@bleedingdev/modern-js-server-runtime-extensions 3.9.0-ultramodern.8 → 3.9.3-ultramodern.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/cjs/backend-federation-security/index.js +73 -152
- package/dist/cjs/bff-policy/index.js +7 -0
- package/dist/cjs/bff-policy/node.js +20 -4
- package/dist/cjs/bff-policy/operationContracts.js +150 -135
- package/dist/cjs/bff-policy/operationIdentity.js +81 -0
- package/dist/cjs/bff-policy/producer.js +79 -0
- package/dist/cjs/localisedLoader.js +65 -0
- package/dist/cjs/localisedLoaderPlugin.js +2 -2
- package/dist/cjs/module-federation-css/remote.js +2 -1
- package/dist/cjs/static-serving/staticModuleFederation.js +49 -12
- package/dist/esm/backend-federation-security/index.mjs +73 -152
- package/dist/esm/bff-policy/index.mjs +1 -0
- package/dist/esm/bff-policy/operationIdentity.mjs +30 -0
- package/dist/esm/bff-policy/producer.mjs +31 -0
- package/dist/esm/localisedLoader.mjs +24 -0
- package/dist/esm/localisedLoaderPlugin.mjs +2 -2
- package/dist/esm/module-federation-css/remote.mjs +2 -1
- package/dist/esm-node/backend-federation-security/index.mjs +73 -152
- package/dist/esm-node/bff-policy/index.mjs +1 -0
- package/dist/esm-node/bff-policy/node.mjs +1 -0
- package/dist/esm-node/bff-policy/operationContracts.mjs +5 -27
- package/dist/esm-node/bff-policy/operationIdentity.mjs +31 -0
- package/dist/esm-node/bff-policy/producer.mjs +32 -0
- package/dist/esm-node/localisedLoader.mjs +25 -0
- package/dist/esm-node/localisedLoaderPlugin.mjs +2 -2
- package/dist/esm-node/module-federation-css/remote.mjs +2 -1
- package/dist/esm-node/static-serving/staticModuleFederation.mjs +49 -12
- package/dist/types/backend-federation-security/node.d.ts +1 -1
- package/dist/types/bff-policy/index.d.ts +1 -0
- package/dist/types/bff-policy/node.d.ts +1 -0
- package/dist/types/bff-policy/operationContracts.d.ts +2 -41
- package/dist/types/bff-policy/operationIdentity.d.ts +34 -0
- package/dist/types/bff-policy/producer.d.ts +10 -0
- package/dist/types/localisedLoader.d.ts +15 -0
- package/dist/types/module-federation-css/remote.d.ts +2 -0
- package/dist/types-esm/backend-federation-security/node.d.mts +1 -1
- package/dist/types-esm/bff-policy/index.d.mts +1 -0
- package/dist/types-esm/bff-policy/node.d.mts +1 -0
- package/dist/types-esm/bff-policy/operationContracts.d.mts +2 -41
- package/dist/types-esm/bff-policy/operationIdentity.d.mts +34 -0
- package/dist/types-esm/bff-policy/producer.d.mts +10 -0
- package/dist/types-esm/localisedLoader.d.mts +15 -0
- package/dist/types-esm/module-federation-css/remote.d.mts +2 -0
- package/package.json +47 -19
- package/src/backend-federation-security/index.ts +151 -318
- package/src/backend-federation-security/node.ts +24 -22
- package/src/bff-policy/index.ts +1 -0
- package/src/bff-policy/node.ts +1 -0
- package/src/bff-policy/operationContracts.ts +13 -86
- package/src/bff-policy/operationIdentity.ts +90 -0
- package/src/bff-policy/producer.ts +40 -0
- package/src/contract-gate-snapshot-store/resolve.ts +0 -1
- package/src/localisedLoader.ts +50 -0
- package/src/localisedLoaderPlugin.ts +6 -7
- package/src/module-federation-css/remote.ts +3 -1
- package/src/static-serving/staticModuleFederation.ts +127 -22
- package/rslib.config.mts +0 -38
- package/rstest.config.mts +0 -18
- package/tests/backendFederationSecurity.test.ts +0 -416
- package/tests/bff-policy/crossProjectPolicy.matrix.test.ts +0 -450
- package/tests/bff-policy/crossProjectPolicy.test.ts +0 -197
- package/tests/bff-policy/operationContracts.test.ts +0 -221
- package/tests/bff-policy/optionalZodPeer.test.ts +0 -30
- package/tests/bff-policy/resolveCrossProjectPolicy.test.ts +0 -76
- package/tests/contractGateSnapshotObserver.test.ts +0 -347
- package/tests/contractGateSnapshotStore.test.ts +0 -225
- package/tests/env.test.ts +0 -54
- package/tests/helpers.ts +0 -20
- package/tests/localisedLoader.test.ts +0 -120
- package/tests/mfCache.test.ts +0 -63
- package/tests/moduleFederationCss.test.ts +0 -348
- package/tests/nativeErrorResponse.test.ts +0 -118
- package/tests/nativeServerAssembly.test.ts +0 -385
- package/tests/runtimeLifecycle.test.ts +0 -159
- package/tests/static-serving/ordering.test.ts +0 -214
- package/tests/static-serving/static.test.ts +0 -411
- package/tests/telemetry.test.ts +0 -248
- package/tests/telemetryHealthMonitor.test.ts +0 -183
- package/tests/telemetryHealthObservation.test.ts +0 -302
- package/tests/telemetryLifecycle.test.ts +0 -123
- package/tests/telemetryRegistryQueueMatrix.test.ts +0 -130
- package/tests/telemetryTraceparent.test.ts +0 -167
- package/tests/tsconfig.json +0 -11
- package/tsconfig.json +0 -10
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
2
|
+
var __webpack_modules__ = {
|
|
3
|
+
"./operationIdentity" (module) {
|
|
4
|
+
module.exports = require("./operationIdentity.js");
|
|
5
|
+
},
|
|
6
|
+
crypto (module) {
|
|
7
|
+
module.exports = require("crypto");
|
|
8
|
+
},
|
|
9
|
+
"node:module" (module) {
|
|
10
|
+
module.exports = require("node:module");
|
|
11
|
+
},
|
|
12
|
+
"reflect-metadata" (module) {
|
|
13
|
+
module.exports = require("reflect-metadata");
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
var __webpack_module_cache__ = {};
|
|
17
|
+
function __webpack_require__(moduleId) {
|
|
18
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
19
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
20
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
21
|
+
exports: {}
|
|
22
|
+
};
|
|
23
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
24
|
+
return module.exports;
|
|
25
|
+
}
|
|
26
|
+
(()=>{
|
|
27
|
+
__webpack_require__.n = (module)=>{
|
|
28
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
29
|
+
__webpack_require__.d(getter, {
|
|
30
|
+
a: getter
|
|
31
|
+
});
|
|
32
|
+
return getter;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
3
35
|
(()=>{
|
|
4
36
|
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
37
|
var define = (defs, kind)=>{
|
|
@@ -26,155 +58,138 @@ var __webpack_require__ = {};
|
|
|
26
58
|
};
|
|
27
59
|
})();
|
|
28
60
|
var __webpack_exports__ = {};
|
|
29
|
-
|
|
30
|
-
__webpack_require__.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const stableStringify = (value)=>{
|
|
51
|
-
if (Array.isArray(value)) return `[${value.map((item)=>stableStringify(item)).join(',')}]`;
|
|
52
|
-
if (value && 'object' == typeof value) {
|
|
53
|
-
const entries = Object.entries(value).filter(([, entryValue])=>void 0 !== entryValue).sort(([a], [b])=>a.localeCompare(b)).map(([key, entryValue])=>`${JSON.stringify(key)}:${stableStringify(entryValue)}`);
|
|
54
|
-
return `{${entries.join(',')}}`;
|
|
55
|
-
}
|
|
56
|
-
return JSON.stringify(value) ?? 'null';
|
|
57
|
-
};
|
|
58
|
-
const sha256 = (text)=>(0, external_crypto_namespaceObject.createHash)('sha256').update(text).digest('hex');
|
|
59
|
-
let cachedZodToJSONSchema;
|
|
60
|
-
const ZOD_SPECIFIER = "zod";
|
|
61
|
-
const resolveZodToJSONSchema = ()=>{
|
|
62
|
-
if (void 0 !== cachedZodToJSONSchema) return cachedZodToJSONSchema;
|
|
63
|
-
try {
|
|
64
|
-
const load = (0, external_node_module_namespaceObject.createRequire)(__filename);
|
|
65
|
-
const zod = load(ZOD_SPECIFIER);
|
|
66
|
-
const candidate = zod?.toJSONSchema ?? zod?.z?.toJSONSchema;
|
|
67
|
-
cachedZodToJSONSchema = 'function' == typeof candidate ? candidate : null;
|
|
68
|
-
} catch {
|
|
69
|
-
cachedZodToJSONSchema = null;
|
|
70
|
-
}
|
|
71
|
-
return cachedZodToJSONSchema;
|
|
72
|
-
};
|
|
73
|
-
const INPUT_SCHEMA_METADATA_KEYS = [
|
|
74
|
-
'DATA',
|
|
75
|
-
'QUERY',
|
|
76
|
-
'PARAMS',
|
|
77
|
-
'HEADERS',
|
|
78
|
-
'Files'
|
|
79
|
-
];
|
|
80
|
-
const serializeSchema = (schema)=>{
|
|
81
|
-
const toJSONSchema = resolveZodToJSONSchema();
|
|
82
|
-
if (toJSONSchema) try {
|
|
83
|
-
return toJSONSchema(schema, {
|
|
84
|
-
io: 'input',
|
|
85
|
-
unrepresentable: 'any'
|
|
86
|
-
});
|
|
87
|
-
} catch {}
|
|
88
|
-
return {
|
|
89
|
-
__unserializableSchema: true
|
|
90
|
-
};
|
|
91
|
-
};
|
|
92
|
-
const serializeOperationSchemas = (handler)=>{
|
|
93
|
-
if ('function' != typeof handler) return;
|
|
94
|
-
const serialized = {};
|
|
95
|
-
for (const metadataKey of INPUT_SCHEMA_METADATA_KEYS){
|
|
96
|
-
let schema;
|
|
61
|
+
(()=>{
|
|
62
|
+
__webpack_require__.r(__webpack_exports__);
|
|
63
|
+
var node_module__rspack_import_0 = __webpack_require__("node:module");
|
|
64
|
+
var crypto__rspack_import_1 = __webpack_require__("crypto");
|
|
65
|
+
__webpack_require__("reflect-metadata");
|
|
66
|
+
var _operationIdentity__rspack_import_3 = __webpack_require__("./operationIdentity");
|
|
67
|
+
var __rspack_reexport = {};
|
|
68
|
+
for(const __rspack_import_key in _operationIdentity__rspack_import_3)if ([
|
|
69
|
+
"createOperationEntries",
|
|
70
|
+
"buildOperationContractMap",
|
|
71
|
+
"createOperationSchemaHash",
|
|
72
|
+
"default",
|
|
73
|
+
"serializeOperationSchemas",
|
|
74
|
+
"createOperationContractHash"
|
|
75
|
+
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_operationIdentity__rspack_import_3[__rspack_import_key];
|
|
76
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
77
|
+
const sha256 = (text)=>(0, crypto__rspack_import_1.createHash)('sha256').update(text).digest('hex');
|
|
78
|
+
let cachedZodToJSONSchema;
|
|
79
|
+
const ZOD_SPECIFIER = "zod";
|
|
80
|
+
const resolveZodToJSONSchema = ()=>{
|
|
81
|
+
if (void 0 !== cachedZodToJSONSchema) return cachedZodToJSONSchema;
|
|
97
82
|
try {
|
|
98
|
-
|
|
83
|
+
const load = (0, node_module__rspack_import_0.createRequire)(__filename);
|
|
84
|
+
const zod = load(ZOD_SPECIFIER);
|
|
85
|
+
const candidate = zod?.toJSONSchema ?? zod?.z?.toJSONSchema;
|
|
86
|
+
cachedZodToJSONSchema = 'function' == typeof candidate ? candidate : null;
|
|
99
87
|
} catch {
|
|
100
|
-
|
|
88
|
+
cachedZodToJSONSchema = null;
|
|
101
89
|
}
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const keyB = `${b.routePath}:${b.httpMethod}:${b.name}`;
|
|
122
|
-
return keyA.localeCompare(keyB);
|
|
123
|
-
});
|
|
124
|
-
const createOperationSchemaHash = (operationEntries, requestId)=>sha256(stableStringify({
|
|
125
|
-
operations: [
|
|
126
|
-
...operationEntries
|
|
127
|
-
].map((item)=>({
|
|
128
|
-
hash: item.schemaHash ?? createOperationContractHash({
|
|
129
|
-
name: item.name,
|
|
130
|
-
httpMethod: item.httpMethod,
|
|
131
|
-
routePath: item.routePath
|
|
132
|
-
}, requestId)
|
|
133
|
-
})).sort((a, b)=>a.hash.localeCompare(b.hash)),
|
|
134
|
-
requestId
|
|
135
|
-
}));
|
|
136
|
-
const buildOperationContractMap = ({ handlers, requestId, operationVersion })=>{
|
|
137
|
-
const normalizedRequestId = 'string' == typeof requestId && requestId.trim().length > 0 ? requestId.trim() : 'default';
|
|
138
|
-
const normalizedOperationVersion = 'number' == typeof operationVersion && Number.isInteger(operationVersion) ? operationVersion : DEFAULT_OPERATION_VERSION;
|
|
139
|
-
const contracts = {};
|
|
140
|
-
handlers.forEach((item)=>{
|
|
141
|
-
const httpMethod = String(item.httpMethod || '').toUpperCase();
|
|
142
|
-
const schemaHash = createOperationContractHash({
|
|
143
|
-
name: item.name,
|
|
144
|
-
httpMethod,
|
|
145
|
-
routePath: item.routePath,
|
|
146
|
-
schemas: serializeOperationSchemas(item.handler)
|
|
147
|
-
}, normalizedRequestId);
|
|
148
|
-
const operationId = `${normalizedRequestId}:${item.name}`;
|
|
149
|
-
const contract = {
|
|
150
|
-
requestId: normalizedRequestId,
|
|
151
|
-
operationVersion: normalizedOperationVersion,
|
|
152
|
-
schemaHash,
|
|
153
|
-
method: httpMethod,
|
|
154
|
-
routePath: item.routePath,
|
|
155
|
-
operationId,
|
|
156
|
-
handlerName: item.name,
|
|
157
|
-
filename: item.filename
|
|
90
|
+
return cachedZodToJSONSchema;
|
|
91
|
+
};
|
|
92
|
+
const INPUT_SCHEMA_METADATA_KEYS = [
|
|
93
|
+
'DATA',
|
|
94
|
+
'QUERY',
|
|
95
|
+
'PARAMS',
|
|
96
|
+
'HEADERS',
|
|
97
|
+
'Files'
|
|
98
|
+
];
|
|
99
|
+
const serializeSchema = (schema)=>{
|
|
100
|
+
const toJSONSchema = resolveZodToJSONSchema();
|
|
101
|
+
if (toJSONSchema) try {
|
|
102
|
+
return toJSONSchema(schema, {
|
|
103
|
+
io: 'input',
|
|
104
|
+
unrepresentable: 'any'
|
|
105
|
+
});
|
|
106
|
+
} catch {}
|
|
107
|
+
return {
|
|
108
|
+
__unserializableSchema: true
|
|
158
109
|
};
|
|
159
|
-
|
|
160
|
-
|
|
110
|
+
};
|
|
111
|
+
const serializeOperationSchemas = (handler)=>{
|
|
112
|
+
if ('function' != typeof handler) return;
|
|
113
|
+
const serialized = {};
|
|
114
|
+
for (const metadataKey of INPUT_SCHEMA_METADATA_KEYS){
|
|
115
|
+
let schema;
|
|
116
|
+
try {
|
|
117
|
+
schema = Reflect.getMetadata(metadataKey, handler);
|
|
118
|
+
} catch {
|
|
119
|
+
schema = void 0;
|
|
120
|
+
}
|
|
121
|
+
if (null != schema) serialized[metadataKey] = serializeSchema(schema);
|
|
122
|
+
}
|
|
123
|
+
return Object.keys(serialized).length > 0 ? serialized : void 0;
|
|
124
|
+
};
|
|
125
|
+
const createOperationContractHash = (operation, requestId)=>sha256((0, _operationIdentity__rspack_import_3.serializeOperationContract)(operation, requestId));
|
|
126
|
+
const createOperationEntries = (handlers)=>handlers.map((item)=>({
|
|
127
|
+
name: item.name,
|
|
128
|
+
httpMethod: String(item.httpMethod || '').toUpperCase(),
|
|
129
|
+
routePath: item.routePath
|
|
130
|
+
})).sort((a, b)=>{
|
|
131
|
+
const keyA = `${a.routePath}:${a.httpMethod}:${a.name}`;
|
|
132
|
+
const keyB = `${b.routePath}:${b.httpMethod}:${b.name}`;
|
|
133
|
+
return keyA.localeCompare(keyB);
|
|
134
|
+
});
|
|
135
|
+
const createOperationSchemaHash = (operationEntries, requestId)=>sha256((0, _operationIdentity__rspack_import_3.stableOperationStringify)({
|
|
136
|
+
operations: [
|
|
137
|
+
...operationEntries
|
|
138
|
+
].map((item)=>({
|
|
139
|
+
hash: item.schemaHash ?? createOperationContractHash({
|
|
140
|
+
name: item.name,
|
|
141
|
+
httpMethod: item.httpMethod,
|
|
142
|
+
routePath: item.routePath
|
|
143
|
+
}, requestId)
|
|
144
|
+
})).sort((a, b)=>a.hash.localeCompare(b.hash)),
|
|
145
|
+
requestId
|
|
146
|
+
}));
|
|
147
|
+
const buildOperationContractMap = ({ handlers, requestId, operationVersion })=>{
|
|
148
|
+
const normalizedRequestId = 'string' == typeof requestId && requestId.trim().length > 0 ? requestId.trim() : 'default';
|
|
149
|
+
const normalizedOperationVersion = 'number' == typeof operationVersion && Number.isInteger(operationVersion) ? operationVersion : _operationIdentity__rspack_import_3.DEFAULT_OPERATION_VERSION;
|
|
150
|
+
const contracts = {};
|
|
151
|
+
handlers.forEach((item)=>{
|
|
152
|
+
const httpMethod = String(item.httpMethod || '').toUpperCase();
|
|
153
|
+
const schemaHash = createOperationContractHash({
|
|
154
|
+
name: item.name,
|
|
155
|
+
httpMethod,
|
|
156
|
+
routePath: item.routePath,
|
|
157
|
+
schemas: serializeOperationSchemas(item.handler)
|
|
158
|
+
}, normalizedRequestId);
|
|
159
|
+
const operationId = `${normalizedRequestId}:${item.name}`;
|
|
160
|
+
const contract = {
|
|
161
|
+
requestId: normalizedRequestId,
|
|
162
|
+
operationVersion: normalizedOperationVersion,
|
|
163
|
+
schemaHash,
|
|
164
|
+
method: httpMethod,
|
|
165
|
+
routePath: item.routePath,
|
|
166
|
+
operationId,
|
|
167
|
+
handlerName: item.name,
|
|
168
|
+
filename: item.filename
|
|
169
|
+
};
|
|
170
|
+
contracts[`${httpMethod}:${item.routePath}`] = contract;
|
|
171
|
+
contracts[`operation:${operationId}`] = contract;
|
|
172
|
+
});
|
|
173
|
+
return contracts;
|
|
174
|
+
};
|
|
175
|
+
__webpack_require__.d(__webpack_exports__, {}, {
|
|
176
|
+
buildOperationContractMap: buildOperationContractMap,
|
|
177
|
+
createOperationContractHash: createOperationContractHash,
|
|
178
|
+
createOperationEntries: createOperationEntries,
|
|
179
|
+
createOperationSchemaHash: createOperationSchemaHash,
|
|
180
|
+
serializeOperationSchemas: serializeOperationSchemas
|
|
161
181
|
});
|
|
162
|
-
|
|
163
|
-
};
|
|
164
|
-
exports.DEFAULT_OPERATION_VERSION = __webpack_exports__.DEFAULT_OPERATION_VERSION;
|
|
182
|
+
})();
|
|
165
183
|
exports.buildOperationContractMap = __webpack_exports__.buildOperationContractMap;
|
|
166
184
|
exports.createOperationContractHash = __webpack_exports__.createOperationContractHash;
|
|
167
185
|
exports.createOperationEntries = __webpack_exports__.createOperationEntries;
|
|
168
186
|
exports.createOperationSchemaHash = __webpack_exports__.createOperationSchemaHash;
|
|
169
|
-
exports.deriveOperationVersion = __webpack_exports__.deriveOperationVersion;
|
|
170
187
|
exports.serializeOperationSchemas = __webpack_exports__.serializeOperationSchemas;
|
|
171
188
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
172
|
-
"DEFAULT_OPERATION_VERSION",
|
|
173
189
|
"buildOperationContractMap",
|
|
174
190
|
"createOperationContractHash",
|
|
175
191
|
"createOperationEntries",
|
|
176
192
|
"createOperationSchemaHash",
|
|
177
|
-
"deriveOperationVersion",
|
|
178
193
|
"serializeOperationSchemas"
|
|
179
194
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
180
195
|
Object.defineProperty(exports, '__esModule', {
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
const DEFAULT_OPERATION_VERSION = 1;
|
|
31
|
+
const deriveOperationVersion = (packageVersion)=>{
|
|
32
|
+
if ('string' != typeof packageVersion) return DEFAULT_OPERATION_VERSION;
|
|
33
|
+
const match = packageVersion.trim().match(/^v?(\d+)\./);
|
|
34
|
+
if (!match) return DEFAULT_OPERATION_VERSION;
|
|
35
|
+
const major = Number.parseInt(match[1], 10);
|
|
36
|
+
return Number.isInteger(major) && major >= 0 ? major : DEFAULT_OPERATION_VERSION;
|
|
37
|
+
};
|
|
38
|
+
const stableOperationStringify = (value)=>{
|
|
39
|
+
if (Array.isArray(value)) return `[${value.map((item)=>stableOperationStringify(item)).join(',')}]`;
|
|
40
|
+
if (value && 'object' == typeof value) {
|
|
41
|
+
const entries = Object.entries(value).filter(([, entryValue])=>void 0 !== entryValue).sort(([a], [b])=>a.localeCompare(b)).map(([key, entryValue])=>`${JSON.stringify(key)}:${stableOperationStringify(entryValue)}`);
|
|
42
|
+
return `{${entries.join(',')}}`;
|
|
43
|
+
}
|
|
44
|
+
return JSON.stringify(value) ?? 'null';
|
|
45
|
+
};
|
|
46
|
+
const serializeOperationContract = (operation, requestId)=>stableOperationStringify({
|
|
47
|
+
httpMethod: String(operation.httpMethod || '').toUpperCase(),
|
|
48
|
+
name: operation.name,
|
|
49
|
+
requestId,
|
|
50
|
+
routePath: operation.routePath,
|
|
51
|
+
...operation.schemas ? {
|
|
52
|
+
schemas: operation.schemas
|
|
53
|
+
} : {}
|
|
54
|
+
});
|
|
55
|
+
async function digestOperationContract(operation, requestId) {
|
|
56
|
+
const digest = await globalThis.crypto.subtle.digest('SHA-256', new TextEncoder().encode(serializeOperationContract(operation, requestId)));
|
|
57
|
+
return Array.from(new Uint8Array(digest), (value)=>value.toString(16).padStart(2, '0')).join('');
|
|
58
|
+
}
|
|
59
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
60
|
+
digestOperationContract: ()=>digestOperationContract
|
|
61
|
+
}, {
|
|
62
|
+
DEFAULT_OPERATION_VERSION: DEFAULT_OPERATION_VERSION,
|
|
63
|
+
deriveOperationVersion: deriveOperationVersion,
|
|
64
|
+
serializeOperationContract: serializeOperationContract,
|
|
65
|
+
stableOperationStringify: stableOperationStringify
|
|
66
|
+
});
|
|
67
|
+
exports.DEFAULT_OPERATION_VERSION = __webpack_exports__.DEFAULT_OPERATION_VERSION;
|
|
68
|
+
exports.deriveOperationVersion = __webpack_exports__.deriveOperationVersion;
|
|
69
|
+
exports.digestOperationContract = __webpack_exports__.digestOperationContract;
|
|
70
|
+
exports.serializeOperationContract = __webpack_exports__.serializeOperationContract;
|
|
71
|
+
exports.stableOperationStringify = __webpack_exports__.stableOperationStringify;
|
|
72
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
73
|
+
"DEFAULT_OPERATION_VERSION",
|
|
74
|
+
"deriveOperationVersion",
|
|
75
|
+
"digestOperationContract",
|
|
76
|
+
"serializeOperationContract",
|
|
77
|
+
"stableOperationStringify"
|
|
78
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
79
|
+
Object.defineProperty(exports, '__esModule', {
|
|
80
|
+
value: true
|
|
81
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
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, getters, values)=>{
|
|
14
|
+
var define = (defs, kind)=>{
|
|
15
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
[kind]: defs[key]
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
define(getters, "get");
|
|
21
|
+
define(values, "value");
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
(()=>{
|
|
25
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
26
|
+
})();
|
|
27
|
+
(()=>{
|
|
28
|
+
__webpack_require__.r = (exports1)=>{
|
|
29
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
30
|
+
value: 'Module'
|
|
31
|
+
});
|
|
32
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
33
|
+
value: true
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
})();
|
|
37
|
+
var __webpack_exports__ = {};
|
|
38
|
+
__webpack_require__.r(__webpack_exports__);
|
|
39
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
40
|
+
resolveOperationProducer: ()=>resolveOperationProducer
|
|
41
|
+
});
|
|
42
|
+
const external_node_fs_namespaceObject = require("node:fs");
|
|
43
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
44
|
+
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
45
|
+
const external_operationIdentity_js_namespaceObject = require("./operationIdentity.js");
|
|
46
|
+
function resolveOperationProducer(options) {
|
|
47
|
+
for (const directory of options.directories){
|
|
48
|
+
if (!directory) continue;
|
|
49
|
+
let current = external_node_path_default().resolve(directory);
|
|
50
|
+
while(true){
|
|
51
|
+
const filename = external_node_path_default().join(current, 'package.json');
|
|
52
|
+
if ((0, external_node_fs_namespaceObject.existsSync)(filename)) {
|
|
53
|
+
options.onDependency?.(filename);
|
|
54
|
+
let metadata = {};
|
|
55
|
+
try {
|
|
56
|
+
metadata = JSON.parse((0, external_node_fs_namespaceObject.readFileSync)(filename, 'utf8')) ?? {};
|
|
57
|
+
} catch {}
|
|
58
|
+
return {
|
|
59
|
+
requestId: options.requestId?.trim() || 'string' == typeof metadata.name && metadata.name.trim() || 'default',
|
|
60
|
+
operationVersion: (0, external_operationIdentity_js_namespaceObject.deriveOperationVersion)(metadata.version)
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
const parent = external_node_path_default().dirname(current);
|
|
64
|
+
if (parent === current) break;
|
|
65
|
+
current = parent;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
requestId: options.requestId?.trim() || 'default',
|
|
70
|
+
operationVersion: (0, external_operationIdentity_js_namespaceObject.deriveOperationVersion)()
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
exports.resolveOperationProducer = __webpack_exports__.resolveOperationProducer;
|
|
74
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
75
|
+
"resolveOperationProducer"
|
|
76
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
77
|
+
Object.defineProperty(exports, '__esModule', {
|
|
78
|
+
value: true
|
|
79
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
expandLocalisedLoaderRoutes: ()=>expandLocalisedLoaderRoutes,
|
|
32
|
+
resolveLocalisedLoaderRoute: ()=>resolveLocalisedLoaderRoute
|
|
33
|
+
});
|
|
34
|
+
const localised_loader_identity_namespaceObject = require("@modern-js/runtime-extensions/localised-loader-identity");
|
|
35
|
+
const localised_urls_namespaceObject = require("@modern-js/runtime-extensions/localised-urls");
|
|
36
|
+
function expandLocalisedLoaderRoutes(routes) {
|
|
37
|
+
const languages = new Set();
|
|
38
|
+
const localisedUrls = {};
|
|
39
|
+
let physical = false;
|
|
40
|
+
const visit = (nodes)=>{
|
|
41
|
+
for (const route of nodes){
|
|
42
|
+
physical ||= 'modernCanonicalPath' in route;
|
|
43
|
+
const identity = Reflect.get(route, 'modernLocalisedRoute');
|
|
44
|
+
if (identity?.paths) {
|
|
45
|
+
localisedUrls[identity.canonicalPath] = identity.paths;
|
|
46
|
+
for (const language of Object.keys(identity.paths))languages.add(language);
|
|
47
|
+
}
|
|
48
|
+
if ('children' in route && route.children) visit(route.children);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
visit(routes);
|
|
52
|
+
return physical || 0 === languages.size ? routes : (0, localised_urls_namespaceObject.applyLocalisedUrlsToRoutes)(routes, [
|
|
53
|
+
...languages
|
|
54
|
+
], localisedUrls);
|
|
55
|
+
}
|
|
56
|
+
const resolveLocalisedLoaderRoute = (requestedRouteId, { routes, matchedRouteIds })=>(0, localised_loader_identity_namespaceObject.resolveLocalisedLoaderRouteId)(routes, requestedRouteId, matchedRouteIds);
|
|
57
|
+
exports.expandLocalisedLoaderRoutes = __webpack_exports__.expandLocalisedLoaderRoutes;
|
|
58
|
+
exports.resolveLocalisedLoaderRoute = __webpack_exports__.resolveLocalisedLoaderRoute;
|
|
59
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
60
|
+
"expandLocalisedLoaderRoutes",
|
|
61
|
+
"resolveLocalisedLoaderRoute"
|
|
62
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
63
|
+
Object.defineProperty(exports, '__esModule', {
|
|
64
|
+
value: true
|
|
65
|
+
});
|
|
@@ -31,14 +31,14 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
31
31
|
injectLocalisedLoaderPlugin: ()=>injectLocalisedLoaderPlugin
|
|
32
32
|
});
|
|
33
33
|
const runtime_namespaceObject = require("@modern-js/plugin-data-loader/runtime");
|
|
34
|
-
const localised_loader_identity_namespaceObject = require("@modern-js/runtime-extensions/localised-loader-identity");
|
|
35
34
|
const server_core_namespaceObject = require("@modern-js/server-core");
|
|
35
|
+
const external_localisedLoader_js_namespaceObject = require("./localisedLoader.js");
|
|
36
36
|
function injectLocalisedLoaderPlugin() {
|
|
37
37
|
return {
|
|
38
38
|
name: '@modern-js/localised-loader',
|
|
39
39
|
setup (api) {
|
|
40
40
|
const handler = async (context, next)=>{
|
|
41
|
-
(0, runtime_namespaceObject.setLoaderRouteIdResolver)((0, server_core_namespaceObject.getLoaderCtx)(context),
|
|
41
|
+
(0, runtime_namespaceObject.setLoaderRouteIdResolver)((0, server_core_namespaceObject.getLoaderCtx)(context), external_localisedLoader_js_namespaceObject.resolveLocalisedLoaderRoute, external_localisedLoader_js_namespaceObject.expandLocalisedLoaderRoutes);
|
|
42
42
|
await next();
|
|
43
43
|
};
|
|
44
44
|
api.onPrepare(()=>{
|
|
@@ -39,7 +39,8 @@ const fetchJsonWithTimeout = async (url, fetcher, timeout)=>{
|
|
|
39
39
|
try {
|
|
40
40
|
const response = await Promise.race([
|
|
41
41
|
fetcher(url, {
|
|
42
|
-
signal: controller.signal
|
|
42
|
+
signal: controller.signal,
|
|
43
|
+
redirect: 'error'
|
|
43
44
|
}),
|
|
44
45
|
new Promise((_, reject)=>{
|
|
45
46
|
timeoutId = setTimeout(()=>{
|
|
@@ -79,11 +79,45 @@ const joinModuleFederationAssetPath = (assetPath, assetName)=>{
|
|
|
79
79
|
const appendModuleFederationAsset = (set, assetPath)=>{
|
|
80
80
|
if (assetPath) set.add(trimLeadingSlash(assetPath));
|
|
81
81
|
};
|
|
82
|
-
const appendModuleFederationAssets = (set, assets)=>{
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
82
|
+
const appendModuleFederationAssets = (set, assets, directory = '')=>{
|
|
83
|
+
for (const asset of [
|
|
84
|
+
...assets?.js?.sync ?? [],
|
|
85
|
+
...assets?.js?.async ?? [],
|
|
86
|
+
...assets?.css?.sync ?? [],
|
|
87
|
+
...assets?.css?.async ?? []
|
|
88
|
+
])appendModuleFederationAsset(set, joinModuleFederationAssetPath(directory, asset));
|
|
89
|
+
};
|
|
90
|
+
const appendModuleFederationManifestAssets = (set, manifest, directory)=>{
|
|
91
|
+
for (const item of [
|
|
92
|
+
...manifest.shared ?? [],
|
|
93
|
+
...manifest.remotes ?? [],
|
|
94
|
+
...manifest.exposes ?? []
|
|
95
|
+
])appendModuleFederationAssets(set, item.assets, directory);
|
|
96
|
+
};
|
|
97
|
+
const getServerContainerDirectory = (metaData)=>{
|
|
98
|
+
const { publicPath, ssrPublicPath } = metaData ?? {};
|
|
99
|
+
if ('string' != typeof publicPath || 'string' != typeof ssrPublicPath || !ssrPublicPath.startsWith(publicPath)) return;
|
|
100
|
+
const directory = ssrPublicPath.slice(publicPath.length).replace(/^\/+|\/+$/gu, '');
|
|
101
|
+
return directory && directory.split('/').every((segment)=>segment && '.' !== segment && '..' !== segment) ? directory : void 0;
|
|
102
|
+
};
|
|
103
|
+
const readModuleFederationManifest = async (manifestPath)=>{
|
|
104
|
+
const manifestBuffer = await fileReader_namespaceObject.fileReader.readFileFromSystem(manifestPath, 'buffer');
|
|
105
|
+
if (null === manifestBuffer) return;
|
|
106
|
+
try {
|
|
107
|
+
return JSON.parse(manifestBuffer.toString('utf-8'));
|
|
108
|
+
} catch {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
const appendServerContainerAssets = async (pwd, set, metaData)=>{
|
|
113
|
+
const directory = getServerContainerDirectory(metaData);
|
|
114
|
+
const remoteEntry = joinModuleFederationAssetPath(metaData?.ssrRemoteEntry?.path, metaData?.ssrRemoteEntry?.name);
|
|
115
|
+
if (!directory || !remoteEntry) return;
|
|
116
|
+
set.add(joinModuleFederationAssetPath(directory, remoteEntry));
|
|
117
|
+
const manifestPath = external_path_default().join(pwd, directory, MODULE_FEDERATION_MANIFEST_FILE);
|
|
118
|
+
if (!await utils_namespaceObject.fs.pathExists(manifestPath)) return;
|
|
119
|
+
const manifest = await readModuleFederationManifest(manifestPath);
|
|
120
|
+
if (manifest) appendModuleFederationManifestAssets(set, manifest, directory);
|
|
87
121
|
};
|
|
88
122
|
const hasAbsoluteProtocol = (value)=>/^https?:\/\//i.test(value) || value.startsWith('//');
|
|
89
123
|
const ensureLeadingSlash = (value)=>{
|
|
@@ -98,9 +132,14 @@ const patchModuleFederationManifestPublicPath = (c, manifestBuffer, pathPrefix)=
|
|
|
98
132
|
if (!publicPath || hasAbsoluteProtocol(publicPath)) return manifestBuffer;
|
|
99
133
|
const requestURL = new URL(c.req.url);
|
|
100
134
|
const prefixPath = ensureTrailingSlash(ensureLeadingSlash(pathPrefix || '/'));
|
|
135
|
+
const servedPublicPath = `${requestURL.origin}${prefixPath}`;
|
|
136
|
+
const { ssrPublicPath } = manifest.metaData ?? {};
|
|
101
137
|
manifest.metaData = {
|
|
102
138
|
...manifest.metaData,
|
|
103
|
-
publicPath:
|
|
139
|
+
publicPath: servedPublicPath,
|
|
140
|
+
...'string' == typeof ssrPublicPath && !hasAbsoluteProtocol(ssrPublicPath) && ssrPublicPath.startsWith(publicPath) ? {
|
|
141
|
+
ssrPublicPath: `${servedPublicPath}${ssrPublicPath.slice(publicPath.length).replace(/^\/+/u, '')}`
|
|
142
|
+
} : {}
|
|
104
143
|
};
|
|
105
144
|
return Buffer.from(JSON.stringify(manifest), 'utf-8');
|
|
106
145
|
} catch {
|
|
@@ -125,9 +164,8 @@ const getModuleFederationAssetList = async (pwd)=>{
|
|
|
125
164
|
if (!await utils_namespaceObject.fs.pathExists(manifestPath)) continue;
|
|
126
165
|
manifestFound = true;
|
|
127
166
|
assets.add(manifestFile);
|
|
128
|
-
const
|
|
129
|
-
if (
|
|
130
|
-
const manifest = JSON.parse(manifestBuffer.toString('utf-8'));
|
|
167
|
+
const manifest = await readModuleFederationManifest(manifestPath);
|
|
168
|
+
if (manifest) try {
|
|
131
169
|
const remoteEntry = joinModuleFederationAssetPath(manifest.metaData?.remoteEntry?.path, manifest.metaData?.remoteEntry?.name);
|
|
132
170
|
const dtsZip = joinModuleFederationAssetPath(manifest.metaData?.types?.path, manifest.metaData?.types?.zip);
|
|
133
171
|
const dtsApi = joinModuleFederationAssetPath(manifest.metaData?.types?.path, manifest.metaData?.types?.api);
|
|
@@ -137,9 +175,8 @@ const getModuleFederationAssetList = async (pwd)=>{
|
|
|
137
175
|
}
|
|
138
176
|
appendModuleFederationAsset(assets, dtsZip);
|
|
139
177
|
appendModuleFederationAsset(assets, dtsApi);
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
manifest.exposes?.forEach((item)=>appendModuleFederationAssets(assets, item.assets));
|
|
178
|
+
appendModuleFederationManifestAssets(assets, manifest);
|
|
179
|
+
if (manifestFile === MODULE_FEDERATION_MANIFEST_FILE) await appendServerContainerAssets(pwd, assets, manifest.metaData);
|
|
143
180
|
} catch {}
|
|
144
181
|
}
|
|
145
182
|
if (manifestFound) {
|