@getforma/core 1.0.10 → 1.2.0
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-T33QUD2Y.cjs → chunk-E3FV2VSU.cjs} +43 -43
- package/dist/{chunk-T33QUD2Y.cjs.map → chunk-E3FV2VSU.cjs.map} +1 -1
- package/dist/chunk-ETPJTPYD.js +103 -0
- package/dist/chunk-ETPJTPYD.js.map +1 -0
- package/dist/chunk-H7MDUHS5.cjs +110 -0
- package/dist/chunk-H7MDUHS5.cjs.map +1 -0
- package/dist/{chunk-6FW5E54W.cjs → chunk-KUXNZ5MG.cjs} +127 -103
- package/dist/chunk-KUXNZ5MG.cjs.map +1 -0
- package/dist/{chunk-3G7ET4O5.js → chunk-Y3A2EVVS.js} +121 -94
- package/dist/chunk-Y3A2EVVS.js.map +1 -0
- package/dist/{chunk-AFRFF7XL.js → chunk-YRNYOZF3.js} +4 -4
- package/dist/{chunk-AFRFF7XL.js.map → chunk-YRNYOZF3.js.map} +1 -1
- package/dist/forma-runtime-csp.js +52 -4
- package/dist/forma-runtime.js +98 -10
- package/dist/formajs-runtime-hardened.global.js +52 -4
- package/dist/formajs-runtime-hardened.global.js.map +1 -1
- package/dist/formajs-runtime.global.js +98 -10
- package/dist/formajs-runtime.global.js.map +1 -1
- package/dist/formajs.global.js +368 -147
- package/dist/formajs.global.js.map +1 -1
- package/dist/http.cjs +11 -11
- package/dist/http.js +2 -2
- package/dist/index.cjs +262 -141
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +32 -27
- package/dist/index.d.ts +32 -27
- package/dist/index.js +204 -83
- package/dist/index.js.map +1 -1
- package/dist/{resource-DeEzxUz6.d.cts → resource-D6HfVgiA.d.cts} +7 -2
- package/dist/{resource-BHsgURy0.d.ts → resource-ljs2X5NM.d.ts} +7 -2
- package/dist/runtime-hardened.cjs +53 -3
- package/dist/runtime-hardened.cjs.map +1 -1
- package/dist/runtime-hardened.js +53 -3
- package/dist/runtime-hardened.js.map +1 -1
- package/dist/runtime.cjs +29 -29
- package/dist/runtime.js +3 -3
- package/dist/server.cjs +7 -7
- package/dist/server.d.cts +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +2 -2
- package/dist/{signal-C9v4akyJ.d.cts → signal-CRBJYQ6B.d.cts} +0 -8
- package/dist/{signal-C9v4akyJ.d.ts → signal-CRBJYQ6B.d.ts} +0 -8
- package/dist/tc39-compat.cjs +3 -6
- package/dist/tc39-compat.cjs.map +1 -1
- package/dist/tc39-compat.d.cts +1 -1
- package/dist/tc39-compat.d.ts +1 -1
- package/dist/tc39-compat.js +1 -4
- package/dist/tc39-compat.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-3G7ET4O5.js.map +0 -1
- package/dist/chunk-6FW5E54W.cjs.map +0 -1
- package/dist/chunk-HLM5BZZQ.js +0 -35
- package/dist/chunk-HLM5BZZQ.js.map +0 -1
- package/dist/chunk-QLPCVK7C.cjs +0 -38
- package/dist/chunk-QLPCVK7C.cjs.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkKUXNZ5MG_cjs = require('./chunk-KUXNZ5MG.cjs');
|
|
4
|
+
var chunkH7MDUHS5_cjs = require('./chunk-H7MDUHS5.cjs');
|
|
5
5
|
|
|
6
6
|
// src/dom/element.ts
|
|
7
7
|
var Fragment = /* @__PURE__ */ Symbol.for("forma.fragment");
|
|
@@ -156,7 +156,7 @@ function getCache(el) {
|
|
|
156
156
|
}
|
|
157
157
|
function handleClass(el, _key, value) {
|
|
158
158
|
if (typeof value === "function") {
|
|
159
|
-
|
|
159
|
+
chunkKUXNZ5MG_cjs.internalEffect(() => {
|
|
160
160
|
const v = value();
|
|
161
161
|
const cache = getCache(el);
|
|
162
162
|
if (cache["class"] === v) return;
|
|
@@ -206,7 +206,7 @@ function applyStyleObj(el, obj, prevKeys) {
|
|
|
206
206
|
function handleStyle(el, _key, value) {
|
|
207
207
|
if (typeof value === "function") {
|
|
208
208
|
let prevKeys = [];
|
|
209
|
-
|
|
209
|
+
chunkKUXNZ5MG_cjs.internalEffect(() => {
|
|
210
210
|
const v = value();
|
|
211
211
|
if (typeof v === "string") {
|
|
212
212
|
const cache = getCache(el);
|
|
@@ -236,7 +236,7 @@ function handleEvent(el, key, value) {
|
|
|
236
236
|
}
|
|
237
237
|
function handleInnerHTML(el, _key, value) {
|
|
238
238
|
if (typeof value === "function") {
|
|
239
|
-
|
|
239
|
+
chunkKUXNZ5MG_cjs.internalEffect(() => {
|
|
240
240
|
const resolved = value();
|
|
241
241
|
if (resolved == null) {
|
|
242
242
|
el.innerHTML = "";
|
|
@@ -280,7 +280,7 @@ function handleInnerHTML(el, _key, value) {
|
|
|
280
280
|
function handleXLink(el, key, value) {
|
|
281
281
|
const localName = key.slice(6);
|
|
282
282
|
if (typeof value === "function") {
|
|
283
|
-
|
|
283
|
+
chunkKUXNZ5MG_cjs.internalEffect(() => {
|
|
284
284
|
const v = value();
|
|
285
285
|
if (v == null || v === false) {
|
|
286
286
|
el.removeAttributeNS(XLINK_NS, localName);
|
|
@@ -298,7 +298,7 @@ function handleXLink(el, key, value) {
|
|
|
298
298
|
}
|
|
299
299
|
function handleBooleanAttr(el, key, value) {
|
|
300
300
|
if (typeof value === "function") {
|
|
301
|
-
|
|
301
|
+
chunkKUXNZ5MG_cjs.internalEffect(() => {
|
|
302
302
|
const v = value();
|
|
303
303
|
const cache = getCache(el);
|
|
304
304
|
if (cache[key] === v) return;
|
|
@@ -322,7 +322,7 @@ function handleBooleanAttr(el, key, value) {
|
|
|
322
322
|
}
|
|
323
323
|
function handleGenericAttr(el, key, value) {
|
|
324
324
|
if (typeof value === "function") {
|
|
325
|
-
|
|
325
|
+
chunkKUXNZ5MG_cjs.internalEffect(() => {
|
|
326
326
|
const v = value();
|
|
327
327
|
if (v == null || v === false) {
|
|
328
328
|
const cache = getCache(el);
|
|
@@ -465,7 +465,7 @@ function appendChild(parent, child) {
|
|
|
465
465
|
}
|
|
466
466
|
currentNode = null;
|
|
467
467
|
};
|
|
468
|
-
|
|
468
|
+
chunkKUXNZ5MG_cjs.internalEffect(() => {
|
|
469
469
|
const v = child();
|
|
470
470
|
let resolved = v;
|
|
471
471
|
if (Array.isArray(v)) {
|
|
@@ -615,7 +615,7 @@ function createShow(when, thenFn, elseFn = () => null) {
|
|
|
615
615
|
let currentNode = null;
|
|
616
616
|
let lastTruthy = null;
|
|
617
617
|
let currentDispose = null;
|
|
618
|
-
const showDispose =
|
|
618
|
+
const showDispose = chunkKUXNZ5MG_cjs.internalEffect(() => {
|
|
619
619
|
const truthy = !!when();
|
|
620
620
|
const DEBUG = typeof globalThis.__FORMA_DEBUG__ !== "undefined";
|
|
621
621
|
const DEBUG_LABEL = DEBUG ? thenFn.toString().slice(0, 60) : "";
|
|
@@ -647,9 +647,9 @@ function createShow(when, thenFn, elseFn = () => null) {
|
|
|
647
647
|
const branchFn = truthy ? thenFn : elseFn;
|
|
648
648
|
if (branchFn) {
|
|
649
649
|
let branchDispose;
|
|
650
|
-
currentNode =
|
|
650
|
+
currentNode = chunkKUXNZ5MG_cjs.createRoot((dispose) => {
|
|
651
651
|
branchDispose = dispose;
|
|
652
|
-
return
|
|
652
|
+
return chunkKUXNZ5MG_cjs.untrack(() => branchFn());
|
|
653
653
|
});
|
|
654
654
|
currentDispose = branchDispose;
|
|
655
655
|
} else {
|
|
@@ -659,7 +659,7 @@ function createShow(when, thenFn, elseFn = () => null) {
|
|
|
659
659
|
parent.insertBefore(currentNode, endMarker);
|
|
660
660
|
}
|
|
661
661
|
});
|
|
662
|
-
|
|
662
|
+
chunkKUXNZ5MG_cjs.registerDisposer(() => {
|
|
663
663
|
if (currentDispose) {
|
|
664
664
|
currentDispose();
|
|
665
665
|
currentDispose = null;
|
|
@@ -707,7 +707,7 @@ function applyDynamicProps(el, props) {
|
|
|
707
707
|
}
|
|
708
708
|
const fn = value;
|
|
709
709
|
const attrKey = key;
|
|
710
|
-
|
|
710
|
+
chunkKUXNZ5MG_cjs.internalEffect(() => {
|
|
711
711
|
const v = fn();
|
|
712
712
|
if (v === false || v == null) {
|
|
713
713
|
el.removeAttribute(attrKey);
|
|
@@ -819,13 +819,13 @@ function setupShowEffect(desc, marker) {
|
|
|
819
819
|
let elseFragment = null;
|
|
820
820
|
const hasSSRContent = marker.start.nextSibling !== marker.end;
|
|
821
821
|
if (!hasSSRContent && currentCondition) {
|
|
822
|
-
if (
|
|
822
|
+
if (chunkH7MDUHS5_cjs.__DEV__) console.warn("[forma] Hydration: show condition mismatch \u2014 SSR empty but client condition is true");
|
|
823
823
|
const trueBranch = desc.whenTrue();
|
|
824
824
|
if (trueBranch instanceof Node) {
|
|
825
825
|
marker.start.parentNode.insertBefore(trueBranch, marker.end);
|
|
826
826
|
}
|
|
827
827
|
}
|
|
828
|
-
|
|
828
|
+
chunkKUXNZ5MG_cjs.internalEffect(() => {
|
|
829
829
|
const next = !!desc.condition();
|
|
830
830
|
if (next === currentCondition) return;
|
|
831
831
|
currentCondition = next;
|
|
@@ -872,7 +872,7 @@ function adoptBranchContent(desc, regionStart, regionEnd) {
|
|
|
872
872
|
}
|
|
873
873
|
function adoptNode(desc, ssrEl) {
|
|
874
874
|
if (!ssrEl || ssrEl.tagName !== desc.tag.toUpperCase()) {
|
|
875
|
-
if (
|
|
875
|
+
if (chunkH7MDUHS5_cjs.__DEV__) console.warn(`Hydration mismatch: expected <${desc.tag}>, got <${ssrEl?.tagName?.toLowerCase() ?? "nothing"}>`);
|
|
876
876
|
const fresh = descriptorToElement(desc);
|
|
877
877
|
if (ssrEl) ssrEl.replaceWith(fresh);
|
|
878
878
|
return;
|
|
@@ -946,7 +946,7 @@ function adoptNode(desc, ssrEl) {
|
|
|
946
946
|
}
|
|
947
947
|
node = node.nextSibling;
|
|
948
948
|
}
|
|
949
|
-
const currentItems =
|
|
949
|
+
const currentItems = chunkKUXNZ5MG_cjs.untrack(() => child.items());
|
|
950
950
|
const listKeyFn = child.keyFn;
|
|
951
951
|
const listRenderFn = child.renderFn;
|
|
952
952
|
const useIndexFallback = ssrKeyMap.size === 0 && ssrElements.length > 0;
|
|
@@ -970,11 +970,11 @@ function adoptNode(desc, ssrEl) {
|
|
|
970
970
|
adoptedNodes.push(ssrNode);
|
|
971
971
|
adoptedItems.push(item);
|
|
972
972
|
} else {
|
|
973
|
-
if (
|
|
973
|
+
if (chunkH7MDUHS5_cjs.__DEV__) console.warn(`[FormaJS] Hydration: list item key "${key}" not found in SSR \u2014 rendering fresh`);
|
|
974
974
|
const prevHydrating = hydrating;
|
|
975
975
|
hydrating = false;
|
|
976
976
|
try {
|
|
977
|
-
const [getIndex] =
|
|
977
|
+
const [getIndex] = chunkH7MDUHS5_cjs.createSignal(i);
|
|
978
978
|
const fresh = listRenderFn(item, getIndex);
|
|
979
979
|
end.parentNode.insertBefore(fresh, end);
|
|
980
980
|
adoptedNodes.push(fresh);
|
|
@@ -992,7 +992,7 @@ function adoptNode(desc, ssrEl) {
|
|
|
992
992
|
}
|
|
993
993
|
} else {
|
|
994
994
|
for (const [unusedKey, unusedNode] of ssrKeyMap) {
|
|
995
|
-
if (
|
|
995
|
+
if (chunkH7MDUHS5_cjs.__DEV__) console.warn(`[FormaJS] Hydration: removing extra SSR list item with key "${unusedKey}"`);
|
|
996
996
|
if (unusedNode.parentNode) {
|
|
997
997
|
unusedNode.parentNode.removeChild(unusedNode);
|
|
998
998
|
}
|
|
@@ -1006,7 +1006,7 @@ function adoptNode(desc, ssrEl) {
|
|
|
1006
1006
|
for (let i = 0; i < adoptedItems.length; i++) {
|
|
1007
1007
|
const item = adoptedItems[i];
|
|
1008
1008
|
const key = listKeyFn(item);
|
|
1009
|
-
const [getIndex, setIndex] =
|
|
1009
|
+
const [getIndex, setIndex] = chunkH7MDUHS5_cjs.createSignal(i);
|
|
1010
1010
|
cache.set(key, {
|
|
1011
1011
|
element: adoptedNodes[i],
|
|
1012
1012
|
item,
|
|
@@ -1016,7 +1016,7 @@ function adoptNode(desc, ssrEl) {
|
|
|
1016
1016
|
}
|
|
1017
1017
|
let reconcileNodes = adoptedNodes.slice();
|
|
1018
1018
|
let reconcileItems = adoptedItems.slice();
|
|
1019
|
-
|
|
1019
|
+
chunkKUXNZ5MG_cjs.internalEffect(() => {
|
|
1020
1020
|
const newItems = child.items();
|
|
1021
1021
|
const parent2 = start.parentNode;
|
|
1022
1022
|
if (!parent2) return;
|
|
@@ -1031,8 +1031,8 @@ function adoptNode(desc, ssrEl) {
|
|
|
1031
1031
|
hydrating = false;
|
|
1032
1032
|
try {
|
|
1033
1033
|
const key = listKeyFn(item);
|
|
1034
|
-
const [getIndex, setIndex] =
|
|
1035
|
-
const element =
|
|
1034
|
+
const [getIndex, setIndex] = chunkH7MDUHS5_cjs.createSignal(0);
|
|
1035
|
+
const element = chunkKUXNZ5MG_cjs.untrack(() => listRenderFn(item, getIndex));
|
|
1036
1036
|
cache.set(key, { element, item, getIndex, setIndex });
|
|
1037
1037
|
return element;
|
|
1038
1038
|
} finally {
|
|
@@ -1081,12 +1081,12 @@ function adoptNode(desc, ssrEl) {
|
|
|
1081
1081
|
const endMarker = findClosingMarker(cursor);
|
|
1082
1082
|
let textNode = cursor.nextSibling;
|
|
1083
1083
|
if (!textNode || textNode.nodeType !== 3) {
|
|
1084
|
-
if (
|
|
1084
|
+
if (chunkH7MDUHS5_cjs.__DEV__) console.warn(`[FormaJS] Hydration: created text node for marker ${data} \u2014 SSR walker should emit content between markers`);
|
|
1085
1085
|
const created = document.createTextNode("");
|
|
1086
1086
|
cursor.parentNode.insertBefore(created, endMarker || cursor.nextSibling);
|
|
1087
1087
|
textNode = created;
|
|
1088
1088
|
}
|
|
1089
|
-
|
|
1089
|
+
chunkKUXNZ5MG_cjs.internalEffect(() => {
|
|
1090
1090
|
textNode.data = String(child());
|
|
1091
1091
|
});
|
|
1092
1092
|
cursor = endMarker ? endMarker.nextSibling : textNode.nextSibling;
|
|
@@ -1096,11 +1096,11 @@ function adoptNode(desc, ssrEl) {
|
|
|
1096
1096
|
if (end) {
|
|
1097
1097
|
let textNode = findTextBetween(start, end);
|
|
1098
1098
|
if (!textNode) {
|
|
1099
|
-
if (
|
|
1099
|
+
if (chunkH7MDUHS5_cjs.__DEV__) console.warn(`[FormaJS] Hydration: created text node for show marker ${start.data} \u2014 SSR walker should emit content between markers`);
|
|
1100
1100
|
textNode = document.createTextNode("");
|
|
1101
1101
|
start.parentNode.insertBefore(textNode, end);
|
|
1102
1102
|
}
|
|
1103
|
-
|
|
1103
|
+
chunkKUXNZ5MG_cjs.internalEffect(() => {
|
|
1104
1104
|
textNode.data = String(child());
|
|
1105
1105
|
});
|
|
1106
1106
|
cursor = end.nextSibling;
|
|
@@ -1113,14 +1113,14 @@ function adoptNode(desc, ssrEl) {
|
|
|
1113
1113
|
} else if (cursor && cursor.nodeType === 3) {
|
|
1114
1114
|
const textNode = cursor;
|
|
1115
1115
|
cursor = cursor.nextSibling;
|
|
1116
|
-
|
|
1116
|
+
chunkKUXNZ5MG_cjs.internalEffect(() => {
|
|
1117
1117
|
textNode.data = String(child());
|
|
1118
1118
|
});
|
|
1119
1119
|
} else {
|
|
1120
|
-
if (
|
|
1120
|
+
if (chunkH7MDUHS5_cjs.__DEV__) console.warn(`[FormaJS] Hydration: created text node in empty <${ssrEl.tagName.toLowerCase()}> \u2014 IR may not cover this component`);
|
|
1121
1121
|
const textNode = document.createTextNode("");
|
|
1122
1122
|
ssrEl.appendChild(textNode);
|
|
1123
|
-
|
|
1123
|
+
chunkKUXNZ5MG_cjs.internalEffect(() => {
|
|
1124
1124
|
textNode.data = String(child());
|
|
1125
1125
|
});
|
|
1126
1126
|
}
|
|
@@ -1134,7 +1134,7 @@ function adoptNode(desc, ssrEl) {
|
|
|
1134
1134
|
function hydrateIsland(component, target) {
|
|
1135
1135
|
const hasSSRContent = target.childElementCount > 0 || target.childNodes.length > 0 && Array.from(target.childNodes).some((n) => n.nodeType === 1 || n.nodeType === 3 && n.data.trim());
|
|
1136
1136
|
if (!hasSSRContent) {
|
|
1137
|
-
if (
|
|
1137
|
+
if (chunkH7MDUHS5_cjs.__DEV__) {
|
|
1138
1138
|
const name = target.getAttribute("data-forma-component") || "unknown";
|
|
1139
1139
|
console.warn(
|
|
1140
1140
|
`[forma] Island "${name}" has no SSR content \u2014 falling back to CSR. This means the IR walker did not render content between ISLAND_START and ISLAND_END.`
|
|
@@ -1450,14 +1450,14 @@ function createList(items, keyFn, renderFn, options) {
|
|
|
1450
1450
|
let currentNodes = [];
|
|
1451
1451
|
let currentItems = [];
|
|
1452
1452
|
const updateOnItemChange = options?.updateOnItemChange ?? "none";
|
|
1453
|
-
|
|
1453
|
+
chunkKUXNZ5MG_cjs.internalEffect(() => {
|
|
1454
1454
|
const newItems = items();
|
|
1455
1455
|
const parent = startMarker.parentNode;
|
|
1456
1456
|
if (!parent) {
|
|
1457
1457
|
return;
|
|
1458
1458
|
}
|
|
1459
1459
|
if (!Array.isArray(newItems)) {
|
|
1460
|
-
if (
|
|
1460
|
+
if (chunkH7MDUHS5_cjs.__DEV__) {
|
|
1461
1461
|
console.warn("[forma] createList: value is not an array, treating as empty");
|
|
1462
1462
|
}
|
|
1463
1463
|
for (const node of currentNodes) {
|
|
@@ -1475,7 +1475,7 @@ function createList(items, keyFn, renderFn, options) {
|
|
|
1475
1475
|
break;
|
|
1476
1476
|
}
|
|
1477
1477
|
}
|
|
1478
|
-
if (
|
|
1478
|
+
if (chunkH7MDUHS5_cjs.__DEV__) {
|
|
1479
1479
|
const seen = /* @__PURE__ */ new Set();
|
|
1480
1480
|
for (const item of cleanItems) {
|
|
1481
1481
|
const key = keyFn(item);
|
|
@@ -1495,7 +1495,7 @@ function createList(items, keyFn, renderFn, options) {
|
|
|
1495
1495
|
if (node[ABORT_SYM3] || node[CACHE_SYM2] || node[DYNAMIC_CHILD_SYM2]) {
|
|
1496
1496
|
return;
|
|
1497
1497
|
}
|
|
1498
|
-
const next =
|
|
1498
|
+
const next = chunkKUXNZ5MG_cjs.untrack(() => renderFn(item, cached.getIndex));
|
|
1499
1499
|
if (canPatchStaticElement(node, next)) {
|
|
1500
1500
|
patchStaticElement(node, next);
|
|
1501
1501
|
cached.element = node;
|
|
@@ -1518,11 +1518,11 @@ function createList(items, keyFn, renderFn, options) {
|
|
|
1518
1518
|
// disposed when the item is removed from the list.
|
|
1519
1519
|
(item) => {
|
|
1520
1520
|
const key = keyFn(item);
|
|
1521
|
-
const [getIndex, setIndex] =
|
|
1521
|
+
const [getIndex, setIndex] = chunkH7MDUHS5_cjs.createSignal(0);
|
|
1522
1522
|
let itemDispose;
|
|
1523
|
-
const element =
|
|
1523
|
+
const element = chunkKUXNZ5MG_cjs.createRoot((dispose) => {
|
|
1524
1524
|
itemDispose = dispose;
|
|
1525
|
-
return
|
|
1525
|
+
return chunkKUXNZ5MG_cjs.untrack(() => renderFn(item, getIndex));
|
|
1526
1526
|
});
|
|
1527
1527
|
cache.set(key, { element, item, getIndex, setIndex, dispose: itemDispose });
|
|
1528
1528
|
return element;
|
|
@@ -1549,7 +1549,7 @@ function createList(items, keyFn, renderFn, options) {
|
|
|
1549
1549
|
currentNodes = result.nodes;
|
|
1550
1550
|
currentItems = result.items;
|
|
1551
1551
|
});
|
|
1552
|
-
|
|
1552
|
+
chunkKUXNZ5MG_cjs.registerDisposer(() => {
|
|
1553
1553
|
for (const cached of cache.values()) {
|
|
1554
1554
|
cached.dispose();
|
|
1555
1555
|
}
|
|
@@ -1568,5 +1568,5 @@ exports.fragment = fragment;
|
|
|
1568
1568
|
exports.h = h;
|
|
1569
1569
|
exports.hydrateIsland = hydrateIsland;
|
|
1570
1570
|
exports.reconcileList = reconcileList;
|
|
1571
|
-
//# sourceMappingURL=chunk-
|
|
1572
|
-
//# sourceMappingURL=chunk-
|
|
1571
|
+
//# sourceMappingURL=chunk-E3FV2VSU.cjs.map
|
|
1572
|
+
//# sourceMappingURL=chunk-E3FV2VSU.cjs.map
|