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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,9 @@
1
+ var ie=Object.defineProperty;var S=(a,n)=>ie(a,"name",{value:n,configurable:!0});import{spawn as ae,fork as ce}from"node:child_process";import{existsSync as N,readFileSync as le}from"node:fs";import{mkdtemp as pe,readFile as z,rm as de}from"node:fs/promises";import u from"node:path";import{parse as Z}from"@babel/parser";import{createFilter as ue}from"@rollup/pluginutils";import{createDebug as P}from"obug";import{transformSync as fe,isolatedDeclarationSync as me}from"oxc-transform";import{RE_DTS as m,RE_NODE_MODULES as A,RE_JS as _,filenameToDts as H,RE_JSON as Q,RE_TS as X,RE_VUE as C,resolveTemplateFunction as ge,replaceTemplateName as J,RE_DTS_MAP as Y}from"../filename.js";import{resolve as ye}from"@visulima/path";import{createRequire as ve}from"node:module";import{tmpdir as he}from"node:os";var we=Object.defineProperty,ee=S((a,n)=>we(a,"name",{value:n,configurable:!0}),"o");const xe=P("rollup-plugin-dts:tsc-context"),te=ee(()=>({files:new Map,programs:[],projects:new Map}),"createContext"),Ee=ee((a,n)=>{const p=ye(n).replaceAll("\\","/");xe(`invalidating context file: ${p}`),a.files.delete(p),a.programs=a.programs.filter(i=>!i.getSourceFiles().some(o=>o.fileName===p)),a.projects.clear()},"invalidateContextFile"),$e=te();var _e=Object.defineProperty,I=S((a,n)=>_e(a,"name",{value:n,configurable:!0}),"n");const M=P("rollup-plugin-dts:tsgo"),Me=I(async(...a)=>{await new Promise((n,p)=>{const i=ae(...a);i.on("close",()=>{n()}),i.on("error",o=>{p(o)})})},"spawnAsync"),be=I(()=>{const a=ve(import.meta.url),n=a.resolve("@typescript/native-preview/package.json"),p=u.dirname(n),i=a(u.join(p,"lib","getExePath.js")),o=typeof i=="function"?i:i.default;if(!o)throw new Error("Failed to resolve getExePath from @typescript/native-preview");return o()},"getTsgoPathFromNodeModules"),je=I(async(a,n,p,i)=>{M("[tsgo] rootDir",a);let o;i?(o=i,M("[tsgo] using custom path",o)):(o=be(),M("[tsgo] using tsgo from node_modules",o));const w=await pe(u.join(he(),"rollup-plugin-dts-"));M("[tsgo] tsgoDist",w);const x=["--noEmit","false","--declaration","--emitDeclarationOnly",...n?["-p",n]:[],"--outDir",w,"--rootDir",a,"--noCheck",...p?["--declarationMap"]:[]];return M("[tsgo] args %o",x),await Me(o,x,{stdio:"inherit"}),w},"runTsgo");var ke=Object.defineProperty,b=S((a,n)=>ke(a,"name",{value:n,configurable:!0}),"x");const v=P("rollup-plugin-dts:generate"),Oe=import.meta.WORKER_URL??"./tsc/worker.js",Ve=b(({build:a,cwd:n,eager:p,emitDtsOnly:i,emitJs:o,exclude:w,include:x,incremental:re,newContext:U,oxc:D,parallel:W,sourcemap:T,tsconfig:j,tsconfigRaw:oe,tsgo:R,tsMacro:se,vue:ne})=>{const L=x||w?ue(x,w):null,h=new Map,B=new Map;let k,V,F,O,E;const G=j?u.dirname(j):n;return{async buildEnd(){k?.kill(),!v.enabled&&E&&await de(E,{force:!0,recursive:!0}).catch(()=>{}),E=void 0,U&&(O=void 0)},async buildStart(s){if(R?E=await je(G,j,T,R.path):D||(W?(k=ce(new URL(Oe,import.meta.url),{stdio:"inherit"}),V=(await import("birpc")).createBirpc({},{on:b(t=>k.on("message",t),"on"),post:b(t=>k.send(t),"post")})):(F=await import("../packem_chunks/index.js"),U&&(O=te()))),!Array.isArray(s.input))for(const[t,r]of Object.entries(s.input)){v("resolving input alias %s -> %s",t,r);let e=await this.resolve(r);r.startsWith("./")||(e||=await this.resolve(`./${r}`));const c=e?.id||r;v("resolved input alias %s -> %s",r,c),B.set(c,t)}},generateBundle(s,t){for(const r of Object.keys(t)){const e=t[r];if(e){if(e.type==="asset"&&Y.test(r)&&typeof e.source=="string"){const c=JSON.parse(e.source);c.names=[],delete c.sourcesContent,e.source=JSON.stringify(c)}i&&e.type==="chunk"&&!m.test(r)&&!Y.test(r)&&delete t[r]}}},load:{filter:{id:{exclude:[A],include:[m]}},async handler(s){if(!h.has(s))return;const{code:t,id:r}=h.get(s);let e,c;if(v("generate dts %s from %s",s,r),R){if(C.test(r))throw new Error("tsgo does not support Vue files.");const l=u.resolve(E,u.relative(G,H(r)));if(N(l)){if(e=await z(l,"utf8"),T){const d=`${l}.map`;if(N(d)){const f=JSON.parse(await z(d,"utf8"));if(Array.isArray(f.sources)){const g=u.dirname(d);f.sources=f.sources.map(y=>y==null?y:u.resolve(g,y))}c=f}}}else throw v("[tsgo]",l,"is missing"),new Error(`tsgo did not generate dts file for ${r}, please check your tsconfig.`)}else if(D&&!C.test(r)){const l=me(r,t,D);if(l.errors.length>0){const[d]=l.errors;return this.error({frame:d?.codeframe||void 0,message:d?.codeframe?`${d.message}
2
+ ${d.codeframe}`:d?.message??"Unknown error"})}e=l.code,l.map&&(c=l.map,c.sourcesContent=void 0,c.names=[])}else{const l=p?void 0:[...h.values()].filter(g=>g.isEntry).map(g=>g.id),d={build:a,context:O,cwd:n,entries:l,id:r,incremental:re,sourcemap:T,tsconfig:j,tsconfigRaw:oe,tsMacro:se,vue:ne};let f;if(f=W?await V.tscEmit(d):F.tscEmit(d),f.error)return this.error(f.error);if(e=f.code,c=f.map,e&&Q.test(r))if(e.includes("declare const _exports")){if(e.includes("declare const _exports: {")&&!e.includes(`
3
+ }[];`)){const g=De(e);let y=0;e+=g.map($=>{const q=`_${$.replaceAll(/[^\w$]/g,"_")}${y++}`,K=JSON.stringify($);return`declare let ${q}: typeof _exports[${K}]
4
+ export { ${q} as ${K} }`}).join(`
5
+ `)}}else{const g=Se(e);e+=`
6
+ declare namespace __json_default_export {
7
+ export { ${Array.from(g.entries(),([y,$])=>y===$?y:`${$} as ${y}`).join(", ")} }
8
+ }
9
+ export { __json_default_export as default }`}}return{code:e||"",map:c}}},name:"rollup-plugin-dts:generate",outputOptions(s){return{...s,entryFileNames(t){const{entryFileNames:r}=s,e=ge(r||"[name].js",t);if(t.name.endsWith(".d")){if(m.test(e))return J(e,t.name.slice(0,-2));if(_.test(e))return e.replace(_,".$1ts")}else if(i){if(t.facadeModuleId&&m.test(t.facadeModuleId)){if(m.test(e))return J(e,t.name);if(_.test(e))return e.replace(_,".$1ts")}return J("[name].js",t.name)}return e}}},async resolveId(s,t){if(h.has(s))return v("resolve dts id %s",s),{id:s};if(!t&&m.test(s)&&!A.test(s)){const r=u.isAbsolute(s)?s:u.resolve(n,s),e=r.replace(m,""),c=[r.replace(m,".$1ts"),`${e}.tsx`,`${e}.ts`,`${e}.mts`,`${e}.cts`];if(!h.has(r)){for(const l of c)if(N(l)){const d=le(l,"utf8");h.set(r,{code:d,id:l,isEntry:!0}),v("populated dtsMap from source for cached re-resolution: %s (via %s)",r,l);break}}return h.has(r)?(v("resolve dts id %s (from cache re-resolution)",r),{id:r}):null}if(t&&X.test(t)&&(s.startsWith("./")||s.startsWith("../"))&&!u.extname(s))for(const r of[".ts",".tsx",".mts",".cts"]){const e=await this.resolve(s+r,t,{skipSelf:!0});if(e)return e}return null},shouldTransformCachedModule({id:s}){return m.test(s)},transform:{handler(s,t){if(!(m.test(t)||A.test(t)||L&&!L(t))){if(!_.test(t)||o){const r=!!this.getModuleInfo(t)?.isEntry,e=H(t);if(h.set(e,{code:s,id:t,isEntry:r}),v("register dts source: %s",t),r){const c=B.get(t);this.emitFile({id:e,name:c?`${c}.d`:void 0,type:"chunk"})}}return i?Q.test(t)?"{}":"export { }":X.test(t)||C.test(t)?fe(t,s,{}).code:null}},order:"pre"},watchChange(s){F&&Ee(O||$e,s)}}},"createGeneratePlugin"),Se=b(a=>{const n=new Map,{program:p}=Z(a,{errorRecovery:!0,plugins:[["typescript",{dts:!0}]],sourceType:"module"});for(const i of p.body)if(i.type==="ExportNamedDeclaration"){if(i.declaration)if(i.declaration.type==="VariableDeclaration")for(const o of i.declaration.declarations)o.id.type==="Identifier"&&n.set(o.id.name,o.id.name);else i.declaration.type==="TSModuleDeclaration"&&i.declaration.id.type==="Identifier"&&n.set(i.declaration.id.name,i.declaration.id.name);else if(i.specifiers.length>0)for(const o of i.specifiers)o.type==="ExportSpecifier"&&o.exported.type==="Identifier"&&n.set(o.exported.name,o.local.type==="Identifier"?o.local.name:o.exported.name)}return n},"collectJsonExportMap"),De=b(a=>{const n=[],{program:p}=Z(a,{plugins:[["typescript",{dts:!0}]],sourceType:"module"}),i=p.body[0].declarations[0].id.typeAnnotation.typeAnnotation.members;for(const o of i)o.key.type==="Identifier"?n.push(o.key.name):o.key.type==="StringLiteral"&&n.push(o.key.value);return n},"collectJsonExports");export{Ve as c,$e as g};
@@ -0,0 +1 @@
1
+ var H=Object.defineProperty;var x=(e,o)=>H(e,"name",{value:o,configurable:!0});import{existsSync as N}from"node:fs";import{createRequire as Q}from"node:module";import d from"node:path";import y from"node:process";import{findTsConfigSync as U,readTsConfig as V}from"@visulima/tsconfig";import O from"typescript";var X=Object.defineProperty,r=x((e,o)=>X(e,"name",{value:o,configurable:!0}),"i");let T=!1;const Y=r(e=>e?e.incremental===!1?-1:e.incremental===!0||typeof e.tsBuildInfoFile=="string"?1:0:0,"checkCompilerOptionsIncremental"),Z=r((e,o)=>{if(e.startsWith("."))return d.resolve(o,e.endsWith(".json")?e:`${e}.json`);try{return Q(d.join(o,"package.json")).resolve(e)}catch{return}},"resolveExtendedTsconfigPath"),_=r(e=>{if(N(e))return O.sys.readFile(e)},"readTsconfigFile"),E=r((e,o=new Set)=>{if(o.has(e))return!1;o.add(e);const t=O.readConfigFile(e,_);if(t.error||!t.config)return!1;const i=t.config,n=Y(i.compilerOptions);if(n!==0)return n===1;if(!i.extends)return!1;const s=Array.isArray(i.extends)?i.extends:[i.extends],m=d.dirname(e);for(const a of s){if(typeof a!="string")continue;const c=Z(a,m);if(c&&E(c,o))return!0}return!1},"hasExplicitIncrementalInTsconfig"),G=r((e,o)=>{if(e===!0||e===void 0)try{const t=U(o);return{resolvedTsconfig:t.config,tsconfig:t.path}}catch{return{resolvedTsconfig:void 0,tsconfig:void 0}}if(typeof e=="string"){const t=d.resolve(o||y.cwd(),e);return{resolvedTsconfig:V(t),tsconfig:t}}return{resolvedTsconfig:void 0,tsconfig:void 0}},"resolveTsconfigPath"),K=r((e,o,t,i)=>{if(e){if(o)throw new Error("[@visulima/rollup-plugin-dts] The `tsgo` option is not compatible with the `vue` option. Please disable one of them.");if(t)throw new Error("[@visulima/rollup-plugin-dts] The `tsgo` option is not compatible with the `tsMacro` option. Please disable one of them.");if(i)throw new Error("[@visulima/rollup-plugin-dts] The `tsgo` option is not compatible with the `oxc` option. Please disable one of them.")}},"validateTsgoCompatibility"),L=r((e,o,t)=>{if(e){if(o)throw new Error("[@visulima/rollup-plugin-dts] The `oxc` option is not compatible with the `vue` option. Please disable one of them.");if(t)throw new Error("[@visulima/rollup-plugin-dts] The `oxc` option is not compatible with the `tsMacro` option. Please disable one of them.")}},"validateOxcCompatibility"),ee=r(e=>e===!1?!1:e===!0?{}:e,"normalizeTsgo"),oe=r((e,o,t,i,n)=>{let s;switch(e){case!1:{s=!1;break}case!0:{s={};break}case void 0:{s=o.isolatedDeclarations&&!t&&!i&&!n?{}:!1;break}default:s=e}return s&&(s.stripInternal??=o.stripInternal??!1,s.sourcemap=o.declarationMap??!1),s},"normalizeOxc"),ce=r(({banner:e,build:o=!1,cjsDefault:t=!1,compilerOptions:i={},cwd:n=y.cwd(),dtsInput:s=!1,eager:m=!1,emitDtsOnly:a=!1,emitJs:c,exclude:I,footer:C,include:P,incremental:j=!1,newContext:M=!1,oxc:k,parallel:D=!1,resolve:F=!1,resolver:J="oxc",sideEffects:S=!1,sourcemap:z,tsconfig:R,tsconfigRaw:q={},tsgo:A=!1,tsMacro:f=!1,vue:p=!1})=>{const{resolvedTsconfig:v,tsconfig:g}=G(R,n),w=i,l={...v?.compilerOptions,...i},B=j||w.incremental===!0||typeof w.tsBuildInfoFile=="string"||typeof g=="string"&&E(g),b=z??!!l.declarationMap;l.declarationMap=b;const W={...v,...q,compilerOptions:l},u=ee(A),h=oe(k,l,p,u,f),$=c??!!(l.checkJs||l.allowJs);return K(u,p,f,h),L(h,p,f),u&&!T&&(console.warn("The `tsgo` option is experimental and may change in the future."),T=!0),{banner:e,build:o,cjsDefault:t,cwd:n,dtsInput:s,eager:m,emitDtsOnly:a,emitJs:$,exclude:I,footer:C,include:P,incremental:B,newContext:M,oxc:h,parallel:D,resolve:F,resolver:J,sideEffects:S,sourcemap:b,tsconfig:g,tsconfigRaw:W,tsgo:u,tsMacro:f,vue:p}},"resolveOptions");export{ce as resolveOptions};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/rollup-plugin-dts",
3
- "version": "1.0.0-alpha.26",
3
+ "version": "1.0.0-alpha.27",
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": {
@@ -37,11 +37,11 @@
37
37
  "type": "module",
