@stacksjs/stx 0.2.286 → 0.2.287
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/builtins/index.d.ts +4 -3
- package/dist/builtins/index.js +11 -11
- package/dist/chunk-122tyfre.js +2 -0
- package/dist/{chunk-0fgcnv6y.js → chunk-19nfvxfw.js} +1 -1
- package/dist/{chunk-ah4e6e09.js → chunk-1kah92n2.js} +1 -1
- package/dist/{chunk-90qr4f9m.js → chunk-1kms3b9d.js} +1 -1
- package/dist/{chunk-s2284nbk.js → chunk-1q4y74mh.js} +1 -1
- package/dist/{chunk-49kk0s96.js → chunk-248e84r1.js} +1 -1
- package/dist/{chunk-zfr4d08r.js → chunk-24ps8kft.js} +1 -1
- package/dist/chunk-2et5hxfv.js +2 -0
- package/dist/chunk-2r1rd8f0.js +2 -0
- package/dist/{chunk-2q630fj4.js → chunk-2tk1zkrz.js} +1 -1
- package/dist/{chunk-ysnk7x79.js → chunk-38ejahd9.js} +1 -1
- package/dist/chunk-3zv4wz87.js +2 -0
- package/dist/chunk-4122k1bh.js +2 -0
- package/dist/chunk-45az9zht.js +2 -0
- package/dist/{chunk-yq1d9hb3.js → chunk-4qr85f07.js} +1 -1
- package/dist/{chunk-m3yaa0v5.js → chunk-4ww3znrr.js} +1 -1
- package/dist/chunk-5a19dhx5.js +2 -0
- package/dist/{chunk-39f40yc4.js → chunk-5kk8gsj2.js} +1 -1
- package/dist/{chunk-kzyhvrp8.js → chunk-5w1e3yxs.js} +1 -1
- package/dist/chunk-6gdycmxr.js +2 -0
- package/dist/{chunk-e2w23g2r.js → chunk-6hmnaza7.js} +10 -10
- package/dist/{chunk-zn5jgmqw.js → chunk-71t0yan0.js} +1 -1
- package/dist/chunk-74v15e8z.js +2 -0
- package/dist/{chunk-j9g11dzx.js → chunk-7b329e5v.js} +1 -1
- package/dist/{chunk-g3fy0tw8.js → chunk-866y9d8b.js} +154 -48
- package/dist/chunk-8fwerspy.js +2 -0
- package/dist/{chunk-c0an64km.js → chunk-8mjdpr94.js} +1 -1
- package/dist/{chunk-q68xmak4.js → chunk-92mj1t26.js} +18 -18
- package/dist/{chunk-mkn6qqc7.js → chunk-9b22663r.js} +1 -1
- package/dist/chunk-9hjdgm4d.js +2 -0
- package/dist/{chunk-y8n174xq.js → chunk-9wr7zcad.js} +2 -2
- package/dist/{chunk-qbeffw17.js → chunk-a0nfbmeh.js} +1 -1
- package/dist/{chunk-rhs51nmz.js → chunk-acn1b56m.js} +2 -2
- package/dist/chunk-awkq3xfx.js +2 -0
- package/dist/{chunk-bf8wf3r2.js → chunk-b6ej2fdf.js} +2 -2
- package/dist/{chunk-e7jfpyqy.js → chunk-b8rrnqry.js} +1 -1
- package/dist/{chunk-s7pc68jf.js → chunk-bfqfs07m.js} +1 -1
- package/dist/{chunk-fjkstnz3.js → chunk-bs6kapy7.js} +1 -1
- package/dist/{chunk-qd8ggjdx.js → chunk-btav940g.js} +1 -1
- package/dist/{chunk-pbk8jxe2.js → chunk-ccspd3mc.js} +1 -1
- package/dist/{chunk-7rxtra1g.js → chunk-csbgwaa5.js} +1 -1
- package/dist/chunk-d8t4sjsp.js +2 -0
- package/dist/chunk-dap191q2.js +2 -0
- package/dist/{chunk-ayrjwkyw.js → chunk-de7fye10.js} +1 -1
- package/dist/{chunk-2g9jwgs7.js → chunk-dgrt76d2.js} +1 -1
- package/dist/{chunk-9zndrzb3.js → chunk-dhh5q7qt.js} +1 -1
- package/dist/chunk-dsffsqnt.js +2 -0
- package/dist/{chunk-d0c3v7ax.js → chunk-dtq7y5ym.js} +1 -1
- package/dist/{chunk-w95sp0k9.js → chunk-fed3xsp9.js} +2 -2
- package/dist/{chunk-jbfpc4z7.js → chunk-ferav3bw.js} +1 -1
- package/dist/{chunk-a63y3aa0.js → chunk-fvhm8psm.js} +1 -1
- package/dist/{chunk-bz2gytfs.js → chunk-g4vpzv6b.js} +1 -1
- package/dist/{chunk-n3jyv9z6.js → chunk-g9csmj0s.js} +1 -1
- package/dist/chunk-gtcrpmz1.js +2 -0
- package/dist/{chunk-hs0387tm.js → chunk-h4xh8cms.js} +1 -1
- package/dist/chunk-h8yqsz9m.js +2 -0
- package/dist/{chunk-phhzfeh9.js → chunk-hcq5dw7a.js} +1 -1
- package/dist/{chunk-qsr3bqav.js → chunk-hm0xha6c.js} +1 -1
- package/dist/chunk-jegt35zh.js +2 -0
- package/dist/{chunk-nh21517m.js → chunk-k56rjjc0.js} +1 -1
- package/dist/{chunk-kmhr1z0m.js → chunk-kdh37tp8.js} +1 -1
- package/dist/{chunk-e4hhz9j3.js → chunk-kxzb4et3.js} +1 -1
- package/dist/{chunk-3bv8h4r6.js → chunk-mf4n3x1j.js} +1 -1
- package/dist/{chunk-5aq35j2e.js → chunk-mkd9kjgb.js} +1 -1
- package/dist/chunk-mxfh1nxg.js +2 -0
- package/dist/{chunk-snknv47x.js → chunk-nkb3scg6.js} +1 -1
- package/dist/{chunk-s67mgegv.js → chunk-nnd4wq8j.js} +1 -1
- package/dist/{chunk-w0sqz3cb.js → chunk-nsp1cw38.js} +1 -1
- package/dist/chunk-p3242nck.js +2 -0
- package/dist/chunk-p98kfh94.js +2 -0
- package/dist/{chunk-t1k5dpbr.js → chunk-pkaabd8h.js} +1 -1
- package/dist/{chunk-xg57nax9.js → chunk-pzm13sdc.js} +1 -1
- package/dist/{chunk-vy8v5xdb.js → chunk-q4p5k2p3.js} +1 -1
- package/dist/{chunk-sskbegsz.js → chunk-qc1f74ek.js} +1 -1
- package/dist/{chunk-nvgxjvnb.js → chunk-qpyjak7z.js} +1 -1
- package/dist/{chunk-an2539bs.js → chunk-qr82je1m.js} +1 -1
- package/dist/{chunk-a54n1r1q.js → chunk-qy73j6m4.js} +1 -1
- package/dist/{chunk-p396xrew.js → chunk-qzkhpsam.js} +1 -1
- package/dist/{chunk-f3hfk78e.js → chunk-r3ayvdz3.js} +1 -1
- package/dist/chunk-r7r66978.js +2 -0
- package/dist/{chunk-6cye5m9f.js → chunk-rbb7dvja.js} +1 -1
- package/dist/{chunk-kdrpx9ft.js → chunk-rj4kajww.js} +1 -1
- package/dist/{chunk-areethga.js → chunk-rp4rjjmf.js} +1 -1
- package/dist/{chunk-gjemavhx.js → chunk-se0p17c2.js} +1 -1
- package/dist/chunk-sj9pmene.js +2 -0
- package/dist/{chunk-a2qghr2x.js → chunk-sscwkffs.js} +1 -1
- package/dist/chunk-svpqxn2c.js +2 -0
- package/dist/chunk-t8y1ggdy.js +2 -0
- package/dist/{chunk-y6kw0wb7.js → chunk-tndhnk9e.js} +1 -1
- package/dist/{chunk-c6fw33zh.js → chunk-v5e1gxwm.js} +2 -2
- package/dist/{chunk-7p9ns60j.js → chunk-vrrax298.js} +1 -1
- package/dist/{chunk-9th1wd1d.js → chunk-wrzwgkbx.js} +3 -3
- package/dist/{chunk-jn6m8zf7.js → chunk-x650vjcp.js} +1 -1
- package/dist/{chunk-mjkfc2v6.js → chunk-xgnc1wy6.js} +1 -1
- package/dist/{chunk-52mh63sp.js → chunk-xpp135ad.js} +1 -1
- package/dist/chunk-y11cxbxd.js +3757 -0
- package/dist/{chunk-cvnh7dma.js → chunk-y98jsjqq.js} +1 -1
- package/dist/{chunk-vbdca0k1.js → chunk-ya386h70.js} +1 -1
- package/dist/chunk-ydrz60kr.js +2 -0
- package/dist/{chunk-0f1kz0x2.js → chunk-ypmqf7tm.js} +1 -1
- package/dist/{chunk-jrk8rhwt.js → chunk-z4jhj5e5.js} +1 -1
- package/dist/{chunk-fskfes13.js → chunk-zg75gjns.js} +1 -1
- package/dist/{chunk-mb518a4n.js → chunk-zqqx1qaj.js} +1 -1
- package/dist/cli.js +14 -14
- package/dist/client-script.js +27 -7
- package/dist/component-client-factories.js +10 -5
- package/dist/component-processing.d.ts +13 -0
- package/dist/component-processing.js +37 -1
- package/dist/component-renderer.js +34 -15
- package/dist/conditionals.js +14 -3
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/database.js +1 -1
- package/dist/document-shell.d.ts +1 -34
- package/dist/document-shell.js +19 -11
- package/dist/html-masking.d.ts +65 -9
- package/dist/html-masking.js +103 -15
- package/dist/misc-directives.d.ts +1 -1
- package/dist/misc-directives.js +48 -13
- package/dist/process.js +14 -4
- package/dist/pwa.js +2 -2
- package/dist/reactive-bindings.js +2 -0
- package/dist/runtime-globals.d.ts +7 -20
- package/dist/runtime-globals.js +28 -3
- package/dist/safe-evaluator.d.ts +15 -0
- package/dist/safe-evaluator.js +16 -12
- package/dist/server-bindings.js +21 -5
- package/dist/signal-processing.d.ts +17 -7
- package/dist/signal-processing.js +112 -43
- package/dist/signals-api.js +5 -2
- package/dist/signals.js +153 -47
- package/dist/ssg.js +2 -2
- package/dist/utils.js +23 -6
- package/dist/variable-extractor.js +17 -47
- package/dist/visual-testing.js +1 -1
- package/package.json +5 -5
- package/dist/chunk-3ehv1by2.js +0 -2
- package/dist/chunk-4cqgbcy7.js +0 -3756
- package/dist/chunk-56ywtaff.js +0 -2
- package/dist/chunk-61sj52qh.js +0 -2
- package/dist/chunk-7ej1d910.js +0 -2
- package/dist/chunk-829pcte9.js +0 -2
- package/dist/chunk-8emkx9ja.js +0 -2
- package/dist/chunk-ajbfeey7.js +0 -2
- package/dist/chunk-b29wbjs5.js +0 -2
- package/dist/chunk-b7tjq91c.js +0 -2
- package/dist/chunk-ba6tthsm.js +0 -2
- package/dist/chunk-e4akvata.js +0 -2
- package/dist/chunk-f4k2a7vs.js +0 -2
- package/dist/chunk-f80wwn5x.js +0 -2
- package/dist/chunk-j03bare5.js +0 -2
- package/dist/chunk-jg0axas8.js +0 -2
- package/dist/chunk-kawk5ve9.js +0 -2
- package/dist/chunk-m7xnzt2t.js +0 -2
- package/dist/chunk-qk8tbcwk.js +0 -2
- package/dist/chunk-qp97dx7x.js +0 -2
- package/dist/chunk-vb10qph4.js +0 -2
- package/dist/chunk-vrvehb01.js +0 -2
- package/dist/chunk-w8smn72c.js +0 -2
- package/dist/chunk-wxk2pbrh.js +0 -2
- package/dist/chunk-x1nw1p8z.js +0 -2
- package/dist/chunk-xz55q3gr.js +0 -2
- package/dist/chunk-ytgnzeeb.js +0 -2
package/dist/utils.js
CHANGED
|
@@ -15,6 +15,7 @@ import { transformStoreImports } from "./store-imports.js";
|
|
|
15
15
|
import { LRUCache } from "./performance-utils.js";
|
|
16
16
|
import { processDirectives } from "./process.js";
|
|
17
17
|
import { getPublicEnvDefine } from "./public-env.js";
|
|
18
|
+
import { isUsableParamName } from "./safe-evaluator.js";
|
|
18
19
|
import { processScopedStyles } from "./style-scoping.js";
|
|
19
20
|
import { findSfcTemplateBlock } from "./sfc-template.js";
|
|
20
21
|
import { importOnce } from "./lazy-module.js";
|
|
@@ -101,8 +102,22 @@ export function getSharedTranspiler(options) {
|
|
|
101
102
|
transpilerPool.set(key, transpiler);
|
|
102
103
|
return transpiler;
|
|
103
104
|
}
|
|
105
|
+
const transpileResults = new WeakMap, TRANSPILE_RESULTS_MAX_ENTRIES = 256;
|
|
104
106
|
export function transpileTypeScript(code) {
|
|
105
107
|
try {
|
|
108
|
+
const transpiler = getSharedTranspiler({
|
|
109
|
+
loader: "ts",
|
|
110
|
+
target: "browser",
|
|
111
|
+
define: getPublicEnvDefine()
|
|
112
|
+
});
|
|
113
|
+
let results = transpileResults.get(transpiler);
|
|
114
|
+
if (!results) {
|
|
115
|
+
results = new Map;
|
|
116
|
+
transpileResults.set(transpiler, results);
|
|
117
|
+
}
|
|
118
|
+
const cached = results.get(code);
|
|
119
|
+
if (cached !== void 0)
|
|
120
|
+
return cached;
|
|
106
121
|
let processedCode = code.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm, "");
|
|
107
122
|
processedCode = processedCode.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm, "");
|
|
108
123
|
const placeholders = [];
|
|
@@ -121,15 +136,17 @@ export function transpileTypeScript(code) {
|
|
|
121
136
|
placeholders.push(match);
|
|
122
137
|
return `"__STX_EXPR_${idx}__"`;
|
|
123
138
|
});
|
|
124
|
-
let result =
|
|
125
|
-
loader: "ts",
|
|
126
|
-
target: "browser",
|
|
127
|
-
define: getPublicEnvDefine()
|
|
128
|
-
}).transformSync(processedCode);
|
|
139
|
+
let result = transpiler.transformSync(processedCode);
|
|
129
140
|
for (let i = 0;i < placeholders.length; i++) {
|
|
130
141
|
result = result.replace(`"__STX_EXPR_${i}__"`, placeholders[i]);
|
|
131
142
|
result = result.replace(`'__STX_EXPR_${i}__'`, placeholders[i]);
|
|
132
143
|
}
|
|
144
|
+
if (results.size >= TRANSPILE_RESULTS_MAX_ENTRIES) {
|
|
145
|
+
const oldest = results.keys().next();
|
|
146
|
+
if (!oldest.done)
|
|
147
|
+
results.delete(oldest.value);
|
|
148
|
+
}
|
|
149
|
+
results.set(code, result);
|
|
133
150
|
return result;
|
|
134
151
|
} catch (e) {
|
|
135
152
|
if (process.env.STX_DEBUG_TS)
|
|
@@ -375,7 +392,7 @@ function applyDestructuredPropDefaults(componentContent, ctx) {
|
|
|
375
392
|
if (!expr)
|
|
376
393
|
continue;
|
|
377
394
|
try {
|
|
378
|
-
const keys = Object.keys(ctx), fn = Function(...keys, `"use strict"; return (${expr});`);
|
|
395
|
+
const keys = Object.keys(ctx).filter(isUsableParamName), fn = Function(...keys, `"use strict"; return (${expr});`);
|
|
379
396
|
ctx[name] = fn(...keys.map((k) => ctx[k]));
|
|
380
397
|
} catch {}
|
|
381
398
|
}
|
|
@@ -56,10 +56,10 @@ const ENGINE_BINDINGS = new Set(STX_ENGINE_BINDING_NAMES), CONTEXT_RESERVED_BIND
|
|
|
56
56
|
import { findMatchingDelimiter } from "./parser/tokenizer.js";
|
|
57
57
|
import { mergeHeadConfigs, seoMetaToHeadConfig } from "./head.js";
|
|
58
58
|
import { getPublicEnvDefine } from "./public-env.js";
|
|
59
|
-
import { safeEvaluate } from "./safe-evaluator.js";
|
|
59
|
+
import { isUsableParamName, safeEvaluate } from "./safe-evaluator.js";
|
|
60
60
|
import { responseBindings } from "./page-response.js";
|
|
61
61
|
import { contentKey, renderMemo } from "./render-memo.js";
|
|
62
|
-
const transpiledServerScripts = renderMemo(128);
|
|
62
|
+
const transpiledServerScripts = renderMemo(128), compiledServerScripts = renderMemo(64);
|
|
63
63
|
function extractDeclaredVariableNames(script) {
|
|
64
64
|
const names = [];
|
|
65
65
|
let depth = 0;
|
|
@@ -479,48 +479,12 @@ export async function extractVariables(scriptContent, context, filePath, options
|
|
|
479
479
|
removeEventListener: () => {}
|
|
480
480
|
}, mockConsole = console;
|
|
481
481
|
try {
|
|
482
|
-
const convertedScript = convertToCommonJS(jsContent, filePath), propsKeys = new Set(Object.keys(propsObj)),
|
|
482
|
+
const convertedScript = convertToCommonJS(jsContent, filePath), propsKeys = new Set(Object.keys(propsObj)), filteredContextKeys = Object.keys(context).filter((key) => !propsKeys.has(key) && !CONTEXT_RESERVED_BINDINGS.has(key) && isUsableParamName(key)), filteredContextValues = filteredContextKeys.map((key) => context[key]);
|
|
483
483
|
if (!filteredContextKeys.includes("__stxServeContext")) {
|
|
484
484
|
filteredContextKeys.push("__stxServeContext");
|
|
485
485
|
filteredContextValues.push(void 0);
|
|
486
486
|
}
|
|
487
|
-
const
|
|
488
|
-
"break",
|
|
489
|
-
"case",
|
|
490
|
-
"catch",
|
|
491
|
-
"class",
|
|
492
|
-
"const",
|
|
493
|
-
"continue",
|
|
494
|
-
"debugger",
|
|
495
|
-
"default",
|
|
496
|
-
"delete",
|
|
497
|
-
"do",
|
|
498
|
-
"else",
|
|
499
|
-
"export",
|
|
500
|
-
"extends",
|
|
501
|
-
"finally",
|
|
502
|
-
"for",
|
|
503
|
-
"function",
|
|
504
|
-
"if",
|
|
505
|
-
"import",
|
|
506
|
-
"in",
|
|
507
|
-
"instanceof",
|
|
508
|
-
"let",
|
|
509
|
-
"new",
|
|
510
|
-
"return",
|
|
511
|
-
"super",
|
|
512
|
-
"switch",
|
|
513
|
-
"this",
|
|
514
|
-
"throw",
|
|
515
|
-
"try",
|
|
516
|
-
"typeof",
|
|
517
|
-
"var",
|
|
518
|
-
"void",
|
|
519
|
-
"while",
|
|
520
|
-
"with",
|
|
521
|
-
"yield",
|
|
522
|
-
"enum",
|
|
523
|
-
"await",
|
|
487
|
+
const stxShadowedNames = new Set([
|
|
524
488
|
"async",
|
|
525
489
|
"module",
|
|
526
490
|
"exports",
|
|
@@ -534,9 +498,9 @@ export async function extractVariables(scriptContent, context, filePath, options
|
|
|
534
498
|
"effect"
|
|
535
499
|
]), propArgNames = [], propArgValues = [];
|
|
536
500
|
for (const [key, value] of Object.entries(propsObj)) {
|
|
537
|
-
if (
|
|
501
|
+
if (!isUsableParamName(key))
|
|
538
502
|
continue;
|
|
539
|
-
if (
|
|
503
|
+
if (stxShadowedNames.has(key))
|
|
540
504
|
continue;
|
|
541
505
|
if (new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${key}\\b`).test(convertedScript))
|
|
542
506
|
continue;
|
|
@@ -551,11 +515,17 @@ export async function extractVariables(scriptContent, context, filePath, options
|
|
|
551
515
|
scriptContextKeys.push(filteredContextKeys[i]);
|
|
552
516
|
scriptContextValues.push(filteredContextValues[i]);
|
|
553
517
|
}
|
|
554
|
-
const
|
|
518
|
+
const scriptParams = [...STX_ENGINE_BINDING_NAMES, ...propArgNames, ...scriptContextKeys], scriptBody = `return (async () => {
|
|
555
519
|
${convertedScript}
|
|
556
520
|
${reSyncCode}
|
|
557
521
|
return module.exports
|
|
558
|
-
})()
|
|
522
|
+
})()`, compileKey = contentKey(scriptBody, scriptParams.join("\x00"));
|
|
523
|
+
let scriptFn = compiledServerScripts.get(compileKey);
|
|
524
|
+
if (!scriptFn) {
|
|
525
|
+
scriptFn = Function(...scriptParams, scriptBody);
|
|
526
|
+
compiledServerScripts.set(compileKey, scriptFn);
|
|
527
|
+
}
|
|
528
|
+
const result = await scriptFn(module, exports, requireFn, propsObj, $props, defineProps, withDefaults, defineClientPayload, state, derived, effect, batch, onMount, onDestroy, definePageMeta, useRoute, useRouter, useHead, useSeoMeta, responseApi.setResponseStatus, responseApi.setResponseHeader, responseApi.notFound, ref, reactive, computed, watch, onMounted, onUnmounted, nextTick, defineEmits, defineExpose, defineSlots, provide, inject, useColorMode, useDark, useMediaQuery, useScrollLock, usePreferredDark, usePreferredLight, usePreferredReducedMotion, usePreferredContrast, windowProxy, mockDocument, mockConsole, mockWindow.confirm, mockWindow.alert, mockWindow.fetch, paramsObj, ...propArgValues, ...scriptContextValues);
|
|
559
529
|
if (options.preserveExisting) {
|
|
560
530
|
for (const [key, value] of Object.entries(result))
|
|
561
531
|
if (!(key in context) || context[key] === void 0)
|
|
@@ -1290,12 +1260,12 @@ function evaluateFallbackExpression(expression, context) {
|
|
|
1290
1260
|
return direct;
|
|
1291
1261
|
if (!/\bprocess\b/.test(expression))
|
|
1292
1262
|
return;
|
|
1293
|
-
const processEnvContext = { ...context, process: Object.freeze({ env: { ...process.env } }) };
|
|
1263
|
+
const processEnvContext = { ...context, process: Object.freeze({ env: { ...process.env } }) }, envKeys = Object.keys(processEnvContext).filter(isUsableParamName), envValues = envKeys.map((key) => processEnvContext[key]);
|
|
1294
1264
|
try {
|
|
1295
|
-
return Function(...
|
|
1265
|
+
return Function(...envKeys, `'use strict'; return (${expression});`)(...envValues);
|
|
1296
1266
|
} catch {
|
|
1297
1267
|
try {
|
|
1298
|
-
return Function(...
|
|
1268
|
+
return Function(...envKeys, `'use strict'; return ${expression};`)(...envValues);
|
|
1299
1269
|
} catch {
|
|
1300
1270
|
return;
|
|
1301
1271
|
}
|
package/dist/visual-testing.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-
|
|
2
|
+
import"./chunk-qc1f74ek.js";import B from"fs";import $ from"path";import k from"crypto";var V=[{name:"mobile",width:375,height:667,isMobile:!0,hasTouch:!0},{name:"tablet",width:768,height:1024,isMobile:!0,hasTouch:!0},{name:"desktop",width:1280,height:800,isMobile:!1,hasTouch:!1},{name:"wide",width:1920,height:1080,isMobile:!1,hasTouch:!1}];function J(N={}){let Y={snapshotDir:N.snapshotDir||"__snapshots__",screenshotDir:N.screenshotDir||"__screenshots__",updateSnapshots:N.updateSnapshots||process.env.UPDATE_SNAPSHOTS==="true",threshold:N.threshold??0.01,viewports:N.viewports||V,generateDiff:N.generateDiff??!0,diffDir:N.diffDir||"__diffs__",compare:N.compare||b,ci:N.ci??process.env.CI==="true",retries:N.retries??(N.ci?3:1)};return{async snapshot(M,X){let q=$.join(Y.snapshotDir,`${X}.html`),G=C(M),Q=K(G);if(await Bun.file(q).exists()){let W=await Bun.file(q).text(),Z=K(C(W));if(Q===Z)return{passed:!0,snapshotPath:q,message:"Snapshot matches"};if(Y.updateSnapshots)return await B.promises.mkdir($.dirname(q),{recursive:!0}),await Bun.write(q,G),{passed:!0,snapshotPath:q,message:"Snapshot updated"};let F=$.join(Y.diffDir,`${X}.actual.html`),U=$.join(Y.diffDir,`${X}.diff.html`);return await B.promises.mkdir(Y.diffDir,{recursive:!0}),await Bun.write(F,G),await Bun.write(U,I(W,G)),{passed:!1,snapshotPath:q,actualPath:F,diffPath:U,message:"Snapshot does not match"}}return await B.promises.mkdir($.dirname(q),{recursive:!0}),await Bun.write(q,G),{passed:!0,snapshotPath:q,message:"New snapshot created"}},async snapshotJson(M,X){let q=$.join(Y.snapshotDir,`${X}.json`),G=JSON.stringify(M,null,2);if(await Bun.file(q).exists()){let Q=await Bun.file(q).text();if(G===Q)return{passed:!0,snapshotPath:q};if(Y.updateSnapshots)return await Bun.write(q,G),{passed:!0,snapshotPath:q,message:"Snapshot updated"};return{passed:!1,snapshotPath:q,message:`JSON snapshot mismatch:
|
|
3
3
|
${z(Q,G)}`}}return await B.promises.mkdir($.dirname(q),{recursive:!0}),await Bun.write(q,G),{passed:!0,snapshotPath:q,message:"New snapshot created"}},matchInlineSnapshot(M,X){let q=C(M);if(X===void 0)return{passed:!0,expected:q};let G=C(X);return{passed:q===G,expected:q}},getConfig(){return Y}}}function D(N={}){let Y=J(N),M=Y.getConfig();return{async compareScreenshots(X,q,G="desktop"){let Q=$.join(M.screenshotDir,G,`${X}.png`),W=$.join(M.diffDir,G,`${X}.actual.png`),Z=$.join(M.diffDir,G,`${X}.diff.png`);if(await Bun.file(Q).exists()){let F=await Bun.file(Q).arrayBuffer(),U=Buffer.from(F),_=await M.compare(q,U);if(_.match||_.diffPercentage<=M.threshold)return{viewport:G,passed:!0,baselinePath:Q};if(M.updateSnapshots)return await B.promises.mkdir($.dirname(Q),{recursive:!0}),await Bun.write(Q,q),{viewport:G,passed:!0,baselinePath:Q};if(await B.promises.mkdir($.dirname(W),{recursive:!0}),await Bun.write(W,q),_.diffImage&&M.generateDiff)await Bun.write(Z,_.diffImage);return{viewport:G,passed:!1,baselinePath:Q,actualPath:W,diffPath:M.generateDiff?Z:void 0,diffPercentage:_.diffPercentage}}return await B.promises.mkdir($.dirname(Q),{recursive:!0}),await Bun.write(Q,q),{viewport:G,passed:!0,baselinePath:Q}},async testViewports(X,q,G=M.viewports){let Q=[];for(let W of G){let Z=null;for(let F=0;F<M.retries;F++)try{let U=await q(W),_=await this.compareScreenshots(X,U,W.name);Q.push(_),Z=null;break}catch(U){if(Z=U,F<M.retries-1)await new Promise((_)=>setTimeout(_,100*(F+1)))}if(Z)Q.push({viewport:W.name,passed:!1,baselinePath:"",diffPercentage:100})}return Q},getSnapshotTester(){return Y}}}function L(N={}){let M=D(N).getSnapshotTester(),X=new Map;return{addStory(q){X.set(`${q.component}/${q.name}`,q)},addStories(q){for(let G of q)this.addStory(G)},getStories(){return Array.from(X.values())},getStoriesForComponent(q){return Array.from(X.values()).filter((G)=>G.component===q)},async testStory(q){let G=X.get(q);if(!G)return{name:q,passed:!1,duration:0,snapshots:[],screenshots:[],errors:[Error(`Story not found: ${q}`)]};let Q=Date.now(),W={name:q,passed:!0,duration:0,snapshots:[],screenshots:[],errors:[]};try{let Z=await G.render(),F=await M.snapshot(Z,q.replace(/\//g,"-"));if(W.snapshots.push(F),!F.passed)W.passed=!1}catch(Z){W.passed=!1,W.errors.push(Z)}return W.duration=Date.now()-Q,W},async testAllStories(){let q=[];for(let G of X.keys()){let Q=await this.testStory(G);q.push(Q)}return q},async generateStoryIndex(){let q={};for(let G of X.values()){if(!q[G.component])q[G.component]=[];q[G.component].push({name:G.name,args:G.args})}return JSON.stringify(q,null,2)}}}async function S(N,Y={}){let M={outputDir:Y.outputDir||"visual-test-report",format:Y.format||"html",title:Y.title||"Visual Test Report",includeScreenshots:Y.includeScreenshots??!0};await B.promises.mkdir(M.outputDir,{recursive:!0});let X=N.length,q=N.filter((F)=>F.passed).length,G=X-q,Q=N.reduce((F,U)=>F+U.duration,0);if(M.format==="json"){let F={title:M.title,summary:{total:X,passed:q,failed:G,duration:Q},results:N,generatedAt:new Date().toISOString()},U=$.join(M.outputDir,"report.json");return await Bun.write(U,JSON.stringify(F,null,2)),U}if(M.format==="markdown"){let F=`# ${M.title}
|
|
4
4
|
|
|
5
5
|
`;F+=`## Summary
|
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.287",
|
|
5
5
|
"description": "A performant UI Framework. Powered by Bun.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -117,12 +117,12 @@
|
|
|
117
117
|
"dependencies": {
|
|
118
118
|
"@stacksjs/ts-css": "^0.3.2",
|
|
119
119
|
"@stacksjs/clapp": "^0.2.14",
|
|
120
|
-
"@stacksjs/desktop": "0.2.
|
|
121
|
-
"@stacksjs/sanitizer": "0.2.
|
|
120
|
+
"@stacksjs/desktop": "0.2.287",
|
|
121
|
+
"@stacksjs/sanitizer": "0.2.287",
|
|
122
122
|
"@stacksjs/ts-i18n": "^0.1.11",
|
|
123
|
-
"bun-plugin-stx": "0.2.
|
|
123
|
+
"bun-plugin-stx": "0.2.287",
|
|
124
124
|
"bunfig": "^0.15.17",
|
|
125
|
-
"stx-router": "0.2.
|
|
125
|
+
"stx-router": "0.2.287",
|
|
126
126
|
"ts-broadcasting": "^0.0.9",
|
|
127
127
|
"ts-images": "^0.2.17",
|
|
128
128
|
"ts-syntax-highlighter": "^0.2.1"
|
package/dist/chunk-3ehv1by2.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{mk as a,nk as b,ok as c,pk as d}from"./chunk-s7pc68jf.js";import"./chunk-y8n174xq.js";import"./chunk-4cqgbcy7.js";import"./chunk-q68xmak4.js";import"./chunk-c0an64km.js";import"./chunk-t1k5dpbr.js";import"./chunk-52mh63sp.js";import"./chunk-9th1wd1d.js";import"./chunk-39f40yc4.js";import"./chunk-ysnk7x79.js";import"./chunk-0f1kz0x2.js";import"./chunk-ayrjwkyw.js";import"./chunk-c6fw33zh.js";import"./chunk-bf8wf3r2.js";import"./chunk-jn6m8zf7.js";import"./chunk-sskbegsz.js";export{b as getAvailableTargets,c as getAvailableFormats,d as default,a as buildNative};
|