@pictogrammers/element-esbuild 0.0.19 → 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/element-build.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
3
|
-
import{fileURLToPath as
|
|
4
|
-
`),loader:"js"}})}}}var
|
|
5
|
-
`),resolveDir:$(process.cwd(),
|
|
3
|
+
import{fileURLToPath as ge,pathToFileURL as he}from"node:url";import{build as $e}from"esbuild";import{join as oe,sep as z}from"node:path";import{readFile as se}from"node:fs/promises";function V(e){return e.replace(/-([a-z])/g,a=>a[1].toUpperCase())}var re="node_modules",ae=process.cwd(),ie=ae.split(z).length,ce=e=>`\x1B[31m${e}\x1B[0m`;function B({localNamespaces:e,externalNamespaces:a}){return{name:"html-dependents-plugin",setup(m){m.onLoad({filter:/\.html$/},async d=>{let A=d.path.split(z).splice(ie),[M,E,g,c,...P]=A,y=await se(d.path,"utf8"),o=y.matchAll(/<\/(?<namespace>\w+)-(?<value>[^>]+)/g),t=new Map;for(let l of o){let{namespace:f,value:i}=l.groups,n=V(i);t.set(`${f}-${n}`,[f,n])}let p=[];return t.forEach(([l,f])=>{let i=A.length-4,n=new Array(i).fill("..");if(l===g){if(f===c)return;p.push(`import './${n.join("/")}/${f}/${f}';`)}else if(e.includes(l))p.push(`import './${n.join("/")}/${l}/${f}/${f}';`);else if(a.has(l)){n.push(".."),n.push(".."),n.push("..");let s=process.env.INIT_CWD;if(s){let C=oe(s,"node_modules");console.log("Node modules directory:",C)}else console.log("INIT_CWD not available. The script was likely not run via `npm run`.");let u=a.get(l);p.push(`import './${n.join("/")}/${re}/${u}/${l}/${f}/${f}';`)}else console.log(ce(`Unable to find namespace folder "${l}". Possibly missing 'external' in element.config.ts`)),process.exit()}),p.push(`export default \`${y}\`;`),{contents:p.join(`
|
|
4
|
+
`),loader:"js"}})}}}var le=e=>`\x1B[32m${e}\x1B[0m`,Z={name:"rebuild-notify",setup(e){e.onEnd(a=>{a.errors.length>0?console.error(`Build ended with ${a.errors.length} errors`):console.log(le("Build succeeded!"))})}};import{access as pe}from"node:fs/promises";import{constants as me}from"node:fs";async function x(e){try{return await pe(e,me.F_OK),!0}catch{return!1}}import{copyFile as X,writeFile as ye}from"node:fs/promises";import{dirname as Ce,join as b}from"node:path";import{join as $}from"node:path";import{readdir as ue}from"node:fs/promises";async function D(e){let a=[];try{let m=await ue(e,{withFileTypes:!0});for(let d of m)d.isDirectory()&&a.push(d.name)}catch(m){console.error("Error reading directory:",m)}return a}import{access as fe}from"node:fs/promises";import{constants as de}from"node:fs";async function H(e){try{return await fe(e,de.F_OK),!0}catch{return!1}}import{readFile as S}from"node:fs/promises";function I(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}function T(e){return e.replace(/([a-zA-Z])(?=[A-Z])/g,"$1-").toLowerCase()}var O=e=>`\x1B[31m${e}\x1B[0m`,at=process.cwd();var v="src",w="components";function J(e){return{name:"playground-plugin",setup(a){let m="playground-entry",d="playground-module";a.onResolve({filter:new RegExp(`^${m}$`)},A=>({path:m,namespace:d})),a.onLoad({filter:/.*/,namespace:d},async A=>{let M=[],E=await D($(v,w));E.length===0&&(console.log(O('Missing at least 1 namespace folder under "src/components/"')),process.exit());let g=[];for(let c of E){let P={namespace:c,components:[]};g.push(P);let y=$(v,w,c),o=await D(y);for(let t of o)if(await x($(v,w,c,t,`${t}.ts`))){let p="";await x($(v,w,c,t,"README.md"))&&(p=await S($(v,w,c,t,"README.md"),"utf8"));let l={namespace:c,component:t,tag:`${c}-${T(t)}`,examples:[],className:"",classExtends:"",readme:p};if(M.push(`import '${w}/${c}/${t}/${t}';`),await H($(y,t,"__examples__"))){let n=await D($(y,t,"__examples__"));for(let s of n)await x($(y,t,"__examples__",s,`${s}.ts`))?(M.push(`import '${w}/${c}/${t}/__examples__/${s}/${s}';`),l.examples.push({namespace:c,component:t,example:s,tag:`x-${c}-${T(t)}-${T(s)}`,className:`X${I(c)}${I(t)}${I(s)}`})):console.log(O(`Missing ${w}/${c}/${t}/__examples__/${s}/${s}.ts`))}let i=(await S($(v,w,c,t,`${t}.ts`),"utf8")).match(/class (\w+) extends (\w+)/);i||(console.log(O(`Component "${c}-${t}" must extend HtmlElement or base class`)),process.exit()),l.className=i[1],l.classExtends=i[2],P.components.push(l)}}return e.after(g),{contents:M.join(`
|
|
5
|
+
`),resolveDir:$(process.cwd(),v)}})}}}import{join as k}from"node:path";import{readFile as K}from"node:fs/promises";async function W({mode:e,rootDir:a,srcDir:m,indexFile:d,defaultDir:A,playgroundFile:M,title:E,repo:g,repoComponent:c,navigation:P,namespaces:y}){let o="";await x(k(a,m,d))?o=await K(k(a,m,d),"utf8"):o=await K(k(A,M),"utf8"),o=o.replace("<title>Default</title>",`<title>${E??"Default"}</title>`),o=o.replace("<h1>Default</h1>",`<h1>${E??"Default"}</h1>`);let t=structuredClone(P??[]);for(let i of t)i.items=[];let p;t.length===0?(p={label:"Components",items:[]},t.push(p)):(p=t.find(i=>!i.extends&&!i.components&&!i.namespaces),p||(p={label:"Other",items:[]},t.push(p)));let l=new Map;if(y.forEach(({components:i})=>{i.forEach(({component:n,namespace:s,tag:u,readme:C,examples:N,className:h,classExtends:F})=>{l.set(h,{className:h,classExtends:F,component:n,namespace:s,tag:u,readme:C,examples:N.map(r=>r.className)}),N.forEach(r=>{l.set(r.className,{className:r.className,classExtends:r.classExtends,component:r.component,namespace:r.namespace,tag:r.tag,example:r.example})});for(let r of t)if(r.include&&r.include.includes(h)){r.items.push({namespace:s,component:n,className:h,tag:u});return}for(let r of t)if(r!==p&&!(r.exclude&&r.exclude.includes(h))&&!(r.namespaces&&!r.namespaces.includes(s))&&!(r.extends&&!r.extends.includes(F))){r.items.push({namespace:s,component:n,className:h,tag:u});return}p.items.push({namespace:s,component:n,examples:N,className:h,tag:u})})}),o=o.replace(/([ ]*)<!-- \[Navigation\] -->/,(i,n)=>t.map(({label:s,items:u})=>[n,`<div>${s}</div>`,"<ul>",u.map(({component:C,namespace:N,tag:h,className:F})=>[`<li data-tag="${h}" data-class-name="${F}" data-component="${C}"><a href="#${h}">${C}</a></li>`].join(`
|
|
6
6
|
${n}`)).join(`
|
|
7
7
|
${n}`),"</ul>"].join(`
|
|
8
8
|
${n}`)).join(`
|
|
9
|
-
${n}`)),g){let s=g.includes("github.com")?"M12,2A10,10 0 0,0 2,12C2,16.42 4.87,20.17 8.84,21.5C9.34,21.58 9.5,21.27 9.5,21C9.5,20.77 9.5,20.14 9.5,19.31C6.73,19.91 6.14,17.97 6.14,17.97C5.68,16.81 5.03,16.5 5.03,16.5C4.12,15.88 5.1,15.9 5.1,15.9C6.1,15.97 6.63,16.93 6.63,16.93C7.5,18.45 8.97,18 9.54,17.76C9.63,17.11 9.89,16.67 10.17,16.42C7.95,16.17 5.62,15.31 5.62,11.5C5.62,10.39 6,9.5 6.65,8.79C6.55,8.54 6.2,7.5 6.75,6.15C6.75,6.15 7.59,5.88 9.5,7.17C10.29,6.95 11.15,6.84 12,6.84C12.85,6.84 13.71,6.95 14.5,7.17C16.41,5.88 17.25,6.15 17.25,6.15C17.8,7.5 17.45,8.54 17.35,8.79C18,9.5 18.38,10.39 18.38,11.5C18.38,15.32 16.04,16.16 13.81,16.41C14.17,16.72 14.5,17.33 14.5,18.26C14.5,19.6 14.5,20.68 14.5,21C14.5,21.27 14.66,21.59 15.17,21.5C19.14,20.16 22,16.42 22,12A10,10 0 0,0 12,2Z":"M6,2H18A2,2 0 0,1 20,4V20A2,2 0 0,1 18,22H6A2,2 0 0,1 4,20V4A2,2 0 0,1 6,2M12.75,13.5C15.5,13.5 16.24,11.47 16.43,10.4C17.34,10.11 18,9.26 18,8.25C18,7 17,6 15.75,6C14.5,6 13.5,7 13.5,8.25C13.5,9.19 14.07,10 14.89,10.33C14.67,11 14,12 12,12C10.62,12 9.66,12.35 9,12.84V8.87C9.87,8.56 10.5,7.73 10.5,6.75C10.5,5.5 9.5,4.5 8.25,4.5C7,4.5 6,5.5 6,6.75C6,7.73 6.63,8.56 7.5,8.87V15.13C6.63,15.44 6,16.27 6,17.25C6,18.5 7,19.5 8.25,19.5C9.5,19.5 10.5,18.5 10.5,17.25C10.5,16.32 9.94,15.5 9.13,15.18C9.41,14.5 10.23,13.5 12.75,13.5M8.25,16.5A0.75,0.75 0 0,1 9,17.25A0.75,0.75 0 0,1 8.25,18A0.75,0.75 0 0,1 7.5,17.25A0.75,0.75 0 0,1 8.25,16.5M8.25,6A0.75,0.75 0 0,1 9,6.75A0.75,0.75 0 0,1 8.25,7.5A0.75,0.75 0 0,1 7.5,6.75A0.75,0.75 0 0,1 8.25,6M15.75,7.5A0.75,0.75 0 0,1 16.5,8.25A0.75,0.75 0 0,1 15.75,9A0.75,0.75 0 0,1 15,8.25A0.75,0.75 0 0,1 15.75,7.5Z";o=o.replace(/([ ]*)<!-- \[Repo\] -->/,(
|
|
10
|
-
${
|
|
11
|
-
${n}`)));let
|
|
12
|
-
`)),o=o.replace(/([ ]*)const navigation = \[\];/,(i,n)=>`${n}const navigation = ${JSON.stringify(t,null," ")};`),o}var
|
|
9
|
+
${n}`)),g){let s=g.includes("github.com")?"M12,2A10,10 0 0,0 2,12C2,16.42 4.87,20.17 8.84,21.5C9.34,21.58 9.5,21.27 9.5,21C9.5,20.77 9.5,20.14 9.5,19.31C6.73,19.91 6.14,17.97 6.14,17.97C5.68,16.81 5.03,16.5 5.03,16.5C4.12,15.88 5.1,15.9 5.1,15.9C6.1,15.97 6.63,16.93 6.63,16.93C7.5,18.45 8.97,18 9.54,17.76C9.63,17.11 9.89,16.67 10.17,16.42C7.95,16.17 5.62,15.31 5.62,11.5C5.62,10.39 6,9.5 6.65,8.79C6.55,8.54 6.2,7.5 6.75,6.15C6.75,6.15 7.59,5.88 9.5,7.17C10.29,6.95 11.15,6.84 12,6.84C12.85,6.84 13.71,6.95 14.5,7.17C16.41,5.88 17.25,6.15 17.25,6.15C17.8,7.5 17.45,8.54 17.35,8.79C18,9.5 18.38,10.39 18.38,11.5C18.38,15.32 16.04,16.16 13.81,16.41C14.17,16.72 14.5,17.33 14.5,18.26C14.5,19.6 14.5,20.68 14.5,21C14.5,21.27 14.66,21.59 15.17,21.5C19.14,20.16 22,16.42 22,12A10,10 0 0,0 12,2Z":"M6,2H18A2,2 0 0,1 20,4V20A2,2 0 0,1 18,22H6A2,2 0 0,1 4,20V4A2,2 0 0,1 6,2M12.75,13.5C15.5,13.5 16.24,11.47 16.43,10.4C17.34,10.11 18,9.26 18,8.25C18,7 17,6 15.75,6C14.5,6 13.5,7 13.5,8.25C13.5,9.19 14.07,10 14.89,10.33C14.67,11 14,12 12,12C10.62,12 9.66,12.35 9,12.84V8.87C9.87,8.56 10.5,7.73 10.5,6.75C10.5,5.5 9.5,4.5 8.25,4.5C7,4.5 6,5.5 6,6.75C6,7.73 6.63,8.56 7.5,8.87V15.13C6.63,15.44 6,16.27 6,17.25C6,18.5 7,19.5 8.25,19.5C9.5,19.5 10.5,18.5 10.5,17.25C10.5,16.32 9.94,15.5 9.13,15.18C9.41,14.5 10.23,13.5 12.75,13.5M8.25,16.5A0.75,0.75 0 0,1 9,17.25A0.75,0.75 0 0,1 8.25,18A0.75,0.75 0 0,1 7.5,17.25A0.75,0.75 0 0,1 8.25,16.5M8.25,6A0.75,0.75 0 0,1 9,6.75A0.75,0.75 0 0,1 8.25,7.5A0.75,0.75 0 0,1 7.5,6.75A0.75,0.75 0 0,1 8.25,6M15.75,7.5A0.75,0.75 0 0,1 16.5,8.25A0.75,0.75 0 0,1 15.75,9A0.75,0.75 0 0,1 15,8.25A0.75,0.75 0 0,1 15.75,7.5Z";o=o.replace(/([ ]*)<!-- \[Repo\] -->/,(u,C)=>[C,`<a href="${g}">`,' <svg viewBox="0 0 24 24">',` <path fill="currentColor" d="${s}" />`," </svg>"," <span>View Repo</span>","</a>"].join(`
|
|
10
|
+
${C}`)),o=o.replace(/const repo = '';/,u=>`const repo = '${g}';`),o=o.replace(/const repoComponent = '';/,u=>`const repoComponent = '${c.replace(/\$repo/g,g)}';`),o=o.replace(/const repoIcon = '';/,u=>`const repoIcon = '${s}';`)}e==="dev"&&(o=o.replace(/([ ]*)<!-- \[info\] -->/,(i,n)=>[n,"<p>This page is generated from <code>npm start</code>. To render only specific components use <code>npm start c-button</code>.</p>"].join(`
|
|
11
|
+
${n}`)));let f=[...l.keys()];return o=o.replace(/([ ]*)const componentMap = new Map\(\);/,(i,n)=>[`${n}const componentMap = new Map();`,...f.map(s=>{let u=l.get(s);return`componentMap.set('${s}', ${JSON.stringify(u)});`})].join(`${n}
|
|
12
|
+
`)),o=o.replace(/([ ]*)const navigation = \[\];/,(i,n)=>`${n}const navigation = ${JSON.stringify(t,null," ")};`),o}var U=[Z],L=[],xe=e=>`\x1B[32m${e}\x1B[0m`,we=e=>`\x1B[31m${e}\x1B[0m`,q="node_modules",be="playground.html",_e=ge(import.meta.url),De=Ce(_e),Y=b(De,"..","default"),G="index.html";var j="src",ee="components",te="element.config.ts",_=process.cwd(),R="build",ve=he(te);await x(te)||(console.log(we("Missing element.config.ts in root."),"Add with content:"),console.log("export default {"),console.log(" namespace: 'hello',"),console.log("}"),process.exit());var Ae=await import(ve.href),{namespace:Q,title:Me,repo:Ee,repoComponent:Pe,navigation:je,external:Ne}=Ae.default,Fe=await D(b(_,j,ee)),ne=new Map;for(let e of Ne??[])(await D(b(_,q,...e.split("/")))).forEach(m=>{m!==q&&ne.set(m,e)});U.push(B({localNamespaces:Fe,externalNamespaces:ne}));Q?(console.log(xe("Building app...")),L.push(`./${j}/${ee}/${Q}/app/app.ts`)):(L.push("playground-entry"),U.push(J({after:async e=>{let a=await W({mode:"production",rootDir:_,srcDir:j,indexFile:G,defaultDir:Y,playgroundFile:be,title:Me,repo:Ee,repoComponent:Pe,navigation:je,namespaces:e});await ye(b(_,R,G),a)}})));$e({entryPoints:L,bundle:!0,platform:"browser",outfile:`./${R}/main.js`,sourcemap:!1,minify:!0,format:"esm",target:"es2024",loader:{".html":"text",".css":"text"},plugins:U}).then(async()=>{let e="favicon.svg";await x(b(_,j,e))?await X(b(_,j,e),b(_,R,e)):await X(b(Y,e),b(_,R,e))}).catch(e=>{process.stderr.write(e.stderr),process.exit(1)});
|
package/bin/element-publish.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
3
|
-
console.log("publish");
|
|
3
|
+
import{pathToFileURL as s,fileURLToPath as r}from"node:url";import{join as c,dirname as l}from"node:path";import{access as n}from"node:fs/promises";import{constants as i}from"node:fs";async function t(o){try{return await n(o,i.F_OK),!0}catch{return!1}}var m=o=>`\x1B[31m${o}\x1B[0m`,a=r(import.meta.url),p=l(a),_=c(p,"..","default"),e="element.config.ts",y=process.cwd();var f=s(e);await t(e)||(console.log(m("Missing element.config.ts in root."),"Add with content:"),console.log("export default {"),console.log(" namespace: 'hello',"),console.log("}"),process.exit());var d=await import(f.href),{namespace:P,external:$,title:v,navigation:C,repo:E,repoComponent:L,copy:M}=d.default;console.log("publish");
|
package/bin/element-start.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
3
|
-
import{context as is}from"esbuild";import{EventEmitter as Ie}from"node:events";import{stat as $e}from"node:fs";import{readdir as Te,stat as Ae}from"node:fs/promises";import*as m from"node:path";import{lstat as Pt,readdir as Qt,realpath as te,stat as ee}from"node:fs/promises";import{join as se,relative as ie,resolve as xt,sep as ne}from"node:path";import{Readable as re}from"node:stream";var A={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},at={root:".",fileFilter:i=>!0,directoryFilter:i=>!0,type:A.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(at);var Ct="READDIRP_RECURSIVE_ERROR",oe=new Set(["ENOENT","EPERM","EACCES","ELOOP",Ct]),bt=[A.DIR_TYPE,A.EVERYTHING_TYPE,A.FILE_DIR_TYPE,A.FILE_TYPE],ae=new Set([A.DIR_TYPE,A.EVERYTHING_TYPE,A.FILE_DIR_TYPE]),ce=new Set([A.EVERYTHING_TYPE,A.FILE_DIR_TYPE,A.FILE_TYPE]),le=i=>oe.has(i.code),he=process.platform==="win32",Dt=i=>!0,Rt=i=>{if(i===void 0)return Dt;if(typeof i=="function")return i;if(typeof i=="string"){let t=i.trim();return e=>e.basename===t}if(Array.isArray(i)){let t=i.map(e=>e.trim());return e=>t.some(n=>e.basename===n)}return Dt},ct=class extends re{parents;reading;parent;_stat;_maxDepth;_wantsDir;_wantsFile;_wantsEverything;_root;_isDirent;_statsProp;_rdOptions;_fileFilter;_directoryFilter;constructor(t={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:t.highWaterMark});let e={...at,...t},{root:n,type:s}=e;this._fileFilter=Rt(e.fileFilter),this._directoryFilter=Rt(e.directoryFilter);let a=e.lstat?Pt:ee;he?this._stat=c=>a(c,{bigint:!0}):this._stat=a,this._maxDepth=e.depth!=null&&Number.isSafeInteger(e.depth)?e.depth:at.depth,this._wantsDir=s?ae.has(s):!1,this._wantsFile=s?ce.has(s):!1,this._wantsEverything=s===A.EVERYTHING_TYPE,this._root=xt(n),this._isDirent=!e.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(n,1)],this.reading=!1,this.parent=void 0}async _read(t){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&t>0;){let e=this.parent,n=e&&e.files;if(n&&n.length>0){let{path:s,depth:a}=e,c=n.splice(0,t).map(r=>this._formatEntry(r,s)),o=await Promise.all(c);for(let r of o){if(!r)continue;if(this.destroyed)return;let d=await this._getEntryType(r);d==="directory"&&this._directoryFilter(r)?(a<=this._maxDepth&&this.parents.push(this._exploreDir(r.fullPath,a+1)),this._wantsDir&&(this.push(r),t--)):(d==="file"||this._includeAsFile(r))&&this._fileFilter(r)&&this._wantsFile&&(this.push(r),t--)}}else{let s=this.parents.pop();if(!s){this.push(null);break}if(this.parent=await s,this.destroyed)return}}}catch(e){this.destroy(e)}finally{this.reading=!1}}}async _exploreDir(t,e){let n;try{n=await Qt(t,this._rdOptions)}catch(s){this._onError(s)}return{files:n,depth:e,path:t}}async _formatEntry(t,e){let n,s=this._isDirent?t.name:t;try{let a=xt(se(e,s));n={path:ie(this._root,a),fullPath:a,basename:s},n[this._statsProp]=this._isDirent?t:await this._stat(a)}catch(a){this._onError(a);return}return n}_onError(t){le(t)&&!this.destroyed?this.emit("warn",t):this.destroy(t)}async _getEntryType(t){if(!t&&this._statsProp in t)return"";let e=t[this._statsProp];if(e.isFile())return"file";if(e.isDirectory())return"directory";if(e&&e.isSymbolicLink()){let n=t.fullPath;try{let s=await te(n),a=await Pt(s);if(a.isFile())return"file";if(a.isDirectory()){let c=s.length;if(n.startsWith(s)&&n.substr(c,1)===ne){let o=new Error(`Circular symlink detected: "${n}" points to "${s}"`);return o.code=Ct,this._onError(o)}return"directory"}}catch(s){return this._onError(s),""}}}_includeAsFile(t){let e=t&&t[this._statsProp];return e&&this._wantsEverything&&!e.isDirectory()}};function vt(i,t={}){let e=t.entryType||t.type;if(e==="both"&&(e=A.FILE_DIR_TYPE),e&&(t.type=e),i){if(typeof i!="string")throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");if(e&&!bt.includes(e))throw new Error(`readdirp: Invalid type passed. Use one of ${bt.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return t.root=i,new ct(t)}import{watch as fe,unwatchFile as It,watchFile as de}from"node:fs";import{realpath as lt,lstat as pe,open as ue,stat as Tt}from"node:fs/promises";import{type as me}from"node:os";import*as b from"node:path";var _e="data",dt="end",At="close",X=()=>{};var Q=process.platform,pt=Q==="win32",we=Q==="darwin",ge=Q==="linux",ye=Q==="freebsd",Ft=me()==="OS400",D={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},N=D,Ee="watch",Pe={lstat:pe,stat:Tt},L="listeners",K="errHandlers",Y="rawEmitters",xe=[L,K,Y],be=new Set(["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),De=i=>be.has(b.extname(i).slice(1).toLowerCase()),ft=(i,t)=>{i instanceof Set?i.forEach(t):t(i)},U=(i,t,e)=>{let n=i[t];n instanceof Set||(i[t]=n=new Set([n])),n.add(e)},Re=i=>t=>{let e=i[t];e instanceof Set?e.clear():delete i[t]},G=(i,t,e)=>{let n=i[t];n instanceof Set?n.delete(e):n===e&&delete i[t]},Nt=i=>i instanceof Set?i.size===0:!i,Z=new Map;function $t(i,t,e,n,s){let a=(c,o)=>{e(i),s(c,o,{watchedPath:i}),o&&i!==o&&q(b.resolve(i,o),L,b.join(i,o))};try{return fe(i,{persistent:t.persistent},a)}catch(c){n(c);return}}var q=(i,t,e,n,s)=>{let a=Z.get(i);a&&ft(a[t],c=>{c(e,n,s)})},Ce=(i,t,e,n)=>{let{listener:s,errHandler:a,rawEmitter:c}=n,o=Z.get(t),r;if(!e.persistent)return r=$t(i,e,s,a,c),r?r.close.bind(r):void 0;if(o)U(o,L,s),U(o,K,a),U(o,Y,c);else{if(r=$t(i,e,q.bind(null,t,L),a,q.bind(null,t,Y)),!r)return;r.on(N.ERROR,async d=>{let f=q.bind(null,t,K);if(o&&(o.watcherUnusable=!0),pt&&d.code==="EPERM")try{await(await ue(i,"r")).close(),f(d)}catch{}else f(d)}),o={listeners:s,errHandlers:a,rawEmitters:c,watcher:r},Z.set(t,o)}return()=>{G(o,L,s),G(o,K,a),G(o,Y,c),Nt(o.listeners)&&(o.watcher.close(),Z.delete(t),xe.forEach(Re(o)),o.watcher=void 0,Object.freeze(o))}},ht=new Map,ve=(i,t,e,n)=>{let{listener:s,rawEmitter:a}=n,c=ht.get(t),o=c&&c.options;return o&&(o.persistent<e.persistent||o.interval>e.interval)&&(It(t),c=void 0),c?(U(c,L,s),U(c,Y,a)):(c={listeners:s,rawEmitters:a,options:e,watcher:de(t,e,(r,d)=>{ft(c.rawEmitters,h=>{h(N.CHANGE,t,{curr:r,prev:d})});let f=r.mtimeMs;(r.size!==d.size||f>d.mtimeMs||f===0)&&ft(c.listeners,h=>h(i,r))})},ht.set(t,c)),()=>{G(c,L,s),G(c,Y,a),Nt(c.listeners)&&(ht.delete(t),It(t),c.options=c.watcher=void 0,Object.freeze(c))}},J=class{fsw;_boundHandleError;constructor(t){this.fsw=t,this._boundHandleError=e=>t._handleError(e)}_watchWithNodeFs(t,e){let n=this.fsw.options,s=b.dirname(t),a=b.basename(t);this.fsw._getWatchedDir(s).add(a);let o=b.resolve(t),r={persistent:n.persistent};e||(e=X);let d;if(n.usePolling){let f=n.interval!==n.binaryInterval;r.interval=f&&De(a)?n.binaryInterval:n.interval,d=ve(t,o,r,{listener:e,rawEmitter:this.fsw._emitRaw})}else d=Ce(t,o,r,{listener:e,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return d}_handleFile(t,e,n){if(this.fsw.closed)return;let s=b.dirname(t),a=b.basename(t),c=this.fsw._getWatchedDir(s),o=e;if(c.has(a))return;let r=async(f,h)=>{if(this.fsw._throttle(Ee,t,5)){if(!h||h.mtimeMs===0)try{let l=await Tt(t);if(this.fsw.closed)return;let p=l.atimeMs,u=l.mtimeMs;if((!p||p<=u||u!==o.mtimeMs)&&this.fsw._emit(N.CHANGE,t,l),(we||ge||ye)&&o.ino!==l.ino){this.fsw._closeFile(f),o=l;let g=this._watchWithNodeFs(t,r);g&&this.fsw._addPathCloser(f,g)}else o=l}catch{this.fsw._remove(s,a)}else if(c.has(a)){let l=h.atimeMs,p=h.mtimeMs;(!l||l<=p||p!==o.mtimeMs)&&this.fsw._emit(N.CHANGE,t,h),o=h}}},d=this._watchWithNodeFs(t,r);if(!(n&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(t)){if(!this.fsw._throttle(N.ADD,t,0))return;this.fsw._emit(N.ADD,t,e)}return d}async _handleSymlink(t,e,n,s){if(this.fsw.closed)return;let a=t.fullPath,c=this.fsw._getWatchedDir(e);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let o;try{o=await lt(n)}catch{return this.fsw._emitReady(),!0}return this.fsw.closed?void 0:(c.has(s)?this.fsw._symlinkPaths.get(a)!==o&&(this.fsw._symlinkPaths.set(a,o),this.fsw._emit(N.CHANGE,n,t.stats)):(c.add(s),this.fsw._symlinkPaths.set(a,o),this.fsw._emit(N.ADD,n,t.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(a))return!0;this.fsw._symlinkPaths.set(a,!0)}_handleRead(t,e,n,s,a,c,o){t=b.join(t,"");let r=s?`${t}:${s}`:t;if(o=this.fsw._throttle("readdir",r,1e3),!o)return;let d=this.fsw._getWatchedDir(n.path),f=new Set,h=this.fsw._readdirp(t,{fileFilter:l=>n.filterPath(l),directoryFilter:l=>n.filterDir(l)});if(h)return h.on(_e,async l=>{if(this.fsw.closed){h=void 0;return}let p=l.path,u=b.join(t,p);if(f.add(p),!(l.stats.isSymbolicLink()&&await this._handleSymlink(l,t,u,p))){if(this.fsw.closed){h=void 0;return}(p===s||!s&&!d.has(p))&&(this.fsw._incrReadyCount(),u=b.join(a,b.relative(a,u)),this._addToNodeFs(u,e,n,c+1))}}).on(N.ERROR,this._boundHandleError),new Promise((l,p)=>{if(!h)return p();h.once(dt,()=>{if(this.fsw.closed){h=void 0;return}let u=o?o.clear():!1;l(void 0),d.getChildren().filter(g=>g!==t&&!f.has(g)).forEach(g=>{this.fsw._remove(t,g)}),h=void 0,u&&this._handleRead(t,!1,n,s,a,c,o)})})}async _handleDir(t,e,n,s,a,c,o){let r=this.fsw._getWatchedDir(b.dirname(t)),d=r.has(b.basename(t));!(n&&this.fsw.options.ignoreInitial)&&!a&&!d&&this.fsw._emit(N.ADD_DIR,t,e),r.add(b.basename(t)),this.fsw._getWatchedDir(t);let f,h,l=this.fsw.options.depth;if((l==null||s<=l)&&!this.fsw._symlinkPaths.has(o)){if(!a&&(await this._handleRead(t,n,c,a,t,s,f),this.fsw.closed))return;h=this._watchWithNodeFs(t,(p,u)=>{u&&u.mtimeMs===0||this._handleRead(p,!1,c,a,t,s,f)})}return h}async _addToNodeFs(t,e,n,s,a){let c=this.fsw._emitReady;if(this.fsw._isIgnored(t)||this.fsw.closed)return c(),!1;let o=this.fsw._getWatchHelpers(t);n&&(o.filterPath=r=>n.filterPath(r),o.filterDir=r=>n.filterDir(r));try{let r=await Pe[o.statMethod](o.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(o.watchPath,r))return c(),!1;let d=this.fsw.options.followSymlinks,f;if(r.isDirectory()){let h=b.resolve(t),l=d?await lt(t):t;if(this.fsw.closed||(f=await this._handleDir(o.watchPath,r,e,s,a,o,l),this.fsw.closed))return;h!==l&&l!==void 0&&this.fsw._symlinkPaths.set(h,l)}else if(r.isSymbolicLink()){let h=d?await lt(t):t;if(this.fsw.closed)return;let l=b.dirname(o.watchPath);if(this.fsw._getWatchedDir(l).add(o.watchPath),this.fsw._emit(N.ADD,o.watchPath,r),f=await this._handleDir(l,r,e,s,t,o,h),this.fsw.closed)return;h!==void 0&&this.fsw._symlinkPaths.set(b.resolve(t),h)}else f=this._handleFile(o.watchPath,r,e);return c(),f&&this.fsw._addPathCloser(t,f),!1}catch(r){if(this.fsw._handleError(r))return c(),t}}};var ut="/",Fe="//",Lt=".",Ne="..",Se="string",Me=/\\/g,jt=/\/\//g,We=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,ke=/^\.[/\\]/;function tt(i){return Array.isArray(i)?i:[i]}var mt=i=>typeof i=="object"&&i!==null&&!(i instanceof RegExp);function Le(i){return typeof i=="function"?i:typeof i=="string"?t=>i===t:i instanceof RegExp?t=>i.test(t):typeof i=="object"&&i!==null?t=>{if(i.path===t)return!0;if(i.recursive){let e=m.relative(i.path,t);return e?!e.startsWith("..")&&!m.isAbsolute(e):!1}return!1}:()=>!1}function je(i){if(typeof i!="string")throw new Error("string expected");i=m.normalize(i),i=i.replace(/\\/g,"/");let t=!1;return i.startsWith("//")&&(t=!0),i=i.replace(jt,"/"),t&&(i="/"+i),i}function St(i,t,e){let n=je(t);for(let s=0;s<i.length;s++){let a=i[s];if(a(n,e))return!0}return!1}function Oe(i,t){if(i==null)throw new TypeError("anymatch: specify first argument");let n=tt(i).map(s=>Le(s));return t==null?(s,a)=>St(n,s,a):St(n,t)}var Mt=i=>{let t=tt(i).flat();if(!t.every(e=>typeof e===Se))throw new TypeError(`Non-string provided as watch path: ${t}`);return t.map(Ot)},Wt=i=>{let t=i.replace(Me,ut),e=!1;return t.startsWith(Fe)&&(e=!0),t=t.replace(jt,ut),e&&(t=ut+t),t},Ot=i=>Wt(m.normalize(Wt(i))),kt=(i="")=>t=>typeof t=="string"?Ot(m.isAbsolute(t)?t:m.join(i,t)):t,ze=(i,t)=>m.isAbsolute(i)?i:m.join(t,i),He=Object.freeze(new Set),_t=class{path;_removeWatcher;items;constructor(t,e){this.path=t,this._removeWatcher=e,this.items=new Set}add(t){let{items:e}=this;e&&t!==Lt&&t!==Ne&&e.add(t)}async remove(t){let{items:e}=this;if(!e||(e.delete(t),e.size>0))return;let n=this.path;try{await Te(n)}catch{this._removeWatcher&&this._removeWatcher(m.dirname(n),m.basename(n))}}has(t){let{items:e}=this;if(e)return e.has(t)}getChildren(){let{items:t}=this;return t?[...t.values()]:[]}dispose(){this.items.clear(),this.path="",this._removeWatcher=X,this.items=He,Object.freeze(this)}},Ye="stat",Ue="lstat",wt=class{fsw;path;watchPath;fullWatchPath;dirParts;followSymlinks;statMethod;constructor(t,e,n){this.fsw=n;let s=t;this.path=t=t.replace(ke,""),this.watchPath=s,this.fullWatchPath=m.resolve(s),this.dirParts=[],this.dirParts.forEach(a=>{a.length>1&&a.pop()}),this.followSymlinks=e,this.statMethod=e?Ye:Ue}entryPath(t){return m.join(this.watchPath,m.relative(this.watchPath,t.fullPath))}filterPath(t){let{stats:e}=t;if(e&&e.isSymbolicLink())return this.filterDir(t);let n=this.entryPath(t);return this.fsw._isntIgnored(n,e)&&this.fsw._hasReadPermissions(e)}filterDir(t){return this.fsw._isntIgnored(this.entryPath(t),t.stats)}},et=class extends Ie{closed;options;_closers;_ignoredPaths;_throttled;_streams;_symlinkPaths;_watched;_pendingWrites;_pendingUnlinks;_readyCount;_emitReady;_closePromise;_userIgnored;_readyEmitted;_emitRaw;_boundRemove;_nodeFsHandler;constructor(t={}){super(),this.closed=!1,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=!1;let e=t.awaitWriteFinish,n={stabilityThreshold:2e3,pollInterval:100},s={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...t,ignored:t.ignored?tt(t.ignored):tt([]),awaitWriteFinish:e===!0?n:typeof e=="object"?{...n,...e}:!1};Ft&&(s.usePolling=!0),s.atomic===void 0&&(s.atomic=!s.usePolling);let a=process.env.CHOKIDAR_USEPOLLING;if(a!==void 0){let r=a.toLowerCase();r==="false"||r==="0"?s.usePolling=!1:r==="true"||r==="1"?s.usePolling=!0:s.usePolling=!!r}let c=process.env.CHOKIDAR_INTERVAL;c&&(s.interval=Number.parseInt(c,10));let o=0;this._emitReady=()=>{o++,o>=this._readyCount&&(this._emitReady=X,this._readyEmitted=!0,process.nextTick(()=>this.emit(D.READY)))},this._emitRaw=(...r)=>this.emit(D.RAW,...r),this._boundRemove=this._remove.bind(this),this.options=s,this._nodeFsHandler=new J(this),Object.freeze(s)}_addIgnoredPath(t){if(mt(t)){for(let e of this._ignoredPaths)if(mt(e)&&e.path===t.path&&e.recursive===t.recursive)return}this._ignoredPaths.add(t)}_removeIgnoredPath(t){if(this._ignoredPaths.delete(t),typeof t=="string")for(let e of this._ignoredPaths)mt(e)&&e.path===t&&this._ignoredPaths.delete(e)}add(t,e,n){let{cwd:s}=this.options;this.closed=!1,this._closePromise=void 0;let a=Mt(t);return s&&(a=a.map(c=>ze(c,s))),a.forEach(c=>{this._removeIgnoredPath(c)}),this._userIgnored=void 0,this._readyCount||(this._readyCount=0),this._readyCount+=a.length,Promise.all(a.map(async c=>{let o=await this._nodeFsHandler._addToNodeFs(c,!n,void 0,0,e);return o&&this._emitReady(),o})).then(c=>{this.closed||c.forEach(o=>{o&&this.add(m.dirname(o),m.basename(e||o))})}),this}unwatch(t){if(this.closed)return this;let e=Mt(t),{cwd:n}=this.options;return e.forEach(s=>{!m.isAbsolute(s)&&!this._closers.has(s)&&(n&&(s=m.join(n,s)),s=m.resolve(s)),this._closePath(s),this._addIgnoredPath(s),this._watched.has(s)&&this._addIgnoredPath({path:s,recursive:!0}),this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let t=[];return this._closers.forEach(e=>e.forEach(n=>{let s=n();s instanceof Promise&&t.push(s)})),this._streams.forEach(e=>e.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(e=>e.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=t.length?Promise.all(t).then(()=>{}):Promise.resolve(),this._closePromise}getWatched(){let t={};return this._watched.forEach((e,n)=>{let a=(this.options.cwd?m.relative(this.options.cwd,n):n)||Lt;t[a]=e.getChildren().sort()}),t}emitWithAll(t,e){this.emit(t,...e),t!==D.ERROR&&this.emit(D.ALL,t,...e)}async _emit(t,e,n){if(this.closed)return;let s=this.options;pt&&(e=m.normalize(e)),s.cwd&&(e=m.relative(s.cwd,e));let a=[e];n!=null&&a.push(n);let c=s.awaitWriteFinish,o;if(c&&(o=this._pendingWrites.get(e)))return o.lastChange=new Date,this;if(s.atomic){if(t===D.UNLINK)return this._pendingUnlinks.set(e,[t,...a]),setTimeout(()=>{this._pendingUnlinks.forEach((r,d)=>{this.emit(...r),this.emit(D.ALL,...r),this._pendingUnlinks.delete(d)})},typeof s.atomic=="number"?s.atomic:100),this;t===D.ADD&&this._pendingUnlinks.has(e)&&(t=D.CHANGE,this._pendingUnlinks.delete(e))}if(c&&(t===D.ADD||t===D.CHANGE)&&this._readyEmitted){let r=(d,f)=>{d?(t=D.ERROR,a[0]=d,this.emitWithAll(t,a)):f&&(a.length>1?a[1]=f:a.push(f),this.emitWithAll(t,a))};return this._awaitWriteFinish(e,c.stabilityThreshold,t,r),this}if(t===D.CHANGE&&!this._throttle(D.CHANGE,e,50))return this;if(s.alwaysStat&&n===void 0&&(t===D.ADD||t===D.ADD_DIR||t===D.CHANGE)){let r=s.cwd?m.join(s.cwd,e):e,d;try{d=await Ae(r)}catch{}if(!d||this.closed)return;a.push(d)}return this.emitWithAll(t,a),this}_handleError(t){let e=t&&t.code;return t&&e!=="ENOENT"&&e!=="ENOTDIR"&&(!this.options.ignorePermissionErrors||e!=="EPERM"&&e!=="EACCES")&&this.emit(D.ERROR,t),t||this.closed}_throttle(t,e,n){this._throttled.has(t)||this._throttled.set(t,new Map);let s=this._throttled.get(t);if(!s)throw new Error("invalid throttle");let a=s.get(e);if(a)return a.count++,!1;let c,o=()=>{let d=s.get(e),f=d?d.count:0;return s.delete(e),clearTimeout(c),d&&clearTimeout(d.timeoutObject),f};c=setTimeout(o,n);let r={timeoutObject:c,clear:o,count:0};return s.set(e,r),r}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(t,e,n,s){let a=this.options.awaitWriteFinish;if(typeof a!="object")return;let c=a.pollInterval,o,r=t;this.options.cwd&&!m.isAbsolute(t)&&(r=m.join(this.options.cwd,t));let d=new Date,f=this._pendingWrites;function h(l){$e(r,(p,u)=>{if(p||!f.has(t)){p&&p.code!=="ENOENT"&&s(p);return}let g=Number(new Date);l&&u.size!==l.size&&(f.get(t).lastChange=g);let x=f.get(t);g-x.lastChange>=e?(f.delete(t),s(void 0,u)):o=setTimeout(h,c,u)})}f.has(t)||(f.set(t,{lastChange:d,cancelWait:()=>(f.delete(t),clearTimeout(o),n)}),o=setTimeout(h,c))}_isIgnored(t,e){if(this.options.atomic&&We.test(t))return!0;if(!this._userIgnored){let{cwd:n}=this.options,a=(this.options.ignored||[]).map(kt(n)),o=[...[...this._ignoredPaths].map(kt(n)),...a];this._userIgnored=Oe(o,void 0)}return this._userIgnored(t,e)}_isntIgnored(t,e){return!this._isIgnored(t,e)}_getWatchHelpers(t){return new wt(t,this.options.followSymlinks,this)}_getWatchedDir(t){let e=m.resolve(t);return this._watched.has(e)||this._watched.set(e,new _t(e,this._boundRemove)),this._watched.get(e)}_hasReadPermissions(t){return this.options.ignorePermissionErrors?!0:!!(Number(t.mode)&256)}_remove(t,e,n){let s=m.join(t,e),a=m.resolve(s);if(n=n??(this._watched.has(s)||this._watched.has(a)),!this._throttle("remove",s,100))return;!n&&this._watched.size===1&&this.add(t,e,!0),this._getWatchedDir(s).getChildren().forEach(l=>this._remove(s,l));let r=this._getWatchedDir(t),d=r.has(e);r.remove(e),this._symlinkPaths.has(a)&&this._symlinkPaths.delete(a);let f=s;if(this.options.cwd&&(f=m.relative(this.options.cwd,s)),this.options.awaitWriteFinish&&this._pendingWrites.has(f)&&this._pendingWrites.get(f).cancelWait()===D.ADD)return;this._watched.delete(s),this._watched.delete(a);let h=n?D.UNLINK_DIR:D.UNLINK;d&&!this._isIgnored(s)&&this._emit(h,s),this._closePath(s)}_closePath(t){this._closeFile(t);let e=m.dirname(t);this._getWatchedDir(e).remove(m.basename(t))}_closeFile(t){let e=this._closers.get(t);e&&(e.forEach(n=>n()),this._closers.delete(t))}_addPathCloser(t,e){if(!e)return;let n=this._closers.get(t);n||(n=[],this._closers.set(t,n)),n.push(e)}_readdirp(t,e){if(this.closed)return;let n={type:D.ALL,alwaysStat:!0,lstat:!0,...e,depth:0},s=vt(t,n);return this._streams.add(s),s.once(At,()=>{s=void 0}),s.once(dt,()=>{s&&(this._streams.delete(s),s=void 0)}),s}};function Ge(i,t={}){let e=new et(t);return e.add(i),e}var zt={watch:Ge,FSWatcher:et};import{pathToFileURL as ns,fileURLToPath as rs}from"node:url";import{join as P,sep as Et,dirname as qt}from"node:path";import{copyFile as V,cp as os,mkdir as as,readFile as cs,writeFile as Jt}from"node:fs/promises";import{access as Ve}from"node:fs/promises";import{constants as Be}from"node:fs";async function S(i){try{return await Ve(i,Be.F_OK),!0}catch{return!1}}import{access as Ke}from"node:fs/promises";import{constants as Ze}from"node:fs";async function j(i){try{return await Ke(i,Ze.F_OK),!0}catch{return!1}}import{join as M}from"node:path";import{readdir as qe}from"node:fs/promises";async function O(i){let t=[];try{let e=await qe(i,{withFileTypes:!0});for(let n of e)n.isDirectory()&&t.push(n.name)}catch(e){console.error("Error reading directory:",e)}return t}import{readFile as Ht}from"node:fs/promises";function st(i){return i&&i.charAt(0).toUpperCase()+i.slice(1)}function it(i){return i.replace(/([a-zA-Z])(?=[A-Z])/g,"$1-").toLowerCase()}var gt=i=>`\x1B[31m${i}\x1B[0m`,Vs=process.cwd();var z="src",k="components";function Yt(i){return{name:"playground-plugin",setup(t){let e="playground-entry",n="playground-module";t.onResolve({filter:new RegExp(`^${e}$`)},s=>({path:e,namespace:n})),t.onLoad({filter:/.*/,namespace:n},async s=>{let a=[],c=await O(M(z,k));c.length===0&&(console.log(gt('Missing at least 1 namespace folder under "src/components/"')),process.exit());let o=[];for(let r of c){let d={namespace:r,components:[]};o.push(d);let f=M(z,k,r),h=await O(f);for(let l of h)if(await S(M(z,k,r,l,`${l}.ts`))){let p="";await S(M(z,k,r,l,"README.md"))&&(p=await Ht(M(z,k,r,l,"README.md"),"utf8"));let u={namespace:r,component:l,tag:`${r}-${it(l)}`,examples:[],className:"",classExtends:"",readme:p};if(a.push(`import '${k}/${r}/${l}/${l}';`),await j(M(f,l,"__examples__"))){let _=await O(M(f,l,"__examples__"));for(let w of _)await S(M(f,l,"__examples__",w,`${w}.ts`))?(a.push(`import '${k}/${r}/${l}/__examples__/${w}/${w}';`),u.examples.push({namespace:r,component:l,example:w,tag:`x-${r}-${it(l)}-${it(w)}`,className:`X${st(r)}${st(l)}${st(w)}`})):console.log(gt(`Missing ${k}/${r}/${l}/__examples__/${w}/${w}.ts`))}let x=(await Ht(M(z,k,r,l,`${l}.ts`),"utf8")).match(/class (\w+) extends (\w+)/);x||(console.log(gt(`Component "${r}-${l}" must extend HtmlElement or base class`)),process.exit()),u.className=x[1],u.classExtends=x[2],d.components.push(u)}}return i.after(o),{contents:a.join(`
|
|
4
|
-
`),resolveDir:M(process.cwd(),z)}})}}}import{sep as Gt}from"node:path";import{readFile as
|
|
5
|
-
`),loader:"js"}})}}}var
|
|
3
|
+
import{context as ns}from"esbuild";import{EventEmitter as Ie}from"node:events";import{stat as Te}from"node:fs";import{readdir as $e,stat as Ae}from"node:fs/promises";import*as m from"node:path";import{lstat as Pt,readdir as Qt,realpath as te,stat as ee}from"node:fs/promises";import{join as se,relative as ie,resolve as xt,sep as ne}from"node:path";import{Readable as re}from"node:stream";var A={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},at={root:".",fileFilter:i=>!0,directoryFilter:i=>!0,type:A.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(at);var Ct="READDIRP_RECURSIVE_ERROR",oe=new Set(["ENOENT","EPERM","EACCES","ELOOP",Ct]),bt=[A.DIR_TYPE,A.EVERYTHING_TYPE,A.FILE_DIR_TYPE,A.FILE_TYPE],ae=new Set([A.DIR_TYPE,A.EVERYTHING_TYPE,A.FILE_DIR_TYPE]),ce=new Set([A.EVERYTHING_TYPE,A.FILE_DIR_TYPE,A.FILE_TYPE]),le=i=>oe.has(i.code),he=process.platform==="win32",Dt=i=>!0,Rt=i=>{if(i===void 0)return Dt;if(typeof i=="function")return i;if(typeof i=="string"){let t=i.trim();return e=>e.basename===t}if(Array.isArray(i)){let t=i.map(e=>e.trim());return e=>t.some(n=>e.basename===n)}return Dt},ct=class extends re{parents;reading;parent;_stat;_maxDepth;_wantsDir;_wantsFile;_wantsEverything;_root;_isDirent;_statsProp;_rdOptions;_fileFilter;_directoryFilter;constructor(t={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:t.highWaterMark});let e={...at,...t},{root:n,type:s}=e;this._fileFilter=Rt(e.fileFilter),this._directoryFilter=Rt(e.directoryFilter);let a=e.lstat?Pt:ee;he?this._stat=c=>a(c,{bigint:!0}):this._stat=a,this._maxDepth=e.depth!=null&&Number.isSafeInteger(e.depth)?e.depth:at.depth,this._wantsDir=s?ae.has(s):!1,this._wantsFile=s?ce.has(s):!1,this._wantsEverything=s===A.EVERYTHING_TYPE,this._root=xt(n),this._isDirent=!e.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(n,1)],this.reading=!1,this.parent=void 0}async _read(t){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&t>0;){let e=this.parent,n=e&&e.files;if(n&&n.length>0){let{path:s,depth:a}=e,c=n.splice(0,t).map(r=>this._formatEntry(r,s)),o=await Promise.all(c);for(let r of o){if(!r)continue;if(this.destroyed)return;let d=await this._getEntryType(r);d==="directory"&&this._directoryFilter(r)?(a<=this._maxDepth&&this.parents.push(this._exploreDir(r.fullPath,a+1)),this._wantsDir&&(this.push(r),t--)):(d==="file"||this._includeAsFile(r))&&this._fileFilter(r)&&this._wantsFile&&(this.push(r),t--)}}else{let s=this.parents.pop();if(!s){this.push(null);break}if(this.parent=await s,this.destroyed)return}}}catch(e){this.destroy(e)}finally{this.reading=!1}}}async _exploreDir(t,e){let n;try{n=await Qt(t,this._rdOptions)}catch(s){this._onError(s)}return{files:n,depth:e,path:t}}async _formatEntry(t,e){let n,s=this._isDirent?t.name:t;try{let a=xt(se(e,s));n={path:ie(this._root,a),fullPath:a,basename:s},n[this._statsProp]=this._isDirent?t:await this._stat(a)}catch(a){this._onError(a);return}return n}_onError(t){le(t)&&!this.destroyed?this.emit("warn",t):this.destroy(t)}async _getEntryType(t){if(!t&&this._statsProp in t)return"";let e=t[this._statsProp];if(e.isFile())return"file";if(e.isDirectory())return"directory";if(e&&e.isSymbolicLink()){let n=t.fullPath;try{let s=await te(n),a=await Pt(s);if(a.isFile())return"file";if(a.isDirectory()){let c=s.length;if(n.startsWith(s)&&n.substr(c,1)===ne){let o=new Error(`Circular symlink detected: "${n}" points to "${s}"`);return o.code=Ct,this._onError(o)}return"directory"}}catch(s){return this._onError(s),""}}}_includeAsFile(t){let e=t&&t[this._statsProp];return e&&this._wantsEverything&&!e.isDirectory()}};function vt(i,t={}){let e=t.entryType||t.type;if(e==="both"&&(e=A.FILE_DIR_TYPE),e&&(t.type=e),i){if(typeof i!="string")throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");if(e&&!bt.includes(e))throw new Error(`readdirp: Invalid type passed. Use one of ${bt.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return t.root=i,new ct(t)}import{watch as fe,unwatchFile as It,watchFile as de}from"node:fs";import{realpath as lt,lstat as pe,open as ue,stat as $t}from"node:fs/promises";import{type as me}from"node:os";import*as b from"node:path";var _e="data",dt="end",At="close",X=()=>{};var Q=process.platform,pt=Q==="win32",we=Q==="darwin",ge=Q==="linux",ye=Q==="freebsd",Ft=me()==="OS400",D={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},N=D,Ee="watch",Pe={lstat:pe,stat:$t},L="listeners",K="errHandlers",Y="rawEmitters",xe=[L,K,Y],be=new Set(["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),De=i=>be.has(b.extname(i).slice(1).toLowerCase()),ft=(i,t)=>{i instanceof Set?i.forEach(t):t(i)},U=(i,t,e)=>{let n=i[t];n instanceof Set||(i[t]=n=new Set([n])),n.add(e)},Re=i=>t=>{let e=i[t];e instanceof Set?e.clear():delete i[t]},G=(i,t,e)=>{let n=i[t];n instanceof Set?n.delete(e):n===e&&delete i[t]},Nt=i=>i instanceof Set?i.size===0:!i,Z=new Map;function Tt(i,t,e,n,s){let a=(c,o)=>{e(i),s(c,o,{watchedPath:i}),o&&i!==o&&q(b.resolve(i,o),L,b.join(i,o))};try{return fe(i,{persistent:t.persistent},a)}catch(c){n(c);return}}var q=(i,t,e,n,s)=>{let a=Z.get(i);a&&ft(a[t],c=>{c(e,n,s)})},Ce=(i,t,e,n)=>{let{listener:s,errHandler:a,rawEmitter:c}=n,o=Z.get(t),r;if(!e.persistent)return r=Tt(i,e,s,a,c),r?r.close.bind(r):void 0;if(o)U(o,L,s),U(o,K,a),U(o,Y,c);else{if(r=Tt(i,e,q.bind(null,t,L),a,q.bind(null,t,Y)),!r)return;r.on(N.ERROR,async d=>{let f=q.bind(null,t,K);if(o&&(o.watcherUnusable=!0),pt&&d.code==="EPERM")try{await(await ue(i,"r")).close(),f(d)}catch{}else f(d)}),o={listeners:s,errHandlers:a,rawEmitters:c,watcher:r},Z.set(t,o)}return()=>{G(o,L,s),G(o,K,a),G(o,Y,c),Nt(o.listeners)&&(o.watcher.close(),Z.delete(t),xe.forEach(Re(o)),o.watcher=void 0,Object.freeze(o))}},ht=new Map,ve=(i,t,e,n)=>{let{listener:s,rawEmitter:a}=n,c=ht.get(t),o=c&&c.options;return o&&(o.persistent<e.persistent||o.interval>e.interval)&&(It(t),c=void 0),c?(U(c,L,s),U(c,Y,a)):(c={listeners:s,rawEmitters:a,options:e,watcher:de(t,e,(r,d)=>{ft(c.rawEmitters,h=>{h(N.CHANGE,t,{curr:r,prev:d})});let f=r.mtimeMs;(r.size!==d.size||f>d.mtimeMs||f===0)&&ft(c.listeners,h=>h(i,r))})},ht.set(t,c)),()=>{G(c,L,s),G(c,Y,a),Nt(c.listeners)&&(ht.delete(t),It(t),c.options=c.watcher=void 0,Object.freeze(c))}},J=class{fsw;_boundHandleError;constructor(t){this.fsw=t,this._boundHandleError=e=>t._handleError(e)}_watchWithNodeFs(t,e){let n=this.fsw.options,s=b.dirname(t),a=b.basename(t);this.fsw._getWatchedDir(s).add(a);let o=b.resolve(t),r={persistent:n.persistent};e||(e=X);let d;if(n.usePolling){let f=n.interval!==n.binaryInterval;r.interval=f&&De(a)?n.binaryInterval:n.interval,d=ve(t,o,r,{listener:e,rawEmitter:this.fsw._emitRaw})}else d=Ce(t,o,r,{listener:e,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return d}_handleFile(t,e,n){if(this.fsw.closed)return;let s=b.dirname(t),a=b.basename(t),c=this.fsw._getWatchedDir(s),o=e;if(c.has(a))return;let r=async(f,h)=>{if(this.fsw._throttle(Ee,t,5)){if(!h||h.mtimeMs===0)try{let l=await $t(t);if(this.fsw.closed)return;let p=l.atimeMs,u=l.mtimeMs;if((!p||p<=u||u!==o.mtimeMs)&&this.fsw._emit(N.CHANGE,t,l),(we||ge||ye)&&o.ino!==l.ino){this.fsw._closeFile(f),o=l;let g=this._watchWithNodeFs(t,r);g&&this.fsw._addPathCloser(f,g)}else o=l}catch{this.fsw._remove(s,a)}else if(c.has(a)){let l=h.atimeMs,p=h.mtimeMs;(!l||l<=p||p!==o.mtimeMs)&&this.fsw._emit(N.CHANGE,t,h),o=h}}},d=this._watchWithNodeFs(t,r);if(!(n&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(t)){if(!this.fsw._throttle(N.ADD,t,0))return;this.fsw._emit(N.ADD,t,e)}return d}async _handleSymlink(t,e,n,s){if(this.fsw.closed)return;let a=t.fullPath,c=this.fsw._getWatchedDir(e);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let o;try{o=await lt(n)}catch{return this.fsw._emitReady(),!0}return this.fsw.closed?void 0:(c.has(s)?this.fsw._symlinkPaths.get(a)!==o&&(this.fsw._symlinkPaths.set(a,o),this.fsw._emit(N.CHANGE,n,t.stats)):(c.add(s),this.fsw._symlinkPaths.set(a,o),this.fsw._emit(N.ADD,n,t.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(a))return!0;this.fsw._symlinkPaths.set(a,!0)}_handleRead(t,e,n,s,a,c,o){t=b.join(t,"");let r=s?`${t}:${s}`:t;if(o=this.fsw._throttle("readdir",r,1e3),!o)return;let d=this.fsw._getWatchedDir(n.path),f=new Set,h=this.fsw._readdirp(t,{fileFilter:l=>n.filterPath(l),directoryFilter:l=>n.filterDir(l)});if(h)return h.on(_e,async l=>{if(this.fsw.closed){h=void 0;return}let p=l.path,u=b.join(t,p);if(f.add(p),!(l.stats.isSymbolicLink()&&await this._handleSymlink(l,t,u,p))){if(this.fsw.closed){h=void 0;return}(p===s||!s&&!d.has(p))&&(this.fsw._incrReadyCount(),u=b.join(a,b.relative(a,u)),this._addToNodeFs(u,e,n,c+1))}}).on(N.ERROR,this._boundHandleError),new Promise((l,p)=>{if(!h)return p();h.once(dt,()=>{if(this.fsw.closed){h=void 0;return}let u=o?o.clear():!1;l(void 0),d.getChildren().filter(g=>g!==t&&!f.has(g)).forEach(g=>{this.fsw._remove(t,g)}),h=void 0,u&&this._handleRead(t,!1,n,s,a,c,o)})})}async _handleDir(t,e,n,s,a,c,o){let r=this.fsw._getWatchedDir(b.dirname(t)),d=r.has(b.basename(t));!(n&&this.fsw.options.ignoreInitial)&&!a&&!d&&this.fsw._emit(N.ADD_DIR,t,e),r.add(b.basename(t)),this.fsw._getWatchedDir(t);let f,h,l=this.fsw.options.depth;if((l==null||s<=l)&&!this.fsw._symlinkPaths.has(o)){if(!a&&(await this._handleRead(t,n,c,a,t,s,f),this.fsw.closed))return;h=this._watchWithNodeFs(t,(p,u)=>{u&&u.mtimeMs===0||this._handleRead(p,!1,c,a,t,s,f)})}return h}async _addToNodeFs(t,e,n,s,a){let c=this.fsw._emitReady;if(this.fsw._isIgnored(t)||this.fsw.closed)return c(),!1;let o=this.fsw._getWatchHelpers(t);n&&(o.filterPath=r=>n.filterPath(r),o.filterDir=r=>n.filterDir(r));try{let r=await Pe[o.statMethod](o.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(o.watchPath,r))return c(),!1;let d=this.fsw.options.followSymlinks,f;if(r.isDirectory()){let h=b.resolve(t),l=d?await lt(t):t;if(this.fsw.closed||(f=await this._handleDir(o.watchPath,r,e,s,a,o,l),this.fsw.closed))return;h!==l&&l!==void 0&&this.fsw._symlinkPaths.set(h,l)}else if(r.isSymbolicLink()){let h=d?await lt(t):t;if(this.fsw.closed)return;let l=b.dirname(o.watchPath);if(this.fsw._getWatchedDir(l).add(o.watchPath),this.fsw._emit(N.ADD,o.watchPath,r),f=await this._handleDir(l,r,e,s,t,o,h),this.fsw.closed)return;h!==void 0&&this.fsw._symlinkPaths.set(b.resolve(t),h)}else f=this._handleFile(o.watchPath,r,e);return c(),f&&this.fsw._addPathCloser(t,f),!1}catch(r){if(this.fsw._handleError(r))return c(),t}}};var ut="/",Fe="//",Lt=".",Ne="..",Se="string",Me=/\\/g,jt=/\/\//g,We=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,ke=/^\.[/\\]/;function tt(i){return Array.isArray(i)?i:[i]}var mt=i=>typeof i=="object"&&i!==null&&!(i instanceof RegExp);function Le(i){return typeof i=="function"?i:typeof i=="string"?t=>i===t:i instanceof RegExp?t=>i.test(t):typeof i=="object"&&i!==null?t=>{if(i.path===t)return!0;if(i.recursive){let e=m.relative(i.path,t);return e?!e.startsWith("..")&&!m.isAbsolute(e):!1}return!1}:()=>!1}function je(i){if(typeof i!="string")throw new Error("string expected");i=m.normalize(i),i=i.replace(/\\/g,"/");let t=!1;return i.startsWith("//")&&(t=!0),i=i.replace(jt,"/"),t&&(i="/"+i),i}function St(i,t,e){let n=je(t);for(let s=0;s<i.length;s++){let a=i[s];if(a(n,e))return!0}return!1}function Oe(i,t){if(i==null)throw new TypeError("anymatch: specify first argument");let n=tt(i).map(s=>Le(s));return t==null?(s,a)=>St(n,s,a):St(n,t)}var Mt=i=>{let t=tt(i).flat();if(!t.every(e=>typeof e===Se))throw new TypeError(`Non-string provided as watch path: ${t}`);return t.map(Ot)},Wt=i=>{let t=i.replace(Me,ut),e=!1;return t.startsWith(Fe)&&(e=!0),t=t.replace(jt,ut),e&&(t=ut+t),t},Ot=i=>Wt(m.normalize(Wt(i))),kt=(i="")=>t=>typeof t=="string"?Ot(m.isAbsolute(t)?t:m.join(i,t)):t,ze=(i,t)=>m.isAbsolute(i)?i:m.join(t,i),He=Object.freeze(new Set),_t=class{path;_removeWatcher;items;constructor(t,e){this.path=t,this._removeWatcher=e,this.items=new Set}add(t){let{items:e}=this;e&&t!==Lt&&t!==Ne&&e.add(t)}async remove(t){let{items:e}=this;if(!e||(e.delete(t),e.size>0))return;let n=this.path;try{await $e(n)}catch{this._removeWatcher&&this._removeWatcher(m.dirname(n),m.basename(n))}}has(t){let{items:e}=this;if(e)return e.has(t)}getChildren(){let{items:t}=this;return t?[...t.values()]:[]}dispose(){this.items.clear(),this.path="",this._removeWatcher=X,this.items=He,Object.freeze(this)}},Ye="stat",Ue="lstat",wt=class{fsw;path;watchPath;fullWatchPath;dirParts;followSymlinks;statMethod;constructor(t,e,n){this.fsw=n;let s=t;this.path=t=t.replace(ke,""),this.watchPath=s,this.fullWatchPath=m.resolve(s),this.dirParts=[],this.dirParts.forEach(a=>{a.length>1&&a.pop()}),this.followSymlinks=e,this.statMethod=e?Ye:Ue}entryPath(t){return m.join(this.watchPath,m.relative(this.watchPath,t.fullPath))}filterPath(t){let{stats:e}=t;if(e&&e.isSymbolicLink())return this.filterDir(t);let n=this.entryPath(t);return this.fsw._isntIgnored(n,e)&&this.fsw._hasReadPermissions(e)}filterDir(t){return this.fsw._isntIgnored(this.entryPath(t),t.stats)}},et=class extends Ie{closed;options;_closers;_ignoredPaths;_throttled;_streams;_symlinkPaths;_watched;_pendingWrites;_pendingUnlinks;_readyCount;_emitReady;_closePromise;_userIgnored;_readyEmitted;_emitRaw;_boundRemove;_nodeFsHandler;constructor(t={}){super(),this.closed=!1,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=!1;let e=t.awaitWriteFinish,n={stabilityThreshold:2e3,pollInterval:100},s={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...t,ignored:t.ignored?tt(t.ignored):tt([]),awaitWriteFinish:e===!0?n:typeof e=="object"?{...n,...e}:!1};Ft&&(s.usePolling=!0),s.atomic===void 0&&(s.atomic=!s.usePolling);let a=process.env.CHOKIDAR_USEPOLLING;if(a!==void 0){let r=a.toLowerCase();r==="false"||r==="0"?s.usePolling=!1:r==="true"||r==="1"?s.usePolling=!0:s.usePolling=!!r}let c=process.env.CHOKIDAR_INTERVAL;c&&(s.interval=Number.parseInt(c,10));let o=0;this._emitReady=()=>{o++,o>=this._readyCount&&(this._emitReady=X,this._readyEmitted=!0,process.nextTick(()=>this.emit(D.READY)))},this._emitRaw=(...r)=>this.emit(D.RAW,...r),this._boundRemove=this._remove.bind(this),this.options=s,this._nodeFsHandler=new J(this),Object.freeze(s)}_addIgnoredPath(t){if(mt(t)){for(let e of this._ignoredPaths)if(mt(e)&&e.path===t.path&&e.recursive===t.recursive)return}this._ignoredPaths.add(t)}_removeIgnoredPath(t){if(this._ignoredPaths.delete(t),typeof t=="string")for(let e of this._ignoredPaths)mt(e)&&e.path===t&&this._ignoredPaths.delete(e)}add(t,e,n){let{cwd:s}=this.options;this.closed=!1,this._closePromise=void 0;let a=Mt(t);return s&&(a=a.map(c=>ze(c,s))),a.forEach(c=>{this._removeIgnoredPath(c)}),this._userIgnored=void 0,this._readyCount||(this._readyCount=0),this._readyCount+=a.length,Promise.all(a.map(async c=>{let o=await this._nodeFsHandler._addToNodeFs(c,!n,void 0,0,e);return o&&this._emitReady(),o})).then(c=>{this.closed||c.forEach(o=>{o&&this.add(m.dirname(o),m.basename(e||o))})}),this}unwatch(t){if(this.closed)return this;let e=Mt(t),{cwd:n}=this.options;return e.forEach(s=>{!m.isAbsolute(s)&&!this._closers.has(s)&&(n&&(s=m.join(n,s)),s=m.resolve(s)),this._closePath(s),this._addIgnoredPath(s),this._watched.has(s)&&this._addIgnoredPath({path:s,recursive:!0}),this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let t=[];return this._closers.forEach(e=>e.forEach(n=>{let s=n();s instanceof Promise&&t.push(s)})),this._streams.forEach(e=>e.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(e=>e.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=t.length?Promise.all(t).then(()=>{}):Promise.resolve(),this._closePromise}getWatched(){let t={};return this._watched.forEach((e,n)=>{let a=(this.options.cwd?m.relative(this.options.cwd,n):n)||Lt;t[a]=e.getChildren().sort()}),t}emitWithAll(t,e){this.emit(t,...e),t!==D.ERROR&&this.emit(D.ALL,t,...e)}async _emit(t,e,n){if(this.closed)return;let s=this.options;pt&&(e=m.normalize(e)),s.cwd&&(e=m.relative(s.cwd,e));let a=[e];n!=null&&a.push(n);let c=s.awaitWriteFinish,o;if(c&&(o=this._pendingWrites.get(e)))return o.lastChange=new Date,this;if(s.atomic){if(t===D.UNLINK)return this._pendingUnlinks.set(e,[t,...a]),setTimeout(()=>{this._pendingUnlinks.forEach((r,d)=>{this.emit(...r),this.emit(D.ALL,...r),this._pendingUnlinks.delete(d)})},typeof s.atomic=="number"?s.atomic:100),this;t===D.ADD&&this._pendingUnlinks.has(e)&&(t=D.CHANGE,this._pendingUnlinks.delete(e))}if(c&&(t===D.ADD||t===D.CHANGE)&&this._readyEmitted){let r=(d,f)=>{d?(t=D.ERROR,a[0]=d,this.emitWithAll(t,a)):f&&(a.length>1?a[1]=f:a.push(f),this.emitWithAll(t,a))};return this._awaitWriteFinish(e,c.stabilityThreshold,t,r),this}if(t===D.CHANGE&&!this._throttle(D.CHANGE,e,50))return this;if(s.alwaysStat&&n===void 0&&(t===D.ADD||t===D.ADD_DIR||t===D.CHANGE)){let r=s.cwd?m.join(s.cwd,e):e,d;try{d=await Ae(r)}catch{}if(!d||this.closed)return;a.push(d)}return this.emitWithAll(t,a),this}_handleError(t){let e=t&&t.code;return t&&e!=="ENOENT"&&e!=="ENOTDIR"&&(!this.options.ignorePermissionErrors||e!=="EPERM"&&e!=="EACCES")&&this.emit(D.ERROR,t),t||this.closed}_throttle(t,e,n){this._throttled.has(t)||this._throttled.set(t,new Map);let s=this._throttled.get(t);if(!s)throw new Error("invalid throttle");let a=s.get(e);if(a)return a.count++,!1;let c,o=()=>{let d=s.get(e),f=d?d.count:0;return s.delete(e),clearTimeout(c),d&&clearTimeout(d.timeoutObject),f};c=setTimeout(o,n);let r={timeoutObject:c,clear:o,count:0};return s.set(e,r),r}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(t,e,n,s){let a=this.options.awaitWriteFinish;if(typeof a!="object")return;let c=a.pollInterval,o,r=t;this.options.cwd&&!m.isAbsolute(t)&&(r=m.join(this.options.cwd,t));let d=new Date,f=this._pendingWrites;function h(l){Te(r,(p,u)=>{if(p||!f.has(t)){p&&p.code!=="ENOENT"&&s(p);return}let g=Number(new Date);l&&u.size!==l.size&&(f.get(t).lastChange=g);let x=f.get(t);g-x.lastChange>=e?(f.delete(t),s(void 0,u)):o=setTimeout(h,c,u)})}f.has(t)||(f.set(t,{lastChange:d,cancelWait:()=>(f.delete(t),clearTimeout(o),n)}),o=setTimeout(h,c))}_isIgnored(t,e){if(this.options.atomic&&We.test(t))return!0;if(!this._userIgnored){let{cwd:n}=this.options,a=(this.options.ignored||[]).map(kt(n)),o=[...[...this._ignoredPaths].map(kt(n)),...a];this._userIgnored=Oe(o,void 0)}return this._userIgnored(t,e)}_isntIgnored(t,e){return!this._isIgnored(t,e)}_getWatchHelpers(t){return new wt(t,this.options.followSymlinks,this)}_getWatchedDir(t){let e=m.resolve(t);return this._watched.has(e)||this._watched.set(e,new _t(e,this._boundRemove)),this._watched.get(e)}_hasReadPermissions(t){return this.options.ignorePermissionErrors?!0:!!(Number(t.mode)&256)}_remove(t,e,n){let s=m.join(t,e),a=m.resolve(s);if(n=n??(this._watched.has(s)||this._watched.has(a)),!this._throttle("remove",s,100))return;!n&&this._watched.size===1&&this.add(t,e,!0),this._getWatchedDir(s).getChildren().forEach(l=>this._remove(s,l));let r=this._getWatchedDir(t),d=r.has(e);r.remove(e),this._symlinkPaths.has(a)&&this._symlinkPaths.delete(a);let f=s;if(this.options.cwd&&(f=m.relative(this.options.cwd,s)),this.options.awaitWriteFinish&&this._pendingWrites.has(f)&&this._pendingWrites.get(f).cancelWait()===D.ADD)return;this._watched.delete(s),this._watched.delete(a);let h=n?D.UNLINK_DIR:D.UNLINK;d&&!this._isIgnored(s)&&this._emit(h,s),this._closePath(s)}_closePath(t){this._closeFile(t);let e=m.dirname(t);this._getWatchedDir(e).remove(m.basename(t))}_closeFile(t){let e=this._closers.get(t);e&&(e.forEach(n=>n()),this._closers.delete(t))}_addPathCloser(t,e){if(!e)return;let n=this._closers.get(t);n||(n=[],this._closers.set(t,n)),n.push(e)}_readdirp(t,e){if(this.closed)return;let n={type:D.ALL,alwaysStat:!0,lstat:!0,...e,depth:0},s=vt(t,n);return this._streams.add(s),s.once(At,()=>{s=void 0}),s.once(dt,()=>{s&&(this._streams.delete(s),s=void 0)}),s}};function Ge(i,t={}){let e=new et(t);return e.add(i),e}var zt={watch:Ge,FSWatcher:et};import{pathToFileURL as rs,fileURLToPath as os}from"node:url";import{join as P,sep as Et,dirname as qt}from"node:path";import{copyFile as V,cp as as,mkdir as cs,readFile as ls,writeFile as Jt}from"node:fs/promises";import{access as Ve}from"node:fs/promises";import{constants as Be}from"node:fs";async function S(i){try{return await Ve(i,Be.F_OK),!0}catch{return!1}}import{access as Ke}from"node:fs/promises";import{constants as Ze}from"node:fs";async function j(i){try{return await Ke(i,Ze.F_OK),!0}catch{return!1}}import{join as M}from"node:path";import{readdir as qe}from"node:fs/promises";async function O(i){let t=[];try{let e=await qe(i,{withFileTypes:!0});for(let n of e)n.isDirectory()&&t.push(n.name)}catch(e){console.error("Error reading directory:",e)}return t}import{readFile as Ht}from"node:fs/promises";function st(i){return i&&i.charAt(0).toUpperCase()+i.slice(1)}function it(i){return i.replace(/([a-zA-Z])(?=[A-Z])/g,"$1-").toLowerCase()}var gt=i=>`\x1B[31m${i}\x1B[0m`,Bs=process.cwd();var z="src",k="components";function Yt(i){return{name:"playground-plugin",setup(t){let e="playground-entry",n="playground-module";t.onResolve({filter:new RegExp(`^${e}$`)},s=>({path:e,namespace:n})),t.onLoad({filter:/.*/,namespace:n},async s=>{let a=[],c=await O(M(z,k));c.length===0&&(console.log(gt('Missing at least 1 namespace folder under "src/components/"')),process.exit());let o=[];for(let r of c){let d={namespace:r,components:[]};o.push(d);let f=M(z,k,r),h=await O(f);for(let l of h)if(await S(M(z,k,r,l,`${l}.ts`))){let p="";await S(M(z,k,r,l,"README.md"))&&(p=await Ht(M(z,k,r,l,"README.md"),"utf8"));let u={namespace:r,component:l,tag:`${r}-${it(l)}`,examples:[],className:"",classExtends:"",readme:p};if(a.push(`import '${k}/${r}/${l}/${l}';`),await j(M(f,l,"__examples__"))){let _=await O(M(f,l,"__examples__"));for(let w of _)await S(M(f,l,"__examples__",w,`${w}.ts`))?(a.push(`import '${k}/${r}/${l}/__examples__/${w}/${w}';`),u.examples.push({namespace:r,component:l,example:w,tag:`x-${r}-${it(l)}-${it(w)}`,className:`X${st(r)}${st(l)}${st(w)}`})):console.log(gt(`Missing ${k}/${r}/${l}/__examples__/${w}/${w}.ts`))}let x=(await Ht(M(z,k,r,l,`${l}.ts`),"utf8")).match(/class (\w+) extends (\w+)/);x||(console.log(gt(`Component "${r}-${l}" must extend HtmlElement or base class`)),process.exit()),u.className=x[1],u.classExtends=x[2],d.components.push(u)}}return i.after(o),{contents:a.join(`
|
|
4
|
+
`),resolveDir:M(process.cwd(),z)}})}}}import{join as Je,sep as Gt}from"node:path";import{readFile as Xe}from"node:fs/promises";function Ut(i){return i.replace(/-([a-z])/g,t=>t[1].toUpperCase())}var Qe="node_modules",ts=process.cwd(),es=ts.split(Gt).length,ss=i=>`\x1B[31m${i}\x1B[0m`;function Vt({localNamespaces:i,externalNamespaces:t}){return{name:"html-dependents-plugin",setup(e){e.onLoad({filter:/\.html$/},async n=>{let s=n.path.split(Gt).splice(es),[a,c,o,r,...d]=s,f=await Xe(n.path,"utf8"),h=f.matchAll(/<\/(?<namespace>\w+)-(?<value>[^>]+)/g),l=new Map;for(let u of h){let{namespace:g,value:x}=u.groups,_=Ut(x);l.set(`${g}-${_}`,[g,_])}let p=[];return l.forEach(([u,g])=>{let x=s.length-4,_=new Array(x).fill("..");if(u===o){if(g===r)return;p.push(`import './${_.join("/")}/${g}/${g}';`)}else if(i.includes(u))p.push(`import './${_.join("/")}/${u}/${g}/${g}';`);else if(t.has(u)){_.push(".."),_.push(".."),_.push("..");let w=process.env.INIT_CWD;if(w){let C=Je(w,"node_modules");console.log("Node modules directory:",C)}else console.log("INIT_CWD not available. The script was likely not run via `npm run`.");let I=t.get(u);p.push(`import './${_.join("/")}/${Qe}/${I}/${u}/${g}/${g}';`)}else console.log(ss(`Unable to find namespace folder "${u}". Possibly missing 'external' in element.config.ts`)),process.exit()}),p.push(`export default \`${f}\`;`),{contents:p.join(`
|
|
5
|
+
`),loader:"js"}})}}}var is=i=>`\x1B[32m${i}\x1B[0m`,Bt={name:"rebuild-notify",setup(i){i.onEnd(t=>{t.errors.length>0?console.error(`Build ended with ${t.errors.length} errors`):console.log(is("Build succeeded!"))})}};import{join as yt}from"node:path";import{readFile as Kt}from"node:fs/promises";async function Zt({mode:i,rootDir:t,srcDir:e,indexFile:n,defaultDir:s,playgroundFile:a,title:c,repo:o,repoComponent:r,navigation:d,namespaces:f}){let h="";await S(yt(t,e,n))?h=await Kt(yt(t,e,n),"utf8"):h=await Kt(yt(s,a),"utf8"),h=h.replace("<title>Default</title>",`<title>${c??"Default"}</title>`),h=h.replace("<h1>Default</h1>",`<h1>${c??"Default"}</h1>`);let l=structuredClone(d??[]);for(let x of l)x.items=[];let p;l.length===0?(p={label:"Components",items:[]},l.push(p)):(p=l.find(x=>!x.extends&&!x.components&&!x.namespaces),p||(p={label:"Other",items:[]},l.push(p)));let u=new Map;if(f.forEach(({components:x})=>{x.forEach(({component:_,namespace:w,tag:I,readme:C,examples:v,className:T,classExtends:H})=>{u.set(T,{className:T,classExtends:H,component:_,namespace:w,tag:I,readme:C,examples:v.map(E=>E.className)}),v.forEach(E=>{u.set(E.className,{className:E.className,classExtends:E.classExtends,component:E.component,namespace:E.namespace,tag:E.tag,example:E.example})});for(let E of l)if(E.include&&E.include.includes(T)){E.items.push({namespace:w,component:_,className:T,tag:I});return}for(let E of l)if(E!==p&&!(E.exclude&&E.exclude.includes(T))&&!(E.namespaces&&!E.namespaces.includes(w))&&!(E.extends&&!E.extends.includes(H))){E.items.push({namespace:w,component:_,className:T,tag:I});return}p.items.push({namespace:w,component:_,examples:v,className:T,tag:I})})}),h=h.replace(/([ ]*)<!-- \[Navigation\] -->/,(x,_)=>l.map(({label:w,items:I})=>[_,`<div>${w}</div>`,"<ul>",I.map(({component:C,namespace:v,tag:T,className:H})=>[`<li data-tag="${T}" data-class-name="${H}" data-component="${C}"><a href="#${T}">${C}</a></li>`].join(`
|
|
6
6
|
${_}`)).join(`
|
|
7
7
|
${_}`),"</ul>"].join(`
|
|
8
8
|
${_}`)).join(`
|
|
9
|
-
${_}`)),o){let w=o.includes("github.com")?"M12,2A10,10 0 0,0 2,12C2,16.42 4.87,20.17 8.84,21.5C9.34,21.58 9.5,21.27 9.5,21C9.5,20.77 9.5,20.14 9.5,19.31C6.73,19.91 6.14,17.97 6.14,17.97C5.68,16.81 5.03,16.5 5.03,16.5C4.12,15.88 5.1,15.9 5.1,15.9C6.1,15.97 6.63,16.93 6.63,16.93C7.5,18.45 8.97,18 9.54,17.76C9.63,17.11 9.89,16.67 10.17,16.42C7.95,16.17 5.62,15.31 5.62,11.5C5.62,10.39 6,9.5 6.65,8.79C6.55,8.54 6.2,7.5 6.75,6.15C6.75,6.15 7.59,5.88 9.5,7.17C10.29,6.95 11.15,6.84 12,6.84C12.85,6.84 13.71,6.95 14.5,7.17C16.41,5.88 17.25,6.15 17.25,6.15C17.8,7.5 17.45,8.54 17.35,8.79C18,9.5 18.38,10.39 18.38,11.5C18.38,15.32 16.04,16.16 13.81,16.41C14.17,16.72 14.5,17.33 14.5,18.26C14.5,19.6 14.5,20.68 14.5,21C14.5,21.27 14.66,21.59 15.17,21.5C19.14,20.16 22,16.42 22,12A10,10 0 0,0 12,2Z":"M6,2H18A2,2 0 0,1 20,4V20A2,2 0 0,1 18,22H6A2,2 0 0,1 4,20V4A2,2 0 0,1 6,2M12.75,13.5C15.5,13.5 16.24,11.47 16.43,10.4C17.34,10.11 18,9.26 18,8.25C18,7 17,6 15.75,6C14.5,6 13.5,7 13.5,8.25C13.5,9.19 14.07,10 14.89,10.33C14.67,11 14,12 12,12C10.62,12 9.66,12.35 9,12.84V8.87C9.87,8.56 10.5,7.73 10.5,6.75C10.5,5.5 9.5,4.5 8.25,4.5C7,4.5 6,5.5 6,6.75C6,7.73 6.63,8.56 7.5,8.87V15.13C6.63,15.44 6,16.27 6,17.25C6,18.5 7,19.5 8.25,19.5C9.5,19.5 10.5,18.5 10.5,17.25C10.5,16.32 9.94,15.5 9.13,15.18C9.41,14.5 10.23,13.5 12.75,13.5M8.25,16.5A0.75,0.75 0 0,1 9,17.25A0.75,0.75 0 0,1 8.25,18A0.75,0.75 0 0,1 7.5,17.25A0.75,0.75 0 0,1 8.25,16.5M8.25,6A0.75,0.75 0 0,1 9,6.75A0.75,0.75 0 0,1 8.25,7.5A0.75,0.75 0 0,1 7.5,6.75A0.75,0.75 0 0,1 8.25,6M15.75,7.5A0.75,0.75 0 0,1 16.5,8.25A0.75,0.75 0 0,1 15.75,9A0.75,0.75 0 0,1 15,8.25A0.75,0.75 0 0,1 15.75,7.5Z";h=h.replace(/([ ]*)<!-- \[Repo\] -->/,(I,
|
|
10
|
-
${
|
|
9
|
+
${_}`)),o){let w=o.includes("github.com")?"M12,2A10,10 0 0,0 2,12C2,16.42 4.87,20.17 8.84,21.5C9.34,21.58 9.5,21.27 9.5,21C9.5,20.77 9.5,20.14 9.5,19.31C6.73,19.91 6.14,17.97 6.14,17.97C5.68,16.81 5.03,16.5 5.03,16.5C4.12,15.88 5.1,15.9 5.1,15.9C6.1,15.97 6.63,16.93 6.63,16.93C7.5,18.45 8.97,18 9.54,17.76C9.63,17.11 9.89,16.67 10.17,16.42C7.95,16.17 5.62,15.31 5.62,11.5C5.62,10.39 6,9.5 6.65,8.79C6.55,8.54 6.2,7.5 6.75,6.15C6.75,6.15 7.59,5.88 9.5,7.17C10.29,6.95 11.15,6.84 12,6.84C12.85,6.84 13.71,6.95 14.5,7.17C16.41,5.88 17.25,6.15 17.25,6.15C17.8,7.5 17.45,8.54 17.35,8.79C18,9.5 18.38,10.39 18.38,11.5C18.38,15.32 16.04,16.16 13.81,16.41C14.17,16.72 14.5,17.33 14.5,18.26C14.5,19.6 14.5,20.68 14.5,21C14.5,21.27 14.66,21.59 15.17,21.5C19.14,20.16 22,16.42 22,12A10,10 0 0,0 12,2Z":"M6,2H18A2,2 0 0,1 20,4V20A2,2 0 0,1 18,22H6A2,2 0 0,1 4,20V4A2,2 0 0,1 6,2M12.75,13.5C15.5,13.5 16.24,11.47 16.43,10.4C17.34,10.11 18,9.26 18,8.25C18,7 17,6 15.75,6C14.5,6 13.5,7 13.5,8.25C13.5,9.19 14.07,10 14.89,10.33C14.67,11 14,12 12,12C10.62,12 9.66,12.35 9,12.84V8.87C9.87,8.56 10.5,7.73 10.5,6.75C10.5,5.5 9.5,4.5 8.25,4.5C7,4.5 6,5.5 6,6.75C6,7.73 6.63,8.56 7.5,8.87V15.13C6.63,15.44 6,16.27 6,17.25C6,18.5 7,19.5 8.25,19.5C9.5,19.5 10.5,18.5 10.5,17.25C10.5,16.32 9.94,15.5 9.13,15.18C9.41,14.5 10.23,13.5 12.75,13.5M8.25,16.5A0.75,0.75 0 0,1 9,17.25A0.75,0.75 0 0,1 8.25,18A0.75,0.75 0 0,1 7.5,17.25A0.75,0.75 0 0,1 8.25,16.5M8.25,6A0.75,0.75 0 0,1 9,6.75A0.75,0.75 0 0,1 8.25,7.5A0.75,0.75 0 0,1 7.5,6.75A0.75,0.75 0 0,1 8.25,6M15.75,7.5A0.75,0.75 0 0,1 16.5,8.25A0.75,0.75 0 0,1 15.75,9A0.75,0.75 0 0,1 15,8.25A0.75,0.75 0 0,1 15.75,7.5Z";h=h.replace(/([ ]*)<!-- \[Repo\] -->/,(I,C)=>[C,`<a href="${o}">`,' <svg viewBox="0 0 24 24">',` <path fill="currentColor" d="${w}" />`," </svg>"," <span>View Repo</span>","</a>"].join(`
|
|
10
|
+
${C}`)),h=h.replace(/const repo = '';/,I=>`const repo = '${o}';`),h=h.replace(/const repoComponent = '';/,I=>`const repoComponent = '${r.replace(/\$repo/g,o)}';`),h=h.replace(/const repoIcon = '';/,I=>`const repoIcon = '${w}';`)}i==="dev"&&(h=h.replace(/([ ]*)<!-- \[info\] -->/,(x,_)=>[_,"<p>This page is generated from <code>npm start</code>. To render only specific components use <code>npm start c-button</code>.</p>"].join(`
|
|
11
11
|
${_}`)));let g=[...u.keys()];return h=h.replace(/([ ]*)const componentMap = new Map\(\);/,(x,_)=>[`${_}const componentMap = new Map();`,...g.map(w=>{let I=u.get(w);return`componentMap.set('${w}', ${JSON.stringify(I)});`})].join(`${_}
|
|
12
|
-
`)),h=h.replace(/([ ]*)const navigation = \[\];/,(x,_)=>`${_}const navigation = ${JSON.stringify(l,null," ")};`),h}(async()=>{let i=[Bt],t=R=>`\x1B[1m${R}\x1B[0m`,e=R=>`\x1B[32m${R}\x1B[0m`,n=R=>`\x1B[31m${R}\x1B[0m`,s=
|
|
12
|
+
`)),h=h.replace(/([ ]*)const navigation = \[\];/,(x,_)=>`${_}const navigation = ${JSON.stringify(l,null," ")};`),h}(async()=>{let i=[Bt],t=R=>`\x1B[1m${R}\x1B[0m`,e=R=>`\x1B[32m${R}\x1B[0m`,n=R=>`\x1B[31m${R}\x1B[0m`,s=os(import.meta.url),a=qt(s),c=P(a,"..","default"),o="element.config.ts",r=process.cwd(),d="publish",f=rs(o);await S(o)||(console.log(n("Missing element.config.ts in root."),"Add with content:"),console.log("export default {"),console.log(" namespace: 'hello',"),console.log("}"),process.exit());let h=await import(f.href),{namespace:l,external:p,title:u,navigation:g,repo:x,repoComponent:_,copy:w}=h.default,I="node_modules",C="dist",v="src",T="components",H=await O(P(r,v,T)),E=new Map;for(let R of p??[])(await O(P(r,I,...R.split("/")))).forEach(y=>{y!==I&&E.set(y,R)});i.push(Vt({localNamespaces:H,externalNamespaces:E}));let nt=[];if(l){console.log(e("Building app...")),nt.push(`./${v}/${T}/${l}/app/app.ts`);let R="index.html";if(await S(P(r,v,R)))await V(P(r,v,R),P(r,C,R));else{let y=await ls(P(c,R),"utf8");y=y.replace("<title>Default</title>",`<title>${u??"Default"}</title>`),y=y.replace("<namespace-app></namespace-app>",`<${l}-app></${l}-app>`),await Jt(P(r,C,R),y)}let $="favicon.svg";await S(P(r,v,$))?await V(P(r,v,$),P(r,C,$)):await V(P(c,$),P(r,C,$))}else{console.log(e("Building components...")),await j(P(v,T))||(console.log(n('Missing required "src/components" directory.')),process.exit());let R="playground.html",$="index.html";nt.push("playground-entry"),i.push(Yt({after:async y=>{let F=await Zt({mode:"dev",rootDir:r,srcDir:v,indexFile:$,defaultDir:c,playgroundFile:R,title:u,repo:x,repoComponent:_,navigation:g,namespaces:y});await Jt(P(r,C,$),F)}}))}let rt=await ns({entryPoints:nt,outfile:`./${C}/main.js`,bundle:!0,format:"esm",target:"es2024",sourcemap:!0,minify:!1,loader:{".css":"text"},plugins:i});await rt.rebuild(),(w??[]).forEach(async({from:R,to:$,exclude:y})=>{let F=$.split(Et),W=R.split(Et);if(W[W.length-1]===""&&(console.log(n('element.config.ts "copy" "from" should not end with a "/". Ex: "assets" not "assets/".')),process.exit()),F[F.length-1]===""&&(console.log(n('element.config.ts "copy" "to" should not end with a "/". Ex: "assets" not "assets/".')),process.exit()),y){let ot=W.join("/");for(let B of y)if(ot.includes(B))return}await j(P(r,v,...W))?await as(P(r,v,...W),P(r,C,...F),{recursive:!0}):await S(P(r,v,...W))&&await V(P(r,v,...W),P(r,C,...F))}),zt.watch("src",{ignoreInitial:!0}).on("all",async(R,$)=>{if(!l){let y=$.split(Et);if(y.length>4&&y[0]===v&&y[1]===T){let F=qt(P(r,d,...y.slice(2)));await j(F)||(console.log(`Creating publish/"${y.slice(2,-1).join("/")}"`),await cs(F,{recursive:!0})),console.log(`Copy "${y.slice(2).join("/")}" to publish/*`),await V(P(r,...y),P(r,d,...y.slice(2)))}(R==="change"||R==="add")&&((w??[]).forEach(async({from:F,to:W,exclude:ot})=>{let B=y.slice(1).join("/");B.startsWith(F)&&console.log("copy after",B,F,W,ot)}),await j(P(r,...y)))}try{await rt.rebuild()}catch(y){console.error("Rebuild failed:",y)}});let{port:Xt}=await rt.serve({servedir:C});console.log(e("Dev server started at"),`localhost:${Xt}`)})();
|
|
13
13
|
/*! Bundled license information:
|
|
14
14
|
|
|
15
15
|
chokidar/index.js:
|
package/package.json
CHANGED
|
@@ -1,4 +1,44 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
import { pathToFileURL, fileURLToPath } from 'node:url';
|
|
4
|
+
import { join, sep, dirname } from 'node:path';
|
|
5
|
+
import { copyFile, cp, mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
6
|
+
|
|
7
|
+
import { fileExists } from '../scripts/fileExists.ts';
|
|
8
|
+
|
|
9
|
+
const bold = (text: string) => `\x1b[1m${text}\x1b[0m`;
|
|
10
|
+
const green = (text: string) => `\x1b[32m${text}\x1b[0m`;
|
|
11
|
+
const red = (text: string) => `\x1b[31m${text}\x1b[0m`;
|
|
12
|
+
|
|
13
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
14
|
+
const __dirname = dirname(__filename);
|
|
15
|
+
const defaultDir = join(__dirname, '..', 'default');
|
|
16
|
+
const configFile = 'element.config.ts';
|
|
17
|
+
const rootDir = process.cwd();
|
|
18
|
+
const publishDir = 'publish';
|
|
19
|
+
const fullConfigPath = pathToFileURL(configFile);
|
|
20
|
+
if (!(await fileExists(configFile))) {
|
|
21
|
+
console.log(red('Missing element.config.ts in root.'), 'Add with content:');
|
|
22
|
+
console.log('export default {');
|
|
23
|
+
console.log(` namespace: 'hello',`);
|
|
24
|
+
console.log('}');
|
|
25
|
+
process.exit();
|
|
26
|
+
}
|
|
27
|
+
const config = await import(fullConfigPath.href);
|
|
28
|
+
|
|
29
|
+
const {
|
|
30
|
+
namespace,
|
|
31
|
+
external,
|
|
32
|
+
title,
|
|
33
|
+
navigation,
|
|
34
|
+
repo,
|
|
35
|
+
repoComponent,
|
|
36
|
+
copy,
|
|
37
|
+
} = config.default;
|
|
38
|
+
const nodeModulesDir = 'node_modules';
|
|
39
|
+
const distDir = 'dist';
|
|
40
|
+
const srcDir = 'src';
|
|
41
|
+
const componentsDir = 'components';
|
|
42
|
+
|
|
3
43
|
// Publish
|
|
4
44
|
console.log('publish');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { sep } from 'node:path';
|
|
1
|
+
import { dirname, join, sep } from 'node:path';
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
3
|
|
|
4
4
|
import { dashToCamel } from "./dashToCamel.ts";
|
|
@@ -48,6 +48,13 @@ export function htmlDependentsPlugin({
|
|
|
48
48
|
backPaths.push('..'); // src
|
|
49
49
|
backPaths.push('..'); // components
|
|
50
50
|
backPaths.push('..'); // node_modules
|
|
51
|
+
const projectRoot = process.env.INIT_CWD;
|
|
52
|
+
if (projectRoot) {
|
|
53
|
+
const nodeModulesPath = join(projectRoot, 'node_modules');
|
|
54
|
+
console.log('Node modules directory:', nodeModulesPath);
|
|
55
|
+
} else {
|
|
56
|
+
console.log('INIT_CWD not available. The script was likely not run via `npm run`.');
|
|
57
|
+
}
|
|
51
58
|
const pkg = externalNamespaces.get(namespace);
|
|
52
59
|
imports.push(`import './${backPaths.join('/')}/${nodeModulesDir}/${pkg}/${namespace}/${component}/${component}';`);
|
|
53
60
|
} else {
|