vinojs 0.1.0 → 0.1.2

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.
Files changed (115) hide show
  1. package/dist/client.mjs +1 -1
  2. package/dist/{compile-Lxl_tdxL.mjs → compile-glNMkyyx.mjs} +3 -47
  3. package/dist/compile-glNMkyyx.mjs.map +1 -0
  4. package/dist/{definePage-Ba4r-TFh.mjs → definePage--9Pz7rHs.mjs} +29 -7
  5. package/dist/definePage--9Pz7rHs.mjs.map +1 -0
  6. package/dist/defineServerFn-H-bz7xBX.mjs +47 -0
  7. package/dist/defineServerFn-H-bz7xBX.mjs.map +1 -0
  8. package/dist/factory-CVT0-OZw.d.mts +187 -0
  9. package/dist/factory-CVT0-OZw.d.mts.map +1 -0
  10. package/dist/factory.d.mts +2 -0
  11. package/dist/factory.mjs +153 -0
  12. package/dist/factory.mjs.map +1 -0
  13. package/dist/vino.d.mts +4 -103
  14. package/dist/vino.d.mts.map +1 -1
  15. package/dist/vino.mjs +8 -3
  16. package/dist/vino.mjs.map +1 -1
  17. package/dist/vite.mjs +3 -2
  18. package/dist/vite.mjs.map +1 -1
  19. package/package.json +5 -1
  20. package/dist/compile-Lxl_tdxL.mjs.map +0 -1
  21. package/dist/definePage-Ba4r-TFh.mjs.map +0 -1
  22. package/examples/basic/dist/client/.assetsignore +0 -2
  23. package/examples/basic/dist/client/about.html +0 -1
  24. package/examples/basic/dist/client/admin.html +0 -1
  25. package/examples/basic/dist/client/assets/Counter-BvqMZKON.js +0 -1
  26. package/examples/basic/dist/client/assets/_slug_-CYpOSbrn.js +0 -1
  27. package/examples/basic/dist/client/assets/about-BZXRzUyv.js +0 -1
  28. package/examples/basic/dist/client/assets/admin-DRE7uh2s.js +0 -1
  29. package/examples/basic/dist/client/assets/client-B6nFkut5.js +0 -1
  30. package/examples/basic/dist/client/assets/client-pages-Bc6cNZAm.js +0 -2
  31. package/examples/basic/dist/client/assets/components-DX9r6vHn.js +0 -1
  32. package/examples/basic/dist/client/assets/components-DsWJ6F73.js +0 -2
  33. package/examples/basic/dist/client/assets/counter-DBpvln_F.js +0 -1
  34. package/examples/basic/dist/client/assets/dom-B5sHIJ1E.js +0 -1
  35. package/examples/basic/dist/client/assets/honoto-9UtdLp4J.js +0 -33
  36. package/examples/basic/dist/client/assets/honoto-client-DEh86_WZ.css +0 -1
  37. package/examples/basic/dist/client/assets/honoto-client.js +0 -2
  38. package/examples/basic/dist/client/assets/hooks-Cz6AT21d.js +0 -1
  39. package/examples/basic/dist/client/assets/jsx-dev-runtime-92VDsVyo.js +0 -1
  40. package/examples/basic/dist/client/counter.html +0 -1
  41. package/examples/basic/dist/client/index.html +0 -1
  42. package/examples/basic/dist/client/jobs.html +0 -1
  43. package/examples/basic/dist/ssr/.vite/manifest.json +0 -140
  44. package/examples/basic/dist/ssr/assets/_slug_-CY3-kffX.js +0 -46
  45. package/examples/basic/dist/ssr/assets/about-CTDjNhkO.js +0 -15
  46. package/examples/basic/dist/ssr/assets/admin-DvS-UGJx.js +0 -26
  47. package/examples/basic/dist/ssr/assets/constants-UoriGYcX-CUecBFMT.js +0 -6
  48. package/examples/basic/dist/ssr/assets/counter-DfIbc9Sp.js +0 -30
  49. package/examples/basic/dist/ssr/assets/honoto-CA313cVy.js +0 -2129
  50. package/examples/basic/dist/ssr/assets/jobs-D9hh-UO9.js +0 -42
  51. package/examples/basic/dist/ssr/assets/jsx-CgYLQazd.js +0 -1080
  52. package/examples/basic/dist/ssr/assets/jsx-dev-runtime-BlUda7H8.js +0 -742
  53. package/examples/basic/dist/ssr/assets/jsx-renderer-CzZcZPnS.js +0 -65
  54. package/examples/basic/dist/ssr/assets/layout-DYvLwr2u.js +0 -53
  55. package/examples/basic/dist/ssr/assets/pages-DB6jeyrt.js +0 -53
  56. package/examples/basic/dist/ssr/assets/rolldown-runtime-D7D4PA-g.js +0 -13
  57. package/examples/basic/dist/ssr/assets/ssr-hooks-CBQr0cdH.js +0 -7
  58. package/examples/basic/dist/ssr/index.js +0 -22
  59. package/examples/basic/dist/ssr/wrangler.json +0 -1
  60. package/examples/full/dist/client/.assetsignore +0 -2
  61. package/examples/full/dist/client/assets/BookmarkButton-py0xGxgl.js +0 -1
  62. package/examples/full/dist/client/assets/_slug_-DZUFsE9O.js +0 -1
  63. package/examples/full/dist/client/assets/auth-client-D2Wtuobe.js +0 -1
  64. package/examples/full/dist/client/assets/bun-sqlite-dialect-C7ftEUSI-CsHdUKBY.js +0 -1
  65. package/examples/full/dist/client/assets/client-B6nFkut5.js +0 -1
  66. package/examples/full/dist/client/assets/client-pages-fshKs747.js +0 -2
  67. package/examples/full/dist/client/assets/components-DX9r6vHn.js +0 -1
  68. package/examples/full/dist/client/assets/components-S_-rWrKi.js +0 -2
  69. package/examples/full/dist/client/assets/d1-sqlite-dialect-BZmaVTp8-FPCaMZqX.js +0 -1
  70. package/examples/full/dist/client/assets/default-query-compiler-CUdqIu1h.js +0 -1
  71. package/examples/full/dist/client/assets/dist-BoGTNvkC.js +0 -1
  72. package/examples/full/dist/client/assets/dom-DCd3wYW7.js +0 -1
  73. package/examples/full/dist/client/assets/factory-Bgf4EtLx.js +0 -8
  74. package/examples/full/dist/client/assets/honoto-client-BSvNAnxN.css +0 -1
  75. package/examples/full/dist/client/assets/honoto-client.js +0 -2
  76. package/examples/full/dist/client/assets/hooks-Cz6AT21d.js +0 -1
  77. package/examples/full/dist/client/assets/jsx-dev-runtime-92VDsVyo.js +0 -1
  78. package/examples/full/dist/client/assets/kysely-adapter-BHhasAnc.js +0 -1
  79. package/examples/full/dist/client/assets/kysely-migration-tables-DFfmKhq--U5ujlMwE.js +0 -1
  80. package/examples/full/dist/client/assets/node-sqlite-dialect-DJDXH5Ot.js +0 -1
  81. package/examples/full/dist/client/assets/pages-CUQx6Eus.js +0 -1
  82. package/examples/full/dist/client/assets/saved-jIi74ncJ.js +0 -1
  83. package/examples/full/dist/client/assets/session-B-accyM3.js +0 -611
  84. package/examples/full/dist/client/assets/sign-in-BelI3gSs.js +0 -1
  85. package/examples/full/dist/client/assets/sign-up-pR94lfdu.js +0 -1
  86. package/examples/full/dist/client/index.html +0 -1
  87. package/examples/full/dist/client/saved.html +0 -1
  88. package/examples/full/dist/client/sign-in.html +0 -1
  89. package/examples/full/dist/client/sign-up.html +0 -1
  90. package/examples/full/dist/ssr/.dev.vars +0 -1
  91. package/examples/full/dist/ssr/.vite/manifest.json +0 -219
  92. package/examples/full/dist/ssr/assets/BookmarkButton-KS7z5_vi.js +0 -298
  93. package/examples/full/dist/ssr/assets/_slug_-rRStRaAN.js +0 -89
  94. package/examples/full/dist/ssr/assets/auth-DSFZ4iak.js +0 -31434
  95. package/examples/full/dist/ssr/assets/auth-client-BFSBVoML.js +0 -894
  96. package/examples/full/dist/ssr/assets/bun-sqlite-dialect-C7ftEUSI-BeXpIqKl.js +0 -162
  97. package/examples/full/dist/ssr/assets/compiled-query-DmoyCh28.js +0 -8410
  98. package/examples/full/dist/ssr/assets/d1-sqlite-dialect-BZmaVTp8-CjJdvL94.js +0 -114
  99. package/examples/full/dist/ssr/assets/default-query-compiler-D7xOzCCJ.js +0 -1727
  100. package/examples/full/dist/ssr/assets/dist-LmmDoNdk.js +0 -6832
  101. package/examples/full/dist/ssr/assets/dist-kFDN1l4Z.js +0 -342
  102. package/examples/full/dist/ssr/assets/factory-AD6s9SIW.js +0 -2079
  103. package/examples/full/dist/ssr/assets/jsx-renderer-mMLf5XLN.js +0 -1926
  104. package/examples/full/dist/ssr/assets/kysely-adapter-BCLenpM8.js +0 -2
  105. package/examples/full/dist/ssr/assets/kysely-migration-tables-DFfmKhq--BtVr6hRe.js +0 -17
  106. package/examples/full/dist/ssr/assets/layout-mVA7qP4j.js +0 -44
  107. package/examples/full/dist/ssr/assets/node-sqlite-dialect-D-wtYAD7.js +0 -162
  108. package/examples/full/dist/ssr/assets/pages-Do5kR_Ia.js +0 -147
  109. package/examples/full/dist/ssr/assets/saved-Dr4pP6B5.js +0 -111
  110. package/examples/full/dist/ssr/assets/session-BvIpX7tr.js +0 -13
  111. package/examples/full/dist/ssr/assets/sign-in-22pzTnJE.js +0 -115
  112. package/examples/full/dist/ssr/assets/sign-up-CN4j8Qg1.js +0 -117
  113. package/examples/full/dist/ssr/assets/sqlite-adapter-DVlms5wO.js +0 -79
  114. package/examples/full/dist/ssr/index.js +0 -97
  115. package/examples/full/dist/ssr/wrangler.json +0 -1
