@getforma/core 0.9.0 → 0.9.1
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-N522P3G6.js → chunk-CN56FSDT.js} +2 -2
- package/dist/chunk-CN56FSDT.js.map +1 -0
- package/dist/{chunk-YMIMKO4W.cjs → chunk-GDULJFJO.cjs} +2 -2
- package/dist/chunk-GDULJFJO.cjs.map +1 -0
- package/dist/forma-runtime-csp.js +1 -1
- package/dist/forma-runtime.js +1 -1
- package/dist/formajs-runtime-hardened.global.js +1 -1
- package/dist/formajs-runtime-hardened.global.js.map +1 -1
- package/dist/formajs-runtime.global.js +1 -1
- package/dist/formajs-runtime.global.js.map +1 -1
- package/dist/formajs.global.js +1 -1
- package/dist/formajs.global.js.map +1 -1
- package/dist/index.cjs +55 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/runtime-hardened.cjs +3 -111
- package/dist/runtime-hardened.cjs.map +1 -1
- package/dist/runtime-hardened.js +4 -112
- package/dist/runtime-hardened.js.map +1 -1
- package/dist/runtime.cjs +22 -22
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.js +1 -1
- package/dist/runtime.js.map +1 -1
- package/dist/{signal-B4_wQJHs.d.cts → signal-YlS1kgfh.d.cts} +1 -1
- package/dist/{signal-B4_wQJHs.d.ts → signal-YlS1kgfh.d.ts} +1 -1
- package/dist/tc39-compat.d.cts +1 -1
- package/dist/tc39-compat.d.ts +1 -1
- package/package.json +1 -1
- package/dist/chunk-N522P3G6.js.map +0 -1
- package/dist/chunk-YMIMKO4W.cjs.map +0 -1
package/dist/runtime-hardened.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { signal, computed, effect, startBatch, endBatch
|
|
1
|
+
import { signal, computed, effect, setActiveSub, startBatch, endBatch } from 'alien-signals';
|
|
2
2
|
|
|
3
3
|
// src/reactive/signal.ts
|
|
4
4
|
function applySignalSet(s, v, equals) {
|
|
@@ -888,7 +888,7 @@ var UNSAFE_METHOD_NAMES = /* @__PURE__ */ new Set([
|
|
|
888
888
|
"eval",
|
|
889
889
|
"Function"
|
|
890
890
|
]);
|
|
891
|
-
|
|
891
|
+
(() => {
|
|
892
892
|
const result = [];
|
|
893
893
|
for (const name of UNSAFE_METHOD_NAMES) {
|
|
894
894
|
const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
@@ -902,44 +902,6 @@ var BLOCKED_METHOD_REGEXES = (() => {
|
|
|
902
902
|
}
|
|
903
903
|
return result;
|
|
904
904
|
})();
|
|
905
|
-
function findBlockedMethod(expr) {
|
|
906
|
-
let cleaned = expr.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
907
|
-
cleaned = cleaned.replace(/\/\/[^\n]*/g, "");
|
|
908
|
-
cleaned = cleaned.replace(/\s*\.\s*/g, ".");
|
|
909
|
-
for (const { name, dotRe, bracketRe } of BLOCKED_METHOD_REGEXES) {
|
|
910
|
-
if (dotRe.test(cleaned)) return name;
|
|
911
|
-
if (bracketRe.test(cleaned)) return name;
|
|
912
|
-
}
|
|
913
|
-
if (cleaned.includes("[")) {
|
|
914
|
-
const bracketContents = extractBracketContents(cleaned);
|
|
915
|
-
for (const content of bracketContents) {
|
|
916
|
-
if (!content.includes("+")) continue;
|
|
917
|
-
const fragments = content.match(/['"`]([^'"`]*?)['"`]/g);
|
|
918
|
-
if (!fragments) continue;
|
|
919
|
-
const joined = fragments.map((f) => f.slice(1, -1)).join("");
|
|
920
|
-
if (UNSAFE_METHOD_NAMES.has(joined)) return joined;
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
|
-
return null;
|
|
924
|
-
}
|
|
925
|
-
function extractBracketContents(expr) {
|
|
926
|
-
const results = [];
|
|
927
|
-
let depth = 0;
|
|
928
|
-
let start = -1;
|
|
929
|
-
for (let i = 0; i < expr.length; i++) {
|
|
930
|
-
if (expr[i] === "[") {
|
|
931
|
-
if (depth === 0) start = i + 1;
|
|
932
|
-
depth++;
|
|
933
|
-
} else if (expr[i] === "]") {
|
|
934
|
-
depth--;
|
|
935
|
-
if (depth === 0 && start >= 0) {
|
|
936
|
-
results.push(expr.slice(start, i));
|
|
937
|
-
start = -1;
|
|
938
|
-
}
|
|
939
|
-
}
|
|
940
|
-
}
|
|
941
|
-
return results;
|
|
942
|
-
}
|
|
943
905
|
var TEXT_BINDING_SYM = /* @__PURE__ */ Symbol.for("forma-text-binding-cache");
|
|
944
906
|
function toTextValue(value2) {
|
|
945
907
|
if (value2 == null) return "";
|
|
@@ -1943,40 +1905,13 @@ function buildEvaluator(expr, scope) {
|
|
|
1943
1905
|
cache.set(cleaned, cspFn);
|
|
1944
1906
|
return cspFn;
|
|
1945
1907
|
}
|
|
1946
|
-
|
|
1908
|
+
{
|
|
1947
1909
|
dbg("buildEvaluator: blocked unsafe eval fallback for expression:", cleaned);
|
|
1948
1910
|
reportDiagnostic("expression-unsupported", cleaned, cspExpressionHint(cleaned));
|
|
1949
1911
|
const blocked = () => void 0;
|
|
1950
1912
|
cache.set(cleaned, blocked);
|
|
1951
1913
|
return blocked;
|
|
1952
1914
|
}
|
|
1953
|
-
const blockedMethod = findBlockedMethod(cleaned);
|
|
1954
|
-
if (blockedMethod) {
|
|
1955
|
-
const msg = `Blocked unsafe method "${blockedMethod}" in expression`;
|
|
1956
|
-
reportDiagnostic("expression-unsupported", cleaned, msg);
|
|
1957
|
-
throw new Error(`[FormaJS] ${msg}: ${cleaned}`);
|
|
1958
|
-
}
|
|
1959
|
-
try {
|
|
1960
|
-
const fn = new Function("__scope", `with(__scope) { return (${cleaned}); }`);
|
|
1961
|
-
const proxy = new Proxy(/* @__PURE__ */ Object.create(null), {
|
|
1962
|
-
has(_, key) {
|
|
1963
|
-
return key in scope.getters;
|
|
1964
|
-
},
|
|
1965
|
-
get(_, key) {
|
|
1966
|
-
if (UNSAFE_METHOD_NAMES.has(key)) return void 0;
|
|
1967
|
-
const g = scope.getters[key];
|
|
1968
|
-
return g ? g() : void 0;
|
|
1969
|
-
}
|
|
1970
|
-
});
|
|
1971
|
-
const unsafe = () => fn(proxy);
|
|
1972
|
-
cache.set(cleaned, unsafe);
|
|
1973
|
-
return unsafe;
|
|
1974
|
-
} catch {
|
|
1975
|
-
reportDiagnostic("expression-unsupported", cleaned, "Expression too complex for CSP-safe mode. Enable unsafe-eval via FormaRuntime.unsafeEval = true, or use the standard (non-hardened) build.");
|
|
1976
|
-
const failed = () => void 0;
|
|
1977
|
-
cache.set(cleaned, failed);
|
|
1978
|
-
return failed;
|
|
1979
|
-
}
|
|
1980
1915
|
}
|
|
1981
1916
|
function parseHandler(expr, scope) {
|
|
1982
1917
|
const normalized = expr.trim().replace(/;+$/g, "").trim();
|
|
@@ -2094,7 +2029,7 @@ function buildHandler(expr, scope) {
|
|
|
2094
2029
|
cache.set(cleaned, result);
|
|
2095
2030
|
return result;
|
|
2096
2031
|
}
|
|
2097
|
-
|
|
2032
|
+
{
|
|
2098
2033
|
dbg("buildHandler: blocked unsafe eval fallback for expression:", cleaned);
|
|
2099
2034
|
reportDiagnostic("handler-unsupported", cleaned, cspExpressionHint(cleaned));
|
|
2100
2035
|
const result = {
|
|
@@ -2105,49 +2040,6 @@ function buildHandler(expr, scope) {
|
|
|
2105
2040
|
cache.set(cleaned, result);
|
|
2106
2041
|
return result;
|
|
2107
2042
|
}
|
|
2108
|
-
const blockedMethod = findBlockedMethod(cleaned);
|
|
2109
|
-
if (blockedMethod) {
|
|
2110
|
-
const msg = `Blocked unsafe method "${blockedMethod}" in handler`;
|
|
2111
|
-
reportDiagnostic("handler-unsupported", cleaned, msg);
|
|
2112
|
-
throw new Error(`[FormaJS] ${msg}: ${cleaned}`);
|
|
2113
|
-
}
|
|
2114
|
-
try {
|
|
2115
|
-
const fn = new Function("__scope", "$event", "event", `with(__scope) { ${cleaned} }`);
|
|
2116
|
-
const proxy = new Proxy(/* @__PURE__ */ Object.create(null), {
|
|
2117
|
-
has(_, key) {
|
|
2118
|
-
if (key === "$event" || key === "event") return false;
|
|
2119
|
-
return key in scope.getters || key in scope.setters;
|
|
2120
|
-
},
|
|
2121
|
-
get(_, key) {
|
|
2122
|
-
if (UNSAFE_METHOD_NAMES.has(key)) return void 0;
|
|
2123
|
-
const g = scope.getters[key];
|
|
2124
|
-
return g ? g() : void 0;
|
|
2125
|
-
},
|
|
2126
|
-
set(_, key, value2) {
|
|
2127
|
-
const s = scope.setters[key];
|
|
2128
|
-
if (s) s(value2);
|
|
2129
|
-
return true;
|
|
2130
|
-
}
|
|
2131
|
-
});
|
|
2132
|
-
const unsafeHandler = (e) => {
|
|
2133
|
-
batch(() => fn(proxy, e, e));
|
|
2134
|
-
};
|
|
2135
|
-
const result = {
|
|
2136
|
-
handler: unsafeHandler,
|
|
2137
|
-
supported: true
|
|
2138
|
-
};
|
|
2139
|
-
cache.set(cleaned, result);
|
|
2140
|
-
return result;
|
|
2141
|
-
} catch {
|
|
2142
|
-
reportDiagnostic("handler-unsupported", cleaned, "Expression too complex for CSP-safe mode. Enable unsafe-eval via FormaRuntime.unsafeEval = true, or use the standard (non-hardened) build.");
|
|
2143
|
-
const result = {
|
|
2144
|
-
handler: () => {
|
|
2145
|
-
},
|
|
2146
|
-
supported: false
|
|
2147
|
-
};
|
|
2148
|
-
cache.set(cleaned, result);
|
|
2149
|
-
return result;
|
|
2150
|
-
}
|
|
2151
2043
|
}
|
|
2152
2044
|
var FORBIDDEN_STATE_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
2153
2045
|
function parseState(raw) {
|