@visulima/packem 1.0.0-alpha.23 → 1.0.0-alpha.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- var rt=Object.defineProperty;var d=(e,t)=>rt(e,"name",{value:t,configurable:!0});import{chmod as nt,stat as $e,readdir as st}from"node:fs/promises";import ie from"node:module";import{env as F,exit as M,versions as it,cwd as at}from"node:process";import{cyan as y,gray as P,bold as O,grey as lt,green as pt}from"@visulima/colorize";import{readFile as X,writeFile as T,readFileSync as ct,writeFileSync as ut,writeJsonSync as mt,collectSync as dt,isAccessibleSync as ft,ensureDirSync as gt,emptyDir as ht,walk as yt,isAccessible as vt}from"@visulima/fs";import{NotFoundError as bt}from"@visulima/fs/error";import{formatBytes as _,duration as $t}from"@visulima/humanizer";import{readTsConfig as jt,findTSConfig as wt}from"@visulima/package";import{parsePackageJson as kt}from"@visulima/package/package-json";import{createPail as xt}from"@visulima/pail";import{MessageFormatterProcessor as Et,ErrorProcessor as Ot,CallerProcessor as Dt}from"@visulima/pail/processor";import{resolve as g,join as E,normalize as B,extname as Y,relative as N,dirname as K,basename as J,isAbsolute as je}from"@visulima/path";import{defu as St}from"defu";import{createHooks as Nt}from"hookable";import{a as I,E as ae}from"./shared/packem.CxExFSHU.mjs";import{pathToFileURL as _t,fileURLToPath as Pt}from"node:url";import{resolvePath as Mt,resolveModuleExportNames as Ct,findStaticImports as we}from"mlly";import S from"magic-string";import ke from"jiti";import{rollup as xe,watch as le}from"rollup";import Ee from"@rollup/plugin-alias";import It from"@rollup/plugin-commonjs";import Ft from"@rollup/plugin-dynamic-import-vars";import{nodeResolve as Oe}from"@rollup/plugin-node-resolve";import De from"@rollup/plugin-replace";import{wasm as Rt}from"@rollup/plugin-wasm";import Tt from"rollup-plugin-polyfill-node";import{visualizer as At}from"rollup-plugin-visualizer";import{minVersion as Se}from"semver";import{glob as Wt}from"glob";import Bt from"glob-parent";import Jt from"@rollup/plugin-json";import{createFilter as Q,normalizePath as pe}from"@rollup/pluginutils";import Lt from"rollup-plugin-license";import{parse as zt}from"@babel/parser";import{existsSync as Z}from"node:fs";import{distance as Ut}from"fastest-levenshtein";
1
+ import"node:fs/promises";import"node:module";import"node:process";import"@visulima/colorize";import"@visulima/fs";import"@visulima/fs/error";import"@visulima/humanizer";import"@visulima/package";import"@visulima/package/package-json";import"@visulima/pail";import"@visulima/pail/processor";import"@visulima/path";import"defu";import"hookable";import{O as g}from"./shared/packem.Bou2wg-L.mjs";import"./shared/packem.CxExFSHU.mjs";
2
2
  // -- pack CommonJS Shims --
3
3
  import __cjs_url__ from "node:url";
4
4
  import __cjs_path__ from "node:path";
