@stacksjs/stx 0.2.607 → 0.2.611
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-02dcqhzy.js +2 -0
- package/dist/{chunk-vw62fjpv.js → chunk-0ff64x1p.js} +3 -3
- package/dist/chunk-0fgp13q4.js +2 -0
- package/dist/chunk-0gpjks6k.js +2 -0
- package/dist/chunk-1239cnda.js +2 -0
- package/dist/chunk-1qx531pp.js +2 -0
- package/dist/chunk-24tx4ysv.js +2 -0
- package/dist/{chunk-zs3ezqy3.js → chunk-2h8xmmtk.js} +1 -1
- package/dist/{chunk-6xsm53pz.js → chunk-2pgvbe5x.js} +4 -4
- package/dist/chunk-2pkx524z.js +2 -0
- package/dist/{chunk-0v89nfz1.js → chunk-2y0qy214.js} +2 -2
- package/dist/chunk-2y80c34h.js +2 -0
- package/dist/{chunk-tbsjg23k.js → chunk-2z56183d.js} +4 -4
- package/dist/{chunk-vntpfbwy.js → chunk-34x22hbs.js} +1 -1
- package/dist/{chunk-qh07a85k.js → chunk-39fqkzyb.js} +3 -3
- package/dist/{chunk-81qmj3sd.js → chunk-3d658f6n.js} +7 -7
- package/dist/{chunk-cp901m61.js → chunk-3v862v2c.js} +1 -1
- package/dist/{chunk-5s47qfp6.js → chunk-3wmt7ykt.js} +2 -2
- package/dist/chunk-4j3fmxeg.js +2 -0
- package/dist/{chunk-y54fz9rk.js → chunk-4rtxkqwh.js} +2 -2
- package/dist/chunk-5f330rrj.js +2 -0
- package/dist/{chunk-s4pjf2pc.js → chunk-5rtatjwq.js} +2 -2
- package/dist/{chunk-wzjf33es.js → chunk-5vnx8dmz.js} +2 -2
- package/dist/chunk-5ys7azpj.js +2 -0
- package/dist/chunk-64vnwrkw.js +2 -0
- package/dist/chunk-65jsp5fd.js +3 -0
- package/dist/{chunk-bsy8v1xj.js → chunk-66e4ga0z.js} +3 -3
- package/dist/{chunk-4tj0ap61.js → chunk-6yrjyrc2.js} +5 -5
- package/dist/{chunk-td5100fz.js → chunk-70n1t4ht.js} +7 -7
- package/dist/chunk-7446n6a3.js +2 -0
- package/dist/{chunk-y8h823cb.js → chunk-74j18qk0.js} +28 -28
- package/dist/chunk-76ebcf61.js +2 -0
- package/dist/chunk-7aa4qncj.js +2 -0
- package/dist/chunk-7awf2gqs.js +2 -0
- package/dist/{chunk-dxqwm8tr.js → chunk-7g47wdd9.js} +3 -3
- package/dist/{chunk-m9h7pmkh.js → chunk-8211vr9v.js} +5 -5
- package/dist/chunk-84f8tft8.js +2 -0
- package/dist/{chunk-yzj55rfs.js → chunk-8f616tym.js} +3 -3
- package/dist/chunk-8t8wf1w2.js +2 -0
- package/dist/chunk-961nvcxw.js +43 -0
- package/dist/{chunk-xjxc4q3w.js → chunk-999d4sns.js} +21 -21
- package/dist/{chunk-r4h8fg1x.js → chunk-9dx519z6.js} +1 -1
- package/dist/{chunk-dnqq1ze0.js → chunk-9kzdk4na.js} +3 -3
- package/dist/chunk-9mmy9m0y.js +2 -0
- package/dist/{chunk-bhf9yt2w.js → chunk-9n7ehv7w.js} +2 -2
- package/dist/{chunk-dmdhbwmn.js → chunk-9nh7vxk1.js} +3 -3
- package/dist/chunk-9vxdjpn5.js +2 -0
- package/dist/chunk-aw79nm5c.js +127 -0
- package/dist/chunk-brbybne9.js +2 -0
- package/dist/chunk-cg8hg6cs.js +3 -0
- package/dist/{chunk-azpkje69.js → chunk-cjrfazzb.js} +34 -10
- package/dist/chunk-cjvq46n8.js +3 -0
- package/dist/chunk-cwvazqab.js +2 -0
- package/dist/{chunk-67tpacz0.js → chunk-cwxkgbck.js} +1 -1
- package/dist/chunk-d17mhbz9.js +2850 -0
- package/dist/{chunk-vp3fzjsc.js → chunk-det49x62.js} +2 -2
- package/dist/{chunk-tydv84gj.js → chunk-dtt7k0bz.js} +2 -2
- package/dist/{chunk-ev6w9c69.js → chunk-e98jqwnf.js} +1 -1
- package/dist/{chunk-8fq6bvnw.js → chunk-eg5yfnrn.js} +33 -33
- package/dist/chunk-ekfmad19.js +2 -0
- package/dist/{chunk-ghdyqt98.js → chunk-ewsd3apq.js} +2 -2
- package/dist/chunk-exwjabr5.js +2 -0
- package/dist/chunk-f19bzr36.js +2 -0
- package/dist/{chunk-5e182xqt.js → chunk-f8tts10s.js} +1 -1
- package/dist/chunk-fa0aa98d.js +2 -0
- package/dist/chunk-fgrjv29d.js +18 -0
- package/dist/chunk-fjx1sbg2.js +2 -0
- package/dist/{chunk-sswjv8p9.js → chunk-g22q68ds.js} +2 -2
- package/dist/chunk-g24kapd5.js +2 -0
- package/dist/{chunk-g04y5wyn.js → chunk-gbk2dbt1.js} +4 -4
- package/dist/{chunk-rmv35cx0.js → chunk-gk4c8d1c.js} +2 -2
- package/dist/{chunk-aestp72s.js → chunk-gn75qghq.js} +1 -1
- package/dist/chunk-gvv4d0tp.js +2 -0
- package/dist/chunk-h3fr7c5y.js +2 -0
- package/dist/{chunk-g63ye3fe.js → chunk-h3tzc41t.js} +2 -2
- package/dist/{chunk-vehtypx0.js → chunk-h7y89m22.js} +2 -2
- package/dist/{chunk-1jxdkp8x.js → chunk-hj49vk9e.js} +6 -6
- package/dist/chunk-hjp38m0w.js +3 -0
- package/dist/chunk-hwt7pyqt.js +2 -0
- package/dist/{chunk-x8q5przn.js → chunk-hxzy2t7r.js} +11 -11
- package/dist/{chunk-tcd2zez3.js → chunk-j18z5nxq.js} +2 -2
- package/dist/chunk-jp1xjh1f.js +2 -0
- package/dist/chunk-jrccxnbt.js +2 -0
- package/dist/chunk-jv3rdes9.js +2 -0
- package/dist/chunk-k36ve5ct.js +2 -0
- package/dist/chunk-k5vytrbx.js +2 -0
- package/dist/chunk-k7vg01vv.js +2 -0
- package/dist/chunk-kayh4pcw.js +2 -0
- package/dist/chunk-myg6gz76.js +2 -0
- package/dist/{chunk-jpxekhdh.js → chunk-n05hxy7w.js} +3 -3
- package/dist/{chunk-t9t66sz4.js → chunk-n1qr6n92.js} +6 -6
- package/dist/{chunk-77kpsnf6.js → chunk-n4f3fzp5.js} +85 -85
- package/dist/chunk-n6tspwf9.js +2 -0
- package/dist/{chunk-z2xrwmjr.js → chunk-nd8yx3qq.js} +10 -10
- package/dist/chunk-nfdma5hp.js +2 -0
- package/dist/chunk-ng819bkf.js +2 -0
- package/dist/{chunk-kxjd6e2h.js → chunk-pc15w7bb.js} +2 -2
- package/dist/{chunk-z8fhtym2.js → chunk-pkgmyg4r.js} +2 -2
- package/dist/{chunk-53y4z4p2.js → chunk-pm1gnjs5.js} +3 -3
- package/dist/{chunk-6by8dtan.js → chunk-pmpqzqq8.js} +2 -2
- package/dist/chunk-pnyxqze0.js +2 -0
- package/dist/{chunk-cfpenvc7.js → chunk-pyqrj2wk.js} +3 -3
- package/dist/chunk-qa5c5x2n.js +2 -0
- package/dist/chunk-qqenm7pg.js +40 -0
- package/dist/{chunk-5j29466h.js → chunk-r4xnqag4.js} +2 -2
- package/dist/chunk-r8a96bbd.js +2 -0
- package/dist/{chunk-1dd4qefr.js → chunk-s5s1w8na.js} +2 -2
- package/dist/chunk-sakagfdq.js +2 -0
- package/dist/chunk-sj0bkdy8.js +2 -0
- package/dist/chunk-spkwmfbm.js +2 -0
- package/dist/chunk-swv69q75.js +4 -0
- package/dist/{chunk-ktvr45qg.js → chunk-t61vdbje.js} +6 -6
- package/dist/{chunk-tfjcs55e.js → chunk-tk50q4zs.js} +12 -12
- package/dist/chunk-v6xk1q66.js +2 -0
- package/dist/{chunk-60wedefh.js → chunk-vep8d57h.js} +1 -1
- package/dist/chunk-vfk3vn6j.js +2 -0
- package/dist/{chunk-bspryr4a.js → chunk-vyjwag3f.js} +9 -9
- package/dist/{chunk-w8g2ppnr.js → chunk-w0h27sf8.js} +2 -2
- package/dist/chunk-w1szscbz.js +2 -0
- package/dist/{chunk-20k77e2a.js → chunk-wa26bn4s.js} +4 -4
- package/dist/chunk-wb9rbwb1.js +2 -0
- package/dist/{chunk-td30jg06.js → chunk-wdy6y0fq.js} +2 -2
- package/dist/chunk-wkx2m2br.js +2 -0
- package/dist/{chunk-mvwcf4xy.js → chunk-wyndxr8w.js} +4 -4
- package/dist/chunk-x73w6v8m.js +2 -0
- package/dist/{chunk-79edpvb2.js → chunk-x8y7yqwh.js} +7 -7
- package/dist/{chunk-7095f0hb.js → chunk-xap2cbkd.js} +9 -9
- package/dist/{chunk-wqmm1qsz.js → chunk-xh98677z.js} +5 -5
- package/dist/chunk-yagzr2ry.js +2 -0
- package/dist/chunk-yda8t21j.js +2 -0
- package/dist/{chunk-efy3038a.js → chunk-ydz9j0d3.js} +2 -2
- package/dist/chunk-yydx0sfy.js +2 -0
- package/dist/{chunk-r69jfs59.js → chunk-z79gnz6z.js} +1 -1
- package/dist/{chunk-c65q0svd.js → chunk-z7ezxqmg.js} +5 -5
- package/dist/{chunk-k3f4044e.js → chunk-zatgmkx7.js} +2 -2
- package/dist/chunk-zg0z8qt6.js +2 -0
- package/dist/{chunk-0cb00ys2.js → chunk-znwnacwz.js} +5 -5
- package/dist/cli.js +46 -46
- package/dist/craft-entry.js +2 -2
- package/dist/craft.js +2 -2
- package/dist/expressions.d.ts +0 -23
- package/dist/expressions.js +14 -11
- package/dist/includes.js +6 -0
- package/dist/native/compiler/component-mapping.js +1 -0
- package/dist/native/compiler/headwind-to-style.js +17 -0
- package/dist/native/compiler/html-to-ir.js +1 -0
- package/dist/native/compiler/inline-style.js +2 -0
- package/dist/native/compiler/ir.d.ts +2 -0
- package/dist/native/components/primitives.d.ts +33 -9
- package/dist/native/components/primitives.js +1 -0
- package/dist/native/primitives/MapPolygon.stx +2 -0
- package/dist/native/prop-names.js +1 -3
- package/dist/native/runtime/craft-bridge.js +22 -1
- package/dist/native/runtime/craft.d.ts +10 -0
- package/dist/process.js +3 -2
- package/dist/pwa.js +3 -3
- package/dist/script-validation.js +4 -4
- package/dist/serve.js +5 -1
- package/dist/ssg.js +13 -13
- package/dist/utils.js +15 -2
- package/package.json +5 -5
- package/dist/chunk-06wv8qwy.js +0 -40
- package/dist/chunk-0d6b3eeb.js +0 -2
- package/dist/chunk-0mgth7cm.js +0 -2
- package/dist/chunk-1fdrhfc0.js +0 -2
- package/dist/chunk-2n59ahd9.js +0 -2
- package/dist/chunk-2pwjnydp.js +0 -2
- package/dist/chunk-2r4an7bh.js +0 -2
- package/dist/chunk-304vaxnk.js +0 -2
- package/dist/chunk-32hr3qq7.js +0 -2
- package/dist/chunk-36n8yz6t.js +0 -2
- package/dist/chunk-39pgf5z3.js +0 -2
- package/dist/chunk-3xwzd9wp.js +0 -2845
- package/dist/chunk-3yttgk0s.js +0 -2
- package/dist/chunk-4ck2xc8m.js +0 -2
- package/dist/chunk-4jasfhh6.js +0 -2
- package/dist/chunk-4szajb1z.js +0 -2
- package/dist/chunk-61ztfana.js +0 -127
- package/dist/chunk-7f63z4xx.js +0 -2
- package/dist/chunk-7renf4zp.js +0 -2
- package/dist/chunk-8bzx0r0x.js +0 -2
- package/dist/chunk-974dxazw.js +0 -2
- package/dist/chunk-9fpnnfr3.js +0 -2
- package/dist/chunk-9sgt7v77.js +0 -2
- package/dist/chunk-9zzhpp2a.js +0 -2
- package/dist/chunk-aan7601v.js +0 -2
- package/dist/chunk-b4tbqz8r.js +0 -2
- package/dist/chunk-bakxqwnz.js +0 -2
- package/dist/chunk-be2kmw0p.js +0 -2
- package/dist/chunk-bnpb6ez9.js +0 -2
- package/dist/chunk-c48mh4d6.js +0 -18
- package/dist/chunk-dzbkgsv8.js +0 -4
- package/dist/chunk-ewkza45r.js +0 -2
- package/dist/chunk-exd1h9sd.js +0 -2
- package/dist/chunk-fcgf8d5k.js +0 -2
- package/dist/chunk-gw2dvp35.js +0 -2
- package/dist/chunk-h9drxwva.js +0 -2
- package/dist/chunk-hrr7k1qc.js +0 -2
- package/dist/chunk-j04brkj0.js +0 -2
- package/dist/chunk-jbvwg4gs.js +0 -2
- package/dist/chunk-jshj69dy.js +0 -2
- package/dist/chunk-k4wkfhvz.js +0 -2
- package/dist/chunk-km9a5gp4.js +0 -2
- package/dist/chunk-m95zjk91.js +0 -3
- package/dist/chunk-mgj0ngyq.js +0 -2
- package/dist/chunk-n35yc890.js +0 -3
- package/dist/chunk-n39ezmxz.js +0 -2
- package/dist/chunk-n8eavnxf.js +0 -2
- package/dist/chunk-p8sv5fqs.js +0 -2
- package/dist/chunk-pghtgep5.js +0 -2
- package/dist/chunk-pt7e0be5.js +0 -2
- package/dist/chunk-q40ahbjs.js +0 -2
- package/dist/chunk-qjxxhdv7.js +0 -2
- package/dist/chunk-rp93n4z7.js +0 -3
- package/dist/chunk-rrw2jg26.js +0 -2
- package/dist/chunk-rxja040z.js +0 -2
- package/dist/chunk-sx0qbekt.js +0 -2
- package/dist/chunk-t83acmv2.js +0 -2
- package/dist/chunk-tc176d93.js +0 -2
- package/dist/chunk-wjhhb6dn.js +0 -2
- package/dist/chunk-wm8w2721.js +0 -2
- package/dist/chunk-wtax276j.js +0 -2
- package/dist/chunk-wy53pys4.js +0 -43
- package/dist/chunk-x49qdt4c.js +0 -2
- package/dist/chunk-y0zyzbjf.js +0 -2
- package/dist/chunk-yn2d8x8m.js +0 -3
- package/dist/chunk-z8mdsjzw.js +0 -2
- package/dist/chunk-zg87pybq.js +0 -2
- package/dist/chunk-zq345s76.js +0 -2
package/dist/expressions.d.ts
CHANGED
|
@@ -101,29 +101,6 @@ export declare function escapeHtml(unsafe: string): string;
|
|
|
101
101
|
* decodes references before anything reads them.
|
|
102
102
|
*/
|
|
103
103
|
export declare function escapeHtmlValue(unsafe: string): string;
|
|
104
|
-
/**
|
|
105
|
-
* A zero-width, non-breaking character, written as a reference.
|
|
106
|
-
*
|
|
107
|
-
* The character references alone stop the *server* reading a value as a
|
|
108
|
-
* template, and they are not enough: the browser decodes them, so the DOM text
|
|
109
|
-
* says `{{ 6*7 }}` again and the client runtime - which binds by scanning text
|
|
110
|
-
* for mustaches - evaluates it in the visitor's browser. Server-side injection
|
|
111
|
-
* becomes cross-site scripting, from the same stored value.
|
|
112
|
-
*
|
|
113
|
-
* A word joiner between the braces breaks the pattern for both sides while
|
|
114
|
-
* changing nothing a reader sees: it has no width, no line-breaking behaviour,
|
|
115
|
-
* and copies as an invisible character. The alternative is teaching the runtime
|
|
116
|
-
* to bind only what the compiler recorded, which is the better shape and a much
|
|
117
|
-
* larger change than a security fix should carry.
|
|
118
|
-
*/
|
|
119
|
-
/**
|
|
120
|
-
* Check if a template uses signals (state, derived, effect) in its script blocks
|
|
121
|
-
* or has reactive attributes (@if, @for) with function call expressions
|
|
122
|
-
*
|
|
123
|
-
* `filePath` lets a script that factors its signals into an imported module be
|
|
124
|
-
* recognised too. Without it the scan is text-only, which is what every caller
|
|
125
|
-
* did before and is still correct for a script that declares its own signals.
|
|
126
|
-
*/
|
|
127
104
|
export declare function usesSignalsInScript(template: string, filePath?: string): boolean;
|
|
128
105
|
/**
|
|
129
106
|
* Where each client-side loop in `html` is, and the names it binds.
|
package/dist/expressions.js
CHANGED
|
@@ -2,7 +2,7 @@ import fs from "node:fs";
|
|
|
2
2
|
import { isDevelopment } from "./env.js";
|
|
3
3
|
import { stripCommentsAndLiterals } from "./strip-literals.js";
|
|
4
4
|
import { createSafeFunction, getExpressionSafetyRule, safeEvaluate } from "./safe-evaluator.js";
|
|
5
|
-
import { createDetailedErrorMessage } from "./utils.js";
|
|
5
|
+
import { componentClientSignalNames, createDetailedErrorMessage } from "./utils.js";
|
|
6
6
|
import { createPlaceholder } from "./placeholder.js";
|
|
7
7
|
import { neutralizeTemplateSyntax } from "./template-syntax-escape.js";
|
|
8
8
|
import { classifyHtmlInterpolation, UnsafeInterpolationContextError } from "./interpolation-context.js";
|
|
@@ -347,13 +347,15 @@ function escapeInterpolatedHtmlValue(source, offset, raw, attributeFragment = !1
|
|
|
347
347
|
return UNSAFE_URL_PREFIX + escaped;
|
|
348
348
|
return sanitizeSubstitutedUrl(schemeWindow(source, offset), raw, escaped);
|
|
349
349
|
}
|
|
350
|
+
function clientScriptBodies(scripts) {
|
|
351
|
+
return scripts.flatMap((script) => {
|
|
352
|
+
const match = script.match(/^<script\b([^>]*)>([\s\S]*?)<\/script\s*>$/i);
|
|
353
|
+
return !match || /\bserver\b|\bsrc\s*=/.test(match[1]) ? [] : [match[2]];
|
|
354
|
+
});
|
|
355
|
+
}
|
|
350
356
|
export function usesSignalsInScript(template, filePath) {
|
|
351
357
|
const { scripts } = stashScriptElements(template);
|
|
352
|
-
for (const
|
|
353
|
-
const match = script.match(/^<script\b([^>]*)>([\s\S]*?)<\/script\s*>$/i);
|
|
354
|
-
if (!match || /\bserver\b|\bsrc\s*=/.test(match[1]))
|
|
355
|
-
continue;
|
|
356
|
-
const content = match[2];
|
|
358
|
+
for (const content of clientScriptBodies(scripts)) {
|
|
357
359
|
if (/\b(state|derived|effect|ref|reactive|computed|watch|watchEffect|useModel)\s*(?:<[^>]*>)?\s*\(/.test(content))
|
|
358
360
|
return !0;
|
|
359
361
|
if (importsSignalDeclarations(content, filePath))
|
|
@@ -565,7 +567,10 @@ export function processExpressions(template, context, filePath) {
|
|
|
565
567
|
output = maskInto(output, styleMatcher, styleBlocks, (n) => `<!--__STX_STYLE_${n}__-->`);
|
|
566
568
|
const scriptBlocks = [];
|
|
567
569
|
output = maskInto(output, matchScriptElement, scriptBlocks, (n) => `<!--__STX_SCRIPT_EXPR_${n}__-->`);
|
|
568
|
-
const hasSignals = context?.__stx_signals_gate === !0 || usesSignalsInScript(template), clientSignalNames = new Set(
|
|
570
|
+
const hasSignals = context?.__stx_signals_gate === !0 || usesSignalsInScript(template), clientSignalNames = new Set([
|
|
571
|
+
...Array.isArray(context?.__stx_client_signal_names) ? context.__stx_client_signal_names : [],
|
|
572
|
+
...componentClientSignalNames(clientScriptBodies(scriptBlocks))
|
|
573
|
+
]), preservedClientExpressions = new Set(Array.isArray(context?.__stx_preserved_client_expressions) ? context.__stx_preserved_client_expressions : []);
|
|
569
574
|
output = replaceInterpolations(output, (match, expr, offset) => {
|
|
570
575
|
try {
|
|
571
576
|
const value = evaluateExpression(expr, context, !1, (r) => warnRejectedExpression(r, match, filePath, template));
|
|
@@ -607,13 +612,13 @@ export function processExpressions(template, context, filePath) {
|
|
|
607
612
|
const jsBuiltins = ["parseInt", "parseFloat", "String", "Number", "Boolean", "Array", "Object", "JSON", "Math", "Date", "encodeURIComponent", "decodeURIComponent", "encodeURI", "decodeURI", "true", "false", "null", "undefined"], identifierPattern = /^([a-zA-Z_$][a-zA-Z0-9_$]*)/, firstVarName = trimmedExpr.match(identifierPattern)?.[1], firstVarInContext = firstVarName && ((firstVarName in context) || jsBuiltins.includes(firstVarName)), firstVarIsClientSignal = Boolean(firstVarName && clientSignalNames.has(firstVarName)), directFunctionCall = /^([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/, directFuncMatch = trimmedExpr.match(directFunctionCall), isLikelySignal = directFuncMatch && !jsBuiltins.includes(directFuncMatch[1]) && !(directFuncMatch[1] in context);
|
|
608
613
|
if (/^__[A-Z_]+__$/.test(trimmedExpr))
|
|
609
614
|
return "";
|
|
615
|
+
if (firstVarIsClientSignal)
|
|
616
|
+
return match;
|
|
610
617
|
let rejection;
|
|
611
618
|
try {
|
|
612
619
|
const value = evaluateExpression(expr, context, !1, (r) => {
|
|
613
620
|
rejection = r;
|
|
614
621
|
});
|
|
615
|
-
if (firstVarIsClientSignal)
|
|
616
|
-
return match;
|
|
617
622
|
if (hasSignals && !expressionUsesOnlyContextVars(trimmedExpr, context))
|
|
618
623
|
return match;
|
|
619
624
|
if (rejection)
|
|
@@ -627,8 +632,6 @@ export function processExpressions(template, context, filePath) {
|
|
|
627
632
|
} catch (error) {
|
|
628
633
|
if (error instanceof UnsafeInterpolationContextError)
|
|
629
634
|
throw error;
|
|
630
|
-
if (firstVarIsClientSignal)
|
|
631
|
-
return match;
|
|
632
635
|
if (hasSignals && !expressionUsesOnlyContextVars(trimmedExpr, context))
|
|
633
636
|
return match;
|
|
634
637
|
if (isLikelySignal)
|
package/dist/includes.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { StxValidationError } from "./errors/types.js";
|
|
2
|
+
import { validateClientScript } from "./script-validation.js";
|
|
1
3
|
import { findSfcTemplateBlock } from "./sfc-template.js";
|
|
2
4
|
import path from "node:path";
|
|
3
5
|
import { existsSync } from "node:fs";
|
|
@@ -663,6 +665,8 @@ export async function processIncludes(template, context, filePath, options, depe
|
|
|
663
665
|
if (isDataBlockScript(scriptAttrs))
|
|
664
666
|
continue;
|
|
665
667
|
const isServerScript = scriptAttrs.includes("server"), shouldTranspile = shouldTranspileTypeScript(scriptAttrs);
|
|
668
|
+
if (!isServerScript && !/\bsrc\s*=/i.test(scriptAttrs))
|
|
669
|
+
validateClientScript(scriptContent, includeFilePath, options.strict);
|
|
666
670
|
if (!isServerScript && scriptContent.trim()) {
|
|
667
671
|
const { interpolateScriptExpressions } = await import("./expressions.js");
|
|
668
672
|
scriptContent = interpolateScriptExpressions(scriptContent, includeContext, includePath);
|
|
@@ -777,6 +781,8 @@ ${scriptContent}`;
|
|
|
777
781
|
` + preservedScript;
|
|
778
782
|
return processedContent;
|
|
779
783
|
} catch (error) {
|
|
784
|
+
if (error instanceof StxValidationError)
|
|
785
|
+
throw error;
|
|
780
786
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
781
787
|
return includeFailure(includePath, `Error processing include ${includePath}: ${errorMessage}`, templateStr, offsetPos);
|
|
782
788
|
}
|
|
@@ -503,6 +503,18 @@ const classParsers = {
|
|
|
503
503
|
style.flexShrink = 0;
|
|
504
504
|
return !0;
|
|
505
505
|
},
|
|
506
|
+
"order-first": (_, style) => {
|
|
507
|
+
style.order = -9999;
|
|
508
|
+
return !0;
|
|
509
|
+
},
|
|
510
|
+
"order-last": (_, style) => {
|
|
511
|
+
style.order = 9999;
|
|
512
|
+
return !0;
|
|
513
|
+
},
|
|
514
|
+
"order-none": (_, style) => {
|
|
515
|
+
style.order = 0;
|
|
516
|
+
return !0;
|
|
517
|
+
},
|
|
506
518
|
"justify-start": (_, style) => {
|
|
507
519
|
style.justifyContent = "flex-start";
|
|
508
520
|
return !0;
|
|
@@ -1303,6 +1315,11 @@ export function compileHeadwindToStyle(classes, unknown) {
|
|
|
1303
1315
|
continue;
|
|
1304
1316
|
if (parseGridColumns(className, style))
|
|
1305
1317
|
continue;
|
|
1318
|
+
const order = /^order-\[(-?\d+)\]$/.exec(className) ?? /^order-(-?\d+)$/.exec(className);
|
|
1319
|
+
if (order) {
|
|
1320
|
+
style.order = Number(order[1]);
|
|
1321
|
+
continue;
|
|
1322
|
+
}
|
|
1306
1323
|
if (parsePosition(className, style))
|
|
1307
1324
|
continue;
|
|
1308
1325
|
if (parseTranslation(className, style))
|
|
@@ -16,6 +16,7 @@ const STYLE_KEYS = new Set([
|
|
|
16
16
|
"flexBasis",
|
|
17
17
|
"flexDirection",
|
|
18
18
|
"flexWrap",
|
|
19
|
+
"order",
|
|
19
20
|
"justifyContent",
|
|
20
21
|
"alignItems",
|
|
21
22
|
"alignSelf",
|
|
@@ -102,6 +103,7 @@ const STYLE_KEYS = new Set([
|
|
|
102
103
|
"flex",
|
|
103
104
|
"flexGrow",
|
|
104
105
|
"flexShrink",
|
|
106
|
+
"order",
|
|
105
107
|
"zIndex",
|
|
106
108
|
"aspectRatio",
|
|
107
109
|
"gap",
|
|
@@ -54,6 +54,7 @@ export declare interface STXStyle {
|
|
|
54
54
|
flexBasis?: number | string
|
|
55
55
|
flexDirection?: 'row' | 'column' | 'row-reverse' | 'column-reverse'
|
|
56
56
|
flexWrap?: 'wrap' | 'nowrap' | 'wrap-reverse'
|
|
57
|
+
order?: number
|
|
57
58
|
justifyContent?: 'flex-start' | 'center' | 'flex-end' | 'space-between' | 'space-around' | 'space-evenly'
|
|
58
59
|
alignItems?: 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline'
|
|
59
60
|
alignSelf?: 'auto' | 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline'
|
|
@@ -215,6 +216,7 @@ export type STXComponentType = | 'Sidebar'
|
|
|
215
216
|
| 'Video'
|
|
216
217
|
| 'Map'
|
|
217
218
|
| 'MapPolyline'
|
|
219
|
+
| 'MapPolygon'
|
|
218
220
|
| 'MapMarker'
|
|
219
221
|
// Lists
|
|
220
222
|
| 'FlatList'
|
|
@@ -23,6 +23,7 @@ export declare const ComponentRegistry: {
|
|
|
23
23
|
Video: 'Video';
|
|
24
24
|
Map: 'Map';
|
|
25
25
|
MapPolyline: 'MapPolyline';
|
|
26
|
+
MapPolygon: 'MapPolygon';
|
|
26
27
|
MapMarker: 'MapMarker';
|
|
27
28
|
FlatList: 'FlatList';
|
|
28
29
|
SectionList: 'SectionList';
|
|
@@ -57,6 +58,7 @@ export declare interface AccessibilityState {
|
|
|
57
58
|
// ============================================================================
|
|
58
59
|
export declare interface ViewProps extends BaseProps {
|
|
59
60
|
onPress?: () => void
|
|
61
|
+
onClick?: () => void
|
|
60
62
|
onLongPress?: () => void
|
|
61
63
|
onLayout?: (event: LayoutEvent) => void
|
|
62
64
|
}
|
|
@@ -68,8 +70,10 @@ export declare interface ScrollViewProps extends ViewProps {
|
|
|
68
70
|
alwaysBounceHorizontal?: boolean
|
|
69
71
|
alwaysBounceVertical?: boolean
|
|
70
72
|
onScroll?: (event: ScrollEvent) => void
|
|
71
|
-
|
|
72
|
-
|
|
73
|
+
onScrollBeginDrag?: (event: ScrollEvent) => void
|
|
74
|
+
onScrollEndDrag?: (event: ScrollEvent) => void
|
|
75
|
+
onMomentumScrollBegin?: (event: ScrollEvent) => void
|
|
76
|
+
onMomentumScrollEnd?: (event: ScrollEvent) => void
|
|
73
77
|
contentContainerStyle?: STXStyle
|
|
74
78
|
keyboardDismissMode?: 'none' | 'on-drag' | 'interactive'
|
|
75
79
|
keyboardShouldPersistTaps?: 'always' | 'handled' | 'never'
|
|
@@ -94,6 +98,7 @@ export declare interface TextProps extends BaseProps {
|
|
|
94
98
|
ellipsizeMode?: 'head' | 'middle' | 'tail' | 'clip'
|
|
95
99
|
selectable?: boolean
|
|
96
100
|
onPress?: () => void
|
|
101
|
+
onClick?: () => void
|
|
97
102
|
onLongPress?: () => void
|
|
98
103
|
}
|
|
99
104
|
export declare interface TextInputProps extends BaseProps {
|
|
@@ -128,6 +133,7 @@ export declare interface TextInputProps extends BaseProps {
|
|
|
128
133
|
export declare interface ButtonProps extends BaseProps {
|
|
129
134
|
title?: string
|
|
130
135
|
onPress?: () => void
|
|
136
|
+
onClick?: () => void
|
|
131
137
|
disabled?: boolean
|
|
132
138
|
color?: string
|
|
133
139
|
}
|
|
@@ -137,6 +143,7 @@ export declare interface LinkProps extends BaseProps {
|
|
|
137
143
|
to?: string
|
|
138
144
|
title?: string
|
|
139
145
|
onPress?: () => void
|
|
146
|
+
onClick?: () => void
|
|
140
147
|
disabled?: boolean
|
|
141
148
|
color?: string
|
|
142
149
|
}
|
|
@@ -231,8 +238,6 @@ export declare interface ImageProps extends BaseProps {
|
|
|
231
238
|
onLoadStart?: () => void
|
|
232
239
|
onLoadEnd?: () => void
|
|
233
240
|
onError?: (event: ImageErrorEvent) => void
|
|
234
|
-
blurRadius?: number
|
|
235
|
-
fadeDuration?: number
|
|
236
241
|
defaultSource?: ImageSource
|
|
237
242
|
}
|
|
238
243
|
export declare interface ImageErrorEvent {
|
|
@@ -290,6 +295,21 @@ export declare interface MapRegion {
|
|
|
290
295
|
center: MapCoordinate
|
|
291
296
|
span: { latitudeDelta: number; longitudeDelta: number }
|
|
292
297
|
}
|
|
298
|
+
/** A keyed polyline overlay for large map collections. */
|
|
299
|
+
export declare interface MapPolylineOverlay {
|
|
300
|
+
id: string
|
|
301
|
+
geometry: number[]
|
|
302
|
+
strokeColor?: string
|
|
303
|
+
strokeWidth?: number
|
|
304
|
+
}
|
|
305
|
+
/** A keyed marker overlay for large map collections. */
|
|
306
|
+
export declare interface MapMarkerOverlay {
|
|
307
|
+
id: string
|
|
308
|
+
geometry: number[]
|
|
309
|
+
title?: string
|
|
310
|
+
pinColor?: string
|
|
311
|
+
bearing?: number
|
|
312
|
+
}
|
|
293
313
|
export declare interface MapProps extends BaseProps {
|
|
294
314
|
region?: MapRegion
|
|
295
315
|
initialRegion?: MapRegion
|
|
@@ -301,11 +321,13 @@ export declare interface MapProps extends BaseProps {
|
|
|
301
321
|
zoomEnabled?: boolean
|
|
302
322
|
rotateEnabled?: boolean
|
|
303
323
|
pitchEnabled?: boolean
|
|
304
|
-
mapType?: 'standard' | 'satellite' | 'hybrid'
|
|
324
|
+
mapType?: 'standard' | 'satellite' | 'hybrid'
|
|
305
325
|
showsCompass?: boolean
|
|
306
326
|
showsScale?: boolean
|
|
307
327
|
cameraPitch?: number
|
|
308
328
|
cameraHeading?: number
|
|
329
|
+
polylines?: MapPolylineOverlay[]
|
|
330
|
+
markers?: MapMarkerOverlay[]
|
|
309
331
|
onPress?: (event: { nativeEvent: MapCoordinate }) => void
|
|
310
332
|
onRegionChangeComplete?: (event: { nativeEvent: MapRegion & { heading: number, pitch: number } }) => void
|
|
311
333
|
onMarkerPress?: (event: { nativeEvent: { id: string } }) => void
|
|
@@ -315,6 +337,12 @@ export declare interface MapPolylineProps extends BaseProps {
|
|
|
315
337
|
strokeColor?: string
|
|
316
338
|
strokeWidth?: number
|
|
317
339
|
}
|
|
340
|
+
export declare interface MapPolygonProps extends BaseProps {
|
|
341
|
+
geometry: number[]
|
|
342
|
+
fillColor?: string
|
|
343
|
+
strokeColor?: string
|
|
344
|
+
strokeWidth?: number
|
|
345
|
+
}
|
|
318
346
|
export declare interface MapMarkerProps extends BaseProps {
|
|
319
347
|
geometry: number[]
|
|
320
348
|
id: string
|
|
@@ -350,7 +378,6 @@ export declare interface ModalProps extends BaseProps {
|
|
|
350
378
|
onRequestClose?: () => void
|
|
351
379
|
onShow?: () => void
|
|
352
380
|
onDismiss?: () => void
|
|
353
|
-
statusBarTranslucent?: boolean
|
|
354
381
|
}
|
|
355
382
|
export declare interface ActivityIndicatorProps extends BaseProps {
|
|
356
383
|
animating?: boolean
|
|
@@ -363,10 +390,7 @@ export declare interface ActivityIndicatorProps extends BaseProps {
|
|
|
363
390
|
// ============================================================================
|
|
364
391
|
export declare interface StatusBarProps {
|
|
365
392
|
barStyle?: 'default' | 'light-content' | 'dark-content'
|
|
366
|
-
backgroundColor?: string
|
|
367
393
|
hidden?: boolean
|
|
368
|
-
animated?: boolean
|
|
369
|
-
translucent?: boolean
|
|
370
394
|
}
|
|
371
395
|
export declare interface RefreshControlProps {
|
|
372
396
|
refreshing: boolean
|
|
@@ -14,13 +14,11 @@ const NATIVE_PROP_NAMES = [
|
|
|
14
14
|
"autoComplete",
|
|
15
15
|
"autoCorrect",
|
|
16
16
|
"autoFocus",
|
|
17
|
-
"blurRadius",
|
|
18
17
|
"contentContainerStyle",
|
|
19
18
|
"currentTime",
|
|
20
19
|
"defaultSource",
|
|
21
20
|
"defaultValue",
|
|
22
21
|
"ellipsizeMode",
|
|
23
|
-
"fadeDuration",
|
|
24
22
|
"hidesWhenStopped",
|
|
25
23
|
"hitSlop",
|
|
26
24
|
"imageStyle",
|
|
@@ -64,7 +62,6 @@ const NATIVE_PROP_NAMES = [
|
|
|
64
62
|
"selectionColor",
|
|
65
63
|
"showsHorizontalScrollIndicator",
|
|
66
64
|
"showsVerticalScrollIndicator",
|
|
67
|
-
"statusBarTranslucent",
|
|
68
65
|
"stickyHeaderIndices",
|
|
69
66
|
"testID",
|
|
70
67
|
"textContentType",
|
|
@@ -83,6 +80,7 @@ const NATIVE_PROP_NAMES = [
|
|
|
83
80
|
"rotateEnabled",
|
|
84
81
|
"pitchEnabled",
|
|
85
82
|
"mapType",
|
|
83
|
+
"fillColor",
|
|
86
84
|
"strokeColor",
|
|
87
85
|
"pinColor",
|
|
88
86
|
"showsCompass",
|
|
@@ -48,6 +48,7 @@ function capabilityFlags(capabilities) {
|
|
|
48
48
|
deviceInfo: capabilities.has("device"),
|
|
49
49
|
fetch: capabilities.has("fetch"),
|
|
50
50
|
badge: capabilities.has("badge"),
|
|
51
|
+
wallet: capabilities.has("wallet"),
|
|
51
52
|
appReview: !1,
|
|
52
53
|
health: capabilities.has("health"),
|
|
53
54
|
dialogs: capabilities.has("dialog"),
|
|
@@ -561,7 +562,21 @@ export function installCraftBridge(protocol, nativeBridge, target = globalThis,
|
|
|
561
562
|
saveMindfulSession: (session) => request("Health", "saveMindfulSession", [session]),
|
|
562
563
|
getMindfulSessions: (options = {}) => request("Health", "getMindfulSessions", [options]),
|
|
563
564
|
startHeartRateUpdates: (options = {}) => request("Health", "startHeartRateUpdates", [{ since: typeof options.since === "number" ? options.since : null }]),
|
|
564
|
-
stopHeartRateUpdates: () => request("Health", "stopHeartRateUpdates", [{}])
|
|
565
|
+
stopHeartRateUpdates: () => request("Health", "stopHeartRateUpdates", [{}]),
|
|
566
|
+
startWorkout: (options = {}) => request("Health", "startWorkout", [{
|
|
567
|
+
type: typeof options.type === "string" ? options.type : "",
|
|
568
|
+
...typeof options.location === "string" ? { location: options.location } : {}
|
|
569
|
+
}]),
|
|
570
|
+
pauseWorkout: () => request("Health", "pauseWorkout", []),
|
|
571
|
+
resumeWorkout: () => request("Health", "resumeWorkout", []),
|
|
572
|
+
endWorkout: () => request("Health", "endWorkout", []),
|
|
573
|
+
onWorkout: (callback) => {
|
|
574
|
+
if (typeof callback !== "function")
|
|
575
|
+
throw TypeError("health.onWorkout needs a function");
|
|
576
|
+
const handler = (event) => callback(event.detail || {});
|
|
577
|
+
target.addEventListener?.("craftHealthWorkout", handler);
|
|
578
|
+
return () => target.removeEventListener?.("craftHealthWorkout", handler);
|
|
579
|
+
}
|
|
565
580
|
};
|
|
566
581
|
if (capabilities.has("healthAvailability")) {
|
|
567
582
|
craft.health.availability = () => request("Health", "availability", []);
|
|
@@ -569,6 +584,12 @@ export function installCraftBridge(protocol, nativeBridge, target = globalThis,
|
|
|
569
584
|
craft.health.openSettings = () => ask("Health", "openSettings", []).then(Boolean);
|
|
570
585
|
}
|
|
571
586
|
}
|
|
587
|
+
if (capabilities.has("wallet"))
|
|
588
|
+
craft.wallet = {
|
|
589
|
+
isAvailable: () => request("Wallet", "isAvailable", []).then(Boolean),
|
|
590
|
+
add: (source) => request("Wallet", "add", [source]).then(Boolean),
|
|
591
|
+
has: (serialNumber) => request("Wallet", "has", [serialNumber]).then(Boolean)
|
|
592
|
+
};
|
|
572
593
|
craft.scheduleNotification = craft.notifications.schedule;
|
|
573
594
|
craft.cancelNotification = craft.notifications.cancel;
|
|
574
595
|
craft.cancelAllNotifications = craft.notifications.cancelAll;
|
|
@@ -237,10 +237,20 @@ export declare interface NativeCraft {
|
|
|
237
237
|
getMindfulSessions: (options?: { startDate?: number, endDate?: number, limit?: number }) => Promise<Array<Record<string, unknown>>>
|
|
238
238
|
startHeartRateUpdates: (options?: { since?: number }) => Promise<boolean>
|
|
239
239
|
stopHeartRateUpdates: () => Promise<boolean>
|
|
240
|
+
startWorkout: (options: { type: string, location?: 'indoor' | 'outdoor' | 'unknown' }) => Promise<{ id: string, type: string, startDate: number }>
|
|
241
|
+
pauseWorkout: () => Promise<boolean>
|
|
242
|
+
resumeWorkout: () => Promise<boolean>
|
|
243
|
+
endWorkout: () => Promise<{ id: string, workoutId: string, endDate: number, durationSeconds: number }>
|
|
244
|
+
onWorkout: (callback: (event: Record<string, unknown>) => unknown) => () => void
|
|
240
245
|
availability?: () => Promise<'available' | 'updateRequired' | 'unavailable'>
|
|
241
246
|
grantedTypes?: () => Promise<string[]>
|
|
242
247
|
openSettings?: () => Promise<boolean>
|
|
243
248
|
}
|
|
249
|
+
wallet?: {
|
|
250
|
+
isAvailable: () => Promise<boolean>
|
|
251
|
+
add: (source: { data?: string, url?: string }) => Promise<boolean>
|
|
252
|
+
has: (serialNumber: string) => Promise<boolean>
|
|
253
|
+
}
|
|
244
254
|
scheduledWorkouts?: {
|
|
245
255
|
isSupported: () => Promise<boolean>
|
|
246
256
|
authorization: () => Promise<'authorized' | 'denied' | 'notDetermined' | 'restricted' | 'unsupported'>
|
package/dist/process.js
CHANGED
|
@@ -628,8 +628,9 @@ ${joined}` : joined;
|
|
|
628
628
|
${output}`;
|
|
629
629
|
return unmaskHtmlComments(output);
|
|
630
630
|
} catch (error) {
|
|
631
|
-
|
|
632
|
-
|
|
631
|
+
if (error instanceof StxValidationError)
|
|
632
|
+
throw error;
|
|
633
|
+
throw new StxRuntimeError(`Error processing layout ${layoutPath}: ${error instanceof Error ? error.message : String(error)}`, filePath);
|
|
633
634
|
}
|
|
634
635
|
return unmaskHtmlComments(await processOtherDirectives(output, context, filePath, resolvedOptions, dependencies));
|
|
635
636
|
}
|
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{nr,Ue,si,uc}from"./chunk-2z56183d.js";import{tr,is,cc,lc,dc}from"./chunk-3d658f6n.js";import{ti,ni,ri,ic,ac}from"./chunk-dtt7k0bz.js";import{de,_t,as}from"./chunk-9nh7vxk1.js";import{pl,fl,gl,ml,Pr,Nu}from"./chunk-3wmt7ykt.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-kayh4pcw.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=de(t,n);o={fileCount:a.fileCount,totalSize:a.totalSize},e.precacheStats=o}try{let a=nr(n,t);if(a){let s=Ue(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 is(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,ni as auditBuildOutput,ti as auditConfig,re as buildPwaAssets,ri as calculateAuditResult,ac as formatAuditResult,as as formatSize,j as generateManifest,_ as generateManifestJson,lc as generateManifestLink,F as generateOfflinePage,de as generatePrecacheManifest,_t as generatePrecacheManifestJs,M as generatePwaIcons,tr as generatePwaTags,nr as generateServiceWorker,uc as generateServiceWorkerAuto,cc as generateSwRegistrationScript,dc as generateThemeColorMeta,N as getExpectedIconPaths,Ue as getServiceWorkerFileName,is as injectPwaTags,se as isPwaEnabled,I as isSharpAvailable,si as isWorkboxEnabled,q as mergeManifestConfig,ae as processPwaHtml,Pr as pwaDirectives,pl as pwaInstallDirective,gl as pwaOfflineDirective,ml as pwaPushDirective,fl as pwaUpdateDirective,Nu as registerPwaDirectives,ic as runPwaAudit,D as validateManifest};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { contentKey, renderMemo } from "./render-memo.js";
|
|
2
2
|
import { stripCommentsAndLiterals } from "./strip-literals.js";
|
|
3
|
+
import { StxValidationError } from "./errors/types.js";
|
|
3
4
|
const verdicts = renderMemo(256);
|
|
4
5
|
export const PROHIBITED_DOM_PATTERNS = [
|
|
5
6
|
{
|
|
@@ -215,7 +216,7 @@ export function validateClientScript(content, filePath, strict, originFilePath)
|
|
|
215
216
|
const memoKey = contentKey(content, filePath, originFilePath, JSON.stringify(strictConfig)), remembered = verdicts.get(memoKey);
|
|
216
217
|
if (remembered !== void 0) {
|
|
217
218
|
if (remembered && strictConfig.failOnViolation)
|
|
218
|
-
throw
|
|
219
|
+
throw new StxValidationError(remembered, originFilePath ?? filePath);
|
|
219
220
|
return;
|
|
220
221
|
}
|
|
221
222
|
const allowPatterns = strictConfig.allowPatterns ?? [], suppressed = parseStrictIgnores(content), errors = [], scannable = stripCommentsAndLiterals(content.replace(/\{\{--[\s\S]*?--\}\}/g, (match) => match.replace(/[^\n]/g, " ")));
|
|
@@ -257,8 +258,7 @@ ${errors.join(`
|
|
|
257
258
|
`)}
|
|
258
259
|
Tip: prefer useRef(), navigate(), and composables for component code`;
|
|
259
260
|
verdicts.set(memoKey, baseMessage);
|
|
261
|
+
console.warn(baseMessage);
|
|
260
262
|
if (strictConfig.failOnViolation)
|
|
261
|
-
throw
|
|
262
|
-
else
|
|
263
|
-
console.warn(baseMessage);
|
|
263
|
+
throw new StxValidationError(baseMessage, originFilePath ?? filePath);
|
|
264
264
|
}
|
package/dist/serve.js
CHANGED
|
@@ -8,6 +8,7 @@ import { extractVariables } from "./utils.js";
|
|
|
8
8
|
import { compressResponse } from "./compression.js";
|
|
9
9
|
import { readResponseHeaders, readResponseStatus } from "./page-response.js";
|
|
10
10
|
import { createServerApi, isServerApiSource } from "./server-api.js";
|
|
11
|
+
import { validateClientScript } from "./script-validation.js";
|
|
11
12
|
export function htmlResponse(html, status = 200, headers = {}) {
|
|
12
13
|
return new Response(html, {
|
|
13
14
|
status,
|
|
@@ -49,8 +50,11 @@ export async function serve(options = {}) {
|
|
|
49
50
|
const attrs = scriptMatch[1], scriptContent = scriptMatch[2], fullScript = scriptMatch[0];
|
|
50
51
|
if (attrs.includes("server"))
|
|
51
52
|
serverScripts.push(scriptContent);
|
|
52
|
-
else
|
|
53
|
+
else {
|
|
54
|
+
if (!/\bsrc\s*=|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/i.test(attrs))
|
|
55
|
+
validateClientScript(scriptContent, filePath, stxOptions.strict);
|
|
53
56
|
clientScripts.push(fullScript);
|
|
57
|
+
}
|
|
54
58
|
}
|
|
55
59
|
const styleMatches = content.match(/<style\b[^>]*>[\s\S]*?<\/style>/gi) || [];
|
|
56
60
|
let templateContent = workingContent.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi, "").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi, "");
|