@visulima/packem 1.0.9 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +16 -0
- package/dist/{typedoc/index.d.ts → builder/typedoc/generate-reference-documentation.d.cts} +1 -1
- package/dist/{typedoc/index.d.mts → builder/typedoc/generate-reference-documentation.d.mts} +1 -1
- package/dist/{typedoc/index.d.cts → builder/typedoc/generate-reference-documentation.d.ts} +1 -1
- package/dist/builder/typedoc/index.cjs +3 -0
- package/dist/builder/typedoc/index.d.cts +5 -0
- package/dist/builder/typedoc/index.d.mts +3 -0
- package/dist/builder/typedoc/index.d.ts +5 -0
- package/dist/builder/typedoc/index.mjs +5 -0
- package/dist/cli.mjs +66 -60
- package/dist/commands/add.d.mts +3 -0
- package/dist/create-bundler.cjs +60 -62
- package/dist/create-bundler.mjs +63 -65
- package/dist/packem_shared/create-or-update-key-storage-BxGi6kMH.mjs +3 -0
- package/dist/packem_shared/create-or-update-key-storage-DslhcsTU.cjs +3 -0
- package/dist/types.d.cts +5 -1
- package/dist/types.d.mts +5 -1
- package/dist/types.d.ts +5 -1
- package/dist/utils/find-packem-file.d.cts +4 -0
- package/dist/utils/find-packem-file.d.mts +2 -0
- package/dist/utils/find-packem-file.d.ts +4 -0
- package/package.json +35 -6
package/dist/cli.mjs
CHANGED
|
@@ -1,115 +1,121 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
2
|
+
var lo=Object.defineProperty;var m=(e,t)=>lo(e,"name",{value:t,configurable:!0});import co from"@visulima/cerebro";import{SimpleReporter as po}from"@visulima/pail/reporter";import{cwd as pt,env as ne,versions as uo,exit as mo}from"node:process";import{installPackage as ie}from"@antfu/install-pkg";import{isAccessible as ut,readFile as Oe,writeFile as fo,readFileSync as Ne,writeFileSync as F,writeJsonSync as me,readJsonSync as Pe,walk as go,isAccessibleSync as S,collectSync as yo,ensureDirSync as ho,emptyDir as vo}from"@visulima/fs";import{join as w,resolve as $,normalize as dt,relative as O,dirname as V,basename as fe,toNamespacedPath as se,extname as mt,isAbsolute as ft}from"@visulima/path";import _ from"magic-string";import{readdirSync as gt,existsSync as yt}from"node:fs";import{stat as ht,chmod as bo,rm as wo}from"node:fs/promises";import Re from"node:module";import{cyan as k,bold as N,gray as M,green as $o,yellow as jo,grey as ko}from"@visulima/colorize";import{findCacheDirSync as xo}from"@visulima/find-cache-dir";import{formatBytes as I,duration as Fe}from"@visulima/humanizer";import{readTsConfig as Eo,findTsConfig as Do}from"@visulima/tsconfig";import{defu as So}from"defu";import{createHooks as Oo}from"hookable";import{createJiti as vt}from"jiti";import{rollup as bt,watch as Je,VERSION as No}from"rollup";import wt from"@rollup/plugin-alias";import Po from"@rollup/plugin-commonjs";import Co from"@rollup/plugin-dynamic-import-vars";import{nodeResolve as $t}from"@rollup/plugin-node-resolve";import jt from"@rollup/plugin-replace";import{wasm as _o}from"@rollup/plugin-wasm";import To from"rollup-plugin-polyfill-node";import{visualizer as Io}from"rollup-plugin-visualizer";import{minVersion as kt,valid as Mo,coerce as Ao}from"semver";import ae from"node:assert/strict";import{extractAssignedNames as Ro,createFilter as z,normalizePath as Be}from"@rollup/pluginutils";import Fo from"glob-parent";import{glob as Jo,isDynamicPattern as Le,globSync as Bo}from"tinyglobby";import{findStaticImports as xt,fileURLToPath as Lo,resolveModuleExportNames as Wo,resolvePath as We}from"mlly";import{parseAsync as Vo}from"oxc-parser";import zo from"@rollup/plugin-json";import Uo from"rollup-plugin-license";import{createHash as Ko}from"node:crypto";import{fileURLToPath as Ho}from"node:url";import{parse as qo}from"@babel/parser";import{parsePackageJson as Et}from"@visulima/package/package-json";import{NotFoundError as Go}from"@visulima/fs/error";import{isRelative as Xo}from"@visulima/path/utils";import{distance as Yo}from"fastest-levenshtein";import{intro as Qo,confirm as L,spinner as U,log as Ve,select as ze,cancel as Zo,outro as er}from"@clack/prompts";import __cjs_url__ from "node:url"; // -- packem CommonJS __filename shim --
|
|
3
3
|
import __cjs_path__ from "node:path"; // -- packem CommonJS __dirname shim --
|
|
4
4
|
import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
|
|
5
5
|
const __filename = __cjs_url__.fileURLToPath(import.meta.url);
|
|
6
6
|
const __dirname = __cjs_path__.dirname(__filename);
|
|
7
7
|
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
8
|
-
const
|
|
8
|
+
const tr="@visulima/packem",or="1.0.9";var rr=Object.defineProperty,nr=m((e,t)=>rr(e,"name",{value:t,configurable:!0}),"t$b");const Dt=nr(async(e,t="")=>{let o=t;if(!o){const r=["packem.config.js","packem.config.mjs","packem.config.cjs","packem.config.ts","packem.config.cts","packem.config.mts"];for await(const n of r)if(await ut(w(e,n))){o="./"+n;break}}if(!/\.(?:js|mjs|cjs|ts|cts|mts)$/.test(o))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts, .cts and .mts extensions are allowed.");return o},"findPackemFile");var ir=Object.defineProperty,Ue=m((e,t)=>ir(e,"name",{value:t,configurable:!0}),"d$g");const sr=["typedoc","typedoc-plugin-markdown","typedoc-plugin-rename-defaults","@ckeditor/typedoc-plugins"],ar=Ue(e=>{e.addCommand({argument:{description:"Add a packem feature to your project",name:"feature",required:!0},description:"Add a optional packem feature to your project",execute:Ue(async({argument:t,logger:o,options:r})=>{const n=$(pt(),r.dir??"."),i=await Dt(n,r.config??""),s=await Oe(i,{buffer:!1}),a=new _(s);if(t.includes("typedoc")){if(s.includes("typedoc: typedocBuilder")||s.includes("@visulima/packem/builder/typedoc")){o.warn("Typedoc has already been added to the packem config.");return}o.info("Adding typedoc dependencies..."),await ie(sr,{cwd:process.cwd(),dev:!0,silent:!0}),a.prepend(`import typedocBuilder from "@visulima/packem/builder/typedoc";
|
|
9
|
+
`),s.includes("builder: {")?a.replace("builder: {",`builder: {
|
|
10
|
+
typedoc: typedocBuilder,
|
|
11
|
+
`):a.replace("transformer,",`transformer,
|
|
12
|
+
builder: {
|
|
13
|
+
typedoc: typedocBuilder,
|
|
14
|
+
},`),o.success("Typedoc added!")}await fo(i,a.toString(),{overwrite:!0})},"execute"),name:"add",options:[{defaultValue:".",description:"The directory to build",name:"dir",type:String},{description:"Use a custom config file",name:"config",type:String}]})},"createAddCommand"),Ce=[".mjs",".js",".json",".node",".cjs",".ts",".cts",".mts",".tsx",".ctsx",".mtsx",".jsx"],C="production",G="development",_e=new Set(["react-server","react-native","edge-light"]),le=new Set([G,C,..._e]),W=/node_modules/,J=/(?:\.d\.[mc]?tsx?|\.\w+)$/,lr="packem_chunks",cr="packem_shared",K=/\.(?:m|c)?(?:j|t)sx?$/;var pr=Object.defineProperty,ur=m((e,t)=>pr(e,"name",{value:t,configurable:!0}),"a$g");const Ee=ur((e,t)=>e.some(o=>o instanceof RegExp?o.test(t):o===t),"arrayIncludes");var dr=Object.defineProperty,mr=m((e,t)=>dr(e,"name",{value:t,configurable:!0}),"a$f");const q=mr(e=>e==null?[]:Array.isArray(e)?e:[e],"arrayify");var fr=Object.defineProperty,gr=m((e,t)=>fr(e,"name",{value:t,configurable:!0}),"a$e");const St=gr((e="")=>{const t=e.split("/");return t[0].startsWith("@")?t[0]+"/"+t[1]:t[0]},"getPackageName");var yr=Object.defineProperty,Ot=m((e,t)=>yr(e,"name",{value:t,configurable:!0}),"s$f");const hr=Ot((e,t,o)=>{const r=o??new Map;return(...n)=>{const i=t?typeof t=="function"?t(...n):t:JSON.stringify({args:n}),s=r.get(i);if(s!==void 0)return s;const a=e(...n);return r.set(i,a),a}},"memoize"),vr=Ot(e=>{const t=new Map;return o=>hr(e,o,t)},"memoizeByKey");var br=Object.defineProperty,X=m((e,t)=>br(e,"name",{value:t,configurable:!0}),"r$f");const wr=X(function*(e){switch(e.declaration?.type){case"ClassDeclaration":case"FunctionDeclaration":{const{id:t}=e.declaration;ae(t,"Expected class/function to have a name"),yield t.name;break}case"VariableDeclaration":{for(const t of e.declaration.declarations)for(const o of Ro(t.id))yield o;break}}},"exportName"),$r=X(function*(e){if(e.declaration)for(const t of wr(e))yield{exportedName:t,from:"self",type:"named"};else if(e.source)yield{bindings:e.specifiers.map(t=>({exportedName:t.exported.name,importedName:t.local.name})),from:"other",source:e.source.value,type:"named"};else for(const t of e.specifiers)yield{exportedName:t.exported.name,from:"self",type:"named"}},"parseExportNamed"),jr=X(function*(e){e.exported?yield{exportedName:e.exported.name,from:"self",type:"named"}:yield{from:"other",source:e.source.value,type:"barrel"}},"parseExportAll"),kr=X(function*(){yield{exportedName:"default",from:"self",type:"named"}},"parseExportDefault"),xr=X(function*(e,t){ae(t.code!=null,`Module ${t.id} doesn't have associated code`);const o=e.parse(t.code);for(const r of o.body)switch(r.type){case"ExportAllDeclaration":{yield*jr(r);break}case"ExportDefaultDeclaration":{yield*kr();break}case"ExportNamedDeclaration":{yield*$r(r);break}}},"parseExports");var Er=Object.defineProperty,Y=m((e,t)=>Er(e,"name",{value:t,configurable:!0}),"n$9");const Nt=Y(async function(e,t,o){const r=await e.resolve(t,o.id);if(ae(r,`Rollup can't resolve ${t} from ${o.id}`),r.external)return null;const n=await e.load(r);return ae(n,`Rollup doesn't have a module for id ${r.id}`),n},"getImportedModule"),Dr=Y(async function*(e,t,o){const r=await Nt(e,t.source,o);r&&(yield*Te(e,r))},"gatherBarrelReExports"),Sr=Y(async function*(e,t,o){const r=await Nt(e,t.source,o);if(!r)return;const n=new Map(t.bindings.map(i=>[i.importedName,i]));for await(const i of Te(e,r)){const s=n.get(i.exportedName);s&&(yield{...i,exportedName:s.exportedName})}},"gatherNamedReExports"),Or=Y(async function*(e,t){yield{exportedName:t.exportedName,id:e.id,sourceName:t.exportedName}},"gatherNamedSelfExports"),Te=Y(async function*(e,t){for(const o of xr(e,t))o.from==="self"?yield*Or(t,o):o.type==="barrel"?yield*Dr(e,o,t):yield*Sr(e,o,t)},"gatherExports");var Nr=Object.defineProperty,Pr=m((e,t)=>Nr(e,"name",{value:t,configurable:!0}),"r$e");const Cr=Pr(()=>({moduleParsed:{async handler(e){if(e.isEntry)for await(const t of Te(this,e))t.id!==e.id&&this.emitFile({id:t.id,name:t.exportedName,preserveSignature:"exports-only",type:"chunk"})},order:"post"},name:"packem:chunk-splitter"}),"chunkSplitter");var _r=Object.defineProperty,Tr=m((e,t)=>_r(e,"name",{value:t,configurable:!0}),"r$d");const Ir=Tr((e,t)=>{const o=e,r=[];let n;for(;(n=o.exec(t))!==null;)n.index===o.lastIndex&&o.lastIndex++,n.forEach(i=>{r.push(i)});return r.filter(Boolean)},"getRegexMatches");var Mr=Object.defineProperty,Ar=m((e,t)=>Mr(e,"name",{value:t,configurable:!0}),"a$d");const Pt=Ar(e=>{const t=Ir(/export\s(\{\s(.*)\s\}|default\s.*);/g,e);if(t.length===0)return null;const o=t.at(-1).split(", ");let r="";for(const n of o)if(!n.includes("type")&&(n.includes("default ")&&(r=n.split("default ")[1]),n.includes("as"))){const[i,s]=n.split(" as ");s==="default"&&(r=i)}if(r!==""){const n=new _(e);return n.replace(new RegExp(`(,s)?${r} as default(,)?`),""),n.replace(new RegExp(`export default ${r};
|
|
9
15
|
?`),""),n.append(`
|
|
10
16
|
|
|
11
|
-
export = `+r+";"),{code:n.toString().replace(/export\s\{\s\s\};/,""),map:n.generateMap({hires:!0})}}return null},"patchCjsDefaultExport");var
|
|
12
|
-
module.exports.default = `+s[2]+";");let l=a.toString();return l=l.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+n.fileName+".",prefix:"plugin:cjs-interop"}),{code:l,map:a.generateMap({hires:!0})}}return i.format==="es"&&/\.d\.(?:ts|cts)$/.test(n.fileName)?o!=="commonjs"&&n.fileName.endsWith(".d.mts")?null:
|
|
17
|
+
export = `+r+";"),{code:n.toString().replace(/export\s\{\s\s\};/,""),map:n.generateMap({hires:!0})}}return null},"patchCjsDefaultExport");var Rr=Object.defineProperty,Ke=m((e,t)=>Rr(e,"name",{value:t,configurable:!0}),"i$b");const Ct=Ke(({addDefaultProperty:e=!1,logger:t,type:o})=>({name:"packem:cjs-interop",renderChunk:Ke(async(r,n,i)=>{if(n.type!=="chunk"||!n.isEntry)return null;if(i.format==="cjs"&&i.exports==="auto"){const s=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(r);if(s===null||s.length<3)return null;const a=new _(r);a.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),a.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&a.append(`
|
|
18
|
+
module.exports.default = `+s[2]+";");let l=a.toString();return l=l.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+n.fileName+".",prefix:"plugin:cjs-interop"}),{code:l,map:a.generateMap({hires:!0})}}return i.format==="es"&&/\.d\.(?:ts|cts)$/.test(n.fileName)?o!=="commonjs"&&n.fileName.endsWith(".d.mts")?null:Pt(r):null},"renderChunk")}),"cjsInteropPlugin");var Fr=Object.defineProperty,Jr=m((e,t)=>Fr(e,"name",{value:t,configurable:!0}),"f$9");const Br=Jr((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(i=>{if(typeof i=="string")return{src:i};if(typeof i=="object"&&"src"in i)return i}).filter(Boolean):typeof n=="string"&&(n=[{src:n}]),{async buildStart(){const i=await Promise.all(n.flatMap(s=>Array.isArray(s.src)?s.src.map(a=>({...s,src:a})):s).map(async s=>await Jo(q(s.src),{ignore:q(s.exclude).filter(Boolean)}).then(a=>({dest:s.dest??"",parent:Fo(s.src),src:a}))));for(const s of i)for(const a of s.src){let l;o.has(a)?l=o.get(a):(l={copied:[],dest:[],timestamp:0},o.set(a,l));const c=r.flatten?dt(s.dest):w(s.dest,O(s.parent,V(a)));l.dest.includes(c)||l.dest.push(c),this.addWatchFile(a)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...o].map(async([s,a])=>{let l;try{const c=await ht(s);if(!c.isFile())return;const u=c.mtime.getTime();u>a.timestamp&&(a.timestamp=u,a.copied=[]),l=await Oe(s,{buffer:!0})}catch(c){t.error({context:[c],message:`error reading file ${s}`,prefix:"plugin:copy"});return}for(const c of a.dest){if(r.copyOnce&&a.copied.includes(c))continue;const u=fe(s),p=w(c,u);try{this.emitFile({[r.exactFileNames?"fileName":"name"]:p,source:l,type:"asset"}),t.debug({message:`copied ${s} → ${p}`,prefix:"plugin:copy"}),a.copied.push(c)}catch(d){t.error({context:[d],message:`error copying file ${s} → ${p}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");var Lr=Object.defineProperty,ge=m((e,t)=>Lr(e,"name",{value:t,configurable:!0}),"t$a");const Wr=/\Wrequire(?:\.resolve)?\(/,Vr=ge((e,t)=>{if(ne.INTERNAL_PACKEM_BUILD!=="1"&&(e.includes("// -- packem CommonJS __filename shim")||e.includes("// -- packem CommonJS __dirname shim")||e.includes("// -- packem CommonJS require shim")))return null;let o=!1,r=!1,n=!1;if(e.includes("__filename")&&(o=!0),e.includes("__dirname")&&(r=!0),Wr.test(e)&&(n=!0),!o&&!r&&!n)return null;const i=xt(e).pop(),s=i?i.end:0,a=new _(e);return a.appendRight(s,t(o,r,n)),{code:a.toString(),map:a.generateMap()}},"CJSToESM"),zr=ge((e,t,o)=>{let r="";return(e||t)&&(r+=`import __cjs_url__ from "node:url"; // -- packem CommonJS __filename shim --
|
|
13
19
|
`),t&&(r+=`import __cjs_path__ from "node:path"; // -- packem CommonJS __dirname shim --
|
|
14
20
|
`),o&&(r+=`import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
|
|
15
21
|
`),(e||t)&&(r+=`const __filename = __cjs_url__.fileURLToPath(import.meta.url);
|
|
16
22
|
`),t&&(r+=`const __dirname = __cjs_path__.dirname(__filename);
|
|
17
23
|
`),o&&(r+=`const require = __cjs_mod__.createRequire(import.meta.url);
|
|
18
|
-
`),r},"generateCJSShim"),
|
|
24
|
+
`),r},"generateCJSShim"),Ur=ge((e,t,o)=>{let r="";return o&&(r+=`import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
|
|
19
25
|
`),e&&(r+=`const __filename = import.meta.filename; // -- packem CommonJS __filename shim --
|
|
20
26
|
`),t&&(r+=`const __dirname = import.meta.dirname; // -- packem CommonJS __dirname shim --
|
|
21
27
|
`),o&&(r+=`const require = __cjs_mod__.createRequire(import.meta.url);
|
|
22
|
-
`),r},"generateCJSShimNode20_11"),
|
|
28
|
+
`),r},"generateCJSShimNode20_11"),Kr=ge((e,t)=>{const o=z(t.include,t.exclude);return{name:"packem:esm-shim-cjs-syntax",renderChunk(r,n,i){if(i.format==="es"&&o(n.fileName)){let s=zr;if(e.engines?.node){const a=kt(e.engines.node);a&&a.major>=20&&a.minor>=11&&(s=Ur)}return Vr(r,s)}return null}}},"esmShimCjsSyntaxPlugin");var Hr=Object.defineProperty,qr=m((e,t)=>Hr(e,"name",{value:t,configurable:!0}),"m$a");const Gr=qr(()=>({name:"packem:fix-dynamic-import-extension",renderChunk(e,t,o){return o.format==="es"||o.format==="cjs"?{code:e.replaceAll(/(import\(.*)(.ts)(['´"`]\))/g,"$1."+(o.format==="es"?"mjs":"cjs")+"$3"),map:null}:null}}),"fixDynamicImportExtension");var Xr=Object.defineProperty,Yr=m((e,t)=>Xr(e,"name",{value:t,configurable:!0}),"a$c");const Qr=Yr((e,t)=>{const o=e.replace(/^\.\//,""),r=t.replace(/^\.\//,"");if(r.startsWith(o))return e+r.slice(o.length);if(e.endsWith(t))return e;const n=e.split("/"),i=t.split("/");let s=n.length-1,a=i.length-1;for(;s>=0&&a>=0&&n[s]===i[a];)s--,a--;const l=n.slice(0,s).join("/"),c=i.slice(a).join("/");return l+(c?"/"+c:"")},"extendString");var Zr=Object.defineProperty,en=m((e,t)=>Zr(e,"name",{value:t,configurable:!0}),"s$c");const tn=en((...e)=>{if(e.length===0)return"";if(e.length===1)return V(e[0]);e=e.map(n=>se(n));const[t,...o]=e;let r=t.split("/");for(const n of o){const i=n.split("/",r.length);let s=0;for(const a of i)if(a===r[s])s+=1;else{r=r.slice(0,s);break}r=r.slice(0,s)}return r.length<=1&&r[0]===""?`/${r[0]}`:r.join("/")},"lowestCommonAncestor");var on=Object.defineProperty,we=m((e,t)=>on(e,"name",{value:t,configurable:!0}),"m$8");const rn=we((e,t,o,r,n={})=>{const i=z(n.include,n.exclude),s={},a=we((c,u)=>{s[c.replace(J,"")]=u},"addOutput");async function l(c,u){if(!i(u))return;let p;try{const g=await Vo(c,{sourceFilename:u});p=JSON.parse(g.program)}catch{}if(p){const g=p.body.filter(h=>h.type==="ImportDeclaration"||h.type==="ExportAllDeclaration"||h.type==="ExportNamedDeclaration");for(const h of g){if(!h.source||fe(h.source.value).includes("."))continue;const b=await this.resolve(h.source.value,u);if(!(!b||b.external)&&(b.id.endsWith(".ts")||b.id.endsWith(".cts")||b.id.endsWith(".mts")||b.id.endsWith(".tsx")||b.id.endsWith(".ctsx")||b.id.endsWith(".mtsx"))){const x=b.id.replace(e+"/","");c=c.replaceAll('from "'+h.source.value+'"','from "'+Qr(h.source.value,x)+'"')}}}const{errors:d,sourceText:f}=await t(u,c);if(d.length>0){if(n.ignoreErrors){this.warn(d[0]);return}return this.error(d[0])}if(a(u,f),!p)return;const y=p.body.filter(g=>g.type==="ImportDeclaration"?g.importKind==="type"?!0:g.specifiers?.every(h=>h.type==="ImportSpecifier"&&h.importKind==="type"):g.type==="ExportNamedDeclaration"||g.type==="ExportAllDeclaration"?g.exportKind==="type"?!0:g.type==="ExportNamedDeclaration"&&g.specifiers?.every(h=>h.type==="ExportSpecifier"&&h.exportKind==="type"):!1);for await(const g of y){if(!g.source)continue;const h=await this.resolve(g.source.value,u);if(!h)return;const b=h.id;if(i(b)&&!s[b.replace(J,"")])try{const x=await Oe(b);await l.call(this,x,b)}catch{}}}return m(l,"h"),we(l,"transform"),{name:"packem:isolated-declarations",async renderStart(c,{input:u}){const p=tn(...Array.isArray(u)?u:Object.values(u));typeof c.entryFileNames=="function"&&(c.entryFileNames=c.entryFileNames({name:c.name}));const d=c.entryFileNames.replace(/\.(.)?[jt]sx?$/,(f,y)=>`.d.${y||""}ts`);for await(let[f,y]of Object.entries(s)){if(r&&c.format==="cjs"){const h=Pt(y);h!==null&&(y=h.code)}const g=y.includes("from '")?"'":'"';(o===!0||o==="compatible")&&c.format==="cjs"&&this.emitFile({fileName:d.replace("[name]",O(p,f)).replace(".cts",".ts"),source:y.replaceAll(/(from\s)['|"]((.*)\..+|['|"].*)['|"];?/g,(h,b,x,v)=>b+g+(v||x)+".d.ts"+g+";"),type:"asset"}),this.emitFile({fileName:d.replace("[name]",O(p,f)),source:y.replaceAll(/(from\s)['|"]((.*)\..+|['|"].*)['|"];?/g,(h,b,x,v)=>b+g+(v||x)+(c.format==="cjs"?".d.cts":".d.mts")+g+";"),type:"asset"})}},transform:l}},"isolatedDeclarationsPlugin");var nn=Object.defineProperty,sn=m((e,t)=>nn(e,"name",{value:t,configurable:!0}),"n$7");const He="export default ",_t=sn(e=>{const t=zo(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(He)&&(n.code=n.code.replace(He,"module.exports = ")),n}}},"JSONPlugin");class an{static{m(this,"WalkerBase")}constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:m(()=>this.should_skip=!0,"skip"),remove:m(()=>this.should_remove=!0,"remove"),replace:m(t=>this.replacement=t,"replace")}}replace(t,o,r,n){t&&o&&(r!=null?t[o][r]=n:t[o]=n)}remove(t,o,r){t&&o&&(r!=null?t[o].splice(r,1):delete t[o])}}class ln extends an{static{m(this,"SyncWalker")}constructor(t,o){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:m(()=>this.should_skip=!0,"skip"),remove:m(()=>this.should_remove=!0,"remove"),replace:m(r=>this.replacement=r,"replace")},this.enter=t,this.leave=o}visit(t,o,r,n){if(t){if(this.enter){const s=this.should_skip,a=this.should_remove,l=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,o,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_skip,u=this.should_remove;if(this.should_skip=s,this.should_remove=a,this.replacement=l,c)return t;if(u)return null}let i;for(i in t){const s=t[i];if(s&&typeof s=="object")if(Array.isArray(s)){const a=s;for(let l=0;l<a.length;l+=1){const c=a[l];qe(c)&&(this.visit(c,t,i,l)||l--)}}else qe(s)&&this.visit(s,t,i,null)}if(this.leave){const s=this.replacement,a=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,t,o,r,n),this.replacement&&(t=this.replacement,this.replace(o,r,n,t)),this.should_remove&&this.remove(o,r,n);const l=this.should_remove;if(this.replacement=s,this.should_remove=a,l)return null}}return t}}function qe(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}m(qe,"isNode");function Tt(e,{enter:t,leave:o}){return new ln(t,o).visit(e,null)}m(Tt,"walk");var cn=Object.defineProperty,pn=m((e,t)=>cn(e,"name",{value:t,configurable:!0}),"u$9");const un=pn(({attributes:e,logger:t})=>{const o=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(r,n){if(!o(n))return null;let i=null;try{i=this.parse(r,{allowReturnOutsideFunction:!0})}catch(l){return this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${n}" and remove the jsx attribute.`}),t.warn(l),null}let s=!1;const a=new _(r);return Tt(i,{enter(l){if(l.type==="CallExpression"&&l.callee.type==="Identifier"&&l.callee.name==="jsx"){const c=l.arguments.filter(u=>u.type==="ObjectExpression"&&Array.isArray(u.properties));for(const u of c)for(const p of u.properties)p.type==="Property"&&p.key.type==="Literal"&&p.value.type==="Literal"&&e.includes(p.key.value)&&(a.overwrite(p.start-2,p.end,""),s=!0)}}}),s?{code:a.toString(),map:a.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var dn=Object.defineProperty,mn=m((e,t)=>dn(e,"name",{value:t,configurable:!0}),"r$b");const fn=mn((e,t,o)=>{const r=new RegExp(`(<!-- ${t} -->)[\\s\\S]*?(<!-- /${t} -->)`,"g");if(r.test(e))return e.replace(r,`$1
|
|
23
29
|
${o}
|
|
24
|
-
$2`)},"replaceContentWithin");var
|
|
25
|
-
`;
|
|
26
|
-
`);const v=new Set;for(const
|
|
27
|
-
`),
|
|
30
|
+
$2`)},"replaceContentWithin");var gn=Object.defineProperty,It=m((e,t)=>gn(e,"name",{value:t,configurable:!0}),"d$b");const yn=It(e=>{const t=[],o=[];return e.forEach(r=>{r.startsWith("(")?t.push(r):o.push(r)}),[...o.sort(),...t.sort()]},"sortLicenses"),Mt=It(({dtsMarker:e,licenseFilePath:t,licenseTemplate:o,logger:r,marker:n,mode:i,packageName:s})=>Uo({thirdParty(a){const l=new Set,c=a.sort(({name:p},{name:d})=>(p||0)>(d||0)?1:(d||0)>(p||0)?-1:0).map(({author:p,contributors:d,license:f,licenseText:y,maintainers:g,name:h,repository:b})=>{let x="## "+h+`
|
|
31
|
+
`;f&&(x+=`License: ${f}
|
|
32
|
+
`);const v=new Set;for(const T of[p,...g,...d]){const Q=typeof T=="string"?T:T?.name;Q&&v.add(Q)}return v.size>0&&(x+=`By: ${[...v].join(", ")}
|
|
33
|
+
`),b&&(x+=`Repository: ${typeof b=="string"?b:b.url}
|
|
28
34
|
`),y&&(x+=`
|
|
29
35
|
`+y.trim().replaceAll(/\r\n|\r/g,`
|
|
30
36
|
`).replaceAll(`<!-- ${n} -->`,"").replaceAll(e?`<!-- ${e} -->`:"","").replaceAll(`<!-- /${n} -->`,"").replaceAll(e?`<!-- /${e} -->`:"","").trim().split(`
|
|
31
|
-
`).map(
|
|
37
|
+
`).map(T=>T?`> ${T}`:">").join(`
|
|
32
38
|
`)+`
|
|
33
|
-
`),
|
|
39
|
+
`),f&&l.add(f),x}).join(`
|
|
34
40
|
---------------------------------------
|
|
35
41
|
|
|
36
|
-
`);if(c===""){r.info({message:"No dependencies license information found.",prefix:"plugin:license:"+i});return}const
|
|
42
|
+
`);if(c===""){r.info({message:"No dependencies license information found.",prefix:"plugin:license:"+i});return}const u=o(yn(l),c,s);try{const p=Ne(t),d=fn(p,n,u);if(!d){r.error({message:`Could not find the license marker: <!-- ${n} --><!-- /${n} --> in ${t}`,prefix:"plugin:license:"+i});return}p!==d&&(F(t,d),r.info({message:`${t} updated.`,prefix:"plugin:license:"+i}))}catch(p){r.error(p)}}}),"license");var hn=Object.defineProperty,vn=m((e,t)=>hn(e,"name",{value:t,configurable:!0}),"i$9");const bn=vn(e=>({async buildEnd(){const t=[];for(const r of this.getModuleIds()){const n=this.getModuleInfo(r);if(n!=null&&!n.isExternal)for(const i of n.importedIds)t.push({source:r,target:i})}if(Array.isArray(t)&&t.length===0)return;const o=$(e.rootDir,e.outDir,"graph.json");me(o,t)},name:"packem:metafile"}),"metafilePlugin");var wn=Object.defineProperty,$n=m((e,t)=>wn(e,"name",{value:t,configurable:!0}),"g$6");let Ge=!1;const jn=$n((e,t,o,r,n,i)=>{if(i!=="*"&&Mo(Ao(i))===null)throw new Error("Invalid typeScriptVersion option. It must be a valid semver range.");return{name:"packem:node10-compatibility",writeBundle(){Ge||(e.info({message:"Declaration node10 compatibility mode is enabled.",prefix:"plugin:node10-compatibility"}),Ge=!0);const s={};for(const c of t)for(const u of c.exportKey)u.includes("/*")?s[u]=["./"+w(o,V(c.name),"*.d.ts")]:s[u]=[...s[u]??[],"./"+w(o,c.name+".d.ts")];const a=w(r,"package.json"),l=Pe(a);n==="file"&&Object.keys(s).length>0?(me(a,{...l,typesVersions:{...l.typesVersions,[i]:s}},{detectIndent:!0}),e.info({message:'Your package.json "typesVersions" field has been updated.',prefix:"plugin:node10-compatibility"})):Object.keys(s).length>0&&e.info({message:`Please add the following field into your package.json to enable node 10 compatibility:
|
|
37
43
|
|
|
38
44
|
${JSON.stringify({typesVersions:{"*":s}},null,4)}
|
|
39
|
-
`,prefix:"plugin:node10-compatibility"})}}},"node10CompatibilityPlugin");var
|
|
40
|
-
`+e}return null},order:"post"}}),"prependDirectivePlugin");var
|
|
45
|
+
`,prefix:"plugin:node10-compatibility"})}}},"node10CompatibilityPlugin");var kn=Object.defineProperty,xn=m((e,t)=>kn(e,"name",{value:t,configurable:!0}),"r$a");const A=xn(e=>{const t=Ko("md5");return t.update(e),t.digest("hex")},"getHash");var En=Object.defineProperty,At=m((e,t)=>En(e,"name",{value:t,configurable:!0}),"d$a");const H=At(e=>e.handler||e,"getHandler"),E=At((e,t,o="")=>({...e,async buildEnd(r){e.buildEnd&&await H(e.buildEnd).call(this,r)},async buildStart(r){e.buildStart&&await H(e.buildStart).call(this,r)},async load(r){if(!e.load)return null;const n=w(o,e.name),i=w("load",A(r));if(t.has(i,n))return await t.get(i,n);const s=await H(e.load).call(this,r);return t.set(i,s,n),s},name:`cached(${e.name})`,async resolveId(r,n,i){if(!e.resolveId)return null;const s=w(o,e.name),a=w("resolveId",A(r),n?A(n):"",A(JSON.stringify(i)));if(t.has(a,s))return await t.get(a,s);const l=await H(e.resolveId).call(this,r,n,i);return t.set(a,l,s),l},async transform(r,n){if(!e.transform)return null;const i=w(o,e.name),s=w("transform",A(n),A(r));if(t.has(s,i))return await t.get(s,i);const a=await H(e.transform).call(this,r,n);return t.set(s,a,i),a}}),"cachingPlugin");var Dn=Object.defineProperty,Sn=m((e,t)=>Dn(e,"name",{value:t,configurable:!0}),"n$6");const On=Sn(()=>({name:"packem:prepend-directive",transform:{handler(e,t){const o=this.getModuleInfo(t);if(o?.meta.preserveDirectives){const r=o.meta.preserveDirectives.directives[0];if(r)return`'${r.value}';
|
|
46
|
+
`+e}return null},order:"post"}}),"prependDirectivePlugin");var Nn=Object.defineProperty,Pn=m((e,t)=>Nn(e,"name",{value:t,configurable:!0}),"c$8");const Cn=Pn(({directiveRegex:e,exclude:t=[],include:o=[],logger:r})=>{const n={},i={},s=z(o,t);return{name:"packem:preserve-directives",onLog(a,l){return l.code==="MODULE_LEVEL_DIRECTIVE"&&a==="warn"?!1:null},renderChunk:{handler(a,l,{sourcemap:c}){const u=l.moduleIds.map(f=>n[f]?n[f]:null).reduce((f,y)=>(y&&y.forEach(g=>{f.add(g)}),f),new Set),p=new _(a);u.size>0&&(r.debug({message:`directives for chunk "${l.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),p.prepend(`${[...u].map(f=>`'${f}';`).join(`
|
|
41
47
|
`)}
|
|
42
|
-
`));let
|
|
43
|
-
`)),
|
|
44
|
-
`);if(i)return null;if(e.includes(r.name)){const s=new
|
|
45
|
-
`),{code:s.toString(),map:n.sourcemap?s.generateMap({hires:!0}):void 0}}return null},order:"post"},async writeBundle(o,r){for(const[n,i]of Object.entries(r))if(i.type==="chunk"&&
|
|
46
|
-
`)=>{const o=
|
|
48
|
+
`));let d;return l.facadeModuleId&&typeof i[l.facadeModuleId]=="string"&&(d=i[l.facadeModuleId]),d&&(r.debug({message:`shebang for chunk "${l.fileName}" is preserved.`,prefix:"plugin:preserve-directives"}),p.prepend(`${d}
|
|
49
|
+
`)),u.size===0&&d===void 0?null:{code:p.toString(),map:c?p.generateMap({hires:!0}):null}},order:"post"},transform(a,l){if(!s(l))return null;let c=!1;const u=new _(a);if(a.startsWith("#")&&a[1]==="!"){let d=0;for(let f=2,y=a.length;f<y;f++){const g=a.codePointAt(f);if(g===10||g===13||g===8232||g===8233){d=f;break}}d&&(i[l]=a.slice(0,d),u.remove(0,d+1),c=!0,r.debug({message:`shebang for module "${l}" is preserved.`,prefix:"plugin:preserve-directives"}))}let p=null;try{p=this.parse(u.toString(),{allowReturnOutsideFunction:!0})}catch(d){return this.warn({code:"PARSE_ERROR",message:`failed to parse "${l}" and extract the directives.`}),r.warn(d),null}if(p.type!=="Program")return null;for(const d of p.body.filter(Boolean)){if(d.type!=="ExpressionStatement")break;let f=null;"directive"in d?f=d.directive:d.expression.type==="Literal"&&typeof d.expression.value=="string"&&e.test(d.expression.value)&&(f=d.expression.value),f!=="use strict"&&f&&(n[l]||=new Set,n[l].add(f),"start"in d&&typeof d.start=="number"&&"end"in d&&typeof d.end=="number"&&(u.remove(d.start,d.end),c=!0),r.debug({message:`directive "${f}" for module "${l}" is preserved.`,prefix:"plugin:preserve-directives"}))}return c?{code:u.toString(),map:u.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...n[l]??[]],shebang:i[l]??null}}}:null}}},"preserveDirectives");var _n=Object.defineProperty,Tn=m((e,t)=>_n(e,"name",{value:t,configurable:!0}),"t$8");const In=Tn(e=>{const t=z(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 Mn=Object.defineProperty,An=m((e,t)=>Mn(e,"name",{value:t,configurable:!0}),"r$9");const Rt=An(()=>({name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return Ho(e)}}),"resolveFileUrl");var Rn=Object.defineProperty,ye=m((e,t)=>Rn(e,"name",{value:t,configurable:!0}),"i$6");const ce=/^#![^\n]*/,De=ye(async e=>{await bo(e,493).catch(()=>{})},"makeExecutable"),Fn=ye((e,t)=>({name:"packem:shebang",renderChunk:{handler(o,r,n){if(!r.isEntry||!r.facadeModuleId)return null;const i=o.startsWith("#")&&o[1]==="!";if(i&&t.replace)return o.replace(ce,t.shebang+`
|
|
50
|
+
`);if(i)return null;if(e.includes(r.name)){const s=new _(o);return s.prepend(t.shebang+`
|
|
51
|
+
`),{code:s.toString(),map:n.sourcemap?s.generateMap({hires:!0}):void 0}}return null},order:"post"},async writeBundle(o,r){for(const[n,i]of Object.entries(r))if(i.type==="chunk"&&ce.test(i.code)&&o.dir){const s=$(o.dir,n);await De(s)}}}),"shebangPlugin"),Jn=ye(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(ce,"")}}),"removeShebangPlugin"),Bn=ye((e,t=`
|
|
52
|
+
`)=>{const o=ce.exec(e);return o?o+t:""},"getShebang");var Ln=Object.defineProperty,B=m((e,t)=>Ln(e,"name",{value:t,configurable:!0}),"r$8");const Wn=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,Vn=/MIT License|MIT license|BSD license/,zn=/\n{2,}/g,Un=/\b(\w+)\$\d+\b/g,Kn=/[-/\\^$*+?.()|[\]{}]/g,Hn=B(e=>e.replaceAll(Kn,"\\$&"),"escapeRegex"),qn=B(e=>[...new Set(e)],"unique"),Gn=B(e=>e.replaceAll(Wn,t=>Vn.test(t)?"":t).replaceAll(zn,`
|
|
47
53
|
|
|
48
|
-
`),"cleanUnnecessaryComments"),
|
|
49
|
-
- ${l}`).join(""),a=t.fileName.replace(/\.[^/.]+$/,"");
|
|
54
|
+
`),"cleanUnnecessaryComments"),Xe=new Map;function Ft(e,t,{identifierReplacements:o},r){const n=xt(e);for(const s in o){const a=n.find(c=>c.specifier===s&&c.imports.includes("{"));if(!a){this.warn(`${t.fileName} does not import "${s}" for replacement`),process.exitCode=1;continue}const l=o[s];for(const c in l){if(!a.imports.includes(c))throw new Error(`${t.fileName} does not import "${c}" from "${s}" for replacement`);const u=l[c],p=Hn(c);u.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${p},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${p}\\b`,"g"),u)}}const i=qn(Array.from(e.matchAll(Un),s=>s[0]));if(i.length>0){const s=i.map(l=>`
|
|
55
|
+
- ${l}`).join(""),a=t.fileName.replace(/\.[^/.]+$/,"");Xe.has(a)||r.warn({message:`${t.fileName} contains confusing identifier names${s}
|
|
50
56
|
|
|
51
|
-
To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),
|
|
57
|
+
To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),Xe.set(a,!0)}return e}m(Ft,"I");B(Ft,"replaceConfusingTypeNames");const Xn=B((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},"removeInternal");function Jt(e,t){if(e.includes("@internal")){const o=new _(e),r=qo(e,{plugins:["typescript"],sourceType:"module"});if(Tt(r,{enter(n){Xn(o,n)&&this.skip()}}),e=o.toString(),e.includes("@internal"))throw new Error(`${t.fileName} has unhandled @internal declarations`)}return e}m(Jt,"S$1");B(Jt,"stripInternalTypes");const Yn=B((e,t)=>({name:"packem:patch-types",renderChunk(o,r){return o=Ft.call(this,o,r,e,t),o=Jt.call(this,o,r),o=Gn(o),o},resolveId(o){return o.startsWith("types/")?{external:!0,id:"../../"+(o.endsWith(".js")?o:o+".js")}:null}}),"patchTypescriptTypes");var Qn=Object.defineProperty,Bt=m((e,t)=>Qn(e,"name",{value:t,configurable:!0}),"m$7");const Lt=Bt((e,t=!0)=>{if(!e)return null;const{config:o,path:r}=e;if(!o.compilerOptions)return null;const{baseUrl:n,paths:i}=o.compilerOptions;if(!n)return null;const s=$(V(r),n),a=[];if(i)for(const[l,c]of Object.entries(i)){let u;l==="@"||l==="~"||l==="#"?u=new RegExp(`^${l}/(.+)$`):u=new RegExp(`^${[...l].map(d=>d==="*"?"(.+)":d.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let p=0;for(const d of c){const f=[...Be($(s,d))].map(y=>y==="*"?"$"+(++p+""):y==="$"?"$$":y).join("");a.push({find:u,replacement:f})}}return t&&a.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...Be(s)].map(l=>l==="$"?"$$":l).join("")}/$1`}),a},"getConfigAlias"),Wt=Bt((e,t)=>{const o=Lt(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(r,n,i){if(!o||r.includes("\0"))return null;for(const{find:s,replacement:a}of o)if(s.test(r)){const l=r.replace(s,a),c=await this.resolve(l,n,{skipSelf:!0,...i});if(c)return t.debug({message:`Resolved ${r} to ${c.id} using paths from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-paths"}),c.id}return null}}},"resolveTsconfigPaths");var Zn=Object.defineProperty,Vt=m((e,t)=>Zn(e,"name",{value:t,configurable:!0}),"u$6");const ei=Vt((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 i=[];for(const s of n){if(s.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${r}.`);if(s.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${r}.`);i.push($(e,s))}return i},"getRootDirectories"),zt=Vt((e,t,o)=>{const r=ei(e,o);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(n,i,s){if(r===null||r.length===0)return null;if(n.startsWith("."))for(const a of r){const l=w(a,n),c=await this.resolve(l,i,{skipSelf:!0,...s});if(c)return t.debug({message:`Resolved ${n} to ${c.id} using rootDirs from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-root-dirs"}),c.id}return null}}},"resolveTsconfigRootDirectories");var ti=Object.defineProperty,oi=m((e,t)=>ti(e,"name",{value:t,configurable:!0}),"r$7");const Ut=oi(()=>{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 ri=Object.defineProperty,Kt=m((e,t)=>ri(e,"name",{value:t,configurable:!0}),"u$5");const Ye=Kt((e,t,o,r)=>{const n=e.findIndex(s=>typeof s=="object"?s.name===o:!1);if(n===-1)throw new Error(`Plugin with name "${o}" was not found, try one of: ${e.map(s=>{if(typeof s=="object")return s.name}).filter(Boolean).join(", ")}`);const i=r?n+1:n;return e.splice(i,0,t),e},"appendPlugin"),Ht=Kt((e,t)=>{if(!t)return e;for(const{after:o=void 0,before:r=void 0,plugin:n}of t)e=o?Ye(e,n,o,!0):Ye(e,n,r,!1);return e},"appendPlugins");var ni=Object.defineProperty,ii=m((e,t)=>ni(e,"name",{value:t,configurable:!0}),"s$7");const si=ii(e=>{const t=fe(e).split(".");if(t.length>=2){const[o,r]=t.slice(-2),n=t[0],i=/^(\w+)-runtime$/.exec(o)?.[1];if(Ce.includes(r)&&i&&i.length>0)return n+"-"+i}},"getCustomModuleLayer");var ai=Object.defineProperty,li=m((e,t)=>ai(e,"name",{value:t,configurable:!0}),"i$5");const $e=li(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var ci=Object.defineProperty,Qe=m((e,t)=>ci(e,"name",{value:t,configurable:!0}),"d$8");const pi=Qe((e,t)=>{const o=new Map;return Qe(function(r,n){const i=n.getModuleInfo(r);if(!i)return;const{isEntry:s}=i,a=i.meta,l=$e(a);if(!s){const c=o.get(r);if(c)return c;const u=si(r);if(u)return o.set(r,u),u}if(s){const c=n.getModuleIds();for(const u of c)n.getModuleInfo(u)&&$e(a)===l&&(e.has(u)||e.set(u,new Set),e.get(u).add([r,l]))}if(l&&!s&&e.has(r)){const c=[...e.get(r)];if(c.some(([p])=>{if(t.some(d=>d.path===p)){const d=n.getModuleInfo(p);return $e(d?d.meta:{})===l}return!1}))return;if(c.every(([,p])=>p===l))return o.has(r)?o.get(r):void 0;const u=fe(r,mt(r))+"-"+l;return o.set(r,u),u}},"splitChunks")},"createSplitChunks");var ui=Object.defineProperty,di=m((e,t)=>ui(e,"name",{value:t,configurable:!0}),"n$4");const R=di((e,t)=>e.isDynamicEntry?`${lr}/[name].${t}`:`${cr}/${e.name}-[hash].${t}`,"getChunkFilename");var mi=Object.defineProperty,fi=m((e,t)=>mi(e,"name",{value:t,configurable:!0}),"o$4");const gi=process.platform==="win32",Ze=fi((e,t)=>{const o=gi?"\\":"/";for(let r of Array.isArray(e.names)?e.names:[]){if(r.includes("node_modules"+o+".pnpm"))return r=r.replace("node_modules"+o+".pnpm","external")+"."+t,r.replace("node_modules"+o,"");if(r.includes("node_modules"))return r.replace("node_modules","external")+"."+t}return"[name]."+t},"getEntryFileNames");var yi=Object.defineProperty,hi=m((e,t)=>yi(e,"name",{value:t,configurable:!0}),"p$2");const Ie=hi((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 i=r[n];typeof i=="string"&&(o[n]=w(e.options.rootDir,i))}}return o={...o,...e.options.alias},e.options.rollup.alias&&(Array.isArray(e.options.rollup.alias.entries)?Object.assign(o,Object.fromEntries(e.options.rollup.alias.entries.map(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 vi=Object.defineProperty,D=m((e,t)=>vi(e,"name",{value:t,configurable:!0}),"p$1");const bi=D((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"+uo.node.split(".")[0];if(t.pkg.engines?.node){const r=kt(t.pkg.engines.node);r&&(o="node"+r.major)}if(t.options.rollup.esbuild.target){const r=q(t.options.rollup.esbuild.target);r.some(n=>n.startsWith("node"))||(t.options.rollup.esbuild.target=[...new Set([...q(o),...r])])}else t.options.rollup.esbuild.target=q(o);return t.tsconfig?.config.compilerOptions?.target==="es5"&&(t.options.rollup.esbuild.keepNames=!1,t.logger.debug("Disabling keepNames because target is set to es5")),{logger:t.logger,minify:t.options.minify,minifyWhitespace:t.options.minify,sourceMap:t.options.sourcemap,...t.options.rollup.esbuild}}if(e==="swc"){if(!t.options.rollup.swc)throw new Error("No swc options found in your configuration.");return{minify:t.options.minify,...t.options.rollup.swc,jsc:{minify:{compress:{directives:!1},format:{comments:"some"},mangle:{topLevel:!0},sourceMap:t.options.sourcemap,toplevel:t.options.emitCJS??t.options.emitESM},...t.options.rollup.swc.jsc},sourceMaps:t.options.sourcemap}}if(e==="sucrase"){if(!t.options.rollup.sucrase)throw new Error("No sucrase options found in your configuration.");return t.options.rollup.sucrase}throw new Error("A Unknown transformer was provided")},"getTransformerConfig"),qt=D((e,t)=>{if(e.code==="CIRCULAR_DEPENDENCY"&&/Circular dependency:[\s\S]*node_modules/.test(e.message))return!0;if(e.code==="UNRESOLVED_IMPORT")throw new Error(`Failed to resolve the module "${e.exporter}" imported by "${k(O($(),e.id))}"
|
|
52
58
|
Is the module installed? Note:
|
|
53
59
|
↳ to inline a module into your bundle, install it to "devDependencies".
|
|
54
|
-
↳ to depend on a module via import/require, install it to "dependencies".`);return e.code==="MODULE_LEVEL_DIRECTIVE"?!0:e.code==="MIXED_EXPORTS"&&t.options.cjsInterop===!0},"sharedOnWarn"),
|
|
55
|
-
${s.stack}`),i){case"info":{e.logger.info({message:a,prefix:o+(s.plugin?":plugin:"+s.plugin:"")});return}case"warn":{e.logger.warn({message:a,prefix:o+(s.plugin?":plugin:"+s.plugin:"")});return}case"debug":e.logger.debug({message:a,prefix:o+(s.plugin?":plugin:"+s.plugin:"")})}},"onLog"),onwarn(i,s){qt(i,e)||i.code||s(i)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),Ht=D(async(e,t)=>{const o=Ie(e,"build");let r;e.options.rollup.resolve&&(r=E(bt({...e.options.rollup.resolve}),t));const n=e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:oi(e.dependencyGraphMap,e.buildEntries),preserveModules:!1};return{...Kt(e,o,"dependencies"),output:[e.options.emitCJS&&{chunkFileNames:D(i=>R(i,"cjs"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:D(i=>Qe(i,"cjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"cjs",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,interop:"compat",sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...n},e.options.emitESM&&{chunkFileNames:D(i=>R(i,"mjs"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:D(i=>Qe(i,"mjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"esm",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...n}].filter(Boolean),plugins:Ut([E(Mt(),t),E(Vt(),t),e.tsconfig&&E(Wt(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&E(Bt(e.tsconfig,e.logger),t),e.options.rollup.replace&&wt({sourcemap:e.options.sourcemap,...e.options.rollup.replace}),e.options.rollup.alias&&vt({customResolver:r,...e.options.rollup.alias,entries:o}),r,e.options.rollup.polyfillNode&&No({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&Pt({...e.options.rollup.json}),xr(),e.options.rollup.wasm&&Po(e.options.rollup.wasm),e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer&&Xr(b(e.options.rootDir,e.options.sourceDir),e.options.isolatedDeclarationTransformer,e.options.declaration,!!e.options.rollup.cjsInterop,e.options.rollup.isolatedDeclarations),e.options.transformer(ui(e.options.transformerName,e)),E(kn({directiveRegex:/^['|"](use (\w+))['|"]$/,...e.options.rollup.preserveDirectives,logger:e.logger}),t),e.options.rollup.shebang&&Nn(e.options.entries.filter(i=>i.executable).map(i=>i.name).filter(Boolean),e.options.rollup.shebang),e.options.cjsInterop&&e.options.emitCJS&&Ot({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&Wr(),e.options.rollup.dynamicVars&&Oo(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&E(So({sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),t),e.options.rollup.preserveDynamicImports&&{name:"packem:preserve-dynamic-imports",renderDynamicImport(){return{left:"import(",right:")"}}},e.options.cjsInterop&&e.options.rollup.shim&&Jr(e.pkg,e.options.rollup.shim),e.options.rollup.raw&&E(Dn(e.options.rollup.raw),t),e.options.rollup.jsxRemoveAttributes&&E(rn({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),t),e.options.rollup.metafile&&un({outDir:$(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&Tr(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&Tt({dtsMarker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dependenciesTemplate,logger:e.logger,marker:e.options.rollup.license.dependenciesMarker??"DEPENDENCIES",mode:"dependencies",packageName:e.pkg.name}),wn(),e.options.emitCJS&&e.mode==="build"&&e.options.declaration==="compatible"&&e.options.rollup.node10Compatibility&&fn(e.logger,e.options.entries,e.options.outDir,e.options.rootDir,e.options.rollup.node10Compatibility.writeToPackageJson?"file":"console",e.options.rollup.node10Compatibility.typeScriptVersion??"*"),e.options.analyze&&e.options.rollup.visualizer!==!1&&Co({brotliSize:!0,gzipSize:!0,projectRoot:e.options.rootDir,sourcemap:e.options.sourcemap,...e.options.rollup.visualizer,filename:"packem-bundle-analyze.html",title:"Packem Visualizer"})].filter(Boolean),e.options.rollup.plugins)}},"getRollupOptions"),di=D(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"),mi=ur(di),Gt=D(async(e,t)=>{const o=Ie(e,"types"),r={load(a){return/\.(?:js|cjs|mjs|jsx|ts|tsx|ctsx|mtsx|mts|json)$/.test(a)?null:""},name:"packem:ignore-files"},n=e.tsconfig?.config.compilerOptions;delete n?.lib;let i;e.options.rollup.resolve&&(i=E(bt({...e.options.rollup.resolve}),t));const s="dts-plugin:"+process.pid+e.tsconfig.path;return{...Kt(e,o,"dts"),onwarn(a,l){qt(a,e)||a.code!=="EMPTY_BUNDLE"&&l(a)},output:[e.options.emitCJS&&{chunkFileNames:D(a=>R(a,"d.cts"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.emitESM&&{chunkFileNames:D(a=>R(a,"d.mts"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts",format:"esm",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.declaration==="compatible"&&{chunkFileNames:D(a=>R(a,"d.ts"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:Ut([E(Mt(),t),E(Vt(),t),e.options.rollup.json&&Pt({...e.options.rollup.json}),r,e.tsconfig&&E(Wt(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&E(Bt(e.tsconfig,e.logger),t),e.options.rollup.replace&&wt({sourcemap:e.options.sourcemap,...e.options.rollup.replace}),e.options.rollup.alias&&vt({customResolver:i,...e.options.rollup.alias,entries:o}),i,await mi(s)(e),e.options.cjsInterop&&e.options.emitCJS&&Ot({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&E(Vn(e.options.rollup.patchTypes,e.logger),t),Cn(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&Tt({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dtsTemplate,logger:e.logger,marker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",mode:"types",packageName:e.pkg.name})].filter(Boolean),e.options.rollup.plugins)}},"getRollupDtsOptions");var fi=Object.defineProperty,gi=m((e,t)=>fi(e,"name",{value:t,configurable:!0}),"f$4");const et="rollup-build.json",xe=gi(async(e,t,o)=>{const r=await Ht(e,t);if(await e.hooks.callHook("rollup:options",e,r),Object.keys(r.input).length===0)return;(!e.options.rollup.isolatedDeclarations||!e.options.isolatedDeclarationTransformer)&&(r.cache=t.get(et,o));const n=await ht(r);t.set(et,n.cache,o),await e.hooks.callHook("rollup:build",e,n);const i=new Map;for(const s of r.output){const{output:a}=await n.write(s),l=new Set,c=a.filter(p=>p.type==="chunk");for(const p of c){l.add(p.fileName);for(const u of p.imports)e.usedImports.add(u);p.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(p.code,"utf8"),chunks:p.imports.filter(u=>c.find(g=>g.fileName===u)),exports:p.exports,modules:Object.entries(p.modules).map(([u,g])=>({bytes:g.renderedLength,id:u})),path:p.fileName,type:"entry"})}const d=a.filter(p=>p.type==="asset");for(const p of d)i.has(p.fileName)||i.set(p.fileName,{bytes:Buffer.byteLength(p.source,"utf8"),path:p.fileName,type:"asset"});for(const p of l)e.usedImports.delete(p)}e.buildEntries.push(...i.values())},"build");var yi=Object.defineProperty,oe=m((e,t)=>yi(e,"name",{value:t,configurable:!0}),"a$7");const tt="rollup-dts.json",re=oe(async(e,t,o)=>{if(e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer){e.logger.info({message:"Using isolated declaration transformer to generate declaration files...",prefix:"dts"});return}const r=await Gt(e,t);if(await e.hooks.callHook("rollup:dts:options",e,r),Object.keys(r.input).length===0)return;r.cache=t.get(tt,o);const n=await ht(r);t.set(tt,n.cache,o),await e.hooks.callHook("rollup:dts:build",e,n),e.logger.info({message:"Building declaration files...",prefix:"dts"}),e.options.emitCJS&&await n.write({chunkFileNames:oe(i=>R(i,"d.cts"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await n.write({chunkFileNames:oe(i=>R(i,"d.mts"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts"}),e.options.declaration==="compatible"&&await n.write({chunkFileNames:oe(i=>R(i,"d.mjs"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts"}),await e.hooks.callHook("rollup:dts:done",e)},"buildTypes");var hi=Object.defineProperty,vi=m((e,t)=>hi(e,"name",{value:t,configurable:!0}),"y$2");const bi=vi((e,t,o)=>e.reduce((r,n)=>{const i=n[t],s=n[o];return r[i]||(r[i]={}),r[i][s]||(r[i][s]=[]),r[i][s].push(n),r},{}),"groupByKeys");var wi=Object.defineProperty,de=m((e,t)=>wi(e,"name",{value:t,configurable:!0}),"j$1");const $i=de((e,t)=>{const o=de(s=>O(t.options.rootDir,$(t.options.outDir,s)),"rPath");let r=!1;const n=[],i=t.buildEntries.filter(s=>s.type==="entry");if(i.length>0){e.raw(`Entries:
|
|
56
|
-
`);for(const s of i){let a=s.bytes??0;for(const c of s.chunks??[])a+=t.buildEntries.find(
|
|
57
|
-
exports: `+
|
|
58
|
-
${s.chunks.map(c=>{const
|
|
59
|
-
`)}`),s.modules&&s.modules.length>0){const c=s.modules.filter(
|
|
60
|
+
↳ to depend on a module via import/require, install it to "dependencies".`);return e.code==="MODULE_LEVEL_DIRECTIVE"?!0:e.code==="MIXED_EXPORTS"&&t.options.cjsInterop===!0},"sharedOnWarn"),et=new Map,je=new Map,Gt=D((e,t,o)=>{const r=D(i=>{for(const[s,a]of Object.entries(t))if(i.startsWith(s))return i.replace(s,a)},"findAlias"),n=Lt(e.tsconfig,!1);return{external(i){const s=r(i);s&&(i=s);const a=St(i);if(Ee(e.options.externals,a)||Ee(e.options.externals,i))return!0;const{pkg:l}=e;if(i.startsWith(".")||ft(i)||/src[/\\]/.test(i)||l.name&&i.startsWith(l.name))return!1;if(l.imports)for(const[c,u]of Object.entries(l.imports)){if(c===i)return!1;if(c.includes("*")){let p;je.has(c)?p=je.get(c):(p=gt(w(e.options.rootDir,u.replace("/*","")),{withFileTypes:!0}).filter(d=>d.isFile()).map(d=>d.name),je.set(c,p));for(const d of p)if(d.replace(J,"")===i.replace(J,"").replace("#",""))return!1}}if(n){for(const{find:c}of n)if(c.test(i))return e.logger.debug({message:`Resolved alias ${i} to ${c.source}`,prefix:o}),!1}return et.has(i)||e.logger.info({message:'Inlined implicit external "'+k(i)+'". If this is incorrect, add it to the "externals" option.',prefix:o}),et.set(i,!0),!1},input:Object.fromEntries(e.options.entries.map(i=>[i.name,$(e.options.rootDir,i.input)])),logLevel:e.options.debug?"debug":"info",onLog:D((i,s)=>{let a=s.message;switch(s.stack&&(a=`${a}
|
|
61
|
+
${s.stack}`),i){case"info":{e.logger.info({message:a,prefix:o+(s.plugin?":plugin:"+s.plugin:"")});return}case"warn":{e.logger.warn({message:a,prefix:o+(s.plugin?":plugin:"+s.plugin:"")});return}case"debug":e.logger.debug({message:a,prefix:o+(s.plugin?":plugin:"+s.plugin:"")})}},"onLog"),onwarn(i,s){qt(i,e)||i.code||s(i)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),Xt=D(async(e,t)=>{const o=Ie(e,"build");let r;e.options.rollup.resolve&&(r=E($t({...e.options.rollup.resolve}),t));const n=e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:pi(e.dependencyGraphMap,e.buildEntries),preserveModules:!1};return{...Gt(e,o,"dependencies"),output:[e.options.emitCJS&&{chunkFileNames:D(i=>R(i,"cjs"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:D(i=>Ze(i,"cjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"cjs",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,interop:"compat",sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...n},e.options.emitESM&&{chunkFileNames:D(i=>R(i,"mjs"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:D(i=>Ze(i,"mjs"),"entryFileNames"),exports:"auto",externalLiveBindings:!1,format:"esm",freeze:!1,generatedCode:{arrowFunctions:!0,constBindings:!0,objectShorthand:!0,preset:e.tsconfig?.config.compilerOptions?.target==="es5"?"es5":"es2015",reservedNamesAsProps:!0,symbols:!0},hoistTransitiveImports:!1,sourcemap:e.options.sourcemap,validate:!0,...e.options.rollup.output,...n}].filter(Boolean),plugins:Ht([E(Rt(),t),E(Ut(),t),e.tsconfig&&E(zt(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&E(Wt(e.tsconfig,e.logger),t),e.options.rollup.replace&&jt({sourcemap:e.options.sourcemap,...e.options.rollup.replace}),e.options.rollup.alias&&wt({customResolver:r,...e.options.rollup.alias,entries:o}),r,e.options.rollup.polyfillNode&&To({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&_t({...e.options.rollup.json}),Cr(),e.options.rollup.wasm&&_o(e.options.rollup.wasm),e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer&&rn(w(e.options.rootDir,e.options.sourceDir),e.options.isolatedDeclarationTransformer,e.options.declaration,!!e.options.rollup.cjsInterop,e.options.rollup.isolatedDeclarations),e.options.transformer(bi(e.options.transformerName,e)),E(Cn({directiveRegex:/^['|"](use (\w+))['|"]$/,...e.options.rollup.preserveDirectives,logger:e.logger}),t),e.options.rollup.shebang&&Fn(e.options.entries.filter(i=>i.executable).map(i=>i.name).filter(Boolean),e.options.rollup.shebang),e.options.cjsInterop&&e.options.emitCJS&&Ct({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&Gr(),e.options.rollup.dynamicVars&&Co(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&E(Po({sourceMap:e.options.sourcemap,...e.options.rollup.commonjs}),t),e.options.rollup.preserveDynamicImports&&{name:"packem:preserve-dynamic-imports",renderDynamicImport(){return{left:"import(",right:")"}}},e.options.cjsInterop&&e.options.rollup.shim&&Kr(e.pkg,e.options.rollup.shim),e.options.rollup.raw&&E(In(e.options.rollup.raw),t),e.options.rollup.jsxRemoveAttributes&&E(un({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),t),e.options.rollup.metafile&&bn({outDir:$(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&Br(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&Mt({dtsMarker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dependenciesTemplate,logger:e.logger,marker:e.options.rollup.license.dependenciesMarker??"DEPENDENCIES",mode:"dependencies",packageName:e.pkg.name}),On(),e.options.emitCJS&&e.mode==="build"&&e.options.declaration==="compatible"&&e.options.rollup.node10Compatibility&&jn(e.logger,e.options.entries,e.options.outDir,e.options.rootDir,e.options.rollup.node10Compatibility.writeToPackageJson?"file":"console",e.options.rollup.node10Compatibility.typeScriptVersion??"*"),e.options.analyze&&e.options.rollup.visualizer!==!1&&Io({brotliSize:!0,gzipSize:!0,projectRoot:e.options.rootDir,sourcemap:e.options.sourcemap,...e.options.rollup.visualizer,filename:"packem-bundle-analyze.html",title:"Packem Visualizer"})].filter(Boolean),e.options.rollup.plugins)}},"getRollupOptions"),wi=D(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"),$i=vr(wi),Yt=D(async(e,t)=>{const o=Ie(e,"types"),r={load(a){return/\.(?:js|cjs|mjs|jsx|ts|tsx|ctsx|mtsx|mts|json)$/.test(a)?null:""},name:"packem:ignore-files"},n=e.tsconfig?.config.compilerOptions;delete n?.lib;let i;e.options.rollup.resolve&&(i=E($t({...e.options.rollup.resolve}),t));const s="dts-plugin:"+process.pid+e.tsconfig.path;return{...Gt(e,o,"dts"),onwarn(a,l){qt(a,e)||a.code!=="EMPTY_BUNDLE"&&l(a)},output:[e.options.emitCJS&&{chunkFileNames:D(a=>R(a,"d.cts"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.emitESM&&{chunkFileNames:D(a=>R(a,"d.mts"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts",format:"esm",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.declaration==="compatible"&&{chunkFileNames:D(a=>R(a,"d.ts"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:Ht([E(Rt(),t),E(Ut(),t),e.options.rollup.json&&_t({...e.options.rollup.json}),r,e.tsconfig&&E(zt(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&E(Wt(e.tsconfig,e.logger),t),e.options.rollup.replace&&jt({sourcemap:e.options.sourcemap,...e.options.rollup.replace}),e.options.rollup.alias&&wt({customResolver:i,...e.options.rollup.alias,entries:o}),i,await $i(s)(e),e.options.cjsInterop&&e.options.emitCJS&&Ct({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&E(Yn(e.options.rollup.patchTypes,e.logger),t),Jn(),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&Mt({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dtsTemplate,logger:e.logger,marker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",mode:"types",packageName:e.pkg.name})].filter(Boolean),e.options.rollup.plugins)}},"getRollupDtsOptions");var ji=Object.defineProperty,ki=m((e,t)=>ji(e,"name",{value:t,configurable:!0}),"f$4");const tt="rollup-build.json",ke=ki(async(e,t,o)=>{const r=await Xt(e,t);if(await e.hooks.callHook("rollup:options",e,r),Object.keys(r.input).length===0)return;(!e.options.rollup.isolatedDeclarations||!e.options.isolatedDeclarationTransformer)&&(r.cache=t.get(tt,o));const n=await bt(r);t.set(tt,n.cache,o),await e.hooks.callHook("rollup:build",e,n);const i=new Map;for(const s of r.output){const{output:a}=await n.write(s),l=new Set,c=a.filter(p=>p.type==="chunk");for(const p of c){l.add(p.fileName);for(const d of p.imports)e.usedImports.add(d);p.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(p.code,"utf8"),chunks:p.imports.filter(d=>c.find(f=>f.fileName===d)),exports:p.exports,modules:Object.entries(p.modules).map(([d,f])=>({bytes:f.renderedLength,id:d})),path:p.fileName,type:"entry"})}const u=a.filter(p=>p.type==="asset");for(const p of u)i.has(p.fileName)||i.set(p.fileName,{bytes:Buffer.byteLength(p.source,"utf8"),path:p.fileName,type:"asset"});for(const p of l)e.usedImports.delete(p)}e.buildEntries.push(...i.values())},"build");var xi=Object.defineProperty,Z=m((e,t)=>xi(e,"name",{value:t,configurable:!0}),"a$7");const ot="rollup-dts.json",ee=Z(async(e,t,o)=>{if(e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer){e.logger.info({message:"Using isolated declaration transformer to generate declaration files...",prefix:"dts"});return}const r=await Yt(e,t);if(await e.hooks.callHook("rollup:dts:options",e,r),Object.keys(r.input).length===0)return;r.cache=t.get(ot,o);const n=await bt(r);t.set(ot,n.cache,o),await e.hooks.callHook("rollup:dts:build",e,n),e.logger.info({message:"Building declaration files...",prefix:"dts"}),e.options.emitCJS&&await n.write({chunkFileNames:Z(i=>R(i,"d.cts"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await n.write({chunkFileNames:Z(i=>R(i,"d.mts"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts"}),e.options.declaration==="compatible"&&await n.write({chunkFileNames:Z(i=>R(i,"d.mjs"),"chunkFileNames"),dir:$(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts"}),await e.hooks.callHook("rollup:dts:done",e)},"buildTypes");var Ei=Object.defineProperty,Di=m((e,t)=>Ei(e,"name",{value:t,configurable:!0}),"y$2");const Si=Di((e,t,o)=>e.reduce((r,n)=>{const i=n[t],s=n[o];return r[i]||(r[i]={}),r[i][s]||(r[i][s]=[]),r[i][s].push(n),r},{}),"groupByKeys");var Oi=Object.defineProperty,pe=m((e,t)=>Oi(e,"name",{value:t,configurable:!0}),"j$1");const Ni=pe((e,t)=>{const o=pe(s=>O(t.options.rootDir,$(t.options.outDir,s)),"rPath");let r=!1;const n=[],i=t.buildEntries.filter(s=>s.type==="entry");if(i.length>0){e.raw(`Entries:
|
|
62
|
+
`);for(const s of i){let a=s.bytes??0;for(const c of s.chunks??[])a+=t.buildEntries.find(u=>u.path===c)?.bytes??0;let l=` ${N(o(s.path))} (${["total size: "+k(I(a)),s.bytes&&"chunk size: "+k(I(s.bytes))].filter(Boolean).join(", ")})`;if(l+=s.exports?.length?`
|
|
63
|
+
exports: `+M(s.exports.join(", ")):"",s.chunks?.length&&(l+=`
|
|
64
|
+
${s.chunks.map(c=>{const u=t.buildEntries.find(p=>p.path===c)??{};return M(" └─ "+o(c)+N(u.bytes?" ("+I(u?.bytes)+")":""))}).join(`
|
|
65
|
+
`)}`),s.modules&&s.modules.length>0){const c=s.modules.filter(u=>u.id.includes("node_modules")).sort((u,p)=>(p.bytes||0)-(u.bytes||0)).map(u=>M(" 📦 "+o(u.id)+N(u.bytes?" ("+I(u.bytes)+")":""))).join(`
|
|
60
66
|
`);l+=c.length>0?`
|
|
61
67
|
inlined modules:
|
|
62
|
-
`+c:""}if(t.options.declaration){let c=s.path.replace(/\.js$/,".d.ts"),
|
|
68
|
+
`+c:""}if(t.options.declaration){let c=s.path.replace(/\.js$/,".d.ts"),u="commonjs";s.path.endsWith(".cjs")?c=s.path.replace(/\.cjs$/,".d.cts"):s.path.endsWith(".mjs")&&(u="module",c=s.path.replace(/\.mjs$/,".d.mts"));const p=t.buildEntries.find(d=>d.path.endsWith(c));if(p){n.push(p.path);let d;c.includes(".d.ts")||(c=c.replace(".d.c",".d."),d=t.buildEntries.find(f=>f.path.endsWith(c))),d&&(n.push(d.path),l+=u==="commonjs"?`
|
|
63
69
|
types:
|
|
64
|
-
`+[p,
|
|
70
|
+
`+[p,d].map(f=>M(" └─ ")+N(o(f.path))+" (total size: "+k(I(f.bytes??0))+")").join(`
|
|
65
71
|
`):`
|
|
66
|
-
types: `+
|
|
72
|
+
types: `+N(o(p.path))+" (total size: "+k(I(p.bytes??0))+")")}}r=!0,l+=`
|
|
67
73
|
|
|
68
|
-
`,e.raw(s.chunk?
|
|
69
|
-
└─ `)+
|
|
74
|
+
`,e.raw(s.chunk?M(l):l)}}if(t.buildEntries.filter(s=>s.type==="asset").length>0){let s="Assets:";for(const a of t.buildEntries.filter(l=>l.type==="asset"))n.includes(a.path)||(s+=M(`
|
|
75
|
+
└─ `)+N(o(a.path))+" (total size: "+k(I(a.bytes??0))+")");s+=`
|
|
70
76
|
|
|
71
|
-
`,e.raw(s)}return r&&e.raw("Σ Total dist size (byte size):",k(
|
|
72
|
-
`),r},"showSizeInformation"),ji=de((e,t)=>{const o=bi(e.options.entries,"environment","runtime"),r=[];for(const[n,i]of Object.entries(o))for(const[s,a]of Object.entries(i)){const l={...e};!e.options.dtsOnly&&(n!=="undefined"||s!=="undefined")&&e.logger.info("Preparing build for "+(n==="undefined"?"":k(n)+" environment"+(s==="undefined"?"":" with "))+(s==="undefined"?"":k(s)+" runtime")),l.options.rollup.replace?(l.options.rollup.replace.values===void 0&&(l.options.rollup.replace.values={}),n!=="undefined"&&(l.options.rollup.replace.values={...l.options.rollup.replace.values,[["process","env","NODE_ENV"].join(".")]:JSON.stringify(n)}),l.options.rollup.replace.values={...l.options.rollup.replace.values,[["process","env","EdgeRuntime"].join(".")]:JSON.stringify(s==="edge-light")}):e.logger.warn("'replace' plugin is disabled. You should enable it to replace 'process.env.*' environments.");let c="";n!=="undefined"&&(c+=n+"/"),s!=="undefined"&&(c+=s+"/");let d=!1;l.options.minify!==void 0&&(d=l.options.minify),n==="development"?d=!1:n==="production"&&(d=!0);const p=[],u=[],g=[],y=[];for(const f of a)f.cjs&&f.esm?p.push(f):f.cjs?g.push(f):f.esm?u.push(f):f.declaration&&y.push(f);if(p.length>0){const f={...l,options:{...l.options,emitCJS:!0,emitESM:!0,entries:p,minify:d}};if(e.options.dtsOnly||r.push(xe(f,t,c)),e.options.declaration){const h=f.options.entries.filter(w=>w.declaration);h.length>0&&r.push(re({...f,options:{...f.options,entries:h}},t,c))}}if(u.length>0){const f={...l,options:{...l.options,emitCJS:!1,emitESM:!0,entries:u,minify:d}};if(e.options.dtsOnly||r.push(xe(f,t,c)),e.options.declaration){const h=f.options.entries.filter(w=>w.declaration);h.length>0&&r.push(re({...f,options:{...f.options,entries:h}},t,c))}}if(g.length>0){const f={...l,options:{...l.options,emitCJS:!0,emitESM:!1,entries:g,minify:d}};if(e.options.dtsOnly||r.push(xe(f,t,c)),e.options.declaration){const h=f.options.entries.filter(w=>w.declaration);h.length>0&&r.push(re({...f,options:{...f.options,entries:h}},t,c))}}if(l.options.declaration&&y.length>0){const f={...l,options:{...l.options,emitCJS:!1,emitESM:!1,entries:y,minify:d}};r.push(re(f,t,c))}}return r.filter(Boolean)},"prepareRollupConfig"),ki=de(async(e,t)=>{await e.hooks.callHook("build:before",e),await Promise.all(ji(e,t)),e.logger.success(uo(e.options.name?"Build succeeded for "+e.options.name:"Build succeeded"));for await(const o of yo(b(e.options.rootDir,e.options.outDir))){let r=e.buildEntries.find(n=>b(e.options.rootDir,e.options.outDir,n.path)===o.path);if(r||(r={chunk:!0,path:o.path},e.buildEntries.push(r)),!r.bytes){const n=await ut($(e.options.rootDir,e.options.outDir,o.path));r.bytes=n.size}}return await e.hooks.callHook("build:done",e),$i(e.logger,e)},"build");var xi=Object.defineProperty,Ei=m((e,t)=>xi(e,"name",{value:t,configurable:!0}),"r$5");const j=Ei((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var Di=Object.defineProperty,Xt=m((e,t)=>Di(e,"name",{value:t,configurable:!0}),"t$4");const me=Xt(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),Oe=Xt((e,t,o,r)=>{if(e==="module-sync")return"esm";if(r){const s=me(r);if(s)return s}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return o;const[n,...i]=t;return Oe(n,i,o,r)},"inferExportType");var Si=Object.defineProperty,Oi=m((e,t)=>Si(e,"name",{value:t,configurable:!0}),"y$1");const Pi=new Set(["electron","import","require","node","node-addons","default","types","deno","browser","module-sync","bun","workerd",..._e,...pe]),Me=Oi((e,t,o,r=[])=>{if(!e)return[];if(typeof e=="string"){const n=me(e);if(n&&n!==t)throw new Error(`Exported file "${e}" has an extension that does not match the package.json type "${t==="esm"?"module":"commonjs"}".`);return[{file:e,key:"exports",type:n??t}]}if(typeof e=="object"){const n=Object.entries(e).filter(([s])=>!s.endsWith(".json"));let i=[];for(const[s,a]of n)if(typeof a=="string"){let l={};Number.isInteger(+s)?l={exportKey:"*"}:s.startsWith("./")?l={exportKey:s.replace("./","")}:l={exportKey:s==="."?".":"*",subKey:s},i.push({...l,file:a,key:"exports",type:Oe(s,r,t,a)})}else if(typeof a=="object"&&a!==null)for(const[l,c]of Object.entries(a)){if(o===!1&&l==="types")continue;const d=Number.isInteger(+s)?l:s;typeof c=="string"?i.push({exportKey:d.replace("./",""),file:c,key:"exports",...Pi.has(l)?{subKey:l}:{},type:Oe(l,r,t,c)}):i=[...i,...Me({[d]:c},t,o,[...r,l])]}return i}return[]},"extractExportFilenames");var Ni=Object.defineProperty,be=m((e,t)=>Ni(e,"name",{value:t,configurable:!0}),"c$3");const Ci=be((e,t)=>e.key==="exports"&&e.subKey===C?C:e.key==="exports"&&e.subKey===Q?Q:t,"getEnvironment"),ne=be((e,t,o,r,n,i,s)=>{const a=Ci(n,i.environment);let l="node";for(const p of _e)if(n.file.includes("."+p+".")||n.subKey===p){l=p;break}let c=e.find(p=>p.input===t&&p.environment===a&&p.runtime===l);c===void 0?c=e[e.push({environment:a,exportKey:new Set([n.exportKey].filter(Boolean)),input:t,runtime:l})-1]:c.exportKey&&n.exportKey&&c.exportKey.add(n.exportKey),s&&(c.isGlob=!0),o&&(c.outDir=r),n.isExecutable?(c.executable=!0,c.declaration=!1,n.type==="cjs"?c.cjs=!0:n.type==="esm"&&(c.esm=!0)):(/\.d\.[mc]?ts$/.test(n.file)&&i.options.declaration!==!1&&(c.declaration=i.options.declaration),n.type==="cjs"?c.cjs=!0:n.type==="esm"&&(c.esm=!0));const d=n.file.replace(ft(n.file),"").replace(new RegExp(`^./${i.options.outDir.replace(/^\.\//,"")}/`),"");pe.has(n.subKey)&&!t.includes(d)&&(c.fileAlias=d)},"createOrUpdateEntry");let ot=!1;const rt=be(e=>{if(e.pkg?.dependencies?.typescript===void 0&&e.pkg?.devDependencies?.typescript===void 0)throw new Error("You tried to use a `.ts`, `.cts` or `.mts` file but `typescript` was not found in your package.json.")},"validateIfTypescriptIsInstalled"),_i=be((e,t,o)=>{const r=[];t.sort((a,l)=>a.split("/").length-l.split("/").length);const n=e.type==="module"?"esm":"cjs";n==="esm"&&(o.options.emitESM=!0),n==="cjs"&&(o.options.emitCJS=!0);const i=Me(e.exports,n,o.options.declaration);if(e.bin){const a=(typeof e.bin=="string"?[e.bin]:Object.values(e.bin)).filter(Boolean);for(const l of a){const c=me(l);if(c&&c!==n)throw new Error(`Exported file "${l}" has an extension that does not match the package.json type "${e.type??"commonjs"}".`);i.push({file:l,isExecutable:!0,key:"bin",type:c??n})}}e.main&&i.push({file:e.main,key:"main",type:me(e.main)??n}),e.module&&i.push({file:e.module,key:"module",type:"esm"}),(e.types||e.typings)&&(rt(o),o.options.declaration===void 0&&(o.options.declaration="compatible"),i.push({file:e.types??e.typings,key:"types"}));const s=[];for(const a of i){o.options.declaration===void 0&&(a.key==="types"||a.subKey==="types")&&(o.options.declaration=a.file.includes(".d.ts")?"compatible":!0),o.options.emitCJS===void 0&&a.type==="cjs"&&(o.options.emitCJS=!0),o.options.emitESM===void 0&&a.type==="esm"&&(o.options.emitESM=!0);const l=a.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),c=l.endsWith("/");if(c&&["./","/"].includes(l))continue;const d=l.replace(new RegExp("(./)?"+o.options.outDir),o.options.sourceDir).replace("./",""),p="(?<=/|$)",u=c?"":"\\.\\w+$";if(a.file.includes("/*")&&a.key==="exports"){ot||(o.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),ot=!0);const h=[],w=new RegExp(p+d.replace("*","(.*)")+u),x=new RegExp(p+d.replace(/(.*)\.[^.]*$/,"$1").replace("*","(.*)")+u);for(const v of t)(w.test(v)||pe.has(a.subKey)&&x.test(v))&&h.push(v);if(h.length===0){r.push(`Could not find entrypoint for \`${a.file}\``);continue}for(const v of h)ne(s,v,c,l,a,o,!0);continue}const g=new RegExp(p+d+u);let y=t.find(h=>g.test(h));if(pe.has(a.subKey)&&y===void 0){const h=new RegExp(p+d.replace(/(.*)\.[^.]*$/,"$1")+u);y=t.find(w=>h.test(w))}if(y===void 0){S($(o.options.rootDir,a.file))||r.push(`Could not find entrypoint for \`${a.file}\``);continue}(y.endsWith(".ts")||y.endsWith(".cts")||y.endsWith(".mts"))&&S(y)&&rt(o);const f=le(y.replace(J,""));S(f+".cts")&&S(f+".mts")?(ne(s,f+".cts",c,l,{...a,type:"cjs"},o,!1),ne(s,f+".mts",c,l,{...a,type:"esm"},o,!1)):ne(s,y,c,l,a,o,!1)}return{entries:s,warnings:r}},"inferEntries");var Ti=Object.defineProperty,Ii=m((e,t)=>Ti(e,"name",{value:t,configurable:!0}),"o$3");const Mi=Ii((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 Ai=Object.defineProperty,Ri=m((e,t)=>Ai(e,"name",{value:t,configurable:!0}),"t$3");const Fi={hooks:{"build:prepare":Ri(function(e){if(e.options.entries.length>0)return;const t=b(e.options.rootDir,e.options.sourceDir);if(!pt(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=ho(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&&(e.logger.info('Using publishConfig found in package.json, to override the default key-value pairs of "'+Object.keys(r.publishConfig).join(", ")+'".'),e.logger.debug(r.publishConfig),r=Mi(r,e.options.declaration));const n=_i(r,o,e);for(const i of n.warnings)j(e,i);if(e.options.entries.push(...n.entries),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",k(e.options.entries.map(i=>i.fileAlias?P(i.fileAlias)+" => "+P(i.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*")):P(i.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),I([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(i=>`[${i}]`).join(" ")))},"build:prepare")}};var Ji=Object.defineProperty,Bi=m((e,t)=>Ji(e,"name",{value:t,configurable:!0}),"t$2");const Li=Bi(async(e,t)=>{if(e==="auto")e=Fi;else{if(e==="none")return{};typeof e=="string"&&(e=await t.import(e)||{})}return typeof e=="function"&&(e=e()),e},"resolvePreset");var Wi=Object.defineProperty,Vi=m((e,t)=>Wi(e,"name",{value:t,configurable:!0}),"j");const zi=Vi(async e=>{const t=e.options.jiti.transformOptions?.babel?.plugins,o=[],r=JSON.stringify({...e.options.jiti,alias:{...Ie(e,"jit"),...e.options.jiti.alias},transformOptions:{...e.options.jiti.transformOptions,babel:{...e.options.jiti.transformOptions?.babel,plugins:"__$BABEL_PLUGINS"}}},null,2).replace('"__$BABEL_PLUGINS"',Array.isArray(t)?"["+t.map((n,i)=>{if(Array.isArray(n)){const[s,...a]=n;return o.push(s),"["+["plugin"+i,...a.map(l=>JSON.stringify(l))].join(", ")+"]"}return o.push(n),"plugin"+i}).join(",")+"]":"[]");for(const n of e.options.entries){const i=$(e.options.rootDir,e.options.outDir,n.name),s=Fo(e.jiti.esmResolve(n.input,{try:!0})??n.input),a=s.replace(J,""),l=Y(s),c=_n(l);let d=[];try{d=await Jo(s,{extensions:Ce})}catch(u){j(e,`Cannot analyze ${s} for exports: ${u.toString()}`);return}const p=d.includes("default")||d.length===0;if(e.options.emitESM){const u=O(z(i),await We("jiti",{conditions:["node","import"],url:import.meta.url})),g=a+".d.mts";A(`${i}.mjs`,c+['import { createJiti } from "'+u+'";',...o.map((y,f)=>"import plugin"+f+' from "'+y+'";'),"","const jiti = createJiti(import.meta.url, "+r+");","",'/** @type {import("'+g+'")} */','const _module = await jiti.import("'+s+'");',p?`
|
|
73
|
-
export default _module;`:"",...
|
|
74
|
-
`)),e.options.declaration&&
|
|
75
|
-
`+(p?'export { default } from "'+
|
|
76
|
-
`)),e.options.declaration&&
|
|
77
|
-
`+(p?'export { default } from "'+
|
|
78
|
-
`;return r.startsWith(n)?r.slice(n.length):r},"extractStack"),
|
|
77
|
+
`,e.raw(s)}return r&&e.raw("Σ Total dist size (byte size):",k(I(t.buildEntries.reduce((s,a)=>s+(a.bytes??0),0))),`
|
|
78
|
+
`),r},"showSizeInformation"),Pi=pe((e,t)=>{const o=Si(e.options.entries,"environment","runtime"),r=[];for(const[n,i]of Object.entries(o))for(const[s,a]of Object.entries(i)){const l={...e};!e.options.dtsOnly&&(n!=="undefined"||s!=="undefined")&&e.logger.info("Preparing build for "+(n==="undefined"?"":k(n)+" environment"+(s==="undefined"?"":" with "))+(s==="undefined"?"":k(s)+" runtime")),l.options.rollup.replace?(l.options.rollup.replace.values===void 0&&(l.options.rollup.replace.values={}),n!=="undefined"&&(l.options.rollup.replace.values={...l.options.rollup.replace.values,[["process","env","NODE_ENV"].join(".")]:JSON.stringify(n)}),l.options.rollup.replace.values={...l.options.rollup.replace.values,[["process","env","EdgeRuntime"].join(".")]:JSON.stringify(s==="edge-light")}):e.logger.warn("'replace' plugin is disabled. You should enable it to replace 'process.env.*' environments.");let c="";n!=="undefined"&&(c+=n+"/"),s!=="undefined"&&(c+=s+"/");let u=!1;l.options.minify!==void 0&&(u=l.options.minify),n==="development"?u=!1:n==="production"&&(u=!0);const p=[],d=[],f=[],y=[];for(const g of a)g.cjs&&g.esm?p.push(g):g.cjs?f.push(g):g.esm?d.push(g):g.declaration&&y.push(g);if(p.length>0){const g={...l,options:{...l.options,emitCJS:!0,emitESM:!0,entries:p,minify:u}};if(e.options.dtsOnly||r.push(ke(g,t,c)),e.options.declaration){const h=g.options.entries.filter(b=>b.declaration);h.length>0&&r.push(ee({...g,options:{...g.options,entries:h}},t,c))}}if(d.length>0){const g={...l,options:{...l.options,emitCJS:!1,emitESM:!0,entries:d,minify:u}};if(e.options.dtsOnly||r.push(ke(g,t,c)),e.options.declaration){const h=g.options.entries.filter(b=>b.declaration);h.length>0&&r.push(ee({...g,options:{...g.options,entries:h}},t,c))}}if(f.length>0){const g={...l,options:{...l.options,emitCJS:!0,emitESM:!1,entries:f,minify:u}};if(e.options.dtsOnly||r.push(ke(g,t,c)),e.options.declaration){const h=g.options.entries.filter(b=>b.declaration);h.length>0&&r.push(ee({...g,options:{...g.options,entries:h}},t,c))}}if(l.options.declaration&&y.length>0){const g={...l,options:{...l.options,emitCJS:!1,emitESM:!1,entries:y,minify:u}};r.push(ee(g,t,c))}}return r.filter(Boolean)},"prepareRollupConfig"),Ci=pe(async(e,t)=>{await e.hooks.callHook("build:before",e),await Promise.all(Pi(e,t)),e.logger.success($o(e.options.name?"Build succeeded for "+e.options.name:"Build succeeded"));for await(const o of go(w(e.options.rootDir,e.options.outDir))){let r=e.buildEntries.find(n=>w(e.options.rootDir,e.options.outDir,n.path)===o.path);if(r||(r={chunk:!0,path:o.path},e.buildEntries.push(r)),!r.bytes){const n=await ht($(e.options.rootDir,e.options.outDir,o.path));r.bytes=n.size}}return await e.hooks.callHook("build:done",e),Ni(e.logger,e)},"build");var _i=Object.defineProperty,Ti=m((e,t)=>_i(e,"name",{value:t,configurable:!0}),"r$5");const j=Ti((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var Ii=Object.defineProperty,Qt=m((e,t)=>Ii(e,"name",{value:t,configurable:!0}),"t$4");const ue=Qt(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),Se=Qt((e,t,o,r)=>{if(e==="module-sync")return"esm";if(r){const s=ue(r);if(s)return s}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return o;const[n,...i]=t;return Se(n,i,o,r)},"inferExportType");var Mi=Object.defineProperty,Ai=m((e,t)=>Mi(e,"name",{value:t,configurable:!0}),"y$1");const Ri=new Set(["electron","import","require","node","node-addons","default","types","deno","browser","module-sync","bun","workerd",..._e,...le]),Me=Ai((e,t,o,r=[])=>{if(!e)return[];if(typeof e=="string"){const n=ue(e);if(n&&n!==t)throw new Error(`Exported file "${e}" has an extension that does not match the package.json type "${t==="esm"?"module":"commonjs"}".`);return[{file:e,key:"exports",type:n??t}]}if(typeof e=="object"){const n=Object.entries(e).filter(([s])=>!s.endsWith(".json"));let i=[];for(const[s,a]of n)if(typeof a=="string"){let l={};Number.isInteger(+s)?l={exportKey:"*"}:s.startsWith("./")?l={exportKey:s.replace("./","")}:l={exportKey:s==="."?".":"*",subKey:s},i.push({...l,file:a,key:"exports",type:Se(s,r,t,a)})}else if(typeof a=="object"&&a!==null)for(const[l,c]of Object.entries(a)){if(o===!1&&l==="types")continue;const u=Number.isInteger(+s)?l:s;typeof c=="string"?i.push({exportKey:u.replace("./",""),file:c,key:"exports",...Ri.has(l)?{subKey:l}:{},type:Se(l,r,t,c)}):i=[...i,...Me({[u]:c},t,o,[...r,l])]}return i}return[]},"extractExportFilenames");var Fi=Object.defineProperty,he=m((e,t)=>Fi(e,"name",{value:t,configurable:!0}),"c$3");const Ji=he((e,t)=>e.key==="exports"&&e.subKey===C?C:e.key==="exports"&&e.subKey===G?G:t,"getEnvironment"),te=he((e,t,o,r,n,i,s)=>{const a=Ji(n,i.environment);let l="node";for(const p of _e)if(n.file.includes("."+p+".")||n.subKey===p){l=p;break}let c=e.find(p=>p.input===t&&p.environment===a&&p.runtime===l);c===void 0?c=e[e.push({environment:a,exportKey:new Set([n.exportKey].filter(Boolean)),input:t,runtime:l})-1]:c.exportKey&&n.exportKey&&c.exportKey.add(n.exportKey),s&&(c.isGlob=!0),o&&(c.outDir=r),n.isExecutable?(c.executable=!0,c.declaration=!1,n.type==="cjs"?c.cjs=!0:n.type==="esm"&&(c.esm=!0)):(/\.d\.[mc]?ts$/.test(n.file)&&i.options.declaration!==!1&&(c.declaration=i.options.declaration),n.type==="cjs"?c.cjs=!0:n.type==="esm"&&(c.esm=!0));const u=n.file.replace(mt(n.file),"").replace(new RegExp(`^./${i.options.outDir.replace(/^\.\//,"")}/`),"");le.has(n.subKey)&&!t.includes(u)&&(c.fileAlias=u)},"createOrUpdateEntry");let rt=!1;const nt=he(e=>{if(e.pkg?.dependencies?.typescript===void 0&&e.pkg?.devDependencies?.typescript===void 0)throw new Error("You tried to use a `.ts`, `.cts` or `.mts` file but `typescript` was not found in your package.json.")},"validateIfTypescriptIsInstalled"),Bi=he((e,t,o)=>{const r=[];t.sort((a,l)=>a.split("/").length-l.split("/").length);const n=e.type==="module"?"esm":"cjs";n==="esm"&&(o.options.emitESM=!0),n==="cjs"&&(o.options.emitCJS=!0);const i=Me(e.exports,n,o.options.declaration);if(e.bin){const a=(typeof e.bin=="string"?[e.bin]:Object.values(e.bin)).filter(Boolean);for(const l of a){const c=ue(l);if(c&&c!==n)throw new Error(`Exported file "${l}" has an extension that does not match the package.json type "${e.type??"commonjs"}".`);i.push({file:l,isExecutable:!0,key:"bin",type:c??n})}}e.main&&i.push({file:e.main,key:"main",type:ue(e.main)??n}),e.module&&i.push({file:e.module,key:"module",type:"esm"}),(e.types||e.typings)&&(nt(o),o.options.declaration===void 0&&(o.options.declaration="compatible"),i.push({file:e.types??e.typings,key:"types"}));const s=[];for(const a of i){o.options.declaration===void 0&&(a.key==="types"||a.subKey==="types")&&(o.options.declaration=a.file.includes(".d.ts")?"compatible":!0),o.options.emitCJS===void 0&&a.type==="cjs"&&(o.options.emitCJS=!0),o.options.emitESM===void 0&&a.type==="esm"&&(o.options.emitESM=!0);const l=a.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),c=l.endsWith("/");if(c&&["./","/"].includes(l))continue;const u=l.replace(new RegExp("(./)?"+o.options.outDir),o.options.sourceDir).replace("./",""),p="(?<=/|$)",d=c?"":"\\.\\w+$";if(a.file.includes("/*")&&a.key==="exports"){rt||(o.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),rt=!0);const h=[],b=new RegExp(p+u.replace("*","(.*)")+d),x=new RegExp(p+u.replace(/(.*)\.[^.]*$/,"$1").replace("*","(.*)")+d);for(const v of t)(b.test(v)||le.has(a.subKey)&&x.test(v))&&h.push(v);if(h.length===0){r.push(`Could not find entrypoint for \`${a.file}\``);continue}for(const v of h)te(s,v,c,l,a,o,!0);continue}const f=new RegExp(p+u+d);let y=t.find(h=>f.test(h));if(le.has(a.subKey)&&y===void 0){const h=new RegExp(p+u.replace(/(.*)\.[^.]*$/,"$1")+d);y=t.find(b=>h.test(b))}if(y===void 0){S($(o.options.rootDir,a.file))||r.push(`Could not find entrypoint for \`${a.file}\``);continue}(y.endsWith(".ts")||y.endsWith(".cts")||y.endsWith(".mts"))&&S(y)&&nt(o);const g=se(y.replace(J,""));S(g+".cts")&&S(g+".mts")?(te(s,g+".cts",c,l,{...a,type:"cjs"},o,!1),te(s,g+".mts",c,l,{...a,type:"esm"},o,!1)):te(s,y,c,l,a,o,!1)}return{entries:s,warnings:r}},"inferEntries");var Li=Object.defineProperty,Wi=m((e,t)=>Li(e,"name",{value:t,configurable:!0}),"o$3");const Vi=Wi((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 zi=Object.defineProperty,Ui=m((e,t)=>zi(e,"name",{value:t,configurable:!0}),"t$3");const Ki={hooks:{"build:prepare":Ui(function(e){if(e.options.entries.length>0)return;const t=w(e.options.rootDir,e.options.sourceDir);if(!yt(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=yo(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&&(e.logger.info('Using publishConfig found in package.json, to override the default key-value pairs of "'+Object.keys(r.publishConfig).join(", ")+'".'),e.logger.debug(r.publishConfig),r=Vi(r,e.options.declaration));const n=Bi(r,o,e);for(const i of n.warnings)j(e,i);if(e.options.entries.push(...n.entries),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",k(e.options.entries.map(i=>i.fileAlias?N(i.fileAlias)+" => "+N(i.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*")):N(i.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),M([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(i=>`[${i}]`).join(" ")))},"build:prepare")}};var Hi=Object.defineProperty,qi=m((e,t)=>Hi(e,"name",{value:t,configurable:!0}),"t$2");const Gi=qi(async(e,t)=>{if(e==="auto")e=Ki;else{if(e==="none")return{};typeof e=="string"&&(e=await t.import(e)||{})}return typeof e=="function"&&(e=e()),e},"resolvePreset");var Xi=Object.defineProperty,Yi=m((e,t)=>Xi(e,"name",{value:t,configurable:!0}),"j");const Qi=Yi(async e=>{const t=e.options.jiti.transformOptions?.babel?.plugins,o=[],r=JSON.stringify({...e.options.jiti,alias:{...Ie(e,"jit"),...e.options.jiti.alias},transformOptions:{...e.options.jiti.transformOptions,babel:{...e.options.jiti.transformOptions?.babel,plugins:"__$BABEL_PLUGINS"}}},null,2).replace('"__$BABEL_PLUGINS"',Array.isArray(t)?"["+t.map((n,i)=>{if(Array.isArray(n)){const[s,...a]=n;return o.push(s),"["+["plugin"+i,...a.map(l=>JSON.stringify(l))].join(", ")+"]"}return o.push(n),"plugin"+i}).join(",")+"]":"[]");for(const n of e.options.entries){const i=$(e.options.rootDir,e.options.outDir,n.name),s=Lo(e.jiti.esmResolve(n.input,{try:!0})??n.input),a=s.replace(J,""),l=Ne(s),c=Bn(l);let u=[];try{u=await Wo(s,{extensions:Ce})}catch(d){j(e,`Cannot analyze ${s} for exports: ${d.toString()}`);return}const p=u.includes("default")||u.length===0;if(e.options.emitESM){const d=O(V(i),await We("jiti",{conditions:["node","import"],url:import.meta.url})),f=a+".d.mts";F(`${i}.mjs`,c+['import { createJiti } from "'+d+'";',...o.map((y,g)=>"import plugin"+g+' from "'+y+'";'),"","const jiti = createJiti(import.meta.url, "+r+");","",'/** @type {import("'+f+'")} */','const _module = await jiti.import("'+s+'");',p?`
|
|
79
|
+
export default _module;`:"",...u.filter(y=>y!=="default").map(y=>`export const ${y} = _module.${y};`)].join(`
|
|
80
|
+
`)),e.options.declaration&&F(`${i}.d.mts`,'export * from "'+f+`";
|
|
81
|
+
`+(p?'export { default } from "'+f+'";':""))}if(e.options.emitCJS){const d=O(V(i),await We("jiti",{conditions:["node","require"],url:import.meta.url})),f=a+".d.cts";F(`${i}.cjs`,c+['const { createJiti } = require("'+d+'");',...o.map((y,g)=>"const plugin"+g+" = require("+JSON.stringify(y)+")"),"","const jiti = createJiti(__filename, "+r+");","",'/** @type {import("'+f+'")} */','module.exports = jiti("'+s+'")'].join(`
|
|
82
|
+
`)),e.options.declaration&&F(i+".d.cts",'export * from "'+f+`";
|
|
83
|
+
`+(p?'export { default } from "'+f+'";':""))}c&&(await De(`${i}.cjs`),await De(`${i}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var Zi=Object.defineProperty,Ae=m((e,t)=>Zi(e,"name",{value:t,configurable:!0}),"i$3");const es=Ae(e=>{const{message:t,name:o="Error",stack:r}=e;if(!r)return r;const n=`${o}: ${t}
|
|
84
|
+
`;return r.startsWith(n)?r.slice(n.length):r},"extractStack"),ts=Ae(e=>`
|
|
79
85
|
${e.replaceAll(/^\n|\n$/g,"")}
|
|
80
|
-
`,"normalizeCodeFrame"),
|
|
86
|
+
`,"normalizeCodeFrame"),Zt=Ae(e=>{const t=es(e);let o=(e.plugin?`[${e.plugin}] `:"")+e.message;e.id&&(o+=`
|
|
81
87
|
file: ${k(e.id+(e.loc?":"+e.loc.line+":"+e.loc.column:""))}`),e.frame&&(o+=`
|
|
82
|
-
`+
|
|
83
|
-
${t}`)},"enhanceRollupError");var
|
|
84
|
-
└─ ${O(process.cwd(),s)}`);if(e.logger.info(i),
|
|
85
|
-
`+y);if(!h){r.error({message:`Could not find the typedoc marker: <!-- ${i} --><!-- /${i} --> in ${l}`,prefix:"typedoc"});return}if(f===h)return;h&&A(l,h.replaceAll(`<!-- _REPLACE_${i}`,`<!-- ${i}`).replaceAll(`<!-- _REPLACE_\\${i}`,"<!-- ${marker}"),{overwrite:!0})}}},"generateReferenceDocumentation");var Zi=Object.defineProperty,es=m((e,t)=>Zi(e,"name",{value:t,configurable:!0}),"i$2");const it=es((e,t,o,r)=>{try{let n={};const i=b(t,"keystore.json");r&&S(i)&&(n=Ne(i)),n[e]===void 0&&(n[e]=new Date().toISOString()),ge(i,n,{overwrite:!0})}catch(n){o.debug({context:n,message:n.message,prefix:"cache-key-store"})}},"createOrUpdateKeyStorage");var ts=Object.defineProperty,Zt=m((e,t)=>ts(e,"name",{value:t,configurable:!0}),"s$4");const os=Zt(e=>{try{JSON.parse(e)}catch{return!1}return!0},"isJson");let rs=class{static{m(this,"g")}static{Zt(this,"FileCache")}#r;#e;#n;#t=!0;#o=new Map;constructor(t,o,r,n){this.#r=t,this.#n=r,o===void 0?n.debug({message:"Could not create cache directory.",prefix:"file-cache"}):(this.#e=o,n.debug({message:"Cache path is: "+this.#e,prefix:"file-cache"}))}set isEnabled(t){this.#t=t}has(t,o){return!this.#t||this.#e===void 0?!1:S(this.getFilePath(t,o))}get(t,o){if(!this.#t||this.#e===void 0)return;const r=this.getFilePath(t,o);if(this.#o.has(r))return this.#o.get(r);if(!S(r))return;const n=Y(r);if(os(n)){const i=JSON.parse(n);return this.#o.set(r,i),i}return this.#o.set(r,n),n}set(t,o,r){if(!this.#t||this.#e===void 0||o===void 0)return;const n=this.getFilePath(t,r);typeof o=="object"&&(o=JSON.stringify(o)),A(n,o,{overwrite:!0})}getFilePath(t,o){let r=t.replaceAll(le(this.#r),"");return r=r.replaceAll(":","-"),b(this.#e,this.#n,o?.replaceAll(":","-")??"",le(r))}};var ns=Object.defineProperty,ie=m((e,t)=>ns(e,"name",{value:t,configurable:!0}),"l$4");const is=U,ss=ie((e,t)=>{const{sideEffects:o}=t;let r;if(typeof o=="boolean")r=ie(()=>o,"hasSideEffects");else if(Array.isArray(o))if(o.length<=0)r=ie(()=>!1,"hasSideEffects");else{const n=o.map(i=>i.includes("/")?i:`**/${i}`);r=is(n,null,{resolve:e})}else r=ie(()=>null,"hasSideEffects");return r},"getPackageSideEffect");var as=Object.defineProperty,ls=m((e,t)=>as(e,"name",{value:t,configurable:!0}),"n");const eo=ls(e=>{const t=b(e,"package.json");if(!S(t))throw new Error("package.json not found at "+t);return{packageJson:kt(t),packageJsonPath:t}},"loadPackageJson");var cs=Object.defineProperty,ps=m((e,t)=>cs(e,"name",{value:t,configurable:!0}),"r$3");const st=ps((e,t)=>{if(e.warnings.size>0&&(t&&e.logger.raw(`
|
|
88
|
+
`+jo(ts(e.frame))),e.message=o,t!==void 0&&(e.stack=`${e.message}
|
|
89
|
+
${t}`)},"enhanceRollupError");var os=Object.defineProperty,eo=m((e,t)=>os(e,"name",{value:t,configurable:!0}),"p");const de="rollup-watch.json",it=eo((e,t,o,r)=>{const n="watcher:"+o;e.on("change",(i,{event:s})=>{r.logger.info({message:`${k(O(".",i))} was ${s}d`,prefix:n})}),e.on("restart",()=>{r.logger.info({message:"Rebuilding "+o+"...",prefix:n})}),e.on("event",async i=>{switch(i.code){case"END":{r.logger.success({message:"Rebuild "+o+" finished",prefix:n});break}case"BUNDLE_START":{r.logger.info({message:k("build started..."),prefix:n});break}case"BUNDLE_END":{await i.result.close(),t.set(o==="bundle"?de:"dts-"+de,i.result.cache),r.logger.info({message:k(`built in ${i.duration+""}ms.`),prefix:n});break}case"ERROR":{Zt(i.error),r.logger.error({context:[i.error],message:"Rebuild "+o+" failed: "+i.error.message,prefix:n});break}}})},"watchHandler"),rs=eo(async(e,t)=>{const o=await Xt(e,t);if(await e.hooks.callHook("rollup:options",e,o),Object.keys(o.input).length===0)return;(!e.options.rollup.isolatedDeclarations||!e.options.isolatedDeclarationTransformer)&&(o.cache=t.get(de)),e.options.rollup.watch&&typeof o.watch=="object"&&o.watch.include===void 0&&(o.watch={...o.watch,...e.options.rollup.watch},o.watch.include=[w(e.options.sourceDir,"**","*"),"package.json"],Array.isArray(e.options.rollup.watch.include)?o.watch.include=[...o.watch.include,...e.options.rollup.watch.include]:e.options.rollup.watch.include&&o.watch.include.push(e.options.rollup.watch.include),o.watch.chokidar={cwd:e.options.rootDir,...o.watch.chokidar,ignored:["**/.git/**","**/node_modules/**","**/test-results/**",...o.watch.chokidar?.ignored??[]]});const r=Je(o);await e.hooks.callHook("rollup:watch",e,r);const n=[...Array.isArray(o.input)?o.input:typeof o.input=="string"?[o.input]:Object.keys(o.input??{})];let i="Starting watchers for entries:";for(const s of n)i+=M(`
|
|
90
|
+
└─ ${O(process.cwd(),s)}`);if(e.logger.info(i),it(r,t,"bundle",e),e.options.declaration){const s=await Yt(e,t);s.cache=t.get("dts-"+de),await e.hooks.callHook("rollup:dts:options",e,s);const a=Je(s);await e.hooks.callHook("rollup:watch",e,a),it(a,t,"types",e)}},"watch");var ns=Object.defineProperty,is=m((e,t)=>ns(e,"name",{value:t,configurable:!0}),"i$2");const ss=is((e,t,o,r)=>{try{let n={};const i=w(t,"keystore.json");r&&S(i)&&(n=Pe(i)),n[e]===void 0&&(n[e]=new Date().toISOString()),me(i,n,{overwrite:!0})}catch(n){o.debug({context:n,message:n.message,prefix:"cache-key-store"})}},"createOrUpdateKeyStorage");var as=Object.defineProperty,to=m((e,t)=>as(e,"name",{value:t,configurable:!0}),"s$4");const ls=to(e=>{try{JSON.parse(e)}catch{return!1}return!0},"isJson");let cs=class{static{m(this,"g")}static{to(this,"FileCache")}#r;#e;#n;#t=!0;#o=new Map;constructor(t,o,r,n){this.#r=t,this.#n=r,o===void 0?n.debug({message:"Could not create cache directory.",prefix:"file-cache"}):(this.#e=o,n.debug({message:"Cache path is: "+this.#e,prefix:"file-cache"}))}set isEnabled(t){this.#t=t}has(t,o){return!this.#t||this.#e===void 0?!1:S(this.getFilePath(t,o))}get(t,o){if(!this.#t||this.#e===void 0)return;const r=this.getFilePath(t,o);if(this.#o.has(r))return this.#o.get(r);if(!S(r))return;const n=Ne(r);if(ls(n)){const i=JSON.parse(n);return this.#o.set(r,i),i}return this.#o.set(r,n),n}set(t,o,r){if(!this.#t||this.#e===void 0||o===void 0)return;const n=this.getFilePath(t,r);typeof o=="object"&&(o=JSON.stringify(o)),F(n,o,{overwrite:!0})}getFilePath(t,o){let r=t.replaceAll(se(this.#r),"");return r=r.replaceAll(":","-"),w(this.#e,this.#n,o?.replaceAll(":","-")??"",se(r))}};var ps=Object.defineProperty,oe=m((e,t)=>ps(e,"name",{value:t,configurable:!0}),"l$4");const us=z,ds=oe((e,t)=>{const{sideEffects:o}=t;let r;if(typeof o=="boolean")r=oe(()=>o,"hasSideEffects");else if(Array.isArray(o))if(o.length<=0)r=oe(()=>!1,"hasSideEffects");else{const n=o.map(i=>i.includes("/")?i:`**/${i}`);r=us(n,null,{resolve:e})}else r=oe(()=>null,"hasSideEffects");return r},"getPackageSideEffect");var ms=Object.defineProperty,fs=m((e,t)=>ms(e,"name",{value:t,configurable:!0}),"n");const oo=fs(e=>{const t=w(e,"package.json");if(!S(t))throw new Error("package.json not found at "+t);return{packageJson:Et(t),packageJsonPath:t}},"loadPackageJson");var gs=Object.defineProperty,ys=m((e,t)=>gs(e,"name",{value:t,configurable:!0}),"r$3");const st=ys((e,t)=>{if(e.warnings.size>0&&(t&&e.logger.raw(`
|
|
86
91
|
`),e.logger.warn(`Build is done with some warnings:
|
|
87
92
|
|
|
88
93
|
${[...e.warnings].map(o=>`- ${o}`).join(`
|
|
89
|
-
`)}`),e.options.failOnWarn))throw new Error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`.")},"logBuildErrors");var
|
|
90
|
-
- `+k(l)+(c.length>0?
|
|
94
|
+
`)}`),e.options.failOnWarn))throw new Error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`.")},"logBuildErrors");var hs=Object.defineProperty,ro=m((e,t)=>hs(e,"name",{value:t,configurable:!0}),"r$2");const at=ro(async(e,t)=>{if(typeof e.name!="string"){let o=ft(e.input)?O(t.options.rootDir,e.input):dt(e.input);o.startsWith("./")&&(o=o.slice(2)),e.name=o.replace(new RegExp(`^${t.options.sourceDir}/`),"").replace(J,"")}if(!e.input)throw new Error(`Missing entry input: ${JSON.stringify(e)}`);Xo(e.input)&&(e.input=$(t.options.rootDir,e.input)),t.options.declaration&&e.declaration===void 0&&(e.declaration=t.options.declaration),e.executable&&(e.cjs===void 0||e.esm===void 0)?t.pkg.type==="commonjs"&&e.cjs===void 0&&t.options.emitCJS!==void 0?(e.cjs=t.options.emitCJS,e.esm=!1):t.pkg.type==="module"&&e.esm===void 0&&t.options.emitESM!==void 0&&(e.esm=t.options.emitESM,e.cjs=!1):e.cjs===void 0&&e.esm===void 0&&(t.options.emitCJS!==void 0&&(e.cjs=t.options.emitCJS),t.options.emitESM!==void 0&&(e.esm=t.options.emitESM)),e.outDir=$(t.options.rootDir,e.outDir??t.options.outDir)},"extendEntry"),vs=ro(async e=>{e.options.entries=e.options.entries.map(t=>typeof t=="string"?{input:t,isGlob:Le(t)}:{...t,exportKey:t.exportKey??new Set,isGlob:Le(t.input)});for(const t of e.options.entries.filter(o=>o.isGlob)){const{isGlob:o,...r}=t,n=["**/.git/**","**/node_modules/**","**/test-results/**"];if(e.options.rollup.watch){if(typeof e.options.rollup.watch.exclude=="string")n.push(e.options.rollup.watch.exclude);else if(Array.isArray(e.options.rollup.watch.exclude))for(const s of e.options.rollup.watch.exclude)typeof s=="string"&&n.push(s)}const i=Bo([r.input],{cwd:e.options.rootDir,dot:!1,ignore:n,onlyFiles:!0});if(i.length===0)throw new Go("No files found in the glob pattern: "+k(w(e.options.rootDir,r.input)));for(const s of i)e.options.entries.push({...r,input:$(e.options.rootDir,s)});e.options.entries.splice(e.options.entries.indexOf(t),1)}for await(const t of e.options.entries.filter(o=>o.fileAlias===void 0))await at(t,e);for await(const t of e.options.entries.filter(o=>o.fileAlias!==void 0))t.name=t.fileAlias,t.fileAlias=void 0,await at(t,e)},"prepareEntries");var bs=Object.defineProperty,ws=m((e,t)=>bs(e,"name",{value:t,configurable:!0}),"o$1");const $s=ws(e=>{if(e.options.validation?.packageJson?.dependencies===!1)return;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(e.pkg?.dependencies)for(const n of Object.keys(e.pkg?.dependencies))o.delete(n);for(const n of t){const i=St(n);!Ee(e.options.externals,n)&&!n.startsWith("chunks/")&&e.pkg?.dependencies?.[i]===void 0&&e.pkg?.peerDependencies?.[i]===void 0&&r.add(n)}o.size>0&&j(e,`Potential unused dependencies found: ${[...o].map(n=>k(n)).join(", ")}`),r.size>0&&j(e,`Potential implicit dependencies found: ${[...r].map(n=>k(n)).join(", ")}`)},"validateDependencies");var js=Object.defineProperty,no=m((e,t)=>js(e,"name",{value:t,configurable:!0}),"i$1");const ks=no((e,t)=>Yo(e,t)<=e.length/3||t.includes(e),"isSimilar"),xs=no((e,t)=>{const o=e.toLowerCase();return t.filter(r=>ks(r.toLowerCase(),o))},"findAlternatives");var Es=Object.defineProperty,lt=m((e,t)=>Es(e,"name",{value:t,configurable:!0}),"r$1");const Ds=lt(e=>{const{options:t}=e;if(t.validation?.packageJson?.exports===!1)return;const o=t.validation?.packageJson,r=new Set([t.declaration&&o?.types?e.pkg.types:"",t.declaration&&o?.types?e.pkg.typings:"",...t.dtsOnly||o?.bin===!1?[""]:typeof e.pkg.bin=="string"?[e.pkg.bin]:Object.values(e.pkg.bin??{}),t.dtsOnly&&o?.main===!1?"":e.pkg.main,t.dtsOnly&&o?.module===!1?"":e.pkg.module,...o?.exports===!1?[]:Me(e.pkg.exports,e.pkg.type==="module"?"esm":"cjs",t.declaration).map(a=>t.dtsOnly?a.subKey==="types"?a.file:void 0:a.file)].filter(Boolean).map(a=>a&&$(t.rootDir,a.replace(/\/[^*/]*\*[^\n\r/\u2028\u2029]*(?:[\n\r\u2028\u2029][^*/]*\*[^\n\r/\u2028\u2029]*)*(?:\/.*)?$/,"")))),n=[];for(const a of r)a&&!a.includes("*")&&!yt(a)&&n.push(a.replace(`${t.rootDir}/`,""));const i=lt(a=>O(t.rootDir,$(t.outDir,a)),"rPath"),s=e.buildEntries.filter(a=>!a.chunk).map(a=>i(a.path));if(n.length>0){let a="Potential missing or wrong package.json files:";for(const l of n){const c=xs(l,s);a+=`
|
|
95
|
+
- `+k(l)+(c.length>0?ko` (did you mean ${c.map(u=>`"${u}"`).join(", ")}?)`:"")}j(e,a)}},"validatePackageEntries");var Ss=Object.defineProperty,Os=m((e,t)=>Ss(e,"name",{value:t,configurable:!0}),"l$2");const Ns=Os(e=>{const{options:{validation:t},pkg:o}=e;o.name===void 0&&t?.packageJson?.name!==!1&&j(e,"The 'name' field is missing in your package.json. Please provide a valid package name."),t?.packageJson?.files!==!1&&(o.files===void 0?j(e,"The 'files' field is missing in your package.json. Add the files to be included in the package."):o.files.length===0?j(e,"The 'files' field in your package.json is empty. Please specify the files to be included in the package."):o.files.some(i=>i.includes(e.options.outDir))||j(e,`The 'files' field in your package.json is missing the '${e.options.outDir}' directory. Ensure the output directory is included.`));const r=o.type==="commonjs"||o.type===void 0,n=o.type==="module";if(r?(t?.packageJson?.main!==!1&&(o.main===void 0&&j(e,"The 'main' field is missing in your package.json. This field should point to your main entry file."),o.main?.includes(".mjs")&&j(e,"The 'main' field in your package.json should not use a '.mjs' extension for CommonJS modules.")),t?.packageJson?.module!==!1&&(o.module===void 0&&e.options.emitESM&&j(e,"The 'module' field is missing in your package.json, but you are emitting ES modules."),o.module&&o.main&&o.module===o.main&&j(e,`Conflict detected: The 'module' and 'main' fields both point to '${o.module}'. Please ensure they refer to different module types.`),e.options.emitESM&&o.module?.includes(".cjs")&&j(e,"The 'module' field in your package.json should not use a '.cjs' extension for ES modules."))):n&&(o.exports===void 0&&!e.options.emitCJS?t?.packageJson?.exports!==!1&&j(e,"The 'exports' field is missing in your package.json. Define module exports explicitly."):e.options.emitCJS&&(t?.packageJson?.main!==!1&&o.main===void 0&&j(e,"The 'main' field is missing in your package.json. This field is needed when emitting CommonJS modules."),t?.packageJson?.module!==!1&&(o.module===void 0&&j(e,"The 'module' field is missing in your package.json. This field is necessary when emitting ES modules."),o.module?.includes(".cjs")&&j(e,"The 'module' field should not use a '.cjs' extension for ES modules."),o.module&&o.main&&o.module===o.main&&j(e,`Conflict detected: The 'module' and 'main' fields both point to '${o.module}'. Please ensure they refer to different module types.`)),t?.packageJson?.exports!==!1&&o.exports===void 0&&j(e,"The 'exports' field is missing in your package.json. This field is required for defining explicit exports."))),o.exports,t?.packageJson?.bin!==!1){if(typeof o.bin=="string"&&o.bin.includes(r?".mjs":".cjs"))j(e,`The 'bin' field in your package.json should not use a ${r?".mjs":".cjs"} extension for ${r?"CommonJS":"ES modules"} binaries.`);else if(typeof o.bin=="object")for(const[i,s]of Object.entries(o.bin))s&&s.includes(r?".mjs":".cjs")&&j(e,`The 'bin.${i}' field in your package.json should not use a ${r?".mjs":".cjs"} extension for ${r?"CommonJS":"ES modules"} binaries.`)}e.options.declaration&&(o.types===void 0&&o.typings===void 0&&t?.packageJson?.types!==!1&&j(e,"The 'types' field is missing in your package.json. This field should point to your type definitions file."),(e.options.declaration===!0||e.options.declaration==="compatible")&&t?.packageJson?.typesVersions!==!1&&(o.typesVersions===void 0||Object.keys(o.typesVersions).length===0)&&j(e,"No 'typesVersions' field found in your package.json. Consider adding this field, or change the declaration option to 'node16' or 'false'."))},"validatePackageFields");var Ps=Object.defineProperty,Cs=m((e,t)=>Ps(e,"name",{value:t,configurable:!0}),"i");const _s=Cs(e=>{const{packageJson:t}=oo(e.options.rootDir);e.pkg=t,$s(e),Ns(e),Ds(e)},"validator");var Ts=Object.defineProperty,Is=m((e,t)=>Ts(e,"name",{value:t,configurable:!0}),"a");const Ms=/^[^a-z_@#~]|[^\w/@#~-]|@\/|#\/|~\//i,As=new Set(["abstract","await","boolean","break","byte","case","catch","char","class","const","continue","debugger","default","delete","do","double","else","enum","export","extends","false","final","finally","float","for","function","goto","if","implements","import","in","instanceof","int","interface","let","long","native","new","null","package","private","protected","public","return","short","static","super","switch","synchronized","this","throw","throws","transient","true","try","typeof","var","void","volatile","while","with","yield"]),ct=Is(e=>{if(!Array.isArray(e)&&e!==null)for(const[t,o]of Object.entries(e)){if(typeof t!="string"||t.trim()==="")throw new Error(`Alias name "${t}" is invalid. Alias names should be non-empty strings.`);if(Ms.test(t))throw new Error(`Alias name "${t}" is invalid. Alias names should start with a letter or underscore and only contain letters, numbers, underscores, and dashes.`);if(As.has(t))throw new Error(`Alias name "${t}" is a reserved keyword and cannot be used.`);const r=$(o);if(!S(r))throw new Error(`Target path "${r}" for alias "${t}" does not exist.`)}},"validateAliasEntries");var Rs=Object.defineProperty,P=m((e,t)=>Rs(e,"name",{value:t,configurable:!0}),"u$1");const Fs=P(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"),Js=P((e,t,o,r,n,i,s,a,l)=>{const c=Fs(l?.config.compilerOptions?.jsx),u=So(i,n,s,{alias:{},cjsInterop:!1,clean:!0,debug:r,declaration:void 0,emitCJS:void 0,emitESM:void 0,entries:[],externals:[...Re.builtinModules,...Re.builtinModules.map(p=>`node:${p}`)],failOnWarn:!0,fileCache:!0,jiti:{alias:{},debug:r,interopDefault:!0},minify:o===C,name:(a.name??"").split("/").pop()??"default",outDir:l?.config.compilerOptions?.outDir??"dist",rollup:{alias:{},cjsInterop:{addDefaultProperty:!1},commonjs:{extensions:[".mjs",".js",".json",".node",".cjs"],ignoreTryCatch:!0,preserveSymlinks:!0,transformMixedEsModules:!1},dts:{compilerOptions:{baseUrl:l?.config.compilerOptions?.baseUrl??".",checkJs:!1,composite:!1,declaration:!0,declarationMap:!1,emitDeclarationOnly:!0,incremental:!1,moduleResolution:100,noEmit:!1,noEmitOnError:!0,preserveSymlinks:!1,skipLibCheck:!0,target:99},respectExternal:!0},dynamicVars:{errorWhenNoFilesFound:!0,include:/\bimport\s*[(/]/},esbuild:{charset:"utf8",exclude:W,jsx:c,jsxDev:l?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:l?.config.compilerOptions?.jsxFactory,jsxFragment:l?.config.compilerOptions?.jsxFragmentFactory,jsxImportSource:l?.config.compilerOptions?.jsxImportSource,jsxSideEffects:!0,keepNames:!0,sourcesContent:!1,target:l?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:l?.config},isolatedDeclarations:{exclude:W,ignoreErrors:!1,include:K},json:{preferConst:!0},license:{dependenciesTemplate:P((p,d,f)=>`
|
|
91
96
|
# Licenses of bundled dependencies
|
|
92
|
-
The published ${
|
|
97
|
+
The published ${f} artifact additionally contains code with the following licenses:
|
|
93
98
|
`+(p.length>0?`${p.join(", ")}
|
|
94
99
|
|
|
95
100
|
`:`
|
|
96
101
|
`)+`# Bundled dependencies:
|
|
97
|
-
`+
|
|
102
|
+
`+d,"dependenciesTemplate"),dtsTemplate:P((p,d,f)=>`
|
|
98
103
|
# Licenses of bundled types
|
|
99
|
-
The published ${
|
|
104
|
+
The published ${f} artifact additionally contains code with the following licenses:
|
|
100
105
|
`+(p.length>0?`${p.join(", ")}
|
|
101
106
|
|
|
102
107
|
`:`
|
|
103
108
|
`)+`# Bundled types:
|
|
104
|
-
`+
|
|
109
|
+
`+d,"dtsTemplate")},node10Compatibility:{},patchTypes:{},polyfillNode:{},preserveDirectives:{exclude:W,include:K},preserveDynamicImports:!0,raw:{exclude:W,include:[/\.(md|txt|css|htm|html|data)$/]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,exportConditions:["module-sync"],extensions:Ce,preferBuiltins:!1},shebang:{replace:!1,shebang:"#!/usr/bin/env node"},shim:{exclude:W,include:K},sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:l?.config.compilerOptions?.esModuleInterop===!1,include:K,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:o===C,...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:K,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,decoratorVersion:"2022-03",legacyDecorator:l?.config.compilerOptions?.experimentalDecorators,react:{development:o!==C,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:ds(t,a),preset:"recommended",propertyReadSideEffects:!0},visualizer:{},watch:{chokidar:{ignoreInitial:!0,ignorePermissionErrors:!0},clearScreen:!0,exclude:W}},rootDir:t,sourceDir:"src",sourcemap:!1,transformerName:void 0,typedoc:{excludePrivate:!0,groupOrder:["Classes","Constructors","Accessors","Methods","Functions","Namespaces","Variables","Enumerations","Interfaces","Type Aliases","*"],kindSortOrder:["Project","Module","Class","Interface","Function","Namespace","Variable","Enum","EnumMember","TypeAlias","Reference","Constructor","Property","Accessor","Method","Parameter","TypeParameter","TypeLiteral","CallSignature","ConstructorSignature","IndexSignature","GetSignature","SetSignature"],marker:"TYPEDOC",name:a.name??"unknown",pretty:!0,readme:"none",showConfig:r,tsconfig:l?.path}});if(!u.transformerName){const p=new Map([...Object.entries(a.dependencies??{}),...Object.entries(a.devDependencies??{})]);let d="0.0.0";if(p.has("esbuild"))u.transformerName="esbuild",d=p.get("esbuild");else if(p.has("@swc/core"))u.transformerName="swc",d=p.get("@swc/core");else if(p.has("sucrase"))u.transformerName="sucrase",d=p.get("sucrase");else throw new Error("Unknown transformer, check your transformer options or install one of the supported transformers: esbuild, swc, sucrase");e.info("Using "+k("rollup ")+No),e.info({message:"Using "+k(u.transformerName)+" "+d,prefix:"transformer"})}return u.rollup.resolve&&u.rollup.resolve.preferBuiltins===!0&&(u.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true")),a.dependencies&&u.externals.push(...Object.keys(a.dependencies)),a.peerDependencies&&u.externals.push(...Object.keys(a.peerDependencies)),a.optionalDependencies&&u.externals.push(...Object.keys(a.optionalDependencies)),ct(u.alias),u.rollup.alias&&u.rollup.alias.entries&&ct(u.rollup.alias.entries),u},"generateOptions"),Bs=P(async(e,t,o,r,n,i,s,a,l,c)=>{const u=await Gi(s.preset??i.preset??"auto",c),p=Js(e,t,r,n,i,s,u,a,l);ho(w(p.rootDir,p.outDir));const d={buildEntries:[],dependencyGraphMap:new Map,environment:r,hooks:Oo(),jiti:vt(p.rootDir,p.jiti),logger:e,mode:o,options:p,pkg:a,tsconfig:l,usedImports:new Set,warnings:new Set};u.hooks&&d.hooks.addHooks(u.hooks),i.hooks&&d.hooks.addHooks(i.hooks),s.hooks&&d.hooks.addHooks(s.hooks),await d.hooks.callHook("build:prepare",d),d.options.emitESM===void 0&&d.logger.info("Emitting of ESM bundles, is disabled."),d.options.emitCJS===void 0&&d.logger.info("Emitting of CJS bundles, is disabled."),d.options.minify&&d.logger.info("Minification is enabled, the output will be minified");const f=a.dependencies?.typescript!==void 0||a.devDependencies?.typescript!==void 0;if(d.options.declaration&&d.tsconfig===void 0&&f)throw new Error("Cannot build declaration files without a tsconfig.json");return f?d.options.declaration===!1&&d.logger.info({message:"Generation of declaration files are disabled.",prefix:"dts"}):(d.options.declaration=!1,d.logger.info({message:"Typescript is not installed. Generation of declaration files are disabled.",prefix:"dts"})),d.options.declaration&&d.logger.info("Using typescript version: "+k(a.devDependencies?.typescript??a.dependencies?.typescript??"unknown")),d.options.declaration&&(a.dependencies?.typescript||a.devDependencies?.typescript)&&!d.tsconfig?.config.compilerOptions?.isolatedModules&&d.logger.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig.
|
|
105
110
|
Because none of the third-party transpiler, packem uses under the hood is type-aware, some techniques or features often used in TypeScript are not properly checked and can cause mis-compilation or even runtime errors.
|
|
106
|
-
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.`),await
|
|
111
|
+
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.`),await vs(d),d},"createContext"),Ls=P(async e=>{const t=[];if(e.options.clean)for(const o of new Set(e.options.entries.map(r=>r.outDir).filter(Boolean).sort()))o===e.options.rootDir||o===e.options.sourceDir||e.options.rootDir.startsWith(o.endsWith("/")?o:`${o}/`)||t.some(r=>o.startsWith(r))||(t.push(o),e.logger.info(`Cleaning dist directory: \`./${O(e.options.rootDir,o)}\``),await vo(o))},"cleanDistributionDirectories"),Ws=P(async(e,t,o)=>{if(e&&S(w(e,"keystore1.json"))){const r=Pe(w(e,"keystore.json")),n=gt(e,{withFileTypes:!0}).filter(s=>s.isDirectory());let i=o;for await(const s of n)r[s.name]||(await wo(w(e,s.name),{force:!0,recursive:!0}),i&&t.raw(`
|
|
107
112
|
|
|
108
|
-
`),t.info({message:"Removing "+s.name+" file cache, the cache key is not used anymore.",prefix:"file-cache"}),i=!1)}},"removeOldCacheFolders"),
|
|
109
|
-
${
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
+
`),t.info({message:"Removing "+s.name+" file cache, the cache key is not used anymore.",prefix:"file-cache"}),i=!1)}},"removeOldCacheFolders"),Vs=P(e=>{switch(e){case"jit":return"Stubbing";case"watch":return"Watching";case"tsdoc":return"Generating TSDoc";default:return"Building"}},"getMode"),zs=P(async(e,t,o,r,n={})=>{const{configPath:i,debug:s,tsconfigPath:a,...l}=n;r.wrapAll(),e=$(pt(),e),r.debug("Root directory:",e);const{packageJson:c,packageJsonPath:u}=oo(e);r.debug("Using package.json found at",u);let p;if(a){const y=w(e,a);if(!await ut(y))throw new Error("tsconfig.json not found at "+y);p={config:Eo(y),path:y},r.info("Using tsconfig settings at",y)}else if(c.dependencies?.typescript||c.devDependencies?.typescript)try{p=await Do(e),r.debug("Using tsconfig settings found at",p.path)}catch{r.info("No tsconfig.json or jsconfig.json found.")}const d=xo("@visulima/packem",{cwd:e});let f=!1;try{const y=await Dt(e,i??""),g=vt(e,{debug:s});let h=await g.import(y,{default:!0,try:!0})||{};typeof h=="function"&&(h=await h(o,t)),r.debug("Using packem config found at",w(e,y));const b=A(JSON.stringify({version:c.version,...c.dependencies,...c.devDependencies,...c.peerDependencies,...c.peerDependenciesMeta,browser:c.browser,eNode:c.engines?.node,exports:c.exports,main:c.main,module:c.module,type:c.type,types:c.types}))+A(JSON.stringify(h));d&&ss(b,d,r);const x=new cs(e,d,b,r),v=await Bs(r,e,t,o,s??!1,l,h,c,p,g);x.isEnabled=v.options.fileCache,v.logger.info(k(Vs(t)+" "+v.options.name)),v.logger.debug({context:v.options.entries,message:`${N("Root dir:")} ${v.options.rootDir}
|
|
114
|
+
${N("Entries:")}}`}),await Ls(v);const T=Date.now(),Q=P(()=>Fe(Math.floor(Date.now()-T)),"getDuration");if(t==="watch"){if(v.options.rollup.watch===!1)throw new Error("Rollup watch is disabled. You should check your packem.config file.");await rs(v,x),st(v,!1);return}t==="jit"?(await Qi(v),await v.hooks.callHook("build:done",v)):(f=await Ci(v,x),await v.hooks.callHook("validate:before",v),_s(v),await v.hooks.callHook("validate:done",v),st(v,f)),v.logger.raw(`
|
|
115
|
+
⚡️ Build run in `+Q());for await(const[be,io]of Object.entries(v.options.builder??{})){v.logger.raw(`
|
|
116
|
+
`),await v.hooks.callHook("builder:before",be,v);const so=Date.now(),ao=P(()=>Fe(Math.floor(Date.now()-so)),"getBuilderDuration");await io(v,d,x,f),await v.hooks.callHook("builder:done",be,v),v.logger.raw(`
|
|
117
|
+
⚡️ `+be+" run in "+ao())}v.logger.restoreAll()}catch(y){throw r.raw(`
|
|
118
|
+
`),Zt(y),y}finally{await Ws(d,r,f)}},"createBundler");var Us=Object.defineProperty,xe=m((e,t)=>Us(e,"name",{value:t,configurable:!0}),"o");const Ks=xe(e=>{e.addCommand({description:"Demonstrate options required",execute:xe(async({logger:t,options:o})=>{let r="build";o.watch?r="watch":o.jit&&(r="jit");const n={};let i;if(ne.NODE_ENV&&[G,C].includes(ne.NODE_ENV)&&(i=ne.NODE_ENV),o.env)for(const s of o.env)if(s.key==="NODE_ENV"){if(i)throw new Error("NODE_ENV was already set, this can't be overridden.");i=s.value}else n["process.env."+s.key]=JSON.stringify(s.value);i===void 0&&(o.production?i=C:o.development&&(i=G));try{await zs(o.dir,r,i,t,{analyze:o.analyze,cjsInterop:o.cjsInterop,clean:o.clean,configPath:o.config??void 0,debug:o.debug,dtsOnly:o.dtsOnly,minify:o.minify===void 0?i===C:o.minify,rollup:{esbuild:{target:o.target},license:{path:o.license},metafile:o.metafile,replace:{values:n}},sourcemap:o.analyze||o.sourcemap,tsconfigPath:o.tsconfig??void 0,validation:o.validation===!1?{packageJson:{bin:!1,dependencies:!1,exports:!1,files:!1,main:!1,module:!1,name:!1,types:!1,typesVersions:!1}}:{},...o.typedoc?{typedoc:{format:"html"}}:{}})}catch(s){t.error(s),mo(1)}},"execute"),name:"build",options:[{defaultValue:".",description:"The directory to build",name:"dir",type:String},{alias:"t",description:"Environments to support. `target` in tsconfig.json is automatically added. Defaults to the current Node.js version.",name:"target"},{description:"Use a custom config file",name:"config",type:String},{description:"Path to the tsconfig.json file",name:"tsconfig",type:String},{description:"Minify the output",name:"minify",type:Boolean},{description:"Generate sourcemaps (experimental)",name:"sourcemap",type:Boolean},{conflicts:"jit",description:"Watch for changes",name:"watch",type:Boolean},{conflicts:"watch",description:"Stub the package for JIT compilation",name:"jit",type:Boolean},{description:"Compile-time environment variables (eg. --env.NODE_ENV=production)",multiple:!0,name:"env",type:xe(t=>{const[o,r]=t.split("=");return{key:o,value:r}},"type")},{defaultValue:!1,description:"Generate meta file (experimental)",name:"metafile",type:Boolean},{description:"Path to the license file",name:"license",type:String},{conflicts:"watch",description:"Visualize and analyze the bundle",name:"analyze",type:Boolean},{description:"CJS interop mode, can export default and named export, (experimental).",name:"cjsInterop",type:Boolean},{conflicts:"development",description:"Run code in production environment",name:"production",type:Boolean},{conflicts:"production",description:"Run code in development environment",name:"development",type:Boolean},{description:"Do not clean the dist directory before building",name:"no-clean",type:Boolean},{description:"Only generate .d.ts files",name:"dts-only",type:Boolean},{description:"Enable or disable the output validation",name:"no-validation",type:Boolean},{description:"Generate type documentation",name:"typedoc",type:Boolean}]})},"createBuildCommand");var Hs=Object.defineProperty,re=m((e,t)=>Hs(e,"name",{value:t,configurable:!0}),"l");const qs=re(e=>{e.addCommand({description:"Initialize packem configuration",execute:re(async({logger:t,options:o})=>{if(Qo("Welcome to packem setup"),S(w(o.dir,"packem.config.ts"))){t.info("Packem project already initialized, you can use `packem build` to build your project");return}const r=w(o.dir,"package.json");if(!S(r))throw new Error("No package.json found in the directory");const n=Et(r),i=[];n.dependencies&&i.push(...Object.keys(n.dependencies)),n.devDependencies&&i.push(...Object.keys(n.devDependencies));const s=!!(n.devDependencies?.typescript??n.dependencies?.typescript);if(o.typescript===void 0&&!s){if(o.typescript=await L({message:"Do you want to install TypeScript?"}),o.typescript){const p=U();p.start("Installing typescript@latest"),await ie("typescript@latest",{cwd:o.dir,dev:!0,silent:!0}),p.stop("")}}else Ve.message("TypeScript version "+(n.devDependencies?.typescript??n.dependencies?.typescript)+" is already installed");if(!S(w(o.dir,"tsconfig.json"))){const p=await L({message:"Do you want to use generate a tsconfig.json?"}),d=await L({message:"Do you want to run your code in the DOM?"});if(p){const f=U();f.start("Generating tsconfig.json"),me(w(o.dir,"tsconfig.json"),{compilerOptions:{esModuleInterop:!0,skipLibCheck:!0,target:"es2022",allowJs:!0,resolveJsonModule:!0,moduleDetection:"force",isolatedModules:!0,verbatimModuleSyntax:!0,strict:!0,noUncheckedIndexedAccess:!0,noImplicitOverride:!0,module:"NodeNext",outDir:"dist",sourceMap:!0,declaration:!0,lib:d?["es2022","dom","dom.iterable"]:["es2022"]}}),f.stop("")}}if(i.includes("esbuild")?o.transformer="esbuild":i.includes("@swc/core")?o.transformer="swc":i.includes("sucrase")&&(o.transformer="sucrase"),o.transformer===void 0){if(o.transformer=await ze({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"}]}),o.transformer&&!i.includes(o.transformer)&&await L({message:"Do you want to install "+o.transformer+"?"})){const p=U();p.start("Installing "+o.transformer),await ie(o.transformer==="swc"?"@swc/core":o.transformer,{cwd:o.dir,dev:!0,silent:!0}),p.stop("")}}else Ve.message("Transformer "+o.transformer+" is already installed.");let a=!0;if(o.isolatedDeclarationTransformer===void 0&&(a=await L({message:"Do you want to use an isolated declaration types?",initialValue:!1})),o.isolatedDeclarationTransformer===void 0&&a&&(o.isolatedDeclarationTransformer=await ze({message:"Pick a isolated declaration transformer",options:[{label:"Typescript",value:"typescript"},{label:"swc",value:"swc"},{label:"OXC",value:"oxc"},{label:"None",value:null}]}),o.isolatedDeclarationTransformer!==null)){let p;switch(o.isolatedDeclarationTransformer){case"typescript":{p="typescript";break}case"swc":{p="@swc/core";break}case"oxc":{p="oxc-transform";break}default:Zo("Invalid isolated declaration transformer")}if(p!==void 0&&!i.includes(p)&&await L({message:"Do you want to install "+p+"?"})){const d=U();d.start("Installing "+o.isolatedDeclarationTransformer),await ie(p,{cwd:o.dir,dev:!0,silent:!0}),d.stop("")}}let l="";s||n.type==="module"?l=`import { defineConfig } from "@visulima/packem/config";
|
|
113
119
|
import transformer from "@visulima/packem/transformer/${o.transformer}";
|
|
114
120
|
${!a||!o.isolatedDeclarationTransformer?"":`import isolatedDeclarationTransformer from "@visulima/packem/dts/isolated/transformer/${o.isolatedDeclarationTransformer}";
|
|
115
121
|
`}
|
|
@@ -125,4 +131,4 @@ module.exports = defineConfig({
|
|
|
125
131
|
transformer${!a||!o.isolatedDeclarationTransformer?"":`,
|
|
126
132
|
isolatedDeclarationTransformer`}
|
|
127
133
|
});
|
|
128
|
-
`;const c=
|
|
134
|
+
`;const c=U(),u=s?"ts":"js";c.start("Creating packem.config."+u),F(w(o.dir,"packem.config."+u),l),c.stop("Created packem.config."+u),er("Now you can run `packem build` to build your project")},"execute"),name:"init",options:[{defaultValue:".",description:"The directory to initialize",name:"dir",type:String},{description:"Choose a transformer",name:"transformer",type:re(t=>{if(typeof t=="string"&&["esbuild","sucrase","swc"].includes(t))return t;throw new Error("Invalid transformer, please choose one of 'swc', 'sucrase' or 'esbuild'")},"type")},{description:"Choose a isolated declaration transformer",name:"isolated-declaration-transformer",type:re(t=>{if(typeof t=="string"&&["none","oxc","swc","typescript"].includes(t))return t;throw new Error("Invalid isolated declaration isolated declaration, please choose one of 'none', 'oxc', 'swc' or 'typescript'")},"type")},{Description:"Use TypeScript",name:"typescript",type:Boolean}]})},"createInitCommand"),ve=new co("packem",{logger:{reporters:[new po({error:{hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0}})],scope:"packem"},packageName:tr,packageVersion:or});qs(ve);Ks(ve);ar(ve);ve.run({shouldExitProcess:!1});
|