@visulima/packem 1.0.0-alpha.72 → 1.0.0-alpha.74

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.
Files changed (31) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cli.mjs +61 -61
  3. package/dist/config.cjs +1 -1
  4. package/dist/config.d.cts +6 -4
  5. package/dist/config.d.mts +6 -4
  6. package/dist/config.d.ts +6 -4
  7. package/dist/config.mjs +1 -1
  8. package/dist/create-bundler.cjs +59 -59
  9. package/dist/create-bundler.d.cts +3 -3
  10. package/dist/create-bundler.d.mts +3 -3
  11. package/dist/create-bundler.d.ts +3 -3
  12. package/dist/create-bundler.mjs +68 -68
  13. package/dist/rollup/plugins/oxc/isolated-declarations-oxc-transformer.d.cts +2 -2
  14. package/dist/rollup/plugins/oxc/isolated-declarations-oxc-transformer.d.mts +2 -2
  15. package/dist/rollup/plugins/oxc/isolated-declarations-oxc-transformer.d.ts +2 -2
  16. package/dist/rollup/plugins/swc/isolated-declarations-swc-transformer.d.cts +2 -2
  17. package/dist/rollup/plugins/swc/isolated-declarations-swc-transformer.d.mts +2 -2
  18. package/dist/rollup/plugins/swc/isolated-declarations-swc-transformer.d.ts +2 -2
  19. package/dist/rollup/plugins/swc/swc-plugin.d.cts +1 -1
  20. package/dist/rollup/plugins/swc/swc-plugin.d.mts +1 -1
  21. package/dist/rollup/plugins/swc/swc-plugin.d.ts +1 -1
  22. package/dist/rollup/plugins/typescript/isolated-declarations-typescript-transformer.d.cts +2 -2
  23. package/dist/rollup/plugins/typescript/isolated-declarations-typescript-transformer.d.mts +2 -2
  24. package/dist/rollup/plugins/typescript/isolated-declarations-typescript-transformer.d.ts +2 -2
  25. package/dist/shared/{packem.iWQSRLv6.d.cts → packem.Bvs809O8.d.cts} +11 -8
  26. package/dist/shared/{packem.Cvy5yEVh.d.cts → packem.CzGE8V_d.d.cts} +2 -2
  27. package/dist/shared/{packem.Cvy5yEVh.d.mts → packem.CzGE8V_d.d.mts} +2 -2
  28. package/dist/shared/{packem.Cvy5yEVh.d.ts → packem.CzGE8V_d.d.ts} +2 -2
  29. package/dist/shared/{packem.D8xT1G8q.d.ts → packem.DVC0qWmL.d.ts} +11 -8
  30. package/dist/shared/{packem.6LZ1Jtxj.d.mts → packem.QRV4ieck.d.mts} +11 -8
  31. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -1,117 +1,117 @@
1
1
  #!/usr/bin/env node
2
- var Dt=Object.defineProperty;var d=(e,t)=>Dt(e,"name",{value:t,configurable:!0});import Nt from"@visulima/cerebro";import{SimpleReporter as _t}from"@visulima/pail/reporter";import{env as j,versions as Pt,cwd as Ct,exit as Mt}from"node:process";import{DEFAULTS as It,nodeResolve as Be}from"@rollup/plugin-node-resolve";import{chmod as Rt,stat as We,readdir as Ft}from"node:fs/promises";import je from"node:module";import{cyan as h,bold as N,gray as R,yellow as Tt,grey as At,green as Jt}from"@visulima/colorize";import{readFile as ce,writeFile as z,isAccessibleSync as k,collectSync as Bt,readFileSync as Le,writeFileSync as q,writeJsonSync as Wt,ensureDirSync as Lt,emptyDir as ze,walk as zt,isAccessible as Ut}from"@visulima/fs";import{NotFoundError as Vt}from"@visulima/fs/error";import{formatBytes as M,duration as Ht}from"@visulima/humanizer";import{parsePackageJson as Ue}from"@visulima/package/package-json";import{resolve as g,join as y,normalize as pe,extname as ue,relative as D,dirname as de,basename as G,isAbsolute as Ve,toNamespacedPath as ke}from"@visulima/path";import{readTsConfig as qt,findTsConfig as Yt}from"@visulima/tsconfig";import{defu as Gt}from"defu";import{createHooks as Kt}from"hookable";import{rollup as He,watch as xe,VERSION as Xt}from"rollup";import{pathToFileURL as Zt,fileURLToPath as Qt}from"node:url";import{resolvePath as eo,resolveModuleExportNames as to,findStaticImports as qe}from"mlly";import P from"magic-string";import Ye from"jiti";import{existsSync as me,rmSync as oo}from"node:fs";import Ge from"@rollup/plugin-alias";import no from"@rollup/plugin-commonjs";import ro from"@rollup/plugin-dynamic-import-vars";import Ke from"@rollup/plugin-replace";import{wasm as io}from"@rollup/plugin-wasm";import so from"rollup-plugin-polyfill-node";import{visualizer as ao}from"rollup-plugin-visualizer";import{minVersion as Xe}from"semver";import{glob as lo}from"glob";import co from"glob-parent";import{createFilter as L,normalizePath as Ee}from"@rollup/pluginutils";import po from"@rollup/plugin-json";import uo from"rollup-plugin-license";import{createHash as mo}from"node:crypto";import{parse as fo}from"@babel/parser";import{findCacheDirSync as go}from"@visulima/find-cache-dir";import{distance as ho}from"fastest-levenshtein";import{installPackage as yo}from"@antfu/install-pkg";import{intro as vo,isCancel as bo,cancel as wo,select as $o,confirm as jo,spinner as Q,outro as ko}from"@clack/prompts";import __cjs_url__ from "node:url"; // -- packem CommonJS __filename shim --
2
+ var Dt=Object.defineProperty;var m=(e,t)=>Dt(e,"name",{value:t,configurable:!0});import Nt from"@visulima/cerebro";import{SimpleReporter as _t}from"@visulima/pail/reporter";import{env as q,versions as Pt,cwd as Ct,exit as Mt}from"node:process";import{DEFAULTS as It,nodeResolve as We}from"@rollup/plugin-node-resolve";import{chmod as Rt,stat as Le,readdir as Ft}from"node:fs/promises";import ke from"node:module";import{cyan as v,bold as N,gray as R,yellow as Tt,grey as At,green as Jt}from"@visulima/colorize";import{readFile as ce,writeFile as z,isAccessibleSync as b,collectSync as Bt,readFileSync as ze,writeFileSync as K,writeJsonSync as Wt,ensureDirSync as Lt,emptyDir as Ue,walk as zt,isAccessible as Ut}from"@visulima/fs";import{NotFoundError as Vt}from"@visulima/fs/error";import{formatBytes as M,duration as Ht}from"@visulima/humanizer";import{parsePackageJson as Ve}from"@visulima/package/package-json";import{resolve as g,join as h,normalize as pe,extname as ue,relative as S,dirname as de,basename as G,isAbsolute as He,toNamespacedPath as xe}from"@visulima/path";import{readTsConfig as qt,findTsConfig as Kt}from"@visulima/tsconfig";import{defu as Yt}from"defu";import{createHooks as Gt}from"hookable";import{rollup as qe,watch as Ee,VERSION as Xt}from"rollup";import{pathToFileURL as Zt,fileURLToPath as Qt}from"node:url";import{resolvePath as eo,resolveModuleExportNames as to,findStaticImports as Ke}from"mlly";import P from"magic-string";import Ye from"jiti";import{existsSync as me,rmSync as oo}from"node:fs";import Ge from"@rollup/plugin-alias";import no from"@rollup/plugin-commonjs";import ro from"@rollup/plugin-dynamic-import-vars";import Xe from"@rollup/plugin-replace";import{wasm as io}from"@rollup/plugin-wasm";import so from"rollup-plugin-polyfill-node";import{visualizer as ao}from"rollup-plugin-visualizer";import{minVersion as Ze}from"semver";import{glob as lo}from"glob";import co from"glob-parent";import{createFilter as W,normalizePath as Oe}from"@rollup/pluginutils";import po from"@rollup/plugin-json";import uo from"rollup-plugin-license";import{createHash as mo}from"node:crypto";import{parse as fo}from"@babel/parser";import{findCacheDirSync as go}from"@visulima/find-cache-dir";import{distance as ho}from"fastest-levenshtein";import{installPackage as yo}from"@antfu/install-pkg";import{intro as vo,isCancel as bo,cancel as $o,select as wo,confirm as jo,spinner as Q,outro as ko}from"@clack/prompts";import __cjs_url__ from "node:url"; // -- packem CommonJS __filename shim --
3
3
  import __cjs_path__ from "node:path"; // -- packem CommonJS __dirname shim --
4
4
  import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
5
5
  const __filename = __cjs_url__.fileURLToPath(import.meta.url);
6
6
  const __dirname = __cjs_path__.dirname(__filename);
7
7
  const require = __cjs_mod__.createRequire(import.meta.url);
