@zuplo/cli 6.71.10 → 6.71.12
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/node_modules/@posthog/core/dist/logs/index.d.ts +2 -1
- package/node_modules/@posthog/core/dist/logs/index.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/logs/index.js +3 -2
- package/node_modules/@posthog/core/dist/logs/index.mjs +3 -2
- package/node_modules/@posthog/core/dist/logs/logs-utils.d.ts +5 -5
- package/node_modules/@posthog/core/dist/logs/logs-utils.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/logs/logs-utils.js +3 -3
- package/node_modules/@posthog/core/dist/logs/logs-utils.mjs +3 -3
- package/node_modules/@posthog/core/dist/types.d.ts +23 -2
- package/node_modules/@posthog/core/dist/types.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/utils/index.d.ts +1 -0
- package/node_modules/@posthog/core/dist/utils/index.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/utils/index.js +17 -2
- package/node_modules/@posthog/core/dist/utils/index.mjs +5 -1
- package/node_modules/@posthog/core/package.json +2 -2
- package/node_modules/@posthog/core/src/logs/index.spec.ts +26 -0
- package/node_modules/@posthog/core/src/logs/index.ts +6 -2
- package/node_modules/@posthog/core/src/logs/logs-utils.ts +8 -8
- package/node_modules/@posthog/core/src/types.ts +23 -2
- package/node_modules/@posthog/core/src/utils/index.ts +8 -0
- package/node_modules/@posthog/types/dist/posthog-config.d.ts +24 -1
- package/node_modules/@posthog/types/dist/posthog-config.d.ts.map +1 -1
- package/node_modules/@posthog/types/package.json +1 -1
- package/node_modules/@posthog/types/src/posthog-config.ts +25 -1
- package/node_modules/@zuplo/core/package.json +1 -1
- package/node_modules/@zuplo/graphql/package.json +1 -1
- package/node_modules/@zuplo/openapi-tools/package.json +1 -1
- package/node_modules/@zuplo/otel/package.json +1 -1
- package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +13 -13
- package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js.map +1 -1
- package/node_modules/@zuplo/runtime/package.json +3 -1
- package/node_modules/hono/dist/adapter/aws-lambda/handler.js +9 -17
- package/node_modules/hono/dist/cjs/adapter/aws-lambda/handler.js +9 -17
- 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/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/tsconfig.build.tsbuildinfo +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/package.json +1 -1
- package/package.json +6 -6
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zuplo/runtime",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "6.71.
|
|
4
|
+
"version": "6.71.12",
|
|
5
5
|
"repository": "https://github.com/zuplo/zuplo",
|
|
6
6
|
"author": "Zuplo, Inc.",
|
|
7
7
|
"exports": {
|
|
@@ -38,6 +38,8 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@cfworker/json-schema": "4.1.1",
|
|
40
40
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
41
|
+
"@opentelemetry/api": "1.9.0",
|
|
42
|
+
"@opentelemetry/api-logs": "0.201.1",
|
|
41
43
|
"ajv": "^8.17.1",
|
|
42
44
|
"bs58": "^6.0.0",
|
|
43
45
|
"cookie": "^1.0.1",
|
|
@@ -209,21 +209,17 @@ var EventV1Processor = class extends EventProcessor {
|
|
|
209
209
|
getHeaders(event) {
|
|
210
210
|
const headers = new Headers();
|
|
211
211
|
this.getCookies(event, headers);
|
|
212
|
-
if (event.headers) {
|
|
213
|
-
for (const [k, v] of Object.entries(event.headers)) {
|
|
214
|
-
if (v) {
|
|
215
|
-
headers.set(k, sanitizeHeaderValue(v));
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
212
|
if (event.multiValueHeaders) {
|
|
220
213
|
for (const [k, values] of Object.entries(event.multiValueHeaders)) {
|
|
221
214
|
if (values) {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
215
|
+
values.forEach((v) => headers.append(k, sanitizeHeaderValue(v)));
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
if (event.headers) {
|
|
220
|
+
for (const [k, v] of Object.entries(event.headers)) {
|
|
221
|
+
if (v && !headers.has(k)) {
|
|
222
|
+
headers.set(k, sanitizeHeaderValue(v));
|
|
227
223
|
}
|
|
228
224
|
}
|
|
229
225
|
}
|
|
@@ -303,11 +299,7 @@ var LatticeV2Processor = class extends EventProcessor {
|
|
|
303
299
|
if (event.headers) {
|
|
304
300
|
for (const [k, values] of Object.entries(event.headers)) {
|
|
305
301
|
if (values) {
|
|
306
|
-
|
|
307
|
-
values.forEach((v) => {
|
|
308
|
-
const sanitizedValue = sanitizeHeaderValue(v);
|
|
309
|
-
return (!foundK || !foundK.includes(sanitizedValue)) && headers.append(k, sanitizedValue);
|
|
310
|
-
});
|
|
302
|
+
values.forEach((v) => headers.append(k, sanitizeHeaderValue(v)));
|
|
311
303
|
}
|
|
312
304
|
}
|
|
313
305
|
}
|
|
@@ -239,21 +239,17 @@ class EventV1Processor extends EventProcessor {
|
|
|
239
239
|
getHeaders(event) {
|
|
240
240
|
const headers = new Headers();
|
|
241
241
|
this.getCookies(event, headers);
|
|
242
|
-
if (event.headers) {
|
|
243
|
-
for (const [k, v] of Object.entries(event.headers)) {
|
|
244
|
-
if (v) {
|
|
245
|
-
headers.set(k, sanitizeHeaderValue(v));
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
242
|
if (event.multiValueHeaders) {
|
|
250
243
|
for (const [k, values] of Object.entries(event.multiValueHeaders)) {
|
|
251
244
|
if (values) {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
245
|
+
values.forEach((v) => headers.append(k, sanitizeHeaderValue(v)));
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
if (event.headers) {
|
|
250
|
+
for (const [k, v] of Object.entries(event.headers)) {
|
|
251
|
+
if (v && !headers.has(k)) {
|
|
252
|
+
headers.set(k, sanitizeHeaderValue(v));
|
|
257
253
|
}
|
|
258
254
|
}
|
|
259
255
|
}
|
|
@@ -333,11 +329,7 @@ class LatticeV2Processor extends EventProcessor {
|
|
|
333
329
|
if (event.headers) {
|
|
334
330
|
for (const [k, values] of Object.entries(event.headers)) {
|
|
335
331
|
if (values) {
|
|
336
|
-
|
|
337
|
-
values.forEach((v) => {
|
|
338
|
-
const sanitizedValue = sanitizeHeaderValue(v);
|
|
339
|
-
return (!foundK || !foundK.includes(sanitizedValue)) && headers.append(k, sanitizedValue);
|
|
340
|
-
});
|
|
332
|
+
values.forEach((v) => headers.append(k, sanitizeHeaderValue(v)));
|
|
341
333
|
}
|
|
342
334
|
}
|
|
343
335
|
}
|
|
@@ -61,6 +61,7 @@ const normalizeLabel = (label) => {
|
|
|
61
61
|
return label.trim().replace(/\s+/g, "-");
|
|
62
62
|
};
|
|
63
63
|
const isValidClassName = (name) => /^-?[_a-zA-Z][_a-zA-Z0-9-]*$/.test(name);
|
|
64
|
+
const hasUnsafeSelectorChar = (name) => /[<{}]/.test(name);
|
|
64
65
|
const RESERVED_KEYFRAME_NAMES = /* @__PURE__ */ new Set([
|
|
65
66
|
"default",
|
|
66
67
|
"inherit",
|
|
@@ -198,7 +199,8 @@ const cxCommon = (args) => {
|
|
|
198
199
|
[CLASS_NAME]: "",
|
|
199
200
|
[STYLE_STRING]: "",
|
|
200
201
|
[SELECTORS]: [],
|
|
201
|
-
|
|
202
|
+
// drop names that are unsafe to emit as a selector
|
|
203
|
+
[EXTERNAL_CLASS_NAMES]: hasUnsafeSelectorChar(arg) ? [] : [arg]
|
|
202
204
|
};
|
|
203
205
|
}
|
|
204
206
|
}
|
|
@@ -29,6 +29,7 @@ module.exports = __toCommonJS(css_exports);
|
|
|
29
29
|
var import_html = require("../../helper/html");
|
|
30
30
|
var import_constants = require("../../jsx/constants");
|
|
31
31
|
var import_css = require("../../jsx/dom/css");
|
|
32
|
+
var import_html2 = require("../../utils/html");
|
|
32
33
|
var import_common = require("./common");
|
|
33
34
|
var import_common2 = require("./common");
|
|
34
35
|
const createCssContext = ({
|
|
@@ -88,7 +89,14 @@ const createCssContext = ({
|
|
|
88
89
|
}
|
|
89
90
|
return Promise.resolve((0, import_html.raw)("", [appendStyle]));
|
|
90
91
|
};
|
|
91
|
-
const
|
|
92
|
+
const rawClassName = cssClassName[import_common.CLASS_NAME];
|
|
93
|
+
let escapedClassName = rawClassName;
|
|
94
|
+
if (/[&<>'"]/.test(rawClassName)) {
|
|
95
|
+
const escapedBuffer = [""];
|
|
96
|
+
(0, import_html2.escapeToBuffer)(rawClassName, escapedBuffer);
|
|
97
|
+
escapedClassName = escapedBuffer[0];
|
|
98
|
+
}
|
|
99
|
+
const className = new String(escapedClassName);
|
|
92
100
|
Object.assign(className, cssClassName);
|
|
93
101
|
className.isEscaped = true;
|
|
94
102
|
className.callbacks = [addClassNameToContext];
|
|
@@ -125,7 +125,7 @@ class JSXNode {
|
|
|
125
125
|
key;
|
|
126
126
|
children;
|
|
127
127
|
isEscaped = true;
|
|
128
|
-
|
|
128
|
+
suspendedContext;
|
|
129
129
|
constructor(tag, props, children) {
|
|
130
130
|
if (typeof tag !== "function" && !(0, import_utils.isValidTagName)(tag)) {
|
|
131
131
|
throw new Error(`Invalid JSX tag name: ${tag}`);
|
|
@@ -143,18 +143,12 @@ class JSXNode {
|
|
|
143
143
|
return this.props.ref || null;
|
|
144
144
|
}
|
|
145
145
|
toString() {
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
context.values.push(value);
|
|
149
|
-
});
|
|
150
|
-
try {
|
|
146
|
+
const render = () => {
|
|
147
|
+
const buffer = [""];
|
|
151
148
|
this.toStringToBuffer(buffer);
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
return buffer.length === 1 ? "callbacks" in buffer ? (0, import_html2.resolveCallbackSync)((0, import_html.raw)(buffer[0], buffer.callbacks)).toString() : buffer[0] : (0, import_html2.stringBufferToString)(buffer, buffer.callbacks);
|
|
149
|
+
return buffer.length === 1 ? "callbacks" in buffer ? (0, import_html2.resolveCallbackSync)((0, import_html.raw)(buffer[0], buffer.callbacks)).toString() : buffer[0] : (0, import_html2.stringBufferToString)(buffer, buffer.callbacks);
|
|
150
|
+
};
|
|
151
|
+
return this.suspendedContext ? this.suspendedContext(render) : (0, import_context.runWithRenderContext)(render);
|
|
158
152
|
}
|
|
159
153
|
toStringToBuffer(buffer) {
|
|
160
154
|
const tag = this.tag;
|
|
@@ -230,12 +224,12 @@ class JSXFunctionNode extends JSXNode {
|
|
|
230
224
|
if (import_context.globalContexts.length === 0) {
|
|
231
225
|
buffer.unshift("", res);
|
|
232
226
|
} else {
|
|
233
|
-
const
|
|
227
|
+
const suspendedContext = (0, import_context.captureRenderContext)();
|
|
234
228
|
buffer.unshift(
|
|
235
229
|
"",
|
|
236
230
|
res.then((childRes) => {
|
|
237
231
|
if (childRes instanceof JSXNode) {
|
|
238
|
-
childRes.
|
|
232
|
+
childRes.suspendedContext = suspendedContext;
|
|
239
233
|
}
|
|
240
234
|
return childRes;
|
|
241
235
|
})
|
|
@@ -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;
|
|
@@ -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
|
})
|