@visulima/packem 1.0.0-alpha.37 → 1.0.0-alpha.39

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 (33) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cli.cjs +8 -0
  3. package/dist/cli.mjs +2 -2
  4. package/dist/config.cjs +1 -0
  5. package/dist/config.d.cts +27 -0
  6. package/dist/config.d.mts +3 -3
  7. package/dist/config.d.ts +3 -3
  8. package/dist/create-bundler.cjs +101 -0
  9. package/dist/create-bundler.d.cts +29 -0
  10. package/dist/create-bundler.d.mts +2 -2
  11. package/dist/create-bundler.d.ts +2 -2
  12. package/dist/create-bundler.mjs +61 -53
  13. package/dist/rollup/plugins/esbuild/index.cjs +1 -0
  14. package/dist/rollup/plugins/esbuild/index.d.cts +9 -0
  15. package/dist/rollup/plugins/sucrase/index.cjs +1 -0
  16. package/dist/rollup/plugins/sucrase/index.d.cts +8 -0
  17. package/dist/rollup/plugins/swc/index.cjs +1 -0
  18. package/dist/rollup/plugins/swc/index.d.cts +7 -0
  19. package/dist/rollup/plugins/swc/index.d.mts +1 -1
  20. package/dist/rollup/plugins/swc/index.d.ts +1 -1
  21. package/dist/shared/{packem.C3jV3VSZ.d.mts → packem.BBXO6_87.d.mts} +3 -4
  22. package/dist/shared/packem.CEXB7aOL.cjs +1 -0
  23. package/dist/shared/packem.ClcPYkxx.d.cts +184 -0
  24. package/dist/shared/packem.D09xRBAa.d.cts +25 -0
  25. package/dist/shared/{packem.DyKwVld7.d.ts → packem.DtAA_1Hu.d.ts} +3 -4
  26. package/dist/shared/packem.DvWhOdt5.d.cts +10 -0
  27. package/dist/shared/packem.NVRVuzg1.cjs +1 -0
  28. package/dist/shared/{packem.C44tLE3n.d.ts → packem.aYVbzCkK.d.cts} +1 -1
  29. package/dist/shared/{packem.C44tLE3n.d.mts → packem.aYVbzCkK.d.mts} +1 -1
  30. package/dist/shared/packem.aYVbzCkK.d.ts +1919 -0
  31. package/package.json +48 -18
  32. package/dist/cli.d.mts +0 -2
  33. package/dist/cli.d.ts +0 -2
@@ -1,4 +1,4 @@
1
- var gt=Object.defineProperty;var m=(e,t)=>gt(e,"name",{value:t,configurable:!0});import{chmod as ht,stat as Ee,readdir as yt}from"node:fs/promises";import pe from"node:module";import{env as A,exit as F,versions as vt,cwd as bt}from"node:process";import{cyan as v,bold as O,gray as C,grey as $t,green as jt}from"@visulima/colorize";import{readFile as Q,writeFile as B,collectSync as wt,readFileSync as De,writeFileSync as Se,writeJsonSync as kt,isAccessibleSync as W,ensureDirSync as xt,emptyDir as Ne,walk as Ot,isAccessible as Et}from"@visulima/fs";import{NotFoundError as Dt}from"@visulima/fs/error";import{formatBytes as _,duration as St}from"@visulima/humanizer";import{findCacheDirectorySync as Nt,readTsConfig as Pt,findTSConfig as _t}from"@visulima/package";import{parsePackageJson as Mt}from"@visulima/package/package-json";import{createPail as Ct}from"@visulima/pail";import{MessageFormatterProcessor as Ft,ErrorProcessor as It,CallerProcessor as Rt}from"@visulima/pail/processor";import{resolve as f,join as y,normalize as Z,extname as ee,relative as S,dirname as te,basename as U,isAbsolute as Pe,toNamespacedPath as ue}from"@visulima/path";import{defu as Tt}from"defu";import{createHooks as At}from"hookable";import{a as R,R as Wt,E as de}from"./shared/packem.HRXF255z.mjs";import{pathToFileURL as Jt,fileURLToPath as Bt}from"node:url";import{resolvePath as Lt,resolveModuleExportNames as zt,findStaticImports as _e}from"mlly";import D from"magic-string";import Me from"jiti";import{existsSync as oe}from"node:fs";import{rollup as Ce,watch as me}from"rollup";import Fe from"@rollup/plugin-alias";import Ut from"@rollup/plugin-commonjs";import Ht from"@rollup/plugin-dynamic-import-vars";import{nodeResolve as Ie}from"@rollup/plugin-node-resolve";import Re from"@rollup/plugin-replace";import{wasm as qt}from"@rollup/plugin-wasm";import Vt from"rollup-plugin-polyfill-node";import{visualizer as Gt}from"rollup-plugin-visualizer";import{minVersion as Te}from"semver";import{glob as Xt}from"glob";import Kt from"glob-parent";import Yt from"@rollup/plugin-json";import{createFilter as ne,normalizePath as fe}from"@rollup/pluginutils";import Qt from"rollup-plugin-license";import{createHash as Zt}from"node:crypto";import{parse as eo}from"@babel/parser";import{distance as to}from"fastest-levenshtein";
1
+ var yt=Object.defineProperty;var m=(e,t)=>yt(e,"name",{value:t,configurable:!0});import{chmod as vt,stat as Ne,readdir as bt}from"node:fs/promises";import de from"node:module";import{env as x,exit as I,versions as $t,cwd as jt}from"node:process";import{cyan as y,bold as O,gray as F,yellow as wt,grey as kt,green as xt}from"@visulima/colorize";import{readFile as Q,writeFile as J,collectSync as Et,readFileSync as Se,writeFileSync as _e,writeJsonSync as Ot,isAccessibleSync as W,ensureDirSync as Dt,emptyDir as Pe,walk as Nt,isAccessible as St}from"@visulima/fs";import{NotFoundError as _t}from"@visulima/fs/error";import{formatBytes as M,duration as Pt}from"@visulima/humanizer";import{findCacheDirectorySync as Mt,readTsConfig as Ct,findTSConfig as Ft}from"@visulima/package";import{parsePackageJson as It}from"@visulima/package/package-json";import{createPail as Rt}from"@visulima/pail";import{MessageFormatterProcessor as Tt,ErrorProcessor as At,CallerProcessor as Wt}from"@visulima/pail/processor";import{resolve as g,join as v,normalize as Z,extname as ee,relative as S,dirname as te,basename as U,isAbsolute as Me,toNamespacedPath as me}from"@visulima/path";import{defu as Bt}from"defu";import{createHooks as Jt}from"hookable";import{rollup as Ce,watch as fe,VERSION as Lt}from"rollup";import{a as T,R as zt,E as ge}from"./shared/packem.HRXF255z.mjs";import{pathToFileURL as Ut,fileURLToPath as Ht}from"node:url";import{resolvePath as Vt,resolveModuleExportNames as qt,findStaticImports as Fe}from"mlly";import N from"magic-string";import Ie from"jiti";import{existsSync as oe}from"node:fs";import Re from"@rollup/plugin-alias";import Yt from"@rollup/plugin-commonjs";import Gt from"@rollup/plugin-dynamic-import-vars";import{nodeResolve as Te}from"@rollup/plugin-node-resolve";import Ae from"@rollup/plugin-replace";import{wasm as Kt}from"@rollup/plugin-wasm";import Xt from"rollup-plugin-polyfill-node";import{visualizer as Qt}from"rollup-plugin-visualizer";import{minVersion as We}from"semver";import{glob as Zt}from"glob";import eo from"glob-parent";import to from"@rollup/plugin-json";import{createFilter as re,normalizePath as he}from"@rollup/pluginutils";import oo from"rollup-plugin-license";import{createHash as ro}from"node:crypto";import{parse as no}from"@babel/parser";import{distance as so}from"fastest-levenshtein";
2
2
  // -- pack CommonJS Shims --
3
3
  import __cjs_url__ from "node:url";
4
4
  import __cjs_path__ from "node:path";
@@ -6,39 +6,39 @@ import __cjs_mod__ from "node:module";
6
6
  const __filename = __cjs_url__.fileURLToPath(import.meta.url);
7
7
  const __dirname = __cjs_path__.dirname(__filename);
8
8
  const require = __cjs_mod__.createRequire(import.meta.url);
