@stacksjs/stx 0.2.195 → 0.2.197
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-0ae6chzd.js +4 -0
- package/dist/chunk-0w0mrtme.js +2 -0
- package/dist/chunk-0y46fbkx.js +3 -0
- package/dist/chunk-118a77bs.js +4471 -0
- package/dist/chunk-12nvcvtn.js +3 -0
- package/dist/chunk-14ynv5ah.js +2 -0
- package/dist/chunk-1e25ksp6.js +3 -0
- package/dist/chunk-1mhc4g86.js +43 -0
- package/dist/chunk-1thssz8x.js +2 -0
- package/dist/chunk-1yk07x7b.js +2 -0
- package/dist/chunk-2zkj69dg.js +13 -0
- package/dist/chunk-338316c2.js +2 -0
- package/dist/chunk-3952ykhb.js +1655 -0
- package/dist/chunk-3es366z4.js +3 -0
- package/dist/chunk-3m49eb4v.js +2 -0
- package/dist/chunk-3nmpfsw5.js +2 -0
- package/dist/chunk-3vy1q9da.js +2 -0
- package/dist/chunk-4a4h28pp.js +3022 -0
- package/dist/chunk-4pf61rcb.js +2 -0
- package/dist/chunk-5anpcnde.js +2 -0
- package/dist/chunk-5mkkre22.js +505 -0
- package/dist/chunk-5n0dt838.js +2 -0
- package/dist/chunk-5s2y052b.js +2 -0
- package/dist/chunk-5v64c8tr.js +2 -0
- package/dist/chunk-5xd7vge2.js +2 -0
- package/dist/chunk-6bxcjdp4.js +2 -0
- package/dist/chunk-6msvxnbr.js +2 -0
- package/dist/chunk-7kger0se.js +1280 -0
- package/dist/chunk-7ry55nms.js +3 -0
- package/dist/chunk-7s0wfa4e.js +24 -0
- package/dist/chunk-7w4c5w2b.js +2 -0
- package/dist/chunk-8src5smc.js +15 -0
- package/dist/chunk-937effkz.js +2 -0
- package/dist/chunk-9b82d4g5.js +3 -0
- package/dist/chunk-9xh78snm.js +3 -0
- package/dist/chunk-a2899x2t.js +2 -0
- package/dist/chunk-abpw3b39.js +2 -0
- package/dist/chunk-avwj12at.js +194 -0
- package/dist/chunk-b6jhznkh.js +71 -0
- package/dist/chunk-bpa2jeyw.js +3 -0
- package/dist/chunk-cbc56wpd.js +3 -0
- package/dist/chunk-dhpy0h9y.js +2 -0
- package/dist/chunk-dtmwr674.js +302 -0
- package/dist/chunk-dxfcyj8t.js +2 -0
- package/dist/chunk-e0460y7f.js +29 -0
- package/dist/chunk-ede7zpjf.js +2 -0
- package/dist/chunk-ehfzp7xe.js +2 -0
- package/dist/chunk-fd77g6t6.js +2 -0
- package/dist/chunk-fnkxbnka.js +30 -0
- package/dist/chunk-fvjh7rx0.js +84 -0
- package/dist/chunk-g19skgmw.js +18 -0
- package/dist/chunk-gcnrdgrq.js +3 -0
- package/dist/chunk-h2wpnxrh.js +8 -0
- package/dist/chunk-hb83d0qc.js +2 -0
- package/dist/chunk-hncp9gz6.js +8 -0
- package/dist/chunk-ht51fz7w.js +4 -0
- package/dist/chunk-hyrjade7.js +321 -0
- package/dist/chunk-hyyzp99b.js +2 -0
- package/dist/chunk-jpbk42j7.js +2 -0
- package/dist/chunk-jr5tp4ks.js +2 -0
- package/dist/chunk-k03b9z9e.js +898 -0
- package/dist/chunk-kjr22neh.js +3 -0
- package/dist/chunk-mjt5e2jy.js +2 -0
- package/dist/chunk-mkm91b6w.js +2 -0
- package/dist/chunk-mtr2f82n.js +2 -0
- package/dist/chunk-n8zpm7xb.js +397 -0
- package/dist/chunk-ndnc7k2n.js +22 -0
- package/dist/chunk-nenge2m2.js +2 -0
- package/dist/chunk-nngpktr2.js +2 -0
- package/dist/chunk-nsjyn31z.js +2 -0
- package/dist/chunk-nye9brje.js +147 -0
- package/dist/chunk-p5kp35dy.js +2 -0
- package/dist/chunk-pw0rzgpv.js +3 -0
- package/dist/chunk-q020t182.js +2 -0
- package/dist/chunk-q4gp9egt.js +4 -0
- package/dist/chunk-q8szpd6w.js +3 -0
- package/dist/chunk-q9n5swx7.js +3 -0
- package/dist/chunk-qpcwahse.js +2 -0
- package/dist/chunk-qz75kx6n.js +231 -0
- package/dist/chunk-r41nsgym.js +116 -0
- package/dist/chunk-r4qnvxhv.js +18 -0
- package/dist/chunk-r6p4ws0a.js +3809 -0
- package/dist/chunk-rdf7d42n.js +2 -0
- package/dist/chunk-rs2fa3g1.js +2 -0
- package/dist/chunk-ryjpp51z.js +499 -0
- package/dist/chunk-s018d32j.js +30 -0
- package/dist/chunk-spn8e3b3.js +2 -0
- package/dist/chunk-sry9atvv.js +2 -0
- package/dist/chunk-st5qggks.js +3 -0
- package/dist/chunk-tywvd1zc.js +11 -0
- package/dist/chunk-v3ryxw4v.js +2 -0
- package/dist/chunk-va9k88da.js +2 -0
- package/dist/chunk-vgk5v31k.js +216 -0
- package/dist/chunk-vj320kyr.js +2 -0
- package/dist/chunk-vr3qtsj4.js +2 -0
- package/dist/chunk-w0ng9e1m.js +341 -0
- package/dist/chunk-w29sv5jf.js +2 -0
- package/dist/chunk-whq99ytc.js +7987 -0
- package/dist/chunk-wnaddtv3.js +288 -0
- package/dist/chunk-wtengj6h.js +2 -0
- package/dist/chunk-x0ks1fer.js +1194 -0
- package/dist/chunk-x0zh76yv.js +4 -0
- package/dist/chunk-x13f5bbe.js +358 -0
- package/dist/chunk-xfp10a23.js +2 -0
- package/dist/chunk-xp3fp266.js +11 -0
- package/dist/chunk-xz019t7t.js +2 -0
- package/dist/chunk-y35rktea.js +12 -0
- package/dist/chunk-y4hkqsgw.js +4 -0
- package/dist/chunk-yab6d6kb.js +28 -0
- package/dist/chunk-yckd6ks5.js +3 -0
- package/dist/chunk-ycn1vnv2.js +5 -0
- package/dist/chunk-yf3bmmkk.js +8 -0
- package/dist/chunk-ygr11tgz.js +3 -0
- package/dist/chunk-ymccpdg6.js +351 -0
- package/dist/chunk-yr2wc2pa.js +3 -0
- package/dist/chunk-yv340gxj.js +2 -0
- package/dist/chunk-z2sp0k8d.js +3 -0
- package/dist/chunk-z5cm0bwn.js +11 -0
- package/dist/chunk-zda3hvde.js +14 -0
- package/dist/chunk-zgvga8rc.js +5 -0
- package/dist/chunk-zqbw8zqq.js +3 -0
- package/dist/cli.js +108 -27481
- package/dist/craft-entry.js +9 -5
- package/dist/craft.js +7 -18503
- package/dist/database.js +2 -2
- package/dist/pwa.js +8 -16603
- package/dist/ssg.js +52 -15512
- package/dist/visual-testing.js +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var L=0;function G(){return`keep-alive-${++L}-${Date.now().toString(36)}`}function Q(f,j={},q){let z=/@keepAlive(?:\s*\(([^)]*)\))?\s*([\s\S]*?)@endkeepAlive/gi;return f.replace(z,(E,B,D)=>{let F=G(),J=M(B||"");return P(F,D.trim(),J)})}function M(f){let j={max:10},q=/(\w+)\s*:\s*(?:'([^']*)'|"([^"]*)"|(\d+)|(\w+))/g,z;while((z=q.exec(f))!==null){let E=z[1],B=z[2]||z[3],D=z[4];switch(E){case"max":j.max=D?parseInt(D,10):10;break;case"include":j.include=B;break;case"exclude":j.exclude=B;break;case"id":j.id=B;break}}return j}function P(f,j,q){let{max:z,include:E,exclude:B}=q,D=q.id||f;return`
|
|
3
|
+
<div class="stx-keep-alive" data-keep-alive-id="${f}" data-custom-id="${D}">
|
|
4
|
+
<div class="stx-keep-alive-content" data-keep-alive-content="${f}">
|
|
5
|
+
${j}
|
|
6
|
+
</div>
|
|
7
|
+
<div class="stx-keep-alive-cache" data-keep-alive-cache="${f}" style="display: none;">
|
|
8
|
+
</div>
|
|
9
|
+
</div>
|
|
10
|
+
<script>
|
|
11
|
+
(function() {
|
|
12
|
+
const keepAliveId = '${f}';
|
|
13
|
+
const customId = '${D}';
|
|
14
|
+
const maxCache = ${z||10};
|
|
15
|
+
const includeFilter = ${E?JSON.stringify(E.split(",").map((F)=>F.trim())):"null"};
|
|
16
|
+
const excludeFilter = ${B?JSON.stringify(B.split(",").map((F)=>F.trim())):"null"};
|
|
17
|
+
|
|
18
|
+
const container = document.querySelector('[data-keep-alive-id="' + keepAliveId + '"]');
|
|
19
|
+
const contentEl = document.querySelector('[data-keep-alive-content="' + keepAliveId + '"]');
|
|
20
|
+
const cacheEl = document.querySelector('[data-keep-alive-cache="' + keepAliveId + '"]');
|
|
21
|
+
|
|
22
|
+
if (!container || !contentEl || !cacheEl) return;
|
|
23
|
+
|
|
24
|
+
// LRU Cache
|
|
25
|
+
const cache = new Map();
|
|
26
|
+
const cacheOrder = [];
|
|
27
|
+
|
|
28
|
+
// Check if component should be cached
|
|
29
|
+
function shouldCache(componentName) {
|
|
30
|
+
if (excludeFilter && excludeFilter.includes(componentName)) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
if (includeFilter && !includeFilter.includes(componentName)) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Get component key from element
|
|
40
|
+
function getComponentKey(element) {
|
|
41
|
+
// Try various ways to identify the component
|
|
42
|
+
return element.getAttribute('data-component') ||
|
|
43
|
+
element.getAttribute('data-key') ||
|
|
44
|
+
element.id ||
|
|
45
|
+
element.className.split(' ')[0] ||
|
|
46
|
+
element.tagName.toLowerCase();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Save scroll positions
|
|
50
|
+
function saveScrollPositions(element) {
|
|
51
|
+
const positions = new Map();
|
|
52
|
+
// eslint-disable-next-line pickier/no-unused-vars
|
|
53
|
+
element.querySelectorAll('[data-keep-scroll]').forEach(function(el) {
|
|
54
|
+
const key = el.getAttribute('data-keep-scroll') || el.id || 'default';
|
|
55
|
+
positions.set(key, { top: el.scrollTop, left: el.scrollLeft });
|
|
56
|
+
});
|
|
57
|
+
// Also save the element's own scroll if scrollable
|
|
58
|
+
if (element.scrollHeight > element.clientHeight || element.scrollWidth > element.clientWidth) {
|
|
59
|
+
positions.set('__self__', { top: element.scrollTop, left: element.scrollLeft });
|
|
60
|
+
}
|
|
61
|
+
return positions;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Restore scroll positions
|
|
65
|
+
function restoreScrollPositions(element, positions) {
|
|
66
|
+
if (!positions) return;
|
|
67
|
+
|
|
68
|
+
positions.forEach(function(pos, key) {
|
|
69
|
+
if (key === '__self__') {
|
|
70
|
+
element.scrollTop = pos.top;
|
|
71
|
+
element.scrollLeft = pos.left;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
const el = element.querySelector('[data-keep-scroll="' + key + '"]') ||
|
|
75
|
+
document.getElementById(key);
|
|
76
|
+
if (el) {
|
|
77
|
+
el.scrollTop = pos.top;
|
|
78
|
+
el.scrollLeft = pos.left;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Save component state (form values, etc.)
|
|
85
|
+
function saveComponentState(element) {
|
|
86
|
+
const state = {};
|
|
87
|
+
|
|
88
|
+
// Save form inputs
|
|
89
|
+
// eslint-disable-next-line pickier/no-unused-vars
|
|
90
|
+
element.querySelectorAll('input, textarea, select').forEach(function(input, index) {
|
|
91
|
+
const key = input.name || input.id || 'input_' + index;
|
|
92
|
+
if (input.type === 'checkbox' || input.type === 'radio') {
|
|
93
|
+
state[key] = input.checked;
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
state[key] = input.value;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// Save data attributes marked for keeping
|
|
101
|
+
// eslint-disable-next-line pickier/no-unused-vars
|
|
102
|
+
element.querySelectorAll('[data-keep-state]').forEach(function(el) {
|
|
103
|
+
const key = el.getAttribute('data-keep-state');
|
|
104
|
+
const value = el.getAttribute('data-state-value') || el.textContent;
|
|
105
|
+
state['__data__' + key] = value;
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
return state;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Restore component state
|
|
112
|
+
function restoreComponentState(element, state) {
|
|
113
|
+
if (!state) return;
|
|
114
|
+
|
|
115
|
+
// Restore form inputs
|
|
116
|
+
// eslint-disable-next-line pickier/no-unused-vars
|
|
117
|
+
element.querySelectorAll('input, textarea, select').forEach(function(input, index) {
|
|
118
|
+
const key = input.name || input.id || 'input_' + index;
|
|
119
|
+
if (state[key] !== undefined) {
|
|
120
|
+
if (input.type === 'checkbox' || input.type === 'radio') {
|
|
121
|
+
input.checked = state[key];
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
input.value = state[key];
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Cache a component
|
|
131
|
+
function cacheComponent(key, element) {
|
|
132
|
+
if (!shouldCache(key)) return;
|
|
133
|
+
|
|
134
|
+
// Remove from cache order if exists (for LRU)
|
|
135
|
+
const existingIndex = cacheOrder.indexOf(key);
|
|
136
|
+
if (existingIndex > -1) {
|
|
137
|
+
cacheOrder.splice(existingIndex, 1);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Evict oldest if at max capacity
|
|
141
|
+
while (cacheOrder.length >= maxCache) {
|
|
142
|
+
const oldestKey = cacheOrder.shift();
|
|
143
|
+
const oldCached = cache.get(oldestKey);
|
|
144
|
+
if (oldCached && oldCached.element) {
|
|
145
|
+
oldCached.element.remove();
|
|
146
|
+
}
|
|
147
|
+
cache.delete(oldestKey);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Clone and cache
|
|
151
|
+
const clone = element.cloneNode(true);
|
|
152
|
+
clone.style.display = 'none';
|
|
153
|
+
clone.setAttribute('data-cached-key', key);
|
|
154
|
+
|
|
155
|
+
const cached = {
|
|
156
|
+
key: key,
|
|
157
|
+
element: clone,
|
|
158
|
+
state: saveComponentState(element),
|
|
159
|
+
scrollPositions: saveScrollPositions(element),
|
|
160
|
+
cachedAt: Date.now()
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
cache.set(key, cached);
|
|
164
|
+
cacheOrder.push(key);
|
|
165
|
+
cacheEl.appendChild(clone);
|
|
166
|
+
|
|
167
|
+
// Dispatch deactivated event
|
|
168
|
+
element.dispatchEvent(new CustomEvent('stx:deactivated', {
|
|
169
|
+
detail: { key: key, keepAliveId: keepAliveId },
|
|
170
|
+
bubbles: true
|
|
171
|
+
}));
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Restore a component from cache
|
|
175
|
+
function restoreComponent(key) {
|
|
176
|
+
const cached = cache.get(key);
|
|
177
|
+
if (!cached) return null;
|
|
178
|
+
|
|
179
|
+
// Move to end of cache order (most recently used)
|
|
180
|
+
const index = cacheOrder.indexOf(key);
|
|
181
|
+
if (index > -1) {
|
|
182
|
+
cacheOrder.splice(index, 1);
|
|
183
|
+
cacheOrder.push(key);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Clone the cached element
|
|
187
|
+
const restored = cached.element.cloneNode(true);
|
|
188
|
+
restored.style.display = '';
|
|
189
|
+
restored.removeAttribute('data-cached-key');
|
|
190
|
+
|
|
191
|
+
// Restore state after a tick (to let DOM settle)
|
|
192
|
+
setTimeout(function() {
|
|
193
|
+
restoreComponentState(restored, cached.state);
|
|
194
|
+
restoreScrollPositions(restored, cached.scrollPositions);
|
|
195
|
+
|
|
196
|
+
// Dispatch activated event
|
|
197
|
+
restored.dispatchEvent(new CustomEvent('stx:activated', {
|
|
198
|
+
detail: { key: key, keepAliveId: keepAliveId, cachedAt: cached.cachedAt },
|
|
199
|
+
bubbles: true
|
|
200
|
+
}));
|
|
201
|
+
}, 0);
|
|
202
|
+
|
|
203
|
+
return restored;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// Check if component is cached
|
|
207
|
+
function isCached(key) {
|
|
208
|
+
return cache.has(key);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// Clear cache
|
|
212
|
+
function clearCache(key) {
|
|
213
|
+
if (key) {
|
|
214
|
+
const cached = cache.get(key);
|
|
215
|
+
if (cached && cached.element) {
|
|
216
|
+
cached.element.remove();
|
|
217
|
+
}
|
|
218
|
+
cache.delete(key);
|
|
219
|
+
const index = cacheOrder.indexOf(key);
|
|
220
|
+
if (index > -1) {
|
|
221
|
+
cacheOrder.splice(index, 1);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
cache.forEach(function(cached) {
|
|
226
|
+
if (cached.element) {
|
|
227
|
+
cached.element.remove();
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
cache.clear();
|
|
231
|
+
cacheOrder.length = 0;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// Expose API
|
|
236
|
+
window.STX = window.STX || {};
|
|
237
|
+
window.STX.keepAlive = window.STX.keepAlive || { instances: {} };
|
|
238
|
+
window.STX.keepAlive.instances[keepAliveId] = {
|
|
239
|
+
id: keepAliveId,
|
|
240
|
+
customId: customId,
|
|
241
|
+
cache: cacheComponent,
|
|
242
|
+
restore: restoreComponent,
|
|
243
|
+
isCached: isCached,
|
|
244
|
+
clear: clearCache,
|
|
245
|
+
getCacheKeys: function() { return Array.from(cache.keys()); },
|
|
246
|
+
getCacheSize: function() { return cache.size; }
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
// Observe for component changes
|
|
250
|
+
const observer = new MutationObserver(function(mutations) {
|
|
251
|
+
mutations.forEach(function(mutation) {
|
|
252
|
+
// Handle removed nodes (cache them)
|
|
253
|
+
mutation.removedNodes.forEach(function(node) {
|
|
254
|
+
if (node.nodeType === Node.ELEMENT_NODE && node.hasAttribute && !node.hasAttribute('data-cached-key')) {
|
|
255
|
+
const key = getComponentKey(node);
|
|
256
|
+
if (key && shouldCache(key)) {
|
|
257
|
+
// Check if this removal is intentional (not just DOM restructuring)
|
|
258
|
+
if (!contentEl.contains(node)) {
|
|
259
|
+
cacheComponent(key, node);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
// Handle added nodes (check if we should restore from cache)
|
|
266
|
+
mutation.addedNodes.forEach(function(node) {
|
|
267
|
+
if (node.nodeType === Node.ELEMENT_NODE && node.hasAttribute) {
|
|
268
|
+
const key = getComponentKey(node);
|
|
269
|
+
if (key && isCached(key)) {
|
|
270
|
+
const restored = restoreComponent(key);
|
|
271
|
+
if (restored) {
|
|
272
|
+
node.replaceWith(restored);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
observer.observe(contentEl, { childList: true, subtree: true });
|
|
281
|
+
|
|
282
|
+
// Cleanup on removal
|
|
283
|
+
container.addEventListener('stx:destroy', function() {
|
|
284
|
+
observer.disconnect();
|
|
285
|
+
clearCache();
|
|
286
|
+
});
|
|
287
|
+
})();
|
|
288
|
+
</script>
|
|
289
|
+
`}function T(f={}){return{id:f.id||G(),cache:new Map,max:f.max||10,include:f.include?f.include.split(",").map((q)=>q.trim()):null,exclude:f.exclude?f.exclude.split(",").map((q)=>q.trim()):null}}function W(f,j){if(j.exclude&&j.exclude.includes(f))return!1;if(j.include&&!j.include.includes(f))return!1;return!0}function X(){return`
|
|
290
|
+
/* STX Keep-Alive Styles */
|
|
291
|
+
.stx-keep-alive {
|
|
292
|
+
position: relative;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
.stx-keep-alive-cache {
|
|
296
|
+
display: none !important;
|
|
297
|
+
visibility: hidden;
|
|
298
|
+
position: absolute;
|
|
299
|
+
pointer-events: none;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/* Activation transition */
|
|
303
|
+
.stx-keep-alive-content > * {
|
|
304
|
+
transition: opacity 0.15s ease;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
.stx-keep-alive-content > [data-activating] {
|
|
308
|
+
opacity: 0;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
.stx-keep-alive-content > [data-activated] {
|
|
312
|
+
opacity: 1;
|
|
313
|
+
}
|
|
314
|
+
`}function Y(){return`
|
|
315
|
+
// STX Keep-Alive Runtime
|
|
316
|
+
(function() {
|
|
317
|
+
if (typeof window === 'undefined') return;
|
|
318
|
+
|
|
319
|
+
window.STX = window.STX || {};
|
|
320
|
+
window.STX.keepAlive = window.STX.keepAlive || { instances: {} };
|
|
321
|
+
|
|
322
|
+
// Global keep-alive utilities
|
|
323
|
+
window.STX.keepAlive.clearAll = function() {
|
|
324
|
+
Object.values(window.STX.keepAlive.instances).forEach(function(instance) {
|
|
325
|
+
instance.clear();
|
|
326
|
+
});
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
window.STX.keepAlive.getTotalCached = function() {
|
|
330
|
+
return Object.values(window.STX.keepAlive.instances).reduce(function(total, instance) {
|
|
331
|
+
return total + instance.getCacheSize();
|
|
332
|
+
}, 0);
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
// Lifecycle hooks for keep-alive
|
|
336
|
+
window.STX.onActivated = function(callback) {
|
|
337
|
+
document.addEventListener('stx:activated', function(e) {
|
|
338
|
+
callback(e.detail);
|
|
339
|
+
});
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
window.STX.onDeactivated = function(callback) {
|
|
343
|
+
document.addEventListener('stx:deactivated', function(e) {
|
|
344
|
+
callback(e.detail);
|
|
345
|
+
});
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
console.log('[stx] Keep-alive runtime initialized');
|
|
349
|
+
})();
|
|
350
|
+
`}function Z(f){if(typeof document<"u")document.addEventListener("stx:activated",(j)=>{f(j.detail)})}function _(f){if(typeof document<"u")document.addEventListener("stx:deactivated",(j)=>{f(j.detail)})}
|
|
351
|
+
export{Q as _h,T as $h,W as ai,X as bi,Y as ci,Z as di,_ as ei};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Tg as n}from"./chunk-s018d32j.js";import{Mo as f,Xp as p,am as b,bm as S,km as k,rm as q}from"./chunk-r6p4ws0a.js";import{Vt as c,Zt as XG,st as d}from"./chunk-3952ykhb.js";import{hu as T}from"./chunk-pw0rzgpv.js";import l from"fs";import F from"path";var{serve:ZG}=globalThis.Bun;function R(G,J,K={}){let Q=`${encodeURIComponent(G)}=${encodeURIComponent(J)}`;if(K.maxAge!==void 0)Q+=`; Max-Age=${K.maxAge}`;if(K.expires)Q+=`; Expires=${K.expires.toUTCString()}`;if(K.path)Q+=`; Path=${K.path}`;if(K.domain)Q+=`; Domain=${K.domain}`;if(K.secure)Q+="; Secure";if(K.httpOnly)Q+="; HttpOnly";if(K.sameSite)Q+=`; SameSite=${K.sameSite}`;return Q}async function i(G){let J=G.headers.get("content-type")||"",K={},Q=(X,Z)=>{let $=K[X];if($===void 0)K[X]=Z;else if(Array.isArray($))$.push(Z);else K[X]=[$,Z]};if(J.includes("multipart/form-data")){let X=await G.formData();for(let[Z,$]of X.entries())if(typeof $==="string")Q(Z,$);return K}if(J.includes("application/x-www-form-urlencoded")){for(let[X,Z]of new URLSearchParams(await G.text()).entries())Q(X,Z);return K}return K}function C(G){if(!G)return!1;let J=G.toUpperCase();return J!=="GET"&&J!=="HEAD"}async function y(G,J={}){let K=J.request,Q=J.method??K?.method;if(!K||!C(Q))return{ran:!1};if(typeof G.action!=="function")return{ran:!1};let X={};try{X=await i(K)}catch{}let Z=await G.action({request:K,form:X,params:J.params??{},query:G.query??{},cookies:J.cookies??{}});if(Z&&typeof Z==="object"){let $=Z,U=a($.cookies),I=$.redirect;if(typeof I==="string"&&I)return{redirect:I,ran:!0,...U.length>0?{cookies:U}:{}};let{cookies:V,redirect:A,...O}=$;if(Object.assign(G,O),U.length>0)return{ran:!0,cookies:U}}return{ran:!0}}function a(G){if(!G||typeof G!=="object"||Array.isArray(G))return[];let J=[];for(let[K,Q]of Object.entries(G)){if(!K)continue;if(typeof Q==="string"){J.push(R(K,Q));continue}if(Q&&typeof Q==="object"){let X=Q;if(typeof X.value!=="string")continue;J.push(R(K,X.value,X))}}return J}function v(G,J=[]){let K=new Headers({Location:G,"Cache-Control":"no-store"});for(let Q of J)K.append("Set-Cookie",Q);return new Response(null,{status:303,headers:K})}async function LG(G,J={}){return(await x(G,J)).html}async function g(G,J={}){let{html:K,context:Q,redirect:X,cookies:Z}=await x(G,J);if(X)return{html:K,redirect:X,cookies:Z};let{extractStreamBoundaries:$}=await import("./chunk-v3ryxw4v.js"),U=$(Q),I=G.streamTemplates;if(I&&Object.keys(I).length>0){let{processDirectives:V}=await import("./chunk-338316c2.js"),{defaultConfig:A}=await import("./chunk-q020t182.js"),O=Q.streamBoundaries||{},D={...A,autoShell:!1},j=Object.keys(I).map((_)=>({id:_,render:async()=>{let M=typeof O[_]==="function"?await O[_]():void 0;return V(I[_],{...Q,$boundary:M},G.sourceFile,D,new Set)}})),N=new Set(j.map((_)=>_.id));U=[...(U||[]).filter((_)=>!N.has(_.id)),...j]}return{html:K,boundaries:U&&U.length>0?U:void 0,cookies:Z}}async function x(G,J){let K={__filename:G.sourceFile,__dirname:G.sourceFile.replace(/[/\\][^/\\]+$/,""),...J};if(!G.hasServerScripts&&!S(G.html))return{html:G.html,context:K};for(let Z of G.serverScriptContent)try{await f(Z,K,G.sourceFile)}catch($){console.warn(`[stx] Server script error in ${G.sourceFile}:`,$)}let Q=await y(K,{request:J.request,method:J.method,params:J.params??{},cookies:J.cookies??{}});if(Q.redirect)return{html:G.html,context:K,redirect:Q.redirect,cookies:Q.cookies};if(!S(G.html))return{html:G.html,context:K,cookies:Q.cookies};let X=new Map;for(let[Z,$]of Object.entries(G.placeholders))if($.expression)try{let U=q($.expression,K);if($.type==="raw")X.set(Z,U!==void 0&&U!==null?String(U):"");else X.set(Z,U!==void 0&&U!==null?k(String(U)):"")}catch{X.set(Z,"")}return{html:b(G.html,X),context:K,cookies:Q.cookies}}async function VG(G,J={}){if(!G.hasServerScripts&&!S(G.fragment))return G.fragment;let K={__filename:G.sourceFile,__dirname:G.sourceFile.replace(/[/\\][^/\\]+$/,""),...J};for(let X of G.serverScriptContent)try{await f(X,K,G.sourceFile)}catch(Z){console.warn(`[stx] Server script error in ${G.sourceFile}:`,Z)}if(!S(G.fragment))return G.fragment;let Q=new Map;for(let[X,Z]of Object.entries(G.placeholders))if(Z.expression)try{let $=q(Z.expression,K);if(Z.type==="raw")Q.set(X,$!==void 0&&$!==null?String($):"");else Q.set(X,$!==void 0&&$!==null?k(String($)):"")}catch{Q.set(X,"")}return b(G.fragment,Q)}XG();import E from"zlib";import{promisify as u}from"util";var s=u(E.brotliCompress),t=u(E.gzip),o=["text/","application/json","application/javascript","application/xml","application/xhtml+xml","application/rss+xml","application/atom+xml","application/manifest+json","image/svg+xml"],e=["text/event-stream","multipart/x-mixed-replace"],GG=1024;function JG(G){if(!G)return!1;let J=G.toLowerCase();if(e.some((K)=>J.startsWith(K)))return!1;return o.some((K)=>J.startsWith(K))}function KG(G){let J=new Map;for(let K of G.split(",")){let[Q,...X]=K.trim().split(";"),Z=Q.trim().toLowerCase();if(!Z)continue;let $=1;for(let U of X){let I=/^\s*q\s*=\s*([\d.]+)\s*$/i.exec(U);if(!I)continue;let V=Number.parseFloat(I[1]);if(Number.isFinite(V))$=V}J.set(Z,$)}return J}function QG(G){if(!G)return null;let J=KG(G),K=J.get("*"),Q=(X)=>J.get(X)??K??0;if(Q("br")>0)return"br";if(Q("gzip")>0)return"gzip";return null}async function m(G,J,K={}){if(J.headers.get("content-encoding"))return J;if(J.status===204||J.status===304||!J.body)return J;if(!JG(J.headers.get("content-type")))return J;let Q=QG(G.headers.get("accept-encoding"));if(!Q)return J;let X;try{X=new Uint8Array(await J.arrayBuffer())}catch{return J}let Z=()=>new Response(X,{status:J.status,statusText:J.statusText,headers:h(J.headers)});if(X.length<(K.threshold??GG))return Z();try{let $=Q==="br"?await s(X,{params:{[E.constants.BROTLI_PARAM_QUALITY]:K.quality??5,[E.constants.BROTLI_PARAM_SIZE_HINT]:X.length}}):await t(X);if($.length>=X.length)return Z();let U=h(J.headers);return U.set("Content-Encoding",Q),U.set("Content-Length",String($.length)),new Response($,{status:J.status,statusText:J.statusText,headers:U})}catch{return Z()}}function h(G){let J=new Headers(G),K=J.get("Vary");if(!K)return J.set("Vary","Accept-Encoding"),J;if(!K.split(",").some((X)=>X.trim().toLowerCase()==="accept-encoding"))J.set("Vary",`${K}, Accept-Encoding`);return J}var $G={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"};async function bG(G={}){let J=F.resolve(G.outputDir||".output"),K=G.port||3000,Q=n(J);if(!Q)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${Q.routes.length} routes...`);let X=new Map,Z=new Map,$=new Map,U=new Map;for(let O of Q.routes)try{let D=F.join(J,O.compiledPath),j=JSON.parse(await Bun.file(D).text());X.set(O.pattern,j),$.set(O.pattern,c(j.html)),U.set(O.pattern,p(j.html));let N=F.join(J,O.fragmentPath);if(await Bun.file(N).exists())Z.set(O.pattern,await Bun.file(N).text())}catch(D){console.warn(`[stx] Failed to load route ${O.pattern}:`,D)}let I=new Map,V=[];for(let O of Q.routes)if(O.hasParams){let{regex:D,params:j}=d(O.pattern);V.push({regex:D,route:O,paramNames:j})}else I.set(O.pattern,O);let A=ZG({port:K,async fetch(O){return m(O,await(async()=>{let j=new URL(O.url).pathname;if(G.onRequest){let W=await G.onRequest(O);if(W)return W}if(G.apiRoutes?.[j])return G.apiRoutes[j](O);if((O.method==="GET"||O.method==="HEAD")&&j!=="/"){let W=F.resolve(J,"public"),Y;try{Y=decodeURIComponent(j)}catch{Y=j}if(!Y.includes("\x00")){let L=F.resolve(W,`.${Y}`);if(L===W||L.startsWith(`${W}${F.sep}`))try{if(l.existsSync(L)&&l.statSync(L).isFile()){let w=F.extname(L).toLowerCase(),H=$G[w]||"application/octet-stream",P=j.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(j);return new Response(Bun.file(L),{headers:{"Content-Type":H,"Cache-Control":P?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let N=O.headers.get("X-STX-Router")==="true",_=null,M={};if(_=I.get(j)||null,!_)for(let{regex:W,route:Y,paramNames:L}of V){let B=j.match(W);if(B){_=Y,L.forEach((w,H)=>{M[w]=B[H+1]});break}}if(!_){let W=I.get("/404")||null;if(W){let Y=X.get(W.pattern);if(Y)return new Response(Y.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}if(N){let W=Z.get(_.pattern);if(W){let Y=$.get(_.pattern);return new Response(W,{headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...U.has(_.pattern)?{"X-STX-Runtime":U.get(_.pattern)?"true":"false"}:{},...Y?{"X-STX-Layout":Y.layout,"X-STX-Layout-Group":Y.group}:{},"Cache-Control":"no-cache"}})}}let r=C(O.method),z=X.get(_.pattern);if(!z){let W=I.get("/500")||null;if(W){let Y=X.get(W.pattern);if(Y)return new Response(Y.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(!r&&!z.hasServerScripts&&Object.keys(z.placeholders).length===0)return new Response(z.html,{headers:{"Content-Type":"text/html","Cache-Control":"public, max-age=60"}});try{let{html:W,boundaries:Y,redirect:L,cookies:B}=await g(z,{params:M,request:O,method:O.method});if(L)return v(L,B);if(Y&&Y.length>0){let{renderStreamingPage:H,streamToResponse:P}=await import("./chunk-v3ryxw4v.js");return P(H(W,Y,{timeoutMs:30000}),{headers:{"Cache-Control":"no-cache"}})}let w=new Headers({"Content-Type":"text/html","Cache-Control":"no-cache"});for(let H of B??[])w.append("Set-Cookie",H);return new Response(W,{headers:w})}catch(W){return console.error(`[stx] Hydration error for ${j}:`,W),new Response(z.html,{headers:{"Content-Type":"text/html"}})}})())}});return console.log(`[stx] Production server running at http://localhost:${K}`),console.log(`[stx] Serving ${Q.routes.length} routes (${X.size} pre-loaded)`),{port:K,stop:()=>A.stop()}}
|
|
3
|
+
export{JG as gf,QG as hf,m as if,R as jf,i as kf,C as lf,y as mf,v as nf,LG as of,g as pf,VG as qf,bG as rf};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{em as a,fm as b,gm as c,hm as d,im as e,jm as f,km as g,lm as h,mm as i,nm as j,om as k,pm as l,qm as m,rm as n,sm as o}from"./chunk-r6p4ws0a.js";import"./chunk-8src5smc.js";import"./chunk-gcnrdgrq.js";import"./chunk-xp3fp266.js";import"./chunk-nye9brje.js";import"./chunk-tywvd1zc.js";import"./chunk-cbc56wpd.js";import"./chunk-x0zh76yv.js";import"./chunk-0ae6chzd.js";import"./chunk-kjr22neh.js";import"./chunk-3952ykhb.js";import"./chunk-dtmwr674.js";import"./chunk-pw0rzgpv.js";export{h as usesSignalsInScript,o as unescapeHtml,c as registerFilters,b as registerFilter,l as processExpressions,k as interpolateScriptsInTemplate,i as interpolateScriptExpressions,j as interpolateScriptAttributes,d as getAllFilters,n as evaluateExpression,g as escapeHtmlValue,f as escapeHtml,a as defaultFilters,e as clearCustomFilters,m as applyFilters};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import G from"path";var L=new Set([".jpg",".jpeg",".png",".gif"]),O=[{ext:".avif",mime:"image/avif"},{ext:".webp",mime:"image/webp"}];async function M(j,z){let H=z.formats??O;if(!z.publicDir)return j;let C=N(j),J=[],Y=/<img\b[^>]*?>/gi,K=[],Q;while((Q=Y.exec(j))!==null){let q=Q[0],y=q.match(/\bsrc=["']([^"']+)["']/i);if(!y)continue;if(_(Q.index,C))continue;K.push({idx:Q.index,length:q.length,src:y[1],raw:q})}if(K.length===0)return j;let Z=await Promise.all(K.map(async(q)=>{let y=await X(q.src,z.publicDir,H);return{match:q,sources:y}}));for(let{match:q,sources:y}of Z){if(y.length===0)continue;let I=`<picture>${y.map(($)=>`<source type="${$.mime}" srcset="${w($.url)}">`).join("")}${q.raw}</picture>`;J.push({start:q.idx,end:q.idx+q.length,replacement:I})}if(J.length===0)return j;let V="",W=0;for(let q of J)V+=j.slice(W,q.start),V+=q.replacement,W=q.end;return V+=j.slice(W),V}async function X(j,z,H){if(!F(j))return[];let C=G.extname(j).toLowerCase();if(!L.has(C))return[];if(!j.startsWith("/"))return[];let J=G.join(z,j.slice(1)),Y=G.dirname(J),K=G.basename(J,C),Q=G.resolve(Y),Z=G.resolve(z);if(!Q.startsWith(Z))return[];let V=G.posix.dirname(j),W=H.map(async(y)=>{let k=G.join(Y,`${K}${y.ext}`);if(!await Bun.file(k).exists())return null;return{url:G.posix.join(V,`${K}${y.ext}`),mime:y.mime}});return(await Promise.all(W)).filter((y)=>y!==null)}function F(j){if(!j)return!1;if(j.startsWith("http://")||j.startsWith("https://"))return!1;if(j.startsWith("//"))return!1;if(j.startsWith("data:"))return!1;return!0}function N(j){let z=[],H=/<picture\b[^>]*>[\s\S]*?<\/picture>/gi,C;while((C=H.exec(j))!==null)z.push([C.index,C.index+C[0].length]);return z}function _(j,z){for(let[H,C]of z)if(j>=H&&j<C)return!0;return!1}function w(j){return j.replace(/&/g,"&").replace(/"/g,""")}
|
|
3
|
+
export{M as eh};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{$i as Z,Zi as j,_i as E}from"./chunk-ht51fz7w.js";import{Il as R,Jl as U,Kl as X,Kr as M,tq as L}from"./chunk-r6p4ws0a.js";import{dt as P}from"./chunk-kjr22neh.js";import $ from"path";var V=new Map;function w(Q,z){for(let J of Q.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(J[1])z.add(J[1]);for(let J of Q.matchAll(/\b(?:const|let|var)\s*\{([^{}]*)\}\s*=/g))for(let H of(J[1]??"").split(",")){let Y=((H.includes(":")?H.split(":").pop():H)??"").replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(Y))z.add(Y)}for(let J of Q.matchAll(/\b(?:const|let|var)\s*\[([^\]]*)\]\s*=/g))for(let H of(J[1]??"").split(",")){let K=H.replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(K))z.add(K)}}async function u(Q){let z;if(Q)z=$.resolve(Q);else{let q=await M();z=$.resolve(q.root||process.cwd(),q.storesDir||"stores")}let J=new Bun.Glob("*.ts"),H=[];try{for await(let q of J.scan({cwd:z,absolute:!0})){let y=$.basename(q,".ts");if(["index","types"].includes(y))continue;if(q.includes(".d.ts"))continue;H.push(q)}}catch{return Z(V,z,"",""),null}let K=j(H),Y=E(V,z,K);if(Y!==void 0)return Y||null;if(H.length===0)return Z(V,z,K,""),null;let x=[];for(let q of H){let y=await Bun.file(q).text();x.push({file:q,hasUseStore:/useStore\s*\(/.test(y)})}x.sort((q,y)=>{if(q.hasUseStore===y.hasUseStore)return 0;return q.hasUseStore?1:-1});let I=x.map((q)=>q.file),A=[],B=new Set,T=L({loader:"ts",target:"browser",define:X()});for(let q of I)try{let y=await Bun.file(q).text(),W=$.basename(q,".ts");w(y,B),y=R(y),y=U(y),y=y.replace(/^export\s+(default\s+)?/gm,""),y=T.transformSync(y),A.push(`// Store: ${W}
|
|
3
|
+
${y.trim()}`)}catch(y){console.warn(`[stx] Failed to load store ${q}:`,y)}if(A.length===0)return Z(V,z,K,""),null;let G=A.join(`
|
|
4
|
+
|
|
5
|
+
`),O=`;(function(){
|
|
6
|
+
var __stx = window.stx || {};
|
|
7
|
+
${P.filter((q)=>!B.has(q)&&new RegExp(`\\b${q}\\b`).test(G)).map((q)=>`var ${q} = __stx[${JSON.stringify(q)}];`).join(`
|
|
8
|
+
`)}
|
|
9
|
+
${G}
|
|
10
|
+
})();`;return Z(V,z,K,O),O}function g(){V.clear()}
|
|
11
|
+
export{u as Ui,g as Vi};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import"./chunk-pw0rzgpv.js";var Y=null,S=[],F=new WeakMap;function I(z){let K=z,B=new Set,G={get value(){if(Y){let H=F.get(G);if(!H)H=new Set,F.set(G,H);H.add(Y)}return K},set value(H){if(!Object.is(K,H)){K=H,B.forEach((J)=>J(H));let L=F.get(G);if(L)L.forEach((J)=>J())}},subscribe(H){return B.add(H),()=>B.delete(H)},peek(){return K}};return G}function W(z){return z!==null&&typeof z==="object"&&"value"in z&&"subscribe"in z&&"peek"in z}function P(z){return W(z)?z.value:z}function j(z){let K={};for(let B in z)if(Object.prototype.hasOwnProperty.call(z,B))K[B]=I(z[B]);return K}function D(z){return I(z)}function U(z){let K=typeof z==="function",B=K?z:z.get,G=K?void 0:z.set,H=K?Object.is:z.equals||Object.is,L,J=!0,Q=new Set,X=new Set,_=()=>{if(J=!0,X.size>0){let N=T.value;X.forEach(($)=>$(N))}};function Z(){Q.clear();let N=Y;Y=_,S.push(_);try{return B()}finally{S.pop(),Y=N}}let T={get value(){if(Y){let N=F.get(T);if(!N)N=new Set,F.set(T,N);N.add(Y)}if(J){let N=Z();if(!H(L,N))L=N;J=!1}return L},set value(N){if(G)G(N);else console.warn("Computed property is readonly")},subscribe(N){return X.add(N),()=>X.delete(N)},peek(){if(J)L=B(),J=!1;return L},invalidate(){J=!0},get dirty(){return J},get deps(){return Q}};return T}function x(z,K,B={}){let{immediate:G=!1,deep:H=!1,flush:L="pre",once:J=!1}=B,Q,X=!0,_=!1,Z=()=>{if(W(z))return H?q(z.value):z.value;return z()},T=()=>{if(!X||_)return;let M=Z();if(Q!==void 0&&Object.is(Q,M)&&!H)return;let A=()=>{if(K(M,Q),Q=H?q(M):M,J)$()};if(L==="sync")A();else if(L==="post")queueMicrotask(A);else Promise.resolve().then(A)},N=null;if(W(z))N=z.subscribe(()=>T());else N=U(z).subscribe(()=>T());if(G)Q=void 0,T();else Q=Z();let $=()=>{if(X=!1,N)N(),N=null};return $.pause=()=>{_=!0},$.resume=()=>{_=!1},$}function E(z,K,B={}){let{immediate:G=!1,once:H=!1}=B,L=z.map((T)=>W(T)?T.value:void 0),J=!0,Q=!1,X=()=>{if(!J||Q)return;let T=z.map((N)=>W(N)?N.value:void 0);if(K(T,L),L=[...T],H)Z()},_=z.map((T)=>{if(W(T))return T.subscribe(()=>X());return()=>{}});if(G)X();let Z=()=>{J=!1,_.forEach((T)=>T())};return Z.pause=()=>{Q=!0},Z.resume=()=>{Q=!1},Z}function y(z,K={}){let{flush:B="pre"}=K,G,H=!0,L=!1,J=()=>{if(!H||L)return;if(G)G();let X=Y;Y=J,S.push(J);try{G=z()}finally{S.pop(),Y=X}};if(B==="sync")J();else if(B==="post")queueMicrotask(J);else Promise.resolve().then(J);let Q=()=>{if(H=!1,G)G()};return Q.pause=()=>{L=!0},Q.resume=()=>{L=!1},Q}function C(z,K={},B){let G=/@computed\s*\(\s*(\w+)\s*,\s*(.+?)\s*\)/gi;return z.replace(G,(H,L,J)=>{try{let X=Function(...Object.keys(K),`return ${J}`)(...Object.values(K));return K[L]=X,`<!-- computed: ${L} = ${X} -->`}catch(Q){return`<!-- computed error: ${L} - ${Q} -->`}})}function R(z,K={},B){let G=/@watch\s*\(\s*(\w+)\s*\)\s*([\s\S]*?)@endwatch/gi;return z.replace(G,(H,L,J)=>{return`
|
|
3
|
+
<script data-watch="${`watch-${Math.random().toString(36).substring(2,9)}`}">
|
|
4
|
+
(function() {
|
|
5
|
+
// Watch implementation for ${L}
|
|
6
|
+
const handler = ${J.trim()};
|
|
7
|
+
if (window.__stxState && window.__stxState['${L}']) {
|
|
8
|
+
window.__stxState['${L}'].subscribe(function(newValue) {
|
|
9
|
+
handler(newValue);
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
})();
|
|
13
|
+
</script>
|
|
14
|
+
`})}function q(z){if(z===null||typeof z!=="object")return z;if(Array.isArray(z))return z.map((B)=>q(B));if(z instanceof Date)return new Date(z.getTime());if(z instanceof Map){let B=new Map;return z.forEach((G,H)=>B.set(q(H),q(G))),B}if(z instanceof Set){let B=new Set;return z.forEach((G)=>B.add(q(G))),B}let K={};for(let B in z)if(Object.prototype.hasOwnProperty.call(z,B))K[B]=q(z[B]);return K}function O(z,K=100){let B=I(z()),G=null,H=()=>{if(G)clearTimeout(G);G=setTimeout(()=>{B.value=z()},K)};return U(z).subscribe(()=>H()),{get value(){return B.value},set value(J){console.warn("Debounced computed is readonly")},subscribe:B.subscribe,peek:B.peek,invalidate(){H()},get dirty(){return!1},get deps(){return new Set}}}function h(z,K=100){let B=I(z()),G=0,H=()=>{let J=Date.now();if(J-G>=K)G=J,B.value=z()};return U(z).subscribe(()=>H()),{get value(){return B.value},set value(J){console.warn("Throttled computed is readonly")},subscribe:B.subscribe,peek:B.peek,invalidate(){H()},get dirty(){return!1},get deps(){return new Set}}}var g={ref:I,computed:U,watch:x,watchMultiple:E,watchEffect:y,isRef:W,unref:P,toRefs:j,shallowRef:D,debouncedComputed:O,throttledComputed:h,processComputedDirectives:C,processWatchDirectives:R};export{E as watchMultiple,y as watchEffect,x as watch,P as unref,j as toRefs,h as throttledComputed,E as stxWatchMultiple,y as stxWatchEffect,x as stxWatch,P as stxUnref,j as stxToRefs,h as stxThrottledComputed,D as stxShallowRef,I as stxRef,W as stxIsRef,O as stxDebouncedComputed,U as stxComputed,D as shallowRef,I as ref,R as processWatchDirectives,C as processComputedDirectives,W as isRef,g as default,O as debouncedComputed,U as computed};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
function G(q){if(!q||typeof q!=="object")return!1;let z=q;return typeof z.message==="string"&&(z.name==="BuildMessage"||z.name==="ResolveMessage"||("position"in z))}function H(q){if(q&&typeof q==="object"&&Array.isArray(q.errors))return q.errors;return[q]}function I(q,z){let j=[];for(let A of H(q)){if(G(A)){let D=A.position||void 0;j.push({file:z||D?.file,line:D?.line,column:D?.column,message:A.message??"",lineText:D?.lineText});continue}j.push({file:z,message:A instanceof Error?A.message:String(A)})}return j}function J(q,z){return I(q,z).map((j)=>{let A=j.file?`${j.file}${j.line?`:${j.line}${j.column?`:${j.column}`:""}`:""}`:"",D=j.lineText?`
|
|
3
|
+
${j.lineText.trim()}`:"";return A?`${A}: ${j.message}${D}`:`${j.message}${D}`}).join(`
|
|
4
|
+
`)}
|
|
5
|
+
export{I as bl,J as cl};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Kr as E}from"./chunk-r6p4ws0a.js";import{hu as D}from"./chunk-pw0rzgpv.js";import I from"path";async function M(q={}){let G=performance.now(),J=q.root||process.cwd(),j=await E(),y=j.ssr?"ssr":"ssg";console.log(`[stx build] Mode: ${y.toUpperCase()}${j.ssr?" (ssr: true in stx.config.ts)":" (default \u2014 ssr is false)"}`);let A,B;if(y==="ssg"){let{generateStaticSite:z}=await import("./ssg.js");A=await z({pagesDir:I.join(j.root||".",j.pagesDir||j.build?.pagesDir||"pages"),publicDir:j.publicDir||j.build?.publicDir||"public",outputDir:j.build?.outputDir||"dist",generate404:j.build?.generate404??!0,minify:j.build?.minify??!0,cleanOutput:j.build?.cleanOutput??!0,...q.ssg})}else{let{buildForProduction:z}=await import("./chunk-5anpcnde.js");B=await z({outputDir:".output",debug:q.debug,...q.ssr})}let H=Math.round(performance.now()-G);return{mode:y,ssg:A,ssr:B,duration:H}}
|
|
3
|
+
export{M as ff};
|