@@ -1,1080 +0,0 @@
1
- import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
- import { C as HtmlEscapedCallbackPhase, E as resolveCallback, S as DOM_STASH, T as raw, _ as createContext, a as normalizeIntrinsicElementKey, b as DOM_MEMO, c as dataPrecedenceAttr, d as isStylesheetLinkWithPrecedence, f as shouldDeDupeByKey, g as useContext, h as globalContexts, i as jsx, l as deDupeKeyMap, m as createContext$1, n as Fragment$1, o as styleObjectForEach, p as captureRenderContext, r as JSXNode, s as toArray, u as domRenderers, v as DOM_ERROR_HANDLER, x as DOM_RENDERER, y as DOM_INTERNAL_TAG } from "./jsx-dev-runtime-BlUda7H8.js";
3
- //#region ../../node_modules/.pnpm/hono@4.13.3/node_modules/hono/dist/jsx/dom/render.js
4
- var HONO_PORTAL_ELEMENT = "_hp";
5
- var eventAliasMap = {
6
- Change: "Input",
7
- DoubleClick: "DblClick"
8
- };
9
- var nameSpaceMap = {
10
- svg: "2000/svg",
11
- math: "1998/Math/MathML"
12
- };
13
- var buildDataStack = [];
14
- var refCleanupMap = /* @__PURE__ */ new WeakMap();
15
- var nameSpaceContext = void 0;
16
- var getNameSpaceContext = () => nameSpaceContext;
17
- var isNodeString = (node) => "t" in node;
18
- var eventCache = { onClick: ["click", false] };
19
- var getEventSpec = (key) => {
20
- if (!key.startsWith("on")) return;
21
- if (eventCache[key]) return eventCache[key];
22
- const match = key.match(/^on([A-Z][a-zA-Z]+?(?:PointerCapture)?)(Capture)?$/);
23
- if (match) {
24
- const [, eventName, capture] = match;
25
- return eventCache[key] = [(eventAliasMap[eventName] || eventName).toLowerCase(), !!capture];
26
- }
27
- };
28
- var 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;
29
- var normalizeFormValue = (value) => value === null || value === void 0 || value === false ? null : value;
30
- var applySelectValue = (select, props) => {
31
- if (!("value" in props)) return;
32
- select.value = normalizeFormValue(props["value"]);
33
- if (!select.multiple && select.selectedIndex === -1) select.selectedIndex = 0;
34
- };
35
- var isIgnorableAttributeError = (error) => error instanceof DOMException && error.name === "InvalidCharacterError";
36
- var applyProps = (container, attributes, oldAttributes) => {
37
- attributes ||= {};
38
- for (let key in attributes) {
39
- const value = attributes[key];
40
- if (key !== "children" && (!oldAttributes || oldAttributes[key] !== value)) {
41
- key = normalizeIntrinsicElementKey(key);
42
- const eventSpec = getEventSpec(key);
43
- if (eventSpec) {
44
- if (oldAttributes?.[key] !== value) {
45
- if (oldAttributes) container.removeEventListener(eventSpec[0], oldAttributes[key], eventSpec[1]);
46
- if (value != null) {
47
- if (typeof value !== "function") throw new Error(`Event handler for "${key}" is not a function`);
48
- container.addEventListener(eventSpec[0], value, eventSpec[1]);
49
- }
50
- }
51
- } else if (key === "dangerouslySetInnerHTML" && value) container.innerHTML = value.__html;
52
- else if (key === "ref") {
53
- let cleanup;
54
- if (typeof value === "function") cleanup = value(container) || (() => value(null));
55
- else if (value && "current" in value) {
56
- value.current = container;
57
- cleanup = () => value.current = null;
58
- }
59
- refCleanupMap.set(container, cleanup);
60
- } else if (key === "style") {
61
- const style = container.style;
62
- if (typeof value === "string") style.cssText = value;
63
- else {
64
- style.cssText = "";
65
- if (value != null) styleObjectForEach(value, style.setProperty.bind(style));
66
- }
67
- } else {
68
- if (key === "value") {
69
- const nodeName = container.nodeName;
70
- if (nodeName === "SELECT") continue;
71
- else if (nodeName === "INPUT" || nodeName === "TEXTAREA") {
72
- container.value = normalizeFormValue(value);
73
- if (nodeName === "TEXTAREA") {
74
- container.textContent = value;
75
- continue;
76
- }
77
- }
78
- } else if (key === "checked" && container.nodeName === "INPUT" || key === "selected" && container.nodeName === "OPTION") container[key] = value;
79
- const k = toAttributeName(container, key);
80
- try {
81
- if (value === null || value === void 0 || value === false) container.removeAttribute(k);
82
- else if (value === true) container.setAttribute(k, "");
83
- else if (typeof value === "string" || typeof value === "number") container.setAttribute(k, value);
84
- else container.setAttribute(k, value.toString());
85
- } catch (e) {
86
- if (!isIgnorableAttributeError(e)) throw e;
87
- }
88
- }
89
- }
90
- }
91
- if (oldAttributes) for (let key in oldAttributes) {
92
- const value = oldAttributes[key];
93
- if (key !== "children" && !(key in attributes)) {
94
- key = normalizeIntrinsicElementKey(key);
95
- const eventSpec = getEventSpec(key);
96
- if (eventSpec) container.removeEventListener(eventSpec[0], value, eventSpec[1]);
97
- else if (key === "ref") refCleanupMap.get(container)?.();
98
- else try {
99
- container.removeAttribute(toAttributeName(container, key));
100
- } catch (e) {
101
- if (!isIgnorableAttributeError(e)) throw e;
102
- }
103
- }
104
- }
105
- };
106
- var invokeTag = (context, node) => {
107
- node[DOM_STASH][0] = 0;
108
- buildDataStack.push([context, node]);
109
- const func = node.tag[DOM_RENDERER] || node.tag;
110
- const props = func.defaultProps ? {
111
- ...func.defaultProps,
112
- ...node.props
113
- } : node.props;
114
- try {
115
- return [func.call(null, props)];
116
- } finally {
117
- buildDataStack.pop();
118
- }
119
- };
120
- var getNextChildren = (node, container, nextChildren, childrenToRemove, callbacks) => {
121
- if (node.vR?.length) {
122
- childrenToRemove.push(...node.vR);
123
- delete node.vR;
124
- }
125
- if (typeof node.tag === "function") node[DOM_STASH][1][1]?.forEach((data) => callbacks.push(data));
126
- node.vC.forEach((child) => {
127
- if (isNodeString(child)) nextChildren.push(child);
128
- else if (typeof child.tag === "function" || child.tag === "") {
129
- child.c = container;
130
- const currentNextChildrenIndex = nextChildren.length;
131
- getNextChildren(child, container, nextChildren, childrenToRemove, callbacks);
132
- if (child.s) {
133
- for (let i = currentNextChildrenIndex; i < nextChildren.length; i++) nextChildren[i].s = true;
134
- child.s = false;
135
- }
136
- } else {
137
- nextChildren.push(child);
138
- if (child.vR?.length) {
139
- childrenToRemove.push(...child.vR);
140
- delete child.vR;
141
- }
142
- }
143
- });
144
- };
145
- var findInsertBefore = (node) => {
146
- while (node && (node.tag === HONO_PORTAL_ELEMENT || !node.e)) node = node.tag === HONO_PORTAL_ELEMENT || !node.vC?.[0] ? node.nN : node.vC[0];
147
- return node?.e;
148
- };
149
- var removeNode = (node) => {
150
- if (!isNodeString(node)) {
151
- node[DOM_STASH]?.[1][1]?.forEach((data) => data[2]?.());
152
- refCleanupMap.get(node.e)?.();
153
- if (node.p === 2) node.vC?.forEach((n) => n.p = 2);
154
- node.vC?.forEach(removeNode);
155
- }
156
- if (!node.p) {
157
- node.e?.remove();
158
- delete node.e;
159
- }
160
- if (typeof node.tag === "function") {
161
- updateMap.delete(node);
162
- fallbackUpdateFnArrayMap.delete(node);
163
- delete node[DOM_STASH][3];
164
- node.a = true;
165
- }
166
- };
167
- var apply = (node, container, isNew) => {
168
- node.c = container;
169
- applyNodeObject(node, container, isNew);
170
- };
171
- var findChildNodeIndex = (childNodes, child) => {
172
- if (!child) return;
173
- for (let i = 0, len = childNodes.length; i < len; i++) if (childNodes[i] === child) return i;
174
- };
175
- var cancelBuild = /* @__PURE__ */ Symbol();
176
- var applyNodeObject = (node, container, isNew) => {
177
- const next = [];
178
- const remove = [];
179
- const callbacks = [];
180
- getNextChildren(node, container, next, remove, callbacks);
181
- remove.forEach(removeNode);
182
- const childNodes = isNew ? void 0 : container.childNodes;
183
- let offset;
184
- let insertBeforeNode = null;
185
- if (isNew) offset = -1;
186
- else if (!childNodes.length) offset = 0;
187
- else {
188
- const offsetByNextNode = findChildNodeIndex(childNodes, findInsertBefore(node.nN));
189
- if (offsetByNextNode !== void 0) {
190
- insertBeforeNode = childNodes[offsetByNextNode];
191
- offset = offsetByNextNode;
192
- } else offset = findChildNodeIndex(childNodes, next.find((n) => n.tag !== HONO_PORTAL_ELEMENT && n.e)?.e) ?? -1;
193
- if (offset === -1) isNew = true;
194
- }
195
- for (let i = 0, len = next.length; i < len; i++, offset++) {
196
- const child = next[i];
197
- let el;
198
- if (child.s && child.e) {
199
- el = child.e;
200
- child.s = false;
201
- } else {
202
- const isNewLocal = isNew || !child.e;
203
- if (isNodeString(child)) {
204
- if (child.e && child.d) child.e.textContent = child.t;
205
- child.d = false;
206
- el = child.e ||= document.createTextNode(child.t);
207
- } else {
208
- el = child.e ||= child.n ? document.createElementNS(child.n, child.tag) : document.createElement(child.tag);
209
- applyProps(el, child.props, child.pP);
210
- applyNodeObject(child, el, isNewLocal);
211
- if (child.tag === "select") applySelectValue(el, child.props);
212
- }
213
- }
214
- if (child.tag === HONO_PORTAL_ELEMENT) offset--;
215
- else if (isNew) {
216
- if (!el.parentNode) container.appendChild(el);
217
- } else if (childNodes[offset] !== el && childNodes[offset - 1] !== el) {
218
- if (childNodes[offset + 1] === el) container.appendChild(childNodes[offset]);
219
- else container.insertBefore(el, insertBeforeNode || childNodes[offset] || null);
220
- }
221
- }
222
- if (node.pP) node.pP = void 0;
223
- if (callbacks.length) {
224
- const useLayoutEffectCbs = [];
225
- const useEffectCbs = [];
226
- callbacks.forEach(([, useLayoutEffectCb, , useEffectCb, useInsertionEffectCb]) => {
227
- if (useLayoutEffectCb) useLayoutEffectCbs.push(useLayoutEffectCb);
228
- if (useEffectCb) useEffectCbs.push(useEffectCb);
229
- useInsertionEffectCb?.();
230
- });
231
- useLayoutEffectCbs.forEach((cb) => cb());
232
- if (useEffectCbs.length) requestAnimationFrame(() => {
233
- useEffectCbs.forEach((cb) => cb());
234
- });
235
- }
236
- };
237
- var isSameContext = (oldContexts, newContexts) => !!(oldContexts && oldContexts.length === newContexts.length && oldContexts.every((ctx, i) => ctx[1] === newContexts[i][1]));
238
- var fallbackUpdateFnArrayMap = /* @__PURE__ */ new WeakMap();
239
- var build = (context, node, children) => {
240
- const buildWithPreviousChildren = !children && node.pC;
241
- if (children) node.pC ||= node.vC;
242
- let foundErrorHandler;
243
- try {
244
- children ||= typeof node.tag == "function" ? invokeTag(context, node) : toArray(node.props.children);
245
- if (children[0]?.tag === "" && children[0][DOM_ERROR_HANDLER]) {
246
- foundErrorHandler = children[0][DOM_ERROR_HANDLER];
247
- context[5].push([
248
- context,
249
- foundErrorHandler,
250
- node
251
- ]);
252
- }
253
- const oldVChildren = buildWithPreviousChildren ? [...node.pC] : node.vC ? [...node.vC] : void 0;
254
- const vChildren = [];
255
- let prevNode;
256
- for (let i = 0; i < children.length; i++) {
257
- if (Array.isArray(children[i])) {
258
- children.splice(i, 1, ...children[i].flat(Infinity));
259
- i--;
260
- continue;
261
- }
262
- let child = buildNode(children[i]);
263
- if (child) {
264
- if (typeof child.tag === "function" && !child.tag[DOM_INTERNAL_TAG]) {
265
- if (globalContexts.length > 0) child[DOM_STASH][2] = globalContexts.map((c) => [c, c.values.at(-1)]);
266
- if (context[5]?.length) child[DOM_STASH][3] = context[5].at(-1);
267
- }
268
- let oldChild;
269
- if (oldVChildren && oldVChildren.length) {
270
- const i2 = oldVChildren.findIndex(isNodeString(child) ? (c) => isNodeString(c) : child.key !== void 0 ? (c) => c.key === child.key && c.tag === child.tag : (c) => c.tag === child.tag);
271
- if (i2 !== -1) {
272
- oldChild = oldVChildren[i2];
273
- oldVChildren.splice(i2, 1);
274
- }
275
- }
276
- if (oldChild) {
277
- if (isNodeString(child)) {
278
- if (oldChild.t !== child.t) {
279
- oldChild.t = child.t;
280
- oldChild.d = true;
281
- }
282
- child = oldChild;
283
- } else {
284
- const pP = oldChild.pP = oldChild.props;
285
- oldChild.props = child.props;
286
- oldChild.f ||= child.f || node.f;
287
- if (typeof child.tag === "function") {
288
- const oldContexts = oldChild[DOM_STASH][2];
289
- oldChild[DOM_STASH][2] = child[DOM_STASH][2] || [];
290
- oldChild[DOM_STASH][3] = child[DOM_STASH][3];
291
- if (!oldChild.f && ((oldChild.o || oldChild) === child.o || oldChild.tag[DOM_MEMO]?.(pP, oldChild.props)) && isSameContext(oldContexts, oldChild[DOM_STASH][2])) oldChild.s = true;
292
- }
293
- child = oldChild;
294
- }
295
- } else if (!isNodeString(child) && nameSpaceContext) {
296
- const ns = useContext(nameSpaceContext);
297
- if (ns) child.n = ns;
298
- }
299
- if (!isNodeString(child) && !child.s) {
300
- build(context, child);
301
- delete child.f;
302
- }
303
- vChildren.push(child);
304
- if (prevNode && !prevNode.s && !child.s) for (let p = prevNode; p && !isNodeString(p); p = p.vC?.at(-1)) p.nN = child;
305
- prevNode = child;
306
- }
307
- }
308
- node.vR = buildWithPreviousChildren ? [...node.vC, ...oldVChildren || []] : oldVChildren || [];
309
- node.vC = vChildren;
310
- if (buildWithPreviousChildren) delete node.pC;
311
- } catch (e) {
312
- node.f = true;
313
- if (e === cancelBuild) {
314
- if (foundErrorHandler) return;
315
- else throw e;
316
- }
317
- const [errorHandlerContext, errorHandler, errorHandlerNode] = node[DOM_STASH]?.[3] || [];
318
- if (errorHandler) {
319
- const fallbackUpdateFn = () => update([
320
- 0,
321
- false,
322
- context[2]
323
- ], errorHandlerNode);
324
- const fallbackUpdateFnArray = fallbackUpdateFnArrayMap.get(errorHandlerNode) || [];
325
- fallbackUpdateFnArray.push(fallbackUpdateFn);
326
- fallbackUpdateFnArrayMap.set(errorHandlerNode, fallbackUpdateFnArray);
327
- const fallback = errorHandler(e, () => {
328
- const fnArray = fallbackUpdateFnArrayMap.get(errorHandlerNode);
329
- if (fnArray) {
330
- const i = fnArray.indexOf(fallbackUpdateFn);
331
- if (i !== -1) {
332
- fnArray.splice(i, 1);
333
- return fallbackUpdateFn();
334
- }
335
- }
336
- });
337
- if (fallback) {
338
- if (context[0] === 1) context[1] = true;
339
- else {
340
- build(context, errorHandlerNode, [fallback]);
341
- if ((errorHandler.length === 1 || context !== errorHandlerContext) && errorHandlerNode.c) {
342
- apply(errorHandlerNode, errorHandlerNode.c, false);
343
- return;
344
- }
345
- }
346
- throw cancelBuild;
347
- }
348
- }
349
- throw e;
350
- } finally {
351
- if (foundErrorHandler) context[5].pop();
352
- }
353
- };
354
- var buildNode = (node) => {
355
- if (node === void 0 || node === null || typeof node === "boolean") return;
356
- else if (typeof node === "string" || typeof node === "number") return {
357
- t: node.toString(),
358
- d: true
359
- };
360
- else {
361
- if ("vR" in node) node = {
362
- tag: node.tag,
363
- props: node.props,
364
- key: node.key,
365
- f: node.f,
366
- type: node.tag,
367
- ref: node.props.ref,
368
- o: node.o || node
369
- };
370
- if (typeof node.tag === "function") node[DOM_STASH] = [0, []];
371
- else {
372
- const ns = nameSpaceMap[node.tag];
373
- if (ns) {
374
- nameSpaceContext ||= createContext("");
375
- node.props.children = [{
376
- tag: nameSpaceContext,
377
- props: {
378
- value: node.n = `http://www.w3.org/${ns}`,
379
- children: node.props.children
380
- }
381
- }];
382
- }
383
- }
384
- return node;
385
- }
386
- };
387
- var updateSync = (context, node) => {
388
- node[DOM_STASH][2]?.forEach(([c, v]) => {
389
- c.values.push(v);
390
- });
391
- try {
392
- build(context, node, void 0);
393
- } catch {
394
- return;
395
- }
396
- if (node.a) {
397
- delete node.a;
398
- return;
399
- }
400
- node[DOM_STASH][2]?.forEach(([c]) => {
401
- c.values.pop();
402
- });
403
- if (context[0] !== 1 || !context[1]) apply(node, node.c, false);
404
- };
405
- var updateMap = /* @__PURE__ */ new WeakMap();
406
- var currentUpdateSets = [];
407
- var update = async (context, node) => {
408
- context[5] ||= [];
409
- const existing = updateMap.get(node);
410
- if (existing) existing[0](void 0);
411
- let resolve;
412
- const promise = new Promise((r) => resolve = r);
413
- updateMap.set(node, [resolve, () => {
414
- if (context[2]) context[2](context, node, (context2) => {
415
- updateSync(context2, node);
416
- }).then(() => resolve(node));
417
- else {
418
- updateSync(context, node);
419
- resolve(node);
420
- }
421
- }]);
422
- if (currentUpdateSets.length) currentUpdateSets.at(-1).add(node);
423
- else {
424
- await Promise.resolve();
425
- const latest = updateMap.get(node);
426
- if (latest) {
427
- updateMap.delete(node);
428
- latest[1]();
429
- }
430
- }
431
- return promise;
432
- };
433
- var createPortal = (children, container, key) => ({
434
- tag: HONO_PORTAL_ELEMENT,
435
- props: { children },
436
- key,
437
- e: container,
438
- p: 1
439
- });
440
- //#endregion
441
- //#region ../../node_modules/.pnpm/hono@4.13.3/node_modules/hono/dist/jsx/hooks/index.js
442
- var STASH_SATE = 0;
443
- var STASH_CALLBACK = 2;
444
- var STASH_MEMO = 3;
445
- var resolvedPromiseValueMap = /* @__PURE__ */ new WeakMap();
446
- var isDepsChanged = (prevDeps, deps) => !prevDeps || !deps || prevDeps.length !== deps.length || deps.some((dep, i) => dep !== prevDeps[i]);
447
- var updateHook = void 0;
448
- var pendingStack = [];
449
- var useState = (initialState) => {
450
- const resolveInitialState = () => typeof initialState === "function" ? initialState() : initialState;
451
- const buildData = buildDataStack.at(-1);
452
- if (!buildData) return [resolveInitialState(), () => {}];
453
- const [, node] = buildData;
454
- const stateArray = node[DOM_STASH][1][STASH_SATE] ||= [];
455
- const hookIndex = node[DOM_STASH][0]++;
456
- return stateArray[hookIndex] ||= [resolveInitialState(), (newState) => {
457
- const localUpdateHook = updateHook;
458
- const stateData = stateArray[hookIndex];
459
- if (typeof newState === "function") newState = newState(stateData[0]);
460
- if (!Object.is(newState, stateData[0])) {
461
- stateData[0] = newState;
462
- if (pendingStack.length) {
463
- const [pendingType, pendingPromise] = pendingStack.at(-1);
464
- Promise.all([pendingType === 3 ? node : update([
465
- pendingType,
466
- false,
467
- localUpdateHook
468
- ], node), pendingPromise]).then(([node2]) => {
469
- if (!node2 || !(pendingType === 2 || pendingType === 3)) return;
470
- const lastVC = node2.vC;
471
- const addUpdateTask = () => {
472
- setTimeout(() => {
473
- if (lastVC !== node2.vC) return;
474
- update([
475
- pendingType === 3 ? 1 : 0,
476
- false,
477
- localUpdateHook
478
- ], node2);
479
- });
480
- };
481
- requestAnimationFrame(addUpdateTask);
482
- });
483
- } else update([
484
- 0,
485
- false,
486
- localUpdateHook
487
- ], node);
488
- }
489
- }];
490
- };
491
- var useCallback = (callback, deps) => {
492
- const buildData = buildDataStack.at(-1);
493
- if (!buildData) return callback;
494
- const [, node] = buildData;
495
- const callbackArray = node[DOM_STASH][1][STASH_CALLBACK] ||= [];
496
- const hookIndex = node[DOM_STASH][0]++;
497
- const prevDeps = callbackArray[hookIndex];
498
- if (isDepsChanged(prevDeps?.[1], deps)) callbackArray[hookIndex] = [callback, deps];
499
- else callback = callbackArray[hookIndex][0];
500
- return callback;
501
- };
502
- var use = (promise) => {
503
- const cachedRes = resolvedPromiseValueMap.get(promise);
504
- if (cachedRes) {
505
- if (cachedRes.length === 2) throw cachedRes[1];
506
- return cachedRes[0];
507
- }
508
- promise.then((res) => resolvedPromiseValueMap.set(promise, [res]), (e) => resolvedPromiseValueMap.set(promise, [void 0, e]));
509
- throw promise;
510
- };
511
- var useMemo = (factory, deps) => {
512
- const buildData = buildDataStack.at(-1);
513
- if (!buildData) return factory();
514
- const [, node] = buildData;
515
- const memoArray = node[DOM_STASH][1][STASH_MEMO] ||= [];
516
- const hookIndex = node[DOM_STASH][0]++;
517
- const prevDeps = memoArray[hookIndex];
518
- if (isDepsChanged(prevDeps?.[1], deps)) memoArray[hookIndex] = [factory(), deps];
519
- return memoArray[hookIndex][0];
520
- };
521
- //#endregion
522
- //#region ../../node_modules/.pnpm/hono@4.13.3/node_modules/hono/dist/jsx/dom/hooks/index.js
523
- var FormContext = createContext({
524
- pending: false,
525
- data: null,
526
- method: null,
527
- action: null
528
- });
529
- var actions = /* @__PURE__ */ new Set();
530
- var registerAction = (action) => {
531
- actions.add(action);
532
- action.finally(() => actions.delete(action));
533
- };
534
- //#endregion
535
- //#region ../../node_modules/.pnpm/hono@4.13.3/node_modules/hono/dist/jsx/dom/intrinsic-element/components.js
536
- var components_exports = /* @__PURE__ */ __exportAll({
537
- button: () => button,
538
- clearCache: () => clearCache,
539
- composeRef: () => composeRef,
540
- form: () => form,
541
- input: () => input,
542
- link: () => link,
543
- meta: () => meta,
544
- script: () => script,
545
- style: () => style,
546
- title: () => title
547
- });
548
- var clearCache = () => {
549
- blockingPromiseMap = /* @__PURE__ */ Object.create(null);
550
- createdElements = /* @__PURE__ */ Object.create(null);
551
- };
552
- var composeRef = (ref, cb) => {
553
- return useMemo(() => (e) => {
554
- let refCleanup;
555
- if (ref) {
556
- if (typeof ref === "function") refCleanup = ref(e) || (() => {
557
- ref(null);
558
- });
559
- else if (ref && "current" in ref) {
560
- ref.current = e;
561
- refCleanup = () => {
562
- ref.current = null;
563
- };
564
- }
565
- }
566
- const cbCleanup = cb(e);
567
- return () => {
568
- cbCleanup?.();
569
- refCleanup?.();
570
- };
571
- }, [ref]);
572
- };
573
- var blockingPromiseMap = /* @__PURE__ */ Object.create(null);
574
- var createdElements = /* @__PURE__ */ Object.create(null);
575
- var documentMetadataTag = (tag, props, preserveNodeType, supportSort, supportBlocking) => {
576
- if (props?.itemProp) return {
577
- tag,
578
- props,
579
- type: tag,
580
- ref: props.ref
581
- };
582
- const head = document.head;
583
- let { onLoad, onError, precedence, blocking, ...restProps } = props;
584
- let element = null;
585
- let created = false;
586
- const deDupeKeys = deDupeKeyMap[tag];
587
- const deDupeByKey = shouldDeDupeByKey(tag, supportSort);
588
- const isDeDupeCandidateLink = (e) => e.getAttribute("rel") === "stylesheet" && e.getAttribute("data-precedence") !== null;
589
- let existingElements = void 0;
590
- if (deDupeByKey) {
591
- const tags = head.querySelectorAll(tag);
592
- LOOP: for (const e of tags) {
593
- if (tag === "link" && !isDeDupeCandidateLink(e)) continue;
594
- for (const key of deDupeKeys) if (e.getAttribute(key) === props[key]) {
595
- element = e;
596
- break LOOP;
597
- }
598
- }
599
- if (!element) {
600
- const cacheKey = deDupeKeys.reduce((acc, key) => props[key] === void 0 ? acc : `${acc}-${key}-${props[key]}`, tag);
601
- created = !createdElements[cacheKey];
602
- element = createdElements[cacheKey] ||= (() => {
603
- const e = document.createElement(tag);
604
- for (const key of deDupeKeys) if (props[key] !== void 0) e.setAttribute(key, props[key]);
605
- if (props.rel) e.setAttribute("rel", props.rel);
606
- return e;
607
- })();
608
- }
609
- } else existingElements = head.querySelectorAll(tag);
610
- precedence = supportSort ? precedence ?? "" : void 0;
611
- if (supportSort) restProps[dataPrecedenceAttr] = precedence;
612
- const insert = useCallback((e) => {
613
- if (deDupeByKey) {
614
- if (tag === "link" && precedence !== void 0) {
615
- let found2 = false;
616
- for (const existingElement of head.querySelectorAll(tag)) {
617
- const existingPrecedence = existingElement.getAttribute(dataPrecedenceAttr);
618
- if (existingPrecedence === null) {
619
- head.insertBefore(e, existingElement);
620
- return;
621
- }
622
- if (found2 && existingPrecedence !== precedence) {
623
- head.insertBefore(e, existingElement);
624
- return;
625
- }
626
- if (existingPrecedence === precedence) found2 = true;
627
- }
628
- head.appendChild(e);
629
- return;
630
- }
631
- let found = false;
632
- for (const existingElement of head.querySelectorAll(tag)) {
633
- if (found && existingElement.getAttribute("data-precedence") !== precedence) {
634
- head.insertBefore(e, existingElement);
635
- return;
636
- }
637
- if (existingElement.getAttribute("data-precedence") === precedence) found = true;
638
- }
639
- head.appendChild(e);
640
- } else if (tag === "link") {
641
- if (!head.contains(e)) head.appendChild(e);
642
- } else if (existingElements) {
643
- let found = false;
644
- for (const existingElement of existingElements) if (existingElement === e) {
645
- found = true;
646
- break;
647
- }
648
- if (!found) head.insertBefore(e, head.contains(existingElements[0]) ? existingElements[0] : head.querySelector(tag));
649
- existingElements = void 0;
650
- }
651
- }, [
652
- deDupeByKey,
653
- precedence,
654
- tag
655
- ]);
656
- const ref = composeRef(props.ref, (e) => {
657
- const key = deDupeKeys[0];
658
- if (preserveNodeType === 2) e.innerHTML = "";
659
- if (created || existingElements) insert(e);
660
- if (!onError && !onLoad) return;
661
- if (!key) return;
662
- let promise = blockingPromiseMap[e.getAttribute(key)] ||= new Promise((resolve, reject) => {
663
- e.addEventListener("load", resolve);
664
- e.addEventListener("error", reject);
665
- });
666
- if (onLoad) promise = promise.then(onLoad);
667
- if (onError) promise = promise.catch(onError);
668
- promise.catch(() => {});
669
- });
670
- if (supportBlocking && blocking === "render") {
671
- const key = deDupeKeyMap[tag][0];
672
- if (key && props[key]) {
673
- const value = props[key];
674
- use(blockingPromiseMap[value] ||= new Promise((resolve, reject) => {
675
- insert(element);
676
- element.addEventListener("load", resolve);
677
- element.addEventListener("error", reject);
678
- }));
679
- }
680
- }
681
- const jsxNode = {
682
- tag,
683
- type: tag,
684
- props: {
685
- ...restProps,
686
- ref
687
- },
688
- ref
689
- };
690
- jsxNode.p = preserveNodeType;
691
- if (element) jsxNode.e = element;
692
- return createPortal(jsxNode, head);
693
- };
694
- var title = (props) => {
695
- const nameSpaceContext = getNameSpaceContext();
696
- if ((nameSpaceContext && useContext(nameSpaceContext))?.endsWith("svg")) return {
697
- tag: "title",
698
- props,
699
- type: "title",
700
- ref: props.ref
701
- };
702
- return documentMetadataTag("title", props, void 0, false, false);
703
- };
704
- var script = (props) => {
705
- if (!props || ["src", "async"].some((k) => !props[k])) return {
706
- tag: "script",
707
- props,
708
- type: "script",
709
- ref: props.ref
710
- };
711
- return documentMetadataTag("script", props, 1, false, true);
712
- };
713
- var style = (props) => {
714
- if (!props || !["href", "precedence"].every((k) => k in props)) return {
715
- tag: "style",
716
- props,
717
- type: "style",
718
- ref: props.ref
719
- };
720
- props["data-href"] = props.href;
721
- delete props.href;
722
- return documentMetadataTag("style", props, 2, true, true);
723
- };
724
- var link = (props) => {
725
- if (!props || ["onLoad", "onError"].some((k) => k in props) || props.rel === "stylesheet" && (!("precedence" in props) || "disabled" in props)) return {
726
- tag: "link",
727
- props,
728
- type: "link",
729
- ref: props.ref
730
- };
731
- return documentMetadataTag("link", props, 1, isStylesheetLinkWithPrecedence(props), true);
732
- };
733
- var meta = (props) => {
734
- return documentMetadataTag("meta", props, void 0, false, false);
735
- };
736
- var customEventFormAction = /* @__PURE__ */ Symbol();
737
- var form = (props) => {
738
- const { action, ...restProps } = props;
739
- if (typeof action !== "function") restProps.action = action;
740
- const [state, setState] = useState([null, false]);
741
- const onSubmit = useCallback(async (ev) => {
742
- const currentAction = ev.isTrusted ? action : ev.detail[customEventFormAction];
743
- if (typeof currentAction !== "function") return;
744
- ev.preventDefault();
745
- const formData = new FormData(ev.target);
746
- setState([formData, true]);
747
- const actionRes = currentAction(formData);
748
- if (actionRes instanceof Promise) {
749
- registerAction(actionRes);
750
- await actionRes;
751
- }
752
- setState([null, true]);
753
- }, []);
754
- const ref = composeRef(props.ref, (el) => {
755
- el.addEventListener("submit", onSubmit);
756
- return () => {
757
- el.removeEventListener("submit", onSubmit);
758
- };
759
- });
760
- const [data, isDirty] = state;
761
- state[1] = false;
762
- return {
763
- tag: FormContext,
764
- props: {
765
- value: {
766
- pending: data !== null,
767
- data,
768
- method: data ? "post" : null,
769
- action: data ? action : null
770
- },
771
- children: {
772
- tag: "form",
773
- props: {
774
- ...restProps,
775
- ref
776
- },
777
- type: "form",
778
- ref
779
- }
780
- },
781
- f: isDirty
782
- };
783
- };
784
- var formActionableElement = (tag, { formAction, ...props }) => {
785
- if (typeof formAction === "function") {
786
- const onClick = useCallback((ev) => {
787
- ev.preventDefault();
788
- ev.currentTarget.form.dispatchEvent(new CustomEvent("submit", { detail: { [customEventFormAction]: formAction } }));
789
- }, []);
790
- props.ref = composeRef(props.ref, (el) => {
791
- el.addEventListener("click", onClick);
792
- return () => {
793
- el.removeEventListener("click", onClick);
794
- };
795
- });
796
- }
797
- return {
798
- tag,
799
- props,
800
- type: tag,
801
- ref: props.ref
802
- };
803
- };
804
- var input = (props) => formActionableElement("input", props);
805
- var button = (props) => formActionableElement("button", props);
806
- Object.assign(domRenderers, {
807
- title,
808
- script,
809
- style,
810
- link,
811
- meta,
812
- form,
813
- input,
814
- button
815
- });
816
- //#endregion
817
- //#region ../../node_modules/.pnpm/hono@4.13.3/node_modules/hono/dist/jsx/dom/jsx-dev-runtime.js
818
- var jsxDEV = (tag, props, key) => {
819
- if (typeof tag === "string" && components_exports[tag]) tag = components_exports[tag];
820
- return {
821
- tag,
822
- type: tag,
823
- props,
824
- key,
825
- ref: props.ref
826
- };
827
- };
828
- var Fragment = (props) => jsxDEV("", props, void 0);
829
- //#endregion
830
- //#region ../../node_modules/.pnpm/hono@4.13.3/node_modules/hono/dist/jsx/dom/components.js
831
- var ErrorBoundary$1 = (({ children, fallback, fallbackRender, onError }) => {
832
- const res = Fragment({ children });
833
- res[DOM_ERROR_HANDLER] = (err) => {
834
- if (err instanceof Promise) throw err;
835
- onError?.(err);
836
- return fallbackRender?.(err) || fallback;
837
- };
838
- return res;
839
- });
840
- var Suspense$1 = (({ children, fallback }) => {
841
- const res = Fragment({ children });
842
- res[DOM_ERROR_HANDLER] = (err, retry) => {
843
- if (!(err instanceof Promise)) throw err;
844
- err.finally(retry);
845
- return fallback;
846
- };
847
- return res;
848
- });
849
- //#endregion
850
- //#region ../../node_modules/.pnpm/hono@4.13.3/node_modules/hono/dist/jsx/streaming.js
851
- var StreamingContext = createContext$1(null);
852
- var suspenseCounter = 0;
853
- var Suspense = async ({ children, fallback }) => {
854
- if (!Array.isArray(children)) children = [children];
855
- const nonce = useContext(StreamingContext)?.scriptNonce;
856
- let resArray = [];
857
- const stackNode = { [DOM_STASH]: [0, []] };
858
- const popNodeStack = () => {
859
- buildDataStack.pop();
860
- };
861
- try {
862
- stackNode[DOM_STASH][0] = 0;
863
- buildDataStack.push([[], stackNode]);
864
- resArray = children.map((c) => c == null || typeof c === "boolean" ? "" : c.toString());
865
- } catch (e) {
866
- if (e instanceof Promise) {
867
- const resume = captureRenderContext();
868
- resArray = [e.then(() => resume(() => {
869
- stackNode[DOM_STASH][0] = 0;
870
- buildDataStack.push([[], stackNode]);
871
- return childrenToString(children).finally(popNodeStack);
872
- }))];
873
- } else throw e;
874
- } finally {
875
- popNodeStack();
876
- }
877
- if (resArray.some((res) => res instanceof Promise)) {
878
- const index = suspenseCounter++;
879
- const fallbackStr = await fallback.toString();
880
- return raw(`<template id="H:${index}"></template>${fallbackStr}<!--/$-->`, [...fallbackStr.callbacks || [], ({ phase, buffer, context }) => {
881
- if (phase === HtmlEscapedCallbackPhase.BeforeStream) return;
882
- return Promise.all(resArray).then(async (htmlArray) => {
883
- htmlArray = htmlArray.flat();
884
- const content = htmlArray.join("");
885
- if (buffer) buffer[0] = buffer[0].replace(new RegExp(`<template id="H:${index}"></template>.*?<!--/\\$-->`), content);
886
- let html = buffer ? "" : `<template data-hono-target="H:${index}">${content}</template><script${nonce ? ` nonce="${nonce}"` : ""}>
887
- ((d,c,n) => {
888
- c=d.currentScript.previousSibling
889
- d=d.getElementById('H:${index}')
890
- if(!d)return
891
- do{n=d.nextSibling;n.remove()}while(n.nodeType!=8||n.nodeValue!='/$')
892
- d.replaceWith(c.content)
893
- })(document)
894
- <\/script>`;
895
- const callbacks = htmlArray.map((html2) => html2.callbacks || []).flat();
896
- if (!callbacks.length) return html;
897
- if (phase === HtmlEscapedCallbackPhase.Stream) html = await resolveCallback(html, HtmlEscapedCallbackPhase.BeforeStream, true, context);
898
- return raw(html, callbacks);
899
- });
900
- }]);
901
- } else return raw(resArray.join(""));
902
- };
903
- Suspense[DOM_RENDERER] = Suspense$1;
904
- var textEncoder = new TextEncoder();
905
- var renderToReadableStream = (content, onError = console.trace) => {
906
- let cancelled = false;
907
- return new ReadableStream({
908
- async start(controller) {
909
- try {
910
- if (content instanceof JSXNode) content = content.toString();
911
- const context = typeof content === "object" ? content : {};
912
- const resolved = await resolveCallback(content, HtmlEscapedCallbackPhase.BeforeStream, true, context);
913
- if (!cancelled) controller.enqueue(textEncoder.encode(resolved));
914
- let resolvedCount = 0;
915
- const callbacks = [];
916
- const then = (promise) => {
917
- callbacks.push(promise.catch((err) => {
918
- console.log(err);
919
- onError(err);
920
- return "";
921
- }).then(async (res) => {
922
- res = await resolveCallback(res, HtmlEscapedCallbackPhase.BeforeStream, true, context);
923
- res.callbacks?.map((c) => c({
924
- phase: HtmlEscapedCallbackPhase.Stream,
925
- context
926
- })).filter(Boolean).forEach(then);
927
- resolvedCount++;
928
- if (!cancelled) controller.enqueue(textEncoder.encode(res));
929
- }));
930
- };
931
- resolved.callbacks?.map((c) => c({
932
- phase: HtmlEscapedCallbackPhase.Stream,
933
- context
934
- })).filter(Boolean).forEach(then);
935
- while (resolvedCount !== callbacks.length) await Promise.all(callbacks);
936
- } catch (e) {
937
- onError(e);
938
- }
939
- if (!cancelled) controller.close();
940
- },
941
- cancel() {
942
- cancelled = true;
943
- }
944
- });
945
- };
946
- //#endregion
947
- //#region ../../node_modules/.pnpm/hono@4.13.3/node_modules/hono/dist/jsx/components.js
948
- var errorBoundaryCounter = 0;
949
- var childrenToString = async (children) => {
950
- try {
951
- return children.flat().map((c) => c == null || typeof c === "boolean" ? "" : c.toString());
952
- } catch (e) {
953
- if (e instanceof Promise) {
954
- const resume = captureRenderContext();
955
- await e;
956
- return resume(() => childrenToString(children));
957
- } else throw e;
958
- }
959
- };
960
- var resolveChildEarly = (c) => {
961
- if (c == null || typeof c === "boolean") return "";
962
- else if (typeof c === "string") return c;
963
- else {
964
- const str = c.toString();
965
- if (!(str instanceof Promise)) return raw(str);
966
- else return str;
967
- }
968
- };
969
- var ErrorBoundary = async ({ children, fallback, fallbackRender, onError }) => {
970
- if (!children) return raw("");
971
- if (!Array.isArray(children)) children = [children];
972
- const nonce = useContext(StreamingContext)?.scriptNonce;
973
- let resume;
974
- const getResume = () => resume ||= captureRenderContext();
975
- let fallbackStrPromise;
976
- const resolveFallbackStr = () => fallbackStrPromise ||= (async () => {
977
- const awaitedFallback = await fallback;
978
- if (typeof awaitedFallback === "string") return awaitedFallback;
979
- else {
980
- const fallbackResult = await getResume()(() => awaitedFallback?.toString());
981
- if (typeof fallbackResult === "string") return raw(fallbackResult, fallbackResult.callbacks || awaitedFallback?.callbacks);
982
- }
983
- })();
984
- const renderFallback = async (error) => {
985
- const fallbackStr = await resolveFallbackStr();
986
- return getResume()(async () => {
987
- onError?.(error);
988
- const fallbackRes = fallbackStr !== void 0 ? fallbackStr : fallbackRender && jsx(Fragment$1, {}, fallbackRender(error)) || "";
989
- const fallbackResString = await Fragment$1({ children: fallbackRes }).toString();
990
- return raw(fallbackResString, fallbackResString.callbacks || fallbackRes.callbacks);
991
- });
992
- };
993
- let resArray = [];
994
- try {
995
- resArray = children.map(resolveChildEarly);
996
- } catch (e) {
997
- const resume2 = getResume();
998
- if (e instanceof Promise) resArray = [e.then(() => resume2(() => childrenToString(children))).catch((e2) => renderFallback(e2))];
999
- else resArray = [await renderFallback(e)];
1000
- }
1001
- if (resArray.some((res) => res instanceof Promise)) {
1002
- getResume();
1003
- const index = errorBoundaryCounter++;
1004
- const replaceRe = RegExp(`(<template id="E:${index}"></template>.*?)(.*?)(<!--E:${index}-->)`);
1005
- let caught = false;
1006
- const catchCallback = async ({ error: error2, buffer }) => {
1007
- if (caught) return "";
1008
- caught = true;
1009
- const fallbackResString = await renderFallback(error2);
1010
- const fallbackCallbacks = fallbackResString.callbacks;
1011
- if (buffer) {
1012
- buffer[0] = buffer[0].replace(replaceRe, fallbackResString);
1013
- return fallbackCallbacks?.length ? raw("", fallbackCallbacks) : "";
1014
- }
1015
- return raw(`<template data-hono-target="E:${index}">${fallbackResString}</template><script>
1016
- ((d,c,n) => {
1017
- c=d.currentScript.previousSibling
1018
- d=d.getElementById('E:${index}')
1019
- if(!d)return
1020
- do{n=d.nextSibling;n.remove()}while(n.nodeType!=8||n.nodeValue!='E:${index}')
1021
- d.replaceWith(c.content)
1022
- })(document)
1023
- <\/script>`, fallbackCallbacks);
1024
- };
1025
- let error;
1026
- const promiseAll = Promise.all(resArray).catch((e) => error = e);
1027
- return raw(`<template id="E:${index}"></template><!--E:${index}-->`, [({ phase, buffer, context }) => {
1028
- if (phase === HtmlEscapedCallbackPhase.BeforeStream) return;
1029
- return promiseAll.then(async (htmlArray) => {
1030
- if (error) throw error;
1031
- htmlArray = htmlArray.flat();
1032
- const content = htmlArray.join("");
1033
- let html = buffer ? "" : `<template data-hono-target="E:${index}">${content}</template><script${nonce ? ` nonce="${nonce}"` : ""}>
1034
- ((d,c) => {
1035
- c=d.currentScript.previousSibling
1036
- d=d.getElementById('E:${index}')
1037
- if(!d)return
1038
- d.parentElement.insertBefore(c.content,d.nextSibling)
1039
- })(document)
1040
- <\/script>`;
1041
- if (htmlArray.every((html2) => !html2.callbacks?.length)) {
1042
- if (buffer) buffer[0] = buffer[0].replace(replaceRe, content);
1043
- return html;
1044
- }
1045
- if (buffer) buffer[0] = buffer[0].replace(replaceRe, (_all, pre, _, post) => `${pre}${content}${post}`);
1046
- const callbacks = htmlArray.map((html2) => html2.callbacks || []).flat();
1047
- if (phase === HtmlEscapedCallbackPhase.Stream) html = await resolveCallback(html, HtmlEscapedCallbackPhase.BeforeStream, true, context);
1048
- let resolvedCount = 0;
1049
- const promises = callbacks.map((c) => (...args) => c(...args)?.then((content2) => {
1050
- resolvedCount++;
1051
- if (buffer) {
1052
- if (resolvedCount === callbacks.length) buffer[0] = buffer[0].replace(replaceRe, (_all, _pre, content3) => content3);
1053
- buffer[0] += content2;
1054
- return raw("", content2.callbacks);
1055
- }
1056
- return raw(content2 + (resolvedCount !== callbacks.length ? "" : `<script>
1057
- ((d,c,n) => {
1058
- d=d.getElementById('E:${index}')
1059
- if(!d)return
1060
- n=d.nextSibling
1061
- while(n.nodeType!=8||n.nodeValue!='E:${index}'){n=n.nextSibling}
1062
- n.remove()
1063
- d.remove()
1064
- })(document)
1065
- <\/script>`), content2.callbacks);
1066
- }).catch((error2) => catchCallback({
1067
- error: error2,
1068
- buffer
1069
- })));
1070
- return raw(html, promises);
1071
- }).catch((error2) => catchCallback({
1072
- error: error2,
1073
- buffer
1074
- }));
1075
- }]);
1076
- } else return Fragment$1({ children: resArray });
1077
- };
1078
- ErrorBoundary[DOM_RENDERER] = ErrorBoundary$1;
1079
- //#endregion
1080
- export { renderToReadableStream as t };