@stacksjs/stx 0.2.364 → 0.2.366
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-gerew7rz.js → chunk-09xgdh4x.js} +1 -1
- package/dist/{chunk-jq4h14y6.js → chunk-09ypvk2t.js} +1 -1
- package/dist/{chunk-tan44cyf.js → chunk-0jp8bx88.js} +1 -1
- package/dist/{chunk-08pf5tmf.js → chunk-0vary9ym.js} +1 -1
- package/dist/{chunk-asxfek33.js → chunk-264fwxyv.js} +2 -2
- package/dist/{chunk-89c03r0q.js → chunk-2d737x81.js} +2 -2
- package/dist/{chunk-ec8pyr0w.js → chunk-2hpey68b.js} +1 -1
- package/dist/{chunk-5qe5amz6.js → chunk-2wbs79rn.js} +1 -1
- package/dist/{chunk-t0e193kb.js → chunk-34thbja9.js} +1 -1
- package/dist/{chunk-szbgwctn.js → chunk-3vctbh57.js} +1 -1
- package/dist/{chunk-8zw9npx5.js → chunk-53breaeh.js} +1 -1
- package/dist/{chunk-7tp3zk2s.js → chunk-5gwf1fxm.js} +1 -1
- package/dist/{chunk-0d96p1my.js → chunk-5yhbx6em.js} +1 -1
- package/dist/{chunk-ddsfdbwt.js → chunk-65nbdz3c.js} +1 -1
- package/dist/{chunk-drk5v3wn.js → chunk-8czscsf3.js} +1 -1
- package/dist/{chunk-3dkv2bqc.js → chunk-9n4wz4p2.js} +1 -1
- package/dist/{chunk-yyxgghm5.js → chunk-b3yn2q9z.js} +1 -1
- package/dist/{chunk-23ftyfcz.js → chunk-bxgq1ec0.js} +1 -1
- package/dist/{chunk-dj0c80w1.js → chunk-chnhccbg.js} +1 -1
- package/dist/{chunk-nfwtms2p.js → chunk-cvpr7j0a.js} +1 -1
- package/dist/{chunk-85tvgy7c.js → chunk-dvzxdyth.js} +1 -1
- package/dist/{chunk-yectvv7c.js → chunk-e16evm88.js} +1 -1
- package/dist/{chunk-zk0enyyh.js → chunk-e2wkw0mv.js} +1 -1
- package/dist/{chunk-c6b161h9.js → chunk-exve9vx9.js} +1 -1
- package/dist/{chunk-7wvvzame.js → chunk-g1wgckhg.js} +1 -1
- package/dist/{chunk-6gns8q1a.js → chunk-hd3g347d.js} +1 -1
- package/dist/{chunk-8qp89yt9.js → chunk-hdpcrf2k.js} +1 -1
- package/dist/{chunk-whywmp6c.js → chunk-ht2neybr.js} +1 -1
- package/dist/{chunk-wbwfsp44.js → chunk-jf9mv5tq.js} +108 -46
- package/dist/{chunk-4v04zysj.js → chunk-jq1pddw6.js} +1 -1
- package/dist/{chunk-bfecmzpa.js → chunk-jxc8ezvk.js} +1 -1
- package/dist/{chunk-7nf8tw22.js → chunk-k2sdmmmq.js} +2 -2
- package/dist/{chunk-p6avvxkg.js → chunk-ksfnb7rd.js} +1 -1
- package/dist/{chunk-2gkbht81.js → chunk-m883x1fp.js} +1 -1
- package/dist/{chunk-md0h8d2h.js → chunk-nfmdrmgz.js} +1 -1
- package/dist/{chunk-wsqbnhcy.js → chunk-nhshe26k.js} +8 -8
- package/dist/{chunk-ck4n9zkv.js → chunk-r92073jh.js} +1 -1
- package/dist/{chunk-6xmkzx0a.js → chunk-rg473fqn.js} +1 -1
- package/dist/{chunk-wzebxbek.js → chunk-t0bnbghk.js} +1 -1
- package/dist/{chunk-rw0j25b8.js → chunk-t6928tnd.js} +1 -1
- package/dist/{chunk-d8n3wqgy.js → chunk-tc8yfmm5.js} +1 -1
- package/dist/{chunk-h6jnte7x.js → chunk-v8ncfppj.js} +1 -1
- package/dist/{chunk-s5qkcz77.js → chunk-vd3ja1q9.js} +1 -1
- package/dist/{chunk-bkeszcra.js → chunk-vr3a5wma.js} +1 -1
- package/dist/{chunk-xh55b3m0.js → chunk-wb2y68dk.js} +1 -1
- package/dist/{chunk-y1vw94q2.js → chunk-y1twpva6.js} +1 -1
- package/dist/{chunk-3xt912sq.js → chunk-y3gd1g9s.js} +16 -16
- package/dist/{chunk-8b5cwheg.js → chunk-y4j6br2e.js} +1 -1
- package/dist/{chunk-e8nxcfp3.js → chunk-z541dzm4.js} +1 -1
- package/dist/{chunk-6xy59d9x.js → chunk-z9zayxg4.js} +1 -1
- package/dist/cli.js +8 -8
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/pwa.js +1 -1
- package/dist/signals.js +108 -46
- package/dist/ssg.js +2 -2
- package/package.json +5 -5
|
@@ -167,6 +167,65 @@ console.log('[stx] entering IIFE');
|
|
|
167
167
|
// Reactive Core
|
|
168
168
|
// ==========================================================================
|
|
169
169
|
|
|
170
|
+
// Compiled expression functions, by parameter list and body. A binding was
|
|
171
|
+
// compiled with new Function on every evaluation: a page with a few hundred
|
|
172
|
+
// names in scope rebuilt a function of a few hundred parameters for every
|
|
173
|
+
// binding of every row, every time a row re-rendered. Opening a 386-message
|
|
174
|
+
// conversation took seven seconds in WebKit, the window frozen meanwhile.
|
|
175
|
+
// A Function built this way closes over nothing, so one can be reused.
|
|
176
|
+
const __stxCompiled = new Map();
|
|
177
|
+
function __stxCompile(params, body) {
|
|
178
|
+
const key = params.join(',') + '\\x01' + body;
|
|
179
|
+
let fn = __stxCompiled.get(key);
|
|
180
|
+
if (!fn) {
|
|
181
|
+
fn = new Function(...params, body);
|
|
182
|
+
// Bounded: expressions are finite per page, but SPA navigation adds more.
|
|
183
|
+
if (__stxCompiled.size >= 5000) __stxCompiled.clear();
|
|
184
|
+
__stxCompiled.set(key, fn);
|
|
185
|
+
}
|
|
186
|
+
return fn;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// The names an expression mentions, by its text.
|
|
190
|
+
const __stxIdentifiers = new Map();
|
|
191
|
+
function __stxNamesIn(body) {
|
|
192
|
+
let names = __stxIdentifiers.get(body);
|
|
193
|
+
if (!names) {
|
|
194
|
+
names = Array.from(new Set(body.match(/[A-Za-z_$][\\w$]*/g) || []));
|
|
195
|
+
if (__stxIdentifiers.size >= 5000) __stxIdentifiers.clear();
|
|
196
|
+
__stxIdentifiers.set(body, names);
|
|
197
|
+
}
|
|
198
|
+
return names;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// Compile an expression over just the names in scope it mentions.
|
|
202
|
+
//
|
|
203
|
+
// It was compiled over every name in scope and called with every value,
|
|
204
|
+
// read through the auto-unwrap proxy. Reading a signal subscribes the
|
|
205
|
+
// running effect, so every binding depended on every signal on the page:
|
|
206
|
+
// changing one unrelated value re-ran every binding of every row. The proxy
|
|
207
|
+
// also tested each signal against the expression with fresh regexes. Now an
|
|
208
|
+
// expression sees, reads and subscribes to what it names; a mention inside
|
|
209
|
+
// a string only widens that, never narrows it.
|
|
210
|
+
function __stxCompileScoped(scope, extraParams, body) {
|
|
211
|
+
const keys = [];
|
|
212
|
+
const names = __stxNamesIn(body);
|
|
213
|
+
for (let i = 0; i < names.length; i++) {
|
|
214
|
+
if (Object.prototype.propertyIsEnumerable.call(scope, names[i])) keys.push(names[i]);
|
|
215
|
+
}
|
|
216
|
+
const fn = __stxCompile(extraParams.length ? keys.concat(extraParams) : keys, body);
|
|
217
|
+
// The cache keys on the parameter list, so a function always has these keys.
|
|
218
|
+
fn.__stxKeys = keys;
|
|
219
|
+
return fn;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function __stxArgs(fn, scope) {
|
|
223
|
+
const keys = fn.__stxKeys;
|
|
224
|
+
const args = new Array(keys.length);
|
|
225
|
+
for (let i = 0; i < keys.length; i++) args[i] = scope[keys[i]];
|
|
226
|
+
return args;
|
|
227
|
+
}
|
|
228
|
+
|
|
170
229
|
let activeEffect = null;
|
|
171
230
|
const effectStack = [];
|
|
172
231
|
const pendingEffects = new Set();
|
|
@@ -756,8 +815,8 @@ else {
|
|
|
756
815
|
// First evaluate the base expression
|
|
757
816
|
let value;
|
|
758
817
|
try {
|
|
759
|
-
const fn =
|
|
760
|
-
value = fn(...
|
|
818
|
+
const fn = __stxCompileScoped(scope, [], 'return ' + valueExpr);
|
|
819
|
+
value = fn(...__stxArgs(fn, scope));
|
|
761
820
|
}
|
|
762
821
|
catch (e) {
|
|
763
822
|
if (!(e instanceof ReferenceError) && !(e instanceof TypeError)) console.warn('[STX] Pipe base expression error:', valueExpr, e);
|
|
@@ -777,8 +836,8 @@ catch (e) {
|
|
|
777
836
|
if (/^['"].*['"]$/.test(arg)) return arg.slice(1, -1);
|
|
778
837
|
// Try to evaluate as expression in scope
|
|
779
838
|
try {
|
|
780
|
-
const fn =
|
|
781
|
-
return fn(...
|
|
839
|
+
const fn = __stxCompileScoped(scope, [], 'return ' + arg);
|
|
840
|
+
return fn(...__stxArgs(fn, scope));
|
|
782
841
|
}
|
|
783
842
|
catch (e) {
|
|
784
843
|
return arg;
|
|
@@ -2069,8 +2128,8 @@ finally {
|
|
|
2069
2128
|
|| expressionUsesSignalApi(expr, prop);
|
|
2070
2129
|
})
|
|
2071
2130
|
: baseScope;
|
|
2072
|
-
const fn =
|
|
2073
|
-
const result = fn(...
|
|
2131
|
+
const fn = __stxCompileScoped(baseScope, [], 'return ' + expr);
|
|
2132
|
+
const result = fn(...__stxArgs(fn, scope));
|
|
2074
2133
|
// Post-eval unwrap \u2014 see evalAttrExpr note for the reason.
|
|
2075
2134
|
return (result && typeof result === 'function' && (result._isSignal || result._isDerived)) ? result() : result;
|
|
2076
2135
|
}
|
|
@@ -2237,8 +2296,8 @@ catch (e) {
|
|
|
2237
2296
|
const v = scope[k];
|
|
2238
2297
|
handlerScope[k] = (v && typeof v === 'function' && v._isStxLoopItem) ? v() : v;
|
|
2239
2298
|
});
|
|
2240
|
-
const fn =
|
|
2241
|
-
fn(...
|
|
2299
|
+
const fn = __stxCompileScoped(handlerScope, ['$event'], expr);
|
|
2300
|
+
fn(...__stxArgs(fn, handlerScope), event);
|
|
2242
2301
|
}
|
|
2243
2302
|
catch (e) {
|
|
2244
2303
|
// Event handlers fire on user interaction, not reactive re-runs \u2014 there's no
|
|
@@ -2547,7 +2606,7 @@ catch (e) {
|
|
|
2547
2606
|
return expressionCallsSignal(expression, prop)
|
|
2548
2607
|
|| expressionUsesSignalApi(expression, prop);
|
|
2549
2608
|
});
|
|
2550
|
-
var fn =
|
|
2609
|
+
var fn = __stxCompile(['__scope__'], 'with(__scope__) { return (' + expression + ') }');
|
|
2551
2610
|
value = fn(unwrapScope);
|
|
2552
2611
|
if (value && typeof value === 'function' && (value._isSignal || value._isDerived)) value = value();
|
|
2553
2612
|
}
|
|
@@ -2755,8 +2814,8 @@ catch (e) {
|
|
|
2755
2814
|
var memoExpr = el.getAttribute('data-stx-memo');
|
|
2756
2815
|
try {
|
|
2757
2816
|
var memoScope = { ...globalHelpers, ...scope, ...(findElementScope(el) || {}) };
|
|
2758
|
-
var memoFn =
|
|
2759
|
-
var memoVals = JSON.stringify(memoFn(...
|
|
2817
|
+
var memoFn = __stxCompileScoped(memoScope, [], 'return ' + memoExpr);
|
|
2818
|
+
var memoVals = JSON.stringify(memoFn(...__stxArgs(memoFn, memoScope)));
|
|
2760
2819
|
if (el.__stx_memo_prev === memoVals) {
|
|
2761
2820
|
return; // Dependencies unchanged \u2014 skip re-processing
|
|
2762
2821
|
}
|
|
@@ -2808,8 +2867,8 @@ catch (e) {
|
|
|
2808
2867
|
else {
|
|
2809
2868
|
// Use auto-unwrap proxy (Feature #1)
|
|
2810
2869
|
const unwrapScope = createExpressionAutoUnwrapProxy(capturedScope, expr);
|
|
2811
|
-
const fn =
|
|
2812
|
-
bindingNode.textContent = fn(...
|
|
2870
|
+
const fn = __stxCompileScoped(capturedScope, [], 'return ' + expr);
|
|
2871
|
+
bindingNode.textContent = fn(...__stxArgs(fn, unwrapScope));
|
|
2813
2872
|
}
|
|
2814
2873
|
}
|
|
2815
2874
|
catch (e) {
|
|
@@ -2817,8 +2876,8 @@ catch (e) {
|
|
|
2817
2876
|
// because it converts the signal to its value before the expression runs.
|
|
2818
2877
|
// Retry without auto-unwrap so signal functions remain callable.
|
|
2819
2878
|
try {
|
|
2820
|
-
const fn =
|
|
2821
|
-
bindingNode.textContent = fn(...
|
|
2879
|
+
const fn = __stxCompileScoped(capturedScope, [], 'return ' + expr);
|
|
2880
|
+
bindingNode.textContent = fn(...__stxArgs(fn, capturedScope));
|
|
2822
2881
|
}
|
|
2823
2882
|
catch (e2) {
|
|
2824
2883
|
if (!(e2 instanceof ReferenceError) && !(e2 instanceof TypeError)) console.warn('[STX] Expression error:', expr, e2);
|
|
@@ -2934,7 +2993,7 @@ else if (part) {
|
|
|
2934
2993
|
|
|
2935
2994
|
// Use auto-unwrap proxy (Feature #1)
|
|
2936
2995
|
const unwrapScope = createExpressionAutoUnwrapProxy(activeScope, expr);
|
|
2937
|
-
const fn =
|
|
2996
|
+
const fn = __stxCompile(['__scope__'], 'with(__scope__) { return (' + expr + ') }');
|
|
2938
2997
|
var value = maybeUnwrapSignal(fn(unwrapScope));
|
|
2939
2998
|
noteExprSuccess(expr);
|
|
2940
2999
|
return value;
|
|
@@ -2943,7 +3002,7 @@ catch (e) {
|
|
|
2943
3002
|
// Auto-unwrap can break explicit signal calls like errorData().message
|
|
2944
3003
|
// Retry without auto-unwrap so signal functions remain callable
|
|
2945
3004
|
try {
|
|
2946
|
-
const fn =
|
|
3005
|
+
const fn = __stxCompile(['__scope__'], 'with(__scope__) { return (' + expr + ') }');
|
|
2947
3006
|
var retried = maybeUnwrapSignal(fn(activeScope));
|
|
2948
3007
|
noteExprSuccess(expr);
|
|
2949
3008
|
return retried;
|
|
@@ -3257,7 +3316,7 @@ else if (name === 'ref' || name === ':ref' || name === 'x-ref' || name === 'data
|
|
|
3257
3316
|
return 'if(' + k + ' !== __s["' + k + '"]()) __s["' + k + '"].set(' + k + ')';
|
|
3258
3317
|
}).join(';');
|
|
3259
3318
|
var body = getVars + ';' + value + ';' + setVars;
|
|
3260
|
-
var fn2 =
|
|
3319
|
+
var fn2 = __stxCompile(['__s', '$event'], body);
|
|
3261
3320
|
fn2(eventCapturedScope, handlerEvent);
|
|
3262
3321
|
} else if (hasSignals) {
|
|
3263
3322
|
// Function calls with signals in scope keep any signal used through
|
|
@@ -3280,11 +3339,11 @@ else if (name === 'ref' || name === ':ref' || name === 'x-ref' || name === 'data
|
|
|
3280
3339
|
}
|
|
3281
3340
|
return 'var ' + k + ' = __s["' + k + '"] && typeof __s["' + k + '"] === "function" && __s["' + k + '"]._isSignal ? __s["' + k + '"]() : __s["' + k + '"]';
|
|
3282
3341
|
}).join(';');
|
|
3283
|
-
var fn3 =
|
|
3342
|
+
var fn3 = __stxCompile(['__s', '$event'], unwrapVars + ';' + value);
|
|
3284
3343
|
fn3(eventCapturedScope, handlerEvent);
|
|
3285
3344
|
} else {
|
|
3286
|
-
var fn =
|
|
3287
|
-
fn(...
|
|
3345
|
+
var fn = __stxCompileScoped(eventCapturedScope, ['$event'], value);
|
|
3346
|
+
fn(...__stxArgs(fn, eventCapturedScope), handlerEvent);
|
|
3288
3347
|
}
|
|
3289
3348
|
}
|
|
3290
3349
|
catch (e) {
|
|
@@ -3409,14 +3468,14 @@ catch (e) {
|
|
|
3409
3468
|
var value;
|
|
3410
3469
|
try {
|
|
3411
3470
|
var unwrapScope = createExpressionAutoUnwrapProxy(capturedScope, expr);
|
|
3412
|
-
var fn =
|
|
3413
|
-
value = fn(...
|
|
3471
|
+
var fn = __stxCompileScoped(capturedScope, [], 'return ' + expr);
|
|
3472
|
+
value = fn(...__stxArgs(fn, unwrapScope));
|
|
3414
3473
|
} catch (e1) {
|
|
3415
3474
|
// Retry without unwrapping \u2014 handles edge cases where the proxy
|
|
3416
3475
|
// interferes with certain expression patterns
|
|
3417
3476
|
try {
|
|
3418
|
-
var fn2 =
|
|
3419
|
-
value = fn2(...
|
|
3477
|
+
var fn2 = __stxCompileScoped(capturedScope, [], 'return ' + expr);
|
|
3478
|
+
value = fn2(...__stxArgs(fn2, capturedScope));
|
|
3420
3479
|
} catch (e2) {
|
|
3421
3480
|
// Suppress ReferenceError/TypeError during async init \u2014 a signal
|
|
3422
3481
|
// or object may not be ready yet on the first effect run, and
|
|
@@ -3461,7 +3520,7 @@ catch (e) {
|
|
|
3461
3520
|
return direct();
|
|
3462
3521
|
try {
|
|
3463
3522
|
var unwrapScope = createExpressionAutoUnwrapProxy(capturedScope, expr);
|
|
3464
|
-
var fn =
|
|
3523
|
+
var fn = __stxCompile(['__scope__'], 'with(__scope__) { return (' + expr + ') }');
|
|
3465
3524
|
return fn(unwrapScope);
|
|
3466
3525
|
}
|
|
3467
3526
|
catch (e) {
|
|
@@ -3489,7 +3548,7 @@ else {
|
|
|
3489
3548
|
// Routing through it also drops the old requirement that every scope
|
|
3490
3549
|
// key be a valid identifier, since nothing is destructured now.
|
|
3491
3550
|
var writeScope = createModelWriteProxy(capturedScope);
|
|
3492
|
-
var writeFn =
|
|
3551
|
+
var writeFn = __stxCompile(['__scope__', '__v__'], 'with(__scope__) { ' + expr + ' = __v__ }');
|
|
3493
3552
|
writeFn(writeScope, val);
|
|
3494
3553
|
}
|
|
3495
3554
|
}
|
|
@@ -3599,11 +3658,14 @@ else {
|
|
|
3599
3658
|
const capturedScope = { ...globalHelpers, ...passedScope, ...(findElementScope(el) || {}) };
|
|
3600
3659
|
const keys = Object.keys(capturedScope);
|
|
3601
3660
|
|
|
3602
|
-
// Pre-compile \u2014
|
|
3603
|
-
|
|
3661
|
+
// Pre-compile \u2014 only the names the expression mentions (see
|
|
3662
|
+
// __stxCompileScoped: reading every signal subscribed the class binding to
|
|
3663
|
+
// every signal on the page), and only valid JS identifiers.
|
|
3664
|
+
const mentioned = new Set(__stxNamesIn(expr));
|
|
3665
|
+
const safeKeys = keys.filter(k => mentioned.has(k) && /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(k));
|
|
3604
3666
|
let fn;
|
|
3605
3667
|
try {
|
|
3606
|
-
fn =
|
|
3668
|
+
fn = __stxCompile(safeKeys, 'return ' + expr);
|
|
3607
3669
|
} catch (e) {
|
|
3608
3670
|
console.warn('[STX] bindClass compile error:', expr, e);
|
|
3609
3671
|
return;
|
|
@@ -3672,13 +3734,13 @@ else {
|
|
|
3672
3734
|
// throw TypeError.
|
|
3673
3735
|
try {
|
|
3674
3736
|
const unwrapScope = createExpressionAutoUnwrapProxy(capturedScope, expr);
|
|
3675
|
-
const fn =
|
|
3676
|
-
return fn(...
|
|
3737
|
+
const fn = __stxCompileScoped(capturedScope, [], 'return ' + expr);
|
|
3738
|
+
return fn(...__stxArgs(fn, unwrapScope));
|
|
3677
3739
|
}
|
|
3678
3740
|
catch (e1) {
|
|
3679
3741
|
try {
|
|
3680
|
-
const fn2 =
|
|
3681
|
-
return fn2(...
|
|
3742
|
+
const fn2 = __stxCompileScoped(capturedScope, [], 'return ' + expr);
|
|
3743
|
+
return fn2(...__stxArgs(fn2, capturedScope));
|
|
3682
3744
|
}
|
|
3683
3745
|
catch (e2) {
|
|
3684
3746
|
if (!(e2 instanceof ReferenceError) && !(e2 instanceof TypeError)) console.warn('[STX] Style expression error:', expr, e2);
|
|
@@ -4163,8 +4225,8 @@ else {
|
|
|
4163
4225
|
return expressionCallsSignal(expression, prop)
|
|
4164
4226
|
|| expressionUsesSignalApi(expression, prop);
|
|
4165
4227
|
});
|
|
4166
|
-
const fn =
|
|
4167
|
-
return fn(...
|
|
4228
|
+
const fn = __stxCompileScoped(scope, [], 'return ' + expression);
|
|
4229
|
+
return fn(...__stxArgs(fn, unwrapScope));
|
|
4168
4230
|
}
|
|
4169
4231
|
catch (e) {
|
|
4170
4232
|
if (!(e instanceof ReferenceError) && !(e instanceof TypeError)) console.warn('[STX] Expression error:', expression, e);
|
|
@@ -4186,7 +4248,7 @@ catch (e) {
|
|
|
4186
4248
|
});
|
|
4187
4249
|
// new Function body is non-strict, so with() works \u2014 only accessed
|
|
4188
4250
|
// properties trigger the proxy's get trap and register as dependencies
|
|
4189
|
-
const fn =
|
|
4251
|
+
const fn = __stxCompile(['__scope__'], 'with(__scope__) { return ' + expression + ' }');
|
|
4190
4252
|
return fn(unwrapScope);
|
|
4191
4253
|
} catch (e) {
|
|
4192
4254
|
if (!(e instanceof ReferenceError) && !(e instanceof TypeError)) console.warn('[STX] Expression error:', expression, e);
|
|
@@ -4281,7 +4343,7 @@ catch (e) {
|
|
|
4281
4343
|
try {
|
|
4282
4344
|
const scope = { [itemName]: item };
|
|
4283
4345
|
if (indexName) scope[indexName] = index;
|
|
4284
|
-
const fn =
|
|
4346
|
+
const fn = __stxCompile([itemName, indexName || '_idx'], 'return ' + keyExpr);
|
|
4285
4347
|
return String(fn(item, index));
|
|
4286
4348
|
} catch (e) {
|
|
4287
4349
|
return String(index);
|
|
@@ -4704,12 +4766,12 @@ catch (e) {
|
|
|
4704
4766
|
try {
|
|
4705
4767
|
var unwrapScope = createExpressionAutoUnwrapProxy(scope, expression);
|
|
4706
4768
|
// new Function body is non-strict, so with() works.
|
|
4707
|
-
var fn =
|
|
4769
|
+
var fn = __stxCompile(['__scope__'], 'with(__scope__) { return ' + expression + ' }');
|
|
4708
4770
|
return fn(unwrapScope);
|
|
4709
4771
|
}
|
|
4710
4772
|
catch (e1) {
|
|
4711
4773
|
try {
|
|
4712
|
-
var fn2 =
|
|
4774
|
+
var fn2 = __stxCompile(['__scope__'], 'with(__scope__) { return ' + expression + ' }');
|
|
4713
4775
|
return fn2(scope);
|
|
4714
4776
|
}
|
|
4715
4777
|
catch (e2) {
|
|
@@ -4953,14 +5015,14 @@ catch (e) { /* a disposer of its own is not this branch's problem */ }
|
|
|
4953
5015
|
try {
|
|
4954
5016
|
const scope = { ...globalHelpers, ...capturedComponentScope, ...(capturedElementScope || {}) };
|
|
4955
5017
|
const unwrapScope = createExpressionAutoUnwrapProxy(scope, expression);
|
|
4956
|
-
const fn =
|
|
5018
|
+
const fn = __stxCompile(['__scope__'], 'with(__scope__) { return ' + expression + ' }');
|
|
4957
5019
|
return fn(unwrapScope);
|
|
4958
5020
|
}
|
|
4959
5021
|
catch (e1) {
|
|
4960
5022
|
try {
|
|
4961
5023
|
// Retry without the unwrap proxy so call-syntax (signal()) works.
|
|
4962
5024
|
const scope2 = { ...globalHelpers, ...capturedComponentScope, ...(capturedElementScope || {}) };
|
|
4963
|
-
const fn2 =
|
|
5025
|
+
const fn2 = __stxCompile(['__scope__'], 'with(__scope__) { return ' + expression + ' }');
|
|
4964
5026
|
return fn2(scope2);
|
|
4965
5027
|
}
|
|
4966
5028
|
catch (e2) {
|
|
@@ -8253,8 +8315,8 @@ else {
|
|
|
8253
8315
|
if (matches) {
|
|
8254
8316
|
matches.forEach(match => {
|
|
8255
8317
|
const expr = match.replace(/^\\{\\{\\s*|\\s*\\}\\}$/g, '');
|
|
8256
|
-
const fn =
|
|
8257
|
-
const value = fn(...
|
|
8318
|
+
const fn = __stxCompileScoped(componentScope, [], 'return ' + expr);
|
|
8319
|
+
const value = fn(...__stxArgs(fn, componentScope));
|
|
8258
8320
|
result = result.replace(match, value != null ? value : '');
|
|
8259
8321
|
});
|
|
8260
8322
|
}
|
|
@@ -8280,8 +8342,8 @@ else if (el.tagName === 'META') {
|
|
|
8280
8342
|
matches.forEach(match => {
|
|
8281
8343
|
const expr = match.replace(/^\\{\\{\\s*|\\s*\\}\\}$/g, '');
|
|
8282
8344
|
if (/^__[A-Z_]+__$/.test(expr.trim())) return;
|
|
8283
|
-
const fn =
|
|
8284
|
-
const value = fn(...
|
|
8345
|
+
const fn = __stxCompileScoped(componentScope, [], 'return ' + expr);
|
|
8346
|
+
const value = fn(...__stxArgs(fn, componentScope));
|
|
8285
8347
|
result = result.replace(match, value != null ? value : '');
|
|
8286
8348
|
});
|
|
8287
8349
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{go as b,ho as c,io as d}from"./chunk-
|
|
2
|
+
import{go as b,ho as c,io as d}from"./chunk-y3gd1g9s.js";import"./chunk-jc6wrxrh.js";import"./chunk-2xpdcr8c.js";import"./chunk-v90kxg77.js";import"./chunk-4arms0am.js";import"./chunk-135mme4g.js";import"./chunk-y4j6br2e.js";import"./chunk-w1asc0zd.js";import"./chunk-kd95t585.js";import"./chunk-rg473fqn.js";import"./chunk-xk402w4a.js";import"./chunk-dnard9gp.js";import"./chunk-vgx5077x.js";import{rv as a}from"./chunk-met6wtbk.js";import"./chunk-ta6z7k4p.js";import"./chunk-zxptxz2b.js";import"./chunk-7racewc5.js";import"./chunk-e03m4har.js";import"./chunk-vsqx756d.js";import"./chunk-m8kem5ca.js";export{b as rendersAsElement,c as processESImports,d as processComponents,a as freeIdentifiers};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{bm as x,fq as M}from"./chunk-
|
|
2
|
+
import{bm as x,fq as M}from"./chunk-y3gd1g9s.js";import"./chunk-jc6wrxrh.js";import"./chunk-2xpdcr8c.js";import"./chunk-v90kxg77.js";import"./chunk-4arms0am.js";import"./chunk-135mme4g.js";import{Ks as B,Ms as P}from"./chunk-y4j6br2e.js";import"./chunk-w1asc0zd.js";import"./chunk-kd95t585.js";import"./chunk-rg473fqn.js";import"./chunk-xk402w4a.js";import"./chunk-dnard9gp.js";import"./chunk-vgx5077x.js";import"./chunk-met6wtbk.js";import"./chunk-ta6z7k4p.js";import"./chunk-zxptxz2b.js";import"./chunk-7racewc5.js";import"./chunk-e03m4har.js";import"./chunk-vsqx756d.js";import"./chunk-m8kem5ca.js";import G from"path";var T=["broadcast","calculateDistance","canNotify","clearCookies","clearFetchCache","clearStorage","copyToClipboard","createShareableFile","defineForm","getBatteryLevel","getCookie","getCurrentPosition","getStorageKeys","getStorageSize","getVoices","hasBattery","hasCameraPermission","hasGeolocationPermission","hasMicrophonePermission","hasNotificationPermission","hasResizeObserver","hexToHsl","hexToRgb","isBroadcastChannelSupported","isCharging","isDeviceMotionSupported","isDeviceOrientationSupported","isEventSourceSupported","isEyeDropperSupported","isInFullscreen","isMutationObserverSupported","isPermissionGranted","isSpeechRecognitionSupported","isSpeechSynthesisSupported","isWakeLockSupported","isWebSocketSupported","notify","parseCookies","pickColor","prefetch","removeCookie","requestMediaPermissions","requestMotionPermission","requestNotificationPermission","requestOrientationPermission","setCookie","share","shareCurrentPage","shareFiles","shareText","shareURL","shareWithFallback","speak","stopSpeaking","toggleFullscreen","useAsyncData","useAttributeObserver","useAutoLogout","useAutoWakeLock","useBattery","useBreakpoint","useBroadcastChannel","useChannel","useChildListObserver","useClipboard","useColorHistory","useConditionalWakeLock","useCookies","useCopySelection","useDeviceMotion","useDeviceOrientation","useElementSize","useElementTextSelection","useElementVisibility","useEventSource","useEyeDropper","useFavicon","useForm","useFullscreen","useGeolocation","useGeolocationWatch","useHotkey","useIdle","useIdleState","useInfiniteScroll","useIntersectionObserver","useIntersectionObserverMultiple","useIsDesktop","useIsMobile","useIsTablet","useKeyPressed","useKeySequence","useKeyboard","useLastActive","useLazyLoad","useMeta","useMouse","useMouseInElement","useMutationObserver","useNetwork","useNotification","useOnline","useParallax","usePermission","usePermissions","usePointer","usePost","useResizeObserver","useResizeObserverMultiple","useSSE","useScroll","useSelectionPopup","useShare","useSpeechRecognition","useSpeechSynthesis","useStorage","useTextObserver","useTextSelection","useTitle","useVisibility","useWakeLock","useWindowSize"],O=new Set(T);var K=new Map,U=B(64),V=new Set,D=0,N=new Set(T);function f(){K.clear(),U.clear()}function S(H){let J=new Map;for(let Q of H){let Z=G.basename(Q);if(Z.endsWith(".d.ts"))continue;let z=Z.replace(/\.[jt]s$/,"");if(z==="index")continue;if(z===Z)continue;let X=J.get(z);if(X&&!X.endsWith(".js"))continue;J.set(z,Q)}return[...J.values()].sort()}function g(H,J){let Q=J.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");return new RegExp(`(?:^|[^\\w$.])(?:const|let|var|function|class)\\s+${Q}\\b`).test(H)}function y(H){if(!H)return[];let J=P(H,D),Q=U.get(J);if(Q)return Q.slice();let Z=H.replace(/<script\b[^>]*\bdata-stx-runtime\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-framework-composables\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-stores\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-composables\b[^>]*>[\s\S]*?<\/script>/gi,""),z=[];for(let X of N){if(V.has(X))continue;let A=X.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");if(new RegExp(`(^|[^\\w$.])${A}\\s*\\(`).test(Z))z.push(X)}return z.sort(),U.set(J,z),z.slice()}async function p(H,J){let Q=y(H);if(Q.length===0)return null;let Z=J??G.join(import.meta.dir,"composables"),z=`${Z}\x00${Q.join(",")}`,X=K.get(z);if(X!==void 0)return X||null;let A=M({loader:"ts",target:"browser",define:x()}),L=new Set(Q),W=[],C=new Set,F=[];try{let q=new Bun.Glob("*.{ts,js}");for await(let j of q.scan({cwd:Z,absolute:!0}))F.push(j)}catch{return K.set(z,""),null}F=S(F);for(let q of F){let j;try{j=await Bun.file(q).text()}catch{continue}let I=[];try{I=A.scan(j).exports.filter(($)=>$!=="default")}catch{continue}if(!I.some(($)=>L.has($)))continue;try{j=j.replace(/^import\s+.*from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),j=j.replace(/^import\s+type\s+.*$/gm,""),j=j.replace(/^export\s+\*\s+(?:as\s+\w+\s+)?from\s*['"][^'"]+['"]\s*;?\s*$/gm,""),j=j.replace(/^export\s+(?:type\s+)?\{[\s\S]*?\}\s*(?:from\s*['"][^'"]+['"]\s*)?;?\s*$/gm,""),j=j.replace(/^export\s+default\s+/gm,""),j=j.replace(/^export\s+(?=(?:declare\s+)?(?:abstract\s+)?(?:async\s+)?(?:function|class|const|let|var|type|interface|enum)\b)/gm,""),W.push(`// ${G.basename(q).replace(/\.[jt]s$/,"")}
|
|
3
3
|
${A.transformSync(j).trim()}`);for(let $ of I)C.add($)}catch($){console.warn(`[stx] framework composable ${G.basename(q)} could not be bundled:`,$)}}let Y=Q.filter((q)=>!C.has(q)&&!g(H,q));if(Y.length>0)console.warn(`[stx] could not bundle ${Y.join(", ")} from @stacksjs/stx/composables \u2014 `+"calls to them will throw ReferenceError in the browser. Import them explicitly so the bundler inlines them, or use a runtime equivalent from window.stx.");if(W.length===0)return K.set(z,""),null;let k=[...C].map((q)=>` try { if (!(${JSON.stringify(q)} in __s)) { __s[${JSON.stringify(q)}] = ${q}; if (!(${JSON.stringify(q)} in window)) window[${JSON.stringify(q)}] = ${q}; } } catch (e) {}`).join(`
|
|
4
4
|
`),w=`<script data-stx-framework-composables>
|
|
5
5
|
;(function(){
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{$m as l,Cm as P,Co as i,Ep as h,Io as T,Km as k,_m as c,sm as R,tm as O}from"./chunk-
|
|
2
|
+
import{$m as l,Cm as P,Co as i,Ep as h,Io as T,Km as k,_m as c,sm as R,tm as O}from"./chunk-y3gd1g9s.js";import{Ps as S,Rs as y}from"./chunk-y4j6br2e.js";import{Lu as m}from"./chunk-met6wtbk.js";import{Ew as YJ,Hw as ZJ,Iw as $J}from"./chunk-e03m4har.js";import{Pw as XJ,Sw as q}from"./chunk-m8kem5ca.js";var r=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/;function s(J,Y,Q){let X={fullTag:Q,content:Y,attrs:J};if(/\bserver\b/.test(J))return{...X,type:"server"};if(/\bdata-stx-scoped\b/.test(J))return{...X,type:"client"};if(r.test(Y))return{...X,type:"signals"};if(/\bclient\b/.test(J)||/\btype\s*=\s*["']module["']/.test(J)||/\bsrc\s*=/.test(J))return{...X,type:"client"};return{...X,type:"server"}}var o=/^<script\b([^>]*)>([\s\S]*)<\/script\s*>$/i;function C(J){let Y=[],Q=[],X=[],$=0;while($<J.length){let Z=J.indexOf("<",$);if(Z===-1)break;let U=y(J,Z);if(U>Z){$=U;continue}let W=S(J,Z);if(W>Z){let j=J.slice(Z,W),F=o.exec(j);if(F){let K=s(F[1],F[2],j);switch(K.type){case"signals":Y.push(K);break;case"client":Q.push(K);break;case"server":X.push(K);break}}$=W;continue}$=Z+(J.startsWith("<!--",Z)?4:1)}return{signals:Y,client:Q,server:X}}var a=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function t(J){let Y=[],Q=/<!--[\s\S]*?(?:-->|$)|<(script|style|textarea|title|template)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,X;while((X=Q.exec(J))!==null)Y.push({start:X.index,end:X.index+X[0].length});return Y}function v(J,Y){return Y.some((Q)=>J>=Q.start&&J<Q.end)}function e(J){let Y=(J||"").trim();if(!Y)return null;if(/[\s>+~,:]/.test(Y))return null;let Q={},X=Y,$=X.match(/^[a-z][\w-]*/i);if($)Q.tag=$[0].toLowerCase(),X=X.slice($[0].length);while(X.length>0){let Z=X.match(/^\[([\w-]+)(?:=(["']?)([^\]"']*)\2)?\]/);if(Z){if(Q.attr=Z[1],Z[3]!==void 0&&Z[3]!=="")Q.attrValue=Z[3];X=X.slice(Z[0].length);continue}let U=X.match(/^#([\w-]+)/);if(U){Q.id=U[1],X=X.slice(U[0].length);continue}let W=X.match(/^\.([\w-]+)/);if(W){Q.className=W[1],X=X.slice(W[0].length);continue}return null}if(!Q.tag&&!Q.attr&&!Q.id&&!Q.className)return null;return Q}function JJ(J,Y){if(Y.attr){if(!(Y.attrValue===void 0?new RegExp(`\\b${Y.attr}(?=[\\s=>/]|$)`,"i"):new RegExp(`\\b${Y.attr}\\s*=\\s*(["'])\\s*${Y.attrValue}\\s*\\1`,"i")).test(J))return!1}if(Y.id){if(!new RegExp(`\\bid\\s*=\\s*(["'])\\s*${Y.id}\\s*\\1`,"i").test(J))return!1}if(Y.className){let Q=J.match(/\bclass\s*=\s*(["'])([\s\S]*?)\1/i);if(!Q)return!1;if(!Q[2].split(/\s+/).includes(Y.className))return!1}return!0}function x(J,Y="main"){let Q=e(Y);if(!Q)return null;let X=/<([a-z][\w-]*)\b([^>]*)>/gi,$=t(J),Z;while((Z=X.exec(J))!==null){if(v(Z.index,$))continue;let U=Z[1].toLowerCase(),W=Z[2]||"";if(W.trimEnd().endsWith("/")||a.has(U))continue;if(Q.tag&&Q.tag!==U)continue;if(!JJ(W,Q))continue;let j=Z[0],F=Z.index+j.length,K=new RegExp(`<(/?)${U}\\b([^>]*)>`,"gi");K.lastIndex=F;let G=1,B;while((B=K.exec(J))!==null){if(v(B.index,$))continue;let w=B[1]==="/";if(!w&&(B[2]||"").trimEnd().endsWith("/"))continue;if(G+=w?-1:1,G===0)return{openTag:j,openIndex:Z.index,start:F,end:B.index,tagName:U}}return null}return null}var NJ="X-STX-Router",_J="private, no-store";function AJ(J){return J.replace(/&#(\d+);/g,(Y,Q)=>f(Number(Q),Y)).replace(/&#x([0-9a-f]+);/gi,(Y,Q)=>f(Number.parseInt(Q,16),Y)).replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&")}function f(J,Y){if(!Number.isInteger(J)||J<0||J>1114111)return Y;try{return String.fromCodePoint(J)}catch{return Y}}function g(J){return J.headers.get("X-STX-Router")==="true"}function QJ(J,Y){if(!J)return Y;return J.split(",").some((X)=>X.trim().toLowerCase()===Y.toLowerCase())?J:`${J}, ${Y}`}function IJ(J){return{Vary:QJ(J,"X-STX-Router")}}import E from"path";YJ();var UJ="stx-page-head:",WJ=/<!--stx-page-head:([A-Za-z0-9+/=]+)-->\n?/,D={dev:null,prod:null};function jJ(){let J=m()?"dev":"prod",Y=D[J];if(Y!==null)return Y;try{let Q=($J(),XJ(ZJ)),X=J==="dev"&&typeof Q.getRouterScriptDev==="function"?Q.getRouterScriptDev:Q.getRouterScript;D[J]=`<script>${X()}</script>`}catch{D[J]=""}return D[J]}async function RJ(J,Y){if(Y===!1)return null;if(Y&&typeof Y==="string"){let X=E.resolve(J,Y);if(await Bun.file(X).exists())return X;return null}let Q=E.join(J,"app.stx");if(await Bun.file(Q).exists())return Q;return null}async function PJ(J,Y){try{let Q=await Bun.file(J).text(),X=Q,$=Q.match(/<template\b[^>]*>([\s\S]*?)<\/template>/i);if($)X=$[1].trim();let Z=C(Q),U=[...Z.client.map((V)=>V.fullTag),...Z.signals.map((V)=>V.fullTag)],W=[],j=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,F;while((F=j.exec(Q))!==null)W.push(F[0]);let K=X;for(let V of Z.server)K=K.replace(V.fullTag,"");for(let V of Z.client)K=K.replace(V.fullTag,"");K=K.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let G="<!--__STX_PAGE_SLOT__-->";if(K=K.replace(/<slot\s*\/>/gi,G).replace(/<slot\s*>\s*<\/slot>/gi,G),!K.includes(G))return console.warn(`[stx] Shell ${J} has no <slot /> \u2014 pages won't be injected`),null;let{processDirectives:B,extractVariables:w,defaultConfig:N,loadStxConfig:A}=await import("./chunk-09xgdh4x.js"),I=await A(),z={__filename:J,__dirname:E.dirname(J)};for(let V of U){let L=V.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(L&&!V.includes("client")&&!V.includes('type="module"'))await w(L[1],z,J)}let _=await B(K,z,J,{...N,...I,...Y},new Set),H=_.indexOf(G);if(H===-1)return console.warn("[stx] Shell slot placeholder lost during processing"),null;return{beforeSlot:_.substring(0,H),afterSlot:_.substring(H+G.length),filePath:J,shellScripts:U,shellStyles:W}}catch(Q){return console.error(`[stx] Error processing shell ${J}:`,Q),null}}function kJ(J,Y,Q){let X,$="",Z=Y.match(WJ);if(Z){Y=Y.replace(Z[0],"");try{let K=Buffer.from(Z[1],"base64").toString("utf8"),G=K.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(G)X=G[1].trim();$=K.replace(/<title[^>]*>[\s\S]*?<\/title>/i,"").trim()}catch{}}let U=Q||X||"stx App",W=jJ(),j="<script>window.__stxRouterConfig={container:'[data-stx-content]'};</script>";return`<!DOCTYPE html>
|
|
3
3
|
<html lang="en">
|
|
4
4
|
<head>
|
|
5
5
|
<meta charset="UTF-8">
|
|
@@ -26,5 +26,5 @@ ${W}
|
|
|
26
26
|
`));if($.length>0)N.push($.join(`
|
|
27
27
|
`));if(G.length>0)N.push(G.join(`
|
|
28
28
|
`));return N.push(K),N.join(`
|
|
29
|
-
`)}import M from"fs";import p from"path";function fJ(J,Y,Q){return{version:1,buildTime:new Date().toISOString(),routes:J,assets:Y,outputDir:Q}}function gJ(J,Y){let Q=p.join(Y,"manifest.json");M.writeFileSync(Q,JSON.stringify(J,null,2))}function uJ(J){let Y=p.join(J,"manifest.json");if(!M.existsSync(Y))return null;try{let Q=M.readFileSync(Y,"utf-8"),X=JSON.parse(Q);if(X.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${X.version}`),null;return X}catch(Q){return console.warn("[stx] Failed to load manifest:",Q),null}}function b(J,Y,Q={}){let X=`${encodeURIComponent(J)}=${encodeURIComponent(Y)}`;if(Q.maxAge!==void 0)X+=`; Max-Age=${Q.maxAge}`;if(Q.expires)X+=`; Expires=${Q.expires.toUTCString()}`;if(Q.path)X+=`; Path=${Q.path}`;if(Q.domain)X+=`; Domain=${Q.domain}`;if(Q.secure)X+="; Secure";if(Q.httpOnly)X+="; HttpOnly";if(Q.sameSite)X+=`; SameSite=${Q.sameSite}`;return X}async function FJ(J){let Y=J.headers.get("content-type")||"",Q={},X=($,Z)=>{let U=Q[$];if(U===void 0)Q[$]=Z;else if(Array.isArray(U))U.push(Z);else Q[$]=[U,Z]};if(Y.includes("multipart/form-data")){let $=await J.formData();for(let[Z,U]of $.entries())if(typeof U==="string")X(Z,U);return Q}if(Y.includes("application/x-www-form-urlencoded")){for(let[$,Z]of new URLSearchParams(await J.text()).entries())X($,Z);return Q}return Q}function GJ(J){if(!J)return!1;let Y=J.toUpperCase();return Y!=="GET"&&Y!=="HEAD"}async function d(J,Y={}){let Q=Y.request,X=Y.method??Q?.method;if(!Q||!GJ(X))return{ran:!1};if(typeof J.action!=="function")return{ran:!1};let $={};try{$=await FJ(Q)}catch{}let Z=await J.action({request:Q,form:$,params:Y.params??{},query:J.query??{},cookies:Y.cookies??{}});if(Z&&typeof Z==="object"){let U=Z,W=zJ(U.cookies),j=U.redirect;if(typeof j==="string"&&j)return{redirect:j,ran:!0,...W.length>0?{cookies:W}:{}};let{cookies:F,redirect:K,...G}=U;if(Object.assign(J,G),W.length>0)return{ran:!0,cookies:W}}return{ran:!0}}function zJ(J){if(!J||typeof J!=="object"||Array.isArray(J))return[];let Y=[];for(let[Q,X]of Object.entries(J)){if(!Q)continue;if(typeof X==="string"){Y.push(b(Q,X));continue}if(X&&typeof X==="object"){let $=X;if(typeof $.value!=="string")continue;Y.push(b(Q,$.value,$))}}return Y}function dJ(J,Y=[],Q){let X=new Headers({Location:J,"Cache-Control":"no-store"});for(let $ of Y)X.append("Set-Cookie",$);for(let[$,Z]of Object.entries(Q??{}))if($.toLowerCase()!=="location")X.set($,Z);return new Response(null,{status:303,headers:X})}async function aJ(J,Y={}){return(await n(J,Y)).html}async function tJ(J,Y={}){let{html:Q,context:X,redirect:$,cookies:Z}=await n(J,Y),U=c(X),W=l(X);if($)return{html:Q,redirect:$,cookies:Z,status:U,headers:W};let{extractStreamBoundaries:j}=await import("./chunk-
|
|
29
|
+
`)}import M from"fs";import p from"path";function fJ(J,Y,Q){return{version:1,buildTime:new Date().toISOString(),routes:J,assets:Y,outputDir:Q}}function gJ(J,Y){let Q=p.join(Y,"manifest.json");M.writeFileSync(Q,JSON.stringify(J,null,2))}function uJ(J){let Y=p.join(J,"manifest.json");if(!M.existsSync(Y))return null;try{let Q=M.readFileSync(Y,"utf-8"),X=JSON.parse(Q);if(X.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${X.version}`),null;return X}catch(Q){return console.warn("[stx] Failed to load manifest:",Q),null}}function b(J,Y,Q={}){let X=`${encodeURIComponent(J)}=${encodeURIComponent(Y)}`;if(Q.maxAge!==void 0)X+=`; Max-Age=${Q.maxAge}`;if(Q.expires)X+=`; Expires=${Q.expires.toUTCString()}`;if(Q.path)X+=`; Path=${Q.path}`;if(Q.domain)X+=`; Domain=${Q.domain}`;if(Q.secure)X+="; Secure";if(Q.httpOnly)X+="; HttpOnly";if(Q.sameSite)X+=`; SameSite=${Q.sameSite}`;return X}async function FJ(J){let Y=J.headers.get("content-type")||"",Q={},X=($,Z)=>{let U=Q[$];if(U===void 0)Q[$]=Z;else if(Array.isArray(U))U.push(Z);else Q[$]=[U,Z]};if(Y.includes("multipart/form-data")){let $=await J.formData();for(let[Z,U]of $.entries())if(typeof U==="string")X(Z,U);return Q}if(Y.includes("application/x-www-form-urlencoded")){for(let[$,Z]of new URLSearchParams(await J.text()).entries())X($,Z);return Q}return Q}function GJ(J){if(!J)return!1;let Y=J.toUpperCase();return Y!=="GET"&&Y!=="HEAD"}async function d(J,Y={}){let Q=Y.request,X=Y.method??Q?.method;if(!Q||!GJ(X))return{ran:!1};if(typeof J.action!=="function")return{ran:!1};let $={};try{$=await FJ(Q)}catch{}let Z=await J.action({request:Q,form:$,params:Y.params??{},query:J.query??{},cookies:Y.cookies??{}});if(Z&&typeof Z==="object"){let U=Z,W=zJ(U.cookies),j=U.redirect;if(typeof j==="string"&&j)return{redirect:j,ran:!0,...W.length>0?{cookies:W}:{}};let{cookies:F,redirect:K,...G}=U;if(Object.assign(J,G),W.length>0)return{ran:!0,cookies:W}}return{ran:!0}}function zJ(J){if(!J||typeof J!=="object"||Array.isArray(J))return[];let Y=[];for(let[Q,X]of Object.entries(J)){if(!Q)continue;if(typeof X==="string"){Y.push(b(Q,X));continue}if(X&&typeof X==="object"){let $=X;if(typeof $.value!=="string")continue;Y.push(b(Q,$.value,$))}}return Y}function dJ(J,Y=[],Q){let X=new Headers({Location:J,"Cache-Control":"no-store"});for(let $ of Y)X.append("Set-Cookie",$);for(let[$,Z]of Object.entries(Q??{}))if($.toLowerCase()!=="location")X.set($,Z);return new Response(null,{status:303,headers:X})}async function aJ(J,Y={}){return(await n(J,Y)).html}async function tJ(J,Y={}){let{html:Q,context:X,redirect:$,cookies:Z}=await n(J,Y),U=c(X),W=l(X);if($)return{html:Q,redirect:$,cookies:Z,status:U,headers:W};let{extractStreamBoundaries:j}=await import("./chunk-v8ncfppj.js"),F=j(X),K=J.streamTemplates;if(K&&Object.keys(K).length>0){let{processDirectives:G}=await import("./chunk-9n4wz4p2.js"),{defaultConfig:B}=await import("./chunk-5gwf1fxm.js"),w=X.streamBoundaries||{},N={...B,autoShell:!1},A=Object.keys(K).map((z)=>({id:z,render:async()=>{let _=typeof w[z]==="function"?await w[z]():void 0;return G(K[z],{...X,$boundary:_},J.sourceFile,N,new Set)}})),I=new Set(A.map((z)=>z.id));F=[...(F||[]).filter((z)=>!I.has(z.id)),...A]}return{html:Q,boundaries:F&&F.length>0?F:void 0,cookies:Z,status:U,headers:W}}async function n(J,Y){let Q={__filename:J.sourceFile,__dirname:J.sourceFile.replace(/[/\\][^/\\]+$/,""),...Y};if(!J.hasServerScripts&&!O(J.html))return{html:J.html,context:Q};for(let U of J.serverScriptContent)try{await T(U,Q,J.sourceFile)}catch(W){if(Y.__stx_strict_hydration)throw W;console.warn(`[stx] Server script error in ${J.sourceFile}:`,W)}let X=await d(Q,{request:Y.request,method:Y.method,params:Y.params??{},cookies:Y.cookies??{}}),$=(U)=>{let W=U.replace(/<script\b[^>]*\bdata-stx-server-data\b[^>]*>[\s\S]*?<\/script>/gi,""),j=i(Q);if(!j)return W;let F=W.indexOf("</head>");return F<0?j+W:W.slice(0,F)+j+W.slice(F)};if(X.redirect)return{html:J.html,context:Q,redirect:X.redirect,cookies:X.cookies};if(!O(J.html))return{html:$(J.html),context:Q,cookies:X.cookies};let Z=new Map;for(let[U,W]of Object.entries(J.placeholders))if(W.expression)try{let j=k(W.expression,Q);if(W.type==="raw")Z.set(U,j!==void 0&&j!==null?String(j):"");else Z.set(U,j!==void 0&&j!==null?P(String(j)):"")}catch(j){if(Y.__stx_strict_hydration)throw j;Z.set(U,"")}return{html:$(R(J.html,Z)),context:Q,cookies:X.cookies}}async function eJ(J,Y={}){if(!J.hasServerScripts&&!O(J.fragment))return J.fragment;let Q={__filename:J.sourceFile,__dirname:J.sourceFile.replace(/[/\\][^/\\]+$/,""),...Y};for(let $ of J.serverScriptContent)try{await T($,Q,J.sourceFile)}catch(Z){console.warn(`[stx] Server script error in ${J.sourceFile}:`,Z)}if(!O(J.fragment))return J.fragment;let X=new Map;for(let[$,Z]of Object.entries(J.placeholders))if(Z.expression)try{let U=k(Z.expression,Q);if(Z.type==="raw")X.set($,U!==void 0&&U!==null?String(U):"");else X.set($,U!==void 0&&U!==null?P(String(U)):"")}catch{X.set($,"")}return R(J.fragment,X)}
|
|
30
30
|
export{s as Yf,C as Zf,e as _f,x as $f,NJ as ag,_J as bg,AJ as cg,g as dg,QJ as eg,IJ as fg,RJ as gg,PJ as hg,kJ as ig,KJ as jg,TJ as kg,SJ as lg,fJ as mg,gJ as ng,uJ as og,b as pg,FJ as qg,GJ as rg,d as sg,dJ as tg,aJ as ug,tJ as vg,eJ as wg};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Kj as b,Lj as c,Mj as d,Nj as e,Oj as f,Pj as g,Qj as h,Rj as i,Sj as j,Tj as k,Uj as l,Vj as m,Wj as n,Xj as o}from"./chunk-
|
|
2
|
+
import{Kj as b,Lj as c,Mj as d,Nj as e,Oj as f,Pj as g,Qj as h,Rj as i,Sj as j,Tj as k,Uj as l,Vj as m,Wj as n,Xj as o}from"./chunk-2wbs79rn.js";import{ul as a}from"./chunk-qjvny3wf.js";import"./chunk-y3gd1g9s.js";import"./chunk-jc6wrxrh.js";import"./chunk-2xpdcr8c.js";import"./chunk-v90kxg77.js";import"./chunk-4arms0am.js";import"./chunk-135mme4g.js";import"./chunk-y4j6br2e.js";import"./chunk-w1asc0zd.js";import"./chunk-kd95t585.js";import"./chunk-rg473fqn.js";import"./chunk-xk402w4a.js";import"./chunk-dnard9gp.js";import"./chunk-vgx5077x.js";import"./chunk-met6wtbk.js";import"./chunk-ta6z7k4p.js";import"./chunk-zxptxz2b.js";import"./chunk-7racewc5.js";import"./chunk-e03m4har.js";import"./chunk-vsqx756d.js";import"./chunk-m8kem5ca.js";export{b as templateCache,j as registerServeModuleBundle,c as readFileCached,e as invalidateFileCacheByDir,d as invalidateFileCache,o as hashFilePath,k as getServeModuleBundle,i as getServeClientAsset,g as getCachedSignalsRuntime,h as getCachedRouterScript,l as clearDevCaches,m as checkCache,n as cacheTemplate,a as cacheEngineFingerprint,f as __setSignalsGeneratorsForTest};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Bm as b}from"./chunk-
|
|
2
|
+
import{Bm as b}from"./chunk-y3gd1g9s.js";import{pv as L,tv as R}from"./chunk-met6wtbk.js";function P(j,U){let Q=1,J=U,B="<template",z="</template";while(J<j.length&&Q>0){let G=j.indexOf("<",J);if(G===-1)break;if(J=G,j.startsWith(B,J)&&(J+B.length>=j.length||/[\s>\/]/.test(j[J+B.length]))){Q++,J+=B.length;continue}if(j.startsWith(z,J)){let W=j.indexOf(">",J+z.length);if(W!==-1){if(Q--,Q===0)return W+1;J=W+1;continue}}J++}return Q===0?J:-1}var F=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function O(j,U){let Q=null;for(let J=U;J<j.length;J++){let B=j[J];if(Q){if(B==="\\"){J++;continue}if(B===Q)Q=null;continue}if(B==='"'||B==="'"){Q=B;continue}if(B===">")return J+1}return-1}function I(j,U,Q){let J=U.toLowerCase(),B=1,z=Q;while(z<j.length){let G=j.indexOf("<",z);if(G===-1)return-1;if(j.startsWith("<!--",G)){let $=j.indexOf("-->",G+4);z=$===-1?j.length:$+3;continue}let W=O(j,G+1);if(W===-1)return-1;let Z=j.slice(G,W),Y=Z.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(Y&&Y[2].toLowerCase()===J){if(Y[1]==="/"){if(B--,B===0)return W}else if(!/\/\s*>$/.test(Z))B++}z=W}return-1}function w(j){let U=[],Q=[],J=/\bslot\s*=\s*(?:"([^"]+)"|'([^']+)')/i,B=0;while(B<j.length){let z=j.indexOf("<",B);if(z===-1)break;if(j.startsWith("<!--",z)){let X=j.indexOf("-->",z+4);B=X===-1?j.length:X+3;continue}let G=O(j,z+1);if(G===-1)break;let W=j.slice(z,G),Z=W.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!Z){B=G;continue}let Y=Z[2].toLowerCase();if(Z[1]==="/"){let X=Q.lastIndexOf(Y);if(X!==-1)Q.splice(X);B=G;continue}let $=/\/\s*>$/.test(W),K=Q.length===0?W.match(J):null;if(K){let X=K[1]||K[2],H=W.replace(J,"").replace(/\s+(?=\/?>$)/,"").replace(/\s{2,}/g," "),_=$||F.has(Y)?-1:I(j,Y,G);if(_===-1)U.push({start:z,end:G,slotName:X,element:H}),B=G;else U.push({start:z,end:_,slotName:X,element:H+j.slice(G,_)}),B=_;continue}if(!$&&!F.has(Y)){if(Q.push(Y),Y==="script"||Y==="style"){let X=j.toLowerCase().indexOf(`</${Y}>`,G);if(X!==-1){B=X;continue}}}B=G}return U}function D(j){let U=[],Q=[],J=/^<template\s+(?:#([a-zA-Z][\w-]*)|v-slot:([a-zA-Z][\w-]*)|slot="([a-zA-Z][\w-]*)")(?:\s*=\s*"([^"]*)")?[^>]*>$/i,B=0;while(B<j.length){let z=j.indexOf("<",B);if(z===-1)break;if(j.startsWith("<!--",z)){let X=j.indexOf("-->",z+4);B=X===-1?j.length:X+3;continue}let G=O(j,z+1);if(G===-1)break;let W=j.slice(z,G),Z=W.match(/^<\s*(\/?)\s*([a-zA-Z][\w-]*)/);if(!Z){B=G;continue}let Y=Z[1]==="/",$=Z[2].toLowerCase();if(Y){let X=Q.lastIndexOf($);if(X!==-1)Q.splice(X);B=G;continue}if($==="template"&&Q.length===0){let X=W.match(J);if(X){let H=P(j,G);if(H!==-1){let _=X[1]||X[2]||X[3];U.push({start:z,end:H,slotName:_,content:j.slice(G,H-11).trim(),propsBinding:X[4]||void 0}),B=H;continue}}}if(!/\/\s*>$/.test(W)&&!F.has($)){if(Q.push($),$==="script"||$==="style"){let X=j.toLowerCase().indexOf(`</${$}>`,G);if(X!==-1){B=X;continue}}}B=G}return U}function v(j){let U={default:"",named:new Map},Q=j,J=D(j);for(let z of J)U.named.set(z.slotName,{name:z.slotName,content:z.content,propsBinding:z.propsBinding});J.sort((z,G)=>G.start-z.start);for(let z of J)Q=Q.slice(0,z.start)+Q.slice(z.end);let B=w(Q);for(let z of B){let G=U.named.get(z.slotName);if(G)G.content+=z.element;else U.named.set(z.slotName,{name:z.slotName,content:z.element})}for(let z=B.length-1;z>=0;z--){let G=B[z];Q=Q.slice(0,G.start)+Q.slice(G.end)}return U.default=Q.trim(),U}function S(j){let U=j.match(/name\s*=\s*["']([^"']+)["']/),Q=U?U[1]:"",J={},B=/:([a-zA-Z][\w-]*)\s*=\s*["']([^"']+)["']/g,z;while((z=B.exec(j))!==null)J[z[1]]=z[2];let G=j.match(/<slot[^>]*>([\s\S]*?)<\/slot>/i),W=G?G[1].trim():"";return{name:Q,props:J,defaultContent:W}}async function k(j,U,Q,J){if(!j)return Q;let B=j.content;if(j.propsBinding&&Object.keys(U).length>0){let z=j.propsBinding.trim(),G={...J};if(z.startsWith("{")&&z.endsWith("}")){let W=z.slice(1,-1).split(",").map((Z)=>Z.trim()).filter(Boolean);for(let Z of W){let[Y,$]=Z.split(":").map((X)=>X.trim()),K=$||Y;if(U[Y]!==void 0)G[K]=U[Y]}}else G[z]=U;B=N(B,G)}return B}function N(j,U){return j.replace(/\{\{\s*([^}]+)\s*\}\}/g,(Q,J)=>{try{let B=J.trim(),z=y(B,U);return b(String(z??""))}catch{return`{{ ${J} }}`}})}function y(j,U){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test(j)){let J=j.split("."),B=U;for(let z of J)if(B&&typeof B==="object"&&z in B)B=B[z];else return;return B}let Q=j.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(Q){let[,J,B,z]=Q,G=U[J],W=parseInt(z,10);if(typeof G==="number")switch(B){case"+":return G+W;case"-":return G-W;case"*":return G*W;case"/":return G/W}}try{if(!L(j))return;return R(j,Object.keys(U))(...Object.values(U))}catch{return}}async function T(j,U,Q){let J=j;J=await C(J,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(G,W,Z,Y)=>{let $=U.named.get(W),K=Y?.trim()||"",X=Z||"",H={},_=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,q;while((q=_.exec(X))!==null){let A=q[1],V=q[2];H[A]=y(V,Q)}return await k($,H,K,Q)});let z=/<slot\b((?:"[^"]*"|'[^']*'|[^>"'])*?)\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return J=J.replace(z,(G,W,Z)=>{if(/\bname\s*=/.test(W||""))return G;let Y=Z?.trim()||"";return U.default||Y}),J}async function C(j,U,Q){let J=[],B=[];j.replace(U,(W,...Z)=>{let Y=Z[Z.length-2];return B.push({match:W,index:Y}),J.push(Q(W,...Z.slice(0,-2))),W});let z=await Promise.all(J),G=j;for(let W=B.length-1;W>=0;W--){let{match:Z,index:Y}=B[W];G=G.slice(0,Y)+z[W]+G.slice(Y+Z.length)}return G}function E(j){let U=v(j);return{defaultSlot:U.default,namedSlots:U.named}}async function x(j,U,Q,J){return await T(j,{default:U,named:Q},J)}
|
|
3
3
|
export{v as Lg,S as Mg,k as Ng,T as Og,E as Pg,x as Qg};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Bm as O,Io as R,Lp as H,qq as x,vr as g}from"./chunk-
|
|
2
|
+
import{Bm as O,Io as R,Lp as H,qq as x,vr as g}from"./chunk-y3gd1g9s.js";import b from"path";var v={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},M=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g;var T=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;function f(q){let B=[],Q=0,G;T.lastIndex=0;while((G=T.exec(q))!==null){if(G.index>Q){let X=q.slice(Q,G.index);if(X.trim())B.push({type:B.length===0?"shell":"content",content:X})}let J=G[1],K=G[2];B.push({type:"suspense",name:J,content:K}),Q=G.index+G[0].length}if(Q<q.length){let J=q.slice(Q);if(J.trim())B.push({type:B.length===0?"shell":"content",content:J})}if(B.length===0)B.push({type:"shell",content:q});return B}async function r(q,B={},Q={}){let G={...g,...Q,streaming:{...v,...Q.streaming}},J=G.streaming?.bufferSize||16384;return new ReadableStream({async start(K){try{let X=await Bun.file(q).text(),z=X.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),L=z?z[1]:"",Y=X.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),j={...B,__filename:q,__dirname:b.dirname(q)};if(L.trim())await R(L,j,q);let D=f(Y),$=new Set;if(!D.some((w)=>w.type==="suspense")){let w=G.streaming?.strategy||"auto",U=new RegExp(M.source,"g");if(!(w!=="manual"&&U.test(Y))){let F=await H(Y,j,q,G,$);for(let V=0;V<F.length;V+=J)K.enqueue(F.slice(V,V+J)),await new Promise((W)=>setTimeout(W,0))}else{let F=[],V=new RegExp(M.source,"g"),W;while((W=V.exec(Y))!==null)F.push({name:W[1],content:W[2],start:W.index,end:W.index+W[0].length});let y=0;for(let A of F){if(A.start>y){let k=Y.slice(y,A.start);if(k.trim()){let E=await H(k,j,q,G,$);K.enqueue(E),await new Promise((S)=>setTimeout(S,0))}}let I=await H(A.content,j,q,G,$);K.enqueue(I),await new Promise((k)=>setTimeout(k,0)),y=A.end}if(y<Y.length){let A=Y.slice(y);if(A.trim()){let I=await H(A,j,q,G,$);K.enqueue(I)}}}}else{let w=new Map;for(let Z of D)if(Z.type==="shell"||Z.type==="content"){let F=await H(Z.content,j,q,G,$);K.enqueue(F)}else if(Z.type==="suspense"&&Z.name){let F=`stx-suspense-${Z.name}`;K.enqueue(`<div id="${F}" data-suspense="${Z.name}" style="display:contents;">
|
|
3
3
|
<template data-suspense-fallback>Loading...</template>
|
|
4
4
|
</div>`),w.set(Z.name,H(Z.content,j,q,G,$))}K.enqueue(`
|
|
5
5
|
<script>
|