38
38
  "exports": {
39
39
  ".": {
40
- "types": "./dist/index.ts",
40
+ "types": "./dist/index.d.ts",
41
41
  "default": "./dist/index.js"
42
42
  },
43
43
  "./filename": {
44
- "types": "./dist/filename.js",
44
+ "types": "./dist/filename.d.ts",
45
45
  "default": "./dist/filename.js"
46
46
  },
47
47
  "./package.json": "./package.json"
@@ -52,25 +52,26 @@
52
52
  "dist"
53
53
  ],
54
54
  "dependencies": {
55
- "@babel/generator": "7.29.1",
56
- "@babel/helper-validator-identifier": "7.28.5",
57
- "@babel/parser": "7.29.2",
58
- "@babel/types": "7.29.0",
55
+ "@babel/generator": "7.29.7",
56
+ "@babel/helper-validator-identifier": "7.29.7",
57
+ "@babel/parser": "7.29.7",
58
+ "@babel/types": "7.29.7",
59
59
  "@rollup/pluginutils": "5.3.0",
60
- "@visulima/tsconfig": "3.0.0-alpha.11",
60
+ "@visulima/path": "3.0.0-alpha.10",
61
+ "@visulima/tsconfig": "3.0.0-alpha.24",
61
62
  "ast-kit": "^2.2.0",
62
63
  "birpc": "^4.0.0",
63
64
  "magic-string": "0.30.21",
64
65
  "obug": "2.1.1",
65
66
  "oxc-resolver": "11.19.1",
66
- "oxc-transform": "0.126.0"
67
+ "oxc-transform": "0.133.0"
67
68
  },
