@fluixi/dom 1.0.0-alpha.82 → 1.0.0-alpha.84
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/cdn/dom-client.cjs +1427 -1
- package/dist/cdn/dom-client.d.ts +2 -2
- package/dist/cdn/dom-client.global.js +2 -1
- package/dist/cdn/dom-client.js +3 -3
- package/dist/cdn/dom-client.mjs +1430 -1
- package/dist/cdn/dom.cjs +3127 -1
- package/dist/cdn/dom.d.ts +2 -2
- package/dist/cdn/dom.global.js +2 -1
- package/dist/cdn/dom.js +4 -4
- package/dist/cdn/dom.mjs +3133 -1
- package/dist/index.cjs +3155 -1
- package/dist/index.js +2 -2
- package/dist/index.mjs +3149 -1
- package/dist/lib/component/index.cjs +128 -1
- package/dist/lib/component/index.mjs +105 -1
- package/dist/lib/component/modifiers.cjs +126 -1
- package/dist/lib/component/modifiers.d.ts +12 -0
- package/dist/lib/component/modifiers.d.ts.map +1 -1
- package/dist/lib/component/modifiers.js +12 -84
- package/dist/lib/component/modifiers.mjs +105 -1
- package/dist/lib/dom/delegate.cjs +60 -1
- package/dist/lib/dom/delegate.js +1 -1
- package/dist/lib/dom/delegate.mjs +39 -1
- package/dist/lib/dom/dynamic-element.cjs +949 -1
- package/dist/lib/dom/dynamic-element.d.ts +3 -3
- package/dist/lib/dom/dynamic-element.js +3 -3
- package/dist/lib/dom/dynamic-element.mjs +928 -1
- package/dist/lib/dom/hydration-state.cjs +93 -1
- package/dist/lib/dom/hydration-state.d.ts +1 -1
- package/dist/lib/dom/hydration-state.js +1 -1
- package/dist/lib/dom/hydration-state.mjs +72 -1
- package/dist/lib/dom/hydration.cjs +685 -1
- package/dist/lib/dom/hydration.js +8 -8
- package/dist/lib/dom/hydration.mjs +664 -1
- package/dist/lib/dom/index.cjs +2040 -1
- package/dist/lib/dom/index.js +1 -1
- package/dist/lib/dom/index.mjs +2020 -1
- package/dist/lib/dom/integration.cjs +71 -1
- package/dist/lib/dom/integration.d.ts.map +1 -1
- package/dist/lib/dom/integration.js +15 -6
- package/dist/lib/dom/integration.mjs +51 -1
- package/dist/lib/dom/island.cjs +790 -1
- package/dist/lib/dom/island.d.ts +1 -1
- package/dist/lib/dom/island.js +12 -12
- package/dist/lib/dom/island.mjs +769 -1
- package/dist/lib/dom/runtime.cjs +1432 -1
- package/dist/lib/dom/runtime.d.ts +71 -19
- package/dist/lib/dom/runtime.d.ts.map +1 -1
- package/dist/lib/dom/runtime.js +261 -100
- package/dist/lib/dom/runtime.mjs +1414 -1
- package/dist/lib/dom/server/fx-data.cjs +53 -1
- package/dist/lib/dom/server/fx-data.d.ts +5 -5
- package/dist/lib/dom/server/fx-data.js +6 -6
- package/dist/lib/dom/server/fx-data.mjs +32 -1
- package/dist/lib/dom/server/host.cjs +66 -1
- package/dist/lib/dom/server/host.d.ts +14 -2
- package/dist/lib/dom/server/host.d.ts.map +1 -1
- package/dist/lib/dom/server/host.js +38 -10
- package/dist/lib/dom/server/host.mjs +45 -1
- package/dist/lib/dom/server/index.cjs +759 -1
- package/dist/lib/dom/server/index.d.ts +1 -1
- package/dist/lib/dom/server/index.js +1 -1
- package/dist/lib/dom/server/index.mjs +743 -1
- package/dist/lib/dom/server/nodes.cjs +302 -1
- package/dist/lib/dom/server/nodes.d.ts +2 -2
- package/dist/lib/dom/server/nodes.d.ts.map +1 -1
- package/dist/lib/dom/server/nodes.js +4 -4
- package/dist/lib/dom/server/nodes.mjs +279 -1
- package/dist/lib/dom/server/parse-template.cjs +395 -1
- package/dist/lib/dom/server/parse-template.d.ts +1 -1
- package/dist/lib/dom/server/parse-template.js +4 -4
- package/dist/lib/dom/server/parse-template.mjs +372 -1
- package/dist/lib/dom/server/render.cjs +691 -1
- package/dist/lib/dom/server/render.d.ts +9 -1
- package/dist/lib/dom/server/render.d.ts.map +1 -1
- package/dist/lib/dom/server/render.js +25 -17
- package/dist/lib/dom/server/render.mjs +677 -1
- package/dist/lib/dom/server/request-context.cjs +110 -1
- package/dist/lib/dom/server/request-context.d.ts +29 -9
- package/dist/lib/dom/server/request-context.d.ts.map +1 -1
- package/dist/lib/dom/server/request-context.js +28 -8
- package/dist/lib/dom/server/request-context.mjs +89 -1
- package/dist/lib/dom/server/serialize.cjs +187 -1
- package/dist/lib/dom/server/serialize.js +3 -3
- package/dist/lib/dom/server/serialize.mjs +164 -1
- package/dist/lib/dom/server-renderer.cjs +760 -1
- package/dist/lib/dom/server-renderer.js +1 -1
- package/dist/lib/dom/server-renderer.mjs +745 -1
- package/dist/lib/dom/types.cjs +18 -1
- package/dist/lib/dom/utils.cjs +381 -1
- package/dist/lib/dom/utils.d.ts +1 -88
- package/dist/lib/dom/utils.d.ts.map +1 -1
- package/dist/lib/dom/utils.js +2 -99
- package/dist/lib/dom/utils.mjs +361 -1
- package/dist/lib/dom/versions.cjs +60 -1
- package/dist/lib/dom/versions.d.ts +3 -3
- package/dist/lib/dom/versions.d.ts.map +1 -1
- package/dist/lib/dom/versions.js +17 -5
- package/dist/lib/dom/versions.mjs +37 -1
- package/dist/lib/element/attributes.cjs +19 -1
- package/dist/lib/element/attributes.d.ts +7 -7
- package/dist/lib/element/attributes.js +1 -1
- package/dist/lib/element/attributes.mjs +1 -0
- package/dist/lib/element/index.cjs +19 -1
- package/dist/lib/element/index.mjs +1 -0
- package/dist/lib/element/types.cjs +18 -1
- package/dist/lib/element/types.d.ts +4 -5
- package/dist/lib/element/types.d.ts.map +1 -1
- package/dist/lib/element/types.js +0 -1
- package/dist/lib/flow/class-map.cjs +38 -1
- package/dist/lib/flow/class-map.d.ts +3 -3
- package/dist/lib/flow/class-map.js +3 -3
- package/dist/lib/flow/class-map.mjs +17 -1
- package/dist/lib/flow/client-only.cjs +57 -1
- package/dist/lib/flow/client-only.d.ts +4 -4
- package/dist/lib/flow/client-only.js +4 -4
- package/dist/lib/flow/client-only.mjs +36 -1
- package/dist/lib/flow/dynamic.cjs +53 -1
- package/dist/lib/flow/dynamic.d.ts +2 -2
- package/dist/lib/flow/dynamic.js +4 -4
- package/dist/lib/flow/dynamic.mjs +32 -1
- package/dist/lib/flow/error-boundary.cjs +43 -1
- package/dist/lib/flow/error-boundary.d.ts +2 -2
- package/dist/lib/flow/error-boundary.js +4 -4
- package/dist/lib/flow/error-boundary.mjs +22 -1
- package/dist/lib/flow/for.cjs +66 -1
- package/dist/lib/flow/for.d.ts +9 -9
- package/dist/lib/flow/for.d.ts.map +1 -1
- package/dist/lib/flow/for.js +2 -2
- package/dist/lib/flow/for.mjs +45 -1
- package/dist/lib/flow/index-flow.cjs +67 -1
- package/dist/lib/flow/index-flow.d.ts +5 -5
- package/dist/lib/flow/index-flow.js +4 -4
- package/dist/lib/flow/index-flow.mjs +46 -1
- package/dist/lib/flow/index.cjs +805 -1
- package/dist/lib/flow/index.mjs +792 -1
- package/dist/lib/flow/portal.cjs +538 -1
- package/dist/lib/flow/portal.mjs +519 -1
- package/dist/lib/flow/show.cjs +81 -1
- package/dist/lib/flow/show.d.ts +1 -1
- package/dist/lib/flow/show.d.ts.map +1 -1
- package/dist/lib/flow/show.js +12 -118
- package/dist/lib/flow/show.mjs +67 -1
- package/dist/lib/flow/style-map.cjs +43 -1
- package/dist/lib/flow/style-map.d.ts +3 -3
- package/dist/lib/flow/style-map.js +4 -4
- package/dist/lib/flow/style-map.mjs +22 -1
- package/dist/lib/flow/switch.cjs +91 -1
- package/dist/lib/flow/switch.d.ts +3 -3
- package/dist/lib/flow/switch.d.ts.map +1 -1
- package/dist/lib/flow/switch.js +7 -7
- package/dist/lib/flow/switch.mjs +70 -1
- package/dist/lib/flow/utils.cjs +44 -1
- package/dist/lib/flow/utils.d.ts +1 -1
- package/dist/lib/flow/utils.js +1 -1
- package/dist/lib/flow/utils.mjs +23 -1
- package/dist/lib/html.cjs +32 -1
- package/dist/lib/html.d.ts +6 -6
- package/dist/lib/html.js +5 -5
- package/dist/lib/html.mjs +11 -1
- package/dist/lib/index.cjs +3104 -1
- package/dist/lib/index.d.ts +0 -1
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +2 -3
- package/dist/lib/index.mjs +3097 -1
- package/dist/lib/shared/types.cjs +18 -1
- package/dist/lib/shared/types.d.ts +8 -8
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/version.generated.cjs +26 -1
- package/dist/version.generated.d.ts +1 -1
- package/dist/version.generated.js +2 -2
- package/dist/version.generated.mjs +5 -1
- package/package.json +7 -6
- package/dist/lib/jsx/control-flow/flow.cjs +0 -1
- package/dist/lib/jsx/control-flow/flow.d.ts +0 -2
- package/dist/lib/jsx/control-flow/flow.d.ts.map +0 -1
- package/dist/lib/jsx/control-flow/flow.js +0 -627
- package/dist/lib/jsx/control-flow/flow.mjs +0 -0
- package/dist/lib/jsx/control-flow/for-flow.cjs +0 -1
- package/dist/lib/jsx/control-flow/for-flow.d.ts +0 -2
- package/dist/lib/jsx/control-flow/for-flow.d.ts.map +0 -1
- package/dist/lib/jsx/control-flow/for-flow.js +0 -1
- package/dist/lib/jsx/control-flow/for-flow.mjs +0 -0
package/dist/lib/flow/portal.cjs
CHANGED
|
@@ -1 +1,538 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/lib/flow/portal.ts
|
|
21
|
+
var portal_exports = {};
|
|
22
|
+
__export(portal_exports, {
|
|
23
|
+
Portal: () => Portal
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(portal_exports);
|
|
26
|
+
var import_signal3 = require("@fluixi/reactive/signal");
|
|
27
|
+
|
|
28
|
+
// src/lib/dom/runtime.ts
|
|
29
|
+
var import_signal = require("@fluixi/reactive/signal");
|
|
30
|
+
|
|
31
|
+
// src/lib/component/modifiers.ts
|
|
32
|
+
function isComponent(value) {
|
|
33
|
+
return typeof value === "function" && value[/* @__PURE__ */ Symbol.for("fluixi-component")] === true;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// src/lib/dom/runtime.ts
|
|
37
|
+
var import_signal2 = require("@fluixi/reactive/signal");
|
|
38
|
+
|
|
39
|
+
// src/lib/dom/server/host.ts
|
|
40
|
+
var SERVER_NODE = /* @__PURE__ */ Symbol.for("fluixi.server-node");
|
|
41
|
+
var STATE = /* @__PURE__ */ Symbol.for("fluixi.dom.server-host");
|
|
42
|
+
var realm = globalThis;
|
|
43
|
+
var state = realm[STATE] ??= {
|
|
44
|
+
server: typeof document === "undefined",
|
|
45
|
+
nodes: null
|
|
46
|
+
};
|
|
47
|
+
function isServer() {
|
|
48
|
+
return state.server;
|
|
49
|
+
}
|
|
50
|
+
function getServerNodes() {
|
|
51
|
+
if (!state.nodes) {
|
|
52
|
+
throw new Error("[fluixi] server render ran before @fluixi/dom/server loaded");
|
|
53
|
+
}
|
|
54
|
+
return state.nodes;
|
|
55
|
+
}
|
|
56
|
+
function isDomNode(x) {
|
|
57
|
+
if (x != null && x[SERVER_NODE] === true) return true;
|
|
58
|
+
return typeof Node !== "undefined" && x instanceof Node;
|
|
59
|
+
}
|
|
60
|
+
function isDomText(x) {
|
|
61
|
+
if (x != null && x[SERVER_NODE] === true) return x.nodeType === 3;
|
|
62
|
+
return typeof Text !== "undefined" && x instanceof Text;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// src/lib/dom/hydration-state.ts
|
|
66
|
+
var hydration = {
|
|
67
|
+
active: false,
|
|
68
|
+
cursor: null,
|
|
69
|
+
parents: []
|
|
70
|
+
};
|
|
71
|
+
var _walker = null;
|
|
72
|
+
function getHydrationWalker() {
|
|
73
|
+
return _walker;
|
|
74
|
+
}
|
|
75
|
+
function isAdopted(parent, node) {
|
|
76
|
+
return hydration.active && node.parentNode === parent;
|
|
77
|
+
}
|
|
78
|
+
function ascendPast(node) {
|
|
79
|
+
const idx = hydration.parents.lastIndexOf(node);
|
|
80
|
+
if (idx !== -1) hydration.parents.length = idx;
|
|
81
|
+
hydration.cursor = node.nextSibling;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// src/lib/dom/runtime.ts
|
|
85
|
+
var HOLE_TAG = "__fx_at";
|
|
86
|
+
function createTextNode(value, anchor = false) {
|
|
87
|
+
if (isServer()) return getServerNodes().createText(value);
|
|
88
|
+
if (hydration.active && !anchor) {
|
|
89
|
+
const node = getHydrationWalker()?.hydrateText(value);
|
|
90
|
+
if (node) return node;
|
|
91
|
+
}
|
|
92
|
+
return document.createTextNode(value);
|
|
93
|
+
}
|
|
94
|
+
var _insertDepth = 0;
|
|
95
|
+
var MAX_INSERT_DEPTH = 200;
|
|
96
|
+
function _createInsertEffect(getAccessor, parent, marker, initialCurrent, setCurrent) {
|
|
97
|
+
let current = initialCurrent;
|
|
98
|
+
const componentCache = /* @__PURE__ */ new Map();
|
|
99
|
+
return (0, import_signal2.createRenderEffect)(() => {
|
|
100
|
+
(0, import_signal2.reportReactiveBinding)(marker ?? parent, "content", void 0, getAccessor);
|
|
101
|
+
let value;
|
|
102
|
+
if (isComponent(getAccessor) && !(0, import_signal.isSignal)(getAccessor)) {
|
|
103
|
+
if (!componentCache.has(getAccessor)) {
|
|
104
|
+
_insertDepth++;
|
|
105
|
+
try {
|
|
106
|
+
const inst = getAccessor();
|
|
107
|
+
componentCache.set(getAccessor, inst);
|
|
108
|
+
} finally {
|
|
109
|
+
_insertDepth--;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
value = componentCache.get(getAccessor);
|
|
113
|
+
while (typeof value === "function" && (0, import_signal.isSignal)(value)) value = value();
|
|
114
|
+
} else {
|
|
115
|
+
value = getAccessor();
|
|
116
|
+
while (typeof value === "function" && (0, import_signal.isSignal)(value)) {
|
|
117
|
+
value = value();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
{
|
|
121
|
+
let chainDepth = 0;
|
|
122
|
+
while (typeof value === "function" && chainDepth++ < 50) {
|
|
123
|
+
if (isComponent(value)) {
|
|
124
|
+
if (!componentCache.has(value)) {
|
|
125
|
+
const thunk = value;
|
|
126
|
+
_insertDepth++;
|
|
127
|
+
try {
|
|
128
|
+
const inst = thunk();
|
|
129
|
+
componentCache.set(thunk, inst);
|
|
130
|
+
} finally {
|
|
131
|
+
_insertDepth--;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
value = componentCache.get(value);
|
|
135
|
+
} else if ((0, import_signal.isSignal)(value)) {
|
|
136
|
+
value = value();
|
|
137
|
+
} else {
|
|
138
|
+
value = value();
|
|
139
|
+
if (typeof value !== "function" || !(0, import_signal.isSignal)(value) && !isComponent(value)) break;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
_insertDepth++;
|
|
144
|
+
try {
|
|
145
|
+
current = insertExpression(parent, value, marker, current, componentCache);
|
|
146
|
+
setCurrent(current);
|
|
147
|
+
} finally {
|
|
148
|
+
_insertDepth--;
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
function insert(parent, accessor, marker, init) {
|
|
153
|
+
if (_insertDepth > MAX_INSERT_DEPTH) {
|
|
154
|
+
console.error("[insert] Exceeded max call depth, possible infinite loop.");
|
|
155
|
+
return () => null;
|
|
156
|
+
}
|
|
157
|
+
if (marker !== void 0 && !marker) {
|
|
158
|
+
marker = createTextNode("", true);
|
|
159
|
+
parent.appendChild(marker);
|
|
160
|
+
}
|
|
161
|
+
let current = init ?? null;
|
|
162
|
+
const isReactiveArray = (element) => {
|
|
163
|
+
return Array.isArray(element) && element.some((v) => typeof v === "function");
|
|
164
|
+
};
|
|
165
|
+
const normalizeAccessor = (accessor2) => {
|
|
166
|
+
if (typeof accessor2 === "function") return accessor2;
|
|
167
|
+
return () => accessor2;
|
|
168
|
+
};
|
|
169
|
+
if (typeof accessor !== "function" && !isReactiveArray(accessor)) {
|
|
170
|
+
_insertDepth++;
|
|
171
|
+
try {
|
|
172
|
+
current = insertExpression(parent, accessor, marker, current);
|
|
173
|
+
} finally {
|
|
174
|
+
_insertDepth--;
|
|
175
|
+
}
|
|
176
|
+
return () => current;
|
|
177
|
+
}
|
|
178
|
+
const dispose = _createInsertEffect(
|
|
179
|
+
normalizeAccessor(accessor),
|
|
180
|
+
parent,
|
|
181
|
+
marker,
|
|
182
|
+
current,
|
|
183
|
+
(v) => {
|
|
184
|
+
current = v;
|
|
185
|
+
}
|
|
186
|
+
);
|
|
187
|
+
return () => {
|
|
188
|
+
dispose?.();
|
|
189
|
+
return current;
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
function insertExpression(parent, value, marker, current, componentCache) {
|
|
193
|
+
if (value == null || typeof value === "boolean") {
|
|
194
|
+
return cleanChildren(parent, current, marker);
|
|
195
|
+
}
|
|
196
|
+
if (typeof value === "function") {
|
|
197
|
+
while (typeof value === "function") {
|
|
198
|
+
value = value();
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if (value == null || typeof value === "boolean") {
|
|
202
|
+
return cleanChildren(parent, current, marker);
|
|
203
|
+
}
|
|
204
|
+
if (isPromise(value)) {
|
|
205
|
+
const placeholder = createTextNode("", true);
|
|
206
|
+
if (Array.isArray(current)) {
|
|
207
|
+
if (current.length > 0) {
|
|
208
|
+
parent.replaceChild(placeholder, current[0]);
|
|
209
|
+
cleanChildren(parent, current.slice(1), marker);
|
|
210
|
+
} else {
|
|
211
|
+
insertBefore(parent, placeholder, marker);
|
|
212
|
+
}
|
|
213
|
+
} else if (current) {
|
|
214
|
+
parent.replaceChild(placeholder, current);
|
|
215
|
+
} else {
|
|
216
|
+
insertBefore(parent, placeholder, marker);
|
|
217
|
+
}
|
|
218
|
+
value.then((resolved) => {
|
|
219
|
+
if (placeholder.parentNode === parent) {
|
|
220
|
+
insertExpression(parent, resolved, placeholder.nextSibling, placeholder);
|
|
221
|
+
}
|
|
222
|
+
}).catch((err) => {
|
|
223
|
+
console.error("Error resolving promise in insertExpression:", err);
|
|
224
|
+
});
|
|
225
|
+
return placeholder;
|
|
226
|
+
}
|
|
227
|
+
const t = typeof value;
|
|
228
|
+
if (t === "string" || t === "number") {
|
|
229
|
+
if (t === "number") value = String(value);
|
|
230
|
+
if (Array.isArray(current)) {
|
|
231
|
+
if (current.length === 0) {
|
|
232
|
+
const node2 = createTextNode(value);
|
|
233
|
+
insertBefore(parent, node2, marker);
|
|
234
|
+
return node2;
|
|
235
|
+
}
|
|
236
|
+
if (current.length === 1 && current[0].nodeType === 3) {
|
|
237
|
+
current[0].data = value;
|
|
238
|
+
return current;
|
|
239
|
+
}
|
|
240
|
+
current = cleanChildren(parent, current, marker);
|
|
241
|
+
}
|
|
242
|
+
if (current && isDomText(current)) {
|
|
243
|
+
current.data = value;
|
|
244
|
+
return current;
|
|
245
|
+
}
|
|
246
|
+
const node = createTextNode(value);
|
|
247
|
+
if (current && current.parentNode === parent) {
|
|
248
|
+
parent.replaceChild(node, current);
|
|
249
|
+
} else if (!isAdopted(parent, node)) {
|
|
250
|
+
insertBefore(parent, node, marker);
|
|
251
|
+
}
|
|
252
|
+
return node;
|
|
253
|
+
}
|
|
254
|
+
if (isDomNode(value)) {
|
|
255
|
+
if (isAdopted(parent, value)) {
|
|
256
|
+
ascendPast(value);
|
|
257
|
+
return value;
|
|
258
|
+
}
|
|
259
|
+
if (Array.isArray(current)) {
|
|
260
|
+
if (current.length === 0) {
|
|
261
|
+
insertBefore(parent, value, marker);
|
|
262
|
+
} else if (current[0].parentNode === parent) {
|
|
263
|
+
parent.replaceChild(value, current[0]);
|
|
264
|
+
cleanChildren(parent, current.slice(1), marker);
|
|
265
|
+
} else {
|
|
266
|
+
insertBefore(parent, value, marker);
|
|
267
|
+
}
|
|
268
|
+
return value;
|
|
269
|
+
}
|
|
270
|
+
if (!current) {
|
|
271
|
+
insertBefore(parent, value, marker);
|
|
272
|
+
} else if (current !== value) {
|
|
273
|
+
if (current.parentNode === parent) {
|
|
274
|
+
parent.replaceChild(value, current);
|
|
275
|
+
} else {
|
|
276
|
+
insertBefore(parent, value, marker);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return value;
|
|
280
|
+
}
|
|
281
|
+
if (Array.isArray(value)) {
|
|
282
|
+
const array = [];
|
|
283
|
+
const currentArray = Array.isArray(current) ? current : current ? [current] : [];
|
|
284
|
+
const reactiveSlots = [];
|
|
285
|
+
flattenArray(value, array, parent, marker, true, componentCache, reactiveSlots);
|
|
286
|
+
const reconciled = reconcileArrays(parent, currentArray, array, marker);
|
|
287
|
+
for (const slot of reactiveSlots) {
|
|
288
|
+
const disposeSlot = insert(parent, slot.sig, slot.marker);
|
|
289
|
+
(0, import_signal2.onCleanup)(() => {
|
|
290
|
+
cleanChildren(parent, disposeSlot());
|
|
291
|
+
if (slot.marker.parentNode === parent) parent.removeChild(slot.marker);
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
return reconciled;
|
|
295
|
+
}
|
|
296
|
+
if (t === "object" && value !== null && typeof value === "object") {
|
|
297
|
+
const objValue = value;
|
|
298
|
+
if ("type" in objValue && "props" in objValue) {
|
|
299
|
+
const jsxValue = objValue;
|
|
300
|
+
if (typeof jsxValue.type === "function") {
|
|
301
|
+
const result = jsxValue.type(jsxValue.props || {});
|
|
302
|
+
return insertExpression(parent, result, marker, current);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
return cleanChildren(parent, current, marker);
|
|
307
|
+
}
|
|
308
|
+
function flattenArray(arr, result, parent, marker, track = true, componentCache, reactiveSlots) {
|
|
309
|
+
for (let i = 0; i < arr.length; i++) {
|
|
310
|
+
let item = arr[i];
|
|
311
|
+
if (item == null || typeof item === "boolean") continue;
|
|
312
|
+
while (typeof item === "function" && !isPromise(item) && !(0, import_signal.isSignal)(item) && !isComponent(item)) {
|
|
313
|
+
item = item();
|
|
314
|
+
if (item == null || typeof item === "boolean") break;
|
|
315
|
+
}
|
|
316
|
+
if (item == null || typeof item === "boolean") continue;
|
|
317
|
+
if (typeof item === "function") {
|
|
318
|
+
let resolved;
|
|
319
|
+
if (isComponent(item) && !(0, import_signal.isSignal)(item)) {
|
|
320
|
+
if (!componentCache) componentCache = /* @__PURE__ */ new Map();
|
|
321
|
+
if (!componentCache.has(item)) componentCache.set(item, item());
|
|
322
|
+
resolved = componentCache.get(item);
|
|
323
|
+
} else {
|
|
324
|
+
resolved = item();
|
|
325
|
+
}
|
|
326
|
+
while (typeof resolved === "function" && !isPromise(resolved) && !(0, import_signal.isSignal)(resolved) && !isComponent(resolved)) {
|
|
327
|
+
if (!componentCache) componentCache = /* @__PURE__ */ new Map();
|
|
328
|
+
if (!componentCache.has(resolved)) componentCache.set(resolved, resolved());
|
|
329
|
+
resolved = componentCache.get(resolved);
|
|
330
|
+
}
|
|
331
|
+
if (resolved == null || typeof resolved === "boolean") continue;
|
|
332
|
+
if (typeof resolved === "function") {
|
|
333
|
+
if ((0, import_signal.isSignal)(resolved)) {
|
|
334
|
+
if (reactiveSlots) {
|
|
335
|
+
const slot = createTextNode("", true);
|
|
336
|
+
result.push(slot);
|
|
337
|
+
reactiveSlots.push({ marker: slot, sig: resolved });
|
|
338
|
+
continue;
|
|
339
|
+
}
|
|
340
|
+
let val = resolved();
|
|
341
|
+
while (typeof val === "function" && (0, import_signal.isSignal)(val)) val = val();
|
|
342
|
+
if (val == null || typeof val === "boolean") continue;
|
|
343
|
+
if (Array.isArray(val)) {
|
|
344
|
+
flattenArray(val, result, parent, marker, track, componentCache);
|
|
345
|
+
} else flattenArray([val], result, parent, marker, track, componentCache);
|
|
346
|
+
continue;
|
|
347
|
+
}
|
|
348
|
+
continue;
|
|
349
|
+
}
|
|
350
|
+
if (Array.isArray(resolved)) flattenArray(resolved, result, parent, marker, track, componentCache, reactiveSlots);
|
|
351
|
+
else flattenArray([resolved], result, parent, marker, track, componentCache, reactiveSlots);
|
|
352
|
+
continue;
|
|
353
|
+
}
|
|
354
|
+
if (isPromise(item)) {
|
|
355
|
+
const placeholder = createTextNode("", true);
|
|
356
|
+
result.push(placeholder);
|
|
357
|
+
item.then((resolved) => {
|
|
358
|
+
if (placeholder.parentNode) {
|
|
359
|
+
const tempNodes = [];
|
|
360
|
+
flattenArray([resolved], tempNodes, placeholder.parentNode, void 0, false, componentCache);
|
|
361
|
+
if (tempNodes.length > 0) {
|
|
362
|
+
placeholder.parentNode.replaceChild(tempNodes[0], placeholder);
|
|
363
|
+
for (let j = 1; j < tempNodes.length; j++) {
|
|
364
|
+
placeholder.parentNode?.insertBefore(tempNodes[j], tempNodes[j - 1].nextSibling);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}).catch((err) => console.error("Error resolving promise in array:", err));
|
|
369
|
+
continue;
|
|
370
|
+
}
|
|
371
|
+
if (Array.isArray(item)) {
|
|
372
|
+
flattenArray(item, result, parent, marker, track, componentCache, reactiveSlots);
|
|
373
|
+
continue;
|
|
374
|
+
}
|
|
375
|
+
if (isDomNode(item)) {
|
|
376
|
+
result.push(item);
|
|
377
|
+
continue;
|
|
378
|
+
}
|
|
379
|
+
if (typeof item === "object" && item !== null && "type" in item && "props" in item) {
|
|
380
|
+
const jsxItem = item;
|
|
381
|
+
if (typeof jsxItem.type === "function") {
|
|
382
|
+
const resolved = jsxItem.type(jsxItem.props || {});
|
|
383
|
+
if (Array.isArray(resolved)) flattenArray(resolved, result, parent, marker, false, componentCache);
|
|
384
|
+
else flattenArray([resolved], result, parent, marker, false, componentCache);
|
|
385
|
+
continue;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
if (typeof item === "string" || typeof item === "number") {
|
|
389
|
+
const str = String(item);
|
|
390
|
+
if (str.trim() === "" && str !== " ") continue;
|
|
391
|
+
result.push(createTextNode(str));
|
|
392
|
+
continue;
|
|
393
|
+
}
|
|
394
|
+
result.push(createTextNode(String(item)));
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
function reconcileArrays(parent, a, b, marker) {
|
|
398
|
+
for (let i = 0; i < b.length; i++) {
|
|
399
|
+
const owner = b[i].parentNode;
|
|
400
|
+
if (owner !== null && owner !== parent && owner.nodeType !== 11) {
|
|
401
|
+
b = b.slice();
|
|
402
|
+
b[i] = b[i].cloneNode(true);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
let bLength = b.length, aEnd = a.length, bEnd = bLength, aStart = 0, bStart = 0, after = aEnd > 0 ? a[aEnd - 1].nextSibling ?? void 0 : marker, map = null;
|
|
406
|
+
while (aStart < aEnd || bStart < bEnd) {
|
|
407
|
+
if (a[aStart] === b[bStart]) {
|
|
408
|
+
aStart++;
|
|
409
|
+
bStart++;
|
|
410
|
+
continue;
|
|
411
|
+
}
|
|
412
|
+
while (aEnd > aStart && bEnd > bStart && a[aEnd - 1] === b[bEnd - 1]) {
|
|
413
|
+
aEnd--;
|
|
414
|
+
bEnd--;
|
|
415
|
+
}
|
|
416
|
+
if (aEnd === aStart) {
|
|
417
|
+
const node = bEnd < bLength ? bStart ? b[bStart - 1].nextSibling ?? void 0 : b[bEnd - bStart] : after;
|
|
418
|
+
while (bStart < bEnd) insertBefore(parent, b[bStart++], node);
|
|
419
|
+
} else if (bEnd === bStart) {
|
|
420
|
+
while (aStart < aEnd) {
|
|
421
|
+
if ((!map || !map.has(a[aStart])) && a[aStart].parentNode === parent)
|
|
422
|
+
parent.removeChild(a[aStart]);
|
|
423
|
+
aStart++;
|
|
424
|
+
}
|
|
425
|
+
} else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
|
|
426
|
+
const node = a[--aEnd].nextSibling;
|
|
427
|
+
insertBefore(parent, b[bStart++], a[aStart++].nextSibling);
|
|
428
|
+
insertBefore(parent, b[--bEnd], node);
|
|
429
|
+
a[aEnd] = a[aStart - 1];
|
|
430
|
+
} else {
|
|
431
|
+
if (!map) {
|
|
432
|
+
map = /* @__PURE__ */ new Map();
|
|
433
|
+
let i = bStart;
|
|
434
|
+
while (i < bEnd) map.set(b[i], i++);
|
|
435
|
+
}
|
|
436
|
+
const index = map.get(a[aStart]);
|
|
437
|
+
if (index != null) {
|
|
438
|
+
if (bStart < index && index < bEnd) {
|
|
439
|
+
let i = aStart, sequence = 1;
|
|
440
|
+
while (++i < aEnd && i < bEnd) {
|
|
441
|
+
if (!map.has(a[i]) || map.get(a[i]) !== index + sequence) break;
|
|
442
|
+
sequence++;
|
|
443
|
+
}
|
|
444
|
+
if (sequence > index - bStart) {
|
|
445
|
+
const node = a[aStart];
|
|
446
|
+
while (bStart < index) insertBefore(parent, b[bStart++], node);
|
|
447
|
+
} else {
|
|
448
|
+
if (a[aStart].parentNode === parent) {
|
|
449
|
+
parent.replaceChild(b[bStart++], a[aStart++]);
|
|
450
|
+
} else {
|
|
451
|
+
insertBefore(parent, b[bStart++], after);
|
|
452
|
+
aStart++;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
} else {
|
|
456
|
+
aStart++;
|
|
457
|
+
}
|
|
458
|
+
} else {
|
|
459
|
+
if (a[aStart].parentNode === parent) parent.removeChild(a[aStart]);
|
|
460
|
+
aStart++;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
return b;
|
|
465
|
+
}
|
|
466
|
+
function cleanChildren(parent, current, marker) {
|
|
467
|
+
if (current) {
|
|
468
|
+
if (Array.isArray(current)) {
|
|
469
|
+
for (let i = 0; i < current.length; i++) {
|
|
470
|
+
if (current[i].parentNode === parent) parent.removeChild(current[i]);
|
|
471
|
+
}
|
|
472
|
+
} else if (current.parentNode === parent) {
|
|
473
|
+
parent.removeChild(current);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
return null;
|
|
477
|
+
}
|
|
478
|
+
function insertBefore(parent, node, marker) {
|
|
479
|
+
if (hydration.active && node.parentNode === parent) return;
|
|
480
|
+
if (marker) {
|
|
481
|
+
if (marker.parentNode === parent) {
|
|
482
|
+
parent.insertBefore(node, marker);
|
|
483
|
+
} else {
|
|
484
|
+
parent.appendChild(node);
|
|
485
|
+
}
|
|
486
|
+
} else {
|
|
487
|
+
parent.appendChild(node);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
function handleRef(ref, element) {
|
|
491
|
+
if (!ref) return;
|
|
492
|
+
const held = ref[HOLE_TAG]?.name;
|
|
493
|
+
(0, import_signal2.reportReactiveDirective)(
|
|
494
|
+
element,
|
|
495
|
+
"ref",
|
|
496
|
+
held || (typeof ref === "function" ? ref.name || "ref" : "ref"),
|
|
497
|
+
ref
|
|
498
|
+
);
|
|
499
|
+
if (isDomNode(ref)) {
|
|
500
|
+
const actualRef = element;
|
|
501
|
+
const actualElement = ref;
|
|
502
|
+
if (!actualRef) return;
|
|
503
|
+
if (typeof actualRef === "function") actualRef(actualElement);
|
|
504
|
+
else if (typeof actualRef === "object" && "current" in actualRef) actualRef.current = actualElement;
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
if (typeof ref === "function") ref(element);
|
|
508
|
+
else if (typeof ref === "object" && "current" in ref) ref.current = element;
|
|
509
|
+
}
|
|
510
|
+
function isPromise(v) {
|
|
511
|
+
return v != null && (typeof v === "object" || typeof v === "function") && typeof v.then === "function" || v instanceof Promise;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
// src/lib/flow/portal.ts
|
|
515
|
+
function Portal(props) {
|
|
516
|
+
const getMount = () => {
|
|
517
|
+
if (!props.mount) return document.body;
|
|
518
|
+
return typeof props.mount === "function" ? props.mount() : props.mount;
|
|
519
|
+
};
|
|
520
|
+
let dispose;
|
|
521
|
+
let container;
|
|
522
|
+
(0, import_signal3.createRoot)((d) => {
|
|
523
|
+
dispose = d;
|
|
524
|
+
container = document.createElement("div");
|
|
525
|
+
container.style.display = "contents";
|
|
526
|
+
const target = getMount();
|
|
527
|
+
target.appendChild(container);
|
|
528
|
+
const inserted = insert(container, props.children);
|
|
529
|
+
if (inserted) {
|
|
530
|
+
handleRef(props.ref, container);
|
|
531
|
+
}
|
|
532
|
+
});
|
|
533
|
+
(0, import_signal3.onCleanup)(() => {
|
|
534
|
+
dispose();
|
|
535
|
+
container.remove();
|
|
536
|
+
});
|
|
537
|
+
return null;
|
|
538
|
+
}
|