@stacksjs/stx 0.2.794 → 0.2.798
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-d6arvs57.js → chunk-0beyn8ak.js} +5 -5
- package/dist/{chunk-5a92srn2.js → chunk-0gsq8gps.js} +1 -1
- package/dist/chunk-0xnvjw7s.js +2 -0
- package/dist/chunk-1wyccmsr.js +2 -0
- package/dist/{chunk-7pk3t82j.js → chunk-20yz8bjp.js} +2 -2
- package/dist/{chunk-h0jnatd4.js → chunk-2ws2qe1k.js} +2 -2
- package/dist/{chunk-ssh2gycr.js → chunk-2z2bq2at.js} +3 -3
- package/dist/chunk-31qjy9xr.js +2 -0
- package/dist/chunk-33devn0s.js +2 -0
- package/dist/{chunk-c0ejyxfj.js → chunk-33vr7x2t.js} +3 -3
- package/dist/chunk-33wpv2n1.js +2 -0
- package/dist/{chunk-wk6xsyv3.js → chunk-3mby4nes.js} +3 -3
- package/dist/chunk-3p5gxc6t.js +2 -0
- package/dist/{chunk-j6255z7f.js → chunk-3x598qjt.js} +4 -4
- package/dist/chunk-4hgz9dkv.js +2 -0
- package/dist/{chunk-rrb9m2q2.js → chunk-4sesw88b.js} +5 -5
- package/dist/{chunk-94gyfwpz.js → chunk-4v50nafp.js} +14 -14
- package/dist/chunk-5kc9kjaa.js +2 -0
- package/dist/{chunk-vav9ktgm.js → chunk-5wwcgze3.js} +2 -2
- package/dist/chunk-5xd53dwe.js +2 -0
- package/dist/chunk-5y6518h8.js +2 -0
- package/dist/chunk-5y77pe7b.js +2 -0
- package/dist/chunk-6a97a9wk.js +2 -0
- package/dist/{chunk-5j619xgb.js → chunk-6b5zhtb3.js} +2 -2
- package/dist/chunk-6hre8cg4.js +2 -0
- package/dist/{chunk-4s5q1aea.js → chunk-6m4y5dh5.js} +6 -6
- package/dist/chunk-6pyweb05.js +2 -0
- package/dist/chunk-6tp7ys77.js +2 -0
- package/dist/chunk-6zxzr20d.js +2 -0
- package/dist/chunk-75ctpxr3.js +2 -0
- package/dist/{chunk-w9nwb8r3.js → chunk-7bxnjr3b.js} +7 -7
- package/dist/chunk-7gw96jpj.js +2 -0
- package/dist/chunk-7m4eesp0.js +2 -0
- package/dist/chunk-7na8bets.js +2 -0
- package/dist/{chunk-kr8qdg0r.js → chunk-7yb82rm6.js} +2 -2
- package/dist/{chunk-e3wmnjz8.js → chunk-810r5dk3.js} +3 -3
- package/dist/{chunk-e0wxcst7.js → chunk-89jn2jmf.js} +4 -4
- package/dist/{chunk-488kx8j5.js → chunk-8bzq2z0m.js} +5 -5
- package/dist/chunk-8k2n6abg.js +2 -0
- package/dist/chunk-8vqs94f3.js +2 -0
- package/dist/{chunk-dhqp3z4w.js → chunk-91htcq62.js} +2 -2
- package/dist/chunk-9736003n.js +2 -0
- package/dist/{chunk-agtvdtx4.js → chunk-9b6896tb.js} +2 -2
- package/dist/{chunk-y0pqpch2.js → chunk-9k6tza24.js} +7 -7
- package/dist/chunk-9w33k6f7.js +2 -0
- package/dist/{chunk-enep9r03.js → chunk-9x62j5f0.js} +52 -52
- package/dist/{chunk-b4r7d6me.js → chunk-a1ba9d2r.js} +5 -5
- package/dist/{chunk-efrc97by.js → chunk-a20wq8wf.js} +4 -4
- package/dist/{chunk-t3ptzpfc.js → chunk-a3xqfyb6.js} +2 -2
- package/dist/chunk-ag8j9ec2.js +2 -0
- package/dist/chunk-ak15dt1a.js +2 -0
- package/dist/{chunk-27rzdq3n.js → chunk-akcyaxwv.js} +2 -2
- package/dist/{chunk-w5hhqjwr.js → chunk-aw6369cx.js} +1 -1
- package/dist/chunk-b5ck6epd.js +177 -0
- package/dist/chunk-b98743ja.js +2 -0
- package/dist/{chunk-14ft0zc7.js → chunk-b9d70mgr.js} +6 -6
- package/dist/chunk-bskxswmn.js +2 -0
- package/dist/chunk-bv5h4etd.js +2 -0
- package/dist/chunk-c7x3bmvs.js +2 -0
- package/dist/{chunk-2gqhfge6.js → chunk-c84pxd2k.js} +2 -2
- package/dist/chunk-camm2hcx.js +2 -0
- package/dist/chunk-cd2wda5c.js +2 -0
- package/dist/chunk-cv6pqg85.js +2 -0
- package/dist/chunk-cy0mab8y.js +2 -0
- package/dist/chunk-d554f2fj.js +2 -0
- package/dist/chunk-dd1vqndp.js +2 -0
- package/dist/{chunk-0r61tkfe.js → chunk-ddhkhhc7.js} +2 -2
- package/dist/{chunk-9tqa8xvf.js → chunk-dsnggn3g.js} +2 -2
- package/dist/chunk-e14v1q9c.js +2 -0
- package/dist/{chunk-2m5h2mtr.js → chunk-e37g6ezw.js} +41 -41
- package/dist/chunk-e3xw2bzh.js +2 -0
- package/dist/{chunk-nps2whkz.js → chunk-eegb7f3t.js} +6 -6
- package/dist/chunk-eeztqt6f.js +2 -0
- package/dist/{chunk-1y9ez7nz.js → chunk-ef3w5thv.js} +2 -2
- package/dist/chunk-eh528njb.js +2 -0
- package/dist/chunk-en0wry1c.js +20 -0
- package/dist/chunk-eszpqrxy.js +2 -0
- package/dist/{chunk-2p4yad7w.js → chunk-fp0ew9n4.js} +4 -4
- package/dist/chunk-fyxkzs9c.js +2 -0
- package/dist/{chunk-d18xd9x5.js → chunk-gjf8cjdt.js} +3 -3
- package/dist/{chunk-7gdwvnwc.js → chunk-gvnfb6s2.js} +2 -2
- package/dist/{chunk-fpn4dren.js → chunk-gzfvj15b.js} +1 -1
- package/dist/chunk-hb4jkdfr.js +2 -0
- package/dist/{chunk-qp3xd98j.js → chunk-hg9mwgnr.js} +2 -2
- package/dist/{chunk-8q63njnd.js → chunk-hmt0vqhb.js} +1 -1
- package/dist/{chunk-v8rfeev5.js → chunk-hp9e8nz6.js} +2 -2
- package/dist/chunk-hzps1xya.js +2 -0
- package/dist/{chunk-985afhhy.js → chunk-j3st59hv.js} +2 -2
- package/dist/{chunk-7sartb04.js → chunk-jde0shn4.js} +2 -2
- package/dist/{chunk-15ckxpq7.js → chunk-jeprxn45.js} +6 -6
- package/dist/{chunk-bwcj9z19.js → chunk-jt0yn7ab.js} +4 -4
- package/dist/chunk-k8gpvg0w.js +2 -0
- package/dist/chunk-kgn911k7.js +2 -0
- package/dist/{chunk-jdj1358b.js → chunk-kj8dvzpc.js} +2 -2
- package/dist/chunk-km8c0j9g.js +2 -0
- package/dist/{chunk-w6taxq7d.js → chunk-mj3hzy1e.js} +5 -5
- package/dist/{chunk-66b56g2z.js → chunk-nw0v655w.js} +6 -6
- package/dist/{chunk-6v4b0xc1.js → chunk-p1mghe1h.js} +6 -6
- package/dist/{chunk-pa9zfbh6.js → chunk-p2a6dwj6.js} +6 -6
- package/dist/chunk-pw89m3re.js +2 -0
- package/dist/chunk-q38vjqv2.js +2 -0
- package/dist/{chunk-yyr7vb7k.js → chunk-q3ma4khe.js} +5 -5
- package/dist/{chunk-ne69yaak.js → chunk-q7q9e0gj.js} +10 -10
- package/dist/{chunk-kce6pzmj.js → chunk-qef2vv0m.js} +3 -3
- package/dist/{chunk-q14d714d.js → chunk-qjbpa1n4.js} +4 -4
- package/dist/{chunk-5gppagt3.js → chunk-qm2wmqre.js} +1 -1
- package/dist/{chunk-605b93pe.js → chunk-qpvwxppw.js} +4 -4
- package/dist/{chunk-8nb8b0nf.js → chunk-qxt6hdat.js} +1 -1
- package/dist/{chunk-1hajf3wc.js → chunk-r6d6jphq.js} +21 -21
- package/dist/chunk-rbv6fxtx.js +3 -0
- package/dist/chunk-rrketemm.js +2 -0
- package/dist/chunk-rwys552r.js +3 -0
- package/dist/chunk-s0bx4gjh.js +2 -0
- package/dist/{chunk-gv3bfkdm.js → chunk-s14jcqdf.js} +5 -5
- package/dist/{chunk-es006emk.js → chunk-s3fmmm98.js} +3 -3
- package/dist/chunk-s8s7b7rv.js +2 -0
- package/dist/{chunk-vkn133cs.js → chunk-s9b6abkb.js} +2 -2
- package/dist/{chunk-3gn1t0pa.js → chunk-sprgkk9j.js} +31 -31
- package/dist/chunk-sywqa4da.js +2 -0
- package/dist/{chunk-gb65t4n1.js → chunk-t65tn8ee.js} +2 -2
- package/dist/{chunk-vrbcdds3.js → chunk-trjhz9d9.js} +1 -1
- package/dist/chunk-txrbz95y.js +2 -0
- package/dist/{chunk-h0c6jtrj.js → chunk-v9hm1xv6.js} +5 -5
- package/dist/{chunk-bmfk3b29.js → chunk-w0zayhmg.js} +2 -2
- package/dist/{chunk-tnn0br4w.js → chunk-w58bnt44.js} +3 -3
- package/dist/chunk-w7681v48.js +2 -0
- package/dist/chunk-w7wz670a.js +2 -0
- package/dist/{chunk-epcy3r18.js → chunk-wp6bdac7.js} +113 -105
- package/dist/{chunk-8ztgy5y4.js → chunk-x8ckxemg.js} +107 -107
- package/dist/{chunk-74rf78w8.js → chunk-x8h81amr.js} +2 -2
- package/dist/{chunk-hh9t97hr.js → chunk-xa36escd.js} +3 -3
- package/dist/{chunk-7fr038wx.js → chunk-xskswvef.js} +4 -4
- package/dist/chunk-xzgtdcbg.js +2 -0
- package/dist/{chunk-k4bdf0dw.js → chunk-y9bj3566.js} +2 -2
- package/dist/chunk-yfdb3x3p.js +2 -0
- package/dist/{chunk-qv85c3qy.js → chunk-yv4dwdhc.js} +2 -2
- package/dist/{chunk-1stvxcjv.js → chunk-z1aq59qj.js} +3 -3
- package/dist/{chunk-nwbq8qvb.js → chunk-z1fb5k3h.js} +1305 -449
- package/dist/{chunk-tnkxww7b.js → chunk-z8wfvqbk.js} +5 -5
- package/dist/chunk-z9a80qqg.js +2 -0
- package/dist/chunk-za5kx15m.js +2 -0
- package/dist/{chunk-8e23zh2y.js → chunk-zbv8e4rq.js} +2 -2
- package/dist/{chunk-v1z6n7wz.js → chunk-znx5m1jv.js} +4 -4
- package/dist/{chunk-6pt4158p.js → chunk-zqsacq3r.js} +1 -1
- package/dist/{chunk-rgz797k3.js → chunk-zsy145ac.js} +3 -3
- package/dist/{chunk-j56mg28d.js → chunk-zx8tnhfr.js} +3 -3
- package/dist/cli.js +19 -19
- package/dist/client/signals-authoring-runtime.js +6 -3
- package/dist/client/signals-binding-utils-runtime.js +2 -4
- package/dist/client/signals-component-props-runtime.js +8 -2
- package/dist/client/signals-expression-compiler-runtime.js +1 -1
- package/dist/client/signals-for-runtime.js +34 -0
- package/dist/client/signals-handler-runtime.js +68 -24
- package/dist/client/signals-helpers-runtime.js +51 -0
- package/dist/client/signals-native-row-runtime.d.ts +26 -0
- package/dist/client/signals-native-row-runtime.js +661 -0
- package/dist/client/signals-pipe-runtime.js +16 -0
- package/dist/client/signals-process-element-runtime.js +305 -287
- package/dist/client/signals-proxy-runtime.js +56 -31
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/native/accessibility.js +8 -0
- package/dist/native/compiler/bundle.js +1 -1
- package/dist/native/compiler/inline-style.js +93 -4
- package/dist/native/compiler/style-variables.js +9 -1
- package/dist/native/event-names.js +1 -0
- package/dist/native/prop-names.js +9 -1
- package/dist/native/runtime/binding-tree.d.ts +2 -0
- package/dist/native/runtime/binding-tree.js +12 -1
- package/dist/native/runtime/craft-bridge.js +66 -0
- package/dist/native/runtime/craft.d.ts +78 -2
- package/dist/native/runtime/native-host.d.ts +2 -0
- package/dist/native/runtime/native-host.js +315 -91
- package/dist/native-build.js +2 -23
- package/dist/pwa.js +3 -3
- package/dist/signals.d.ts +13 -10
- package/dist/signals.js +5 -3
- package/dist/ssg.js +15 -15
- package/dist/stx-virtual-ts.d.ts +25 -1
- package/dist/stx-virtual-ts.js +109 -6
- package/dist/typecheck.d.ts +3 -1
- package/dist/typecheck.js +28 -11
- package/package.json +6 -6
- package/dist/chunk-0675z8hj.js +0 -177
- package/dist/chunk-1brkqd5f.js +0 -2
- package/dist/chunk-1ds97d9m.js +0 -2
- package/dist/chunk-1tvb2stj.js +0 -2
- package/dist/chunk-2vxh8b8g.js +0 -2
- package/dist/chunk-33na85q2.js +0 -2
- package/dist/chunk-3t4t655h.js +0 -2
- package/dist/chunk-43ynckvh.js +0 -2
- package/dist/chunk-4v22nj67.js +0 -2
- package/dist/chunk-5v5w0cd2.js +0 -2
- package/dist/chunk-699t603m.js +0 -2
- package/dist/chunk-6f6xqzhb.js +0 -2
- package/dist/chunk-7mrr4ke5.js +0 -2
- package/dist/chunk-7tzzzvdg.js +0 -2
- package/dist/chunk-8a5txj4f.js +0 -2
- package/dist/chunk-8pphy0p1.js +0 -2
- package/dist/chunk-8rmb79zw.js +0 -2
- package/dist/chunk-8rwnzmvb.js +0 -2
- package/dist/chunk-90pxjq62.js +0 -2
- package/dist/chunk-9s4ggstz.js +0 -2
- package/dist/chunk-9wmjmas8.js +0 -2
- package/dist/chunk-9xdz8r73.js +0 -2
- package/dist/chunk-agvykxs8.js +0 -2
- package/dist/chunk-ajj56vrw.js +0 -2
- package/dist/chunk-ay4ep67v.js +0 -2
- package/dist/chunk-bwfncfe1.js +0 -3
- package/dist/chunk-cdsv4yrv.js +0 -2
- package/dist/chunk-d5e47gr4.js +0 -2
- package/dist/chunk-d910ytt2.js +0 -2
- package/dist/chunk-d9p7xaj7.js +0 -2
- package/dist/chunk-dsrn2vgp.js +0 -2
- package/dist/chunk-fkkdt6sj.js +0 -2
- package/dist/chunk-fpw03bhv.js +0 -2
- package/dist/chunk-fxy0cq7h.js +0 -2
- package/dist/chunk-g6smtcc0.js +0 -2
- package/dist/chunk-g747k4gg.js +0 -3
- package/dist/chunk-gryrg1c0.js +0 -2
- package/dist/chunk-gvj862m1.js +0 -2
- package/dist/chunk-h5nrnen8.js +0 -2
- package/dist/chunk-hagk74x6.js +0 -2
- package/dist/chunk-hv0whj8t.js +0 -2
- package/dist/chunk-k2brrhf8.js +0 -2
- package/dist/chunk-k6ncb5qm.js +0 -2
- package/dist/chunk-kn38mjpp.js +0 -2
- package/dist/chunk-kvmpc0sg.js +0 -2
- package/dist/chunk-nbjgytem.js +0 -2
- package/dist/chunk-nf2bzqaw.js +0 -2
- package/dist/chunk-nt7wqqax.js +0 -2
- package/dist/chunk-pq1qs7bp.js +0 -2
- package/dist/chunk-pvw58x2j.js +0 -20
- package/dist/chunk-qk9v0emh.js +0 -2
- package/dist/chunk-qnj444zc.js +0 -2
- package/dist/chunk-qzb0v08n.js +0 -2
- package/dist/chunk-s1wdzttg.js +0 -2
- package/dist/chunk-sq0qc9sk.js +0 -2
- package/dist/chunk-th5afzmv.js +0 -2
- package/dist/chunk-tktkj2dc.js +0 -2
- package/dist/chunk-vgzfsh1z.js +0 -2
- package/dist/chunk-wmh4yxcs.js +0 -2
- package/dist/chunk-wr3adhd8.js +0 -2
- package/dist/chunk-xmae29mn.js +0 -2
- package/dist/chunk-zdwnzq78.js +0 -2
- package/dist/chunk-zssf9fdg.js +0 -2
- package/dist/chunk-zyf6737j.js +0 -2
|
@@ -2,6 +2,53 @@ export const SIGNALS_PROXY_RUNTIME = ` // =====================================
|
|
|
2
2
|
// Auto-unwrap Signals (Feature #1)
|
|
3
3
|
// ==========================================================================
|
|
4
4
|
|
|
5
|
+
// One handler class for every auto-unwrap proxy: an expression is
|
|
6
|
+
// evaluated through a fresh one each time it runs, and a handler object
|
|
7
|
+
// with closures of its own per proxy was a cost every binding paid in an
|
|
8
|
+
// interpreter. A handler knows how to keep a signal either by a callback
|
|
9
|
+
// (preserveSignal) or, for an expression, by what the expression does with
|
|
10
|
+
// the name (expressionKeepsSignal), which needs no closure at all.
|
|
11
|
+
function StxAutoUnwrapHandler(preserveSignal, expression) {
|
|
12
|
+
this.preserveSignal = preserveSignal;
|
|
13
|
+
this.expression = expression;
|
|
14
|
+
}
|
|
15
|
+
StxAutoUnwrapHandler.prototype.get = function(target, prop) {
|
|
16
|
+
const val = target[prop];
|
|
17
|
+
// If it's a signal or derived, call it to get the value
|
|
18
|
+
if (val && typeof val === 'function' && (val._isSignal || val._isDerived)) {
|
|
19
|
+
// Loop variables are implementation-detail signals so keyed rows can
|
|
20
|
+
// update reactively. In template expressions they must behave like
|
|
21
|
+
// their item value, including for objects with fields named value,
|
|
22
|
+
// set, or subscribe. Otherwise item.value is mistaken for the
|
|
23
|
+
// signal compatibility API and resolves to the whole item object.
|
|
24
|
+
if (val._isStxLoopItem) return val();
|
|
25
|
+
if (this.expression !== null) {
|
|
26
|
+
if (expressionKeepsSignal(this.expression, prop, val)) return val;
|
|
27
|
+
}
|
|
28
|
+
else if (this.preserveSignal && this.preserveSignal(prop, val)) return val;
|
|
29
|
+
return val();
|
|
30
|
+
}
|
|
31
|
+
// If it's an stx store, return a recursively-unwrapping wrapper so
|
|
32
|
+
// store.signalProp resolves to the value in template expressions
|
|
33
|
+
if (val && typeof val === 'object' && val._isStxStore) {
|
|
34
|
+
return new Proxy(val, this);
|
|
35
|
+
}
|
|
36
|
+
return val;
|
|
37
|
+
};
|
|
38
|
+
StxAutoUnwrapHandler.prototype.set = function(target, prop, value) {
|
|
39
|
+
const cur = target[prop];
|
|
40
|
+
if (cur && typeof cur === 'function' && cur._isSignal && typeof cur.set === 'function') {
|
|
41
|
+
cur.set(value);
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
target[prop] = value;
|
|
45
|
+
return true;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// The scope an auto-unwrap proxy reads, so compiling an expression asks
|
|
49
|
+
// the scope itself which names it holds rather than through the proxy.
|
|
50
|
+
const __stxUnwrapTargetOf = new WeakMap();
|
|
51
|
+
|
|
5
52
|
// Create a proxy that auto-unwraps signals when accessed.
|
|
6
53
|
// For stx stores (objects with _isStxStore), recursively wrap so nested
|
|
7
54
|
// signal properties auto-unwrap too \u2014 this is what makes template
|
|
@@ -9,37 +56,15 @@ export const SIGNALS_PROXY_RUNTIME = ` // =====================================
|
|
|
9
56
|
// resolve to the value. Action methods on the store pass through as
|
|
10
57
|
// functions because they don't carry _isSignal/_isDerived markers.
|
|
11
58
|
function createAutoUnwrapProxy(scope, preserveSignal) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// signal compatibility API and resolves to the whole item object.
|
|
22
|
-
if (val._isStxLoopItem) return val();
|
|
23
|
-
if (preserveSignal && preserveSignal(prop, val)) return val;
|
|
24
|
-
return val();
|
|
25
|
-
}
|
|
26
|
-
// If it's an stx store, return a recursively-unwrapping wrapper so
|
|
27
|
-
// store.signalProp resolves to the value in template expressions
|
|
28
|
-
if (val && typeof val === 'object' && val._isStxStore) {
|
|
29
|
-
return createAutoUnwrapProxy(val, preserveSignal);
|
|
30
|
-
}
|
|
31
|
-
return val;
|
|
32
|
-
},
|
|
33
|
-
set(target, prop, value) {
|
|
34
|
-
const cur = target[prop];
|
|
35
|
-
if (cur && typeof cur === 'function' && cur._isSignal && typeof cur.set === 'function') {
|
|
36
|
-
cur.set(value);
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
target[prop] = value;
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
});
|
|
59
|
+
const proxy = new Proxy(scope, new StxAutoUnwrapHandler(preserveSignal || null, null));
|
|
60
|
+
__stxUnwrapTargetOf.set(proxy, scope);
|
|
61
|
+
return proxy;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function createExpressionUnwrapProxy(scope, expression) {
|
|
65
|
+
const proxy = new Proxy(scope, new StxAutoUnwrapHandler(null, expression));
|
|
66
|
+
__stxUnwrapTargetOf.set(proxy, scope);
|
|
67
|
+
return proxy;
|
|
43
68
|
}
|
|
44
69
|
|
|
45
70
|
// A proxy for the WRITE side of x-model, kept separate from the read proxy
|
package/dist/craft-entry.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{So,va,xa}from"./chunk-s3fmmm98.js";import"./chunk-sprgkk9j.js";import"./chunk-4v50nafp.js";import"./chunk-t65tn8ee.js";import"./chunk-2yxva96k.js";import"./chunk-wp6bdac7.js";import"./chunk-akcyaxwv.js";import"./chunk-zbv8e4rq.js";import"./chunk-2ws2qe1k.js";import"./chunk-qjbpa1n4.js";import"./chunk-9x62j5f0.js";import"./chunk-7bxnjr3b.js";import"./chunk-qpvwxppw.js";import"./chunk-rbv6fxtx.js";import"./chunk-nw0v655w.js";import"./chunk-e37g6ezw.js";import"./chunk-89jn2jmf.js";import"./chunk-q7q9e0gj.js";import"./chunk-9k6tza24.js";import"./chunk-2z2bq2at.js";import"./chunk-c84pxd2k.js";import"./chunk-33vr7x2t.js";import{fu,Sa,hh,yh,ka,ko,Qr,_a,Ca,bh,wh,Ea,Ta,$a,Ra}from"./chunk-r6d6jphq.js";import"./chunk-a20wq8wf.js";import"./chunk-rwys552r.js";import"./chunk-yv4dwdhc.js";import"./chunk-eegb7f3t.js";import"./chunk-aw6369cx.js";import"./chunk-3mby4nes.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
|
|
3
3
|
`),scripts:t.scripts.join(`
|
|
4
4
|
`),metadata:{renderTime:0,cacheHit:!0,totalSize:c.html.length,componentCount:t.metadata.componentCount}}}let a;if(n.streaming)a=await H(t.tree,e);else a=h(t.tree,e);let i;if(n.hydrate){let o=j(a,t,e);a=o.html,i=o.data}if(n.minify)a=D(a);if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`;d.set(o,{html:a,timestamp:Date.now()})}let s=performance.now()-r;return{html:a,styles:t.styles.join(`
|
|
5
5
|
`),scripts:t.scripts.join(`
|
|
6
6
|
`),hydrationData:i,metadata:{renderTime:s,cacheHit:!1,totalSize:a.length,componentCount:t.metadata.componentCount}}}function V(t,e){let n=[],r=[],a=[],i=new Map,s=[];return y(t.tree,(o,c)=>{if(o.type==="component"&&o.componentName){if(T(o.componentName))n.push(o.componentName)}if(o.type==="element"&&o.tag){let p=J(o);if(p)s.push(p);if(o.props){for(let[l,f]of Object.entries(o.props))if(l.startsWith("on")&&typeof f==="string"){let g=`handler_${i.size}`;i.set(g,f)}}}if(o.isStatic&&o.type==="element")r.push(b(o));else if(!o.isStatic&&o.type!=="text")a.push(o.tag||o.componentName||"unknown")}),{nativeComponents:n,staticHTML:r,dynamicParts:a,eventHandlers:i,nativeWidgets:s}}function Y(t,e={}){let n=R(t),r=P(n,e),a=new Map,i=[];return y(n.tree,(s)=>{if(s.type==="component"&&s.componentName){if(T(s.componentName)){i.push(s.componentName);let o=`<!--craft:${s.componentName}:${s.hydrationKey||"default"}-->`;a.set(s.hydrationKey||s.componentName,o)}}}),{staticHTML:r,dynamicPlaceholders:a,craftComponents:i}}function M(t){let e={type:"fragment",children:[]},n=e,r=[e],a=t,i=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);while(a.length>0){let s=a.match(/^<(@?[\w-]+)([^>]*)>/);if(s){let[p,l,f]=s,g=z(f),u=l.startsWith("@craft-"),C=u?l:l.toLowerCase(),S={type:u?"component":"element",tag:C,props:g,children:[],componentName:u?C.slice(1):void 0,isStatic:!v(f),hydrationKey:F()};if(n.children=n.children||[],n.children.push(S),!i.has(C)&&!f.endsWith("/"))r.push(S),n=S;a=a.slice(p.length);continue}let o=a.match(/^<\/(@?[\w-]+)>/);if(o){let[p,l]=o,g=l.startsWith("@craft-")?l:l.toLowerCase();while(r.length>1){let u=r.pop();if(n=r[r.length-1],u.tag===g)break}a=a.slice(p.length);continue}let c=a.match(/^[^<]+/);if(c){let p=c[0];if(p.trim()){let l={type:"text",text:p,isStatic:!v(p)};n.children=n.children||[],n.children.push(l)}a=a.slice(p.length);continue}a=a.slice(1)}return e}function z(t){let e={},n=/([\w-:@]+)(?:=(?:"([^"]*)"|'([^']*)'|(\S+)))?/g,r;while((r=n.exec(t))!==null){let[,a,i,s,o]=r,c=i??s??o??!0;e[a]=c}return e}function y(t,e,n=[]){if(e(t,n),t.children)t.children.forEach((r,a)=>{y(r,e,[...n,`${a}`])})}function h(t,e){switch(t.type){case"text":return x(t.text||"",e);case"element":case"component":{let n=t.tag||"div",r=N(t.props||{},e),a=(t.children||[]).map((i)=>h(i,e)).join("");if(!t.children||t.children.length===0){if(["input","br","hr","img","meta","link"].includes(n))return`<${n}${r} />`}return`<${n}${r}>${a}</${n}>`}case"fragment":return(t.children||[]).map((n)=>h(n,e)).join("");case"slot":return`<!--slot:${t.slotName||"default"}-->`;default:return""}}function b(t){if(t.type==="text")return t.text||"";let e=t.tag||"div",n=N(t.props||{},{});return`<${e}${n}></${e}>`}function N(t,e){let n=[];for(let[r,a]of Object.entries(t))if(a===!0)n.push(` ${r}`);else if(a!==!1&&a!==null&&a!==void 0){let i=x(String(a),e);n.push(` ${r}="${k(i)}"`)}return n.join("")}async function H(t,e){return h(t,e)}function P(t,e){let n=[];return y(t.tree,(r)=>{if(r.isStatic)n.push(h(r,e))}),n.join("")}function j(t,e,n){let r={templateId:e.id,context:n,dynamicParts:Array.from(e.dynamicParts.entries())},a=`
|
|
7
7
|
<script data-craft-hydration>
|
|
8
8
|
window.__CRAFT_HYDRATION__ = ${JSON.stringify(r)};
|
|
9
|
-
</script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{
|
|
9
|
+
</script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{fu as CRAFT_BRIDGE_SCRIPT,ko as CRAFT_COMPONENTS,_a as CRAFT_COMPONENT_RUNTIME,Qr as CRAFT_COMPONENT_STYLES,So as NATIVE_COMPONENTS,Ea as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,va as compileToNative,xa as createHotReloadServer,Ta as findCraftBinary,Sa as generateCraftBridgeScript,V as generateCraftOptimizations,Ra as getAvailableFormats,$a as getAvailableTargets,wh as getCraftComponents,G as getSSRCacheStats,ka as injectCraftBridge,hh as isCraftEnvironment,Y as prerenderForCraft,Ca as processCraftComponents,yh as processCraftDirective,bh as registerCraftComponent,Q as renderSSR};
|
package/dist/craft.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{So,va,xa}from"./chunk-s3fmmm98.js";import"./chunk-sprgkk9j.js";import"./chunk-4v50nafp.js";import"./chunk-t65tn8ee.js";import"./chunk-2yxva96k.js";import"./chunk-wp6bdac7.js";import"./chunk-akcyaxwv.js";import"./chunk-zbv8e4rq.js";import"./chunk-2ws2qe1k.js";import"./chunk-qjbpa1n4.js";import"./chunk-9x62j5f0.js";import"./chunk-7bxnjr3b.js";import"./chunk-qpvwxppw.js";import"./chunk-rbv6fxtx.js";import"./chunk-nw0v655w.js";import"./chunk-e37g6ezw.js";import"./chunk-89jn2jmf.js";import"./chunk-q7q9e0gj.js";import"./chunk-9k6tza24.js";import"./chunk-2z2bq2at.js";import"./chunk-c84pxd2k.js";import"./chunk-33vr7x2t.js";import{fu,Sa,hh,yh,ka,ko,Qr,_a,Ca,bh,wh,Ea,Ta,$a,Ra}from"./chunk-r6d6jphq.js";import"./chunk-a20wq8wf.js";import"./chunk-rwys552r.js";import"./chunk-yv4dwdhc.js";import"./chunk-eegb7f3t.js";import"./chunk-aw6369cx.js";import"./chunk-3mby4nes.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
|
|
3
3
|
`),scripts:t.scripts.join(`
|
|
4
4
|
`),metadata:{renderTime:0,cacheHit:!0,totalSize:c.html.length,componentCount:t.metadata.componentCount}}}let a;if(n.streaming)a=await H(t.tree,e);else a=h(t.tree,e);let i;if(n.hydrate){let o=j(a,t,e);a=o.html,i=o.data}if(n.minify)a=D(a);if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`;d.set(o,{html:a,timestamp:Date.now()})}let s=performance.now()-r;return{html:a,styles:t.styles.join(`
|
|
5
5
|
`),scripts:t.scripts.join(`
|
|
6
6
|
`),hydrationData:i,metadata:{renderTime:s,cacheHit:!1,totalSize:a.length,componentCount:t.metadata.componentCount}}}function V(t,e){let n=[],r=[],a=[],i=new Map,s=[];return y(t.tree,(o,c)=>{if(o.type==="component"&&o.componentName){if(T(o.componentName))n.push(o.componentName)}if(o.type==="element"&&o.tag){let p=J(o);if(p)s.push(p);if(o.props){for(let[l,f]of Object.entries(o.props))if(l.startsWith("on")&&typeof f==="string"){let g=`handler_${i.size}`;i.set(g,f)}}}if(o.isStatic&&o.type==="element")r.push(b(o));else if(!o.isStatic&&o.type!=="text")a.push(o.tag||o.componentName||"unknown")}),{nativeComponents:n,staticHTML:r,dynamicParts:a,eventHandlers:i,nativeWidgets:s}}function Y(t,e={}){let n=R(t),r=P(n,e),a=new Map,i=[];return y(n.tree,(s)=>{if(s.type==="component"&&s.componentName){if(T(s.componentName)){i.push(s.componentName);let o=`<!--craft:${s.componentName}:${s.hydrationKey||"default"}-->`;a.set(s.hydrationKey||s.componentName,o)}}}),{staticHTML:r,dynamicPlaceholders:a,craftComponents:i}}function M(t){let e={type:"fragment",children:[]},n=e,r=[e],a=t,i=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);while(a.length>0){let s=a.match(/^<(@?[\w-]+)([^>]*)>/);if(s){let[p,l,f]=s,g=z(f),u=l.startsWith("@craft-"),C=u?l:l.toLowerCase(),S={type:u?"component":"element",tag:C,props:g,children:[],componentName:u?C.slice(1):void 0,isStatic:!v(f),hydrationKey:F()};if(n.children=n.children||[],n.children.push(S),!i.has(C)&&!f.endsWith("/"))r.push(S),n=S;a=a.slice(p.length);continue}let o=a.match(/^<\/(@?[\w-]+)>/);if(o){let[p,l]=o,g=l.startsWith("@craft-")?l:l.toLowerCase();while(r.length>1){let u=r.pop();if(n=r[r.length-1],u.tag===g)break}a=a.slice(p.length);continue}let c=a.match(/^[^<]+/);if(c){let p=c[0];if(p.trim()){let l={type:"text",text:p,isStatic:!v(p)};n.children=n.children||[],n.children.push(l)}a=a.slice(p.length);continue}a=a.slice(1)}return e}function z(t){let e={},n=/([\w-:@]+)(?:=(?:"([^"]*)"|'([^']*)'|(\S+)))?/g,r;while((r=n.exec(t))!==null){let[,a,i,s,o]=r,c=i??s??o??!0;e[a]=c}return e}function y(t,e,n=[]){if(e(t,n),t.children)t.children.forEach((r,a)=>{y(r,e,[...n,`${a}`])})}function h(t,e){switch(t.type){case"text":return x(t.text||"",e);case"element":case"component":{let n=t.tag||"div",r=N(t.props||{},e),a=(t.children||[]).map((i)=>h(i,e)).join("");if(!t.children||t.children.length===0){if(["input","br","hr","img","meta","link"].includes(n))return`<${n}${r} />`}return`<${n}${r}>${a}</${n}>`}case"fragment":return(t.children||[]).map((n)=>h(n,e)).join("");case"slot":return`<!--slot:${t.slotName||"default"}-->`;default:return""}}function b(t){if(t.type==="text")return t.text||"";let e=t.tag||"div",n=N(t.props||{},{});return`<${e}${n}></${e}>`}function N(t,e){let n=[];for(let[r,a]of Object.entries(t))if(a===!0)n.push(` ${r}`);else if(a!==!1&&a!==null&&a!==void 0){let i=x(String(a),e);n.push(` ${r}="${k(i)}"`)}return n.join("")}async function H(t,e){return h(t,e)}function P(t,e){let n=[];return y(t.tree,(r)=>{if(r.isStatic)n.push(h(r,e))}),n.join("")}function j(t,e,n){let r={templateId:e.id,context:n,dynamicParts:Array.from(e.dynamicParts.entries())},a=`
|
|
7
7
|
<script data-craft-hydration>
|
|
8
8
|
window.__CRAFT_HYDRATION__ = ${JSON.stringify(r)};
|
|
9
|
-
</script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{
|
|
9
|
+
</script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{fu as CRAFT_BRIDGE_SCRIPT,ko as CRAFT_COMPONENTS,_a as CRAFT_COMPONENT_RUNTIME,Qr as CRAFT_COMPONENT_STYLES,So as NATIVE_COMPONENTS,Ea as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,va as compileToNative,xa as createHotReloadServer,Ta as findCraftBinary,Sa as generateCraftBridgeScript,V as generateCraftOptimizations,Ra as getAvailableFormats,$a as getAvailableTargets,wh as getCraftComponents,G as getSSRCacheStats,ka as injectCraftBridge,hh as isCraftEnvironment,Y as prerenderForCraft,Ca as processCraftComponents,yh as processCraftDirective,bh as registerCraftComponent,Q as renderSSR};
|
|
@@ -89,6 +89,14 @@ export function applyStaticAccessibility(props) {
|
|
|
89
89
|
}
|
|
90
90
|
export const ACCESSIBILITY_FIELDS = ["accessibilityLabel", "accessibilityRole", "accessibilityState", "accessibilityValue"];
|
|
91
91
|
export function projectAccessibility(props, type) {
|
|
92
|
+
let relevant = type === "Image";
|
|
93
|
+
if (!relevant) {
|
|
94
|
+
const names = Object.keys(props);
|
|
95
|
+
for (let i = 0;i < names.length && !relevant; i++)
|
|
96
|
+
relevant = isAccessibilityAttribute(names[i]) || ACCESSIBILITY_FIELDS.includes(names[i]);
|
|
97
|
+
}
|
|
98
|
+
if (!relevant)
|
|
99
|
+
return {};
|
|
92
100
|
const projected = { ...props };
|
|
93
101
|
applyStaticAccessibility(projected);
|
|
94
102
|
if (type === "Image" && projected.accessibilityLabel === void 0 && props.alt != null && props.alt !== "")
|
|
@@ -154,7 +154,7 @@ export async function compileNativeBundle(options) {
|
|
|
154
154
|
const browser = options.browser;
|
|
155
155
|
if (options.screens[NATIVE_RUNTIME_ROUTE])
|
|
156
156
|
throw Error(`${NATIVE_RUNTIME_ROUTE} is the runtime prelude's file, not a screen name`);
|
|
157
|
-
const signalsRuntime = generateSignalsRuntime();
|
|
157
|
+
const signalsRuntime = generateSignalsRuntime({ native: !0 });
|
|
158
158
|
if (browser && options.routesDir)
|
|
159
159
|
throw Error("A browser screen is one route; routesDir is for device hosts");
|
|
160
160
|
const dependencies = new Set(compiledScreens.flatMap(({ compiled }) => compiled.dependencies));
|
|
@@ -219,7 +219,39 @@ function declarations(css) {
|
|
|
219
219
|
}
|
|
220
220
|
return result;
|
|
221
221
|
}
|
|
222
|
+
const textEntries = new Map;
|
|
222
223
|
function styleEntries(input, report) {
|
|
224
|
+
if (typeof input === "string") {
|
|
225
|
+
const known = textEntries.get(input);
|
|
226
|
+
if (known)
|
|
227
|
+
return known;
|
|
228
|
+
const entries = textStyleEntries(input, report);
|
|
229
|
+
if (entries) {
|
|
230
|
+
if (textEntries.size >= 2000)
|
|
231
|
+
textEntries.clear();
|
|
232
|
+
textEntries.set(input, entries);
|
|
233
|
+
return entries;
|
|
234
|
+
}
|
|
235
|
+
return [];
|
|
236
|
+
}
|
|
237
|
+
return objectStyleEntries(input, report);
|
|
238
|
+
}
|
|
239
|
+
function textStyleEntries(text, report) {
|
|
240
|
+
let input = text.trim();
|
|
241
|
+
if (!input)
|
|
242
|
+
return [];
|
|
243
|
+
try {
|
|
244
|
+
input = JSON.parse(input);
|
|
245
|
+
} catch {}
|
|
246
|
+
if (typeof input === "string")
|
|
247
|
+
return declarations(input);
|
|
248
|
+
if (input && typeof input === "object" && !Array.isArray(input))
|
|
249
|
+
return Object.entries(input);
|
|
250
|
+
if (input != null && input !== !1)
|
|
251
|
+
report({ kind: "non-numeric-style", name: "style" });
|
|
252
|
+
return null;
|
|
253
|
+
}
|
|
254
|
+
function objectStyleEntries(input, report) {
|
|
223
255
|
let entries;
|
|
224
256
|
if (typeof input === "string") {
|
|
225
257
|
input = input.trim();
|
|
@@ -247,11 +279,68 @@ export function parseNativeStyle(input, report = () => {}, context = {}) {
|
|
|
247
279
|
}
|
|
248
280
|
const NO_STYLE_VARIABLES = new Map;
|
|
249
281
|
export function parseNativeStyleLayers(inputs, inheritedVariables, report) {
|
|
250
|
-
|
|
251
|
-
|
|
282
|
+
let known = null, keys = null;
|
|
283
|
+
const layers = Array(inputs.length);
|
|
284
|
+
let empty = !0;
|
|
285
|
+
for (let i = 0;i < inputs.length; i++) {
|
|
286
|
+
const input = inputs[i];
|
|
287
|
+
if (input && typeof input === "object" && !Array.isArray(input) || typeof input === "string" && input) {
|
|
288
|
+
const key = typeof input === "string" ? standaloneStyleText(input) : standaloneStyleKey(input), kept = key === void 0 ? void 0 : rememberedStyles.get(key);
|
|
289
|
+
if (kept) {
|
|
290
|
+
(known ??= Array(inputs.length))[i] = kept;
|
|
291
|
+
layers[i] = NO_ENTRIES;
|
|
292
|
+
empty = !1;
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
if (key !== void 0)
|
|
296
|
+
(keys ??= Array(inputs.length))[i] = key;
|
|
297
|
+
}
|
|
298
|
+
layers[i] = styleEntries(input, report);
|
|
299
|
+
if (layers[i].length)
|
|
300
|
+
empty = !1;
|
|
301
|
+
}
|
|
302
|
+
if (empty)
|
|
252
303
|
return { variables: inheritedVariables ?? NO_STYLE_VARIABLES, styles: layers.map(() => ({})) };
|
|
253
|
-
const variables = createStyleVariables(layers.flat(), inheritedVariables);
|
|
254
|
-
|
|
304
|
+
const variables = createStyleVariables(layers.flat(), inheritedVariables), computed = variables.computed(), styles = Array(inputs.length);
|
|
305
|
+
for (let i = 0;i < inputs.length; i++) {
|
|
306
|
+
const kept = known?.[i];
|
|
307
|
+
if (kept) {
|
|
308
|
+
styles[i] = kept;
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
311
|
+
const key = keys?.[i];
|
|
312
|
+
if (key === void 0) {
|
|
313
|
+
styles[i] = layers[i].length ? parseEntries(layers[i], variables, report) : {};
|
|
314
|
+
continue;
|
|
315
|
+
}
|
|
316
|
+
let reported = !1;
|
|
317
|
+
const style = parseEntries(layers[i], variables, (diagnostic) => {
|
|
318
|
+
reported = !0;
|
|
319
|
+
report(diagnostic);
|
|
320
|
+
});
|
|
321
|
+
if (!reported) {
|
|
322
|
+
if (rememberedStyles.size >= 2000)
|
|
323
|
+
rememberedStyles.clear();
|
|
324
|
+
rememberedStyles.set(key, style);
|
|
325
|
+
}
|
|
326
|
+
styles[i] = style;
|
|
327
|
+
}
|
|
328
|
+
return { variables: computed, styles };
|
|
329
|
+
}
|
|
330
|
+
const NO_ENTRIES = [], rememberedStyles = new Map;
|
|
331
|
+
function standaloneStyleText(text) {
|
|
332
|
+
return text.includes("var(") || text.includes("--") ? void 0 : `\x03${text}`;
|
|
333
|
+
}
|
|
334
|
+
function standaloneStyleKey(input) {
|
|
335
|
+
let text;
|
|
336
|
+
try {
|
|
337
|
+
text = JSON.stringify(input);
|
|
338
|
+
} catch {
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
if (typeof text !== "string" || text.includes("var(") || text.includes('"--'))
|
|
342
|
+
return;
|
|
343
|
+
return text;
|
|
255
344
|
}
|
|
256
345
|
function parseEntries(entries, variables, report) {
|
|
257
346
|
const style = {}, declarationNames = [];
|
|
@@ -63,8 +63,16 @@ function substitute(input, lookup) {
|
|
|
63
63
|
return replaced && output.length > LIMIT ? void 0 : output;
|
|
64
64
|
}
|
|
65
65
|
const NO_VARIABLES = new Map;
|
|
66
|
+
function declaresVariables(entries) {
|
|
67
|
+
for (let i = 0;i < entries.length; i++) {
|
|
68
|
+
const name = entries[i][0];
|
|
69
|
+
if (typeof name === "string" && name.trim().startsWith("--"))
|
|
70
|
+
return !0;
|
|
71
|
+
}
|
|
72
|
+
return !1;
|
|
73
|
+
}
|
|
66
74
|
export function createStyleVariables(entries, inherited) {
|
|
67
|
-
if (!entries.length) {
|
|
75
|
+
if (!entries.length || !declaresVariables(entries)) {
|
|
68
76
|
const used = new Set, resolve = (text, depth = 0) => depth > 64 ? void 0 : substitute(text, (name, fallback) => {
|
|
69
77
|
used.add(name);
|
|
70
78
|
return inherited?.get(name) ?? (fallback === void 0 ? void 0 : resolve(fallback, depth + 1));
|
|
@@ -155,8 +155,16 @@ const nativePropNames = new Map(NATIVE_PROP_NAMES.map((name) => [normaliseKey(na
|
|
|
155
155
|
function normaliseKey(name) {
|
|
156
156
|
return name.replace(/[-_]/g, "").toLowerCase();
|
|
157
157
|
}
|
|
158
|
+
const propNameCache = new Map;
|
|
158
159
|
export function nativePropName(name, type) {
|
|
159
160
|
if ((type === "Image" || type === "Video") && name.toLowerCase() === "src")
|
|
160
161
|
return "source";
|
|
161
|
-
|
|
162
|
+
let prop = propNameCache.get(name);
|
|
163
|
+
if (prop === void 0) {
|
|
164
|
+
prop = nativePropNames.get(normaliseKey(name)) ?? name;
|
|
165
|
+
if (propNameCache.size >= 2000)
|
|
166
|
+
propNameCache.clear();
|
|
167
|
+
propNameCache.set(name, prop);
|
|
168
|
+
}
|
|
169
|
+
return prop;
|
|
162
170
|
}
|
|
@@ -3,6 +3,8 @@ import type { NativeHost, NativeNode } from './native-host';
|
|
|
3
3
|
import type { STXDocument } from '../compiler/ir';
|
|
4
4
|
/** Clone the DOM-shaped metadata while the host clones the native descriptor. */
|
|
5
5
|
export declare function cloneNativeBindingNode(source: NativeBindingNode, id: string, onClassChange?: (value: string) => void, Element?: BindingElementClass): NativeBindingNode;
|
|
6
|
+
/** The same, with the attributes a caller chose (a loop row's, less what it binds itself). */
|
|
7
|
+
export declare function cloneNativeBindingNodeWith(source: NativeBindingNode, id: string, attributes: Array<{ name: string, value: string }>, Element?: BindingElementClass): NativeBindingNode;
|
|
6
8
|
/** Build host handles and a manifest-id lookup from already translated IR. */
|
|
7
9
|
export declare function materializeNativeBindingTree(document: STXDocument, manifest: BindingManifest, host: NativeHost): NativeBindingTree;
|
|
8
10
|
export declare interface NativeBindingNode extends NativeNode {
|
|
@@ -26,7 +26,10 @@ export class BindingElement {
|
|
|
26
26
|
this.__stxId = id;
|
|
27
27
|
this.tagName = type === "TextInput" ? "INPUT" : type === "Picker" ? "SELECT" : type.toUpperCase();
|
|
28
28
|
this.attributes = attributes;
|
|
29
|
-
|
|
29
|
+
const byName = new Map;
|
|
30
|
+
for (let i = 0;i < attributes.length; i++)
|
|
31
|
+
byName.set(attributes[i].name, attributes[i]);
|
|
32
|
+
this.byName = byName;
|
|
30
33
|
this.onClassChange = onClassChange;
|
|
31
34
|
}
|
|
32
35
|
get nextSibling() {
|
|
@@ -130,6 +133,14 @@ export function cloneNativeBindingNode(source, id, onClassChange, Element) {
|
|
|
130
133
|
}));
|
|
131
134
|
return createBindingNode(id, source.tagName, bindings, !1, source.className, onClassChange, Element);
|
|
132
135
|
}
|
|
136
|
+
export function cloneNativeBindingNodeWith(source, id, attributes, Element) {
|
|
137
|
+
const copies = Array(attributes.length);
|
|
138
|
+
for (let i = 0;i < attributes.length; i++)
|
|
139
|
+
copies[i] = { name: attributes[i].name, value: attributes[i].value };
|
|
140
|
+
const node = new (Element ?? BindingElement)(id, source.tagName, copies);
|
|
141
|
+
node.isConnected = !1;
|
|
142
|
+
return node;
|
|
143
|
+
}
|
|
133
144
|
export function materializeNativeBindingTree(document, manifest, host) {
|
|
134
145
|
const entries = new Map(manifest.entries.map((entry) => [entry.id, entry])), nodes = new Map, scopes = new Map;
|
|
135
146
|
let sequence = 0;
|
|
@@ -9,6 +9,11 @@ function capabilityFlags(capabilities) {
|
|
|
9
9
|
return {
|
|
10
10
|
desktop: capabilities.has("desktop"),
|
|
11
11
|
haptics: capabilities.has("haptics"),
|
|
12
|
+
rawMotionSensors: capabilities.has("rawMotionSensors"),
|
|
13
|
+
barometer: capabilities.has("barometer"),
|
|
14
|
+
pedometer: capabilities.has("pedometer"),
|
|
15
|
+
healthBackground: capabilities.has("healthBackground"),
|
|
16
|
+
pedometerPassive: capabilities.has("pedometerPassive"),
|
|
12
17
|
speechRecognition: !1,
|
|
13
18
|
share: capabilities.has("share"),
|
|
14
19
|
camera: capabilities.has("camera"),
|
|
@@ -24,6 +29,7 @@ function capabilityFlags(capabilities) {
|
|
|
24
29
|
localDatabase: capabilities.has("database"),
|
|
25
30
|
lifecycle: capabilities.has("lifecycle"),
|
|
26
31
|
geolocation: capabilities.has("geolocation"),
|
|
32
|
+
locationRecordingBarometer: capabilities.has("locationRecordingBarometer"),
|
|
27
33
|
locationRecordingOwnership: capabilities.has("locationRecordingOwnership"),
|
|
28
34
|
locationRecordingIntentIdentity: capabilities.has("locationRecordingIntentIdentity"),
|
|
29
35
|
music: capabilities.has("music"),
|
|
@@ -78,6 +84,12 @@ function platformUserAgent(platform) {
|
|
|
78
84
|
}
|
|
79
85
|
export function installCraftBridge(protocol, nativeBridge, target = globalThis, options = {}) {
|
|
80
86
|
const craft = target.craft = target.craft || {}, capabilities = new Set(nativeBridge.capabilities || []), request = (module, method, args) => protocol.callNativeAPI(module, method, ...args), ask = (module, method, args) => protocol.callPersonFacingAPI(module, method, ...args), recordingRequest = (module, method, options) => {
|
|
87
|
+
if (module === "Location" && options && Object.prototype.hasOwnProperty.call(options, "includeBarometerSamples")) {
|
|
88
|
+
if (typeof options.includeBarometerSamples !== "boolean")
|
|
89
|
+
return Promise.reject(Object.assign(Error("includeBarometerSamples must be boolean"), { code: "INVALID_ARGUMENT" }));
|
|
90
|
+
if (options.includeBarometerSamples && !capabilities.has("locationRecordingBarometer"))
|
|
91
|
+
return Promise.reject(Object.assign(Error("This app build cannot read recorded pressure"), { code: "UNSUPPORTED" }));
|
|
92
|
+
}
|
|
81
93
|
if (options && Object.prototype.hasOwnProperty.call(options, "expectedId")) {
|
|
82
94
|
if (typeof options.expectedId !== "string" || !options.expectedId.trim())
|
|
83
95
|
return Promise.reject(Object.assign(Error("expectedId must be a nonempty recording ID"), { code: "INVALID_ARGUMENT" }));
|
|
@@ -87,6 +99,12 @@ export function installCraftBridge(protocol, nativeBridge, target = globalThis,
|
|
|
87
99
|
}
|
|
88
100
|
return request(module, method, options === void 0 ? [] : [options]);
|
|
89
101
|
}, recordingStart = async (module, options = {}) => {
|
|
102
|
+
if (module === "Location" && Object.prototype.hasOwnProperty.call(options, "barometer")) {
|
|
103
|
+
if (typeof options.barometer !== "boolean")
|
|
104
|
+
throw Object.assign(Error("barometer must be boolean"), { code: "INVALID_ARGUMENT" });
|
|
105
|
+
if (options.barometer && !capabilities.has("locationRecordingBarometer"))
|
|
106
|
+
throw Object.assign(Error("This app build cannot record background pressure"), { code: "UNSUPPORTED" });
|
|
107
|
+
}
|
|
90
108
|
if (Object.prototype.hasOwnProperty.call(options, "recordingId")) {
|
|
91
109
|
if (typeof options.recordingId !== "string" || !options.recordingId.trim())
|
|
92
110
|
throw Object.assign(Error("recordingId must be a nonempty recording ID"), { code: "INVALID_ARGUMENT" });
|
|
@@ -249,6 +267,54 @@ export function installCraftBridge(protocol, nativeBridge, target = globalThis,
|
|
|
249
267
|
})
|
|
250
268
|
};
|
|
251
269
|
}
|
|
270
|
+
const onSensorUpdate = (event, callback) => {
|
|
271
|
+
if (typeof callback !== "function")
|
|
272
|
+
throw TypeError("sensor.onUpdate needs a function");
|
|
273
|
+
return protocol.on("CRAFT_EVENT", ({ payload }) => {
|
|
274
|
+
if (payload?.event === event)
|
|
275
|
+
callback(payload.detail);
|
|
276
|
+
});
|
|
277
|
+
};
|
|
278
|
+
if (capabilities.has("rawMotionSensors"))
|
|
279
|
+
craft.rawMotionSensors = {
|
|
280
|
+
getAvailability: () => request("MotionSensors", "getAvailability", []),
|
|
281
|
+
start: (options) => request("MotionSensors", "start", [options]),
|
|
282
|
+
stop: (sensor) => request("MotionSensors", "stop", [sensor]),
|
|
283
|
+
stopAll: () => request("MotionSensors", "stopAll", []),
|
|
284
|
+
onUpdate: (callback) => onSensorUpdate("craftRawMotionUpdate", callback)
|
|
285
|
+
};
|
|
286
|
+
if (capabilities.has("barometer"))
|
|
287
|
+
craft.barometer = {
|
|
288
|
+
getAvailability: () => request("Barometer", "getAvailability", []),
|
|
289
|
+
start: (options = {}) => request("Barometer", "start", [options]),
|
|
290
|
+
stop: () => request("Barometer", "stop", []),
|
|
291
|
+
onUpdate: (callback) => onSensorUpdate("craftBarometerUpdate", callback)
|
|
292
|
+
};
|
|
293
|
+
if (capabilities.has("pedometer"))
|
|
294
|
+
craft.pedometer = {
|
|
295
|
+
getAvailability: () => request("Pedometer", "getAvailability", []),
|
|
296
|
+
getPermissionStatus: () => request("Pedometer", "getPermissionStatus", []),
|
|
297
|
+
requestPermission: () => ask("Pedometer", "requestPermission", []),
|
|
298
|
+
start: (options = {}) => request("Pedometer", "start", [options]),
|
|
299
|
+
stop: () => request("Pedometer", "stop", []),
|
|
300
|
+
query: (options) => request("Pedometer", "query", [options]),
|
|
301
|
+
onUpdate: (callback) => onSensorUpdate("craftPedometerUpdate", callback)
|
|
302
|
+
};
|
|
303
|
+
if (capabilities.has("healthBackground"))
|
|
304
|
+
craft.healthBackground = {
|
|
305
|
+
status: () => request("HealthBackground", "status", []),
|
|
306
|
+
pending: () => request("HealthBackground", "pending", []),
|
|
307
|
+
acknowledge: (ids) => request("HealthBackground", "acknowledge", [ids]),
|
|
308
|
+
refresh: () => request("HealthBackground", "refresh", []),
|
|
309
|
+
onChange: (callback) => onSensorUpdate("craftHealthBackground", callback)
|
|
310
|
+
};
|
|
311
|
+
if (capabilities.has("pedometerPassive"))
|
|
312
|
+
craft.pedometerPassive = {
|
|
313
|
+
availability: () => request("PedometerPassive", "availability", []),
|
|
314
|
+
start: () => request("PedometerPassive", "start", []),
|
|
315
|
+
stop: () => request("PedometerPassive", "stop", []),
|
|
316
|
+
history: () => request("PedometerPassive", "history", [])
|
|
317
|
+
};
|
|
252
318
|
craft.biometrics = {
|
|
253
319
|
isAvailable: () => request("Biometrics", "isAvailable", []),
|
|
254
320
|
getBiometricType: () => request("Biometrics", "getBiometricType", []),
|