@stacksjs/stx 0.2.531 → 0.2.533
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-ktmacsqc.js → chunk-01343ehq.js} +2 -2
- package/dist/chunk-0e5nasyf.js +2 -0
- package/dist/chunk-13zbt9py.js +2 -0
- package/dist/{chunk-9w2vmfha.js → chunk-1c4t7ncb.js} +2 -2
- package/dist/{chunk-gxfnmjzp.js → chunk-1xgs9gd5.js} +2 -2
- package/dist/{chunk-hrrxggpx.js → chunk-2bvk0qyd.js} +63 -12
- package/dist/{chunk-cp8f1pv4.js → chunk-2h4f37kx.js} +2 -2
- package/dist/{chunk-q6e45gnw.js → chunk-2kvbg3t5.js} +3 -3
- package/dist/{chunk-8n7qsr17.js → chunk-2n4je46m.js} +2 -2
- package/dist/{chunk-xcfhy5bj.js → chunk-33bzhsyw.js} +2 -2
- package/dist/{chunk-7ybgfk0m.js → chunk-3nk8cnrm.js} +2 -2
- package/dist/{chunk-gsxb0ry9.js → chunk-3r1m3tyr.js} +1 -1
- package/dist/chunk-3zs8yxy0.js +2 -0
- package/dist/{chunk-d3mssbgp.js → chunk-40hbpz2b.js} +5 -5
- package/dist/chunk-4a7v51vh.js +2 -0
- package/dist/{chunk-xtknewf7.js → chunk-4hyhr5r7.js} +1 -1
- package/dist/{chunk-srcv6wvm.js → chunk-4pxc3r1p.js} +4 -4
- package/dist/chunk-4qts8zk7.js +2 -0
- package/dist/{chunk-587ehsxn.js → chunk-4r7s3862.js} +2 -2
- package/dist/chunk-4y2av4ev.js +2 -0
- package/dist/chunk-5g498pdp.js +2 -0
- package/dist/chunk-5gq8m2m7.js +2 -0
- package/dist/chunk-5wx323bm.js +2 -0
- package/dist/{chunk-d2r8t40y.js → chunk-66s4nhp7.js} +2 -2
- package/dist/{chunk-d7x6n702.js → chunk-6dtmants.js} +3 -3
- package/dist/chunk-6rcxtdh3.js +2 -0
- package/dist/{chunk-st79dqpz.js → chunk-6sd4zdtg.js} +1 -1
- package/dist/{chunk-zpdq0kx1.js → chunk-6tnh3cyq.js} +1 -1
- package/dist/chunk-6va8wt88.js +2 -0
- package/dist/chunk-7v2j9bmc.js +2 -0
- package/dist/chunk-7zgtdap7.js +2 -0
- package/dist/{chunk-rsy1r1t2.js → chunk-843y0pfg.js} +4 -4
- package/dist/{chunk-b0tmg1q1.js → chunk-8chxczpj.js} +3 -3
- package/dist/{chunk-b7xdk1g4.js → chunk-8m1y1kyr.js} +5 -5
- package/dist/chunk-90kzf313.js +2 -0
- package/dist/{chunk-m5c2gts6.js → chunk-93n6yv5x.js} +12 -12
- package/dist/chunk-94rg5s6c.js +2 -0
- package/dist/chunk-9674w2gm.js +2 -0
- package/dist/{chunk-tvssmzc2.js → chunk-9p6bt089.js} +3 -3
- package/dist/{chunk-kg77xs08.js → chunk-bczcm7jk.js} +2 -2
- package/dist/{chunk-v38kqjew.js → chunk-bxsehntq.js} +1 -1
- package/dist/{chunk-vg8thz41.js → chunk-c56qtne1.js} +1 -1
- package/dist/chunk-d1jxmhph.js +2 -0
- package/dist/{chunk-5tj6expd.js → chunk-d7zterbp.js} +2 -2
- package/dist/{chunk-mc5agc81.js → chunk-d871008z.js} +4 -4
- package/dist/chunk-dekpf1ry.js +2 -0
- package/dist/chunk-epa1c4q4.js +2 -0
- package/dist/{chunk-95z7yemm.js → chunk-f3q84h7b.js} +2 -2
- package/dist/{chunk-mwte3cbe.js → chunk-fqfqyn48.js} +4 -4
- package/dist/{chunk-qwpgggkj.js → chunk-gnx0fzne.js} +60 -60
- package/dist/chunk-gsc5t942.js +2 -0
- package/dist/chunk-gsm1y1kb.js +2 -0
- package/dist/chunk-gxedmh17.js +2 -0
- package/dist/{chunk-9xq5yer8.js → chunk-h4crv0by.js} +1 -1
- package/dist/{chunk-pr5q4wev.js → chunk-hp8g2q2n.js} +1 -1
- package/dist/{chunk-38w14qs7.js → chunk-hvpzy98g.js} +1 -1
- package/dist/chunk-j9c0yam7.js +2 -0
- package/dist/{chunk-12e4a0ab.js → chunk-jbfad9cc.js} +2 -2
- package/dist/chunk-jv3jj612.js +2 -0
- package/dist/chunk-jvqas8y2.js +2 -0
- package/dist/{chunk-z14e2qyn.js → chunk-k3v13vfr.js} +2 -2
- package/dist/chunk-kcs7hyep.js +2 -0
- package/dist/chunk-kvp0at16.js +2 -0
- package/dist/{chunk-31c1g3rt.js → chunk-m011s2ha.js} +3 -3
- package/dist/{chunk-2jk0vceh.js → chunk-m56m95gk.js} +2 -2
- package/dist/{chunk-7s14bthq.js → chunk-m5fw8jq1.js} +2 -2
- package/dist/chunk-m7jmpech.js +2 -0
- package/dist/chunk-m8n9wxba.js +2 -0
- package/dist/{chunk-fyxydww2.js → chunk-mjdyyekx.js} +2 -2
- package/dist/{chunk-ennxrn5g.js → chunk-nd8v4xgb.js} +5 -5
- package/dist/chunk-ngma9vzc.js +2 -0
- package/dist/{chunk-rtk6n3vh.js → chunk-ngxqydsg.js} +3 -3
- package/dist/{chunk-cxxcy624.js → chunk-nmy4x6dx.js} +4 -4
- package/dist/chunk-pz1mjgsp.js +2 -0
- package/dist/{chunk-er031j13.js → chunk-qfc912e5.js} +2 -2
- package/dist/chunk-qk3ptn6h.js +2 -0
- package/dist/{chunk-03wggzg8.js → chunk-qmza4327.js} +2 -2
- package/dist/{chunk-w3xs6kb9.js → chunk-qqr4rn9p.js} +4 -4
- package/dist/chunk-rx4hz615.js +2 -0
- package/dist/chunk-shf0hd05.js +2 -0
- package/dist/{chunk-3vvppnws.js → chunk-sqb6gkzf.js} +8374 -8374
- package/dist/chunk-t1g1sp2z.js +2 -0
- package/dist/{chunk-9f3m5ecs.js → chunk-tgc645pa.js} +45 -45
- package/dist/{chunk-2dzd2h15.js → chunk-tkvp3rz0.js} +1 -1
- package/dist/{chunk-458etq5a.js → chunk-tqnh98j7.js} +3 -3
- package/dist/chunk-tr9bjtqx.js +2 -0
- package/dist/{chunk-2y6tzn6d.js → chunk-ty1v368m.js} +2 -2
- package/dist/{chunk-fmp8dmt0.js → chunk-v4r8nzf3.js} +1 -1
- package/dist/{chunk-p8yh7mgr.js → chunk-v9vvzdag.js} +2 -2
- package/dist/{chunk-0wvsfs4s.js → chunk-vb4xxpa6.js} +2 -2
- package/dist/chunk-vfnerp7h.js +2 -0
- package/dist/{chunk-tkeabv04.js → chunk-vhfwnvmc.js} +5 -5
- package/dist/{chunk-15r72kw7.js → chunk-vjdj0ex3.js} +1 -1
- package/dist/{chunk-9pztpvvk.js → chunk-wh7xn313.js} +1 -1
- package/dist/chunk-wjt46tdp.js +2 -0
- package/dist/chunk-wxy9re1a.js +2 -0
- package/dist/{chunk-kwvexxey.js → chunk-x607yxrc.js} +3 -3
- package/dist/{chunk-3zyvhf4p.js → chunk-xey01yna.js} +1 -1
- package/dist/{chunk-7b2hj6nt.js → chunk-xwrbrg1q.js} +1 -1
- package/dist/{chunk-9sqjmd9a.js → chunk-y18yvcjb.js} +5 -5
- package/dist/chunk-ydtnskdv.js +2 -0
- package/dist/{chunk-ky25egh1.js → chunk-yw3cqy43.js} +1 -1
- package/dist/{chunk-tyts58ks.js → chunk-z9r3tqyr.js} +1 -1
- package/dist/chunk-zeve89kw.js +2 -0
- package/dist/cli.js +12 -12
- package/dist/client/signals-appearance-runtime.d.ts +2 -0
- package/dist/client/signals-appearance-runtime.js +283 -0
- package/dist/client/signals-authoring-runtime.d.ts +2 -0
- package/dist/client/signals-authoring-runtime.js +187 -0
- package/dist/client/signals-binding-utils-runtime.d.ts +2 -0
- package/dist/client/signals-binding-utils-runtime.js +130 -0
- package/dist/client/signals-bootstrap-runtime.d.ts +4 -0
- package/dist/client/signals-bootstrap-runtime.js +24 -0
- package/dist/client/signals-class-runtime.d.ts +2 -0
- package/dist/client/signals-class-runtime.js +69 -0
- package/dist/client/signals-component-api-runtime.d.ts +1 -0
- package/dist/client/signals-component-api-runtime.js +57 -0
- package/dist/client/signals-component-hydration-runtime.d.ts +2 -0
- package/dist/client/signals-component-hydration-runtime.js +147 -0
- package/dist/client/signals-component-props-runtime.d.ts +2 -0
- package/dist/client/signals-component-props-runtime.js +90 -0
- package/dist/client/signals-conditional-chain-runtime.d.ts +2 -0
- package/dist/client/signals-conditional-chain-runtime.js +39 -0
- package/dist/client/signals-conditional-component-runtime.d.ts +2 -0
- package/dist/client/signals-conditional-component-runtime.js +82 -0
- package/dist/client/signals-container-cleanup-runtime.d.ts +2 -0
- package/dist/client/signals-container-cleanup-runtime.js +42 -0
- package/dist/client/signals-context-runtime.d.ts +2 -0
- package/dist/client/signals-context-runtime.js +48 -0
- package/dist/client/signals-cookie-runtime.d.ts +2 -0
- package/dist/client/signals-cookie-runtime.js +56 -0
- package/dist/client/signals-devtools-runtime.d.ts +2 -0
- package/dist/client/signals-devtools-runtime.js +136 -0
- package/dist/client/signals-dialog-runtime.d.ts +2 -0
- package/dist/client/signals-dialog-runtime.js +195 -0
- package/dist/client/signals-dom-ready-runtime.d.ts +2 -0
- package/dist/client/signals-dom-ready-runtime.js +306 -0
- package/dist/client/signals-drawer-runtime.d.ts +2 -0
- package/dist/client/signals-drawer-runtime.js +39 -0
- package/dist/client/signals-effect-runtime.d.ts +2 -0
- package/dist/client/signals-effect-runtime.js +157 -0
- package/dist/client/signals-event-shorthand-runtime.d.ts +2 -0
- package/dist/client/signals-event-shorthand-runtime.js +88 -0
- package/dist/client/signals-expression-compiler-runtime.d.ts +2 -0
- package/dist/client/signals-expression-compiler-runtime.js +59 -0
- package/dist/client/signals-expression-runtime.d.ts +2 -0
- package/dist/client/signals-expression-runtime.js +67 -0
- package/dist/client/signals-fetch-runtime.d.ts +2 -0
- package/dist/client/signals-fetch-runtime.js +144 -0
- package/dist/client/signals-fetch-transport-runtime.d.ts +2 -0
- package/dist/client/signals-fetch-transport-runtime.js +216 -0
- package/dist/client/signals-for-runtime.d.ts +2 -0
- package/dist/client/signals-for-runtime.js +647 -0
- package/dist/client/signals-globals-runtime.d.ts +2 -0
- package/dist/client/signals-globals-runtime.js +66 -0
- package/dist/client/signals-handler-runtime.d.ts +2 -0
- package/dist/client/signals-handler-runtime.js +80 -0
- package/dist/client/signals-head-runtime.d.ts +2 -0
- package/dist/client/signals-head-runtime.js +92 -0
- package/dist/client/signals-helpers-runtime.d.ts +2 -0
- package/dist/client/signals-helpers-runtime.js +137 -0
- package/dist/client/signals-host-runtime.d.ts +9 -0
- package/dist/client/signals-host-runtime.js +132 -0
- package/dist/client/signals-hydration-audit-runtime.d.ts +2 -0
- package/dist/client/signals-hydration-audit-runtime.js +209 -0
- package/dist/client/signals-hydration-runtime.d.ts +2 -0
- package/dist/client/signals-hydration-runtime.js +52 -0
- package/dist/client/signals-if-chain-runtime.d.ts +2 -0
- package/dist/client/signals-if-chain-runtime.js +283 -0
- package/dist/client/signals-if-runtime.d.ts +2 -0
- package/dist/client/signals-if-runtime.js +346 -0
- package/dist/client/signals-kept-runtime.d.ts +2 -0
- package/dist/client/signals-kept-runtime.js +62 -0
- package/dist/client/signals-lazy-hydration-runtime.d.ts +2 -0
- package/dist/client/signals-lazy-hydration-runtime.js +133 -0
- package/dist/client/signals-lifecycle-runtime.d.ts +2 -0
- package/dist/client/signals-lifecycle-runtime.js +114 -0
- package/dist/client/signals-loop-component-remap-runtime.d.ts +2 -0
- package/dist/client/signals-loop-component-remap-runtime.js +66 -0
- package/dist/client/signals-loop-conditional-runtime.d.ts +2 -0
- package/dist/client/signals-loop-conditional-runtime.js +48 -0
- package/dist/client/signals-loop-row-runtime.d.ts +2 -0
- package/dist/client/signals-loop-row-runtime.js +41 -0
- package/dist/client/signals-manifest-hydration-runtime.d.ts +2 -0
- package/dist/client/signals-manifest-hydration-runtime.js +82 -0
- package/dist/client/signals-model-runtime.d.ts +2 -0
- package/dist/client/signals-model-runtime.js +156 -0
- package/dist/client/signals-mount-runtime.d.ts +1 -0
- package/dist/client/signals-mount-runtime.js +231 -0
- package/dist/client/signals-navigation-runtime.d.ts +2 -0
- package/dist/client/signals-navigation-runtime.js +198 -0
- package/dist/client/signals-optimistic-runtime.d.ts +2 -0
- package/dist/client/signals-optimistic-runtime.js +34 -0
- package/dist/client/signals-overlay-runtime.d.ts +2 -0
- package/dist/client/signals-overlay-runtime.js +352 -0
- package/dist/client/signals-pipe-runtime.d.ts +2 -0
- package/dist/client/signals-pipe-runtime.js +177 -0
- package/dist/client/signals-process-element-runtime.d.ts +1 -0
- package/dist/client/signals-process-element-runtime.js +696 -0
- package/dist/client/signals-proxy-runtime.d.ts +2 -0
- package/dist/client/signals-proxy-runtime.js +78 -0
- package/dist/client/signals-public-api-runtime.d.ts +1 -0
- package/dist/client/signals-public-api-runtime.js +120 -0
- package/dist/client/signals-query-runtime.d.ts +2 -0
- package/dist/client/signals-query-runtime.js +351 -0
- package/dist/client/signals-reactive-core-bootstrap-runtime.d.ts +1 -0
- package/dist/client/signals-reactive-core-bootstrap-runtime.js +30 -0
- package/dist/client/signals-reactive-runtime.d.ts +2 -0
- package/dist/client/signals-reactive-runtime.js +67 -0
- package/dist/client/signals-ref-runtime.d.ts +2 -0
- package/dist/client/signals-ref-runtime.js +33 -0
- package/dist/client/signals-scope-disposal-runtime.d.ts +2 -0
- package/dist/client/signals-scope-disposal-runtime.js +195 -0
- package/dist/client/signals-scope-traversal-runtime.d.ts +2 -0
- package/dist/client/signals-scope-traversal-runtime.js +42 -0
- package/dist/client/signals-show-runtime.d.ts +2 -0
- package/dist/client/signals-show-runtime.js +54 -0
- package/dist/client/signals-spa-load-control-runtime.d.ts +2 -0
- package/dist/client/signals-spa-load-control-runtime.js +42 -0
- package/dist/client/signals-spa-load-runtime.d.ts +2 -0
- package/dist/client/signals-spa-load-runtime.js +187 -0
- package/dist/client/signals-state-runtime.d.ts +2 -0
- package/dist/client/signals-state-runtime.js +125 -0
- package/dist/client/signals-storage-runtime.d.ts +2 -0
- package/dist/client/signals-storage-runtime.js +79 -0
- package/dist/client/signals-store-registry-runtime.d.ts +1 -0
- package/dist/client/signals-store-registry-runtime.js +461 -0
- package/dist/client/signals-style-runtime.d.ts +2 -0
- package/dist/client/signals-style-runtime.js +35 -0
- package/dist/client/signals-suspense-runtime.d.ts +2 -0
- package/dist/client/signals-suspense-runtime.js +59 -0
- package/dist/client/signals-timer-runtime.d.ts +2 -0
- package/dist/client/signals-timer-runtime.js +378 -0
- package/dist/client/signals-toast-runtime.d.ts +2 -0
- package/dist/client/signals-toast-runtime.js +206 -0
- package/dist/client/signals-tooltip-runtime.d.ts +2 -0
- package/dist/client/signals-tooltip-runtime.js +40 -0
- package/dist/client/signals-transition-group-runtime.d.ts +2 -0
- package/dist/client/signals-transition-group-runtime.js +92 -0
- package/dist/client/signals-websocket-runtime.d.ts +2 -0
- package/dist/client/signals-websocket-runtime.js +138 -0
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/native/runtime/native-host.js +4 -1
- package/dist/pwa.js +3 -3
- package/dist/signals-context-runtime.d.ts +2 -0
- package/dist/signals-drawer-runtime.d.ts +2 -0
- package/dist/signals-host-runtime.d.ts +9 -0
- package/dist/signals-loop-conditional-runtime.d.ts +2 -0
- package/dist/signals-manifest-hydration-runtime.d.ts +2 -0
- package/dist/signals-optimistic-runtime.d.ts +2 -0
- package/dist/signals-overlay-runtime.d.ts +2 -0
- package/dist/signals-scope-disposal-runtime.d.ts +2 -0
- package/dist/signals-spa-load-control-runtime.d.ts +2 -0
- package/dist/signals-storage-runtime.d.ts +2 -0
- package/dist/signals.js +141 -9900
- package/dist/ssg.js +3 -3
- package/package.json +5 -5
- package/dist/chunk-0zmv31nc.js +0 -2
- package/dist/chunk-1cdanx2v.js +0 -2
- package/dist/chunk-1wt5fagh.js +0 -2
- package/dist/chunk-2936t942.js +0 -2
- package/dist/chunk-3dd5zxbt.js +0 -2
- package/dist/chunk-3v91cb0g.js +0 -2
- package/dist/chunk-4cyjdghc.js +0 -2
- package/dist/chunk-5achv4zv.js +0 -2
- package/dist/chunk-5yg6m30k.js +0 -2
- package/dist/chunk-6qzjyr8e.js +0 -2
- package/dist/chunk-785ckss2.js +0 -2
- package/dist/chunk-88kjwkza.js +0 -2
- package/dist/chunk-8bcvb86w.js +0 -2
- package/dist/chunk-8h1zg44w.js +0 -2
- package/dist/chunk-8jtyra19.js +0 -2
- package/dist/chunk-bnsz09pg.js +0 -2
- package/dist/chunk-c9rwnsk7.js +0 -2
- package/dist/chunk-csjax0ej.js +0 -2
- package/dist/chunk-dd31q423.js +0 -2
- package/dist/chunk-dptjyncv.js +0 -2
- package/dist/chunk-et8ejd7k.js +0 -2
- package/dist/chunk-g1kyy5h1.js +0 -2
- package/dist/chunk-h791c7sb.js +0 -2
- package/dist/chunk-h88jcr3k.js +0 -2
- package/dist/chunk-hvvbppt4.js +0 -2
- package/dist/chunk-j4rb9rxx.js +0 -2
- package/dist/chunk-ka7qdsha.js +0 -2
- package/dist/chunk-m4d99a9r.js +0 -2
- package/dist/chunk-m5gdwq1d.js +0 -2
- package/dist/chunk-nz5ekyxn.js +0 -2
- package/dist/chunk-rchwwcxy.js +0 -2
- package/dist/chunk-s5cb4hkj.js +0 -2
- package/dist/chunk-t2mjeezd.js +0 -2
- package/dist/chunk-vk18649m.js +0 -2
- package/dist/chunk-vmfw4svt.js +0 -2
- package/dist/chunk-wbv6vjhm.js +0 -2
- package/dist/chunk-wpnv0naj.js +0 -2
- package/dist/chunk-wv2crxm6.js +0 -2
- package/dist/chunk-xda69f13.js +0 -2
- package/dist/chunk-ym182eg0.js +0 -2
- package/dist/chunk-zah67v44.js +0 -2
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
export function signalsAuthoringRuntime(createModelSignalSource) {
|
|
2
|
+
return ` var __stxGeneratedIdCounter = 0;
|
|
3
|
+
|
|
4
|
+
// Stable, scope-aware DOM ids for component authoring. A component setup
|
|
5
|
+
// runs with window.__STX_CURRENT_ELEMENT__ pointing at its compiled root, so
|
|
6
|
+
// the data-stx scope id is already the canonical per-instance identity. The
|
|
7
|
+
// local counter supports multiple useId() calls in one component while the
|
|
8
|
+
// global fallback covers page scripts and manually-mounted roots.
|
|
9
|
+
function useId(prefix) {
|
|
10
|
+
var normalizedPrefix = String(prefix || 'stx')
|
|
11
|
+
.trim()
|
|
12
|
+
.replace(/[^a-zA-Z0-9_-]+/g, '-')
|
|
13
|
+
.replace(/^-+|-+$/g, '') || 'stx';
|
|
14
|
+
var root = window.__STX_CURRENT_ELEMENT__;
|
|
15
|
+
if (root && root.getAttribute) {
|
|
16
|
+
var scopeId = root.getAttribute('data-stx-scope') || root.getAttribute('data-stx') || '';
|
|
17
|
+
if (scopeId) {
|
|
18
|
+
root.__stx_id_counter = (root.__stx_id_counter || 0) + 1;
|
|
19
|
+
return normalizedPrefix + '-' + String(scopeId).replace(/[^a-zA-Z0-9_-]+/g, '-') + '-' + root.__stx_id_counter;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
__stxGeneratedIdCounter++;
|
|
23
|
+
return normalizedPrefix + '-' + __stxGeneratedIdCounter;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var createModelSignal = ${createModelSignalSource};
|
|
27
|
+
function useModel(name, options) {
|
|
28
|
+
if (typeof name !== 'string') { options = name || {}; name = 'modelValue'; }
|
|
29
|
+
options = options || {};
|
|
30
|
+
var source = useReactiveProp(name, options.default, { parse: options.parse });
|
|
31
|
+
var modifierName = name === 'modelValue' ? 'modelModifiers' : name + 'Modifiers';
|
|
32
|
+
var modifiers = useReactiveProp(modifierName, {});
|
|
33
|
+
var emit = window.stx.defineEmits(['update:' + name]);
|
|
34
|
+
return createModelSignal(source, function() { return modifiers() || {}; },
|
|
35
|
+
function(value) { emit('update:' + name, value); }, options, onDestroy);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Reactive prop binding. Bridges the gap between a parent's clientReactive
|
|
39
|
+
// attribute (e.g. :open="modalOpen()" on a component) and the component's
|
|
40
|
+
// internal state. Returns a signal whose value tracks the named attribute
|
|
41
|
+
// on the component's root element \u2014 when the parent's expression changes
|
|
42
|
+
// and bindAttr updates the attribute, a MutationObserver on the root
|
|
43
|
+
// forwards the change into this signal. See stacksjs/stx#1704.
|
|
44
|
+
//
|
|
45
|
+
// Parse heuristic (override via opts.parse for typed props):
|
|
46
|
+
// - empty string or "true" \u2192 true
|
|
47
|
+
// - "false" \u2192 false
|
|
48
|
+
// - numeric-looking \u2192 Number
|
|
49
|
+
// - otherwise \u2192 original string
|
|
50
|
+
//
|
|
51
|
+
// The signal is one-way (parent \u2192 child). For two-way binding, components
|
|
52
|
+
// still emit events (@input / @change / @close) and the parent
|
|
53
|
+
// updates its source signal. The signal's own .set() won't propagate back
|
|
54
|
+
// through the attribute by design; that prevents observer feedback loops.
|
|
55
|
+
function useReactiveProp(name, defaultValue, opts) {
|
|
56
|
+
opts = opts || {};
|
|
57
|
+
var parse = opts.parse || function(v) {
|
|
58
|
+
// Infer the prop's intended scalar type from its default. A string prop
|
|
59
|
+
// with an empty value must stay "", not become the boolean true. This
|
|
60
|
+
// mirrors typed component props and keeps form/error text stable when a
|
|
61
|
+
// parent forwards an empty signal value through a DOM attribute.
|
|
62
|
+
if (typeof defaultValue === 'string') return v == null ? '' : String(v);
|
|
63
|
+
if (typeof defaultValue === 'boolean') {
|
|
64
|
+
if (v === '' || v === 'true') return true;
|
|
65
|
+
if (v === 'false' || v === null || v === undefined) return false;
|
|
66
|
+
return Boolean(v);
|
|
67
|
+
}
|
|
68
|
+
if (v === '' || v === 'true') return true;
|
|
69
|
+
if (v === 'false') return false;
|
|
70
|
+
if (typeof v === 'string' && (v.charAt(0) === '[' || v.charAt(0) === '{')) {
|
|
71
|
+
try { return JSON.parse(v); }
|
|
72
|
+
catch (e) {}
|
|
73
|
+
}
|
|
74
|
+
if (typeof defaultValue === 'number')
|
|
75
|
+
return v != null && v !== '' && !isNaN(Number(v)) ? Number(v) : defaultValue;
|
|
76
|
+
if (v != null && v !== '' && !isNaN(Number(v))) return Number(v);
|
|
77
|
+
return v;
|
|
78
|
+
};
|
|
79
|
+
var root = window.__STX_CURRENT_ELEMENT__;
|
|
80
|
+
var kebabName = name.replace(/([A-Z])/g, function(_, c) { return '-' + c.toLowerCase(); });
|
|
81
|
+
var lowerName = name.toLowerCase();
|
|
82
|
+
var attributeNames = [name];
|
|
83
|
+
if (kebabName !== name) attributeNames.push(kebabName);
|
|
84
|
+
if (lowerName !== name && lowerName !== kebabName) attributeNames.push(lowerName);
|
|
85
|
+
function readAttribute() {
|
|
86
|
+
if (!root || !root.hasAttribute) return { has: false, raw: null };
|
|
87
|
+
for (var i = 0; i < attributeNames.length; i++) {
|
|
88
|
+
var candidate = attributeNames[i];
|
|
89
|
+
if (root.hasAttribute(candidate))
|
|
90
|
+
return { has: true, raw: root.getAttribute(candidate) };
|
|
91
|
+
}
|
|
92
|
+
return { has: false, raw: null };
|
|
93
|
+
}
|
|
94
|
+
var staticValue = defaultValue;
|
|
95
|
+
if (root && root.getAttribute) {
|
|
96
|
+
var serializedProps = root.getAttribute('data-stx-props');
|
|
97
|
+
if (serializedProps) {
|
|
98
|
+
try {
|
|
99
|
+
var parsedProps = JSON.parse(serializedProps);
|
|
100
|
+
var camelName = name.replace(/-([a-z0-9])/g, function(_, c) { return c.toUpperCase(); });
|
|
101
|
+
if (Object.prototype.hasOwnProperty.call(parsedProps, name)) staticValue = parsedProps[name];
|
|
102
|
+
else if (Object.prototype.hasOwnProperty.call(parsedProps, camelName)) staticValue = parsedProps[camelName];
|
|
103
|
+
}
|
|
104
|
+
catch (e) {}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
var initial;
|
|
108
|
+
var lastRaw = null;
|
|
109
|
+
var initialAttribute = readAttribute();
|
|
110
|
+
if (initialAttribute.has) {
|
|
111
|
+
lastRaw = initialAttribute.raw;
|
|
112
|
+
initial = parse(lastRaw);
|
|
113
|
+
} else if (typeof staticValue === 'string' && (opts.parse || typeof defaultValue !== 'string')) {
|
|
114
|
+
// A prop written as a plain attribute is serialized as the string it was
|
|
115
|
+
// written as, so it gets the same parse an attribute does. Taken raw,
|
|
116
|
+
// currentPage="1" reached Pagination as "1": "1" + 1 is "11", the
|
|
117
|
+
// range maths took the wrong branch, and ten pages rendered as
|
|
118
|
+
// 1 ... 1 2 3 4 5 6 7 8 9 10 ... 10. A string prop stays a string.
|
|
119
|
+
initial = parse(staticValue);
|
|
120
|
+
} else {
|
|
121
|
+
initial = staticValue;
|
|
122
|
+
}
|
|
123
|
+
var s = state(initial);
|
|
124
|
+
if (!root) return s;
|
|
125
|
+
var propSignals = root.__stx_reactive_prop_signals
|
|
126
|
+
|| (root.__stx_reactive_prop_signals = {});
|
|
127
|
+
function register() {
|
|
128
|
+
propSignals[name] = s;
|
|
129
|
+
propSignals[kebabName] = s;
|
|
130
|
+
propSignals[lowerName] = s;
|
|
131
|
+
}
|
|
132
|
+
register();
|
|
133
|
+
function sync() {
|
|
134
|
+
var attribute = readAttribute();
|
|
135
|
+
var hasAttr = attribute.has;
|
|
136
|
+
var raw = attribute.raw;
|
|
137
|
+
if (raw === lastRaw) return;
|
|
138
|
+
lastRaw = raw;
|
|
139
|
+
var directValues = root.__stx_direct_prop_values;
|
|
140
|
+
var directValue = directValues && directValues[name];
|
|
141
|
+
var next;
|
|
142
|
+
if (directValue && directValue.raw === raw) {
|
|
143
|
+
next = directValue.value;
|
|
144
|
+
delete directValues[name];
|
|
145
|
+
for (var directKey in directValues) {
|
|
146
|
+
if (directValues[directKey] === directValue) delete directValues[directKey];
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
next = hasAttr ? parse(raw) : staticValue;
|
|
151
|
+
}
|
|
152
|
+
if (next !== s()) s.set(next);
|
|
153
|
+
}
|
|
154
|
+
var observer = new MutationObserver(sync);
|
|
155
|
+
var connected = true;
|
|
156
|
+
observer.observe(root, { attributes: true, attributeFilter: attributeNames });
|
|
157
|
+
// An :if hides a component and shows it again with the same setup, so
|
|
158
|
+
// the link to the parent is dropped on unmount and made again on mount.
|
|
159
|
+
// Disconnected for good, a component re-shown in an :if kept the prop it
|
|
160
|
+
// had when it hid: a chat header's avatar showed the previous person.
|
|
161
|
+
onMount(function() {
|
|
162
|
+
if (connected) return;
|
|
163
|
+
connected = true;
|
|
164
|
+
register();
|
|
165
|
+
observer.observe(root, { attributes: true, attributeFilter: attributeNames });
|
|
166
|
+
sync();
|
|
167
|
+
});
|
|
168
|
+
onDestroy(function() {
|
|
169
|
+
connected = false;
|
|
170
|
+
observer.disconnect();
|
|
171
|
+
attributeNames.forEach(function(attributeName) {
|
|
172
|
+
if (propSignals[attributeName] === s) delete propSignals[attributeName];
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
return s;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function useEventListener(event, handler, options) {
|
|
179
|
+
var target = (options && options.target) || window;
|
|
180
|
+
if (typeof target === 'string') target = document.querySelector(target);
|
|
181
|
+
if (!target) return;
|
|
182
|
+
var opts = { capture: options && options.capture, passive: options && options.passive, once: options && options.once };
|
|
183
|
+
target.addEventListener(event, handler, opts);
|
|
184
|
+
onDestroy(function() { target.removeEventListener(event, handler, opts); });
|
|
185
|
+
}
|
|
186
|
+
`;
|
|
187
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/** DOM binding helpers shared by generated client directives. */
|
|
2
|
+
export declare const SIGNALS_BINDING_UTILS_RUNTIME = " // Minimal attribute-only pass for the host element of a deferred subtree.\n // The full walk happens on children via processElement.\n function processAttributesOnly(el, scope) {\n // Just call processElement but mark it as already visited to prevent\n // infinite recursion via the stx-hydrate check below.\n el.__stx_hydrated = true;\n processElement(el, scope);\n }\n\n function isForDirectiveExpression(expr) {\n return typeof expr === 'string'\n && /^\\s*\\(?\\s*\\w+(?:\\s*,\\s*\\w+)?\\s*\\)?\\s+(?:in|of)\\s+.+\\s*$/.test(expr);\n }\n\n function getElementAttributes(el) {\n if (!el || !el.attributes) return [];\n return Array.from(el.attributes).map(function(attr) {\n // Browser DOM exposes Attr records through NamedNodeMap. HappyDOM and\n // other standards-oriented DOM implementations may expose Map entries\n // for cloned nodes instead. Normalize both shapes so reactive nodes\n // created by :for hydrate exactly like their browser counterparts.\n if (Array.isArray(attr)) return { name: attr[0], value: attr[1] };\n return attr;\n });\n }\n\n function getModelBinding(el) {\n if (!el || !el.attributes) return null;\n var prefixes = ['x-model', ':model', '@model'];\n var attrs = getElementAttributes(el);\n for (var i = 0; i < attrs.length; i++) {\n var name = attrs[i] && attrs[i].name;\n if (!name) continue;\n for (var j = 0; j < prefixes.length; j++) {\n if (name === prefixes[j] || name.indexOf(prefixes[j] + '.') === 0)\n return { name: name, expression: attrs[i].value };\n }\n }\n return null;\n }\n\n function readDeferredParentComponentProps(el) {\n var serialized = el.getAttribute('data-stx-deferred-parent-bindings');\n if (!serialized) return {};\n try {\n var parsed = JSON.parse(serialized);\n return parsed && typeof parsed === 'object' ? parsed : {};\n }\n catch (e) {\n return {};\n }\n }\n\n function preserveDeferredParentComponentProps(el) {\n var names = (el.getAttribute('data-stx-parent-bindings') || '').split(/\\s+/).filter(Boolean);\n if (!names.length) return;\n var deferred = readDeferredParentComponentProps(el);\n names.forEach(function(name) {\n var sourceName = ':' + name;\n if (el.hasAttribute(sourceName))\n deferred[name] = el.getAttribute(sourceName);\n });\n if (Object.keys(deferred).length)\n el.setAttribute('data-stx-deferred-parent-bindings', JSON.stringify(deferred));\n }\n\n function hasPendingLoopBoundary(el) {\n var loopBoundary = el;\n while (loopBoundary && loopBoundary !== document) {\n var loopExpression = loopBoundary.getAttribute && (\n loopBoundary.getAttribute('@for')\n || loopBoundary.getAttribute(':for')\n || loopBoundary.getAttribute('x-for')\n );\n if (loopExpression && isForDirectiveExpression(loopExpression))\n return true;\n loopBoundary = loopBoundary.parentElement || loopBoundary.parentNode;\n }\n return false;\n }\n\n function hasPendingAncestorLoopBoundary(el) {\n var loopBoundary = el && (el.parentElement || el.parentNode);\n while (loopBoundary && loopBoundary !== document) {\n var loopExpression = loopBoundary.getAttribute && (\n loopBoundary.getAttribute('@for')\n || loopBoundary.getAttribute(':for')\n || loopBoundary.getAttribute('x-for')\n );\n if (loopExpression && isForDirectiveExpression(loopExpression))\n return true;\n loopBoundary = loopBoundary.parentElement || loopBoundary.parentNode;\n }\n return false;\n }\n\n function syncComponentPropSignal(el, name, value) {\n if (!el || !el.getAttribute || value === undefined) return;\n var scopeId = el.getAttribute('data-stx-scope');\n var scopeVars = scopeId && window.stx._scopes && window.stx._scopes[scopeId];\n var camelName = name.replace(/-([a-z0-9])/g, function(_, character) {\n return character.toUpperCase();\n });\n // useReactiveProp signals are often intentionally aliased inside the\n // child, for example liveClosable = useReactiveProp('closable', true).\n // The public prop name therefore cannot be inferred from the variable\n // name exported by the component scope. Keep an element-owned registry as\n // the canonical bridge, with the scope lookup retained for older output.\n var propSignals = el.__stx_reactive_prop_signals;\n var propSignal = propSignals && (propSignals[name] || propSignals[camelName]);\n if (!propSignal && scopeVars)\n propSignal = scopeVars[name] || scopeVars[camelName];\n if (!propSignal || !propSignal._isSignal || typeof propSignal.set !== 'function') return;\n var directValues = el.__stx_direct_prop_values || (el.__stx_direct_prop_values = {});\n var directValue = {\n raw: el.hasAttribute(name) ? el.getAttribute(name) : null,\n value: value,\n };\n directValues[name] = directValue;\n directValues[camelName] = directValue;\n // This runs inside the parent binding effect. Reading the child prop\n // signal normally would subscribe that effect to its own output. Parent\n // expressions that return a fresh array or object would then recurse:\n // syncing the child retriggers the parent, which creates another value.\n // Compare without dependency tracking so the effect only follows the\n // caller-owned signals used by the binding expression.\n if (!Object.is(peek(function() { return propSignal(); }), value))\n propSignal.set(value);\n }\n";
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
export const SIGNALS_BINDING_UTILS_RUNTIME = ` // Minimal attribute-only pass for the host element of a deferred subtree.
|
|
2
|
+
// The full walk happens on children via processElement.
|
|
3
|
+
function processAttributesOnly(el, scope) {
|
|
4
|
+
// Just call processElement but mark it as already visited to prevent
|
|
5
|
+
// infinite recursion via the stx-hydrate check below.
|
|
6
|
+
el.__stx_hydrated = true;
|
|
7
|
+
processElement(el, scope);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function isForDirectiveExpression(expr) {
|
|
11
|
+
return typeof expr === 'string'
|
|
12
|
+
&& /^\\s*\\(?\\s*\\w+(?:\\s*,\\s*\\w+)?\\s*\\)?\\s+(?:in|of)\\s+.+\\s*$/.test(expr);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function getElementAttributes(el) {
|
|
16
|
+
if (!el || !el.attributes) return [];
|
|
17
|
+
return Array.from(el.attributes).map(function(attr) {
|
|
18
|
+
// Browser DOM exposes Attr records through NamedNodeMap. HappyDOM and
|
|
19
|
+
// other standards-oriented DOM implementations may expose Map entries
|
|
20
|
+
// for cloned nodes instead. Normalize both shapes so reactive nodes
|
|
21
|
+
// created by :for hydrate exactly like their browser counterparts.
|
|
22
|
+
if (Array.isArray(attr)) return { name: attr[0], value: attr[1] };
|
|
23
|
+
return attr;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function getModelBinding(el) {
|
|
28
|
+
if (!el || !el.attributes) return null;
|
|
29
|
+
var prefixes = ['x-model', ':model', '@model'];
|
|
30
|
+
var attrs = getElementAttributes(el);
|
|
31
|
+
for (var i = 0; i < attrs.length; i++) {
|
|
32
|
+
var name = attrs[i] && attrs[i].name;
|
|
33
|
+
if (!name) continue;
|
|
34
|
+
for (var j = 0; j < prefixes.length; j++) {
|
|
35
|
+
if (name === prefixes[j] || name.indexOf(prefixes[j] + '.') === 0)
|
|
36
|
+
return { name: name, expression: attrs[i].value };
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function readDeferredParentComponentProps(el) {
|
|
43
|
+
var serialized = el.getAttribute('data-stx-deferred-parent-bindings');
|
|
44
|
+
if (!serialized) return {};
|
|
45
|
+
try {
|
|
46
|
+
var parsed = JSON.parse(serialized);
|
|
47
|
+
return parsed && typeof parsed === 'object' ? parsed : {};
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
return {};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function preserveDeferredParentComponentProps(el) {
|
|
55
|
+
var names = (el.getAttribute('data-stx-parent-bindings') || '').split(/\\s+/).filter(Boolean);
|
|
56
|
+
if (!names.length) return;
|
|
57
|
+
var deferred = readDeferredParentComponentProps(el);
|
|
58
|
+
names.forEach(function(name) {
|
|
59
|
+
var sourceName = ':' + name;
|
|
60
|
+
if (el.hasAttribute(sourceName))
|
|
61
|
+
deferred[name] = el.getAttribute(sourceName);
|
|
62
|
+
});
|
|
63
|
+
if (Object.keys(deferred).length)
|
|
64
|
+
el.setAttribute('data-stx-deferred-parent-bindings', JSON.stringify(deferred));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function hasPendingLoopBoundary(el) {
|
|
68
|
+
var loopBoundary = el;
|
|
69
|
+
while (loopBoundary && loopBoundary !== document) {
|
|
70
|
+
var loopExpression = loopBoundary.getAttribute && (
|
|
71
|
+
loopBoundary.getAttribute('@for')
|
|
72
|
+
|| loopBoundary.getAttribute(':for')
|
|
73
|
+
|| loopBoundary.getAttribute('x-for')
|
|
74
|
+
);
|
|
75
|
+
if (loopExpression && isForDirectiveExpression(loopExpression))
|
|
76
|
+
return true;
|
|
77
|
+
loopBoundary = loopBoundary.parentElement || loopBoundary.parentNode;
|
|
78
|
+
}
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function hasPendingAncestorLoopBoundary(el) {
|
|
83
|
+
var loopBoundary = el && (el.parentElement || el.parentNode);
|
|
84
|
+
while (loopBoundary && loopBoundary !== document) {
|
|
85
|
+
var loopExpression = loopBoundary.getAttribute && (
|
|
86
|
+
loopBoundary.getAttribute('@for')
|
|
87
|
+
|| loopBoundary.getAttribute(':for')
|
|
88
|
+
|| loopBoundary.getAttribute('x-for')
|
|
89
|
+
);
|
|
90
|
+
if (loopExpression && isForDirectiveExpression(loopExpression))
|
|
91
|
+
return true;
|
|
92
|
+
loopBoundary = loopBoundary.parentElement || loopBoundary.parentNode;
|
|
93
|
+
}
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function syncComponentPropSignal(el, name, value) {
|
|
98
|
+
if (!el || !el.getAttribute || value === undefined) return;
|
|
99
|
+
var scopeId = el.getAttribute('data-stx-scope');
|
|
100
|
+
var scopeVars = scopeId && window.stx._scopes && window.stx._scopes[scopeId];
|
|
101
|
+
var camelName = name.replace(/-([a-z0-9])/g, function(_, character) {
|
|
102
|
+
return character.toUpperCase();
|
|
103
|
+
});
|
|
104
|
+
// useReactiveProp signals are often intentionally aliased inside the
|
|
105
|
+
// child, for example liveClosable = useReactiveProp('closable', true).
|
|
106
|
+
// The public prop name therefore cannot be inferred from the variable
|
|
107
|
+
// name exported by the component scope. Keep an element-owned registry as
|
|
108
|
+
// the canonical bridge, with the scope lookup retained for older output.
|
|
109
|
+
var propSignals = el.__stx_reactive_prop_signals;
|
|
110
|
+
var propSignal = propSignals && (propSignals[name] || propSignals[camelName]);
|
|
111
|
+
if (!propSignal && scopeVars)
|
|
112
|
+
propSignal = scopeVars[name] || scopeVars[camelName];
|
|
113
|
+
if (!propSignal || !propSignal._isSignal || typeof propSignal.set !== 'function') return;
|
|
114
|
+
var directValues = el.__stx_direct_prop_values || (el.__stx_direct_prop_values = {});
|
|
115
|
+
var directValue = {
|
|
116
|
+
raw: el.hasAttribute(name) ? el.getAttribute(name) : null,
|
|
117
|
+
value: value,
|
|
118
|
+
};
|
|
119
|
+
directValues[name] = directValue;
|
|
120
|
+
directValues[camelName] = directValue;
|
|
121
|
+
// This runs inside the parent binding effect. Reading the child prop
|
|
122
|
+
// signal normally would subscribe that effect to its own output. Parent
|
|
123
|
+
// expressions that return a fresh array or object would then recurse:
|
|
124
|
+
// syncing the child retriggers the parent, which creates another value.
|
|
125
|
+
// Compare without dependency tracking so the effect only follows the
|
|
126
|
+
// caller-owned signals used by the binding expression.
|
|
127
|
+
if (!Object.is(peek(function() { return propSignal(); }), value))
|
|
128
|
+
propSignal.set(value);
|
|
129
|
+
}
|
|
130
|
+
`;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Runtime preamble installed before any reactive APIs are created. */
|
|
2
|
+
export declare const SIGNALS_PREAMBLE_RUNTIME = "\n// STX Signals Runtime (Development Build)\nconsole.log('[stx] signals runtime loading');\n// Pre-initialization shim: capture onMount/onDestroy calls made before the runtime IIFE runs\n// (e.g. from partial scripts that execute before the full runtime is ready)\nif(!window.__stx_early_mounts)window.__stx_early_mounts=[];\nif(!window.__stx_early_destroys)window.__stx_early_destroys=[];\nif(!window.onMount)window.onMount=function(fn){window.__stx_early_mounts.push(fn)};\nif(!window.onDestroy)window.onDestroy=function(fn){window.__stx_early_destroys.push(fn)};\nconsole.log('[stx] entering IIFE');\n(function() {\n 'use strict';\n\n";
|
|
3
|
+
/** Browser-only setup that must run after the host adapter is selected. */
|
|
4
|
+
export declare const SIGNALS_CLOAK_RUNTIME = " // Inject x-cloak CSS to prevent FOUC (Flash of Unstyled Content)\n // Elements with x-cloak are hidden until the runtime removes the attribute after mount\n var cloakStyle = document.getElementById ? document.getElementById('stx-cloak-style') : null;\n if (!cloakStyle) {\n cloakStyle = document.createElement('style');\n cloakStyle.id = 'stx-cloak-style';\n cloakStyle.textContent = '[x-cloak] { display: none !important; }';\n document.head.appendChild(cloakStyle);\n }\n\n";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const SIGNALS_PREAMBLE_RUNTIME = `
|
|
2
|
+
// STX Signals Runtime (Development Build)
|
|
3
|
+
console.log('[stx] signals runtime loading');
|
|
4
|
+
// Pre-initialization shim: capture onMount/onDestroy calls made before the runtime IIFE runs
|
|
5
|
+
// (e.g. from partial scripts that execute before the full runtime is ready)
|
|
6
|
+
if(!window.__stx_early_mounts)window.__stx_early_mounts=[];
|
|
7
|
+
if(!window.__stx_early_destroys)window.__stx_early_destroys=[];
|
|
8
|
+
if(!window.onMount)window.onMount=function(fn){window.__stx_early_mounts.push(fn)};
|
|
9
|
+
if(!window.onDestroy)window.onDestroy=function(fn){window.__stx_early_destroys.push(fn)};
|
|
10
|
+
console.log('[stx] entering IIFE');
|
|
11
|
+
(function() {
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
`, SIGNALS_CLOAK_RUNTIME = ` // Inject x-cloak CSS to prevent FOUC (Flash of Unstyled Content)
|
|
15
|
+
// Elements with x-cloak are hidden until the runtime removes the attribute after mount
|
|
16
|
+
var cloakStyle = document.getElementById ? document.getElementById('stx-cloak-style') : null;
|
|
17
|
+
if (!cloakStyle) {
|
|
18
|
+
cloakStyle = document.createElement('style');
|
|
19
|
+
cloakStyle.id = 'stx-cloak-style';
|
|
20
|
+
cloakStyle.textContent = '[x-cloak] { display: none !important; }';
|
|
21
|
+
document.head.appendChild(cloakStyle);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
`;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/** Reactive class binding for the generated client runtime. */
|
|
2
|
+
export declare const SIGNALS_CLASS_RUNTIME = " function bindClass(el, expr, passedScope = componentScope, isVisible) {\n const originalClasses = el.className;\n const capturedScope = { ...globalHelpers, ...passedScope, ...(findElementScope(el) || {}) };\n const keys = Object.keys(capturedScope);\n\n // Pre-compile \u2014 only the names the expression mentions (see\n // __stxCompileScoped: reading every signal subscribed the class binding to\n // every signal on the page), and only valid JS identifiers.\n const mentioned = new Set(__stxNamesIn(expr));\n const safeKeys = keys.filter(k => mentioned.has(k) && /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(k));\n let fn;\n try {\n fn = __stxCompile(safeKeys, 'return ' + expr);\n } catch (e) {\n console.warn('[STX] bindClass compile error:', expr, e);\n return;\n }\n\n effect(() => {\n if (isVisible && !isVisible()) return;\n // Subscribe to signals by reading them, establishing reactive deps.\n // But pass RAW scope values to the fn so call-expressions like\n // activeTab() === 'overview' work \u2014 if we passed unwrapped values,\n // the fn would try to invoke a primitive and throw.\n for (let i = 0; i < safeKeys.length; i++) {\n const v = capturedScope[safeKeys[i]];\n if (v && typeof v === 'function' && (v._isSignal || v._isDerived)) {\n v();\n }\n }\n\n let value;\n try {\n // First pass: auto-unwrap proxy \u2014 handles expressions that read\n // signals as primitives (e.g. { 'active': count > 5 } where count\n // is a signal).\n const unwrapScope = createExpressionAutoUnwrapProxy(capturedScope, expr);\n value = fn.apply(null, safeKeys.map(k => unwrapScope[k]));\n } catch (e1) {\n // Retry with raw scope \u2014 handles call-expressions like activeTab()\n // that need the signal function to remain callable.\n try {\n value = fn.apply(null, safeKeys.map(k => capturedScope[k]));\n } catch (e2) {\n if (!(e2 instanceof ReferenceError) && !(e2 instanceof TypeError)) console.warn('[STX] Class expression error:', expr, e2);\n value = '';\n }\n }\n if (typeof value === 'object' && value !== null && !Array.isArray(value)) {\n // Object form { \"cls-a cls-b\": cond } \u2014 keys may contain multiple\n // whitespace-separated classes; classList.add/remove can't accept\n // those as a single token (throws DOMException), so split each key.\n Object.keys(value).forEach(cls => {\n const tokens = cls.split(/\\s+/).filter(Boolean);\n if (value[cls]) tokens.forEach(t => el.classList.add(t));\n else tokens.forEach(t => el.classList.remove(t));\n });\n }\nelse if (Array.isArray(value)) {\n var _clsArr = [originalClasses, value.filter(Boolean).join(' ')].filter(Boolean).join(' ');\n if (typeof el.className === 'string') el.className = _clsArr; else el.setAttribute('class', _clsArr);\n }\nelse {\n var _clsStr = [originalClasses, value || ''].filter(Boolean).join(' ');\n if (typeof el.className === 'string') el.className = _clsStr; else el.setAttribute('class', _clsStr);\n }\n });\n }\n";
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export const SIGNALS_CLASS_RUNTIME = ` function bindClass(el, expr, passedScope = componentScope, isVisible) {
|
|
2
|
+
const originalClasses = el.className;
|
|
3
|
+
const capturedScope = { ...globalHelpers, ...passedScope, ...(findElementScope(el) || {}) };
|
|
4
|
+
const keys = Object.keys(capturedScope);
|
|
5
|
+
|
|
6
|
+
// Pre-compile \u2014 only the names the expression mentions (see
|
|
7
|
+
// __stxCompileScoped: reading every signal subscribed the class binding to
|
|
8
|
+
// every signal on the page), and only valid JS identifiers.
|
|
9
|
+
const mentioned = new Set(__stxNamesIn(expr));
|
|
10
|
+
const safeKeys = keys.filter(k => mentioned.has(k) && /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(k));
|
|
11
|
+
let fn;
|
|
12
|
+
try {
|
|
13
|
+
fn = __stxCompile(safeKeys, 'return ' + expr);
|
|
14
|
+
} catch (e) {
|
|
15
|
+
console.warn('[STX] bindClass compile error:', expr, e);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
effect(() => {
|
|
20
|
+
if (isVisible && !isVisible()) return;
|
|
21
|
+
// Subscribe to signals by reading them, establishing reactive deps.
|
|
22
|
+
// But pass RAW scope values to the fn so call-expressions like
|
|
23
|
+
// activeTab() === 'overview' work \u2014 if we passed unwrapped values,
|
|
24
|
+
// the fn would try to invoke a primitive and throw.
|
|
25
|
+
for (let i = 0; i < safeKeys.length; i++) {
|
|
26
|
+
const v = capturedScope[safeKeys[i]];
|
|
27
|
+
if (v && typeof v === 'function' && (v._isSignal || v._isDerived)) {
|
|
28
|
+
v();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let value;
|
|
33
|
+
try {
|
|
34
|
+
// First pass: auto-unwrap proxy \u2014 handles expressions that read
|
|
35
|
+
// signals as primitives (e.g. { 'active': count > 5 } where count
|
|
36
|
+
// is a signal).
|
|
37
|
+
const unwrapScope = createExpressionAutoUnwrapProxy(capturedScope, expr);
|
|
38
|
+
value = fn.apply(null, safeKeys.map(k => unwrapScope[k]));
|
|
39
|
+
} catch (e1) {
|
|
40
|
+
// Retry with raw scope \u2014 handles call-expressions like activeTab()
|
|
41
|
+
// that need the signal function to remain callable.
|
|
42
|
+
try {
|
|
43
|
+
value = fn.apply(null, safeKeys.map(k => capturedScope[k]));
|
|
44
|
+
} catch (e2) {
|
|
45
|
+
if (!(e2 instanceof ReferenceError) && !(e2 instanceof TypeError)) console.warn('[STX] Class expression error:', expr, e2);
|
|
46
|
+
value = '';
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
|
|
50
|
+
// Object form { "cls-a cls-b": cond } \u2014 keys may contain multiple
|
|
51
|
+
// whitespace-separated classes; classList.add/remove can't accept
|
|
52
|
+
// those as a single token (throws DOMException), so split each key.
|
|
53
|
+
Object.keys(value).forEach(cls => {
|
|
54
|
+
const tokens = cls.split(/\\s+/).filter(Boolean);
|
|
55
|
+
if (value[cls]) tokens.forEach(t => el.classList.add(t));
|
|
56
|
+
else tokens.forEach(t => el.classList.remove(t));
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
else if (Array.isArray(value)) {
|
|
60
|
+
var _clsArr = [originalClasses, value.filter(Boolean).join(' ')].filter(Boolean).join(' ');
|
|
61
|
+
if (typeof el.className === 'string') el.className = _clsArr; else el.setAttribute('class', _clsArr);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
var _clsStr = [originalClasses, value || ''].filter(Boolean).join(' ');
|
|
65
|
+
if (typeof el.className === 'string') el.className = _clsStr; else el.setAttribute('class', _clsStr);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SIGNALS_COMPONENT_API_RUNTIME = " // Component composition API (Phase 4)\n defineProps: function(definitions) {\n var props = window.__STX_CURRENT_PROPS__ || {};\n if (!definitions) return props;\n var result = Object.assign({}, props);\n for (var key in definitions) {\n if (!definitions.hasOwnProperty(key)) continue;\n var def = definitions[key];\n var opts = (typeof def === 'function' || Array.isArray(def)) ? { type: def } : (def || {});\n if (result[key] === undefined && opts['default'] !== undefined) {\n result[key] = typeof opts['default'] === 'function' ? opts['default']() : opts['default'];\n }\n }\n return result;\n },\n withDefaults: function(props, defaults) {\n var result = Object.assign({}, props);\n for (var key in defaults) {\n if (!defaults.hasOwnProperty(key)) continue;\n if (result[key] === undefined) {\n result[key] = typeof defaults[key] === 'function' ? defaults[key]() : defaults[key];\n }\n }\n return result;\n },\n defineEmits: function(events) {\n var el = window.__STX_CURRENT_ELEMENT__ || null;\n var declaredEvents = Array.isArray(events)\n ? events\n : (events && typeof events === 'object' ? Object.keys(events) : []);\n if (el && declaredEvents.length) {\n el.__stx_component_emits = el.__stx_component_emits || Object.create(null);\n declaredEvents.forEach(function(event) {\n el.__stx_component_emits[event] = true;\n });\n }\n return function(event, payload) {\n var target = el || document.body;\n if (el) {\n el.__stx_component_emits = el.__stx_component_emits || Object.create(null);\n el.__stx_component_emits[event] = true;\n }\n target.dispatchEvent(new CustomEvent(event, { detail: payload, bubbles: true, cancelable: true }));\n };\n },\n defineExpose: function(exposed) {\n var el = window.__STX_CURRENT_ELEMENT__;\n if (el) el.__stx_exposed = exposed;\n },\n defineSlots: function() {\n return window.__STX_CURRENT_SLOTS__ || {};\n },\n // Vue spells the same lookup useSlots(); it was auto-imported with no\n // implementation behind it (#1804).\n useSlots: function() {\n return window.__STX_CURRENT_SLOTS__ || {};\n },";
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export const SIGNALS_COMPONENT_API_RUNTIME = ` // Component composition API (Phase 4)
|
|
2
|
+
defineProps: function(definitions) {
|
|
3
|
+
var props = window.__STX_CURRENT_PROPS__ || {};
|
|
4
|
+
if (!definitions) return props;
|
|
5
|
+
var result = Object.assign({}, props);
|
|
6
|
+
for (var key in definitions) {
|
|
7
|
+
if (!definitions.hasOwnProperty(key)) continue;
|
|
8
|
+
var def = definitions[key];
|
|
9
|
+
var opts = (typeof def === 'function' || Array.isArray(def)) ? { type: def } : (def || {});
|
|
10
|
+
if (result[key] === undefined && opts['default'] !== undefined) {
|
|
11
|
+
result[key] = typeof opts['default'] === 'function' ? opts['default']() : opts['default'];
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return result;
|
|
15
|
+
},
|
|
16
|
+
withDefaults: function(props, defaults) {
|
|
17
|
+
var result = Object.assign({}, props);
|
|
18
|
+
for (var key in defaults) {
|
|
19
|
+
if (!defaults.hasOwnProperty(key)) continue;
|
|
20
|
+
if (result[key] === undefined) {
|
|
21
|
+
result[key] = typeof defaults[key] === 'function' ? defaults[key]() : defaults[key];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return result;
|
|
25
|
+
},
|
|
26
|
+
defineEmits: function(events) {
|
|
27
|
+
var el = window.__STX_CURRENT_ELEMENT__ || null;
|
|
28
|
+
var declaredEvents = Array.isArray(events)
|
|
29
|
+
? events
|
|
30
|
+
: (events && typeof events === 'object' ? Object.keys(events) : []);
|
|
31
|
+
if (el && declaredEvents.length) {
|
|
32
|
+
el.__stx_component_emits = el.__stx_component_emits || Object.create(null);
|
|
33
|
+
declaredEvents.forEach(function(event) {
|
|
34
|
+
el.__stx_component_emits[event] = true;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return function(event, payload) {
|
|
38
|
+
var target = el || document.body;
|
|
39
|
+
if (el) {
|
|
40
|
+
el.__stx_component_emits = el.__stx_component_emits || Object.create(null);
|
|
41
|
+
el.__stx_component_emits[event] = true;
|
|
42
|
+
}
|
|
43
|
+
target.dispatchEvent(new CustomEvent(event, { detail: payload, bubbles: true, cancelable: true }));
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
defineExpose: function(exposed) {
|
|
47
|
+
var el = window.__STX_CURRENT_ELEMENT__;
|
|
48
|
+
if (el) el.__stx_exposed = exposed;
|
|
49
|
+
},
|
|
50
|
+
defineSlots: function() {
|
|
51
|
+
return window.__STX_CURRENT_SLOTS__ || {};
|
|
52
|
+
},
|
|
53
|
+
// Vue spells the same lookup useSlots(); it was auto-imported with no
|
|
54
|
+
// implementation behind it (#1804).
|
|
55
|
+
useSlots: function() {
|
|
56
|
+
return window.__STX_CURRENT_SLOTS__ || {};
|
|
57
|
+
},`;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/** Component-scope hydration helpers for the generated client runtime. */
|
|
2
|
+
export declare const SIGNALS_COMPONENT_HYDRATION_RUNTIME = " function hydrateComponentScopes(nodes, callerScope) {\n var roots = [];\n var scripts = [];\n forEachGroupElement(nodes, function(node, insideTemplateContent) {\n // A template's content is inert source material. Remapping must traverse\n // it, but setup and event hydration belong to the live clones inserted by\n // bindIf/bindFor, where the correct iteration scope is available.\n if (insideTemplateContent) return;\n if (node.hasAttribute && node.hasAttribute('data-stx-scope')) roots.push(node);\n if (node.tagName === 'SCRIPT' && node.hasAttribute('data-stx-scoped')) scripts.push(node);\n });\n if (!roots.length) return;\n\n function hasPendingStructuralAncestor(root) {\n var cursor = root && root.parentElement;\n while (cursor && cursor.nodeType === Node.ELEMENT_NODE) {\n if (cursor.hasAttribute('@for')\n || cursor.hasAttribute(':for')\n || cursor.hasAttribute('x-for')\n || cursor.hasAttribute('@if')\n || cursor.hasAttribute(':if')\n || cursor.hasAttribute('x-if')\n || cursor.hasAttribute('@else-if')\n || cursor.hasAttribute(':else-if')\n || cursor.hasAttribute('x-else-if')\n || cursor.hasAttribute('@else')\n || cursor.hasAttribute(':else')\n || cursor.hasAttribute('x-else'))\n return true;\n cursor = cursor.parentElement;\n }\n return false;\n }\n\n // Scripts cloned from template.content are inert in browsers. Compile each\n // distinct component setup body once, then run that cached function for\n // every loop instance. Temporarily restoring the template's original scope\n // id lets existing compiled setup code locate the correct root without\n // rewriting and reparsing the full script for every row.\n scripts.forEach(function(old) {\n var text = old.textContent || '';\n var pendingRoots = roots.filter(function(root) {\n var scopeId = root.getAttribute('data-stx-scope');\n var originalScopeId = root.getAttribute('data-stx-template-scope') || scopeId;\n return scopeId\n && originalScopeId\n && text.indexOf(originalScopeId) !== -1\n && !hasPendingStructuralAncestor(root)\n && !(window.stx._scopes && window.stx._scopes[scopeId]);\n });\n if (!pendingRoots.length) return;\n\n var setup = __forComponentSetupFactories.get(text);\n if (!setup) {\n try {\n setup = new Function(text);\n __forComponentSetupFactories.set(text, setup);\n }\n catch (e) {\n console.error('[stx] cloned component setup compile error:', e);\n return;\n }\n }\n\n pendingRoots.forEach(function(root) {\n var scopeId = root.getAttribute('data-stx-scope');\n var originalScopeId = root.getAttribute('data-stx-template-scope') || scopeId;\n if (!scopeId || !originalScopeId) return;\n\n root.setAttribute('data-stx-scope', originalScopeId);\n // The setup finds its root by id, which a detached clone cannot answer\n // to: rows a :for builds inside a component's closed :if are set up\n // before the :if puts them in the document, and found nothing, so they\n // never read a prop. Hand the root over (utils.ts reads it).\n var previousSetupRoot = window.__STX_SETUP_ROOT__;\n window.__STX_SETUP_ROOT__ = root;\n try {\n setup();\n var registeredScope = window.stx._scopes && (window.stx._scopes[originalScopeId] || window.stx._scopes[scopeId]);\n if (registeredScope && originalScopeId !== scopeId) {\n delete window.stx._scopes[originalScopeId];\n window.stx._scopes[scopeId] = registeredScope;\n }\n }\n catch (e) {\n console.error('[stx] cloned component setup error:', e);\n }\n finally {\n window.__STX_SETUP_ROOT__ = previousSetupRoot;\n root.setAttribute('data-stx-scope', scopeId);\n }\n });\n\n // A component that is itself a structural source still needs its setup\n // sibling when bindFor/bindIf turns that source into a clone template.\n // Final row instances have no structural attribute and can discard it.\n var isStructuralSource = pendingRoots.some(function(root) {\n return root.hasAttribute('@for')\n || root.hasAttribute(':for')\n || root.hasAttribute('x-for')\n || root.hasAttribute('@if')\n || root.hasAttribute(':if')\n || root.hasAttribute('x-if');\n });\n if (!isStructuralSource && old.parentNode) old.parentNode.removeChild(old);\n });\n\n roots.forEach(function(root) {\n // Still inside a conditional or loop this walk has not bound: the\n // directive decides whether the component is on the page at all, and\n // hydrates it through this same function when it is. Mounting it from\n // here is what ran a hidden pane's onMount when an enclosing :if opened\n // (stacksjs/stx#2071): the walk reached the pane's root while the pane's\n // own :if was still an attribute, so its condition was never asked. The\n // setup half above already leaves these roots alone.\n if (hasPendingStructuralAncestor(root)) return;\n var scopeId = root.getAttribute('data-stx-scope');\n var scopeVars = scopeId && window.stx._scopes && window.stx._scopes[scopeId];\n var resolvedCallerScope = resolveComponentCallerScope(root, callerScope);\n root.__stx_parent_scope = resolvedCallerScope;\n bindParentComponentProps(root, resolvedCallerScope);\n if (!scopeVars) return;\n if (root.__stx_disposers) {\n // Bound already, by the page's scope walk: a component behind a false\n // :if in a PARTIAL is in the list that walk collects, and is detached\n // by the time it is reached, so it was bound and its mount deferred\n // (stacksjs/stx#2036). Showing the branch is that mount. Without this\n // the component rendered and its onMount never ran at all.\n if (scopeVars.__mountCallbacks && !scopeVars.__mounted && !scopeVars.__suspended && root.isConnected) {\n scopeVars.__el = root;\n scopeVars.__mounted = true;\n runMountCallbacks(scopeVars.__mountCallbacks, scopeDestroySink(scopeVars));\n }\n return;\n }\n scopeVars.__el = root;\n var childScope = { ...resolvedCallerScope, ...scopeVars };\n root.__stx_disposers = trackEffects(function() {\n processElement(root, childScope);\n });\n if (scopeVars.__mountCallbacks && !scopeVars.__mounted) {\n scopeVars.__mounted = true;\n runMountCallbacks(scopeVars.__mountCallbacks, scopeDestroySink(scopeVars));\n }\n });\n }\n";
|