@noodleseed/one 0.22.0 → 0.23.0
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/commands/author-loop.d.ts.map +1 -1
- package/dist/commands/author-loop.js +2 -2
- package/dist/commands/author-loop.js.map +1 -1
- package/dist/commands/catalog-dispatch.d.ts.map +1 -1
- package/dist/commands/catalog-dispatch.js +21 -2
- package/dist/commands/catalog-dispatch.js.map +1 -1
- package/dist/commands/deploy-ops.d.ts.map +1 -1
- package/dist/commands/deploy-ops.js +28 -11
- package/dist/commands/deploy-ops.js.map +1 -1
- package/dist/first-run.d.ts +11 -0
- package/dist/first-run.d.ts.map +1 -1
- package/dist/first-run.js +19 -4
- package/dist/first-run.js.map +1 -1
- package/dist/project-scaffold-templates.d.ts +11 -0
- package/dist/project-scaffold-templates.d.ts.map +1 -0
- package/dist/project-scaffold-templates.js +359 -0
- package/dist/project-scaffold-templates.js.map +1 -0
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +1 -323
- package/dist/project.js.map +1 -1
- package/dist/react.d.ts +2 -2
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +1 -1
- package/dist/react.js.map +1 -1
- package/dist/validate.d.ts +12 -0
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +11 -0
- package/dist/validate.js.map +1 -1
- package/node_modules/@noodle-borg/agent-kit/dist/skill-content.d.ts.map +1 -1
- package/node_modules/@noodle-borg/agent-kit/dist/skill-content.js +6 -9
- package/node_modules/@noodle-borg/agent-kit/dist/skill-content.js.map +1 -1
- package/node_modules/@noodle-borg/agent-kit/package.json +1 -1
- package/node_modules/@noodle-borg/authoring/dist/index.d.ts +3 -3
- package/node_modules/@noodle-borg/authoring/dist/index.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/index.js +1 -1
- package/node_modules/@noodle-borg/authoring/dist/index.js.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react/components.d.ts +302 -7
- package/node_modules/@noodle-borg/authoring/dist/react/components.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react/components.js +39 -7
- package/node_modules/@noodle-borg/authoring/dist/react/components.js.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react/index.d.ts +4 -2
- package/node_modules/@noodle-borg/authoring/dist/react/index.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react/index.js +2 -1
- package/node_modules/@noodle-borg/authoring/dist/react/index.js.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react/semantic-components.d.ts +2618 -0
- package/node_modules/@noodle-borg/authoring/dist/react/semantic-components.d.ts.map +1 -0
- package/node_modules/@noodle-borg/authoring/dist/react/semantic-components.js +110 -0
- package/node_modules/@noodle-borg/authoring/dist/react/semantic-components.js.map +1 -0
- package/node_modules/@noodle-borg/authoring/dist/react.d.ts +2 -2
- package/node_modules/@noodle-borg/authoring/dist/react.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react.js +1 -1
- package/node_modules/@noodle-borg/authoring/dist/react.js.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/recording.d.ts +1 -1
- package/node_modules/@noodle-borg/authoring/dist/recording.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/recording.js +14 -1
- package/node_modules/@noodle-borg/authoring/dist/recording.js.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/server.d.ts +25 -2
- package/node_modules/@noodle-borg/authoring/dist/server.d.ts.map +1 -1
- package/node_modules/@noodle-borg/authoring/dist/server.js +7 -3
- package/node_modules/@noodle-borg/authoring/dist/server.js.map +1 -1
- package/node_modules/@noodle-borg/compiler/dist/compile.d.ts.map +1 -1
- package/node_modules/@noodle-borg/compiler/dist/compile.js +20 -8
- package/node_modules/@noodle-borg/compiler/dist/compile.js.map +1 -1
- package/node_modules/@noodle-borg/compiler/dist/manifest/schema.d.ts +2 -0
- package/node_modules/@noodle-borg/compiler/dist/manifest/schema.d.ts.map +1 -1
- package/node_modules/@noodle-borg/compiler/dist/manifest/schema.js +6 -0
- package/node_modules/@noodle-borg/compiler/dist/manifest/schema.js.map +1 -1
- package/node_modules/@noodle-borg/connector-http/package.json +1 -1
- package/node_modules/@noodle-borg/protocol/dist/mapping.d.ts.map +1 -1
- package/node_modules/@noodle-borg/protocol/dist/mapping.js +8 -0
- package/node_modules/@noodle-borg/protocol/dist/mapping.js.map +1 -1
- package/node_modules/hono/dist/adapter/aws-lambda/handler.js +15 -21
- package/node_modules/hono/dist/adapter/bun/websocket.js +3 -1
- package/node_modules/hono/dist/adapter/lambda-edge/handler.js +8 -2
- package/node_modules/hono/dist/cjs/adapter/aws-lambda/handler.js +15 -21
- package/node_modules/hono/dist/cjs/adapter/bun/websocket.js +3 -1
- package/node_modules/hono/dist/cjs/adapter/lambda-edge/handler.js +8 -2
- package/node_modules/hono/dist/cjs/helper/css/common.js +3 -1
- package/node_modules/hono/dist/cjs/helper/css/index.js +9 -1
- package/node_modules/hono/dist/cjs/jsx/base.js +8 -14
- package/node_modules/hono/dist/cjs/jsx/components.js +41 -21
- package/node_modules/hono/dist/cjs/jsx/context.js +131 -5
- package/node_modules/hono/dist/cjs/jsx/streaming.js +9 -7
- package/node_modules/hono/dist/cjs/middleware/cors/index.js +2 -5
- package/node_modules/hono/dist/cjs/middleware/serve-static/index.js +2 -2
- package/node_modules/hono/dist/cjs/utils/body.js +12 -4
- package/node_modules/hono/dist/cjs/utils/buffer.js +2 -1
- package/node_modules/hono/dist/cjs/validator/validator.js +3 -3
- package/node_modules/hono/dist/helper/css/common.js +3 -1
- package/node_modules/hono/dist/helper/css/index.js +9 -1
- package/node_modules/hono/dist/jsx/base.js +15 -15
- package/node_modules/hono/dist/jsx/components.js +42 -22
- package/node_modules/hono/dist/jsx/context.js +129 -5
- package/node_modules/hono/dist/jsx/streaming.js +10 -8
- package/node_modules/hono/dist/middleware/cors/index.js +2 -5
- package/node_modules/hono/dist/middleware/serve-static/index.js +2 -2
- package/node_modules/hono/dist/types/adapter/aws-lambda/handler.d.ts +1 -1
- package/node_modules/hono/dist/types/jsx/base.d.ts +1 -3
- package/node_modules/hono/dist/types/jsx/context.d.ts +39 -0
- package/node_modules/hono/dist/types/middleware/context-storage/index.d.ts +2 -2
- package/node_modules/hono/dist/types/utils/body.d.ts +1 -1
- package/node_modules/hono/dist/utils/body.js +12 -4
- package/node_modules/hono/dist/utils/buffer.js +2 -1
- package/node_modules/hono/dist/validator/validator.js +3 -3
- package/node_modules/hono/package.json +9 -10
- package/node_modules/tailwindcss/dist/chunk-HMCCH6MG.mjs +1 -0
- package/node_modules/tailwindcss/dist/default-theme.mjs +1 -1
- package/node_modules/tailwindcss/dist/lib.js +13 -13
- package/node_modules/tailwindcss/dist/lib.mjs +18 -18
- package/node_modules/tailwindcss/package.json +2 -2
- package/node_modules/undici/README.md +3 -2
- package/node_modules/undici/docs/docs/api/Agent.md +248 -44
- package/node_modules/undici/docs/docs/api/BalancedPool.md +246 -48
- package/node_modules/undici/docs/docs/api/CacheStorage.md +171 -13
- package/node_modules/undici/docs/docs/api/CacheStore.md +294 -98
- package/node_modules/undici/docs/docs/api/Client.md +365 -178
- package/node_modules/undici/docs/docs/api/ClientStats.md +80 -14
- package/node_modules/undici/docs/docs/api/Connector.md +118 -36
- package/node_modules/undici/docs/docs/api/ContentType.md +65 -25
- package/node_modules/undici/docs/docs/api/Cookies.md +125 -47
- package/node_modules/undici/docs/docs/api/Debug.md +34 -18
- package/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +364 -164
- package/node_modules/undici/docs/docs/api/Dispatcher.md +479 -1093
- package/node_modules/undici/docs/docs/api/EnvHttpProxyAgent.md +101 -87
- package/node_modules/undici/docs/docs/api/Errors.md +503 -40
- package/node_modules/undici/docs/docs/api/EventSource.md +294 -32
- package/node_modules/undici/docs/docs/api/Fetch.md +680 -31
- package/node_modules/undici/docs/docs/api/GlobalInstallation.md +78 -98
- package/node_modules/undici/docs/docs/api/H2CClient.md +298 -176
- package/node_modules/undici/docs/docs/api/Interceptors.md +355 -0
- package/node_modules/undici/docs/docs/api/MockAgent.md +314 -322
- package/node_modules/undici/docs/docs/api/MockCallHistory.md +272 -98
- package/node_modules/undici/docs/docs/api/MockCallHistoryLog.md +189 -26
- package/node_modules/undici/docs/docs/api/MockClient.md +151 -33
- package/node_modules/undici/docs/docs/api/MockErrors.md +56 -5
- package/node_modules/undici/docs/docs/api/MockPool.md +299 -263
- package/node_modules/undici/docs/docs/api/Pool.md +235 -43
- package/node_modules/undici/docs/docs/api/PoolStats.md +119 -13
- package/node_modules/undici/docs/docs/api/ProxyAgent.md +179 -160
- package/node_modules/undici/docs/docs/api/RedirectHandler.md +238 -63
- package/node_modules/undici/docs/docs/api/RetryAgent.md +113 -26
- package/node_modules/undici/docs/docs/api/RetryHandler.md +161 -77
- package/node_modules/undici/docs/docs/api/RoundRobinPool.md +166 -72
- package/node_modules/undici/docs/docs/api/SnapshotAgent.md +264 -542
- package/node_modules/undici/docs/docs/api/Socks5ProxyAgent.md +162 -186
- package/node_modules/undici/docs/docs/api/Util.md +68 -11
- package/node_modules/undici/docs/docs/api/WebSocket.md +475 -80
- package/node_modules/undici/docs/docs/api/api-lifecycle.md +100 -32
- package/node_modules/undici/docs/docs/best-practices/client-certificate.md +2 -0
- package/node_modules/undici/docs/docs/best-practices/crawling.md +3 -1
- package/node_modules/undici/docs/docs/best-practices/migrating-from-v7-to-v8.md +6 -4
- package/node_modules/undici/docs/docs/best-practices/mocking-request.md +9 -7
- package/node_modules/undici/docs/docs/best-practices/proxy.md +3 -1
- package/node_modules/undici/docs/docs/best-practices/undici-vs-builtin-fetch.md +10 -8
- package/node_modules/undici/docs/docs/best-practices/writing-tests.md +2 -0
- package/node_modules/undici/docs/docs/{GettingStarted.md → getting-started.md} +22 -19
- package/node_modules/undici/docs/docs/index.md +779 -0
- package/node_modules/undici/docs/docs/site.json +125 -0
- package/node_modules/undici/docs/docs/type-map.json +79 -0
- package/node_modules/undici/lib/api/api-request.js +7 -1
- package/node_modules/undici/lib/api/readable.js +47 -2
- package/node_modules/undici/lib/core/errors.js +20 -0
- package/node_modules/undici/lib/core/request.js +1 -1
- package/node_modules/undici/lib/core/util.js +24 -1
- package/node_modules/undici/lib/dispatcher/client-h1.js +92 -1
- package/node_modules/undici/lib/dispatcher/client-h2.js +322 -118
- package/node_modules/undici/lib/dispatcher/client.js +6 -2
- package/node_modules/undici/lib/dispatcher/dispatcher-base.js +1 -0
- package/node_modules/undici/lib/dispatcher/proxy-agent.js +42 -7
- package/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +4 -2
- package/node_modules/undici/lib/handler/redirect-handler.js +1 -0
- package/node_modules/undici/lib/handler/retry-handler.js +57 -19
- package/node_modules/undici/lib/util/cache.js +8 -2
- package/node_modules/undici/lib/web/cookies/parse.js +20 -27
- package/node_modules/undici/lib/web/cookies/util.js +1 -1
- package/node_modules/undici/lib/web/eventsource/eventsource.js +7 -18
- package/node_modules/undici/lib/web/eventsource/util.js +32 -1
- package/node_modules/undici/lib/web/fetch/body.js +43 -0
- package/node_modules/undici/lib/web/fetch/constants.js +1 -1
- package/node_modules/undici/lib/web/fetch/index.js +11 -2
- package/node_modules/undici/lib/web/fetch/request.js +1 -0
- package/node_modules/undici/lib/web/fetch/util.js +4 -1
- package/node_modules/undici/lib/web/websocket/receiver.js +20 -3
- package/node_modules/undici/lib/web/websocket/stream/websocketstream.js +8 -1
- package/node_modules/undici/lib/web/websocket/websocket.js +3 -1
- package/node_modules/undici/package.json +1 -1
- package/node_modules/undici/types/client.d.ts +6 -1
- package/node_modules/undici/types/cookies.d.ts +1 -1
- package/node_modules/undici/types/errors.d.ts +10 -0
- package/node_modules/undici/types/fetch.d.ts +1 -0
- package/node_modules/undici/types/handlers.d.ts +2 -0
- package/node_modules/undici/types/proxy-agent.d.ts +7 -0
- package/package.json +4 -4
- package/react/styles.css +510 -5
- package/react/styles.source.css +850 -0
- package/node_modules/hono/dist/tsconfig.build.tsbuildinfo +0 -1
- package/node_modules/tailwindcss/dist/chunk-XVOTX5KS.mjs +0 -1
|
@@ -34,8 +34,9 @@ const childrenToString = async (children) => {
|
|
|
34
34
|
return children.flat().map((c) => c == null || typeof c === "boolean" ? "" : c.toString());
|
|
35
35
|
} catch (e) {
|
|
36
36
|
if (e instanceof Promise) {
|
|
37
|
+
const resume = (0, import_context.captureRenderContext)();
|
|
37
38
|
await e;
|
|
38
|
-
return childrenToString(children);
|
|
39
|
+
return resume(() => childrenToString(children));
|
|
39
40
|
} else {
|
|
40
41
|
throw e;
|
|
41
42
|
}
|
|
@@ -63,51 +64,68 @@ const ErrorBoundary = async ({ children, fallback, fallbackRender, onError }) =>
|
|
|
63
64
|
children = [children];
|
|
64
65
|
}
|
|
65
66
|
const nonce = (0, import_context.useContext)(import_streaming.StreamingContext)?.scriptNonce;
|
|
66
|
-
let
|
|
67
|
-
const
|
|
67
|
+
let resume;
|
|
68
|
+
const getResume = () => resume ||= (0, import_context.captureRenderContext)();
|
|
69
|
+
let fallbackStrPromise;
|
|
70
|
+
const resolveFallbackStr = () => fallbackStrPromise ||= (async () => {
|
|
68
71
|
const awaitedFallback = await fallback;
|
|
69
72
|
if (typeof awaitedFallback === "string") {
|
|
70
|
-
|
|
73
|
+
return awaitedFallback;
|
|
71
74
|
} else {
|
|
72
|
-
|
|
73
|
-
if (typeof
|
|
74
|
-
|
|
75
|
+
const fallbackResult = await getResume()(() => awaitedFallback?.toString());
|
|
76
|
+
if (typeof fallbackResult === "string") {
|
|
77
|
+
return (0, import_html.raw)(
|
|
78
|
+
fallbackResult,
|
|
79
|
+
fallbackResult.callbacks || awaitedFallback?.callbacks
|
|
80
|
+
);
|
|
75
81
|
}
|
|
76
82
|
}
|
|
77
|
-
};
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
return
|
|
83
|
+
})();
|
|
84
|
+
const renderFallback = async (error) => {
|
|
85
|
+
const fallbackStr = await resolveFallbackStr();
|
|
86
|
+
return getResume()(async () => {
|
|
87
|
+
onError?.(error);
|
|
88
|
+
const fallbackRes = fallbackStr !== void 0 ? fallbackStr : fallbackRender && (0, import_base.jsx)(import_base.Fragment, {}, fallbackRender(error)) || "";
|
|
89
|
+
const fallbackResString = await (0, import_base.Fragment)({
|
|
90
|
+
children: fallbackRes
|
|
91
|
+
}).toString();
|
|
92
|
+
return (0, import_html.raw)(
|
|
93
|
+
fallbackResString,
|
|
94
|
+
fallbackResString.callbacks || fallbackRes.callbacks
|
|
95
|
+
);
|
|
96
|
+
});
|
|
81
97
|
};
|
|
82
98
|
let resArray = [];
|
|
83
99
|
try {
|
|
84
100
|
resArray = children.map(resolveChildEarly);
|
|
85
101
|
} catch (e) {
|
|
86
|
-
|
|
102
|
+
const resume2 = getResume();
|
|
87
103
|
if (e instanceof Promise) {
|
|
88
104
|
resArray = [
|
|
89
|
-
e.then(() => childrenToString(children)).catch((e2) =>
|
|
105
|
+
e.then(() => resume2(() => childrenToString(children))).catch((e2) => renderFallback(e2))
|
|
90
106
|
];
|
|
91
107
|
} else {
|
|
92
|
-
resArray = [
|
|
108
|
+
resArray = [await renderFallback(e)];
|
|
93
109
|
}
|
|
94
110
|
}
|
|
95
111
|
if (resArray.some((res) => res instanceof Promise)) {
|
|
96
|
-
|
|
112
|
+
getResume();
|
|
97
113
|
const index = errorBoundaryCounter++;
|
|
98
114
|
const replaceRe = RegExp(`(<template id="E:${index}"></template>.*?)(.*?)(<!--E:${index}-->)`);
|
|
99
|
-
|
|
115
|
+
let caught = false;
|
|
100
116
|
const catchCallback = async ({ error: error2, buffer }) => {
|
|
101
117
|
if (caught) {
|
|
102
118
|
return "";
|
|
103
119
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
120
|
+
caught = true;
|
|
121
|
+
const fallbackResString = await renderFallback(error2);
|
|
122
|
+
const fallbackCallbacks = fallbackResString.callbacks;
|
|
107
123
|
if (buffer) {
|
|
108
124
|
buffer[0] = buffer[0].replace(replaceRe, fallbackResString);
|
|
125
|
+
return fallbackCallbacks?.length ? (0, import_html.raw)("", fallbackCallbacks) : "";
|
|
109
126
|
}
|
|
110
|
-
return
|
|
127
|
+
return (0, import_html.raw)(
|
|
128
|
+
`<template data-hono-target="E:${index}">${fallbackResString}</template><script>
|
|
111
129
|
((d,c,n) => {
|
|
112
130
|
c=d.currentScript.previousSibling
|
|
113
131
|
d=d.getElementById('E:${index}')
|
|
@@ -115,7 +133,9 @@ if(!d)return
|
|
|
115
133
|
do{n=d.nextSibling;n.remove()}while(n.nodeType!=8||n.nodeValue!='E:${index}')
|
|
116
134
|
d.replaceWith(c.content)
|
|
117
135
|
})(document)
|
|
118
|
-
</script
|
|
136
|
+
</script>`,
|
|
137
|
+
fallbackCallbacks
|
|
138
|
+
);
|
|
119
139
|
};
|
|
120
140
|
let error;
|
|
121
141
|
const promiseAll = Promise.all(resArray).catch((e) => error = e);
|
|
@@ -17,8 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
var context_exports = {};
|
|
19
19
|
__export(context_exports, {
|
|
20
|
+
captureRenderContext: () => captureRenderContext,
|
|
20
21
|
createContext: () => createContext,
|
|
21
22
|
globalContexts: () => globalContexts,
|
|
23
|
+
runWithRenderContext: () => runWithRenderContext,
|
|
22
24
|
useContext: () => useContext
|
|
23
25
|
});
|
|
24
26
|
module.exports = __toCommonJS(context_exports);
|
|
@@ -27,21 +29,143 @@ var import_base = require("./base");
|
|
|
27
29
|
var import_constants = require("./constants");
|
|
28
30
|
var import_context = require("./dom/context");
|
|
29
31
|
const globalContexts = [];
|
|
32
|
+
let alsProbed = false;
|
|
33
|
+
let asyncLocalStorage;
|
|
34
|
+
let fallbackStore;
|
|
35
|
+
let fallbackRendersInFlight = 0;
|
|
36
|
+
let warnedFallbackDefault = false;
|
|
37
|
+
const loadAsyncLocalStorage = () => {
|
|
38
|
+
if (alsProbed) {
|
|
39
|
+
return asyncLocalStorage;
|
|
40
|
+
}
|
|
41
|
+
alsProbed = true;
|
|
42
|
+
const global = globalThis;
|
|
43
|
+
let AsyncLocalStorage;
|
|
44
|
+
for (const probe of [
|
|
45
|
+
// Node.js >= 20.16, Deno, Bun, Cloudflare Workers (nodejs_compat). Property
|
|
46
|
+
// access only, so bundlers don't statically resolve `node:async_hooks`.
|
|
47
|
+
() => global.process?.getBuiltinModule?.("node:async_hooks")?.AsyncLocalStorage,
|
|
48
|
+
// Node.js < 20.16 has no `process.getBuiltinModule`, but a CJS entrypoint
|
|
49
|
+
// exposes the main module's `require` here.
|
|
50
|
+
() => global.process?.mainModule?.require?.("node:async_hooks")?.AsyncLocalStorage
|
|
51
|
+
]) {
|
|
52
|
+
try {
|
|
53
|
+
AsyncLocalStorage = probe();
|
|
54
|
+
} catch {
|
|
55
|
+
}
|
|
56
|
+
if (AsyncLocalStorage) {
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (AsyncLocalStorage) {
|
|
61
|
+
asyncLocalStorage = new AsyncLocalStorage();
|
|
62
|
+
}
|
|
63
|
+
return asyncLocalStorage;
|
|
64
|
+
};
|
|
65
|
+
const getCurrentStore = () => {
|
|
66
|
+
return loadAsyncLocalStorage()?.getStore() || fallbackStore;
|
|
67
|
+
};
|
|
68
|
+
const warnIfStorelessAccess = () => {
|
|
69
|
+
if (fallbackRendersInFlight > 0 && !warnedFallbackDefault) {
|
|
70
|
+
warnedFallbackDefault = true;
|
|
71
|
+
console.warn(
|
|
72
|
+
"hono/jsx: AsyncLocalStorage is unavailable in this runtime, so useContext() after an await in an async component falls back to the context default value during server-side rendering. To get provided values across await boundaries, use a runtime with AsyncLocalStorage (Node.js >= 20.16, Deno, Bun, or Cloudflare Workers with the nodejs_compat flag)."
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
const getContextValuesIn = (store, context) => {
|
|
77
|
+
if (!store) {
|
|
78
|
+
warnIfStorelessAccess();
|
|
79
|
+
return context.values;
|
|
80
|
+
}
|
|
81
|
+
let values = store.get(context);
|
|
82
|
+
if (!values) {
|
|
83
|
+
values = [context.values[0]];
|
|
84
|
+
store.set(context, values);
|
|
85
|
+
}
|
|
86
|
+
return values;
|
|
87
|
+
};
|
|
88
|
+
const readContextValueIn = (store, context) => {
|
|
89
|
+
if (!store) {
|
|
90
|
+
warnIfStorelessAccess();
|
|
91
|
+
return context.values.at(-1);
|
|
92
|
+
}
|
|
93
|
+
const values = store.get(context);
|
|
94
|
+
return values?.length ? values.at(-1) : context.values[0];
|
|
95
|
+
};
|
|
96
|
+
const captureContextValues = (store) => (store ? globalContexts.filter((c) => store.has(c)) : globalContexts).map((c) => [
|
|
97
|
+
c,
|
|
98
|
+
readContextValueIn(store, c)
|
|
99
|
+
]);
|
|
100
|
+
const resumeWithContextValues = (callback, store, contexts) => runWithRenderContext(() => {
|
|
101
|
+
const currentStore = getCurrentStore();
|
|
102
|
+
const valuesPerContext = contexts.map(([context, value]) => {
|
|
103
|
+
const values = getContextValuesIn(currentStore, context);
|
|
104
|
+
values.push(value);
|
|
105
|
+
return values;
|
|
106
|
+
});
|
|
107
|
+
const popContextValues = () => {
|
|
108
|
+
valuesPerContext.forEach((values) => {
|
|
109
|
+
values.pop();
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
try {
|
|
113
|
+
const result = callback();
|
|
114
|
+
if (result instanceof Promise) {
|
|
115
|
+
return result.finally(popContextValues);
|
|
116
|
+
}
|
|
117
|
+
popContextValues();
|
|
118
|
+
return result;
|
|
119
|
+
} catch (e) {
|
|
120
|
+
popContextValues();
|
|
121
|
+
throw e;
|
|
122
|
+
}
|
|
123
|
+
}, store);
|
|
124
|
+
const runWithRenderContext = (callback, resumeStore) => {
|
|
125
|
+
if (getCurrentStore()) {
|
|
126
|
+
return callback();
|
|
127
|
+
}
|
|
128
|
+
const store = resumeStore ?? /* @__PURE__ */ new WeakMap();
|
|
129
|
+
const storage = loadAsyncLocalStorage();
|
|
130
|
+
if (storage) {
|
|
131
|
+
return storage.run(store, callback);
|
|
132
|
+
}
|
|
133
|
+
fallbackStore = store;
|
|
134
|
+
let result;
|
|
135
|
+
try {
|
|
136
|
+
result = callback();
|
|
137
|
+
} finally {
|
|
138
|
+
fallbackStore = void 0;
|
|
139
|
+
}
|
|
140
|
+
if (!warnedFallbackDefault && result instanceof Promise) {
|
|
141
|
+
fallbackRendersInFlight++;
|
|
142
|
+
result = result.finally(() => {
|
|
143
|
+
fallbackRendersInFlight--;
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
return result;
|
|
147
|
+
};
|
|
148
|
+
const captureRenderContext = () => {
|
|
149
|
+
const store = getCurrentStore();
|
|
150
|
+
const contexts = captureContextValues(store);
|
|
151
|
+
return (callback) => resumeWithContextValues(callback, store, contexts);
|
|
152
|
+
};
|
|
30
153
|
const createContext = (defaultValue) => {
|
|
31
154
|
const values = [defaultValue];
|
|
32
155
|
const context = ((props) => {
|
|
33
|
-
|
|
156
|
+
const contextValues = getContextValuesIn(getCurrentStore(), context);
|
|
157
|
+
contextValues.push(props.value);
|
|
34
158
|
let string;
|
|
35
159
|
try {
|
|
36
160
|
string = props.children ? (Array.isArray(props.children) ? new import_base.JSXFragmentNode("", {}, props.children) : props.children).toString() : "";
|
|
37
161
|
} catch (e) {
|
|
38
|
-
|
|
162
|
+
contextValues.pop();
|
|
39
163
|
throw e;
|
|
40
164
|
}
|
|
41
165
|
if (string instanceof Promise) {
|
|
42
|
-
return string.finally(() =>
|
|
166
|
+
return string.finally(() => contextValues.pop()).then((resString) => (0, import_html.raw)(resString, resString.callbacks));
|
|
43
167
|
} else {
|
|
44
|
-
|
|
168
|
+
contextValues.pop();
|
|
45
169
|
return (0, import_html.raw)(string);
|
|
46
170
|
}
|
|
47
171
|
});
|
|
@@ -52,11 +176,13 @@ const createContext = (defaultValue) => {
|
|
|
52
176
|
return context;
|
|
53
177
|
};
|
|
54
178
|
const useContext = (context) => {
|
|
55
|
-
return
|
|
179
|
+
return readContextValueIn(getCurrentStore(), context);
|
|
56
180
|
};
|
|
57
181
|
// Annotate the CommonJS export names for ESM import in node:
|
|
58
182
|
0 && (module.exports = {
|
|
183
|
+
captureRenderContext,
|
|
59
184
|
createContext,
|
|
60
185
|
globalContexts,
|
|
186
|
+
runWithRenderContext,
|
|
61
187
|
useContext
|
|
62
188
|
});
|
|
@@ -42,9 +42,8 @@ const Suspense = async ({
|
|
|
42
42
|
const nonce = (0, import_context.useContext)(StreamingContext)?.scriptNonce;
|
|
43
43
|
let resArray = [];
|
|
44
44
|
const stackNode = { [import_constants.DOM_STASH]: [0, []] };
|
|
45
|
-
const popNodeStack = (
|
|
45
|
+
const popNodeStack = () => {
|
|
46
46
|
import_render.buildDataStack.pop();
|
|
47
|
-
return value;
|
|
48
47
|
};
|
|
49
48
|
try {
|
|
50
49
|
stackNode[import_constants.DOM_STASH][0] = 0;
|
|
@@ -54,12 +53,15 @@ const Suspense = async ({
|
|
|
54
53
|
);
|
|
55
54
|
} catch (e) {
|
|
56
55
|
if (e instanceof Promise) {
|
|
56
|
+
const resume = (0, import_context.captureRenderContext)();
|
|
57
57
|
resArray = [
|
|
58
|
-
e.then(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
e.then(
|
|
59
|
+
() => resume(() => {
|
|
60
|
+
stackNode[import_constants.DOM_STASH][0] = 0;
|
|
61
|
+
import_render.buildDataStack.push([[], stackNode]);
|
|
62
|
+
return (0, import_components.childrenToString)(children).finally(popNodeStack);
|
|
63
|
+
})
|
|
64
|
+
)
|
|
63
65
|
];
|
|
64
66
|
} else {
|
|
65
67
|
throw e;
|
|
@@ -31,9 +31,6 @@ const cors = (options) => {
|
|
|
31
31
|
const findAllowOrigin = ((optsOrigin) => {
|
|
32
32
|
if (typeof optsOrigin === "string") {
|
|
33
33
|
if (optsOrigin === "*") {
|
|
34
|
-
if (opts.credentials) {
|
|
35
|
-
return (origin) => origin || null;
|
|
36
|
-
}
|
|
37
34
|
return () => optsOrigin;
|
|
38
35
|
} else {
|
|
39
36
|
return (origin) => optsOrigin === origin ? origin : null;
|
|
@@ -68,7 +65,7 @@ const cors = (options) => {
|
|
|
68
65
|
set("Access-Control-Expose-Headers", opts.exposeHeaders.join(","));
|
|
69
66
|
}
|
|
70
67
|
if (c.req.method === "OPTIONS") {
|
|
71
|
-
if (opts.origin !== "*"
|
|
68
|
+
if (opts.origin !== "*") {
|
|
72
69
|
set("Vary", "Origin");
|
|
73
70
|
}
|
|
74
71
|
if (opts.maxAge != null) {
|
|
@@ -98,7 +95,7 @@ const cors = (options) => {
|
|
|
98
95
|
});
|
|
99
96
|
}
|
|
100
97
|
await next();
|
|
101
|
-
if (opts.origin !== "*"
|
|
98
|
+
if (opts.origin !== "*") {
|
|
102
99
|
c.header("Vary", "Origin", { append: true });
|
|
103
100
|
}
|
|
104
101
|
};
|
|
@@ -45,7 +45,7 @@ const serveStatic = (options) => {
|
|
|
45
45
|
} else {
|
|
46
46
|
try {
|
|
47
47
|
filename = (0, import_url.tryDecodeURI)(c.req.path);
|
|
48
|
-
if (/(?:^|[\/\\])\.{1,2}(?:$|[\/\\])|[\/\\]{2,}
|
|
48
|
+
if (/(?:^|[\/\\])\.{1,2}(?:$|[\/\\])|[\/\\]{2,}|\\/.test(filename)) {
|
|
49
49
|
throw new Error();
|
|
50
50
|
}
|
|
51
51
|
} catch {
|
|
@@ -65,7 +65,7 @@ const serveStatic = (options) => {
|
|
|
65
65
|
if (content instanceof Response) {
|
|
66
66
|
return c.newResponse(content.body, content);
|
|
67
67
|
}
|
|
68
|
-
if (content) {
|
|
68
|
+
if (content != null) {
|
|
69
69
|
const mimeType = options.mimes && (0, import_mime.getMimeType)(path, options.mimes) || (0, import_mime.getMimeType)(path);
|
|
70
70
|
c.header("Content-Type", mimeType || "application/octet-stream");
|
|
71
71
|
if (options.precompressed && (!mimeType || import_compress.COMPRESSIBLE_CONTENT_TYPE_REGEX.test(mimeType))) {
|
|
@@ -20,18 +20,26 @@ __export(body_exports, {
|
|
|
20
20
|
parseBody: () => parseBody
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(body_exports);
|
|
23
|
-
var
|
|
23
|
+
var import_buffer = require("./buffer");
|
|
24
|
+
const isRawRequest = (request) => "headers" in request;
|
|
24
25
|
const parseBody = async (request, options = /* @__PURE__ */ Object.create(null)) => {
|
|
25
26
|
const { all = false, dot = false } = options;
|
|
26
|
-
const headers = request
|
|
27
|
+
const headers = isRawRequest(request) ? request.headers : request.raw.headers;
|
|
27
28
|
const contentType = headers.get("Content-Type");
|
|
28
|
-
|
|
29
|
+
const mediaType = contentType?.split(";")[0].trim().toLowerCase();
|
|
30
|
+
if (mediaType === "multipart/form-data" || mediaType === "application/x-www-form-urlencoded") {
|
|
29
31
|
return parseFormData(request, { all, dot });
|
|
30
32
|
}
|
|
31
33
|
return {};
|
|
32
34
|
};
|
|
33
35
|
async function parseFormData(request, options) {
|
|
34
|
-
const
|
|
36
|
+
const headers = isRawRequest(request) ? request.headers : request.raw.headers;
|
|
37
|
+
const arrayBuffer = await request.arrayBuffer();
|
|
38
|
+
const formDataPromise = (0, import_buffer.bufferToFormData)(arrayBuffer, headers.get("Content-Type") || "");
|
|
39
|
+
if (!isRawRequest(request)) {
|
|
40
|
+
request.bodyCache.formData = formDataPromise;
|
|
41
|
+
}
|
|
42
|
+
const formData = await formDataPromise;
|
|
35
43
|
if (formData) {
|
|
36
44
|
return convertFormDataToBodyData(formData, options);
|
|
37
45
|
}
|
|
@@ -88,7 +88,8 @@ const bufferToString = (buffer) => {
|
|
|
88
88
|
const bufferToFormData = (arrayBuffer, contentType) => {
|
|
89
89
|
const response = new Response(arrayBuffer, {
|
|
90
90
|
headers: {
|
|
91
|
-
|
|
91
|
+
// Normalize the media type (case-insensitive) while keeping parameters like the boundary
|
|
92
|
+
"Content-Type": contentType.replace(/^[^;]+/, (mediaType) => mediaType.toLowerCase())
|
|
92
93
|
}
|
|
93
94
|
});
|
|
94
95
|
return response.formData();
|
|
@@ -23,9 +23,9 @@ module.exports = __toCommonJS(validator_exports);
|
|
|
23
23
|
var import_cookie = require("../helper/cookie");
|
|
24
24
|
var import_http_exception = require("../http-exception");
|
|
25
25
|
var import_buffer = require("../utils/buffer");
|
|
26
|
-
const jsonRegex = /^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))
|
|
27
|
-
const multipartRegex = /^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)
|
|
28
|
-
const urlencodedRegex = /^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))
|
|
26
|
+
const jsonRegex = /^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/i;
|
|
27
|
+
const multipartRegex = /^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/i;
|
|
28
|
+
const urlencodedRegex = /^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/i;
|
|
29
29
|
const validator = (target, validationFunc) => {
|
|
30
30
|
return async (c, next) => {
|
|
31
31
|
let value = {};
|
|
@@ -25,6 +25,7 @@ var normalizeLabel = (label) => {
|
|
|
25
25
|
return label.trim().replace(/\s+/g, "-");
|
|
26
26
|
};
|
|
27
27
|
var isValidClassName = (name) => /^-?[_a-zA-Z][_a-zA-Z0-9-]*$/.test(name);
|
|
28
|
+
var hasUnsafeSelectorChar = (name) => /[<{}]/.test(name);
|
|
28
29
|
var RESERVED_KEYFRAME_NAMES = /* @__PURE__ */ new Set([
|
|
29
30
|
"default",
|
|
30
31
|
"inherit",
|
|
@@ -162,7 +163,8 @@ var cxCommon = (args) => {
|
|
|
162
163
|
[CLASS_NAME]: "",
|
|
163
164
|
[STYLE_STRING]: "",
|
|
164
165
|
[SELECTORS]: [],
|
|
165
|
-
|
|
166
|
+
// drop names that are unsafe to emit as a selector
|
|
167
|
+
[EXTERNAL_CLASS_NAMES]: hasUnsafeSelectorChar(arg) ? [] : [arg]
|
|
166
168
|
};
|
|
167
169
|
}
|
|
168
170
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { raw } from "../../helper/html/index.js";
|
|
3
3
|
import { DOM_RENDERER } from "../../jsx/constants.js";
|
|
4
4
|
import { createCssJsxDomObjects } from "../../jsx/dom/css.js";
|
|
5
|
+
import { escapeToBuffer } from "../../utils/html.js";
|
|
5
6
|
import {
|
|
6
7
|
CLASS_NAME,
|
|
7
8
|
DEFAULT_STYLE_ID,
|
|
@@ -72,7 +73,14 @@ var createCssContext = ({
|
|
|
72
73
|
}
|
|
73
74
|
return Promise.resolve(raw("", [appendStyle]));
|
|
74
75
|
};
|
|
75
|
-
const
|
|
76
|
+
const rawClassName = cssClassName[CLASS_NAME];
|
|
77
|
+
let escapedClassName = rawClassName;
|
|
78
|
+
if (/[&<>'"]/.test(rawClassName)) {
|
|
79
|
+
const escapedBuffer = [""];
|
|
80
|
+
escapeToBuffer(rawClassName, escapedBuffer);
|
|
81
|
+
escapedClassName = escapedBuffer[0];
|
|
82
|
+
}
|
|
83
|
+
const className = new String(escapedClassName);
|
|
76
84
|
Object.assign(className, cssClassName);
|
|
77
85
|
className.isEscaped = true;
|
|
78
86
|
className.callbacks = [addClassNameToContext];
|
|
@@ -2,7 +2,13 @@
|
|
|
2
2
|
import { raw } from "../helper/html/index.js";
|
|
3
3
|
import { escapeToBuffer, resolveCallbackSync, stringBufferToString } from "../utils/html.js";
|
|
4
4
|
import { DOM_RENDERER, DOM_MEMO } from "./constants.js";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
captureRenderContext,
|
|
7
|
+
createContext,
|
|
8
|
+
globalContexts,
|
|
9
|
+
runWithRenderContext,
|
|
10
|
+
useContext
|
|
11
|
+
} from "./context.js";
|
|
6
12
|
import { domRenderers } from "./intrinsic-element/common.js";
|
|
7
13
|
import * as intrinsicElementTags from "./intrinsic-element/components.js";
|
|
8
14
|
import {
|
|
@@ -88,7 +94,7 @@ var JSXNode = class {
|
|
|
88
94
|
key;
|
|
89
95
|
children;
|
|
90
96
|
isEscaped = true;
|
|
91
|
-
|
|
97
|
+
suspendedContext;
|
|
92
98
|
constructor(tag, props, children) {
|
|
93
99
|
if (typeof tag !== "function" && !isValidTagName(tag)) {
|
|
94
100
|
throw new Error(`Invalid JSX tag name: ${tag}`);
|
|
@@ -106,18 +112,12 @@ var JSXNode = class {
|
|
|
106
112
|
return this.props.ref || null;
|
|
107
113
|
}
|
|
108
114
|
toString() {
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
context.values.push(value);
|
|
112
|
-
});
|
|
113
|
-
try {
|
|
115
|
+
const render = () => {
|
|
116
|
+
const buffer = [""];
|
|
114
117
|
this.toStringToBuffer(buffer);
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
return buffer.length === 1 ? "callbacks" in buffer ? resolveCallbackSync(raw(buffer[0], buffer.callbacks)).toString() : buffer[0] : stringBufferToString(buffer, buffer.callbacks);
|
|
118
|
+
return buffer.length === 1 ? "callbacks" in buffer ? resolveCallbackSync(raw(buffer[0], buffer.callbacks)).toString() : buffer[0] : stringBufferToString(buffer, buffer.callbacks);
|
|
119
|
+
};
|
|
120
|
+
return this.suspendedContext ? this.suspendedContext(render) : runWithRenderContext(render);
|
|
121
121
|
}
|
|
122
122
|
toStringToBuffer(buffer) {
|
|
123
123
|
const tag = this.tag;
|
|
@@ -193,12 +193,12 @@ var JSXFunctionNode = class extends JSXNode {
|
|
|
193
193
|
if (globalContexts.length === 0) {
|
|
194
194
|
buffer.unshift("", res);
|
|
195
195
|
} else {
|
|
196
|
-
const
|
|
196
|
+
const suspendedContext = captureRenderContext();
|
|
197
197
|
buffer.unshift(
|
|
198
198
|
"",
|
|
199
199
|
res.then((childRes) => {
|
|
200
200
|
if (childRes instanceof JSXNode) {
|
|
201
|
-
childRes.
|
|
201
|
+
childRes.suspendedContext = suspendedContext;
|
|
202
202
|
}
|
|
203
203
|
return childRes;
|
|
204
204
|
})
|
|
@@ -3,7 +3,7 @@ import { raw } from "../helper/html/index.js";
|
|
|
3
3
|
import { HtmlEscapedCallbackPhase, resolveCallback } from "../utils/html.js";
|
|
4
4
|
import { jsx, Fragment } from "./base.js";
|
|
5
5
|
import { DOM_RENDERER } from "./constants.js";
|
|
6
|
-
import { useContext } from "./context.js";
|
|
6
|
+
import { captureRenderContext, useContext } from "./context.js";
|
|
7
7
|
import { ErrorBoundary as ErrorBoundaryDomRenderer } from "./dom/components.js";
|
|
8
8
|
import { StreamingContext } from "./streaming.js";
|
|
9
9
|
var errorBoundaryCounter = 0;
|
|
@@ -12,8 +12,9 @@ var childrenToString = async (children) => {
|
|
|
12
12
|
return children.flat().map((c) => c == null || typeof c === "boolean" ? "" : c.toString());
|
|
13
13
|
} catch (e) {
|
|
14
14
|
if (e instanceof Promise) {
|
|
15
|
+
const resume = captureRenderContext();
|
|
15
16
|
await e;
|
|
16
|
-
return childrenToString(children);
|
|
17
|
+
return resume(() => childrenToString(children));
|
|
17
18
|
} else {
|
|
18
19
|
throw e;
|
|
19
20
|
}
|
|
@@ -41,51 +42,68 @@ var ErrorBoundary = async ({ children, fallback, fallbackRender, onError }) => {
|
|
|
41
42
|
children = [children];
|
|
42
43
|
}
|
|
43
44
|
const nonce = useContext(StreamingContext)?.scriptNonce;
|
|
44
|
-
let
|
|
45
|
-
const
|
|
45
|
+
let resume;
|
|
46
|
+
const getResume = () => resume ||= captureRenderContext();
|
|
47
|
+
let fallbackStrPromise;
|
|
48
|
+
const resolveFallbackStr = () => fallbackStrPromise ||= (async () => {
|
|
46
49
|
const awaitedFallback = await fallback;
|
|
47
50
|
if (typeof awaitedFallback === "string") {
|
|
48
|
-
|
|
51
|
+
return awaitedFallback;
|
|
49
52
|
} else {
|
|
50
|
-
|
|
51
|
-
if (typeof
|
|
52
|
-
|
|
53
|
+
const fallbackResult = await getResume()(() => awaitedFallback?.toString());
|
|
54
|
+
if (typeof fallbackResult === "string") {
|
|
55
|
+
return raw(
|
|
56
|
+
fallbackResult,
|
|
57
|
+
fallbackResult.callbacks || awaitedFallback?.callbacks
|
|
58
|
+
);
|
|
53
59
|
}
|
|
54
60
|
}
|
|
55
|
-
};
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
return
|
|
61
|
+
})();
|
|
62
|
+
const renderFallback = async (error) => {
|
|
63
|
+
const fallbackStr = await resolveFallbackStr();
|
|
64
|
+
return getResume()(async () => {
|
|
65
|
+
onError?.(error);
|
|
66
|
+
const fallbackRes = fallbackStr !== void 0 ? fallbackStr : fallbackRender && jsx(Fragment, {}, fallbackRender(error)) || "";
|
|
67
|
+
const fallbackResString = await Fragment({
|
|
68
|
+
children: fallbackRes
|
|
69
|
+
}).toString();
|
|
70
|
+
return raw(
|
|
71
|
+
fallbackResString,
|
|
72
|
+
fallbackResString.callbacks || fallbackRes.callbacks
|
|
73
|
+
);
|
|
74
|
+
});
|
|
59
75
|
};
|
|
60
76
|
let resArray = [];
|
|
61
77
|
try {
|
|
62
78
|
resArray = children.map(resolveChildEarly);
|
|
63
79
|
} catch (e) {
|
|
64
|
-
|
|
80
|
+
const resume2 = getResume();
|
|
65
81
|
if (e instanceof Promise) {
|
|
66
82
|
resArray = [
|
|
67
|
-
e.then(() => childrenToString(children)).catch((e2) =>
|
|
83
|
+
e.then(() => resume2(() => childrenToString(children))).catch((e2) => renderFallback(e2))
|
|
68
84
|
];
|
|
69
85
|
} else {
|
|
70
|
-
resArray = [
|
|
86
|
+
resArray = [await renderFallback(e)];
|
|
71
87
|
}
|
|
72
88
|
}
|
|
73
89
|
if (resArray.some((res) => res instanceof Promise)) {
|
|
74
|
-
|
|
90
|
+
getResume();
|
|
75
91
|
const index = errorBoundaryCounter++;
|
|
76
92
|
const replaceRe = RegExp(`(<template id="E:${index}"></template>.*?)(.*?)(<!--E:${index}-->)`);
|
|
77
|
-
|
|
93
|
+
let caught = false;
|
|
78
94
|
const catchCallback = async ({ error: error2, buffer }) => {
|
|
79
95
|
if (caught) {
|
|
80
96
|
return "";
|
|
81
97
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
98
|
+
caught = true;
|
|
99
|
+
const fallbackResString = await renderFallback(error2);
|
|
100
|
+
const fallbackCallbacks = fallbackResString.callbacks;
|
|
85
101
|
if (buffer) {
|
|
86
102
|
buffer[0] = buffer[0].replace(replaceRe, fallbackResString);
|
|
103
|
+
return fallbackCallbacks?.length ? raw("", fallbackCallbacks) : "";
|
|
87
104
|
}
|
|
88
|
-
return
|
|
105
|
+
return raw(
|
|
106
|
+
`<template data-hono-target="E:${index}">${fallbackResString}</template><script>
|
|
89
107
|
((d,c,n) => {
|
|
90
108
|
c=d.currentScript.previousSibling
|
|
91
109
|
d=d.getElementById('E:${index}')
|
|
@@ -93,7 +111,9 @@ if(!d)return
|
|
|
93
111
|
do{n=d.nextSibling;n.remove()}while(n.nodeType!=8||n.nodeValue!='E:${index}')
|
|
94
112
|
d.replaceWith(c.content)
|
|
95
113
|
})(document)
|
|
96
|
-
</script
|
|
114
|
+
</script>`,
|
|
115
|
+
fallbackCallbacks
|
|
116
|
+
);
|
|
97
117
|
};
|
|
98
118
|
let error;
|
|
99
119
|
const promiseAll = Promise.all(resArray).catch((e) => error = e);
|