@pictogrammers/element-esbuild 0.0.20 → 0.0.22
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
|
-
|
|
4
|
-
`),loader:"js"}})}}}var pe=e=>`\x1B[32m${e}\x1B[0m`,
|
|
5
|
-
`),resolveDir:$(process.cwd(),
|
|
3
|
+
import{fileURLToPath as he,pathToFileURL as $e}from"node:url";import{build as ye}from"esbuild";import{join as re,sep as B}from"node:path";import{readFile as ae}from"node:fs/promises";function V(e){return e.replace(/-([a-z])/g,a=>a[1].toUpperCase())}var ie=process.cwd(),ce=ie.split(B).length,le=e=>`\x1B[31m${e}\x1B[0m`,z=process.env.INIT_CWD,Z="";z?Z=re(z,"node_modules"):(console.log("INIT_CWD not available. The script was likely not run via `npm run`."),process.exit());function H({localNamespaces:e,externalNamespaces:a}){return{name:"html-dependents-plugin",setup(m){m.onLoad({filter:/\.html$/},async d=>{let A=d.path.split(B).splice(ce),[M,E,g,c,...P]=A,y=await ae(d.path,"utf8"),o=y.matchAll(/<\/(?<namespace>\w+)-(?<value>[^>]+)/g),t=new Map;for(let l of o){let{namespace:u,value:i}=l.groups,n=V(i);t.set(`${u}-${n}`,[u,n])}let p=[];return t.forEach(([l,u])=>{let i=A.length-4,n=new Array(i).fill("..");if(l===g){if(u===c)return;p.push(`import './${n.join("/")}/${u}/${u}';`)}else if(e.includes(l))p.push(`import './${n.join("/")}/${l}/${u}/${u}';`);else if(a.has(l)){n.push(".."),n.push(".."),n.push("..");let s=a.get(l);p.push(`import './${Z}/${s}/${l}/${u}/${u}';`)}else console.log(le(`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 pe=e=>`\x1B[32m${e}\x1B[0m`,S={name:"rebuild-notify",setup(e){e.onEnd(a=>{a.errors.length>0?console.error(`Build ended with ${a.errors.length} errors`):console.log(pe("Build succeeded!"))})}};import{access as me}from"node:fs/promises";import{constants as ue}from"node:fs";async function C(e){try{return await me(e,ue.F_OK),!0}catch{return!1}}import{copyFile as G,writeFile as Ce}from"node:fs/promises";import{dirname as xe,join as w}from"node:path";import{join as $}from"node:path";import{readdir as fe}from"node:fs/promises";async function D(e){let a=[];try{let m=await fe(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 de}from"node:fs/promises";import{constants as ge}from"node:fs";async function J(e){try{return await de(e,ge.F_OK),!0}catch{return!1}}import{readFile as K}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`,it=process.cwd();var v="src",x="components";function W(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,x));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,x,c),o=await D(y);for(let t of o)if(await C($(v,x,c,t,`${t}.ts`))){let p="";await C($(v,x,c,t,"README.md"))&&(p=await K($(v,x,c,t,"README.md"),"utf8"));let l={namespace:c,component:t,tag:`${c}-${T(t)}`,examples:[],className:"",classExtends:"",readme:p};if(M.push(`import '${x}/${c}/${t}/${t}';`),await J($(y,t,"__examples__"))){let n=await D($(y,t,"__examples__"));for(let s of n)await C($(y,t,"__examples__",s,`${s}.ts`))?(M.push(`import '${x}/${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 ${x}/${c}/${t}/__examples__/${s}/${s}.ts`))}let i=(await K($(v,x,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 X}from"node:fs/promises";async function q({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 C(k(a,m,d))?o=await X(k(a,m,d),"utf8"):o=await X(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:f,readme:_,examples:N,className:h,classExtends:F})=>{l.set(h,{className:h,classExtends:F,component:n,namespace:s,tag:f,readme:_,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:f});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:f});return}p.items.push({namespace:s,component:n,examples:N,className:h,tag:f})})}),o=o.replace(/([ ]*)<!-- \[Navigation\] -->/,(i,n)=>t.map(({label:s,items:f})=>[n,`<div>${s}</div>`,"<ul>",f.map(({component:_,namespace:N,tag:h,className:F})=>[`<li data-tag="${h}" data-class-name="${F}" data-component="${_}"><a href="#${h}">${_}</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\] -->/,(f,_)=>[_,`<a href="${g}">`,' <svg viewBox="0 0 24 24">',` <path fill="currentColor" d="${s}" />`," </svg>"," <span>View Repo</span>","</a>"].join(`
|
|
10
|
+
${_}`)),o=o.replace(/const repo = '';/,f=>`const repo = '${g}';`),o=o.replace(/const repoComponent = '';/,f=>`const repoComponent = '${c.replace(/\$repo/g,g)}';`),o=o.replace(/const repoIcon = '';/,f=>`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 u=[...l.keys()];return o=o.replace(/([ ]*)const componentMap = new Map\(\);/,(i,n)=>[`${n}const componentMap = new Map();`,...u.map(s=>{let f=l.get(s);return`componentMap.set('${s}', ${JSON.stringify(f)});`})].join(`${n}
|
|
12
|
+
`)),o=o.replace(/([ ]*)const navigation = \[\];/,(i,n)=>`${n}const navigation = ${JSON.stringify(t,null," ")};`),o}var U=[S],L=[],we=e=>`\x1B[32m${e}\x1B[0m`,be=e=>`\x1B[31m${e}\x1B[0m`,Q="node_modules",_e="playground.html",De=he(import.meta.url),ve=xe(De),te=w(ve,"..","default"),Y="index.html";var j="src",ne="components",oe="element.config.ts",b=process.cwd(),R="build",Ae=$e(oe);await C(oe)||(console.log(be("Missing element.config.ts in root."),"Add with content:"),console.log("export default {"),console.log(" namespace: 'hello',"),console.log("}"),process.exit());var Me=await import(Ae.href),{namespace:ee,title:Ee,repo:Pe,repoComponent:je,navigation:Ne,external:Fe}=Me.default,Ie=await D(w(b,j,ne)),se=new Map;for(let e of Fe??[])(await D(w(b,Q,...e.split("/")))).forEach(m=>{m!==Q&&se.set(m,e)});U.push(H({localNamespaces:Ie,externalNamespaces:se}));ee?(console.log(we("Building app...")),L.push(`./${j}/${ne}/${ee}/app/app.ts`)):(L.push("playground-entry"),U.push(W({after:async e=>{let a=await q({mode:"production",rootDir:b,srcDir:j,indexFile:Y,defaultDir:te,playgroundFile:_e,title:Ee,repo:Pe,repoComponent:je,navigation:Ne,namespaces:e});await Ce(w(b,R,Y),a)}})));ye({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 C(w(b,j,e))?await G(w(b,j,e),w(b,R,e)):await G(w(te,e),w(b,R,e))}).catch(e=>{process.stderr.write(e.stderr),process.exit(1)});
|
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
|
-
var K=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});import{context as rs}from"esbuild";import{EventEmitter as $e}from"node:events";import{stat as Te}from"node:fs";import{readdir as Ae,stat as Fe}from"node:fs/promises";import*as m from"node:path";import{lstat as xt,readdir as te,realpath as ee,stat as se}from"node:fs/promises";import{join as ie,relative as ne,resolve as bt,sep as re}from"node:path";import{Readable as oe}from"node:stream";var A={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},ct={root:".",fileFilter:i=>!0,directoryFilter:i=>!0,type:A.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(ct);var vt="READDIRP_RECURSIVE_ERROR",ae=new Set(["ENOENT","EPERM","EACCES","ELOOP",vt]),Dt=[A.DIR_TYPE,A.EVERYTHING_TYPE,A.FILE_DIR_TYPE,A.FILE_TYPE],ce=new Set([A.DIR_TYPE,A.EVERYTHING_TYPE,A.FILE_DIR_TYPE]),le=new Set([A.EVERYTHING_TYPE,A.FILE_DIR_TYPE,A.FILE_TYPE]),he=i=>ae.has(i.code),fe=process.platform==="win32",Rt=i=>!0,Ct=i=>{if(i===void 0)return Rt;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 Rt},lt=class extends oe{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={...ct,...t},{root:n,type:s}=e;this._fileFilter=Ct(e.fileFilter),this._directoryFilter=Ct(e.directoryFilter);let a=e.lstat?xt:se;fe?this._stat=c=>a(c,{bigint:!0}):this._stat=a,this._maxDepth=e.depth!=null&&Number.isSafeInteger(e.depth)?e.depth:ct.depth,this._wantsDir=s?ce.has(s):!1,this._wantsFile=s?le.has(s):!1,this._wantsEverything=s===A.EVERYTHING_TYPE,this._root=bt(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 te(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=bt(ie(e,s));n={path:ne(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){he(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 ee(n),a=await xt(s);if(a.isFile())return"file";if(a.isDirectory()){let c=s.length;if(n.startsWith(s)&&n.substr(c,1)===re){let o=new Error(`Circular symlink detected: "${n}" points to "${s}"`);return o.code=vt,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 It(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&&!Dt.includes(e))throw new Error(`readdirp: Invalid type passed. Use one of ${Dt.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return t.root=i,new lt(t)}import{watch as de,unwatchFile as $t,watchFile as pe}from"node:fs";import{realpath as ht,lstat as ue,open as me,stat as At}from"node:fs/promises";import{type as _e}from"node:os";import*as b from"node:path";var we="data",pt="end",Ft="close",Q=()=>{};var tt=process.platform,ut=tt==="win32",ge=tt==="darwin",ye=tt==="linux",Ee=tt==="freebsd",Nt=_e()==="OS400",D={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},N=D,Pe="watch",xe={lstat:ue,stat:At},L="listeners",q="errHandlers",Y="rawEmitters",be=[L,q,Y],De=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"]),Re=i=>De.has(b.extname(i).slice(1).toLowerCase()),dt=(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)},Ce=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]},St=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&&J(b.resolve(i,o),L,b.join(i,o))};try{return de(i,{persistent:t.persistent},a)}catch(c){n(c);return}}var J=(i,t,e,n,s)=>{let a=Z.get(i);a&&dt(a[t],c=>{c(e,n,s)})},ve=(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,q,a),U(o,Y,c);else{if(r=Tt(i,e,J.bind(null,t,L),a,J.bind(null,t,Y)),!r)return;r.on(N.ERROR,async d=>{let f=J.bind(null,t,q);if(o&&(o.watcherUnusable=!0),ut&&d.code==="EPERM")try{await(await me(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,q,a),G(o,Y,c),St(o.listeners)&&(o.watcher.close(),Z.delete(t),be.forEach(Ce(o)),o.watcher=void 0,Object.freeze(o))}},ft=new Map,Ie=(i,t,e,n)=>{let{listener:s,rawEmitter:a}=n,c=ft.get(t),o=c&&c.options;return o&&(o.persistent<e.persistent||o.interval>e.interval)&&($t(t),c=void 0),c?(U(c,L,s),U(c,Y,a)):(c={listeners:s,rawEmitters:a,options:e,watcher:pe(t,e,(r,d)=>{dt(c.rawEmitters,h=>{h(N.CHANGE,t,{curr:r,prev:d})});let f=r.mtimeMs;(r.size!==d.size||f>d.mtimeMs||f===0)&&dt(c.listeners,h=>h(i,r))})},ft.set(t,c)),()=>{G(c,L,s),G(c,Y,a),St(c.listeners)&&(ft.delete(t),$t(t),c.options=c.watcher=void 0,Object.freeze(c))}},X=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=Q);let d;if(n.usePolling){let f=n.interval!==n.binaryInterval;r.interval=f&&Re(a)?n.binaryInterval:n.interval,d=Ie(t,o,r,{listener:e,rawEmitter:this.fsw._emitRaw})}else d=ve(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(Pe,t,5)){if(!h||h.mtimeMs===0)try{let l=await At(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),(ge||ye||Ee)&&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 ht(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(we,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(pt,()=>{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 xe[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 ht(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 ht(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 mt="/",Ne="//",jt=".",Se="..",Me="string",We=/\\/g,Ot=/\/\//g,ke=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,Le=/^\.[/\\]/;function et(i){return Array.isArray(i)?i:[i]}var _t=i=>typeof i=="object"&&i!==null&&!(i instanceof RegExp);function je(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 Oe(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(Ot,"/"),t&&(i="/"+i),i}function Mt(i,t,e){let n=Oe(t);for(let s=0;s<i.length;s++){let a=i[s];if(a(n,e))return!0}return!1}function ze(i,t){if(i==null)throw new TypeError("anymatch: specify first argument");let n=et(i).map(s=>je(s));return t==null?(s,a)=>Mt(n,s,a):Mt(n,t)}var Wt=i=>{let t=et(i).flat();if(!t.every(e=>typeof e===Me))throw new TypeError(`Non-string provided as watch path: ${t}`);return t.map(zt)},kt=i=>{let t=i.replace(We,mt),e=!1;return t.startsWith(Ne)&&(e=!0),t=t.replace(Ot,mt),e&&(t=mt+t),t},zt=i=>kt(m.normalize(kt(i))),Lt=(i="")=>t=>typeof t=="string"?zt(m.isAbsolute(t)?t:m.join(i,t)):t,He=(i,t)=>m.isAbsolute(i)?i:m.join(t,i),Ye=Object.freeze(new Set),wt=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!==jt&&t!==Se&&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 Ae(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=Q,this.items=Ye,Object.freeze(this)}},Ue="stat",Ge="lstat",gt=class{fsw;path;watchPath;fullWatchPath;dirParts;followSymlinks;statMethod;constructor(t,e,n){this.fsw=n;let s=t;this.path=t=t.replace(Le,""),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?Ue:Ge}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)}},st=class extends $e{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?et(t.ignored):et([]),awaitWriteFinish:e===!0?n:typeof e=="object"?{...n,...e}:!1};Nt&&(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=Q,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 X(this),Object.freeze(s)}_addIgnoredPath(t){if(_t(t)){for(let e of this._ignoredPaths)if(_t(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)_t(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=Wt(t);return s&&(a=a.map(c=>He(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=Wt(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)||jt;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;ut&&(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 Fe(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&&ke.test(t))return!0;if(!this._userIgnored){let{cwd:n}=this.options,a=(this.options.ignored||[]).map(Lt(n)),o=[...[...this._ignoredPaths].map(Lt(n)),...a];this._userIgnored=ze(o,void 0)}return this._userIgnored(t,e)}_isntIgnored(t,e){return!this._isIgnored(t,e)}_getWatchHelpers(t){return new gt(t,this.options.followSymlinks,this)}_getWatchedDir(t){let e=m.resolve(t);return this._watched.has(e)||this._watched.set(e,new wt(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=It(t,n);return this._streams.add(s),s.once(Ft,()=>{s=void 0}),s.once(pt,()=>{s&&(this._streams.delete(s),s=void 0)}),s}};function Ve(i,t={}){let e=new st(t);return e.add(i),e}var Ht={watch:Ve,FSWatcher:st};import{pathToFileURL as os,fileURLToPath as as}from"node:url";import{join as P,sep as Pt,dirname as Jt}from"node:path";import{copyFile as V,cp as cs,mkdir as ls,readFile as hs,writeFile as Xt}from"node:fs/promises";import{access as Be}from"node:fs/promises";import{constants as Ke}from"node:fs";async function S(i){try{return await Be(i,Ke.F_OK),!0}catch{return!1}}import{access as qe}from"node:fs/promises";import{constants as Ze}from"node:fs";async function j(i){try{return await qe(i,Ze.F_OK),!0}catch{return!1}}import{join as M}from"node:path";import{readdir as Je}from"node:fs/promises";async function O(i){let t=[];try{let e=await Je(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 Yt}from"node:fs/promises";function it(i){return i&&i.charAt(0).toUpperCase()+i.slice(1)}function nt(i){return i.replace(/([a-zA-Z])(?=[A-Z])/g,"$1-").toLowerCase()}var yt=i=>`\x1B[31m${i}\x1B[0m`,qs=process.cwd();var z="src",k="components";function Ut(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(yt('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 Yt(M(z,k,r,l,"README.md"),"utf8"));let u={namespace:r,component:l,tag:`${r}-${nt(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}-${nt(l)}-${nt(w)}`,className:`X${it(r)}${it(l)}${it(w)}`})):console.log(yt(`Missing ${k}/${r}/${l}/__examples__/${w}/${w}.ts`))}let x=(await Yt(M(z,k,r,l,`${l}.ts`),"utf8")).match(/class (\w+) extends (\w+)/);x||(console.log(yt(`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{
|
|
5
|
-
`),loader:"js"}})}}}var ns=i=>`\x1B[32m${i}\x1B[0m`,
|
|
3
|
+
import{context as rs}from"esbuild";import{EventEmitter as $e}from"node:events";import{stat as Ae}from"node:fs";import{readdir as Fe,stat as Ne}from"node:fs/promises";import*as m from"node:path";import{lstat as Pt,readdir as ee,realpath as se,stat as ie}from"node:fs/promises";import{join as ne,relative as re,resolve as xt,sep as oe}from"node:path";import{Readable as ae}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",ce=new Set(["ENOENT","EPERM","EACCES","ELOOP",Ct]),bt=[A.DIR_TYPE,A.EVERYTHING_TYPE,A.FILE_DIR_TYPE,A.FILE_TYPE],le=new Set([A.DIR_TYPE,A.EVERYTHING_TYPE,A.FILE_DIR_TYPE]),he=new Set([A.EVERYTHING_TYPE,A.FILE_DIR_TYPE,A.FILE_TYPE]),fe=i=>ce.has(i.code),de=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 ae{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:ie;de?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?le.has(s):!1,this._wantsFile=s?he.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 ee(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(ne(e,s));n={path:re(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){fe(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 se(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)===oe){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 pe,unwatchFile as It,watchFile as ue}from"node:fs";import{realpath as lt,lstat as me,open as _e,stat as $t}from"node:fs/promises";import{type as we}from"node:os";import*as b from"node:path";var ge="data",dt="end",At="close",X=()=>{};var Q=process.platform,pt=Q==="win32",ye=Q==="darwin",Ee=Q==="linux",Pe=Q==="freebsd",Ft=we()==="OS400",D={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},N=D,xe="watch",be={lstat:me,stat:$t},L="listeners",K="errHandlers",Y="rawEmitters",De=[L,K,Y],Re=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"]),Ce=i=>Re.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)},ve=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 pe(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)})},Ie=(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 _e(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),De.forEach(ve(o)),o.watcher=void 0,Object.freeze(o))}},ht=new Map,Te=(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:ue(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&&Ce(a)?n.binaryInterval:n.interval,d=Te(t,o,r,{listener:e,rawEmitter:this.fsw._emitRaw})}else d=Ie(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(xe,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),(ye||Ee||Pe)&&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(ge,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 be[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="/",Se="//",Lt=".",Me="..",We="string",ke=/\\/g,jt=/\/\//g,Le=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,je=/^\.[/\\]/;function tt(i){return Array.isArray(i)?i:[i]}var mt=i=>typeof i=="object"&&i!==null&&!(i instanceof RegExp);function Oe(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 ze(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=ze(t);for(let s=0;s<i.length;s++){let a=i[s];if(a(n,e))return!0}return!1}function He(i,t){if(i==null)throw new TypeError("anymatch: specify first argument");let n=tt(i).map(s=>Oe(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===We))throw new TypeError(`Non-string provided as watch path: ${t}`);return t.map(Ot)},Wt=i=>{let t=i.replace(ke,ut),e=!1;return t.startsWith(Se)&&(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,Ye=(i,t)=>m.isAbsolute(i)?i:m.join(t,i),Ue=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!==Me&&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 Fe(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=Ue,Object.freeze(this)}},Ge="stat",Ve="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(je,""),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?Ge:Ve}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 $e{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=>Ye(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 Ne(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){Ae(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&&Le.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=He(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 Be(i,t={}){let e=new et(t);return e.add(i),e}var zt={watch:Be,FSWatcher:et};import{pathToFileURL as os,fileURLToPath as as}from"node:url";import{join as P,sep as Et,dirname as Xt}from"node:path";import{copyFile as V,cp as cs,mkdir as ls,readFile as hs,writeFile as Qt}from"node:fs/promises";import{access as Ke}from"node:fs/promises";import{constants as Ze}from"node:fs";async function S(i){try{return await Ke(i,Ze.F_OK),!0}catch{return!1}}import{access as qe}from"node:fs/promises";import{constants as Je}from"node:fs";async function j(i){try{return await qe(i,Je.F_OK),!0}catch{return!1}}import{join as M}from"node:path";import{readdir as Xe}from"node:fs/promises";async function O(i){let t=[];try{let e=await Xe(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`,Ks=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 Qe,sep as Vt}from"node:path";import{readFile as ts}from"node:fs/promises";function Ut(i){return i.replace(/-([a-z])/g,t=>t[1].toUpperCase())}var es=process.cwd(),ss=es.split(Vt).length,is=i=>`\x1B[31m${i}\x1B[0m`,Gt=process.env.INIT_CWD,Bt="";Gt?Bt=Qe(Gt,"node_modules"):(console.log("INIT_CWD not available. The script was likely not run via `npm run`."),process.exit());function Kt({localNamespaces:i,externalNamespaces:t}){return{name:"html-dependents-plugin",setup(e){e.onLoad({filter:/\.html$/},async n=>{let s=n.path.split(Vt).splice(ss),[a,c,o,r,...d]=s,f=await ts(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=t.get(u);p.push(`import './${Bt}/${w}/${u}/${g}/${g}';`)}else console.log(is(`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 ns=i=>`\x1B[32m${i}\x1B[0m`,Zt={name:"rebuild-notify",setup(i){i.onEnd(t=>{t.errors.length>0?console.error(`Build ended with ${t.errors.length} errors`):console.log(ns("Build succeeded!"))})}};import{join as yt}from"node:path";import{readFile as qt}from"node:fs/promises";async function Jt({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 qt(yt(t,e,n),"utf8"):h=await qt(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:v,examples:C,className:T,classExtends:H})=>{u.set(T,{className:T,classExtends:H,component:_,namespace:w,tag:I,readme:v,examples:C.map(E=>E.className)}),C.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:C,className:T,tag:I})})}),h=h.replace(/([ ]*)<!-- \[Navigation\] -->/,(x,_)=>l.map(({label:w,items:I})=>[_,`<div>${w}</div>`,"<ul>",I.map(({component:v,namespace:C,tag:T,className:H})=>[`<li data-tag="${T}" data-class-name="${H}" data-component="${v}"><a href="#${T}">${v}</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,v)=>[v,`<a href="${o}">`,' <svg viewBox="0 0 24 24">',` <path fill="currentColor" d="${w}" />`," </svg>"," <span>View Repo</span>","</a>"].join(`
|
|
10
|
+
${v}`)),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=[
|
|
12
|
+
`)),h=h.replace(/([ ]*)const navigation = \[\];/,(x,_)=>`${_}const navigation = ${JSON.stringify(l,null," ")};`),h}(async()=>{let i=[Zt],t=R=>`\x1B[1m${R}\x1B[0m`,e=R=>`\x1B[32m${R}\x1B[0m`,n=R=>`\x1B[31m${R}\x1B[0m`,s=as(import.meta.url),a=Xt(s),c=P(a,"..","default"),o="element.config.ts",r=process.cwd(),d="publish",f=os(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",v="dist",C="src",T="components",H=await O(P(r,C,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(Kt({localNamespaces:H,externalNamespaces:E}));let nt=[];if(l){console.log(e("Building app...")),nt.push(`./${C}/${T}/${l}/app/app.ts`);let R="index.html";if(await S(P(r,C,R)))await V(P(r,C,R),P(r,v,R));else{let y=await hs(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 Qt(P(r,v,R),y)}let $="favicon.svg";await S(P(r,C,$))?await V(P(r,C,$),P(r,v,$)):await V(P(c,$),P(r,v,$))}else{console.log(e("Building components...")),await j(P(C,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 Jt({mode:"dev",rootDir:r,srcDir:C,indexFile:$,defaultDir:c,playgroundFile:R,title:u,repo:x,repoComponent:_,navigation:g,namespaces:y});await Qt(P(r,v,$),F)}}))}let rt=await rs({entryPoints:nt,outfile:`./${v}/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,C,...W))?await cs(P(r,C,...W),P(r,v,...F),{recursive:!0}):await S(P(r,C,...W))&&await V(P(r,C,...W),P(r,v,...F))}),zt.watch("src",{ignoreInitial:!0}).on("all",async(R,$)=>{if(!l){let y=$.split(Et);if(y.length>4&&y[0]===C&&y[1]===T){let F=Xt(P(r,d,...y.slice(2)));await j(F)||(console.log(`Creating publish/"${y.slice(2,-1).join("/")}"`),await ls(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:te}=await rt.serve({servedir:v});console.log(e("Dev server started at"),`localhost:${te}`)})();
|
|
13
13
|
/*! Bundled license information:
|
|
14
14
|
|
|
15
15
|
chokidar/index.js:
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { dirname, 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";
|
|
@@ -13,6 +13,15 @@ interface PluginOptions {
|
|
|
13
13
|
externalNamespaces: Map<string, string>
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
const projectRoot = process.env.INIT_CWD;
|
|
17
|
+
let rootNodeModules: string = '';
|
|
18
|
+
if (projectRoot) {
|
|
19
|
+
rootNodeModules = join(projectRoot, 'node_modules');
|
|
20
|
+
} else {
|
|
21
|
+
console.log('INIT_CWD not available. The script was likely not run via `npm run`.');
|
|
22
|
+
process.exit();
|
|
23
|
+
}
|
|
24
|
+
|
|
16
25
|
export function htmlDependentsPlugin({
|
|
17
26
|
localNamespaces,
|
|
18
27
|
externalNamespaces,
|
|
@@ -48,12 +57,9 @@ export function htmlDependentsPlugin({
|
|
|
48
57
|
backPaths.push('..'); // src
|
|
49
58
|
backPaths.push('..'); // components
|
|
50
59
|
backPaths.push('..'); // node_modules
|
|
51
|
-
const appDir2 = require.main?.paths[0].split('node_modules')[0].slice(0, -1);
|
|
52
|
-
const appDir = require.main?.filename ? dirname(require.main?.filename) : null;
|
|
53
|
-
console.log('dir>>>', appDir);
|
|
54
|
-
console.log('dir2>>>', appDir2);
|
|
55
60
|
const pkg = externalNamespaces.get(namespace);
|
|
56
|
-
imports.push(`import './${backPaths.join('/')}/${nodeModulesDir}/${pkg}/${namespace}/${component}/${component}';`);
|
|
61
|
+
//imports.push(`import './${backPaths.join('/')}/${nodeModulesDir}/${pkg}/${namespace}/${component}/${component}';`);
|
|
62
|
+
imports.push(`import './${rootNodeModules}/${pkg}/${namespace}/${component}/${component}';`);
|
|
57
63
|
} else {
|
|
58
64
|
console.log(red(`Unable to find namespace folder "${namespace}". Possibly missing 'external' in element.config.ts`));
|
|
59
65
|
process.exit();
|