@visulima/rollup-plugin-dts 1.0.0-alpha.2 → 1.0.0-alpha.21
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 +108 -0
- package/dist/banner.d.ts +4 -0
- package/dist/dts-input.d.ts +4 -0
- package/dist/fake-js.d.ts +4 -0
- package/dist/filename.d.ts +14 -17
- package/dist/filename.js +1 -1
- package/dist/generate.d.ts +12 -0
- package/dist/index.d.ts +7 -56
- package/dist/index.js +3 -3
- package/dist/options.d.ts +215 -0
- package/dist/packem_chunks/index.js +1 -1
- package/dist/packem_shared/createFakeJsPlugin-DhesHehE.js +3 -0
- package/dist/packem_shared/createGeneratePlugin-DWAaoMPf.js +1 -0
- package/dist/packem_shared/generate-C7_nIfGu.js +9 -0
- package/dist/packem_shared/resolveOptions-Bp8RzeQ2.js +1 -0
- package/dist/resolver.d.ts +4 -0
- package/dist/tsc/context.d.ts +14 -0
- package/dist/tsc/emit-build.d.ts +3 -0
- package/dist/tsc/emit-compiler.d.ts +3 -0
- package/dist/tsc/index.d.ts +3 -0
- package/dist/tsc/resolver.d.ts +3 -0
- package/dist/tsc/system.d.ts +7 -0
- package/dist/tsc/types.d.ts +26 -0
- package/dist/tsc/utils.d.ts +5 -0
- package/dist/tsc/volar.d.ts +4 -0
- package/dist/tsc/worker.d.ts +6 -0
- package/dist/tsgo.d.ts +2 -0
- package/package.json +8 -7
- package/dist/packem_shared/createFakeJsPlugin-C_PkEz9j.js +0 -1
- package/dist/packem_shared/createGeneratePlugin-BgPgGC2n.js +0 -1
- package/dist/packem_shared/generate-CxhgFvNH.js +0 -9
- package/dist/packem_shared/resolveOptions-CpYBT-5y.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,111 @@
|
|
|
1
|
+
## @visulima/rollup-plugin-dts [1.0.0-alpha.21](https://github.com/visulima/packem/compare/@visulima/rollup-plugin-dts@1.0.0-alpha.20...@visulima/rollup-plugin-dts@1.0.0-alpha.21) (2026-04-24)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* **rollup-plugin-dts:** force re-transform for node_modules .d.ts too ([c93d34e](https://github.com/visulima/packem/commit/c93d34e588956920f9cc5958dcffe7eb0ffb3ee9))
|
|
6
|
+
|
|
7
|
+
## @visulima/rollup-plugin-dts [1.0.0-alpha.20](https://github.com/visulima/packem/compare/@visulima/rollup-plugin-dts@1.0.0-alpha.19...@visulima/rollup-plugin-dts@1.0.0-alpha.20) (2026-04-24)
|
|
8
|
+
|
|
9
|
+
### Code Refactoring
|
|
10
|
+
|
|
11
|
+
* **rollup-plugin-dts:** improve sibling-dts fallback helper ([1df7353](https://github.com/visulima/packem/commit/1df735325914ced9ab7e2b73d6980e3243a43838))
|
|
12
|
+
|
|
13
|
+
## @visulima/rollup-plugin-dts [1.0.0-alpha.19](https://github.com/visulima/packem/compare/@visulima/rollup-plugin-dts@1.0.0-alpha.18...@visulima/rollup-plugin-dts@1.0.0-alpha.19) (2026-04-24)
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* **rollup-plugin-dts:** sibling .d.ts fallback for string-form exports ([2a26b69](https://github.com/visulima/packem/commit/2a26b69b322375061cdcd55a14c72301085606ef))
|
|
18
|
+
|
|
19
|
+
## @visulima/rollup-plugin-dts [1.0.0-alpha.18](https://github.com/visulima/packem/compare/@visulima/rollup-plugin-dts@1.0.0-alpha.17...@visulima/rollup-plugin-dts@1.0.0-alpha.18) (2026-04-24)
|
|
20
|
+
|
|
21
|
+
## @visulima/rollup-plugin-dts [1.0.0-alpha.17](https://github.com/visulima/packem/compare/@visulima/rollup-plugin-dts@1.0.0-alpha.16...@visulima/rollup-plugin-dts@1.0.0-alpha.17) (2026-04-24)
|
|
22
|
+
|
|
23
|
+
### Bug Fixes
|
|
24
|
+
|
|
25
|
+
* correctly handle peer-dep/types-only/merged-declaration edge cases in DTS ([42b6f7c](https://github.com/visulima/packem/commit/42b6f7c0888b6e51f7755a1afca5954b1e8ba1d3))
|
|
26
|
+
|
|
27
|
+
## @visulima/rollup-plugin-dts [1.0.0-alpha.16](https://github.com/visulima/packem/compare/@visulima/rollup-plugin-dts@1.0.0-alpha.15...@visulima/rollup-plugin-dts@1.0.0-alpha.16) (2026-04-24)
|
|
28
|
+
|
|
29
|
+
### Bug Fixes
|
|
30
|
+
|
|
31
|
+
* **rollup-plugin-dts:** inline bundled-package types in emitted .d.ts ([ce4c00d](https://github.com/visulima/packem/commit/ce4c00d24ebf14b25c799dc51f3b5f8939a9fae3))
|
|
32
|
+
|
|
33
|
+
## @visulima/rollup-plugin-dts [1.0.0-alpha.15](https://github.com/visulima/packem/compare/@visulima/rollup-plugin-dts@1.0.0-alpha.14...@visulima/rollup-plugin-dts@1.0.0-alpha.15) (2026-04-24)
|
|
34
|
+
|
|
35
|
+
### Bug Fixes
|
|
36
|
+
|
|
37
|
+
* **rollup-plugin-dts:** don't force disk-mode for composite-only projects ([a2498f7](https://github.com/visulima/packem/commit/a2498f722ed30369ecb715381bed5ad607274967))
|
|
38
|
+
|
|
39
|
+
## @visulima/rollup-plugin-dts [1.0.0-alpha.14](https://github.com/visulima/packem/compare/@visulima/rollup-plugin-dts@1.0.0-alpha.13...@visulima/rollup-plugin-dts@1.0.0-alpha.14) (2026-04-23)
|
|
40
|
+
|
|
41
|
+
## @visulima/rollup-plugin-dts [1.0.0-alpha.13](https://github.com/visulima/packem/compare/@visulima/rollup-plugin-dts@1.0.0-alpha.12...@visulima/rollup-plugin-dts@1.0.0-alpha.13) (2026-04-23)
|
|
42
|
+
|
|
43
|
+
## @visulima/rollup-plugin-dts [1.0.0-alpha.12](https://github.com/visulima/packem/compare/@visulima/rollup-plugin-dts@1.0.0-alpha.11...@visulima/rollup-plugin-dts@1.0.0-alpha.12) (2026-04-23)
|
|
44
|
+
|
|
45
|
+
### Bug Fixes
|
|
46
|
+
|
|
47
|
+
* **rollup-plugin-dts:** sync fixes from upstream rolldown-plugin-dts ([449794f](https://github.com/visulima/packem/commit/449794ff6b57e71957c8647c09c7d9145a07f3d0)), closes [sxzz/rolldown-plugin-dts#191](https://github.com/sxzz/rolldown-plugin-dts/issues/191)
|
|
48
|
+
|
|
49
|
+
### Miscellaneous Chores
|
|
50
|
+
|
|
51
|
+
* **rollup-plugin-dts:** restore isolatedDeclarationTransformer in build config ([46d54f4](https://github.com/visulima/packem/commit/46d54f4f590529abd88b998ab2ade4cd4a861571))
|
|
52
|
+
|
|
53
|
+
## @visulima/rollup-plugin-dts [1.0.0-alpha.11](https://github.com/visulima/packem/compare/@visulima/rollup-plugin-dts@1.0.0-alpha.10...@visulima/rollup-plugin-dts@1.0.0-alpha.11) (2026-04-18)
|
|
54
|
+
|
|
55
|
+
## @visulima/rollup-plugin-dts [1.0.0-alpha.10](https://github.com/visulima/packem/compare/@visulima/rollup-plugin-dts@1.0.0-alpha.9...@visulima/rollup-plugin-dts@1.0.0-alpha.10) (2026-04-16)
|
|
56
|
+
|
|
57
|
+
### Miscellaneous Chores
|
|
58
|
+
|
|
59
|
+
* bump node engines to ^22.14.0 || >=24.10.0 ([32f705a](https://github.com/visulima/packem/commit/32f705aa866f9daea6a094df74ef66aa8088e2c6))
|
|
60
|
+
|
|
61
|
+
## @visulima/rollup-plugin-dts [1.0.0-alpha.9](https://github.com/visulima/packem/compare/@visulima/rollup-plugin-dts@1.0.0-alpha.8...@visulima/rollup-plugin-dts@1.0.0-alpha.9) (2026-03-28)
|
|
62
|
+
|
|
63
|
+
## @visulima/rollup-plugin-dts [1.0.0-alpha.8](https://github.com/visulima/packem/compare/@visulima/rollup-plugin-dts@1.0.0-alpha.7...@visulima/rollup-plugin-dts@1.0.0-alpha.8) (2026-03-24)
|
|
64
|
+
|
|
65
|
+
## @visulima/rollup-plugin-dts [1.0.0-alpha.7](https://github.com/visulima/packem/compare/@visulima/rollup-plugin-dts@1.0.0-alpha.6...@visulima/rollup-plugin-dts@1.0.0-alpha.7) (2026-03-24)
|
|
66
|
+
|
|
67
|
+
### Miscellaneous Chores
|
|
68
|
+
|
|
69
|
+
* allow typescript 5 and 6 in peerDependencies and examples ([de6362d](https://github.com/visulima/packem/commit/de6362d402f593c11a9eedd04d756d69bade4ac5))
|
|
70
|
+
|
|
71
|
+
## @visulima/rollup-plugin-dts [1.0.0-alpha.6](https://github.com/visulima/packem/compare/@visulima/rollup-plugin-dts@1.0.0-alpha.5...@visulima/rollup-plugin-dts@1.0.0-alpha.6) (2026-03-24)
|
|
72
|
+
|
|
73
|
+
### Bug Fixes
|
|
74
|
+
|
|
75
|
+
* **rollup-plugin-dts:** only add export {} for declare module augmentations, not declare global ([c53e3db](https://github.com/visulima/packem/commit/c53e3dbce725ac2579eaa0fdca30e52fc8b43b89))
|
|
76
|
+
* **rollup-plugin-dts:** preserve export {} in module augmentation files ([43c7975](https://github.com/visulima/packem/commit/43c7975cdf1300fbd0e0c949f6b5c3851e5a937c))
|
|
77
|
+
* **rollup-plugin-dts:** preserve JSDoc comment positioning in type aliases ([436f8dc](https://github.com/visulima/packem/commit/436f8dcb4a6ce025a2eb7b537ee7f868f4bbed01))
|
|
78
|
+
|
|
79
|
+
### Tests
|
|
80
|
+
|
|
81
|
+
* **rollup-plugin-dts:** add triple-slash directive preservation test ([eacac81](https://github.com/visulima/packem/commit/eacac81d49d7ef5917cd7aaf10762dfdac040a0d))
|
|
82
|
+
|
|
83
|
+
## @visulima/rollup-plugin-dts [1.0.0-alpha.5](https://github.com/visulima/packem/compare/@visulima/rollup-plugin-dts@1.0.0-alpha.4...@visulima/rollup-plugin-dts@1.0.0-alpha.5) (2026-03-24)
|
|
84
|
+
|
|
85
|
+
### Features
|
|
86
|
+
|
|
87
|
+
* **rollup-plugin-dts:** add include/exclude filter support ([5d76867](https://github.com/visulima/packem/commit/5d76867939d95c1d75469f85a59b9504f3c3f1e4))
|
|
88
|
+
|
|
89
|
+
### Bug Fixes
|
|
90
|
+
|
|
91
|
+
* **rollup-plugin-dts:** externalize scss/sass/less/styl/stylus imports ([183ff0b](https://github.com/visulima/packem/commit/183ff0b0e58c11d7ee0d11b6ab69b493f01f3b75))
|
|
92
|
+
* **rollup-plugin-dts:** handle function overloads in .d.ts bundling ([afe77ab](https://github.com/visulima/packem/commit/afe77ab941fc51d024c49fea58086d7a6b81073f))
|
|
93
|
+
* **rollup-plugin-dts:** support decorator auto-accessors in .d.ts parsing ([154795a](https://github.com/visulima/packem/commit/154795aa6f5d0f9b39c8ea39c18356bf285c15d4))
|
|
94
|
+
* updated deps ([a50675d](https://github.com/visulima/packem/commit/a50675d7f9a98236edd89bc39bc35b8cb4db1565))
|
|
95
|
+
|
|
96
|
+
### Miscellaneous Chores
|
|
97
|
+
|
|
98
|
+
* **rollup-plugin-dts:** add explicit return type to loadVueLanguageTools ([cf47a3c](https://github.com/visulima/packem/commit/cf47a3c60fe2c7931d23dedc4162789ce3a8b5c0))
|
|
99
|
+
|
|
100
|
+
### Tests
|
|
101
|
+
|
|
102
|
+
* **rollup-plugin-dts:** add regression tests for type modifier preservation through export * ([ca9fe87](https://github.com/visulima/packem/commit/ca9fe87b05f37afe6b80263d94b855ef69143ee3)), closes [#225](https://github.com/visulima/packem/issues/225)
|
|
103
|
+
* **rollup-plugin-dts:** add tests for overloads, scss, decorators, infer renaming ([36e0987](https://github.com/visulima/packem/commit/36e09874d3aba9b8f5361dd8899d56865d00bf0b))
|
|
104
|
+
|
|
105
|
+
## @visulima/rollup-plugin-dts [1.0.0-alpha.4](https://github.com/visulima/packem/compare/@visulima/rollup-plugin-dts@1.0.0-alpha.3...@visulima/rollup-plugin-dts@1.0.0-alpha.4) (2026-03-16)
|
|
106
|
+
|
|
107
|
+
## @visulima/rollup-plugin-dts [1.0.0-alpha.3](https://github.com/visulima/packem/compare/@visulima/rollup-plugin-dts@1.0.0-alpha.2...@visulima/rollup-plugin-dts@1.0.0-alpha.3) (2026-03-14)
|
|
108
|
+
|
|
1
109
|
## @visulima/rollup-plugin-dts [1.0.0-alpha.2](https://github.com/visulima/packem/compare/@visulima/rollup-plugin-dts@1.0.0-alpha.1...@visulima/rollup-plugin-dts@1.0.0-alpha.2) (2026-03-06)
|
|
2
110
|
|
|
3
111
|
### Bug Fixes
|
package/dist/banner.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Plugin } from "rollup";
|
|
2
|
+
import type { OptionsResolved } from "./options.d.ts";
|
|
3
|
+
declare const createFakeJsPlugin: ({ cjsDefault, sideEffects, sourcemap }: Pick<OptionsResolved, "sourcemap" | "cjsDefault" | "sideEffects">) => Plugin;
|
|
4
|
+
export default createFakeJsPlugin;
|
package/dist/filename.d.ts
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import { PreRenderedChunk } from
|
|
2
|
-
|
|
3
|
-
declare const
|
|
4
|
-
declare const
|
|
5
|
-
declare const
|
|
6
|
-
declare const
|
|
7
|
-
declare const
|
|
8
|
-
declare const
|
|
9
|
-
declare const
|
|
10
|
-
declare const
|
|
11
|
-
declare const
|
|
12
|
-
declare const
|
|
13
|
-
declare const
|
|
14
|
-
declare const
|
|
15
|
-
declare const replaceTemplateName: (template: string, name: string) => string;
|
|
16
|
-
|
|
17
|
-
export { RE_CSS, RE_DTS, RE_DTS_MAP, RE_JS, RE_JSON, RE_NODE_MODULES, RE_TS, RE_VUE, filename_dts_to, filename_js_to_dts, filename_to_dts, replaceTemplateName, resolveTemplateFn };
|
|
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;
|
package/dist/filename.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var _=Object.defineProperty;var
|
|
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};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Plugin } from "rollup";
|
|
2
|
+
import type { OptionsResolved } from "./options.d.ts";
|
|
3
|
+
export interface TsModule {
|
|
4
|
+
/** `.ts` source code */
|
|
5
|
+
code: string;
|
|
6
|
+
/** `.ts` file name */
|
|
7
|
+
id: string;
|
|
8
|
+
isEntry: boolean;
|
|
9
|
+
}
|
|
10
|
+
/** dts filename -> ts module */
|
|
11
|
+
export type DtsMap = Map<string, TsModule>;
|
|
12
|
+
export declare const createGeneratePlugin: ({ build, cwd, eager, emitDtsOnly, emitJs, exclude, include, incremental, newContext, oxc, parallel, sourcemap, tsconfig, tsconfigRaw, tsgo, tsMacro, vue, }: Pick<OptionsResolved, "cwd" | "tsconfig" | "tsconfigRaw" | "build" | "incremental" | "oxc" | "emitDtsOnly" | "vue" | "tsMacro" | "parallel" | "eager" | "tsgo" | "newContext" | "emitJs" | "sourcemap" | "include" | "exclude">) => Plugin;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,56 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
compilerOptions?: TsConfigJson.CompilerOptions;
|
|
9
|
-
cwd?: string;
|
|
10
|
-
dtsInput?: boolean;
|
|
11
|
-
emitDtsOnly?: boolean;
|
|
12
|
-
resolve?: boolean | (string | RegExp)[];
|
|
13
|
-
resolver?: "oxc" | "tsc";
|
|
14
|
-
sideEffects?: boolean;
|
|
15
|
-
sourcemap?: boolean;
|
|
16
|
-
tsconfig?: string | boolean;
|
|
17
|
-
tsconfigRaw?: Omit<TsConfigJson, "compilerOptions">;
|
|
18
|
-
}
|
|
19
|
-
interface TscOptions {
|
|
20
|
-
banner?: string | Promise<string> | AddonFunction;
|
|
21
|
-
build?: boolean;
|
|
22
|
-
eager?: boolean;
|
|
23
|
-
emitJs?: boolean;
|
|
24
|
-
footer?: string | Promise<string> | AddonFunction;
|
|
25
|
-
incremental?: boolean;
|
|
26
|
-
newContext?: boolean;
|
|
27
|
-
parallel?: boolean;
|
|
28
|
-
tsMacro?: boolean;
|
|
29
|
-
vue?: boolean;
|
|
30
|
-
}
|
|
31
|
-
interface Options extends GeneralOptions, TscOptions {
|
|
32
|
-
oxc?: boolean | Omit<IsolatedDeclarationsOptions, "sourcemap">;
|
|
33
|
-
tsgo?: boolean | {
|
|
34
|
-
path?: string;
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;
|
|
38
|
-
type MarkPartial<T, K extends keyof T> = Omit<Required<T>, K> & Partial<Pick<T, K>>;
|
|
39
|
-
type OptionsResolved = Overwrite<MarkPartial<Omit<Options, "compilerOptions">, "banner" | "footer">, {
|
|
40
|
-
oxc: IsolatedDeclarationsOptions | false;
|
|
41
|
-
tsconfig?: string;
|
|
42
|
-
tsconfigRaw: TsConfigJson;
|
|
43
|
-
tsgo: {
|
|
44
|
-
path?: string;
|
|
45
|
-
} | false;
|
|
46
|
-
}>;
|
|
47
|
-
declare const resolveOptions: ({ banner, build, cjsDefault, compilerOptions, cwd, dtsInput, eager, emitDtsOnly, emitJs, footer, incremental, newContext, oxc, parallel, resolve, resolver, sideEffects, sourcemap, tsconfig, tsconfigRaw: overriddenTsconfigRaw, tsgo: tsgoOption, tsMacro, vue, }: Options) => OptionsResolved;
|
|
48
|
-
|
|
49
|
-
declare const createFakeJsPlugin: ({ cjsDefault, sideEffects, sourcemap }: Pick<OptionsResolved, "sourcemap" | "cjsDefault" | "sideEffects">) => Plugin;
|
|
50
|
-
|
|
51
|
-
declare const createGeneratePlugin: ({ build, cwd, eager, emitDtsOnly, emitJs, incremental, newContext, oxc, parallel, sourcemap, tsconfig, tsconfigRaw, tsgo, tsMacro, vue, }: Pick<OptionsResolved, "cwd" | "tsconfig" | "tsconfigRaw" | "build" | "incremental" | "oxc" | "emitDtsOnly" | "vue" | "tsMacro" | "parallel" | "eager" | "tsgo" | "newContext" | "emitJs" | "sourcemap">) => Plugin;
|
|
52
|
-
|
|
53
|
-
declare const dts: (options?: Options) => Plugin[];
|
|
54
|
-
|
|
55
|
-
export { createFakeJsPlugin, createGeneratePlugin, dts, resolveOptions };
|
|
56
|
-
export type { Options };
|
|
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";
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
2
|
-
`)}if(e){const
|
|
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-C7_nIfGu.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}
|
|
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};
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import type { TsConfigJson } from "@visulima/tsconfig";
|
|
2
|
+
import type { IsolatedDeclarationsOptions } from "oxc-transform";
|
|
3
|
+
import type { AddonFunction } from "rollup";
|
|
4
|
+
export type FilterPattern = ReadonlyArray<string | RegExp> | string | RegExp | null;
|
|
5
|
+
export interface GeneralOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Determines how the default export is emitted.
|
|
8
|
+
*
|
|
9
|
+
* If set to `true`, and you are only exporting a single item using `export default ...`,
|
|
10
|
+
* the output will use `export = ...` instead of the standard ES module syntax.
|
|
11
|
+
* This is useful for compatibility with CommonJS.
|
|
12
|
+
*/
|
|
13
|
+
cjsDefault?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* A pattern (or array of patterns) specifying files to exclude from DTS generation.
|
|
16
|
+
* Files matching this pattern will be skipped by the transform hook and will not have
|
|
17
|
+
* `.d.ts` files generated.
|
|
18
|
+
*
|
|
19
|
+
* Accepts minimatch glob patterns, regular expressions, or arrays of either.
|
|
20
|
+
*/
|
|
21
|
+
exclude?: FilterPattern;
|
|
22
|
+
/**
|
|
23
|
+
* Override the `compilerOptions` specified in `tsconfig.json`.
|
|
24
|
+
* @see https://www.typescriptlang.org/tsconfig/#compilerOptions
|
|
25
|
+
*/
|
|
26
|
+
compilerOptions?: TsConfigJson.CompilerOptions;
|
|
27
|
+
/**
|
|
28
|
+
* The directory in which the plugin will search for the `tsconfig.json` file.
|
|
29
|
+
*/
|
|
30
|
+
cwd?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Set to `true` if your entry files are `.d.ts` files instead of `.ts` files.
|
|
33
|
+
*
|
|
34
|
+
* When enabled, the plugin will skip generating a `.d.ts` file for the entry point.
|
|
35
|
+
*/
|
|
36
|
+
dtsInput?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* If `true`, the plugin will emit only `.d.ts` files and remove all other output chunks.
|
|
39
|
+
*
|
|
40
|
+
* This is especially useful when generating `.d.ts` files for the CommonJS format as part of a separate build step.
|
|
41
|
+
*/
|
|
42
|
+
emitDtsOnly?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* A pattern (or array of patterns) specifying files to include in DTS generation.
|
|
45
|
+
* Only files matching this pattern will have `.d.ts` files generated.
|
|
46
|
+
*
|
|
47
|
+
* By default, all TypeScript and Vue files are included.
|
|
48
|
+
* Accepts minimatch glob patterns, regular expressions, or arrays of either.
|
|
49
|
+
*/
|
|
50
|
+
include?: FilterPattern;
|
|
51
|
+
/**
|
|
52
|
+
* Controls whether type definitions from `node_modules` are bundled into your final `.d.ts` file or kept as external `import` statements.
|
|
53
|
+
*
|
|
54
|
+
* By default, dependencies are external, resulting in `import { Type } from 'some-package'`. When bundled, this `import` is removed, and the type definitions from `some-package` are copied directly into your file.
|
|
55
|
+
*
|
|
56
|
+
* - `true`: Bundles all dependencies.
|
|
57
|
+
* - `false`: (Default) Keeps all dependencies external.
|
|
58
|
+
* - `(string | RegExp)[]`: Bundles only dependencies matching the provided strings or regular expressions (e.g. `['pkg-a', /^@scope\//]`).
|
|
59
|
+
*/
|
|
60
|
+
resolve?: boolean | (string | RegExp)[];
|
|
61
|
+
/**
|
|
62
|
+
* Specifies a resolver to resolve type definitions, especially for `node_modules`.
|
|
63
|
+
*
|
|
64
|
+
* - `'oxc'`: Uses Oxc's module resolution, which is faster and more efficient.
|
|
65
|
+
* - `'tsc'`: Uses TypeScript's native module resolution, which may be more compatible with complex setups, but slower.
|
|
66
|
+
* @default 'oxc'
|
|
67
|
+
*/
|
|
68
|
+
resolver?: "oxc" | "tsc";
|
|
69
|
+
/**
|
|
70
|
+
* Indicates whether the generated `.d.ts` files have side effects.
|
|
71
|
+
* - If set to `true`, Rolldown will treat the `.d.ts` files as having side effects during tree-shaking.
|
|
72
|
+
* - If set to `false`, Rolldown may consider the `.d.ts` files as side-effect-free, potentially removing them if they are not imported.
|
|
73
|
+
* @default false
|
|
74
|
+
*/
|
|
75
|
+
sideEffects?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* If `true`, the plugin will generate declaration maps (`.d.ts.map`) for `.d.ts` files.
|
|
78
|
+
*/
|
|
79
|
+
sourcemap?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* The path to the `tsconfig.json` file.
|
|
82
|
+
*
|
|
83
|
+
* If set to `false`, the plugin will ignore any `tsconfig.json` file.
|
|
84
|
+
* You can still specify `compilerOptions` directly in the options.
|
|
85
|
+
* @default 'tsconfig.json'
|
|
86
|
+
*/
|
|
87
|
+
tsconfig?: string | boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Pass a raw `tsconfig.json` object directly to the plugin.
|
|
90
|
+
* @see https://www.typescriptlang.org/tsconfig
|
|
91
|
+
*/
|
|
92
|
+
tsconfigRaw?: Omit<TsConfigJson, "compilerOptions">;
|
|
93
|
+
}
|
|
94
|
+
export interface TscOptions {
|
|
95
|
+
/**
|
|
96
|
+
* Content to be added at the top of each generated `.d.ts` file.
|
|
97
|
+
*/
|
|
98
|
+
banner?: string | Promise<string> | AddonFunction;
|
|
99
|
+
/**
|
|
100
|
+
* Build mode for the TypeScript compiler:
|
|
101
|
+
*
|
|
102
|
+
* - If `true`, the plugin will use [`tsc -b`](https://www.typescriptlang.org/docs/handbook/project-references.html#build-mode-for-typescript) to build the project and all referenced projects before emitting `.d.ts` files.
|
|
103
|
+
* - If `false`, the plugin will use [`tsc`](https://www.typescriptlang.org/docs/handbook/compiler-options.html) to emit `.d.ts` files without building referenced projects.
|
|
104
|
+
* @default false
|
|
105
|
+
*/
|
|
106
|
+
build?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* If `true`, the plugin will prepare all files listed in `tsconfig.json` for `tsc` or `vue-tsc`.
|
|
109
|
+
*
|
|
110
|
+
* This is especially useful when you have a single `tsconfig.json` for multiple projects in a monorepo.
|
|
111
|
+
*/
|
|
112
|
+
eager?: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* If `true`, the plugin will emit `.d.ts` files for `.js` files as well.
|
|
115
|
+
* This is useful when you want to generate type definitions for JavaScript files with JSDoc comments.
|
|
116
|
+
*
|
|
117
|
+
* Enabled by default when `allowJs` in compilerOptions is `true`.
|
|
118
|
+
* This option is only used when {@link Options.oxc} is
|
|
119
|
+
* `false`.
|
|
120
|
+
*/
|
|
121
|
+
emitJs?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Content to be added at the bottom of each generated `.d.ts` file.
|
|
124
|
+
*/
|
|
125
|
+
footer?: string | Promise<string> | AddonFunction;
|
|
126
|
+
/**
|
|
127
|
+
* If your tsconfig.json has
|
|
128
|
+
* [`references`](https://www.typescriptlang.org/tsconfig/#references) option,
|
|
129
|
+
* `@visulima/rollup-plugin-dts` will use [`tsc
|
|
130
|
+
* -b`](https://www.typescriptlang.org/docs/handbook/project-references.html#build-mode-for-typescript)
|
|
131
|
+
* to build the project and all referenced projects before emitting `.d.ts`
|
|
132
|
+
* files.
|
|
133
|
+
*
|
|
134
|
+
* In such case, if this option is `true`, `@visulima/rollup-plugin-dts` will write
|
|
135
|
+
* down all built files into your disk, including
|
|
136
|
+
* [`.tsbuildinfo`](https://www.typescriptlang.org/tsconfig/#tsBuildInfoFile)
|
|
137
|
+
* and other built files. This is equivalent to running `tsc -b` in your
|
|
138
|
+
* project.
|
|
139
|
+
*
|
|
140
|
+
* Otherwise, if this option is `false`, `@visulima/rollup-plugin-dts` will write
|
|
141
|
+
* built files only into memory and leave a small footprint in your disk.
|
|
142
|
+
*
|
|
143
|
+
* Enabling this option will decrease the build time by caching previous build
|
|
144
|
+
* results. This is helpful when you have a large project with multiple
|
|
145
|
+
* referenced projects.
|
|
146
|
+
*
|
|
147
|
+
* By default, `incremental` is `true` if your tsconfig has
|
|
148
|
+
* [`incremental`](https://www.typescriptlang.org/tsconfig/#incremental) or
|
|
149
|
+
* [`tsBuildInfoFile`](https://www.typescriptlang.org/tsconfig/#tsBuildInfoFile)
|
|
150
|
+
* enabled.
|
|
151
|
+
*
|
|
152
|
+
* This option is only used when {@link Options.oxc} is
|
|
153
|
+
* `false`.
|
|
154
|
+
*/
|
|
155
|
+
incremental?: boolean;
|
|
156
|
+
/**
|
|
157
|
+
* If `true`, the plugin will create a new isolated context for each build,
|
|
158
|
+
* ensuring that previously generated `.d.ts` code and caches are not reused.
|
|
159
|
+
*
|
|
160
|
+
* By default, the plugin may reuse internal caches or incremental build artifacts
|
|
161
|
+
* to speed up repeated builds. Enabling this option forces a clean context,
|
|
162
|
+
* guaranteeing that all type definitions are generated from scratch.
|
|
163
|
+
* @default false
|
|
164
|
+
*/
|
|
165
|
+
newContext?: boolean;
|
|
166
|
+
/**
|
|
167
|
+
* If `true`, the plugin will launch a separate process for `tsc` or `vue-tsc`.
|
|
168
|
+
* This enables processing multiple projects in parallel.
|
|
169
|
+
*/
|
|
170
|
+
parallel?: boolean;
|
|
171
|
+
/**
|
|
172
|
+
* If `true`, the plugin will generate `.d.ts` files using `@ts-macro/tsc`.
|
|
173
|
+
*/
|
|
174
|
+
tsMacro?: boolean;
|
|
175
|
+
/**
|
|
176
|
+
* If `true`, the plugin will generate `.d.ts` files using `vue-tsc`.
|
|
177
|
+
*/
|
|
178
|
+
vue?: boolean;
|
|
179
|
+
}
|
|
180
|
+
export interface Options extends GeneralOptions, TscOptions {
|
|
181
|
+
/**
|
|
182
|
+
* If `true`, the plugin will generate `.d.ts` files using Oxc,
|
|
183
|
+
* which is significantly faster than the TypeScript compiler.
|
|
184
|
+
*
|
|
185
|
+
* This option is automatically enabled when `isolatedDeclarations` in `compilerOptions` is set to `true`.
|
|
186
|
+
*/
|
|
187
|
+
oxc?: boolean | Omit<IsolatedDeclarationsOptions, "sourcemap">;
|
|
188
|
+
/**
|
|
189
|
+
* **[Experimental]** Enables DTS generation using `tsgo`.
|
|
190
|
+
*
|
|
191
|
+
* To use this option, make sure `@typescript/native-preview` is installed as a dependency.
|
|
192
|
+
*
|
|
193
|
+
* **Note:** This option is not yet recommended for production environments.
|
|
194
|
+
* `tsconfigRaw` and `isolatedDeclarations` options will be ignored when this option is enabled.
|
|
195
|
+
*
|
|
196
|
+
* Pass `true` to use the bundled tsgo binary, or an object with `path` to specify a custom binary path.
|
|
197
|
+
*/
|
|
198
|
+
tsgo?: boolean | {
|
|
199
|
+
path?: string;
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;
|
|
203
|
+
type MarkPartial<T, K extends keyof T> = Omit<Required<T>, K> & Partial<Pick<T, K>>;
|
|
204
|
+
export type OptionsResolved = Overwrite<MarkPartial<Omit<Options, "compilerOptions">, "banner" | "footer">, {
|
|
205
|
+
exclude: FilterPattern;
|
|
206
|
+
include: FilterPattern;
|
|
207
|
+
oxc: IsolatedDeclarationsOptions | false;
|
|
208
|
+
tsconfig?: string;
|
|
209
|
+
tsconfigRaw: TsConfigJson;
|
|
210
|
+
tsgo: {
|
|
211
|
+
path?: string;
|
|
212
|
+
} | false;
|
|
213
|
+
}>;
|
|
214
|
+
export declare const resolveOptions: ({ banner, build, cjsDefault, compilerOptions, cwd, dtsInput, eager, emitDtsOnly, emitJs, exclude, footer, include, incremental, newContext, oxc, parallel, resolve, resolver, sideEffects, sourcemap, tsconfig, tsconfigRaw: overriddenTsconfigRaw, tsgo: tsgoOption, tsMacro, vue, }: Options) => OptionsResolved;
|
|
215
|
+
export {};
|
|
@@ -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,
|
|
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-C7_nIfGu.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};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var Ee=Object.defineProperty;var _=(e,a)=>Ee(e,"name",{value:a,configurable:!0});import ne from"node:path";import{generate as ae}from"@babel/generator";import{isIdentifierName as Se}from"@babel/helper-validator-identifier";import{parse as se}from"@babel/parser";import f from"@babel/types";import{isTypeOf as $,isDeclarationType as be,walkAST as K,resolveString as H,isIdentifierOf as Z}from"ast-kit";import{RE_DTS as A,resolveTemplateFn as De,filename_js_to_dts as oe,replaceTemplateName as le,filename_dts_to as ce,RE_DTS_MAP as ve,filename_to_dts as Te}from"../filename.js";var Ie=Object.defineProperty,b=_((e,a)=>Ie(e,"name",{value:a,configurable:!0}),"c");const z="__rollup_dts_resolve__:",Qe=b(({cjsDefault:e,sideEffects:a,sourcemap:S})=>{let t=0;const w=new Map,j=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"||!A.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 v=ne.posix.relative(ne.posix.dirname(i.fileName),h);return v.startsWith(".")||(v=`./${v}`),v=ce(v,"js"),JSON.stringify(v)}));for(const i of Object.values(s))if(ve.test(i.fileName))if(S){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(A.test(y))return y;const C=oe(le(i,d.name));if(A.test(C))return C}return i},sourcemap:p.sourcemap||S}},renderChunk:P,async transform(p,s){if(A.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);j.set(s,x)}const h=[],v=new Map,n=new Map,r=new Set;for(const[x,o]of y.body.entries()){const k=b(c=>y.body[x]=c,"setStmt");if(Pe(o,k,C))continue;const M=o.type==="TSModuleDeclaration"&&o.kind!=="namespace";let g;if(M&&o.id.type==="StringLiteral"){const c=await this.resolve(o.id.value,s);c&&!c.external?g=A.test(c.id)?c.id:Te(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(M&&s.endsWith(".vue.d.ts")&&p.slice(o.start,o.end).includes("__VLS_"))continue;const U=o.type==="ExportDefaultDeclaration",W=$(o,["ExportNamedDeclaration","ExportDefaultDeclaration"])&&o.declaration,T=W?o.declaration:o,J=W?c=>o.declaration=c:k;if(T.type!=="TSDeclareFunction"&&!be(T))continue;$(T,["TSEnumDeclaration","ClassDeclaration","FunctionDeclaration","TSDeclareFunction","TSModuleDeclaration","VariableDeclaration"])&&(T.declare=!0);const I=[];if(T.type==="VariableDeclaration")I.push(...T.declarations.map(c=>c.id));else if("id"in T&&T.id){let c=T.id;c.type==="TSQualifiedName"&&(c=X(c)),c=M?f.identifier(`_${L(u,"")}`):c,I.push(c)}else{const c=f.identifier("export_default");I.push(c),T.id=c}const O=me(T),l=new Set,E=he(T,v,l,u),m=[...l].filter(c=>I.every(N=>c!==N));if(T!==o&&(T.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:T,deps:E,depsOffset:N.deps.length,params:O,paramsOffset:N.params.length}),N.deps.push(...E),N.params.push(...O),N.children.push(...m),r.add(x);continue}const D=q({bindings:I,children:m,decl:T,deps:E,params:O,resolvedModuleId:g});I.length===1&&n.set(I[0].name,D);const Q=f.numericLiteral(D),ee=f.arrowFunctionExpression(O.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=M&&f.callExpression(f.identifier("sideEffect"),[I[0]]),ge=we(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"))])),k(ie)):J(ie)}return a&&h.push(f.expressionStatement(f.callExpression(f.identifier("sideEffect"),[]))),y.body=[...Array.from(v.values(),({stmt:x})=>x),...y.body.filter((x,o)=>!r.has(o)),...h],V.set(s,C),ae(d,{comments:!1,sourceFileName:s,sourceMaps:S})}function P(p,s){if(!A.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=Oe(i.body),i.body=Ae(i.body),i.body=i.body.flatMap(n=>{if(ke(n))return[];if(n.type==="ExpressionStatement")return[];const r=Me(n,u,e);if(r===!1)return[];if(r)return[r];if(n.type!=="VariableDeclaration")return[n];if(!Ce(n))return[];const[x,o,k]=n.declarations[0].init.elements,M=x.value,g=Y(M);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,W=g.primaryParamsCount??g.params.length,T=g.primaryDepsCount??g.deps.length;for(let l=0;l<U;l++){const E=k.elements[l];Object.assign(g.children[l],{loc:E.loc})}const J=o.params;for(let l=0;l<W;l++){const E=J[l].name;for(const m of g.params[l].typeParams)m.name=E}const I=o.body.elements;for(let l=0;l<T;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 O=[];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=k.elements[l.childrenOffset+E];D&&Object.assign(m,{loc:D.loc})}for(const[E,m]of l.params.entries()){const D=J[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))}O.push(l.decl)}return[Re(n,g.decl),...O]}).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,v=new Set;for(const n of s.moduleIds){const r=j.get(n);r&&(r.forEach(x=>{const o=x.type+x.value;v.has(o)||(v.add(o),h.add(x))}),j.delete(n))}return h.size>0&&(i.body[0].leadingComments||=[],i.body[0].leadingComments.unshift(...h)),ae(d,{comments:!0,sourceFileName:s.fileName,sourceMaps:S})}function L(p,s){return s in p?p[s]++:p[s]=0}function q(p){const s=t++;return w.set(s,p),s}function Y(p){return w.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 v(r){return r.type==="Identifier"&&h.has(r.name)}return _(v,"b"),b(v,"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,k=r.qualifier,M=xe(r,k,o,s,d);n(M);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)||v(r)||i.add(r)}_(n,"P")}function xe(p,s,u,d,i){const y=u.value.replaceAll(/\W/g,"_"),C=`_$${Se(u.value)?u.value:`${y}${L(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 v=p;return p.typeParameters?(R(p,f.tsTypeReference(h,p.typeParameters)),v=h):R(p,h),{...F(h),replace(n){R(v,n)}}}},"createFakeJsPlugin");function de(e,a){return!!(e.type==="Identifier"||$(a,["TSPropertySignature","TSMethodSignature"])&&a.key===e)}_(de,"Ie");b(de,"isChildSymbol");const Ne=/\/\s*<reference\s+(?:path|types)=/,fe=b((e,a=!1)=>e.filter(S=>Ne.test(S.value)!==a),"collectReferenceDirectives"),Ce=b(e=>f.isVariableDeclaration(e)&&e.declarations.length>0&&f.isVariableDeclarator(e.declarations[0])&&_e(e.declarations[0].init),"isRuntimeBindingVariableDeclaration"),_e=b(e=>f.isArrayExpression(e)&&je(e.elements),"isRuntimeBindingArrayExpression"),we=b(e=>f.arrayExpression(e),"runtimeBindingArrayExpression"),je=b(e=>{const[a,S,t,w]=e;return a?.type==="NumericLiteral"&&S?.type==="ArrowFunctionExpression"&&t?.type==="ArrayExpression"&&(!w||w.type==="CallExpression")},"isRuntimeBindingArrayElements"),G=b(e=>Z(e,"infer"),"isInfer"),ue=b(e=>Z(e,"this")||e.type==="ThisExpression"||e.type==="MemberExpression"&&ue(e.object),"isThisExpression"),F=b(e=>{if(e.type==="Identifier")return e;const a=F(e.left);return Object.assign(e,f.memberExpression(a,e.right))},"TSEntityNameToRuntime"),X=b(e=>e.type==="Identifier"?e:X(e.left),"getIdFromTSEntityName"),pe=b(e=>$(e,["Identifier","MemberExpression"]),"isReferenceId"),ke=b(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"),Me=b((e,a,S)=>{if(e.type==="ExportNamedDeclaration"&&!e.declaration&&!e.source&&e.specifiers.length===0&&!e.attributes?.length)return!1;if(e.type==="ImportDeclaration"&&e.specifiers.length)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 w=H(t.exported);a.includes(w)&&(t.type==="ExportSpecifier"?t.exportKind="type":e.exportKind="type")}if(e.source?.value&&A.test(e.source.value))return e.source.value=ce(e.source.value,"js"),e;if(S&&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"),Oe=b(e=>{const a=new Set;for(const[t,w]of e.entries()){const j=S(w);if(!j)continue;const[V,B]=j;B.properties.length!==0&&(e[t]={body:{body:[{declaration:null,source:null,specifiers:B.properties.filter(P=>P.type==="ObjectProperty").map(P=>{const L=P.value.body,q=P.key;return f.exportSpecifier(L,q)}),type:"ExportNamedDeclaration"}],type:"TSModuleBlock"},declare:!0,id:V,kind:"namespace",type:"TSModuleDeclaration"})}return e.filter(t=>!a.has(t));function S(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 w=t.declarations[0].id,j=t.declarations[0].init.arguments[0];return[w,j]}},"patchTsNamespace"),Ae=b(e=>{const a=new Map;for(const[S,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 w=t.expression.arguments;a.set(w[0].name,w[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[S]={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"),Pe=b((e,a,S)=>{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")&&S.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=b((e,a)=>{for(const S of Object.keys(e))delete e[S];return Object.assign(e,a),e},"overwriteNode"),Re=b((e,a)=>{a.leadingComments||=[];const S=e.leadingComments?.filter(t=>t.value.startsWith("#"));return S&&a.leadingComments.unshift(...S),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"obug";import"oxc-transform";import"@rollup/pluginutils";import"../filename.js";import{c as g}from"./generate-C7_nIfGu.js";export{g as createGeneratePlugin};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
var ur=Object.defineProperty;var ne=(s,i)=>ur(s,"name",{value:i,configurable:!0});import{spawn as pr,fork as fr}from"node:child_process";import{existsSync as je,readFileSync as dr}from"node:fs";import{mkdtemp as gr,readFile as Ze,rm as mr}from"node:fs/promises";import z from"node:path";import{parse as Qe}from"@babel/parser";import{createDebug as Ae}from"obug";import{transformSync as hr,isolatedDeclarationSync as xr}from"oxc-transform";import{createFilter as yr}from"@rollup/pluginutils";import{RE_DTS as R,RE_NODE_MODULES as Ee,RE_JS as oe,filename_to_dts as Ue,RE_JSON as qe,RE_TS as Ge,RE_VUE as Me,resolveTemplateFn as $r,replaceTemplateName as _e,RE_DTS_MAP as Ve}from"../filename.js";import{createRequire as wr}from"node:module";import{tmpdir as vr}from"node:os";var br=Object.defineProperty,a=ne((s,i)=>br(s,"name",{value:i,configurable:!0}),"s");let Ke=a(()=>{var s=(()=>{var i=Object.defineProperty,l=Object.getOwnPropertyDescriptor,c=Object.getOwnPropertyNames,f=Object.prototype.hasOwnProperty,w=a((e,t)=>{for(var r in t)i(e,r,{get:t[r],enumerable:!0})},"ne"),_=a((e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of c(t))!f.call(e,n)&&n!==r&&i(e,n,{get:a(()=>t[n],"get"),enumerable:!(o=l(t,n))||o.enumerable});return e},"ae"),j=a(e=>_(i({},"__esModule",{value:!0}),e),"oe"),C={};w(C,{zeptomatch:a(()=>Le,"zeptomatch")});var U=a(e=>{const t=new Set,r=[e];for(let o=0;o<r.length;o++){const n=r[o];if(t.has(n))continue;t.add(n);const{children:u}=n;if(u?.length)for(let g=0,y=u.length;g<y;g++)r.push(u[g])}return Array.from(t)},"M"),le=a(e=>{let t="";const r=U(e);for(let o=0,n=r.length;o<n;o++){const u=r[o];if(!u.regex)continue;const g=u.regex.flags;if(t||(t=g),t!==g)throw new Error(`Inconsistent RegExp flags used: "${t}" and "${g}"`)}return t},"se"),q=a((e,t,r)=>{const o=r.get(e);if(o!==void 0)return o;const n=e.partial??t;let u="";if(e.regex&&(u+=n?"(?:$|":"",u+=e.regex.source),e.children?.length){const g=me(e.children.map(y=>q(y,t,r)).filter(Boolean));if(g?.length){const y=e.children.some(te=>!te.regex||!(te.partial??t)),b=g.length>1||n&&(!u.length||y);u+=b?n?"(?:$|":"(?:":"",u+=g.join("|"),u+=b?")":""}}return e.regex&&(u+=n?")":""),r.set(e,u),u},"O"),G=a((e,t)=>{const r=new Map,o=U(e);for(let n=o.length-1;n>=0;n--){const u=q(o[n],t,r);if(!(n>0))return u}return""},"ie"),me=a(e=>Array.from(new Set(e)),"ue"),N=a((e,t,r)=>N.compile(e,r).test(t),"R");N.compile=(e,t)=>{const r=t?.partial??!1,o=G(e,r),n=le(e);return new RegExp(`^(?:${o})$`,n)};var he=N,xe=a((e,t)=>{const r=he.compile(e,t),o=`${r.source.slice(0,-1)}[\\\\/]?$`,n=r.flags;return new RegExp(o,n)},"le"),ce=xe,k=a(e=>{const t=e.map(o=>o.source).join("|")||"$^",r=e[0]?.flags;return new RegExp(t,r)},"ve"),ue=k,W=a(e=>Array.isArray(e),"j"),P=a(e=>typeof e=="function","_"),X=a(e=>e.length===0,"he"),V=(()=>{const{toString:e}=Function.prototype,t=/(?:^\(\s*(?:[^,.()]|\.(?!\.\.))*\s*\)\s*=>|^\s*[a-zA-Z$_][a-zA-Z0-9$_]*\s*=>)/;return r=>(r.length===0||r.length===1)&&t.test(e.call(r))})(),B=a(e=>typeof e=="number","de"),pe=a(e=>typeof e=="object"&&e!==null,"xe"),x=a(e=>e instanceof RegExp,"me"),m=(()=>{const e=/\\\(|\((?!\?(?::|=|!|<=|<!))/;return t=>e.test(t.source)})(),h=(()=>{const e=/^[a-zA-Z0-9_-]+$/;return t=>e.test(t.source)&&!t.flags.includes("i")})(),d=a(e=>typeof e=="string","A"),$=a(e=>e===void 0,"f"),E=a(e=>{const t=new Map;return r=>{const o=t.get(r);if(o!==void 0)return o;const n=e(r);return t.set(r,n),n}},"ye"),M=a((e,t,r={})=>{const o={cache:{},input:e,index:0,indexBacktrackMax:0,options:r,output:[]},n=D(t)(o),u=Math.max(o.index,o.indexBacktrackMax);if(n&&o.index===e.length)return o.output;throw new Error(`Failed to parse at index ${u}`)},"I"),p=a((e,t)=>W(e)?S(e,t):d(e)?Y(e,t):T(e,t),"i"),S=a((e,t)=>{const r={};for(const o of e){if(o.length!==1)throw new Error(`Invalid character: "${o}"`);const n=o.charCodeAt(0);r[n]=!0}return o=>{const n=o.input;let u=o.index,g=u;for(;g<n.length&&n.charCodeAt(g)in r;)g+=1;if(g>u){if(!$(t)&&!o.options.silent){const y=n.slice(u,g),b=P(t)?t(y,n,`${u}`):t;$(b)||o.output.push(b)}o.index=g}return!0}},"we"),T=a((e,t)=>{if(h(e))return Y(e.source,t);{const r=e.source,o=e.flags.replace(/y|$/,"y"),n=new RegExp(r,o);return m(e)&&P(t)&&!V(t)?J(n,t):fe(n,t)}},"$e"),J=a((e,t)=>r=>{const o=r.index,n=r.input;e.lastIndex=o;const u=e.exec(n);if(u){const g=e.lastIndex;if(!r.options.silent){const y=t(...u,n,`${o}`);$(y)||r.output.push(y)}return r.index=g,!0}else return!1},"Ee"),fe=a((e,t)=>r=>{const o=r.index,n=r.input;if(e.lastIndex=o,e.test(n)){const u=e.lastIndex;if(!$(t)&&!r.options.silent){const g=P(t)?t(n.slice(o,u),n,`${o}`):t;$(g)||r.output.push(g)}return r.index=u,!0}else return!1},"Ce"),Y=a((e,t)=>r=>{const o=r.index,n=r.input;if(n.startsWith(e,o)){if(!$(t)&&!r.options.silent){const u=P(t)?t(e,n,`${o}`):t;$(u)||r.output.push(u)}return r.index+=e.length,!0}else return!1},"F"),ye=a((e,t,r,o)=>{const n=D(e),u=t>1;return we($e(Re(g=>{let y=0;for(;y<r;){const b=g.index;if(!n(g)||(y+=1,g.index===b))break}return y>=t},u),o))},"k"),Se=a((e,t)=>ye(e,0,1,t),"L"),de=a((e,t)=>ye(e,0,1/0,t),"$"),nt=a((e,t)=>ye(e,1,1/0,t),"Re"),K=a((e,t)=>{const r=e.map(D);return we($e(Re(o=>{for(let n=0,u=r.length;n<u;n++)if(!r[n](o))return!1;return!0}),t))},"x"),A=a((e,t)=>{const r=e.map(D);return we($e(o=>{for(let n=0,u=r.length;n<u;n++)if(r[n](o))return!0;return!1},t))},"p"),Re=a((e,t=!0,r=!1)=>{const o=D(e);return t?n=>{const u=n.index,g=n.output.length,y=o(n);return!y&&!r&&(n.indexBacktrackMax=Math.max(n.indexBacktrackMax,n.index)),(!y||r)&&(n.index=u,n.output.length!==g&&(n.output.length=g)),y}:o},"q"),$e=a((e,t)=>{const r=D(e);return t?o=>{if(o.options.silent)return r(o);const n=o.output.length;if(r(o)){const u=o.output.splice(n,1/0),g=t(u);return $(g)||o.output.push(g),!0}else return!1}:r},"B"),we=(()=>{let e=0;return t=>{const r=D(t),o=e+=1;return n=>{var u;if(n.options.memoization===!1)return r(n);const g=n.index,y=(u=n.cache)[o]||(u[o]={indexMax:-1,queue:[]}),b=y.queue;if(g<=y.indexMax){const re=y.store||(y.store=new Map);if(b.length){for(let Q=0,ar=b.length;Q<ar;Q+=2){const lr=b[Q*2],cr=b[Q*2+1];re.set(lr,cr)}b.length=0}const O=re.get(g);if(O===!1)return!1;if(B(O))return n.index=O,!0;if(O)return n.index=O.index,O.output?.length&&n.output.push(...O.output),!0}const te=n.output.length,ir=r(n);if(y.indexMax=Math.max(y.indexMax,g),ir){const re=n.index,O=n.output.length;if(O>te){const Q=n.output.slice(te,O);b.push(g,{index:re,output:Q})}else b.push(g,re);return!0}else return b.push(g,!1),!1}}})(),Ie=a(e=>{let t;return r=>(t||(t=D(e())),t(r))},"G"),D=E(e=>{if(P(e))return X(e)?Ie(e):e;if(d(e)||x(e))return p(e);if(W(e))return K(e);if(pe(e))return A(Object.values(e));throw new Error("Invalid rule")}),L=a(e=>e,"d"),ot=a(e=>typeof e=="string","ke"),st=a(e=>{const t=new WeakMap,r=new WeakMap;return(o,n)=>{const u=n?.partial?r:t,g=u.get(o);if(g!==void 0)return g;const y=e(o,n);return u.set(o,y),y}},"Be"),it=a(e=>{const t={},r={};return(o,n)=>{const u=n?.partial?r:t;return u[o]??(u[o]=e(o,n))}},"Pe"),at=p(/\\./,L),lt=p(/./,L),ct=p(/\*\*\*+/,"*"),ut=p(/([^/{[(!])\*\*/,(e,t)=>`${t}*`),pt=p(/(^|.)\*\*(?=[^*/)\]}])/,(e,t)=>`${t}*`),ft=de(A([at,ct,ut,pt,lt])),dt=ft,gt=a(e=>M(e,dt,{memoization:!1}).join(""),"Ie"),mt=gt,ze="abcdefghijklmnopqrstuvwxyz",ht=a(e=>{let t="";for(;e>0;){const r=(e-1)%26;t=ze[r]+t,e=Math.floor((e-1)/26)}return t},"Le"),Ce=a(e=>{let t=0;for(let r=0,o=e.length;r<o;r++)t=t*26+ze.indexOf(e[r])+1;return t},"V"),ve=a((e,t)=>{if(t<e)return ve(t,e);const r=[];for(;e<=t;)r.push(e++);return r},"b"),xt=a((e,t,r)=>ve(e,t).map(o=>String(o).padStart(r,"0")),"qe"),Pe=a((e,t)=>ve(Ce(e),Ce(t)).map(ht),"W"),v=a(e=>({partial:!1,regex:new RegExp(e,"s"),children:[]}),"c"),ee=a(e=>({children:e}),"y"),H=(()=>{const e=a((t,r,o)=>{if(o.has(t))return;o.add(t);const{children:n}=t;if(!n.length)n.push(r);else for(let u=0,g=n.length;u<g;u++)e(n[u],r,o)},"e");return t=>{if(!t.length)return ee([]);for(let r=t.length-1;r>=1;r--){const o=new Set,n=t[r-1],u=t[r];e(n,u,o)}return t[0]}})(),F=a(()=>({regex:new RegExp("[\\\\/]","s"),children:[]}),"g"),yt=p(/\\./,v),$t=p(/[$.*+?^(){}[\]\|]/,e=>v(`\\${e}`)),wt=p(/[\\\/]/,F),vt=p(/[^$.*+?^(){}[\]\|\\\/]+/,v),bt=p(/^(?:!!)*!(.*)$/,(e,t)=>v(`(?!^${Le.compile(t).source}$).*?`)),jt=p(/^(!!)+/),Et=A([bt,jt]),Mt=p(/\/(\*\*\/)+/,()=>ee([H([F(),v(".+?"),F()]),F()])),_t=p(/^(\*\*\/)+/,()=>ee([v("^"),H([v(".*?"),F()])])),kt=p(/\/(\*\*)$/,()=>ee([H([F(),v(".*?")]),v("$")])),At=p(/\*\*/,()=>v(".*?")),De=A([Mt,_t,kt,At]),Ot=p(/\*\/(?!\*\*\/|\*$)/,()=>H([v("[^\\\\/]*?"),F()])),St=p(/\*/,()=>v("[^\\\\/]*")),Fe=A([Ot,St]),Ne=p("?",()=>v("[^\\\\/]")),Rt=p("[",L),It=p("]",L),zt=p(/[!^]/,"^\\\\/"),Ct=p(/[a-z]-[a-z]|[0-9]-[0-9]/i,L),Pt=p(/\\./,L),Dt=p(/[$.*+?^(){}[\|]/,e=>`\\${e}`),Ft=p(/[\\\/]/,"\\\\/"),Nt=p(/[^$.*+?^(){}[\]\|\\\/]+/,L),Wt=A([Pt,Dt,Ft,Ct,Nt]),We=K([Rt,Se(zt),de(Wt),It],e=>v(e.join(""))),Bt=p("{","(?:"),Tt=p("}",")"),Jt=p(/(\d+)\.\.(\d+)/,(e,t,r)=>xt(+t,+r,Math.min(t.length,r.length)).join("|")),Lt=p(/([a-z]+)\.\.([a-z]+)/,(e,t,r)=>Pe(t,r).join("|")),Zt=p(/([A-Z]+)\.\.([A-Z]+)/,(e,t,r)=>Pe(t.toLowerCase(),r.toLowerCase()).join("|").toUpperCase()),Ut=A([Jt,Lt,Zt]),Be=K([Bt,Ut,Tt],e=>v(e.join(""))),qt=p("{"),Gt=p("}"),Vt=p(","),Kt=p(/\\./,v),Ht=p(/[$.*+?^(){[\]\|]/,e=>v(`\\${e}`)),Qt=p(/[\\\/]/,F),Xt=p(/[^$.*+?^(){}[\]\|\\\/,]+/,v),Yt=Ie(()=>Je),er=p("",()=>v("(?:)")),tr=nt(A([De,Fe,Ne,We,Be,Yt,Kt,Ht,Qt,Xt]),H),Te=A([tr,er]),Je=K([qt,Se(K([Te,de(K([Vt,Te]))])),Gt],ee),rr=de(A([Et,De,Fe,Ne,We,Be,Je,yt,$t,wt,vt]),H),nr=rr,or=a(e=>M(e,nr,{memoization:!1})[0],"kr"),sr=or,be=a((e,t,r)=>be.compile(e,r).test(t),"N");be.compile=(()=>{const e=it((r,o)=>ce(sr(mt(r)),o)),t=st((r,o)=>ue(r.map(n=>e(n,o))));return(r,o)=>ot(r)?e(r,o):t(r,o)})();var Le=be;return j(C)})();return s.default||s},"_lazyMatch"),ke;const jr=a((s,i)=>(ke||(ke=Ke(),Ke=null),ke(s,i)),"zeptomatch"),Er=/^[A-Z]:\//i,Z=a((s="")=>s&&s.replaceAll("\\","/").replace(Er,i=>i.toUpperCase()),"normalizeWindowsPath"),Mr=/^[/\\]{2}/,_r=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,Xe=/^[A-Z]:$/i,He=/^\/([A-Z]:)?$/i,kr=/.(\.[^./]+)$/,Ar=/^[/\\]|^[a-z]:[/\\]/i,Or=/\/$/,Sr=a(()=>typeof process.cwd=="function"?process.cwd().replaceAll("\\","/"):"/","cwd"),Ye=a((s,i)=>{let l="",c=0,f=-1,w=0,_;for(let j=0;j<=s.length;++j){if(j<s.length)_=s[j];else{if(_==="/")break;_="/"}if(_==="/"){if(!(f===j-1||w===1))if(w===2){if(l.length<2||c!==2||!l.endsWith(".")||l.at(-2)!=="."){if(l.length>2){const C=l.lastIndexOf("/");C===-1?(l="",c=0):(l=l.slice(0,C),c=l.length-1-l.lastIndexOf("/")),f=j,w=0;continue}else if(l.length>0){l="",c=0,f=j,w=0;continue}}i&&(l+=l.length>0?"/..":"..",c=2)}else l.length>0?l+=`/${s.slice(f+1,j)}`:l=s.slice(f+1,j),c=j-f-1;f=j,w=0}else _==="."&&w!==-1?++w:w=-1}return l},"normalizeString"),ae=a(s=>_r.test(s),"isAbsolute"),et=a(function(s){if(s.length===0)return".";s=Z(s);const i=Mr.exec(s),l=ae(s),c=s.at(-1)==="/";return s=Ye(s,!l),s.length===0?l?"/":c?"./":".":(c&&(s+="/"),Xe.test(s)&&(s+="/"),i?l?`//${s}`:`//./${s}`:l&&!ae(s)?`/${s}`:s)},"normalize");a((...s)=>{let i="";for(const l of s)if(l)if(i.length>0){const c=i.at(-1)==="/",f=l[0]==="/";c&&f?i+=l.slice(1):i+=c||f?l:`/${l}`}else i+=l;return et(i)},"join");const ge=a(function(...s){s=s.map(c=>Z(c));let i="",l=!1;for(let c=s.length-1;c>=-1&&!l;c--){const f=c>=0?s[c]:Sr();!f||f.length===0||(i=`${f}/${i}`,l=ae(f))}return i=Ye(i,!l),l&&!ae(i)?`/${i}`:i.length>0?i:"."},"resolve");a(function(s){return Z(s)},"toNamespacedPath");const Rr=a(function(s){return kr.exec(Z(s))?.[1]??""},"extname");a(function(s,i){const l=ge(s).replace(He,"$1").split("/"),c=ge(i).replace(He,"$1").split("/");if(c[0][1]===":"&&l[0][1]===":"&&l[0]!==c[0])return c.join("/");const f=[...l];for(const w of f){if(c[0]!==w)break;l.shift(),c.shift()}return[...l.map(()=>".."),...c].join("/")},"relative");const Ir=a(s=>{const i=Z(s).replace(Or,"").split("/").slice(0,-1);return i.length===1&&Xe.test(i[0])&&(i[0]=`${i[0]}/`),i.join("/")||(ae(s)?"/":".")},"dirname");a(function(s){const i=[s.root,s.dir,s.base??s.name+s.ext].filter(Boolean);return Z(s.root?ge(...i):i.join("/"))},"format");const zr=a((s,i)=>{const l=Z(s).split("/").pop();return i&&l.endsWith(i)?l.slice(0,-i.length):l},"basename");a(function(s){const i=Ar.exec(s)?.[0]?.replaceAll("\\","/")??"",l=zr(s),c=Rr(l);return{base:l,dir:Ir(s),ext:c,name:l.slice(0,l.length-c.length),root:i}},"parse");a((s,i)=>jr(i,et(s)),"matchesGlob");var Cr=Object.defineProperty,tt=ne((s,i)=>Cr(s,"name",{value:i,configurable:!0}),"r");const Pr=Ae("rollup-plugin-dts:tsc-context"),rt=tt(()=>({files:new Map,programs:[],projects:new Map}),"createContext"),Dr=tt((s,i)=>{i=ge(i).replaceAll("\\","/"),Pr(`invalidating context file: ${i}`),s.files.delete(i),s.programs=s.programs.filter(l=>!l.getSourceFiles().some(c=>c.fileName===i)),s.projects.clear()},"invalidateContextFile"),Fr=rt();var Nr=Object.defineProperty,Oe=ne((s,i)=>Nr(s,"name",{value:i,configurable:!0}),"i");const se=Ae("rollup-plugin-dts:tsgo"),Wr=Oe((...s)=>new Promise((i,l)=>{const c=pr(...s);c.on("close",()=>i()),c.on("error",f=>l(f))}),"spawnAsync"),Br=Oe(()=>{const s=wr(import.meta.url),i=s.resolve("@typescript/native-preview/package.json"),l=z.dirname(i),c=s(z.join(l,"lib","getExePath.js"));return(typeof c=="function"?c:c.default)()},"getTsgoPathFromNodeModules"),Tr=Oe(async(s,i,l,c)=>{se("[tsgo] rootDir",s);let f;c?(f=c,se("[tsgo] using custom path",f)):(f=Br(),se("[tsgo] using tsgo from node_modules",f));const w=await gr(z.join(vr(),"rollup-plugin-dts-"));se("[tsgo] tsgoDist",w);const _=["--noEmit","false","--declaration","--emitDeclarationOnly",...i?["-p",i]:[],"--outDir",w,"--rootDir",s,"--noCheck",...l?["--declarationMap"]:[]];return se("[tsgo] args %o",_),await Wr(f,_,{stdio:"inherit"}),w},"runTsgo");var Jr=Object.defineProperty,ie=ne((s,i)=>Jr(s,"name",{value:i,configurable:!0}),"y");const I=Ae("rollup-plugin-dts:generate"),Lr=import.meta.WORKER_URL??"./tsc/worker.js",on=ie(({build:s,cwd:i,eager:l,emitDtsOnly:c,emitJs:f,exclude:w,include:_,incremental:j,newContext:C,oxc:U,parallel:le,sourcemap:q,tsconfig:G,tsconfigRaw:me,tsgo:N,tsMacro:he,vue:xe})=>{const ce=_||w?yr(_,w):null,k=new Map,ue=new Map;let W,P,X,V,B;const pe=G?z.dirname(G):i;return{async buildEnd(){W?.kill(),!I.enabled&&B&&await mr(B,{force:!0,recursive:!0}).catch(()=>{}),B=void 0,C&&(V=void 0)},async buildStart(x){if(N?B=await Tr(pe,G,q,N.path):U||(le?(W=fr(new URL(Lr,import.meta.url),{stdio:"inherit"}),P=(await import("birpc")).createBirpc({},{on:ie(m=>W.on("message",m),"on"),post:ie(m=>W.send(m),"post")})):(X=await import("../packem_chunks/index.js"),C&&(V=rt()))),!Array.isArray(x.input))for(const[m,h]of Object.entries(x.input)){I("resolving input alias %s -> %s",m,h);let d=await this.resolve(h);h.startsWith("./")||(d||=await this.resolve(`./${h}`));const $=d?.id||h;I("resolved input alias %s -> %s",h,$),ue.set($,m)}},generateBundle(x,m){for(const h of Object.keys(m)){const d=m[h];if(d){if(d.type==="asset"&&Ve.test(h)&&typeof d.source=="string"){const $=JSON.parse(d.source);$.names=[],delete $.sourcesContent,d.source=JSON.stringify($)}c&&d.type==="chunk"&&!R.test(h)&&!Ve.test(h)&&delete m[h]}}},load:{filter:{id:{exclude:[Ee],include:[R]}},async handler(x){if(!k.has(x))return;const{code:m,id:h}=k.get(x);let d,$;if(I("generate dts %s from %s",x,h),N){if(Me.test(h))throw new Error("tsgo does not support Vue files.");const E=z.resolve(B,z.relative(pe,Ue(h)));if(je(E)){if(d=await Ze(E,"utf8"),q){const M=`${E}.map`;je(M)&&($=JSON.parse(await Ze(M,"utf8")))}}else throw I("[tsgo]",E,"is missing"),new Error(`tsgo did not generate dts file for ${h}, please check your tsconfig.`)}else if(U&&!Me.test(h)){const E=xr(h,m,U);if(E.errors.length>0){const[M]=E.errors;return this.error({frame:M?.codeframe||void 0,message:M?.codeframe?`${M.message}
|
|
2
|
+
${M.codeframe}`:M?.message??"Unknown error"})}d=E.code,E.map&&($=E.map,$.sourcesContent=void 0,$.names=[])}else{const E=l?void 0:[...k.values()].filter(S=>S.isEntry).map(S=>S.id),M={build:s,context:V,cwd:i,entries:E,id:h,incremental:j,sourcemap:q,tsconfig:G,tsconfigRaw:me,tsMacro:he,vue:xe};let p;if(p=le?await P.tscEmit(M):X.tscEmit(M),p.error)return this.error(p.error);if(d=p.code,$=p.map,d&&qe.test(h))if(d.includes("declare const _exports")){if(d.includes("declare const _exports: {")&&!d.includes(`
|
|
3
|
+
}[];`)){const S=Ur(d);let T=0;d+=S.map(J=>{const fe=`_${J.replaceAll(/[^\w$]/g,"_")}${T++}`,Y=JSON.stringify(J);return`declare let ${fe}: typeof _exports[${Y}]
|
|
4
|
+
export { ${fe} as ${Y} }`}).join(`
|
|
5
|
+
`)}}else{const S=Zr(d);d+=`
|
|
6
|
+
declare namespace __json_default_export {
|
|
7
|
+
export { ${Array.from(S.entries(),([T,J])=>T===J?T:`${J} as ${T}`).join(", ")} }
|
|
8
|
+
}
|
|
9
|
+
export { __json_default_export as default }`}}return{code:d||"",map:$}}},name:"rollup-plugin-dts:generate",outputOptions(x){return{...x,entryFileNames(m){const{entryFileNames:h}=x,d=$r(h||"[name].js",m);if(m.name.endsWith(".d")){if(R.test(d))return _e(d,m.name.slice(0,-2));if(oe.test(d))return d.replace(oe,".$1ts")}else if(c){if(m.facadeModuleId&&R.test(m.facadeModuleId)){if(R.test(d))return _e(d,m.name);if(oe.test(d))return d.replace(oe,".$1ts")}return _e("[name].js",m.name)}return d}}},async resolveId(x,m){if(k.has(x))return I("resolve dts id %s",x),{id:x};if(!m&&R.test(x)&&!Ee.test(x)){const h=z.isAbsolute(x)?x:z.resolve(i,x),d=h.replace(R,".$1ts");if(!k.has(h)&&je(d)){const $=dr(d,"utf8");k.set(h,{code:$,id:d,isEntry:!0}),I("populated dtsMap from source for cached re-resolution: %s",h)}return k.has(h)?(I("resolve dts id %s (from cache re-resolution)",h),{id:h}):null}if(m&&Ge.test(m)&&(x.startsWith("./")||x.startsWith("../"))&&!z.extname(x))for(const h of[".ts",".tsx",".mts",".cts"]){const d=await this.resolve(x+h,m,{skipSelf:!0});if(d)return d}return null},shouldTransformCachedModule({id:x}){return R.test(x)},transform:{handler(x,m){if(!(R.test(m)||Ee.test(m)||ce&&!ce(m))){if(!oe.test(m)||f){const h=!!this.getModuleInfo(m)?.isEntry,d=Ue(m);if(k.set(d,{code:x,id:m,isEntry:h}),I("register dts source: %s",m),h){const $=ue.get(m);this.emitFile({id:d,name:$?`${$}.d`:void 0,type:"chunk"})}}return c?qe.test(m)?"{}":"export { }":Ge.test(m)||Me.test(m)?hr(m,x,{}).code:null}},order:"pre"},watchChange(x){X&&Dr(V||Fr,x)}}},"createGeneratePlugin"),Zr=ie(s=>{const i=new Map,{program:l}=Qe(s,{errorRecovery:!0,plugins:[["typescript",{dts:!0}]],sourceType:"module"});for(const c of l.body)if(c.type==="ExportNamedDeclaration"){if(c.declaration)if(c.declaration.type==="VariableDeclaration")for(const f of c.declaration.declarations)f.id.type==="Identifier"&&i.set(f.id.name,f.id.name);else c.declaration.type==="TSModuleDeclaration"&&c.declaration.id.type==="Identifier"&&i.set(c.declaration.id.name,c.declaration.id.name);else if(c.specifiers.length>0)for(const f of c.specifiers)f.type==="ExportSpecifier"&&f.exported.type==="Identifier"&&i.set(f.exported.name,f.local.type==="Identifier"?f.local.name:f.exported.name)}return i},"collectJsonExportMap"),Ur=ie(s=>{const i=[],{program:l}=Qe(s,{plugins:[["typescript",{dts:!0}]],sourceType:"module"}),c=l.body[0].declarations[0].id.typeAnnotation.typeAnnotation.members;for(const f of c)f.key.type==="Identifier"?i.push(f.key.name):f.key.type==="StringLiteral"&&i.push(f.key.value);return i},"collectJsonExports");export{Ir as V,on as c,Fr as g};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var A=Object.defineProperty;var b=(i,n)=>A(i,"name",{value:n,configurable:!0});import{existsSync as W}from"node:fs";import{createRequire as $}from"node:module";import d from"node:path";import T from"node:process";import{findTsConfigSync as q,readTsConfig as z}from"@visulima/tsconfig";import O from"typescript";var G=Object.defineProperty,I=b((i,n)=>G(i,"name",{value:n,configurable:!0}),"w");let E=!1;const M=I((i,n=new Set)=>{if(n.has(i))return!1;n.add(i);const a=O.readConfigFile(i,o=>W(o)?O.sys.readFile(o):void 0);if(a.error||!a.config)return!1;const e=a.config,s=e.compilerOptions;if(s){if(s.incremental===!1)return!1;if(s.incremental===!0||typeof s.tsBuildInfoFile=="string")return!0}if(!e.extends)return!1;const h=Array.isArray(e.extends)?e.extends:[e.extends],c=d.dirname(i);for(const o of h){if(typeof o!="string")continue;let l;if(o.startsWith("."))l=d.resolve(c,o.endsWith(".json")?o:`${o}.json`);else try{l=$(d.join(c,"package.json")).resolve(o)}catch{l=void 0}if(l&&M(l,n))return!0}return!1},"hasExplicitIncrementalInTsconfig"),X=I(({banner:i,build:n=!1,cjsDefault:a=!1,compilerOptions:e={},cwd:s=T.cwd(),dtsInput:h=!1,eager:c=!1,emitDtsOnly:o=!1,emitJs:l,exclude:j=null,footer:P,include:C=null,incremental:v=!1,newContext:D=!1,oxc:r,parallel:F=!1,resolve:J=!1,resolver:R="oxc",sideEffects:B=!1,sourcemap:g,tsconfig:t,tsconfigRaw:S={},tsgo:w=!1,tsMacro:p=!1,vue:u=!1})=>{let m;if(t===!0||t==null)try{const y=q(s);t=y.path,m=y.config}catch{t=void 0}else typeof t=="string"?(t=d.resolve(s||T.cwd(),t),m=z(t)):t=void 0;const x=e;e={...m?.compilerOptions,...e},v||=x.incremental===!0||typeof x.tsBuildInfoFile=="string"||typeof t=="string"&&M(t),g??=!!e.declarationMap,e.declarationMap=g;const k={...m,...S,compilerOptions:e};let f=!1;if(w&&(f=w===!0?{}:w),r??=!!(e?.isolatedDeclarations&&!u&&!f&&!p),r===!0&&(r={}),r&&(r.stripInternal??=!!e?.stripInternal,r.sourcemap=!!e.declarationMap),l??=!!(e.checkJs||e.allowJs),f){if(u)throw new Error("[@visulima/rollup-plugin-dts] The `tsgo` option is not compatible with the `vue` option. Please disable one of them.");if(p)throw new Error("[@visulima/rollup-plugin-dts] The `tsgo` option is not compatible with the `tsMacro` option. Please disable one of them.");if(r)throw new Error("[@visulima/rollup-plugin-dts] The `tsgo` option is not compatible with the `oxc` option. Please disable one of them.")}if(r&&u)throw new Error("[@visulima/rollup-plugin-dts] The `oxc` option is not compatible with the `vue` option. Please disable one of them.");if(r&&p)throw new Error("[@visulima/rollup-plugin-dts] The `oxc` option is not compatible with the `tsMacro` option. Please disable one of them.");return f&&!E&&(console.warn("The `tsgo` option is experimental and may change in the future."),E=!0),{banner:i,build:n,cjsDefault:a,cwd:s,dtsInput:h,eager:c,emitDtsOnly:o,emitJs:l,exclude:j,footer:P,include:C,incremental:v,newContext:D,oxc:r,parallel:F,resolve:J,resolver:R,sideEffects:B,sourcemap:g,tsconfig:t,tsconfigRaw:k,tsgo:f,tsMacro:p,vue:u}},"resolveOptions");export{X as resolveOptions};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Plugin } from "rollup";
|
|
2
|
+
import type { OptionsResolved } from "./options.d.ts";
|
|
3
|
+
declare const createDtsResolvePlugin: ({ cwd, resolve, resolver, sideEffects, tsconfig, tsconfigRaw, }: Pick<OptionsResolved, "cwd" | "tsconfig" | "tsconfigRaw" | "resolve" | "resolver" | "sideEffects">) => Plugin;
|
|
4
|
+
export default createDtsResolvePlugin;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type ts from "typescript";
|
|
2
|
+
export interface ParsedProject {
|
|
3
|
+
parsedConfig: ts.ParsedCommandLine;
|
|
4
|
+
tsconfigPath: string;
|
|
5
|
+
}
|
|
6
|
+
export type SourceFileToProjectMap = Map<string, ParsedProject>;
|
|
7
|
+
export interface TscContext {
|
|
8
|
+
files: Map<string, string>;
|
|
9
|
+
programs: ts.Program[];
|
|
10
|
+
projects: Map<string, SourceFileToProjectMap>;
|
|
11
|
+
}
|
|
12
|
+
export declare const createContext: () => TscContext;
|
|
13
|
+
export declare const invalidateContextFile: (context: TscContext, file: string) => void;
|
|
14
|
+
export declare const globalContext: TscContext;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
/**
|
|
3
|
+
* A system that writes files to both memory and disk. It will try read files
|
|
4
|
+
* from memory firstly and fallback to disk if not found.
|
|
5
|
+
*/
|
|
6
|
+
export declare const createFsSystem: (files: Map<string, string>) => ts.System;
|
|
7
|
+
export declare const createMemorySystem: (files: Map<string, string>) => ts.System;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { TsConfigJson } from "@visulima/tsconfig";
|
|
2
|
+
import type { SourceMapInput } from "rollup";
|
|
3
|
+
import type ts from "typescript";
|
|
4
|
+
import type { TscContext } from "./context.d.ts";
|
|
5
|
+
export interface TscModule {
|
|
6
|
+
file: ts.SourceFile;
|
|
7
|
+
program: ts.Program;
|
|
8
|
+
}
|
|
9
|
+
export interface TscOptions {
|
|
10
|
+
build: boolean;
|
|
11
|
+
context?: TscContext;
|
|
12
|
+
cwd: string;
|
|
13
|
+
entries?: string[];
|
|
14
|
+
id: string;
|
|
15
|
+
incremental: boolean;
|
|
16
|
+
sourcemap: boolean;
|
|
17
|
+
tsconfig?: string;
|
|
18
|
+
tsconfigRaw: TsConfigJson;
|
|
19
|
+
tsMacro?: boolean;
|
|
20
|
+
vue?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface TscResult {
|
|
23
|
+
code?: string;
|
|
24
|
+
error?: string;
|
|
25
|
+
map?: SourceMapInput;
|
|
26
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ExistingRawSourceMap } from "rollup";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
export declare const formatHost: ts.FormatDiagnosticsHost;
|
|
4
|
+
export declare const customTransformers: ts.CustomTransformers;
|
|
5
|
+
export declare const setSourceMapRoot: (map: ExistingRawSourceMap | undefined, originalFilePath: string, finalFilePath: string) => void;
|
package/dist/tsgo.d.ts
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/rollup-plugin-dts",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.21",
|
|
4
4
|
"description": "A Rollup plugin to bundle dts files",
|
|
5
5
|
"homepage": "https://github.com/visulima/packem/tree/main/packages/rollup-plugin-dts",
|
|
6
6
|
"bugs": {
|
|
@@ -54,22 +54,23 @@
|
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@babel/generator": "7.29.1",
|
|
56
56
|
"@babel/helper-validator-identifier": "7.28.5",
|
|
57
|
-
"@babel/parser": "7.29.
|
|
57
|
+
"@babel/parser": "7.29.2",
|
|
58
58
|
"@babel/types": "7.29.0",
|
|
59
|
-
"@
|
|
59
|
+
"@rollup/pluginutils": "5.3.0",
|
|
60
|
+
"@visulima/tsconfig": "3.0.0-alpha.11",
|
|
60
61
|
"ast-kit": "^2.2.0",
|
|
61
62
|
"birpc": "^4.0.0",
|
|
62
63
|
"magic-string": "0.30.21",
|
|
63
64
|
"obug": "2.1.1",
|
|
64
65
|
"oxc-resolver": "11.19.1",
|
|
65
|
-
"oxc-transform": "0.
|
|
66
|
+
"oxc-transform": "0.126.0"
|
|
66
67
|
},
|
|
67
68
|
"peerDependencies": {
|
|
68
69
|
"@ts-macro/tsc": "0.3.7",
|
|
69
70
|
"@typescript/native-preview": ">=7.0.0-dev.20250601.1",
|
|
70
71
|
"rollup": ">=4.0.0",
|
|
71
|
-
"typescript": "^5.
|
|
72
|
-
"vue-tsc": "3.2.
|
|
72
|
+
"typescript": "^5.0.0 || ^6.0.0",
|
|
73
|
+
"vue-tsc": "3.2.6"
|
|
73
74
|
},
|
|
74
75
|
"peerDependenciesMeta": {
|
|
75
76
|
"@typescript/native-preview": {
|
|
@@ -86,7 +87,7 @@
|
|
|
86
87
|
}
|
|
87
88
|
},
|
|
88
89
|
"engines": {
|
|
89
|
-
"node": ">=
|
|
90
|
+
"node": "^22.14.0 || >= 24.10.0"
|
|
90
91
|
},
|
|
91
92
|
"publishConfig": {
|
|
92
93
|
"access": "public",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var xe=Object.defineProperty;var D=(e,n)=>xe(e,"name",{value:n,configurable:!0});import X from"node:path";import{generate as Y}from"@babel/generator";import{isIdentifierName as ge}from"@babel/helper-validator-identifier";import{parse as Z}from"@babel/parser";import f from"@babel/types";import{isTypeOf as C,isDeclarationType as Se,walkAST as V,resolveString as B,isIdentifierOf as ie}from"ast-kit";import{RE_DTS as _,resolveTemplateFn as he,filename_js_to_dts as ee,replaceTemplateName as te,filename_dts_to as ne,RE_DTS_MAP as Ee,filename_to_dts as be}from"../filename.js";var De=Object.defineProperty,S=D((e,n)=>De(e,"name",{value:n,configurable:!0}),"o");const $="__rollup_dts_resolve__:",We=S(({cjsDefault:e,sideEffects:n,sourcemap:g})=>{let r=0;const T=new Map,N=new Map,A=new Map;return{generateBundle(s,o){const d=new Map;for(const i of Object.values(o))if(i.type==="chunk")for(const u of i.moduleIds)d.set(u,i.fileName);const c=new RegExp(`"${$}(.+?)"`,"g");for(const i of Object.values(o))i.type!=="chunk"||!_.test(i.fileName)||i.code.includes($)&&(i.code=i.code.replaceAll(c,(u,E)=>{const a=d.get(E);if(!a)return u;let y=X.posix.relative(X.posix.dirname(i.fileName),a);return y.startsWith(".")||(y=`./${y}`),y=ne(y,"js"),JSON.stringify(y)}));for(const i of Object.values(o))if(Ee.test(i.fileName))if(g){if(i.type==="chunk"||typeof i.source!="string")continue;const u=JSON.parse(i.source);u.sourcesContent=void 0,i.source=JSON.stringify(u)}else delete o[i.fileName]},name:"rollup-plugin-dts:fake-js",outputOptions(s){const{chunkFileNames:o,entryFileNames:d}=s;return(s.format==="cjs"||s.format==="commonjs")&&(s={...s,format:"es"}),{...s,chunkFileNames(c){const i=he(c.isEntry?d||"[name].js":o||"[name]-[hash].js",c);if(c.name.endsWith(".d")){const u=ee(te(i,c.name.slice(0,-2)));if(_.test(u))return u;const E=ee(te(i,c.name));if(_.test(E))return E}return i},sourcemap:s.sourcemap||g}},renderChunk:j,async transform(s,o){if(_.test(o))return O.call(this,s,o)}};async function O(s,o){const d=Object.create(null),c=Z(s,{createParenthesizedExpressions:!0,errorRecovery:!0,plugins:[["typescript",{dts:!0}]],sourceType:"module"}),{comments:i,program:u}=c,E=[];if(i){const m=ae(i);N.set(o,m)}const a=[],y=new Map;for(const[m,t]of u.body.entries()){const v=S(l=>u.body[m]=l,"setStmt");if(Me(t,v,E))continue;const h=t.type==="TSModuleDeclaration"&&t.kind!=="namespace";let b;if(h&&t.id.type==="StringLiteral"){const l=await this.resolve(t.id.value,o);l&&!l.external?b=_.test(l.id)?l.id:be(l.id):t.id.value[0]==="."&&this.warn(`\`declare module ${JSON.stringify(t.id.value)}\` will be kept as-is in the output. Relative module declaration may cause unexpected issues. Found in ${o}.`)}if(h&&o.endsWith(".vue.d.ts")&&s.slice(t.start,t.end).includes("__VLS_"))continue;const k=t.type==="ExportDefaultDeclaration",R=C(t,["ExportNamedDeclaration","ExportDefaultDeclaration"])&&t.declaration,p=R?t.declaration:t,I=R?l=>t.declaration=l:v;if(p.type!=="TSDeclareFunction"&&!Se(p))continue;C(p,["TSEnumDeclaration","ClassDeclaration","FunctionDeclaration","TSDeclareFunction","TSModuleDeclaration","VariableDeclaration"])&&(p.declare=!0);const x=[];if(p.type==="VariableDeclaration")x.push(...p.declarations.map(l=>l.id));else if("id"in p&&p.id){let l=p.id;l.type==="TSQualifiedName"&&(l=W(l)),l=h?f.identifier(`_${P(d,"")}`):l,x.push(l)}else{const l=f.identifier("export_default");x.push(l),p.id=l}const F=pe(p),J=new Set,L=de(p,y,J,d),Q=[...J].filter(l=>x.every(ye=>l!==ye));p!==t&&(p.leadingComments=t.leadingComments);const ue=K({bindings:x,children:Q,decl:p,deps:L,params:F,resolvedModuleId:b}),q=f.numericLiteral(ue),z=f.arrowFunctionExpression(F.map(({name:l})=>f.identifier(l)),f.arrayExpression(L)),H=f.arrayExpression(Q.map(l=>({end:l.end,loc:l.loc,start:l.start,type:"StringLiteral",value:""}))),U=h&&f.callExpression(f.identifier("sideEffect"),[x[0]]),me=Ne(U?[q,z,H,U]:[q,z,H]),G={declarations:[{id:{...x[0],typeAnnotation:null},init:me,type:"VariableDeclarator"},...x.slice(1).map(l=>({id:{...l,typeAnnotation:null},type:"VariableDeclarator"}))],kind:"var",type:"VariableDeclaration"};k?(a.push(f.exportNamedDeclaration(null,[f.exportSpecifier(x[0],f.identifier("default"))])),v(G)):I(G)}return n&&a.push(f.expressionStatement(f.callExpression(f.identifier("sideEffect"),[]))),u.body=[...Array.from(y.values(),({stmt:m})=>m),...u.body,...a],A.set(o,E),Y(c,{comments:!1,sourceFileName:o,sourceMaps:g})}function j(s,o){if(!_.test(o.fileName))return;const d=[];for(const a of o.moduleIds){const y=A.get(a);y&&d.push(...y)}const c=Z(s,{sourceType:"module"}),{program:i}=c;if(i.body=Ce(i.body),i.body=ke(i.body),i.body=i.body.map(a=>{if(je(a)||a.type==="ExpressionStatement")return null;const y=we(a,d,e);if(y||y===!1)return y;if(a.type!=="VariableDeclaration")return a;if(!ve(a))return null;const[m,t,v]=a.declarations[0].init.elements,h=m.value,b=le(h);V(b.decl,{enter(p){p.type!=="CommentBlock"&&delete p.loc}});for(const[p,I]of a.declarations.entries()){const x={...I.id,typeAnnotation:b.bindings[p].typeAnnotation};M(b.bindings[p],x)}for(const[p,I]of v.elements.entries())Object.assign(b.children[p],{loc:I.loc});const k=t.params;for(const[p,I]of k.entries()){const x=I.name;for(const F of b.params[p].typeParams)F.name=x}const R=t.body.elements;for(let p=0;p<b.deps.length;p++){const I=b.deps[p];let x=R[p];x&&x.type==="UnaryExpression"&&x.operator==="void"&&(x={...f.identifier("undefined"),end:x.end,loc:x.loc,start:x.start}),I.replace?I.replace(x):Object.assign(I,x)}return b.decl.type==="TSModuleDeclaration"&&b.resolvedModuleId&&(b.decl.id.value=$+b.resolvedModuleId),Ae(a,b.decl)}).filter(a=>!!a),i.body.length===0)return"export { };";const u=new Set,E=new Set;for(const a of o.moduleIds){const y=N.get(a);y&&(y.forEach(m=>{const t=m.type+m.value;E.has(t)||(E.add(t),u.add(m))}),N.delete(a))}return u.size>0&&(i.body[0].leadingComments||=[],i.body[0].leadingComments.unshift(...u)),Y(c,{comments:!0,sourceFileName:o.fileName,sourceMaps:g})}function P(s,o){return o in s?s[o]++:s[o]=0}function K(s){const o=r++;return T.set(o,s),o}function le(s){return T.get(s)}function pe(s){const o=[];V(s,{leave(c){"typeParameters"in c&&c.typeParameters?.type==="TSTypeParameterDeclaration"&&o.push(...c.typeParameters.params)}});const d=new Map;for(const c of o){const{name:i}=c,u=d.get(i);u?u.push(c):d.set(i,[c])}return Array.from(d.entries(),([c,i])=>({name:c,typeParams:i}))}function ce(s){const o=[];return V(s,{enter(d){d.type==="TSInferType"&&d.typeParameter&&o.push(d.typeParameter.name)}}),o}function de(s,o,d,c){const i=new Set,u=new Set,E=[];let a=new Set;function y(t){return t.type==="Identifier"&&a.has(t.name)}return D(y,"l"),S(y,"isInferred"),V(s,{enter(t){if(t.type==="TSConditionalType"){const v=ce(t.extendsType);E.push(v)}},leave(t,v){if(t.type==="TSConditionalType")E.pop();else if(v?.type==="TSConditionalType"){const h=v.trueType===t;a=new Set((h?E:E.slice(0,-1)).flat())}else a=new Set;if(t.type==="ExportNamedDeclaration")for(const h of t.specifiers)h.type==="ExportSpecifier"&&m(h.local);else if(t.type==="TSInterfaceDeclaration"&&t.extends)for(const h of t.extends||[])m(w(h.expression));else if(t.type==="ClassDeclaration"){if(t.superClass&&m(t.superClass),t.implements)for(const h of t.implements)h.type!=="ClassImplements"&&m(w(h.expression))}else if(C(t,["ObjectMethod","ObjectProperty","ClassProperty","TSPropertySignature","TSDeclareMethod"]))t.computed&&re(t.key)&&m(t.key),"value"in t&&re(t.value)&&m(t.value);else switch(t.type){case"TSImportType":{u.add(t);const h=t.argument,b=t.qualifier,k=fe(t,b,h,o,c);m(k);break}case"TSTypeQuery":{if(u.has(t.exprName))return;if(t.exprName.type==="TSImportType")break;m(w(t.exprName));break}case"TSTypeReference":{m(w(t.typeName));break}}v&&!i.has(t)&&oe(t,v)&&d.add(t)}}),[...i];function m(t){se(t)||y(t)||i.add(t)}D(m,"S")}function fe(s,o,d,c,i){const u=d.value.replaceAll(/\W/g,"_"),E=ge(d.value)?d.value:`${u}${P(i,u)}`;let a=f.identifier(E);if(c.has(d.value)?a=c.get(d.value).local:c.set(d.value,{local:a,stmt:f.importDeclaration([f.importNamespaceSpecifier(a)],d)}),o){const m=W(o);M(m,f.tsQualifiedName(a,{...m})),a=o}let y=s;return s.typeParameters?(M(s,f.tsTypeReference(a,s.typeParameters)),y=a):M(s,a),{...w(a),replace(m){M(y,m)}}}},"createFakeJsPlugin");function oe(e,n){return!!(e.type==="Identifier"||C(n,["TSPropertySignature","TSMethodSignature"])&&n.key===e)}D(oe,"De");S(oe,"isChildSymbol");const Te=/\/\s*<reference\s+(?:path|types)=/,ae=S((e,n=!1)=>e.filter(g=>Te.test(g.value)!==n),"collectReferenceDirectives"),ve=S(e=>f.isVariableDeclaration(e)&&e.declarations.length>0&&f.isVariableDeclarator(e.declarations[0])&&Ie(e.declarations[0].init),"isRuntimeBindingVariableDeclaration"),Ie=S(e=>f.isArrayExpression(e)&&_e(e.elements),"isRuntimeBindingArrayExpression"),Ne=S(e=>f.arrayExpression(e),"runtimeBindingArrayExpression"),_e=S(e=>{const[n,g,r,T]=e;return n?.type==="NumericLiteral"&&g?.type==="ArrowFunctionExpression"&&r?.type==="ArrayExpression"&&(!T||T.type==="CallExpression")},"isRuntimeBindingArrayElements"),se=S(e=>ie(e,"this")||e.type==="ThisExpression"||e.type==="MemberExpression"&&se(e.object),"isThisExpression"),w=S(e=>{if(e.type==="Identifier")return e;const n=w(e.left);return Object.assign(e,f.memberExpression(n,e.right))},"TSEntityNameToRuntime"),W=S(e=>e.type==="Identifier"?e:W(e.left),"getIdFromTSEntityName"),re=S(e=>C(e,["Identifier","MemberExpression"]),"isReferenceId"),je=S(e=>e.type==="ImportDeclaration"&&e.specifiers.length===1&&e.specifiers.every(n=>n.type==="ImportSpecifier"&&n.imported.type==="Identifier"&&["__export","__reExport"].includes(n.local.name)),"isHelperImport"),we=S((e,n,g)=>{if(e.type==="ExportNamedDeclaration"&&!e.declaration&&!e.source&&e.specifiers.length===0&&!e.attributes?.length)return!1;if(C(e,["ImportDeclaration","ExportAllDeclaration","ExportNamedDeclaration"])){if(e.type==="ExportNamedDeclaration"&&n.length>0)for(const r of e.specifiers){const T=B(r.exported);n.includes(T)&&(r.type==="ExportSpecifier"?r.exportKind="type":e.exportKind="type")}if(e.source?.value&&_.test(e.source.value))return e.source.value=ne(e.source.value,"js"),e;if(g&&e.type==="ExportNamedDeclaration"&&!e.source&&e.specifiers.length===1&&e.specifiers[0].type==="ExportSpecifier"&&B(e.specifiers[0].exported)==="default")return{expression:e.specifiers[0].local,type:"TSExportAssignment"}}},"patchImportExport"),Ce=S(e=>{const n=new Set;for(const[r,T]of e.entries()){const N=g(T);if(!N)continue;const[A,O]=N;O.properties.length!==0&&(e[r]={body:{body:[{declaration:null,source:null,specifiers:O.properties.filter(j=>j.type==="ObjectProperty").map(j=>{const P=j.value.body,K=j.key;return f.exportSpecifier(P,K)}),type:"ExportNamedDeclaration"}],type:"TSModuleBlock"},declare:!0,id:A,kind:"namespace",type:"TSModuleDeclaration"})}return e.filter(r=>!n.has(r));function g(r){if(r.type!=="VariableDeclaration"||r.declarations.length!==1||r.declarations[0].id.type!=="Identifier"||r.declarations[0].init?.type!=="CallExpression"||r.declarations[0].init.callee.type!=="Identifier"||r.declarations[0].init.callee.name!=="__export"||r.declarations[0].init.arguments.length!==1||r.declarations[0].init.arguments[0].type!=="ObjectExpression")return!1;const T=r.declarations[0].id,N=r.declarations[0].init.arguments[0];return[T,N]}},"patchTsNamespace"),ke=S(e=>{const n=new Map;for(const[g,r]of e.entries())if(r.type==="ImportDeclaration"&&r.specifiers.length===1&&r.specifiers[0].type==="ImportSpecifier"&&r.specifiers[0].local.type==="Identifier"&&r.specifiers[0].local.name.endsWith("_exports"))n.set(r.specifiers[0].local.name,r.specifiers[0].local.name);else if(r.type==="ExpressionStatement"&&r.expression.type==="CallExpression"&&ie(r.expression.callee,"__reExport")){const T=r.expression.arguments;n.set(T[0].name,T[1].name)}else r.type==="VariableDeclaration"&&r.declarations.length===1&&r.declarations[0].init?.type==="MemberExpression"&&r.declarations[0].init.object.type==="Identifier"&&n.has(r.declarations[0].init.object.name)?e[g]={id:{name:r.declarations[0].id.name,type:"Identifier"},type:"TSTypeAliasDeclaration",typeAnnotation:{type:"TSTypeReference",typeName:{left:{name:n.get(r.declarations[0].init.object.name),type:"Identifier"},right:{name:r.declarations[0].init.property.name,type:"Identifier"},type:"TSQualifiedName"}}}:r.type==="ExportNamedDeclaration"&&r.specifiers.length===1&&r.specifiers[0].type==="ExportSpecifier"&&r.specifiers[0].local.type==="Identifier"&&n.has(r.specifiers[0].local.name)&&(r.specifiers[0].local.name=n.get(r.specifiers[0].local.name));return e},"patchReExport"),Me=S((e,n,g)=>{if(e.type==="ImportDeclaration"||e.type==="ExportNamedDeclaration"&&!e.declaration){for(const r of e.specifiers)("exportKind"in r&&r.exportKind==="type"||"exportKind"in e&&e.exportKind==="type")&&g.push(B(r.exported)),r.type==="ImportSpecifier"?r.importKind="value":r.type==="ExportSpecifier"&&(r.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"&&n({source:e.moduleReference.expression,specifiers:[{local:e.id,type:"ImportDefaultSpecifier"}],type:"ImportDeclaration"}),!0):e.type==="TSExportAssignment"&&e.expression.type==="Identifier"?(n({specifiers:[{exported:{name:"default",type:"Identifier"},local:e.expression,type:"ExportSpecifier"}],type:"ExportNamedDeclaration"}),!0):e.type==="ExportDefaultDeclaration"&&e.declaration.type==="Identifier"?(n({specifiers:[{exported:f.identifier("default"),local:e.declaration,type:"ExportSpecifier"}],type:"ExportNamedDeclaration"}),!0):!1},"rewriteImportExport"),M=S((e,n)=>{for(const g of Object.keys(e))delete e[g];return Object.assign(e,n),e},"overwriteNode"),Ae=S((e,n)=>{n.leadingComments||=[];const g=e.leadingComments?.filter(r=>r.value.startsWith("#"));return g&&n.leadingComments.unshift(...g),n.leadingComments=ae(n.leadingComments,!0),n},"inheritNodeComments");export{We as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"node:child_process";import"node:fs";import"node:fs/promises";import"node:path";import"@babel/parser";import"obug";import"oxc-transform";import"../filename.js";import{c as f}from"./generate-CxhgFvNH.js";export{f as createGeneratePlugin};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
var ur=Object.defineProperty;var te=(s,i)=>ur(s,"name",{value:i,configurable:!0});import{spawn as pr,fork as fr}from"node:child_process";import{existsSync as ve,readFileSync as dr}from"node:fs";import{mkdtemp as gr,readFile as Te,rm as mr}from"node:fs/promises";import P from"node:path";import{parse as Xe}from"@babel/parser";import{createDebug as Me}from"obug";import{transformSync as hr,isolatedDeclarationSync as xr}from"oxc-transform";import{RE_DTS as z,RE_NODE_MODULES as de,RE_JS as re,filename_to_dts as Ze,RE_JSON as Le,RE_TS as Ue,RE_VUE as je,resolveTemplateFn as yr,replaceTemplateName as be,RE_DTS_MAP as qe}from"../filename.js";import{createRequire as $r}from"node:module";import{tmpdir as wr}from"node:os";var vr=Object.defineProperty,a=te((s,i)=>vr(s,"name",{value:i,configurable:!0}),"s");let Ge=a(()=>{var s=(()=>{var i=Object.defineProperty,l=Object.getOwnPropertyDescriptor,c=Object.getOwnPropertyNames,f=Object.prototype.hasOwnProperty,v=a((e,t)=>{for(var r in t)i(e,r,{get:t[r],enumerable:!0})},"ne"),_=a((e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of c(t))!f.call(e,n)&&n!==r&&i(e,n,{get:a(()=>t[n],"get"),enumerable:!(o=l(t,n))||o.enumerable});return e},"ae"),j=a(e=>_(i({},"__esModule",{value:!0}),e),"oe"),N={};v(N,{zeptomatch:a(()=>Je,"zeptomatch")});var Z=a(e=>{const t=new Set,r=[e];for(let o=0;o<r.length;o++){const n=r[o];if(t.has(n))continue;t.add(n);const{children:u}=n;if(u?.length)for(let d=0,y=u.length;d<y;d++)r.push(u[d])}return Array.from(t)},"M"),L=a(e=>{let t="";const r=Z(e);for(let o=0,n=r.length;o<n;o++){const u=r[o];if(!u.regex)continue;const d=u.regex.flags;if(t||(t=d),t!==d)throw new Error(`Inconsistent RegExp flags used: "${t}" and "${d}"`)}return t},"se"),ie=a((e,t,r)=>{const o=r.get(e);if(o!==void 0)return o;const n=e.partial??t;let u="";if(e.regex&&(u+=n?"(?:$|":"",u+=e.regex.source),e.children?.length){const d=me(e.children.map(y=>ie(y,t,r)).filter(Boolean));if(d?.length){const y=e.children.some(Y=>!Y.regex||!(Y.partial??t)),b=d.length>1||n&&(!u.length||y);u+=b?n?"(?:$|":"(?:":"",u+=d.join("|"),u+=b?")":""}}return e.regex&&(u+=n?")":""),r.set(e,u),u},"O"),X=a((e,t)=>{const r=new Map,o=Z(e);for(let n=o.length-1;n>=0;n--){const u=ie(o[n],t,r);if(!(n>0))return u}return""},"ie"),me=a(e=>Array.from(new Set(e)),"ue"),K=a((e,t,r)=>K.compile(e,r).test(t),"R");K.compile=(e,t)=>{const r=t?.partial??!1,o=X(e,r),n=L(e);return new RegExp(`^(?:${o})$`,n)};var S=K,ae=a((e,t)=>{const r=S.compile(e,t),o=`${r.source.slice(0,-1)}[\\\\/]?$`,n=r.flags;return new RegExp(o,n)},"le"),U=ae,le=a(e=>{const t=e.map(o=>o.source).join("|")||"$^",r=e[0]?.flags;return new RegExp(t,r)},"ve"),H=le,B=a(e=>Array.isArray(e),"j"),A=a(e=>typeof e=="function","_"),ce=a(e=>e.length===0,"he"),x=(()=>{const{toString:e}=Function.prototype,t=/(?:^\(\s*(?:[^,.()]|\.(?!\.\.))*\s*\)\s*=>|^\s*[a-zA-Z$_][a-zA-Z0-9$_]*\s*=>)/;return r=>(r.length===0||r.length===1)&&t.test(e.call(r))})(),m=a(e=>typeof e=="number","de"),h=a(e=>typeof e=="object"&&e!==null,"xe"),g=a(e=>e instanceof RegExp,"me"),$=(()=>{const e=/\\\(|\((?!\?(?::|=|!|<=|<!))/;return t=>e.test(t.source)})(),E=(()=>{const e=/^[a-zA-Z0-9_-]+$/;return t=>e.test(t.source)&&!t.flags.includes("i")})(),M=a(e=>typeof e=="string","A"),k=a(e=>e===void 0,"f"),I=a(e=>{const t=new Map;return r=>{const o=t.get(r);if(o!==void 0)return o;const n=e(r);return t.set(r,n),n}},"ye"),D=a((e,t,r={})=>{const o={cache:{},input:e,index:0,indexBacktrackMax:0,options:r,output:[]},n=F(t)(o),u=Math.max(o.index,o.indexBacktrackMax);if(n&&o.index===e.length)return o.output;throw new Error(`Failed to parse at index ${u}`)},"I"),p=a((e,t)=>B(e)?ue(e,t):M(e)?_e(e,t):pe(e,t),"i"),ue=a((e,t)=>{const r={};for(const o of e){if(o.length!==1)throw new Error(`Invalid character: "${o}"`);const n=o.charCodeAt(0);r[n]=!0}return o=>{const n=o.input;let u=o.index,d=u;for(;d<n.length&&n.charCodeAt(d)in r;)d+=1;if(d>u){if(!k(t)&&!o.options.silent){const y=n.slice(u,d),b=A(t)?t(y,n,`${u}`):t;k(b)||o.output.push(b)}o.index=d}return!0}},"we"),pe=a((e,t)=>{if(E(e))return _e(e.source,t);{const r=e.source,o=e.flags.replace(/y|$/,"y"),n=new RegExp(r,o);return $(e)&&A(t)&&!x(t)?tt(n,t):rt(n,t)}},"$e"),tt=a((e,t)=>r=>{const o=r.index,n=r.input;e.lastIndex=o;const u=e.exec(n);if(u){const d=e.lastIndex;if(!r.options.silent){const y=t(...u,n,`${o}`);k(y)||r.output.push(y)}return r.index=d,!0}else return!1},"Ee"),rt=a((e,t)=>r=>{const o=r.index,n=r.input;if(e.lastIndex=o,e.test(n)){const u=e.lastIndex;if(!k(t)&&!r.options.silent){const d=A(t)?t(n.slice(o,u),n,`${o}`):t;k(d)||r.output.push(d)}return r.index=u,!0}else return!1},"Ce"),_e=a((e,t)=>r=>{const o=r.index,n=r.input;if(n.startsWith(e,o)){if(!k(t)&&!r.options.silent){const u=A(t)?t(e,n,`${o}`):t;k(u)||r.output.push(u)}return r.index+=e.length,!0}else return!1},"F"),he=a((e,t,r,o)=>{const n=F(e),u=t>1;return ye(xe(Se(d=>{let y=0;for(;y<r;){const b=d.index;if(!n(d)||(y+=1,d.index===b))break}return y>=t},u),o))},"k"),Ae=a((e,t)=>he(e,0,1,t),"L"),fe=a((e,t)=>he(e,0,1/0,t),"$"),nt=a((e,t)=>he(e,1,1/0,t),"Re"),q=a((e,t)=>{const r=e.map(F);return ye(xe(Se(o=>{for(let n=0,u=r.length;n<u;n++)if(!r[n](o))return!1;return!0}),t))},"x"),O=a((e,t)=>{const r=e.map(F);return ye(xe(o=>{for(let n=0,u=r.length;n<u;n++)if(r[n](o))return!0;return!1},t))},"p"),Se=a((e,t=!0,r=!1)=>{const o=F(e);return t?n=>{const u=n.index,d=n.output.length,y=o(n);return!y&&!r&&(n.indexBacktrackMax=Math.max(n.indexBacktrackMax,n.index)),(!y||r)&&(n.index=u,n.output.length!==d&&(n.output.length=d)),y}:o},"q"),xe=a((e,t)=>{const r=F(e);return t?o=>{if(o.options.silent)return r(o);const n=o.output.length;if(r(o)){const u=o.output.splice(n,1/0),d=t(u);return k(d)||o.output.push(d),!0}else return!1}:r},"B"),ye=(()=>{let e=0;return t=>{const r=F(t),o=e+=1;return n=>{var u;if(n.options.memoization===!1)return r(n);const d=n.index,y=(u=n.cache)[o]||(u[o]={indexMax:-1,queue:[]}),b=y.queue;if(d<=y.indexMax){const ee=y.store||(y.store=new Map);if(b.length){for(let V=0,ar=b.length;V<ar;V+=2){const lr=b[V*2],cr=b[V*2+1];ee.set(lr,cr)}b.length=0}const R=ee.get(d);if(R===!1)return!1;if(m(R))return n.index=R,!0;if(R)return n.index=R.index,R.output?.length&&n.output.push(...R.output),!0}const Y=n.output.length,ir=r(n);if(y.indexMax=Math.max(y.indexMax,d),ir){const ee=n.index,R=n.output.length;if(R>Y){const V=n.output.slice(Y,R);b.push(d,{index:ee,output:V})}else b.push(d,ee);return!0}else return b.push(d,!1),!1}}})(),Oe=a(e=>{let t;return r=>(t||(t=F(e())),t(r))},"G"),F=I(e=>{if(A(e))return ce(e)?Oe(e):e;if(M(e)||g(e))return p(e);if(B(e))return q(e);if(h(e))return O(Object.values(e));throw new Error("Invalid rule")}),J=a(e=>e,"d"),ot=a(e=>typeof e=="string","ke"),st=a(e=>{const t=new WeakMap,r=new WeakMap;return(o,n)=>{const u=n?.partial?r:t,d=u.get(o);if(d!==void 0)return d;const y=e(o,n);return u.set(o,y),y}},"Be"),it=a(e=>{const t={},r={};return(o,n)=>{const u=n?.partial?r:t;return u[o]??(u[o]=e(o,n))}},"Pe"),at=p(/\\./,J),lt=p(/./,J),ct=p(/\*\*\*+/,"*"),ut=p(/([^/{[(!])\*\*/,(e,t)=>`${t}*`),pt=p(/(^|.)\*\*(?=[^*/)\]}])/,(e,t)=>`${t}*`),ft=fe(O([at,ct,ut,pt,lt])),dt=ft,gt=a(e=>D(e,dt,{memoization:!1}).join(""),"Ie"),mt=gt,Re="abcdefghijklmnopqrstuvwxyz",ht=a(e=>{let t="";for(;e>0;){const r=(e-1)%26;t=Re[r]+t,e=Math.floor((e-1)/26)}return t},"Le"),Ie=a(e=>{let t=0;for(let r=0,o=e.length;r<o;r++)t=t*26+Re.indexOf(e[r])+1;return t},"V"),$e=a((e,t)=>{if(t<e)return $e(t,e);const r=[];for(;e<=t;)r.push(e++);return r},"b"),xt=a((e,t,r)=>$e(e,t).map(o=>String(o).padStart(r,"0")),"qe"),ze=a((e,t)=>$e(Ie(e),Ie(t)).map(ht),"W"),w=a(e=>({partial:!1,regex:new RegExp(e,"s"),children:[]}),"c"),Q=a(e=>({children:e}),"y"),G=(()=>{const e=a((t,r,o)=>{if(o.has(t))return;o.add(t);const{children:n}=t;if(!n.length)n.push(r);else for(let u=0,d=n.length;u<d;u++)e(n[u],r,o)},"e");return t=>{if(!t.length)return Q([]);for(let r=t.length-1;r>=1;r--){const o=new Set,n=t[r-1],u=t[r];e(n,u,o)}return t[0]}})(),W=a(()=>({regex:new RegExp("[\\\\/]","s"),children:[]}),"g"),yt=p(/\\./,w),$t=p(/[$.*+?^(){}[\]\|]/,e=>w(`\\${e}`)),wt=p(/[\\\/]/,W),vt=p(/[^$.*+?^(){}[\]\|\\\/]+/,w),jt=p(/^(?:!!)*!(.*)$/,(e,t)=>w(`(?!^${Je.compile(t).source}$).*?`)),bt=p(/^(!!)+/),Et=O([jt,bt]),Mt=p(/\/(\*\*\/)+/,()=>Q([G([W(),w(".+?"),W()]),W()])),kt=p(/^(\*\*\/)+/,()=>Q([w("^"),G([w(".*?"),W()])])),_t=p(/\/(\*\*)$/,()=>Q([G([W(),w(".*?")]),w("$")])),At=p(/\*\*/,()=>w(".*?")),Ce=O([Mt,kt,_t,At]),St=p(/\*\/(?!\*\*\/|\*$)/,()=>G([w("[^\\\\/]*?"),W()])),Ot=p(/\*/,()=>w("[^\\\\/]*")),Pe=O([St,Ot]),Ne=p("?",()=>w("[^\\\\/]")),Rt=p("[",J),It=p("]",J),zt=p(/[!^]/,"^\\\\/"),Ct=p(/[a-z]-[a-z]|[0-9]-[0-9]/i,J),Pt=p(/\\./,J),Nt=p(/[$.*+?^(){}[\|]/,e=>`\\${e}`),Dt=p(/[\\\/]/,"\\\\/"),Ft=p(/[^$.*+?^(){}[\]\|\\\/]+/,J),Wt=O([Pt,Nt,Dt,Ct,Ft]),De=q([Rt,Ae(zt),fe(Wt),It],e=>w(e.join(""))),Bt=p("{","(?:"),Jt=p("}",")"),Tt=p(/(\d+)\.\.(\d+)/,(e,t,r)=>xt(+t,+r,Math.min(t.length,r.length)).join("|")),Zt=p(/([a-z]+)\.\.([a-z]+)/,(e,t,r)=>ze(t,r).join("|")),Lt=p(/([A-Z]+)\.\.([A-Z]+)/,(e,t,r)=>ze(t.toLowerCase(),r.toLowerCase()).join("|").toUpperCase()),Ut=O([Tt,Zt,Lt]),Fe=q([Bt,Ut,Jt],e=>w(e.join(""))),qt=p("{"),Gt=p("}"),Vt=p(","),Xt=p(/\\./,w),Kt=p(/[$.*+?^(){[\]\|]/,e=>w(`\\${e}`)),Ht=p(/[\\\/]/,W),Qt=p(/[^$.*+?^(){}[\]\|\\\/,]+/,w),Yt=Oe(()=>Be),er=p("",()=>w("(?:)")),tr=nt(O([Ce,Pe,Ne,De,Fe,Yt,Xt,Kt,Ht,Qt]),G),We=O([tr,er]),Be=q([qt,Ae(q([We,fe(q([Vt,We]))])),Gt],Q),rr=fe(O([Et,Ce,Pe,Ne,De,Fe,Be,yt,$t,wt,vt]),G),nr=rr,or=a(e=>D(e,nr,{memoization:!1})[0],"kr"),sr=or,we=a((e,t,r)=>we.compile(e,r).test(t),"N");we.compile=(()=>{const e=it((r,o)=>U(sr(mt(r)),o)),t=st((r,o)=>H(r.map(n=>e(n,o))));return(r,o)=>ot(r)?e(r,o):t(r,o)})();var Je=we;return j(N)})();return s.default||s},"_lazyMatch"),Ee;const jr=a((s,i)=>(Ee||(Ee=Ge(),Ge=null),Ee(s,i)),"zeptomatch"),br=/^[A-Z]:\//i,T=a((s="")=>s&&s.replaceAll("\\","/").replace(br,i=>i.toUpperCase()),"normalizeWindowsPath"),Er=/^[/\\]{2}/,Mr=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,Ke=/^[A-Z]:$/i,Ve=/^\/([A-Z]:)?$/i,kr=/.(\.[^./]+)$/,_r=/^[/\\]|^[a-z]:[/\\]/i,Ar=a(()=>typeof process.cwd=="function"?process.cwd().replaceAll("\\","/"):"/","cwd"),He=a((s,i)=>{let l="",c=0,f=-1,v=0,_;for(let j=0;j<=s.length;++j){if(j<s.length)_=s[j];else{if(_==="/")break;_="/"}if(_==="/"){if(!(f===j-1||v===1))if(v===2){if(l.length<2||c!==2||!l.endsWith(".")||l.at(-2)!=="."){if(l.length>2){const N=l.lastIndexOf("/");N===-1?(l="",c=0):(l=l.slice(0,N),c=l.length-1-l.lastIndexOf("/")),f=j,v=0;continue}else if(l.length>0){l="",c=0,f=j,v=0;continue}}i&&(l+=l.length>0?"/..":"..",c=2)}else l.length>0?l+=`/${s.slice(f+1,j)}`:l=s.slice(f+1,j),c=j-f-1;f=j,v=0}else _==="."&&v!==-1?++v:v=-1}return l},"normalizeString"),se=a(s=>Mr.test(s),"isAbsolute"),Qe=a(function(s){if(s.length===0)return".";s=T(s);const i=Er.exec(s),l=se(s),c=s.at(-1)==="/";return s=He(s,!l),s.length===0?l?"/":c?"./":".":(c&&(s+="/"),Ke.test(s)&&(s+="/"),i?l?`//${s}`:`//./${s}`:l&&!se(s)?`/${s}`:s)},"normalize");a((...s)=>{let i="";for(const l of s)if(l)if(i.length>0){const c=i[i.length-1]==="/",f=l[0]==="/";c&&f?i+=l.slice(1):i+=c||f?l:`/${l}`}else i+=l;return Qe(i)},"join");const ge=a(function(...s){s=s.map(c=>T(c));let i="",l=!1;for(let c=s.length-1;c>=-1&&!l;c--){const f=c>=0?s[c]:Ar();!f||f.length===0||(i=`${f}/${i}`,l=se(f))}return i=He(i,!l),l&&!se(i)?`/${i}`:i.length>0?i:"."},"resolve");a(function(s){return T(s)},"toNamespacedPath");const Sr=a(function(s){return kr.exec(T(s))?.[1]??""},"extname");a(function(s,i){const l=ge(s).replace(Ve,"$1").split("/"),c=ge(i).replace(Ve,"$1").split("/");if(c[0][1]===":"&&l[0][1]===":"&&l[0]!==c[0])return c.join("/");const f=[...l];for(const v of f){if(c[0]!==v)break;l.shift(),c.shift()}return[...l.map(()=>".."),...c].join("/")},"relative");const Or=a(s=>{const i=T(s).replace(/\/$/,"").split("/").slice(0,-1);return i.length===1&&Ke.test(i[0])&&(i[0]+="/"),i.join("/")||(se(s)?"/":".")},"dirname");a(function(s){const i=[s.root,s.dir,s.base??s.name+s.ext].filter(Boolean);return T(s.root?ge(...i):i.join("/"))},"format");const Rr=a((s,i)=>{const l=T(s).split("/").pop();return i&&l.endsWith(i)?l.slice(0,-i.length):l},"basename");a(function(s){const i=_r.exec(s)?.[0]?.replaceAll("\\","/")??"",l=Rr(s),c=Sr(l);return{base:l,dir:Or(s),ext:c,name:l.slice(0,l.length-c.length),root:i}},"parse");a((s,i)=>jr(i,Qe(s)),"matchesGlob");var Ir=Object.defineProperty,Ye=te((s,i)=>Ir(s,"name",{value:i,configurable:!0}),"r");const zr=Me("rollup-plugin-dts:tsc-context"),et=Ye(()=>({files:new Map,programs:[],projects:new Map}),"createContext"),Cr=Ye((s,i)=>{i=ge(i).replaceAll("\\","/"),zr(`invalidating context file: ${i}`),s.files.delete(i),s.programs=s.programs.filter(l=>!l.getSourceFiles().some(c=>c.fileName===i)),s.projects.clear()},"invalidateContextFile"),Pr=et();var Nr=Object.defineProperty,ke=te((s,i)=>Nr(s,"name",{value:i,configurable:!0}),"i");const ne=Me("rollup-plugin-dts:tsgo"),Dr=ke((...s)=>new Promise((i,l)=>{const c=pr(...s);c.on("close",()=>i()),c.on("error",f=>l(f))}),"spawnAsync"),Fr=ke(()=>{const s=$r(import.meta.url),i=s.resolve("@typescript/native-preview/package.json"),l=P.dirname(i),c=s(P.join(l,"lib","getExePath.js"));return(typeof c=="function"?c:c.default)()},"getTsgoPathFromNodeModules"),Wr=ke(async(s,i,l,c)=>{ne("[tsgo] rootDir",s);let f;c?(f=c,ne("[tsgo] using custom path",f)):(f=Fr(),ne("[tsgo] using tsgo from node_modules",f));const v=await gr(P.join(wr(),"rollup-plugin-dts-"));ne("[tsgo] tsgoDist",v);const _=["--noEmit","false","--declaration","--emitDeclarationOnly",...i?["-p",i]:[],"--outDir",v,"--rootDir",s,"--noCheck",...l?["--declarationMap"]:[]];return ne("[tsgo] args %o",_),await Dr(f,_,{stdio:"inherit"}),v},"runTsgo");var Br=Object.defineProperty,oe=te((s,i)=>Br(s,"name",{value:i,configurable:!0}),"y");const C=Me("rollup-plugin-dts:generate"),Jr=import.meta.WORKER_URL??"./tsc/worker.js",tn=oe(({build:s,cwd:i,eager:l,emitDtsOnly:c,emitJs:f,incremental:v,newContext:_,oxc:j,parallel:N,sourcemap:Z,tsconfig:L,tsconfigRaw:ie,tsgo:X,tsMacro:me,vue:K})=>{const S=new Map,ae=new Map;let U,le,H,B,A;const ce=L?P.dirname(L):i;return{async buildEnd(){U?.kill(),!C.enabled&&A&&await mr(A,{force:!0,recursive:!0}).catch(()=>{}),A=void 0,_&&(B=void 0)},async buildStart(x){if(X?A=await Wr(ce,L,Z,X.path):j||(N?(U=fr(new URL(Jr,import.meta.url),{stdio:"inherit"}),le=(await import("birpc")).createBirpc({},{on:oe(m=>U.on("message",m),"on"),post:oe(m=>U.send(m),"post")})):(H=await import("../packem_chunks/index.js"),_&&(B=et()))),!Array.isArray(x.input))for(const[m,h]of Object.entries(x.input)){C("resolving input alias %s -> %s",m,h);let g=await this.resolve(h);h.startsWith("./")||(g||=await this.resolve(`./${h}`));const $=g?.id||h;C("resolved input alias %s -> %s",h,$),ae.set($,m)}},generateBundle(x,m){for(const h of Object.keys(m)){const g=m[h];if(g){if(g.type==="asset"&&qe.test(h)&&typeof g.source=="string"){const $=JSON.parse(g.source);$.names=[],delete $.sourcesContent,g.source=JSON.stringify($)}c&&g.type==="chunk"&&!z.test(h)&&!qe.test(h)&&delete m[h]}}},load:{filter:{id:{exclude:[de],include:[z]}},async handler(x){if(!S.has(x))return;const{code:m,id:h}=S.get(x);let g,$;if(C("generate dts %s from %s",x,h),X){if(je.test(h))throw new Error("tsgo does not support Vue files.");const E=P.resolve(A,P.relative(ce,Ze(h)));if(ve(E)){if(g=await Te(E,"utf8"),Z){const M=`${E}.map`;ve(M)&&($=JSON.parse(await Te(M,"utf8")))}}else throw C("[tsgo]",E,"is missing"),new Error(`tsgo did not generate dts file for ${h}, please check your tsconfig.`)}else if(j&&!je.test(h)){const E=xr(h,m,j);if(E.errors.length>0){const[M]=E.errors;return this.error({frame:M?.codeframe||void 0,message:M?.codeframe?`${M.message}
|
|
2
|
-
${M.codeframe}`:M?.message??"Unknown error"})}g=E.code,E.map&&($=E.map,$.sourcesContent=void 0,$.names=[])}else{const E=l?void 0:[...S.values()].filter(I=>I.isEntry).map(I=>I.id),M={build:s,context:B,cwd:i,entries:E,id:h,incremental:v,sourcemap:Z,tsconfig:L,tsconfigRaw:ie,tsMacro:me,vue:K};let k;if(k=N?await le.tscEmit(M):H.tscEmit(M),k.error)return this.error(k.error);if(g=k.code,$=k.map,g&&Le.test(h))if(g.includes("declare const _exports")){if(g.includes("declare const _exports: {")&&!g.includes(`
|
|
3
|
-
}[];`)){const I=Zr(g);let D=0;g+=I.map(p=>{const ue=`_${p.replaceAll(/[^\w$]/g,"_")}${D++}`,pe=JSON.stringify(p);return`declare let ${ue}: typeof _exports[${pe}]
|
|
4
|
-
export { ${ue} as ${pe} }`}).join(`
|
|
5
|
-
`)}}else{const I=Tr(g);g+=`
|
|
6
|
-
declare namespace __json_default_export {
|
|
7
|
-
export { ${Array.from(I.entries(),([D,p])=>D===p?D:`${p} as ${D}`).join(", ")} }
|
|
8
|
-
}
|
|
9
|
-
export { __json_default_export as default }`}}return{code:g||"",map:$}}},name:"rollup-plugin-dts:generate",outputOptions(x){return{...x,entryFileNames(m){const{entryFileNames:h}=x,g=yr(h||"[name].js",m);if(m.name.endsWith(".d")){if(z.test(g))return be(g,m.name.slice(0,-2));if(re.test(g))return g.replace(re,".$1ts")}else if(c){if(m.facadeModuleId&&z.test(m.facadeModuleId)){if(z.test(g))return be(g,m.name);if(re.test(g))return g.replace(re,".$1ts")}return be("[name].js",m.name)}return g}}},async resolveId(x,m){if(S.has(x))return C("resolve dts id %s",x),{id:x};if(!m&&z.test(x)&&!de.test(x)){const h=P.isAbsolute(x)?x:P.resolve(i,x),g=h.replace(z,".$1ts");if(!S.has(h)&&ve(g)){const $=dr(g,"utf8");S.set(h,{code:$,id:g,isEntry:!0}),C("populated dtsMap from source for cached re-resolution: %s",h)}return S.has(h)?(C("resolve dts id %s (from cache re-resolution)",h),{id:h}):null}if(m&&Ue.test(m)&&(x.startsWith("./")||x.startsWith("../"))&&!P.extname(x))for(const h of[".ts",".tsx",".mts",".cts"]){const g=await this.resolve(x+h,m,{skipSelf:!0});if(g)return g}return null},shouldTransformCachedModule({id:x}){return z.test(x)&&!de.test(x)},transform:{handler(x,m){if(!(z.test(m)||de.test(m))){if(!re.test(m)||f){const h=!!this.getModuleInfo(m)?.isEntry,g=Ze(m);if(S.set(g,{code:x,id:m,isEntry:h}),C("register dts source: %s",m),h){const $=ae.get(m);this.emitFile({id:g,name:$?`${$}.d`:void 0,type:"chunk"})}}return c?Le.test(m)?"{}":"export { }":Ue.test(m)||je.test(m)?hr(m,x,{}).code:null}},order:"pre"},watchChange(x){H&&Cr(B||Pr,x)}}},"createGeneratePlugin"),Tr=oe(s=>{const i=new Map,{program:l}=Xe(s,{errorRecovery:!0,plugins:[["typescript",{dts:!0}]],sourceType:"module"});for(const c of l.body)if(c.type==="ExportNamedDeclaration"){if(c.declaration)if(c.declaration.type==="VariableDeclaration")for(const f of c.declaration.declarations)f.id.type==="Identifier"&&i.set(f.id.name,f.id.name);else c.declaration.type==="TSModuleDeclaration"&&c.declaration.id.type==="Identifier"&&i.set(c.declaration.id.name,c.declaration.id.name);else if(c.specifiers.length>0)for(const f of c.specifiers)f.type==="ExportSpecifier"&&f.exported.type==="Identifier"&&i.set(f.exported.name,f.local.type==="Identifier"?f.local.name:f.exported.name)}return i},"collectJsonExportMap"),Zr=oe(s=>{const i=[],{program:l}=Xe(s,{plugins:[["typescript",{dts:!0}]],sourceType:"module"}),c=l.body[0].declarations[0].id.typeAnnotation.typeAnnotation.members;for(const f of c)f.key.type==="Identifier"?i.push(f.key.name):f.key.type==="StringLiteral"&&i.push(f.key.value);return i},"collectJsonExports");export{Or as X,tn as c,Pr as g};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var C=Object.defineProperty;var d=(i,l)=>C(i,"name",{value:l,configurable:!0});import j from"node:path";import w from"node:process";import{findTsConfigSync as R,readTsConfig as k}from"@visulima/tsconfig";var B=Object.defineProperty,F=d((i,l)=>B(i,"name",{value:l,configurable:!0}),"m");let g=!1;const G=F(({banner:i,build:l=!1,cjsDefault:v=!1,compilerOptions:e={},cwd:c=w.cwd(),dtsInput:b=!1,eager:x=!1,emitDtsOnly:O=!1,emitJs:u,footer:T,incremental:m=!1,newContext:y=!1,oxc:o,parallel:E=!1,resolve:M=!1,resolver:I="oxc",sideEffects:P=!1,sourcemap:p,tsconfig:t,tsconfigRaw:D={},tsgo:f=!1,tsMacro:n=!1,vue:r=!1})=>{let a;if(t===!0||t==null)try{const h=R(c);t=h.path,a=h.config}catch{t=void 0}else typeof t=="string"?(t=j.resolve(c||w.cwd(),t),a=k(t)):t=void 0;e={...a?.compilerOptions,...e},m||=e.incremental||!!e.tsBuildInfoFile,p??=!!e.declarationMap,e.declarationMap=p;const J={...a,...D,compilerOptions:e};let s=!1;if(f&&(s=f===!0?{}:f),o??=!!(e?.isolatedDeclarations&&!r&&!s&&!n),o===!0&&(o={}),o&&(o.stripInternal??=!!e?.stripInternal,o.sourcemap=!!e.declarationMap),u??=!!(e.checkJs||e.allowJs),s){if(r)throw new Error("[@visulima/rollup-plugin-dts] The `tsgo` option is not compatible with the `vue` option. Please disable one of them.");if(n)throw new Error("[@visulima/rollup-plugin-dts] The `tsgo` option is not compatible with the `tsMacro` option. Please disable one of them.");if(o)throw new Error("[@visulima/rollup-plugin-dts] The `tsgo` option is not compatible with the `oxc` option. Please disable one of them.")}if(o&&r)throw new Error("[@visulima/rollup-plugin-dts] The `oxc` option is not compatible with the `vue` option. Please disable one of them.");if(o&&n)throw new Error("[@visulima/rollup-plugin-dts] The `oxc` option is not compatible with the `tsMacro` option. Please disable one of them.");return s&&!g&&(console.warn("The `tsgo` option is experimental and may change in the future."),g=!0),{banner:i,build:l,cjsDefault:v,cwd:c,dtsInput:b,eager:x,emitDtsOnly:O,emitJs:u,footer:T,incremental:m,newContext:y,oxc:o,parallel:E,resolve:M,resolver:I,sideEffects:P,sourcemap:p,tsconfig:t,tsconfigRaw:J,tsgo:s,tsMacro:n,vue:r}},"resolveOptions");export{G as resolveOptions};
|