@@ -6,96 +6,4 @@ 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 Ht=Object.defineProperty,L=d((e,t)=>Ht(e,"name",{value:t,configurable:!0}),"i$a");const ee=/^#![^\n]*/,q=L(async e=>{await nt(e,493).catch(()=>{})},"makeExecutable"),qt=L((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 S(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"&&ee.test(s.code)&&o.dir){const i=g(o.dir,n);await q(i)}}}),"shebangPlugin"),Vt=L(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(ee,"")}}),"removeShebangPlugin"),Gt=L((e,t=`
11
- `)=>{const o=ee.exec(e);return o?o+t:""},"getShebang");var Xt=Object.defineProperty,Yt=d((e,t)=>Xt(e,"name",{value:t,configurable:!0}),"p$1");const te=Yt((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]=E(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 Kt=Object.defineProperty,Qt=d((e,t)=>Kt(e,"name",{value:t,configurable:!0}),"o$3");const Zt=Qt((e,t)=>{const o=ke(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 eo=Object.defineProperty,to=d((e,t)=>eo(e,"name",{value:t,configurable:!0}),"r$8");const R=to((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var oo=Object.defineProperty,ro=d((e,t)=>oo(e,"name",{value:t,configurable:!0}),"u$6");const no=ro(async e=>{const t=await Mt("jiti",{url:import.meta.url}),o=JSON.stringify({...e.options.stubOptions.jiti,alias:{...te(e,"jit"),...e.options.stubOptions.jiti.alias}},null,2);for(const r of e.options.entries){const n=g(e.options.rootDir,e.options.outDir,r.name),s=B(Zt(r.input,e.options.rootDir)||r.input),i=s.slice(0,Math.max(0,s.length-Y(s).length)),l=await X(s),c=Gt(l);e.options.emitCJS&&await T(`${n}.cjs`,c+[`const jiti = require(${JSON.stringify(t)})`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(i)})} */`,`module.exports = _jiti(${JSON.stringify(s)})`].join(`
12
- `));let p=[];try{p=await Ct(s,{extensions:I})}catch(u){R(e,`Cannot analyze ${s} for exports:${u}`);return}const a=p.includes("default")||p.length===0;await T(`${n}.mjs`,c+[`import jiti from ${JSON.stringify(_t(t).href)};`,"",`const _jiti = jiti(null, ${o})`,"",`/** @type {import(${JSON.stringify(s)})} */`,`const _module = await _jiti.import(${JSON.stringify(s)});`,a?`
13
- export default _module;`:"",...p.filter(u=>u!=="default").map(u=>`export const ${u} = _module.${u};`)].join(`
14
- `)),await T(`${n}.d.cts`,[`export * from ${JSON.stringify(i)};`,a?`export { default } from ${JSON.stringify(i)};`:""].join(`
15
- `)),await T(`${n}.d.mts`,[`export * from ${JSON.stringify(s)};`,a?`export { default } from ${JSON.stringify(s)};`:""].join(`
16
- `)),c&&(await q(`${n}.cjs`),await q(`${n}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var so=Object.defineProperty,io=d((e,t)=>so(e,"name",{value:t,configurable:!0}),"a$b");const V=io((e,t)=>e.some(o=>o instanceof RegExp?o.test(t):o===t),"arrayIncludes");var ao=Object.defineProperty,lo=d((e,t)=>ao(e,"name",{value:t,configurable:!0}),"a$a");const z=lo(e=>e===void 0?[]:Array.isArray(e)?e:[e],"arrayify");var po=Object.defineProperty,co=d((e,t)=>po(e,"name",{value:t,configurable:!0}),"e$1");const G=co((e="")=>{const t=e.split("/");return t[0][0]==="@"?`${t[0]}/${t[1]}`:t[0]},"getPackageName");var uo=Object.defineProperty,Ne=d((e,t)=>uo(e,"name",{value:t,configurable:!0}),"s$c");const mo=Ne((e,t,o)=>{const r=o??new Map;return(...n)=>{const s=t?typeof t=="function"?t(...n):t:JSON.stringify({args:n}),i=r.get(s);if(i!==void 0)return i;const l=e(...n);return r.set(s,l),l}},"memoize"),fo=Ne(e=>{const t=new Map;return o=>mo(e,o,t)},"memoizeByKey");var go=Object.defineProperty,ho=d((e,t)=>go(e,"name",{value:t,configurable:!0}),"m$5");const _e=ho(({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 i=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(r);if(i===null||i.length<3)return null;const l=new S(r);l.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),l.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&l.append(`
17
- module.exports.default = `+i[2]+";");let c=l.toString();return c=c.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+n.fileName+".",prefix:"plugin:cjs-interop"}),{code:c,map:l.generateMap({hires:!0})}}if(s.format==="es"&&/\.d\.(?:ts|cts)$/.test(n.fileName)){if(o!=="commonjs"&&n.fileName.endsWith(".d.ts"))return null;const i=/export\s\{\s(.*)\s\}/i.exec(r);if(i===null||i.length<2)return null;const l=i[1].split(", "),c=[];let p="";for(const u of l)if(!u.includes("type"))if(u.includes("as")){const[m,f]=u.split(" as ");if(f==="default"&&(p=m,!e))continue;c.push(f+": typeof "+m+";")}else c.push(u+": typeof "+u+";");const a=new S(r);return a.replace(" "+p+" as default,",""),a.append(`
18
-
19
- declare const defaultExport: {
20
- `+(c.length>0?" ":"")+c.join(`
21
- `)+`
22
- } & typeof `+p+`;
23
-
24
- export default defaultExport;`),t.debug({message:"Applied CommonJS interop to entry chunk "+n.fileName+".",prefix:"plugin:cjs-interop"}),{code:a.toString(),map:a.generateMap({hires:!0})}}return null}}),"cjsInterop");var yo=Object.defineProperty,vo=d((e,t)=>yo(e,"name",{value:t,configurable:!0}),"f$7");const bo=vo((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(i=>Array.isArray(i.src)?i.src.map(l=>({...i,src:l})):i).map(async i=>await Wt(i.src,{ignore:i.exclude}).then(l=>({dest:i.dest??"",parent:Bt(i.src),src:l}))));for(const i of s)for(const l of i.src){let c;o.has(l)?c=o.get(l):(c={copied:[],dest:[],timestamp:0},o.set(l,c));const p=r.flatten?B(i.dest):E(i.dest,N(i.parent,K(l)));c.dest.includes(p)||c.dest.push(p),this.addWatchFile(l)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...o].map(async([i,l])=>{let c;try{const p=await $e(i);if(!p.isFile())return;const a=p.mtime.getTime();a>l.timestamp&&(l.timestamp=a,l.copied=[]),c=await X(i,{buffer:!0})}catch(p){t.error({context:[p],message:`error reading file ${i}`,prefix:"plugin:copy"});return}for(const p of l.dest){if(r.copyOnce&&l.copied.includes(p))continue;const a=J(i),u=E(p,a);try{this.emitFile({[r.exactFileNames?"fileName":"name"]:u,source:c,type:"asset"}),t.debug({message:`copied ${i} → ${u}`,prefix:"plugin:copy"}),l.copied.push(p)}catch(m){t.error({context:[m],message:`error copying file ${i} → ${u}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var $o=Object.defineProperty,jo=d((e,t)=>$o(e,"name",{value:t,configurable:!0}),"n$7");const ce="export default ",Pe=jo(e=>{const t=Jt(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(ce)&&(n.code=n.code.replace(ce,"module.exports = ")),n}}},"JSONPlugin");class wo{static{d(this,"WalkerBase")}constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:d(()=>this.should_skip=!0,"skip"),remove:d(()=>this.should_remove=!0,"remove"),replace:d(t=>this.replacement=t,"replace")}}replace(t,o,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 wo{static{d(this,"SyncWalker")}constructor(t,o){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:d(()=>this.should_skip=!0,"skip"),remove:d(()=>this.should_remove=!0,"remove"),replace:d(r=>this.replacement=r,"replace")},this.enter=t,this.leave=o}visit(t,o,r,n){if(t){if(this.enter){const i=this.should_skip,l=this.should_remove,c=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,o,r,n),this.replacement&&(t=this.replacement,this.replace(o,r,n,t)),this.should_remove&&this.remove(o,r,n);const p=this.should_skip,a=this.should_remove;if(this.should_skip=i,this.should_remove=l,this.replacement=c,p)return t;if(a)return null}let s;for(s in t){const i=t[s];if(i&&typeof i=="object")if(Array.isArray(i)){const l=i;for(let c=0;c<l.length;c+=1){const p=l[c];ue(p)&&(this.visit(p,t,s,c)||c--)}}else ue(i)&&this.visit(i,t,s,null)}if(this.leave){const i=this.replacement,l=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=i,this.should_remove=l,c)return null}}return t}}function ue(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}d(ue,"isNode");function Me(e,{enter:t,leave:o}){return new ko(t,o).visit(e,null)}d(Me,"walk");var xo=Object.defineProperty,Eo=d((e,t)=>xo(e,"name",{value:t,configurable:!0}),"u$4");const Oo=Eo(({attributes:e,logger:t})=>{const o=Q([/\.[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 i=!1;const l=new S(r);return Me(s,{enter(c){if(c.type==="CallExpression"&&c.callee.type==="Identifier"&&c.callee.name==="jsx"){const p=c.arguments.filter(a=>a.type==="ObjectExpression"&&Array.isArray(a.properties));for(const a of p)for(const u of a.properties)u.type==="Property"&&u.key.type==="Literal"&&u.value.type==="Literal"&&e.includes(u.key.value)&&(l.overwrite(u.start-2,u.end,""),i=!0)}}}),i?{code:l.toString(),map:l.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var Do=Object.defineProperty,oe=d((e,t)=>Do(e,"name",{value:t,configurable:!0}),"p");const So=oe(e=>{const t=[],o=[];return e.forEach(r=>{r.startsWith("(")?t.push(r):o.push(r)}),[...o.sort(),...t.sort()]},"sortLicenses"),No=oe((e,t,o)=>{const r=new RegExp(`(<!-- ${t} -->)[\\s\\S]*?(<!-- ${t} -->)`,"g");if(r.test(e))return e.replace(r,`$1
25
- ${o}
26
- $2`)},"replaceContentWithin"),Ce=oe(({licenseFilePath:e,licenseTemplate:t,logger:o,marker:r,mode:n,packageName:s})=>Lt({thirdParty(i){const l=new Set,c=i.sort(({name:a},{name:u})=>a>u?1:u>a?-1:0).map(({author:a,contributors:u,license:m,licenseText:f,maintainers:h,name:j,repository:b})=>{let w="## "+j+`
27
- `;m&&(w+=`License: ${m}
28
- `);const k=new Set;for(const x of[a,...h,...u]){const se=typeof x=="string"?x:x?.name;se&&k.add(se)}return k.size>0&&(w+=`By: ${[...k].join(", ")}
29
- `),b&&(w+=`Repository: ${typeof b=="string"?b:b.url}
30
- `),f&&(w+=`
31
- `+f.trim().replaceAll(/(\r\n|\r)/g,`
32
- `).split(`
33
- `).map(x=>`> ${x}`).join(`
34
- `)+`
35
- `),m&&l.add(m),w}).join(`
36
- ---------------------------------------
37
-
38
- `);if(c===""){o.info({message:"No dependencies license information found.",prefix:"plugin:license:"+n});return}const p=t(So(l),c,s);try{const a=ct(e),u=No(a,r,p);if(!u){o.error({message:`Could not find the license marker: <!-- ${r} --> in ${e}`,prefix:"plugin:license:"+n});return}a!==u&&(ut(e,u),o.info({message:`${e} updated.`,prefix:"plugin:license:"+n}))}catch(a){o.error(a)}}}),"license");var _o=Object.defineProperty,Po=d((e,t)=>_o(e,"name",{value:t,configurable:!0}),"i$7");const Mo=Po(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=g(e.outDir,"graph.json");mt(o,t)},name:"packem:metafile"}),"metafilePlugin");var Co=Object.defineProperty,Io=d((e,t)=>Co(e,"name",{value:t,configurable:!0}),"c$4");const Fo=/\.(?:m|c)?(?:j|t)sx?$/,Ro=/^use \w+$/,To=Io(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 i=n.moduleIds.map(p=>t[p]?t[p]:null).reduce((p,a)=>(a&&a.forEach(u=>{p.add(u)}),p),new Set),l=new S(r);i.size>0&&(e.debug({message:`directives for chunk "${n.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),l.prepend(`${[...i].map(p=>`'${p}';`).join(`
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"}),l.prepend(`${c}
41
- `)),i.size===0&&c===null?null:{code:l.toString(),map:s?l.generateMap({hires:!0}):null}},order:"post"},transform:{handler(r,n){const s=Y(n);if(!Fo.test(s))return null;let i=!1;const l=new S(r);if(r.startsWith("#")&&r[1]==="!"){let p=0;for(let a=2,u=r.length;a<u;a++){const m=r.codePointAt(a);if(m===10||m===13||m===8232||m===8233){p=a;break}}p&&(o[n]=r.slice(0,p),l.remove(0,p+1),i=!0,e.debug({message:`shebang for module "${n}" is preserved.`,prefix:"plugin:preserve-directives"}))}let c=null;try{c=this.parse(l.toString(),{allowReturnOutsideFunction:!0})}catch(p){return this.warn({code:"PARSE_ERROR",message:`[packem:preserve-directives]: failed to parse "${n}" and extract the directives.`}),e.warn(p),null}if(c.type!=="Program")return null;for(const p of c.body.filter(Boolean)){if(p.type!=="ExpressionStatement")break;let a=null;"directive"in p?a=p.directive:p.expression.type==="Literal"&&typeof p.expression.value=="string"&&Ro.test(p.expression.value)&&(a=p.expression.value),a!=="use strict"&&a&&(t[n]||=new Set,t[n].add(a),"start"in p&&typeof p.start=="number"&&"end"in p&&typeof p.end=="number"&&(l.remove(p.start,p.end),i=!0),e.debug({message:`directive "${a}" for module "${n}" is preserved.`,prefix:"plugin:preserve-directives"}))}return i?{code:l.toString(),map:l.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...t[n]??[]],shebang:o[n]??null}}}:null},order:"post"}}},"preserveDirectives");var Ao=Object.defineProperty,Wo=d((e,t)=>Ao(e,"name",{value:t,configurable:!0}),"r$6");const Bo={exclude:[],include:[/\.(md|txt|css|htm|html)$/]},Jo=Wo((e={})=>{e={...e,...Bo};const t=Q(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 Lo=Object.defineProperty,zo=d((e,t)=>Lo(e,"name",{value:t,configurable:!0}),"l$5");const U="\0__file_url__",Ie=zo(()=>({async load(e){if(e.startsWith(U)){const t=Pt(e.slice(U.length));return await X(t)}},name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return`${U}${e}`}}),"resolveFileUrl");var Uo=Object.defineProperty,Fe=d((e,t)=>Uo(e,"name",{value:t,configurable:!0}),"i$4");const Ho=/__filename|__dirname|require\(|require\.resolve\(/,Re=`
42
- // -- pack CommonJS Shims --
43
- import __cjs_url__ from "node:url";
44
- import __cjs_path__ from "node:path";
45
- import __cjs_mod__ from "node:module";
46
- const __filename = __cjs_url__.fileURLToPath(import.meta.url);
47
- const __dirname = __cjs_path__.dirname(__filename);
48
- const require = __cjs_mod__.createRequire(import.meta.url);
49
- `,Te=`
50
- // -- pack CommonJS Shims Node 20.11 --
51
- import __cjs_mod__ from "node:module";
52
- const __filename = import.meta.filename;
53
- const __dirname = import.meta.dirname;
54
- const require = __cjs_mod__.createRequire(import.meta.url);
55
- `,qo=Fe((e,t)=>{if(F.INTERNAL_PACKEM_BUILD!=="1"&&(e.includes(Re)||e.includes(Te)||!Ho.test(e)))return null;const o=we(e).pop(),r=o?o.end:0,n=new S(e);return n.appendRight(r,t),{code:n.toString(),map:n.generateMap()}},"CJSToESM"),Vo=Fe(e=>({name:"packem:cjs",renderChunk(t,o,r){if(r.format==="es"){let n=Re;if(e.engines?.node){const s=Se(e.engines.node);s&&s.major>=20&&s.minor>=11&&(n=Te)}return qo(t,n)}return null}}),"cjsPlugin");var Go=Object.defineProperty,C=d((e,t)=>Go(e,"name",{value:t,configurable:!0}),"s$9");const Xo=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,Yo=/MIT License|MIT license|BSD license/,Ko=/\n{2,}/g,Qo=/\b(\w+)\$\d+\b/g,Zo=/[-/\\^$*+?.()|[\]{}]/g,er=C(e=>e.replaceAll(Zo,"\\$&"),"escapeRegex"),tr=C(e=>[...new Set(e)],"unique"),or=C(e=>e.replaceAll(Xo,t=>Yo.test(t)?"":t).replaceAll(Ko,`
56
-
57
- `),"cleanUnnecessaryComments"),me=new Map;function Ae(e,t,{identifierReplacements:o},r){const n=we(e);for(const i in o){const l=n.find(p=>p.specifier===i&&p.imports.includes("{"));if(!l){this.warn(`${t.fileName} does not import "${i}" for replacement`),process.exitCode=1;continue}const c=o[i];for(const p in c){l.imports.includes(p)||(this.warn(`${t.fileName} does not import "${p}" from "${i}" for replacement`),M(1));const a=c[p],u=er(p);a.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${u},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${u}\\b`,"g"),a)}}const s=tr(Array.from(e.matchAll(Qo),i=>i[0]));if(s.length>0){const i=s.map(c=>`
58
- - ${c}`).join(""),l=t.fileName.replace(/\.[^/.]+$/,"");me.has(l)||r.warn({message:`${t.fileName} contains confusing identifier names${i}
59
-
60
- To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),me.set(l,!0)}return e}d(Ae,"v$2");C(Ae,"replaceConfusingTypeNames");function We(e,t){if(t.leadingComments?.some(o=>o.type==="CommentBlock"&&o.value.includes("@internal"))){const o=e.original[t.end]===","?t.end+1:t.end;return e.remove(t.leadingComments[0].start,o),!0}return!1}d(We,"N$1");C(We,"removeInternal");function Be(e,t){if(e.includes("@internal")){const o=new S(e),r=zt(e,{plugins:["typescript"],sourceType:"module"});Me(r,{enter(n){We(o,n)&&this.skip()}}),e=o.toString(),e.includes("@internal")&&(this.warn(`${t.fileName} has unhandled @internal declarations`),M(1))}return e}d(Be,"S");C(Be,"stripInternalTypes");const rr=C((e,t)=>({name:"packem:patch-types",renderChunk(o,r){return o=Ae.call(this,o,r,e,t),o=Be.call(this,o,r),o=or(o),o},resolveId(o){return o.startsWith("types/")?{external:!0,id:"../../"+(o.endsWith(".js")?o:o+".js")}:null}}),"patchTypescriptTypes");var nr=Object.defineProperty,Je=d((e,t)=>nr(e,"name",{value:t,configurable:!0}),"u$2");const Le=Je((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 i=g(K(r),n),l=[];if(s)for(const[c,p]of Object.entries(s)){const a=new RegExp(`^${[...c].map(m=>m==="*"?"(.+)":m.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let u=0;for(const m of p){const f=[...pe(g(i,m))].map(h=>h==="*"?`$${++u}`:h==="$"?"$$":h).join("");l.push({find:a,replacement:f})}}return t&&l.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...pe(i)].map(c=>c==="$"?"$$":c).join("")}/$1`}),l},"getConfigAlias"),ze=Je((e,t)=>{const o=Le(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(r,n,s){if(!o||r.includes("\0"))return null;for(const{find:i,replacement:l}of o)if(i.test(r)){const c=r.replace(i,l),p=await this.resolve(c,n,{skipSelf:!0,...s});if(p)return t.debug({message:`Resolved ${r} to ${p.id} using paths from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-paths"}),p.id}return null}}},"resolveTsconfigPaths");var sr=Object.defineProperty,Ue=d((e,t)=>sr(e,"name",{value:t,configurable:!0}),"u$1");const ir=Ue((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 i of n){if(i.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${r}.`);if(i.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${r}.`);s.push(g(e,i))}return s},"getRootDirectories"),He=Ue((e,t,o)=>{const r=ir(e,o);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(n,s,i){if(r===null||r.length===0)return null;if(n.startsWith("."))for(const l of r){const c=E(l,n),p=await this.resolve(c,s,{skipSelf:!0,...i});if(p)return t.debug({message:`Resolved ${n} to ${p.id} using rootDirs from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-root-dirs"}),p.id}return null}}},"resolveTsconfigRootDirectories");var ar=Object.defineProperty,lr=d((e,t)=>ar(e,"name",{value:t,configurable:!0}),"r$5");const qe=lr(()=>{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 pr=Object.defineProperty,cr=d((e,t)=>pr(e,"name",{value:t,configurable:!0}),"s$8");const ur=cr(e=>{const t=J(e).split(".");if(t.length>=2){const[o,r]=t.slice(-2),n=t[0],s=/^(\w+)-runtime$/.exec(o)?.[1];if(I.includes(r)&&s&&s.length>0)return n+"-"+s}},"getCustomModuleLayer");var mr=Object.defineProperty,dr=d((e,t)=>mr(e,"name",{value:t,configurable:!0}),"i$3");const H=dr(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var fr=Object.defineProperty,de=d((e,t)=>fr(e,"name",{value:t,configurable:!0}),"c$2");const fe=de((e,t)=>{const o=new Map;return de(function(r,n){const s=n.getModuleInfo(r);if(!s)return;const{isEntry:i}=s,l=s.meta,c=H(l);if(!i){const p=o.get(r);if(p)return p;const a=ur(r);if(a)return o.set(r,a),a}if(i){const p=n.getModuleIds();for(const a of p)n.getModuleInfo(a)&&H(l)===c&&(e.has(a)||e.set(a,new Set),e.get(a).add([r,c]))}if(c&&!i&&e.has(r)){const p=[...e.get(r)];if(p.some(([u])=>{if(t.some(m=>m.path===u)){const m=n.getModuleInfo(u);return H(m?m.meta:{})===c}return!1}))return;if(p.every(([,u])=>u===c))return o.has(r)?o.get(r):void 0;const a=`${J(r,Y(r))}-${c}`;return o.set(r,a),a}},"splitChunks")},"createSplitChunks");var gr=Object.defineProperty,hr=d((e,t)=>gr(e,"name",{value:t,configurable:!0}),"n$5");const D=hr((e,t,o)=>t.isDynamicEntry?`chunks/[name].${o}`:`shared/${e.options.name}.[hash].${o}`,"getChunkFilename");var yr=Object.defineProperty,vr=d((e,t)=>yr(e,"name",{value:t,configurable:!0}),"s$6");const br=process.platform==="win32",ge=vr((e,t)=>{const o=br?"\\":"/";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 $r=Object.defineProperty,v=d((e,t)=>$r(e,"name",{value:t,configurable:!0}),"l$4");const jr=v((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"+it.node.split(".")[0];if(t.pkg.engines?.node){const r=Se(t.pkg.engines.node);r&&(o="node"+r.major)}if(t.options.rollup.esbuild.target){const r=z(t.options.rollup.esbuild.target);r.some(n=>n.startsWith("node"))||(t.options.rollup.esbuild.target=[...new Set([...z(o),...r])])}else t.options.rollup.esbuild.target=z(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"),Ve=v((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(N(g(),e.id))}"
61
- Is the module installed? Note:
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"),he=new Map,Ge=v((e,t,o)=>{const r=v(s=>{for(const[i,l]of Object.entries(t))if(s.startsWith(i))return s.replace(i,l)},"findAlias"),n=Le(e.tsconfig,!1);return{external(s){const i=r(s);i&&(s=i);const l=G(s),c=V(e.options.externals,l)||V(e.options.externals,s);if(c)return!0;if(s.startsWith(".")||je(s)||/src[/\\]/.test(s)||e.pkg.name&&s.startsWith(e.pkg.name))return!1;if(n){for(const{find:p}of n)if(p.test(s))return e.logger.debug({message:`Resolved alias ${s} to ${p.source}`,prefix:o}),!1}return!c&&!he.has(s)&&e.logger.info({message:'Inlined implicit external "'+y(s)+'". If this is incorrect, add it to the "externals" option.',prefix:o}),he.set(s,!0),c},input:Object.fromEntries(e.options.entries.map(s=>[s.name,g(e.options.rootDir,s.input)])),onLog:v((s,i)=>{let l=i.message;switch(i.stack&&(l=`${l}
64
- ${i.stack}`),s){case"info":{e.logger.info({message:l,prefix:o+(i.plugin?":plugin:"+i.plugin:"")});return}case"warn":{e.logger.warn({message:l,prefix:o+(i.plugin?":plugin:"+i.plugin:"")});return}case"debug":e.logger.debug({message:l,prefix:o+(i.plugin?":plugin:"+i.plugin:"")})}},"onLog"),onwarn(s,i){Ve(s,e)||s.code||i(s)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),Xe=v(async e=>{const t=te(e,"build");let o;return e.options.rollup.resolve&&(o=Oe({extensions:I,...e.options.rollup.resolve})),{...Ge(e,t,"dependencies"),output:[e.options.emitCJS&&{chunkFileNames:v(r=>D(e,r,"cjs"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:v(r=>ge(r,"cjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"cjs",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,interop:"compat",sourcemap:e.options.sourcemap,...e.options.rollup.output,...e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:fe(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}},e.options.emitESM&&{chunkFileNames:v(r=>D(e,r,"mjs"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:v(r=>ge(r,"mjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"esm",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,sourcemap:e.options.sourcemap,...e.options.rollup.output,...e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:fe(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}}].filter(Boolean),plugins:[Ie(),qe(),e.tsconfig&&He(e.options.rootDir,e.logger,e.tsconfig),e.tsconfig&&ze(e.tsconfig,e.logger),e.options.rollup.replace&&De({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&Ee({customResolver:o?.resolveId,...e.options.rollup.alias,entries:t}),o,e.options.rollup.polyfillNode&&Tt({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&Pe({...e.options.rollup.json}),To(e.logger),qt(e.options.entries.filter(r=>r.isExecutable).map(r=>r.name).filter(Boolean)),e.options.rollup.wsam&&Rt(e.options.rollup.wsam),e.options.transformer?.(jr(e.options.transformerName,e)),e.options.cjsInterop&&e.options.emitCJS&&_e({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&Ft(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&It({extensions:I,sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),e.options.rollup.preserveDynamicImports&&{renderDynamicImport(){return{left:"import(",right:")"}}},e.options.rollup.shim&&Vo(e.pkg),e.options.rollup.raw&&Jo(e.options.rollup.raw),e.options.rollup.jsxRemoveAttributes&&Oo({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),e.options.rollup.metafile&&Mo({outDir:g(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&bo(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&Ce({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&&At({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"),wr=v(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"),kr=fo(wr),Ye=v(async e=>{const t=te(e,"types"),o={load(i){return/\.(?:js|cjs|mjs|jsx|ts|tsx|mts|json)$/.test(i)?null:""},name:"packem:ignore-files"},r=e.tsconfig?.config.compilerOptions;delete r?.lib;let n;e.options.rollup.resolve&&(n=Oe({extensions:I,...e.options.rollup.resolve}));const s="dts-plugin:"+process.pid+e.tsconfig.path;return{...Ge(e,t,"dts"),onwarn(i,l){Ve(i,e)||i.code!=="EMPTY_BUNDLE"&&l(i)},output:[e.options.emitCJS&&{chunkFileNames:v(i=>D(e,i,"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:v(i=>D(e,i,"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:v(i=>D(e,i,"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:[Ie(),qe(),e.options.rollup.json&&Pe({...e.options.rollup.json}),o,e.tsconfig&&He(e.options.rootDir,e.logger,e.tsconfig),e.tsconfig&&ze(e.tsconfig,e.logger),e.options.rollup.replace&&De({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&Ee({customResolver:n?.resolveId,...e.options.rollup.alias,entries:t}),n,await kr(s)(e),e.options.cjsInterop&&e.options.emitCJS&&_e({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&rr(e.options.rollup.patchTypes,e.logger),Vt(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&Ce({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 xr=Object.defineProperty,Er=d((e,t)=>xr(e,"name",{value:t,configurable:!0}),"a$3");const Or=Er(async e=>{const t=await Xe(e);if(await e.hooks.callHook("rollup:options",e,t),Object.keys(t.input).length===0)return;const o=await xe(t);await e.hooks.callHook("rollup:build",e,o);const r=t.output,n=new Map;for(const s of r){const{output:i}=await o.write(s),l=new Set,c=i.filter(a=>a.type==="chunk");for(const a of c){l.add(a.fileName);for(const u of a.imports)e.usedImports.add(u);a.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(a.code,"utf8"),chunks:a.imports.filter(u=>c.find(m=>m.fileName===u)),exports:a.exports,modules:Object.entries(a.modules).map(([u,m])=>({bytes:m.renderedLength,id:u})),path:a.fileName,type:"entry"})}const p=i.filter(a=>a.type==="asset");for(const a of p)n.has(a.fileName)||n.set(a.fileName,{bytes:Buffer.byteLength(a.source,"utf8"),path:a.fileName,type:"asset"});for(const a of l)e.usedImports.delete(a)}e.buildEntries.push(...n.values())},"build");var Dr=Object.defineProperty,A=d((e,t)=>Dr(e,"name",{value:t,configurable:!0}),"r$3");const Sr=A(async e=>{const t=await Ye(e);if(await e.hooks.callHook("rollup:dts:options",e,t),Object.keys(t.input).length===0)return;const o=await xe(t);await e.hooks.callHook("rollup:dts:build",e,o),e.logger.info({message:"Building declaration files...",prefix:"dts"}),e.options.emitCJS&&await o.write({chunkFileNames:A(r=>D(e,r,"d.cts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await o.write({chunkFileNames:A(r=>D(e,r,"d.mts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts"}),(e.options.declaration===!0||e.options.declaration==="compatible")&&await o.write({chunkFileNames:A(r=>D(e,r,"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 Nr=Object.defineProperty,Ke=d((e,t)=>Nr(e,"name",{value:t,configurable:!0}),"l$3");const ye=Ke((e,t,o)=>{const r="watcher:"+t;e.on("change",(n,{event:s})=>{o.info({message:`${y(N(".",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"),_r=Ke(async e=>{const t=await Xe(e);if(await e.hooks.callHook("rollup:options",e,t),Object.keys(t.input).length===0)return;const o=le(t);await e.hooks.callHook("rollup:watch",e,o);const r=[...Array.isArray(t.input)?t.input:typeof t.input=="string"?[t.input]:Object.keys(t.input??{})];let n="Starting watchers for entries:";for(const s of r)n+=P(`
65
- └─ ${N(process.cwd(),s)}`);if(e.logger.info(n),ye(o,"bundle",e.logger),e.options.declaration){const s=await Ye(e);await e.hooks.callHook("rollup:dts:options",e,s);const i=le(s);await e.hooks.callHook("rollup:watch",e,i),ye(i,"types",e.logger)}},"watch");var Pr=Object.defineProperty,Mr=d((e,t)=>Pr(e,"name",{value:t,configurable:!0}),"i$2");const Qe=Mr(e=>`{ ${Object.keys(e).map(t=>`${t}: ${JSON.stringify(e[t])}`).join(", ")} }`,"dumpObject");var Cr=Object.defineProperty,W=d((e,t)=>Cr(e,"name",{value:t,configurable:!0}),"l$2");const Ir=Q,Fr=W((e,t)=>{const{sideEffects:o}=t;let r;if(typeof o=="boolean")r=W(()=>o,"hasSideEffects");else if(Array.isArray(o))if(o.length<=0)r=W(()=>!1,"hasSideEffects");else{const n=o.map(s=>s.includes("/")?s:`**/${s}`);r=Ir(n,null,{resolve:e})}else r=W(()=>null,"hasSideEffects");return r},"getPackageSideEffect");var Rr=Object.defineProperty,Tr=d((e,t)=>Rr(e,"name",{value:t,configurable:!0}),"t$4");const Ar=Tr(e=>e.replace(/\.(js|mjs|cjs|ts|mts|cts|json|jsx|tsx)$/,""),"removeExtension");var Wr=Object.defineProperty,Ze=d((e,t)=>Wr(e,"name",{value:t,configurable:!0}),"t$3");const re=Ze(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),et=Ze((e,t,o,r)=>{if(o){const i=re(o);if(i)return i}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 et(n,s,o,r)},"inferExportType");var Br=Object.defineProperty,Jr=d((e,t)=>Br(e,"name",{value:t,configurable:!0}),"f$3");const ne=Jr((e,t,o,r=[])=>{if(!e)return[];if(typeof e=="string"){const n=re(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,type:n??s}]}return Object.entries(e).filter(([n])=>!n.endsWith(".json")).flatMap(([n,s])=>n==="types"&&!o?[]:typeof s=="string"?{file:s,type:et(n,r,s,t)}:ne(s,t,o,[...r,n]))},"extractExportFilenames");var Lr=Object.defineProperty,zr=d((e,t)=>Lr(e,"name",{value:t,configurable:!0}),"e");const Ur=zr(e=>{const t=B(e).split("/");return t.map((o,r)=>t.slice(r).join("/")).filter(Boolean)},"getEntrypointPaths");var Hr=Object.defineProperty,qr=d((e,t)=>Hr(e,"name",{value:t,configurable:!0}),"h$1");const Vr=qr((e,t,o,r=".")=>{const n=[];t.sort((u,m)=>u.split("/").length-m.split("/").length);const s=ne(e.exports,e.type??"commonjs",o);if(e.bin){const u=typeof e.bin=="string"?[e.bin]:Object.values(e.bin);for(const m of u)s.push({file:m,isExecutable:!0})}e.main&&s.push({file:e.main,type:re(e.main)??(e.type==="module"?"esm":"cjs")}),e.module&&s.push({file:e.module,type:"esm"}),o===void 0&&(e.types||e.typings)&&s.push({file:e.types??e.typings});const i=e.type==="module";for(const u of s.filter(m=>!m.type)){const m=u.file.endsWith(".js");i&&m||u.file.endsWith(".mjs")?u.type="esm":(!i&&m||u.file.endsWith(".cjs"))&&(u.type="cjs")}let l=!1,c=!1,p=!1;const a=[];for(const u of s){const m=u.file.replace(/(?:\*[^/\\]*|\.d\.(?:m|c)?ts|\.\w+)$/,""),f=m.endsWith("/");if(f&&["./","/"].includes(m))continue;const h=Ur(m).reduce((b,w)=>{if(b)return b;const k=new RegExp(`(?<=/|$)${w}${f?"":"\\.\\w+"}$`);return t.find(x=>k.test(x))?.replace(/(?:\.d\.(?:m|c)?ts|\.\w+)$/,"")},void 0);if(!h){Z(g(r,u.file))||n.push(`Could not find entrypoint for \`${u.file}\``);continue}u.type==="cjs"&&(l=!0),u.type==="esm"&&(c=!0);const j=a.find(b=>b.input===h)??a[a.push({input:h})-1];/\.d\.(?:m|c)?ts$/.test(u.file)&&(p=!0),f&&(j.outDir=m),u.isExecutable&&(j.isExecutable=!0)}return{cjs:l,dts:p,entries:a,esm:c,warnings:n}},"inferEntries");var Gr=Object.defineProperty,Xr=d((e,t)=>Gr(e,"name",{value:t,configurable:!0}),"t$2");const Yr=Xr((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 Kr=Object.defineProperty,Qr=d((e,t)=>Kr(e,"name",{value:t,configurable:!0}),"t$1");const Zr={hooks:{"build:prepare":Qr(function(e){if(e.options.entries.length>0)return;const t=E(e.options.rootDir,"src");if(!Z(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=dt(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=Yr(r,e.options.declaration));const n=Vr(r,o,e.options.declaration,e.options.rootDir);for(const s of n.warnings)R(e,s);if(e.options.entries.push(...n.entries),e.options.emitCJS===void 0&&n.cjs&&(e.options.emitCJS=!0),e.options.emitESM===void 0&&n.esm&&(e.options.emitESM=!0),e.options.declaration===void 0&&n.dts&&(e.options.declaration=n.dts),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(", ")),P([n.esm&&"esm",n.cjs&&"cjs",n.dts&&"dts"].filter(Boolean).map(s=>`[${s}]`).join(" ")))},"build:prepare")}};var en=Object.defineProperty,tn=d((e,t)=>en(e,"name",{value:t,configurable:!0}),"r");const tt=tn((e,t)=>ke(t,{esmResolve:!0,interopDefault:!0})(e),"tryRequire");var on=Object.defineProperty,rn=d((e,t)=>on(e,"name",{value:t,configurable:!0}),"t");const nn=rn((e,t)=>(e==="auto"?e=Zr:typeof e=="string"&&(e=tt(e,t)),typeof e=="function"&&(e=e()),e),"resolvePreset");var sn=Object.defineProperty,an=d((e,t)=>sn(e,"name",{value:t,configurable:!0}),"o");const ln=an(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)!V(e.options.externals,n)&&!n.startsWith("chunks/")&&!e.options.dependencies.includes(G(n))&&!e.options.peerDependencies.includes(G(n))&&r.add(n);o.size>0&&R(e,`Potential unused dependencies found: ${[...o].map(n=>y(n)).join(", ")}`),r.size>0&&R(e,`Potential implicit dependencies found: ${[...r].map(n=>y(n)).join(", ")}`)},"validateDependencies");var pn=Object.defineProperty,ot=d((e,t)=>pn(e,"name",{value:t,configurable:!0}),"i");const cn=ot((e,t)=>Ut(e,t)<=e.length/3||t.includes(e),"isSimilar"),un=ot((e,t)=>{const o=e.toLowerCase();return t.filter(r=>cn(r.toLowerCase(),o))},"findAlternatives");var mn=Object.defineProperty,ve=d((e,t)=>mn(e,"name",{value:t,configurable:!0}),"n");const dn=ve((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:"",...ne(e.exports,e.type??"commonjs",t.options.declaration).map(n=>n.file)].map(n=>n&&g(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("*")&&!Z(n)&&r.push(n.replace(`${t.rootDir}/`,""));if(r.length>0){const n=ve(l=>N(t.rootDir,g(t.options.outDir,l)),"rPath"),s=t.buildEntries.filter(l=>!l.chunk).map(l=>n(l.path));let i="Potential missing or wrong package.json files:";for(const l of r){const c=un(l,s);i+=`
66
- - `+y(l)+(c.length>0?lt` (did you mean ${c.map(p=>`"${p}"`).join(", ")}?)`:"")}R(t,i)}},"validatePackage");var fn=Object.defineProperty,$=d((e,t)=>fn(e,"name",{value:t,configurable:!0}),"m");const be=$((e,t)=>{e.warnings.size>0&&(t&&e.logger.raw(`
67
- `),e.logger.warn(`Build is done with some warnings:
68
-
69
- ${[...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`."),M(1)))},"logErrors"),gn=$(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"),hn=$((e,t,o,r,n,s,i,l)=>{const c=gn(l?.config.compilerOptions?.jsx),p=St(n,r,s,{alias:{},clean:!0,declaration:void 0,dependencies:[],devDependencies:[],emitCJS:void 0,emitESM:void 0,entries:[],externals:[...ie.builtinModules,...ie.builtinModules.map(a=>`node:${a}`)],failOnWarn:!0,minify:F.NODE_ENV==="production",name:(i.name??"").split("/").pop()??"default",optionalDependencies:[],outDir:"dist",peerDependencies:[],replace:{},rollup:{alias:{},cjsInterop:{addDefaultProperty:!1},commonjs:{ignoreTryCatch:!0,preserveSymlinks:!0,transformMixedEsModules:!1},dts:{compilerOptions:{baseUrl:l?.config.compilerOptions?.baseUrl??".",checkJs:!1,composite:!1,declaration:!0,declarationMap:!1,emitDeclarationOnly:!0,incremental:!1,noEmit:!1,noEmitOnError:!0,preserveSymlinks:!1,skipLibCheck:!0,target:99},respectExternal:!0},dynamicVars:{errorWhenNoFilesFound:!0,include:/\bimport\s*[(/]/},esbuild:{charset:"utf8",include:/\.[jt]sx?$/,jsx:c,jsxDev:l?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:l?.config.compilerOptions?.jsxFactory,jsxFragment:l?.config.compilerOptions?.jsxFragmentFactory,jsxImportSource:l?.config.compilerOptions?.jsxImportSource,jsxSideEffects:!0,keepNames:!0,minifyWhitespace:F.NODE_ENV==="production",sourcesContent:!1,target:l?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:l?.config},json:{preferConst:!0},license:{dependenciesTemplate:$((a,u,m)=>`
71
- # Licenses of bundled dependencies
72
- The published ${m} artifact additionally contains code with the following licenses:
73
- ${a.join(", ")}
74
-
75
- # Bundled dependencies:
76
- `+u,"dependenciesTemplate"),dtsTemplate:$((a,u,m)=>`
77
- # Licenses of bundled types
78
- The published ${m} artifact additionally contains code with the following licenses:
79
- ${a.join(", ")}
80
-
81
- # Bundled types:
82
- `+u,"dtsTemplate")},patchTypes:{},polyfillNode:{},preserveDynamicImports:!0,raw:{exclude:ae,include:["**/*.data","**/*.txt"]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,preferBuiltins:!1},shim:!0,sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:l?.config.compilerOptions?.esModuleInterop===!1,include:/\.[jt]sx?$/,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:F.NODE_ENV==="production",...l?.config.compilerOptions?.jsx&&["react","react-jsx","react-jsxdev"].includes(l.config.compilerOptions.jsx)?{jsxFragmentPragma:l.config.compilerOptions.jsxFragmentFactory,jsxImportSource:l.config.compilerOptions.jsxImportSource,jsxPragma:l.config.compilerOptions.jsxFactory,jsxRuntime:c,transforms:["typescript","jsx",...l.config.compilerOptions.esModuleInterop?["imports"]:[]]}:{transforms:["typescript",...l?.config.compilerOptions?.esModuleInterop?["imports"]:[]]}},swc:{include:/\.[jt]sx?$/,inlineSourcesContent:!1,inputSourceMap:!1,isModule:!0,jsc:{experimental:{keepImportAttributes:!0},externalHelpers:!1,keepClassNames:!0,loose:!0,parser:{decorators:l?.config.compilerOptions?.experimentalDecorators,syntax:l?"typescript":"ecmascript",[l?"tsx":"jsx"]:!0},target:l?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:l?.config.compilerOptions?.emitDecoratorMetadata,legacyDecorator:l?.config.compilerOptions?.experimentalDecorators,react:{development:F.NODE_ENV!=="production",pragma:l?.config.compilerOptions?.jsxFactory,pragmaFrag:l?.config.compilerOptions?.jsxFragmentFactory,runtime:c,throwIfNamespace:!0},treatConstEnumAsEnum:l?.config.compilerOptions?.preserveConstEnums,useDefineForClassFields:l?.config.compilerOptions?.useDefineForClassFields}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"}},treeshake:{moduleSideEffects:Fr(t,i),preset:"recommended"},watch:{clearScreen:!0,exclude:ae}},rootDir:t,sourcemap:!1,stub:o==="jit",stubOptions:{jiti:{alias:{},esmResolve:!0,interopDefault:!0}},transformerName:void 0});if(!p.transformerName){const a=new Set([...Object.keys(i.dependencies??{}),...Object.keys(i.devDependencies??{})]);if(a.has("esbuild"))p.transformerName="esbuild";else if(a.has("@swc/core"))p.transformerName="swc";else if(a.has("sucrase"))p.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 "'+y(p.transformerName)+'" as transformer.')}return p.outDir=g(p.rootDir,p.outDir),p.rollup.resolve&&p.rollup.resolve.preferBuiltins===!0&&(p.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true")),l?.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.`),p.dependencies=Object.keys(i.dependencies??{}),p.peerDependencies=Object.keys(i.peerDependencies??{}),p.devDependencies=Object.keys(i.devDependencies??{}),p.optionalDependencies=Object.keys(i.optionalDependencies??{}),p.externals.push(...p.dependencies,...p.peerDependencies,...p.optionalDependencies),p},"generateOptions"),yn=$(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=je(o.input)?N(t,o.input):B(o.input);r.startsWith("./")&&(r=r.slice(2)),o.name=Ar(r.replace(/^src\//,""))}if(!o.input)throw new Error(`Missing entry input: ${Qe(o)}`);if(!e.options.declaration&&o.declaration===void 0&&(o.declaration=e.options.declaration),o.input=g(e.options.rootDir,o.input),!ft(o.input)){const r=new Set(await st(K(o.input)));let n=!1;for(const s of I)if(r.has(J(o.input)+s)){n=!0;break}if(!n)throw new bt("Your configured entry: "+y(o.input)+" does not exist.")}o.outDir=g(e.options.rootDir,o.outDir??e.options.outDir)}},"prepareEntries"),vn=$((e,t,o)=>{const r=$(s=>N(t.rootDir,g(t.options.outDir,s)),"rPath");let n=!1;for(const s of t.buildEntries.filter(i=>!i.chunk)){let i=s.bytes??0;for(const c of s.chunks??[])i+=t.buildEntries.find(p=>p.path===c)?.bytes??0;let l=` ${O(r(s.path))} (${["total size: "+y(_(i)),s.type!=="asset"&&s.bytes&&"chunk size: "+y(_(s.bytes))].filter(Boolean).join(", ")})`;if(l+=s.exports?.length?`
85
- exports: `+P(s.exports.join(", ")):"",s.chunks?.length&&(l+=`
86
- ${s.chunks.map(c=>{const p=t.buildEntries.find(a=>a.path===c)??{};return P(" └─ "+r(c)+O(p.bytes?" ("+_(p?.bytes)+")":""))}).join(`
87
- `)}`),s.modules&&s.modules.length>0){const c=s.modules.filter(p=>p.id.includes("node_modules")).sort((p,a)=>(a.bytes||0)-(p.bytes||0)).map(p=>P(" 📦 "+r(p.id)+O(p.bytes?" ("+_(p.bytes)+")":""))).join(`
88
- `);l+=c.length>0?`
89
- inlined modules:
90
- `+c:""}if(t.options.declaration&&s.type==="entry"){let c=s.path.replace(/\.js$/,".d.ts"),p="commonjs";s.path.endsWith(".cjs")?c=s.path.replace(/\.cjs$/,".d.cts"):s.path.endsWith(".mjs")&&(p="module",c=s.path.replace(/\.mjs$/,".d.mts"));const a=t.buildEntries.find(u=>u.path.endsWith(c));if(a){let u;(t.options.declaration===!0||t.options.declaration==="compatible")&&!c.includes(".d.ts")&&(c=c.replace(p==="commonjs"?".d.c":".d.m",".d."),u=t.buildEntries.find(m=>m.path.endsWith(c))),l+=u&&p===o.type?`
91
- types:
92
- `+[a,u].map(m=>P(" └─ ")+O(r(m.path))+" (total size: "+y(_(m.bytes??0))+")").join(`
93
- `):`
94
- types: `+O(r(a.path))+" (total size: "+y(_(a.bytes??0))+")"}}n=!0,l+=`
95
-
96
- `,e.raw(s.chunk?P(l):l)}return n&&e.raw("Σ Total dist size (byte size):",y(_(t.buildEntries.reduce((s,i)=>s+(i.bytes??0),0))),`
97
- `),n},"showSizeInformation"),bn=$(async(e,t,o,r,n,s,i,l)=>{const c=nn(n.preset??r.preset??"auto",t),p=hn(e,t,o,r,n,c,s,i);gt(p.outDir);const a={buildEntries:[],dependencyGraphMap:new Map,hooks:Nt(),logger:e,mode:o,options:p,pkg:s,rootDir:t,tsconfig:i,usedImports:new Set,warnings:new Set};if(c.hooks&&a.hooks.addHooks(c.hooks),r.hooks&&a.hooks.addHooks(r.hooks),n.hooks&&a.hooks.addHooks(n.hooks),await a.hooks.callHook("build:prepare",a),a.options.emitESM===!1&&a.options.emitCJS===!1)throw new Error("Both emitESM and emitCJS are disabled. At least one of them must be enabled.");if(a.options.declaration&&i===void 0)throw new Error("Cannot build declaration files without a tsconfig.json");a.options.emitESM===void 0&&e.info("Emitting ESM bundles, is disabled."),a.options.emitCJS===void 0&&e.info("Emitting CJS bundles, is disabled."),a.options.declaration||e.info("Declaration files, are disabled."),await yn(a,t),await a.hooks.callHook("build:before",a);let u="Building";if(o==="watch"?u="Watching":o==="jit"&&(u="Stubbing"),e.info(y(`${u} ${a.options.name}`)),e.debug(`${O("Root dir:")} ${a.options.rootDir}
98
- ${O("Entries:")}
99
- ${a.options.entries.map(f=>` ${Qe(f)}`).join(`
100
- `)}`),a.options.clean)for(const f of new Set(a.options.entries.map(h=>h.outDir).filter(Boolean).sort()))f===a.options.rootDir||a.options.rootDir.startsWith(f.endsWith("/")?f:`${f}/`)||l.some(h=>f.startsWith(h))||(l.push(f),e.info(`Cleaning dist directory: \`./${N(a.options.rootDir,f)}\``),await ht(f));if(a.options.stub){await no(a),await a.hooks.callHook("build:done",a);return}if(o==="watch"){await _r(a),be(a,!1);return}await Promise.all([Or(a),a.options.declaration&&Sr(a)]),e.success(pt(`Build succeeded for ${a.options.name}`));for await(const f of yt(a.options.outDir)){let h=a.buildEntries.find(j=>E(a.options.outDir,j.path)===f.path);if(h||(h={chunk:!0,path:f.path},a.buildEntries.push(h)),!h.bytes){const j=await $e(g(a.options.outDir,f.path));h.bytes=j.size}}const m=vn(e,a,s);ln(a),dn(s,a),await a.hooks.callHook("build:done",a),be(a,m)},"build"),ns=$(async(e,t,o={})=>{const{configPath:r,debug:n,tsconfigPath:s,...i}=o,l=[new Et,new Ot];n&&l.push(new Dt);const c=xt({logLevel:n?"debug":"informational",processors:l,scope:"packem"});c.wrapAll(),e=g(at(),e),c.debug("Root directory:",e);const p=E(e,"package.json"),a=kt(p);c.debug("Using package.json found at",p);let u;if(s){const m=E(e,s);await vt(m)||(c.error("tsconfig.json not found at",m),M(1)),u={config:jt(m),path:m},c.info("Using tsconfig settings at",m)}else try{u=await wt(e),c.debug("Using tsconfig settings found at",u.path)}catch{c.info("No tsconfig.json or jsconfig.json found.")}try{const m=r??"./packem.config.ts";/\.(?:js|mjs|cjs|ts)$/.test(m)||(c.error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts extensions are allowed."),M(1));const f=tt(m,e);c.debug("Using packem config found at",E(e,m));const h=(Array.isArray(f)?f:[f]).filter(Boolean),j=Date.now(),b=$(()=>$t(Math.floor(Date.now()-j)),"getDuration"),w=[],k=[];for(const x of h)k.push(bn(c,e,t,i,x,a,u,w));await Promise.all(k),c.raw(`
101
- ⚡️ Build`+(k.length>1?"s":"")+" run in "+b()),c.restoreAll(),M(0)}catch(m){c.error("An error occurred while building",m),M(1)}},"createBundler");export{ns as default};
9
+ export{g as default};
@@ -0,0 +1,101 @@
1
+ var rt=Object.defineProperty;var m=(e,t)=>rt(e,"name",{value:t,configurable:!0});import{chmod as it,stat as je,readdir as at}from"node:fs/promises";import ie from"node:module";import{env as R,exit as M,versions as lt,cwd as pt}from"node:process";import{cyan as b,gray as P,bold as O,grey as ct,green as ut}from"@visulima/colorize";import{readFile as Y,writeFile as A,readFileSync as dt,writeFileSync as mt,writeJsonSync as $e,isAccessibleSync as we,readJsonSync as ft,collectSync as gt,ensureDirSync as ht,emptyDir as yt,walk as vt,isAccessible as bt}from"@visulima/fs";import{NotFoundError as jt}from"@visulima/fs/error";import{formatBytes as N,duration as $t}from"@visulima/humanizer";import{findCacheDirectorySync as wt,readTsConfig as kt,findTSConfig as xt}from"@visulima/package";import{parsePackageJson as Et}from"@visulima/package/package-json";import{createPail as Ot}from"@visulima/pail";import{MessageFormatterProcessor as _t,ErrorProcessor as Dt,CallerProcessor as St}from"@visulima/pail/processor";import{resolve as g,join as E,normalize as B,extname as K,relative as S,dirname as Q,basename as J,isAbsolute as ke}from"@visulima/path";import{defu as Nt}from"defu";import{createHooks as Pt}from"hookable";import{a as I,E as ae}from"./packem.CxExFSHU.mjs";import{pathToFileURL as Mt,fileURLToPath as Ct}from"node:url";import{resolvePath as It,resolveModuleExportNames as Rt,findStaticImports as xe}from"mlly";import D from"magic-string";import Ee from"jiti";import{rollup as Oe,watch as le}from"rollup";import _e from"@rollup/plugin-alias";import Ft from"@rollup/plugin-commonjs";import Tt from"@rollup/plugin-dynamic-import-vars";import{nodeResolve as De}from"@rollup/plugin-node-resolve";import Se from"@rollup/plugin-replace";import{wasm as At}from"@rollup/plugin-wasm";import Lt from"rollup-plugin-polyfill-node";import{visualizer as Wt}from"rollup-plugin-visualizer";import{minVersion as Ne}from"semver";import{glob as Bt}from"glob";import Jt from"glob-parent";import zt from"@rollup/plugin-json";import{createFilter as Z,normalizePath as pe}from"@rollup/pluginutils";import Ut from"rollup-plugin-license";import{parse as Ht}from"@babel/parser";import{createHash as qt}from"node:crypto";import{existsSync as ee}from"node:fs";import{distance as Vt}from"fastest-levenshtein";
2
+ // -- pack CommonJS Shims --
3
+ import __cjs_url__ from "node:url";
4
+ import __cjs_path__ from "node:path";
5
+ import __cjs_mod__ from "node:module";
6
+ const __filename = __cjs_url__.fileURLToPath(import.meta.url);
7
+ const __dirname = __cjs_path__.dirname(__filename);
8
+ const require = __cjs_mod__.createRequire(import.meta.url);
9
+ const Gt="@visulima/packem",Xt="1.0.0-alpha.24",Yt="A fast and modern bundler for Node.js and TypeScript.",Kt=["anolilab","assets","bundle","bundler","cjs","commonjs","compiler","css","declaration","es6","esbuild","esm","exports","package.json","packem","rollup","sucrase","swc","typescript","visulima","zero config"],Qt="https://www.visulima.com/docs/package/packem",Zt={type:"git",url:"https://github.com/visulima/packem.git",directory:"packages/packem"},es=[{type:"github",url:"https://github.com/sponsors/prisis"},{type:"consulting",url:"https://anolilab.com/support"}],ts="MIT",ss={name:"Daniel Bannert",email:"d.bannert@anolilab.de"},os=!1,ns="module",rs={".":{require:{types:"./dist/create-bundler.d.cts",default:"./dist/create-bundler.cjs"},import:{types:"./dist/create-bundler.d.mts",default:"./dist/create-bundler.mjs"}},"./config":{require:{types:"./dist/config.d.cts",default:"./dist/config.cjs"},import:{types:"./dist/config.d.mts",default:"./dist/config.mjs"}},"./transformer/esbuild":{require:{types:"./dist/rollup/plugins/esbuild/index.d.cts",default:"./dist/rollup/plugins/esbuild/index.cjs"},import:{types:"./dist/rollup/plugins/esbuild/index.d.mts",default:"./dist/rollup/plugins/esbuild/index.mjs"}},"./transformer/swc":{require:{types:"./dist/rollup/plugins/swc/index.d.cts",default:"./dist/rollup/plugins/swc/index.cjs"},import:{types:"./dist/rollup/plugins/swc/index.d.mts",default:"./dist/rollup/plugins/swc/index.mjs"}},"./transformer/sucrase":{require:{types:"./dist/rollup/plugins/sucrase/index.d.cts",default:"./dist/rollup/plugins/sucrase/index.cjs"},import:{types:"./dist/rollup/plugins/sucrase/index.d.mts",default:"./dist/rollup/plugins/sucrase/index.mjs"}},"./package.json":"./package.json"},is="./dist/create-bundler.cjs",as="./dist/create-bundler.mjs",ls="./dist/create-bundler.d.ts",ps={packem:"./dist/cli.cjs"},cs=["dist/**","README.md","CHANGELOG.md","LICENSE.md"],us={build:"cross-env JITI_ESM_RESOLVE=1 INTERNAL_PACKEM_BUILD=1 jiti ./src/cli build","build:prod":"cross-env JITI_ESM_RESOLVE=1 INTERNAL_PACKEM_BUILD=1 jiti ./src/cli build --minify",clean:"rimraf node_modules dist .eslintcache",dev:"pnpm run build","lint:eslint":"eslint . --ext js,cjs,mjs,jsx,ts,tsx,json,yaml,yml,md,mdx --max-warnings=0 --config .eslintrc.cjs","lint:eslint:fix":"eslint . --ext js,cjs,mjs,jsx,ts,tsx,json,yaml,yml,md,mdx --max-warnings=0 --config .eslintrc.cjs --fix","lint:packagejson":"publint --strict","lint:prettier":"prettier --config=.prettierrc.cjs --check .","lint:prettier:fix":"prettier --config=.prettierrc.cjs --write .","lint:types":"tsc --noEmit",test:"vitest run","test:coverage":"vitest run --coverage","test:ui":"vitest --ui --coverage.enabled=true","test:watch":"vitest"},ds={"@antfu/install-pkg":"^0.3.3","@babel/parser":"^7.24.6","@rollup/plugin-alias":"^5.1.0","@rollup/plugin-commonjs":"^25.0.8","@rollup/plugin-dynamic-import-vars":"^2.1.2","@rollup/plugin-inject":"^5.0.5","@rollup/plugin-json":"^6.1.0","@rollup/plugin-node-resolve":"^15.2.3","@rollup/plugin-replace":"^5.0.5","@rollup/plugin-wasm":"^6.2.2","@rollup/pluginutils":"^5.1.0","@visulima/cerebro":"^1.0.29","@visulima/colorize":"^1.4.1","@visulima/fs":"^2.1.2","@visulima/humanizer":"^1.0.3","@visulima/package":"^1.8.3","@visulima/pail":"^1.1.11","@visulima/path":"^1.0.1","@clack/prompts":"^0.7.0",defu:"6.1.4","es-module-lexer":"^1.5.3","fastest-levenshtein":"^1.0.16",glob:"^10.4.1","glob-parent":"^6.0.2",hookable:"^5.5.3","magic-string":"^0.30.10",mlly:"^1.7.0",rollup:"^4.18.0","rollup-plugin-dts":"^6.1.1","rollup-plugin-license":"^3.4.0","rollup-plugin-polyfill-node":"^0.13.0","rollup-plugin-visualizer":"^5.12.0",semver:"^7.6.2"},ms={"@anolilab/eslint-config":"^15.0.3","@anolilab/prettier-config":"^5.0.14","@anolilab/semantic-release-pnpm":"^1.1.0","@anolilab/semantic-release-preset":"^8.1.0","@babel/core":"^7.24.6","@rushstack/eslint-plugin-security":"^0.8.1","@secretlint/secretlint-rule-preset-recommend":"^8.2.4","@swc/core":"^1.5.7","@swc/types":"0.1.7","@total-typescript/ts-reset":"^0.5.1","@types/estree":"^1.0.5","@types/glob":"^8.1.0","@types/glob-parent":"^5.1.3","@types/micromatch":"^4.0.7","@types/node":"18.18.14","@types/react":"^18.3.3","@types/react-dom":"^18.3.0","@types/semver":"^7.5.8","@vitest/coverage-v8":"^1.6.0","@vitest/ui":"^1.6.0","cross-env":"^7.0.3",esbuild:"^0.21.4",eslint:"^8.56.0","eslint-plugin-deprecation":"^2.0.0","eslint-plugin-etc":"^2.0.3","eslint-plugin-import":"npm:eslint-plugin-i@^2.29.1","eslint-plugin-mdx":"^3.1.5","eslint-plugin-vitest":"^0.4.1","eslint-plugin-vitest-globals":"^1.5.0","estree-walker":"^3.0.3",execa:"^9.1.0",jiti:"^1.21.0",prettier:"^3.2.5",react:"^18.3.1","react-dom":"^18.3.1",rimraf:"^5.0.7",secretlint:"8.2.4","semantic-release":"^23.1.1","sort-package-json":"^2.10.0",sucrase:"^3.35.0",tempy:"^3.1.0","ts-essentials":"^10.0.0",typescript:"^5.4.5",vitest:"^1.6.0"},fs={"@swc/core":"^1.5.7",esbuild:"^0.20.2 || ^0.21.3",jiti:"^1.21.0",sucrase:"^3.35.0",typescript:"^4.5 || ^5.0"},gs={"@swc/core":{optional:!0},esbuild:{optional:!0},sucrase:{optional:!0},typescript:{optional:!0}},hs={node:">=18.* <=21.*"},ys={access:"public",provenance:!0},vs={"eslint-config":{plugin:{tsdoc:!1,"testing-library-react":!1,"react-usememo":!1,"react-hooks":!1,"jsx-a11y":!1,react:!1,"validate-jsx-nesting":!1,"ssr-friendly":!1},warn_on_unsupported_typescript_version:!1,info_on_disabling_jsx_react_rule:!1,info_on_disabling_prettier_conflict_rule:!1,info_on_disabling_jsonc_sort_keys_rule:!1,info_on_disabling_etc_no_deprecated:!1}},bs={name:Gt,version:Xt,description:Yt,keywords:Kt,homepage:Qt,repository:Zt,funding:es,license:ts,author:ss,sideEffects:os,type:ns,exports:rs,main:is,module:as,types:ls,bin:ps,files:cs,scripts:us,dependencies:ds,devDependencies:ms,peerDependencies:fs,peerDependenciesMeta:gs,engines:hs,publishConfig:ys,anolilab:vs};var js=Object.defineProperty,z=m((e,t)=>js(e,"name",{value:t,configurable:!0}),"i$a");const te=/^#![^\n]*/,V=z(async e=>{await it(e,493).catch(()=>{})},"makeExecutable"),$s=z((e,t=`#!/usr/bin/env node
10
+ `)=>({name:"packem:shebang",renderChunk:{handler(s,o,n){if(!o.isEntry||!o.facadeModuleId||s.startsWith("#")&&s[1]==="!")return null;if(e.includes(o.name)){const r=new D(s);return r.prepend(t),{code:r.toString(),map:n.sourcemap?r.generateMap({hires:!0}):void 0}}return null},order:"post"},async writeBundle(s,o){for(const[n,r]of Object.entries(o))if(r.type==="chunk"&&te.test(r.code)&&s.dir){const i=g(s.dir,n);await V(i)}}}),"shebangPlugin"),ws=z(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(te,"")}}),"removeShebangPlugin"),ks=z((e,t=`
11
+ `)=>{const s=te.exec(e);return s?s+t:""},"getShebang");var xs=Object.defineProperty,Es=m((e,t)=>xs(e,"name",{value:t,configurable:!0}),"p$2");const se=Es((e,t)=>{let s={};if(e.pkg.name&&(s[e.pkg.name]=e.options.rootDir),e.pkg.imports){const{imports:o}=e.pkg;for(const n in o){if(n.startsWith("#"))continue;const r=o[n];typeof r=="string"&&(s[n]=E(e.rootDir,r))}}return s={...s,...e.options.alias},e.options.rollup.alias&&(Array.isArray(e.options.rollup.alias.entries)?Object.assign(s,Object.fromEntries(e.options.rollup.alias.entries.map(o=>[o.find,o.replacement]))):Object.assign(s,e.options.rollup.alias.entries??e.options.rollup.alias)),e.logger.debug({message:"Resolved aliases: "+JSON.stringify(s),prefix:t}),s},"resolveAliases");var Os=Object.defineProperty,_s=m((e,t)=>Os(e,"name",{value:t,configurable:!0}),"o$3");const Ds=_s((e,t)=>{const s=Ee(t,{esmResolve:!0,interopDefault:!0});try{return s.resolve(e)}catch(o){if(o.code!=="MODULE_NOT_FOUND")throw new Error(`Error trying import ${e} from ${t}`,{cause:o});return e}},"tryResolve");var Ss=Object.defineProperty,Ns=m((e,t)=>Ss(e,"name",{value:t,configurable:!0}),"r$8");const F=Ns((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var Ps=Object.defineProperty,Ms=m((e,t)=>Ps(e,"name",{value:t,configurable:!0}),"u$9");const Cs=Ms(async e=>{const t=await It("jiti",{url:import.meta.url}),s=JSON.stringify({...e.options.stubOptions.jiti,alias:{...se(e,"jit"),...e.options.stubOptions.jiti.alias}},null,2);for(const o of e.options.entries){const n=g(e.options.rootDir,e.options.outDir,o.name),r=B(Ds(o.input,e.options.rootDir)||o.input),i=r.slice(0,Math.max(0,r.length-K(r).length)),a=await Y(r),c=ks(a);e.options.emitCJS&&await A(`${n}.cjs`,c+[`const jiti = require(${JSON.stringify(t)})`,"",`const _jiti = jiti(null, ${s})`,"",`/** @type {import(${JSON.stringify(i)})} */`,`module.exports = _jiti(${JSON.stringify(r)})`].join(`
12
+ `));let p=[];try{p=await Rt(r,{extensions:I})}catch(l){F(e,`Cannot analyze ${r} for exports:${l}`);return}const u=p.includes("default")||p.length===0;await A(`${n}.mjs`,c+[`import jiti from ${JSON.stringify(Mt(t).href)};`,"",`const _jiti = jiti(null, ${s})`,"",`/** @type {import(${JSON.stringify(r)})} */`,`const _module = await _jiti.import(${JSON.stringify(r)});`,u?`
13
+ export default _module;`:"",...p.filter(l=>l!=="default").map(l=>`export const ${l} = _module.${l};`)].join(`
14
+ `)),await A(`${n}.d.cts`,[`export * from ${JSON.stringify(i)};`,u?`export { default } from ${JSON.stringify(i)};`:""].join(`
15
+ `)),await A(`${n}.d.mts`,[`export * from ${JSON.stringify(r)};`,u?`export { default } from ${JSON.stringify(r)};`:""].join(`
16
+ `)),c&&(await V(`${n}.cjs`),await V(`${n}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var Is=Object.defineProperty,Rs=m((e,t)=>Is(e,"name",{value:t,configurable:!0}),"a$a");const G=Rs((e,t)=>e.some(s=>s instanceof RegExp?s.test(t):s===t),"arrayIncludes");var Fs=Object.defineProperty,Ts=m((e,t)=>Fs(e,"name",{value:t,configurable:!0}),"a$9");const U=Ts(e=>e===void 0?[]:Array.isArray(e)?e:[e],"arrayify");var As=Object.defineProperty,Ls=m((e,t)=>As(e,"name",{value:t,configurable:!0}),"e$2");const X=Ls((e="")=>{const t=e.split("/");return t[0][0]==="@"?`${t[0]}/${t[1]}`:t[0]},"getPackageName");var Ws=Object.defineProperty,Pe=m((e,t)=>Ws(e,"name",{value:t,configurable:!0}),"s$d");const Bs=Pe((e,t,s)=>{const o=s??new Map;return(...n)=>{const r=t?typeof t=="function"?t(...n):t:JSON.stringify({args:n}),i=o.get(r);if(i!==void 0)return i;const a=e(...n);return o.set(r,a),a}},"memoize"),Js=Pe(e=>{const t=new Map;return s=>Bs(e,s,t)},"memoizeByKey");var zs=Object.defineProperty,Us=m((e,t)=>zs(e,"name",{value:t,configurable:!0}),"m$5");const Me=Us(({addDefaultProperty:e=!1,logger:t,type:s})=>({name:"packem:cjs-interop",renderChunk(o,n,r){if(n.type!=="chunk"||!n.isEntry)return null;if(r.format==="cjs"&&r.exports==="auto"){const i=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(o);if(i===null||i.length<3)return null;const a=new D(o);a.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),a.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&a.append(`
17
+ module.exports.default = `+i[2]+";");let c=a.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:a.generateMap({hires:!0})}}if(r.format==="es"&&/\.d\.(?:ts|cts)$/.test(n.fileName)){if(s!=="commonjs"&&n.fileName.endsWith(".d.ts"))return null;const i=/export\s\{\s(.*)\s\}/i.exec(o);if(i===null||i.length<2)return null;const a=i[1].split(", "),c=[];let p="";for(const l of a)if(!l.includes("type"))if(l.includes("as")){const[d,h]=l.split(" as ");if(h==="default"&&(p=d,!e))continue;c.push(h+": typeof "+d+";")}else c.push(l+": typeof "+l+";");const u=new D(o);return u.replace(" "+p+" as default,",""),u.append(`
18
+
19
+ declare const defaultExport: {
20
+ `+(c.length>0?" ":"")+c.join(`
21
+ `)+`
22
+ } & typeof `+p+`;
23
+
24
+ export default defaultExport;`),t.debug({message:"Applied CommonJS interop to entry chunk "+n.fileName+".",prefix:"plugin:cjs-interop"}),{code:u.toString(),map:u.generateMap({hires:!0})}}return null}}),"cjsInterop");var Hs=Object.defineProperty,qs=m((e,t)=>Hs(e,"name",{value:t,configurable:!0}),"f$9");const Vs=qs((e,t)=>{const s=new Map,o={copyOnce:!0,exactFileNames:!0,flatten:!1,...e};let{targets:n}=o;return Array.isArray(n)?n=n.map(r=>{if(typeof r=="string")return{src:r};if(typeof r=="object"&&"src"in r)return r}).filter(Boolean):typeof n=="string"&&(n=[{src:n}]),{async buildStart(){const r=await Promise.all(n.flatMap(i=>Array.isArray(i.src)?i.src.map(a=>({...i,src:a})):i).map(async i=>await Bt(i.src,{ignore:i.exclude}).then(a=>({dest:i.dest??"",parent:Jt(i.src),src:a}))));for(const i of r)for(const a of i.src){let c;s.has(a)?c=s.get(a):(c={copied:[],dest:[],timestamp:0},s.set(a,c));const p=o.flatten?B(i.dest):E(i.dest,S(i.parent,Q(a)));c.dest.includes(p)||c.dest.push(p),this.addWatchFile(a)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...s].map(async([i,a])=>{let c;try{const p=await je(i);if(!p.isFile())return;const u=p.mtime.getTime();u>a.timestamp&&(a.timestamp=u,a.copied=[]),c=await Y(i,{buffer:!0})}catch(p){t.error({context:[p],message:`error reading file ${i}`,prefix:"plugin:copy"});return}for(const p of a.dest){if(o.copyOnce&&a.copied.includes(p))continue;const u=J(i),l=E(p,u);try{this.emitFile({[o.exactFileNames?"fileName":"name"]:l,source:c,type:"asset"}),t.debug({message:`copied ${i} → ${l}`,prefix:"plugin:copy"}),a.copied.push(p)}catch(d){t.error({context:[d],message:`error copying file ${i} → ${l}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var Gs=Object.defineProperty,Xs=m((e,t)=>Gs(e,"name",{value:t,configurable:!0}),"n$6");const ce="export default ",Ce=Xs(e=>{const t=zt(e);return{...t,name:"packem:json",transform(s,o){const n=t.transform?.call(this,s,o);return n&&typeof n!="string"&&"code"in n&&n.code?.startsWith(ce)&&(n.code=n.code.replace(ce,"module.exports = ")),n}}},"JSONPlugin");class Ys{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,s,o,n){t&&s&&(o!=null?t[s][o]=n:t[s]=n)}remove(t,s,o){t&&s&&(o!=null?t[s].splice(o,1):delete t[s])}}class Ks extends Ys{static{m(this,"SyncWalker")}constructor(t,s){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(o=>this.replacement=o,"replace")},this.enter=t,this.leave=s}visit(t,s,o,n){if(t){if(this.enter){const i=this.should_skip,a=this.should_remove,c=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,s,o,n),this.replacement&&(t=this.replacement,this.replace(s,o,n,t)),this.should_remove&&this.remove(s,o,n);const p=this.should_skip,u=this.should_remove;if(this.should_skip=i,this.should_remove=a,this.replacement=c,p)return t;if(u)return null}let r;for(r in t){const i=t[r];if(i&&typeof i=="object")if(Array.isArray(i)){const a=i;for(let c=0;c<a.length;c+=1){const p=a[c];ue(p)&&(this.visit(p,t,r,c)||c--)}}else ue(i)&&this.visit(i,t,r,null)}if(this.leave){const i=this.replacement,a=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,t,s,o,n),this.replacement&&(t=this.replacement,this.replace(s,o,n,t)),this.should_remove&&this.remove(s,o,n);const c=this.should_remove;if(this.replacement=i,this.should_remove=a,c)return null}}return t}}function ue(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}m(ue,"isNode");function Ie(e,{enter:t,leave:s}){return new Ks(t,s).visit(e,null)}m(Ie,"walk");var Qs=Object.defineProperty,Zs=m((e,t)=>Qs(e,"name",{value:t,configurable:!0}),"u$7");const eo=Zs(({attributes:e,logger:t})=>{const s=Z([/\.[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(o,n){if(!s(n))return null;let r=null;try{r=this.parse(o,{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 i=!1;const a=new D(o);return Ie(r,{enter(c){if(c.type==="CallExpression"&&c.callee.type==="Identifier"&&c.callee.name==="jsx"){const p=c.arguments.filter(u=>u.type==="ObjectExpression"&&Array.isArray(u.properties));for(const u of p)for(const l of u.properties)l.type==="Property"&&l.key.type==="Literal"&&l.value.type==="Literal"&&e.includes(l.key.value)&&(a.overwrite(l.start-2,l.end,""),i=!0)}}}),i?{code:a.toString(),map:a.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var to=Object.defineProperty,oe=m((e,t)=>to(e,"name",{value:t,configurable:!0}),"p$1");const so=oe(e=>{const t=[],s=[];return e.forEach(o=>{o.startsWith("(")?t.push(o):s.push(o)}),[...s.sort(),...t.sort()]},"sortLicenses"),oo=oe((e,t,s)=>{const o=new RegExp(`(<!-- ${t} -->)[\\s\\S]*?(<!-- ${t} -->)`,"g");if(o.test(e))return e.replace(o,`$1
25
+ ${s}
26
+ $2`)},"replaceContentWithin"),Re=oe(({licenseFilePath:e,licenseTemplate:t,logger:s,marker:o,mode:n,packageName:r})=>Ut({thirdParty(i){const a=new Set,c=i.sort(({name:u},{name:l})=>u>l?1:l>u?-1:0).map(({author:u,contributors:l,license:d,licenseText:h,maintainers:f,name:y,repository:v})=>{let w="## "+y+`
27
+ `;d&&(w+=`License: ${d}
28
+ `);const k=new Set;for(const x of[u,...f,...l]){const T=typeof x=="string"?x:x?.name;T&&k.add(T)}return k.size>0&&(w+=`By: ${[...k].join(", ")}
29
+ `),v&&(w+=`Repository: ${typeof v=="string"?v:v.url}
30
+ `),h&&(w+=`
31
+ `+h.trim().replaceAll(/(\r\n|\r)/g,`
32
+ `).split(`
33
+ `).map(x=>`> ${x}`).join(`
34
+ `)+`
35
+ `),d&&a.add(d),w}).join(`
36
+ ---------------------------------------
37
+
38
+ `);if(c===""){s.info({message:"No dependencies license information found.",prefix:"plugin:license:"+n});return}const p=t(so(a),c,r);try{const u=dt(e),l=oo(u,o,p);if(!l){s.error({message:`Could not find the license marker: <!-- ${o} --> in ${e}`,prefix:"plugin:license:"+n});return}u!==l&&(mt(e,l),s.info({message:`${e} updated.`,prefix:"plugin:license:"+n}))}catch(u){s.error(u)}}}),"license");var no=Object.defineProperty,ro=m((e,t)=>no(e,"name",{value:t,configurable:!0}),"i$7");const io=ro(e=>({async buildEnd(){const t=[];for(const o of this.getModuleIds()){const n=this.getModuleInfo(o);if(n!=null&&!n.isExternal)for(const r of n.importedIds)t.push({source:o,target:r})}if(Array.isArray(t)&&t.length===0)return;const s=g(e.outDir,"graph.json");$e(s,t)},name:"packem:metafile"}),"metafilePlugin");var ao=Object.defineProperty,lo=m((e,t)=>ao(e,"name",{value:t,configurable:!0}),"c$3");const po=/\.(?:m|c)?(?:j|t)sx?$/,co=/^use \w+$/,uo=lo(e=>{const t={},s={};return{name:"packem:preserve-directives",onLog(o,n){return n.code==="MODULE_LEVEL_DIRECTIVE"&&o==="warn"?!1:null},renderChunk:{handler(o,n,{sourcemap:r}){const i=n.moduleIds.map(p=>t[p]?t[p]:null).reduce((p,u)=>(u&&u.forEach(l=>{p.add(l)}),p),new Set),a=new D(o);i.size>0&&(e.debug({message:`directives for chunk "${n.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),a.prepend(`${[...i].map(p=>`'${p}';`).join(`
39
+ `)}
40
+ `));let c=null;return n.facadeModuleId&&typeof s[n.facadeModuleId]=="string"&&(c=s[n.facadeModuleId]),c&&(e.debug({message:`shebang for chunk "${n.fileName}" is preserved.`,prefix:"plugin:preserve-directives"}),a.prepend(`${c}
41
+ `)),i.size===0&&c===null?null:{code:a.toString(),map:r?a.generateMap({hires:!0}):null}},order:"post"},transform:{handler(o,n){const r=K(n);if(!po.test(r))return null;let i=!1;const a=new D(o);if(o.startsWith("#")&&o[1]==="!"){let p=0;for(let u=2,l=o.length;u<l;u++){const d=o.codePointAt(u);if(d===10||d===13||d===8232||d===8233){p=u;break}}p&&(s[n]=o.slice(0,p),a.remove(0,p+1),i=!0,e.debug({message:`shebang for module "${n}" is preserved.`,prefix:"plugin:preserve-directives"}))}let c=null;try{c=this.parse(a.toString(),{allowReturnOutsideFunction:!0})}catch(p){return this.warn({code:"PARSE_ERROR",message:`[packem:preserve-directives]: failed to parse "${n}" and extract the directives.`}),e.warn(p),null}if(c.type!=="Program")return null;for(const p of c.body.filter(Boolean)){if(p.type!=="ExpressionStatement")break;let u=null;"directive"in p?u=p.directive:p.expression.type==="Literal"&&typeof p.expression.value=="string"&&co.test(p.expression.value)&&(u=p.expression.value),u!=="use strict"&&u&&(t[n]||=new Set,t[n].add(u),"start"in p&&typeof p.start=="number"&&"end"in p&&typeof p.end=="number"&&(a.remove(p.start,p.end),i=!0),e.debug({message:`directive "${u}" for module "${n}" is preserved.`,prefix:"plugin:preserve-directives"}))}return i?{code:a.toString(),map:a.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...t[n]??[]],shebang:s[n]??null}}}:null},order:"post"}}},"preserveDirectives");var mo=Object.defineProperty,fo=m((e,t)=>mo(e,"name",{value:t,configurable:!0}),"r$6");const go={exclude:[],include:[/\.(md|txt|css|htm|html)$/]},ho=fo((e={})=>{e={...e,...go};const t=Z(e.include,e.exclude);return{name:"packem:raw",transform(s,o){return t(o)?{code:`export default ${JSON.stringify(s)}`,map:null}:null}}},"rawPlugin");var yo=Object.defineProperty,vo=m((e,t)=>yo(e,"name",{value:t,configurable:!0}),"l$4");const H="\0__file_url__",Fe=vo(()=>({async load(e){if(e.startsWith(H)){const t=Ct(e.slice(H.length));return await Y(t)}},name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return`${H}${e}`}}),"resolveFileUrl");var bo=Object.defineProperty,Te=m((e,t)=>bo(e,"name",{value:t,configurable:!0}),"i$4");const jo=/__filename|__dirname|require\(|require\.resolve\(/,Ae=`
42
+ // -- pack CommonJS Shims --
43
+ import __cjs_url__ from "node:url";
44
+ import __cjs_path__ from "node:path";
45
+ import __cjs_mod__ from "node:module";
46
+ const __filename = __cjs_url__.fileURLToPath(import.meta.url);
47
+ const __dirname = __cjs_path__.dirname(__filename);
48
+ const require = __cjs_mod__.createRequire(import.meta.url);
49
+ `,Le=`
50
+ // -- pack CommonJS Shims Node 20.11 --
51
+ import __cjs_mod__ from "node:module";
52
+ const __filename = import.meta.filename;
53
+ const __dirname = import.meta.dirname;
54
+ const require = __cjs_mod__.createRequire(import.meta.url);
55
+ `,$o=Te((e,t)=>{if(R.INTERNAL_PACKEM_BUILD!=="1"&&(e.includes(Ae)||e.includes(Le)||!jo.test(e)))return null;const s=xe(e).pop(),o=s?s.end:0,n=new D(e);return n.appendRight(o,t),{code:n.toString(),map:n.generateMap()}},"CJSToESM"),wo=Te(e=>({name:"packem:cjs",renderChunk(t,s,o){if(o.format==="es"){let n=Ae;if(e.engines?.node){const r=Ne(e.engines.node);r&&r.major>=20&&r.minor>=11&&(n=Le)}return $o(t,n)}return null}}),"cjsPlugin");var ko=Object.defineProperty,C=m((e,t)=>ko(e,"name",{value:t,configurable:!0}),"s$a");const xo=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,Eo=/MIT License|MIT license|BSD license/,Oo=/\n{2,}/g,_o=/\b(\w+)\$\d+\b/g,Do=/[-/\\^$*+?.()|[\]{}]/g,So=C(e=>e.replaceAll(Do,"\\$&"),"escapeRegex"),No=C(e=>[...new Set(e)],"unique"),Po=C(e=>e.replaceAll(xo,t=>Eo.test(t)?"":t).replaceAll(Oo,`
56
+
57
+ `),"cleanUnnecessaryComments"),de=new Map;function We(e,t,{identifierReplacements:s},o){const n=xe(e);for(const i in s){const a=n.find(p=>p.specifier===i&&p.imports.includes("{"));if(!a){this.warn(`${t.fileName} does not import "${i}" for replacement`),process.exitCode=1;continue}const c=s[i];for(const p in c){a.imports.includes(p)||(this.warn(`${t.fileName} does not import "${p}" from "${i}" for replacement`),M(1));const u=c[p],l=So(p);u.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${l},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${l}\\b`,"g"),u)}}const r=No(Array.from(e.matchAll(_o),i=>i[0]));if(r.length>0){const i=r.map(c=>`
58
+ - ${c}`).join(""),a=t.fileName.replace(/\.[^/.]+$/,"");de.has(a)||o.warn({message:`${t.fileName} contains confusing identifier names${i}
59
+
60
+ To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),de.set(a,!0)}return e}m(We,"v$2");C(We,"replaceConfusingTypeNames");function Be(e,t){if(t.leadingComments?.some(s=>s.type==="CommentBlock"&&s.value.includes("@internal"))){const s=e.original[t.end]===","?t.end+1:t.end;return e.remove(t.leadingComments[0].start,s),!0}return!1}m(Be,"N$1");C(Be,"removeInternal");function Je(e,t){if(e.includes("@internal")){const s=new D(e),o=Ht(e,{plugins:["typescript"],sourceType:"module"});Ie(o,{enter(n){Be(s,n)&&this.skip()}}),e=s.toString(),e.includes("@internal")&&(this.warn(`${t.fileName} has unhandled @internal declarations`),M(1))}return e}m(Je,"S$1");C(Je,"stripInternalTypes");const Mo=C((e,t)=>({name:"packem:patch-types",renderChunk(s,o){return s=We.call(this,s,o,e,t),s=Je.call(this,s,o),s=Po(s),s},resolveId(s){return s.startsWith("types/")?{external:!0,id:"../../"+(s.endsWith(".js")?s:s+".js")}:null}}),"patchTypescriptTypes");var Co=Object.defineProperty,ze=m((e,t)=>Co(e,"name",{value:t,configurable:!0}),"u$5");const Ue=ze((e,t=!0)=>{if(!e)return null;const{config:s,path:o}=e;if(!s.compilerOptions)return null;const{baseUrl:n,paths:r}=s.compilerOptions;if(!n)return null;const i=g(Q(o),n),a=[];if(r)for(const[c,p]of Object.entries(r)){const u=new RegExp(`^${[...c].map(d=>d==="*"?"(.+)":d.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let l=0;for(const d of p){const h=[...pe(g(i,d))].map(f=>f==="*"?`$${++l}`:f==="$"?"$$":f).join("");a.push({find:u,replacement:h})}}return t&&a.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...pe(i)].map(c=>c==="$"?"$$":c).join("")}/$1`}),a},"getConfigAlias"),He=ze((e,t)=>{const s=Ue(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(o,n,r){if(!s||o.includes("\0"))return null;for(const{find:i,replacement:a}of s)if(i.test(o)){const c=o.replace(i,a),p=await this.resolve(c,n,{skipSelf:!0,...r});if(p)return t.debug({message:`Resolved ${o} to ${p.id} using paths from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-paths"}),p.id}return null}}},"resolveTsconfigPaths");var Io=Object.defineProperty,qe=m((e,t)=>Io(e,"name",{value:t,configurable:!0}),"u$4");const Ro=qe((e,t)=>{if(!t)return null;const{config:s,path:o}=t;if(!s.compilerOptions)return null;const{rootDirs:n}=s.compilerOptions;if(!n)return null;const r=[];for(const i of n){if(i.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${o}.`);if(i.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${o}.`);r.push(g(e,i))}return r},"getRootDirectories"),Ve=qe((e,t,s)=>{const o=Ro(e,s);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(n,r,i){if(o===null||o.length===0)return null;if(n.startsWith("."))for(const a of o){const c=E(a,n),p=await this.resolve(c,r,{skipSelf:!0,...i});if(p)return t.debug({message:`Resolved ${n} to ${p.id} using rootDirs from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-root-dirs"}),p.id}return null}}},"resolveTsconfigRootDirectories");var Fo=Object.defineProperty,To=m((e,t)=>Fo(e,"name",{value:t,configurable:!0}),"r$5");const Ge=To(()=>{const e=/\.(?:[mc]?js|jsx)$/;return{name:"packem:resolve-typescript-mjs-cjs",async resolveId(t,s,o){return e.test(t)&&s?await this.resolve(t.replace(/js(x?)$/,"ts$1"),s,o):null}}},"resolveTypescriptMjsCts");var Ao=Object.defineProperty,Lo=m((e,t)=>Ao(e,"name",{value:t,configurable:!0}),"s$9");const Wo=Lo(e=>{const t=J(e).split(".");if(t.length>=2){const[s,o]=t.slice(-2),n=t[0],r=/^(\w+)-runtime$/.exec(s)?.[1];if(I.includes(o)&&r&&r.length>0)return n+"-"+r}},"getCustomModuleLayer");var Bo=Object.defineProperty,Jo=m((e,t)=>Bo(e,"name",{value:t,configurable:!0}),"i$3");const q=Jo(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var zo=Object.defineProperty,me=m((e,t)=>zo(e,"name",{value:t,configurable:!0}),"c$1");const fe=me((e,t)=>{const s=new Map;return me(function(o,n){const r=n.getModuleInfo(o);if(!r)return;const{isEntry:i}=r,a=r.meta,c=q(a);if(!i){const p=s.get(o);if(p)return p;const u=Wo(o);if(u)return s.set(o,u),u}if(i){const p=n.getModuleIds();for(const u of p)n.getModuleInfo(u)&&q(a)===c&&(e.has(u)||e.set(u,new Set),e.get(u).add([o,c]))}if(c&&!i&&e.has(o)){const p=[...e.get(o)];if(p.some(([l])=>{if(t.some(d=>d.path===l)){const d=n.getModuleInfo(l);return q(d?d.meta:{})===c}return!1}))return;if(p.every(([,l])=>l===c))return s.has(o)?s.get(o):void 0;const u=`${J(o,K(o))}-${c}`;return s.set(o,u),u}},"splitChunks")},"createSplitChunks");var Uo=Object.defineProperty,Ho=m((e,t)=>Uo(e,"name",{value:t,configurable:!0}),"n$4");const _=Ho((e,t,s)=>t.isDynamicEntry?`chunks/[name].${s}`:`shared/${e.options.name}.[hash].${s}`,"getChunkFilename");var qo=Object.defineProperty,Vo=m((e,t)=>qo(e,"name",{value:t,configurable:!0}),"s$7");const Go=process.platform==="win32",ge=Vo((e,t)=>{const s=Go?"\\":"/";return e.name?.includes("node_modules"+s+".pnpm")?(e.name.replace("node_modules"+s+".pnpm","external")+"."+t).replace("node_modules"+s,""):e.name?.includes("node_modules")?e.name.replace("node_modules","external")+"."+t:"[name]."+t},"getEntryFileNames");var Xo=Object.defineProperty,j=m((e,t)=>Xo(e,"name",{value:t,configurable:!0}),"l$3");const Yo=j((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 s="node"+lt.node.split(".")[0];if(t.pkg.engines?.node){const o=Ne(t.pkg.engines.node);o&&(s="node"+o.major)}if(t.options.rollup.esbuild.target){const o=U(t.options.rollup.esbuild.target);o.some(n=>n.startsWith("node"))||(t.options.rollup.esbuild.target=[...new Set([...U(s),...o])])}else t.options.rollup.esbuild.target=U(s);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"),Xe=j((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 "${b(S(g(),e.id))}"
61
+ Is the module installed? Note:
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"),he=new Map,Ye=j((e,t,s)=>{const o=j(r=>{for(const[i,a]of Object.entries(t))if(r.startsWith(i))return r.replace(i,a)},"findAlias"),n=Ue(e.tsconfig,!1);return{external(r){const i=o(r);i&&(r=i);const a=X(r),c=G(e.options.externals,a)||G(e.options.externals,r);if(c)return!0;if(r.startsWith(".")||ke(r)||/src[/\\]/.test(r)||e.pkg.name&&r.startsWith(e.pkg.name))return!1;if(n){for(const{find:p}of n)if(p.test(r))return e.logger.debug({message:`Resolved alias ${r} to ${p.source}`,prefix:s}),!1}return!c&&!he.has(r)&&e.logger.info({message:'Inlined implicit external "'+b(r)+'". If this is incorrect, add it to the "externals" option.',prefix:s}),he.set(r,!0),c},input:Object.fromEntries(e.options.entries.map(r=>[r.name,g(e.options.rootDir,r.input)])),onLog:j((r,i)=>{let a=i.message;switch(i.stack&&(a=`${a}
64
+ ${i.stack}`),r){case"info":{e.logger.info({message:a,prefix:s+(i.plugin?":plugin:"+i.plugin:"")});return}case"warn":{e.logger.warn({message:a,prefix:s+(i.plugin?":plugin:"+i.plugin:"")});return}case"debug":e.logger.debug({message:a,prefix:s+(i.plugin?":plugin:"+i.plugin:"")})}},"onLog"),onwarn(r,i){Xe(r,e)||r.code||i(r)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),Ke=j(async e=>{const t=se(e,"build");let s;return e.options.rollup.resolve&&(s=De({extensions:I,...e.options.rollup.resolve})),{...Ye(e,t,"dependencies"),output:[e.options.emitCJS&&{chunkFileNames:j(o=>_(e,o,"cjs"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:j(o=>ge(o,"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,...e.options.rollup.output,...e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:fe(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}},e.options.emitESM&&{chunkFileNames:j(o=>_(e,o,"mjs"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:j(o=>ge(o,"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,...e.options.rollup.output,...e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:fe(e.dependencyGraphMap,e.buildEntries),preserveModules:!1}}].filter(Boolean),plugins:[Fe(),Ge(),e.tsconfig&&Ve(e.options.rootDir,e.logger,e.tsconfig),e.tsconfig&&He(e.tsconfig,e.logger),e.options.rollup.replace&&Se({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&_e({customResolver:s?.resolveId,...e.options.rollup.alias,entries:t}),s,e.options.rollup.polyfillNode&&Lt({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&Ce({...e.options.rollup.json}),uo(e.logger),$s(e.options.entries.filter(o=>o.isExecutable).map(o=>o.name).filter(Boolean)),e.options.rollup.wsam&&At(e.options.rollup.wsam),e.options.transformer?.(Yo(e.options.transformerName,e)),e.options.cjsInterop&&e.options.emitCJS&&Me({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&Tt(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&Ft({extensions:I,sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),e.options.rollup.preserveDynamicImports&&{renderDynamicImport(){return{left:"import(",right:")"}}},e.options.rollup.shim&&wo(e.pkg),e.options.rollup.raw&&ho(e.options.rollup.raw),e.options.rollup.jsxRemoveAttributes&&eo({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),e.options.rollup.metafile&&io({outDir:g(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&Vs(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&Re({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&&Wt({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"),Ko=j(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"),Qo=Js(Ko),Qe=j(async e=>{const t=se(e,"types"),s={load(i){return/\.(?:js|cjs|mjs|jsx|ts|tsx|mts|json)$/.test(i)?null:""},name:"packem:ignore-files"},o=e.tsconfig?.config.compilerOptions;delete o?.lib;let n;e.options.rollup.resolve&&(n=De({extensions:I,...e.options.rollup.resolve}));const r="dts-plugin:"+process.pid+e.tsconfig.path;return{...Ye(e,t,"dts"),onwarn(i,a){Xe(i,e)||i.code!=="EMPTY_BUNDLE"&&a(i)},output:[e.options.emitCJS&&{chunkFileNames:j(i=>_(e,i,"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:j(i=>_(e,i,"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:j(i=>_(e,i,"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:[Fe(),Ge(),e.options.rollup.json&&Ce({...e.options.rollup.json}),s,e.tsconfig&&Ve(e.options.rootDir,e.logger,e.tsconfig),e.tsconfig&&He(e.tsconfig,e.logger),e.options.rollup.replace&&Se({...e.options.rollup.replace,values:{...e.options.replace,...e.options.rollup.replace.values}}),e.options.rollup.alias&&_e({customResolver:n?.resolveId,...e.options.rollup.alias,entries:t}),n,await Qo(r)(e),e.options.cjsInterop&&e.options.emitCJS&&Me({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&Mo(e.options.rollup.patchTypes,e.logger),ws(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&Re({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 Zo=Object.defineProperty,en=m((e,t)=>Zo(e,"name",{value:t,configurable:!0}),"f$5");const tn=en(async(e,t)=>{const s=await Ke(e);if(await e.hooks.callHook("rollup:options",e,s),Object.keys(s.input).length===0)return;s.cache=t.get("rollup-build");const o=await Oe(s);t.set("rollup-build",o.cache),await e.hooks.callHook("rollup:build",e,o);const n=s.output,r=new Map;for(const i of n){const{output:a}=await o.write(i),c=new Set,p=a.filter(l=>l.type==="chunk");for(const l of p){c.add(l.fileName);for(const d of l.imports)e.usedImports.add(d);l.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(l.code,"utf8"),chunks:l.imports.filter(d=>p.find(h=>h.fileName===d)),exports:l.exports,modules:Object.entries(l.modules).map(([d,h])=>({bytes:h.renderedLength,id:d})),path:l.fileName,type:"entry"})}const u=a.filter(l=>l.type==="asset");for(const l of u)r.has(l.fileName)||r.set(l.fileName,{bytes:Buffer.byteLength(l.source,"utf8"),path:l.fileName,type:"asset"});for(const l of c)e.usedImports.delete(l)}e.buildEntries.push(...r.values())},"build");var sn=Object.defineProperty,L=m((e,t)=>sn(e,"name",{value:t,configurable:!0}),"r$3");const on=L(async(e,t)=>{const s=await Qe(e);if(await e.hooks.callHook("rollup:dts:options",e,s),Object.keys(s.input).length===0)return;s.cache=t.get("rollup-dts");const o=await Oe(s);t.set("rollup-dts",o.cache),await e.hooks.callHook("rollup:dts:build",e,o),e.logger.info({message:"Building declaration files...",prefix:"dts"}),e.options.emitCJS&&await o.write({chunkFileNames:L(n=>_(e,n,"d.cts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await o.write({chunkFileNames:L(n=>_(e,n,"d.mts"),"chunkFileNames"),dir:g(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts"}),(e.options.declaration===!0||e.options.declaration==="compatible")&&await o.write({chunkFileNames:L(n=>_(e,n,"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 nn=Object.defineProperty,Ze=m((e,t)=>nn(e,"name",{value:t,configurable:!0}),"e$1");const ye=Ze((e,t,s)=>{const o="watcher:"+t;e.on("change",(n,{event:r})=>{s.info({message:`${b(S(".",n))} was ${r}d`,prefix:o})}),e.on("restart",()=>{s.info({message:"Rebuilding "+t+"...",prefix:o})}),e.on("event",n=>{n.code==="END"&&s.success({message:"Rebuild "+t+" finished",prefix:o}),n.code==="ERROR"&&s.error({context:[n.error],message:"Rebuild "+t+" failed: "+n.error.message,prefix:o})})},"watchHandler"),rn=Ze(async(e,t)=>{const s=await Ke(e);if(await e.hooks.callHook("rollup:options",e,s),Object.keys(s.input).length===0)return;s.cache=t.get("rollup-watch");const o=le(s);await e.hooks.callHook("rollup:watch",e,o);const n=[...Array.isArray(s.input)?s.input:typeof s.input=="string"?[s.input]:Object.keys(s.input??{})];let r="Starting watchers for entries:";for(const i of n)r+=P(`
65
+ └─ ${S(process.cwd(),i)}`);if(e.logger.info(r),ye(o,"bundle",e.logger),e.options.declaration){const i=await Qe(e);await e.hooks.callHook("rollup:dts:options",e,i);const a=le(i);await e.hooks.callHook("rollup:watch",e,a),ye(a,"types",e.logger)}},"watch");var an=Object.defineProperty,ln=m((e,t)=>an(e,"name",{value:t,configurable:!0}),"i$2");const et=ln(e=>`{ ${Object.keys(e).map(t=>`${t}: ${JSON.stringify(e[t])}`).join(", ")} }`,"dumpObject");var pn=Object.defineProperty,cn=m((e,t)=>pn(e,"name",{value:t,configurable:!0}),"s$5");let un=class{static{m(this,"h")}static{cn(this,"FileCache")}#e;#t;#s=!0;constructor(t,s,o){this.#e=wt("visulima-packem",{create:!0,cwd:t});const n=qt("md5");n.update(s),this.#t=n.digest("hex"),this.#e===void 0?o.debug("Could not create cache directory."):o.debug(`Cache path is: ${this.#e}`)}set isEnabled(t){this.#s=t}get(t){if(!this.#s||this.#e===void 0)return;const s=`${this.#e}/${t}-${this.#t}.json`;if(we(s))return ft(s)}set(t,s){this.#s&&(this.#e===void 0||s===void 0||$e(`${this.#e}/${t}-${this.#t}.json`,s,{indent:2,overwrite:!0}))}};var dn=Object.defineProperty,W=m((e,t)=>dn(e,"name",{value:t,configurable:!0}),"l$2");const mn=Z,fn=W((e,t)=>{const{sideEffects:s}=t;let o;if(typeof s=="boolean")o=W(()=>s,"hasSideEffects");else if(Array.isArray(s))if(s.length<=0)o=W(()=>!1,"hasSideEffects");else{const n=s.map(r=>r.includes("/")?r:`**/${r}`);o=mn(n,null,{resolve:e})}else o=W(()=>null,"hasSideEffects");return o},"getPackageSideEffect");var gn=Object.defineProperty,hn=m((e,t)=>gn(e,"name",{value:t,configurable:!0}),"t$4");const yn=hn(e=>e.replace(/\.(js|mjs|cjs|ts|mts|cts|json|jsx|tsx)$/,""),"removeExtension");var vn=Object.defineProperty,tt=m((e,t)=>vn(e,"name",{value:t,configurable:!0}),"t$3");const ne=tt(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),st=tt((e,t,s,o)=>{if(s){const i=ne(s);if(i)return i}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return o==="commonjs"?"cjs":"esm";const[n,...r]=t;return st(n,r,s,o)},"inferExportType");var bn=Object.defineProperty,jn=m((e,t)=>bn(e,"name",{value:t,configurable:!0}),"f$3");const re=jn((e,t,s,o=[])=>{if(!e)return[];if(typeof e=="string"){const n=ne(e),r=t==="module"?"esm":"cjs";if(n&&n!==r)throw new Error(`Exported file "${e}" has an extension that does not match the package.json type "${t}".`);return[{file:e,type:n??r}]}return Object.entries(e).filter(([n])=>!n.endsWith(".json")).flatMap(([n,r])=>n==="types"&&!s?[]:typeof r=="string"?{file:r,type:st(n,o,r,t)}:re(r,t,s,[...o,n]))},"extractExportFilenames");var $n=Object.defineProperty,wn=m((e,t)=>$n(e,"name",{value:t,configurable:!0}),"e");const kn=wn(e=>{const t=B(e).split("/");return t.map((s,o)=>t.slice(o).join("/")).filter(Boolean)},"getEntrypointPaths");var xn=Object.defineProperty,En=m((e,t)=>xn(e,"name",{value:t,configurable:!0}),"h$1");const On=En((e,t,s,o=".")=>{const n=[];t.sort((l,d)=>l.split("/").length-d.split("/").length);const r=re(e.exports,e.type??"commonjs",s);if(e.bin){const l=typeof e.bin=="string"?[e.bin]:Object.values(e.bin);for(const d of l)r.push({file:d,isExecutable:!0})}e.main&&r.push({file:e.main,type:ne(e.main)??(e.type==="module"?"esm":"cjs")}),e.module&&r.push({file:e.module,type:"esm"}),s===void 0&&(e.types||e.typings)&&r.push({file:e.types??e.typings});const i=e.type==="module";for(const l of r.filter(d=>!d.type)){const d=l.file.endsWith(".js");i&&d||l.file.endsWith(".mjs")?l.type="esm":(!i&&d||l.file.endsWith(".cjs"))&&(l.type="cjs")}let a=!1,c=!1,p=!1;const u=[];for(const l of r){const d=l.file.replace(/(?:\*[^/\\]*|\.d\.(?:m|c)?ts|\.\w+)$/,""),h=d.endsWith("/");if(h&&["./","/"].includes(d))continue;const f=kn(d).reduce((v,w)=>{if(v)return v;const k=new RegExp(`(?<=/|$)${w}${h?"":"\\.\\w+"}$`);return t.find(x=>k.test(x))?.replace(/(?:\.d\.(?:m|c)?ts|\.\w+)$/,"")},void 0);if(!f){ee(g(o,l.file))||n.push(`Could not find entrypoint for \`${l.file}\``);continue}l.type==="cjs"&&(a=!0),l.type==="esm"&&(c=!0);const y=u.find(v=>v.input===f)??u[u.push({input:f})-1];/\.d\.(?:m|c)?ts$/.test(l.file)&&(p=!0),h&&(y.outDir=d),l.isExecutable&&(y.isExecutable=!0)}return{cjs:a,dts:p,entries:u,esm:c,warnings:n}},"inferEntries");var _n=Object.defineProperty,Dn=m((e,t)=>_n(e,"name",{value:t,configurable:!0}),"t$2");const Sn=Dn((e,t)=>{const{publishConfig:s}=e;return s&&(s.bin&&(typeof s.bin=="object"||typeof s.bin=="string")&&(e.bin=s.bin),s.type&&typeof s.type=="string"&&s.type!==""&&(e.type=s.type),s.main&&typeof s.main=="string"&&s.main!==""&&(e.main=s.main),s.module&&typeof s.module=="string"&&s.module!==""&&(e.module=s.module),t===void 0&&s.types&&typeof s.types=="string"&&s.types!==""?e.types=s.types:t===void 0&&s.typings&&typeof s.typings=="string"&&s.typings!==""&&(e.typings=s.typings),s.exports&&typeof s.exports=="object"&&(e.exports=s.exports)),e},"overwriteWithPublishConfig");var Nn=Object.defineProperty,Pn=m((e,t)=>Nn(e,"name",{value:t,configurable:!0}),"t$1");const Mn={hooks:{"build:prepare":Pn(function(e){if(e.options.entries.length>0)return;const t=E(e.options.rootDir,"src");if(!ee(t))throw new Error("No 'src' directory found. Please provide entries manually.");const s=gt(t,{extensions:[],includeDirs:!1,includeSymlinks:!1});if(s.length===0)throw new Error("No source files found in 'src' directory. Please provide entries manually.");let o={...e.pkg};o.publishConfig&&(o=Sn(o,e.options.declaration));const n=On(o,s,e.options.declaration,e.options.rootDir);for(const r of n.warnings)F(e,r);if(e.options.entries.push(...n.entries),e.options.emitCJS===void 0&&n.cjs&&(e.options.emitCJS=!0),e.options.emitESM===void 0&&n.esm&&(e.options.emitESM=!0),e.options.declaration===void 0&&n.dts&&(e.options.declaration=n.dts),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",b(e.options.entries.map(r=>O(r.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),P([n.esm&&"esm",n.cjs&&"cjs",n.dts&&"dts"].filter(Boolean).map(r=>`[${r}]`).join(" ")))},"build:prepare")}};var Cn=Object.defineProperty,In=m((e,t)=>Cn(e,"name",{value:t,configurable:!0}),"r");const ot=In((e,t)=>Ee(t,{esmResolve:!0,interopDefault:!0})(e),"tryRequire");var Rn=Object.defineProperty,Fn=m((e,t)=>Rn(e,"name",{value:t,configurable:!0}),"t");const Tn=Fn((e,t)=>(e==="auto"?e=Mn:typeof e=="string"&&(e=ot(e,t)),typeof e=="function"&&(e=e()),e),"resolvePreset");var An=Object.defineProperty,Ln=m((e,t)=>An(e,"name",{value:t,configurable:!0}),"o");const Wn=Ln(e=>{const t=new Set,s=new Set(Object.keys(e.pkg.dependencies??{})),o=new Set;for(const n of e.usedImports)s.delete(n),t.add(n);if(Array.isArray(e.options.dependencies))for(const n of e.options.dependencies)s.delete(n);for(const n of t)!G(e.options.externals,n)&&!n.startsWith("chunks/")&&!e.options.dependencies.includes(X(n))&&!e.options.peerDependencies.includes(X(n))&&o.add(n);s.size>0&&F(e,`Potential unused dependencies found: ${[...s].map(n=>b(n)).join(", ")}`),o.size>0&&F(e,`Potential implicit dependencies found: ${[...o].map(n=>b(n)).join(", ")}`)},"validateDependencies");var Bn=Object.defineProperty,nt=m((e,t)=>Bn(e,"name",{value:t,configurable:!0}),"i");const Jn=nt((e,t)=>Vt(e,t)<=e.length/3||t.includes(e),"isSimilar"),zn=nt((e,t)=>{const s=e.toLowerCase();return t.filter(o=>Jn(o.toLowerCase(),s))},"findAlternatives");var Un=Object.defineProperty,ve=m((e,t)=>Un(e,"name",{value:t,configurable:!0}),"n");const Hn=ve((e,t)=>{const s=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:"",...re(e.exports,e.type??"commonjs",t.options.declaration).map(n=>n.file)].map(n=>n&&g(t.rootDir,n.replace(/\/[^*/]*\*[^\n\r/\u2028\u2029]*(?:[\n\r\u2028\u2029][^*/]*\*[^\n\r/\u2028\u2029]*)*(?:\/.*)?$/,"")))),o=[];for(const n of s)n&&!n.includes("*")&&!ee(n)&&o.push(n.replace(`${t.rootDir}/`,""));if(o.length>0){const n=ve(a=>S(t.rootDir,g(t.options.outDir,a)),"rPath"),r=t.buildEntries.filter(a=>!a.chunk).map(a=>n(a.path));let i="Potential missing or wrong package.json files:";for(const a of o){const c=zn(a,r);i+=`
66
+ - `+b(a)+(c.length>0?ct` (did you mean ${c.map(p=>`"${p}"`).join(", ")}?)`:"")}F(t,i)}},"validatePackage");var qn=Object.defineProperty,$=m((e,t)=>qn(e,"name",{value:t,configurable:!0}),"m");const be=$((e,t)=>{e.warnings.size>0&&(t&&e.logger.raw(`
67
+ `),e.logger.warn(`Build is done with some warnings:
68
+
69
+ ${[...e.warnings].map(s=>`- ${s}`).join(`
70
+ `)}`),e.options.failOnWarn&&(e.logger.error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`."),M(1)))},"logErrors"),Vn=$(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"),Gn=$((e,t,s,o,n,r,i,a)=>{const c=Vn(a?.config.compilerOptions?.jsx),p=Nt(n,o,r,{alias:{},cache:!0,clean:!0,declaration:void 0,dependencies:[],devDependencies:[],emitCJS:void 0,emitESM:void 0,entries:[],externals:[...ie.builtinModules,...ie.builtinModules.map(u=>`node:${u}`)],failOnWarn:!0,minify:R.NODE_ENV==="production",name:(i.name??"").split("/").pop()??"default",optionalDependencies:[],outDir:"dist",peerDependencies:[],replace:{},rollup:{alias:{},cjsInterop:{addDefaultProperty:!1},commonjs:{ignoreTryCatch:!0,preserveSymlinks:!0,transformMixedEsModules:!1},dts:{compilerOptions:{baseUrl:a?.config.compilerOptions?.baseUrl??".",checkJs:!1,composite:!1,declaration:!0,declarationMap:!1,emitDeclarationOnly:!0,incremental:!1,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:a?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:a?.config.compilerOptions?.jsxFactory,jsxFragment:a?.config.compilerOptions?.jsxFragmentFactory,jsxImportSource:a?.config.compilerOptions?.jsxImportSource,jsxSideEffects:!0,keepNames:!0,minifyWhitespace:R.NODE_ENV==="production",sourcesContent:!1,target:a?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:a?.config},json:{preferConst:!0},license:{dependenciesTemplate:$((u,l,d)=>`
71
+ # Licenses of bundled dependencies
72
+ The published ${d} artifact additionally contains code with the following licenses:
73
+ ${u.join(", ")}
74
+
75
+ # Bundled dependencies:
76
+ `+l,"dependenciesTemplate"),dtsTemplate:$((u,l,d)=>`
77
+ # Licenses of bundled types
78
+ The published ${d} artifact additionally contains code with the following licenses:
79
+ ${u.join(", ")}
80
+
81
+ # Bundled types:
82
+ `+l,"dtsTemplate")},patchTypes:{},polyfillNode:{},preserveDynamicImports:!0,raw:{exclude:ae,include:["**/*.data","**/*.txt"]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,preferBuiltins:!1},shim:!0,sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:a?.config.compilerOptions?.esModuleInterop===!1,include:/\.[jt]sx?$/,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:R.NODE_ENV==="production",...a?.config.compilerOptions?.jsx&&["react","react-jsx","react-jsxdev"].includes(a.config.compilerOptions.jsx)?{jsxFragmentPragma:a.config.compilerOptions.jsxFragmentFactory,jsxImportSource:a.config.compilerOptions.jsxImportSource,jsxPragma:a.config.compilerOptions.jsxFactory,jsxRuntime:c,transforms:["typescript","jsx",...a.config.compilerOptions.esModuleInterop?["imports"]:[]]}:{transforms:["typescript",...a?.config.compilerOptions?.esModuleInterop?["imports"]:[]]}},swc:{include:/\.[jt]sx?$/,inlineSourcesContent:!1,inputSourceMap:!1,isModule:!0,jsc:{experimental:{keepImportAttributes:!0},externalHelpers:!1,keepClassNames:!0,loose:!0,parser:{decorators:a?.config.compilerOptions?.experimentalDecorators,syntax:a?"typescript":"ecmascript",[a?"tsx":"jsx"]:!0},target:a?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:a?.config.compilerOptions?.emitDecoratorMetadata,legacyDecorator:a?.config.compilerOptions?.experimentalDecorators,react:{development:R.NODE_ENV!=="production",pragma:a?.config.compilerOptions?.jsxFactory,pragmaFrag:a?.config.compilerOptions?.jsxFragmentFactory,runtime:c,throwIfNamespace:!0},treatConstEnumAsEnum:a?.config.compilerOptions?.preserveConstEnums,useDefineForClassFields:a?.config.compilerOptions?.useDefineForClassFields}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"}},treeshake:{moduleSideEffects:fn(t,i),preset:"recommended"},watch:{clearScreen:!0,exclude:ae}},rootDir:t,sourcemap:!1,stub:s==="jit",stubOptions:{jiti:{alias:{},esmResolve:!0,interopDefault:!0}},transformerName:void 0});if(!p.transformerName){const u=new Set([...Object.keys(i.dependencies??{}),...Object.keys(i.devDependencies??{})]);if(u.has("esbuild"))p.transformerName="esbuild";else if(u.has("@swc/core"))p.transformerName="swc";else if(u.has("sucrase"))p.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 "'+b(p.transformerName)+'" as transformer.')}return p.outDir=g(p.rootDir,p.outDir),p.rollup.resolve&&p.rollup.resolve.preferBuiltins===!0&&(p.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true")),a?.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.`),p.dependencies=Object.keys(i.dependencies??{}),p.peerDependencies=Object.keys(i.peerDependencies??{}),p.devDependencies=Object.keys(i.devDependencies??{}),p.optionalDependencies=Object.keys(i.optionalDependencies??{}),p.externals.push(...p.dependencies,...p.peerDependencies,...p.optionalDependencies),p},"generateOptions"),Xn=$(async(e,t)=>{e.options.entries=e.options.entries.map(s=>typeof s=="string"?{input:s}:s);for await(const s of e.options.entries){if(typeof s.name!="string"){let o=ke(s.input)?S(t,s.input):B(s.input);o.startsWith("./")&&(o=o.slice(2)),s.name=yn(o.replace(/^src\//,""))}if(!s.input)throw new Error(`Missing entry input: ${et(s)}`);if(!e.options.declaration&&s.declaration===void 0&&(s.declaration=e.options.declaration),s.input=g(e.options.rootDir,s.input),!we(s.input)){const o=new Set(await at(Q(s.input)));let n=!1;for(const r of I)if(o.has(J(s.input)+r)){n=!0;break}if(!n)throw new jt("Your configured entry: "+b(s.input)+" does not exist.")}s.outDir=g(e.options.rootDir,s.outDir??e.options.outDir)}},"prepareEntries"),Yn=$((e,t,s)=>{const o=$(r=>S(t.rootDir,g(t.options.outDir,r)),"rPath");let n=!1;for(const r of t.buildEntries.filter(i=>!i.chunk)){let i=r.bytes??0;for(const c of r.chunks??[])i+=t.buildEntries.find(p=>p.path===c)?.bytes??0;let a=` ${O(o(r.path))} (${["total size: "+b(N(i)),r.type!=="asset"&&r.bytes&&"chunk size: "+b(N(r.bytes))].filter(Boolean).join(", ")})`;if(a+=r.exports?.length?`
85
+ exports: `+P(r.exports.join(", ")):"",r.chunks?.length&&(a+=`
86
+ ${r.chunks.map(c=>{const p=t.buildEntries.find(u=>u.path===c)??{};return P(" └─ "+o(c)+O(p.bytes?" ("+N(p?.bytes)+")":""))}).join(`
87
+ `)}`),r.modules&&r.modules.length>0){const c=r.modules.filter(p=>p.id.includes("node_modules")).sort((p,u)=>(u.bytes||0)-(p.bytes||0)).map(p=>P(" 📦 "+o(p.id)+O(p.bytes?" ("+N(p.bytes)+")":""))).join(`
88
+ `);a+=c.length>0?`
89
+ inlined modules:
90
+ `+c:""}if(t.options.declaration&&r.type==="entry"){let c=r.path.replace(/\.js$/,".d.ts"),p="commonjs";r.path.endsWith(".cjs")?c=r.path.replace(/\.cjs$/,".d.cts"):r.path.endsWith(".mjs")&&(p="module",c=r.path.replace(/\.mjs$/,".d.mts"));const u=t.buildEntries.find(l=>l.path.endsWith(c));if(u){let l;(t.options.declaration===!0||t.options.declaration==="compatible")&&!c.includes(".d.ts")&&(c=c.replace(p==="commonjs"?".d.c":".d.m",".d."),l=t.buildEntries.find(d=>d.path.endsWith(c))),a+=l&&p===s.type?`
91
+ types:
92
+ `+[u,l].map(d=>P(" └─ ")+O(o(d.path))+" (total size: "+b(N(d.bytes??0))+")").join(`
93
+ `):`
94
+ types: `+O(o(u.path))+" (total size: "+b(N(u.bytes??0))+")"}}n=!0,a+=`
95
+
96
+ `,e.raw(r.chunk?P(a):a)}return n&&e.raw("Σ Total dist size (byte size):",b(N(t.buildEntries.reduce((r,i)=>r+(i.bytes??0),0))),`
97
+ `),n},"showSizeInformation"),Kn=$(async(e,t,s,o,n,r,i,a,c)=>{const p=Tn(n.preset??o.preset??"auto",t),u=Gn(e,t,s,o,n,p,r,i);a.isEnabled=u.cache,ht(u.outDir);const l={buildEntries:[],dependencyGraphMap:new Map,hooks:Pt(),logger:e,mode:s,options:u,pkg:r,rootDir:t,tsconfig:i,usedImports:new Set,warnings:new Set};if(p.hooks&&l.hooks.addHooks(p.hooks),o.hooks&&l.hooks.addHooks(o.hooks),n.hooks&&l.hooks.addHooks(n.hooks),await l.hooks.callHook("build:prepare",l),l.options.emitESM===!1&&l.options.emitCJS===!1)throw new Error("Both emitESM and emitCJS are disabled. At least one of them must be enabled.");if(l.options.declaration&&i===void 0)throw new Error("Cannot build declaration files without a tsconfig.json");l.options.emitESM===void 0&&e.info("Emitting ESM bundles, is disabled."),l.options.emitCJS===void 0&&e.info("Emitting CJS bundles, is disabled."),l.options.declaration||e.info("Declaration files, are disabled."),await Xn(l,t),await l.hooks.callHook("build:before",l);let d="Building";if(s==="watch"?d="Watching":s==="jit"&&(d="Stubbing"),e.info(b(`${d} ${l.options.name}`)),e.debug(`${O("Root dir:")} ${l.options.rootDir}
98
+ ${O("Entries:")}
99
+ ${l.options.entries.map(f=>` ${et(f)}`).join(`
100
+ `)}`),l.options.clean)for(const f of new Set(l.options.entries.map(y=>y.outDir).filter(Boolean).sort()))f===l.options.rootDir||l.options.rootDir.startsWith(f.endsWith("/")?f:`${f}/`)||c.some(y=>f.startsWith(y))||(c.push(f),e.info(`Cleaning dist directory: \`./${S(l.options.rootDir,f)}\``),await yt(f));if(l.options.stub){await Cs(l),await l.hooks.callHook("build:done",l);return}if(s==="watch"){await rn(l,a),be(l,!1);return}await Promise.all([tn(l,a),l.options.declaration&&on(l,a)]),e.success(ut(`Build succeeded for ${l.options.name}`));for await(const f of vt(l.options.outDir)){let y=l.buildEntries.find(v=>E(l.options.outDir,v.path)===f.path);if(y||(y={chunk:!0,path:f.path},l.buildEntries.push(y)),!y.bytes){const v=await je(g(l.options.outDir,f.path));y.bytes=v.size}}const h=Yn(e,l,r);Wn(l),Hn(r,l),await l.hooks.callHook("build:done",l),be(l,h)},"build"),Ar=$(async(e,t,s={})=>{const{configPath:o,debug:n,tsconfigPath:r,...i}=s,a=[new _t,new Dt];n&&a.push(new St);const c=Ot({logLevel:n?"debug":"informational",processors:a,scope:"packem"});e=g(pt(),e),c.debug("Root directory:",e);const p=E(e,"package.json"),u=Et(p);c.debug("Using package.json found at",p);let l;if(r){const d=E(e,r);await bt(d)||(c.error("tsconfig.json not found at",d),M(1)),l={config:kt(d),path:d},c.info("Using tsconfig settings at",d)}else try{l=await xt(e),c.debug("Using tsconfig settings found at",l.path)}catch{c.info("No tsconfig.json or jsconfig.json found.")}try{const d=o??"./packem.config.ts";/\.(?:js|mjs|cjs|ts)$/.test(d)||(c.error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts extensions are allowed."),M(1));const h=ot(d,e);c.debug("Using packem config found at",E(e,d));const f=(Array.isArray(h)?h:[h]).filter(Boolean),y=Date.now(),v=$(()=>$t(Math.floor(Date.now()-y)),"getDuration"),w=[],k=[],x=new un(e,bs.version,c);for(const T of f)k.push(Kn(c,e,t,i,T,u,l,x,w));await Promise.all(k),c.raw(`
101
+ ⚡️ Build`+(k.length>1?"s":"")+" run in "+v()),c.restoreAll(),M(0)}catch(d){c.error("An error occurred while building",d),M(1)}},"createBundler");export{Ar as O,Gt as n,Xt as v};
@@ -100,6 +100,7 @@ type BuildEntry = {
100
100
  };
101
101
  interface BuildOptions {
102
102
  alias: Record<string, string>;
103
+ cache?: boolean;
103
104
  cjsInterop?: boolean;
104
105
  clean: boolean;
105
106
  declaration?: boolean | "compatible" | "node16";
@@ -100,6 +100,7 @@ type BuildEntry = {
100
100
  };
101
101
  interface BuildOptions {
102
102
  alias: Record<string, string>;
103
+ cache?: boolean;
103
104
  cjsInterop?: boolean;
104
105
  clean: boolean;
105
106
  declaration?: boolean | "compatible" | "node16";
@@ -100,6 +100,7 @@ type BuildEntry = {
100
100
  };
101
101
  interface BuildOptions {
102
102
  alias: Record<string, string>;
103
+ cache?: boolean;
103
104
  cjsInterop?: boolean;
104
105
  clean: boolean;
105
106
  declaration?: boolean | "compatible" | "node16";