68
69
  "peerDependencies": {
69
70
  "@ts-macro/tsc": "0.3.7",
70
71
  "@typescript/native-preview": ">=7.0.0-dev.20250601.1",
71
- "rollup": ">=4.0.0",
72
- "typescript": "^5.0.0 || ^6.0.0",
73
- "vue-tsc": "3.2.6"
72
+ "rollup": ">=4.60.4",
73
+ "typescript": "^6.0.3",
74
+ "vue-tsc": "3.3.2"
74
75
  },
75
76
  "peerDependenciesMeta": {
76
77
  "@typescript/native-preview": {
package/dist/banner.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import type { Plugin } from "rollup";
2
- import type { OptionsResolved } from "./options.d.ts";
3
- declare const createBannerPlugin: ({ banner, footer }: Pick<OptionsResolved, "banner" | "footer">) => Plugin;
4
- export default createBannerPlugin;
@@ -1,4 +0,0 @@
1
- import type { Plugin } from "rollup";
2
- import type { OptionsResolved } from "./options.d.ts";
3
- declare const createDtsInputPlugin: ({ sideEffects }: Pick<OptionsResolved, "sideEffects">) => Plugin;
4
- export default createDtsInputPlugin;
package/dist/fake-js.d.ts DELETED
@@ -1,4 +0,0 @@
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;
@@ -1,12 +0,0 @@
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/options.d.ts DELETED
@@ -1,215 +0,0 @@
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,3 +0,0 @@
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};
@@ -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"@rollup/pluginutils";import"../filename.js";import{c as g}from"./generate-ufHefAw7.js";export{g as createGeneratePlugin};
@@ -1,9 +0,0 @@
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 mr,readFile as Ze,rm as gr}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 S,RE_NODE_MODULES as Me,RE_JS as oe,filename_to_dts as Ue,RE_JSON as qe,RE_TS as Ge,RE_VUE as Ee,resolveTemplateFn as $r,replaceTemplateName as ke,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,d=Object.prototype.hasOwnProperty,w=a((e,t)=>{for(var r in t)i(e,r,{get:t[r],enumerable:!0})},"ne"),k=a((e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of c(t))!d.call(e,n)&&n!==r&&i(e,n,{get:a(()=>t[n],"get"),enumerable:!(o=l(t,n))||o.enumerable});return e},"ae"),E=a(e=>k(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 m=0,y=u.length;m<y;m++)r.push(u[m])}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 m=u.regex.flags;if(t||(t=m),t!==m)throw new Error(`Inconsistent RegExp flags used: "${t}" and "${m}"`)}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 m=ge(e.children.map(y=>q(y,t,r)).filter(Boolean));if(m?.length){const y=e.children.some(te=>!te.regex||!(te.partial??t)),M=m.length>1||n&&(!u.length||y);u+=M?n?"(?:$|":"(?:":"",u+=m.join("|"),u+=M?")":""}}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"),ge=a(e=>Array.from(new Set(e)),"ue"),F=a((e,t,r)=>F.compile(e,r).test(t),"R");F.compile=(e,t)=>{const r=t?.partial??!1,o=G(e,r),n=le(e);return new RegExp(`^(?:${o})$`,n)};var he=F,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,_=a(e=>{const t=e.map(o=>o.source).join("|")||"$^",r=e[0]?.flags;return new RegExp(t,r)},"ve"),ue=_,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"),g=(()=>{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")})(),p=a(e=>typeof e=="string","A"),$=a(e=>e===void 0,"f"),v=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"),j=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"),f=a((e,t)=>W(e)?R(e,t):p(e)?Y(e,t):T(e,t),"i"),R=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,m=u;for(;m<n.length&&n.charCodeAt(m)in r;)m+=1;if(m>u){if(!$(t)&&!o.options.silent){const y=n.slice(u,m),M=P(t)?t(y,n,`${u}`):t;$(M)||o.output.push(M)}o.index=m}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 g(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 m=e.lastIndex;if(!r.options.silent){const y=t(...u,n,`${o}`);$(y)||r.output.push(y)}return r.index=m,!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 m=P(t)?t(n.slice(o,u),n,`${o}`):t;$(m)||r.output.push(m)}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(m=>{let y=0;for(;y<r;){const M=m.index;if(!n(m)||(y+=1,m.index===M))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,m=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!==m&&(n.output.length=m)),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),m=t(u);return $(m)||o.output.push(m),!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 m=n.index,y=(u=n.cache)[o]||(u[o]={indexMax:-1,queue:[]}),M=y.queue;if(m<=y.indexMax){const re=y.store||(y.store=new Map);if(M.length){for(let Q=0,ar=M.length;Q<ar;Q+=2){const lr=M[Q*2],cr=M[Q*2+1];re.set(lr,cr)}M.length=0}const O=re.get(m);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,m),ir){const re=n.index,O=n.output.length;if(O>te){const Q=n.output.slice(te,O);M.push(m,{index:re,output:Q})}else M.push(m,re);return!0}else return M.push(m,!1),!1}}})(),Ie=a(e=>{let t;return r=>(t||(t=D(e())),t(r))},"G"),D=v(e=>{if(P(e))return X(e)?Ie(e):e;if(p(e)||x(e))return f(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,m=u.get(o);if(m!==void 0)return m;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=f(/\\./,L),lt=f(/./,L),ct=f(/\*\*\*+/,"*"),ut=f(/([^/{[(!])\*\*/,(e,t)=>`${t}*`),pt=f(/(^|.)\*\*(?=[^*/)\]}])/,(e,t)=>`${t}*`),ft=de(A([at,ct,ut,pt,lt])),dt=ft,mt=a(e=>j(e,dt,{memoization:!1}).join(""),"Ie"),gt=mt,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"),b=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,m=n.length;u<m;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]}})(),N=a(()=>({regex:new RegExp("[\\\\/]","s"),children:[]}),"g"),yt=f(/\\./,b),$t=f(/[$.*+?^(){}[\]\|]/,e=>b(`\\${e}`)),wt=f(/[\\\/]/,N),vt=f(/[^$.*+?^(){}[\]\|\\\/]+/,b),bt=f(/^(?:!!)*!(.*)$/,(e,t)=>b(`(?!^${Le.compile(t).source}$).*?`)),jt=f(/^(!!)+/),Mt=A([bt,jt]),Et=f(/\/(\*\*\/)+/,()=>ee([H([N(),b(".+?"),N()]),N()])),kt=f(/^(\*\*\/)+/,()=>ee([b("^"),H([b(".*?"),N()])])),_t=f(/\/(\*\*)$/,()=>ee([H([N(),b(".*?")]),b("$")])),At=f(/\*\*/,()=>b(".*?")),De=A([Et,kt,_t,At]),Ot=f(/\*\/(?!\*\*\/|\*$)/,()=>H([b("[^\\\\/]*?"),N()])),St=f(/\*/,()=>b("[^\\\\/]*")),Ne=A([Ot,St]),Fe=f("?",()=>b("[^\\\\/]")),Rt=f("[",L),It=f("]",L),zt=f(/[!^]/,"^\\\\/"),Ct=f(/[a-z]-[a-z]|[0-9]-[0-9]/i,L),Pt=f(/\\./,L),Dt=f(/[$.*+?^(){}[\|]/,e=>`\\${e}`),Nt=f(/[\\\/]/,"\\\\/"),Ft=f(/[^$.*+?^(){}[\]\|\\\/]+/,L),Wt=A([Pt,Dt,Nt,Ct,Ft]),We=K([Rt,Se(zt),de(Wt),It],e=>b(e.join(""))),Bt=f("{","(?:"),Tt=f("}",")"),Jt=f(/(\d+)\.\.(\d+)/,(e,t,r)=>xt(+t,+r,Math.min(t.length,r.length)).join("|")),Lt=f(/([a-z]+)\.\.([a-z]+)/,(e,t,r)=>Pe(t,r).join("|")),Zt=f(/([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=>b(e.join(""))),qt=f("{"),Gt=f("}"),Vt=f(","),Kt=f(/\\./,b),Ht=f(/[$.*+?^(){[\]\|]/,e=>b(`\\${e}`)),Qt=f(/[\\\/]/,N),Xt=f(/[^$.*+?^(){}[\]\|\\\/,]+/,b),Yt=Ie(()=>Je),er=f("",()=>b("(?:)")),tr=nt(A([De,Ne,Fe,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([Mt,De,Ne,Fe,We,Be,Je,yt,$t,wt,vt]),H),nr=rr,or=a(e=>j(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(gt(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 E(C)})();return s.default||s},"_lazyMatch"),_e;const jr=a((s,i)=>(_e||(_e=Ke(),Ke=null),_e(s,i)),"zeptomatch"),Mr=/^[A-Z]:\//i,Z=a((s="")=>s&&s.replaceAll("\\","/").replace(Mr,i=>i.toUpperCase()),"normalizeWindowsPath"),Er=/^[/\\]{2}/,kr=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,Xe=/^[A-Z]:$/i,He=/^\/([A-Z]:)?$/i,_r=/.(\.[^./]+)$/,Ar=/^[/\\]|^[a-z]:[/\\]/i,Or=/\/$/,Sr=a(()=>typeof process.cwd=="function"?process.cwd().replaceAll("\\","/"):"/","cwd"),Ye=a((s,i)=>{let l="",c=0,d=-1,w=0,k;for(let E=0;E<=s.length;++E){if(E<s.length)k=s[E];else{if(k==="/")break;k="/"}if(k==="/"){if(!(d===E-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("/")),d=E,w=0;continue}else if(l.length>0){l="",c=0,d=E,w=0;continue}}i&&(l+=l.length>0?"/..":"..",c=2)}else l.length>0?l+=`/${s.slice(d+1,E)}`:l=s.slice(d+1,E),c=E-d-1;d=E,w=0}else k==="."&&w!==-1?++w:w=-1}return l},"normalizeString"),ae=a(s=>kr.test(s),"isAbsolute"),et=a(function(s){if(s.length===0)return".";s=Z(s);const i=Er.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)==="/",d=l[0]==="/";c&&d?i+=l.slice(1):i+=c||d?l:`/${l}`}else i+=l;return et(i)},"join");const me=a(function(...s){s=s.map(c=>Z(c));let i="",l=!1;for(let c=s.length-1;c>=-1&&!l;c--){const d=c>=0?s[c]:Sr();!d||d.length===0||(i=`${d}/${i}`,l=ae(d))}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 _r.exec(Z(s))?.[1]??""},"extname");a(function(s,i){const l=me(s).replace(He,"$1").split("/"),c=me(i).replace(He,"$1").split("/");if(c[0][1]===":"&&l[0][1]===":"&&l[0]!==c[0])return c.join("/");const d=[...l];for(const w of d){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?me(...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=me(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"),Nr=rt();var Fr=Object.defineProperty,Oe=ne((s,i)=>Fr(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",d=>l(d))}),"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 d;c?(d=c,se("[tsgo] using custom path",d)):(d=Br(),se("[tsgo] using tsgo from node_modules",d));const w=await mr(z.join(vr(),"rollup-plugin-dts-"));se("[tsgo] tsgoDist",w);const k=["--noEmit","false","--declaration","--emitDeclarationOnly",...i?["-p",i]:[],"--outDir",w,"--rootDir",s,"--noCheck",...l?["--declarationMap"]:[]];return se("[tsgo] args %o",k),await Wr(d,k,{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:d,exclude:w,include:k,incremental:E,newContext:C,oxc:U,parallel:le,sourcemap:q,tsconfig:G,tsconfigRaw:ge,tsgo:F,tsMacro:he,vue:xe})=>{const ce=k||w?yr(k,w):null,_=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 gr(B,{force:!0,recursive:!0}).catch(()=>{}),B=void 0,C&&(V=void 0)},async buildStart(x){if(F?B=await Tr(pe,G,q,F.path):U||(le?(W=fr(new URL(Lr,import.meta.url),{stdio:"inherit"}),P=(await import("birpc")).createBirpc({},{on:ie(g=>W.on("message",g),"on"),post:ie(g=>W.send(g),"post")})):(X=await import("../packem_chunks/index.js"),C&&(V=rt()))),!Array.isArray(x.input))for(const[g,h]of Object.entries(x.input)){I("resolving input alias %s -> %s",g,h);let p=await this.resolve(h);h.startsWith("./")||(p||=await this.resolve(`./${h}`));const $=p?.id||h;I("resolved input alias %s -> %s",h,$),ue.set($,g)}},generateBundle(x,g){for(const h of Object.keys(g)){const p=g[h];if(p){if(p.type==="asset"&&Ve.test(h)&&typeof p.source=="string"){const $=JSON.parse(p.source);$.names=[],delete $.sourcesContent,p.source=JSON.stringify($)}c&&p.type==="chunk"&&!S.test(h)&&!Ve.test(h)&&delete g[h]}}},load:{filter:{id:{exclude:[Me],include:[S]}},async handler(x){if(!_.has(x))return;const{code:g,id:h}=_.get(x);let p,$;if(I("generate dts %s from %s",x,h),F){if(Ee.test(h))throw new Error("tsgo does not support Vue files.");const v=z.resolve(B,z.relative(pe,Ue(h)));if(je(v)){if(p=await Ze(v,"utf8"),q){const j=`${v}.map`;je(j)&&($=JSON.parse(await Ze(j,"utf8")))}}else throw I("[tsgo]",v,"is missing"),new Error(`tsgo did not generate dts file for ${h}, please check your tsconfig.`)}else if(U&&!Ee.test(h)){const v=xr(h,g,U);if(v.errors.length>0){const[j]=v.errors;return this.error({frame:j?.codeframe||void 0,message:j?.codeframe?`${j.message}
2
- ${j.codeframe}`:j?.message??"Unknown error"})}p=v.code,v.map&&($=v.map,$.sourcesContent=void 0,$.names=[])}else{const v=l?void 0:[..._.values()].filter(R=>R.isEntry).map(R=>R.id),j={build:s,context:V,cwd:i,entries:v,id:h,incremental:E,sourcemap:q,tsconfig:G,tsconfigRaw:ge,tsMacro:he,vue:xe};let f;if(f=le?await P.tscEmit(j):X.tscEmit(j),f.error)return this.error(f.error);if(p=f.code,$=f.map,p&&qe.test(h))if(p.includes("declare const _exports")){if(p.includes("declare const _exports: {")&&!p.includes(`
3
- }[];`)){const R=Ur(p);let T=0;p+=R.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 R=Zr(p);p+=`
6
- declare namespace __json_default_export {
7
- export { ${Array.from(R.entries(),([T,J])=>T===J?T:`${J} as ${T}`).join(", ")} }
8
- }
9
- export { __json_default_export as default }`}}return{code:p||"",map:$}}},name:"rollup-plugin-dts:generate",outputOptions(x){return{...x,entryFileNames(g){const{entryFileNames:h}=x,p=$r(h||"[name].js",g);if(g.name.endsWith(".d")){if(S.test(p))return ke(p,g.name.slice(0,-2));if(oe.test(p))return p.replace(oe,".$1ts")}else if(c){if(g.facadeModuleId&&S.test(g.facadeModuleId)){if(S.test(p))return ke(p,g.name);if(oe.test(p))return p.replace(oe,".$1ts")}return ke("[name].js",g.name)}return p}}},async resolveId(x,g){if(_.has(x))return I("resolve dts id %s",x),{id:x};if(!g&&S.test(x)&&!Me.test(x)){const h=z.isAbsolute(x)?x:z.resolve(i,x),p=h.replace(S,""),$=[h.replace(S,".$1ts"),`${p}.tsx`,`${p}.ts`,`${p}.mts`,`${p}.cts`];if(!_.has(h)){for(const v of $)if(je(v)){const j=dr(v,"utf8");_.set(h,{code:j,id:v,isEntry:!0}),I("populated dtsMap from source for cached re-resolution: %s (via %s)",h,v);break}}return _.has(h)?(I("resolve dts id %s (from cache re-resolution)",h),{id:h}):null}if(g&&Ge.test(g)&&(x.startsWith("./")||x.startsWith("../"))&&!z.extname(x))for(const h of[".ts",".tsx",".mts",".cts"]){const p=await this.resolve(x+h,g,{skipSelf:!0});if(p)return p}return null},shouldTransformCachedModule({id:x}){return S.test(x)},transform:{handler(x,g){if(!(S.test(g)||Me.test(g)||ce&&!ce(g))){if(!oe.test(g)||d){const h=!!this.getModuleInfo(g)?.isEntry,p=Ue(g);if(_.set(p,{code:x,id:g,isEntry:h}),I("register dts source: %s",g),h){const $=ue.get(g);this.emitFile({id:p,name:$?`${$}.d`:void 0,type:"chunk"})}}return c?qe.test(g)?"{}":"export { }":Ge.test(g)||Ee.test(g)?hr(g,x,{}).code:null}},order:"pre"},watchChange(x){X&&Dr(V||Nr,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 d of c.declaration.declarations)d.id.type==="Identifier"&&i.set(d.id.name,d.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 d of c.specifiers)d.type==="ExportSpecifier"&&d.exported.type==="Identifier"&&i.set(d.exported.name,d.local.type==="Identifier"?d.local.name:d.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 d of c)d.key.type==="Identifier"?i.push(d.key.name):d.key.type==="StringLiteral"&&i.push(d.key.value);return i},"collectJsonExports");export{Ir as V,on as c,Nr as g};
@@ -1 +0,0 @@
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};
@@ -1,4 +0,0 @@
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;
@@ -1,14 +0,0 @@
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;
@@ -1,3 +0,0 @@
1
- import type { TscOptions, TscResult } from "./types.d.ts";
2
- declare const tscEmitBuild: (tscOptions: TscOptions) => TscResult;
3
- export default tscEmitBuild;
@@ -1,3 +0,0 @@
1
- import type { TscOptions, TscResult } from "./types.d.ts";
2
- declare const tscEmitCompiler: (tscOptions: TscOptions) => TscResult;
3
- export default tscEmitCompiler;
@@ -1,3 +0,0 @@
1
- import type { TscOptions, TscResult } from "./types.d.ts";
2
- export type { TscModule, TscOptions, TscResult } from "./types.d.ts";
3
- export declare const tscEmit: (tscOptions: TscOptions) => TscResult;
@@ -1,3 +0,0 @@
1
- import ts from "typescript";
2
- declare const tscResolve: (id: string, importer: string, cwd: string, tsconfig: string | undefined, tsconfigRaw: any, reference?: ts.ResolvedProjectReference) => string | undefined;
3
- export default tscResolve;
@@ -1,7 +0,0 @@
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;
@@ -1,26 +0,0 @@
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
- }
@@ -1,5 +0,0 @@
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;
@@ -1,4 +0,0 @@
1
- import type Ts from "typescript";
2
- import type { TscOptions } from "./types.d.ts";
3
- declare const createProgramFactory: (ts: typeof Ts, options: Pick<TscOptions, "vue" | "tsMacro">) => typeof Ts.createProgram;
4
- export default createProgramFactory;
@@ -1,6 +0,0 @@
1
- import { tscEmit } from "./index.d.ts";
2
- declare const functions: {
3
- tscEmit: typeof tscEmit;
4
- };
5
- type TscFunctions = typeof functions;
6
- export type { TscFunctions as default };
package/dist/tsgo.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export declare const getTsgoPathFromNodeModules: () => string;
2
- export declare const runTsgo: (rootDir: string, tsconfig?: string, sourcemap?: boolean, tsgoPath?: string) => Promise<string>;