@skyramp/mcp 0.3.2 → 0.3.4
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/build/index.js +47 -2
- package/build/playwright/PlaywrightTraceService.d.ts +8 -0
- package/build/playwright/PlaywrightTraceService.js +1 -0
- package/build/playwright/registerPlaywrightTools.js +42 -1
- package/build/prompts/enhance-assertions/sharedAssertionRules.js +19 -0
- package/build/prompts/pom-aware-code-reuse.js +17 -8
- package/build/prompts/test-maintenance/actionsInstructions.js +2 -2
- package/build/prompts/test-recommendation/analysisOutputPrompt.js +1 -4
- package/build/prompts/test-recommendation/recommendationSections.d.ts +1 -1
- package/build/prompts/test-recommendation/recommendationSections.js +5 -5
- package/build/prompts/test-recommendation/test-recommendation-prompt.js +13 -7
- package/build/prompts/testbot/testbot-prompts.d.ts +2 -12
- package/build/prompts/testbot/testbot-prompts.js +28 -16
- package/build/recommendation/discriminators.d.ts +7 -1
- package/build/recommendation/discriminators.js +16 -3
- package/build/resources/testbotResource.js +20 -4
- package/build/services/ScenarioGenerationService.js +5 -2
- package/build/services/TestExecutionService.d.ts +13 -8
- package/build/services/TestExecutionService.js +73 -26
- package/build/services/TestGenerationService.js +24 -9
- package/build/services/containerEnv.d.ts +12 -1
- package/build/services/containerEnv.js +118 -1
- package/build/tools/executeSkyrampTestTool.d.ts +9 -0
- package/build/tools/executeSkyrampTestTool.js +20 -6
- package/build/tools/execution-video-state.d.ts +21 -0
- package/build/tools/execution-video-state.js +51 -0
- package/build/tools/generate-tests/generateBatchScenarioRestTool.js +31 -11
- package/build/tools/generate-tests/planGuard.d.ts +5 -5
- package/build/tools/generate-tests/planGuard.js +5 -17
- package/build/tools/queryProxyMocksTool.js +0 -1
- package/build/tools/submitReportTool.d.ts +83 -10
- package/build/tools/submitReportTool.js +179 -29
- package/build/tools/test-management/actionsTool.js +52 -41
- package/build/tools/test-management/analyzeChangesTool.d.ts +11 -0
- package/build/tools/test-management/analyzeChangesTool.js +37 -33
- package/build/tools/test-management/analyzeTestHealthTool.js +3 -3
- package/build/tools/test-management/registerTestPlanTool.js +113 -31
- package/build/types/TestAnalysis.d.ts +7 -3
- package/build/types/TestExecution.d.ts +14 -0
- package/build/types/TestTypes.js +3 -2
- package/build/types/TestbotPromptOptions.d.ts +34 -0
- package/build/types/TestbotPromptOptions.js +1 -0
- package/build/types/TestbotReport.d.ts +10 -0
- package/build/types/TestbotReport.js +10 -1
- package/build/types/index.d.ts +2 -0
- package/build/types/index.js +1 -0
- package/build/utils/AnalysisStateManager.d.ts +36 -2
- package/build/utils/AnalysisStateManager.js +34 -13
- package/build/utils/frontendSelectors.js +0 -1
- package/build/utils/gitStaging.d.ts +5 -0
- package/build/utils/gitStaging.js +1 -1
- package/build/utils/pom-catalog.d.ts +23 -0
- package/build/utils/pom-catalog.js +30 -0
- package/build/utils/pom-scope/pom-files.d.ts +14 -0
- package/build/utils/pom-scope/pom-files.js +32 -6
- package/build/utils/pom-scope/testIdDiscovery.d.ts +40 -0
- package/build/utils/pom-scope/testIdDiscovery.js +104 -0
- package/build/utils/reportVerification.d.ts +7 -2
- package/build/utils/reportVerification.js +9 -3
- package/build/utils/scenarioDrafting.js +7 -1
- package/build/utils/skyrampMdContent.d.ts +1 -1
- package/build/utils/skyrampMdContent.js +1 -1
- package/build/utils/urlPath.d.ts +37 -0
- package/build/utils/urlPath.js +55 -0
- package/build/utils/utils.d.ts +45 -0
- package/build/utils/utils.js +50 -0
- package/build/utils/versions.d.ts +3 -3
- package/build/utils/versions.js +1 -1
- package/build/utils/workspaceAuth.d.ts +15 -15
- package/build/utils/workspaceAuth.js +32 -17
- package/build/workspace/queryParamResolution.d.ts +93 -0
- package/build/workspace/queryParamResolution.js +201 -0
- package/build/workspace/workspace.d.ts +104 -0
- package/build/workspace/workspace.js +24 -0
- package/node_modules/playwright/ThirdPartyNotices.txt +319 -266
- package/node_modules/playwright/lib/dom-analyzer/blueprint.js +154 -27
- package/node_modules/playwright/lib/dom-analyzer/crawler.js +2 -2
- package/node_modules/playwright/lib/mcp/browser/tools/pageBlueprint.js +1 -1
- package/node_modules/playwright/lib/mcp/browser/tools/sitemap.js +6 -2
- package/node_modules/playwright/lib/mcp/skyramp/loadTraceTool.js +3 -2
- package/node_modules/playwright/lib/mcp/skyramp/resultCode.js +4 -3
- package/node_modules/playwright/lib/mcp/skyramp/skyRampImport.js +15 -3
- package/node_modules/playwright/lib/mcp/skyramp/specImport.js +781 -0
- package/node_modules/playwright/lib/mcp/skyramp/traceRecordingBackend.js +14 -3
- package/node_modules/playwright/lib/mcp/test/resultCode.test.js +2 -1
- package/node_modules/playwright/lib/mcp/test/skyRampExport.js +1 -1
- package/node_modules/playwright/lib/mcp/test/skyRampExport.test.js +30 -0
- package/node_modules/playwright/lib/transform/babelBundleImpl.js +200 -199
- package/node_modules/playwright/node_modules/playwright-core/ThirdPartyNotices.txt +3 -3
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/.package-lock.json +3 -3
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/adapter/aws-lambda/handler.js +16 -25
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/adapter/bun/websocket.js +3 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/adapter/lambda-edge/handler.js +20 -4
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/adapter/aws-lambda/handler.js +16 -25
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/adapter/bun/websocket.js +3 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/adapter/lambda-edge/handler.js +20 -4
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/client/client.js +10 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/client/utils.js +1 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/helper/css/common.js +3 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/helper/css/index.js +9 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/jsx/base.js +8 -14
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/jsx/components.js +41 -21
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/jsx/context.js +131 -5
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/jsx/streaming.js +9 -7
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/middleware/bearer-auth/index.js +1 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/middleware/cache/index.js +1 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/middleware/compress/index.js +2 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/middleware/cors/index.js +2 -5
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/middleware/etag/index.js +2 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/middleware/language/language.js +10 -32
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/middleware/method-override/index.js +5 -3
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/middleware/serve-static/index.js +2 -2
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/middleware/timing/timing.js +3 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/router/trie-router/node.js +9 -0
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/utils/body.js +12 -4
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/utils/buffer.js +2 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/utils/ipaddr.js +6 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/cjs/validator/validator.js +3 -3
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/client/client.js +10 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/client/utils.js +1 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/helper/css/common.js +3 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/helper/css/index.js +9 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/jsx/base.js +15 -15
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/jsx/components.js +42 -22
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/jsx/context.js +129 -5
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/jsx/streaming.js +10 -8
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/middleware/bearer-auth/index.js +1 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/middleware/cache/index.js +1 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/middleware/compress/index.js +2 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/middleware/cors/index.js +2 -5
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/middleware/etag/index.js +2 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/middleware/language/language.js +10 -32
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/middleware/method-override/index.js +5 -3
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/middleware/serve-static/index.js +2 -2
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/middleware/timing/timing.js +3 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/router/trie-router/node.js +9 -0
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/types/adapter/aws-lambda/handler.d.ts +1 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/types/adapter/lambda-edge/handler.d.ts +1 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/types/helper/websocket/index.d.ts +1 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/types/jsx/base.d.ts +1 -3
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/types/jsx/context.d.ts +39 -0
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/types/middleware/context-storage/index.d.ts +2 -2
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/types/middleware/language/language.d.ts +18 -0
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/types/utils/body.d.ts +1 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/types/utils/types.d.ts +1 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/utils/body.js +12 -4
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/utils/buffer.js +2 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/utils/ipaddr.js +6 -1
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/validator/validator.js +3 -3
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/package.json +29 -22
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/package-lock.json +3 -3
- package/node_modules/playwright/node_modules/playwright-core/lib/generated/pollingRecorderSource.js +1 -1
- package/node_modules/playwright/node_modules/playwright-core/lib/server/codegen/skyramp/jsonlReader.js +5 -1
- package/node_modules/playwright/node_modules/playwright-core/lib/server/codegen/skyramp/specReader.js +781 -0
- package/node_modules/playwright/node_modules/playwright-core/lib/server/recorder/recorderApp.js +25 -6
- package/node_modules/playwright/node_modules/playwright-core/lib/server/recorder/skyramp/replayEngine.js +3 -1
- package/node_modules/playwright/node_modules/playwright-core/lib/utils.js +2 -0
- package/node_modules/playwright/node_modules/playwright-core/lib/vite/htmlReport/index.html +253 -27
- package/node_modules/playwright/node_modules/playwright-core/lib/vite/recorder/assets/{codeMirrorModule-D0BjbCb7.js → codeMirrorModule-DtudTj_v.js} +1 -1
- package/node_modules/playwright/node_modules/playwright-core/lib/vite/recorder/assets/index-BpDwp16L.js +422 -0
- package/node_modules/playwright/node_modules/playwright-core/lib/vite/recorder/index.html +1 -1
- package/node_modules/playwright/node_modules/playwright-core/lib/vite/traceViewer/assets/{codeMirrorModule-Bzd72-bG.js → codeMirrorModule-FNMuBzX1.js} +1 -1
- package/node_modules/playwright/node_modules/playwright-core/lib/vite/traceViewer/assets/defaultSettingsView-Co9upU5h.js +1035 -0
- package/node_modules/playwright/node_modules/playwright-core/lib/vite/traceViewer/index.DXNIQ_dx.js +2 -0
- package/node_modules/playwright/node_modules/playwright-core/lib/vite/traceViewer/index.html +2 -2
- package/node_modules/playwright/node_modules/playwright-core/lib/vite/traceViewer/uiMode.CIKB3XSv.js +5 -0
- package/node_modules/playwright/node_modules/playwright-core/lib/vite/traceViewer/uiMode.html +2 -2
- package/node_modules/playwright/node_modules/playwright-core/package.json +1 -1
- package/node_modules/playwright/node_modules/playwright-core/src/generated/pollingRecorderSource.ts +1 -1
- package/node_modules/playwright/node_modules/playwright-core/src/server/codegen/skyramp/jsonlReader.ts +4 -0
- package/node_modules/playwright/node_modules/playwright-core/src/server/codegen/skyramp/specReader.ts +1028 -0
- package/node_modules/playwright/node_modules/playwright-core/src/server/recorder/recorderApp.ts +31 -8
- package/node_modules/playwright/node_modules/playwright-core/src/server/recorder/skyramp/replayEngine.ts +1 -0
- package/node_modules/playwright/node_modules/playwright-core/src/utils.ts +1 -0
- package/node_modules/playwright/package.json +1 -1
- package/package.json +10 -6
- package/node_modules/playwright/node_modules/playwright-core/bundles/mcp/node_modules/hono/dist/tsconfig.build.tsbuildinfo +0 -1
- package/node_modules/playwright/node_modules/playwright-core/lib/vite/recorder/assets/index-lvTRGFx-.js +0 -193
- package/node_modules/playwright/node_modules/playwright-core/lib/vite/traceViewer/assets/defaultSettingsView-DzxTioTK.js +0 -809
- package/node_modules/playwright/node_modules/playwright-core/lib/vite/traceViewer/index.BGc30U3S.js +0 -2
- package/node_modules/playwright/node_modules/playwright-core/lib/vite/traceViewer/uiMode.IaDrb29A.js +0 -5
|
@@ -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 = "";
|
|
@@ -55,7 +55,7 @@ const cache = (options) => {
|
|
|
55
55
|
);
|
|
56
56
|
const addHeader = (c, responseVary) => {
|
|
57
57
|
if (cacheControlDirectives) {
|
|
58
|
-
const existingDirectives = c.res.headers.get("Cache-Control")?.split(",").map((d) => d.trim().split("=", 1)[0]) ?? [];
|
|
58
|
+
const existingDirectives = c.res.headers.get("Cache-Control")?.split(",").map((d) => d.trim().split("=", 1)[0].toLowerCase()) ?? [];
|
|
59
59
|
for (const directive of cacheControlDirectives) {
|
|
60
60
|
let [name, value] = directive.trim().split("=", 2);
|
|
61
61
|
name = name.toLowerCase();
|
|
@@ -57,7 +57,8 @@ const compress = (options) => {
|
|
|
57
57
|
return async function compress2(ctx, next) {
|
|
58
58
|
await next();
|
|
59
59
|
const contentLength = ctx.res.headers.get("Content-Length");
|
|
60
|
-
if (ctx.res.
|
|
60
|
+
if (ctx.res.status === 206 || // partial content, Content-Range refers to the uncompressed bytes
|
|
61
|
+
ctx.res.headers.has("Content-Encoding") || // already encoded
|
|
61
62
|
ctx.res.headers.has("Transfer-Encoding") || // already encoded or chunked
|
|
62
63
|
ctx.req.method === "HEAD" || // HEAD request
|
|
63
64
|
contentLength && Number(contentLength) < threshold || // content-length below threshold
|
|
@@ -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
|
};
|
|
@@ -70,7 +70,8 @@ const etag = (options) => {
|
|
|
70
70
|
}
|
|
71
71
|
etag3 = weak ? `W/"${hash}"` : `"${hash}"`;
|
|
72
72
|
}
|
|
73
|
-
|
|
73
|
+
const matched = ifNoneMatch === "*" ? (c.req.method === "GET" || c.req.method === "HEAD") && res.ok : etagMatches(etag3, ifNoneMatch);
|
|
74
|
+
if (matched) {
|
|
74
75
|
c.res = new Response(null, {
|
|
75
76
|
status: 304,
|
|
76
77
|
statusText: "Not Modified",
|
|
@@ -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
|
};
|
|
@@ -80,11 +80,13 @@ const methodOverride = (options) => async function methodOverride2(c, next) {
|
|
|
80
80
|
if (method) {
|
|
81
81
|
const url = new URL(c.req.url);
|
|
82
82
|
url.searchParams.delete(queryName);
|
|
83
|
-
const
|
|
83
|
+
const requestInit = {
|
|
84
84
|
body: c.req.raw.body,
|
|
85
85
|
headers: c.req.raw.headers,
|
|
86
|
-
method
|
|
87
|
-
|
|
86
|
+
method,
|
|
87
|
+
duplex: c.req.raw.body ? "half" : void 0
|
|
88
|
+
};
|
|
89
|
+
const request = new Request(url.toString(), requestInit);
|
|
88
90
|
return app.fetch(request, c.env, getExecutionCtx(c));
|
|
89
91
|
}
|
|
90
92
|
}
|
|
@@ -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))) {
|
|
@@ -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) {
|
|
@@ -155,6 +155,15 @@ class Node {
|
|
|
155
155
|
if (m) {
|
|
156
156
|
params[name] = m[0];
|
|
157
157
|
this.#pushHandlerSets(handlerSets, child, method, node.#params, params);
|
|
158
|
+
if (m[0].length === restPathString.length && child.#children["*"]) {
|
|
159
|
+
this.#pushHandlerSets(
|
|
160
|
+
handlerSets,
|
|
161
|
+
child.#children["*"],
|
|
162
|
+
method,
|
|
163
|
+
node.#params,
|
|
164
|
+
params
|
|
165
|
+
);
|
|
166
|
+
}
|
|
158
167
|
if (hasChildren(child.#children)) {
|
|
159
168
|
child.#params = params;
|
|
160
169
|
const componentCount = m[0].match(/\//)?.length ?? 0;
|
|
@@ -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();
|
|
@@ -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
|
}
|
|
@@ -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 = {};
|
|
@@ -170,7 +170,16 @@ var hc = (baseUrl, options) => createProxy(function proxyCallback(opts) {
|
|
|
170
170
|
});
|
|
171
171
|
if (method) {
|
|
172
172
|
options ??= {};
|
|
173
|
-
const
|
|
173
|
+
const reqOptions = { ...opts.args[1] };
|
|
174
|
+
const baseHeaders = options.headers;
|
|
175
|
+
const reqHeaders = reqOptions.headers;
|
|
176
|
+
if (baseHeaders && reqHeaders) {
|
|
177
|
+
reqOptions.headers = async () => ({
|
|
178
|
+
...typeof baseHeaders === "function" ? await baseHeaders() : baseHeaders,
|
|
179
|
+
...typeof reqHeaders === "function" ? await reqHeaders() : reqHeaders
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
const args = deepMerge(options, reqOptions);
|
|
174
183
|
return req.fetch(opts.args[0], args);
|
|
175
184
|
}
|
|
176
185
|
return req;
|
|
@@ -8,7 +8,7 @@ var mergePath = (base, path) => {
|
|
|
8
8
|
};
|
|
9
9
|
var replaceUrlParam = (urlString, params) => {
|
|
10
10
|
for (const [k, v] of Object.entries(params)) {
|
|
11
|
-
const reg = new RegExp("/:" + k + "(?:{[^/]+})?\\??");
|
|
11
|
+
const reg = new RegExp("/:" + k + "(?:{[^/]+})?\\??(?=/|$)");
|
|
12
12
|
urlString = urlString.replace(reg, v ? `/${v}` : "");
|
|
13
13
|
}
|
|
14
14
|
return urlString;
|
|
@@ -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
|
})
|