hono 4.5.6 → 4.5.7
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/README.md +1 -1
- package/dist/cjs/client/utils.js +2 -2
- package/dist/cjs/jsx/dom/context.js +1 -1
- package/dist/cjs/jsx/dom/intrinsic-element/components.js +43 -28
- package/dist/cjs/jsx/dom/jsx-dev-runtime.js +9 -5
- package/dist/cjs/jsx/dom/render.js +153 -86
- package/dist/cjs/jsx/dom/utils.js +0 -15
- package/dist/cjs/jsx/hooks/index.js +6 -5
- package/dist/cjs/validator/validator.js +1 -1
- package/dist/client/utils.js +2 -2
- package/dist/jsx/dom/context.js +2 -2
- package/dist/jsx/dom/intrinsic-element/components.js +43 -28
- package/dist/jsx/dom/jsx-dev-runtime.js +9 -5
- package/dist/jsx/dom/render.js +153 -86
- package/dist/jsx/dom/utils.js +0 -14
- package/dist/jsx/hooks/index.js +6 -5
- package/dist/types/client/utils.d.ts +1 -1
- package/dist/types/jsx/dom/render.d.ts +2 -1
- package/dist/types/jsx/dom/utils.d.ts +0 -6
- package/dist/types/jsx/intrinsic-elements.d.ts +27 -19
- package/dist/types/utils/types.d.ts +5 -0
- package/dist/validator/validator.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -62,7 +62,7 @@ The migration guide is available on [docs/MIGRATION.md](docs/MIGRATION.md).
|
|
|
62
62
|
|
|
63
63
|
## Communication
|
|
64
64
|
|
|
65
|
-
[
|
|
65
|
+
[X](https://x.com/honojs) and [Discord channel](https://discord.gg/KMh2eNSdxV) are available.
|
|
66
66
|
|
|
67
67
|
## Contributing
|
|
68
68
|
|
package/dist/cjs/client/utils.js
CHANGED
|
@@ -33,8 +33,8 @@ const mergePath = (base, path) => {
|
|
|
33
33
|
};
|
|
34
34
|
const replaceUrlParam = (urlString, params) => {
|
|
35
35
|
for (const [k, v] of Object.entries(params)) {
|
|
36
|
-
const reg = new RegExp("/:" + k + "(?:{[^/]+})
|
|
37
|
-
urlString = urlString.replace(reg, `/${v}`);
|
|
36
|
+
const reg = new RegExp("/:" + k + "(?:{[^/]+})?\\??");
|
|
37
|
+
urlString = urlString.replace(reg, v ? `/${v}` : "");
|
|
38
38
|
}
|
|
39
39
|
return urlString;
|
|
40
40
|
};
|
|
@@ -50,7 +50,7 @@ const createContextProviderFunction = (values) => ({ value, children }) => {
|
|
|
50
50
|
}),
|
|
51
51
|
props: {}
|
|
52
52
|
});
|
|
53
|
-
const res =
|
|
53
|
+
const res = { tag: "", props, type: "" };
|
|
54
54
|
res[import_constants.DOM_ERROR_HANDLER] = (err) => {
|
|
55
55
|
values.pop();
|
|
56
56
|
throw err;
|
|
@@ -30,7 +30,6 @@ __export(components_exports, {
|
|
|
30
30
|
title: () => title
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(components_exports);
|
|
33
|
-
var import_utils = require("../utils");
|
|
34
33
|
var import_render = require("../render");
|
|
35
34
|
var import_context = require("../../context");
|
|
36
35
|
var import_hooks = require("../../hooks");
|
|
@@ -69,10 +68,12 @@ let blockingPromiseMap = /* @__PURE__ */ Object.create(null);
|
|
|
69
68
|
let createdElements = /* @__PURE__ */ Object.create(null);
|
|
70
69
|
const documentMetadataTag = (tag, props, preserveNodeType, supportSort, supportBlocking) => {
|
|
71
70
|
if (props?.itemProp) {
|
|
72
|
-
return
|
|
71
|
+
return {
|
|
73
72
|
tag,
|
|
74
|
-
props
|
|
75
|
-
|
|
73
|
+
props,
|
|
74
|
+
type: tag,
|
|
75
|
+
ref: props.ref
|
|
76
|
+
};
|
|
76
77
|
}
|
|
77
78
|
const head = document.head;
|
|
78
79
|
let { onLoad, onError, precedence, blocking, ...restProps } = props;
|
|
@@ -188,13 +189,15 @@ const documentMetadataTag = (tag, props, preserveNodeType, supportSort, supportB
|
|
|
188
189
|
(0, import_hooks.use)(promise);
|
|
189
190
|
}
|
|
190
191
|
}
|
|
191
|
-
const jsxNode =
|
|
192
|
+
const jsxNode = {
|
|
192
193
|
tag,
|
|
194
|
+
type: tag,
|
|
193
195
|
props: {
|
|
194
196
|
...restProps,
|
|
195
197
|
ref
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
+
},
|
|
199
|
+
ref
|
|
200
|
+
};
|
|
198
201
|
jsxNode.p = preserveNodeType;
|
|
199
202
|
if (element) {
|
|
200
203
|
jsxNode.e = element;
|
|
@@ -208,28 +211,34 @@ const title = (props) => {
|
|
|
208
211
|
const nameSpaceContext = (0, import_render.getNameSpaceContext)();
|
|
209
212
|
const ns = nameSpaceContext && (0, import_context.useContext)(nameSpaceContext);
|
|
210
213
|
if (ns?.endsWith("svg")) {
|
|
211
|
-
return
|
|
214
|
+
return {
|
|
212
215
|
tag: "title",
|
|
213
|
-
props
|
|
214
|
-
|
|
216
|
+
props,
|
|
217
|
+
type: "title",
|
|
218
|
+
ref: props.ref
|
|
219
|
+
};
|
|
215
220
|
}
|
|
216
221
|
return documentMetadataTag("title", props, void 0, false, false);
|
|
217
222
|
};
|
|
218
223
|
const script = (props) => {
|
|
219
224
|
if (!props || ["src", "async"].some((k) => !props[k])) {
|
|
220
|
-
return
|
|
221
|
-
tag: "
|
|
222
|
-
props
|
|
223
|
-
|
|
225
|
+
return {
|
|
226
|
+
tag: "script",
|
|
227
|
+
props,
|
|
228
|
+
type: "script",
|
|
229
|
+
ref: props.ref
|
|
230
|
+
};
|
|
224
231
|
}
|
|
225
232
|
return documentMetadataTag("script", props, 1, false, true);
|
|
226
233
|
};
|
|
227
234
|
const style = (props) => {
|
|
228
235
|
if (!props || !["href", "precedence"].every((k) => k in props)) {
|
|
229
|
-
return
|
|
236
|
+
return {
|
|
230
237
|
tag: "style",
|
|
231
|
-
props
|
|
232
|
-
|
|
238
|
+
props,
|
|
239
|
+
type: "style",
|
|
240
|
+
ref: props.ref
|
|
241
|
+
};
|
|
233
242
|
}
|
|
234
243
|
props["data-href"] = props.href;
|
|
235
244
|
delete props.href;
|
|
@@ -237,10 +246,12 @@ const style = (props) => {
|
|
|
237
246
|
};
|
|
238
247
|
const link = (props) => {
|
|
239
248
|
if (!props || ["onLoad", "onError"].some((k) => k in props) || props.rel === "stylesheet" && (!("precedence" in props) || "disabled" in props)) {
|
|
240
|
-
return
|
|
249
|
+
return {
|
|
241
250
|
tag: "link",
|
|
242
|
-
props
|
|
243
|
-
|
|
251
|
+
props,
|
|
252
|
+
type: "link",
|
|
253
|
+
ref: props.ref
|
|
254
|
+
};
|
|
244
255
|
}
|
|
245
256
|
return documentMetadataTag("link", props, 1, "precedence" in props, true);
|
|
246
257
|
};
|
|
@@ -281,7 +292,7 @@ const form = (props) => {
|
|
|
281
292
|
});
|
|
282
293
|
const [data, isDirty] = state;
|
|
283
294
|
state[1] = false;
|
|
284
|
-
return
|
|
295
|
+
return {
|
|
285
296
|
tag: import_hooks2.FormContext,
|
|
286
297
|
props: {
|
|
287
298
|
value: {
|
|
@@ -290,16 +301,18 @@ const form = (props) => {
|
|
|
290
301
|
method: data ? "post" : null,
|
|
291
302
|
action: data ? action : null
|
|
292
303
|
},
|
|
293
|
-
children:
|
|
304
|
+
children: {
|
|
294
305
|
tag: "form",
|
|
295
306
|
props: {
|
|
296
307
|
...restProps,
|
|
297
308
|
ref
|
|
298
|
-
}
|
|
299
|
-
|
|
309
|
+
},
|
|
310
|
+
type: "form",
|
|
311
|
+
ref
|
|
312
|
+
}
|
|
300
313
|
},
|
|
301
314
|
f: isDirty
|
|
302
|
-
}
|
|
315
|
+
};
|
|
303
316
|
};
|
|
304
317
|
const formActionableElement = (tag, {
|
|
305
318
|
formAction,
|
|
@@ -319,10 +332,12 @@ const formActionableElement = (tag, {
|
|
|
319
332
|
};
|
|
320
333
|
});
|
|
321
334
|
}
|
|
322
|
-
return
|
|
335
|
+
return {
|
|
323
336
|
tag,
|
|
324
|
-
props
|
|
325
|
-
|
|
337
|
+
props,
|
|
338
|
+
type: tag,
|
|
339
|
+
ref: props.ref
|
|
340
|
+
};
|
|
326
341
|
};
|
|
327
342
|
const input = (props) => formActionableElement("input", props);
|
|
328
343
|
const button = (props) => formActionableElement("button", props);
|
|
@@ -28,14 +28,18 @@ __export(jsx_dev_runtime_exports, {
|
|
|
28
28
|
jsxDEV: () => jsxDEV
|
|
29
29
|
});
|
|
30
30
|
module.exports = __toCommonJS(jsx_dev_runtime_exports);
|
|
31
|
-
var import_utils = require("./utils");
|
|
32
31
|
var intrinsicElementTags = __toESM(require("./intrinsic-element/components"), 1);
|
|
33
32
|
const jsxDEV = (tag, props, key) => {
|
|
34
|
-
|
|
35
|
-
tag
|
|
33
|
+
if (typeof tag === "string" && intrinsicElementTags[tag]) {
|
|
34
|
+
tag = intrinsicElementTags[tag];
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
tag,
|
|
38
|
+
type: tag,
|
|
36
39
|
props,
|
|
37
|
-
key
|
|
38
|
-
|
|
40
|
+
key,
|
|
41
|
+
ref: props.ref
|
|
42
|
+
};
|
|
39
43
|
};
|
|
40
44
|
const Fragment = (props) => jsxDEV("", props, void 0);
|
|
41
45
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -35,7 +35,6 @@ var import_context = require("../context");
|
|
|
35
35
|
var import_hooks = require("../hooks");
|
|
36
36
|
var import_utils = require("../utils");
|
|
37
37
|
var import_context2 = require("./context");
|
|
38
|
-
var import_utils2 = require("./utils");
|
|
39
38
|
const HONO_PORTAL_ELEMENT = "_hp";
|
|
40
39
|
const eventAliasMap = {
|
|
41
40
|
Change: "Input",
|
|
@@ -45,36 +44,47 @@ const nameSpaceMap = {
|
|
|
45
44
|
svg: "2000/svg",
|
|
46
45
|
math: "1998/Math/MathML"
|
|
47
46
|
};
|
|
48
|
-
const skipProps = /* @__PURE__ */ new Set(["children"]);
|
|
49
47
|
const buildDataStack = [];
|
|
50
48
|
const refCleanupMap = /* @__PURE__ */ new WeakMap();
|
|
51
49
|
let nameSpaceContext = void 0;
|
|
52
50
|
const getNameSpaceContext = () => nameSpaceContext;
|
|
53
51
|
const isNodeString = (node) => "t" in node;
|
|
52
|
+
const eventCache = {
|
|
53
|
+
onClick: ["click", false]
|
|
54
|
+
};
|
|
54
55
|
const getEventSpec = (key) => {
|
|
56
|
+
if (!key.startsWith("on")) {
|
|
57
|
+
return void 0;
|
|
58
|
+
}
|
|
59
|
+
if (eventCache[key]) {
|
|
60
|
+
return eventCache[key];
|
|
61
|
+
}
|
|
55
62
|
const match = key.match(/^on([A-Z][a-zA-Z]+?(?:PointerCapture)?)(Capture)?$/);
|
|
56
63
|
if (match) {
|
|
57
64
|
const [, eventName, capture] = match;
|
|
58
|
-
return [(eventAliasMap[eventName] || eventName).toLowerCase(), !!capture];
|
|
65
|
+
return eventCache[key] = [(eventAliasMap[eventName] || eventName).toLowerCase(), !!capture];
|
|
59
66
|
}
|
|
60
67
|
return void 0;
|
|
61
68
|
};
|
|
62
|
-
const toAttributeName = (element, key) => element instanceof SVGElement && /[A-Z]/.test(key) && (key in element.style || key.match(/^(?:o|pai|str|u|ve)/)) ? key.replace(/([A-Z])/g, "-$1").toLowerCase() : key;
|
|
69
|
+
const toAttributeName = (element, key) => nameSpaceContext && element instanceof SVGElement && /[A-Z]/.test(key) && (key in element.style || key.match(/^(?:o|pai|str|u|ve)/)) ? key.replace(/([A-Z])/g, "-$1").toLowerCase() : key;
|
|
63
70
|
const applyProps = (container, attributes, oldAttributes) => {
|
|
64
71
|
attributes ||= {};
|
|
65
|
-
for (let
|
|
66
|
-
|
|
72
|
+
for (let key in attributes) {
|
|
73
|
+
const value = attributes[key];
|
|
74
|
+
if (key !== "children" && (!oldAttributes || oldAttributes[key] !== value)) {
|
|
67
75
|
key = (0, import_utils.normalizeIntrinsicElementKey)(key);
|
|
68
76
|
const eventSpec = getEventSpec(key);
|
|
69
77
|
if (eventSpec) {
|
|
70
|
-
if (oldAttributes) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (
|
|
75
|
-
|
|
78
|
+
if (oldAttributes?.[key] !== value) {
|
|
79
|
+
if (oldAttributes) {
|
|
80
|
+
container.removeEventListener(eventSpec[0], oldAttributes[key], eventSpec[1]);
|
|
81
|
+
}
|
|
82
|
+
if (value != null) {
|
|
83
|
+
if (typeof value !== "function") {
|
|
84
|
+
throw new Error(`Event handler for "${key}" is not a function`);
|
|
85
|
+
}
|
|
86
|
+
container.addEventListener(eventSpec[0], value, eventSpec[1]);
|
|
76
87
|
}
|
|
77
|
-
container.addEventListener(eventSpec[0], value, eventSpec[1]);
|
|
78
88
|
}
|
|
79
89
|
} else if (key === "dangerouslySetInnerHTML" && value) {
|
|
80
90
|
container.innerHTML = value.__html;
|
|
@@ -98,8 +108,8 @@ const applyProps = (container, attributes, oldAttributes) => {
|
|
|
98
108
|
}
|
|
99
109
|
}
|
|
100
110
|
} else {
|
|
101
|
-
const nodeName = container.nodeName;
|
|
102
111
|
if (key === "value") {
|
|
112
|
+
const nodeName = container.nodeName;
|
|
103
113
|
if (nodeName === "INPUT" || nodeName === "TEXTAREA" || nodeName === "SELECT") {
|
|
104
114
|
;
|
|
105
115
|
container.value = value === null || value === void 0 || value === false ? null : value;
|
|
@@ -114,7 +124,7 @@ const applyProps = (container, attributes, oldAttributes) => {
|
|
|
114
124
|
continue;
|
|
115
125
|
}
|
|
116
126
|
}
|
|
117
|
-
} else if (key === "checked" && nodeName === "INPUT" || key === "selected" && nodeName === "OPTION") {
|
|
127
|
+
} else if (key === "checked" && container.nodeName === "INPUT" || key === "selected" && container.nodeName === "OPTION") {
|
|
118
128
|
;
|
|
119
129
|
container[key] = value;
|
|
120
130
|
}
|
|
@@ -132,8 +142,9 @@ const applyProps = (container, attributes, oldAttributes) => {
|
|
|
132
142
|
}
|
|
133
143
|
}
|
|
134
144
|
if (oldAttributes) {
|
|
135
|
-
for (let
|
|
136
|
-
|
|
145
|
+
for (let key in oldAttributes) {
|
|
146
|
+
const value = oldAttributes[key];
|
|
147
|
+
if (key !== "children" && !(key in attributes)) {
|
|
137
148
|
key = (0, import_utils.normalizeIntrinsicElementKey)(key);
|
|
138
149
|
const eventSpec = getEventSpec(key);
|
|
139
150
|
if (eventSpec) {
|
|
@@ -148,27 +159,24 @@ const applyProps = (container, attributes, oldAttributes) => {
|
|
|
148
159
|
}
|
|
149
160
|
};
|
|
150
161
|
const invokeTag = (context, node) => {
|
|
151
|
-
if (node.s) {
|
|
152
|
-
const res = node.s;
|
|
153
|
-
node.s = void 0;
|
|
154
|
-
return res;
|
|
155
|
-
}
|
|
156
162
|
node[import_constants.DOM_STASH][0] = 0;
|
|
157
163
|
buildDataStack.push([context, node]);
|
|
158
164
|
const func = node.tag[import_constants.DOM_RENDERER] || node.tag;
|
|
165
|
+
const props = func.defaultProps ? {
|
|
166
|
+
...func.defaultProps,
|
|
167
|
+
...node.props
|
|
168
|
+
} : node.props;
|
|
159
169
|
try {
|
|
160
|
-
return [
|
|
161
|
-
func.call(null, {
|
|
162
|
-
...func.defaultProps || {},
|
|
163
|
-
...node.props
|
|
164
|
-
})
|
|
165
|
-
];
|
|
170
|
+
return [func.call(null, props)];
|
|
166
171
|
} finally {
|
|
167
172
|
buildDataStack.pop();
|
|
168
173
|
}
|
|
169
174
|
};
|
|
170
175
|
const getNextChildren = (node, container, nextChildren, childrenToRemove, callbacks) => {
|
|
171
|
-
|
|
176
|
+
if (node.vR?.length) {
|
|
177
|
+
childrenToRemove.push(...node.vR);
|
|
178
|
+
delete node.vR;
|
|
179
|
+
}
|
|
172
180
|
if (typeof node.tag === "function") {
|
|
173
181
|
node[import_constants.DOM_STASH][1][import_hooks.STASH_EFFECT]?.forEach((data) => callbacks.push(data));
|
|
174
182
|
}
|
|
@@ -178,16 +186,33 @@ const getNextChildren = (node, container, nextChildren, childrenToRemove, callba
|
|
|
178
186
|
} else {
|
|
179
187
|
if (typeof child.tag === "function" || child.tag === "") {
|
|
180
188
|
child.c = container;
|
|
189
|
+
const currentNextChildrenIndex = nextChildren.length;
|
|
181
190
|
getNextChildren(child, container, nextChildren, childrenToRemove, callbacks);
|
|
191
|
+
if (child.s) {
|
|
192
|
+
for (let i = currentNextChildrenIndex; i < nextChildren.length; i++) {
|
|
193
|
+
nextChildren[i].s = true;
|
|
194
|
+
}
|
|
195
|
+
child.s = false;
|
|
196
|
+
}
|
|
182
197
|
} else {
|
|
183
198
|
nextChildren.push(child);
|
|
184
|
-
|
|
199
|
+
if (child.vR?.length) {
|
|
200
|
+
childrenToRemove.push(...child.vR);
|
|
201
|
+
delete child.vR;
|
|
202
|
+
}
|
|
185
203
|
}
|
|
186
204
|
}
|
|
187
205
|
});
|
|
188
206
|
};
|
|
189
207
|
const findInsertBefore = (node) => {
|
|
190
|
-
|
|
208
|
+
for (; ; node = node.tag === HONO_PORTAL_ELEMENT || !node.vC || !node.pP ? node.nN : node.vC[0]) {
|
|
209
|
+
if (!node) {
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
if (node.tag !== HONO_PORTAL_ELEMENT && node.e) {
|
|
213
|
+
return node.e;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
191
216
|
};
|
|
192
217
|
const removeNode = (node) => {
|
|
193
218
|
if (!isNodeString(node)) {
|
|
@@ -209,16 +234,9 @@ const removeNode = (node) => {
|
|
|
209
234
|
node.a = true;
|
|
210
235
|
}
|
|
211
236
|
};
|
|
212
|
-
const apply = (node, container) => {
|
|
237
|
+
const apply = (node, container, isNew) => {
|
|
213
238
|
node.c = container;
|
|
214
|
-
applyNodeObject(node, container);
|
|
215
|
-
};
|
|
216
|
-
const applyNode = (node, container) => {
|
|
217
|
-
if (isNodeString(node)) {
|
|
218
|
-
container.textContent = node.t;
|
|
219
|
-
} else {
|
|
220
|
-
applyNodeObject(node, container);
|
|
221
|
-
}
|
|
239
|
+
applyNodeObject(node, container, isNew);
|
|
222
240
|
};
|
|
223
241
|
const findChildNodeIndex = (childNodes, child) => {
|
|
224
242
|
if (!child) {
|
|
@@ -232,39 +250,81 @@ const findChildNodeIndex = (childNodes, child) => {
|
|
|
232
250
|
return;
|
|
233
251
|
};
|
|
234
252
|
const cancelBuild = Symbol();
|
|
235
|
-
const applyNodeObject = (node, container) => {
|
|
253
|
+
const applyNodeObject = (node, container, isNew) => {
|
|
236
254
|
const next = [];
|
|
237
255
|
const remove = [];
|
|
238
256
|
const callbacks = [];
|
|
239
257
|
getNextChildren(node, container, next, remove, callbacks);
|
|
240
|
-
|
|
241
|
-
|
|
258
|
+
remove.forEach(removeNode);
|
|
259
|
+
const childNodes = isNew ? void 0 : container.childNodes;
|
|
260
|
+
let offset;
|
|
261
|
+
if (isNew) {
|
|
262
|
+
offset = -1;
|
|
263
|
+
} else {
|
|
264
|
+
offset = (childNodes.length && (findChildNodeIndex(childNodes, findInsertBefore(node.nN)) ?? findChildNodeIndex(
|
|
265
|
+
childNodes,
|
|
266
|
+
next.find((n) => n.tag !== HONO_PORTAL_ELEMENT && n.e)?.e
|
|
267
|
+
))) ?? -1;
|
|
268
|
+
if (offset === -1) {
|
|
269
|
+
isNew = true;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
242
272
|
for (let i = 0, len = next.length; i < len; i++, offset++) {
|
|
243
273
|
const child = next[i];
|
|
244
274
|
let el;
|
|
245
|
-
if (
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
}
|
|
249
|
-
child.d = false;
|
|
250
|
-
el = child.e ||= document.createTextNode(child.t);
|
|
275
|
+
if (child.s && child.e) {
|
|
276
|
+
el = child.e;
|
|
277
|
+
child.s = false;
|
|
251
278
|
} else {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
279
|
+
const isNewLocal = isNew || !child.e;
|
|
280
|
+
if (isNodeString(child)) {
|
|
281
|
+
if (child.e && child.d) {
|
|
282
|
+
child.e.textContent = child.t;
|
|
283
|
+
}
|
|
284
|
+
child.d = false;
|
|
285
|
+
el = child.e ||= document.createTextNode(child.t);
|
|
286
|
+
} else {
|
|
287
|
+
el = child.e ||= child.n ? document.createElementNS(child.n, child.tag) : document.createElement(child.tag);
|
|
288
|
+
applyProps(el, child.props, child.pP);
|
|
289
|
+
applyNodeObject(child, el, isNewLocal);
|
|
290
|
+
}
|
|
255
291
|
}
|
|
256
292
|
if (child.tag === HONO_PORTAL_ELEMENT) {
|
|
257
293
|
offset--;
|
|
258
|
-
} else if (
|
|
259
|
-
|
|
294
|
+
} else if (isNew) {
|
|
295
|
+
if (!el.parentNode) {
|
|
296
|
+
container.appendChild(el);
|
|
297
|
+
}
|
|
298
|
+
} else if (childNodes[offset] !== el && childNodes[offset - 1] !== el) {
|
|
299
|
+
if (childNodes[offset + 1] === el) {
|
|
300
|
+
container.appendChild(childNodes[offset]);
|
|
301
|
+
} else {
|
|
302
|
+
container.insertBefore(el, childNodes[offset] || null);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
if (node.pP) {
|
|
307
|
+
delete node.pP;
|
|
308
|
+
}
|
|
309
|
+
if (callbacks.length) {
|
|
310
|
+
const useLayoutEffectCbs = [];
|
|
311
|
+
const useEffectCbs = [];
|
|
312
|
+
callbacks.forEach(([, useLayoutEffectCb, , useEffectCb, useInsertionEffectCb]) => {
|
|
313
|
+
if (useLayoutEffectCb) {
|
|
314
|
+
useLayoutEffectCbs.push(useLayoutEffectCb);
|
|
315
|
+
}
|
|
316
|
+
if (useEffectCb) {
|
|
317
|
+
useEffectCbs.push(useEffectCb);
|
|
318
|
+
}
|
|
319
|
+
useInsertionEffectCb?.();
|
|
320
|
+
});
|
|
321
|
+
useLayoutEffectCbs.forEach((cb) => cb());
|
|
322
|
+
if (useEffectCbs.length) {
|
|
323
|
+
requestAnimationFrame(() => {
|
|
324
|
+
useEffectCbs.forEach((cb) => cb());
|
|
325
|
+
});
|
|
260
326
|
}
|
|
261
327
|
}
|
|
262
|
-
remove.forEach(removeNode);
|
|
263
|
-
callbacks.forEach(([, , , , cb]) => cb?.());
|
|
264
|
-
callbacks.forEach(([, cb]) => cb?.());
|
|
265
|
-
requestAnimationFrame(() => {
|
|
266
|
-
callbacks.forEach(([, , , cb]) => cb?.());
|
|
267
|
-
});
|
|
268
328
|
};
|
|
269
329
|
const fallbackUpdateFnArrayMap = /* @__PURE__ */ new WeakMap();
|
|
270
330
|
const build = (context, node, children) => {
|
|
@@ -279,30 +339,33 @@ const build = (context, node, children) => {
|
|
|
279
339
|
foundErrorHandler = children[0][import_constants.DOM_ERROR_HANDLER];
|
|
280
340
|
context[5].push([context, foundErrorHandler, node]);
|
|
281
341
|
}
|
|
282
|
-
const oldVChildren = buildWithPreviousChildren ? [...node.pC] : node.vC ? [...node.vC] :
|
|
342
|
+
const oldVChildren = buildWithPreviousChildren ? [...node.pC] : node.vC ? [...node.vC] : void 0;
|
|
283
343
|
const vChildren = [];
|
|
284
|
-
node.vR = buildWithPreviousChildren ? [...node.vC] : [];
|
|
285
344
|
let prevNode;
|
|
286
|
-
children.
|
|
287
|
-
|
|
345
|
+
for (let i = 0; i < children.length; i++) {
|
|
346
|
+
if (Array.isArray(children[i])) {
|
|
347
|
+
children.splice(i, 1, ...children[i].flat());
|
|
348
|
+
}
|
|
349
|
+
let child = buildNode(children[i]);
|
|
288
350
|
if (child) {
|
|
289
351
|
if (typeof child.tag === "function" && !child.tag[import_constants.DOM_INTERNAL_TAG]) {
|
|
290
352
|
if (import_context.globalContexts.length > 0) {
|
|
291
|
-
child[import_constants.DOM_STASH][2] = import_context.globalContexts.map((
|
|
353
|
+
child[import_constants.DOM_STASH][2] = import_context.globalContexts.map((c) => [c, c.values.at(-1)]);
|
|
292
354
|
}
|
|
293
355
|
if (context[5]?.length) {
|
|
294
356
|
child[import_constants.DOM_STASH][3] = context[5].at(-1);
|
|
295
357
|
}
|
|
296
358
|
}
|
|
297
359
|
let oldChild;
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
360
|
+
if (oldVChildren && oldVChildren.length) {
|
|
361
|
+
const i2 = oldVChildren.findIndex(
|
|
362
|
+
isNodeString(child) ? (c) => isNodeString(c) : child.key !== void 0 ? (c) => c.key === child.key && c.tag === child.tag : (c) => c.tag === child.tag
|
|
363
|
+
);
|
|
364
|
+
if (i2 !== -1) {
|
|
365
|
+
oldChild = oldVChildren[i2];
|
|
366
|
+
oldVChildren.splice(i2, 1);
|
|
367
|
+
}
|
|
304
368
|
}
|
|
305
|
-
let skipBuild = false;
|
|
306
369
|
if (oldChild) {
|
|
307
370
|
if (isNodeString(child)) {
|
|
308
371
|
if (oldChild.t !== child.t) {
|
|
@@ -311,8 +374,6 @@ const build = (context, node, children) => {
|
|
|
311
374
|
oldChild.d = true;
|
|
312
375
|
}
|
|
313
376
|
child = oldChild;
|
|
314
|
-
} else if (oldChild.tag !== child.tag) {
|
|
315
|
-
node.vR.push(oldChild);
|
|
316
377
|
} else {
|
|
317
378
|
const pP = oldChild.pP = oldChild.props;
|
|
318
379
|
oldChild.props = child.props;
|
|
@@ -323,7 +384,9 @@ const build = (context, node, children) => {
|
|
|
323
384
|
if (!oldChild.f) {
|
|
324
385
|
const prevPropsKeys = Object.keys(pP);
|
|
325
386
|
const currentProps = oldChild.props;
|
|
326
|
-
|
|
387
|
+
if (prevPropsKeys.length === Object.keys(currentProps).length && prevPropsKeys.every((k) => k in currentProps && currentProps[k] === pP[k])) {
|
|
388
|
+
oldChild.s = true;
|
|
389
|
+
}
|
|
327
390
|
}
|
|
328
391
|
}
|
|
329
392
|
child = oldChild;
|
|
@@ -334,19 +397,21 @@ const build = (context, node, children) => {
|
|
|
334
397
|
child.n = ns;
|
|
335
398
|
}
|
|
336
399
|
}
|
|
337
|
-
if (!isNodeString(child) && !
|
|
400
|
+
if (!isNodeString(child) && !child.s) {
|
|
338
401
|
build(context, child);
|
|
339
402
|
delete child.f;
|
|
340
403
|
}
|
|
341
404
|
vChildren.push(child);
|
|
342
|
-
|
|
343
|
-
p
|
|
405
|
+
if (prevNode && !prevNode.s && !child.s) {
|
|
406
|
+
for (let p = prevNode; p && !isNodeString(p); p = p.vC?.at(-1)) {
|
|
407
|
+
p.nN = child;
|
|
408
|
+
}
|
|
344
409
|
}
|
|
345
410
|
prevNode = child;
|
|
346
411
|
}
|
|
347
|
-
}
|
|
412
|
+
}
|
|
413
|
+
node.vR = buildWithPreviousChildren ? [...node.vC, ...oldVChildren || []] : oldVChildren || [];
|
|
348
414
|
node.vC = vChildren;
|
|
349
|
-
node.vR.push(...oldVChildren);
|
|
350
415
|
if (buildWithPreviousChildren) {
|
|
351
416
|
delete node.pC;
|
|
352
417
|
}
|
|
@@ -381,7 +446,7 @@ const build = (context, node, children) => {
|
|
|
381
446
|
} else {
|
|
382
447
|
build(context, errorHandlerNode, [fallback]);
|
|
383
448
|
if ((errorHandler.length === 1 || context !== errorHandlerContext) && errorHandlerNode.c) {
|
|
384
|
-
apply(errorHandlerNode, errorHandlerNode.c);
|
|
449
|
+
apply(errorHandlerNode, errorHandlerNode.c, false);
|
|
385
450
|
return;
|
|
386
451
|
}
|
|
387
452
|
}
|
|
@@ -402,12 +467,14 @@ const buildNode = (node) => {
|
|
|
402
467
|
return { t: node.toString(), d: true };
|
|
403
468
|
} else {
|
|
404
469
|
if ("vR" in node) {
|
|
405
|
-
node =
|
|
470
|
+
node = {
|
|
406
471
|
tag: node.tag,
|
|
407
472
|
props: node.props,
|
|
408
473
|
key: node.key,
|
|
409
|
-
f: node.f
|
|
410
|
-
|
|
474
|
+
f: node.f,
|
|
475
|
+
type: node.tag,
|
|
476
|
+
ref: node.props.ref
|
|
477
|
+
};
|
|
411
478
|
}
|
|
412
479
|
if (typeof node.tag === "function") {
|
|
413
480
|
;
|
|
@@ -453,7 +520,7 @@ const updateSync = (context, node) => {
|
|
|
453
520
|
c.values.pop();
|
|
454
521
|
});
|
|
455
522
|
if (context[0] !== 1 || !context[1]) {
|
|
456
|
-
apply(node, node.c);
|
|
523
|
+
apply(node, node.c, false);
|
|
457
524
|
}
|
|
458
525
|
};
|
|
459
526
|
const updateMap = /* @__PURE__ */ new WeakMap();
|
|
@@ -499,7 +566,7 @@ const renderNode = (node, container) => {
|
|
|
499
566
|
build(context, node, void 0);
|
|
500
567
|
context[4] = false;
|
|
501
568
|
const fragment = document.createDocumentFragment();
|
|
502
|
-
apply(node, fragment);
|
|
569
|
+
apply(node, fragment, true);
|
|
503
570
|
replaceContainer(node, fragment, container);
|
|
504
571
|
container.replaceChildren(fragment);
|
|
505
572
|
};
|
|
@@ -18,7 +18,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var utils_exports = {};
|
|
20
20
|
__export(utils_exports, {
|
|
21
|
-
newJSXNode: () => newJSXNode,
|
|
22
21
|
setInternalTagFlag: () => setInternalTagFlag
|
|
23
22
|
});
|
|
24
23
|
module.exports = __toCommonJS(utils_exports);
|
|
@@ -28,21 +27,7 @@ const setInternalTagFlag = (fn) => {
|
|
|
28
27
|
fn[import_constants.DOM_INTERNAL_TAG] = true;
|
|
29
28
|
return fn;
|
|
30
29
|
};
|
|
31
|
-
const JSXNodeCompatPrototype = {
|
|
32
|
-
type: {
|
|
33
|
-
get() {
|
|
34
|
-
return this.tag;
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
ref: {
|
|
38
|
-
get() {
|
|
39
|
-
return this.props?.ref;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
const newJSXNode = (obj) => Object.defineProperties(obj, JSXNodeCompatPrototype);
|
|
44
30
|
// Annotate the CommonJS export names for ESM import in node:
|
|
45
31
|
0 && (module.exports = {
|
|
46
|
-
newJSXNode,
|
|
47
32
|
setInternalTagFlag
|
|
48
33
|
});
|
|
@@ -214,13 +214,14 @@ const useState = (initialState) => {
|
|
|
214
214
|
];
|
|
215
215
|
};
|
|
216
216
|
const useReducer = (reducer, initialArg, init) => {
|
|
217
|
-
const
|
|
218
|
-
return [
|
|
219
|
-
state,
|
|
217
|
+
const handler = useCallback(
|
|
220
218
|
(action) => {
|
|
221
219
|
setState((state2) => reducer(state2, action));
|
|
222
|
-
}
|
|
223
|
-
|
|
220
|
+
},
|
|
221
|
+
[reducer]
|
|
222
|
+
);
|
|
223
|
+
const [state, setState] = useState(() => init ? init(initialArg) : initialArg);
|
|
224
|
+
return [state, handler];
|
|
224
225
|
};
|
|
225
226
|
const useEffectCommon = (index, effect, deps) => {
|
|
226
227
|
const buildData = import_render.buildDataStack.at(-1);
|