@pictogrammers/element-esbuild 0.0.25 → 0.0.26

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.
@@ -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 ye,pathToFileURL as xe}from"node:url";import{build as Ce}from"esbuild";import{sep as B}from"node:path";import{readFile as ae}from"node:fs/promises";function z(e){return e.replace(/-([a-z])/g,r=>r[1].toUpperCase())}var ie=process.cwd(),ce=ie.split(B).length,le=e=>`\x1B[31m${e}\x1B[0m`;function Z({localNamespaces:e,externalNamespaces:r}){return{name:"html-dependents-plugin",setup(p){p.onLoad({filter:/\.html$/},async u=>{let b=u.path.split(B).splice(ce),[E,M,g,c,...P]=b,y=await ae(u.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=z(i);t.set(`${f}-${n}`,[f,n])}let m=[];return t.forEach(([l,f])=>{let i=b.length-4,n=new Array(i).fill("..");if(l===g){if(f===c)return;m.push(`import './${n.join("/")}/${f}/${f}';`)}else if(e.includes(l))m.push(`import './${n.join("/")}/${l}/${f}/${f}';`);else if(r.has(l)){n.push(".."),n.push(".."),n.push("..");let s=r.get(l);m.push(`import '${s}/${l}/${f}/${f}';`)}else console.log(le(`Unable to find namespace folder "${l}". Possibly missing 'external' in element.config.ts`)),process.exit()}),m.push(`export default \`${y}\`;`),{contents:m.join(`
4
- `),loader:"js"}})}}}var pe=e=>`\x1B[32m${e}\x1B[0m`,H={name:"rebuild-notify",setup(e){e.onEnd(r=>{r.errors.length>0?console.error(`Build ended with ${r.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 x(e){try{return await me(e,ue.F_OK),!0}catch{return!1}}import{copyFile as Y,writeFile as we}from"node:fs/promises";import{dirname as ve,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 r=[];try{let p=await fe(e,{withFileTypes:!0});for(let u of p)u.isDirectory()&&r.push(u.name)}catch(p){console.error("Error reading directory:",p)}return r}import{access as de}from"node:fs/promises";import{constants as ge}from"node:fs";async function S(e){try{return await de(e,ge.F_OK),!0}catch{return!1}}import{readFile as J}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 k=e=>`\x1B[31m${e}\x1B[0m`,ct=process.cwd();var A="src",C="components";function K(e){return{name:"playground-plugin",setup(r){let p="playground-entry",u="playground-module";r.onResolve({filter:new RegExp(`^${p}$`)},b=>({path:p,namespace:u})),r.onLoad({filter:/.*/,namespace:u},async b=>{let E=[],M=await D($(A,C));M.length===0&&(console.log(k('Missing at least 1 namespace folder under "src/components/"')),process.exit());let g=[];for(let c of M){let P={namespace:c,components:[]};g.push(P);let y=$(A,C,c),o=await D(y);for(let t of o)if(await x($(A,C,c,t,`${t}.ts`))){let m="";await x($(A,C,c,t,"README.md"))&&(m=await J($(A,C,c,t,"README.md"),"utf8"));let l={namespace:c,component:t,tag:`${c}-${T(t)}`,examples:[],className:"",classExtends:"",readme:m};if(E.push(`import '${C}/${c}/${t}/${t}';`),await S($(y,t,"__examples__"))){let n=await D($(y,t,"__examples__"));for(let s of n)await x($(y,t,"__examples__",s,`${s}.ts`))?(E.push(`import '${C}/${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(k(`Missing ${C}/${c}/${t}/__examples__/${s}/${s}.ts`))}let i=(await J($(A,C,c,t,`${t}.ts`),"utf8")).match(/class (\w+) extends (\w+)/);i||(console.log(k(`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:E.join(`
5
- `),resolveDir:$(process.cwd(),A)}})}}}import{join as L}from"node:path";import{readFile as W}from"node:fs/promises";async function X({mode:e,rootDir:r,srcDir:p,indexFile:u,defaultDir:b,playgroundFile:E,title:M,repo:g,repoComponent:c,navigation:P,namespaces:y}){let o="";await x(L(r,p,u))?o=await W(L(r,p,u),"utf8"):o=await W(L(b,E),"utf8"),o=o.replace("<title>Default</title>",`<title>${M??"Default"}</title>`),o=o.replace("<h1>Default</h1>",`<h1>${M??"Default"}</h1>`);let t=structuredClone(P??[]);for(let i of t)i.items=[];let m;t.length===0?(m={label:"Components",items:[]},t.push(m)):(m=t.find(i=>!i.extends&&!i.components&&!i.namespaces),m||(m={label:"Other",items:[]},t.push(m)));let l=new Map;if(y.forEach(({components:i})=>{i.forEach(({component:n,namespace:s,tag:d,readme:_,examples:N,className:h,classExtends:F})=>{l.set(h,{className:h,classExtends:F,component:n,namespace:s,tag:d,readme:_,examples:N.map(a=>a.className)}),N.forEach(a=>{l.set(a.className,{className:a.className,classExtends:a.classExtends,component:a.component,namespace:a.namespace,tag:a.tag,example:a.example})});for(let a of t)if(a.include&&a.include.includes(h)){a.items.push({namespace:s,component:n,className:h,tag:d});return}for(let a of t)if(a!==m&&!(a.exclude&&a.exclude.includes(h))&&!(a.namespaces&&!a.namespaces.includes(s))&&!(a.extends&&!a.extends.includes(F))){a.items.push({namespace:s,component:n,className:h,tag:d});return}m.items.push({namespace:s,component:n,examples:N,className:h,tag:d})})}),o=o.replace(/([ ]*)<!-- \[Navigation\] -->/,(i,n)=>t.map(({label:s,items:d})=>[n,`<div>${s}</div>`,"<ul>",d.map(({component:_,namespace:N,tag:h,className:F})=>[`<li data-tag="${h}" data-class-name="${F}" data-component="${_}"><a href="#${h}">${_}</a></li>`].join(`
3
+ import{fileURLToPath as xe,pathToFileURL as Ce}from"node:url";import{build as we}from"esbuild";import{sep as z}from"node:path";import{readFile as ie}from"node:fs/promises";function k(e){return e.replace(/-([a-z])/g,r=>r[1].toUpperCase())}var ce=process.cwd(),le=ce.split(z).length,pe=e=>`\x1B[31m${e}\x1B[0m`;function B({localNamespaces:e,externalNamespaces:r}){return{name:"html-dependents-plugin",setup(p){p.onLoad({filter:/\.html$/},async u=>{let b=u.path.split(z).splice(le),[E,M,g,c,...P]=b,y=await ie(u.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=k(i);t.set(`${f}-${n}`,[f,n])}let m=[];return t.forEach(([l,f])=>{let i=b.length-4,n=new Array(i).fill("..");if(l===g){if(f===c)return;m.push(`import './${n.join("/")}/${f}/${f}';`)}else if(e.includes(l))m.push(`import './${n.join("/")}/${l}/${f}/${f}';`);else if(r.has(l)){n.push(".."),n.push(".."),n.push("..");let s=r.get(l);m.push(`import '${s}/${l}/${f}/${f}';`)}else console.log(pe(`Unable to find namespace folder "${l}". Possibly missing 'external' in element.config.ts`)),process.exit()}),m.push(`export default \`${y}\`;`),{contents:m.join(`
4
+ `),loader:"js"}})}}}var me=e=>`\x1B[32m${e}\x1B[0m`,Z={name:"rebuild-notify",setup(e){e.onEnd(r=>{r.errors.length>0?console.error(`Build ended with ${r.errors.length} errors`):console.log(me("Build succeeded!"))})}};import{access as ue}from"node:fs/promises";import{constants as fe}from"node:fs";async function x(e){try{return await ue(e,fe.F_OK),!0}catch{return!1}}import{copyFile as Q,writeFile as ve}from"node:fs/promises";import{dirname as be,join as w}from"node:path";import{join as $}from"node:path";import{readdir as de}from"node:fs/promises";async function D(e){let r=[];try{let p=await de(e,{withFileTypes:!0});for(let u of p)u.isDirectory()&&r.push(u.name)}catch(p){console.error("Error reading directory:",p)}return r}import{access as ge}from"node:fs/promises";import{constants as he}from"node:fs";async function H(e){try{return await ge(e,he.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 L=e=>`\x1B[31m${e}\x1B[0m`,ct=process.cwd();var A="src",C="components";function J(e){return{name:"playground-plugin",setup(r){let p="playground-entry",u="playground-module";r.onResolve({filter:new RegExp(`^${p}$`)},b=>({path:p,namespace:u})),r.onLoad({filter:/.*/,namespace:u},async b=>{let E=[],M=await D($(A,C));M.length===0&&(console.log(L('Missing at least 1 namespace folder under "src/components/"')),process.exit());let g=[];for(let c of M){let P={namespace:c,components:[]};g.push(P);let y=$(A,C,c),o=await D(y);for(let t of o)if(await x($(A,C,c,t,`${t}.ts`))){let m="";await x($(A,C,c,t,"README.md"))&&(m=await S($(A,C,c,t,"README.md"),"utf8"));let l={namespace:c,component:t,tag:`${c}-${T(t)}`,examples:[],className:"",classExtends:"",readme:m};if(E.push(`import '${C}/${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`))?(E.push(`import '${C}/${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(L(`Missing ${C}/${c}/${t}/__examples__/${s}/${s}.ts`))}let i=(await S($(A,C,c,t,`${t}.ts`),"utf8")).match(/class (\w+) extends (\w+)/);i||(console.log(L(`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:E.join(`
5
+ `),resolveDir:$(process.cwd(),A)}})}}}import{join as U}from"node:path";import{readFile as K}from"node:fs/promises";async function W({mode:e,rootDir:r,srcDir:p,indexFile:u,defaultDir:b,playgroundFile:E,title:M,repo:g,repoComponent:c,navigation:P,namespaces:y}){let o="";await x(U(r,p,u))?o=await K(U(r,p,u),"utf8"):o=await K(U(b,E),"utf8"),o=o.replace("<title>Default</title>",`<title>${M??"Default"}</title>`),o=o.replace("<h1>Default</h1>",`<h1>${M??"Default"}</h1>`);let t=structuredClone(P??[]);for(let i of t)i.items=[];let m;t.length===0?(m={label:"Components",items:[]},t.push(m)):(m=t.find(i=>!i.extends&&!i.components&&!i.namespaces),m||(m={label:"Other",items:[]},t.push(m)));let l=new Map;if(y.forEach(({components:i})=>{i.forEach(({component:n,namespace:s,tag:d,readme:_,examples:N,className:h,classExtends:F})=>{l.set(h,{className:h,classExtends:F,component:n,namespace:s,tag:d,readme:_,examples:N.map(a=>a.className)}),N.forEach(a=>{l.set(a.className,{className:a.className,classExtends:a.classExtends,component:a.component,namespace:a.namespace,tag:a.tag,example:a.example})});for(let a of t)if(a.include&&a.include.includes(h)){a.items.push({namespace:s,component:n,className:h,tag:d});return}for(let a of t)if(a!==m&&!(a.exclude&&a.exclude.includes(h))&&!(a.namespaces&&!a.namespaces.includes(s))&&!(a.extends&&!a.extends.includes(F))){a.items.push({namespace:s,component:n,className:h,tag:d});return}m.items.push({namespace:s,component:n,examples:N,className:h,tag:d})})}),o=o.replace(/([ ]*)<!-- \[Navigation\] -->/,(i,n)=>t.map(({label:s,items:d})=>[n,`<div>${s}</div>`,"<ul>",d.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
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\] -->/,(d,_)=>[_,`<a href="${g}">`,' <svg viewBox="0 0 24 24">',` <path fill="currentColor" d="${s}" />`," </svg>"," <span>View Repo</span>","</a>"].join(`
10
10
  ${_}`)),o=o.replace(/const repo = '';/,d=>`const repo = '${g}';`),o=o.replace(/const repoComponent = '';/,d=>`const repoComponent = '${c.replace(/\$repo/g,g)}';`),o=o.replace(/const repoIcon = '';/,d=>`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
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 d=l.get(s);return`componentMap.set('${s}', ${JSON.stringify(d)});`})].join(`${n}
12
- `)),o=o.replace(/([ ]*)const navigation = \[\];/,(i,n)=>`${n}const navigation = ${JSON.stringify(t,null," ")};`),o}import{join as he,resolve as $e}from"node:path";var q=process.env.INIT_CWD,G="";q?G=he(q,"node_modules"):(console.log("INIT_CWD not available. The script was likely not run via `npm run`."),process.exit());function Q({externalNamespaces:e}){return{name:"resolve-external",setup(r){e.forEach(p=>{r.onResolve({filter:new RegExp(`^${p}/`)},u=>({path:$e(G,u.path.substring(`${p}/`.length))}))})}}}var O=[H],U=[],be=e=>`\x1B[32m${e}\x1B[0m`,_e=e=>`\x1B[31m${e}\x1B[0m`,ee="node_modules",De="playground.html",Ae=ye(import.meta.url),Ee=ve(Ae),oe=w(Ee,"..","default"),te="index.html";var j="src",se="components",re="element.config.ts",v=process.cwd(),R="build",Me=xe(re);await x(re)||(console.log(_e("Missing element.config.ts in root."),"Add with content:"),console.log("export default {"),console.log(" namespace: 'hello',"),console.log("}"),process.exit());var Pe=await import(Me.href),{namespace:ne,title:je,repo:Ne,repoComponent:Fe,navigation:Ie,external:Te}=Pe.default,Re=await D(w(v,j,se)),V=new Map;for(let e of Te??[])(await D(w(v,ee,...e.split("/")))).forEach(p=>{p!==ee&&V.set(p,e)});O.push(Q({externalNamespaces:V}));O.push(Z({localNamespaces:Re,externalNamespaces:V}));ne?(console.log(be("Building app...")),U.push(`./${j}/${se}/${ne}/app/app.ts`)):(U.push("playground-entry"),O.push(K({after:async e=>{let r=await X({mode:"production",rootDir:v,srcDir:j,indexFile:te,defaultDir:oe,playgroundFile:De,title:je,repo:Ne,repoComponent:Fe,navigation:Ie,namespaces:e});await we(w(v,R,te),r)}})));Ce({entryPoints:U,bundle:!0,platform:"browser",outfile:`./${R}/main.js`,sourcemap:!1,minify:!0,format:"esm",target:"es2024",loader:{".html":"text",".css":"text"},plugins:O}).then(async()=>{let e="favicon.svg";await x(w(v,j,e))?await Y(w(v,j,e),w(v,R,e)):await Y(w(oe,e),w(v,R,e))}).catch(e=>{process.stderr.write(e.stderr),process.exit(1)});
12
+ `)),o=o.replace(/([ ]*)const navigation = \[\];/,(i,n)=>`${n}const navigation = ${JSON.stringify(t,null," ")};`),o}import{join as $e,resolve as ye}from"node:path";var X=process.env.INIT_CWD,q="";X?q=$e(X,"node_modules"):(console.log("INIT_CWD not available. The script was likely not run via `npm run`."),process.exit());function G({external:e}){return{name:"resolve-external",setup(r){e.forEach(p=>{r.onResolve({filter:new RegExp(`^${p}/`)},u=>({path:ye(q,u.path.substring(`${p}/`.length))}))})}}}var O=[Z],V=[],_e=e=>`\x1B[32m${e}\x1B[0m`,De=e=>`\x1B[31m${e}\x1B[0m`,Y="node_modules",Ae="playground.html",Ee=xe(import.meta.url),Me=be(Ee),ne=w(Me,"..","default"),ee="index.html";var j="src",oe="components",se="element.config.ts",v=process.cwd(),R="build",Pe=Ce(se);await x(se)||(console.log(De("Missing element.config.ts in root."),"Add with content:"),console.log("export default {"),console.log(" namespace: 'hello',"),console.log("}"),process.exit());var je=await import(Pe.href),{namespace:te,title:Ne,repo:Fe,repoComponent:Ie,navigation:Te,external:re}=je.default,Re=await D(w(v,j,oe)),ae=new Map;for(let e of re??[])(await D(w(v,Y,...e.split("/")))).forEach(p=>{p!==Y&&ae.set(p,e)});O.push(G({external:re??[]}));O.push(B({localNamespaces:Re,externalNamespaces:ae}));te?(console.log(_e("Building app...")),V.push(`./${j}/${oe}/${te}/app/app.ts`)):(V.push("playground-entry"),O.push(J({after:async e=>{let r=await W({mode:"production",rootDir:v,srcDir:j,indexFile:ee,defaultDir:ne,playgroundFile:Ae,title:Ne,repo:Fe,repoComponent:Ie,navigation:Te,namespaces:e});await ve(w(v,R,ee),r)}})));we({entryPoints:V,bundle:!0,platform:"browser",outfile:`./${R}/main.js`,sourcemap:!1,minify:!0,format:"esm",target:"es2024",loader:{".html":"text",".css":"text"},plugins:O}).then(async()=>{let e="favicon.svg";await x(w(v,j,e))?await Q(w(v,j,e),w(v,R,e)):await Q(w(ne,e),w(v,R,e))}).catch(e=>{process.stderr.write(e.stderr),process.exit(1)});
@@ -2,14 +2,14 @@
2
2
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
3
3
  import{context as as}from"esbuild";import{EventEmitter as Ae}from"node:events";import{stat as Fe}from"node:fs";import{readdir as Ne,stat as Se}from"node:fs/promises";import*as m from"node:path";import{lstat as Pt,readdir as se,realpath as ie,stat as ne}from"node:fs/promises";import{join as re,relative as oe,resolve as xt,sep as ae}from"node:path";import{Readable as ce}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 Rt="READDIRP_RECURSIVE_ERROR",le=new Set(["ENOENT","EPERM","EACCES","ELOOP",Rt]),bt=[A.DIR_TYPE,A.EVERYTHING_TYPE,A.FILE_DIR_TYPE,A.FILE_TYPE],he=new Set([A.DIR_TYPE,A.EVERYTHING_TYPE,A.FILE_DIR_TYPE]),fe=new Set([A.EVERYTHING_TYPE,A.FILE_DIR_TYPE,A.FILE_TYPE]),de=i=>le.has(i.code),pe=process.platform==="win32",Dt=i=>!0,vt=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 ce{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=vt(e.fileFilter),this._directoryFilter=vt(e.directoryFilter);let a=e.lstat?Pt:ne;pe?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?he.has(s):!1,this._wantsFile=s?fe.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 se(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(re(e,s));n={path:oe(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){de(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 ie(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)===ae){let o=new Error(`Circular symlink detected: "${n}" points to "${s}"`);return o.code=Rt,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 Ct(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 ue,unwatchFile as It,watchFile as me}from"node:fs";import{realpath as lt,lstat as _e,open as we,stat as $t}from"node:fs/promises";import{type as ge}from"node:os";import*as b from"node:path";var ye="data",dt="end",At="close",X=()=>{};var Q=process.platform,pt=Q==="win32",Ee=Q==="darwin",Pe=Q==="linux",xe=Q==="freebsd",Ft=ge()==="OS400",D={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},N=D,be="watch",De={lstat:_e,stat:$t},L="listeners",K="errHandlers",Y="rawEmitters",ve=[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)},Ie=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 ue(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)})},Te=(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 we(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),ve.forEach(Ie(o)),o.watcher=void 0,Object.freeze(o))}},ht=new Map,$e=(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:me(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=$e(t,o,r,{listener:e,rawEmitter:this.fsw._emitRaw})}else d=Te(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(be,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),(Ee||Pe||xe)&&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(ye,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 De[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="/",Me="//",Lt=".",We="..",ke="string",Le=/\\/g,jt=/\/\//g,je=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,Oe=/^\.[/\\]/;function tt(i){return Array.isArray(i)?i:[i]}var mt=i=>typeof i=="object"&&i!==null&&!(i instanceof RegExp);function ze(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 He(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=He(t);for(let s=0;s<i.length;s++){let a=i[s];if(a(n,e))return!0}return!1}function Ye(i,t){if(i==null)throw new TypeError("anymatch: specify first argument");let n=tt(i).map(s=>ze(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===ke))throw new TypeError(`Non-string provided as watch path: ${t}`);return t.map(Ot)},Wt=i=>{let t=i.replace(Le,ut),e=!1;return t.startsWith(Me)&&(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,Ue=(i,t)=>m.isAbsolute(i)?i:m.join(t,i),Ge=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!==We&&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 Ne(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=Ge,Object.freeze(this)}},Ve="stat",Be="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(Oe,""),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?Ve:Be}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 Ae{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=>Ue(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 Se(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){Fe(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&&je.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=Ye(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=Ct(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 Ke(i,t={}){let e=new et(t);return e.add(i),e}var zt={watch:Ke,FSWatcher:et};import{pathToFileURL as cs,fileURLToPath as ls}from"node:url";import{join as P,sep as Et,dirname as Qt}from"node:path";import{copyFile as V,cp as hs,mkdir as fs,readFile as ds,writeFile as te}from"node:fs/promises";import{access as Ze}from"node:fs/promises";import{constants as qe}from"node:fs";async function S(i){try{return await Ze(i,qe.F_OK),!0}catch{return!1}}import{access as Je}from"node:fs/promises";import{constants as Xe}from"node:fs";async function j(i){try{return await Je(i,Xe.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`,qs=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
4
  `),resolveDir:M(process.cwd(),z)}})}}}import{sep as Gt}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(Gt).length,is=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(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 '${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`,Bt={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 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:R,className:T,classExtends:H})=>{u.set(T,{className:T,classExtends:H,component:_,namespace:w,tag:I,readme:C,examples:R.map(y=>y.className)}),R.forEach(y=>{u.set(y.className,{className:y.className,classExtends:y.classExtends,component:y.component,namespace:y.namespace,tag:y.tag,example:y.example})});for(let y of l)if(y.include&&y.include.includes(T)){y.items.push({namespace:w,component:_,className:T,tag:I});return}for(let y of l)if(y!==p&&!(y.exclude&&y.exclude.includes(T))&&!(y.namespaces&&!y.namespaces.includes(w))&&!(y.extends&&!y.extends.includes(H))){y.items.push({namespace:w,component:_,className:T,tag:I});return}p.items.push({namespace:w,component:_,examples:R,className:T,tag:I})})}),h=h.replace(/([ ]*)<!-- \[Navigation\] -->/,(x,_)=>l.map(({label:w,items:I})=>[_,`<div>${w}</div>`,"<ul>",I.map(({component:C,namespace:R,tag:T,className:H})=>[`<li data-tag="${T}" data-class-name="${H}" data-component="${C}"><a href="#${T}">${C}</a></li>`].join(`
5
+ `),loader:"js"}})}}}var ns=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(ns("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:R,className:T,classExtends:H})=>{u.set(T,{className:T,classExtends:H,component:_,namespace:w,tag:I,readme:C,examples:R.map(E=>E.className)}),R.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:R,className:T,tag:I})})}),h=h.replace(/([ ]*)<!-- \[Navigation\] -->/,(x,_)=>l.map(({label:w,items:I})=>[_,`<div>${w}</div>`,"<ul>",I.map(({component:C,namespace:R,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
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
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}import{join as rs,resolve as os}from"node:path";var qt=process.env.INIT_CWD,Jt="";qt?Jt=rs(qt,"node_modules"):(console.log("INIT_CWD not available. The script was likely not run via `npm run`."),process.exit());function Xt({externalNamespaces:i}){return{name:"resolve-external",setup(t){i.forEach(e=>{t.onResolve({filter:new RegExp(`^${e}/`)},n=>({path:os(Jt,n.path.substring(`${e}/`.length))}))})}}}(async()=>{let i=[Bt],t=v=>`\x1B[1m${v}\x1B[0m`,e=v=>`\x1B[32m${v}\x1B[0m`,n=v=>`\x1B[31m${v}\x1B[0m`,s=ls(import.meta.url),a=Qt(s),c=P(a,"..","default"),o="element.config.ts",r=process.cwd(),d="publish",f=cs(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",R="src",T="components",H=await O(P(r,R,T)),y=new Map;for(let v of p??[])(await O(P(r,I,...v.split("/")))).forEach(E=>{E!==I&&y.set(E,v)});i.push(Xt({externalNamespaces:y})),i.push(Vt({localNamespaces:H,externalNamespaces:y}));let nt=[];if(l){console.log(e("Building app...")),nt.push(`./${R}/${T}/${l}/app/app.ts`);let v="index.html";if(await S(P(r,R,v)))await V(P(r,R,v),P(r,C,v));else{let E=await ds(P(c,v),"utf8");E=E.replace("<title>Default</title>",`<title>${u??"Default"}</title>`),E=E.replace("<namespace-app></namespace-app>",`<${l}-app></${l}-app>`),await te(P(r,C,v),E)}let $="favicon.svg";await S(P(r,R,$))?await V(P(r,R,$),P(r,C,$)):await V(P(c,$),P(r,C,$))}else{console.log(e("Building components...")),await j(P(R,T))||(console.log(n('Missing required "src/components" directory.')),process.exit());let v="playground.html",$="index.html";nt.push("playground-entry"),i.push(Yt({after:async E=>{let F=await Zt({mode:"dev",rootDir:r,srcDir:R,indexFile:$,defaultDir:c,playgroundFile:v,title:u,repo:x,repoComponent:_,navigation:g,namespaces:E});await te(P(r,C,$),F)}}))}let rt=await as({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:v,to:$,exclude:E})=>{let F=$.split(Et),W=v.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()),E){let ot=W.join("/");for(let B of E)if(ot.includes(B))return}await j(P(r,R,...W))?await hs(P(r,R,...W),P(r,C,...F),{recursive:!0}):await S(P(r,R,...W))&&await V(P(r,R,...W),P(r,C,...F))}),zt.watch("src",{ignoreInitial:!0}).on("all",async(v,$)=>{if(!l){let E=$.split(Et);if(E.length>4&&E[0]===R&&E[1]===T){let F=Qt(P(r,d,...E.slice(2)));await j(F)||(console.log(`Creating publish/"${E.slice(2,-1).join("/")}"`),await fs(F,{recursive:!0})),console.log(`Copy "${E.slice(2).join("/")}" to publish/*`),await V(P(r,...E),P(r,d,...E.slice(2)))}(v==="change"||v==="add")&&((w??[]).forEach(async({from:F,to:W,exclude:ot})=>{let B=E.slice(1).join("/");B.startsWith(F)&&console.log("copy after",B,F,W,ot)}),await j(P(r,...E)))}try{await rt.rebuild()}catch(E){console.error("Rebuild failed:",E)}});let{port:ee}=await rt.serve({servedir:C});console.log(e("Dev server started at"),`localhost:${ee}`)})();
12
+ `)),h=h.replace(/([ ]*)const navigation = \[\];/,(x,_)=>`${_}const navigation = ${JSON.stringify(l,null," ")};`),h}import{join as rs,resolve as os}from"node:path";var qt=process.env.INIT_CWD,Jt="";qt?Jt=rs(qt,"node_modules"):(console.log("INIT_CWD not available. The script was likely not run via `npm run`."),process.exit());function Xt({external:i}){return{name:"resolve-external",setup(t){i.forEach(e=>{t.onResolve({filter:new RegExp(`^${e}/`)},n=>({path:os(Jt,n.path.substring(`${e}/`.length))}))})}}}(async()=>{let i=[Bt],t=v=>`\x1B[1m${v}\x1B[0m`,e=v=>`\x1B[32m${v}\x1B[0m`,n=v=>`\x1B[31m${v}\x1B[0m`,s=ls(import.meta.url),a=Qt(s),c=P(a,"..","default"),o="element.config.ts",r=process.cwd(),d="publish",f=cs(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",R="src",T="components",H=await O(P(r,R,T)),E=new Map;for(let v of p??[])(await O(P(r,I,...v.split("/")))).forEach(y=>{y!==I&&E.set(y,v)});i.push(Xt({external:p??[]})),i.push(Vt({localNamespaces:H,externalNamespaces:E}));let nt=[];if(l){console.log(e("Building app...")),nt.push(`./${R}/${T}/${l}/app/app.ts`);let v="index.html";if(await S(P(r,R,v)))await V(P(r,R,v),P(r,C,v));else{let y=await ds(P(c,v),"utf8");y=y.replace("<title>Default</title>",`<title>${u??"Default"}</title>`),y=y.replace("<namespace-app></namespace-app>",`<${l}-app></${l}-app>`),await te(P(r,C,v),y)}let $="favicon.svg";await S(P(r,R,$))?await V(P(r,R,$),P(r,C,$)):await V(P(c,$),P(r,C,$))}else{console.log(e("Building components...")),await j(P(R,T))||(console.log(n('Missing required "src/components" directory.')),process.exit());let v="playground.html",$="index.html";nt.push("playground-entry"),i.push(Yt({after:async y=>{let F=await Zt({mode:"dev",rootDir:r,srcDir:R,indexFile:$,defaultDir:c,playgroundFile:v,title:u,repo:x,repoComponent:_,navigation:g,namespaces:y});await te(P(r,C,$),F)}}))}let rt=await as({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:v,to:$,exclude:y})=>{let F=$.split(Et),W=v.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,R,...W))?await hs(P(r,R,...W),P(r,C,...F),{recursive:!0}):await S(P(r,R,...W))&&await V(P(r,R,...W),P(r,C,...F))}),zt.watch("src",{ignoreInitial:!0}).on("all",async(v,$)=>{if(!l){let y=$.split(Et);if(y.length>4&&y[0]===R&&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 fs(F,{recursive:!0})),console.log(`Copy "${y.slice(2).join("/")}" to publish/*`),await V(P(r,...y),P(r,d,...y.slice(2)))}(v==="change"||v==="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:ee}=await rt.serve({servedir:C});console.log(e("Dev server started at"),`localhost:${ee}`)})();
13
13
  /*! Bundled license information:
14
14
 
15
15
  chokidar/index.js:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pictogrammers/element-esbuild",
3
- "version": "0.0.25",
3
+ "version": "0.0.26",
4
4
  "type": "module",
5
5
  "description": "Element esbuild",
6
6
  "homepage": "https://github.com/Pictogrammers/Element-esbuild#readme",
@@ -62,7 +62,7 @@ for (let packageName of (external ?? [])) {
62
62
  });
63
63
  }
64
64
  // Workaround for npm link issues
65
- plugins.push(resolveExternal({ externalNamespaces }));
65
+ plugins.push(resolveExternal({ external: external ?? [] }));
66
66
  // Autoload referenced html elements
67
67
  plugins.push(htmlDependentsPlugin({
68
68
  localNamespaces,
@@ -71,7 +71,7 @@ for (let packageName of (external ?? [])) {
71
71
  });
72
72
  }
73
73
  // Workaround for npm link issues
74
- plugins.push(resolveExternal({ externalNamespaces }));
74
+ plugins.push(resolveExternal({ external: external ?? [] }));
75
75
  // Autoload referenced html elements
76
76
  plugins.push(htmlDependentsPlugin({
77
77
  localNamespaces,
@@ -13,17 +13,17 @@ if (projectRoot) {
13
13
  }
14
14
 
15
15
  interface PluginOptions {
16
- externalNamespaces: Map<string, string>;
16
+ external: Map<string, string>;
17
17
  }
18
18
 
19
- export function resolveExternal({ externalNamespaces }: PluginOptions) {
19
+ export function resolveExternal({ external }: PluginOptions) {
20
20
  return {
21
21
  name: 'resolve-external',
22
22
  setup(build: any) {
23
- externalNamespaces.forEach((externalNamespace) => {
24
- build.onResolve({ filter: new RegExp(`^${externalNamespace}/`) }, (args: any) => {
23
+ external.forEach((pkgName) => {
24
+ build.onResolve({ filter: new RegExp(`^${pkgName}/`) }, (args: any) => {
25
25
  // Resolve the path relative to the current working directory,
26
- const resolvedPath = resolve(rootNodeModules, args.path.substring(`${externalNamespace}/`.length));
26
+ const resolvedPath = resolve(rootNodeModules, args.path.substring(`${pkgName}/`.length));
27
27
  return { path: resolvedPath };
28
28
  });
29
29
  });