@suveren/gateway 0.2.11 → 0.3.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/README.md +21 -7
- package/dist/control-plane/index.mjs +146 -2
- package/dist/mcp-server/http.mjs +80 -38
- package/dist/ui/assets/index-RkZBhIxU.js +105 -0
- package/dist/ui/index.html +1 -1
- package/node_modules/@hap/core/dist/index.d.mts +147 -3
- package/node_modules/@hap/core/dist/index.d.ts +147 -3
- package/node_modules/@hap/core/dist/index.js +74 -10
- package/node_modules/@hap/core/dist/index.mjs +69 -10
- package/node_modules/@hap/core/package.json +1 -1
- package/node_modules/@hap/core/src/gatekeeper.ts +4 -4
- package/node_modules/@hap/core/src/identity.ts +77 -0
- package/node_modules/@hap/core/src/index.ts +2 -0
- package/node_modules/@hap/core/src/intent-disclosure.ts +69 -0
- package/node_modules/@hap/core/src/types.ts +62 -2
- package/node_modules/@modelcontextprotocol/sdk/node_modules/body-parser/README.md +16 -1
- package/node_modules/@modelcontextprotocol/sdk/node_modules/body-parser/index.js +4 -20
- package/node_modules/@modelcontextprotocol/sdk/node_modules/body-parser/lib/read.js +17 -17
- package/node_modules/@modelcontextprotocol/sdk/node_modules/body-parser/lib/types/json.js +60 -32
- package/node_modules/@modelcontextprotocol/sdk/node_modules/body-parser/lib/types/raw.js +3 -3
- package/node_modules/@modelcontextprotocol/sdk/node_modules/body-parser/lib/types/text.js +3 -3
- package/node_modules/@modelcontextprotocol/sdk/node_modules/body-parser/lib/types/urlencoded.js +16 -20
- package/node_modules/@modelcontextprotocol/sdk/node_modules/body-parser/lib/utils.js +18 -16
- package/node_modules/@modelcontextprotocol/sdk/node_modules/body-parser/node_modules/content-type/LICENSE +22 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/body-parser/node_modules/content-type/README.md +69 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/body-parser/node_modules/content-type/dist/index.d.ts +26 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/body-parser/node_modules/content-type/dist/index.js +170 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/body-parser/node_modules/content-type/dist/index.js.map +1 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/body-parser/node_modules/content-type/package.json +52 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/body-parser/package.json +23 -10
- package/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/node/assert/strict.d.ts +10 -1
- package/node_modules/@types/node/assert.d.ts +144 -17
- package/node_modules/@types/node/async_hooks.d.ts +9 -9
- package/node_modules/@types/node/buffer.d.ts +0 -5
- package/node_modules/@types/node/child_process.d.ts +17 -21
- package/node_modules/@types/node/cluster.d.ts +13 -13
- package/node_modules/@types/node/console.d.ts +1 -1
- package/node_modules/@types/node/crypto.d.ts +454 -571
- package/node_modules/@types/node/diagnostics_channel.d.ts +37 -29
- package/node_modules/@types/node/dns.d.ts +14 -14
- package/node_modules/@types/node/events.d.ts +3 -3
- package/node_modules/@types/node/fs/promises.d.ts +4 -4
- package/node_modules/@types/node/fs.d.ts +3 -12
- package/node_modules/@types/node/globals.d.ts +4 -4
- package/node_modules/@types/node/http.d.ts +5 -5
- package/node_modules/@types/node/http2.d.ts +5 -1
- package/node_modules/@types/node/index.d.ts +0 -3
- package/node_modules/@types/node/inspector.d.ts +1 -1
- package/node_modules/@types/node/module.d.ts +16 -45
- package/node_modules/@types/node/net.d.ts +1 -1
- package/node_modules/@types/node/os.d.ts +2 -2
- package/node_modules/@types/node/package.json +4 -4
- package/node_modules/@types/node/perf_hooks.d.ts +1 -9
- package/node_modules/@types/node/process.d.ts +11 -11
- package/node_modules/@types/node/readline.d.ts +12 -11
- package/node_modules/@types/node/repl.d.ts +10 -10
- package/node_modules/@types/node/sqlite.d.ts +1 -1
- package/node_modules/@types/node/stream/promises.d.ts +2 -2
- package/node_modules/@types/node/stream/web.d.ts +1 -1
- package/node_modules/@types/node/stream.d.ts +5 -5
- package/node_modules/@types/node/test/reporters.d.ts +1 -1
- package/node_modules/@types/node/test.d.ts +8 -8
- package/node_modules/@types/node/tls.d.ts +1 -1
- package/node_modules/@types/node/ts5.6/index.d.ts +1 -4
- package/node_modules/@types/node/ts5.7/index.d.ts +0 -3
- package/node_modules/@types/node/url.d.ts +3 -3
- package/node_modules/@types/node/util/types.d.ts +1 -1
- package/node_modules/@types/node/util.d.ts +3 -20
- package/node_modules/@types/node/v8.d.ts +1 -1
- package/node_modules/@types/node/vm.d.ts +9 -9
- package/node_modules/@types/node/web-globals/domexception.d.ts +15 -0
- package/node_modules/@types/node/worker_threads.d.ts +2 -5
- package/node_modules/@types/node/zlib.d.ts +3 -3
- package/node_modules/fast-uri/index.js +1 -1
- package/node_modules/fast-uri/package.json +1 -1
- package/node_modules/fast-uri/test/security.test.js +28 -0
- package/node_modules/hono/dist/adapter/aws-lambda/handler.js +14 -20
- package/node_modules/hono/dist/adapter/lambda-edge/handler.js +8 -2
- package/node_modules/hono/dist/cjs/adapter/aws-lambda/handler.js +14 -20
- 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/bearer-auth/index.js +1 -1
- package/node_modules/hono/dist/cjs/middleware/cors/index.js +2 -5
- package/node_modules/hono/dist/cjs/middleware/language/language.js +10 -32
- package/node_modules/hono/dist/cjs/middleware/serve-static/index.js +1 -1
- package/node_modules/hono/dist/cjs/middleware/timing/timing.js +3 -1
- package/node_modules/hono/dist/cjs/utils/ipaddr.js +6 -1
- 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/bearer-auth/index.js +1 -1
- package/node_modules/hono/dist/middleware/cors/index.js +2 -5
- package/node_modules/hono/dist/middleware/language/language.js +10 -32
- package/node_modules/hono/dist/middleware/serve-static/index.js +1 -1
- package/node_modules/hono/dist/middleware/timing/timing.js +3 -1
- package/node_modules/hono/dist/tsconfig.build.tsbuildinfo +1 -1
- 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/utils/ipaddr.js +6 -1
- package/node_modules/hono/package.json +19 -13
- package/node_modules/http-proxy-middleware/README.md +3 -10
- package/node_modules/http-proxy-middleware/dist/errors.d.ts +4 -0
- package/node_modules/http-proxy-middleware/dist/errors.js +16 -1
- package/node_modules/http-proxy-middleware/dist/factory.d.ts +2 -2
- package/node_modules/http-proxy-middleware/dist/handlers/fix-request-body-utils/stringify-form-data.d.ts +7 -0
- package/node_modules/http-proxy-middleware/dist/handlers/fix-request-body-utils/stringify-form-data.js +45 -0
- package/node_modules/http-proxy-middleware/dist/handlers/fix-request-body.d.ts +1 -1
- package/node_modules/http-proxy-middleware/dist/handlers/fix-request-body.js +23 -23
- package/node_modules/http-proxy-middleware/dist/handlers/response-interceptor.d.ts +1 -1
- package/node_modules/http-proxy-middleware/dist/handlers/response-interceptor.js +1 -1
- package/node_modules/http-proxy-middleware/dist/http-proxy-middleware.d.ts +1 -1
- package/node_modules/http-proxy-middleware/dist/http-proxy-middleware.js +2 -2
- package/node_modules/http-proxy-middleware/dist/legacy/create-proxy-middleware.d.ts +1 -1
- package/node_modules/http-proxy-middleware/dist/legacy/create-proxy-middleware.js +1 -1
- package/node_modules/http-proxy-middleware/dist/legacy/options-adapter.js +1 -1
- package/node_modules/http-proxy-middleware/dist/legacy/types.d.ts +1 -1
- package/node_modules/http-proxy-middleware/dist/path-filter.d.ts +1 -1
- package/node_modules/http-proxy-middleware/dist/path-filter.js +1 -1
- package/node_modules/http-proxy-middleware/dist/path-rewriter.js +1 -1
- package/node_modules/http-proxy-middleware/dist/plugins/default/error-response-plugin.js +2 -1
- package/node_modules/http-proxy-middleware/dist/plugins/default/logger-plugin.js +3 -3
- package/node_modules/http-proxy-middleware/dist/router.js +26 -8
- package/node_modules/http-proxy-middleware/dist/status-code.js +15 -12
- package/node_modules/http-proxy-middleware/dist/types.d.ts +3 -3
- package/node_modules/http-proxy-middleware/dist/types.js +0 -4
- package/node_modules/http-proxy-middleware/dist/utils/sanitize.d.ts +1 -0
- package/node_modules/http-proxy-middleware/dist/utils/sanitize.js +6 -0
- package/node_modules/http-proxy-middleware/package.json +30 -28
- package/node_modules/qs/CHANGELOG.md +11 -0
- package/node_modules/qs/dist/qs.js +17 -17
- package/node_modules/qs/lib/parse.js +19 -8
- package/node_modules/qs/lib/utils.js +47 -8
- package/node_modules/qs/package.json +6 -5
- package/node_modules/qs/test/parse.js +230 -0
- package/node_modules/qs/test/utils.js +194 -0
- package/node_modules/side-channel/CHANGELOG.md +10 -0
- package/node_modules/side-channel/README.md +1 -1
- package/node_modules/side-channel/index.js +5 -2
- package/node_modules/side-channel/package.json +10 -10
- package/node_modules/side-channel/test/index.js +16 -0
- package/node_modules/undici-types/agent.d.ts +0 -2
- package/node_modules/undici-types/client.d.ts +25 -19
- package/node_modules/undici-types/dispatcher.d.ts +7 -33
- package/node_modules/undici-types/dispatcher1-wrapper.d.ts +7 -0
- package/node_modules/undici-types/fetch.d.ts +24 -4
- package/node_modules/undici-types/h2c-client.d.ts +6 -6
- package/node_modules/undici-types/handlers.d.ts +1 -2
- package/node_modules/undici-types/header.d.ts +5 -0
- package/node_modules/undici-types/index.d.ts +3 -1
- package/node_modules/undici-types/interceptors.d.ts +1 -1
- package/node_modules/undici-types/package.json +1 -1
- package/node_modules/undici-types/pool.d.ts +0 -2
- package/node_modules/undici-types/proxy-agent.d.ts +2 -2
- package/node_modules/undici-types/round-robin-pool.d.ts +0 -2
- package/node_modules/undici-types/snapshot-agent.d.ts +4 -0
- package/node_modules/undici-types/socks5-proxy-agent.d.ts +2 -2
- package/node_modules/undici-types/webidl.d.ts +0 -1
- package/package.json +3 -3
- package/dist/ui/assets/index-D3srGi9r.js +0 -102
- package/node_modules/@types/node/compatibility/iterators.d.ts +0 -21
|
@@ -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);
|
|
@@ -4,21 +4,143 @@ import { JSXFragmentNode } from "./base.js";
|
|
|
4
4
|
import { DOM_RENDERER } from "./constants.js";
|
|
5
5
|
import { createContextProviderFunction } from "./dom/context.js";
|
|
6
6
|
var globalContexts = [];
|
|
7
|
+
var alsProbed = false;
|
|
8
|
+
var asyncLocalStorage;
|
|
9
|
+
var fallbackStore;
|
|
10
|
+
var fallbackRendersInFlight = 0;
|
|
11
|
+
var warnedFallbackDefault = false;
|
|
12
|
+
var loadAsyncLocalStorage = () => {
|
|
13
|
+
if (alsProbed) {
|
|
14
|
+
return asyncLocalStorage;
|
|
15
|
+
}
|
|
16
|
+
alsProbed = true;
|
|
17
|
+
const global = globalThis;
|
|
18
|
+
let AsyncLocalStorage;
|
|
19
|
+
for (const probe of [
|
|
20
|
+
// Node.js >= 20.16, Deno, Bun, Cloudflare Workers (nodejs_compat). Property
|
|
21
|
+
// access only, so bundlers don't statically resolve `node:async_hooks`.
|
|
22
|
+
() => global.process?.getBuiltinModule?.("node:async_hooks")?.AsyncLocalStorage,
|
|
23
|
+
// Node.js < 20.16 has no `process.getBuiltinModule`, but a CJS entrypoint
|
|
24
|
+
// exposes the main module's `require` here.
|
|
25
|
+
() => global.process?.mainModule?.require?.("node:async_hooks")?.AsyncLocalStorage
|
|
26
|
+
]) {
|
|
27
|
+
try {
|
|
28
|
+
AsyncLocalStorage = probe();
|
|
29
|
+
} catch {
|
|
30
|
+
}
|
|
31
|
+
if (AsyncLocalStorage) {
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (AsyncLocalStorage) {
|
|
36
|
+
asyncLocalStorage = new AsyncLocalStorage();
|
|
37
|
+
}
|
|
38
|
+
return asyncLocalStorage;
|
|
39
|
+
};
|
|
40
|
+
var getCurrentStore = () => {
|
|
41
|
+
return loadAsyncLocalStorage()?.getStore() || fallbackStore;
|
|
42
|
+
};
|
|
43
|
+
var warnIfStorelessAccess = () => {
|
|
44
|
+
if (fallbackRendersInFlight > 0 && !warnedFallbackDefault) {
|
|
45
|
+
warnedFallbackDefault = true;
|
|
46
|
+
console.warn(
|
|
47
|
+
"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)."
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
var getContextValuesIn = (store, context) => {
|
|
52
|
+
if (!store) {
|
|
53
|
+
warnIfStorelessAccess();
|
|
54
|
+
return context.values;
|
|
55
|
+
}
|
|
56
|
+
let values = store.get(context);
|
|
57
|
+
if (!values) {
|
|
58
|
+
values = [context.values[0]];
|
|
59
|
+
store.set(context, values);
|
|
60
|
+
}
|
|
61
|
+
return values;
|
|
62
|
+
};
|
|
63
|
+
var readContextValueIn = (store, context) => {
|
|
64
|
+
if (!store) {
|
|
65
|
+
warnIfStorelessAccess();
|
|
66
|
+
return context.values.at(-1);
|
|
67
|
+
}
|
|
68
|
+
const values = store.get(context);
|
|
69
|
+
return values?.length ? values.at(-1) : context.values[0];
|
|
70
|
+
};
|
|
71
|
+
var captureContextValues = (store) => (store ? globalContexts.filter((c) => store.has(c)) : globalContexts).map((c) => [
|
|
72
|
+
c,
|
|
73
|
+
readContextValueIn(store, c)
|
|
74
|
+
]);
|
|
75
|
+
var resumeWithContextValues = (callback, store, contexts) => runWithRenderContext(() => {
|
|
76
|
+
const currentStore = getCurrentStore();
|
|
77
|
+
const valuesPerContext = contexts.map(([context, value]) => {
|
|
78
|
+
const values = getContextValuesIn(currentStore, context);
|
|
79
|
+
values.push(value);
|
|
80
|
+
return values;
|
|
81
|
+
});
|
|
82
|
+
const popContextValues = () => {
|
|
83
|
+
valuesPerContext.forEach((values) => {
|
|
84
|
+
values.pop();
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
try {
|
|
88
|
+
const result = callback();
|
|
89
|
+
if (result instanceof Promise) {
|
|
90
|
+
return result.finally(popContextValues);
|
|
91
|
+
}
|
|
92
|
+
popContextValues();
|
|
93
|
+
return result;
|
|
94
|
+
} catch (e) {
|
|
95
|
+
popContextValues();
|
|
96
|
+
throw e;
|
|
97
|
+
}
|
|
98
|
+
}, store);
|
|
99
|
+
var runWithRenderContext = (callback, resumeStore) => {
|
|
100
|
+
if (getCurrentStore()) {
|
|
101
|
+
return callback();
|
|
102
|
+
}
|
|
103
|
+
const store = resumeStore ?? /* @__PURE__ */ new WeakMap();
|
|
104
|
+
const storage = loadAsyncLocalStorage();
|
|
105
|
+
if (storage) {
|
|
106
|
+
return storage.run(store, callback);
|
|
107
|
+
}
|
|
108
|
+
fallbackStore = store;
|
|
109
|
+
let result;
|
|
110
|
+
try {
|
|
111
|
+
result = callback();
|
|
112
|
+
} finally {
|
|
113
|
+
fallbackStore = void 0;
|
|
114
|
+
}
|
|
115
|
+
if (!warnedFallbackDefault && result instanceof Promise) {
|
|
116
|
+
fallbackRendersInFlight++;
|
|
117
|
+
result = result.finally(() => {
|
|
118
|
+
fallbackRendersInFlight--;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
return result;
|
|
122
|
+
};
|
|
123
|
+
var captureRenderContext = () => {
|
|
124
|
+
const store = getCurrentStore();
|
|
125
|
+
const contexts = captureContextValues(store);
|
|
126
|
+
return (callback) => resumeWithContextValues(callback, store, contexts);
|
|
127
|
+
};
|
|
7
128
|
var createContext = (defaultValue) => {
|
|
8
129
|
const values = [defaultValue];
|
|
9
130
|
const context = ((props) => {
|
|
10
|
-
|
|
131
|
+
const contextValues = getContextValuesIn(getCurrentStore(), context);
|
|
132
|
+
contextValues.push(props.value);
|
|
11
133
|
let string;
|
|
12
134
|
try {
|
|
13
135
|
string = props.children ? (Array.isArray(props.children) ? new JSXFragmentNode("", {}, props.children) : props.children).toString() : "";
|
|
14
136
|
} catch (e) {
|
|
15
|
-
|
|
137
|
+
contextValues.pop();
|
|
16
138
|
throw e;
|
|
17
139
|
}
|
|
18
140
|
if (string instanceof Promise) {
|
|
19
|
-
return string.finally(() =>
|
|
141
|
+
return string.finally(() => contextValues.pop()).then((resString) => raw(resString, resString.callbacks));
|
|
20
142
|
} else {
|
|
21
|
-
|
|
143
|
+
contextValues.pop();
|
|
22
144
|
return raw(string);
|
|
23
145
|
}
|
|
24
146
|
});
|
|
@@ -29,10 +151,12 @@ var createContext = (defaultValue) => {
|
|
|
29
151
|
return context;
|
|
30
152
|
};
|
|
31
153
|
var useContext = (context) => {
|
|
32
|
-
return
|
|
154
|
+
return readContextValueIn(getCurrentStore(), context);
|
|
33
155
|
};
|
|
34
156
|
export {
|
|
157
|
+
captureRenderContext,
|
|
35
158
|
createContext,
|
|
36
159
|
globalContexts,
|
|
160
|
+
runWithRenderContext,
|
|
37
161
|
useContext
|
|
38
162
|
};
|
|
@@ -4,7 +4,7 @@ import { HtmlEscapedCallbackPhase, resolveCallback } from "../utils/html.js";
|
|
|
4
4
|
import { JSXNode } from "./base.js";
|
|
5
5
|
import { childrenToString } from "./components.js";
|
|
6
6
|
import { DOM_RENDERER, DOM_STASH } from "./constants.js";
|
|
7
|
-
import { createContext, useContext } from "./context.js";
|
|
7
|
+
import { captureRenderContext, createContext, useContext } from "./context.js";
|
|
8
8
|
import { Suspense as SuspenseDomRenderer } from "./dom/components.js";
|
|
9
9
|
import { buildDataStack } from "./dom/render.js";
|
|
10
10
|
var StreamingContext = createContext(null);
|
|
@@ -19,9 +19,8 @@ var Suspense = async ({
|
|
|
19
19
|
const nonce = useContext(StreamingContext)?.scriptNonce;
|
|
20
20
|
let resArray = [];
|
|
21
21
|
const stackNode = { [DOM_STASH]: [0, []] };
|
|
22
|
-
const popNodeStack = (
|
|
22
|
+
const popNodeStack = () => {
|
|
23
23
|
buildDataStack.pop();
|
|
24
|
-
return value;
|
|
25
24
|
};
|
|
26
25
|
try {
|
|
27
26
|
stackNode[DOM_STASH][0] = 0;
|
|
@@ -31,12 +30,15 @@ var Suspense = async ({
|
|
|
31
30
|
);
|
|
32
31
|
} catch (e) {
|
|
33
32
|
if (e instanceof Promise) {
|
|
33
|
+
const resume = captureRenderContext();
|
|
34
34
|
resArray = [
|
|
35
|
-
e.then(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
e.then(
|
|
36
|
+
() => resume(() => {
|
|
37
|
+
stackNode[DOM_STASH][0] = 0;
|
|
38
|
+
buildDataStack.push([[], stackNode]);
|
|
39
|
+
return childrenToString(children).finally(popNodeStack);
|
|
40
|
+
})
|
|
41
|
+
)
|
|
40
42
|
];
|
|
41
43
|
} else {
|
|
42
44
|
throw e;
|
|
@@ -6,7 +6,7 @@ var PREFIX = "Bearer";
|
|
|
6
6
|
var HEADER = "Authorization";
|
|
7
7
|
var bearerAuth = (options) => {
|
|
8
8
|
if (!("token" in options || "verifyToken" in options)) {
|
|
9
|
-
throw new Error('bearer auth middleware requires options for "token"');
|
|
9
|
+
throw new Error('bearer auth middleware requires options for "token" or "verifyToken"');
|
|
10
10
|
}
|
|
11
11
|
if (!options.realm) {
|
|
12
12
|
options.realm = "";
|
|
@@ -10,9 +10,6 @@ var cors = (options) => {
|
|
|
10
10
|
const findAllowOrigin = ((optsOrigin) => {
|
|
11
11
|
if (typeof optsOrigin === "string") {
|
|
12
12
|
if (optsOrigin === "*") {
|
|
13
|
-
if (opts.credentials) {
|
|
14
|
-
return (origin) => origin || null;
|
|
15
|
-
}
|
|
16
13
|
return () => optsOrigin;
|
|
17
14
|
} else {
|
|
18
15
|
return (origin) => optsOrigin === origin ? origin : null;
|
|
@@ -47,7 +44,7 @@ var cors = (options) => {
|
|
|
47
44
|
set("Access-Control-Expose-Headers", opts.exposeHeaders.join(","));
|
|
48
45
|
}
|
|
49
46
|
if (c.req.method === "OPTIONS") {
|
|
50
|
-
if (opts.origin !== "*"
|
|
47
|
+
if (opts.origin !== "*") {
|
|
51
48
|
set("Vary", "Origin");
|
|
52
49
|
}
|
|
53
50
|
if (opts.maxAge != null) {
|
|
@@ -77,7 +74,7 @@ var cors = (options) => {
|
|
|
77
74
|
});
|
|
78
75
|
}
|
|
79
76
|
await next();
|
|
80
|
-
if (opts.origin !== "*"
|
|
77
|
+
if (opts.origin !== "*") {
|
|
81
78
|
c.header("Vary", "Origin", { append: true });
|
|
82
79
|
}
|
|
83
80
|
};
|
|
@@ -53,20 +53,12 @@ var normalizeLanguage = (lang, options) => {
|
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
55
|
var detectFromQuery = (c, options) => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return normalizeLanguage(query, options);
|
|
59
|
-
} catch {
|
|
60
|
-
return void 0;
|
|
61
|
-
}
|
|
56
|
+
const query = c.req.query(options.lookupQueryString);
|
|
57
|
+
return normalizeLanguage(query, options);
|
|
62
58
|
};
|
|
63
59
|
var detectFromCookie = (c, options) => {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return normalizeLanguage(cookie, options);
|
|
67
|
-
} catch {
|
|
68
|
-
return void 0;
|
|
69
|
-
}
|
|
60
|
+
const cookie = getCookie(c, options.lookupCookie);
|
|
61
|
+
return normalizeLanguage(cookie, options);
|
|
70
62
|
};
|
|
71
63
|
function detectFromHeader(c, options) {
|
|
72
64
|
try {
|
|
@@ -87,14 +79,10 @@ function detectFromHeader(c, options) {
|
|
|
87
79
|
}
|
|
88
80
|
}
|
|
89
81
|
function detectFromPath(c, options) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
return normalizeLanguage(langSegment, options);
|
|
95
|
-
} catch {
|
|
96
|
-
return void 0;
|
|
97
|
-
}
|
|
82
|
+
const url = new URL(c.req.url);
|
|
83
|
+
const pathSegments = url.pathname.split("/").filter(Boolean);
|
|
84
|
+
const langSegment = pathSegments[options.lookupFromPathIndex];
|
|
85
|
+
return normalizeLanguage(langSegment, options);
|
|
98
86
|
}
|
|
99
87
|
var detectors = {
|
|
100
88
|
querystring: detectFromQuery,
|
|
@@ -129,9 +117,6 @@ var detectLanguage = (c, options) => {
|
|
|
129
117
|
let detectedLang;
|
|
130
118
|
for (const detectorName of options.order) {
|
|
131
119
|
const detector = detectors[detectorName];
|
|
132
|
-
if (!detector) {
|
|
133
|
-
continue;
|
|
134
|
-
}
|
|
135
120
|
try {
|
|
136
121
|
detectedLang = detector(c, options);
|
|
137
122
|
if (detectedLang) {
|
|
@@ -164,15 +149,8 @@ var languageDetector = (userOptions) => {
|
|
|
164
149
|
};
|
|
165
150
|
validateOptions(options);
|
|
166
151
|
return async function languageDetector2(ctx, next) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
ctx.set("language", lang);
|
|
170
|
-
} catch (error) {
|
|
171
|
-
if (options.debug) {
|
|
172
|
-
console.error("Language detection failed:", error);
|
|
173
|
-
}
|
|
174
|
-
ctx.set("language", options.fallbackLanguage);
|
|
175
|
-
}
|
|
152
|
+
const lang = detectLanguage(ctx, options);
|
|
153
|
+
ctx.set("language", lang);
|
|
176
154
|
await next();
|
|
177
155
|
};
|
|
178
156
|
};
|
|
@@ -24,7 +24,7 @@ var serveStatic = (options) => {
|
|
|
24
24
|
} else {
|
|
25
25
|
try {
|
|
26
26
|
filename = tryDecodeURI(c.req.path);
|
|
27
|
-
if (/(?:^|[\/\\])\.{1,2}(?:$|[\/\\])|[\/\\]{2,}
|
|
27
|
+
if (/(?:^|[\/\\])\.{1,2}(?:$|[\/\\])|[\/\\]{2,}|\\/.test(filename)) {
|
|
28
28
|
throw new Error();
|
|
29
29
|
}
|
|
30
30
|
} catch {
|
|
@@ -31,7 +31,9 @@ var timing = (config) => {
|
|
|
31
31
|
endTime(c, "total");
|
|
32
32
|
}
|
|
33
33
|
if (options.autoEnd) {
|
|
34
|
-
timers.forEach((_, key) =>
|
|
34
|
+
timers.forEach((_, key) => {
|
|
35
|
+
endTime(c, key);
|
|
36
|
+
});
|
|
35
37
|
}
|
|
36
38
|
const enabled = typeof options.enabled === "function" ? options.enabled(c) : options.enabled;
|
|
37
39
|
if (enabled) {
|