mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-05 22:07:10 -04:00
2 lines
10 KiB
JavaScript
2 lines
10 KiB
JavaScript
![]() |
import{q as b,a0 as H,i as A,n as O,r as $,w as j,A as W,a1 as S,ac as I}from"./chunk-449c23a2.js";import{_ as D}from"./chunk-cf010ec4.js";function F(o){return typeof o=="function"?o():b(o)}const C=F;typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;function _(o,t={},e){for(const s in o){const r=o[s],n=e?`${e}:${s}`:s;typeof r=="object"&&r!==null?_(r,t,n):typeof r=="function"&&(t[n]=r)}return t}const U={run:o=>o()},q=()=>U,T=typeof console.createTask<"u"?console.createTask:q;function x(o,t){const e=t.shift(),s=T(e);return o.reduce((r,n)=>r.then(()=>s.run(()=>n(...t))),Promise.resolve())}function B(o,t){const e=t.shift(),s=T(e);return Promise.all(o.map(r=>s.run(()=>r(...t))))}function h(o,t){for(const e of[...o])e(t)}class K{constructor(){this._hooks={},this._before=void 0,this._after=void 0,this._deprecatedMessages=void 0,this._deprecatedHooks={},this.hook=this.hook.bind(this),this.callHook=this.callHook.bind(this),this.callHookWith=this.callHookWith.bind(this)}hook(t,e,s={}){if(!t||typeof e!="function")return()=>{};const r=t;let n;for(;this._deprecatedHooks[t];)n=this._deprecatedHooks[t],t=n.to;if(n&&!s.allowDeprecated){let i=n.message;i||(i=`${r} hook has been deprecated`+(n.to?`, please use ${n.to}`:"")),this._deprecatedMessages||(this._deprecatedMessages=new Set),this._deprecatedMessages.has(i)||(console.warn(i),this._deprecatedMessages.add(i))}if(!e.name)try{Object.defineProperty(e,"name",{get:()=>"_"+t.replace(/\W+/g,"_")+"_hook_cb",configurable:!0})}catch{}return this._hooks[t]=this._hooks[t]||[],this._hooks[t].push(e),()=>{e&&(this.removeHook(t,e),e=void 0)}}hookOnce(t,e){let s,r=(...n)=>(typeof s=="function"&&s(),s=void 0,r=void 0,e(...n));return s=this.hook(t,r),s}removeHook(t,e){if(this._hooks[t]){const s=this._hooks[t].indexOf(e);s!==-1&&this._hooks[t].splice(s,1),this._hooks[t].length===0&&delete this._hooks[t]}}deprecateHook(t,e){this._deprecatedHooks[t]=typeof e=="string"?{to:e}:e;const s=this._hooks[t]||[];delete this._hooks[t];for(const r of s)this.hook(t,r)}deprecateHooks(t){Object.assign(this._deprecatedHooks,t);for(const e in t)this.deprecateHook(e,t[e])}addHooks(t){const e=_(t),s=Object.keys(e).map(r=>this.hook(r,e[r]));return()=>{for(const r of s.splice(0,s.length))r()}}removeHooks(t){const e=_(t);for(const s in e)this.removeHook(s,e[s])}removeAllHooks(){for(const t in this._hooks)delete this._hooks[t]}callHook(t,...e){return e.unshift(t),this.callHookWith(x,t,...e)}callHookParallel(t,...e){return e.unshift(t),this.callHookWith(B,t,...e)}callHookWith(t,e,...s){const r=this._before||this._after?{name:e,args:s,context:{}}:void 0;this._before&&h(this._before,r);const n=t(e in this._hooks?[...this._hooks[e]]:[],s);return n instanceof Promise?n.finally(()=>{this._after&&r&&h(this._after,r)}):(this._after&&r&&h(this._after,r),n)}beforeEach(t){return this._before=this._before||[],this._before.push(t),()=>{if(this._before!==void 0){const e=this._before.indexOf(t);e!==-1&&this._before.splice(e,1)}}}afterEach(t){return this._after=this._after||[],this._after.push(t),()=>{if(this._after!==void 0){const e=this._after.indexOf(t);e!==-1&&this._after.splice(e,1)}}}}function M(){return new K}const L=["base","meta","link","style","script","noscript"],V=["title","titleTemplate","base","htmlAttrs","bodyAttrs","meta","link","style","script","noscript"],R=["tagPosition","tagPriority","tagDuplicateStrategy"];function G(o,t){const e={tag:o,props:{}};return o==="title"||o==="titleTemplate"?(e.children=t,e):(e.props=Q({...t}),["children","innerHtml","innerHTML"].forEach(s=>{typeof e.props[s]<"u"&&(e.children=e.props[s],delete e.props[s])}),Object.keys(e.props).filter(s=>R.includes(s)).forEach(s=>{e[s]=e.props[s],delete e.props[s]}),typeof e.props.class=="object"&&!Array.isArray(e.props.class)&&(e.props.class=Object.keys(e.props.class).filter(s=>e.props.class[s])),Array.isArray(e.props.class)&&(e.props.class=e.props.class.join(" ")),e.props.content&&Array.isArray(e.props.content)?e.props.content.map((s,r)=>{const n={...e,props:{...e.props}};return n.props.content=s,n.key=`${e.props.name||e.props.property
|