@stacksjs/bun-router 0.0.27 → 0.1.0
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/chunk-0gjq8ttx.js +14 -0
- package/dist/chunk-0t5vz87j.js +35 -0
- package/dist/chunk-30rkn2ym.js +2 -0
- package/dist/chunk-38cmrard.js +2 -0
- package/dist/chunk-3qna6dwd.js +2 -0
- package/dist/chunk-4d5fmta0.js +2 -0
- package/dist/chunk-4x3b4b4q.js +2 -0
- package/dist/chunk-5be9x5cq.js +3 -0
- package/dist/chunk-5mxby3fd.js +1654 -0
- package/dist/chunk-5n0ckcmc.js +3 -0
- package/dist/chunk-5ncn73tp.js +3 -0
- package/dist/chunk-5s0pnsd6.js +12 -0
- package/dist/chunk-5s1pr62n.js +3 -0
- package/dist/chunk-67wgad4f.js +60 -0
- package/dist/chunk-6bbmkwng.js +3 -0
- package/dist/chunk-6s1kbajm.js +7851 -0
- package/dist/chunk-6sjvhy5f.js +3 -0
- package/dist/chunk-6xed4va1.js +2 -0
- package/dist/chunk-73k79n7q.js +15413 -0
- package/dist/chunk-748n6ydj.js +2 -0
- package/dist/chunk-7qnxdedn.js +321 -0
- package/dist/chunk-7rsf8tes.js +898 -0
- package/dist/chunk-8aspmtf1.js +2 -0
- package/dist/chunk-8wpj3fqe.js +351 -0
- package/dist/chunk-8yfdg595.js +2 -0
- package/dist/chunk-90eze7av.js +3 -0
- package/dist/chunk-9805tt8n.js +341 -0
- package/dist/chunk-9dvwyej7.js +2 -0
- package/dist/chunk-9ght4n4r.js +216 -0
- package/dist/chunk-a2w45krb.js +2 -0
- package/dist/chunk-a3wahyg7.js +3 -0
- package/dist/chunk-a547f2ab.js +48 -0
- package/dist/chunk-bqdycvtc.js +2 -0
- package/dist/chunk-brpgjyqg.js +3 -0
- package/dist/chunk-cd03rk3x.js +2 -0
- package/dist/chunk-csfrpsp7.js +185 -0
- package/dist/chunk-ct0m17q5.js +2 -0
- package/dist/chunk-dhbvvr5h.js +2 -0
- package/dist/chunk-dhptcsya.js +943 -0
- package/dist/chunk-dq93zag9.js +2 -0
- package/dist/chunk-dxg045wj.js +5 -0
- package/dist/chunk-e3qej0jr.js +4 -0
- package/dist/chunk-edrtesh7.js +2 -0
- package/dist/chunk-ejcws37w.js +2 -0
- package/dist/chunk-ex5fkjah.js +397 -0
- package/dist/chunk-ex890p45.js +51 -0
- package/dist/chunk-f69cpnhw.js +2 -0
- package/dist/chunk-fjf53b44.js +2 -0
- package/dist/chunk-fjzye4qj.js +2 -0
- package/dist/chunk-gfd23b6t.js +2 -0
- package/dist/chunk-habv0vef.js +12 -0
- package/dist/chunk-hmgedrmr.js +11 -0
- package/dist/chunk-hz6fc788.js +2 -0
- package/dist/chunk-jff6j9y3.js +10 -0
- package/dist/chunk-jmeb7n8k.js +70 -0
- package/dist/chunk-jrf5a2ap.js +2 -0
- package/dist/chunk-jy2jhcpy.js +246 -0
- package/dist/chunk-kc659vhx.js +4 -0
- package/dist/chunk-kjtjbcq4.js +71 -0
- package/dist/chunk-krkchy8v.js +4 -0
- package/dist/chunk-kxp888dn.js +4540 -0
- package/dist/chunk-m249t3je.js +3 -0
- package/dist/chunk-m9yabnjx.js +2 -0
- package/dist/chunk-mekrq9wd.js +2 -0
- package/dist/chunk-mmxv535f.js +82 -0
- package/dist/chunk-mypn7jss.js +2 -0
- package/dist/chunk-n18x1k3c.js +2 -0
- package/dist/chunk-nkddjzsa.js +2 -0
- package/dist/chunk-pjmhqmr9.js +2 -0
- package/dist/chunk-qyrnsaq1.js +2 -0
- package/dist/chunk-r19ff2qm.js +62 -0
- package/dist/chunk-r338fssq.js +2 -0
- package/dist/chunk-s36z58x2.js +29 -0
- package/dist/chunk-s3dn1kwx.js +231 -0
- package/dist/chunk-s79dd325.js +471 -0
- package/dist/chunk-sw0chtw4.js +4 -0
- package/dist/chunk-ta38j9em.js +2 -0
- package/dist/chunk-tpfgntwj.js +4211 -0
- package/dist/chunk-vr10sbbh.js +3 -0
- package/dist/chunk-vsh4390q.js +358 -0
- package/dist/chunk-vv3gb1m5.js +84 -0
- package/dist/chunk-vw8rwv6e.js +2 -0
- package/dist/chunk-w4r464v5.js +288 -0
- package/dist/chunk-wcrqs5z9.js +2 -0
- package/dist/chunk-x6d1rmwa.js +2 -0
- package/dist/chunk-x7ft15zz.js +2 -0
- package/dist/chunk-x8trwn7j.js +3 -0
- package/dist/chunk-xg9xscqz.js +1 -0
- package/dist/chunk-xhepdj1f.js +2 -0
- package/dist/chunk-xv2em0q4.js +4 -0
- package/dist/chunk-ypw6g0te.js +2 -0
- package/dist/chunk-z8szsm21.js +2 -0
- package/dist/chunk-zetqzgf3.js +194 -0
- package/dist/chunk-zfbh14qe.js +2 -0
- package/dist/chunk-zhx0hxdd.js +28 -0
- package/dist/cli.js +67 -3240
- package/dist/container/index.js +1 -321
- package/dist/index.js +80 -13987
- package/package.json +1 -1
- package/dist/chunk-1ahs68ys.js +0 -18
- package/dist/chunk-cgptvjdf.js +0 -18131
- package/dist/chunk-g3ybefhg.js +0 -1923
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Zu as b}from"./chunk-a3wahyg7.js";var n;async function f(){if(n!==void 0)return n;try{n=await import("bun-queue")}catch{n=null}return n}class u{channel;event;data;excludeSocketId;connection;queue;delay;tries;timeout;backoff;constructor(e,t,i,a){this.channel=e,this.event=t,this.data=i,this.excludeSocketId=a,this.tries=3,this.timeout=30000,this.backoff=[1000,5000]}async handle(e){try{e.broadcast(this.channel,this.event,this.data,this.excludeSocketId)}catch(t){throw console.error(`Failed to broadcast to ${this.channel}:`,t),t}}failed(e){console.error(`BroadcastJob failed for channel ${this.channel}:`,e.message)}}class c extends u{constructor(e,t,i,a,s){super(e,t,i,s);this.delay=a}}class d{channel;event;dataFn;cronExpression;connection;queue;delay;tries;timeout;constructor(e,t,i,a){this.channel=e,this.event=t,this.dataFn=i,this.cronExpression=a,this.tries=3,this.timeout=30000}async handle(e){try{let t=typeof this.dataFn==="function"?await this.dataFn():this.dataFn;e.broadcast(this.channel,this.event,t)}catch(t){throw console.error(`Failed to broadcast recurring event to ${this.channel}:`,t),t}}failed(e){console.error(`RecurringBroadcastJob failed for channel ${this.channel}:`,e.message)}}class g{queue=null;server;config;deadLetterQueue;constructor(e,t){if(this.server=e,this.config={enabled:t?.enabled??!1,connection:t?.connection||"default",defaultQueue:t?.defaultQueue||"broadcasts",retry:{attempts:t?.retry?.attempts??3,backoff:t?.retry?.backoff??{type:"exponential",delay:1000}},deadLetter:{enabled:t?.deadLetter?.enabled??!0,maxRetries:t?.deadLetter?.maxRetries??3}},this.config.enabled)this.initializeQueue()}async initializeQueue(){let e=await f();if(!e?.getQueueManager){console.warn("bun-queue is not installed. Queue features will be disabled."),this.config.enabled=!1;return}try{let t=e.getQueueManager();if(this.queue=t.connection(this.config.connection).queue(this.config.defaultQueue),this.config.deadLetter.enabled)this.deadLetterQueue=this.queue.getDeadLetterQueue();this.queue.processJobs(10),console.log(`\u2713 Broadcasting queue initialized: ${this.config.defaultQueue}`)}catch(t){console.error("Failed to initialize broadcasting queue:",t),this.config.enabled=!1}}async queueBroadcast(e,t,i,a){if(!this.isEnabled())throw Error("Queue system is not enabled");let s=Array.isArray(e)?e:[e],r=[];for(let o of s){let l=a?.delay?new c(o,t,i,a.delay,a?.excludeSocketId):new u(o,t,i,a?.excludeSocketId),h=await this.queue.dispatchJob(l,this.server);r.push(h)}return s.length===1?r[0]:r}async scheduleRecurringBroadcast(e,t,i,a){if(!this.isEnabled())throw Error("Queue system is not enabled");let s=new d(e,t,i,a);return await this.queue.scheduleCron({cron:a,data:{job:s,server:this.server},name:`recurring-broadcast-${e}-${t}`})}async cancelRecurringBroadcast(e){if(!this.isEnabled())return!1;return this.queue.unscheduleCron(e)}async getStats(){if(!this.isEnabled())return null;let e=await this.queue.getJobCounts(),t=this.deadLetterQueue?await this.deadLetterQueue.getJobs():[];return{waiting:e.waiting,active:e.active,completed:e.completed,failed:e.failed,delayed:e.delayed,deadLetter:t.length}}async getFailedJobs(e=0,t=-1){if(!this.isEnabled())return[];return this.queue.getJobs("failed",e,t)}async getDeadLetterJobs(e=0,t=-1){if(!this.isEnabled()||!this.deadLetterQueue)return[];return this.deadLetterQueue.getJobs(e,t)}async retryJob(e){if(!this.isEnabled())return null;return this.queue.retryJob(e)}async republishDeadLetterJob(e,t=!0){if(!this.isEnabled()||!this.deadLetterQueue)return null;return this.queue.republishDeadLetterJob(e,{resetRetries:t})}async clearFailedJobs(){if(!this.isEnabled())return;let e=(await this.queue.getJobs("failed")).map((t)=>t.id);if(e.length>0)await this.queue.bulkRemove(e)}async clearDeadLetterQueue(){if(!this.isEnabled()||!this.deadLetterQueue)return;await this.queue.clearDeadLetterQueue()}isEnabled(){return this.config.enabled&&this.queue!==null}async close(){if(this.queue)await this.queue.close(),this.queue=null}}
|
|
3
|
+
export{u as W,c as X,d as Y,g as Z};
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var f=0;function p(){return`async-${++f}-${Date.now().toString(36)}`}function w(e,t={},c){let o=/@async\s*\(([^)]*)\)\s*([\s\S]*?)@error\s*([\s\S]*?)@endasync/gi,a=/@async\s*\(([^)]*)\)\s*([\s\S]*?)@endasync/gi,n=e;return n=n.replace(o,(r,s,i,d)=>{let l=p(),y=u(s);return m(l,y,i.trim(),d.trim())}),n=n.replace(a,(r,s,i)=>{let d=p(),l=u(s);return m(d,l,i.trim(),'<div class="stx-async-error">Failed to load component</div>')}),n}function u(e){let t={component:"",timeout:30000,delay:200,suspensible:!0,retries:0},c=/(\w+)\s*:\s*(?:'([^']*)'|"([^"]*)"|(\d+)|(\w+))/g,o;while((o=c.exec(e))!==null){let a=o[1],n=o[2]||o[3],r=o[4],s=o[5];switch(a){case"component":t.component=n||s||"";break;case"timeout":t.timeout=r?parseInt(r,10):30000;break;case"delay":t.delay=r?parseInt(r,10):200;break;case"suspensible":t.suspensible=s==="true";break;case"retries":t.retries=r?parseInt(r,10):0;break;case"loadingComponent":t.loadingComponent=n||s;break;case"errorComponent":t.errorComponent=n||s;break}}return t}function m(e,t,c,o){let{component:a,timeout:n,delay:r,suspensible:s,retries:i}=t;return`
|
|
3
|
+
<div class="stx-async-component" data-async-id="${e}" data-component="${a}" data-status="pending">
|
|
4
|
+
<div class="stx-async-loading" data-async-loading="${e}">
|
|
5
|
+
${c}
|
|
6
|
+
</div>
|
|
7
|
+
<div class="stx-async-content" data-async-content="${e}" style="display: none;">
|
|
8
|
+
</div>
|
|
9
|
+
<div class="stx-async-error" data-async-error="${e}" style="display: none;">
|
|
10
|
+
${o}
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
<script>
|
|
14
|
+
(function() {
|
|
15
|
+
const asyncId = '${e}';
|
|
16
|
+
const componentPath = '${a}';
|
|
17
|
+
const timeout = ${n};
|
|
18
|
+
const delay = ${r};
|
|
19
|
+
const suspensible = ${s};
|
|
20
|
+
const maxRetries = ${i};
|
|
21
|
+
|
|
22
|
+
const container = document.querySelector('[data-async-id="' + asyncId + '"]');
|
|
23
|
+
const loadingEl = document.querySelector('[data-async-loading="' + asyncId + '"]');
|
|
24
|
+
const contentEl = document.querySelector('[data-async-content="' + asyncId + '"]');
|
|
25
|
+
const errorEl = document.querySelector('[data-async-error="' + asyncId + '"]');
|
|
26
|
+
|
|
27
|
+
if (!container || !loadingEl || !contentEl || !errorEl) return;
|
|
28
|
+
|
|
29
|
+
let attempts = 0;
|
|
30
|
+
let delayTimer = null;
|
|
31
|
+
let timeoutTimer = null;
|
|
32
|
+
let resolved = false;
|
|
33
|
+
let aborted = false;
|
|
34
|
+
|
|
35
|
+
// AbortController + container detachment guards (stacksjs/stx#1720). Without
|
|
36
|
+
// these, an in-flight fetch from a previous page would write innerHTML on
|
|
37
|
+
// a detached container after the user SPA-navigated away, or \u2014 for
|
|
38
|
+
// components removed via :if/parent toggle \u2014 would log a "rejected" state
|
|
39
|
+
// on a node that no longer exists. The router dispatches stx:navigate
|
|
40
|
+
// when a navigation starts; we treat that as a teardown signal. The
|
|
41
|
+
// isConnected check covers non-router unmounts (:if false, parent remove).
|
|
42
|
+
const controller = new AbortController();
|
|
43
|
+
function teardown() {
|
|
44
|
+
if (aborted) return;
|
|
45
|
+
aborted = true;
|
|
46
|
+
controller.abort();
|
|
47
|
+
clearTimeout(delayTimer);
|
|
48
|
+
clearTimeout(timeoutTimer);
|
|
49
|
+
window.removeEventListener('stx:navigate', teardown);
|
|
50
|
+
}
|
|
51
|
+
window.addEventListener('stx:navigate', teardown);
|
|
52
|
+
|
|
53
|
+
// Update state
|
|
54
|
+
function setState(status) {
|
|
55
|
+
container.setAttribute('data-status', status);
|
|
56
|
+
loadingEl.style.display = status === 'loading' ? '' : 'none';
|
|
57
|
+
contentEl.style.display = status === 'resolved' ? '' : 'none';
|
|
58
|
+
errorEl.style.display = status === 'rejected' ? '' : 'none';
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Show loading after delay
|
|
62
|
+
function showLoading() {
|
|
63
|
+
if (!resolved) {
|
|
64
|
+
setState('loading');
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Load component
|
|
69
|
+
async function loadComponent() {
|
|
70
|
+
attempts++;
|
|
71
|
+
|
|
72
|
+
// Start delay timer for loading state
|
|
73
|
+
delayTimer = setTimeout(showLoading, delay);
|
|
74
|
+
|
|
75
|
+
// Start timeout timer
|
|
76
|
+
timeoutTimer = setTimeout(function() {
|
|
77
|
+
if (!resolved) {
|
|
78
|
+
handleError(new Error('Component load timeout after ' + timeout + 'ms'));
|
|
79
|
+
}
|
|
80
|
+
}, timeout);
|
|
81
|
+
|
|
82
|
+
try {
|
|
83
|
+
// Notify Suspense boundary if suspensible
|
|
84
|
+
if (suspensible && window.STX && window.STX.suspense) {
|
|
85
|
+
window.STX.suspense.register(asyncId);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Fetch the component with the AbortController signal so a teardown
|
|
89
|
+
// (SPA navigation, component unmount) cancels the in-flight request.
|
|
90
|
+
const response = await fetch('/_stx/component/' + encodeURIComponent(componentPath), {
|
|
91
|
+
signal: controller.signal
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
if (!response.ok) {
|
|
95
|
+
throw new Error('Failed to load component: ' + response.statusText);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const html = await response.text();
|
|
99
|
+
|
|
100
|
+
// Clear timers
|
|
101
|
+
clearTimeout(delayTimer);
|
|
102
|
+
clearTimeout(timeoutTimer);
|
|
103
|
+
|
|
104
|
+
// Belt-and-suspenders: if the container was removed between the fetch
|
|
105
|
+
// starting and now (e.g. :if flipped to false, or a non-router parent
|
|
106
|
+
// mutation), bail before writing innerHTML on a detached node.
|
|
107
|
+
if (aborted || !container.isConnected) return;
|
|
108
|
+
|
|
109
|
+
resolved = true;
|
|
110
|
+
contentEl.innerHTML = html;
|
|
111
|
+
setState('resolved');
|
|
112
|
+
|
|
113
|
+
// Execute any scripts in the loaded component
|
|
114
|
+
contentEl.querySelectorAll('script').forEach(function(script) {
|
|
115
|
+
const newScript = document.createElement('script');
|
|
116
|
+
if (script.src) {
|
|
117
|
+
newScript.src = script.src;
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
newScript.textContent = script.textContent;
|
|
121
|
+
}
|
|
122
|
+
script.parentNode.replaceChild(newScript, script);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// Process signals/bindings on the loaded content ({{ }}, :attr, @event, etc.)
|
|
126
|
+
if (window.stx && window.stx._latestSetup) {
|
|
127
|
+
window.dispatchEvent(new Event('stx:load'));
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Notify Suspense boundary
|
|
131
|
+
if (suspensible && window.STX && window.STX.suspense) {
|
|
132
|
+
window.STX.suspense.resolve(asyncId);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Dispatch loaded event
|
|
136
|
+
container.dispatchEvent(new CustomEvent('stx:async:loaded', {
|
|
137
|
+
detail: { asyncId: asyncId, component: componentPath },
|
|
138
|
+
bubbles: true
|
|
139
|
+
}));
|
|
140
|
+
|
|
141
|
+
// Load succeeded \u2014 drop the navigate-teardown listener so it doesn't
|
|
142
|
+
// accumulate per async component across an app's lifetime.
|
|
143
|
+
window.removeEventListener('stx:navigate', teardown);
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
// AbortError fires when teardown() runs during an in-flight fetch.
|
|
147
|
+
// That's not a load failure \u2014 the component is being unmounted, so
|
|
148
|
+
// don't render the rejected state, don't retry, don't dispatch error.
|
|
149
|
+
if (aborted || (error && error.name === 'AbortError')) return;
|
|
150
|
+
handleError(error);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Handle errors
|
|
155
|
+
function handleError(error) {
|
|
156
|
+
clearTimeout(delayTimer);
|
|
157
|
+
clearTimeout(timeoutTimer);
|
|
158
|
+
|
|
159
|
+
// The container may have been removed (e.g., a non-router :if toggle)
|
|
160
|
+
// between the failure and now. No DOM left to write the error state to.
|
|
161
|
+
if (aborted || !container.isConnected) return;
|
|
162
|
+
|
|
163
|
+
if (attempts < maxRetries) {
|
|
164
|
+
// Retry
|
|
165
|
+
console.warn('[stx:async:' + asyncId + '] Retrying... (' + attempts + '/' + maxRetries + ')');
|
|
166
|
+
setTimeout(loadComponent, 1000 * attempts); // Exponential backoff
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
resolved = true;
|
|
171
|
+
setState('rejected');
|
|
172
|
+
|
|
173
|
+
// Update error content with error message
|
|
174
|
+
const errorMsgEl = errorEl.querySelector('[data-error-message]');
|
|
175
|
+
if (errorMsgEl) {
|
|
176
|
+
errorMsgEl.textContent = error.message;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// Notify Suspense boundary
|
|
180
|
+
if (suspensible && window.STX && window.STX.suspense) {
|
|
181
|
+
window.STX.suspense.reject(asyncId, error);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Dispatch error event
|
|
185
|
+
container.dispatchEvent(new CustomEvent('stx:async:error', {
|
|
186
|
+
detail: { asyncId: asyncId, component: componentPath, error: error },
|
|
187
|
+
bubbles: true
|
|
188
|
+
}));
|
|
189
|
+
|
|
190
|
+
console.error('[stx:async:' + asyncId + ']', error);
|
|
191
|
+
|
|
192
|
+
// Final error state \u2014 no more retries. Drop the navigate listener so it
|
|
193
|
+
// doesn't outlive the (failed) component.
|
|
194
|
+
window.removeEventListener('stx:navigate', teardown);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Retry function
|
|
198
|
+
function retry() {
|
|
199
|
+
resolved = false;
|
|
200
|
+
attempts = 0;
|
|
201
|
+
setState('pending');
|
|
202
|
+
loadComponent();
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// Expose retry function
|
|
206
|
+
window['$stxAsyncRetry_' + asyncId.replace(/-/g, '_')] = retry;
|
|
207
|
+
|
|
208
|
+
// Make $retry available within the error content
|
|
209
|
+
errorEl.querySelectorAll('[onclick*="$retry"]').forEach(function(el) {
|
|
210
|
+
const onclick = el.getAttribute('onclick');
|
|
211
|
+
if (onclick) {
|
|
212
|
+
el.setAttribute('onclick', onclick.replace(/\\$retry\\(\\)/g, "window['$stxAsyncRetry_" + asyncId.replace(/-/g, '_') + "']()"));
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
// Expose API
|
|
217
|
+
window.STX = window.STX || {};
|
|
218
|
+
window.STX.asyncComponents = window.STX.asyncComponents || {};
|
|
219
|
+
window.STX.asyncComponents[asyncId] = {
|
|
220
|
+
getStatus: function() { return container.getAttribute('data-status'); },
|
|
221
|
+
retry: retry,
|
|
222
|
+
getAttempts: function() { return attempts; }
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
// Start loading
|
|
226
|
+
loadComponent();
|
|
227
|
+
})();
|
|
228
|
+
</script>
|
|
229
|
+
`}function g(e){return{__asyncComponent:!0,...typeof e==="function"?{loader:e}:e}}function h(e){return typeof e==="object"&&e!==null&&"__asyncComponent"in e&&e.__asyncComponent===!0}function b(){return`
|
|
230
|
+
/* STX Async Component Styles */
|
|
231
|
+
.stx-async-component {
|
|
232
|
+
position: relative;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.stx-async-loading {
|
|
236
|
+
display: flex;
|
|
237
|
+
align-items: center;
|
|
238
|
+
justify-content: center;
|
|
239
|
+
min-height: 100px;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
.stx-async-error {
|
|
243
|
+
padding: 1rem;
|
|
244
|
+
border: 1px solid #ef4444;
|
|
245
|
+
border-radius: 0.5rem;
|
|
246
|
+
background-color: #fef2f2;
|
|
247
|
+
color: #991b1b;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.stx-async-error button {
|
|
251
|
+
margin-top: 0.5rem;
|
|
252
|
+
padding: 0.5rem 1rem;
|
|
253
|
+
border: 1px solid #ef4444;
|
|
254
|
+
border-radius: 0.25rem;
|
|
255
|
+
background-color: #ef4444;
|
|
256
|
+
color: white;
|
|
257
|
+
cursor: pointer;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.stx-async-error button:hover {
|
|
261
|
+
background-color: #dc2626;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/* Loading spinner animation */
|
|
265
|
+
@keyframes stx-async-spin {
|
|
266
|
+
to { transform: rotate(360deg); }
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.stx-async-spinner {
|
|
270
|
+
width: 24px;
|
|
271
|
+
height: 24px;
|
|
272
|
+
border: 2px solid #e5e7eb;
|
|
273
|
+
border-top-color: #3b82f6;
|
|
274
|
+
border-radius: 50%;
|
|
275
|
+
animation: stx-async-spin 0.8s linear infinite;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/* Skeleton loading */
|
|
279
|
+
.stx-async-skeleton {
|
|
280
|
+
background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
|
|
281
|
+
background-size: 200% 100%;
|
|
282
|
+
animation: stx-async-shimmer 1.5s infinite;
|
|
283
|
+
border-radius: 0.25rem;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
@keyframes stx-async-shimmer {
|
|
287
|
+
0% { background-position: 200% 0; }
|
|
288
|
+
100% { background-position: -200% 0; }
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/* Dark mode */
|
|
292
|
+
@media (prefers-color-scheme: dark) {
|
|
293
|
+
.stx-async-error {
|
|
294
|
+
background-color: #450a0a;
|
|
295
|
+
color: #fecaca;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.stx-async-skeleton {
|
|
299
|
+
background: linear-gradient(90deg, #374151 25%, #4b5563 50%, #374151 75%);
|
|
300
|
+
background-size: 200% 100%;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
`}function x(){return`
|
|
304
|
+
// STX Async Component Runtime
|
|
305
|
+
(function() {
|
|
306
|
+
if (typeof window === 'undefined') return;
|
|
307
|
+
|
|
308
|
+
window.STX = window.STX || {};
|
|
309
|
+
window.STX.asyncComponents = window.STX.asyncComponents || {};
|
|
310
|
+
|
|
311
|
+
// Load a component dynamically
|
|
312
|
+
window.STX.loadComponent = async function(componentPath, targetSelector, options) {
|
|
313
|
+
options = options || {};
|
|
314
|
+
const target = document.querySelector(targetSelector);
|
|
315
|
+
if (!target) {
|
|
316
|
+
throw new Error('Target element not found: ' + targetSelector);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
const loadingHtml = options.loading || '<div class="stx-async-spinner"></div>';
|
|
320
|
+
target.innerHTML = loadingHtml;
|
|
321
|
+
|
|
322
|
+
try {
|
|
323
|
+
const response = await fetch('/_stx/component/' + encodeURIComponent(componentPath));
|
|
324
|
+
if (!response.ok) {
|
|
325
|
+
throw new Error('Failed to load: ' + response.statusText);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
const html = await response.text();
|
|
329
|
+
target.innerHTML = html;
|
|
330
|
+
|
|
331
|
+
// Execute scripts
|
|
332
|
+
target.querySelectorAll('script').forEach(function(script) {
|
|
333
|
+
const newScript = document.createElement('script');
|
|
334
|
+
if (script.src) {
|
|
335
|
+
newScript.src = script.src;
|
|
336
|
+
}
|
|
337
|
+
else {
|
|
338
|
+
newScript.textContent = script.textContent;
|
|
339
|
+
}
|
|
340
|
+
script.parentNode.replaceChild(newScript, script);
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
if (options.onLoad) options.onLoad();
|
|
344
|
+
return true;
|
|
345
|
+
}
|
|
346
|
+
catch (error) {
|
|
347
|
+
if (options.error) {
|
|
348
|
+
target.innerHTML = options.error;
|
|
349
|
+
}
|
|
350
|
+
if (options.onError) options.onError(error);
|
|
351
|
+
throw error;
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
console.log('[stx] Async component runtime initialized');
|
|
356
|
+
})();
|
|
357
|
+
`}
|
|
358
|
+
export{w as Ke,g as Le,h as Me,b as Ne,x as Oe};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var h=0;function m(){return`stx-defer-${++h}`}function v(a){let n=a.match(/on:\s*['"]?(\w+)(?:\((\d+)\))?['"]?/);if(n)return{trigger:n[1],value:n[2]};return{trigger:"immediate"}}function p(a,n,o){let{trigger:l,value:r}=v(n),t=o,d,i,e,c=o.match(/@placeholder\s*([\s\S]*?)(?=@loading|@error|$)/);if(c)d=c[1].trim(),t=t.replace(/@placeholder[\s\S]*?(?=@loading|@error|$)/,"");let s=o.match(/@loading\s*([\s\S]*?)(?=@error|$)/);if(s)i=s[1].trim(),t=t.replace(/@loading[\s\S]*?(?=@error|$)/,"");let f=o.match(/@error(?:\s*\(\s*(\w+)\s*\))?\s*([\s\S]*)$/);if(f)e=f[2].trim(),t=t.replace(/@error(?:\s*\(\s*\w+\s*\))?[\s\S]*$/,"");return t=t.trim(),{trigger:l,triggerValue:r,content:t,placeholder:d,loading:i,error:e}}function E(a,n){let{trigger:o,triggerValue:l}=n,r;switch(o){case"visible":r=`
|
|
3
|
+
const observer = new IntersectionObserver((entries) => {
|
|
4
|
+
if (entries[0].isIntersecting) {
|
|
5
|
+
observer.disconnect();
|
|
6
|
+
loadContent();
|
|
7
|
+
}
|
|
8
|
+
}, { threshold: 0.1 });
|
|
9
|
+
observer.observe(container);
|
|
10
|
+
`;break;case"idle":r=`
|
|
11
|
+
if ('requestIdleCallback' in window) {
|
|
12
|
+
requestIdleCallback(() => loadContent(), { timeout: 3000 });
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
setTimeout(loadContent, 200);
|
|
16
|
+
}
|
|
17
|
+
`;break;case"interaction":r=`
|
|
18
|
+
const events = ['click', 'focus', 'touchstart'];
|
|
19
|
+
const handler = () => {
|
|
20
|
+
events.forEach(e => container.removeEventListener(e, handler));
|
|
21
|
+
loadContent();
|
|
22
|
+
};
|
|
23
|
+
events.forEach(e => container.addEventListener(e, handler, { once: true, passive: true }));
|
|
24
|
+
`;break;case"hover":r=`
|
|
25
|
+
const handler = () => {
|
|
26
|
+
container.removeEventListener('mouseenter', handler);
|
|
27
|
+
container.removeEventListener('focusin', handler);
|
|
28
|
+
loadContent();
|
|
29
|
+
};
|
|
30
|
+
container.addEventListener('mouseenter', handler, { once: true });
|
|
31
|
+
container.addEventListener('focusin', handler, { once: true });
|
|
32
|
+
`;break;case"timer":r=`
|
|
33
|
+
setTimeout(loadContent, ${l||"1000"});
|
|
34
|
+
`;break;case"immediate":default:r=`
|
|
35
|
+
Promise.resolve().then(loadContent);
|
|
36
|
+
`;break}return`
|
|
37
|
+
<script>
|
|
38
|
+
(function() {
|
|
39
|
+
const container = document.getElementById('${a}');
|
|
40
|
+
if (!container) return;
|
|
41
|
+
|
|
42
|
+
const contentEl = container.querySelector('[data-defer-content]');
|
|
43
|
+
const placeholderEl = container.querySelector('[data-defer-placeholder]');
|
|
44
|
+
const loadingEl = container.querySelector('[data-defer-loading]');
|
|
45
|
+
const errorEl = container.querySelector('[data-defer-error]');
|
|
46
|
+
|
|
47
|
+
function showElement(el) {
|
|
48
|
+
if (el) el.style.display = '';
|
|
49
|
+
}
|
|
50
|
+
function hideElement(el) {
|
|
51
|
+
if (el) el.style.display = 'none';
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function loadContent() {
|
|
55
|
+
hideElement(placeholderEl);
|
|
56
|
+
showElement(loadingEl);
|
|
57
|
+
|
|
58
|
+
// Simulate async load (content is already rendered but hidden)
|
|
59
|
+
Promise.resolve().then(() => {
|
|
60
|
+
hideElement(loadingEl);
|
|
61
|
+
showElement(contentEl);
|
|
62
|
+
container.dispatchEvent(new CustomEvent('defer:loaded'));
|
|
63
|
+
}).catch((err) => {
|
|
64
|
+
hideElement(loadingEl);
|
|
65
|
+
if (errorEl) {
|
|
66
|
+
showElement(errorEl);
|
|
67
|
+
}
|
|
68
|
+
console.error('Defer load error:', err);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
${r}
|
|
73
|
+
})();
|
|
74
|
+
</script>
|
|
75
|
+
`}function $(a,n,o){h=0;let l=/@defer\s*\(([^)]*)\)\s*([\s\S]*?)@enddefer/g;return a.replace(l,(r,t,d)=>{let i=m(),e=p(r,t,d),c=e.placeholder?`<div data-defer-placeholder>${e.placeholder}</div>`:"",s=e.loading?`<div data-defer-loading style="display: none;">${e.loading}</div>`:'<div data-defer-loading style="display: none;"></div>',f=e.error?`<div data-defer-error style="display: none;">${e.error}</div>`:"",u=`<div data-defer-content style="display: none;">${e.content}</div>`,g=E(i,e);return`
|
|
76
|
+
<div id="${i}" class="stx-defer" data-defer-trigger="${e.trigger}">
|
|
77
|
+
${c}
|
|
78
|
+
${s}
|
|
79
|
+
${u}
|
|
80
|
+
${f}
|
|
81
|
+
</div>
|
|
82
|
+
${g}
|
|
83
|
+
`})}
|
|
84
|
+
export{$ as we};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{$ as a,$a as aa,$b as ab,$c as ac,Aa as B,Ab as Ba,Ac as Bb,Ad as Bc,Ba as C,Bb as Ca,Bc as Cb,Bd as Cc,Ca as D,Cb as Da,Cc as Db,Cd as Dc,Da as E,Db as Ea,Dc as Eb,Dd as Ec,Ea as F,Eb as Fa,Ec as Fb,Ed as Fc,Fa as G,Fb as Ga,Fc as Gb,Fd as Gc,Ga as H,Gb as Ha,Gc as Hb,Gd as Hc,Ha as I,Hb as Ia,Hc as Ib,Hd as Ic,Ia as J,Ib as Ja,Ic as Jb,Id as Jc,Ja as K,Jb as Ka,Jc as Kb,Jd as Kc,Ka as L,Kb as La,Kc as Lb,Kd as Lc,La as M,Lb as Ma,Lc as Mb,Ld as Mc,Ma as N,Mb as Na,Mc as Nb,Md as Nc,Na as O,Nb as Oa,Nc as Ob,Nd as Oc,Oa as P,Ob as Pa,Oc as Pb,Od as Pc,Pa as Q,Pb as Qa,Pc as Qb,Pd as Qc,Qa as R,Qb as Ra,Qc as Rb,Qd as Rc,Ra as S,Rb as Sa,Rc as Sb,Rd as Sc,Sa as T,Sb as Ta,Sc as Tb,Sd as Tc,Ta as U,Tb as Ua,Tc as Ub,Ua as V,Ub as Va,Uc as Vb,Va as W,Vb as Wa,Vc as Wb,Wa as X,Wb as Xa,Wc as Xb,Xa as Y,Xb as Ya,Xc as Yb,Ya as Z,Yb as Za,Yc as Zb,Za as _,Zb as _a,Zc as _b,_a as $,_b as $a,_c as $b,aa as b,ab as ba,ac as bb,ad as bc,ba as c,bb as ca,bc as cb,bd as cc,ca as d,cb as da,cc as db,cd as dc,da as e,db as ea,dc as eb,dd as ec,ea as f,eb as fa,ec as fb,ed as fc,fa as g,fb as ga,fc as gb,fd as gc,ga as h,gb as ha,gc as hb,gd as hc,ha as i,hb as ia,hc as ib,hd as ic,ia as j,ib as ja,ic as jb,id as jc,ja as k,jb as ka,jc as kb,jd as kc,ka as l,kb as la,kc as lb,kd as lc,la as m,lb as ma,lc as mb,ld as mc,ma as n,mb as na,mc as nb,md as nc,na as o,nb as oa,nc as ob,nd as oc,oa as p,ob as pa,oc as pb,od as pc,pa as q,pb as qa,pc as qb,pd as qc,qa as r,qb as ra,qc as rb,qd as rc,ra as s,rb as sa,rc as sb,rd as sc,sa as t,sb as ta,sc as tb,sd as tc,ta as u,tb as ua,tc as ub,td as uc,ua as v,ub as va,uc as vb,ud as vc,va as w,vb as wa,vc as wb,vd as wc,wa as x,wb as xa,wc as xb,wd as xc,xa as y,xb as ya,xc as yb,xd as yc,ya as z,yb as za,yc as zb,yd as zc,za as A,zb as Aa,zc as Ab,zd as Ac}from"./chunk-dhptcsya.js";import"./chunk-a3wahyg7.js";export{zb as writeText,Bb as writeHTML,U as writeBinaryFile,Wa as workManager,nb as windowsWidgets,mb as windowsHello,n as windowManager,ib as windowManagement,p as window,o as win,Y as watch,Kc as vueOptimizations,ma as verifyPassword,rc as variants,ha as uuid,Nc as updater,mc as updateTouchBarItem,jc as updateToolbarItem,R as unregisterShortcut,pc as tw,t as trayManager,u as tray,ab as touchBar,lb as toastNotifications,Sa as tipKit,ka as timingSafeEqual,ya as tempDir,kb as taskbarProgress,vc as tahoeStyles,Lb as tahoeStyle,Ec as tahoeDemoData,Lc as svelteOptimizations,A as submenu,Ic as styles,sc as style,Qa as storeKit,V as stat,qb as startupTask,cb as stageManager,fb as spotlight,va as spawn,eb as sidecar,yc as sidebarUtils,Tb as sidebarSeparator,Sb as sidebarSection,Rb as sidebarItem,zc as sidebarCSSVariables,Jb as sidebar,ac as showQuickLook,xb as showPrompt,ec as showFontPicker,H as showDockIcon,fc as showDatePicker,wb as showConfirm,dc as showColorPicker,vb as showAlert,Sc as show,pb as shareTarget,Pa as sharePlay,hb as shareExtension,Ja as share,lc as setTouchBar,kc as setToolbarVisible,ic as setToolbar,I as setBadge,x as separator,Ha as secureStorage,rb as secondaryTiles,ub as saveFile,a as resolveCraftBinary,j as requireCraftRuntime,Bc as renderTahoeSidebar,Dc as renderOrbStackSidebar,Cc as renderArcSidebar,Q as registerShortcut,Ab as readText,Cb as readHTML,T as readBinaryFile,Jc as reactOptimizations,ia as randomString,D as quit,gb as quickActions,Ya as predictiveBack,$a as playBilling,Va as photoPicker,Ea as permissions,c as packageApp,d as pack,xc as orbstackStyles,Nb as orbstackStyle,Gc as orbstackDemoData,tb as openFolder,sb as openFile,_ as openDatabase,Ba as open,P as notify,La as notifications,La as notification,ob as msixUpdate,X as move,y as menuItem,Eb as media,Ua as materialYou,Ia as location,Tc as loadURL,Oa as liveActivities,Ka as lifecycle,jb as jumpList,qa as isMobile,pa as isDesktop,N as isDarkMode,f as isCraftRuntime,ra as isCraft,ba as http,xa as homeDir,ja as hmac,bc as hideQuickLook,G as hideDockIcon,E as hide,la as hashPassword,Da as haptics,db as handoff,K as getVersion,sa as getSystemInfo,Ac as getSidebarStyle,oa as getPlatform,M as getPath,h as getNativeBridgeCall,L as getName,O as getLocale,J as getInfo,Hc as getFullPageHTML,g as getCraft,Pc as generateUpdateManifest,tc as generateConfig,S as fs,Xa as foregroundService,Ta as focusFilters,F as focus,za as exit,ta as exec,na as env,yb as dialog,Ca as device,bb as desktopWidgets,Z as db,qc as cx,wa as cwd,ga as crypto,q as createWindow,Ob as createTahoeSidebar,_b as createTableView,Ub as createSplitView,Gb as createSidebar,Ib as createSettingsSidebar,gc as createProgress,Yb as createOutlineView,Qb as createOrbStackSidebar,v as createMenubarApp,Hb as createFileSidebar,Wb as createFileBrowser,fa as createClient,Pb as createArcSidebar,Rc as createApp,i as craftUnavailableMessage,b as craftBinaryNotFoundMessage,W as copy,Kb as components,Mc as commonOptimizations,qc as clsx,Db as clipboard,z as checkbox,Ma as carplay,cc as canQuickLook,Fa as camera,w as buildMenu,uc as buildCSS,Ga as biometrics,Aa as argv,wc as arcStyles,Mb as arcStyle,Fc as arcDemoData,B as appManager,Za as appLanguage,Ra as appIntents,Na as appClips,C as app,_a as androidWidgets,m as Window,ea as WebSocketClient,l as Timer,$b as TableViewInstance,r as SystemTray,nc as StyleSheet,k as Storage,Vb as SplitViewInstance,Fb as Sidebar,hc as ProgressInstance,Zb as OutlineViewInstance,s as MenubarApp,aa as KeyValueStore,da as HttpError,ca as HttpClient,Xb as FileBrowserInstance,$ as Database,Qc as CraftApp,ua as ChildProcess,Oc as AutoUpdater,e as AudioManager,oc as Animated};
|