@dtsx/dtsx 0.11.45 → 0.11.46
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/dist/bin/cli.js +1 -1
- package/dist/{chunk-t88j01sz.js → chunk-013mp499.js} +2 -2
- package/dist/{chunk-hzy5z7x2.js → chunk-0af0hsfc.js} +2 -2
- package/dist/{chunk-qab5rsk8.js → chunk-0gwj2fct.js} +6 -6
- package/dist/{chunk-2cjs4r5v.js → chunk-0kvy1dh8.js} +4 -4
- package/dist/{chunk-t1js8enq.js → chunk-0nw1w523.js} +3 -3
- package/dist/{chunk-8xpkce3g.js → chunk-1xgcs6aq.js} +4 -4
- package/dist/{chunk-ybdp7k49.js → chunk-1y19tmb0.js} +3 -3
- package/dist/{chunk-f3avgz4y.js → chunk-1z9550gn.js} +8 -8
- package/dist/{chunk-8c5dzvwk.js → chunk-290jpwny.js} +3 -3
- package/dist/{chunk-jy5h728q.js → chunk-2h5p8n7w.js} +2 -2
- package/dist/{chunk-9knxvphg.js → chunk-2wxgt73q.js} +3 -3
- package/dist/{chunk-qkesb95f.js → chunk-2xp48sa2.js} +2 -2
- package/dist/{chunk-z82jsz2r.js → chunk-4kn7y9ns.js} +3 -3
- package/dist/{chunk-8zr7m1pk.js → chunk-4mrq1jdn.js} +2 -2
- package/dist/{chunk-4fspqk22.js → chunk-5cgpcdsb.js} +3 -3
- package/dist/{chunk-vher6t7j.js → chunk-6bmr0e81.js} +5 -5
- package/dist/{chunk-b7azvfdn.js → chunk-6m8f0y7w.js} +2 -2
- package/dist/{chunk-grpmcw9x.js → chunk-8ab8793q.js} +11 -11
- package/dist/{chunk-755bntty.js → chunk-8gksa73c.js} +3 -3
- package/dist/{chunk-xhgs3gx2.js → chunk-8qpzh9yc.js} +3 -3
- package/dist/{chunk-s013113f.js → chunk-986k5306.js} +2 -2
- package/dist/{chunk-zwcvtbt4.js → chunk-9kfzjkd1.js} +10 -10
- package/dist/{chunk-b3979d26.js → chunk-a0900w7b.js} +2 -2
- package/dist/{chunk-kthga8ar.js → chunk-a8djrg2n.js} +3 -3
- package/dist/{chunk-e9x8ywhv.js → chunk-ac95p5v4.js} +4 -4
- package/dist/{chunk-57xvwm7c.js → chunk-c7dw612y.js} +2 -2
- package/dist/{chunk-zb48dx6a.js → chunk-dhzr60ge.js} +2 -2
- package/dist/{chunk-r2e0r0pd.js → chunk-dpd2b7dd.js} +2 -2
- package/dist/{chunk-m8rvd58d.js → chunk-dw84pjmf.js} +4 -4
- package/dist/{chunk-fkdq1x5f.js → chunk-ehpz5rg3.js} +10 -10
- package/dist/{chunk-4t1we2h5.js → chunk-em9pz9s0.js} +2 -2
- package/dist/{chunk-d5q4qfys.js → chunk-g2191y9b.js} +4 -4
- package/dist/{chunk-bv1q1w42.js → chunk-g9kqk7y0.js} +4 -4
- package/dist/{chunk-1gy2z5an.js → chunk-ga769zw5.js} +5 -5
- package/dist/{chunk-48jvmndg.js → chunk-gqk2s9wt.js} +2 -2
- package/dist/{chunk-qj2yvdjn.js → chunk-gsvb5wey.js} +2 -2
- package/dist/{chunk-x9vpsya2.js → chunk-h7tsf2qg.js} +21 -21
- package/dist/{chunk-nfd9v8ba.js → chunk-hbe5sg17.js} +2 -2
- package/dist/{chunk-41d5ehn0.js → chunk-hcf0hd85.js} +1 -1
- package/dist/{chunk-gns23mhj.js → chunk-j0y149qx.js} +2 -2
- package/dist/{chunk-t76htvct.js → chunk-j32xn94r.js} +2 -2
- package/dist/{chunk-s6t0ff96.js → chunk-jtq24yb8.js} +2 -2
- package/dist/{chunk-c94sk67h.js → chunk-jwcw24cc.js} +4 -4
- package/dist/{chunk-wwjt0p6m.js → chunk-k0exaspt.js} +3 -3
- package/dist/{chunk-xtckj8w1.js → chunk-k472ve44.js} +2 -2
- package/dist/{chunk-y9bxeq10.js → chunk-k75z3nef.js} +2 -2
- package/dist/chunk-kcbbz8t7.js +37 -0
- package/dist/{chunk-exf6bsbe.js → chunk-kcfc6zg6.js} +1 -1
- package/dist/{chunk-55yw66ha.js → chunk-kdqckf54.js} +3 -3
- package/dist/{chunk-vrfp12ts.js → chunk-kp6qv2fb.js} +2 -2
- package/dist/{chunk-gwsjj23d.js → chunk-ktt2m4eh.js} +3 -3
- package/dist/{chunk-05cbfytc.js → chunk-nmjxxcvg.js} +3 -3
- package/dist/{chunk-783erq83.js → chunk-nxqap7nx.js} +4 -4
- package/dist/{chunk-4vtfqwpq.js → chunk-pjqd38w1.js} +2 -2
- package/dist/{chunk-870p7sky.js → chunk-pp9aevcb.js} +2 -2
- package/dist/{chunk-x5z8vprh.js → chunk-qmg1535a.js} +2 -2
- package/dist/{chunk-cd27mg71.js → chunk-rdb7j1d6.js} +2 -2
- package/dist/{chunk-vye45h9n.js → chunk-rkpwmkrm.js} +2 -2
- package/dist/{chunk-mc9kwthm.js → chunk-rnvqc8st.js} +2 -2
- package/dist/{chunk-6gvctv0q.js → chunk-rwdcmcx3.js} +3 -3
- package/dist/{chunk-7x4eqjfw.js → chunk-ry1c863d.js} +2 -2
- package/dist/{chunk-pydpyx8x.js → chunk-s9e2a0t7.js} +2 -2
- package/dist/{chunk-t73v233w.js → chunk-swmftav9.js} +4 -4
- package/dist/chunk-t03y036d.js +3 -0
- package/dist/{chunk-m14550z9.js → chunk-t7jvkq9j.js} +2 -2
- package/dist/{chunk-3x19egjd.js → chunk-t89jepjk.js} +2 -2
- package/dist/{chunk-51vf9de8.js → chunk-thzkm86y.js} +2 -2
- package/dist/{chunk-k0vthrqs.js → chunk-trvp818c.js} +1 -1
- package/dist/{chunk-j51p30sb.js → chunk-tsbthwf0.js} +3 -3
- package/dist/chunk-v4z6808c.js +3 -0
- package/dist/{chunk-3nmjt94q.js → chunk-vdhzc40m.js} +3 -3
- package/dist/{chunk-m29ph3cg.js → chunk-wrjrwren.js} +1 -1
- package/dist/{chunk-yh04e0n4.js → chunk-xg8yhpe6.js} +2 -2
- package/dist/{chunk-a4791583.js → chunk-xm63aee8.js} +2 -2
- package/dist/chunk-y1xq2hm4.js +3 -0
- package/dist/{chunk-8c8pgvxv.js → chunk-yaej6q2v.js} +1 -1
- package/dist/{chunk-f191378r.js → chunk-yapmefw7.js} +3 -3
- package/dist/{chunk-mvxcxnff.js → chunk-z0aa0gd8.js} +2 -2
- package/dist/{chunk-xvk9v148.js → chunk-zaka2jk1.js} +2 -2
- package/dist/src/augmentation-graph.js +1 -1
- package/dist/src/binding-patterns.js +1 -1
- package/dist/src/branded-types.js +1 -1
- package/dist/src/bundle-linker.js +1 -1
- package/dist/src/bundler.js +1 -1
- package/dist/src/cache.js +1 -1
- package/dist/src/call-signatures.js +1 -1
- package/dist/src/circular.js +1 -1
- package/dist/src/compat.d.ts +0 -29
- package/dist/src/compat.js +1 -1
- package/dist/src/computed-keys.js +1 -1
- package/dist/src/config.js +1 -1
- package/dist/src/dangling-refs.js +1 -1
- package/dist/src/declaration-project.js +1 -1
- package/dist/src/declaration-publication.js +1 -1
- package/dist/src/declaration-references.js +1 -1
- package/dist/src/diff.js +1 -1
- package/dist/src/docs.js +1 -1
- package/dist/src/enum-declarations.js +1 -1
- package/dist/src/errors.js +1 -1
- package/dist/src/extractor/directives.js +1 -1
- package/dist/src/extractor/extract.js +1 -1
- package/dist/src/extractor/scanner.d.ts +0 -13
- package/dist/src/extractor/scanner.js +1 -1
- package/dist/src/extractor.js +1 -1
- package/dist/src/formats.js +1 -1
- package/dist/src/formatter.js +1 -1
- package/dist/src/function-properties.js +1 -1
- package/dist/src/generator.js +1 -1
- package/dist/src/global-types.js +1 -1
- package/dist/src/import-sorter.js +1 -1
- package/dist/src/incremental.js +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/inferred-imports.js +1 -1
- package/dist/src/initializer-type-spans.js +1 -1
- package/dist/src/lexical.js +1 -1
- package/dist/src/logger.js +1 -1
- package/dist/src/lsp.js +1 -1
- package/dist/src/memory.js +1 -1
- package/dist/src/merger.js +1 -1
- package/dist/src/module-graph.js +1 -1
- package/dist/src/module-references.js +1 -1
- package/dist/src/native-checker.js +1 -1
- package/dist/src/native-engine.js +1 -1
- package/dist/src/native-extractor.js +1 -1
- package/dist/src/native-generation.js +1 -1
- package/dist/src/native-project.js +1 -1
- package/dist/src/numeric-literals.js +1 -1
- package/dist/src/optimizer.d.ts +0 -14
- package/dist/src/optimizer.js +1 -1
- package/dist/src/output-normalizer.js +1 -1
- package/dist/src/parallel-processor.js +1 -1
- package/dist/src/parameters.js +1 -1
- package/dist/src/parser.js +1 -1
- package/dist/src/plugins/bun.js +1 -1
- package/dist/src/plugins/esbuild.js +1 -1
- package/dist/src/plugins/index.js +1 -1
- package/dist/src/plugins/tsdown.js +1 -1
- package/dist/src/plugins/tsup.js +1 -1
- package/dist/src/plugins/vite.js +1 -1
- package/dist/src/plugins/webpack.js +1 -1
- package/dist/src/plugins.js +1 -1
- package/dist/src/process-source.js +1 -1
- package/dist/src/processor/cache.js +1 -1
- package/dist/src/processor/declarations.js +1 -1
- package/dist/src/processor/import-usage.js +1 -1
- package/dist/src/processor/imports.js +1 -1
- package/dist/src/processor/index.js +1 -1
- package/dist/src/processor/type-inference.d.ts +4 -0
- package/dist/src/processor/type-inference.js +1 -1
- package/dist/src/processor.js +1 -1
- package/dist/src/profiling.js +1 -1
- package/dist/src/return-type-scope.js +1 -1
- package/dist/src/security.js +1 -1
- package/dist/src/source-cache.js +1 -1
- package/dist/src/sourcemap.js +1 -1
- package/dist/src/stx.js +1 -1
- package/dist/src/tracking.js +1 -1
- package/dist/src/transformers.js +1 -1
- package/dist/src/tree-shaker.js +1 -1
- package/dist/src/type-mappings.js +1 -1
- package/dist/src/utils.js +1 -1
- package/dist/src/value-inference.js +1 -1
- package/dist/src/vue.js +1 -1
- package/dist/src/watcher.js +1 -1
- package/dist/src/worker-thread.js +1 -1
- package/dist/src/worker.js +1 -1
- package/dist/src/workspace.js +1 -1
- 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 +1 -1
- package/dist/chunk-83w2qbmb.js +0 -3
- package/dist/chunk-hvt855ms.js +0 -3
- package/dist/chunk-sqa3ke1a.js +0 -3
- package/dist/chunk-zmnb3yg1.js +0 -37
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{e}from"./chunk-
|
|
2
|
+
import{e}from"./chunk-qmg1535a.js";import{existsSync as h}from"fs";import{cpus as u}from"os";import{resolve as l}from"path";import{fileURLToPath as k}from"url";import{Worker as c}from"worker_threads";var __dirname="/home/runner/work/dtsx/dtsx/packages/dtsx/src",a;function f(){if(a!==void 0)return a;a=null;for(let t of["./worker-thread.js","./worker-thread.ts","./src/worker-thread.js","./src/worker-thread.ts"]){let r=new URL(t,import.meta.url);try{if(h(k(r))){a=r;break}}catch{}}return a}class Jt{workers=[];taskQueue=[];config;stats={totalTasks:0,completedTasks:0,failedTasks:0,averageDuration:0,activeWorkers:0,idleWorkers:0};isShuttingDown=!1;idleCheckInterval=null;constructor(t={}){let r=t.maxWorkers??Math.max(1,u().length-1);this.config={maxWorkers:r,taskTimeout:t.taskTimeout??30000,recycleAfter:t.recycleAfter??100,idleTimeout:t.idleTimeout??1e4,initialWorkers:t.initialWorkers??Math.min(2,r)}}async init(){let t=Math.min(this.config.initialWorkers,this.config.maxWorkers);for(let r=0;r<t;r++)this.createWorker();if(this.config.idleTimeout>0){if(this.idleCheckInterval=setInterval(()=>{this.checkIdleWorkers()},5000),this.idleCheckInterval&&typeof this.idleCheckInterval==="object"&&"unref"in this.idleCheckInterval)this.idleCheckInterval.unref()}}createWorker(){let t=`
|
|
3
3
|
const { parentPort } = require('worker_threads');
|
|
4
4
|
const bun = typeof Bun !== 'undefined' ? Bun : null;
|
|
5
5
|
const fs = bun ? null : require('node:fs');
|
|
@@ -173,5 +173,5 @@ catch (error) {
|
|
|
173
173
|
const result = await processTask(task);
|
|
174
174
|
parentPort.postMessage(result);
|
|
175
175
|
});
|
|
176
|
-
`,r=f(),o=r?new c(k(r)):new c(t,{eval:!0}),s={worker:o,busy:!1,taskCount:0,lastActive:Date.now(),currentTask:null};return o.on("message",(i)=>{this.handleWorkerResult(s,i)}),o.on("error",(i)=>{e.error("Worker error:",i),this.handleWorkerError(s,i)}),o.on("exit",(i)=>{if(i!==0&&!this.isShuttingDown)e.error(`Worker exited with code ${i}`),this.removeWorker(s)}),this.workers.push(s),this.updateStats(),s}handleWorkerResult(t,r){if(t.busy=!1,t.taskCount++,t.lastActive=Date.now(),t.currentTask&&t.currentTask.id===r.id){clearTimeout(t.currentTask.timeout);let{resolve:s}=t.currentTask;t.currentTask=null,s(r)}if(r.success)this.stats.completedTasks++;else this.stats.failedTasks++;let o=this.stats.averageDuration*(this.stats.completedTasks+this.stats.failedTasks-1)+r.duration;if(this.stats.averageDuration=o/(this.stats.completedTasks+this.stats.failedTasks),this.updateStats(),t.taskCount>=this.config.recycleAfter)this.recycleWorker(t);this.processQueue()}handleWorkerError(t,r){if(t.busy=!1,t.currentTask){clearTimeout(t.currentTask.timeout);let{reject:o}=t.currentTask;t.currentTask=null,o(r)}this.stats.failedTasks++,this.updateStats(),this.recycleWorker(t),this.processQueue()}removeWorker(t){let r=this.workers.indexOf(t);if(r!==-1)this.workers.splice(r,1),t.worker.terminate();this.updateStats()}recycleWorker(t){if(this.removeWorker(t),!this.isShuttingDown&&this.workers.length<this.config.maxWorkers)this.createWorker()}checkIdleWorkers(){let t=Date.now(),r=1;for(let o=this.workers.length-1;o>=0;o--){let s=this.workers[o];if(!s.busy&&t-s.lastActive>this.config.idleTimeout&&this.workers.length>1)this.removeWorker(s)}}processQueue(){while(this.taskQueue.length>0){let t;for(let n=0;n<this.workers.length;n++)if(!this.workers[n].busy){t=this.workers[n];break}if(!t&&this.workers.length<this.config.maxWorkers)t=this.createWorker();if(!t)return;let{task:r,resolve:o,reject:s}=this.taskQueue.shift();t.busy=!0,t.lastActive=Date.now();let i=setTimeout(()=>{if(t.currentTask?.id===r.id)t.currentTask=null;s(Error(`Task ${r.id} timed out`)),this.recycleWorker(t)},this.config.taskTimeout);t.currentTask={id:r.id,resolve:o,reject:s,timeout:i},t.worker.postMessage(r),this.updateStats()}}async submit(t){return this.stats.totalTasks++,new Promise((r,o)=>{this.taskQueue.push({task:t,resolve:r,reject:o}),this.processQueue()})}async processFiles(t,r={}){let o=t.map((s,i)=>({id:`task-${i}-${Date.now()}`,type:"process",filePath:s.path,sourceCode:s.content,config:r}));return Promise.all(o.map((s)=>this.submit(s)))}updateStats(){let t=0;for(let r=0;r<this.workers.length;r++)if(this.workers[r].busy)t++;this.stats.activeWorkers=t,this.stats.idleWorkers=this.workers.length-t}getStats(){return{...this.stats}}async shutdown(){if(this.isShuttingDown=!0,this.idleCheckInterval)clearInterval(this.idleCheckInterval);while(this.taskQueue.length>0||this.workers.some((t)=>t.busy))await new Promise((t)=>setTimeout(t,100));await Promise.all(this.workers.map((t)=>t.worker.terminate())),this.workers=[]}}function
|
|
177
|
-
export{
|
|
176
|
+
`,r=f(),o=r?new c(k(r)):new c(t,{eval:!0}),s={worker:o,busy:!1,taskCount:0,lastActive:Date.now(),currentTask:null};return o.on("message",(i)=>{this.handleWorkerResult(s,i)}),o.on("error",(i)=>{e.error("Worker error:",i),this.handleWorkerError(s,i)}),o.on("exit",(i)=>{if(i!==0&&!this.isShuttingDown)e.error(`Worker exited with code ${i}`),this.removeWorker(s)}),this.workers.push(s),this.updateStats(),s}handleWorkerResult(t,r){if(t.busy=!1,t.taskCount++,t.lastActive=Date.now(),t.currentTask&&t.currentTask.id===r.id){clearTimeout(t.currentTask.timeout);let{resolve:s}=t.currentTask;t.currentTask=null,s(r)}if(r.success)this.stats.completedTasks++;else this.stats.failedTasks++;let o=this.stats.averageDuration*(this.stats.completedTasks+this.stats.failedTasks-1)+r.duration;if(this.stats.averageDuration=o/(this.stats.completedTasks+this.stats.failedTasks),this.updateStats(),t.taskCount>=this.config.recycleAfter)this.recycleWorker(t);this.processQueue()}handleWorkerError(t,r){if(t.busy=!1,t.currentTask){clearTimeout(t.currentTask.timeout);let{reject:o}=t.currentTask;t.currentTask=null,o(r)}this.stats.failedTasks++,this.updateStats(),this.recycleWorker(t),this.processQueue()}removeWorker(t){let r=this.workers.indexOf(t);if(r!==-1)this.workers.splice(r,1),t.worker.terminate();this.updateStats()}recycleWorker(t){if(this.removeWorker(t),!this.isShuttingDown&&this.workers.length<this.config.maxWorkers)this.createWorker()}checkIdleWorkers(){let t=Date.now(),r=1;for(let o=this.workers.length-1;o>=0;o--){let s=this.workers[o];if(!s.busy&&t-s.lastActive>this.config.idleTimeout&&this.workers.length>1)this.removeWorker(s)}}processQueue(){while(this.taskQueue.length>0){let t;for(let n=0;n<this.workers.length;n++)if(!this.workers[n].busy){t=this.workers[n];break}if(!t&&this.workers.length<this.config.maxWorkers)t=this.createWorker();if(!t)return;let{task:r,resolve:o,reject:s}=this.taskQueue.shift();t.busy=!0,t.lastActive=Date.now();let i=setTimeout(()=>{if(t.currentTask?.id===r.id)t.currentTask=null;s(Error(`Task ${r.id} timed out`)),this.recycleWorker(t)},this.config.taskTimeout);t.currentTask={id:r.id,resolve:o,reject:s,timeout:i},t.worker.postMessage(r),this.updateStats()}}async submit(t){return this.stats.totalTasks++,new Promise((r,o)=>{this.taskQueue.push({task:t,resolve:r,reject:o}),this.processQueue()})}async processFiles(t,r={}){let o=t.map((s,i)=>({id:`task-${i}-${Date.now()}`,type:"process",filePath:s.path,sourceCode:s.content,config:r}));return Promise.all(o.map((s)=>this.submit(s)))}updateStats(){let t=0;for(let r=0;r<this.workers.length;r++)if(this.workers[r].busy)t++;this.stats.activeWorkers=t,this.stats.idleWorkers=this.workers.length-t}getStats(){return{...this.stats}}async shutdown(){if(this.isShuttingDown=!0,this.idleCheckInterval)clearInterval(this.idleCheckInterval);while(this.taskQueue.length>0||this.workers.some((t)=>t.busy))await new Promise((t)=>setTimeout(t,100));await Promise.all(this.workers.map((t)=>t.worker.terminate())),this.workers=[]}}function pr(t={}){return new Jt(t)}async function Wi(t,r={},o={}){let s=pr(o);await s.init();try{return await s.processFiles(t,r)}finally{await s.shutdown()}}function _i(t,r){let o=[];for(let s=0;s<t.length;s+=r)o.push(t.slice(s,s+r));return o}function ji(t,r=u().length){if(t<=r)return 1;let s=r*3;return Math.max(1,Math.ceil(t/s))}
|
|
177
|
+
export{Jt,pr,Wi,_i,ji};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{A}from"./chunk-
|
|
3
|
-
export{
|
|
2
|
+
import{A}from"./chunk-yapmefw7.js";import{re}from"./chunk-6bmr0e81.js";import{ne,$e}from"./chunk-hcf0hd85.js";import{Nn}from"./chunk-ry1c863d.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 Vi(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={...A,...f};if(await ne(n),n.isolatedDeclarations===void 0)n.isolatedDeclarations=await re(n);let u=await Nn(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 $e(n,o),Object.freeze({filesGenerated:o.size,outputFiles:Object.freeze([...o.keys()])})}
|
|
3
|
+
export{Vi};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
class
|
|
3
|
-
`)}async writeResults(){if(!this.config.outputFile)return;let e=this.getResults(),t=JSON.stringify(e,null,2);try{let s=await import("fs/promises");await s.writeFile(this.config.outputFile,t,"utf-8")}catch{await Bun.write(this.config.outputFile,t)}}}function y(){if(typeof process<"u"&&process.memoryUsage){let e=process.memoryUsage();return{timestamp:Date.now(),heapUsed:e.heapUsed,heapTotal:e.heapTotal,external:e.external,arrayBuffers:e.arrayBuffers||0,rss:e.rss}}return{timestamp:Date.now(),heapUsed:0,heapTotal:0,external:0,arrayBuffers:0,rss:0}}function d(){if(typeof process<"u"&&process.cpuUsage){let e=process.cpuUsage();return{user:e.user,system:e.system}}return{user:0,system:0}}function n(e){if(e===0)return"0 B";let t=["B","KB","MB","GB"],s=1024,r=Math.floor(Math.log(e)/Math.log(s));return`${Number.parseFloat((e/s**r).toFixed(2))} ${t[r]}`}function
|
|
4
|
-
export{
|
|
2
|
+
class Qt{config;memorySamples=[];cpuSamples=[];ioOperations=[];startTime=0;memoryInterval=null;cpuInterval=null;lastCpuUsage=null;isRunning=!1;constructor(e={}){this.config={memory:e.memory??!1,memoryLimit:e.memoryLimit??1024,cpu:e.cpu??!1,samplingInterval:e.samplingInterval??100,io:e.io??!1,trackOperations:e.trackOperations??["read","write"],outputFile:e.outputFile??""}}start(){if(this.isRunning)return;if(this.isRunning=!0,this.startTime=Date.now(),this.memorySamples=[],this.cpuSamples=[],this.ioOperations=[],this.lastCpuUsage=null,this.config.memory)this.sampleMemory(),this.memoryInterval=setInterval(()=>this.sampleMemory(),this.config.samplingInterval);if(this.config.cpu)this.sampleCpu(),this.cpuInterval=setInterval(()=>this.sampleCpu(),this.config.samplingInterval)}stop(){if(!this.isRunning)return;if(this.isRunning=!1,this.memoryInterval)clearInterval(this.memoryInterval),this.memoryInterval=null;if(this.cpuInterval)clearInterval(this.cpuInterval),this.cpuInterval=null}sampleMemory(){let e=y();this.memorySamples.push(e)}sampleCpu(){let e=d();if(this.lastCpuUsage){let t={timestamp:Date.now(),user:e.user-this.lastCpuUsage.user,system:e.system-this.lastCpuUsage.system,total:e.user-this.lastCpuUsage.user+(e.system-this.lastCpuUsage.system)};this.cpuSamples.push(t)}this.lastCpuUsage=e}recordIo(e,t,s,r){if(!this.config.io)return;if(!this.config.trackOperations.includes(e))return;this.ioOperations.push({timestamp:Date.now(),operation:e,path:t,size:s,durationMs:r})}getResults(){let e=Date.now(),t=[],s=this.memorySamples[0]||y(),r=0;for(let a of this.memorySamples){if(r+=a.heapUsed,a.heapUsed>s.heapUsed)s=a;let g=a.heapUsed/1048576;if(g>this.config.memoryLimit)t.push(`Memory limit exceeded at ${new Date(a.timestamp).toISOString()}: ${g.toFixed(2)}MB > ${this.config.memoryLimit}MB`)}let i=this.memorySamples.length>0?r/this.memorySamples.length:0,o=0,m=0;for(let a of this.cpuSamples)o+=a.user,m+=a.system;let u=0,l=0,p=0,h=0,c=0,f=0;for(let a of this.ioOperations)if(a.operation==="read")u++,p+=a.size,c+=a.durationMs;else l++,h+=a.size,f+=a.durationMs;return{startTime:this.startTime,endTime:e,durationMs:e-this.startTime,memory:{samples:this.memorySamples,peak:s,average:{timestamp:0,heapUsed:i,heapTotal:0,external:0,arrayBuffers:0,rss:0},warnings:t},cpu:{samples:this.cpuSamples,totalUser:o,totalSystem:m},io:{operations:this.ioOperations,totalReads:u,totalWrites:l,totalReadBytes:p,totalWriteBytes:h,totalReadMs:c,totalWriteMs:f}}}formatResults(){let e=this.getResults(),t=["=== Profiling Results ===",""];if(t.push(`Duration: ${e.durationMs}ms`),t.push(""),this.config.memory){if(t.push("Memory:"),t.push(` Samples: ${e.memory.samples.length}`),t.push(` Peak heap: ${n(e.memory.peak.heapUsed)}`),t.push(` Average heap: ${n(e.memory.average.heapUsed)}`),e.memory.warnings.length>0){t.push(" Warnings:");for(let s of e.memory.warnings)t.push(` - ${s}`)}t.push("")}if(this.config.cpu)t.push("CPU:"),t.push(` Samples: ${e.cpu.samples.length}`),t.push(` Total user time: ${(e.cpu.totalUser/1000).toFixed(2)}ms`),t.push(` Total system time: ${(e.cpu.totalSystem/1000).toFixed(2)}ms`),t.push("");if(this.config.io)t.push("I/O:"),t.push(` Total reads: ${e.io.totalReads}`),t.push(` Total writes: ${e.io.totalWrites}`),t.push(` Total read: ${n(e.io.totalReadBytes)} in ${e.io.totalReadMs.toFixed(2)}ms`),t.push(` Total write: ${n(e.io.totalWriteBytes)} in ${e.io.totalWriteMs.toFixed(2)}ms`),t.push("");return t.join(`
|
|
3
|
+
`)}async writeResults(){if(!this.config.outputFile)return;let e=this.getResults(),t=JSON.stringify(e,null,2);try{let s=await import("fs/promises");await s.writeFile(this.config.outputFile,t,"utf-8")}catch{await Bun.write(this.config.outputFile,t)}}}function y(){if(typeof process<"u"&&process.memoryUsage){let e=process.memoryUsage();return{timestamp:Date.now(),heapUsed:e.heapUsed,heapTotal:e.heapTotal,external:e.external,arrayBuffers:e.arrayBuffers||0,rss:e.rss}}return{timestamp:Date.now(),heapUsed:0,heapTotal:0,external:0,arrayBuffers:0,rss:0}}function d(){if(typeof process<"u"&&process.cpuUsage){let e=process.cpuUsage();return{user:e.user,system:e.system}}return{user:0,system:0}}function n(e){if(e===0)return"0 B";let t=["B","KB","MB","GB"],s=1024,r=Math.floor(Math.log(e)/Math.log(s));return`${Number.parseFloat((e/s**r).toFixed(2))} ${t[r]}`}function Sr(e){return new Qt(e)}async function fs(e,t){let s=Sr({memory:!0,cpu:!0,...t});s.start();try{return{result:await e(),profile:s.getResults()}}finally{s.stop()}}function ds(e){return{async read(t,s){let r=Date.now();try{let i=await s(),o=typeof i==="string"?i.length:0;return e.recordIo("read",t,o,Date.now()-r),i}catch(i){throw e.recordIo("read",t,0,Date.now()-r),i}},async write(t,s,r){let i=Date.now();try{await s(),e.recordIo("write",t,r,Date.now()-i)}catch(o){throw e.recordIo("write",t,0,Date.now()-i),o}}}}class en{marks=new Map;durations=new Map;mark(e){this.marks.set(e,performance.now())}measure(e,t){let s=this.marks.get(t);if(s===void 0)throw Error(`Mark "${t}" not found`);let r=performance.now()-s,i=this.durations.get(e)||[];return i.push(r),this.durations.set(e,i),r}getDurations(e){return this.durations.get(e)||[]}getAverage(e){let t=this.getDurations(e);if(t.length===0)return 0;return t.reduce((s,r)=>s+r,0)/t.length}getSummary(){let e=new Map;for(let[t,s]of this.durations)e.set(t,{count:s.length,total:s.reduce((r,i)=>r+i,0),average:s.reduce((r,i)=>r+i,0)/s.length,min:Math.min(...s),max:Math.max(...s)});return e}clear(){this.marks.clear(),this.durations.clear()}}function ps(){return new en}
|
|
4
|
+
export{Qt,Sr,fs,ds,en,ps};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{st}from"./chunk-
|
|
2
|
+
import{st}from"./chunk-2h5p8n7w.js";import{A}from"./chunk-yapmefw7.js";import{Mn}from"./chunk-rwdcmcx3.js";import{ke}from"./chunk-hgg4aqvf.js";import{ce}from"./chunk-x6ddycvm.js";import y from"process";import{readdir as v}from"fs/promises";import{join as C,resolve as D}from"path";function tt(){return`${String.fromCharCode(47,47,35)} sourceMappingURL=`}function Mo(n,r){throw Error(r||`Unexpected value: ${n}`)}async function Y(n,r,o="lf"){let t=r.replace(/\r\n/g,`
|
|
3
3
|
`);if(!t.endsWith(`
|
|
4
4
|
`))t+=`
|
|
5
5
|
`;if(o==="crlf")t=t.replace(/\n/g,`\r
|
|
6
|
-
`);if(await st(n,t)!==Buffer.byteLength(t,"utf8"))throw Error(`Incomplete declaration write: ${n}`)}async function
|
|
6
|
+
`);if(await st(n,t)!==Buffer.byteLength(t,"utf8"))throw Error(`Incomplete declaration write: ${n}`)}async function yi(n){let r=n??A.root,o=await v(r,{withFileTypes:!0});return(await Promise.all(o.map((i)=>{let c=C(r,i.name);return i.isDirectory()?yi(c):c}))).flat(1/0).filter((i)=>{if(typeof i!=="string")return!1;return/\.(?:ts|tsx|mts|cts)$/.test(i)&&!/\.d\.(?:ts|mts|cts)$/.test(i)})}async function re(n){try{let r=n?.cwd||y.cwd();return(await ce(D(r,n?.tsconfigPath||"tsconfig.json"),{allowCircular:!0}))?.isolatedDeclarations??!1}catch{return!1}}function Tt(n,r){let o={isValid:!0,errors:[]};for(let t of ke(n))o.errors.push({line:t.line,column:t.column,message:t.message,code:t.code});for(let t of Mn(n))o.errors.push({line:t.line,column:1,message:`'${t.name}' is used but never declared or imported here, so it resolves to an error type for anything consuming this file. It is most likely an ambient global in the source project \u2014 import it explicitly. Referenced by: ${t.context}`,code:"dangling-type-reference"});return o.isValid=o.errors.length===0,o}function At(n,r,o){if(n===r)return"";let t=n.split(`
|
|
7
7
|
`),i=r.split(`
|
|
8
8
|
`),c=new Map,a=new Map;for(let e=0;e<t.length;e++)c.set(t[e],(c.get(t[e])??0)+1);for(let e=0;e<i.length;e++)a.set(i[e],(a.get(i[e])??0)+1);let g=[],u=[];for(let[e,s]of c){let m=s-(a.get(e)??0);for(let l=0;l<m;l++)g.push(e)}for(let[e,s]of a){let m=s-(c.get(e)??0);for(let l=0;l<m;l++)u.push(e)}if(g.length===0&&u.length===0)return"";let p=[`--- ${o}`,`+++ ${o}`];for(let e=0;e<g.length;e++)p.push(`- ${g[e]}`);for(let e=0;e<u.length;e++)p.push(`+ ${u[e]}`);return p.join(`
|
|
9
|
-
`)}function
|
|
9
|
+
`)}function Pt(n,r,o,t){let i=n.split(`
|
|
10
10
|
`),c=[];function a(s){let l="",f=s<0?-s<<1|1:s<<1;do{let d=f&31;if(f>>>=5,f>0)d|=32;l+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[d]}while(f>0);return l}let g=0,u=0,p=0,e=t.split(`
|
|
11
|
-
`).length;for(let s=0;s<i.length;s++){if(i[s].trim()===""){c.push("");continue}g=0;let l=Math.min(s,e-1),f=[],d=0-g,h=0,w=l-u,x=0-p;f.push(a(d)+a(h)+a(w)+a(x)),g=0,u=l,p=0,c.push(f.join(","))}return{version:3,file:r,sourceRoot:"",sources:[o],sourcesContent:[t],mappings:c.join(";")}}function
|
|
11
|
+
`).length;for(let s=0;s<i.length;s++){if(i[s].trim()===""){c.push("");continue}g=0;let l=Math.min(s,e-1),f=[],d=0-g,h=0,w=l-u,x=0-p;f.push(a(d)+a(h)+a(w)+a(x)),g=0,u=l,p=0,c.push(f.join(","))}return{version:3,file:r,sourceRoot:"",sources:[o],sourcesContent:[t],mappings:c.join(";")}}function Dt(n,r){return`${n}
|
|
12
12
|
${tt()}${r}
|
|
13
13
|
`}
|
|
14
|
-
export{tt,
|
|
14
|
+
export{tt,Mo,Y,yi,re,Tt,At,Pt,Dt};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{s}from"./chunk-
|
|
3
|
-
export{Ke,Da,
|
|
2
|
+
import{s}from"./chunk-ehpz5rg3.js";function Ke(d={}){let{buildStart:l=!0,buildEnd:u=!1,writeBundle:c=!1,modes:t,onGenerated:f,onError:o,...p}=d,i="production",r=async()=>{try{let e=await s(p);f?.(e)}catch(e){let a=e instanceof Error?e:Error(String(e));if(o?.(a),!o)console.error("[dtsx] Generation failed:",a.message)}},n=()=>{if(!t||t.length===0)return!0;return t.includes(i)};return{name:"dtsx",apply(e){return i=e.mode,!0},async buildStart(){if(l&&n())await r()},async buildEnd(){if(u&&n())await r()},async writeBundle(){if(c&&n())await r()}}}var Da=Ke,Ra=Ke;
|
|
3
|
+
export{Ke,Da,Ra};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{t,d}from"./chunk-
|
|
3
|
-
`,l);l=
|
|
2
|
+
import{t,d}from"./chunk-tsbthwf0.js";import{V}from"./chunk-t89jepjk.js";import{jt}from"./chunk-kcbbz8t7.js";import{x}from"./chunk-k75z3nef.js";import{ae}from"./chunk-jtq24yb8.js";import{relative as O}from"path";function P(n){let y=t(n),c=(l)=>y[l]?n.slice(y[l].start,y[l].end):"",i=c(0)==="export"?1:0;if(c(i++)!=="declare")return;let f;if(c(i)==="module"&&y[i+1]?.kind==="quoted"){if(f=d(c(i+1)),f===void 0)return;i+=2}else if(c(i++)!=="global")return;if(c(i)!=="{")return;let h=y[i].end,S=1;for(i++;i<y.length;i++)if(c(i)==="{")S++;else if(c(i)==="}"&&--S===0)return{specifier:f,body:n.slice(h,y[i].start),start:h,end:y[i].start};return}var te=/^[A-Z_$][\w$]*$/i;function Oo(n){let y=[],c=[],i=0,f=0,h=[],S=!1,l=0,E=n.length,R=(a)=>{let w=n.slice(i,a).trim();if(i=a,!w)return;if(ne(w)){c.push(w);return}y.push({text:w,comments:c}),c=[]};while(l<E){let a=n[l];if(S){if(a==="\\"){l+=2;continue}if(a==="`"){S=!1,l++;continue}if(a==="$"&&n[l+1]==="{"){h.push(f),f++,S=!1,l+=2;continue}l++;continue}if(a==="/"&&n[l+1]==="*"){let w=n.indexOf("*/",l+2);l=w===-1?E:w+2;continue}if(a==="/"&&n[l+1]==="/"){let w=n.indexOf(`
|
|
3
|
+
`,l);l=w===-1?E:w;continue}if(a==="'"||a==='"'){l++;while(l<E&&n[l]!==a&&n[l]!==`
|
|
4
4
|
`){if(n[l]==="\\")l++;l++}l++;continue}if(a==="`"){S=!0,l++;continue}if(a==="("||a==="["||a==="{"){f++,l++;continue}if(a===")"||a==="]"||a==="}"){if(f--,h.length>0&&a==="}"&&f===h[h.length-1])h.pop(),S=!0;l++;continue}if(f===0&&a===";"){R(l+1),l++;continue}if(f===0&&a===`
|
|
5
|
-
`){let
|
|
6
|
-
`,y);y=c===-1?n.length:c;continue}if(n.startsWith("/*",y)){let c=n.indexOf("*/",y+2);if(c===-1)return!0;y=c+2;continue}return!1}return!0}function X(n){let y=[];for(let c of n.split(",")){let i=c.replace(/\/\*[\s\S]*?\*\//g,"").trim().replace(/^type\s+/,"");if(!i)continue;let f=i.match(/^([\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!f)continue;y.push({local:f[1],exported:f[2]??f[1]})}return y}var se=/^(?:export\s+)?(default\s+)?(?:declare\s+)?(abstract\s+)?(class|interface|type|function\s*\*?|enum|const\s+enum|namespace|module|const|let|var|async\s+function)\b\s*([\w$]+)?/;function ie(n,y){let c=n.replace(/^export\s+/,""),i=/^default\s+/.test(c);if(c=c.replace(/^default\s+/,""),i)c=c.replace(/^((?:declare\s+)?(?:abstract\s+)?(?:class|function\s*\*?|async\s+function\s*\*?))\s*(?=[(<{])/,(f,h)=>`${h.trimEnd()} ${y}`);if(/^(?:interface|type)\b/.test(c)||/^declare\b/.test(c))return c;return`declare ${c}`}function q(n,y,c=!1){let i={file:n,declarations:[],declared:new Set,imports:new Map,localExports:new Map,namedReExports:[],starReExports:[],namespaceReExports:[],verbatim:[],augmentations:[],directives:[]},f=c?jt(y,n).map((h)=>({text:h.text,comments:[...h.leadingComments??[]]})):
|
|
7
|
-
`).map((v)=>v.trim()).filter((v)=>v.startsWith("///"))),!1;return!0});let S=h.text.replace(/;\s*$/,"").trim(),l=S.startsWith("import")?
|
|
8
|
-
`;while(a<
|
|
9
|
-
`,a),N=k===-1?
|
|
10
|
-
`){if(n[k]==="\\")k++;k++}R+=n.slice(a,k+1),a=k+1,v=
|
|
11
|
-
`||!/\s/.test(
|
|
5
|
+
`){let w=n[l+1];if(w!==void 0&&/[\w$@/]/.test(w))R(l+1);l++;continue}l++}return R(E),y}function ne(n){let y=0;while(y<n.length){while(y<n.length&&/\s/.test(n[y]))y++;if(y>=n.length)return!0;if(n.startsWith("//",y)){let c=n.indexOf(`
|
|
6
|
+
`,y);y=c===-1?n.length:c;continue}if(n.startsWith("/*",y)){let c=n.indexOf("*/",y+2);if(c===-1)return!0;y=c+2;continue}return!1}return!0}function X(n){let y=[];for(let c of n.split(",")){let i=c.replace(/\/\*[\s\S]*?\*\//g,"").trim().replace(/^type\s+/,"");if(!i)continue;let f=i.match(/^([\w$]+)(?:\s+as\s+([\w$]+))?$/);if(!f)continue;y.push({local:f[1],exported:f[2]??f[1]})}return y}var se=/^(?:export\s+)?(default\s+)?(?:declare\s+)?(abstract\s+)?(class|interface|type|function\s*\*?|enum|const\s+enum|namespace|module|const|let|var|async\s+function)\b\s*([\w$]+)?/;function ie(n,y){let c=n.replace(/^export\s+/,""),i=/^default\s+/.test(c);if(c=c.replace(/^default\s+/,""),i)c=c.replace(/^((?:declare\s+)?(?:abstract\s+)?(?:class|function\s*\*?|async\s+function\s*\*?))\s*(?=[(<{])/,(f,h)=>`${h.trimEnd()} ${y}`);if(/^(?:interface|type)\b/.test(c)||/^declare\b/.test(c))return c;return`declare ${c}`}function q(n,y,c=!1){let i={file:n,declarations:[],declared:new Set,imports:new Map,localExports:new Map,namedReExports:[],starReExports:[],namespaceReExports:[],verbatim:[],augmentations:[],directives:[]},f=c?jt(y,n).map((h)=>({text:h.text,comments:[...h.leadingComments??[]]})):Oo(y);for(let h of f){h.comments=h.comments.filter((w)=>{if(/^\/\/\/\s*</.test(w))return i.directives.push(...w.split(`
|
|
7
|
+
`).map((v)=>v.trim()).filter((v)=>v.startsWith("///"))),!1;return!0});let S=h.text.replace(/;\s*$/,"").trim(),l=S.startsWith("import")?x(S):null;if(l&&!l.isImportEquals){let w=l.source;if(l.defaultName)i.imports.set(l.defaultName,{specifier:w,imported:"default"});if(l.namespaceName)i.imports.set(l.namespaceName,{specifier:w,imported:"*"});for(let v of l.namedItems)i.imports.set(v.name,{specifier:w,imported:/^['"]/.test(v.originalName)?d(v.originalName):v.originalName});continue}if(/^import\s+['"]/.test(S)){i.verbatim.push(h);continue}let E=S.match(/^export\s+(?:type\s+)?\*\s+as\s+([\w$]+)\s+from\s+(['"])([^'"]+)\2/);if(E){i.namespaceReExports.push({specifier:E[3],exported:E[1]});continue}if(E=S.match(/^export\s+(?:type\s+)?\*\s+from\s+(['"])([^'"]+)\1/),E){i.starReExports.push(E[2]);continue}if(E=S.match(/^export\s+(?:type\s+)?\{([\s\S]*)\}\s+from\s+(['"])([^'"]+)\2/),E){for(let w of X(E[1]))i.namedReExports.push({specifier:E[3],imported:w.local,exported:w.exported});continue}if(E=S.match(/^export\s+(?:type\s+)?\{([\s\S]*)\}$/),E){for(let w of X(E[1]))i.localExports.set(w.exported,w.local);continue}if(E=S.match(/^export\s+default\s+([\w$]+)$/),E&&te.test(E[1])){i.localExports.set("default",E[1]);continue}let R=P(S);if(R?.specifier!==void 0&&V(y)){i.augmentations.push({statement:h,specifier:R.specifier,body:R.body});continue}if(/^export\s+as\s+namespace\b/.test(S)||R){i.verbatim.push(h);continue}let a=S.match(se);if(a){let w=!!a[1],v=a[4]??(w?"_default":null);if(v){if(i.declared.add(v),/^export\s/.test(S))i.localExports.set(w?"default":v,v);i.declarations.push({statement:h,name:v,emit:ie(h.text,v)});continue}}i.declarations.push({statement:h,name:null,emit:h.text})}return i}function nt(n,y){if(y.size===0)return n;let c=t(n),i=new Map(c.filter((m)=>m.kind==="literal").map((m)=>[m.start,m.end])),f=(m)=>c[m]?n.slice(c[m].start,c[m].end):"",h=new Map,S=[];for(let m=0;m<c.length;m++){let b=f(m);if(["(","[","{","<"].includes(b))S.push(m);else if([")","]","}",">"].includes(b)&&!(b===">"&&f(m-1)==="=")){let k=S.at(-1);if(k!==void 0&&["()","[]","{}","<>"].includes(f(k)+b))S.pop(),h.set(k,m)}}let l=(m)=>{for(let b=m;b<c.length;b++){if([";",",",")","]","}"].includes(f(b))||f(b)===">"&&f(b-1)!=="=")return b;let k=h.get(b);if(k!==void 0)b=k}return c.length},E=new Set;for(let m=0;m<c.length;m++){let b=h.get(m);if(f(m)!=="<"||b===void 0)continue;let k=["class","interface","type"].includes(f(m-2));if(!k&&f(b+1)!=="(")continue;let N=new Set;for(let u=m+1;u<b;u++){if(u===m+1||f(u-1)===","){while(["const","in","out"].includes(f(u)))u++;if(c[u]?.kind==="word")N.add(f(u))}let D=h.get(u);if(D!==void 0)u=D}let I=l(b+1);if(k&&f(m-2)!=="type")for(let u=b+1;u<c.length;u++){if(f(u)==="{"){I=h.get(u)??I;break}let D=h.get(u);if(D!==void 0)u=D}for(let u=m+1;u<I;u++){let D=f(m-2)==="class"&&u>b&&f(u-1)==="extends";if(N.has(f(u))&&f(u-1)!=="typeof"&&!D)E.add(c[u].start)}}for(let m=0;m<c.length;m++){if(!["namespace","module"].includes(f(m))||c[m+1]?.kind!=="word"||f(m+2)!=="{")continue;let b=h.get(m+2);if(b===void 0)continue;let k=jt(n.slice(c[m+2].end,c[b].start),"bundle-namespace.ts"),N=new Set(k.filter((u)=>["class","interface","type","enum","module","namespace"].includes(u.kind)).map((u)=>u.name)),I=new Set(k.filter((u)=>["class","variable","function","enum","module","namespace"].includes(u.kind)).map((u)=>u.name));for(let u=m+3;u<b;u++)if((f(u-1)==="typeof"?I:N).has(f(u)))E.add(c[u].start)}let R="",a=0,w=n.length,v=`
|
|
8
|
+
`;while(a<w){let m=i.get(a);if(m!==void 0){R+=n.slice(a,m),a=m,v="`";continue}let b=n[a];if(b==="/"&&n[a+1]==="*"){let k=n.indexOf("*/",a+2),N=k===-1?w:k+2;R+=n.slice(a,N),a=N;continue}if(b==="/"&&n[a+1]==="/"){let k=n.indexOf(`
|
|
9
|
+
`,a),N=k===-1?w:k;R+=n.slice(a,N),a=N;continue}if(b==="'"||b==='"'){let k=a+1;while(k<w&&n[k]!==b&&n[k]!==`
|
|
10
|
+
`){if(n[k]==="\\")k++;k++}R+=n.slice(a,k+1),a=k+1,v=b;continue}if(/[A-Z_$]/i.test(b)){let k=a+1;while(k<w&&/[\w$]/.test(n[k]))k++;let N=n.slice(a,k),I=y.get(N);if(I!==void 0&&v!=="."&&!E.has(a)){let u=k;while(u<w&&(n[u]===" "||n[u]==="\t"))u++;let D=(n[u]===":"||n[u]==="?"&&n[u+1]===":")&&/[{;,(\n]/.test(v);R+=D?N:I}else R+=N;v="a",a=k;continue}if(R+=b,b===`
|
|
11
|
+
`||!/\s/.test(b))v=b;a++}return R}function Dn(n,y,c,i){let f=[],h=new Map,S=[n,...y.filter((e)=>e!==n)];for(let e of S){let s=c.get(e);if(s===void 0){f.push(`No declarations were generated for ${O(i.cwd,e)}; it is left out of the bundle`);continue}h.set(e,q(e,s))}let l=(e,s)=>{if(!e.startsWith(".")&&!e.startsWith("/"))return null;let o=ae(e,s).resolved;return o&&h.has(o)?o:null},E=(e)=>e.startsWith(".")||e.startsWith("/"),R=new Set,a=(e)=>{let s=e;for(let o=1;R.has(s);o++)s=`${e}_${o}`;return R.add(s),s},w=new Map;for(let[e,s]of h){let o=new Map;for(let g of s.declared)o.set(g,a(g));w.set(e,o)}let v=new Map,m=(e,s,o)=>{let g=`${e}\x00${s}`,r=v.get(g);if(!r)r=a(o),v.set(g,r);return r},b=new Map,k=new Map,N=new Set,I=new Map,u=!0,D=(e,s,o)=>{let g=l(s,e.file);if(g){if(o==="*")return{kind:"namespace",file:g};let r=L(g).get(o);if(!r&&!u)f.push(`${O(i.cwd,e.file)}: '${o}' is not exported by '${s}'`);return r??null}if(E(s))return f.push(`${O(i.cwd,e.file)}: '${s}' is not part of the bundle`),null;return o==="*"?{kind:"external-namespace",source:s}:{kind:"external",source:s,imported:o}},Y=(e,s)=>{if(e.declared.has(s))return{kind:"local",name:w.get(e.file).get(s)};let o=e.imports.get(s);if(o)return D(e,o.specifier,o.imported);return f.push(`${O(i.cwd,e.file)}: cannot resolve exported name '${s}'`),null};function L(e){let s=b.get(e);if(s)return s;let o=new Map,g=h.get(e);if(!g||N.has(e))return o;N.add(e);let r=new Set;for(let[p,M]of g.localExports){let B=Y(g,M);if(B)o.set(p,B)}for(let p of g.namedReExports){let M=D(g,p.specifier,p.imported);if(M)o.set(p.exported,M)}for(let p of g.namespaceReExports){let M=D(g,p.specifier,"*");if(M)o.set(p.exported,M)}for(let p of g.starReExports){let M=l(p,e);if(M){for(let[B,C]of L(M))if(B!=="default"&&!o.has(B))o.set(B,C);for(let B of k.get(M)??[])r.add(B)}else if(E(p))f.push(`${O(i.cwd,e)}: '${p}' is not part of the bundle`);else r.add(p)}for(let[p,M]of I.get(e)??[])o.set(p,M);return N.delete(e),b.set(e,o),k.set(e,r),o}for(let[e,s]of h)for(let o of s.augmentations){let g=l(o.specifier,e);if(!g)continue;for(let r of q(e,o.body,!0).declared){if(L(g).has(r))continue;let p=I.get(g);if(!p)p=new Map,I.set(g,p);p.set(r,{kind:"local",name:a(r)}),b.clear()}}u=!1,b.clear(),k.clear();let J=new Map,F=[],z=(e,s)=>{switch(e.kind){case"local":return e.name;case"external":return m(e.source,e.imported,e.imported==="default"?s:e.imported);case"external-namespace":return m(e.source,"*",s);case"namespace":return ee(e.file,s)}};function ee(e,s){let o=J.get(e);if(o)return o;let g=a(s);J.set(e,g);let r=[];for(let[p,M]of L(e)){if(p==="default")continue;let B=z(M,p);r.push(B===p?p:`${B} as ${p}`)}if(k.get(e)?.size)f.push(`${O(i.cwd,e)}: 'export * from' an external module cannot be expressed inside namespace '${g}'`);return F.push(`declare namespace ${g} {
|
|
12
12
|
export { ${r.join(", ")} };
|
|
13
|
-
}`),g}let Q=[],A=[],H=new Set;for(let[e,s]of h){for(let r of s.directives)H.add(r);let o=new Map;for(let[r,p]of
|
|
13
|
+
}`),g}let Q=[],A=[],H=new Set;for(let[e,s]of h){for(let r of s.directives)H.add(r);let o=new Map;for(let[r,p]of w.get(e))if(r!==p)o.set(r,p);for(let[r,p]of s.imports){if(s.declared.has(r))continue;let M=D(s,p.specifier,p.imported);if(!M)continue;let B=z(M,r);if(B!==r)o.set(r,B)}let g=[];for(let r of s.declarations){if(i.keepComments)g.push(...r.statement.comments);let p=nt(r.emit,o);if(!/[;}]$/.test(p))p+=";";g.push(p)}for(let r of s.verbatim){if(i.keepComments)A.push(...r.comments);let p=P(r.text);if(p){let M=new Map(o);for(let B of q(e,p.body,!0).declared)M.delete(B);A.push(r.text.slice(0,p.start)+nt(p.body,M)+r.text.slice(p.end))}else{let M=t(r.text),B=M[1]?.kind==="quoted"?d(r.text.slice(M[1].start,M[1].end)):void 0;if(B===void 0||!l(B,e))A.push(nt(r.text,o))}}for(let r of s.augmentations){let p=l(r.specifier,e),M=q(e,r.body,!0),B=new Map(o);if(!p){for(let K of M.declared)B.delete(K);let C=P(r.statement.text);if(i.keepComments)A.push(...r.statement.comments);A.push(r.statement.text.slice(0,C.start)+nt(C.body,B)+r.statement.text.slice(C.end));continue}for(let[C,K]of L(p))B.set(C,z(K,C));if(i.keepComments)g.push(...r.statement.comments);for(let C of M.declarations){if(!C.name||!L(p).has(C.name))throw Error(`Cannot link augmentation '${r.specifier}' member '${C.name??C.emit}'`);if(i.keepComments)g.push(...C.statement.comments);g.push(nt(C.emit,B))}}if(g.length>0)Q.push(`// From: ${O(i.cwd,e)}
|
|
14
14
|
${g.join(`
|
|
15
15
|
`)}`)}let U=L(n),Z=[],T=[];for(let[e,s]of U){if(s.kind==="external"){T.push(`export { ${s.imported===e?e:`${s.imported} as ${e}`} } from '${s.source}';`);continue}if(s.kind==="external-namespace"){T.push(`export * as ${e} from '${s.source}';`);continue}let o=z(s,e==="default"?"_default":e);Z.push(o===e?e:`${o} as ${e}`)}for(let e of k.get(n)??[])T.push(`export * from '${e}';`);let G=new Map;for(let[e,s]of v){let[o,g]=e.split("\x00"),r=G.get(o)??{named:[],defaults:[],namespaces:[]};if(G.set(o,r),g==="*")r.namespaces.push(s);else if(g==="default")r.defaults.push(s);else r.named.push(g===s?s:`${g} as ${s}`)}let W=[];for(let[e,s]of[...G].sort(([o],[g])=>o.localeCompare(g))){for(let o of s.defaults)W.push(`import ${o} from '${e}';`);for(let o of s.namespaces)W.push(`import * as ${o} from '${e}';`);if(s.named.length>0)W.push(`import { ${s.named.join(", ")} } from '${e}';`)}let j=[];if(H.size>0)j.push([...H].join(`
|
|
16
16
|
`));if(j.push(`/**
|
|
@@ -24,4 +24,4 @@ ${g.join(`
|
|
|
24
24
|
|
|
25
25
|
`)}
|
|
26
26
|
`,files:[...h.keys()],exportCount:U.size,warnings:f}}
|
|
27
|
-
export{
|
|
27
|
+
export{Oo,nt,Dn};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
function L(n){return n.endsWith(".vue")}function
|
|
2
|
+
function L(n){return n.endsWith(".vue")}function Ca(n){let i={script:null,scriptSetup:null},e=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,s;while((s=e.exec(n))!==null){let t=s[1]||"",r=/lang\s*=\s*["']([^"']+)["']/i.exec(t)?.[1]?.toLowerCase()??"js",l={content:s[2]??"",attrs:t,setup:/\bsetup\b/.test(t),lang:r};if(l.setup)i.scriptSetup=l;else i.script=l}return i}function h(n,i){let e=n[i];i++;while(i<n.length){let s=n[i];if(s==="\\"){i+=2;continue}if(s===e)return i+1;i++}return i}function d(n,i){i++;let e=0;while(i<n.length){let s=n[i];if(s==="\\"){i+=2;continue}if(s==="`"&&e===0)return i+1;if(s==="$"&&n[i+1]==="{"){e++,i+=2;continue}if(s==="}"){if(e>0)e--;i++;continue}i++}return i}function b(n,i){if(n[i+1]==="/"){let e=n.indexOf(`
|
|
3
3
|
`,i+2);return e===-1?n.length:e+1}if(n[i+1]==="*"){let e=n.indexOf("*/",i+2);return e===-1?n.length:e+2}return i+1}function Ot(n,i){let e=n[i];if(e==='"'||e==="'")return h(n,i);if(e==="`")return d(n,i);if(e==="/"&&(n[i+1]==="/"||n[i+1]==="*"))return b(n,i);return i}function It(n){let i=n.split(""),e=0;while(e<n.length){let s=Ot(n,e);if(s>e){for(let t=e;t<s;t++)if(i[t]!==`
|
|
4
4
|
`&&i[t]!=="\r")i[t]=" ";e=s;continue}e++}return i.join("")}function c(n,i,e,s){let t=0,r=i;while(r<n.length){let l=n[r];if(l==='"'||l==="'"){r=h(n,r);continue}if(l==="`"){r=d(n,r);continue}if(l==="/"&&(n[r+1]==="/"||n[r+1]==="*")){r=b(n,r);continue}if(l===e)t++;else if(l===s){if(t--,t===0)return r}r++}return-1}function W(n,i){let e=0,s=i;while(s<n.length){let t=n[s];if(t==='"'||t==="'"){s=h(n,s);continue}if(t==="`"){s=d(n,s);continue}if(t==="/"&&(n[s+1]==="/"||n[s+1]==="*")){s=b(n,s);continue}if(t==="="&&n[s+1]===">"){s+=2;continue}if(t==="<")e++;else if(t===">"){if(e--,e===0)return s}s++}return-1}function S(n,i=","){let e=[],s=0,t="",r=0;while(r<n.length){let l=n[r];if(l==='"'||l==="'"){let u=h(n,r);t+=n.slice(r,u),r=u;continue}if(l==="`"){let u=d(n,r);t+=n.slice(r,u),r=u;continue}if(l==="/"&&(n[r+1]==="/"||n[r+1]==="*")){r=b(n,r);continue}if(l==="{"||l==="["||l==="("||l==="<")s++;else if(l==="}"||l==="]"||l===")"||l===">")s--;if(l===i&&s===0){e.push(t),t="",r++;continue}t+=l,r++}if(t.trim()!=="")e.push(t);return e}function O(n){let i=n.trim();if(!i.startsWith("{"))return[];let e=c(i,0,"{","}");if(e===-1)return[];let s=i.slice(1,e),t=[];for(let r of S(s)){let l=-1,u=0;for(let p=0;p<r.length;p++){let f=r[p];if(f==='"'||f==="'"){p=h(r,p)-1;continue}if(f==="`"){p=d(r,p)-1;continue}if(f==="{"||f==="["||f==="("||f==="<")u++;else if(f==="}"||f==="]"||f===")"||f===">")u--;else if(f===":"&&u===0){l=p;break}}if(l!==-1){t.push({key:E(r.slice(0,l).trim()),value:r.slice(l+1).trim(),isMethod:!1});continue}let o=/^([A-Za-z_$][\w$]*|['"][^'"]+['"])\s*\(/.exec(r.trim());if(o){t.push({key:E(o[1]),value:r.trim(),isMethod:!0});continue}let a=r.trim();if(a)t.push({key:E(a),value:"",isMethod:!1})}return t}function E(n){if(n.startsWith("'")&&n.endsWith("'")||n.startsWith('"')&&n.endsWith('"'))return n.slice(1,-1);return n}function k(n){return/^[A-Za-z_$][\w$]*$/.test(n)?n:JSON.stringify(n)}function Ne(n,i){let e=new RegExp(`\\b${i}\\b`,"g"),s;while((s=e.exec(n))!==null){let t=s.index+s[0].length;while(t<n.length&&/\s/.test(n[t]))t++;let r=null;if(n[t]==="<"){let o=W(n,t);if(o===-1)return null;r=n.slice(t+1,o).trim(),t=o+1;while(t<n.length&&/\s/.test(n[t]))t++}if(n[t]!=="(")continue;let l=c(n,t,"(",")");if(l===-1)return null;let u=S(n.slice(t+1,l));return{generic:r,arg:u.length>0?u[0].trim():null}}return null}function P(n,i){let e=M(n,i);if(!e)return null;return e.kind==="interface"?n.slice(e.bodyStart,e.end):n.slice(e.bodyStart,e.end).trim()}function M(n,i){let s=new RegExp(`\\binterface\\s+${i}\\b[^{]*\\{`,"m").exec(n);if(s){let l=s.index+s[0].length-1,u=c(n,l,"{","}");if(u!==-1)return{kind:"interface",start:s.index,end:u+1,bodyStart:l}}let r=new RegExp(`\\btype\\s+${i}\\b[^=]*=`,"m").exec(n);if(r){let l=r.index+r[0].length,u=0,o=l;while(l<n.length){let a=n[l];if(a==='"'||a==="'"){l=h(n,l);continue}if(a==="`"){l=d(n,l);continue}if(a==="{"||a==="["||a==="("||a==="<")u++;else if(a==="}"||a==="]"||a===")"||a===">")u--;else if((a===";"||a===`
|
|
5
5
|
`)&&u===0)break;l++}return{kind:"type",start:r.index,end:l,bodyStart:o}}return null}var C={String:"string",Number:"number",Boolean:"boolean",Array:"unknown[]",Object:"Record<string, unknown>",Function:"(...args: any[]) => any",Symbol:"symbol",Promise:"Promise<unknown>",Date:"Date",BigInt:"bigint"};function x(n){let i=n.search(/\bas\s+PropType\s*</);if(i===-1)return null;let e=n.indexOf("<",i),s=W(n,e);if(s===-1)return null;if(n.slice(s+1).trim()!=="")return null;return n.slice(e+1,s).trim()}function T(n){let i=n.trim(),e=x(i);if(e!==null)return{type:e,optional:!0};if(i==="null")return{type:"unknown",optional:!0};if(i.startsWith("[")){let s=c(i,0,"[","]");if(s!==-1){let t=S(i.slice(1,s)).map((r)=>T(r).type).filter((r)=>r!=="unknown");return{type:t.length>0?[...new Set(t)].join(" | "):"unknown",optional:!0}}}if(i.startsWith("{")){let s=O(i),t=s.find((o)=>o.key==="type"),r=s.find((o)=>o.key==="required"),l=t?T(t.value).type:"unknown",u=!(r&&r.value.trim()==="true");return{type:l,optional:u}}if(C[i])return{type:C[i],optional:!0};if(/^[A-Za-z_$][\w$.]*$/.test(i))return{type:i,optional:!0};return{type:"unknown",optional:!0}}function ot(n){let i=n.trim();if(i.startsWith("{")){let e=O(i);if(e.length===0)return"{}";return`{ ${e.map((t)=>{if(t.isMethod||t.value==="")return`${k(t.key)}?: unknown`;let r=T(t.value);return`${k(t.key)}${r.optional?"?":""}: ${r.type}`}).join(", ")} }`}if(i.startsWith("[")){let e=c(i,0,"[","]");if(e===-1)return null;let s=S(i.slice(1,e)).map((t)=>E(t.trim())).filter((t)=>t!=="");if(s.length===0)return"{}";return`{ ${s.map((t)=>`${k(t)}?: unknown`).join(", ")} }`}return null}function V(n){let i=n.trim();if(!i.startsWith("["))return null;let e=c(i,0,"[","]");if(e===-1)return null;let s=S(i.slice(1,e)).map((t)=>t.trim());if(s.length===0)return"{}";if(!s.every((t)=>t.startsWith("'")&&t.endsWith("'")||t.startsWith('"')&&t.endsWith('"')))return"string[]";return`[${s.map((t)=>JSON.stringify(E(t))).join(", ")}]`}function A(n){let i=n.trim();if(!i.startsWith("{"))return null;let e=O(i);if(e.length===0)return"{}";return`{ ${e.map((t)=>`${JSON.stringify(t.key)}: (...args: any[]) => void`).join(", ")} }`}function R(n){return V(n)??A(n)}function D(n){let i=[],e=0,s="",t=0;while(t<n.length){let r=n[t];if(r==='"'||r==="'"){let l=h(n,t);s+=n.slice(t,l),t=l;continue}if(r==="`"){let l=d(n,t);s+=n.slice(t,l),t=l;continue}if(r==="/"&&(n[t+1]==="/"||n[t+1]==="*")){let l=b(n,t);s+=n.slice(t,l),t=l;continue}if(r==="="&&n[t+1]===">"){s+="=>",t+=2;continue}if(r==="{"||r==="["||r==="("||r==="<")e++;else if(r==="}"||r==="]"||r===")"||r===">")e--;if((r===";"||r===","||r===`
|
|
@@ -15,7 +15,7 @@ function L(n){return n.endsWith(".vue")}function wa(n){let i={script:null,script
|
|
|
15
15
|
`&&e===0)i.add(s+1);s++}return i}function lt(n,i,e){let s=n.indexOf(e);if(s===-1)return n;let t=n.lastIndexOf(`
|
|
16
16
|
`,s)+1;if(/\bexport\b/.test(n.slice(t,s)))return n;let r=n.slice(0,s)+n.slice(s+e.length);if(new RegExp(`\\b${i}\\b`).test(r))return n;return r}function Ft(n){let i="",e=0,s=()=>{for(let r=i.length-1;r>=0;r--)if(!/\s/.test(i[r]))return i[r];return""},t=(r)=>{for(let l=r;l<n.length;l++)if(!/\s/.test(n[l]))return n[l];return""};while(e<n.length){let r=n[e];if(r==='"'||r==="'"){let l=h(n,e);i+=n.slice(e,l),e=l;continue}if(r==="`"){let l=d(n,e);i+=n.slice(e,l),e=l;continue}if(r==="/"&&n[e+1]==="*"){let l=b(n,e);i+=n.slice(e,l).replace(/\s*\n\s*/g," "),e=l;continue}if(r==="/"&&n[e+1]==="/"){let l=e+2;while(l<n.length&&n[l]!==`
|
|
17
17
|
`)l++;let u=n.slice(e+2,l).trim();if(u!==""&&!u.includes("*/"))i+=`/* ${u} */`;e=l;continue}if(r===`
|
|
18
|
-
`){let l=s(),u=t(e+1);if(l===""||u===""){e++;continue}let o=F(i);if(!o&&("{;,(<:=[".includes(l)||"}),]>;|&".includes(u))){if(!i.endsWith(" ")&&!i.endsWith(";"))i+=" "}else if(o){if(!i.endsWith(" "))i+=" "}else{if(i.endsWith(" "))i=i.slice(0,-1);i+="; "}e++;while(e<n.length&&(n[e]===" "||n[e]==="\t"))e++;continue}i+=r,e++}return i}function F(n){let i=n.length-1;while(i>=0&&/\s/.test(n[i]))i--;if(i<1||n[i]!=="/"||n[i-1]!=="*")return!1;let e=n.lastIndexOf("/*",i);if(e===-1)return!1;for(let s=e-1;s>=0;s--){let t=n[s];if(/\s/.test(t))continue;return"{;,(<:".includes(t)}return!0}function ut(n,i){let e=[n,i].filter((s)=>s!==null);for(let s of e){let t=Ne(s,"defineProps");if(!t)continue;if(t.generic){let r=t.generic;if(r.startsWith("{"))return{type:r};if(/^[A-Za-z_$][\w$]*$/.test(r)){for(let l of e){let u=M(l,r);if(!u)continue;let o=P(l,r);if(o===null)continue;return{type:o,inlinedLocal:{name:r,declText:l.slice(u.start,u.end)}}}return{type:r}}return{type:r}}if(t.arg){let r=ot(t.arg);if(r!==null)return{type:r}}}return null}function Bt(n,i){let e=[n,i].filter((s)=>s!==null);for(let s of e){let t=Ne(s,"defineEmits");if(!t)continue;if(t.generic)return I(t.generic)??t.generic;if(t.arg){let r=R(t.arg);if(r!==null)return r}}return null}function Wt(n,i){let e=[n,i].filter((s)=>s!==null);for(let s of e){let t=Ne(s,"defineExpose");if(!t||!t.arg||!t.arg.startsWith("{"))continue;let r=O(t.arg);if(r.length===0)return null;return`{ ${r.map((u)=>{if(u.value===""&&/^[A-Za-z_$][\w$]*$/.test(u.key))return`${k(u.key)}: typeof ${u.key}`;let o=u.isMethod||/=>|^\s*function\b/.test(u.value);return`${k(u.key)}: ${o?"(...args: any[]) => any":"unknown"}`}).join(", ")} }`}return null}function N(n){let i=
|
|
18
|
+
`){let l=s(),u=t(e+1);if(l===""||u===""){e++;continue}let o=F(i);if(!o&&("{;,(<:=[".includes(l)||"}),]>;|&".includes(u))){if(!i.endsWith(" ")&&!i.endsWith(";"))i+=" "}else if(o){if(!i.endsWith(" "))i+=" "}else{if(i.endsWith(" "))i=i.slice(0,-1);i+="; "}e++;while(e<n.length&&(n[e]===" "||n[e]==="\t"))e++;continue}i+=r,e++}return i}function F(n){let i=n.length-1;while(i>=0&&/\s/.test(n[i]))i--;if(i<1||n[i]!=="/"||n[i-1]!=="*")return!1;let e=n.lastIndexOf("/*",i);if(e===-1)return!1;for(let s=e-1;s>=0;s--){let t=n[s];if(/\s/.test(t))continue;return"{;,(<:".includes(t)}return!0}function ut(n,i){let e=[n,i].filter((s)=>s!==null);for(let s of e){let t=Ne(s,"defineProps");if(!t)continue;if(t.generic){let r=t.generic;if(r.startsWith("{"))return{type:r};if(/^[A-Za-z_$][\w$]*$/.test(r)){for(let l of e){let u=M(l,r);if(!u)continue;let o=P(l,r);if(o===null)continue;return{type:o,inlinedLocal:{name:r,declText:l.slice(u.start,u.end)}}}return{type:r}}return{type:r}}if(t.arg){let r=ot(t.arg);if(r!==null)return{type:r}}}return null}function Bt(n,i){let e=[n,i].filter((s)=>s!==null);for(let s of e){let t=Ne(s,"defineEmits");if(!t)continue;if(t.generic)return I(t.generic)??t.generic;if(t.arg){let r=R(t.arg);if(r!==null)return r}}return null}function Wt(n,i){let e=[n,i].filter((s)=>s!==null);for(let s of e){let t=Ne(s,"defineExpose");if(!t||!t.arg||!t.arg.startsWith("{"))continue;let r=O(t.arg);if(r.length===0)return null;return`{ ${r.map((u)=>{if(u.value===""&&/^[A-Za-z_$][\w$]*$/.test(u.key))return`${k(u.key)}: typeof ${u.key}`;let o=u.isMethod||/=>|^\s*function\b/.test(u.value);return`${k(u.key)}: ${o?"(...args: any[]) => any":"unknown"}`}).join(", ")} }`}return null}function N(n){let i=Ca(n),e="",s=null,t=null;if(i.script){let y=Nt(i.script.content);if(y.passthrough)return i.scriptSetup?`${i.script.content}
|
|
19
19
|
${i.scriptSetup.content}`:i.script.content;if(e=y.script,y.options){let _=at(y.options,"props");if(_)s=ot(_);let j=at(y.options,"emits");if(j)t=R(j)}}let r=i.scriptSetup?.content??null,l=r!==null?Lt(r):null,u=ut(r,r!==null?null:e),o=u?.type??s??"{}",a=Bt(r,null)??t,p=Wt(r,null),f=u?.inlinedLocal;if(f){if(e=lt(e,f.name,f.declText),l!==null)l=lt(l,f.name,f.declText)}let m=[o,p??"{}"];if(a)m.push("{}","{}","{}","{}","{}",a);let w=Ft(`DefineComponent<${m.join(", ")}>`),g=[],v=ct(e,w);if(v.trim()!=="")g.push(v);if(l&&l.trim()!==""){let y=ct(l,w);if(y.trim()!=="")g.push(y)}return g.push("import type { DefineComponent } from 'vue'"),g.push(`type __DtsxComponentType = ${w}`),g.push("const __dtsx_component__: __DtsxComponentType = null as unknown as __DtsxComponentType"),g.push("export default __dtsx_component__"),g.join(`
|
|
20
20
|
`)}
|
|
21
|
-
export{L,
|
|
21
|
+
export{L,Ca,Ot,It,c,Ne,ot,Lt,Nt,at,ct,lt,Ft,ut,Bt,Wt,N};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{se}from"./chunk-
|
|
3
|
-
`));if(!t.some((a,i)=>a!==e.leadingComments[i]))return;return{...e,leadingComments:t}}}function
|
|
4
|
-
export{
|
|
2
|
+
import{se}from"./chunk-290jpwny.js";function Si(n,r,e,t={}){return{kind:n,name:r,text:e,isExported:t.isExported??!1,...t}}function $i(n){if(typeof structuredClone==="function")return structuredClone(n);return JSON.parse(JSON.stringify(n))}function Ln(n,r,e=null){for(let t of n){r.enter?.(t,e);let o=r[t.kind];if(o)o(t,e);if(t.members&&t.members.length>0)Ln(t.members,r,t);r.leave?.(t,e)}}function Fo(n,r){let e=[];return Ln(n,{enter:(t)=>{if(r(t))e.push(t)}}),e}async function Ei(n,r,e){let t=[],o=n.length;for(let a=0;a<n.length;a++){let i=n[a],s={...e,index:a,total:o,allDeclarations:n},l=await r(i,s);if(l===null)continue;else if(l===void 0)t.push(i);else if(Array.isArray(l))t.push(...l);else t.push(l)}return t}function Bo(...n){return async(r,e)=>{let t=r;for(let o of n){if(t===null)return null;if(Array.isArray(t)){let a=[];for(let i of t){let s=await o(i,e);if(s===null)continue;if(s===void 0)a.push(i);else if(Array.isArray(s))a.push(...s);else a.push(s)}t=a.length>0?a:null}else{let a=await o(t,e);if(a===null)t=null;else if(a===void 0);else t=a}}return t}}function Te(n,r){let e=new Set(Array.isArray(n)?n:[n]);return async(t,o)=>{if(e.has(t.kind))return r(t,o);return}}function Wo(n,r){return async(e,t)=>{if(n(e))return r(e,t);return}}function it(n){let r={createDeclaration:Si,cloneDeclaration:$i,modifyText:(e,t)=>({...e,text:t}),addModifier:(e,t)=>({...e,modifiers:[...e.modifiers||[],t]}),removeModifier:(e,t)=>({...e,modifiers:(e.modifiers||[]).filter((o)=>o!==t)})};return se({name:n.name,version:n.version,description:n.description,onBeforeFile:n.beforeParse?async(e)=>n.beforeParse(e.content,{filePath:e.filePath,phase:"before"}):void 0,onDeclarations:n.transform?async(e)=>Ei(e.declarations,n.transform,{filePath:e.filePath,sourceCode:e.sourceCode,...r}):void 0,onAfterFile:n.afterGenerate?async(e)=>n.afterGenerate(e.content,{filePath:e.filePath,phase:"after"}):void 0})}function _o(n,r){let e=typeof n==="string"?new RegExp(n):n;return(t)=>{if(e.test(t.name)){let o=typeof r==="function"?r(t.name,t):t.name.replace(e,r),a=t.text.replace(new RegExp(`\\b${f(t.name)}\\b`),o);return{...t,name:o,text:a}}return}}function ki(n,r){return(e)=>{if(e.kind==="import")return;if(r&&!r(e))return;let t=`${n}${e.name}`,o=e.text.replace(new RegExp(`\\b${f(e.name)}\\b`),t);return{...e,name:t,text:o}}}function jo(n,r){return(e)=>{if(e.kind==="import")return;if(r&&!r(e))return;let t=`${e.name}${n}`,o=e.text.replace(new RegExp(`\\b${f(e.name)}\\b`),t);return{...e,name:t,text:o}}}function Ti(n){let r=typeof n==="function"?n:(e)=>(typeof n==="string"?new RegExp(n):n).test(e.name);return(e)=>{if(r(e))return null;return}}function Go(n){return(r)=>{let e=n(r);if(!e)return;let o=(Array.isArray(e)?e:[e]).map((a)=>{if(a.startsWith("/**"))return a;if(a.startsWith("/*"))return a;return`/** ${a} */`});return{...r,leadingComments:[...r.leadingComments||[],...o]}}}function Vo(n){return(r)=>{if(!r.typeAnnotation)return;let e=n(r.typeAnnotation,r);if(e===null)return null;if(e===void 0)return;let t=r.text.replace(new RegExp(`:[ ]*${f(r.typeAnnotation)}`),`: ${e}`);return{...r,typeAnnotation:e,text:t}}}function Uo(n){return Te("function",(r)=>{if(!r.returnType)return;let e=n(r.returnType,r);if(e===null)return null;if(e===void 0)return;let t=r.text.replace(new RegExp(`\\):[ ]*${f(r.returnType)}`),`): ${e}`);return{...r,returnType:e,text:t}})}function zo(n){return Te(["function","class"],(r)=>{if(!r.parameters)return;let e=n(r.parameters,r);if(e===null)return null;if(e===void 0)return;let t=e.map((a)=>{let i="";if(a.rest)i+="...";if(i+=a.name,a.optional)i+="?";if(a.type)i+=`: ${a.type}`;if(a.defaultValue)i+=` = ${a.defaultValue}`;return i}).join(", "),o=r.text.replace(/\([^)]*\)/,`(${t})`);return{...r,parameters:e,text:o}})}function Ai(n,r){return(e)=>{if(r&&!r(e))return;if(e.modifiers?.includes(n))return;let t=[...e.modifiers||[],n],o=e.text;if(!o.includes(n)){let a=["function","class","interface","type","enum","const","let","var"];for(let i of a){let s=o.indexOf(i);if(s>=0){o=`${o.slice(0,s)}${n} ${o.slice(s)}`;break}}}return{...e,modifiers:t,text:o}}}var Pi=Te(["interface","type"],(n)=>{let r=n.text.replace(/(\n\s*)(\w+)(\??:\s)/g,"$1readonly $2$3");if(r===n.text)return;return{...n,text:r}}),Ho=Te(["interface","type"],(n)=>{let r=n.text.replace(/(\w+)\?:/g,"$1:");if(r===n.text)return;return{...n,text:r}}),Ko=Te(["interface","type"],(n)=>{let r=n.text.replace(/(\w+)(?<!\?):/g,"$1?:");if(r===n.text)return;return{...n,text:r}});function qo(n){let r=new RegExp(`@(${n.join("|")})\\b[^@]*`,"g");return(e)=>{if(!e.leadingComments?.length)return;let t=e.leadingComments.map((a)=>a.replace(r,"").replace(/\n\s*\*\s*\n/g,`
|
|
3
|
+
`));if(!t.some((a,i)=>a!==e.leadingComments[i]))return;return{...e,leadingComments:t}}}function Jo(n,r){return(e)=>{if(r&&!r(e))return;if(!e.typeAnnotation)return;let t=`${n}<${e.typeAnnotation}>`,o=e.text.replace(e.typeAnnotation,t);return{...e,typeAnnotation:t,text:o}}}var Yo=it({name:"readonly",version:"1.0.0",description:"Makes all interface properties readonly",transform:Pi}),Xo=it({name:"strip-private",version:"1.0.0",description:"Strips @internal, @private, and @hidden declarations",transform:Ti((n)=>{if(!n.leadingComments)return!1;return n.leadingComments.some((r)=>/@(internal|private|hidden)\b/.test(r))})}),Zo=it({name:"declare",version:"1.0.0",description:"Adds declare keyword to all declarations",transform:Ai("declare",(n)=>n.kind!=="import")});function Qo(n){return it({name:`namespace-prefix-${n}`,version:"1.0.0",description:`Prefixes exported declarations with ${n}`,transform:ki(`${n}_`,(r)=>r.isExported&&r.kind!=="import")})}function f(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}
|
|
4
|
+
export{Si,$i,Ln,Fo,Ei,Bo,Te,Wo,it,_o,ki,jo,Ti,Go,Vo,Uo,zo,Ai,Pi,Ho,Ko,qo,Jo,Yo,Xo,Zo,Qo};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
function l(t,e){if(e===2)return t===48||t===49;if(e===8)return t>=48&&t<=55;if(e===10)return t>=48&&t<=57;return t>=48&&t<=57||t>=97&&t<=102||t>=65&&t<=70}function i(t,e,n){let r=!1,a=!1;while(e.at<t.length){let f=t.charCodeAt(e.at);if(l(f,n))r=!0,a=!1,e.at++;else if(f===95&&r&&!a&&e.at+1<t.length&&l(t.charCodeAt(e.at+1),n))a=!0,e.at++;else break}return r&&!a}function u(t,e){if(t.charCodeAt(e)!==48||e+1>=t.length)return 0;let n=t.charCodeAt(e+1)|32;return n===120?16:n===98?2:n===111?8:0}function g(t){if(t.length===0)return!1;let e={at:0};if(t.charCodeAt(0)===45)e.at++;if(e.at>=t.length)return!1;let n=u(t,e.at);if(n)return e.at+=2,i(t,e,n)&&e.at===t.length;let r=i(t,e,10);if(t.charCodeAt(e.at)===46){e.at++;let f=i(t,e,10);if(!r&&!f)return!1}else if(!r)return!1;let a=t.charCodeAt(e.at);if(a===101||a===69){if(e.at++,t.charCodeAt(e.at)===43||t.charCodeAt(e.at)===45)e.at++;if(!i(t,e,10))return!1}return e.at===t.length}function ee(t){if(t.length<2||t.charCodeAt(t.length-1)!==110)return!1;let e=t.slice(0,-1),n={at:0};if(e.charCodeAt(0)===45)n.at++;if(n.at>=e.length)return!1;let r=u(e,n.at);if(r)return n.at+=2,i(e,n,r)&&n.at===e.length;return i(e,n,10)&&n.at===e.length}function
|
|
3
|
-
export{g,ee,
|
|
2
|
+
function l(t,e){if(e===2)return t===48||t===49;if(e===8)return t>=48&&t<=55;if(e===10)return t>=48&&t<=57;return t>=48&&t<=57||t>=97&&t<=102||t>=65&&t<=70}function i(t,e,n){let r=!1,a=!1;while(e.at<t.length){let f=t.charCodeAt(e.at);if(l(f,n))r=!0,a=!1,e.at++;else if(f===95&&r&&!a&&e.at+1<t.length&&l(t.charCodeAt(e.at+1),n))a=!0,e.at++;else break}return r&&!a}function u(t,e){if(t.charCodeAt(e)!==48||e+1>=t.length)return 0;let n=t.charCodeAt(e+1)|32;return n===120?16:n===98?2:n===111?8:0}function g(t){if(t.length===0)return!1;let e={at:0};if(t.charCodeAt(0)===45)e.at++;if(e.at>=t.length)return!1;let n=u(t,e.at);if(n)return e.at+=2,i(t,e,n)&&e.at===t.length;let r=i(t,e,10);if(t.charCodeAt(e.at)===46){e.at++;let f=i(t,e,10);if(!r&&!f)return!1}else if(!r)return!1;let a=t.charCodeAt(e.at);if(a===101||a===69){if(e.at++,t.charCodeAt(e.at)===43||t.charCodeAt(e.at)===45)e.at++;if(!i(t,e,10))return!1}return e.at===t.length}function ee(t){if(t.length<2||t.charCodeAt(t.length-1)!==110)return!1;let e=t.slice(0,-1),n={at:0};if(e.charCodeAt(0)===45)n.at++;if(n.at>=e.length)return!1;let r=u(e,n.at);if(r)return n.at+=2,i(e,n,r)&&n.at===e.length;return i(e,n,10)&&n.at===e.length}function K(t){return t.includes("_")?t.replaceAll("_",""):t}
|
|
3
|
+
export{g,ee,K};
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var
|
|
2
|
+
var bn=["import","type","interface","enum","class","function","variable","export","module","namespace","unknown"],si=["builtin","external","scoped","internal","parent","sibling","index","type"];function Xe(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=wn(r,t),p?.enabled!==!1)r=Sn(r,p||{});if(f)r=$n(r,f);if(a)r=xn(r);if(r=Cn(r,u),l)r=oi(r,x);if(i||b)r=vn(r);return r}function wn(e,n){let t=e;if(e.indexOf("\r")!==-1){if(e.indexOf(`\r
|
|
3
3
|
`)!==-1)t=t.replace(/\r\n/g,`
|
|
4
4
|
`);if(t.indexOf("\r")!==-1)t=t.replace(/\r/g,`
|
|
5
5
|
`)}if(n==="crlf")t=t.replace(/\n/g,`\r
|
|
6
|
-
`);return t}function
|
|
6
|
+
`);return t}function ho(e){let n=(e.match(/\r\n/g)||[]).length,t=(e.match(/(?<!\r)\n/g)||[]).length;if(n>t)return"crlf";return"lf"}function xn(e){return e.split(`
|
|
7
7
|
`).map((n)=>n.replace(/[\t ]+$/,"")).join(`
|
|
8
|
-
`)}function
|
|
9
|
-
`.repeat(n+1))}function
|
|
10
|
-
`}function
|
|
8
|
+
`)}function Cn(e,n){let t=new RegExp(`\\n{${n+2},}`,"g");return e.replace(t,`
|
|
9
|
+
`.repeat(n+1))}function vn(e){return`${e.replace(/\s+$/,"")}
|
|
10
|
+
`}function oi(e,n){let{style:t="spaces",size:i=2}=n,u=t==="tabs"?"\t":" ".repeat(i),a=e.split(`
|
|
11
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
|
|
12
|
+
`)}function Sn(e,n){let{groups:t=si,separateGroups:i=!0,alphabetize:u=!0}=n,a=e.split(`
|
|
13
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
|
|
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 $n(e,n){let{kinds:t=bn,alphabetize:i=!1,groupExports:u=!0}=n,a=e.split(`
|
|
15
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
|
|
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 yo(e){let n=e.split(`
|
|
17
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
|
|
19
|
-
export{
|
|
18
|
+
`)}function bo(e={}){return{normalize:(n)=>Xe(n,e),normalizeLineEndings:(n)=>wn(n,e.lineEnding||"lf"),removeTrailingWhitespace:xn,normalizeBlankLines:(n)=>Cn(n,e.maxBlankLines||1),ensureTrailingNewline:vn,processImports:(n)=>Sn(n,e.importGrouping||{}),orderDeclarations:(n)=>$n(n,e.declarationOrder||{})}}var wo={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:bn,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{bn,si,Xe,wn,ho,xn,Cn,vn,oi,Sn,$n,yo,bo,wo};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import _ from"process";import{existsSync as U}from"fs";import{arch as I,platform as E}from"os";import{fileURLToPath as L}from"url";var T=["native","typescript"];function
|
|
3
|
-
export{
|
|
2
|
+
import _ from"process";import{existsSync as U}from"fs";import{arch as I,platform as E}from"os";import{fileURLToPath as L}from"url";var T=["native","typescript"];function q(n,t="engine"){if(n===void 0||n===null||n==="")return;if(typeof n==="string"&&T.includes(n))return n;throw Error(`Invalid ${t} ${JSON.stringify(n)}: expected "native" or "typescript"`)}var S;function gi(n){S=q(n)}function J(n){return q(n)??S??q(_.env.DTSX_ENGINE,"DTSX_ENGINE")??"native"}var b;function w(){return`${E()==="win32"?"windows":E()}-${I()}`}function z(n){let t=[],e=_.env.DTSX_NATIVE_LIBRARY;if(e)t.push(e);for(let r of[`../native/${w()}/${n}`,`../../native/${w()}/${n}`,`../../zig-dtsx/zig-out/lib/${n}`,`../../zig-dtsx/zig-out/bin/${n}`])try{t.push(L(new URL(r,import.meta.url)))}catch{}return t}function B(){if(typeof globalThis.Bun>"u")return null;let n;try{n=import.meta.require("bun:ffi")}catch{return null}let{dlopen:t,FFIType:e,ptr:r,suffix:c,toArrayBuffer:a}=n,g=c==="dll"?`zig-dtsx.${c}`:`libzig-dtsx.${c}`;for(let u of z(g)){if(!U(u))continue;try{let p=t(u,{process_source_checked_v1:{args:[e.ptr,e.u64,e.bool,e.bool,e.ptr,e.ptr],returns:e.ptr},process_source_with_context_v1:{args:[e.ptr,e.u64,e.bool,e.bool,e.ptr,e.u64,e.ptr,e.ptr],returns:e.ptr},free_result:{args:[e.ptr,e.u64],returns:e.void}}),{symbols:l}=p,f=new TextDecoder;return{checked:(i,o,d,m,y,h)=>l.process_source_checked_v1(r(i),o,d,m,r(y),r(h)),contextual:(i,o,d,m,y,h,A,N)=>l.process_source_with_context_v1(r(i),o,d,m,r(y),h,r(A),r(N)),read:(i,o)=>{if(!i)return"";let d=o?f.decode(a(i,0,o)):"";return l.free_result(i,o),d}}}catch{continue}}return null}function k(){if(b===void 0)b=B();return b}function hi(n){return J(n)==="native"&&k()!==null}var D=new TextEncoder,s=new Uint8Array(65536),x=new BigUint64Array(1),v=new Uint32Array(1);function Ee(n,t){if(J(t.engine)==="typescript")return null;let e=k();if(!e)return null;if(n.length*3>s.length)s=new Uint8Array(n.length*3);let{written:r}=D.encodeInto(n,s),c=t.sourceFile!==void 0||(t.inferenceSources?.size??0)>0||(t.augmentationImports?.size??0)>0,a;if(c){let u=t.sourceFile??"source.ts",p=D.encode(JSON.stringify({version:1,moduleSpecifierMode:"preserve",sourceFile:u,outputFile:u.replace(/\.(?:[cm]?[jt]sx?|vue|stx)$/,".d.ts"),sourceHash:new Bun.CryptoHasher("sha256").update(s.subarray(0,r)).digest("hex"),rewrites:[],augmentationImports:[...t.augmentationImports??[]],inferenceSources:[...t.inferenceSources??[]].map(([l,f])=>({specifier:l,source:f}))}));a=e.contextual(s,r,t.keepComments,t.isolatedDeclarations,p,p.length,x,v)}else a=e.checked(s,r,t.keepComments,t.isolatedDeclarations,x,v);let g=Number(x[0]);if(v[0]!==0)return e.read(a,g),null;return e.read(a,g)}
|
|
3
|
+
export{q,gi,J,hi,Ee};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{p}from"./chunk-v6fwy63g.js";import{createHash as g}from"crypto";import{mkdir as y,readFile as l,stat as m,writeFile as v}from"fs/promises";import{dirname as C,join as o}from"path";var c="1.0.0",b=".dtsx-cache",d="manifest.json";class
|
|
3
|
-
`)}function
|
|
4
|
-
export{
|
|
2
|
+
import{p}from"./chunk-v6fwy63g.js";import{createHash as g}from"crypto";import{mkdir as y,readFile as l,stat as m,writeFile as v}from"fs/promises";import{dirname as C,join as o}from"path";var c="1.0.0",b=".dtsx-cache",d="manifest.json";class mi{config;manifest=null;dirty=!1;stats={totalEntries:0,hits:0,misses:0,hitRatio:0,sizeBytes:0,timeSavedMs:0};constructor(t={}){this.config={enabled:t.enabled??!0,cacheDir:t.cacheDir??b,format:t.format??"json",maxAge:t.maxAge??86400000,force:t.force??!1,validateCache:t.validateCache??!0}}async init(){if(!this.config.enabled)return;try{await y(this.config.cacheDir,{recursive:!0}),await this.loadManifest()}catch{this.manifest={version:c,entries:{},createdAt:Date.now(),updatedAt:Date.now()}}}async loadManifest(){let t=o(this.config.cacheDir,d);try{let e=await l(t,"utf-8");if(this.manifest=JSON.parse(e),this.manifest.version!==c){await this.clear();return}this.stats.totalEntries=Object.keys(this.manifest.entries).length}catch{this.manifest={version:c,entries:{},createdAt:Date.now(),updatedAt:Date.now()}}}async save(){if(!this.config.enabled||!this.manifest||!this.dirty)return;let t=o(this.config.cacheDir,d);this.manifest.updatedAt=Date.now(),await v(t,JSON.stringify(this.manifest,null,2)),this.dirty=!1}async get(t,e){if(!this.config.enabled||!this.manifest||this.config.force)return this.stats.misses++,null;let s=this.manifest.entries[t];if(!s)return this.stats.misses++,null;if(s.configHash!==e)return this.stats.misses++,null;if(Date.now()-s.cachedAt>this.config.maxAge)return this.stats.misses++,delete this.manifest.entries[t],this.dirty=!0,null;if(this.config.validateCache)try{let a=(await m(t)).mtimeMs;if(a!==s.mtime){let i=await l(t,"utf-8");if(this.hashContent(i)!==s.hash)return this.stats.misses++,null;s.mtime=a,this.dirty=!0}}catch{return this.stats.misses++,delete this.manifest.entries[t],this.dirty=!0,null}if(s.dependencies.length>0){if((await Promise.all(s.dependencies.map(async(a)=>{let i=this.manifest.entries[a];if(!i)return!0;try{return(await m(a)).mtimeMs===i.mtime}catch{return!1}}))).some((a)=>!a))return this.stats.misses++,null}return this.stats.hits++,this.stats.timeSavedMs+=50,this.updateHitRatio(),s}async set(t,e,s,r,a,i){if(!this.config.enabled||!this.manifest)return;let n=Date.now();try{n=(await m(t)).mtimeMs}catch{}let h={filePath:t,hash:this.hashContent(e),mtime:n,declarations:s,dtsContent:r,dependencies:a,cachedAt:Date.now(),configHash:i};if(!(t in this.manifest.entries))this.stats.totalEntries++;this.manifest.entries[t]=h,this.dirty=!0}invalidate(t){if(!this.manifest)return;delete this.manifest.entries[t],this.dirty=!0;for(let[e,s]of Object.entries(this.manifest.entries))if(s.dependencies.includes(t))delete this.manifest.entries[e]}async clear(){this.manifest={version:c,entries:{},createdAt:Date.now(),updatedAt:Date.now()},this.stats={totalEntries:0,hits:0,misses:0,hitRatio:0,sizeBytes:0,timeSavedMs:0},this.dirty=!0,await this.save()}getStats(){return{...this.stats}}hashContent(t){return String(p(t))}updateHitRatio(){let t=this.stats.hits+this.stats.misses;this.stats.hitRatio=t>0?this.stats.hits/t:0}static hashConfig(t){let e={outdir:t.outdir,clean:t.clean,tsconfigPath:t.tsconfigPath};return g("sha256").update(JSON.stringify(e)).digest("hex").slice(0,16)}}function Ao(t,e){let s=[],r=[],a=[];return{async needsRebuild(i){return await t.get(i,e)===null},async getCachedDeclarations(i){let n=await t.get(i,e);if(n)return r.push(i),n.declarations;return null},async getCachedDts(i){let n=await t.get(i,e);if(n)return n.dtsContent;return null},async cacheResult(i,n,h,u,f=[]){await t.set(i,n,h,u,f,e),s.push(i)},skip(i){a.push(i)},getResult(){return{rebuilt:s,cached:r,skipped:a,stats:t.getStats()}},async save(){await t.save()}}}async function Po(t,e=604800000){let s=t.getStats();if(s.totalEntries>1000)return await t.clear(),s.totalEntries;return 0}function Do(t){let e=[];return e.push("Incremental Build Results:"),e.push(` Rebuilt: ${t.rebuilt.length} files`),e.push(` From cache: ${t.cached.length} files`),e.push(` Skipped: ${t.skipped.length} files`),e.push(""),e.push("Cache Statistics:"),e.push(` Total entries: ${t.stats.totalEntries}`),e.push(` Hit ratio: ${(t.stats.hitRatio*100).toFixed(1)}%`),e.push(` Time saved: ~${t.stats.timeSavedMs}ms`),e.join(`
|
|
3
|
+
`)}function Ro(t,e){let s=[],r=/import\s+(?:type\s+)?(?:.+(?:[\n\r\u2028\u2029]\s*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF])from\s+)?['"]([^'"]+)['"]/g,a;while((a=r.exec(t))!==null){let i=a[1];if(i.startsWith(".")){let n=o(C(e),i);s.push(n),s.push(`${n}.ts`),s.push(`${n}.tsx`),s.push(o(n,"index.ts")),s.push(o(n,"index.tsx"))}}return s}
|
|
4
|
+
export{mi,Ao,Po,Do,Ro};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
var Se={PARSE_ERROR:"PARSE_ERROR",SYNTAX_ERROR:"SYNTAX_ERROR",FILE_NOT_FOUND:"FILE_NOT_FOUND",FILE_READ_ERROR:"FILE_READ_ERROR",FILE_WRITE_ERROR:"FILE_WRITE_ERROR",TYPE_INFERENCE_ERROR:"TYPE_INFERENCE_ERROR",UNRESOLVED_TYPE:"UNRESOLVED_TYPE",EXTRACTION_ERROR:"EXTRACTION_ERROR",PROCESSING_ERROR:"PROCESSING_ERROR",VALIDATION_ERROR:"VALIDATION_ERROR",INVALID_DECLARATION:"INVALID_DECLARATION",CONFIG_ERROR:"CONFIG_ERROR",INVALID_ENTRYPOINT:"INVALID_ENTRYPOINT",CIRCULAR_DEPENDENCY:"CIRCULAR_DEPENDENCY",TIMEOUT_ERROR:"TIMEOUT_ERROR",NOT_SUPPORTED:"NOT_SUPPORTED",UNKNOWN_ERROR:"UNKNOWN_ERROR"};class k extends Error{code;context;constructor(n,e="UNKNOWN_ERROR",t){super(n);if(this.name="DtsxError",this.code=e,this.context=t,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toString(){let n=`${this.name} [${this.code}]: ${this.message}`;if(this.context)n+=`
|
|
3
|
-
Context: ${JSON.stringify(this.context,null,2)}`;return n}toJSON(){return{name:this.name,code:this.code,message:this.message,context:this.context,stack:this.stack}}}class
|
|
4
|
-
`)t++,s=1;else s++;r++}return{line:t,column:s,offset:e}}function
|
|
3
|
+
Context: ${JSON.stringify(this.context,null,2)}`;return n}toJSON(){return{name:this.name,code:this.code,message:this.message,context:this.context,stack:this.stack}}}class Tn extends k{filePath;line;column;constructor(n,e,t){super(n,"PARSE_ERROR",{filePath:e,line:t?.line,column:t?.column});if(this.name="ParseError",this.filePath=e,this.line=t?.line,this.column=t?.column,t?.cause)this.cause=t.cause}get locationString(){if(this.line!==void 0&&this.column!==void 0)return`${this.filePath}:${this.line}:${this.column}`;return this.line!==void 0?`${this.filePath}:${this.line}`:this.filePath}}class ui extends k{filePath;declarationKind;constructor(n,e,t,s){super(n,"EXTRACTION_ERROR",{filePath:e,declarationKind:t});if(this.name="ExtractionError",this.filePath=e,this.declarationKind=t,s)this.cause=s}}class fi extends k{declarationName;constructor(n,e,t){super(n,"PROCESSING_ERROR",{declarationName:e});if(this.name="ProcessingError",this.declarationName=e,t)this.cause=t}}class An extends k{filePath;operation;constructor(n,e,t,s){super(n,t==="read"?"FILE_READ_ERROR":"FILE_WRITE_ERROR",{filePath:e,operation:t});if(this.name="FileError",this.filePath=e,this.operation=t,s)this.cause=s}}class Pn extends k{configPath;invalidKey;constructor(n,e){super(n,"CONFIG_ERROR",{configPath:e?.configPath,invalidKey:e?.invalidKey});if(this.name="ConfigError",this.configPath=e?.configPath,this.invalidKey=e?.invalidKey,e?.cause)this.cause=e.cause}}class di extends k{cycle;constructor(n){super(`Circular dependency detected: ${n.join(" -> ")}`,"CIRCULAR_DEPENDENCY",{cycle:n});this.name="CircularDependencyError",this.cycle=n}}function xo(n){return n instanceof k}function Co(n){return n instanceof Tn}function vo(n){return n instanceof An}function So(n){return n instanceof Pn}function $o(n,e="UNKNOWN_ERROR",t){if(n instanceof k)return n;let s=t||(n instanceof Error?n.message:String(n)),r=new k(s,e);if(n instanceof Error)r.cause=n;return r}function Eo(n,e){let t=1,s=1,r=0;for(let i of n){if(r>=e)break;if(i===`
|
|
4
|
+
`)t++,s=1;else s++;r++}return{line:t,column:s,offset:e}}function ko(n,e,t,s){let r=n.split(`
|
|
5
5
|
`),i=e.line-1,o=[];if(s)o.push(`${s}:${e.line}:${e.column}`);else o.push(`Line ${e.line}, Column ${e.column}`);o.push(`Error: ${t}`),o.push("");let E=Math.max(0,i-1),c=Math.min(r.length-1,i+1);for(let a=E;a<=c;a++){let R=(a+1).toString().padStart(4," "),u=a===i?">":" ";if(o.push(`${u} ${R} | ${r[a]}`),a===i){let l=" ".repeat(8+e.column-1);o.push(`${l}^`)}}return o.join(`
|
|
6
6
|
`)}function Qe(n,e,t){let s={file:e,message:"Unknown error",code:Se.UNKNOWN_ERROR};if(n instanceof Error){s.message=n.message,s.stack=n.stack;let r=n.message.match(/\((\d+),(\d+)\)/);if(r)s.location={line:Number.parseInt(r[1],10),column:Number.parseInt(r[2],10)};if(n.message.includes("Cannot find")||n.message.includes("not found"))s.code=Se.FILE_NOT_FOUND,s.suggestion="Check that the file path is correct and the file exists.";else if(n.message.includes("syntax")||n.message.includes("Unexpected token"))s.code=Se.SYNTAX_ERROR,s.suggestion="Check for syntax errors in your TypeScript code.";else if(n.message.includes("type")&&n.message.includes("cannot"))s.code=Se.TYPE_INFERENCE_ERROR,s.suggestion="Add explicit type annotations to help with type inference.";else if(n.message.includes("parse")||n.message.includes("Parse"))s.code=Se.PARSE_ERROR,s.suggestion="The file contains invalid TypeScript syntax."}else if(typeof n==="string")s.message=n;return s}function Et(n,e){let t=[],s=n.file;if(n.location)s+=`:${n.location.line}:${n.location.column}`;if(n.code)s+=` [${n.code}]`;if(t.push(s),t.push(` Error: ${n.message}`),e&&n.location){t.push("");let r=e.split(`
|
|
7
7
|
`),i=n.location.line-1;if(i>=0&&i<r.length){let o=Math.max(0,i-1),E=Math.min(r.length-1,i+1);for(let c=o;c<=E;c++){let a=(c+1).toString().padStart(4," "),R=c===i?">":" ";if(t.push(` ${R} ${a} | ${r[c]}`),c===i&&n.location.column>0){let u=" ".repeat(10+n.location.column-1);t.push(` ${u}^`)}}}}if(n.suggestion)t.push(""),t.push(` Suggestion: ${n.suggestion}`);return t.join(`
|
|
8
|
-
`)}function
|
|
8
|
+
`)}function To(n){if(n.length===0)return"No errors";let e=new Map;for(let s of n){let r=s.code||"UNKNOWN";e.set(r,(e.get(r)||0)+1)}let t=[`${n.length} error(s) found:`];for(let[s,r]of e.entries())t.push(` - ${s}: ${r}`);return t.join(`
|
|
9
9
|
`)}
|
|
10
|
-
export{Se,k,
|
|
10
|
+
export{Se,k,Tn,ui,fi,An,Pn,di,xo,Co,vo,So,$o,Eo,ko,Qe,Et,To};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{t}from"./chunk-
|
|
3
|
-
export{_e,
|
|
2
|
+
import{t}from"./chunk-tsbthwf0.js";function C(n,o){if(o.kind!=="punctuation")return 0;let r=n.slice(o.start,o.end);if("([{<".includes(r))return 1;if(")]}".includes(r)||r===">"&&n[o.start-1]!=="=")return-1;return 0}function _e(n){if(!n.includes("?"))return n;let o=n.trim(),r=o.startsWith("(")&&o.endsWith(")"),u=n.indexOf(o)+(r?1:0),s=r?o.slice(1,-1):o,a=[[]],h=0;for(let i of t(s)){if(i.kind==="punctuation"&&s[i.start]===","&&h===0)a.push([]);else a[a.length-1].push(i);h+=C(s,i)}let m=a.map((i)=>{let l=0,d=-1;for(let[D,A]of i.entries()){if(l===0&&A.kind==="punctuation"&&s[A.start]===":"){d=D;break}l+=C(s,A)}let f=d>0&&s[i[d-1].start]==="?"?i[d-1]:void 0,y=i[0]?s.slice(i[0].start,i[0].end):"",q=i[0]&&s.startsWith("...",i[0].start);return{tokens:i,colon:d,question:f,required:i.length>0&&!f&&!q&&y!=="this"}}),c=-1;for(let[i,l]of m.entries())if(l.required)c=i;let e=[];for(let[i,l]of m.entries()){if(i>=c||!l.question||l.colon<0)continue;let d=l.tokens[l.colon+1],f=l.tokens.at(-1);if(!d||!f)continue;e.push({start:u+l.question.start,end:u+l.question.end,text:""},{start:u+d.start,end:u+d.start,text:"("},{start:u+f.end,end:u+f.end,text:") | undefined"})}if(!e.length)return n;let g=[],p=0;for(let i of e)g.push(n.slice(p,i.start),i.text),p=i.end;return g.push(n.slice(p)),g.join("")}function x(n){return n>=65&&n<=90||n>=97&&n<=122||n===95||n===36}function k(n,o){if(o>=n.length||!x(n.charCodeAt(o)))return o;let r=o+1;while(r<n.length&&(x(n.charCodeAt(r))||n.charCodeAt(r)>=48&&n.charCodeAt(r)<=57))r++;return r}function b(n,o){let r=o;while(r<n.length&&n.charCodeAt(r)<=32)r++;return r}function we(n,o){if(o.trim()!=="{}")return null;let r=n.trim();if(r.length<2||r[0]!=="{"||r[r.length-1]!=="}")return null;let u=r.slice(1,-1),s=[],a=0,h=0;for(let c=0;c<u.length;c++){let e=u.charCodeAt(c);if(e===34||e===39||e===96){c++;while(c<u.length&&u.charCodeAt(c)!==e){if(u.charCodeAt(c)===92)c++;c++}if(c>=u.length)return null;continue}if(e===47&&(u.charCodeAt(c+1)===47||u.charCodeAt(c+1)===42))return null;if(e===40||e===91||e===123)a++;else if(e===41||e===93||e===125){if(--a<0)return null}else if(e===44&&a===0)s.push(u.slice(h,c)),h=c+1}if(a!==0)return null;if(u.slice(h).trim()||s.length===0)s.push(u.slice(h));let m=[];for(let c of s){let e=c.trim(),g=k(e,0);if(g===0)return null;let p=e.slice(0,g),i=p,l=b(e,g);if(e.charCodeAt(l)===58){let f=b(e,l+1),y=k(e,f);if(y===f)return null;i=e.slice(f,y),l=b(e,y)}if(e.charCodeAt(l)!==61||e.charCodeAt(l+1)===61||e.charCodeAt(l+1)===62)return null;let d=e.slice(l+1).trim();if(!d)return null;m.push({key:p,alias:i,value:d})}return m}function je(n,o){let r=n.map((s)=>s.key===s.alias?s.key:`${s.key}: ${s.alias}`).join(", "),u=n.map((s)=>{let a=o(s.value),h=a==="unknown"||a==="any"?a:`${a.includes("=>")?`(${a})`:a} | undefined`;return`${s.key}?: ${h}`}).join("; ");return`{ ${r} }?: { ${u} }`}
|
|
3
|
+
export{_e,we,je};
|