@reckona/mreact-compat 0.0.168 → 0.0.170
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/dom-children.d.ts.map +1 -1
- package/dist/dom-children.js +53 -0
- package/dist/dom-children.js.map +1 -1
- package/dist/element.d.ts +19 -4
- package/dist/element.d.ts.map +1 -1
- package/dist/element.js +56 -19
- package/dist/element.js.map +1 -1
- package/dist/hooks.js +18 -11
- package/dist/hooks.js.map +1 -1
- package/dist/host-reconciler.d.ts.map +1 -1
- package/dist/host-reconciler.js +263 -31
- package/dist/host-reconciler.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/jsx-dev-runtime.d.ts +1 -1
- package/dist/jsx-dev-runtime.d.ts.map +1 -1
- package/dist/jsx-dev-runtime.js.map +1 -1
- package/dist/jsx-runtime.d.ts +2 -2
- package/dist/jsx-runtime.d.ts.map +1 -1
- package/dist/jsx-runtime.js.map +1 -1
- package/package.json +3 -3
- package/src/dom-children.ts +78 -0
- package/src/element.ts +109 -23
- package/src/hooks.ts +24 -11
- package/src/host-reconciler.ts +430 -42
- package/src/index.ts +1 -0
- package/src/jsx-dev-runtime.ts +1 -1
- package/src/jsx-runtime.ts +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom-children.d.ts","sourceRoot":"","sources":["../src/dom-children.ts"],"names":[],"mappings":"AAIA,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,IAAI,EAAE,GAAG,IAAI,CAEnF;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,UAAU,EAClB,aAAa,EAAE,SAAS,IAAI,EAAE,EAC9B,SAAS,EAAE,SAAS,IAAI,EAAE,GACzB,IAAI,CAiBN;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,EAAE,CAQjE;AAED,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,SAAS,GAAG,IAAI,EACxB,KAAK,EAAE,SAAS,GAAG,IAAI,EACvB,SAAS,EAAE,SAAS,IAAI,EAAE,GACzB,IAAI,
|
|
1
|
+
{"version":3,"file":"dom-children.d.ts","sourceRoot":"","sources":["../src/dom-children.ts"],"names":[],"mappings":"AAIA,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,IAAI,EAAE,GAAG,IAAI,CAEnF;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,UAAU,EAClB,aAAa,EAAE,SAAS,IAAI,EAAE,EAC9B,SAAS,EAAE,SAAS,IAAI,EAAE,GACzB,IAAI,CAiBN;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,EAAE,CAQjE;AAED,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,SAAS,GAAG,IAAI,EACxB,KAAK,EAAE,SAAS,GAAG,IAAI,EACvB,SAAS,EAAE,SAAS,IAAI,EAAE,GACzB,IAAI,CAqDN;AA8JD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,GAAG,IAAI,CAc1E"}
|
package/dist/dom-children.js
CHANGED
|
@@ -25,6 +25,9 @@ export function collectOwnedChildNodes(parent) {
|
|
|
25
25
|
return Array.from(parent.childNodes).filter((node) => ownedChildParentByNode.get(node) === parent);
|
|
26
26
|
}
|
|
27
27
|
export function syncScopedChildNodes(parent, before, after, nextNodes) {
|
|
28
|
+
if (replaceEmptyFullChildList(parent, before, after, nextNodes)) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
28
31
|
if (replaceDisjointFullChildList(parent, before, after, nextNodes)) {
|
|
29
32
|
return;
|
|
30
33
|
}
|
|
@@ -33,6 +36,9 @@ export function syncScopedChildNodes(parent, before, after, nextNodes) {
|
|
|
33
36
|
removeSingleMissingChild(parent, before, after, nextNodes)) {
|
|
34
37
|
return;
|
|
35
38
|
}
|
|
39
|
+
if (nextNodes.length > 16 && moveSingleSwappedPair(parent, before, after, nextNodes)) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
36
42
|
let cursor = parent.firstChild;
|
|
37
43
|
if (before !== null) {
|
|
38
44
|
cursor = before.nextSibling;
|
|
@@ -58,6 +64,16 @@ export function syncScopedChildNodes(parent, before, after, nextNodes) {
|
|
|
58
64
|
}
|
|
59
65
|
}
|
|
60
66
|
}
|
|
67
|
+
function replaceEmptyFullChildList(parent, before, after, nextNodes) {
|
|
68
|
+
if (before !== null ||
|
|
69
|
+
after !== null ||
|
|
70
|
+
nextNodes.length <= 16 ||
|
|
71
|
+
parent.childNodes.length !== 0) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
parent.replaceChildren(...nextNodes);
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
61
77
|
function replaceDisjointFullChildList(parent, before, after, nextNodes) {
|
|
62
78
|
if (before !== null || after !== null || nextNodes.length <= 16) {
|
|
63
79
|
return false;
|
|
@@ -112,6 +128,43 @@ function removeSingleMissingChild(parent, before, after, nextNodes) {
|
|
|
112
128
|
removeChildIfPresent(parent, cursor);
|
|
113
129
|
return true;
|
|
114
130
|
}
|
|
131
|
+
function moveSingleSwappedPair(parent, before, after, nextNodes) {
|
|
132
|
+
let cursor = before === null ? parent.firstChild : before.nextSibling;
|
|
133
|
+
let index = 0;
|
|
134
|
+
let firstMismatchIndex = -1;
|
|
135
|
+
let secondMismatchIndex = -1;
|
|
136
|
+
let firstCurrent = null;
|
|
137
|
+
let secondCurrent = null;
|
|
138
|
+
while (cursor !== null && cursor !== after && index < nextNodes.length) {
|
|
139
|
+
const current = cursor;
|
|
140
|
+
if (current !== nextNodes[index]) {
|
|
141
|
+
if (firstMismatchIndex === -1) {
|
|
142
|
+
firstMismatchIndex = index;
|
|
143
|
+
firstCurrent = current;
|
|
144
|
+
}
|
|
145
|
+
else if (secondMismatchIndex === -1) {
|
|
146
|
+
secondMismatchIndex = index;
|
|
147
|
+
secondCurrent = current;
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
cursor = current.nextSibling;
|
|
154
|
+
index += 1;
|
|
155
|
+
}
|
|
156
|
+
if (index !== nextNodes.length ||
|
|
157
|
+
cursor !== after ||
|
|
158
|
+
firstCurrent === null ||
|
|
159
|
+
secondCurrent === null ||
|
|
160
|
+
firstCurrent !== nextNodes[secondMismatchIndex] ||
|
|
161
|
+
secondCurrent !== nextNodes[firstMismatchIndex]) {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
parent.insertBefore(secondCurrent, firstCurrent);
|
|
165
|
+
parent.insertBefore(firstCurrent, nextNodes[secondMismatchIndex + 1] ?? after);
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
115
168
|
export function removeChildIfPresent(parent, child) {
|
|
116
169
|
if (child.parentNode !== parent) {
|
|
117
170
|
return;
|
package/dist/dom-children.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom-children.js","sourceRoot":"","sources":["../src/dom-children.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,MAAM,sBAAsB,GAAG,IAAI,OAAO,EAAoB,CAAC;AAE/D,MAAM,UAAU,cAAc,CAAC,MAAkB,EAAE,SAA0B;IAC3E,oBAAoB,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,MAAkB,EAClB,aAA8B,EAC9B,SAA0B;IAE1B,MAAM,kBAAkB,GACtB,aAAa,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,aAAa,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AC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,CAAC,UAAU,KAAK,MAAM,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1D,OAAO;QACT,CAAC;QAED,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED,SAAS,eAAe,CAAC,KAAc;IACrC,MAAM,UAAU,GAAG,KAA8C,CAAC;IAElE,OAAO,CACL,UAAU,CAAC,IAAI,KAAK,eAAe;QACnC,CAAC,OAAO,UAAU,CAAC,OAAO,KAAK,QAAQ,IAAI,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CACvF,CAAC;AACJ,CAAC","sourcesContent":["import { collectScopedNodes } from \"./hydration.js\";\n\nconst ownedChildParentByNode = new WeakMap<Node, ParentNode>();\n\nexport function syncChildNodes(parent: ParentNode, nextNodes: readonly Node[]): void {\n syncScopedChildNodes(parent, null, null, nextNodes);\n}\n\nexport function syncOwnedChildNodes(\n parent: ParentNode,\n previousNodes: readonly Node[],\n nextNodes: readonly Node[],\n): void {\n const ownedPreviousNodes =\n previousNodes.length === 0 ? collectOwnedChildNodes(parent) : previousNodes;\n const nextSet = new Set(nextNodes);\n\n for (const node of nextNodes) {\n ownedChildParentByNode.set(node, parent);\n if (node.parentNode !== parent || node.nextSibling !== null) {\n parent.appendChild(node);\n }\n }\n\n for (const child of ownedPreviousNodes) {\n if (!nextSet.has(child)) {\n removeChildIfPresent(parent, child);\n }\n }\n}\n\nexport function collectOwnedChildNodes(parent: ParentNode): Node[] {\n if (!(\"childNodes\" in parent)) {\n return [];\n }\n\n return Array.from(parent.childNodes).filter(\n (node) => ownedChildParentByNode.get(node) === parent,\n );\n}\n\nexport function syncScopedChildNodes(\n parent: ParentNode,\n before: ChildNode | null,\n after: ChildNode | null,\n nextNodes: readonly Node[],\n): void {\n if (replaceDisjointFullChildList(parent, before, after, nextNodes)) {\n return;\n }\n\n if (\n nextNodes.length > 16 &&\n hasSingleExtraScopedChild(parent, before, after, nextNodes.length) &&\n removeSingleMissingChild(parent, before, after, nextNodes)\n ) {\n return;\n }\n\n let cursor = parent.firstChild;\n\n if (before !== null) {\n cursor = before.nextSibling;\n }\n\n let changed = false;\n\n for (const node of nextNodes) {\n if (node !== cursor) {\n parent.insertBefore(node, cursor === after ? after : cursor);\n changed = true;\n }\n\n cursor = node.nextSibling;\n }\n\n if (!changed && cursor === after) {\n return;\n }\n\n if (!changed && after === null && cursor === null) {\n return;\n }\n\n const nextSet = new Set(nextNodes);\n\n for (const child of collectScopedNodes(parent, before, after)) {\n if (!nextSet.has(child)) {\n removeChildIfPresent(parent, child);\n }\n }\n}\n\nfunction replaceDisjointFullChildList(\n parent: ParentNode,\n before: ChildNode | null,\n after: ChildNode | null,\n nextNodes: readonly Node[],\n): boolean {\n if (before !== null || after !== null || nextNodes.length <= 16) {\n return false;\n }\n\n const currentNodes = parent.childNodes;\n\n if (currentNodes.length <= 16 || currentNodes.length !== nextNodes.length) {\n return false;\n }\n\n const nextSet = new Set(nextNodes);\n\n for (let index = 0; index < currentNodes.length; index += 1) {\n if (nextSet.has(currentNodes[index]!)) {\n return false;\n }\n }\n\n parent.replaceChildren(...nextNodes);\n return true;\n}\n\nfunction hasSingleExtraScopedChild(\n parent: ParentNode,\n before: ChildNode | null,\n after: ChildNode | null,\n nextCount: number,\n): boolean {\n if (before === null && after === null) {\n return parent.childNodes.length === nextCount + 1;\n }\n\n let cursor = before === null ? parent.firstChild : before.nextSibling;\n let currentCount = 0;\n\n while (cursor !== null && cursor !== after && currentCount <= nextCount + 1) {\n currentCount += 1;\n cursor = cursor.nextSibling;\n }\n\n return currentCount === nextCount + 1 && (cursor === null || cursor === after);\n}\n\nfunction removeSingleMissingChild(\n parent: ParentNode,\n before: ChildNode | null,\n after: ChildNode | null,\n nextNodes: readonly Node[],\n): boolean {\n let cursor = before === null ? parent.firstChild : before.nextSibling;\n let removed = false;\n\n for (const nextNode of nextNodes) {\n if (cursor === nextNode) {\n cursor = cursor.nextSibling;\n continue;\n }\n\n if (removed || cursor === null || cursor === after || cursor.nextSibling !== nextNode) {\n return false;\n }\n\n const missing = cursor;\n cursor = nextNode.nextSibling;\n removeChildIfPresent(parent, missing);\n removed = true;\n }\n\n if (cursor === after || cursor === null) {\n return removed;\n }\n\n if (removed || cursor.nextSibling !== after) {\n return false;\n }\n\n removeChildIfPresent(parent, cursor);\n return true;\n}\n\nexport function removeChildIfPresent(parent: ParentNode, child: Node): void {\n if (child.parentNode !== parent) {\n return;\n }\n\n try {\n parent.removeChild(child);\n } catch (error) {\n if (child.parentNode !== parent && isNotFoundError(error)) {\n return;\n }\n\n throw error;\n }\n}\n\nfunction isNotFoundError(error: unknown): boolean {\n const maybeError = error as { message?: unknown; name?: unknown };\n\n return (\n maybeError.name === \"NotFoundError\" ||\n (typeof maybeError.message === \"string\" && maybeError.message.includes(\"not a child\"))\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dom-children.js","sourceRoot":"","sources":["../src/dom-children.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,MAAM,sBAAsB,GAAG,IAAI,OAAO,EAAoB,CAAC;AAE/D,MAAM,UAAU,cAAc,CAAC,MAAkB,EAAE,SAA0B;IAC3E,oBAAoB,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,MAAkB,EAClB,aAA8B,EAC9B,SAA0B;IAE1B,MAAM,kBAAkB,GACtB,aAAa,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC;IAC9E,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC;IAEnC,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE,CAAC;QAC7B,sBAAsB,CAAC,GAAG,CAAC,IAAI,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;IAED,IACE,KAAK,KAAK,SAAS,CAAC,MAAM;QAC1B,MAAM,KAAK,KAAK;QAChB,YAAY,KAAK,IAAI;QACrB,aAAa,KAAK,IAAI;QACtB,YAAY,KAAK,SAAS,CAAC,mBAAmB,CAAC;QAC/C,aAAa,KAAK,SAAS,CAAC,kBAAkB,CAAC,EAC/C,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,CAAC,YAAY,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;IACjD,MAAM,CAAC,YAAY,CACjB,YAAY,EACX,SAAS,CAAC,mBAAmB,GAAG,CAAC,CAA2B,IAAI,KAAK,CACvE,CAAC;IACF,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,MAAkB,EAAE,KAAW;IAClE,IAAI,KAAK,CAAC,UAAU,KAAK,MAAM,EAAE,CAAC;QAChC,OAAO;IACT,CAAC;IAED,IAAI,CAAC;QACH,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,CAAC,UAAU,KAAK,MAAM,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1D,OAAO;QACT,CAAC;QAED,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED,SAAS,eAAe,CAAC,KAAc;IACrC,MAAM,UAAU,GAAG,KAA8C,CAAC;IAElE,OAAO,CACL,UAAU,CAAC,IAAI,KAAK,eAAe;QACnC,CAAC,OAAO,UAAU,CAAC,OAAO,KAAK,QAAQ,IAAI,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CACvF,CAAC;AACJ,CAAC","sourcesContent":["import { collectScopedNodes } from \"./hydration.js\";\n\nconst ownedChildParentByNode = new WeakMap<Node, ParentNode>();\n\nexport function syncChildNodes(parent: ParentNode, nextNodes: readonly Node[]): void {\n syncScopedChildNodes(parent, null, null, nextNodes);\n}\n\nexport function syncOwnedChildNodes(\n parent: ParentNode,\n previousNodes: readonly Node[],\n nextNodes: readonly Node[],\n): void {\n const ownedPreviousNodes =\n previousNodes.length === 0 ? collectOwnedChildNodes(parent) : previousNodes;\n const nextSet = new Set(nextNodes);\n\n for (const node of nextNodes) {\n ownedChildParentByNode.set(node, parent);\n if (node.parentNode !== parent || node.nextSibling !== null) {\n parent.appendChild(node);\n }\n }\n\n for (const child of ownedPreviousNodes) {\n if (!nextSet.has(child)) {\n removeChildIfPresent(parent, child);\n }\n }\n}\n\nexport function collectOwnedChildNodes(parent: ParentNode): Node[] {\n if (!(\"childNodes\" in parent)) {\n return [];\n }\n\n return Array.from(parent.childNodes).filter(\n (node) => ownedChildParentByNode.get(node) === parent,\n );\n}\n\nexport function syncScopedChildNodes(\n parent: ParentNode,\n before: ChildNode | null,\n after: ChildNode | null,\n nextNodes: readonly Node[],\n): void {\n if (replaceEmptyFullChildList(parent, before, after, nextNodes)) {\n return;\n }\n\n if (replaceDisjointFullChildList(parent, before, after, nextNodes)) {\n return;\n }\n\n if (\n nextNodes.length > 16 &&\n hasSingleExtraScopedChild(parent, before, after, nextNodes.length) &&\n removeSingleMissingChild(parent, before, after, nextNodes)\n ) {\n return;\n }\n\n if (nextNodes.length > 16 && moveSingleSwappedPair(parent, before, after, nextNodes)) {\n return;\n }\n\n let cursor = parent.firstChild;\n\n if (before !== null) {\n cursor = before.nextSibling;\n }\n\n let changed = false;\n\n for (const node of nextNodes) {\n if (node !== cursor) {\n parent.insertBefore(node, cursor === after ? after : cursor);\n changed = true;\n }\n\n cursor = node.nextSibling;\n }\n\n if (!changed && cursor === after) {\n return;\n }\n\n if (!changed && after === null && cursor === null) {\n return;\n }\n\n const nextSet = new Set(nextNodes);\n\n for (const child of collectScopedNodes(parent, before, after)) {\n if (!nextSet.has(child)) {\n removeChildIfPresent(parent, child);\n }\n }\n}\n\nfunction replaceEmptyFullChildList(\n parent: ParentNode,\n before: ChildNode | null,\n after: ChildNode | null,\n nextNodes: readonly Node[],\n): boolean {\n if (\n before !== null ||\n after !== null ||\n nextNodes.length <= 16 ||\n parent.childNodes.length !== 0\n ) {\n return false;\n }\n\n parent.replaceChildren(...nextNodes);\n return true;\n}\n\nfunction replaceDisjointFullChildList(\n parent: ParentNode,\n before: ChildNode | null,\n after: ChildNode | null,\n nextNodes: readonly Node[],\n): boolean {\n if (before !== null || after !== null || nextNodes.length <= 16) {\n return false;\n }\n\n const currentNodes = parent.childNodes;\n\n if (currentNodes.length <= 16 || currentNodes.length !== nextNodes.length) {\n return false;\n }\n\n const nextSet = new Set(nextNodes);\n\n for (let index = 0; index < currentNodes.length; index += 1) {\n if (nextSet.has(currentNodes[index]!)) {\n return false;\n }\n }\n\n parent.replaceChildren(...nextNodes);\n return true;\n}\n\nfunction hasSingleExtraScopedChild(\n parent: ParentNode,\n before: ChildNode | null,\n after: ChildNode | null,\n nextCount: number,\n): boolean {\n if (before === null && after === null) {\n return parent.childNodes.length === nextCount + 1;\n }\n\n let cursor = before === null ? parent.firstChild : before.nextSibling;\n let currentCount = 0;\n\n while (cursor !== null && cursor !== after && currentCount <= nextCount + 1) {\n currentCount += 1;\n cursor = cursor.nextSibling;\n }\n\n return currentCount === nextCount + 1 && (cursor === null || cursor === after);\n}\n\nfunction removeSingleMissingChild(\n parent: ParentNode,\n before: ChildNode | null,\n after: ChildNode | null,\n nextNodes: readonly Node[],\n): boolean {\n let cursor = before === null ? parent.firstChild : before.nextSibling;\n let removed = false;\n\n for (const nextNode of nextNodes) {\n if (cursor === nextNode) {\n cursor = cursor.nextSibling;\n continue;\n }\n\n if (removed || cursor === null || cursor === after || cursor.nextSibling !== nextNode) {\n return false;\n }\n\n const missing = cursor;\n cursor = nextNode.nextSibling;\n removeChildIfPresent(parent, missing);\n removed = true;\n }\n\n if (cursor === after || cursor === null) {\n return removed;\n }\n\n if (removed || cursor.nextSibling !== after) {\n return false;\n }\n\n removeChildIfPresent(parent, cursor);\n return true;\n}\n\nfunction moveSingleSwappedPair(\n parent: ParentNode,\n before: ChildNode | null,\n after: ChildNode | null,\n nextNodes: readonly Node[],\n): boolean {\n let cursor = before === null ? parent.firstChild : before.nextSibling;\n let index = 0;\n let firstMismatchIndex = -1;\n let secondMismatchIndex = -1;\n let firstCurrent: ChildNode | null = null;\n let secondCurrent: ChildNode | null = null;\n\n while (cursor !== null && cursor !== after && index < nextNodes.length) {\n const current = cursor;\n\n if (current !== nextNodes[index]) {\n if (firstMismatchIndex === -1) {\n firstMismatchIndex = index;\n firstCurrent = current;\n } else if (secondMismatchIndex === -1) {\n secondMismatchIndex = index;\n secondCurrent = current;\n } else {\n return false;\n }\n }\n\n cursor = current.nextSibling;\n index += 1;\n }\n\n if (\n index !== nextNodes.length ||\n cursor !== after ||\n firstCurrent === null ||\n secondCurrent === null ||\n firstCurrent !== nextNodes[secondMismatchIndex] ||\n secondCurrent !== nextNodes[firstMismatchIndex]\n ) {\n return false;\n }\n\n parent.insertBefore(secondCurrent, firstCurrent);\n parent.insertBefore(\n firstCurrent,\n (nextNodes[secondMismatchIndex + 1] as ChildNode | undefined) ?? after,\n );\n return true;\n}\n\nexport function removeChildIfPresent(parent: ParentNode, child: Node): void {\n if (child.parentNode !== parent) {\n return;\n }\n\n try {\n parent.removeChild(child);\n } catch (error) {\n if (child.parentNode !== parent && isNotFoundError(error)) {\n return;\n }\n\n throw error;\n }\n}\n\nfunction isNotFoundError(error: unknown): boolean {\n const maybeError = error as { message?: unknown; name?: unknown };\n\n return (\n maybeError.name === \"NotFoundError\" ||\n (typeof maybeError.message === \"string\" && maybeError.message.includes(\"not a child\"))\n );\n}\n"]}
|
package/dist/element.d.ts
CHANGED
|
@@ -30,8 +30,23 @@ export interface ReactCompatContextProviderShorthand {
|
|
|
30
30
|
export type ElementType<P = Record<string, unknown>> = string | typeof Fragment | typeof Suspense | typeof SuspenseList | typeof Activity | typeof Profiler | typeof ERROR_BOUNDARY_TYPE | typeof STRICT_MODE_TYPE | ReactCompatContextProviderShorthand | ReactCompatProviderType | ForwardRefType<P> | MemoType<P> | LazyType<P> | ((props: P) => ReactCompatNode | PromiseLike<ReactCompatNode>) | (new (props: P) => {
|
|
31
31
|
render(): ReactCompatNode;
|
|
32
32
|
});
|
|
33
|
+
/** Element-shaped renderable value accepted regardless of its original prop shape. */
|
|
34
|
+
export interface ReactCompatRenderableElement {
|
|
35
|
+
/** React-compatible element marker. */
|
|
36
|
+
$$typeof: typeof REACT_COMPAT_ELEMENT_TYPE;
|
|
37
|
+
/** Host tag, component, or special element type. */
|
|
38
|
+
type: unknown;
|
|
39
|
+
/** Normalized React key. */
|
|
40
|
+
key: string | null;
|
|
41
|
+
/** Normalized React ref. */
|
|
42
|
+
ref: unknown;
|
|
43
|
+
/** Element props with children widened to the renderable node surface. */
|
|
44
|
+
props: {
|
|
45
|
+
children?: ReactCompatNode;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
33
48
|
/** Renderable value accepted by the React-compatible renderer. */
|
|
34
|
-
export type ReactCompatNode =
|
|
49
|
+
export type ReactCompatNode = ReactCompatRenderableElement | ReactCompatPortal | string | number | boolean | null | undefined | ReactCompatNode[];
|
|
35
50
|
/** React-compatible element record produced by createElement and JSX transforms. */
|
|
36
51
|
export interface ReactCompatElement<P = Record<string, unknown>> {
|
|
37
52
|
$$typeof: typeof REACT_COMPAT_ELEMENT_TYPE;
|
|
@@ -50,9 +65,9 @@ export interface ReactCompatPortal {
|
|
|
50
65
|
key: string | null;
|
|
51
66
|
}
|
|
52
67
|
/** Creates a React-compatible element from a type, config object, and children. */
|
|
53
|
-
export declare function createElement<P extends
|
|
68
|
+
export declare function createElement<P extends object>(type: ElementType<P>, config: (P & ReactReservedProps) | null, ...children: ReactCompatNode[]): ReactCompatElement<P>;
|
|
54
69
|
/** Creates a React-compatible element from JSX runtime arguments. */
|
|
55
|
-
export declare function createElementFromJsxConfig<P extends
|
|
70
|
+
export declare function createElementFromJsxConfig<P extends object>(type: ElementType<P>, config: (P & ReactReservedProps & {
|
|
56
71
|
children?: ReactCompatNode;
|
|
57
72
|
}) | null, keyArgument?: unknown): ReactCompatElement<P>;
|
|
58
73
|
/** Returns true when a value is a React-compatible element record. */
|
|
@@ -102,7 +117,7 @@ export declare function lazy<P>(load: () => Promise<{
|
|
|
102
117
|
/** Symbol used to mark a subtree for strict-mode development checks. */
|
|
103
118
|
export declare const StrictMode: symbol;
|
|
104
119
|
/** Clones an existing element with merged props and optional replacement children. */
|
|
105
|
-
export declare function cloneElement<P extends
|
|
120
|
+
export declare function cloneElement<P extends object>(element: ReactCompatElement<P>, props: (Partial<P> & ReactReservedProps) | null, ...children: ReactCompatNode[]): ReactCompatElement<P>;
|
|
106
121
|
interface ReactReservedProps {
|
|
107
122
|
key?: unknown;
|
|
108
123
|
ref?: unknown;
|
package/dist/element.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../src/element.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,yBAAyB,eAA2C,CAAC;AAClF,eAAO,MAAM,mBAAmB,eAA6C,CAAC;AAC9E,eAAO,MAAM,gBAAgB,eAAkC,CAAC;AAChE,eAAO,MAAM,SAAS,eAA2B,CAAC;AAClD,eAAO,MAAM,SAAS,eAA2B,CAAC;AAClD,eAAO,MAAM,gBAAgB,eAAkC,CAAC;AAChE,eAAO,MAAM,WAAW,eAA6B,CAAC;AAEtD,uEAAuE;AACvE,eAAO,MAAM,QAAQ,eAA+B,CAAC;AACrD,qEAAqE;AACrE,eAAO,MAAM,QAAQ,eAA+B,CAAC;AACrD,8DAA8D;AAC9D,eAAO,MAAM,YAAY,eAAoC,CAAC;AAC9D,yEAAyE;AACzE,eAAO,MAAM,QAAQ,eAA+B,CAAC;AACrD,kEAAkE;AAClE,eAAO,MAAM,QAAQ,eAA+B,CAAC;AACrD,eAAO,MAAM,6BAA6B,eAEzC,CAAC;AACF,wEAAwE;AACxE,eAAO,MAAM,0BAA0B,eAEtC,CAAC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ROPS_META = Symbol.for("modular.react.host_chil
|
|
|
20
20
|
/** Metadata key that links a state value to a reactive text binding. */
|
|
21
21
|
export const REACTIVE_TEXT_BINDING_META = Symbol.for("modular.react.reactive_text_binding_meta");
|
|
22
22
|
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
export function createElement(type, config) {
|
|
24
|
+
const childCount = arguments.length - 2;
|
|
25
25
|
if (typeof type === "string") {
|
|
26
26
|
const key = config?.key === undefined ? null : String(config.key);
|
|
27
27
|
const ref = config?.ref ?? null;
|
|
28
|
-
const props =
|
|
29
|
-
|
|
30
|
-
props.children = children[0];
|
|
31
|
-
}
|
|
32
|
-
else if (children.length > 1) {
|
|
33
|
-
props.children = children;
|
|
34
|
-
}
|
|
28
|
+
const props = copyCreateElementProps(config);
|
|
29
|
+
assignCreateElementChildren(props, childCount, arguments);
|
|
35
30
|
setHostOwnPropsMeta(props);
|
|
36
31
|
return {
|
|
37
32
|
$$typeof: REACT_COMPAT_ELEMENT_TYPE,
|
|
@@ -44,13 +39,8 @@ export function createElement(type, config, ...children) {
|
|
|
44
39
|
const normalizedType = typeof type === "object" && type !== null ? normalizeElementType(type) : type;
|
|
45
40
|
const key = config?.key === undefined ? null : String(config.key);
|
|
46
41
|
const ref = config?.ref ?? null;
|
|
47
|
-
const props = applyDefaultProps(normalizedType,
|
|
48
|
-
|
|
49
|
-
props.children = children[0];
|
|
50
|
-
}
|
|
51
|
-
else if (children.length > 1) {
|
|
52
|
-
props.children = children;
|
|
53
|
-
}
|
|
42
|
+
const props = applyDefaultProps(normalizedType, copyCreateElementProps(config));
|
|
43
|
+
assignCreateElementChildren(props, childCount, arguments);
|
|
54
44
|
if (typeof normalizedType === "string") {
|
|
55
45
|
setHostOwnPropsMeta(props);
|
|
56
46
|
}
|
|
@@ -62,6 +52,21 @@ export function createElement(type, config, ...children) {
|
|
|
62
52
|
props: props,
|
|
63
53
|
};
|
|
64
54
|
}
|
|
55
|
+
function assignCreateElementChildren(props, childCount, args) {
|
|
56
|
+
if (childCount === 1) {
|
|
57
|
+
props.children = args[2];
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (childCount <= 1) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const children = [];
|
|
64
|
+
children.length = childCount;
|
|
65
|
+
for (let index = 0; index < childCount; index += 1) {
|
|
66
|
+
children[index] = args[index + 2];
|
|
67
|
+
}
|
|
68
|
+
props.children = children;
|
|
69
|
+
}
|
|
65
70
|
/** Creates a React-compatible element from JSX runtime arguments. */
|
|
66
71
|
export function createElementFromJsxConfig(type, config, keyArgument) {
|
|
67
72
|
const normalizedType = typeof type === "object" && type !== null ? normalizeElementType(type) : type;
|
|
@@ -153,7 +158,7 @@ export function cloneElement(element, props, ...children) {
|
|
|
153
158
|
props: nextProps,
|
|
154
159
|
};
|
|
155
160
|
}
|
|
156
|
-
function copyElementProps(source, base, omitChildren = false) {
|
|
161
|
+
function copyElementProps(source, base, omitChildren = false, copySymbols = true) {
|
|
157
162
|
const props = {};
|
|
158
163
|
if (base !== undefined) {
|
|
159
164
|
copyOwnStringElementProps(base, props, omitChildren);
|
|
@@ -162,10 +167,36 @@ function copyElementProps(source, base, omitChildren = false) {
|
|
|
162
167
|
return props;
|
|
163
168
|
}
|
|
164
169
|
copyOwnStringElementProps(source, props, omitChildren);
|
|
165
|
-
|
|
170
|
+
if (copySymbols === "internal") {
|
|
171
|
+
copyInternalElementSymbolProps(source, props);
|
|
172
|
+
}
|
|
173
|
+
else if (copySymbols) {
|
|
174
|
+
copyOwnSymbolElementProps(source, props);
|
|
175
|
+
}
|
|
176
|
+
return props;
|
|
177
|
+
}
|
|
178
|
+
function copyCreateElementProps(source) {
|
|
179
|
+
const props = {};
|
|
180
|
+
if (source === null || source === undefined) {
|
|
181
|
+
return props;
|
|
182
|
+
}
|
|
183
|
+
const stringSource = source;
|
|
184
|
+
for (const name in source) {
|
|
185
|
+
if (!hasOwnProperty.call(source, name)) {
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
if (name !== "key" &&
|
|
189
|
+
name !== "ref" &&
|
|
190
|
+
name !== "__self" &&
|
|
191
|
+
name !== "__source") {
|
|
192
|
+
props[name] = stringSource[name];
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
copyInternalElementSymbolProps(source, props);
|
|
166
196
|
return props;
|
|
167
197
|
}
|
|
168
198
|
function copyOwnStringElementProps(source, target, omitChildren) {
|
|
199
|
+
const stringSource = source;
|
|
169
200
|
for (const name in source) {
|
|
170
201
|
if (!hasOwnProperty.call(source, name)) {
|
|
171
202
|
continue;
|
|
@@ -175,7 +206,7 @@ function copyOwnStringElementProps(source, target, omitChildren) {
|
|
|
175
206
|
name !== "__self" &&
|
|
176
207
|
name !== "__source" &&
|
|
177
208
|
(!omitChildren || name !== "children")) {
|
|
178
|
-
target[name] =
|
|
209
|
+
target[name] = stringSource[name];
|
|
179
210
|
}
|
|
180
211
|
}
|
|
181
212
|
}
|
|
@@ -185,6 +216,12 @@ function copyOwnSymbolElementProps(source, target) {
|
|
|
185
216
|
target[symbol] = symbolSource[symbol];
|
|
186
217
|
}
|
|
187
218
|
}
|
|
219
|
+
function copyInternalElementSymbolProps(source, target) {
|
|
220
|
+
const symbolSource = source;
|
|
221
|
+
if (hasOwnProperty.call(source, REACTIVE_TEXT_BINDING_META)) {
|
|
222
|
+
target[REACTIVE_TEXT_BINDING_META] = symbolSource[REACTIVE_TEXT_BINDING_META];
|
|
223
|
+
}
|
|
224
|
+
}
|
|
188
225
|
function normalizeElementType(type) {
|
|
189
226
|
return isReactCompatContextProviderShorthand(type) ? type.Provider : type;
|
|
190
227
|
}
|
package/dist/element.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element.js","sourceRoot":"","sources":["../src/element.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC,GAAG,CAAC,4BAA4B,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AE,CAAC;YAChD,OAAO,CAAC,CAAC;QACX,CAAC;QAED,OAAO,eAAe,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC;IAC1C,CAAC;IACD,OAAO,CAAC,QAAyB;QAC/B,OAAO,YAAY,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;IACD,IAAI,CAAC,QAAyB;QAC5B,MAAM,KAAK,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;QAErC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACjD,CAAC;QAED,OAAO,KAAK,CAAC,CAAC,CAAyD,CAAC;IAC1E,CAAC;CACF,CAAC;AAEF,SAAS,YAAY,CACnB,QAAyB;IAEzB,OAAO,eAAe,CAAC,QAAQ,CAAC,CAAC,MAAM,CACrC,CAAC,KAAK,EAAiE,EAAE,CACvE,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,KAAK,SAAS,CACtE,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,CAAC,QAAyB;IAChD,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7D,CAAC;IAED,OAAO,CAAC,QAAQ,CAAC,CAAC;AACpB,CAAC;AAQD,kEAAkE;AAClE,MAAM,UAAU,mBAAmB,CACjC,OAA6B,EAC7B,QAAyB;IAEzB,OAAO,aAAa,CAAC,mBAAmB,EAAE;QACxC,GAAG,OAAO;QACV,QAAQ;KACT,CAAC,CAAC;AACL,CAAC","sourcesContent":["export const REACT_COMPAT_ELEMENT_TYPE = Symbol.for(\"react.transitional.element\");\nexport const ERROR_BOUNDARY_TYPE = Symbol.for(\"modular.react.error_boundary\");\nexport const FORWARD_REF_TYPE = Symbol.for(\"react.forward_ref\");\nexport const MEMO_TYPE = Symbol.for(\"react.memo\");\nexport const LAZY_TYPE = Symbol.for(\"react.lazy\");\nexport const STRICT_MODE_TYPE = Symbol.for(\"react.strict_mode\");\nexport const PORTAL_TYPE = Symbol.for(\"react.portal\");\nconst REACT_COMPAT_PROVIDER_TYPE = Symbol.for(\"react.context\");\n/** Symbol used to group JSX children without adding a host element. */\nexport const Fragment = Symbol.for(\"react.fragment\");\n/** Symbol used to suspend rendering while async content resolves. */\nexport const Suspense = Symbol.for(\"react.suspense\");\n/** Symbol used to coordinate multiple suspense boundaries. */\nexport const SuspenseList = Symbol.for(\"react.suspense_list\");\n/** Symbol used to mark activity boundaries in React-compatible trees. */\nexport const Activity = Symbol.for(\"react.activity\");\n/** Symbol used to measure render work with profiler callbacks. */\nexport const Profiler = Symbol.for(\"react.profiler\");\nexport const HOST_CHILDREN_ONLY_PROPS_META = Symbol.for(\n \"modular.react.host_children_only_props_meta\",\n);\n/** Metadata key that links a state value to a reactive text binding. */\nexport const REACTIVE_TEXT_BINDING_META = Symbol.for(\n \"modular.react.reactive_text_binding_meta\",\n);\nconst hasOwnProperty = Object.prototype.hasOwnProperty;\n\nexport interface ReactCompatProviderType {\n $$typeof: symbol;\n context: unknown;\n}\n\nexport interface ReactCompatContextProviderShorthand {\n Provider: ReactCompatProviderType;\n Consumer: unknown;\n}\n\n/** Element type accepted by createElement, JSX, and renderer entrypoints. */\nexport type ElementType<P = Record<string, unknown>> =\n | string\n | typeof Fragment\n | typeof Suspense\n | typeof SuspenseList\n | typeof Activity\n | typeof Profiler\n | typeof ERROR_BOUNDARY_TYPE\n | typeof STRICT_MODE_TYPE\n | ReactCompatContextProviderShorthand\n | ReactCompatProviderType\n | ForwardRefType<P>\n | MemoType<P>\n | LazyType<P>\n | ((props: P) => ReactCompatNode | PromiseLike<ReactCompatNode>)\n | (new (props: P) => { render(): ReactCompatNode });\n\n/** Renderable value accepted by the React-compatible renderer. */\nexport type ReactCompatNode =\n | ReactCompatElement\n | ReactCompatPortal\n | string\n | number\n | boolean\n | null\n | undefined\n | ReactCompatNode[];\n\n/** React-compatible element record produced by createElement and JSX transforms. */\nexport interface ReactCompatElement<P = Record<string, unknown>> {\n $$typeof: typeof REACT_COMPAT_ELEMENT_TYPE;\n type: ElementType<P>;\n key: string | null;\n ref: unknown;\n props: P & { children?: ReactCompatNode };\n}\n\n/** Portal record that renders children into an external DOM container. */\nexport interface ReactCompatPortal {\n $$typeof: typeof PORTAL_TYPE;\n container: Element;\n children: ReactCompatNode;\n key: string | null;\n}\n\n/** Creates a React-compatible element from a type, config object, and children. */\nexport function createElement<P extends Record<string, unknown>>(\n type: ElementType<P>,\n config: (P & ReactReservedProps) | null,\n ...children: ReactCompatNode[]\n): ReactCompatElement<P> {\n if (typeof type === \"string\") {\n const key = config?.key === undefined ? null : String(config.key);\n const ref = config?.ref ?? null;\n const props = copyElementProps(config) as P & { children?: ReactCompatNode };\n\n if (children.length === 1) {\n props.children = children[0];\n } else if (children.length > 1) {\n props.children = children;\n }\n\n setHostOwnPropsMeta(props);\n\n return {\n $$typeof: REACT_COMPAT_ELEMENT_TYPE,\n type,\n key,\n ref,\n props,\n };\n }\n\n const normalizedType =\n typeof type === \"object\" && type !== null ? normalizeElementType(type) : type;\n const key = config?.key === undefined ? null : String(config.key);\n const ref = config?.ref ?? null;\n const props = applyDefaultProps(normalizedType, copyElementProps(config)) as P & {\n children?: ReactCompatNode;\n };\n\n if (children.length === 1) {\n props.children = children[0];\n } else if (children.length > 1) {\n props.children = children;\n }\n\n if (typeof normalizedType === \"string\") {\n setHostOwnPropsMeta(props);\n }\n\n return {\n $$typeof: REACT_COMPAT_ELEMENT_TYPE,\n type: normalizedType as ElementType<P>,\n key,\n ref,\n props: props as P & { children?: ReactCompatNode },\n };\n}\n\n/** Creates a React-compatible element from JSX runtime arguments. */\nexport function createElementFromJsxConfig<P extends Record<string, unknown>>(\n type: ElementType<P>,\n config: (P & ReactReservedProps & { children?: ReactCompatNode }) | null,\n keyArgument?: unknown,\n): ReactCompatElement<P> {\n const normalizedType =\n typeof type === \"object\" && type !== null ? normalizeElementType(type) : type;\n const key = keyArgument !== undefined\n ? String(keyArgument)\n : config?.key === undefined ? null : String(config.key);\n const ref = config?.ref ?? null;\n const hasChildren = config !== null && config !== undefined && hasOwnProperty.call(config, \"children\");\n const children = config?.children;\n const copiedProps = copyElementProps(config, undefined, true);\n const props = (typeof normalizedType === \"string\"\n ? copiedProps\n : applyDefaultProps(normalizedType, copiedProps)) as P & {\n children?: ReactCompatNode;\n };\n\n if (hasChildren) {\n props.children = children;\n }\n\n if (typeof normalizedType === \"string\") {\n setHostOwnPropsMeta(props);\n }\n\n return {\n $$typeof: REACT_COMPAT_ELEMENT_TYPE,\n type: normalizedType as ElementType<P>,\n key,\n ref,\n props,\n };\n}\n\n/** Returns true when a value is a React-compatible element record. */\nexport function isReactCompatElement(\n value: unknown,\n): value is ReactCompatElement {\n return (\n typeof value === \"object\" &&\n value !== null &&\n (value as { $$typeof?: unknown }).$$typeof === REACT_COMPAT_ELEMENT_TYPE\n );\n}\n\n/** Creates a portal that renders children into a DOM container outside the parent tree. */\nexport function createPortal(\n children: ReactCompatNode,\n container: Element,\n key?: unknown,\n): ReactCompatPortal {\n return {\n $$typeof: PORTAL_TYPE,\n container,\n children,\n key: key === undefined ? null : String(key),\n };\n}\n\n/** Returns true when a value is a React-compatible portal record. */\nexport function isReactCompatPortal(value: unknown): value is ReactCompatPortal {\n return (\n typeof value === \"object\" &&\n value !== null &&\n (value as { $$typeof?: unknown }).$$typeof === PORTAL_TYPE\n );\n}\n\n/** Creates a mutable ref object with a null initial current value. */\nexport function createRef<T>(): { current: T | null } {\n return { current: null };\n}\n\n/** Element type record produced by forwardRef. */\nexport interface ForwardRefType<P = Record<string, unknown>> {\n $$typeof: typeof FORWARD_REF_TYPE;\n render: (props: P, ref: unknown) => ReactCompatNode;\n}\n\n/** Element type record produced by memo. */\nexport interface MemoType<P = Record<string, unknown>> {\n $$typeof: typeof MEMO_TYPE;\n type: ElementType<P>;\n compare?: (previous: P, next: P) => boolean;\n}\n\n/** Element type record produced by lazy. */\nexport interface LazyType<P = Record<string, unknown>> {\n $$typeof: typeof LAZY_TYPE;\n load: () => Promise<{ default: ElementType<P> }>;\n status: \"uninitialized\" | \"pending\" | \"resolved\" | \"rejected\";\n promise?: Promise<void>;\n resolved?: ElementType<P>;\n error?: unknown;\n}\n\n/** Wraps a component so it can receive a ref as the second render argument. */\nexport function forwardRef<P, T>(\n render: (props: P, ref: { current: T | null } | ((value: T | null) => void) | null) => ReactCompatNode,\n): ForwardRefType<P & { ref?: unknown }> {\n return { $$typeof: FORWARD_REF_TYPE, render: render as ForwardRefType<P>[\"render\"] };\n}\n\n/** Wraps an element type with optional prop comparison for memoized renders. */\nexport function memo<P>(\n type: ElementType<P>,\n compare?: (previous: P, next: P) => boolean,\n): MemoType<P> {\n return compare === undefined\n ? { $$typeof: MEMO_TYPE, type }\n : { $$typeof: MEMO_TYPE, type, compare };\n}\n\n/** Creates a lazy element type that resolves its implementation on demand. */\nexport function lazy<P>(\n load: () => Promise<{ default: ElementType<P> }>,\n): LazyType<P> {\n return {\n $$typeof: LAZY_TYPE,\n load,\n status: \"uninitialized\",\n };\n}\n\n/** Symbol used to mark a subtree for strict-mode development checks. */\nexport const StrictMode = STRICT_MODE_TYPE;\n\n/** Clones an existing element with merged props and optional replacement children. */\nexport function cloneElement<P extends Record<string, unknown>>(\n element: ReactCompatElement<P>,\n props: Partial<P> | null,\n ...children: ReactCompatNode[]\n): ReactCompatElement<P> {\n const key = props === null || props.key === undefined ? element.key : String(props.key);\n const ref = props === null || props.ref === undefined ? element.ref : props.ref;\n const nextProps = copyElementProps(props, element.props) as P & {\n children?: ReactCompatNode;\n };\n\n if (children.length === 1) {\n (nextProps as P & { children?: ReactCompatNode }).children = children[0];\n } else if (children.length > 1) {\n (nextProps as P & { children?: ReactCompatNode }).children = children;\n }\n\n return {\n $$typeof: REACT_COMPAT_ELEMENT_TYPE,\n type: element.type,\n key,\n ref,\n props: nextProps as P & { children?: ReactCompatNode },\n };\n}\n\nfunction copyElementProps(\n source: Record<string, unknown> | null | undefined,\n base?: Record<string, unknown>,\n omitChildren = false,\n): Record<string, unknown> {\n const props: Record<PropertyKey, unknown> = {};\n\n if (base !== undefined) {\n copyOwnStringElementProps(base, props, omitChildren);\n }\n\n if (source === null || source === undefined) {\n return props as Record<string, unknown>;\n }\n\n copyOwnStringElementProps(source, props, omitChildren);\n copyOwnSymbolElementProps(source, props);\n return props as Record<string, unknown>;\n}\n\nfunction copyOwnStringElementProps(\n source: Record<string, unknown>,\n target: Record<string, unknown>,\n omitChildren: boolean,\n): void {\n for (const name in source) {\n if (!hasOwnProperty.call(source, name)) {\n continue;\n }\n\n if (\n name !== \"key\" &&\n name !== \"ref\" &&\n name !== \"__self\" &&\n name !== \"__source\" &&\n (!omitChildren || name !== \"children\")\n ) {\n target[name] = source[name];\n }\n }\n}\n\nfunction copyOwnSymbolElementProps(\n source: Record<string, unknown>,\n target: Record<PropertyKey, unknown>,\n): void {\n const symbolSource = source as Record<PropertyKey, unknown>;\n for (const symbol of Object.getOwnPropertySymbols(source)) {\n target[symbol] = symbolSource[symbol];\n }\n}\n\nfunction normalizeElementType<P>(type: ElementType<P>): ElementType<P> {\n return isReactCompatContextProviderShorthand(type) ? (type.Provider as ElementType<P>) : type;\n}\n\nfunction applyDefaultProps(\n type: unknown,\n props: Record<string, unknown>,\n): Record<string, unknown> {\n if (typeof type !== \"function\" && (typeof type !== \"object\" || type === null)) {\n return props;\n }\n\n const defaultProps = (type as { defaultProps?: Record<string, unknown> } | undefined)\n ?.defaultProps;\n\n if (defaultProps === undefined) {\n return props;\n }\n\n for (const [name, value] of Object.entries(defaultProps)) {\n if (props[name] === undefined) {\n props[name] = value;\n }\n }\n\n return props;\n}\n\ninterface ReactReservedProps {\n key?: unknown;\n ref?: unknown;\n __self?: unknown;\n __source?: unknown;\n}\n\nfunction isReactCompatContextProviderShorthand(\n value: unknown,\n): value is ReactCompatContextProviderShorthand {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n\n const provider = (value as { Provider?: unknown }).Provider;\n\n return (\n typeof provider === \"object\" &&\n provider !== null &&\n (provider as { $$typeof?: unknown }).$$typeof === REACT_COMPAT_PROVIDER_TYPE\n );\n}\n\nfunction setHostOwnPropsMeta(props: Record<string, unknown>): void {\n if (hostPropsAreChildrenOnly(props)) {\n (props as { [HOST_CHILDREN_ONLY_PROPS_META]?: true })[\n HOST_CHILDREN_ONLY_PROPS_META\n ] = true;\n }\n}\n\nfunction hostPropsAreChildrenOnly(props: Record<string, unknown>): boolean {\n for (const name in props) {\n if (hasOwnProperty.call(props, name) && name !== \"children\") {\n return false;\n }\n }\n\n return true;\n}\n\n/** Alias for checking whether a value is a React-compatible element. */\nexport const isValidElement = isReactCompatElement;\n\n/** Helpers for iterating, counting, flattening, and validating children. */\nexport const Children = {\n map<T>(\n children: ReactCompatNode,\n fn: (child: Exclude<ReactCompatNode, null | undefined | boolean>, index: number) => T,\n ): T[] | null {\n if (children === null || children === undefined) {\n return null;\n }\n\n return flattenChildren(children).map((child, index) =>\n fn(child as Exclude<ReactCompatNode, null | undefined | boolean>, index),\n );\n },\n forEach(\n children: ReactCompatNode,\n fn: (child: Exclude<ReactCompatNode, null | undefined | boolean>, index: number) => void,\n ): void {\n toChildArray(children).forEach((child, index) => {\n fn(child, index);\n });\n },\n count(children: ReactCompatNode): number {\n if (children === null || children === undefined) {\n return 0;\n }\n\n return flattenChildren(children).length;\n },\n toArray(children: ReactCompatNode): Exclude<ReactCompatNode, null | undefined | boolean>[] {\n return toChildArray(children);\n },\n only(children: ReactCompatNode): Exclude<ReactCompatNode, null | undefined | boolean> {\n const array = toChildArray(children);\n\n if (array.length !== 1) {\n throw new Error(\"Expected exactly one child.\");\n }\n\n return array[0] as Exclude<ReactCompatNode, null | undefined | boolean>;\n },\n};\n\nfunction toChildArray(\n children: ReactCompatNode,\n): Exclude<ReactCompatNode, null | undefined | boolean>[] {\n return flattenChildren(children).filter(\n (child): child is Exclude<ReactCompatNode, null | undefined | boolean> =>\n child !== null && child !== undefined && typeof child !== \"boolean\",\n );\n}\n\nfunction flattenChildren(children: ReactCompatNode): ReactCompatNode[] {\n if (Array.isArray(children)) {\n return children.flatMap((child) => flattenChildren(child));\n }\n\n return [children];\n}\n\n/** Options used to render and observe a React-compatible error boundary. */\nexport interface ErrorBoundaryOptions {\n fallback: (error: Error) => ReactCompatNode;\n onError?: (error: Error) => void;\n}\n\n/** Creates an error boundary element with a fallback renderer. */\nexport function createErrorBoundary(\n options: ErrorBoundaryOptions,\n children: ReactCompatNode,\n): ReactCompatElement<ErrorBoundaryOptions & { children: ReactCompatNode }> {\n return createElement(ERROR_BOUNDARY_TYPE, {\n ...options,\n children,\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"element.js","sourceRoot":"","sources":["../src/element.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;AAClF,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;AAC9E,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;AAChE,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;AAClD,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;AAClD,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;AAChE,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;AACtD,MAAM,0BAA0B,GAAG,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;AAC/D,uEAAu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AY,CACnB,QAAyB;IAEzB,OAAO,eAAe,CAAC,QAAQ,CAAC,CAAC,MAAM,CACrC,CAAC,KAAK,EAAiE,EAAE,CACvE,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,KAAK,SAAS,CACtE,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,CAAC,QAAyB;IAChD,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7D,CAAC;IAED,OAAO,CAAC,QAAQ,CAAC,CAAC;AACpB,CAAC;AAQD,kEAAkE;AAClE,MAAM,UAAU,mBAAmB,CACjC,OAA6B,EAC7B,QAAyB;IAEzB,OAAO,aAAa,CAAC,mBAAmB,EAAE;QACxC,GAAG,OAAO;QACV,QAAQ;KACT,CAAC,CAAC;AACL,CAAC","sourcesContent":["export const REACT_COMPAT_ELEMENT_TYPE = Symbol.for(\"react.transitional.element\");\nexport const ERROR_BOUNDARY_TYPE = Symbol.for(\"modular.react.error_boundary\");\nexport const FORWARD_REF_TYPE = Symbol.for(\"react.forward_ref\");\nexport const MEMO_TYPE = Symbol.for(\"react.memo\");\nexport const LAZY_TYPE = Symbol.for(\"react.lazy\");\nexport const STRICT_MODE_TYPE = Symbol.for(\"react.strict_mode\");\nexport const PORTAL_TYPE = Symbol.for(\"react.portal\");\nconst REACT_COMPAT_PROVIDER_TYPE = Symbol.for(\"react.context\");\n/** Symbol used to group JSX children without adding a host element. */\nexport const Fragment = Symbol.for(\"react.fragment\");\n/** Symbol used to suspend rendering while async content resolves. */\nexport const Suspense = Symbol.for(\"react.suspense\");\n/** Symbol used to coordinate multiple suspense boundaries. */\nexport const SuspenseList = Symbol.for(\"react.suspense_list\");\n/** Symbol used to mark activity boundaries in React-compatible trees. */\nexport const Activity = Symbol.for(\"react.activity\");\n/** Symbol used to measure render work with profiler callbacks. */\nexport const Profiler = Symbol.for(\"react.profiler\");\nexport const HOST_CHILDREN_ONLY_PROPS_META = Symbol.for(\n \"modular.react.host_children_only_props_meta\",\n);\n/** Metadata key that links a state value to a reactive text binding. */\nexport const REACTIVE_TEXT_BINDING_META = Symbol.for(\n \"modular.react.reactive_text_binding_meta\",\n);\nconst hasOwnProperty = Object.prototype.hasOwnProperty;\n\nexport interface ReactCompatProviderType {\n $$typeof: symbol;\n context: unknown;\n}\n\nexport interface ReactCompatContextProviderShorthand {\n Provider: ReactCompatProviderType;\n Consumer: unknown;\n}\n\n/** Element type accepted by createElement, JSX, and renderer entrypoints. */\nexport type ElementType<P = Record<string, unknown>> =\n | string\n | typeof Fragment\n | typeof Suspense\n | typeof SuspenseList\n | typeof Activity\n | typeof Profiler\n | typeof ERROR_BOUNDARY_TYPE\n | typeof STRICT_MODE_TYPE\n | ReactCompatContextProviderShorthand\n | ReactCompatProviderType\n | ForwardRefType<P>\n | MemoType<P>\n | LazyType<P>\n | ((props: P) => ReactCompatNode | PromiseLike<ReactCompatNode>)\n | (new (props: P) => { render(): ReactCompatNode });\n\n/** Element-shaped renderable value accepted regardless of its original prop shape. */\nexport interface ReactCompatRenderableElement {\n /** React-compatible element marker. */\n $$typeof: typeof REACT_COMPAT_ELEMENT_TYPE;\n /** Host tag, component, or special element type. */\n type: unknown;\n /** Normalized React key. */\n key: string | null;\n /** Normalized React ref. */\n ref: unknown;\n /** Element props with children widened to the renderable node surface. */\n props: { children?: ReactCompatNode };\n}\n\n/** Renderable value accepted by the React-compatible renderer. */\nexport type ReactCompatNode =\n | ReactCompatRenderableElement\n | ReactCompatPortal\n | string\n | number\n | boolean\n | null\n | undefined\n | ReactCompatNode[];\n\n/** React-compatible element record produced by createElement and JSX transforms. */\nexport interface ReactCompatElement<P = Record<string, unknown>> {\n $$typeof: typeof REACT_COMPAT_ELEMENT_TYPE;\n type: ElementType<P>;\n key: string | null;\n ref: unknown;\n props: P & { children?: ReactCompatNode };\n}\n\n/** Portal record that renders children into an external DOM container. */\nexport interface ReactCompatPortal {\n $$typeof: typeof PORTAL_TYPE;\n container: Element;\n children: ReactCompatNode;\n key: string | null;\n}\n\n/** Creates a React-compatible element from a type, config object, and children. */\nexport function createElement<P extends object>(\n type: ElementType<P>,\n config: (P & ReactReservedProps) | null,\n ...children: ReactCompatNode[]\n): ReactCompatElement<P>;\nexport function createElement<P extends object>(\n type: ElementType<P>,\n config: (P & ReactReservedProps) | null,\n): ReactCompatElement<P> {\n const childCount = arguments.length - 2;\n\n if (typeof type === \"string\") {\n const key = config?.key === undefined ? null : String(config.key);\n const ref = config?.ref ?? null;\n const props = copyCreateElementProps(config) as P & {\n children?: ReactCompatNode;\n };\n\n assignCreateElementChildren(props, childCount, arguments);\n\n setHostOwnPropsMeta(props);\n\n return {\n $$typeof: REACT_COMPAT_ELEMENT_TYPE,\n type,\n key,\n ref,\n props,\n };\n }\n\n const normalizedType =\n typeof type === \"object\" && type !== null ? normalizeElementType(type) : type;\n const key = config?.key === undefined ? null : String(config.key);\n const ref = config?.ref ?? null;\n const props = applyDefaultProps(\n normalizedType,\n copyCreateElementProps(config),\n ) as P & {\n children?: ReactCompatNode;\n };\n\n assignCreateElementChildren(props, childCount, arguments);\n\n if (typeof normalizedType === \"string\") {\n setHostOwnPropsMeta(props);\n }\n\n return {\n $$typeof: REACT_COMPAT_ELEMENT_TYPE,\n type: normalizedType as ElementType<P>,\n key,\n ref,\n props: props as P & { children?: ReactCompatNode },\n };\n}\n\nfunction assignCreateElementChildren(\n props: { children?: ReactCompatNode },\n childCount: number,\n args: IArguments,\n): void {\n if (childCount === 1) {\n props.children = args[2] as ReactCompatNode;\n return;\n }\n\n if (childCount <= 1) {\n return;\n }\n\n const children: ReactCompatNode[] = [];\n children.length = childCount;\n\n for (let index = 0; index < childCount; index += 1) {\n children[index] = args[index + 2] as ReactCompatNode;\n }\n\n props.children = children;\n}\n\n/** Creates a React-compatible element from JSX runtime arguments. */\nexport function createElementFromJsxConfig<P extends object>(\n type: ElementType<P>,\n config: (P & ReactReservedProps & { children?: ReactCompatNode }) | null,\n keyArgument?: unknown,\n): ReactCompatElement<P> {\n const normalizedType =\n typeof type === \"object\" && type !== null ? normalizeElementType(type) : type;\n const key = keyArgument !== undefined\n ? String(keyArgument)\n : config?.key === undefined ? null : String(config.key);\n const ref = config?.ref ?? null;\n const hasChildren = config !== null && config !== undefined && hasOwnProperty.call(config, \"children\");\n const children = config?.children;\n const copiedProps = copyElementProps(config, undefined, true);\n const props = (typeof normalizedType === \"string\"\n ? copiedProps\n : applyDefaultProps(normalizedType, copiedProps)) as P & {\n children?: ReactCompatNode;\n };\n\n if (hasChildren) {\n props.children = children;\n }\n\n if (typeof normalizedType === \"string\") {\n setHostOwnPropsMeta(props);\n }\n\n return {\n $$typeof: REACT_COMPAT_ELEMENT_TYPE,\n type: normalizedType as ElementType<P>,\n key,\n ref,\n props,\n };\n}\n\n/** Returns true when a value is a React-compatible element record. */\nexport function isReactCompatElement(\n value: unknown,\n): value is ReactCompatElement {\n return (\n typeof value === \"object\" &&\n value !== null &&\n (value as { $$typeof?: unknown }).$$typeof === REACT_COMPAT_ELEMENT_TYPE\n );\n}\n\n/** Creates a portal that renders children into a DOM container outside the parent tree. */\nexport function createPortal(\n children: ReactCompatNode,\n container: Element,\n key?: unknown,\n): ReactCompatPortal {\n return {\n $$typeof: PORTAL_TYPE,\n container,\n children,\n key: key === undefined ? null : String(key),\n };\n}\n\n/** Returns true when a value is a React-compatible portal record. */\nexport function isReactCompatPortal(value: unknown): value is ReactCompatPortal {\n return (\n typeof value === \"object\" &&\n value !== null &&\n (value as { $$typeof?: unknown }).$$typeof === PORTAL_TYPE\n );\n}\n\n/** Creates a mutable ref object with a null initial current value. */\nexport function createRef<T>(): { current: T | null } {\n return { current: null };\n}\n\n/** Element type record produced by forwardRef. */\nexport interface ForwardRefType<P = Record<string, unknown>> {\n $$typeof: typeof FORWARD_REF_TYPE;\n render: (props: P, ref: unknown) => ReactCompatNode;\n}\n\n/** Element type record produced by memo. */\nexport interface MemoType<P = Record<string, unknown>> {\n $$typeof: typeof MEMO_TYPE;\n type: ElementType<P>;\n compare?: (previous: P, next: P) => boolean;\n}\n\n/** Element type record produced by lazy. */\nexport interface LazyType<P = Record<string, unknown>> {\n $$typeof: typeof LAZY_TYPE;\n load: () => Promise<{ default: ElementType<P> }>;\n status: \"uninitialized\" | \"pending\" | \"resolved\" | \"rejected\";\n promise?: Promise<void>;\n resolved?: ElementType<P>;\n error?: unknown;\n}\n\n/** Wraps a component so it can receive a ref as the second render argument. */\nexport function forwardRef<P, T>(\n render: (props: P, ref: { current: T | null } | ((value: T | null) => void) | null) => ReactCompatNode,\n): ForwardRefType<P & { ref?: unknown }> {\n return { $$typeof: FORWARD_REF_TYPE, render: render as ForwardRefType<P>[\"render\"] };\n}\n\n/** Wraps an element type with optional prop comparison for memoized renders. */\nexport function memo<P>(\n type: ElementType<P>,\n compare?: (previous: P, next: P) => boolean,\n): MemoType<P> {\n return compare === undefined\n ? { $$typeof: MEMO_TYPE, type }\n : { $$typeof: MEMO_TYPE, type, compare };\n}\n\n/** Creates a lazy element type that resolves its implementation on demand. */\nexport function lazy<P>(\n load: () => Promise<{ default: ElementType<P> }>,\n): LazyType<P> {\n return {\n $$typeof: LAZY_TYPE,\n load,\n status: \"uninitialized\",\n };\n}\n\n/** Symbol used to mark a subtree for strict-mode development checks. */\nexport const StrictMode = STRICT_MODE_TYPE;\n\n/** Clones an existing element with merged props and optional replacement children. */\nexport function cloneElement<P extends object>(\n element: ReactCompatElement<P>,\n props: (Partial<P> & ReactReservedProps) | null,\n ...children: ReactCompatNode[]\n): ReactCompatElement<P> {\n const key = props === null || props.key === undefined ? element.key : String(props.key);\n const ref = props === null || props.ref === undefined ? element.ref : props.ref;\n const nextProps = copyElementProps(props, element.props) as P & {\n children?: ReactCompatNode;\n };\n\n if (children.length === 1) {\n (nextProps as P & { children?: ReactCompatNode }).children = children[0];\n } else if (children.length > 1) {\n (nextProps as P & { children?: ReactCompatNode }).children = children;\n }\n\n return {\n $$typeof: REACT_COMPAT_ELEMENT_TYPE,\n type: element.type,\n key,\n ref,\n props: nextProps as P & { children?: ReactCompatNode },\n };\n}\n\nfunction copyElementProps(\n source: object | null | undefined,\n base?: object,\n omitChildren = false,\n copySymbols: boolean | \"internal\" = true,\n): Record<string, unknown> {\n const props: Record<PropertyKey, unknown> = {};\n\n if (base !== undefined) {\n copyOwnStringElementProps(base, props, omitChildren);\n }\n\n if (source === null || source === undefined) {\n return props as Record<string, unknown>;\n }\n\n copyOwnStringElementProps(source, props, omitChildren);\n if (copySymbols === \"internal\") {\n copyInternalElementSymbolProps(source, props);\n } else if (copySymbols) {\n copyOwnSymbolElementProps(source, props);\n }\n return props as Record<string, unknown>;\n}\n\nfunction copyCreateElementProps(\n source: object | null | undefined,\n): Record<string, unknown> {\n const props: Record<PropertyKey, unknown> = {};\n\n if (source === null || source === undefined) {\n return props as Record<string, unknown>;\n }\n\n const stringSource = source as Record<string, unknown>;\n for (const name in source) {\n if (!hasOwnProperty.call(source, name)) {\n continue;\n }\n\n if (\n name !== \"key\" &&\n name !== \"ref\" &&\n name !== \"__self\" &&\n name !== \"__source\"\n ) {\n props[name] = stringSource[name];\n }\n }\n\n copyInternalElementSymbolProps(source, props);\n return props as Record<string, unknown>;\n}\n\nfunction copyOwnStringElementProps(\n source: object,\n target: Record<string, unknown>,\n omitChildren: boolean,\n): void {\n const stringSource = source as Record<string, unknown>;\n for (const name in source) {\n if (!hasOwnProperty.call(source, name)) {\n continue;\n }\n\n if (\n name !== \"key\" &&\n name !== \"ref\" &&\n name !== \"__self\" &&\n name !== \"__source\" &&\n (!omitChildren || name !== \"children\")\n ) {\n target[name] = stringSource[name];\n }\n }\n}\n\nfunction copyOwnSymbolElementProps(\n source: object,\n target: Record<PropertyKey, unknown>,\n): void {\n const symbolSource = source as Record<PropertyKey, unknown>;\n for (const symbol of Object.getOwnPropertySymbols(source)) {\n target[symbol] = symbolSource[symbol];\n }\n}\n\nfunction copyInternalElementSymbolProps(\n source: object,\n target: Record<PropertyKey, unknown>,\n): void {\n const symbolSource = source as Record<PropertyKey, unknown>;\n if (hasOwnProperty.call(source, REACTIVE_TEXT_BINDING_META)) {\n target[REACTIVE_TEXT_BINDING_META] = symbolSource[REACTIVE_TEXT_BINDING_META];\n }\n}\n\nfunction normalizeElementType<P>(type: ElementType<P>): ElementType<P> {\n return isReactCompatContextProviderShorthand(type) ? (type.Provider as ElementType<P>) : type;\n}\n\nfunction applyDefaultProps(\n type: unknown,\n props: Record<string, unknown>,\n): Record<string, unknown> {\n if (typeof type !== \"function\" && (typeof type !== \"object\" || type === null)) {\n return props;\n }\n\n const defaultProps = (type as { defaultProps?: Record<string, unknown> } | undefined)\n ?.defaultProps;\n\n if (defaultProps === undefined) {\n return props;\n }\n\n for (const [name, value] of Object.entries(defaultProps)) {\n if (props[name] === undefined) {\n props[name] = value;\n }\n }\n\n return props;\n}\n\ninterface ReactReservedProps {\n key?: unknown;\n ref?: unknown;\n __self?: unknown;\n __source?: unknown;\n}\n\nfunction isReactCompatContextProviderShorthand(\n value: unknown,\n): value is ReactCompatContextProviderShorthand {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n\n const provider = (value as { Provider?: unknown }).Provider;\n\n return (\n typeof provider === \"object\" &&\n provider !== null &&\n (provider as { $$typeof?: unknown }).$$typeof === REACT_COMPAT_PROVIDER_TYPE\n );\n}\n\nfunction setHostOwnPropsMeta(props: Record<string, unknown>): void {\n if (hostPropsAreChildrenOnly(props)) {\n (props as { [HOST_CHILDREN_ONLY_PROPS_META]?: true })[\n HOST_CHILDREN_ONLY_PROPS_META\n ] = true;\n }\n}\n\nfunction hostPropsAreChildrenOnly(props: Record<string, unknown>): boolean {\n for (const name in props) {\n if (hasOwnProperty.call(props, name) && name !== \"children\") {\n return false;\n }\n }\n\n return true;\n}\n\n/** Alias for checking whether a value is a React-compatible element. */\nexport const isValidElement = isReactCompatElement;\n\n/** Helpers for iterating, counting, flattening, and validating children. */\nexport const Children = {\n map<T>(\n children: ReactCompatNode,\n fn: (child: Exclude<ReactCompatNode, null | undefined | boolean>, index: number) => T,\n ): T[] | null {\n if (children === null || children === undefined) {\n return null;\n }\n\n return flattenChildren(children).map((child, index) =>\n fn(child as Exclude<ReactCompatNode, null | undefined | boolean>, index),\n );\n },\n forEach(\n children: ReactCompatNode,\n fn: (child: Exclude<ReactCompatNode, null | undefined | boolean>, index: number) => void,\n ): void {\n toChildArray(children).forEach((child, index) => {\n fn(child, index);\n });\n },\n count(children: ReactCompatNode): number {\n if (children === null || children === undefined) {\n return 0;\n }\n\n return flattenChildren(children).length;\n },\n toArray(children: ReactCompatNode): Exclude<ReactCompatNode, null | undefined | boolean>[] {\n return toChildArray(children);\n },\n only(children: ReactCompatNode): Exclude<ReactCompatNode, null | undefined | boolean> {\n const array = toChildArray(children);\n\n if (array.length !== 1) {\n throw new Error(\"Expected exactly one child.\");\n }\n\n return array[0] as Exclude<ReactCompatNode, null | undefined | boolean>;\n },\n};\n\nfunction toChildArray(\n children: ReactCompatNode,\n): Exclude<ReactCompatNode, null | undefined | boolean>[] {\n return flattenChildren(children).filter(\n (child): child is Exclude<ReactCompatNode, null | undefined | boolean> =>\n child !== null && child !== undefined && typeof child !== \"boolean\",\n );\n}\n\nfunction flattenChildren(children: ReactCompatNode): ReactCompatNode[] {\n if (Array.isArray(children)) {\n return children.flatMap((child) => flattenChildren(child));\n }\n\n return [children];\n}\n\n/** Options used to render and observe a React-compatible error boundary. */\nexport interface ErrorBoundaryOptions {\n fallback: (error: Error) => ReactCompatNode;\n onError?: (error: Error) => void;\n}\n\n/** Creates an error boundary element with a fallback renderer. */\nexport function createErrorBoundary(\n options: ErrorBoundaryOptions,\n children: ReactCompatNode,\n): ReactCompatElement<ErrorBoundaryOptions & { children: ReactCompatNode }> {\n return createElement(ERROR_BOUNDARY_TYPE, {\n ...options,\n children,\n });\n}\n"]}
|
package/dist/hooks.js
CHANGED
|
@@ -1550,6 +1550,9 @@ function cleanupInactiveInstances(runtime) {
|
|
|
1550
1550
|
if (activeInstanceKeys === undefined) {
|
|
1551
1551
|
return;
|
|
1552
1552
|
}
|
|
1553
|
+
if (activeInstanceKeys.size === runtime.instances.size) {
|
|
1554
|
+
return;
|
|
1555
|
+
}
|
|
1553
1556
|
for (const [key, instance] of runtime.instances) {
|
|
1554
1557
|
if (!activeInstanceKeys.has(key)) {
|
|
1555
1558
|
cleanupInstance(instance);
|
|
@@ -1559,34 +1562,38 @@ function cleanupInactiveInstances(runtime) {
|
|
|
1559
1562
|
}
|
|
1560
1563
|
}
|
|
1561
1564
|
function indexInstanceKey(runtime, key) {
|
|
1562
|
-
|
|
1565
|
+
forEachInstanceKeyPrefix(key, (prefix) => {
|
|
1563
1566
|
let keys = runtime.instanceKeysByPrefix.get(prefix);
|
|
1564
1567
|
if (keys === undefined) {
|
|
1565
1568
|
keys = new Set();
|
|
1566
1569
|
runtime.instanceKeysByPrefix.set(prefix, keys);
|
|
1567
1570
|
}
|
|
1568
1571
|
keys.add(key);
|
|
1569
|
-
}
|
|
1572
|
+
});
|
|
1570
1573
|
}
|
|
1571
1574
|
function removeInstanceKeyFromIndex(runtime, key) {
|
|
1572
|
-
|
|
1575
|
+
forEachInstanceKeyPrefix(key, (prefix) => {
|
|
1573
1576
|
const keys = runtime.instanceKeysByPrefix.get(prefix);
|
|
1574
1577
|
if (keys === undefined) {
|
|
1575
|
-
|
|
1578
|
+
return;
|
|
1576
1579
|
}
|
|
1577
1580
|
keys.delete(key);
|
|
1578
1581
|
if (keys.size === 0) {
|
|
1579
1582
|
runtime.instanceKeysByPrefix.delete(prefix);
|
|
1580
1583
|
}
|
|
1581
|
-
}
|
|
1584
|
+
});
|
|
1582
1585
|
}
|
|
1583
|
-
function
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1586
|
+
function forEachInstanceKeyPrefix(key, callback) {
|
|
1587
|
+
let start = 0;
|
|
1588
|
+
while (start < key.length) {
|
|
1589
|
+
const next = key.indexOf(".", start);
|
|
1590
|
+
if (next === -1) {
|
|
1591
|
+
break;
|
|
1592
|
+
}
|
|
1593
|
+
callback(key.slice(0, next));
|
|
1594
|
+
start = next + 1;
|
|
1588
1595
|
}
|
|
1589
|
-
|
|
1596
|
+
callback(key);
|
|
1590
1597
|
}
|
|
1591
1598
|
function cleanupInstance(instance) {
|
|
1592
1599
|
instance.disposed = true;
|