@01.software/sdk 0.5.3 → 0.5.4
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/ui/flow.cjs +70 -8
- package/dist/ui/flow.cjs.map +1 -1
- package/dist/ui/flow.js +70 -8
- package/dist/ui/flow.js.map +1 -1
- package/package.json +1 -1
package/dist/ui/flow.cjs
CHANGED
|
@@ -472,6 +472,7 @@ function ensureQuickJSLoaded() {
|
|
|
472
472
|
_notify();
|
|
473
473
|
}).catch(() => {
|
|
474
474
|
_state = { status: "failed", module: null };
|
|
475
|
+
_notify();
|
|
475
476
|
});
|
|
476
477
|
}
|
|
477
478
|
function useQuickJS() {
|
|
@@ -616,7 +617,11 @@ function sanitizeStyle(style) {
|
|
|
616
617
|
for (const [k, v] of Object.entries(style)) {
|
|
617
618
|
if (BLOCKED_STYLE_PROPS.has(k)) continue;
|
|
618
619
|
if (typeof v === "string" && /url\s*\(/i.test(v)) continue;
|
|
619
|
-
if (k === "position" && typeof v === "string" && /fixed|
|
|
620
|
+
if (k === "position" && typeof v === "string" && /fixed|sticky/i.test(v)) continue;
|
|
621
|
+
if (k === "zIndex") {
|
|
622
|
+
const n = typeof v === "number" ? v : parseInt(String(v), 10);
|
|
623
|
+
if (isNaN(n) || n > 9998) continue;
|
|
624
|
+
}
|
|
620
625
|
safe[k] = v;
|
|
621
626
|
}
|
|
622
627
|
return safe;
|
|
@@ -712,10 +717,10 @@ function compileTemplate(code, slug) {
|
|
|
712
717
|
if (!qjs) return null;
|
|
713
718
|
const cacheKey = `${slug}:${code.length}:${hashCode(code)}`;
|
|
714
719
|
if (rendererCache.has(cacheKey)) {
|
|
715
|
-
const
|
|
720
|
+
const entry = rendererCache.get(cacheKey);
|
|
716
721
|
rendererCache.delete(cacheKey);
|
|
717
|
-
rendererCache.set(cacheKey,
|
|
718
|
-
return
|
|
722
|
+
rendererCache.set(cacheKey, entry);
|
|
723
|
+
return entry.fc;
|
|
719
724
|
}
|
|
720
725
|
let jsCode;
|
|
721
726
|
try {
|
|
@@ -730,12 +735,13 @@ function compileTemplate(code, slug) {
|
|
|
730
735
|
return null;
|
|
731
736
|
}
|
|
732
737
|
const renderer = makeRenderer(jsCode);
|
|
738
|
+
const fc = makeReactFC(renderer, qjs);
|
|
733
739
|
if (rendererCache.size >= MAX_CACHE_SIZE) {
|
|
734
740
|
const oldest = rendererCache.keys().next().value;
|
|
735
741
|
if (oldest) rendererCache.delete(oldest);
|
|
736
742
|
}
|
|
737
|
-
rendererCache.set(cacheKey, renderer);
|
|
738
|
-
return
|
|
743
|
+
rendererCache.set(cacheKey, { renderer, fc });
|
|
744
|
+
return fc;
|
|
739
745
|
}
|
|
740
746
|
function clearTemplateCache() {
|
|
741
747
|
rendererCache.clear();
|
|
@@ -932,6 +938,11 @@ var import_postcss = __toESM(require("postcss"), 1);
|
|
|
932
938
|
var ALLOWED_AT_RULES = /* @__PURE__ */ new Set(["keyframes", "media", "supports", "container", "layer"]);
|
|
933
939
|
var BLOCKED_VALUE_PATTERNS = [/url\s*\(/i, /expression\s*\(/i, /paint\s*\(/i, /-moz-binding/i];
|
|
934
940
|
var DANGEROUS_SELECTOR = /(?:^|[\s,])(?::root|html|body)\b/;
|
|
941
|
+
var BLOCKED_PROPERTY_VALUES = {
|
|
942
|
+
// absolute is allowed — contained by nearest positioned ancestor (node wrapper)
|
|
943
|
+
position: /fixed|sticky/i
|
|
944
|
+
};
|
|
945
|
+
var Z_INDEX_MAX = 9998;
|
|
935
946
|
function sanitizeCSS(css, scopeClass) {
|
|
936
947
|
let root;
|
|
937
948
|
try {
|
|
@@ -939,14 +950,66 @@ function sanitizeCSS(css, scopeClass) {
|
|
|
939
950
|
} catch (e) {
|
|
940
951
|
return "";
|
|
941
952
|
}
|
|
953
|
+
const safeScopeClass = scopeClass ? scopeClass.replace(/[{}()[\];,'"\\<>\s]/g, "") : "";
|
|
954
|
+
const keyframeNameMap = /* @__PURE__ */ new Map();
|
|
955
|
+
if (safeScopeClass) {
|
|
956
|
+
root.walkAtRules(/^keyframes$/i, (node) => {
|
|
957
|
+
const rawName = node.params.trim().replace(/^['"]|['"]$/g, "");
|
|
958
|
+
const originalName = rawName;
|
|
959
|
+
const scopedName = `${safeScopeClass}__${rawName.replace(/\s+/g, "_")}`;
|
|
960
|
+
keyframeNameMap.set(originalName, scopedName);
|
|
961
|
+
node.params = scopedName;
|
|
962
|
+
});
|
|
963
|
+
}
|
|
964
|
+
if (safeScopeClass && keyframeNameMap.size > 0) {
|
|
965
|
+
const ANIM_KEYWORDS = /* @__PURE__ */ new Set(["none", "initial", "inherit", "unset", "revert"]);
|
|
966
|
+
const replaceAnimName = (token) => {
|
|
967
|
+
var _a;
|
|
968
|
+
const t = token.trim().replace(/^['"]|['"]$/g, "");
|
|
969
|
+
return ANIM_KEYWORDS.has(t) ? token : (_a = keyframeNameMap.get(t)) != null ? _a : token;
|
|
970
|
+
};
|
|
971
|
+
root.walkDecls(/^animation-name$/i, (node) => {
|
|
972
|
+
node.value = node.value.split(",").map(replaceAnimName).join(", ");
|
|
973
|
+
});
|
|
974
|
+
root.walkDecls(/^animation$/i, (node) => {
|
|
975
|
+
node.value = node.value.split(",").map(
|
|
976
|
+
(anim) => anim.split(/(\s+)/).map((token) => /\s/.test(token) ? token : replaceAnimName(token)).join("")
|
|
977
|
+
).join(",");
|
|
978
|
+
});
|
|
979
|
+
}
|
|
942
980
|
root.walkAtRules((node) => {
|
|
943
981
|
if (!ALLOWED_AT_RULES.has(node.name.toLowerCase())) {
|
|
944
982
|
node.remove();
|
|
945
983
|
}
|
|
946
984
|
});
|
|
947
985
|
root.walkDecls((node) => {
|
|
948
|
-
|
|
986
|
+
const normalizedValue = node.value.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
987
|
+
if (BLOCKED_VALUE_PATTERNS.some((p) => p.test(normalizedValue))) {
|
|
949
988
|
node.remove();
|
|
989
|
+
return;
|
|
990
|
+
}
|
|
991
|
+
const propLower = node.prop.toLowerCase();
|
|
992
|
+
const blockedValuePattern = BLOCKED_PROPERTY_VALUES[propLower];
|
|
993
|
+
if (blockedValuePattern) {
|
|
994
|
+
const deescaped = normalizedValue.replace(
|
|
995
|
+
/\\([0-9a-fA-F]{1,6})\s?/g,
|
|
996
|
+
(_, hex) => String.fromCodePoint(parseInt(hex, 16))
|
|
997
|
+
);
|
|
998
|
+
if (blockedValuePattern.test(deescaped)) {
|
|
999
|
+
node.remove();
|
|
1000
|
+
return;
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
if (propLower === "z-index") {
|
|
1004
|
+
const zv = node.value.trim();
|
|
1005
|
+
if (zv === "auto" || zv === "initial" || zv === "inherit" || zv === "unset" || zv === "revert") {
|
|
1006
|
+
} else {
|
|
1007
|
+
const val = parseInt(zv, 10);
|
|
1008
|
+
if (isNaN(val) || String(val) !== zv || val > Z_INDEX_MAX) {
|
|
1009
|
+
node.remove();
|
|
1010
|
+
return;
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
950
1013
|
}
|
|
951
1014
|
});
|
|
952
1015
|
root.walkRules((rule) => {
|
|
@@ -956,7 +1019,6 @@ function sanitizeCSS(css, scopeClass) {
|
|
|
956
1019
|
return;
|
|
957
1020
|
}
|
|
958
1021
|
if (scopeClass) {
|
|
959
|
-
const safeScopeClass = scopeClass.replace(/[{}()[\];,'"\\<>]/g, "");
|
|
960
1022
|
if (!safeScopeClass) {
|
|
961
1023
|
rule.remove();
|
|
962
1024
|
return;
|