@stacksjs/stx 0.2.793 → 0.2.795
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-027hdpgv.js +2 -0
- package/dist/chunk-054h7ktz.js +2 -0
- package/dist/chunk-09nyt9c5.js +2 -0
- package/dist/chunk-0d3ncyqh.js +2 -0
- package/dist/{chunk-2gqhfge6.js → chunk-12jjf2me.js} +2 -2
- package/dist/{chunk-jdj1358b.js → chunk-1hq3y7ss.js} +2 -2
- package/dist/{chunk-b4r7d6me.js → chunk-1q16p7t2.js} +5 -5
- package/dist/chunk-1yew6rw9.js +2 -0
- package/dist/chunk-211kxm18.js +2 -0
- package/dist/chunk-26y92p8r.js +2 -0
- package/dist/{chunk-a4cse2tj.js → chunk-2bvaakcv.js} +3 -3
- package/dist/{chunk-1z9hbzpk.js → chunk-2e5tvryz.js} +1 -1
- package/dist/{chunk-66r0f799.js → chunk-2xprqx2v.js} +5 -5
- package/dist/{chunk-dhqp3z4w.js → chunk-3em44jbm.js} +2 -2
- package/dist/chunk-3ep9h16p.js +2 -0
- package/dist/{chunk-6jzqzap6.js → chunk-3f8w1x6w.js} +10 -10
- package/dist/{chunk-14ft0zc7.js → chunk-3vpgr6nk.js} +6 -6
- package/dist/{chunk-8nb8b0nf.js → chunk-427mhgje.js} +1 -1
- package/dist/chunk-49tn6yst.js +2 -0
- package/dist/chunk-4b7dwwn6.js +2 -0
- package/dist/chunk-4ncbq4bx.js +2 -0
- package/dist/{chunk-985afhhy.js → chunk-4p5g7v9g.js} +2 -2
- package/dist/{chunk-7pk3t82j.js → chunk-4s0ye933.js} +2 -2
- package/dist/chunk-4srnxp3b.js +2 -0
- package/dist/chunk-538d185r.js +3 -0
- package/dist/{chunk-605b93pe.js → chunk-53v4cby3.js} +4 -4
- package/dist/{chunk-94gyfwpz.js → chunk-624xpap6.js} +12 -12
- package/dist/{chunk-kr8qdg0r.js → chunk-6s9bk98p.js} +2 -2
- package/dist/{chunk-q14d714d.js → chunk-6wpwpk3c.js} +4 -4
- package/dist/chunk-6z4bza9z.js +2 -0
- package/dist/chunk-75y9heas.js +2 -0
- package/dist/chunk-7ckdvsmj.js +3 -0
- package/dist/{chunk-rrb9m2q2.js → chunk-7k6hd10j.js} +5 -5
- package/dist/{chunk-1y9ez7nz.js → chunk-7s1kerhs.js} +2 -2
- package/dist/{chunk-k4bdf0dw.js → chunk-7xs45trj.js} +2 -2
- package/dist/{chunk-kce6pzmj.js → chunk-7y29q1ng.js} +3 -3
- package/dist/{chunk-vj59es75.js → chunk-7y73txmp.js} +1 -1
- package/dist/{chunk-gg71gm25.js → chunk-88acqv2r.js} +4 -4
- package/dist/{chunk-4de6rhaj.js → chunk-8t8e75xm.js} +4 -4
- package/dist/chunk-8w1wxr96.js +2 -0
- package/dist/{chunk-7gdwvnwc.js → chunk-8zf87cc5.js} +2 -2
- package/dist/{chunk-gv3bfkdm.js → chunk-90zswh9v.js} +5 -5
- package/dist/chunk-98kjk52z.js +2 -0
- package/dist/{chunk-c2qwbej3.js → chunk-9b9tvhmh.js} +5 -5
- package/dist/{chunk-bb2zfgwf.js → chunk-9jcqbgq9.js} +5 -5
- package/dist/chunk-9sea317f.js +2 -0
- package/dist/chunk-9tpv4cg7.js +2 -0
- package/dist/{chunk-qzb0v08n.js → chunk-ak10vygz.js} +1 -1
- package/dist/{chunk-m997knnz.js → chunk-aksrh8je.js} +3 -3
- package/dist/{chunk-6v4b0xc1.js → chunk-ata5wp2m.js} +4 -4
- package/dist/{chunk-a1ynjj47.js → chunk-axjfaere.js} +1226 -449
- package/dist/chunk-axq3c7cb.js +2 -0
- package/dist/{chunk-2hwwmn7c.js → chunk-ayd635jf.js} +5 -5
- package/dist/{chunk-qv85c3qy.js → chunk-azqf0ps0.js} +2 -2
- package/dist/{chunk-gb65t4n1.js → chunk-b58n1kfe.js} +2 -2
- package/dist/{chunk-c0ejyxfj.js → chunk-baj6w8ja.js} +2 -2
- package/dist/{chunk-es006emk.js → chunk-bwf8b4e4.js} +3 -3
- package/dist/{chunk-h0jnatd4.js → chunk-bzhzp4f4.js} +2 -2
- package/dist/chunk-c5trhqpg.js +2 -0
- package/dist/{chunk-bmfk3b29.js → chunk-c5vzr1va.js} +2 -2
- package/dist/chunk-c692kj5v.js +2 -0
- package/dist/{chunk-55j4jxwe.js → chunk-cepctq7e.js} +108 -108
- package/dist/{chunk-0r61tkfe.js → chunk-cfbpvm5e.js} +2 -2
- package/dist/chunk-cfr7cd88.js +2 -0
- package/dist/{chunk-bwcj9z19.js → chunk-d50vw81s.js} +4 -4
- package/dist/chunk-dsh5q9bg.js +2 -0
- package/dist/{chunk-e3wmnjz8.js → chunk-dstzvtvk.js} +3 -3
- package/dist/{chunk-2p4yad7w.js → chunk-dxe94pwy.js} +4 -4
- package/dist/{chunk-0ykteae5.js → chunk-ectx5ar9.js} +3 -3
- package/dist/chunk-emnphnz7.js +2 -0
- package/dist/chunk-ennzzth4.js +177 -0
- package/dist/chunk-epcdgn78.js +2 -0
- package/dist/chunk-etegf4zj.js +2 -0
- package/dist/chunk-ewzdsksb.js +2 -0
- package/dist/chunk-ey8bgg6x.js +2 -0
- package/dist/chunk-f03sg8b0.js +2 -0
- package/dist/{chunk-w5hhqjwr.js → chunk-f4j7nsj1.js} +1 -1
- package/dist/{chunk-fpn4dren.js → chunk-fcqxa38q.js} +1 -1
- package/dist/{chunk-j4s5k8sp.js → chunk-g4n0bjfb.js} +52 -52
- package/dist/chunk-gf04pgaa.js +2 -0
- package/dist/chunk-ghn8vhet.js +2 -0
- package/dist/chunk-gywp6kd8.js +2 -0
- package/dist/{chunk-tnn0br4w.js → chunk-h656zg6k.js} +3 -3
- package/dist/{chunk-syheccfj.js → chunk-hnbx1t3t.js} +2 -2
- package/dist/{chunk-g89fx9rq.js → chunk-hp10khyy.js} +41 -41
- package/dist/{chunk-d18xd9x5.js → chunk-hwcfgs3e.js} +3 -3
- package/dist/{chunk-5a92srn2.js → chunk-jmbh26gv.js} +1 -1
- package/dist/chunk-k6sjqb7g.js +2 -0
- package/dist/{chunk-vrbcdds3.js → chunk-ka8sk5qa.js} +1 -1
- package/dist/{chunk-r2nvxbjc.js → chunk-m081078c.js} +2 -2
- package/dist/{chunk-spt5kmb2.js → chunk-mcj5qtpp.js} +1 -1
- package/dist/chunk-me71d5w5.js +2 -0
- package/dist/{chunk-6h7yhyb8.js → chunk-njk5db1q.js} +4 -4
- package/dist/chunk-nvytej81.js +2 -0
- package/dist/{chunk-xc0vws7m.js → chunk-nyer6v3y.js} +5 -5
- package/dist/chunk-p1txw41y.js +2 -0
- package/dist/{chunk-agtvdtx4.js → chunk-p3ej3954.js} +2 -2
- package/dist/chunk-p8gekf4b.js +2 -0
- package/dist/{chunk-6jx0trea.js → chunk-pm8a4kdf.js} +6 -6
- package/dist/{chunk-56yhvhjq.js → chunk-pnddmgjf.js} +7 -7
- package/dist/chunk-px0qsd38.js +2 -0
- package/dist/{chunk-27rzdq3n.js → chunk-qnxctfdf.js} +2 -2
- package/dist/chunk-qr23snrp.js +2 -0
- package/dist/{chunk-v8rfeev5.js → chunk-r1vkk7qp.js} +2 -2
- package/dist/{chunk-qp3xd98j.js → chunk-r3a15pax.js} +2 -2
- package/dist/{chunk-pa9zfbh6.js → chunk-rdymnn2t.js} +2 -2
- package/dist/{chunk-g3z2g6hm.js → chunk-reb7rddz.js} +1 -1
- package/dist/chunk-s151a2dj.js +2 -0
- package/dist/{chunk-v1z6n7wz.js → chunk-sphc7xzx.js} +4 -4
- package/dist/chunk-sqettc34.js +2 -0
- package/dist/chunk-srgbv05n.js +2 -0
- package/dist/chunk-t0d4rsfx.js +2 -0
- package/dist/chunk-t0k0yk24.js +2 -0
- package/dist/chunk-tdcgskyy.js +2 -0
- package/dist/chunk-te3hr6d7.js +2 -0
- package/dist/chunk-tes8fdv6.js +2 -0
- package/dist/{chunk-9tqa8xvf.js → chunk-thpwk6ya.js} +2 -2
- package/dist/{chunk-w9nwb8r3.js → chunk-tmfrq4nq.js} +7 -7
- package/dist/{chunk-tnkxww7b.js → chunk-tqvw1673.js} +5 -5
- package/dist/chunk-v6j5vkce.js +2 -0
- package/dist/chunk-vmp876q6.js +2 -0
- package/dist/{chunk-4s5q1aea.js → chunk-vpzdqbw7.js} +4 -4
- package/dist/{chunk-tktkj2dc.js → chunk-vwp5fchy.js} +1 -1
- package/dist/{chunk-hs9fzxn0.js → chunk-w6e30qkz.js} +13 -13
- package/dist/{chunk-3gn1t0pa.js → chunk-w76cve9j.js} +9 -9
- package/dist/{chunk-7yb8943c.js → chunk-wa7fzgw7.js} +4 -4
- package/dist/chunk-wes5fdpe.js +2 -0
- package/dist/chunk-wfnfb4fr.js +2 -0
- package/dist/{chunk-cdsv4yrv.js → chunk-wfrqwtar.js} +1 -1
- package/dist/chunk-wzwfbehm.js +20 -0
- package/dist/{chunk-xadd911n.js → chunk-x8ghjw9b.js} +2 -2
- package/dist/{chunk-74rf78w8.js → chunk-x8h81amr.js} +2 -2
- package/dist/chunk-xbhb8102.js +2 -0
- package/dist/{chunk-5j619xgb.js → chunk-xqjat573.js} +2 -2
- package/dist/chunk-xv4paxmt.js +2 -0
- package/dist/{chunk-628jcm1d.js → chunk-y2jqx5k4.js} +1 -1
- package/dist/{chunk-g7anxh36.js → chunk-y64f5t74.js} +5 -5
- package/dist/chunk-yeaqebnd.js +2 -0
- package/dist/chunk-yj20tq3s.js +2 -0
- package/dist/chunk-yjm7c78z.js +2 -0
- package/dist/{chunk-h0c6jtrj.js → chunk-yjnaqahd.js} +4 -4
- package/dist/{chunk-4cffjp4f.js → chunk-zmr0pvcd.js} +113 -105
- package/dist/{chunk-44ep7dkr.js → chunk-zv3zpmv1.js} +1 -1
- package/dist/{chunk-bxxgr5c5.js → chunk-zva4a7xq.js} +2 -2
- package/dist/cli.js +19 -19
- package/dist/client/signals-authoring-runtime.js +2 -2
- package/dist/client/signals-binding-utils-runtime.js +14 -8
- 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 +43 -20
- package/dist/client/signals-helpers-runtime.js +39 -0
- package/dist/client/signals-native-row-runtime.d.ts +26 -0
- package/dist/client/signals-native-row-runtime.js +626 -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 +38 -1
- 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 +219 -94
- 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 +5 -5
- package/dist/chunk-0a9ceqa8.js +0 -2
- package/dist/chunk-0cm94ksp.js +0 -2
- package/dist/chunk-0ppx28f6.js +0 -2
- package/dist/chunk-1aent61q.js +0 -2
- package/dist/chunk-1brkqd5f.js +0 -2
- package/dist/chunk-1pbyr47e.js +0 -2
- package/dist/chunk-1tvb2stj.js +0 -2
- package/dist/chunk-22z2cwhv.js +0 -2
- package/dist/chunk-276e3d0g.js +0 -3
- package/dist/chunk-27vn4674.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-44tq4d62.js +0 -2
- package/dist/chunk-499v1ade.js +0 -2
- package/dist/chunk-4gx5ze56.js +0 -2
- package/dist/chunk-4v22nj67.js +0 -2
- package/dist/chunk-55wsqxfk.js +0 -2
- package/dist/chunk-5pe7wcvh.js +0 -2
- package/dist/chunk-5y5k6x3r.js +0 -2
- package/dist/chunk-699t603m.js +0 -2
- package/dist/chunk-6f6xqzhb.js +0 -2
- package/dist/chunk-7fx8p9w5.js +0 -2
- package/dist/chunk-8698v9gf.js +0 -2
- package/dist/chunk-8pphy0p1.js +0 -2
- package/dist/chunk-98308vtv.js +0 -20
- package/dist/chunk-ad2fk303.js +0 -2
- package/dist/chunk-ajj56vrw.js +0 -2
- package/dist/chunk-brqcepmv.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-ddbkw53b.js +0 -2
- package/dist/chunk-dtnyrjcj.js +0 -2
- package/dist/chunk-dyp0kgmr.js +0 -177
- package/dist/chunk-fc384a2h.js +0 -2
- package/dist/chunk-fkkdt6sj.js +0 -2
- package/dist/chunk-fxy0cq7h.js +0 -2
- package/dist/chunk-g6smtcc0.js +0 -2
- package/dist/chunk-gnydrw29.js +0 -2
- package/dist/chunk-jkm34gec.js +0 -2
- package/dist/chunk-js5zve3p.js +0 -2
- package/dist/chunk-k3mcb700.js +0 -3
- package/dist/chunk-kn38mjpp.js +0 -2
- package/dist/chunk-kvmpc0sg.js +0 -2
- package/dist/chunk-ncxed9r1.js +0 -2
- package/dist/chunk-nf2bzqaw.js +0 -2
- package/dist/chunk-nptp3x62.js +0 -2
- package/dist/chunk-qd9f47ds.js +0 -2
- package/dist/chunk-s1wdzttg.js +0 -2
- package/dist/chunk-t8vtf522.js +0 -2
- package/dist/chunk-t9744tty.js +0 -2
- package/dist/chunk-th5afzmv.js +0 -2
- package/dist/chunk-vaqqch06.js +0 -2
- package/dist/chunk-vgzfsh1z.js +0 -2
- package/dist/chunk-wr3adhd8.js +0 -2
- package/dist/chunk-zdwnzq78.js +0 -2
- package/dist/chunk-zsjw2jgy.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{xo,wa,va}from"./chunk-bwf8b4e4.js";import"./chunk-w76cve9j.js";import"./chunk-624xpap6.js";import"./chunk-b58n1kfe.js";import"./chunk-2yxva96k.js";import"./chunk-zmr0pvcd.js";import"./chunk-qnxctfdf.js";import"./chunk-hnbx1t3t.js";import"./chunk-bzhzp4f4.js";import"./chunk-6wpwpk3c.js";import"./chunk-g4n0bjfb.js";import"./chunk-tmfrq4nq.js";import"./chunk-53v4cby3.js";import"./chunk-538d185r.js";import"./chunk-9jcqbgq9.js";import"./chunk-hp10khyy.js";import"./chunk-njk5db1q.js";import"./chunk-3f8w1x6w.js";import"./chunk-pnddmgjf.js";import"./chunk-2bvaakcv.js";import"./chunk-12jjf2me.js";import"./chunk-baj6w8ja.js";import{pu,xa,mh,hh,Sa,So,Qr,ka,_a,yh,bh,Ca,Ea,Ta,$a}from"./chunk-w6e30qkz.js";import"./chunk-8t8e75xm.js";import"./chunk-7ckdvsmj.js";import"./chunk-azqf0ps0.js";import"./chunk-pm8a4kdf.js";import"./chunk-f4j7nsj1.js";import"./chunk-aksrh8je.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{pu as CRAFT_BRIDGE_SCRIPT,
|
|
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{pu as CRAFT_BRIDGE_SCRIPT,So as CRAFT_COMPONENTS,ka as CRAFT_COMPONENT_RUNTIME,Qr as CRAFT_COMPONENT_STYLES,xo as NATIVE_COMPONENTS,Ca as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,wa as compileToNative,va as createHotReloadServer,Ea as findCraftBinary,xa as generateCraftBridgeScript,V as generateCraftOptimizations,$a as getAvailableFormats,Ta as getAvailableTargets,bh as getCraftComponents,G as getSSRCacheStats,Sa as injectCraftBridge,mh as isCraftEnvironment,Y as prerenderForCraft,_a as processCraftComponents,hh as processCraftDirective,yh as registerCraftComponent,Q as renderSSR};
|
package/dist/craft.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{xo,wa,va}from"./chunk-bwf8b4e4.js";import"./chunk-w76cve9j.js";import"./chunk-624xpap6.js";import"./chunk-b58n1kfe.js";import"./chunk-2yxva96k.js";import"./chunk-zmr0pvcd.js";import"./chunk-qnxctfdf.js";import"./chunk-hnbx1t3t.js";import"./chunk-bzhzp4f4.js";import"./chunk-6wpwpk3c.js";import"./chunk-g4n0bjfb.js";import"./chunk-tmfrq4nq.js";import"./chunk-53v4cby3.js";import"./chunk-538d185r.js";import"./chunk-9jcqbgq9.js";import"./chunk-hp10khyy.js";import"./chunk-njk5db1q.js";import"./chunk-3f8w1x6w.js";import"./chunk-pnddmgjf.js";import"./chunk-2bvaakcv.js";import"./chunk-12jjf2me.js";import"./chunk-baj6w8ja.js";import{pu,xa,mh,hh,Sa,So,Qr,ka,_a,yh,bh,Ca,Ea,Ta,$a}from"./chunk-w6e30qkz.js";import"./chunk-8t8e75xm.js";import"./chunk-7ckdvsmj.js";import"./chunk-azqf0ps0.js";import"./chunk-pm8a4kdf.js";import"./chunk-f4j7nsj1.js";import"./chunk-aksrh8je.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{pu as CRAFT_BRIDGE_SCRIPT,
|
|
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{pu as CRAFT_BRIDGE_SCRIPT,So as CRAFT_COMPONENTS,ka as CRAFT_COMPONENT_RUNTIME,Qr as CRAFT_COMPONENT_STYLES,xo as NATIVE_COMPONENTS,Ca as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,wa as compileToNative,va as createHotReloadServer,Ea as findCraftBinary,xa as generateCraftBridgeScript,V as generateCraftOptimizations,$a as getAvailableFormats,Ta as getAvailableTargets,bh as getCraftComponents,G as getSSRCacheStats,Sa as injectCraftBridge,mh as isCraftEnvironment,Y as prerenderForCraft,_a as processCraftComponents,hh as processCraftDirective,yh 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));
|
|
@@ -251,7 +251,44 @@ export function parseNativeStyleLayers(inputs, inheritedVariables, report) {
|
|
|
251
251
|
if (layers.every((entries) => entries.length === 0))
|
|
252
252
|
return { variables: inheritedVariables ?? NO_STYLE_VARIABLES, styles: layers.map(() => ({})) };
|
|
253
253
|
const variables = createStyleVariables(layers.flat(), inheritedVariables);
|
|
254
|
-
return { variables: variables.computed(), styles: layers.map((entries) =>
|
|
254
|
+
return { variables: variables.computed(), styles: layers.map((entries) => parseRememberedEntries(entries, variables, report)) };
|
|
255
|
+
}
|
|
256
|
+
const rememberedStyles = new Map;
|
|
257
|
+
function parseRememberedEntries(entries, variables, report) {
|
|
258
|
+
if (entries.length === 0)
|
|
259
|
+
return {};
|
|
260
|
+
let key = "";
|
|
261
|
+
for (let i = 0;i < entries.length; i++) {
|
|
262
|
+
const [name, value] = entries[i], kind = typeof value;
|
|
263
|
+
if (name.includes("--") || kind === "string" && value.includes("var("))
|
|
264
|
+
return parseEntries(entries, variables, report);
|
|
265
|
+
if (kind === "string" || kind === "number" || kind === "boolean" || value == null)
|
|
266
|
+
key += `${name}\x01${kind[0]}${String(value)}\x02`;
|
|
267
|
+
else if (kind === "object") {
|
|
268
|
+
let nested;
|
|
269
|
+
try {
|
|
270
|
+
nested = JSON.stringify(value);
|
|
271
|
+
} catch {
|
|
272
|
+
return parseEntries(entries, variables, report);
|
|
273
|
+
}
|
|
274
|
+
key += `${name}\x01o${nested}\x02`;
|
|
275
|
+
} else
|
|
276
|
+
return parseEntries(entries, variables, report);
|
|
277
|
+
}
|
|
278
|
+
const known = rememberedStyles.get(key);
|
|
279
|
+
if (known)
|
|
280
|
+
return known;
|
|
281
|
+
let reported = !1;
|
|
282
|
+
const style = parseEntries(entries, variables, (diagnostic) => {
|
|
283
|
+
reported = !0;
|
|
284
|
+
report(diagnostic);
|
|
285
|
+
});
|
|
286
|
+
if (!reported) {
|
|
287
|
+
if (rememberedStyles.size >= 2000)
|
|
288
|
+
rememberedStyles.clear();
|
|
289
|
+
rememberedStyles.set(key, style);
|
|
290
|
+
}
|
|
291
|
+
return style;
|
|
255
292
|
}
|
|
256
293
|
function parseEntries(entries, variables, report) {
|
|
257
294
|
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", []),
|
|
@@ -106,6 +106,9 @@ export declare interface NativeLocation {
|
|
|
106
106
|
timestamp: number
|
|
107
107
|
}
|
|
108
108
|
export declare interface NativeLocationRecordingState {
|
|
109
|
+
barometer?: boolean
|
|
110
|
+
barometerError?: string
|
|
111
|
+
barometerEvents?: NativeRecordingPressureEvent[]
|
|
109
112
|
id: string | null
|
|
110
113
|
active: boolean
|
|
111
114
|
paused: boolean
|
|
@@ -148,7 +151,53 @@ export declare interface NativeFile {
|
|
|
148
151
|
type: string
|
|
149
152
|
size: number
|
|
150
153
|
}
|
|
154
|
+
export declare interface NativeRawMotionSensors {
|
|
155
|
+
getAvailability: () => Promise<Record<NativeRawMotionSensor, boolean>>
|
|
156
|
+
start: (options: { sensor: NativeRawMotionSensor, intervalMs?: number }) => Promise<boolean>
|
|
157
|
+
stop: (sensor: NativeRawMotionSensor) => Promise<boolean>
|
|
158
|
+
stopAll: () => Promise<boolean>
|
|
159
|
+
onUpdate: (callback: (reading: NativeRawMotionReading) => void) => () => void
|
|
160
|
+
}
|
|
161
|
+
export declare interface NativeBarometer {
|
|
162
|
+
getAvailability: () => Promise<{ relativeAltitude: boolean, absoluteAltitude: boolean, background: boolean, permissionDenied?: boolean }>
|
|
163
|
+
start: (options?: { intervalMs?: number, background?: boolean }) => Promise<boolean>
|
|
164
|
+
stop: () => Promise<boolean>
|
|
165
|
+
onUpdate: (callback: (event: NativeBarometerEvent) => void) => () => void
|
|
166
|
+
}
|
|
167
|
+
export declare interface NativePedometer {
|
|
168
|
+
getAvailability: () => Promise<Record<string, boolean>>
|
|
169
|
+
getPermissionStatus: () => Promise<'granted' | 'denied' | 'restricted' | 'notDetermined' | 'unavailable'>
|
|
170
|
+
requestPermission: () => Promise<'granted' | 'denied' | 'restricted' | 'notDetermined' | 'unavailable'>
|
|
171
|
+
start: (options?: { startDate?: number, sensor?: 'counter' | 'detector', background?: false }) => Promise<boolean>
|
|
172
|
+
stop: () => Promise<boolean>
|
|
173
|
+
query: (options: { startDate: number, endDate?: number }) => Promise<Extract<NativePedometerEvent, { kind: 'interval' }>>
|
|
174
|
+
onUpdate: (callback: (event: NativePedometerEvent) => void) => () => void
|
|
175
|
+
}
|
|
176
|
+
export declare interface NativeHealthBackgroundBatch {
|
|
177
|
+
id: string
|
|
178
|
+
type: string
|
|
179
|
+
samples: Array<{ id: string, startDate: number, endDate: number, value?: number, unit?: string, category?: number, workoutActivity?: number, durationSeconds?: number }>
|
|
180
|
+
deleted: string[]
|
|
181
|
+
}
|
|
182
|
+
export declare interface NativeHealthBackground {
|
|
183
|
+
status: () => Promise<{ types: string[], frequency: string, pendingBatches: number, errors: Record<string, string> }>
|
|
184
|
+
pending: () => Promise<NativeHealthBackgroundBatch[]>
|
|
185
|
+
acknowledge: (ids: string[]) => Promise<boolean>
|
|
186
|
+
refresh: () => Promise<boolean>
|
|
187
|
+
onChange: (callback: (detail: { type: string }) => void) => () => void
|
|
188
|
+
}
|
|
189
|
+
export declare interface NativePedometerPassive {
|
|
190
|
+
availability: () => Promise<{ supported: boolean, enabled: boolean, permissionGranted: boolean }>
|
|
191
|
+
start: () => Promise<boolean>
|
|
192
|
+
stop: () => Promise<boolean>
|
|
193
|
+
history: () => Promise<Array<{ kind: 'daily', source: 'healthServices', day: string, timeZone: string, startDate: number, endDate: number, steps: number }>>
|
|
194
|
+
}
|
|
151
195
|
export declare interface NativeCraft {
|
|
196
|
+
pedometerPassive?: NativePedometerPassive
|
|
197
|
+
healthBackground?: NativeHealthBackground
|
|
198
|
+
pedometer?: NativePedometer
|
|
199
|
+
rawMotionSensors?: NativeRawMotionSensors
|
|
200
|
+
barometer?: NativeBarometer
|
|
152
201
|
liveActivity?: NativeLiveActivities
|
|
153
202
|
desktop?: NativeDesktop
|
|
154
203
|
web?: NativeWeb
|
|
@@ -238,12 +287,12 @@ export declare interface NativeCraft {
|
|
|
238
287
|
getCurrentPosition: (options?: { enableHighAccuracy?: boolean, timeout?: number, maximumAge?: number }) => Promise<NativeLocation>
|
|
239
288
|
watchPosition: (callback: (location: NativeLocation) => unknown, options?: Record<string, unknown>) => number
|
|
240
289
|
clearWatch: (id?: number) => void
|
|
241
|
-
startRecording: (options?: Record<string, unknown> & { recordingId?: string }) => Promise<NativeLocationRecordingState>
|
|
290
|
+
startRecording: (options?: Record<string, unknown> & { recordingId?: string, barometer?: boolean }) => Promise<NativeLocationRecordingState>
|
|
242
291
|
pauseRecording: (options?: { expectedId: string }) => Promise<NativeLocationRecordingState>
|
|
243
292
|
resumeRecording: (options?: { expectedId: string }) => Promise<NativeLocationRecordingState>
|
|
244
293
|
stopRecording: (options?: { expectedId: string }) => Promise<NativeLocationRecordingState & { locations: NativeLocation[] }>
|
|
245
294
|
acknowledgeRecording: (options: { expectedId: string }) => Promise<boolean>
|
|
246
|
-
getRecordingState: (options?: { expectedId
|
|
295
|
+
getRecordingState: (options?: { expectedId?: string, includeBarometerSamples?: boolean }) => Promise<NativeLocationRecordingState & { sampleCount: number }>
|
|
247
296
|
readRecording: (options?: { expectedId: string }) => Promise<NativeLocation[]>
|
|
248
297
|
}
|
|
249
298
|
setKeepAwake?: (enabled: boolean) => Promise<boolean>
|
|
@@ -429,6 +478,33 @@ export declare interface NativeWeb {
|
|
|
429
478
|
openDownload: (path: string) => Promise<boolean>
|
|
430
479
|
}
|
|
431
480
|
export type NativePermissionStatus = 'granted' | 'denied' | 'undetermined';
|
|
481
|
+
/** Recorded pressure uses a new relative-altitude reference for each segment. */
|
|
482
|
+
export type NativeRecordingPressureEvent = {
|
|
483
|
+
recordingId: string
|
|
484
|
+
/** Unix milliseconds when the native journal received this event. */
|
|
485
|
+
timestamp: number
|
|
486
|
+
} & (
|
|
487
|
+
| { state: 'sample', segmentId: string, pressureHpa: number, referencePressureHpa: number, relativeAltitudeMeters: number, timestampMs: number }
|
|
488
|
+
| { state: 'segment', segmentId: string, reason: 'startedOrRecovered' | 'sampleGap', timestampMs?: number }
|
|
489
|
+
| { state: 'stopped', segmentId?: string, reason: 'paused' | 'stopped' | 'sensorOrStorageError' }
|
|
490
|
+
);
|
|
491
|
+
export type NativeRawMotionSensor = 'accelerometer' | 'gyroscope' | 'magnetometer' | 'rotationVector';
|
|
492
|
+
export type NativeRawMotionReading = {
|
|
493
|
+
/** Monotonic milliseconds since boot, not Unix time. */
|
|
494
|
+
timestampMs: number
|
|
495
|
+
accuracy: number
|
|
496
|
+
} & (
|
|
497
|
+
| { sensor: 'accelerometer', unit: 'm/s²', values: { x: number, y: number, z: number } }
|
|
498
|
+
| { sensor: 'gyroscope', unit: 'rad/s', values: { x: number, y: number, z: number } }
|
|
499
|
+
| { sensor: 'magnetometer', unit: 'µT', values: { x: number, y: number, z: number } }
|
|
500
|
+
| { sensor: 'rotationVector', unit: 'quaternion', values: { w: number, x: number, y: number, z: number } }
|
|
501
|
+
);
|
|
502
|
+
export type NativeBarometerEvent = | { state: 'sample', pressureHpa: number, relativeAltitudeMeters: number, timestampMs: number, referencePressureHpa?: number }
|
|
503
|
+
| { state: 'stopped', reason: 'background' | 'requested' | 'disposed' | 'sensorError' | 'permissionDenied' }
|
|
504
|
+
export type NativePedometerEvent = | { state: 'sample', kind: 'interval', startDate: number, endDate: number, steps: number, distanceMeters?: number, cadenceStepsPerSecond?: number, paceSecondsPerMeter?: number, averageActivePaceSecondsPerMeter?: number, floorsAscended?: number, floorsDescended?: number }
|
|
505
|
+
| { state: 'sample', kind: 'counter', stepsSinceBoot: number, timestampMs: number }
|
|
506
|
+
| { state: 'sample', kind: 'step', count: 1, timestampMs: number }
|
|
507
|
+
| { state: 'stopped', reason: 'requested' | 'background' | 'disposed' | 'sensorError' | 'permissionDenied' }
|
|
432
508
|
export type NativeWebEvent = | ({ type: 'state' } & NativeWebTabState)
|
|
433
509
|
| { type: 'navigationStart' | 'navigationFinish', tab: string, url: string }
|
|
434
510
|
| { type: 'navigationError', tab: string, url: string, code: number, domain: string, message: string }
|
|
@@ -53,6 +53,8 @@ export declare interface NativeHost {
|
|
|
53
53
|
setVisible: (node: NativeNode, visible: boolean) => boolean
|
|
54
54
|
anchor: (label: string) => NativeNode
|
|
55
55
|
clone: (node: NativeNode) => NativeNode
|
|
56
|
+
cloneElement: (node: NativeNode, attributes: Array<{ name: string, value: string }>) => NativeNode
|
|
57
|
+
append: (parent: NativeNode, node: NativeNode) => void
|
|
56
58
|
insert: (parent: NativeNode, node: NativeNode, before?: NativeNode | null) => void
|
|
57
59
|
remove: (node: NativeNode) => void
|
|
58
60
|
descendants: (node: NativeNode) => NativeNode[]
|