@stacksjs/stx 0.2.604 → 0.2.606
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-38mt83wa.js → chunk-06wv8qwy.js} +6 -6
- package/dist/chunk-0d6b3eeb.js +2 -0
- package/dist/{chunk-9cgga2aw.js → chunk-0v89nfz1.js} +2 -2
- package/dist/chunk-1e28n9q2.js +2 -0
- package/dist/chunk-1fdrhfc0.js +2 -0
- package/dist/{chunk-htcptqtn.js → chunk-1jxdkp8x.js} +6 -6
- package/dist/chunk-1veeefpn.js +2 -0
- package/dist/{chunk-6eg9a3mt.js → chunk-20k77e2a.js} +4 -4
- package/dist/chunk-2r4an7bh.js +2 -0
- package/dist/chunk-304vaxnk.js +2 -0
- package/dist/chunk-327bt8zb.js +2 -0
- package/dist/chunk-36n8yz6t.js +2 -0
- package/dist/{chunk-jczknjbw.js → chunk-3cnwstra.js} +2 -2
- package/dist/chunk-3gm6013p.js +2 -0
- package/dist/chunk-3ttnn4t3.js +2 -0
- package/dist/chunk-3yttgk0s.js +2 -0
- package/dist/chunk-4ck2xc8m.js +2 -0
- package/dist/{chunk-rd7w0cx4.js → chunk-4dfqgmgs.js} +39 -39
- package/dist/chunk-4jasfhh6.js +2 -0
- package/dist/{chunk-axz1x4r9.js → chunk-4tj0ap61.js} +5 -5
- package/dist/{chunk-9nt3q23a.js → chunk-53y4z4p2.js} +3 -3
- package/dist/{chunk-j1dmkt29.js → chunk-5e182xqt.js} +1 -1
- package/dist/{chunk-67m2prah.js → chunk-5s47qfp6.js} +2 -2
- package/dist/{chunk-bn7fzfc2.js → chunk-5taenpfg.js} +1 -1
- package/dist/chunk-605c6zks.js +2 -0
- package/dist/chunk-61d0gr5b.js +2 -0
- package/dist/{chunk-1944jgb2.js → chunk-67tpacz0.js} +1 -1
- package/dist/{chunk-9h1ytsgm.js → chunk-6by8dtan.js} +2 -2
- package/dist/{chunk-k71e38fk.js → chunk-6xsm53pz.js} +4 -4
- package/dist/{chunk-tc3ne706.js → chunk-7095f0hb.js} +9 -9
- package/dist/chunk-7renf4zp.js +2 -0
- package/dist/{chunk-9wtb959p.js → chunk-81qmj3sd.js} +7 -7
- package/dist/chunk-8t3c2myr.js +2 -0
- package/dist/chunk-8x2ejkcc.js +2 -0
- package/dist/chunk-915s0may.js +2 -0
- package/dist/chunk-93na8hh0.js +2 -0
- package/dist/{chunk-de3gknmn.js → chunk-9734nkc8.js} +3 -3
- package/dist/chunk-9fpnnfr3.js +2 -0
- package/dist/{chunk-ftr0fvw7.js → chunk-9zwdpa7p.js} +5 -5
- package/dist/chunk-ajd5w5c4.js +2 -0
- package/dist/{chunk-nfht2ryp.js → chunk-azpkje69.js} +8 -5
- package/dist/chunk-b4tbqz8r.js +2 -0
- package/dist/chunk-be2kmw0p.js +2 -0
- package/dist/{chunk-48s1nprc.js → chunk-bhf9yt2w.js} +2 -2
- package/dist/chunk-bkjre6xk.js +127 -0
- package/dist/chunk-bnpb6ez9.js +2 -0
- package/dist/{chunk-jtq8e3b0.js → chunk-bsy8v1xj.js} +2 -2
- package/dist/chunk-c0h9cxew.js +2 -0
- package/dist/{chunk-zrw1zf54.js → chunk-cfpenvc7.js} +3 -3
- package/dist/chunk-cw76y2p5.js +2 -0
- package/dist/chunk-d0kes50w.js +2 -0
- package/dist/{chunk-4st1qw62.js → chunk-dmdhbwmn.js} +3 -3
- package/dist/{chunk-t19th11m.js → chunk-dnqq1ze0.js} +3 -3
- package/dist/chunk-dzbkgsv8.js +4 -0
- package/dist/chunk-dzekcand.js +2 -0
- package/dist/{chunk-bfbmdjh4.js → chunk-efy3038a.js} +2 -2
- package/dist/chunk-en388k3h.js +2 -0
- package/dist/chunk-ewkza45r.js +2 -0
- package/dist/chunk-fcgf8d5k.js +2 -0
- package/dist/chunk-fese2cf6.js +2 -0
- package/dist/{chunk-79zfhk62.js → chunk-fwp1en28.js} +6 -6
- package/dist/{chunk-9x4r15mv.js → chunk-ghdyqt98.js} +2 -2
- package/dist/chunk-gk7mmc2e.js +2 -0
- package/dist/chunk-gw2dvp35.js +2 -0
- package/dist/chunk-h9drxwva.js +2 -0
- package/dist/chunk-hrr7k1qc.js +2 -0
- package/dist/{chunk-jb6zejnt.js → chunk-htf3z9et.js} +3 -3
- package/dist/chunk-j04brkj0.js +2 -0
- package/dist/chunk-jbvwg4gs.js +2 -0
- package/dist/{chunk-wkxzzdzs.js → chunk-jpxekhdh.js} +3 -3
- package/dist/chunk-jshj69dy.js +2 -0
- package/dist/{chunk-y09g63k0.js → chunk-jsktg3ab.js} +5 -5
- package/dist/{chunk-zvs13kgh.js → chunk-k3f4044e.js} +2 -2
- package/dist/chunk-k7spjpr0.js +2 -0
- package/dist/chunk-kgvm5ytn.js +2 -0
- package/dist/chunk-km9a5gp4.js +2 -0
- package/dist/{chunk-4h58as2c.js → chunk-kxjd6e2h.js} +2 -2
- package/dist/{chunk-nb0ytx70.js → chunk-m95zjk91.js} +2 -2
- package/dist/{chunk-h7atbtds.js → chunk-m9h7pmkh.js} +5 -5
- package/dist/chunk-mfery7a4.js +2 -0
- package/dist/chunk-mn7a5b55.js +3 -0
- package/dist/{chunk-vmsw9sdw.js → chunk-mtxs4fya.js} +2 -2
- package/dist/{chunk-8s7zbhdd.js → chunk-mvwcf4xy.js} +4 -4
- package/dist/chunk-myqhdz1w.js +2 -0
- package/dist/chunk-n35yc890.js +3 -0
- package/dist/chunk-n882b1fy.js +2 -0
- package/dist/chunk-p8sv5fqs.js +2 -0
- package/dist/chunk-pndhb1nk.js +2 -0
- package/dist/chunk-pt7e0be5.js +2 -0
- package/dist/chunk-q40ahbjs.js +2 -0
- package/dist/{chunk-gzpxvca7.js → chunk-qh07a85k.js} +3 -3
- package/dist/chunk-qjxxhdv7.js +2 -0
- package/dist/chunk-qygr4pv8.js +2 -0
- package/dist/{chunk-18ws9heh.js → chunk-r4h8fg1x.js} +1 -1
- package/dist/chunk-r4wqh5fd.js +2845 -0
- package/dist/{chunk-tnafnb23.js → chunk-r69jfs59.js} +1 -1
- package/dist/{chunk-xcyreehd.js → chunk-rg7wvcqw.js} +2 -2
- package/dist/{chunk-82bttwqm.js → chunk-rmv35cx0.js} +2 -2
- package/dist/chunk-rp93n4z7.js +3 -0
- package/dist/chunk-rrw2jg26.js +2 -0
- package/dist/{chunk-kn2exbq7.js → chunk-s45envb5.js} +5 -5
- package/dist/{chunk-tds3d65g.js → chunk-s4pjf2pc.js} +2 -2
- package/dist/{chunk-b3c1gggs.js → chunk-sswjv8p9.js} +2 -2
- package/dist/{chunk-bsy10tz6.js → chunk-t9t66sz4.js} +6 -6
- package/dist/{chunk-pb7vste8.js → chunk-tbsjg23k.js} +4 -4
- package/dist/{chunk-q6h6yjg4.js → chunk-tcd2zez3.js} +2 -2
- package/dist/{chunk-f17rcvdb.js → chunk-td30jg06.js} +2 -2
- package/dist/{chunk-qf39z0hg.js → chunk-td5100fz.js} +7 -7
- package/dist/{chunk-hvqjs9ps.js → chunk-tyb481p0.js} +1 -1
- package/dist/{chunk-a8n6mt7s.js → chunk-tydv84gj.js} +2 -2
- package/dist/{chunk-hsy9rhct.js → chunk-vehtypx0.js} +2 -2
- package/dist/{chunk-jmczvhpy.js → chunk-vhajhs44.js} +5 -5
- package/dist/{chunk-5c153w4j.js → chunk-vm2d4hap.js} +3 -3
- package/dist/{chunk-y3wdf7v7.js → chunk-vntpfbwy.js} +1 -1
- package/dist/{chunk-25zpd110.js → chunk-vp3fzjsc.js} +2 -2
- package/dist/{chunk-3xdfqn0d.js → chunk-vvfpb3k3.js} +5 -5
- package/dist/{chunk-q1cvef6b.js → chunk-vw62fjpv.js} +3 -3
- package/dist/{chunk-er5wxv0f.js → chunk-w67rrd1f.js} +10 -10
- package/dist/{chunk-shnsvsg4.js → chunk-w8g2ppnr.js} +2 -2
- package/dist/chunk-wjhhb6dn.js +2 -0
- package/dist/chunk-wm8w2721.js +2 -0
- package/dist/{chunk-g6ew2drc.js → chunk-wy53pys4.js} +5 -5
- package/dist/{chunk-v8ze2q95.js → chunk-wzjf33es.js} +2 -2
- package/dist/{chunk-gh181dnr.js → chunk-x8q5przn.js} +10 -10
- package/dist/{chunk-vn6h03nq.js → chunk-xjxc4q3w.js} +27 -27
- package/dist/chunk-y2wr7c9e.js +2 -0
- package/dist/{chunk-kx52xt96.js → chunk-y54fz9rk.js} +2 -2
- package/dist/{chunk-788d9msn.js → chunk-y6gj9jq8.js} +6 -6
- package/dist/chunk-y8jjmwa9.js +2 -0
- package/dist/{chunk-xwatzxk5.js → chunk-y9a9cvke.js} +13 -13
- package/dist/{chunk-y0qjpcc8.js → chunk-yzj55rfs.js} +3 -3
- package/dist/{chunk-hz11wmx9.js → chunk-z8fhtym2.js} +2 -2
- package/dist/chunk-z8mdsjzw.js +2 -0
- package/dist/chunk-zg87pybq.js +2 -0
- package/dist/chunk-zs3ezqy3.js +2 -0
- package/dist/{chunk-ydt4sd6m.js → chunk-zs3tmd12.js} +2 -2
- package/dist/cli.js +20 -20
- package/dist/component-renderer.js +62 -9
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/expressions.js +7 -1
- package/dist/native/accessibility.d.ts +12 -0
- package/dist/native/accessibility.js +19 -0
- package/dist/native/compiler/headwind-to-style.js +23 -29
- package/dist/native/compiler/html-to-ir.js +17 -7
- package/dist/native/compiler/inline-style.d.ts +7 -0
- package/dist/native/compiler/inline-style.js +8 -1
- package/dist/native/compiler/ir.d.ts +3 -1
- package/dist/native/compiler/render-screen.js +1 -1
- package/dist/native/components/primitives.d.ts +16 -14
- package/dist/native/components/primitives.js +1 -0
- package/dist/native/index.d.ts +1 -0
- package/dist/native/primitives/Link.stx +5 -0
- package/dist/native/prop-names.js +6 -0
- package/dist/native/runtime/binding-tree.js +2 -1
- package/dist/native/runtime/browser-renderer.js +63 -4
- package/dist/native/runtime/craft-bridge.js +8 -2
- package/dist/native/runtime/craft.d.ts +4 -0
- package/dist/native/runtime/native-host.js +20 -14
- package/dist/native/runtime/overlay-presenter.d.ts +2 -0
- package/dist/native/runtime/overlay-presenter.js +10 -5
- package/dist/native/runtime/view-operations.d.ts +1 -1
- package/dist/native/runtime/view-operations.js +5 -1
- package/dist/pwa.js +3 -3
- package/dist/slot-scopes.d.ts +7 -0
- package/dist/slot-scopes.js +19 -0
- package/dist/slots.js +23 -7
- package/dist/ssg.js +12 -12
- package/dist/stx-virtual-ts.js +6 -5
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +1 -1
- package/package.json +5 -5
- package/dist/chunk-00vp75pj.js +0 -2
- package/dist/chunk-04gt67sv.js +0 -2
- package/dist/chunk-08p1kxsj.js +0 -2
- package/dist/chunk-0hpw65yr.js +0 -2
- package/dist/chunk-0rekvsy4.js +0 -2
- package/dist/chunk-122y2fkw.js +0 -3
- package/dist/chunk-138zjhwa.js +0 -2
- package/dist/chunk-1sbj8yqe.js +0 -2
- package/dist/chunk-2c7ysn9s.js +0 -2
- package/dist/chunk-2qt63502.js +0 -2
- package/dist/chunk-2wb1w0p6.js +0 -2
- package/dist/chunk-38mt99p3.js +0 -2
- package/dist/chunk-3q312svf.js +0 -2
- package/dist/chunk-6djvj6hg.js +0 -2
- package/dist/chunk-6vncjspv.js +0 -2
- package/dist/chunk-7dkwf9h5.js +0 -2
- package/dist/chunk-7ejmya3v.js +0 -2
- package/dist/chunk-8992smwz.js +0 -2
- package/dist/chunk-8mffwm1f.js +0 -2
- package/dist/chunk-8txwa114.js +0 -2
- package/dist/chunk-9j6hk72q.js +0 -2
- package/dist/chunk-a1szmtn1.js +0 -127
- package/dist/chunk-acm2tym9.js +0 -2
- package/dist/chunk-afmzxwj1.js +0 -2
- package/dist/chunk-bk3yktq8.js +0 -2
- package/dist/chunk-bpz3yv92.js +0 -2
- package/dist/chunk-bx3qewwk.js +0 -2
- package/dist/chunk-ce2d0hz9.js +0 -2
- package/dist/chunk-d81h4mxd.js +0 -2
- package/dist/chunk-dgtxj56t.js +0 -3
- package/dist/chunk-djqmzzn6.js +0 -2
- package/dist/chunk-eactb0nz.js +0 -2
- package/dist/chunk-eqa0wdv9.js +0 -4
- package/dist/chunk-esac5ych.js +0 -2
- package/dist/chunk-esj49jvz.js +0 -2
- package/dist/chunk-et8wjgxw.js +0 -2
- package/dist/chunk-ffykng6w.js +0 -2
- package/dist/chunk-fwt5fh5w.js +0 -2
- package/dist/chunk-g3qbe5y2.js +0 -2
- package/dist/chunk-h5g8k974.js +0 -2
- package/dist/chunk-hhwnd24n.js +0 -2
- package/dist/chunk-hq4mtcp0.js +0 -2
- package/dist/chunk-hvd9qc98.js +0 -2
- package/dist/chunk-j0z7010x.js +0 -2845
- package/dist/chunk-jhswy523.js +0 -2
- package/dist/chunk-jjs6nqh1.js +0 -2
- package/dist/chunk-jyqanvwp.js +0 -2
- package/dist/chunk-khdvzjzd.js +0 -2
- package/dist/chunk-n06xznty.js +0 -2
- package/dist/chunk-p973efbe.js +0 -2
- package/dist/chunk-qq59xzwc.js +0 -2
- package/dist/chunk-r0e743c3.js +0 -2
- package/dist/chunk-r4adpej7.js +0 -2
- package/dist/chunk-rd9yv1n3.js +0 -3
- package/dist/chunk-shzesarq.js +0 -2
- package/dist/chunk-t9914jjh.js +0 -2
- package/dist/chunk-wf2wnmjg.js +0 -2
- package/dist/chunk-wn2gzwmv.js +0 -2
- package/dist/chunk-wr6gw263.js +0 -2
- package/dist/chunk-xarb7knj.js +0 -2
- package/dist/chunk-xe7jw7nn.js +0 -2
- package/dist/chunk-xfe2nzxd.js +0 -2
- package/dist/chunk-xjwgzp6s.js +0 -2
- package/dist/chunk-xmz2h8cb.js +0 -2
- package/dist/chunk-y6909jm7.js +0 -2
- package/dist/chunk-zg0pnh4w.js +0 -2
|
@@ -1,15 +1,18 @@
|
|
|
1
|
+
import { accessibilityChanges, authoredAccessibilityProps, projectAccessibility } from "../accessibility.js";
|
|
1
2
|
import { compileClassStyles } from "../compiler/headwind-to-style.js";
|
|
2
3
|
import { resolveIconName } from "../compiler/icons.js";
|
|
3
|
-
import { parseNativeStyleLayers } from "../compiler/inline-style.js";
|
|
4
|
+
import { applyNativeLayoutDefaults, parseNativeStyleLayers } from "../compiler/inline-style.js";
|
|
4
5
|
import { createStyleVariables } from "../compiler/style-variables.js";
|
|
5
6
|
import { affectsGeometry, parseSvgMarkup, parseViewBox, SVG_NODE_TYPES, svgGeometry } from "../compiler/svg.js";
|
|
6
7
|
import { NATIVE_EVENT_NAMES } from "../event-names.js";
|
|
7
|
-
import { accessibilityPatch, isAccessibilityAttribute } from "../accessibility.js";
|
|
8
8
|
import { nativePropName } from "../prop-names.js";
|
|
9
9
|
import { cloneNativeBindingNode } from "./binding-tree.js";
|
|
10
10
|
import { NATIVE_FORM_ENTRIES } from "./jsc-globals.js";
|
|
11
11
|
import { createNativeOverlayPresenter } from "./overlay-presenter.js";
|
|
12
12
|
import { nativeViewError } from "./view-operations.js";
|
|
13
|
+
function isHiddenInput(record) {
|
|
14
|
+
return record.type === "View" && record.props.type === "hidden";
|
|
15
|
+
}
|
|
13
16
|
function irDisplay(value) {
|
|
14
17
|
return value === "none" || value === "grid" || value === "flex" ? value : "flex";
|
|
15
18
|
}
|
|
@@ -256,7 +259,7 @@ export function createNativeHost(options) {
|
|
|
256
259
|
node: {
|
|
257
260
|
type: record.type,
|
|
258
261
|
...record.key === void 0 ? {} : { key: record.key },
|
|
259
|
-
props: { ...record.props },
|
|
262
|
+
props: { ...record.props, ...projectAccessibility(record.props) },
|
|
260
263
|
style: { ...record.style },
|
|
261
264
|
...Object.keys(record.events).length ? { events: { ...record.events } } : {},
|
|
262
265
|
...record.text === void 0 ? {} : { children: [record.text] }
|
|
@@ -280,7 +283,7 @@ export function createNativeHost(options) {
|
|
|
280
283
|
const resolved = parseNativeStyleLayers([record.styleSource, record.boundStyle, record.forwardedStyle], inherited, report);
|
|
281
284
|
record.variables = resolved.variables;
|
|
282
285
|
const classes = compileClassStyles(`${record.classes} ${record.forwardedClasses ?? ""}`, record.variables);
|
|
283
|
-
return { ...classes.style, ...colorScheme === "dark" ? classes.dark : {}, ...resolved.styles[0], ...record.baseStyle, ...resolved.styles[1], ...resolved.styles[2], ...record.visible ? {} : { display: "none" } };
|
|
286
|
+
return { ...applyNativeLayoutDefaults({ ...classes.style, ...colorScheme === "dark" ? classes.dark : {}, ...resolved.styles[0], ...record.baseStyle, ...resolved.styles[1], ...resolved.styles[2] }), ...record.visible && !isHiddenInput(record) ? {} : { display: "none" } };
|
|
284
287
|
}
|
|
285
288
|
function refreshStyleTree(node, inherited = node.__stxOwner ? descriptorOf(node.__stxOwner)?.variables : stylesheetVariables, appearanceChanged = !1) {
|
|
286
289
|
if (node.__stxAnchor !== void 0)
|
|
@@ -298,6 +301,8 @@ export function createNativeHost(options) {
|
|
|
298
301
|
if (!isBindingNode(node) || !(node.getAttribute("data-stx-native-forward") ?? "").split(/\s+/).includes(name))
|
|
299
302
|
return;
|
|
300
303
|
const find = (candidate) => {
|
|
304
|
+
if (candidate !== node && isBindingNode(candidate) && candidate.hasAttribute("data-stx-native-host-owner"))
|
|
305
|
+
return;
|
|
301
306
|
if (isBindingNode(candidate) && candidate.hasAttribute("data-stx-native-host-root"))
|
|
302
307
|
return candidate;
|
|
303
308
|
for (const child of recordOf(candidate).children) {
|
|
@@ -452,7 +457,7 @@ export function createNativeHost(options) {
|
|
|
452
457
|
const classes = descriptor?._classes ?? "", classStyle = compileClassStyles(classes).style, baseStyle = descriptor?._styleSource !== void 0 ? {} : descriptor?._inlineStyle ? { ...descriptor._inlineStyle } : Object.fromEntries(Object.entries(descriptor?.style ?? {}).filter(([key, value]) => classStyle[key] !== value)), record = {
|
|
453
458
|
type,
|
|
454
459
|
key: descriptor?.key,
|
|
455
|
-
props:
|
|
460
|
+
props: authoredAccessibilityProps(descriptor?.props ?? {}, descriptor?._accessibilitySource),
|
|
456
461
|
style: { ...descriptor?.style ?? {} },
|
|
457
462
|
baseStyle,
|
|
458
463
|
styleSource: descriptor?._styleSource,
|
|
@@ -483,6 +488,7 @@ export function createNativeHost(options) {
|
|
|
483
488
|
}
|
|
484
489
|
const overlayPresenter = createNativeOverlayPresenter({
|
|
485
490
|
canFocus: options.views?.capabilities.focus === !0,
|
|
491
|
+
canPresentNonModal: options.views?.capabilities.nonModalPresentation === !0,
|
|
486
492
|
focus: (node, focusOptions) => host.focus(node, focusOptions),
|
|
487
493
|
descendants: collectDescendants,
|
|
488
494
|
hasAutofocus: (node) => {
|
|
@@ -570,7 +576,7 @@ export function createNativeHost(options) {
|
|
|
570
576
|
return {
|
|
571
577
|
id: node.__stxId,
|
|
572
578
|
type: record.type,
|
|
573
|
-
props: { ...record.props },
|
|
579
|
+
props: { ...record.props, ...projectAccessibility(record.props) },
|
|
574
580
|
style: { ...record.style },
|
|
575
581
|
events: { ...record.events },
|
|
576
582
|
children: record.text === void 0 ? children : [record.text]
|
|
@@ -620,7 +626,7 @@ export function createNativeHost(options) {
|
|
|
620
626
|
applyClasses(node.__stxId, record);
|
|
621
627
|
return;
|
|
622
628
|
}
|
|
623
|
-
const prop = nativePropName(name), record = recordOf(node);
|
|
629
|
+
const prop = nativePropName(name), record = recordOf(node), accessibilityBefore = prop === "role" || prop.startsWith("aria-") || prop.startsWith("accessibility") ? projectAccessibility(record.props) : void 0;
|
|
624
630
|
record.props[prop] = value;
|
|
625
631
|
if (record.type === "Icon" && prop === "name") {
|
|
626
632
|
const icon = resolveIconName(String(value ?? ""));
|
|
@@ -628,8 +634,8 @@ export function createNativeHost(options) {
|
|
|
628
634
|
this.setAttribute(node, "symbol", icon.symbol);
|
|
629
635
|
}
|
|
630
636
|
const patch = { [prop]: value };
|
|
631
|
-
if (
|
|
632
|
-
Object.assign(patch,
|
|
637
|
+
if (accessibilityBefore)
|
|
638
|
+
Object.assign(patch, accessibilityChanges(record.props, accessibilityBefore, prop));
|
|
633
639
|
if (SVG_NODE_TYPES.has(record.type)) {
|
|
634
640
|
if (prop === "strokeDasharray" && value != null && !Array.isArray(value))
|
|
635
641
|
patch[prop] = record.props[prop] = String(value).split(/[\s,]+/).map(Number).filter(Number.isFinite);
|
|
@@ -654,11 +660,11 @@ export function createNativeHost(options) {
|
|
|
654
660
|
this.setAttribute(node, name, "");
|
|
655
661
|
return;
|
|
656
662
|
}
|
|
657
|
-
const prop = nativePropName(name), record = recordOf(node);
|
|
663
|
+
const prop = nativePropName(name), record = recordOf(node), accessibilityBefore = prop === "role" || prop.startsWith("aria-") || prop.startsWith("accessibility") ? projectAccessibility(record.props) : void 0;
|
|
658
664
|
delete record.props[prop];
|
|
659
665
|
const patch = { [prop]: null };
|
|
660
|
-
if (
|
|
661
|
-
Object.assign(patch,
|
|
666
|
+
if (accessibilityBefore)
|
|
667
|
+
Object.assign(patch, accessibilityChanges(record.props, accessibilityBefore, prop));
|
|
662
668
|
if (affectsGeometry(record.type, prop))
|
|
663
669
|
patch.geometry = record.props.geometry = svgGeometry(record.type, record.props);
|
|
664
670
|
if (record.materialized)
|
|
@@ -693,7 +699,7 @@ export function createNativeHost(options) {
|
|
|
693
699
|
}
|
|
694
700
|
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
695
701
|
return;
|
|
696
|
-
const style = value;
|
|
702
|
+
const style = { ...value, ...isHiddenInput(record) ? { display: "none" } : {} };
|
|
697
703
|
Object.assign(record.baseStyle, style);
|
|
698
704
|
Object.assign(record.style, style);
|
|
699
705
|
if (record.materialized)
|
|
@@ -763,7 +769,7 @@ export function createNativeHost(options) {
|
|
|
763
769
|
const data = payload && typeof payload === "object" ? payload : {}, value = data.text ?? data.value ?? data.nativeEvent?.text ?? data.nativeEvent?.value, record = recordOf(node);
|
|
764
770
|
if (record.type === "Checkbox" && value !== void 0)
|
|
765
771
|
node.checked = Boolean(value);
|
|
766
|
-
if (value !== void 0 && !Object.is(record.props.value, value) && (record.type === "TextInput" || record.type === "Picker")) {
|
|
772
|
+
if (value !== void 0 && !Object.is(record.props.value, value) && (record.type === "TextInput" || record.type === "Picker" || record.type === "Switch")) {
|
|
767
773
|
record.props.value = value;
|
|
768
774
|
if (record.materialized)
|
|
769
775
|
emit({ op: "updateNode", id: node.__stxId, patch: { props: { value } } });
|
|
@@ -9,10 +9,12 @@ export declare interface NativeOverlayEntry {
|
|
|
9
9
|
zIndex?: number | null
|
|
10
10
|
panel?: FocusTarget
|
|
11
11
|
initialFocus?: FocusTarget
|
|
12
|
+
onBackdrop?: (() => void) | null
|
|
12
13
|
onRequestClose?: ((event?: unknown) => void) | null
|
|
13
14
|
}
|
|
14
15
|
declare interface OverlayHost {
|
|
15
16
|
canFocus: boolean
|
|
17
|
+
canPresentNonModal: boolean
|
|
16
18
|
focus: (node: NativeNode, options: NativeFocusOptions) => Promise<true>
|
|
17
19
|
descendants: (node: NativeNode) => NativeNode[]
|
|
18
20
|
hasAutofocus: (node: NativeNode) => boolean
|
|
@@ -27,9 +27,12 @@ export function createNativeOverlayPresenter(host) {
|
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
function sync(entries) {
|
|
30
|
-
for (const entry of entries)
|
|
31
|
-
if (!entry.
|
|
32
|
-
throw Error(`[stx:overlays] Native
|
|
30
|
+
for (const entry of entries) {
|
|
31
|
+
if (!entry.modal && !host.canPresentNonModal)
|
|
32
|
+
throw Error(`[stx:overlays] Native popup "${entry.id}" requires the viewNonModalPresentation host positioning capability.`);
|
|
33
|
+
if (!entry.root || host.type(entry.root) !== "Modal")
|
|
34
|
+
throw Error(`[stx:overlays] Native overlay "${entry.id}" requires a Modal root (data-native="Modal") for host-owned presentation.`);
|
|
35
|
+
}
|
|
33
36
|
const previous = current;
|
|
34
37
|
current = entries.slice();
|
|
35
38
|
for (const entry of previous)
|
|
@@ -50,14 +53,16 @@ export function createNativeOverlayPresenter(host) {
|
|
|
50
53
|
}
|
|
51
54
|
});
|
|
52
55
|
}
|
|
56
|
+
host.setAttribute(root, "nonModal", !entry.modal);
|
|
57
|
+
host.setAttribute(root, "dismissOnOutsideTap", !entry.modal && !!entry.onBackdrop);
|
|
53
58
|
host.setAttribute(root, "visible", !0);
|
|
54
59
|
host.setStyle(root, { zIndex: (entry.zIndex ?? 1000) + index });
|
|
55
60
|
}
|
|
56
61
|
const top = current.at(-1);
|
|
57
|
-
if (top?.root !== previous.at(-1)?.root) {
|
|
62
|
+
if (top?.root !== previous.at(-1)?.root || top?.modal !== previous.at(-1)?.modal) {
|
|
58
63
|
focusing?.abort();
|
|
59
64
|
focusing = null;
|
|
60
|
-
if (top && !previous.some((entry) => entry.root === top.root))
|
|
65
|
+
if (top?.modal && !previous.some((entry) => entry.root === top.root && entry.modal))
|
|
61
66
|
focusInitial(top);
|
|
62
67
|
}
|
|
63
68
|
}
|
|
@@ -14,7 +14,7 @@ export declare interface NativeViewBounds {
|
|
|
14
14
|
coordinateSpace: 'screenViewport'
|
|
15
15
|
}
|
|
16
16
|
export declare interface NativeViewOperations {
|
|
17
|
-
readonly capabilities: { focus: boolean, measure: boolean }
|
|
17
|
+
readonly capabilities: { focus: boolean, measure: boolean, nonModalPresentation: boolean }
|
|
18
18
|
focus: (nodeId: string, options?: NativeFocusOptions) => Promise<true>
|
|
19
19
|
measure: (nodeId: string) => Promise<NativeViewBounds>
|
|
20
20
|
}
|
|
@@ -9,7 +9,11 @@ export function createNativeViewOperations(protocol, capabilities, beforeRequest
|
|
|
9
9
|
beforeRequest();
|
|
10
10
|
}
|
|
11
11
|
return {
|
|
12
|
-
capabilities: {
|
|
12
|
+
capabilities: {
|
|
13
|
+
focus: supported.has("viewFocus"),
|
|
14
|
+
measure: supported.has("viewMeasure"),
|
|
15
|
+
nonModalPresentation: supported.has("viewNonModalPresentation")
|
|
16
|
+
},
|
|
13
17
|
async focus(nodeId, options = {}) {
|
|
14
18
|
if (options.signal?.aborted)
|
|
15
19
|
throw nativeViewError("CANCELLED", "Native focus was cancelled");
|
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{er,Ve,ri,uc}from"./chunk-tbsjg23k.js";import{Qn,os,ac,cc,lc}from"./chunk-81qmj3sd.js";import{ei,ti,ni,oc,ic}from"./chunk-tydv84gj.js";import{le,kt,is}from"./chunk-dmdhbwmn.js";import{pl,fl,gl,ml,Ar,Nd}from"./chunk-5s47qfp6.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-dzekcand.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=
|
|
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=le(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=er(n,t);if(a){let s=Ve(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 os(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,ti as auditBuildOutput,ei as auditConfig,re as buildPwaAssets,ni as calculateAuditResult,ic as formatAuditResult,is as formatSize,j as generateManifest,_ as generateManifestJson,cc as generateManifestLink,F as generateOfflinePage,le as generatePrecacheManifest,kt as generatePrecacheManifestJs,M as generatePwaIcons,Qn as generatePwaTags,er as generateServiceWorker,uc as generateServiceWorkerAuto,ac as generateSwRegistrationScript,lc as generateThemeColorMeta,N as getExpectedIconPaths,Ve as getServiceWorkerFileName,os as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,ri as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,Ar as pwaDirectives,pl as pwaInstallDirective,gl as pwaOfflineDirective,ml as pwaPushDirective,fl as pwaUpdateDirective,Nd as registerPwaDirectives,oc as runPwaAudit,D as validateManifest};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function collectSlotScopes(source) {
|
|
2
|
+
if (!source.includes("#") && !source.includes("v-slot:"))
|
|
3
|
+
return [];
|
|
4
|
+
const scopes = [], stack = [], tags = /<!--[\s\S]*?-->|<script\b(?:"[^"]*"|'[^']*'|[^'">])*>[\s\S]*?<\/script\s*>|<style\b(?:"[^"]*"|'[^']*'|[^'">])*>[\s\S]*?<\/style\s*>|<\/?[a-z][\w:-]*\b(?:"[^"]*"|'[^']*'|[^'">])*>/gi;
|
|
5
|
+
for (const match of source.matchAll(tags)) {
|
|
6
|
+
const tag = match[0];
|
|
7
|
+
if (/^<\/template\s*>$/i.test(tag)) {
|
|
8
|
+
const scope = stack.pop();
|
|
9
|
+
if (scope)
|
|
10
|
+
scope.end = match.index;
|
|
11
|
+
} else if (/^<template\b/i.test(tag) && !/\/\s*>$/.test(tag)) {
|
|
12
|
+
const binding = [...tag.slice(9).matchAll(/([^\s=/>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g)].find((attr) => /^(?:#[\w-]+|v-slot:[\w-]+)$/i.test(attr[1])), value = (binding?.[2] ?? binding?.[3])?.trim(), scope = value ? { start: match.index + tag.length, end: source.length, binding: value } : void 0;
|
|
13
|
+
stack.push(scope);
|
|
14
|
+
if (scope)
|
|
15
|
+
scopes.push(scope);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return scopes;
|
|
19
|
+
}
|
package/dist/slots.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { escapeHtml } from "./expressions.js";
|
|
2
2
|
import { isExpressionSafe, createSafeFunction } from "./safe-evaluator.js";
|
|
3
|
+
import { readsAnyName } from "./loop-binding.js";
|
|
3
4
|
function findMatchingTemplateClose(content, startIndex) {
|
|
4
5
|
let depth = 1, i = startIndex;
|
|
5
6
|
const openTag = "<template", closeTag = "</template";
|
|
@@ -251,24 +252,39 @@ export async function renderSlot(slotDef, slotProps, defaultContent, context) {
|
|
|
251
252
|
return defaultContent;
|
|
252
253
|
let content = slotDef.content;
|
|
253
254
|
if (slotDef.propsBinding && Object.keys(slotProps).length > 0) {
|
|
254
|
-
const binding = slotDef.propsBinding.trim(), slotContext = { ...context };
|
|
255
|
+
const binding = slotDef.propsBinding.trim(), slotContext = { ...context }, unresolved = new Set, resolved = new Set;
|
|
255
256
|
if (binding.startsWith("{") && binding.endsWith("}")) {
|
|
256
257
|
const propNames = binding.slice(1, -1).split(",").map((p) => p.trim()).filter(Boolean);
|
|
257
258
|
for (const propName of propNames) {
|
|
258
259
|
const [key, alias] = propName.split(":").map((s) => s.trim()), actualKey = alias || key;
|
|
260
|
+
slotContext[actualKey] = slotProps[key];
|
|
259
261
|
if (slotProps[key] !== void 0)
|
|
260
|
-
|
|
262
|
+
resolved.add(actualKey);
|
|
263
|
+
else
|
|
264
|
+
unresolved.add(actualKey);
|
|
261
265
|
}
|
|
262
|
-
} else
|
|
266
|
+
} else {
|
|
263
267
|
slotContext[binding] = slotProps;
|
|
264
|
-
|
|
268
|
+
if (Object.values(slotProps).some((value) => value === void 0))
|
|
269
|
+
unresolved.add(binding);
|
|
270
|
+
else
|
|
271
|
+
resolved.add(binding);
|
|
272
|
+
}
|
|
273
|
+
content = processSlotExpressions(content, slotContext, unresolved, resolved);
|
|
265
274
|
}
|
|
266
275
|
return content;
|
|
267
276
|
}
|
|
268
|
-
function processSlotExpressions(content, context) {
|
|
269
|
-
return content.replace(/\{\{\s*([^}]+)\s*\}\}/g, (
|
|
277
|
+
function processSlotExpressions(content, context, unresolved, resolved) {
|
|
278
|
+
return content.replace(/\{\{\s*([^}]+)\s*\}\}/g, (match, expr) => {
|
|
270
279
|
try {
|
|
271
|
-
const trimmedExpr = expr.trim()
|
|
280
|
+
const trimmedExpr = expr.trim();
|
|
281
|
+
if (readsAnyName(trimmedExpr, unresolved))
|
|
282
|
+
return match;
|
|
283
|
+
if (Array.isArray(context.__stx_preserved_client_expressions) && context.__stx_preserved_client_expressions.includes(trimmedExpr) && !readsAnyName(trimmedExpr, resolved))
|
|
284
|
+
return match;
|
|
285
|
+
const result = evaluateSimpleExpression(trimmedExpr, context);
|
|
286
|
+
if (result === void 0)
|
|
287
|
+
return match;
|
|
272
288
|
return escapeHtml(String(result ?? ""));
|
|
273
289
|
} catch {
|
|
274
290
|
return `{{ ${expr} }}`;
|
package/dist/ssg.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-
|
|
3
|
-
`)}class ht{cacheDir;cache=new Map;loaded=!1;salt;constructor(t,i=""){this.cacheDir=t,this.salt=i}async load(){if(this.loaded)return;let t=g.join(this.cacheDir,"build-cache.json");if(await Bun.file(t).exists())try{let i=JSON.parse(await Bun.file(t).text());for(let[s,r]of Object.entries(i))this.cache.set(s,r)}catch{}this.loaded=!0}async save(){await x.promises.mkdir(this.cacheDir,{recursive:!0});let t=g.join(this.cacheDir,"build-cache.json"),i={};for(let[s,r]of this.cache)i[s]=r;await Bun.write(t,JSON.stringify(i))}getHash(t,i){let s=x.statSync(t),r=`${this.salt}|${t}:${s.mtimeMs}`;for(let e of i)if(x.existsSync(e)){let l=x.statSync(e);r+=`:${e}:${l.mtimeMs}`}let c=0;for(let e=0;e<r.length;e++){let l=r.charCodeAt(e);c=(c<<5)-c+l,c=c&c}return Math.abs(c).toString(36)}get(t,i){let s=this.cache.get(t);if(!s)return null;let r=this.getHash(i,s.dependencies??[]);if(s.hash!==r)return this.cache.delete(t),null;return s.html}set(t,i,s,r){let c=this.getHash(i,s);this.cache.set(t,{hash:c,html:r,generatedAt:Date.now(),dependencies:s})}}class mt{cacheDir;constructor(t){this.cacheDir=t}getFilePath(t){let i=t.replace(/[^a-zA-Z0-9]/g,"_")+".json";return g.join(this.cacheDir,"isr",i)}async get(t){let i=this.getFilePath(t);if(!await Bun.file(i).exists())return null;try{return JSON.parse(await Bun.file(i).text())}catch{return null}}async set(t,i){let s=this.getFilePath(t);await x.promises.mkdir(g.dirname(s),{recursive:!0}),await Bun.write(s,JSON.stringify(i))}async invalidate(t){let i=this.getFilePath(t);if(await Bun.file(i).exists())await x.promises.unlink(i)}async invalidatePattern(t){let i=g.join(this.cacheDir,"isr");if(!x.existsSync(i))return;let s=await x.promises.readdir(i);for(let r of s){let c=r.replace(/_/g,"/").replace(".json","");if(t.test(c))await x.promises.unlink(g.join(i,r))}}async needsRevalidation(t){let i=await this.get(t);if(!i)return!0;return Date.now()>i.revalidateAfter}}async function
|
|
2
|
+
import"./chunk-s4pjf2pc.js";import"./chunk-06wv8qwy.js";import"./chunk-wzjf33es.js";import{lt,ut,dt,pt,ft,gt}from"./chunk-azpkje69.js";import"./chunk-sswjv8p9.js";import"./chunk-bsy8v1xj.js";import{f,Ke,L,J,n,o}from"./chunk-r4wqh5fd.js";import"./chunk-x8q5przn.js";import{br}from"./chunk-td5100fz.js";import"./chunk-bhf9yt2w.js";import"./chunk-3cnwstra.js";import"./chunk-rmv35cx0.js";import"./chunk-6xsm53pz.js";import"./chunk-vhajhs44.js";import{ue,Ct,_t}from"./chunk-y6gj9jq8.js";import{Yo,Zo,Qo}from"./chunk-cfpenvc7.js";import{St,dn,pn}from"./chunk-rp93n4z7.js";import"./chunk-dnqq1ze0.js";import{a}from"./chunk-n35yc890.js";import x from"fs";import g from"path";import{createHash as Pt}from"crypto";function $t(t){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(t).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return t}}var Dt=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;function Rt(t){return Bun.hash(t).toString(16)}function it(t,i={}){if(!t.includes('type="stx/island"'))return{html:t,chunks:[]};let s=new Map,r=t.replace(Dt,(e,l,w,y)=>{let h=y.trim();if(!h)return e;if(/\bdata-stx-src=/.test(w))return e;if(i.minify)h=$t(h);let S=Rt(h);if(!s.has(S))s.set(S,h);let P=i.integrity?` data-stx-integrity="sha384-${Pt("sha384").update(h).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${l}" data-stx-src="/_stx/islands/${S}.js"${P}${w}></script>`}),c=Array.from(s,([e,l])=>({hash:e,code:l}));return{html:r,chunks:c}}var kt=new Set(["visible","idle"]);function st(t){if(!t.includes("data-stx-src="))return t;let i=new Map,s=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,r;while((r=s.exec(t))!==null)i.set(r[1],r[2]);let c=new Set,e=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,l;while((l=e.exec(t))!==null)if(kt.has(i.get(l[1])||""))c.add(l[2]);let w=t.lastIndexOf("</head>");if(c.size===0||w===-1)return t;let y=Array.from(c).filter((h)=>!t.includes(`rel="prefetch" href="${h}"`)).map((h)=>`<link rel="prefetch" href="${h}" as="script">`).join("");if(!y)return t;return t.slice(0,w)+y+t.slice(w)}var Et=["STX_SITE_URL","SITE_URL","URL","VERCEL_URL","CF_PAGES_URL"];function q(t){let i=t.trim();if(!i)return null;let s=/^https?:\/\//i.test(i)?i:`https://${i}`;try{return new URL(s).origin+new URL(s).pathname.replace(/\/$/,"")}catch{return null}}function It(t){for(let i of Et){let s=t[i];if(!s)continue;let r=q(s);if(r)return{url:r,source:"env",via:i}}return null}function at(t){if(!t||typeof t!=="object")return null;let i=t,s=i.site?.url??i.url??i.app?.url;return typeof s==="string"?q(s):null}async function Bt(t){let{existsSync:i}=await import("fs"),s=await import("path");for(let r of["site.config.ts","site.config.js",".config/site.config.ts"]){let c=s.resolve(t,r);if(!i(c))continue;try{let e=await import(c),l=at(e.default??e);if(l)return l}catch{}}return null}async function ot(t={}){let i=t.cwd??process.cwd(),s=t.env??process.env;if(t.explicit){let l=q(t.explicit);if(l)return{url:l,source:"option"}}let r=at(t.stxConfig);if(r)return{url:r,source:"stx.config",via:"site.url"};let c=await Bt(i);if(c)return{url:c,source:"site.config",via:"url"};let e=It(s);if(e)return e;return{url:"http://localhost",source:"fallback"}}function ct(){return["No site URL configured \u2014 sitemap.xml and robots.txt will point at http://localhost."," Set one in stx.config.ts (site: { url: 'https://example.com' }), in site.config.ts,"," via --domain, or with SITE_URL in the build environment."].join(`
|
|
3
|
+
`)}class ht{cacheDir;cache=new Map;loaded=!1;salt;constructor(t,i=""){this.cacheDir=t,this.salt=i}async load(){if(this.loaded)return;let t=g.join(this.cacheDir,"build-cache.json");if(await Bun.file(t).exists())try{let i=JSON.parse(await Bun.file(t).text());for(let[s,r]of Object.entries(i))this.cache.set(s,r)}catch{}this.loaded=!0}async save(){await x.promises.mkdir(this.cacheDir,{recursive:!0});let t=g.join(this.cacheDir,"build-cache.json"),i={};for(let[s,r]of this.cache)i[s]=r;await Bun.write(t,JSON.stringify(i))}getHash(t,i){let s=x.statSync(t),r=`${this.salt}|${t}:${s.mtimeMs}`;for(let e of i)if(x.existsSync(e)){let l=x.statSync(e);r+=`:${e}:${l.mtimeMs}`}let c=0;for(let e=0;e<r.length;e++){let l=r.charCodeAt(e);c=(c<<5)-c+l,c=c&c}return Math.abs(c).toString(36)}get(t,i){let s=this.cache.get(t);if(!s)return null;let r=this.getHash(i,s.dependencies??[]);if(s.hash!==r)return this.cache.delete(t),null;return s.html}set(t,i,s,r){let c=this.getHash(i,s);this.cache.set(t,{hash:c,html:r,generatedAt:Date.now(),dependencies:s})}}class mt{cacheDir;constructor(t){this.cacheDir=t}getFilePath(t){let i=t.replace(/[^a-zA-Z0-9]/g,"_")+".json";return g.join(this.cacheDir,"isr",i)}async get(t){let i=this.getFilePath(t);if(!await Bun.file(i).exists())return null;try{return JSON.parse(await Bun.file(i).text())}catch{return null}}async set(t,i){let s=this.getFilePath(t);await x.promises.mkdir(g.dirname(s),{recursive:!0}),await Bun.write(s,JSON.stringify(i))}async invalidate(t){let i=this.getFilePath(t);if(await Bun.file(i).exists())await x.promises.unlink(i)}async invalidatePattern(t){let i=g.join(this.cacheDir,"isr");if(!x.existsSync(i))return;let s=await x.promises.readdir(i);for(let r of s){let c=r.replace(/_/g,"/").replace(".json","");if(t.test(c))await x.promises.unlink(g.join(i,r))}}async needsRevalidation(t){let i=await this.get(t);if(!i)return!0;return Date.now()>i.revalidateAfter}}async function jt(t){try{let s=(await Bun.file(t).text()).match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!s)return null;let r=s[1];if(!r.includes("getStaticPaths"))return null;let c=r.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticPaths\s*\([^)]*\)\s*\{([\s\S]*?)\n[\t ]*\}/);if(!c)return null;return await Function(`
|
|
4
4
|
return (async function getStaticPaths() {
|
|
5
5
|
${c[1]}
|
|
6
6
|
})()
|
|
7
|
-
`)()}catch(i){return console.error(`Error extracting static paths from ${t}:`,i),null}}async function
|
|
7
|
+
`)()}catch(i){return console.error(`Error extracting static paths from ${t}:`,i),null}}async function Ft(t){let i=[];if(!t.isDynamic)i.push({url:t.pattern,params:{}});else{let s=await jt(t.filePath);if(!s||s.paths.length===0)return console.warn(`Warning: Dynamic route ${t.pattern} has no getStaticPaths or returned empty paths`),i;for(let r of s.paths){let c=t.pattern;for(let[e,l]of Object.entries(r.params))c=c.replace(`:${e}`,l).replace(`:${e}*`,l);i.push({url:c,params:r.params,props:r.props,revalidate:r.revalidate})}}return i}async function Ot(t){let i=[t.replace(/\.stx$/,".data.ts"),t.replace(/\.stx$/,".data.js"),t+".data.ts",t+".data.js"];for(let s of i)if(await Bun.file(s).exists())try{let r=await import(s);if(typeof r.default==="function")return await r.default();else if(typeof r.default==="object")return r.default;else if(typeof r.getData==="function")return await r.getData();else{let{default:c,...e}=r;return e}}catch(r){console.error(`Error loading data file ${s}:`,r)}return null}async function Tt(t,i,s){let r=t.match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!r)return null;let c=r[1];if(!c.includes("getStaticProps"))return null;try{let e=c.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticProps\s*\([^)]*\)\s*\{([\s\S]*?)\n\}/);if(!e)return null;return await Function("params",`
|
|
8
8
|
return (async function getStaticProps() {
|
|
9
9
|
${e[1]}
|
|
10
10
|
})()
|
|
11
|
-
`)(i)}catch(e){return console.error(`Error executing getStaticProps in ${s}:`,e),null}}function
|
|
12
|
-
resolved against partialsDir: ${b.partialsDir}`)},onServerScriptError:(b)=>{P.push(`${g.relative(process.cwd(),b.sourcePath)} (${b.kind}): ${b.message}`)}};if(
|
|
11
|
+
`)(i)}catch(e){return console.error(`Error executing getStaticProps in ${s}:`,e),null}}function At(t){return/(?:^|[^\w$.])(?:export\s+)?(?:async\s+)?function\s+action\s*\(/.test(t)||/(?:^|[^\w$.])(?:export\s+)?(?:const|let|var)\s+action\s*=/.test(t)}async function wt(t,i,s={},r,c){let e=await Bun.file(t.filePath).text(),l=await Ot(t.filePath),w=await Tt(e,i,t.filePath),y={...l||{},...w||{},...s,params:i,$route:{path:t.pattern,params:i}},h=new Set,S=[],P=[],D={...c,...r.partialsDir?{partialsDir:r.partialsDir}:{},...r.componentsDir?{componentsDir:r.componentsDir}:{},debug:!1,cache:!1,autoShell:!0,onIncludeError:(b)=>{S.push(`${g.relative(process.cwd(),b.templatePath)}: ${b.message}
|
|
12
|
+
resolved against partialsDir: ${b.partialsDir}`)},onServerScriptError:(b)=>{P.push(`${g.relative(process.cwd(),b.sourcePath)} (${b.kind}): ${b.message}`)}};if(At(e))console.warn(`Warning: ${t.pattern} exports a page action, which cannot run in a static build. Its form will submit to a file. Serve this route with the production server, or point the form's action at a route handler.`);let p=await n(e,y,t.filePath,D,h);for(let b of[t.filePath,...h])for(let B of ue(b))h.add(B);if(Object.keys(i).length>0){let b=`<script>if(window.stx)window.stx._rp=${JSON.stringify(i)};else window.__stx_rp=${JSON.stringify(i)};</script>`;if(p.includes("</head>"))p=p.replace("</head>",`${b}
|
|
13
13
|
</head>`);else p=`${b}
|
|
14
|
-
${p}`}if(p=await J(p,{router:r.router}),p=await f(p),r.minify!==!1)return{html:
|
|
14
|
+
${p}`}if(p=await J(p,{router:r.router}),p=await f(p),r.minify!==!1)return{html:Lt(p),dependencies:Array.from(h),includeFailures:S,serverScriptFailures:P};return{html:p,dependencies:Array.from(h),includeFailures:S,serverScriptFailures:P}}function Lt(t){let i=[],s=0,r=/(<script[^>]*>)([\s\S]*?)(<\/script>)/gi,c;while((c=r.exec(t))!==null){let l=t.slice(s,c.index);i.push(l.replace(/<!--(?!\[if)[\s\S]*?-->/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><"));let w=c[1],y=c[2],h=c[3];y=y.replace(/([^:"\\'`])\/\/(?!\/)(?![*!])([^\n]*)/g,"$1"),i.push(w+y+h),s=c.index+c[0].length}let e=t.slice(s);return i.push(e.replace(/<!--(?!\[if)[\s\S]*?-->/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><")),i.join("").trim()}function Mt(t){let i=0;for(let s=0;s<t.length;s++){let r=t.charCodeAt(s);i=(i<<5)-i+r,i=i&i}return`"${Math.abs(i).toString(36)}"`}function Ut(t,i,s,r){if(s?.sitemap===!1)return!0;if(/<meta[^>]+name=["']robots["'][^>]+content=["'][^"']*noindex/i.test(i))return!0;return r.some((c)=>{if(c instanceof RegExp)return c.test(t);return c.endsWith("/")?t===c.slice(0,-1)||t.startsWith(c):t===c})}function Gt(t,i){return`<?xml version="1.0" encoding="UTF-8"?>
|
|
15
15
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
16
16
|
${t.map((r)=>{let c=new URL(r.loc,i).href,e=` <url>
|
|
17
17
|
<loc>${I(c)}</loc>`;if(r.lastmod)e+=`
|
|
@@ -41,7 +41,7 @@ ${t.map((r)=>{let c=new URL(r.loc,i).href,e=` <url>
|
|
|
41
41
|
${s.join(`
|
|
42
42
|
`)}
|
|
43
43
|
</channel>
|
|
44
|
-
</rss>`}async function zt(t={}){let i=Date.now();
|
|
44
|
+
</rss>`}async function zt(t={}){let i=Date.now();_t();let s=await o(process.cwd()),r=s.build||{},c=await ot({explicit:t.domain||r.domain,stxConfig:s});if(c.source==="fallback"&&(t.sitemap??r.sitemap??!0))console.warn(ct());let e={router:t.router??s?.router??{},pagesDir:t.pagesDir||r.pagesDir||"pages",outputDir:t.outputDir||r.outputDir||"dist",baseUrl:t.baseUrl||r.baseUrl||"/",domain:c.url,revalidate:t.revalidate??r.revalidate??!1,sitemap:t.sitemap??r.sitemap??!0,sitemapExclude:t.sitemapExclude||r.sitemapExclude||[],robots:t.robots??r.robots??!0,rss:t.rss??r.rss??!1,concurrency:t.concurrency||r.concurrency||10,cache:t.cache??r.cache??!0,cacheDir:t.cacheDir||r.cacheDir||a(process.cwd(),"ssg-cache"),contentLoaders:t.contentLoaders||[],hooks:t.hooks||{},minify:t.minify??r.minify??!0,generate404:t.generate404??r.generate404??!0,publicDir:t.publicDir||r.publicDir||"public",trailingSlash:t.trailingSlash??r.trailingSlash??!1,cleanOutput:t.cleanOutput??r.cleanOutput??!0,cacheSalt:t.cacheSalt??"",partialsDir:t.partialsDir||s?.partialsDir||"",componentsDir:t.componentsDir||s?.componentsDir||"",failOnIncludeError:t.failOnIncludeError??!0,failOnServerScriptError:t.failOnServerScriptError??!0,chunkIslands:t.chunkIslands===!0,prefetchIslands:t.prefetchIslands===!0,integrityIslands:t.integrityIslands===!0},l={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},w=new Set,y=0,h={},S={};await e.hooks.onBuildStart?.();try{if(e.cleanOutput&&x.existsSync(e.outputDir))await x.promises.rm(e.outputDir,{recursive:!0});await x.promises.mkdir(e.outputDir,{recursive:!0});let D=e.cacheSalt;if(!D){let{resolveUserCssConfig:u,fingerprintConfig:m}=await import("./chunk-c0h9cxew.js");try{D=m(await u(process.cwd()))}catch{}}let{prepareImageDelivery:p}=await import("./chunk-y8jjmwa9.js"),b=await p(e.publicDir,e.outputDir);if(b.count>0)console.log(`Optimized ${b.count} image(s) for responsive delivery`),D=[D,b.fingerprint].filter(Boolean).join(":");let B=new ht(e.cacheDir,D);if(e.cache)await B.load();try{let{generateCss:u}=await import("./chunk-c0h9cxew.js");await u('<div class="bg-black"></div>')}catch{}lt();let yt=s?.routeMiddleware?.dir||"middleware";await dt(process.cwd(),yt);let H=ut();if(H.length>0)console.log(`Loaded ${H.length} middleware: ${H.join(", ")}`);let xt=s?.routeMiddleware?.global||[];Qo(s?.layoutsDir,a(process.cwd()));let K=L(".",{pagesDir:e.pagesDir,pagesDirs:s?._layerPageDirs});console.log(`Found ${K.length} routes`);let G=[];for(let u of K){let m=await Ft(u);for(let v of m)G.push({route:u,url:v.url,params:v.params,props:v.props,revalidate:v.revalidate??e.revalidate})}l.totalPages=G.length,console.log(`Generating ${l.totalPages} pages...`);let A=[],X=[];for(let u=0;u<G.length;u+=e.concurrency)X.push(G.slice(u,u+e.concurrency));for(let u of X)await Promise.all(u.map(async(m)=>{let{route:v,url:d,params:M,props:vt,revalidate:Q}=m;try{await e.hooks.onPageStart?.(d);let j=await Bun.file(v.filePath).text(),F=Jt(j),bt=F?.middleware?Array.isArray(F.middleware)?F.middleware:[F.middleware]:[],tt=[...xt,...bt];if(tt.length>0){let C=pt(d,M,F||{}),O=ft(C,null,void 0,{isServer:!0}),E=await gt(tt,O);if(E.redirect){let R=typeof E.redirect==="string"?E.redirect:E.redirect.path||E.redirect,_=Vt(String(R),d),T=Kt(d,e);await x.promises.mkdir(g.dirname(T),{recursive:!0}),await Bun.write(T,_),l.successCount++,l.pages.push({route:d,outputPath:T,size:Buffer.byteLength(_),cached:!1}),A.push({loc:d,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${d} \u2192 redirect to ${R}`);return}if(E.abort){let R=typeof E.abort==="string"?E.abort:E.abort?.error?.message||"aborted";console.warn(` \u21B3 ${d} \u2014 middleware aborted: ${R}`);return}}let et=j.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(et)try{if(!await Function("route",`
|
|
45
45
|
const validate = ${et[1]};
|
|
46
46
|
return validate(route);
|
|
47
47
|
`)({params:M})){console.warn(`Validation failed for ${d}, skipping...`);return}}catch{}let k=null,rt=!1;if(e.cache){if(k=B.get(d,v.filePath),k)rt=!0,l.cachedCount++}if(!k){let C=await wt(v,M,vt,e,s);if(k=C.html,e.failOnIncludeError&&C.includeFailures.length>0)throw Error(`${C.includeFailures.length} include(s) failed to resolve, so this page would have shipped with an error banner where the markup should be:
|
|
@@ -50,7 +50,7 @@ ${s.join(`
|
|
|
50
50
|
Set ssg.failOnIncludeError to false to build anyway.`);if(e.failOnServerScriptError&&C.serverScriptFailures.length>0)throw Error(`${C.serverScriptFailures.length} <script server> block(s) failed, so this page would have shipped with the content they produce missing:
|
|
51
51
|
${C.serverScriptFailures.join(`
|
|
52
52
|
`)}
|
|
53
|
-
Set ssg.failOnServerScriptError to false to build anyway.`);if(e.cache)B.set(d,v.filePath,C.dependencies,k)}let U;if(e.trailingSlash)U=g.join(e.outputDir,d,"index.html");else U=d==="/"?g.join(e.outputDir,"index.html"):g.join(e.outputDir,`${d}.html`);if(e.chunkIslands){let{html:C,chunks:O}=it(k,{integrity:e.integrityIslands,minify:e.minify});if(O.length>0){let E=g.join(e.outputDir,"_stx","islands");await x.promises.mkdir(E,{recursive:!0});for(let R of O){let _=g.join(E,`${R.hash}.js`);if(!await Bun.file(_).exists())await Bun.write(_,R.code);if(!w.has(R.hash)){w.add(R.hash);let T=Buffer.byteLength(R.code,"utf8");y+=T,h[R.hash]={bytes:T,file:`/_stx/islands/${R.hash}.js`}}}if(S[d]=O.map((R)=>R.hash),k=C,e.prefetchIslands)k=st(k)}}if(await x.promises.mkdir(g.dirname(U),{recursive:!0}),await Bun.write(U,k),!
|
|
53
|
+
Set ssg.failOnServerScriptError to false to build anyway.`);if(e.cache)B.set(d,v.filePath,C.dependencies,k)}let U;if(e.trailingSlash)U=g.join(e.outputDir,d,"index.html");else U=d==="/"?g.join(e.outputDir,"index.html"):g.join(e.outputDir,`${d}.html`);if(e.chunkIslands){let{html:C,chunks:O}=it(k,{integrity:e.integrityIslands,minify:e.minify});if(O.length>0){let E=g.join(e.outputDir,"_stx","islands");await x.promises.mkdir(E,{recursive:!0});for(let R of O){let _=g.join(E,`${R.hash}.js`);if(!await Bun.file(_).exists())await Bun.write(_,R.code);if(!w.has(R.hash)){w.add(R.hash);let T=Buffer.byteLength(R.code,"utf8");y+=T,h[R.hash]={bytes:T,file:`/_stx/islands/${R.hash}.js`}}}if(S[d]=O.map((R)=>R.hash),k=C,e.prefetchIslands)k=st(k)}}if(await x.promises.mkdir(g.dirname(U),{recursive:!0}),await Bun.write(U,k),!Ut(d,k,F,e.sitemapExclude))A.push({loc:d,lastmod:new Date().toISOString().split("T")[0],priority:d==="/"?1:0.8});let nt={route:d,outputPath:U,size:Buffer.byteLength(k,"utf8"),cached:rt};if(Q!==!1)nt.revalidateAt=Date.now()+Q*1000;l.pages.push(nt),l.successCount++,await e.hooks.onPageEnd?.(d,k)}catch(j){l.failedCount++,l.errors.push({route:d,error:j}),await e.hooks.onError?.(j,d),console.error(`Error generating ${d}:`,j)}}));let Y=Ct();if(Y.length>0){let u=Y.map((m)=>`${m.filePath}: ${m.message}`).join(`
|
|
54
54
|
`);throw Error(`Client script bundling failed:
|
|
55
55
|
${u}`)}if(e.cache)await B.save();if(e.generate404){let u=g.join(e.pagesDir,"404.stx");if(await Bun.file(u).exists()){let m=new Set,v={...s,debug:!1,cache:!1},d=await n(await Bun.file(u).text(),{},u,v,m);await Bun.write(g.join(e.outputDir,"404.html"),d)}else await Bun.write(g.join(e.outputDir,"404.html"),`<!DOCTYPE html>
|
|
56
56
|
<html lang="en">
|
|
@@ -73,7 +73,7 @@ ${u}`)}if(e.cache)await B.save();if(e.generate404){let u=g.join(e.pagesDir,"404.
|
|
|
73
73
|
<a href="/">Go home</a>
|
|
74
74
|
</div>
|
|
75
75
|
</body>
|
|
76
|
-
</html>`)}for(let u of[500]){let m=g.join(e.pagesDir,`${u}.stx`);if(await Bun.file(m).exists()){let v=new Set,d={...s,debug:!1,cache:!1},M=await n(await Bun.file(m).text(),{},m,d,v);await Bun.write(g.join(e.outputDir,`${u}.html`),M)}}let W=g.join(e.pagesDir,"error.stx");if(await Bun.file(W).exists()){let u=new Set,m={...s,debug:!1,cache:!1},v=await n(await Bun.file(W).text(),{},W,m,u);await Bun.write(g.join(e.outputDir,"error.html"),v)}if(e.sitemap&&A.length>0){let u=Gt(A,e.domain),m=g.join(e.outputDir,"sitemap.xml");await Bun.write(m,u),l.sitemapPath=m,console.log(`Generated sitemap.xml with ${A.length} URLs`)}if(e.robots!==!1){let u=typeof e.robots==="object"?e.robots:{},m=[...e.sitemapExclude.filter((d)=>typeof d==="string"),...u.disallow||[]],v=
|
|
76
|
+
</html>`)}for(let u of[500]){let m=g.join(e.pagesDir,`${u}.stx`);if(await Bun.file(m).exists()){let v=new Set,d={...s,debug:!1,cache:!1},M=await n(await Bun.file(m).text(),{},m,d,v);await Bun.write(g.join(e.outputDir,`${u}.html`),M)}}let W=g.join(e.pagesDir,"error.stx");if(await Bun.file(W).exists()){let u=new Set,m={...s,debug:!1,cache:!1},v=await n(await Bun.file(W).text(),{},W,m,u);await Bun.write(g.join(e.outputDir,"error.html"),v)}if(e.sitemap&&A.length>0){let u=Gt(A,e.domain),m=g.join(e.outputDir,"sitemap.xml");await Bun.write(m,u),l.sitemapPath=m,console.log(`Generated sitemap.xml with ${A.length} URLs`)}if(e.robots!==!1){let u=typeof e.robots==="object"?e.robots:{},m=[...e.sitemapExclude.filter((d)=>typeof d==="string"),...u.disallow||[]],v=br({rules:[{userAgent:u.userAgent||"*",allow:u.allow||["/"],...m.length>0?{disallow:m}:{}}],...u.sitemap!==!1&&l.sitemapPath?{sitemap:new URL("/sitemap.xml",e.domain).href}:{}});await Bun.write(g.join(e.outputDir,"robots.txt"),v),console.log("Generated robots.txt")}if(e.rss){let u=typeof e.rss==="object"?e.rss:{title:"Site Feed",description:"Latest updates",link:e.domain},m=[];if(u.getItems)m=await u.getItems();let v=Nt(u,m),d=g.join(e.outputDir,"rss.xml");await Bun.write(d,v),l.rssPath=d,console.log(`Generated rss.xml with ${m.length} items`)}let N=Yo(e.outputDir);if(N.assets>0)console.log(`Externalized ${N.assets} asset(s) from ${N.pages} page(s) (${(N.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);let z=Zo(e.outputDir);if(z.assets>0)console.log(`Externalized ${z.assets} repeated asset(s) from ${z.pages} page(s) (${(z.bytesInlined/1024).toFixed(1)}KB removed from HTML)`);if(e.publicDir&&x.existsSync(e.publicDir))await V(e.publicDir,e.outputDir),console.log(`Copied public assets from ${e.publicDir}`);let Z=pn();if(Z)await V(Z,g.join(e.outputDir,dn)),console.log(`Copied assets from ${St}`)}catch(D){throw await e.hooks.onError?.(D),D}if(l.buildTime=Date.now()-i,w.size>0){l.islandChunks={count:w.size,totalBytes:y};let D={generatedChunks:w.size,totalBytes:y,chunks:h,pages:S};await Bun.write(g.join(e.outputDir,"_stx","islands-manifest.json"),JSON.stringify(D,null,2))}await e.hooks.onBuildEnd?.(l);let P=l.islandChunks?`
|
|
77
77
|
Island chunks: ${l.islandChunks.count} (${(l.islandChunks.totalBytes/1024).toFixed(1)} KB lifted out of inline HTML)`:"";return console.log(`
|
|
78
78
|
Build complete!
|
|
79
79
|
Total: ${l.totalPages} pages
|
|
@@ -81,8 +81,8 @@ Build complete!
|
|
|
81
81
|
Cached: ${l.cachedCount}
|
|
82
82
|
Failed: ${l.failedCount}
|
|
83
83
|
Time: ${l.buildTime}ms${P}
|
|
84
|
-
`),l}async function V(t,i){await x.promises.mkdir(i,{recursive:!0});let s=await x.promises.readdir(t,{withFileTypes:!0});for(let r of s){let c=g.join(t,r.name),e=g.join(i,r.name);if(r.isDirectory())await x.promises.mkdir(e,{recursive:!0}),await V(c,e);else await x.promises.copyFile(c,e)}}function Ht(t={}){let i=t.cacheDir||a(process.cwd(),"ssg-cache"),s=new mt(i),r=t.revalidate||3600;return{async get(c){let e=await s.get(c);if(!e)return null;if(Date.now()>e.revalidateAfter)this.revalidate(c).catch(console.error);return{html:e.html,headers:{"Cache-Control":`public, max-age=${r}, stale-while-revalidate=${r*2}`,ETag:e.etag,"X-ISR-Generated":new Date(e.generatedAt).toISOString(),...e.headers}}},async revalidate(c){let l=L(".",{pagesDir:t.pagesDir||"pages"}).find((P)=>c.match(P.regex)!==null);if(!l){console.warn(`Route not found for revalidation: ${c}`);return}let w=c.match(l.regex),y={};if(w)l.params.forEach((P,D)=>{y[P]=w[D+1]});let h=await o(),{html:S}=await wt(l,y,{},t,h);await s.set(c,{html:S,generatedAt:Date.now(),revalidateAfter:Date.now()+r*1000,etag:
|
|
85
|
-
`)){let P=S.indexOf(":");if(P>0){let D=S.slice(0,P).trim(),p=S.slice(P+1).trim();if(p==="true")p=!0;else if(p==="false")p=!1;else if(/^\d+$/.test(p))p=parseInt(p,10);else if(/^\d+\.\d+$/.test(p))p=parseFloat(p);else if(p.startsWith("[")&&p.endsWith("]"))p=p.slice(1,-1).split(",").map((b)=>b.trim().replace(/^['"]|['"]$/g,""));r[D]=p}}}let e=c.replace(/^### (.*$)/gim,"<h3>$1</h3>").replace(/^## (.*$)/gim,"<h2>$1</h2>").replace(/^# (.*$)/gim,"<h1>$1</h1>").replace(/\*\*(.*)\*\*/gim,"<strong>$1</strong>").replace(/\*(.*)\*/gim,"<em>$1</em>").replace(/`([^`]+)`/gim,"<code>$1</code>").replace(/\[([^\]]+)\]\(([^)]+)\)/gim,'<a href="$2">$1</a>').replace(/\n/gim,"<br>"),l=[],w=/<h([1-6])>([^<]+)<\/h[1-6]>/gi,y;while((y=w.exec(e))!==null){let h=parseInt(y[1],10),S=y[2],P=S.toLowerCase().replace(/[^a-z0-9]+/g,"-");l.push({id:P,text:S,level:h})}return{content:e,data:r,toc:l}}}}function Jt(t){return
|
|
84
|
+
`),l}async function V(t,i){await x.promises.mkdir(i,{recursive:!0});let s=await x.promises.readdir(t,{withFileTypes:!0});for(let r of s){let c=g.join(t,r.name),e=g.join(i,r.name);if(r.isDirectory())await x.promises.mkdir(e,{recursive:!0}),await V(c,e);else await x.promises.copyFile(c,e)}}function Ht(t={}){let i=t.cacheDir||a(process.cwd(),"ssg-cache"),s=new mt(i),r=t.revalidate||3600;return{async get(c){let e=await s.get(c);if(!e)return null;if(Date.now()>e.revalidateAfter)this.revalidate(c).catch(console.error);return{html:e.html,headers:{"Cache-Control":`public, max-age=${r}, stale-while-revalidate=${r*2}`,ETag:e.etag,"X-ISR-Generated":new Date(e.generatedAt).toISOString(),...e.headers}}},async revalidate(c){let l=L(".",{pagesDir:t.pagesDir||"pages"}).find((P)=>c.match(P.regex)!==null);if(!l){console.warn(`Route not found for revalidation: ${c}`);return}let w=c.match(l.regex),y={};if(w)l.params.forEach((P,D)=>{y[P]=w[D+1]});let h=await o(),{html:S}=await wt(l,y,{},t,h);await s.set(c,{html:S,generatedAt:Date.now(),revalidateAfter:Date.now()+r*1000,etag:Mt(S)}),console.log(`Revalidated: ${c}`)},async invalidate(c){if(typeof c==="string")await s.invalidate(c);else await s.invalidatePattern(c)}}}function Wt(t){return async()=>({paths:await t(),fallback:!1})}function qt(){return{name:"markdown",extensions:[".md",".mdx"],async load(t){let i=await Bun.file(t).text(),s=i.match(/^---\n([\s\S]*?)\n---/),r={},c=i;if(s){let h=s[1];c=i.slice(s[0].length).trim();for(let S of h.split(`
|
|
85
|
+
`)){let P=S.indexOf(":");if(P>0){let D=S.slice(0,P).trim(),p=S.slice(P+1).trim();if(p==="true")p=!0;else if(p==="false")p=!1;else if(/^\d+$/.test(p))p=parseInt(p,10);else if(/^\d+\.\d+$/.test(p))p=parseFloat(p);else if(p.startsWith("[")&&p.endsWith("]"))p=p.slice(1,-1).split(",").map((b)=>b.trim().replace(/^['"]|['"]$/g,""));r[D]=p}}}let e=c.replace(/^### (.*$)/gim,"<h3>$1</h3>").replace(/^## (.*$)/gim,"<h2>$1</h2>").replace(/^# (.*$)/gim,"<h1>$1</h1>").replace(/\*\*(.*)\*\*/gim,"<strong>$1</strong>").replace(/\*(.*)\*/gim,"<em>$1</em>").replace(/`([^`]+)`/gim,"<code>$1</code>").replace(/\[([^\]]+)\]\(([^)]+)\)/gim,'<a href="$2">$1</a>').replace(/\n/gim,"<br>"),l=[],w=/<h([1-6])>([^<]+)<\/h[1-6]>/gi,y;while((y=w.exec(e))!==null){let h=parseInt(y[1],10),S=y[2],P=S.toLowerCase().replace(/[^a-z0-9]+/g,"-");l.push({id:P,text:S,level:h})}return{content:e,data:r,toc:l}}}}function Jt(t){return Ke(t)}function Vt(t,i){return`<!DOCTYPE html>
|
|
86
86
|
<html>
|
|
87
87
|
<head>
|
|
88
88
|
<meta charset="utf-8">
|
|
@@ -94,4 +94,4 @@ Build complete!
|
|
|
94
94
|
<p>Redirecting to <a href="${t}">${t}</a>...</p>
|
|
95
95
|
<script>window.location.replace('${t}')</script>
|
|
96
96
|
</body>
|
|
97
|
-
</html>`}function Kt(t,i){if(t==="/"||t==="")return g.join(i.outputDir,"index.html");let s=t.replace(/^\/|\/$/g,"");if(i.trailingSlash)return g.join(i.outputDir,s,"index.html");return g.join(i.outputDir,`${s}.html`)}var ye={generateStaticSite:zt,createISRHandler:Ht,defineStaticPaths:Wt,createMarkdownLoader:qt};export{Ht as createISRHandler,qt as createMarkdownLoader,
|
|
97
|
+
</html>`}function Kt(t,i){if(t==="/"||t==="")return g.join(i.outputDir,"index.html");let s=t.replace(/^\/|\/$/g,"");if(i.trailingSlash)return g.join(i.outputDir,s,"index.html");return g.join(i.outputDir,`${s}.html`)}var ye={generateStaticSite:zt,createISRHandler:Ht,defineStaticPaths:Wt,createMarkdownLoader:qt};export{Ht as createISRHandler,qt as createMarkdownLoader,At as declaresPageAction,ye as default,Wt as defineStaticPaths,zt as generateStaticSite,Ut as isExcludedFromSitemap};
|
package/dist/stx-virtual-ts.js
CHANGED
|
@@ -6,6 +6,7 @@ import { parseLoopBinding } from "./loop-binding.js";
|
|
|
6
6
|
import { bracketDepths, stripCommentsAndLiterals } from "./strip-literals.js";
|
|
7
7
|
import { STX_RUNTIME_GLOBALS } from "./runtime-globals.js";
|
|
8
8
|
import { componentContractChecks } from "./component-contract-checks.js";
|
|
9
|
+
import { collectSlotScopes } from "./slot-scopes.js";
|
|
9
10
|
const SCRIPT_RE = /<script(\s[^>]*)?>([\s\S]*?)<\/script>/gi;
|
|
10
11
|
function blankCommentContents(source) {
|
|
11
12
|
const blank = (match) => match.replace(/[^\n]/g, " ");
|
|
@@ -771,7 +772,7 @@ export function buildVirtualTypeScript(source, options = {}) {
|
|
|
771
772
|
}).filter((entry) => entry.statement !== null);
|
|
772
773
|
statements.push(...components?.checks || []);
|
|
773
774
|
if (statements.length > 0) {
|
|
774
|
-
const maskedSource = maskNonTemplateRegions(source), conditionAliases = collectConditionAliases(blocks.map((block) => block.code)), shadowed = [...new Set(blocks.flatMap((block) => collectBlockDeclarations(block.code)))].filter((name) => /^[A-Z_$][\w$]*$/i.test(name));
|
|
775
|
+
const maskedSource = maskNonTemplateRegions(source), slotScopes = collectSlotScopes(maskedSource), conditionAliases = collectConditionAliases(blocks.map((block) => block.code)), shadowed = [...new Set(blocks.flatMap((block) => collectBlockDeclarations(block.code)))].filter((name) => /^[A-Z_$][\w$]*$/i.test(name));
|
|
775
776
|
let indent = 0;
|
|
776
777
|
if (shadowed.length > 0) {
|
|
777
778
|
append(UNWRAP_HELPER_DECL);
|
|
@@ -781,13 +782,13 @@ export function buildVirtualTypeScript(source, options = {}) {
|
|
|
781
782
|
indent = 1;
|
|
782
783
|
}
|
|
783
784
|
for (const { expression, statement } of statements) {
|
|
784
|
-
const pad = " ".repeat(indent), guards = expression.offset === void 0 ? [] : guardChainAt(maskedSource, expression.offset), guardPrefix = guards.length > 0 ? `${guards.map((condition) => `if (${expandConditionAliases(condition, conditionAliases)}) `).join("")}{ ` : "", guardSuffix = guards.length > 0 ? " }" : "";
|
|
785
|
-
append(pad + guardPrefix + statement.text + guardSuffix, {
|
|
785
|
+
const pad = " ".repeat(indent), enclosingSlots = expression.offset === void 0 ? [] : slotScopes.filter((scope) => expression.offset >= scope.start && expression.offset < scope.end), slotPrefix = enclosingSlots.map((scope) => `;((${scope.binding.replace(/[\r\n]/g, " ")}: any) => { `).join(""), slotSuffix = " });".repeat(enclosingSlots.length), guards = expression.offset === void 0 ? [] : guardChainAt(maskedSource, expression.offset), guardPrefix = guards.length > 0 ? `${guards.map((condition) => `if (${expandConditionAliases(condition, conditionAliases)}) `).join("")}{ ` : "", guardSuffix = guards.length > 0 ? " }" : "";
|
|
786
|
+
append(pad + slotPrefix + guardPrefix + statement.text + guardSuffix + slotSuffix, {
|
|
786
787
|
line: expression.line,
|
|
787
788
|
column: expression.column,
|
|
788
789
|
expression,
|
|
789
|
-
prefixLength: statement.prefixLength + pad.length + guardPrefix.length,
|
|
790
|
-
guardPrefixLength: pad.length + guardPrefix.length
|
|
790
|
+
prefixLength: statement.prefixLength + pad.length + slotPrefix.length + guardPrefix.length,
|
|
791
|
+
guardPrefixLength: pad.length + slotPrefix.length + guardPrefix.length
|
|
791
792
|
});
|
|
792
793
|
}
|
|
793
794
|
if (indent > 0)
|
package/dist/utils.d.ts
CHANGED
|
@@ -65,7 +65,7 @@ export declare function slotContentHasExpressions(slotContent: string): boolean;
|
|
|
65
65
|
* named `title` also exists in the server context.
|
|
66
66
|
*/
|
|
67
67
|
export declare function componentClientSignalNames(scripts: string[]): string[];
|
|
68
|
-
export declare function renderComponentWithSlot(componentPath: string, props: Record<string, unknown>, slotContent: string, componentsDir: string, parentContext: Record<string, unknown>, parentFilePath: string, options: StxOptions, processedComponents?: Set<string> | undefined, dependencies: Set<string>, clientLoopNames?: readonly string[], renderMetadata?: { declaredProps: Set<string>, consumedProps?: Set<string>, reactiveProps?: string[] }, lookupName?: string): Promise<string>;
|
|
68
|
+
export declare function renderComponentWithSlot(componentPath: string, props: Record<string, unknown>, slotContent: string, componentsDir: string, parentContext: Record<string, unknown>, parentFilePath: string, options: StxOptions, processedComponents?: Set<string> | undefined, dependencies: Set<string>, clientLoopNames?: readonly string[], renderMetadata?: { declaredProps: Set<string>, consumedProps?: Set<string>, reactiveProps?: string[], events?: string[] }, lookupName?: string): Promise<string>;
|
|
69
69
|
/**
|
|
70
70
|
* Check if a file exists
|
|
71
71
|
*/
|
package/dist/utils.js
CHANGED
|
@@ -635,7 +635,7 @@ export async function renderComponentWithSlot(componentPath, props, slotContent,
|
|
|
635
635
|
searchDirs.push(parentRelative);
|
|
636
636
|
if (options.componentsDir && options.componentsDir !== componentsDir && !searchDirs.includes(options.componentsDir))
|
|
637
637
|
searchDirs.push(options.componentsDir);
|
|
638
|
-
const targetIsFallback = options._targetComponentFallbackNames?.some((name) => name.toLowerCase() === baseName.toLowerCase());
|
|
638
|
+
const checkedControl = options._nativeHostAttrs && /^(?:checkbox|switch)$/i.test(baseName), eventNames = (renderMetadata?.events ?? []).map((name) => name.replace(/^@/, "").split(".")[0].toLowerCase().replace(/-/g, "")), sharedCheckedUsage = !eventNames.includes("valuechange") && (Object.hasOwn(props, "checked") || renderMetadata?.reactiveProps?.includes("checked") || eventNames.includes("change")), targetIsFallback = options._targetComponentFallbackNames?.some((name) => name.toLowerCase() === baseName.toLowerCase()) && (!checkedControl || sharedCheckedUsage);
|
|
639
639
|
for (const dir of targetIsFallback ? [] : options._targetComponentDirs ?? [])
|
|
640
640
|
if (dir && !searchDirs.includes(dir))
|
|
641
641
|
searchDirs.push(dir);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/stx",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.606",
|
|
5
5
|
"description": "A performant UI Framework. Powered by Bun.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -128,12 +128,12 @@
|
|
|
128
128
|
"dependencies": {
|
|
129
129
|
"@stacksjs/ts-css": "^0.3.11",
|
|
130
130
|
"@stacksjs/clapp": "^0.2.16",
|
|
131
|
-
"@stacksjs/desktop": "0.2.
|
|
132
|
-
"@stacksjs/sanitizer": "0.2.
|
|
131
|
+
"@stacksjs/desktop": "0.2.606",
|
|
132
|
+
"@stacksjs/sanitizer": "0.2.606",
|
|
133
133
|
"@stacksjs/ts-i18n": "^0.1.11",
|
|
134
|
-
"bun-plugin-stx": "0.2.
|
|
134
|
+
"bun-plugin-stx": "0.2.606",
|
|
135
135
|
"bunfig": "^0.15.21",
|
|
136
|
-
"stx-router": "0.2.
|
|
136
|
+
"stx-router": "0.2.606",
|
|
137
137
|
"ts-broadcasting": "^0.0.11",
|
|
138
138
|
"ts-images": "^0.2.22",
|
|
139
139
|
"ts-syntax-highlighter": "^0.2.1"
|
package/dist/chunk-00vp75pj.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{pd,Ic,Cs,_s,xi,Si,Es,Ts,ar,Oc,ki,Ci,Dc,Ye}from"./chunk-j0z7010x.js";import"./chunk-t19th11m.js";import"./chunk-v8ze2q95.js";import"./chunk-k71e38fk.js";import"./chunk-jczknjbw.js";import"./chunk-48s1nprc.js";import"./chunk-qf39z0hg.js";import"./chunk-gh181dnr.js";import"./chunk-38mt83wa.js";import"./chunk-jtq8e3b0.js";import"./chunk-b3c1gggs.js";import"./chunk-nfht2ryp.js";import"./chunk-82bttwqm.js";export{pd as clearScriptScanCache,Es as convertServerLoopAttributesToDirectives,xi as convertSignalDirectivesToAttributes,Ts as convertSignalLoopsToAttributes,Oc as extractExports,Ci as findMarkupIndexOutsideScripts,_s as hasSignalsSyntax,Cs as parseLoopExpression,Si as preEvalLiteralReactiveIfs,ar as processScriptSetup,ki as processSignals,Dc as rewriteStxImportSpecifiers,Ic as scanScriptTags,Ye as stripStxRuntimeImports};
|
package/dist/chunk-04gt67sv.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{qr,Gr,Kr,Oa,Xr,Jr,Da,Yr,Zr,Do,Na}from"./chunk-gzpxvca7.js";export{qr as VideoProcessorCache,Do as analyzeVideo,Oa as clearVideoCache,Zr as generateDASHManifest,Yr as generateHLSManifest,Xr as generatePoster,Da as generateSpriteSheet,Jr as generateThumbnails,Gr as getCachedVideoResult,Na as processVideo,Kr as setCachedVideoResult};
|