@vidact/runtime 0.2.0-beta.0 → 0.2.0-beta.10
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/CHANGELOG.md +71 -0
- package/README.md +1 -1
- package/dist/actions.d.ts +32 -30
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +251 -266
- package/dist/actions.js.map +1 -1
- package/dist/async.d.ts +20 -17
- package/dist/async.d.ts.map +1 -1
- package/dist/async.js +18 -17
- package/dist/async.js.map +1 -1
- package/dist/compiled/async-resource.d.ts +9 -6
- package/dist/compiled/async-resource.d.ts.map +1 -1
- package/dist/compiled/async-resource.js +69 -77
- package/dist/compiled/async-resource.js.map +1 -1
- package/dist/compiled/core.d.ts +148 -147
- package/dist/compiled/core.d.ts.map +1 -1
- package/dist/compiled/core.js +3064 -2987
- package/dist/compiled/core.js.map +1 -1
- package/dist/compiled/types.d.ts +44 -56
- package/dist/compiled/types.d.ts.map +1 -1
- package/dist/compiled/types.js +10 -6
- package/dist/compiled/types.js.map +1 -1
- package/dist/compiled/validation.d.ts +4 -1
- package/dist/compiled/validation.d.ts.map +1 -1
- package/dist/compiled/validation.js +17 -20
- package/dist/compiled/validation.js.map +1 -1
- package/dist/component-spread.d.ts +5 -3
- package/dist/component-spread.d.ts.map +1 -1
- package/dist/component-spread.js +49 -67
- package/dist/component-spread.js.map +1 -1
- package/dist/concurrent.d.ts +20 -18
- package/dist/concurrent.d.ts.map +1 -1
- package/dist/concurrent.js +191 -210
- package/dist/concurrent.js.map +1 -1
- package/dist/direct-dom.d.ts +17 -12
- package/dist/direct-dom.d.ts.map +1 -1
- package/dist/direct-dom.js +279 -222
- package/dist/direct-dom.js.map +1 -1
- package/dist/dom/attributes.d.ts +9 -6
- package/dist/dom/attributes.d.ts.map +1 -1
- package/dist/dom/attributes.js +65 -47
- package/dist/dom/attributes.js.map +1 -1
- package/dist/dom/events.d.ts +8 -2
- package/dist/dom/events.d.ts.map +1 -1
- package/dist/dom/events.js +118 -65
- package/dist/dom/events.js.map +1 -1
- package/dist/dom/forms.d.ts +9 -6
- package/dist/dom/forms.d.ts.map +1 -1
- package/dist/dom/forms.js +152 -198
- package/dist/dom/forms.js.map +1 -1
- package/dist/dom/intrinsic.d.ts +17 -15
- package/dist/dom/intrinsic.d.ts.map +1 -1
- package/dist/dom/intrinsic.js +48 -50
- package/dist/dom/intrinsic.js.map +1 -1
- package/dist/dom/namespace.d.ts +4 -1
- package/dist/dom/namespace.d.ts.map +1 -1
- package/dist/dom/namespace.js +25 -28
- package/dist/dom/namespace.js.map +1 -1
- package/dist/dom/namespaces.d.ts +11 -8
- package/dist/dom/namespaces.d.ts.map +1 -1
- package/dist/dom/namespaces.js +14 -12
- package/dist/dom/namespaces.js.map +1 -1
- package/dist/dom/properties.d.ts +18 -16
- package/dist/dom/properties.d.ts.map +1 -1
- package/dist/dom/properties.js +273 -296
- package/dist/dom/properties.js.map +1 -1
- package/dist/dom/style-properties.d.ts +4 -1
- package/dist/dom/style-properties.d.ts.map +1 -1
- package/dist/dom/style-properties.js +49 -45
- package/dist/dom/style-properties.js.map +1 -1
- package/dist/dom/styles.d.ts +5 -2
- package/dist/dom/styles.d.ts.map +1 -1
- package/dist/dom/styles.js +47 -67
- package/dist/dom/styles.js.map +1 -1
- package/dist/dom-forms.d.ts +4 -1
- package/dist/dom-forms.d.ts.map +1 -1
- package/dist/dom-forms.js +16 -13
- package/dist/dom-forms.js.map +1 -1
- package/dist/dom-styles.d.ts +4 -1
- package/dist/dom-styles.d.ts.map +1 -1
- package/dist/dom-styles.js +10 -7
- package/dist/dom-styles.js.map +1 -1
- package/dist/framework-hydrate.d.ts +20 -17
- package/dist/framework-hydrate.d.ts.map +1 -1
- package/dist/framework-hydrate.js +128 -146
- package/dist/framework-hydrate.js.map +1 -1
- package/dist/framework-protocol.d.ts +27 -25
- package/dist/framework-protocol.d.ts.map +1 -1
- package/dist/framework-protocol.js +173 -211
- package/dist/framework-protocol.js.map +1 -1
- package/dist/framework.d.ts +34 -32
- package/dist/framework.d.ts.map +1 -1
- package/dist/framework.js +74 -93
- package/dist/framework.js.map +1 -1
- package/dist/hydrate.d.ts +11 -8
- package/dist/hydrate.d.ts.map +1 -1
- package/dist/hydrate.js +13 -9
- package/dist/hydrate.js.map +1 -1
- package/dist/hydration-bridge.d.ts +70 -58
- package/dist/hydration-bridge.d.ts.map +1 -1
- package/dist/hydration-bridge.js +77 -66
- package/dist/hydration-bridge.js.map +1 -1
- package/dist/hydration.d.ts +54 -28
- package/dist/hydration.d.ts.map +1 -1
- package/dist/hydration.js +450 -463
- package/dist/hydration.js.map +1 -1
- package/dist/index.d.ts +13 -13
- package/dist/index.js +11 -13
- package/dist/indexed-list.d.ts +8 -5
- package/dist/indexed-list.d.ts.map +1 -1
- package/dist/indexed-list.js +14 -7
- package/dist/indexed-list.js.map +1 -1
- package/dist/jsx-runtime.d.ts +10 -8
- package/dist/jsx-runtime.d.ts.map +1 -1
- package/dist/jsx-runtime.js +28 -23
- package/dist/jsx-runtime.js.map +1 -1
- package/dist/keyed-list.d.ts +17 -14
- package/dist/keyed-list.d.ts.map +1 -1
- package/dist/keyed-list.js +244 -161
- package/dist/keyed-list.js.map +1 -1
- package/dist/metadata.d.ts +6 -3
- package/dist/metadata.d.ts.map +1 -1
- package/dist/metadata.js +131 -164
- package/dist/metadata.js.map +1 -1
- package/dist/nested-prop.d.ts +4 -2
- package/dist/nested-prop.d.ts.map +1 -1
- package/dist/nested-prop.js +17 -16
- package/dist/nested-prop.js.map +1 -1
- package/dist/profiling.d.ts +11 -8
- package/dist/profiling.d.ts.map +1 -1
- package/dist/profiling.js +17 -17
- package/dist/profiling.js.map +1 -1
- package/dist/protocol.d.ts +5 -2
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +8 -5
- package/dist/protocol.js.map +1 -1
- package/dist/raw-html.d.ts +5 -2
- package/dist/raw-html.d.ts.map +1 -1
- package/dist/raw-html.js +86 -146
- package/dist/raw-html.js.map +1 -1
- package/dist/ref.d.ts +8 -3
- package/dist/ref.d.ts.map +1 -1
- package/dist/ref.js +10 -2
- package/dist/ref.js.map +1 -1
- package/dist/renderable-protocol.d.ts +26 -8
- package/dist/renderable-protocol.d.ts.map +1 -1
- package/dist/renderable-protocol.js +30 -9
- package/dist/renderable-protocol.js.map +1 -1
- package/dist/renderable.d.ts +28 -22
- package/dist/renderable.d.ts.map +1 -1
- package/dist/renderable.js +152 -133
- package/dist/renderable.js.map +1 -1
- package/dist/retained-ui.d.ts +9 -6
- package/dist/retained-ui.d.ts.map +1 -1
- package/dist/retained-ui.js +12 -10
- package/dist/retained-ui.js.map +1 -1
- package/dist/root.d.ts +18 -15
- package/dist/root.d.ts.map +1 -1
- package/dist/root.js +73 -85
- package/dist/root.js.map +1 -1
- package/dist/scheduler.d.ts +10 -8
- package/dist/scheduler.d.ts.map +1 -1
- package/dist/scheduler.js +97 -105
- package/dist/scheduler.js.map +1 -1
- package/dist/server-framework.d.ts +45 -42
- package/dist/server-framework.d.ts.map +1 -1
- package/dist/server-framework.js +209 -217
- package/dist/server-framework.js.map +1 -1
- package/dist/server.d.ts +130 -128
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +603 -710
- package/dist/server.js.map +1 -1
- package/dist/shared/promise.d.ts +6 -3
- package/dist/shared/promise.d.ts.map +1 -1
- package/dist/shared/promise.js +21 -19
- package/dist/shared/promise.js.map +1 -1
- package/dist/source-mask.d.ts +10 -6
- package/dist/source-mask.d.ts.map +1 -1
- package/dist/source-mask.js +60 -63
- package/dist/source-mask.js.map +1 -1
- package/dist/spread.d.ts +5 -2
- package/dist/spread.d.ts.map +1 -1
- package/dist/spread.js +79 -99
- package/dist/spread.js.map +1 -1
- package/dist/state-slot.d.ts +29 -15
- package/dist/state-slot.d.ts.map +1 -1
- package/dist/state-slot.js +73 -42
- package/dist/state-slot.js.map +1 -1
- package/dist/testing.d.ts +9 -6
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +16 -12
- package/dist/testing.js.map +1 -1
- package/package.json +8 -7
- package/src/actions.ts +415 -0
- package/src/async.ts +78 -0
- package/src/compiled/async-resource.ts +113 -0
- package/src/compiled/core.ts +4647 -0
- package/src/compiled/types.ts +96 -0
- package/src/compiled/validation.ts +23 -0
- package/src/component-spread.ts +86 -0
- package/src/concurrent.ts +310 -0
- package/src/direct-dom.ts +491 -0
- package/src/dom/attributes.ts +55 -0
- package/src/dom/events.ts +179 -0
- package/src/dom/forms.ts +220 -0
- package/src/dom/intrinsic.ts +94 -0
- package/src/dom/namespace.ts +30 -0
- package/src/dom/namespaces.ts +14 -0
- package/src/dom/properties.ts +355 -0
- package/src/dom/style-properties.ts +46 -0
- package/src/dom/styles.ts +86 -0
- package/src/dom-forms.ts +23 -0
- package/src/dom-styles.ts +11 -0
- package/src/env.d.ts +6 -0
- package/src/framework-hydrate.ts +224 -0
- package/src/framework-protocol.ts +335 -0
- package/src/framework.ts +161 -0
- package/src/hydrate.ts +38 -0
- package/src/hydration-bridge.ts +202 -0
- package/src/hydration.ts +644 -0
- package/src/index.ts +94 -0
- package/src/indexed-list.ts +20 -0
- package/src/jsx-runtime.ts +55 -0
- package/src/keyed-list.ts +379 -0
- package/src/metadata.ts +212 -0
- package/src/nested-prop.ts +27 -0
- package/src/profiling.ts +43 -0
- package/src/protocol.ts +8 -0
- package/src/raw-html.ts +206 -0
- package/src/ref.ts +13 -0
- package/src/renderable-protocol.ts +63 -0
- package/src/renderable.ts +313 -0
- package/src/retained-ui.ts +19 -0
- package/src/root.ts +122 -0
- package/src/scheduler.ts +136 -0
- package/src/server-framework.ts +397 -0
- package/src/server.ts +1160 -0
- package/src/shared/promise.ts +28 -0
- package/src/source-mask.ts +103 -0
- package/src/spread.ts +131 -0
- package/src/state-slot.ts +132 -0
- package/src/testing.ts +27 -0
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
package/dist/keyed-list.js
CHANGED
|
@@ -1,180 +1,263 @@
|
|
|
1
|
-
|
|
2
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|
|
105
|
-
|
|
1
|
+
import { claimHydrationArrayRange, finishHydrationArrayRange, withHydrationInsertion } from "./hydration-bridge.js";
|
|
2
|
+
//#region src/keyed-list.ts
|
|
3
|
+
const DEV = typeof __VIDACT_DEV__ === "undefined" || __VIDACT_DEV__;
|
|
4
|
+
function createKeyedList(parent, options, before = null) {
|
|
5
|
+
const hydratedRange = claimHydrationArrayRange(parent);
|
|
6
|
+
const start = hydratedRange?.[0] ?? document.createComment(DEV ? "vidact:list" : "");
|
|
7
|
+
const end = hydratedRange?.[1] ?? document.createComment(DEV ? "/vidact:list" : "");
|
|
8
|
+
if (hydratedRange === void 0) {
|
|
9
|
+
parent.insertBefore(start, before);
|
|
10
|
+
parent.insertBefore(end, before);
|
|
11
|
+
}
|
|
12
|
+
let disposed = false;
|
|
13
|
+
let hydrationPending = hydratedRange !== void 0;
|
|
14
|
+
let records = [];
|
|
15
|
+
const update = (values) => {
|
|
16
|
+
if (disposed) throw new Error(DEV ? "cannot update a disposed keyed list" : "V801");
|
|
17
|
+
const currentParent = end.parentNode;
|
|
18
|
+
if (currentParent === null || start.parentNode !== currentParent) throw new Error(DEV ? "cannot update a detached keyed list" : "V802");
|
|
19
|
+
const keys = values.map(options.key);
|
|
20
|
+
assertValidKeys(keys);
|
|
21
|
+
assertUniqueKeys(keys);
|
|
22
|
+
if (!hydrationPending && values.length === 0 && records.length > 0) {
|
|
23
|
+
const removed = records;
|
|
24
|
+
records = [];
|
|
25
|
+
deleteRangeContents(start, end);
|
|
26
|
+
const cleanup = disposeRecordOwners(removed);
|
|
27
|
+
if (cleanup[1]) throw cleanup[0];
|
|
28
|
+
return [];
|
|
29
|
+
}
|
|
30
|
+
if (!hydrationPending && hasRetainedPrefix(records, keys)) {
|
|
31
|
+
const retainedCount = Math.min(records.length, values.length);
|
|
32
|
+
const created = [];
|
|
33
|
+
try {
|
|
34
|
+
for (let index = records.length; index < values.length; index += 1) {
|
|
35
|
+
const value = values[index];
|
|
36
|
+
const item = normalizeRenderResult(withHydrationInsertion(parent, end, () => options.render(value, index)));
|
|
37
|
+
created.push([
|
|
38
|
+
keys[index],
|
|
39
|
+
item[0],
|
|
40
|
+
item[1],
|
|
41
|
+
item[2]
|
|
42
|
+
]);
|
|
43
|
+
}
|
|
44
|
+
for (let index = 0; index < retainedCount; index += 1) records[index][2]?.(values[index], index);
|
|
45
|
+
} catch (error) {
|
|
46
|
+
disposeRecords(currentParent, created);
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
const cleanup = disposeRecords(currentParent, records.slice(values.length));
|
|
50
|
+
const fragment = document.createDocumentFragment();
|
|
51
|
+
for (const record of created) for (const node of record[1]) fragment.append(node);
|
|
52
|
+
currentParent.insertBefore(fragment, end);
|
|
53
|
+
if (records.length !== values.length) records = retainedCount === 0 ? created : [...records.slice(0, retainedCount), ...created];
|
|
54
|
+
if (cleanup[1]) throw cleanup[0];
|
|
55
|
+
return collectRecordNodes(created);
|
|
56
|
+
}
|
|
57
|
+
const previousByKey = /* @__PURE__ */ new Map();
|
|
58
|
+
for (let index = 0; index < records.length; index += 1) {
|
|
59
|
+
const record = records[index];
|
|
60
|
+
previousByKey.set(record[0], [record, index]);
|
|
61
|
+
}
|
|
62
|
+
const created = [];
|
|
63
|
+
const retained = [];
|
|
64
|
+
const previousIndexes = [];
|
|
65
|
+
let nextRecords;
|
|
66
|
+
try {
|
|
67
|
+
nextRecords = values.map((value, index) => {
|
|
68
|
+
const key = keys[index];
|
|
69
|
+
const previous = previousByKey.get(key);
|
|
70
|
+
if (previous !== void 0) {
|
|
71
|
+
previousByKey.delete(key);
|
|
72
|
+
retained.push([
|
|
73
|
+
previous[0],
|
|
74
|
+
value,
|
|
75
|
+
index
|
|
76
|
+
]);
|
|
77
|
+
previousIndexes.push(previous[1]);
|
|
78
|
+
return previous[0];
|
|
79
|
+
}
|
|
80
|
+
const item = normalizeRenderResult(withHydrationInsertion(parent, end, () => options.render(value, index)));
|
|
81
|
+
const record = [
|
|
82
|
+
key,
|
|
83
|
+
item[0],
|
|
84
|
+
item[1],
|
|
85
|
+
item[2]
|
|
86
|
+
];
|
|
87
|
+
created.push(record);
|
|
88
|
+
previousIndexes.push(-1);
|
|
89
|
+
return record;
|
|
90
|
+
});
|
|
91
|
+
for (const [record, value, index] of retained) record[2]?.(value, index);
|
|
92
|
+
} catch (error) {
|
|
93
|
+
disposeRecords(currentParent, created);
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
const cleanup = disposeRecords(currentParent, mapRecords(previousByKey.values()));
|
|
97
|
+
const stableRecords = longestIncreasingSubsequence(previousIndexes);
|
|
98
|
+
const activeElement = previousIndexes.some((previousIndex, index) => previousIndex >= 0 && stableRecords[index] === 0) ? document.activeElement instanceof HTMLElement && currentParent.contains(document.activeElement) ? document.activeElement : null : null;
|
|
99
|
+
const selectionControl = activeElement instanceof HTMLInputElement || activeElement instanceof HTMLTextAreaElement ? activeElement : null;
|
|
100
|
+
const selection = selectionControl === null ? null : [selectionControl.selectionStart, selectionControl.selectionEnd];
|
|
101
|
+
let cursor = end;
|
|
102
|
+
for (let recordIndex = nextRecords.length - 1; recordIndex >= 0; recordIndex -= 1) {
|
|
103
|
+
const record = nextRecords[recordIndex];
|
|
104
|
+
if (previousIndexes[recordIndex] === -1 || stableRecords[recordIndex] === 0) for (let nodeIndex = record[1].length - 1; nodeIndex >= 0; nodeIndex -= 1) {
|
|
105
|
+
const node = record[1][nodeIndex];
|
|
106
|
+
if (node.nextSibling !== cursor) moveBefore(currentParent, node, cursor);
|
|
107
|
+
cursor = node;
|
|
108
|
+
}
|
|
109
|
+
else cursor = record[1][0];
|
|
110
|
+
}
|
|
111
|
+
if (activeElement !== null && document.activeElement !== activeElement && currentParent.contains(activeElement)) {
|
|
112
|
+
activeElement.focus({ preventScroll: true });
|
|
113
|
+
if (selectionControl !== null && selection !== null && selection[0] !== null && selection[1] !== null) selectionControl.setSelectionRange(selection[0], selection[1]);
|
|
114
|
+
}
|
|
115
|
+
records = nextRecords;
|
|
116
|
+
if (hydrationPending) {
|
|
117
|
+
hydrationPending = false;
|
|
118
|
+
finishHydrationArrayRange(currentParent, end);
|
|
119
|
+
}
|
|
120
|
+
if (cleanup[1]) throw cleanup[0];
|
|
121
|
+
return collectRecordNodes(created);
|
|
122
|
+
};
|
|
123
|
+
const dispose = () => {
|
|
124
|
+
if (disposed) return;
|
|
125
|
+
disposed = true;
|
|
126
|
+
const currentParent = end.parentNode;
|
|
127
|
+
const cleanup = currentParent === null ? [void 0, false] : disposeRecords(currentParent, records);
|
|
128
|
+
records = [];
|
|
129
|
+
start.remove();
|
|
130
|
+
end.remove();
|
|
131
|
+
if (cleanup[1]) throw cleanup[0];
|
|
132
|
+
};
|
|
133
|
+
return {
|
|
134
|
+
dispose,
|
|
135
|
+
parent: () => end.parentNode,
|
|
136
|
+
update
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function* mapRecords(entries) {
|
|
140
|
+
for (const [record] of entries) yield record;
|
|
141
|
+
}
|
|
142
|
+
function collectRecordNodes(records) {
|
|
143
|
+
const nodes = [];
|
|
144
|
+
for (const record of records) nodes.push(...record[1]);
|
|
145
|
+
return nodes;
|
|
146
|
+
}
|
|
147
|
+
function longestIncreasingSubsequence(indexes) {
|
|
148
|
+
const predecessors = new Int32Array(indexes.length).fill(-1);
|
|
149
|
+
const tails = [];
|
|
150
|
+
for (let index = 0; index < indexes.length; index += 1) {
|
|
151
|
+
const value = indexes[index];
|
|
152
|
+
if (value < 0) continue;
|
|
153
|
+
let low = 0;
|
|
154
|
+
let high = tails.length;
|
|
155
|
+
while (low < high) {
|
|
156
|
+
const middle = low + high >>> 1;
|
|
157
|
+
if (indexes[tails[middle]] < value) low = middle + 1;
|
|
158
|
+
else high = middle;
|
|
159
|
+
}
|
|
160
|
+
if (low > 0) predecessors[index] = tails[low - 1];
|
|
161
|
+
tails[low] = index;
|
|
162
|
+
}
|
|
163
|
+
const stable = new Uint8Array(indexes.length);
|
|
164
|
+
let index = tails.at(-1) ?? -1;
|
|
165
|
+
while (index >= 0) {
|
|
166
|
+
stable[index] = 1;
|
|
167
|
+
index = predecessors[index];
|
|
168
|
+
}
|
|
169
|
+
return stable;
|
|
170
|
+
}
|
|
171
|
+
function hasRetainedPrefix(records, keys) {
|
|
172
|
+
const retainedCount = Math.min(records.length, keys.length);
|
|
173
|
+
for (let index = 0; index < retainedCount; index += 1) if (records[index][0] !== keys[index]) return false;
|
|
174
|
+
return true;
|
|
106
175
|
}
|
|
107
176
|
function moveBefore(parent, node, before) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
parent.insertBefore(node, before);
|
|
114
|
-
}
|
|
177
|
+
const statePreservingParent = parent;
|
|
178
|
+
if (statePreservingParent.moveBefore !== void 0 && node.parentNode === parent) statePreservingParent.moveBefore(node, before);
|
|
179
|
+
else parent.insertBefore(node, before);
|
|
115
180
|
}
|
|
116
181
|
function assertValidKeys(keys) {
|
|
117
|
-
|
|
118
|
-
if (typeof key !== 'string' && typeof key !== 'number' && typeof key !== 'bigint') {
|
|
119
|
-
throw new Error(DEV ? `invalid key in keyed list: ${String(key)}` : 'V803');
|
|
120
|
-
}
|
|
121
|
-
}
|
|
182
|
+
for (const key of keys) if (typeof key !== "string" && typeof key !== "number" && typeof key !== "bigint") throw new Error(DEV ? `invalid key in keyed list: ${String(key)}` : "V803");
|
|
122
183
|
}
|
|
123
184
|
function assertUniqueKeys(keys) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
seen.add(key);
|
|
130
|
-
}
|
|
185
|
+
const seen = /* @__PURE__ */ new Set();
|
|
186
|
+
for (const key of keys) {
|
|
187
|
+
if (seen.has(key)) throw new Error(DEV ? `duplicate key in keyed list: ${String(key)}` : "V804");
|
|
188
|
+
seen.add(key);
|
|
189
|
+
}
|
|
131
190
|
}
|
|
132
191
|
function normalizeRenderResult(result) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
192
|
+
if (isNode(result)) return [normalizeNodes([result])];
|
|
193
|
+
if (isNodeArray(result)) return [normalizeNodes(result)];
|
|
194
|
+
return [
|
|
195
|
+
normalizeNodes(result[0]),
|
|
196
|
+
result[1],
|
|
197
|
+
result[2]
|
|
198
|
+
];
|
|
138
199
|
}
|
|
139
200
|
function normalizeNodes(nodes) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
201
|
+
if (nodes.length === 0) return [document.createComment(DEV ? "vidact:empty" : "")];
|
|
202
|
+
let firstFragment = -1;
|
|
203
|
+
for (let index = 0; index < nodes.length; index += 1) if (nodes[index].nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
|
|
204
|
+
firstFragment = index;
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
if (firstFragment === -1) return nodes;
|
|
208
|
+
const normalized = nodes.slice(0, firstFragment);
|
|
209
|
+
for (let index = firstFragment; index < nodes.length; index += 1) {
|
|
210
|
+
const node = nodes[index];
|
|
211
|
+
if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) normalized.push(...node.childNodes);
|
|
212
|
+
else normalized.push(node);
|
|
213
|
+
}
|
|
214
|
+
return normalized.length === 0 ? [document.createComment(DEV ? "vidact:empty" : "")] : normalized;
|
|
150
215
|
}
|
|
151
216
|
function isNode(value) {
|
|
152
|
-
|
|
217
|
+
return typeof value === "object" && value !== null && "nodeType" in value;
|
|
153
218
|
}
|
|
154
219
|
function isNodeArray(value) {
|
|
155
|
-
|
|
220
|
+
return Array.isArray(value) && (value.length === 0 || isNode(value[0]));
|
|
156
221
|
}
|
|
157
222
|
function removeNodes(parent, nodes) {
|
|
158
|
-
|
|
159
|
-
if (node.parentNode === parent)
|
|
160
|
-
parent.removeChild(node);
|
|
161
|
-
}
|
|
223
|
+
for (const node of nodes) if (node.parentNode === parent) parent.removeChild(node);
|
|
162
224
|
}
|
|
163
225
|
function disposeRecords(parent, records) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
226
|
+
let firstError;
|
|
227
|
+
let failed = false;
|
|
228
|
+
for (const record of records) {
|
|
229
|
+
removeNodes(parent, record[1]);
|
|
230
|
+
try {
|
|
231
|
+
disposeRecord(record[3]);
|
|
232
|
+
} catch (error) {
|
|
233
|
+
if (!failed) firstError = error;
|
|
234
|
+
failed = true;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return [firstError, failed];
|
|
238
|
+
}
|
|
239
|
+
function disposeRecordOwners(records) {
|
|
240
|
+
let firstError;
|
|
241
|
+
let failed = false;
|
|
242
|
+
for (const record of records) try {
|
|
243
|
+
disposeRecord(record[3]);
|
|
244
|
+
} catch (error) {
|
|
245
|
+
if (!failed) firstError = error;
|
|
246
|
+
failed = true;
|
|
247
|
+
}
|
|
248
|
+
return [firstError, failed];
|
|
249
|
+
}
|
|
250
|
+
function disposeRecord(disposer) {
|
|
251
|
+
if (typeof disposer === "function") disposer();
|
|
252
|
+
else disposer?.[3]();
|
|
253
|
+
}
|
|
254
|
+
function deleteRangeContents(start, end) {
|
|
255
|
+
const range = start.ownerDocument?.createRange() ?? document.createRange();
|
|
256
|
+
range.setStartAfter(start);
|
|
257
|
+
range.setEndBefore(end);
|
|
258
|
+
range.deleteContents();
|
|
259
|
+
}
|
|
260
|
+
//#endregion
|
|
261
|
+
export { createKeyedList };
|
|
262
|
+
|
|
180
263
|
//# sourceMappingURL=keyed-list.js.map
|
package/dist/keyed-list.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3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AAY,MAAM;AAC5B;AAEA,SAAS,oBACP,SAC4C;CAC5C,IAAI;CACJ,IAAI,SAAS;CACb,KAAK,MAAM,UAAU,SACnB,IAAI;EACF,cAAc,OAAO,EAAE;CACzB,SAAS,OAAO;EACd,IAAI,CAAC,QAAQ,aAAa;EAC1B,SAAS;CACX;CAEF,OAAO,CAAC,YAAY,MAAM;AAC5B;AAEA,SAAS,cAAc,UAA2C;CAChE,IAAI,OAAO,aAAa,YAAY,SAAS;MACxC,WAAW,EAAE,CAAC;AACrB;AAEA,SAAS,oBAAoB,OAAa,KAAiB;CACzD,MAAM,QAAQ,MAAM,eAAe,YAAY,KAAK,SAAS,YAAY;CACzE,MAAM,cAAc,KAAK;CACzB,MAAM,aAAa,GAAG;CACtB,MAAM,eAAe;AACvB"}
|
package/dist/metadata.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
//#region src/metadata.d.ts
|
|
2
|
+
declare function installFrameworkMetadataPropRekeying(): void;
|
|
3
|
+
declare function isFrameworkMetadataElement(element: Element, props?: Readonly<Record<string, unknown>> | null): boolean;
|
|
4
|
+
declare function hoistFrameworkMetadata(element: Element): DocumentFragment;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { hoistFrameworkMetadata, installFrameworkMetadataPropRekeying, isFrameworkMetadataElement };
|
|
4
7
|
//# sourceMappingURL=metadata.d.ts.map
|
package/dist/metadata.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.d.ts","
|
|
1
|
+
{"version":3,"file":"metadata.d.ts","names":[],"sources":["../src/metadata.ts"],"mappings":";iBA6BgB;iBAiBA,2BACd,SAAS,SACT,QAAO,SAAS;iBAuBF,uBAAuB,SAAS,UAAU"}
|