@visulima/rollup-plugin-dts 1.0.0-alpha.3 → 1.0.0-alpha.30
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 +153 -0
- package/dist/filename.d.ts +2 -17
- package/dist/filename.js +1 -1
- package/dist/index.d.ts +98 -43
- package/dist/index.js +3 -3
- package/dist/packem_chunks/index.js +1 -1
- package/dist/packem_chunks/resolver.js +1 -1
- package/dist/packem_shared/createFakeJsPlugin-BmWTsDfe.js +3 -0
- package/dist/packem_shared/createGeneratePlugin-B0-c7yPx.js +1 -0
- package/dist/packem_shared/filename.d-BqANlmrG.d.ts +833 -0
- package/dist/packem_shared/generate-JArF6z_0.js +9 -0
- package/dist/packem_shared/resolveOptions-xvkhsYiy.js +1 -0
- package/package.json +16 -14
- package/dist/packem_shared/createFakeJsPlugin-C_PkEz9j.js +0 -1
- package/dist/packem_shared/createGeneratePlugin-BgPgGC2n.js +0 -1
- package/dist/packem_shared/generate-CxhgFvNH.js +0 -9
- package/dist/packem_shared/resolveOptions-CpYBT-5y.js +0 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
var pe=Object.defineProperty;var O=(a,s)=>pe(a,"name",{value:s,configurable:!0});import{spawn as de,fork as ue}from"node:child_process";import{existsSync as A,readFileSync as fe}from"node:fs";import{mkdtemp as me,readFile as Q,rm as ge}from"node:fs/promises";import d from"node:path";import{parse as te}from"@babel/parser";import{createFilter as ye}from"@rollup/pluginutils";import{createDebug as J}from"obug";import{transformSync as he,isolatedDeclarationSync as ve}from"oxc-transform";import{RE_DTS as m,RE_NODE_MODULES as C,RE_JS as _,filenameToDts as X,RE_JSON as Y,RE_TS as Z,RE_VUE as P,resolveTemplateFunction as xe,replaceTemplateName as T,RE_DTS_MAP as ee}from"../filename.js";import{resolve as we}from"@visulima/path";import{createRequire as Ee}from"node:module";import{tmpdir as be}from"node:os";var _e=Object.defineProperty,re=O((a,s)=>_e(a,"name",{value:s,configurable:!0}),"o");const $e=J("rollup-plugin-dts:tsc-context"),oe=re(()=>({files:new Map,programs:[],projects:new Map}),"createContext"),Me=re((a,s)=>{const p=we(s).replaceAll("\\","/");$e(`invalidating context file: ${p}`),a.files.delete(p),a.programs=a.programs.filter(n=>!n.getSourceFiles().some(i=>i.fileName===p)),a.projects.clear()},"invalidateContextFile"),Se=oe();var je=Object.defineProperty,I=O((a,s)=>je(a,"name",{value:s,configurable:!0}),"n");const $=J("rollup-plugin-dts:tsgo"),ke=I(async(...a)=>{await new Promise((s,p)=>{const n=de(...a);n.on("close",()=>{s()}),n.on("error",i=>{p(i)})})},"spawnAsync"),Oe=I(()=>{const a=Ee(import.meta.url),s=a.resolve("@typescript/native-preview/package.json"),p=d.dirname(s),n=a(d.join(p,"lib","getExePath.js")),i=typeof n=="function"?n:n.default;if(!i)throw new Error("Failed to resolve getExePath from @typescript/native-preview");return i()},"getTsgoPathFromNodeModules"),De=I(async(a,s,p,n)=>{$("[tsgo] rootDir",a);let i;n?(i=n,$("[tsgo] using custom path",i)):(i=Oe(),$("[tsgo] using tsgo from node_modules",i));const x=await me(d.join(be(),"rollup-plugin-dts-"));$("[tsgo] tsgoDist",x);const w=["--noEmit","false","--declaration","--emitDeclarationOnly",...s?["-p",s]:[],"--outDir",x,"--rootDir",a,"--noCheck",...p?["--declarationMap"]:[]];return $("[tsgo] args %o",w),await ke(i,w,{stdio:"inherit"}),x},"runTsgo");var Re=Object.defineProperty,M=O((a,s)=>Re(a,"name",{value:s,configurable:!0}),"x");const h=J("rollup-plugin-dts:generate"),Fe=import.meta.WORKER_URL??"./tsc/worker.js",ze=M(({build:a,cwd:s,eager:p,emitDtsOnly:n,emitJs:i,entry:x,exclude:w,include:U,incremental:se,newContext:W,oxc:D,parallel:G,sourcemap:R,tsconfig:S,tsconfigRaw:ie,tsgo:F,tsMacro:ne,vue:ae})=>{const L=U||w?ye(U,w):null,le=x?.filter(o=>o[0]!=="!"),ce=x?.filter(o=>o[0]==="!").map(o=>o.slice(1)),B=x?o=>{const e=o.split(d.sep).join("/");return le.some(r=>d.posix.matchesGlob(e,r))&&!ce.some(r=>d.posix.matchesGlob(e,r))}:void 0,v=new Map,V=new Map;let j,K,N,k,E;const q=S?d.dirname(S):s;return{async buildEnd(){j?.kill(),!h.enabled&&E&&await ge(E,{force:!0,recursive:!0}).catch(()=>{}),E=void 0,W&&(k=void 0)},async buildStart(o){if(F?E=await De(q,S,R,F.path):D||(G?(j=ue(new URL(Fe,import.meta.url),{stdio:"inherit"}),K=(await import("birpc")).createBirpc({},{on:M(e=>j.on("message",e),"on"),post:M(e=>j.send(e),"post")})):(N=await import("../packem_chunks/index.js"),W&&(k=oe()))),!Array.isArray(o.input))for(const[e,r]of Object.entries(o.input)){h("resolving input alias %s -> %s",e,r);let t=await this.resolve(r);r.startsWith("./")||(t||=await this.resolve(`./${r}`));const c=t?.id||r;h("resolved input alias %s -> %s",r,c),V.set(c,e)}},generateBundle(o,e){for(const r of Object.keys(e)){const t=e[r];if(t){if(t.type==="asset"&&ee.test(r)&&typeof t.source=="string"){const c=JSON.parse(t.source);c.names=[],delete c.sourcesContent,t.source=JSON.stringify(c)}n&&t.type==="chunk"&&!m.test(r)&&!ee.test(r)&&delete e[r]}}},load:{filter:{id:{exclude:[C],include:[m]}},async handler(o){if(!v.has(o))return;const{code:e,id:r}=v.get(o);let t,c;if(h("generate dts %s from %s",o,r),F){if(P.test(r))throw new Error("tsgo does not support Vue files.");const l=d.resolve(E,d.relative(q,X(r)));if(A(l)){if(t=await Q(l,"utf8"),R){const u=`${l}.map`;if(A(u)){const f=JSON.parse(await Q(u,"utf8"));if(Array.isArray(f.sources)){const g=d.dirname(u);f.sources=f.sources.map(y=>y==null?y:d.resolve(g,y))}c=f}}}else throw h("[tsgo]",l,"is missing"),new Error(`tsgo did not generate dts file for ${r}, please check your tsconfig.`)}else if(D&&!P.test(r)){const l=ve(r,e,D);if(l.errors.length>0){const[u]=l.errors;return this.error({frame:u?.codeframe||void 0,message:u?.codeframe?`${u.message}
|
|
2
|
+
${u.codeframe}`:u?.message??"Unknown error"})}t=l.code,l.map&&(c=l.map,c.sourcesContent=void 0,c.names=[])}else{const l=p?void 0:[...v.values()].filter(g=>g.isEntry).map(g=>g.id),u={build:a,context:k,cwd:s,entries:l,id:r,incremental:se,sourcemap:R,tsconfig:S,tsconfigRaw:ie,tsMacro:ne,vue:ae};let f;if(f=G?await K.tscEmit(u):N.tscEmit(u),f.error)return this.error(f.error);if(t=f.code,c=f.map,t&&Y.test(r))if(t.includes("declare const _exports")){if(t.includes("declare const _exports: {")&&!t.includes(`
|
|
3
|
+
}[];`)){const g=Ae(t);let y=0;t+=g.map(b=>{const z=`_${b.replaceAll(/[^\w$]/g,"_")}${y++}`,H=JSON.stringify(b);return`declare let ${z}: typeof _exports[${H}]
|
|
4
|
+
export { ${z} as ${H} }`}).join(`
|
|
5
|
+
`)}}else{const g=Ne(t);t+=`
|
|
6
|
+
declare namespace __json_default_export {
|
|
7
|
+
export { ${Array.from(g.entries(),([y,b])=>y===b?y:`${b} as ${y}`).join(", ")} }
|
|
8
|
+
}
|
|
9
|
+
export { __json_default_export as default }`}}return{code:t||"",map:c}}},name:"rollup-plugin-dts:generate",outputOptions(o){return{...o,entryFileNames(e){const{entryFileNames:r}=o,t=xe(r||"[name].js",e);if(e.name.endsWith(".d")){if(m.test(t))return T(t,e.name.slice(0,-2));if(_.test(t))return t.replace(_,".$1ts")}else if(n){if(e.facadeModuleId&&m.test(e.facadeModuleId)){if(m.test(t))return T(t,e.name);if(_.test(t))return t.replace(_,".$1ts")}return T("[name].js",e.name)}return t}}},async resolveId(o,e){if(v.has(o))return h("resolve dts id %s",o),{id:o};if(!e&&m.test(o)&&!C.test(o)){const r=d.isAbsolute(o)?o:d.resolve(s,o),t=r.replace(m,""),c=[r.replace(m,".$1ts"),`${t}.tsx`,`${t}.ts`,`${t}.mts`,`${t}.cts`];if(!v.has(r)){for(const l of c)if(A(l)){const u=fe(l,"utf8");v.set(r,{code:u,id:l,isEntry:!0}),h("populated dtsMap from source for cached re-resolution: %s (via %s)",r,l);break}}return v.has(r)?(h("resolve dts id %s (from cache re-resolution)",r),{id:r}):null}if(e&&Z.test(e)&&(o.startsWith("./")||o.startsWith("../"))&&!d.extname(o))for(const r of[".ts",".tsx",".mts",".cts"]){const t=await this.resolve(o+r,e,{skipSelf:!0});if(t)return t}return null},shouldTransformCachedModule({id:o}){return m.test(o)},transform:{handler(o,e){if(!(m.test(e)||C.test(e)||L&&!L(e))){if(!_.test(e)||i){const r=!!this.getModuleInfo(e)?.isEntry,t=B?r&&B(d.relative(s,e)):r,c=X(e);if(v.set(c,{code:o,id:e,isEntry:t}),h("register dts source: %s",e),t){const l=V.get(e);this.emitFile({id:c,name:l?`${l}.d`:void 0,type:"chunk"})}}return n?Y.test(e)?"{}":"export { }":Z.test(e)||P.test(e)?he(e,o,{}).code:null}},order:"pre"},watchChange(o){N&&Me(k||Se,o)}}},"createGeneratePlugin"),Ne=M(a=>{const s=new Map,{program:p}=te(a,{errorRecovery:!0,plugins:[["typescript",{dts:!0}]],sourceType:"module"});for(const n of p.body)if(n.type==="ExportNamedDeclaration"){if(n.declaration)if(n.declaration.type==="VariableDeclaration")for(const i of n.declaration.declarations)i.id.type==="Identifier"&&s.set(i.id.name,i.id.name);else n.declaration.type==="TSModuleDeclaration"&&n.declaration.id.type==="Identifier"&&s.set(n.declaration.id.name,n.declaration.id.name);else if(n.specifiers.length>0)for(const i of n.specifiers)i.type==="ExportSpecifier"&&i.exported.type==="Identifier"&&s.set(i.exported.name,i.local.type==="Identifier"?i.local.name:i.exported.name)}return s},"collectJsonExportMap"),Ae=M(a=>{const s=[],{program:p}=te(a,{plugins:[["typescript",{dts:!0}]],sourceType:"module"}),n=p.body[0].declarations[0].id.typeAnnotation.typeAnnotation.members;for(const i of n)i.key.type==="Identifier"?s.push(i.key.name):i.key.type==="StringLiteral"&&s.push(i.key.value);return s},"collectJsonExports");export{ze as c,Se as g};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var X=Object.defineProperty;var O=(e,t)=>X(e,"name",{value:t,configurable:!0});import{existsSync as Y}from"node:fs";import{createRequire as Z}from"node:module";import m from"node:path";import I from"node:process";import{findTsConfigSync as _,readTsConfig as H}from"@visulima/tsconfig";import C from"typescript";var K=Object.defineProperty,r=O((e,t)=>K(e,"name",{value:t,configurable:!0}),"i");let E=!1;const N=r(e=>e?e.incremental===!1?-1:e.incremental===!0||typeof e.tsBuildInfoFile=="string"?1:0:0,"checkCompilerOptionsIncremental"),Q=r((e,t)=>{if(e.startsWith("."))return m.resolve(t,e.endsWith(".json")?e:`${e}.json`);try{return Z(m.join(t,"package.json")).resolve(e)}catch{return}},"resolveExtendedTsconfigPath"),U=r(e=>{if(Y(e))return C.sys.readFile(e)},"readTsconfigFile"),P=r((e,t=new Set)=>{if(t.has(e))return!1;t.add(e);const o=C.readConfigFile(e,U);if(o.error||!o.config)return!1;const i=o.config,n=N(i.compilerOptions);if(n!==0)return n===1;if(!i.extends)return!1;const s=Array.isArray(i.extends)?i.extends:[i.extends],g=m.dirname(e);for(const a of s){if(typeof a!="string")continue;const f=Q(a,g);if(f&&P(f,t))return!0}return!1},"hasExplicitIncrementalInTsconfig"),ee=r((e,t)=>{if(e===!0||e===void 0)try{const o=_(t);return{resolvedTsconfig:o.config,tsconfig:o.path}}catch{return{resolvedTsconfig:void 0,tsconfig:void 0}}if(typeof e=="string"){const o=m.resolve(t||I.cwd(),e);return{resolvedTsconfig:H(o),tsconfig:o}}return{resolvedTsconfig:void 0,tsconfig:void 0}},"resolveTsconfigPath"),te=r((e,t,o,i)=>{if(e){if(t)throw new Error("[@visulima/rollup-plugin-dts] The `tsgo` option is not compatible with the `vue` option. Please disable one of them.");if(o)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"),oe=r((e,t,o)=>{if(e){if(t)throw new Error("[@visulima/rollup-plugin-dts] The `oxc` option is not compatible with the `vue` option. Please disable one of them.");if(o)throw new Error("[@visulima/rollup-plugin-dts] The `oxc` option is not compatible with the `tsMacro` option. Please disable one of them.")}},"validateOxcCompatibility"),ie=r(e=>e===!1?!1:e===!0?{}:e.enabled===!1?!1:{path:e.path},"normalizeTsgo"),se=r((e,t,o,i,n)=>{let s;switch(e){case!1:{s=!1;break}case!0:{s={};break}case void 0:{s=t.isolatedDeclarations&&!o&&!i&&!n?{}:!1;break}default:s=e}return s&&(s.stripInternal??=t.stripInternal??!1,s.sourcemap=t.declarationMap??!1),s},"normalizeOxc"),ue=r(({banner:e,build:t=!1,cjsDefault:o=!1,compilerOptions:i={},cwd:n=I.cwd(),dtsInput:s=!1,eager:g=!1,emitDtsOnly:a=!1,emitJs:f,entry:c,exclude:j,footer:k,include:M,incremental:D=!1,newContext:F=!1,oxc:A,parallel:J=!1,resolve:R=!1,resolver:z="oxc",sideEffects:S=!1,sourcemap:W,tsconfig:B,tsconfigRaw:$={},tsgo:q=!1,tsMacro:p=!1,vue:u=!1})=>{const{resolvedTsconfig:w,tsconfig:h}=ee(B,n),b=i,l={...w?.compilerOptions,...i},G=D||b.incremental===!0||typeof b.tsBuildInfoFile=="string"||typeof h=="string"&&P(h),y=W??!!l.declarationMap;l.declarationMap=y;let x;if(c!==void 0){const T=Array.isArray(c)?c:[c];x=T.length>0?T:void 0}const L={...w,...$,compilerOptions:l},d=ie(q),v=se(A,l,u,d,p),V=f??!!(l.checkJs||l.allowJs);return te(d,u,p,v),oe(v,u,p),d&&!E&&(console.warn("The `tsgo` option is experimental and may change in the future."),E=!0),{banner:e,build:t,cjsDefault:o,cwd:n,dtsInput:s,eager:g,emitDtsOnly:a,emitJs:V,entry:x,exclude:j,footer:k,include:M,incremental:G,newContext:F,oxc:v,parallel:J,resolve:R,resolver:z,sideEffects:S,sourcemap:y,tsconfig:h,tsconfigRaw:L,tsgo:d,tsMacro:p,vue:u}},"resolveOptions");export{ue 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.
|
|
3
|
+
"version": "1.0.0-alpha.30",
|
|
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.
|
|
44
|
+
"types": "./dist/filename.d.ts",
|
|
45
45
|
"default": "./dist/filename.js"
|
|
46
46
|
},
|
|
47
47
|
"./package.json": "./package.json"
|
|
@@ -52,24 +52,26 @@
|
|
|
52
52
|
"dist"
|
|
53
53
|
],
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@babel/generator": "7.29.
|
|
56
|
-
"@babel/helper-validator-identifier": "7.
|
|
57
|
-
"@babel/parser": "7.29.
|
|
58
|
-
"@babel/types": "7.29.
|
|
59
|
-
"@
|
|
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
|
+
"@rollup/pluginutils": "5.4.0",
|
|
60
|
+
"@visulima/path": "3.0.0-alpha.10",
|
|
61
|
+
"@visulima/tsconfig": "3.0.0-alpha.24",
|
|
60
62
|
"ast-kit": "^2.2.0",
|
|
61
63
|
"birpc": "^4.0.0",
|
|
62
64
|
"magic-string": "0.30.21",
|
|
63
65
|
"obug": "2.1.1",
|
|
64
|
-
"oxc-resolver": "11.
|
|
65
|
-
"oxc-transform": "0.
|
|
66
|
+
"oxc-resolver": "11.20.0",
|
|
67
|
+
"oxc-transform": "0.133.0"
|
|
66
68
|
},
|
|
67
69
|
"peerDependencies": {
|
|
68
70
|
"@ts-macro/tsc": "0.3.7",
|
|
69
71
|
"@typescript/native-preview": ">=7.0.0-dev.20250601.1",
|
|
70
|
-
"rollup": ">=4.
|
|
71
|
-
"typescript": "^
|
|
72
|
-
"vue-tsc": "3.
|
|
72
|
+
"rollup": ">=4.61.0",
|
|
73
|
+
"typescript": "^6.0.3",
|
|
74
|
+
"vue-tsc": "3.3.3"
|
|
73
75
|
},
|
|
74
76
|
"peerDependenciesMeta": {
|
|
75
77
|
"@typescript/native-preview": {
|
|
@@ -86,7 +88,7 @@
|
|
|
86
88
|
}
|
|
87
89
|
},
|
|
88
90
|
"engines": {
|
|
89
|
-
"node": ">=
|
|
91
|
+
"node": "^22.14.0 || >= 24.10.0"
|
|
90
92
|
},
|
|
91
93
|
"publishConfig": {
|
|
92
94
|
"access": "public",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var xe=Object.defineProperty;var D=(e,n)=>xe(e,"name",{value:n,configurable:!0});import X from"node:path";import{generate as Y}from"@babel/generator";import{isIdentifierName as ge}from"@babel/helper-validator-identifier";import{parse as Z}from"@babel/parser";import f from"@babel/types";import{isTypeOf as C,isDeclarationType as Se,walkAST as V,resolveString as B,isIdentifierOf as ie}from"ast-kit";import{RE_DTS as _,resolveTemplateFn as he,filename_js_to_dts as ee,replaceTemplateName as te,filename_dts_to as ne,RE_DTS_MAP as Ee,filename_to_dts as be}from"../filename.js";var De=Object.defineProperty,S=D((e,n)=>De(e,"name",{value:n,configurable:!0}),"o");const $="__rollup_dts_resolve__:",We=S(({cjsDefault:e,sideEffects:n,sourcemap:g})=>{let r=0;const T=new Map,N=new Map,A=new Map;return{generateBundle(s,o){const d=new Map;for(const i of Object.values(o))if(i.type==="chunk")for(const u of i.moduleIds)d.set(u,i.fileName);const c=new RegExp(`"${$}(.+?)"`,"g");for(const i of Object.values(o))i.type!=="chunk"||!_.test(i.fileName)||i.code.includes($)&&(i.code=i.code.replaceAll(c,(u,E)=>{const a=d.get(E);if(!a)return u;let y=X.posix.relative(X.posix.dirname(i.fileName),a);return y.startsWith(".")||(y=`./${y}`),y=ne(y,"js"),JSON.stringify(y)}));for(const i of Object.values(o))if(Ee.test(i.fileName))if(g){if(i.type==="chunk"||typeof i.source!="string")continue;const u=JSON.parse(i.source);u.sourcesContent=void 0,i.source=JSON.stringify(u)}else delete o[i.fileName]},name:"rollup-plugin-dts:fake-js",outputOptions(s){const{chunkFileNames:o,entryFileNames:d}=s;return(s.format==="cjs"||s.format==="commonjs")&&(s={...s,format:"es"}),{...s,chunkFileNames(c){const i=he(c.isEntry?d||"[name].js":o||"[name]-[hash].js",c);if(c.name.endsWith(".d")){const u=ee(te(i,c.name.slice(0,-2)));if(_.test(u))return u;const E=ee(te(i,c.name));if(_.test(E))return E}return i},sourcemap:s.sourcemap||g}},renderChunk:j,async transform(s,o){if(_.test(o))return O.call(this,s,o)}};async function O(s,o){const d=Object.create(null),c=Z(s,{createParenthesizedExpressions:!0,errorRecovery:!0,plugins:[["typescript",{dts:!0}]],sourceType:"module"}),{comments:i,program:u}=c,E=[];if(i){const m=ae(i);N.set(o,m)}const a=[],y=new Map;for(const[m,t]of u.body.entries()){const v=S(l=>u.body[m]=l,"setStmt");if(Me(t,v,E))continue;const h=t.type==="TSModuleDeclaration"&&t.kind!=="namespace";let b;if(h&&t.id.type==="StringLiteral"){const l=await this.resolve(t.id.value,o);l&&!l.external?b=_.test(l.id)?l.id:be(l.id):t.id.value[0]==="."&&this.warn(`\`declare module ${JSON.stringify(t.id.value)}\` will be kept as-is in the output. Relative module declaration may cause unexpected issues. Found in ${o}.`)}if(h&&o.endsWith(".vue.d.ts")&&s.slice(t.start,t.end).includes("__VLS_"))continue;const k=t.type==="ExportDefaultDeclaration",R=C(t,["ExportNamedDeclaration","ExportDefaultDeclaration"])&&t.declaration,p=R?t.declaration:t,I=R?l=>t.declaration=l:v;if(p.type!=="TSDeclareFunction"&&!Se(p))continue;C(p,["TSEnumDeclaration","ClassDeclaration","FunctionDeclaration","TSDeclareFunction","TSModuleDeclaration","VariableDeclaration"])&&(p.declare=!0);const x=[];if(p.type==="VariableDeclaration")x.push(...p.declarations.map(l=>l.id));else if("id"in p&&p.id){let l=p.id;l.type==="TSQualifiedName"&&(l=W(l)),l=h?f.identifier(`_${P(d,"")}`):l,x.push(l)}else{const l=f.identifier("export_default");x.push(l),p.id=l}const F=pe(p),J=new Set,L=de(p,y,J,d),Q=[...J].filter(l=>x.every(ye=>l!==ye));p!==t&&(p.leadingComments=t.leadingComments);const ue=K({bindings:x,children:Q,decl:p,deps:L,params:F,resolvedModuleId:b}),q=f.numericLiteral(ue),z=f.arrowFunctionExpression(F.map(({name:l})=>f.identifier(l)),f.arrayExpression(L)),H=f.arrayExpression(Q.map(l=>({end:l.end,loc:l.loc,start:l.start,type:"StringLiteral",value:""}))),U=h&&f.callExpression(f.identifier("sideEffect"),[x[0]]),me=Ne(U?[q,z,H,U]:[q,z,H]),G={declarations:[{id:{...x[0],typeAnnotation:null},init:me,type:"VariableDeclarator"},...x.slice(1).map(l=>({id:{...l,typeAnnotation:null},type:"VariableDeclarator"}))],kind:"var",type:"VariableDeclaration"};k?(a.push(f.exportNamedDeclaration(null,[f.exportSpecifier(x[0],f.identifier("default"))])),v(G)):I(G)}return n&&a.push(f.expressionStatement(f.callExpression(f.identifier("sideEffect"),[]))),u.body=[...Array.from(y.values(),({stmt:m})=>m),...u.body,...a],A.set(o,E),Y(c,{comments:!1,sourceFileName:o,sourceMaps:g})}function j(s,o){if(!_.test(o.fileName))return;const d=[];for(const a of o.moduleIds){const y=A.get(a);y&&d.push(...y)}const c=Z(s,{sourceType:"module"}),{program:i}=c;if(i.body=Ce(i.body),i.body=ke(i.body),i.body=i.body.map(a=>{if(je(a)||a.type==="ExpressionStatement")return null;const y=we(a,d,e);if(y||y===!1)return y;if(a.type!=="VariableDeclaration")return a;if(!ve(a))return null;const[m,t,v]=a.declarations[0].init.elements,h=m.value,b=le(h);V(b.decl,{enter(p){p.type!=="CommentBlock"&&delete p.loc}});for(const[p,I]of a.declarations.entries()){const x={...I.id,typeAnnotation:b.bindings[p].typeAnnotation};M(b.bindings[p],x)}for(const[p,I]of v.elements.entries())Object.assign(b.children[p],{loc:I.loc});const k=t.params;for(const[p,I]of k.entries()){const x=I.name;for(const F of b.params[p].typeParams)F.name=x}const R=t.body.elements;for(let p=0;p<b.deps.length;p++){const I=b.deps[p];let x=R[p];x&&x.type==="UnaryExpression"&&x.operator==="void"&&(x={...f.identifier("undefined"),end:x.end,loc:x.loc,start:x.start}),I.replace?I.replace(x):Object.assign(I,x)}return b.decl.type==="TSModuleDeclaration"&&b.resolvedModuleId&&(b.decl.id.value=$+b.resolvedModuleId),Ae(a,b.decl)}).filter(a=>!!a),i.body.length===0)return"export { };";const u=new Set,E=new Set;for(const a of o.moduleIds){const y=N.get(a);y&&(y.forEach(m=>{const t=m.type+m.value;E.has(t)||(E.add(t),u.add(m))}),N.delete(a))}return u.size>0&&(i.body[0].leadingComments||=[],i.body[0].leadingComments.unshift(...u)),Y(c,{comments:!0,sourceFileName:o.fileName,sourceMaps:g})}function P(s,o){return o in s?s[o]++:s[o]=0}function K(s){const o=r++;return T.set(o,s),o}function le(s){return T.get(s)}function pe(s){const o=[];V(s,{leave(c){"typeParameters"in c&&c.typeParameters?.type==="TSTypeParameterDeclaration"&&o.push(...c.typeParameters.params)}});const d=new Map;for(const c of o){const{name:i}=c,u=d.get(i);u?u.push(c):d.set(i,[c])}return Array.from(d.entries(),([c,i])=>({name:c,typeParams:i}))}function ce(s){const o=[];return V(s,{enter(d){d.type==="TSInferType"&&d.typeParameter&&o.push(d.typeParameter.name)}}),o}function de(s,o,d,c){const i=new Set,u=new Set,E=[];let a=new Set;function y(t){return t.type==="Identifier"&&a.has(t.name)}return D(y,"l"),S(y,"isInferred"),V(s,{enter(t){if(t.type==="TSConditionalType"){const v=ce(t.extendsType);E.push(v)}},leave(t,v){if(t.type==="TSConditionalType")E.pop();else if(v?.type==="TSConditionalType"){const h=v.trueType===t;a=new Set((h?E:E.slice(0,-1)).flat())}else a=new Set;if(t.type==="ExportNamedDeclaration")for(const h of t.specifiers)h.type==="ExportSpecifier"&&m(h.local);else if(t.type==="TSInterfaceDeclaration"&&t.extends)for(const h of t.extends||[])m(w(h.expression));else if(t.type==="ClassDeclaration"){if(t.superClass&&m(t.superClass),t.implements)for(const h of t.implements)h.type!=="ClassImplements"&&m(w(h.expression))}else if(C(t,["ObjectMethod","ObjectProperty","ClassProperty","TSPropertySignature","TSDeclareMethod"]))t.computed&&re(t.key)&&m(t.key),"value"in t&&re(t.value)&&m(t.value);else switch(t.type){case"TSImportType":{u.add(t);const h=t.argument,b=t.qualifier,k=fe(t,b,h,o,c);m(k);break}case"TSTypeQuery":{if(u.has(t.exprName))return;if(t.exprName.type==="TSImportType")break;m(w(t.exprName));break}case"TSTypeReference":{m(w(t.typeName));break}}v&&!i.has(t)&&oe(t,v)&&d.add(t)}}),[...i];function m(t){se(t)||y(t)||i.add(t)}D(m,"S")}function fe(s,o,d,c,i){const u=d.value.replaceAll(/\W/g,"_"),E=ge(d.value)?d.value:`${u}${P(i,u)}`;let a=f.identifier(E);if(c.has(d.value)?a=c.get(d.value).local:c.set(d.value,{local:a,stmt:f.importDeclaration([f.importNamespaceSpecifier(a)],d)}),o){const m=W(o);M(m,f.tsQualifiedName(a,{...m})),a=o}let y=s;return s.typeParameters?(M(s,f.tsTypeReference(a,s.typeParameters)),y=a):M(s,a),{...w(a),replace(m){M(y,m)}}}},"createFakeJsPlugin");function oe(e,n){return!!(e.type==="Identifier"||C(n,["TSPropertySignature","TSMethodSignature"])&&n.key===e)}D(oe,"De");S(oe,"isChildSymbol");const Te=/\/\s*<reference\s+(?:path|types)=/,ae=S((e,n=!1)=>e.filter(g=>Te.test(g.value)!==n),"collectReferenceDirectives"),ve=S(e=>f.isVariableDeclaration(e)&&e.declarations.length>0&&f.isVariableDeclarator(e.declarations[0])&&Ie(e.declarations[0].init),"isRuntimeBindingVariableDeclaration"),Ie=S(e=>f.isArrayExpression(e)&&_e(e.elements),"isRuntimeBindingArrayExpression"),Ne=S(e=>f.arrayExpression(e),"runtimeBindingArrayExpression"),_e=S(e=>{const[n,g,r,T]=e;return n?.type==="NumericLiteral"&&g?.type==="ArrowFunctionExpression"&&r?.type==="ArrayExpression"&&(!T||T.type==="CallExpression")},"isRuntimeBindingArrayElements"),se=S(e=>ie(e,"this")||e.type==="ThisExpression"||e.type==="MemberExpression"&&se(e.object),"isThisExpression"),w=S(e=>{if(e.type==="Identifier")return e;const n=w(e.left);return Object.assign(e,f.memberExpression(n,e.right))},"TSEntityNameToRuntime"),W=S(e=>e.type==="Identifier"?e:W(e.left),"getIdFromTSEntityName"),re=S(e=>C(e,["Identifier","MemberExpression"]),"isReferenceId"),je=S(e=>e.type==="ImportDeclaration"&&e.specifiers.length===1&&e.specifiers.every(n=>n.type==="ImportSpecifier"&&n.imported.type==="Identifier"&&["__export","__reExport"].includes(n.local.name)),"isHelperImport"),we=S((e,n,g)=>{if(e.type==="ExportNamedDeclaration"&&!e.declaration&&!e.source&&e.specifiers.length===0&&!e.attributes?.length)return!1;if(C(e,["ImportDeclaration","ExportAllDeclaration","ExportNamedDeclaration"])){if(e.type==="ExportNamedDeclaration"&&n.length>0)for(const r of e.specifiers){const T=B(r.exported);n.includes(T)&&(r.type==="ExportSpecifier"?r.exportKind="type":e.exportKind="type")}if(e.source?.value&&_.test(e.source.value))return e.source.value=ne(e.source.value,"js"),e;if(g&&e.type==="ExportNamedDeclaration"&&!e.source&&e.specifiers.length===1&&e.specifiers[0].type==="ExportSpecifier"&&B(e.specifiers[0].exported)==="default")return{expression:e.specifiers[0].local,type:"TSExportAssignment"}}},"patchImportExport"),Ce=S(e=>{const n=new Set;for(const[r,T]of e.entries()){const N=g(T);if(!N)continue;const[A,O]=N;O.properties.length!==0&&(e[r]={body:{body:[{declaration:null,source:null,specifiers:O.properties.filter(j=>j.type==="ObjectProperty").map(j=>{const P=j.value.body,K=j.key;return f.exportSpecifier(P,K)}),type:"ExportNamedDeclaration"}],type:"TSModuleBlock"},declare:!0,id:A,kind:"namespace",type:"TSModuleDeclaration"})}return e.filter(r=>!n.has(r));function g(r){if(r.type!=="VariableDeclaration"||r.declarations.length!==1||r.declarations[0].id.type!=="Identifier"||r.declarations[0].init?.type!=="CallExpression"||r.declarations[0].init.callee.type!=="Identifier"||r.declarations[0].init.callee.name!=="__export"||r.declarations[0].init.arguments.length!==1||r.declarations[0].init.arguments[0].type!=="ObjectExpression")return!1;const T=r.declarations[0].id,N=r.declarations[0].init.arguments[0];return[T,N]}},"patchTsNamespace"),ke=S(e=>{const n=new Map;for(const[g,r]of e.entries())if(r.type==="ImportDeclaration"&&r.specifiers.length===1&&r.specifiers[0].type==="ImportSpecifier"&&r.specifiers[0].local.type==="Identifier"&&r.specifiers[0].local.name.endsWith("_exports"))n.set(r.specifiers[0].local.name,r.specifiers[0].local.name);else if(r.type==="ExpressionStatement"&&r.expression.type==="CallExpression"&&ie(r.expression.callee,"__reExport")){const T=r.expression.arguments;n.set(T[0].name,T[1].name)}else r.type==="VariableDeclaration"&&r.declarations.length===1&&r.declarations[0].init?.type==="MemberExpression"&&r.declarations[0].init.object.type==="Identifier"&&n.has(r.declarations[0].init.object.name)?e[g]={id:{name:r.declarations[0].id.name,type:"Identifier"},type:"TSTypeAliasDeclaration",typeAnnotation:{type:"TSTypeReference",typeName:{left:{name:n.get(r.declarations[0].init.object.name),type:"Identifier"},right:{name:r.declarations[0].init.property.name,type:"Identifier"},type:"TSQualifiedName"}}}:r.type==="ExportNamedDeclaration"&&r.specifiers.length===1&&r.specifiers[0].type==="ExportSpecifier"&&r.specifiers[0].local.type==="Identifier"&&n.has(r.specifiers[0].local.name)&&(r.specifiers[0].local.name=n.get(r.specifiers[0].local.name));return e},"patchReExport"),Me=S((e,n,g)=>{if(e.type==="ImportDeclaration"||e.type==="ExportNamedDeclaration"&&!e.declaration){for(const r of e.specifiers)("exportKind"in r&&r.exportKind==="type"||"exportKind"in e&&e.exportKind==="type")&&g.push(B(r.exported)),r.type==="ImportSpecifier"?r.importKind="value":r.type==="ExportSpecifier"&&(r.exportKind="value");return e.type==="ImportDeclaration"?e.importKind="value":e.type==="ExportNamedDeclaration"&&(e.exportKind="value"),!0}return e.type==="ExportAllDeclaration"?(e.exportKind="value",!0):e.type==="TSImportEqualsDeclaration"?(e.moduleReference.type==="TSExternalModuleReference"&&n({source:e.moduleReference.expression,specifiers:[{local:e.id,type:"ImportDefaultSpecifier"}],type:"ImportDeclaration"}),!0):e.type==="TSExportAssignment"&&e.expression.type==="Identifier"?(n({specifiers:[{exported:{name:"default",type:"Identifier"},local:e.expression,type:"ExportSpecifier"}],type:"ExportNamedDeclaration"}),!0):e.type==="ExportDefaultDeclaration"&&e.declaration.type==="Identifier"?(n({specifiers:[{exported:f.identifier("default"),local:e.declaration,type:"ExportSpecifier"}],type:"ExportNamedDeclaration"}),!0):!1},"rewriteImportExport"),M=S((e,n)=>{for(const g of Object.keys(e))delete e[g];return Object.assign(e,n),e},"overwriteNode"),Ae=S((e,n)=>{n.leadingComments||=[];const g=e.leadingComments?.filter(r=>r.value.startsWith("#"));return g&&n.leadingComments.unshift(...g),n.leadingComments=ae(n.leadingComments,!0),n},"inheritNodeComments");export{We as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"node:child_process";import"node:fs";import"node:fs/promises";import"node:path";import"@babel/parser";import"obug";import"oxc-transform";import"../filename.js";import{c as f}from"./generate-CxhgFvNH.js";export{f as createGeneratePlugin};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
var ur=Object.defineProperty;var te=(s,i)=>ur(s,"name",{value:i,configurable:!0});import{spawn as pr,fork as fr}from"node:child_process";import{existsSync as ve,readFileSync as dr}from"node:fs";import{mkdtemp as gr,readFile as Te,rm as mr}from"node:fs/promises";import P from"node:path";import{parse as Xe}from"@babel/parser";import{createDebug as Me}from"obug";import{transformSync as hr,isolatedDeclarationSync as xr}from"oxc-transform";import{RE_DTS as z,RE_NODE_MODULES as de,RE_JS as re,filename_to_dts as Ze,RE_JSON as Le,RE_TS as Ue,RE_VUE as je,resolveTemplateFn as yr,replaceTemplateName as be,RE_DTS_MAP as qe}from"../filename.js";import{createRequire as $r}from"node:module";import{tmpdir as wr}from"node:os";var vr=Object.defineProperty,a=te((s,i)=>vr(s,"name",{value:i,configurable:!0}),"s");let Ge=a(()=>{var s=(()=>{var i=Object.defineProperty,l=Object.getOwnPropertyDescriptor,c=Object.getOwnPropertyNames,f=Object.prototype.hasOwnProperty,v=a((e,t)=>{for(var r in t)i(e,r,{get:t[r],enumerable:!0})},"ne"),_=a((e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of c(t))!f.call(e,n)&&n!==r&&i(e,n,{get:a(()=>t[n],"get"),enumerable:!(o=l(t,n))||o.enumerable});return e},"ae"),j=a(e=>_(i({},"__esModule",{value:!0}),e),"oe"),N={};v(N,{zeptomatch:a(()=>Je,"zeptomatch")});var Z=a(e=>{const t=new Set,r=[e];for(let o=0;o<r.length;o++){const n=r[o];if(t.has(n))continue;t.add(n);const{children:u}=n;if(u?.length)for(let d=0,y=u.length;d<y;d++)r.push(u[d])}return Array.from(t)},"M"),L=a(e=>{let t="";const r=Z(e);for(let o=0,n=r.length;o<n;o++){const u=r[o];if(!u.regex)continue;const d=u.regex.flags;if(t||(t=d),t!==d)throw new Error(`Inconsistent RegExp flags used: "${t}" and "${d}"`)}return t},"se"),ie=a((e,t,r)=>{const o=r.get(e);if(o!==void 0)return o;const n=e.partial??t;let u="";if(e.regex&&(u+=n?"(?:$|":"",u+=e.regex.source),e.children?.length){const d=me(e.children.map(y=>ie(y,t,r)).filter(Boolean));if(d?.length){const y=e.children.some(Y=>!Y.regex||!(Y.partial??t)),b=d.length>1||n&&(!u.length||y);u+=b?n?"(?:$|":"(?:":"",u+=d.join("|"),u+=b?")":""}}return e.regex&&(u+=n?")":""),r.set(e,u),u},"O"),X=a((e,t)=>{const r=new Map,o=Z(e);for(let n=o.length-1;n>=0;n--){const u=ie(o[n],t,r);if(!(n>0))return u}return""},"ie"),me=a(e=>Array.from(new Set(e)),"ue"),K=a((e,t,r)=>K.compile(e,r).test(t),"R");K.compile=(e,t)=>{const r=t?.partial??!1,o=X(e,r),n=L(e);return new RegExp(`^(?:${o})$`,n)};var S=K,ae=a((e,t)=>{const r=S.compile(e,t),o=`${r.source.slice(0,-1)}[\\\\/]?$`,n=r.flags;return new RegExp(o,n)},"le"),U=ae,le=a(e=>{const t=e.map(o=>o.source).join("|")||"$^",r=e[0]?.flags;return new RegExp(t,r)},"ve"),H=le,B=a(e=>Array.isArray(e),"j"),A=a(e=>typeof e=="function","_"),ce=a(e=>e.length===0,"he"),x=(()=>{const{toString:e}=Function.prototype,t=/(?:^\(\s*(?:[^,.()]|\.(?!\.\.))*\s*\)\s*=>|^\s*[a-zA-Z$_][a-zA-Z0-9$_]*\s*=>)/;return r=>(r.length===0||r.length===1)&&t.test(e.call(r))})(),m=a(e=>typeof e=="number","de"),h=a(e=>typeof e=="object"&&e!==null,"xe"),g=a(e=>e instanceof RegExp,"me"),$=(()=>{const e=/\\\(|\((?!\?(?::|=|!|<=|<!))/;return t=>e.test(t.source)})(),E=(()=>{const e=/^[a-zA-Z0-9_-]+$/;return t=>e.test(t.source)&&!t.flags.includes("i")})(),M=a(e=>typeof e=="string","A"),k=a(e=>e===void 0,"f"),I=a(e=>{const t=new Map;return r=>{const o=t.get(r);if(o!==void 0)return o;const n=e(r);return t.set(r,n),n}},"ye"),D=a((e,t,r={})=>{const o={cache:{},input:e,index:0,indexBacktrackMax:0,options:r,output:[]},n=F(t)(o),u=Math.max(o.index,o.indexBacktrackMax);if(n&&o.index===e.length)return o.output;throw new Error(`Failed to parse at index ${u}`)},"I"),p=a((e,t)=>B(e)?ue(e,t):M(e)?_e(e,t):pe(e,t),"i"),ue=a((e,t)=>{const r={};for(const o of e){if(o.length!==1)throw new Error(`Invalid character: "${o}"`);const n=o.charCodeAt(0);r[n]=!0}return o=>{const n=o.input;let u=o.index,d=u;for(;d<n.length&&n.charCodeAt(d)in r;)d+=1;if(d>u){if(!k(t)&&!o.options.silent){const y=n.slice(u,d),b=A(t)?t(y,n,`${u}`):t;k(b)||o.output.push(b)}o.index=d}return!0}},"we"),pe=a((e,t)=>{if(E(e))return _e(e.source,t);{const r=e.source,o=e.flags.replace(/y|$/,"y"),n=new RegExp(r,o);return $(e)&&A(t)&&!x(t)?tt(n,t):rt(n,t)}},"$e"),tt=a((e,t)=>r=>{const o=r.index,n=r.input;e.lastIndex=o;const u=e.exec(n);if(u){const d=e.lastIndex;if(!r.options.silent){const y=t(...u,n,`${o}`);k(y)||r.output.push(y)}return r.index=d,!0}else return!1},"Ee"),rt=a((e,t)=>r=>{const o=r.index,n=r.input;if(e.lastIndex=o,e.test(n)){const u=e.lastIndex;if(!k(t)&&!r.options.silent){const d=A(t)?t(n.slice(o,u),n,`${o}`):t;k(d)||r.output.push(d)}return r.index=u,!0}else return!1},"Ce"),_e=a((e,t)=>r=>{const o=r.index,n=r.input;if(n.startsWith(e,o)){if(!k(t)&&!r.options.silent){const u=A(t)?t(e,n,`${o}`):t;k(u)||r.output.push(u)}return r.index+=e.length,!0}else return!1},"F"),he=a((e,t,r,o)=>{const n=F(e),u=t>1;return ye(xe(Se(d=>{let y=0;for(;y<r;){const b=d.index;if(!n(d)||(y+=1,d.index===b))break}return y>=t},u),o))},"k"),Ae=a((e,t)=>he(e,0,1,t),"L"),fe=a((e,t)=>he(e,0,1/0,t),"$"),nt=a((e,t)=>he(e,1,1/0,t),"Re"),q=a((e,t)=>{const r=e.map(F);return ye(xe(Se(o=>{for(let n=0,u=r.length;n<u;n++)if(!r[n](o))return!1;return!0}),t))},"x"),O=a((e,t)=>{const r=e.map(F);return ye(xe(o=>{for(let n=0,u=r.length;n<u;n++)if(r[n](o))return!0;return!1},t))},"p"),Se=a((e,t=!0,r=!1)=>{const o=F(e);return t?n=>{const u=n.index,d=n.output.length,y=o(n);return!y&&!r&&(n.indexBacktrackMax=Math.max(n.indexBacktrackMax,n.index)),(!y||r)&&(n.index=u,n.output.length!==d&&(n.output.length=d)),y}:o},"q"),xe=a((e,t)=>{const r=F(e);return t?o=>{if(o.options.silent)return r(o);const n=o.output.length;if(r(o)){const u=o.output.splice(n,1/0),d=t(u);return k(d)||o.output.push(d),!0}else return!1}:r},"B"),ye=(()=>{let e=0;return t=>{const r=F(t),o=e+=1;return n=>{var u;if(n.options.memoization===!1)return r(n);const d=n.index,y=(u=n.cache)[o]||(u[o]={indexMax:-1,queue:[]}),b=y.queue;if(d<=y.indexMax){const ee=y.store||(y.store=new Map);if(b.length){for(let V=0,ar=b.length;V<ar;V+=2){const lr=b[V*2],cr=b[V*2+1];ee.set(lr,cr)}b.length=0}const R=ee.get(d);if(R===!1)return!1;if(m(R))return n.index=R,!0;if(R)return n.index=R.index,R.output?.length&&n.output.push(...R.output),!0}const Y=n.output.length,ir=r(n);if(y.indexMax=Math.max(y.indexMax,d),ir){const ee=n.index,R=n.output.length;if(R>Y){const V=n.output.slice(Y,R);b.push(d,{index:ee,output:V})}else b.push(d,ee);return!0}else return b.push(d,!1),!1}}})(),Oe=a(e=>{let t;return r=>(t||(t=F(e())),t(r))},"G"),F=I(e=>{if(A(e))return ce(e)?Oe(e):e;if(M(e)||g(e))return p(e);if(B(e))return q(e);if(h(e))return O(Object.values(e));throw new Error("Invalid rule")}),J=a(e=>e,"d"),ot=a(e=>typeof e=="string","ke"),st=a(e=>{const t=new WeakMap,r=new WeakMap;return(o,n)=>{const u=n?.partial?r:t,d=u.get(o);if(d!==void 0)return d;const y=e(o,n);return u.set(o,y),y}},"Be"),it=a(e=>{const t={},r={};return(o,n)=>{const u=n?.partial?r:t;return u[o]??(u[o]=e(o,n))}},"Pe"),at=p(/\\./,J),lt=p(/./,J),ct=p(/\*\*\*+/,"*"),ut=p(/([^/{[(!])\*\*/,(e,t)=>`${t}*`),pt=p(/(^|.)\*\*(?=[^*/)\]}])/,(e,t)=>`${t}*`),ft=fe(O([at,ct,ut,pt,lt])),dt=ft,gt=a(e=>D(e,dt,{memoization:!1}).join(""),"Ie"),mt=gt,Re="abcdefghijklmnopqrstuvwxyz",ht=a(e=>{let t="";for(;e>0;){const r=(e-1)%26;t=Re[r]+t,e=Math.floor((e-1)/26)}return t},"Le"),Ie=a(e=>{let t=0;for(let r=0,o=e.length;r<o;r++)t=t*26+Re.indexOf(e[r])+1;return t},"V"),$e=a((e,t)=>{if(t<e)return $e(t,e);const r=[];for(;e<=t;)r.push(e++);return r},"b"),xt=a((e,t,r)=>$e(e,t).map(o=>String(o).padStart(r,"0")),"qe"),ze=a((e,t)=>$e(Ie(e),Ie(t)).map(ht),"W"),w=a(e=>({partial:!1,regex:new RegExp(e,"s"),children:[]}),"c"),Q=a(e=>({children:e}),"y"),G=(()=>{const e=a((t,r,o)=>{if(o.has(t))return;o.add(t);const{children:n}=t;if(!n.length)n.push(r);else for(let u=0,d=n.length;u<d;u++)e(n[u],r,o)},"e");return t=>{if(!t.length)return Q([]);for(let r=t.length-1;r>=1;r--){const o=new Set,n=t[r-1],u=t[r];e(n,u,o)}return t[0]}})(),W=a(()=>({regex:new RegExp("[\\\\/]","s"),children:[]}),"g"),yt=p(/\\./,w),$t=p(/[$.*+?^(){}[\]\|]/,e=>w(`\\${e}`)),wt=p(/[\\\/]/,W),vt=p(/[^$.*+?^(){}[\]\|\\\/]+/,w),jt=p(/^(?:!!)*!(.*)$/,(e,t)=>w(`(?!^${Je.compile(t).source}$).*?`)),bt=p(/^(!!)+/),Et=O([jt,bt]),Mt=p(/\/(\*\*\/)+/,()=>Q([G([W(),w(".+?"),W()]),W()])),kt=p(/^(\*\*\/)+/,()=>Q([w("^"),G([w(".*?"),W()])])),_t=p(/\/(\*\*)$/,()=>Q([G([W(),w(".*?")]),w("$")])),At=p(/\*\*/,()=>w(".*?")),Ce=O([Mt,kt,_t,At]),St=p(/\*\/(?!\*\*\/|\*$)/,()=>G([w("[^\\\\/]*?"),W()])),Ot=p(/\*/,()=>w("[^\\\\/]*")),Pe=O([St,Ot]),Ne=p("?",()=>w("[^\\\\/]")),Rt=p("[",J),It=p("]",J),zt=p(/[!^]/,"^\\\\/"),Ct=p(/[a-z]-[a-z]|[0-9]-[0-9]/i,J),Pt=p(/\\./,J),Nt=p(/[$.*+?^(){}[\|]/,e=>`\\${e}`),Dt=p(/[\\\/]/,"\\\\/"),Ft=p(/[^$.*+?^(){}[\]\|\\\/]+/,J),Wt=O([Pt,Nt,Dt,Ct,Ft]),De=q([Rt,Ae(zt),fe(Wt),It],e=>w(e.join(""))),Bt=p("{","(?:"),Jt=p("}",")"),Tt=p(/(\d+)\.\.(\d+)/,(e,t,r)=>xt(+t,+r,Math.min(t.length,r.length)).join("|")),Zt=p(/([a-z]+)\.\.([a-z]+)/,(e,t,r)=>ze(t,r).join("|")),Lt=p(/([A-Z]+)\.\.([A-Z]+)/,(e,t,r)=>ze(t.toLowerCase(),r.toLowerCase()).join("|").toUpperCase()),Ut=O([Tt,Zt,Lt]),Fe=q([Bt,Ut,Jt],e=>w(e.join(""))),qt=p("{"),Gt=p("}"),Vt=p(","),Xt=p(/\\./,w),Kt=p(/[$.*+?^(){[\]\|]/,e=>w(`\\${e}`)),Ht=p(/[\\\/]/,W),Qt=p(/[^$.*+?^(){}[\]\|\\\/,]+/,w),Yt=Oe(()=>Be),er=p("",()=>w("(?:)")),tr=nt(O([Ce,Pe,Ne,De,Fe,Yt,Xt,Kt,Ht,Qt]),G),We=O([tr,er]),Be=q([qt,Ae(q([We,fe(q([Vt,We]))])),Gt],Q),rr=fe(O([Et,Ce,Pe,Ne,De,Fe,Be,yt,$t,wt,vt]),G),nr=rr,or=a(e=>D(e,nr,{memoization:!1})[0],"kr"),sr=or,we=a((e,t,r)=>we.compile(e,r).test(t),"N");we.compile=(()=>{const e=it((r,o)=>U(sr(mt(r)),o)),t=st((r,o)=>H(r.map(n=>e(n,o))));return(r,o)=>ot(r)?e(r,o):t(r,o)})();var Je=we;return j(N)})();return s.default||s},"_lazyMatch"),Ee;const jr=a((s,i)=>(Ee||(Ee=Ge(),Ge=null),Ee(s,i)),"zeptomatch"),br=/^[A-Z]:\//i,T=a((s="")=>s&&s.replaceAll("\\","/").replace(br,i=>i.toUpperCase()),"normalizeWindowsPath"),Er=/^[/\\]{2}/,Mr=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,Ke=/^[A-Z]:$/i,Ve=/^\/([A-Z]:)?$/i,kr=/.(\.[^./]+)$/,_r=/^[/\\]|^[a-z]:[/\\]/i,Ar=a(()=>typeof process.cwd=="function"?process.cwd().replaceAll("\\","/"):"/","cwd"),He=a((s,i)=>{let l="",c=0,f=-1,v=0,_;for(let j=0;j<=s.length;++j){if(j<s.length)_=s[j];else{if(_==="/")break;_="/"}if(_==="/"){if(!(f===j-1||v===1))if(v===2){if(l.length<2||c!==2||!l.endsWith(".")||l.at(-2)!=="."){if(l.length>2){const N=l.lastIndexOf("/");N===-1?(l="",c=0):(l=l.slice(0,N),c=l.length-1-l.lastIndexOf("/")),f=j,v=0;continue}else if(l.length>0){l="",c=0,f=j,v=0;continue}}i&&(l+=l.length>0?"/..":"..",c=2)}else l.length>0?l+=`/${s.slice(f+1,j)}`:l=s.slice(f+1,j),c=j-f-1;f=j,v=0}else _==="."&&v!==-1?++v:v=-1}return l},"normalizeString"),se=a(s=>Mr.test(s),"isAbsolute"),Qe=a(function(s){if(s.length===0)return".";s=T(s);const i=Er.exec(s),l=se(s),c=s.at(-1)==="/";return s=He(s,!l),s.length===0?l?"/":c?"./":".":(c&&(s+="/"),Ke.test(s)&&(s+="/"),i?l?`//${s}`:`//./${s}`:l&&!se(s)?`/${s}`:s)},"normalize");a((...s)=>{let i="";for(const l of s)if(l)if(i.length>0){const c=i[i.length-1]==="/",f=l[0]==="/";c&&f?i+=l.slice(1):i+=c||f?l:`/${l}`}else i+=l;return Qe(i)},"join");const ge=a(function(...s){s=s.map(c=>T(c));let i="",l=!1;for(let c=s.length-1;c>=-1&&!l;c--){const f=c>=0?s[c]:Ar();!f||f.length===0||(i=`${f}/${i}`,l=se(f))}return i=He(i,!l),l&&!se(i)?`/${i}`:i.length>0?i:"."},"resolve");a(function(s){return T(s)},"toNamespacedPath");const Sr=a(function(s){return kr.exec(T(s))?.[1]??""},"extname");a(function(s,i){const l=ge(s).replace(Ve,"$1").split("/"),c=ge(i).replace(Ve,"$1").split("/");if(c[0][1]===":"&&l[0][1]===":"&&l[0]!==c[0])return c.join("/");const f=[...l];for(const v of f){if(c[0]!==v)break;l.shift(),c.shift()}return[...l.map(()=>".."),...c].join("/")},"relative");const Or=a(s=>{const i=T(s).replace(/\/$/,"").split("/").slice(0,-1);return i.length===1&&Ke.test(i[0])&&(i[0]+="/"),i.join("/")||(se(s)?"/":".")},"dirname");a(function(s){const i=[s.root,s.dir,s.base??s.name+s.ext].filter(Boolean);return T(s.root?ge(...i):i.join("/"))},"format");const Rr=a((s,i)=>{const l=T(s).split("/").pop();return i&&l.endsWith(i)?l.slice(0,-i.length):l},"basename");a(function(s){const i=_r.exec(s)?.[0]?.replaceAll("\\","/")??"",l=Rr(s),c=Sr(l);return{base:l,dir:Or(s),ext:c,name:l.slice(0,l.length-c.length),root:i}},"parse");a((s,i)=>jr(i,Qe(s)),"matchesGlob");var Ir=Object.defineProperty,Ye=te((s,i)=>Ir(s,"name",{value:i,configurable:!0}),"r");const zr=Me("rollup-plugin-dts:tsc-context"),et=Ye(()=>({files:new Map,programs:[],projects:new Map}),"createContext"),Cr=Ye((s,i)=>{i=ge(i).replaceAll("\\","/"),zr(`invalidating context file: ${i}`),s.files.delete(i),s.programs=s.programs.filter(l=>!l.getSourceFiles().some(c=>c.fileName===i)),s.projects.clear()},"invalidateContextFile"),Pr=et();var Nr=Object.defineProperty,ke=te((s,i)=>Nr(s,"name",{value:i,configurable:!0}),"i");const ne=Me("rollup-plugin-dts:tsgo"),Dr=ke((...s)=>new Promise((i,l)=>{const c=pr(...s);c.on("close",()=>i()),c.on("error",f=>l(f))}),"spawnAsync"),Fr=ke(()=>{const s=$r(import.meta.url),i=s.resolve("@typescript/native-preview/package.json"),l=P.dirname(i),c=s(P.join(l,"lib","getExePath.js"));return(typeof c=="function"?c:c.default)()},"getTsgoPathFromNodeModules"),Wr=ke(async(s,i,l,c)=>{ne("[tsgo] rootDir",s);let f;c?(f=c,ne("[tsgo] using custom path",f)):(f=Fr(),ne("[tsgo] using tsgo from node_modules",f));const v=await gr(P.join(wr(),"rollup-plugin-dts-"));ne("[tsgo] tsgoDist",v);const _=["--noEmit","false","--declaration","--emitDeclarationOnly",...i?["-p",i]:[],"--outDir",v,"--rootDir",s,"--noCheck",...l?["--declarationMap"]:[]];return ne("[tsgo] args %o",_),await Dr(f,_,{stdio:"inherit"}),v},"runTsgo");var Br=Object.defineProperty,oe=te((s,i)=>Br(s,"name",{value:i,configurable:!0}),"y");const C=Me("rollup-plugin-dts:generate"),Jr=import.meta.WORKER_URL??"./tsc/worker.js",tn=oe(({build:s,cwd:i,eager:l,emitDtsOnly:c,emitJs:f,incremental:v,newContext:_,oxc:j,parallel:N,sourcemap:Z,tsconfig:L,tsconfigRaw:ie,tsgo:X,tsMacro:me,vue:K})=>{const S=new Map,ae=new Map;let U,le,H,B,A;const ce=L?P.dirname(L):i;return{async buildEnd(){U?.kill(),!C.enabled&&A&&await mr(A,{force:!0,recursive:!0}).catch(()=>{}),A=void 0,_&&(B=void 0)},async buildStart(x){if(X?A=await Wr(ce,L,Z,X.path):j||(N?(U=fr(new URL(Jr,import.meta.url),{stdio:"inherit"}),le=(await import("birpc")).createBirpc({},{on:oe(m=>U.on("message",m),"on"),post:oe(m=>U.send(m),"post")})):(H=await import("../packem_chunks/index.js"),_&&(B=et()))),!Array.isArray(x.input))for(const[m,h]of Object.entries(x.input)){C("resolving input alias %s -> %s",m,h);let g=await this.resolve(h);h.startsWith("./")||(g||=await this.resolve(`./${h}`));const $=g?.id||h;C("resolved input alias %s -> %s",h,$),ae.set($,m)}},generateBundle(x,m){for(const h of Object.keys(m)){const g=m[h];if(g){if(g.type==="asset"&&qe.test(h)&&typeof g.source=="string"){const $=JSON.parse(g.source);$.names=[],delete $.sourcesContent,g.source=JSON.stringify($)}c&&g.type==="chunk"&&!z.test(h)&&!qe.test(h)&&delete m[h]}}},load:{filter:{id:{exclude:[de],include:[z]}},async handler(x){if(!S.has(x))return;const{code:m,id:h}=S.get(x);let g,$;if(C("generate dts %s from %s",x,h),X){if(je.test(h))throw new Error("tsgo does not support Vue files.");const E=P.resolve(A,P.relative(ce,Ze(h)));if(ve(E)){if(g=await Te(E,"utf8"),Z){const M=`${E}.map`;ve(M)&&($=JSON.parse(await Te(M,"utf8")))}}else throw C("[tsgo]",E,"is missing"),new Error(`tsgo did not generate dts file for ${h}, please check your tsconfig.`)}else if(j&&!je.test(h)){const E=xr(h,m,j);if(E.errors.length>0){const[M]=E.errors;return this.error({frame:M?.codeframe||void 0,message:M?.codeframe?`${M.message}
|
|
2
|
-
${M.codeframe}`:M?.message??"Unknown error"})}g=E.code,E.map&&($=E.map,$.sourcesContent=void 0,$.names=[])}else{const E=l?void 0:[...S.values()].filter(I=>I.isEntry).map(I=>I.id),M={build:s,context:B,cwd:i,entries:E,id:h,incremental:v,sourcemap:Z,tsconfig:L,tsconfigRaw:ie,tsMacro:me,vue:K};let k;if(k=N?await le.tscEmit(M):H.tscEmit(M),k.error)return this.error(k.error);if(g=k.code,$=k.map,g&&Le.test(h))if(g.includes("declare const _exports")){if(g.includes("declare const _exports: {")&&!g.includes(`
|
|
3
|
-
}[];`)){const I=Zr(g);let D=0;g+=I.map(p=>{const ue=`_${p.replaceAll(/[^\w$]/g,"_")}${D++}`,pe=JSON.stringify(p);return`declare let ${ue}: typeof _exports[${pe}]
|
|
4
|
-
export { ${ue} as ${pe} }`}).join(`
|
|
5
|
-
`)}}else{const I=Tr(g);g+=`
|
|
6
|
-
declare namespace __json_default_export {
|
|
7
|
-
export { ${Array.from(I.entries(),([D,p])=>D===p?D:`${p} as ${D}`).join(", ")} }
|
|
8
|
-
}
|
|
9
|
-
export { __json_default_export as default }`}}return{code:g||"",map:$}}},name:"rollup-plugin-dts:generate",outputOptions(x){return{...x,entryFileNames(m){const{entryFileNames:h}=x,g=yr(h||"[name].js",m);if(m.name.endsWith(".d")){if(z.test(g))return be(g,m.name.slice(0,-2));if(re.test(g))return g.replace(re,".$1ts")}else if(c){if(m.facadeModuleId&&z.test(m.facadeModuleId)){if(z.test(g))return be(g,m.name);if(re.test(g))return g.replace(re,".$1ts")}return be("[name].js",m.name)}return g}}},async resolveId(x,m){if(S.has(x))return C("resolve dts id %s",x),{id:x};if(!m&&z.test(x)&&!de.test(x)){const h=P.isAbsolute(x)?x:P.resolve(i,x),g=h.replace(z,".$1ts");if(!S.has(h)&&ve(g)){const $=dr(g,"utf8");S.set(h,{code:$,id:g,isEntry:!0}),C("populated dtsMap from source for cached re-resolution: %s",h)}return S.has(h)?(C("resolve dts id %s (from cache re-resolution)",h),{id:h}):null}if(m&&Ue.test(m)&&(x.startsWith("./")||x.startsWith("../"))&&!P.extname(x))for(const h of[".ts",".tsx",".mts",".cts"]){const g=await this.resolve(x+h,m,{skipSelf:!0});if(g)return g}return null},shouldTransformCachedModule({id:x}){return z.test(x)&&!de.test(x)},transform:{handler(x,m){if(!(z.test(m)||de.test(m))){if(!re.test(m)||f){const h=!!this.getModuleInfo(m)?.isEntry,g=Ze(m);if(S.set(g,{code:x,id:m,isEntry:h}),C("register dts source: %s",m),h){const $=ae.get(m);this.emitFile({id:g,name:$?`${$}.d`:void 0,type:"chunk"})}}return c?Le.test(m)?"{}":"export { }":Ue.test(m)||je.test(m)?hr(m,x,{}).code:null}},order:"pre"},watchChange(x){H&&Cr(B||Pr,x)}}},"createGeneratePlugin"),Tr=oe(s=>{const i=new Map,{program:l}=Xe(s,{errorRecovery:!0,plugins:[["typescript",{dts:!0}]],sourceType:"module"});for(const c of l.body)if(c.type==="ExportNamedDeclaration"){if(c.declaration)if(c.declaration.type==="VariableDeclaration")for(const f of c.declaration.declarations)f.id.type==="Identifier"&&i.set(f.id.name,f.id.name);else c.declaration.type==="TSModuleDeclaration"&&c.declaration.id.type==="Identifier"&&i.set(c.declaration.id.name,c.declaration.id.name);else if(c.specifiers.length>0)for(const f of c.specifiers)f.type==="ExportSpecifier"&&f.exported.type==="Identifier"&&i.set(f.exported.name,f.local.type==="Identifier"?f.local.name:f.exported.name)}return i},"collectJsonExportMap"),Zr=oe(s=>{const i=[],{program:l}=Xe(s,{plugins:[["typescript",{dts:!0}]],sourceType:"module"}),c=l.body[0].declarations[0].id.typeAnnotation.typeAnnotation.members;for(const f of c)f.key.type==="Identifier"?i.push(f.key.name):f.key.type==="StringLiteral"&&i.push(f.key.value);return i},"collectJsonExports");export{Or as X,tn as c,Pr as g};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var C=Object.defineProperty;var d=(i,l)=>C(i,"name",{value:l,configurable:!0});import j from"node:path";import w from"node:process";import{findTsConfigSync as R,readTsConfig as k}from"@visulima/tsconfig";var B=Object.defineProperty,F=d((i,l)=>B(i,"name",{value:l,configurable:!0}),"m");let g=!1;const G=F(({banner:i,build:l=!1,cjsDefault:v=!1,compilerOptions:e={},cwd:c=w.cwd(),dtsInput:b=!1,eager:x=!1,emitDtsOnly:O=!1,emitJs:u,footer:T,incremental:m=!1,newContext:y=!1,oxc:o,parallel:E=!1,resolve:M=!1,resolver:I="oxc",sideEffects:P=!1,sourcemap:p,tsconfig:t,tsconfigRaw:D={},tsgo:f=!1,tsMacro:n=!1,vue:r=!1})=>{let a;if(t===!0||t==null)try{const h=R(c);t=h.path,a=h.config}catch{t=void 0}else typeof t=="string"?(t=j.resolve(c||w.cwd(),t),a=k(t)):t=void 0;e={...a?.compilerOptions,...e},m||=e.incremental||!!e.tsBuildInfoFile,p??=!!e.declarationMap,e.declarationMap=p;const J={...a,...D,compilerOptions:e};let s=!1;if(f&&(s=f===!0?{}:f),o??=!!(e?.isolatedDeclarations&&!r&&!s&&!n),o===!0&&(o={}),o&&(o.stripInternal??=!!e?.stripInternal,o.sourcemap=!!e.declarationMap),u??=!!(e.checkJs||e.allowJs),s){if(r)throw new Error("[@visulima/rollup-plugin-dts] The `tsgo` option is not compatible with the `vue` option. Please disable one of them.");if(n)throw new Error("[@visulima/rollup-plugin-dts] The `tsgo` option is not compatible with the `tsMacro` option. Please disable one of them.");if(o)throw new Error("[@visulima/rollup-plugin-dts] The `tsgo` option is not compatible with the `oxc` option. Please disable one of them.")}if(o&&r)throw new Error("[@visulima/rollup-plugin-dts] The `oxc` option is not compatible with the `vue` option. Please disable one of them.");if(o&&n)throw new Error("[@visulima/rollup-plugin-dts] The `oxc` option is not compatible with the `tsMacro` option. Please disable one of them.");return s&&!g&&(console.warn("The `tsgo` option is experimental and may change in the future."),g=!0),{banner:i,build:l,cjsDefault:v,cwd:c,dtsInput:b,eager:x,emitDtsOnly:O,emitJs:u,footer:T,incremental:m,newContext:y,oxc:o,parallel:E,resolve:M,resolver:I,sideEffects:P,sourcemap:p,tsconfig:t,tsconfigRaw:J,tsgo:s,tsMacro:n,vue:r}},"resolveOptions");export{G as resolveOptions};
|