@visulima/packem 2.0.0-alpha.27 → 2.0.0-alpha.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/builder/typedoc/index.d.ts +4 -2
  3. package/dist/builder/typedoc/index.js +3 -3
  4. package/dist/cli/index.js +22 -22
  5. package/dist/config/index.d.ts +4 -2
  6. package/dist/index.d.ts +6 -4
  7. package/dist/index.js +1 -1
  8. package/dist/packem_shared/{default-Gd-5cD57.js → default-BGHvCOQE.js} +1 -1
  9. package/dist/packem_shared/default-BM-KR0tJ.js +1 -0
  10. package/dist/packem_shared/{default-Jms1t_Ru.js → default-D78T-lZt.js} +1 -1
  11. package/dist/packem_shared/{default-BOtIzYpr.js → default-DwVph-yx.js} +1 -1
  12. package/dist/packem_shared/esbuildPlugin-BrFhdKJk-BzTGlVjw.js +3 -0
  13. package/dist/packem_shared/{index-CFqWYreU.js → index-CMlYROc_.js} +83 -68
  14. package/dist/packem_shared/{index-B4tRN_2r.d.ts → index-DyxUGh2S.d.ts} +92 -4
  15. package/dist/packem_shared/isolatedDeclarationsTypescriptTransformer-DkuEkofo-CAV3IRk9.js +3 -0
  16. package/dist/packem_shared/oxcResolvePlugin-BJpi-eSG-D88S5wUe.js +1 -0
  17. package/dist/packem_shared/resolveTypescriptMjsCtsPlugin-DcZrZTmM-C40Ff4h5.js +6 -0
  18. package/dist/packem_shared/{types-CjNosz_D.d.ts → types-B3qw516E.d.ts} +1 -1
  19. package/dist/rollup/plugins/esbuild/index.d.ts +4 -2
  20. package/dist/rollup/plugins/esbuild/index.js +1 -1
  21. package/dist/rollup/plugins/oxc/isolated-declarations-oxc-transformer.d.ts +3 -1
  22. package/dist/rollup/plugins/oxc/oxc-transformer.d.ts +3 -1
  23. package/dist/rollup/plugins/sucrase/index.d.ts +3 -1
  24. package/dist/rollup/plugins/sucrase/index.js +1 -1
  25. package/dist/rollup/plugins/swc/isolated-declarations-swc-transformer.d.ts +3 -1
  26. package/dist/rollup/plugins/swc/swc-plugin.d.ts +4 -2
  27. package/dist/rollup/plugins/typescript/isolated-declarations-typescript-transformer.d.ts +3 -1
  28. package/dist/rollup/plugins/typescript/isolated-declarations-typescript-transformer.js +1 -1
  29. package/package.json +3 -3
  30. package/dist/packem_shared/default-BSK7122E.js +0 -1
  31. package/dist/packem_shared/esbuildPlugin-BrFhdKJk-ByenQxgl.js +0 -3
  32. package/dist/packem_shared/isolatedDeclarationsTypescriptTransformer-DkuEkofo-OpINP11F.js +0 -3
  33. package/dist/packem_shared/oxcResolvePlugin-BJpi-eSG-Dnnq2zke.js +0 -1
  34. package/dist/packem_shared/resolveTypescriptMjsCtsPlugin-DcZrZTmM-CKlu5gDZ.js +0 -6
@@ -6,16 +6,18 @@ import { RollupReplaceOptions } from '@rollup/plugin-replace';
6
6
  import { RollupWasmOptions } from '@rollup/plugin-wasm';
7
7
  import { FilterPattern } from '@rollup/pluginutils';
8
8
  import { RollupBuild, RollupOptions, RollupWatcher, OutputOptions, Plugin as Plugin$1 } from 'rollup';
9
- import { Options as Options$3 } from 'rollup-plugin-dts';
9
+ import { Options as Options$4 } from 'rollup-plugin-dts';
10
10
  import { NodePolyfillsOptions } from 'rollup-plugin-polyfill-node';
11
11
  import { PureAnnotationsOptions } from 'rollup-plugin-pure';
12
12
  import { PluginVisualizerOptions } from 'rollup-plugin-visualizer';
13
+ import { SourceMapOptions } from 'magic-string';
14
+ import { MinifierOptions } from 'html-minifier-next';
13
15
  import { TransformOptions as TransformOptions$1, Loader, BuildOptions } from 'esbuild';
14
16
  import { PackageJson } from '@visulima/package';
15
17
  import { AnsiColors as AnsiColors$1 } from '@visulima/colorize';
16
18
  import { NapiResolveOptions } from 'oxc-resolver';
17
19
  import { TransformOptions as TransformOptions$2, JsxOptions } from 'oxc-transform';
18
- import { Options as Options$4 } from 'sucrase';
20
+ import { Options as Options$5 } from 'sucrase';
19
21
 
20
22
  type AnsiColors = "bgBlack" | "bgBlackBright" | "bgBlue" | "bgBlueBright" | "bgCyan" | "bgCyanBright" | "bgGray" | "bgGreen" | "bgGreenBright" | "bgGrey" | "bgMagenta" | "bgMagentaBright" | "bgRed" | "bgRedBright" | "bgWhite" | "bgWhiteBright" | "bgYellow" | "bgYellowBright" | "black" | "blackBright" | "blue" | "blueBright" | "cyan" | "cyanBright" | "gray" | "green" | "greenBright" | "grey" | "magenta" | "magentaBright" | "red" | "redBright" | "white" | "whiteBright" | "yellow" | "yellowBright";
21
23
 
@@ -267,6 +269,92 @@ declare class PailServerImpl$1<T extends string = string, L extends string = str
267
269
  }
268
270
  type PailServerType$1<T extends string = string, L extends string = string> = PailServerImpl$1<T, L> & Record<DefaultLogTypes$1, LoggerFunction$1> & Record<T, LoggerFunction$1> & (new <TC extends string = string, LC extends string = string>(options?: ServerConstructorOptions$1<TC, LC>) => PailServerType$1<TC, LC>);
269
271
 
