@stacksjs/stx 0.2.795 → 0.2.798
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-y64f5t74.js → chunk-0beyn8ak.js} +5 -5
- package/dist/{chunk-jmbh26gv.js → chunk-0gsq8gps.js} +1 -1
- package/dist/chunk-0xnvjw7s.js +2 -0
- package/dist/chunk-1wyccmsr.js +2 -0
- package/dist/{chunk-4s0ye933.js → chunk-20yz8bjp.js} +2 -2
- package/dist/{chunk-bzhzp4f4.js → chunk-2ws2qe1k.js} +2 -2
- package/dist/{chunk-2bvaakcv.js → chunk-2z2bq2at.js} +3 -3
- package/dist/chunk-31qjy9xr.js +2 -0
- package/dist/chunk-33devn0s.js +2 -0
- package/dist/{chunk-baj6w8ja.js → chunk-33vr7x2t.js} +3 -3
- package/dist/chunk-33wpv2n1.js +2 -0
- package/dist/{chunk-aksrh8je.js → chunk-3mby4nes.js} +3 -3
- package/dist/chunk-3p5gxc6t.js +2 -0
- package/dist/{chunk-88acqv2r.js → chunk-3x598qjt.js} +4 -4
- package/dist/chunk-4hgz9dkv.js +2 -0
- package/dist/{chunk-7k6hd10j.js → chunk-4sesw88b.js} +5 -5
- package/dist/{chunk-624xpap6.js → chunk-4v50nafp.js} +13 -13
- package/dist/chunk-5kc9kjaa.js +2 -0
- package/dist/{chunk-2e5tvryz.js → chunk-5wwcgze3.js} +2 -2
- package/dist/chunk-5xd53dwe.js +2 -0
- package/dist/chunk-5y6518h8.js +2 -0
- package/dist/chunk-5y77pe7b.js +2 -0
- package/dist/chunk-6a97a9wk.js +2 -0
- package/dist/{chunk-xqjat573.js → chunk-6b5zhtb3.js} +2 -2
- package/dist/chunk-6hre8cg4.js +2 -0
- package/dist/{chunk-vpzdqbw7.js → chunk-6m4y5dh5.js} +6 -6
- package/dist/chunk-6pyweb05.js +2 -0
- package/dist/chunk-6tp7ys77.js +2 -0
- package/dist/chunk-6zxzr20d.js +2 -0
- package/dist/chunk-75ctpxr3.js +2 -0
- package/dist/{chunk-tmfrq4nq.js → chunk-7bxnjr3b.js} +7 -7
- package/dist/chunk-7gw96jpj.js +2 -0
- package/dist/chunk-7m4eesp0.js +2 -0
- package/dist/chunk-7na8bets.js +2 -0
- package/dist/{chunk-6s9bk98p.js → chunk-7yb82rm6.js} +2 -2
- package/dist/{chunk-dstzvtvk.js → chunk-810r5dk3.js} +3 -3
- package/dist/{chunk-njk5db1q.js → chunk-89jn2jmf.js} +4 -4
- package/dist/{chunk-nyer6v3y.js → chunk-8bzq2z0m.js} +5 -5
- package/dist/chunk-8k2n6abg.js +2 -0
- package/dist/chunk-8vqs94f3.js +2 -0
- package/dist/{chunk-3em44jbm.js → chunk-91htcq62.js} +2 -2
- package/dist/chunk-9736003n.js +2 -0
- package/dist/{chunk-p3ej3954.js → chunk-9b6896tb.js} +2 -2
- package/dist/{chunk-pnddmgjf.js → chunk-9k6tza24.js} +7 -7
- package/dist/chunk-9w33k6f7.js +2 -0
- package/dist/{chunk-g4n0bjfb.js → chunk-9x62j5f0.js} +10 -10
- package/dist/{chunk-1q16p7t2.js → chunk-a1ba9d2r.js} +5 -5
- package/dist/{chunk-8t8e75xm.js → chunk-a20wq8wf.js} +4 -4
- package/dist/{chunk-7y73txmp.js → chunk-a3xqfyb6.js} +2 -2
- package/dist/chunk-ag8j9ec2.js +2 -0
- package/dist/chunk-ak15dt1a.js +2 -0
- package/dist/{chunk-qnxctfdf.js → chunk-akcyaxwv.js} +2 -2
- package/dist/{chunk-f4j7nsj1.js → chunk-aw6369cx.js} +1 -1
- package/dist/{chunk-ennzzth4.js → chunk-b5ck6epd.js} +17 -17
- package/dist/chunk-b98743ja.js +2 -0
- package/dist/{chunk-3vpgr6nk.js → chunk-b9d70mgr.js} +3 -3
- package/dist/chunk-bskxswmn.js +2 -0
- package/dist/chunk-bv5h4etd.js +2 -0
- package/dist/chunk-c7x3bmvs.js +2 -0
- package/dist/{chunk-12jjf2me.js → chunk-c84pxd2k.js} +2 -2
- package/dist/chunk-camm2hcx.js +2 -0
- package/dist/chunk-cd2wda5c.js +2 -0
- package/dist/chunk-cv6pqg85.js +2 -0
- package/dist/chunk-cy0mab8y.js +2 -0
- package/dist/chunk-d554f2fj.js +2 -0
- package/dist/chunk-dd1vqndp.js +2 -0
- package/dist/{chunk-cfbpvm5e.js → chunk-ddhkhhc7.js} +2 -2
- package/dist/{chunk-thpwk6ya.js → chunk-dsnggn3g.js} +2 -2
- package/dist/chunk-e14v1q9c.js +2 -0
- package/dist/{chunk-hp10khyy.js → chunk-e37g6ezw.js} +20 -20
- package/dist/chunk-e3xw2bzh.js +2 -0
- package/dist/{chunk-pm8a4kdf.js → chunk-eegb7f3t.js} +5 -5
- package/dist/chunk-eeztqt6f.js +2 -0
- package/dist/{chunk-7s1kerhs.js → chunk-ef3w5thv.js} +2 -2
- package/dist/chunk-eh528njb.js +2 -0
- package/dist/{chunk-wzwfbehm.js → chunk-en0wry1c.js} +11 -11
- package/dist/chunk-eszpqrxy.js +2 -0
- package/dist/{chunk-dxe94pwy.js → chunk-fp0ew9n4.js} +4 -4
- package/dist/chunk-fyxkzs9c.js +2 -0
- package/dist/{chunk-hwcfgs3e.js → chunk-gjf8cjdt.js} +3 -3
- package/dist/{chunk-8zf87cc5.js → chunk-gvnfb6s2.js} +2 -2
- package/dist/{chunk-fcqxa38q.js → chunk-gzfvj15b.js} +1 -1
- package/dist/chunk-hb4jkdfr.js +2 -0
- package/dist/{chunk-r3a15pax.js → chunk-hg9mwgnr.js} +1 -1
- package/dist/{chunk-reb7rddz.js → chunk-hmt0vqhb.js} +1 -1
- package/dist/{chunk-r1vkk7qp.js → chunk-hp9e8nz6.js} +2 -2
- package/dist/chunk-hzps1xya.js +2 -0
- package/dist/{chunk-4p5g7v9g.js → chunk-j3st59hv.js} +2 -2
- package/dist/{chunk-zva4a7xq.js → chunk-jde0shn4.js} +2 -2
- package/dist/{chunk-2xprqx2v.js → chunk-jeprxn45.js} +6 -6
- package/dist/{chunk-d50vw81s.js → chunk-jt0yn7ab.js} +4 -4
- package/dist/chunk-k8gpvg0w.js +2 -0
- package/dist/chunk-kgn911k7.js +2 -0
- package/dist/{chunk-1hq3y7ss.js → chunk-kj8dvzpc.js} +2 -2
- package/dist/chunk-km8c0j9g.js +2 -0
- package/dist/{chunk-ayd635jf.js → chunk-mj3hzy1e.js} +5 -5
- package/dist/{chunk-9jcqbgq9.js → chunk-nw0v655w.js} +6 -6
- package/dist/{chunk-ata5wp2m.js → chunk-p1mghe1h.js} +6 -6
- package/dist/{chunk-rdymnn2t.js → chunk-p2a6dwj6.js} +6 -6
- package/dist/chunk-pw89m3re.js +2 -0
- package/dist/chunk-q38vjqv2.js +2 -0
- package/dist/{chunk-9b9tvhmh.js → chunk-q3ma4khe.js} +5 -5
- package/dist/{chunk-3f8w1x6w.js → chunk-q7q9e0gj.js} +7 -7
- package/dist/{chunk-7y29q1ng.js → chunk-qef2vv0m.js} +2 -2
- package/dist/{chunk-6wpwpk3c.js → chunk-qjbpa1n4.js} +4 -4
- package/dist/{chunk-y2jqx5k4.js → chunk-qm2wmqre.js} +1 -1
- package/dist/{chunk-53v4cby3.js → chunk-qpvwxppw.js} +4 -4
- package/dist/{chunk-427mhgje.js → chunk-qxt6hdat.js} +1 -1
- package/dist/{chunk-w6e30qkz.js → chunk-r6d6jphq.js} +20 -20
- package/dist/{chunk-538d185r.js → chunk-rbv6fxtx.js} +2 -2
- package/dist/chunk-rrketemm.js +2 -0
- package/dist/chunk-rwys552r.js +3 -0
- package/dist/chunk-s0bx4gjh.js +2 -0
- package/dist/{chunk-90zswh9v.js → chunk-s14jcqdf.js} +4 -4
- package/dist/{chunk-bwf8b4e4.js → chunk-s3fmmm98.js} +3 -3
- package/dist/chunk-s8s7b7rv.js +2 -0
- package/dist/{chunk-vkn133cs.js → chunk-s9b6abkb.js} +2 -2
- package/dist/{chunk-w76cve9j.js → chunk-sprgkk9j.js} +31 -31
- package/dist/chunk-sywqa4da.js +2 -0
- package/dist/{chunk-b58n1kfe.js → chunk-t65tn8ee.js} +2 -2
- package/dist/{chunk-ka8sk5qa.js → chunk-trjhz9d9.js} +1 -1
- package/dist/chunk-txrbz95y.js +2 -0
- package/dist/{chunk-yjnaqahd.js → chunk-v9hm1xv6.js} +5 -5
- package/dist/{chunk-c5vzr1va.js → chunk-w0zayhmg.js} +2 -2
- package/dist/{chunk-h656zg6k.js → chunk-w58bnt44.js} +3 -3
- package/dist/chunk-w7681v48.js +2 -0
- package/dist/chunk-w7wz670a.js +2 -0
- package/dist/{chunk-zmr0pvcd.js → chunk-wp6bdac7.js} +59 -59
- package/dist/{chunk-cepctq7e.js → chunk-x8ckxemg.js} +23 -23
- package/dist/{chunk-mcj5qtpp.js → chunk-xa36escd.js} +3 -3
- package/dist/{chunk-wa7fzgw7.js → chunk-xskswvef.js} +4 -4
- package/dist/chunk-xzgtdcbg.js +2 -0
- package/dist/{chunk-7xs45trj.js → chunk-y9bj3566.js} +2 -2
- package/dist/chunk-yfdb3x3p.js +2 -0
- package/dist/{chunk-azqf0ps0.js → chunk-yv4dwdhc.js} +2 -2
- package/dist/{chunk-m081078c.js → chunk-z1aq59qj.js} +3 -3
- package/dist/{chunk-axjfaere.js → chunk-z1fb5k3h.js} +127 -40
- package/dist/{chunk-tqvw1673.js → chunk-z8wfvqbk.js} +5 -5
- package/dist/chunk-z9a80qqg.js +2 -0
- package/dist/chunk-za5kx15m.js +2 -0
- package/dist/{chunk-hnbx1t3t.js → chunk-zbv8e4rq.js} +2 -2
- package/dist/{chunk-sphc7xzx.js → chunk-znx5m1jv.js} +1 -1
- package/dist/{chunk-zv3zpmv1.js → chunk-zqsacq3r.js} +1 -1
- package/dist/{chunk-ectx5ar9.js → chunk-zsy145ac.js} +3 -3
- package/dist/{chunk-x8ghjw9b.js → chunk-zx8tnhfr.js} +3 -3
- package/dist/cli.js +18 -18
- package/dist/client/signals-authoring-runtime.js +4 -1
- package/dist/client/signals-handler-runtime.js +25 -4
- package/dist/client/signals-helpers-runtime.js +12 -0
- package/dist/client/signals-native-row-runtime.js +58 -23
- package/dist/client/signals-pipe-runtime.js +16 -0
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/native/compiler/inline-style.js +91 -39
- package/dist/native/runtime/native-host.js +138 -17
- package/dist/native-build.js +2 -23
- package/dist/pwa.js +3 -3
- package/dist/ssg.js +5 -5
- package/package.json +6 -6
- package/dist/chunk-027hdpgv.js +0 -2
- package/dist/chunk-054h7ktz.js +0 -2
- package/dist/chunk-09nyt9c5.js +0 -2
- package/dist/chunk-0d3ncyqh.js +0 -2
- package/dist/chunk-1yew6rw9.js +0 -2
- package/dist/chunk-211kxm18.js +0 -2
- package/dist/chunk-26y92p8r.js +0 -2
- package/dist/chunk-3ep9h16p.js +0 -2
- package/dist/chunk-49tn6yst.js +0 -2
- package/dist/chunk-4b7dwwn6.js +0 -2
- package/dist/chunk-4ncbq4bx.js +0 -2
- package/dist/chunk-4srnxp3b.js +0 -2
- package/dist/chunk-6z4bza9z.js +0 -2
- package/dist/chunk-75y9heas.js +0 -2
- package/dist/chunk-7ckdvsmj.js +0 -3
- package/dist/chunk-8w1wxr96.js +0 -2
- package/dist/chunk-98kjk52z.js +0 -2
- package/dist/chunk-9sea317f.js +0 -2
- package/dist/chunk-9tpv4cg7.js +0 -2
- package/dist/chunk-9wmjmas8.js +0 -2
- package/dist/chunk-ak10vygz.js +0 -2
- package/dist/chunk-axq3c7cb.js +0 -2
- package/dist/chunk-c5trhqpg.js +0 -2
- package/dist/chunk-c692kj5v.js +0 -2
- package/dist/chunk-cfr7cd88.js +0 -2
- package/dist/chunk-dsh5q9bg.js +0 -2
- package/dist/chunk-emnphnz7.js +0 -2
- package/dist/chunk-epcdgn78.js +0 -2
- package/dist/chunk-etegf4zj.js +0 -2
- package/dist/chunk-ewzdsksb.js +0 -2
- package/dist/chunk-ey8bgg6x.js +0 -2
- package/dist/chunk-f03sg8b0.js +0 -2
- package/dist/chunk-gf04pgaa.js +0 -2
- package/dist/chunk-ghn8vhet.js +0 -2
- package/dist/chunk-gywp6kd8.js +0 -2
- package/dist/chunk-k6sjqb7g.js +0 -2
- package/dist/chunk-me71d5w5.js +0 -2
- package/dist/chunk-nvytej81.js +0 -2
- package/dist/chunk-p1txw41y.js +0 -2
- package/dist/chunk-p8gekf4b.js +0 -2
- package/dist/chunk-px0qsd38.js +0 -2
- package/dist/chunk-qr23snrp.js +0 -2
- package/dist/chunk-s151a2dj.js +0 -2
- package/dist/chunk-sqettc34.js +0 -2
- package/dist/chunk-srgbv05n.js +0 -2
- package/dist/chunk-t0d4rsfx.js +0 -2
- package/dist/chunk-t0k0yk24.js +0 -2
- package/dist/chunk-tdcgskyy.js +0 -2
- package/dist/chunk-te3hr6d7.js +0 -2
- package/dist/chunk-tes8fdv6.js +0 -2
- package/dist/chunk-v6j5vkce.js +0 -2
- package/dist/chunk-vmp876q6.js +0 -2
- package/dist/chunk-vwp5fchy.js +0 -2
- package/dist/chunk-wes5fdpe.js +0 -2
- package/dist/chunk-wfnfb4fr.js +0 -2
- package/dist/chunk-wfrqwtar.js +0 -2
- package/dist/chunk-xbhb8102.js +0 -2
- package/dist/chunk-xv4paxmt.js +0 -2
- package/dist/chunk-yeaqebnd.js +0 -2
- package/dist/chunk-yj20tq3s.js +0 -2
- package/dist/chunk-yjm7c78z.js +0 -2
|
@@ -11,6 +11,10 @@ export const SIGNALS_NATIVE_ROW_RUNTIME = ` // ================================
|
|
|
11
11
|
|
|
12
12
|
function __stxAlwaysVisible() { return true; }
|
|
13
13
|
|
|
14
|
+
// What planning throws for a template it leaves to the generic path: one
|
|
15
|
+
// object, not an Error with a stack to capture for every refusal.
|
|
16
|
+
var ROW_UNPLANNED = { unplanned: true };
|
|
17
|
+
|
|
14
18
|
// A plan for rows cloned from \`template\`, or null where the generic path
|
|
15
19
|
// has to make them.
|
|
16
20
|
function planNativeRow(template) {
|
|
@@ -48,14 +52,13 @@ export const SIGNALS_NATIVE_ROW_RUNTIME = ` // ================================
|
|
|
48
52
|
: 'return ' + raw;
|
|
49
53
|
var source = kind === 'attr' || kind === 'text' || kind === 'if' ? expr : raw;
|
|
50
54
|
var group = kind === 'prop' ? plan.prop : plan.eval;
|
|
51
|
-
if (parsePipeExpression(source, {}) !== null) throw
|
|
52
|
-
if (plan.component && raw.indexOf(plan.scopeId) !== -1) throw
|
|
55
|
+
if (parsePipeExpression(source, {}) !== null) throw ROW_UNPLANNED;
|
|
56
|
+
if (plan.component && raw.indexOf(plan.scopeId) !== -1) throw ROW_UNPLANNED;
|
|
53
57
|
// The names the expression can read: not the words of its quoted strings
|
|
54
58
|
// (a class list in a ternary) nor keywords, which every row would
|
|
55
59
|
// otherwise look up in its scope for nothing.
|
|
56
|
-
var
|
|
57
|
-
|
|
58
|
-
});
|
|
60
|
+
var unquoted = source.indexOf("'") === -1 && source.indexOf('"') === -1 ? source : source.replace(__STX_QUOTED, ' ');
|
|
61
|
+
var names = __stxNamesIn(unquoted).filter(function(k) { return !__STX_KEYWORDS[k]; });
|
|
59
62
|
for (var i = 0; i < names.length; i++) {
|
|
60
63
|
if (group.nameIndex[names[i]] === undefined) {
|
|
61
64
|
group.nameIndex[names[i]] = group.names.length;
|
|
@@ -70,8 +73,8 @@ export const SIGNALS_NATIVE_ROW_RUNTIME = ` // ================================
|
|
|
70
73
|
// One element of the template: its bindings, the attributes a row's copy
|
|
71
74
|
// keeps, and its children. Throws where the template needs the generic path;
|
|
72
75
|
// returns { generic: true } for an :if branch whose content does.
|
|
73
|
-
function planRowNode(plan, tmpl, isRoot, inBranch) {
|
|
74
|
-
var node = { tmpl: tmpl, attrs: [], ops: [], children: [], ifSite: null, generic: false, inert: false, remap: [] };
|
|
76
|
+
function planRowNode(plan, tmpl, isRoot, inBranch, gated) {
|
|
77
|
+
var node = { tmpl: tmpl, attrs: [], ops: [], children: [], ifSite: null, generic: false, inert: false, remap: [], gated: !!(gated || inBranch) };
|
|
75
78
|
var attrs = getElementAttributes(tmpl);
|
|
76
79
|
var parentEvents = __stxWords(tmpl.getAttribute('data-stx-parent-events') || '');
|
|
77
80
|
var parentBindings = isRoot && plan.component ? __stxWords(tmpl.getAttribute('data-stx-parent-bindings') || '') : [];
|
|
@@ -91,22 +94,23 @@ export const SIGNALS_NATIVE_ROW_RUNTIME = ` // ================================
|
|
|
91
94
|
delete deferredProps[propName];
|
|
92
95
|
}
|
|
93
96
|
}
|
|
97
|
+
if (getElseAttrInfo(tmpl)) throw ROW_UNPLANNED;
|
|
94
98
|
var generic = false;
|
|
95
99
|
for (var i = 0; i < attrs.length; i++) {
|
|
96
100
|
var name = attrs[i].name;
|
|
97
101
|
var value = attrs[i].value;
|
|
98
102
|
if (!name) continue;
|
|
99
103
|
if (name === ':if' || name === '@if') {
|
|
100
|
-
if (isRoot) throw
|
|
101
|
-
if (getElseAttrInfo(tmpl.nextElementSibling)) throw
|
|
104
|
+
if (isRoot) throw ROW_UNPLANNED;
|
|
105
|
+
if (getElseAttrInfo(tmpl.nextElementSibling)) throw ROW_UNPLANNED;
|
|
102
106
|
node.ifSite = planRowSite(plan, value, 'if');
|
|
103
107
|
continue;
|
|
104
108
|
}
|
|
105
|
-
if (name === 'x-if'
|
|
106
|
-
if ((name === ':for' || name === '@for' || name === 'x-for') && isForDirectiveExpression(value)) throw
|
|
109
|
+
if (name === 'x-if') throw ROW_UNPLANNED;
|
|
110
|
+
if ((name === ':for' || name === '@for' || name === 'x-for') && isForDirectiveExpression(value)) throw ROW_UNPLANNED;
|
|
107
111
|
if (name === 'x-cloak') continue;
|
|
108
112
|
if (name === 'data-stx-scope' || name === 'data-stx-template-scope') {
|
|
109
|
-
if (!isRoot) throw
|
|
113
|
+
if (!isRoot) throw ROW_UNPLANNED;
|
|
110
114
|
continue;
|
|
111
115
|
}
|
|
112
116
|
if (__STX_ROW_GENERIC_ATTRS[name] || name.startsWith('::') || name.startsWith('x-') || name.startsWith('@bind:')) { generic = true; continue; }
|
|
@@ -135,7 +139,7 @@ export const SIGNALS_NATIVE_ROW_RUNTIME = ` // ================================
|
|
|
135
139
|
var parts = name.slice(1).split('.');
|
|
136
140
|
var eventName = parentEvents.find(function(event) { return event.toLowerCase() === parts[0].toLowerCase(); }) || parts[0];
|
|
137
141
|
if (__STX_ROW_SKIPPED_EVENTS[eventName]) { generic = true; continue; }
|
|
138
|
-
if (plan.component && value.indexOf(plan.scopeId) !== -1) throw
|
|
142
|
+
if (plan.component && value.indexOf(plan.scopeId) !== -1) throw ROW_UNPLANNED;
|
|
139
143
|
node.ops.push({
|
|
140
144
|
kind: 'event',
|
|
141
145
|
eventName: eventName,
|
|
@@ -154,15 +158,15 @@ export const SIGNALS_NATIVE_ROW_RUNTIME = ` // ================================
|
|
|
154
158
|
node.attrs.push(attrs[i]);
|
|
155
159
|
}
|
|
156
160
|
if (generic) {
|
|
157
|
-
if (!inBranch || !node.ifSite) throw
|
|
161
|
+
if (!inBranch || !node.ifSite) throw ROW_UNPLANNED;
|
|
158
162
|
return { tmpl: tmpl, generic: true, ifSite: node.ifSite };
|
|
159
163
|
}
|
|
160
164
|
var kids = tmpl.childNodes || [];
|
|
161
165
|
for (var k = 0; k < kids.length; k++) {
|
|
162
166
|
var child = kids[k];
|
|
163
|
-
if (child.nodeType !== 1 || child.tagName === 'SCRIPT' || child.tagName === 'TEMPLATE' || child.__stx_scope) throw
|
|
167
|
+
if (child.nodeType !== 1 || child.tagName === 'SCRIPT' || child.tagName === 'TEMPLATE' || child.__stx_scope) throw ROW_UNPLANNED;
|
|
164
168
|
var hasIf = child.hasAttribute(':if') || child.hasAttribute('@if');
|
|
165
|
-
node.children.push(planRowNode(plan, child, false, hasIf));
|
|
169
|
+
node.children.push(planRowNode(plan, child, false, hasIf, node.gated));
|
|
166
170
|
}
|
|
167
171
|
return node;
|
|
168
172
|
}
|
|
@@ -171,10 +175,29 @@ export const SIGNALS_NATIVE_ROW_RUNTIME = ` // ================================
|
|
|
171
175
|
// compiled for that answer. Rows of one loop nearly always share one.
|
|
172
176
|
function rowShape(group, own, layers) {
|
|
173
177
|
var names = group.names;
|
|
178
|
+
var stack = own[__STX_LAYERS];
|
|
179
|
+
// A row's scope is its loop's layers (the same objects for every row)
|
|
180
|
+
// and a few of its own (its item, its component's variables), which hold
|
|
181
|
+
// the same names from row to row. When this row's are the last row's or
|
|
182
|
+
// hold the same names, every name lives where it did: nothing to look up.
|
|
183
|
+
var last = group.last;
|
|
184
|
+
if (last && stack.length === last.stack.length && own[__STX_HIDDEN] === undefined && Object.keys(own).length === 0) {
|
|
185
|
+
var same = true;
|
|
186
|
+
for (var j = 0; j < stack.length && same; j++) {
|
|
187
|
+
if (stack[j] !== last.stack[j]) same = Object.keys(stack[j]).join('\x01') === last.names[j];
|
|
188
|
+
}
|
|
189
|
+
if (same) {
|
|
190
|
+
for (var n = 0; n < names.length; n++) layers[n] = last.at[n] < 0 ? null : stack[last.at[n]];
|
|
191
|
+
last.stack = stack;
|
|
192
|
+
return last.shape;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
174
195
|
var signature = '';
|
|
196
|
+
var at = new Array(names.length);
|
|
175
197
|
for (var i = 0; i < names.length; i++) {
|
|
176
198
|
var layer = __stxLayerOf(own, names[i]);
|
|
177
199
|
layers[i] = layer;
|
|
200
|
+
at[i] = layer === null ? -1 : stack.lastIndexOf(layer);
|
|
178
201
|
signature += layer === null ? '0' : '1';
|
|
179
202
|
}
|
|
180
203
|
var shape = group.shapes.get(signature);
|
|
@@ -182,6 +205,13 @@ export const SIGNALS_NATIVE_ROW_RUNTIME = ` // ================================
|
|
|
182
205
|
shape = { signature: signature, compiled: [] };
|
|
183
206
|
group.shapes.set(signature, shape);
|
|
184
207
|
}
|
|
208
|
+
// Remembered for the next row only when every name was found in a layer
|
|
209
|
+
// (not on the scope's own object, which differs per row).
|
|
210
|
+
var ownless = Object.keys(own).length === 0 && own[__STX_HIDDEN] === undefined;
|
|
211
|
+
if (ownless) {
|
|
212
|
+
for (var k = 0; k < names.length; k++) if (layers[k] !== null && at[k] < 0) ownless = false;
|
|
213
|
+
}
|
|
214
|
+
group.last = ownless ? { stack: stack, names: stack.map(function(layer) { return Object.keys(layer).join('\x01'); }), at: at, shape: shape } : null;
|
|
185
215
|
return shape;
|
|
186
216
|
}
|
|
187
217
|
|
|
@@ -305,7 +335,10 @@ export const SIGNALS_NATIVE_ROW_RUNTIME = ` // ================================
|
|
|
305
335
|
|
|
306
336
|
// The visibility gates an element's attribute bindings wait on: every :if
|
|
307
337
|
// around it, the row's own and those around the loop.
|
|
308
|
-
function rowVisibility(el, row) {
|
|
338
|
+
function rowVisibility(el, row, pnode) {
|
|
339
|
+
// Outside every :if of the row, in a loop no :if hides: always visible,
|
|
340
|
+
// without walking up to find that out.
|
|
341
|
+
if (!pnode.gated && !row.outer.length && !row.inserted) return __stxAlwaysVisible;
|
|
309
342
|
var gates = [];
|
|
310
343
|
for (var node = el; node; node = node.parentNode) {
|
|
311
344
|
if (node.__stx_if_visible) gates.push(node.__stx_if_visible);
|
|
@@ -356,16 +389,16 @@ export const SIGNALS_NATIVE_ROW_RUNTIME = ` // ================================
|
|
|
356
389
|
for (var i = 0; i < ops.length; i++) {
|
|
357
390
|
var op = ops[i];
|
|
358
391
|
if (op.kind === 'attr') {
|
|
359
|
-
if (!visible) visible = rowVisibility(el, row);
|
|
392
|
+
if (!visible) visible = rowVisibility(el, row, pnode);
|
|
360
393
|
if (!urlWarning) urlWarning = { warned: false };
|
|
361
394
|
bindRowAttribute(el, op, row, visible, urlWarning);
|
|
362
395
|
}
|
|
363
396
|
else if (op.kind === 'class') {
|
|
364
|
-
if (!visible) visible = rowVisibility(el, row);
|
|
397
|
+
if (!visible) visible = rowVisibility(el, row, pnode);
|
|
365
398
|
bindRowClass(el, op.site, row, visible);
|
|
366
399
|
}
|
|
367
400
|
else if (op.kind === 'style') {
|
|
368
|
-
if (!visible) visible = rowVisibility(el, row);
|
|
401
|
+
if (!visible) visible = rowVisibility(el, row, pnode);
|
|
369
402
|
bindRowStyle(el, op.site, row, visible);
|
|
370
403
|
}
|
|
371
404
|
else if (op.kind === 'text') {
|
|
@@ -376,8 +409,10 @@ export const SIGNALS_NATIVE_ROW_RUNTIME = ` // ================================
|
|
|
376
409
|
if (el[op.key]) continue;
|
|
377
410
|
el[op.key] = true;
|
|
378
411
|
var forwarded = op.forwarded && !!el.__stx_parent_scope;
|
|
379
|
-
|
|
380
|
-
|
|
412
|
+
// A forwarded handler runs in its caller's scope, which the listener
|
|
413
|
+
// layers again when it fires; one layering serves all of the row's.
|
|
414
|
+
if (forwarded && row.forwardedScope === null) row.forwardedScope = layerTemplateScopes(globalHelpers, el.__stx_parent_scope);
|
|
415
|
+
listenTemplateEvent(el, op.eventName, op.modifiers, op.value, forwarded ? row.forwardedScope : row.evalScope, forwarded);
|
|
381
416
|
}
|
|
382
417
|
}
|
|
383
418
|
if (pnode.inert) return;
|
|
@@ -577,7 +612,7 @@ export const SIGNALS_NATIVE_ROW_RUNTIME = ` // ================================
|
|
|
577
612
|
// A row of \`plan\`, bound before it is inserted. \`parent\` is where it will
|
|
578
613
|
// go; the caller inserts it and then calls finishNativeRow.
|
|
579
614
|
function createNativeRow(plan, itemScope, parent) {
|
|
580
|
-
var row = { plan: plan, root: null, scope: null, evalScope: null, local: null, caller: null, outer: [], after: [], inserted: false, scopeVars: null, scopeId: null };
|
|
615
|
+
var row = { plan: plan, root: null, scope: null, evalScope: null, local: null, caller: null, forwardedScope: null, outer: [], after: [], inserted: false, scopeVars: null, scopeId: null };
|
|
581
616
|
for (var node = parent; node; node = node.parentNode) if (node.__stx_if_visible) row.outer.push(node.__stx_if_visible);
|
|
582
617
|
if (plan.component) row.scopeId = plan.scopeId + '_for_' + (++__forComponentScopeCounter);
|
|
583
618
|
var made = buildRowNode(plan.root, row);
|
|
@@ -13,6 +13,22 @@ export const SIGNALS_PIPE_RUNTIME = ` // ======================================
|
|
|
13
13
|
if (expr.indexOf('|') === -1) return null;
|
|
14
14
|
const known = __stxPipeIndex.get(expr);
|
|
15
15
|
if (known === -1) return null;
|
|
16
|
+
// Nearly every bar is half of a ||: when no bar stands alone, there is no
|
|
17
|
+
// pipe, and the character scan below (slow in an interpreter, for an
|
|
18
|
+
// expression of any length) has nothing to find.
|
|
19
|
+
if (known === undefined) {
|
|
20
|
+
let bar = expr.indexOf('|');
|
|
21
|
+
while (bar !== -1) {
|
|
22
|
+
if (expr.charCodeAt(bar + 1) === 124) { bar = expr.indexOf('|', bar + 2); continue; }
|
|
23
|
+
if (bar > 0 && expr.charCodeAt(bar - 1) === 63) { bar = expr.indexOf('|', bar + 1); continue; }
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
if (bar === -1) {
|
|
27
|
+
if (__stxPipeIndex.size >= 5000) __stxPipeIndex.clear();
|
|
28
|
+
__stxPipeIndex.set(expr, -1);
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
16
32
|
// Find pipe operators: single | that's not part of || or preceded by ?
|
|
17
33
|
// We need to find | that is:
|
|
18
34
|
// 1. Not preceded by | or ?
|
package/dist/craft-entry.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{So,va,xa}from"./chunk-s3fmmm98.js";import"./chunk-sprgkk9j.js";import"./chunk-4v50nafp.js";import"./chunk-t65tn8ee.js";import"./chunk-2yxva96k.js";import"./chunk-wp6bdac7.js";import"./chunk-akcyaxwv.js";import"./chunk-zbv8e4rq.js";import"./chunk-2ws2qe1k.js";import"./chunk-qjbpa1n4.js";import"./chunk-9x62j5f0.js";import"./chunk-7bxnjr3b.js";import"./chunk-qpvwxppw.js";import"./chunk-rbv6fxtx.js";import"./chunk-nw0v655w.js";import"./chunk-e37g6ezw.js";import"./chunk-89jn2jmf.js";import"./chunk-q7q9e0gj.js";import"./chunk-9k6tza24.js";import"./chunk-2z2bq2at.js";import"./chunk-c84pxd2k.js";import"./chunk-33vr7x2t.js";import{fu,Sa,hh,yh,ka,ko,Qr,_a,Ca,bh,wh,Ea,Ta,$a,Ra}from"./chunk-r6d6jphq.js";import"./chunk-a20wq8wf.js";import"./chunk-rwys552r.js";import"./chunk-yv4dwdhc.js";import"./chunk-eegb7f3t.js";import"./chunk-aw6369cx.js";import"./chunk-3mby4nes.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
|
|
3
3
|
`),scripts:t.scripts.join(`
|
|
4
4
|
`),metadata:{renderTime:0,cacheHit:!0,totalSize:c.html.length,componentCount:t.metadata.componentCount}}}let a;if(n.streaming)a=await H(t.tree,e);else a=h(t.tree,e);let i;if(n.hydrate){let o=j(a,t,e);a=o.html,i=o.data}if(n.minify)a=D(a);if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`;d.set(o,{html:a,timestamp:Date.now()})}let s=performance.now()-r;return{html:a,styles:t.styles.join(`
|
|
5
5
|
`),scripts:t.scripts.join(`
|
|
6
6
|
`),hydrationData:i,metadata:{renderTime:s,cacheHit:!1,totalSize:a.length,componentCount:t.metadata.componentCount}}}function V(t,e){let n=[],r=[],a=[],i=new Map,s=[];return y(t.tree,(o,c)=>{if(o.type==="component"&&o.componentName){if(T(o.componentName))n.push(o.componentName)}if(o.type==="element"&&o.tag){let p=J(o);if(p)s.push(p);if(o.props){for(let[l,f]of Object.entries(o.props))if(l.startsWith("on")&&typeof f==="string"){let g=`handler_${i.size}`;i.set(g,f)}}}if(o.isStatic&&o.type==="element")r.push(b(o));else if(!o.isStatic&&o.type!=="text")a.push(o.tag||o.componentName||"unknown")}),{nativeComponents:n,staticHTML:r,dynamicParts:a,eventHandlers:i,nativeWidgets:s}}function Y(t,e={}){let n=R(t),r=P(n,e),a=new Map,i=[];return y(n.tree,(s)=>{if(s.type==="component"&&s.componentName){if(T(s.componentName)){i.push(s.componentName);let o=`<!--craft:${s.componentName}:${s.hydrationKey||"default"}-->`;a.set(s.hydrationKey||s.componentName,o)}}}),{staticHTML:r,dynamicPlaceholders:a,craftComponents:i}}function M(t){let e={type:"fragment",children:[]},n=e,r=[e],a=t,i=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);while(a.length>0){let s=a.match(/^<(@?[\w-]+)([^>]*)>/);if(s){let[p,l,f]=s,g=z(f),u=l.startsWith("@craft-"),C=u?l:l.toLowerCase(),S={type:u?"component":"element",tag:C,props:g,children:[],componentName:u?C.slice(1):void 0,isStatic:!v(f),hydrationKey:F()};if(n.children=n.children||[],n.children.push(S),!i.has(C)&&!f.endsWith("/"))r.push(S),n=S;a=a.slice(p.length);continue}let o=a.match(/^<\/(@?[\w-]+)>/);if(o){let[p,l]=o,g=l.startsWith("@craft-")?l:l.toLowerCase();while(r.length>1){let u=r.pop();if(n=r[r.length-1],u.tag===g)break}a=a.slice(p.length);continue}let c=a.match(/^[^<]+/);if(c){let p=c[0];if(p.trim()){let l={type:"text",text:p,isStatic:!v(p)};n.children=n.children||[],n.children.push(l)}a=a.slice(p.length);continue}a=a.slice(1)}return e}function z(t){let e={},n=/([\w-:@]+)(?:=(?:"([^"]*)"|'([^']*)'|(\S+)))?/g,r;while((r=n.exec(t))!==null){let[,a,i,s,o]=r,c=i??s??o??!0;e[a]=c}return e}function y(t,e,n=[]){if(e(t,n),t.children)t.children.forEach((r,a)=>{y(r,e,[...n,`${a}`])})}function h(t,e){switch(t.type){case"text":return x(t.text||"",e);case"element":case"component":{let n=t.tag||"div",r=N(t.props||{},e),a=(t.children||[]).map((i)=>h(i,e)).join("");if(!t.children||t.children.length===0){if(["input","br","hr","img","meta","link"].includes(n))return`<${n}${r} />`}return`<${n}${r}>${a}</${n}>`}case"fragment":return(t.children||[]).map((n)=>h(n,e)).join("");case"slot":return`<!--slot:${t.slotName||"default"}-->`;default:return""}}function b(t){if(t.type==="text")return t.text||"";let e=t.tag||"div",n=N(t.props||{},{});return`<${e}${n}></${e}>`}function N(t,e){let n=[];for(let[r,a]of Object.entries(t))if(a===!0)n.push(` ${r}`);else if(a!==!1&&a!==null&&a!==void 0){let i=x(String(a),e);n.push(` ${r}="${k(i)}"`)}return n.join("")}async function H(t,e){return h(t,e)}function P(t,e){let n=[];return y(t.tree,(r)=>{if(r.isStatic)n.push(h(r,e))}),n.join("")}function j(t,e,n){let r={templateId:e.id,context:n,dynamicParts:Array.from(e.dynamicParts.entries())},a=`
|
|
7
7
|
<script data-craft-hydration>
|
|
8
8
|
window.__CRAFT_HYDRATION__ = ${JSON.stringify(r)};
|
|
9
|
-
</script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{
|
|
9
|
+
</script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{fu as CRAFT_BRIDGE_SCRIPT,ko as CRAFT_COMPONENTS,_a as CRAFT_COMPONENT_RUNTIME,Qr as CRAFT_COMPONENT_STYLES,So as NATIVE_COMPONENTS,Ea as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,va as compileToNative,xa as createHotReloadServer,Ta as findCraftBinary,Sa as generateCraftBridgeScript,V as generateCraftOptimizations,Ra as getAvailableFormats,$a as getAvailableTargets,wh as getCraftComponents,G as getSSRCacheStats,ka as injectCraftBridge,hh as isCraftEnvironment,Y as prerenderForCraft,Ca as processCraftComponents,yh as processCraftDirective,bh as registerCraftComponent,Q as renderSSR};
|
package/dist/craft.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
2
|
+
import{So,va,xa}from"./chunk-s3fmmm98.js";import"./chunk-sprgkk9j.js";import"./chunk-4v50nafp.js";import"./chunk-t65tn8ee.js";import"./chunk-2yxva96k.js";import"./chunk-wp6bdac7.js";import"./chunk-akcyaxwv.js";import"./chunk-zbv8e4rq.js";import"./chunk-2ws2qe1k.js";import"./chunk-qjbpa1n4.js";import"./chunk-9x62j5f0.js";import"./chunk-7bxnjr3b.js";import"./chunk-qpvwxppw.js";import"./chunk-rbv6fxtx.js";import"./chunk-nw0v655w.js";import"./chunk-e37g6ezw.js";import"./chunk-89jn2jmf.js";import"./chunk-q7q9e0gj.js";import"./chunk-9k6tza24.js";import"./chunk-2z2bq2at.js";import"./chunk-c84pxd2k.js";import"./chunk-33vr7x2t.js";import{fu,Sa,hh,yh,ka,ko,Qr,_a,Ca,bh,wh,Ea,Ta,$a,Ra}from"./chunk-r6d6jphq.js";import"./chunk-a20wq8wf.js";import"./chunk-rwys552r.js";import"./chunk-yv4dwdhc.js";import"./chunk-eegb7f3t.js";import"./chunk-aw6369cx.js";import"./chunk-3mby4nes.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
|
|
3
3
|
`),scripts:t.scripts.join(`
|
|
4
4
|
`),metadata:{renderTime:0,cacheHit:!0,totalSize:c.html.length,componentCount:t.metadata.componentCount}}}let a;if(n.streaming)a=await H(t.tree,e);else a=h(t.tree,e);let i;if(n.hydrate){let o=j(a,t,e);a=o.html,i=o.data}if(n.minify)a=D(a);if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`;d.set(o,{html:a,timestamp:Date.now()})}let s=performance.now()-r;return{html:a,styles:t.styles.join(`
|
|
5
5
|
`),scripts:t.scripts.join(`
|
|
6
6
|
`),hydrationData:i,metadata:{renderTime:s,cacheHit:!1,totalSize:a.length,componentCount:t.metadata.componentCount}}}function V(t,e){let n=[],r=[],a=[],i=new Map,s=[];return y(t.tree,(o,c)=>{if(o.type==="component"&&o.componentName){if(T(o.componentName))n.push(o.componentName)}if(o.type==="element"&&o.tag){let p=J(o);if(p)s.push(p);if(o.props){for(let[l,f]of Object.entries(o.props))if(l.startsWith("on")&&typeof f==="string"){let g=`handler_${i.size}`;i.set(g,f)}}}if(o.isStatic&&o.type==="element")r.push(b(o));else if(!o.isStatic&&o.type!=="text")a.push(o.tag||o.componentName||"unknown")}),{nativeComponents:n,staticHTML:r,dynamicParts:a,eventHandlers:i,nativeWidgets:s}}function Y(t,e={}){let n=R(t),r=P(n,e),a=new Map,i=[];return y(n.tree,(s)=>{if(s.type==="component"&&s.componentName){if(T(s.componentName)){i.push(s.componentName);let o=`<!--craft:${s.componentName}:${s.hydrationKey||"default"}-->`;a.set(s.hydrationKey||s.componentName,o)}}}),{staticHTML:r,dynamicPlaceholders:a,craftComponents:i}}function M(t){let e={type:"fragment",children:[]},n=e,r=[e],a=t,i=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);while(a.length>0){let s=a.match(/^<(@?[\w-]+)([^>]*)>/);if(s){let[p,l,f]=s,g=z(f),u=l.startsWith("@craft-"),C=u?l:l.toLowerCase(),S={type:u?"component":"element",tag:C,props:g,children:[],componentName:u?C.slice(1):void 0,isStatic:!v(f),hydrationKey:F()};if(n.children=n.children||[],n.children.push(S),!i.has(C)&&!f.endsWith("/"))r.push(S),n=S;a=a.slice(p.length);continue}let o=a.match(/^<\/(@?[\w-]+)>/);if(o){let[p,l]=o,g=l.startsWith("@craft-")?l:l.toLowerCase();while(r.length>1){let u=r.pop();if(n=r[r.length-1],u.tag===g)break}a=a.slice(p.length);continue}let c=a.match(/^[^<]+/);if(c){let p=c[0];if(p.trim()){let l={type:"text",text:p,isStatic:!v(p)};n.children=n.children||[],n.children.push(l)}a=a.slice(p.length);continue}a=a.slice(1)}return e}function z(t){let e={},n=/([\w-:@]+)(?:=(?:"([^"]*)"|'([^']*)'|(\S+)))?/g,r;while((r=n.exec(t))!==null){let[,a,i,s,o]=r,c=i??s??o??!0;e[a]=c}return e}function y(t,e,n=[]){if(e(t,n),t.children)t.children.forEach((r,a)=>{y(r,e,[...n,`${a}`])})}function h(t,e){switch(t.type){case"text":return x(t.text||"",e);case"element":case"component":{let n=t.tag||"div",r=N(t.props||{},e),a=(t.children||[]).map((i)=>h(i,e)).join("");if(!t.children||t.children.length===0){if(["input","br","hr","img","meta","link"].includes(n))return`<${n}${r} />`}return`<${n}${r}>${a}</${n}>`}case"fragment":return(t.children||[]).map((n)=>h(n,e)).join("");case"slot":return`<!--slot:${t.slotName||"default"}-->`;default:return""}}function b(t){if(t.type==="text")return t.text||"";let e=t.tag||"div",n=N(t.props||{},{});return`<${e}${n}></${e}>`}function N(t,e){let n=[];for(let[r,a]of Object.entries(t))if(a===!0)n.push(` ${r}`);else if(a!==!1&&a!==null&&a!==void 0){let i=x(String(a),e);n.push(` ${r}="${k(i)}"`)}return n.join("")}async function H(t,e){return h(t,e)}function P(t,e){let n=[];return y(t.tree,(r)=>{if(r.isStatic)n.push(h(r,e))}),n.join("")}function j(t,e,n){let r={templateId:e.id,context:n,dynamicParts:Array.from(e.dynamicParts.entries())},a=`
|
|
7
7
|
<script data-craft-hydration>
|
|
8
8
|
window.__CRAFT_HYDRATION__ = ${JSON.stringify(r)};
|
|
9
|
-
</script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{
|
|
9
|
+
</script>`;return{html:t+a,data:r}}function O(t){let e=!1,n=!1,r=!1,a=!1,i=0,s=0;function o(c,p){if(s=Math.max(s,p),c.type==="slot")e=!0;if(c.type==="component")i++;if(!c.isStatic)n=!0;if(c.props)for(let l of Object.keys(c.props)){if(l.startsWith("on"))r=!0;if(l==="@async"||l==="data-async")a=!0}if(c.children)c.children.forEach((l)=>o(l,p+1))}return o(t,0),{hasSlots:e,hasDynamicContent:n,hasEventHandlers:r,hasAsyncContent:a,componentCount:i,maxDepth:s,estimatedSize:JSON.stringify(t).length}}function A(t){let e=new Map,n=new Map;return y(t,(r,a)=>{let i=a.join(".");if(r.isStatic)e.set(i,b(r));else n.set(i,r.tag||r.componentName||"dynamic")}),{staticParts:e,dynamicParts:n}}function L(t){let e=[],n=/<script[^>]*>([\s\S]*?)<\/script>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function W(t){let e=[],n=/<style[^>]*>([\s\S]*?)<\/style>/gi,r;while((r=n.exec(t))!==null)e.push(r[1]);return e}function _(t){let e=[],n=/@include\s*\(\s*['"]([^'"]+)['"]/g,r;while((r=n.exec(t))!==null)e.push(r[1]);let a=/@component\s*\(\s*['"]([^'"]+)['"]/g;while((r=a.exec(t))!==null)e.push(r[1]);let i=/<@craft-[\w-]+/g;while((r=i.exec(t))!==null)e.push(r[0].slice(2));return[...new Set(e)]}function v(t){return/\{\{.*?\}\}|\{\!\!.*?\!\!\}/.test(t)}function x(t,e){let n=t.replace(/\{\{\s*(.+?)\s*\}\}/g,(r,a)=>{try{let i=w(a.trim(),e);return k(String(i??""))}catch{return""}});return n=n.replace(/\{!!\s*(.+?)\s*!!\}/g,(r,a)=>{try{let i=w(a.trim(),e);return String(i??"")}catch{return""}}),n}function w(t,e){if(/^[\w.]+$/.test(t)){let n=t.split("."),r=e;for(let a of n)if(r&&typeof r==="object"&&a in r)r=r[a];else return;return r}try{return Function(...Object.keys(e),`return ${t}`)(...Object.values(e))}catch{return}}function k(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function D(t){return t.replace(/\s+/g," ").replace(/>\s+</g,"><").replace(/\s+>/g,">").replace(/<\s+/g,"<").trim()}function E(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return`tpl_${Math.abs(e).toString(36)}`}function I(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);e=(e<<5)-e+r,e=e&e}return Math.abs(e).toString(36)}var K=0;function F(){return`h_${++K}`}function T(t){return["craft-button","craft-text-input","craft-textarea","craft-checkbox","craft-radio","craft-select","craft-slider","craft-toggle","craft-date-picker","craft-time-picker","craft-color-picker","craft-file-input","craft-modal","craft-alert","craft-toast","craft-progress","craft-spinner","craft-avatar","craft-badge","craft-card","craft-accordion","craft-tabs","craft-tooltip","craft-popover","craft-dropdown","craft-context-menu","craft-data-table","craft-virtual-list","craft-tree-view","craft-map","craft-chart","craft-video","craft-audio","craft-webview","craft-canvas","craft-image-viewer","craft-pdf-viewer","craft-code-editor","craft-rich-editor"].includes(t)}function J(t){let e=t.tag?.toLowerCase(),n=t.props?.type,r={button:{component:"craft-button",confidence:0.95,reason:"Native button provides better touch feedback"},"input:text":{component:"craft-text-input",confidence:0.9,reason:"Native text input has better keyboard handling"},"input:checkbox":{component:"craft-checkbox",confidence:0.95,reason:"Native checkbox follows platform conventions"},"input:range":{component:"craft-slider",confidence:0.9,reason:"Native slider provides smooth interaction"},"input:date":{component:"craft-date-picker",confidence:0.95,reason:"Native date picker provides platform-specific UI"},"input:time":{component:"craft-time-picker",confidence:0.95,reason:"Native time picker provides platform-specific UI"},"input:color":{component:"craft-color-picker",confidence:0.9,reason:"Native color picker provides platform-specific UI"},textarea:{component:"craft-textarea",confidence:0.85,reason:"Native textarea handles multiline input better"},select:{component:"craft-select",confidence:0.9,reason:"Native select provides platform dropdown UI"},progress:{component:"craft-progress",confidence:0.95,reason:"Native progress bar matches platform style"},video:{component:"craft-video",confidence:0.95,reason:"Native video provides hardware acceleration"},audio:{component:"craft-audio",confidence:0.95,reason:"Native audio provides system integration"},dialog:{component:"craft-modal",confidence:0.9,reason:"Native modal provides proper layering and focus"}},a=n?`${e}:${n}`:e,i=r[a||""]||r[e||""];if(i)return{htmlSelector:a||e||"",nativeComponent:i.component,confidence:i.confidence,reason:i.reason};return null}function U(){m.clear()}function q(){d.clear()}function B(){U(),q()}function G(){return{templateCacheSize:m.size,renderCacheSize:d.size,totalEntries:m.size+d.size}}export{fu as CRAFT_BRIDGE_SCRIPT,ko as CRAFT_COMPONENTS,_a as CRAFT_COMPONENT_RUNTIME,Qr as CRAFT_COMPONENT_STYLES,So as NATIVE_COMPONENTS,Ea as buildNative,B as clearAllCaches,q as clearRenderCache,U as clearTemplateCache,R as compileTemplate,va as compileToNative,xa as createHotReloadServer,Ta as findCraftBinary,Sa as generateCraftBridgeScript,V as generateCraftOptimizations,Ra as getAvailableFormats,$a as getAvailableTargets,wh as getCraftComponents,G as getSSRCacheStats,ka as injectCraftBridge,hh as isCraftEnvironment,Y as prerenderForCraft,Ca as processCraftComponents,yh as processCraftDirective,bh as registerCraftComponent,Q as renderSSR};
|
|
@@ -219,7 +219,39 @@ function declarations(css) {
|
|
|
219
219
|
}
|
|
220
220
|
return result;
|
|
221
221
|
}
|
|
222
|
+
const textEntries = new Map;
|
|
222
223
|
function styleEntries(input, report) {
|
|
224
|
+
if (typeof input === "string") {
|
|
225
|
+
const known = textEntries.get(input);
|
|
226
|
+
if (known)
|
|
227
|
+
return known;
|
|
228
|
+
const entries = textStyleEntries(input, report);
|
|
229
|
+
if (entries) {
|
|
230
|
+
if (textEntries.size >= 2000)
|
|
231
|
+
textEntries.clear();
|
|
232
|
+
textEntries.set(input, entries);
|
|
233
|
+
return entries;
|
|
234
|
+
}
|
|
235
|
+
return [];
|
|
236
|
+
}
|
|
237
|
+
return objectStyleEntries(input, report);
|
|
238
|
+
}
|
|
239
|
+
function textStyleEntries(text, report) {
|
|
240
|
+
let input = text.trim();
|
|
241
|
+
if (!input)
|
|
242
|
+
return [];
|
|
243
|
+
try {
|
|
244
|
+
input = JSON.parse(input);
|
|
245
|
+
} catch {}
|
|
246
|
+
if (typeof input === "string")
|
|
247
|
+
return declarations(input);
|
|
248
|
+
if (input && typeof input === "object" && !Array.isArray(input))
|
|
249
|
+
return Object.entries(input);
|
|
250
|
+
if (input != null && input !== !1)
|
|
251
|
+
report({ kind: "non-numeric-style", name: "style" });
|
|
252
|
+
return null;
|
|
253
|
+
}
|
|
254
|
+
function objectStyleEntries(input, report) {
|
|
223
255
|
let entries;
|
|
224
256
|
if (typeof input === "string") {
|
|
225
257
|
input = input.trim();
|
|
@@ -247,48 +279,68 @@ export function parseNativeStyle(input, report = () => {}, context = {}) {
|
|
|
247
279
|
}
|
|
248
280
|
const NO_STYLE_VARIABLES = new Map;
|
|
249
281
|
export function parseNativeStyleLayers(inputs, inheritedVariables, report) {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
const
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
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);
|
|
282
|
+
let known = null, keys = null;
|
|
283
|
+
const layers = Array(inputs.length);
|
|
284
|
+
let empty = !0;
|
|
285
|
+
for (let i = 0;i < inputs.length; i++) {
|
|
286
|
+
const input = inputs[i];
|
|
287
|
+
if (input && typeof input === "object" && !Array.isArray(input) || typeof input === "string" && input) {
|
|
288
|
+
const key = typeof input === "string" ? standaloneStyleText(input) : standaloneStyleKey(input), kept = key === void 0 ? void 0 : rememberedStyles.get(key);
|
|
289
|
+
if (kept) {
|
|
290
|
+
(known ??= Array(inputs.length))[i] = kept;
|
|
291
|
+
layers[i] = NO_ENTRIES;
|
|
292
|
+
empty = !1;
|
|
293
|
+
continue;
|
|
273
294
|
}
|
|
274
|
-
key
|
|
275
|
-
|
|
276
|
-
|
|
295
|
+
if (key !== void 0)
|
|
296
|
+
(keys ??= Array(inputs.length))[i] = key;
|
|
297
|
+
}
|
|
298
|
+
layers[i] = styleEntries(input, report);
|
|
299
|
+
if (layers[i].length)
|
|
300
|
+
empty = !1;
|
|
277
301
|
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
let
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
302
|
+
if (empty)
|
|
303
|
+
return { variables: inheritedVariables ?? NO_STYLE_VARIABLES, styles: layers.map(() => ({})) };
|
|
304
|
+
const variables = createStyleVariables(layers.flat(), inheritedVariables), computed = variables.computed(), styles = Array(inputs.length);
|
|
305
|
+
for (let i = 0;i < inputs.length; i++) {
|
|
306
|
+
const kept = known?.[i];
|
|
307
|
+
if (kept) {
|
|
308
|
+
styles[i] = kept;
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
311
|
+
const key = keys?.[i];
|
|
312
|
+
if (key === void 0) {
|
|
313
|
+
styles[i] = layers[i].length ? parseEntries(layers[i], variables, report) : {};
|
|
314
|
+
continue;
|
|
315
|
+
}
|
|
316
|
+
let reported = !1;
|
|
317
|
+
const style = parseEntries(layers[i], variables, (diagnostic) => {
|
|
318
|
+
reported = !0;
|
|
319
|
+
report(diagnostic);
|
|
320
|
+
});
|
|
321
|
+
if (!reported) {
|
|
322
|
+
if (rememberedStyles.size >= 2000)
|
|
323
|
+
rememberedStyles.clear();
|
|
324
|
+
rememberedStyles.set(key, style);
|
|
325
|
+
}
|
|
326
|
+
styles[i] = style;
|
|
290
327
|
}
|
|
291
|
-
return
|
|
328
|
+
return { variables: computed, styles };
|
|
329
|
+
}
|
|
330
|
+
const NO_ENTRIES = [], rememberedStyles = new Map;
|
|
331
|
+
function standaloneStyleText(text) {
|
|
332
|
+
return text.includes("var(") || text.includes("--") ? void 0 : `\x03${text}`;
|
|
333
|
+
}
|
|
334
|
+
function standaloneStyleKey(input) {
|
|
335
|
+
let text;
|
|
336
|
+
try {
|
|
337
|
+
text = JSON.stringify(input);
|
|
338
|
+
} catch {
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
if (typeof text !== "string" || text.includes("var(") || text.includes('"--'))
|
|
342
|
+
return;
|
|
343
|
+
return text;
|
|
292
344
|
}
|
|
293
345
|
function parseEntries(entries, variables, report) {
|
|
294
346
|
const style = {}, declarationNames = [];
|