@visulima/rollup-plugin-dts 1.0.0-alpha.25 → 1.0.0-alpha.27

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,15 @@
1
+ ## @visulima/rollup-plugin-dts [1.0.0-alpha.27](https://github.com/visulima/packem/compare/@visulima/rollup-plugin-dts@1.0.0-alpha.26...@visulima/rollup-plugin-dts@1.0.0-alpha.27) (2026-05-28)
2
+
3
+ ### Features
4
+
5
+ * rolldown ([#196](https://github.com/visulima/packem/issues/196)) ([197d465](https://github.com/visulima/packem/commit/197d465c2465993a17039319f8ede13398e00def))
6
+
7
+ ### Bug Fixes
8
+
9
+ * **release:** break multi-semantic-release dependency cycle ([1443e4c](https://github.com/visulima/packem/commit/1443e4ca7bad413e52ea61a68f360dd5d355c570))
10
+
11
+ ## @visulima/rollup-plugin-dts [1.0.0-alpha.26](https://github.com/visulima/packem/compare/@visulima/rollup-plugin-dts@1.0.0-alpha.25...@visulima/rollup-plugin-dts@1.0.0-alpha.26) (2026-05-07)
12
+
1
13
  ## @visulima/rollup-plugin-dts [1.0.0-alpha.25](https://github.com/visulima/packem/compare/@visulima/rollup-plugin-dts@1.0.0-alpha.24...@visulima/rollup-plugin-dts@1.0.0-alpha.25) (2026-04-27)
2
14
 
3
15
  ## @visulima/rollup-plugin-dts [1.0.0-alpha.24](https://github.com/visulima/packem/compare/@visulima/rollup-plugin-dts@1.0.0-alpha.23...@visulima/rollup-plugin-dts@1.0.0-alpha.24) (2026-04-24)
@@ -1,14 +1,2 @@
1
- import type { PreRenderedChunk } from "rollup";
2
- export declare const RE_JS: RegExp;
3
- export declare const RE_TS: RegExp;
4
- export declare const RE_DTS: RegExp;
5
- export declare const RE_DTS_MAP: RegExp;
6
- export declare const RE_NODE_MODULES: RegExp;
7
- export declare const RE_CSS: RegExp;
8
- export declare const RE_VUE: RegExp;
9
- export declare const RE_JSON: RegExp;
10
- export declare const filename_js_to_dts: (id: string) => string;
11
- export declare const filename_to_dts: (id: string) => string;
12
- export declare const filename_dts_to: (id: string, extension: "js" | "ts") => string;
13
- export declare const resolveTemplateFn: (function_: ((chunk: PreRenderedChunk) => string) | string, chunk: PreRenderedChunk) => string;
14
- export declare const replaceTemplateName: (template: string, name: string) => string;
1
+ export { a as RE_CSS, b as RE_DTS, c as RE_DTS_MAP, d as RE_JS, e as RE_JSON, f as RE_NODE_MODULES, g as RE_TS, h as RE_VUE, i as filenameDtsTo, j as filenameJsToDts, k as filenameToDts, r as replaceTemplateName, l as resolveTemplateFunction } from "./packem_shared/filename.d-BqANlmrG.js";
2
+ import 'estree';
package/dist/filename.js CHANGED
@@ -1 +1 @@
1
- var _=Object.defineProperty;var a=(e,s)=>_(e,"name",{value:s,configurable:!0});var m=Object.defineProperty,t=a((e,s)=>m(e,"name",{value:s,configurable:!0}),"s");const l=/\.([cm]?)jsx?$/,c=/\.([cm]?)tsx?$/,r=/\.d\.([cm]?)ts$/,d=/\.d\.([cm]?)ts\.map$/,$=/[\\/]node_modules[\\/]/,E=/\.(?:css|scss|sass|less|styl|stylus)$/,n=/\.vue$/,o=/\.json$/,f=t(e=>e.replace(l,".d.$1ts"),"filename_js_to_dts"),i=t(e=>e.replace(n,".vue.ts").replace(c,".d.$1ts").replace(l,".d.$1ts").replace(o,".json.d.ts"),"filename_to_dts"),u=t((e,s)=>e.replace(r,`.$1${s}`),"filename_dts_to"),R=t((e,s)=>typeof e=="function"?e(s):e,"resolveTemplateFn"),S=t((e,s)=>e.replaceAll("[name]",s),"replaceTemplateName");export{E as RE_CSS,r as RE_DTS,d as RE_DTS_MAP,l as RE_JS,o as RE_JSON,$ as RE_NODE_MODULES,c as RE_TS,n as RE_VUE,u as filename_dts_to,f as filename_js_to_dts,i as filename_to_dts,S as replaceTemplateName,R as resolveTemplateFn};
1
+ var c=Object.defineProperty;var a=(e,s)=>c(e,"name",{value:s,configurable:!0});var m=Object.defineProperty,t=a((e,s)=>m(e,"name",{value:s,configurable:!0}),"t");const l=/\.([cm]?)jsx?$/,n=/\.([cm]?)tsx?$/,o=/\.d\.([cm]?)ts$/,$=/\.d\.([cm]?)ts\.map$/,i=/[\\/]node_modules[\\/]/,E=/\.(?:css|scss|sass|less|styl|stylus)$/,r=/\.vue$/,p=/\.json$/,_=t(e=>e.replace(l,".d.$1ts"),"filenameJsToDts"),f=t(e=>e.replace(r,".vue.ts").replace(n,".d.$1ts").replace(l,".d.$1ts").replace(p,".json.d.ts"),"filenameToDts"),u=t((e,s)=>e.replace(o,`.$1${s}`),"filenameDtsTo"),D=t((e,s)=>typeof e=="function"?e(s):e,"resolveTemplateFunction"),d=t((e,s)=>e.replaceAll("[name]",s),"replaceTemplateName");export{E as RE_CSS,o as RE_DTS,$ as RE_DTS_MAP,l as RE_JS,p as RE_JSON,i as RE_NODE_MODULES,n as RE_TS,r as RE_VUE,u as filenameDtsTo,_ as filenameJsToDts,f as filenameToDts,d as replaceTemplateName,D as resolveTemplateFunction};
package/dist/index.d.ts CHANGED
@@ -1,7 +1,105 @@
1
- import type { Plugin } from "rollup";
2
- import type { Options } from "./options.d.ts";
3
- export { default as createFakeJsPlugin } from "./fake-js.d.ts";
4
- export declare const dts: (options?: Options) => Plugin[];
5
- export { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_JSON, RE_NODE_MODULES, RE_TS, RE_VUE } from "./filename.d.ts";
6
- export { createGeneratePlugin } from "./generate.d.ts";
7
- export { type FilterPattern, type Options, resolveOptions } from "./options.d.ts";
1
+ import { R as RenderedChunk, P as Plugin } from "./packem_shared/filename.d-BqANlmrG.js";
2
+ export { a as RE_CSS, b as RE_DTS, c as RE_DTS_MAP, d as RE_JS, e as RE_JSON, f as RE_NODE_MODULES, g as RE_TS, h as RE_VUE } from "./packem_shared/filename.d-BqANlmrG.js";
3
+ import { TsConfigJson } from '@visulima/tsconfig';
4
+ import { IsolatedDeclarationsOptions } from 'oxc-transform';
5
+ import 'estree';
6
+ type AddonFunction = (chunk: RenderedChunk) => string | Promise<string>;
7
+ type FilterPattern = ReadonlyArray<string | RegExp> | string | RegExp | undefined;
8
+ interface GeneralOptions {
9
+ cjsDefault?: boolean;
10
+ compilerOptions?: TsConfigJson.CompilerOptions;
11
+ cwd?: string;
12
+ dtsInput?: boolean;
13
+ emitDtsOnly?: boolean;
14
+ exclude?: FilterPattern;
15
+ include?: FilterPattern;
16
+ resolve?: boolean | (string | RegExp)[];
17
+ resolver?: "oxc" | "tsc";
18
+ sideEffects?: boolean;
19
+ sourcemap?: boolean;
20
+ tsconfig?: string | boolean;
21
+ tsconfigRaw?: Omit<TsConfigJson, "compilerOptions">;
22
+ }
23
+ interface TscOptions {
24
+ banner?: string | Promise<string> | AddonFunction;
25
+ build?: boolean;
26
+ eager?: boolean;
27
+ emitJs?: boolean;
28
+ footer?: string | Promise<string> | AddonFunction;
29
+ incremental?: boolean;
30
+ newContext?: boolean;
31
+ parallel?: boolean;
32
+ tsMacro?: boolean;
33
+ vue?: boolean;
34
+ }
35
+ interface Options extends GeneralOptions, TscOptions {
36
+ oxc?: boolean | Omit<IsolatedDeclarationsOptions, "sourcemap">;
37
+ tsgo?: boolean | {
38
+ path?: string;
39
+ };
40
+ }
41
+ type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;
42
+ type MarkPartial<T, K extends keyof T> = Omit<Required<T>, K> & Partial<Pick<T, K>>;
43
+ type OptionsResolved = Overwrite<MarkPartial<Omit<Options, "compilerOptions">, "banner" | "footer">, {
44
+ exclude: FilterPattern;
45
+ include: FilterPattern;
46
+ oxc: IsolatedDeclarationsOptions | false;
47
+ tsconfig?: string;
48
+ tsconfigRaw: TsConfigJson;
49
+ tsgo: {
50
+ path?: string;
51
+ } | false;
52
+ }>;
53
+ declare const resolveOptions: ({
54
+ banner,
55
+ build,
56
+ cjsDefault,
57
+ compilerOptions: userCompilerOptions,
58
+ cwd,
59
+ dtsInput,
60
+ eager,
61
+ emitDtsOnly,
62
+ emitJs: emitJsOption,
63
+ exclude,
64
+ footer,
65
+ include,
66
+ incremental: incrementalOption,
67
+ newContext,
68
+ oxc: oxcOption,
69
+ parallel,
70
+ resolve,
71
+ resolver,
72
+ sideEffects,
73
+ sourcemap: sourcemapOption,
74
+ tsconfig: tsconfigOption,
75
+ tsconfigRaw: overriddenTsconfigRaw,
76
+ tsgo: tsgoOption,
77
+ tsMacro,
78
+ vue
79
+ }: Options) => OptionsResolved;
80
+ declare const createFakeJsPlugin: ({
81
+ cjsDefault,
82
+ sideEffects,
83
+ sourcemap
84
+ }: Pick<OptionsResolved, "sourcemap" | "cjsDefault" | "sideEffects">) => Plugin;
85
+ declare const createGeneratePlugin: ({
86
+ build,
87
+ cwd,
88
+ eager,
89
+ emitDtsOnly,
90
+ emitJs,
91
+ exclude,
92
+ include,
93
+ incremental,
94
+ newContext,
95
+ oxc,
96
+ parallel,
97
+ sourcemap,
98
+ tsconfig,
99
+ tsconfigRaw,
100
+ tsgo,
101
+ tsMacro,
102
+ vue
103
+ }: Pick<OptionsResolved, "cwd" | "tsconfig" | "tsconfigRaw" | "build" | "incremental" | "oxc" | "emitDtsOnly" | "vue" | "tsMacro" | "parallel" | "eager" | "tsgo" | "newContext" | "emitJs" | "sourcemap" | "include" | "exclude">) => Plugin;
104
+ declare const dts: (options?: Options) => Plugin[];
105
+ export { type FilterPattern, type Options, createFakeJsPlugin, createGeneratePlugin, dts, resolveOptions };
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- var $=Object.defineProperty;var p=(t,e)=>$(t,"name",{value:e,configurable:!0});import{createDebug as T}from"obug";import C from"magic-string";import{RE_DTS as m,resolveTemplateFn as I,replaceTemplateName as R,RE_TS as J,RE_VUE as M,RE_JSON as U,RE_CSS as W,filename_to_dts as x,RE_NODE_MODULES as P,RE_JS as A,filename_js_to_dts as B}from"./filename.js";import{RE_DTS_MAP as he}from"./filename.js";import q from"./packem_shared/createFakeJsPlugin-DhesHehE.js";import{c as z}from"./packem_shared/generate-ufHefAw7.js";import{resolveOptions as G}from"./packem_shared/resolveOptions-Bp8RzeQ2.js";import g from"node:path";import{ResolverFactory as L}from"oxc-resolver";import{existsSync as D,readFileSync as V}from"node:fs";var H=Object.defineProperty,K=p((t,e)=>H(t,"name",{value:e,configurable:!0}),"o$1");const Q=K(({banner:t,footer:e})=>({name:"rollup-plugin-dts:banner",async renderChunk(n,a){if(!m.test(a.fileName))return;const i=new C(n);if(t){const u=await(typeof t=="function"?t(a):t);u&&i.prepend(`${u}
1
+ var j=Object.defineProperty;var p=(t,e)=>j(t,"name",{value:e,configurable:!0});import{createDebug as $}from"obug";import J from"magic-string";import{RE_DTS as m,resolveTemplateFunction as A,replaceTemplateName as _,RE_TS as C,RE_VUE as I,RE_JSON as M,RE_CSS as W,filenameToDts as D,RE_NODE_MODULES as P,RE_JS as B,filenameJsToDts as U}from"./filename.js";import{RE_DTS_MAP as he}from"./filename.js";import q from"./packem_shared/createFakeJsPlugin-BVCg2c5s.js";import{c as z}from"./packem_shared/generate-Dy7UEhz1.js";import{resolveOptions as G}from"./packem_shared/resolveOptions-Dh02RM2W.js";import{existsSync as k,readFileSync as L}from"node:fs";import g from"node:path";import{ResolverFactory as V}from"oxc-resolver";var H=Object.defineProperty,K=p((t,e)=>H(t,"name",{value:e,configurable:!0}),"o$1");const Q=K(({banner:t,footer:e})=>({name:"rollup-plugin-dts:banner",async renderChunk(n,a){if(!m.test(a.fileName))return;const i=new J(n);if(t){const u=await(typeof t=="function"?t(a):t);u&&i.prepend(`${u}
2
2
  `)}if(e){const u=await(typeof e=="function"?e(a):e);u&&i.append(`
3
- ${u}`)}return{code:i.toString(),get map(){return i.generateMap({hires:"boundary",includeContent:!0,source:a.fileName})}}}}),"createBannerPlugin");var X=Object.defineProperty,Y=p((t,e)=>X(t,"name",{value:e,configurable:!0}),"m");const Z=Y(({sideEffects:t})=>({name:"rollup-plugin-dts:dts-input",options:t===!1?e=>({treeshake:e.treeshake===!1?!1:{...typeof e.treeshake=="object"&&e.treeshake!==null?e.treeshake:{},moduleSideEffects:!1},...e}):void 0,outputOptions(e){return{...e,entryFileNames(n){const{entryFileNames:a}=e;if(a){const i=I(a,n),u=R(i,n.name);if(m.test(u))return i;const v=R(i,`${n.name}.d`);if(m.test(v))return v}return m.test(n.name)?n.name:n.name.endsWith(".d")?"[name].ts":"[name].d.ts"}}}}),"createDtsInputPlugin");var ee=Object.defineProperty,b=p((t,e)=>ee(t,"name",{value:e,configurable:!0}),"c");const h=b(t=>J.test(t)||M.test(t)||U.test(t),"isSourceFile"),te=b(({cwd:t,resolve:e,resolver:n,sideEffects:a,tsconfig:i,tsconfigRaw:u})=>{const v=new L({conditionNames:["types","typings","import","require"],mainFields:["types","typings","module","main"],tsconfig:i?{configFile:i,references:"auto"}:void 0}),y=a?!0:null;return{name:"rollup-plugin-dts:resolver",resolveId:{async handler(s,o,c){if(!o||!m.test(o))return;const r={external:!0,id:s,moduleSideEffects:a};if(W.test(s))return r;if(!S(s)&&_(s)){const l=await O(s,o,null);if(l&&m.test(l))return{id:l,moduleSideEffects:y};if(l&&h(l))return await this.load({id:l}),{id:x(l),moduleSideEffects:y}}const f=await this.resolve(s,o,c);if(f?.external)return r;const d=await O(s,o,f);return d?P.test(d)&&!_(s)&&!(S(s)&&P.test(o)&&N(o))?r:m.test(d)?{id:d,moduleSideEffects:y}:h(d)?(await this.load({id:d}),{id:x(d),moduleSideEffects:y}):null:S(s)?null:r},order:"pre"}};function _(s){return typeof e=="boolean"?e:e.some(o=>typeof o=="string"?s===o:o.test(s))}function N(s){const o=s.replace(/\\/g,"/"),c="/node_modules/",r=o.lastIndexOf(c);if(r<0)return!1;const f=o.slice(r+c.length),d=f.indexOf("/");let l=d===-1?f:f.slice(0,d);if(l.startsWith("@")){const w=f.slice(l.length+1),F=w.indexOf("/"),j=F===-1?w:w.slice(0,F);l=`${l}/${j}`}return _(l)}async function O(s,o,c){let r;if(n==="tsc"){const{default:f}=await import("./packem_chunks/resolver.js");r=f(s,o,t,i,u)}else r=v.resolveDtsSync(o,s).path;if(r&&(r=g.normalize(r)),r&&A.test(r)&&ne(r)){const f=B(r);if(D(f))return f}return!r||!h(r)?c&&S(c.id)&&h(c.id)&&!c.external?c.id:null:r}},"createDtsResolvePlugin"),S=b(t=>t.startsWith(".")||g.isAbsolute(t),"isFilePath"),E=new Map,ne=b(t=>{const e=g.dirname(t);if(E.has(e))return E.get(e);let n=e;for(;n!==g.dirname(n);){const a=g.join(n,"package.json");if(D(a)){let i=!1;try{const{exports:u}=JSON.parse(V(a,"utf8"));i=u===void 0||typeof u=="string"}catch{}return E.set(e,i),i}n=g.dirname(n)}return E.set(e,!1),!1},"canFallBackToSiblingDts");var re=Object.defineProperty,se=p((t,e)=>re(t,"name",{value:e,configurable:!0}),"o");const k=T("rollup-plugin-dts:options"),ge=se((t={})=>{k("resolving dts options");const e=G(t);k("resolved dts options %o",e);const n=[];return t.dtsInput?n.push(Z(e)):n.push(z(e)),n.push(te(e),q(e)),(t.banner||t.footer)&&n.push(Q(e)),n},"dts");export{W as RE_CSS,m as RE_DTS,he as RE_DTS_MAP,A as RE_JS,U as RE_JSON,P as RE_NODE_MODULES,J as RE_TS,M as RE_VUE,q as createFakeJsPlugin,z as createGeneratePlugin,ge as dts,G as resolveOptions};
3
+ ${u}`)}return{code:i.toString(),get map(){return i.generateMap({hires:"boundary",includeContent:!0,source:a.fileName})}}}}),"createBannerPlugin");var X=Object.defineProperty,Y=p((t,e)=>X(t,"name",{value:e,configurable:!0}),"i");const Z=Y(({sideEffects:t})=>({name:"rollup-plugin-dts:dts-input",options:t?void 0:e=>({treeshake:e.treeshake===!1?!1:{...typeof e.treeshake=="object"?e.treeshake:{},moduleSideEffects:!1},...e}),outputOptions(e){return{...e,entryFileNames(n){const{entryFileNames:a}=e;if(a){const i=A(a,n),u=_(i,n.name);if(m.test(u))return i;const v=_(i,`${n.name}.d`);if(m.test(v))return v}return m.test(n.name)?n.name:n.name.endsWith(".d")?"[name].ts":"[name].d.ts"}}}}),"createDtsInputPlugin");var ee=Object.defineProperty,b=p((t,e)=>ee(t,"name",{value:e,configurable:!0}),"c");const h=b(t=>C.test(t)||I.test(t)||M.test(t),"isSourceFile"),te=b(({cwd:t,resolve:e,resolver:n,sideEffects:a,tsconfig:i,tsconfigRaw:u})=>{const v=new V({conditionNames:["types","typings","import","require"],mainFields:["types","typings","module","main"],tsconfig:i?{configFile:i,references:"auto"}:void 0}),y=a?!0:null;return{name:"rollup-plugin-dts:resolver",resolveId:{async handler(s,o,c){if(!o||!m.test(o))return;const r={external:!0,id:s,moduleSideEffects:a};if(W.test(s))return r;if(!S(s)&&w(s)){const l=await F(s,o,null);if(l&&m.test(l))return{id:l,moduleSideEffects:y};if(l&&h(l))return await this.load({id:l}),{id:D(l),moduleSideEffects:y}}const f=await this.resolve(s,o,c);if(f?.external)return r;const d=await F(s,o,f);return d?P.test(d)&&!w(s)&&!(S(s)&&P.test(o)&&N(o))?r:m.test(d)?{id:d,moduleSideEffects:y}:h(d)?(await this.load({id:d}),{id:D(d),moduleSideEffects:y}):null:S(s)?null:r},order:"pre"}};function w(s){return typeof e=="boolean"?e:e.some(o=>typeof o=="string"?s===o:o.test(s))}function N(s){const o=s.replaceAll("\\","/"),c="/node_modules/",r=o.lastIndexOf(c);if(r===-1)return!1;const f=o.slice(r+c.length),d=f.indexOf("/");let l=d===-1?f:f.slice(0,d);if(l.startsWith("@")){const O=f.slice(l.length+1),R=O.indexOf("/"),T=R===-1?O:O.slice(0,R);l=`${l}/${T}`}return w(l)}async function F(s,o,c){let r;if(n==="tsc"){const{default:f}=await import("./packem_chunks/resolver.js");r=f(s,o,t,i,u)}else r=v.resolveDtsSync(o,s).path;if(r&&(r=g.normalize(r)),r&&B.test(r)&&ne(r)){const f=U(r);if(k(f))return f}return!r||!h(r)?c&&S(c.id)&&h(c.id)&&!c.external?c.id:null:r}},"createDtsResolvePlugin"),S=b(t=>t.startsWith(".")||g.isAbsolute(t),"isFilePath"),E=new Map,ne=b(t=>{const e=g.dirname(t);if(E.has(e))return E.get(e);let n=e;for(;n!==g.dirname(n);){const a=g.join(n,"package.json");if(k(a)){let i=!1;try{const{exports:u}=JSON.parse(L(a,"utf8"));i=u===void 0||typeof u=="string"}catch{}return E.set(e,i),i}n=g.dirname(n)}return E.set(e,!1),!1},"canFallBackToSiblingDts");var re=Object.defineProperty,se=p((t,e)=>re(t,"name",{value:e,configurable:!0}),"o");const x=$("rollup-plugin-dts:options"),ge=se((t={})=>{x("resolving dts options");const e=G(t);x("resolved dts options %o",e);const n=[];return t.dtsInput?n.push(Z(e)):n.push(z(e)),n.push(te(e),q(e)),(t.banner||t.footer)&&n.push(Q(e)),n},"dts");export{W as RE_CSS,m as RE_DTS,he as RE_DTS_MAP,B as RE_JS,M as RE_JSON,P as RE_NODE_MODULES,C as RE_TS,I as RE_VUE,q as createFakeJsPlugin,z as createGeneratePlugin,ge as dts,G as resolveOptions};
@@ -1 +1 @@
1
- var q=Object.defineProperty;var h=(e,t)=>q(e,"name",{value:t,configurable:!0});import{createDebug as P}from"obug";import u from"typescript";import{g as F,V as N}from"../packem_shared/generate-ufHefAw7.js";import{posix as w}from"node:path";import{pathToFileURL as j}from"node:url";var T=Object.defineProperty,S=h((e,t)=>T(e,"name",{value:t,configurable:!0}),"i");const U=P("rollup-plugin-dts:tsc-system"),x=S(e=>({...u.sys,deleteFile(t,...r){e.delete(t),u.sys.deleteFile?.(t,...r)},directoryExists(t){return[...e.keys()].some(r=>r.startsWith(t))?!0:u.sys.directoryExists(t)},fileExists(t){return e.has(t)?!0:u.sys.fileExists(t)},readFile(t,...r){return e.has(t)?e.get(t):u.sys.readFile(t,...r)},resolvePath(t){return e.has(t)?t:u.sys.resolvePath(t)},write(t){U(t)},writeFile(t,r,...o){e.set(t,r),u.sys.writeFile(t,r,...o)}}),"createFsSystem"),B=S(e=>({...x(e),deleteFile(t){e.delete(t)},writeFile(t,r){e.set(t,r)}}),"createMemorySystem");var J=Object.defineProperty,$=h((e,t)=>J(e,"name",{value:t,configurable:!0}),"s$1");const W=$(e=>{const t=$(r=>u.isPropertySignature(r)&&u.isPrivateIdentifier(r.name)?e.factory.updatePropertySignature(r,r.modifiers,e.factory.createStringLiteral(r.name.text),r.questionToken,r.type):u.visitEachChild(r,t,e),"visitor");return r=>u.visitNode(r,t,u.isSourceFile)??r},"stripPrivateFields"),M={getCanonicalFileName:u.sys.useCaseSensitiveFileNames?e=>e:e=>e.toLowerCase(),getCurrentDirectory:$(()=>u.sys.getCurrentDirectory(),"getCurrentDirectory"),getNewLine:$(()=>u.sys.newLine,"getNewLine")},O={afterDeclarations:[W]},R=$((e,t,r)=>{if(!e||e.sourceRoot)return;const o=w.dirname(j(t).pathname),s=w.dirname(j(r).pathname);o!==s&&(e.sourceRoot=w.relative(s,o))},"setSourceMapRoot");var z=Object.defineProperty,m=h((e,t)=>z(e,"name",{value:t,configurable:!0}),"f$1");const g=P("rollup-plugin-dts:tsc-build"),H=m((e,t,r,o,s)=>{let i=e.projects.get(r);return i?(g(`skip building projects for ${r}`),i):(i=V(t,r,o,s),e.projects.set(r,i),i)},"getOrBuildProjects"),V=m((e,t,r,o)=>{g(`start building projects for ${t}`);const s=G(t,e,r,o);g("collected %d projects: %j",s.length,s.map(n=>n.tsconfigPath));const i=u.createSolutionBuilderHost(e,I),l=u.createSolutionBuilder(i,[t],{force:r,verbose:!0}).build(void 0,void 0,void 0,n=>(g(`transforming project ${n}`),O));g(`built solution for ${t} with exit status ${l}`);const a=new Map;for(const n of s)for(const c of n.parsedConfig.fileNames)a.set(e.resolvePath(c),n);return a},"buildProjects"),G=m((e,t,r,o)=>{const s=new Set,i=[],l=[t.resolvePath(e)];for(;;){const a=l.pop();if(!a)break;if(s.has(a))continue;s.add(a);const n=A(a,t);if(n){n.options=D(n.options,{force:r,sourcemap:o,tsconfigPath:a}),i.push({parsedConfig:n,tsconfigPath:a});for(const c of n.projectReferences??[])l.push(u.resolveProjectReferencePath(c))}}return i},"collectProjectGraph"),A=m((e,t)=>{const r=[],o=u.getParsedCommandLineOfConfigFile(e,void 0,{...t,onUnRecoverableConfigFileDiagnostic:m(s=>{r.push(s)},"onUnRecoverableConfigFileDiagnostic")});if(r.length>0)throw new Error(`[rollup-plugin-dts] Unable to read ${e}: ${u.formatDiagnostics(r,M)}`);return o},"parseTsconfig"),D=m((e,t)=>{const r=e.noEmit??!1,o=e.declaration??!!e.composite,s=e.declarationMap??!1,i=t?.tsconfigPath&&!t.force;return r===!0&&(e={...e,noEmit:!1},i&&console.warn(`[rollup-plugin-dts] ${t.tsconfigPath} has "noEmit" set to true. Please set it to false to generate declaration files.`)),o===!1&&(e={...e,declaration:!0},i&&console.warn(`[rollup-plugin-dts] ${t.tsconfigPath} has "declaration" set to false. Please set it to true to generate declaration files.`)),s===!1&&t?.sourcemap&&(e={...e,declarationMap:!0},i&&console.warn(`[rollup-plugin-dts] ${t.tsconfigPath} has "declarationMap" set to false. Please set it to true if you want to generate source maps for declaration files.`)),e},"patchCompilerOptions"),I=m((e,t,...r)=>u.createEmitAndSemanticDiagnosticsBuilderProgram(e,D(t??{},null),...r),"createProgramWithPatchedCompilerOptions"),L=m(e=>{const{context:t=F,id:r,incremental:o,sourcemap:s,tsconfig:i}=e;if(g(`running tscEmitBuild id: ${r}, tsconfig: ${i}, incremental: ${o}`),!i)return{error:"[rollup-plugin-dts] build mode requires a tsconfig path"};const l=(o?x:B)(t.files),a=l.resolvePath(r);a!==r&&g(`resolved id from ${r} to ${a}`);const n=H(t,l,i,!o,s).get(a);if(!n)return g(`unable to locate a project containing ${a}`),{error:`Unable to locate ${r} from the given tsconfig file ${i}`};g(`loaded project ${n.tsconfigPath} for ${r}`);const c=!l.useCaseSensitiveFileNames,f=u.getOutputFileNames(n.parsedConfig,a,c);let v,y;for(const d of f){if(d.endsWith(".d.ts")){if(!l.fileExists(d)){console.warn(`[rollup-plugin-dts] Unable to read file ${d}`);continue}v=l.readFile(d);continue}if(d.endsWith(".d.ts.map")){if(!l.fileExists(d))continue;const E=l.readFile(d);if(!E){console.warn(`[rollup-plugin-dts] Unexpected sourcemap ${d}`);continue}y=JSON.parse(E),R(y,d,a)}}return v?{code:v,map:y}:o?(g("incremental build failed"),L({...e,incremental:!1})):(g(`unable to build .d.ts file for ${r}`),n.parsedConfig.options.declaration!==!0?{error:`Unable to build .d.ts file for ${r}; Make sure the "declaration" option is set to true in ${n.tsconfigPath}`}:{error:`Unable to build .d.ts file for ${r}; This seems like a bug of rollup-plugin-dts. Please report this issue to https://github.com/sxzz/rollup-plugin-dts/issues`})},"tscEmitBuild");var K=Object.defineProperty,b=h((e,t)=>K(e,"name",{value:t,configurable:!0}),"g");const Y=b(()=>{const e=P("rollup-plugin-dts:vue");e("loading vue language tools");try{const t=require.resolve("vue-tsc"),{proxyCreateProgram:r}=require(require.resolve("@volar/typescript",{paths:[t]})),o=require(require.resolve("@vue/language-core",{paths:[t]}));return{getLanguagePlugin:b((s,i)=>{const l=i.options.$rootDir,a=i.options.$configRaw,n=new o.CompilerOptionsResolver(s,s.sys.readFile);n.addConfig(a?.vueCompilerOptions??{},l);const c=n.build();return o.createVueLanguagePlugin(s,i.options,c,f=>f)},"getLanguagePlugin"),proxyCreateProgram:r}}catch(t){throw e("vue language tools not found",t),new Error("Failed to load vue language tools. Please manually install vue-tsc.")}},"loadVueLanguageTools"),Q=b(()=>{const e=P("rollup-plugin-dts:ts-macro");e("loading ts-macro language tools");try{const t=require.resolve("@ts-macro/tsc"),{proxyCreateProgram:r}=require(require.resolve("@volar/typescript",{paths:[t]})),o=require(require.resolve("@ts-macro/language-plugin",{paths:[t]})),{getOptions:s}=require(require.resolve("@ts-macro/language-plugin/options",{paths:[t]}));return{getLanguagePlugin:b((i,l)=>{const a=l.options.$rootDir;return o.getLanguagePlugins(i,l.options,s(i,a))[0]},"getLanguagePlugin"),proxyCreateProgram:r}}catch(t){throw e("ts-macro language tools not found",t),new Error("Failed to load ts-macro language tools. Please manually install @ts-macro/tsc.")}},"loadTsMacro"),X=b((e,t)=>{const r=t.vue?Y():void 0,o=t.tsMacro?Q():void 0,s=r?.proxyCreateProgram||o?.proxyCreateProgram;return s?s(e,e.createProgram,(i,l)=>{const a=[];return r&&a.push(r.getLanguagePlugin(i,l)),o&&a.push(o.getLanguagePlugin(i,l)),{languagePlugins:a}}):e.createProgram},"createProgramFactory");var Z=Object.defineProperty,C=h((e,t)=>Z(e,"name",{value:t,configurable:!0}),"m");const p=P("rollup-plugin-dts:tsc-compiler"),_={checkJs:!1,declaration:!0,declarationMap:!1,emitDeclarationOnly:!0,moduleResolution:u.ModuleResolutionKind.Bundler,noEmit:!1,noEmitOnError:!0,resolveJsonModule:!0,skipLibCheck:!0,target:99},ee=C(e=>{const{context:t=F,entries:r,id:o}=e,s=t.programs.find(l=>{const a=l.getRootFileNames();return r?r.every(n=>a.includes(n)):a.includes(o)});if(s){const l=s.getSourceFile(o);if(l)return{file:l,program:s}}p(`create program for module: ${o}`);const i=te(e);return p(`created program for module: ${o}`),t.programs.push(i.program),i},"createOrGetTsModule"),te=C(({context:e=F,cwd:t,entries:r,id:o,tsconfig:s,tsconfigRaw:i,tsMacro:l,vue:a})=>{const n=x(e.files),c=s?N(s):t,f=u.parseJsonConfigFileContent(i,n,c);return p(`Creating program for root project: ${c}`),re({baseDir:c,entries:r,fsSystem:n,id:o,parsedConfig:f,tsMacro:l,vue:a})},"createTsProgram"),re=C(({baseDir:e,entries:t,fsSystem:r,id:o,parsedConfig:s,tsMacro:i,vue:l})=>{const a={..._,...s.options,$configRaw:s.raw,$rootDir:e},n=[...new Set([o,...t||s.fileNames].map(y=>r.resolvePath(y)))],c=u.createCompilerHost(a,!0),f=X(u,{tsMacro:i,vue:l})({host:c,options:a,projectReferences:s.projectReferences,rootNames:n}),v=f.getSourceFile(o);if(!v)throw p(`source file not found in program: ${o}`),s.projectReferences?.length?new Error(`[rollup-plugin-dts] Unable to load ${o}; You have "references" in your tsconfig file. Perhaps you want to add \`dts: { build: true }\` in your config?`):r.fileExists(o)?(p(`File ${o} exists on disk.`),new Error(`Unable to load file ${o} from the program. This seems like a bug of rollup-plugin-dts. Please report this issue to https://github.com/sxzz/rollup-plugin-dts/issues`)):(p(`File ${o} does not exist on disk.`),new Error(`Source file not found: ${o}`));return{file:v,program:f}},"createTsProgramFromParsedConfig"),oe=C(e=>{p(`running tscEmitCompiler ${e.id}`);const t=ee(e),{file:r,program:o}=t;p(`got source file: ${r.fileName}`);let s,i;const{diagnostics:l,emitSkipped:a}=o.emit(r,(n,c)=>{n.endsWith(".map")?(p(`emit dts sourcemap: ${n}`),i=JSON.parse(c),R(i,n,e.id)):(p(`emit dts: ${n}`),s=c)},void 0,!0,O,!0);return a&&l.length>0?{error:u.formatDiagnostics(l,M)}:(!s&&r.isDeclarationFile&&(p("nothing was emitted. fallback to sourceFile text."),s=r.getFullText()),{code:s,map:i})},"tscEmitCompiler");var se=Object.defineProperty,ie=h((e,t)=>se(e,"name",{value:t,configurable:!0}),"r");const k=P("rollup-plugin-dts:tsc");k(`loaded typescript: ${u.version}`);const pe=ie(e=>(k(`running tscEmit ${e.id}`),e.build?L(e):oe(e)),"tscEmit");export{pe as tscEmit};
1
+ var q=Object.defineProperty;var h=(e,t)=>q(e,"name",{value:t,configurable:!0});import{createDebug as P}from"obug";import u from"typescript";import{g as F}from"../packem_shared/generate-Dy7UEhz1.js";import{posix as w}from"node:path";import{pathToFileURL as j}from"node:url";import{dirname as N}from"@visulima/path";var T=Object.defineProperty,S=h((e,t)=>T(e,"name",{value:t,configurable:!0}),"i");const U=P("rollup-plugin-dts:tsc-system"),x=S(e=>({...u.sys,deleteFile(t,...r){e.delete(t),u.sys.deleteFile?.(t,...r)},directoryExists(t){return[...e.keys()].some(r=>r.startsWith(t))?!0:u.sys.directoryExists(t)},fileExists(t){return e.has(t)?!0:u.sys.fileExists(t)},readFile(t,...r){return e.has(t)?e.get(t):u.sys.readFile(t,...r)},resolvePath(t){return e.has(t)?t:u.sys.resolvePath(t)},write(t){U(t)},writeFile(t,r,...o){e.set(t,r),u.sys.writeFile(t,r,...o)}}),"createFsSystem"),B=S(e=>({...x(e),deleteFile(t){e.delete(t)},writeFile(t,r){e.set(t,r)}}),"createMemorySystem");var J=Object.defineProperty,$=h((e,t)=>J(e,"name",{value:t,configurable:!0}),"o$1");const W=$(e=>{const t=$(r=>u.isPropertySignature(r)&&u.isPrivateIdentifier(r.name)?e.factory.updatePropertySignature(r,r.modifiers,e.factory.createStringLiteral(r.name.text),r.questionToken,r.type):u.visitEachChild(r,t,e),"visitor");return r=>u.visitNode(r,t,u.isSourceFile)},"stripPrivateFields"),M={getCanonicalFileName:u.sys.useCaseSensitiveFileNames?e=>e:e=>e.toLowerCase(),getCurrentDirectory:$(()=>u.sys.getCurrentDirectory(),"getCurrentDirectory"),getNewLine:$(()=>u.sys.newLine,"getNewLine")},O={afterDeclarations:[W]},R=$((e,t,r)=>{if(!e||e.sourceRoot)return;const o=w.dirname(j(t).pathname),s=w.dirname(j(r).pathname);o!==s&&(e.sourceRoot=w.relative(s,o))},"setSourceMapRoot");var z=Object.defineProperty,m=h((e,t)=>z(e,"name",{value:t,configurable:!0}),"f$1");const g=P("rollup-plugin-dts:tsc-build"),H=m((e,t,r,o,s)=>{let i=e.projects.get(r);return i?(g(`skip building projects for ${r}`),i):(i=G(t,r,o,s),e.projects.set(r,i),i)},"getOrBuildProjects"),G=m((e,t,r,o)=>{g(`start building projects for ${t}`);const s=V(t,e,r,o);g("collected %d projects: %j",s.length,s.map(n=>n.tsconfigPath));const i=u.createSolutionBuilderHost(e,I),l=u.createSolutionBuilder(i,[t],{force:r,verbose:!0}).build(void 0,void 0,void 0,n=>(g(`transforming project ${n}`),O));g(`built solution for ${t} with exit status ${l}`);const a=new Map;for(const n of s)for(const c of n.parsedConfig.fileNames)a.set(e.resolvePath(c),n);return a},"buildProjects"),V=m((e,t,r,o)=>{const s=new Set,i=[],l=[t.resolvePath(e)];for(;;){const a=l.pop();if(!a)break;if(s.has(a))continue;s.add(a);const n=A(a,t);if(n){n.options=D(n.options,{force:r,sourcemap:o,tsconfigPath:a}),i.push({parsedConfig:n,tsconfigPath:a});for(const c of n.projectReferences??[])l.push(u.resolveProjectReferencePath(c))}}return i},"collectProjectGraph"),A=m((e,t)=>{const r=[],o=u.getParsedCommandLineOfConfigFile(e,void 0,{...t,onUnRecoverableConfigFileDiagnostic:m(s=>{r.push(s)},"onUnRecoverableConfigFileDiagnostic")});if(r.length>0)throw new Error(`[rollup-plugin-dts] Unable to read ${e}: ${u.formatDiagnostics(r,M)}`);return o},"parseTsconfig"),D=m((e,t)=>{const r=e.noEmit??!1,o=e.declaration??!!e.composite,s=e.declarationMap??!1,i=t?.tsconfigPath&&!t.force;return r&&(e={...e,noEmit:!1},i&&console.warn(`[rollup-plugin-dts] ${t.tsconfigPath} has "noEmit" set to true. Please set it to false to generate declaration files.`)),o||(e={...e,declaration:!0},i&&console.warn(`[rollup-plugin-dts] ${t.tsconfigPath} has "declaration" set to false. Please set it to true to generate declaration files.`)),!s&&t?.sourcemap&&(e={...e,declarationMap:!0},i&&console.warn(`[rollup-plugin-dts] ${t.tsconfigPath} has "declarationMap" set to false. Please set it to true if you want to generate source maps for declaration files.`)),e},"patchCompilerOptions"),I=m((e,t,...r)=>u.createEmitAndSemanticDiagnosticsBuilderProgram(e,D(t??{},null),...r),"createProgramWithPatchedCompilerOptions"),L=m(e=>{const{context:t=F,id:r,incremental:o,sourcemap:s,tsconfig:i}=e;if(g(`running tscEmitBuild id: ${r}, tsconfig: ${i}, incremental: ${o}`),!i)return{error:"[rollup-plugin-dts] build mode requires a tsconfig path"};const l=(o?x:B)(t.files),a=l.resolvePath(r);a!==r&&g(`resolved id from ${r} to ${a}`);const n=H(t,l,i,!o,s).get(a);if(!n)return g(`unable to locate a project containing ${a}`),{error:`Unable to locate ${r} from the given tsconfig file ${i}`};g(`loaded project ${n.tsconfigPath} for ${r}`);const c=!l.useCaseSensitiveFileNames,f=u.getOutputFileNames(n.parsedConfig,a,c);let v,y;for(const d of f){if(d.endsWith(".d.ts")){if(!l.fileExists(d)){console.warn(`[rollup-plugin-dts] Unable to read file ${d}`);continue}v=l.readFile(d);continue}if(d.endsWith(".d.ts.map")){if(!l.fileExists(d))continue;const E=l.readFile(d);if(!E){console.warn(`[rollup-plugin-dts] Unexpected sourcemap ${d}`);continue}y=JSON.parse(E),R(y,d,a)}}return v?{code:v,map:y}:o?(g("incremental build failed"),L({...e,incremental:!1})):(g(`unable to build .d.ts file for ${r}`),n.parsedConfig.options.declaration!==!0?{error:`Unable to build .d.ts file for ${r}; Make sure the "declaration" option is set to true in ${n.tsconfigPath}`}:{error:`Unable to build .d.ts file for ${r}; This seems like a bug of rollup-plugin-dts. Please report this issue to https://github.com/sxzz/rollup-plugin-dts/issues`})},"tscEmitBuild");var K=Object.defineProperty,b=h((e,t)=>K(e,"name",{value:t,configurable:!0}),"g");const Y=b(()=>{const e=P("rollup-plugin-dts:vue");e("loading vue language tools");try{const t=require.resolve("vue-tsc"),{proxyCreateProgram:r}=require(require.resolve("@volar/typescript",{paths:[t]})),o=require(require.resolve("@vue/language-core",{paths:[t]}));return{getLanguagePlugin:b((s,i)=>{const l=i.options.$rootDir,a=i.options.$configRaw,n=new o.CompilerOptionsResolver(s,s.sys.readFile);n.addConfig(a?.vueCompilerOptions??{},l);const c=n.build();return o.createVueLanguagePlugin(s,i.options,c,f=>f)},"getLanguagePlugin"),proxyCreateProgram:r}}catch(t){throw e("vue language tools not found",t),new Error("Failed to load vue language tools. Please manually install vue-tsc.")}},"loadVueLanguageTools"),Q=b(()=>{const e=P("rollup-plugin-dts:ts-macro");e("loading ts-macro language tools");try{const t=require.resolve("@ts-macro/tsc"),{proxyCreateProgram:r}=require(require.resolve("@volar/typescript",{paths:[t]})),o=require(require.resolve("@ts-macro/language-plugin",{paths:[t]})),{getOptions:s}=require(require.resolve("@ts-macro/language-plugin/options",{paths:[t]}));return{getLanguagePlugin:b((i,l)=>{const a=l.options.$rootDir;return o.getLanguagePlugins(i,l.options,s(i,a))[0]},"getLanguagePlugin"),proxyCreateProgram:r}}catch(t){throw e("ts-macro language tools not found",t),new Error("Failed to load ts-macro language tools. Please manually install @ts-macro/tsc.")}},"loadTsMacro"),X=b((e,t)=>{const r=t.vue?Y():void 0,o=t.tsMacro?Q():void 0,s=r?.proxyCreateProgram||o?.proxyCreateProgram;return s?s(e,e.createProgram,(i,l)=>{const a=[];return r&&a.push(r.getLanguagePlugin(i,l)),o&&a.push(o.getLanguagePlugin(i,l)),{languagePlugins:a}}):e.createProgram},"createProgramFactory");var Z=Object.defineProperty,C=h((e,t)=>Z(e,"name",{value:t,configurable:!0}),"m");const p=P("rollup-plugin-dts:tsc-compiler"),_={checkJs:!1,declaration:!0,declarationMap:!1,emitDeclarationOnly:!0,moduleResolution:u.ModuleResolutionKind.Bundler,noEmit:!1,noEmitOnError:!0,resolveJsonModule:!0,skipLibCheck:!0,target:99},ee=C(({baseDirectory:e,entries:t,fsSystem:r,id:o,parsedConfig:s,tsMacro:i,vue:l})=>{const a={..._,...s.options,$configRaw:s.raw,$rootDir:e},n=[...new Set([o,...t??s.fileNames].map(y=>r.resolvePath(y)))],c=u.createCompilerHost(a,!0),f=X(u,{tsMacro:i,vue:l})({host:c,options:a,projectReferences:s.projectReferences,rootNames:n}),v=f.getSourceFile(o);if(!v)throw p(`source file not found in program: ${o}`),s.projectReferences?.length?new Error(`[rollup-plugin-dts] Unable to load ${o}; You have "references" in your tsconfig file. Perhaps you want to add \`dts: { build: true }\` in your config?`):r.fileExists(o)?(p(`File ${o} exists on disk.`),new Error(`Unable to load file ${o} from the program. This seems like a bug of rollup-plugin-dts. Please report this issue to https://github.com/sxzz/rollup-plugin-dts/issues`)):(p(`File ${o} does not exist on disk.`),new Error(`Source file not found: ${o}`));return{file:v,program:f}},"createTsProgramFromParsedConfig"),te=C(({context:e=F,cwd:t,entries:r,id:o,tsconfig:s,tsconfigRaw:i,tsMacro:l,vue:a})=>{const n=x(e.files),c=s?N(s):t,f=u.parseJsonConfigFileContent(i,n,c);return p(`Creating program for root project: ${c}`),ee({baseDirectory:c,entries:r,fsSystem:n,id:o,parsedConfig:f,tsMacro:l,vue:a})},"createTsProgram"),re=C(e=>{const{context:t=F,entries:r,id:o}=e,s=t.programs.find(l=>{const a=l.getRootFileNames();return r?r.every(n=>a.includes(n)):a.includes(o)});if(s){const l=s.getSourceFile(o);if(l)return{file:l,program:s}}p(`create program for module: ${o}`);const i=te(e);return p(`created program for module: ${o}`),t.programs.push(i.program),i},"createOrGetTsModule"),oe=C(e=>{p(`running tscEmitCompiler ${e.id}`);const t=re(e),{file:r,program:o}=t;p(`got source file: ${r.fileName}`);let s,i;const{diagnostics:l,emitSkipped:a}=o.emit(r,(n,c)=>{n.endsWith(".map")?(p(`emit dts sourcemap: ${n}`),i=JSON.parse(c),R(i,n,e.id)):(p(`emit dts: ${n}`),s=c)},void 0,!0,O,!0);return a&&l.length>0?{error:u.formatDiagnostics(l,M)}:(!s&&r.isDeclarationFile&&(p("nothing was emitted. fallback to sourceFile text."),s=r.getFullText()),{code:s,map:i})},"tscEmitCompiler");var se=Object.defineProperty,ie=h((e,t)=>se(e,"name",{value:t,configurable:!0}),"r");const k=P("rollup-plugin-dts:tsc");k(`loaded typescript: ${u.version}`);const de=ie(e=>(k(`running tscEmit ${e.id}`),e.build?L(e):oe(e)),"tscEmit");export{de as tscEmit};
@@ -1 +1 @@
1
- var m=Object.defineProperty;var l=(e,o)=>m(e,"name",{value:o,configurable:!0});import p from"node:path";import{createDebug as v}from"obug";import r from"typescript";var c=Object.defineProperty,f=l((e,o)=>c(e,"name",{value:o,configurable:!0}),"t");const g=v("rollup-plugin-dts:tsc-resolver"),F=f((e,o,n,s,i,a)=>{const d=s?p.dirname(s):n,u=r.parseJsonConfigFileContent(i,r.sys,d),t=r.bundlerModuleNameResolver(e,o,u.options,r.sys,void 0,a);return g('tsc resolving id "%s" from "%s" -> %O',e,o,t.resolvedModule),t.resolvedModule?.resolvedFileName},"tscResolve");export{F as default};
1
+ var m=Object.defineProperty;var l=(e,o)=>m(e,"name",{value:o,configurable:!0});import p from"node:path";import{createDebug as v}from"obug";import r from"typescript";var c=Object.defineProperty,f=l((e,o)=>c(e,"name",{value:o,configurable:!0}),"t");const g=v("rollup-plugin-dts:tsc-resolver"),F=f((e,o,n,s,i,d)=>{const u=s?p.dirname(s):n,a=r.parseJsonConfigFileContent(i,r.sys,u),t=r.bundlerModuleNameResolver(e,o,a.options,r.sys,void 0,d);return g('tsc resolving id "%s" from "%s" -> %O',e,o,t.resolvedModule),t.resolvedModule?.resolvedFileName},"tscResolve");export{F as default};
@@ -0,0 +1,3 @@
1
+ var Ee=Object.defineProperty;var w=(e,a)=>Ee(e,"name",{value:a,configurable:!0});import ne from"node:path";import{generate as ae}from"@babel/generator";import{isIdentifierName as be}from"@babel/helper-validator-identifier";import{parse as se}from"@babel/parser";import f from"@babel/types";import{isTypeOf as $,isDeclarationType as Se,walkAST as K,resolveString as H,isIdentifierOf as Z}from"ast-kit";import{RE_DTS as j,resolveTemplateFunction as De,filenameJsToDts as oe,replaceTemplateName as le,filenameDtsTo as ce,RE_DTS_MAP as Te,filenameToDts as ve}from"../filename.js";var Ie=Object.defineProperty,S=w((e,a)=>Ie(e,"name",{value:a,configurable:!0}),"c");const z="__rollup_dts_resolve__:",Qe=S(({cjsDefault:e,sideEffects:a,sourcemap:b})=>{let t=0;const M=new Map,O=new Map,V=new Map;return{generateBundle(p,s){const u=new Map;for(const i of Object.values(s))if(i.type==="chunk")for(const y of i.moduleIds)u.set(y,i.fileName);const d=new RegExp(`"${z}(.+?)"`,"g");for(const i of Object.values(s))i.type!=="chunk"||!j.test(i.fileName)||i.code.includes(z)&&(i.code=i.code.replaceAll(d,(y,C)=>{const h=u.get(C);if(!h)return y;let T=ne.posix.relative(ne.posix.dirname(i.fileName),h);return T.startsWith(".")||(T=`./${T}`),T=ce(T,"js"),JSON.stringify(T)}));for(const i of Object.values(s))if(Te.test(i.fileName))if(b){if(i.type==="chunk"||typeof i.source!="string")continue;const y=JSON.parse(i.source);y.sourcesContent=void 0,i.source=JSON.stringify(y)}else delete s[i.fileName]},name:"rollup-plugin-dts:fake-js",outputOptions(p){const{chunkFileNames:s,entryFileNames:u}=p;return(p.format==="cjs"||p.format==="commonjs")&&(p={...p,format:"es"}),{...p,chunkFileNames(d){const i=De(d.isEntry?u||"[name].js":s||"[name]-[hash].js",d);if(d.name.endsWith(".d")){const y=oe(le(i,d.name.slice(0,-2)));if(j.test(y))return y;const C=oe(le(i,d.name));if(j.test(C))return C}return i},sourcemap:p.sourcemap||b}},renderChunk:A,async transform(p,s){if(j.test(s))return B.call(this,p,s)}};async function B(p,s){const u=Object.create(null);let d;try{d=se(p,{createParenthesizedExpressions:!0,errorRecovery:!0,plugins:[["typescript",{dts:!0}],"decoratorAutoAccessors"],sourceType:"module"})}catch(x){throw new Error(`Failed to parse ${s}. This may be caused by a syntax error in the declaration file or a bug in the plugin. Please report this issue to https://github.com/visulima/packem
2
+ ${x}`,{cause:x})}const{comments:i,program:y}=d,C=[];if(i){const x=fe(i);O.set(s,x)}const h=[],T=new Map,n=new Map,r=new Set;for(const[x,o]of y.body.entries()){const _=S(c=>y.body[x]=c,"setStmt");if(Ae(o,_,C))continue;if(o.type==="TSNamespaceExportDeclaration"){r.add(x);continue}const k=o.type==="TSModuleDeclaration"&&o.kind!=="namespace";let g;if(k&&o.id.type==="StringLiteral"){const c=await this.resolve(o.id.value,s);c&&!c.external?g=j.test(c.id)?c.id:ve(c.id):o.id.value[0]==="."&&this.warn(`\`declare module ${JSON.stringify(o.id.value)}\` will be kept as-is in the output. Relative module declaration may cause unexpected issues. Found in ${s}.`)}if(k&&s.endsWith(".vue.d.ts")&&p.slice(o.start,o.end).includes("__VLS_"))continue;const U=o.type==="ExportDefaultDeclaration",L=$(o,["ExportNamedDeclaration","ExportDefaultDeclaration"])&&o.declaration,v=L?o.declaration:o,W=L?c=>o.declaration=c:_;if(v.type!=="TSDeclareFunction"&&!Se(v))continue;$(v,["TSEnumDeclaration","ClassDeclaration","FunctionDeclaration","TSDeclareFunction","TSModuleDeclaration","VariableDeclaration"])&&(v.declare=!0);const I=[];if(v.type==="VariableDeclaration")I.push(...v.declarations.map(c=>c.id));else if("id"in v&&v.id){let c=v.id;c.type==="TSQualifiedName"&&(c=X(c)),c=k&&c.type!=="Identifier"?f.identifier(`_${J(u,"")}`):c,I.push(c)}else{const c=f.identifier("export_default");I.push(c),v.id=c}const P=me(v),l=new Set,E=he(v,T,l,u),m=[...l].filter(c=>I.every(N=>c!==N));if(v!==o&&(v.leadingComments=o.leadingComments),I.length===1&&n.has(I[0].name)){const c=n.get(I[0].name),N=Y(c);N.overloads||(N.overloads=[],N.primaryDepsCount=N.deps.length,N.primaryParamsCount=N.params.length,N.primaryChildrenCount=N.children.length),N.overloads.push({children:m,childrenOffset:N.children.length,decl:v,deps:E,depsOffset:N.deps.length,params:P,paramsOffset:N.params.length}),N.deps.push(...E),N.params.push(...P),N.children.push(...m),r.add(x);continue}const D=q({bindings:I,children:m,decl:v,deps:E,params:P,resolvedModuleId:g});I.length===1&&n.set(I[0].name,D);const Q=f.numericLiteral(D),ee=f.arrowFunctionExpression(P.map(({name:c})=>f.identifier(c)),f.arrayExpression(E)),te=f.arrayExpression(m.map(c=>({end:c.end,loc:c.loc,start:c.start,type:"StringLiteral",value:""}))),re=k&&f.callExpression(f.identifier("sideEffect"),[I[0]]),ge=Me(re?[Q,ee,te,re]:[Q,ee,te]),ie={declarations:[{id:{...I[0],typeAnnotation:null},init:ge,type:"VariableDeclarator"},...I.slice(1).map(c=>({id:{...c,typeAnnotation:null},type:"VariableDeclarator"}))],kind:"var",type:"VariableDeclaration"};U?(h.push(f.exportNamedDeclaration(null,[f.exportSpecifier(I[0],f.identifier("default"))])),_(ie)):W(ie)}return a&&h.push(f.expressionStatement(f.callExpression(f.identifier("sideEffect"),[]))),y.body=[...Array.from(T.values(),({stmt:x})=>x),...y.body.filter((x,o)=>!r.has(o)),...h],V.set(s,C),ae(d,{comments:!1,sourceFileName:s,sourceMaps:b})}function A(p,s){if(!j.test(s.fileName))return;const u=[];for(const n of s.moduleIds){const r=V.get(n);r&&u.push(...r)}let d;try{d=se(p,{sourceType:"module"})}catch(n){throw new Error(`Failed to parse generated code for chunk ${s.fileName}. This may be caused by a bug in the plugin. Please report this issue to https://github.com/visulima/packem
3
+ ${n}`,{cause:n})}const{program:i}=d;if(i.body=Pe(i.body),i.body=je(i.body),i.body=i.body.flatMap(n=>{if(_e(n))return[];if(n.type==="ExpressionStatement")return[];const r=ke(n,u,e);if(r===!1)return[];if(r)return[r];if(n.type!=="VariableDeclaration")return[n];if(!Ce(n))return[];const[x,o,_]=n.declarations[0].init.elements,k=x.value,g=Y(k);K(g.decl,{enter(l){l.type!=="CommentBlock"&&(l.leadingComments?.length||delete l.loc)}});for(const[l,E]of n.declarations.entries()){const m={...E.id,typeAnnotation:g.bindings[l].typeAnnotation};R(g.bindings[l],m)}const U=g.primaryChildrenCount??g.children.length,L=g.primaryParamsCount??g.params.length,v=g.primaryDepsCount??g.deps.length;for(let l=0;l<U;l++){const E=_.elements[l];Object.assign(g.children[l],{loc:E.loc})}const W=o.params;for(let l=0;l<L;l++){const E=W[l].name;for(const m of g.params[l].typeParams)m.name=E}const I=o.body.elements;for(let l=0;l<v;l++){const E=g.deps[l];let m=I[l];m&&m.type==="UnaryExpression"&&m.operator==="void"?m={...f.identifier("undefined"),end:m.end,loc:m.loc,start:m.start}:G(m)&&(m.name="__Infer"),E.replace?E.replace(m):Object.assign(E,m)}g.decl.type==="TSModuleDeclaration"&&g.resolvedModuleId&&(g.decl.id.value=z+g.resolvedModuleId);const P=[];if(g.overloads)for(const l of g.overloads){K(l.decl,{enter(E){E.type!=="CommentBlock"&&delete E.loc}}),"id"in l.decl&&l.decl.id&&R(l.decl.id,{...g.bindings[0]});for(const[E,m]of l.children.entries()){const D=_.elements[l.childrenOffset+E];D&&Object.assign(m,{loc:D.loc})}for(const[E,m]of l.params.entries()){const D=W[l.paramsOffset+E];if(D)for(const Q of m.typeParams)Q.name=D.name}for(const[E,m]of l.deps.entries()){let D=I[l.depsOffset+E];D&&(D.type==="UnaryExpression"&&D.operator==="void"?D={...f.identifier("undefined"),end:D.end,loc:D.loc,start:D.start}:G(D)&&(D.name="__Infer"),m.replace?m.replace(D):Object.assign(m,D))}P.push(l.decl)}return[Re(n,g.decl),...P]}).filter(n=>!!n),i.body.length===0)return"export { };";const y=i.body.some(n=>n.type==="ExportNamedDeclaration"||n.type==="ExportDefaultDeclaration"||n.type==="ExportAllDeclaration"),C=i.body.some(n=>n.type==="TSModuleDeclaration"&&n.id.type==="StringLiteral");!y&&C&&i.body.push({declaration:null,source:null,specifiers:[],type:"ExportNamedDeclaration"});const h=new Set,T=new Set;for(const n of s.moduleIds){const r=O.get(n);r&&(r.forEach(x=>{const o=x.type+x.value;T.has(o)||(T.add(o),h.add(x))}),O.delete(n))}return h.size>0&&(i.body[0].leadingComments||=[],i.body[0].leadingComments.unshift(...h)),ae(d,{comments:!0,sourceFileName:s.fileName,sourceMaps:b})}function J(p,s){return s in p?p[s]++:p[s]=0}function q(p){const s=t++;return M.set(s,p),s}function Y(p){return M.get(p)}function me(p){const s=[];K(p,{leave(d){"typeParameters"in d&&d.typeParameters?.type==="TSTypeParameterDeclaration"&&s.push(...d.typeParameters.params)}});const u=new Map;for(const d of s){const{name:i}=d,y=u.get(i);y?y.push(d):u.set(i,[d])}return Array.from(u.entries(),([d,i])=>({name:d,typeParams:i}))}function ye(p){const s=[];return K(p,{enter(u){u.type==="TSInferType"&&u.typeParameter&&s.push(u.typeParameter.name)}}),s}function he(p,s,u,d){const i=new Set,y=new Set,C=[];let h=new Set;function T(r){return r.type==="Identifier"&&h.has(r.name)}return w(T,"b"),S(T,"isInferred"),K(p,{enter(r){if(r.type==="TSConditionalType"){const x=ye(r.extendsType);C.push(x)}},leave(r,x){if(r.type==="TSConditionalType")C.pop();else if(x?.type==="TSConditionalType"){const o=x.trueType===r;h=new Set((o?C:C.slice(0,-1)).flat())}else h=new Set;if(r.type==="ExportNamedDeclaration")for(const o of r.specifiers)o.type==="ExportSpecifier"&&n(o.local);else if(r.type==="TSInterfaceDeclaration"&&r.extends)for(const o of r.extends||[])n(F(o.expression));else if(r.type==="ClassDeclaration"){if(r.superClass&&n(r.superClass),r.implements)for(const o of r.implements)o.type!=="ClassImplements"&&n(F(o.expression))}else if($(r,["ObjectMethod","ObjectProperty","ClassProperty","TSPropertySignature","TSDeclareMethod"]))r.computed&&pe(r.key)&&n(r.key),"value"in r&&pe(r.value)&&n(r.value);else switch(r.type){case"TSImportType":{y.add(r);const o=r.argument,_=r.qualifier,k=xe(r,_,o,s,d);n(k);break}case"TSTypeQuery":{if(y.has(r.exprName))return;if(r.exprName.type==="TSImportType")break;n(F(r.exprName));break}case"TSTypeReference":{n(F(r.typeName));break}}x&&!i.has(r)&&de(r,x)&&u.add(r)}}),[...i];function n(r){ue(r)||T(r)||i.add(r)}w(n,"R")}function xe(p,s,u,d,i){const y=u.value.replaceAll(/\W/g,"_"),C=`_$${be(u.value)?u.value:`${y}${J(i,y)}`}`;let h=f.identifier(C);if(d.has(u.value)?h=d.get(u.value).local:d.set(u.value,{local:h,stmt:f.importDeclaration([f.importNamespaceSpecifier(h)],u)}),s){const n=X(s);R(n,f.tsQualifiedName(h,{...n})),h=s}let T=p;return p.typeParameters?(R(p,f.tsTypeReference(h,p.typeParameters)),T=h):R(p,h),{...F(h),replace(n){R(T,n)}}}},"createFakeJsPlugin");function de(e,a){return!!(e.type==="Identifier"||$(a,["TSPropertySignature","TSMethodSignature"])&&a.key===e)}w(de,"Ie");S(de,"isChildSymbol");const Ne=/\/\s*<reference\s+(?:path|types)=/,fe=S((e,a=!1)=>e.filter(b=>Ne.test(b.value)!==a),"collectReferenceDirectives"),Ce=S(e=>f.isVariableDeclaration(e)&&e.declarations.length>0&&f.isVariableDeclarator(e.declarations[0])&&we(e.declarations[0].init),"isRuntimeBindingVariableDeclaration"),we=S(e=>f.isArrayExpression(e)&&Oe(e.elements),"isRuntimeBindingArrayExpression"),Me=S(e=>f.arrayExpression(e),"runtimeBindingArrayExpression"),Oe=S(e=>{const[a,b,t,M]=e;return a?.type==="NumericLiteral"&&b?.type==="ArrowFunctionExpression"&&t?.type==="ArrayExpression"&&(!M||M.type==="CallExpression")},"isRuntimeBindingArrayElements"),G=S(e=>Z(e,"infer"),"isInfer"),ue=S(e=>Z(e,"this")||e.type==="ThisExpression"||e.type==="MemberExpression"&&ue(e.object),"isThisExpression"),F=S(e=>{if(e.type==="Identifier")return e;const a=F(e.left);return Object.assign(e,f.memberExpression(a,e.right))},"TSEntityNameToRuntime"),X=S(e=>e.type==="Identifier"?e:X(e.left),"getIdFromTSEntityName"),pe=S(e=>$(e,["Identifier","MemberExpression"]),"isReferenceId"),_e=S(e=>e.type==="ImportDeclaration"&&e.specifiers.length===1&&e.specifiers.every(a=>a.type==="ImportSpecifier"&&a.imported.type==="Identifier"&&["__export","__reExport"].includes(a.local.name)),"isHelperImport"),ke=S((e,a,b)=>{if(e.type==="ExportNamedDeclaration"&&!e.declaration&&!e.source&&e.specifiers.length===0&&!e.attributes?.length)return!1;if(e.type==="ImportDeclaration"&&e.specifiers.length>0)for(const t of e.specifiers)G(t.local)&&(t.local.name="__Infer");if($(e,["ImportDeclaration","ExportAllDeclaration","ExportNamedDeclaration"])){if(e.type==="ExportNamedDeclaration"&&a.length>0)for(const t of e.specifiers){const M=H(t.exported);a.includes(M)&&(t.type==="ExportSpecifier"?t.exportKind="type":e.exportKind="type")}if(e.source?.value&&j.test(e.source.value))return e.source.value=ce(e.source.value,"js"),e;if(b&&e.type==="ExportNamedDeclaration"&&!e.source&&e.specifiers.length===1&&e.specifiers[0].type==="ExportSpecifier"&&H(e.specifiers[0].exported)==="default")return{expression:e.specifiers[0].local,type:"TSExportAssignment"}}},"patchImportExport"),Pe=S(e=>{const a=new Set;for(const[t,M]of e.entries()){const O=b(M);if(!O)continue;const[V,B]=O;B.properties.length!==0&&(e[t]={body:{body:[{declaration:null,source:null,specifiers:B.properties.filter(A=>A.type==="ObjectProperty").map(A=>{const J=A.value.body,q=A.key;return f.exportSpecifier(J,q)}),type:"ExportNamedDeclaration"}],type:"TSModuleBlock"},declare:!0,id:V,kind:"namespace",type:"TSModuleDeclaration"})}return e.filter(t=>!a.has(t));function b(t){if(t.type!=="VariableDeclaration"||t.declarations.length!==1||t.declarations[0].id.type!=="Identifier"||t.declarations[0].init?.type!=="CallExpression"||t.declarations[0].init.callee.type!=="Identifier"||t.declarations[0].init.callee.name!=="__export"||t.declarations[0].init.arguments.length!==1||t.declarations[0].init.arguments[0].type!=="ObjectExpression")return!1;const M=t.declarations[0].id,O=t.declarations[0].init.arguments[0];return[M,O]}},"patchTsNamespace"),je=S(e=>{const a=new Map;for(const[b,t]of e.entries())if(t.type==="ImportDeclaration"&&t.specifiers.length===1&&t.specifiers[0].type==="ImportSpecifier"&&t.specifiers[0].local.type==="Identifier"&&t.specifiers[0].local.name.endsWith("_exports"))a.set(t.specifiers[0].local.name,t.specifiers[0].local.name);else if(t.type==="ExpressionStatement"&&t.expression.type==="CallExpression"&&Z(t.expression.callee,"__reExport")){const M=t.expression.arguments;a.set(M[0].name,M[1].name)}else t.type==="VariableDeclaration"&&t.declarations.length===1&&t.declarations[0].init?.type==="MemberExpression"&&t.declarations[0].init.object.type==="Identifier"&&a.has(t.declarations[0].init.object.name)?e[b]={id:{name:t.declarations[0].id.name,type:"Identifier"},type:"TSTypeAliasDeclaration",typeAnnotation:{type:"TSTypeReference",typeName:{left:{name:a.get(t.declarations[0].init.object.name),type:"Identifier"},right:{name:t.declarations[0].init.property.name,type:"Identifier"},type:"TSQualifiedName"}}}:t.type==="ExportNamedDeclaration"&&t.specifiers.length===1&&t.specifiers[0].type==="ExportSpecifier"&&t.specifiers[0].local.type==="Identifier"&&a.has(t.specifiers[0].local.name)&&(t.specifiers[0].local.name=a.get(t.specifiers[0].local.name));return e},"patchReExport"),Ae=S((e,a,b)=>{if(e.type==="ImportDeclaration"||e.type==="ExportNamedDeclaration"&&!e.declaration){for(const t of e.specifiers)("exportKind"in t&&t.exportKind==="type"||"exportKind"in e&&e.exportKind==="type")&&b.push(H(t.exported)),t.type==="ImportSpecifier"?t.importKind="value":t.type==="ExportSpecifier"&&(t.exportKind="value");return e.type==="ImportDeclaration"?e.importKind="value":e.type==="ExportNamedDeclaration"&&(e.exportKind="value"),!0}return e.type==="ExportAllDeclaration"?(e.exportKind="value",!0):e.type==="TSImportEqualsDeclaration"?(e.moduleReference.type==="TSExternalModuleReference"&&a({source:e.moduleReference.expression,specifiers:[{local:e.id,type:"ImportDefaultSpecifier"}],type:"ImportDeclaration"}),!0):e.type==="TSExportAssignment"&&e.expression.type==="Identifier"?(a({specifiers:[{exported:{name:"default",type:"Identifier"},local:e.expression,type:"ExportSpecifier"}],type:"ExportNamedDeclaration"}),!0):e.type==="ExportDefaultDeclaration"&&e.declaration.type==="Identifier"?(a({specifiers:[{exported:f.identifier("default"),local:e.declaration,type:"ExportSpecifier"}],type:"ExportNamedDeclaration"}),!0):!1},"rewriteImportExport"),R=S((e,a)=>{for(const b of Object.keys(e))delete e[b];return Object.assign(e,a),e},"overwriteNode"),Re=S((e,a)=>{a.leadingComments||=[];const b=e.leadingComments?.filter(t=>t.value.startsWith("#"));return b&&a.leadingComments.unshift(...b),a.leadingComments=fe(a.leadingComments,!0),a},"inheritNodeComments");export{Qe as default};
@@ -0,0 +1 @@
1
+ import"node:child_process";import"node:fs";import"node:fs/promises";import"node:path";import"@babel/parser";import"@rollup/pluginutils";import"obug";import"oxc-transform";import"../filename.js";import{c as g}from"./generate-Dy7UEhz1.js";export{g as createGeneratePlugin};