272
+ interface Template {
273
+ parts: TemplatePart[];
274
+ tag?: string;
275
+ }
276
+ interface TemplatePart {
277
+ end: number;
278
+ start: number;
279
+ text: string;
280
+ }
281
+ interface Strategy$1<N = unknown> {
282
+ getRootNode: (source: string, fileName?: string) => N;
283
+ getTaggedTemplateTemplate: (node: N) => unknown;
284
+ getTagText: (node: N) => string;
285
+ getTemplateParts: (node: N) => TemplatePart[];
286
+ isTaggedTemplate: (node: N) => boolean;
287
+ isTemplate: (node: N) => boolean;
288
+ walkNodes: (parent: N, visit: (child: N) => void) => void;
289
+ }
290
+
291
+ interface ParseLiteralsOptions {
292
+ fileName?: string;
293
+ strategy?: Partial<Strategy$1<unknown>>;
294
+ }
295
+ declare const parseLiterals: (source: string, options?: ParseLiteralsOptions) => Template[];
296
+
297
+ interface Strategy<O = unknown, C = unknown> {
298
+ combineHTMLStrings: (parts: TemplatePart[], placeholder: string) => string;
299
+ getPlaceholder: (parts: TemplatePart[]) => string;
300
+ minifyCSS?: (css: string, options?: C) => string;
301
+ minifyHTML: (html: string, options?: O) => string | Promise<string>;
302
+ splitHTMLByPlaceholder: (html: string, placeholder: string) => string[];
303
+ }
304
+ declare const defaultMinifyOptions: MinifierOptions;
305
+
306
+ type Options$3 = DefaultOptions | CustomOptions<unknown>;
307
+ interface DefaultOptions extends BaseOptions {
308
+ minifyOptions?: Partial<typeof defaultMinifyOptions>;
309
+ }
310
+ interface CustomOptions<S extends Strategy | unknown> extends BaseOptions {
311
+ minifyOptions?: S extends Strategy<infer O> ? Partial<O> : never;
312
+ strategy: S;
313
+ }
314
+ interface BaseOptions {
315
+ fileName?: string;
316
+ generateSourceMap?: ((ms: MagicStringLike, fileName: string) => SourceMap | undefined) | false;
317
+ MagicString?: new (source: string) => MagicStringLike;
318
+ parseLiterals?: typeof parseLiterals;
319
+ parseLiteralsOptions?: Partial<ParseLiteralsOptions>;
320
+ shouldMinify?: (template: Template) => boolean;
321
+ shouldMinifyCSS?: (template: Template) => boolean;
322
+ validate?: Validation | false;
323
+ }
324
+ interface MagicStringLike {
325
+ generateMap: (options?: Partial<SourceMapOptions>) => SourceMap;
326
+ overwrite: (start: number, end: number, content: string) => unknown;
327
+ toString: () => string;
328
+ }
329
+ interface SourceMap {
330
+ file?: string;
331
+ mappings: string;
332
+ names: string[];
333
+ sources: string[];
334
+ sourcesContent?: string[];
335
+ toString: () => string;
336
+ toUrl: () => string;
337
+ version: number;
338
+ }
339
+ interface Validation {
340
+ ensureHTMLPartsValid: (parts: TemplatePart[], htmlParts: string[]) => void;
341
+ ensurePlaceholderValid: (placeholder: unknown) => void;
342
+ }
343
+ interface Result {
344
+ code: string;
345
+ map: SourceMap | undefined;
346
+ }
347
+ declare function minifyHTMLLiterals(source: string, options?: DefaultOptions): Promise<Result | null>;
348
+ declare function minifyHTMLLiterals<S extends Strategy>(source: string, options?: CustomOptions<S>): Promise<Result | null>;
349
+
350
+ interface MinifyHTMLLiteralsOptions {
351
+ exclude?: FilterPattern;
352
+ failOnError?: boolean;
353
+ include?: FilterPattern;
354
+ minifyHTMLLiterals?: typeof minifyHTMLLiterals;
355
+ options?: Partial<Options$3>;
356
+ }
357
+
270
358
  /**
271
359
  Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
272
360
 
@@ -3064,7 +3152,7 @@ type OxcResolveOptions = Omit<NapiResolveOptions, "tsconfig"> & {
3064
3152
  ignoreSideEffectsForRoot?: boolean;
3065
3153
  };
3066
3154
 
3067
- interface SucrasePluginConfig extends Options$4 {
3155
+ interface SucrasePluginConfig extends Options$5 {
3068
3156
  exclude?: FilterPattern;
3069
3157
  include?: FilterPattern;
3070
3158
  }
@@ -5215,7 +5303,7 @@ interface PackemRollupOptions {
5215
5303
  copy?: CopyPluginOptions | false;
5216
5304
  dataUri?: DataUriPluginOptions | false;
5217
5305
  debarrel?: DebarrelPluginOptions | false;
5218
- dts: Options$3;
5306
+ dts: Options$4;
5219
5307
  dynamicVars?: RollupDynamicImportVariablesOptions | false;
5220
5308
  esbuild?: Options$1 | false;
5221
5309
  experimental?: {
@@ -0,0 +1,3 @@
1
+ var m=Object.defineProperty;var l=(e,r)=>m(e,"name",{value:r,configurable:!0});import{createRequire as f}from"node:module";const d=f(import.meta.url);const O=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,{transpileDeclaration:y,formatDiagnostics:_,sys:o}=d("typescript");var b=Object.defineProperty,v=l((e,r)=>b(e,"name",{value:r,configurable:!0}),"p"),j=Object.defineProperty,N=v((e,r)=>j(e,"name",{value:r,configurable:!0}),"l"),T=Object.defineProperty,t=N((e,r)=>T(e,"name",{value:r,configurable:!0}),"s");const C=t(e=>{const r=e.split(`
2
+ `);return r.at(-1)?.startsWith("//# sourceMappingURL=")?r.slice(0,-1).join(`
3
+ `):e},"stripMapUrl"),h=t(async(e,r,u,n)=>{const a={declarationMap:u,...n?.compilerOptions};let{diagnostics:c,outputText:i,sourceMapText:s}=y(r,{fileName:e,reportDiagnostics:!0,...n,compilerOptions:a});a.declarationMap&&(i=C(i));const g=c?.length?[_(c,{getCanonicalFileName:t(p=>o.useCaseSensitiveFileNames?p:p.toLowerCase(),"getCanonicalFileName"),getCurrentDirectory:t(()=>o.getCurrentDirectory(),"getCurrentDirectory"),getNewLine:t(()=>o.newLine,"getNewLine")})]:[];return s&&(s=JSON.parse(s).mappings),{errors:g,map:s,sourceText:i}},"isolatedDeclarationsTypescriptTransformer");export{h as v};
@@ -0,0 +1 @@
1
+ var R=Object.defineProperty;var y=(r,e)=>R(r,"name",{value:e,configurable:!0});import{createRequire as w}from"node:module";import{createFilter as M}from"@rollup/pluginutils";import{findPackageJson as S}from"@visulima/package/package-json";import{dirname as a}from"@visulima/path";const F=w(import.meta.url);const N=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,{ResolverFactory:k}=F("oxc-resolver");var O=Object.defineProperty,q=y((r,e)=>O(r,"name",{value:e,configurable:!0}),"y"),T=Object.defineProperty,A=q((r,e)=>T(r,"name",{value:e,configurable:!0}),"g"),B=Object.defineProperty,u=A((r,e)=>B(r,"name",{value:e,configurable:!0}),"a");let x;const J=new Map,G=u((r,e,_,p)=>{const{ignoreSideEffectsForRoot:h,...i}=r;let c=x;return c||(c=x=new k({...i,roots:[...i.roots??[],e],tsconfig:p?{configFile:p,references:"auto"}:void 0})),{name:"oxc-resolve",resolveId:{async handler(m,l,{isEntry:j}){const g=j||!l?a(m):a(l),{error:v,path:o}=await c.async(g,m);if(v){_.debug(v,{context:[{basedir:e,extensions:i.extensions,id:o}]});return}let f=u(t=>!1,"hasModuleSideEffects");try{const{packageJson:t,path:E}=await S(a(o),{cache:J}),b=a(E);if(!h||e!==b){const n=t.sideEffects;if(typeof n=="boolean")f=u(()=>n,"hasModuleSideEffects");else if(Array.isArray(n)){const P=n.map(d=>d.includes("/")?d:`**/${d}`);f=M(P,void 0,{resolve:b})}}}catch(t){console.debug(t.message,{context:[{basedir:g,caller:"Resolver",error:t,extensions:i.extensions,id:o}]})}const s=await this.resolve(o,l,{skipSelf:!0});if(s)return s.external?!1:s.id!==o?s:{id:o,meta:s.meta,moduleSideEffects:f(o)}},order:"post"}}},"oxcResolvePlugin");export{G as z};
@@ -0,0 +1,6 @@
1
+ var D=Object.defineProperty;var u=(t,e)=>D(t,"name",{value:e,configurable:!0});import{createRequire as E}from"node:module";import{parse as F}from"@babel/parser";import{findStaticImports as Z}from"mlly";import{isAbsolute as z,join as B,dirname as G,resolve as N}from"@visulima/path";import{isRelative as H}from"@visulima/path/utils";const U=E(import.meta.url);const Fe=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,L=U("magic-string");var J=Object.defineProperty,m=u((t,e)=>J(t,"name",{value:e,configurable:!0}),"u$1"),K=Object.defineProperty,h=m((t,e)=>K(t,"name",{value:e,configurable:!0}),"n"),Q=Object.defineProperty,x=h((t,e)=>Q(t,"name",{value:e,configurable:!0}),"i");let I=class{static{u(this,"y")}static{m(this,"_")}static{h(this,"WalkerBase")}static{x(this,"WalkerBase")}constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:x(()=>this.should_skip=!0,"skip"),remove:x(()=>this.should_remove=!0,"remove"),replace:x(e=>this.replacement=e,"replace")}}replace(e,s,r,n){e&&s&&(r!=null?e[s][r]=n:e[s]=n)}remove(e,s,r){e&&s&&(r!=null?e[s].splice(r,1):delete e[s])}};var V=Object.defineProperty,g=h((t,e)=>V(t,"name",{value:e,configurable:!0}),"c$1");let X=class extends I{static{u(this,"A")}static{m(this,"x")}static{h(this,"SyncWalker")}static{g(this,"SyncWalker")}constructor(e,s){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:g(()=>this.should_skip=!0,"skip"),remove:g(()=>this.should_remove=!0,"remove"),replace:g(r=>this.replacement=r,"replace")},this.enter=e,this.leave=s}visit(e,s,r,n){if(e){if(this.enter){const i=this.should_skip,o=this.should_remove,l=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,e,s,r,n),this.replacement&&(e=this.replacement,this.replace(s,r,n,e)),this.should_remove&&this.remove(s,r,n);const a=this.should_skip,p=this.should_remove;if(this.should_skip=i,this.should_remove=o,this.replacement=l,a)return e;if(p)return null}let c;for(c in e){const i=e[c];if(i&&typeof i=="object")if(Array.isArray(i)){const o=i;for(let l=0;l<o.length;l+=1){const a=o[l];y(a)&&(this.visit(a,e,c,l)||l--)}}else y(i)&&this.visit(i,e,c,null)}if(this.leave){const i=this.replacement,o=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,e,s,r,n),this.replacement&&(e=this.replacement,this.replace(s,r,n,e)),this.should_remove&&this.remove(s,r,n);const l=this.should_remove;if(this.replacement=i,this.should_remove=o,l)return null}}return e}};function y(t){return t!==null&&typeof t=="object"&&"type"in t&&typeof t.type=="string"}u(y,"d$2");m(y,"f");h(y,"n");g(y,"isNode");var Y=Object.defineProperty,b=h((t,e)=>Y(t,"name",{value:e,configurable:!0}),"c");let ee=class extends I{static{u(this,"P")}static{m(this,"j")}static{h(this,"AsyncWalker")}static{b(this,"AsyncWalker")}constructor(e,s){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:b(()=>this.should_skip=!0,"skip"),remove:b(()=>this.should_remove=!0,"remove"),replace:b(r=>this.replacement=r,"replace")},this.enter=e,this.leave=s}async visit(e,s,r,n){if(e){if(this.enter){const i=this.should_skip,o=this.should_remove,l=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,await this.enter.call(this.context,e,s,r,n),this.replacement&&(e=this.replacement,this.replace(s,r,n,e)),this.should_remove&&this.remove(s,r,n);const a=this.should_skip,p=this.should_remove;if(this.should_skip=i,this.should_remove=o,this.replacement=l,a)return e;if(p)return null}let c;for(c in e){const i=e[c];if(i&&typeof i=="object")if(Array.isArray(i)){const o=i;for(let l=0;l<o.length;l+=1){const a=o[l];$(a)&&(await this.visit(a,e,c,l)||l--)}}else $(i)&&await this.visit(i,e,c,null)}if(this.leave){const i=this.replacement,o=this.should_remove;this.replacement=null,this.should_remove=!1,await this.leave.call(this.context,e,s,r,n),this.replacement&&(e=this.replacement,this.replace(s,r,n,e)),this.should_remove&&this.remove(s,r,n);const l=this.should_remove;if(this.replacement=i,this.should_remove=o,l)return null}}return e}};function $(t){return t!==null&&typeof t=="object"&&"type"in t&&typeof t.type=="string"}u($,"f$2");m($,"d");h($,"a$1");b($,"isNode");var te=Object.defineProperty,C=h((t,e)=>te(t,"name",{value:e,configurable:!0}),"a");function j(t,{enter:e,leave:s}){return new X(e,s).visit(t,null)}u(j,"k$1");m(j,"A");h(j,"walk");C(j,"walk");async function P(t,{enter:e,leave:s}){return await new ee(e,s).visit(t,null)}u(P,"w$3");m(P,"O");h(P,"asyncWalk");C(P,"asyncWalk");var se=Object.defineProperty,A=u((t,e)=>se(t,"name",{value:e,configurable:!0}),"l$1"),re=Object.defineProperty,T=A((t,e)=>re(t,"name",{value:e,configurable:!0}),"l"),ie=Object.defineProperty,d=T((t,e)=>ie(t,"name",{value:e,configurable:!0}),"r");const ne=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,oe=/MIT License|MIT license|BSD license/,le=/\n{2,}/g,ae=/\b(\w+)\$\d+\b/g,ce=/[-/\\^$*+?.()|[\]{}]/g,ue=d(t=>t.replaceAll(ce,String.raw`\$&`),"escapeRegex"),pe=d(t=>[...new Set(t)],"unique"),he=d(t=>t.replaceAll(ne,e=>oe.test(e)?"":e).replaceAll(le,`
2
+
3
+ `),"cleanUnnecessaryComments"),R=new Map;function w(t,e,{identifierReplacements:s},r){const n=Z(t);for(const i in s){const o=n.find(a=>a.specifier===i&&a.imports.includes("{"));if(!o){this.warn(`${e.fileName} does not import "${i}" for replacement`),process.exitCode=1;continue}const l=s[i];for(const a in l){if(!o.imports.includes(a))throw new Error(`${e.fileName} does not import "${a}" from "${i}" for replacement`);const p=l[a],v=ue(a);p.includes(".")&&(t=t.replace(new RegExp(`\\b\\w+\\b as ${v},?\\s?`),"")),t=t.replaceAll(new RegExp(`\\b${v}\\b`,"g"),p)}}const c=pe(Array.from(t.matchAll(ae),i=>i[0]));if(c.length>0){const i=c.map(l=>`
4
+ - ${l}`).join(""),o=e.fileName.replace(/\.[^/.]+$/,"");R.has(o)||r.warn({message:`${e.fileName} contains confusing identifier names${i}
5
+
6
+ To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),R.set(o,!0)}return t}u(w,"f$1");A(w,"g");T(w,"I");d(w,"replaceConfusingTypeNames");const fe=d((t,e)=>{if(e.leadingComments?.some(s=>s.type==="CommentBlock"&&s.value.includes("@internal"))){const s=t.original[e.end]===","?e.end+1:e.end;return t.remove(e.leadingComments[0].start,s),!0}return!1},"removeInternal");function O(t,e){if(t.includes("@internal")){const s=new L(t),r=F(t,{plugins:["typescript"],sourceType:"module"});if(j(r,{enter(n){fe(s,n)&&this.skip()}}),t=s.toString(),t.includes("@internal"))throw new Error(`${e.fileName} has unhandled @internal declarations`)}return t}u(O,"u");A(O,"h");T(O,"S");d(O,"stripInternalTypes");const Qe=d((t,e)=>({name:"packem:patch-types",renderChunk(s,r){return s=w.call(this,s,r,t,e),s=O.call(this,s,r),s=he(s),s}}),"patchTypescriptTypes");var me=Object.defineProperty,de=u((t,e)=>me(t,"name",{value:e,configurable:!0}),"d$1"),ve=Object.defineProperty,ge=de((t,e)=>ve(t,"name",{value:e,configurable:!0}),"d"),be=Object.defineProperty,f=ge((t,e)=>be(t,"name",{value:e,configurable:!0}),"o");const ye=42,$e=f(t=>{let e=!1;for(let s=0;s<t.length;s++)if(t.codePointAt(s)===ye){if(e)return!1;e=!0}return!0},"hasZeroOrOneAsteriskCharacter"),_e=f(t=>{const e=t.indexOf("*");return e===-1?void 0:{prefix:t.slice(0,e),suffix:t.slice(e+1)}},"tryParsePattern"),ke=f(({prefix:t,suffix:e},s)=>s.length>=t.length+e.length&&s.startsWith(t)&&s.endsWith(e),"isPatternMatch"),xe=f((t,e,s)=>{let r,n=-1;for(const c of t){const i=e(c);ke(i,s)&&i.prefix.length>n&&(n=i.prefix.length,r=c)}return r},"findBestPatternMatch"),je=f((t,e)=>{const s=[];for(const r of t){if(!$e(r))continue;const n=_e(r);if(n)s.push(n);else if(r===e)return r}return xe(s,r=>r,e)},"matchPatternOrExact"),we=f((t,e)=>e.substring(t.prefix.length,e.length-t.suffix.length),"matchedText"),Oe=f(({prefix:t,suffix:e})=>`${t}*${e}`,"patternText"),Pe=f((t,e,s)=>{let r=G(e.path);e.config.compilerOptions?.baseUrl&&(r=N(t,e.config.compilerOptions.baseUrl)),s?.debug({message:`Resolved baseUrl to ${r}`,prefix:"plugin:resolve-tsconfig-paths"});const n=e.config.compilerOptions?.paths??{};return Object.keys(n).length===0&&s?.debug({message:"No paths found in tsconfig.json",prefix:"plugin:resolve-tsconfig-paths"}),{paths:n,resolvedBaseUrl:r}},"getTsconfigPaths"),Ve=f((t,e,s,r)=>{const{paths:n,resolvedBaseUrl:c}=Pe(t,e,s),i=Object.keys(n);return{name:"plugin:resolve-tsconfig-paths",async resolveId(o,l,a){if(i.length===0)return;if(o.includes("\0")){s.debug({message:`Skipping resolution of ${o} as it is a virtual module`,prefix:"plugin:resolve-tsconfig-paths"});return}if(o.includes("node_modules")){s.debug({message:`Skipping request as it is inside node_modules ${o}`,prefix:"plugin:resolve-tsconfig-paths"});return}if(!r.resolveAbsolutePath&&z(o)){s.debug({message:`Skipping request as it is an absolute path ${o}`,prefix:"plugin:resolve-tsconfig-paths"});return}if(H(o)){s.debug({message:`Skipping request as it is a relative path ${o}`,prefix:"plugin:resolve-tsconfig-paths"});return}const p=je(i,o);if(!p){s.debug({message:`moduleName did not match any paths pattern ${o}`,prefix:"plugin:resolve-tsconfig-paths"});return}const v=typeof p=="string"?void 0:we(p,o),q=typeof p=="string"?p:Oe(p);for await(const W of n[q]){const _=v?W.replace("*",v):W;if(_.endsWith(".d.ts")||_.endsWith(".d.cts")||_.endsWith(".d.mts"))continue;const S=B(c,_);try{const k=await this.resolve(S,l,{skipSelf:!0,...a});if(k)return k}catch(k){s.debug({context:[k],message:`Failed to resolve ${S} from ${o}`,prefix:"plugin:resolve-tsconfig-paths"})}}}}},"resolveTsconfigPathsPlugin");var Ae=Object.defineProperty,Te=u((t,e)=>Ae(t,"name",{value:e,configurable:!0}),"f"),We=Object.defineProperty,Se=Te((t,e)=>We(t,"name",{value:e,configurable:!0}),"c"),Re=Object.defineProperty,M=Se((t,e)=>Re(t,"name",{value:e,configurable:!0}),"u");const Be=M((t,e)=>{if(!e)return;const{config:s,path:r}=e;if(!s.compilerOptions)return;const{rootDirs:n}=s.compilerOptions;if(!n)return;const c=[];for(const i of n){if(i.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${r}.`);if(i.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${r}.`);c.push(N(t,i))}return c},"getRootDirectories"),Xe=M((t,e,s)=>{const r=Be(t,s);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(n,c,i){if(!(r===void 0||r.length===0)&&n.startsWith("."))for(const o of r){const l=B(o,n),a=await this.resolve(l,c,{skipSelf:!0,...i});if(a)return e.debug({message:`Resolved ${n} to ${a.id} using rootDirs from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-root-dirs"}),a.id}}}},"resolveTsconfigRootDirectories");var Ne=Object.defineProperty,Ie=u((t,e)=>Ne(t,"name",{value:e,configurable:!0}),"t"),Ce=Object.defineProperty,Me=Ie((t,e)=>Ce(t,"name",{value:e,configurable:!0}),"t"),qe=Object.defineProperty,De=Me((t,e)=>qe(t,"name",{value:e,configurable:!0}),"r");const Ye=De(()=>{const t=/\.(?:[mc]?js|jsx)$/;return{name:"packem:resolve-typescript-mjs-cjs",async resolveId(e,s,r){if(t.test(e)&&s)return await this.resolve(e.replace(/js(x?)$/,"ts$1"),s,r)}}},"resolveTypescriptMjsCts");export{Qe as B,Xe as D,Ve as N,Ye as i,j as k};
@@ -1,5 +1,5 @@
1
1
  import { CheckPackageOptions } from '@arethetypeswrong/core';
2
- import { B as BuildContext, E as Environment, R as Runtime, I as IsolatedDeclarationsTransformer, F as Format, P as PackemRollupOptions, T as TransformerFn, d as BuildHooks, g as InternalOXCTransformPluginConfig, a as TransformerName, M as Mode } from './index-B4tRN_2r.js';
2
+ import { B as BuildContext, E as Environment, R as Runtime, I as IsolatedDeclarationsTransformer, F as Format, P as PackemRollupOptions, T as TransformerFn, d as BuildHooks, g as InternalOXCTransformPluginConfig, a as TransformerName, M as Mode } from './index-DyxUGh2S.js';
3
3
  import { StyleOptions } from '@visulima/rollup-plugin-css';
4
4
  import { JitiOptions } from 'jiti';
5
5
  import { TypeDocOptions } from 'typedoc';
@@ -1,5 +1,5 @@
1
- import { T as TransformerFn } from '../../../packem_shared/index-B4tRN_2r.js';
2
- export { e as EsbuildPluginConfig } from '../../../packem_shared/index-B4tRN_2r.js';
1
+ import { T as TransformerFn } from '../../../packem_shared/index-DyxUGh2S.js';
2
+ export { e as EsbuildPluginConfig } from '../../../packem_shared/index-DyxUGh2S.js';
3
3
  import '@rollup/plugin-alias';
4
4
  import '@rollup/plugin-commonjs';
5
5
  import '@rollup/plugin-json';
@@ -12,6 +12,8 @@ import 'rollup-plugin-dts';
12
12
  import 'rollup-plugin-polyfill-node';
13
13
  import 'rollup-plugin-pure';
14
14
  import 'rollup-plugin-visualizer';
15
+ import 'magic-string';
16
+ import 'html-minifier-next';
15
17
  import 'esbuild';
16
18
  import '@visulima/package';
17
19
  import '@visulima/colorize';
@@ -1 +1 @@
1
- import{z as f}from"../../../packem_shared/esbuildPlugin-BrFhdKJk-ByenQxgl.js";export{f as default};
1
+ import{z as f}from"../../../packem_shared/esbuildPlugin-BrFhdKJk-BzTGlVjw.js";export{f as default};
@@ -1,5 +1,5 @@
1
1
  import { IsolatedDeclarationsOptions } from 'oxc-transform';
2
- import { f as IsolatedDeclarationsResult, T as TransformerFn } from '../../../packem_shared/index-B4tRN_2r.js';
2
+ import { f as IsolatedDeclarationsResult, T as TransformerFn } from '../../../packem_shared/index-DyxUGh2S.js';
3
3
  import '@rollup/plugin-alias';
4
4
  import '@rollup/plugin-commonjs';
5
5
  import '@rollup/plugin-json';
@@ -12,6 +12,8 @@ import 'rollup-plugin-dts';
12
12
  import 'rollup-plugin-polyfill-node';
13
13
  import 'rollup-plugin-pure';
14
14
  import 'rollup-plugin-visualizer';
15
+ import 'magic-string';
16
+ import 'html-minifier-next';
15
17
  import 'esbuild';
16
18
  import '@visulima/package';
17
19
  import '@visulima/colorize';
@@ -1,6 +1,6 @@
1
1
  export { o as default, default as isolatedDeclarationsOxcTransformer } from './isolated-declarations-oxc-transformer.js';
2
2
  import 'oxc-transform';
3
- import '../../../packem_shared/index-B4tRN_2r.js';
3
+ import '../../../packem_shared/index-DyxUGh2S.js';
4
4
  import '@rollup/plugin-alias';
5
5
  import '@rollup/plugin-commonjs';
6
6
  import '@rollup/plugin-json';
@@ -13,6 +13,8 @@ import 'rollup-plugin-dts';
13
13
  import 'rollup-plugin-polyfill-node';
14
14
  import 'rollup-plugin-pure';
15
15
  import 'rollup-plugin-visualizer';
16
+ import 'magic-string';
17
+ import 'html-minifier-next';
16
18
  import 'esbuild';
17
19
  import '@visulima/package';
18
20
  import '@visulima/colorize';
@@ -1,4 +1,4 @@
1
- export { h as SucrasePluginConfig, s as default } from '../../../packem_shared/index-B4tRN_2r.js';
1
+ export { h as SucrasePluginConfig, s as default } from '../../../packem_shared/index-DyxUGh2S.js';
2
2
  import '@rollup/plugin-alias';
3
3
  import '@rollup/plugin-commonjs';
4
4
  import '@rollup/plugin-json';
@@ -11,6 +11,8 @@ import 'rollup-plugin-dts';
11
11
  import 'rollup-plugin-polyfill-node';
12
12
  import 'rollup-plugin-pure';
13
13
  import 'rollup-plugin-visualizer';
14
+ import 'magic-string';
15
+ import 'html-minifier-next';
14
16
  import 'esbuild';
15
17
  import '@visulima/package';
16
18
  import '@visulima/colorize';
@@ -1 +1 @@
1
- import{sucrasePlugin as r}from"../../../packem_shared/default-BSK7122E.js";export{r as default};
1
+ import{sucrasePlugin as r}from"../../../packem_shared/default-BM-KR0tJ.js";export{r as default};
@@ -1,5 +1,5 @@
1
1
  export { i as default } from './swc-plugin.js';
2
- import '../../../packem_shared/index-B4tRN_2r.js';
2
+ import '../../../packem_shared/index-DyxUGh2S.js';
3
3
  import '@rollup/plugin-alias';
4
4
  import '@rollup/plugin-commonjs';
5
5
  import '@rollup/plugin-json';
@@ -12,6 +12,8 @@ import 'rollup-plugin-dts';
12
12
  import 'rollup-plugin-polyfill-node';
13
13
  import 'rollup-plugin-pure';
14
14
  import 'rollup-plugin-visualizer';
15
+ import 'magic-string';
16
+ import 'html-minifier-next';
15
17
  import 'esbuild';
16
18
  import '@visulima/package';
17
19
  import '@visulima/colorize';
@@ -1,5 +1,5 @@
1
- import { T as TransformerFn, f as IsolatedDeclarationsResult } from '../../../packem_shared/index-B4tRN_2r.js';
2
- export { S as SwcPluginConfig } from '../../../packem_shared/index-B4tRN_2r.js';
1
+ import { T as TransformerFn, f as IsolatedDeclarationsResult } from '../../../packem_shared/index-DyxUGh2S.js';
2
+ export { S as SwcPluginConfig } from '../../../packem_shared/index-DyxUGh2S.js';
3
3
  import '@rollup/plugin-alias';
4
4
  import '@rollup/plugin-commonjs';
5
5
  import '@rollup/plugin-json';
@@ -12,6 +12,8 @@ import 'rollup-plugin-dts';
12
12
  import 'rollup-plugin-polyfill-node';
13
13
  import 'rollup-plugin-pure';
14
14
  import 'rollup-plugin-visualizer';
15
+ import 'magic-string';
16
+ import 'html-minifier-next';
15
17
  import 'esbuild';
16
18
  import '@visulima/package';
17
19
  import '@visulima/colorize';
@@ -1,5 +1,5 @@
1
1
  import { TranspileOptions } from 'typescript';
2
- import { f as IsolatedDeclarationsResult } from '../../../packem_shared/index-B4tRN_2r.js';
2
+ import { f as IsolatedDeclarationsResult } from '../../../packem_shared/index-DyxUGh2S.js';
3
3
  import '@rollup/plugin-alias';
4
4
  import '@rollup/plugin-commonjs';
5
5
  import '@rollup/plugin-json';
@@ -12,6 +12,8 @@ import 'rollup-plugin-dts';
12
12
  import 'rollup-plugin-polyfill-node';
13
13
  import 'rollup-plugin-pure';
14
14
  import 'rollup-plugin-visualizer';
15
+ import 'magic-string';
16
+ import 'html-minifier-next';
15
17
  import 'esbuild';
16
18
  import '@visulima/package';
17
19
  import '@visulima/colorize';
@@ -1 +1 @@
1
- import{v as f}from"../../../packem_shared/isolatedDeclarationsTypescriptTransformer-DkuEkofo-OpINP11F.js";export{f as default};
1
+ import{v as f}from"../../../packem_shared/isolatedDeclarationsTypescriptTransformer-DkuEkofo-CAV3IRk9.js";export{f as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/packem",
3
- "version": "2.0.0-alpha.27",
3
+ "version": "2.0.0-alpha.28",
4
4
  "description": "A fast and modern bundler for Node.js and TypeScript.",
5
5
  "keywords": [
6
6
  "anolilab",
@@ -171,7 +171,7 @@
171
171
  "@visulima/fs": "3.1.8",
172
172
  "@visulima/humanizer": "1.2.2",
173
173
  "@visulima/package": "4.0.0",
174
- "@visulima/packem-rollup": "1.0.0-alpha.21",
174
+ "@visulima/packem-rollup": "1.0.0-alpha.22",
175
175
  "@visulima/packem-share": "1.0.0-alpha.13",
176
176
  "@visulima/pail": "2.1.28",
177
177
  "@visulima/path": "1.4.0",
@@ -185,7 +185,7 @@
185
185
  "defu": "6.1.4",
186
186
  "fastest-levenshtein": "1.0.16",
187
187
  "hookable": "5.5.3",
188
- "html-minifier-next": "^2.1.6",
188
+ "html-minifier-next": "^2.1.7",
189
189
  "jiti": "2.6.0",
190
190
  "magic-string": "0.30.19",
191
191
  "mlly": "1.8.0",
@@ -1 +0,0 @@
1
- var l=Object.defineProperty;var o=(e,r)=>l(e,"name",{value:r,configurable:!0});import{createFilter as f}from"@rollup/pluginutils";import{f as p}from"./index-CUp9WuCG.js";const m=globalThis.process.getBuiltinModule("module").createRequire(import.meta.url),{transform:d}=m("sucrase");var b=Object.defineProperty,v=o((e,r)=>b(e,"name",{value:r,configurable:!0}),"n"),g=Object.defineProperty,P=v((e,r)=>g(e,"name",{value:r,configurable:!0}),"a"),j=Object.defineProperty,y=P((e,r)=>j(e,"name",{value:r,configurable:!0}),"n");const t=y(({exclude:e,include:r,...n})=>{const c=f(r,e??p);return{name:"packem:sucrase",async transform(s,a){if(!c(a))return;const{code:u,sourceMap:i}=d(s,{...n,filePath:a,sourceMapOptions:{compiledFilename:a}});return{code:u,map:i}}}},"sucraseTransformPlugin");t.NAME="sucrase";const h=t;export{h as sucrasePlugin};
@@ -1,3 +0,0 @@
1
- var k=Object.defineProperty;var v=(e,r)=>k(e,"name",{value:r,configurable:!0});import{createFilter as M}from"@rollup/pluginutils";import{a as P}from"./index-CUp9WuCG.js";import{extname as A,join as $}from"@visulima/path";import{findCacheDirSync as R}from"@visulima/find-cache-dir";import{readFileSync as S}from"@visulima/fs";import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
2
- const require = __cjs_mod__.createRequire(import.meta.url);
3
- const w=globalThis.process.getBuiltinModule("module").createRequire(import.meta.url),{transform:_,formatMessages:E,build:q}=w("esbuild"),h=w("rs-module-lexer"),W={...h,default:h};var C=Object.defineProperty,F=v((e,r)=>C(e,"name",{value:r,configurable:!0}),"h"),I=Object.defineProperty,f=F((e,r)=>I(e,"name",{value:r,configurable:!0}),"u"),T=Object.defineProperty,B=f((e,r)=>T(e,"name",{value:r,configurable:!0}),"n$1");const j=B(async(e,r)=>{r.length>0&&(await E(r,{color:!0,kind:"warning"})).forEach(s=>e.warn(s))},"warn");var L=Object.defineProperty,D=f((e,r)=>L(e,"name",{value:r,configurable:!0}),"t");const N=D(e=>{if(e==="es")return"esm";if(e==="cjs")return e},"getEsbuildFormat"),G=D(({sourceMap:e=!0,...r})=>async function(s,a,i){if(r.minify||r.minifyWhitespace||r.minifyIdentifiers||r.minifySyntax){const t=N(i.format),c=await _(s,{format:t,loader:"js",sourcemap:e,...r});if(await j(this,c.warnings),c.code)return{code:c.code,map:c.map||void 0}}},"getRenderChunk");var H=Object.defineProperty,z=f((e,r)=>H(e,"name",{value:r,configurable:!0}),"n");const y=z(e=>e.replaceAll("\\","/"),"slash"),{parseAsync:U}=W,J=z(async e=>{const r=R("@visulima/packem/optimize-deps",{create:!0,cwd:e.cwd});if(!r)throw new Error('[packem:optimize-deps]: failed to find or create cache directory "node_modules/.cache/packem/optimize_deps".');await q({absWorkingDir:e.cwd,bundle:!0,entryPoints:e.include,format:"esm",ignoreAnnotations:!0,metafile:!0,outdir:r,sourcemap:e.sourceMap,splitting:!0,...e.esbuildOptions,plugins:[{name:"optimize-deps",async setup(a){a.onResolve({filter:/.*/},async i=>{if(e.exclude?.includes(i.path))return{external:!0};if(!i.pluginData?.__resolving_dep_path__&&e.include.includes(i.path)){const t=await a.resolve(i.path,{kind:"import-statement",pluginData:{__resolving_dep_path__:!0},resolveDir:i.resolveDir});return t.errors.length>0||t.warnings.length>0?t:{namespace:"optimize-deps",path:i.path,pluginData:{absolute:t.path,resolveDir:i.resolveDir}}}}),a.onLoad({filter:/.*/,namespace:"optimize-deps"},async i=>{const{absolute:t,resolveDir:c}=i.pluginData,u=S(t),{output:g}=await U({input:[{code:u,filename:t}]});return{contents:(g[0]?.exports??[]).length>0?`export * from '${y(t)}'`:`module.exports = require('${y(t)}')`,resolveDir:c}})}},...e.esbuildOptions?.plugins??[]]});const s=new Map;for(const a of e.include)s.set(a,{file:$(r,`${a}.js`)});return{cacheDir:r,optimized:s}},"optimizeDeps");var K=Object.defineProperty,Q=f((e,r)=>K(e,"name",{value:r,configurable:!0}),"g");const V=Q(({exclude:e,include:r,loaders:s,logger:a,optimizeDeps:i,sourceMap:t,...c})=>{const u=P;if(s!==void 0)for(let[o,n]of Object.entries(s)){const p=o.startsWith(".")?o:`.${o}`;typeof n=="string"?u[p]=n:n||delete u[p]}const g=Object.keys(u),x=new RegExp(`\\.(${g.map(o=>o.slice(1)).join("|")})$`),O=M(r??x,e);let l,b=process.cwd();return{async buildStart(){!i||l||(l=await J({cwd:b,sourceMap:t??!1,...i}),a.debug("optimized %O",l.optimized))},name:"packem:esbuild",options({context:o}){o&&(b=o)},renderChunk:G({...c,sourceMap:t}),async resolveId(o){if(l?.optimized.has(o)){const n=l.optimized.get(o);if(n)return a.debug("resolved %s to %s",o,n.file),n.file}},async transform(o,n){if(!O(n)||l?.optimized.has(n))return;const p=A(n),d=u[p];if(a.debug("transforming %s with %s loader",n,d),!d)return;const m=await _(o,{format:["base64","binary","dataurl","text","json"].includes(d)?"esm":void 0,loader:d,sourcefile:n.replace(/\.[cm]ts/,".ts"),sourcemap:t,...c});if(await j(this,m.warnings),m.code)return{code:m.code,map:m.map||void 0}}}},"esbuildTransformer");V.NAME="esbuild";export{V as z};
@@ -1,3 +0,0 @@
1
- var m=Object.defineProperty;var p=(e,t)=>m(e,"name",{value:t,configurable:!0});const y=globalThis.process.getBuiltinModule("module").createRequire(import.meta.url),{transpileDeclaration:d,formatDiagnostics:f,sys:n}=y("typescript");var v=Object.defineProperty,N=p((e,t)=>v(e,"name",{value:t,configurable:!0}),"p"),b=Object.defineProperty,C=N((e,t)=>b(e,"name",{value:t,configurable:!0}),"l"),D=Object.defineProperty,r=C((e,t)=>D(e,"name",{value:t,configurable:!0}),"s");const M=r(e=>{const t=e.split(`
2
- `);return t.at(-1)?.startsWith("//# sourceMappingURL=")?t.slice(0,-1).join(`
3
- `):e},"stripMapUrl"),T=r(async(e,t,u,o)=>{const s={declarationMap:u,...o?.compilerOptions};let{diagnostics:c,outputText:i,sourceMapText:a}=d(t,{fileName:e,reportDiagnostics:!0,...o,compilerOptions:s});s.declarationMap&&(i=M(i));const g=c?.length?[f(c,{getCanonicalFileName:r(l=>n.useCaseSensitiveFileNames?l:l.toLowerCase(),"getCanonicalFileName"),getCurrentDirectory:r(()=>n.getCurrentDirectory(),"getCurrentDirectory"),getNewLine:r(()=>n.newLine,"getNewLine")})]:[];return a&&(a=JSON.parse(a).mappings),{errors:g,map:a,sourceText:i}},"isolatedDeclarationsTypescriptTransformer");export{T as v};
@@ -1 +0,0 @@
1
- var j=Object.defineProperty;var x=(r,e)=>j(r,"name",{value:e,configurable:!0});import{createFilter as S}from"@rollup/pluginutils";import{findPackageJson as k}from"@visulima/package/package-json";import{dirname as n}from"@visulima/path";const F=globalThis.process.getBuiltinModule("module").createRequire(import.meta.url),{ResolverFactory:M}=F("oxc-resolver");var O=Object.defineProperty,_=x((r,e)=>O(r,"name",{value:e,configurable:!0}),"y"),q=Object.defineProperty,A=_((r,e)=>q(r,"name",{value:e,configurable:!0}),"g"),J=Object.defineProperty,u=A((r,e)=>J(r,"name",{value:e,configurable:!0}),"a");let y;const z=new Map,C=u((r,e,h,m)=>{const{ignoreSideEffectsForRoot:E,...a}=r;let c=y;return c||(c=y=new M({...a,roots:[...a.roots??[],e],tsconfig:m?{configFile:m,references:"auto"}:void 0})),{name:"oxc-resolve",resolveId:{async handler(v,l,{isEntry:w}){const g=w||!l?n(v):n(l),{error:p,path:o}=await c.async(g,v);if(p){h.debug(p,{context:[{basedir:e,extensions:a.extensions,id:o}]});return}let f=u(s=>!1,"hasModuleSideEffects");try{const{packageJson:s,path:P}=await k(n(o),{cache:z}),b=n(P);if(!E||e!==b){const i=s.sideEffects;if(typeof i=="boolean")f=u(()=>i,"hasModuleSideEffects");else if(Array.isArray(i)){const R=i.map(d=>d.includes("/")?d:`**/${d}`);f=S(R,void 0,{resolve:b})}}}catch(s){console.debug(s.message,{context:[{basedir:g,caller:"Resolver",error:s,extensions:a.extensions,id:o}]})}const t=await this.resolve(o,l,{skipSelf:!0});if(t)return t.external?!1:t.id!==o?t:{id:o,meta:t.meta,moduleSideEffects:f(o)}},order:"post"}}},"oxcResolvePlugin");export{C as z};
@@ -1,6 +0,0 @@
1
- var E=Object.defineProperty;var u=(t,e)=>E(t,"name",{value:e,configurable:!0});import{parse as U}from"@babel/parser";import{findStaticImports as L}from"mlly";import{isAbsolute as Z,join as B,dirname as z,resolve as I}from"@visulima/path";import{isRelative as G}from"@visulima/path/utils";const q=globalThis.process.getBuiltinModule("module").createRequire(import.meta.url),F=q("magic-string");var H=Object.defineProperty,m=u((t,e)=>H(t,"name",{value:e,configurable:!0}),"u$1"),J=Object.defineProperty,h=m((t,e)=>J(t,"name",{value:e,configurable:!0}),"n"),K=Object.defineProperty,x=h((t,e)=>K(t,"name",{value:e,configurable:!0}),"i");let N=class{static{u(this,"y")}static{m(this,"_")}static{h(this,"WalkerBase")}static{x(this,"WalkerBase")}constructor(){this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:x(()=>this.should_skip=!0,"skip"),remove:x(()=>this.should_remove=!0,"remove"),replace:x(e=>this.replacement=e,"replace")}}replace(e,s,r,n){e&&s&&(r!=null?e[s][r]=n:e[s]=n)}remove(e,s,r){e&&s&&(r!=null?e[s].splice(r,1):delete e[s])}};var Q=Object.defineProperty,g=h((t,e)=>Q(t,"name",{value:e,configurable:!0}),"c$1");let V=class extends N{static{u(this,"A")}static{m(this,"x")}static{h(this,"SyncWalker")}static{g(this,"SyncWalker")}constructor(e,s){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:g(()=>this.should_skip=!0,"skip"),remove:g(()=>this.should_remove=!0,"remove"),replace:g(r=>this.replacement=r,"replace")},this.enter=e,this.leave=s}visit(e,s,r,n){if(e){if(this.enter){const i=this.should_skip,o=this.should_remove,l=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.enter.call(this.context,e,s,r,n),this.replacement&&(e=this.replacement,this.replace(s,r,n,e)),this.should_remove&&this.remove(s,r,n);const a=this.should_skip,p=this.should_remove;if(this.should_skip=i,this.should_remove=o,this.replacement=l,a)return e;if(p)return null}let c;for(c in e){const i=e[c];if(i&&typeof i=="object")if(Array.isArray(i)){const o=i;for(let l=0;l<o.length;l+=1){const a=o[l];b(a)&&(this.visit(a,e,c,l)||l--)}}else b(i)&&this.visit(i,e,c,null)}if(this.leave){const i=this.replacement,o=this.should_remove;this.replacement=null,this.should_remove=!1,this.leave.call(this.context,e,s,r,n),this.replacement&&(e=this.replacement,this.replace(s,r,n,e)),this.should_remove&&this.remove(s,r,n);const l=this.should_remove;if(this.replacement=i,this.should_remove=o,l)return null}}return e}};function b(t){return t!==null&&typeof t=="object"&&"type"in t&&typeof t.type=="string"}u(b,"d$2");m(b,"f");h(b,"n");g(b,"isNode");var X=Object.defineProperty,y=h((t,e)=>X(t,"name",{value:e,configurable:!0}),"c");let Y=class extends N{static{u(this,"P")}static{m(this,"j")}static{h(this,"AsyncWalker")}static{y(this,"AsyncWalker")}constructor(e,s){super(),this.should_skip=!1,this.should_remove=!1,this.replacement=null,this.context={skip:y(()=>this.should_skip=!0,"skip"),remove:y(()=>this.should_remove=!0,"remove"),replace:y(r=>this.replacement=r,"replace")},this.enter=e,this.leave=s}async visit(e,s,r,n){if(e){if(this.enter){const i=this.should_skip,o=this.should_remove,l=this.replacement;this.should_skip=!1,this.should_remove=!1,this.replacement=null,await this.enter.call(this.context,e,s,r,n),this.replacement&&(e=this.replacement,this.replace(s,r,n,e)),this.should_remove&&this.remove(s,r,n);const a=this.should_skip,p=this.should_remove;if(this.should_skip=i,this.should_remove=o,this.replacement=l,a)return e;if(p)return null}let c;for(c in e){const i=e[c];if(i&&typeof i=="object")if(Array.isArray(i)){const o=i;for(let l=0;l<o.length;l+=1){const a=o[l];$(a)&&(await this.visit(a,e,c,l)||l--)}}else $(i)&&await this.visit(i,e,c,null)}if(this.leave){const i=this.replacement,o=this.should_remove;this.replacement=null,this.should_remove=!1,await this.leave.call(this.context,e,s,r,n),this.replacement&&(e=this.replacement,this.replace(s,r,n,e)),this.should_remove&&this.remove(s,r,n);const l=this.should_remove;if(this.replacement=i,this.should_remove=o,l)return null}}return e}};function $(t){return t!==null&&typeof t=="object"&&"type"in t&&typeof t.type=="string"}u($,"f$2");m($,"d");h($,"a$1");y($,"isNode");var ee=Object.defineProperty,C=h((t,e)=>ee(t,"name",{value:e,configurable:!0}),"a");function j(t,{enter:e,leave:s}){return new V(e,s).visit(t,null)}u(j,"k$1");m(j,"A");h(j,"walk");C(j,"walk");async function P(t,{enter:e,leave:s}){return await new Y(e,s).visit(t,null)}u(P,"w$3");m(P,"O");h(P,"asyncWalk");C(P,"asyncWalk");var te=Object.defineProperty,A=u((t,e)=>te(t,"name",{value:e,configurable:!0}),"l$1"),se=Object.defineProperty,W=A((t,e)=>se(t,"name",{value:e,configurable:!0}),"l"),re=Object.defineProperty,d=W((t,e)=>re(t,"name",{value:e,configurable:!0}),"r");const ie=/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g,ne=/MIT License|MIT license|BSD license/,oe=/\n{2,}/g,le=/\b(\w+)\$\d+\b/g,ae=/[-/\\^$*+?.()|[\]{}]/g,ce=d(t=>t.replaceAll(ae,String.raw`\$&`),"escapeRegex"),ue=d(t=>[...new Set(t)],"unique"),pe=d(t=>t.replaceAll(ie,e=>ne.test(e)?"":e).replaceAll(oe,`
2
-
3
- `),"cleanUnnecessaryComments"),R=new Map;function w(t,e,{identifierReplacements:s},r){const n=L(t);for(const i in s){const o=n.find(a=>a.specifier===i&&a.imports.includes("{"));if(!o){this.warn(`${e.fileName} does not import "${i}" for replacement`),process.exitCode=1;continue}const l=s[i];for(const a in l){if(!o.imports.includes(a))throw new Error(`${e.fileName} does not import "${a}" from "${i}" for replacement`);const p=l[a],v=ce(a);p.includes(".")&&(t=t.replace(new RegExp(`\\b\\w+\\b as ${v},?\\s?`),"")),t=t.replaceAll(new RegExp(`\\b${v}\\b`,"g"),p)}}const c=ue(Array.from(t.matchAll(le),i=>i[0]));if(c.length>0){const i=c.map(l=>`
4
- - ${l}`).join(""),o=e.fileName.replace(/\.[^/.]+$/,"");R.has(o)||r.warn({message:`${e.fileName} contains confusing identifier names${i}
5
-
6
- To replace these, add them to the "rollup -> patchTypes -> identifierReplacements" option in your packem config.`,prefix:"plugin:patch-types"}),R.set(o,!0)}return t}u(w,"f$1");A(w,"g");W(w,"I");d(w,"replaceConfusingTypeNames");const he=d((t,e)=>{if(e.leadingComments?.some(s=>s.type==="CommentBlock"&&s.value.includes("@internal"))){const s=t.original[e.end]===","?e.end+1:e.end;return t.remove(e.leadingComments[0].start,s),!0}return!1},"removeInternal");function O(t,e){if(t.includes("@internal")){const s=new F(t),r=U(t,{plugins:["typescript"],sourceType:"module"});if(j(r,{enter(n){he(s,n)&&this.skip()}}),t=s.toString(),t.includes("@internal"))throw new Error(`${e.fileName} has unhandled @internal declarations`)}return t}u(O,"u");A(O,"h");W(O,"S");d(O,"stripInternalTypes");const He=d((t,e)=>({name:"packem:patch-types",renderChunk(s,r){return s=w.call(this,s,r,t,e),s=O.call(this,s,r),s=pe(s),s}}),"patchTypescriptTypes");var fe=Object.defineProperty,me=u((t,e)=>fe(t,"name",{value:e,configurable:!0}),"d$1"),de=Object.defineProperty,ve=me((t,e)=>de(t,"name",{value:e,configurable:!0}),"d"),ge=Object.defineProperty,f=ve((t,e)=>ge(t,"name",{value:e,configurable:!0}),"o");const ye=42,be=f(t=>{let e=!1;for(let s=0;s<t.length;s++)if(t.codePointAt(s)===ye){if(e)return!1;e=!0}return!0},"hasZeroOrOneAsteriskCharacter"),$e=f(t=>{const e=t.indexOf("*");return e===-1?void 0:{prefix:t.slice(0,e),suffix:t.slice(e+1)}},"tryParsePattern"),ke=f(({prefix:t,suffix:e},s)=>s.length>=t.length+e.length&&s.startsWith(t)&&s.endsWith(e),"isPatternMatch"),_e=f((t,e,s)=>{let r,n=-1;for(const c of t){const i=e(c);ke(i,s)&&i.prefix.length>n&&(n=i.prefix.length,r=c)}return r},"findBestPatternMatch"),xe=f((t,e)=>{const s=[];for(const r of t){if(!be(r))continue;const n=$e(r);if(n)s.push(n);else if(r===e)return r}return _e(s,r=>r,e)},"matchPatternOrExact"),je=f((t,e)=>e.substring(t.prefix.length,e.length-t.suffix.length),"matchedText"),we=f(({prefix:t,suffix:e})=>`${t}*${e}`,"patternText"),Oe=f((t,e,s)=>{let r=z(e.path);e.config.compilerOptions?.baseUrl&&(r=I(t,e.config.compilerOptions.baseUrl)),s?.debug({message:`Resolved baseUrl to ${r}`,prefix:"plugin:resolve-tsconfig-paths"});const n=e.config.compilerOptions?.paths??{};return Object.keys(n).length===0&&s?.debug({message:"No paths found in tsconfig.json",prefix:"plugin:resolve-tsconfig-paths"}),{paths:n,resolvedBaseUrl:r}},"getTsconfigPaths"),Je=f((t,e,s,r)=>{const{paths:n,resolvedBaseUrl:c}=Oe(t,e,s),i=Object.keys(n);return{name:"plugin:resolve-tsconfig-paths",async resolveId(o,l,a){if(i.length===0)return;if(o.includes("\0")){s.debug({message:`Skipping resolution of ${o} as it is a virtual module`,prefix:"plugin:resolve-tsconfig-paths"});return}if(o.includes("node_modules")){s.debug({message:`Skipping request as it is inside node_modules ${o}`,prefix:"plugin:resolve-tsconfig-paths"});return}if(!r.resolveAbsolutePath&&Z(o)){s.debug({message:`Skipping request as it is an absolute path ${o}`,prefix:"plugin:resolve-tsconfig-paths"});return}if(G(o)){s.debug({message:`Skipping request as it is a relative path ${o}`,prefix:"plugin:resolve-tsconfig-paths"});return}const p=xe(i,o);if(!p){s.debug({message:`moduleName did not match any paths pattern ${o}`,prefix:"plugin:resolve-tsconfig-paths"});return}const v=typeof p=="string"?void 0:je(p,o),D=typeof p=="string"?p:we(p);for await(const T of n[D]){const k=v?T.replace("*",v):T;if(k.endsWith(".d.ts")||k.endsWith(".d.cts")||k.endsWith(".d.mts"))continue;const S=B(c,k);try{const _=await this.resolve(S,l,{skipSelf:!0,...a});if(_)return _}catch(_){s.debug({context:[_],message:`Failed to resolve ${S} from ${o}`,prefix:"plugin:resolve-tsconfig-paths"})}}}}},"resolveTsconfigPathsPlugin");var Pe=Object.defineProperty,Ae=u((t,e)=>Pe(t,"name",{value:e,configurable:!0}),"f"),We=Object.defineProperty,Te=Ae((t,e)=>We(t,"name",{value:e,configurable:!0}),"c"),Se=Object.defineProperty,M=Te((t,e)=>Se(t,"name",{value:e,configurable:!0}),"u");const Re=M((t,e)=>{if(!e)return;const{config:s,path:r}=e;if(!s.compilerOptions)return;const{rootDirs:n}=s.compilerOptions;if(!n)return;const c=[];for(const i of n){if(i.startsWith("."))throw new Error(`Invalid rootDir value '.' in ${r}.`);if(i.startsWith(".."))throw new Error(`Invalid rootDir value '..' in ${r}.`);c.push(I(t,i))}return c},"getRootDirectories"),Ke=M((t,e,s)=>{const r=Re(t,s);return{name:"packem:resolve-tsconfig-root-dirs",async resolveId(n,c,i){if(!(r===void 0||r.length===0)&&n.startsWith("."))for(const o of r){const l=B(o,n),a=await this.resolve(l,c,{skipSelf:!0,...i});if(a)return e.debug({message:`Resolved ${n} to ${a.id} using rootDirs from tsconfig.json.`,prefix:"plugin:resolve-tsconfig-root-dirs"}),a.id}}}},"resolveTsconfigRootDirectories");var Be=Object.defineProperty,Ie=u((t,e)=>Be(t,"name",{value:e,configurable:!0}),"t"),Ne=Object.defineProperty,Ce=Ie((t,e)=>Ne(t,"name",{value:e,configurable:!0}),"t"),Me=Object.defineProperty,De=Ce((t,e)=>Me(t,"name",{value:e,configurable:!0}),"r");const Qe=De(()=>{const t=/\.(?:[mc]?js|jsx)$/;return{name:"packem:resolve-typescript-mjs-cjs",async resolveId(e,s,r){if(t.test(e)&&s)return await this.resolve(e.replace(/js(x?)$/,"ts$1"),s,r)}}},"resolveTypescriptMjsCts");export{He as B,Ke as D,Je as N,Qe as i,j as k};