@bleedingdev/modern-js-server-core 3.2.0-ultramodern.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/LICENSE +21 -0
- package/README.md +26 -0
- package/dist/cjs/adapters/node/helper/index.js +55 -0
- package/dist/cjs/adapters/node/helper/loadCache.js +58 -0
- package/dist/cjs/adapters/node/helper/loadConfig.js +78 -0
- package/dist/cjs/adapters/node/helper/loadEnv.js +66 -0
- package/dist/cjs/adapters/node/helper/loadPlugin.js +47 -0
- package/dist/cjs/adapters/node/helper/utils.js +39 -0
- package/dist/cjs/adapters/node/hono.js +95 -0
- package/dist/cjs/adapters/node/index.js +87 -0
- package/dist/cjs/adapters/node/node.js +180 -0
- package/dist/cjs/adapters/node/plugins/index.js +72 -0
- package/dist/cjs/adapters/node/plugins/nodeServer.js +43 -0
- package/dist/cjs/adapters/node/plugins/resource.js +206 -0
- package/dist/cjs/adapters/node/plugins/static.js +379 -0
- package/dist/cjs/constants.js +77 -0
- package/dist/cjs/context.js +41 -0
- package/dist/cjs/helper.js +45 -0
- package/dist/cjs/hono.js +46 -0
- package/dist/cjs/index.js +247 -0
- package/dist/cjs/plugins/compat/hooks.js +80 -0
- package/dist/cjs/plugins/compat/index.js +64 -0
- package/dist/cjs/plugins/contractGateAutopilot.js +158 -0
- package/dist/cjs/plugins/contractGateSnapshotStore.js +239 -0
- package/dist/cjs/plugins/default.js +61 -0
- package/dist/cjs/plugins/favicon.js +48 -0
- package/dist/cjs/plugins/index.js +157 -0
- package/dist/cjs/plugins/log.js +92 -0
- package/dist/cjs/plugins/mfCache.js +78 -0
- package/dist/cjs/plugins/middlewares.js +49 -0
- package/dist/cjs/plugins/monitors.js +192 -0
- package/dist/cjs/plugins/processedBy.js +50 -0
- package/dist/cjs/plugins/render/csrRscRender.js +74 -0
- package/dist/cjs/plugins/render/dataHandler.js +53 -0
- package/dist/cjs/plugins/render/index.js +158 -0
- package/dist/cjs/plugins/render/inject.js +92 -0
- package/dist/cjs/plugins/render/render.js +273 -0
- package/dist/cjs/plugins/render/renderRscHandler.js +72 -0
- package/dist/cjs/plugins/render/serverActionHandler.js +47 -0
- package/dist/cjs/plugins/render/ssrCache.js +198 -0
- package/dist/cjs/plugins/render/ssrRender.js +96 -0
- package/dist/cjs/plugins/render/utils.js +49 -0
- package/dist/cjs/plugins/route.js +68 -0
- package/dist/cjs/plugins/telemetry.js +1283 -0
- package/dist/cjs/serverBase.js +176 -0
- package/dist/cjs/types/config/bff.js +18 -0
- package/dist/cjs/types/config/dev.js +18 -0
- package/dist/cjs/types/config/html.js +18 -0
- package/dist/cjs/types/config/index.js +93 -0
- package/dist/cjs/types/config/output.js +18 -0
- package/dist/cjs/types/config/security.js +18 -0
- package/dist/cjs/types/config/server.js +18 -0
- package/dist/cjs/types/config/share.js +18 -0
- package/dist/cjs/types/config/source.js +18 -0
- package/dist/cjs/types/config/tools.js +18 -0
- package/dist/cjs/types/index.js +79 -0
- package/dist/cjs/types/plugins/base.js +18 -0
- package/dist/cjs/types/plugins/index.js +58 -0
- package/dist/cjs/types/plugins/plugin.js +18 -0
- package/dist/cjs/types/render.js +18 -0
- package/dist/cjs/types/requestHandler.js +18 -0
- package/dist/cjs/types/server.js +18 -0
- package/dist/cjs/utils/entry.js +40 -0
- package/dist/cjs/utils/env.js +51 -0
- package/dist/cjs/utils/error.js +93 -0
- package/dist/cjs/utils/index.js +114 -0
- package/dist/cjs/utils/middlewareCollector.js +63 -0
- package/dist/cjs/utils/publicDir.js +92 -0
- package/dist/cjs/utils/request.js +86 -0
- package/dist/cjs/utils/serverConfig.js +43 -0
- package/dist/cjs/utils/storage.js +69 -0
- package/dist/cjs/utils/transformStream.js +65 -0
- package/dist/cjs/utils/warmup.js +40 -0
- package/dist/esm/adapters/node/helper/index.mjs +5 -0
- package/dist/esm/adapters/node/helper/loadCache.mjs +14 -0
- package/dist/esm/adapters/node/helper/loadConfig.mjs +31 -0
- package/dist/esm/adapters/node/helper/loadEnv.mjs +22 -0
- package/dist/esm/adapters/node/helper/loadPlugin.mjs +13 -0
- package/dist/esm/adapters/node/helper/utils.mjs +5 -0
- package/dist/esm/adapters/node/hono.mjs +55 -0
- package/dist/esm/adapters/node/index.mjs +4 -0
- package/dist/esm/adapters/node/node.mjs +130 -0
- package/dist/esm/adapters/node/plugins/index.mjs +3 -0
- package/dist/esm/adapters/node/plugins/nodeServer.mjs +9 -0
- package/dist/esm/adapters/node/plugins/resource.mjs +138 -0
- package/dist/esm/adapters/node/plugins/static.mjs +329 -0
- package/dist/esm/constants.mjs +28 -0
- package/dist/esm/context.mjs +4 -0
- package/dist/esm/helper.mjs +11 -0
- package/dist/esm/hono.mjs +2 -0
- package/dist/esm/index.mjs +12 -0
- package/dist/esm/plugins/compat/hooks.mjs +40 -0
- package/dist/esm/plugins/compat/index.mjs +27 -0
- package/dist/esm/plugins/contractGateAutopilot.mjs +124 -0
- package/dist/esm/plugins/contractGateSnapshotStore.mjs +180 -0
- package/dist/esm/plugins/default.mjs +27 -0
- package/dist/esm/plugins/favicon.mjs +14 -0
- package/dist/esm/plugins/index.mjs +11 -0
- package/dist/esm/plugins/log.mjs +58 -0
- package/dist/esm/plugins/mfCache.mjs +35 -0
- package/dist/esm/plugins/middlewares.mjs +15 -0
- package/dist/esm/plugins/monitors.mjs +149 -0
- package/dist/esm/plugins/processedBy.mjs +16 -0
- package/dist/esm/plugins/render/csrRscRender.mjs +40 -0
- package/dist/esm/plugins/render/dataHandler.mjs +19 -0
- package/dist/esm/plugins/render/index.mjs +84 -0
- package/dist/esm/plugins/render/inject.mjs +55 -0
- package/dist/esm/plugins/render/render.mjs +230 -0
- package/dist/esm/plugins/render/renderRscHandler.mjs +38 -0
- package/dist/esm/plugins/render/serverActionHandler.mjs +13 -0
- package/dist/esm/plugins/render/ssrCache.mjs +158 -0
- package/dist/esm/plugins/render/ssrRender.mjs +62 -0
- package/dist/esm/plugins/render/utils.mjs +15 -0
- package/dist/esm/plugins/route.mjs +34 -0
- package/dist/esm/plugins/telemetry.mjs +1195 -0
- package/dist/esm/rslib-runtime.mjs +18 -0
- package/dist/esm/serverBase.mjs +139 -0
- package/dist/esm/types/config/bff.mjs +0 -0
- package/dist/esm/types/config/dev.mjs +0 -0
- package/dist/esm/types/config/html.mjs +0 -0
- package/dist/esm/types/config/index.mjs +6 -0
- package/dist/esm/types/config/output.mjs +0 -0
- package/dist/esm/types/config/security.mjs +0 -0
- package/dist/esm/types/config/server.mjs +0 -0
- package/dist/esm/types/config/share.mjs +0 -0
- package/dist/esm/types/config/source.mjs +0 -0
- package/dist/esm/types/config/tools.mjs +0 -0
- package/dist/esm/types/index.mjs +4 -0
- package/dist/esm/types/plugins/base.mjs +0 -0
- package/dist/esm/types/plugins/index.mjs +1 -0
- package/dist/esm/types/plugins/plugin.mjs +0 -0
- package/dist/esm/types/render.mjs +0 -0
- package/dist/esm/types/requestHandler.mjs +0 -0
- package/dist/esm/types/server.mjs +0 -0
- package/dist/esm/utils/entry.mjs +3 -0
- package/dist/esm/utils/env.mjs +14 -0
- package/dist/esm/utils/error.mjs +53 -0
- package/dist/esm/utils/index.mjs +9 -0
- package/dist/esm/utils/middlewareCollector.mjs +26 -0
- package/dist/esm/utils/publicDir.mjs +33 -0
- package/dist/esm/utils/request.mjs +40 -0
- package/dist/esm/utils/serverConfig.mjs +9 -0
- package/dist/esm/utils/storage.mjs +35 -0
- package/dist/esm/utils/transformStream.mjs +28 -0
- package/dist/esm/utils/warmup.mjs +6 -0
- package/dist/esm-node/adapters/node/helper/index.mjs +6 -0
- package/dist/esm-node/adapters/node/helper/loadCache.mjs +15 -0
- package/dist/esm-node/adapters/node/helper/loadConfig.mjs +32 -0
- package/dist/esm-node/adapters/node/helper/loadEnv.mjs +23 -0
- package/dist/esm-node/adapters/node/helper/loadPlugin.mjs +14 -0
- package/dist/esm-node/adapters/node/helper/utils.mjs +6 -0
- package/dist/esm-node/adapters/node/hono.mjs +56 -0
- package/dist/esm-node/adapters/node/index.mjs +5 -0
- package/dist/esm-node/adapters/node/node.mjs +131 -0
- package/dist/esm-node/adapters/node/plugins/index.mjs +4 -0
- package/dist/esm-node/adapters/node/plugins/nodeServer.mjs +10 -0
- package/dist/esm-node/adapters/node/plugins/resource.mjs +139 -0
- package/dist/esm-node/adapters/node/plugins/static.mjs +330 -0
- package/dist/esm-node/constants.mjs +29 -0
- package/dist/esm-node/context.mjs +5 -0
- package/dist/esm-node/helper.mjs +12 -0
- package/dist/esm-node/hono.mjs +3 -0
- package/dist/esm-node/index.mjs +13 -0
- package/dist/esm-node/plugins/compat/hooks.mjs +41 -0
- package/dist/esm-node/plugins/compat/index.mjs +28 -0
- package/dist/esm-node/plugins/contractGateAutopilot.mjs +125 -0
- package/dist/esm-node/plugins/contractGateSnapshotStore.mjs +182 -0
- package/dist/esm-node/plugins/default.mjs +28 -0
- package/dist/esm-node/plugins/favicon.mjs +15 -0
- package/dist/esm-node/plugins/index.mjs +12 -0
- package/dist/esm-node/plugins/log.mjs +59 -0
- package/dist/esm-node/plugins/mfCache.mjs +36 -0
- package/dist/esm-node/plugins/middlewares.mjs +16 -0
- package/dist/esm-node/plugins/monitors.mjs +150 -0
- package/dist/esm-node/plugins/processedBy.mjs +17 -0
- package/dist/esm-node/plugins/render/csrRscRender.mjs +41 -0
- package/dist/esm-node/plugins/render/dataHandler.mjs +20 -0
- package/dist/esm-node/plugins/render/index.mjs +85 -0
- package/dist/esm-node/plugins/render/inject.mjs +56 -0
- package/dist/esm-node/plugins/render/render.mjs +231 -0
- package/dist/esm-node/plugins/render/renderRscHandler.mjs +39 -0
- package/dist/esm-node/plugins/render/serverActionHandler.mjs +14 -0
- package/dist/esm-node/plugins/render/ssrCache.mjs +159 -0
- package/dist/esm-node/plugins/render/ssrRender.mjs +63 -0
- package/dist/esm-node/plugins/render/utils.mjs +16 -0
- package/dist/esm-node/plugins/route.mjs +35 -0
- package/dist/esm-node/plugins/telemetry.mjs +1196 -0
- package/dist/esm-node/rslib-runtime.mjs +19 -0
- package/dist/esm-node/serverBase.mjs +140 -0
- package/dist/esm-node/types/config/bff.mjs +1 -0
- package/dist/esm-node/types/config/dev.mjs +1 -0
- package/dist/esm-node/types/config/html.mjs +1 -0
- package/dist/esm-node/types/config/index.mjs +7 -0
- package/dist/esm-node/types/config/output.mjs +1 -0
- package/dist/esm-node/types/config/security.mjs +1 -0
- package/dist/esm-node/types/config/server.mjs +1 -0
- package/dist/esm-node/types/config/share.mjs +1 -0
- package/dist/esm-node/types/config/source.mjs +1 -0
- package/dist/esm-node/types/config/tools.mjs +1 -0
- package/dist/esm-node/types/index.mjs +5 -0
- package/dist/esm-node/types/plugins/base.mjs +1 -0
- package/dist/esm-node/types/plugins/index.mjs +2 -0
- package/dist/esm-node/types/plugins/plugin.mjs +1 -0
- package/dist/esm-node/types/render.mjs +1 -0
- package/dist/esm-node/types/requestHandler.mjs +1 -0
- package/dist/esm-node/types/server.mjs +1 -0
- package/dist/esm-node/utils/entry.mjs +4 -0
- package/dist/esm-node/utils/env.mjs +15 -0
- package/dist/esm-node/utils/error.mjs +54 -0
- package/dist/esm-node/utils/index.mjs +10 -0
- package/dist/esm-node/utils/middlewareCollector.mjs +27 -0
- package/dist/esm-node/utils/publicDir.mjs +34 -0
- package/dist/esm-node/utils/request.mjs +41 -0
- package/dist/esm-node/utils/serverConfig.mjs +10 -0
- package/dist/esm-node/utils/storage.mjs +36 -0
- package/dist/esm-node/utils/transformStream.mjs +29 -0
- package/dist/esm-node/utils/warmup.mjs +7 -0
- package/dist/types/adapters/node/helper/index.d.ts +6 -0
- package/dist/types/adapters/node/helper/loadCache.d.ts +2 -0
- package/dist/types/adapters/node/helper/loadConfig.d.ts +3 -0
- package/dist/types/adapters/node/helper/loadEnv.d.ts +3 -0
- package/dist/types/adapters/node/helper/loadPlugin.d.ts +3 -0
- package/dist/types/adapters/node/helper/utils.d.ts +21 -0
- package/dist/types/adapters/node/hono.d.ts +19 -0
- package/dist/types/adapters/node/index.d.ts +5 -0
- package/dist/types/adapters/node/node.d.ts +17 -0
- package/dist/types/adapters/node/plugins/index.d.ts +3 -0
- package/dist/types/adapters/node/plugins/nodeServer.d.ts +6 -0
- package/dist/types/adapters/node/plugins/resource.d.ts +11 -0
- package/dist/types/adapters/node/plugins/static.d.ts +25 -0
- package/dist/types/constants.d.ts +26 -0
- package/dist/types/context.d.ts +3 -0
- package/dist/types/helper.d.ts +10 -0
- package/dist/types/hono.d.ts +3 -0
- package/dist/types/index.d.ts +14 -0
- package/dist/types/plugins/compat/hooks.d.ts +8 -0
- package/dist/types/plugins/compat/index.d.ts +3 -0
- package/dist/types/plugins/contractGateAutopilot.d.ts +35 -0
- package/dist/types/plugins/contractGateSnapshotStore.d.ts +57 -0
- package/dist/types/plugins/default.d.ts +7 -0
- package/dist/types/plugins/favicon.d.ts +2 -0
- package/dist/types/plugins/index.d.ts +11 -0
- package/dist/types/plugins/log.d.ts +2 -0
- package/dist/types/plugins/mfCache.d.ts +12 -0
- package/dist/types/plugins/middlewares.d.ts +2 -0
- package/dist/types/plugins/monitors.d.ts +6 -0
- package/dist/types/plugins/processedBy.d.ts +2 -0
- package/dist/types/plugins/render/csrRscRender.d.ts +2 -0
- package/dist/types/plugins/render/dataHandler.d.ts +5 -0
- package/dist/types/plugins/render/index.d.ts +3 -0
- package/dist/types/plugins/render/inject.d.ts +7 -0
- package/dist/types/plugins/render/render.d.ts +16 -0
- package/dist/types/plugins/render/renderRscHandler.d.ts +2 -0
- package/dist/types/plugins/render/serverActionHandler.d.ts +2 -0
- package/dist/types/plugins/render/ssrCache.d.ts +18 -0
- package/dist/types/plugins/render/ssrRender.d.ts +26 -0
- package/dist/types/plugins/render/utils.d.ts +3 -0
- package/dist/types/plugins/route.d.ts +2 -0
- package/dist/types/plugins/telemetry.d.ts +309 -0
- package/dist/types/serverBase.d.ts +38 -0
- package/dist/types/types/config/bff.d.ts +142 -0
- package/dist/types/types/config/dev.d.ts +4 -0
- package/dist/types/types/config/html.d.ts +15 -0
- package/dist/types/types/config/index.d.ts +35 -0
- package/dist/types/types/config/output.d.ts +20 -0
- package/dist/types/types/config/security.d.ts +4 -0
- package/dist/types/types/config/server.d.ts +402 -0
- package/dist/types/types/config/share.d.ts +3 -0
- package/dist/types/types/config/source.d.ts +7 -0
- package/dist/types/types/config/tools.d.ts +2 -0
- package/dist/types/types/index.d.ts +4 -0
- package/dist/types/types/plugins/base.d.ts +57 -0
- package/dist/types/types/plugins/index.d.ts +2 -0
- package/dist/types/types/plugins/plugin.d.ts +31 -0
- package/dist/types/types/render.d.ts +24 -0
- package/dist/types/types/requestHandler.d.ts +48 -0
- package/dist/types/types/server.d.ts +67 -0
- package/dist/types/utils/entry.d.ts +3 -0
- package/dist/types/utils/env.d.ts +2 -0
- package/dist/types/utils/error.d.ts +8 -0
- package/dist/types/utils/index.d.ts +9 -0
- package/dist/types/utils/middlewareCollector.d.ts +12 -0
- package/dist/types/utils/publicDir.d.ts +40 -0
- package/dist/types/utils/request.d.ts +17 -0
- package/dist/types/utils/serverConfig.d.ts +8 -0
- package/dist/types/utils/storage.d.ts +5 -0
- package/dist/types/utils/transformStream.d.ts +5 -0
- package/dist/types/utils/warmup.d.ts +1 -0
- package/package.json +103 -0
- package/rslib.config.mts +4 -0
- package/rstest.config.mts +7 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: definition[key]
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
(()=>{
|
|
21
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
+
})();
|
|
23
|
+
(()=>{
|
|
24
|
+
__webpack_require__.r = (exports1)=>{
|
|
25
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
+
value: 'Module'
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
+
value: true
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
var __webpack_exports__ = {};
|
|
34
|
+
__webpack_require__.r(__webpack_exports__);
|
|
35
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
CONTRACT_GATE_SNAPSHOT_SCHEMA_VERSION: ()=>CONTRACT_GATE_SNAPSHOT_SCHEMA_VERSION,
|
|
37
|
+
DEFAULT_CONTRACT_GATE_SNAPSHOT_PATH: ()=>DEFAULT_CONTRACT_GATE_SNAPSHOT_PATH,
|
|
38
|
+
createFileContractGateSnapshotStore: ()=>createFileContractGateSnapshotStore,
|
|
39
|
+
createHttpContractGateSnapshotStore: ()=>createHttpContractGateSnapshotStore,
|
|
40
|
+
resolveContractGateSnapshotPath: ()=>resolveContractGateSnapshotPath,
|
|
41
|
+
resolveContractGateSnapshotStore: ()=>resolveContractGateSnapshotStore
|
|
42
|
+
});
|
|
43
|
+
const utils_namespaceObject = require("@modern-js/utils");
|
|
44
|
+
const external_fs_namespaceObject = require("fs");
|
|
45
|
+
const external_path_namespaceObject = require("path");
|
|
46
|
+
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
47
|
+
const CONTRACT_GATE_SNAPSHOT_SCHEMA_VERSION = 1;
|
|
48
|
+
const DEFAULT_CONTRACT_GATE_SNAPSHOT_PATH = '.modern/contract-gates.json';
|
|
49
|
+
const DEFAULT_HTTP_STORE_TIMEOUT_MS = 5000;
|
|
50
|
+
const BUILTIN_HTTP_STATE_STORE_MODULES = new Set([
|
|
51
|
+
'http',
|
|
52
|
+
'@modern-js/server-core/http',
|
|
53
|
+
'@modern-js/server-core/contract-gate-http-store'
|
|
54
|
+
]);
|
|
55
|
+
const isRecord = (value)=>'object' == typeof value && null !== value && !Array.isArray(value);
|
|
56
|
+
const normalizeSnapshot = (snapshot)=>{
|
|
57
|
+
if (!isRecord(snapshot)) return;
|
|
58
|
+
const schemaVersion = 'number' == typeof snapshot.schemaVersion ? snapshot.schemaVersion : CONTRACT_GATE_SNAPSHOT_SCHEMA_VERSION;
|
|
59
|
+
const updatedAt = 'number' == typeof snapshot.updatedAt ? snapshot.updatedAt : Date.now();
|
|
60
|
+
const gates = isRecord(snapshot.gates) ? snapshot.gates : {};
|
|
61
|
+
return {
|
|
62
|
+
schemaVersion,
|
|
63
|
+
updatedAt,
|
|
64
|
+
gates
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
const normalizeHttpStoreOptions = (options)=>{
|
|
68
|
+
const endpoint = 'string' == typeof options?.endpoint ? options.endpoint.trim() : '';
|
|
69
|
+
if (!endpoint) throw new Error('[telemetry.canary.autopilot] HTTP stateStore requires options.endpoint');
|
|
70
|
+
const readMethod = 'string' == typeof options?.readMethod && options.readMethod.trim() ? options.readMethod.trim().toUpperCase() : 'GET';
|
|
71
|
+
const writeMethod = 'string' == typeof options?.writeMethod && options.writeMethod.trim() ? options.writeMethod.trim().toUpperCase() : 'PUT';
|
|
72
|
+
const timeoutMsRaw = Number(options?.timeoutMs);
|
|
73
|
+
const timeoutMs = Number.isFinite(timeoutMsRaw) && timeoutMsRaw > 0 ? Math.floor(timeoutMsRaw) : DEFAULT_HTTP_STORE_TIMEOUT_MS;
|
|
74
|
+
const headersRaw = options?.headers;
|
|
75
|
+
const headers = {};
|
|
76
|
+
if (headersRaw && 'object' == typeof headersRaw && !Array.isArray(headersRaw)) Object.entries(headersRaw).forEach(([key, value])=>{
|
|
77
|
+
if ('string' == typeof key && key.trim().length > 0 && null != value) headers[key] = String(value);
|
|
78
|
+
});
|
|
79
|
+
return {
|
|
80
|
+
endpoint,
|
|
81
|
+
readMethod,
|
|
82
|
+
writeMethod,
|
|
83
|
+
headers,
|
|
84
|
+
timeoutMs
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
const withTimeoutAbort = (timeoutMs)=>{
|
|
88
|
+
const controller = new AbortController();
|
|
89
|
+
const timer = setTimeout(()=>controller.abort(), timeoutMs);
|
|
90
|
+
return {
|
|
91
|
+
signal: controller.signal,
|
|
92
|
+
clear: ()=>clearTimeout(timer)
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
const createHttpContractGateSnapshotStore = (options)=>{
|
|
96
|
+
const normalized = normalizeHttpStoreOptions(options);
|
|
97
|
+
const endpoint = normalized.endpoint;
|
|
98
|
+
return {
|
|
99
|
+
name: `http:${endpoint}`,
|
|
100
|
+
async readSnapshot () {
|
|
101
|
+
const { signal, clear } = withTimeoutAbort(normalized.timeoutMs || 5000);
|
|
102
|
+
try {
|
|
103
|
+
const response = await fetch(endpoint, {
|
|
104
|
+
method: normalized.readMethod || 'GET',
|
|
105
|
+
headers: {
|
|
106
|
+
accept: 'application/json',
|
|
107
|
+
...normalized.headers || {}
|
|
108
|
+
},
|
|
109
|
+
signal
|
|
110
|
+
});
|
|
111
|
+
if (404 === response.status) return;
|
|
112
|
+
if (!response.ok) throw new Error(`HTTP stateStore read failed with status ${String(response.status)}`);
|
|
113
|
+
const payload = await response.json();
|
|
114
|
+
return normalizeSnapshot(payload);
|
|
115
|
+
} finally{
|
|
116
|
+
clear();
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
async writeSnapshot (snapshot) {
|
|
120
|
+
const body = JSON.stringify(normalizeSnapshot(snapshot) || {
|
|
121
|
+
schemaVersion: CONTRACT_GATE_SNAPSHOT_SCHEMA_VERSION,
|
|
122
|
+
updatedAt: Date.now(),
|
|
123
|
+
gates: {}
|
|
124
|
+
});
|
|
125
|
+
const { signal, clear } = withTimeoutAbort(normalized.timeoutMs || 5000);
|
|
126
|
+
try {
|
|
127
|
+
const response = await fetch(endpoint, {
|
|
128
|
+
method: normalized.writeMethod || 'PUT',
|
|
129
|
+
headers: {
|
|
130
|
+
'content-type': 'application/json',
|
|
131
|
+
...normalized.headers || {}
|
|
132
|
+
},
|
|
133
|
+
body,
|
|
134
|
+
signal
|
|
135
|
+
});
|
|
136
|
+
if (!response.ok) throw new Error(`HTTP stateStore write failed with status ${String(response.status)}`);
|
|
137
|
+
} finally{
|
|
138
|
+
clear();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
const tryResolveBuiltinSnapshotStore = (input)=>{
|
|
144
|
+
const moduleName = input.stateStore.module.trim();
|
|
145
|
+
if (!BUILTIN_HTTP_STATE_STORE_MODULES.has(moduleName)) return;
|
|
146
|
+
return createHttpContractGateSnapshotStore(input.stateStore.options || {});
|
|
147
|
+
};
|
|
148
|
+
const pickStoreFactory = (mod)=>{
|
|
149
|
+
if ('function' == typeof mod) return mod;
|
|
150
|
+
if ('function' == typeof mod.createContractGateSnapshotStore) return mod.createContractGateSnapshotStore;
|
|
151
|
+
if ('function' == typeof mod.default) return mod.default;
|
|
152
|
+
if (mod.default && 'object' == typeof mod.default && 'function' == typeof mod.default.createContractGateSnapshotStore) return mod.default.createContractGateSnapshotStore;
|
|
153
|
+
};
|
|
154
|
+
const ensureStoreShape = (store, modulePath)=>{
|
|
155
|
+
if (!store || 'object' != typeof store || 'function' != typeof store.readSnapshot || 'function' != typeof store.writeSnapshot) throw new Error(`Invalid contract gate snapshot store from "${modulePath}". Expected { readSnapshot(), writeSnapshot() }.`);
|
|
156
|
+
};
|
|
157
|
+
const resolveStoreModulePath = (appDirectory, modulePath)=>{
|
|
158
|
+
const normalized = modulePath.trim();
|
|
159
|
+
if (!normalized) throw new Error('Contract gate snapshot stateStore.module must be non-empty');
|
|
160
|
+
if (external_path_default().isAbsolute(normalized)) return normalized;
|
|
161
|
+
return normalized.startsWith('.') ? external_path_default().resolve(appDirectory, normalized) : normalized;
|
|
162
|
+
};
|
|
163
|
+
const resolveContractGateSnapshotPath = (appDirectory, configuredPath)=>{
|
|
164
|
+
const rawPath = configuredPath || process.env.MODERN_CONTRACT_GATES_FILE || DEFAULT_CONTRACT_GATE_SNAPSHOT_PATH;
|
|
165
|
+
if (external_path_default().isAbsolute(rawPath)) return rawPath;
|
|
166
|
+
return external_path_default().resolve(appDirectory, rawPath);
|
|
167
|
+
};
|
|
168
|
+
const createFileContractGateSnapshotStore = (gateSnapshotPath)=>{
|
|
169
|
+
const resolvedPath = external_path_default().resolve(gateSnapshotPath);
|
|
170
|
+
return {
|
|
171
|
+
name: `file:${resolvedPath}`,
|
|
172
|
+
async readSnapshot () {
|
|
173
|
+
if (!await utils_namespaceObject.fs.pathExists(resolvedPath)) return;
|
|
174
|
+
try {
|
|
175
|
+
const raw = await external_fs_namespaceObject.promises.readFile(resolvedPath, 'utf8');
|
|
176
|
+
return normalizeSnapshot(JSON.parse(raw));
|
|
177
|
+
} catch (_error) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
async writeSnapshot (snapshot) {
|
|
182
|
+
const normalized = normalizeSnapshot(snapshot) || {
|
|
183
|
+
schemaVersion: CONTRACT_GATE_SNAPSHOT_SCHEMA_VERSION,
|
|
184
|
+
updatedAt: Date.now(),
|
|
185
|
+
gates: {}
|
|
186
|
+
};
|
|
187
|
+
await external_fs_namespaceObject.promises.mkdir(external_path_default().dirname(resolvedPath), {
|
|
188
|
+
recursive: true
|
|
189
|
+
});
|
|
190
|
+
await external_fs_namespaceObject.promises.writeFile(resolvedPath, `${JSON.stringify(normalized, null, 2)}\n`);
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
const resolveContractGateSnapshotStore = async (input)=>{
|
|
195
|
+
const { appDirectory, gateSnapshotPath, stateStore, logger } = input;
|
|
196
|
+
if (!stateStore?.module) return createFileContractGateSnapshotStore(gateSnapshotPath);
|
|
197
|
+
const builtinStore = tryResolveBuiltinSnapshotStore({
|
|
198
|
+
stateStore
|
|
199
|
+
});
|
|
200
|
+
if (builtinStore) {
|
|
201
|
+
logger?.info?.(`[telemetry.canary.autopilot] using built-in contract gate snapshot store "${builtinStore.name}"`);
|
|
202
|
+
return builtinStore;
|
|
203
|
+
}
|
|
204
|
+
const modulePath = resolveStoreModulePath(appDirectory, stateStore.module);
|
|
205
|
+
let mod;
|
|
206
|
+
try {
|
|
207
|
+
mod = require(modulePath);
|
|
208
|
+
} catch (error) {
|
|
209
|
+
throw new Error(`[telemetry.canary.autopilot] Failed to load stateStore.module "${stateStore.module}" (${modulePath}): ${error instanceof Error ? error.message : String(error)}`);
|
|
210
|
+
}
|
|
211
|
+
const factory = pickStoreFactory(mod);
|
|
212
|
+
if (!factory) throw new Error(`[telemetry.canary.autopilot] stateStore.module "${stateStore.module}" does not export createContractGateSnapshotStore()`);
|
|
213
|
+
const store = await factory({
|
|
214
|
+
appDirectory,
|
|
215
|
+
gateSnapshotPath,
|
|
216
|
+
options: stateStore.options,
|
|
217
|
+
logger
|
|
218
|
+
});
|
|
219
|
+
ensureStoreShape(store, modulePath);
|
|
220
|
+
logger?.info?.(`[telemetry.canary.autopilot] using contract gate snapshot store "${store.name || modulePath}"`);
|
|
221
|
+
return store;
|
|
222
|
+
};
|
|
223
|
+
exports.CONTRACT_GATE_SNAPSHOT_SCHEMA_VERSION = __webpack_exports__.CONTRACT_GATE_SNAPSHOT_SCHEMA_VERSION;
|
|
224
|
+
exports.DEFAULT_CONTRACT_GATE_SNAPSHOT_PATH = __webpack_exports__.DEFAULT_CONTRACT_GATE_SNAPSHOT_PATH;
|
|
225
|
+
exports.createFileContractGateSnapshotStore = __webpack_exports__.createFileContractGateSnapshotStore;
|
|
226
|
+
exports.createHttpContractGateSnapshotStore = __webpack_exports__.createHttpContractGateSnapshotStore;
|
|
227
|
+
exports.resolveContractGateSnapshotPath = __webpack_exports__.resolveContractGateSnapshotPath;
|
|
228
|
+
exports.resolveContractGateSnapshotStore = __webpack_exports__.resolveContractGateSnapshotStore;
|
|
229
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
230
|
+
"CONTRACT_GATE_SNAPSHOT_SCHEMA_VERSION",
|
|
231
|
+
"DEFAULT_CONTRACT_GATE_SNAPSHOT_PATH",
|
|
232
|
+
"createFileContractGateSnapshotStore",
|
|
233
|
+
"createHttpContractGateSnapshotStore",
|
|
234
|
+
"resolveContractGateSnapshotPath",
|
|
235
|
+
"resolveContractGateSnapshotStore"
|
|
236
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
237
|
+
Object.defineProperty(exports, '__esModule', {
|
|
238
|
+
value: true
|
|
239
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
createDefaultPlugins: ()=>createDefaultPlugins
|
|
28
|
+
});
|
|
29
|
+
const index_js_namespaceObject = require("./compat/index.js");
|
|
30
|
+
const external_log_js_namespaceObject = require("./log.js");
|
|
31
|
+
const external_monitors_js_namespaceObject = require("./monitors.js");
|
|
32
|
+
const external_processedBy_js_namespaceObject = require("./processedBy.js");
|
|
33
|
+
const external_render_index_js_namespaceObject = require("./render/index.js");
|
|
34
|
+
const external_route_js_namespaceObject = require("./route.js");
|
|
35
|
+
const external_telemetry_js_namespaceObject = require("./telemetry.js");
|
|
36
|
+
function createSilenceLogger() {
|
|
37
|
+
return new Proxy({}, {
|
|
38
|
+
get: ()=>()=>{}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function createDefaultPlugins(options = {}) {
|
|
42
|
+
const plugins = [
|
|
43
|
+
(0, index_js_namespaceObject.compatPlugin)(),
|
|
44
|
+
(0, external_log_js_namespaceObject.logPlugin)(),
|
|
45
|
+
(0, external_monitors_js_namespaceObject.initMonitorsPlugin)(),
|
|
46
|
+
(0, external_telemetry_js_namespaceObject.injectTelemetryPlugin)(),
|
|
47
|
+
(0, external_render_index_js_namespaceObject.injectRenderHandlerPlugin)(options),
|
|
48
|
+
(0, external_monitors_js_namespaceObject.injectloggerPlugin)(options.logger ? options.logger : createSilenceLogger()),
|
|
49
|
+
(0, external_monitors_js_namespaceObject.injectServerTiming)(),
|
|
50
|
+
(0, external_processedBy_js_namespaceObject.processedByPlugin)(),
|
|
51
|
+
(0, external_route_js_namespaceObject.injectRoutePlugin)()
|
|
52
|
+
];
|
|
53
|
+
return plugins;
|
|
54
|
+
}
|
|
55
|
+
exports.createDefaultPlugins = __webpack_exports__.createDefaultPlugins;
|
|
56
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
57
|
+
"createDefaultPlugins"
|
|
58
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
59
|
+
Object.defineProperty(exports, '__esModule', {
|
|
60
|
+
value: true
|
|
61
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
faviconPlugin: ()=>faviconPlugin
|
|
28
|
+
});
|
|
29
|
+
const faviconPlugin = ()=>({
|
|
30
|
+
name: '@modern-js/plugin-favicon',
|
|
31
|
+
setup (api) {
|
|
32
|
+
api.onPrepare(()=>{
|
|
33
|
+
const { middlewares } = api.getServerContext();
|
|
34
|
+
middlewares.push({
|
|
35
|
+
name: 'favicon-fallback',
|
|
36
|
+
path: '/favicon.ico',
|
|
37
|
+
handler: async (c, _next)=>c.body(null, 204)
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
exports.faviconPlugin = __webpack_exports__.faviconPlugin;
|
|
43
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
44
|
+
"faviconPlugin"
|
|
45
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
46
|
+
Object.defineProperty(exports, '__esModule', {
|
|
47
|
+
value: true
|
|
48
|
+
});
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
CONTRACT_GATE_SNAPSHOT_SCHEMA_VERSION: ()=>external_contractGateSnapshotStore_js_namespaceObject.CONTRACT_GATE_SNAPSHOT_SCHEMA_VERSION,
|
|
28
|
+
ContractGateAutopilot: ()=>external_contractGateAutopilot_js_namespaceObject.ContractGateAutopilot,
|
|
29
|
+
DEFAULT_CONTRACT_GATE_SNAPSHOT_PATH: ()=>external_contractGateSnapshotStore_js_namespaceObject.DEFAULT_CONTRACT_GATE_SNAPSHOT_PATH,
|
|
30
|
+
DEFAULT_RUNTIME_FALLBACK_SIGNAL_ENDPOINT: ()=>external_telemetry_js_namespaceObject.DEFAULT_RUNTIME_FALLBACK_SIGNAL_ENDPOINT,
|
|
31
|
+
DEFAULT_RUNTIME_STATUS_ENDPOINT: ()=>external_telemetry_js_namespaceObject.DEFAULT_RUNTIME_STATUS_ENDPOINT,
|
|
32
|
+
TelemetryCanaryOrchestrator: ()=>external_telemetry_js_namespaceObject.TelemetryCanaryOrchestrator,
|
|
33
|
+
TelemetryRegistry: ()=>external_telemetry_js_namespaceObject.TelemetryRegistry,
|
|
34
|
+
TelemetryStartupHealthError: ()=>external_telemetry_js_namespaceObject.TelemetryStartupHealthError,
|
|
35
|
+
compatPlugin: ()=>index_js_namespaceObject.compatPlugin,
|
|
36
|
+
createDefaultPlugins: ()=>external_default_js_namespaceObject.createDefaultPlugins,
|
|
37
|
+
createFileContractGateSnapshotStore: ()=>external_contractGateSnapshotStore_js_namespaceObject.createFileContractGateSnapshotStore,
|
|
38
|
+
createHttpContractGateSnapshotStore: ()=>external_contractGateSnapshotStore_js_namespaceObject.createHttpContractGateSnapshotStore,
|
|
39
|
+
createOtlpTelemetryExporter: ()=>external_telemetry_js_namespaceObject.createOtlpTelemetryExporter,
|
|
40
|
+
createRuntimeFallbackSignalRuntimeState: ()=>external_telemetry_js_namespaceObject.createRuntimeFallbackSignalRuntimeState,
|
|
41
|
+
createRuntimeSignalError: ()=>external_telemetry_js_namespaceObject.createRuntimeSignalError,
|
|
42
|
+
createTelemetryAwareMetrics: ()=>external_telemetry_js_namespaceObject.createTelemetryAwareMetrics,
|
|
43
|
+
createVictoriaMetricsTelemetryExporter: ()=>external_telemetry_js_namespaceObject.createVictoriaMetricsTelemetryExporter,
|
|
44
|
+
enforceRuntimeFallbackSignalAuthToken: ()=>external_telemetry_js_namespaceObject.enforceRuntimeFallbackSignalAuthToken,
|
|
45
|
+
enforceRuntimeFallbackSignalTrustPolicy: ()=>external_telemetry_js_namespaceObject.enforceRuntimeFallbackSignalTrustPolicy,
|
|
46
|
+
faviconPlugin: ()=>external_favicon_js_namespaceObject.faviconPlugin,
|
|
47
|
+
getRenderHandler: ()=>external_render_index_js_namespaceObject.getRenderHandler,
|
|
48
|
+
getRuntimeSignalErrorStatusCode: ()=>external_telemetry_js_namespaceObject.getRuntimeSignalErrorStatusCode,
|
|
49
|
+
handleSetupResult: ()=>index_js_namespaceObject.handleSetupResult,
|
|
50
|
+
hasEnabledTelemetryExporters: ()=>external_telemetry_js_namespaceObject.hasEnabledTelemetryExporters,
|
|
51
|
+
injectConfigMiddlewarePlugin: ()=>external_middlewares_js_namespaceObject.injectConfigMiddlewarePlugin,
|
|
52
|
+
injectRenderHandlerPlugin: ()=>external_render_index_js_namespaceObject.injectRenderHandlerPlugin,
|
|
53
|
+
injectServerTiming: ()=>external_monitors_js_namespaceObject.injectServerTiming,
|
|
54
|
+
injectTelemetryPlugin: ()=>external_telemetry_js_namespaceObject.injectTelemetryPlugin,
|
|
55
|
+
injectloggerPlugin: ()=>external_monitors_js_namespaceObject.injectloggerPlugin,
|
|
56
|
+
logPlugin: ()=>external_log_js_namespaceObject.logPlugin,
|
|
57
|
+
normalizeRuntimeFallbackSignalAuthConfig: ()=>external_telemetry_js_namespaceObject.normalizeRuntimeFallbackSignalAuthConfig,
|
|
58
|
+
normalizeRuntimeFallbackTrustPolicy: ()=>external_telemetry_js_namespaceObject.normalizeRuntimeFallbackTrustPolicy,
|
|
59
|
+
parseRuntimeFallbackSignalPayloadFromRawBody: ()=>external_telemetry_js_namespaceObject.parseRuntimeFallbackSignalPayloadFromRawBody,
|
|
60
|
+
processedByPlugin: ()=>external_processedBy_js_namespaceObject.processedByPlugin,
|
|
61
|
+
renderPlugin: ()=>external_render_index_js_namespaceObject.renderPlugin,
|
|
62
|
+
resolveContractGateSnapshotPath: ()=>external_contractGateSnapshotStore_js_namespaceObject.resolveContractGateSnapshotPath,
|
|
63
|
+
resolveContractGateSnapshotStore: ()=>external_contractGateSnapshotStore_js_namespaceObject.resolveContractGateSnapshotStore,
|
|
64
|
+
resolveRuntimeFallbackSignalEndpoint: ()=>external_telemetry_js_namespaceObject.resolveRuntimeFallbackSignalEndpoint
|
|
65
|
+
});
|
|
66
|
+
const index_js_namespaceObject = require("./compat/index.js");
|
|
67
|
+
const external_contractGateAutopilot_js_namespaceObject = require("./contractGateAutopilot.js");
|
|
68
|
+
const external_contractGateSnapshotStore_js_namespaceObject = require("./contractGateSnapshotStore.js");
|
|
69
|
+
const external_default_js_namespaceObject = require("./default.js");
|
|
70
|
+
const external_favicon_js_namespaceObject = require("./favicon.js");
|
|
71
|
+
const external_log_js_namespaceObject = require("./log.js");
|
|
72
|
+
const external_middlewares_js_namespaceObject = require("./middlewares.js");
|
|
73
|
+
const external_monitors_js_namespaceObject = require("./monitors.js");
|
|
74
|
+
const external_processedBy_js_namespaceObject = require("./processedBy.js");
|
|
75
|
+
const external_render_index_js_namespaceObject = require("./render/index.js");
|
|
76
|
+
const external_telemetry_js_namespaceObject = require("./telemetry.js");
|
|
77
|
+
exports.CONTRACT_GATE_SNAPSHOT_SCHEMA_VERSION = __webpack_exports__.CONTRACT_GATE_SNAPSHOT_SCHEMA_VERSION;
|
|
78
|
+
exports.ContractGateAutopilot = __webpack_exports__.ContractGateAutopilot;
|
|
79
|
+
exports.DEFAULT_CONTRACT_GATE_SNAPSHOT_PATH = __webpack_exports__.DEFAULT_CONTRACT_GATE_SNAPSHOT_PATH;
|
|
80
|
+
exports.DEFAULT_RUNTIME_FALLBACK_SIGNAL_ENDPOINT = __webpack_exports__.DEFAULT_RUNTIME_FALLBACK_SIGNAL_ENDPOINT;
|
|
81
|
+
exports.DEFAULT_RUNTIME_STATUS_ENDPOINT = __webpack_exports__.DEFAULT_RUNTIME_STATUS_ENDPOINT;
|
|
82
|
+
exports.TelemetryCanaryOrchestrator = __webpack_exports__.TelemetryCanaryOrchestrator;
|
|
83
|
+
exports.TelemetryRegistry = __webpack_exports__.TelemetryRegistry;
|
|
84
|
+
exports.TelemetryStartupHealthError = __webpack_exports__.TelemetryStartupHealthError;
|
|
85
|
+
exports.compatPlugin = __webpack_exports__.compatPlugin;
|
|
86
|
+
exports.createDefaultPlugins = __webpack_exports__.createDefaultPlugins;
|
|
87
|
+
exports.createFileContractGateSnapshotStore = __webpack_exports__.createFileContractGateSnapshotStore;
|
|
88
|
+
exports.createHttpContractGateSnapshotStore = __webpack_exports__.createHttpContractGateSnapshotStore;
|
|
89
|
+
exports.createOtlpTelemetryExporter = __webpack_exports__.createOtlpTelemetryExporter;
|
|
90
|
+
exports.createRuntimeFallbackSignalRuntimeState = __webpack_exports__.createRuntimeFallbackSignalRuntimeState;
|
|
91
|
+
exports.createRuntimeSignalError = __webpack_exports__.createRuntimeSignalError;
|
|
92
|
+
exports.createTelemetryAwareMetrics = __webpack_exports__.createTelemetryAwareMetrics;
|
|
93
|
+
exports.createVictoriaMetricsTelemetryExporter = __webpack_exports__.createVictoriaMetricsTelemetryExporter;
|
|
94
|
+
exports.enforceRuntimeFallbackSignalAuthToken = __webpack_exports__.enforceRuntimeFallbackSignalAuthToken;
|
|
95
|
+
exports.enforceRuntimeFallbackSignalTrustPolicy = __webpack_exports__.enforceRuntimeFallbackSignalTrustPolicy;
|
|
96
|
+
exports.faviconPlugin = __webpack_exports__.faviconPlugin;
|
|
97
|
+
exports.getRenderHandler = __webpack_exports__.getRenderHandler;
|
|
98
|
+
exports.getRuntimeSignalErrorStatusCode = __webpack_exports__.getRuntimeSignalErrorStatusCode;
|
|
99
|
+
exports.handleSetupResult = __webpack_exports__.handleSetupResult;
|
|
100
|
+
exports.hasEnabledTelemetryExporters = __webpack_exports__.hasEnabledTelemetryExporters;
|
|
101
|
+
exports.injectConfigMiddlewarePlugin = __webpack_exports__.injectConfigMiddlewarePlugin;
|
|
102
|
+
exports.injectRenderHandlerPlugin = __webpack_exports__.injectRenderHandlerPlugin;
|
|
103
|
+
exports.injectServerTiming = __webpack_exports__.injectServerTiming;
|
|
104
|
+
exports.injectTelemetryPlugin = __webpack_exports__.injectTelemetryPlugin;
|
|
105
|
+
exports.injectloggerPlugin = __webpack_exports__.injectloggerPlugin;
|
|
106
|
+
exports.logPlugin = __webpack_exports__.logPlugin;
|
|
107
|
+
exports.normalizeRuntimeFallbackSignalAuthConfig = __webpack_exports__.normalizeRuntimeFallbackSignalAuthConfig;
|
|
108
|
+
exports.normalizeRuntimeFallbackTrustPolicy = __webpack_exports__.normalizeRuntimeFallbackTrustPolicy;
|
|
109
|
+
exports.parseRuntimeFallbackSignalPayloadFromRawBody = __webpack_exports__.parseRuntimeFallbackSignalPayloadFromRawBody;
|
|
110
|
+
exports.processedByPlugin = __webpack_exports__.processedByPlugin;
|
|
111
|
+
exports.renderPlugin = __webpack_exports__.renderPlugin;
|
|
112
|
+
exports.resolveContractGateSnapshotPath = __webpack_exports__.resolveContractGateSnapshotPath;
|
|
113
|
+
exports.resolveContractGateSnapshotStore = __webpack_exports__.resolveContractGateSnapshotStore;
|
|
114
|
+
exports.resolveRuntimeFallbackSignalEndpoint = __webpack_exports__.resolveRuntimeFallbackSignalEndpoint;
|
|
115
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
116
|
+
"CONTRACT_GATE_SNAPSHOT_SCHEMA_VERSION",
|
|
117
|
+
"ContractGateAutopilot",
|
|
118
|
+
"DEFAULT_CONTRACT_GATE_SNAPSHOT_PATH",
|
|
119
|
+
"DEFAULT_RUNTIME_FALLBACK_SIGNAL_ENDPOINT",
|
|
120
|
+
"DEFAULT_RUNTIME_STATUS_ENDPOINT",
|
|
121
|
+
"TelemetryCanaryOrchestrator",
|
|
122
|
+
"TelemetryRegistry",
|
|
123
|
+
"TelemetryStartupHealthError",
|
|
124
|
+
"compatPlugin",
|
|
125
|
+
"createDefaultPlugins",
|
|
126
|
+
"createFileContractGateSnapshotStore",
|
|
127
|
+
"createHttpContractGateSnapshotStore",
|
|
128
|
+
"createOtlpTelemetryExporter",
|
|
129
|
+
"createRuntimeFallbackSignalRuntimeState",
|
|
130
|
+
"createRuntimeSignalError",
|
|
131
|
+
"createTelemetryAwareMetrics",
|
|
132
|
+
"createVictoriaMetricsTelemetryExporter",
|
|
133
|
+
"enforceRuntimeFallbackSignalAuthToken",
|
|
134
|
+
"enforceRuntimeFallbackSignalTrustPolicy",
|
|
135
|
+
"faviconPlugin",
|
|
136
|
+
"getRenderHandler",
|
|
137
|
+
"getRuntimeSignalErrorStatusCode",
|
|
138
|
+
"handleSetupResult",
|
|
139
|
+
"hasEnabledTelemetryExporters",
|
|
140
|
+
"injectConfigMiddlewarePlugin",
|
|
141
|
+
"injectRenderHandlerPlugin",
|
|
142
|
+
"injectServerTiming",
|
|
143
|
+
"injectTelemetryPlugin",
|
|
144
|
+
"injectloggerPlugin",
|
|
145
|
+
"logPlugin",
|
|
146
|
+
"normalizeRuntimeFallbackSignalAuthConfig",
|
|
147
|
+
"normalizeRuntimeFallbackTrustPolicy",
|
|
148
|
+
"parseRuntimeFallbackSignalPayloadFromRawBody",
|
|
149
|
+
"processedByPlugin",
|
|
150
|
+
"renderPlugin",
|
|
151
|
+
"resolveContractGateSnapshotPath",
|
|
152
|
+
"resolveContractGateSnapshotStore",
|
|
153
|
+
"resolveRuntimeFallbackSignalEndpoint"
|
|
154
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
155
|
+
Object.defineProperty(exports, '__esModule', {
|
|
156
|
+
value: true
|
|
157
|
+
});
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
logPlugin: ()=>logPlugin
|
|
28
|
+
});
|
|
29
|
+
const index_js_namespaceObject = require("../utils/index.js");
|
|
30
|
+
const humanize = (times)=>{
|
|
31
|
+
const [delimiter, separator] = [
|
|
32
|
+
',',
|
|
33
|
+
'.'
|
|
34
|
+
];
|
|
35
|
+
const orderTimes = times.map((v)=>v.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, `$1${delimiter}`));
|
|
36
|
+
return orderTimes.join(separator);
|
|
37
|
+
};
|
|
38
|
+
const time = (start)=>{
|
|
39
|
+
const delta = Date.now() - start;
|
|
40
|
+
return humanize([
|
|
41
|
+
delta < 1000 ? `${delta}ms` : `${Math.round(delta / 1000)}s`
|
|
42
|
+
]);
|
|
43
|
+
};
|
|
44
|
+
const colorStatus = (status)=>{
|
|
45
|
+
const out = {
|
|
46
|
+
7: `\x1b[35m${status}\x1b[0m`,
|
|
47
|
+
5: `\x1b[31m${status}\x1b[0m`,
|
|
48
|
+
4: `\x1b[33m${status}\x1b[0m`,
|
|
49
|
+
3: `\x1b[36m${status}\x1b[0m`,
|
|
50
|
+
2: `\x1b[32m${status}\x1b[0m`,
|
|
51
|
+
1: `\x1b[32m${status}\x1b[0m`,
|
|
52
|
+
0: `\x1b[33m${status}\x1b[0m`
|
|
53
|
+
};
|
|
54
|
+
const calculateStatus = Math.floor(status / 100);
|
|
55
|
+
return out[calculateStatus];
|
|
56
|
+
};
|
|
57
|
+
function log(fn, prefix, method, path, status = 0, elapsed) {
|
|
58
|
+
const out = "<--" === prefix ? ` ${prefix} ${method} ${path}` : ` ${prefix} ${method} ${path} ${colorStatus(status)} ${elapsed}`;
|
|
59
|
+
fn(out);
|
|
60
|
+
}
|
|
61
|
+
function logHandler() {
|
|
62
|
+
return async function(c, next) {
|
|
63
|
+
const { method } = c.req;
|
|
64
|
+
const monitors = c.get('monitors');
|
|
65
|
+
if (!monitors) return void await next();
|
|
66
|
+
const path = (0, index_js_namespaceObject.getPathname)(c.req.raw);
|
|
67
|
+
const logFn = monitors.debug;
|
|
68
|
+
log(logFn, "<--", method, path);
|
|
69
|
+
const start = Date.now();
|
|
70
|
+
await next();
|
|
71
|
+
log(logFn, "-->", method, path, c?.env?.node?.res?.statusCode ?? c.res.status, time(start));
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
const logPlugin = ()=>({
|
|
75
|
+
name: '@modern-js/plugin-log',
|
|
76
|
+
setup (api) {
|
|
77
|
+
api.onPrepare(()=>{
|
|
78
|
+
const { middlewares } = api.getServerContext();
|
|
79
|
+
middlewares.push({
|
|
80
|
+
name: 'print_log',
|
|
81
|
+
handler: logHandler()
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
exports.logPlugin = __webpack_exports__.logPlugin;
|
|
87
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
88
|
+
"logPlugin"
|
|
89
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
90
|
+
Object.defineProperty(exports, '__esModule', {
|
|
91
|
+
value: true
|
|
92
|
+
});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
getRequestPathname: ()=>getRequestPathname,
|
|
28
|
+
isMfManifestAsset: ()=>isMfManifestAsset,
|
|
29
|
+
isMfRemoteEntryAsset: ()=>isMfRemoteEntryAsset,
|
|
30
|
+
resolveMfAssetCacheHeaders: ()=>resolveMfAssetCacheHeaders
|
|
31
|
+
});
|
|
32
|
+
const REMOTE_ENTRY_REGEXP = /(^|\/)remoteEntry(?:\.[a-zA-Z0-9_-]+)?\.js$/;
|
|
33
|
+
function firstQueryValue(value) {
|
|
34
|
+
if (Array.isArray(value)) return value.find((item)=>'string' == typeof item && item.length > 0);
|
|
35
|
+
if ('string' == typeof value && value.length > 0) return value;
|
|
36
|
+
}
|
|
37
|
+
function getRequestPathname(url) {
|
|
38
|
+
try {
|
|
39
|
+
return new URL(url, 'http://modernjs.local').pathname;
|
|
40
|
+
} catch (_error) {
|
|
41
|
+
return url.split('?')[0] || '/';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function isMfManifestAsset(pathname) {
|
|
45
|
+
return pathname.endsWith('/mf-manifest.json') || pathname.endsWith('/mf-stats.json');
|
|
46
|
+
}
|
|
47
|
+
function isMfRemoteEntryAsset(pathname) {
|
|
48
|
+
return REMOTE_ENTRY_REGEXP.test(pathname);
|
|
49
|
+
}
|
|
50
|
+
function hasRemoteVersionPin(query = {}) {
|
|
51
|
+
return Boolean(firstQueryValue(query.mfv) || firstQueryValue(query.v) || firstQueryValue(query.version));
|
|
52
|
+
}
|
|
53
|
+
function resolveMfAssetCacheHeaders(url, query = {}) {
|
|
54
|
+
const pathname = getRequestPathname(url);
|
|
55
|
+
if (isMfManifestAsset(pathname)) return {
|
|
56
|
+
'cache-control': 'no-cache, no-store, must-revalidate',
|
|
57
|
+
pragma: 'no-cache',
|
|
58
|
+
expires: '0'
|
|
59
|
+
};
|
|
60
|
+
if (isMfRemoteEntryAsset(pathname)) return hasRemoteVersionPin(query) ? {
|
|
61
|
+
'cache-control': 'public, max-age=31536000, immutable'
|
|
62
|
+
} : {
|
|
63
|
+
'cache-control': 'public, max-age=0, must-revalidate'
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
exports.getRequestPathname = __webpack_exports__.getRequestPathname;
|
|
67
|
+
exports.isMfManifestAsset = __webpack_exports__.isMfManifestAsset;
|
|
68
|
+
exports.isMfRemoteEntryAsset = __webpack_exports__.isMfRemoteEntryAsset;
|
|
69
|
+
exports.resolveMfAssetCacheHeaders = __webpack_exports__.resolveMfAssetCacheHeaders;
|
|
70
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
71
|
+
"getRequestPathname",
|
|
72
|
+
"isMfManifestAsset",
|
|
73
|
+
"isMfRemoteEntryAsset",
|
|
74
|
+
"resolveMfAssetCacheHeaders"
|
|
75
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
76
|
+
Object.defineProperty(exports, '__esModule', {
|
|
77
|
+
value: true
|
|
78
|
+
});
|