9
- var oo=Object.defineProperty,H=m((e,t)=>oo(e,"name",{value:t,configurable:!0}),"i$b");const re=/^#![^\n]*/,X=H(async e=>{await ht(e,493).catch(()=>{})},"makeExecutable"),no=H((e,t=`#!/usr/bin/env node
10
- `)=>({name:"packem:shebang",renderChunk:{handler(o,r,n){if(!r.isEntry||!r.facadeModuleId||o.startsWith("#")&&o[1]==="!")return null;if(e.includes(r.name)){const s=new D(o);return s.prepend(t),{code:s.toString(),map:n.sourcemap?s.generateMap({hires:!0}):void 0}}return null},order:"post"},async writeBundle(o,r){for(const[n,s]of Object.entries(r))if(s.type==="chunk"&&re.test(s.code)&&o.dir){const a=f(o.dir,n);await X(a)}}}),"shebangPlugin"),ro=H(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(re,"")}}),"removeShebangPlugin"),so=H((e,t=`
11
- `)=>{const o=re.exec(e);return o?o+t:""},"getShebang");var io=Object.defineProperty,ao=m((e,t)=>io(e,"name",{value:t,configurable:!0}),"p$3");const se=ao((e,t)=>{let o={};if(e.pkg.name&&(o[e.pkg.name]=e.options.rootDir),e.pkg.imports){const{imports:r}=e.pkg;for(const n in r){if(n.startsWith("#"))continue;const s=r[n];typeof s=="string"&&(o[n]=y(e.rootDir,s))}}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(r=>[r.find,r.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 lo=Object.defineProperty,co=m((e,t)=>lo(e,"name",{value:t,configurable:!0}),"o$3");const po=co((e,t)=>{const o=Me(t,{esmResolve:!0,interopDefault:!0});try{return o.resolve(e)}catch(r){if(r.code!=="MODULE_NOT_FOUND")throw new Error(`Error trying import ${e} from ${t}`,{cause:r});return e}},"tryResolve");var uo=Object.defineProperty,mo=m((e,t)=>uo(e,"name",{value:t,configurable:!0}),"r$8");const J=mo((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var fo=Object.defineProperty,go=m((e,t)=>fo(e,"name",{value:t,configurable:!0}),"u$7");const ho=go(async e=>{const t=await Lt("jiti",{url:import.meta.url}),o=JSON.stringify({...e.options.stubOptions.jiti,alias:{...se(e,"jit"),...e.options.stubOptions.jiti.alias}},null,2);for(const r of e.options.entries){const n=f(e.options.rootDir,e.options.outDir,r.name),s=Z(po(r.input,e.options.rootDir)||r.input),a=s.slice(0,Math.max(0,s.length-ee(s).length)),i=await Q(s),c=so(i);e.options.emitCJS&&await B(`${n}.cjs`,c+[`const jiti = require(${JSON.stringify(t)})`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(a)})} */`,`module.exports = _jiti(${JSON.stringify(s)})`].join(`
12
- `));let l=[];try{l=await zt(s,{extensions:R})}catch(d){J(e,`Cannot analyze ${s} for exports:${d}`);return}const p=l.includes("default")||l.length===0;await B(`${n}.mjs`,c+[`import jiti from ${JSON.stringify(Jt(t).href)};`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(s)})} */`,`const _module = await _jiti.import(${JSON.stringify(s)});`,p?`
13
- export default _module;`:"",...l.filter(d=>d!=="default").map(d=>`export const ${d} = _module.${d};`)].join(`
14
- `)),await B(`${n}.d.cts`,[`export * from ${JSON.stringify(a)};`,p?`export { default } from ${JSON.stringify(a)};`:""].join(`
15
- `)),await B(`${n}.d.mts`,[`export * from ${JSON.stringify(s)};`,p?`export { default } from ${JSON.stringify(s)};`:""].join(`
16
- `)),c&&(await X(`${n}.cjs`),await X(`${n}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var yo=Object.defineProperty,vo=m((e,t)=>yo(e,"name",{value:t,configurable:!0}),"r$7");const Ae=vo((e,t)=>Me(t,{esmResolve:!0,interopDefault:!0})(e),"tryRequire");var bo=Object.defineProperty,We=m((e,t)=>bo(e,"name",{value:t,configurable:!0}),"t$4");const ie=We(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),Je=We((e,t,o,r)=>{if(o){const a=ie(o);if(a)return a}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return r==="commonjs"?"cjs":"esm";const[n,...s]=t;return Je(n,s,o,r)},"inferExportType");var $o=Object.defineProperty,jo=m((e,t)=>$o(e,"name",{value:t,configurable:!0}),"o$2");const ae=jo((e,t,o,r=[])=>{if(!e)return[];if(typeof e=="string"){const n=ie(e),s=t==="module"?"esm":"cjs";if(n&&n!==s)throw new Error(`Exported file "${e}" has an extension that does not match the package.json type "${t}".`);return[{file:e,key:"exports",type:n??s}]}return Object.entries(e).filter(([n])=>!n.endsWith(".json")).flatMap(([n,s])=>n==="types"&&o===!1?[]:typeof s=="string"?{file:s,key:"exports",subKey:n,type:Je(n,r,s,t)}:ae(s,t,o,[...r,n]))},"extractExportFilenames");var wo=Object.defineProperty,Be=m((e,t)=>wo(e,"name",{value:t,configurable:!0}),"d$4");const ge=Be((e,t,o,r,n,s,a)=>{const i=e.find(c=>c.input===t)??e[e.push({input:t})-1];if(o&&(i.outDir=r),n.file.includes(".min.")&&(i.minify=!0),n.isExecutable)i.executable=!0,i.declaration=!1,i.cjs=s.type==="commonjs",i.esm=s.type==="module";else{/\.d\.[mc]?ts$/.test(n.file)&&!a&&(i.declaration=a),n.type==="cjs"&&(i.cjs=!0),n.type==="esm"&&(i.esm=!0);for(const c of Wt)if(n.file.includes(c)){i.runtime=c;break}n.key==="exports"&&n.subKey==="production"?i.environment="production":n.key==="exports"&&n.subKey==="development"&&(i.environment="development")}},"createOrUpdateEntry"),he=/(?:\.d\.[mc]?ts|\.\w+)$/,ko=Be((e,t,o)=>{const r=[];t.sort((i,c)=>i.split("/").length-c.split("/").length);const n=ae(e.exports,e.type??"commonjs",o.options.declaration);if(e.bin){const i=typeof e.bin=="string"?[e.bin]:Object.values(e.bin);for(const c of i)n.push({file:c,isExecutable:!0,key:"bin"})}e.main&&n.push({file:e.main,key:"main",type:ie(e.main)??(e.type==="module"?"esm":"cjs")}),e.module&&n.push({file:e.module,key:"module",type:"esm"}),o.options.declaration!==!1&&(e.types||e.typings)&&n.push({file:e.types??e.typings,key:"types"});const s=e.type==="module";for(const i of n.filter(c=>!c.type)){const c=i.file.endsWith(".js");s&&c||i.file.endsWith(".mjs")?i.type="esm":(!s&&c||i.file.endsWith(".cjs"))&&(i.type="cjs")}const a=[];for(const i of n){const c=i.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),l=c.endsWith("/");if(l&&["./","/"].includes(c))continue;const p=c.replace(new RegExp("(./)?"+o.options.outDir),o.options.sourceDir);if(i.file.includes("/*")&&i.key==="exports"){o.logger.warn("Private subfolders are not supported, if you need this feature please open an issue on GitHub.");const g=[],j=new RegExp("(?<=/|$)"+p.replace("*","(.*)")+(l?"":"\\.\\w+"));for(const x of t)j.test(x)&&g.push(x.replace(he,""));if(g.length===0){r.push(`Could not find entrypoints for \`${i.file}\``);continue}for(const x of g)ge(a,x,l,c,i,e,o.options.declaration);continue}const d=new RegExp("(?<=/|$)"+p+(l?"":"\\.\\w+")),u=t.find(g=>d.test(g))?.replace(he,"");if(!u){oe(f(o.options.rootDir,i.file))||r.push(`Could not find entrypoint for \`${i.file}\``);continue}ge(a,u,l,c,i,e,o.options.declaration)}return{entries:a,warnings:r}},"inferEntries");var xo=Object.defineProperty,Oo=m((e,t)=>xo(e,"name",{value:t,configurable:!0}),"t$3");const Eo=Oo((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 Do=Object.defineProperty,So=m((e,t)=>Do(e,"name",{value:t,configurable:!0}),"n$8");const No={hooks:{"build:prepare":So(function(e){if(e.options.entries.length>0)return;const t=y(e.options.rootDir,"src");if(!oe(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=wt(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 r={...e.pkg};r.publishConfig&&(r=Eo(r,e.options.declaration));const n=ko(r,o,e);for(const s of n.warnings)J(e,s);if(e.options.entries.push(...n.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(s=>O(s.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),C([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(s=>`[${s}]`).join(" ")))},"build:prepare")}};var Po=Object.defineProperty,_o=m((e,t)=>Po(e,"name",{value:t,configurable:!0}),"t$2");const Mo=_o((e,t)=>(e==="auto"?e=No:typeof e=="string"&&(e=Ae(e,t)),typeof e=="function"&&(e=e()),e),"resolvePreset");var Co=Object.defineProperty,Fo=m((e,t)=>Co(e,"name",{value:t,configurable:!0}),"a$a");const K=Fo((e,t)=>e.some(o=>o instanceof RegExp?o.test(t):o===t),"arrayIncludes");var Io=Object.defineProperty,Ro=m((e,t)=>Io(e,"name",{value:t,configurable:!0}),"a$9");const q=Ro(e=>e===void 0?[]:Array.isArray(e)?e:[e],"arrayify");var To=Object.defineProperty,Ao=m((e,t)=>To(e,"name",{value:t,configurable:!0}),"e$1");const Y=Ao((e="")=>{const t=e.split("/");return t[0][0]==="@"?`${t[0]}/${t[1]}`:t[0]},"getPackageName");var Wo=Object.defineProperty,Le=m((e,t)=>Wo(e,"name",{value:t,configurable:!0}),"s$a");const Jo=Le((e,t,o)=>{const r=o??new Map;return(...n)=>{const s=t?typeof t=="function"?t(...n):t:JSON.stringify({args:n}),a=r.get(s);if(a!==void 0)return a;const i=e(...n);return r.set(s,i),i}},"memoize"),Bo=Le(e=>{const t=new Map;return o=>Jo(e,o,t)},"memoizeByKey");var Lo=Object.defineProperty,zo=m((e,t)=>Lo(e,"name",{value:t,configurable:!0}),"m$6");const ze=zo(({addDefaultProperty:e=!1,logger:t,type:o})=>({name:"packem:cjs-interop",renderChunk(r,n,s){if(n.type!=="chunk"||!n.isEntry)return null;if(s.format==="cjs"&&s.exports==="auto"){const a=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(r);if(a===null||a.length<3)return null;const i=new D(r);i.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),i.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&i.append(`
17
- module.exports.default = `+a[2]+";");let c=i.toString();return c=c.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+n.fileName+".",prefix:"plugin:cjs-interop"}),{code:c,map:i.generateMap({hires:!0})}}if(s.format==="es"&&/\.d\.(?:ts|cts)$/.test(n.fileName)){if(o!=="commonjs"&&n.fileName.endsWith(".d.ts"))return null;const a=/export\s\{\s(.*)\s\}/i.exec(r);if(a===null||a.length<2)return null;const i=a[1].split(", "),c=[];let l="";for(const d of i)if(!d.includes("type"))if(d.includes("as")){const[u,g]=d.split(" as ");if(g==="default"&&(l=u,!e))continue;c.push(g+": typeof "+u+";")}else c.push(d+": typeof "+d+";");const p=new D(r);return p.replace(" "+l+" as default,",""),p.append(`
9
+ var io=Object.defineProperty,H=m((e,t)=>io(e,"name",{value:t,configurable:!0}),"i$c");const ne=/^#![^\n]*/,G=H(async e=>{await vt(e,493).catch(()=>{})},"makeExecutable"),ao=H((e,t=`#!/usr/bin/env node
10
+ `)=>({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 s=new N(o);return s.prepend(t),{code:s.toString(),map:r.sourcemap?s.generateMap({hires:!0}):void 0}}return null},order:"post"},async writeBundle(o,n){for(const[r,s]of Object.entries(n))if(s.type==="chunk"&&ne.test(s.code)&&o.dir){const l=g(o.dir,r);await G(l)}}}),"shebangPlugin"),lo=H(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(ne,"")}}),"removeShebangPlugin"),co=H((e,t=`
11
+ `)=>{const o=ne.exec(e);return o?o+t:""},"getShebang");var po=Object.defineProperty,uo=m((e,t)=>po(e,"name",{value:t,configurable:!0}),"p$3");const se=uo((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 s=n[r];typeof s=="string"&&(o[r]=v(e.rootDir,s))}}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,fo=m((e,t)=>mo(e,"name",{value:t,configurable:!0}),"o$4");const go=fo((e,t)=>{const o=Ie(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 ho=Object.defineProperty,yo=m((e,t)=>ho(e,"name",{value:t,configurable:!0}),"r$9");const B=yo((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var vo=Object.defineProperty,bo=m((e,t)=>vo(e,"name",{value:t,configurable:!0}),"u$8");const $o=bo(async e=>{const t=await Vt("jiti",{url:import.meta.url}),o=JSON.stringify({...e.options.stubOptions.jiti,alias:{...se(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),s=Z(go(n.input,e.options.rootDir)||n.input),l=s.slice(0,Math.max(0,s.length-ee(s).length)),a=await Q(s),i=co(a);e.options.emitCJS&&await J(`${r}.cjs`,i+[`const jiti = require(${JSON.stringify(t)})`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(l)})} */`,`module.exports = _jiti(${JSON.stringify(s)})`].join(`
12
+ `));let c=[];try{c=await qt(s,{extensions:T})}catch(u){B(e,`Cannot analyze ${s} for exports:${u}`);return}const p=c.includes("default")||c.length===0;await J(`${r}.mjs`,i+[`import jiti from ${JSON.stringify(Ut(t).href)};`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(s)})} */`,`const _module = await _jiti.import(${JSON.stringify(s)});`,p?`
13
+ export default _module;`:"",...c.filter(u=>u!=="default").map(u=>`export const ${u} = _module.${u};`)].join(`
14
+ `)),await J(`${r}.d.cts`,[`export * from ${JSON.stringify(l)};`,p?`export { default } from ${JSON.stringify(l)};`:""].join(`
15
+ `)),await J(`${r}.d.mts`,[`export * from ${JSON.stringify(s)};`,p?`export { default } from ${JSON.stringify(s)};`:""].join(`
16
+ `)),i&&(await G(`${r}.cjs`),await G(`${r}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var jo=Object.defineProperty,wo=m((e,t)=>jo(e,"name",{value:t,configurable:!0}),"r$8");const Be=wo((e,t)=>Ie(t,{esmResolve:!0,interopDefault:!0})(e),"tryRequire");var ko=Object.defineProperty,Je=m((e,t)=>ko(e,"name",{value:t,configurable:!0}),"t$4");const ie=Je(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),Le=Je((e,t,o,n)=>{if(o){const l=ie(o);if(l)return l}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return n==="commonjs"?"cjs":"esm";const[r,...s]=t;return Le(r,s,o,n)},"inferExportType");var xo=Object.defineProperty,Eo=m((e,t)=>xo(e,"name",{value:t,configurable:!0}),"o$3");const ae=Eo((e,t,o,n=[])=>{if(!e)return[];if(typeof e=="string"){const r=ie(e),s=t==="module"?"esm":"cjs";if(r&&r!==s)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??s}]}return Object.entries(e).filter(([r])=>!r.endsWith(".json")).flatMap(([r,s])=>r==="types"&&o===!1?[]:typeof s=="string"?{file:s,key:"exports",subKey:r,type:Le(r,n,s,t)}:ae(s,t,o,[...n,r]))},"extractExportFilenames");var Oo=Object.defineProperty,le=m((e,t)=>Oo(e,"name",{value:t,configurable:!0}),"c$6");const Do=le(e=>{if(e.key==="exports"&&e.subKey==="production")return"production";if(e.key==="exports"&&e.subKey==="development")return"development";if(x.NODE_ENV){if(!x.NODE_ENV.includes("production")&&!x.NODE_ENV.includes("development"))throw new Error(`Invalid NODE_ENV value: ${x.NODE_ENV}, must be either "production" or "development".`);return x.NODE_ENV}return"production"},"getEnvironment"),ye=le((e,t,o,n,r,s,l)=>{const a=e.find(i=>i.input===t)??e[e.push({input:t})-1];if(o&&(a.outDir=n),r.isExecutable)a.executable=!0,a.declaration=!1,a.cjs=s.type==="commonjs",a.esm=s.type==="module";else{/\.d\.[mc]?ts$/.test(r.file)&&l!==!1&&(a.declaration=l),r.type==="cjs"&&(a.cjs=!0),r.type==="esm"&&(a.esm=!0);for(const i of zt)if(r.file.includes(i+".")){a.runtime=i;break}}a.runtime===void 0&&(a.runtime="node"),a.environment=Do(r)},"createOrUpdateEntry"),ve=/(?:\.d\.[mc]?ts|\.\w+)$/,No=le((e,t,o)=>{const n=[];t.sort((a,i)=>a.split("/").length-i.split("/").length);const r=ae(e.exports,e.type??"commonjs",o.options.declaration);if(e.bin){const a=typeof e.bin=="string"?[e.bin]:Object.values(e.bin);for(const i of a)r.push({file:i,isExecutable:!0,key:"bin"})}e.main&&r.push({file:e.main,key:"main",type:ie(e.main)??(e.type==="module"?"esm":"cjs")}),e.module&&r.push({file:e.module,key:"module",type:"esm"}),o.options.declaration!==!1&&(e.types||e.typings)&&r.push({file:e.types??e.typings,key:"types"});const s=e.type==="module";for(const a of r.filter(i=>!i.type)){const i=a.file.endsWith(".js");s&&i||a.file.endsWith(".mjs")?a.type="esm":(!s&&i||a.file.endsWith(".cjs"))&&(a.type="cjs")}const l=[];for(const a of r){const i=a.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),c=i.endsWith("/");if(c&&["./","/"].includes(i))continue;const p=i.replace(new RegExp("(./)?"+o.options.outDir),o.options.sourceDir);if(a.file.includes("/*")&&a.key==="exports"){o.logger.warn("Private subfolders are not supported, if you need this feature please open an issue on GitHub.");const f=[],j=new RegExp("(?<=/|$)"+p.replace("*","(.*)")+(c?"":"\\.\\w+"));for(const E of t)j.test(E)&&f.push(E.replace(ve,""));if(f.length===0){n.push(`Could not find entrypoints for \`${a.file}\``);continue}for(const E of f)ye(l,E,c,i,a,e,o.options.declaration);continue}const u=new RegExp("(?<=/|$)"+p+(c?"":"\\.\\w+")),d=t.find(f=>u.test(f))?.replace(ve,"");if(!d){oe(g(o.options.rootDir,a.file))||n.push(`Could not find entrypoint for \`${a.file}\``);continue}ye(l,d,c,i,a,e,o.options.declaration)}return{entries:l,warnings:n}},"inferEntries");var So=Object.defineProperty,_o=m((e,t)=>So(e,"name",{value:t,configurable:!0}),"t$3");const Po=_o((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 Mo=Object.defineProperty,Co=m((e,t)=>Mo(e,"name",{value:t,configurable:!0}),"n$8");const Fo={hooks:{"build:prepare":Co(function(e){if(e.options.entries.length>0)return;const t=v(e.options.rootDir,"src");if(!oe(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=Et(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=Po(n,e.options.declaration));const r=No(n,o,e);for(const s of r.warnings)B(e,s);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:",y(e.options.entries.map(s=>O(s.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),F([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(s=>`[${s}]`).join(" ")))},"build:prepare")}};var Io=Object.defineProperty,Ro=m((e,t)=>Io(e,"name",{value:t,configurable:!0}),"t$2");const To=Ro((e,t)=>(e==="auto"?e=Fo:typeof e=="string"&&(e=Be(e,t)),typeof e=="function"&&(e=e()),e),"resolvePreset");var Ao=Object.defineProperty,Wo=m((e,t)=>Ao(e,"name",{value:t,configurable:!0}),"a$b");const K=Wo((e,t)=>e.some(o=>o instanceof RegExp?o.test(t):o===t),"arrayIncludes");var Bo=Object.defineProperty,Jo=m((e,t)=>Bo(e,"name",{value:t,configurable:!0}),"a$a");const V=Jo(e=>e===void 0?[]:Array.isArray(e)?e:[e],"arrayify");var Lo=Object.defineProperty,zo=m((e,t)=>Lo(e,"name",{value:t,configurable:!0}),"a$9");const X=zo((e="")=>{const t=e.split("/");return t[0].startsWith("@")?t[0]+"/"+t[1]:t[0]},"getPackageName");var Uo=Object.defineProperty,ze=m((e,t)=>Uo(e,"name",{value:t,configurable:!0}),"s$a");const Ho=ze((e,t,o)=>{const n=o??new Map;return(...r)=>{const s=t?typeof t=="function"?t(...r):t:JSON.stringify({args:r}),l=n.get(s);if(l!==void 0)return l;const a=e(...r);return n.set(s,a),a}},"memoize"),Vo=ze(e=>{const t=new Map;return o=>Ho(e,o,t)},"memoizeByKey");var qo=Object.defineProperty,Yo=m((e,t)=>qo(e,"name",{value:t,configurable:!0}),"m$5");const Ue=Yo(({addDefaultProperty:e=!1,logger:t,type:o})=>({name:"packem:cjs-interop",renderChunk(n,r,s){if(r.type!=="chunk"||!r.isEntry)return null;if(s.format==="cjs"&&s.exports==="auto"){const l=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(n);if(l===null||l.length<3)return null;const a=new N(n);a.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),a.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&a.append(`
17
+ module.exports.default = `+l[2]+";");let i=a.toString();return i=i.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+r.fileName+".",prefix:"plugin:cjs-interop"}),{code:i,map:a.generateMap({hires:!0})}}if(s.format==="es"&&/\.d\.(?:ts|cts)$/.test(r.fileName)){if(o!=="commonjs"&&r.fileName.endsWith(".d.ts"))return null;const l=/export\s\{\s(.*)\s\}/i.exec(n);if(l===null||l.length<2)return null;const a=l[1].split(", "),i=[];let c="";for(const u of a)if(!u.includes("type"))if(u.includes("as")){const[d,f]=u.split(" as ");if(f==="default"&&(c=d,!e))continue;i.push(f+": typeof "+d+";")}else i.push(u+": typeof "+u+";");const p=new N(n);return p.replace(" "+c+" as default,",""),p.append(`
18
18
 
19
19
  declare const defaultExport: {
20
- `+(c.length>0?" ":"")+c.join(`
20
+ `+(i.length>0?" ":"")+i.join(`
21
21
  `)+`
22
- } & typeof `+l+`;
22
+ } & typeof `+c+`;
23
23
 
24
- export default defaultExport;`),t.debug({message:"Applied CommonJS interop to entry chunk "+n.fileName+".",prefix:"plugin:cjs-interop"}),{code:p.toString(),map:p.generateMap({hires:!0})}}return null}}),"cjsInterop");var Uo=Object.defineProperty,Ho=m((e,t)=>Uo(e,"name",{value:t,configurable:!0}),"f$6");const qo=Ho((e,t)=>{const o=new Map,r={copyOnce:!0,exactFileNames:!0,flatten:!1,...e};let{targets:n}=r;return Array.isArray(n)?n=n.map(s=>{if(typeof s=="string")return{src:s};if(typeof s=="object"&&"src"in s)return s}).filter(Boolean):typeof n=="string"&&(n=[{src:n}]),{async buildStart(){const s=await Promise.all(n.flatMap(a=>Array.isArray(a.src)?a.src.map(i=>({...a,src:i})):a).map(async a=>await Xt(a.src,{ignore:a.exclude}).then(i=>({dest:a.dest??"",parent:Kt(a.src),src:i}))));for(const a of s)for(const i of a.src){let c;o.has(i)?c=o.get(i):(c={copied:[],dest:[],timestamp:0},o.set(i,c));const l=r.flatten?Z(a.dest):y(a.dest,S(a.parent,te(i)));c.dest.includes(l)||c.dest.push(l),this.addWatchFile(i)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...o].map(async([a,i])=>{let c;try{const l=await Ee(a);if(!l.isFile())return;const p=l.mtime.getTime();p>i.timestamp&&(i.timestamp=p,i.copied=[]),c=await Q(a,{buffer:!0})}catch(l){t.error({context:[l],message:`error reading file ${a}`,prefix:"plugin:copy"});return}for(const l of i.dest){if(r.copyOnce&&i.copied.includes(l))continue;const p=U(a),d=y(l,p);try{this.emitFile({[r.exactFileNames?"fileName":"name"]:d,source:c,type:"asset"}),t.debug({message:`copied ${a} → ${d}`,prefix:"plugin:copy"}),i.copied.push(l)}catch(u){t.error({context:[u],message:`error copying file ${a} → ${d}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var Vo=Object.defineProperty,Go=m((e,t)=>Vo(e,"name",{value:t,configurable:!0}),"n$4");const ye="export default ",Ue=Go(e=>{const t=Yt(e);return{...t,name:"packem:json",transform(o,r){const n=t.transform?.call(this,o,r);return n&&typeof n!="string"&&"code"in n&&n.code?.startsWith(ye)&&(n.code=n.code.replace(ye,"module.exports = ")),n}}},"JSONPlugin");class Xo{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,r,n){t&&o&&(r!=null?t[o][r]=n:t[o]=n)}remove(t,o,r){t&&o&&(r!=null?t[o].splice(r,1):delete t[o])}}class Ko extends Xo{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(r=>this.replacement=r,"replace")},this.enter=t,this.leave=o}visit(t,o,r,n){if(t){if(this.enter){const a=this.should_skip,i=this.should_remove,c=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,o,r,n),this.replacement&&(t=this.replacement,this.replace(o,r,n,t)),this.should_remove&&this.remove(o,r,n);const l=this.should_skip,p=this.should_remove;if(this.should_skip=a,this.should_remove=i,this.replacement=c,l)return t;if(p)return null}let s;for(s in t){const a=t[s];if(a&&typeof a=="object")if(Array.isArray(a)){const i=a;for(let c=0;c<i.length;c+=1){const l=i[c];ve(l)&&(this.visit(l,t,s,c)||c--)}}else ve(a)&&this.visit(a,t,s,null)}if(this.leave){const a=this.replacement,i=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,t,o,r,n),this.replacement&&(t=this.replacement,this.replace(o,r,n,t)),this.should_remove&&this.remove(o,r,n);const c=this.should_remove;if(this.replacement=a,this.should_remove=i,c)return null}}return t}}function ve(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}m(ve,"isNode");function He(e,{enter:t,leave:o}){return new Ko(t,o).visit(e,null)}m(He,"walk");var Yo=Object.defineProperty,Qo=m((e,t)=>Yo(e,"name",{value:t,configurable:!0}),"u$5");const Zo=Qo(({attributes:e,logger:t})=>{const o=ne([/\.[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(r,n){if(!o(n))return null;let s=null;try{s=this.parse(r,{allowReturnOutsideFunction:!0})}catch(c){return this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${n}" and remove the jsx attribute.`}),t.warn(c),null}let a=!1;const i=new D(r);return He(s,{enter(c){if(c.type==="CallExpression"&&c.callee.type==="Identifier"&&c.callee.name==="jsx"){const l=c.arguments.filter(p=>p.type==="ObjectExpression"&&Array.isArray(p.properties));for(const p of l)for(const d of p.properties)d.type==="Property"&&d.key.type==="Literal"&&d.value.type==="Literal"&&e.includes(d.key.value)&&(i.overwrite(d.start-2,d.end,""),a=!0)}}}),a?{code:i.toString(),map:i.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var en=Object.defineProperty,le=m((e,t)=>en(e,"name",{value:t,configurable:!0}),"p$1");const tn=le(e=>{const t=[],o=[];return e.forEach(r=>{r.startsWith("(")?t.push(r):o.push(r)}),[...o.sort(),...t.sort()]},"sortLicenses"),on=le((e,t,o)=>{const r=new RegExp(`(<!-- ${t} -->)[\\s\\S]*?(<!-- ${t} -->)`,"g");if(r.test(e))return e.replace(r,`$1
24
+ 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 Go=Object.defineProperty,Ko=m((e,t)=>Go(e,"name",{value:t,configurable:!0}),"f$7");const Xo=Ko((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(s=>{if(typeof s=="string")return{src:s};if(typeof s=="object"&&"src"in s)return s}).filter(Boolean):typeof r=="string"&&(r=[{src:r}]),{async buildStart(){const s=await Promise.all(r.flatMap(l=>Array.isArray(l.src)?l.src.map(a=>({...l,src:a})):l).map(async l=>await Zt(l.src,{ignore:l.exclude}).then(a=>({dest:l.dest??"",parent:eo(l.src),src:a}))));for(const l of s)for(const a of l.src){let i;o.has(a)?i=o.get(a):(i={copied:[],dest:[],timestamp:0},o.set(a,i));const c=n.flatten?Z(l.dest):v(l.dest,S(l.parent,te(a)));i.dest.includes(c)||i.dest.push(c),this.addWatchFile(a)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...o].map(async([l,a])=>{let i;try{const c=await Ne(l);if(!c.isFile())return;const p=c.mtime.getTime();p>a.timestamp&&(a.timestamp=p,a.copied=[]),i=await Q(l,{buffer:!0})}catch(c){t.error({context:[c],message:`error reading file ${l}`,prefix:"plugin:copy"});return}for(const c of a.dest){if(n.copyOnce&&a.copied.includes(c))continue;const p=U(l),u=v(c,p);try{this.emitFile({[n.exactFileNames?"fileName":"name"]:u,source:i,type:"asset"}),t.debug({message:`copied ${l} → ${u}`,prefix:"plugin:copy"}),a.copied.push(c)}catch(d){t.error({context:[d],message:`error copying file ${l} → ${u}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var Qo=Object.defineProperty,Zo=m((e,t)=>Qo(e,"name",{value:t,configurable:!0}),"n$4");const be="export default ",He=Zo(e=>{const t=to(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(be)&&(r.code=r.code.replace(be,"module.exports = ")),r}}},"JSONPlugin");class er{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 tr extends er{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 l=this.should_skip,a=this.should_remove,i=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=l,this.should_remove=a,this.replacement=i,c)return t;if(p)return null}let s;for(s in t){const l=t[s];if(l&&typeof l=="object")if(Array.isArray(l)){const a=l;for(let i=0;i<a.length;i+=1){const c=a[i];$e(c)&&(this.visit(c,t,s,i)||i--)}}else $e(l)&&this.visit(l,t,s,null)}if(this.leave){const l=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 i=this.should_remove;if(this.replacement=l,this.should_remove=a,i)return null}}return t}}function $e(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}m($e,"isNode");function Ve(e,{enter:t,leave:o}){return new tr(t,o).visit(e,null)}m(Ve,"walk");var or=Object.defineProperty,rr=m((e,t)=>or(e,"name",{value:t,configurable:!0}),"u$6");const nr=rr(({attributes:e,logger:t})=>{const o=re([/\.[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 s=null;try{s=this.parse(n,{allowReturnOutsideFunction:!0})}catch(i){return this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${r}" and remove the jsx attribute.`}),t.warn(i),null}let l=!1;const a=new N(n);return Ve(s,{enter(i){if(i.type==="CallExpression"&&i.callee.type==="Identifier"&&i.callee.name==="jsx"){const c=i.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,""),l=!0)}}}),l?{code:a.toString(),map:a.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var sr=Object.defineProperty,ce=m((e,t)=>sr(e,"name",{value:t,configurable:!0}),"p$1");const ir=ce(e=>{const t=[],o=[];return e.forEach(n=>{n.startsWith("(")?t.push(n):o.push(n)}),[...o.sort(),...t.sort()]},"sortLicenses"),ar=ce((e,t,o)=>{const n=new RegExp(`(<!-- ${t} -->)[\\s\\S]*?(<!-- ${t} -->)`,"g");if(n.test(e))return e.replace(n,`$1
25
25
  ${o}
26
- $2`)},"replaceContentWithin"),qe=le(({licenseFilePath:e,licenseTemplate:t,logger:o,marker:r,mode:n,packageName:s})=>Qt({thirdParty(a){const i=new Set,c=a.sort(({name:p},{name:d})=>p>d?1:d>p?-1:0).map(({author:p,contributors:d,license:u,licenseText:g,maintainers:j,name:x,repository:N})=>{let w="## "+x+`
27
- `;u&&(w+=`License: ${u}
28
- `);const h=new Set;for(const P of[p,...j,...d]){const ce=typeof P=="string"?P:P?.name;ce&&h.add(ce)}return h.size>0&&(w+=`By: ${[...h].join(", ")}
29
- `),N&&(w+=`Repository: ${typeof N=="string"?N:N.url}
30
- `),g&&(w+=`
31
- `+g.trim().replaceAll(/(\r\n|\r)/g,`
26
+ $2`)},"replaceContentWithin"),qe=ce(({licenseFilePath:e,licenseTemplate:t,logger:o,marker:n,mode:r,packageName:s})=>oo({thirdParty(l){const a=new Set,i=l.sort(({name:p},{name:u})=>p>u?1:u>p?-1:0).map(({author:p,contributors:u,license:d,licenseText:f,maintainers:j,name:E,repository:_})=>{let w="## "+E+`
27
+ `;d&&(w+=`License: ${d}
28
+ `);const h=new Set;for(const P of[p,...j,...u]){const ue=typeof P=="string"?P:P?.name;ue&&h.add(ue)}return h.size>0&&(w+=`By: ${[...h].join(", ")}
29
+ `),_&&(w+=`Repository: ${typeof _=="string"?_:_.url}
30
+ `),f&&(w+=`
31
+ `+f.trim().replaceAll(/(\r\n|\r)/g,`
32
32
  `).split(`
33
33
  `).map(P=>`> ${P}`).join(`
34
34
  `)+`
35
- `),u&&i.add(u),w}).join(`
35
+ `),d&&a.add(d),w}).join(`
36
36
  ---------------------------------------
37
37
 
38
- `);if(c===""){o.info({message:"No dependencies license information found.",prefix:"plugin:license:"+n});return}const l=t(tn(i),c,s);try{const p=De(e),d=on(p,r,l);if(!d){o.error({message:`Could not find the license marker: <!-- ${r} --> in ${e}`,prefix:"plugin:license:"+n});return}p!==d&&(Se(e,d),o.info({message:`${e} updated.`,prefix:"plugin:license:"+n}))}catch(p){o.error(p)}}}),"license");var nn=Object.defineProperty,rn=m((e,t)=>nn(e,"name",{value:t,configurable:!0}),"i$7");const sn=rn(e=>({async buildEnd(){const t=[];for(const r of this.getModuleIds()){const n=this.getModuleInfo(r);if(n!=null&&!n.isExternal)for(const s of n.importedIds)t.push({source:r,target:s})}if(Array.isArray(t)&&t.length===0)return;const o=f(e.rootDir,e.outDir,"graph.json");kt(o,t)},name:"packem:metafile"}),"metafilePlugin");var an=Object.defineProperty,ln=m((e,t)=>an(e,"name",{value:t,configurable:!0}),"r$5");const M=ln(e=>{const t=Zt("md5");return t.update(e),t.digest("hex")},"getHash");var cn=Object.defineProperty,Ve=m((e,t)=>cn(e,"name",{value:t,configurable:!0}),"m$5");const T=Ve(e=>e.handler||e,"getHandler"),k=Ve((e,t)=>({...e,async buildEnd(o){e.buildEnd&&await T(e.buildEnd).call(this,o)},async buildStart(o){e.buildStart&&await T(e.buildStart).call(this,o)},async load(o){if(!e.load)return null;const r=y("load",M(o));if(t.has(r,e.name))return await t.get(r,e.name);const n=await T(e.load).call(this,o);return t.set(r,n,e.name),n},name:`cached(${e.name})`,async resolveId(o,r,n){if(!e.resolveId)return null;const s=y("resolveId",M(o),r?M(r):"",M(JSON.stringify(n)));if(t.has(s,e.name))return await t.get(s,e.name);const a=await T(e.resolveId).call(this,o,r,n);return t.set(s,a,e.name),a},async transform(o,r){if(!e.transform)return null;const n=y("transform",M(r),M(o));if(t.has(n,e.name))return await t.get(n,e.name);const s=await T(e.transform).call(this,o,r);return t.set(n,s,e.name),s}}),"cachingPlugin");var pn=Object.defineProperty,un=m((e,t)=>pn(e,"name",{value:t,configurable:!0}),"c$4");const dn=/\.(?:m|c)?(?:j|t)sx?$/,mn=/^use \w+$/,fn=un(e=>{const t={},o={};return{name:"packem:preserve-directives",onLog(r,n){return n.code==="MODULE_LEVEL_DIRECTIVE"&&r==="warn"?!1:null},renderChunk:{handler(r,n,{sourcemap:s}){const a=n.moduleIds.map(l=>t[l]?t[l]:null).reduce((l,p)=>(p&&p.forEach(d=>{l.add(d)}),l),new Set),i=new D(r);a.size>0&&(e.debug({message:`directives for chunk "${n.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),i.prepend(`${[...a].map(l=>`'${l}';`).join(`
38
+ `);if(i===""){o.info({message:"No dependencies license information found.",prefix:"plugin:license:"+r});return}const c=t(ir(a),i,s);try{const p=Se(e),u=ar(p,n,c);if(!u){o.error({message:`Could not find the license marker: <!-- ${n} --> in ${e}`,prefix:"plugin:license:"+r});return}p!==u&&(_e(e,u),o.info({message:`${e} updated.`,prefix:"plugin:license:"+r}))}catch(p){o.error(p)}}}),"license");var lr=Object.defineProperty,cr=m((e,t)=>lr(e,"name",{value:t,configurable:!0}),"i$8");const pr=cr(e=>({async buildEnd(){const t=[];for(const n of this.getModuleIds()){const r=this.getModuleInfo(n);if(r!=null&&!r.isExternal)for(const s of r.importedIds)t.push({source:n,target:s})}if(Array.isArray(t)&&t.length===0)return;const o=g(e.rootDir,e.outDir,"graph.json");Ot(o,t)},name:"packem:metafile"}),"metafilePlugin");var ur=Object.defineProperty,dr=m((e,t)=>ur(e,"name",{value:t,configurable:!0}),"r$5");const C=dr(e=>{const t=ro("md5");return t.update(e),t.digest("hex")},"getHash");var mr=Object.defineProperty,Ye=m((e,t)=>mr(e,"name",{value:t,configurable:!0}),"m$4");const A=Ye(e=>e.handler||e,"getHandler"),k=Ye((e,t)=>({...e,async buildEnd(o){e.buildEnd&&await A(e.buildEnd).call(this,o)},async buildStart(o){e.buildStart&&await A(e.buildStart).call(this,o)},async load(o){if(!e.load)return null;const n=v("load",C(o));if(t.has(n,e.name))return await t.get(n,e.name);const r=await A(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 s=v("resolveId",C(o),n?C(n):"",C(JSON.stringify(r)));if(t.has(s,e.name))return await t.get(s,e.name);const l=await A(e.resolveId).call(this,o,n,r);return t.set(s,l,e.name),l},async transform(o,n){if(!e.transform)return null;const r=v("transform",C(n),C(o));if(t.has(r,e.name))return await t.get(r,e.name);const s=await A(e.transform).call(this,o,n);return t.set(r,s,e.name),s}}),"cachingPlugin");var fr=Object.defineProperty,gr=m((e,t)=>fr(e,"name",{value:t,configurable:!0}),"c$5");const hr=/\.(?:m|c)?(?:j|t)sx?$/,yr=/^use \w+$/,vr=gr(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:s}){const l=r.moduleIds.map(c=>t[c]?t[c]:null).reduce((c,p)=>(p&&p.forEach(u=>{c.add(u)}),c),new Set),a=new N(n);l.size>0&&(e.debug({message:`directives for chunk "${r.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),a.prepend(`${[...l].map(c=>`'${c}';`).join(`
39
39
  `)}
40
- `));let c=null;return n.facadeModuleId&&typeof o[n.facadeModuleId]=="string"&&(c=o[n.facadeModuleId]),c&&(e.debug({message:`shebang for chunk "${n.fileName}" is preserved.`,prefix:"plugin:preserve-directives"}),i.prepend(`${c}
41
- `)),a.size===0&&c===null?null:{code:i.toString(),map:s?i.generateMap({hires:!0}):null}},order:"post"},transform:{handler(r,n){const s=ee(n);if(!dn.test(s))return null;let a=!1;const i=new D(r);if(r.startsWith("#")&&r[1]==="!"){let l=0;for(let p=2,d=r.length;p<d;p++){const u=r.codePointAt(p);if(u===10||u===13||u===8232||u===8233){l=p;break}}l&&(o[n]=r.slice(0,l),i.remove(0,l+1),a=!0,e.debug({message:`shebang for module "${n}" is preserved.`,prefix:"plugin:preserve-directives"}))}let c=null;try{c=this.parse(i.toString(),{allowReturnOutsideFunction:!0})}catch(l){return this.warn({code:"PARSE_ERROR",message:`[packem:preserve-directives]: failed to parse "${n}" and extract the directives.`}),e.warn(l),null}if(c.type!=="Program")return null;for(const l of c.body.filter(Boolean)){if(l.type!=="ExpressionStatement")break;let p=null;"directive"in l?p=l.directive:l.expression.type==="Literal"&&typeof l.expression.value=="string"&&mn.test(l.expression.value)&&(p=l.expression.value),p!=="use strict"&&p&&(t[n]||=new Set,t[n].add(p),"start"in l&&typeof l.start=="number"&&"end"in l&&typeof l.end=="number"&&(i.remove(l.start,l.end),a=!0),e.debug({message:`directive "${p}" for module "${n}" is preserved.`,prefix:"plugin:preserve-directives"}))}return a?{code:i.toString(),map:i.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...t[n]??[]],shebang:o[n]??null}}}:null},order:"post"}}},"preserveDirectives");var gn=Object.defineProperty,hn=m((e,t)=>gn(e,"name",{value:t,configurable:!0}),"r$4");const yn={exclude:[],include:[/\.(md|txt|css|htm|html)$/]},vn=hn((e={})=>{e={...e,...yn};const t=ne(e.include,e.exclude);return{name:"packem:raw",transform(o,r){return t(r)?{code:`export default ${JSON.stringify(o)}`,map:null}:null}}},"rawPlugin");var bn=Object.defineProperty,$n=m((e,t)=>bn(e,"name",{value:t,configurable:!0}),"l$2");const V="\0__file_url__",Ge=$n(()=>({async load(e){if(e.startsWith(V)){const t=Bt(e.slice(V.length));return await Q(t)}},name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return`${V}${e}`}}),"resolveFileUrl");var jn=Object.defineProperty,Xe=m((e,t)=>jn(e,"name",{value:t,configurable:!0}),"i$3");const wn=/__filename|__dirname|require\(|require\.resolve\(/,Ke=`
40
+ `));let i=null;return r.facadeModuleId&&typeof o[r.facadeModuleId]=="string"&&(i=o[r.facadeModuleId]),i&&(e.debug({message:`shebang for chunk "${r.fileName}" is preserved.`,prefix:"plugin:preserve-directives"}),a.prepend(`${i}
41
+ `)),l.size===0&&i===null?null:{code:a.toString(),map:s?a.generateMap({hires:!0}):null}},order:"post"},transform:{handler(n,r){const s=ee(r);if(!hr.test(s))return null;let l=!1;const a=new N(n);if(n.startsWith("#")&&n[1]==="!"){let c=0;for(let p=2,u=n.length;p<u;p++){const d=n.codePointAt(p);if(d===10||d===13||d===8232||d===8233){c=p;break}}c&&(o[r]=n.slice(0,c),a.remove(0,c+1),l=!0,e.debug({message:`shebang for module "${r}" is preserved.`,prefix:"plugin:preserve-directives"}))}let i=null;try{i=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(i.type!=="Program")return null;for(const c of i.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"&&yr.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),l=!0),e.debug({message:`directive "${p}" for module "${r}" is preserved.`,prefix:"plugin:preserve-directives"}))}return l?{code:a.toString(),map:a.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...t[r]??[]],shebang:o[r]??null}}}:null},order:"post"}}},"preserveDirectives");var br=Object.defineProperty,$r=m((e,t)=>br(e,"name",{value:t,configurable:!0}),"r$4");const jr={exclude:[],include:[/\.(md|txt|css|htm|html)$/]},wr=$r((e={})=>{e={...e,...jr};const t=re(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 kr=Object.defineProperty,xr=m((e,t)=>kr(e,"name",{value:t,configurable:!0}),"l$3");const q="\0__file_url__",Ge=xr(()=>({async load(e){if(e.startsWith(q)){const t=Ht(e.slice(q.length));return await Q(t)}},name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return`${q}${e}`}}),"resolveFileUrl");var Er=Object.defineProperty,Ke=m((e,t)=>Er(e,"name",{value:t,configurable:!0}),"i$4");const Or=/__filename|__dirname|require\(|require\.resolve\(/,Xe=`
42
42
  // -- pack CommonJS Shims --
43
43
  import __cjs_url__ from "node:url";
44
44
  import __cjs_path__ from "node:path";
@@ -46,56 +46,64 @@ import __cjs_mod__ from "node:module";
46
46
  const __filename = __cjs_url__.fileURLToPath(import.meta.url);
47
47
  const __dirname = __cjs_path__.dirname(__filename);
48
48
  const require = __cjs_mod__.createRequire(import.meta.url);
49
- `,Ye=`
49
+ `,Qe=`
50
50
  // -- pack CommonJS Shims Node 20.11 --
51
51
  import __cjs_mod__ from "node:module";
52
52
  const __filename = import.meta.filename;
53
53
  const __dirname = import.meta.dirname;
54
54
  const require = __cjs_mod__.createRequire(import.meta.url);
55
- `,kn=Xe((e,t)=>{if(A.INTERNAL_PACKEM_BUILD!=="1"&&(e.includes(Ke)||e.includes(Ye)||!wn.test(e)))return null;const o=_e(e).pop(),r=o?o.end:0,n=new D(e);return n.appendRight(r,t),{code:n.toString(),map:n.generateMap()}},"CJSToESM"),xn=Xe(e=>({name:"packem:cjs",renderChunk(t,o,r){if(r.format==="es"){let n=Ke;if(e.engines?.node){const s=Te(e.engines.node);s&&s.major>=20&&s.minor>=11&&(n=Ye)}return kn(t,n)}return null}}),"cjsPlugin");var On=Object.defineProperty,I=m((e,t)=>On(e,"name",{value:t,configurable:!0}),"s$6");const En=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,Dn=/MIT License|MIT license|BSD license/,Sn=/\n{2,}/g,Nn=/\b(\w+)\$\d+\b/g,Pn=/[-/\\^$*+?.()|[\]{}]/g,_n=I(e=>e.replaceAll(Pn,"\\$&"),"escapeRegex"),Mn=I(e=>[...new Set(e)],"unique"),Cn=I(e=>e.replaceAll(En,t=>Dn.test(t)?"":t).replaceAll(Sn,`
55
+ `,Dr=Ke((e,t)=>{if(x.INTERNAL_PACKEM_BUILD!=="1"&&(e.includes(Xe)||e.includes(Qe)||!Or.test(e)))return null;const o=Fe(e).pop(),n=o?o.end:0,r=new N(e);return r.appendRight(n,t),{code:r.toString(),map:r.generateMap()}},"CJSToESM"),Nr=Ke(e=>({name:"packem:cjs",renderChunk(t,o,n){if(n.format==="es"){let r=Xe;if(e.engines?.node){const s=We(e.engines.node);s&&s.major>=20&&s.minor>=11&&(r=Qe)}return Dr(t,r)}return null}}),"cjsPlugin");var Sr=Object.defineProperty,R=m((e,t)=>Sr(e,"name",{value:t,configurable:!0}),"s$6");const _r=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,Pr=/MIT License|MIT license|BSD license/,Mr=/\n{2,}/g,Cr=/\b(\w+)\$\d+\b/g,Fr=/[-/\\^$*+?.()|[\]{}]/g,Ir=R(e=>e.replaceAll(Fr,"\\$&"),"escapeRegex"),Rr=R(e=>[...new Set(e)],"unique"),Tr=R(e=>e.replaceAll(_r,t=>Pr.test(t)?"":t).replaceAll(Mr,`
56
56
 
57
- `),"cleanUnnecessaryComments"),be=new Map;function Qe(e,t,{identifierReplacements:o},r){const n=_e(e);for(const a in o){const i=n.find(l=>l.specifier===a&&l.imports.includes("{"));if(!i){this.warn(`${t.fileName} does not import "${a}" for replacement`),process.exitCode=1;continue}const c=o[a];for(const l in c){i.imports.includes(l)||(this.warn(`${t.fileName} does not import "${l}" from "${a}" for replacement`),F(1));const p=c[l],d=_n(l);p.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${d},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${d}\\b`,"g"),p)}}const s=Mn(Array.from(e.matchAll(Nn),a=>a[0]));if(s.length>0){const a=s.map(c=>`
58
- - ${c}`).join(""),i=t.fileName.replace(/\.[^/.]+$/,"");be.has(i)||r.warn({message:`${t.fileName} contains confusing identifier names${a}
57
+ `),"cleanUnnecessaryComments"),je=new Map;function Ze(e,t,{identifierReplacements:o},n){const r=Fe(e);for(const l in o){const a=r.find(c=>c.specifier===l&&c.imports.includes("{"));if(!a){this.warn(`${t.fileName} does not import "${l}" for replacement`),process.exitCode=1;continue}const i=o[l];for(const c in i){a.imports.includes(c)||(this.warn(`${t.fileName} does not import "${c}" from "${l}" for replacement`),I(1));const p=i[c],u=Ir(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 s=Rr(Array.from(e.matchAll(Cr),l=>l[0]));if(s.length>0){const l=s.map(i=>`
58
+ - ${i}`).join(""),a=t.fileName.replace(/\.[^/.]+$/,"");je.has(a)||n.warn({message:`${t.fileName} contains confusing identifier names${l}
59
59
 
60
- To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),be.set(i,!0)}return e}m(Qe,"v$1");I(Qe,"replaceConfusingTypeNames");function Ze(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(Ze,"N");I(Ze,"removeInternal");function et(e,t){if(e.includes("@internal")){const o=new D(e),r=eo(e,{plugins:["typescript"],sourceType:"module"});He(r,{enter(n){Ze(o,n)&&this.skip()}}),e=o.toString(),e.includes("@internal")&&(this.warn(`${t.fileName} has unhandled @internal declarations`),F(1))}return e}m(et,"S");I(et,"stripInternalTypes");const Fn=I((e,t)=>({name:"packem:patch-types",renderChunk(o,r){return o=Qe.call(this,o,r,e,t),o=et.call(this,o,r),o=Cn(o),o},resolveId(o){return o.startsWith("types/")?{external:!0,id:"../../"+(o.endsWith(".js")?o:o+".js")}:null}}),"patchTypescriptTypes");var In=Object.defineProperty,tt=m((e,t)=>In(e,"name",{value:t,configurable:!0}),"u$3");const ot=tt((e,t=!0)=>{if(!e)return null;const{config:o,path:r}=e;if(!o.compilerOptions)return null;const{baseUrl:n,paths:s}=o.compilerOptions;if(!n)return null;const a=f(te(r),n),i=[];if(s)for(const[c,l]of Object.entries(s)){const p=new RegExp(`^${[...c].map(u=>u==="*"?"(.+)":u.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let d=0;for(const u of l){const g=[...fe(f(a,u))].map(j=>j==="*"?`$${++d}`:j==="$"?"$$":j).join("");i.push({find:p,replacement:g})}}return t&&i.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...fe(a)].map(c=>c==="$"?"$$":c).join("")}/$1`}),i},"getConfigAlias"),nt=tt((e,t)=>{const o=ot(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(r,n,s){if(!o||r.includes("\0"))return null;for(const{find:a,replacement:i}of o)if(a.test(r)){const c=r.replace(a,i),l=await this.resolve(c,n,{skipSelf:!0,...s});if(l)return t.debug({message:`Resolved ${r} to ${l.id} using paths from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-paths"}),l.id}return null}}},"resolveTsconfigPaths");var Rn=Object.defineProperty,rt=m((e,t)=>Rn(e,"name",{value:t,configurable:!0}),"u$2");const Tn=rt((e,t)=>{if(!t)return null;const{config:o,path:r}=t;if(!o.compilerOptions)return null;const{rootDirs:n}=o.compilerOptions;if(!n)return null;const s=[];for(const a of n){if(a.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${r}.`);if(a.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${r}.`);s.push(f(e,a))}return s},"getRootDirectories"),st=rt((e,t,o)=>{const r=Tn(e,o);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(n,s,a){if(r===null||r.length===0)return null;if(n.startsWith("."))for(const i of r){const c=y(i,n),l=await this.resolve(c,s,{skipSelf:!0,...a});if(l)return t.debug({message:`Resolved ${n} to ${l.id} using rootDirs from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-root-dirs"}),l.id}return null}}},"resolveTsconfigRootDirectories");var An=Object.defineProperty,Wn=m((e,t)=>An(e,"name",{value:t,configurable:!0}),"r$3");const it=Wn(()=>{const e=/\.(?:[mc]?js|jsx)$/;return{name:"packem:resolve-typescript-mjs-cjs",async resolveId(t,o,r){return e.test(t)&&o?await this.resolve(t.replace(/js(x?)$/,"ts$1"),o,r):null}}},"resolveTypescriptMjsCts");var Jn=Object.defineProperty,Bn=m((e,t)=>Jn(e,"name",{value:t,configurable:!0}),"s$5");const Ln=Bn(e=>{const t=U(e).split(".");if(t.length>=2){const[o,r]=t.slice(-2),n=t[0],s=/^(\w+)-runtime$/.exec(o)?.[1];if(R.includes(r)&&s&&s.length>0)return n+"-"+s}},"getCustomModuleLayer");var zn=Object.defineProperty,Un=m((e,t)=>zn(e,"name",{value:t,configurable:!0}),"i$2");const G=Un(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var Hn=Object.defineProperty,$e=m((e,t)=>Hn(e,"name",{value:t,configurable:!0}),"c$2");const je=$e((e,t)=>{const o=new Map;return $e(function(r,n){const s=n.getModuleInfo(r);if(!s)return;const{isEntry:a}=s,i=s.meta,c=G(i);if(!a){const l=o.get(r);if(l)return l;const p=Ln(r);if(p)return o.set(r,p),p}if(a){const l=n.getModuleIds();for(const p of l)n.getModuleInfo(p)&&G(i)===c&&(e.has(p)||e.set(p,new Set),e.get(p).add([r,c]))}if(c&&!a&&e.has(r)){const l=[...e.get(r)];if(l.some(([d])=>{if(t.some(u=>u.path===d)){const u=n.getModuleInfo(d);return G(u?u.meta:{})===c}return!1}))return;if(l.every(([,d])=>d===c))return o.has(r)?o.get(r):void 0;const p=`${U(r,ee(r))}-${c}`;return o.set(r,p),p}},"splitChunks")},"createSplitChunks");var qn=Object.defineProperty,Vn=m((e,t)=>qn(e,"name",{value:t,configurable:!0}),"n$2");const E=Vn((e,t,o)=>t.isDynamicEntry?`chunks/[name].${o}`:`shared/${e.options.name}.[hash].${o}`,"getChunkFilename");var Gn=Object.defineProperty,Xn=m((e,t)=>Gn(e,"name",{value:t,configurable:!0}),"s$3");const Kn=process.platform==="win32",we=Xn((e,t)=>{const o=Kn?"\\":"/";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 Yn=Object.defineProperty,b=m((e,t)=>Yn(e,"name",{value:t,configurable:!0}),"p");const Qn=b((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"+vt.node.split(".")[0];if(t.pkg.engines?.node){const r=Te(t.pkg.engines.node);r&&(o="node"+r.major)}if(t.options.rollup.esbuild.target){const r=q(t.options.rollup.esbuild.target);r.some(n=>n.startsWith("node"))||(t.options.rollup.esbuild.target=[...new Set([...q(o),...r])])}else t.options.rollup.esbuild.target=q(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")),{minify:t.options.minify,sourceMap:t.options.sourcemap,...t.options.rollup.esbuild,logger:t.logger}}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"),at=b((e,t)=>e.code==="CIRCULAR_DEPENDENCY"&&/Circular dependency:[\s\S]*node_modules/.test(e.message)?!0:e.code==="UNRESOLVED_IMPORT"?(t.logger.error(`Failed to resolve the module "${e.exporter}" imported by "${v(S(f(),e.id))}"
60
+ To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),je.set(a,!0)}return e}m(Ze,"v$1");R(Ze,"replaceConfusingTypeNames");function et(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(et,"N$1");R(et,"removeInternal");function tt(e,t){if(e.includes("@internal")){const o=new N(e),n=no(e,{plugins:["typescript"],sourceType:"module"});Ve(n,{enter(r){et(o,r)&&this.skip()}}),e=o.toString(),e.includes("@internal")&&(this.warn(`${t.fileName} has unhandled @internal declarations`),I(1))}return e}m(tt,"S");R(tt,"stripInternalTypes");const Ar=R((e,t)=>({name:"packem:patch-types",renderChunk(o,n){return o=Ze.call(this,o,n,e,t),o=tt.call(this,o,n),o=Tr(o),o},resolveId(o){return o.startsWith("types/")?{external:!0,id:"../../"+(o.endsWith(".js")?o:o+".js")}:null}}),"patchTypescriptTypes");var Wr=Object.defineProperty,ot=m((e,t)=>Wr(e,"name",{value:t,configurable:!0}),"u$4");const rt=ot((e,t=!0)=>{if(!e)return null;const{config:o,path:n}=e;if(!o.compilerOptions)return null;const{baseUrl:r,paths:s}=o.compilerOptions;if(!r)return null;const l=g(te(n),r),a=[];if(s)for(const[i,c]of Object.entries(s)){const p=new RegExp(`^${[...i].map(d=>d==="*"?"(.+)":d.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let u=0;for(const d of c){const f=[...he(g(l,d))].map(j=>j==="*"?`$${++u}`:j==="$"?"$$":j).join("");a.push({find:p,replacement:f})}}return t&&a.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...he(l)].map(i=>i==="$"?"$$":i).join("")}/$1`}),a},"getConfigAlias"),nt=ot((e,t)=>{const o=rt(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(n,r,s){if(!o||n.includes("\0"))return null;for(const{find:l,replacement:a}of o)if(l.test(n)){const i=n.replace(l,a),c=await this.resolve(i,r,{skipSelf:!0,...s});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 Br=Object.defineProperty,st=m((e,t)=>Br(e,"name",{value:t,configurable:!0}),"u$3");const Jr=st((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 s=[];for(const l of r){if(l.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${n}.`);if(l.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${n}.`);s.push(g(e,l))}return s},"getRootDirectories"),it=st((e,t,o)=>{const n=Jr(e,o);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(r,s,l){if(n===null||n.length===0)return null;if(r.startsWith("."))for(const a of n){const i=v(a,r),c=await this.resolve(i,s,{skipSelf:!0,...l});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 Lr=Object.defineProperty,zr=m((e,t)=>Lr(e,"name",{value:t,configurable:!0}),"r$3");const at=zr(()=>{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 Ur=Object.defineProperty,Hr=m((e,t)=>Ur(e,"name",{value:t,configurable:!0}),"s$5");const Vr=Hr(e=>{const t=U(e).split(".");if(t.length>=2){const[o,n]=t.slice(-2),r=t[0],s=/^(\w+)-runtime$/.exec(o)?.[1];if(T.includes(n)&&s&&s.length>0)return r+"-"+s}},"getCustomModuleLayer");var qr=Object.defineProperty,Yr=m((e,t)=>qr(e,"name",{value:t,configurable:!0}),"i$3");const Y=Yr(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var Gr=Object.defineProperty,we=m((e,t)=>Gr(e,"name",{value:t,configurable:!0}),"c$3");const ke=we((e,t)=>{const o=new Map;return we(function(n,r){const s=r.getModuleInfo(n);if(!s)return;const{isEntry:l}=s,a=s.meta,i=Y(a);if(!l){const c=o.get(n);if(c)return c;const p=Vr(n);if(p)return o.set(n,p),p}if(l){const c=r.getModuleIds();for(const p of c)r.getModuleInfo(p)&&Y(a)===i&&(e.has(p)||e.set(p,new Set),e.get(p).add([n,i]))}if(i&&!l&&e.has(n)){const c=[...e.get(n)];if(c.some(([u])=>{if(t.some(d=>d.path===u)){const d=r.getModuleInfo(u);return Y(d?d.meta:{})===i}return!1}))return;if(c.every(([,u])=>u===i))return o.has(n)?o.get(n):void 0;const p=`${U(n,ee(n))}-${i}`;return o.set(n,p),p}},"splitChunks")},"createSplitChunks");var Kr=Object.defineProperty,Xr=m((e,t)=>Kr(e,"name",{value:t,configurable:!0}),"n$2");const D=Xr((e,t,o)=>t.isDynamicEntry?`chunks/[name].${o}`:`shared/${e.options.name}.[hash].${o}`,"getChunkFilename");var Qr=Object.defineProperty,Zr=m((e,t)=>Qr(e,"name",{value:t,configurable:!0}),"s$3");const en=process.platform==="win32",xe=Zr((e,t)=>{const o=en?"\\":"/";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 tn=Object.defineProperty,b=m((e,t)=>tn(e,"name",{value:t,configurable:!0}),"p");const on=b((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"+$t.node.split(".")[0];if(t.pkg.engines?.node){const n=We(t.pkg.engines.node);n&&(o="node"+n.major)}if(t.options.rollup.esbuild.target){const n=V(t.options.rollup.esbuild.target);n.some(r=>r.startsWith("node"))||(t.options.rollup.esbuild.target=[...new Set([...V(o),...n])])}else t.options.rollup.esbuild.target=V(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")),{minify:t.options.minify,sourceMap:t.options.sourcemap,...t.options.rollup.esbuild,logger:t.logger}}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"),lt=b((e,t)=>e.code==="CIRCULAR_DEPENDENCY"&&/Circular dependency:[\s\S]*node_modules/.test(e.message)?!0:e.code==="UNRESOLVED_IMPORT"?(t.logger.error(`Failed to resolve the module "${e.exporter}" imported by "${y(S(g(),e.id))}"
61
61
  Is the module installed? Note:
62
62
  ↳ to inline a module into your bundle, install it to "devDependencies".
63
- ↳ to depend on a module via import/require, install it to "dependencies".`),process.exitCode=1,!0):e.code==="MIXED_EXPORTS"&&t.options.cjsInterop===!0,"sharedOnWarn"),ke=new Map,lt=b((e,t,o)=>{const r=b(s=>{for(const[a,i]of Object.entries(t))if(s.startsWith(a))return s.replace(a,i)},"findAlias"),n=ot(e.tsconfig,!1);return{external(s){const a=r(s);a&&(s=a);const i=Y(s),c=K(e.options.externals,i)||K(e.options.externals,s);if(c)return!0;if(s.startsWith(".")||Pe(s)||/src[/\\]/.test(s)||e.pkg.name&&s.startsWith(e.pkg.name))return!1;if(n){for(const{find:l}of n)if(l.test(s))return e.logger.debug({message:`Resolved alias ${s} to ${l.source}`,prefix:o}),!1}return!c&&!ke.has(s)&&e.logger.info({message:'Inlined implicit external "'+v(s)+'". If this is incorrect, add it to the "externals" option.',prefix:o}),ke.set(s,!0),c},input:Object.fromEntries(e.options.entries.map(s=>[s.name,f(e.options.rootDir,s.input)])),onLog:b((s,a)=>{let i=a.message;switch(a.stack&&(i=`${i}
64
- ${a.stack}`),s){case"info":{e.logger.info({message:i,prefix:o+(a.plugin?":plugin:"+a.plugin:"")});return}case"warn":{e.logger.warn({message:i,prefix:o+(a.plugin?":plugin:"+a.plugin:"")});return}case"debug":e.logger.debug({message:i,prefix:o+(a.plugin?":plugin:"+a.plugin:"")})}},"onLog"),onwarn(s,a){at(s,e)||s.code||a(s)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),ct=b(async(e,t)=>{const o=se(e,"build");let r;return e.options.rollup.resolve&&(r=k(Ie({extensions:R,...e.options.rollup.resolve}),t)),{...lt(e,o,"dependencies"),output:[e.options.emitCJS&&{chunkFileNames:b(n=>E(e,n,"cjs"),"chunkFileNames"),dir:f(e.options.rootDir,e.options.outDir),entryFileNames:b(n=>we(n,"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:je(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}},e.options.emitESM&&{chunkFileNames:b(n=>E(e,n,"mjs"),"chunkFileNames"),dir:f(e.options.rootDir,e.options.outDir),entryFileNames:b(n=>we(n,"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:je(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}}].filter(Boolean),plugins:[k(Ge(),t),k(it(),t),e.tsconfig&&k(st(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&k(nt(e.tsconfig,e.logger),t),e.options.rollup.replace&&Re({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&Fe({customResolver:r?.resolveId,...e.options.rollup.alias,entries:o}),r,e.options.rollup.polyfillNode&&Vt({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&Ue({...e.options.rollup.json}),fn(e.logger),no(e.options.entries.filter(n=>n.executable).map(n=>n.name).filter(Boolean)),e.options.rollup.wsam&&qt(e.options.rollup.wsam),e.options.transformer?.(Qn(e.options.transformerName,e)),e.options.cjsInterop&&e.options.emitCJS&&ze({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&Ht(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&k(Ut({extensions:R,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.raw&&vn(e.options.rollup.raw),e.options.rollup.jsxRemoveAttributes&&Zo({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),e.options.rollup.metafile&&sn({outDir:f(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&qo(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&qe({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&&Gt({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"),Zn=b(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"),er=Bo(Zn),pt=b(async(e,t)=>{const o=se(e,"types"),r={load(i){return/\.(?:js|cjs|mjs|jsx|ts|tsx|mts|json)$/.test(i)?null:""},name:"packem:ignore-files"},n=e.tsconfig?.config.compilerOptions;delete n?.lib;let s;e.options.rollup.resolve&&(s=k(Ie({extensions:R,...e.options.rollup.resolve}),t));const a="dts-plugin:"+process.pid+e.tsconfig.path;return{...lt(e,o,"dts"),onwarn(i,c){at(i,e)||i.code!=="EMPTY_BUNDLE"&&c(i)},output:[e.options.emitCJS&&{chunkFileNames:b(i=>E(e,i,"d.cts"),"chunkFileNames"),dir:f(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},{chunkFileNames:b(i=>E(e,i,"d.mts"),"chunkFileNames"),dir:f(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:b(i=>E(e,i,"d.ts"),"chunkFileNames"),dir:f(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:[k(Ge(),t),k(it(),t),e.options.rollup.json&&Ue({...e.options.rollup.json}),r,e.tsconfig&&k(st(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&k(nt(e.tsconfig,e.logger),t),e.options.rollup.replace&&Re({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&Fe({customResolver:s?.resolveId,...e.options.rollup.alias,entries:o}),s,await er(a)(e),e.options.cjsInterop&&e.options.emitCJS&&ze({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&Fn(e.options.rollup.patchTypes,e.logger),ro(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&qe({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dtsTemplate,logger:e.logger,marker:e.options.rollup.license.dependenciesMarker??"TYPE_DEPENDENCIES",mode:"types",packageName:e.pkg.name})].filter(Boolean)}},"getRollupDtsOptions");var tr=Object.defineProperty,or=m((e,t)=>tr(e,"name",{value:t,configurable:!0}),"c$1");const nr=or(async(e,t)=>{const o=await ct(e,t);if(await e.hooks.callHook("rollup:options",e,o),Object.keys(o.input).length===0)return;const r="rollup-build.json";o.cache=t.get(r);const n=await Ce(o);t.set(r,n.cache),await e.hooks.callHook("rollup:build",e,n);const s=o.output,a=new Map;for(const i of s){const{output:c}=await n.write(i),l=new Set,p=c.filter(u=>u.type==="chunk");for(const u of p){l.add(u.fileName);for(const g of u.imports)e.usedImports.add(g);u.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(u.code,"utf8"),chunks:u.imports.filter(g=>p.find(j=>j.fileName===g)),exports:u.exports,modules:Object.entries(u.modules).map(([g,j])=>({bytes:j.renderedLength,id:g})),path:u.fileName,type:"entry"})}const d=c.filter(u=>u.type==="asset");for(const u of d)a.has(u.fileName)||a.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(...a.values())},"build");var rr=Object.defineProperty,L=m((e,t)=>rr(e,"name",{value:t,configurable:!0}),"r$1");const sr=L(async(e,t)=>{const o=await pt(e,t);if(await e.hooks.callHook("rollup:dts:options",e,o),Object.keys(o.input).length===0)return;const r="rollup-dts.json";o.cache=t.get(r);const n=await Ce(o);t.set(r,n.cache),await e.hooks.callHook("rollup:dts:build",e,n),e.logger.info({message:"Building declaration files...",prefix:"dts"}),e.options.emitCJS&&await n.write({chunkFileNames:L(s=>E(e,s,"d.cts"),"chunkFileNames"),dir:f(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await n.write({chunkFileNames:L(s=>E(e,s,"d.mts"),"chunkFileNames"),dir:f(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts"}),(e.options.declaration===!0||e.options.declaration==="compatible")&&await n.write({chunkFileNames:L(s=>E(e,s,"d.ts"),"chunkFileNames"),dir:f(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts"}),await e.hooks.callHook("rollup:dts:done",e)},"buildTypes");var ir=Object.defineProperty,ut=m((e,t)=>ir(e,"name",{value:t,configurable:!0}),"e");const xe=ut((e,t,o)=>{const r="watcher:"+t;e.on("change",(n,{event:s})=>{o.info({message:`${v(S(".",n))} was ${s}d`,prefix:r})}),e.on("restart",()=>{o.info({message:"Rebuilding "+t+"...",prefix:r})}),e.on("event",n=>{n.code==="END"&&o.success({message:"Rebuild "+t+" finished",prefix:r}),n.code==="ERROR"&&o.error({context:[n.error],message:"Rebuild "+t+" failed: "+n.error.message,prefix:r})})},"watchHandler"),ar=ut(async(e,t)=>{const o=await ct(e,t);if(await e.hooks.callHook("rollup:options",e,o),Object.keys(o.input).length===0)return;o.cache=t.get("rollup-watch");const r=me(o);await e.hooks.callHook("rollup:watch",e,r);const n=[...Array.isArray(o.input)?o.input:typeof o.input=="string"?[o.input]:Object.keys(o.input??{})];let s="Starting watchers for entries:";for(const a of n)s+=C(`
65
- └─ ${S(process.cwd(),a)}`);if(e.logger.info(s),xe(r,"bundle",e.logger),e.options.declaration){const a=await pt(e,t);await e.hooks.callHook("rollup:dts:options",e,a);const i=me(a);await e.hooks.callHook("rollup:watch",e,i),xe(i,"types",e.logger)}},"watch");var lr=Object.defineProperty,cr=m((e,t)=>lr(e,"name",{value:t,configurable:!0}),"i$1");const dt=cr(e=>`{ ${Object.keys(e).map(t=>`${t}: ${JSON.stringify(e[t])}`).join(", ")} }`,"dumpObject");var pr=Object.defineProperty,ur=m((e,t)=>pr(e,"name",{value:t,configurable:!0}),"a$2");let dr=class{static{m(this,"g")}static{ur(this,"FileCache")}#n;#e;#r;#t=!0;#o=new Map;constructor(t,o,r){this.#n=t,this.#e=Nt("visulima-packem",{cwd:t}),this.#r=o,this.#e===void 0?r.debug("Could not create cache directory."):r.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:W(this.getFilePath(t,o))}get(t,o){if(!this.#t||this.#e===void 0)return;const r=this.getFilePath(t,o);if(this.#o.has(r))return this.#o.get(r);if(!W(r))return;const n=De(r),s=JSON.parse(n);return this.#o.set(r,s),s}set(t,o,r){if(!this.#t||this.#e===void 0||o===void 0)return;const n=this.getFilePath(t,r);typeof o=="object"&&(o=JSON.stringify(o)),Se(n,o,{overwrite:!0})}getFilePath(t,o){let r=t.replaceAll(ue(this.#n),"");return r=r.replaceAll(":","-"),y(this.#e,this.#r,o?.replaceAll(":","-")??"",ue(r))}};var mr=Object.defineProperty,z=m((e,t)=>mr(e,"name",{value:t,configurable:!0}),"l$1");const fr=ne,gr=z((e,t)=>{const{sideEffects:o}=t;let r;if(typeof o=="boolean")r=z(()=>o,"hasSideEffects");else if(Array.isArray(o))if(o.length<=0)r=z(()=>!1,"hasSideEffects");else{const n=o.map(s=>s.includes("/")?s:`**/${s}`);r=fr(n,null,{resolve:e})}else r=z(()=>null,"hasSideEffects");return r},"getPackageSideEffect");var hr=Object.defineProperty,yr=m((e,t)=>hr(e,"name",{value:t,configurable:!0}),"o");const vr=yr(e=>{const t=new Set,o=new Set(Object.keys(e.pkg.dependencies??{})),r=new Set;for(const n of e.usedImports)o.delete(n),t.add(n);if(Array.isArray(e.options.dependencies))for(const n of e.options.dependencies)o.delete(n);for(const n of t)!K(e.options.externals,n)&&!n.startsWith("chunks/")&&!e.options.dependencies.includes(Y(n))&&!e.options.peerDependencies.includes(Y(n))&&r.add(n);o.size>0&&J(e,`Potential unused dependencies found: ${[...o].map(n=>v(n)).join(", ")}`),r.size>0&&J(e,`Potential implicit dependencies found: ${[...r].map(n=>v(n)).join(", ")}`)},"validateDependencies");var br=Object.defineProperty,mt=m((e,t)=>br(e,"name",{value:t,configurable:!0}),"i");const $r=mt((e,t)=>to(e,t)<=e.length/3||t.includes(e),"isSimilar"),jr=mt((e,t)=>{const o=e.toLowerCase();return t.filter(r=>$r(r.toLowerCase(),o))},"findAlternatives");var wr=Object.defineProperty,Oe=m((e,t)=>wr(e,"name",{value:t,configurable:!0}),"n");const kr=Oe((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:"",...ae(e.exports,e.type??"commonjs",t.options.declaration).map(n=>n.file)].map(n=>n&&f(t.rootDir,n.replace(/\/[^*/]*\*[^\n\r/\u2028\u2029]*(?:[\n\r\u2028\u2029][^*/]*\*[^\n\r/\u2028\u2029]*)*(?:\/.*)?$/,"")))),r=[];for(const n of o)n&&!n.includes("*")&&!oe(n)&&r.push(n.replace(`${t.rootDir}/`,""));if(r.length>0){const n=Oe(i=>S(t.rootDir,f(t.options.outDir,i)),"rPath"),s=t.buildEntries.filter(i=>!i.chunk).map(i=>n(i.path));let a="Potential missing or wrong package.json files:";for(const i of r){const c=jr(i,s);a+=`
66
- - `+v(i)+(c.length>0?$t` (did you mean ${c.map(l=>`"${l}"`).join(", ")}?)`:"")}J(t,a)}},"validatePackage");var xr=Object.defineProperty,$=m((e,t)=>xr(e,"name",{value:t,configurable:!0}),"m");const ft=$((e,t)=>{e.warnings.size>0&&(t&&e.logger.raw(`
63
+ ↳ to depend on a module via import/require, install it to "dependencies".`),process.exitCode=1,!0):e.code==="MIXED_EXPORTS"&&t.options.cjsInterop===!0,"sharedOnWarn"),Ee=new Map,ct=b((e,t,o)=>{const n=b(s=>{for(const[l,a]of Object.entries(t))if(s.startsWith(l))return s.replace(l,a)},"findAlias"),r=rt(e.tsconfig,!1);return{external(s){const l=n(s);l&&(s=l);const a=X(s),i=K(e.options.externals,a)||K(e.options.externals,s);if(i)return!0;if(s.startsWith(".")||Me(s)||/src[/\\]/.test(s)||e.pkg.name&&s.startsWith(e.pkg.name))return!1;if(r){for(const{find:c}of r)if(c.test(s))return e.logger.debug({message:`Resolved alias ${s} to ${c.source}`,prefix:o}),!1}return!i&&!Ee.has(s)&&e.logger.info({message:'Inlined implicit external "'+y(s)+'". If this is incorrect, add it to the "externals" option.',prefix:o}),Ee.set(s,!0),i},input:Object.fromEntries(e.options.entries.map(s=>[s.name,g(e.options.rootDir,s.input)])),logLevel:e.options.debug?"debug":"info",onLog:b((s,l)=>{let a=l.message;switch(l.stack&&(a=`${a}
64
+ ${l.stack}`),s){case"info":{e.logger.info({message:a,prefix:o+(l.plugin?":plugin:"+l.plugin:"")});return}case"warn":{e.logger.warn({message:a,prefix:o+(l.plugin?":plugin:"+l.plugin:"")});return}case"debug":e.logger.debug({message:a,prefix:o+(l.plugin?":plugin:"+l.plugin:"")})}},"onLog"),onwarn(s,l){lt(s,e)||s.code||l(s)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),pt=b(async(e,t)=>{const o=se(e,"build");let n;return e.options.rollup.resolve&&(n=k(Te({extensions:T,...e.options.rollup.resolve}),t)),{...ct(e,o,"dependencies"),output:[e.options.emitCJS&&{chunkFileNames:b(r=>D(e,r,"cjs"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:b(r=>xe(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:ke(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}},e.options.emitESM&&{chunkFileNames:b(r=>D(e,r,"mjs"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:b(r=>xe(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:ke(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}}].filter(Boolean),plugins:[k(Ge(),t),k(at(),t),e.tsconfig&&k(it(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&k(nt(e.tsconfig,e.logger),t),e.options.rollup.replace&&Ae({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&Re({customResolver:n?.resolveId,...e.options.rollup.alias,entries:o}),n,e.options.rollup.polyfillNode&&Xt({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&He({...e.options.rollup.json}),vr(e.logger),ao(e.options.entries.filter(r=>r.executable).map(r=>r.name).filter(Boolean)),e.options.rollup.wsam&&Kt(e.options.rollup.wsam),e.options.transformer?.(on(e.options.transformerName,e)),e.options.cjsInterop&&e.options.emitCJS&&Ue({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&Gt(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&k(Yt({extensions:T,sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),t),e.options.rollup.preserveDynamicImports&&{renderDynamicImport(){return{left:"import(",right:")"}}},e.options.rollup.shim&&Nr(e.pkg),e.options.rollup.raw&&wr(e.options.rollup.raw),e.options.rollup.jsxRemoveAttributes&&nr({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),e.options.rollup.metafile&&pr({outDir:g(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&Xo(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&qe({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&&Qt({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"),rn=b(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"),nn=Vo(rn),ut=b(async(e,t)=>{const o=se(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 s;e.options.rollup.resolve&&(s=k(Te({extensions:T,...e.options.rollup.resolve}),t));const l="dts-plugin:"+process.pid+e.tsconfig.path;return{...ct(e,o,"dts"),onwarn(a,i){lt(a,e)||a.code!=="EMPTY_BUNDLE"&&i(a)},output:[e.options.emitCJS&&{chunkFileNames:b(a=>D(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},{chunkFileNames:b(a=>D(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:b(a=>D(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:[k(Ge(),t),k(at(),t),e.options.rollup.json&&He({...e.options.rollup.json}),n,e.tsconfig&&k(it(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&k(nt(e.tsconfig,e.logger),t),e.options.rollup.replace&&Ae({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&Re({customResolver:s?.resolveId,...e.options.rollup.alias,entries:o}),s,await nn(l)(e),e.options.cjsInterop&&e.options.emitCJS&&Ue({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&Ar(e.options.rollup.patchTypes,e.logger),lo(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&qe({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dtsTemplate,logger:e.logger,marker:e.options.rollup.license.dependenciesMarker??"TYPE_DEPENDENCIES",mode:"types",packageName:e.pkg.name})].filter(Boolean)}},"getRollupDtsOptions");var sn=Object.defineProperty,an=m((e,t)=>sn(e,"name",{value:t,configurable:!0}),"c$2");const ln=an(async(e,t)=>{const o=await pt(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 Ce(o);t.set(n,r.cache),await e.hooks.callHook("rollup:build",e,r);const s=o.output,l=new Map;for(const a of s){const{output:i}=await r.write(a),c=new Set,p=i.filter(d=>d.type==="chunk");for(const d of p){c.add(d.fileName);for(const f of d.imports)e.usedImports.add(f);d.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(d.code,"utf8"),chunks:d.imports.filter(f=>p.find(j=>j.fileName===f)),exports:d.exports,modules:Object.entries(d.modules).map(([f,j])=>({bytes:j.renderedLength,id:f})),path:d.fileName,type:"entry"})}const u=i.filter(d=>d.type==="asset");for(const d of u)l.has(d.fileName)||l.set(d.fileName,{bytes:Buffer.byteLength(d.source,"utf8"),path:d.fileName,type:"asset"});for(const d of c)e.usedImports.delete(d)}e.buildEntries.push(...l.values())},"build");var cn=Object.defineProperty,L=m((e,t)=>cn(e,"name",{value:t,configurable:!0}),"r$1");const pn=L(async(e,t)=>{const o=await ut(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 Ce(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:L(s=>D(e,s,"d.cts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await r.write({chunkFileNames:L(s=>D(e,s,"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:L(s=>D(e,s,"d.ts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts"}),await e.hooks.callHook("rollup:dts:done",e)},"buildTypes");var un=Object.defineProperty,pe=m((e,t)=>un(e,"name",{value:t,configurable:!0}),"i$2");const dn=pe(e=>{const{message:t,name:o="Error",stack:n}=e;if(!n)return n;const r=`${o}: ${t}
65
+ `;return n.startsWith(r)?n.slice(r.length):n},"extractStack"),mn=pe(e=>`
66
+ ${e.replaceAll(/^\n|\n$/g,"")}
67
+ `,"normalizeCodeFrame"),dt=pe(e=>{const t=dn(e);let o=(e.plugin?`[${e.plugin}] `:"")+e.message;e.id&&(o+=`
68
+ file: ${y(e.id+(e.loc?":"+e.loc.line+":"+e.loc.column:""))}`),e.frame&&(o+=`
69
+ `+wt(mn(e.frame))),e.message=o,t!==void 0&&(e.stack=`${e.message}
70
+ ${t}`)},"enhanceRollupError");var fn=Object.defineProperty,mt=m((e,t)=>fn(e,"name",{value:t,configurable:!0}),"l$2");const Oe=mt((e,t,o)=>{const n="watcher:"+t;e.on("change",(r,{event:s})=>{o.info({message:`${y(S(".",r))} was ${s}d`,prefix:n})}),e.on("restart",()=>{o.info({message:"Rebuilding "+t+"...",prefix:n})}),e.on("event",r=>{switch(r.code){case"END":{o.success({message:"Rebuild "+t+" finished",prefix:n});break}case"BUNDLE_START":{o.info({message:y(`
71
+ build started...`),prefix:n});break}case"BUNDLE_END":{r.result.close(),o.info({message:y(`built in ${r.duration}ms.`),prefix:n});break}case"ERROR":{dt(r.error),o.error({context:[r.error],message:"Rebuild "+t+" failed: "+r.error.message,prefix:n});break}}})},"watchHandler"),gn=mt(async(e,t)=>{const o=await pt(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=[v(e.options.sourceDir,"**")],o.watch.chokidar={cwd:e.options.rootDir,...o.watch.chokidar});const n=await fe(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 s="Starting watchers for entries:";for(const l of r)s+=F(`
72
+ └─ ${S(process.cwd(),l)}`);if(e.logger.info(s),Oe(n,"bundle",e.logger),e.options.declaration){const l=await ut(e,t);await e.hooks.callHook("rollup:dts:options",e,l);const a=fe(l);await e.hooks.callHook("rollup:watch",e,a),Oe(a,"types",e.logger)}},"watch");var hn=Object.defineProperty,yn=m((e,t)=>hn(e,"name",{value:t,configurable:!0}),"i$1");const ft=yn(e=>`{ ${Object.keys(e).map(t=>`${t}: ${JSON.stringify(e[t])}`).join(", ")} }`,"dumpObject");var vn=Object.defineProperty,bn=m((e,t)=>vn(e,"name",{value:t,configurable:!0}),"a$2");let $n=class{static{m(this,"g")}static{bn(this,"FileCache")}#r;#e;#n;#t=!0;#o=new Map;constructor(t,o,n){this.#r=t,this.#e=Mt("visulima-packem",{cwd:t}),this.#n=o,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:W(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(!W(n))return;const r=Se(n),s=JSON.parse(r);return this.#o.set(n,s),s}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)),_e(r,o,{overwrite:!0})}getFilePath(t,o){let n=t.replaceAll(me(this.#r),"");return n=n.replaceAll(":","-"),v(this.#e,this.#n,o?.replaceAll(":","-")??"",me(n))}};var jn=Object.defineProperty,z=m((e,t)=>jn(e,"name",{value:t,configurable:!0}),"l$1");const wn=re,kn=z((e,t)=>{const{sideEffects:o}=t;let n;if(typeof o=="boolean")n=z(()=>o,"hasSideEffects");else if(Array.isArray(o))if(o.length<=0)n=z(()=>!1,"hasSideEffects");else{const r=o.map(s=>s.includes("/")?s:`**/${s}`);n=wn(r,null,{resolve:e})}else n=z(()=>null,"hasSideEffects");return n},"getPackageSideEffect");var xn=Object.defineProperty,En=m((e,t)=>xn(e,"name",{value:t,configurable:!0}),"y");const On=En((e,t,o)=>e.reduce((n,r)=>{const s=r[t],l=r[o];return n[s]||(n[s]={}),n[s][l]||(n[s][l]=[]),n[s][l].push(r),n},{}),"groupByKeys");var Dn=Object.defineProperty,Nn=m((e,t)=>Dn(e,"name",{value:t,configurable:!0}),"o");const Sn=Nn(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(Array.isArray(e.options.dependencies))for(const r of e.options.dependencies)o.delete(r);for(const r of t)!K(e.options.externals,r)&&!r.startsWith("chunks/")&&!e.options.dependencies.includes(X(r))&&!e.options.peerDependencies.includes(X(r))&&n.add(r);o.size>0&&B(e,`Potential unused dependencies found: ${[...o].map(r=>y(r)).join(", ")}`),n.size>0&&B(e,`Potential implicit dependencies found: ${[...n].map(r=>y(r)).join(", ")}`)},"validateDependencies");var _n=Object.defineProperty,gt=m((e,t)=>_n(e,"name",{value:t,configurable:!0}),"i");const Pn=gt((e,t)=>so(e,t)<=e.length/3||t.includes(e),"isSimilar"),Mn=gt((e,t)=>{const o=e.toLowerCase();return t.filter(n=>Pn(n.toLowerCase(),o))},"findAlternatives");var Cn=Object.defineProperty,De=m((e,t)=>Cn(e,"name",{value:t,configurable:!0}),"n");const Fn=De((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:"",...ae(e.exports,e.type??"commonjs",t.options.declaration).map(r=>r.file)].map(r=>r&&g(t.rootDir,r.replace(/\/[^*/]*\*[^\n\r/\u2028\u2029]*(?:[\n\r\u2028\u2029][^*/]*\*[^\n\r/\u2028\u2029]*)*(?:\/.*)?$/,"")))),n=[];for(const r of o)r&&!r.includes("*")&&!oe(r)&&n.push(r.replace(`${t.rootDir}/`,""));if(n.length>0){const r=De(a=>S(t.rootDir,g(t.options.outDir,a)),"rPath"),s=t.buildEntries.filter(a=>!a.chunk).map(a=>r(a.path));let l="Potential missing or wrong package.json files:";for(const a of n){const i=Mn(a,s);l+=`
73
+ - `+y(a)+(i.length>0?kt` (did you mean ${i.map(c=>`"${c}"`).join(", ")}?)`:"")}B(t,l)}},"validatePackage");var In=Object.defineProperty,$=m((e,t)=>In(e,"name",{value:t,configurable:!0}),"f");const ht=$((e,t)=>{e.warnings.size>0&&(t&&e.logger.raw(`
67
74
  `),e.logger.warn(`Build is done with some warnings:
68
75
 
69
76
  ${[...e.warnings].map(o=>`- ${o}`).join(`
70
- `)}`),e.options.failOnWarn&&(e.logger.error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`."),F(1)))},"logErrors"),Or=$(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"),Er=$((e,t,o,r,n,s,a,i)=>{const c=Or(i?.config.compilerOptions?.jsx),l=Tt(n,r,s,{alias:{},clean:!0,declaration:!0,dependencies:[],devDependencies:[],emitCJS:!0,emitESM:!0,entries:[],externals:[...pe.builtinModules,...pe.builtinModules.map(p=>`node:${p}`)],failOnWarn:!0,fileCache:!0,minify:A.NODE_ENV==="production",name:(a.name??"").split("/").pop()??"default",optionalDependencies:[],outDir:"dist",peerDependencies:[],replace:{},rollup:{alias:{},cjsInterop:{addDefaultProperty:!1},commonjs:{ignoreTryCatch:!0,preserveSymlinks:!0,transformMixedEsModules:!1},dts:{compilerOptions:{baseUrl:i?.config.compilerOptions?.baseUrl??".",checkJs:!1,composite:!1,declaration:!0,declarationMap:!1,emitDeclarationOnly:!0,incremental:!1,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:i?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:i?.config.compilerOptions?.jsxFactory,jsxFragment:i?.config.compilerOptions?.jsxFragmentFactory,jsxImportSource:i?.config.compilerOptions?.jsxImportSource,jsxSideEffects:!0,keepNames:!0,minifyWhitespace:A.NODE_ENV==="production",sourcesContent:!1,target:i?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:i?.config},json:{preferConst:!0},license:{dependenciesTemplate:$((p,d,u)=>`
77
+ `)}`),e.options.failOnWarn&&(e.logger.error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`."),I(1)))},"logErrors"),Rn=$(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"),Tn=$((e,t,o,n,r,s,l,a,i)=>{const c=Rn(i?.config.compilerOptions?.jsx),p=Bt(s,r,l,{alias:{},clean:!0,debug:n,declaration:!0,dependencies:[],devDependencies:[],emitCJS:!0,emitESM:!0,entries:[],externals:[...de.builtinModules,...de.builtinModules.map(u=>`node:${u}`)],failOnWarn:!0,fileCache:!0,minify:x.NODE_ENV==="production",name:(a.name??"").split("/").pop()??"default",optionalDependencies:[],outDir:"dist",peerDependencies:[],replace:{},rollup:{alias:{},cjsInterop:{addDefaultProperty:!1},commonjs:{ignoreTryCatch:!0,preserveSymlinks:!0,transformMixedEsModules:!1},dts:{compilerOptions:{baseUrl:i?.config.compilerOptions?.baseUrl??".",checkJs:!1,composite:!1,declaration:!0,declarationMap:!1,emitDeclarationOnly:!0,incremental:!1,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:i?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:i?.config.compilerOptions?.jsxFactory,jsxFragment:i?.config.compilerOptions?.jsxFragmentFactory,jsxImportSource:i?.config.compilerOptions?.jsxImportSource,jsxSideEffects:!0,keepNames:!0,minifyWhitespace:x.NODE_ENV==="production",sourcesContent:!1,target:i?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:i?.config},json:{preferConst:!0},license:{dependenciesTemplate:$((u,d,f)=>`
71
78
  # Licenses of bundled dependencies
72
- The published ${u} artifact additionally contains code with the following licenses:
73
- ${p.join(", ")}
79
+ The published ${f} artifact additionally contains code with the following licenses:
80
+ ${u.join(", ")}
74
81
 
75
82
  # Bundled dependencies:
76
- `+d,"dependenciesTemplate"),dtsTemplate:$((p,d,u)=>`
83
+ `+d,"dependenciesTemplate"),dtsTemplate:$((u,d,f)=>`
77
84
  # Licenses of bundled types
78
- The published ${u} artifact additionally contains code with the following licenses:
79
- ${p.join(", ")}
85
+ The published ${f} artifact additionally contains code with the following licenses:
86
+ ${u.join(", ")}
80
87
 
81
88
  # Bundled types:
82
- `+d,"dtsTemplate")},patchTypes:{},polyfillNode:{},preserveDynamicImports:!0,raw:{exclude:de,include:["**/*.data","**/*.txt"]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,preferBuiltins:!1},shim:!0,sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:i?.config.compilerOptions?.esModuleInterop===!1,include:/\.[jt]sx?$/,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:A.NODE_ENV==="production",...i?.config.compilerOptions?.jsx&&["react","react-jsx","react-jsxdev"].includes(i.config.compilerOptions.jsx)?{jsxFragmentPragma:i.config.compilerOptions.jsxFragmentFactory,jsxImportSource:i.config.compilerOptions.jsxImportSource,jsxPragma:i.config.compilerOptions.jsxFactory,jsxRuntime:c,transforms:["typescript","jsx",...i.config.compilerOptions.esModuleInterop?["imports"]:[]]}:{transforms:["typescript",...i?.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:i?.config.compilerOptions?.experimentalDecorators,syntax:i?"typescript":"ecmascript",[i?"tsx":"jsx"]:!0},target:i?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:i?.config.compilerOptions?.emitDecoratorMetadata,legacyDecorator:i?.config.compilerOptions?.experimentalDecorators,react:{development:A.NODE_ENV!=="production",pragma:i?.config.compilerOptions?.jsxFactory,pragmaFrag:i?.config.compilerOptions?.jsxFragmentFactory,runtime:c,throwIfNamespace:!0},treatConstEnumAsEnum:i?.config.compilerOptions?.preserveConstEnums,useDefineForClassFields:i?.config.compilerOptions?.useDefineForClassFields}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"}},treeshake:{moduleSideEffects:gr(t,a),preset:"recommended"},watch:{clearScreen:!0,exclude:de}},rootDir:t,sourceDir:"src",sourcemap:!1,stub:o==="jit",stubOptions:{jiti:{alias:{},esmResolve:!0,interopDefault:!0}},transformerName:void 0});if(!l.transformerName){const p=new Set([...Object.keys(a.dependencies??{}),...Object.keys(a.devDependencies??{})]);if(p.has("esbuild"))l.transformerName="esbuild";else if(p.has("@swc/core"))l.transformerName="swc";else if(p.has("sucrase"))l.transformerName="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(l.transformerName)+'" as transformer.')}return l.rollup.resolve&&l.rollup.resolve.preferBuiltins===!0&&(l.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true")),i?.config.compilerOptions?.isolatedModules||e.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig.
83
- Because none of the third-party transpilers, 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.
84
- 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.`),l.dependencies=Object.keys(a.dependencies??{}),l.peerDependencies=Object.keys(a.peerDependencies??{}),l.devDependencies=Object.keys(a.devDependencies??{}),l.optionalDependencies=Object.keys(a.optionalDependencies??{}),l.externals.push(...l.dependencies,...l.peerDependencies,...l.optionalDependencies),l},"generateOptions"),Dr=$(e=>e.replace(/\.(?:js|mjs|cjs|ts|mts|cts|json|jsx|tsx)$/,""),"removeExtension"),Sr=$(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 r=Pe(o.input)?S(t,o.input):Z(o.input);r.startsWith("./")&&(r=r.slice(2)),o.name=Dr(r.replace(/^src\//,""))}if(!o.input)throw new Error(`Missing entry input: ${dt(o)}`);if(o.input=f(e.options.rootDir,o.input),!W(o.input)){const r=new Set(await yt(te(o.input)));let n=!1;for(const s of R)if(r.has(U(o.input)+s)){n=!0;break}if(!n)throw new Dt("Your configured entry: "+v(o.input)+" does not exist.")}o.outDir=f(e.options.rootDir,o.outDir??e.options.outDir)}},"prepareEntries"),Nr=$((e,t,o)=>{const r=$(s=>S(t.rootDir,f(t.options.outDir,s)),"rPath");let n=!1;for(const s of t.buildEntries.filter(a=>!a.chunk)){let a=s.bytes??0;for(const c of s.chunks??[])a+=t.buildEntries.find(l=>l.path===c)?.bytes??0;let i=` ${O(r(s.path))} (${["total size: "+v(_(a)),s.type!=="asset"&&s.bytes&&"chunk size: "+v(_(s.bytes))].filter(Boolean).join(", ")})`;if(i+=s.exports?.length?`
85
- exports: `+C(s.exports.join(", ")):"",s.chunks?.length&&(i+=`
86
- ${s.chunks.map(c=>{const l=t.buildEntries.find(p=>p.path===c)??{};return C(" └─ "+r(c)+O(l.bytes?" ("+_(l?.bytes)+")":""))}).join(`
87
- `)}`),s.modules&&s.modules.length>0){const c=s.modules.filter(l=>l.id.includes("node_modules")).sort((l,p)=>(p.bytes||0)-(l.bytes||0)).map(l=>C(" 📦 "+r(l.id)+O(l.bytes?" ("+_(l.bytes)+")":""))).join(`
88
- `);i+=c.length>0?`
89
+ `+d,"dtsTemplate")},patchTypes:{},polyfillNode:{},preserveDynamicImports:!0,raw:{exclude:ge,include:["**/*.data","**/*.txt"]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,preferBuiltins:!1},shim:!0,sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:i?.config.compilerOptions?.esModuleInterop===!1,include:/\.[jt]sx?$/,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:x.NODE_ENV==="production",...i?.config.compilerOptions?.jsx&&["react","react-jsx","react-jsxdev"].includes(i.config.compilerOptions.jsx)?{jsxFragmentPragma:i.config.compilerOptions.jsxFragmentFactory,jsxImportSource:i.config.compilerOptions.jsxImportSource,jsxPragma:i.config.compilerOptions.jsxFactory,jsxRuntime:c,transforms:["typescript","jsx",...i.config.compilerOptions.esModuleInterop?["imports"]:[]]}:{transforms:["typescript",...i?.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:i?.config.compilerOptions?.experimentalDecorators,syntax:i?"typescript":"ecmascript",[i?"tsx":"jsx"]:!0},target:i?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:i?.config.compilerOptions?.emitDecoratorMetadata,legacyDecorator:i?.config.compilerOptions?.experimentalDecorators,react:{development:x.NODE_ENV!=="production",pragma:i?.config.compilerOptions?.jsxFactory,pragmaFrag:i?.config.compilerOptions?.jsxFragmentFactory,runtime:c,throwIfNamespace:!0},treatConstEnumAsEnum:i?.config.compilerOptions?.preserveConstEnums,useDefineForClassFields:i?.config.compilerOptions?.useDefineForClassFields}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"}},treeshake:{moduleSideEffects:kn(t,a),preset:"recommended"},watch:{chokidar:{ignoreInitial:!0,ignorePermissionErrors:!0},clearScreen:!0,exclude:ge}},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 d="0.0.0";if(u.has("esbuild"))p.transformerName="esbuild",d=u.get("esbuild");else if(u.has("@swc/core"))p.transformerName="swc",d=u.get("@swc/core");else if(u.has("sucrase"))p.transformerName="sucrase",d=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 "+y("rollup ")+Lt,"Using "+y(p.transformerName)+" "+d+" as transformer"].join(`
90
+ `))}return p.rollup.resolve&&p.rollup.resolve.preferBuiltins===!0&&(p.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true")),i?.config.compilerOptions?.isolatedModules||e.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig.
91
+ 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.
92
+ 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.`),p.dependencies=Object.keys(a.dependencies??{}),p.peerDependencies=Object.keys(a.peerDependencies??{}),p.devDependencies=Object.keys(a.devDependencies??{}),p.optionalDependencies=Object.keys(a.optionalDependencies??{}),p.externals.push(...p.dependencies,...p.peerDependencies,...p.optionalDependencies),p},"generateOptions"),An=$(e=>e.replace(/\.(?:js|mjs|cjs|ts|mts|cts|json|jsx|tsx)$/,""),"removeExtension"),Wn=$(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=Me(o.input)?S(t,o.input):Z(o.input);n.startsWith("./")&&(n=n.slice(2)),o.name=An(n.replace(/^src\//,""))}if(!o.input)throw new Error(`Missing entry input: ${ft(o)}`);if(o.input=g(e.options.rootDir,o.input),!W(o.input)){const n=new Set(await bt(te(o.input)));let r=!1;for(const s of T)if(n.has(U(o.input)+s)){r=!0;break}if(!r)throw new _t("Your configured entry: "+y(o.input)+" does not exist.")}o.outDir=g(e.options.rootDir,o.outDir??e.options.outDir)}},"prepareEntries"),Bn=$((e,t,o)=>{const n=$(s=>S(t.rootDir,g(t.options.outDir,s)),"rPath");let r=!1;for(const s of t.buildEntries.filter(l=>!l.chunk)){let l=s.bytes??0;for(const i of s.chunks??[])l+=t.buildEntries.find(c=>c.path===i)?.bytes??0;let a=` ${O(n(s.path))} (${["total size: "+y(M(l)),s.type!=="asset"&&s.bytes&&"chunk size: "+y(M(s.bytes))].filter(Boolean).join(", ")})`;if(a+=s.exports?.length?`
93
+ exports: `+F(s.exports.join(", ")):"",s.chunks?.length&&(a+=`
94
+ ${s.chunks.map(i=>{const c=t.buildEntries.find(p=>p.path===i)??{};return F(" └─ "+n(i)+O(c.bytes?" ("+M(c?.bytes)+")":""))}).join(`
95
+ `)}`),s.modules&&s.modules.length>0){const i=s.modules.filter(c=>c.id.includes("node_modules")).sort((c,p)=>(p.bytes||0)-(c.bytes||0)).map(c=>F(" 📦 "+n(c.id)+O(c.bytes?" ("+M(c.bytes)+")":""))).join(`
96
+ `);a+=i.length>0?`
89
97
  inlined modules:
90
- `+c:""}if(t.options.declaration&&s.type==="entry"){let c=s.path.replace(/\.js$/,".d.ts"),l="commonjs";s.path.endsWith(".cjs")?c=s.path.replace(/\.cjs$/,".d.cts"):s.path.endsWith(".mjs")&&(l="module",c=s.path.replace(/\.mjs$/,".d.mts"));const p=t.buildEntries.find(d=>d.path.endsWith(c));if(p){let d;(t.options.declaration===!0||t.options.declaration==="compatible")&&!c.includes(".d.ts")&&(c=c.replace(l==="commonjs"?".d.c":".d.m",".d."),d=t.buildEntries.find(u=>u.path.endsWith(c))),i+=d&&l===o.type?`
98
+ `+i:""}if(t.options.declaration&&s.type==="entry"){let i=s.path.replace(/\.js$/,".d.ts"),c="commonjs";s.path.endsWith(".cjs")?i=s.path.replace(/\.cjs$/,".d.cts"):s.path.endsWith(".mjs")&&(c="module",i=s.path.replace(/\.mjs$/,".d.mts"));const p=t.buildEntries.find(u=>u.path.endsWith(i));if(p){let u;(t.options.declaration===!0||t.options.declaration==="compatible")&&!i.includes(".d.ts")&&(i=i.replace(c==="commonjs"?".d.c":".d.m",".d."),u=t.buildEntries.find(d=>d.path.endsWith(i))),a+=u&&c===o.type?`
91
99
  types:
92
- `+[p,d].map(u=>C(" └─ ")+O(r(u.path))+" (total size: "+v(_(u.bytes??0))+")").join(`
100
+ `+[p,u].map(d=>F(" └─ ")+O(n(d.path))+" (total size: "+y(M(d.bytes??0))+")").join(`
93
101
  `):`
94
- types: `+O(r(p.path))+" (total size: "+v(_(p.bytes??0))+")"}}n=!0,i+=`
102
+ types: `+O(n(p.path))+" (total size: "+y(M(p.bytes??0))+")"}}r=!0,a+=`
95
103
 
96
- `,e.raw(s.chunk?C(i):i)}return n&&e.raw("Σ Total dist size (byte size):",v(_(t.buildEntries.reduce((s,a)=>s+(a.bytes??0),0))),`
97
- `),n},"showSizeInformation"),Pr=$(async(e,t,o,r,n,s,a)=>{const i=Mo(n.preset??r.preset??"auto",t),c=Er(e,t,o,r,n,i,s,a);xt(y(c.rootDir,c.outDir));const l={buildEntries:[],dependencyGraphMap:new Map,hooks:At(),logger:e,mode:o,options:c,pkg:s,rootDir:t,tsconfig:a,usedImports:new Set,warnings:new Set};if(i.hooks&&l.hooks.addHooks(i.hooks),r.hooks&&l.hooks.addHooks(r.hooks),n.hooks&&l.hooks.addHooks(n.hooks),await l.hooks.callHook("build:prepare",l),!l.options.emitESM&&!l.options.emitCJS)throw new Error("Both emitESM and emitCJS are disabled. At least one of them must be enabled.");if(l.options.declaration&&a===void 0)throw new Error("Cannot build declaration files without a tsconfig.json");return l.options.emitESM===void 0&&l.logger.info("Emitting ESM bundles, is disabled."),l.options.emitCJS===void 0&&l.logger.info("Emitting CJS bundles, is disabled."),l.options.declaration||l.logger.info("Declaration files, are disabled."),l},"createContext"),_r=$(async e=>{const t=[];if(e.options.clean)for(const o of new Set(e.options.entries.map(r=>r.outDir).filter(Boolean).sort()))o===e.options.rootDir||e.options.rootDir.startsWith(o.endsWith("/")?o:`${o}/`)||t.some(r=>o.startsWith(r))||(t.push(o),e.logger.info(`Cleaning dist directory: \`./${S(e.options.rootDir,o)}\``),await Ne(o))},"cleanDistributionDirectories"),Mr=$(async(e,t,o)=>{await e.hooks.callHook("build:before",e),await Promise.all([nr(e,o),e.options.declaration&&sr(e,o)]),e.logger.success(jt(`Build succeeded for ${e.options.name}`));for await(const n of Ot(y(e.options.rootDir,e.options.outDir))){let s=e.buildEntries.find(a=>y(e.options.rootDir,e.options.outDir,a.path)===n.path);if(s||(s={chunk:!0,path:n.path},e.buildEntries.push(s)),!s.bytes){const a=await Ee(f(e.options.rootDir,e.options.outDir,n.path));s.bytes=a.size}}const r=Nr(e.logger,e,t);vr(e),kr(t,e),await e.hooks.callHook("build:done",e),ft(e,r)},"build"),bs=$(async(e,t,o={})=>{const{configPath:r,debug:n,tsconfigPath:s,...a}=o,i=[new Ft,new It];n&&i.push(new Rt);const c=Ct({logLevel:n?"debug":"informational",processors:i,scope:"packem"});e=f(bt(),e),c.debug("Root directory:",e);const l=y(e,"package.json"),p=Mt(l);c.debug("Using package.json found at",l);let d;if(s){const u=y(e,s);await Et(u)||(c.error("tsconfig.json not found at",u),F(1)),d={config:Pt(u),path:u},c.info("Using tsconfig settings at",u)}else try{d=await _t(e),c.debug("Using tsconfig settings found at",d.path)}catch{c.info("No tsconfig.json or jsconfig.json found.")}try{const u=r??"./packem.config.ts";/\.(?:js|mjs|cjs|ts)$/.test(u)||(c.error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts extensions are allowed."),F(1));const g=Ae(u,e);c.debug("Using packem config found at",y(e,u));const j=Date.now(),x=$(()=>St(Math.floor(Date.now()-j)),"getDuration"),N=M(p.version+JSON.stringify({...p.dependencies,...p.devDependencies,eNode:p.engines?.node})),w=new dr(e,N,c);w.cachePath&&!W(y(w.cachePath,N))&&W(w.cachePath)&&(c.info("Clearing file cache because the cache key has changed."),await Ne(w.cachePath));const h=await Pr(c,e,t,a,g,p,d);if(w.isEnabled=h.options.fileCache,await Sr(h,e),h.logger.info(v((t==="watch"?"Watching":t==="jit"?"Stubbing":"Building")+" "+h.options.name)),h.logger.debug(`${O("Root dir:")} ${h.options.rootDir}
104
+ `,e.raw(s.chunk?F(a):a)}return r&&e.raw("Σ Total dist size (byte size):",y(M(t.buildEntries.reduce((s,l)=>s+(l.bytes??0),0))),`
105
+ `),r},"showSizeInformation"),Jn=$(async(e,t,o,n,r,s,l,a)=>{const i=To(s.preset??r.preset??"auto",t),c=Tn(e,t,o,n,r,s,i,l,a);Dt(v(c.rootDir,c.outDir));const p={buildEntries:[],dependencyGraphMap:new Map,hooks:Jt(),logger:e,mode:o,options:c,pkg:l,rootDir:t,tsconfig:a,usedImports:new Set,warnings:new Set};if(i.hooks&&p.hooks.addHooks(i.hooks),r.hooks&&p.hooks.addHooks(r.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.");if(p.options.declaration&&a===void 0)throw new Error("Cannot build declaration files without a tsconfig.json");return 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."),p.options.declaration||p.logger.info("Declaration files, are disabled."),p},"createContext"),Ln=$(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||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 Pe(o))},"cleanDistributionDirectories"),zn=$(async(e,t,o)=>{await e.hooks.callHook("build:before",e);const n=On(e.options.entries,"environment","runtime"),r=[],s=[];for(const[a,i]of Object.entries(n))for(const[c,p]of Object.entries(i)){s.push(...p.filter(d=>d.declaration));const u={...e};a==="development"&&(u.options.minify=!1),e.options.rollup.replace?(e.options.rollup.replace.values={...e.options.rollup.replace.values,production:a},c==="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."),u.options.entries=p,r.push(ln(u,o))}if(e.options.declaration){const a={...e};a.options.entries=s,r.push(pn(a,o))}await Promise.all(r),e.logger.success(xt(`Build succeeded for ${e.options.name}`));for await(const a of Nt(v(e.options.rootDir,e.options.outDir))){let i=e.buildEntries.find(c=>v(e.options.rootDir,e.options.outDir,c.path)===a.path);if(i||(i={chunk:!0,path:a.path},e.buildEntries.push(i)),!i.bytes){const c=await Ne(g(e.options.rootDir,e.options.outDir,a.path));i.bytes=c.size}}const l=Bn(e.logger,e,t);Sn(e),Fn(t,e),await e.hooks.callHook("build:done",e),ht(e,l)},"build"),_s=$(async(e,t,o={})=>{const{configPath:n,debug:r,tsconfigPath:s,...l}=o,a=[new Tt,new At];r&&a.push(new Wt);const i=Rt({logLevel:r?"debug":"informational",processors:a,scope:"packem"});e=g(jt(),e),i.debug("Root directory:",e);const c=v(e,"package.json"),p=It(c);i.debug("Using package.json found at",c);let u;if(s){const d=v(e,s);await St(d)||(i.error("tsconfig.json not found at",d),I(1)),u={config:Ct(d),path:d},i.info("Using tsconfig settings at",d)}else try{u=await Ft(e),i.debug("Using tsconfig settings found at",u.path)}catch{i.info("No tsconfig.json or jsconfig.json found.")}try{const d=n??"./packem.config.ts";/\.(?:js|mjs|cjs|ts)$/.test(d)||(i.error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts extensions are allowed."),I(1));const f=Be(d,e);i.debug("Using packem config found at",v(e,d));const j=Date.now(),E=$(()=>Pt(Math.floor(Date.now()-j)),"getDuration"),_=C(p.version+JSON.stringify({...p.dependencies,...p.devDependencies,eNode:p.engines?.node})),w=new $n(e,_,i);w.cachePath&&!W(v(w.cachePath,_))&&W(w.cachePath)&&(i.info("Clearing file cache because the cache key has changed."),await Pe(w.cachePath));const h=await Jn(i,e,t,r??!1,l,f,p,u);if(w.isEnabled=h.options.fileCache,await Wn(h,e),h.logger.info(y((t==="watch"?"Watching":t==="jit"?"Stubbing":"Building")+" "+h.options.name)),h.logger.debug(`${O("Root dir:")} ${h.options.rootDir}
98
106
  ${O("Entries:")}
99
- ${h.options.entries.map(P=>` ${dt(P)}`).join(`
100
- `)}`),await _r(h),h.options.stub){await ho(h),await h.hooks.callHook("build:done",h);return}if(t==="watch"){await ar(h,w),ft(h,!1);return}await Mr(h,p,w),c.raw(`
101
- ⚡️ Build run in `+x()),c.restoreAll(),F(0)}catch(u){c.error("An error occurred while building",u),F(1)}},"createBundler");export{bs as default};
107
+ ${h.options.entries.map(P=>` ${ft(P)}`).join(`
108
+ `)}`),await Ln(h),h.options.stub){await $o(h),await h.hooks.callHook("build:done",h);return}if(t==="watch"){if(h.options.rollup.watch===!1)throw new Error("Rollup watch is disabled. You should check your packem.config file.");await gn(h,w),ht(h,!1);return}await zn(h,p,w),i.raw(`
109
+ ⚡️ Build run in `+E()),i.restoreAll(),I(0)}catch(d){dt(d),i.error("An error occurred while building",d),I(1)}},"createBundler");export{_s as default};
@@ -0,0 +1 @@
1
+ "use strict";var $=Object.defineProperty;var g=(e,r)=>$(e,"name",{value:r,configurable:!0});const _=require("node:fs"),P=require("@rollup/pluginutils"),h=require("@visulima/path"),v=require("esbuild"),x=require("../../../shared/packem.NVRVuzg1.cjs"),z=require("../../../shared/packem.CEXB7aOL.cjs"),R=require("node:fs/promises"),F=require("@visulima/package"),j=require("es-module-lexer");var L=Object.defineProperty,S=g((e,r)=>L(e,"name",{value:r,configurable:!0}),"t$1");const k=S(async(e,r)=>{r.length>0&&(await v.formatMessages(r,{color:!0,kind:"warning"})).forEach(c=>e.warn(c))},"warn");var W=Object.defineProperty,q=g((e,r)=>W(e,"name",{value:r,configurable:!0}),"t");const A=q(e=>{if(e==="es")return"esm";if(e==="cjs")return e},"getEsbuildFormat"),C=q(({sourceMap:e=!0,...r})=>async function(c,o,i){if(r.minify||r.minifyWhitespace||r.minifyIdentifiers||r.minifySyntax){const n=A(i.format),l=await v.transform(c,{format:n,loader:"js",sourcemap:e,...r});if(await k(this,l.warnings),l.code)return{code:l.code,map:l.map||null}}return null},"getRenderChunk");var I=Object.defineProperty,O=g((e,r)=>I(e,"name",{value:r,configurable:!0}),"o");const E=O(e=>e.replaceAll("\\","/"),"slash"),U=O(async e=>{const r=await F.findCacheDirectory("packem/optimize_deps",{create:!0,cwd:e.cwd});if(!r)throw new Error('[packem:optimize-deps]: failed to find or create cache directory "node_modules/.cache/packem/optimize_deps".');await j.init,await v.build({absWorkingDir:e.cwd,bundle:!0,entryPoints:e.include,format:"esm",ignoreAnnotations:!0,metafile:!0,outdir:r,sourcemap:e.sourceMap,splitting:!0,...e.esbuildOptions,plugins:[{name:"optimize-deps",async setup(o){o.onResolve({filter:/.*/},async i=>{if(e.exclude?.includes(i.path))return{external:!0};if(i.pluginData?.__resolving_dep_path__)return null;if(e.include.includes(i.path)){const n=await o.resolve(i.path,{kind:"import-statement",pluginData:{__resolving_dep_path__:!0},resolveDir:i.resolveDir});return n.errors.length>0||n.warnings.length>0?n:{namespace:"optimize-deps",path:i.path,pluginData:{absolute:n.path,resolveDir:i.resolveDir}}}return null}),o.onLoad({filter:/.*/,namespace:"optimize-deps"},async i=>{const{absolute:n,resolveDir:l}=i.pluginData,p=await R.readFile(n,"utf8"),[,f]=j.parse(p);return{contents:f.length>0?`export * from '${E(n)}'`:`module.exports = require('${E(n)}')`,resolveDir:l}})}},...e.esbuildOptions?.plugins||[]]});const c=new Map;for(const o of e.include)c.set(o,{file:h.join(r,`${o}.js`)});return{cacheDir:r,optimized:c}},"optimizeDeps");var X=Object.defineProperty,G=g((e,r)=>X(e,"name",{value:r,configurable:!0}),"w");const T=G(({exclude:e,include:r,loaders:c,logger:o,optimizeDeps:i,sourceMap:n=!0,...l})=>{const p=x.DEFAULT_LOADERS;if(c!==void 0)for(let[t,s]of Object.entries(c))t=t.startsWith(".")?t:`.${t}`,typeof s=="string"?p[t]=s:s||delete p[t];const f=Object.keys(p),M=new RegExp(`\\.(${f.map(t=>t.slice(1)).join("|")})$`),y=P.createFilter(r??M,e??x.EXCLUDE_REGEXP);let d,D=process.cwd();const w=new Map;return{async buildStart(){!i||d||(d=await U({cwd:D,sourceMap:n,...i}),o.debug("optimized %O",d.optimized))},name:"esbuild",options({context:t}){return t&&(D=t),null},renderChunk:C({...l,sourceMap:n}),async resolveId(t,s,{isEntry:b}){if(!s||b||!y(t)||t.startsWith("\0"))return null;if(d?.optimized.has(t)){const a=d.optimized.get(t);if(a)return o.debug("resolved %s to %s",t,a.file),a.file}const u=w.get(t);if(u!==void 0)return u;if(s&&t.startsWith(".")){const a=h.resolve(s?h.dirname(s):process.cwd(),t);let m=z.x(f,a);if(m||!m&&_.existsSync(a)&&_.statSync(a).isDirectory()&&(m=z.x(f,a,!0),m))return w.set(t,m),m}return w.set(t,null),null},async transform(t,s){if(!y(s)||d?.optimized.has(s))return null;const b=h.extname(s),u=p[b];if(o.debug("transforming %s with %s loader",s,u),!u)return null;const a=await v.transform(t,{format:["base64","binary","dataurl","text","json"].includes(u)?"esm":void 0,loader:u,sourcefile:s.replace(/\.[cm]ts/,".ts"),sourcemap:n,...l});return await k(this,a.warnings),a.code?{code:a.code,map:a.map||null}:null}}},"default");module.exports=T;
@@ -0,0 +1,9 @@
1
+ import { Plugin } from 'rollup';
2
+ import { E as EsbuildPluginConfig } from '../../../shared/packem.D09xRBAa.cjs';
3
+ import '@rollup/pluginutils';
4
+ import '@visulima/pail';
5
+ import 'esbuild';
6
+
7
+ declare const _default: ({ exclude, include, loaders: _loaders, logger, optimizeDeps, sourceMap, ...esbuildOptions }: EsbuildPluginConfig) => Plugin;
8
+
9
+ export { _default as default };
@@ -0,0 +1 @@
1
+ "use strict";var y=Object.defineProperty;var l=(n,r)=>y(n,"name",{value:r,configurable:!0});const f=require("node:fs"),q=require("@rollup/pluginutils"),d=require("@visulima/path"),x=require("sucrase"),p=require("../../../shared/packem.NVRVuzg1.cjs"),E=require("../../../shared/packem.CEXB7aOL.cjs");var g=Object.defineProperty,h=l((n,r)=>g(n,"name",{value:r,configurable:!0}),"f");const F=h(({exclude:n,extensions:r=p.DEFAULT_EXTENSIONS,include:m,...v})=>{const a=q.createFilter(m,n??p.EXCLUDE_REGEXP),c=new Map;return{async resolveId(e,t,{isEntry:u}){if(!t||u||!a(e)||e.startsWith("\0"))return null;const i=c.get(e);if(i!==void 0)return i;if(t&&e.startsWith(".")){const o=d.resolve(t?d.dirname(t):process.cwd(),e);let s=E.x(r,o);if(s||!s&&f.existsSync(o)&&f.statSync(o).isDirectory()&&(s=E.x(r,o,!0),s))return c.set(e,s),s}return c.set(e,null),null},async transform(e,t){if(!a(t))return null;const{code:u,sourceMap:i}=x.transform(e,{...v,filePath:t,sourceMapOptions:{compiledFilename:t}});return{code:u,map:i}}}},"sucrasePlugin");module.exports=F;
@@ -0,0 +1,8 @@
1
+ import { Plugin } from 'rollup';
2
+ import { S as SucrasePluginConfig } from '../../../shared/packem.DvWhOdt5.cjs';
3
+ import '@rollup/pluginutils';
4
+ import 'sucrase';
5
+
6
+ declare const sucrasePlugin: ({ exclude, extensions, include, ...transformOptions }: SucrasePluginConfig) => Plugin;
7
+
8
+ export { sucrasePlugin as default };