@stacksjs/stx 0.2.517 → 0.2.519
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/browser-auto-imports.d.ts +26 -0
- package/dist/browser-core-imports.d.ts +2 -0
- package/dist/browser-core-imports.js +9 -0
- package/dist/{chunk-zffc870e.js → chunk-02fry4k9.js} +5 -5
- package/dist/{chunk-a80pc7yk.js → chunk-0d9znrk3.js} +1 -1
- package/dist/{chunk-8p3knpcz.js → chunk-0rc0zanq.js} +2 -2
- package/dist/{chunk-2e3x5h3x.js → chunk-0sc4hfpz.js} +1 -1
- package/dist/{chunk-0zv8ftnn.js → chunk-10n5sjnc.js} +1 -1
- package/dist/{chunk-2yjes3gp.js → chunk-28jnw45c.js} +1 -1
- package/dist/{chunk-10xg8gds.js → chunk-2r852nze.js} +1 -1
- package/dist/{chunk-3f9999cj.js → chunk-2xjf207h.js} +1 -1
- package/dist/{chunk-d2w32ck9.js → chunk-383fpjag.js} +1 -1
- package/dist/{chunk-yybzcsjv.js → chunk-3rt07ec9.js} +1 -1
- package/dist/{chunk-ytcqk6np.js → chunk-49mkn02f.js} +1 -1
- package/dist/{chunk-9afwh767.js → chunk-4ka1vqzc.js} +164 -155
- package/dist/{chunk-hv92fwyw.js → chunk-5pwdgk0p.js} +1 -1
- package/dist/{chunk-add8tq7t.js → chunk-5snae0x9.js} +4 -1
- package/dist/{chunk-5e6bhs6v.js → chunk-7wp5r7er.js} +1 -1
- package/dist/{chunk-s78m3jpp.js → chunk-8b1g1dyc.js} +1 -1
- package/dist/{chunk-ts8an4wm.js → chunk-8e062ckg.js} +1 -1
- package/dist/{chunk-g2990jbf.js → chunk-8yzj60vj.js} +1 -1
- package/dist/{chunk-frfjy37k.js → chunk-bhah6ngn.js} +1 -1
- package/dist/chunk-bj98tbj4.js +2 -0
- package/dist/{chunk-6stn6vtm.js → chunk-bv9bf961.js} +1 -1
- package/dist/{chunk-t768bb57.js → chunk-c311fczy.js} +1 -1
- package/dist/{chunk-f1cm6kh5.js → chunk-dgd0pedw.js} +2 -2
- package/dist/{chunk-vxzt9dhb.js → chunk-ebx5vyzv.js} +1 -1
- package/dist/{chunk-833fqs6p.js → chunk-emhqzh0r.js} +1 -1
- package/dist/{chunk-pvvd41f9.js → chunk-eyq96y73.js} +1 -1
- package/dist/{chunk-s84ygk4m.js → chunk-f8sp9dpx.js} +1 -1
- package/dist/{chunk-q3z8c54t.js → chunk-fgvhepsg.js} +1 -1
- package/dist/chunk-gxjscw5n.js +45 -0
- package/dist/{chunk-jjhn731j.js → chunk-hrxj9rvt.js} +1 -1
- package/dist/chunk-j39n1p72.js +2 -0
- package/dist/{chunk-2afm5p56.js → chunk-jv96mqj5.js} +1 -1
- package/dist/{chunk-y08ncpqj.js → chunk-jvygw613.js} +1 -1
- package/dist/{chunk-0x2qent6.js → chunk-krmfkjmr.js} +1 -1
- package/dist/{chunk-38jkc8p6.js → chunk-kwkhhb3p.js} +1 -1
- package/dist/{chunk-vad0zphe.js → chunk-m49ar4nx.js} +1 -1
- package/dist/{chunk-b3mfy2eb.js → chunk-mdfggh1k.js} +2 -2
- package/dist/{chunk-trzwxf9q.js → chunk-mqhc108n.js} +1 -1
- package/dist/{chunk-pmctmsqq.js → chunk-nne0200a.js} +1 -1
- package/dist/chunk-ssq3veat.js +2 -0
- package/dist/{chunk-8xz090ne.js → chunk-tqyv643n.js} +1 -1
- package/dist/{chunk-mzdjpm84.js → chunk-v0pm4sb7.js} +1 -1
- package/dist/{chunk-r17fgrax.js → chunk-v5hx02q8.js} +1 -1
- package/dist/{chunk-bg48xvb7.js → chunk-vgjeneva.js} +1 -1
- package/dist/{chunk-0wsywdaq.js → chunk-w6chh1c7.js} +1 -1
- package/dist/{chunk-mge6kj6e.js → chunk-wjnt2rxg.js} +1 -1
- package/dist/{chunk-hkwjanc9.js → chunk-wkrpxnfa.js} +1 -1
- package/dist/{chunk-012h75ke.js → chunk-wvgr7d7p.js} +1 -1
- package/dist/{chunk-aad7fmvp.js → chunk-xa3sy06t.js} +1 -1
- package/dist/{chunk-jz87m1j8.js → chunk-xyqw5y8g.js} +1 -1
- package/dist/cli.js +8 -8
- package/dist/client-script.js +10 -1
- package/dist/component-renderer.js +3 -30
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/native/compiler/component-mapping.js +1 -0
- package/dist/native/compiler/html-to-ir.js +24 -0
- package/dist/native/compiler/ir.d.ts +1 -0
- package/dist/native/compiler/svg.d.ts +7 -0
- package/dist/native/compiler/svg.js +144 -0
- package/dist/native/components/primitives.d.ts +11 -0
- package/dist/native/components/primitives.js +1 -0
- package/dist/native/primitives/Checkbox.stx +5 -0
- package/dist/native/runtime/binding-tree.js +1 -1
- package/dist/native/runtime/native-host.d.ts +1 -0
- package/dist/native/runtime/native-host.js +54 -2
- package/dist/pwa.js +1 -1
- package/dist/signals.js +4 -1
- package/dist/ssg.js +2 -2
- package/dist/stx.d.ts +2 -0
- package/package.json +6 -5
- package/stx.d.ts +2 -0
- package/dist/chunk-1jwjtcvd.js +0 -2
- package/dist/chunk-c1d3c45y.js +0 -45
- package/dist/chunk-dpg7gtv5.js +0 -2
- package/dist/chunk-sfx3zz08.js +0 -2
package/dist/craft.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Hr,Ao,Po}from"./chunk-tkagcknf.js";import"./chunk-365ktg70.js";import"./chunk-c57j92td.js";import"./chunk-1aw9qbdf.js";import"./chunk-yxdyh23k.js";import"./chunk-ba88n1j7.js";import"./chunk-
|
|
2
|
+
import{Hr,Ao,Po}from"./chunk-tkagcknf.js";import"./chunk-365ktg70.js";import"./chunk-c57j92td.js";import"./chunk-1aw9qbdf.js";import"./chunk-yxdyh23k.js";import"./chunk-ba88n1j7.js";import"./chunk-4ka1vqzc.js";import"./chunk-gynes6rm.js";import"./chunk-gbfap7rv.js";import"./chunk-6k4f583z.js";import"./chunk-c311fczy.js";import"./chunk-e6y6s7q8.js";import"./chunk-kp4mzspk.js";import{wd,ko,vd,xd,Co,zr,Eo,Sd,$o,kd,Cd,_o,To,Ro}from"./chunk-ebx5vyzv.js";import"./chunk-mdfggh1k.js";import"./chunk-fxxrrq9n.js";var m=new Map,d=new Map;function R(t,e){let n=e?.id||E(t),r=I(t),a=m.get(n);if(a&&a.hash===r)return a;let i=M(t),s=L(t),o=W(t),c=O(i),{staticParts:p,dynamicParts:l}=A(i),f=_(t),g={id:n,hash:r,tree:i,scripts:s,styles:o,staticParts:p,dynamicParts:l,dependencies:f,metadata:c};return m.set(n,g),g}async function Q(t,e={},n={}){let r=performance.now();if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`,c=d.get(o);if(c&&Date.now()-c.timestamp<(n.cacheTTL||60000))return{html:c.html,styles:t.styles.join(`
|
|
3
3
|
`),scripts:t.scripts.join(`
|
|
4
4
|
`),metadata:{renderTime:0,cacheHit:!0,totalSize:c.html.length,componentCount:t.metadata.componentCount}}}let a;if(n.streaming)a=await H(t.tree,e);else a=h(t.tree,e);let i;if(n.hydrate){let o=j(a,t,e);a=o.html,i=o.data}if(n.minify)a=D(a);if(n.cache){let o=`${t.id}:${JSON.stringify(e)}`;d.set(o,{html:a,timestamp:Date.now()})}let s=performance.now()-r;return{html:a,styles:t.styles.join(`
|
|
5
5
|
`),scripts:t.scripts.join(`
|
|
@@ -259,6 +259,7 @@ const STYLE_KEYS = new Set([
|
|
|
259
259
|
"FlatList",
|
|
260
260
|
"SectionList",
|
|
261
261
|
"Switch",
|
|
262
|
+
"Checkbox",
|
|
262
263
|
"Slider",
|
|
263
264
|
"Picker",
|
|
264
265
|
"DatePicker",
|
|
@@ -356,6 +357,21 @@ function readAttributes(tag, attributes, diagnostics) {
|
|
|
356
357
|
const style = { ...classes ? compileClassStyles(classes).style : {}, ...inline };
|
|
357
358
|
return { props, style, events, bindings, classes, inline };
|
|
358
359
|
}
|
|
360
|
+
function structuredStyle(property, value) {
|
|
361
|
+
if (property === "shadowOffset") {
|
|
362
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
363
|
+
return;
|
|
364
|
+
const { width, height } = value;
|
|
365
|
+
return typeof width === "number" && typeof height === "number" ? { width, height } : void 0;
|
|
366
|
+
}
|
|
367
|
+
if (property === "transform") {
|
|
368
|
+
if (!Array.isArray(value))
|
|
369
|
+
return;
|
|
370
|
+
const steps = value.filter((step) => Boolean(step) && typeof step === "object" && !Array.isArray(step) && Object.keys(step).length === 1).filter((step) => ["number", "string"].includes(typeof Object.values(step)[0]));
|
|
371
|
+
return steps.length ? steps : void 0;
|
|
372
|
+
}
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
359
375
|
function holdsString(property, value) {
|
|
360
376
|
if (NUMERIC_STYLE_KEYS.has(property))
|
|
361
377
|
return !1;
|
|
@@ -377,6 +393,14 @@ function inlineStyle(tag, css, diagnostics) {
|
|
|
377
393
|
if (rawValue === null || rawValue === void 0)
|
|
378
394
|
continue;
|
|
379
395
|
const translated = typeof rawValue === "string" ? styleValue(rawValue) : rawValue;
|
|
396
|
+
if (typeof translated === "object") {
|
|
397
|
+
const kept = structuredStyle(property, translated);
|
|
398
|
+
if (kept === void 0)
|
|
399
|
+
diagnostics.push({ kind: "non-numeric-style", tag, name: property });
|
|
400
|
+
else
|
|
401
|
+
style[property] = kept;
|
|
402
|
+
continue;
|
|
403
|
+
}
|
|
380
404
|
if (typeof translated !== "string" && typeof translated !== "number")
|
|
381
405
|
continue;
|
|
382
406
|
if (typeof translated === "string" && !holdsString(property, translated)) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { STXNode } from './ir';
|
|
1
2
|
/** `"0 0 320 180"` (or with commas) to four numbers, or null. */
|
|
2
3
|
export declare function parseViewBox(value: unknown): [number, number, number, number] | null;
|
|
3
4
|
/** Path data to absolute commands. Unknown or malformed parts end the path, as a browser does. */
|
|
@@ -9,6 +10,12 @@ export declare function pathGeometry(d: string): number[];
|
|
|
9
10
|
export declare function svgGeometry(type: string, props: Record<string, unknown>): number[] | null;
|
|
10
11
|
/** Whether changing `attribute` on a `type` node changes its outline. */
|
|
11
12
|
export declare function affectsGeometry(type: string, attribute: string): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Parse an SVG fragment that arrived at runtime into the same IR used for
|
|
15
|
+
* inline SVG. This deliberately has no DOM or Bun dependency: native screens
|
|
16
|
+
* run in JavaScriptCore, where the markup often came from an API response.
|
|
17
|
+
*/
|
|
18
|
+
export declare function parseSvgMarkup(markup: string): STXNode[];
|
|
12
19
|
/**
|
|
13
20
|
* Vector drawing for native screens: `<svg>` and the shapes inside it.
|
|
14
21
|
*
|
|
@@ -412,3 +412,147 @@ export function svgGeometry(type, props) {
|
|
|
412
412
|
export function affectsGeometry(type, attribute) {
|
|
413
413
|
return SVG_GEOMETRY_ATTRIBUTES[type]?.includes(attribute) ?? !1;
|
|
414
414
|
}
|
|
415
|
+
export function parseSvgMarkup(markup) {
|
|
416
|
+
const roots = [], stack = [];
|
|
417
|
+
let cursor = 0;
|
|
418
|
+
const decode = (value) => value.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/�?39;|'/gi, "'").replace(/&/g, "&"), camel = (name) => {
|
|
419
|
+
const lower = name.toLowerCase();
|
|
420
|
+
return {
|
|
421
|
+
viewbox: "viewBox",
|
|
422
|
+
preserveaspectratio: "preserveAspectRatio",
|
|
423
|
+
"stroke-width": "strokeWidth",
|
|
424
|
+
"stroke-dasharray": "strokeDasharray",
|
|
425
|
+
"stroke-dashoffset": "strokeDashoffset",
|
|
426
|
+
"stroke-linecap": "strokeLinecap",
|
|
427
|
+
"stroke-linejoin": "strokeLinejoin",
|
|
428
|
+
"stroke-miterlimit": "strokeMiterlimit",
|
|
429
|
+
"stroke-opacity": "strokeOpacity",
|
|
430
|
+
"fill-opacity": "fillOpacity",
|
|
431
|
+
"fill-rule": "fillRule",
|
|
432
|
+
"vector-effect": "vectorEffect",
|
|
433
|
+
"text-anchor": "textAnchor",
|
|
434
|
+
"dominant-baseline": "dominantBaseline",
|
|
435
|
+
"font-size": "fontSize",
|
|
436
|
+
"font-weight": "fontWeight"
|
|
437
|
+
}[lower] ?? lower.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
438
|
+
}, valueOf = (name, value) => {
|
|
439
|
+
const decoded = decode(value);
|
|
440
|
+
if (name === "viewBox")
|
|
441
|
+
return parseViewBox(decoded) ?? decoded;
|
|
442
|
+
if (name === "strokeDasharray")
|
|
443
|
+
return decoded.split(/[\s,]+/).map(Number).filter(Number.isFinite);
|
|
444
|
+
if (/^(?:[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?)$/i.test(decoded.trim()))
|
|
445
|
+
return Number(decoded);
|
|
446
|
+
return decoded;
|
|
447
|
+
}, styleOf = (value) => {
|
|
448
|
+
const style = {}, styleRecord = style;
|
|
449
|
+
for (const declaration of decode(value).split(";")) {
|
|
450
|
+
const separator = declaration.indexOf(":");
|
|
451
|
+
if (separator < 1)
|
|
452
|
+
continue;
|
|
453
|
+
const name = camel(declaration.slice(0, separator).trim()), raw = declaration.slice(separator + 1).trim();
|
|
454
|
+
styleRecord[name] = /^-?(?:\d+\.?\d*|\.\d+)$/.test(raw) ? Number(raw) : raw;
|
|
455
|
+
}
|
|
456
|
+
return style;
|
|
457
|
+
}, attributesOf = (source) => {
|
|
458
|
+
const props = {}, style = {};
|
|
459
|
+
let classes = "";
|
|
460
|
+
const attribute = /([^\s=]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s]+)))?/g;
|
|
461
|
+
let match;
|
|
462
|
+
while (match = attribute.exec(source)) {
|
|
463
|
+
const rawName = match[1].toLowerCase(), rawValue = match[2] ?? match[3] ?? match[4] ?? "";
|
|
464
|
+
if (rawName === "class") {
|
|
465
|
+
classes = decode(rawValue);
|
|
466
|
+
continue;
|
|
467
|
+
}
|
|
468
|
+
if (rawName === "style") {
|
|
469
|
+
Object.assign(style, styleOf(rawValue));
|
|
470
|
+
continue;
|
|
471
|
+
}
|
|
472
|
+
if (rawName === "data-native" || rawName.startsWith("data-stx-"))
|
|
473
|
+
continue;
|
|
474
|
+
props[camel(rawName)] = valueOf(camel(rawName), rawValue);
|
|
475
|
+
}
|
|
476
|
+
return { props, style, classes };
|
|
477
|
+
}, endOfTag = (start) => {
|
|
478
|
+
let quote = "";
|
|
479
|
+
for (let i = start;i < markup.length; i++) {
|
|
480
|
+
const character = markup[i];
|
|
481
|
+
if (quote) {
|
|
482
|
+
if (character === quote)
|
|
483
|
+
quote = "";
|
|
484
|
+
continue;
|
|
485
|
+
}
|
|
486
|
+
if (character === '"' || character === "'") {
|
|
487
|
+
quote = character;
|
|
488
|
+
continue;
|
|
489
|
+
}
|
|
490
|
+
if (character === ">")
|
|
491
|
+
return i;
|
|
492
|
+
}
|
|
493
|
+
return markup.length - 1;
|
|
494
|
+
}, append = (node) => {
|
|
495
|
+
const parent = stack[stack.length - 1];
|
|
496
|
+
if (parent?.node && !parent.dropped)
|
|
497
|
+
parent.node.children.push(node);
|
|
498
|
+
else if (!parent)
|
|
499
|
+
roots.push(node);
|
|
500
|
+
};
|
|
501
|
+
while (cursor < markup.length) {
|
|
502
|
+
const open = markup.indexOf("<", cursor);
|
|
503
|
+
if (open === -1) {
|
|
504
|
+
const text = decode(markup.slice(cursor)).replace(/\s+/g, " ");
|
|
505
|
+
if (text.trim() && stack[stack.length - 1]?.node && !stack[stack.length - 1].dropped)
|
|
506
|
+
stack[stack.length - 1].node.children.push(text);
|
|
507
|
+
break;
|
|
508
|
+
}
|
|
509
|
+
if (open > cursor) {
|
|
510
|
+
const text = decode(markup.slice(cursor, open)).replace(/\s+/g, " ");
|
|
511
|
+
if (text.trim() && stack[stack.length - 1]?.node && !stack[stack.length - 1].dropped)
|
|
512
|
+
stack[stack.length - 1].node.children.push(text);
|
|
513
|
+
}
|
|
514
|
+
const close = endOfTag(open + 1), token = markup.slice(open + 1, close).trim();
|
|
515
|
+
cursor = close + 1;
|
|
516
|
+
if (!token || token.startsWith("!") || token.startsWith("?"))
|
|
517
|
+
continue;
|
|
518
|
+
if (token.startsWith("/")) {
|
|
519
|
+
const tag = token.slice(1).trim().toLowerCase();
|
|
520
|
+
while (stack.length)
|
|
521
|
+
if (stack.pop().tag === tag)
|
|
522
|
+
break;
|
|
523
|
+
continue;
|
|
524
|
+
}
|
|
525
|
+
const selfClosing = token.endsWith("/"), source = selfClosing ? token.slice(0, -1).trim() : token, name = source.match(/^([^\s/>]+)/)?.[1]?.toLowerCase();
|
|
526
|
+
if (!name)
|
|
527
|
+
continue;
|
|
528
|
+
const parentDropped = stack[stack.length - 1]?.dropped ?? !1, type = SVG_TYPES[name];
|
|
529
|
+
if (parentDropped || SVG_DROPPED.has(name) || !type) {
|
|
530
|
+
if (!selfClosing)
|
|
531
|
+
stack.push({ tag: name, dropped: !0 });
|
|
532
|
+
continue;
|
|
533
|
+
}
|
|
534
|
+
const parsed = attributesOf(source.slice(name.length)), node = {
|
|
535
|
+
type,
|
|
536
|
+
props: parsed.props,
|
|
537
|
+
style: parsed.style,
|
|
538
|
+
events: {},
|
|
539
|
+
children: [],
|
|
540
|
+
_inlineStyle: { ...parsed.style }
|
|
541
|
+
};
|
|
542
|
+
if (parsed.classes)
|
|
543
|
+
node._classes = parsed.classes;
|
|
544
|
+
if (type === "Svg")
|
|
545
|
+
for (const axis of ["width", "height"]) {
|
|
546
|
+
if (typeof node.props[axis] === "number" && node.style[axis] === void 0)
|
|
547
|
+
node.style[axis] = node.props[axis];
|
|
548
|
+
delete node.props[axis];
|
|
549
|
+
}
|
|
550
|
+
const geometry = svgGeometry(type, node.props);
|
|
551
|
+
if (geometry)
|
|
552
|
+
node.props.geometry = geometry;
|
|
553
|
+
append(node);
|
|
554
|
+
if (!selfClosing)
|
|
555
|
+
stack.push({ tag: name, node, dropped: !1 });
|
|
556
|
+
}
|
|
557
|
+
return roots;
|
|
558
|
+
}
|
|
@@ -12,6 +12,7 @@ export declare const ComponentRegistry: {
|
|
|
12
12
|
TouchableHighlight: 'TouchableHighlight';
|
|
13
13
|
Pressable: 'Pressable';
|
|
14
14
|
Switch: 'Switch';
|
|
15
|
+
Checkbox: 'Checkbox';
|
|
15
16
|
Slider: 'Slider';
|
|
16
17
|
Picker: 'Picker';
|
|
17
18
|
DatePicker: 'DatePicker';
|
|
@@ -143,6 +144,16 @@ export declare interface SwitchProps extends BaseProps {
|
|
|
143
144
|
thumbColor?: string
|
|
144
145
|
ios_backgroundColor?: string
|
|
145
146
|
}
|
|
147
|
+
/** A checkbox: the platform's own (UIButton with a checkmark, Android's CheckBox). */
|
|
148
|
+
export declare interface CheckboxProps extends BaseProps {
|
|
149
|
+
value?: boolean
|
|
150
|
+
checked?: boolean
|
|
151
|
+
indeterminate?: boolean
|
|
152
|
+
label?: string
|
|
153
|
+
onValueChange?: (value: boolean) => void
|
|
154
|
+
disabled?: boolean
|
|
155
|
+
color?: string
|
|
156
|
+
}
|
|
146
157
|
export declare interface SliderProps extends BaseProps {
|
|
147
158
|
value?: number
|
|
148
159
|
minimumValue?: number
|
|
@@ -25,7 +25,7 @@ function createBindingNode(id, type, bindings, connected = !0, classes = "", onC
|
|
|
25
25
|
node.className = node.className.split(/\s+/).filter((token) => token && !tokens.includes(token)).join(" ");
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
|
-
tagName: type.toUpperCase(),
|
|
28
|
+
tagName: type === "TextInput" ? "INPUT" : type === "Picker" ? "SELECT" : type.toUpperCase(),
|
|
29
29
|
attributes,
|
|
30
30
|
parentNode: null,
|
|
31
31
|
parentElement: null,
|
|
@@ -19,6 +19,7 @@ export declare interface NativeHost {
|
|
|
19
19
|
readonly isNative: true
|
|
20
20
|
setColorScheme: (scheme: 'light' | 'dark') => void
|
|
21
21
|
setText: (node: NativeNode, value: unknown) => void
|
|
22
|
+
setMarkup: (node: NativeNode, value: unknown) => void
|
|
22
23
|
setAttribute: (node: NativeNode, name: string, value: unknown) => void
|
|
23
24
|
removeAttribute: (node: NativeNode, name: string) => void
|
|
24
25
|
setStyle: (node: NativeNode, value: unknown) => void
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { compileClassStyles } from "../compiler/headwind-to-style.js";
|
|
2
2
|
import { resolveIconName } from "../compiler/icons.js";
|
|
3
|
-
import { affectsGeometry, parseViewBox, SVG_NODE_TYPES, svgGeometry } from "../compiler/svg.js";
|
|
3
|
+
import { affectsGeometry, parseSvgMarkup, parseViewBox, SVG_NODE_TYPES, svgGeometry } from "../compiler/svg.js";
|
|
4
4
|
import { nativePropName } from "../prop-names.js";
|
|
5
5
|
import { cloneNativeBindingNode } from "./binding-tree.js";
|
|
6
6
|
function eventAt(payload, node) {
|
|
@@ -13,6 +13,7 @@ function eventAt(payload, node) {
|
|
|
13
13
|
}
|
|
14
14
|
export const HOST_METHODS = [
|
|
15
15
|
"setText",
|
|
16
|
+
"setMarkup",
|
|
16
17
|
"setAttribute",
|
|
17
18
|
"removeAttribute",
|
|
18
19
|
"setStyle",
|
|
@@ -141,6 +142,24 @@ export function createNativeHost(options) {
|
|
|
141
142
|
records.set(node.__stxId, record);
|
|
142
143
|
return record;
|
|
143
144
|
}
|
|
145
|
+
function decorateControl(node, type) {
|
|
146
|
+
if (type === "TextInput" || type === "Picker") {
|
|
147
|
+
Object.defineProperty(node, "value", {
|
|
148
|
+
configurable: !0,
|
|
149
|
+
enumerable: !0,
|
|
150
|
+
get: () => descriptorOf(node)?.props.value ?? "",
|
|
151
|
+
set: (value) => {
|
|
152
|
+
const record = recordOf(node);
|
|
153
|
+
if (Object.is(record.props.value, value))
|
|
154
|
+
return;
|
|
155
|
+
record.props.value = value;
|
|
156
|
+
if (record.materialized)
|
|
157
|
+
emit({ op: "updateNode", id: node.__stxId, patch: { props: { value } } });
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
Object.defineProperty(node, "type", { configurable: !0, get: () => descriptorOf(node)?.props.type ?? "text" });
|
|
161
|
+
}
|
|
162
|
+
}
|
|
144
163
|
function materialize(node) {
|
|
145
164
|
const record = recordOf(node);
|
|
146
165
|
if (record.materialized || node.__stxAnchor !== void 0)
|
|
@@ -273,6 +292,7 @@ export function createNativeHost(options) {
|
|
|
273
292
|
if (descriptor)
|
|
274
293
|
descriptor.style = { ...record.style };
|
|
275
294
|
records.set(node.__stxId, record);
|
|
295
|
+
decorateControl(node, type);
|
|
276
296
|
decoratePosition(node);
|
|
277
297
|
node.__stxOwner = owner ?? null;
|
|
278
298
|
if (owner) {
|
|
@@ -319,6 +339,27 @@ export function createNativeHost(options) {
|
|
|
319
339
|
if (record.materialized)
|
|
320
340
|
emit({ op: "updateNode", id: node.__stxId, patch: { children: [text] } });
|
|
321
341
|
},
|
|
342
|
+
setMarkup(node, value) {
|
|
343
|
+
const record = recordOf(node), markup = value == null ? "" : String(value);
|
|
344
|
+
if (record.markup === markup)
|
|
345
|
+
return;
|
|
346
|
+
for (const child of [...record.children])
|
|
347
|
+
this.remove(child);
|
|
348
|
+
record.markup = markup;
|
|
349
|
+
for (const source of parseSvgMarkup(markup)) {
|
|
350
|
+
const materializeMarkup = (parent, descriptor) => {
|
|
351
|
+
const child = { __stxId: nextId("n") };
|
|
352
|
+
decoratePosition(child);
|
|
353
|
+
adopt(child, descriptor.type, null, descriptor);
|
|
354
|
+
records.get(child.__stxId).materialized = !1;
|
|
355
|
+
this.insert(parent, child);
|
|
356
|
+
for (const nested of descriptor.children)
|
|
357
|
+
if (typeof nested !== "string")
|
|
358
|
+
materializeMarkup(child, nested);
|
|
359
|
+
};
|
|
360
|
+
materializeMarkup(node, source);
|
|
361
|
+
}
|
|
362
|
+
},
|
|
322
363
|
setAttribute(node, name, value) {
|
|
323
364
|
if (name === "class" || name === "className") {
|
|
324
365
|
const record = recordOf(node);
|
|
@@ -366,7 +407,17 @@ export function createNativeHost(options) {
|
|
|
366
407
|
},
|
|
367
408
|
listen(node, event, handler) {
|
|
368
409
|
const id = nextId("h"), nativeEvent = NATIVE_EVENT_NAMES[event.toLowerCase()] ?? event;
|
|
369
|
-
handlers.set(id, (payload) =>
|
|
410
|
+
handlers.set(id, (payload) => {
|
|
411
|
+
if (nativeEvent === "onChangeText" || nativeEvent === "onValueChange") {
|
|
412
|
+
const data = payload && typeof payload === "object" ? payload : {}, value = data.text ?? data.value ?? data.nativeEvent?.text ?? data.nativeEvent?.value, record = recordOf(node);
|
|
413
|
+
if (value !== void 0 && !Object.is(record.props.value, value) && (record.type === "TextInput" || record.type === "Picker")) {
|
|
414
|
+
record.props.value = value;
|
|
415
|
+
if (record.materialized)
|
|
416
|
+
emit({ op: "updateNode", id: node.__stxId, patch: { props: { value } } });
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
handler(eventAt(payload, node));
|
|
420
|
+
});
|
|
370
421
|
const record = recordOf(node);
|
|
371
422
|
record.events[nativeEvent] = id;
|
|
372
423
|
if (record.materialized)
|
|
@@ -425,6 +476,7 @@ export function createNativeHost(options) {
|
|
|
425
476
|
visible: descriptor.visible,
|
|
426
477
|
materialized: !1
|
|
427
478
|
});
|
|
479
|
+
decorateControl(copy, descriptor.type);
|
|
428
480
|
setConnected(copy, !1);
|
|
429
481
|
for (const child of descriptor.children) {
|
|
430
482
|
const childCopy = this.clone(child);
|
package/dist/pwa.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import{Ln,Oe,Bo,Wa}from"./chunk-4c1afy15.js";import{Nn,Vr,Ha,Va,Ua}from"./chunk-jbvg29t0.js";import{No,Lo,jo,Fa,za}from"./chunk-e62nw7zk.js";import{oe,gt,Ur}from"./chunk-hkjqqx92.js";import{Xc,Gc,Jc,Yc,fr,mu}from"./chunk-3ynfz6h8.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-
|
|
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-49mkn02f.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">
|
package/dist/signals.js
CHANGED
|
@@ -81,6 +81,7 @@ console.log('[stx] entering IIFE');
|
|
|
81
81
|
// exactly as it was: same calls, one property lookup earlier.
|
|
82
82
|
var stxHost = window.__stx_host || {
|
|
83
83
|
setText: function(node, value) { node.textContent = value; },
|
|
84
|
+
setMarkup: function(node, value) { node.innerHTML = value == null ? '' : value; },
|
|
84
85
|
setAttribute: function(node, name, value) {
|
|
85
86
|
if (value === false) { node.removeAttribute(name); return; }
|
|
86
87
|
if (value === true) { node.setAttribute(name, ''); return; }
|
|
@@ -3416,7 +3417,9 @@ else if (name === '@html' || name === ':html' || name === 'x-html') {
|
|
|
3416
3417
|
effect(() => {
|
|
3417
3418
|
// Coerce null/undefined to '' so a missing/unresolved binding renders
|
|
3418
3419
|
// nothing rather than the literal string "undefined" (#1767).
|
|
3419
|
-
|
|
3420
|
+
var markup = evalAttrExpr(value) ?? '';
|
|
3421
|
+
if (stxHost.isNative && stxHost.setMarkup) stxHost.setMarkup(el, markup);
|
|
3422
|
+
else el.innerHTML = markup;
|
|
3420
3423
|
});
|
|
3421
3424
|
el.removeAttribute(name);
|
|
3422
3425
|
}
|
package/dist/ssg.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-2hc5mbw8.js";import"./chunk-365ktg70.js";import"./chunk-c57j92td.js";import{et,tt,nt,rt,st,ot}from"./chunk-1aw9qbdf.js";import"./chunk-yxdyh23k.js";import"./chunk-ba88n1j7.js";import{f,Be,N,K,n,o}from"./chunk-
|
|
2
|
+
import"./chunk-2hc5mbw8.js";import"./chunk-365ktg70.js";import"./chunk-c57j92td.js";import{et,tt,nt,rt,st,ot}from"./chunk-1aw9qbdf.js";import"./chunk-yxdyh23k.js";import"./chunk-ba88n1j7.js";import{f,Be,N,K,n,o}from"./chunk-4ka1vqzc.js";import"./chunk-gynes6rm.js";import{nr}from"./chunk-gbfap7rv.js";import"./chunk-6k4f583z.js";import"./chunk-c311fczy.js";import"./chunk-e6y6s7q8.js";import"./chunk-kp4mzspk.js";import"./chunk-8e062ckg.js";import{ie,mt,ht}from"./chunk-krmfkjmr.js";import{Do,Oo,Mo}from"./chunk-er7y8hk9.js";import{ft,Yt,Zt}from"./chunk-g7ey7mtw.js";import"./chunk-fxxrrq9n.js";import{a}from"./chunk-dne8n6h3.js";import x from"fs";import g from"path";import{createHash as Dt}from"crypto";function Rt(t){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(t).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return t}}var kt=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;function Ct(t){return Bun.hash(t).toString(16)}function ut(t,i={}){if(!t.includes('type="stx/island"'))return{html:t,chunks:[]};let s=new Map,r=t.replace(kt,(e,l,w,y)=>{let h=y.trim();if(!h)return e;if(/\bdata-stx-src=/.test(w))return e;if(i.minify)h=Rt(h);let S=Ct(h);if(!s.has(S))s.set(S,h);let P=i.integrity?` data-stx-integrity="sha384-${Dt("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 Et=new Set(["visible","idle"]);function dt(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(Et.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 It=["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 Bt(t){for(let i of It){let s=t[i];if(!s)continue;let r=q(s);if(r)return{url:r,source:"env",via:i}}return null}function gt(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 jt(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=gt(e.default??e);if(l)return l}catch{}}return null}async function pt(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=gt(t.stxConfig);if(r)return{url:r,source:"stx.config",via:"site.url"};let c=await jt(i);if(c)return{url:c,source:"site.config",via:"url"};let e=Bt(s);if(e)return e;return{url:"http://localhost",source:"fallback"}}function wt(){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
3
|
`)}class yt{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 St{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 Ft(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]}
|
|
@@ -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();ht();let s=await o(process.cwd()),r=s.build||{},c=await pt({explicit:t.domain||r.domain,stxConfig:s});if(c.source==="fallback"&&(t.sitemap??r.sitemap??!0))console.warn(wt());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-
|
|
44
|
+
</rss>`}async function zt(t={}){let i=Date.now();ht();let s=await o(process.cwd()),r=s.build||{},c=await pt({explicit:t.domain||r.domain,stxConfig:s});if(c.source==="fallback"&&(t.sitemap??r.sitemap??!0))console.warn(wt());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-5pwdgk0p.js");try{D=m(await u(process.cwd()))}catch{}}let{prepareImageDelivery:p}=await import("./chunk-0sc4hfpz.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 yt(e.cacheDir,D);if(e.cache)await B.load();try{let{generateCss:u}=await import("./chunk-5pwdgk0p.js");await u('<div class="bg-black"></div>')}catch{}et();let vt=s?.routeMiddleware?.dir||"middleware";await nt(process.cwd(),vt);let H=tt();if(H.length>0)console.log(`Loaded ${H.length} middleware: ${H.join(", ")}`);let bt=s?.routeMiddleware?.global||[];Mo(s?.layoutsDir,a(process.cwd()));let V=N(".",{pagesDir:e.pagesDir,pagesDirs:s?._layerPageDirs});console.log(`Found ${V.length} routes`);let _=[];for(let u of V){let m=await Ot(u);for(let v of m)_.push({route:u,url:v.url,params:v.params,props:v.props,revalidate:v.revalidate??e.revalidate})}l.totalPages=_.length,console.log(`Generating ${l.totalPages} pages...`);let A=[],X=[];for(let u=0;u<_.length;u+=e.concurrency)X.push(_.slice(u,u+e.concurrency));for(let u of X)await Promise.all(u.map(async(m)=>{let{route:v,url:d,params:L,props:Pt,revalidate:Q}=m;try{await e.hooks.onPageStart?.(d);let j=await Bun.file(v.filePath).text(),F=Jt(j),$t=F?.middleware?Array.isArray(F.middleware)?F.middleware:[F.middleware]:[],it=[...bt,...$t];if(it.length>0){let C=rt(d,L,F||{}),O=st(C,null,void 0,{isServer:!0}),E=await ot(it,O);if(E.redirect){let R=typeof E.redirect==="string"?E.redirect:E.redirect.path||E.redirect,U=Vt(String(R),d),T=Kt(d,e);await x.promises.mkdir(g.dirname(T),{recursive:!0}),await Bun.write(T,U),l.successCount++,l.pages.push({route:d,outputPath:T,size:Buffer.byteLength(U),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 at=j.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(at)try{if(!await Function("route",`
|
|
45
45
|
const validate = ${at[1]};
|
|
46
46
|
return validate(route);
|
|
47
47
|
`)({params:L})){console.warn(`Validation failed for ${d}, skipping...`);return}}catch{}let k=null,ct=!1;if(e.cache){if(k=B.get(d,v.filePath),k)ct=!0,l.cachedCount++}if(!k){let C=await xt(v,L,Pt,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:
|
package/dist/stx.d.ts
CHANGED
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
* packages/stx/src/signals.ts → window.stx = { ... }
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
+
/// <reference path="./browser-auto-imports.d.ts" />
|
|
21
|
+
|
|
20
22
|
// ============================================================================
|
|
21
23
|
// Module declarations
|
|
22
24
|
// ============================================================================
|
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.519",
|
|
5
5
|
"description": "A performant UI Framework. Powered by Bun.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -89,6 +89,7 @@
|
|
|
89
89
|
"README.md",
|
|
90
90
|
"dist",
|
|
91
91
|
"stx.d.ts",
|
|
92
|
+
"browser-auto-imports.d.ts",
|
|
92
93
|
"stx-module.d.ts"
|
|
93
94
|
],
|
|
94
95
|
"scripts": {
|
|
@@ -122,12 +123,12 @@
|
|
|
122
123
|
"dependencies": {
|
|
123
124
|
"@stacksjs/ts-css": "^0.3.11",
|
|
124
125
|
"@stacksjs/clapp": "^0.2.16",
|
|
125
|
-
"@stacksjs/desktop": "0.2.
|
|
126
|
-
"@stacksjs/sanitizer": "0.2.
|
|
126
|
+
"@stacksjs/desktop": "0.2.519",
|
|
127
|
+
"@stacksjs/sanitizer": "0.2.519",
|
|
127
128
|
"@stacksjs/ts-i18n": "^0.1.11",
|
|
128
|
-
"bun-plugin-stx": "0.2.
|
|
129
|
+
"bun-plugin-stx": "0.2.519",
|
|
129
130
|
"bunfig": "^0.15.19",
|
|
130
|
-
"stx-router": "0.2.
|
|
131
|
+
"stx-router": "0.2.519",
|
|
131
132
|
"ts-broadcasting": "^0.0.11",
|
|
132
133
|
"ts-images": "^0.2.22",
|
|
133
134
|
"ts-syntax-highlighter": "^0.2.1"
|
package/stx.d.ts
CHANGED
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
* packages/stx/src/signals.ts → window.stx = { ... }
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
+
/// <reference path="./browser-auto-imports.d.ts" />
|
|
21
|
+
|
|
20
22
|
// ============================================================================
|
|
21
23
|
// Module declarations
|
|
22
24
|
// ============================================================================
|
package/dist/chunk-1jwjtcvd.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Ui,Wi}from"./chunk-zffc870e.js";import"./chunk-jz87m1j8.js";import"./chunk-aad7fmvp.js";import"./chunk-gte0wmh8.js";import"./chunk-2j04bc8c.js";import"./chunk-38jkc8p6.js";import"./chunk-01rz8h7x.js";import"./chunk-d2w32ck9.js";import{io}from"./chunk-f1cm6kh5.js";import"./chunk-4hz4g5ym.js";import"./chunk-jcmgj8kk.js";import"./chunk-g2990jbf.js";import"./chunk-8fb1mqw1.js";import"./chunk-n34kagea.js";import"./chunk-833fqs6p.js";import"./chunk-3y8ykqpx.js";import"./chunk-zv0vgamy.js";import"./chunk-fesb4h31.js";import"./chunk-vp827ah7.js";import"./chunk-ygetbydb.js";import"./chunk-8xpyzcq2.js";import"./chunk-67actssw.js";import"./chunk-pmctmsqq.js";import"./chunk-h6q8jafh.js";import"./chunk-3s9s1mdt.js";import"./chunk-s9mq9x2k.js";import"./chunk-1c407nky.js";import"./chunk-xx2pk2ay.js";import"./chunk-5e6bhs6v.js";import"./chunk-add8tq7t.js";import"./chunk-s78m3jpp.js";import"./chunk-b3mfy2eb.js";import"./chunk-er7y8hk9.js";import"./chunk-0x2qent6.js";import"./chunk-ts8an4wm.js";import"./chunk-2hc5mbw8.js";import{he,nn,rn,K,u,n,Jn,R,o,le}from"./chunk-9afwh767.js";import"./chunk-fxxrrq9n.js";import"./chunk-c57j92td.js";import"./chunk-kp4mzspk.js";import"./chunk-t768bb57.js";import"./chunk-6k4f583z.js";import"./chunk-gbfap7rv.js";import"./chunk-gynes6rm.js";import"./chunk-365ktg70.js";import"./chunk-ba88n1j7.js";import"./chunk-yxdyh23k.js";import"./chunk-1aw9qbdf.js";import"./chunk-e6y6s7q8.js";export{Jn as buildWebComponents,rn as cacheTemplate,nn as checkCache,io as classifyAllScripts,Ui as createMiddleware,Wi as createRoute,R as defaultConfig,u as extractVariables,K as injectRouterScript,o as loadStxConfig,he as processClientScript,n as processDirectives,le as readMarkdownFile};
|