@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
|
@@ -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;
|
|
@@ -27,7 +27,7 @@ const PREFIX = "Bearer";
|
|
|
27
27
|
const HEADER = "Authorization";
|
|
28
28
|
const bearerAuth = (options) => {
|
|
29
29
|
if (!("token" in options || "verifyToken" in options)) {
|
|
30
|
-
throw new Error('bearer auth middleware requires options for "token"');
|
|
30
|
+
throw new Error('bearer auth middleware requires options for "token" or "verifyToken"');
|
|
31
31
|
}
|
|
32
32
|
if (!options.realm) {
|
|
33
33
|
options.realm = "";
|
|
@@ -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
|
};
|
|
@@ -83,20 +83,12 @@ const normalizeLanguage = (lang, options) => {
|
|
|
83
83
|
}
|
|
84
84
|
};
|
|
85
85
|
const detectFromQuery = (c, options) => {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
return normalizeLanguage(query, options);
|
|
89
|
-
} catch {
|
|
90
|
-
return void 0;
|
|
91
|
-
}
|
|
86
|
+
const query = c.req.query(options.lookupQueryString);
|
|
87
|
+
return normalizeLanguage(query, options);
|
|
92
88
|
};
|
|
93
89
|
const detectFromCookie = (c, options) => {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return normalizeLanguage(cookie, options);
|
|
97
|
-
} catch {
|
|
98
|
-
return void 0;
|
|
99
|
-
}
|
|
90
|
+
const cookie = (0, import_cookie.getCookie)(c, options.lookupCookie);
|
|
91
|
+
return normalizeLanguage(cookie, options);
|
|
100
92
|
};
|
|
101
93
|
function detectFromHeader(c, options) {
|
|
102
94
|
try {
|
|
@@ -117,14 +109,10 @@ function detectFromHeader(c, options) {
|
|
|
117
109
|
}
|
|
118
110
|
}
|
|
119
111
|
function detectFromPath(c, options) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
return normalizeLanguage(langSegment, options);
|
|
125
|
-
} catch {
|
|
126
|
-
return void 0;
|
|
127
|
-
}
|
|
112
|
+
const url = new URL(c.req.url);
|
|
113
|
+
const pathSegments = url.pathname.split("/").filter(Boolean);
|
|
114
|
+
const langSegment = pathSegments[options.lookupFromPathIndex];
|
|
115
|
+
return normalizeLanguage(langSegment, options);
|
|
128
116
|
}
|
|
129
117
|
const detectors = {
|
|
130
118
|
querystring: detectFromQuery,
|
|
@@ -159,9 +147,6 @@ const detectLanguage = (c, options) => {
|
|
|
159
147
|
let detectedLang;
|
|
160
148
|
for (const detectorName of options.order) {
|
|
161
149
|
const detector = detectors[detectorName];
|
|
162
|
-
if (!detector) {
|
|
163
|
-
continue;
|
|
164
|
-
}
|
|
165
150
|
try {
|
|
166
151
|
detectedLang = detector(c, options);
|
|
167
152
|
if (detectedLang) {
|
|
@@ -194,15 +179,8 @@ const languageDetector = (userOptions) => {
|
|
|
194
179
|
};
|
|
195
180
|
validateOptions(options);
|
|
196
181
|
return async function languageDetector2(ctx, next) {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
ctx.set("language", lang);
|
|
200
|
-
} catch (error) {
|
|
201
|
-
if (options.debug) {
|
|
202
|
-
console.error("Language detection failed:", error);
|
|
203
|
-
}
|
|
204
|
-
ctx.set("language", options.fallbackLanguage);
|
|
205
|
-
}
|
|
182
|
+
const lang = detectLanguage(ctx, options);
|
|
183
|
+
ctx.set("language", lang);
|
|
206
184
|
await next();
|
|
207
185
|
};
|
|
208
186
|
};
|
|
@@ -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 {
|
|
@@ -56,7 +56,9 @@ const timing = (config) => {
|
|
|
56
56
|
endTime(c, "total");
|
|
57
57
|
}
|
|
58
58
|
if (options.autoEnd) {
|
|
59
|
-
timers.forEach((_, key) =>
|
|
59
|
+
timers.forEach((_, key) => {
|
|
60
|
+
endTime(c, key);
|
|
61
|
+
});
|
|
60
62
|
}
|
|
61
63
|
const enabled = typeof options.enabled === "function" ? options.enabled(c) : options.enabled;
|
|
62
64
|
if (enabled) {
|
|
@@ -43,7 +43,9 @@ const expandIPv6 = (ipV6) => {
|
|
|
43
43
|
if (node !== "") {
|
|
44
44
|
sections[i] = node.padStart(4, "0");
|
|
45
45
|
} else {
|
|
46
|
-
sections[i + 1] === ""
|
|
46
|
+
while (sections[i + 1] === "") {
|
|
47
|
+
sections.splice(i + 1, 1);
|
|
48
|
+
}
|
|
47
49
|
sections[i] = new Array(8 - sections.length + 1).fill("0000").join(":");
|
|
48
50
|
}
|
|
49
51
|
}
|
|
@@ -263,6 +265,9 @@ const convertIPv4BinaryToString = (ipV4) => {
|
|
|
263
265
|
const isIPv4MappedIPv6 = (ipv6binary) => ipv6binary >> 32n === 0xffffn;
|
|
264
266
|
const convertIPv4MappedIPv6ToIPv4 = (ipv6binary) => ipv6binary & 0xffffffffn;
|
|
265
267
|
const convertIPv6BinaryToString = (ipV6) => {
|
|
268
|
+
if (ipV6 === 0n) {
|
|
269
|
+
return "::";
|
|
270
|
+
}
|
|
266
271
|
if (isIPv4MappedIPv6(ipV6)) {
|
|
267
272
|
return `::ffff:${convertIPv4BinaryToString(convertIPv4MappedIPv6ToIPv4(ipV6))}`;
|
|
268
273
|
}
|
|
@@ -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
|
})
|