@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
|
@@ -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 = [];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { accessibilityChanges, authoredAccessibilityProps, projectAccessibility } from "../accessibility.js";
|
|
1
|
+
import { ACCESSIBILITY_FIELDS, accessibilityChanges, authoredAccessibilityProps, isAccessibilityAttribute, projectAccessibility } from "../accessibility.js";
|
|
2
2
|
import { seedClassTable } from "../compiler/class-table.js";
|
|
3
3
|
import { compileClassStyles, NATIVE_STATE_VARIANTS } from "../compiler/headwind-to-style.js";
|
|
4
4
|
import { resolveIconName } from "../compiler/icons.js";
|
|
@@ -82,6 +82,28 @@ function flatName(name) {
|
|
|
82
82
|
}
|
|
83
83
|
return flat;
|
|
84
84
|
}
|
|
85
|
+
const nativeEventNames = new Map;
|
|
86
|
+
function nativeEventName(event) {
|
|
87
|
+
let name = nativeEventNames.get(event);
|
|
88
|
+
if (name === void 0) {
|
|
89
|
+
name = NATIVE_EVENT_NAMES[event.toLowerCase()] ?? event;
|
|
90
|
+
if (nativeEventNames.size >= 2000)
|
|
91
|
+
nativeEventNames.clear();
|
|
92
|
+
nativeEventNames.set(event, name);
|
|
93
|
+
}
|
|
94
|
+
return name;
|
|
95
|
+
}
|
|
96
|
+
const scriptEventNames = new Map;
|
|
97
|
+
function scriptOnlyEvent(event) {
|
|
98
|
+
let only = scriptEventNames.get(event);
|
|
99
|
+
if (only === void 0) {
|
|
100
|
+
only = NATIVE_EVENT_NAMES[event.toLowerCase()] === void 0 && !/^on[A-Z]/.test(event);
|
|
101
|
+
if (scriptEventNames.size >= 2000)
|
|
102
|
+
scriptEventNames.clear();
|
|
103
|
+
scriptEventNames.set(event, only);
|
|
104
|
+
}
|
|
105
|
+
return only;
|
|
106
|
+
}
|
|
85
107
|
function followsHref() {}
|
|
86
108
|
export function createNativeHost(options) {
|
|
87
109
|
const records = new Map, attributeObservers = new WeakMap, childObservers = new WeakMap, handlers = new Map, eventRegistrations = new WeakMap, componentListeners = new WeakMap, controlsWithDefaultListeners = new WeakSet, implicitSubmitListeners = new WeakMap, formResetCallbacks = new WeakMap, boundHrefs = new WeakMap;
|
|
@@ -312,6 +334,24 @@ export function createNativeHost(options) {
|
|
|
312
334
|
function hostProps(record) {
|
|
313
335
|
return { ...record.props, ...projectAccessibility(record.props, record.type), ...projectTextEntry(record.type, record.props) };
|
|
314
336
|
}
|
|
337
|
+
function createdProps(record) {
|
|
338
|
+
const props = record.props, created = {};
|
|
339
|
+
let accessible = record.type === "Image";
|
|
340
|
+
const names = Object.keys(props);
|
|
341
|
+
for (let i = 0;i < names.length; i++) {
|
|
342
|
+
const name = names[i], first = name.charCodeAt(0);
|
|
343
|
+
if (first === 100 ? name.startsWith("data-stx-") && name !== "data-stx-component-wrapper" : name === "__stxId")
|
|
344
|
+
continue;
|
|
345
|
+
if (!accessible && (first === 97 || first === 114))
|
|
346
|
+
accessible = isAccessibilityAttribute(name) || ACCESSIBILITY_FIELDS.includes(name);
|
|
347
|
+
created[name] = props[name];
|
|
348
|
+
}
|
|
349
|
+
if (accessible)
|
|
350
|
+
Object.assign(created, projectAccessibility(props, record.type));
|
|
351
|
+
if (record.type === "TextInput")
|
|
352
|
+
Object.assign(created, projectTextEntry(record.type, props));
|
|
353
|
+
return created;
|
|
354
|
+
}
|
|
315
355
|
function ariaState(value) {
|
|
316
356
|
return value === !0 || value === "true";
|
|
317
357
|
}
|
|
@@ -375,7 +415,7 @@ export function createNativeHost(options) {
|
|
|
375
415
|
let delegatedPress = !1;
|
|
376
416
|
if (pressable) {
|
|
377
417
|
for (let owner = node.__stxOwner;owner; owner = owner.__stxOwner)
|
|
378
|
-
if (componentListeners.get(owner)?.some((listener) => (
|
|
418
|
+
if (componentListeners.get(owner)?.some((listener) => nativeEventName(listener.event) === "onPress")) {
|
|
379
419
|
delegatedPress = !0;
|
|
380
420
|
break;
|
|
381
421
|
}
|
|
@@ -401,7 +441,7 @@ export function createNativeHost(options) {
|
|
|
401
441
|
} else if (!eligible && previous) {
|
|
402
442
|
previous.stop();
|
|
403
443
|
implicitSubmitListeners.delete(node);
|
|
404
|
-
if (!componentListeners.get(node)?.some((listener) => (
|
|
444
|
+
if (!componentListeners.get(node)?.some((listener) => nativeEventName(listener.event) === "onSubmitEditing")) {
|
|
405
445
|
const id = record.events.onSubmitEditing;
|
|
406
446
|
if (id)
|
|
407
447
|
handlers.delete(id);
|
|
@@ -428,7 +468,7 @@ export function createNativeHost(options) {
|
|
|
428
468
|
node: {
|
|
429
469
|
type: record.type,
|
|
430
470
|
...record.key === void 0 ? {} : { key: record.key },
|
|
431
|
-
props:
|
|
471
|
+
props: createdProps(record),
|
|
432
472
|
style: { ...record.style },
|
|
433
473
|
...Object.keys(record.events).length ? { events: { ...record.events } } : {},
|
|
434
474
|
...record.text === void 0 ? {} : { children: [record.text] }
|
|
@@ -445,7 +485,24 @@ export function createNativeHost(options) {
|
|
|
445
485
|
let resolvingId = "";
|
|
446
486
|
const reportStyle = (diagnostic) => {
|
|
447
487
|
console.warn(`[STX Native] ${diagnostic.kind}: ${resolvingId}: ${diagnostic.name}`);
|
|
448
|
-
}, NO_LAYERS = [];
|
|
488
|
+
}, NO_LAYERS = [], classMemos = new Map;
|
|
489
|
+
function classStylesOf(record, forStyle) {
|
|
490
|
+
const classes = record.forwardedClasses === void 0 ? `${record.classes} ` : `${record.classes} ${record.forwardedClasses}`, source = record.type === "TextInput" ? `\x01${classes}` : classes;
|
|
491
|
+
let memo = record.classMemo;
|
|
492
|
+
if (!memo || memo.source !== source || memo.variables !== record.variables || memo.scheme !== colorScheme) {
|
|
493
|
+
memo = classMemos.get(source);
|
|
494
|
+
if (!memo || memo.variables !== record.variables || memo.scheme !== colorScheme) {
|
|
495
|
+
memo = { source, variables: record.variables, scheme: colorScheme };
|
|
496
|
+
if (classMemos.size >= 2000)
|
|
497
|
+
classMemos.clear();
|
|
498
|
+
classMemos.set(source, memo);
|
|
499
|
+
}
|
|
500
|
+
record.classMemo = memo;
|
|
501
|
+
}
|
|
502
|
+
if (forStyle)
|
|
503
|
+
return memo.style ??= compileClassStyles(classes, record.variables, { focus: record.type === "TextInput", focusWithin: !0, rules: options.stylesheetRules, appearance: colorScheme, pointer: options.pointer === !0 });
|
|
504
|
+
return memo.props ??= compileClassStyles(classes, record.variables, { focus: record.type === "TextInput", focusWithin: !0, rules: options.stylesheetRules });
|
|
505
|
+
}
|
|
449
506
|
function resolveStyle(record, id) {
|
|
450
507
|
resolvingId = id;
|
|
451
508
|
const report = reportStyle;
|
|
@@ -456,7 +513,30 @@ export function createNativeHost(options) {
|
|
|
456
513
|
inherited = parseNativeStyleLayers([ancestors[i]], inherited, report).variables;
|
|
457
514
|
const resolved = parseNativeStyleLayers([record.styleSource, record.boundStyle, record.forwardedStyle], inherited, report);
|
|
458
515
|
record.variables = resolved.variables;
|
|
459
|
-
const classes =
|
|
516
|
+
const classes = classStylesOf(record, !0), plain = !classes.responsive?.length && !classes.states && !classes.disabled && !record.focusWithin && !record.focused && record.dividerStyle === void 0 && isBlank(record.layoutDefaults) && isBlank(record.baseStyle) && !isHiddenInput(record);
|
|
517
|
+
let kept;
|
|
518
|
+
const keptAs = `${colorScheme}${record.visible ? 1 : 0}`;
|
|
519
|
+
if (plain) {
|
|
520
|
+
let byFirst = resolvedStyles.get(classes);
|
|
521
|
+
if (!byFirst)
|
|
522
|
+
resolvedStyles.set(classes, byFirst = new WeakMap);
|
|
523
|
+
const first = layerKey(resolved.styles[0]);
|
|
524
|
+
let bySecond = byFirst.get(first);
|
|
525
|
+
if (!bySecond)
|
|
526
|
+
byFirst.set(first, bySecond = new WeakMap);
|
|
527
|
+
const second = layerKey(resolved.styles[1]);
|
|
528
|
+
let byThird = bySecond.get(second);
|
|
529
|
+
if (!byThird)
|
|
530
|
+
bySecond.set(second, byThird = new WeakMap);
|
|
531
|
+
const third = layerKey(resolved.styles[2]);
|
|
532
|
+
kept = byThird.get(third);
|
|
533
|
+
if (!kept)
|
|
534
|
+
byThird.set(third, kept = new Map);
|
|
535
|
+
const known = kept.get(keptAs);
|
|
536
|
+
if (known)
|
|
537
|
+
return { ...known };
|
|
538
|
+
}
|
|
539
|
+
const classStyle = { ...classes.style };
|
|
460
540
|
for (const layer of classes.responsive ?? []) {
|
|
461
541
|
widthBounds.min.add(layer.min);
|
|
462
542
|
if (layer.max !== void 0)
|
|
@@ -495,8 +575,17 @@ export function createNativeHost(options) {
|
|
|
495
575
|
style.pressStyle = { ...active.style, ...colorScheme === "dark" ? active.dark : {} };
|
|
496
576
|
if (!record.visible || isHiddenInput(record))
|
|
497
577
|
style.display = "none";
|
|
578
|
+
if (kept)
|
|
579
|
+
kept.set(keptAs, { ...style });
|
|
498
580
|
return style;
|
|
499
581
|
}
|
|
582
|
+
const resolvedStyles = new WeakMap, BLANK_LAYER = {};
|
|
583
|
+
function layerKey(style) {
|
|
584
|
+
return !style || isBlank(style) ? BLANK_LAYER : style;
|
|
585
|
+
}
|
|
586
|
+
function isBlank(value) {
|
|
587
|
+
return !value || Object.keys(value).length === 0;
|
|
588
|
+
}
|
|
500
589
|
function refreshFocusChain(node) {
|
|
501
590
|
for (let current = node;current; current = current.__stxOwner) {
|
|
502
591
|
const record = descriptorOf(current);
|
|
@@ -611,7 +700,7 @@ export function createNativeHost(options) {
|
|
|
611
700
|
emit({ op: "updateNode", id, patch: { style: { ...patch, ...style } } });
|
|
612
701
|
}
|
|
613
702
|
record.style = style;
|
|
614
|
-
const classes =
|
|
703
|
+
const classes = classStylesOf(record, !1), divideChanged = classes.divide !== record.divide && JSON.stringify(classes.divide) !== JSON.stringify(record.divide);
|
|
615
704
|
record.divide = classes.divide;
|
|
616
705
|
if (divideChanged || record.divide)
|
|
617
706
|
refreshDividersOf(record);
|
|
@@ -661,6 +750,9 @@ export function createNativeHost(options) {
|
|
|
661
750
|
visit(node);
|
|
662
751
|
return out;
|
|
663
752
|
}
|
|
753
|
+
function componentEventOnly(node, event) {
|
|
754
|
+
return isBindingNode(node) && node.hasAttribute("data-stx-component-wrapper") && scriptOnlyEvent(event);
|
|
755
|
+
}
|
|
664
756
|
function isBindingNode(node) {
|
|
665
757
|
return node.nodeType === 1;
|
|
666
758
|
}
|
|
@@ -834,7 +926,16 @@ export function createNativeHost(options) {
|
|
|
834
926
|
own.styleDirty = !0;
|
|
835
927
|
}
|
|
836
928
|
insertIntoBindingParent(parent, node, index);
|
|
837
|
-
|
|
929
|
+
}
|
|
930
|
+
const plainProps = new Map;
|
|
931
|
+
function plainProp(prop, type) {
|
|
932
|
+
const key = `${type}\x01${prop}`;
|
|
933
|
+
let plain = plainProps.get(key);
|
|
934
|
+
if (plain === void 0) {
|
|
935
|
+
plain = !(type === "Image" && prop === "alt" || prop === "role" || prop.startsWith("aria-") || prop.startsWith("accessibility") || TEXT_ENTRY_SOURCES.has(prop) || prop === "multiline" || prop === "disabled" || NATIVE_STATE_VARIANTS.has(prop) || type === "Icon" && prop === "name" || prop === "href" || SVG_NODE_TYPES.has(type));
|
|
936
|
+
plainProps.set(key, plain);
|
|
937
|
+
}
|
|
938
|
+
return plain;
|
|
838
939
|
}
|
|
839
940
|
function copyNode(node, source, copy) {
|
|
840
941
|
if (!isBindingNode(node))
|
|
@@ -1030,7 +1131,8 @@ export function createNativeHost(options) {
|
|
|
1030
1131
|
const forwarded = forwardedHostRoot(node, name);
|
|
1031
1132
|
reflectAttribute(node, name, value);
|
|
1032
1133
|
if (forwarded) {
|
|
1033
|
-
|
|
1134
|
+
if (forwarded !== node)
|
|
1135
|
+
reflectAttribute(forwarded, name, value);
|
|
1034
1136
|
if (applyForwardedStyle(forwarded, name, value))
|
|
1035
1137
|
return;
|
|
1036
1138
|
node = forwarded;
|
|
@@ -1042,7 +1144,18 @@ export function createNativeHost(options) {
|
|
|
1042
1144
|
applyClasses(node.__stxId, record);
|
|
1043
1145
|
return;
|
|
1044
1146
|
}
|
|
1045
|
-
const record = recordOf(node), prop = nativePropName(name, record.type)
|
|
1147
|
+
const record = recordOf(node), prop = nativePropName(name, record.type);
|
|
1148
|
+
if (plainProp(prop, record.type)) {
|
|
1149
|
+
record.props[prop] = value;
|
|
1150
|
+
if (record.focused && disabled(record)) {
|
|
1151
|
+
record.focused = !1;
|
|
1152
|
+
refreshFocusChain(node);
|
|
1153
|
+
}
|
|
1154
|
+
if (record.materialized)
|
|
1155
|
+
emit({ op: "updateNode", id: node.__stxId, patch: { props: { [prop]: value } } });
|
|
1156
|
+
return;
|
|
1157
|
+
}
|
|
1158
|
+
const accessibilityBefore = record.type === "Image" && prop === "alt" || prop === "role" || prop.startsWith("aria-") || prop.startsWith("accessibility") ? projectAccessibility(record.props, record.type) : void 0, textEntryBefore = TEXT_ENTRY_SOURCES.has(prop) ? projectTextEntry(record.type, record.props) : void 0, wasDisabled = disabled(record);
|
|
1046
1159
|
record.props[prop] = value;
|
|
1047
1160
|
if (TEXT_ENTRY_SOURCES.has(prop) || prop === "multiline")
|
|
1048
1161
|
syncImplicitSubmit(node);
|
|
@@ -1196,15 +1309,23 @@ export function createNativeHost(options) {
|
|
|
1196
1309
|
listen(node, event, handler, options) {
|
|
1197
1310
|
if (disposed)
|
|
1198
1311
|
return () => {};
|
|
1199
|
-
const listenerOptions = options
|
|
1312
|
+
const listenerOptions = options;
|
|
1313
|
+
let listeners = componentListeners.get(node);
|
|
1314
|
+
if (!listeners)
|
|
1315
|
+
componentListeners.set(node, listeners = []);
|
|
1316
|
+
const listener = { event, handler, once: !!listenerOptions?.once, capture: !!listenerOptions?.capture };
|
|
1200
1317
|
listeners.push(listener);
|
|
1201
|
-
componentListeners.set(node, listeners);
|
|
1202
1318
|
const unsubscribe = () => {
|
|
1203
1319
|
const index = listeners.indexOf(listener);
|
|
1204
1320
|
if (index !== -1)
|
|
1205
1321
|
listeners.splice(index, 1);
|
|
1206
|
-
}
|
|
1207
|
-
|
|
1322
|
+
};
|
|
1323
|
+
if (componentEventOnly(node, event))
|
|
1324
|
+
return unsubscribe;
|
|
1325
|
+
const nativeEvent = nativeEventName(event), record = recordOf(node);
|
|
1326
|
+
let registrations = eventRegistrations.get(node);
|
|
1327
|
+
if (!registrations)
|
|
1328
|
+
eventRegistrations.set(node, registrations = new Map);
|
|
1208
1329
|
const existing = registrations.get(nativeEvent);
|
|
1209
1330
|
if (existing && handlers.has(existing))
|
|
1210
1331
|
return unsubscribe;
|
|
@@ -1247,7 +1368,7 @@ export function createNativeHost(options) {
|
|
|
1247
1368
|
Object.defineProperty(physical, "currentTarget", { configurable: !0, value: target });
|
|
1248
1369
|
const group = componentListeners.get(target) ?? [];
|
|
1249
1370
|
for (const current of [...group]) {
|
|
1250
|
-
if ((
|
|
1371
|
+
if (nativeEventName(current.event) !== nativeEvent || current.capture !== capture)
|
|
1251
1372
|
continue;
|
|
1252
1373
|
if (target !== node && (current.event === "blur" || current.event === "focus"))
|
|
1253
1374
|
continue;
|
|
@@ -1290,7 +1411,7 @@ export function createNativeHost(options) {
|
|
|
1290
1411
|
}
|
|
1291
1412
|
const form = formOwner(node);
|
|
1292
1413
|
if (form && nativeEvent === "onSubmitEditing" && !physical?.defaultPrevented && !record.props.multiline && hostProps(record).returnKeyType !== "next") {
|
|
1293
|
-
const implicit = implicitSubmitListeners.get(node), authored = componentListeners.get(node)?.some((listener) => (
|
|
1414
|
+
const implicit = implicitSubmitListeners.get(node), authored = componentListeners.get(node)?.some((listener) => nativeEventName(listener.event) === "onSubmitEditing" && listener.handler !== implicit?.listener);
|
|
1294
1415
|
if (implicit && !authored) {
|
|
1295
1416
|
const submitter = collectDescendants(form).find((control) => {
|
|
1296
1417
|
const candidate = descriptorOf(control);
|
|
@@ -1314,7 +1435,7 @@ export function createNativeHost(options) {
|
|
|
1314
1435
|
record.events[nativeEvent] = id;
|
|
1315
1436
|
if (record.materialized)
|
|
1316
1437
|
emit({ op: "updateNode", id: node.__stxId, patch: { events: { [nativeEvent]: id } } });
|
|
1317
|
-
if (nativeEvent === "onPress") {
|
|
1438
|
+
if (nativeEvent === "onPress" && record.children.length) {
|
|
1318
1439
|
for (const child of collectDescendants(node))
|
|
1319
1440
|
if (["Button", "Pressable"].includes(descriptorOf(child)?.type ?? ""))
|
|
1320
1441
|
installControlListeners(child);
|
package/dist/native-build.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { type MacOSSigningOptions } from './native-signing';
|
|
2
|
+
import { type PlistValue } from './info-plist';
|
|
3
|
+
export type { PlistValue } from './info-plist';
|
|
2
4
|
/**
|
|
3
5
|
* Build an stx template into a native application
|
|
4
6
|
*/
|
|
@@ -74,7 +76,7 @@ export declare interface NativeBuildConfig {
|
|
|
74
76
|
hideDockIcon?: boolean
|
|
75
77
|
menubarOnly?: boolean
|
|
76
78
|
trayPopover?: boolean
|
|
77
|
-
infoPlist?: Record<string,
|
|
79
|
+
infoPlist?: Record<string, PlistValue>
|
|
78
80
|
minimumSystemVersion?: string
|
|
79
81
|
category?: string
|
|
80
82
|
copyright?: string
|
package/dist/native-build.js
CHANGED
|
@@ -2,13 +2,14 @@ var {require}=import.meta;import { existsSync, mkdirSync, copyFileSync, chmodSyn
|
|
|
2
2
|
import { join, dirname, basename, resolve } from "node:path";
|
|
3
3
|
import { spawn } from "node:child_process";
|
|
4
4
|
import { platform as osPlatform } from "node:os";
|
|
5
|
-
import { resolveCraftExecutablePath } from "@stacksjs/desktop";
|
|
5
|
+
import { createDiskImage, resolveCraftExecutablePath } from "@stacksjs/desktop";
|
|
6
6
|
import { injectCraftBridge } from "./craft-bridge.js";
|
|
7
7
|
import { processCraftComponents, CRAFT_COMPONENT_STYLES } from "./craft-components.js";
|
|
8
8
|
import { renderTemplate } from "./render.js";
|
|
9
9
|
import { loadStxConfig } from "./config.js";
|
|
10
10
|
import { createTempDir, removeTempDir } from "./temp-dir.js";
|
|
11
11
|
import { signMacOSBundle } from "./native-signing.js";
|
|
12
|
+
import { renderInfoPlist } from "./info-plist.js";
|
|
12
13
|
export async function buildNative(config) {
|
|
13
14
|
if (config.window?.cornerRadius !== void 0 && (!Number.isFinite(config.window.cornerRadius) || config.window.cornerRadius < 0 || config.window.cornerRadius > 128))
|
|
14
15
|
throw Error("Native window cornerRadius must be between 0 and 128");
|
|
@@ -296,24 +297,6 @@ ${stderr}`.match(/(\d+)\.(\d+)\.(\d+)/);
|
|
|
296
297
|
return !1;
|
|
297
298
|
}
|
|
298
299
|
}
|
|
299
|
-
function escapeXml(value) {
|
|
300
|
-
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
301
|
-
}
|
|
302
|
-
function renderInfoPlist(entries) {
|
|
303
|
-
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
304
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
305
|
-
<plist version="1.0">
|
|
306
|
-
<dict>
|
|
307
|
-
${Object.entries(entries).map(([key, value]) => {
|
|
308
|
-
const rendered = typeof value === "boolean" ? `<${value}/>` : typeof value === "number" ? `<integer>${value}</integer>` : `<string>${escapeXml(String(value))}</string>`;
|
|
309
|
-
return ` <key>${escapeXml(key)}</key>
|
|
310
|
-
${rendered}`;
|
|
311
|
-
}).join(`
|
|
312
|
-
`)}
|
|
313
|
-
</dict>
|
|
314
|
-
</plist>
|
|
315
|
-
`;
|
|
316
|
-
}
|
|
317
300
|
async function buildWindows(html, appName, appVersion, outputDir, format, config, craftPath) {
|
|
318
301
|
const appDir = join(outputDir, appName);
|
|
319
302
|
mkdirSync(appDir, { recursive: !0 });
|
|
@@ -432,28 +415,7 @@ function getDefaultFormat(target) {
|
|
|
432
415
|
}
|
|
433
416
|
}
|
|
434
417
|
async function createDMG(appBundlePath, outputPath, volumeName) {
|
|
435
|
-
return
|
|
436
|
-
const proc = spawn("hdiutil", [
|
|
437
|
-
"create",
|
|
438
|
-
"-volname",
|
|
439
|
-
volumeName,
|
|
440
|
-
"-srcfolder",
|
|
441
|
-
appBundlePath,
|
|
442
|
-
"-ov",
|
|
443
|
-
"-format",
|
|
444
|
-
"UDZO",
|
|
445
|
-
outputPath
|
|
446
|
-
]);
|
|
447
|
-
proc.on("close", (code) => {
|
|
448
|
-
if (code === 0)
|
|
449
|
-
resolve({ success: !0 });
|
|
450
|
-
else
|
|
451
|
-
resolve({ success: !1, error: `hdiutil exited with code ${code}` });
|
|
452
|
-
});
|
|
453
|
-
proc.on("error", (err) => {
|
|
454
|
-
resolve({ success: !1, error: err.message });
|
|
455
|
-
});
|
|
456
|
-
});
|
|
418
|
+
return createDiskImage({ appBundlePath, outputPath, volumeName });
|
|
457
419
|
}
|
|
458
420
|
async function createZip(sourceDir, outputPath) {
|
|
459
421
|
return new Promise((resolve) => {
|
package/dist/pwa.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{
|
|
3
|
-
Icon generation requires the sharp package for image processing.`),e.success=!1,e}let g=await c.default(o).metadata();if(g.width&&g.width<512)e.warnings.push(`Source icon is ${g.width}x${g.height}. Recommend using at least 512x512 for best quality.`);for(let i of s){let d=u.join(a,`icon-${i}x${i}.png`);if(await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d),l){let x=u.join(a,`icon-${i}x${i}.webp`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile(x),e.generatedFiles.push(x)}}if(p){for(let d of S){let x=u.join(a,`apple-touch-icon-${d}x${d}.png`);await c.default(o).resize(d,d,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(x),e.generatedFiles.push(x)}let i=u.join(a,"apple-touch-icon.png");await c.default(o).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(i),e.generatedFiles.push(i)}for(let i of P){let d=u.join(a,`favicon-${i}x${i}.png`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d)}let f=512,y=u.join(a,`icon-maskable-${f}x${f}.png`),m=Math.floor(f*0.1),k=f-m*2;await c.default(o).resize(k,k,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:m,bottom:m,left:m,right:m,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(y),e.generatedFiles.push(y)}catch(c){let h=c instanceof Error?c.message:String(c);e.errors.push(`Icon generation failed: ${h}`),e.success=!1}return e}function N(n){let t=n.sizes||v,e=n.outputDir?`/${n.outputDir}`:"/pwa-icons",r=n.generateWebP??!0,o=n.generateAppleIcons??!0,a=[];for(let s of t)if(a.push(`${e}/icon-${s}x${s}.png`),r)a.push(`${e}/icon-${s}x${s}.webp`);if(o){a.push(`${e}/apple-touch-icon.png`);for(let s of S)a.push(`${e}/apple-touch-icon-${s}x${s}.png`)}for(let s of P)a.push(`${e}/favicon-${s}x${s}.png`);return a.push(`${e}/icon-maskable-512x512.png`),a}async function I(){try{return await import("sharp"),!0}catch{return!1}}function A(n,t,e,r){let o=[],a=r.join(" ");for(let s of n)if(o.push({src:`${t}/icon-${s}x${s}.png`,sizes:`${s}x${s}`,type:"image/png",purpose:a}),e)o.push({src:`${t}/icon-${s}x${s}.webp`,sizes:`${s}x${s}`,type:"image/webp",purpose:a});return o}function C(n){return n.map((t)=>({name:t.name,short_name:t.shortName,description:t.description,url:t.url,icons:t.icons?.map((e)=>({src:e.src,sizes:e.sizes,type:e.type}))}))}function T(n){let t=n.pwa?.shareTarget;if(!t?.enabled)return;let e={action:t.action||"/share",method:t.method||"POST",enctype:t.enctype||"multipart/form-data",params:{title:t.params?.title||"title",text:t.params?.text||"text",url:t.params?.url||"url"}};if(t.acceptFiles&&t.acceptFiles.length>0)e.params.files=t.acceptFiles.map((r)=>({name:r.name,accept:r.accept}));return e}function H(n){let t=n.pwa?.fileHandlers;if(!t?.enabled||!t.accept)return;let e=[{action:t.action||"/",accept:t.accept,launch_type:t.launchType||"single-client"}];if(t.icons)e[0].icons=t.icons.map((r)=>({src:r.src,sizes:r.sizes,type:r.type}));return e}function W(n){let t=n.pwa?.protocolHandlers;if(!t||t.length===0)return;return t.map((e)=>({protocol:e.protocol,url:e.url}))}function j(n){let t=n.pwa;if(!t?.enabled||!t.manifest)return null;let{manifest:e,icons:r}=t,o=r?.sizes||[72,96,128,144,152,192,384,512],a=r?.outputDir?`/${r.outputDir}`:"/pwa-icons",s=r?.generateWebP??!0,l=r?.purpose||["any","maskable"],p={name:e.name,short_name:e.shortName||e.name,description:e.description,start_url:e.startUrl||"/",display:e.display||"standalone",display_override:e.displayOverride,orientation:e.orientation,theme_color:e.themeColor,background_color:e.backgroundColor,scope:e.scope||"/",lang:e.lang,dir:e.dir,id:e.id,categories:e.categories,icons:A(o,a,s,l)};if(e.shortcuts&&e.shortcuts.length>0)p.shortcuts=C(e.shortcuts);if(e.screenshots&&e.screenshots.length>0)p.screenshots=e.screenshots.map((f)=>({src:f.src,sizes:f.sizes,type:f.type,label:f.label,form_factor:f.platform}));let c=T(n);if(c)p.share_target=c;let h=H(n);if(h)p.file_handlers=h;let g=W(n);if(g)p.protocol_handlers=g;if(e.launchHandler)p.launch_handler={client_mode:e.launchHandler};if(e.handleLinks)p.handle_links=e.handleLinks;if(e.edgeSidePanel?.enabled)p.edge_side_panel={preferred_width:e.edgeSidePanel.preferredWidth};return p}function _(n){let t=j(n);if(!t)return"";let e=JSON.parse(JSON.stringify(t));return JSON.stringify(e,null,2)}function q(n,t){return{...t,...n,shortcuts:n.shortcuts||t.shortcuts,screenshots:n.screenshots||t.screenshots,categories:n.categories||t.categories}}function D(n){let t=[],e=n.pwa;if(!e?.enabled)return t;let r=e.manifest;if(!r)return t.push("PWA manifest configuration is missing"),t;if(!r.name)t.push("Manifest name is required");let o=["fullscreen","standalone","minimal-ui","browser"];if(r.display&&!o.includes(r.display))t.push(`Invalid display mode: ${r.display}. Must be one of: ${o.join(", ")}`);let a=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(r.orientation&&!a.includes(r.orientation))t.push(`Invalid orientation: ${r.orientation}`);let s=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(r.themeColor&&!s.test(r.themeColor))t.push(`Invalid theme color: ${r.themeColor}. Must be a valid hex color.`);if(r.backgroundColor&&!s.test(r.backgroundColor))t.push(`Invalid background color: ${r.backgroundColor}. Must be a valid hex color.`);if(e.shareTarget?.enabled){if(!e.shareTarget.action)t.push("Share target action URL is required")}if(e.fileHandlers?.enabled){if(!e.fileHandlers.accept||Object.keys(e.fileHandlers.accept).length===0)t.push("File handlers must specify accepted MIME types")}if(e.protocolHandlers)for(let l of e.protocolHandlers){if(!l.protocol)t.push("Protocol handler missing protocol");if(!l.url||!l.url.includes("%s"))t.push(`Protocol handler URL must contain %s placeholder: ${l.protocol}`)}return t}import z from"path";async function F(n){let t=n.pwa?.offline;if(!t?.enabled)return"";if(t.page){let e=z.isAbsolute(t.page)?t.page:z.resolve(process.cwd(),t.page);if(await Bun.file(e).exists())try{let{processDirectives:r}=await import("./chunk-
|
|
2
|
+
import{eo,Ht,Sl,Cg}from"./chunk-83myk906.js";import{Qs,Ii,Sg,kg,_g}from"./chunk-t5vjt37c.js";import{wl,vl,xl,vg,xg}from"./chunk-d8rcba53.js";import{Ue,Tn,Oi}from"./chunk-y9bj3566.js";import{Eg,Tg,$g,Rg,to,dy}from"./chunk-gqjb1y7c.js";import B from"fs";import w from"path";import O from"fs";import u from"path";var v=[72,96,128,144,152,192,384,512],S=[120,152,167,180],P=[16,32];async function M(n,t){let e={success:!0,generatedFiles:[],errors:[],warnings:[]},r=n.pwa?.icons;if(!r?.src)return e.errors.push("No source icon specified in pwa.icons.src"),e.success=!1,e;let o=u.isAbsolute(r.src)?r.src:u.resolve(process.cwd(),r.src);if(!await Bun.file(o).exists())return e.errors.push(`Source icon not found: ${o}`),e.success=!1,e;let a=u.resolve(t,r.outputDir||"pwa-icons");try{O.mkdirSync(a,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${a}`),e.success=!1,e}let s=r.sizes||v,l=r.generateWebP??!0,p=r.generateAppleIcons??!0;try{let c;try{c=await import("sharp")}catch{return e.errors.push(`sharp is not installed. Install it with: bun add sharp
|
|
3
|
+
Icon generation requires the sharp package for image processing.`),e.success=!1,e}let g=await c.default(o).metadata();if(g.width&&g.width<512)e.warnings.push(`Source icon is ${g.width}x${g.height}. Recommend using at least 512x512 for best quality.`);for(let i of s){let d=u.join(a,`icon-${i}x${i}.png`);if(await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d),l){let x=u.join(a,`icon-${i}x${i}.webp`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile(x),e.generatedFiles.push(x)}}if(p){for(let d of S){let x=u.join(a,`apple-touch-icon-${d}x${d}.png`);await c.default(o).resize(d,d,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(x),e.generatedFiles.push(x)}let i=u.join(a,"apple-touch-icon.png");await c.default(o).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(i),e.generatedFiles.push(i)}for(let i of P){let d=u.join(a,`favicon-${i}x${i}.png`);await c.default(o).resize(i,i,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(d),e.generatedFiles.push(d)}let f=512,y=u.join(a,`icon-maskable-${f}x${f}.png`),m=Math.floor(f*0.1),k=f-m*2;await c.default(o).resize(k,k,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:m,bottom:m,left:m,right:m,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(y),e.generatedFiles.push(y)}catch(c){let h=c instanceof Error?c.message:String(c);e.errors.push(`Icon generation failed: ${h}`),e.success=!1}return e}function N(n){let t=n.sizes||v,e=n.outputDir?`/${n.outputDir}`:"/pwa-icons",r=n.generateWebP??!0,o=n.generateAppleIcons??!0,a=[];for(let s of t)if(a.push(`${e}/icon-${s}x${s}.png`),r)a.push(`${e}/icon-${s}x${s}.webp`);if(o){a.push(`${e}/apple-touch-icon.png`);for(let s of S)a.push(`${e}/apple-touch-icon-${s}x${s}.png`)}for(let s of P)a.push(`${e}/favicon-${s}x${s}.png`);return a.push(`${e}/icon-maskable-512x512.png`),a}async function I(){try{return await import("sharp"),!0}catch{return!1}}function A(n,t,e,r){let o=[],a=r.join(" ");for(let s of n)if(o.push({src:`${t}/icon-${s}x${s}.png`,sizes:`${s}x${s}`,type:"image/png",purpose:a}),e)o.push({src:`${t}/icon-${s}x${s}.webp`,sizes:`${s}x${s}`,type:"image/webp",purpose:a});return o}function C(n){return n.map((t)=>({name:t.name,short_name:t.shortName,description:t.description,url:t.url,icons:t.icons?.map((e)=>({src:e.src,sizes:e.sizes,type:e.type}))}))}function T(n){let t=n.pwa?.shareTarget;if(!t?.enabled)return;let e={action:t.action||"/share",method:t.method||"POST",enctype:t.enctype||"multipart/form-data",params:{title:t.params?.title||"title",text:t.params?.text||"text",url:t.params?.url||"url"}};if(t.acceptFiles&&t.acceptFiles.length>0)e.params.files=t.acceptFiles.map((r)=>({name:r.name,accept:r.accept}));return e}function H(n){let t=n.pwa?.fileHandlers;if(!t?.enabled||!t.accept)return;let e=[{action:t.action||"/",accept:t.accept,launch_type:t.launchType||"single-client"}];if(t.icons)e[0].icons=t.icons.map((r)=>({src:r.src,sizes:r.sizes,type:r.type}));return e}function W(n){let t=n.pwa?.protocolHandlers;if(!t||t.length===0)return;return t.map((e)=>({protocol:e.protocol,url:e.url}))}function j(n){let t=n.pwa;if(!t?.enabled||!t.manifest)return null;let{manifest:e,icons:r}=t,o=r?.sizes||[72,96,128,144,152,192,384,512],a=r?.outputDir?`/${r.outputDir}`:"/pwa-icons",s=r?.generateWebP??!0,l=r?.purpose||["any","maskable"],p={name:e.name,short_name:e.shortName||e.name,description:e.description,start_url:e.startUrl||"/",display:e.display||"standalone",display_override:e.displayOverride,orientation:e.orientation,theme_color:e.themeColor,background_color:e.backgroundColor,scope:e.scope||"/",lang:e.lang,dir:e.dir,id:e.id,categories:e.categories,icons:A(o,a,s,l)};if(e.shortcuts&&e.shortcuts.length>0)p.shortcuts=C(e.shortcuts);if(e.screenshots&&e.screenshots.length>0)p.screenshots=e.screenshots.map((f)=>({src:f.src,sizes:f.sizes,type:f.type,label:f.label,form_factor:f.platform}));let c=T(n);if(c)p.share_target=c;let h=H(n);if(h)p.file_handlers=h;let g=W(n);if(g)p.protocol_handlers=g;if(e.launchHandler)p.launch_handler={client_mode:e.launchHandler};if(e.handleLinks)p.handle_links=e.handleLinks;if(e.edgeSidePanel?.enabled)p.edge_side_panel={preferred_width:e.edgeSidePanel.preferredWidth};return p}function _(n){let t=j(n);if(!t)return"";let e=JSON.parse(JSON.stringify(t));return JSON.stringify(e,null,2)}function q(n,t){return{...t,...n,shortcuts:n.shortcuts||t.shortcuts,screenshots:n.screenshots||t.screenshots,categories:n.categories||t.categories}}function D(n){let t=[],e=n.pwa;if(!e?.enabled)return t;let r=e.manifest;if(!r)return t.push("PWA manifest configuration is missing"),t;if(!r.name)t.push("Manifest name is required");let o=["fullscreen","standalone","minimal-ui","browser"];if(r.display&&!o.includes(r.display))t.push(`Invalid display mode: ${r.display}. Must be one of: ${o.join(", ")}`);let a=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(r.orientation&&!a.includes(r.orientation))t.push(`Invalid orientation: ${r.orientation}`);let s=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(r.themeColor&&!s.test(r.themeColor))t.push(`Invalid theme color: ${r.themeColor}. Must be a valid hex color.`);if(r.backgroundColor&&!s.test(r.backgroundColor))t.push(`Invalid background color: ${r.backgroundColor}. Must be a valid hex color.`);if(e.shareTarget?.enabled){if(!e.shareTarget.action)t.push("Share target action URL is required")}if(e.fileHandlers?.enabled){if(!e.fileHandlers.accept||Object.keys(e.fileHandlers.accept).length===0)t.push("File handlers must specify accepted MIME types")}if(e.protocolHandlers)for(let l of e.protocolHandlers){if(!l.protocol)t.push("Protocol handler missing protocol");if(!l.url||!l.url.includes("%s"))t.push(`Protocol handler URL must contain %s placeholder: ${l.protocol}`)}return t}import z from"path";async function F(n){let t=n.pwa?.offline;if(!t?.enabled)return"";if(t.page){let e=z.isAbsolute(t.page)?t.page:z.resolve(process.cwd(),t.page);if(await Bun.file(e).exists())try{let{processDirectives:r}=await import("./chunk-p5efqqtk.js"),o=await Bun.file(e).text();return await r(o,{},e,n,new Set)}catch(r){console.warn(`[PWA] Failed to process custom offline page: ${r}`)}else console.warn(`[PWA] Custom offline page not found: ${e}`)}return E(n)}function E(n){let t=n.pwa?.offline,e=n.pwa?.manifest,r=t?.fallbackTitle||"You are offline",o=t?.fallbackMessage||"Please check your internet connection and try again.",a=e?.themeColor||"#4f46e5",s=e?.shortName||e?.name||"App";return`<!DOCTYPE html>
|
|
4
4
|
<html lang="en">
|
|
5
5
|
<head>
|
|
6
6
|
<meta charset="UTF-8">
|
|
@@ -233,4 +233,4 @@ Icon generation requires the sharp package for image processing.`),e.success=!1,
|
|
|
233
233
|
}, 5000);
|
|
234
234
|
</script>
|
|
235
235
|
</body>
|
|
236
|
-
</html>`}function b(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}async function re(n,t){let e={success:!0,files:{icons:[]},errors:[],warnings:[]},r=n.pwa;if(!r?.enabled)return e;try{B.mkdirSync(t,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${t}`),e.success=!1,e}try{let a=_(n);if(a){let s=w.join(t,"manifest.json");await Bun.write(s,a),e.files.manifest=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate manifest.json: ${s}`),e.success=!1}if(r.icons?.src)if(await I()){let s=await M(n,t);if(e.files.icons=s.generatedFiles,e.warnings.push(...s.warnings),!s.success)e.errors.push(...s.errors),e.success=!1}else e.warnings.push("sharp is not installed. Skipping icon generation. Install with: bun add sharp");if(r.offline?.enabled)try{let a=await F(n);if(a){let s=w.join(t,"offline.html");await Bun.write(s,a),e.files.offlinePage=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate offline page: ${s}`),e.success=!1}let o;if(r.precache?.enabled){let a=Ue(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=
|
|
236
|
+
</html>`}function b(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}async function re(n,t){let e={success:!0,files:{icons:[]},errors:[],warnings:[]},r=n.pwa;if(!r?.enabled)return e;try{B.mkdirSync(t,{recursive:!0})}catch{return e.errors.push(`Failed to create output directory: ${t}`),e.success=!1,e}try{let a=_(n);if(a){let s=w.join(t,"manifest.json");await Bun.write(s,a),e.files.manifest=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate manifest.json: ${s}`),e.success=!1}if(r.icons?.src)if(await I()){let s=await M(n,t);if(e.files.icons=s.generatedFiles,e.warnings.push(...s.warnings),!s.success)e.errors.push(...s.errors),e.success=!1}else e.warnings.push("sharp is not installed. Skipping icon generation. Install with: bun add sharp");if(r.offline?.enabled)try{let a=await F(n);if(a){let s=w.join(t,"offline.html");await Bun.write(s,a),e.files.offlinePage=s}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate offline page: ${s}`),e.success=!1}let o;if(r.precache?.enabled){let a=Ue(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=eo(n,t);if(a){let s=Ht(n),l=w.join(t,s);await Bun.write(l,a),e.files.serviceWorker=l}}catch(a){let s=a instanceof Error?a.message:String(a);e.errors.push(`Failed to generate service worker: ${s}`),e.success=!1}return e}function ae(n,t){return Ii(n,t)}function se(n){return n.pwa?.enabled===!0}export{S as APPLE_TOUCH_ICON_SIZES,v as DEFAULT_ICON_SIZES,P as FAVICON_SIZES,vl as auditBuildOutput,wl as auditConfig,re as buildPwaAssets,xl as calculateAuditResult,xg as formatAuditResult,Oi as formatSize,j as generateManifest,_ as generateManifestJson,kg as generateManifestLink,F as generateOfflinePage,Ue as generatePrecacheManifest,Tn as generatePrecacheManifestJs,M as generatePwaIcons,Qs as generatePwaTags,eo as generateServiceWorker,Cg as generateServiceWorkerAuto,Sg as generateSwRegistrationScript,_g as generateThemeColorMeta,N as getExpectedIconPaths,Ht as getServiceWorkerFileName,Ii as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,Sl as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,to as pwaDirectives,Eg as pwaInstallDirective,$g as pwaOfflineDirective,Rg as pwaPushDirective,Tg as pwaUpdateDirective,dy as registerPwaDirectives,vg as runPwaAudit,D as validateManifest};
|