@visulima/rollup-plugin-dts 1.0.0-alpha.5 → 1.0.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## @visulima/rollup-plugin-dts [1.0.0-alpha.6](https://github.com/visulima/packem/compare/@visulima/rollup-plugin-dts@1.0.0-alpha.5...@visulima/rollup-plugin-dts@1.0.0-alpha.6) (2026-03-24)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* **rollup-plugin-dts:** only add export {} for declare module augmentations, not declare global ([c53e3db](https://github.com/visulima/packem/commit/c53e3dbce725ac2579eaa0fdca30e52fc8b43b89))
|
|
6
|
+
* **rollup-plugin-dts:** preserve export {} in module augmentation files ([43c7975](https://github.com/visulima/packem/commit/43c7975cdf1300fbd0e0c949f6b5c3851e5a937c))
|
|
7
|
+
* **rollup-plugin-dts:** preserve JSDoc comment positioning in type aliases ([436f8dc](https://github.com/visulima/packem/commit/436f8dcb4a6ce025a2eb7b537ee7f868f4bbed01))
|
|
8
|
+
|
|
9
|
+
### Tests
|
|
10
|
+
|
|
11
|
+
* **rollup-plugin-dts:** add triple-slash directive preservation test ([eacac81](https://github.com/visulima/packem/commit/eacac81d49d7ef5917cd7aaf10762dfdac040a0d))
|
|
12
|
+
|
|
1
13
|
## @visulima/rollup-plugin-dts [1.0.0-alpha.5](https://github.com/visulima/packem/compare/@visulima/rollup-plugin-dts@1.0.0-alpha.4...@visulima/rollup-plugin-dts@1.0.0-alpha.5) (2026-03-24)
|
|
2
14
|
|
|
3
15
|
### Features
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var R=Object.defineProperty;var c=(t,e)=>R(t,"name",{value:e,configurable:!0});import{createDebug as w}from"obug";import O from"magic-string";import{RE_DTS as p,resolveTemplateFn as F,replaceTemplateName as h,RE_TS as $,RE_VUE as D,RE_JSON as N,RE_CSS as k,RE_NODE_MODULES as j,filename_to_dts as x}from"./filename.js";import{RE_DTS_MAP as ie,RE_JS as ae}from"./filename.js";import T from"./packem_shared/createFakeJsPlugin-
|
|
1
|
+
var R=Object.defineProperty;var c=(t,e)=>R(t,"name",{value:e,configurable:!0});import{createDebug as w}from"obug";import O from"magic-string";import{RE_DTS as p,resolveTemplateFn as F,replaceTemplateName as h,RE_TS as $,RE_VUE as D,RE_JSON as N,RE_CSS as k,RE_NODE_MODULES as j,filename_to_dts as x}from"./filename.js";import{RE_DTS_MAP as ie,RE_JS as ae}from"./filename.js";import T from"./packem_shared/createFakeJsPlugin-C_mwUsJT.js";import{c as C}from"./packem_shared/generate-BnWcSpbk.js";import{resolveOptions as I}from"./packem_shared/resolveOptions-MWViYRPS.js";import S from"node:path";import{ResolverFactory as J}from"oxc-resolver";var M=Object.defineProperty,A=c((t,e)=>M(t,"name",{value:e,configurable:!0}),"o$2");const U=A(({banner:t,footer:e})=>({name:"rollup-plugin-dts:banner",async renderChunk(r,a){if(!p.test(a.fileName))return;const o=new O(r);if(t){const l=await(typeof t=="function"?t(a):t);l&&o.prepend(`${l}
|
|
2
2
|
`)}if(e){const l=await(typeof e=="function"?e(a):e);l&&o.append(`
|
|
3
|
-
${l}`)}return{code:o.toString(),get map(){return o.generateMap({hires:"boundary",includeContent:!0,source:a.fileName})}}}}),"createBannerPlugin");var W=Object.defineProperty,q=c((t,e)=>W(t,"name",{value:e,configurable:!0}),"m");const z=q(({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(r){const{entryFileNames:a}=e;if(a){const o=F(a,r),l=h(o,r.name);if(p.test(l))return o;const d=h(o,`${r.name}.d`);if(p.test(d))return d}return p.test(r.name)?r.name:r.name.endsWith(".d")?"[name].ts":"[name].d.ts"}}}}),"createDtsInputPlugin");var B=Object.defineProperty,v=c((t,e)=>B(t,"name",{value:e,configurable:!0}),"o$1");const g=v(t=>$.test(t)||D.test(t)||N.test(t),"isSourceFile"),G=v(({cwd:t,resolve:e,resolver:r,sideEffects:a,tsconfig:o,tsconfigRaw:l})=>{const d=new J({conditionNames:["types","typings","import","require"],mainFields:["types","typings","module","main"],tsconfig:o?{configFile:o,references:"auto"}:void 0}),y=a?!0:null;return{name:"rollup-plugin-dts:resolver",resolveId:{async handler(s,i,u){if(!i||!p.test(i))return;const n={external:!0,id:s,moduleSideEffects:a};if(k.test(s))return n;const m=await this.resolve(s,i,u);if(m?.external)return n;const f=await P(s,i,m);return f?j.test(f)&&!_(s)?n:p.test(f)?{id:f,moduleSideEffects:y}:g(f)?(await this.load({id:f}),{id:x(f),moduleSideEffects:y}):null:E(s)?null:n},order:"pre"}};function _(s){return typeof e=="boolean"?e:e.some(i=>typeof i=="string"?s===i:i.test(s))}async function P(s,i,u){let n;if(r==="tsc"){const{default:m}=await import("./packem_chunks/resolver.js");n=m(s,i,t,o,l)}else n=d.resolveDtsSync(i,s).path;return n&&(n=S.normalize(n)),!n||!g(n)?u&&E(u.id)&&g(u.id)&&!u.external?u.id:null:n}},"createDtsResolvePlugin"),E=v(t=>t.startsWith(".")||S.isAbsolute(t),"isFilePath");var L=Object.defineProperty,V=c((t,e)=>L(t,"name",{value:e,configurable:!0}),"o");const b=w("rollup-plugin-dts:options"),ne=V((t={})=>{b("resolving dts options");const e=
|
|
3
|
+
${l}`)}return{code:o.toString(),get map(){return o.generateMap({hires:"boundary",includeContent:!0,source:a.fileName})}}}}),"createBannerPlugin");var W=Object.defineProperty,q=c((t,e)=>W(t,"name",{value:e,configurable:!0}),"m");const z=q(({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(r){const{entryFileNames:a}=e;if(a){const o=F(a,r),l=h(o,r.name);if(p.test(l))return o;const d=h(o,`${r.name}.d`);if(p.test(d))return d}return p.test(r.name)?r.name:r.name.endsWith(".d")?"[name].ts":"[name].d.ts"}}}}),"createDtsInputPlugin");var B=Object.defineProperty,v=c((t,e)=>B(t,"name",{value:e,configurable:!0}),"o$1");const g=v(t=>$.test(t)||D.test(t)||N.test(t),"isSourceFile"),G=v(({cwd:t,resolve:e,resolver:r,sideEffects:a,tsconfig:o,tsconfigRaw:l})=>{const d=new J({conditionNames:["types","typings","import","require"],mainFields:["types","typings","module","main"],tsconfig:o?{configFile:o,references:"auto"}:void 0}),y=a?!0:null;return{name:"rollup-plugin-dts:resolver",resolveId:{async handler(s,i,u){if(!i||!p.test(i))return;const n={external:!0,id:s,moduleSideEffects:a};if(k.test(s))return n;const m=await this.resolve(s,i,u);if(m?.external)return n;const f=await P(s,i,m);return f?j.test(f)&&!_(s)?n:p.test(f)?{id:f,moduleSideEffects:y}:g(f)?(await this.load({id:f}),{id:x(f),moduleSideEffects:y}):null:E(s)?null:n},order:"pre"}};function _(s){return typeof e=="boolean"?e:e.some(i=>typeof i=="string"?s===i:i.test(s))}async function P(s,i,u){let n;if(r==="tsc"){const{default:m}=await import("./packem_chunks/resolver.js");n=m(s,i,t,o,l)}else n=d.resolveDtsSync(i,s).path;return n&&(n=S.normalize(n)),!n||!g(n)?u&&E(u.id)&&g(u.id)&&!u.external?u.id:null:n}},"createDtsResolvePlugin"),E=v(t=>t.startsWith(".")||S.isAbsolute(t),"isFilePath");var L=Object.defineProperty,V=c((t,e)=>L(t,"name",{value:e,configurable:!0}),"o");const b=w("rollup-plugin-dts:options"),ne=V((t={})=>{b("resolving dts options");const e=I(t);b("resolved dts options %o",e);const r=[];return t.dtsInput?r.push(z(e)):r.push(C(e)),r.push(G(e),T(e)),(t.banner||t.footer)&&r.push(U(e)),r},"dts");export{k as RE_CSS,p as RE_DTS,ie as RE_DTS_MAP,ae as RE_JS,N as RE_JSON,j as RE_NODE_MODULES,$ as RE_TS,D as RE_VUE,T as createFakeJsPlugin,C as createGeneratePlugin,ne as dts,I as resolveOptions};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var Se=Object.defineProperty;var _=(e,i)=>Se(e,"name",{value:i,configurable:!0});import ie from"node:path";import{generate as ae}from"@babel/generator";import{isIdentifierName as Ee}from"@babel/helper-validator-identifier";import{parse as oe}from"@babel/parser";import f from"@babel/types";import{isTypeOf as K,isDeclarationType as De,walkAST as V,resolveString as H,isIdentifierOf as Z}from"ast-kit";import{RE_DTS as P,resolveTemplateFn as be,filename_js_to_dts as se,replaceTemplateName as le,filename_dts_to as ce,RE_DTS_MAP as Te,filename_to_dts as ve}from"../filename.js";var Ie=Object.defineProperty,E=_((e,i)=>Ie(e,"name",{value:i,configurable:!0}),"c");const z="__rollup_dts_resolve__:",Qe=E(({cjsDefault:e,sideEffects:i,sourcemap:S})=>{let t=0;const M=new Map,O=new Map,B=new Map;return{generateBundle(p,o){const u=new Map;for(const n of Object.values(o))if(n.type==="chunk")for(const y of n.moduleIds)u.set(y,n.fileName);const d=new RegExp(`"${z}(.+?)"`,"g");for(const n of Object.values(o))n.type!=="chunk"||!P.test(n.fileName)||n.code.includes(z)&&(n.code=n.code.replaceAll(d,(y,C)=>{const x=u.get(C);if(!x)return y;let v=ie.posix.relative(ie.posix.dirname(n.fileName),x);return v.startsWith(".")||(v=`./${v}`),v=ce(v,"js"),JSON.stringify(v)}));for(const n of Object.values(o))if(Te.test(n.fileName))if(S){if(n.type==="chunk"||typeof n.source!="string")continue;const y=JSON.parse(n.source);y.sourcesContent=void 0,n.source=JSON.stringify(y)}else delete o[n.fileName]},name:"rollup-plugin-dts:fake-js",outputOptions(p){const{chunkFileNames:o,entryFileNames:u}=p;return(p.format==="cjs"||p.format==="commonjs")&&(p={...p,format:"es"}),{...p,chunkFileNames(d){const n=be(d.isEntry?u||"[name].js":o||"[name]-[hash].js",d);if(d.name.endsWith(".d")){const y=se(le(n,d.name.slice(0,-2)));if(P.test(y))return y;const C=se(le(n,d.name));if(P.test(C))return C}return n},sourcemap:p.sourcemap||S}},renderChunk:k,async transform(p,o){if(P.test(o))return $.call(this,p,o)}};async function $(p,o){const u=Object.create(null),d=oe(p,{createParenthesizedExpressions:!0,errorRecovery:!0,plugins:[["typescript",{dts:!0}],"decoratorAutoAccessors"],sourceType:"module"}),{comments:n,program:y}=d,C=[];if(n){const D=fe(n);O.set(o,D)}const x=[],v=new Map,a=new Map,r=new Set;for(const[D,s]of y.body.entries()){const j=E(c=>y.body[D]=c,"setStmt");if(ke(s,j,C))continue;const w=s.type==="TSModuleDeclaration"&&s.kind!=="namespace";let h;if(w&&s.id.type==="StringLiteral"){const c=await this.resolve(s.id.value,o);c&&!c.external?h=P.test(c.id)?c.id:ve(c.id):s.id.value[0]==="."&&this.warn(`\`declare module ${JSON.stringify(s.id.value)}\` will be kept as-is in the output. Relative module declaration may cause unexpected issues. Found in ${o}.`)}if(w&&o.endsWith(".vue.d.ts")&&p.slice(s.start,s.end).includes("__VLS_"))continue;const U=s.type==="ExportDefaultDeclaration",W=K(s,["ExportNamedDeclaration","ExportDefaultDeclaration"])&&s.declaration,b=W?s.declaration:s,J=W?c=>s.declaration=c:j;if(b.type!=="TSDeclareFunction"&&!De(b))continue;K(b,["TSEnumDeclaration","ClassDeclaration","FunctionDeclaration","TSDeclareFunction","TSModuleDeclaration","VariableDeclaration"])&&(b.declare=!0);const I=[];if(b.type==="VariableDeclaration")I.push(...b.declarations.map(c=>c.id));else if("id"in b&&b.id){let c=b.id;c.type==="TSQualifiedName"&&(c=X(c)),c=w?f.identifier(`_${L(u,"")}`):c,I.push(c)}else{const c=f.identifier("export_default");I.push(c),b.id=c}const A=me(b),l=new Set,g=xe(b,v,l,u),m=[...l].filter(c=>I.every(N=>c!==N));if(b!==s&&(b.leadingComments=s.leadingComments),b.type==="TSDeclareFunction"&&I.length===1&&a.has(I[0].name)){const c=a.get(I[0].name),N=Y(c);N.overloads||(N.overloads=[],N.primaryDepsCount=N.deps.length,N.primaryParamsCount=N.params.length,N.primaryChildrenCount=N.children.length),N.overloads.push({children:m,childrenOffset:N.children.length,decl:b,deps:g,depsOffset:N.deps.length,params:A,paramsOffset:N.params.length}),N.deps.push(...g),N.params.push(...A),N.children.push(...m),r.add(D);continue}const T=q({bindings:I,children:m,decl:b,deps:g,params:A,resolvedModuleId:h});b.type==="TSDeclareFunction"&&I.length===1&&a.set(I[0].name,T);const Q=f.numericLiteral(T),ee=f.arrowFunctionExpression(A.map(({name:c})=>f.identifier(c)),f.arrayExpression(g)),te=f.arrayExpression(m.map(c=>({end:c.end,loc:c.loc,start:c.start,type:"StringLiteral",value:""}))),re=w&&f.callExpression(f.identifier("sideEffect"),[I[0]]),ge=Me(re?[Q,ee,te,re]:[Q,ee,te]),ne={declarations:[{id:{...I[0],typeAnnotation:null},init:ge,type:"VariableDeclarator"},...I.slice(1).map(c=>({id:{...c,typeAnnotation:null},type:"VariableDeclarator"}))],kind:"var",type:"VariableDeclaration"};U?(x.push(f.exportNamedDeclaration(null,[f.exportSpecifier(I[0],f.identifier("default"))])),j(ne)):J(ne)}return i&&x.push(f.expressionStatement(f.callExpression(f.identifier("sideEffect"),[]))),y.body=[...Array.from(v.values(),({stmt:D})=>D),...y.body.filter((D,s)=>!r.has(s)),...x],B.set(o,C),ae(d,{comments:!1,sourceFileName:o,sourceMaps:S})}function k(p,o){if(!P.test(o.fileName))return;const u=[];for(const a of o.moduleIds){const r=B.get(a);r&&u.push(...r)}const d=oe(p,{sourceType:"module"}),{program:n}=d;if(n.body=Ae(n.body),n.body=Pe(n.body),n.body=n.body.flatMap(a=>{if(je(a))return[];if(a.type==="ExpressionStatement")return[];const r=we(a,u,e);if(r===!1)return[];if(r)return[r];if(a.type!=="VariableDeclaration")return[a];if(!Ce(a))return[];const[D,s,j]=a.declarations[0].init.elements,w=D.value,h=Y(w);V(h.decl,{enter(l){l.type!=="CommentBlock"&&(l.leadingComments?.length||delete l.loc)}});for(const[l,g]of a.declarations.entries()){const m={...g.id,typeAnnotation:h.bindings[l].typeAnnotation};R(h.bindings[l],m)}const U=h.primaryChildrenCount??h.children.length,W=h.primaryParamsCount??h.params.length,b=h.primaryDepsCount??h.deps.length;for(let l=0;l<U;l++){const g=j.elements[l];Object.assign(h.children[l],{loc:g.loc})}const J=s.params;for(let l=0;l<W;l++){const g=J[l].name;for(const m of h.params[l].typeParams)m.name=g}const I=s.body.elements;for(let l=0;l<b;l++){const g=h.deps[l];let m=I[l];m&&m.type==="UnaryExpression"&&m.operator==="void"?m={...f.identifier("undefined"),end:m.end,loc:m.loc,start:m.start}:G(m)&&(m.name="__Infer"),g.replace?g.replace(m):Object.assign(g,m)}h.decl.type==="TSModuleDeclaration"&&h.resolvedModuleId&&(h.decl.id.value=z+h.resolvedModuleId);const A=[];if(h.overloads)for(const l of h.overloads){V(l.decl,{enter(g){g.type!=="CommentBlock"&&delete g.loc}}),"id"in l.decl&&l.decl.id&&R(l.decl.id,{...h.bindings[0]});for(const[g,m]of l.children.entries()){const T=j.elements[l.childrenOffset+g];T&&Object.assign(m,{loc:T.loc})}for(const[g,m]of l.params.entries()){const T=J[l.paramsOffset+g];if(T)for(const Q of m.typeParams)Q.name=T.name}for(const[g,m]of l.deps.entries()){let T=I[l.depsOffset+g];T&&(T.type==="UnaryExpression"&&T.operator==="void"?T={...f.identifier("undefined"),end:T.end,loc:T.loc,start:T.start}:G(T)&&(T.name="__Infer"),m.replace?m.replace(T):Object.assign(m,T))}A.push(l.decl)}return[Re(a,h.decl),...A]}).filter(a=>!!a),n.body.length===0)return"export { };";const y=n.body.some(a=>a.type==="ExportNamedDeclaration"||a.type==="ExportDefaultDeclaration"||a.type==="ExportAllDeclaration"),C=n.body.some(a=>a.type==="TSModuleDeclaration"&&a.id.type==="StringLiteral");!y&&C&&n.body.push({declaration:null,source:null,specifiers:[],type:"ExportNamedDeclaration"});const x=new Set,v=new Set;for(const a of o.moduleIds){const r=O.get(a);r&&(r.forEach(D=>{const s=D.type+D.value;v.has(s)||(v.add(s),x.add(D))}),O.delete(a))}return x.size>0&&(n.body[0].leadingComments||=[],n.body[0].leadingComments.unshift(...x)),ae(d,{comments:!0,sourceFileName:o.fileName,sourceMaps:S})}function L(p,o){return o in p?p[o]++:p[o]=0}function q(p){const o=t++;return M.set(o,p),o}function Y(p){return M.get(p)}function me(p){const o=[];V(p,{leave(d){"typeParameters"in d&&d.typeParameters?.type==="TSTypeParameterDeclaration"&&o.push(...d.typeParameters.params)}});const u=new Map;for(const d of o){const{name:n}=d,y=u.get(n);y?y.push(d):u.set(n,[d])}return Array.from(u.entries(),([d,n])=>({name:d,typeParams:n}))}function ye(p){const o=[];return V(p,{enter(u){u.type==="TSInferType"&&u.typeParameter&&o.push(u.typeParameter.name)}}),o}function xe(p,o,u,d){const n=new Set,y=new Set,C=[];let x=new Set;function v(r){return r.type==="Identifier"&&x.has(r.name)}return _(v,"N"),E(v,"isInferred"),V(p,{enter(r){if(r.type==="TSConditionalType"){const D=ye(r.extendsType);C.push(D)}},leave(r,D){if(r.type==="TSConditionalType")C.pop();else if(D?.type==="TSConditionalType"){const s=D.trueType===r;x=new Set((s?C:C.slice(0,-1)).flat())}else x=new Set;if(r.type==="ExportNamedDeclaration")for(const s of r.specifiers)s.type==="ExportSpecifier"&&a(s.local);else if(r.type==="TSInterfaceDeclaration"&&r.extends)for(const s of r.extends||[])a(F(s.expression));else if(r.type==="ClassDeclaration"){if(r.superClass&&a(r.superClass),r.implements)for(const s of r.implements)s.type!=="ClassImplements"&&a(F(s.expression))}else if(K(r,["ObjectMethod","ObjectProperty","ClassProperty","TSPropertySignature","TSDeclareMethod"]))r.computed&&pe(r.key)&&a(r.key),"value"in r&&pe(r.value)&&a(r.value);else switch(r.type){case"TSImportType":{y.add(r);const s=r.argument,j=r.qualifier,w=he(r,j,s,o,d);a(w);break}case"TSTypeQuery":{if(y.has(r.exprName))return;if(r.exprName.type==="TSImportType")break;a(F(r.exprName));break}case"TSTypeReference":{a(F(r.typeName));break}}D&&!n.has(r)&&de(r,D)&&u.add(r)}}),[...n];function a(r){ue(r)||v(r)||n.add(r)}_(a,"R")}function he(p,o,u,d,n){const y=u.value.replaceAll(/\W/g,"_"),C=Ee(u.value)?u.value:`${y}${L(n,y)}`;let x=f.identifier(C);if(d.has(u.value)?x=d.get(u.value).local:d.set(u.value,{local:x,stmt:f.importDeclaration([f.importNamespaceSpecifier(x)],u)}),o){const a=X(o);R(a,f.tsQualifiedName(x,{...a})),x=o}let v=p;return p.typeParameters?(R(p,f.tsTypeReference(x,p.typeParameters)),v=x):R(p,x),{...F(x),replace(a){R(v,a)}}}},"createFakeJsPlugin");function de(e,i){return!!(e.type==="Identifier"||K(i,["TSPropertySignature","TSMethodSignature"])&&i.key===e)}_(de,"Ie");E(de,"isChildSymbol");const Ne=/\/\s*<reference\s+(?:path|types)=/,fe=E((e,i=!1)=>e.filter(S=>Ne.test(S.value)!==i),"collectReferenceDirectives"),Ce=E(e=>f.isVariableDeclaration(e)&&e.declarations.length>0&&f.isVariableDeclarator(e.declarations[0])&&_e(e.declarations[0].init),"isRuntimeBindingVariableDeclaration"),_e=E(e=>f.isArrayExpression(e)&&Oe(e.elements),"isRuntimeBindingArrayExpression"),Me=E(e=>f.arrayExpression(e),"runtimeBindingArrayExpression"),Oe=E(e=>{const[i,S,t,M]=e;return i?.type==="NumericLiteral"&&S?.type==="ArrowFunctionExpression"&&t?.type==="ArrayExpression"&&(!M||M.type==="CallExpression")},"isRuntimeBindingArrayElements"),G=E(e=>Z(e,"infer"),"isInfer"),ue=E(e=>Z(e,"this")||e.type==="ThisExpression"||e.type==="MemberExpression"&&ue(e.object),"isThisExpression"),F=E(e=>{if(e.type==="Identifier")return e;const i=F(e.left);return Object.assign(e,f.memberExpression(i,e.right))},"TSEntityNameToRuntime"),X=E(e=>e.type==="Identifier"?e:X(e.left),"getIdFromTSEntityName"),pe=E(e=>K(e,["Identifier","MemberExpression"]),"isReferenceId"),je=E(e=>e.type==="ImportDeclaration"&&e.specifiers.length===1&&e.specifiers.every(i=>i.type==="ImportSpecifier"&&i.imported.type==="Identifier"&&["__export","__reExport"].includes(i.local.name)),"isHelperImport"),we=E((e,i,S)=>{if(e.type==="ExportNamedDeclaration"&&!e.declaration&&!e.source&&e.specifiers.length===0&&!e.attributes?.length)return!1;if(e.type==="ImportDeclaration"&&e.specifiers.length)for(const t of e.specifiers)G(t.local)&&(t.local.name="__Infer");if(K(e,["ImportDeclaration","ExportAllDeclaration","ExportNamedDeclaration"])){if(e.type==="ExportNamedDeclaration"&&i.length>0)for(const t of e.specifiers){const M=H(t.exported);i.includes(M)&&(t.type==="ExportSpecifier"?t.exportKind="type":e.exportKind="type")}if(e.source?.value&&P.test(e.source.value))return e.source.value=ce(e.source.value,"js"),e;if(S&&e.type==="ExportNamedDeclaration"&&!e.source&&e.specifiers.length===1&&e.specifiers[0].type==="ExportSpecifier"&&H(e.specifiers[0].exported)==="default")return{expression:e.specifiers[0].local,type:"TSExportAssignment"}}},"patchImportExport"),Ae=E(e=>{const i=new Set;for(const[t,M]of e.entries()){const O=S(M);if(!O)continue;const[B,$]=O;$.properties.length!==0&&(e[t]={body:{body:[{declaration:null,source:null,specifiers:$.properties.filter(k=>k.type==="ObjectProperty").map(k=>{const L=k.value.body,q=k.key;return f.exportSpecifier(L,q)}),type:"ExportNamedDeclaration"}],type:"TSModuleBlock"},declare:!0,id:B,kind:"namespace",type:"TSModuleDeclaration"})}return e.filter(t=>!i.has(t));function S(t){if(t.type!=="VariableDeclaration"||t.declarations.length!==1||t.declarations[0].id.type!=="Identifier"||t.declarations[0].init?.type!=="CallExpression"||t.declarations[0].init.callee.type!=="Identifier"||t.declarations[0].init.callee.name!=="__export"||t.declarations[0].init.arguments.length!==1||t.declarations[0].init.arguments[0].type!=="ObjectExpression")return!1;const M=t.declarations[0].id,O=t.declarations[0].init.arguments[0];return[M,O]}},"patchTsNamespace"),Pe=E(e=>{const i=new Map;for(const[S,t]of e.entries())if(t.type==="ImportDeclaration"&&t.specifiers.length===1&&t.specifiers[0].type==="ImportSpecifier"&&t.specifiers[0].local.type==="Identifier"&&t.specifiers[0].local.name.endsWith("_exports"))i.set(t.specifiers[0].local.name,t.specifiers[0].local.name);else if(t.type==="ExpressionStatement"&&t.expression.type==="CallExpression"&&Z(t.expression.callee,"__reExport")){const M=t.expression.arguments;i.set(M[0].name,M[1].name)}else t.type==="VariableDeclaration"&&t.declarations.length===1&&t.declarations[0].init?.type==="MemberExpression"&&t.declarations[0].init.object.type==="Identifier"&&i.has(t.declarations[0].init.object.name)?e[S]={id:{name:t.declarations[0].id.name,type:"Identifier"},type:"TSTypeAliasDeclaration",typeAnnotation:{type:"TSTypeReference",typeName:{left:{name:i.get(t.declarations[0].init.object.name),type:"Identifier"},right:{name:t.declarations[0].init.property.name,type:"Identifier"},type:"TSQualifiedName"}}}:t.type==="ExportNamedDeclaration"&&t.specifiers.length===1&&t.specifiers[0].type==="ExportSpecifier"&&t.specifiers[0].local.type==="Identifier"&&i.has(t.specifiers[0].local.name)&&(t.specifiers[0].local.name=i.get(t.specifiers[0].local.name));return e},"patchReExport"),ke=E((e,i,S)=>{if(e.type==="ImportDeclaration"||e.type==="ExportNamedDeclaration"&&!e.declaration){for(const t of e.specifiers)("exportKind"in t&&t.exportKind==="type"||"exportKind"in e&&e.exportKind==="type")&&S.push(H(t.exported)),t.type==="ImportSpecifier"?t.importKind="value":t.type==="ExportSpecifier"&&(t.exportKind="value");return e.type==="ImportDeclaration"?e.importKind="value":e.type==="ExportNamedDeclaration"&&(e.exportKind="value"),!0}return e.type==="ExportAllDeclaration"?(e.exportKind="value",!0):e.type==="TSImportEqualsDeclaration"?(e.moduleReference.type==="TSExternalModuleReference"&&i({source:e.moduleReference.expression,specifiers:[{local:e.id,type:"ImportDefaultSpecifier"}],type:"ImportDeclaration"}),!0):e.type==="TSExportAssignment"&&e.expression.type==="Identifier"?(i({specifiers:[{exported:{name:"default",type:"Identifier"},local:e.expression,type:"ExportSpecifier"}],type:"ExportNamedDeclaration"}),!0):e.type==="ExportDefaultDeclaration"&&e.declaration.type==="Identifier"?(i({specifiers:[{exported:f.identifier("default"),local:e.declaration,type:"ExportSpecifier"}],type:"ExportNamedDeclaration"}),!0):!1},"rewriteImportExport"),R=E((e,i)=>{for(const S of Object.keys(e))delete e[S];return Object.assign(e,i),e},"overwriteNode"),Re=E((e,i)=>{i.leadingComments||=[];const S=e.leadingComments?.filter(t=>t.value.startsWith("#"));return S&&i.leadingComments.unshift(...S),i.leadingComments=fe(i.leadingComments,!0),i},"inheritNodeComments");export{Qe as default};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var Se=Object.defineProperty;var C=(e,a)=>Se(e,"name",{value:a,configurable:!0});import ie from"node:path";import{generate as ae}from"@babel/generator";import{isIdentifierName as Ee}from"@babel/helper-validator-identifier";import{parse as oe}from"@babel/parser";import f from"@babel/types";import{isTypeOf as R,isDeclarationType as De,walkAST as V,resolveString as z,isIdentifierOf as X}from"ast-kit";import{RE_DTS as M,resolveTemplateFn as be,filename_js_to_dts as se,replaceTemplateName as le,filename_dts_to as ce,RE_DTS_MAP as ve,filename_to_dts as Te}from"../filename.js";var Ie=Object.defineProperty,v=C((e,a)=>Ie(e,"name",{value:a,configurable:!0}),"c");const U="__rollup_dts_resolve__:",Qe=v(({cjsDefault:e,sideEffects:a,sourcemap:D})=>{let t=0;const _=new Map,j=new Map,K=new Map;return{generateBundle(l,o){const u=new Map;for(const i of Object.values(o))if(i.type==="chunk")for(const m of i.moduleIds)u.set(m,i.fileName);const d=new RegExp(`"${U}(.+?)"`,"g");for(const i of Object.values(o))i.type!=="chunk"||!M.test(i.fileName)||i.code.includes(U)&&(i.code=i.code.replaceAll(d,(m,T)=>{const s=u.get(T);if(!s)return m;let x=ie.posix.relative(ie.posix.dirname(i.fileName),s);return x.startsWith(".")||(x=`./${x}`),x=ce(x,"js"),JSON.stringify(x)}));for(const i of Object.values(o))if(ve.test(i.fileName))if(D){if(i.type==="chunk"||typeof i.source!="string")continue;const m=JSON.parse(i.source);m.sourcesContent=void 0,i.source=JSON.stringify(m)}else delete o[i.fileName]},name:"rollup-plugin-dts:fake-js",outputOptions(l){const{chunkFileNames:o,entryFileNames:u}=l;return(l.format==="cjs"||l.format==="commonjs")&&(l={...l,format:"es"}),{...l,chunkFileNames(d){const i=be(d.isEntry?u||"[name].js":o||"[name]-[hash].js",d);if(d.name.endsWith(".d")){const m=se(le(i,d.name.slice(0,-2)));if(M.test(m))return m;const T=se(le(i,d.name));if(M.test(T))return T}return i},sourcemap:l.sourcemap||D}},renderChunk:O,async transform(l,o){if(M.test(o))return B.call(this,l,o)}};async function B(l,o){const u=Object.create(null),d=oe(l,{createParenthesizedExpressions:!0,errorRecovery:!0,plugins:[["typescript",{dts:!0}],"decoratorAutoAccessors"],sourceType:"module"}),{comments:i,program:m}=d,T=[];if(i){const I=fe(i);j.set(o,I)}const s=[],x=new Map,g=new Map,r=new Set;for(const[I,p]of m.body.entries()){const y=v(c=>m.body[I]=c,"setStmt");if(Ae(p,y,T))continue;const w=p.type==="TSModuleDeclaration"&&p.kind!=="namespace";let W;if(w&&p.id.type==="StringLiteral"){const c=await this.resolve(p.id.value,o);c&&!c.external?W=M.test(c.id)?c.id:Te(c.id):p.id.value[0]==="."&&this.warn(`\`declare module ${JSON.stringify(p.id.value)}\` will be kept as-is in the output. Relative module declaration may cause unexpected issues. Found in ${o}.`)}if(w&&o.endsWith(".vue.d.ts")&&l.slice(p.start,p.end).includes("__VLS_"))continue;const Q=p.type==="ExportDefaultDeclaration",F=R(p,["ExportNamedDeclaration","ExportDefaultDeclaration"])&&p.declaration,b=F?p.declaration:p,L=F?c=>p.declaration=c:y;if(b.type!=="TSDeclareFunction"&&!De(b))continue;R(b,["TSEnumDeclaration","ClassDeclaration","FunctionDeclaration","TSDeclareFunction","TSModuleDeclaration","VariableDeclaration"])&&(b.declare=!0);const n=[];if(b.type==="VariableDeclaration")n.push(...b.declarations.map(c=>c.id));else if("id"in b&&b.id){let c=b.id;c.type==="TSQualifiedName"&&(c=H(c)),c=w?f.identifier(`_${$(u,"")}`):c,n.push(c)}else{const c=f.identifier("export_default");n.push(c),b.id=c}const S=me(b),h=new Set,E=he(b,x,h,u),k=[...h].filter(c=>n.every(N=>c!==N));if(b!==p&&(b.leadingComments=p.leadingComments),b.type==="TSDeclareFunction"&&n.length===1&&g.has(n[0].name)){const c=g.get(n[0].name),N=Y(c);N.overloads||(N.overloads=[],N.primaryDepsCount=N.deps.length,N.primaryParamsCount=N.params.length,N.primaryChildrenCount=N.children.length),N.overloads.push({children:k,childrenOffset:N.children.length,decl:b,deps:E,depsOffset:N.deps.length,params:S,paramsOffset:N.params.length}),N.deps.push(...E),N.params.push(...S),N.children.push(...k),r.add(I);continue}const Z=J({bindings:n,children:k,decl:b,deps:E,params:S,resolvedModuleId:W});b.type==="TSDeclareFunction"&&n.length===1&&g.set(n[0].name,Z);const G=f.numericLiteral(Z),ee=f.arrowFunctionExpression(S.map(({name:c})=>f.identifier(c)),f.arrayExpression(E)),te=f.arrayExpression(k.map(c=>({end:c.end,loc:c.loc,start:c.start,type:"StringLiteral",value:""}))),re=w&&f.callExpression(f.identifier("sideEffect"),[n[0]]),ge=je(re?[G,ee,te,re]:[G,ee,te]),ne={declarations:[{id:{...n[0],typeAnnotation:null},init:ge,type:"VariableDeclarator"},...n.slice(1).map(c=>({id:{...c,typeAnnotation:null},type:"VariableDeclarator"}))],kind:"var",type:"VariableDeclaration"};Q?(s.push(f.exportNamedDeclaration(null,[f.exportSpecifier(n[0],f.identifier("default"))])),y(ne)):L(ne)}return a&&s.push(f.expressionStatement(f.callExpression(f.identifier("sideEffect"),[]))),m.body=[...Array.from(x.values(),({stmt:I})=>I),...m.body.filter((I,p)=>!r.has(p)),...s],K.set(o,T),ae(d,{comments:!1,sourceFileName:o,sourceMaps:D})}function O(l,o){if(!M.test(o.fileName))return;const u=[];for(const s of o.moduleIds){const x=K.get(s);x&&u.push(...x)}const d=oe(l,{sourceType:"module"}),{program:i}=d;if(i.body=ke(i.body),i.body=Pe(i.body),i.body=i.body.flatMap(s=>{if(Me(s))return[];if(s.type==="ExpressionStatement")return[];const x=Oe(s,u,e);if(x===!1)return[];if(x)return[x];if(s.type!=="VariableDeclaration")return[s];if(!Ce(s))return[];const[g,r,I]=s.declarations[0].init.elements,p=g.value,y=Y(p);V(y.decl,{enter(n){n.type!=="CommentBlock"&&delete n.loc}});for(const[n,S]of s.declarations.entries()){const h={...S.id,typeAnnotation:y.bindings[n].typeAnnotation};P(y.bindings[n],h)}const w=y.primaryChildrenCount??y.children.length,W=y.primaryParamsCount??y.params.length,Q=y.primaryDepsCount??y.deps.length;for(let n=0;n<w;n++){const S=I.elements[n];Object.assign(y.children[n],{loc:S.loc})}const F=r.params;for(let n=0;n<W;n++){const S=F[n].name;for(const h of y.params[n].typeParams)h.name=S}const b=r.body.elements;for(let n=0;n<Q;n++){const S=y.deps[n];let h=b[n];h&&h.type==="UnaryExpression"&&h.operator==="void"?h={...f.identifier("undefined"),end:h.end,loc:h.loc,start:h.start}:q(h)&&(h.name="__Infer"),S.replace?S.replace(h):Object.assign(S,h)}y.decl.type==="TSModuleDeclaration"&&y.resolvedModuleId&&(y.decl.id.value=U+y.resolvedModuleId);const L=[];if(y.overloads)for(const n of y.overloads){V(n.decl,{enter(S){S.type!=="CommentBlock"&&delete S.loc}}),"id"in n.decl&&n.decl.id&&P(n.decl.id,{...y.bindings[0]});for(const[S,h]of n.children.entries()){const E=I.elements[n.childrenOffset+S];E&&Object.assign(h,{loc:E.loc})}for(const[S,h]of n.params.entries()){const E=F[n.paramsOffset+S];if(E)for(const k of h.typeParams)k.name=E.name}for(const[S,h]of n.deps.entries()){let E=b[n.depsOffset+S];E&&(E.type==="UnaryExpression"&&E.operator==="void"?E={...f.identifier("undefined"),end:E.end,loc:E.loc,start:E.start}:q(E)&&(E.name="__Infer"),h.replace?h.replace(E):Object.assign(h,E))}L.push(n.decl)}return[Re(s,y.decl),...L]}).filter(s=>!!s),i.body.length===0)return"export { };";const m=new Set,T=new Set;for(const s of o.moduleIds){const x=j.get(s);x&&(x.forEach(g=>{const r=g.type+g.value;T.has(r)||(T.add(r),m.add(g))}),j.delete(s))}return m.size>0&&(i.body[0].leadingComments||=[],i.body[0].leadingComments.unshift(...m)),ae(d,{comments:!0,sourceFileName:o.fileName,sourceMaps:D})}function $(l,o){return o in l?l[o]++:l[o]=0}function J(l){const o=t++;return _.set(o,l),o}function Y(l){return _.get(l)}function me(l){const o=[];V(l,{leave(d){"typeParameters"in d&&d.typeParameters?.type==="TSTypeParameterDeclaration"&&o.push(...d.typeParameters.params)}});const u=new Map;for(const d of o){const{name:i}=d,m=u.get(i);m?m.push(d):u.set(i,[d])}return Array.from(u.entries(),([d,i])=>({name:d,typeParams:i}))}function ye(l){const o=[];return V(l,{enter(u){u.type==="TSInferType"&&u.typeParameter&&o.push(u.typeParameter.name)}}),o}function he(l,o,u,d){const i=new Set,m=new Set,T=[];let s=new Set;function x(r){return r.type==="Identifier"&&s.has(r.name)}return C(x,"p"),v(x,"isInferred"),V(l,{enter(r){if(r.type==="TSConditionalType"){const I=ye(r.extendsType);T.push(I)}},leave(r,I){if(r.type==="TSConditionalType")T.pop();else if(I?.type==="TSConditionalType"){const p=I.trueType===r;s=new Set((p?T:T.slice(0,-1)).flat())}else s=new Set;if(r.type==="ExportNamedDeclaration")for(const p of r.specifiers)p.type==="ExportSpecifier"&&g(p.local);else if(r.type==="TSInterfaceDeclaration"&&r.extends)for(const p of r.extends||[])g(A(p.expression));else if(r.type==="ClassDeclaration"){if(r.superClass&&g(r.superClass),r.implements)for(const p of r.implements)p.type!=="ClassImplements"&&g(A(p.expression))}else if(R(r,["ObjectMethod","ObjectProperty","ClassProperty","TSPropertySignature","TSDeclareMethod"]))r.computed&&pe(r.key)&&g(r.key),"value"in r&&pe(r.value)&&g(r.value);else switch(r.type){case"TSImportType":{m.add(r);const p=r.argument,y=r.qualifier,w=xe(r,y,p,o,d);g(w);break}case"TSTypeQuery":{if(m.has(r.exprName))return;if(r.exprName.type==="TSImportType")break;g(A(r.exprName));break}case"TSTypeReference":{g(A(r.typeName));break}}I&&!i.has(r)&&de(r,I)&&u.add(r)}}),[...i];function g(r){ue(r)||x(r)||i.add(r)}C(g,"x")}function xe(l,o,u,d,i){const m=u.value.replaceAll(/\W/g,"_"),T=Ee(u.value)?u.value:`${m}${$(i,m)}`;let s=f.identifier(T);if(d.has(u.value)?s=d.get(u.value).local:d.set(u.value,{local:s,stmt:f.importDeclaration([f.importNamespaceSpecifier(s)],u)}),o){const g=H(o);P(g,f.tsQualifiedName(s,{...g})),s=o}let x=l;return l.typeParameters?(P(l,f.tsTypeReference(s,l.typeParameters)),x=s):P(l,s),{...A(s),replace(g){P(x,g)}}}},"createFakeJsPlugin");function de(e,a){return!!(e.type==="Identifier"||R(a,["TSPropertySignature","TSMethodSignature"])&&a.key===e)}C(de,"be");v(de,"isChildSymbol");const Ne=/\/\s*<reference\s+(?:path|types)=/,fe=v((e,a=!1)=>e.filter(D=>Ne.test(D.value)!==a),"collectReferenceDirectives"),Ce=v(e=>f.isVariableDeclaration(e)&&e.declarations.length>0&&f.isVariableDeclarator(e.declarations[0])&&_e(e.declarations[0].init),"isRuntimeBindingVariableDeclaration"),_e=v(e=>f.isArrayExpression(e)&&we(e.elements),"isRuntimeBindingArrayExpression"),je=v(e=>f.arrayExpression(e),"runtimeBindingArrayExpression"),we=v(e=>{const[a,D,t,_]=e;return a?.type==="NumericLiteral"&&D?.type==="ArrowFunctionExpression"&&t?.type==="ArrayExpression"&&(!_||_.type==="CallExpression")},"isRuntimeBindingArrayElements"),q=v(e=>X(e,"infer"),"isInfer"),ue=v(e=>X(e,"this")||e.type==="ThisExpression"||e.type==="MemberExpression"&&ue(e.object),"isThisExpression"),A=v(e=>{if(e.type==="Identifier")return e;const a=A(e.left);return Object.assign(e,f.memberExpression(a,e.right))},"TSEntityNameToRuntime"),H=v(e=>e.type==="Identifier"?e:H(e.left),"getIdFromTSEntityName"),pe=v(e=>R(e,["Identifier","MemberExpression"]),"isReferenceId"),Me=v(e=>e.type==="ImportDeclaration"&&e.specifiers.length===1&&e.specifiers.every(a=>a.type==="ImportSpecifier"&&a.imported.type==="Identifier"&&["__export","__reExport"].includes(a.local.name)),"isHelperImport"),Oe=v((e,a,D)=>{if(e.type==="ExportNamedDeclaration"&&!e.declaration&&!e.source&&e.specifiers.length===0&&!e.attributes?.length)return!1;if(e.type==="ImportDeclaration"&&e.specifiers.length)for(const t of e.specifiers)q(t.local)&&(t.local.name="__Infer");if(R(e,["ImportDeclaration","ExportAllDeclaration","ExportNamedDeclaration"])){if(e.type==="ExportNamedDeclaration"&&a.length>0)for(const t of e.specifiers){const _=z(t.exported);a.includes(_)&&(t.type==="ExportSpecifier"?t.exportKind="type":e.exportKind="type")}if(e.source?.value&&M.test(e.source.value))return e.source.value=ce(e.source.value,"js"),e;if(D&&e.type==="ExportNamedDeclaration"&&!e.source&&e.specifiers.length===1&&e.specifiers[0].type==="ExportSpecifier"&&z(e.specifiers[0].exported)==="default")return{expression:e.specifiers[0].local,type:"TSExportAssignment"}}},"patchImportExport"),ke=v(e=>{const a=new Set;for(const[t,_]of e.entries()){const j=D(_);if(!j)continue;const[K,B]=j;B.properties.length!==0&&(e[t]={body:{body:[{declaration:null,source:null,specifiers:B.properties.filter(O=>O.type==="ObjectProperty").map(O=>{const $=O.value.body,J=O.key;return f.exportSpecifier($,J)}),type:"ExportNamedDeclaration"}],type:"TSModuleBlock"},declare:!0,id:K,kind:"namespace",type:"TSModuleDeclaration"})}return e.filter(t=>!a.has(t));function D(t){if(t.type!=="VariableDeclaration"||t.declarations.length!==1||t.declarations[0].id.type!=="Identifier"||t.declarations[0].init?.type!=="CallExpression"||t.declarations[0].init.callee.type!=="Identifier"||t.declarations[0].init.callee.name!=="__export"||t.declarations[0].init.arguments.length!==1||t.declarations[0].init.arguments[0].type!=="ObjectExpression")return!1;const _=t.declarations[0].id,j=t.declarations[0].init.arguments[0];return[_,j]}},"patchTsNamespace"),Pe=v(e=>{const a=new Map;for(const[D,t]of e.entries())if(t.type==="ImportDeclaration"&&t.specifiers.length===1&&t.specifiers[0].type==="ImportSpecifier"&&t.specifiers[0].local.type==="Identifier"&&t.specifiers[0].local.name.endsWith("_exports"))a.set(t.specifiers[0].local.name,t.specifiers[0].local.name);else if(t.type==="ExpressionStatement"&&t.expression.type==="CallExpression"&&X(t.expression.callee,"__reExport")){const _=t.expression.arguments;a.set(_[0].name,_[1].name)}else t.type==="VariableDeclaration"&&t.declarations.length===1&&t.declarations[0].init?.type==="MemberExpression"&&t.declarations[0].init.object.type==="Identifier"&&a.has(t.declarations[0].init.object.name)?e[D]={id:{name:t.declarations[0].id.name,type:"Identifier"},type:"TSTypeAliasDeclaration",typeAnnotation:{type:"TSTypeReference",typeName:{left:{name:a.get(t.declarations[0].init.object.name),type:"Identifier"},right:{name:t.declarations[0].init.property.name,type:"Identifier"},type:"TSQualifiedName"}}}:t.type==="ExportNamedDeclaration"&&t.specifiers.length===1&&t.specifiers[0].type==="ExportSpecifier"&&t.specifiers[0].local.type==="Identifier"&&a.has(t.specifiers[0].local.name)&&(t.specifiers[0].local.name=a.get(t.specifiers[0].local.name));return e},"patchReExport"),Ae=v((e,a,D)=>{if(e.type==="ImportDeclaration"||e.type==="ExportNamedDeclaration"&&!e.declaration){for(const t of e.specifiers)("exportKind"in t&&t.exportKind==="type"||"exportKind"in e&&e.exportKind==="type")&&D.push(z(t.exported)),t.type==="ImportSpecifier"?t.importKind="value":t.type==="ExportSpecifier"&&(t.exportKind="value");return e.type==="ImportDeclaration"?e.importKind="value":e.type==="ExportNamedDeclaration"&&(e.exportKind="value"),!0}return e.type==="ExportAllDeclaration"?(e.exportKind="value",!0):e.type==="TSImportEqualsDeclaration"?(e.moduleReference.type==="TSExternalModuleReference"&&a({source:e.moduleReference.expression,specifiers:[{local:e.id,type:"ImportDefaultSpecifier"}],type:"ImportDeclaration"}),!0):e.type==="TSExportAssignment"&&e.expression.type==="Identifier"?(a({specifiers:[{exported:{name:"default",type:"Identifier"},local:e.expression,type:"ExportSpecifier"}],type:"ExportNamedDeclaration"}),!0):e.type==="ExportDefaultDeclaration"&&e.declaration.type==="Identifier"?(a({specifiers:[{exported:f.identifier("default"),local:e.declaration,type:"ExportSpecifier"}],type:"ExportNamedDeclaration"}),!0):!1},"rewriteImportExport"),P=v((e,a)=>{for(const D of Object.keys(e))delete e[D];return Object.assign(e,a),e},"overwriteNode"),Re=v((e,a)=>{a.leadingComments||=[];const D=e.leadingComments?.filter(t=>t.value.startsWith("#"));return D&&a.leadingComments.unshift(...D),a.leadingComments=fe(a.leadingComments,!0),a},"inheritNodeComments");export{Qe as default};
|