@stacksjs/bun-router 0.0.26 → 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/dist/types.d.ts +12 -2
- 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,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{rl as a,sl as b}from"./chunk-tpfgntwj.js";import"./chunk-jff6j9y3.js";import"./chunk-csfrpsp7.js";import"./chunk-0t5vz87j.js";import"./chunk-krkchy8v.js";import"./chunk-brpgjyqg.js";import"./chunk-5mxby3fd.js";import"./chunk-5be9x5cq.js";import"./chunk-jmeb7n8k.js";import"./chunk-kc659vhx.js";import"./chunk-a3wahyg7.js";export{b as processLoops,a as parseLoopBinding};
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var d=0;function s(){return`keep-alive-${++d}-${Date.now().toString(36)}`}function h(e,t={},o){let n=/@keepAlive(?:\s*\(([^)]*)\))?\s*([\s\S]*?)@endkeepAlive/gi;return e.replace(n,(a,c,i)=>{let l=s(),r=u(c||"");return p(l,i.trim(),r)})}function u(e){let t={max:10},o=/(\w+)\s*:\s*(?:'([^']*)'|"([^"]*)"|(\d+)|(\w+))/g,n;while((n=o.exec(e))!==null){let a=n[1],c=n[2]||n[3],i=n[4];switch(a){case"max":t.max=i?parseInt(i,10):10;break;case"include":t.include=c;break;case"exclude":t.exclude=c;break;case"id":t.id=c;break}}return t}function p(e,t,o){let{max:n,include:a,exclude:c}=o,i=o.id||e;return`
|
|
3
|
+
<div class="stx-keep-alive" data-keep-alive-id="${e}" data-custom-id="${i}">
|
|
4
|
+
<div class="stx-keep-alive-content" data-keep-alive-content="${e}">
|
|
5
|
+
${t}
|
|
6
|
+
</div>
|
|
7
|
+
<div class="stx-keep-alive-cache" data-keep-alive-cache="${e}" style="display: none;">
|
|
8
|
+
</div>
|
|
9
|
+
</div>
|
|
10
|
+
<script>
|
|
11
|
+
(function() {
|
|
12
|
+
const keepAliveId = '${e}';
|
|
13
|
+
const customId = '${i}';
|
|
14
|
+
const maxCache = ${n||10};
|
|
15
|
+
const includeFilter = ${a?JSON.stringify(a.split(",").map((l)=>l.trim())):"null"};
|
|
16
|
+
const excludeFilter = ${c?JSON.stringify(c.split(",").map((l)=>l.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 m(e={}){return{id:e.id||s(),cache:new Map,max:e.max||10,include:e.include?e.include.split(",").map((t)=>t.trim()):null,exclude:e.exclude?e.exclude.split(",").map((t)=>t.trim()):null}}function f(e,t){if(t.exclude&&t.exclude.includes(e))return!1;if(t.include&&!t.include.includes(e))return!1;return!0}function v(){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 k(){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 y(e){if(typeof document<"u")document.addEventListener("stx:activated",(t)=>{e(t.detail)})}function x(e){if(typeof document<"u")document.addEventListener("stx:deactivated",(t)=>{e(t.detail)})}
|
|
351
|
+
export{h as Pe,m as Qe,f as Re,v as Se,k as Te,y as Ue,x as Ve};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Td as a,Ud as b,Vd as c,Wd as d,Xd as e,Yd as f,Zd as g}from"./chunk-9ght4n4r.js";import"./chunk-a3wahyg7.js";export{d as useVirtualList,b as processVirtualListDirectives,f as processVirtualGridDirectives,e as processInfiniteListDirectives,c as generateVirtualListCSS,g as default,a as createVirtualList};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{$s as F,dt as M}from"./chunk-jy2jhcpy.js";import{Zu as R}from"./chunk-a3wahyg7.js";import y from"fs";import l from"path";import b from"os";import B from"crypto";var N=[320,640,768,1024,1280,1536,1920],O=["webp","jpeg"],_=80,H=[".jpg",".jpeg",".png",".webp",".avif",".gif",".svg"],P={webp:"image/webp",avif:"image/avif",jpeg:"image/jpeg",png:"image/png"},w=null,v=!1;async function d(){if(v)return w;v=!0;try{let t=await import("sharp");return w=t.default||t,w}catch{return null}}async function J(){return await d()!==null}async function Z(){return!0}async function tt(t,e={}){let{widths:a=N,formats:r=O,quality:i=_,fit:o="cover",placeholder:n="none",outputDir:f=".stx/images",baseUrl:q="/images"}=e,h,m;if(typeof t==="string"){if(m=t,!await Bun.file(t).exists())throw new I(`Image not found: ${t}`,"NOT_FOUND");h=await Bun.file(t).arrayBuffer().then((s)=>Buffer.from(s))}else m="buffer-input",h=t;let $=B.createHash("sha256").update(h).digest("hex").slice(0,12),T=await x(h),{width:c,height:E}=T,S=c/E;await y.promises.mkdir(f,{recursive:!0});let U=[],z=l.basename(m,l.extname(m)),g=a.filter((s)=>s<=c);if(!g.includes(c)&&c<=Math.max(...a))g.push(c);g.sort((s,u)=>s-u);for(let s of g){let u=Math.round(s/S);for(let p of r){let A=`${z}-${s}w-${$}.${p}`,L=l.join(f,A),D=`${q}/${A}`,k=await W(h,{width:s,height:u,format:p,quality:i,fit:o});await Bun.write(L,k),U.push({path:L,url:D,width:s,height:u,format:p,size:k.length})}}let j;if(n!=="none")j=await C(h,n);return{src:m,variants:U,placeholder:j,width:c,height:E,aspectRatio:S,hash:$}}async function x(t){let e=typeof t==="string"?Buffer.from(await Bun.file(t).arrayBuffer()):t,a=await d();if(a){let r=await a(e).metadata();return{width:r.width||0,height:r.height||0,format:r.format||"unknown",hasAlpha:r.hasAlpha}}return V(e)}function V(t){if(t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71){let e=t.readUInt32BE(16),a=t.readUInt32BE(20);return{width:e,height:a,format:"png",hasAlpha:!0}}if(t[0]===255&&t[1]===216){let e=2;while(e<t.length){if(t[e]!==255)break;let a=t[e+1];if(a>=192&&a<=207&&a!==196&&a!==200&&a!==204){let i=t.readUInt16BE(e+5);return{width:t.readUInt16BE(e+7),height:i,format:"jpeg",hasAlpha:!1}}let r=t.readUInt16BE(e+2);e+=2+r}}if(t.toString("utf8",0,4)==="RIFF"&&t.toString("utf8",8,12)==="WEBP"){let e=t.toString("utf8",12,16);if(e==="VP8 "){let a=t.readUInt16LE(26)&16383,r=t.readUInt16LE(28)&16383;return{width:a,height:r,format:"webp",hasAlpha:!1}}if(e==="VP8L"){let a=t.readUInt32LE(21),r=(a&16383)+1,i=(a>>14&16383)+1;return{width:r,height:i,format:"webp",hasAlpha:!0}}}if(t.toString("utf8",0,3)==="GIF"){let e=t.readUInt16LE(6),a=t.readUInt16LE(8);return{width:e,height:a,format:"gif",hasAlpha:!0}}throw new I("Unable to parse image dimensions","PARSE_ERROR")}async function W(t,e){let a=await d();if(a){let i=a(t).resize(e.width,e.height,{fit:e.fit});switch(e.format){case"webp":i=i.webp({quality:e.quality});break;case"avif":i=i.avif({quality:e.quality});break;case"jpeg":i=i.jpeg({quality:e.quality});break;case"png":i=i.png({quality:e.quality});break}return i.toBuffer()}let r=l.join(b.tmpdir(),`stx-img-${B.randomBytes(8).toString("hex")}.${e.format}`);try{return await F({input:t,output:r,format:e.format,quality:e.quality,resize:{width:e.width,height:e.height,fit:e.fit}}),Buffer.from(await Bun.file(r).arrayBuffer())}finally{await y.promises.unlink(r).catch(()=>{})}}async function C(t,e){let a=await d();if(e==="blur"&&a){let o=(await a(t).resize(20).blur(10).toBuffer()).toString("base64"),n=await x(t);return`data:${P[n.format]||"image/jpeg"};base64,${o}`}if(e==="dominant-color"&&a){let{dominant:o}=await a(t).resize(1,1).toBuffer().then(async(n)=>{let f=await a(n).metadata();return{dominant:{r:128,g:128,b:128}}}).catch(()=>({dominant:{r:128,g:128,b:128}}));return`rgb(${o.r}, ${o.g}, ${o.b})`}let r=await x(t),i=l.join(b.tmpdir(),`stx-ph-${B.randomBytes(8).toString("hex")}.${r.format==="unknown"?"bin":r.format}`);try{await Bun.write(i,t);let o=e==="blur"?"blur":e==="thumbhash"?"thumbhash":"dominant-color",n=await M(i,{strategy:o,width:o==="thumbhash"?void 0:32});if(e==="dominant-color"&&n.dominantColor)return n.dominantColor;if(n.dataURL)return n.dataURL;return"rgb(128, 128, 128)"}catch{return"rgb(128, 128, 128)"}finally{await y.promises.unlink(i).catch(()=>{})}}function et(t,e){return(e?t.filter((a)=>a.format===e):t).sort((a,r)=>a.width-r.width).map((a)=>`${a.url} ${a.width}w`).join(", ")}function at(t){if(!t||Object.keys(t).length===0)return"100vw";return Object.entries(t).sort((e,a)=>{let r=Number.parseInt(e[0].replace(/\D/g,""))||0;return(Number.parseInt(a[0].replace(/\D/g,""))||0)-r}).map(([e,a])=>`(max-width: ${e}) ${a}`).join(", ")+", 100vw"}function rt(t){let e=t.filter((r)=>r.format==="jpeg");if(e.length===0)return t[Math.floor(t.length/2)];let a=e.sort((r,i)=>r.width-i.width);return a[Math.floor(a.length/2)]}function it(t){let e=new Map;for(let a of t){let r=e.get(a.format)||[];r.push(a),e.set(a.format,r)}return e}function nt(t){let e=l.extname(t).toLowerCase();return H.includes(e)}function ot(t){return P[t]||"application/octet-stream"}function st(t){return t.reduce((e,a)=>e+a.size,0)}function ht(t){if(t<1024)return`${t} B`;if(t<1048576)return`${(t/1024).toFixed(1)} KB`;return`${(t/1048576).toFixed(2)} MB`}class I extends Error{code;constructor(t,e){super(t);this.name="ImageProcessingError",this.code=e}}
|
|
3
|
+
export{N as ds,O as es,_ as fs,J as gs,Z as hs,tt as is,x as js,W as ks,et as ls,at as ms,rt as ns,it as os,nt as ps,ot as qs,st as rs,ht as ss,I as ts};
|