@stacksjs/stx 0.2.582 → 0.2.583
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-ayy9mmrw.js → chunk-02qaqamv.js} +6 -6
- package/dist/{chunk-6w2yqtrd.js → chunk-07anexcg.js} +1 -1
- package/dist/{chunk-dvgvvy5b.js → chunk-09zwhsf9.js} +1 -1
- package/dist/{chunk-cb2pyg5t.js → chunk-0dfgefjv.js} +2 -2
- package/dist/chunk-0fx3ppnt.js +2 -0
- package/dist/chunk-0sfexf9t.js +2 -0
- package/dist/chunk-2927nax9.js +2 -0
- package/dist/{chunk-eww6sdzz.js → chunk-2943qhdt.js} +1 -1
- package/dist/{chunk-9jh2ake5.js → chunk-2nehykbm.js} +5 -5
- package/dist/chunk-2rj0ttas.js +2 -0
- package/dist/chunk-3ae39ttg.js +2 -0
- package/dist/{chunk-q2a58n2a.js → chunk-440yjsk5.js} +1 -1
- package/dist/{chunk-kp0hg06s.js → chunk-4pkpr5cg.js} +2 -2
- package/dist/{chunk-g4crr86j.js → chunk-4pmgr32a.js} +3 -3
- package/dist/chunk-521pe0hb.js +18 -0
- package/dist/chunk-58z26y07.js +2 -0
- package/dist/chunk-5r9k9s3m.js +2 -0
- package/dist/{chunk-vx75fb0d.js → chunk-6fc8vw2v.js} +2 -2
- package/dist/{chunk-43h8q2cm.js → chunk-6m3me7yj.js} +6 -6
- package/dist/chunk-76vza4ve.js +2 -0
- package/dist/{chunk-c1r7zq0q.js → chunk-8tq83fq7.js} +71 -71
- package/dist/chunk-8y8bbsh5.js +2 -0
- package/dist/{chunk-620szfcp.js → chunk-96mb3brj.js} +2 -2
- package/dist/chunk-9kzycb15.js +2 -0
- package/dist/{chunk-djft0m5h.js → chunk-ac6v3s3k.js} +1 -1
- package/dist/chunk-agfhb2qd.js +2 -0
- package/dist/chunk-ay6dzpt4.js +2 -0
- package/dist/{chunk-dtcc09x1.js → chunk-b9njk81d.js} +1 -1
- package/dist/chunk-bfbcmfww.js +2 -0
- package/dist/chunk-br01jvra.js +2 -0
- package/dist/{chunk-v8p5p2kp.js → chunk-c12y2bet.js} +1 -1
- package/dist/chunk-c2nwchk0.js +2 -0
- package/dist/{chunk-3qrrv6af.js → chunk-cby4mkjf.js} +1 -1
- package/dist/{chunk-qazn64pm.js → chunk-ck1yca7g.js} +1 -1
- package/dist/chunk-cxqrwvc5.js +2 -0
- package/dist/chunk-czea8zr1.js +2 -0
- package/dist/chunk-d99kfx3k.js +2 -0
- package/dist/{chunk-7hkc96de.js → chunk-dhq80e4r.js} +4 -4
- package/dist/{chunk-cdgwkzms.js → chunk-dm1qh2vq.js} +1 -1
- package/dist/{chunk-5pgbsc3a.js → chunk-dskrwa8f.js} +1 -1
- package/dist/{chunk-zk2xk0wd.js → chunk-dvc15djp.js} +2 -2
- package/dist/chunk-e6ycqvdm.js +2 -0
- package/dist/{chunk-8v19753h.js → chunk-e809x7m0.js} +1 -1
- package/dist/{chunk-ta3wn842.js → chunk-en7xxgtb.js} +2 -2
- package/dist/chunk-fvx6pd66.js +2 -0
- package/dist/{chunk-xpnpg967.js → chunk-g9zeybqh.js} +2 -2
- package/dist/{chunk-zz02hwec.js → chunk-h3z9b6bw.js} +22 -22
- package/dist/{chunk-yk3fbzx5.js → chunk-hp9nxva6.js} +3 -3
- package/dist/chunk-hrbjapvr.js +2 -0
- package/dist/{chunk-pmpb34md.js → chunk-hzqyfdpy.js} +5 -5
- package/dist/chunk-jc4mxq56.js +2 -0
- package/dist/chunk-jdpyxt8j.js +2 -0
- package/dist/{chunk-4rkvwm6v.js → chunk-je1as16r.js} +9 -9
- package/dist/chunk-k0zev8wc.js +2 -0
- package/dist/{chunk-nrfh7gaa.js → chunk-kfwmqacd.js} +1 -1
- package/dist/{chunk-t61vdbje.js → chunk-ktvr45qg.js} +6 -6
- package/dist/{chunk-y8q1n7hx.js → chunk-ky1426s1.js} +6 -6
- package/dist/{chunk-rr8a7d4q.js → chunk-m417sp42.js} +3 -3
- package/dist/{chunk-101ekf6y.js → chunk-mjj24qpb.js} +2 -2
- package/dist/{chunk-ev5f79mg.js → chunk-mt9x626h.js} +3 -3
- package/dist/{chunk-faghmmrs.js → chunk-n4e02qdz.js} +85 -85
- package/dist/{chunk-yy3ser06.js → chunk-nh3svtvj.js} +3 -3
- package/dist/{chunk-yfq2v7x5.js → chunk-nhd9m8h5.js} +6 -6
- package/dist/chunk-nx8rf4qd.js +2 -0
- package/dist/{chunk-t8wpzqs4.js → chunk-pbwk8tzz.js} +1 -1
- package/dist/chunk-pe5bk9ns.js +2 -0
- package/dist/chunk-qb2j34sp.js +2 -0
- package/dist/chunk-qknfceta.js +2 -0
- package/dist/{chunk-0vnngvy1.js → chunk-qn8gdw21.js} +4 -4
- package/dist/chunk-sf98zgw2.js +2 -0
- package/dist/chunk-sgsp4dph.js +2 -0
- package/dist/{chunk-jtbzmbzz.js → chunk-sv08pd66.js} +2 -2
- package/dist/{chunk-30rf7k4n.js → chunk-tfxmzat6.js} +24 -24
- package/dist/chunk-tms7amrb.js +2 -0
- package/dist/chunk-v0zgarvv.js +2 -0
- package/dist/chunk-vczw73ga.js +2 -0
- package/dist/{chunk-be2ba3hj.js → chunk-vkc51n9m.js} +2 -2
- package/dist/{chunk-1v1mew46.js → chunk-vke73gts.js} +1 -1
- package/dist/{chunk-c0s3k64c.js → chunk-w6wtxj54.js} +2 -2
- package/dist/chunk-webrqm20.js +2 -0
- package/dist/chunk-wngqr949.js +2 -0
- package/dist/{chunk-71sdgv7e.js → chunk-wyn5rfzk.js} +105 -35
- package/dist/{chunk-yhpyqsbr.js → chunk-x552npae.js} +2 -2
- package/dist/{chunk-3wy8q3aq.js → chunk-xp7fxc6p.js} +5 -5
- package/dist/{chunk-t4g2fptt.js → chunk-xytkfa48.js} +4 -4
- package/dist/chunk-xyzy84x0.js +2 -0
- package/dist/chunk-y1jffvkj.js +2 -0
- package/dist/{chunk-74j18qk0.js → chunk-y8h823cb.js} +28 -28
- package/dist/chunk-yas134jv.js +2 -0
- package/dist/{chunk-tszkg6sj.js → chunk-ycj0342k.js} +1 -1
- package/dist/{chunk-mxe21m6q.js → chunk-yd55vynh.js} +1 -1
- package/dist/{chunk-hzfhn2vr.js → chunk-ye66wc53.js} +2 -2
- package/dist/{chunk-k9th7hc4.js → chunk-ym1sb5bg.js} +2 -2
- package/dist/chunk-yn2d8x8m.js +3 -0
- package/dist/chunk-ze86h6vp.js +2 -0
- package/dist/cli.js +44 -44
- package/dist/client/signals-authoring-runtime.js +13 -6
- package/dist/client/signals-binding-utils-runtime.js +14 -1
- package/dist/client/signals-component-api-runtime.js +3 -1
- package/dist/client/signals-event-shorthand-runtime.js +1 -1
- package/dist/client/signals-expression-runtime.js +1 -1
- package/dist/client/signals-host-runtime.js +20 -0
- package/dist/client/signals-manifest-hydration-runtime.js +7 -0
- package/dist/client/signals-model-runtime.js +2 -0
- package/dist/client/signals-mount-runtime.js +5 -1
- package/dist/client/signals-process-element-runtime.js +22 -7
- package/dist/component-model.d.ts +1 -1
- package/dist/component-model.js +6 -3
- package/dist/composition-api.js +3 -2
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/native/compiler/bundle.js +8 -3
- package/dist/native/compiler/html-to-ir.d.ts +3 -1
- package/dist/native/compiler/html-to-ir.js +28 -1
- package/dist/native/runtime/binding-tree.js +12 -0
- package/dist/native/runtime/craft-bridge.js +2 -1
- package/dist/native/runtime/jsc-globals.d.ts +10 -3
- package/dist/native/runtime/jsc-globals.js +23 -4
- package/dist/native/runtime/native-host.d.ts +4 -0
- package/dist/native/runtime/native-host.js +273 -21
- package/dist/native/runtime/shared-screen.js +1 -0
- package/dist/native/testing.js +1 -1
- package/dist/pwa.js +3 -3
- package/dist/ssg.js +7 -7
- package/package.json +5 -5
- package/dist/chunk-0047meje.js +0 -2
- package/dist/chunk-1cat8kdj.js +0 -2
- package/dist/chunk-1dwnp35v.js +0 -2
- package/dist/chunk-2dnr5qfk.js +0 -2
- package/dist/chunk-2v73cjbc.js +0 -2
- package/dist/chunk-3akgppsy.js +0 -2
- package/dist/chunk-4t67wmcg.js +0 -2
- package/dist/chunk-51zn42jy.js +0 -2
- package/dist/chunk-5702x95v.js +0 -2
- package/dist/chunk-60c2bsh9.js +0 -2
- package/dist/chunk-79v4d9qh.js +0 -2
- package/dist/chunk-7pp2vx1g.js +0 -2
- package/dist/chunk-8zm6tkqb.js +0 -2
- package/dist/chunk-a1z36dt5.js +0 -2
- package/dist/chunk-atsf1fe0.js +0 -2
- package/dist/chunk-b8qd6h1q.js +0 -2
- package/dist/chunk-ccxs40xy.js +0 -2
- package/dist/chunk-cg8hg6cs.js +0 -3
- package/dist/chunk-cp442y7a.js +0 -2
- package/dist/chunk-d4en5d3s.js +0 -2
- package/dist/chunk-dh80d57p.js +0 -2
- package/dist/chunk-dyqte1xq.js +0 -2
- package/dist/chunk-e4n4v022.js +0 -2
- package/dist/chunk-g2fw68zm.js +0 -2
- package/dist/chunk-hcgm37dy.js +0 -2
- package/dist/chunk-hd2bn5q7.js +0 -2
- package/dist/chunk-j1nqnmcd.js +0 -18
- package/dist/chunk-k7jqkt93.js +0 -2
- package/dist/chunk-mqy7g74k.js +0 -2
- package/dist/chunk-ne03tfje.js +0 -2
- package/dist/chunk-p2sns0bn.js +0 -2
- package/dist/chunk-s1sycp43.js +0 -2
- package/dist/chunk-sp46w7z9.js +0 -2
- package/dist/chunk-sy1bk1ry.js +0 -2
- package/dist/chunk-tpd5nwa3.js +0 -2
- package/dist/chunk-tpt4bgs5.js +0 -2
- package/dist/chunk-vq0cb1m9.js +0 -2
- package/dist/chunk-y1bppxgw.js +0 -2
- package/dist/chunk-yv5rwthv.js +0 -2
- package/dist/chunk-z1r4tdqy.js +0 -2
- package/dist/chunk-zv288w4e.js +0 -2
|
@@ -94,6 +94,17 @@ export const SIGNALS_BINDING_UTILS_RUNTIME = ` // Minimal attribute-only pass f
|
|
|
94
94
|
return false;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
function bindFormControlReset(el, key, read, write) {
|
|
98
|
+
if (!stxHost.onFormReset) return;
|
|
99
|
+
var bindings = el.__stx_form_resets || (el.__stx_form_resets = {});
|
|
100
|
+
if (bindings[key]) return;
|
|
101
|
+
var initial = peek(read);
|
|
102
|
+
bindings[key] = true;
|
|
103
|
+
var stop = stxHost.onFormReset(el, function() { write(initial); });
|
|
104
|
+
el.__stx_destroy = el.__stx_destroy || [];
|
|
105
|
+
el.__stx_destroy.push(function() { stop(); delete bindings[key]; });
|
|
106
|
+
}
|
|
107
|
+
|
|
97
108
|
function syncComponentPropSignal(el, name, value) {
|
|
98
109
|
if (!el || !el.getAttribute || value === undefined) return;
|
|
99
110
|
var scopeId = el.getAttribute('data-stx-scope');
|
|
@@ -110,7 +121,6 @@ export const SIGNALS_BINDING_UTILS_RUNTIME = ` // Minimal attribute-only pass f
|
|
|
110
121
|
var propSignal = propSignals && (propSignals[name] || propSignals[camelName]);
|
|
111
122
|
if (!propSignal && scopeVars)
|
|
112
123
|
propSignal = scopeVars[name] || scopeVars[camelName];
|
|
113
|
-
if (!propSignal || !propSignal._isSignal || typeof propSignal.set !== 'function') return;
|
|
114
124
|
var directValues = el.__stx_direct_prop_values || (el.__stx_direct_prop_values = {});
|
|
115
125
|
var directValue = {
|
|
116
126
|
raw: el.hasAttribute(name) ? el.getAttribute(name) : null,
|
|
@@ -118,6 +128,9 @@ export const SIGNALS_BINDING_UTILS_RUNTIME = ` // Minimal attribute-only pass f
|
|
|
118
128
|
};
|
|
119
129
|
directValues[name] = directValue;
|
|
120
130
|
directValues[camelName] = directValue;
|
|
131
|
+
// The parent binding can run before child setup. Keep the typed value
|
|
132
|
+
// even then: JSON attributes cannot retain validators or other callbacks.
|
|
133
|
+
if (!propSignal || !propSignal._isSignal || typeof propSignal.set !== 'function') return;
|
|
121
134
|
// This runs inside the parent binding effect. Reading the child prop
|
|
122
135
|
// signal normally would subscribe that effect to its own output. Parent
|
|
123
136
|
// expressions that return a fresh array or object would then recurse:
|
|
@@ -40,7 +40,9 @@ export const SIGNALS_COMPONENT_API_RUNTIME = ` // Component composition API (
|
|
|
40
40
|
el.__stx_component_emits = el.__stx_component_emits || Object.create(null);
|
|
41
41
|
el.__stx_component_emits[event] = true;
|
|
42
42
|
}
|
|
43
|
-
|
|
43
|
+
var emitted = new CustomEvent(event, { detail: payload, bubbles: true, cancelable: true });
|
|
44
|
+
emitted.__stx_emit_args = Array.prototype.slice.call(arguments, 1);
|
|
45
|
+
stxHost.emitComponentEvent(target, emitted);
|
|
44
46
|
};
|
|
45
47
|
},
|
|
46
48
|
defineExpose: function(exposed) {
|
|
@@ -79,7 +79,7 @@ export const SIGNALS_EVENT_SHORTHAND_RUNTIME = ` // ===========================
|
|
|
79
79
|
if (bareIdMatch) {
|
|
80
80
|
const fn = scope[bareIdMatch[1]];
|
|
81
81
|
if (typeof fn === 'function' && !fn._isSignal) {
|
|
82
|
-
return (
|
|
82
|
+
return (...args) => fn(...args);
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
|
|
@@ -6,7 +6,7 @@ export const SIGNALS_EXPRESSION_RUNTIME = ` let componentScope = { $refs: {} };
|
|
|
6
6
|
function findElementScope(el) {
|
|
7
7
|
let current = el;
|
|
8
8
|
while (current && current !== document) {
|
|
9
|
-
//
|
|
9
|
+
// Explicit element-local mounts own their scope, ahead of a registry.
|
|
10
10
|
if (current.__stx_scope) {
|
|
11
11
|
return current.__stx_scope;
|
|
12
12
|
}
|
|
@@ -25,6 +25,11 @@ export const SIGNALS_HOST_RUNTIME = ` // \u2500\u2500 Host \u2500\u2500
|
|
|
25
25
|
node.setAttribute(name, next);
|
|
26
26
|
},
|
|
27
27
|
removeAttribute: function(node, name) { node.removeAttribute(name); },
|
|
28
|
+
observeAttributes: function(node, names, callback) {
|
|
29
|
+
var observer = new MutationObserver(callback);
|
|
30
|
+
observer.observe(node, { attributes: true, attributeFilter: names });
|
|
31
|
+
return function() { observer.disconnect(); };
|
|
32
|
+
},
|
|
28
33
|
setStyle: function(node, value) {
|
|
29
34
|
if (typeof value === 'object' && value !== null) {
|
|
30
35
|
Object.assign(node.style, value);
|
|
@@ -57,6 +62,21 @@ export const SIGNALS_HOST_RUNTIME = ` // \u2500\u2500 Host \u2500\u2500
|
|
|
57
62
|
// parameter silently makes every touch listener blocking again, so it stays
|
|
58
63
|
// in the signature and each host decides what to do with it.
|
|
59
64
|
listen: function(node, event, handler, options) { node.addEventListener(event, handler, options); },
|
|
65
|
+
emitComponentEvent: function(node, event) { return node.dispatchEvent(event); },
|
|
66
|
+
onFormReset: function(node, callback) {
|
|
67
|
+
var active = true;
|
|
68
|
+
var document = node.ownerDocument;
|
|
69
|
+
var listener = function(event) {
|
|
70
|
+
if (event.target !== node.form) return;
|
|
71
|
+
// The reset event precedes the browser default action and may be
|
|
72
|
+
// canceled by a later listener. Synchronize models only afterward.
|
|
73
|
+
queueMicrotask(function() {
|
|
74
|
+
if (active && !event.defaultPrevented) callback();
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
document.addEventListener('reset', listener, true);
|
|
78
|
+
return function() { active = false; document.removeEventListener('reset', listener, true); };
|
|
79
|
+
},
|
|
60
80
|
|
|
61
81
|
// Returns the PREVIOUS visibility. bindShow needs to know whether it just
|
|
62
82
|
// revealed something, and asking the node afterwards is the one read-back
|
|
@@ -43,6 +43,11 @@ export const SIGNALS_MANIFEST_HYDRATION_RUNTIME = ` /**
|
|
|
43
43
|
// that no longer exists in the host tree. Browser hydration keeps its
|
|
44
44
|
// existing behaviour because it does not pass resolvedNodes here.
|
|
45
45
|
if (resolvedNodes && node.__stxId !== undefined && node.isConnected === false) continue;
|
|
46
|
+
if (resolvedNodes && node.hasAttribute && node.hasAttribute('data-stx-scope')
|
|
47
|
+
&& !hasPendingLoopBoundary(node)) {
|
|
48
|
+
node.__stx_parent_scope = resolveComponentCallerScope(node, scope);
|
|
49
|
+
bindParentComponentProps(node, node.__stx_parent_scope);
|
|
50
|
+
}
|
|
46
51
|
processElement(node, scope, true);
|
|
47
52
|
}
|
|
48
53
|
return true;
|
|
@@ -72,6 +77,8 @@ export const SIGNALS_MANIFEST_HYDRATION_RUNTIME = ` /**
|
|
|
72
77
|
if (!mounted) return;
|
|
73
78
|
mounted = false;
|
|
74
79
|
disposeEffects();
|
|
80
|
+
disposeSubtreeEffects(root);
|
|
81
|
+
disposeSubtreeScopes(root);
|
|
75
82
|
var hooks = localDestroyHooks.splice(0, localDestroyHooks.length);
|
|
76
83
|
for (var i = 0; i < hooks.length; i++) {
|
|
77
84
|
try { hooks[i](); }
|
|
@@ -197,7 +197,11 @@ else {
|
|
|
197
197
|
if (typeof scope === 'object' && scope !== null) {
|
|
198
198
|
scope.$el = root;
|
|
199
199
|
scope.$refs = scope.$refs || {};
|
|
200
|
-
|
|
200
|
+
// An auto-mounted page can start with a shared component. That
|
|
201
|
+
// wrapper already owns a component scope: the page supplies its
|
|
202
|
+
// caller, not a replacement for its handlers/refs/prop signals.
|
|
203
|
+
if (root.hasAttribute('data-stx-component-wrapper')) root.__stx_parent_scope = scope;
|
|
204
|
+
else root.__stx_scope = scope;
|
|
201
205
|
Object.assign(componentScope, scope); // Keep for backwards compat
|
|
202
206
|
}
|
|
203
207
|
|
|
@@ -22,8 +22,12 @@ export function signalsProcessElementRuntime(directiveNamesLiteral, eventRegexLi
|
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
if (el.nodeType === Node.ELEMENT_NODE && el.
|
|
26
|
-
|
|
25
|
+
if (el.nodeType === Node.ELEMENT_NODE && el.hasAttribute
|
|
26
|
+
&& el.hasAttribute('data-stx-scope') && !hasPendingLoopBoundary(el)) {
|
|
27
|
+
// A page walk can reach a component before the dedicated scope pass.
|
|
28
|
+
// Resolve its caller before props/events bind and their guards latch.
|
|
29
|
+
el.__stx_parent_scope = el.__stx_parent_scope || resolveComponentCallerScope(el, scope);
|
|
30
|
+
bindParentComponentProps(el, el.__stx_parent_scope);
|
|
27
31
|
}
|
|
28
32
|
if (el.nodeType === Node.ELEMENT_NODE && el.hasAttribute) {
|
|
29
33
|
// x-data elements: the reactive bridge has registered their scope into window.stx._scopes.
|
|
@@ -350,6 +354,13 @@ catch (e2) {
|
|
|
350
354
|
var bindingScope = el.__stx_parent_scope && parentBindingNames.includes(attrName)
|
|
351
355
|
? el.__stx_parent_scope
|
|
352
356
|
: attrCapturedScope;
|
|
357
|
+
if ((attrName === 'value' || attrName === 'checked') && attrName in el) {
|
|
358
|
+
var modelName = value.trim().match(/^([a-zA-Z_$][\\w$]*)(?:\\(\\))?$/);
|
|
359
|
+
var resetModel = modelName && bindingScope[modelName[1]];
|
|
360
|
+
if (resetModel && resetModel._isSignal && typeof resetModel.set === 'function') {
|
|
361
|
+
bindFormControlReset(el, attrName, resetModel, function(initial) { resetModel.set(initial); });
|
|
362
|
+
}
|
|
363
|
+
}
|
|
353
364
|
effect(() => {
|
|
354
365
|
if (!attributesVisible()) return;
|
|
355
366
|
const v = evalAttrExpr(value, bindingScope);
|
|
@@ -503,6 +514,9 @@ else if (name === 'ref' || name === ':ref' || name === 'x-ref' || name === 'data
|
|
|
503
514
|
if (refOwnerScope.$refs) refOwnerScope.$refs[value] = el;
|
|
504
515
|
}
|
|
505
516
|
else {
|
|
517
|
+
// Manifest hydration receives the page scope for each node. A
|
|
518
|
+
// component-local ref still belongs to the node's owning scope.
|
|
519
|
+
if (refOwnerScope && refOwnerScope.$refs) refOwnerScope.$refs[value] = el;
|
|
506
520
|
if (scope.$refs) scope.$refs[value] = el;
|
|
507
521
|
if (componentScope.$refs) componentScope.$refs[value] = el;
|
|
508
522
|
}
|
|
@@ -512,7 +526,7 @@ else if (name === 'ref' || name === ':ref' || name === 'x-ref' || name === 'data
|
|
|
512
526
|
// it silently returned undefined.
|
|
513
527
|
var refTarget = refCaller && refOwnerScope
|
|
514
528
|
? refOwnerScope[value]
|
|
515
|
-
: (scope && scope[value]) || componentScope[value];
|
|
529
|
+
: (refOwnerScope && refOwnerScope[value]) || (scope && scope[value]) || componentScope[value];
|
|
516
530
|
if (refTarget && typeof refTarget === 'function' && refTarget._isSignal && typeof refTarget.set === 'function') {
|
|
517
531
|
refTarget.set(el);
|
|
518
532
|
}
|
|
@@ -570,9 +584,10 @@ else if (name === 'ref' || name === ':ref' || name === 'x-ref' || name === 'data
|
|
|
570
584
|
// Vue-style component handlers receive the emitted payload directly.
|
|
571
585
|
// Native root events still receive the Event object so server-only
|
|
572
586
|
// components can forward clicks and other browser events.
|
|
573
|
-
var
|
|
574
|
-
? event.
|
|
575
|
-
|
|
587
|
+
var emittedArgs = isForwardedComponentEvent && event instanceof CustomEvent
|
|
588
|
+
&& Array.isArray(event.__stx_emit_args) ? event.__stx_emit_args : null;
|
|
589
|
+
var handlerEvent = emittedArgs ? emittedArgs[0]
|
|
590
|
+
: isForwardedComponentEvent && event instanceof CustomEvent ? event.detail : event;
|
|
576
591
|
|
|
577
592
|
// Skip an opener click that reaches UI which just became visible in
|
|
578
593
|
// this frame. A click whose target is inside the revealed subtree is
|
|
@@ -605,7 +620,7 @@ else if (name === 'ref' || name === ':ref' || name === 'x-ref' || name === 'data
|
|
|
605
620
|
try {
|
|
606
621
|
if (!value || /^__[A-Z_]+__$/.test(value.trim())) return;
|
|
607
622
|
var shorthandFn = parseEventShorthand(value, eventCapturedScope);
|
|
608
|
-
if (shorthandFn) { shorthandFn(handlerEvent); return; }
|
|
623
|
+
if (shorthandFn) { shorthandFn.apply(null, emittedArgs || [handlerEvent]); return; }
|
|
609
624
|
// Check if any scope values are signals (x-data pattern)
|
|
610
625
|
// A derived value reads like a signal in a handler, as it does in a
|
|
611
626
|
// binding: \`pick(selectedPackage)\` passes the package. Leaving it
|
|
@@ -4,7 +4,7 @@ import type { Signal } from './signals-api';
|
|
|
4
4
|
* function closure-free: the runtime embeds its JavaScript source, with all
|
|
5
5
|
* reactive and lifecycle dependencies supplied explicitly.
|
|
6
6
|
*/
|
|
7
|
-
export declare function createModelSignal<T>(source: Signal<T>, modifiers: () => ModelModifiers, emit: (value: T) => void, options: ModelOptions<T>, cleanup: (fn: () => void) => void): ModelSignal<T>;
|
|
7
|
+
export declare function createModelSignal<T>(source: Signal<T>, modifiers: () => ModelModifiers, emit: (value: T) => void, options: ModelOptions<T>, cleanup: (fn: () => void) => void, mount?: (fn: () => void) => void): ModelSignal<T>;
|
|
8
8
|
export declare function useModel<T>(options: ModelOptions<T> & { default: T }): ModelSignal<T>;
|
|
9
9
|
export declare function useModel<T>(name: string, options: ModelOptions<T> & { default: T }): ModelSignal<T>;
|
|
10
10
|
export declare function useModel<T = unknown>(name?: string, options?: ModelOptions<T>): ModelSignal<T | undefined>;
|
package/dist/component-model.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineEmits, getCurrentInstance } from "./composition-api.js";
|
|
2
|
-
import { effect, isDerived, isSignal, onDestroy, state } from "./signals-api.js";
|
|
3
|
-
export function createModelSignal(source, modifiers, emit, options, cleanup) {
|
|
2
|
+
import { effect, isDerived, isSignal, onDestroy, onMount, state } from "./signals-api.js";
|
|
3
|
+
export function createModelSignal(source, modifiers, emit, options, cleanup, mount) {
|
|
4
4
|
let active = !0;
|
|
5
5
|
const subscriptions = new Set, read = (value) => options.get ? options.get(value) : value, model = () => read(source());
|
|
6
6
|
Object.defineProperty(model, "_isSignal", { value: !0 });
|
|
@@ -47,6 +47,9 @@ export function createModelSignal(source, modifiers, emit, options, cleanup) {
|
|
|
47
47
|
subscriptions.forEach((unsubscribe) => unsubscribe());
|
|
48
48
|
subscriptions.clear();
|
|
49
49
|
});
|
|
50
|
+
mount?.(() => {
|
|
51
|
+
active = !0;
|
|
52
|
+
});
|
|
50
53
|
return model;
|
|
51
54
|
}
|
|
52
55
|
export function useModel(nameOrOptions = "modelValue", options = {}) {
|
|
@@ -55,5 +58,5 @@ export function useModel(nameOrOptions = "modelValue", options = {}) {
|
|
|
55
58
|
source.set(value === void 0 ? opts.default : value);
|
|
56
59
|
});
|
|
57
60
|
onDestroy(stop);
|
|
58
|
-
return createModelSignal(source, () => readProp(modifierName) || {}, (value) => emit(`update:${name}`, value), opts, onDestroy);
|
|
61
|
+
return createModelSignal(source, () => readProp(modifierName) || {}, (value) => emit(`update:${name}`, value), opts, onDestroy, onMount);
|
|
59
62
|
}
|
package/dist/composition-api.js
CHANGED
|
@@ -68,11 +68,12 @@ export function defineEmits(events) {
|
|
|
68
68
|
if (element) {
|
|
69
69
|
const emittedEvents = element.__stx_component_emits ||= Object.create(null);
|
|
70
70
|
emittedEvents[event] = !0;
|
|
71
|
-
|
|
71
|
+
const emitted = Object.assign(new CustomEvent(event, {
|
|
72
72
|
detail: args.length === 1 ? args[0] : args,
|
|
73
73
|
bubbles: !0,
|
|
74
74
|
cancelable: !0
|
|
75
|
-
}));
|
|
75
|
+
}), { __stx_emit_args: args });
|
|
76
|
+
element.dispatchEvent(emitted);
|
|
76
77
|
}
|
|
77
78
|
};
|
|
78
79
|
if (instance)
|
package/dist/craft-entry.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Jr,Bo,Fo}from"./chunk-
|
|
2
|
+
import{Jr,Bo,Fo}from"./chunk-96mb3brj.js";import"./chunk-dhq80e4r.js";import"./chunk-ah9xyss2.js";import"./chunk-x552npae.js";import"./chunk-dvc15djp.js";import"./chunk-vpdx7qr3.js";import"./chunk-n4e02qdz.js";import"./chunk-6m3me7yj.js";import"./chunk-02qaqamv.js";import"./chunk-vkc51n9m.js";import"./chunk-2943qhdt.js";import"./chunk-qdyp2zqf.js";import"./chunk-sv08pd66.js";import"./chunk-117xss52.js";import{Au,Io,Pu,Iu,Oo,Xr,Do,Ou,Mo,Du,Mu,No,Lo,jo}from"./chunk-h3z9b6bw.js";import"./chunk-521pe0hb.js";import"./chunk-dm1qh2vq.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{Au as CRAFT_BRIDGE_SCRIPT,Xr as CRAFT_COMPONENTS,Ou as CRAFT_COMPONENT_RUNTIME,Do as CRAFT_COMPONENT_STYLES,Jr as NATIVE_COMPONENTS,No as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,Bo as compileToNative,Fo as createHotReloadServer,Io as generateCraftBridgeScript,V as generateCraftOptimizations,jo as getAvailableFormats,Lo as getAvailableTargets,Mu as getCraftComponents,G as getSSRCacheStats,Oo as injectCraftBridge,Pu as isCraftEnvironment,Y as prerenderForCraft,Mo as processCraftComponents,Iu as processCraftDirective,Du as registerCraftComponent,Q as renderSSR};
|
package/dist/craft.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Jr,Bo,Fo}from"./chunk-
|
|
2
|
+
import{Jr,Bo,Fo}from"./chunk-96mb3brj.js";import"./chunk-dhq80e4r.js";import"./chunk-ah9xyss2.js";import"./chunk-x552npae.js";import"./chunk-dvc15djp.js";import"./chunk-vpdx7qr3.js";import"./chunk-n4e02qdz.js";import"./chunk-6m3me7yj.js";import"./chunk-02qaqamv.js";import"./chunk-vkc51n9m.js";import"./chunk-2943qhdt.js";import"./chunk-qdyp2zqf.js";import"./chunk-sv08pd66.js";import"./chunk-117xss52.js";import{Au,Io,Pu,Iu,Oo,Xr,Do,Ou,Mo,Du,Mu,No,Lo,jo}from"./chunk-h3z9b6bw.js";import"./chunk-521pe0hb.js";import"./chunk-dm1qh2vq.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{Au as CRAFT_BRIDGE_SCRIPT,Xr as CRAFT_COMPONENTS,Ou as CRAFT_COMPONENT_RUNTIME,Do as CRAFT_COMPONENT_STYLES,Jr as NATIVE_COMPONENTS,No as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,Bo as compileToNative,Fo as createHotReloadServer,Io as generateCraftBridgeScript,V as generateCraftOptimizations,jo as getAvailableFormats,Lo as getAvailableTargets,Mu as getCraftComponents,G as getSSRCacheStats,Oo as injectCraftBridge,Pu as isCraftEnvironment,Y as prerenderForCraft,Mo as processCraftComponents,Iu as processCraftDirective,Du as registerCraftComponent,Q as renderSSR};
|
|
@@ -90,8 +90,13 @@ function areasRead(code) {
|
|
|
90
90
|
areas.add(match[1]);
|
|
91
91
|
return [...areas].sort();
|
|
92
92
|
}
|
|
93
|
-
function runtimeDocument(document) {
|
|
94
|
-
|
|
93
|
+
function runtimeDocument(document, root) {
|
|
94
|
+
const source = path.isAbsolute(document.meta.source) ? path.relative(root, document.meta.source).split(path.sep).join("/") : document.meta.source;
|
|
95
|
+
return {
|
|
96
|
+
...document,
|
|
97
|
+
script: { exports: document.script.exports, functions: [], code: "" },
|
|
98
|
+
meta: { ...document.meta, source, compiledAt: 0 }
|
|
99
|
+
};
|
|
95
100
|
}
|
|
96
101
|
export async function compileNativeBundle(options) {
|
|
97
102
|
const names = Object.keys(options.screens);
|
|
@@ -140,7 +145,7 @@ var isApp = ${appFile ? `routeName === ${JSON.stringify(NATIVE_APP_ROUTE)}` : "f
|
|
|
140
145
|
if (!isApp && routeNames.indexOf(routeName) === -1) throw new Error(['Unknown native screen:', routeName].join(' '));
|
|
141
146
|
if (isApp ? ${!withApp} : ${JSON.stringify(bundled.map(({ name }) => name))}.indexOf(routeName) === -1) throw new Error(['This bundle does not hold the native screen', routeName].join(' '));` : `var routeName = 'main';
|
|
142
147
|
var isApp = false;`, selections = bundled.map(({ name, compiled }, index) => `${index === 0 ? "if" : "else if"} (routeName === ${JSON.stringify(routed ? name : "main")}) {
|
|
143
|
-
nativeDocument = ${JSON.stringify(runtimeDocument(compiled.document))};
|
|
148
|
+
nativeDocument = ${JSON.stringify(runtimeDocument(compiled.document, root))};
|
|
144
149
|
manifest = ${JSON.stringify(compiled.manifest)};
|
|
145
150
|
}`).join(`
|
|
146
151
|
`), setups = bundled.map(({ name, compiled }, index) => `${index === 0 ? "if" : "else if"} (routeName === ${JSON.stringify(routed ? name : "main")}) {
|
|
@@ -42,4 +42,6 @@ export type TranslationDiagnosticKind = | 'unmapped-tag'
|
|
|
42
42
|
/** A value the IR's field cannot hold, so emitting it would brick the screen. */
|
|
43
43
|
| 'non-numeric-style'
|
|
44
44
|
/** A legacy virtual-list prop has no meaning in the shared-runtime tree. */
|
|
45
|
-
| 'unsupported-list-prop'
|
|
45
|
+
| 'unsupported-list-prop'
|
|
46
|
+
/** A control with no supported native interaction contract. */
|
|
47
|
+
| 'unsupported-control';
|
|
@@ -411,6 +411,11 @@ function settle(frame, diagnostics) {
|
|
|
411
411
|
return node;
|
|
412
412
|
}
|
|
413
413
|
if (node.type === "Text" && elements.length > 0) {
|
|
414
|
+
if (elements.some((child) => child.type !== "Text")) {
|
|
415
|
+
node.type = "View";
|
|
416
|
+
node.children = node.children.map((child) => typeof child === "string" ? createNode("Text", {}, {}, {}, [child]) : child);
|
|
417
|
+
return node;
|
|
418
|
+
}
|
|
414
419
|
const flattened = flattenText(node);
|
|
415
420
|
diagnostics.push({ kind: "flattened-text", tag: frame.tag });
|
|
416
421
|
node.children = flattened ? [flattened] : [];
|
|
@@ -460,8 +465,26 @@ export async function translateHtmlToIR(html, options = {}) {
|
|
|
460
465
|
if (typeof declared === "string" && NATIVE_TYPES.has(declared)) {
|
|
461
466
|
type = declared;
|
|
462
467
|
delete props["data-native"];
|
|
463
|
-
} else
|
|
468
|
+
} else {
|
|
464
469
|
type = BOX_ONLY.has(tag) ? "View" : mapToNativeComponent(tag);
|
|
470
|
+
if (tag === "input") {
|
|
471
|
+
const inputType = String(props.type ?? "text").toLowerCase();
|
|
472
|
+
if (inputType === "checkbox") {
|
|
473
|
+
type = "Checkbox";
|
|
474
|
+
props.formValue = props.value ?? "on";
|
|
475
|
+
props.checked = props.checked === "" || props.checked === !0 || props.checked === "true";
|
|
476
|
+
props.value = props.checked;
|
|
477
|
+
} else if (inputType === "hidden") {
|
|
478
|
+
type = "View";
|
|
479
|
+
style.display = "none";
|
|
480
|
+
inline.display = "none";
|
|
481
|
+
} else if (inputType === "radio") {
|
|
482
|
+
type = "View";
|
|
483
|
+
props.accessibilityRole = "radio";
|
|
484
|
+
diagnostics.push({ kind: "unsupported-control", tag, name: "input:radio" });
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
}
|
|
465
488
|
if (type === tag && !NATIVE_TYPES.has(type) && !DROP_SUBTREE.has(tag) && !UNWRAP.has(tag) && !seenUnmapped.has(tag)) {
|
|
466
489
|
seenUnmapped.add(tag);
|
|
467
490
|
diagnostics.push({ kind: "unmapped-tag", tag });
|
|
@@ -470,6 +493,10 @@ export async function translateHtmlToIR(html, options = {}) {
|
|
|
470
493
|
seenUnmapped.add(`drop:${tag}`);
|
|
471
494
|
diagnostics.push({ kind: "dropped-subtree", tag });
|
|
472
495
|
}
|
|
496
|
+
if (tag === "form")
|
|
497
|
+
props["data-stx-form"] = !0;
|
|
498
|
+
if (tag === "button" && props.type === void 0)
|
|
499
|
+
props.type = "submit";
|
|
473
500
|
if (type === "Video" && props.source === void 0 && props.src !== void 0) {
|
|
474
501
|
props.source = props.src;
|
|
475
502
|
delete props.src;
|
|
@@ -10,6 +10,7 @@ function createBindingNode(id, type, bindings, connected = !0, classes = "", onC
|
|
|
10
10
|
attributes.push({ name: "class", value: classes });
|
|
11
11
|
const node = {
|
|
12
12
|
__stxId: id,
|
|
13
|
+
__stxScope: void 0,
|
|
13
14
|
nodeType: 1,
|
|
14
15
|
get className() {
|
|
15
16
|
return node.getAttribute("class") ?? "";
|
|
@@ -42,6 +43,8 @@ function createBindingNode(id, type, bindings, connected = !0, classes = "", onC
|
|
|
42
43
|
return attributes.find((attribute) => attribute.name === name)?.value ?? null;
|
|
43
44
|
},
|
|
44
45
|
setAttribute(name, value) {
|
|
46
|
+
if (name === "data-stx-scope")
|
|
47
|
+
node.__stxScope = String(value);
|
|
45
48
|
const existing = attributes.find((attribute) => attribute.name === name);
|
|
46
49
|
if (existing)
|
|
47
50
|
existing.value = String(value);
|
|
@@ -51,6 +54,8 @@ function createBindingNode(id, type, bindings, connected = !0, classes = "", onC
|
|
|
51
54
|
onClassChange?.(String(value));
|
|
52
55
|
},
|
|
53
56
|
removeAttribute(name) {
|
|
57
|
+
if (name === "data-stx-scope")
|
|
58
|
+
node.__stxScope = void 0;
|
|
54
59
|
const index = attributes.findIndex((attribute) => attribute.name === name);
|
|
55
60
|
if (index !== -1)
|
|
56
61
|
attributes.splice(index, 1);
|
|
@@ -99,6 +104,13 @@ export function materializeNativeBindingTree(document, manifest, host) {
|
|
|
99
104
|
if (!runtimeBindings.some((binding) => binding.name.replace(/^[:@]/, "") === name))
|
|
100
105
|
runtimeBindings.push({ name: `:${name}`, value, kind: "attr" });
|
|
101
106
|
const node = createBindingNode(id, source.type, runtimeBindings, !0, source._classes, (value) => host.setAttribute(node, "class", value));
|
|
107
|
+
if (source.type === "Checkbox" && source.props.type === "checkbox")
|
|
108
|
+
node.tagName = "INPUT";
|
|
109
|
+
for (const [name, value] of Object.entries(source.props)) {
|
|
110
|
+
if (value === void 0 || value === null || name === "__stxId")
|
|
111
|
+
continue;
|
|
112
|
+
node.setAttribute(name, typeof value === "object" ? JSON.stringify(value) : String(value));
|
|
113
|
+
}
|
|
102
114
|
source.id = id;
|
|
103
115
|
source.props.__stxId = id;
|
|
104
116
|
node.parentNode = parent;
|
|
@@ -184,7 +184,7 @@ export function installCraftBridge(protocol, nativeBridge, target = globalThis,
|
|
|
184
184
|
delete: (key) => request("SecureStorage", "remove", [key]),
|
|
185
185
|
clear: () => request("SecureStorage", "clear", [])
|
|
186
186
|
});
|
|
187
|
-
const sessionKey = String(craft.session?.key || nativeBridge.sessionTokenKey || "auth.token");
|
|
187
|
+
const sessionKey = String(craft.session?.key || nativeBridge.sessionTokenKey || "auth.token"), supportsSessionEvents = craft.session?.supportsEvents === !0 || typeof nativeBridge.sessionTokenKey === "string" && nativeBridge.sessionTokenKey.length > 0;
|
|
188
188
|
craft.session = Object.assign({
|
|
189
189
|
token: () => {
|
|
190
190
|
const value = craft.secureStorage.getSync(sessionKey);
|
|
@@ -192,6 +192,7 @@ export function installCraftBridge(protocol, nativeBridge, target = globalThis,
|
|
|
192
192
|
}
|
|
193
193
|
}, craft.session || {}, {
|
|
194
194
|
key: sessionKey,
|
|
195
|
+
supportsEvents: supportsSessionEvents,
|
|
195
196
|
onChange: (callback) => protocol.on("SESSION_CHANGED", ({ payload }) => {
|
|
196
197
|
if (payload?.key && payload.key !== sessionKey)
|
|
197
198
|
return;
|
|
@@ -21,6 +21,8 @@ export declare function abortError(reason?: unknown): Error;
|
|
|
21
21
|
export declare function nativeAnimationFrame(target: AnyRecord, callback: (time: number) => void): unknown;
|
|
22
22
|
/** Install only the browser-shaped globals the shared runtime needs to boot in JSC. */
|
|
23
23
|
export declare function installJSCGlobals(target?: AnyRecord): void;
|
|
24
|
+
/** The native host supplies successful controls, not a browser DOM tree. */
|
|
25
|
+
export declare const NATIVE_FORM_ENTRIES: symbol;
|
|
24
26
|
/** A display's frame, in milliseconds: 60 a second. */
|
|
25
27
|
export declare const NATIVE_FRAME_MS: number;
|
|
26
28
|
/**
|
|
@@ -40,12 +42,17 @@ declare class NativeEvent {
|
|
|
40
42
|
type: string;
|
|
41
43
|
detail: unknown;
|
|
42
44
|
target: unknown;
|
|
45
|
+
currentTarget: unknown;
|
|
46
|
+
bubbles: boolean;
|
|
47
|
+
cancelable: boolean;
|
|
48
|
+
defaultPrevented: boolean;
|
|
49
|
+
cancelBubble: boolean;
|
|
43
50
|
key: string;
|
|
44
51
|
ctrlKey: boolean;
|
|
45
52
|
altKey: boolean;
|
|
46
53
|
shiftKey: boolean;
|
|
47
54
|
metaKey: boolean;
|
|
48
|
-
constructor(type: string, options?: { detail?: unknown });
|
|
55
|
+
constructor(type: string, options?: { detail?: unknown, bubbles?: boolean, cancelable?: boolean });
|
|
49
56
|
preventDefault(): void;
|
|
50
57
|
stopPropagation(): void;
|
|
51
58
|
}
|
|
@@ -127,8 +134,8 @@ declare class NativeURL {
|
|
|
127
134
|
* text and the files `craft.files` made (a `File` on the page). `fetch` on a
|
|
128
135
|
* native screen sends it as multipart/form-data, built by the host, so code
|
|
129
136
|
* shared with the page posts a photo the same way on both
|
|
130
|
-
* (`form.append('photo', file)`).
|
|
131
|
-
*
|
|
137
|
+
* (`form.append('photo', file)`). Collection is available without device
|
|
138
|
+
* services; sending multipart bodies remains gated by the files capability.
|
|
132
139
|
*/
|
|
133
140
|
export declare class NativeFormData {
|
|
134
141
|
constructor(form?: unknown);
|
|
@@ -2,6 +2,11 @@ class NativeEvent {
|
|
|
2
2
|
type;
|
|
3
3
|
detail;
|
|
4
4
|
target = null;
|
|
5
|
+
currentTarget = null;
|
|
6
|
+
bubbles;
|
|
7
|
+
cancelable;
|
|
8
|
+
defaultPrevented = !1;
|
|
9
|
+
cancelBubble = !1;
|
|
5
10
|
key = "";
|
|
6
11
|
ctrlKey = !1;
|
|
7
12
|
altKey = !1;
|
|
@@ -10,9 +15,16 @@ class NativeEvent {
|
|
|
10
15
|
constructor(type, options = {}) {
|
|
11
16
|
this.type = type;
|
|
12
17
|
this.detail = options.detail;
|
|
18
|
+
this.bubbles = options.bubbles ?? !1;
|
|
19
|
+
this.cancelable = options.cancelable ?? !1;
|
|
20
|
+
}
|
|
21
|
+
preventDefault() {
|
|
22
|
+
if (this.cancelable)
|
|
23
|
+
this.defaultPrevented = !0;
|
|
24
|
+
}
|
|
25
|
+
stopPropagation() {
|
|
26
|
+
this.cancelBubble = !0;
|
|
13
27
|
}
|
|
14
|
-
preventDefault() {}
|
|
15
|
-
stopPropagation() {}
|
|
16
28
|
}
|
|
17
29
|
|
|
18
30
|
class NativeTextEncoder {
|
|
@@ -478,12 +490,18 @@ export { nativeAtob, nativeBtoa };
|
|
|
478
490
|
export function isNativeFile(value) {
|
|
479
491
|
return !!value && typeof value === "object" && typeof value.path === "string" && typeof value.name === "string";
|
|
480
492
|
}
|
|
493
|
+
export const NATIVE_FORM_ENTRIES = Symbol.for("stx.native.form.entries");
|
|
481
494
|
|
|
482
495
|
export class NativeFormData {
|
|
483
496
|
list = [];
|
|
484
497
|
constructor(form) {
|
|
485
|
-
if (form
|
|
486
|
-
|
|
498
|
+
if (form === void 0)
|
|
499
|
+
return;
|
|
500
|
+
const read = form && form[NATIVE_FORM_ENTRIES];
|
|
501
|
+
if (typeof read !== "function")
|
|
502
|
+
throw TypeError("FormData requires a native form handle, or no argument when built with append()");
|
|
503
|
+
for (const [name, value] of read.call(form))
|
|
504
|
+
this.append(name, value);
|
|
487
505
|
}
|
|
488
506
|
append(name, value, filename) {
|
|
489
507
|
this.list.push([String(name), formValue(value, filename)]);
|
|
@@ -622,6 +640,7 @@ export function installJSCGlobals(target = globalThis) {
|
|
|
622
640
|
target.Node ??= { ELEMENT_NODE: 1, TEXT_NODE: 3, COMMENT_NODE: 8 };
|
|
623
641
|
target.Event ??= NativeEvent;
|
|
624
642
|
target.CustomEvent ??= NativeEvent;
|
|
643
|
+
target.FormData ??= NativeFormData;
|
|
625
644
|
target.addEventListener ??= addEventListener;
|
|
626
645
|
target.removeEventListener ??= removeEventListener;
|
|
627
646
|
target.dispatchEvent ??= dispatchEvent;
|