@dtsx/dtsx 0.0.0-stage → 0.11.37
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/LICENSE.md +21 -0
- package/README.md +442 -2
- package/dist/bin/cli.d.ts +1 -0
- package/dist/bin/cli.js +12 -0
- package/dist/chunk-0azm93j9.js +31 -0
- package/dist/chunk-0ke9xh7t.js +4 -0
- package/dist/chunk-1bpv3tck.js +10 -0
- package/dist/chunk-1e10w914.js +18 -0
- package/dist/chunk-1h6ycqza.js +6 -0
- package/dist/chunk-1j6092xz.js +7 -0
- package/dist/chunk-1pz7zxhc.js +3 -0
- package/dist/chunk-25vyhfzh.js +3 -0
- package/dist/chunk-2kwjbk55.js +3 -0
- package/dist/chunk-437g8zz6.js +177 -0
- package/dist/chunk-4f2mwn7p.js +5 -0
- package/dist/chunk-5hyv43ps.js +12 -0
- package/dist/chunk-5n0tfrpc.js +6 -0
- package/dist/chunk-60ssvwc8.js +4 -0
- package/dist/chunk-69dbf6de.js +3 -0
- package/dist/chunk-7610h2tf.js +3 -0
- package/dist/chunk-79nv7twc.js +14 -0
- package/dist/chunk-853ftm92.js +8 -0
- package/dist/chunk-90aptjh6.js +24 -0
- package/dist/chunk-acyj1dev.js +18 -0
- package/dist/chunk-asws39qs.js +31 -0
- package/dist/chunk-aw48mk3t.js +3 -0
- package/dist/chunk-bdxq6500.js +4 -0
- package/dist/chunk-bqabznps.js +7 -0
- package/dist/chunk-cen2t56g.js +3 -0
- package/dist/chunk-ckq8g1ck.js +4 -0
- package/dist/chunk-cs4gwz1k.js +27 -0
- package/dist/chunk-d43bpfk6.js +3 -0
- package/dist/chunk-dfye109x.js +3 -0
- package/dist/chunk-dv5hhg1a.js +3 -0
- package/dist/chunk-ezbp8tss.js +10 -0
- package/dist/chunk-fgbdm1y6.js +6 -0
- package/dist/chunk-fy97syc2.js +3 -0
- package/dist/chunk-g9d5r6a8.js +3 -0
- package/dist/chunk-ggbahdr2.js +4 -0
- package/dist/chunk-gpq2kggq.js +3 -0
- package/dist/chunk-gs7wfk8b.js +2 -0
- package/dist/chunk-gsb3ty07.js +3 -0
- package/dist/chunk-gsv5yc32.js +6 -0
- package/dist/chunk-h7k9wamx.js +3 -0
- package/dist/chunk-j6pfxvy8.js +3 -0
- package/dist/chunk-km8t8gqg.js +3 -0
- package/dist/chunk-knrtwppp.js +102 -0
- package/dist/chunk-m1khpcqb.js +3 -0
- package/dist/chunk-mt9219xc.js +7 -0
- package/dist/chunk-n2nyd0ck.js +3 -0
- package/dist/chunk-n37yj3xv.js +8 -0
- package/dist/chunk-n3p7wedp.js +3 -0
- package/dist/chunk-n6nw7sn2.js +7 -0
- package/dist/chunk-n94729d9.js +3 -0
- package/dist/chunk-nchp0pqa.js +3 -0
- package/dist/chunk-nn9tpxx3.js +3 -0
- package/dist/chunk-p2qz2nk2.js +3 -0
- package/dist/chunk-p7w9ydhe.js +9 -0
- package/dist/chunk-pga5m4wm.js +3 -0
- package/dist/chunk-psrgw9f8.js +19 -0
- package/dist/chunk-py7pj8aj.js +5 -0
- package/dist/chunk-pzedkn7z.js +4 -0
- package/dist/chunk-q0hn0ymb.js +6 -0
- package/dist/chunk-qnf4byak.js +3 -0
- package/dist/chunk-r4s18nn5.js +3 -0
- package/dist/chunk-r4zkf9ag.js +3 -0
- package/dist/chunk-rdzfdjkb.js +7 -0
- package/dist/chunk-rmdwvzgn.js +3 -0
- package/dist/chunk-s0mvstt0.js +3 -0
- package/dist/chunk-s6c98nad.js +29 -0
- package/dist/chunk-sjneg7p7.js +34 -0
- package/dist/chunk-sq34kkhy.js +3 -0
- package/dist/chunk-srg5qhch.js +22 -0
- package/dist/chunk-strqhcqs.js +3 -0
- package/dist/chunk-t1jtn2r0.js +10 -0
- package/dist/chunk-ttc5pr8y.js +37 -0
- package/dist/chunk-v44crx69.js +62 -0
- package/dist/chunk-v6fwy63g.js +3 -0
- package/dist/chunk-vae5wxar.js +3 -0
- package/dist/chunk-vtskg4r2.js +4 -0
- package/dist/chunk-w9av39jy.js +3 -0
- package/dist/chunk-wnk9yjw2.js +3 -0
- package/dist/chunk-wrnz0e76.js +4 -0
- package/dist/chunk-wzcwctba.js +9 -0
- package/dist/chunk-xb92nrsm.js +3 -0
- package/dist/chunk-xr1h3tv2.js +8 -0
- package/dist/chunk-xsf941gw.js +3 -0
- package/dist/chunk-z4mvkazp.js +21 -0
- package/dist/chunk-zq93f8ca.js +5 -0
- package/dist/src/augmentation-graph.d.ts +11 -0
- package/dist/src/augmentation-graph.js +2 -0
- package/dist/src/binding-patterns.d.ts +18 -0
- package/dist/src/binding-patterns.js +2 -0
- package/dist/src/branded-types.d.ts +159 -0
- package/dist/src/branded-types.js +2 -0
- package/dist/src/bundle-linker.d.ts +38 -0
- package/dist/src/bundle-linker.js +2 -0
- package/dist/src/bundler.d.ts +55 -0
- package/dist/src/bundler.js +2 -0
- package/dist/src/cache.d.ts +53 -0
- package/dist/src/cache.js +2 -0
- package/dist/src/call-signatures.d.ts +1 -0
- package/dist/src/call-signatures.js +2 -0
- package/dist/src/checker.d.ts +107 -0
- package/dist/src/circular.d.ts +82 -0
- package/dist/src/circular.js +2 -0
- package/dist/src/compat.d.ts +114 -0
- package/dist/src/compat.js +2 -0
- package/dist/src/computed-keys.d.ts +12 -0
- package/dist/src/computed-keys.js +2 -0
- package/dist/src/concurrency.d.ts +4 -0
- package/dist/src/concurrency.js +2 -0
- package/dist/src/config.d.ts +35 -0
- package/dist/src/config.js +2 -0
- package/dist/src/dangling-refs.d.ts +11 -0
- package/dist/src/dangling-refs.js +2 -0
- package/dist/src/declaration-project.d.ts +33 -0
- package/dist/src/declaration-project.js +2 -0
- package/dist/src/declaration-publication.d.ts +15 -0
- package/dist/src/declaration-publication.js +2 -0
- package/dist/src/declaration-references.d.ts +19 -0
- package/dist/src/declaration-references.js +2 -0
- package/dist/src/diff.d.ts +82 -0
- package/dist/src/diff.js +2 -0
- package/dist/src/docs.d.ts +97 -0
- package/dist/src/docs.js +2 -0
- package/dist/src/enum-declarations.d.ts +6 -0
- package/dist/src/enum-declarations.js +2 -0
- package/dist/src/errors.d.ts +113 -0
- package/dist/src/errors.js +2 -0
- package/dist/src/extractor/directives.d.ts +5 -0
- package/dist/src/extractor/directives.js +2 -0
- package/dist/src/extractor/extract.d.ts +10 -0
- package/dist/src/extractor/extract.js +2 -0
- package/dist/src/extractor/hash.d.ts +1 -0
- package/dist/src/extractor/hash.js +2 -0
- package/dist/src/extractor/scanner.d.ts +32 -0
- package/dist/src/extractor/scanner.js +2 -0
- package/dist/src/extractor.d.ts +5 -0
- package/dist/src/extractor.js +2 -0
- package/dist/src/formats.d.ts +50 -0
- package/dist/src/formats.js +2 -0
- package/dist/src/formatter.d.ts +61 -0
- package/dist/src/formatter.js +2 -0
- package/dist/src/function-properties.d.ts +3 -0
- package/dist/src/function-properties.js +2 -0
- package/dist/src/generator.d.ts +18 -0
- package/dist/src/generator.js +2 -0
- package/dist/src/global-types.d.ts +17 -0
- package/dist/src/global-types.js +2 -0
- package/dist/src/import-sorter.d.ts +99 -0
- package/dist/src/import-sorter.js +2 -0
- package/dist/src/incremental.d.ts +103 -0
- package/dist/src/incremental.js +2 -0
- package/dist/src/index.d.ts +62 -0
- package/dist/src/index.js +2 -0
- package/dist/src/inferred-imports.d.ts +4 -0
- package/dist/src/inferred-imports.js +2 -0
- package/dist/src/json-config.d.ts +2 -0
- package/dist/src/json-config.js +2 -0
- package/dist/src/lexical.d.ts +6 -0
- package/dist/src/lexical.js +2 -0
- package/dist/src/logger.d.ts +57 -0
- package/dist/src/logger.js +2 -0
- package/dist/src/lsp.d.ts +333 -0
- package/dist/src/lsp.js +2 -0
- package/dist/src/memory.d.ts +127 -0
- package/dist/src/memory.js +2 -0
- package/dist/src/merger.d.ts +38 -0
- package/dist/src/merger.js +2 -0
- package/dist/src/module-graph.d.ts +70 -0
- package/dist/src/module-graph.js +2 -0
- package/dist/src/module-references.d.ts +30 -0
- package/dist/src/module-references.js +2 -0
- package/dist/src/native-checker.d.ts +55 -0
- package/dist/src/native-checker.js +2 -0
- package/dist/src/native-engine.d.ts +16 -0
- package/dist/src/native-engine.js +2 -0
- package/dist/src/native-extractor.d.ts +9 -0
- package/dist/src/native-extractor.js +2 -0
- package/dist/src/native-generation.d.ts +20 -0
- package/dist/src/native-generation.js +2 -0
- package/dist/src/native-project.d.ts +35 -0
- package/dist/src/native-project.js +2 -0
- package/dist/src/optimizer.d.ts +56 -0
- package/dist/src/optimizer.js +2 -0
- package/dist/src/output-normalizer.d.ts +123 -0
- package/dist/src/output-normalizer.js +2 -0
- package/dist/src/parallel-processor.d.ts +63 -0
- package/dist/src/parallel-processor.js +2 -0
- package/dist/src/parameters.d.ts +5 -0
- package/dist/src/parameters.js +2 -0
- package/dist/src/parser.d.ts +68 -0
- package/dist/src/parser.js +2 -0
- package/dist/src/plugins/bun.d.ts +58 -0
- package/dist/src/plugins/bun.js +2 -0
- package/dist/src/plugins/esbuild.d.ts +63 -0
- package/dist/src/plugins/esbuild.js +2 -0
- package/dist/src/plugins/index.d.ts +16 -0
- package/dist/src/plugins/index.js +2 -0
- package/dist/src/plugins/tsdown.d.ts +30 -0
- package/dist/src/plugins/tsdown.js +2 -0
- package/dist/src/plugins/tsup.d.ts +53 -0
- package/dist/src/plugins/tsup.js +2 -0
- package/dist/src/plugins/vite.d.ts +49 -0
- package/dist/src/plugins/vite.js +2 -0
- package/dist/src/plugins/webpack.d.ts +69 -0
- package/dist/src/plugins/webpack.js +2 -0
- package/dist/src/plugins.d.ts +88 -0
- package/dist/src/plugins.js +2 -0
- package/dist/src/process-source.d.ts +28 -0
- package/dist/src/process-source.js +2 -0
- package/dist/src/processor/cache.d.ts +18 -0
- package/dist/src/processor/cache.js +2 -0
- package/dist/src/processor/comments.d.ts +9 -0
- package/dist/src/processor/comments.js +2 -0
- package/dist/src/processor/declarations.d.ts +37 -0
- package/dist/src/processor/declarations.js +2 -0
- package/dist/src/processor/import-usage.d.ts +6 -0
- package/dist/src/processor/import-usage.js +2 -0
- package/dist/src/processor/imports.d.ts +68 -0
- package/dist/src/processor/imports.js +2 -0
- package/dist/src/processor/index.d.ts +33 -0
- package/dist/src/processor/index.js +2 -0
- package/dist/src/processor/type-inference.d.ts +116 -0
- package/dist/src/processor/type-inference.js +2 -0
- package/dist/src/processor.d.ts +5 -0
- package/dist/src/processor.js +2 -0
- package/dist/src/profiling.d.ts +114 -0
- package/dist/src/profiling.js +2 -0
- package/dist/src/return-type-scope.d.ts +3 -0
- package/dist/src/return-type-scope.js +2 -0
- package/dist/src/security.d.ts +100 -0
- package/dist/src/security.js +2 -0
- package/dist/src/source-cache.d.ts +16 -0
- package/dist/src/source-cache.js +2 -0
- package/dist/src/sourcemap.d.ts +137 -0
- package/dist/src/sourcemap.js +2 -0
- package/dist/src/stx.d.ts +20 -0
- package/dist/src/stx.js +2 -0
- package/dist/src/syntax-validator.d.ts +7 -0
- package/dist/src/syntax-validator.js +2 -0
- package/dist/src/tracking.d.ts +95 -0
- package/dist/src/tracking.js +2 -0
- package/dist/src/transformers.d.ts +188 -0
- package/dist/src/transformers.js +2 -0
- package/dist/src/tree-shaker.d.ts +69 -0
- package/dist/src/tree-shaker.js +2 -0
- package/dist/src/tsconfig.d.ts +8 -0
- package/dist/src/tsconfig.js +2 -0
- package/dist/src/type-mappings.d.ts +145 -0
- package/dist/src/type-mappings.js +2 -0
- package/dist/src/types.d.ts +230 -0
- package/dist/src/types.js +1 -0
- package/dist/src/utils.d.ts +63 -0
- package/dist/src/utils.js +2 -0
- package/dist/src/value-inference.d.ts +6 -0
- package/dist/src/value-inference.js +2 -0
- package/dist/src/vue.d.ts +108 -0
- package/dist/src/vue.js +2 -0
- package/dist/src/watcher.d.ts +64 -0
- package/dist/src/watcher.js +2 -0
- package/dist/src/worker-thread.d.ts +1 -0
- package/dist/src/worker-thread.js +2 -0
- package/dist/src/worker.d.ts +98 -0
- package/dist/src/worker.js +2 -0
- package/dist/src/workspace.d.ts +62 -0
- package/dist/src/workspace.js +2 -0
- package/native/README.md +6 -0
- package/native/darwin-arm64/libzig-dtsx.dylib +0 -0
- package/native/darwin-x64/libzig-dtsx.dylib +0 -0
- package/native/freebsd-x64/libzig-dtsx.so +0 -0
- package/native/linux-arm64/libzig-dtsx.so +0 -0
- package/native/linux-x64/libzig-dtsx.so +0 -0
- package/native/windows-x64/zig-dtsx.dll +0 -0
- package/package.json +120 -4
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{t,F}from"./chunk-1j6092xz.js";import{Hn}from"./chunk-2kwjbk55.js";function et(o){let f=t(o);if(f.length!==1||f[0].kind!=="word")return;let l=o.slice(f[0].start,f[0].end);return["true","false","null","undefined","this","super"].includes(l)?void 0:l}function Mt(o){let f=t(o);if(f.length===0)return!0;let l=f[f.length-1],s=o.slice(l.start,l.end);if(l.kind==="word"&&(s==="is"||s==="extends"))return!0;if(s==="|"||s==="&")return!0;let n=f[f.length-2];return s===">"&&n!==void 0&&o.slice(n.start,n.end)==="="}function j(o){return w(o,F(o))}function Vn(o){for(let f=1024;f<o.length;f*=8){let l=o.slice(0,f),s=v(l,t(l),f);if(s!==void 0)return s}return w(o,t(o))}function w(o,f){return v(o,f,1/0)??!1}function v(o,f,l){let s=0;for(let n=0;n<f.length;n++){let a=f[n];if(a.end>=l)return;if(a.kind==="punctuation"){let d=o.charCodeAt(a.start);if(d===123||d===40||d===91)s++;else if(d===125||d===41||d===93)s--;continue}if(s!==0||a.kind!=="word"||a.end-a.start!==6)continue;let c=o.slice(a.start,a.end);if(c==="export")return!0;if(c==="import"){let d=f[n+1];if(d===void 0?l!==1/0:d.end>=l)return;let x=d?o.slice(d.start,d.end):"";if(x!=="("&&x!==".")return!0}}return l===1/0?!1:void 0}function Un(o){if(o.isExported)return!1;if(["function","variable","interface","type","class","enum","namespace"].includes(o.kind))return!0;return o.kind==="module"&&(o.moduleForm==="namespace"||o.moduleForm==="identifier")}function zn(o,f){let l=o.text,s=t(l),n=(i)=>s[i]?l.slice(s[i].start,s[i].end):"",a=(i)=>s[i]?.kind==="word",c=new Map,d=[];for(let i=0;i<s.length;i++){let e=n(i);if(e==="("||e==="["||e==="{"||e==="<")d.push(i);else if(e===")"||e==="]"||e==="}"||e===">"&&n(i-1)!=="="){let r=d.at(-1);if(r!==void 0&&(n(r)==="("&&e===")"||n(r)==="["&&e==="]"||n(r)==="{"&&e==="}"||n(r)==="<"&&e===">"))d.pop(),c.set(r,i)}}let x=[];for(let i=0;i<s.length;i++){if(n(i)!=="(")continue;let e=c.get(i);if(e===void 0||!(n(e+1)===":"||n(e+1)==="="&&n(e+2)===">"))continue;let r=new Set,u=i+1;while(u<e){let m=u;while(m<e&&n(m)!==","){let b=c.get(m);if(b!==void 0)m=b+1;else m++}let g=u;while(g<m&&n(g)!==":"&&n(g)!=="="){let b=c.get(g);if(b!==void 0)g=b+1;else g++}let h=u;while([".","public","private","protected","readonly","override"].includes(n(h)))h++;if(n(h)==="{"||n(h)==="[")for(let b of Hn(l.slice(s[h].start,s[g-1].end)))r.add(b);else if(a(h))r.add(n(h));u=m+1}let p=e+(n(e+1)===":"?2:3);while(p<s.length){if([";",",",")","]","}"].includes(n(p))||n(p)===">"&&n(p-1)!=="=")break;let m=c.get(p);if(m!==void 0)p=m+1;else p++}x.push({start:i,end:p,names:r})}let y=(i)=>{if(!a(i))return;let e=n(i);if(!x.some((r)=>i>=r.start&&i<r.end&&r.names.has(e)))f.add(e)},k=(i,e)=>{for(let r=i;r<e;r++){if(n(r)==="<"&&c.has(r)){r=c.get(r);continue}if(!a(r)||n(r-1)==="."||n(r+1)===":")continue;if(["true","false","null","undefined","new","this","super","as","satisfies","typeof","void","keyof"].includes(n(r)))continue;y(r)}};for(let i=0;i<s.length;i++){if(n(i)==="typeof")y(i+1);if(n(i)==="export"){let e=i+1;if(n(e)==="default"){if(!["function","class","abstract"].includes(n(e+1)))k(e+1,s.length);continue}if(n(e)==="type")e++;if(n(e)==="{"){let r=c.get(e);if(r===void 0||n(r+1)==="from")continue;for(let u=e+1;u<r;){if(n(u)==="type"&&a(u+1)&&n(u+1)!=="as")u++;y(u);while(u<r&&n(u)!==",")u++;u++}}}if(n(i)==="["){let e=c.get(i);if(e!==void 0&&[":","?","("].includes(n(e+1))&&n(i+2)!==":"&&n(i+2)!=="in")k(i+1,e)}}if(o.kind==="class"){let i=-1;for(let e=0;e<s.length&&n(e)!=="{";e++)if(n(e)==="<"&&c.has(e))e=c.get(e);else if(n(e)==="extends"){i=e;break}if(i!==-1){let e=i+1;while(e<s.length&&n(e)!=="{"&&n(e)!=="implements"){let r=c.get(e);if(r!==void 0)e=r+1;else e++}k(i+1,e)}}}
|
|
3
|
+
export{et,Mt,j,Vn,Un,zn};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var a={debug:0,info:1,warn:2,error:3,silent:4},i="info",u="[dtsx]",L=!1,l=null;function t(o){return a[o]>=a[i]}function d(){if(!L)return"";return`[${new Date().toISOString().slice(11,23)}] `}function v(o,s){let n=d();if(o||n)return[`${n}${o}`,...s];return s}function g(o,s,n){let r=v(s,n);if(l){l(o,...r);return}switch(o){case"debug":console.debug(...r);break;case"info":console.log(...r);break;case"warn":console.warn(...r);break;case"error":console.error(...r);break}}function c(o){return{debug:(...n)=>{if(t("debug"))g("debug",o,n)},info:(...n)=>{if(t("info"))g("info",o,n)},warn:(...n)=>{if(t("warn"))g("warn",o,n)},error:(...n)=>{if(t("error"))g("error",o,n)},setLevel:(n)=>{i=n},getLevel:()=>i,child:(n)=>{let r=o?`${o}:${n}`:`[${n}]`;return c(r)},time:(n)=>{let r=performance.now();return()=>{let f=performance.now()-r;if(t("debug"))g("debug",o,[`${n}: ${f.toFixed(2)}ms`])}},progress:(n)=>{if(t("info"))if(typeof process<"u"&&process.stdout?.isTTY)process.stdout.write(`\r${o} ${n}`);else g("info",o,[n])}}}function ta(o={}){if(o.level)i=o.level;if(o.prefix!==void 0)u=o.prefix;if(o.timestamps!==void 0)L=o.timestamps;if(o.output)l=o.output;return c(u)}var e=c(u);function na(o){return e.child(o)}function I(o){i=o}function ra(){return i}function ia(o){u=o}function sa(o){L=o}var Ci={debug:()=>{},info:()=>{},warn:()=>{},error:()=>{},setLevel:()=>{},getLevel:()=>"silent",child:()=>Ci,time:()=>()=>{},progress:()=>{}};
|
|
3
|
+
export{ta,e,na,I,ra,ia,sa,Ci};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{r}from"./chunk-qnf4byak.js";import{e}from"./chunk-km8t8gqg.js";import{existsSync as j,mkdirSync as S,readFileSync as E,writeFileSync as f}from"fs";import{basename as h,join as g}from"path";function Wt(t){let n={description:"",params:[],examples:[],tags:{},see:[],throws:[]};if(!t||t.length===0)return n;for(let s of t){let o=s.replace(/^\/\*\*/,"").replace(/\*\/$/,"").split(`
|
|
3
|
+
`).map((p)=>p.replace(/^\s*\*\s?/,"")).join(`
|
|
4
|
+
`).trim(),i=o.search(/@\w+/);if(i===-1){n.description=o;continue}else if(i>0)n.description=o.slice(0,i).trim(),o=o.slice(i);let a=/@(\w+)(?:\s+\{([^}]+)\})?\s*([^\n@]*(?:\n(?!@)[^\n@]*)*)/g,c;while((c=a.exec(o))!==null){let[,p,u,d]=c,m=d.trim();switch(p){case"param":{let l=m.match(/^(\[)?(\w+)\]?\s*(?:-\s*)?(.*)/);if(l)n.params.push({name:l[2],type:u,description:l[3].trim(),optional:!!l[1]});break}case"returns":case"return":n.returns={type:u,description:m};break;case"example":n.examples.push(m);break;case"deprecated":n.deprecated=m||"Deprecated";break;case"since":n.since=m;break;case"see":n.see.push(m);break;case"throws":case"throw":n.throws.push({type:u,description:m});break;case"category":n.category=m;break;default:if(!n.tags[p])n.tags[p]=[];n.tags[p].push(m)}}}return n}function w(t,n){let s=Wt(t.leadingComments),o="";switch(t.kind){case"function":o=M(t);break;case"variable":o=C(t);break;case"interface":o=P(t);break;case"type":o=v(t);break;case"class":o=T(t);break;case"enum":o=F(t);break;default:o=t.text||t.name}let i={name:t.name,kind:t.kind,signature:o,jsdoc:s,isExported:t.isExported,isDefault:t.isDefault,sourceFile:n};if(t.members&&t.members.length>0)i.members=t.members.map((a)=>w(a,n));return i}function M(t){let n=[];if(t.isExported)n.push("export");if(t.isDefault)n.push("default");if(n.push("function"),n.push(t.name),t.generics)n.push(t.generics);if(t.parameters){let s=t.parameters.map((o)=>{let i="";if(o.rest)i+="...";if(i+=o.name,o.optional)i+="?";if(o.type)i+=`: ${o.type}`;return i}).join(", ");n.push(`(${s})`)}else n.push("()");if(t.returnType)n.push(`: ${t.returnType}`);return n.join(" ").replace(/\s+/g," ")}function C(t){let n=[];if(t.isExported)n.push("export");if(n.push("const"),n.push(t.name),t.typeAnnotation)n.push(`: ${t.typeAnnotation}`);return n.join(" ")}function P(t){let n=[];if(t.isExported)n.push("export");if(n.push("interface"),n.push(t.name),t.generics)n.push(t.generics);if(t.extends)n.push(`extends ${t.extends}`);return n.join(" ")}function v(t){let n=[];if(t.isExported)n.push("export");if(n.push("type"),n.push(t.name),t.generics)n.push(t.generics);if(n.push("="),t.typeAnnotation)n.push(t.typeAnnotation);return n.join(" ")}function T(t){let n=[];if(t.isExported)n.push("export");if(t.isDefault)n.push("default");if(n.push("class"),n.push(t.name),t.generics)n.push(t.generics);if(t.extends)n.push(`extends ${t.extends}`);if(t.implements&&t.implements.length>0)n.push(`implements ${t.implements.join(", ")}`);return n.join(" ")}function F(t){let n=[];if(t.isExported)n.push("export");return n.push("enum"),n.push(t.name),n.join(" ")}async function jt(t,n={}){let s=[],o=new Map;for(let i of t){if(!j(i)){e.warn(`File not found: ${i}`);continue}let a=E(i,"utf-8"),c=r(a,i,!0);for(let p of c){if(p.kind==="import")continue;if(!n.includePrivate&&p.name.startsWith("_"))continue;if(!n.includeInternal&&p.leadingComments?.some((d)=>d.includes("@internal")))continue;let u=w(p,i);if(s.push(u),n.groupByCategory&&u.jsdoc.category){let d=u.jsdoc.category;if(!o.has(d))o.set(d,[]);o.get(d).push(u)}}}return{title:n.title||"API Documentation",description:n.description,entries:s,categories:o,generatedAt:new Date}}function Be(t,n={}){let s=[];if(s.push(`# ${t.title}`),s.push(""),t.description)s.push(t.description),s.push("");if(s.push(`> Generated on ${t.generatedAt.toISOString()}`),s.push(""),s.push("## Table of Contents"),s.push(""),n.groupByCategory&&t.categories.size>0)for(let o of t.categories.keys())s.push(`- [${o}](#${D(o)})`);else{let o=x(t.entries);for(let[i,a]of o)if(a.length>0)s.push(`- [${b(i)}](#${D(b(i))})`)}if(s.push(""),n.groupByCategory&&t.categories.size>0)for(let[o,i]of t.categories){s.push(`## ${o}`),s.push("");for(let a of i)s.push(...k(a,n))}else{let o=x(t.entries);for(let[i,a]of o)if(a.length>0){s.push(`## ${b(i)}`),s.push("");for(let c of a)s.push(...k(c,n))}}return s.join(`
|
|
5
|
+
`)}function k(t,n){let s=[];if(s.push(`### ${t.name}`),s.push(""),t.jsdoc.deprecated)s.push(`> **Deprecated:** ${t.jsdoc.deprecated}`),s.push("");if(s.push("```typescript"),s.push(t.signature),s.push("```"),s.push(""),t.jsdoc.description)s.push(t.jsdoc.description),s.push("");if(t.jsdoc.params.length>0){s.push("**Parameters:**"),s.push(""),s.push("| Name | Type | Description |"),s.push("|------|------|-------------|");for(let o of t.jsdoc.params){let i=o.optional?" (optional)":"",a=o.type||"any";s.push(`| \`${o.name}\`${i} | \`${a}\` | ${o.description} |`)}s.push("")}if(t.jsdoc.returns){s.push("**Returns:**"),s.push("");let o=t.jsdoc.returns.type?`\`${t.jsdoc.returns.type}\``:"";s.push(`${o} ${t.jsdoc.returns.description}`),s.push("")}if(t.jsdoc.throws.length>0){s.push("**Throws:**"),s.push("");for(let o of t.jsdoc.throws){let i=o.type?`\`${o.type}\``:"";s.push(`- ${i} ${o.description}`)}s.push("")}if(t.jsdoc.examples.length>0){s.push("**Examples:**"),s.push("");for(let o of t.jsdoc.examples)s.push("```typescript"),s.push(o),s.push("```"),s.push("")}if(t.jsdoc.see.length>0){s.push("**See also:**"),s.push("");for(let o of t.jsdoc.see)s.push(`- ${o}`);s.push("")}if(t.jsdoc.since)s.push(`*Since: ${t.jsdoc.since}*`),s.push("");if(n.includeSourceLinks&&t.sourceFile){let o=t.sourceFile;if(n.sourceBaseUrl)s.push(`[Source](${n.sourceBaseUrl}/${o})`);else s.push(`*Source: ${o}*`);s.push("")}if(t.members&&t.members.length>0){s.push("**Members:**"),s.push("");for(let o of t.members)if(s.push(`#### ${o.name}`),s.push(""),s.push("```typescript"),s.push(o.signature),s.push("```"),s.push(""),o.jsdoc.description)s.push(o.jsdoc.description),s.push("")}return s.push("---"),s.push(""),s}function _t(t,n={}){let s=Be(t,n);return`<!DOCTYPE html>
|
|
6
|
+
<html lang="en">
|
|
7
|
+
<head>
|
|
8
|
+
<meta charset="UTF-8">
|
|
9
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
10
|
+
<title>${A(t.title)}</title>
|
|
11
|
+
<style>
|
|
12
|
+
:root {
|
|
13
|
+
--bg: #ffffff;
|
|
14
|
+
--text: #1a1a1a;
|
|
15
|
+
--code-bg: #f4f4f4;
|
|
16
|
+
--border: #e0e0e0;
|
|
17
|
+
--link: #0066cc;
|
|
18
|
+
}
|
|
19
|
+
@media (prefers-color-scheme: dark) {
|
|
20
|
+
:root {
|
|
21
|
+
--bg: #1a1a1a;
|
|
22
|
+
--text: #e0e0e0;
|
|
23
|
+
--code-bg: #2d2d2d;
|
|
24
|
+
--border: #404040;
|
|
25
|
+
--link: #66b3ff;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
body {
|
|
29
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
30
|
+
line-height: 1.6;
|
|
31
|
+
max-width: 900px;
|
|
32
|
+
margin: 0 auto;
|
|
33
|
+
padding: 2rem;
|
|
34
|
+
background: var(--bg);
|
|
35
|
+
color: var(--text);
|
|
36
|
+
}
|
|
37
|
+
h1, h2, h3, h4 { margin-top: 2rem; }
|
|
38
|
+
code {
|
|
39
|
+
background: var(--code-bg);
|
|
40
|
+
padding: 0.2em 0.4em;
|
|
41
|
+
border-radius: 3px;
|
|
42
|
+
font-family: 'Monaco', 'Menlo', monospace;
|
|
43
|
+
font-size: 0.9em;
|
|
44
|
+
}
|
|
45
|
+
pre {
|
|
46
|
+
background: var(--code-bg);
|
|
47
|
+
padding: 1rem;
|
|
48
|
+
border-radius: 6px;
|
|
49
|
+
overflow-x: auto;
|
|
50
|
+
}
|
|
51
|
+
pre code {
|
|
52
|
+
padding: 0;
|
|
53
|
+
background: none;
|
|
54
|
+
}
|
|
55
|
+
table {
|
|
56
|
+
border-collapse: collapse;
|
|
57
|
+
width: 100%;
|
|
58
|
+
margin: 1rem 0;
|
|
59
|
+
}
|
|
60
|
+
th, td {
|
|
61
|
+
border: 1px solid var(--border);
|
|
62
|
+
padding: 0.5rem;
|
|
63
|
+
text-align: left;
|
|
64
|
+
}
|
|
65
|
+
th { background: var(--code-bg); }
|
|
66
|
+
a { color: var(--link); }
|
|
67
|
+
blockquote {
|
|
68
|
+
border-left: 4px solid var(--border);
|
|
69
|
+
margin: 1rem 0;
|
|
70
|
+
padding-left: 1rem;
|
|
71
|
+
color: #666;
|
|
72
|
+
}
|
|
73
|
+
hr {
|
|
74
|
+
border: none;
|
|
75
|
+
border-top: 1px solid var(--border);
|
|
76
|
+
margin: 2rem 0;
|
|
77
|
+
}
|
|
78
|
+
.deprecated {
|
|
79
|
+
background: #fff3cd;
|
|
80
|
+
border-left: 4px solid #ffc107;
|
|
81
|
+
padding: 0.5rem 1rem;
|
|
82
|
+
margin: 1rem 0;
|
|
83
|
+
}
|
|
84
|
+
@media (prefers-color-scheme: dark) {
|
|
85
|
+
.deprecated {
|
|
86
|
+
background: #3d3000;
|
|
87
|
+
border-left-color: #ffc107;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
</style>
|
|
91
|
+
</head>
|
|
92
|
+
<body>
|
|
93
|
+
<article id="content"></article>
|
|
94
|
+
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
|
95
|
+
<script>
|
|
96
|
+
const markdown = ${JSON.stringify(s)};
|
|
97
|
+
document.getElementById('content').innerHTML = marked.parse(markdown);
|
|
98
|
+
</script>
|
|
99
|
+
</body>
|
|
100
|
+
</html>`}function Gt(t,n={}){let s={title:t.title,description:t.description,generatedAt:t.generatedAt.toISOString(),version:"1.0.0",entries:t.entries.map((o)=>({name:o.name,kind:o.kind,signature:o.signature,description:o.jsdoc.description,isExported:o.isExported,isDefault:o.isDefault,deprecated:o.jsdoc.deprecated,since:o.jsdoc.since,category:o.jsdoc.category,params:o.jsdoc.params,returns:o.jsdoc.returns,examples:o.jsdoc.examples,throws:o.jsdoc.throws,see:o.jsdoc.see,tags:o.jsdoc.tags,sourceFile:o.sourceFile,sourceLine:o.sourceLine,members:o.members?.map((i)=>({name:i.name,kind:i.kind,signature:i.signature,description:i.jsdoc.description,deprecated:i.jsdoc.deprecated,params:i.jsdoc.params,returns:i.jsdoc.returns}))})),categories:n.groupByCategory?Object.fromEntries(Array.from(t.categories.entries()).map(([o,i])=>[o,i.map((a)=>a.name)])):void 0};return JSON.stringify(s,null,2)}function gr(t){let n={id:0,name:t.title,kind:1,kindString:"Project",flags:{},children:t.entries.map((s,o)=>({id:o+1,name:s.name,kind:y(s.kind),kindString:s.kind,flags:{isExported:s.isExported,isDefault:s.isDefault},comment:s.jsdoc.description?{summary:[{kind:"text",text:s.jsdoc.description}],blockTags:s.jsdoc.deprecated?[{tag:"@deprecated",content:[{kind:"text",text:s.jsdoc.deprecated}]}]:void 0}:void 0,sources:s.sourceFile?[{fileName:s.sourceFile,line:s.sourceLine||1,character:0}]:void 0,signatures:s.kind==="function"?[{id:o+1000,name:s.name,kind:4096,kindString:"Call signature",parameters:s.jsdoc.params.map((i,a)=>({id:o+2000+a,name:i.name,kind:32768,kindString:"Parameter",flags:{isOptional:i.optional},type:i.type?{type:"intrinsic",name:i.type}:void 0,comment:i.description?{summary:[{kind:"text",text:i.description}]}:void 0})),type:s.jsdoc.returns?.type?{type:"intrinsic",name:s.jsdoc.returns.type}:void 0}]:void 0,children:s.members?.map((i,a)=>({id:o+3000+a,name:i.name,kind:y(i.kind),kindString:i.kind,comment:i.jsdoc.description?{summary:[{kind:"text",text:i.jsdoc.description}]}:void 0}))}))};return JSON.stringify(n,null,2)}async function Yi(t,n){e.info("Extracting documentation...");let s=await jt(t,n);if(e.info(`Found ${s.entries.length} documented entries`),!j(n.outdir))S(n.outdir,{recursive:!0});if(n.format==="markdown")if(n.splitByModule){let o=I(s.entries);for(let[a,c]of o){let p={title:h(a,".ts"),description:`Documentation for ${a}`,entries:c,categories:new Map,generatedAt:s.generatedAt},u=Be(p,n),d=g(n.outdir,`${h(a,".ts")}.md`);f(d,u),e.info(`Generated: ${d}`)}let i=[`# ${s.title}`,"",s.description||"","","## Modules",""];for(let[a]of o){let c=h(a,".ts");i.push(`- [${c}](./${c}.md)`)}f(g(n.outdir,"README.md"),i.join(`
|
|
101
|
+
`)),e.info(`Generated: ${g(n.outdir,"README.md")}`)}else{let o=Be(s,n),i=g(n.outdir,"API.md");f(i,o),e.info(`Generated: ${i}`)}else if(n.format==="json"){let o=Gt(s,n),i=g(n.outdir,"api.json");f(i,o),e.info(`Generated: ${i}`);let a=gr(s),c=g(n.outdir,"typedoc.json");f(c,a),e.info(`Generated: ${c}`)}else{let o=_t(s,n),i=g(n.outdir,"index.html");f(i,o),e.info(`Generated: ${i}`)}}function D(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function b(t){return{function:"Functions",variable:"Variables",interface:"Interfaces",type:"Type Aliases",class:"Classes",enum:"Enums",export:"Exports",module:"Modules"}[t]||t}function x(t){let n=new Map,s=["function","class","interface","type","enum","variable"];for(let o of s)n.set(o,[]);for(let o of t){let i=o.kind;if(!n.has(i))n.set(i,[]);n.get(i).push(o)}return n}function A(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function I(t){let n=new Map;for(let s of t){let o=s.sourceFile||"unknown";if(!n.has(o))n.set(o,[]);n.get(o).push(s)}return n}function y(t){return{function:64,variable:32,interface:256,type:4194304,class:128,enum:8,property:1024,method:2048,module:2,namespace:4}[t]||0}function Xi(t={}){return{extract:(n)=>jt(n,t),generateMarkdown:(n)=>Be(n,t),generateHTML:(n)=>_t(n,t),generateJSON:(n)=>Gt(n,t),parseJSDoc:Wt}}
|
|
102
|
+
export{Wt,jt,Be,_t,Gt,gr,Yi,Xi};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{s}from"./chunk-0azm93j9.js";function ue(a={}){let{onStart:d=!1,onEnd:l=!0,onGenerated:u,onError:i,...n}=a,e=async()=>{try{let r=await s(n);u?.(r)}catch(r){let t=r instanceof Error?r:Error(String(r));if(i?.(t),!i)console.error("[dtsx] Generation failed:",t.message)}};return{name:"dtsx",setup(r){let t=r.initialOptions;if(!n.entrypoints&&t.entryPoints)if(Array.isArray(t.entryPoints))n.entrypoints=t.entryPoints;else n.entrypoints=Object.values(t.entryPoints);if(!n.outdir){if(t.outdir)n.outdir=t.outdir;else if(t.outfile){let o=t.outfile.lastIndexOf("/");if(o!==-1)n.outdir=t.outfile.substring(0,o)}}if(d)r.onStart(async()=>{await e()});if(l)r.onEnd(async(o)=>{if(o.errors.length===0)await e()})}}}var wa=ue,Zn=ue,xa=ue;
|
|
3
|
+
export{ue,wa,Zn,xa};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{vt,St,a,ve,Ke,$t,Et,qe,Je,Ye,kt,Xe,Tt,At}from"./chunk-z4mvkazp.js";function A(t){return t.endsWith(".stx")}function h(t){let n=[],s=/<script\b([^>]*)>([\s\S]*?)<\/script\s*>/gi,o;while((o=s.exec(t))!==null){let r=o[1]??"",i=/\blang\s*=\s*["']([^"']+)["']/i.exec(r)?.[1]?.toLowerCase()??(/\b(?:type\s*=\s*["'](?:text\/)?typescript["']|typescript)\b/i.test(r)?"ts":"js"),e=/\bserver\b/i.test(r)?"server":/\bclient\b/i.test(r)?"client":"universal";n.push({content:o[2]??"",kind:"script",attrs:r,context:e,lang:i,start:o.index})}return n}function y(t){let n=[],s=/^[ \t]*@ts[ \t]*(?:\r?\n|$)/gm,o;while((o=s.exec(t))!==null){let r=s.lastIndex,i=/^[ \t]*@endts[ \t]*(?:\r?\n|$)/gm;i.lastIndex=r;let e=i.exec(t),l=e?.index??t.length;if(n.push({content:t.slice(r,l),kind:"ts",attrs:"",context:"universal",lang:"ts",start:o.index}),!e)break;s.lastIndex=i.lastIndex}return n}function Ro(t){return[...h(t),...y(t)].sort((n,s)=>n.start-s.start)}function k(t){if(t.kind==="ts"||t.context!=="universal"||t.lang==="ts")return!0;return/\b(?:defineProps|defineEmits|defineExpose|defineSlots)\b|\bexport\s|\b(?:interface|type)\s+[A-Za-z_$]/.test(t.content)}function _(t){let n=/(?:\$?props)\s+as\s+/g,s;while((s=n.exec(t))!==null){let o=n.lastIndex;while(o<t.length&&/\s/.test(t[o]))o++;if(t[o]==="{"){let e=a(t,o,"{","}");if(e!==-1)return t.slice(o,e+1).trim();continue}let r=/^[A-Za-z_$][\w$]*/.exec(t.slice(o))?.[0];if(!r)continue;let i=o+r.length;while(i<t.length&&/\s/.test(t[i]))i++;if(t[i]==="<"){let e=a(t,i,"<",">");if(e!==-1)i=e+1}return t.slice(o,i).trim()}return null}function w(t){return/\b(?:const|let|var)\s+\$?props\s*:\s*([^=;\n]+)/.exec(t)?.[1]?.trim()??null}function T(t){let n=/^\s*(?:\|\||\?\?)\s*([^;\n]+)/.exec(t)?.[1]?.trim();if(/^['"`]/.test(n??""))return"string";if(/^(?:true|false)\b/.test(n??""))return"boolean";if(/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)\b/.test(n??""))return"number";if(/^\[/.test(n??""))return"unknown[]";if(/^\{/.test(n??""))return"Record<string, unknown>";if(/^\s*(?:===?|!==?)\s*(?:true|false)\b/.test(t))return"boolean";return"unknown"}function E(t,n){if(!t||t==="unknown")return n;if(n==="unknown"||t===n)return t;return[...new Set([...t.split(" | "),...n.split(" | ")])].join(" | ")}function v(t){let n=St(t),s=new Map,o=/\$props(?:\.([A-Za-z_$][\w$]*)|\[\s*(['"])([^'"\n]+)\2\s*\])/g,r;while((r=o.exec(t))!==null){if(n.slice(r.index,r.index+6)!=="$props")continue;let e=r[1]??r[3],l=T(t.slice(o.lastIndex));s.set(e,E(s.get(e),l))}if(s.size===0)return null;return{type:`{ ${[...s].map(([e,l])=>`${/^[A-Za-z_$][\w$]*$/.test(e)?e:JSON.stringify(e)}?: ${l}`).join(", ")} }`}}function C(t){let n=Xe(t,null);if(n)return n;let s=_(t)??w(t);if(!s)return v(t);if(/^[A-Za-z_$][\w$]*$/.test(s)){let o=s.replace(/[$]/g,"\\$&");if(new RegExp(`\\bexport\\s+(?:declare\\s+)?(?:interface|type)\\s+${o}\\b`).test(t))return{type:s}}return Xe(`${t}
|
|
3
|
+
defineProps<${s}>()`,null)}function R(t){return $t(t)}function S(t){let n=St(t).trimStart();if(n==="")return!0;return/^(?:import\b|export\b|declare\b|interface\b|type\b|(?:export\s+)?namespace\b|(?:export\s+)?module\b|(?:abstract\s+)?class\b|const\b|let\b|var\b|(?:async\s+)?function\b)/.test(n)}function B(t){let n=[],s=0,o=0,r=0;while(r<t.length){let e=t[r],l=vt(t,r);if(l>r){r=l;continue}if(e==="{"||e==="["||e==="(")o++;else if(e==="}"||e==="]"||e===")")o=Math.max(0,o-1);if((e===";"||e===`
|
|
4
|
+
`)&&o===0){let c=r+1;if(!S(t.slice(s,c)))n.push([s,c]);s=c}r++}if(s<t.length&&!S(t.slice(s)))n.push([s,t.length]);let i=t;for(let e=n.length-1;e>=0;e--)i=i.slice(0,n[e][0])+i.slice(n[e][1]);return i}function P(t){let s=Ro(t).filter(k).map((f)=>f.content).join(`
|
|
5
|
+
`),o=null,r=Et(s);if(r.passthrough)return s;if(s=r.script,r.options){let f=qe(r.options,"props");if(f)o=Ke(f)}let i=s,e=R(s),l=C(i),c=l?.type??o??"{}",m=Tt(i,null),d=At(i,null),g=ve(i,"defineSlots")?.generic??null,x=l?.inlinedLocal;if(x)e=Ye(e,x.name,x.declText);let p=`DefineComponent<${c}>`,u=[];if(m)u.push(`readonly __stxEmits?: ${m}`);if(g)u.push(`readonly __stxSlots?: ${g}`);if(d)u.push(`readonly __stxExposed?: ${d}`);if(u.length>0)p+=` & { ${u.join(", ")} }`;p=kt(p),e=B(Je(e,p));let b=["import type { DefineComponent } from '@stacksjs/stx'",`type __DtsxStxComponentType = ${p}`,"const __dtsx_component__: __DtsxStxComponentType = null as unknown as __DtsxStxComponentType","export default __dtsx_component__"];if(e.trim()!=="")b.push(e);return b.join(`
|
|
6
|
+
`)}
|
|
7
|
+
export{A,Ro,P};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{t,d,x}from"./chunk-1j6092xz.js";var C={kind:"symbol"},K=/^(?:0[xX][\da-fA-F_]+|0[bB][01_]+|0[oO][0-7_]+|(?:[\d_]+(?:\.[\d_]*)?|\.[\d_]+)(?:[eE][+-]?[\d_]+)?)/,v={"|":1,"^":2,"&":3,"<<":4,">>":4,">>>":4,"+":5,"-":5,"*":6,"/":6,"%":6,"**":7},M=[">>>","<<",">>","**","+","-","*","/","%","|","^","&"];function w(l,c,o=0){if(o>=64)return;let n=l.trim(),r=t(n);if(!r.length)return;if(r[0].start!==0||r[r.length-1].end!==n.length)return w(n.slice(r[0].start,r[r.length-1].end),c,o+1);if(r.length===1&&r[0].kind==="quoted")return d(n);if(r.length===1&&r[0].kind==="word"){let e=c.get(n);return typeof e==="object"?void 0:e}if(K.exec(n)?.[0].length===n.length){let e=Number(n.replaceAll("_",""));return Number.isFinite(e)?e:void 0}let i=0,a;for(let e=0;e<r.length;e++){let s=r[e],u=n.slice(s.start,s.end);if(s.kind!=="punctuation")continue;if(["(","[","{"].includes(u)){i++;continue}if([")","]","}"].includes(u)){i--;continue}let m=K.exec(n.slice(s.start));if(m){while(r[e+1]?.start<s.start+m[0].length)e++;continue}if(i)continue;let f=M.find((S)=>n.startsWith(S,s.start));if(!f)continue;let p=r[e-1],h=p?n.slice(p.start,p.end):"";if(!(!p||p.kind==="punctuation"&&![")","]"].includes(h)&&!/\d/.test(h))&&(!a||v[f]<a.priority||v[f]===a.priority&&f!=="**"))a={start:s.start,operator:f,priority:v[f]};while(r[e+1]?.start<s.start+f.length)e++}if(a){let e=w(n.slice(0,a.start),c,o+1),s=w(n.slice(a.start+a.operator.length),c,o+1);if(e===void 0||s===void 0)return;if(a.operator==="+"&&(typeof e==="string"||typeof s==="string"))return String(e)+String(s);if(typeof e!=="number"||typeof s!=="number")return;let u;switch(a.operator){case"+":u=e+s;break;case"-":u=e-s;break;case"*":u=e*s;break;case"/":u=e/s;break;case"%":u=e%s;break;case"**":u=e**s;break;case"<<":u=e<<s;break;case">>":u=e>>s;break;case">>>":u=e>>>s;break;case"|":u=e|s;break;case"^":u=e^s;break;case"&":u=e&s;break;default:return}return Number.isFinite(u)?u:void 0}if(n.startsWith("(")&&n.endsWith(")")){let e=0;if(r.every((u,m)=>{let f=n.slice(u.start,u.end);if(f==="(")e++;if(f===")")e--;return e!==0||m===r.length-1}))return w(n.slice(1,-1),c,o+1)}if(["+","-","~"].includes(n[0])){let e=w(n.slice(1),c,o+1);if(typeof e!=="number")return;return n[0]==="-"?-e:n[0]==="~"?~e:e}if(!n.startsWith("`")||!n.endsWith("`"))return;let y="",b=1;for(let e=1;e<n.length-1;e++){if(n[e]==="\\"){e++;continue}if(n[e]!=="$"||n[e+1]!=="{")continue;let s=d(`\`${n.slice(b,e)}\``);if(s===void 0)return;y+=s;let u=0,m=r.find((p)=>{if(p.start<e+2||p.kind!=="punctuation")return!1;let h=n.slice(p.start,p.end);if(h==="{")u++;if(h!=="}")return!1;if(u===0)return!0;return u--,!1});if(!m)return;let f=w(n.slice(e+2,m.start),c,o+1);if(f===void 0)return;y+=String(f),e=m.start,b=e+1}let g=d(`\`${n.slice(b,-1)}\``);return g===void 0?void 0:y+g}function Wn(l,c){let o=[...new Set([...l,...c.values()])];if(!o.some((i)=>i.kind==="variable"&&typeof i.value==="string"&&/[\[{]/.test(i.value)))return;o.sort((i,a)=>(i.start??0)-(a.start??0));let n=new Map,r=new Map,k=o.some((i)=>i.name==="Symbol");for(let i of o){if(i.kind!=="variable"||typeof i.value!=="string")continue;if(i.value.includes("{")||i.value.includes("[")){let g=new Map(n);g.mutableBindingTypes=new Map(r),i.computedKeyConstants=g}let a=t(i.value),y=a.length===1&&a[0].kind==="word"?n.get(i.value.slice(a[0].start,a[0].end)):void 0;if(i.typeAnnotation==="unique symbol"||i.typeAnnotation==="symbol"||typeof y==="object"||!k&&a[0]?.kind==="word"&&i.value.slice(a[0].start,a[0].end)==="Symbol"&&["(","."].includes(i.value.slice(a[1]?.start,a[1]?.end))){n.set(i.name,C);continue}if(i.modifiers?.[0]!=="const"||i.typeAnnotation||i.modifiers.includes("const assertion"))continue;let b=w(i.value,n);if(b!==void 0){if(n.set(i.name,b),!(a.length===1&&a[0].kind==="word")||r.has(i.value.trim()))r.set(i.name,typeof b)}else if(i.value.trim()==="true"||i.value.trim()==="false")r.set(i.name,"boolean");else if(a.length===1&&a[0].kind==="word"){let g=r.get(i.value.trim());if(g)r.set(i.name,g)}}}function jn(l,c){if(!l.trimStart().startsWith("[")||!l.includes("`"))return;let o=t(l);if(l[o[0]?.start]!=="["||l[o[1]?.start]!=="`"||l[o.at(-1)?.start??-1]!=="]")return;let n=l.slice(o[0].end,o.at(-1).start).trim(),r=w(n,c??new Map);return typeof r==="string"?{name:x(r,"'")}:{index:!0}}function _n(l,c){if(!c||!l.trimStart().startsWith("["))return!1;let o=t(l);return o.length===3&&l[o[0].start]==="["&&o[1].kind==="word"&&l[o[2].start]==="]"&&typeof c.get(l.slice(o[1].start,o[1].end))==="object"}function Gn(l){if(!l.trimStart().startsWith("[")||!l.includes("`"))return!1;let c=t(l);return l[c[1]?.start]==="`"&&c.some((o)=>o.kind==="punctuation"&&l[o.start]==="{")}
|
|
3
|
+
export{w,Wn,jn,_n,Gn};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{mn}from"./chunk-aw48mk3t.js";var g=new Set(["This","True","False","Null","Undefined","Void","Never","Any","Unknown","Object","Infinity","NaN"]);function f(e,o={strings:!0}){let c="",n=0;while(n<e.length){let t=e.slice(n,n+2);if(t==="//"){let s=e.indexOf(`
|
|
3
|
+
`,n),a=s===-1?e.length:s;c+=" ".repeat(a-n),n=a;continue}if(t==="/*"){let s=e.indexOf("*/",n+2),a=s===-1?e.length:s+2;for(let r=n;r<a;r++)c+=e[r]===`
|
|
4
|
+
`?`
|
|
5
|
+
`:" ";n=a;continue}let i=e[n];if(o.strings&&(i==='"'||i==="'"||i==="`")){let s=i;c+=" ",n++;while(n<e.length){if(e[n]==="\\"){c+=" ",n+=2;continue}if(e[n]===s){c+=" ",n++;break}c+=e[n]===`
|
|
6
|
+
`?`
|
|
7
|
+
`:" ",n++}continue}c+=i,n++}return c}function m(e){let o=new Set,c=[/\b(?:export\s+)?(?:declare\s+)?(?:abstract\s+)?(?:type|interface|class|enum|namespace|module)\s+([A-Za-z_$][\w$]*)/g,/\b(?:export\s+)?(?:declare\s+)?(?:async\s+)?function\s*\*?\s*([A-Za-z_$][\w$]*)/g,/\b(?:export\s+)?declare\s+(?:const|let|var)\s+([A-Za-z_$][\w$]*)/g];for(let n of c)for(let t of e.matchAll(n))o.add(t[1]);return o}function d(e){let o=new Set;for(let c of e.matchAll(/\bimport\s+(?:type\s+)?([\s\S]*?)\s+from\s*['"`]/g)){let n=c[1],t=/\*\s*as\s+([A-Za-z_$][\w$]*)/.exec(n);if(t)o.add(t[1]);let i=n.split("{")[0].replace(/\*\s*as\s+[A-Za-z_$][\w$]*/,"");for(let a of i.split(",")){let r=a.trim();if(/^[A-Za-z_$][\w$]*$/.test(r))o.add(r)}let s=/\{([\s\S]*?)\}/.exec(n);if(s)for(let a of s[1].split(",")){let r=a.trim().replace(/^type\s+/,"");if(!r)continue;let l=/\bas\s+([A-Za-z_$][\w$]*)$/.exec(r);o.add(l?l[1]:r.split(/\s+/)[0])}}for(let c of e.matchAll(/\bimport\s*\(\s*['"`][^'"`]*['"`]\s*\)\s*\.\s*([A-Za-z_$][\w$]*)/g))o.add(c[1]);return o}function p(e){let o=new Set,c=(t)=>{for(let i of t.split(",")){let s=i.trim().split(/\s+|=/)[0]?.trim();if(s&&/^[A-Za-z_$][\w$]*$/.test(s))o.add(s)}},n=/\b(?:type|interface|class|function)\s+[A-Za-z_$][\w$]*\s*<([^<>]*(?:<[^<>]*>[^<>]*)*)>/g;for(let t of e.matchAll(n))c(t[1]);for(let t of e.matchAll(/(?:\b[A-Za-z_$][\w$]*)?\s*<([^<>()]*)>\s*\(/g))c(t[1]);for(let t of e.matchAll(/\binfer\s+([A-Za-z_$][\w$]*)/g))o.add(t[1]);for(let t of e.matchAll(/\[\s*([A-Za-z_$][\w$]*)\s+in\b/g))o.add(t[1]);return o}function h(e){let o=new Map,c=(t)=>{let i=1;for(let s=0;s<t&&s<e.length;s++)if(e.charCodeAt(s)===10)i++;return i},n=(t,i,s)=>{for(let a of t.matchAll(/\b([A-Z][\w$]*)\b/g)){let r=a[1];if(o.has(r))continue;let l=t.slice(a.index+r.length);if(/^\s*\??:/.test(l))continue;o.set(r,{line:c(i),context:s.trim().slice(0,120)})}};for(let t of e.matchAll(/\btype\s+[A-Za-z_$][\w$]*\s*(?:<[^=]*?>)?\s*=([^;]*)/g))n(t[1],t.index+t[0].indexOf("="),t[0]);for(let t of e.matchAll(/\b(?:extends|implements)\s+([^{;]*)/g))n(t[1],t.index,t[0]);for(let t of e.matchAll(/:\s*([^;,){}\n=]+)/g))n(t[1],t.index,t[0]);for(let t of e.matchAll(/<([^<>()]*)>/g))n(t[1],t.index,t[0]);return o}function pn(e){let o=f(e),c=f(e,{strings:!1}),n=new Set([...m(o),...d(c),...p(o),...mn,...g]),t=[];for(let[i,s]of h(o)){if(n.has(i))continue;if(new RegExp(`[\\w$]\\s*\\.\\s*${i}\\b`).test(o))continue;t.push({name:i,line:s.line,context:s.context})}return t.sort((i,s)=>i.line-s.line||i.name.localeCompare(s.name))}
|
|
8
|
+
export{pn};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{lstat as d,realpath as f,stat as T}from"fs/promises";import{isAbsolute as l,normalize as g,relative as p,resolve as u}from"path";var L={rootDir:process.cwd(),maxFileSize:10485760,maxTotalSize:104857600,timeout:30000,followSymlinks:!1,maxFiles:1e4,blockedPatterns:["**/.git/**","**/node_modules/**","**/.env*","**/secrets/**","**/*.key","**/*.pem"]};class C extends Error{code;path;constructor(t,r,e){super(t);this.code=r;this.path=e;this.name="SecurityError"}}function We(t,r={}){let{rootDir:e=process.cwd()}=r,i=g(t),n=l(i)?i:u(e,i),o=u(n),s=p(e,o);if(s.startsWith("..")||l(s))throw new C(`Path traversal detected: "${t}" resolves outside root directory`,"PATH_TRAVERSAL",t);return o}function hr(t,r={}){return t.map((e)=>We(e,r))}function Vt(t,r={}){let e=r.blockedPatterns||L.blockedPatterns;for(let i of e)if(h(t,i))return!0;return!1}var m=new Map;function P(t){let r=m.get(t);if(r)return r;let e=t.replace(/\*\*/g,"<<GLOBSTAR>>").replace(/\*/g,"<<STAR>>").replace(/\?/g,"<<QUESTION>>");e=e.replace(/[.+^${}()|[\]\\]/g,"\\$&"),e=e.replace(/^<<GLOBSTAR>>\//,"(.*\\/)?"),e=e.replace(/\/<<GLOBSTAR>>$/,"(\\/.*)?"),e=e.replace(/\/<<GLOBSTAR>>\//g,"(\\/.*)?\\/"),e=e.replace(/<<GLOBSTAR>>/g,".*"),e=e.replace(/<<STAR>>/g,"[^/]*"),e=e.replace(/<<QUESTION>>/g,"[^/]");let i=new RegExp(`^${e}$`);return m.set(t,i),i}function h(t,r){let e=t.indexOf("\\")===-1?t:t.replace(/\\/g,"/");return P(r).test(e)}async function yr(t,r={}){let e=r.maxFileSize??L.maxFileSize;try{let i=await T(t);if(i.size>e)throw new C(`File too large: "${t}" is ${a(i.size)}, max is ${a(e)}`,"FILE_TOO_LARGE",t);return i.size}catch(i){if(i instanceof C)throw i;throw new C(`Failed to check file size: ${t}`,"INVALID_PATH",t)}}async function br(t){try{return(await d(t)).isSymbolicLink()}catch{return!1}}async function wr(t,r={}){let e=r.followSymlinks??L.followSymlinks;if(await br(t)){if(!e)throw new C(`Symbolic links not allowed: "${t}"`,"SYMLINK_NOT_ALLOWED",t);let i=await f(t);return We(i,r)}return t}async function ot(t,r={}){let e=We(t,r);if(Vt(e,r))throw new C(`Path matches blocked pattern: "${t}"`,"BLOCKED_PATTERN",t);let i=await wr(e,r),n=await yr(i,r);return{path:i,size:n}}async function Ut(t,r={}){let e=r.maxFiles??L.maxFiles,i=r.maxTotalSize??L.maxTotalSize;if(t.length>e)throw new C(`Too many files: ${t.length} exceeds maximum of ${e}`,"MAX_FILES_EXCEEDED");let n=[],o=0;for(let s of t){let c=await ot(s,r);if(n.push(c.path),o+=c.size,o>i)throw new C(`Total size exceeded: ${a(o)} exceeds maximum of ${a(i)}`,"TOTAL_SIZE_EXCEEDED")}return{paths:n,totalSize:o}}function at(t,r,e="Operation"){return new Promise((i,n)=>{let o=setTimeout(()=>{n(new C(`${e} timed out after ${r}ms`,"TIMEOUT"))},r);t.then((s)=>{clearTimeout(o),i(s)}).catch((s)=>{clearTimeout(o),n(s)})})}function xr(t,r={}){let e=r.timeout??L.timeout;return async(i)=>{let{path:n}=await ot(i,r);return at(t(n),e,`Processing ${i}`)}}function Qi(t,r={}){let e=r.timeout??L.timeout;return async(i)=>{let{paths:n}=await Ut(i,r);return at(t(n),e,`Processing ${i.length} files`)}}function es(t){let r=t.replace(/\\/g,"/").replace(/\0/g,"").replace(/^\/+/,"").replace(/^[A-Z]:/i,""),e="";while(e!==r)e=r,r=r.replace(/\.\.\/|\.\.$/g,"").replace(/\/+/g,"/");return r.replace(/^\/+|\/+$/g,"")}function ts(t){if(t.includes("\x00"))return!1;if(g(t).includes(".."))return!1;if(l(t)&&!t.startsWith(process.cwd()))return!1;return!0}function a(t){if(t===0)return"0 B";let r=["B","KB","MB","GB"],e=1024,i=Math.floor(Math.log(t)/Math.log(e));return`${Number.parseFloat((t/e**i).toFixed(2))} ${r[i]}`}function ns(t={}){let r={...L,...t};return{validatePath:(e)=>We(e,r),validatePaths:(e)=>hr(e,r),validateFile:(e)=>ot(e,r),validateBatch:(e)=>Ut(e,r),withTimeout:(e,i)=>at(e,r.timeout,i),secureProcessor:(e)=>xr(e,r),isBlocked:(e)=>Vt(e,r),getConfig:()=>r}}
|
|
3
|
+
export{L,C,We,hr,Vt,yr,br,wr,ot,Ut,at,xr,Qi,es,ts,ns};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{ae}from"./chunk-dfye109x.js";function M(n,t){let e=n.length,i=t.length,o=Array.from({length:e+1},()=>Array(i+1).fill(0));for(let s=1;s<=e;s++)for(let r=1;r<=i;r++)if(n[s-1]===t[r-1])o[s][r]=o[s-1][r-1]+1;else o[s][r]=Math.max(o[s-1][r],o[s][r-1]);return o}function S(n,t,e,i,o){let s=[];while(i>0||o>0)if(i>0&&o>0&&t[i-1]===e[o-1])s.unshift({op:"equal",oldIdx:i-1,newIdx:o-1,line:t[i-1]}),i--,o--;else if(o>0&&(i===0||n[i][o-1]>=n[i-1][o]))s.unshift({op:"add",newIdx:o-1,line:e[o-1]}),o--;else if(i>0)s.unshift({op:"remove",oldIdx:i-1,line:t[i-1]}),i--;return s}function k(n,t){let e=n;if(t.ignoreWhitespace)e=e.replace(/\s+/g," ").trim();return e}function ut(n,t,e,i={}){let{context:o=3,ignoreWhitespace:s=!1,ignoreBlankLines:r=!1}=i,f=n.split(`
|
|
3
|
+
`),p=t.split(`
|
|
4
|
+
`);if(f[f.length-1]==="")f.pop();if(p[p.length-1]==="")p.pop();let d=f.map((l)=>k(l,{ignoreWhitespace:s})),a=p.map((l)=>k(l,{ignoreWhitespace:s})),c=d,g=a,w=f.map((l,x)=>x),m=p.map((l,x)=>x);if(r)c=[],g=[],w=[],m=[],d.forEach((l,x)=>{if(l.trim())c.push(l),w.push(x)}),a.forEach((l,x)=>{if(l.trim())g.push(l),m.push(x)});let F=M(c,g),b=S(F,c,g,c.length,g.length),B=b.every((l)=>l.op==="equal"),D=0,u=0,h=0;for(let l of b)if(l.op==="add")D++;else if(l.op==="remove")u++;else h++;let y=C(b,f,p,w,m,o);return{filePath:e,identical:B,hunks:y,stats:{additions:D,deletions:u,unchanged:h},oldContent:n,newContent:t}}function C(n,t,e,i,o,s){let r=[],f=[];if(n.forEach((a,c)=>{if(a.op!=="equal")f.push(c)}),f.length===0)return r;let p=[],d=[f[0]];for(let a=1;a<f.length;a++)if(f[a]-f[a-1]<=s*2+1)d.push(f[a]);else p.push(d),d=[f[a]];p.push(d);for(let a of p){let c=Math.max(0,a[0]-s),g=Math.min(n.length-1,a[a.length-1]+s),w=n.slice(c,g+1),m=[],F=1,b=1,B=0,D=0;for(let u=0;u<c;u++){let h=n[u];if(h.op==="equal"||h.op==="remove")F++;if(h.op==="equal"||h.op==="add")b++}for(let u of w)if(u.op==="equal")m.push(` ${u.line}`),B++,D++;else if(u.op==="remove")m.push(`-${u.line}`),B++;else if(u.op==="add")m.push(`+${u.line}`),D++;r.push({operation:"equal",lines:m,oldStart:F,oldCount:B,newStart:b,newCount:D})}return r}function Ps(n){if(n.identical)return"";let t=[];t.push(`--- a/${n.filePath}`),t.push(`+++ b/${n.filePath}`);for(let e of n.hunks)t.push(`@@ -${e.oldStart},${e.oldCount} +${e.newStart},${e.newCount} @@`),t.push(...e.lines);return t.join(`
|
|
5
|
+
`)}function Mr(n){if(n.identical)return`\x1B[32m\u2713 ${n.filePath} (unchanged)\x1B[0m`;let t=[],e=`+${n.stats.additions} -${n.stats.deletions}`;t.push(`\x1B[1m${n.filePath}\x1B[0m \x1B[90m(${e})\x1B[0m`),t.push("");for(let i of n.hunks){t.push(`\x1B[36m@@ -${i.oldStart},${i.oldCount} +${i.newStart},${i.newCount} @@\x1B[0m`);for(let o of i.lines)if(o.startsWith("+"))t.push(`\x1B[32m${o}\x1B[0m`);else if(o.startsWith("-"))t.push(`\x1B[31m${o}\x1B[0m`);else t.push(`\x1B[90m${o}\x1B[0m`);t.push("")}return t.join(`
|
|
6
|
+
`)}function Ds(n){if(n.identical)return`${n.filePath}: unchanged`;return`${n.filePath}: +${n.stats.additions} -${n.stats.deletions} lines`}async function Or(n,t,e={}){let i="";try{let o=ae(n);if(await o.exists())i=await o.text();else if(!e.treatMissingAsEmpty)return ut("",t,n,e)}catch{if(!e.treatMissingAsEmpty)return ut("",t,n,e)}return ut(i,t,n,e)}async function Rs(n,t={}){let e=new Map;for(let[i,o]of n){let s=await Or(i,o,t);e.set(i,s)}return e}function Ir(n){let t=0,e=0,i=0,o=0,s=0;for(let r of n.values())if(r.identical)e++;else if(t++,i+=r.stats.additions,o+=r.stats.deletions,!r.oldContent)s++;return{totalFiles:n.size,changedFiles:t,unchangedFiles:e,totalAdditions:i,totalDeletions:o,newFiles:s}}function Fr(n){console.log(Mr(n))}function Ms(n,t=!1){for(let i of n.values()){if(i.identical&&!t)continue;Fr(i)}let e=Ir(n);if(console.log(""),console.log(`\x1B[1mSummary:\x1B[0m ${e.totalFiles} files, ${e.changedFiles} changed, ${e.unchangedFiles} unchanged`),e.changedFiles>0)console.log(` \x1B[32m+${e.totalAdditions}\x1B[0m \x1B[31m-${e.totalDeletions}\x1B[0m lines`);if(e.newFiles>0)console.log(` ${e.newFiles} new files`)}
|
|
7
|
+
export{ut,Ps,Mr,Ds,Or,Rs,Ir,Fr,Ms};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{R,M}from"./chunk-z4mvkazp.js";import{A,P}from"./chunk-mt9219xc.js";import{p}from"./chunk-v6fwy63g.js";import{k,D}from"./chunk-ttc5pr8y.js";import{xe}from"./chunk-25vyhfzh.js";import{l}from"./chunk-t1jtn2r0.js";import{ye}from"./chunk-w9av39jy.js";function Ue(t,n,s,r,i){if(r.length!==1||r[0]!=="bun")return null;let o=R(n)?M(t):A(n)?P(t):t;return ye(o,{keepComments:s,isolatedDeclarations:i})}var S=100,h=0,c=new Map;function bt(t,n="stdin.ts",s=!0,r=["bun"],i=!1){let o=p(t),a=JSON.stringify([n,s,i,r]),g=c.get(a);if(g&&g.contentHash===o)return g.lastAccess=++h,g.result;let b=Ue(t,n,s,r,i)??y(t,n,s,r,i);if(c.set(a,{result:b,contentHash:o,lastAccess:++h}),c.size>S){let x=Math.max(1,Math.ceil(c.size*0.1)),u=[];for(let[e,f]of c)u.push([e,f.lastAccess]);u.sort((e,f)=>e[1]-f[1]);for(let e=0;e<x&&e<u.length;e++)c.delete(u[e][0])}return b}function oi(t,n="stdin.ts",s=!0,r=["bun"]){return bt(t,n,s,r,!0)}function ai(t,n="stdin.ts",s=!0,r=["bun"]){return bt(t,n,s,r,!1)}function y(t,n,s,r,i){let o=xe(t,n,s,i);return l(o,{filePath:n,sourceCode:t,declarations:o},s,r)}function ci(){c.clear()}function Ca(t,n="stdin.ts",s=!0,r=["bun"],i=!1){return Ue(t,n,s,r,i)??gn(t,n,s,r,i)}function gn(t,n="stdin.ts",s=!0,r=["bun"],i=!1){if(R(n))t=M(t);else if(A(n))t=P(t);let o=i?k(t,n,s):D(t,n,s);return l(o,{filePath:n,sourceCode:t,declarations:o},s,r)}
|
|
3
|
+
export{Ue,bt,oi,ai,ci,Ca,gn};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{s}from"./chunk-0azm93j9.js";import w from"process";import{dirname as x,relative as y,resolve as B,sep as l}from"path";function Fe(p={}){let{preBuild:c=!1,postBuild:r=!0,onGenerated:n,onError:o,failOnError:E=!0,...e}=p,v=async(i)=>{try{let t=await s(i);n?.(t)}catch(t){let d=t instanceof Error?t:Error(String(t));if(o?.(d),!o)console.error("[dtsx] Generation failed:",d.message);if(E)throw d}};return{name:"dtsx",async setup(i){if(!c&&!r)return;let t=e.cwd||w.cwd(),u=(i.config.entrypoints||[]).map((a)=>B(t,a)),g=e.root||i.config.root||(u.length>0?y(t,G(u))||".":"./src"),f=B(t,g),m=e.entrypoints||u.filter((a)=>a===f||a.startsWith(`${f}${l}`)).map((a)=>y(f,a));await v({...e,cwd:t,root:g,entrypoints:m.length>0?m:["index.ts"],outdir:e.outdir||i.config.outdir||"./dist",moduleSpecifierMode:e.moduleSpecifierMode??(i.config.target==="node"?"node":"preserve")})}}}function G(p){let c=p.map((n)=>x(n).split(l)),r=c[0];for(let n of c.slice(1)){let o=0;while(o<r.length&&o<n.length&&r[o]===n[o])o++;r=r.slice(0,o)}return r.join(l)||l}var ha=Fe,ya=Fe;
|
|
3
|
+
export{Fe,ha,ya};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var Zr=[{pattern:/^Promise<void>$/,replacement:"Promise<void>",priority:-1},{pattern:/^Record<string,\s*any>$/,replacement:"Record<string, unknown>",priority:0},{pattern:/^Array<([^<>]+)>$/,replacement:"$1[]",priority:0}],Qr=[{pattern:/\bany\b/,replacement:"unknown",global:!0,priority:10},{pattern:/^object$/,replacement:"Record<string, unknown>",priority:10},{pattern:/^Function$/,replacement:"(...args: unknown[]) => unknown",priority:10}],ei=[{pattern:/^(\w+)\[\]$/,replacement:"readonly $1[]",priority:5},{pattern:/^Array<(.+)>$/,replacement:"ReadonlyArray<$1>",priority:5},{pattern:/^Map<(.+),\s*(.+)>$/,replacement:"ReadonlyMap<$1, $2>",priority:5},{pattern:/^Set<(.+)>$/,replacement:"ReadonlySet<$1>",priority:5}],ti=[{pattern:/^Partial<Partial<(.+)>>$/,replacement:"Partial<$1>",priority:5},{pattern:/^Required<Required<(.+)>>$/,replacement:"Required<$1>",priority:5},{pattern:/^Pick<Omit<(.+),\s*(.+)>,\s*(.+)>$/,replacement:"Pick<$1, $3>",priority:5}];function ni(e){switch(e){case"strict":return Qr;case"readonly":return ei;case"simplified":return ti;case"nullable":return[{pattern:/^(.+)\s*\|\s*undefined$/,replacement:"$1 | undefined",priority:5}];case"branded":return[{pattern:/^string$/,replacement:"string",condition:(r)=>r.declarationKind==="variable"&&(r.declarationName?.includes("path")??!1),priority:5}];default:return[]}}var u=/[.*+?^${}()|[\]\\]/g,c=2048;class fn{rules;compiled=[];cache=new Map;constructor(e={rules:[]}){if(this.rules=[],e.includeDefaults!==!1)this.rules.push(...Zr);if(e.presets)for(let r of e.presets)this.rules.push(...ni(r));this.rules.push(...e.rules),this.rules.sort((r,t)=>(t.priority||0)-(r.priority||0)),this.recompile()}recompile(){let e=Array(this.rules.length);for(let r=0;r<this.rules.length;r++){let t=this.rules[r],i=typeof t.pattern==="string"?new RegExp(t.pattern.replace(u,"\\$&"),t.global?"g":""):t.pattern;e[r]={rule:t,regex:i}}this.compiled=e}map(e,r={}){let i=!r.declarationName&&!r.declarationKind&&!r.filePath&&!r.isReturnType&&!r.isParameterType&&!r.isPropertyType?e:`${e}\x00${r.declarationName??""}\x00${r.declarationKind??""}\x00${r.filePath??""}\x00${r.isReturnType?"r":""}${r.isParameterType?"p":""}${r.isPropertyType?"P":""}`,l=this.cache.get(i);if(l!==void 0)return l;let a=e,o=null;for(let s=0;s<this.compiled.length;s++){let{rule:p,regex:n}=this.compiled[s];if(p.condition){if(!o)o={type:e,...r};if(!p.condition(o))continue}if(n.lastIndex=0,n.test(a)){if(n.lastIndex=0,a=a.replace(n,p.replacement),n.lastIndex=0,!p.global)break}}if(this.cache.size>=c){let s=Math.ceil(c*0.1),p=0;for(let n of this.cache.keys()){if(p++>=s)break;this.cache.delete(n)}}return this.cache.set(i,a),a}mapAll(e,r={}){return e.map((t)=>this.map(t,{...r,type:t}))}addRule(e){this.rules.push(e),this.rules.sort((r,t)=>(t.priority||0)-(r.priority||0)),this.recompile(),this.cache.clear()}removeRules(e){let r=this.rules.length;return this.rules=this.rules.filter((t)=>{let i=typeof t.pattern==="string"?t.pattern:t.pattern.source;if(e instanceof RegExp)e.lastIndex=0;return typeof e==="string"?i!==e:!e.test(i)}),this.recompile(),this.cache.clear(),r-this.rules.length}clearCache(){this.cache.clear()}getRules(){return this.rules}}function U(e={rules:[]}){return new fn(e)}var go=U({rules:[]}),ho=U({rules:[],presets:["strict"]});function dt(e,r,t={}){return e.replace(/:\s*([^;,)\]}]+)/g,(i,l)=>`: ${r.map(l.trim(),t)}`)}var yo={makeReadonly:(e)=>{if(e.endsWith("[]"))return`readonly ${e}`;if(e.startsWith("Array<"))return e.replace("Array<","ReadonlyArray<");return e},makeNullable:(e)=>{if(e.includes("| null")||e.includes("| undefined"))return e;return`${e} | null`},makeOptional:(e)=>{if(e.includes("| undefined"))return e;return`${e} | undefined`},makeRequired:(e)=>e.replace(/\s*\|\s*null/g,"").replace(/\s*\|\s*undefined/g,"").trim(),promisify:(e)=>{if(e.startsWith("Promise<"))return e;return`Promise<${e}>`},unpromisify:(e)=>{let r=e.match(/^Promise<(.+)>$/);return r?r[1]:e},arrayify:(e)=>{if(e.endsWith("[]")||e.startsWith("Array<"))return e;return`${e}[]`},unarrayify:(e)=>{if(e.endsWith("[]"))return e.slice(0,-2);let r=e.match(/^(?:Readonly)?Array<(.+)>$/);return r?r[1]:e}};
|
|
3
|
+
export{Zr,Qr,ei,ti,ni,fn,U,go,ho,dt,yo};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Pe}from"./chunk-cen2t56g.js";import{k}from"./chunk-ttc5pr8y.js";import{y}from"./chunk-wnk9yjw2.js";function dn(i,r){let n=new Set;for(let e of k(i,"imports.ts",!1)){if(e.kind!=="import")continue;let t=y(e.text),a=t&&r.get(t.source);if(!t||t.isTypeOnly||!a)continue;let s=_e(a);for(let o of t.namedItems)if(!o.isTypeOnly&&s.some((m)=>m.name===o.originalName))n.add(o.name);if(t.defaultName&&s.some((o)=>o.isDefault))n.add(t.defaultName)}return n}function _e(i){let r=k(i,"dependency.ts",!1).filter((n)=>n.kind==="function");return r.filter((n)=>n.isExported&&!n.generics&&r.filter((e)=>e.name===n.name).length===1&&Pe(i,n.name)===1).map((n)=>({name:n.name,isDefault:Boolean(n.isDefault)})).sort((n,e)=>n.name.localeCompare(e.name))}
|
|
3
|
+
export{dn,_e};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
function rt(e,r={}){let{entryPoints:n,keepExported:s=!0,keep:t=[],remove:l=[],shakableKinds:c=["type","interface"],debug:m=!1}=r,p=m?console.log.bind(console,"[tree-shake]"):()=>{},x=new Map;for(let a of e)x.set(a.name,a);let i=it(e);p("Dependency graph:",Object.fromEntries(Array.from(i.entries()).map(([a,d])=>[a,Array.from(d)])));let o=new Set;if(n&&n.length>0){for(let a of n)if(x.has(a))o.add(a)}else{let a=new Set(c);for(let d of e){if(s&&d.isExported){o.add(d.name);continue}if(k(d.name,t)){o.add(d.name);continue}if(!a.has(d.kind))o.add(d.name)}}if(n&&n.length>0&&t.length>0){for(let a of e)if(k(a.name,t))o.add(a.name)}p("Entry points:",Array.from(o));let f=T(o,i);p("Reachable:",Array.from(f));let u=new Set,g=[];for(let a of e){let d=a.name;if(f.has(d)){u.add(d);continue}if(k(d,l)){g.push(d);continue}if(!c.includes(a.kind)){u.add(d);continue}g.push(d)}p("Keeping:",Array.from(u)),p("Removing:",g);let b=e.filter((a)=>u.has(a.name)),y={totalBefore:e.length,totalAfter:b.length,removedCount:g.length,reductionPercent:e.length>0?Math.round(g.length/e.length*100):0};return{declarations:b,removed:g,dependencyGraph:i,stats:y}}function it(e){let r=new Map,n=new Set;for(let s=0;s<e.length;s++)n.add(e[s].name);for(let s of e){let t=new Set,l=st(s);for(let c of l)if(n.has(c)&&c!==s.name)t.add(c);r.set(s.name,t)}return r}function st(e){let r=new Set;if(e.typeAnnotation)h(e.typeAnnotation,r);if(e.extends)h(e.extends,r);if(e.text)R(e.text,r);if(e.members)for(let n of e.members){let s=st(n);for(let t of s)r.add(t)}if(e.parameters){for(let n of e.parameters)if(n.type)h(n.type,r)}if(e.returnType)h(e.returnType,r);return r}var E=new Set(["string","number","boolean","object","any","unknown","never","void","null","undefined","symbol","bigint","true","false","Array","Object","String","Number","Boolean","Function","Symbol","Promise","Map","Set","WeakMap","WeakSet","Record","Partial","Required","Readonly","Pick","Omit","Exclude","Extract","NonNullable","Parameters","ReturnType","InstanceType","ConstructorParameters","ThisParameterType","OmitThisParameter","ThisType","Uppercase","Lowercase","Capitalize","Uncapitalize","Awaited","keyof","typeof","infer","extends","readonly","const","new"]),S=/\b([A-Z]\w*)\b/g,D=/\btypeof\s+([$A-Z_a-z][$\w]*)/g;function h(e,r){S.lastIndex=0;let n;while((n=S.exec(e))!==null){let s=n[1];if(!E.has(s))r.add(s)}D.lastIndex=0;while((n=D.exec(e))!==null)r.add(n[1])}function R(e,r){h(e,r)}function T(e,r){let n=new Set,s=Array.from(e);while(s.length>0){let t=s.pop();if(n.has(t))continue;n.add(t);let l=r.get(t);if(l){for(let c of l)if(!n.has(c))s.push(c)}}return n}function k(e,r){for(let n of r)if(typeof n==="string"){if(n.includes("*")){if(new RegExp(`^${n.replace(/\*/g,".*").replace(/\?/g,".")}$`).test(e))return!0}else if(e===n)return!0}else if(n.test(e))return!0;return!1}function tr(e,r={}){let n=e.split(`
|
|
3
|
+
`),s=[],t=null;for(let i=0;i<n.length;i++){let o=n[i],f=o.trim();if(!t&&(f===""||f.startsWith("//")))continue;if(!t){let u=f.match(/^(export\s+)?(declare\s+)?(interface|type|enum|class|function|const|let|var)\s+(\w+)/);if(u){let[,g,,b,y]=u;if(t={name:y,kind:b,isExported:!!g,start:i,lines:[o],braceCount:0},t.braceCount+=(o.match(/\{/g)||[]).length,t.braceCount-=(o.match(/\}/g)||[]).length,t.braceCount===0&&(f.endsWith(";")||!f.includes("{")))s.push({name:t.name,kind:t.kind,isExported:t.isExported,start:t.start,end:i,text:t.lines.join(`
|
|
4
|
+
`)}),t=null;continue}}if(t){if(t.lines.push(o),t.braceCount+=(o.match(/\{/g)||[]).length,t.braceCount-=(o.match(/\}/g)||[]).length,t.braceCount<=0&&(f.endsWith("}")||f.endsWith(";")))s.push({name:t.name,kind:t.kind,isExported:t.isExported,start:t.start,end:i,text:t.lines.join(`
|
|
5
|
+
`)}),t=null}}if(s.length===0)return{content:e,removed:[]};let l=s.map((i)=>({name:i.name,kind:i.kind,isExported:i.isExported,text:i.text})),c=rt(l,r),m=new Set(c.declarations.map((i)=>i.name)),p=new Set;for(let i of s)if(!m.has(i.name))for(let o=i.start;o<=i.end;o++)p.add(o);return{content:n.filter((i,o)=>!p.has(o)).join(`
|
|
6
|
+
`).replace(/\n{3,}/g,`
|
|
7
|
+
|
|
8
|
+
`),removed:c.removed}}function nr(e,r={}){return rt(e,{...r,debug:!1}).removed}function rr(e,r){let n=it(r),s=n.get(e)||new Set,t=T(new Set([e]),n);t.delete(e);let l=[];for(let[c,m]of n)if(c!==e&&m.has(e))l.push(c);return{directDependencies:Array.from(s),transitiveDependencies:Array.from(t),dependents:l}}function Ai(e={}){return{shake:(r)=>rt(r,e),shakeContent:(r)=>tr(r,e),findUnused:(r)=>nr(r,e),analyzeDependencies:(r,n)=>rr(r,n),buildGraph:it,extractRefs:st}}
|
|
9
|
+
export{rt,it,st,tr,nr,rr,Ai};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var rn=["import","type","interface","enum","class","function","variable","export","module","namespace","unknown"],Yr=["builtin","external","scoped","internal","parent","sibling","index","type"];function je(e,n={}){let{lineEnding:t="lf",trailingNewline:i=!0,maxBlankLines:u=1,trimTrailingWhitespace:a=!0,normalizeIndentation:l=!0,indent:x={style:"spaces",size:2},declarationOrder:f,importGrouping:p,preserveComments:d=!0,insertFinalNewline:b=!0}=n,r=e;if(r=sn(r,t),p?.enabled!==!1)r=ln(r,p||{});if(f)r=un(r,f);if(a)r=on(r);if(r=an(r,u),l)r=Xr(r,x);if(i||b)r=cn(r);return r}function sn(e,n){let t=e;if(e.indexOf("\r")!==-1){if(e.indexOf(`\r
|
|
3
|
+
`)!==-1)t=t.replace(/\r\n/g,`
|
|
4
|
+
`);if(t.indexOf("\r")!==-1)t=t.replace(/\r/g,`
|
|
5
|
+
`)}if(n==="crlf")t=t.replace(/\n/g,`\r
|
|
6
|
+
`);return t}function uo(e){let n=(e.match(/\r\n/g)||[]).length,t=(e.match(/(?<!\r)\n/g)||[]).length;if(n>t)return"crlf";return"lf"}function on(e){return e.split(`
|
|
7
|
+
`).map((n)=>n.replace(/[\t ]+$/,"")).join(`
|
|
8
|
+
`)}function an(e,n){let t=new RegExp(`\\n{${n+2},}`,"g");return e.replace(t,`
|
|
9
|
+
`.repeat(n+1))}function cn(e){return`${e.replace(/\s+$/,"")}
|
|
10
|
+
`}function Xr(e,n){let{style:t="spaces",size:i=2}=n,u=t==="tabs"?"\t":" ".repeat(i),a=e.split(`
|
|
11
|
+
`),l=[];for(let x of a){let f=x.match(/^([\t ]*)(.*)$/);if(!f){l.push(x);continue}let[,p,d]=f;if(!d){l.push("");continue}let b=p.replace(/\t/g," "),r=Math.floor(b.length/2);l.push(u.repeat(r)+d)}return l.join(`
|
|
12
|
+
`)}function ln(e,n){let{groups:t=Yr,separateGroups:i=!0,alphabetize:u=!0}=n,a=e.split(`
|
|
13
|
+
`),l=[],x=[],f=-1;for(let s=0;s<a.length;s++){let c=a[s],o=E(c);if(o)l.push({line:c,source:o.source,group:o.group,isType:o.isType}),f=s;else if(l.length>0&&c.trim()==="")continue;else if(l.length>0||c.trim()!==""){if(l.length===0||s>f+1)x.push(c)}}if(l.length===0)return e;let p=new Map;for(let s of t)p.set(s,[]);for(let s of l)(p.get(s.group)||p.get("external")||[]).push(s);if(u)for(let[,s]of p)s.sort((c,o)=>{if(c.isType!==o.isType)return c.isType?1:-1;return c.source.localeCompare(o.source)});let d=[],b=null;for(let s of t){let c=p.get(s)||[];if(c.length===0)continue;if(i&&b!==null)d.push("");for(let o of c)d.push(o.line);b=s}let r=a.slice(0,a.findIndex((s)=>E(s)!==null)),m=x;while(m.length>0&&m[0].trim()==="")m.shift();return[...r,...d,"",...m].join(`
|
|
14
|
+
`)}function E(e){let n=e.trim(),t=n.match(/^import\s+(type\s+)?.*from\s+['"]([^'"]+)['"]/);if(!t){let a=n.match(/^import\s+['"]([^'"]+)['"]/);if(a)return{source:a[1],group:k(a[1]),isType:!1};return null}let i=!!t[1],u=t[2];return{source:u,group:i?"type":k(u),isType:i}}function k(e){if(e.startsWith("node:"))return"builtin";let n=["assert","buffer","child_process","cluster","crypto","dgram","dns","events","fs","http","https","net","os","path","querystring","readline","stream","url","util","zlib"];if(n.includes(e)||n.includes(e.split("/")[0]))return"builtin";if(e==="."||e==="./index"||e==="./index.js"||e==="./index.ts")return"index";if(e.startsWith("./"))return"sibling";if(e.startsWith("../"))return"parent";if(e.startsWith("@/")||e.startsWith("~/")||e.startsWith("#"))return"internal";if(e.startsWith("@"))return"scoped";return"external"}function un(e,n){let{kinds:t=rn,alphabetize:i=!1,groupExports:u=!0}=n,a=e.split(`
|
|
15
|
+
`),l=[],x=[],f=[],p=null,d=0,b=!0,r=!1,m=[];for(let o=0;o<a.length;o++){let g=a[o],h=g.trim(),y=d,z=h.startsWith("///"),I=y===0&&!z&&(h.startsWith("//")||h.startsWith("/*"));if(r||I){if(m.push(g),!r&&h.startsWith("/*")&&!h.includes("*/"))r=!0;else if(r&&h.includes("*/"))r=!1;continue}if(y===0&&m.length>0&&h===""){m.push(g);continue}d+=(g.match(/\{/g)||[]).length,d-=(g.match(/\}/g)||[]).length;let W=T(h);if(b&&W&&W.kind!=="import"&&!h.startsWith("//")&&!h.startsWith("/*"))b=!1;if(b){if(m.length>0){if(W?.kind==="import"||!W)x.push(...m),m.length=0}x.push(g);continue}if(W&&d<=1){if(p)l.push(p);p={lines:m.length>0?[...m,g]:[g],kind:W.kind,name:W.name,isExport:W.isExport},m.length=0}else if(p)p.lines.push(g);else{if(h==="")continue;f.push(g)}}if(p)l.push(p);if(m.length>0)f.push(...m);l.sort((o,g)=>{if(u&&o.isExport!==g.isExport)return o.isExport?-1:1;let h=t.indexOf(o.kind),y=t.indexOf(g.kind),z=h>=0?h:t.length,I=y>=0?y:t.length;if(z!==I)return z-I;if(i)return o.name.localeCompare(g.name);return 0});let s=[...x],c=null;for(let o of l){if(c!==null&&o.kind!==c)s.push("");s.push(...o.lines),c=o.kind}if(f.length>0)s.push(""),s.push(...f);return s.join(`
|
|
16
|
+
`)}function T(e){let n=e.startsWith("export "),t=n?e.slice(7):e;if(e.startsWith("import "))return{kind:"import",name:e.match(/from\s+['"]([^'"]+)['"]/)?.[1]||"",isExport:!1};if(t.startsWith("type ")||t.startsWith("declare type "))return{kind:"type",name:t.match(/type\s+(\w+)/)?.[1]||"",isExport:n};if(t.startsWith("interface ")||t.startsWith("declare interface "))return{kind:"interface",name:t.match(/interface\s+(\w+)/)?.[1]||"",isExport:n};if(t.startsWith("class ")||t.startsWith("abstract class ")||t.startsWith("declare class ")||t.startsWith("declare abstract class "))return{kind:"class",name:t.match(/class\s+(\w+)/)?.[1]||"",isExport:n};if(t.startsWith("enum ")||t.startsWith("const enum ")||t.startsWith("declare enum ")||t.startsWith("declare const enum "))return{kind:"enum",name:t.match(/enum\s+(\w+)/)?.[1]||"",isExport:n};if(t.startsWith("function ")||t.startsWith("async function ")||t.startsWith("declare function ")||t.startsWith("declare async function "))return{kind:"function",name:t.match(/function\s+(\w+)/)?.[1]||"",isExport:n};if(t.startsWith("const ")||t.startsWith("let ")||t.startsWith("var ")||t.startsWith("declare const ")||t.startsWith("declare let ")||t.startsWith("declare var "))return{kind:"variable",name:t.match(/(?:const|let|var)\s+(\w+)/)?.[1]||"",isExport:n};if(t.startsWith("namespace ")||t.startsWith("declare namespace "))return{kind:"namespace",name:t.match(/namespace\s+(\w+)/)?.[1]||"",isExport:n};if(t.startsWith("module ")||t.startsWith("declare module "))return{kind:"module",name:t.match(/module\s+['"]?(\w+)['"]?/)?.[1]||"",isExport:n};if(e.startsWith("export {")||e.startsWith("export *")||e.startsWith("export type {"))return{kind:"export",name:"",isExport:!0};return null}function fo(e){let n=e.split(`
|
|
17
|
+
`),t=[];for(let i=0;i<n.length;i++){let u=n[i],a=u.trim();if(a.startsWith("/**")||a.startsWith("*")||a.startsWith("*/")){t.push(u);continue}if(a.startsWith("//")){t.push(u);continue}if(a.startsWith("/*")||a.endsWith("*/")){t.push(u);continue}t.push(u)}return t.join(`
|
|
18
|
+
`)}function po(e={}){return{normalize:(n)=>je(n,e),normalizeLineEndings:(n)=>sn(n,e.lineEnding||"lf"),removeTrailingWhitespace:on,normalizeBlankLines:(n)=>an(n,e.maxBlankLines||1),ensureTrailingNewline:cn,processImports:(n)=>ln(n,e.importGrouping||{}),orderDeclarations:(n)=>un(n,e.declarationOrder||{})}}var mo={default:{lineEnding:"lf",trailingNewline:!0,maxBlankLines:1,trimTrailingWhitespace:!0,normalizeIndentation:!0,indent:{style:"spaces",size:2},importGrouping:{enabled:!0,separateGroups:!0,alphabetize:!0}},minimal:{lineEnding:"lf",trailingNewline:!0,maxBlankLines:2,trimTrailingWhitespace:!0,normalizeIndentation:!1,importGrouping:{enabled:!1}},strict:{lineEnding:"lf",trailingNewline:!0,maxBlankLines:1,trimTrailingWhitespace:!0,normalizeIndentation:!0,indent:{style:"spaces",size:2},importGrouping:{enabled:!0,separateGroups:!0,alphabetize:!0},declarationOrder:{kinds:rn,alphabetize:!0,groupExports:!0}},windows:{lineEnding:"crlf",trailingNewline:!0,maxBlankLines:1,trimTrailingWhitespace:!0,normalizeIndentation:!0,indent:{style:"spaces",size:2},importGrouping:{enabled:!0,separateGroups:!0,alphabetize:!0}},tabs:{lineEnding:"lf",trailingNewline:!0,maxBlankLines:1,trimTrailingWhitespace:!0,normalizeIndentation:!0,indent:{style:"tabs",size:1},importGrouping:{enabled:!0,separateGroups:!0,alphabetize:!0}}};
|
|
19
|
+
export{rn,Yr,je,sn,uo,on,an,cn,Xr,ln,un,fo,po,mo};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var Ht=["builtin","external","internal","parent","sibling","index","type","unknown"];function Kt(e){let i=e.match(/^(import\s+)(type\s+)?(.+?)\s+from\s+['"]([^'"]+)['"]/);if(!i){let p=e.match(/^import\s+['"]([^'"]+)['"]/);if(p)return{statement:e,source:p[1],isTypeOnly:!1,group:ct(p[1]),specifiers:[]};return null}let[,,u,l,c]=i,g=!!u,m,h,f=[],n=l.trim(),a=n.match(/^\*\s+as\s+(\w+)$/);if(a)h=a[1];else if(n.includes("{")){let p=n.match(/^(\w+)\s*,/);if(p)m=p[1];let d=n.match(/\{([^}]+)\}/);if(d){let I=d[1].split(",").map((y)=>y.trim()).filter(Boolean);f.push(...I)}}else if(/^\w+$/.test(n))m=n;else{let p=n.match(/\{([^}]+)\}/);if(p){let d=p[1].split(",").map((I)=>I.trim()).filter(Boolean);f.push(...d)}}return{statement:e,source:c,isTypeOnly:g,group:ct(c,g),specifiers:f,defaultImport:m,namespaceImport:h}}function ct(e,i=!1){if(i)return"type";if(e.startsWith("node:")||O(e))return"builtin";if(e.startsWith("./"))return"sibling";if(e.startsWith("../"))return"parent";if(e==="."||e==="./index")return"index";if(e.startsWith("@/")||e.startsWith("~/")||e.startsWith("#"))return"internal";if(e.startsWith("@")||/^[a-z]/.test(e))return"external";return"unknown"}var b=new Set(["assert","buffer","child_process","cluster","console","constants","crypto","dgram","dns","domain","events","fs","http","https","module","net","os","path","perf_hooks","process","punycode","querystring","readline","repl","stream","string_decoder","sys","timers","tls","tty","url","util","v8","vm","wasi","worker_threads","zlib"]);function O(e){return b.has(e)}function qt(e,i={}){let{order:u=[],groupByType:l=!0,groups:c=Ht,alphabetize:g=!0,caseInsensitive:m=!0,typeImportsLast:h=!1,separateTypeImports:f=!1}=i,n=[];for(let t of e){let r=Kt(t);if(r)n.push(r);else n.push({statement:t,source:"",isTypeOnly:!1,group:"unknown",specifiers:[]})}let a=u.length>0?u.map((t)=>{if(t.startsWith("^"))try{return{regex:new RegExp(t),prefix:t.slice(1)}}catch{return{prefix:t.slice(1)}}return{prefix:t}}):[],p=(t)=>{for(let r=0;r<a.length;r++){let s=a[r];if(s.regex){if(s.regex.test(t))return r}else if(t.startsWith(s.prefix)||t.includes(`/${s.prefix}`))return r}return a.length},d=new Map,I=(t)=>{let r=d.get(t);if(r!==void 0)return r;let s=c.indexOf(t),o=s>=0?s:c.length;return d.set(t,o),o},y=(t,r)=>{if(a.length>0){let s=p(t.source),o=p(r.source);if(s!==o)return s-o}if(l){let s=I(t.group),o=I(r.group);if(s!==o)return s-o}if(h&&t.isTypeOnly!==r.isTypeOnly)return t.isTypeOnly?1:-1;if(g){let s=m?t.source.toLowerCase():t.source,o=m?r.source.toLowerCase():r.source;return s.localeCompare(o)}return 0};if(n.sort(y),l){let t=[],r=null;for(let s of n){if(r!==null&&s.group!==r){let o=c.indexOf(r),x=c.indexOf(s.group);if(o>=0&&x>=0&&o!==x)t.push("")}t.push(s.statement),r=s.group}return t}return n.map((t)=>t.statement)}function Er(e,i={}){let u=e.split(`
|
|
3
|
+
`),l=[],c=[],g=-1;for(let n=0;n<u.length;n++){let a=u[n].trim();if(a.startsWith("import "))l.push(u[n]),c.push(n),g=n;else if(l.length>0&&a==="")continue;else if(l.length>0&&!a.startsWith("import "))break}if(l.length===0)return e;let m=qt(l,i),h=u.slice(0,c[0]),f=u.slice(g+1);while(f.length>0&&f[0].trim()==="")f.shift();return[...h,...m,"",...f].join(`
|
|
4
|
+
`)}function ss(e={}){return{sort:(i)=>qt(i,e),sortContent:(i)=>Er(i,e),parse:Kt,detectGroup:ct}}var os={default:{groupByType:!0,groups:Ht,alphabetize:!0,caseInsensitive:!0},node:{order:["node:"],groupByType:!0,groups:["builtin","external","internal","parent","sibling","index"],alphabetize:!0},bun:{order:["bun","node:"],groupByType:!0,groups:["builtin","external","internal","parent","sibling","index"],alphabetize:!0},typeSeparated:{groupByType:!0,groups:["builtin","external","internal","parent","sibling","index","type"],separateTypeImports:!0,alphabetize:!0},alphabetical:{groupByType:!1,alphabetize:!0,caseInsensitive:!0},none:{groupByType:!1,alphabetize:!1}};
|
|
5
|
+
export{Ht,Kt,ct,qt,Er,ss,os};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
function Re(h){let a="",i=0,e=0;while(i<h.length){let r=h.charCodeAt(i);if(e){if(a+=h[i],r===92&&i+1<h.length){a+=h[i+1],i+=2;continue}if(r===e)e=0;i++;continue}if(r===34){e=r,a+=h[i++];continue}if(r===47&&h.charCodeAt(i+1)===47){i+=2;while(i<h.length&&h.charCodeAt(i)!==10&&h.charCodeAt(i)!==13)i++;continue}if(r===47&&h.charCodeAt(i+1)===42){i+=2;while(i+1<h.length&&!(h.charCodeAt(i)===42&&h.charCodeAt(i+1)===47)){if(h.charCodeAt(i)===10)a+=`
|
|
3
|
+
`;i++}i=Math.min(i+2,h.length);continue}if(r===44){let c=i+1;while(c<h.length){while(c<h.length&&h.charCodeAt(c)<=32)c++;if(h.charCodeAt(c)===47&&h.charCodeAt(c+1)===47){c+=2;while(c<h.length&&h.charCodeAt(c)!==10&&h.charCodeAt(c)!==13)c++;continue}if(h.charCodeAt(c)===47&&h.charCodeAt(c+1)===42){c+=2;while(c+1<h.length&&!(h.charCodeAt(c)===42&&h.charCodeAt(c+1)===47))c++;c=Math.min(c+2,h.length);continue}break}let t=h.charCodeAt(c);if(t===93||t===125){i++;continue}}a+=h[i++]}return a}
|
|
4
|
+
export{Re};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{readFile as M,writeFile as S}from"fs/promises";import{basename as x,dirname as d,relative as b,resolve as C}from"path";function f(e){return`${String.fromCharCode(47,47,35)} sourceMappingURL=${e}`}class Zt{file;sourceRoot;sources=[];sourcesContent=[];names=[];mappings=[];sourceIndexMap=new Map;nameIndexMap=new Map;constructor(e){this.file=e.file,this.sourceRoot=e.sourceRoot}addSource(e,n){let r=this.sourceIndexMap.get(e);if(r===void 0)r=this.sources.length,this.sources.push(e),this.sourcesContent.push(n??null),this.sourceIndexMap.set(e,r);else if(n&&!this.sourcesContent[r])this.sourcesContent[r]=n;return r}addName(e){let n=this.nameIndexMap.get(e);if(n===void 0)n=this.names.length,this.names.push(e),this.nameIndexMap.set(e,n);return n}addMapping(e){let n=this.addSource(e.source),r;if(e.name)r=this.addName(e.name);this.mappings.push({generated:e.generated,original:e.original,sourceIndex:n,nameIndex:r})}generate(e=!1){this.mappings.sort((r,t)=>{if(r.generated.line!==t.generated.line)return r.generated.line-t.generated.line;return r.generated.column-t.generated.column});let n={version:3,file:this.file,sources:this.sources,names:this.names,mappings:this.encodeMappings()};if(this.sourceRoot)n.sourceRoot=this.sourceRoot;if(e)n.sourcesContent=this.sourcesContent;return n}encodeMappings(){let e=[],n=0,r=0,t=0,i=0,o=0,s=0,u=[];for(let a of this.mappings){while(n<a.generated.line)e.push(u.join(",")),u=[],n++,r=0;let l=[];if(l.push(a.generated.column-r),r=a.generated.column,l.push(a.sourceIndex-t),t=a.sourceIndex,l.push(a.original.line-i),i=a.original.line,l.push(a.original.column-o),o=a.original.column,a.nameIndex!==void 0)l.push(a.nameIndex-s),s=a.nameIndex;u.push(I(l))}return e.push(u.join(",")),e.join(";")}toString(e=!1){return JSON.stringify(this.generate(e))}toDataUrl(e=!1){let n=this.toString(e);return`data:application/json;charset=utf-8;base64,${Buffer.from(n).toString("base64")}`}toComment(e=!1){return f(this.toDataUrl(e))}}class ft{map;decodedMappings=null;constructor(e){this.map=typeof e==="string"?JSON.parse(e):e}originalPositionFor(e){let n=this.getMappings(),r=0,t=n.length-1,i=null;while(r<=t){let o=Math.floor((r+t)/2),s=n[o];if(s.generated.line===e.line)if(s.generated.column===e.column){i=s;break}else if(s.generated.column<e.column)i=s,r=o+1;else t=o-1;else if(s.generated.line<e.line)r=o+1;else t=o-1}if(!i)return{source:null,line:null,column:null,name:null};return{source:this.map.sources[i.sourceIndex]||null,line:i.original.line,column:i.original.column,name:i.nameIndex!==void 0?this.map.names[i.nameIndex]:null}}generatedPositionFor(e){let n=this.map.sources.indexOf(e.source);if(n===-1)return null;let r=this.getMappings();for(let t of r)if(t.sourceIndex===n&&t.original.line===e.line&&t.original.column<=e.column)return t.generated;return null}getMappings(){if(!this.decodedMappings)this.decodedMappings=v(this.map.mappings);return this.decodedMappings}sourceContentFor(e){let n=this.map.sources.indexOf(e);if(n===-1||!this.map.sourcesContent)return null;return this.map.sourcesContent[n]}}function I(e){return e.map(L).join("")}function L(e){let o="",s=e<0?-e<<1|1:e<<1;do{let u=s&31;if(s>>>=5,s>0)u|=32;o+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[u]}while(s>0);return o}function v(e){let n=[],r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,i=0,o=0,s=0,u=0,a=0,l=e.split(";");for(let g of l){if(i=0,g){let h=g.split(",");for(let p of h){if(!p)continue;let c=N(p,"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");if(c.length>=1)i+=c[0];if(c.length>=4){o+=c[1],s+=c[2],u+=c[3];let m={generated:{line:t,column:i},original:{line:s,column:u},sourceIndex:o};if(c.length>=5)a+=c[4],m.nameIndex=a;n.push(m)}}}t++}return n}function N(e,n){let t=[],i=0,o=0;for(let s of e){let u=n.indexOf(s);if(u===-1)continue;let a=u&32;if(o+=(u&31)<<i,a)i+=5;else{let l=o&1;o>>=1,t.push(l?-o:o),o=0,i=0}}return t}function Js(e){let n=new Zt({file:x(e.generatedFile),sourceRoot:e.sourceRoot}),r=b(d(e.generatedFile),e.sourceFile);n.addSource(r,e.sourceContent);for(let t of e.mappings)n.addMapping({generated:{line:t.generatedLine,column:t.generatedColumn},original:{line:t.originalLine,column:t.originalColumn},source:r,name:t.name});return n}function Ys(e,n){return`${e}
|
|
3
|
+
${f(n)}`}function Xs(e,n,r=!1){return`${e}
|
|
4
|
+
${n.toComment(r)}`}async function Zs(e,n,r=!1){await S(e,n.toString(r))}async function Gr(e){let n=await M(e,"utf-8");return new ft(n)}async function Qs(e,n){let r=e.match(/\/\/# sourceMappingURL=data:application\/json[^,]+,(\S+)/);if(r){let i=r[1],o=Buffer.from(i,"base64").toString("utf-8");return new ft(o)}let t=e.match(/\/\/# sourceMappingURL=(.+)$/);if(t){let i=C(d(n),t[1].trim());try{return await Gr(i)}catch{return null}}return null}function eo(e,n){let r=e,t=n,i=r.split(`
|
|
5
|
+
`),o=[],s=0,u=0;for(let a of t){while(s+i[u].length+1<=a.generatedStart&&u<i.length-1)s+=i[u].length+1,u++;let l=a.generatedStart-s;o.push({generatedLine:u,generatedColumn:Math.max(0,l),originalLine:a.originalLine,originalColumn:a.originalColumn,name:a.name})}return o}
|
|
6
|
+
export{Zt,ft,Js,Ys,Xs,Zs,Gr,Qs,eo};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{B}from"./chunk-pga5m4wm.js";import{xe,Sn}from"./chunk-25vyhfzh.js";import{Y,wn}from"./chunk-1pz7zxhc.js";function ui(){wn(),Sn()}function r(e,t,c=!0,n=!1,o){return xe(e,t,c,n,o)}async function yn(e,t,c=!0,n={}){return await Y(t,e,n),r(e,t,c)}async function fi(e,t={}){let c=B(t.concurrency,4),n=new Map;for(let o=0;o<e.length;o+=c){let s=e.slice(o,o+c),i=await Promise.all(s.map(async(a)=>({path:a.filePath,declarations:await yn(a.sourceCode,a.filePath,a.keepComments,t)})));for(let a of i)n.set(a.path,a.declarations)}return n}
|
|
3
|
+
export{ui,r,yn,fi};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{S}from"./chunk-v44crx69.js";import{q}from"./chunk-79nv7twc.js";import{K,pe}from"./chunk-s0mvstt0.js";import{Xt}from"./chunk-fy97syc2.js";import{spawn as j}from"child_process";var N=new Set(["cwd","root","outdir","entrypoints","include","exclude","autoIncludeReExports","outputStructure","tsconfigPath","moduleSpecifierMode","keepComments","isolatedDeclarations","clean","lineEnding"]);function x(l,f,d,n,u){let s=u.signal;s?.throwIfAborted();let c=u.timeoutMs??30000;if(!Number.isSafeInteger(c)||c<=0||c>2147483647)throw RangeError("Native project timeoutMs must be an integer between 1 and 2147483647");return new Promise((g,r)=>{let o=j(l,f,{cwd:n,stdio:["pipe","pipe","pipe"],windowsHide:!0}),i=[],a=[],e,h,v=!1,p=(t)=>{e??=t,o.kill()},m=()=>p(s?.reason instanceof Error?s.reason:Error("Native declaration project aborted",{cause:s?.reason})),b=setTimeout(()=>p(Error(`Native declaration project exceeded ${c}ms`)),c),E=(t,w)=>{if(v)return;if(v=!0,clearTimeout(b),s?.removeEventListener("abort",m),t)r(t);else g(w)};if(o.once("error",(t)=>E(t)),o.stdout.on("data",(t)=>i.push(Buffer.from(t))),o.stderr.on("data",(t)=>a.push(Buffer.from(t))),o.stdout.once("error",p),o.stderr.once("error",p),o.stdin.once("error",(t)=>{h??=t}),o.once("close",(t,w)=>{if(t!==0&&!e)e=Error(`Native declaration project failed (${w??t}): ${Buffer.concat(a).toString("utf8")}`);E(e??h,Buffer.concat(i).toString("utf8"))}),s?.addEventListener("abort",m,{once:!0}),s?.aborted)m();o.stdin.end(Buffer.from(d,"utf8"))})}async function Zi(l,f={},d={}){if(!l||l.includes("\x00"))throw Error("A native zig-dtsx executable is required");for(let i of Object.keys(f))if(!N.has(i))throw Error(`Native declaration project does not support option: ${i}`);d.signal?.throwIfAborted();let n={...S,...f};if(await K(n),n.isolatedDeclarations===void 0)n.isolatedDeclarations=await q(n);let u=await Xt(n),s=["--batch"];if(!n.keepComments)s.push("--no-comments");if(n.isolatedDeclarations)s.push("--isolated-declarations");let c=JSON.stringify({protocol:"zig-dtsx-project",version:1,files:u.files.map((i)=>({source:i.source,context:i.context}))}),g=await x(l,s,c,n.cwd,d),r;try{r=JSON.parse(g)}catch(i){throw Error("Native executable did not return a valid zig-dtsx project protocol response",{cause:i})}if(!r||typeof r!=="object"||!("protocol"in r)||r.protocol!=="zig-dtsx-project"||!("version"in r)||r.version!==1||!("files"in r)||!Array.isArray(r.files)||r.files.length!==u.files.length)throw Error("Native executable returned an unsupported or incomplete project response");let o=new Map;for(let[i,a]of u.files.entries()){let e=r.files[i];if(!e||typeof e!=="object"||!("sourceFile"in e)||e.sourceFile!==a.sourceFile||!("outputFile"in e)||e.outputFile!==a.outputFile||!("sourceHash"in e)||e.sourceHash!==a.context.sourceHash||!("content"in e)||typeof e.content!=="string")throw Error(`Native executable returned a mismatched project result for ${a.sourceFile}`);o.set(a.outputFile,{content:e.content,lineEnding:n.lineEnding})}return d.signal?.throwIfAborted(),await pe(n,o),Object.freeze({filesGenerated:o.size,outputFiles:Object.freeze([...o.keys()])})}
|
|
3
|
+
export{Zi};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{createReadStream as l,createWriteStream as c,statSync as m}from"fs";import{createInterface as u}from"readline";class Nt{config;profiles=[];cleanupTimer=null;constructor(e={}){this.config={maxMemoryMB:e.maxMemoryMB??512,chunkSize:e.chunkSize??65536,aggressiveGC:e.aggressiveGC??!0,maxDeclarationsInMemory:e.maxDeclarationsInMemory??1e4,profile:e.profile??!1,cleanupInterval:e.cleanupInterval??5000}}startMonitoring(){if(this.cleanupTimer=setInterval(()=>{this.checkMemoryAndCleanup()},this.config.cleanupInterval),this.cleanupTimer&&typeof this.cleanupTimer==="object"&&"unref"in this.cleanupTimer)this.cleanupTimer.unref()}stopMonitoring(){if(this.cleanupTimer)clearInterval(this.cleanupTimer),this.cleanupTimer=null}checkMemoryAndCleanup(){if(this.getMemoryStats().heapUsedMB>this.config.maxMemoryMB)this.triggerCleanup()}triggerCleanup(){if(this.config.aggressiveGC&&global.gc)global.gc()}getMemoryStats(){let e=process.memoryUsage();return{heapUsed:e.heapUsed,heapTotal:e.heapTotal,external:e.external,arrayBuffers:e.arrayBuffers,rss:e.rss,heapUsedMB:Math.ceil(e.heapUsed/1024/1024),percentUsed:Math.min(100,Math.round(e.heapUsed/e.heapTotal*100))}}async profile(e,t){if(!this.config.profile)return t();let r=this.getMemoryStats(),i=Date.now();try{return await t()}finally{let n=this.getMemoryStats(),s=Date.now()-i;this.profiles.push({timestamp:Date.now(),operation:e,memoryBefore:r,memoryAfter:n,duration:s})}}getProfiles(){return[...this.profiles]}clearProfiles(){this.profiles=[]}async*streamFile(e){let t=l(e,{encoding:"utf-8",highWaterMark:this.config.chunkSize}),r=u({input:t,crlfDelay:1/0});for await(let i of r)yield i}async processFileInChunks(e,t,r=1000){let i=[],n=[];for await(let s of this.streamFile(e))if(n.push(s),n.length>=r){let a=await t(n);i.push(...a),n=[],this.checkMemoryAndCleanup()}if(n.length>0){let s=await t(n);i.push(...s)}return i}async streamWrite(e,t){let r=c(e,{encoding:"utf-8"});return new Promise((i,n)=>{let s=async()=>{try{for await(let a of t)if(!r.write(a))await new Promise((o)=>r.once("drain",()=>o()));r.end(),r.once("finish",i)}catch(a){n(a)}};r.once("error",n),s()})}}class ir{declarations=new Map;registry=new FinalizationRegistry((e)=>{this.declarations.delete(e)});maxSize;constructor(e=1e4){this.maxSize=e}add(e,t){if(this.declarations.size>=this.maxSize)this.evictOldest();let r=new WeakRef(t);this.declarations.set(e,r),this.registry.register(t,e)}get(e){return this.declarations.get(e)?.deref()}has(e){return this.declarations.get(e)?.deref()!==void 0}delete(e){this.declarations.delete(e)}clear(){this.declarations.clear()}get size(){return this.declarations.size}evictOldest(){let e=Math.ceil(this.maxSize*0.2),t=Array.from(this.declarations.keys());for(let r=0;r<e&&r<t.length;r++)this.declarations.delete(t[r])}}class sr{value=null;loaded=!1;loader;constructor(e){this.loader=e}async get(){if(!this.loaded)this.value=await this.loader(),this.loaded=!0;return this.value}isLoaded(){return this.loaded}unload(){this.value=null,this.loaded=!1}}class or{strings=new Map;maxSize;constructor(e=50000){this.maxSize=e}intern(e){if(e.length>100)return e;let t=this.strings.get(e);if(t!==void 0)return t;if(this.strings.size>=this.maxSize){let r=Array.from(this.strings.keys());for(let i=0;i<r.length/2;i++)this.strings.delete(r[i])}return this.strings.set(e,e),e}get size(){return this.strings.size}clear(){this.strings.clear()}}class ar{pool=[];factory;reset;maxSize;constructor(e,t,r=1000){this.factory=e,this.reset=t,this.maxSize=r}acquire(){if(this.pool.length>0)return this.pool.pop();return this.factory()}release(e){if(this.pool.length<this.maxSize)this.reset(e),this.pool.push(e)}get size(){return this.pool.length}clear(){this.pool=[]}}function Pi(e,t={}){return{...e,memory:{maxMemoryMB:t.maxMemoryMB??512,chunkSize:t.chunkSize??65536,aggressiveGC:t.aggressiveGC??!0,maxDeclarationsInMemory:t.maxDeclarationsInMemory??1e4,profile:t.profile??!1,cleanupInterval:t.cleanupInterval??5000}}}function Di(e){let r=m(e).size/1024/1024,i=r*4,n=65536;if(r>10)n=32768;if(r>50)n=16384;return{fileSizeMB:Math.round(r*100)/100,estimatedMemoryMB:Math.round(i*100)/100,recommendedChunkSize:n}}function Ri(e){return[`Heap: ${e.heapUsedMB}MB / ${Math.round(e.heapTotal/1024/1024)}MB (${e.percentUsed}%)`,`RSS: ${Math.round(e.rss/1024/1024)}MB`,`External: ${Math.round(e.external/1024/1024)}MB`].join(" | ")}function Mi(e={}){return new Nt(e)}
|
|
3
|
+
export{Nt,ir,sr,or,ar,Pi,Di,Ri,Mi};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
function u(r,e=!0){if(!e||!r||r.length===0)return"";if(r.length===1){let t=r[0];if(t.length>0&&t.charCodeAt(0)>32&&t.charCodeAt(t.length-1)>32)return`${t}
|
|
3
|
+
`;return`${t.trim()}
|
|
4
|
+
`}let n="";for(let t=0;t<r.length;t++){if(t>0)n+=`
|
|
5
|
+
`;n+=r[t].trim()}return`${n}
|
|
6
|
+
`}function Te(r){return r.replaceAll("*/","*\\/")}
|
|
7
|
+
export{u,Te};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Re}from"./chunk-pzedkn7z.js";import{readFileSync as m,statSync as w}from"fs";import{readFile as y}from"fs/promises";import{createRequire as v}from"module";import{dirname as g,isAbsolute as b,join as u,resolve as p}from"path";function l(t){let o=[t];if(!t.endsWith(".json"))o.push(`${t}.json`);o.push(u(t,"tsconfig.json"));for(let a of o)try{if(w(a).isFile())return a}catch{}return null}function E(t,o){if(b(t)||t.startsWith("."))return l(p(g(o),t));let a=v(o),n=t.startsWith("@")?/^@[^/]+\/[^/]+/.exec(t)?.[0]:t.split("/")[0];if(n)for(let d of a.resolve.paths(n)??[]){let e=l(u(d,n,"package.json"));if(!e)continue;let i=JSON.parse(m(e,"utf8"));if(t===n){if(i.tsconfig!==void 0){if(typeof i.tsconfig!=="string")throw Error(`Invalid tsconfig field in ${e}`);let r=l(p(g(e),i.tsconfig));if(!r)throw Error(`Cannot resolve tsconfig ${JSON.stringify(i.tsconfig)} from ${e}`);return r}let s=l(u(g(e),"tsconfig.json"));if(s)return s}break}for(let d of[`${t}/tsconfig.json`,t])try{let e=a.resolve(d),i=e.endsWith(".json")?l(e):null;if(i)return i}catch{}return null}async function oe(t,o={},a=new Set){let n=l(t);if(!n)return;if(a.has(n)){if(o.allowCircular)return;throw Error(`Circular tsconfig extends: ${n}`)}let d=new Set(a).add(n),e=JSON.parse(Re(await y(n,"utf8"))),i=typeof e.extends==="string"?[e.extends]:e.extends??[];if(!Array.isArray(i)||i.some((f)=>typeof f!=="string"))throw Error(`Invalid tsconfig extends in ${n}`);let s={};for(let f of i){let c=E(f,n);if(!c)throw Error(`Cannot resolve tsconfig extends ${JSON.stringify(f)} from ${n}`);s={...s,...await oe(c,o,d)}}let r=e.compilerOptions??{};if(r.isolatedDeclarations!==void 0)s.isolatedDeclarations=r.isolatedDeclarations;if(r.baseUrl!==void 0){if(typeof r.baseUrl!=="string")throw Error(`Invalid baseUrl in ${n}`);s.baseUrl=p(g(n),r.baseUrl)}if(r.paths!==void 0){if(!r.paths||typeof r.paths!=="object"||Array.isArray(r.paths))throw Error(`Invalid paths in ${n}`);for(let[f,c]of Object.entries(r.paths))if(f.split("*").length>2||!Array.isArray(c)||c.length===0||c.some((h)=>typeof h!=="string"||h.split("*").length>2))throw Error(`Invalid path mapping ${JSON.stringify(f)} in ${n}`);s.paths=r.paths,s.pathsBasePath=g(n)}return s}
|
|
3
|
+
export{oe};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{v}from"./chunk-853ftm92.js";import{_}from"./chunk-79nv7twc.js";import{chmod as G,lstat as S,mkdir as y,readdir as j,realpath as q,rename as k,rm as R,rmdir as L,stat as A,writeFile as W}from"fs/promises";import{basename as B,dirname as m,isAbsolute as M,parse as J,relative as F,resolve as l}from"path";function f(a,e){return a instanceof Error&&"code"in a&&a.code===e}async function w(a){try{return await S(a)}catch(e){if(f(e,"ENOENT"))return;throw e}}async function g(a){let e=l(a);try{return await q(e)}catch(n){if(!f(n,"ENOENT")||m(e)===e)throw n;return l(await g(m(e)),B(e))}}async function K(a){let e=l(a.cwd,a.outdir);if(a.bundle&&a.bundleOutput){if(M(a.bundleOutput))throw Error("bundleOutput must be relative to outdir");if(!v(l(e,a.bundleOutput),e))throw Error("bundleOutput must stay within outdir")}if(!a.clean||a.dryRun)return;if(e===J(e).root)throw Error("Refusing to clean declarations from the filesystem root");let[n,r]=await Promise.all([g(e),g(l(a.cwd,a.root))]);if(v(r,n))throw Error("Refusing to clean an outdir that contains the source root")}function z(a){return[".d.ts",".d.mts",".d.cts",".d.ts.map",".d.mts.map",".d.cts.map"].some((e)=>a.endsWith(e))}function O(a,e){return a.dev===e.dev&&a.ino===e.ino}async function x(a,e){try{if(!(await A(a)).isDirectory())throw Error(`Declaration output parent is not a directory: ${a}`);return}catch(r){if(!f(r,"ENOENT"))throw r}let n=m(a);if(n===a)throw Error(`Cannot create declaration output directory: ${a}`);await x(n,e);try{await y(a),e.push(a)}catch(r){if(!f(r,"EEXIST")||!(await A(a)).isDirectory())throw r}}async function X(a,e,n){for(let r of(await j(a,{withFileTypes:!0})).sort((s,p)=>s.name.localeCompare(p.name))){let s=l(a,r.name);if(s===e)continue;if(r.isDirectory())await X(s,e,n);else if(z(r.name)){let p=await w(s);if(!p)throw Error(`Declaration output changed during inventory: ${s}`);n.set(s,p)}}}function P(a,e,n,r,s){return Object.assign(AggregateError(e,a),{code:"DTSX_PUBLICATION_FAILED",phase:n,recoveryDirectory:r,outputsCommitted:s})}async function pe(a,e){if(a.dryRun||e.size===0&&!a.clean)return;await K(a);let n=l(a.cwd,a.outdir);if(e.size===0&&!await w(n))return;let r=l(n,".dtsx-publication"),s=new Map;for(let[o,c]of e){let t=l(o);if(!M(o)||t===n||!v(t,n)||v(t,r)||!z(t))throw Error(`Invalid declaration publication target: ${o}`);if(s.has(t))throw Error(`Duplicate declaration publication target: ${o}`);s.set(t,c)}let p=[],T=[],I=[],b=!1,E,d,C=!1;async function h(o,c){let t=await g(m(o));if(!v(t,c))throw Error(`Declaration publication parent escapes outdir: ${o}`);if(v(t,l(c,".dtsx-publication")))throw Error(`Declaration publication target overlaps its transaction directory: ${o}`)}async function N(){if(!b)return;if(!E)throw Error(`Cannot verify declaration publication ownership: ${r}`);let o=await w(r);if(!o||!O(o,E))throw Error(`Declaration publication ownership changed: ${r}`);if(d&&await g(r)!==l(d,".dtsx-publication"))throw Error(`Declaration publication location changed: ${r}`);await R(r,{recursive:!0})}try{await x(n,p);try{await y(r)}catch(t){if(f(t,"EEXIST"))throw Error(`Declaration publication is active or requires recovery at ${r}`,{cause:t});throw t}b=!0,E=await S(r),d=await g(n);let o=new Map;if(a.clean)await X(n,r,o);for(let t of s.keys()){await h(t,d);let i=await w(t);if(i&&!i.isFile())throw Error(`Declaration publication target is not a regular file: ${t}`);if(i)o.set(t,i)}for(let t of o.keys())await h(t,d);await y(l(r,"staged")),await y(l(r,"backups"));let c=new Map;for(let t of new Set([...o.keys(),...s.keys()])){let i=c.size.toString();c.set(t,{path:t,existing:o.get(t),backup:l(r,"backups",i),staged:s.has(t)?l(r,"staged",i):void 0})}await W(l(r,"manifest.json"),JSON.stringify({version:1,outdir:n,targets:[...c.values()].map((t)=>({path:F(n,t.path),backup:F(r,t.backup),hadPrevious:!!t.existing}))}));for(let[t,i]of s){let u=c.get(t),D=u.staged;if(await _(D,i.content,i.lineEnding),!a.clean&&u.existing)await G(D,u.existing.mode&511);u.stagedIdentity=await S(D)}for(let t of c.values()){if(!t.existing)continue;await h(t.path,d);let i=await w(t.path);if(!i||!O(i,t.existing))throw Error(`Declaration output changed before commit: ${t.path}`);await k(t.path,t.backup),T.push(t)}for(let t of c.values()){if(!t.staged||!t.stagedIdentity)continue;if(await h(t.path,d),await x(m(t.path),p),await h(t.path,d),await w(t.path))throw Error(`Declaration output appeared during commit: ${t.path}`);await k(t.staged,t.path),I.push({path:t.path,identity:t.stagedIdentity})}C=!0;try{await N()}catch(t){throw P(`Declaration outputs committed, but transaction cleanup failed at ${r}`,[t],"finalize",r,!0)}}catch(o){if(C)throw o;let c=[];for(let i of I.toReversed())try{if(d)await h(i.path,d);let u=await w(i.path);if(!u)continue;if(!O(u,i.identity))throw Error(`Installed declaration changed before rollback: ${i.path}`);await R(i.path)}catch(u){c.push(u)}for(let i of T.toReversed())try{if(d)await h(i.path,d);if(await w(i.path))throw Error(`Cannot restore declaration over an existing path: ${i.path}`);await k(i.backup,i.path)}catch(u){c.push(u)}if(c.length>0)throw P(`Declaration rollback failed; recovery data retained at ${r}`,[o,...c],"rollback",r,!1);let t=[];try{await N()}catch(i){t.push(i)}for(let i of p.toReversed())try{await L(i)}catch(u){if(!f(u,"ENOENT")&&!f(u,"ENOTEMPTY")&&!f(u,"EEXIST"))t.push(u)}if(t.length>0)throw P(`Prior declarations retained, but publication cleanup failed at ${r}`,[o,...t],"cleanup",b?r:void 0,!1);throw o}}
|
|
3
|
+
export{K,pe};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{u,Te}from"./chunk-rdzfdjkb.js";import{Pt,Dt,n,ke,W}from"./chunk-90aptjh6.js";function h(t){if(t.includes(`
|
|
3
|
+
`))return`/**
|
|
4
|
+
* ${t}
|
|
5
|
+
*/
|
|
6
|
+
`;return`/** ${t} */
|
|
7
|
+
`}function D(t){let o=t.indexOf("{");if(o===-1)return-1;let s=t.indexOf("<");if(s===-1||s>o)return o;let e=0,r=!1,a="";for(let i=0;i<t.length;i++){let f=t[i],l=i>0?t[i-1]:"";if(!r&&(f==='"'||f==="'"||f==="`"))r=!0,a=f;else if(r&&f===a&&l!=="\\")r=!1;if(!r){if(f==="<")e++;else if(f===">")e--;else if(f==="{"&&e===0)return i}}return-1}function X(t,o=!0){return u(t.leadingComments,o)+t.text}function g(t,o=!0){if(t.inferenceError)throw Object.assign(Error(`Cannot infer alias '${t.name}': unsupported source value flow`),{code:t.inferenceError});let s=u(t.leadingComments,o);if(!t.typeAnnotation&&t.inferredType)return s+t.text;if(t.typeAnnotation&&!t.value)return s+t.text;let e="";if(t.isExported)e+="export ";e+="declare ";let r=t.modifiers?.[0]||"const";e+=`${r} `,e+=t.name;let{typeAnnotation:a,value:i}=t,f=!a&&i?W(i):null;if(f)a=f;else if(!a&&i&&i.trim().endsWith("as const"))a=n(i,!0,!1,0,t.computedKeyConstants);else if(!a&&i&&r==="const"){let c=i.trim(),m=c.startsWith("{")||c.startsWith("[");if(m)Pt();a=n(i,!m,!1,0,t.computedKeyConstants)}else if(!a&&i)a=n(i,r==="const",!1,0,t.computedKeyConstants);if(!a)a="unknown";let l="";if(o&&i&&!t.typeAnnotation&&!i.trim().endsWith("as const")){let c=i.trim();if(r!=="const"){if((a==="string"||a==="number"||a==="boolean")&&c.length>0)l=`@defaultValue ${c}`}else if(c.startsWith("{")||c.startsWith("[")){let m=Dt();if(m)if(m.includes(`
|
|
8
|
+
`))l=`@defaultValue
|
|
9
|
+
* \`\`\`ts
|
|
10
|
+
${m.split(`
|
|
11
|
+
`).map((p)=>` * ${p}`).join(`
|
|
12
|
+
`)}
|
|
13
|
+
* \`\`\``;else l=`@defaultValue \`${m}\``}}else if(o&&i&&t.typeAnnotation&&ke(t.typeAnnotation)){Pt();let c=i.trim(),m=c.endsWith("as const")?c.slice(0,-8).trim():c;n(m,!1,!1,0,t.computedKeyConstants);let x=Dt();if(x)if(x.includes(`
|
|
14
|
+
`))l=`@defaultValue
|
|
15
|
+
* \`\`\`ts
|
|
16
|
+
${x.split(`
|
|
17
|
+
`).map((d)=>` * ${d}`).join(`
|
|
18
|
+
`)}
|
|
19
|
+
* \`\`\``;else l=`@defaultValue \`${x}\``}if(l=Te(l),e+=`: ${a};`,l&&s&&s.includes("@defaultValue"))l="";if(l&&s){let c=s.trimEnd(),m=c.lastIndexOf("*/");if(m!==-1){let p=c.slice(0,m).trimEnd();if(p.startsWith("/** ")&&!p.includes(`
|
|
20
|
+
`))p=`/**
|
|
21
|
+
* ${p.slice(4)}`;return`${p}
|
|
22
|
+
* ${l}
|
|
23
|
+
*/
|
|
24
|
+
`+e}return`/**
|
|
25
|
+
* ${c.replace(/^\/\/\s*/,"")}
|
|
26
|
+
* ${l}
|
|
27
|
+
*/
|
|
28
|
+
${e}`}if(l)return`${h(l)}${e}`;return s+e}function Z(t,o=!0){let s=u(t.leadingComments,o),e=t.text;if(e.startsWith("export declare interface")||e.startsWith("declare interface"))return s+e;let r="";if(t.isExported)r+="export ";if(r+="declare interface ",r+=t.name,t.generics)r+=t.generics;if(t.extends)r+=` extends ${t.extends}`;let a=D(t.text);if(a!==-1)r+=` ${t.text.slice(a)}`;else r+=" {}";return s+r}function Q(t,o=!0){let s=u(t.leadingComments,o);if(t.text.includes("{")&&t.text.includes("}")&&t.text.includes("from"))return s+t.text;let e="";if(t.isExported)e+="export ";if(!t.isExported&&!t.text.includes(" from "))e+="declare ";let r=t.text.indexOf("type ");if(r!==-1){let i=t.text.slice(r),f=i.length;while(f>0&&(i.charCodeAt(f-1)===59||i.charCodeAt(f-1)===32||i.charCodeAt(f-1)===10||i.charCodeAt(f-1)===13))f--;if(f<i.length)i=i.slice(0,f);e+=i}else{if(e+=`type ${t.name}`,t.generics)e+=t.generics;e+=" = any"}let a=e.trimEnd();if(!a.endsWith(";")&&!a.endsWith("}"))e+=";";return s+e}function ee(t,o=!0){return u(t.leadingComments,o)+t.text}function te(t,o=!0){let s=u(t.leadingComments,o),e="";if(t.isExported)e+="export ";if(e+="declare ",t.modifiers?.includes("const"))e+="const ";e+="enum ",e+=t.name;let r=t.text.indexOf("{");if(r!==-1)e+=` ${t.text.slice(r)}`;else e+=" {}";return s+e}function Dn(t){let o=t.text.trim(),s=o.length;while(s>0&&o.charCodeAt(s-1)===59)s--;if(s<o.length)o=o.slice(0,s);return o+=";",o}function Rn(t,o=!0){return u(t.leadingComments,o)+t.text.trim()}function ne(t,o=!0){let s=u(t.leadingComments,o);if(t.text.startsWith("declare global"))return s+t.text;if(t.source||(t.name.startsWith('"')||t.name.startsWith("'")||t.name.startsWith("`"))){let i="declare module ";i+=t.name;let f=t.text.indexOf("{");if(f!==-1)i+=` ${t.text.slice(f)}`;else i+=" {}";return s+i}let r="";if(t.isExported)r+="export ";if(!t.modifiers?.includes("declare"))r+="declare ";r+="namespace ",r+=t.name;let a=t.text.indexOf("{");if(a!==-1)r+=` ${t.text.slice(a)}`;else r+=" {}";return s+r}
|
|
29
|
+
export{X,g,Z,Q,ee,te,Dn,Rn,ne};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
function p(r,t){let e=r.trim();if(e==="string")return{type:"string"};if(e==="number")return{type:"number"};if(e==="boolean")return{type:"boolean"};if(e==="null")return{type:"null"};if(e==="undefined")return{type:"null"};if(e==="any"||e==="unknown")return{};if(e==="never")return{not:{}};if(e==="void")return{type:"null"};if(e==="bigint")return{type:"integer"};if(e==="symbol")return{type:"string",description:"Symbol type"};if(e==="object")return{type:"object"};if(e.startsWith("'")||e.startsWith('"'))return{const:e.slice(1,-1)};if(/^-?\d+(\.\d+)?$/.test(e))return{const:Number.parseFloat(e)};if(e==="true")return{const:!0};if(e==="false")return{const:!1};let n=e.match(/^(.+)\[\]$/)||e.match(/^Array<(.+)>$/i);if(n)return{type:"array",items:p(n[1],t)};let i=e.match(/^\[(.+)\]$/);if(i){let f=l(i[1],",").map((d)=>p(d.trim(),t));return{type:"array",items:f,minItems:f.length,maxItems:f.length}}if(e.includes("|")){let f=l(e,"|");if(f.length>1){let d=f.filter((a)=>a.trim()!=="null"&&a.trim()!=="undefined");if(f.some((a)=>a.trim()==="null"||a.trim()==="undefined")&&d.length===1){let a=p(d[0],t);if(a.type&&typeof a.type==="string")return{...a,type:[a.type,"null"]};return{oneOf:[a,{type:"null"}]}}return{oneOf:f.map((a)=>p(a.trim(),t))}}}if(e.includes("&")){let f=l(e,"&");if(f.length>1)return{allOf:f.map((d)=>p(d.trim(),t))}}let s=e.match(/^Record<(.+),\s*(.+)>$/i);if(s)return{type:"object",additionalProperties:p(s[2],t)};let o=e.match(/^Promise<(.+)>$/i);if(o)return p(o[1],t);let u=e.match(/^Partial<(.+)>$/i);if(u)return{...p(u[1],t),required:[]};let h=e.match(/^Required<(.+)>$/i);if(h)return p(h[1],t);let c=e.match(/^Readonly<(.+)>$/i);if(c)return p(c[1],t);let y=e.match(/^Pick<(.+),\s*(.+)>$/i);if(y)return p(y[1],t);let b=e.match(/^Omit<(.+),\s*(.+)>$/i);if(b)return p(b[1],t);if(e==="Date")return{type:"string",format:"date-time"};if(/^[A-Z]\w*$/.test(e))return{$ref:`#/$defs/${e}`};return{type:"object"}}function Lr(r,t={}){let e=t.indent??2,n=t.jsonSchemaDraft??"2020-12",i={"2020-12":"https://json-schema.org/draft/2020-12/schema","2019-09":"https://json-schema.org/draft/2019-09/schema","draft-07":"http://json-schema.org/draft-07/schema#"}[n],s=new Map,o={$schema:t.includeSchema!==!1?i:void 0,$defs:{}};for(let u of r)if(u.kind==="interface"||u.kind==="type"){let h=N(u,s,t);if(o.$defs)o.$defs[u.name]=h}if(o.$defs&&Object.keys(o.$defs).length===1){let[u,h]=Object.entries(o.$defs)[0];return JSON.stringify({$schema:o.$schema,title:u,...h},null,e)}return JSON.stringify(o,null,e)}function N(r,t,e){let n={type:"object"};if(e.includeDescriptions&&r.leadingComments?.length){let i=v(r.leadingComments);if(i)n.description=i}if(r.members&&r.members.length>0){n.properties={},n.required=[];for(let i of r.members)if(i.name&&i.typeAnnotation){let s=p(i.typeAnnotation,t);if(e.includeDescriptions&&i.leadingComments?.length){let u=v(i.leadingComments);if(u)s.description=u}if(n.properties[i.name]=s,!(i.modifiers?.includes("?")||i.text?.includes("?:")||e.allOptional))n.required.push(i.name)}if(n.required.length===0)delete n.required}else if(r.typeAnnotation)return p(r.typeAnnotation,t);return n}function Nr(r,t={}){let e=["import { z } from 'zod'",""];for(let n of r)if(n.kind==="interface"||n.kind==="type"){let i=t.exportName||`${n.name}Schema`,s=x(n,t);if(e.push(`export const ${i} = ${s}`),e.push(""),t.useInfer!==!1)e.push(`export type ${n.name} = z.infer<typeof ${i}>`),e.push("")}return e.join(`
|
|
3
|
+
`)}function x(r,t){if(r.members&&r.members.length>0)return`z.object({
|
|
4
|
+
${r.members.filter((n)=>n.name&&n.typeAnnotation).map((n)=>{let i=m(n.typeAnnotation);if(n.modifiers?.includes("?")||n.text?.includes("?:")||t.allOptional)i=`${i}.optional()`;if(t.includeDescriptions&&n.leadingComments?.length){let o=v(n.leadingComments);if(o)i=`${i}.describe(${JSON.stringify(o)})`}return` ${n.name}: ${i}`}).join(`,
|
|
5
|
+
`)}
|
|
6
|
+
})`;if(r.typeAnnotation)return m(r.typeAnnotation);return"z.unknown()"}function m(r){let t=r.trim();if(t==="string")return"z.string()";if(t==="number")return"z.number()";if(t==="boolean")return"z.boolean()";if(t==="null")return"z.null()";if(t==="undefined")return"z.undefined()";if(t==="any")return"z.any()";if(t==="unknown")return"z.unknown()";if(t==="never")return"z.never()";if(t==="void")return"z.void()";if(t==="bigint")return"z.bigint()";if(t==="symbol")return"z.symbol()";if(t==="Date")return"z.date()";if(t.startsWith("'")||t.startsWith('"'))return`z.literal(${t})`;if(/^-?\d+(\.\d+)?$/.test(t))return`z.literal(${t})`;if(t==="true"||t==="false")return`z.literal(${t})`;let e=t.match(/^(.+)\[\]$/)||t.match(/^Array<(.+)>$/i);if(e)return`z.array(${m(e[1])})`;let n=t.match(/^\[(.+)\]$/);if(n)return`z.tuple([${l(n[1],",").map((b)=>m(b.trim())).join(", ")}])`;if(t.includes("|")){let y=l(t,"|");if(y.length>1){let b=y.filter((a)=>a.trim()!=="null"&&a.trim()!=="undefined"),f=y.some((a)=>a.trim()==="null"),d=y.some((a)=>a.trim()==="undefined");if((f||d)&&b.length===1){let a=m(b[0]);if(f)a=`${a}.nullable()`;if(d)a=`${a}.optional()`;return a}return`z.union([${y.map((a)=>m(a.trim())).join(", ")}])`}}if(t.includes("&")){let y=l(t,"&");if(y.length>1)return y.map((f)=>m(f.trim())).reduce((f,d)=>`${f}.and(${d})`)}let i=t.match(/^Record<(.+),\s*(.+)>$/i);if(i)return`z.record(${m(i[1])}, ${m(i[2])})`;let s=t.match(/^Promise<(.+)>$/i);if(s)return`z.promise(${m(s[1])})`;let o=t.match(/^Map<(.+),\s*(.+)>$/i);if(o)return`z.map(${m(o[1])}, ${m(o[2])})`;let u=t.match(/^Set<(.+)>$/i);if(u)return`z.set(${m(u[1])})`;let h=t.match(/^Partial<(.+)>$/i);if(h)return`${m(h[1])}.partial()`;let c=t.match(/^Required<(.+)>$/i);if(c)return`${m(c[1])}.required()`;if(/^[A-Z]\w*$/.test(t))return`${t}Schema`;return"z.unknown()"}function Br(r,t={}){let e=["import * as v from 'valibot'",""];for(let n of r)if(n.kind==="interface"||n.kind==="type"){let i=t.exportName||`${n.name}Schema`,s=j(n,t);if(e.push(`export const ${i} = ${s}`),e.push(""),t.useInfer!==!1)e.push(`export type ${n.name} = v.InferOutput<typeof ${i}>`),e.push("")}return e.join(`
|
|
7
|
+
`)}function j(r,t){if(r.members&&r.members.length>0)return`v.object({
|
|
8
|
+
${r.members.filter((n)=>n.name&&n.typeAnnotation).map((n)=>{let i=g(n.typeAnnotation);if(n.modifiers?.includes("?")||n.text?.includes("?:")||t.allOptional)i=`v.optional(${i})`;return` ${n.name}: ${i}`}).join(`,
|
|
9
|
+
`)}
|
|
10
|
+
})`;if(r.typeAnnotation)return g(r.typeAnnotation);return"v.unknown()"}function g(r){let t=r.trim();if(t==="string")return"v.string()";if(t==="number")return"v.number()";if(t==="boolean")return"v.boolean()";if(t==="null")return"v.null_()";if(t==="undefined")return"v.undefined_()";if(t==="any")return"v.any()";if(t==="unknown")return"v.unknown()";if(t==="never")return"v.never()";if(t==="void")return"v.void_()";if(t==="bigint")return"v.bigint()";if(t==="symbol")return"v.symbol()";if(t==="Date")return"v.date()";if(t.startsWith("'")||t.startsWith('"'))return`v.literal(${t})`;if(/^-?\d+(\.\d+)?$/.test(t))return`v.literal(${t})`;if(t==="true"||t==="false")return`v.literal(${t})`;let e=t.match(/^(.+)\[\]$/)||t.match(/^Array<(.+)>$/i);if(e)return`v.array(${g(e[1])})`;let n=t.match(/^\[(.+)\]$/);if(n)return`v.tuple([${l(n[1],",").map((o)=>g(o.trim())).join(", ")}])`;if(t.includes("|")){let s=l(t,"|");if(s.length>1){let o=s.filter((c)=>c.trim()!=="null"&&c.trim()!=="undefined"),u=s.some((c)=>c.trim()==="null"),h=s.some((c)=>c.trim()==="undefined");if((u||h)&&o.length===1){let c=g(o[0]);if(u)c=`v.nullable(${c})`;if(h)c=`v.optional(${c})`;return c}return`v.union([${s.map((c)=>g(c.trim())).join(", ")}])`}}if(t.includes("&")){let s=l(t,"&");if(s.length>1)return`v.intersect([${s.map((o)=>g(o.trim())).join(", ")}])`}let i=t.match(/^Record<(.+),\s*(.+)>$/i);if(i)return`v.record(${g(i[1])}, ${g(i[2])})`;if(/^[A-Z]\w*$/.test(t))return`${t}Schema`;return"v.unknown()"}function Wr(r,t={}){let e=["import * as t from 'io-ts'",""];for(let n of r)if(n.kind==="interface"||n.kind==="type"){let i=t.exportName||`${n.name}Codec`,s=A(n,t);if(e.push(`export const ${i} = ${s}`),e.push(""),t.useInfer!==!1)e.push(`export type ${n.name} = t.TypeOf<typeof ${i}>`),e.push("")}return e.join(`
|
|
11
|
+
`)}function A(r,t){if(r.members&&r.members.length>0){let e=[],n=[];for(let i of r.members){if(!i.name||!i.typeAnnotation)continue;let s=O(i.typeAnnotation),o=i.modifiers?.includes("?")||i.text?.includes("?:")||t.allOptional,u=` ${i.name}: ${s}`;if(o)n.push(u);else e.push(u)}if(n.length>0)return`t.intersection([
|
|
12
|
+
t.type({
|
|
13
|
+
${e.join(`,
|
|
14
|
+
`)}
|
|
15
|
+
}),
|
|
16
|
+
t.partial({
|
|
17
|
+
${n.join(`,
|
|
18
|
+
`)}
|
|
19
|
+
})
|
|
20
|
+
])`;return`t.type({
|
|
21
|
+
${e.join(`,
|
|
22
|
+
`)}
|
|
23
|
+
})`}if(r.typeAnnotation)return O(r.typeAnnotation);return"t.unknown"}function O(r){let t=r.trim();if(t==="string")return"t.string";if(t==="number")return"t.number";if(t==="boolean")return"t.boolean";if(t==="null")return"t.null";if(t==="undefined")return"t.undefined";if(t==="any")return"t.unknown";if(t==="unknown")return"t.unknown";if(t==="never")return"t.never";if(t==="void")return"t.void";if(t.startsWith("'")||t.startsWith('"'))return`t.literal(${t})`;if(/^-?\d+(\.\d+)?$/.test(t))return`t.literal(${t})`;if(t==="true"||t==="false")return`t.literal(${t})`;let e=t.match(/^(.+)\[\]$/)||t.match(/^Array<(.+)>$/i);if(e)return`t.array(${O(e[1])})`;let n=t.match(/^\[(.+)\]$/);if(n)return`t.tuple([${l(n[1],",").map((o)=>O(o.trim())).join(", ")}])`;if(t.includes("|")){let s=l(t,"|");if(s.length>1)return`t.union([${s.map((o)=>O(o.trim())).join(", ")}])`}if(t.includes("&")){let s=l(t,"&");if(s.length>1)return`t.intersection([${s.map((o)=>O(o.trim())).join(", ")}])`}let i=t.match(/^Record<(.+),\s*(.+)>$/i);if(i)return`t.record(${O(i[1])}, ${O(i[2])})`;if(/^[A-Z]\w*$/.test(t))return`${t}Codec`;return"t.unknown"}function jr(r,t={}){let e=["import * as yup from 'yup'",""];for(let n of r)if(n.kind==="interface"||n.kind==="type"){let i=t.exportName||`${n.name}Schema`,s=z(n,t);if(e.push(`export const ${i} = ${s}`),e.push(""),t.useInfer!==!1)e.push(`export type ${n.name} = yup.InferType<typeof ${i}>`),e.push("")}return e.join(`
|
|
24
|
+
`)}function z(r,t){if(r.members&&r.members.length>0)return`yup.object({
|
|
25
|
+
${r.members.filter((n)=>n.name&&n.typeAnnotation).map((n)=>{let i=T(n.typeAnnotation);if(!(n.modifiers?.includes("?")||n.text?.includes("?:")||t.allOptional))i=`${i}.required()`;return` ${n.name}: ${i}`}).join(`,
|
|
26
|
+
`)}
|
|
27
|
+
})`;if(r.typeAnnotation)return T(r.typeAnnotation);return"yup.mixed()"}function T(r){let t=r.trim();if(t==="string")return"yup.string()";if(t==="number")return"yup.number()";if(t==="boolean")return"yup.boolean()";if(t==="Date")return"yup.date()";if(t==="any"||t==="unknown")return"yup.mixed()";let e=t.match(/^(.+)\[\]$/)||t.match(/^Array<(.+)>$/i);if(e)return`yup.array().of(${T(e[1])})`;if(t.includes("|")){let n=l(t,"|");if(n.length>1){let i=n.filter((o)=>o.trim()!=="null"&&o.trim()!=="undefined");if(n.some((o)=>o.trim()==="null"||o.trim()==="undefined")&&i.length===1)return`${T(i[0])}.nullable()`}}if(/^[A-Z]\w*$/.test(t))return`${t}Schema`;return"yup.mixed()"}function _r(r,t={}){let e=["import { type } from 'arktype'",""];for(let n of r)if(n.kind==="interface"||n.kind==="type"){let i=t.exportName||n.name,s=w(n,t);if(e.push(`export const ${i} = ${s}`),e.push(""),t.useInfer!==!1)e.push(`export type ${n.name}Type = typeof ${i}.infer`),e.push("")}return e.join(`
|
|
28
|
+
`)}function w(r,t){if(r.members&&r.members.length>0)return`type({
|
|
29
|
+
${r.members.filter((n)=>n.name&&n.typeAnnotation).map((n)=>{let i=S(n.typeAnnotation);return` ${n.modifiers?.includes("?")||n.text?.includes("?:")||t.allOptional?`'${n.name}?'`:`${n.name}`}: ${i}`}).join(`,
|
|
30
|
+
`)}
|
|
31
|
+
})`;if(r.typeAnnotation)return`type(${S(r.typeAnnotation)})`;return"type('unknown')"}function S(r){let t=r.trim();if(t==="string")return"'string'";if(t==="number")return"'number'";if(t==="boolean")return"'boolean'";if(t==="null")return"'null'";if(t==="undefined")return"'undefined'";if(t==="bigint")return"'bigint'";if(t==="symbol")return"'symbol'";if(t==="Date")return"'Date'";if(t==="any"||t==="unknown")return"'unknown'";let e=t.match(/^(.+)\[\]$/)||t.match(/^Array<(.+)>$/i);if(e)return`${S(e[1])}.array()`;if(t.includes("|")){let n=l(t,"|");if(n.length>1)return`'${n.map((i)=>i.trim()).join(" | ")}'`}if(t.startsWith("'")||t.startsWith('"'))return`'${t}'`;return`'${t}'`}function l(r,t){let e=[],n="",i=0;for(let s=0;s<r.length;s++){let o=r[s];if(o==="<"||o==="("||o==="["||o==="{")i++,n+=o;else if(o===">"||o===")"||o==="]"||o==="}")i--,n+=o;else if(i===0&&r.slice(s,s+t.length)===t)e.push(n.trim()),n="",s+=t.length-1;else n+=o}if(n.trim())e.push(n.trim());return e}function v(r){for(let t of r){let e=t.replace(/^\/\*\*|\*\/$/g,"").replace(/^\s*\*\s?/gm,"").replace(/@\w.*/g,"").trim();if(e)return e}return null}function Ks(r,t){switch(t.format){case"json-schema":return Lr(r,t);case"zod":return Nr(r,t);case"valibot":return Br(r,t);case"io-ts":return Wr(r,t);case"yup":return jr(r,t);case"arktype":return _r(r,t);case"dts":default:return r.map((e)=>e.text).join(`
|
|
32
|
+
|
|
33
|
+
`)}}function qs(r){switch(r){case"json-schema":return".schema.json";case"zod":case"valibot":case"io-ts":case"yup":case"arktype":return".schema.ts";case"dts":default:return".d.ts"}}
|
|
34
|
+
export{Lr,Nr,Br,Wr,jr,_r,Ks,qs};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{s}from"./chunk-0azm93j9.js";function le(d={}){let{onBuildStart:u=!1,onBuildEnd:f=!0,onGenerated:l,onError:i,...c}=d,o,r,e=async()=>{let t={...c};if(!t.outdir&&o)t.outdir=o;if(!t.entrypoints&&r)t.entrypoints=r;try{let n=await s(t);l?.(n)}catch(n){let a=n instanceof Error?n:Error(String(n));if(i?.(a),!i)console.error("[dtsx] Generation failed:",a.message)}};return{name:"dtsx",esbuildOptions(t){if(t.outdir&&typeof t.outdir==="string")o=t.outdir;if(t.entryPoints){if(Array.isArray(t.entryPoints))r=t.entryPoints;else if(typeof t.entryPoints==="object")r=Object.values(t.entryPoints)}},async buildStart(){if(u)await e()},async buildEnd(t){if(f)await e()}}}var ma=le,Yn=le,ga=le;
|
|
3
|
+
export{le,ma,Yn,ga};
|