@visulima/rollup-plugin-dts 1.0.0-alpha.23 → 1.0.0-alpha.24
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 +6 -0
- package/dist/index.js +1 -1
- package/dist/packem_chunks/index.js +1 -1
- package/dist/packem_shared/{createGeneratePlugin-DWAaoMPf.js → createGeneratePlugin-DF6d3tLz.js} +1 -1
- package/dist/packem_shared/generate-ufHefAw7.js +9 -0
- package/package.json +1 -1
- package/dist/packem_shared/generate-C7_nIfGu.js +0 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## @visulima/rollup-plugin-dts [1.0.0-alpha.24](https://github.com/visulima/packem/compare/@visulima/rollup-plugin-dts@1.0.0-alpha.23...@visulima/rollup-plugin-dts@1.0.0-alpha.24) (2026-04-24)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* **rollup-plugin-dts:** map cached `.d.ts` entries back to all source extensions ([5d8f670](https://github.com/visulima/packem/commit/5d8f670954806c6111eb90cff42e0faeef59dea1))
|
|
6
|
+
|
|
1
7
|
## @visulima/rollup-plugin-dts [1.0.0-alpha.23](https://github.com/visulima/packem/compare/@visulima/rollup-plugin-dts@1.0.0-alpha.22...@visulima/rollup-plugin-dts@1.0.0-alpha.23) (2026-04-24)
|
|
2
8
|
|
|
3
9
|
## @visulima/rollup-plugin-dts [1.0.0-alpha.22](https://github.com/visulima/packem/compare/@visulima/rollup-plugin-dts@1.0.0-alpha.21...@visulima/rollup-plugin-dts@1.0.0-alpha.22) (2026-04-24)
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var $=Object.defineProperty;var p=(t,e)=>$(t,"name",{value:e,configurable:!0});import{createDebug as T}from"obug";import C from"magic-string";import{RE_DTS as m,resolveTemplateFn as I,replaceTemplateName as R,RE_TS as J,RE_VUE as M,RE_JSON as U,RE_CSS as W,filename_to_dts as x,RE_NODE_MODULES as P,RE_JS as A,filename_js_to_dts as B}from"./filename.js";import{RE_DTS_MAP as he}from"./filename.js";import q from"./packem_shared/createFakeJsPlugin-DhesHehE.js";import{c as z}from"./packem_shared/generate-
|
|
1
|
+
var $=Object.defineProperty;var p=(t,e)=>$(t,"name",{value:e,configurable:!0});import{createDebug as T}from"obug";import C from"magic-string";import{RE_DTS as m,resolveTemplateFn as I,replaceTemplateName as R,RE_TS as J,RE_VUE as M,RE_JSON as U,RE_CSS as W,filename_to_dts as x,RE_NODE_MODULES as P,RE_JS as A,filename_js_to_dts as B}from"./filename.js";import{RE_DTS_MAP as he}from"./filename.js";import q from"./packem_shared/createFakeJsPlugin-DhesHehE.js";import{c as z}from"./packem_shared/generate-ufHefAw7.js";import{resolveOptions as G}from"./packem_shared/resolveOptions-Bp8RzeQ2.js";import g from"node:path";import{ResolverFactory as L}from"oxc-resolver";import{existsSync as D,readFileSync as V}from"node:fs";var H=Object.defineProperty,K=p((t,e)=>H(t,"name",{value:e,configurable:!0}),"o$1");const Q=K(({banner:t,footer:e})=>({name:"rollup-plugin-dts:banner",async renderChunk(n,a){if(!m.test(a.fileName))return;const i=new C(n);if(t){const u=await(typeof t=="function"?t(a):t);u&&i.prepend(`${u}
|
|
2
2
|
`)}if(e){const u=await(typeof e=="function"?e(a):e);u&&i.append(`
|
|
3
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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var q=Object.defineProperty;var h=(e,t)=>q(e,"name",{value:t,configurable:!0});import{createDebug as P}from"obug";import u from"typescript";import{g as F,V as N}from"../packem_shared/generate-
|
|
1
|
+
var q=Object.defineProperty;var h=(e,t)=>q(e,"name",{value:t,configurable:!0});import{createDebug as P}from"obug";import u from"typescript";import{g as F,V as N}from"../packem_shared/generate-ufHefAw7.js";import{posix as w}from"node:path";import{pathToFileURL as j}from"node:url";var T=Object.defineProperty,S=h((e,t)=>T(e,"name",{value:t,configurable:!0}),"i");const U=P("rollup-plugin-dts:tsc-system"),x=S(e=>({...u.sys,deleteFile(t,...r){e.delete(t),u.sys.deleteFile?.(t,...r)},directoryExists(t){return[...e.keys()].some(r=>r.startsWith(t))?!0:u.sys.directoryExists(t)},fileExists(t){return e.has(t)?!0:u.sys.fileExists(t)},readFile(t,...r){return e.has(t)?e.get(t):u.sys.readFile(t,...r)},resolvePath(t){return e.has(t)?t:u.sys.resolvePath(t)},write(t){U(t)},writeFile(t,r,...o){e.set(t,r),u.sys.writeFile(t,r,...o)}}),"createFsSystem"),B=S(e=>({...x(e),deleteFile(t){e.delete(t)},writeFile(t,r){e.set(t,r)}}),"createMemorySystem");var J=Object.defineProperty,$=h((e,t)=>J(e,"name",{value:t,configurable:!0}),"s$1");const W=$(e=>{const t=$(r=>u.isPropertySignature(r)&&u.isPrivateIdentifier(r.name)?e.factory.updatePropertySignature(r,r.modifiers,e.factory.createStringLiteral(r.name.text),r.questionToken,r.type):u.visitEachChild(r,t,e),"visitor");return r=>u.visitNode(r,t,u.isSourceFile)??r},"stripPrivateFields"),M={getCanonicalFileName:u.sys.useCaseSensitiveFileNames?e=>e:e=>e.toLowerCase(),getCurrentDirectory:$(()=>u.sys.getCurrentDirectory(),"getCurrentDirectory"),getNewLine:$(()=>u.sys.newLine,"getNewLine")},O={afterDeclarations:[W]},R=$((e,t,r)=>{if(!e||e.sourceRoot)return;const o=w.dirname(j(t).pathname),s=w.dirname(j(r).pathname);o!==s&&(e.sourceRoot=w.relative(s,o))},"setSourceMapRoot");var z=Object.defineProperty,m=h((e,t)=>z(e,"name",{value:t,configurable:!0}),"f$1");const g=P("rollup-plugin-dts:tsc-build"),H=m((e,t,r,o,s)=>{let i=e.projects.get(r);return i?(g(`skip building projects for ${r}`),i):(i=V(t,r,o,s),e.projects.set(r,i),i)},"getOrBuildProjects"),V=m((e,t,r,o)=>{g(`start building projects for ${t}`);const s=G(t,e,r,o);g("collected %d projects: %j",s.length,s.map(n=>n.tsconfigPath));const i=u.createSolutionBuilderHost(e,I),l=u.createSolutionBuilder(i,[t],{force:r,verbose:!0}).build(void 0,void 0,void 0,n=>(g(`transforming project ${n}`),O));g(`built solution for ${t} with exit status ${l}`);const a=new Map;for(const n of s)for(const c of n.parsedConfig.fileNames)a.set(e.resolvePath(c),n);return a},"buildProjects"),G=m((e,t,r,o)=>{const s=new Set,i=[],l=[t.resolvePath(e)];for(;;){const a=l.pop();if(!a)break;if(s.has(a))continue;s.add(a);const n=A(a,t);if(n){n.options=D(n.options,{force:r,sourcemap:o,tsconfigPath:a}),i.push({parsedConfig:n,tsconfigPath:a});for(const c of n.projectReferences??[])l.push(u.resolveProjectReferencePath(c))}}return i},"collectProjectGraph"),A=m((e,t)=>{const r=[],o=u.getParsedCommandLineOfConfigFile(e,void 0,{...t,onUnRecoverableConfigFileDiagnostic:m(s=>{r.push(s)},"onUnRecoverableConfigFileDiagnostic")});if(r.length>0)throw new Error(`[rollup-plugin-dts] Unable to read ${e}: ${u.formatDiagnostics(r,M)}`);return o},"parseTsconfig"),D=m((e,t)=>{const r=e.noEmit??!1,o=e.declaration??!!e.composite,s=e.declarationMap??!1,i=t?.tsconfigPath&&!t.force;return r===!0&&(e={...e,noEmit:!1},i&&console.warn(`[rollup-plugin-dts] ${t.tsconfigPath} has "noEmit" set to true. Please set it to false to generate declaration files.`)),o===!1&&(e={...e,declaration:!0},i&&console.warn(`[rollup-plugin-dts] ${t.tsconfigPath} has "declaration" set to false. Please set it to true to generate declaration files.`)),s===!1&&t?.sourcemap&&(e={...e,declarationMap:!0},i&&console.warn(`[rollup-plugin-dts] ${t.tsconfigPath} has "declarationMap" set to false. Please set it to true if you want to generate source maps for declaration files.`)),e},"patchCompilerOptions"),I=m((e,t,...r)=>u.createEmitAndSemanticDiagnosticsBuilderProgram(e,D(t??{},null),...r),"createProgramWithPatchedCompilerOptions"),L=m(e=>{const{context:t=F,id:r,incremental:o,sourcemap:s,tsconfig:i}=e;if(g(`running tscEmitBuild id: ${r}, tsconfig: ${i}, incremental: ${o}`),!i)return{error:"[rollup-plugin-dts] build mode requires a tsconfig path"};const l=(o?x:B)(t.files),a=l.resolvePath(r);a!==r&&g(`resolved id from ${r} to ${a}`);const n=H(t,l,i,!o,s).get(a);if(!n)return g(`unable to locate a project containing ${a}`),{error:`Unable to locate ${r} from the given tsconfig file ${i}`};g(`loaded project ${n.tsconfigPath} for ${r}`);const c=!l.useCaseSensitiveFileNames,f=u.getOutputFileNames(n.parsedConfig,a,c);let v,y;for(const d of f){if(d.endsWith(".d.ts")){if(!l.fileExists(d)){console.warn(`[rollup-plugin-dts] Unable to read file ${d}`);continue}v=l.readFile(d);continue}if(d.endsWith(".d.ts.map")){if(!l.fileExists(d))continue;const E=l.readFile(d);if(!E){console.warn(`[rollup-plugin-dts] Unexpected sourcemap ${d}`);continue}y=JSON.parse(E),R(y,d,a)}}return v?{code:v,map:y}:o?(g("incremental build failed"),L({...e,incremental:!1})):(g(`unable to build .d.ts file for ${r}`),n.parsedConfig.options.declaration!==!0?{error:`Unable to build .d.ts file for ${r}; Make sure the "declaration" option is set to true in ${n.tsconfigPath}`}:{error:`Unable to build .d.ts file for ${r}; This seems like a bug of rollup-plugin-dts. Please report this issue to https://github.com/sxzz/rollup-plugin-dts/issues`})},"tscEmitBuild");var K=Object.defineProperty,b=h((e,t)=>K(e,"name",{value:t,configurable:!0}),"g");const Y=b(()=>{const e=P("rollup-plugin-dts:vue");e("loading vue language tools");try{const t=require.resolve("vue-tsc"),{proxyCreateProgram:r}=require(require.resolve("@volar/typescript",{paths:[t]})),o=require(require.resolve("@vue/language-core",{paths:[t]}));return{getLanguagePlugin:b((s,i)=>{const l=i.options.$rootDir,a=i.options.$configRaw,n=new o.CompilerOptionsResolver(s,s.sys.readFile);n.addConfig(a?.vueCompilerOptions??{},l);const c=n.build();return o.createVueLanguagePlugin(s,i.options,c,f=>f)},"getLanguagePlugin"),proxyCreateProgram:r}}catch(t){throw e("vue language tools not found",t),new Error("Failed to load vue language tools. Please manually install vue-tsc.")}},"loadVueLanguageTools"),Q=b(()=>{const e=P("rollup-plugin-dts:ts-macro");e("loading ts-macro language tools");try{const t=require.resolve("@ts-macro/tsc"),{proxyCreateProgram:r}=require(require.resolve("@volar/typescript",{paths:[t]})),o=require(require.resolve("@ts-macro/language-plugin",{paths:[t]})),{getOptions:s}=require(require.resolve("@ts-macro/language-plugin/options",{paths:[t]}));return{getLanguagePlugin:b((i,l)=>{const a=l.options.$rootDir;return o.getLanguagePlugins(i,l.options,s(i,a))[0]},"getLanguagePlugin"),proxyCreateProgram:r}}catch(t){throw e("ts-macro language tools not found",t),new Error("Failed to load ts-macro language tools. Please manually install @ts-macro/tsc.")}},"loadTsMacro"),X=b((e,t)=>{const r=t.vue?Y():void 0,o=t.tsMacro?Q():void 0,s=r?.proxyCreateProgram||o?.proxyCreateProgram;return s?s(e,e.createProgram,(i,l)=>{const a=[];return r&&a.push(r.getLanguagePlugin(i,l)),o&&a.push(o.getLanguagePlugin(i,l)),{languagePlugins:a}}):e.createProgram},"createProgramFactory");var Z=Object.defineProperty,C=h((e,t)=>Z(e,"name",{value:t,configurable:!0}),"m");const p=P("rollup-plugin-dts:tsc-compiler"),_={checkJs:!1,declaration:!0,declarationMap:!1,emitDeclarationOnly:!0,moduleResolution:u.ModuleResolutionKind.Bundler,noEmit:!1,noEmitOnError:!0,resolveJsonModule:!0,skipLibCheck:!0,target:99},ee=C(e=>{const{context:t=F,entries:r,id:o}=e,s=t.programs.find(l=>{const a=l.getRootFileNames();return r?r.every(n=>a.includes(n)):a.includes(o)});if(s){const l=s.getSourceFile(o);if(l)return{file:l,program:s}}p(`create program for module: ${o}`);const i=te(e);return p(`created program for module: ${o}`),t.programs.push(i.program),i},"createOrGetTsModule"),te=C(({context:e=F,cwd:t,entries:r,id:o,tsconfig:s,tsconfigRaw:i,tsMacro:l,vue:a})=>{const n=x(e.files),c=s?N(s):t,f=u.parseJsonConfigFileContent(i,n,c);return p(`Creating program for root project: ${c}`),re({baseDir:c,entries:r,fsSystem:n,id:o,parsedConfig:f,tsMacro:l,vue:a})},"createTsProgram"),re=C(({baseDir:e,entries:t,fsSystem:r,id:o,parsedConfig:s,tsMacro:i,vue:l})=>{const a={..._,...s.options,$configRaw:s.raw,$rootDir:e},n=[...new Set([o,...t||s.fileNames].map(y=>r.resolvePath(y)))],c=u.createCompilerHost(a,!0),f=X(u,{tsMacro:i,vue:l})({host:c,options:a,projectReferences:s.projectReferences,rootNames:n}),v=f.getSourceFile(o);if(!v)throw p(`source file not found in program: ${o}`),s.projectReferences?.length?new Error(`[rollup-plugin-dts] Unable to load ${o}; You have "references" in your tsconfig file. Perhaps you want to add \`dts: { build: true }\` in your config?`):r.fileExists(o)?(p(`File ${o} exists on disk.`),new Error(`Unable to load file ${o} from the program. This seems like a bug of rollup-plugin-dts. Please report this issue to https://github.com/sxzz/rollup-plugin-dts/issues`)):(p(`File ${o} does not exist on disk.`),new Error(`Source file not found: ${o}`));return{file:v,program:f}},"createTsProgramFromParsedConfig"),oe=C(e=>{p(`running tscEmitCompiler ${e.id}`);const t=ee(e),{file:r,program:o}=t;p(`got source file: ${r.fileName}`);let s,i;const{diagnostics:l,emitSkipped:a}=o.emit(r,(n,c)=>{n.endsWith(".map")?(p(`emit dts sourcemap: ${n}`),i=JSON.parse(c),R(i,n,e.id)):(p(`emit dts: ${n}`),s=c)},void 0,!0,O,!0);return a&&l.length>0?{error:u.formatDiagnostics(l,M)}:(!s&&r.isDeclarationFile&&(p("nothing was emitted. fallback to sourceFile text."),s=r.getFullText()),{code:s,map:i})},"tscEmitCompiler");var se=Object.defineProperty,ie=h((e,t)=>se(e,"name",{value:t,configurable:!0}),"r");const k=P("rollup-plugin-dts:tsc");k(`loaded typescript: ${u.version}`);const pe=ie(e=>(k(`running tscEmit ${e.id}`),e.build?L(e):oe(e)),"tscEmit");export{pe as tscEmit};
|
package/dist/packem_shared/{createGeneratePlugin-DWAaoMPf.js → createGeneratePlugin-DF6d3tLz.js}
RENAMED
|
@@ -1 +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-
|
|
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};
|
|
@@ -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 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};
|
package/package.json
CHANGED
|
@@ -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 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};
|