@visulima/packem 2.0.0-alpha.87 → 2.0.0-alpha.88

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 CHANGED
@@ -1,3 +1,35 @@
1
+ ## @visulima/packem [2.0.0-alpha.88](https://github.com/visulima/packem/compare/@visulima/packem@2.0.0-alpha.87...@visulima/packem@2.0.0-alpha.88) (2026-06-12)
2
+
3
+ ### Features
4
+
5
+ * **packem:** run preserve-directives/jsx/pure plugins under rolldown + native rolldown watch ([3087190](https://github.com/visulima/packem/commit/3087190f011f85e881c7a2dc5b0579360741ac67))
6
+
7
+ ### Bug Fixes
8
+
9
+ * **packem-rollup:** handle first-position attribute in jsx-remove-attributes ([5b36f50](https://github.com/visulima/packem/commit/5b36f504c4548cf2f85e6293cb0cbb94dc01d769))
10
+ * **packem:** enable chunk-per-export splitting under rolldown ([8eb4e67](https://github.com/visulima/packem/commit/8eb4e679ed044487d3d1c1a86956ca5ee856501b))
11
+ * **packem:** keep watch mode alive when onSuccess fails ([a413637](https://github.com/visulima/packem/commit/a413637503dc156f8f30d81efb47921658fe1b20))
12
+ * resolve package audit findings across the monorepo ([2800d68](https://github.com/visulima/packem/commit/2800d68c00de2ff488b51ad90179731b929b9642))
13
+ * **rollup-plugin-css:** survive rollup cache restores so watch mode can keep its cache ([8de1655](https://github.com/visulima/packem/commit/8de1655c56085be0bab7ddeddd70ad8a25c18da1))
14
+
15
+ ### Code Refactoring
16
+
17
+ * **packem:** extract shared dependency-cache load/persist helpers ([00e2e79](https://github.com/visulima/packem/commit/00e2e7954bc0dae1c633ba8c570c793849a4ffff))
18
+
19
+ ### Tests
20
+
21
+ * **packem:** accept backtick-quoted inlined values in package-json-exports ([084196e](https://github.com/visulima/packem/commit/084196e5f1f238d114b88eaaf589e7c6f48ada88))
22
+ * **packem:** fail fast when updating snapshots without PACKEM_TEST_BUNDLER ([a0a490c](https://github.com/visulima/packem/commit/a0a490cbb04c2aff973fc81fd79b3a2cf4ecf0e2))
23
+ * **packem:** regenerate rolldown snapshots to match native rolldown output ([15331f4](https://github.com/visulima/packem/commit/15331f4513bba3dddb574cfa7b0aaa1302d16fab)), closes [/#region](https://github.com/visulima///issues/region)
24
+
25
+
26
+ ### Dependencies
27
+
28
+ * **@visulima/packem-share:** upgraded to 1.0.0-alpha.50
29
+ * **@visulima/rollup-plugin-css:** upgraded to 1.0.0-alpha.53
30
+ * **@visulima/rollup-plugin-dts:** upgraded to 1.0.0-alpha.34
31
+ * **@visulima/packem-rollup:** upgraded to 1.0.0-alpha.73
32
+
1
33
  ## @visulima/packem [2.0.0-alpha.87](https://github.com/visulima/packem/compare/@visulima/packem@2.0.0-alpha.86...@visulima/packem@2.0.0-alpha.87) (2026-06-04)
2
34
 
3
35
  ### Bug Fixes
@@ -0,0 +1 @@
1
+ var m=Object.defineProperty;var u=(r,e)=>m(r,"name",{value:e,configurable:!0});import{transformAsync as g}from"@babel/core";var d=Object.defineProperty,l=u((r,e)=>d(r,"name",{value:e,configurable:!0}),"o");const f=/\.tsx?$/,y=/['"]use memo['"]/,_="babel-options",w="__packem_babel_missing_options__",b=l(r=>r.find(e=>e==="babel-plugin-react-compiler"||Array.isArray(e)&&e[0]==="babel-plugin-react-compiler"),"getReactCompilerPlugin"),A=l((r,e)=>{if(r.length===0)return;const s=b(r);if(!(!s||!Array.isArray(s))&&s[1]?.compilationMode==="annotation"&&!y.test(e)){const o=r.indexOf(s);o!==-1&&r.splice(o,1)}},"filterReactCompilerByAnnotation"),v=l(async(r,e,{filename:s,generatorOpts:o,sourceFileName:h,...t})=>{let i=[];t.plugins&&Array.isArray(t.plugins)&&(i=[...t.plugins]),i.length>0&&A(i,r);const a=[];(e.endsWith(".jsx")||e.endsWith(".tsx"))&&a.push("jsx"),f.test(e)&&a.push("typescript");const n=t.parserOpts?.plugins;n&&Array.isArray(n)&&a.unshift(...n);const c=[...new Set(a)],p=await g(r,{...t,filename:e,generatorOpts:{...o,decoratorsBeforeExport:!0,importAttributesKeyword:"with"},parserOpts:{...t.parserOpts,allowAwaitOutsideFunction:!0,plugins:c.length>0?c:[],sourceType:"module"},plugins:i.length>0?i:[],sourceFileName:e});if(p?.code)return{code:p.code,map:p.map??void 0}},"transformCode");export{w as N,_ as O,v as t};
@@ -1 +1 @@
1
- var t=Object.defineProperty;var e=(r,o)=>t(r,"name",{value:o,configurable:!0});import f from"workerpool";import{t as m}from"../../packem_shared/transform-code-Cd2HSMcx.js";var n=Object.defineProperty,s=e((r,o)=>n(r,"name",{value:o,configurable:!0}),"s");const c=s(async(r,o,a)=>m(r,o,a),"transform");f.worker({transform:c});
1
+ var s=Object.defineProperty;var n=(r,o)=>s(r,"name",{value:o,configurable:!0});import i from"workerpool";import{N as m,t as c}from"../../packem_shared/transform-code-KNtowoK1.js";var p=Object.defineProperty,v=n((r,o)=>p(r,"name",{value:o,configurable:!0}),"t");const f=new Map,d=v(async(r,o,t,e)=>{e!==void 0&&f.set(t,e);const a=f.get(t);if(a===void 0)throw new Error(m);return c(r,o,a)},"transform");i.worker({transform:d});
@@ -1,3 +1,3 @@
1
- import{P as h,T as w,f as k,q as $}from"../../packem_shared/create-or-update-key-storage-CRDW-Kwa.js";import{w as m}from"../../packem_shared/utils-Bsoe7qJG.js";import{readdirSync as E}from"node:fs";import{replaceContentWithinMarker as j}from"@visulima/packem-share";import{Application as A}from"typedoc";const P=(e,o,t,r,n)=>{const s=E(e,{withFileTypes:!0}).filter(a=>a.isFile());let i="";for(const a of s)a.name==="README.md"&&o>1||(i+=h(m(e,a.name)).replaceAll(`<!-- ${t}`,`<!-- _REPLACE_${t}`).replaceAll("<!-- ${marker}",`<!-- _REPLACE_\\${t}`));if(i==="")return;const c=h(r),p=j(c,t,`
2
- ${i}`);if(!p){n.error({message:`Could not find the typedoc marker: <!-- ${t} --><!-- /${t} --> in ${r}`,prefix:"typedoc"});return}c!==p&&w(r,p.replaceAll(`<!-- _REPLACE_${t}`,`<!-- ${t}`).replaceAll(`<!-- _REPLACE_\\${t}`,"<!-- ${marker}"),{overwrite:!0})},v=(e,o,t,r)=>{if(e==="inline"&&t===void 0)throw new Error("The `readmePath` option is required when using the `inline` format.");if(e!=="inline"&&typeof t=="string"&&r.warn({message:"The `readmePath` option is only used when the `inline` format is used.",prefix:"typedoc"}),e==="json"&&!o?.endsWith(".json"))throw new Error(o===void 0?"The `jsonFileName` option is required when using the `json` format.":"The `jsonFileName` option must end with `.json`.");e!=="json"&&typeof o=="string"&&r.warn({message:"The `jsonFileName` option is only used when the `json` format is used.",prefix:"typedoc"})},C=async(e,o,t,r)=>{if(o.length===0)return;const{format:n,jsonFileName:s,marker:i,output:c,plugin:p,readmePath:a,...f}=e;v(n,s,a,r);const y=o.map(g=>g.input),u=p??[];u.push("typedoc-plugin-rename-defaults"),(n==="inline"||n==="markdown")&&u.push("typedoc-plugin-markdown");const l=await A.bootstrapWithPlugins({...f,compilerOptions:{allowJs:!0,declaration:!1,declarationMap:!1,esModuleInterop:!0,module:99,moduleResolution:100,noEmit:!0,noImplicitAny:!1,skipLibCheck:!0,sourceMap:!1,target:99,...f.compilerOptions},entryPoints:y,hideGenerator:!0,out:t,plugin:u,...n==="inline"?{hideBreadcrumbs:!0,hidePageHeader:!0,navigation:!1,outputFileStrategy:"modules",useCodeBlocks:!0}:{}},[]),d=await l.convert();if(d){if(n==="json")await l.generateJson(d,s);else if(n==="html")await l.generateDocs(d,t);else if(await l.generateOutputs(d),n==="inline"){if(i===void 0)throw new Error("The `marker` option is required when using the `inline` format.");P(t,o.length,i,a,r)}}},T=e=>e.logger,L=async(e,o,t,r)=>{if(e.options.typedoc&&e.options.typedoc.format!==void 0){const n=T(e);let s="unknown";e.pkg.dependencies?.typedoc?s=e.pkg.dependencies.typedoc:e.pkg.devDependencies?.typedoc&&(s=e.pkg.devDependencies.typedoc),o&&k("typedoc",o,n,!0),r&&n.raw(`
1
+ import{P as h,T as w,f as k,q as $}from"../../packem_shared/create-or-update-key-storage-DHOKZmnD.js";import{w as m}from"../../packem_shared/utils-Bsoe7qJG.js";import{readdirSync as E}from"node:fs";import{replaceContentWithinMarker as j}from"@visulima/packem-share";import{Application as A}from"typedoc";const P=(e,o,t,r,n)=>{const s=E(e,{withFileTypes:!0}).filter(a=>a.isFile());let i="";for(const a of s)a.name==="README.md"&&o>1||(i+=h(m(e,a.name)).replaceAll(`<!-- ${t}`,`<!-- _REPLACE_${t}`).replaceAll("<!-- ${marker}",`<!-- _REPLACE_\\${t}`));if(i==="")return;const c=h(r),p=j(c,t,`
2
+ ${i}`);if(!p){n.error({message:`Could not find the typedoc marker: <!-- ${t} --><!-- /${t} --> in ${r}`,prefix:"typedoc"});return}c!==p&&w(r,p.replaceAll(`<!-- _REPLACE_${t}`,`<!-- ${t}`).replaceAll(`<!-- _REPLACE_\\${t}`,"<!-- ${marker}"),{overwrite:!0})},v=(e,o,t,r)=>{if(e==="inline"&&t===void 0)throw new Error("The `readmePath` option is required when using the `inline` format.");if(e!=="inline"&&typeof t=="string"&&r.warn({message:"The `readmePath` option is only used when the `inline` format is used.",prefix:"typedoc"}),e==="json"&&!o?.endsWith(".json"))throw new Error(o===void 0?"The `jsonFileName` option is required when using the `json` format.":"The `jsonFileName` option must end with `.json`.");e!=="json"&&typeof o=="string"&&r.warn({message:"The `jsonFileName` option is only used when the `json` format is used.",prefix:"typedoc"})},C=async(e,o,t,r)=>{if(o.length===0)return;const{format:n,jsonFileName:s,marker:i,output:c,plugin:p,readmePath:a,...f}=e;v(n,s,a,r);const y=o.map(g=>g.input),u=p??[];u.push("typedoc-plugin-rename-defaults"),(n==="inline"||n==="markdown")&&u.push("typedoc-plugin-markdown");const l=await A.bootstrapWithPlugins({...f,compilerOptions:{allowJs:!0,declaration:!1,declarationMap:!1,esModuleInterop:!0,module:99,moduleResolution:100,noEmit:!0,noImplicitAny:!1,skipLibCheck:!0,sourceMap:!1,target:99,...f.compilerOptions},entryPoints:y,hideGenerator:!0,out:t,plugin:u,...n==="inline"?{hideBreadcrumbs:!0,hidePageHeader:!0,navigation:!1,outputFileStrategy:"modules",useCodeBlocks:!0}:{}},[]),d=await l.convert();if(d){if(n==="json")await l.generateJson(d,s);else if(n==="html")await l.generateDocs(d,t);else if(await l.generateOutputs(d),n==="inline"){if(i===void 0)throw new Error("The `marker` option is required when using the `inline` format.");P(t,o.length,i,a,r)}}},T=e=>e.logger,L=async(e,o,t,r)=>{if(e.options.typedoc&&e.options.typedoc.format!==void 0){const n=T(e);let s="unknown";e.pkg.dependencies?.typedoc?s=e.pkg.dependencies.typedoc:e.pkg.devDependencies?.typedoc&&(s=e.pkg.devDependencies.typedoc),o&&k("typedoc",o,n),r&&n.raw(`
3
3
  `),n.info({message:`Using ${$("typedoc")} ${s} to generate reference documentation`,prefix:"typedoc"}),await e.hooks.callHook("typedoc:before",e);let i=e.options.rootDir;e.options.typedoc.output?i=e.options.typedoc.output:e.options.typedoc.format==="inline"&&o?i=m(o,"typedoc"):e.options.typedoc.format!=="json"&&(i=m(i,"api-docs")),await C(e.options.typedoc,e.options.entries,i,n),await e.hooks.callHook("typedoc:done",e)}};export{L as default};
package/dist/cli/index.js CHANGED
@@ -1,39 +1,39 @@
1
1
  #!/usr/bin/env node
2
- import{createCerebro as Q}from"@visulima/cerebro";import Z from"@visulima/cerebro/logger/pail";import{r as A,S as q,f as ee,e as te,g as se,i as ae,B as ne,T as ie,j as B,v as oe,l as re,d as ce}from"../packem_shared/index-BKMfJDaY.js";import v,{cwd as L,exit as le}from"node:process";import{installPackage as h}from"@antfu/install-pkg";import{spinner as E,confirm as f,cancel as O,select as g,multiselect as G,intro as K,log as P,outro as U,isCancel as W}from"@clack/prompts";import{a as de,b as ue,q as pe,s as N,T as me,S as fe}from"../packem_shared/create-or-update-key-storage-CRDW-Kwa.js";import{P as D,w as b}from"../packem_shared/utils-Bsoe7qJG.js";import ge from"magic-string";import{exec as ye}from"tinyexec";import{PRODUCTION_ENV as F,DEVELOPMENT_ENV as we}from"@visulima/packem-share/constants";import{createJiti as be}from"jiti";import{writeFile as z,readFile as he}from"node:fs/promises";import{existsSync as V}from"node:fs";import{parseEnv as T}from"node:util";import{createInterface as ve}from"node:readline/promises";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
2
+ import{createCerebro as Q}from"@visulima/cerebro";import Z from"@visulima/cerebro/logger/pail";import{e as q,S as G,m as ee,f as te,g as se,i as ae,B as ie,T as ne,j as T,v as oe,l as re,d as ce}from"../packem_shared/index-C47QUEeX.js";import k,{cwd as O,exit as le}from"node:process";import{installPackage as h}from"@antfu/install-pkg";import{spinner as D,confirm as f,cancel as B,select as g,multiselect as K,intro as U,log as E,outro as W,isCancel as F}from"@clack/prompts";import{a as de,b as ue,q as pe,s as N,T as me,S as fe}from"../packem_shared/create-or-update-key-storage-DHOKZmnD.js";import{P as L,w as b}from"../packem_shared/utils-Bsoe7qJG.js";import ge from"magic-string";import{exec as ye}from"tinyexec";import{PRODUCTION_ENV as z,DEVELOPMENT_ENV as we}from"@visulima/packem-share/constants";import{createJiti as be}from"jiti";import{writeFile as J,readFile as he}from"node:fs/promises";import{existsSync as V}from"node:fs";import{parseEnv as R}from"node:util";import{createInterface as ve}from"node:readline/promises";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
3
3
  const require = __cjs_mod__.createRequire(import.meta.url);
4
- const J={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","@csstools/css-parser-algorithms","@csstools/css-tokenizer","@csstools/postcss-slow-plugins","icss-utils","@visulima/css-style-inject"],sass:["sass"],"sass-embedded":["sass-embedded"],stylus:["stylus"],tailwindcss:["@tailwindcss/node","@tailwindcss/oxide","tailwindcss"]},ke=/defineConfig\s*\(\s*\{/,$e=/preset:\s*['"][^'"]+['"]/,Se=["typedoc","typedoc-plugin-markdown","typedoc-plugin-rename-defaults"],Ce=["@babel/core","@babel/preset-react"],je=["react","react-dom"],xe=["@babel/core","babel-preset-solid"],Pe=["solid-js"],Ee=["@babel/core","@babel/preset-react","babel-plugin-transform-hook-names"],De=["preact"],Ie=["unplugin-vue"],Me=["vue"],Ne=["rollup-plugin-svelte"],Le=["svelte"],k=(t,e,a)=>t.includes(`preset: '${e}'`)||t.includes(`preset: "${e}"`)||t.includes(`preset: '${e}',`)||t.includes(`preset: "${e}",`)||t.includes(a)||t.includes(`@visulima/packem/config/preset/${e}`),$=(t,e)=>{const{logger:a,magic:s,packemConfig:n}=t,i=ke.exec(n);if(i?.index!==void 0){const r=i.index+i[0].length;if(n.includes("preset:")){const o=$e.exec(n);if(o)s.replace(o[0],`preset: '${e}'`);else throw a.warn(`A preset already exists in the config. Please manually set it to '${e}'.`),new Error("Preset exists but is not a string")}else s.appendLeft(r,`
5
- preset: '${e}',`)}else if(n.includes("transformer:"))s.replace("transformer:",`preset: '${e}',
6
- transformer:`);else{const r=n.indexOf("{");r!==-1&&s.appendLeft(r+1,`
7
- preset: '${e}',`)}},Oe=async t=>{try{return((await ye("git",["status","--porcelain"],{nodeOptions:{cwd:t,stdio:["pipe","pipe","pipe"]}})).stdout?.trim().length??0)>0}catch{return!1}},_=async t=>{const e=b(t,"package.json"),a=await q(e,{resolveCatalogs:!0});return!!(a.devDependencies?.typescript??a.dependencies?.typescript)},Ve=async t=>{const e=await _(t),a=[...je],s=[...Ce];return e?s.push("@types/react","@types/react-dom"):await f({initialValue:!1,message:"Do you want to use TypeScript?"})&&s.push("typescript","@types/react","@types/react-dom"),{devPackages:s,packages:a}},S=async(t,e,a)=>{const{rootDirectory:s,spinner:n}=t;n.start("Installing packages"),await h(a,{cwd:s,dev:!1,silent:!0}),await h(e,{cwd:s,dev:!0,silent:!0}),n.stop("Installed packages")},Be=async t=>{const{logger:e,magic:a,packemConfig:s,packemConfigFormat:n,rootDirectory:i,spinner:r,transformerReplaceKey:o,transformerSearchKey:c}=t;if(s.includes("typedoc: typedocBuilder")||s.includes("@visulima/packem/builder/typedoc")){e.warn("Typedoc has already been added to the packem config.");return}n==="cjs"?a.prepend(`const typedocBuilder = require("@visulima/packem/builder/typedoc");
4
+ const _={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","@csstools/css-parser-algorithms","@csstools/css-tokenizer","@csstools/postcss-slow-plugins","icss-utils","@visulima/css-style-inject"],sass:["sass"],"sass-embedded":["sass-embedded"],stylus:["stylus"],tailwindcss:["@tailwindcss/node","@tailwindcss/oxide","tailwindcss"]},ke=/defineConfig\s*\(\s*\{/,$e=/preset:\s*['"][^'"]+['"]/,Se=["typedoc","typedoc-plugin-markdown","typedoc-plugin-rename-defaults"],Ce=["@babel/core","@babel/preset-react"],je=["react","react-dom"],xe=["@babel/core","babel-preset-solid"],Pe=["solid-js"],Ee=["@babel/core","@babel/preset-react","babel-plugin-transform-hook-names"],De=["preact"],Le=["unplugin-vue"],Ie=["vue"],Me=["rollup-plugin-svelte"],Ne=["svelte"],$=(t,e,a)=>t.includes(`preset: '${e}'`)||t.includes(`preset: "${e}"`)||t.includes(`preset: '${e}',`)||t.includes(`preset: "${e}",`)||t.includes(a)||t.includes(`@visulima/packem/config/preset/${e}`),S=(t,e)=>{const{logger:a,magic:s,packemConfig:i}=t,n=ke.exec(i);if(n?.index!==void 0){const r=n.index+n[0].length;if(i.includes("preset:")){const o=$e.exec(i);if(o)s.replace(o[0],`preset: '${e}'`);else throw a.warn(`A preset already exists in the config. Please manually set it to '${e}'.`),new Error("Preset exists but is not a string")}else s.appendLeft(r,`
5
+ preset: '${e}',`)}else if(i.includes("transformer:"))s.replace("transformer:",`preset: '${e}',
6
+ transformer:`);else{const r=i.indexOf("{");r!==-1&&s.appendLeft(r+1,`
7
+ preset: '${e}',`)}},Oe=async t=>{try{return((await ye("git",["status","--porcelain"],{nodeOptions:{cwd:t,stdio:["pipe","pipe","pipe"]}})).stdout?.trim().length??0)>0}catch{return!1}},H=async t=>{const e=b(t,"package.json"),a=await G(e,{resolveCatalogs:!0});return!!(a.devDependencies?.typescript??a.dependencies?.typescript)},Be=async t=>{const e=await H(t),a=[...je],s=[...Ce];return e?s.push("@types/react","@types/react-dom"):await f({initialValue:!1,message:"Do you want to use TypeScript?"})&&s.push("typescript","@types/react","@types/react-dom"),{devPackages:s,packages:a}},C=async(t,e,a)=>{const{rootDirectory:s,spinner:i}=t;i.start("Installing packages"),await h(a,{cwd:s,dev:!1,silent:!0}),await h(e,{cwd:s,dev:!0,silent:!0}),i.stop("Installed packages")},Ve=async t=>{const{logger:e,magic:a,packemConfig:s,packemConfigFormat:i,rootDirectory:n,spinner:r,transformerReplaceKey:o,transformerSearchKey:l}=t;if(s.includes("typedoc: typedocBuilder")||s.includes("@visulima/packem/builder/typedoc")){e.warn("Typedoc has already been added to the packem config.");return}i==="cjs"?a.prepend(`const typedocBuilder = require("@visulima/packem/builder/typedoc");
8
8
  `):a.prepend(`import typedocBuilder from "@visulima/packem/builder/typedoc";
9
9
  `),s.includes("builder: {")?a.replace("builder: {",`builder: {
10
10
  typedoc: typedocBuilder,
11
- `):a.replace(c,`${o}
11
+ `):a.replace(l,`${o}
12
12
  builder: {
13
13
  typedoc: typedocBuilder,
14
- },`),e.info("Adding typedoc dependencies..."),r.start("Installing packages"),await h(Se,{cwd:i,dev:!0,silent:!0}),r.stop("Installed packages"),e.success(`
15
- Typedoc added!`)},Te=async t=>{const{logger:e,packemConfig:a}=t;if(k(a,"react","createReactPreset")){e.warn("React preset has already been added to the packem config.");return}$(t,"react");const{devPackages:s,packages:n}=await Ve(t.rootDirectory);e.info("Adding React dependencies..."),await S(t,s,n),e.success(`
16
- React preset added!`)},Re=async t=>{const{logger:e,packemConfig:a}=t;if(k(a,"solid","createSolidPreset")){e.warn("Solid preset has already been added to the packem config.");return}$(t,"solid"),e.info("Adding Solid dependencies..."),await S(t,xe,Pe),e.success(`
17
- Solid preset added!`)},Ae=async t=>{const e=await _(t),a=[...De],s=[...Ee];return e?s.push("@types/preact"):await f({initialValue:!1,message:"Do you want to use TypeScript?"})&&s.push("typescript","@types/preact"),{devPackages:s,packages:a}},qe=async t=>{const{logger:e,packemConfig:a}=t;if(k(a,"preact","createPreactPreset")){e.warn("Preact preset has already been added to the packem config.");return}$(t,"preact");const{devPackages:s,packages:n}=await Ae(t.rootDirectory);e.info("Adding Preact dependencies..."),await S(t,s,n),e.success(`
18
- Preact preset added!`)},Ge=async t=>{const{logger:e,packemConfig:a}=t;if(k(a,"vue","createVuePreset")){e.warn("Vue preset has already been added to the packem config.");return}$(t,"vue"),e.info("Adding Vue dependencies..."),await S(t,Ie,Me),e.success(`
19
- Vue preset added!`)},Ke=async t=>{const{logger:e,packemConfig:a}=t;if(k(a,"svelte","createSveltePreset")){e.warn("Svelte preset has already been added to the packem config.");return}$(t,"svelte"),e.info("Adding Svelte dependencies..."),await S(t,Ne,Le),e.success(`
20
- Svelte preset added!`)},Ue=async()=>{const t=[],e=await g({message:"Pick a css loader",options:[{label:"PostCSS",value:"postcss"},{hint:"experimental",label:"Lightning CSS",value:"lightningcss"},{hint:"Tailwind Css Oxide",label:"Tailwind CSS",value:"tailwindcss"}]});if(t.push(e),e!=="tailwindcss"){let a=await G({message:"Pick extra loaders",options:[{label:"Sass",value:"sass"},{label:"Stylus",value:"stylus"},{label:"Less",value:"less"}],required:!1});if(a.includes("sass")){const s=await g({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"}]});s!=="sass"&&(a=a.filter(n=>n!=="sass"),a.push(s))}t.push(...a)}return{cssLoaders:t,mainCssLoader:e}},We=async(t,e,a,s)=>{if(!await f({initialValue:!1,message:"Do you want to minify your css?"}))return;const n=await g({message:"Pick a css minifier",options:[{label:"CSSNano",value:"cssnano"},{label:"Lightning CSS",value:"lightningcss"}]});return a.includes("lightningcss")||s.push(n),e==="cjs"?t.prepend(`const ${n}Minifier = require("@visulima/packem/css/minifier/${n.toLowerCase()}");
21
- `):t.prepend(`import ${n}Minifier from "@visulima/packem/css/minifier/${n.toLowerCase()}";
22
- `),n},Fe=async t=>{const{logger:e,magic:a,packemConfig:s,packemConfigFormat:n,transformerReplaceKey:i,transformerSearchKey:r}=t;if(s.includes("css: {")||s.includes("@visulima/packem/css")){e.warn("Css loaders have already been added to the packem config.");return}const{cssLoaders:o,mainCssLoader:c}=await Ue(),l=[];for(const p of o)l.push(...J[p]);c!=="tailwindcss"&&o.push("sourceMap");for(const p of o){const d=p==="sass-embedded"||p==="node-sass"?"sass":p;n==="cjs"?a.prepend(`const ${d}Loader = require("@visulima/packem/css/loader/${d.toLowerCase()}");
23
- `):a.prepend(`import ${d}Loader from "@visulima/packem/css/loader/${d.toLowerCase()}";
24
- `)}const u=await We(a,n,o,l),m=o.map(p=>p==="sass-embedded"||p==="node-sass"?"sass":`${p}Loader`).join(", ");s.includes("rollup: {")?a.replace("rollup: {",`rollup: {
25
- css: {${u?`
26
- minifier: ${u}Minifier,`:""}
14
+ },`),e.info("Adding typedoc dependencies..."),r.start("Installing packages"),await h(Se,{cwd:n,dev:!0,silent:!0}),r.stop("Installed packages"),e.success(`
15
+ Typedoc added!`)},Te=async t=>{const{logger:e,packemConfig:a}=t;if($(a,"react","createReactPreset")){e.warn("React preset has already been added to the packem config.");return}S(t,"react");const{devPackages:s,packages:i}=await Be(t.rootDirectory);e.info("Adding React dependencies..."),await C(t,s,i),e.success(`
16
+ React preset added!`)},Re=async t=>{const{logger:e,packemConfig:a}=t;if($(a,"solid","createSolidPreset")){e.warn("Solid preset has already been added to the packem config.");return}S(t,"solid"),e.info("Adding Solid dependencies..."),await C(t,xe,Pe),e.success(`
17
+ Solid preset added!`)},Ae=async t=>{const e=await H(t),a=[...De],s=[...Ee];return e?s.push("@types/preact"):await f({initialValue:!1,message:"Do you want to use TypeScript?"})&&s.push("typescript","@types/preact"),{devPackages:s,packages:a}},qe=async t=>{const{logger:e,packemConfig:a}=t;if($(a,"preact","createPreactPreset")){e.warn("Preact preset has already been added to the packem config.");return}S(t,"preact");const{devPackages:s,packages:i}=await Ae(t.rootDirectory);e.info("Adding Preact dependencies..."),await C(t,s,i),e.success(`
18
+ Preact preset added!`)},Ge=async t=>{const{logger:e,packemConfig:a}=t;if($(a,"vue","createVuePreset")){e.warn("Vue preset has already been added to the packem config.");return}S(t,"vue"),e.info("Adding Vue dependencies..."),await C(t,Le,Ie),e.success(`
19
+ Vue preset added!`)},Ke=async t=>{const{logger:e,packemConfig:a}=t;if($(a,"svelte","createSveltePreset")){e.warn("Svelte preset has already been added to the packem config.");return}S(t,"svelte"),e.info("Adding Svelte dependencies..."),await C(t,Me,Ne),e.success(`
20
+ Svelte preset added!`)},Ue=async()=>{const t=[],e=await g({message:"Pick a css loader",options:[{label:"PostCSS",value:"postcss"},{hint:"experimental",label:"Lightning CSS",value:"lightningcss"},{hint:"Tailwind Css Oxide",label:"Tailwind CSS",value:"tailwindcss"}]});if(t.push(e),e!=="tailwindcss"){let a=await K({message:"Pick extra loaders",options:[{label:"Sass",value:"sass"},{label:"Stylus",value:"stylus"},{label:"Less",value:"less"}],required:!1});if(a.includes("sass")){const s=await g({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"}]});s!=="sass"&&(a=a.filter(i=>i!=="sass"),a.push(s))}t.push(...a)}return{cssLoaders:t,mainCssLoader:e}},We=async(t,e,a,s)=>{if(!await f({initialValue:!1,message:"Do you want to minify your css?"}))return;const i=await g({message:"Pick a css minifier",options:[{label:"CSSNano",value:"cssnano"},{label:"Lightning CSS",value:"lightningcss"}]});return a.includes("lightningcss")||s.push(i),e==="cjs"?t.prepend(`const ${i}Minifier = require("@visulima/packem/css/minifier/${i.toLowerCase()}");
21
+ `):t.prepend(`import ${i}Minifier from "@visulima/packem/css/minifier/${i.toLowerCase()}";
22
+ `),i},Fe=async t=>{const{logger:e,magic:a,packemConfig:s,packemConfigFormat:i,transformerReplaceKey:n,transformerSearchKey:r}=t;if(s.includes("css: {")||s.includes("@visulima/packem/css")){e.warn("Css loaders have already been added to the packem config.");return}const{cssLoaders:o,mainCssLoader:l}=await Ue(),c=[];for(const u of o)c.push(..._[u]);l!=="tailwindcss"&&o.push("sourceMap");for(const u of o){const p=u==="sass-embedded"||u==="node-sass"?"sass":u;i==="cjs"?a.prepend(`const ${p}Loader = require("@visulima/packem/css/loader/${p.toLowerCase()}");
23
+ `):a.prepend(`import ${p}Loader from "@visulima/packem/css/loader/${p.toLowerCase()}";
24
+ `)}const d=await We(a,i,o,c),m=o.map(u=>u==="sass-embedded"||u==="node-sass"?"sass":`${u}Loader`).join(", ");s.includes("rollup: {")?a.replace("rollup: {",`rollup: {
25
+ css: {${d?`
26
+ minifier: ${d}Minifier,`:""}
27
27
  loaders: [${m}],
28
28
  },
29
- `):a.replace(r,`${i}
29
+ `):a.replace(r,`${n}
30
30
  rollup: {
31
- css: {${u?`
32
- minifier: ${u}Minifier,`:""}
31
+ css: {${d?`
32
+ minifier: ${d}Minifier,`:""}
33
33
  loaders: [${m}],
34
34
  },
35
- },`),t.spinner.start("Installing packages"),await h(l,{cwd:t.rootDirectory,dev:!0,silent:!0}),t.spinner.stop("Installed packages"),e.success(`
36
- CSS loaders added!`)},ze=t=>{t.addCommand({argument:{description:"Add a packem feature to your project",name:"feature",required:!0},description:"Add a optional packem feature to your project",execute:async({argument:e,logger:a,options:s})=>{const n=a,i=E(),r=D(L(),typeof s.dir=="string"?s.dir:".");let o;try{o=await A(r,s.config)}catch{n.error("Could not find a packem config file, please run `packem init` first.");return}if(await Oe(r)&&!await f({initialValue:!1,message:"Git repository has uncommitted changes. Do you want to proceed?"})){O("Operation cancelled.");return}const c=await de(o,{buffer:!1}),l=c.includes("import")?"esm":"cjs",u=new ge(c),m=" transformer,",p=c.includes(" transformer,")?" transformer,":" transformer",d={logger:n,magic:u,packemConfig:c,packemConfigFormat:l,rootDirectory:r,spinner:i,transformerReplaceKey:m,transformerSearchKey:p};e.includes("typedoc")&&await Be(d),e.includes("react")&&await Te(d),e.includes("solid")&&await Re(d),e.includes("preact")&&await qe(d),e.includes("vue")&&await Ge(d),e.includes("svelte")&&await Ke(d),e.includes("css")&&await Fe(d),await ue(o,u.toString(),{overwrite:!0})},name:"add",options:[{defaultValue:".",description:"The directory to build",name:"dir",type:String},{description:"Use a custom config file",name:"config",type:String}]})},Je=(t,e)=>{if(t==="rolldown")return`// Generated by \`packem\` first-run setup. See https://packem.dev for full options.
35
+ },`),t.spinner.start("Installing packages"),await h(c,{cwd:t.rootDirectory,dev:!0,silent:!0}),t.spinner.stop("Installed packages"),e.success(`
36
+ CSS loaders added!`)},ze=t=>{t.addCommand({argument:{description:"Add a packem feature to your project",name:"feature",required:!0},description:"Add a optional packem feature to your project",execute:async({argument:e,logger:a,options:s})=>{const i=a,n=D(),r=L(O(),typeof s.dir=="string"?s.dir:".");let o;try{o=await q(r,s.config)}catch{i.error("Could not find a packem config file, please run `packem init` first.");return}if(await Oe(r)&&!await f({initialValue:!1,message:"Git repository has uncommitted changes. Do you want to proceed?"})){B("Operation cancelled.");return}const l=await de(o,{buffer:!1}),c=l.includes("import")?"esm":"cjs",d=new ge(l),m=" transformer,",u=l.includes(" transformer,")?" transformer,":" transformer",p={logger:i,magic:d,packemConfig:l,packemConfigFormat:c,rootDirectory:r,spinner:n,transformerReplaceKey:m,transformerSearchKey:u};e.includes("typedoc")&&await Ve(p),e.includes("react")&&await Te(p),e.includes("solid")&&await Re(p),e.includes("preact")&&await qe(p),e.includes("vue")&&await Ge(p),e.includes("svelte")&&await Ke(p),e.includes("css")&&await Fe(p),await ue(o,d.toString(),{overwrite:!0})},name:"add",options:[{defaultValue:".",description:"The directory to build",name:"dir",type:String},{description:"Use a custom config file",name:"config",type:String}]})},Je=(t,e)=>{if(t==="rolldown")return`// Generated by \`packem\` first-run setup. See https://packem.dev for full options.
37
37
  import { defineConfig } from "@visulima/packem/config";
38
38
 
39
39
  export default defineConfig({
@@ -49,35 +49,35 @@ export default defineConfig({
49
49
  declaration: true,
50
50
  transformer,
51
51
  });
52
- `},_e=async()=>{const t=await g({initialValue:"rollup",message:"Which bundler do you want to use?",options:[{hint:"stable, full feature set, supports DTS",label:"rollup",value:"rollup"},{hint:"experimental, fast — falls back to rollup for DTS",label:"rolldown",value:"rolldown"}]});if(W(t))throw O("Setup cancelled."),new Error("Packem setup was cancelled.");return t},He=async()=>{const t=await g({initialValue:"esbuild",message:"Which transformer do you want to use?",options:[{hint:"fast, widely used",label:"esbuild",value:"esbuild"},{hint:"fastest, Rust-based",label:"oxc",value:"oxc"},{hint:"TypeScript-aware, Rust-based",label:"swc",value:"swc"},{hint:"minimal, JS-based",label:"sucrase",value:"sucrase"}]});if(W(t))throw O("Setup cancelled."),new Error("Packem setup was cancelled.");return t},Xe=async(t,e)=>{if(t.length===0)return;const a=E();a.start(`Installing ${t.join(", ")}`);try{await h(t,{cwd:e,dev:!0,silent:!0}),a.stop(`Installed ${t.join(", ")}`)}catch(s){throw a.stop(`Failed to install ${t.join(", ")}`),s}},Ye=async t=>{if(await ee(t))return;if(!(process.stdout.isTTY&&!process.env.CI)){const i=await te(["rollup","esbuild"],t);throw new Error(`No packem.config found. Run packem in an interactive terminal to generate one, or install the defaults manually:
53
- ${i}
54
- and create a packem.config.ts.`)}K(pe("Packem first-run setup")),P.info("No packem.config found — let's create one.");const e=await _e(),a=e==="rolldown"?void 0:await He(),s=[e];e==="rolldown"&&s.push("rollup"),a&&s.push(se[a]),await Xe(s,t);const n=b(t,"packem.config.ts");await z(n,Je(e,a),"utf8"),P.success(`Created ${n}`),U("Setup complete — continuing with build.")},Qe=/^([^#:=]+)=(.*)$/,R=(t,e="PACKEM_")=>{const a={};for(const s of t.split(`
55
- `)){const n=s.trim();if(!n||n.startsWith("#"))continue;const i=Qe.exec(n);if(i?.[1]){const r=i[1].trim();let o=i[2].trim();(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'"))&&(o=o.slice(1,-1)),(!e||r.startsWith(e))&&(a[`process.env.${r}`]=JSON.stringify(o))}}return a},Ze=async(t,e,a="PACKEM_")=>{const s=D(e,t);if(!V(s))return{};const{readFile:n}=await import("node:fs/promises"),i=await n(s,"utf8"),r={};if(typeof T=="function")try{const o=T(i);for(const[c,l]of Object.entries(o))(!a||c.startsWith(a))&&(r[`process.env.${c}`]=JSON.stringify(l))}catch{return R(i,a)}else return R(i,a);return r},et=async(t,e,a,s,n)=>{const i=await A(e,n),r=await t.import(i,{default:!0,try:!0})??{};return{config:typeof r=="function"?await r(a,s):r,path:i}},tt=async(t,e)=>{switch(t){case"none":return{};case"preact":{const{createPreactPreset:a}=await import("../config/preset/preact.js");t=a();break}case"react":{const{createReactPreset:a}=await import("../config/preset/react.js");t=a();break}case"solid":{const{createSolidPreset:a}=await import("../config/preset/solid.js");t=a();break}case"svelte":{const{createSveltePreset:a}=await import("../config/preset/svelte.js");t=a();break}case"vue":{const{createVuePreset:a}=await import("../config/preset/vue.js");t=a();break}default:typeof t=="string"&&(t=await e.import(t)||{})}return typeof t=="function"&&(t=t()),t},st=t=>t.watch?"watch":t.jit?"jit":"build",at=t=>{let e;const a={};if(t.env)for(const s of t.env)s.key==="NODE_ENV"?e=s.value:a[`process.env.${s.key}`]=JSON.stringify(s.value);return{cliEnvVariables:a,nodeEnvironment:e}},nt=(t,e)=>{if(e!==void 0)return e;if(t.production)return F;if(t.development)return we},it=t=>{const e=[];if(t.external)for(const a of t.external)e.push(a.split(","));return e},ot=t=>{t.addCommand({description:"Demonstrate options required",execute:async({logger:e,options:a})=>{const s=a,n=st(s),{cliEnvVariables:i,nodeEnvironment:r}=at(s),o=nt(s,r),c=it(s),l=D(L(),s.dir??".");await Ye(l);const u=be(l,{debug:s.debug}),{config:m,path:p}=await et(u,l,o,n,s.config??void 0);e.debug("Using packem config found at",p);const d=s.envFile??m.envFile,j=s.envPrefix??m.envPrefix??"PACKEM_",w={};if(d){const y=await Ze(d,l,j);Object.assign(w,y)}Object.assign(w,i);const I=await tt(m.preset??"none",u);s.minify&&s.sourcemap===void 0&&(s.sourcemap=!0);try{const y=ae()(m,ne,I,{analyze:s.analyze,bundler:s.bundler,cjsInterop:s.cjsInterop,clean:s.clean,dtsOnly:s.dtsOnly,externals:c,killSignal:s.killSignal,minify:s.minify??o===F,onSuccess:s.onSuccess,rollup:{esbuild:{target:s.target},license:{path:s.license},metafile:s.metafile,...Object.keys(w).length>0||Object.keys(i).length>0?{replace:{values:w}}:{},resolveExternals:s.noExternal?{builtins:!1,deps:!1,devDeps:!1,optDeps:!1,peerDeps:!1}:{}},runtime:s.runtime,sourcemap:s.metafile||s.analyze||s.sourcemap,unbundle:s.unbundle,validation:s.validation===!1?!1:{},...s.exe?{exe:!0}:{},...s.typedoc?{typedoc:{format:"html"}}:{}});s.validation===!1&&!m.validation&&(y.validation=!1),await ie(l,n,o,e,s.debug??!1,y,s.tsconfig??void 0)}catch(y){e.error(y),le(1)}},name:"build",options:[{description:"Specify the bundler to use (rollup or rolldown)",name:"bundler",type:e=>{if(e==="rollup"||e==="rolldown")return e;throw new Error("Invalid bundler. Use 'rollup' or 'rolldown'.")}},{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:e=>{const[a,s]=e.split("=");return{key:a,value:s}}},{description:"Path to the .env file to load environment variables from",name:"env-file",type:String},{description:"Prefix for environment variables to load from .env file (default: PACKEM_)",name:"env-prefix",type:String},{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:"Disable the output validation",name:"no-validation",type:Boolean},{description:"Disable the cache",name:"no-cache",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:e=>{if(e==="SIGTERM"||e==="SIGKILL")return e;throw new Error("Invalid kill signal. Use 'SIGTERM' or 'SIGKILL'.")}},{description:"Specify an external dependency, separate by comma (eg. --external lodash,react,react-dom)",multiple:!0,name:"external",typeLabel:"string[]"},{description:"do not bundle external dependencies",name:"no-external",type:Boolean},{description:"Specify the build runtime (nodejs, browser).",name:"runtime",type:e=>{if(e==="node"||e==="browser")return e;throw new Error("Invalid runtime. Use 'node' or 'browser'.")}},{description:"Enable unbundle mode to preserve source file structure instead of bundling into a single file",name:"unbundle",type:Boolean},{description:"Bundle the output into a standalone executable via Node.js SEA (requires Node.js >= 25.7.0, single entry)",name:"exe",type:Boolean}]})},H=t=>t==="sass-embedded"||t==="node-sass"?"sass":t,rt=(t,e)=>{fe(b(t,"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:e?["es2022","dom","dom.iterable"]:["es2022"]}})},ct=(t,e,a,s,n)=>{let i="";if(t)for(const r of e){const o=H(r);i+=n?`import ${o}Loader from "@visulima/packem/css/loader/${o.toLowerCase()}";
52
+ `},_e=async()=>{const t=await g({initialValue:"rollup",message:"Which bundler do you want to use?",options:[{hint:"stable, full feature set, supports DTS",label:"rollup",value:"rollup"},{hint:"experimental, fast — falls back to rollup for DTS",label:"rolldown",value:"rolldown"}]});if(F(t))throw B("Setup cancelled."),new Error("Packem setup was cancelled.");return t},He=async()=>{const t=await g({initialValue:"esbuild",message:"Which transformer do you want to use?",options:[{hint:"fast, widely used",label:"esbuild",value:"esbuild"},{hint:"fastest, Rust-based",label:"oxc",value:"oxc"},{hint:"TypeScript-aware, Rust-based",label:"swc",value:"swc"},{hint:"minimal, JS-based",label:"sucrase",value:"sucrase"}]});if(F(t))throw B("Setup cancelled."),new Error("Packem setup was cancelled.");return t},Xe=async(t,e)=>{if(t.length===0)return;const a=D();a.start(`Installing ${t.join(", ")}`);try{await h(t,{cwd:e,dev:!0,silent:!0}),a.stop(`Installed ${t.join(", ")}`)}catch(s){throw a.stop(`Failed to install ${t.join(", ")}`),s}},Ye=async t=>{if(await ee(t))return;if(!(process.stdout.isTTY&&!process.env.CI)){const n=await te(["rollup","esbuild"],t);throw new Error(`No packem.config found. Run packem in an interactive terminal to generate one, or install the defaults manually:
53
+ ${n}
54
+ and create a packem.config.ts.`)}U(pe("Packem first-run setup")),E.info("No packem.config found — let's create one.");const e=await _e(),a=e==="rolldown"?void 0:await He(),s=[e];e==="rolldown"&&s.push("rollup"),a&&s.push(se[a]),await Xe(s,t);const i=b(t,"packem.config.ts");await J(i,Je(e,a),"utf8"),E.success(`Created ${i}`),W("Setup complete — continuing with build.")},Qe=/^([^#:=]+)=(.*)$/,A=(t,e="PACKEM_")=>{const a={};for(const s of t.split(`
55
+ `)){const i=s.trim();if(!i||i.startsWith("#"))continue;const n=Qe.exec(i);if(n?.[1]){const r=n[1].trim();let o=n[2].trim();(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'"))&&(o=o.slice(1,-1)),(!e||r.startsWith(e))&&(a[`process.env.${r}`]=JSON.stringify(o))}}return a},Ze=async(t,e,a="PACKEM_",s)=>{const i=L(e,t);if(!V(i))return s?.warn(`Env file not found at "${i}"; no environment variables were loaded.`),{};const{readFile:n}=await import("node:fs/promises"),r=await n(i,"utf8"),o={};if(typeof R=="function")try{const l=R(r),c=Object.keys(l).length;for(const[m,u]of Object.entries(l))(!a||m.startsWith(a))&&(o[`process.env.${m}`]=JSON.stringify(u));const d=Object.keys(o).length;c>0&&d===0&&a?s?.warn(`Loaded 0 of ${c} variables from "${t}"; none matched the "${a}" prefix.`):s?.info(`Loaded ${d} of ${c} variables from "${t}"${a?` (prefix "${a}")`:""}.`)}catch{return A(r,a)}else return A(r,a);return o},et=async(t,e,a,s,i)=>{const n=await q(e,i),r=await t.import(n,{default:!0})??{};return{config:typeof r=="function"?await r(a,s):r,path:n}},tt=async(t,e)=>{switch(t){case"none":return{};case"preact":{const{createPreactPreset:a}=await import("../config/preset/preact.js");t=a();break}case"react":{const{createReactPreset:a}=await import("../config/preset/react.js");t=a();break}case"solid":{const{createSolidPreset:a}=await import("../config/preset/solid.js");t=a();break}case"svelte":{const{createSveltePreset:a}=await import("../config/preset/svelte.js");t=a();break}case"vue":{const{createVuePreset:a}=await import("../config/preset/vue.js");t=a();break}default:typeof t=="string"&&(t=await e.import(t,{default:!0})||{})}return typeof t=="function"&&(t=t()),t},st=t=>t.watch?"watch":t.jit?"jit":"build",at=t=>{let e;const a={};if(t.env)for(const s of t.env)s.key==="NODE_ENV"?e=s.value:a[`process.env.${s.key}`]=JSON.stringify(s.value);return{cliEnvVariables:a,nodeEnvironment:e}},it=(t,e)=>{if(e!==void 0)return e;if(t.production)return z;if(t.development)return we},nt=t=>{const e=[];if(t.external)for(const a of t.external)e.push(a.split(","));return e},ot=t=>{t.addCommand({description:"Build the package using the resolved packem configuration",execute:async({logger:e,options:a})=>{const s=a,i=st(s),{cliEnvVariables:n,nodeEnvironment:r}=at(s),o=it(s,r),l=nt(s),c=L(O(),s.dir??".");await Ye(c);const d=be(c,{debug:s.debug}),{config:m,path:u}=await et(d,c,o,i,s.config??void 0);e.debug("Using packem config found at",u);const p=s.envFile??m.envFile,x=s.envPrefix??m.envPrefix??"PACKEM_",w={};if(p){const y=await Ze(p,c,x,{info:v=>e.info(v),warn:v=>e.warn(v)});Object.assign(w,y)}Object.assign(w,n);const I=await tt(m.preset??"none",d);s.minify&&s.sourcemap===void 0&&(s.sourcemap=!0);try{const y=ae()(m,ie,I,{analyze:s.analyze,bundler:s.bundler,cjsInterop:s.cjsInterop,clean:s.clean,dtsOnly:s.dtsOnly,externals:l,killSignal:s.killSignal,minify:s.minify??o===z,onSuccess:s.onSuccess,rollup:{esbuild:{target:s.target},license:{path:s.license},metafile:s.metafile,...Object.keys(w).length>0||Object.keys(n).length>0?{replace:{values:w}}:{},resolveExternals:s.noExternal?{builtins:!1,deps:!1,devDeps:!1,optDeps:!1,peerDeps:!1}:{}},runtime:s.runtime,sourcemap:s.metafile||s.analyze||s.sourcemap,unbundle:s.unbundle,validation:s.validation===!1?!1:{},...s.exe?{exe:!0}:{},...s.typedoc?{typedoc:{format:"html"}}:{}});s.validation===!1&&!m.validation&&(y.validation=!1),s.cache===!1&&(y.fileCache=!1),await ne(c,i,o,e,s.debug??!1,y,s.tsconfig??void 0)}catch(y){e.error(y),le(1)}},name:"build",options:[{description:"Specify the bundler to use (rollup or rolldown)",name:"bundler",type:e=>{if(e==="rollup"||e==="rolldown")return e;throw new Error("Invalid bundler. Use 'rollup' or 'rolldown'.")}},{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:e=>{const a=e.indexOf("=");return a===-1?{key:e,value:""}:{key:e.slice(0,a),value:e.slice(a+1)}}},{description:"Path to the .env file to load environment variables from",name:"env-file",type:String},{description:"Prefix for environment variables to load from .env file (default: PACKEM_)",name:"env-prefix",type:String},{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:"Disable the output validation",name:"no-validation",type:Boolean},{description:"Disable the cache",name:"no-cache",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:e=>{if(e==="SIGTERM"||e==="SIGKILL")return e;throw new Error("Invalid kill signal. Use 'SIGTERM' or 'SIGKILL'.")}},{description:"Specify an external dependency, separate by comma (eg. --external lodash,react,react-dom)",multiple:!0,name:"external",typeLabel:"string[]"},{description:"do not bundle external dependencies",name:"no-external",type:Boolean},{description:"Specify the build runtime (node, browser).",name:"runtime",type:e=>{if(e==="node"||e==="browser")return e;throw new Error("Invalid runtime. Use 'node' or 'browser'.")}},{description:"Enable unbundle mode to preserve source file structure instead of bundling into a single file",name:"unbundle",type:Boolean},{description:"Bundle the output into a standalone executable via Node.js SEA (requires Node.js >= 25.7.0, single entry)",name:"exe",type:Boolean}]})},X=t=>t==="sass-embedded"||t==="node-sass"?"sass":t,rt=(t,e)=>{fe(b(t,"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:e?["es2022","dom","dom.iterable"]:["es2022"]}})},ct=(t,e,a,s,i)=>{let n="";if(t)for(const r of e){const o=X(r);n+=i?`import ${o}Loader from "@visulima/packem/css/loader/${o.toLowerCase()}";
56
56
  `:`const ${o}Loader = require("@visulima/packem/css/loader/${o.toLowerCase()}");
57
- `}return s&&a&&(i+=n?`import ${a}Minifier from "@visulima/packem/css/minifier/${a.toLowerCase()}";
57
+ `}return s&&a&&(n+=i?`import ${a}Minifier from "@visulima/packem/css/minifier/${a.toLowerCase()}";
58
58
  `:`const ${a}Minifier = require("@visulima/packem/css/minifier/${a.toLowerCase()}");
59
- `),i},lt=(t,e,a,s)=>{if(!t&&!a)return"";let n=`,
59
+ `),n},lt=(t,e,a,s)=>{if(!t&&!a)return"";let i=`,
60
60
  rollup: {
61
- css: {`;if(t){const i=s.map(r=>`${H(r)}Loader`).join(", ");n+=`
62
- loaders: [${i}],`}return a&&e&&(n+=`
63
- minifier: ${e}Minifier,`),n+=`
61
+ css: {`;if(t){const n=s.map(r=>`${X(r)}Loader`).join(", ");i+=`
62
+ loaders: [${n}],`}return a&&e&&(i+=`
63
+ minifier: ${e}Minifier,`),i+=`
64
64
  }
65
- }`,n},dt=(t,e,a,s,n)=>t?`import { defineConfig } from "@visulima/packem/config";
65
+ }`,i},dt=(t,e,a,s,i)=>t?`import { defineConfig } from "@visulima/packem/config";
66
66
  import transformer from "@visulima/packem/transformer/${e}";
67
67
  ${s}
68
68
  export default defineConfig({
69
69
  runtime: "${a}",
70
- transformer${n}
70
+ transformer${i}
71
71
  });
72
72
  `:`const { defineConfig } = require("@visulima/packem/config");
73
73
  const transformer = require("@visulima/packem/transformer/${e}");
74
74
  ${s}
75
75
  module.exports = defineConfig({
76
76
  runtime: ${a},
77
- transformer${n}
77
+ transformer${i}
78
78
  });
79
- `,ut=t=>{const e=[];return t.dependencies&&e.push(...Object.keys(t.dependencies)),t.devDependencies&&e.push(...Object.keys(t.devDependencies)),e},pt=async(t,e,a,s)=>{if(t===void 0&&!e){const i=await f({message:"Do you want to install TypeScript?"});return i&&s.push("typescript@latest"),i}const n=a.devDependencies?.typescript??a.dependencies?.typescript??"unknown";return P.message(`TypeScript version ${n} is already installed`),t},mt=async(t,e,a)=>{let s=t;return e.includes("esbuild")?s="esbuild":e.includes("@swc/core")?s="swc":e.includes("sucrase")&&(s="sucrase"),s!==void 0?(P.message(`Transformer ${s} is already installed.`),s):(s=await g({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"},{label:"OXC",value:"oxc"}]}),s&&s!=="oxc"&&!e.includes(s)&&await f({message:`Do you want to install ${s}?`})&&a.push(s==="swc"?"@swc/core":s),s)},ft=async t=>{if(N(b(t,"tsconfig.json")))return;const e=await f({message:"Do you want to use generate a tsconfig.json?"}),a=await f({message:"Do you want to run your code in the DOM?"});if(e){const s=E();s.start("Generating tsconfig.json"),rt(t,!!a),s.stop("")}},gt=async t=>{if(!t.includes("sass"))return t;const e=await g({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"}]});return e==="sass"?t:[...t.filter(a=>a!=="sass"),e]},yt=async t=>{const e=[],a=await g({message:"Pick a css loader",options:[{label:"PostCSS",value:"postcss"},{hint:"experimental",label:"Lightning CSS",value:"lightningcss"}]});e.push(a);const s=await G({message:"Pick your loaders",options:[{label:"Sass",value:"sass"},{label:"Stylus",value:"stylus"},{label:"Less",value:"less"}],required:!1}),n=await gt(s);if(e.push(...n),await f({message:`Do you want to install "${e.join('", "')}"?`}))for(const i of e)t.push(...J[i]);return e.push("sourceMap"),e},wt=async(t,e)=>{const a=await g({message:"Pick a css minifier",options:[{label:"CSSNano",value:"cssnano"},{label:"Lightning CSS",value:"lightningcss"}]});return t.includes("lightningcss")||await f({message:`Do you want to install "${a}"?`})&&e.push(a),a},bt=t=>{t.addCommand({description:"Initialize packem configuration",execute:async({logger:e,options:a})=>{const s=a,n=e;if(K("Welcome to packem setup"),N(b(s.dir??".","packem.config.ts"))){n.info("Packem project already initialized, you can use `packem build` to build your project");return}const i=D(L(),s.dir??"."),r=b(i,"package.json");if(!N(r))throw new Error("No package.json found in the directory");const o=await q(r,{resolveCatalogs:!0}),c=ut(o),l=!!(o.devDependencies?.typescript??o.dependencies?.typescript),u=[];s.typescript=await pt(s.typescript,l,o,u),await ft(i),s.runtime??=await g({message:"Pick a build runtime",options:[{label:"Node",value:"node"},{label:"Browser",value:"browser"}]}),s.transformer=await mt(s.transformer,c,u),s.css??=await f({initialValue:!1,message:"Do you want to use css in your project?"});const m=s.css?await yt(u):[];s.cssMinifier??=await f({initialValue:!1,message:"Do you want to minify your css?"});const p=s.cssMinifier?await wt(m,u):void 0,d=s.css??!1,j=s.cssMinifier??!1,w=l||o.type==="module",I=lt(d,p,j,m),y=ct(d,m,p,j,w),Y=dt(w,s.transformer??"",s.runtime??"",y,I),x=E(),M=l?"ts":"js";u.length>0&&(x.start("Installing packages"),await h(u,{cwd:i,dev:!0,silent:!0}),x.stop("Installed packages")),x.start(`Creating packem.config.${M}`),me(b(i,`packem.config.${M}`),Y),x.stop(`Created packem.config.${M}`),U("Now you can run `packem build` to build your project")},name:"init",options:[{defaultValue:".",description:"The directory to initialize",name:"dir",type:String},{description:"Choose a transformer",name:"transformer",type:e=>{if(typeof e=="string"&&["esbuild","sucrase","swc"].includes(e))return e;throw new Error("Invalid transformer, please choose one of 'swc', 'sucrase' or 'esbuild'")}},{description:"Use CSS",name:"css",type:Boolean},{description:"Use CSS minifier",name:"css-minifier",type:Boolean},{description:"Use TypeScript",name:"typescript",type:Boolean},{description:"Specify the build runtime (nodejs, browser).",name:"runtime",type:e=>{if(e==="node"||e==="browser")return e;throw new Error("Invalid runtime. Use 'node' or 'browser'.")}}]})},X={bunchee:"@visulima/packem",tsup:"@visulima/packem","tsup-node":"@visulima/packem",unbuild:"@visulima/packem"},ht={dependencies:`^${B.version}`,devDependencies:`^${B.version}`,peerDependencies:"*"},vt=(t,e,a,s)=>{const n={};for(const i of Object.keys(t))i===e?n[a]=s??t[e]:n[i]=t[i];return n},kt=/\bunbuild\b/g,$t=/\bbunchee\b/g,St=/\btsup(?:-node)?/g,Ct=/\bbuild\b/g,jt=[{from:"tsup",rewrite:t=>t.replaceAll(St,"packem build").replaceAll(Ct,"build")},{from:"unbuild",rewrite:t=>t.replaceAll(kt,"packem build")},{from:"bunchee",rewrite:t=>t.replaceAll($t,"packem build")}],xt=(t,e,a)=>{let s=e,n=!1;for(const i of Object.keys(X))s.includes(i)&&(a.info(`Migrating \`${t}\` script from ${i} to packem`),n=!0,s=s.replaceAll(new RegExp(String.raw`\b${i}\b`,"g"),"packem").replaceAll(new RegExp(String.raw`\b${i}-node\b`,"g"),"packem"));for(const{from:i,rewrite:r}of jt)s.includes(i)&&(a.info(`Migrating \`${t}\` script from ${i} to packem`),n=!0,s=r(s));return n?s:void 0},Pt=(t,e)=>{const a={...t};let s=!1;for(const n of Object.keys(a)){const i=xt(n,a[n],e);i!==void 0&&(a[n]=i,s=!0)}return{found:s,scripts:a}},Et=(t,e)=>{const a={...t};let s=!1;for(const[n,i]of Object.entries(ht)){let r=a[n];for(const[o,c]of Object.entries(X))r?.[o]&&(e.info(`Migrating \`${n}\` from ${o} to ${c}.`),s=!0,r=vt(r,o,c,i),a[n]=r)}return{found:s,pkg:a}},Dt=(t,e)=>{const a=["tsup","unbuild","bunchee"];for(const s of a)t[s]&&e.info(`Found \`${s}\` config field in package.json. Consider moving to packem.config.ts`)},It=async(t,e)=>{if(!V("package.json"))return e.error("No package.json found"),!1;const a=await he("package.json","utf8"),s=JSON.parse(a),{found:n,pkg:i}=Et(s,e);let r=n;if(i.scripts){const{found:c,scripts:l}=Pt(i.scripts,e);c&&(i.scripts=l,r=!0)}if(Dt(i,e),!r)return e.warn("No migratable bundler dependencies found in package.json"),!1;const o=`${JSON.stringify(i,void 0,a.includes(" ")?" ":2)}
80
- `;return t?(e.info("[dry-run] package.json changes:"),e.info("Old content:"),console.info(a),e.info("New content:"),console.info(o)):(await z("package.json",o),e.success("Migrated `package.json`")),!0},Mt=["tsup.config.ts","tsup.config.cts","tsup.config.mts","tsup.config.js","tsup.config.cjs","tsup.config.mjs","tsup.config.json","build.config.ts","build.config.cts","build.config.mts","build.config.js","build.config.cjs","build.config.mjs","bunchee.config.ts","bunchee.config.cts","bunchee.config.mts","bunchee.config.js","bunchee.config.cjs","bunchee.config.mjs"],Nt=t=>{let e=!1;for(const a of Mt)V(a)&&(t.info(`Found config file \`${a}\`. Consider creating packem.config.ts instead.`),t.warn("Manual migration required for config files. See https://www.visulima.com/docs/package/packem"),e=!0);return e||t.warn("No bundler config files found"),e},Lt=async({cwd:t,dryRun:e,logger:a})=>{if(e)a.info("Dry run enabled. No changes will be made.");else{const n=ve({input:v.stdin,output:v.stdout});a.warn(`
79
+ `,ut=t=>{const e=[];return t.dependencies&&e.push(...Object.keys(t.dependencies)),t.devDependencies&&e.push(...Object.keys(t.devDependencies)),e},pt=async(t,e,a,s)=>{if(t===void 0&&!e){const n=await f({message:"Do you want to install TypeScript?"});return n&&s.push("typescript@latest"),n}const i=a.devDependencies?.typescript??a.dependencies?.typescript??"unknown";return E.message(`TypeScript version ${i} is already installed`),t},mt=async(t,e,a)=>{let s=t;return e.includes("esbuild")?s="esbuild":e.includes("@swc/core")?s="swc":e.includes("sucrase")&&(s="sucrase"),s!==void 0?(E.message(`Transformer ${s} is already installed.`),s):(s=await g({message:"Pick a transformer",options:[{label:"esbuild",value:"esbuild"},{label:"swc",value:"swc"},{label:"Sucrase",value:"sucrase"},{label:"OXC",value:"oxc"}]}),s&&s!=="oxc"&&!e.includes(s)&&await f({message:`Do you want to install ${s}?`})&&a.push(s==="swc"?"@swc/core":s),s)},ft=async t=>{if(N(b(t,"tsconfig.json")))return;const e=await f({message:"Do you want to use generate a tsconfig.json?"}),a=await f({message:"Do you want to run your code in the DOM?"});if(e){const s=D();s.start("Generating tsconfig.json"),rt(t,!!a),s.stop("")}},gt=async t=>{if(!t.includes("sass"))return t;const e=await g({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"}]});return e==="sass"?t:[...t.filter(a=>a!=="sass"),e]},yt=async t=>{const e=[],a=await g({message:"Pick a css loader",options:[{label:"PostCSS",value:"postcss"},{hint:"experimental",label:"Lightning CSS",value:"lightningcss"}]});e.push(a);const s=await K({message:"Pick your loaders",options:[{label:"Sass",value:"sass"},{label:"Stylus",value:"stylus"},{label:"Less",value:"less"}],required:!1}),i=await gt(s);if(e.push(...i),await f({message:`Do you want to install "${e.join('", "')}"?`}))for(const n of e)t.push(..._[n]);return e.push("sourceMap"),e},wt=async(t,e)=>{const a=await g({message:"Pick a css minifier",options:[{label:"CSSNano",value:"cssnano"},{label:"Lightning CSS",value:"lightningcss"}]});return t.includes("lightningcss")||await f({message:`Do you want to install "${a}"?`})&&e.push(a),a},bt=t=>{t.addCommand({description:"Initialize packem configuration",execute:async({logger:e,options:a})=>{const s=a,i=e;if(U("Welcome to packem setup"),N(b(s.dir??".","packem.config.ts"))){i.info("Packem project already initialized, you can use `packem build` to build your project");return}const n=L(O(),s.dir??"."),r=b(n,"package.json");if(!N(r))throw new Error("No package.json found in the directory");const o=await G(r,{resolveCatalogs:!0}),l=ut(o),c=!!(o.devDependencies?.typescript??o.dependencies?.typescript),d=[];s.typescript=await pt(s.typescript,c,o,d),await ft(n),s.runtime??=await g({message:"Pick a build runtime",options:[{label:"Node",value:"node"},{label:"Browser",value:"browser"}]}),s.transformer=await mt(s.transformer,l,d),s.css??=await f({initialValue:!1,message:"Do you want to use css in your project?"});const m=s.css?await yt(d):[];s.cssMinifier??=await f({initialValue:!1,message:"Do you want to minify your css?"});const u=s.cssMinifier?await wt(m,d):void 0,p=s.css??!1,x=s.cssMinifier??!1,w=c||o.type==="module",I=lt(p,u,x,m),y=ct(p,m,u,x,w),v=dt(w,s.transformer??"",s.runtime??"",y,I),P=D(),M=c?"ts":"js";d.length>0&&(P.start("Installing packages"),await h(d,{cwd:n,dev:!0,silent:!0}),P.stop("Installed packages")),P.start(`Creating packem.config.${M}`),me(b(n,`packem.config.${M}`),v),P.stop(`Created packem.config.${M}`),W("Now you can run `packem build` to build your project")},name:"init",options:[{defaultValue:".",description:"The directory to initialize",name:"dir",type:String},{description:"Choose a transformer",name:"transformer",type:e=>{if(typeof e=="string"&&["esbuild","sucrase","swc"].includes(e))return e;throw new Error("Invalid transformer, please choose one of 'swc', 'sucrase' or 'esbuild'")}},{description:"Use CSS",name:"css",type:Boolean},{description:"Use CSS minifier",name:"css-minifier",type:Boolean},{description:"Use TypeScript",name:"typescript",type:Boolean},{description:"Specify the build runtime (nodejs, browser).",name:"runtime",type:e=>{if(e==="node"||e==="browser")return e;throw new Error("Invalid runtime. Use 'node' or 'browser'.")}}]})},Y={bunchee:"@visulima/packem",tsup:"@visulima/packem","tsup-node":"@visulima/packem",unbuild:"@visulima/packem"},ht={dependencies:`^${T.version}`,devDependencies:`^${T.version}`,peerDependencies:"*"},vt=(t,e,a,s)=>{const i={};for(const n of Object.keys(t))n===e?i[a]=s??t[e]:i[n]=t[n];return i},kt=/\bunbuild\b/g,$t=/\bbunchee\b/g,St=/\btsup(?:-node)?/g,Ct=/\bbuild\b/g,jt=[{from:"tsup",rewrite:t=>t.replaceAll(St,"packem build").replaceAll(Ct,"build")},{from:"unbuild",rewrite:t=>t.replaceAll(kt,"packem build")},{from:"bunchee",rewrite:t=>t.replaceAll($t,"packem build")}],xt=(t,e,a)=>{let s=e,i=!1;for(const n of Object.keys(Y))s.includes(n)&&(a.info(`Migrating \`${t}\` script from ${n} to packem`),i=!0,s=s.replaceAll(new RegExp(String.raw`\b${n}\b`,"g"),"packem").replaceAll(new RegExp(String.raw`\b${n}-node\b`,"g"),"packem"));for(const{from:n,rewrite:r}of jt)s.includes(n)&&(a.info(`Migrating \`${t}\` script from ${n} to packem`),i=!0,s=r(s));return i?s:void 0},Pt=(t,e)=>{const a={...t};let s=!1;for(const i of Object.keys(a)){const n=xt(i,a[i],e);n!==void 0&&(a[i]=n,s=!0)}return{found:s,scripts:a}},Et=(t,e)=>{const a={...t};let s=!1;for(const[i,n]of Object.entries(ht)){let r=a[i];for(const[o,l]of Object.entries(Y))r?.[o]&&(e.info(`Migrating \`${i}\` from ${o} to ${l}.`),s=!0,r=vt(r,o,l,n),a[i]=r)}return{found:s,pkg:a}},Dt=(t,e)=>{const a=["tsup","unbuild","bunchee"];for(const s of a)t[s]&&e.info(`Found \`${s}\` config field in package.json. Consider moving to packem.config.ts`)},Lt=async(t,e)=>{if(!V("package.json"))return e.error("No package.json found"),!1;const a=await he("package.json","utf8"),s=JSON.parse(a),{found:i,pkg:n}=Et(s,e);let r=i;if(n.scripts){const{found:l,scripts:c}=Pt(n.scripts,e);l&&(n.scripts=c,r=!0)}if(Dt(n,e),!r)return e.warn("No migratable bundler dependencies found in package.json"),!1;const o=`${JSON.stringify(n,void 0,a.includes(" ")?" ":2)}
80
+ `;return t?(e.info("[dry-run] package.json changes:"),e.info("Old content:"),console.info(a),e.info("New content:"),console.info(o)):(await J("package.json",o),e.success("Migrated `package.json`")),!0},It=["tsup.config.ts","tsup.config.cts","tsup.config.mts","tsup.config.js","tsup.config.cjs","tsup.config.mjs","tsup.config.json","build.config.ts","build.config.cts","build.config.mts","build.config.js","build.config.cjs","build.config.mjs","bunchee.config.ts","bunchee.config.cts","bunchee.config.mts","bunchee.config.js","bunchee.config.cjs","bunchee.config.mjs"],Mt=t=>{let e=!1;for(const a of It)V(a)&&(t.info(`Found config file \`${a}\`. Consider creating packem.config.ts instead.`),t.warn("Manual migration required for config files. See https://www.visulima.com/docs/package/packem"),e=!0);return e||t.warn("No bundler config files found"),e},Nt=async({cwd:t,dryRun:e,logger:a})=>{if(e)a.info("Dry run enabled. No changes will be made.");else{const i=ve({input:k.stdin,output:k.stdout});a.warn(`
81
81
 
82
82
  Before proceeding, review the migration guide at https://www.visulima.com/docs/package/packem, as this process will modify your files.
83
- Uncommitted changes will be lost. Use the --dry-run flag to preview changes without applying them.`);const i=await n.question("Continue? (Y/n) ");if(n.close(),!(i.toLowerCase()==="y"||i==="")){a.error("Migration cancelled."),v.exitCode=1;return}}t&&v.chdir(t);let s=!1;await It(e,a)&&(s=!0),Nt(a)&&(s=!0),s?a.success("Migration completed. Remember to run install command with your package manager."):(a.error("No migration performed."),v.exitCode=1)},Ot=t=>{t.addCommand({description:"Migrate from other bundlers (tsup, unbuild, bunchee, etc.) to packem",execute:async({logger:e,options:a})=>{const s=a;await Lt({cwd:s.cwd,dryRun:s.dryRun,logger:e})},name:"migrate",options:[{defaultValue:".",description:"The directory to migrate",name:"cwd",type:String},{description:"Preview changes without applying them",name:"dry-run",type:Boolean}]})};try{require("node:module").enableCompileCache?.()||require("v8-compile-cache")}catch{}const C=Q("packem",{logger:Z({reporters:[new ce({error:{hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0}})],scope:"packem"}),packageName:re,packageVersion:oe});bt(C);ot(C);ze(C);Ot(C);C.run({shouldExitProcess:!1});
83
+ Uncommitted changes will be lost. Use the --dry-run flag to preview changes without applying them.`);const n=await i.question("Continue? (Y/n) ");if(i.close(),!(n.toLowerCase()==="y"||n==="")){a.error("Migration cancelled."),k.exitCode=1;return}}t&&k.chdir(t);let s=!1;await Lt(e,a)&&(s=!0),Mt(a)&&(s=!0),s?a.success("Migration completed. Remember to run install command with your package manager."):(a.error("No migration performed."),k.exitCode=1)},Ot=t=>{t.addCommand({description:"Migrate from other bundlers (tsup, unbuild, bunchee, etc.) to packem",execute:async({logger:e,options:a})=>{const s=a;await Nt({cwd:s.cwd,dryRun:s.dryRun,logger:e})},name:"migrate",options:[{defaultValue:".",description:"The directory to migrate",name:"cwd",type:String},{description:"Preview changes without applying them",name:"dry-run",type:Boolean}]})};try{require("node:module").enableCompileCache?.()}catch{}const j=Q("packem",{logger:Z({reporters:[new ce({error:{hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0}})],scope:"packem"}),packageName:re,packageVersion:oe});bt(j);ot(j);ze(j);Ot(j);j.run({shouldExitProcess:!1});
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import{createRequire as He}from"node:module";import{n as Ht,Z as xe,Y as Jt,J as Je,h as Se,y as yt,X as Gt,q as Ut,M as zt,a as Kt,A as be,K as Yt,k as Qt,b as Zt,c as Be,d as Xt,T as er}from"./packem_shared/index-BKMfJDaY.js";import{g as wt}from"./packem_shared/create-or-update-key-storage-CRDW-Kwa.js";const tr=He(import.meta.url),ie=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:Q,Ge=t=>{if(typeof ie<"u"&&ie.versions&&ie.versions.node){const[e,r]=ie.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return ie.getBuiltinModule(t)}return tr(t)},Q=ie,{execFileSync:rr}=Ge("node:child_process"),ue=Ge("node:fs"),sr=Ge("node:tty"),Ue=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],ze=[12288,12288,65281,65376,65504,65510],Ke=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],Ye=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],Ae=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141],ge=(t,e)=>{let r=0,s=Math.floor(t.length/2)-1;for(;r<=s;){const i=Math.floor((r+s)/2),o=i*2;if(e<t[o])s=i-1;else if(e>t[o+1])r=i+1;else return!0}return!1},ir=Ue[0],nr=Ue.at(-1),or=ze[0],ar=ze.at(-1),lr=Ke[0],cr=Ke.at(-1),ur=Ye[0],fr=Ye.at(-1),hr=Ae[0],gr=Ae.at(-1),nt=19968,[dr,pr]=mr(Ae);function mr(t){let e=t[0],r=t[1];for(let s=0;s<t.length;s+=2){const i=t[s],o=t[s+1];if(nt>=i&&nt<=o)return[i,o];o-i>r-e&&(e=i,r=o)}return[e,r]}const br=t=>t<ir||t>nr?!1:ge(Ue,t),yr=t=>t<or||t>ar?!1:ge(ze,t),wr=t=>t<lr||t>cr?!1:ge(Ke,t),$r=t=>t<ur||t>fr?!1:ge(Ye,t),vr=t=>t>=dr&&t<=pr?!0:t<hr||t>gr?!1:ge(Ae,t);function xr(t){return br(t)?"ambiguous":yr(t)?"fullwidth":wr(t)?"halfwidth":$r(t)?"narrow":vr(t)?"wide":"neutral"}function Sr(t){if(!Number.isSafeInteger(t))throw new TypeError(`Expected a code point, got \`${typeof t}\`.`)}function $t(t){return Sr(t),xr(t)}const vt=String.raw,ot=vt`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,kr=()=>new RegExp(vt`\p{RI}{2}|(?![#*\d](?!\uFE0F?\u20E3))${ot}(?:\u200D${ot})*`,"gu"),ae=new Set(["\x1B","›"]),Le="\x07",xt="[",Qe="m",ke="]8;;",Er=39,Tr=/[\u200B\uFEFF\u2060-\u2064]/g,Ar=new RegExp(`(?:\\${xt}(?<code>\\d+)m|\\${ke}(?<uri>.*)${Le})`),Lr=Object.freeze(new Map([[0,0],[1,22],[2,22],[3,23],[4,24],[7,27],[8,28],[9,29],[30,39],[31,39],[32,39],[33,39],[34,39],[35,39],[36,39],[37,39],[40,49],[41,49],[42,49],[43,49],[44,49],[45,49],[46,49],[47,49],[90,39]])),le=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,ye=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,je=kr(),at=new Map,we=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,$e=t=>t>=32&&t<=126?"latin":t===8203||t===8204||t===8205||t===8288?"zero":t<=31||t>=127&&t<=159?"control":t>=160&&t<=255||t>=9472&&t<=9599?"latin":t>=4352&&t<=4607||t>=11904&&t<=40959||t>=44032&&t<=55215||t>=63744&&t<=64255||t>=65280&&t<=65519&&!(t>=65377&&t<=65439)||t>=12352&&t<=12543?"wide":t===8230?"latin":"other",Mr=(t,e)=>{const r=Math.floor(t/65536),s=t%65536;let i=at.get(r);if(i||(i=new Map,at.set(r,i)),i.has(s))return i.get(s);let o;if($e(t)==="latin")o=e.width.regular;else if($e(t)==="control")o=e.width.control;else if($e(t)==="wide")o=e.width.wide;else switch($t(t)){case"ambiguous":{o=e.width.ambiguousIsNarrow?e.width.regular:e.width.wide;break}case"fullwidth":{o=e.width.fullWidth;break}case"wide":{o=e.width.wide;break}default:o=e.width.regular}return i.set(s,o),o},Or=t=>t>=768&&t<=879||t>=6832&&t<=6911||t>=7616&&t<=7679||t>=8400&&t<=8447||t>=65056&&t<=65071||t>=917760&&t<=917999||t>=65024&&t<=65039||t>=3633&&t<=3642||t>=3655&&t<=3662||t>=3761&&t<=3769||t>=3771&&t<=3772||t>=3784&&t<=3789||t>=2304&&t<=2307||t>=2362&&t<=2383||t>=2385&&t<=2391||t>=2402&&t<=2403||t>=2433&&t<=2435||t>=2492&&t<=2500||t>=2509&&t<=2509||t>=2561&&t<=2563||t>=2620&&t<=2637||t>=1611&&t<=1631||t>=1648&&t<=1648||t>=1750&&t<=1773||t>=2276&&t<=2302||t>=1425&&t<=1469||t>=1471&&t<=1471||t>=1473&&t<=1474||t>=1476&&t<=1477||t>=1479&&t<=1479||t>=3893&&t<=3893||t>=3895&&t<=3895||t>=3897&&t<=3897||t>=3953&&t<=3966||t>=3968&&t<=3972||t>=3974&&t<=3975?!0:t>=768&&t<=777||t>=803&&t<=803,Ce=(t,e={})=>{if(!t||t.length===0)return{ellipsed:!1,index:0,truncated:!1,width:0};const r={truncation:{countAnsiEscapeCodes:e.countAnsiEscapeCodes??!1,ellipsis:e.ellipsis??"",ellipsisWidth:e.ellipsisWidth??(e.ellipsis?Ce(e.ellipsis,{...e,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width:0),limit:e.limit??Number.POSITIVE_INFINITY},width:{ambiguousIsNarrow:e.ambiguousIsNarrow??!1,ansi:e.ansiWidth??0,control:e.controlWidth??0,emoji:e.emojiWidth??2,fullWidth:e.fullWidth??2,halfWidth:e.halfWidth??1,regular:e.regularWidth??1,tab:e.tabWidth??8,wide:e.wideWidth??2}},s=Math.max(0,r.truncation.limit-r.truncation.ellipsisWidth),{length:i}=t,o=i>1e4;let a=0,n=0,c=i,u=!1;const l=t.includes("\x1B")||t.includes("›");for(;a<i;){if(l&&(t[a]==="\x1B"||t[a]==="›")){if(t.startsWith("\x1B]8;;",a)){const v="\x1B]8;;\x07",B=v.length,V=t.indexOf("\x07",a+5);if(V!==-1){const H=t.indexOf(v,V+1);if(H!==-1){const d=H+B,g=t.slice(V+1,H).replace(le,""),$=Ce(g,{ambiguousIsNarrow:r.width.ambiguousIsNarrow,ansiWidth:r.width.ansi,controlWidth:r.width.control,countAnsiEscapeCodes:!1,ellipsis:r.truncation.ellipsis,ellipsisWidth:r.truncation.ellipsisWidth,emojiWidth:r.width.emoji,fullWidth:r.width.fullWidth,halfWidth:r.width.halfWidth,limit:Math.max(0,s-n),regularWidth:r.width.regular,tabWidth:r.width.tab,wideWidth:r.width.wide}),I=$.width;if($.truncated)u=!0,c=Math.min(c,a);else if(n+I>s&&(c=Math.min(c,a),u=!0,n+I>r.truncation.limit))break;if(n+=I,a=d,u&&n>=r.truncation.limit)break;continue}}}if(le.lastIndex=a,le.test(t)){const v=le.lastIndex-a,B=r.truncation.countAnsiEscapeCodes?v:r.width.ansi;if(n+B>s&&(c=Math.min(c,a),n+B>r.truncation.limit)){u=!0;break}n+=B,a=le.lastIndex;continue}}const w=t.codePointAt(a);if(w===8203||w===65279||w>=8288&&w<=8292){a+=1;continue}if(w===9){if(n+r.width.tab>s&&(c=Math.min(c,a),n+r.width.tab>r.truncation.limit)){u=!0;break}n+=r.width.tab,a+=1;continue}if(we.lastIndex=a,we.test(t)){const v=(we.lastIndex-a)*r.width.regular;if(n+v>s){const B=Math.floor((s-n)/r.width.regular);if(c=Math.min(c,a+B),n+v>r.truncation.limit){u=!0;break}}n+=v,a=we.lastIndex;continue}if((w<=31||w>=127&&w<=159)&&(ye.lastIndex=a,ye.test(t))){const v=(ye.lastIndex-a)*r.width.control;if(n+v>s&&(c=Math.min(c,a+Math.floor((s-n)/r.width.control)),n+v>r.truncation.limit)){u=!0;break}n+=v,a=ye.lastIndex;continue}if(je.lastIndex=a,je.test(t)){if(n+r.width.emoji>s&&(c=Math.min(c,a),n+r.width.emoji>r.truncation.limit)){u=!0;break}n+=r.width.emoji,a=je.lastIndex;continue}const N=t.codePointAt(a)??0;if(Or(N)){a+=N>65535?2:1;continue}let k;if(o)k=Mr(N,r);else switch($e(N)){case"control":{k=r.width.control;break}case"latin":{k=r.width.regular;break}case"wide":{k=r.width.wide;break}case"zero":{k=0;break}default:switch($t(N)){case"ambiguous":{k=r.width.ambiguousIsNarrow?r.width.regular:r.width.wide;break}case"fullwidth":{k=r.width.fullWidth;break}case"wide":{k=r.width.wide;break}default:k=r.width.regular}}if(n+k>s&&(c=Math.min(c,a),n+k>r.truncation.limit)){u=!0;break}n+=k,a+=N>65535?2:1}let h=n,p=!1;return u&&r.truncation.limit>=r.truncation.ellipsisWidth&&(h=r.truncation.limit,p=!0),{ellipsed:p,index:u?c:i,truncated:u,width:h}},Z=(t,e={})=>Ce(t,{...e,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width,Br=/\x1B\[(\d+)m/;class St{activeForeground=void 0;activeBackground=void 0;activeFormatting=[];processEscape(e){const r=Br.exec(e);if(!r)return;const s=Number.parseInt(r[1],10);switch(s){case 0:{this.activeForeground=void 0,this.activeBackground=void 0,this.activeFormatting=[];break}case 39:{this.activeForeground=void 0;break}case 49:{this.activeBackground=void 0;break}default:if(s>=30&&s<=37||s>=90&&s<=97)this.activeForeground=e;else if(s>=40&&s<=47||s>=100&&s<=107)this.activeBackground=e;else if([1,2,3,4,7,8,9].includes(s))this.activeFormatting.push(e);else if([22,23,24,27,28,29].includes(s)){const i={22:"[1m",23:"[3m",24:"[4m",27:"[7m",28:"[8m",29:"[9m"}[s];i&&(this.activeFormatting=this.activeFormatting.filter(o=>!o.includes(i)))}}}getStartEscapesForAllActiveAttributes(){return[this.activeBackground,this.activeForeground,...this.activeFormatting].filter(Boolean).join("")}getEndEscapesForAllActiveAttributes(){const e=[];if(this.activeFormatting.length>0){const r={"\x1B[1m":"\x1B[22m","\x1B[2m":"\x1B[22m","\x1B[3m":"\x1B[23m","\x1B[4m":"\x1B[24m","\x1B[7m":"\x1B[27m","\x1B[8m":"\x1B[28m","\x1B[9m":"\x1B[29m"};[...this.activeFormatting].toReversed().forEach(s=>{const i=r[s];i&&e.push(i)})}return this.activeForeground&&e.push("\x1B[39m"),this.activeBackground&&e.push("\x1B[49m"),e.join("")}}const kt=(t,e)=>{if(!ae.has(t[e]))return{isInsideEscape:!1,isInsideLinkEscape:!1};const r=!0,s=t.slice(e+1,e+1+ke.length).join("")===ke;return{isInsideEscape:r,isInsideLinkEscape:s}},jr=(t,e={})=>{const r=new St;let s="",i=!1,o="",a="",n=!1;const c=[...t];for(let u=0;u<c.length;u++){const l=c[u];if(l&&ae.has(l)){if(s){const k=e.getWidth?.(s)??0,v={isEscapeSequence:!1,isGrapheme:!0,text:s,width:k};if(n&&(v.isHyperlink=!0,v.hyperlinkUrl=a),e.onSegment?.(v,r)===!1)return;s=""}i=!0,o=l;const w=kt(c,u),{isInsideLinkEscape:N}=w;if(N){let k=u+1;for(a="";k<c.length;){const B=c[k];if(B===Le)break;a+=B,k+=1}a=a.slice(4);const v={hyperlinkUrl:a,isEscapeSequence:!0,isGrapheme:!1,isHyperlink:!0,isHyperlinkStart:!0,width:0};if(e.onSegment?.(v,r)===!1)return;u=k,n=!0,i=!1,o="";continue}if(u+1<c.length&&c[u+1]==="\\"&&n){const k={isEscapeSequence:!0,isGrapheme:!1,isHyperlink:!0,isHyperlinkEnd:!0,width:0};if(e.onSegment?.(k,r)===!1)return;n=!1,a="",u+=1,i=!1,o="";continue}}if(i){if(o!==l&&(o+=l),l===Qe){i=!1,r.processEscape(o);const w={isEscapeSequence:!0,isGrapheme:!1,text:o,width:0};if(e.onSegment?.(w,r)===!1)return;o=""}continue}s+=l;const h=e.getWidth?.(s)??0,p={isEscapeSequence:!1,isGrapheme:!0,text:s,width:h};if(n&&(p.isHyperlink=!0,p.hyperlinkUrl=a),e.onSegment?.(p,r)===!1)return;s=""}if(s){const u=e.getWidth?.(s)??0,l={isEscapeSequence:!1,isGrapheme:!0,text:s,width:u};n&&(l.isHyperlink=!0,l.hyperlinkUrl=a),e.onSegment?.(l,r)}if(o){const u={isEscapeSequence:!0,isGrapheme:!1,text:o,width:0};e.onSegment?.(u,r)}},lt=t=>`${ae.values().next().value}${xt}${String(t)}${Qe}`,ct=t=>`${ae.values().next().value}${ke}${t}${Le}`,Nr=t=>{if(t.length===0)return"";if(t.length===1)return t[0];let e="",r,s;const i=t.join(`
1
+ import{createRequire as He}from"node:module";import{n as Ht,Z as xe,Y as Jt,J as Je,h as Se,y as yt,X as Gt,q as Ut,M as zt,a as Kt,A as be,K as Yt,k as Qt,b as Zt,c as Be,d as Xt,T as er}from"./packem_shared/index-C47QUEeX.js";import{g as wt}from"./packem_shared/create-or-update-key-storage-DHOKZmnD.js";const tr=He(import.meta.url),ie=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:Q,Ge=t=>{if(typeof ie<"u"&&ie.versions&&ie.versions.node){const[e,r]=ie.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return ie.getBuiltinModule(t)}return tr(t)},Q=ie,{execFileSync:rr}=Ge("node:child_process"),ue=Ge("node:fs"),sr=Ge("node:tty"),Ue=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],ze=[12288,12288,65281,65376,65504,65510],Ke=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],Ye=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],Ae=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141],ge=(t,e)=>{let r=0,s=Math.floor(t.length/2)-1;for(;r<=s;){const i=Math.floor((r+s)/2),o=i*2;if(e<t[o])s=i-1;else if(e>t[o+1])r=i+1;else return!0}return!1},ir=Ue[0],nr=Ue.at(-1),or=ze[0],ar=ze.at(-1),lr=Ke[0],cr=Ke.at(-1),ur=Ye[0],fr=Ye.at(-1),hr=Ae[0],gr=Ae.at(-1),nt=19968,[dr,pr]=mr(Ae);function mr(t){let e=t[0],r=t[1];for(let s=0;s<t.length;s+=2){const i=t[s],o=t[s+1];if(nt>=i&&nt<=o)return[i,o];o-i>r-e&&(e=i,r=o)}return[e,r]}const br=t=>t<ir||t>nr?!1:ge(Ue,t),yr=t=>t<or||t>ar?!1:ge(ze,t),wr=t=>t<lr||t>cr?!1:ge(Ke,t),$r=t=>t<ur||t>fr?!1:ge(Ye,t),vr=t=>t>=dr&&t<=pr?!0:t<hr||t>gr?!1:ge(Ae,t);function xr(t){return br(t)?"ambiguous":yr(t)?"fullwidth":wr(t)?"halfwidth":$r(t)?"narrow":vr(t)?"wide":"neutral"}function Sr(t){if(!Number.isSafeInteger(t))throw new TypeError(`Expected a code point, got \`${typeof t}\`.`)}function $t(t){return Sr(t),xr(t)}const vt=String.raw,ot=vt`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,kr=()=>new RegExp(vt`\p{RI}{2}|(?![#*\d](?!\uFE0F?\u20E3))${ot}(?:\u200D${ot})*`,"gu"),ae=new Set(["\x1B","›"]),Le="\x07",xt="[",Qe="m",ke="]8;;",Er=39,Tr=/[\u200B\uFEFF\u2060-\u2064]/g,Ar=new RegExp(`(?:\\${xt}(?<code>\\d+)m|\\${ke}(?<uri>.*)${Le})`),Lr=Object.freeze(new Map([[0,0],[1,22],[2,22],[3,23],[4,24],[7,27],[8,28],[9,29],[30,39],[31,39],[32,39],[33,39],[34,39],[35,39],[36,39],[37,39],[40,49],[41,49],[42,49],[43,49],[44,49],[45,49],[46,49],[47,49],[90,39]])),le=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,ye=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,je=kr(),at=new Map,we=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,$e=t=>t>=32&&t<=126?"latin":t===8203||t===8204||t===8205||t===8288?"zero":t<=31||t>=127&&t<=159?"control":t>=160&&t<=255||t>=9472&&t<=9599?"latin":t>=4352&&t<=4607||t>=11904&&t<=40959||t>=44032&&t<=55215||t>=63744&&t<=64255||t>=65280&&t<=65519&&!(t>=65377&&t<=65439)||t>=12352&&t<=12543?"wide":t===8230?"latin":"other",Mr=(t,e)=>{const r=Math.floor(t/65536),s=t%65536;let i=at.get(r);if(i||(i=new Map,at.set(r,i)),i.has(s))return i.get(s);let o;if($e(t)==="latin")o=e.width.regular;else if($e(t)==="control")o=e.width.control;else if($e(t)==="wide")o=e.width.wide;else switch($t(t)){case"ambiguous":{o=e.width.ambiguousIsNarrow?e.width.regular:e.width.wide;break}case"fullwidth":{o=e.width.fullWidth;break}case"wide":{o=e.width.wide;break}default:o=e.width.regular}return i.set(s,o),o},Or=t=>t>=768&&t<=879||t>=6832&&t<=6911||t>=7616&&t<=7679||t>=8400&&t<=8447||t>=65056&&t<=65071||t>=917760&&t<=917999||t>=65024&&t<=65039||t>=3633&&t<=3642||t>=3655&&t<=3662||t>=3761&&t<=3769||t>=3771&&t<=3772||t>=3784&&t<=3789||t>=2304&&t<=2307||t>=2362&&t<=2383||t>=2385&&t<=2391||t>=2402&&t<=2403||t>=2433&&t<=2435||t>=2492&&t<=2500||t>=2509&&t<=2509||t>=2561&&t<=2563||t>=2620&&t<=2637||t>=1611&&t<=1631||t>=1648&&t<=1648||t>=1750&&t<=1773||t>=2276&&t<=2302||t>=1425&&t<=1469||t>=1471&&t<=1471||t>=1473&&t<=1474||t>=1476&&t<=1477||t>=1479&&t<=1479||t>=3893&&t<=3893||t>=3895&&t<=3895||t>=3897&&t<=3897||t>=3953&&t<=3966||t>=3968&&t<=3972||t>=3974&&t<=3975?!0:t>=768&&t<=777||t>=803&&t<=803,Ce=(t,e={})=>{if(!t||t.length===0)return{ellipsed:!1,index:0,truncated:!1,width:0};const r={truncation:{countAnsiEscapeCodes:e.countAnsiEscapeCodes??!1,ellipsis:e.ellipsis??"",ellipsisWidth:e.ellipsisWidth??(e.ellipsis?Ce(e.ellipsis,{...e,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width:0),limit:e.limit??Number.POSITIVE_INFINITY},width:{ambiguousIsNarrow:e.ambiguousIsNarrow??!1,ansi:e.ansiWidth??0,control:e.controlWidth??0,emoji:e.emojiWidth??2,fullWidth:e.fullWidth??2,halfWidth:e.halfWidth??1,regular:e.regularWidth??1,tab:e.tabWidth??8,wide:e.wideWidth??2}},s=Math.max(0,r.truncation.limit-r.truncation.ellipsisWidth),{length:i}=t,o=i>1e4;let a=0,n=0,c=i,u=!1;const l=t.includes("\x1B")||t.includes("›");for(;a<i;){if(l&&(t[a]==="\x1B"||t[a]==="›")){if(t.startsWith("\x1B]8;;",a)){const v="\x1B]8;;\x07",B=v.length,V=t.indexOf("\x07",a+5);if(V!==-1){const H=t.indexOf(v,V+1);if(H!==-1){const d=H+B,g=t.slice(V+1,H).replace(le,""),$=Ce(g,{ambiguousIsNarrow:r.width.ambiguousIsNarrow,ansiWidth:r.width.ansi,controlWidth:r.width.control,countAnsiEscapeCodes:!1,ellipsis:r.truncation.ellipsis,ellipsisWidth:r.truncation.ellipsisWidth,emojiWidth:r.width.emoji,fullWidth:r.width.fullWidth,halfWidth:r.width.halfWidth,limit:Math.max(0,s-n),regularWidth:r.width.regular,tabWidth:r.width.tab,wideWidth:r.width.wide}),I=$.width;if($.truncated)u=!0,c=Math.min(c,a);else if(n+I>s&&(c=Math.min(c,a),u=!0,n+I>r.truncation.limit))break;if(n+=I,a=d,u&&n>=r.truncation.limit)break;continue}}}if(le.lastIndex=a,le.test(t)){const v=le.lastIndex-a,B=r.truncation.countAnsiEscapeCodes?v:r.width.ansi;if(n+B>s&&(c=Math.min(c,a),n+B>r.truncation.limit)){u=!0;break}n+=B,a=le.lastIndex;continue}}const w=t.codePointAt(a);if(w===8203||w===65279||w>=8288&&w<=8292){a+=1;continue}if(w===9){if(n+r.width.tab>s&&(c=Math.min(c,a),n+r.width.tab>r.truncation.limit)){u=!0;break}n+=r.width.tab,a+=1;continue}if(we.lastIndex=a,we.test(t)){const v=(we.lastIndex-a)*r.width.regular;if(n+v>s){const B=Math.floor((s-n)/r.width.regular);if(c=Math.min(c,a+B),n+v>r.truncation.limit){u=!0;break}}n+=v,a=we.lastIndex;continue}if((w<=31||w>=127&&w<=159)&&(ye.lastIndex=a,ye.test(t))){const v=(ye.lastIndex-a)*r.width.control;if(n+v>s&&(c=Math.min(c,a+Math.floor((s-n)/r.width.control)),n+v>r.truncation.limit)){u=!0;break}n+=v,a=ye.lastIndex;continue}if(je.lastIndex=a,je.test(t)){if(n+r.width.emoji>s&&(c=Math.min(c,a),n+r.width.emoji>r.truncation.limit)){u=!0;break}n+=r.width.emoji,a=je.lastIndex;continue}const N=t.codePointAt(a)??0;if(Or(N)){a+=N>65535?2:1;continue}let k;if(o)k=Mr(N,r);else switch($e(N)){case"control":{k=r.width.control;break}case"latin":{k=r.width.regular;break}case"wide":{k=r.width.wide;break}case"zero":{k=0;break}default:switch($t(N)){case"ambiguous":{k=r.width.ambiguousIsNarrow?r.width.regular:r.width.wide;break}case"fullwidth":{k=r.width.fullWidth;break}case"wide":{k=r.width.wide;break}default:k=r.width.regular}}if(n+k>s&&(c=Math.min(c,a),n+k>r.truncation.limit)){u=!0;break}n+=k,a+=N>65535?2:1}let h=n,p=!1;return u&&r.truncation.limit>=r.truncation.ellipsisWidth&&(h=r.truncation.limit,p=!0),{ellipsed:p,index:u?c:i,truncated:u,width:h}},Z=(t,e={})=>Ce(t,{...e,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width,Br=/\x1B\[(\d+)m/;class St{activeForeground=void 0;activeBackground=void 0;activeFormatting=[];processEscape(e){const r=Br.exec(e);if(!r)return;const s=Number.parseInt(r[1],10);switch(s){case 0:{this.activeForeground=void 0,this.activeBackground=void 0,this.activeFormatting=[];break}case 39:{this.activeForeground=void 0;break}case 49:{this.activeBackground=void 0;break}default:if(s>=30&&s<=37||s>=90&&s<=97)this.activeForeground=e;else if(s>=40&&s<=47||s>=100&&s<=107)this.activeBackground=e;else if([1,2,3,4,7,8,9].includes(s))this.activeFormatting.push(e);else if([22,23,24,27,28,29].includes(s)){const i={22:"[1m",23:"[3m",24:"[4m",27:"[7m",28:"[8m",29:"[9m"}[s];i&&(this.activeFormatting=this.activeFormatting.filter(o=>!o.includes(i)))}}}getStartEscapesForAllActiveAttributes(){return[this.activeBackground,this.activeForeground,...this.activeFormatting].filter(Boolean).join("")}getEndEscapesForAllActiveAttributes(){const e=[];if(this.activeFormatting.length>0){const r={"\x1B[1m":"\x1B[22m","\x1B[2m":"\x1B[22m","\x1B[3m":"\x1B[23m","\x1B[4m":"\x1B[24m","\x1B[7m":"\x1B[27m","\x1B[8m":"\x1B[28m","\x1B[9m":"\x1B[29m"};[...this.activeFormatting].toReversed().forEach(s=>{const i=r[s];i&&e.push(i)})}return this.activeForeground&&e.push("\x1B[39m"),this.activeBackground&&e.push("\x1B[49m"),e.join("")}}const kt=(t,e)=>{if(!ae.has(t[e]))return{isInsideEscape:!1,isInsideLinkEscape:!1};const r=!0,s=t.slice(e+1,e+1+ke.length).join("")===ke;return{isInsideEscape:r,isInsideLinkEscape:s}},jr=(t,e={})=>{const r=new St;let s="",i=!1,o="",a="",n=!1;const c=[...t];for(let u=0;u<c.length;u++){const l=c[u];if(l&&ae.has(l)){if(s){const k=e.getWidth?.(s)??0,v={isEscapeSequence:!1,isGrapheme:!0,text:s,width:k};if(n&&(v.isHyperlink=!0,v.hyperlinkUrl=a),e.onSegment?.(v,r)===!1)return;s=""}i=!0,o=l;const w=kt(c,u),{isInsideLinkEscape:N}=w;if(N){let k=u+1;for(a="";k<c.length;){const B=c[k];if(B===Le)break;a+=B,k+=1}a=a.slice(4);const v={hyperlinkUrl:a,isEscapeSequence:!0,isGrapheme:!1,isHyperlink:!0,isHyperlinkStart:!0,width:0};if(e.onSegment?.(v,r)===!1)return;u=k,n=!0,i=!1,o="";continue}if(u+1<c.length&&c[u+1]==="\\"&&n){const k={isEscapeSequence:!0,isGrapheme:!1,isHyperlink:!0,isHyperlinkEnd:!0,width:0};if(e.onSegment?.(k,r)===!1)return;n=!1,a="",u+=1,i=!1,o="";continue}}if(i){if(o!==l&&(o+=l),l===Qe){i=!1,r.processEscape(o);const w={isEscapeSequence:!0,isGrapheme:!1,text:o,width:0};if(e.onSegment?.(w,r)===!1)return;o=""}continue}s+=l;const h=e.getWidth?.(s)??0,p={isEscapeSequence:!1,isGrapheme:!0,text:s,width:h};if(n&&(p.isHyperlink=!0,p.hyperlinkUrl=a),e.onSegment?.(p,r)===!1)return;s=""}if(s){const u=e.getWidth?.(s)??0,l={isEscapeSequence:!1,isGrapheme:!0,text:s,width:u};n&&(l.isHyperlink=!0,l.hyperlinkUrl=a),e.onSegment?.(l,r)}if(o){const u={isEscapeSequence:!0,isGrapheme:!1,text:o,width:0};e.onSegment?.(u,r)}},lt=t=>`${ae.values().next().value}${xt}${String(t)}${Qe}`,ct=t=>`${ae.values().next().value}${ke}${t}${Le}`,Nr=t=>{if(t.length===0)return"";if(t.length===1)return t[0];let e="",r,s;const i=t.join(`
2
2
  `),o=[...i];let a=0;for(const[n,c]of o.entries()){if(e+=c,ae.has(c)){const l=Ar.exec(i.slice(a))?.groups??{};if(l.code!==void 0){const h=Number.parseFloat(l.code);r=h===Er?void 0:h}else l.uri!==void 0&&(s=l.uri.length===0?void 0:l.uri)}const u=Lr.get(Number(r));o[n+1]===`
3
3
  `?(s&&(e+=ct("")),r&&u&&(e+=lt(u))):c===`
4
4
  `&&(r&&u&&(e+=lt(r)),s&&(e+=ct(s))),a+=c.length}return e},Et=/(?=\s)|(?<=\s)/,Tt=/^\s+$/,Ne=t=>{if(!t.includes("\x1B"))return t;let e=t;return t.includes("\x1B[30m")&&(e+="\x1B[39m"),t.includes("\x1B[42m")&&(e+="\x1B[49m"),e},te=t=>{const e=t.split(" ");let r=e.length;for(;r>0&&Z(e[r-1])===0;)r--;return r===e.length?t:e.slice(0,r).join(" ")+e.slice(r).join("")},At=(t,e,r)=>{if(t.length===0)return[""];if(e<=0)return[t];const s=[],i=new St;let o="",a=0,n=!1,c=!1,u="",l=0;for(;l<t.length;){const h=t[l];if(ae.has(h)){n=!0,u=h,o+=h,c=kt([...t],l).isInsideLinkEscape,l+=1;continue}if(n){u+=h,o+=h,c?h===Le&&(n=c=!1):h===Qe&&(n=!1,i.processEscape(u)),l+=1;continue}const p=Z(h),w=h===" ";if(p===0){o+=h,l+=1;continue}if(a+p>e&&(o&&s.push(o+i.getEndEscapesForAllActiveAttributes()),o=i.getStartEscapesForAllActiveAttributes(),a=Z(o),w&&r)){for(;l<t.length&&t[l]===" ";)l+=1;continue}if(o+=h,a+=p,a===e&&l<t.length-1&&(s.push(o+i.getEndEscapesForAllActiveAttributes()),o=i.getStartEscapesForAllActiveAttributes(),a=Z(o),l+1<t.length&&t[l+1]===" "&&r)){for(l+=1;l<t.length&&t[l]===" ";)l+=1;continue}l+=1}return o&&s.push(o+i.getEndEscapesForAllActiveAttributes()),r?s.map(h=>te(h)):s},Ir=(t,e,r)=>{if(t.length===0)return[];const s=r?t.trim():t;if(s.length===0)return[];const i=[];let o="",a=0;return jr(s,{getWidth:Z,onSegment:(n,c)=>{const u=n.text??"";if(n.isEscapeSequence)o+=u;else{const l=u===" ";if(n.width===0)return o+=u,!0;if(a+n.width>e&&(o&&i.push(o),o=c.getStartEscapesForAllActiveAttributes(),a=0,l))return r||i.push(c.getStartEscapesForAllActiveAttributes()+u),!0;o+=u,a+=n.width}return!0}}),o&&i.push(o),r?i.map(n=>te(n)):i},Pr=(t,e,r)=>{if(t.length===0)return[];const s=r?t.trim():t;if(s.length===0)return[];const i=s.split(Et),o=[];let a="",n=0,c=0;for(;c<i.length;){const u=i[c],l=Tt.test(u),h=Z(u);if(u.length===0){c+=1;continue}if(r&&l&&n===0){c+=1;continue}if(n+h>e&&n>0){r?o.push(te(a)):o.push(a),a="",n=0;continue}a+=u,n+=h,c+=1}return a&&(r?o.push(te(a)):o.push(a)),o},Fr=(t,e,r)=>{if(t.length===0)return[];const s=r?t.trim():t;if(s.length===0)return[];const i=s.split(Et),o=[];let a="",n=0,c=0;for(;c<i.length;){const u=i[c],l=Tt.test(u),h=Z(u);if(u.length===0){c+=1;continue}if(r&&l&&n===0){c+=1;continue}if(h>e){a&&o.push(Ne(r?te(a):a));const p=At(u,e,r);if(p.length>0){for(let w=0;w<p.length-1;w+=1)o.push(p[w]);a=p.at(-1),n=Z(a)}else a="",n=0;c+=1;continue}if(n+h>e&&n>0&&(o.push(Ne(r?te(a):a)),a="",n=0,r&&l)){c+=1;continue}a+=u,n+=h,c+=1}return a&&o.push(Ne(r?te(a):a)),o},fe={BREAK_AT_CHARACTERS:"BREAK_AT_CHARACTERS",BREAK_WORDS:"BREAK_WORDS",PRESERVE_WORDS:"PRESERVE_WORDS",STRICT_WIDTH:"STRICT_WIDTH"},Rr=(t,e={})=>{const{removeZeroWidthCharacters:r=!0,trim:s=!0,width:i=80,wrapMode:o=fe.PRESERVE_WORDS}=e;if(s&&t.trim()==="")return"";let a=t.normalize("NFC").replaceAll(`\r
@@ -25,4 +25,4 @@ ${this.codeFrame}
25
25
  `:""}catch(p){if(p.code!=="ENOENT")throw p}const c=o(t,s,u);await rg(e,`${c}${f}`,a)},"writeJson");var Og=Object.defineProperty,Ci=(e,t)=>Og(e,"name",{value:t,configurable:!0});const _g=F(import.meta.url),Pt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ag=Ci(e=>{if(typeof Pt<"u"&&Pt.versions&&Pt.versions.node){const[t,r]=Pt.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return Pt.getBuiltinModule(e)}return _g(e)},"__cjs_getBuiltinModule"),{readFileSync:xg}=Ag("node:fs");var Pg=Object.defineProperty,Rg=Ci((e,t)=>Pg(e,"name",{value:t,configurable:!0}),"r");const Tg=Rg((e,t,r={})=>{const{detectIndent:n,indent:i,replacer:s,stringify:o=JSON.stringify,...a}={indent:" ",...r};let u=i,f=`
26
26
  `;if(_e(e,or))try{const p=xg(e,"utf8");if(n){const{indent:d}=vr(p);u=d}f=p.endsWith(`
27
27
  `)?`
28
- `:""}catch(p){if(p.code!=="ENOENT")throw p}const c=o(t,s,u);hg(e,`${c}${f}`,a)},"writeJsonSync");var kg=Object.defineProperty,Ni=(e,t)=>kg(e,"name",{value:t,configurable:!0});const jg=F(import.meta.url),Rt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Tn=Ni(e=>{if(typeof Rt<"u"&&Rt.versions&&Rt.versions.node){const[t,r]=Rt.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return Rt.getBuiltinModule(e)}return jg(e)},"__cjs_getBuiltinModule"),Cg=Tn("fs"),Ng=Tn("os"),Mg=Tn("path");var Bg=Object.defineProperty,Lg=Ni((e,t)=>Bg(e,"name",{value:t,configurable:!0}),"a"),Dg=Object.defineProperty,wr=Lg((e,t)=>Dg(e,"name",{value:t,configurable:!0}),"s");const Mi=wr(e=>{let t="";for(let r=0;r<e.length;r+=1){const n=e[r],i=n.toUpperCase();t+=n===i?n.toLowerCase():i}return t},"invertCase"),jr=new Map,fo=wr((e,t)=>{const r=Mg.join(e,`.is-fs-case-sensitive-test-${process.pid}`);try{return t.writeFileSync(r,""),!t.existsSync(Mi(r))}finally{try{t.unlinkSync(r)}catch{}}},"checkDirectoryCaseWithWrite"),Fg=wr((e,t,r)=>{try{return fo(e,r)}catch(n){if(t===void 0)return fo(Ng.tmpdir(),r);throw n}},"checkDirectoryCaseWithFallback");wr((e,t=Cg,r=!0)=>{const n=e??process.cwd();if(r&&jr.has(n))return jr.get(n);let i;const s=Mi(n);return s!==n&&t.existsSync(n)?i=!t.existsSync(s):i=Fg(n,e,t),r&&jr.set(n,i),i},"isFsCaseSensitive");const fh=(e,t,r,n)=>{try{let i={};const s=Nt(t,"keystore.json");n&&_e(s)&&(i=_n(s)),Object.hasOwn(i,e)||(i[e]=new Date().toISOString()),Tg(s,i,{overwrite:!0})}catch(i){r.debug({context:[i],message:i instanceof Error?i.message:String(i),prefix:"cache-key-store"})}};export{qg as E,nh as F,Gg as H,Xg as I,lh as J,zg as K,rh as N,Jl as P,Tg as S,hg as T,ch as _,Wl as a,rg as b,_n as c,Ce as d,Kg as e,fh as f,xe as g,Qg as h,th as i,Ug as j,Yg as k,oh as l,ih as m,Vg as n,Jg as o,ir as p,Wg as q,qr as r,_e as s,wi as t,br as u};
28
+ `:""}catch(p){if(p.code!=="ENOENT")throw p}const c=o(t,s,u);hg(e,`${c}${f}`,a)},"writeJsonSync");var kg=Object.defineProperty,Ni=(e,t)=>kg(e,"name",{value:t,configurable:!0});const jg=F(import.meta.url),Rt=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Tn=Ni(e=>{if(typeof Rt<"u"&&Rt.versions&&Rt.versions.node){const[t,r]=Rt.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return Rt.getBuiltinModule(e)}return jg(e)},"__cjs_getBuiltinModule"),Cg=Tn("fs"),Ng=Tn("os"),Mg=Tn("path");var Bg=Object.defineProperty,Lg=Ni((e,t)=>Bg(e,"name",{value:t,configurable:!0}),"a"),Dg=Object.defineProperty,wr=Lg((e,t)=>Dg(e,"name",{value:t,configurable:!0}),"s");const Mi=wr(e=>{let t="";for(let r=0;r<e.length;r+=1){const n=e[r],i=n.toUpperCase();t+=n===i?n.toLowerCase():i}return t},"invertCase"),jr=new Map,fo=wr((e,t)=>{const r=Mg.join(e,`.is-fs-case-sensitive-test-${process.pid}`);try{return t.writeFileSync(r,""),!t.existsSync(Mi(r))}finally{try{t.unlinkSync(r)}catch{}}},"checkDirectoryCaseWithWrite"),Fg=wr((e,t,r)=>{try{return fo(e,r)}catch(n){if(t===void 0)return fo(Ng.tmpdir(),r);throw n}},"checkDirectoryCaseWithFallback");wr((e,t=Cg,r=!0)=>{const n=e??process.cwd();if(r&&jr.has(n))return jr.get(n);let i;const s=Mi(n);return s!==n&&t.existsSync(n)?i=!t.existsSync(s):i=Fg(n,e,t),r&&jr.set(n,i),i},"isFsCaseSensitive");const fh=(e,t,r,n)=>{try{let i={};const s=Nt(t,"keystore.json");_e(s)&&(i=_n(s)),Object.hasOwn(i,e)||(i[e]=new Date().toISOString()),Tg(s,i,{overwrite:!0})}catch(i){r.debug({context:[i],message:i instanceof Error?i.message:String(i),prefix:"cache-key-store"})}};export{qg as E,nh as F,Gg as H,Xg as I,lh as J,zg as K,rh as N,Jl as P,Tg as S,hg as T,ch as _,Wl as a,rg as b,_n as c,Ce as d,Kg as e,fh as f,xe as g,Qg as h,th as i,Ug as j,Yg as k,oh as l,ih as m,Vg as n,Jg as o,ir as p,Wg as q,qr as r,_e as s,wi as t,br as u};
@@ -0,0 +1 @@
1
+ import{j as s,t as a}from"./oxcTransformPlugin-Dwvbw2jE-DgTjbGep.js";export{s as oxcResolvePlugin,a as oxcTransformPlugin};