@stacksjs/stx 0.2.795 → 0.2.799
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-7y73txmp.js → chunk-00w4ccrz.js} +2 -2
- package/dist/{chunk-wa7fzgw7.js → chunk-0y7h27ga.js} +4 -4
- package/dist/{chunk-g4n0bjfb.js → chunk-116ajzvm.js} +46 -46
- package/dist/chunk-16htz6k0.js +18 -0
- package/dist/chunk-1ayk62gk.js +2 -0
- package/dist/chunk-1rwfgmmk.js +2 -0
- package/dist/chunk-24aq9yrk.js +2 -0
- package/dist/chunk-2by8tphv.js +2 -0
- package/dist/chunk-2ehn5r6d.js +2 -0
- package/dist/chunk-2r3e3m9m.js +2 -0
- package/dist/{chunk-y2jqx5k4.js → chunk-2xa05bav.js} +1 -1
- package/dist/{chunk-azqf0ps0.js → chunk-2yb1rwmy.js} +2 -2
- package/dist/{chunk-baj6w8ja.js → chunk-33vr7x2t.js} +3 -3
- package/dist/chunk-3dgkdmj0.js +2 -0
- package/dist/chunk-3qqjhb4e.js +2 -0
- package/dist/chunk-4p42q0wa.js +2 -0
- package/dist/{chunk-7y29q1ng.js → chunk-4rny8rf5.js} +2 -2
- package/dist/{chunk-p3ej3954.js → chunk-549end3k.js} +2 -2
- package/dist/chunk-5fzvcr9v.js +2 -0
- package/dist/{chunk-zmr0pvcd.js → chunk-5pzcd5jh.js} +59 -59
- package/dist/{chunk-wzwfbehm.js → chunk-600xzcs0.js} +12 -12
- package/dist/chunk-6fq522rd.js +2 -0
- package/dist/chunk-6gt07bzy.js +2 -0
- package/dist/chunk-6hrfmvkn.js +2 -0
- package/dist/{chunk-axjfaere.js → chunk-6n5cbyes.js} +127 -40
- package/dist/chunk-77v7g18n.js +2 -0
- package/dist/chunk-7m4eesp0.js +2 -0
- package/dist/{chunk-2bvaakcv.js → chunk-7svwyjxb.js} +7 -7
- package/dist/{chunk-6s9bk98p.js → chunk-7yb82rm6.js} +2 -2
- package/dist/{chunk-d50vw81s.js → chunk-83myk906.js} +4 -4
- package/dist/chunk-87p1av24.js +2 -0
- package/dist/chunk-8adf5x29.js +2 -0
- package/dist/{chunk-nyer6v3y.js → chunk-8c81cgyb.js} +5 -5
- package/dist/{chunk-yjnaqahd.js → chunk-8ey61ppd.js} +5 -5
- package/dist/chunk-8m0khhe5.js +2 -0
- package/dist/{chunk-hp10khyy.js → chunk-8tb3cmhv.js} +49 -49
- package/dist/chunk-9736003n.js +2 -0
- package/dist/{chunk-x8ghjw9b.js → chunk-99aqp5ss.js} +3 -3
- package/dist/chunk-9d2cgsn2.js +2 -0
- package/dist/{chunk-bzhzp4f4.js → chunk-9gwhs0gk.js} +2 -2
- package/dist/{chunk-aksrh8je.js → chunk-9hn0zpxj.js} +3 -3
- package/dist/{chunk-jmbh26gv.js → chunk-9kadf7pv.js} +1 -1
- package/dist/{chunk-pnddmgjf.js → chunk-9y6vdjy5.js} +7 -7
- package/dist/chunk-a3vbwkjh.js +2 -0
- package/dist/{chunk-qnxctfdf.js → chunk-akcyaxwv.js} +2 -2
- package/dist/{chunk-ectx5ar9.js → chunk-b0ct7x3p.js} +3 -3
- package/dist/{chunk-m081078c.js → chunk-b3xmheq9.js} +3 -3
- package/dist/{chunk-3vpgr6nk.js → chunk-b9d70mgr.js} +3 -3
- package/dist/{chunk-bwf8b4e4.js → chunk-bbt09ebh.js} +3 -3
- package/dist/{chunk-r3a15pax.js → chunk-bfm5cedw.js} +1 -1
- package/dist/chunk-bj6ax0he.js +2 -0
- package/dist/{chunk-7k6hd10j.js → chunk-bphwhfbd.js} +5 -5
- package/dist/{chunk-1hq3y7ss.js → chunk-brhas9mp.js} +2 -2
- package/dist/{chunk-mcj5qtpp.js → chunk-bs8xype1.js} +3 -3
- package/dist/{chunk-rdymnn2t.js → chunk-c1bsagbe.js} +6 -6
- package/dist/{chunk-12jjf2me.js → chunk-c84pxd2k.js} +2 -2
- package/dist/chunk-cas0vn5m.js +2 -0
- package/dist/chunk-cbx7qght.js +2 -0
- package/dist/{chunk-ayd635jf.js → chunk-cccf42yy.js} +5 -5
- package/dist/{chunk-zv3zpmv1.js → chunk-cezw6q40.js} +1 -1
- package/dist/{chunk-3f8w1x6w.js → chunk-cm0f5aj3.js} +7 -7
- package/dist/chunk-cxpnkgvw.js +2 -0
- package/dist/chunk-d1c1qggs.js +2 -0
- package/dist/{chunk-3em44jbm.js → chunk-d8rcba53.js} +2 -2
- package/dist/chunk-dd1vqndp.js +2 -0
- package/dist/{chunk-cfbpvm5e.js → chunk-ddhkhhc7.js} +2 -2
- package/dist/{chunk-tmfrq4nq.js → chunk-dq87xd5c.js} +40 -40
- package/dist/chunk-dwydz68f.js +2 -0
- package/dist/{chunk-ennzzth4.js → chunk-e32pjcyd.js} +17 -17
- package/dist/chunk-enpx5t99.js +2 -0
- package/dist/chunk-eszpqrxy.js +2 -0
- package/dist/{chunk-h656zg6k.js → chunk-fn3q1gtr.js} +3 -3
- package/dist/{chunk-hwcfgs3e.js → chunk-gjf8cjdt.js} +3 -3
- package/dist/{chunk-4s0ye933.js → chunk-gqjb1y7c.js} +2 -2
- package/dist/chunk-gv0bp9ve.js +2 -0
- package/dist/{chunk-8zf87cc5.js → chunk-gvnfb6s2.js} +2 -2
- package/dist/{chunk-fcqxa38q.js → chunk-gzfvj15b.js} +1 -1
- package/dist/{chunk-90zswh9v.js → chunk-hcwjdpzv.js} +5 -5
- package/dist/chunk-hdsccfga.js +2 -0
- package/dist/{chunk-r1vkk7qp.js → chunk-hp9e8nz6.js} +2 -2
- package/dist/{chunk-7s1kerhs.js → chunk-hrrrf46j.js} +2 -2
- package/dist/{chunk-dstzvtvk.js → chunk-j0bbr6ee.js} +3 -3
- package/dist/{chunk-6wpwpk3c.js → chunk-j2v9f2dk.js} +4 -4
- package/dist/{chunk-4p5g7v9g.js → chunk-j3st59hv.js} +2 -2
- package/dist/chunk-jn6g5n02.js +2 -0
- package/dist/chunk-js4t4825.js +2 -0
- package/dist/{chunk-pm8a4kdf.js → chunk-jzxh4y5j.js} +5 -5
- package/dist/chunk-kgn911k7.js +2 -0
- package/dist/{chunk-8t8e75xm.js → chunk-krjd21ws.js} +4 -4
- package/dist/{chunk-thpwk6ya.js → chunk-kvz01wzc.js} +2 -2
- package/dist/{chunk-9b9tvhmh.js → chunk-kyb43mnq.js} +5 -5
- package/dist/{chunk-f4j7nsj1.js → chunk-kydgndkt.js} +1 -1
- package/dist/chunk-mshnt7y9.js +3 -0
- package/dist/chunk-mt95md1e.js +2 -0
- package/dist/chunk-nbb9btn0.js +2 -0
- package/dist/chunk-nm20k22y.js +2 -0
- package/dist/chunk-nq4d91zm.js +2 -0
- package/dist/{chunk-y64f5t74.js → chunk-nxdgvtgc.js} +5 -5
- package/dist/chunk-p5efqqtk.js +2 -0
- package/dist/chunk-pjs4q88m.js +2 -0
- package/dist/chunk-pm8d60n0.js +2 -0
- package/dist/chunk-ps9fcjyg.js +2 -0
- package/dist/chunk-q38vjqv2.js +2 -0
- package/dist/{chunk-ata5wp2m.js → chunk-q3dsjk2b.js} +6 -6
- package/dist/chunk-q78jxqnr.js +2 -0
- package/dist/chunk-q8xw7yye.js +2 -0
- package/dist/chunk-qkck7zx0.js +2 -0
- package/dist/{chunk-hnbx1t3t.js → chunk-qkfdp97k.js} +2 -2
- package/dist/{chunk-53v4cby3.js → chunk-qpvwxppw.js} +4 -4
- package/dist/{chunk-427mhgje.js → chunk-qxt6hdat.js} +1 -1
- package/dist/{chunk-1q16p7t2.js → chunk-r32pqvpq.js} +5 -5
- package/dist/{chunk-2e5tvryz.js → chunk-r50b54a8.js} +2 -2
- package/dist/chunk-rd3pek52.js +2 -0
- package/dist/chunk-rxc1076r.js +2 -0
- package/dist/{chunk-cepctq7e.js → chunk-s2vnydq0.js} +81 -81
- package/dist/{chunk-dxe94pwy.js → chunk-s90m43sm.js} +4 -4
- package/dist/{chunk-vkn133cs.js → chunk-s9b6abkb.js} +2 -2
- package/dist/{chunk-88acqv2r.js → chunk-sbe6xr6h.js} +4 -4
- package/dist/{chunk-624xpap6.js → chunk-se44tmvx.js} +17 -17
- package/dist/{chunk-w76cve9j.js → chunk-sprgkk9j.js} +31 -31
- package/dist/{chunk-ka8sk5qa.js → chunk-sxee2rxz.js} +1 -1
- package/dist/{chunk-2xprqx2v.js → chunk-t4gmj0nd.js} +6 -6
- package/dist/{chunk-vpzdqbw7.js → chunk-t5vjt37c.js} +6 -6
- package/dist/{chunk-b58n1kfe.js → chunk-t65tn8ee.js} +2 -2
- package/dist/{chunk-tqvw1673.js → chunk-tb4wmzzd.js} +5 -5
- package/dist/chunk-tjn7htz7.js +2 -0
- package/dist/chunk-tkb335d7.js +2 -0
- package/dist/chunk-tx75gjzg.js +2 -0
- package/dist/{chunk-538d185r.js → chunk-v1xtm49w.js} +2 -2
- package/dist/{chunk-c5vzr1va.js → chunk-w0zayhmg.js} +2 -2
- package/dist/chunk-w4jymx0v.js +2 -0
- package/dist/{chunk-njk5db1q.js → chunk-w5dw3c8m.js} +4 -4
- package/dist/chunk-w5sbp9ry.js +2 -0
- package/dist/{chunk-reb7rddz.js → chunk-w9hpdka1.js} +1 -1
- package/dist/chunk-whq40bdm.js +2 -0
- package/dist/chunk-wkrep5sj.js +2 -0
- package/dist/{chunk-xqjat573.js → chunk-x82zksaj.js} +2 -2
- package/dist/chunk-xgqyzkt2.js +2 -0
- package/dist/{chunk-w6e30qkz.js → chunk-xkrcte91.js} +37 -37
- package/dist/{chunk-zva4a7xq.js → chunk-xystfx25.js} +2 -2
- package/dist/{chunk-7xs45trj.js → chunk-y9bj3566.js} +2 -2
- package/dist/chunk-ys46rqxg.js +2 -0
- package/dist/chunk-z5650kd0.js +2 -0
- package/dist/{chunk-sphc7xzx.js → chunk-znx5m1jv.js} +1 -1
- package/dist/chunk-zvfw1h3f.js +2 -0
- 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/dev-server/serve-css-assets.d.ts +5 -0
- package/dist/dev-server/serve-css-assets.js +60 -0
- package/dist/dev-server/ts-css.d.ts +1 -1
- package/dist/dev-server/ts-css.js +5 -20
- package/dist/info-plist.d.ts +4 -0
- package/dist/info-plist.js +42 -0
- package/dist/native/compiler/inline-style.js +91 -39
- package/dist/native/runtime/native-host.js +138 -17
- package/dist/native-build.d.ts +3 -1
- package/dist/native-build.js +3 -41
- package/dist/pwa.js +3 -3
- package/dist/ssg.js +19 -19
- 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-9jcqbgq9.js +0 -18
- 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-bbt09ebh.js";import"./chunk-sprgkk9j.js";import"./chunk-se44tmvx.js";import"./chunk-t65tn8ee.js";import"./chunk-2yxva96k.js";import"./chunk-5pzcd5jh.js";import"./chunk-akcyaxwv.js";import"./chunk-qkfdp97k.js";import"./chunk-9gwhs0gk.js";import"./chunk-j2v9f2dk.js";import"./chunk-116ajzvm.js";import"./chunk-dq87xd5c.js";import"./chunk-qpvwxppw.js";import"./chunk-v1xtm49w.js";import"./chunk-16htz6k0.js";import"./chunk-8tb3cmhv.js";import"./chunk-w5dw3c8m.js";import"./chunk-cm0f5aj3.js";import"./chunk-9y6vdjy5.js";import"./chunk-7svwyjxb.js";import"./chunk-c84pxd2k.js";import"./chunk-33vr7x2t.js";import{fu,Sa,yh,bh,ka,ko,Qr,_a,Ca,wh,vh,Ea,Ta,$a,Ra}from"./chunk-xkrcte91.js";import"./chunk-krjd21ws.js";import"./chunk-mshnt7y9.js";import"./chunk-2yb1rwmy.js";import"./chunk-jzxh4y5j.js";import"./chunk-kydgndkt.js";import"./chunk-9hn0zpxj.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,vh as getCraftComponents,G as getSSRCacheStats,ka as injectCraftBridge,yh as isCraftEnvironment,Y as prerenderForCraft,Ca as processCraftComponents,bh as processCraftDirective,wh 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-bbt09ebh.js";import"./chunk-sprgkk9j.js";import"./chunk-se44tmvx.js";import"./chunk-t65tn8ee.js";import"./chunk-2yxva96k.js";import"./chunk-5pzcd5jh.js";import"./chunk-akcyaxwv.js";import"./chunk-qkfdp97k.js";import"./chunk-9gwhs0gk.js";import"./chunk-j2v9f2dk.js";import"./chunk-116ajzvm.js";import"./chunk-dq87xd5c.js";import"./chunk-qpvwxppw.js";import"./chunk-v1xtm49w.js";import"./chunk-16htz6k0.js";import"./chunk-8tb3cmhv.js";import"./chunk-w5dw3c8m.js";import"./chunk-cm0f5aj3.js";import"./chunk-9y6vdjy5.js";import"./chunk-7svwyjxb.js";import"./chunk-c84pxd2k.js";import"./chunk-33vr7x2t.js";import{fu,Sa,yh,bh,ka,ko,Qr,_a,Ca,wh,vh,Ea,Ta,$a,Ra}from"./chunk-xkrcte91.js";import"./chunk-krjd21ws.js";import"./chunk-mshnt7y9.js";import"./chunk-2yb1rwmy.js";import"./chunk-jzxh4y5j.js";import"./chunk-kydgndkt.js";import"./chunk-9hn0zpxj.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,vh as getCraftComponents,G as getSSRCacheStats,ka as injectCraftBridge,yh as isCraftEnvironment,Y as prerenderForCraft,Ca as processCraftComponents,bh as processCraftDirective,wh as registerCraftComponent,Q as renderSSR};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Return a hash only after its bytes are durable; callers can otherwise inline. */
|
|
2
|
+
export declare function registerCssServeAsset(css: string): string | undefined;
|
|
3
|
+
/** Synchronous for existing callers; disk is read only on a memory miss. */
|
|
4
|
+
export declare function getCssServeAsset(hash: string): string | undefined;
|
|
5
|
+
export declare function clearCssServeAssets(): void;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { stateDir } from "../state-dir.js";
|
|
4
|
+
const LIMIT = 256, assets = new Map, hashOf = (css) => Bun.hash(css).toString(16).padStart(16, "0").slice(0, 16), fileFor = (hash) => stateDir(process.cwd(), "css-assets", `${hash}.css`);
|
|
5
|
+
function remember(file, css) {
|
|
6
|
+
assets.delete(file);
|
|
7
|
+
assets.set(file, css);
|
|
8
|
+
if (assets.size > LIMIT)
|
|
9
|
+
assets.delete(assets.keys().next().value);
|
|
10
|
+
}
|
|
11
|
+
export function registerCssServeAsset(css) {
|
|
12
|
+
const hash = hashOf(css), file = fileFor(hash);
|
|
13
|
+
if (assets.has(file)) {
|
|
14
|
+
remember(file, css);
|
|
15
|
+
return hash;
|
|
16
|
+
}
|
|
17
|
+
let temporary;
|
|
18
|
+
try {
|
|
19
|
+
let existing;
|
|
20
|
+
try {
|
|
21
|
+
existing = fs.readFileSync(file, "utf8");
|
|
22
|
+
} catch {}
|
|
23
|
+
if (existing !== css) {
|
|
24
|
+
fs.mkdirSync(path.dirname(file), { recursive: !0 });
|
|
25
|
+
temporary = `${file}.${process.pid}.${crypto.randomUUID()}.tmp`;
|
|
26
|
+
fs.writeFileSync(temporary, css, { flag: "wx" });
|
|
27
|
+
fs.renameSync(temporary, file);
|
|
28
|
+
}
|
|
29
|
+
remember(file, css);
|
|
30
|
+
return hash;
|
|
31
|
+
} catch {
|
|
32
|
+
return;
|
|
33
|
+
} finally {
|
|
34
|
+
if (temporary)
|
|
35
|
+
try {
|
|
36
|
+
fs.unlinkSync(temporary);
|
|
37
|
+
} catch {}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export function getCssServeAsset(hash) {
|
|
41
|
+
if (!/^[a-f0-9]{16}$/.test(hash))
|
|
42
|
+
return;
|
|
43
|
+
const file = fileFor(hash), cached = assets.get(file);
|
|
44
|
+
if (cached !== void 0) {
|
|
45
|
+
remember(file, cached);
|
|
46
|
+
return cached;
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
const css = fs.readFileSync(file, "utf8");
|
|
50
|
+
if (hashOf(css) !== hash)
|
|
51
|
+
return;
|
|
52
|
+
remember(file, css);
|
|
53
|
+
return css;
|
|
54
|
+
} catch {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
export function clearCssServeAssets() {
|
|
59
|
+
assets.clear();
|
|
60
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export declare function getCssServeAsset(hash: string): string | undefined;
|
|
2
1
|
/**
|
|
3
2
|
* Lazily load the Css module
|
|
4
3
|
* Returns null if Css is not installed
|
|
@@ -99,3 +98,4 @@ declare interface CSSGenerator {
|
|
|
99
98
|
generate(className: string): void
|
|
100
99
|
toCSS(preflight: boolean, minify: boolean): string
|
|
101
100
|
}
|
|
101
|
+
export { getCssServeAsset } from './serve-css-assets';
|
|
@@ -7,6 +7,8 @@ import { stateDir } from "../state-dir.js";
|
|
|
7
7
|
import { dedupeScopedStyles, findDuplicateScopedStyleRanges } from "../style-scoping.js";
|
|
8
8
|
import { colors } from "./terminal-colors.js";
|
|
9
9
|
import { contentKey, renderMemo } from "../render-memo.js";
|
|
10
|
+
import { clearCssServeAssets, registerCssServeAsset } from "./serve-css-assets.js";
|
|
11
|
+
export { getCssServeAsset } from "./serve-css-assets.js";
|
|
10
12
|
let cssModule = null, cssEngineStamp = "";
|
|
11
13
|
function stampEngine(file) {
|
|
12
14
|
try {
|
|
@@ -17,7 +19,7 @@ function stampEngine(file) {
|
|
|
17
19
|
}
|
|
18
20
|
}
|
|
19
21
|
let cssLoadAttempted = !1, cachedConfig = null, cachedCSS = "", isBuilding = !1;
|
|
20
|
-
const MAX_CACHE = 256, cssByClassSet = new Map
|
|
22
|
+
const MAX_CACHE = 256, cssByClassSet = new Map;
|
|
21
23
|
let diskCacheRoot = null, configFingerprint = null;
|
|
22
24
|
const configByRoot = new Map, warnedRoleRoots = new Set;
|
|
23
25
|
function shortHash(input) {
|
|
@@ -30,23 +32,6 @@ function setLruCache(key, value) {
|
|
|
30
32
|
cssByClassSet.delete(cssByClassSet.keys().next().value);
|
|
31
33
|
cssByClassSet.set(key, value);
|
|
32
34
|
}
|
|
33
|
-
function registerServeCss(css) {
|
|
34
|
-
const hash = shortHash(css);
|
|
35
|
-
if (serveCssByHash.has(hash))
|
|
36
|
-
serveCssByHash.delete(hash);
|
|
37
|
-
else if (serveCssByHash.size >= MAX_CACHE)
|
|
38
|
-
serveCssByHash.delete(serveCssByHash.keys().next().value);
|
|
39
|
-
serveCssByHash.set(hash, css);
|
|
40
|
-
return hash;
|
|
41
|
-
}
|
|
42
|
-
export function getCssServeAsset(hash) {
|
|
43
|
-
const css = serveCssByHash.get(hash);
|
|
44
|
-
if (css === void 0)
|
|
45
|
-
return;
|
|
46
|
-
serveCssByHash.delete(hash);
|
|
47
|
-
serveCssByHash.set(hash, css);
|
|
48
|
-
return css;
|
|
49
|
-
}
|
|
50
35
|
async function readDiskCache(key, root = diskCacheRoot) {
|
|
51
36
|
if (!root)
|
|
52
37
|
return null;
|
|
@@ -182,7 +167,7 @@ export function resetCssCache() {
|
|
|
182
167
|
cachedConfig = null;
|
|
183
168
|
cachedCSS = "";
|
|
184
169
|
cssByClassSet.clear();
|
|
185
|
-
|
|
170
|
+
clearCssServeAssets();
|
|
186
171
|
configFingerprint = null;
|
|
187
172
|
configByRoot.clear();
|
|
188
173
|
}
|
|
@@ -435,7 +420,7 @@ export async function injectCss(htmlContent, appDir, serveMode = !1, dedupeRende
|
|
|
435
420
|
const css = await generateCss(htmlContent, appDir);
|
|
436
421
|
if (!css)
|
|
437
422
|
return dedupeRenderedScopedStyles ? dedupeScopedStyles(htmlContent) : htmlContent;
|
|
438
|
-
const
|
|
423
|
+
const serveHash = serveMode ? registerCssServeAsset(css) : void 0, assetTag = serveHash ? `<link data-css="generated" rel="stylesheet" href="/_stx/css.${serveHash}.css">` : `<style data-css="generated">
|
|
439
424
|
${css}
|
|
440
425
|
</style>`;
|
|
441
426
|
if (dedupeRenderedScopedStyles)
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Serialize an app's dictionary before its bundle is signed. Never splice raw XML. */
|
|
2
|
+
export declare function renderInfoPlist(entries: Readonly<Record<string, PlistValue>>): string;
|
|
3
|
+
/** Values supported by STX's Info.plist configuration (#2152). */
|
|
4
|
+
export type PlistValue = string | number | boolean | readonly PlistValue[] | { readonly [key: string]: PlistValue }
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const escapeXml = (value) => value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
2
|
+
export function renderInfoPlist(entries) {
|
|
3
|
+
const ancestors = new Set, render = (value, pad, location) => {
|
|
4
|
+
if (typeof value === "string")
|
|
5
|
+
return `${pad}<string>${escapeXml(value)}</string>`;
|
|
6
|
+
if (typeof value === "boolean")
|
|
7
|
+
return `${pad}<${value}/>`;
|
|
8
|
+
if (typeof value === "number") {
|
|
9
|
+
if (!Number.isFinite(value))
|
|
10
|
+
throw TypeError(`Non-finite Info.plist number at ${location}`);
|
|
11
|
+
const tag = Number.isSafeInteger(value) ? "integer" : "real";
|
|
12
|
+
return `${pad}<${tag}>${value}</${tag}>`;
|
|
13
|
+
}
|
|
14
|
+
if (value !== null && typeof value === "object") {
|
|
15
|
+
const array = Array.isArray(value);
|
|
16
|
+
if (!array && Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null)
|
|
17
|
+
throw TypeError(`Unsupported Info.plist value at ${location}`);
|
|
18
|
+
if (ancestors.has(value))
|
|
19
|
+
throw TypeError(`Cyclic Info.plist value at ${location}`);
|
|
20
|
+
ancestors.add(value);
|
|
21
|
+
try {
|
|
22
|
+
const tag = array ? "array" : "dict", indent = `${pad} `, children = array ? Array.from(value, (item, index) => render(item, indent, `${location}[${index}]`)) : Object.entries(value).map(([key, item]) => `${indent}<key>${escapeXml(key)}</key>
|
|
23
|
+
${render(item, indent, `${location}.${key}`)}`);
|
|
24
|
+
return children.length ? `${pad}<${tag}>
|
|
25
|
+
${children.join(`
|
|
26
|
+
`)}
|
|
27
|
+
${pad}</${tag}>` : `${pad}<${tag}/>`;
|
|
28
|
+
} finally {
|
|
29
|
+
ancestors.delete(value);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
throw TypeError(`Unsupported Info.plist value at ${location}`);
|
|
33
|
+
};
|
|
34
|
+
if (!entries || Array.isArray(entries) || typeof entries !== "object")
|
|
35
|
+
throw TypeError("Info.plist root must be a dictionary");
|
|
36
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
37
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
38
|
+
<plist version="1.0">
|
|
39
|
+
${render(entries, "", "infoPlist")}
|
|
40
|
+
</plist>
|
|
41
|
+
`;
|
|
42
|
+
}
|