8
- const xo="@visulima/packem",Eo="1.0.0-alpha.71",A=[...It.extensions,".cjs",".ts",".cts",".mts",".tsx",".jsx"],S="production",B="development",Oo=[B,S],Ze=["react-server","react-native","edge-light"];[...Oo,...Ze];const ee=/node_modules/;var So=Object.defineProperty,K=d((e,t)=>So(e,"name",{value:t,configurable:!0}),"i$c");const fe=/^#![^\n]*/,ae=K(async e=>{await Rt(e,493).catch(()=>{})},"makeExecutable"),Do=K((e,t=`#!/usr/bin/env node
9
- `)=>({name:"packem:shebang",renderChunk:{handler(o,n,r){if(!n.isEntry||!n.facadeModuleId||o.startsWith("#")&&o[1]==="!")return null;if(e.includes(n.name)){const i=new P(o);return i.prepend(t),{code:i.toString(),map:r.sourcemap?i.generateMap({hires:!0}):void 0}}return null},order:"post"},async writeBundle(o,n){for(const[r,i]of Object.entries(n))if(i.type==="chunk"&&fe.test(i.code)&&o.dir){const s=g(o.dir,r);await ae(s)}}}),"shebangPlugin"),No=K(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(fe,"")}}),"removeShebangPlugin"),_o=K((e,t=`
10
- `)=>{const o=fe.exec(e);return o?o+t:""},"getShebang");var Po=Object.defineProperty,Co=d((e,t)=>Po(e,"name",{value:t,configurable:!0}),"p$4");const ge=Co((e,t)=>{let o={};if(e.pkg.name&&(o[e.pkg.name]=e.options.rootDir),e.pkg.imports){const{imports:n}=e.pkg;for(const r in n){if(r.startsWith("#"))continue;const i=n[r];typeof i=="string"&&(o[r]=y(e.options.rootDir,i))}}return o={...o,...e.options.alias},e.options.rollup.alias&&(Array.isArray(e.options.rollup.alias.entries)?Object.assign(o,Object.fromEntries(e.options.rollup.alias.entries.map(n=>[n.find,n.replacement]))):Object.assign(o,e.options.rollup.alias.entries??e.options.rollup.alias)),e.logger.debug({message:"Resolved aliases: "+JSON.stringify(o),prefix:t}),o},"resolveAliases");var Mo=Object.defineProperty,Io=d((e,t)=>Mo(e,"name",{value:t,configurable:!0}),"o$3");const Ro=Io((e,t)=>{const o=Ye(t,{esmResolve:!0,interopDefault:!0});try{return o.resolve(e)}catch(n){if(n.code!=="MODULE_NOT_FOUND")throw new Error(`Error trying import ${e} from ${t}`,{cause:n});return e}},"tryResolve");var Fo=Object.defineProperty,To=d((e,t)=>Fo(e,"name",{value:t,configurable:!0}),"r$9");const W=To((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var Ao=Object.defineProperty,Jo=d((e,t)=>Ao(e,"name",{value:t,configurable:!0}),"u$a");const Bo=Jo(async e=>{const t=await eo("jiti",{url:import.meta.url}),o=JSON.stringify({...e.options.stubOptions.jiti,alias:{...ge(e,"jit"),...e.options.stubOptions.jiti.alias}},null,2);for(const n of e.options.entries){const r=g(e.options.rootDir,e.options.outDir,n.name),i=pe(Ro(n.input,e.options.rootDir)||n.input),s=i.slice(0,Math.max(0,i.length-ue(i).length)),a=await ce(i),l=_o(a);e.options.emitCJS&&await z(`${r}.cjs`,l+[`const jiti = require(${JSON.stringify(t)})`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(s)})} */`,`module.exports = _jiti(${JSON.stringify(i)})`].join(`
11
- `));let c=[];try{c=await to(i,{extensions:A})}catch(u){W(e,`Cannot analyze ${i} for exports: ${u.toString()}`);return}const p=c.includes("default")||c.length===0;await z(`${r}.mjs`,l+[`import jiti from ${JSON.stringify(Zt(t).href)};`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(i)})} */`,`const _module = await _jiti.import(${JSON.stringify(i)});`,p?`
12
- export default _module;`:"",...c.filter(u=>u!=="default").map(u=>`export const ${u} = _module.${u};`)].join(`
13
- `)),await z(`${r}.d.cts`,[`export * from ${JSON.stringify(s)};`,p?`export { default } from ${JSON.stringify(s)};`:""].join(`
14
- `)),await z(`${r}.d.mts`,[`export * from ${JSON.stringify(i)};`,p?`export { default } from ${JSON.stringify(i)};`:""].join(`
15
- `)),l&&(await ae(`${r}.cjs`),await ae(`${r}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var Wo=Object.defineProperty,Lo=d((e,t)=>Wo(e,"name",{value:t,configurable:!0}),"r$8");const Qe=Lo((e,t)=>Ye(t,{esmResolve:!0,interopDefault:!0})(e),"tryRequire");var zo=Object.defineProperty,et=d((e,t)=>zo(e,"name",{value:t,configurable:!0}),"t$8");const Y=et(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),tt=et((e,t,o,n)=>{if(o){const s=Y(o);if(s)return s}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return n==="commonjs"?"cjs":"esm";const[r,...i]=t;return tt(r,i,o,n)},"inferExportType");var Uo=Object.defineProperty,Vo=d((e,t)=>Uo(e,"name",{value:t,configurable:!0}),"n$8");const he=Vo((e,t,o,n=[])=>{if(!e)return[];if(typeof e=="string"){const r=Y(e),i=t==="module"?"esm":"cjs";if(r&&r!==i)throw new Error(`Exported file "${e}" has an extension that does not match the package.json type "${t}".`);return[{file:e,key:"exports",type:r??i}]}return Object.entries(e).filter(([r])=>!r.endsWith(".json")).flatMap(([r,i])=>r==="types"&&o===!1?[]:typeof i=="string"?{file:i,key:"exports",...["browser","default","deno","development","import","node","node-addons","production","require","types"].includes(r)?{subKey:r}:{},type:tt(r,n,i,t)}:he(i,t,o,[...n,r]))},"extractExportFilenames");var Ho=Object.defineProperty,ye=d((e,t)=>Ho(e,"name",{value:t,configurable:!0}),"a$c");const qo=ye(e=>{if(e.key==="exports"&&e.subKey==="production")return"production";if(e.key==="exports"&&e.subKey==="development")return"development";if(j.production){if(!j.NODE_ENV.includes(S)&&!j.NODE_ENV.includes(B))throw new Error("Invalid production value: "+j.production+', must be either "'+S+'" or "'+B+'".');return j.production}return"production"},"getEnvironment"),U=ye((e,t,o,n,r,i)=>{const s=e.find(a=>a.input===t)??e[e.push({input:t})-1];if(o&&(s.outDir=n),r.isExecutable)s.executable=!0,s.declaration=!1,r.type==="cjs"&&(s.cjs=!0),r.type==="esm"&&(s.esm=!0);else{/\.d\.[mc]?ts$/.test(r.file)&&i!==!1&&(s.declaration=i),r.type==="cjs"&&(s.cjs=!0),r.type==="esm"&&(s.esm=!0);for(const a of Ze)if(r.file.includes("."+a+".")){s.runtime=a;break}}s.runtime===void 0&&(s.runtime="node"),s.environment=qo(r)},"createOrUpdateEntry"),Oe=/(?:\.d\.[mc]?ts|\.\w+)$/;let Se=!1;const Yo=ye((e,t,o)=>{const n=[];t.sort((a,l)=>a.split("/").length-l.split("/").length);const r=e.type==="module"?"esm":"cjs",i=he(e.exports,e.type??"commonjs",o.options.declaration);if(e.bin){const a=(typeof e.bin=="string"?[e.bin]:Object.values(e.bin)).filter(Boolean);for(const l of a){const c=Y(l);if(c&&c!==r)throw new Error(`Exported file "${l}" has an extension that does not match the package.json type "${e.type}".`);i.push({file:l,isExecutable:!0,key:"bin",type:c??r})}}e.main&&i.push({file:e.main,key:"main",type:Y(e.main)??r}),e.module&&i.push({file:e.module,key:"module",type:"esm"}),(e.types||e.typings)&&o.options.declaration&&i.push({file:e.types??e.typings,key:"types"});const s=[];for(const a of i){const l=a.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),c=l.endsWith("/");if(c&&["./","/"].includes(l))continue;const p=l.replace(new RegExp("(./)?"+o.options.outDir),o.options.sourceDir).replace("./","");if(a.file.includes("/*")&&a.key==="exports"){Se||(o.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),Se=!0);const f=[],b=new RegExp("(?<=/|$)"+p.replace("*","(.*)")+(c?"":"\\.\\w+"));for(const w of t)b.test(w)&&f.push(w.replace(Oe,""));if(f.length===0){n.push(`Could not find entrypoint for \`${a.file}\``);continue}for(const w of f)U(s,w,c,l,a,o.options.declaration);continue}const u=new RegExp("(?<=/|$)"+p+(c?"":"\\.\\w+")),m=t.find(f=>u.test(f))?.replace(Oe,"");if(!m){me(g(o.options.rootDir,a.file))||n.push(`Could not find entrypoint for \`${a.file}\``);continue}if(k(m+".cts")&&k(m+".mts")){if(o.pkg?.dependencies?.typescript===void 0&&o.pkg?.devDependencies?.typescript===void 0)throw new Error("You tried to use a `.cts` or `.mts` file but `typescript` was not found in your package.json.");U(s,m+".cts",c,l,{...a,type:"cjs"},o.options.declaration),U(s,m+".mts",c,l,{...a,type:"esm"},o.options.declaration)}else{if((k(m+".ts")||k(m+".cts")||k(m+".mts"))&&o.pkg?.dependencies?.typescript===void 0&&o.pkg?.devDependencies?.typescript===void 0)throw new Error("You tried to use a `.ts`, `.cts` or `.mts` file but `typescript` was not found in your package.json.");U(s,m,c,l,a,o.options.declaration)}}return{entries:s,warnings:n}},"inferEntries");var Go=Object.defineProperty,Ko=d((e,t)=>Go(e,"name",{value:t,configurable:!0}),"t$7");const Xo=Ko((e,t)=>{const{publishConfig:o}=e;return o&&(o.bin&&(typeof o.bin=="object"||typeof o.bin=="string")&&(e.bin=o.bin),o.type&&typeof o.type=="string"&&o.type!==""&&(e.type=o.type),o.main&&typeof o.main=="string"&&o.main!==""&&(e.main=o.main),o.module&&typeof o.module=="string"&&o.module!==""&&(e.module=o.module),t===void 0&&o.types&&typeof o.types=="string"&&o.types!==""?e.types=o.types:t===void 0&&o.typings&&typeof o.typings=="string"&&o.typings!==""&&(e.typings=o.typings),o.exports&&typeof o.exports=="object"&&(e.exports=o.exports)),e},"overwriteWithPublishConfig");var Zo=Object.defineProperty,Qo=d((e,t)=>Zo(e,"name",{value:t,configurable:!0}),"t$6");const en={hooks:{"build:prepare":Qo(function(e){if(e.options.entries.length>0)return;const t=y(e.options.rootDir,e.options.sourceDir);if(!me(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=Bt(t,{extensions:[],includeDirs:!1,includeSymlinks:!1});if(o.length===0)throw new Error("No source files found in 'src' directory. Please provide entries manually.");let n={...e.pkg};n.publishConfig&&(n=Xo(n,e.options.declaration));const r=Yo(n,o,e);for(const i of r.warnings)W(e,i);if(e.options.entries.push(...r.entries),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",h(e.options.entries.map(i=>N(i.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),R([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(i=>`[${i}]`).join(" ")))},"build:prepare")}};var tn=Object.defineProperty,on=d((e,t)=>tn(e,"name",{value:t,configurable:!0}),"t$5");const nn=on((e,t)=>(e==="auto"?e=en:typeof e=="string"&&(e=Qe(e,t)),typeof e=="function"&&(e=e()),e),"resolvePreset");var rn=Object.defineProperty,sn=d((e,t)=>rn(e,"name",{value:t,configurable:!0}),"a$b");const le=sn((e,t)=>e.some(o=>o instanceof RegExp?o.test(t):o===t),"arrayIncludes");var an=Object.defineProperty,ln=d((e,t)=>an(e,"name",{value:t,configurable:!0}),"a$a");const te=ln(e=>e===void 0?[]:Array.isArray(e)?e:[e],"arrayify");var cn=Object.defineProperty,pn=d((e,t)=>cn(e,"name",{value:t,configurable:!0}),"a$9");const ot=pn((e="")=>{const t=e.split("/");return t[0].startsWith("@")?t[0]+"/"+t[1]:t[0]},"getPackageName");var un=Object.defineProperty,nt=d((e,t)=>un(e,"name",{value:t,configurable:!0}),"s$b");const dn=nt((e,t,o)=>{const n=o??new Map;return(...r)=>{const i=t?typeof t=="function"?t(...r):t:JSON.stringify({args:r}),s=n.get(i);if(s!==void 0)return s;const a=e(...r);return n.set(i,a),a}},"memoize"),mn=nt(e=>{const t=new Map;return o=>dn(e,o,t)},"memoizeByKey");var fn=Object.defineProperty,gn=d((e,t)=>fn(e,"name",{value:t,configurable:!0}),"m$9");const rt=gn(({addDefaultProperty:e=!1,logger:t,type:o})=>({name:"packem:cjs-interop",renderChunk(n,r,i){if(r.type!=="chunk"||!r.isEntry)return null;if(i.format==="cjs"&&i.exports==="auto"){const s=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(n);if(s===null||s.length<3)return null;const a=new P(n);a.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),a.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&a.append(`
16
- module.exports.default = `+s[2]+";");let l=a.toString();return l=l.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+r.fileName+".",prefix:"plugin:cjs-interop"}),{code:l,map:a.generateMap({hires:!0})}}if(i.format==="es"&&/\.d\.(?:ts|cts)$/.test(r.fileName)){if(o!=="commonjs"&&r.fileName.endsWith(".d.ts"))return null;const s=/export\s\{\s(.*)\s\}/i.exec(n);if(s===null||s.length<2)return null;const a=s[1].split(", "),l=[];let c="";for(const u of a)if(!u.includes("type"))if(u.includes("as")){const[m,f]=u.split(" as ");if(f==="default"&&(c=m,!e))continue;l.push(f+": typeof "+m+";")}else l.push(u+": typeof "+u+";");const p=new P(n);return p.replace(" "+c+" as default,",""),p.append(`
8
+ const xo="@visulima/packem",Eo="1.0.0-alpha.73",A=[...It.extensions,".cjs",".ts",".cts",".mts",".tsx",".jsx"],E="production",F="development",Oo=[F,E],Qe=["react-server","react-native","edge-light"];[...Oo,...Qe];const ee=/node_modules/;var So=Object.defineProperty,X=m((e,t)=>So(e,"name",{value:t,configurable:!0}),"i$d");const fe=/^#![^\n]*/,ae=X(async e=>{await Rt(e,493).catch(()=>{})},"makeExecutable"),Do=X((e,t=`#!/usr/bin/env node
9
+ `)=>({name:"packem:shebang",renderChunk:{handler(o,n,r){if(!n.isEntry||!n.facadeModuleId||o.startsWith("#")&&o[1]==="!")return null;if(e.includes(n.name)){const i=new P(o);return i.prepend(t),{code:i.toString(),map:r.sourcemap?i.generateMap({hires:!0}):void 0}}return null},order:"post"},async writeBundle(o,n){for(const[r,i]of Object.entries(n))if(i.type==="chunk"&&fe.test(i.code)&&o.dir){const s=g(o.dir,r);await ae(s)}}}),"shebangPlugin"),No=X(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(fe,"")}}),"removeShebangPlugin"),_o=X((e,t=`
10
+ `)=>{const o=fe.exec(e);return o?o+t:""},"getShebang");var Po=Object.defineProperty,Co=m((e,t)=>Po(e,"name",{value:t,configurable:!0}),"p$4");const ge=Co((e,t)=>{let o={};if(e.pkg.name&&(o[e.pkg.name]=e.options.rootDir),e.pkg.imports){const{imports:n}=e.pkg;for(const r in n){if(r.startsWith("#"))continue;const i=n[r];typeof i=="string"&&(o[r]=h(e.options.rootDir,i))}}return o={...o,...e.options.alias},e.options.rollup.alias&&(Array.isArray(e.options.rollup.alias.entries)?Object.assign(o,Object.fromEntries(e.options.rollup.alias.entries.map(n=>[n.find,n.replacement]))):Object.assign(o,e.options.rollup.alias.entries??e.options.rollup.alias)),e.logger.debug({message:"Resolved aliases: "+JSON.stringify(o),prefix:t}),o},"resolveAliases");var Mo=Object.defineProperty,Io=m((e,t)=>Mo(e,"name",{value:t,configurable:!0}),"o$3");const Ro=Io((e,t)=>{const o=Ye(t,{esmResolve:!0,interopDefault:!0});try{return o.resolve(e)}catch(n){if(n.code!=="MODULE_NOT_FOUND")throw new Error(`Error trying import ${e} from ${t}`,{cause:n});return e}},"tryResolve");var Fo=Object.defineProperty,To=m((e,t)=>Fo(e,"name",{value:t,configurable:!0}),"r$9");const B=To((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var Ao=Object.defineProperty,Jo=m((e,t)=>Ao(e,"name",{value:t,configurable:!0}),"u$a");const Bo=Jo(async e=>{const t=await eo("jiti",{url:import.meta.url}),o=JSON.stringify({...e.options.stubOptions.jiti,alias:{...ge(e,"jit"),...e.options.stubOptions.jiti.alias}},null,2);for(const n of e.options.entries){const r=g(e.options.rootDir,e.options.outDir,n.name),i=pe(Ro(n.input,e.options.rootDir)||n.input),s=i.slice(0,Math.max(0,i.length-ue(i).length)),l=await ce(i),c=_o(l);e.options.emitCJS&&await z(`${r}.cjs`,c+[`const jiti = require(${JSON.stringify(t)})`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(s)})} */`,`module.exports = _jiti(${JSON.stringify(i)})`].join(`
11
+ `));let a=[];try{a=await to(i,{extensions:A})}catch(p){B(e,`Cannot analyze ${i} for exports: ${p.toString()}`);return}const u=a.includes("default")||a.length===0;await z(`${r}.mjs`,c+[`import jiti from ${JSON.stringify(Zt(t).href)};`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(i)})} */`,`const _module = await _jiti.import(${JSON.stringify(i)});`,u?`
12
+ export default _module;`:"",...a.filter(p=>p!=="default").map(p=>`export const ${p} = _module.${p};`)].join(`
13
+ `)),await z(`${r}.d.cts`,[`export * from ${JSON.stringify(s)};`,u?`export { default } from ${JSON.stringify(s)};`:""].join(`
14
+ `)),await z(`${r}.d.mts`,[`export * from ${JSON.stringify(i)};`,u?`export { default } from ${JSON.stringify(i)};`:""].join(`
15
+ `)),c&&(await ae(`${r}.cjs`),await ae(`${r}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var Wo=Object.defineProperty,Lo=m((e,t)=>Wo(e,"name",{value:t,configurable:!0}),"r$8");const et=Lo((e,t)=>Ye(t,{esmResolve:!0,interopDefault:!0})(e),"tryRequire");var zo=Object.defineProperty,Uo=m((e,t)=>zo(e,"name",{value:t,configurable:!0}),"i$a");const he=Uo(e=>`{ ${Object.keys(e).map(t=>`${t}: ${JSON.stringify(e[t])}`).join(", ")} }`,"dumpObject");var Vo=Object.defineProperty,tt=m((e,t)=>Vo(e,"name",{value:t,configurable:!0}),"t$8");const Y=tt(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),ot=tt((e,t,o,n)=>{if(o){const s=Y(o);if(s)return s}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return n==="commonjs"?"cjs":"esm";const[r,...i]=t;return ot(r,i,o,n)},"inferExportType");var Ho=Object.defineProperty,qo=m((e,t)=>Ho(e,"name",{value:t,configurable:!0}),"i$9");const Ko=["import","require","node","node-addons","default","production","types","deno","browser","development","react-native","react-server"],ye=qo((e,t,o,n=[])=>{if(!e)return[];if(typeof e=="string"){const r=Y(e),i=t==="module"?"esm":"cjs";if(r&&r!==i)throw new Error(`Exported file "${e}" has an extension that does not match the package.json type "${t}".`);return[{file:e,key:"exports",type:r??i}]}return Object.entries(e).filter(([r])=>!r.endsWith(".json")).flatMap(([r,i])=>r==="types"&&o===!1?[]:typeof i=="string"?{file:i,key:"exports",...Ko.includes(r)?{subKey:r}:{},type:ot(r,n,i,t)}:ye(i,t,o,[...n,r]))},"extractExportFilenames");var Yo=Object.defineProperty,ve=m((e,t)=>Yo(e,"name",{value:t,configurable:!0}),"a$c");const Go=ve((e,t)=>e.key==="exports"&&e.subKey===E?E:e.key==="exports"&&e.subKey===F?F:t,"getEnvironment"),U=ve((e,t,o,n,r,i,s)=>{const l=Go(r,s);let c=e.find(a=>a.input===t&&a.environment===l);if(c===void 0&&(c=e[e.push({input:t})-1]),o&&(c.outDir=n),r.isExecutable)c.executable=!0,c.declaration=!1,r.type==="cjs"&&(c.cjs=!0),r.type==="esm"&&(c.esm=!0);else{/\.d\.[mc]?ts$/.test(r.file)&&i!==!1&&(c.declaration=i),r.type==="cjs"&&(c.cjs=!0),r.type==="esm"&&(c.esm=!0);for(const a of Qe)if(r.file.includes("."+a+".")){c.runtime=a;break}}c.runtime===void 0&&(c.runtime="node"),c.environment=l,[F,E].includes(r.subKey)&&r.file.includes("."+r.subKey+".")&&(c.fileAlias=!0)},"createOrUpdateEntry"),Se=/(?:\.d\.[mc]?ts|\.\w+)$/;let De=!1;const Xo=ve((e,t,o)=>{const n=[];t.sort((l,c)=>l.split("/").length-c.split("/").length);const r=e.type==="module"?"esm":"cjs",i=ye(e.exports,e.type??"commonjs",o.options.declaration);if(e.bin){const l=(typeof e.bin=="string"?[e.bin]:Object.values(e.bin)).filter(Boolean);for(const c of l){const a=Y(c);if(a&&a!==r)throw new Error(`Exported file "${c}" has an extension that does not match the package.json type "${e.type}".`);i.push({file:c,isExecutable:!0,key:"bin",type:a??r})}}e.main&&i.push({file:e.main,key:"main",type:Y(e.main)??r}),e.module&&i.push({file:e.module,key:"module",type:"esm"}),(e.types||e.typings)&&o.options.declaration&&i.push({file:e.types??e.typings,key:"types"});const s=[];for(const l of i){const c=l.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),a=c.endsWith("/");if(a&&["./","/"].includes(c))continue;let u=c.replace(new RegExp("(./)?"+o.options.outDir),o.options.sourceDir).replace("./","");if((l.subKey===F||l.subKey===E)&&(u=u.replace("."+l.subKey,"")),l.file.includes("/*")&&l.key==="exports"){De||(o.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),De=!0);const f=[],j=new RegExp("(?<=/|$)"+u.replace("*","(.*)")+(a?"":"\\.\\w+"));for(const D of t)j.test(D)&&f.push(D.replace(Se,""));if(f.length===0){n.push(`Could not find entrypoint for \`${l.file}\``);continue}for(const D of f)U(s,D,a,c,l,o.options.declaration,o.environment);continue}const p=new RegExp("(?<=/|$)"+u+(a?"":"\\.\\w+")),d=t.find(f=>p.test(f))?.replace(Se,"");if(!d){me(g(o.options.rootDir,l.file))||n.push(`Could not find entrypoint for \`${l.file}\``);continue}if(b(d+".cts")&&b(d+".mts")){if(o.pkg?.dependencies?.typescript===void 0&&o.pkg?.devDependencies?.typescript===void 0)throw new Error("You tried to use a `.cts` or `.mts` file but `typescript` was not found in your package.json.");U(s,d+".cts",a,c,{...l,type:"cjs"},o.options.declaration,o.environment),U(s,d+".mts",a,c,{...l,type:"esm"},o.options.declaration,o.environment)}else{if((b(d+".ts")||b(d+".cts")||b(d+".mts"))&&o.pkg?.dependencies?.typescript===void 0&&o.pkg?.devDependencies?.typescript===void 0)throw new Error("You tried to use a `.ts`, `.cts` or `.mts` file but `typescript` was not found in your package.json.");U(s,d,a,c,l,o.options.declaration,o.environment)}}return{entries:s,warnings:n}},"inferEntries");var Zo=Object.defineProperty,Qo=m((e,t)=>Zo(e,"name",{value:t,configurable:!0}),"t$7");const en=Qo((e,t)=>{const{publishConfig:o}=e;return o&&(o.bin&&(typeof o.bin=="object"||typeof o.bin=="string")&&(e.bin=o.bin),o.type&&typeof o.type=="string"&&o.type!==""&&(e.type=o.type),o.main&&typeof o.main=="string"&&o.main!==""&&(e.main=o.main),o.module&&typeof o.module=="string"&&o.module!==""&&(e.module=o.module),t===void 0&&o.types&&typeof o.types=="string"&&o.types!==""?e.types=o.types:t===void 0&&o.typings&&typeof o.typings=="string"&&o.typings!==""&&(e.typings=o.typings),o.exports&&typeof o.exports=="object"&&(e.exports=o.exports)),e},"overwriteWithPublishConfig");var tn=Object.defineProperty,on=m((e,t)=>tn(e,"name",{value:t,configurable:!0}),"t$6");const nn={hooks:{"build:prepare":on(function(e){if(e.options.entries.length>0)return;const t=h(e.options.rootDir,e.options.sourceDir);if(!me(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=Bt(t,{extensions:[],includeDirs:!1,includeSymlinks:!1});if(o.length===0)throw new Error("No source files found in 'src' directory. Please provide entries manually.");let n={...e.pkg};n.publishConfig&&(e.logger.info('Using publishConfig found in package.json, to override the default key-value pairs of "'+Object.keys(n.publishConfig).join(", ")+'".'),e.logger.debug(he(n.publishConfig)),n=en(n,e.options.declaration));const r=Xo(n,o,e);for(const i of r.warnings)B(e,i);if(e.options.entries.push(...r.entries),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",v(e.options.entries.map(i=>N(i.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),R([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(i=>`[${i}]`).join(" ")))},"build:prepare")}};var rn=Object.defineProperty,sn=m((e,t)=>rn(e,"name",{value:t,configurable:!0}),"t$5");const an=sn((e,t)=>(e==="auto"?e=nn:typeof e=="string"&&(e=et(e,t)),typeof e=="function"&&(e=e()),e),"resolvePreset");var ln=Object.defineProperty,cn=m((e,t)=>ln(e,"name",{value:t,configurable:!0}),"a$b");const le=cn((e,t)=>e.some(o=>o instanceof RegExp?o.test(t):o===t),"arrayIncludes");var pn=Object.defineProperty,un=m((e,t)=>pn(e,"name",{value:t,configurable:!0}),"a$a");const te=un(e=>e===void 0?[]:Array.isArray(e)?e:[e],"arrayify");var dn=Object.defineProperty,mn=m((e,t)=>dn(e,"name",{value:t,configurable:!0}),"a$9");const nt=mn((e="")=>{const t=e.split("/");return t[0].startsWith("@")?t[0]+"/"+t[1]:t[0]},"getPackageName");var fn=Object.defineProperty,rt=m((e,t)=>fn(e,"name",{value:t,configurable:!0}),"s$b");const gn=rt((e,t,o)=>{const n=o??new Map;return(...r)=>{const i=t?typeof t=="function"?t(...r):t:JSON.stringify({args:r}),s=n.get(i);if(s!==void 0)return s;const l=e(...r);return n.set(i,l),l}},"memoize"),hn=rt(e=>{const t=new Map;return o=>gn(e,o,t)},"memoizeByKey");var yn=Object.defineProperty,vn=m((e,t)=>yn(e,"name",{value:t,configurable:!0}),"m$8");const it=vn(({addDefaultProperty:e=!1,logger:t,type:o})=>({name:"packem:cjs-interop",renderChunk(n,r,i){if(r.type!=="chunk"||!r.isEntry)return null;if(i.format==="cjs"&&i.exports==="auto"){const s=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(n);if(s===null||s.length<3)return null;const l=new P(n);l.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),l.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&l.append(`
16
+ module.exports.default = `+s[2]+";");let c=l.toString();return c=c.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+r.fileName+".",prefix:"plugin:cjs-interop"}),{code:c,map:l.generateMap({hires:!0})}}if(i.format==="es"&&/\.d\.(?:ts|cts)$/.test(r.fileName)){if(o!=="commonjs"&&r.fileName.endsWith(".d.ts"))return null;const s=/export\s\{\s(.*)\s\}/i.exec(n);if(s===null||s.length<2)return null;const l=s[1].split(", "),c=[];let a="";for(const p of l)if(!p.includes("type"))if(p.includes("as")){const[d,f]=p.split(" as ");if(f==="default"&&(a=d,!e))continue;c.push(f+": typeof "+d+";")}else c.push(p+": typeof "+p+";");const u=new P(n);return u.replace(" "+a+" as default,",""),u.append(`
17
17
 
18
18
  declare const defaultExport: {
19
- `+(l.length>0?" ":"")+l.join(`
19
+ `+(c.length>0?" ":"")+c.join(`
20
20
  `)+`
21
- }`+(c?" & typeof "+c:"")+`;
21
+ }`+(a?" & typeof "+a:"")+`;
22
22
 
23
- export default defaultExport;`),t.debug({message:"Applied CommonJS interop to entry chunk "+r.fileName+".",prefix:"plugin:cjs-interop"}),{code:p.toString(),map:p.generateMap({hires:!0})}}return null}}),"cjsInterop");var hn=Object.defineProperty,yn=d((e,t)=>hn(e,"name",{value:t,configurable:!0}),"f$4");const vn=yn((e,t)=>{const o=new Map,n={copyOnce:!0,exactFileNames:!0,flatten:!1,...e};let{targets:r}=n;return Array.isArray(r)?r=r.map(i=>{if(typeof i=="string")return{src:i};if(typeof i=="object"&&"src"in i)return i}).filter(Boolean):typeof r=="string"&&(r=[{src:r}]),{async buildStart(){const i=await Promise.all(r.flatMap(s=>Array.isArray(s.src)?s.src.map(a=>({...s,src:a})):s).map(async s=>await lo(s.src,{ignore:s.exclude}).then(a=>({dest:s.dest??"",parent:co(s.src),src:a}))));for(const s of i)for(const a of s.src){let l;o.has(a)?l=o.get(a):(l={copied:[],dest:[],timestamp:0},o.set(a,l));const c=n.flatten?pe(s.dest):y(s.dest,D(s.parent,de(a)));l.dest.includes(c)||l.dest.push(c),this.addWatchFile(a)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...o].map(async([s,a])=>{let l;try{const c=await We(s);if(!c.isFile())return;const p=c.mtime.getTime();p>a.timestamp&&(a.timestamp=p,a.copied=[]),l=await ce(s,{buffer:!0})}catch(c){t.error({context:[c],message:`error reading file ${s}`,prefix:"plugin:copy"});return}for(const c of a.dest){if(n.copyOnce&&a.copied.includes(c))continue;const p=G(s),u=y(c,p);try{this.emitFile({[n.exactFileNames?"fileName":"name"]:u,source:l,type:"asset"}),t.debug({message:`copied ${s} → ${u}`,prefix:"plugin:copy"}),a.copied.push(c)}catch(m){t.error({context:[m],message:`error copying file ${s} → ${u}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var bn=Object.defineProperty,X=d((e,t)=>bn(e,"name",{value:t,configurable:!0}),"t$4");const wn=/\Wrequire(?:\.resolve)?\(/,$n=X((e,t)=>{if(j.INTERNAL_PACKEM_BUILD!=="1"&&(e.includes("// -- packem CommonJS __filename shim")||e.includes("// -- packem CommonJS __dirname shim")||e.includes("// -- packem CommonJS require shim")))return null;let o=!1,n=!1,r=!1;if(e.includes("__filename")&&(o=!0),e.includes("__dirname")&&(n=!0),wn.test(e)&&(r=!0),!o&&!n&&!r)return null;const i=qe(e).pop(),s=i?i.end:0,a=new P(e);return a.appendRight(s,t(o,n,r)),{code:a.toString(),map:a.generateMap()}},"CJSToESM"),jn=X((e,t,o)=>{let n="";return(e||t)&&(n+=`import __cjs_url__ from "node:url"; // -- packem CommonJS __filename shim --
23
+ export default defaultExport;`),t.debug({message:"Applied CommonJS interop to entry chunk "+r.fileName+".",prefix:"plugin:cjs-interop"}),{code:u.toString(),map:u.generateMap({hires:!0})}}return null}}),"cjsInterop");var bn=Object.defineProperty,$n=m((e,t)=>bn(e,"name",{value:t,configurable:!0}),"f$4");const wn=$n((e,t)=>{const o=new Map,n={copyOnce:!0,exactFileNames:!0,flatten:!1,...e};let{targets:r}=n;return Array.isArray(r)?r=r.map(i=>{if(typeof i=="string")return{src:i};if(typeof i=="object"&&"src"in i)return i}).filter(Boolean):typeof r=="string"&&(r=[{src:r}]),{async buildStart(){const i=await Promise.all(r.flatMap(s=>Array.isArray(s.src)?s.src.map(l=>({...s,src:l})):s).map(async s=>await lo(s.src,{ignore:s.exclude}).then(l=>({dest:s.dest??"",parent:co(s.src),src:l}))));for(const s of i)for(const l of s.src){let c;o.has(l)?c=o.get(l):(c={copied:[],dest:[],timestamp:0},o.set(l,c));const a=n.flatten?pe(s.dest):h(s.dest,S(s.parent,de(l)));c.dest.includes(a)||c.dest.push(a),this.addWatchFile(l)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...o].map(async([s,l])=>{let c;try{const a=await Le(s);if(!a.isFile())return;const u=a.mtime.getTime();u>l.timestamp&&(l.timestamp=u,l.copied=[]),c=await ce(s,{buffer:!0})}catch(a){t.error({context:[a],message:`error reading file ${s}`,prefix:"plugin:copy"});return}for(const a of l.dest){if(n.copyOnce&&l.copied.includes(a))continue;const u=G(s),p=h(a,u);try{this.emitFile({[n.exactFileNames?"fileName":"name"]:p,source:c,type:"asset"}),t.debug({message:`copied ${s} → ${p}`,prefix:"plugin:copy"}),l.copied.push(a)}catch(d){t.error({context:[d],message:`error copying file ${s} → ${p}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var jn=Object.defineProperty,Z=m((e,t)=>jn(e,"name",{value:t,configurable:!0}),"t$4");const kn=/\Wrequire(?:\.resolve)?\(/,xn=Z((e,t)=>{if(q.INTERNAL_PACKEM_BUILD!=="1"&&(e.includes("// -- packem CommonJS __filename shim")||e.includes("// -- packem CommonJS __dirname shim")||e.includes("// -- packem CommonJS require shim")))return null;let o=!1,n=!1,r=!1;if(e.includes("__filename")&&(o=!0),e.includes("__dirname")&&(n=!0),kn.test(e)&&(r=!0),!o&&!n&&!r)return null;const i=Ke(e).pop(),s=i?i.end:0,l=new P(e);return l.appendRight(s,t(o,n,r)),{code:l.toString(),map:l.generateMap()}},"CJSToESM"),En=Z((e,t,o)=>{let n="";return(e||t)&&(n+=`import __cjs_url__ from "node:url"; // -- packem CommonJS __filename shim --
24
24
  `),t&&(n+=`import __cjs_path__ from "node:path"; // -- packem CommonJS __dirname shim --
25
25
  `),o&&(n+=`import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
26
26
  `),(e||t)&&(n+=`const __filename = __cjs_url__.fileURLToPath(import.meta.url);
27
27
  `),t&&(n+=`const __dirname = __cjs_path__.dirname(__filename);
28
28
  `),o&&(n+=`const require = __cjs_mod__.createRequire(import.meta.url);
29
- `),n},"generateCJSShim"),kn=X((e,t,o)=>{let n="";return o&&(n+=`import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
29
+ `),n},"generateCJSShim"),On=Z((e,t,o)=>{let n="";return o&&(n+=`import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
30
30
  `),e&&(n+=`const __filename = import.meta.filename; // -- packem CommonJS __filename shim --
31
31
  `),t&&(n+=`const __dirname = import.meta.dirname; // -- packem CommonJS __dirname shim --
32
32
  `),o&&(n+=`const require = __cjs_mod__.createRequire(import.meta.url);
33
- `),n},"generateCJSShimNode20_11"),xn=X((e,t)=>{const o=L(t.include,t.exclude);return{name:"packem:cjs",renderChunk(n,r,i){if(i.format==="es"&&o(r.fileName)){let s=jn;if(e.engines?.node){const a=Xe(e.engines.node);a&&a.major>=20&&a.minor>=11&&(s=kn)}return $n(n,s)}return null}}},"esmShimCjsSyntaxPlugin");var En=Object.defineProperty,On=d((e,t)=>En(e,"name",{value:t,configurable:!0}),"n$3");const Sn=On(()=>({name:"packem:cjs",renderChunk(e,t,o){return o.format==="es"||o.format==="cjs"?{code:e.replaceAll(/(import\(.*)(.ts)(['´"`]\))/g,"$1."+(o.format==="es"?"mjs":"cjs")+"$3"),map:null}:null}}),"fixDynamicImportExtension");var Dn=Object.defineProperty,De=d((e,t)=>Dn(e,"name",{value:t,configurable:!0}),"c$8");const Nn=De(e=>(t,o={})=>{const n=L(o.include,o.exclude),r={},i=De((s,a)=>{r[s.replace(/\..?[jt]s$/,"")]=a},"addOutput");return{generateBundle(s,a){let{entryFileNames:l}=s;typeof l=="function"&&(l=l(a));const c=l.replace(/\.(.)?[jt]s$/,(p,u)=>`.d.${u||""}ts`);for(const[p,u]of Object.entries(r))this.emitFile({fileName:c.replace("[name]",D(e,p)),source:u,type:"asset"})},name:"packem:isolated-declarations",async transform(s,a){if(!n(a))return;const l=await t(a,s),{errors:c,sourceText:p}=l;c.length>0?o.ignoreErrors?this.warn(c[0]):this.error(c[0]):i(a,p)}}},"isolatedDeclarationsPlugin");var _n=Object.defineProperty,Pn=d((e,t)=>_n(e,"name",{value:t,configurable:!0}),"n$2");const Ne="export default ",it=Pn(e=>{const t=po(e);return{...t,name:"packem:json",transform(o,n){const r=t.transform?.call(this,o,n);return r&&typeof r!="string"&&"code"in r&&r.code?.startsWith(Ne)&&(r.code=r.code.replace(Ne,"module.exports = ")),r}}},"JSONPlugin");class Cn{static{d(this,"WalkerBase")}constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:d(()=>this.should_skip=!0,"skip"),remove:d(()=>this.should_remove=!0,"remove"),replace:d(t=>this.replacement=t,"replace")}}replace(t,o,n,r){t&&o&&(n!=null?t[o][n]=r:t[o]=r)}remove(t,o,n){t&&o&&(n!=null?t[o].splice(n,1):delete t[o])}}class Mn extends Cn{static{d(this,"SyncWalker")}constructor(t,o){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:d(()=>this.should_skip=!0,"skip"),remove:d(()=>this.should_remove=!0,"remove"),replace:d(n=>this.replacement=n,"replace")},this.enter=t,this.leave=o}visit(t,o,n,r){if(t){if(this.enter){const s=this.should_skip,a=this.should_remove,l=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,o,n,r),this.replacement&&(t=this.replacement,this.replace(o,n,r,t)),this.should_remove&&this.remove(o,n,r);const c=this.should_skip,p=this.should_remove;if(this.should_skip=s,this.should_remove=a,this.replacement=l,c)return t;if(p)return null}let i;for(i in t){const s=t[i];if(s&&typeof s=="object")if(Array.isArray(s)){const a=s;for(let l=0;l<a.length;l+=1){const c=a[l];_e(c)&&(this.visit(c,t,i,l)||l--)}}else _e(s)&&this.visit(s,t,i,null)}if(this.leave){const s=this.replacement,a=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,t,o,n,r),this.replacement&&(t=this.replacement,this.replace(o,n,r,t)),this.should_remove&&this.remove(o,n,r);const l=this.should_remove;if(this.replacement=s,this.should_remove=a,l)return null}}return t}}function _e(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}d(_e,"isNode");function st(e,{enter:t,leave:o}){return new Mn(t,o).visit(e,null)}d(st,"walk");var In=Object.defineProperty,Rn=d((e,t)=>In(e,"name",{value:t,configurable:!0}),"u$8");const Fn=Rn(({attributes:e,logger:t})=>{const o=L([/\.[tj]sx$/],/node_modules/);if(!Array.isArray(e)||e.length===0)throw new Error("[packem:jsx-remove-attributes]: attributes must be a non-empty array of strings.");return{name:"packem:jsx-remove-attributes",transform(n,r){if(!o(r))return null;let i=null;try{i=this.parse(n,{allowReturnOutsideFunction:!0})}catch(l){return this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${r}" and remove the jsx attribute.`}),t.warn(l),null}let s=!1;const a=new P(n);return st(i,{enter(l){if(l.type==="CallExpression"&&l.callee.type==="Identifier"&&l.callee.name==="jsx"){const c=l.arguments.filter(p=>p.type==="ObjectExpression"&&Array.isArray(p.properties));for(const p of c)for(const u of p.properties)u.type==="Property"&&u.key.type==="Literal"&&u.value.type==="Literal"&&e.includes(u.key.value)&&(a.overwrite(u.start-2,u.end,""),s=!0)}}}),s?{code:a.toString(),map:a.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var Tn=Object.defineProperty,ve=d((e,t)=>Tn(e,"name",{value:t,configurable:!0}),"g$3");const An=ve(e=>{const t=[],o=[];return e.forEach(n=>{n.startsWith("(")?t.push(n):o.push(n)}),[...o.sort(),...t.sort()]},"sortLicenses"),Jn=ve((e,t,o)=>{const n=new RegExp(`(<!-- ${t} -->)[\\s\\S]*?(<!-- ${t} -->)`,"g");if(n.test(e))return e.replace(n,`$1
33
+ `),n},"generateCJSShimNode20_11"),Sn=Z((e,t)=>{const o=W(t.include,t.exclude);return{name:"packem:esm-shim-cjs-syntax",renderChunk(n,r,i){if(i.format==="es"&&o(r.fileName)){let s=En;if(e.engines?.node){const l=Ze(e.engines.node);l&&l.major>=20&&l.minor>=11&&(s=On)}return xn(n,s)}return null}}},"esmShimCjsSyntaxPlugin");var Dn=Object.defineProperty,Nn=m((e,t)=>Dn(e,"name",{value:t,configurable:!0}),"n$3");const _n=Nn(()=>({name:"packem:cjs",renderChunk(e,t,o){return o.format==="es"||o.format==="cjs"?{code:e.replaceAll(/(import\(.*)(.ts)(['´"`]\))/g,"$1."+(o.format==="es"?"mjs":"cjs")+"$3"),map:null}:null}}),"fixDynamicImportExtension");var Pn=Object.defineProperty,Ne=m((e,t)=>Pn(e,"name",{value:t,configurable:!0}),"c$8");const Cn=Ne(e=>(t,o={})=>{const n=W(o.include,o.exclude),r={},i=Ne((s,l)=>{r[s.replace(/\..?[jt]s$/,"")]=l},"addOutput");return{generateBundle(s,l){let{entryFileNames:c}=s;typeof c=="function"&&(c=c(l));const a=c.replace(/\.(.)?[jt]s$/,(u,p)=>`.d.${p||""}ts`);for(const[u,p]of Object.entries(r))this.emitFile({fileName:a.replace("[name]",S(e,u)),source:p,type:"asset"})},name:"packem:isolated-declarations",async transform(s,l){if(!n(l))return;const c=await t(l,s),{errors:a,sourceText:u}=c;a.length>0?o.ignoreErrors?this.warn(a[0]):this.error(a[0]):i(l,u)}}},"isolatedDeclarationsPlugin");var Mn=Object.defineProperty,In=m((e,t)=>Mn(e,"name",{value:t,configurable:!0}),"n$2");const _e="export default ",st=In(e=>{const t=po(e);return{...t,name:"packem:json",transform(o,n){const r=t.transform?.call(this,o,n);return r&&typeof r!="string"&&"code"in r&&r.code?.startsWith(_e)&&(r.code=r.code.replace(_e,"module.exports = ")),r}}},"JSONPlugin");class Rn{static{m(this,"WalkerBase")}constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:m(()=>this.should_skip=!0,"skip"),remove:m(()=>this.should_remove=!0,"remove"),replace:m(t=>this.replacement=t,"replace")}}replace(t,o,n,r){t&&o&&(n!=null?t[o][n]=r:t[o]=r)}remove(t,o,n){t&&o&&(n!=null?t[o].splice(n,1):delete t[o])}}class Fn extends Rn{static{m(this,"SyncWalker")}constructor(t,o){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:m(()=>this.should_skip=!0,"skip"),remove:m(()=>this.should_remove=!0,"remove"),replace:m(n=>this.replacement=n,"replace")},this.enter=t,this.leave=o}visit(t,o,n,r){if(t){if(this.enter){const s=this.should_skip,l=this.should_remove,c=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,o,n,r),this.replacement&&(t=this.replacement,this.replace(o,n,r,t)),this.should_remove&&this.remove(o,n,r);const a=this.should_skip,u=this.should_remove;if(this.should_skip=s,this.should_remove=l,this.replacement=c,a)return t;if(u)return null}let i;for(i in t){const s=t[i];if(s&&typeof s=="object")if(Array.isArray(s)){const l=s;for(let c=0;c<l.length;c+=1){const a=l[c];Pe(a)&&(this.visit(a,t,i,c)||c--)}}else Pe(s)&&this.visit(s,t,i,null)}if(this.leave){const s=this.replacement,l=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,t,o,n,r),this.replacement&&(t=this.replacement,this.replace(o,n,r,t)),this.should_remove&&this.remove(o,n,r);const c=this.should_remove;if(this.replacement=s,this.should_remove=l,c)return null}}return t}}function Pe(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}m(Pe,"isNode");function at(e,{enter:t,leave:o}){return new Fn(t,o).visit(e,null)}m(at,"walk");var Tn=Object.defineProperty,An=m((e,t)=>Tn(e,"name",{value:t,configurable:!0}),"u$8");const Jn=An(({attributes:e,logger:t})=>{const o=W([/\.[tj]sx$/],/node_modules/);if(!Array.isArray(e)||e.length===0)throw new Error("[packem:jsx-remove-attributes]: attributes must be a non-empty array of strings.");return{name:"packem:jsx-remove-attributes",transform(n,r){if(!o(r))return null;let i=null;try{i=this.parse(n,{allowReturnOutsideFunction:!0})}catch(c){return this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${r}" and remove the jsx attribute.`}),t.warn(c),null}let s=!1;const l=new P(n);return at(i,{enter(c){if(c.type==="CallExpression"&&c.callee.type==="Identifier"&&c.callee.name==="jsx"){const a=c.arguments.filter(u=>u.type==="ObjectExpression"&&Array.isArray(u.properties));for(const u of a)for(const p of u.properties)p.type==="Property"&&p.key.type==="Literal"&&p.value.type==="Literal"&&e.includes(p.key.value)&&(l.overwrite(p.start-2,p.end,""),s=!0)}}}),s?{code:l.toString(),map:l.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var Bn=Object.defineProperty,be=m((e,t)=>Bn(e,"name",{value:t,configurable:!0}),"g$3");const Wn=be(e=>{const t=[],o=[];return e.forEach(n=>{n.startsWith("(")?t.push(n):o.push(n)}),[...o.sort(),...t.sort()]},"sortLicenses"),Ln=be((e,t,o)=>{const n=new RegExp(`(<!-- ${t} -->)[\\s\\S]*?(<!-- ${t} -->)`,"g");if(n.test(e))return e.replace(n,`$1
34
34
  ${o}
35
- $2`)},"replaceContentWithin"),at=ve(({dtsMarker:e,licenseFilePath:t,licenseTemplate:o,logger:n,marker:r,mode:i,packageName:s})=>uo({thirdParty(a){const l=new Set,c=a.sort(({name:u},{name:m})=>(u||0)>(m||0)?1:(m||0)>(u||0)?-1:0).map(({author:u,contributors:m,license:f,licenseText:b,maintainers:w,name:O,repository:v})=>{let C="## "+O+`
36
- `;f&&(C+=`License: ${f}
37
- `);const Z=new Set;for(const T of[u,...w,...m]){const $e=typeof T=="string"?T:T?.name;$e&&Z.add($e)}return Z.size>0&&(C+=`By: ${[...Z].join(", ")}
38
- `),v&&(C+=`Repository: ${typeof v=="string"?v:v.url}
39
- `),b&&(C+=`
40
- `+b.trim().replaceAll(/\r\n|\r/g,`
35
+ $2`)},"replaceContentWithin"),lt=be(({dtsMarker:e,licenseFilePath:t,licenseTemplate:o,logger:n,marker:r,mode:i,packageName:s})=>uo({thirdParty(l){const c=new Set,a=l.sort(({name:p},{name:d})=>(p||0)>(d||0)?1:(d||0)>(p||0)?-1:0).map(({author:p,contributors:d,license:f,licenseText:j,maintainers:D,name:L,repository:k})=>{let y="## "+L+`
36
+ `;f&&(y+=`License: ${f}
37
+ `);const C=new Set;for(const O of[p,...D,...d]){const je=typeof O=="string"?O:O?.name;je&&C.add(je)}return C.size>0&&(y+=`By: ${[...C].join(", ")}
38
+ `),k&&(y+=`Repository: ${typeof k=="string"?k:k.url}
39
+ `),j&&(y+=`
40
+ `+j.trim().replaceAll(/\r\n|\r/g,`
41
41
  `).replaceAll(`<!-- ${r} -->`,"").replaceAll(e?`<!-- ${e} -->`:"","").trim().split(`
42
- `).map(T=>T?`> ${T}`:">").join(`
42
+ `).map(O=>O?`> ${O}`:">").join(`
43
43
  `)+`
44
- `),f&&l.add(f),C}).join(`
44
+ `),f&&c.add(f),y}).join(`
45
45
  ---------------------------------------
46
46
 
47
- `);if(c===""){n.info({message:"No dependencies license information found.",prefix:"plugin:license:"+i});return}const p=o(An(l),c,s);try{const u=Le(t),m=Jn(u,r,p);if(!m){n.error({message:`Could not find the license marker: <!-- ${r} --> in ${t}`,prefix:"plugin:license:"+i});return}u!==m&&(q(t,m),n.info({message:`${t} updated.`,prefix:"plugin:license:"+i}))}catch(u){n.error(u)}}}),"license");var Bn=Object.defineProperty,Wn=d((e,t)=>Bn(e,"name",{value:t,configurable:!0}),"i$8");const Ln=Wn(e=>({async buildEnd(){const t=[];for(const n of this.getModuleIds()){const r=this.getModuleInfo(n);if(r!=null&&!r.isExternal)for(const i of r.importedIds)t.push({source:n,target:i})}if(Array.isArray(t)&&t.length===0)return;const o=g(e.rootDir,e.outDir,"graph.json");Wt(o,t)},name:"packem:metafile"}),"metafilePlugin");var zn=Object.defineProperty,Un=d((e,t)=>zn(e,"name",{value:t,configurable:!0}),"r$5");const I=Un(e=>{const t=mo("md5");return t.update(e),t.digest("hex")},"getHash");var Vn=Object.defineProperty,lt=d((e,t)=>Vn(e,"name",{value:t,configurable:!0}),"m$6");const J=lt(e=>e.handler||e,"getHandler"),E=lt((e,t)=>({...e,async buildEnd(o){e.buildEnd&&await J(e.buildEnd).call(this,o)},async buildStart(o){e.buildStart&&await J(e.buildStart).call(this,o)},async load(o){if(!e.load)return null;const n=y("load",I(o));if(t.has(n,e.name))return await t.get(n,e.name);const r=await J(e.load).call(this,o);return t.set(n,r,e.name),r},name:`cached(${e.name})`,async resolveId(o,n,r){if(!e.resolveId)return null;const i=y("resolveId",I(o),n?I(n):"",I(JSON.stringify(r)));if(t.has(i,e.name))return await t.get(i,e.name);const s=await J(e.resolveId).call(this,o,n,r);return t.set(i,s,e.name),s},async transform(o,n){if(!e.transform)return null;const r=y("transform",I(n),I(o));if(t.has(r,e.name))return await t.get(r,e.name);const i=await J(e.transform).call(this,o,n);return t.set(r,i,e.name),i}}),"cachingPlugin");var Hn=Object.defineProperty,qn=d((e,t)=>Hn(e,"name",{value:t,configurable:!0}),"c$6");const Yn=/\.(?:m|c)?(?:j|t)sx?$/,Gn=/^use \w+$/,Kn=qn(e=>{const t={},o={};return{name:"packem:preserve-directives",onLog(n,r){return r.code==="MODULE_LEVEL_DIRECTIVE"&&n==="warn"?!1:null},renderChunk:{handler(n,r,{sourcemap:i}){const s=r.moduleIds.map(c=>t[c]?t[c]:null).reduce((c,p)=>(p&&p.forEach(u=>{c.add(u)}),c),new Set),a=new P(n);s.size>0&&(e.debug({message:`directives for chunk "${r.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),a.prepend(`${[...s].map(c=>`'${c}';`).join(`
47
+ `);if(a===""){n.info({message:"No dependencies license information found.",prefix:"plugin:license:"+i});return}const u=o(Wn(c),a,s);try{const p=ze(t),d=Ln(p,r,u);if(!d){n.error({message:`Could not find the license marker: <!-- ${r} --> in ${t}`,prefix:"plugin:license:"+i});return}p!==d&&(K(t,d),n.info({message:`${t} updated.`,prefix:"plugin:license:"+i}))}catch(p){n.error(p)}}}),"license");var zn=Object.defineProperty,Un=m((e,t)=>zn(e,"name",{value:t,configurable:!0}),"i$7");const Vn=Un(e=>({async buildEnd(){const t=[];for(const n of this.getModuleIds()){const r=this.getModuleInfo(n);if(r!=null&&!r.isExternal)for(const i of r.importedIds)t.push({source:n,target:i})}if(Array.isArray(t)&&t.length===0)return;const o=g(e.rootDir,e.outDir,"graph.json");Wt(o,t)},name:"packem:metafile"}),"metafilePlugin");var Hn=Object.defineProperty,qn=m((e,t)=>Hn(e,"name",{value:t,configurable:!0}),"r$4");const I=qn(e=>{const t=mo("md5");return t.update(e),t.digest("hex")},"getHash");var Kn=Object.defineProperty,ct=m((e,t)=>Kn(e,"name",{value:t,configurable:!0}),"m$5");const J=ct(e=>e.handler||e,"getHandler"),x=ct((e,t)=>({...e,async buildEnd(o){e.buildEnd&&await J(e.buildEnd).call(this,o)},async buildStart(o){e.buildStart&&await J(e.buildStart).call(this,o)},async load(o){if(!e.load)return null;const n=h("load",I(o));if(t.has(n,e.name))return await t.get(n,e.name);const r=await J(e.load).call(this,o);return t.set(n,r,e.name),r},name:`cached(${e.name})`,async resolveId(o,n,r){if(!e.resolveId)return null;const i=h("resolveId",I(o),n?I(n):"",I(JSON.stringify(r)));if(t.has(i,e.name))return await t.get(i,e.name);const s=await J(e.resolveId).call(this,o,n,r);return t.set(i,s,e.name),s},async transform(o,n){if(!e.transform)return null;const r=h("transform",I(n),I(o));if(t.has(r,e.name))return await t.get(r,e.name);const i=await J(e.transform).call(this,o,n);return t.set(r,i,e.name),i}}),"cachingPlugin");var Yn=Object.defineProperty,Gn=m((e,t)=>Yn(e,"name",{value:t,configurable:!0}),"c$6");const Xn=/\.(?:m|c)?(?:j|t)sx?$/,Zn=/^use \w+$/,Qn=Gn(e=>{const t={},o={};return{name:"packem:preserve-directives",onLog(n,r){return r.code==="MODULE_LEVEL_DIRECTIVE"&&n==="warn"?!1:null},renderChunk:{handler(n,r,{sourcemap:i}){const s=r.moduleIds.map(a=>t[a]?t[a]:null).reduce((a,u)=>(u&&u.forEach(p=>{a.add(p)}),a),new Set),l=new P(n);s.size>0&&(e.debug({message:`directives for chunk "${r.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),l.prepend(`${[...s].map(a=>`'${a}';`).join(`
48
48
  `)}
49
- `));let l=null;return r.facadeModuleId&&typeof o[r.facadeModuleId]=="string"&&(l=o[r.facadeModuleId]),l&&(e.debug({message:`shebang for chunk "${r.fileName}" is preserved.`,prefix:"plugin:preserve-directives"}),a.prepend(`${l}
50
- `)),s.size===0&&l===null?null:{code:a.toString(),map:i?a.generateMap({hires:!0}):null}},order:"post"},transform:{handler(n,r){const i=ue(r);if(!Yn.test(i))return null;let s=!1;const a=new P(n);if(n.startsWith("#")&&n[1]==="!"){let c=0;for(let p=2,u=n.length;p<u;p++){const m=n.codePointAt(p);if(m===10||m===13||m===8232||m===8233){c=p;break}}c&&(o[r]=n.slice(0,c),a.remove(0,c+1),s=!0,e.debug({message:`shebang for module "${r}" is preserved.`,prefix:"plugin:preserve-directives"}))}let l=null;try{l=this.parse(a.toString(),{allowReturnOutsideFunction:!0})}catch(c){return this.warn({code:"PARSE_ERROR",message:`[packem:preserve-directives]: failed to parse "${r}" and extract the directives.`}),e.warn(c),null}if(l.type!=="Program")return null;for(const c of l.body.filter(Boolean)){if(c.type!=="ExpressionStatement")break;let p=null;"directive"in c?p=c.directive:c.expression.type==="Literal"&&typeof c.expression.value=="string"&&Gn.test(c.expression.value)&&(p=c.expression.value),p!=="use strict"&&p&&(t[r]||=new Set,t[r].add(p),"start"in c&&typeof c.start=="number"&&"end"in c&&typeof c.end=="number"&&(a.remove(c.start,c.end),s=!0),e.debug({message:`directive "${p}" for module "${r}" is preserved.`,prefix:"plugin:preserve-directives"}))}return s?{code:a.toString(),map:a.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...t[r]??[]],shebang:o[r]??null}}}:null},order:"post"}}},"preserveDirectives");var Xn=Object.defineProperty,Zn=d((e,t)=>Xn(e,"name",{value:t,configurable:!0}),"t$2");const Qn=Zn(e=>{const t=L(e.include,e.exclude);return{name:"packem:raw",transform(o,n){return t(n)?{code:`export default ${JSON.stringify(o)}`,map:null}:null}}},"rawPlugin");var er=Object.defineProperty,tr=d((e,t)=>er(e,"name",{value:t,configurable:!0}),"l$4");const oe="\0__file_url__",ct=tr(()=>({async load(e){if(e.startsWith(oe)){const t=Qt(e.slice(oe.length));return await ce(t)}},name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return`${oe}${e}`}}),"resolveFileUrl");var or=Object.defineProperty,F=d((e,t)=>or(e,"name",{value:t,configurable:!0}),"r$4");const nr=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,rr=/MIT License|MIT license|BSD license/,ir=/\n{2,}/g,sr=/\b(\w+)\$\d+\b/g,ar=/[-/\\^$*+?.()|[\]{}]/g,lr=F(e=>e.replaceAll(ar,"\\$&"),"escapeRegex"),cr=F(e=>[...new Set(e)],"unique"),pr=F(e=>e.replaceAll(nr,t=>rr.test(t)?"":t).replaceAll(ir,`
49
+ `));let c=null;return r.facadeModuleId&&typeof o[r.facadeModuleId]=="string"&&(c=o[r.facadeModuleId]),c&&(e.debug({message:`shebang for chunk "${r.fileName}" is preserved.`,prefix:"plugin:preserve-directives"}),l.prepend(`${c}
50
+ `)),s.size===0&&c===null?null:{code:l.toString(),map:i?l.generateMap({hires:!0}):null}},order:"post"},transform:{handler(n,r){const i=ue(r);if(!Xn.test(i))return null;let s=!1;const l=new P(n);if(n.startsWith("#")&&n[1]==="!"){let a=0;for(let u=2,p=n.length;u<p;u++){const d=n.codePointAt(u);if(d===10||d===13||d===8232||d===8233){a=u;break}}a&&(o[r]=n.slice(0,a),l.remove(0,a+1),s=!0,e.debug({message:`shebang for module "${r}" is preserved.`,prefix:"plugin:preserve-directives"}))}let c=null;try{c=this.parse(l.toString(),{allowReturnOutsideFunction:!0})}catch(a){return this.warn({code:"PARSE_ERROR",message:`[packem:preserve-directives]: failed to parse "${r}" and extract the directives.`}),e.warn(a),null}if(c.type!=="Program")return null;for(const a of c.body.filter(Boolean)){if(a.type!=="ExpressionStatement")break;let u=null;"directive"in a?u=a.directive:a.expression.type==="Literal"&&typeof a.expression.value=="string"&&Zn.test(a.expression.value)&&(u=a.expression.value),u!=="use strict"&&u&&(t[r]||=new Set,t[r].add(u),"start"in a&&typeof a.start=="number"&&"end"in a&&typeof a.end=="number"&&(l.remove(a.start,a.end),s=!0),e.debug({message:`directive "${u}" for module "${r}" is preserved.`,prefix:"plugin:preserve-directives"}))}return s?{code:l.toString(),map:l.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...t[r]??[]],shebang:o[r]??null}}}:null},order:"post"}}},"preserveDirectives");var er=Object.defineProperty,tr=m((e,t)=>er(e,"name",{value:t,configurable:!0}),"t$2");const or=tr(e=>{const t=W(e.include,e.exclude);return{name:"packem:raw",transform(o,n){return t(n)?{code:`export default ${JSON.stringify(o)}`,map:null}:null}}},"rawPlugin");var nr=Object.defineProperty,rr=m((e,t)=>nr(e,"name",{value:t,configurable:!0}),"l$4");const oe="\0__file_url__",pt=rr(()=>({async load(e){if(e.startsWith(oe)){const t=Qt(e.slice(oe.length));return await ce(t)}},name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return`${oe}${e}`}}),"resolveFileUrl");var ir=Object.defineProperty,T=m((e,t)=>ir(e,"name",{value:t,configurable:!0}),"r$3");const sr=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,ar=/MIT License|MIT license|BSD license/,lr=/\n{2,}/g,cr=/\b(\w+)\$\d+\b/g,pr=/[-/\\^$*+?.()|[\]{}]/g,ur=T(e=>e.replaceAll(pr,"\\$&"),"escapeRegex"),dr=T(e=>[...new Set(e)],"unique"),mr=T(e=>e.replaceAll(sr,t=>ar.test(t)?"":t).replaceAll(lr,`
51
51
 
52
- `),"cleanUnnecessaryComments"),Pe=new Map;function pt(e,t,{identifierReplacements:o},n){const r=qe(e);for(const s in o){const a=r.find(c=>c.specifier===s&&c.imports.includes("{"));if(!a){this.warn(`${t.fileName} does not import "${s}" for replacement`),process.exitCode=1;continue}const l=o[s];for(const c in l){if(!a.imports.includes(c))throw new Error(`${t.fileName} does not import "${c}" from "${s}" for replacement`);const p=l[c],u=lr(c);p.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${u},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${u}\\b`,"g"),p)}}const i=cr(Array.from(e.matchAll(sr),s=>s[0]));if(i.length>0){const s=i.map(l=>`
53
- - ${l}`).join(""),a=t.fileName.replace(/\.[^/.]+$/,"");Pe.has(a)||n.warn({message:`${t.fileName} contains confusing identifier names${s}
52
+ `),"cleanUnnecessaryComments"),Ce=new Map;function ut(e,t,{identifierReplacements:o},n){const r=Ke(e);for(const s in o){const l=r.find(a=>a.specifier===s&&a.imports.includes("{"));if(!l){this.warn(`${t.fileName} does not import "${s}" for replacement`),process.exitCode=1;continue}const c=o[s];for(const a in c){if(!l.imports.includes(a))throw new Error(`${t.fileName} does not import "${a}" from "${s}" for replacement`);const u=c[a],p=ur(a);u.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${p},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${p}\\b`,"g"),u)}}const i=dr(Array.from(e.matchAll(cr),s=>s[0]));if(i.length>0){const s=i.map(c=>`
53
+ - ${c}`).join(""),l=t.fileName.replace(/\.[^/.]+$/,"");Ce.has(l)||n.warn({message:`${t.fileName} contains confusing identifier names${s}
54
54
 
55
- To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),Pe.set(a,!0)}return e}d(pt,"I$1");F(pt,"replaceConfusingTypeNames");function ut(e,t){if(t.leadingComments?.some(o=>o.type==="CommentBlock"&&o.value.includes("@internal"))){const o=e.original[t.end]===","?t.end+1:t.end;return e.remove(t.leadingComments[0].start,o),!0}return!1}d(ut,"N$1");F(ut,"removeInternal");function dt(e,t){if(e.includes("@internal")){const o=new P(e),n=fo(e,{plugins:["typescript"],sourceType:"module"});if(st(n,{enter(r){ut(o,r)&&this.skip()}}),e=o.toString(),e.includes("@internal"))throw new Error(`${t.fileName} has unhandled @internal declarations`)}return e}d(dt,"S");F(dt,"stripInternalTypes");const ur=F((e,t)=>({name:"packem:patch-types",renderChunk(o,n){return o=pt.call(this,o,n,e,t),o=dt.call(this,o,n),o=pr(o),o},resolveId(o){return o.startsWith("types/")?{external:!0,id:"../../"+(o.endsWith(".js")?o:o+".js")}:null}}),"patchTypescriptTypes");var dr=Object.defineProperty,mt=d((e,t)=>dr(e,"name",{value:t,configurable:!0}),"u$6");const ft=mt((e,t=!0)=>{if(!e)return null;const{config:o,path:n}=e;if(!o.compilerOptions)return null;const{baseUrl:r,paths:i}=o.compilerOptions;if(!r)return null;const s=g(de(n),r),a=[];if(i)for(const[l,c]of Object.entries(i)){const p=new RegExp(`^${[...l].map(m=>m==="*"?"(.+)":m.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let u=0;for(const m of c){const f=[...Ee(g(s,m))].map(b=>b==="*"?"$"+(++u+""):b==="$"?"$$":b).join("");a.push({find:p,replacement:f})}}return t&&a.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...Ee(s)].map(l=>l==="$"?"$$":l).join("")}/$1`}),a},"getConfigAlias"),gt=mt((e,t)=>{const o=ft(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(n,r,i){if(!o||n.includes("\0"))return null;for(const{find:s,replacement:a}of o)if(s.test(n)){const l=n.replace(s,a),c=await this.resolve(l,r,{skipSelf:!0,...i});if(c)return t.debug({message:`Resolved ${n} to ${c.id} using paths from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-paths"}),c.id}return null}}},"resolveTsconfigPaths");var mr=Object.defineProperty,ht=d((e,t)=>mr(e,"name",{value:t,configurable:!0}),"u$5");const fr=ht((e,t)=>{if(!t)return null;const{config:o,path:n}=t;if(!o.compilerOptions)return null;const{rootDirs:r}=o.compilerOptions;if(!r)return null;const i=[];for(const s of r){if(s.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${n}.`);if(s.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${n}.`);i.push(g(e,s))}return i},"getRootDirectories"),yt=ht((e,t,o)=>{const n=fr(e,o);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(r,i,s){if(n===null||n.length===0)return null;if(r.startsWith("."))for(const a of n){const l=y(a,r),c=await this.resolve(l,i,{skipSelf:!0,...s});if(c)return t.debug({message:`Resolved ${r} to ${c.id} using rootDirs from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-root-dirs"}),c.id}return null}}},"resolveTsconfigRootDirectories");var gr=Object.defineProperty,hr=d((e,t)=>gr(e,"name",{value:t,configurable:!0}),"r$3");const vt=hr(()=>{const e=/\.(?:[mc]?js|jsx)$/;return{name:"packem:resolve-typescript-mjs-cjs",async resolveId(t,o,n){return e.test(t)&&o?await this.resolve(t.replace(/js(x?)$/,"ts$1"),o,n):null}}},"resolveTypescriptMjsCts");var yr=Object.defineProperty,vr=d((e,t)=>yr(e,"name",{value:t,configurable:!0}),"s$8");const br=vr(e=>{const t=G(e).split(".");if(t.length>=2){const[o,n]=t.slice(-2),r=t[0],i=/^(\w+)-runtime$/.exec(o)?.[1];if(A.includes(n)&&i&&i.length>0)return r+"-"+i}},"getCustomModuleLayer");var wr=Object.defineProperty,$r=d((e,t)=>wr(e,"name",{value:t,configurable:!0}),"i$4");const ne=$r(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var jr=Object.defineProperty,Ce=d((e,t)=>jr(e,"name",{value:t,configurable:!0}),"c$4");const Me=Ce((e,t)=>{const o=new Map;return Ce(function(n,r){const i=r.getModuleInfo(n);if(!i)return;const{isEntry:s}=i,a=i.meta,l=ne(a);if(!s){const c=o.get(n);if(c)return c;const p=br(n);if(p)return o.set(n,p),p}if(s){const c=r.getModuleIds();for(const p of c)r.getModuleInfo(p)&&ne(a)===l&&(e.has(p)||e.set(p,new Set),e.get(p).add([n,l]))}if(l&&!s&&e.has(n)){const c=[...e.get(n)];if(c.some(([u])=>{if(t.some(m=>m.path===u)){const m=r.getModuleInfo(u);return ne(m?m.meta:{})===l}return!1}))return;if(c.every(([,u])=>u===l))return o.has(n)?o.get(n):void 0;const p=`${G(n,ue(n))}-${l}`;return o.set(n,p),p}},"splitChunks")},"createSplitChunks");var kr=Object.defineProperty,xr=d((e,t)=>kr(e,"name",{value:t,configurable:!0}),"n");const _=xr((e,t,o)=>t.isDynamicEntry?`chunks/[name].${o}`:`shared/${e.options.name}.[hash].${o}`,"getChunkFilename");var Er=Object.defineProperty,Or=d((e,t)=>Er(e,"name",{value:t,configurable:!0}),"s$6");const Sr=process.platform==="win32",Ie=Or((e,t)=>{const o=Sr?"\\":"/";return e.name?.includes("node_modules"+o+".pnpm")?(e.name.replace("node_modules"+o+".pnpm","external")+"."+t).replace("node_modules"+o,""):e.name?.includes("node_modules")?e.name.replace("node_modules","external")+"."+t:"[name]."+t},"getEntryFileNames");var Dr=Object.defineProperty,$=d((e,t)=>Dr(e,"name",{value:t,configurable:!0}),"p$2");const Nr=$((e,t)=>{if(e==="esbuild"){if(!t.options.rollup.esbuild)throw new Error("No esbuild options found in your configuration.");t.tsconfig?.config.compilerOptions?.target?.toLowerCase()==="es3"&&(t.logger.warn(["ES3 target is not supported by esbuild, so ES5 will be used instead..","Please set 'target' option in tsconfig to at least ES5 to disable this error"].join(" ")),t.tsconfig.config.compilerOptions.target="es5",t.options.rollup.esbuild.target="es5");let o="node"+Pt.node.split(".")[0];if(t.pkg.engines?.node){const n=Xe(t.pkg.engines.node);n&&(o="node"+n.major)}if(t.options.rollup.esbuild.target){const n=te(t.options.rollup.esbuild.target);n.some(r=>r.startsWith("node"))||(t.options.rollup.esbuild.target=[...new Set([...te(o),...n])])}else t.options.rollup.esbuild.target=te(o);return t.tsconfig?.config.compilerOptions?.target==="es5"&&(t.options.rollup.esbuild.keepNames=!1,t.logger.debug("Disabling keepNames because target is set to es5")),{logger:t.logger,minify:t.options.minify,minifyWhitespace:t.options.minify,sourceMap:t.options.sourcemap,...t.options.rollup.esbuild}}if(e==="swc"){if(!t.options.rollup.swc)throw new Error("No swc options found in your configuration.");return{minify:t.options.minify,...t.options.rollup.swc,jsc:{minify:{compress:{directives:!1},format:{comments:"some"},mangle:{toplevel:!0},sourceMap:t.options.sourcemap,toplevel:t.options.emitCJS??t.options.emitESM},...t.options.rollup.swc.jsc},sourceMaps:t.options.sourcemap}}if(e==="sucrase"){if(!t.options.rollup.sucrase)throw new Error("No sucrase options found in your configuration.");return{...t.options.rollup.sucrase}}throw new Error("A Unknown transformer was provided")},"getTransformerConfig"),bt=$((e,t)=>{if(e.code==="CIRCULAR_DEPENDENCY"&&/Circular dependency:[\s\S]*node_modules/.test(e.message))return!0;if(e.code==="UNRESOLVED_IMPORT")throw new Error(`Failed to resolve the module "${e.exporter}" imported by "${h(D(g(),e.id))}"
55
+ To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),Ce.set(l,!0)}return e}m(ut,"I$1");T(ut,"replaceConfusingTypeNames");function dt(e,t){if(t.leadingComments?.some(o=>o.type==="CommentBlock"&&o.value.includes("@internal"))){const o=e.original[t.end]===","?t.end+1:t.end;return e.remove(t.leadingComments[0].start,o),!0}return!1}m(dt,"N");T(dt,"removeInternal");function mt(e,t){if(e.includes("@internal")){const o=new P(e),n=fo(e,{plugins:["typescript"],sourceType:"module"});if(at(n,{enter(r){dt(o,r)&&this.skip()}}),e=o.toString(),e.includes("@internal"))throw new Error(`${t.fileName} has unhandled @internal declarations`)}return e}m(mt,"S");T(mt,"stripInternalTypes");const fr=T((e,t)=>({name:"packem:patch-types",renderChunk(o,n){return o=ut.call(this,o,n,e,t),o=mt.call(this,o,n),o=mr(o),o},resolveId(o){return o.startsWith("types/")?{external:!0,id:"../../"+(o.endsWith(".js")?o:o+".js")}:null}}),"patchTypescriptTypes");var gr=Object.defineProperty,ft=m((e,t)=>gr(e,"name",{value:t,configurable:!0}),"u$6");const gt=ft((e,t=!0)=>{if(!e)return null;const{config:o,path:n}=e;if(!o.compilerOptions)return null;const{baseUrl:r,paths:i}=o.compilerOptions;if(!r)return null;const s=g(de(n),r),l=[];if(i)for(const[c,a]of Object.entries(i)){const u=new RegExp(`^${[...c].map(d=>d==="*"?"(.+)":d.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let p=0;for(const d of a){const f=[...Oe(g(s,d))].map(j=>j==="*"?"$"+(++p+""):j==="$"?"$$":j).join("");l.push({find:u,replacement:f})}}return t&&l.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...Oe(s)].map(c=>c==="$"?"$$":c).join("")}/$1`}),l},"getConfigAlias"),ht=ft((e,t)=>{const o=gt(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(n,r,i){if(!o||n.includes("\0"))return null;for(const{find:s,replacement:l}of o)if(s.test(n)){const c=n.replace(s,l),a=await this.resolve(c,r,{skipSelf:!0,...i});if(a)return t.debug({message:`Resolved ${n} to ${a.id} using paths from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-paths"}),a.id}return null}}},"resolveTsconfigPaths");var hr=Object.defineProperty,yt=m((e,t)=>hr(e,"name",{value:t,configurable:!0}),"u$5");const yr=yt((e,t)=>{if(!t)return null;const{config:o,path:n}=t;if(!o.compilerOptions)return null;const{rootDirs:r}=o.compilerOptions;if(!r)return null;const i=[];for(const s of r){if(s.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${n}.`);if(s.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${n}.`);i.push(g(e,s))}return i},"getRootDirectories"),vt=yt((e,t,o)=>{const n=yr(e,o);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(r,i,s){if(n===null||n.length===0)return null;if(r.startsWith("."))for(const l of n){const c=h(l,r),a=await this.resolve(c,i,{skipSelf:!0,...s});if(a)return t.debug({message:`Resolved ${r} to ${a.id} using rootDirs from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-root-dirs"}),a.id}return null}}},"resolveTsconfigRootDirectories");var vr=Object.defineProperty,br=m((e,t)=>vr(e,"name",{value:t,configurable:!0}),"r$2");const bt=br(()=>{const e=/\.(?:[mc]?js|jsx)$/;return{name:"packem:resolve-typescript-mjs-cjs",async resolveId(t,o,n){return e.test(t)&&o?await this.resolve(t.replace(/js(x?)$/,"ts$1"),o,n):null}}},"resolveTypescriptMjsCts");var $r=Object.defineProperty,wr=m((e,t)=>$r(e,"name",{value:t,configurable:!0}),"s$8");const jr=wr(e=>{const t=G(e).split(".");if(t.length>=2){const[o,n]=t.slice(-2),r=t[0],i=/^(\w+)-runtime$/.exec(o)?.[1];if(A.includes(n)&&i&&i.length>0)return r+"-"+i}},"getCustomModuleLayer");var kr=Object.defineProperty,xr=m((e,t)=>kr(e,"name",{value:t,configurable:!0}),"i$3");const ne=xr(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var Er=Object.defineProperty,Me=m((e,t)=>Er(e,"name",{value:t,configurable:!0}),"c$4");const Ie=Me((e,t)=>{const o=new Map;return Me(function(n,r){const i=r.getModuleInfo(n);if(!i)return;const{isEntry:s}=i,l=i.meta,c=ne(l);if(!s){const a=o.get(n);if(a)return a;const u=jr(n);if(u)return o.set(n,u),u}if(s){const a=r.getModuleIds();for(const u of a)r.getModuleInfo(u)&&ne(l)===c&&(e.has(u)||e.set(u,new Set),e.get(u).add([n,c]))}if(c&&!s&&e.has(n)){const a=[...e.get(n)];if(a.some(([p])=>{if(t.some(d=>d.path===p)){const d=r.getModuleInfo(p);return ne(d?d.meta:{})===c}return!1}))return;if(a.every(([,p])=>p===c))return o.has(n)?o.get(n):void 0;const u=G(n,ue(n))+"-"+c;return o.set(n,u),u}},"splitChunks")},"createSplitChunks");var Or=Object.defineProperty,Sr=m((e,t)=>Or(e,"name",{value:t,configurable:!0}),"n");const _=Sr((e,t,o)=>t.isDynamicEntry?`chunks/[name].${o}`:`shared/${e.options.name}.[hash].${o}`,"getChunkFilename");var Dr=Object.defineProperty,Nr=m((e,t)=>Dr(e,"name",{value:t,configurable:!0}),"s$6");const _r=process.platform==="win32",Re=Nr((e,t)=>{const o=_r?"\\":"/";return e.name?.includes("node_modules"+o+".pnpm")?(e.name.replace("node_modules"+o+".pnpm","external")+"."+t).replace("node_modules"+o,""):e.name?.includes("node_modules")?e.name.replace("node_modules","external")+"."+t:"[name]."+t},"getEntryFileNames");var Pr=Object.defineProperty,$=m((e,t)=>Pr(e,"name",{value:t,configurable:!0}),"p$2");const Cr=$((e,t)=>{if(e==="esbuild"){if(!t.options.rollup.esbuild)throw new Error("No esbuild options found in your configuration.");t.tsconfig?.config.compilerOptions?.target?.toLowerCase()==="es3"&&(t.logger.warn(["ES3 target is not supported by esbuild, so ES5 will be used instead..","Please set 'target' option in tsconfig to at least ES5 to disable this error"].join(" ")),t.tsconfig.config.compilerOptions.target="es5",t.options.rollup.esbuild.target="es5");let o="node"+Pt.node.split(".")[0];if(t.pkg.engines?.node){const n=Ze(t.pkg.engines.node);n&&(o="node"+n.major)}if(t.options.rollup.esbuild.target){const n=te(t.options.rollup.esbuild.target);n.some(r=>r.startsWith("node"))||(t.options.rollup.esbuild.target=[...new Set([...te(o),...n])])}else t.options.rollup.esbuild.target=te(o);return t.tsconfig?.config.compilerOptions?.target==="es5"&&(t.options.rollup.esbuild.keepNames=!1,t.logger.debug("Disabling keepNames because target is set to es5")),{logger:t.logger,minify:t.options.minify,minifyWhitespace:t.options.minify,sourceMap:t.options.sourcemap,...t.options.rollup.esbuild}}if(e==="swc"){if(!t.options.rollup.swc)throw new Error("No swc options found in your configuration.");return{minify:t.options.minify,...t.options.rollup.swc,jsc:{minify:{compress:{directives:!1},format:{comments:"some"},mangle:{toplevel:!0},sourceMap:t.options.sourcemap,toplevel:t.options.emitCJS??t.options.emitESM},...t.options.rollup.swc.jsc},sourceMaps:t.options.sourcemap}}if(e==="sucrase"){if(!t.options.rollup.sucrase)throw new Error("No sucrase options found in your configuration.");return{...t.options.rollup.sucrase}}throw new Error("A Unknown transformer was provided")},"getTransformerConfig"),$t=$((e,t)=>{if(e.code==="CIRCULAR_DEPENDENCY"&&/Circular dependency:[\s\S]*node_modules/.test(e.message))return!0;if(e.code==="UNRESOLVED_IMPORT")throw new Error(`Failed to resolve the module "${e.exporter}" imported by "${v(S(g(),e.id))}"
56
56
  Is the module installed? Note:
57
57
  ↳ to inline a module into your bundle, install it to "devDependencies".
58
- ↳ to depend on a module via import/require, install it to "dependencies".`);return e.code==="MIXED_EXPORTS"&&t.options.cjsInterop===!0},"sharedOnWarn"),Re=new Map,wt=$((e,t,o)=>{const n=$(i=>{for(const[s,a]of Object.entries(t))if(i.startsWith(s))return i.replace(s,a)},"findAlias"),r=ft(e.tsconfig,!1);return{external(i){const s=n(i);s&&(i=s);const a=ot(i);if(le(e.options.externals,a)||le(e.options.externals,i))return!0;const{pkg:l}=e;if(i.startsWith(".")||Ve(i)||/src[/\\]/.test(i)||l.name&&i.startsWith(l.name)||l?.imports?.[i]!==void 0)return!1;if(r){for(const{find:c}of r)if(c.test(i))return e.logger.debug({message:`Resolved alias ${i} to ${c.source}`,prefix:o}),!1}return Re.has(i)||e.logger.info({message:'Inlined implicit external "'+h(i)+'". If this is incorrect, add it to the "externals" option.',prefix:o}),Re.set(i,!0),!1},input:Object.fromEntries(e.options.entries.map(i=>[i.name,g(e.options.rootDir,i.input)])),logLevel:e.options.debug?"debug":"info",onLog:$((i,s)=>{let a=s.message;switch(s.stack&&(a=`${a}
59
- ${s.stack}`),i){case"info":{e.logger.info({message:a,prefix:o+(s.plugin?":plugin:"+s.plugin:"")});return}case"warn":{e.logger.warn({message:a,prefix:o+(s.plugin?":plugin:"+s.plugin:"")});return}case"debug":e.logger.debug({message:a,prefix:o+(s.plugin?":plugin:"+s.plugin:"")})}},"onLog"),onwarn(i,s){bt(i,e)||i.code||s(i)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),$t=$(async(e,t)=>{const o=ge(e,"build");let n;return e.options.rollup.resolve&&(n=E(Be({extensions:A,...e.options.rollup.resolve}),t)),{...wt(e,o,"dependencies"),output:[e.options.emitCJS&&{chunkFileNames:$(r=>_(e,r,"cjs"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:$(r=>Ie(r,"cjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"cjs",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,interop:"compat",sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:Me(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}},e.options.emitESM&&{chunkFileNames:$(r=>_(e,r,"mjs"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:$(r=>Ie(r,"mjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"esm",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:Me(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}}].filter(Boolean),plugins:[E(ct(),t),E(vt(),t),e.tsconfig&&E(yt(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&E(gt(e.tsconfig,e.logger),t),e.options.rollup.replace&&Ke({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&Ge({customResolver:n,...e.options.rollup.alias,entries:o}),n,e.options.rollup.polyfillNode&&so({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&it({...e.options.rollup.json}),Kn(e.logger),Do(e.options.entries.filter(r=>r.executable).map(r=>r.name).filter(Boolean)),e.options.rollup.wsam&&io(e.options.rollup.wsam),e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer&&Nn(y(e.options.rootDir,e.options.sourceDir))(e.options.isolatedDeclarationTransformer,e.options.rollup.isolatedDeclarations),e.options.transformer?.(Nr(e.options.transformerName,e)),e.options.cjsInterop&&e.options.emitCJS&&rt({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&Sn(),e.options.rollup.dynamicVars&&ro(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&E(no({extensions:A,sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),t),e.options.rollup.preserveDynamicImports&&{renderDynamicImport(){return{left:"import(",right:")"}}},e.options.rollup.shim&&xn(e.pkg,e.options.rollup.shim),e.options.rollup.raw&&Qn(e.options.rollup.raw),e.options.rollup.jsxRemoveAttributes&&Fn({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),e.options.rollup.metafile&&Ln({outDir:g(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&vn(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&at({dtsMarker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dependenciesTemplate,logger:e.logger,marker:e.options.rollup.license.dependenciesMarker??"DEPENDENCIES",mode:"dependencies",packageName:e.pkg.name}),e.options.rollup.visualizer&&ao({brotliSize:!0,filename:"packem-bundle-analyze.html",gzipSize:!0,projectRoot:e.options.rootDir,sourcemap:e.options.sourcemap,title:"Packem Visualizer",...e.options.rollup.visualizer})].filter(Boolean)}},"getRollupOptions"),_r=$(async e=>{const{dts:t}=require("rollup-plugin-dts");return t({compilerOptions:{...e.options.rollup.dts.compilerOptions,incremental:void 0,inlineSources:void 0,sourceMap:void 0,tsBuildInfoFile:void 0},respectExternal:e.options.rollup.dts.respectExternal,tsconfig:e.tsconfig?.path})},"createDtsPlugin"),Pr=mn(_r),jt=$(async(e,t)=>{const o=ge(e,"types"),n={load(a){return/\.(?:js|cjs|mjs|jsx|ts|tsx|mts|json)$/.test(a)?null:""},name:"packem:ignore-files"},r=e.tsconfig?.config.compilerOptions;delete r?.lib;let i;e.options.rollup.resolve&&(i=E(Be({extensions:A,...e.options.rollup.resolve}),t));const s="dts-plugin:"+process.pid+e.tsconfig.path;return{...wt(e,o,"dts"),onwarn(a,l){bt(a,e)||a.code!=="EMPTY_BUNDLE"&&l(a)},output:[e.options.emitCJS&&{chunkFileNames:$(a=>_(e,a,"d.cts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.emitESM&&{chunkFileNames:$(a=>_(e,a,"d.mts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts",format:"esm",sourcemap:e.options.sourcemap,...e.options.rollup.output},(e.options.declaration===!0||e.options.declaration==="compatible")&&{chunkFileNames:$(a=>_(e,a,"d.ts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:[E(ct(),t),E(vt(),t),e.options.rollup.json&&it({...e.options.rollup.json}),n,e.tsconfig&&E(yt(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&E(gt(e.tsconfig,e.logger),t),e.options.rollup.replace&&Ke({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&Ge({customResolver:i,...e.options.rollup.alias,entries:o}),i,await Pr(s)(e),e.options.cjsInterop&&e.options.emitCJS&&rt({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&ur(e.options.rollup.patchTypes,e.logger),No(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&at({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dtsTemplate,logger:e.logger,marker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",mode:"types",packageName:e.pkg.name})].filter(Boolean)}},"getRollupDtsOptions");var Cr=Object.defineProperty,Mr=d((e,t)=>Cr(e,"name",{value:t,configurable:!0}),"c$3");const re=Mr(async(e,t)=>{const o=await $t(e,t);if(await e.hooks.callHook("rollup:options",e,o),Object.keys(o.input).length===0)return;const n="rollup-build.json";o.cache=t.get(n);const r=await He(o);t.set(n,r.cache),await e.hooks.callHook("rollup:build",e,r);const i=new Map;for(const s of o.output){const{output:a}=await r.write(s),l=new Set,c=a.filter(u=>u.type==="chunk");for(const u of c){l.add(u.fileName);for(const m of u.imports)e.usedImports.add(m);u.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(u.code,"utf8"),chunks:u.imports.filter(m=>c.find(f=>f.fileName===m)),exports:u.exports,modules:Object.entries(u.modules).map(([m,f])=>({bytes:f.renderedLength,id:m})),path:u.fileName,type:"entry"})}const p=a.filter(u=>u.type==="asset");for(const u of p)i.has(u.fileName)||i.set(u.fileName,{bytes:Buffer.byteLength(u.source,"utf8"),path:u.fileName,type:"asset"});for(const u of l)e.usedImports.delete(u)}e.buildEntries.push(...i.values())},"build");var Ir=Object.defineProperty,V=d((e,t)=>Ir(e,"name",{value:t,configurable:!0}),"s$5");const ie=V(async(e,t)=>{if(e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer){e.logger.debug({message:"Skipping declaration file generation as isolated declaration transformer is enabled.",prefix:"dts"});return}const o=await jt(e,t);if(await e.hooks.callHook("rollup:dts:options",e,o),Object.keys(o.input).length===0)return;const n="rollup-dts.json";o.cache=t.get(n);const r=await He(o);t.set(n,r.cache),await e.hooks.callHook("rollup:dts:build",e,r),e.logger.info({message:"Building declaration files...",prefix:"dts"}),e.options.emitCJS&&await r.write({chunkFileNames:V(i=>_(e,i,"d.cts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await r.write({chunkFileNames:V(i=>_(e,i,"d.mts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts"}),(e.options.declaration===!0||e.options.declaration==="compatible")&&await r.write({chunkFileNames:V(i=>_(e,i,"d.mjs"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts"}),await e.hooks.callHook("rollup:dts:done",e)},"buildTypes");var Rr=Object.defineProperty,be=d((e,t)=>Rr(e,"name",{value:t,configurable:!0}),"i$2");const Fr=be(e=>{const{message:t,name:o="Error",stack:n}=e;if(!n)return n;const r=`${o}: ${t}
60
- `;return n.startsWith(r)?n.slice(r.length):n},"extractStack"),Tr=be(e=>`
58
+ ↳ to depend on a module via import/require, install it to "dependencies".`);return e.code==="MODULE_LEVEL_DIRECTIVE"?!0:e.code==="MIXED_EXPORTS"&&t.options.cjsInterop===!0},"sharedOnWarn"),Fe=new Map,wt=$((e,t,o)=>{const n=$(i=>{for(const[s,l]of Object.entries(t))if(i.startsWith(s))return i.replace(s,l)},"findAlias"),r=gt(e.tsconfig,!1);return{external(i){const s=n(i);s&&(i=s);const l=nt(i);if(le(e.options.externals,l)||le(e.options.externals,i))return!0;const{pkg:c}=e;if(i.startsWith(".")||He(i)||/src[/\\]/.test(i)||c.name&&i.startsWith(c.name)||c?.imports?.[i]!==void 0)return!1;if(r){for(const{find:a}of r)if(a.test(i))return e.logger.debug({message:`Resolved alias ${i} to ${a.source}`,prefix:o}),!1}return Fe.has(i)||e.logger.info({message:'Inlined implicit external "'+v(i)+'". If this is incorrect, add it to the "externals" option.',prefix:o}),Fe.set(i,!0),!1},input:Object.fromEntries(e.options.entries.map(i=>[i.name,g(e.options.rootDir,i.input)])),logLevel:e.options.debug?"debug":"info",onLog:$((i,s)=>{let l=s.message;switch(s.stack&&(l=`${l}
59
+ ${s.stack}`),i){case"info":{e.logger.info({message:l,prefix:o+(s.plugin?":plugin:"+s.plugin:"")});return}case"warn":{e.logger.warn({message:l,prefix:o+(s.plugin?":plugin:"+s.plugin:"")});return}case"debug":e.logger.debug({message:l,prefix:o+(s.plugin?":plugin:"+s.plugin:"")})}},"onLog"),onwarn(i,s){$t(i,e)||i.code||s(i)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),jt=$(async(e,t)=>{const o=ge(e,"build");let n;return e.options.rollup.resolve&&(n=x(We({extensions:A,...e.options.rollup.resolve}),t)),{...wt(e,o,"dependencies"),output:[e.options.emitCJS&&{chunkFileNames:$(r=>_(e,r,"cjs"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:$(r=>Re(r,"cjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"cjs",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,interop:"compat",sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:Ie(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}},e.options.emitESM&&{chunkFileNames:$(r=>_(e,r,"mjs"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:$(r=>Re(r,"mjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"esm",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:Ie(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}}].filter(Boolean),plugins:[x(pt(),t),x(bt(),t),e.tsconfig&&x(vt(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&x(ht(e.tsconfig,e.logger),t),e.options.rollup.replace&&Xe({sourcemap:e.options.sourcemap,...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&Ge({customResolver:n,...e.options.rollup.alias,entries:o}),n,e.options.rollup.polyfillNode&&so({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&st({...e.options.rollup.json}),Qn(e.logger),Do(e.options.entries.filter(r=>r.executable).map(r=>r.name).filter(Boolean)),e.options.rollup.wsam&&io(e.options.rollup.wsam),e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer&&Cn(h(e.options.rootDir,e.options.sourceDir))(e.options.isolatedDeclarationTransformer,e.options.rollup.isolatedDeclarations),e.options.transformer?.(Cr(e.options.transformerName,e)),e.options.cjsInterop&&e.options.emitCJS&&it({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&_n(),e.options.rollup.dynamicVars&&ro(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&x(no({extensions:A,sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),t),e.options.rollup.preserveDynamicImports&&{renderDynamicImport(){return{left:"import(",right:")"}}},e.options.rollup.shim&&Sn(e.pkg,e.options.rollup.shim),e.options.rollup.raw&&or(e.options.rollup.raw),e.options.rollup.jsxRemoveAttributes&&Jn({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),e.options.rollup.metafile&&Vn({outDir:g(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&wn(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&lt({dtsMarker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dependenciesTemplate,logger:e.logger,marker:e.options.rollup.license.dependenciesMarker??"DEPENDENCIES",mode:"dependencies",packageName:e.pkg.name}),e.options.rollup.visualizer&&ao({brotliSize:!0,filename:"packem-bundle-analyze.html",gzipSize:!0,projectRoot:e.options.rootDir,sourcemap:e.options.sourcemap,title:"Packem Visualizer",...e.options.rollup.visualizer})].filter(Boolean)}},"getRollupOptions"),Mr=$(async e=>{const{dts:t}=require("rollup-plugin-dts");return t({compilerOptions:{...e.options.rollup.dts.compilerOptions,incremental:void 0,inlineSources:void 0,sourceMap:void 0,tsBuildInfoFile:void 0},respectExternal:e.options.rollup.dts.respectExternal,tsconfig:e.tsconfig?.path})},"createDtsPlugin"),Ir=hn(Mr),kt=$(async(e,t)=>{const o=ge(e,"types"),n={load(l){return/\.(?:js|cjs|mjs|jsx|ts|tsx|mts|json)$/.test(l)?null:""},name:"packem:ignore-files"},r=e.tsconfig?.config.compilerOptions;delete r?.lib;let i;e.options.rollup.resolve&&(i=x(We({extensions:A,...e.options.rollup.resolve}),t));const s="dts-plugin:"+process.pid+e.tsconfig.path;return{...wt(e,o,"dts"),onwarn(l,c){$t(l,e)||l.code!=="EMPTY_BUNDLE"&&c(l)},output:[e.options.emitCJS&&{chunkFileNames:$(l=>_(e,l,"d.cts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.emitESM&&{chunkFileNames:$(l=>_(e,l,"d.mts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts",format:"esm",sourcemap:e.options.sourcemap,...e.options.rollup.output},(e.options.declaration===!0||e.options.declaration==="compatible")&&{chunkFileNames:$(l=>_(e,l,"d.ts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:[x(pt(),t),x(bt(),t),e.options.rollup.json&&st({...e.options.rollup.json}),n,e.tsconfig&&x(vt(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&x(ht(e.tsconfig,e.logger),t),e.options.rollup.replace&&Xe({sourcemap:e.options.sourcemap,...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&Ge({customResolver:i,...e.options.rollup.alias,entries:o}),i,await Ir(s)(e),e.options.cjsInterop&&e.options.emitCJS&&it({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&fr(e.options.rollup.patchTypes,e.logger),No(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&lt({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dtsTemplate,logger:e.logger,marker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",mode:"types",packageName:e.pkg.name})].filter(Boolean)}},"getRollupDtsOptions");var Rr=Object.defineProperty,Fr=m((e,t)=>Rr(e,"name",{value:t,configurable:!0}),"c$3");const re=Fr(async(e,t)=>{const o=await jt(e,t);if(await e.hooks.callHook("rollup:options",e,o),Object.keys(o.input).length===0)return;const n="rollup-build.json";o.cache=t.get(n);const r=await qe(o);t.set(n,r.cache),await e.hooks.callHook("rollup:build",e,r);const i=new Map;for(const s of o.output){const{output:l}=await r.write(s),c=new Set,a=l.filter(p=>p.type==="chunk");for(const p of a){c.add(p.fileName);for(const d of p.imports)e.usedImports.add(d);p.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(p.code,"utf8"),chunks:p.imports.filter(d=>a.find(f=>f.fileName===d)),exports:p.exports,modules:Object.entries(p.modules).map(([d,f])=>({bytes:f.renderedLength,id:d})),path:p.fileName,type:"entry"})}const u=l.filter(p=>p.type==="asset");for(const p of u)i.has(p.fileName)||i.set(p.fileName,{bytes:Buffer.byteLength(p.source,"utf8"),path:p.fileName,type:"asset"});for(const p of c)e.usedImports.delete(p)}e.buildEntries.push(...i.values())},"build");var Tr=Object.defineProperty,V=m((e,t)=>Tr(e,"name",{value:t,configurable:!0}),"s$5");const ie=V(async(e,t)=>{if(e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer){e.logger.debug({message:"Skipping declaration file generation as isolated declaration transformer is enabled.",prefix:"dts"});return}const o=await kt(e,t);if(await e.hooks.callHook("rollup:dts:options",e,o),Object.keys(o.input).length===0)return;const n="rollup-dts.json";o.cache=t.get(n);const r=await qe(o);t.set(n,r.cache),await e.hooks.callHook("rollup:dts:build",e,r),e.logger.info({message:"Building declaration files...",prefix:"dts"}),e.options.emitCJS&&await r.write({chunkFileNames:V(i=>_(e,i,"d.cts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await r.write({chunkFileNames:V(i=>_(e,i,"d.mts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts"}),(e.options.declaration===!0||e.options.declaration==="compatible")&&await r.write({chunkFileNames:V(i=>_(e,i,"d.mjs"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts"}),await e.hooks.callHook("rollup:dts:done",e)},"buildTypes");var Ar=Object.defineProperty,$e=m((e,t)=>Ar(e,"name",{value:t,configurable:!0}),"i$1");const Jr=$e(e=>{const{message:t,name:o="Error",stack:n}=e;if(!n)return n;const r=`${o}: ${t}
60
+ `;return n.startsWith(r)?n.slice(r.length):n},"extractStack"),Br=$e(e=>`
61
61
  ${e.replaceAll(/^\n|\n$/g,"")}
62
- `,"normalizeCodeFrame"),kt=be(e=>{const t=Fr(e);let o=(e.plugin?`[${e.plugin}] `:"")+e.message;e.id&&(o+=`
63
- file: ${h(e.id+(e.loc?":"+e.loc.line+":"+e.loc.column:""))}`),e.frame&&(o+=`
64
- `+Tt(Tr(e.frame))),e.message=o,t!==void 0&&(e.stack=`${e.message}
65
- ${t}`)},"enhanceRollupError");var Ar=Object.defineProperty,xt=d((e,t)=>Ar(e,"name",{value:t,configurable:!0}),"l$3");const Fe=xt((e,t,o)=>{const n="watcher:"+t;e.on("change",(r,{event:i})=>{o.info({message:`${h(D(".",r))} was ${i}d`,prefix:n})}),e.on("restart",()=>{o.info({message:"Rebuilding "+t+"...",prefix:n})}),e.on("event",async r=>{switch(r.code){case"END":{o.success({message:"Rebuild "+t+" finished",prefix:n});break}case"BUNDLE_START":{o.info({message:h("build started..."),prefix:n});break}case"BUNDLE_END":{await r.result.close(),o.info({message:h(`built in ${r.duration+""}ms.`),prefix:n});break}case"ERROR":{kt(r.error),o.error({context:[r.error],message:"Rebuild "+t+" failed: "+r.error.message,prefix:n});break}}})},"watchHandler"),Jr=xt(async(e,t)=>{const o=await $t(e,t);if(await e.hooks.callHook("rollup:options",e,o),Object.keys(o.input).length===0)return;o.cache=t.get("rollup-watch"),typeof o.watch=="object"&&o.watch.include===void 0&&(o.watch.include=[y(e.options.sourceDir,"**")],o.watch.chokidar={cwd:e.options.rootDir,...o.watch.chokidar});const n=xe(o);await e.hooks.callHook("rollup:watch",e,n);const r=[...Array.isArray(o.input)?o.input:typeof o.input=="string"?[o.input]:Object.keys(o.input??{})];let i="Starting watchers for entries:";for(const s of r)i+=R(`
66
- └─ ${D(process.cwd(),s)}`);if(e.logger.info(i),Fe(n,"bundle",e.logger),e.options.declaration){const s=await jt(e,t);await e.hooks.callHook("rollup:dts:options",e,s);const a=xe(s);await e.hooks.callHook("rollup:watch",e,a),Fe(a,"types",e.logger)}},"watch");var Br=Object.defineProperty,Wr=d((e,t)=>Br(e,"name",{value:t,configurable:!0}),"i$1");const Et=Wr(e=>`{ ${Object.keys(e).map(t=>`${t}: ${JSON.stringify(e[t])}`).join(", ")} }`,"dumpObject");var Lr=Object.defineProperty,zr=d((e,t)=>Lr(e,"name",{value:t,configurable:!0}),"a$4");let Ur=class{static{d(this,"p")}static{zr(this,"FileCache")}#n;#e;#r;#t=!0;#o=new Map;#i;constructor(t,o,n){this.#n=t,this.#e=go("@visulima/packem",{cwd:t}),this.#r=o,this.#i=n,this.#e===void 0?n.debug("Could not create cache directory."):n.debug(`Cache path is: ${this.#e}`)}set isEnabled(t){this.#t=t}get cachePath(){return this.#e}has(t,o){return!this.#t||this.#e===void 0?!1:k(this.getFilePath(t,o))}get(t,o){if(!this.#t||this.#e===void 0)return;const n=this.getFilePath(t,o);if(this.#o.has(n))return this.#o.get(n);if(!k(n))return;const r=Le(n);try{const i=JSON.parse(r);return this.#o.set(n,i),i}catch{this.#i.warn(`Could not parse cache file: ${n}, deleting the broken cache file.`),this.#o.delete(n),oo(n,{force:!0});return}}set(t,o,n){if(!this.#t||this.#e===void 0||o===void 0)return;const r=this.getFilePath(t,n);typeof o=="object"&&(o=JSON.stringify(o)),q(r,o,{overwrite:!0})}getFilePath(t,o){let n=t.replaceAll(ke(this.#n),"");return n=n.replaceAll(":","-"),y(this.#e,this.#r,o?.replaceAll(":","-")??"",ke(n))}};var Vr=Object.defineProperty,H=d((e,t)=>Vr(e,"name",{value:t,configurable:!0}),"l$2");const Hr=L,qr=H((e,t)=>{const{sideEffects:o}=t;let n;if(typeof o=="boolean")n=H(()=>o,"hasSideEffects");else if(Array.isArray(o))if(o.length<=0)n=H(()=>!1,"hasSideEffects");else{const r=o.map(i=>i.includes("/")?i:`**/${i}`);n=Hr(r,null,{resolve:e})}else n=H(()=>null,"hasSideEffects");return n},"getPackageSideEffect");var Yr=Object.defineProperty,Gr=d((e,t)=>Yr(e,"name",{value:t,configurable:!0}),"y");const Kr=Gr((e,t,o)=>e.reduce((n,r)=>{const i=r[t],s=r[o];return n[i]||(n[i]={}),n[i][s]||(n[i][s]=[]),n[i][s].push(r),n},{}),"groupByKeys");var Xr=Object.defineProperty,Zr=d((e,t)=>Xr(e,"name",{value:t,configurable:!0}),"a$3");const Qr=/^[^a-z_@#~]|[^\w/@#~-]|@\/|#\/|~\//i,ei=new Set(["abstract","await","boolean","break","byte","case","catch","char","class","const","continue","debugger","default","delete","do","double","else","enum","export","extends","false","final","finally","float","for","function","goto","if","implements","import","in","instanceof","int","interface","let","long","native","new","null","package","private","protected","public","return","short","static","super","switch","synchronized","this","throw","throws","transient","true","try","typeof","var","void","volatile","while","with","yield"]),Te=Zr(e=>{if(!Array.isArray(e)&&e!==null)for(const[t,o]of Object.entries(e)){if(typeof t!="string"||t.trim()==="")throw new Error(`Alias name "${t}" is invalid. Alias names should be non-empty strings.`);if(Qr.test(t))throw new Error(`Alias name "${t}" is invalid. Alias names should start with a letter or underscore and only contain letters, numbers, underscores, and dashes.`);if(ei.has(t))throw new Error(`Alias name "${t}" is a reserved keyword and cannot be used.`);const n=g(o);if(!k(n))throw new Error(`Target path "${n}" for alias "${t}" does not exist.`)}},"validateAliasEntries");var ti=Object.defineProperty,oi=d((e,t)=>ti(e,"name",{value:t,configurable:!0}),"o");const ni=oi(e=>{const t=new Set,o=new Set(Object.keys(e.pkg?.dependencies??{})),n=new Set;for(const r of e.usedImports)o.delete(r),t.add(r);if(e.pkg?.dependencies)for(const r of Object.keys(e.pkg?.dependencies))o.delete(r);for(const r of t){const i=ot(r);!le(e.options.externals,r)&&!r.startsWith("chunks/")&&e.pkg?.dependencies?.[i]===void 0&&e.pkg?.peerDependencies?.[i]===void 0&&n.add(r)}o.size>0&&W(e,`Potential unused dependencies found: ${[...o].map(r=>h(r)).join(", ")}`),n.size>0&&W(e,`Potential implicit dependencies found: ${[...n].map(r=>h(r)).join(", ")}`)},"validateDependencies");var ri=Object.defineProperty,Ot=d((e,t)=>ri(e,"name",{value:t,configurable:!0}),"i");const ii=Ot((e,t)=>ho(e,t)<=e.length/3||t.includes(e),"isSimilar"),si=Ot((e,t)=>{const o=e.toLowerCase();return t.filter(n=>ii(n.toLowerCase(),o))},"findAlternatives");var ai=Object.defineProperty,Ae=d((e,t)=>ai(e,"name",{value:t,configurable:!0}),"s");const li=Ae((e,t)=>{const o=new Set([...typeof e.bin=="string"?[e.bin]:Object.values(e.bin??{}),e.main,e.module,t.options.declaration?e.types:"",t.options.declaration?e.typings:"",...he(e.exports,e.type??"commonjs",t.options.declaration).map(r=>r.file)].map(r=>r&&g(t.options.rootDir,r.replace(/\/[^*/]*\*[^\n\r/\u2028\u2029]*(?:[\n\r\u2028\u2029][^*/]*\*[^\n\r/\u2028\u2029]*)*(?:\/.*)?$/,"")))),n=[];for(const r of o)r&&!r.includes("*")&&!me(r)&&n.push(r.replace(`${t.options.rootDir}/`,""));if(n.length>0){const r=Ae(a=>D(t.options.rootDir,g(t.options.outDir,a)),"rPath"),i=t.buildEntries.filter(a=>!a.chunk).map(a=>r(a.path));let s="Potential missing or wrong package.json files:";for(const a of n){const l=si(a,i);s+=`
67
- - `+h(a)+(l.length>0?At` (did you mean ${l.map(c=>`"${c}"`).join(", ")}?)`:"")}W(t,s)}},"validatePackage");var ci=Object.defineProperty,x=d((e,t)=>ci(e,"name",{value:t,configurable:!0}),"h$1");const St=x((e,t)=>{if(e.warnings.size>0&&(t&&e.logger.raw(`
62
+ `,"normalizeCodeFrame"),xt=$e(e=>{const t=Jr(e);let o=(e.plugin?`[${e.plugin}] `:"")+e.message;e.id&&(o+=`
63
+ file: ${v(e.id+(e.loc?":"+e.loc.line+":"+e.loc.column:""))}`),e.frame&&(o+=`
64
+ `+Tt(Br(e.frame))),e.message=o,t!==void 0&&(e.stack=`${e.message}
65
+ ${t}`)},"enhanceRollupError");var Wr=Object.defineProperty,Et=m((e,t)=>Wr(e,"name",{value:t,configurable:!0}),"l$3");const Te=Et((e,t,o)=>{const n="watcher:"+t;e.on("change",(r,{event:i})=>{o.info({message:`${v(S(".",r))} was ${i}d`,prefix:n})}),e.on("restart",()=>{o.info({message:"Rebuilding "+t+"...",prefix:n})}),e.on("event",async r=>{switch(r.code){case"END":{o.success({message:"Rebuild "+t+" finished",prefix:n});break}case"BUNDLE_START":{o.info({message:v("build started..."),prefix:n});break}case"BUNDLE_END":{await r.result.close(),o.info({message:v(`built in ${r.duration+""}ms.`),prefix:n});break}case"ERROR":{xt(r.error),o.error({context:[r.error],message:"Rebuild "+t+" failed: "+r.error.message,prefix:n});break}}})},"watchHandler"),Lr=Et(async(e,t)=>{const o=await jt(e,t);if(await e.hooks.callHook("rollup:options",e,o),Object.keys(o.input).length===0)return;o.cache=t.get("rollup-watch"),typeof o.watch=="object"&&o.watch.include===void 0&&(o.watch.include=[h(e.options.sourceDir,"**")],o.watch.chokidar={cwd:e.options.rootDir,...o.watch.chokidar});const n=Ee(o);await e.hooks.callHook("rollup:watch",e,n);const r=[...Array.isArray(o.input)?o.input:typeof o.input=="string"?[o.input]:Object.keys(o.input??{})];let i="Starting watchers for entries:";for(const s of r)i+=R(`
66
+ └─ ${S(process.cwd(),s)}`);if(e.logger.info(i),Te(n,"bundle",e.logger),e.options.declaration){const s=await kt(e,t);await e.hooks.callHook("rollup:dts:options",e,s);const l=Ee(s);await e.hooks.callHook("rollup:watch",e,l),Te(l,"types",e.logger)}},"watch");var zr=Object.defineProperty,Ur=m((e,t)=>zr(e,"name",{value:t,configurable:!0}),"a$4");let Vr=class{static{m(this,"p")}static{Ur(this,"FileCache")}#n;#e;#r;#t=!0;#o=new Map;#i;constructor(t,o,n){this.#n=t,this.#e=go("@visulima/packem",{cwd:t}),this.#r=o,this.#i=n,this.#e===void 0?n.debug("Could not create cache directory."):n.debug(`Cache path is: ${this.#e}`)}set isEnabled(t){this.#t=t}get cachePath(){return this.#e}has(t,o){return!this.#t||this.#e===void 0?!1:b(this.getFilePath(t,o))}get(t,o){if(!this.#t||this.#e===void 0)return;const n=this.getFilePath(t,o);if(this.#o.has(n))return this.#o.get(n);if(!b(n))return;const r=ze(n);try{const i=JSON.parse(r);return this.#o.set(n,i),i}catch{this.#i.warn(`Could not parse cache file: ${n}, deleting the broken cache file.`),this.#o.delete(n),oo(n,{force:!0});return}}set(t,o,n){if(!this.#t||this.#e===void 0||o===void 0)return;const r=this.getFilePath(t,n);typeof o=="object"&&(o=JSON.stringify(o)),K(r,o,{overwrite:!0})}getFilePath(t,o){let n=t.replaceAll(xe(this.#n),"");return n=n.replaceAll(":","-"),h(this.#e,this.#r,o?.replaceAll(":","-")??"",xe(n))}};var Hr=Object.defineProperty,H=m((e,t)=>Hr(e,"name",{value:t,configurable:!0}),"l$2");const qr=W,Kr=H((e,t)=>{const{sideEffects:o}=t;let n;if(typeof o=="boolean")n=H(()=>o,"hasSideEffects");else if(Array.isArray(o))if(o.length<=0)n=H(()=>!1,"hasSideEffects");else{const r=o.map(i=>i.includes("/")?i:`**/${i}`);n=qr(r,null,{resolve:e})}else n=H(()=>null,"hasSideEffects");return n},"getPackageSideEffect");var Yr=Object.defineProperty,Gr=m((e,t)=>Yr(e,"name",{value:t,configurable:!0}),"y");const Xr=Gr((e,t,o)=>e.reduce((n,r)=>{const i=r[t],s=r[o];return n[i]||(n[i]={}),n[i][s]||(n[i][s]=[]),n[i][s].push(r),n},{}),"groupByKeys");var Zr=Object.defineProperty,Qr=m((e,t)=>Zr(e,"name",{value:t,configurable:!0}),"a$3");const ei=/^[^a-z_@#~]|[^\w/@#~-]|@\/|#\/|~\//i,ti=new Set(["abstract","await","boolean","break","byte","case","catch","char","class","const","continue","debugger","default","delete","do","double","else","enum","export","extends","false","final","finally","float","for","function","goto","if","implements","import","in","instanceof","int","interface","let","long","native","new","null","package","private","protected","public","return","short","static","super","switch","synchronized","this","throw","throws","transient","true","try","typeof","var","void","volatile","while","with","yield"]),Ae=Qr(e=>{if(!Array.isArray(e)&&e!==null)for(const[t,o]of Object.entries(e)){if(typeof t!="string"||t.trim()==="")throw new Error(`Alias name "${t}" is invalid. Alias names should be non-empty strings.`);if(ei.test(t))throw new Error(`Alias name "${t}" is invalid. Alias names should start with a letter or underscore and only contain letters, numbers, underscores, and dashes.`);if(ti.has(t))throw new Error(`Alias name "${t}" is a reserved keyword and cannot be used.`);const n=g(o);if(!b(n))throw new Error(`Target path "${n}" for alias "${t}" does not exist.`)}},"validateAliasEntries");var oi=Object.defineProperty,ni=m((e,t)=>oi(e,"name",{value:t,configurable:!0}),"o");const ri=ni(e=>{const t=new Set,o=new Set(Object.keys(e.pkg?.dependencies??{})),n=new Set;for(const r of e.usedImports)o.delete(r),t.add(r);if(e.pkg?.dependencies)for(const r of Object.keys(e.pkg?.dependencies))o.delete(r);for(const r of t){const i=nt(r);!le(e.options.externals,r)&&!r.startsWith("chunks/")&&e.pkg?.dependencies?.[i]===void 0&&e.pkg?.peerDependencies?.[i]===void 0&&n.add(r)}o.size>0&&B(e,`Potential unused dependencies found: ${[...o].map(r=>v(r)).join(", ")}`),n.size>0&&B(e,`Potential implicit dependencies found: ${[...n].map(r=>v(r)).join(", ")}`)},"validateDependencies");var ii=Object.defineProperty,Ot=m((e,t)=>ii(e,"name",{value:t,configurable:!0}),"i");const si=Ot((e,t)=>ho(e,t)<=e.length/3||t.includes(e),"isSimilar"),ai=Ot((e,t)=>{const o=e.toLowerCase();return t.filter(n=>si(n.toLowerCase(),o))},"findAlternatives");var li=Object.defineProperty,Je=m((e,t)=>li(e,"name",{value:t,configurable:!0}),"s$1");const ci=Je((e,t)=>{const o=new Set([...typeof e.bin=="string"?[e.bin]:Object.values(e.bin??{}),e.main,e.module,t.options.declaration?e.types:"",t.options.declaration?e.typings:"",...ye(e.exports,e.type??"commonjs",t.options.declaration).map(r=>r.file)].map(r=>r&&g(t.options.rootDir,r.replace(/\/[^*/]*\*[^\n\r/\u2028\u2029]*(?:[\n\r\u2028\u2029][^*/]*\*[^\n\r/\u2028\u2029]*)*(?:\/.*)?$/,"")))),n=[];for(const r of o)r&&!r.includes("*")&&!me(r)&&n.push(r.replace(`${t.options.rootDir}/`,""));if(n.length>0){const r=Je(l=>S(t.options.rootDir,g(t.options.outDir,l)),"rPath"),i=t.buildEntries.filter(l=>!l.chunk).map(l=>r(l.path));let s="Potential missing or wrong package.json files:";for(const l of n){const c=ai(l,i);s+=`
67
+ - `+v(l)+(c.length>0?At` (did you mean ${c.map(a=>`"${a}"`).join(", ")}?)`:"")}B(t,s)}},"validatePackage");var pi=Object.defineProperty,w=m((e,t)=>pi(e,"name",{value:t,configurable:!0}),"h$1");const St=w((e,t)=>{if(e.warnings.size>0&&(t&&e.logger.raw(`
68
68
  `),e.logger.warn(`Build is done with some warnings:
69
69
 
70
70
  ${[...e.warnings].map(o=>`- ${o}`).join(`
71
- `)}`),e.options.failOnWarn))throw new Error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`.")},"logErrors"),pi=x(e=>{switch(e){case"preserve":case"react-native":return"preserve";case"react":return"transform";case"react-jsx":case"react-jsxdev":return"automatic";default:return}},"resolveTsconfigJsxToJsxRuntime"),ui=x((e,t,o,n,r,i,s,a,l)=>{const c=pi(l?.config.compilerOptions?.jsx),p=Gt(i,r,s,{alias:{},clean:!0,debug:n,declaration:!0,emitCJS:!0,emitESM:!0,entries:[],externals:[...je.builtinModules,...je.builtinModules.map(u=>`node:${u}`)],failOnWarn:!0,fileCache:!0,minify:j.production==="production",name:(a.name??"").split("/").pop()??"default",outDir:"dist",replace:{},rollup:{alias:{},cjsInterop:{addDefaultProperty:!1},commonjs:{ignoreTryCatch:!0,preserveSymlinks:!0,transformMixedEsModules:!1},dts:{compilerOptions:{baseUrl:l?.config.compilerOptions?.baseUrl??".",checkJs:!1,composite:!1,declaration:!0,declarationMap:!1,emitDeclarationOnly:!0,incremental:!1,moduleResolution:100,noEmit:!1,noEmitOnError:!0,preserveSymlinks:!1,skipLibCheck:!0,target:99},respectExternal:!0},dynamicVars:{errorWhenNoFilesFound:!0,include:/\bimport\s*[(/]/},esbuild:{charset:"utf8",include:/\.[jt]sx?$/,jsx:c,jsxDev:l?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:l?.config.compilerOptions?.jsxFactory,jsxFragment:l?.config.compilerOptions?.jsxFragmentFactory,jsxImportSource:l?.config.compilerOptions?.jsxImportSource,jsxSideEffects:!0,keepNames:!0,sourcesContent:!1,target:l?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:l?.config},isolatedDeclarations:{exclude:ee,ignoreErrors:!1,include:[/\.[cm]?ts$/]},json:{preferConst:!0},license:{dependenciesTemplate:x((u,m,f)=>`
71
+ `)}`),e.options.failOnWarn))throw new Error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`.")},"logErrors"),ui=w(e=>{switch(e){case"preserve":case"react-native":return"preserve";case"react":return"transform";case"react-jsx":case"react-jsxdev":return"automatic";default:return}},"resolveTsconfigJsxToJsxRuntime"),di=w((e,t,o,n,r,i,s,l,c,a)=>{const u=ui(a?.config.compilerOptions?.jsx),p=Yt(s,i,l,{alias:{},clean:!0,debug:r,declaration:!0,emitCJS:!0,emitESM:!0,entries:[],externals:[...ke.builtinModules,...ke.builtinModules.map(d=>`node:${d}`)],failOnWarn:!0,fileCache:!0,minify:n===E,name:(c.name??"").split("/").pop()??"default",outDir:"dist",replace:{},rollup:{alias:{},cjsInterop:{addDefaultProperty:!1},commonjs:{ignoreTryCatch:!0,preserveSymlinks:!0,transformMixedEsModules:!1},dts:{compilerOptions:{baseUrl:a?.config.compilerOptions?.baseUrl??".",checkJs:!1,composite:!1,declaration:!0,declarationMap:!1,emitDeclarationOnly:!0,incremental:!1,moduleResolution:100,noEmit:!1,noEmitOnError:!0,preserveSymlinks:!1,skipLibCheck:!0,target:99},respectExternal:!0},dynamicVars:{errorWhenNoFilesFound:!0,include:/\bimport\s*[(/]/},esbuild:{charset:"utf8",include:/\.[jt]sx?$/,jsx:u,jsxDev:a?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:a?.config.compilerOptions?.jsxFactory,jsxFragment:a?.config.compilerOptions?.jsxFragmentFactory,jsxImportSource:a?.config.compilerOptions?.jsxImportSource,jsxSideEffects:!0,keepNames:!0,sourcesContent:!1,target:a?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:a?.config},isolatedDeclarations:{exclude:ee,ignoreErrors:!1,include:[/\.[cm]?ts$/]},json:{preferConst:!0},license:{dependenciesTemplate:w((d,f,j)=>`
72
72
  # Licenses of bundled dependencies
73
- The published ${f} artifact additionally contains code with the following licenses:
74
- `+(u.length>0?`${u.join(", ")}
73
+ The published ${j} artifact additionally contains code with the following licenses:
74
+ `+(d.length>0?`${d.join(", ")}
75
75
 
76
76
  `:`
77
77
  `)+`# Bundled dependencies:
78
- `+m,"dependenciesTemplate"),dtsTemplate:x((u,m,f)=>`
78
+ `+f,"dependenciesTemplate"),dtsTemplate:w((d,f,j)=>`
79
79
  # Licenses of bundled types
80
- The published ${f} artifact additionally contains code with the following licenses:
81
- `+(u.length>0?`${u.join(", ")}
80
+ The published ${j} artifact additionally contains code with the following licenses:
81
+ `+(d.length>0?`${d.join(", ")}
82
82
 
83
83
  `:`
84
84
  `)+`# Bundled types:
85
- `+m,"dtsTemplate")},patchTypes:{},polyfillNode:{},preserveDynamicImports:!0,raw:{exclude:ee,include:["**/*.data","**/*.txt",/\.(md|txt|css|htm|html)$/]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,preferBuiltins:!1},shim:{exclude:[/node_modules/],include:[/\.(js|cjs|mjs|tsx|mts|cts)$/]},sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:l?.config.compilerOptions?.esModuleInterop===!1,include:/\.[jt]sx?$/,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:j.production===S,...l?.config.compilerOptions?.jsx&&["react","react-jsx","react-jsxdev"].includes(l.config.compilerOptions.jsx)?{jsxFragmentPragma:l.config.compilerOptions.jsxFragmentFactory,jsxImportSource:l.config.compilerOptions.jsxImportSource,jsxPragma:l.config.compilerOptions.jsxFactory,jsxRuntime:c,transforms:["typescript","jsx",...l.config.compilerOptions.esModuleInterop?["imports"]:[]]}:{transforms:["typescript",...l?.config.compilerOptions?.esModuleInterop?["imports"]:[]]}},swc:{include:/\.[jt]sx?$/,inlineSourcesContent:!1,inputSourceMap:!1,isModule:!0,jsc:{experimental:{keepImportAttributes:!0},externalHelpers:!1,keepClassNames:!0,loose:!0,parser:{decorators:l?.config.compilerOptions?.experimentalDecorators,syntax:l?"typescript":"ecmascript",[l?"tsx":"jsx"]:!0},target:l?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:l?.config.compilerOptions?.emitDecoratorMetadata,legacyDecorator:l?.config.compilerOptions?.experimentalDecorators,react:{development:j.production!==S,pragma:l?.config.compilerOptions?.jsxFactory,pragmaFrag:l?.config.compilerOptions?.jsxFragmentFactory,runtime:c,throwIfNamespace:!0},treatConstEnumAsEnum:l?.config.compilerOptions?.preserveConstEnums,useDefineForClassFields:l?.config.compilerOptions?.useDefineForClassFields}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"},transform:{decoratorVersion:"2022-03"}},treeshake:{moduleSideEffects:qr(t,a),preset:"recommended"},watch:{chokidar:{ignoreInitial:!0,ignorePermissionErrors:!0},clearScreen:!0,exclude:ee}},rootDir:t,sourceDir:"src",sourcemap:!1,stub:o==="jit",stubOptions:{jiti:{alias:{},esmResolve:!0,interopDefault:!0}},transformerName:void 0});if(!p.transformerName){const u=new Map([...Object.entries(a.dependencies??{}),...Object.entries(a.devDependencies??{})]);let m="0.0.0";if(u.has("esbuild"))p.transformerName="esbuild",m=u.get("esbuild");else if(u.has("@swc/core"))p.transformerName="swc",m=u.get("@swc/core");else if(u.has("sucrase"))p.transformerName="sucrase",m=u.get("sucrase");else throw new Error("Unknown transformer, check your transformer options or install one of the supported transformers: esbuild, swc, sucrase");e.info("Using "+h("rollup ")+Xt),e.info({message:"Using "+h(p.transformerName)+" "+m,prefix:"transformer"})}return p.rollup.resolve&&p.rollup.resolve.preferBuiltins===!0&&(p.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true")),p.declaration&&(a.dependencies?.typescript||a.devDependencies?.typescript)&&!l?.config.compilerOptions?.isolatedModules&&e.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig.
85
+ `+f,"dtsTemplate")},patchTypes:{},polyfillNode:{},preserveDynamicImports:!0,raw:{exclude:ee,include:[/\.(md|txt|css|htm|html|data)$/]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,preferBuiltins:!1},shim:{exclude:[/node_modules/],include:[/\.(js|cjs|mjs|tsx|mts|cts)$/]},sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:a?.config.compilerOptions?.esModuleInterop===!1,include:/\.[jt]sx?$/,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:n===E,...a?.config.compilerOptions?.jsx&&["react","react-jsx","react-jsxdev"].includes(a.config.compilerOptions.jsx)?{jsxFragmentPragma:a.config.compilerOptions.jsxFragmentFactory,jsxImportSource:a.config.compilerOptions.jsxImportSource,jsxPragma:a.config.compilerOptions.jsxFactory,jsxRuntime:u,transforms:["typescript","jsx",...a.config.compilerOptions.esModuleInterop?["imports"]:[]]}:{transforms:["typescript",...a?.config.compilerOptions?.esModuleInterop?["imports"]:[]]}},swc:{include:/\.[jt]sx?$/,inlineSourcesContent:!1,inputSourceMap:!1,isModule:!0,jsc:{experimental:{keepImportAttributes:!0},externalHelpers:!1,keepClassNames:!0,loose:!0,parser:{decorators:a?.config.compilerOptions?.experimentalDecorators,syntax:a?"typescript":"ecmascript",[a?"tsx":"jsx"]:!0},target:a?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:a?.config.compilerOptions?.emitDecoratorMetadata,legacyDecorator:a?.config.compilerOptions?.experimentalDecorators,react:{development:n!==E,pragma:a?.config.compilerOptions?.jsxFactory,pragmaFrag:a?.config.compilerOptions?.jsxFragmentFactory,runtime:u,throwIfNamespace:!0},treatConstEnumAsEnum:a?.config.compilerOptions?.preserveConstEnums,useDefineForClassFields:a?.config.compilerOptions?.useDefineForClassFields}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"},transform:{decoratorVersion:"2022-03"}},treeshake:{moduleSideEffects:Kr(t,c),preset:"recommended"},watch:{chokidar:{ignoreInitial:!0,ignorePermissionErrors:!0},clearScreen:!0,exclude:ee}},rootDir:t,sourceDir:"src",sourcemap:!1,stub:o==="jit",stubOptions:{jiti:{alias:{},esmResolve:!0,interopDefault:!0}},transformerName:void 0});if(!p.transformerName){const d=new Map([...Object.entries(c.dependencies??{}),...Object.entries(c.devDependencies??{})]);let f="0.0.0";if(d.has("esbuild"))p.transformerName="esbuild",f=d.get("esbuild");else if(d.has("@swc/core"))p.transformerName="swc",f=d.get("@swc/core");else if(d.has("sucrase"))p.transformerName="sucrase",f=d.get("sucrase");else throw new Error("Unknown transformer, check your transformer options or install one of the supported transformers: esbuild, swc, sucrase");e.info("Using "+v("rollup ")+Xt),e.info({message:"Using "+v(p.transformerName)+" "+f,prefix:"transformer"})}return p.rollup.resolve&&p.rollup.resolve.preferBuiltins===!0&&(p.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true")),p.declaration&&(c.dependencies?.typescript||c.devDependencies?.typescript)&&!a?.config.compilerOptions?.isolatedModules&&e.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig.
86
86
  Because none of the third-party transpiler, packem uses under the hood is type-aware, some techniques or features often used in TypeScript are not properly checked and can cause mis-compilation or even runtime errors.
87
- To mitigate this, you should set the isolatedModules option to true in tsconfig and let your IDE warn you when such incompatible constructs are used.`),a.dependencies&&p.externals.push(...Object.keys(a.dependencies)),a.peerDependencies&&p.externals.push(...Object.keys(a.peerDependencies)),a.optionalDependencies&&p.externals.push(...Object.keys(a.optionalDependencies)),Te(p.alias),p.rollup.alias&&p.rollup.alias.entries&&Te(p.rollup.alias.entries),p},"generateOptions"),di=x(e=>e.replace(/\.(?:js|mjs|cjs|ts|mts|cts|json|jsx|tsx)$/,""),"removeExtension"),mi=x(async(e,t)=>{e.options.entries=e.options.entries.map(o=>typeof o=="string"?{input:o}:o);for await(const o of e.options.entries){if(typeof o.name!="string"){let n=Ve(o.input)?D(t,o.input):pe(o.input);n.startsWith("./")&&(n=n.slice(2)),o.name=di(n.replace(/^src\//,""))}if(!o.input)throw new Error(`Missing entry input: ${Et(o)}`);if(o.input=g(e.options.rootDir,o.input),!k(o.input)){const n=new Set(await Ft(de(o.input)));let r=!1;for(const i of A)if(n.has(G(o.input)+i)){r=!0;break}if(!r)throw new Vt("Your configured entry: "+h(o.input)+" does not exist.")}o.outDir=g(e.options.rootDir,o.outDir??e.options.outDir)}},"prepareEntries"),fi=x((e,t,o)=>{const n=x(i=>D(t.options.rootDir,g(t.options.outDir,i)),"rPath");let r=!1;for(const i of t.buildEntries.filter(s=>!s.chunk)){let s=i.bytes??0;for(const l of i.chunks??[])s+=t.buildEntries.find(c=>c.path===l)?.bytes??0;let a=` ${N(n(i.path))} (${["total size: "+h(M(s)),i.type!=="asset"&&i.bytes&&"chunk size: "+h(M(i.bytes))].filter(Boolean).join(", ")})`;if(a+=i.exports?.length?`
88
- exports: `+R(i.exports.join(", ")):"",i.chunks?.length&&(a+=`
89
- ${i.chunks.map(l=>{const c=t.buildEntries.find(p=>p.path===l)??{};return R(" └─ "+n(l)+N(c.bytes?" ("+M(c?.bytes)+")":""))}).join(`
90
- `)}`),i.modules&&i.modules.length>0){const l=i.modules.filter(c=>c.id.includes("node_modules")).sort((c,p)=>(p.bytes||0)-(c.bytes||0)).map(c=>R(" 📦 "+n(c.id)+N(c.bytes?" ("+M(c.bytes)+")":""))).join(`
91
- `);a+=l.length>0?`
87
+ To mitigate this, you should set the isolatedModules option to true in tsconfig and let your IDE warn you when such incompatible constructs are used.`),c.dependencies&&p.externals.push(...Object.keys(c.dependencies)),c.peerDependencies&&p.externals.push(...Object.keys(c.peerDependencies)),c.optionalDependencies&&p.externals.push(...Object.keys(c.optionalDependencies)),Ae(p.alias),p.rollup.alias&&p.rollup.alias.entries&&Ae(p.rollup.alias.entries),p},"generateOptions"),mi=w(e=>e.replace(/\.(?:js|mjs|cjs|ts|mts|cts|json|jsx|tsx)$/,""),"removeExtension"),fi=w(async(e,t)=>{e.options.entries=e.options.entries.map(n=>typeof n=="string"?{input:n}:n);const o=[];for await(const n of e.options.entries){if(typeof n.name!="string"){let r=He(n.input)?S(t,n.input):pe(n.input);r.startsWith("./")&&(r=r.slice(2)),n.name=mi(r.replace(/^src\//,"")),n.fileAlias&&o.push({...n,name:n.name+"."+n.environment})}if(!n.input)throw new Error(`Missing entry input: ${he(n)}`);if(n.input=g(e.options.rootDir,n.input),!b(n.input)){const r=new Set(await Ft(de(n.input)));let i=!1;for(const s of A)if(r.has(G(n.input)+s)){i=!0;break}if(!i)throw new Vt("Your configured entry: "+v(n.input)+" does not exist.")}n.outDir=g(e.options.rootDir,n.outDir??e.options.outDir)}e.options.entries.push(...o)},"prepareEntries"),gi=w((e,t,o)=>{const n=w(i=>S(t.options.rootDir,g(t.options.outDir,i)),"rPath");let r=!1;for(const i of t.buildEntries.filter(s=>!s.chunk)){let s=i.bytes??0;for(const c of i.chunks??[])s+=t.buildEntries.find(a=>a.path===c)?.bytes??0;let l=` ${N(n(i.path))} (${["total size: "+v(M(s)),i.type!=="asset"&&i.bytes&&"chunk size: "+v(M(i.bytes))].filter(Boolean).join(", ")})`;if(l+=i.exports?.length?`
88
+ exports: `+R(i.exports.join(", ")):"",i.chunks?.length&&(l+=`
89
+ ${i.chunks.map(c=>{const a=t.buildEntries.find(u=>u.path===c)??{};return R(" └─ "+n(c)+N(a.bytes?" ("+M(a?.bytes)+")":""))}).join(`
90
+ `)}`),i.modules&&i.modules.length>0){const c=i.modules.filter(a=>a.id.includes("node_modules")).sort((a,u)=>(u.bytes||0)-(a.bytes||0)).map(a=>R(" 📦 "+n(a.id)+N(a.bytes?" ("+M(a.bytes)+")":""))).join(`
91
+ `);l+=c.length>0?`
92
92
  inlined modules:
93
- `+l:""}if(t.options.declaration&&i.type==="entry"){let l=i.path.replace(/\.js$/,".d.ts"),c="commonjs";i.path.endsWith(".cjs")?l=i.path.replace(/\.cjs$/,".d.cts"):i.path.endsWith(".mjs")&&(c="module",l=i.path.replace(/\.mjs$/,".d.mts"));const p=t.buildEntries.find(u=>u.path.endsWith(l));if(p){let u;(t.options.declaration===!0||t.options.declaration==="compatible")&&!l.includes(".d.ts")&&(l=l.replace(c==="commonjs"?".d.c":".d.m",".d."),u=t.buildEntries.find(m=>m.path.endsWith(l))),a+=u&&c===o.type?`
93
+ `+c:""}if(t.options.declaration&&i.type==="entry"){let c=i.path.replace(/\.js$/,".d.ts"),a="commonjs";i.path.endsWith(".cjs")?c=i.path.replace(/\.cjs$/,".d.cts"):i.path.endsWith(".mjs")&&(a="module",c=i.path.replace(/\.mjs$/,".d.mts"));const u=t.buildEntries.find(p=>p.path.endsWith(c));if(u){let p;(t.options.declaration===!0||t.options.declaration==="compatible")&&!c.includes(".d.ts")&&(c=c.replace(a==="commonjs"?".d.c":".d.m",".d."),p=t.buildEntries.find(d=>d.path.endsWith(c))),l+=p&&a===o.type?`
94
94
  types:
95
- `+[p,u].map(m=>R(" └─ ")+N(n(m.path))+" (total size: "+h(M(m.bytes??0))+")").join(`
95
+ `+[u,p].map(d=>R(" └─ ")+N(n(d.path))+" (total size: "+v(M(d.bytes??0))+")").join(`
96
96
  `):`
97
- types: `+N(n(p.path))+" (total size: "+h(M(p.bytes??0))+")"}}r=!0,a+=`
97
+ types: `+N(n(u.path))+" (total size: "+v(M(u.bytes??0))+")"}}r=!0,l+=`
98
98
 
99
- `,e.raw(i.chunk?R(a):a)}return r&&e.raw("Σ Total dist size (byte size):",h(M(t.buildEntries.reduce((i,s)=>i+(s.bytes??0),0))),`
100
- `),r},"showSizeInformation"),gi=x(async(e,t,o,n,r,i,s,a)=>{const l=nn(i.preset??r.preset??"auto",t),c=ui(e,t,o,n,r,i,l,s,a);Lt(y(c.rootDir,c.outDir));const p={buildEntries:[],dependencyGraphMap:new Map,hooks:Kt(),logger:e,mode:o,options:c,pkg:s,tsconfig:a,usedImports:new Set,warnings:new Set};if(l.hooks&&p.hooks.addHooks(l.hooks),r.hooks&&p.hooks.addHooks(r.hooks),i.hooks&&p.hooks.addHooks(i.hooks),await p.hooks.callHook("build:prepare",p),!p.options.emitESM&&!p.options.emitCJS)throw new Error("Both emitESM and emitCJS are disabled. At least one of them must be enabled.");p.options.emitESM===void 0&&p.logger.info("Emitting ESM bundles, is disabled."),p.options.emitCJS===void 0&&p.logger.info("Emitting CJS bundles, is disabled.");const u=s.dependencies?.typescript!==void 0||s.devDependencies?.typescript!==void 0;if(p.options.declaration&&a===void 0&&u)throw new Error(" Cannot build declaration files without a tsconfig.json");return u||(p.options.declaration=!1),p.options.declaration?p.logger.info("Using typescript version: "+h(s.devDependencies?.typescript??s.dependencies?.typescript??"unknown")):p.logger.info("Generation of declaration files is disabled."),p},"createContext"),hi=x(async e=>{const t=[];if(e.options.clean)for(const o of new Set(e.options.entries.map(n=>n.outDir).filter(Boolean).sort()))o===e.options.rootDir||o===e.options.sourceDir||e.options.rootDir.startsWith(o.endsWith("/")?o:`${o}/`)||t.some(n=>o.startsWith(n))||(t.push(o),e.logger.info(`Cleaning dist directory: \`./${D(e.options.rootDir,o)}\``),await ze(o))},"cleanDistributionDirectories"),yi=x(async(e,t,o)=>{await e.hooks.callHook("build:before",e),e.options.minify&&e.logger.info("Minification is enabled, the output will be minified");const n=Kr(e.options.entries,"environment","runtime"),r=[];for(const[s,a]of Object.entries(n))for(const[l,c]of Object.entries(a)){e.logger.info("Preparing build for "+h(s)+" environment"+(l?" with "+h(l)+" runtime":"")),e.options.rollup.replace?(e.options.rollup.replace.values={...e.options.rollup.replace.values,production:s},l==="edge-light"&&(e.options.rollup.replace.values.EdgeRuntime="edge-runtime")):e.logger.warn("'replace' plugin is disabled. You should enable it to replace 'process.env.*' environments.");const p=[],u=[],m=[];for(const f of c)f.cjs&&f.esm?p.push(f):f.cjs?m.push(f):f.esm&&u.push(f);if(p.length>0){const f={...e,options:{...e.options,emitCJS:!0,emitESM:!0,entries:p}};r.push(re(f,o));const b=f.options.entries.filter(w=>w.declaration);e.options.declaration&&b.length>0&&r.push(ie({...f,options:{...f.options,entries:b}},o))}if(u.length>0){const f={...e,options:{...e.options,emitCJS:!1,emitESM:!0,entries:u}};r.push(re(f,o));const b=f.options.entries.filter(w=>w.declaration);e.options.declaration&&b.length>0&&r.push(ie({...f,options:{...f.options,entries:b}},o))}if(m.length>0){const f={...e,options:{...e.options,emitCJS:!0,emitESM:!1,entries:m}};r.push(re(f,o));const b=f.options.entries.filter(w=>w.declaration);e.options.declaration&&b.length>0&&r.push(ie({...f,options:{...f.options,entries:b}},o))}}await Promise.all(r),e.logger.success(Jt(e.options.name?"Build succeeded for "+e.options.name:"Build succeeded"));for await(const s of zt(y(e.options.rootDir,e.options.outDir))){let a=e.buildEntries.find(l=>y(e.options.rootDir,e.options.outDir,l.path)===s.path);if(a||(a={chunk:!0,path:s.path},e.buildEntries.push(a)),!a.bytes){const l=await We(g(e.options.rootDir,e.options.outDir,s.path));a.bytes=l.size}}const i=fi(e.logger,e,t);ni(e),li(t,e),await e.hooks.callHook("build:done",e),St(e,i)},"build"),vi=x(async(e,t,o,n={})=>{const{configPath:r,debug:i,tsconfigPath:s,...a}=n;o.wrapAll(),e=g(Ct(),e),o.debug("Root directory:",e);const l=y(e,"package.json");if(!k(l))throw new Error("package.json not found at "+l);const c=Ue(l);o.debug("Using package.json found at",l);let p;if(s){const u=y(e,s);if(!await Ut(u))throw new Error("tsconfig.json not found at "+u);p={config:qt(u),path:u},o.info("Using tsconfig settings at",u)}else if(c.dependencies?.typescript||c.devDependencies?.typescript)try{p=await Yt(e),o.debug("Using tsconfig settings found at",p.path)}catch{o.info("No tsconfig.json or jsconfig.json found.")}try{const u=r??"./packem.config.ts";if(!/\.(?:js|mjs|cjs|ts)$/.test(u))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts extensions are allowed.");const m=Qe(u,e);o.debug("Using packem config found at",y(e,u));const f=Date.now(),b=x(()=>Ht(Math.floor(Date.now()-f)),"getDuration"),w=I(JSON.stringify({version:c.version,...c.dependencies,...c.devDependencies,...c.peerDependencies,...c.peerDependenciesMeta,browser:c.browser,eNode:c.engines?.node,exports:c.exports,main:c.main,module:c.module,type:c.type,types:c.types})),O=new Ur(e,w,o);O.cachePath&&!k(y(O.cachePath,w))&&k(O.cachePath)&&(o.info("Clearing file cache because the cache key has changed."),await ze(O.cachePath));const v=await gi(o,e,t,i??!1,a,m,c,p);if(O.isEnabled=v.options.fileCache,await mi(v,e),v.logger.info(h((t==="watch"?"Watching":t==="jit"?"Stubbing":"Building")+" "+v.options.name)),v.logger.debug(`${N("Root dir:")} ${v.options.rootDir}
99
+ `,e.raw(i.chunk?R(l):l)}return r&&e.raw("Σ Total dist size (byte size):",v(M(t.buildEntries.reduce((i,s)=>i+(s.bytes??0),0))),`
100
+ `),r},"showSizeInformation"),hi=w(async(e,t,o,n,r,i,s,l,c)=>{const a=an(s.preset??i.preset??"auto",t),u=di(e,t,o,n,r,i,s,a,l,c);Lt(h(u.rootDir,u.outDir));const p={buildEntries:[],dependencyGraphMap:new Map,environment:n,hooks:Gt(),logger:e,mode:o,options:u,pkg:l,tsconfig:c,usedImports:new Set,warnings:new Set};if(a.hooks&&p.hooks.addHooks(a.hooks),i.hooks&&p.hooks.addHooks(i.hooks),s.hooks&&p.hooks.addHooks(s.hooks),await p.hooks.callHook("build:prepare",p),!p.options.emitESM&&!p.options.emitCJS)throw new Error("Both emitESM and emitCJS are disabled. At least one of them must be enabled.");p.options.emitESM===void 0&&p.logger.info("Emitting ESM bundles, is disabled."),p.options.emitCJS===void 0&&p.logger.info("Emitting CJS bundles, is disabled.");const d=l.dependencies?.typescript!==void 0||l.devDependencies?.typescript!==void 0;if(p.options.declaration&&c===void 0&&d)throw new Error(" Cannot build declaration files without a tsconfig.json");return d||(p.options.declaration=!1),p.options.declaration?p.logger.info("Using typescript version: "+v(l.devDependencies?.typescript??l.dependencies?.typescript??"unknown")):p.logger.info("Generation of declaration files is disabled."),p},"createContext"),yi=w(async e=>{const t=[];if(e.options.clean)for(const o of new Set(e.options.entries.map(n=>n.outDir).filter(Boolean).sort()))o===e.options.rootDir||o===e.options.sourceDir||e.options.rootDir.startsWith(o.endsWith("/")?o:`${o}/`)||t.some(n=>o.startsWith(n))||(t.push(o),e.logger.info(`Cleaning dist directory: \`./${S(e.options.rootDir,o)}\``),await Ue(o))},"cleanDistributionDirectories"),vi=w((e,t)=>{const o=Xr(e.options.entries,"environment","runtime"),n=[];for(const[r,i]of Object.entries(o))for(const[s,l]of Object.entries(i)){e.logger.info("Preparing build for "+(r==="undefined"?"":v(r)+" environment"+(s?" with ":""))+(s?v(s)+" runtime":"")),e.options.rollup.replace?(e.options.rollup.replace.values={...e.options.rollup.replace.values,[["process","env","NODE_ENV"].join(".")]:JSON.stringify(r)},s==="edge-light"&&(e.options.rollup.replace.values.EdgeRuntime=JSON.stringify("edge-runtime"))):e.logger.warn("'replace' plugin is disabled. You should enable it to replace 'process.env.*' environments.");const c=[],a=[],u=[];for(const p of l)p.cjs&&p.esm?c.push(p):p.cjs?u.push(p):p.esm&&a.push(p);if(c.length>0){const p={...e,options:{...e.options,emitCJS:!0,emitESM:!0,entries:c,minify:r!=="development"&&e.options.minify}};n.push(re(p,t));const d=p.options.entries.filter(f=>f.declaration);e.options.declaration&&d.length>0&&n.push(ie({...p,options:{...p.options,entries:d}},t))}if(a.length>0){const p={...e,options:{...e.options,emitCJS:!1,emitESM:!0,entries:a,minify:r!=="development"&&e.options.minify}};n.push(re(p,t));const d=p.options.entries.filter(f=>f.declaration);e.options.declaration&&d.length>0&&n.push(ie({...p,options:{...p.options,entries:d}},t))}if(u.length>0){const p={...e,options:{...e.options,emitCJS:!0,emitESM:!1,entries:u,minify:r!=="development"&&e.options.minify}};n.push(re(p,t));const d=p.options.entries.filter(f=>f.declaration);e.options.declaration&&d.length>0&&n.push(ie({...p,options:{...p.options,entries:d}},t))}}return n},"prepareRollupConfig"),bi=w(async(e,t,o)=>{await e.hooks.callHook("build:before",e),e.options.minify&&e.logger.info("Minification is enabled, the output will be minified"),await Promise.all(vi(e,o)),e.logger.success(Jt(e.options.name?"Build succeeded for "+e.options.name:"Build succeeded"));for await(const r of zt(h(e.options.rootDir,e.options.outDir))){let i=e.buildEntries.find(s=>h(e.options.rootDir,e.options.outDir,s.path)===r.path);if(i||(i={chunk:!0,path:r.path},e.buildEntries.push(i)),!i.bytes){const s=await Le(g(e.options.rootDir,e.options.outDir,r.path));i.bytes=s.size}}const n=gi(e.logger,e,t);ri(e),ci(t,e),await e.hooks.callHook("build:done",e),St(e,n)},"build"),$i=w(async(e,t,o,n,r={})=>{const{configPath:i,debug:s,tsconfigPath:l,...c}=r;n.wrapAll(),e=g(Ct(),e),n.debug("Root directory:",e);const a=h(e,"package.json");if(!b(a))throw new Error("package.json not found at "+a);const u=Ve(a);n.debug("Using package.json found at",a);let p;if(l){const d=h(e,l);if(!await Ut(d))throw new Error("tsconfig.json not found at "+d);p={config:qt(d),path:d},n.info("Using tsconfig settings at",d)}else if(u.dependencies?.typescript||u.devDependencies?.typescript)try{p=await Kt(e),n.debug("Using tsconfig settings found at",p.path)}catch{n.info("No tsconfig.json or jsconfig.json found.")}try{let d=i??"";if(!d){const C=["packem.config.js","packem.config.mjs","packem.config.cjs","packem.config.ts","packem.config.cts","packem.config.mts"];for(const O of C)if(b(h(e,O))){d="./"+O;break}}if(!/\.(?:js|mjs|cjs|ts|cts|mts)$/.test(d))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts, .cts and .mts extensions are allowed.");let f=et(d,e);typeof f=="function"&&(f=f(o,t)),n.debug("Using packem config found at",h(e,d));const j=Date.now(),D=w(()=>Ht(Math.floor(Date.now()-j)),"getDuration"),L=I(JSON.stringify({version:u.version,...u.dependencies,...u.devDependencies,...u.peerDependencies,...u.peerDependenciesMeta,browser:u.browser,eNode:u.engines?.node,exports:u.exports,main:u.main,module:u.module,type:u.type,types:u.types})),k=new Vr(e,L,n);k.cachePath&&!b(h(k.cachePath,L))&&b(k.cachePath)&&(n.info("Clearing file cache because the cache key has changed."),await Ue(k.cachePath));const y=await hi(n,e,t,o,s??!1,c,f,u,p);if(k.isEnabled=y.options.fileCache,await fi(y,e),y.logger.info(v((t==="watch"?"Watching":t==="jit"?"Stubbing":"Building")+" "+y.options.name)),y.logger.debug(`${N("Root dir:")} ${y.options.rootDir}
101
101
  ${N("Entries:")}
102
- ${v.options.entries.map(C=>` ${Et(C)}`).join(`
103
- `)}`),await hi(v),v.options.stub){await Bo(v),await v.hooks.callHook("build:done",v);return}if(t==="watch"){if(v.options.rollup.watch===!1)throw new Error("Rollup watch is disabled. You should check your packem.config file.");await Jr(v,O),St(v,!1);return}await yi(v,c,O),o.raw(`
104
- ⚡️ Build run in `+b()),o.restoreAll()}catch(u){throw o.raw(`
105
- `),kt(u),u}},"createBundler");var bi=Object.defineProperty,se=d((e,t)=>bi(e,"name",{value:t,configurable:!0}),"a");const wi=se(e=>{e.addCommand({description:"Demonstrate options required",execute:se(async({logger:t,options:o})=>{let n="build";o.watch?n="watch":o.jit&&(n="jit");const r={};if(j.production&&[B,S].includes(j.production)&&(r.NODE_ENV=j.production),o.env)for(const i of o.env){if(i.key==="production"&&r.production)throw new Error("production was already set, this can't be overridden.");r[i.key]=i.value}r.production===void 0&&(o.production?r.NODE_ENV=S:o.development?r.NODE_ENV=B:r.NODE_ENV=S,j.NODE_ENV=r.production);try{await vi(o.dir,n,t,{cjsInterop:o.cjsInterop,configPath:o.config??void 0,debug:o.debug,minify:o.minify===void 0?j.production===S:o.minify,replace:{...r},rollup:{esbuild:{target:o.target},license:{path:o.license},metafile:o.metafile,...o.analyze?{visualizer:{}}:{visualizer:!1}},sourcemap:o.sourcemap,tsconfigPath:o.tsconfig??void 0})}catch(i){t.error(i),Mt(1)}},"execute"),name:"build",options:[{defaultValue:".",description:"The directory to build",name:"dir",type:String},{alias:"t",description:"Environments to support. `target` in tsconfig.json is automatically added. Defaults to the current Node.js version.",name:"target"},{description:"Use a custom config file",name:"config",type:String},{description:"Path to the tsconfig.json file",name:"tsconfig",type:String},{description:"Minify the output",name:"minify",type:Boolean},{description:"Generate sourcemaps (experimental)",name:"sourcemap",type:Boolean},{conflicts:"jit",description:"Watch for changes",name:"watch",type:Boolean},{conflicts:"watch",description:"Stub the package for JIT compilation",name:"jit",type:Boolean},{description:"Compile-time environment variables (eg. --env.NODE_ENV=production)",multiple:!0,name:"env",type:se(t=>{const[o,n]=t.split("=");return{key:o,value:n}},"type")},{defaultValue:!1,description:"Generate meta file (experimental)",name:"metafile",type:Boolean},{description:"Path to the license file",name:"license",type:String},{conflicts:"watch",description:"Visualize and analyze the bundle",name:"analyze",type:Boolean},{description:"CJS interop mode, can export default and named export, (experimental).",name:"cjsInterop",type:Boolean},{conflicts:"development",description:"Run code in production environment",name:"production",type:Boolean},{conflicts:"production",description:"Run code in development environment",name:"development",type:Boolean}]})},"createBuildCommand");var $i=Object.defineProperty,Je=d((e,t)=>$i(e,"name",{value:t,configurable:!0}),"m");const ji=Je(e=>{e.addCommand({description:"Initialize packem configuration",execute:Je(async({logger:t,options:o})=>{if(vo("Welcome to packem setup"),k(y(o.dir,"packem.config.ts"))){t.info("Packem project already initialized, you can use `packem build` to build your project");return}if(bo(o.transformer)){wo("Operation cancelled");return}const n=y(o.dir,"package.json");if(!k(n))throw new Error("No package.json found in the directory");const r=Ue(n),i=[];if(r.dependencies&&i.push(...Object.keys(r.dependencies)),r.devDependencies&&i.push(...Object.keys(r.devDependencies)),o.transformer===void 0&&(o.transformer=await $o({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"}]}),!i.includes(o.transformer)&&await jo({message:"Do you want to install "+o.transformer+"?"}))){const s=Q();s.start("Installing "+o.transformer),await yo(o.transformer==="swc"?"@swc/core":o.transformer,{cwd:o.dir,dev:!0,silent:!0}),s.stop("")}if(i.includes("typescript")||r.type==="module"){const s=`import { defineConfig } from "@visulima/packem/config";
102
+ ${y.options.entries.map(C=>` ${he(C)}`).join(`
103
+ `)}`),await yi(y),y.options.stub){await Bo(y),await y.hooks.callHook("build:done",y);return}if(t==="watch"){if(y.options.rollup.watch===!1)throw new Error("Rollup watch is disabled. You should check your packem.config file.");await Lr(y,k),St(y,!1);return}await bi(y,u,k),n.raw(`
104
+ ⚡️ Build run in `+D()),n.restoreAll()}catch(d){throw n.raw(`
105
+ `),xt(d),d}},"createBundler");var wi=Object.defineProperty,se=m((e,t)=>wi(e,"name",{value:t,configurable:!0}),"a");const ji=se(e=>{e.addCommand({description:"Demonstrate options required",execute:se(async({logger:t,options:o})=>{let n="build";o.watch?n="watch":o.jit&&(n="jit");const r={};let i;if(q.NODE_ENV&&[F,E].includes(q.NODE_ENV)&&(i=q.NODE_ENV),o.env)for(const s of o.env)if(s.key==="NODE_ENV"){if(i)throw new Error("NODE_ENV was already set, this can't be overridden.");i=s.value}else r["process.env."+s.key]=JSON.stringify(s.value);i===void 0&&(o.production?i=E:o.development&&(i=F));try{await $i(o.dir,n,i,t,{cjsInterop:o.cjsInterop,configPath:o.config??void 0,debug:o.debug,minify:o.minify===void 0?i===E:o.minify,replace:{...r},rollup:{esbuild:{target:o.target},license:{path:o.license},metafile:o.metafile,...o.analyze?{visualizer:{}}:{visualizer:!1}},sourcemap:o.sourcemap,tsconfigPath:o.tsconfig??void 0})}catch(s){t.error(s),Mt(1)}},"execute"),name:"build",options:[{defaultValue:".",description:"The directory to build",name:"dir",type:String},{alias:"t",description:"Environments to support. `target` in tsconfig.json is automatically added. Defaults to the current Node.js version.",name:"target"},{description:"Use a custom config file",name:"config",type:String},{description:"Path to the tsconfig.json file",name:"tsconfig",type:String},{description:"Minify the output",name:"minify",type:Boolean},{description:"Generate sourcemaps (experimental)",name:"sourcemap",type:Boolean},{conflicts:"jit",description:"Watch for changes",name:"watch",type:Boolean},{conflicts:"watch",description:"Stub the package for JIT compilation",name:"jit",type:Boolean},{description:"Compile-time environment variables (eg. --env.NODE_ENV=production)",multiple:!0,name:"env",type:se(t=>{const[o,n]=t.split("=");return{key:o,value:n}},"type")},{defaultValue:!1,description:"Generate meta file (experimental)",name:"metafile",type:Boolean},{description:"Path to the license file",name:"license",type:String},{conflicts:"watch",description:"Visualize and analyze the bundle",name:"analyze",type:Boolean},{description:"CJS interop mode, can export default and named export, (experimental).",name:"cjsInterop",type:Boolean},{conflicts:"development",description:"Run code in production environment",name:"production",type:Boolean},{conflicts:"production",description:"Run code in development environment",name:"development",type:Boolean}]})},"createBuildCommand");var ki=Object.defineProperty,Be=m((e,t)=>ki(e,"name",{value:t,configurable:!0}),"m");const xi=Be(e=>{e.addCommand({description:"Initialize packem configuration",execute:Be(async({logger:t,options:o})=>{if(vo("Welcome to packem setup"),b(h(o.dir,"packem.config.ts"))){t.info("Packem project already initialized, you can use `packem build` to build your project");return}if(bo(o.transformer)){$o("Operation cancelled");return}const n=h(o.dir,"package.json");if(!b(n))throw new Error("No package.json found in the directory");const r=Ve(n),i=[];if(r.dependencies&&i.push(...Object.keys(r.dependencies)),r.devDependencies&&i.push(...Object.keys(r.devDependencies)),o.transformer===void 0&&(o.transformer=await wo({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"}]}),!i.includes(o.transformer)&&await jo({message:"Do you want to install "+o.transformer+"?"}))){const s=Q();s.start("Installing "+o.transformer),await yo(o.transformer==="swc"?"@swc/core":o.transformer,{cwd:o.dir,dev:!0,silent:!0}),s.stop("")}if(i.includes("typescript")||r.type==="module"){const s=`import { defineConfig } from "@visulima/packem/config";
106
106
  import transformer from "@visulima/packem/transformer/${o.transformer}";
107
107
 
108
108
  export default defineConfig({
109
109
  transformer
110
110
  });
111
- `,a=Q(),l=r.type==="module"?"mjs":"ts";a.start("Creating packem.config."+l),q(y(o.dir,"packem.config."+l),s),a.stop("Created packem.config."+l)}else{const s=`const { defineConfig } = require("@visulima/packem/config");
111
+ `,l=Q(),c=r.type==="module"?"mjs":"ts";l.start("Creating packem.config."+c),K(h(o.dir,"packem.config."+c),s),l.stop("Created packem.config."+c)}else{const s=`const { defineConfig } = require("@visulima/packem/config");
112
112
  const transformer = require("@visulima/packem/transformer/${o.transformer}");
113
113
 
114
114
  module.exports = defineConfig({
115
115
  transformer
116
116
  });
117
- `,a=Q();a.start("Creating packem.config.js"),q(y(o.dir,"packem.config.js"),s),a.stop("Created packem.config.js")}ko("Now you can run `packem build` to build your project")},"execute"),name:"init",options:[{defaultValue:".",description:"The directory to initialize",name:"dir",type:String},{description:"Choose a transformer to use for packem",name:"transformer",type:String}]})},"createInitCommand"),we=new Nt("packem",{logger:{reporters:[new _t({error:{hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0}})],scope:"packem"},packageName:xo,packageVersion:Eo});ji(we);wi(we);we.run({shouldExitProcess:!1});
117
+ `,l=Q();l.start("Creating packem.config.js"),K(h(o.dir,"packem.config.js"),s),l.stop("Created packem.config.js")}ko("Now you can run `packem build` to build your project")},"execute"),name:"init",options:[{defaultValue:".",description:"The directory to initialize",name:"dir",type:String},{description:"Choose a transformer to use for packem",name:"transformer",type:String}]})},"createInitCommand"),we=new Nt("packem",{logger:{reporters:[new _t({error:{hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0}})],scope:"packem"},packageName:xo,packageVersion:Eo});xi(we);ji(we);we.run({shouldExitProcess:!1});