PageSourceSearch

https://fosstodon.org/packs/helmet-C5cFHKKR.js

js fosstodon.org collected 2026-09-24 06:56:22 UTC 15,939 bytes, 2 lines download raw bytes

1import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{t}from"./react-C21x__mS.js";import{t as n}from"./defineProperty-BbfpZ9Tg.js";var r=e(t(),1);function i(e,t){if(typeof t==`function`&&t.key&&e.plugins.has(t.key))return;let n=typeof t==`function`?t(e):t,r=n.key||String(e.plugins.size+1);if(!e.plugins.get(r)){e.plugins.set(r,n);for(let t in n.hooks||{})e.hooks?.hook(t,n.hooks[t])}}function a(e,t={}){let n=!t.document,r=new Map,a={_entryCount:1,_h:0,plugins:new Map,resolvedOptions:t,ssr:n,entries:r,hooks:void 0,render:()=>e(a),use:e=>i(a,e),push(e,t){let i=t?._index??a._entryCount++,o=t?{...t}:{};delete o.head,delete o.onRendered,delete o._index;let s={_i:i,input:e,options:o};return r.set(i,s),{_i:i,dispose(){r.delete(i)},patch(e){n?(s.input=e,delete s._tags):s._pending=e,r.has(i)||r.set(i,s)}}}};return t.init?.forEach(e=>e&&a.push(e)),a}var o=new Set([`link`,`style`,`script`,`noscript`]),s=new Set([`title`,`titleTemplate`,`script`,`style`,`noscript`]),c=new Set([`base`,`meta`,`link`,`style`,`script`,`noscript`]),l=new Set([`title`,`base`,`htmlAttrs`,`bodyAttrs`,`meta`,`link`,`style`,`script`,`noscript`]),u=new Set([`base`,`title`,`titleTemplate`,`bodyAttrs`,`htmlAttrs`,`templateParams`]),d=new Set([`key`,`tagPosition`,`tagPriority`,`tagDuplicateStrategy`,`innerHTML`,`textContent`,`processTemplateParams`]),f=new Set([`templateParams`,`htmlAttrs`,`bodyAttrs`]),p=new Set([`theme-color`,`google-site-verification`,`author`,`og:locale:alternate`,`og:image`,`og:video`,`og:audio`,`article:author`,`article:tag`,`book:author`,`book:tag`,`twitter:image`]),m={critical:-8,high:-1,low:2},h=e=>typeof e==`number`?Number.isFinite(e):e;function g(e){return e===`__proto__`||e===`constructor`||e===`prototype`}function _(e,t,n,r){for(let i=n;i<e.length;i+=1)try{let n=r?r.run(()=>e[i](...t)):e[i](...t);if(n&&typeof n.then==`function`)return Promise.resolve(n).then(()=>_(e,t,i+1,r))}catch(e){return Promise.reject(e)}}var v=class{constructor(){n(this,`_hooks`,void 0),this._hooks={}}hook(e,t){return!e||typeof t!=`function`?()=>{}:(this._hooks[e]=this._hooks[e]||[],this._hooks[e].push(t),()=>{t&&=(this.removeHook(e,t),void 0)})}removeHook(e,t){let n=this._hooks[e];if(n){let r=n.indexOf(t);r!==-1&&n.splice(r,1),n.length===0&&(this._hooks[e]=void 0)}}callHook(e,...t){let n=this._hooks[e];if(!(!n||n.length===0))return _(n,t,0)}};function y(e){let t=new v;for(let n in e||{})t.hook(n,e[n]);return t}function b(e,t,n){if(e.hooks?._hooks?.[t]?.length)return e.hooks?.callHook(t,n)}function x(e,t,n){let r=e.push,a=e;return a.ssr=!1,a.hooks=t,a.dirty=!!a.dirty,a.use=e=>i(a,e),a.render=()=>n(a),a.invalidate=()=>{for(let e of a.entries.values())delete e._tags;a.dirty=!0,t.callHook(`entries:updated`,a)},a.push=(n,i)=>{let o=i?.onRendered?t.hook(`dom:rendered`,i.onRendered):void 0,s=r(n,i),c=e.entries.get(s._i);return c&&(c._o=n),a.dirty=!0,t.callHook(`entries:updated`,a),{_i:s._i,patch(e){s.patch(e),a.dirty=!0,t.callHook(`entries:updated`,a)},dispose(){o?.(),e.entries.has(s._i)&&(s.dispose(),a.invalidate())}}},t.hook(`entries:updated`,()=>{a.render()}),a}var S=/^(?:viewport|description|keywords|robots)$/,C=[`name`,`property`,`http-equiv`];function w(e){let t=e.indexOf(`:`);if(t===-1)return!1;let n=e.slice(t+1);return p.has(n)||n.startsWith(`og:image:`)||n.startsWith(`og:video:`)||n.startsWith(`og:audio:`)||n.startsWith(`twitter:image:`)}function T(e){let{props:t,tag:n,key:r}=e;if(u.has(n))return n;if(n===`link`){if(t.rel===`canonical`)return`canonical`;if(t.rel===`alternate`&&t.hreflang)return`alternate:${t.hreflang}`}if(t.charset)return`charset`;if(n===`meta`)for(let e of C){let n=t[e];if(n!==void 0)return`meta:${n}${(typeof n!=`string`||!n.includes(`:`))&&!S.test(n)&&r?`:key:${r}`:``}`}return r?`${n}:key:${r}`:t.id?`${n}:id:${t.id}`:n===`link`&&t.rel&&t.href?`link:${t.rel}:${t.href}`:s.has(n)&&(e.textContent||e.innerHTML)?`${n}:content:${e.textContent||e.innerHTML}`:void 0}function E(e){let t=e._h||e._d||e.textContent||e.innerHTML;if(t)return t;let n=Object.keys(e.props).sort(),r=`${e.tag}:`,i=``;for(let t of n)r+=`${i}${t}:${String(e.props[t])}`,i=`,`;return r}function D(e,t,n){if(n===`_resolver`)return e;typeof e==`function`&&(!n||n!==`titleTemplate`&&!n.startsWith(`on`))&&(e=e());let r=t?t(n,e):e;if(Array.isArray(r)){let e;for(let n=0;n<r.length;n++){let i=D(r[n],t);e?e[n]=i:i!==r[n]&&(e=r.slice(0,n),e[n]=i)}return e||r}if(r?.constructor===Object){let e;for(let n in r){let i=g(n),a=i?void 0:D(r[n],t,n);if(!e&&(i||a!==r[n])){e={};for(let t in r){if(t===n)break;e[t]=r[t]}}e&&!i&&(e[n]=a)}return e||r}return r}var O=/[\s"'<>/=\x00-\x1F\x7F]/;function ee(e,t){let n=e===`style`,r=n?new Map:new Set,i=e=>{if(e){if(n){let t=e.indexOf(`:`);t>0&&r.set(e.slice(0,t).trim(),e.slice(t+1).trim())}
1else e.split(` `).forEach(e=>e&&r.add(e))}};if(typeof t==`string`)(n?t.split(`;`):[t]).forEach(i);else if(Array.isArray(t))t.forEach(i);else if(t&&typeof t==`object`)for(let e in t){let a=t[e];a&&a!==`false`&&(n?r.set(e.trim(),String(a)):i(e))}return r}function k(e,t){if(e.props=e.props||{},!t)return e;if(e.tag===`templateParams`)return e.props=t,e;let n=c.has(e.tag)||e.tag===`htmlAttrs`||e.tag===`bodyAttrs`;for(let r in t){if(g(r))continue;let i=r.startsWith(`data-`),a=n&&!d.has(r),o=a&&!i?r.toLowerCase():r;if(a&&(!o||O.test(o)))continue;let s=t[r];if(s===null)e.props[o]=null;else if(r===`class`||r===`style`)e.props[r]=ee(r,s);else if(d.has(r)){if((r===`textContent`||r===`innerHTML`)&&typeof s==`object`){let n=t.type||`application/json`;(n.endsWith(`json`)||n===`speculationrules`||n===`importmap`)&&(e.props.type=t.type=n,e[r]=JSON.stringify(s))}else e[r]=s}else if(s!==void 0){let t=String(s),n=e.tag===`meta`&&o===`content`;e.props[o]=t===`true`||t===``?i||n?t:!0:!s&&i&&t===`false`?`false`:s}}return e}function A(e,t){let n;return t.length&&(n=(e,n)=>{for(let r=0;r<t.length;r++)n=t[r](e,n);return n},e=n(void 0,e)),D(e,n)}function j(e,t){let n=k({tag:e,props:{}},typeof t==`object`&&typeof t!=`function`?t:{[e===`script`||e===`noscript`||e===`style`?`innerHTML`:`textContent`]:t});if(n.key&&o.has(n.tag)&&(n.props[`data-hid`]=n._h=n.key),n.tag===`script`&&typeof n.innerHTML==`object`&&(n.innerHTML=JSON.stringify(n.innerHTML),n.props.type=n.props.type||`application/json`),Array.isArray(n.props.content)){let e=[];for(let t of n.props.content)e.push({...n,props:{...n.props,content:t}});return e}return n}function M(e,t){if(Array.isArray(t))for(let n of t)e.push(n);else e.push(t)}function N(e,t){if(!e)return[];typeof e==`function`&&(e=e()),e=A(e,t);let n=[];for(let t in e){let r=e[t];if(r!==void 0){if(Array.isArray(r))for(let e of r)M(n,j(t,e));else M(n,j(t,r))}}return n}var P=/</g,F=/<\/script/g,I=(e,t)=>e._w===t._w?e._p-t._p:e._w-t._w,L=()=>100;function R(e){for(let t in e)return!1;return!0}var z=/^tags:|:render/;function B(e,t){let n=(t[`entries:resolve`]?.length||0)+(t[`entries:normalize`]?.length||0);if(e._h!==n){e._h=n;for(let t of e.entries.values())delete t._tags}}function V(e){for(let t=0;t<e.length;t++){let n=e[t],r={...n.props};r.class instanceof Set&&(r.class=new Set(r.class)),r.style instanceof Map&&(r.style=new Map(r.style)),e[t]={...n,props:r}}}function H(e,t){let n=e.tags,r=0;for(let t of e.tagMap.values())if(Array.isArray(t))for(let e of t)n[r++]=e;else n[r++]=t;n.length=r,t&&n.sort(I)}function U(e){let t=!1;for(let n of e.tags.sort(I)){let r=n._d||E(n);if(!r)continue;let i=e.tagMap.get(r);if(!i){e.tagMap.set(r,n);continue}if((n.tagDuplicateStrategy||(f.has(n.tag)?`merge`:null)||(n.key&&n.key===i.key?`merge`:null))===`merge`){let t={...i.props};for(let e in n.props)t[e]=e===`style`?new Map([...i.props.style||new Map,...n.props[e]]):e===`class`?new Set([...i.props.class||[],...n.props[e]]):n.props[e];e.tagMap.set(r,{...n,props:t})}else n._p>>10==i._p>>10&&n.tag===`meta`&&w(r)?(e.tagMap.set(r,Object.assign([...Array.isArray(i)?i:[i],n],n)),t=!0):(n._w===i._w?n._p>i._p:n._w<i._w)&&e.tagMap.set(r,n)}return t}function W(e,t){let n=e.tagMap.get(`title`),r=e.tagMap.get(`titleTemplate`);if(t._title=n?.textContent,!r)return;let i=r.textContent;if(t._titleTemplate=i,!i)return;let a=typeof i==`function`?i(n?.textContent):i;typeof a==`string`&&!t.plugins.has(`template-params`)&&(a=a.replace(`%s`,n?.textContent||``)),n?a===null?e.tagMap.delete(`title`):e.tagMap.set(`title`,{...n,textContent:a}):e.tagMap.set(`titleTemplate`,{...r,tag:`title`,textContent:a})}function G(e){let t=0;for(let n of e){let{innerHTML:r,tag:i,props:a}=n;if(!(!l.has(i)||R(a)&&!h(r)&&!h(n.textContent))&&!(i===`meta`&&!h(a.content)&&!a[`http-equiv`]&&!a.charset)){if(i===`script`&&(r||n.textContent)){let e=String(a.type),t=e.endsWith(`json`)||e===`importmap`||e===`speculationrules`,i=e=>t?(typeof e==`string`?e:JSON.stringify(e)).replace(P,`\\u003C`):typeof e==`string`?e.replace(F,`<\\/script`):e;n={...n},r&&(n.innerHTML=i(r)),n.textContent&&(n.textContent=i(n.textContent)),n._d=T(n)}e[t++]=n}}return e.length=t,e}function K(e,t){let n=t?.tagWeight??e.resolvedOptions._tagWeight??L,r={tagMap:new Map,tags:[]},i=e.hooks?._hooks||{};B(e,i);for(let t of e.entries.values())t._pending!==void 0&&(t.input=t._pending,delete t._pending,delete t._tags,delete t._precomputedTags);let a;(i[`entries:resolve`]?.length||i[`entries:normalize`]?.length)&&(a=[...e.entries.values()],i[`entries:resolve`]?.length&&b(e,`entries:resolve`,{entr
1ies:a,...r})),B(e,i);for(let t of a||e.entries.values()){let a=t._tags;if(!a){if(t._precomputedTags&&n===e.resolvedOptions._tagWeight&&!i[`entries:normalize`]?.length&&!i[`entries:resolve`]?.length&&(!t.options||R(t.options)))a=t._precomputedTags;else{if(a=N(t.input,e.resolvedOptions.propResolvers||[]),t.options&&!R(t.options))for(let e of a)Object.assign(e,t.options);if(i[`entries:normalize`]?.length){let n={tags:a,entry:t};b(e,`entries:normalize`,n),a=n.tags}for(let e=0;e<a.length;e++){let r=a[e];r._w=n(r),r._p=(t._i<<10)+e,r._d=T(r),r._d||(r._h=E(r))}t._tags=a}}r.tags.push(...a)}for(let e in i)if(i[e]?.length&&z.test(e)){V(r.tags);break}let o=U(r);return W(r,e),H(r,o),b(e,`tags:beforeResolve`,r),b(e,`tags:resolve`,r),b(e,`tags:afterResolve`,r),G(r.tags)}var q=/\s+/;function J(e={}){return t=>Z(t,e)}function Y(e){for(let t of e.entries.values())if(t._pending!==void 0)return!0;return!1}function X(e,t){let n={_d:t,_t:t.title,_e:new Map([[`htmlAttrs`,t.documentElement],[`bodyAttrs`,t.body]]),_p:{},_s:{},_l:new Map};for(let e of[...t.body.children,...t.head.children]){let t=e.tagName.toLowerCase();if(!c.has(t))continue;let r={innerHTML:e.innerHTML};for(let t of e.getAttributeNames())r[t]=e.getAttribute(t);let i=k({tag:t,props:{}},r);i.key=e.getAttribute(`data-hid`)||void 0;let a=T(i)||E(i),o=a,s=1;for(;n._e.has(o);)o=`${a}:${s++}`;n._e.set(o,e)}for(let t of e.entries.values())if(t._o!==void 0){let e=t._o;for(let t of[`bodyAttrs`,`htmlAttrs`]){let r=e[t]?.class;if(typeof r==`string`){let e=n._e.get(t);for(let i of r.split(q))i&&(n._p[`${t}:attr:class:${i}`]=()=>e.classList.remove(i))}}}return n}function Z(e,t={}){let n=t.document||e.resolvedOptions.document,r=e._dom,i=!!r&&r._d!==n;if(!n||r&&!i&&!e.dirty&&!Y(e)||e._du)return!1;let a=n.defaultView;e._du=!0;let o=!1;try{let i=function(e,t,n){f._s[e]=!n&&p[e]||t,delete p[e]},s=function(e,t,n,r,a,o){let s=`${e}:event:${t}`,c=f._l.get(s);if(c&&c[0]===o&&c[1]===n&&c[2]===r){i(s,c[4]);return}c?.[4]();let l=`data-${t}`,u=(e=>r.call(a,e)),d=()=>{o.removeEventListener(n,u),a.getAttribute(l)===``&&a.removeAttribute(l),f._l.get(s)?.[3]===u&&f._l.delete(s)};o.addEventListener(n,u),f._l.set(s,[o,n,r,u,d]),a.setAttribute(l,``),i(s,d,!0)},l=function({id:e,$el:t,tag:n}){let r=n.tag.endsWith(`Attrs`);if(f._e.set(e,t),!r){let r=n.textContent;r!=null&&r!==``&&(r!==t.textContent&&(t.textContent=r),i(`${e}:text`,()=>{t.textContent===r&&(t.textContent=``)},!0));let a=n.innerHTML;a!=null&&a!==``&&(a!==t.innerHTML&&(t.innerHTML=a),i(`${e}:html`,()=>{t.innerHTML===a&&(t.innerHTML=``)},!0));let o=`${e}:el`;i(o,p[o]||(()=>{t?.remove(),f._e.delete(e)}))}for(let r in n.props){let o=n.props[r];if(r[0]===`o`&&r[1]===`n`&&typeof o==`function`){let i=r.slice(2);t?.dataset?.[`${r}fired`]&&o.call(t,new((a?.Event)||Event)(i)),s(e,r,i,o,t,n.tag===`bodyAttrs`&&a?a:t);continue}let c=`${e}:attr:${r}`;if(r===`class`&&o)for(let e of o){let n=`${c}:${e}`;i(n,p[n]||(()=>t.classList.remove(e))),t.classList.contains(e)||t.classList.add(e)}else if(r===`style`&&o)for(let[e,n]of o){let r=`${c}:${e}`;i(r,p[r]||(()=>t.style.removeProperty(e))),t.style.setProperty(e,n)}else o!==!1&&o!==null&&(t.getAttribute(r)!==o&&t.setAttribute(r,o===!0?``:String(o)),i(c,p[c]||(()=>t.removeAttribute(r))))}},u={shouldRender:!0,tags:[]};if(b(e,`dom:beforeRender`,u),!u.shouldRender)return!1;let d=r;if(d?._d!==n){if(d){for(let e in d._s)d._s[e]();for(let e in d._p)d._p[e]();d._s=d._p={},d._e.clear(),d._l.clear()}d=void 0}d?d._p=d._s:d=X(e,n),d._s={};let f=d,p=f._p,m=[],h={};e.dirty=!1;let g=K(e,t.tagWeight?{tagWeight:t.tagWeight}:void 0),_=[],v={};for(let e of g){let t=v[e._d]||0,r=(t?`${e._d}:${t}`:e._d)||e._h,a={tag:e,id:r,shouldRender:!0};if(e.tag===`meta`&&e._d&&w(e._d)&&(v[e._d]=t+1),_.push(a),e.tag===`title`){n.title=e.textContent,i(`title:`,()=>n.title=f._t);continue}a.$el=f._e.get(r),a.$el?l(a):c.has(e.tag)&&m.push(a)}for(let e of m)e.$el=n.createElement(e.tag.tag),l(e),(h[e.tag.tagPosition||`head`]??=n.createDocumentFragment()).appendChild(e.$el);h.head&&n.head.appendChild(h.head),h.bodyOpen&&n.body.insertBefore(h.bodyOpen,n.body.firstChild),h.bodyClose&&n.body.appendChild(h.bodyClose);for(let e in p)p[e]();e._dom=f,o=!0,b(e,`dom:rendered`,{renders:_})}catch(t){throw e.dirty=!0,t}finally{e._du=!1}return o&&(e.dirty||Y(e))&&Z(e,t),o}var Q=e=>typeof e.tagPriority==`number`?e.tagPriority:100+(m[e.tagPriority]||0);function te(e={}){e.document=e.document||(typeof window<`u`?document:void 0);let t=e.render||J({document:e.document}),n=x(a(t,{document:e.document,propResolvers:e.propResolvers,_tagWeight:Q,init:[]}),y(e.hooks),t);
1return e.plugins?.forEach(e=>n.use(e)),e.init?.forEach(e=>e&&n.push(e)),n}function ne(e,t){let n=0;return()=>{let r=++n;t(()=>{n===r&&e()})}}var re=(0,r.createContext)(null),$=null;function ie(){let e=(0,r.useContext)(re);if(e)return e;if(!$){if(typeof window>`u`)throw TypeError(`Helmet requires UnheadProvider on the server. Wrap your app with <UnheadProvider>.`);let e=J(),t;t=te({render:ne(()=>e(t),e=>setTimeout(e,0))}),$=t}return $}var ae=({children:e,defaultTitle:t,titleTemplate:n,onChangeClientState:i,title:a,base:o,meta:u,link:d,script:f,style:p,noscript:m,htmlAttributes:h,bodyAttributes:g,encodeSpecialCharacters:_,defer:v})=>{let y=ie(),b=(0,r.useMemo)(()=>r.Children.toArray(e).filter(r.isValidElement),[e]),x=(0,r.useCallback)(()=>{let e={};n&&(e.titleTemplate=t?e=>e?n:t:n),a!=null&&(e.title=a),o&&(e.base=o),u&&(e.meta=[...u]),d&&(e.link=[...d]),f&&(e.script=[...f]),p&&(e.style=[...p]),m&&(e.noscript=[...m]),h&&(e.htmlAttrs=h),g&&(e.bodyAttrs=g);let r=!!a;for(let t of b){let{type:n,props:i}=t,a=String(n);if(a===`html`?a=`htmlAttrs`:a===`body`&&(a=`bodyAttrs`),!l.has(a))continue;let o={...typeof i==`object`?i:{}};if(s.has(a)&&o.children!=null){let e=a===`script`?`innerHTML`:`textContent`;o[e]=Array.isArray(o.children)?o.children.map(String).join(``):String(o.children)}if(delete o.children,a===`title`&&(r=!0),c.has(a)){let t=a;Array.isArray(e[t])||(e[t]=[]),e[t].push(o)}else e[a]=o}return!r&&t&&!n&&(e.title={textContent:t,tagPriority:`low`}),e},[b,n,t,a,o,u,d,f,p,m,h,g]),S=(0,r.useRef)(null),C=(0,r.useRef)(i);return C.current=i,y.ssr&&!S.current&&(S.current=y.push(x())),(0,r.useEffect)(()=>(S.current=y.push(x(),{onRendered:()=>{let e=C.current;if(!e)return;let t={title:document.querySelector(`title`)?.textContent||``};for(let e of[`meta`,`link`,`script`,`style`,`base`])t[`${e}Tags`]=Array.from(document.querySelectorAll(`head ${e}`));e(t,{},{})}}),()=>{S.current?.dispose(),S.current=null}),[y]),(0,r.useEffect)(()=>{S.current?.patch(x())},[x]),null};export{ae as t};
2//# sourceMappingURL=helmet-C5cFHKKR.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.