@visulima/packem 1.4.1 → 1.5.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 +12 -0
- package/README.md +7 -7
- package/dist/cli.mjs +121 -103
- package/dist/packem.cjs +2 -2
- package/dist/packem.mjs +2 -2
- package/dist/rollup/plugins/css/loaders/postcss/index.cjs +4 -4
- package/dist/rollup/plugins/css/loaders/postcss/index.mjs +4 -4
- package/package.json +2 -5
package/dist/cli.mjs
CHANGED
|
@@ -1,27 +1,45 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
2
|
+
var Gs=Object.defineProperty;var f=(e,t)=>Gs(e,"name",{value:t,configurable:!0});import Hs from"@visulima/cerebro";import{SimpleReporter as Ys}from"@visulima/pail/reporter";import Ve,{cwd as zt,env as Se,versions as Xs,exit as Qs}from"node:process";import{installPackage as Xe}from"@antfu/install-pkg";import{spinner as Qe,select as Z,multiselect as Ut,confirm as U,intro as Zs,log as ft,cancel as eo,outro as to}from"@clack/prompts";import{isAccessible as nt,readFile as rt,writeFile as qt,isAccessibleSync as R,readFileSync as Me,writeFileSync as se,writeJsonSync as Te,readJsonSync as it,walk as so,collectSync as oo,ensureDirSync as no,emptyDir as ro}from"@visulima/fs";import{join as x,resolve as j,normalize as J,relative as I,dirname as B,basename as pe,isAbsolute as Ae,parse as ze,toNamespacedPath as Oe,extname as Kt}from"@visulima/path";import G from"magic-string";import{readdirSync as Gt,existsSync as Ht}from"node:fs";import{stat as Yt,chmod as io,rm as ao}from"node:fs/promises";import mt from"node:module";import{cyan as D,bold as q,gray as X,green as lo,yellow as co,grey as po}from"@visulima/colorize";import{findCacheDirSync as uo}from"@visulima/find-cache-dir";import{formatBytes as Y,duration as gt}from"@visulima/humanizer";import{readTsConfig as fo,findTsConfig as mo}from"@visulima/tsconfig";import go from"browserslist";import{defu as ho}from"defu";import{createHooks as yo}from"hookable";import{createJiti as Xt}from"jiti";import{rollup as Qt,watch as ht,VERSION as vo}from"rollup";import{exec as bo}from"tinyexec";import Zt from"@rollup/plugin-alias";import wo from"@rollup/plugin-commonjs";import $o from"@rollup/plugin-dynamic-import-vars";import{nodeResolve as es}from"@rollup/plugin-node-resolve";import ts from"@rollup/plugin-replace";import{wasm as xo}from"@rollup/plugin-wasm";import{isRelative as ss,resolveAlias as jo}from"@visulima/path/utils";import ko from"rollup-plugin-polyfill-node";import{visualizer as Eo}from"rollup-plugin-visualizer";import{minVersion as os,valid as So,coerce as Oo}from"semver";import De from"node:assert/strict";import{extractAssignedNames as Do,createFilter as ne}from"@rollup/pluginutils";import Co from"glob-parent";import{glob as Po,isDynamicPattern as yt,globSync as No}from"tinyglobby";import{SourceMapConsumer as Io,SourceMapGenerator as _o}from"source-map-js";import{interopDefault as Mo,loadModule as To,findStaticImports as ns,fileURLToPath as Ao,resolveModuleExportNames as Ro,resolvePath as vt}from"mlly";import{fileURLToPath as rs}from"node:url";import{ResolverFactory as Fo}from"oxc-resolver";import{parseAsync as Lo}from"oxc-parser";import Jo from"@rollup/plugin-json";import Bo from"rollup-plugin-license";import{createHash as Wo}from"node:crypto";import{parse as Vo}from"@babel/parser";import zo from"child_process";import{parsePackageJson as is}from"@visulima/package/package-json";import{NotFoundError as Uo}from"@visulima/fs/error";import{distance as qo}from"fastest-levenshtein";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
|
|
9
|
-
`)
|
|
8
|
+
const Ko="@visulima/packem",Go="1.4.2";var Ho=Object.defineProperty,Yo=f((e,t)=>Ho(e,"name",{value:t,configurable:!0}),"t$c");const as=Yo(async(e,t="")=>{let s=t;if(!s){const o=["packem.config.js","packem.config.mjs","packem.config.cjs","packem.config.ts","packem.config.cts","packem.config.mts"];for(const n of o)if(await nt(x(e,n))){s="./"+n;break}}if(!/\.(?:js|mjs|cjs|ts|cts|mts)$/.test(s))throw new Error("Invalid packem config file extension. Only .js, .mjs, .cjs, .ts, .cts and .mts extensions are allowed.");return s},"findPackemFile"),ls={less:["less"],lightningcss:["lightningcss"],"node-sass":["node-sass"],postcss:["postcss","postcss-load-config","postcss-modules-extract-imports","postcss-modules-local-by-default","postcss-modules-scope","postcss-modules-values","postcss-value-parser","icss-utils"],sass:["sass"],"sass-embedded":["sass-embedded"],stylus:["stylus"]};var Xo=Object.defineProperty,bt=f((e,t)=>Xo(e,"name",{value:t,configurable:!0}),"f$f");const Qo=["typedoc","typedoc-plugin-markdown","typedoc-plugin-rename-defaults","@ckeditor/typedoc-plugins"],Zo=bt(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:bt(async({argument:t,logger:s,options:o})=>{const n=Qe(),r=j(zt(),o.dir??".");let i;try{i=await as(r,o.config)}catch{s.error("Could not find a packem config file, please run `packem init` first.");return}const l=await rt(i,{buffer:!1});let c="cjs";l.includes("import")&&(c="esm");const a=new G(l);if(t.includes("typedoc")){if(l.includes("typedoc: typedocBuilder")||l.includes("@visulima/packem/builder/typedoc")){s.warn("Typedoc has already been added to the packem config.");return}c==="cjs"?a.prepend(`const typedocBuilder = require("@visulima/packem/builder/typedoc");
|
|
9
|
+
`):a.prepend(`import typedocBuilder from "@visulima/packem/builder/typedoc";
|
|
10
|
+
`),l.includes("builder: {")?a.replace("builder: {",`builder: {
|
|
10
11
|
typedoc: typedocBuilder,
|
|
11
|
-
`):
|
|
12
|
+
`):a.replace("transformer,",`transformer,
|
|
12
13
|
builder: {
|
|
13
14
|
typedoc: typedocBuilder,
|
|
14
|
-
},`),
|
|
15
|
-
|
|
15
|
+
},`),s.info("Adding typedoc dependencies..."),n.start("Installing packages"),await Xe(Qo,{cwd:r,dev:!0,silent:!0}),n.stop("Installed packages"),s.success(`
|
|
16
|
+
Typedoc added!`)}if(t.includes("css")){if(l.includes("css: {")||l.includes("@visulima/packem/css")){s.warn("Css loaders have already been added to the packem config.");return}const p=[],d=await Z({message:"Pick a css loader",options:[{label:"PostCSS",value:"postcss"},{label:"Lightning CSS",value:"lightningcss"}]});p.push(d);let u=await Ut({message:"Pick extra loaders",options:[{label:"Sass",value:"sass"},{label:"Stylus",value:"stylus"},{label:"Less",value:"less"}],required:!1});if(u.includes("sass")){const y=await Z({message:"Pick a sass loader",options:[{hint:"recommended",label:"Sass embedded",value:"sass-embedded"},{label:"Sass",value:"sass"},{hint:"legacy",label:"Node Sass",value:"node-sass"}]});y!=="sass"&&(u=u.filter(w=>w!=="sass"),u.push(y))}p.push(...u);const m=[];for(const y of p)m.push(...ls[y]);p.push("sourceMap");for(let y of p)(y==="sass-embedded"||y==="node-sass")&&(y="sass"),c==="cjs"?a.prepend(`const ${y}Loader = require("@visulima/packem/css/loader/${y.toLowerCase()}");
|
|
17
|
+
`):a.prepend(`import ${y}Loader from "@visulima/packem/css/loader/${y.toLowerCase()}";
|
|
18
|
+
`);const v=await U({initialValue:!1,message:"Do you want to minify your css?"});let h;v&&(h=await Z({message:"Pick a css minifier",options:[{label:"CSSNano",value:"cssnano"},{label:"Lightning CSS",value:"lightningcss"}]}),p.includes("lightningcss")||m.push(h),c==="cjs"?a.prepend(`const ${h}Minifier = require("@visulima/packem/css/minifier/${h.toLowerCase()}");
|
|
19
|
+
`):a.prepend(`import ${h}Minifier from "@visulima/packem/css/minifier/${h.toLowerCase()}";
|
|
20
|
+
`));const g=p.map(y=>((y==="sass-embedded"||y==="node-sass")&&(y="sass"),`${y}Loader`)).join(", ");if(l.includes("rollup: {"))a.replace("rollup: {",`rollup: {
|
|
21
|
+
css: {${h?`
|
|
22
|
+
minifier: ${h}Minifier,`:""}
|
|
23
|
+
loaders: [${g}],
|
|
24
|
+
},
|
|
25
|
+
`);else{const y=l.includes(" transformer,")?" transformer,":" transformer";a.replace(y,` transformer,
|
|
26
|
+
rollup: {
|
|
27
|
+
css: {${h?`
|
|
28
|
+
minifier: ${h}Minifier,`:""}
|
|
29
|
+
loaders: [${g}],
|
|
30
|
+
},
|
|
31
|
+
},`)}n.start("Installing packages"),await Xe(m,{cwd:r,dev:!0,silent:!0}),n.stop("Installed packages"),s.success(`
|
|
32
|
+
CSS loaders added!`)}await qt(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"),at=[".mjs",".js",".json",".node",".cjs",".ts",".cts",".mts",".tsx",".ctsx",".mtsx",".jsx"],K="production",ye="development",lt=new Set(["react-server","react-native","edge-light"]),Ce=new Set([ye,K,...lt]),le=/node_modules/,oe=/(?:\.d\.[mc]?tsx?|\.\w+)$/,en="packem_chunks",tn="packem_shared",fe=/\.(?:m|c)?(?:j|t)sx?$/;var sn=Object.defineProperty,on=f((e,t)=>sn(e,"name",{value:t,configurable:!0}),"a$n");const Ze=on((e,t)=>e.some(s=>s instanceof RegExp?s.test(t):s===t),"arrayIncludes");var nn=Object.defineProperty,rn=f((e,t)=>nn(e,"name",{value:t,configurable:!0}),"a$m");const he=rn(e=>e==null?[]:Array.isArray(e)?e:[e],"arrayify");var an=Object.defineProperty,ln=f((e,t)=>an(e,"name",{value:t,configurable:!0}),"a$l");const cs=ln((e="")=>{const t=e.split("/");return t[0].startsWith("@")?t[0]+"/"+t[1]:t[0]},"getPackageName");var cn=Object.defineProperty,ps=f((e,t)=>cn(e,"name",{value:t,configurable:!0}),"s$f");const pn=ps((e,t,s)=>{const o=s??new Map;return(...n)=>{const r=t?typeof t=="function"?t(...n):t:JSON.stringify({args:n}),i=o.get(r);if(i!==void 0)return i;const l=e(...n);return o.set(r,l),l}},"memoize"),un=ps(e=>{const t=new Map;return s=>pn(e,s,t)},"memoizeByKey");var dn=Object.defineProperty,ve=f((e,t)=>dn(e,"name",{value:t,configurable:!0}),"r$g");const fn=ve(function*(e){switch(e.declaration?.type){case"ClassDeclaration":case"FunctionDeclaration":{const{id:t}=e.declaration;De(t,"Expected class/function to have a name"),yield t.name;break}case"VariableDeclaration":{for(const t of e.declaration.declarations)for(const s of Do(t.id))yield s;break}}},"exportName"),mn=ve(function*(e){if(e.declaration)for(const t of fn(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"),gn=ve(function*(e){e.exported?yield{exportedName:e.exported.name,from:"self",type:"named"}:yield{from:"other",source:e.source.value,type:"barrel"}},"parseExportAll"),hn=ve(function*(){yield{exportedName:"default",from:"self",type:"named"}},"parseExportDefault"),yn=ve(function*(e,t){De(t.code!=null,`Module ${t.id} doesn't have associated code`);const s=e.parse(t.code);for(const o of s.body)switch(o.type){case"ExportAllDeclaration":{yield*gn(o);break}case"ExportDefaultDeclaration":{yield*hn();break}case"ExportNamedDeclaration":{yield*mn(o);break}}},"parseExports");var vn=Object.defineProperty,be=f((e,t)=>vn(e,"name",{value:t,configurable:!0}),"n$d");const us=be(async function(e,t,s){const o=await e.resolve(t,s.id);if(De(o,`Rollup can't resolve ${t} from ${s.id}`),o.external)return null;const n=await e.load(o);return De(n,`Rollup doesn't have a module for id ${o.id}`),n},"getImportedModule"),bn=be(async function*(e,t,s){const o=await us(e,t.source,s);o&&(yield*ct(e,o))},"gatherBarrelReExports"),wn=be(async function*(e,t,s){const o=await us(e,t.source,s);if(!o)return;const n=new Map(t.bindings.map(r=>[r.importedName,r]));for await(const r of ct(e,o)){const i=n.get(r.exportedName);i&&(yield{...r,exportedName:i.exportedName})}},"gatherNamedReExports"),$n=be(async function*(e,t){yield{exportedName:t.exportedName,id:e.id,sourceName:t.exportedName}},"gatherNamedSelfExports"),ct=be(async function*(e,t){for(const s of yn(e,t))s.from==="self"?yield*$n(t,s):s.type==="barrel"?yield*bn(e,s,t):yield*wn(e,s,t)},"gatherExports");var xn=Object.defineProperty,jn=f((e,t)=>xn(e,"name",{value:t,configurable:!0}),"r$f");const kn=jn(()=>({moduleParsed:{async handler(e){if(e.isEntry)for await(const t of ct(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 En=Object.defineProperty,Sn=f((e,t)=>En(e,"name",{value:t,configurable:!0}),"r$e");const On=Sn((e,t)=>{const s=e,o=[];let n;for(;(n=s.exec(t))!==null;)n.index===s.lastIndex&&s.lastIndex++,n.forEach(r=>{o.push(r)});return o.filter(Boolean)},"getRegexMatches");var Dn=Object.defineProperty,Cn=f((e,t)=>Dn(e,"name",{value:t,configurable:!0}),"a$k");const ds=Cn(e=>{const t=On(/export\s(\{\s(.*)\s\}|default\s.*);/g,e);if(t.length===0)return null;const s=t.at(-1).split(", ");let o="";for(const n of s)if(!n.includes("type")&&(n.includes("default ")&&(o=n.split("default ")[1]),n.includes("as"))){const[r,i]=n.split(" as ");i==="default"&&(o=r)}if(o!==""){const n=new G(e);return n.replace(new RegExp(`(,s)?${o} as default(,)?`),""),n.replace(new RegExp(`export default ${o};
|
|
33
|
+
?`),""),n.append(`
|
|
16
34
|
|
|
17
|
-
export = `+
|
|
18
|
-
module.exports.default = `+i[2]+";");let c=l.toString();return c=c.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+r.fileName+".",prefix:"plugin:cjs-interop"}),{code:c,map:l.generateMap({hires:!0})}}return n.format==="es"&&/\.d\.(?:ts|cts)$/.test(r.fileName)?o!=="commonjs"&&r.fileName.endsWith(".d.mts")?null:co(s):null},"renderChunk")}),"cjsInteropPlugin");var Cr=Object.defineProperty,Pr=m((e,t)=>Cr(e,"name",{value:t,configurable:!0}),"f$c");const Nr=Pr((e,t)=>{const o=new Map,s={copyOnce:!0,exactFileNames:!0,flatten:!1,...e};let{targets:r}=s;return Array.isArray(r)?r=r.map(n=>{if(typeof n=="string")return{src:n};if(typeof n=="object"&&"src"in n)return n}).filter(Boolean):typeof r=="string"&&(r=[{src:r}]),{async buildStart(){const n=await Promise.all(r.flatMap(i=>Array.isArray(i.src)?i.src.map(l=>({...i,src:l})):i).map(async i=>await Es(ye(i.src),{ignore:ye(i.exclude).filter(Boolean)}).then(l=>({dest:i.dest??"",parent:ks(i.src),src:l}))));for(const i of n)for(const l of i.src){let c;o.has(l)?c=o.get(l):(c={copied:[],dest:[],timestamp:0},o.set(l,c));const a=s.flatten?L(i.dest):x(i.dest,I(i.parent,B(l)));c.dest.includes(a)||c.dest.push(a),this.addWatchFile(l)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...o].map(async([i,l])=>{let c;try{const a=await Gt(i);if(!a.isFile())return;const p=a.mtime.getTime();p>l.timestamp&&(l.timestamp=p,l.copied=[]),c=await nt(i,{buffer:!0})}catch(a){t.error({context:[a],message:`error reading file ${i}`,prefix:"plugin:copy"});return}for(const a of l.dest){if(s.copyOnce&&l.copied.includes(a))continue;const p=ue(i),d=x(a,p);try{this.emitFile({[s.exactFileNames?"fileName":"name"]:d,source:c,type:"asset"}),t.debug({message:`copied ${i} → ${d}`,prefix:"plugin:copy"}),l.copied.push(a)}catch(u){t.error({context:[u],message:`error copying file ${i} → ${d}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");function uo(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}m(uo,"getDefaultExportFromCjs");var Ke={exports:{}},$t;function Ir(){return $t||($t=1,function(e){var t=Object.prototype.hasOwnProperty,o="~";function s(){}m(s,"Events"),Object.create&&(s.prototype=Object.create(null),new s().__proto__||(o=!1));function r(c,a,p){this.fn=c,this.context=a,this.once=p||!1}m(r,"EE");function n(c,a,p,d,u){if(typeof p!="function")throw new TypeError("The listener must be a function");var f=new r(p,d||c,u),g=o?o+a:a;return c._events[g]?c._events[g].fn?c._events[g]=[c._events[g],f]:c._events[g].push(f):(c._events[g]=f,c._eventsCount++),c}m(n,"addListener");function i(c,a){--c._eventsCount===0?c._events=new s:delete c._events[a]}m(i,"clearEvent");function l(){this._events=new s,this._eventsCount=0}m(l,"EventEmitter"),l.prototype.eventNames=m(function(){var a=[],p,d;if(this._eventsCount===0)return a;for(d in p=this._events)t.call(p,d)&&a.push(o?d.slice(1):d);return Object.getOwnPropertySymbols?a.concat(Object.getOwnPropertySymbols(p)):a},"eventNames"),l.prototype.listeners=m(function(a){var p=o?o+a:a,d=this._events[p];if(!d)return[];if(d.fn)return[d.fn];for(var u=0,f=d.length,g=new Array(f);u<f;u++)g[u]=d[u].fn;return g},"listeners"),l.prototype.listenerCount=m(function(a){var p=o?o+a:a,d=this._events[p];return d?d.fn?1:d.length:0},"listenerCount"),l.prototype.emit=m(function(a,p,d,u,f,g){var y=o?o+a:a;if(!this._events[y])return!1;var h=this._events[y],v=arguments.length,w,$;if(h.fn){switch(h.once&&this.removeListener(a,h.fn,void 0,!0),v){case 1:return h.fn.call(h.context),!0;case 2:return h.fn.call(h.context,p),!0;case 3:return h.fn.call(h.context,p,d),!0;case 4:return h.fn.call(h.context,p,d,u),!0;case 5:return h.fn.call(h.context,p,d,u,f),!0;case 6:return h.fn.call(h.context,p,d,u,f,g),!0}for($=1,w=new Array(v-1);$<v;$++)w[$-1]=arguments[$];h.fn.apply(h.context,w)}else{var E=h.length,b;for($=0;$<E;$++)switch(h[$].once&&this.removeListener(a,h[$].fn,void 0,!0),v){case 1:h[$].fn.call(h[$].context);break;case 2:h[$].fn.call(h[$].context,p);break;case 3:h[$].fn.call(h[$].context,p,d);break;case 4:h[$].fn.call(h[$].context,p,d,u);break;default:if(!w)for(b=1,w=new Array(v-1);b<v;b++)w[b-1]=arguments[b];h[$].fn.apply(h[$].context,w)}}return!0},"emit"),l.prototype.on=m(function(a,p,d){return n(this,a,p,d,!1)},"on"),l.prototype.once=m(function(a,p,d){return n(this,a,p,d,!0)},"once"),l.prototype.removeListener=m(function(a,p,d,u){var f=o?o+a:a;if(!this._events[f])return this;if(!p)return i(this,f),this;var g=this._events[f];if(g.fn)g.fn===p&&(!u||g.once)&&(!d||g.context===d)&&i(this,f);else{for(var y=0,h=[],v=g.length;y<v;y++)(g[y].fn!==p||u&&!g[y].once||d&&g[y].context!==d)&&h.push(g[y]);h.length?this._events[f]=h.length===1?h[0]:h:i(this,f)}return this},"removeListener"),l.prototype.removeAllListeners=m(function(a){var p;return a?(p=o?o+a:a,this._events[p]&&i(this,p)):(this._events=new s,this._eventsCount=0),this},"removeAllListeners"),l.prototype.off=l.prototype.removeListener,l.prototype.addListener=l.prototype.on,l.prefixed=o,l.EventEmitter=l,e.exports=l}(Ke)),Ke.exports}m(Ir,"requireEventemitter3");var _r=Ir();const Tr=uo(_r);class fo extends Error{static{m(this,"TimeoutError")}constructor(t){super(t),this.name="TimeoutError"}}class Mr extends Error{static{m(this,"AbortError")}constructor(t){super(),this.name="AbortError",this.message=t}}const xt=m(e=>globalThis.DOMException===void 0?new Mr(e):new DOMException(e),"getDOMException"),jt=m(e=>{const t=e.reason===void 0?xt("This operation was aborted."):e.reason;return t instanceof Error?t:xt(t)},"getAbortedReason");function Ar(e,t){const{milliseconds:o,fallback:s,message:r,customTimers:n={setTimeout,clearTimeout}}=t;let i;const c=new Promise((a,p)=>{if(typeof o!="number"||Math.sign(o)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${o}\``);if(t.signal){const{signal:u}=t;u.aborted&&p(jt(u));const f=m(()=>{p(jt(u))},"abortHandler");u.addEventListener("abort",f,{once:!0}),e.finally(()=>{u.removeEventListener("abort",f)})}if(o===Number.POSITIVE_INFINITY){e.then(a,p);return}const d=new fo;i=n.setTimeout.call(void 0,()=>{if(s){try{a(s())}catch(u){p(u)}return}typeof e.cancel=="function"&&e.cancel(),r===!1?a():r instanceof Error?p(r):(d.message=r??`Promise timed out after ${o} milliseconds`,p(d))},o),(async()=>{try{a(await e)}catch(u){p(u)}})()}).finally(()=>{c.clear()});return c.clear=()=>{n.clearTimeout.call(void 0,i),i=void 0},c}m(Ar,"pTimeout");function Rr(e,t,o){let s=0,r=e.length;for(;r>0;){const n=Math.trunc(r/2);let i=s+n;o(e[i],t)<=0?(s=++i,r-=n+1):r=n}return s}m(Rr,"lowerBound");class Fr{static{m(this,"PriorityQueue")}#e=[];enqueue(t,o){o={priority:0,...o};const s={priority:o.priority,run:t};if(this.size&&this.#e[this.size-1].priority>=o.priority){this.#e.push(s);return}const r=Rr(this.#e,s,(n,i)=>i.priority-n.priority);this.#e.splice(r,0,s)}dequeue(){return this.#e.shift()?.run}filter(t){return this.#e.filter(o=>o.priority===t.priority).map(o=>o.run)}get size(){return this.#e.length}}class Jr extends Tr{static{m(this,"PQueue")}#e;#o;#n=0;#a;#i;#m=0;#s;#c;#t;#g;#r=0;#p;#l;#h;timeout;constructor(t){if(super(),t={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:Fr,...t},!(typeof t.intervalCap=="number"&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${t.intervalCap?.toString()??""}\` (${typeof t.intervalCap})`);if(t.interval===void 0||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${t.interval?.toString()??""}\` (${typeof t.interval})`);this.#e=t.carryoverConcurrencyCount,this.#o=t.intervalCap===Number.POSITIVE_INFINITY||t.interval===0,this.#a=t.intervalCap,this.#i=t.interval,this.#t=new t.queueClass,this.#g=t.queueClass,this.concurrency=t.concurrency,this.timeout=t.timeout,this.#h=t.throwOnTimeout===!0,this.#l=t.autoStart===!1}get#b(){return this.#o||this.#n<this.#a}get#w(){return this.#r<this.#p}#$(){this.#r--,this.#u(),this.emit("next")}#x(){this.#v(),this.#y(),this.#c=void 0}get#j(){const t=Date.now();if(this.#s===void 0){const o=this.#m-t;if(o<0)this.#n=this.#e?this.#r:0;else return this.#c===void 0&&(this.#c=setTimeout(()=>{this.#x()},o)),!0}return!1}#u(){if(this.#t.size===0)return this.#s&&clearInterval(this.#s),this.#s=void 0,this.emit("empty"),this.#r===0&&this.emit("idle"),!1;if(!this.#l){const t=!this.#j;if(this.#b&&this.#w){const o=this.#t.dequeue();return o?(this.emit("active"),o(),t&&this.#y(),!0):!1}}return!1}#y(){this.#o||this.#s!==void 0||(this.#s=setInterval(()=>{this.#v()},this.#i),this.#m=Date.now()+this.#i)}#v(){this.#n===0&&this.#r===0&&this.#s&&(clearInterval(this.#s),this.#s=void 0),this.#n=this.#e?this.#r:0,this.#d()}#d(){for(;this.#u(););}get concurrency(){return this.#p}set concurrency(t){if(!(typeof t=="number"&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);this.#p=t,this.#d()}async#k(t){return new Promise((o,s)=>{t.addEventListener("abort",()=>{s(t.reason)},{once:!0})})}async add(t,o={}){return o={timeout:this.timeout,throwOnTimeout:this.#h,...o},new Promise((s,r)=>{this.#t.enqueue(async()=>{this.#r++,this.#n++;try{o.signal?.throwIfAborted();let n=t({signal:o.signal});o.timeout&&(n=Ar(Promise.resolve(n),{milliseconds:o.timeout})),o.signal&&(n=Promise.race([n,this.#k(o.signal)]));const i=await n;s(i),this.emit("completed",i)}catch(n){if(n instanceof fo&&!o.throwOnTimeout){s();return}r(n),this.emit("error",n)}finally{this.#$()}},o),this.emit("add"),this.#u()})}async addAll(t,o){return Promise.all(t.map(async s=>this.add(s,o)))}start(){return this.#l?(this.#l=!1,this.#d(),this):this}pause(){this.#l=!0}clear(){this.#t=new this.#g}async onEmpty(){this.#t.size!==0&&await this.#f("empty")}async onSizeLessThan(t){this.#t.size<t||await this.#f("next",()=>this.#t.size<t)}async onIdle(){this.#r===0&&this.#t.size===0||await this.#f("idle")}async#f(t,o){return new Promise(s=>{const r=m(()=>{o&&!o()||(this.off(t,r),s())},"listener");this.on(t,r)})}get size(){return this.#t.size}sizeBy(t){return this.#t.filter(t).length}get pending(){return this.#r}get isPaused(){return this.#l}}var Lr=Object.defineProperty,Br=m((e,t)=>Lr(e,"name",{value:t,configurable:!0}),"r$d");const kt=Br((e,t)=>{if(!t)return!1;if(typeof t=="function")return t(e);if(typeof t.test=="function")return t.test(e);throw new Error("Invalid condition type")},"matchFile");var Wr=Object.defineProperty,zr=m((e,t)=>Wr(e,"name",{value:t,configurable:!0}),"a$j");const Vr=4,Ur=process.env.UV_THREADPOOL_SIZE?Number.parseInt(process.env.UV_THREADPOOL_SIZE,10):Vr;let qr=class{static{m(this,"f")}static{zr(this,"LoaderManager")}test;loaders=new Map;options;workQueue;logger;constructor({extensions:t,loaders:o,logger:s,options:r}){this.test=n=>t.some(i=>n.toLowerCase().endsWith(i)),o.length>0&&this.add(...o),this.options=r,this.logger=s}add(...t){for(const o of t)this.loaders.has(o.name)||this.loaders.set(o.name,o)}isSupported(t){if(this.test(t))return!0;for(const[,o]of this.loaders)if(kt(t,o.test))return!0;return!1}async process(t,o){this.workQueue||(this.workQueue=new Jr({concurrency:Ur-1}));for await(const[s,r]of this.loaders){const n={...o,options:this.options[s]??{}};if(r.alwaysProcess||kt(n.id,r.test)){this.logger.debug(`Processing ${s} loader for ${n.id}`);const i=await this.workQueue.add(r.process.bind(n,t));i&&(t=i)}}return t}};const Kr=/data:[^\n\r;]+(?:;charset=[^\n\r;]+)?;base64,([\d+/A-Za-z]+={0,2})/;var Gr=Object.defineProperty,Je=m((e,t)=>Gr(e,"name",{value:t,configurable:!0}),"i$b");const mo=/(?:\n|\r\n)?\/\*[#*@]+\s*sourceMappingURL\s*=\s*(\S+)\s*\*+\//g,go=/(?:\n|\r\n)?\/\/[#@]+\s*sourceMappingURL\s*=\s*(\S+)\s*?$/gm;let Hr=class{static{m(this,"S")}static{Je(this,"MapModifier")}map;constructor(t){if(typeof t=="string")try{this.map=JSON.parse(t)}catch{}else this.map=t}modify(t){return this.map?(t(this.map),this):this}modifySources(t){return this.map?(this.map.sources&&(this.map.sources=this.map.sources.map(o=>t(o))),this):this}resolve(t=process.cwd()){return this.modifySources(o=>o==="<no source>"?o:k(t,o))}relative(t=process.cwd()){return this.modifySources(o=>o==="<no source>"?o:Fe(o)?I(t,o):L(o))}toObject(){return this.map}toString(){return this.map?JSON.stringify(this.map):this.map}toConsumer(){return this.map?new Os(this.map):this.map}toCommentData(){const t=this.toString();return t?`
|
|
35
|
+
export = `+o+";"),{code:n.toString().replace(/export\s\{\s\s\};/,""),map:n.generateMap({hires:!0})}}return null},"patchCjsDefaultExport");var Pn=Object.defineProperty,wt=f((e,t)=>Pn(e,"name",{value:t,configurable:!0}),"i$c");const fs=wt(({addDefaultProperty:e=!1,logger:t,type:s})=>({name:"packem:cjs-interop",renderChunk:wt(async(o,n,r)=>{if(n.type!=="chunk"||!n.isEntry)return null;if(r.format==="cjs"&&r.exports==="auto"){const i=/(exports(?:\['default'\]|\.default)) = (.*);/i.exec(o);if(i===null||i.length<3)return null;const l=new G(o);l.replace("Object.defineProperty(exports, '__esModule', { value: true });",""),l.replaceAll(/exports\.(.*) = (.*);/g,"module.exports.$1 = $2;"),e&&l.append(`
|
|
36
|
+
module.exports.default = `+i[2]+";");let c=l.toString();return c=c.replace(/(?:module\.)?exports(?:\['default'\]|\.default)/i,"module.exports"),t.debug({message:"Applied CommonJS interop to entry chunk "+n.fileName+".",prefix:"plugin:cjs-interop"}),{code:c,map:l.generateMap({hires:!0})}}return r.format==="es"&&/\.d\.(?:ts|cts)$/.test(n.fileName)?s!=="commonjs"&&n.fileName.endsWith(".d.mts")?null:ds(o):null},"renderChunk")}),"cjsInteropPlugin");var Nn=Object.defineProperty,In=f((e,t)=>Nn(e,"name",{value:t,configurable:!0}),"f$c");const _n=In((e,t)=>{const s=new Map,o={copyOnce:!0,exactFileNames:!0,flatten:!1,...e};let{targets:n}=o;return Array.isArray(n)?n=n.map(r=>{if(typeof r=="string")return{src:r};if(typeof r=="object"&&"src"in r)return r}).filter(Boolean):typeof n=="string"&&(n=[{src:n}]),{async buildStart(){const r=await Promise.all(n.flatMap(i=>Array.isArray(i.src)?i.src.map(l=>({...i,src:l})):i).map(async i=>await Po(he(i.src),{ignore:he(i.exclude).filter(Boolean)}).then(l=>({dest:i.dest??"",parent:Co(i.src),src:l}))));for(const i of r)for(const l of i.src){let c;s.has(l)?c=s.get(l):(c={copied:[],dest:[],timestamp:0},s.set(l,c));const a=o.flatten?J(i.dest):x(i.dest,I(i.parent,B(l)));c.dest.includes(a)||c.dest.push(a),this.addWatchFile(l)}t.info({message:"Copying files...",prefix:"plugin:copy"}),await Promise.all([...s].map(async([i,l])=>{let c;try{const a=await Yt(i);if(!a.isFile())return;const p=a.mtime.getTime();p>l.timestamp&&(l.timestamp=p,l.copied=[]),c=await rt(i,{buffer:!0})}catch(a){t.error({context:[a],message:`error reading file ${i}`,prefix:"plugin:copy"});return}for(const a of l.dest){if(o.copyOnce&&l.copied.includes(a))continue;const p=pe(i),d=x(a,p);try{this.emitFile({[o.exactFileNames?"fileName":"name"]:d,source:c,type:"asset"}),t.debug({message:`copied ${i} → ${d}`,prefix:"plugin:copy"}),l.copied.push(a)}catch(u){t.error({context:[u],message:`error copying file ${i} → ${d}`,prefix:"plugin:copy"})}}}))},name:"packem:copy"}},"copyPlugin");function ms(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}f(ms,"getDefaultExportFromCjs");var Ue={exports:{}},$t;function Mn(){return $t||($t=1,function(e){var t=Object.prototype.hasOwnProperty,s="~";function o(){}f(o,"Events"),Object.create&&(o.prototype=Object.create(null),new o().__proto__||(s=!1));function n(c,a,p){this.fn=c,this.context=a,this.once=p||!1}f(n,"EE");function r(c,a,p,d,u){if(typeof p!="function")throw new TypeError("The listener must be a function");var m=new n(p,d||c,u),v=s?s+a:a;return c._events[v]?c._events[v].fn?c._events[v]=[c._events[v],m]:c._events[v].push(m):(c._events[v]=m,c._eventsCount++),c}f(r,"addListener");function i(c,a){--c._eventsCount===0?c._events=new o:delete c._events[a]}f(i,"clearEvent");function l(){this._events=new o,this._eventsCount=0}f(l,"EventEmitter"),l.prototype.eventNames=f(function(){var a=[],p,d;if(this._eventsCount===0)return a;for(d in p=this._events)t.call(p,d)&&a.push(s?d.slice(1):d);return Object.getOwnPropertySymbols?a.concat(Object.getOwnPropertySymbols(p)):a},"eventNames"),l.prototype.listeners=f(function(a){var p=s?s+a:a,d=this._events[p];if(!d)return[];if(d.fn)return[d.fn];for(var u=0,m=d.length,v=new Array(m);u<m;u++)v[u]=d[u].fn;return v},"listeners"),l.prototype.listenerCount=f(function(a){var p=s?s+a:a,d=this._events[p];return d?d.fn?1:d.length:0},"listenerCount"),l.prototype.emit=f(function(a,p,d,u,m,v){var h=s?s+a:a;if(!this._events[h])return!1;var g=this._events[h],y=arguments.length,w,$;if(g.fn){switch(g.once&&this.removeListener(a,g.fn,void 0,!0),y){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,p),!0;case 3:return g.fn.call(g.context,p,d),!0;case 4:return g.fn.call(g.context,p,d,u),!0;case 5:return g.fn.call(g.context,p,d,u,m),!0;case 6:return g.fn.call(g.context,p,d,u,m,v),!0}for($=1,w=new Array(y-1);$<y;$++)w[$-1]=arguments[$];g.fn.apply(g.context,w)}else{var E=g.length,b;for($=0;$<E;$++)switch(g[$].once&&this.removeListener(a,g[$].fn,void 0,!0),y){case 1:g[$].fn.call(g[$].context);break;case 2:g[$].fn.call(g[$].context,p);break;case 3:g[$].fn.call(g[$].context,p,d);break;case 4:g[$].fn.call(g[$].context,p,d,u);break;default:if(!w)for(b=1,w=new Array(y-1);b<y;b++)w[b-1]=arguments[b];g[$].fn.apply(g[$].context,w)}}return!0},"emit"),l.prototype.on=f(function(a,p,d){return r(this,a,p,d,!1)},"on"),l.prototype.once=f(function(a,p,d){return r(this,a,p,d,!0)},"once"),l.prototype.removeListener=f(function(a,p,d,u){var m=s?s+a:a;if(!this._events[m])return this;if(!p)return i(this,m),this;var v=this._events[m];if(v.fn)v.fn===p&&(!u||v.once)&&(!d||v.context===d)&&i(this,m);else{for(var h=0,g=[],y=v.length;h<y;h++)(v[h].fn!==p||u&&!v[h].once||d&&v[h].context!==d)&&g.push(v[h]);g.length?this._events[m]=g.length===1?g[0]:g:i(this,m)}return this},"removeListener"),l.prototype.removeAllListeners=f(function(a){var p;return a?(p=s?s+a:a,this._events[p]&&i(this,p)):(this._events=new o,this._eventsCount=0),this},"removeAllListeners"),l.prototype.off=l.prototype.removeListener,l.prototype.addListener=l.prototype.on,l.prefixed=s,l.EventEmitter=l,e.exports=l}(Ue)),Ue.exports}f(Mn,"requireEventemitter3");var Tn=Mn();const An=ms(Tn);class gs extends Error{static{f(this,"TimeoutError")}constructor(t){super(t),this.name="TimeoutError"}}class Rn extends Error{static{f(this,"AbortError")}constructor(t){super(),this.name="AbortError",this.message=t}}const xt=f(e=>globalThis.DOMException===void 0?new Rn(e):new DOMException(e),"getDOMException"),jt=f(e=>{const t=e.reason===void 0?xt("This operation was aborted."):e.reason;return t instanceof Error?t:xt(t)},"getAbortedReason");function Fn(e,t){const{milliseconds:s,fallback:o,message:n,customTimers:r={setTimeout,clearTimeout}}=t;let i;const c=new Promise((a,p)=>{if(typeof s!="number"||Math.sign(s)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${s}\``);if(t.signal){const{signal:u}=t;u.aborted&&p(jt(u));const m=f(()=>{p(jt(u))},"abortHandler");u.addEventListener("abort",m,{once:!0}),e.finally(()=>{u.removeEventListener("abort",m)})}if(s===Number.POSITIVE_INFINITY){e.then(a,p);return}const d=new gs;i=r.setTimeout.call(void 0,()=>{if(o){try{a(o())}catch(u){p(u)}return}typeof e.cancel=="function"&&e.cancel(),n===!1?a():n instanceof Error?p(n):(d.message=n??`Promise timed out after ${s} milliseconds`,p(d))},s),(async()=>{try{a(await e)}catch(u){p(u)}})()}).finally(()=>{c.clear()});return c.clear=()=>{r.clearTimeout.call(void 0,i),i=void 0},c}f(Fn,"pTimeout");function Ln(e,t,s){let o=0,n=e.length;for(;n>0;){const r=Math.trunc(n/2);let i=o+r;s(e[i],t)<=0?(o=++i,n-=r+1):n=r}return o}f(Ln,"lowerBound");class Jn{static{f(this,"PriorityQueue")}#e=[];enqueue(t,s){s={priority:0,...s};const o={priority:s.priority,run:t};if(this.size&&this.#e[this.size-1].priority>=s.priority){this.#e.push(o);return}const n=Ln(this.#e,o,(r,i)=>i.priority-r.priority);this.#e.splice(n,0,o)}dequeue(){return this.#e.shift()?.run}filter(t){return this.#e.filter(s=>s.priority===t.priority).map(s=>s.run)}get size(){return this.#e.length}}class Bn extends An{static{f(this,"PQueue")}#e;#s;#r=0;#a;#i;#m=0;#o;#c;#t;#g;#n=0;#p;#l;#h;timeout;constructor(t){if(super(),t={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:Jn,...t},!(typeof t.intervalCap=="number"&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${t.intervalCap?.toString()??""}\` (${typeof t.intervalCap})`);if(t.interval===void 0||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${t.interval?.toString()??""}\` (${typeof t.interval})`);this.#e=t.carryoverConcurrencyCount,this.#s=t.intervalCap===Number.POSITIVE_INFINITY||t.interval===0,this.#a=t.intervalCap,this.#i=t.interval,this.#t=new t.queueClass,this.#g=t.queueClass,this.concurrency=t.concurrency,this.timeout=t.timeout,this.#h=t.throwOnTimeout===!0,this.#l=t.autoStart===!1}get#b(){return this.#s||this.#r<this.#a}get#w(){return this.#n<this.#p}#$(){this.#n--,this.#u(),this.emit("next")}#x(){this.#v(),this.#y(),this.#c=void 0}get#j(){const t=Date.now();if(this.#o===void 0){const s=this.#m-t;if(s<0)this.#r=this.#e?this.#n:0;else return this.#c===void 0&&(this.#c=setTimeout(()=>{this.#x()},s)),!0}return!1}#u(){if(this.#t.size===0)return this.#o&&clearInterval(this.#o),this.#o=void 0,this.emit("empty"),this.#n===0&&this.emit("idle"),!1;if(!this.#l){const t=!this.#j;if(this.#b&&this.#w){const s=this.#t.dequeue();return s?(this.emit("active"),s(),t&&this.#y(),!0):!1}}return!1}#y(){this.#s||this.#o!==void 0||(this.#o=setInterval(()=>{this.#v()},this.#i),this.#m=Date.now()+this.#i)}#v(){this.#r===0&&this.#n===0&&this.#o&&(clearInterval(this.#o),this.#o=void 0),this.#r=this.#e?this.#n:0,this.#d()}#d(){for(;this.#u(););}get concurrency(){return this.#p}set concurrency(t){if(!(typeof t=="number"&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);this.#p=t,this.#d()}async#k(t){return new Promise((s,o)=>{t.addEventListener("abort",()=>{o(t.reason)},{once:!0})})}async add(t,s={}){return s={timeout:this.timeout,throwOnTimeout:this.#h,...s},new Promise((o,n)=>{this.#t.enqueue(async()=>{this.#n++,this.#r++;try{s.signal?.throwIfAborted();let r=t({signal:s.signal});s.timeout&&(r=Fn(Promise.resolve(r),{milliseconds:s.timeout})),s.signal&&(r=Promise.race([r,this.#k(s.signal)]));const i=await r;o(i),this.emit("completed",i)}catch(r){if(r instanceof gs&&!s.throwOnTimeout){o();return}n(r),this.emit("error",r)}finally{this.#$()}},s),this.emit("add"),this.#u()})}async addAll(t,s){return Promise.all(t.map(async o=>this.add(o,s)))}start(){return this.#l?(this.#l=!1,this.#d(),this):this}pause(){this.#l=!0}clear(){this.#t=new this.#g}async onEmpty(){this.#t.size!==0&&await this.#f("empty")}async onSizeLessThan(t){this.#t.size<t||await this.#f("next",()=>this.#t.size<t)}async onIdle(){this.#n===0&&this.#t.size===0||await this.#f("idle")}async#f(t,s){return new Promise(o=>{const n=f(()=>{s&&!s()||(this.off(t,n),o())},"listener");this.on(t,n)})}get size(){return this.#t.size}sizeBy(t){return this.#t.filter(t).length}get pending(){return this.#n}get isPaused(){return this.#l}}var Wn=Object.defineProperty,Vn=f((e,t)=>Wn(e,"name",{value:t,configurable:!0}),"r$d");const kt=Vn((e,t)=>{if(!t)return!1;if(typeof t=="function")return t(e);if(typeof t.test=="function")return t.test(e);throw new Error("Invalid condition type")},"matchFile");var zn=Object.defineProperty,Un=f((e,t)=>zn(e,"name",{value:t,configurable:!0}),"a$j");const qn=4,Kn=process.env.UV_THREADPOOL_SIZE?Number.parseInt(process.env.UV_THREADPOOL_SIZE,10):qn;let Gn=class{static{f(this,"f")}static{Un(this,"LoaderManager")}test;loaders=new Map;options;workQueue;logger;constructor({extensions:t,loaders:s,logger:o,options:n}){this.test=r=>t.some(i=>r.toLowerCase().endsWith(i)),s.length>0&&this.add(...s),this.options=n,this.logger=o}add(...t){for(const s of t)this.loaders.has(s.name)||this.loaders.set(s.name,s)}isSupported(t){if(this.test(t))return!0;for(const[,s]of this.loaders)if(kt(t,s.test))return!0;return!1}async process(t,s){this.workQueue||(this.workQueue=new Bn({concurrency:Kn-1}));for await(const[o,n]of this.loaders){const r={...s,options:this.options[o]??{}};if(n.alwaysProcess||kt(r.id,n.test)){this.logger.debug(`Processing ${o} loader for ${r.id}`);const i=await this.workQueue.add(n.process.bind(r,t));i&&(t=i)}}return t}};const Hn=/data:[^\n\r;]+(?:;charset=[^\n\r;]+)?;base64,([\d+/A-Za-z]+={0,2})/;var Yn=Object.defineProperty,Re=f((e,t)=>Yn(e,"name",{value:t,configurable:!0}),"i$b");const hs=/(?:\n|\r\n)?\/\*[#*@]+\s*sourceMappingURL\s*=\s*(\S+)\s*\*+\//g,ys=/(?:\n|\r\n)?\/\/[#@]+\s*sourceMappingURL\s*=\s*(\S+)\s*?$/gm;let Xn=class{static{f(this,"S")}static{Re(this,"MapModifier")}map;constructor(t){if(typeof t=="string")try{this.map=JSON.parse(t)}catch{}else this.map=t}modify(t){return this.map?(t(this.map),this):this}modifySources(t){return this.map?(this.map.sources&&(this.map.sources=this.map.sources.map(s=>t(s))),this):this}resolve(t=process.cwd()){return this.modifySources(s=>s==="<no source>"?s:j(t,s))}relative(t=process.cwd()){return this.modifySources(s=>s==="<no source>"?s:Ae(s)?I(t,s):J(s))}toObject(){return this.map}toString(){return this.map?JSON.stringify(this.map):this.map}toConsumer(){return this.map?new Io(this.map):this.map}toCommentData(){const t=this.toString();return t?`
|
|
19
37
|
/*# sourceMappingURL=data:application/json;base64,${Buffer.from(t).toString("base64")} */`:""}toCommentFile(t){return this.map?`
|
|
20
|
-
/*# sourceMappingURL=${t} */`:""}};
|
|
21
|
-
`).length}}return{css:
|
|
22
|
-
`),map:t}},"concat");var
|
|
23
|
-
`)),
|
|
24
|
-
`));const
|
|
38
|
+
/*# sourceMappingURL=${t} */`:""}};Re(async(e,t)=>{const[,s]=hs.exec(e)??ys.exec(e)??[];if(!s)return;const[,o]=Hn.exec(s)??[];if(o)return Buffer.from(o,"base64").toString();if(!t)throw new Error("Extracted map detected, but no ID is provided");const n=j(B(t),s);if(R(n))return Me(n)},"getMap");Re(e=>e.replaceAll(hs,"").replaceAll(ys,""),"stripMap");const et=Re(e=>new Xn(e),"mm");var Qn=Object.defineProperty,Zn=f((e,t)=>Qn(e,"name",{value:t,configurable:!0}),"u$c");const er=Zn(async e=>{const t=new _o({file:""}),s=[];let o=0;for await(const{css:n,map:r}of e){s.push(n);const i=et(r),l=i.toObject();if(!l)continue;const c=i.toConsumer();if(c){if(c.eachMapping(a=>{t.addMapping({generated:{column:a.generatedColumn,line:o+a.generatedLine},name:a.name,original:{column:a.originalColumn,line:a.originalLine},source:a.source})}),l.sourcesContent)for(const a of l.sources)t.setSourceContent(a,c.sourceContentFor(a,!0));o+=n.split(`
|
|
39
|
+
`).length}}return{css:s.join(`
|
|
40
|
+
`),map:t}},"concat");var tr=Object.defineProperty,sr=f((e,t)=>tr(e,"name",{value:t,configurable:!0}),"s$c");const vs=sr(e=>e.map((t,s,o)=>{const n=`\`${t}\``;switch(s){case o.length-1:return`or ${n}`;case o.length-2:return n;default:return`${n},`}}).join(" "),"default");var or=Object.defineProperty,nr=f((e,t)=>or(e,"name",{value:t,configurable:!0}),"l$9");const rr=B(rs(import.meta.url)),Et=nr((e,t)=>{const s={baseDirs:[rr],caller:"Resolver",extensions:[".mjs",".js",".cjs",".json"],symlinks:!0,...t},o=new Fo({extensions:s.extensions,symlinks:s.symlinks});for(const n of s.baseDirs)for(const r of e)try{const{error:i,path:l}=o.sync(n,r);if(l)return l;i&&console.debug(i,{context:{basedir:n,caller:t.caller,extensions:t.extensions,id:r}})}catch(i){console.debug(i.message,{context:{basedir:n,caller:t.caller,error:i,extensions:t.extensions,id:r}})}throw new Error(`${s.caller} could not resolve ${vs(e)}`)},"resolve");var ir=Object.defineProperty,ar=f((e,t)=>ir(e,"name",{value:t,configurable:!0}),"t$b");const te={},lr=[".js",".mjs",".cjs",".json"],cr=ar(async(e,t)=>{if(te[e])return te[e];if(te[e]===null)return;const s={baseDirs:[t],caller:"Module loader",extensions:lr,symlinks:!1};try{te[e]=require(Et([e,`./${e}`],s))}catch(o){if(o.code==="ERR_REQUIRE_ESM")try{te[e]=Mo(await To(Et([e,`./${e}`],s)))}catch{}else{te[e]=null;return}}return te[e]},"default");var pr=Object.defineProperty,ue=f((e,t)=>pr(e,"name",{value:t,configurable:!0}),"r$c");const bs=["inject","extract","emit"],ur=vs(bs),dr=ue(e=>{const t=Array.isArray(e)?e:[e];if(t[0]&&!bs.includes(t[0]))throw new Error(`Incorrect mode provided, allowed modes are ${ur}`);return{emit:t[0]==="emit",extract:t[0]==="extract"&&(t[1]??!0),inject:(!t[0]||t[0]==="inject")&&(t[1]??!0)}},"inferModeOption"),tt=ue((e,t)=>typeof e=="boolean"?e&&{}:typeof e=="object"?e:t,"inferOption"),fr=ue(e=>{const t=Array.isArray(e)?e:[e];return t[0]?{content:!0,...t[1],inline:t[0]==="inline"}:!1},"inferSourceMapOption"),St=ue((e,t)=>{const s=tt(e,{});return t&&typeof s=="object"&&!s.alias&&(s.alias=t),s},"inferHandlerOption"),ce=ue(async(e,t,s)=>{if(typeof e!="string")return e;const o=await cr(e,s);if(!o)throw new Error(`Unable to load PostCSS ${t} \`${e}\``);return o},"ensurePCSSOption"),mr=ue(async(e,t)=>{if(e===void 0)return[];if(e.length===0)return[];const s=[];for await(const o of e.filter(Boolean)){if(!Array.isArray(o)){s.push(await ce(o,"plugin",t));continue}const[n,r]=o;r?s.push((await ce(n,"plugin",t))(r)):s.push(await ce(n,"plugin",t))}return s},"ensurePCSSPlugins");var gr=Object.defineProperty,ge=f((e,t)=>gr(e,"name",{value:t,configurable:!0}),"b$3");const hr=ge(async(e,t)=>e.sort((s,o)=>t.indexOf(s.name)-t.indexOf(o.name)),"sortByNameOrder"),yr=ge(async(e,t,s,o,n,r,i,l,c,a)=>{const p={...a,...e.alias},d=ne(e.include,e.exclude),u=fr(e.sourceMap),m={...dr(e.mode),autoModules:e.autoModules??!1,dts:e.dts,extensions:e.extensions,namedExports:e.namedExports};typeof m.inject=="object"&&m.inject.treeshakeable&&(m.namedExports=!1,t.info({message:"Disabling named exports due to `inject.treeshakeable` option",prefix:"css"}));let v=!1;if(e.loaders)for(const w of e.loaders)w.name==="postcss"&&(v=!0);else e.loaders=[];v&&(m.postcss={...e.postcss,config:tt(e.postcss?.config,{}),import:St(e.postcss?.import,p),modules:tt(e.postcss?.modules,void 0),to:e.postcss?.to,url:St(e.postcss?.url,p)},e.postcss?.parser&&(m.postcss.parser=await ce(e.postcss.parser,"parser",o)),e.postcss?.syntax&&(m.postcss.syntax=await ce(e.postcss.syntax,"syntax",o)),e.postcss?.stringifier&&(m.postcss.stringifier=await ce(e.postcss.stringifier,"stringifier",o)),e.postcss?.plugins&&(m.postcss.plugins=await mr(e.postcss.plugins,o)));const h=new Gn({extensions:m.extensions,loaders:await hr(e.loaders,["sourcemap","stylus","less","sass","postcss"]),logger:t,options:{...e,...m,alias:p}});let g=[];const y=ge((w,$)=>{const E=[];for(const b of Object.keys(w)){const P=new Set;let _=[b];do{const W=[];for(const F of _){if(P.has(F))continue;if(h.isSupported(F)){d(F)&&W.push(F);continue}P.add(F);const ie=$(F);ie&&W.push(...ie.importedIds)}_=W}while(_.some(W=>!h.isSupported(W)));E.push(..._)}return E},"traverseImportedModules");return{augmentChunkHash(w){if(g.length===0)return null;const $=y(w.modules,this.getModuleInfo),E=g.filter(b=>$.includes(b.id)).sort((b,P)=>$.lastIndexOf(b.id)-$.lastIndexOf(P.id)).map(b=>`${pe(b.id)}:${b.css}`);return E.length===0?null:E.join(":")},async generateBundle(w,$){if(g.length===0||!(w.dir||w.file))return;const E=Object.values($),b=w.dir??B(w.file),P=E.filter(S=>S.type==="chunk"),_=P.filter(S=>!S.facadeModuleId),W=w.preserveModules?P:P.filter(S=>S.isEntry||S.isDynamicEntry),F=[],ie=ge(async(S,C)=>{const k=typeof m.extract=="string"?J(m.extract).replace(/^\.[/\\]/,""):J(`${S}.css`);Ae(k)&&this.error(["Extraction path must be relative to the output directory,",`which is ${I(o,b)}`].join(`
|
|
41
|
+
`)),ss(k)&&this.error(["Extraction path must be nested inside output directory,",`which is ${I(o,b)}`].join(`
|
|
42
|
+
`));const V=g.filter(z=>C.includes(z.id)).sort((z,ae)=>C.lastIndexOf(z.id)-C.lastIndexOf(ae.id)),we=await er(V);return{css:we.css,map:et(we.map.toString()).relative(B(j(b,k))).toString(),name:k}},"getExtractedData"),L=ge(S=>{if(w.file)return ze(w.file).name;if(w.preserveModules){const{dir:C,name:k}=ze(S.fileName);return C?x(C,k):k}return S.name},"getName"),H=[];if(typeof m.extract=="string"){t.debug({message:`Extracting to ${m.extract}`,prefix:"css"});const S=[];for(const k of _){const V=y(k.modules,this.getModuleInfo);H.push(...V),S.push(...V)}for(const k of W)S.push(...y(k.modules,this.getModuleInfo).filter(V=>!H.includes(V)));const C=L(P[0]);F.push([C,S])}else{t.debug({message:"Extracting to individual files",prefix:"css"});for(const S of _){const C=y(S.modules,this.getModuleInfo);if(C.length===0)continue;H.push(...C);const k=L(S);F.push([k,C])}for(const S of W){const C=y(S.modules,this.getModuleInfo).filter(V=>!H.includes(V));if(C.length===0)continue;const k=L(S);F.push([k,C])}}for await(const[S,C]of F){const k=await ie(S,C);if(typeof e.onExtract=="function"&&!e.onExtract(k))continue;if(c&&e.minifier){t.info({message:`Minifying ${k.name} with ${e.minifier.name}`,prefix:"css"});const{css:z,map:ae}=await e.minifier.handler.bind({browserTargets:s,warn:this.warn.bind(this)})(k,u,e[e.minifier.name]??{});k.css=z,k.map=ae}const V={fileName:k.name,name:k.name,names:[k.name],originalFileName:k.name,originalFileNames:[k.name],source:k.css,type:"asset"},we=this.emitFile(V);if(k.map&&u){const z=this.getFileName(we),ae=typeof w.assetFileNames=="string"?J(B(w.assetFileNames)):typeof w.assetFileNames=="function"?J(B(w.assetFileNames(V))):"assets",de=et(k.map).modify(N=>(N.file=pe(z),N)).modifySources(N=>{if(N==="<no source>"||ae.length<=1)return N;N=`../${N}`;for(const We of ae)We==="/"&&(N=`../${N}`);return N});if(u.inline)de.modify(N=>u.transform?.(N,J(x(b,z)))),$[z].source+=de.toCommentData();else{const N=`${z}.map`;de.modify(Ks=>u.transform?.(Ks,J(x(b,N)))),this.emitFile({fileName:N,source:de.toString(),type:"asset"});const{base:We}=ze(N);$[z].source+=de.toCommentFile(We)}}}},name:"packem:css",async transform(w,$){if(!d($)||!h.isSupported($)||w.replaceAll(/\s/g,"")==="")return null;try{return this.parse(w,{}),this.warn(`Skipping processed file ${I(o,$)}`),null}catch{}typeof e.onImport=="function"&&e.onImport(w,$);const E={alias:p,assets:new Map,autoModules:m.autoModules,browserTargets:s,cwd:o,debug:l,deps:new Set,dts:m.dts,emit:m.emit,environment:r,extensions:m.extensions,extract:m.extract,id:$,inject:m.inject,logger:t,namedExports:m.namedExports,options:{},plugin:this,sourceDir:n,sourceMap:u,useSourcemap:i,warn:this.warn.bind(this)},b=await h.process({code:w},E);for(const P of E.deps)this.addWatchFile(P);for(const[P,_]of E.assets)this.emitFile({fileName:P,source:_,type:"asset"});if(b.extracted){const{id:P}=b.extracted;g=g.filter(_=>_.id!==P),g.push(b.extracted)}return{code:b.code,map:u&&b.map?b.map:{mappings:""},meta:{styles:b.meta},moduleSideEffects:b.extracted?!0:null}}}},"default");var vr=Object.defineProperty,br=f((e,t)=>vr(e,"name",{value:t,configurable:!0}),"t$a");const wr=/\.module\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/,qe=br((e,t)=>e===void 0?!0:typeof e=="function"?e(t):e instanceof RegExp?e.test(t):e&&wr.test(t),"ensureAutoModules");var $r=Object.defineProperty,xr=f((e,t)=>$r(e,"name",{value:t,configurable:!0}),"u$9");const jr=`
|
|
25
43
|
/* eslint-disable */
|
|
26
44
|
/* prettier-ignore */
|
|
27
45
|
// @ts-nocheck
|
|
@@ -29,135 +47,135 @@ module.exports.default = `+i[2]+";");let c=l.toString();return c=c.replace(/(?:m
|
|
|
29
47
|
* Generated by packem
|
|
30
48
|
* @see https://npmjs.com/@visulima/packem
|
|
31
49
|
*/
|
|
32
|
-
`.trim(),
|
|
33
|
-
${l}`),
|
|
34
|
-
`),t&&(
|
|
35
|
-
`),
|
|
36
|
-
`),(e||t)&&(
|
|
37
|
-
`),t&&(
|
|
38
|
-
`),
|
|
39
|
-
`),
|
|
40
|
-
`),e&&(
|
|
41
|
-
`),t&&(
|
|
42
|
-
`),
|
|
43
|
-
`),
|
|
44
|
-
${
|
|
45
|
-
$2`)},"replaceContentWithin");var
|
|
46
|
-
`;
|
|
47
|
-
`);const $=new Set;for(const E of[d,...
|
|
48
|
-
`),
|
|
49
|
-
`),
|
|
50
|
-
`+
|
|
51
|
-
`).replaceAll(`<!-- ${
|
|
50
|
+
`.trim(),kr=xr((e,t,s)=>{let o;return e.postcss&&typeof e.postcss.modules=="boolean"?o=e.postcss.modules:e.lightningcss&&typeof e.lightningcss.modules=="boolean"&&(o=e.lightningcss.modules),{async transform(n,r){let i=o;if(e.postcss&&typeof e.postcss.modules=="object"?i=qe(e.postcss.modules.include,r):e.lightningcss&&typeof e.lightningcss.modules=="object"&&(i=qe(e.lightningcss.modules.include,r)),e.autoModules&&i===void 0&&(i=qe(e.autoModules,r)),!i)return null;const{types:l}=this.getModuleInfo(r)?.meta.styles??{};return l===void 0||await nt(r)&&(await qt(r+".d.ts",`${jr}
|
|
51
|
+
${l}`),s.info({message:`Generated types for ${J(r).replace(t+"/","")}`,prefix:"dts:css-modules"}),this.addWatchFile(r+".d.ts")),null}}},"cssModulesTypes");var Er=Object.defineProperty,Fe=f((e,t)=>Er(e,"name",{value:t,configurable:!0}),"t$9");const Sr=/\Wrequire(?:\.resolve)?\(/,Or=Fe((e,t)=>{if(Se.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 s=!1,o=!1,n=!1;if(e.includes("__filename")&&(s=!0),e.includes("__dirname")&&(o=!0),Sr.test(e)&&(n=!0),!s&&!o&&!n)return null;const r=ns(e).pop(),i=r?r.end:0,l=new G(e);return l.appendRight(i,t(s,o,n)),{code:l.toString(),map:l.generateMap()}},"CJSToESM"),Dr=Fe((e,t,s)=>{let o="";return(e||t)&&(o+=`import __cjs_url__ from "node:url"; // -- packem CommonJS __filename shim --
|
|
52
|
+
`),t&&(o+=`import __cjs_path__ from "node:path"; // -- packem CommonJS __dirname shim --
|
|
53
|
+
`),s&&(o+=`import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
|
|
54
|
+
`),(e||t)&&(o+=`const __filename = __cjs_url__.fileURLToPath(import.meta.url);
|
|
55
|
+
`),t&&(o+=`const __dirname = __cjs_path__.dirname(__filename);
|
|
56
|
+
`),s&&(o+=`const require = __cjs_mod__.createRequire(import.meta.url);
|
|
57
|
+
`),o},"generateCJSShim"),Cr=Fe((e,t,s)=>{let o="";return s&&(o+=`import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
|
|
58
|
+
`),e&&(o+=`const __filename = import.meta.filename; // -- packem CommonJS __filename shim --
|
|
59
|
+
`),t&&(o+=`const __dirname = import.meta.dirname; // -- packem CommonJS __dirname shim --
|
|
60
|
+
`),s&&(o+=`const require = __cjs_mod__.createRequire(import.meta.url);
|
|
61
|
+
`),o},"generateCJSShimNode20_11"),Pr=Fe((e,t)=>{const s=ne(t.include,t.exclude);return{name:"packem:esm-shim-cjs-syntax",renderChunk(o,n,r){if(r.format==="es"&&s(n.fileName)){let i=Dr;if(e.engines?.node){const l=os(e.engines.node);l&&l.major>=20&&l.minor>=11&&(i=Cr)}return Or(o,i)}return null}}},"esmShimCjsSyntaxPlugin");var Nr=Object.defineProperty,Ir=f((e,t)=>Nr(e,"name",{value:t,configurable:!0}),"m$c");const _r=Ir(()=>({name:"packem:fix-dynamic-import-extension",renderChunk(e,t,s){return s.format==="es"||s.format==="cjs"?{code:e.replaceAll(/(import\(.*)(.ts)(['´"`]\))/g,"$1."+(s.format==="es"?"mjs":"cjs")+"$3"),map:null}:null}}),"fixDynamicImportExtension");var Mr=Object.defineProperty,Tr=f((e,t)=>Mr(e,"name",{value:t,configurable:!0}),"a$f");const Ar=Tr((e,t)=>{const s=e.replace(/^\.\//,""),o=t.replace(/^\.\//,"");if(o.startsWith(s))return e+o.slice(s.length);if(e.endsWith(t))return e;const n=e.split("/"),r=t.split("/");let i=n.length-1,l=r.length-1;for(;i>=0&&l>=0&&n[i]===r[l];)i--,l--;const c=n.slice(0,i).join("/"),a=r.slice(l).join("/");return c+(a?"/"+a:"")},"extendString");var Rr=Object.defineProperty,Fr=f((e,t)=>Rr(e,"name",{value:t,configurable:!0}),"s$b");const Lr=Fr((...e)=>{if(e.length===0)return"";if(e.length===1)return B(e[0]);e=e.map(n=>Oe(n));const[t,...s]=e;let o=t.split("/");for(const n of s){const r=n.split("/",o.length);let i=0;for(const l of r)if(l===o[i])i+=1;else{o=o.slice(0,i);break}o=o.slice(0,i)}return o.length<=1&&o[0]===""?`/${o[0]}`:o.join("/")},"lowestCommonAncestor");var Jr=Object.defineProperty,Ke=f((e,t)=>Jr(e,"name",{value:t,configurable:!0}),"m$a");const Br=Ke((e,t,s,o,n={})=>{const r=ne(n.include,n.exclude),i={},l=Ke((a,p)=>{i[a.replace(oe,"")]=p},"addOutput");async function c(a,p){if(!r(p))return;let d;try{const h=await Lo(a,{sourceFilename:p});d=JSON.parse(h.program)}catch{}if(d){const h=d.body.filter(g=>g.type==="ImportDeclaration"||g.type==="ExportAllDeclaration"||g.type==="ExportNamedDeclaration");for(const g of h){if(!g.source||pe(g.source.value).includes("."))continue;const y=await this.resolve(g.source.value,p);if(!(!y||y.external)&&(y.id.endsWith(".ts")||y.id.endsWith(".cts")||y.id.endsWith(".mts")||y.id.endsWith(".tsx")||y.id.endsWith(".ctsx")||y.id.endsWith(".mtsx"))){const w=y.id.replace(e+"/","");a=a.replaceAll('from "'+g.source.value+'"','from "'+Ar(g.source.value,w)+'"')}}}const{errors:u,sourceText:m}=await t(p,a);if(u.length>0){if(n.ignoreErrors){this.warn(u[0]);return}return this.error(u[0])}if(l(p,m),!d)return;const v=d.body.filter(h=>h.type==="ImportDeclaration"?h.importKind==="type"?!0:h.specifiers?.every(g=>g.type==="ImportSpecifier"&&g.importKind==="type"):h.type==="ExportNamedDeclaration"||h.type==="ExportAllDeclaration"?h.exportKind==="type"?!0:h.type==="ExportNamedDeclaration"&&h.specifiers?.every(g=>g.type==="ExportSpecifier"&&g.exportKind==="type"):!1);for await(const h of v){if(!h.source)continue;const g=await this.resolve(h.source.value,p);if(!g)return;const y=g.id;if(r(y)&&!i[y.replace(oe,"")])try{const w=await rt(y);await c.call(this,w,y)}catch{}}}return f(c,"h"),Ke(c,"transform"),{name:"packem:isolated-declarations",async renderStart(a,{input:p}){const d=Lr(...Array.isArray(p)?p:Object.values(p));typeof a.entryFileNames=="function"&&(a.entryFileNames=a.entryFileNames({name:a.name}));const u=a.entryFileNames.replace(/\.(.)?[jt]sx?$/,(m,v)=>`.d.${v||""}ts`);for await(let[m,v]of Object.entries(i)){if(o&&a.format==="cjs"){const g=ds(v);g!==null&&(v=g.code)}const h=v.includes("from '")?"'":'"';(s===!0||s==="compatible")&&a.format==="cjs"&&this.emitFile({fileName:u.replace("[name]",I(d,m)).replace(".cts",".ts"),source:v.replaceAll(/(from\s)['|"]((.*)\..+|['|"].*)['|"];?/g,(g,y,w,$)=>y+h+($||w)+".d.ts"+h+";"),type:"asset"}),this.emitFile({fileName:u.replace("[name]",I(d,m)),source:v.replaceAll(/(from\s)['|"]((.*)\..+|['|"].*)['|"];?/g,(g,y,w,$)=>y+h+($||w)+(a.format==="cjs"?".d.cts":".d.mts")+h+";"),type:"asset"})}},transform:c}},"isolatedDeclarationsPlugin");var Wr=Object.defineProperty,Vr=f((e,t)=>Wr(e,"name",{value:t,configurable:!0}),"n$9");const Ot="export default ",ws=Vr(e=>{const t=Jo(e);return{...t,name:"packem:json",transform(s,o){const n=t.transform?.call(this,s,o);return n&&typeof n!="string"&&"code"in n&&n.code?.startsWith(Ot)&&(n.code=n.code.replace(Ot,"module.exports = ")),n}}},"JSONPlugin");class zr{static{f(this,"WalkerBase")}constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:f(()=>this.should_skip=!0,"skip"),remove:f(()=>this.should_remove=!0,"remove"),replace:f(t=>this.replacement=t,"replace")}}replace(t,s,o,n){t&&s&&(o!=null?t[s][o]=n:t[s]=n)}remove(t,s,o){t&&s&&(o!=null?t[s].splice(o,1):delete t[s])}}class Ur extends zr{static{f(this,"SyncWalker")}constructor(t,s){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:f(()=>this.should_skip=!0,"skip"),remove:f(()=>this.should_remove=!0,"remove"),replace:f(o=>this.replacement=o,"replace")},this.enter=t,this.leave=s}visit(t,s,o,n){if(t){if(this.enter){const i=this.should_skip,l=this.should_remove,c=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,t,s,o,n),this.replacement&&(t=this.replacement,this.replace(s,o,n,t)),this.should_remove&&this.remove(s,o,n);const a=this.should_skip,p=this.should_remove;if(this.should_skip=i,this.should_remove=l,this.replacement=c,a)return t;if(p)return null}let r;for(r in t){const i=t[r];if(i&&typeof i=="object")if(Array.isArray(i)){const l=i;for(let c=0;c<l.length;c+=1){const a=l[c];Dt(a)&&(this.visit(a,t,r,c)||c--)}}else Dt(i)&&this.visit(i,t,r,null)}if(this.leave){const i=this.replacement,l=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,t,s,o,n),this.replacement&&(t=this.replacement,this.replace(s,o,n,t)),this.should_remove&&this.remove(s,o,n);const c=this.should_remove;if(this.replacement=i,this.should_remove=l,c)return null}}return t}}function Dt(e){return e!==null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"}f(Dt,"isNode");function $s(e,{enter:t,leave:s}){return new Ur(t,s).visit(e,null)}f($s,"walk");var qr=Object.defineProperty,Kr=f((e,t)=>qr(e,"name",{value:t,configurable:!0}),"u$8");const Gr=Kr(({attributes:e,logger:t})=>{const s=ne([/\.[tj]sx$/],/node_modules/);if(!Array.isArray(e)||e.length===0)throw new Error("[packem:jsx-remove-attributes]: attributes must be a non-empty array of strings.");return{name:"packem:jsx-remove-attributes",transform(o,n){if(!s(n))return null;let r=null;try{r=this.parse(o,{allowReturnOutsideFunction:!0})}catch(c){return this.warn({code:"PARSE_ERROR",message:`[packem:jsx-remove-attributes]: failed to parse "${n}" and remove the jsx attribute.`}),t.warn(c),null}let i=!1;const l=new G(o);return $s(r,{enter(c){if(c.type==="CallExpression"&&c.callee.type==="Identifier"&&c.callee.name==="jsx"){const a=c.arguments.filter(p=>p.type==="ObjectExpression"&&Array.isArray(p.properties));for(const p of a)for(const d of p.properties)d.type==="Property"&&d.key.type==="Literal"&&d.value.type==="Literal"&&e.includes(d.key.value)&&(l.overwrite(d.start-2,d.end,""),i=!0)}}}),i?{code:l.toString(),map:l.generateMap({hires:!0})}:null}}},"jsxRemoveAttributes");var Hr=Object.defineProperty,Yr=f((e,t)=>Hr(e,"name",{value:t,configurable:!0}),"r$a");const Xr=Yr((e,t,s)=>{const o=new RegExp(`(<!-- ${t} -->)[\\s\\S]*?(<!-- /${t} -->)`,"g");if(o.test(e))return e.replace(o,`$1
|
|
62
|
+
${s}
|
|
63
|
+
$2`)},"replaceContentWithin");var Qr=Object.defineProperty,xs=f((e,t)=>Qr(e,"name",{value:t,configurable:!0}),"d$b");const Zr=xs(e=>{const t=[],s=[];return e.forEach(o=>{o.startsWith("(")?t.push(o):s.push(o)}),[...s.sort(),...t.sort()]},"sortLicenses"),js=xs(({dtsMarker:e,licenseFilePath:t,licenseTemplate:s,logger:o,marker:n,mode:r,packageName:i})=>Bo({thirdParty(l){const c=new Set,a=l.sort(({name:d},{name:u})=>(d||0)>(u||0)?1:(u||0)>(d||0)?-1:0).map(({author:d,contributors:u,license:m,licenseText:v,maintainers:h,name:g,repository:y})=>{let w="## "+g+`
|
|
64
|
+
`;m&&(w+=`License: ${m}
|
|
65
|
+
`);const $=new Set;for(const E of[d,...h,...u]){const b=typeof E=="string"?E:E?.name;b&&$.add(b)}return $.size>0&&(w+=`By: ${[...$].join(", ")}
|
|
66
|
+
`),y&&(w+=`Repository: ${typeof y=="string"?y:y.url}
|
|
67
|
+
`),v&&(w+=`
|
|
68
|
+
`+v.trim().replaceAll(/\r\n|\r/g,`
|
|
69
|
+
`).replaceAll(`<!-- ${n} -->`,"").replaceAll(e?`<!-- ${e} -->`:"","").replaceAll(`<!-- /${n} -->`,"").replaceAll(e?`<!-- /${e} -->`:"","").trim().split(`
|
|
52
70
|
`).map(E=>E?`> ${E}`:">").join(`
|
|
53
71
|
`)+`
|
|
54
|
-
`),
|
|
72
|
+
`),m&&c.add(m),w}).join(`
|
|
55
73
|
---------------------------------------
|
|
56
74
|
|
|
57
|
-
`);if(a===""){
|
|
75
|
+
`);if(a===""){o.info({message:"No dependencies license information found.",prefix:"plugin:license:"+r});return}const p=s(Zr(c),a,i);try{const d=Me(t),u=Xr(d,n,p);if(!u){o.error({message:`Could not find the license marker: <!-- ${n} --><!-- /${n} --> in ${t}`,prefix:"plugin:license:"+r});return}d!==u&&(se(t,u),o.info({message:`${t} updated.`,prefix:"plugin:license:"+r}))}catch(d){o.error(d)}}}),"license");var ei=Object.defineProperty,ti=f((e,t)=>ei(e,"name",{value:t,configurable:!0}),"i$9");const si=ti(e=>({async buildEnd(){const t=[];for(const o of this.getModuleIds()){const n=this.getModuleInfo(o);if(n!=null&&!n.isExternal)for(const r of n.importedIds)t.push({source:o,target:r})}if(Array.isArray(t)&&t.length===0)return;const s=j(e.rootDir,e.outDir,"graph.json");Te(s,t)},name:"packem:metafile"}),"metafilePlugin");var oi=Object.defineProperty,ni=f((e,t)=>oi(e,"name",{value:t,configurable:!0}),"g$5");let Ct=!1;const ri=ni((e,t,s,o,n,r)=>{if(r!=="*"&&So(Oo(r))===null)throw new Error("Invalid typeScriptVersion option. It must be a valid semver range.");return{name:"packem:node10-compatibility",writeBundle(){Ct||(e.info({message:"Declaration node10 compatibility mode is enabled.",prefix:"plugin:node10-compatibility"}),Ct=!0);const i={};for(const a of t)for(const p of a.exportKey)p.includes("/*")?i[p]=["./"+x(s,B(a.name),"*.d.ts")]:i[p]=[...i[p]??[],"./"+x(s,a.name+".d.ts")];const l=x(o,"package.json"),c=it(l);n==="file"&&Object.keys(i).length>0?(Te(l,{...c,typesVersions:{...c.typesVersions,[r]:i}},{detectIndent:!0}),e.info({message:'Your package.json "typesVersions" field has been updated.',prefix:"plugin:node10-compatibility"})):Object.keys(i).length>0&&e.info({message:`Please add the following field into your package.json to enable node 10 compatibility:
|
|
58
76
|
|
|
59
77
|
${JSON.stringify({typesVersions:{"*":i}},null,4)}
|
|
60
|
-
`,prefix:"plugin:node10-compatibility"})}}},"node10CompatibilityPlugin");var
|
|
61
|
-
`+e}return null},order:"post"}}),"prependDirectivePlugin");var
|
|
78
|
+
`,prefix:"plugin:node10-compatibility"})}}},"node10CompatibilityPlugin");var ii=Object.defineProperty,ai=f((e,t)=>ii(e,"name",{value:t,configurable:!0}),"t$7");const Q=ai(e=>Wo("sha256").update(e).digest("hex"),"getHash");var li=Object.defineProperty,ks=f((e,t)=>li(e,"name",{value:t,configurable:!0}),"d$a");const me=ks(e=>e.handler||e,"getHandler"),M=ks((e,t,s="")=>({...e,async buildEnd(o){e.buildEnd&&await me(e.buildEnd).call(this,o)},async buildStart(o){e.buildStart&&await me(e.buildStart).call(this,o)},async load(o){if(!e.load)return null;const n=x(s,e.name),r=x("load",Q(o));if(t.has(r,n))return await t.get(r,n);const i=await me(e.load).call(this,o);return t.set(r,i,n),i},name:`cached(${e.name})`,async resolveId(o,n,r){if(!e.resolveId)return null;const i=x(s,e.name),l=x("resolveId",Q(o),n?Q(n):"",Q(JSON.stringify(r)));if(t.has(l,i))return await t.get(l,i);const c=await me(e.resolveId).call(this,o,n,r);return t.set(l,c,i),c},async transform(o,n){if(!e.transform)return null;const r=x(s,e.name),i=x("transform",Q(n),Q(o));if(t.has(i,r))return await t.get(i,r);const l=await me(e.transform).call(this,o,n);return t.set(i,l,r),l}}),"cachingPlugin");var ci=Object.defineProperty,pi=f((e,t)=>ci(e,"name",{value:t,configurable:!0}),"n$8");const ui=pi(()=>({name:"packem:prepend-directive",transform:{handler(e,t){const s=this.getModuleInfo(t);if(s?.meta.preserveDirectives){const o=s.meta.preserveDirectives.directives[0];if(o)return`'${o.value}';
|
|
79
|
+
`+e}return null},order:"post"}}),"prependDirectivePlugin");var di=Object.defineProperty,fi=f((e,t)=>di(e,"name",{value:t,configurable:!0}),"c$a");const mi=fi(({directiveRegex:e,exclude:t=[],include:s=[],logger:o})=>{const n={},r={},i=ne(s,t);return{name:"packem:preserve-directives",onLog(l,c){return c.code==="MODULE_LEVEL_DIRECTIVE"&&l==="warn"?!1:null},renderChunk:{handler(l,c,{sourcemap:a}){const p=c.moduleIds.map(m=>n[m]?n[m]:null).reduce((m,v)=>(v&&v.forEach(h=>{m.add(h)}),m),new Set),d=new G(l);p.size>0&&(o.debug({message:`directives for chunk "${c.fileName}" are preserved.`,prefix:"plugin:preserve-directives"}),d.prepend(`${[...p].map(m=>`'${m}';`).join(`
|
|
62
80
|
`)}
|
|
63
|
-
`));let u;return c.facadeModuleId&&typeof
|
|
64
|
-
`)),p.size===0&&u===void 0?null:{code:d.toString(),map:a?d.generateMap({hires:!0}):null}},order:"post"},transform(l,c){if(!i(c))return null;let a=!1;const p=new G(l);if(l.startsWith("#")&&l[1]==="!"){let u=0;for(let
|
|
65
|
-
`);if(
|
|
66
|
-
`),{code:i.toString(),map:
|
|
67
|
-
`)=>{const
|
|
81
|
+
`));let u;return c.facadeModuleId&&typeof r[c.facadeModuleId]=="string"&&(u=r[c.facadeModuleId]),u&&(o.debug({message:`shebang for chunk "${c.fileName}" is preserved.`,prefix:"plugin:preserve-directives"}),d.prepend(`${u}
|
|
82
|
+
`)),p.size===0&&u===void 0?null:{code:d.toString(),map:a?d.generateMap({hires:!0}):null}},order:"post"},transform(l,c){if(!i(c))return null;let a=!1;const p=new G(l);if(l.startsWith("#")&&l[1]==="!"){let u=0;for(let m=2,v=l.length;m<v;m++){const h=l.codePointAt(m);if(h===10||h===13||h===8232||h===8233){u=m;break}}u&&(r[c]=l.slice(0,u),p.remove(0,u+1),a=!0,o.debug({message:`shebang for module "${c}" is preserved.`,prefix:"plugin:preserve-directives"}))}let d=null;try{d=this.parse(p.toString(),{allowReturnOutsideFunction:!0})}catch(u){return this.warn({code:"PARSE_ERROR",message:`failed to parse "${c}" and extract the directives.`}),o.warn(u),null}if(d.type!=="Program")return null;for(const u of d.body.filter(Boolean)){if(u.type!=="ExpressionStatement")break;let m=null;"directive"in u?m=u.directive:u.expression.type==="Literal"&&typeof u.expression.value=="string"&&e.test(u.expression.value)&&(m=u.expression.value),m!=="use strict"&&m&&(n[c]||=new Set,n[c].add(m),"start"in u&&typeof u.start=="number"&&"end"in u&&typeof u.end=="number"&&(p.remove(u.start,u.end),a=!0),o.debug({message:`directive "${m}" for module "${c}" is preserved.`,prefix:"plugin:preserve-directives"}))}return a?{code:p.toString(),map:p.generateMap({hires:!0}),meta:{preserveDirectives:{directives:[...n[c]??[]],shebang:r[c]??null}}}:null}}},"preserveDirectives");var gi=Object.defineProperty,hi=f((e,t)=>gi(e,"name",{value:t,configurable:!0}),"n$7");const yi=hi(e=>{const t=ne(e.include,e.exclude);return{async load(s){return s.includes("?raw")?await this.load({id:s.replace(/\?raw$/,"")}):null},name:"packem:raw",transform(s,o){return!t(o)&&!o.includes("?raw")?null:(o.includes("?raw")||(s=`export default ${JSON.stringify(s)}`),{code:s,map:{mappings:""}})}}},"rawPlugin");var vi=Object.defineProperty,bi=f((e,t)=>vi(e,"name",{value:t,configurable:!0}),"r$9");const Es=bi(()=>({name:"packem:resolve-file-url",resolveId(e){if(e.startsWith("file://"))return rs(e)}}),"resolveFileUrl");var wi=Object.defineProperty,Le=f((e,t)=>wi(e,"name",{value:t,configurable:!0}),"i$6");const Pe=/^#![^\n]*/,st=Le(async e=>{await io(e,493).catch(()=>{})},"makeExecutable"),$i=Le((e,t)=>({name:"packem:shebang",renderChunk:{handler(s,o,n){if(!o.isEntry||!o.facadeModuleId)return null;const r=s.startsWith("#")&&s[1]==="!";if(r&&t.replace)return s.replace(Pe,t.shebang+`
|
|
83
|
+
`);if(r)return null;if(e.includes(o.name)){const i=new G(s);return i.prepend(t.shebang+`
|
|
84
|
+
`),{code:i.toString(),map:n.sourcemap?i.generateMap({hires:!0}):void 0}}return null},order:"post"},async writeBundle(s,o){for(const[n,r]of Object.entries(o))if(r.type==="chunk"&&Pe.test(r.code)&&s.dir){const i=j(s.dir,n);await st(i)}}}),"shebangPlugin"),xi=Le(()=>({name:"packem:remove-shebang",renderChunk(e){return e.replace(Pe,"")}}),"removeShebangPlugin"),ji=Le((e,t=`
|
|
85
|
+
`)=>{const s=Pe.exec(e);return s?s+t:""},"getShebang");var ki=Object.defineProperty,re=f((e,t)=>ki(e,"name",{value:t,configurable:!0}),"r$8");const Ei=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,Si=/MIT License|MIT license|BSD license/,Oi=/\n{2,}/g,Di=/\b(\w+)\$\d+\b/g,Ci=/[-/\\^$*+?.()|[\]{}]/g,Pi=re(e=>e.replaceAll(Ci,"\\$&"),"escapeRegex"),Ni=re(e=>[...new Set(e)],"unique"),Ii=re(e=>e.replaceAll(Ei,t=>Si.test(t)?"":t).replaceAll(Oi,`
|
|
68
86
|
|
|
69
|
-
`),"cleanUnnecessaryComments"),Pt=new Map;function
|
|
70
|
-
- ${c}`).join(""),l=t.fileName.replace(/\.[^/.]+$/,"");Pt.has(l)||
|
|
87
|
+
`),"cleanUnnecessaryComments"),Pt=new Map;function Ss(e,t,{identifierReplacements:s},o){const n=ns(e);for(const i in s){const l=n.find(a=>a.specifier===i&&a.imports.includes("{"));if(!l){this.warn(`${t.fileName} does not import "${i}" for replacement`),process.exitCode=1;continue}const c=s[i];for(const a in c){if(!l.imports.includes(a))throw new Error(`${t.fileName} does not import "${a}" from "${i}" for replacement`);const p=c[a],d=Pi(a);p.includes(".")&&(e=e.replace(new RegExp(`\\b\\w+\\b as ${d},?\\s?`),"")),e=e.replaceAll(new RegExp(`\\b${d}\\b`,"g"),p)}}const r=Ni(Array.from(e.matchAll(Di),i=>i[0]));if(r.length>0){const i=r.map(c=>`
|
|
88
|
+
- ${c}`).join(""),l=t.fileName.replace(/\.[^/.]+$/,"");Pt.has(l)||o.warn({message:`${t.fileName} contains confusing identifier names${i}
|
|
71
89
|
|
|
72
|
-
To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),Pt.set(l,!0)}return e}
|
|
90
|
+
To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),Pt.set(l,!0)}return e}f(Ss,"I$1");re(Ss,"replaceConfusingTypeNames");const _i=re((e,t)=>{if(t.leadingComments?.some(s=>s.type==="CommentBlock"&&s.value.includes("@internal"))){const s=e.original[t.end]===","?t.end+1:t.end;return e.remove(t.leadingComments[0].start,s),!0}return!1},"removeInternal");function Os(e,t){if(e.includes("@internal")){const s=new G(e),o=Vo(e,{plugins:["typescript"],sourceType:"module"});if($s(o,{enter(n){_i(s,n)&&this.skip()}}),e=s.toString(),e.includes("@internal"))throw new Error(`${t.fileName} has unhandled @internal declarations`)}return e}f(Os,"S");re(Os,"stripInternalTypes");const Mi=re((e,t)=>({name:"packem:patch-types",renderChunk(s,o){return s=Ss.call(this,s,o,e,t),s=Os.call(this,s,o),s=Ii(s),s},resolveId(s){return s.startsWith("types/")?{external:!0,id:"../../"+(s.endsWith(".js")?s:s+".js")}:null}}),"patchTypescriptTypes");var Ti=Object.defineProperty,Ds=f((e,t)=>Ti(e,"name",{value:t,configurable:!0}),"m$9");const Cs=Ds((e,t=!0)=>{if(!e)return null;const{config:s,path:o}=e;if(!s.compilerOptions)return null;const{baseUrl:n,paths:r}=s.compilerOptions;if(!n)return null;const i=j(B(o),n),l=[];if(r)for(const[c,a]of Object.entries(r)){let p;c==="@"||c==="~"||c==="#"?p=new RegExp(`^${c}/(.+)$`):p=new RegExp(`^${[...c].map(u=>u==="*"?"(.+)":u.replace(/[\\^$*+?.()|[\]{}]/,"\\$&")).join("")}$`);let d=0;for(const u of a){const m=[...J(j(i,u))].map(v=>v==="*"?"$"+(++d+""):v==="$"?"$$":v).join("");l.push({find:p,replacement:m})}}return t&&l.push({find:/^(?!\.*\/|\.*$|\w:)(.+)$/,replacement:`${[...J(i)].map(c=>c==="$"?"$$":c).join("")}/$1`}),l},"getConfigAlias"),Ps=Ds((e,t)=>{const s=Cs(e);return{name:"packem:resolve-tsconfig-paths",async resolveId(o,n,r){if(!s||o.includes("\0"))return null;for(const{find:i,replacement:l}of s)if(i.test(o)){const c=o.replace(i,l),a=await this.resolve(c,n,{skipSelf:!0,...r});if(a)return t.debug({message:`Resolved ${o} to ${a.id} using paths from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-paths"}),a.id}return null}}},"resolveTsconfigPaths");var Ai=Object.defineProperty,Ns=f((e,t)=>Ai(e,"name",{value:t,configurable:!0}),"u$5");const Ri=Ns((e,t)=>{if(!t)return null;const{config:s,path:o}=t;if(!s.compilerOptions)return null;const{rootDirs:n}=s.compilerOptions;if(!n)return null;const r=[];for(const i of n){if(i.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${o}.`);if(i.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${o}.`);r.push(j(e,i))}return r},"getRootDirectories"),Is=Ns((e,t,s)=>{const o=Ri(e,s);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(n,r,i){if(o===null||o.length===0)return null;if(n.startsWith("."))for(const l of o){const c=x(l,n),a=await this.resolve(c,r,{skipSelf:!0,...i});if(a)return t.debug({message:`Resolved ${n} to ${a.id} using rootDirs from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-root-dirs"}),a.id}return null}}},"resolveTsconfigRootDirectories");var Fi=Object.defineProperty,Li=f((e,t)=>Fi(e,"name",{value:t,configurable:!0}),"r$7");const _s=Li(()=>{const e=/\.(?:[mc]?js|jsx)$/;return{name:"packem:resolve-typescript-mjs-cjs",async resolveId(t,s,o){return e.test(t)&&s?await this.resolve(t.replace(/js(x?)$/,"ts$1"),s,o):null}}},"resolveTypescriptMjsCts");var Ji=Object.defineProperty,Bi=f((e,t)=>Ji(e,"name",{value:t,configurable:!0}),"s$7");const Wi=Bi(e=>{const t=pe(e).split(".");if(t.length>=2){const[s,o]=t.slice(-2),n=t[0],r=/^(\w+)-runtime$/.exec(s)?.[1];if(at.includes(o)&&r&&r.length>0)return n+"-"+r}},"getCustomModuleLayer");var Vi=Object.defineProperty,zi=f((e,t)=>Vi(e,"name",{value:t,configurable:!0}),"i$5");const Ge=zi(e=>(e.preserveDirectives||{directives:[]}).directives.map(t=>t.replace(/^use /,"")).find(t=>t!=="strict"),"getModuleLayer");var Ui=Object.defineProperty,Nt=f((e,t)=>Ui(e,"name",{value:t,configurable:!0}),"d$9");const qi=Nt((e,t)=>{const s=new Map;return Nt(function(o,n){const r=n.getModuleInfo(o);if(!r)return;const{isEntry:i}=r,l=r.meta,c=Ge(l);if(!i){const a=s.get(o);if(a)return a;const p=Wi(o);if(p)return s.set(o,p),p}if(i){const a=n.getModuleIds();for(const p of a)n.getModuleInfo(p)&&Ge(l)===c&&(e.has(p)||e.set(p,new Set),e.get(p).add([o,c]))}if(c&&!i&&e.has(o)){const a=[...e.get(o)];if(a.some(([d])=>{if(t.some(u=>u.path===d)){const u=n.getModuleInfo(d);return Ge(u?u.meta:{})===c}return!1}))return;if(a.every(([,d])=>d===c))return s.has(o)?s.get(o):void 0;const p=pe(o,Kt(o))+"-"+c;return s.set(o,p),p}},"splitChunks")},"createSplitChunks");var Ki=Object.defineProperty,Gi=f((e,t)=>Ki(e,"name",{value:t,configurable:!0}),"n$5");const ee=Gi((e,t)=>e.isDynamicEntry?`${en}/[name].${t}`:`${tn}/${e.name}-[hash].${t}`,"getChunkFilename");var Hi=Object.defineProperty,Yi=f((e,t)=>Hi(e,"name",{value:t,configurable:!0}),"o$4");const Xi=process.platform==="win32",It=Yi((e,t)=>{const s=Xi?"\\":"/";for(let o of Array.isArray(e.names)?e.names:[]){if(o.includes("node_modules"+s+".pnpm"))return o=o.replace("node_modules"+s+".pnpm","external")+"."+t,o.replace("node_modules"+s,"");if(o.includes("node_modules"))return o.replace("node_modules","external")+"."+t}return"[name]."+t},"getEntryFileNames");var Qi=Object.defineProperty,Zi=f((e,t)=>Qi(e,"name",{value:t,configurable:!0}),"p$1");const pt=Zi((e,t)=>{let s={};if(e.pkg.name&&(s[e.pkg.name]=e.options.rootDir),e.pkg.imports){const{imports:o}=e.pkg;for(const n in o){if(n.startsWith("#"))continue;const r=o[n];typeof r=="string"&&(s[n]=x(e.options.rootDir,r))}}return s={...s,...e.options.alias},e.options.rollup.alias&&(Array.isArray(e.options.rollup.alias.entries)?Object.assign(s,Object.fromEntries(e.options.rollup.alias.entries.map(o=>[o.find,o.replacement]))):Object.assign(s,e.options.rollup.alias.entries??e.options.rollup.alias)),e.logger.debug({message:"Resolved aliases: "+JSON.stringify(s),prefix:t}),s},"resolveAliases");var ea=Object.defineProperty,T=f((e,t)=>ea(e,"name",{value:t,configurable:!0}),"n$3");const Ms=T((e,t)=>{const s=[],o=[],n=[];return e&&e.filter(Boolean).filter(r=>r.type===t?!0:t==="build"&&r.type===void 0).forEach(r=>{r.enforce==="pre"?s.push(r.plugin):r.enforce==="post"?o.push(r.plugin):n.push(r.plugin)}),[s,n,o]},"sortUserPlugins"),ta=T((e,t)=>{if(e==="esbuild"){if(!t.options.rollup.esbuild)throw new Error("No esbuild options found in your configuration.");t.tsconfig?.config.compilerOptions?.target?.toLowerCase()==="es3"&&(t.logger.warn(["ES3 target is not supported by esbuild, so ES5 will be used instead..","Please set 'target' option in tsconfig to at least ES5 to disable this error"].join(" ")),t.tsconfig.config.compilerOptions.target="es5",t.options.rollup.esbuild.target="es5");let s="node"+Xs.node.split(".")[0];if(t.pkg.engines?.node){const o=os(t.pkg.engines.node);o&&(s="node"+o.major)}if(t.options.rollup.esbuild.target){const o=he(t.options.rollup.esbuild.target);o.some(n=>n.startsWith("node"))||(t.options.rollup.esbuild.target=[...new Set([...he(s),...o])])}else t.options.rollup.esbuild.target=he(s);return t.tsconfig?.config.compilerOptions?.target==="es5"&&(t.options.rollup.esbuild.keepNames=!1,t.logger.debug("Disabling keepNames because target is set to es5")),{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"),Ts=T((e,t)=>{if(e.code==="CIRCULAR_DEPENDENCY"&&/Circular dependency:[\s\S]*node_modules/.test(e.message))return!0;if(e.code==="UNRESOLVED_IMPORT")throw new Error(`Failed to resolve the module "${e.exporter}" imported by "${D(I(j(),e.id))}"
|
|
73
91
|
Is the module installed? Note:
|
|
74
92
|
↳ to inline a module into your bundle, install it to "devDependencies".
|
|
75
|
-
↳ 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"),_t=new Map,
|
|
76
|
-
${n.stack}`),r){case"info":{e.logger.info({message:i,prefix:o+(n.plugin?":plugin:"+n.plugin:"")});return}case"warn":{e.logger.warn({message:i,prefix:o+(n.plugin?":plugin:"+n.plugin:"")});return}case"debug":e.logger.debug({message:i,prefix:o+(n.plugin?":plugin:"+n.plugin:"")})}},"onLog"),onwarn(r,n){_o(r,e)||r.code||n(r)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),Mo=M(async(e,t)=>{const o=pt(e,"build");let s;e.options.rollup.resolve&&(s=T(Qt({...e.options.rollup.resolve}),t));const r=e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:Ui(e.dependencyGraphMap,e.buildEntries),preserveModules:!1},[n,i,l]=Io(e.options.rollup.plugins,"build");return{...To(e,o,"build"),output:[e.options.emitCJS&&{assetFileNames:"[name]-[hash][extname]",chunkFileNames:M(c=>Z(c,"cjs"),"chunkFileNames"),compact:e.options.minify,dir:k(e.options.rootDir,e.options.outDir),entryFileNames:M(c=>It(c,"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,...r},e.options.emitESM&&{assetFileNames:"[name]-[hash][extname]",chunkFileNames:M(c=>Z(c,"mjs"),"chunkFileNames"),compact:e.options.minify,dir:k(e.options.rootDir,e.options.outDir),entryFileNames:M(c=>It(c,"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,...r}].filter(Boolean),plugins:[T(jo(),t),T(No(),t),e.tsconfig&&T(Po(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&T(Do(e.tsconfig,e.logger),t),e.options.rollup.replace&&Zt({sourcemap:e.options.sourcemap,...e.options.rollup.replace}),e.options.rollup.alias&&Xt({customResolver:s,...e.options.rollup.alias,entries:o}),...n,s,e.options.rollup.polyfillNode&&bs({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&vo({...e.options.rollup.json}),xr(),e.options.rollup.wasm&&ys(e.options.rollup.wasm),e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer&&Ln(x(e.options.rootDir,e.options.sourceDir),e.options.isolatedDeclarationTransformer,e.options.declaration,!!e.options.rollup.cjsInterop,e.options.rollup.isolatedDeclarations),e.options.rollup.css&&e.options.rollup.css.loaders&&e.options.rollup.css.loaders.length>0&&await hn({dts:!!e.options.declaration||e.options.isolatedDeclarationTransformer!==void 0,sourceMap:e.options.sourcemap,...e.options.rollup.css},e.logger,e.options.browserTargets,e.options.rootDir,e.options.sourceDir,e.environment,e.options.sourcemap,e.options.debug,e.options.minify??!1,o),e.options.rollup.css&&e.options.rollup.css.loaders&&e.options.rollup.css.loaders.length>0&&e.options.declaration&&jn(e.options.rollup.css,e.options.rootDir,e.logger),e.options.rollup.raw&&T(hi(e.options.rollup.raw),t),...i,e.options.transformer(ea(e.options.transformerName,e)),T(fi({directiveRegex:/^['|"](use (\w+))['|"]$/,...e.options.rollup.preserveDirectives,logger:e.logger}),t),e.options.rollup.shebang&&wi(e.options.entries.filter(c=>c.executable).map(c=>c.name).filter(Boolean),e.options.rollup.shebang),e.options.cjsInterop&&e.options.emitCJS&&po({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&In(),e.options.rollup.dynamicVars&&hs(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&T(gs({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&&Cn(e.pkg,e.options.rollup.shim),e.options.rollup.jsxRemoveAttributes&&T(Kn({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),t),...l,e.options.rollup.metafile&&ti({outDir:k(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&Nr(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&$o({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}),pi(),e.options.emitCJS&&e.mode==="build"&&e.options.declaration==="compatible"&&e.options.rollup.node10Compatibility&&ri(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&&ws({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)}},"getRollupOptions"),ta=M(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"),oa=cr(ta),Ao=M(async(e,t)=>{const o=pt(e,"types"),s=e.tsconfig?.config.compilerOptions;delete s?.lib;let r;e.options.rollup.resolve&&(r=T(Qt({...e.options.rollup.resolve}),t));const n="dts-plugin:"+process.pid+e.tsconfig.path,[i,l,c]=Io(e.options.rollup.plugins,"dts");return{...To(e,o,"dts"),onwarn(a,p){_o(a,e)||a.code!=="EMPTY_BUNDLE"&&p(a)},output:[e.options.emitCJS&&{chunkFileNames:M(a=>Z(a,"d.cts"),"chunkFileNames"),compact:e.options.minify,dir:k(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.emitESM&&{chunkFileNames:M(a=>Z(a,"d.mts"),"chunkFileNames"),compact:e.options.minify,dir:k(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:M(a=>Z(a,"d.ts"),"chunkFileNames"),compact:e.options.minify,dir:k(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:[T(jo(),t),T(No(),t),e.options.rollup.json&&vo({...e.options.rollup.json}),{load(a){return/\.(?:js|cjs|mjs|jsx|ts|tsx|ctsx|mtsx|mts|json)$/.test(a)?null:""},name:"packem:ignore-files"},e.tsconfig&&T(Po(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&T(Do(e.tsconfig,e.logger),t),e.options.rollup.replace&&Zt({sourcemap:e.options.sourcemap,...e.options.rollup.replace}),e.options.rollup.alias&&Xt({customResolver:r,...e.options.rollup.alias,entries:o}),...i,r,...l,await oa(n)(e),e.options.cjsInterop&&e.options.emitCJS&&po({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&T(_i(e.options.rollup.patchTypes,e.logger),t),$i(),...c,e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&$o({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dtsTemplate,logger:e.logger,marker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",mode:"types",packageName:e.pkg.name})].filter(Boolean)}},"getRollupDtsOptions");var sa=Object.defineProperty,ra=m((e,t)=>sa(e,"name",{value:t,configurable:!0}),"m$6");const Tt="rollup-build.json",na=ra(async(e,t,o)=>{const s=await Mo(e,t);if(await e.hooks.callHook("rollup:options",e,s),Object.keys(s.input).length===0)return;let r=!0;(e.options.rollup.isolatedDeclarations||e.options.isolatedDeclarationTransformer||e.options.rollup.css)&&(r=!1),r&&(s.cache=t.get(Tt,o));const n=await Yt(s);r&&t.set(Tt,n.cache,o),await e.hooks.callHook("rollup:build",e,n);const i=new Map;for(const l of s.output){const{output:c}=await n.write(l),a=new Set,p=c.filter(u=>u.type==="chunk");for(const u of p){a.add(u.fileName);for(const f of u.imports)e.usedImports.add(f);u.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(u.code,"utf8"),chunks:u.imports.filter(f=>p.find(g=>g.fileName===f)),exports:u.exports,modules:Object.entries(u.modules).map(([f,g])=>({bytes:g.renderedLength,id:f})),path:u.fileName,type:"entry"})}const d=c.filter(u=>u.type==="asset");for(const u of d)i.has(u.fileName)||i.set(u.fileName,{bytes:Buffer.byteLength(u.source,"utf8"),path:u.fileName,type:"asset"});for(const u of a)e.usedImports.delete(u)}e.buildEntries.push(...i.values())},"build");var ia=Object.defineProperty,je=m((e,t)=>ia(e,"name",{value:t,configurable:!0}),"a$8");const Mt="rollup-dts.json",aa=je(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 s=await Ao(e,t);if(await e.hooks.callHook("rollup:dts:options",e,s),Object.keys(s.input).length===0)return;s.cache=t.get(Mt,o);const r=await Yt(s);t.set(Mt,r.cache,o),await e.hooks.callHook("rollup:dts:build",e,r),e.logger.info({message:"Building declaration files...",prefix:"dts"}),e.options.emitCJS&&await r.write({chunkFileNames:je(n=>Z(n,"d.cts"),"chunkFileNames"),dir:k(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await r.write({chunkFileNames:je(n=>Z(n,"d.mts"),"chunkFileNames"),dir:k(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts"}),e.options.declaration==="compatible"&&await r.write({chunkFileNames:je(n=>Z(n,"d.mjs"),"chunkFileNames"),dir:k(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts"}),await e.hooks.callHook("rollup:dts:done",e)},"buildTypes");var la=Object.defineProperty,ca=m((e,t)=>la(e,"name",{value:t,configurable:!0}),"y$3");const pa=ca((e,t,o)=>e.reduce((s,r)=>{const n=r[t],i=r[o];return s[n]||(s[n]={}),s[n][i]||(s[n][i]=[]),s[n][i].push(r),s},{}),"groupByKeys");var ua=Object.defineProperty,_e=m((e,t)=>ua(e,"name",{value:t,configurable:!0}),"j$1");const da=_e((e,t)=>{const o=_e(i=>I(t.options.rootDir,k(t.options.outDir,i)),"rPath");let s=!1;const r=[],n=t.buildEntries.filter(i=>i.type==="entry");if(n.length>0){e.raw(`Entries:
|
|
77
|
-
`);for(const i of
|
|
93
|
+
↳ 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"),_t=new Map,He=new Map,As=T((e,t,s)=>{const o=Cs(e.tsconfig,!1);return{external(n){n=jo(n,t);const r=cs(n);if(Ze(e.options.externals,r)||Ze(e.options.externals,n))return!0;const{pkg:i}=e;if(n.startsWith(".")||Ae(n)||/src[/\\]/.test(n)||i.name&&n.startsWith(i.name))return!1;if(i.imports)for(const[l,c]of Object.entries(i.imports)){if(l===n)return!1;if(l.includes("*")){let a;He.has(l)?a=He.get(l):(a=Gt(x(e.options.rootDir,c.replace("/*","")),{withFileTypes:!0}).filter(p=>p.isFile()).map(p=>p.name),He.set(l,a));for(const p of a)if(p.replace(oe,"")===n.replace(oe,"").replace("#",""))return!1}}if(o){for(const{find:l}of o)if(l.test(n))return e.logger.debug({message:`Resolved alias ${n} to ${l.source}`,prefix:s}),!1}return _t.has(n)||e.logger.info({message:'Inlined implicit external "'+D(n)+'". If this is incorrect, add it to the "externals" option.',prefix:s}),_t.set(n,!0),!1},input:Object.fromEntries(e.options.entries.map(n=>[n.name,j(e.options.rootDir,n.input)])),logLevel:e.options.debug?"debug":"info",onLog:T((n,r)=>{let i=r.message;switch(r.stack&&(i=`${i}
|
|
94
|
+
${r.stack}`),n){case"info":{e.logger.info({message:i,prefix:s+(r.plugin?":plugin:"+r.plugin:"")});return}case"warn":{e.logger.warn({message:i,prefix:s+(r.plugin?":plugin:"+r.plugin:"")});return}case"debug":e.logger.debug({message:i,prefix:s+(r.plugin?":plugin:"+r.plugin:"")})}},"onLog"),onwarn(n,r){Ts(n,e)||n.code||r(n)},watch:e.mode==="watch"?e.options.rollup.watch:!1}},"baseRollupOptions"),Rs=T(async(e,t)=>{const s=pt(e,"build");let o;e.options.rollup.resolve&&(o=M(es({...e.options.rollup.resolve}),t));const n=e.options.rollup.output?.preserveModules?{preserveModules:!0,preserveModulesRoot:e.options.rollup.output.preserveModulesRoot??"src"}:{manualChunks:qi(e.dependencyGraphMap,e.buildEntries),preserveModules:!1},[r,i,l]=Ms(e.options.rollup.plugins,"build");return{...As(e,s,"build"),output:[e.options.emitCJS&&{assetFileNames:"[name]-[hash][extname]",chunkFileNames:T(c=>ee(c,"cjs"),"chunkFileNames"),compact:e.options.minify,dir:j(e.options.rootDir,e.options.outDir),entryFileNames:T(c=>It(c,"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&&{assetFileNames:"[name]-[hash][extname]",chunkFileNames:T(c=>ee(c,"mjs"),"chunkFileNames"),compact:e.options.minify,dir:j(e.options.rootDir,e.options.outDir),entryFileNames:T(c=>It(c,"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:[M(Es(),t),M(_s(),t),e.tsconfig&&M(Is(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&M(Ps(e.tsconfig,e.logger),t),e.options.rollup.replace&&ts({sourcemap:e.options.sourcemap,...e.options.rollup.replace}),e.options.rollup.alias&&Zt({customResolver:o,...e.options.rollup.alias,entries:s}),...r,o,e.options.rollup.polyfillNode&&ko({sourceMap:e.options.sourcemap,...e.options.rollup.polyfillNode}),e.options.rollup.json&&ws({...e.options.rollup.json}),kn(),e.options.rollup.wasm&&xo(e.options.rollup.wasm),e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer&&Br(x(e.options.rootDir,e.options.sourceDir),e.options.isolatedDeclarationTransformer,e.options.declaration,!!e.options.rollup.cjsInterop,e.options.rollup.isolatedDeclarations),e.options.rollup.css&&e.options.rollup.css.loaders&&e.options.rollup.css.loaders.length>0&&await yr({dts:!!e.options.declaration||e.options.isolatedDeclarationTransformer!==void 0,sourceMap:e.options.sourcemap,...e.options.rollup.css},e.logger,e.options.browserTargets,e.options.rootDir,e.options.sourceDir,e.environment,e.options.sourcemap,e.options.debug,e.options.minify??!1,s),e.options.rollup.css&&e.options.rollup.css.loaders&&e.options.rollup.css.loaders.length>0&&e.options.declaration&&kr(e.options.rollup.css,e.options.rootDir,e.logger),e.options.rollup.raw&&M(yi(e.options.rollup.raw),t),...i,e.options.transformer(ta(e.options.transformerName,e)),M(mi({directiveRegex:/^['|"](use (\w+))['|"]$/,...e.options.rollup.preserveDirectives,logger:e.logger}),t),e.options.rollup.shebang&&$i(e.options.entries.filter(c=>c.executable).map(c=>c.name).filter(Boolean),e.options.rollup.shebang),e.options.cjsInterop&&e.options.emitCJS&&fs({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.dynamicVars&&_r(),e.options.rollup.dynamicVars&&$o(e.options.rollup.dynamicVars),e.options.rollup.commonjs&&M(wo({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&&Pr(e.pkg,e.options.rollup.shim),e.options.rollup.jsxRemoveAttributes&&M(Gr({attributes:e.options.rollup.jsxRemoveAttributes.attributes,logger:e.logger}),t),...l,e.options.rollup.metafile&&si({outDir:j(e.options.rootDir,e.options.outDir),rootDir:e.options.rootDir}),e.options.rollup.copy&&_n(e.options.rollup.copy,e.logger),e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dependenciesTemplate=="function"&&js({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}),ui(),e.options.emitCJS&&e.mode==="build"&&e.options.declaration==="compatible"&&e.options.rollup.node10Compatibility&&ri(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&&Eo({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)}},"getRollupOptions"),sa=T(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"),oa=un(sa),Fs=T(async(e,t)=>{const s=pt(e,"types"),o=e.tsconfig?.config.compilerOptions;delete o?.lib;let n;e.options.rollup.resolve&&(n=M(es({...e.options.rollup.resolve}),t));const r="dts-plugin:"+process.pid+e.tsconfig.path,[i,l,c]=Ms(e.options.rollup.plugins,"dts");return{...As(e,s,"dts"),onwarn(a,p){Ts(a,e)||a.code!=="EMPTY_BUNDLE"&&p(a)},output:[e.options.emitCJS&&{chunkFileNames:T(a=>ee(a,"d.cts"),"chunkFileNames"),compact:e.options.minify,dir:j(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output},e.options.emitESM&&{chunkFileNames:T(a=>ee(a,"d.mts"),"chunkFileNames"),compact:e.options.minify,dir:j(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:T(a=>ee(a,"d.ts"),"chunkFileNames"),compact:e.options.minify,dir:j(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts",format:"cjs",sourcemap:e.options.sourcemap,...e.options.rollup.output}].filter(Boolean),plugins:[M(Es(),t),M(_s(),t),e.options.rollup.json&&ws({...e.options.rollup.json}),{load(a){return/\.(?:js|cjs|mjs|jsx|ts|tsx|ctsx|mtsx|mts|json)$/.test(a)?null:""},name:"packem:ignore-files"},e.tsconfig&&M(Is(e.options.rootDir,e.logger,e.tsconfig),t),e.tsconfig&&M(Ps(e.tsconfig,e.logger),t),e.options.rollup.replace&&ts({sourcemap:e.options.sourcemap,...e.options.rollup.replace}),e.options.rollup.alias&&Zt({customResolver:n,...e.options.rollup.alias,entries:s}),...i,n,...l,await oa(r)(e),e.options.cjsInterop&&e.options.emitCJS&&fs({...e.options.rollup.cjsInterop,logger:e.logger,type:e.pkg.type??"commonjs"}),e.options.rollup.patchTypes&&M(Mi(e.options.rollup.patchTypes,e.logger),t),xi(),...c,e.options.rollup.license&&e.options.rollup.license.path&&typeof e.options.rollup.license.dtsTemplate=="function"&&js({licenseFilePath:e.options.rollup.license.path,licenseTemplate:e.options.rollup.license.dtsTemplate,logger:e.logger,marker:e.options.rollup.license.dtsMarker??"TYPE_DEPENDENCIES",mode:"types",packageName:e.pkg.name})].filter(Boolean)}},"getRollupDtsOptions");var na=Object.defineProperty,ra=f((e,t)=>na(e,"name",{value:t,configurable:!0}),"m$7");const Mt="rollup-build.json",ia=ra(async(e,t,s)=>{const o=await Rs(e,t);if(await e.hooks.callHook("rollup:options",e,o),Object.keys(o.input).length===0)return;let n=!0;(e.options.rollup.isolatedDeclarations||e.options.isolatedDeclarationTransformer||e.options.rollup.css)&&(n=!1),n&&(o.cache=t.get(Mt,s));const r=await Qt(o);n&&t.set(Mt,r.cache,s),await e.hooks.callHook("rollup:build",e,r);const i=new Map;for(const l of o.output){const{output:c}=await r.write(l),a=new Set,p=c.filter(u=>u.type==="chunk");for(const u of p){a.add(u.fileName);for(const m of u.imports)e.usedImports.add(m);u.isEntry&&e.buildEntries.push({bytes:Buffer.byteLength(u.code,"utf8"),chunks:u.imports.filter(m=>p.find(v=>v.fileName===m)),exports:u.exports,modules:Object.entries(u.modules).map(([m,v])=>({bytes:v.renderedLength,id:m})),path:u.fileName,type:"entry"})}const d=c.filter(u=>u.type==="asset");for(const u of d)i.has(u.fileName)||i.set(u.fileName,{bytes:Buffer.byteLength(u.source,"utf8"),path:u.fileName,type:"asset"});for(const u of a)e.usedImports.delete(u)}e.buildEntries.push(...i.values())},"build");var aa=Object.defineProperty,$e=f((e,t)=>aa(e,"name",{value:t,configurable:!0}),"a$8");const Tt="rollup-dts.json",la=$e(async(e,t,s)=>{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 o=await Fs(e,t);if(await e.hooks.callHook("rollup:dts:options",e,o),Object.keys(o.input).length===0)return;o.cache=t.get(Tt,s);const n=await Qt(o);t.set(Tt,n.cache,s),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:$e(r=>ee(r,"d.cts"),"chunkFileNames"),dir:j(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.cts"}),e.options.emitESM&&await n.write({chunkFileNames:$e(r=>ee(r,"d.mts"),"chunkFileNames"),dir:j(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.mts"}),e.options.declaration==="compatible"&&await n.write({chunkFileNames:$e(r=>ee(r,"d.mjs"),"chunkFileNames"),dir:j(e.options.rootDir,e.options.outDir),entryFileNames:"[name].d.ts"}),await e.hooks.callHook("rollup:dts:done",e)},"buildTypes");var ca=Object.defineProperty,pa=f((e,t)=>ca(e,"name",{value:t,configurable:!0}),"y$3");const ua=pa((e,t,s)=>e.reduce((o,n)=>{const r=n[t],i=n[s];return o[r]||(o[r]={}),o[r][i]||(o[r][i]=[]),o[r][i].push(n),o},{}),"groupByKeys");var da=Object.defineProperty,Ne=f((e,t)=>da(e,"name",{value:t,configurable:!0}),"j$1");const fa=Ne((e,t)=>{const s=Ne(i=>I(t.options.rootDir,j(t.options.outDir,i)),"rPath");let o=!1;const n=[],r=t.buildEntries.filter(i=>i.type==="entry");if(r.length>0){e.raw(`Entries:
|
|
95
|
+
`);for(const i of r){let l=i.bytes??0;for(const a of i.chunks??[])l+=t.buildEntries.find(p=>p.path===a)?.bytes??0;let c=` ${q(s(i.path))} (${["total size: "+D(Y(l)),i.bytes&&"chunk size: "+D(Y(i.bytes))].filter(Boolean).join(", ")})`;if(c+=i.exports?.length?`
|
|
78
96
|
exports: `+X(i.exports.join(", ")):"",i.chunks?.length&&(c+=`
|
|
79
|
-
${i.chunks.map(a=>{const p=t.buildEntries.find(d=>d.path===a)??{};return X(" └─ "+
|
|
80
|
-
`)}`),i.modules&&i.modules.length>0){const a=i.modules.filter(p=>p.id.includes("node_modules")).sort((p,d)=>(d.bytes||0)-(p.bytes||0)).map(p=>X(" 📦 "+
|
|
97
|
+
${i.chunks.map(a=>{const p=t.buildEntries.find(d=>d.path===a)??{};return X(" └─ "+s(a)+q(p.bytes?" ("+Y(p?.bytes)+")":""))}).join(`
|
|
98
|
+
`)}`),i.modules&&i.modules.length>0){const a=i.modules.filter(p=>p.id.includes("node_modules")).sort((p,d)=>(d.bytes||0)-(p.bytes||0)).map(p=>X(" 📦 "+s(p.id)+q(p.bytes?" ("+Y(p.bytes)+")":""))).join(`
|
|
81
99
|
`);c+=a.length>0?`
|
|
82
100
|
inlined modules:
|
|
83
|
-
`+a:""}if(t.options.declaration){let a=i.path.replace(/\.js$/,".d.ts"),p="commonjs";i.path.endsWith(".cjs")?a=i.path.replace(/\.cjs$/,".d.cts"):i.path.endsWith(".mjs")&&(p="module",a=i.path.replace(/\.mjs$/,".d.mts"));const d=t.buildEntries.find(u=>u.path.endsWith(a));if(d){
|
|
101
|
+
`+a:""}if(t.options.declaration){let a=i.path.replace(/\.js$/,".d.ts"),p="commonjs";i.path.endsWith(".cjs")?a=i.path.replace(/\.cjs$/,".d.cts"):i.path.endsWith(".mjs")&&(p="module",a=i.path.replace(/\.mjs$/,".d.mts"));const d=t.buildEntries.find(u=>u.path.endsWith(a));if(d){n.push(d.path);let u;a.includes(".d.ts")||(a=a.replace(".d.c",".d."),u=t.buildEntries.find(m=>m.path.endsWith(a))),u&&(n.push(u.path),c+=p==="commonjs"?`
|
|
84
102
|
types:
|
|
85
|
-
`+[d,u].map(
|
|
103
|
+
`+[d,u].map(m=>X(" └─ ")+q(s(m.path))+" (total size: "+D(Y(m.bytes??0))+")").join(`
|
|
86
104
|
`):`
|
|
87
|
-
types: `+
|
|
105
|
+
types: `+q(s(d.path))+" (total size: "+D(Y(d.bytes??0))+")")}}o=!0,c+=`
|
|
88
106
|
|
|
89
|
-
`,e.raw(i.chunk?X(c):c)}}if(t.buildEntries.filter(i=>i.type==="asset").length>0){let i="Assets:";for(const l of t.buildEntries.filter(c=>c.type==="asset"))
|
|
90
|
-
└─ `)+
|
|
107
|
+
`,e.raw(i.chunk?X(c):c)}}if(t.buildEntries.filter(i=>i.type==="asset").length>0){let i="Assets:";for(const l of t.buildEntries.filter(c=>c.type==="asset"))n.includes(l.path)||(i+=X(`
|
|
108
|
+
└─ `)+q(s(l.path))+" (total size: "+D(Y(l.bytes??0))+")");i+=`
|
|
91
109
|
|
|
92
|
-
`,e.raw(i)}return
|
|
93
|
-
`),s},"showSizeInformation"),fa=_e((e,t)=>{const o=pa(e.options.entries,"environment","runtime"),s=new Set,r=new Set;for(const[n,i]of Object.entries(o))for(const[l,c]of Object.entries(i)){const a={...e};!e.options.dtsOnly&&(n!=="undefined"||l!=="undefined")&&e.logger.info("Preparing build for "+(n==="undefined"?"":D(n)+" environment"+(l==="undefined"?"":" with "))+(l==="undefined"?"":D(l)+" runtime"));const p={};a.options.rollup.replace?(a.options.rollup.replace.values===void 0&&(a.options.rollup.replace.values={}),n!=="undefined"&&(p[["process","env","NODE_ENV"].join(".")]=JSON.stringify(n)),p[["process","env","EdgeRuntime"].join(".")]=JSON.stringify(l==="edge-light"),Object.freeze(p)):e.logger.warn("'replace' plugin is disabled. You should enable it to replace 'process.env.*' environments.");let d="";n!=="undefined"&&(d+=n+"/"),l!=="undefined"&&(d+=l+"/");let u=!1;a.options.minify!==void 0&&(u=a.options.minify),n==="development"?u=!1:n==="production"&&(u=!0);const f=[],g=[],y=[],h=[];for(const v of c)v.cjs&&v.esm?f.push(v):v.cjs?y.push(v):v.esm?g.push(v):v.declaration&&h.push(v);if(f.length>0){const v={...a,options:{...a.options,emitCJS:!0,emitESM:!0,entries:f,minify:u,rollup:{...a.options.rollup,replace:a.options.rollup.replace?{...a.options.rollup.replace,values:{...a.options.rollup.replace.values,...p}}:!1}}};if(e.options.dtsOnly||s.add({context:v,fileCache:t,subDirectory:d}),e.options.declaration){const w=v.options.entries.filter($=>$.declaration);w.length>0&&r.add({context:{...v,options:{...v.options,entries:w}},fileCache:t,subDirectory:d})}}if(g.length>0){const v={...a,options:{...a.options,emitCJS:!1,emitESM:!0,entries:g,minify:u,rollup:{...a.options.rollup,replace:a.options.rollup.replace?{...a.options.rollup.replace,values:{...a.options.rollup.replace.values,...p}}:!1}}};if(e.options.dtsOnly||s.add({context:v,fileCache:t,subDirectory:d}),e.options.declaration){const w=v.options.entries.filter($=>$.declaration);w.length>0&&r.add({context:{...v,options:{...v.options,entries:w}},fileCache:t,subDirectory:d})}}if(y.length>0){const v={...a,options:{...a.options,emitCJS:!0,emitESM:!1,entries:y,minify:u,rollup:{...a.options.rollup,replace:a.options.rollup.replace?{...a.options.rollup.replace,values:{...a.options.rollup.replace.values,...p}}:!1}}};if(e.options.dtsOnly||s.add({context:v,fileCache:t,subDirectory:d}),e.options.declaration){const w=v.options.entries.filter($=>$.declaration);w.length>0&&r.add({context:{...v,options:{...v.options,entries:w}},fileCache:t,subDirectory:d})}}a.options.declaration&&h.length>0&&r.add({context:{...a,options:{...a.options,emitCJS:!1,emitESM:!1,entries:h,minify:u,rollup:{...a.options.rollup,replace:a.options.rollup.replace?{...a.options.rollup.replace,values:{...a.options.rollup.replace.values,...p}}:!1}}},fileCache:t,subDirectory:d})}return{builders:s,typeBuilders:r}},"prepareRollupConfig"),ma=_e(async(e,t)=>{await e.hooks.callHook("build:before",e);const{builders:o,typeBuilders:s}=fa(e,t);await Promise.all([...o].map(async({context:r,fileCache:n,subDirectory:i})=>await na(r,n,i))),await Promise.all([...s].map(async({context:r,fileCache:n,subDirectory:i})=>await aa(r,n,i))),e.logger.success(rs(e.options.name?"Build succeeded for "+e.options.name:"Build succeeded"));for await(const r of Qo(x(e.options.rootDir,e.options.outDir))){let n=e.buildEntries.find(i=>x(e.options.rootDir,e.options.outDir,i.path)===r.path);if(n||(n={chunk:!0,path:r.path},e.buildEntries.push(n)),!n.bytes){const i=await Gt(k(e.options.rootDir,e.options.outDir,r.path));n.bytes=i.size}}return await e.hooks.callHook("build:done",e),da(e.logger,e)},"build");var ga=Object.defineProperty,ha=m((e,t)=>ga(e,"name",{value:t,configurable:!0}),"r$5");const O=ha((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var ya=Object.defineProperty,Ro=m((e,t)=>ya(e,"name",{value:t,configurable:!0}),"t$3");const Te=Ro(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),st=Ro((e,t,o,s)=>{if(e==="module-sync")return"esm";if(s){const i=Te(s);if(i)return i}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return o;const[r,...n]=t;return st(r,n,o,s)},"inferExportType");var va=Object.defineProperty,ba=m((e,t)=>va(e,"name",{value:t,configurable:!0}),"y$2");const wa=new Set(["electron","import","require","node","node-addons","default","types","deno","browser","module-sync","bun","workerd",...lt,...Ne]),ut=ba((e,t,o,s=[])=>{if(!e)return[];if(typeof e=="string"){const r=Te(e);if(r&&r!==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:r??t}]}if(typeof e=="object"){const r=Object.entries(e).filter(([i])=>!i.endsWith(".json"));let n=[];for(const[i,l]of r)if(typeof l=="string"){let c={};Number.isInteger(+i)?c={exportKey:"*"}:i.startsWith("./")?c={exportKey:i.replace("./","")}:c={exportKey:i==="."?".":"*",subKey:i},n.push({...c,file:l,key:"exports",type:st(i,s,t,l)})}else if(typeof l=="object"&&l!==null)for(const[c,a]of Object.entries(l)){if(o===!1&&c==="types")continue;const p=Number.isInteger(+i)?c:i;typeof a=="string"?n.push({exportKey:p.replace("./",""),file:a,key:"exports",...wa.has(c)?{subKey:c}:{},type:st(c,s,t,a)}):n=[...n,...ut({[p]:a},t,o,[...s,c])]}return n}return[]},"extractExportFilenames");var $a=Object.defineProperty,We=m((e,t)=>$a(e,"name",{value:t,configurable:!0}),"c$4");const xa=We((e,t)=>e.key==="exports"&&e.subKey===K?K:e.key==="exports"&&e.subKey===ve?ve:t,"getEnvironment"),ke=We((e,t,o,s,r,n,i)=>{const l=xa(r,n.environment);let c="node";for(const d of lt)if(r.file.includes("."+d+".")||r.subKey===d){c=d;break}let a=e.find(d=>d.input===t&&d.environment===l&&d.runtime===c);a===void 0?a=e[e.push({environment:l,exportKey:new Set([r.exportKey].filter(Boolean)),input:t,runtime:c})-1]:a.exportKey&&r.exportKey&&a.exportKey.add(r.exportKey),i&&(a.isGlob=!0),o&&(a.outDir=s),r.isExecutable?(a.executable=!0,a.declaration=!1,r.type==="cjs"?a.cjs=!0:r.type==="esm"&&(a.esm=!0)):(/\.d\.[mc]?ts$/.test(r.file)&&n.options.declaration!==!1&&(a.declaration=n.options.declaration),r.type==="cjs"?a.cjs=!0:r.type==="esm"&&(a.esm=!0));const p=r.file.replace(Ut(r.file),"").replace(new RegExp(`^./${n.options.outDir.replace(/^\.\//,"")}/`),"");Ne.has(r.subKey)&&!t.includes(p)&&(a.fileAlias=p)},"createOrUpdateEntry");let At=!1;const Rt=We(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"),ja=We((e,t,o)=>{const s=[];t.sort((l,c)=>l.split("/").length-c.split("/").length);const r=e.type==="module"?"esm":"cjs";r==="esm"&&(o.options.emitESM=!0),r==="cjs"&&(o.options.emitCJS=!0);const n=ut(e.exports,r,o.options.declaration);if(e.bin){const l=(typeof e.bin=="string"?[e.bin]:Object.values(e.bin)).filter(Boolean);for(const c of l){const a=Te(c);if(a&&a!==r)throw new Error(`Exported file "${c}" has an extension that does not match the package.json type "${e.type??"commonjs"}".`);n.push({file:c,isExecutable:!0,key:"bin",type:a??r})}}e.main&&n.push({file:e.main,key:"main",type:Te(e.main)??r}),e.module&&n.push({file:e.module,key:"module",type:"esm"}),(e.types||e.typings)&&(Rt(o),o.options.declaration===void 0&&(o.options.declaration="compatible"),n.push({file:e.types??e.typings,key:"types"}));const i=[];for(const l of n){o.options.declaration===void 0&&(l.key==="types"||l.subKey==="types")&&(o.options.declaration=l.file.includes(".d.ts")?"compatible":!0),o.options.emitCJS===void 0&&l.type==="cjs"&&(o.options.emitCJS=!0),o.options.emitESM===void 0&&l.type==="esm"&&(o.options.emitESM=!0);const c=l.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),a=c.endsWith("/");if(a&&["./","/"].includes(c))continue;const p=c.replace(new RegExp("(./)?"+o.options.outDir),o.options.sourceDir).replace("./",""),d="(?<=/|$)",u=a?"":"\\.\\w+$";if(l.file.includes("/*")&&l.key==="exports"){At||(o.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),At=!0);const h=[],v=new RegExp(d+p.replace("*","(.*)")+u),w=new RegExp(d+p.replace(/(.*)\.[^.]*$/,"$1").replace("*","(.*)")+u);for(const $ of t)(v.test($)||Ne.has(l.subKey)&&w.test($))&&h.push($);if(h.length===0){s.push(`Could not find entrypoint for \`${l.file}\``);continue}for(const $ of h)ke(i,$,a,c,l,o,!0);continue}const f=new RegExp(d+p+u);let g=t.find(h=>f.test(h));if(Ne.has(l.subKey)&&g===void 0){const h=new RegExp(d+p.replace(/(.*)\.[^.]*$/,"$1")+u);g=t.find(v=>h.test(v))}if(g===void 0){R(k(o.options.rootDir,l.file))||s.push(`Could not find entrypoint for \`${l.file}\``);continue}(g.endsWith(".ts")||g.endsWith(".cts")||g.endsWith(".mts"))&&R(g)&&Rt(o);const y=Ce(g.replace(se,""));R(y+".cts")&&R(y+".mts")?(ke(i,y+".cts",a,c,{...l,type:"cjs"},o,!1),ke(i,y+".mts",a,c,{...l,type:"esm"},o,!1)):ke(i,g,a,c,l,o,!1)}return{entries:i,warnings:s}},"inferEntries");var ka=Object.defineProperty,Ea=m((e,t)=>ka(e,"name",{value:t,configurable:!0}),"o$3");const Sa=Ea((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 Oa=Object.defineProperty,Da=m((e,t)=>Oa(e,"name",{value:t,configurable:!0}),"t$2");const Ca={hooks:{"build:prepare":Da(function(e){if(e.options.entries.length>0)return;const t=x(e.options.rootDir,e.options.sourceDir);if(!Kt(t))throw new Error("No 'src' directory found. Please provide entries manually.");const o=Zo(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 s={...e.pkg};s.publishConfig&&(e.logger.info('Using publishConfig found in package.json, to override the default key-value pairs of "'+Object.keys(s.publishConfig).join(", ")+'".'),e.logger.debug(s.publishConfig),s=Sa(s,e.options.declaration));const r=ja(s,o,e);for(const n of r.warnings)O(e,n);if(e.options.entries.push(...r.entries),e.options.entries.length===0)throw new Error("No entries detected. Please provide entries manually.");e.logger.info("Automatically detected entries:",D(e.options.entries.map(n=>n.fileAlias?U(n.fileAlias)+" => "+U(n.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*")):U(n.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),X([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(n=>`[${n}]`).join(" ")))},"build:prepare")}};var Pa=Object.defineProperty,Na=m((e,t)=>Pa(e,"name",{value:t,configurable:!0}),"t$1");const Ia=Na(async(e,t)=>{if(e==="auto")e=Ca;else{if(e==="none")return{};typeof e=="string"&&(e=await t.import(e)||{})}return typeof e=="function"&&(e=e()),e},"resolvePreset");var _a=Object.defineProperty,Ta=m((e,t)=>_a(e,"name",{value:t,configurable:!0}),"j");const Ma=Ta(async e=>{const t=e.options.jiti.transformOptions?.babel?.plugins,o=[],s=JSON.stringify({...e.options.jiti,alias:{...pt(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((r,n)=>{if(Array.isArray(r)){const[i,...l]=r;return o.push(i),"["+["plugin"+n,...l.map(c=>JSON.stringify(c))].join(", ")+"]"}return o.push(r),"plugin"+n}).join(",")+"]":"[]");for(const r of e.options.entries){const n=k(e.options.rootDir,e.options.outDir,r.name),i=Ns(e.jiti.esmResolve(r.input,{try:!0})??r.input),l=i.replace(se,""),c=Ae(i),a=xi(c);let p=[];try{p=await Is(i,{extensions:at})}catch(u){O(e,`Cannot analyze ${i} for exports: ${u.toString()}`);return}const d=p.includes("default")||p.length===0;if(e.options.emitESM){const u=I(B(n),await yt("jiti",{conditions:["node","import"],url:import.meta.url})),f=l+".d.mts";oe(`${n}.mjs`,a+['import { createJiti } from "'+u+'";',...o.map((g,y)=>"import plugin"+y+' from "'+g+'";'),"","const jiti = createJiti(import.meta.url, "+s+");","",'/** @type {import("'+f+'")} */','const _module = await jiti.import("'+i+'");',d?`
|
|
94
|
-
export default _module;`:"",...p.filter(
|
|
95
|
-
`)),e.options.declaration&&
|
|
96
|
-
`+(d?'export { default } from "'+
|
|
97
|
-
`)),e.options.declaration&&
|
|
98
|
-
`+(d?'export { default } from "'+
|
|
99
|
-
`;return
|
|
110
|
+
`,e.raw(i)}return o&&e.raw("Σ Total dist size (byte size):",D(Y(t.buildEntries.reduce((i,l)=>i+(l.bytes??0),0),{decimals:2})),`
|
|
111
|
+
`),o},"showSizeInformation"),ma=Ne((e,t)=>{const s=ua(e.options.entries,"environment","runtime"),o=new Set,n=new Set;for(const[r,i]of Object.entries(s))for(const[l,c]of Object.entries(i)){const a={...e};!e.options.dtsOnly&&(r!=="undefined"||l!=="undefined")&&e.logger.info("Preparing build for "+(r==="undefined"?"":D(r)+" environment"+(l==="undefined"?"":" with "))+(l==="undefined"?"":D(l)+" runtime"));const p={};a.options.rollup.replace?(a.options.rollup.replace.values===void 0&&(a.options.rollup.replace.values={}),r!=="undefined"&&(p[["process","env","NODE_ENV"].join(".")]=JSON.stringify(r)),p[["process","env","EdgeRuntime"].join(".")]=JSON.stringify(l==="edge-light"),Object.freeze(p)):e.logger.warn("'replace' plugin is disabled. You should enable it to replace 'process.env.*' environments.");let d="";r!=="undefined"&&(d+=r+"/"),l!=="undefined"&&(d+=l+"/");let u=!1;a.options.minify!==void 0&&(u=a.options.minify),r==="development"?u=!1:r==="production"&&(u=!0);const m=[],v=[],h=[],g=[];for(const y of c)y.cjs&&y.esm?m.push(y):y.cjs?h.push(y):y.esm?v.push(y):y.declaration&&g.push(y);if(m.length>0){const y={...a,options:{...a.options,emitCJS:!0,emitESM:!0,entries:m,minify:u,rollup:{...a.options.rollup,replace:a.options.rollup.replace?{...a.options.rollup.replace,values:{...a.options.rollup.replace.values,...p}}:!1}}};if(e.options.dtsOnly||o.add({context:y,fileCache:t,subDirectory:d}),e.options.declaration){const w=y.options.entries.filter($=>$.declaration);w.length>0&&n.add({context:{...y,options:{...y.options,entries:w}},fileCache:t,subDirectory:d})}}if(v.length>0){const y={...a,options:{...a.options,emitCJS:!1,emitESM:!0,entries:v,minify:u,rollup:{...a.options.rollup,replace:a.options.rollup.replace?{...a.options.rollup.replace,values:{...a.options.rollup.replace.values,...p}}:!1}}};if(e.options.dtsOnly||o.add({context:y,fileCache:t,subDirectory:d}),e.options.declaration){const w=y.options.entries.filter($=>$.declaration);w.length>0&&n.add({context:{...y,options:{...y.options,entries:w}},fileCache:t,subDirectory:d})}}if(h.length>0){const y={...a,options:{...a.options,emitCJS:!0,emitESM:!1,entries:h,minify:u,rollup:{...a.options.rollup,replace:a.options.rollup.replace?{...a.options.rollup.replace,values:{...a.options.rollup.replace.values,...p}}:!1}}};if(e.options.dtsOnly||o.add({context:y,fileCache:t,subDirectory:d}),e.options.declaration){const w=y.options.entries.filter($=>$.declaration);w.length>0&&n.add({context:{...y,options:{...y.options,entries:w}},fileCache:t,subDirectory:d})}}a.options.declaration&&g.length>0&&n.add({context:{...a,options:{...a.options,emitCJS:!1,emitESM:!1,entries:g,minify:u,rollup:{...a.options.rollup,replace:a.options.rollup.replace?{...a.options.rollup.replace,values:{...a.options.rollup.replace.values,...p}}:!1}}},fileCache:t,subDirectory:d})}return{builders:o,typeBuilders:n}},"prepareRollupConfig"),ga=Ne(async(e,t)=>{await e.hooks.callHook("build:before",e);const{builders:s,typeBuilders:o}=ma(e,t);await Promise.all([...s].map(async({context:n,fileCache:r,subDirectory:i})=>await ia(n,r,i))),await Promise.all([...o].map(async({context:n,fileCache:r,subDirectory:i})=>await la(n,r,i))),e.logger.success(lo(e.options.name?"Build succeeded for "+e.options.name:"Build succeeded"));for await(const n of so(x(e.options.rootDir,e.options.outDir))){let r=e.buildEntries.find(i=>x(e.options.rootDir,e.options.outDir,i.path)===n.path);if(r||(r={chunk:!0,path:n.path},e.buildEntries.push(r)),!r.bytes){const i=await Yt(j(e.options.rootDir,e.options.outDir,n.path));r.bytes=i.size}}return await e.hooks.callHook("build:done",e),fa(e.logger,e)},"build");var ha=Object.defineProperty,ya=f((e,t)=>ha(e,"name",{value:t,configurable:!0}),"r$5");const O=ya((e,t)=>{e.warnings.has(t)||e.warnings.add(t)},"warn");var va=Object.defineProperty,Ls=f((e,t)=>va(e,"name",{value:t,configurable:!0}),"t$3");const Ie=Ls(e=>{if(e.endsWith(".mjs")||e.endsWith(".d.mts"))return"esm";if(e.endsWith(".cjs")||e.endsWith(".d.cts"))return"cjs"},"inferExportTypeFromFileName"),ot=Ls((e,t,s,o)=>{if(e==="module-sync")return"esm";if(o){const i=Ie(o);if(i)return i}if(e==="module"||e==="import")return"esm";if(e==="require")return"cjs";if(t.length===0)return s;const[n,...r]=t;return ot(n,r,s,o)},"inferExportType");var ba=Object.defineProperty,wa=f((e,t)=>ba(e,"name",{value:t,configurable:!0}),"y$2");const $a=new Set(["electron","import","require","node","node-addons","default","types","deno","browser","module-sync","bun","workerd",...lt,...Ce]),ut=wa((e,t,s,o=[])=>{if(!e)return[];if(typeof e=="string"){const n=Ie(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(([i])=>!i.endsWith(".json"));let r=[];for(const[i,l]of n)if(typeof l=="string"){let c={};Number.isInteger(+i)?c={exportKey:"*"}:i.startsWith("./")?c={exportKey:i.replace("./","")}:c={exportKey:i==="."?".":"*",subKey:i},r.push({...c,file:l,key:"exports",type:ot(i,o,t,l)})}else if(typeof l=="object"&&l!==null)for(const[c,a]of Object.entries(l)){if(s===!1&&c==="types")continue;const p=Number.isInteger(+i)?c:i;typeof a=="string"?r.push({exportKey:p.replace("./",""),file:a,key:"exports",...$a.has(c)?{subKey:c}:{},type:ot(c,o,t,a)}):r=[...r,...ut({[p]:a},t,s,[...o,c])]}return r}return[]},"extractExportFilenames");var xa=Object.defineProperty,Je=f((e,t)=>xa(e,"name",{value:t,configurable:!0}),"c$4");const ja=Je((e,t)=>e.key==="exports"&&e.subKey===K?K:e.key==="exports"&&e.subKey===ye?ye:t,"getEnvironment"),xe=Je((e,t,s,o,n,r,i)=>{const l=ja(n,r.environment);let c="node";for(const d of lt)if(n.file.includes("."+d+".")||n.subKey===d){c=d;break}let a=e.find(d=>d.input===t&&d.environment===l&&d.runtime===c);a===void 0?a=e[e.push({environment:l,exportKey:new Set([n.exportKey].filter(Boolean)),input:t,runtime:c})-1]:a.exportKey&&n.exportKey&&a.exportKey.add(n.exportKey),i&&(a.isGlob=!0),s&&(a.outDir=o),n.isExecutable?(a.executable=!0,a.declaration=!1,n.type==="cjs"?a.cjs=!0:n.type==="esm"&&(a.esm=!0)):(/\.d\.[mc]?ts$/.test(n.file)&&r.options.declaration!==!1&&(a.declaration=r.options.declaration),n.type==="cjs"?a.cjs=!0:n.type==="esm"&&(a.esm=!0));const p=n.file.replace(Kt(n.file),"").replace(new RegExp(`^./${r.options.outDir.replace(/^\.\//,"")}/`),"");Ce.has(n.subKey)&&!t.includes(p)&&(a.fileAlias=p)},"createOrUpdateEntry");let At=!1;const Rt=Je(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"),ka=Je((e,t,s)=>{const o=[];t.sort((l,c)=>l.split("/").length-c.split("/").length);const n=e.type==="module"?"esm":"cjs";n==="esm"&&(s.options.emitESM=!0),n==="cjs"&&(s.options.emitCJS=!0);const r=ut(e.exports,n,s.options.declaration);if(e.bin){const l=(typeof e.bin=="string"?[e.bin]:Object.values(e.bin)).filter(Boolean);for(const c of l){const a=Ie(c);if(a&&a!==n)throw new Error(`Exported file "${c}" has an extension that does not match the package.json type "${e.type??"commonjs"}".`);r.push({file:c,isExecutable:!0,key:"bin",type:a??n})}}e.main&&r.push({file:e.main,key:"main",type:Ie(e.main)??n}),e.module&&r.push({file:e.module,key:"module",type:"esm"}),(e.types||e.typings)&&(Rt(s),s.options.declaration===void 0&&(s.options.declaration="compatible"),r.push({file:e.types??e.typings,key:"types"}));const i=[];for(const l of r){s.options.declaration===void 0&&(l.key==="types"||l.subKey==="types")&&(s.options.declaration=l.file.includes(".d.ts")?"compatible":!0),s.options.emitCJS===void 0&&l.type==="cjs"&&(s.options.emitCJS=!0),s.options.emitESM===void 0&&l.type==="esm"&&(s.options.emitESM=!0);const c=l.file.replace(/(?:\*[^/\\]|\.d\.[mc]?ts|\.\w+)$/,""),a=c.endsWith("/");if(a&&["./","/"].includes(c))continue;const p=c.replace(new RegExp("(./)?"+s.options.outDir),s.options.sourceDir).replace("./",""),d="(?<=/|$)",u=a?"":"\\.\\w+$";if(l.file.includes("/*")&&l.key==="exports"){At||(s.logger.debug("Private subfolders are not supported, if you need this feature please open an issue on GitHub."),At=!0);const g=[],y=new RegExp(d+p.replace("*","(.*)")+u),w=new RegExp(d+p.replace(/(.*)\.[^.]*$/,"$1").replace("*","(.*)")+u);for(const $ of t)(y.test($)||Ce.has(l.subKey)&&w.test($))&&g.push($);if(g.length===0){o.push(`Could not find entrypoint for \`${l.file}\``);continue}for(const $ of g)xe(i,$,a,c,l,s,!0);continue}const m=new RegExp(d+p+u);let v=t.find(g=>m.test(g));if(Ce.has(l.subKey)&&v===void 0){const g=new RegExp(d+p.replace(/(.*)\.[^.]*$/,"$1")+u);v=t.find(y=>g.test(y))}if(v===void 0){R(j(s.options.rootDir,l.file))||o.push(`Could not find entrypoint for \`${l.file}\``);continue}(v.endsWith(".ts")||v.endsWith(".cts")||v.endsWith(".mts"))&&R(v)&&Rt(s);const h=Oe(v.replace(oe,""));R(h+".cts")&&R(h+".mts")?(xe(i,h+".cts",a,c,{...l,type:"cjs"},s,!1),xe(i,h+".mts",a,c,{...l,type:"esm"},s,!1)):xe(i,v,a,c,l,s,!1)}return{entries:i,warnings:o}},"inferEntries");var Ea=Object.defineProperty,Sa=f((e,t)=>Ea(e,"name",{value:t,configurable:!0}),"o$3");const Oa=Sa((e,t)=>{const{publishConfig:s}=e;return s&&(s.bin&&(typeof s.bin=="object"||typeof s.bin=="string")&&(e.bin=s.bin),s.type&&typeof s.type=="string"&&s.type!==""&&(e.type=s.type),s.main&&typeof s.main=="string"&&s.main!==""&&(e.main=s.main),s.module&&typeof s.module=="string"&&s.module!==""&&(e.module=s.module),t===void 0&&s.types&&typeof s.types=="string"&&s.types!==""?e.types=s.types:t===void 0&&s.typings&&typeof s.typings=="string"&&s.typings!==""&&(e.typings=s.typings),s.exports&&typeof s.exports=="object"&&(e.exports=s.exports)),e},"overwriteWithPublishConfig");var Da=Object.defineProperty,Ca=f((e,t)=>Da(e,"name",{value:t,configurable:!0}),"t$2");const Pa={hooks:{"build:prepare":Ca(function(e){if(e.options.entries.length>0)return;const t=x(e.options.rootDir,e.options.sourceDir);if(!Ht(t))throw new Error("No 'src' directory found. Please provide entries manually.");const s=oo(t,{extensions:[],includeDirs:!1,includeSymlinks:!1});if(s.length===0)throw new Error("No source files found in 'src' directory. Please provide entries manually.");let o={...e.pkg};o.publishConfig&&(e.logger.info('Using publishConfig found in package.json, to override the default key-value pairs of "'+Object.keys(o.publishConfig).join(", ")+'".'),e.logger.debug(o.publishConfig),o=Oa(o,e.options.declaration));const n=ka(o,s,e);for(const r of n.warnings)O(e,r);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:",D(e.options.entries.map(r=>r.fileAlias?q(r.fileAlias)+" => "+q(r.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*")):q(r.input.replace(`${e.options.rootDir}/`,"").replace(/\/$/,"/*"))).join(", ")),X([e.options.emitESM&&"esm",e.options.emitCJS&&"cjs",e.options.declaration&&"dts"].filter(Boolean).map(r=>`[${r}]`).join(" ")))},"build:prepare")}};var Na=Object.defineProperty,Ia=f((e,t)=>Na(e,"name",{value:t,configurable:!0}),"t$1");const _a=Ia(async(e,t)=>{if(e==="auto")e=Pa;else{if(e==="none")return{};typeof e=="string"&&(e=await t.import(e)||{})}return typeof e=="function"&&(e=e()),e},"resolvePreset");var Ma=Object.defineProperty,Ta=f((e,t)=>Ma(e,"name",{value:t,configurable:!0}),"j");const Aa=Ta(async e=>{const t=e.options.jiti.transformOptions?.babel?.plugins,s=[],o=JSON.stringify({...e.options.jiti,alias:{...pt(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,r)=>{if(Array.isArray(n)){const[i,...l]=n;return s.push(i),"["+["plugin"+r,...l.map(c=>JSON.stringify(c))].join(", ")+"]"}return s.push(n),"plugin"+r}).join(",")+"]":"[]");for(const n of e.options.entries){const r=j(e.options.rootDir,e.options.outDir,n.name),i=Ao(e.jiti.esmResolve(n.input,{try:!0})??n.input),l=i.replace(oe,""),c=Me(i),a=ji(c);let p=[];try{p=await Ro(i,{extensions:at})}catch(u){O(e,`Cannot analyze ${i} for exports: ${u.toString()}`);return}const d=p.includes("default")||p.length===0;if(e.options.emitESM){const u=I(B(r),await vt("jiti",{conditions:["node","import"],url:import.meta.url})),m=l+".d.mts";se(`${r}.mjs`,a+['import { createJiti } from "'+u+'";',...s.map((v,h)=>"import plugin"+h+' from "'+v+'";'),"","const jiti = createJiti(import.meta.url, "+o+");","",'/** @type {import("'+m+'")} */','const _module = await jiti.import("'+i+'");',d?`
|
|
112
|
+
export default _module;`:"",...p.filter(v=>v!=="default").map(v=>`export const ${v} = _module.${v};`)].join(`
|
|
113
|
+
`)),e.options.declaration&&se(`${r}.d.mts`,'export * from "'+m+`";
|
|
114
|
+
`+(d?'export { default } from "'+m+'";':""))}if(e.options.emitCJS){const u=I(B(r),await vt("jiti",{conditions:["node","require"],url:import.meta.url})),m=l+".d.cts";se(`${r}.cjs`,a+['const { createJiti } = require("'+u+'");',...s.map((v,h)=>"const plugin"+h+" = require("+JSON.stringify(v)+")"),"","const jiti = createJiti(__filename, "+o+");","",'/** @type {import("'+m+'")} */','module.exports = jiti("'+i+'")'].join(`
|
|
115
|
+
`)),e.options.declaration&&se(r+".d.cts",'export * from "'+m+`";
|
|
116
|
+
`+(d?'export { default } from "'+m+'";':""))}a&&(await st(`${r}.cjs`),await st(`${r}.mjs`))}await e.hooks.callHook("rollup:done",e)},"createStub");var Ra=Object.defineProperty,dt=f((e,t)=>Ra(e,"name",{value:t,configurable:!0}),"i$3");const Fa=dt(e=>{const{message:t,name:s="Error",stack:o}=e;if(!o)return o;const n=`${s}: ${t}
|
|
117
|
+
`;return o.startsWith(n)?o.slice(n.length):o},"extractStack"),La=dt(e=>`
|
|
100
118
|
${e.replaceAll(/^\n|\n$/g,"")}
|
|
101
|
-
`,"normalizeCodeFrame"),
|
|
102
|
-
file: ${D(e.id+(e.loc?":"+e.loc.line+":"+e.loc.column:""))}`),e.frame&&(
|
|
103
|
-
`+
|
|
104
|
-
${t}`)},"enhanceRollupError");var Ja=Object.defineProperty,
|
|
119
|
+
`,"normalizeCodeFrame"),Js=dt(e=>{const t=Fa(e);let s=(e.plugin?`[${e.plugin}] `:"")+e.message;e.id&&(s+=`
|
|
120
|
+
file: ${D(e.id+(e.loc?":"+e.loc.line+":"+e.loc.column:""))}`),e.frame&&(s+=`
|
|
121
|
+
`+co(La(e.frame))),e.message=s,t!==void 0&&(e.stack=`${e.message}
|
|
122
|
+
${t}`)},"enhanceRollupError");var Ja=Object.defineProperty,Bs=f((e,t)=>Ja(e,"name",{value:t,configurable:!0}),"d$4");const _e="rollup-watch.json",Ft=Bs(({context:e,doOnSuccessCleanup:t,fileCache:s,mode:o,runBuilder:n,runOnsuccess:r,useCache:i,watcher:l})=>{const c="watcher:"+o;l.on("change",async(a,{event:p})=>{await t?.(),e.logger.info({message:`${D(I(".",a))} was ${p}d`,prefix:c})}),l.on("restart",()=>{e.logger.info({message:"Rebuilding ...",prefix:c})}),l.on("event",async a=>{switch(a.code){case"END":{e.logger.success({message:"Rebuild finished",prefix:c}),await r?.();break}case"BUNDLE_START":{e.logger.info({message:D("build started..."),prefix:c});break}case"BUNDLE_END":{await a.result.close(),i&&s.set(o==="bundle"?_e:"dts-"+_e,a.result.cache),e.logger.raw(`
|
|
105
123
|
⚡️ Build run in `+a.duration+`ms
|
|
106
124
|
|
|
107
|
-
`),await
|
|
108
|
-
└─ ${I(process.cwd(),p)}`);if(e.logger.info(a),Ft({context:e,doOnSuccessCleanup:
|
|
125
|
+
`),await n?.(!0);break}case"ERROR":{Js(a.error),e.logger.error({context:[a.error],message:"Rebuild failed: "+a.error.message,prefix:c});break}}})},"watchHandler"),Ba=Bs(async(e,t,s,o,n)=>{const r=await Rs(e,t);if(await e.hooks.callHook("rollup:options",e,r),Object.keys(r.input).length===0)return;let i=!0;(e.options.rollup.isolatedDeclarations||e.options.isolatedDeclarationTransformer||e.options.rollup.css)&&(i=!1),i&&(r.cache=t.get(_e)),e.options.rollup.watch&&typeof r.watch=="object"&&r.watch.include===void 0&&(r.watch={...r.watch,...e.options.rollup.watch},r.watch.include=[x(e.options.sourceDir,"**","*"),"package.json","packem.config.*"],Array.isArray(e.options.rollup.watch.include)?r.watch.include=[...r.watch.include,...e.options.rollup.watch.include]:e.options.rollup.watch.include&&r.watch.include.push(e.options.rollup.watch.include),r.watch.chokidar={cwd:e.options.rootDir,...r.watch.chokidar,ignored:["**/.git/**","**/node_modules/**","**/test-results/**",...r.watch.chokidar?.ignored??[]]});const l=ht(r);await e.hooks.callHook("rollup:watch",e,l);const c=[...Array.isArray(r.input)?r.input:typeof r.input=="string"?[r.input]:Object.keys(r.input??{})];let a="Starting watcher for entries:";for(const p of c)a+=X(`
|
|
126
|
+
└─ ${I(process.cwd(),p)}`);if(e.logger.info(a),Ft({context:e,doOnSuccessCleanup:n,fileCache:t,mode:"bundle",runBuilder:s,runOnsuccess:o,useCache:i,watcher:l}),e.options.declaration&&e.options.rollup.isolatedDeclarations&&e.options.isolatedDeclarationTransformer)e.logger.info({message:"Using isolated declaration transformer to generate declaration files...",prefix:"dts"});else if(e.options.declaration){const p=await Fs(e,t);i&&(p.cache=t.get("dts-"+_e)),await e.hooks.callHook("rollup:dts:options",e,p);const d=ht(p);await e.hooks.callHook("rollup:watch",e,d),Ft({context:e,fileCache:t,mode:"types",useCache:i,watcher:d})}},"watch");var Wa=Object.defineProperty,Va=f((e,t)=>Wa(e,"name",{value:t,configurable:!0}),"i$2");const za=Va((e,t,s,o)=>{try{let n={};const r=x(t,"keystore.json");o&&R(r)&&(n=it(r)),n[e]===void 0&&(n[e]=new Date().toISOString()),Te(r,n,{overwrite:!0})}catch(n){s.debug({context:n,message:n.message,prefix:"cache-key-store"})}},"createOrUpdateKeyStorage");var Ua=Object.defineProperty,Ws=f((e,t)=>Ua(e,"name",{value:t,configurable:!0}),"s$4");const qa=Ws(e=>{try{JSON.parse(e)}catch{return!1}return!0},"isJson");let Ka=class{static{f(this,"g")}static{Ws(this,"FileCache")}#e;#s;#r;#a=!0;#i=new Map;constructor(t,s,o,n){this.#e=t,this.#r=o,s===void 0?n.debug({message:"Could not create cache directory.",prefix:"file-cache"}):(this.#s=s,n.debug({message:"Cache path is: "+this.#s,prefix:"file-cache"}))}set isEnabled(t){this.#a=t}has(t,s){return!this.#a||this.#s===void 0?!1:R(this.getFilePath(t,s))}get(t,s){if(!this.#a||this.#s===void 0)return;const o=this.getFilePath(t,s);if(this.#i.has(o))return this.#i.get(o);if(!R(o))return;const n=Me(o);if(qa(n)){const r=JSON.parse(n);return this.#i.set(o,r),r}return this.#i.set(o,n),n}set(t,s,o){if(!this.#a||this.#s===void 0||s===void 0)return;const n=this.getFilePath(t,o);typeof s=="object"&&(s=JSON.stringify(s)),se(n,s,{overwrite:!0})}getFilePath(t,s){let o=t.replaceAll(Oe(this.#e),"");return o=o.replaceAll(":","-"),x(this.#s,this.#r,s?.replaceAll(":","-")??"",Oe(o))}};var Ga=Object.defineProperty,je=f((e,t)=>Ga(e,"name",{value:t,configurable:!0}),"l$4");const Ha=ne,Ya=je((e,t)=>{const{sideEffects:s}=t;let o;if(typeof s=="boolean")o=je(()=>s,"hasSideEffects");else if(Array.isArray(s))if(s.length<=0)o=je(()=>!1,"hasSideEffects");else{const n=s.map(r=>r.includes("/")?r:`**/${r}`);o=Ha(n,null,{resolve:e})}else o=je(()=>null,"hasSideEffects");return o},"getPackageSideEffect");var Ye,Lt;function Xa(){if(Lt)return Ye;Lt=1;var e=zo,t=e.spawn,s=e.exec;Ye=f(function(i,l,c){if(typeof l=="function"&&c===void 0&&(c=l,l=void 0),i=parseInt(i),Number.isNaN(i)){if(c)return c(new Error("pid must be a number"));throw new Error("pid must be a number")}var a={},p={};switch(a[i]=[],p[i]=1,process.platform){case"win32":s("taskkill /pid "+i+" /T /F",c);break;case"darwin":r(i,a,p,function(d){return t("pgrep",["-P",d])},function(){o(a,l,c)});break;default:r(i,a,p,function(d){return t("ps",["-o","pid","--no-headers","--ppid",d])},function(){o(a,l,c)});break}},"treeKill");function o(i,l,c){var a={};try{Object.keys(i).forEach(function(p){i[p].forEach(function(d){a[d]||(n(d,l),a[d]=1)}),a[p]||(n(p,l),a[p]=1)})}catch(p){if(c)return c(p);throw p}if(c)return c()}f(o,"killAll");function n(i,l){try{process.kill(parseInt(i,10),l)}catch(c){if(c.code!=="ESRCH")throw c}}f(n,"killPid");function r(i,l,c,a,p){var d=a(i),u="";d.stdout.on("data",function(h){var h=h.toString("ascii");u+=h});var m=f(function(v){if(delete c[i],v!=0){Object.keys(c).length==0&&p();return}u.match(/\d+/g).forEach(function(h){h=parseInt(h,10),l[i].push(h),l[h]=[],c[h]=1,r(h,l,c,a,p)})},"onClose");d.on("close",m)}return f(r,"buildProcessTree"),Ye}f(Xa,"requireTreeKill");var Qa=Xa();const Za=ms(Qa);var el=Object.defineProperty,Vs=f((e,t)=>el(e,"name",{value:t,configurable:!0}),"l$3");const tl=Vs(e=>process.platform==="win32"&&"cmd"in e&&"code"in e&&typeof e.cmd=="string"&&e.cmd.startsWith("taskkill")&&e.code===128,"isTaskKillCmdProcessNotFoundError"),sl=Vs(async({pid:e,signal:t})=>await new Promise((s,o)=>{if(!Number.isInteger(e)||e<=0){o(new Error("Invalid process ID"));return}Za(e,t,n=>{if(n&&!tl(n)){o(n);return}s()})}),"killProcess");var ol=Object.defineProperty,nl=f((e,t)=>ol(e,"name",{value:t,configurable:!0}),"n");const zs=nl(e=>{const t=x(e,"package.json");if(!R(t))throw new Error("package.json not found at "+t);return{packageJson:is(t),packageJsonPath:t}},"loadPackageJson");var rl=Object.defineProperty,il=f((e,t)=>rl(e,"name",{value:t,configurable:!0}),"r$3");const Jt=il((e,t)=>{if(e.warnings.size>0&&(t&&e.logger.raw(`
|
|
109
127
|
`),e.logger.warn(`Build is done with some warnings:
|
|
110
128
|
|
|
111
|
-
${[...e.warnings].map(
|
|
112
|
-
`)}`),e.options.failOnWarn))throw new Error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`.")},"logBuildErrors");var
|
|
113
|
-
- `+D(c)+(a.length>0?
|
|
129
|
+
${[...e.warnings].map(s=>`- ${s}`).join(`
|
|
130
|
+
`)}`),e.options.failOnWarn))throw new Error("Exiting with code (1). You can change this behavior by setting `failOnWarn: false`.")},"logBuildErrors");var al=Object.defineProperty,Us=f((e,t)=>al(e,"name",{value:t,configurable:!0}),"r$2");const Bt=Us(async(e,t)=>{if(typeof e.name!="string"){let s=Ae(e.input)?I(t.options.rootDir,e.input):J(e.input);s.startsWith("./")&&(s=s.slice(2)),e.name=s.replace(new RegExp(`^${t.options.sourceDir}/`),"").replace(oe,"")}if(!e.input)throw new Error(`Missing entry input: ${JSON.stringify(e)}`);ss(e.input)&&(e.input=j(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=j(t.options.rootDir,e.outDir??t.options.outDir)},"extendEntry"),ll=Us(async e=>{e.options.entries=e.options.entries.map(t=>typeof t=="string"?{input:t,isGlob:yt(t)}:{...t,exportKey:t.exportKey??new Set,isGlob:yt(t.input)});for(const t of e.options.entries.filter(s=>s.isGlob)){const{isGlob:s,...o}=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 i of e.options.rollup.watch.exclude)typeof i=="string"&&n.push(i)}const r=No([o.input],{cwd:e.options.rootDir,dot:!1,ignore:n,onlyFiles:!0});if(r.length===0)throw new Uo("No files found in the glob pattern: "+D(x(e.options.rootDir,o.input)));for(const i of r)e.options.entries.push({...o,input:j(e.options.rootDir,i)});e.options.entries.splice(e.options.entries.indexOf(t),1)}for(const t of e.options.entries.filter(s=>s.fileAlias===void 0))await Bt(t,e);for(const t of e.options.entries.filter(s=>s.fileAlias!==void 0))t.name=t.fileAlias,t.fileAlias=void 0,await Bt(t,e)},"prepareEntries");var cl=Object.defineProperty,pl=f((e,t)=>cl(e,"name",{value:t,configurable:!0}),"o$1");const ul=pl(e=>{if(e.options.validation?.packageJson?.dependencies===!1)return;const t=new Set,s=new Set(Object.keys(e.pkg?.dependencies??{})),o=new Set;for(const n of e.usedImports)s.delete(n),t.add(n);if(e.pkg?.dependencies)for(const n of Object.keys(e.pkg?.dependencies))s.delete(n);for(const n of t){const r=cs(n);!Ze(e.options.externals,n)&&!n.startsWith("chunks/")&&e.pkg?.dependencies?.[r]===void 0&&e.pkg?.peerDependencies?.[r]===void 0&&o.add(n)}s.size>0&&O(e,`Potential unused dependencies found: ${[...s].map(n=>D(n)).join(", ")}`),o.size>0&&O(e,`Potential implicit dependencies found: ${[...o].map(n=>D(n)).join(", ")}`)},"validateDependencies");var dl=Object.defineProperty,qs=f((e,t)=>dl(e,"name",{value:t,configurable:!0}),"i$1");const fl=qs((e,t)=>qo(e,t)<=e.length/3||t.includes(e),"isSimilar"),ml=qs((e,t)=>{const s=e.toLowerCase();return t.filter(o=>fl(o.toLowerCase(),s))},"findAlternatives");var gl=Object.defineProperty,Wt=f((e,t)=>gl(e,"name",{value:t,configurable:!0}),"r$1");const hl=Wt(e=>{const{options:t}=e;if(t.validation?.packageJson?.exports===!1)return;const s=t.validation?.packageJson,o=new Set([t.declaration&&s?.types?e.pkg.types:"",t.declaration&&s?.types?e.pkg.typings:"",...t.dtsOnly||s?.bin===!1?[""]:typeof e.pkg.bin=="string"?[e.pkg.bin]:Object.values(e.pkg.bin??{}),t.dtsOnly&&s?.main===!1?"":e.pkg.main,t.dtsOnly&&s?.module===!1?"":e.pkg.module,...s?.exports===!1?[]:ut(e.pkg.exports,e.pkg.type==="module"?"esm":"cjs",t.declaration).map(l=>t.dtsOnly?l.subKey==="types"?l.file:void 0:l.file)].filter(Boolean).map(l=>l&&j(t.rootDir,l.replace(/\/[^*/]*\*[^\n\r/\u2028\u2029]*(?:[\n\r\u2028\u2029][^*/]*\*[^\n\r/\u2028\u2029]*)*(?:\/.*)?$/,"")))),n=[];for(const l of o)l&&!l.includes("*")&&!Ht(l)&&n.push(l.replace(`${t.rootDir}/`,""));const r=Wt(l=>I(t.rootDir,j(t.outDir,l)),"rPath"),i=e.buildEntries.filter(l=>!l.chunk).map(l=>r(l.path));if(n.length>0){let l="Potential missing or wrong package.json files:";for(const c of n){const a=ml(c,i);l+=`
|
|
131
|
+
- `+D(c)+(a.length>0?po` (did you mean ${a.map(p=>`"${p}"`).join(", ")}?)`:"")}O(e,l)}},"validatePackageEntries");var yl=Object.defineProperty,vl=f((e,t)=>yl(e,"name",{value:t,configurable:!0}),"l$1");const bl=vl(e=>{const{options:{validation:t},pkg:s}=e;s.name===void 0&&t?.packageJson?.name!==!1&&O(e,"The 'name' field is missing in your package.json. Please provide a valid package name."),t?.packageJson?.files!==!1&&(s.files===void 0?O(e,"The 'files' field is missing in your package.json. Add the files to be included in the package."):s.files.length===0?O(e,"The 'files' field in your package.json is empty. Please specify the files to be included in the package."):s.files.some(r=>r.includes(e.options.outDir))||O(e,`The 'files' field in your package.json is missing the '${e.options.outDir}' directory. Ensure the output directory is included.`));const o=s.type==="commonjs"||s.type===void 0,n=s.type==="module";if(o?(t?.packageJson?.main!==!1&&(s.main===void 0&&O(e,"The 'main' field is missing in your package.json. This field should point to your main entry file."),s.main?.includes(".mjs")&&O(e,"The 'main' field in your package.json should not use a '.mjs' extension for CommonJS modules.")),t?.packageJson?.module!==!1&&(s.module===void 0&&e.options.emitESM&&O(e,"The 'module' field is missing in your package.json, but you are emitting ES modules."),s.module&&s.main&&s.module===s.main&&O(e,`Conflict detected: The 'module' and 'main' fields both point to '${s.module}'. Please ensure they refer to different module types.`),e.options.emitESM&&s.module?.includes(".cjs")&&O(e,"The 'module' field in your package.json should not use a '.cjs' extension for ES modules."))):n&&(s.exports===void 0&&!e.options.emitCJS?t?.packageJson?.exports!==!1&&O(e,"The 'exports' field is missing in your package.json. Define module exports explicitly."):e.options.emitCJS&&(t?.packageJson?.main!==!1&&s.main===void 0&&O(e,"The 'main' field is missing in your package.json. This field is needed when emitting CommonJS modules."),t?.packageJson?.module!==!1&&(s.module===void 0&&O(e,"The 'module' field is missing in your package.json. This field is necessary when emitting ES modules."),s.module?.includes(".cjs")&&O(e,"The 'module' field should not use a '.cjs' extension for ES modules."),s.module&&s.main&&s.module===s.main&&O(e,`Conflict detected: The 'module' and 'main' fields both point to '${s.module}'. Please ensure they refer to different module types.`)),t?.packageJson?.exports!==!1&&s.exports===void 0&&O(e,"The 'exports' field is missing in your package.json. This field is required for defining explicit exports."))),s.exports,t?.packageJson?.bin!==!1){if(typeof s.bin=="string"&&s.bin.includes(o?".mjs":".cjs"))O(e,`The 'bin' field in your package.json should not use a ${o?".mjs":".cjs"} extension for ${o?"CommonJS":"ES modules"} binaries.`);else if(typeof s.bin=="object")for(const[r,i]of Object.entries(s.bin))i&&i.includes(o?".mjs":".cjs")&&O(e,`The 'bin.${r}' field in your package.json should not use a ${o?".mjs":".cjs"} extension for ${o?"CommonJS":"ES modules"} binaries.`)}if(e.options.declaration){let r=!0;s.type==="module"&&(r=!!s.main?.endsWith(".cjs")),s.types===void 0&&s.typings===void 0&&r&&t?.packageJson?.types!==!1&&O(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")&&r&&t?.packageJson?.typesVersions!==!1&&(s.typesVersions===void 0||Object.keys(s.typesVersions).length===0)&&O(e,"No 'typesVersions' field found in your package.json. Consider adding this field, or change the declaration option to 'node16' or 'false'.")}},"validatePackageFields");var wl=Object.defineProperty,$l=f((e,t)=>wl(e,"name",{value:t,configurable:!0}),"i");const xl=$l(e=>{const{packageJson:t}=zs(e.options.rootDir);e.pkg=t,ul(e),bl(e),hl(e)},"validator");var jl=Object.defineProperty,kl=f((e,t)=>jl(e,"name",{value:t,configurable:!0}),"a");const El=/^[^a-z_@#~]|[^\w/@#~-]|@\/|#\/|~\//i,Sl=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"]),Vt=kl(e=>{if(!Array.isArray(e)&&e!==null)for(const[t,s]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(El.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(Sl.has(t))throw new Error(`Alias name "${t}" is a reserved keyword and cannot be used.`);const o=j(s);if(!R(o))throw new Error(`Target path "${o}" for alias "${t}" does not exist.`)}},"validateAliasEntries");var Ol=Object.defineProperty,A=f((e,t)=>Ol(e,"name",{value:t,configurable:!0}),"u$1");const Dl=A(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"),Cl=A((e,t,s,o,n,r,i,l,c)=>{const a=Dl(c?.config.compilerOptions?.jsx),p=ho(r,n,i,{alias:{},browserTargets:go(),cjsInterop:!1,clean:!0,debug:o,declaration:void 0,emitCJS:void 0,emitESM:void 0,entries:[],externals:[...mt.builtinModules,...mt.builtinModules.map(d=>`node:${d}`)],failOnWarn:!0,fileCache:!0,jiti:{alias:{},debug:o,interopDefault:!0},minify:s===K,name:(l.name??"").split("/").pop()??"default",outDir:c?.config.compilerOptions?.outDir??"dist",rollup:{alias:{},cjsInterop:{addDefaultProperty:!1},commonjs:{extensions:[".mjs",".js",".json",".node",".cjs"],ignoreTryCatch:!0,preserveSymlinks:!0,transformMixedEsModules:!1},css:{autoModules:!0,extensions:[".css",".pcss",".postcss",".sss"],namedExports:!0},dts:{compilerOptions:{baseUrl:c?.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:le,jsx:a,jsxDev:c?.config.compilerOptions?.jsx==="react-jsxdev",jsxFactory:c?.config.compilerOptions?.jsxFactory,jsxFragment:c?.config.compilerOptions?.jsxFragmentFactory,jsxImportSource:c?.config.compilerOptions?.jsxImportSource,jsxSideEffects:!0,keepNames:!0,sourcesContent:!1,target:c?.config.compilerOptions?.target,treeShaking:!0,tsconfigRaw:c?.config},isolatedDeclarations:{exclude:le,ignoreErrors:!1,include:fe},json:{preferConst:!0},license:{dependenciesTemplate:A((d,u,m)=>`
|
|
114
132
|
# Licenses of bundled dependencies
|
|
115
|
-
The published ${
|
|
133
|
+
The published ${m} artifact additionally contains code with the following licenses:
|
|
116
134
|
`+(d.length>0?`${d.join(", ")}
|
|
117
135
|
|
|
118
136
|
`:`
|
|
119
137
|
`)+`# Bundled dependencies:
|
|
120
|
-
`+u,"dependenciesTemplate"),dtsTemplate:A((d,u,
|
|
138
|
+
`+u,"dependenciesTemplate"),dtsTemplate:A((d,u,m)=>`
|
|
121
139
|
# Licenses of bundled types
|
|
122
|
-
The published ${
|
|
140
|
+
The published ${m} artifact additionally contains code with the following licenses:
|
|
123
141
|
`+(d.length>0?`${d.join(", ")}
|
|
124
142
|
|
|
125
143
|
`:`
|
|
126
144
|
`)+`# Bundled types:
|
|
127
|
-
`+u,"dtsTemplate")},node10Compatibility:{},patchTypes:{},polyfillNode:{},preserveDirectives:{exclude:le,include:
|
|
145
|
+
`+u,"dtsTemplate")},node10Compatibility:{},patchTypes:{},polyfillNode:{},preserveDirectives:{exclude:le,include:fe},preserveDynamicImports:!0,raw:{exclude:le,include:[/\.(md|txt|htm|html|data)$/]},replace:{objectGuards:!0,preventAssignment:!0},resolve:{allowExportsFolderMapping:!1,exportConditions:["module-sync"],extensions:at,preferBuiltins:!1},shebang:{replace:!1,shebang:"#!/usr/bin/env node"},shim:{exclude:le,include:fe},sucrase:{disableESTransforms:!0,enableLegacyBabel5ModuleInterop:!1,enableLegacyTypeScriptModuleInterop:c?.config.compilerOptions?.esModuleInterop===!1,include:fe,injectCreateRequireForImportRequire:!1,preserveDynamicImport:!0,production:s===K,...c?.config.compilerOptions?.jsx&&["react","react-jsx","react-jsxdev"].includes(c.config.compilerOptions.jsx)?{jsxFragmentPragma:c.config.compilerOptions.jsxFragmentFactory,jsxImportSource:c.config.compilerOptions.jsxImportSource,jsxPragma:c.config.compilerOptions.jsxFactory,jsxRuntime:a,transforms:["typescript","jsx",...c.config.compilerOptions.esModuleInterop?["imports"]:[]]}:{transforms:["typescript",...c?.config.compilerOptions?.esModuleInterop?["imports"]:[]]}},swc:{include:fe,inlineSourcesContent:!1,inputSourceMap:!1,isModule:!0,jsc:{experimental:{keepImportAttributes:!0},externalHelpers:!1,keepClassNames:!0,loose:!0,parser:{decorators:c?.config.compilerOptions?.experimentalDecorators,syntax:c?"typescript":"ecmascript",[c?"tsx":"jsx"]:!0},target:c?.config.compilerOptions?.target?.toLowerCase(),transform:{decoratorMetadata:c?.config.compilerOptions?.emitDecoratorMetadata,decoratorVersion:"2022-03",legacyDecorator:c?.config.compilerOptions?.experimentalDecorators,react:{development:s!==K,pragma:c?.config.compilerOptions?.jsxFactory,pragmaFrag:c?.config.compilerOptions?.jsxFragmentFactory,runtime:a,throwIfNamespace:!0},treatConstEnumAsEnum:c?.config.compilerOptions?.preserveConstEnums,useDefineForClassFields:c?.config.compilerOptions?.useDefineForClassFields}},module:{ignoreDynamic:!0,importInterop:"none",preserveImportMeta:!0,strict:!1,strictMode:!1,type:"es6"}},treeshake:{moduleSideEffects:Ya(t,l),preset:"recommended",propertyReadSideEffects:!0},visualizer:{},watch:{chokidar:{ignoreInitial:!0,ignorePermissionErrors:!0},clearScreen:!0,exclude:le}},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:l.name??"unknown",pretty:!0,readme:"none",showConfig:o,tsconfig:c?.path}});if(!p.transformerName){const d=new Map([...Object.entries(l.dependencies??{}),...Object.entries(l.devDependencies??{})]);let u="0.0.0";if(d.has("esbuild"))p.transformerName="esbuild",u=d.get("esbuild");else if(d.has("@swc/core"))p.transformerName="swc",u=d.get("@swc/core");else if(d.has("sucrase"))p.transformerName="sucrase",u=d.get("sucrase");else throw new Error("Unknown transformer, check your transformer options or install one of the supported transformers: esbuild, swc, sucrase");e.info("Using "+D("rollup ")+vo),e.info({message:"Using "+D(p.transformerName)+" "+u,prefix:"transformer"})}return p.rollup.resolve&&p.rollup.resolve.preferBuiltins===!0&&(p.rollup.polyfillNode=!1,e.debug("Disabling polyfillNode because preferBuiltins is set to true")),p.browserTargets&&p.browserTargets.length>0&&e.debug("Using browser targets: "+p.browserTargets.join(", ")),l.dependencies&&p.externals.push(...Object.keys(l.dependencies)),l.peerDependencies&&p.externals.push(...Object.keys(l.peerDependencies)),l.optionalDependencies&&p.externals.push(...Object.keys(l.optionalDependencies)),Vt(p.alias),p.rollup.alias&&p.rollup.alias.entries&&Vt(p.rollup.alias.entries),p},"generateOptions"),Pl=A(async(e,t,s,o,n,r,i,l,c,a)=>{const p=await _a(i.preset??r.preset??"auto",a),d=Cl(e,t,o,n,r,i,p,l,c);no(x(d.rootDir,d.outDir));const u={buildEntries:[],dependencyGraphMap:new Map,environment:o,hooks:yo(),jiti:Xt(d.rootDir,d.jiti),logger:e,mode:s,options:d,pkg:l,tsconfig:c,usedImports:new Set,warnings:new Set};p.hooks&&u.hooks.addHooks(p.hooks),r.hooks&&u.hooks.addHooks(r.hooks),i.hooks&&u.hooks.addHooks(i.hooks),await u.hooks.callHook("build:prepare",u),u.options.emitESM===void 0&&u.logger.info("Emitting of ESM bundles, is disabled."),u.options.emitCJS===void 0&&u.logger.info("Emitting of CJS bundles, is disabled."),u.options.minify&&u.logger.info("Minification is enabled, the output will be minified");const m=l.dependencies?.typescript!==void 0||l.devDependencies?.typescript!==void 0;if(u.options.declaration&&u.tsconfig===void 0&&m)throw new Error("Cannot build declaration files without a tsconfig.json");return m?u.options.declaration===!1&&u.logger.info({message:"Generation of declaration files are disabled.",prefix:"dts"}):(u.options.declaration=!1,u.logger.info({message:"Typescript is not installed. Generation of declaration files are disabled.",prefix:"dts"})),u.options.declaration&&u.logger.info("Using typescript version: "+D(l.devDependencies?.typescript??l.dependencies?.typescript??"unknown")),u.options.declaration&&(l.dependencies?.typescript||l.devDependencies?.typescript)&&!u.tsconfig?.config.compilerOptions?.isolatedModules&&u.logger.warn(`'compilerOptions.isolatedModules' is not enabled in tsconfig.
|
|
128
146
|
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.
|
|
129
|
-
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
|
|
147
|
+
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 ll(u),u},"createContext"),Nl=A(async e=>{const t=[];if(e.options.clean)for(const s of new Set(e.options.entries.map(o=>o.outDir).filter(Boolean).sort()))s===e.options.rootDir||s===e.options.sourceDir||e.options.rootDir.startsWith(s.endsWith("/")?s:`${s}/`)||t.some(o=>s.startsWith(o))||(t.push(s),e.logger.info(`Cleaning dist directory: \`./${I(e.options.rootDir,s)}\``),await ro(s))},"cleanDistributionDirectories"),Il=A(async(e,t,s)=>{if(e&&R(x(e,"keystore1.json"))){const o=it(x(e,"keystore.json")),n=Gt(e,{withFileTypes:!0}).filter(i=>i.isDirectory());let r=s;for(const i of n)o[i.name]||(await ao(x(e,i.name),{force:!0,recursive:!0}),r&&t.raw(`
|
|
130
148
|
|
|
131
|
-
`),t.info({message:"Removing "+i.name+" file cache, the cache key is not used anymore.",prefix:"file-cache"}),
|
|
132
|
-
${
|
|
133
|
-
`),await b.hooks.callHook("builder:before",H,b);const C=Date.now(),
|
|
134
|
-
⚡️ `+H+" run in "+
|
|
149
|
+
`),t.info({message:"Removing "+i.name+" file cache, the cache key is not used anymore.",prefix:"file-cache"}),r=!1)}},"removeOldCacheFolders"),_l=A(e=>{switch(e){case"jit":return"Stubbing";case"watch":return"Watching";case"tsdoc":return"Generating TSDoc";default:return"Building"}},"getMode"),Ml=A(async(e,t,s,o,n={})=>{const{configPath:r,debug:i,tsconfigPath:l,...c}=n;o.wrapAll(),e=j(Ve.cwd(),e),o.debug("Root directory:",e);const{packageJson:a,packageJsonPath:p}=zs(e);o.debug("Using package.json found at",p);let d;if(l){const g=x(e,l);if(!await nt(g))throw new Error("tsconfig.json not found at "+g);d={config:fo(g),path:g},o.info("Using tsconfig settings at",g)}else if(a.dependencies?.typescript||a.devDependencies?.typescript)try{d=await mo(e),o.debug("Using tsconfig settings found at",d.path)}catch{o.info("No tsconfig.json or jsconfig.json found.")}const u=uo("@visulima/packem",{cwd:e});let m=!1,v,h;try{const g=await as(e,r??""),y=Xt(e,{debug:i});let w=await y.import(g,{default:!0,try:!0})||{};typeof w=="function"&&(w=await w(s,t)),o.debug("Using packem config found at",x(e,g));const $=Q(JSON.stringify({version:a.version,...a.dependencies,...a.devDependencies,...a.peerDependencies,...a.peerDependenciesMeta,browser:a.browser,eNode:a.engines?.node,exports:a.exports,main:a.main,module:a.module,type:a.type,types:a.types}))+Q(JSON.stringify(w));u&&za($,u,o);const E=new Ka(e,u,$,o),b=await Pl(o,e,t,s,i??!1,c,w,a,d,y);E.isEnabled=b.options.fileCache,b.logger.info(D(_l(t)+" "+b.options.name)),b.logger.debug({context:b.options.entries,message:`${q("Root dir:")} ${b.options.rootDir}
|
|
150
|
+
${q("Entries:")}`}),await Nl(b);const P=A(async L=>{for await(const[H,S]of Object.entries(b.options.builder??{})){b.logger.raw(`
|
|
151
|
+
`),await b.hooks.callHook("builder:before",H,b);const C=Date.now(),k=A(()=>gt(Math.floor(Date.now()-C)),"getBuilderDuration");await S(b,u,E,m),await b.hooks.callHook("builder:done",H,b),b.logger.raw(`
|
|
152
|
+
⚡️ `+H+" run in "+k()),L&&b.logger.raw(`
|
|
135
153
|
|
|
136
|
-
`)}},"runBuilder"),_=A(async()=>{if(
|
|
137
|
-
⚡️ Build run in `+ie()),await P(),await W(),
|
|
138
|
-
`),
|
|
139
|
-
isolatedDeclarationTransformer`),(
|
|
154
|
+
`)}},"runBuilder"),_=A(async()=>{if(v!==void 0)await sl({pid:v.pid,signal:c.killSignal??w.killSignal??"SIGTERM"});else if(h!==void 0)try{await h()}catch(L){throw new Error("onSuccess function cleanup failed: "+L.message,{cause:L})}v=void 0,h=void 0},"doOnSuccessCleanup"),W=A(async()=>{if(typeof b.options.onSuccess=="function")try{h=await b.options.onSuccess()}catch(L){throw new Error("onSuccess function failed: "+L.message,{cause:L})}else if(typeof b.options.onSuccess=="string"){const L=b.options.onSuccessTimeout??3e4;if(v=bo(b.options.onSuccess,[],{nodeOptions:{shell:!0,stdio:"inherit",timeout:L}}),await v,v.exitCode&&v.exitCode!==0)throw new Error("onSuccess script failed with exit code "+v.exitCode+". Check the output above for details.")}},"runOnsuccess"),F=Date.now(),ie=A(()=>gt(Math.floor(Date.now()-F)),"getDuration");if(t==="watch"){if(b.options.rollup.watch===!1)throw new Error("Rollup watch is disabled. You should check your packem.config file.");await Ba(b,E,P,W,_),Jt(b,!1);return}t==="jit"?(await Aa(b),await b.hooks.callHook("build:done",b)):(m=await ga(b,E),await b.hooks.callHook("validate:before",b),xl(b),await b.hooks.callHook("validate:done",b),Jt(b,m)),b.logger.raw(`
|
|
155
|
+
⚡️ Build run in `+ie()),await P(),await W(),Ve.on("SIGINT",async()=>{await _()}),Ve.on("SIGTERM",async()=>{await _()})}catch(g){throw o.raw(`
|
|
156
|
+
`),Js(g),g}finally{o.restoreAll(),await Il(u,o,m)}},"packem");var Tl=Object.defineProperty,ke=f((e,t)=>Tl(e,"name",{value:t,configurable:!0}),"o");const Al=ke(e=>{e.addCommand({description:"Demonstrate options required",execute:ke(async({logger:t,options:s})=>{let o="build";s.watch?o="watch":s.jit&&(o="jit");const n={};let r;if(Se.NODE_ENV&&[ye,K].includes(Se.NODE_ENV)&&(r=Se.NODE_ENV),s.env)for(const i of s.env)if(i.key==="NODE_ENV"){if(r)throw new Error("NODE_ENV was already set, this can't be overridden.");r=i.value}else n["process.env."+i.key]=JSON.stringify(i.value);r===void 0&&(s.production?r=K:s.development&&(r=ye));try{await Ml(s.dir,o,r,t,{analyze:s.analyze,cjsInterop:s.cjsInterop,clean:s.clean,configPath:s.config??void 0,debug:s.debug,dtsOnly:s.dtsOnly,killSignal:s.killSignal,minify:s.minify===void 0?r===K:s.minify,onSuccess:s.onSuccess,rollup:{esbuild:{target:s.target},license:{path:s.license},metafile:s.metafile,replace:{values:n}},sourcemap:s.analyze||s.sourcemap,tsconfigPath:s.tsconfig??void 0,validation:s.validation===!1?{packageJson:{bin:!1,dependencies:!1,exports:!1,files:!1,main:!1,module:!1,name:!1,types:!1,typesVersions:!1}}:{},...s.typedoc?{typedoc:{format:"html"}}:{}})}catch(i){t.error(i),Qs(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:ke(t=>{const[s,o]=t.split("=");return{key:s,value:o}},"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},{description:"Execute command after successful build, specially useful for watch mode",name:"onSuccess",type:String},{description:'Signal to kill child process, "SIGTERM" or "SIGKILL"',name:"killSignal",type:ke(t=>{if(t==="SIGTERM"||t==="SIGKILL")return t;throw new Error("Invalid kill signal. Use 'SIGTERM' or 'SIGKILL'.")},"type")}]})},"createBuildCommand");var Rl=Object.defineProperty,Ee=f((e,t)=>Rl(e,"name",{value:t,configurable:!0}),"m");const Fl=Ee(e=>{e.addCommand({description:"Initialize packem configuration",execute:Ee(async({logger:t,options:s})=>{if(Zs("Welcome to packem setup"),R(x(s.dir,"packem.config.ts"))){t.info("Packem project already initialized, you can use `packem build` to build your project");return}const o=j(zt(),s.dir??"."),n=x(o,"package.json");if(!R(n))throw new Error("No package.json found in the directory");const r=is(n),i=[];r.dependencies&&i.push(...Object.keys(r.dependencies)),r.devDependencies&&i.push(...Object.keys(r.devDependencies));const l=!!(r.devDependencies?.typescript??r.dependencies?.typescript),c=[];if(s.typescript===void 0&&!l?(s.typescript=await U({message:"Do you want to install TypeScript?"}),s.typescript&&c.push("typescript@latest")):ft.message("TypeScript version "+(r.devDependencies?.typescript??r.dependencies?.typescript)+" is already installed"),!R(x(o,"tsconfig.json"))){const h=await U({message:"Do you want to use generate a tsconfig.json?"}),g=await U({message:"Do you want to run your code in the DOM?"});if(h){const y=Qe();y.start("Generating tsconfig.json"),Te(x(o,"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:g?["es2022","dom","dom.iterable"]:["es2022"]}}),y.stop("")}}if(i.includes("esbuild")?s.transformer="esbuild":i.includes("@swc/core")?s.transformer="swc":i.includes("sucrase")&&(s.transformer="sucrase"),s.transformer===void 0?(s.transformer=await Z({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"}]}),s.transformer&&!i.includes(s.transformer)&&await U({message:"Do you want to install "+s.transformer+"?"})&&c.push(s.transformer==="swc"?"@swc/core":s.transformer)):ft.message("Transformer "+s.transformer+" is already installed."),s.isolatedDeclarationTransformer===void 0&&(s.isolatedDeclarationTransformer=await U({message:"Do you want to use an isolated declaration types?",initialValue:!1})),s.isolatedDeclarationTransformer===void 0&&(s.isolatedDeclarationTransformer=await Z({message:"Pick a isolated declaration transformer",options:[{label:"Typescript",value:"typescript"},{label:"swc",value:"swc"},{label:"OXC",value:"oxc"},{label:"None",value:null}]}),s.isolatedDeclarationTransformer!==null)){let h;switch(s.isolatedDeclarationTransformer){case"typescript":{h="typescript";break}case"swc":{h="@swc/core";break}case"oxc":{h="oxc-transform";break}default:eo("Invalid isolated declaration transformer")}h!==void 0&&!i.includes(h)&&await U({message:"Do you want to install "+h+"?"})&&c.push(h)}s.css===void 0&&(s.css=await U({message:"Do you want to use css in your project?",initialValue:!1}));const a=[];if(s.css){const h=await Z({message:"Pick a css loader",options:[{label:"PostCSS",value:"postcss"},{label:"Lightning CSS",value:"lightningcss"}]});a.push(h);let g=await Ut({message:"Pick your loaders",options:[{label:"Sass",value:"sass"},{label:"Stylus",value:"stylus"},{label:"Less",value:"less"}],required:!1});if(g.includes("sass")){const y=await Z({message:"Pick a sass loader",options:[{label:"Sass embedded",value:"sass-embedded",hint:"recommended"},{label:"Sass",value:"sass"},{label:"Node Sass",value:"node-sass",hint:"legacy"}]});y!=="sass"&&(g=g.filter(w=>w!=="sass"),g.push(y))}if(a.push(...g),await U({message:'Do you want to install "'+a.join('", "')+'"?'}))for(const y of a)c.push(...ls[y]);a.push("sourceMap")}s.cssMinifier===void 0&&(s.cssMinifier=await U({message:"Do you want to minify your css?",initialValue:!1}));let p;s.cssMinifier&&(p=await Z({message:"Pick a css minifier",options:[{label:"CSSNano",value:"cssnano"},{label:"Lightning CSS",value:"lightningcss"}]}),a.includes("lightningcss")||await U({message:'Do you want to install "'+p+'"?'})&&c.push(p));let d="",u="";if(s.isolatedDeclarationTransformer&&(u+=`,
|
|
157
|
+
isolatedDeclarationTransformer`),(s.css||s.cssMinifier)&&(u+=`,
|
|
140
158
|
rollup: {
|
|
141
|
-
css: {`),
|
|
142
|
-
loaders: [
|
|
143
|
-
minifier: `+
|
|
159
|
+
css: {`),s.css){const h=a.map(g=>((g==="sass-embedded"||g==="node-sass")&&(g="sass"),`${g}Loader`)).join(", ");u+=`
|
|
160
|
+
loaders: [${h}],`}if(s.cssMinifier&&p&&(u+=`
|
|
161
|
+
minifier: `+p+"Minifier,"),(s.css||s.cssMinifier)&&(u+=`
|
|
144
162
|
}
|
|
145
|
-
}`),
|
|
146
|
-
`),
|
|
147
|
-
`;
|
|
148
|
-
`),
|
|
149
|
-
import transformer from "@visulima/packem/transformer/${
|
|
150
|
-
${
|
|
163
|
+
}`),l||r.type==="module"){let h="";if(s.isolatedDeclarationTransformer&&(h+=`import isolatedDeclarationTransformer from "@visulima/packem/dts/isolated/transformer/${s.isolatedDeclarationTransformer}";
|
|
164
|
+
`),s.css)for(let g of a)(g==="sass-embedded"||g==="node-sass")&&(g="sass"),h+=`import ${g}Loader from "@visulima/packem/css/loader/${g.toLowerCase()}";
|
|
165
|
+
`;s.cssMinifier&&p&&(h+=`import ${p}Minifier from "@visulima/packem/css/minifier/${p.toLowerCase()}";
|
|
166
|
+
`),d=`import { defineConfig } from "@visulima/packem/config";
|
|
167
|
+
import transformer from "@visulima/packem/transformer/${s.transformer}";
|
|
168
|
+
${h}
|
|
151
169
|
export default defineConfig({
|
|
152
|
-
transformer${
|
|
170
|
+
transformer${u}
|
|
153
171
|
});
|
|
154
|
-
`}else{let
|
|
155
|
-
`),
|
|
156
|
-
`;
|
|
157
|
-
`),
|
|
158
|
-
const transformer = require("@visulima/packem/transformer/${
|
|
159
|
-
${
|
|
172
|
+
`}else{let h="";if(s.isolatedDeclarationTransformer&&(h+=`const isolatedDeclarationTransformer = require("@visulima/packem/dts/isolated/transformer/${s.isolatedDeclarationTransformer}");
|
|
173
|
+
`),s.css)for(let g of a)(g==="sass-embedded"||g==="node-sass")&&(g="sass"),h+=`const ${g}Loader = require("@visulima/packem/css/loader/${g.toLowerCase()}");
|
|
174
|
+
`;s.cssMinifier&&p&&(h+=`const ${p}Minifier = require("@visulima/packem/css/minifier/${p.toLowerCase()}");
|
|
175
|
+
`),d=`const { defineConfig } = require("@visulima/packem/config");
|
|
176
|
+
const transformer = require("@visulima/packem/transformer/${s.transformer}");
|
|
177
|
+
${h}
|
|
160
178
|
module.exports = defineConfig({
|
|
161
|
-
transformer${
|
|
179
|
+
transformer${u}
|
|
162
180
|
});
|
|
163
|
-
`}const
|
|
181
|
+
`}const m=Qe(),v=l?"ts":"js";c.length>0&&(m.start("Installing packages"),await Xe(c,{cwd:o,dev:!0,silent:!0}),m.stop("Installed packages")),m.start("Creating packem.config."+v),se(x(o,"packem.config."+v),d),m.stop("Created packem.config."+v),to("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:Ee(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:Ee(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 CSS",name:"css",type:Boolean},{description:"Use CSS minifier",name:"css-minifier",type:Boolean},{Description:"Use TypeScript",name:"typescript",type:Boolean}]})},"createInitCommand"),Be=new Hs("packem",{logger:{reporters:[new Ys({error:{hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0}})],scope:"packem"},packageName:Ko,packageVersion:Go});Fl(Be);Al(Be);Zo(Be);Be.run({shouldExitProcess:!1});
|