@bleedingdev/modern-js-renderer-core 0.0.0-bootstrap → 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/LICENSE +21 -0
- package/dist/cjs/abort.js +65 -0
- package/dist/cjs/adapter.js +62 -0
- package/dist/cjs/data/body.js +78 -0
- package/dist/cjs/data/client.js +409 -0
- package/dist/cjs/data/codec.js +168 -0
- package/dist/cjs/data/index.js +125 -0
- package/dist/cjs/data/private.js +77 -0
- package/dist/cjs/data/routes.js +149 -0
- package/dist/cjs/data/server.js +791 -0
- package/dist/cjs/data/static.js +110 -0
- package/dist/cjs/data/tree.js +231 -0
- package/dist/cjs/data/types.js +56 -0
- package/dist/cjs/document.js +184 -0
- package/dist/cjs/entry-client.js +142 -0
- package/dist/cjs/entry-server.js +253 -0
- package/dist/cjs/federation.js +80 -0
- package/dist/cjs/identity.js +120 -0
- package/dist/cjs/index.js +46 -0
- package/dist/cjs/localization.js +48 -0
- package/dist/cjs/router.js +293 -0
- package/dist/cjs/server/assets.js +56 -0
- package/dist/cjs/server/dispatch.js +351 -0
- package/dist/cjs/server/index.js +57 -0
- package/dist/cjs/server/types.js +18 -0
- package/dist/cjs/server/worker.js +73 -0
- package/dist/cjs/session/cache.js +172 -0
- package/dist/cjs/session/index.js +63 -0
- package/dist/cjs/session/request.js +269 -0
- package/dist/cjs/session/types.js +18 -0
- package/dist/esm/abort.mjs +27 -0
- package/dist/esm/adapter.mjs +21 -0
- package/dist/esm/data/body.mjs +40 -0
- package/dist/esm/data/client.mjs +368 -0
- package/dist/esm/data/codec.mjs +112 -0
- package/dist/esm/data/index.mjs +7 -0
- package/dist/esm/data/private.mjs +39 -0
- package/dist/esm/data/routes.mjs +108 -0
- package/dist/esm/data/server.mjs +723 -0
- package/dist/esm/data/static.mjs +51 -0
- package/dist/esm/data/tree.mjs +193 -0
- package/dist/esm/data/types.mjs +6 -0
- package/dist/esm/document.mjs +131 -0
- package/dist/esm/entry-client.mjs +104 -0
- package/dist/esm/entry-server.mjs +215 -0
- package/dist/esm/federation.mjs +36 -0
- package/dist/esm/identity.mjs +63 -0
- package/dist/esm/index.mjs +1 -0
- package/dist/esm/localization.mjs +10 -0
- package/dist/esm/router.mjs +225 -0
- package/dist/esm/server/assets.mjs +15 -0
- package/dist/esm/server/dispatch.mjs +307 -0
- package/dist/esm/server/index.mjs +3 -0
- package/dist/esm/server/types.mjs +0 -0
- package/dist/esm/server/worker.mjs +35 -0
- package/dist/esm/session/cache.mjs +116 -0
- package/dist/esm/session/index.mjs +3 -0
- package/dist/esm/session/request.mjs +231 -0
- package/dist/esm/session/types.mjs +0 -0
- package/dist/esm-node/abort.mjs +28 -0
- package/dist/esm-node/adapter.mjs +22 -0
- package/dist/esm-node/data/body.mjs +41 -0
- package/dist/esm-node/data/client.mjs +369 -0
- package/dist/esm-node/data/codec.mjs +113 -0
- package/dist/esm-node/data/index.mjs +8 -0
- package/dist/esm-node/data/private.mjs +40 -0
- package/dist/esm-node/data/routes.mjs +109 -0
- package/dist/esm-node/data/server.mjs +724 -0
- package/dist/esm-node/data/static.mjs +52 -0
- package/dist/esm-node/data/tree.mjs +194 -0
- package/dist/esm-node/data/types.mjs +7 -0
- package/dist/esm-node/document.mjs +132 -0
- package/dist/esm-node/entry-client.mjs +105 -0
- package/dist/esm-node/entry-server.mjs +216 -0
- package/dist/esm-node/federation.mjs +37 -0
- package/dist/esm-node/identity.mjs +64 -0
- package/dist/esm-node/index.mjs +2 -0
- package/dist/esm-node/localization.mjs +11 -0
- package/dist/esm-node/router.mjs +226 -0
- package/dist/esm-node/server/assets.mjs +16 -0
- package/dist/esm-node/server/dispatch.mjs +308 -0
- package/dist/esm-node/server/index.mjs +4 -0
- package/dist/esm-node/server/types.mjs +1 -0
- package/dist/esm-node/server/worker.mjs +36 -0
- package/dist/esm-node/session/cache.mjs +117 -0
- package/dist/esm-node/session/index.mjs +4 -0
- package/dist/esm-node/session/request.mjs +232 -0
- package/dist/esm-node/session/types.mjs +1 -0
- package/dist/types/abort.d.ts +6 -0
- package/dist/types/adapter.d.ts +195 -0
- package/dist/types/data/body.d.ts +2 -0
- package/dist/types/data/client.d.ts +17 -0
- package/dist/types/data/codec.d.ts +14 -0
- package/dist/types/data/index.d.ts +8 -0
- package/dist/types/data/private.d.ts +6 -0
- package/dist/types/data/routes.d.ts +28 -0
- package/dist/types/data/server.d.ts +59 -0
- package/dist/types/data/static.d.ts +31 -0
- package/dist/types/data/tree.d.ts +3 -0
- package/dist/types/data/types.d.ts +104 -0
- package/dist/types/document.d.ts +76 -0
- package/dist/types/entry-client.d.ts +53 -0
- package/dist/types/entry-server.d.ts +63 -0
- package/dist/types/federation.d.ts +56 -0
- package/dist/types/identity.d.ts +27 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/localization.d.ts +58 -0
- package/dist/types/router.d.ts +201 -0
- package/dist/types/server/assets.d.ts +14 -0
- package/dist/types/server/dispatch.d.ts +11 -0
- package/dist/types/server/index.d.ts +4 -0
- package/dist/types/server/types.d.ts +64 -0
- package/dist/types/server/worker.d.ts +25 -0
- package/dist/types/session/cache.d.ts +25 -0
- package/dist/types/session/index.d.ts +4 -0
- package/dist/types/session/request.d.ts +8 -0
- package/dist/types/session/types.d.ts +48 -0
- package/package.json +159 -4
- package/src/abort.ts +40 -0
- package/src/adapter.ts +255 -0
- package/src/data/body.ts +43 -0
- package/src/data/client.ts +501 -0
- package/src/data/codec.ts +247 -0
- package/src/data/index.ts +8 -0
- package/src/data/private.ts +68 -0
- package/src/data/routes.ts +201 -0
- package/src/data/server.ts +977 -0
- package/src/data/static.ts +105 -0
- package/src/data/tree.ts +244 -0
- package/src/data/types.ts +98 -0
- package/src/document.ts +338 -0
- package/src/entry-client.ts +236 -0
- package/src/entry-server.ts +393 -0
- package/src/federation.ts +111 -0
- package/src/identity.ts +128 -0
- package/src/index.ts +7 -0
- package/src/localization.ts +77 -0
- package/src/router.ts +475 -0
- package/src/server/assets.ts +60 -0
- package/src/server/dispatch.ts +523 -0
- package/src/server/index.ts +16 -0
- package/src/server/types.ts +94 -0
- package/src/server/worker.ts +94 -0
- package/src/session/cache.ts +177 -0
- package/src/session/index.ts +11 -0
- package/src/session/request.ts +324 -0
- package/src/session/types.ts +60 -0
|
@@ -0,0 +1,142 @@
|
|
|
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
|
+
startNativeClientEntry: ()=>startNativeClientEntry
|
|
32
|
+
});
|
|
33
|
+
const index_js_namespaceObject = require("./data/index.js");
|
|
34
|
+
const external_document_js_namespaceObject = require("./document.js");
|
|
35
|
+
const external_localization_js_namespaceObject = require("./localization.js");
|
|
36
|
+
const external_router_js_namespaceObject = require("./router.js");
|
|
37
|
+
const external_abort_js_namespaceObject = require("./abort.js");
|
|
38
|
+
function isNativeEntryHot(value) {
|
|
39
|
+
return 'object' == typeof value && null !== value && 'dispose' in value && 'function' == typeof value.dispose;
|
|
40
|
+
}
|
|
41
|
+
function clientRouteLoader(application, identity) {
|
|
42
|
+
const serverDataRoutes = new Set(application.serverDataRoutes);
|
|
43
|
+
return async (route, input)=>{
|
|
44
|
+
const loader = application.dataModules[route.id]?.loader;
|
|
45
|
+
if (loader) return (0, index_js_namespaceObject.invokeRouteData)(loader, input, {
|
|
46
|
+
production: 'production' === process.env.NODE_ENV
|
|
47
|
+
});
|
|
48
|
+
if (!serverDataRoutes.has(route.id)) return {
|
|
49
|
+
kind: 'success',
|
|
50
|
+
value: void 0,
|
|
51
|
+
status: 200
|
|
52
|
+
};
|
|
53
|
+
return (0, index_js_namespaceObject.createDataClient)(route.id, identity).loader({
|
|
54
|
+
request: input.request
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function startNativeClientEntry(options, adapter) {
|
|
59
|
+
const identity = Object.freeze({
|
|
60
|
+
...options.identity
|
|
61
|
+
});
|
|
62
|
+
const root = document.getElementById(options.rootId ?? 'root');
|
|
63
|
+
if (!root) throw new Error('The native application mount element is missing');
|
|
64
|
+
const bootstrap = document.getElementById(external_document_js_namespaceObject.RENDERER_BOOTSTRAP_ID) ? adapter.readBootstrap(document, identity) : void 0;
|
|
65
|
+
const hydrating = bootstrap?.hydrating ?? false;
|
|
66
|
+
const controller = new AbortController();
|
|
67
|
+
const { signal } = controller;
|
|
68
|
+
let disposed = false;
|
|
69
|
+
let dispose;
|
|
70
|
+
if (isNativeEntryHot(options.hot)) options.hot.dispose(()=>{
|
|
71
|
+
disposed = true;
|
|
72
|
+
controller.abort(new DOMException('The application entry was disposed', 'AbortError'));
|
|
73
|
+
dispose?.();
|
|
74
|
+
});
|
|
75
|
+
const load = async ()=>{
|
|
76
|
+
const application = await (0, external_abort_js_namespaceObject.untilAborted)(options.load(), signal);
|
|
77
|
+
const { i18n } = options;
|
|
78
|
+
let instance;
|
|
79
|
+
if (i18n) {
|
|
80
|
+
const handoff = i18n.clientHandoff();
|
|
81
|
+
instance = await (0, external_abort_js_namespaceObject.untilAborted)(i18n.create(handoff.language, handoff.resources), signal);
|
|
82
|
+
const stopPersist = i18n.persist?.(instance);
|
|
83
|
+
if (stopPersist) signal.addEventListener('abort', stopPersist, {
|
|
84
|
+
once: true
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
const current = instance;
|
|
88
|
+
const localization = i18n && current ? {
|
|
89
|
+
i18n: (0, external_localization_js_namespaceObject.nativeI18nView)(i18n, current)
|
|
90
|
+
} : {};
|
|
91
|
+
if (!(0, external_router_js_namespaceObject.isRoutedApplication)(application)) return {
|
|
92
|
+
kind: 'component',
|
|
93
|
+
component: application.default,
|
|
94
|
+
...localization
|
|
95
|
+
};
|
|
96
|
+
const router = adapter.createRouter(application, {
|
|
97
|
+
identity,
|
|
98
|
+
loadRoute: clientRouteLoader(application, identity),
|
|
99
|
+
signal,
|
|
100
|
+
...i18n && current ? {
|
|
101
|
+
rewrite: i18n.rewrite(()=>current.language)
|
|
102
|
+
} : {}
|
|
103
|
+
});
|
|
104
|
+
const stopSync = i18n && current ? i18n.syncWithRouter(router, current) : void 0;
|
|
105
|
+
if (stopSync) signal.addEventListener('abort', stopSync, {
|
|
106
|
+
once: true
|
|
107
|
+
});
|
|
108
|
+
try {
|
|
109
|
+
await (0, external_abort_js_namespaceObject.untilAborted)(adapter.prepareRouter(router, hydrating, signal), signal);
|
|
110
|
+
} catch (error) {
|
|
111
|
+
stopSync?.();
|
|
112
|
+
throw error;
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
kind: 'router',
|
|
116
|
+
router,
|
|
117
|
+
...localization
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
adapter.start({
|
|
121
|
+
root,
|
|
122
|
+
identity,
|
|
123
|
+
bootstrap,
|
|
124
|
+
signal,
|
|
125
|
+
load
|
|
126
|
+
}).then((release)=>{
|
|
127
|
+
dispose = release;
|
|
128
|
+
if (disposed) release();
|
|
129
|
+
}).catch((error)=>{
|
|
130
|
+
if (!signal.aborted) controller.abort(error);
|
|
131
|
+
if (!disposed) queueMicrotask(()=>{
|
|
132
|
+
throw error;
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
exports.startNativeClientEntry = __webpack_exports__.startNativeClientEntry;
|
|
137
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
138
|
+
"startNativeClientEntry"
|
|
139
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
140
|
+
Object.defineProperty(exports, '__esModule', {
|
|
141
|
+
value: true
|
|
142
|
+
});
|
|
@@ -0,0 +1,253 @@
|
|
|
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
|
+
createNativeServerEntry: ()=>createNativeServerEntry
|
|
32
|
+
});
|
|
33
|
+
const external_abort_js_namespaceObject = require("./abort.js");
|
|
34
|
+
const index_js_namespaceObject = require("./data/index.js");
|
|
35
|
+
const external_identity_js_namespaceObject = require("./identity.js");
|
|
36
|
+
const external_localization_js_namespaceObject = require("./localization.js");
|
|
37
|
+
const external_router_js_namespaceObject = require("./router.js");
|
|
38
|
+
function serverRouteLoader(application) {
|
|
39
|
+
return async (route, input)=>{
|
|
40
|
+
const loader = application.dataModules[route.id]?.loader;
|
|
41
|
+
if (!loader) return {
|
|
42
|
+
kind: 'success',
|
|
43
|
+
value: void 0,
|
|
44
|
+
status: 200
|
|
45
|
+
};
|
|
46
|
+
return (0, index_js_namespaceObject.invokeRouteData)(loader, input, {
|
|
47
|
+
production: 'development' !== process.env.NODE_ENV
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function resolveDocumentPolicy(session, vary) {
|
|
52
|
+
if (!session.responsePolicy) session.resolveResponse({
|
|
53
|
+
kind: 'document',
|
|
54
|
+
status: 200,
|
|
55
|
+
headers: [
|
|
56
|
+
[
|
|
57
|
+
'content-type',
|
|
58
|
+
'text/html; charset=utf-8'
|
|
59
|
+
],
|
|
60
|
+
...vary?.length ? [
|
|
61
|
+
[
|
|
62
|
+
'vary',
|
|
63
|
+
vary.join(', ')
|
|
64
|
+
]
|
|
65
|
+
] : []
|
|
66
|
+
],
|
|
67
|
+
cache: {
|
|
68
|
+
mode: 'no-store'
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
const detectedVary = (language)=>language?.kind === 'language' ? language.vary : void 0;
|
|
73
|
+
function createNativeServerEntry(options, adapter) {
|
|
74
|
+
const rendererIdentity = Object.freeze({
|
|
75
|
+
...options.identity
|
|
76
|
+
});
|
|
77
|
+
const { i18n } = options;
|
|
78
|
+
const own = (request, context)=>{
|
|
79
|
+
(0, external_identity_js_namespaceObject.assertRendererIdentity)(context.entry, rendererIdentity);
|
|
80
|
+
(0, external_identity_js_namespaceObject.assertRendererIdentity)(context.session.identity, rendererIdentity);
|
|
81
|
+
if (request !== context.session.request) throw new Error('Native request/session ownership mismatch');
|
|
82
|
+
};
|
|
83
|
+
const prepare = (request, context)=>{
|
|
84
|
+
own(request, context);
|
|
85
|
+
return adapter.document({
|
|
86
|
+
documentId: crypto.randomUUID(),
|
|
87
|
+
rootId: options.rootId ?? 'root',
|
|
88
|
+
...void 0 === context.nonce ? {} : {
|
|
89
|
+
nonce: context.nonce
|
|
90
|
+
},
|
|
91
|
+
...void 0 === context.assets ? {} : {
|
|
92
|
+
assets: context.assets
|
|
93
|
+
}
|
|
94
|
+
}, context.nativeManifest, rendererIdentity);
|
|
95
|
+
};
|
|
96
|
+
const routedApplication = async (signal)=>{
|
|
97
|
+
const application = await (0, external_abort_js_namespaceObject.untilAborted)(options.app(), signal);
|
|
98
|
+
if (!(0, external_router_js_namespaceObject.isRoutedApplication)(application)) throw new Error('unsupported-renderer-capability: ssrByRouteIds requires native route matching.');
|
|
99
|
+
return application;
|
|
100
|
+
};
|
|
101
|
+
const nativeCSRRequestHandler = (request, context)=>adapter.run(context.session, async ()=>{
|
|
102
|
+
const document = prepare(request, context);
|
|
103
|
+
if (!i18n) {
|
|
104
|
+
resolveDocumentPolicy(context.session);
|
|
105
|
+
return adapter.renderCSR(context, document);
|
|
106
|
+
}
|
|
107
|
+
const language = i18n.resolveRequest(request);
|
|
108
|
+
if ('redirect' === language.kind) return adapter.respond(context.session, i18n.redirect(language.location));
|
|
109
|
+
resolveDocumentPolicy(context.session, detectedVary(language));
|
|
110
|
+
return adapter.renderCSR(context, {
|
|
111
|
+
...document,
|
|
112
|
+
lang: language.language,
|
|
113
|
+
inlineData: [
|
|
114
|
+
i18n.handoff(language.language)
|
|
115
|
+
]
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
const nativeMatchRouteIds = (request, context)=>adapter.run(context.session, async ()=>{
|
|
119
|
+
own(request, context);
|
|
120
|
+
const application = await routedApplication(context.session.signal);
|
|
121
|
+
const router = adapter.createRouter(application, {
|
|
122
|
+
identity: rendererIdentity,
|
|
123
|
+
loadRoute: serverRouteLoader(application),
|
|
124
|
+
request,
|
|
125
|
+
context: context.session.platform.bindings,
|
|
126
|
+
session: context.session,
|
|
127
|
+
...i18n ? {
|
|
128
|
+
rewrite: i18n.rewrite(()=>i18n.resolveRequest(request).language)
|
|
129
|
+
} : {}
|
|
130
|
+
});
|
|
131
|
+
return (0, external_router_js_namespaceObject.matchApplicationRouteIds)(router, new URL(request.url));
|
|
132
|
+
});
|
|
133
|
+
const nativeRequestHandler = (request, context)=>adapter.run(context.session, async ()=>{
|
|
134
|
+
const document = prepare(request, context);
|
|
135
|
+
const { session } = context;
|
|
136
|
+
const application = await (0, external_abort_js_namespaceObject.untilAborted)(options.app(), session.signal);
|
|
137
|
+
const routed = (0, external_router_js_namespaceObject.isRoutedApplication)(application);
|
|
138
|
+
const nativeRequest = routed ? new Request(request, {
|
|
139
|
+
signal: session.signal
|
|
140
|
+
}) : request;
|
|
141
|
+
const language = i18n?.resolveRequest(nativeRequest);
|
|
142
|
+
if (!routed && i18n && language?.kind === 'redirect') return adapter.respond(session, i18n.redirect(language.location));
|
|
143
|
+
const localize = async (inlineData = [])=>{
|
|
144
|
+
if (!i18n || !language) return {
|
|
145
|
+
document,
|
|
146
|
+
localization: void 0
|
|
147
|
+
};
|
|
148
|
+
const instance = await (0, external_abort_js_namespaceObject.untilAborted)(i18n.create(language.language), session.signal);
|
|
149
|
+
return {
|
|
150
|
+
document: {
|
|
151
|
+
...document,
|
|
152
|
+
lang: instance.language,
|
|
153
|
+
inlineData: [
|
|
154
|
+
...inlineData,
|
|
155
|
+
i18n.handoff(instance.language, instance)
|
|
156
|
+
]
|
|
157
|
+
},
|
|
158
|
+
localization: (0, external_localization_js_namespaceObject.nativeI18nView)(i18n, instance)
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
if (!routed) {
|
|
162
|
+
const localized = await localize(document.inlineData);
|
|
163
|
+
resolveDocumentPolicy(session, detectedVary(language));
|
|
164
|
+
return adapter.renderComponent(context, application.default, localized.document, localized.localization);
|
|
165
|
+
}
|
|
166
|
+
const bindings = session.platform.bindings;
|
|
167
|
+
const outcomes = [];
|
|
168
|
+
const outcomeRanks = [];
|
|
169
|
+
let routeOrder;
|
|
170
|
+
const addOutcome = (rank, outcome)=>{
|
|
171
|
+
const at = outcomeRanks.findIndex((other)=>other > rank);
|
|
172
|
+
const index = at < 0 ? outcomes.length : at;
|
|
173
|
+
outcomes.splice(index, 0, outcome);
|
|
174
|
+
outcomeRanks.splice(index, 0, rank);
|
|
175
|
+
};
|
|
176
|
+
const router = adapter.createRouter(application, {
|
|
177
|
+
identity: rendererIdentity,
|
|
178
|
+
loadRoute: serverRouteLoader(application),
|
|
179
|
+
request: nativeRequest,
|
|
180
|
+
context: bindings,
|
|
181
|
+
onOutcome: (routeId, outcome)=>{
|
|
182
|
+
if ('response' in outcome) {
|
|
183
|
+
routeOrder ??= (0, external_router_js_namespaceObject.matchApplicationRouteIds)(router, new URL(nativeRequest.url));
|
|
184
|
+
const rank = routeOrder.indexOf(routeId);
|
|
185
|
+
addOutcome(rank < 0 ? 1 / 0 : rank, outcome);
|
|
186
|
+
} else if (outcome.completion) {
|
|
187
|
+
const completion = outcome.completion;
|
|
188
|
+
completion.catch((error)=>session.fail(error));
|
|
189
|
+
session.registerCleanup(()=>completion);
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
session,
|
|
193
|
+
...void 0 === context.nonce ? {} : {
|
|
194
|
+
nonce: context.nonce
|
|
195
|
+
},
|
|
196
|
+
...i18n && language ? {
|
|
197
|
+
rewrite: i18n.rewrite(()=>language.language)
|
|
198
|
+
} : {}
|
|
199
|
+
});
|
|
200
|
+
const dataResponse = await (0, index_js_namespaceObject.handleDataRequest)({
|
|
201
|
+
request: nativeRequest,
|
|
202
|
+
identity: rendererIdentity,
|
|
203
|
+
context: bindings,
|
|
204
|
+
privateValues: [
|
|
205
|
+
context,
|
|
206
|
+
session,
|
|
207
|
+
session.platform,
|
|
208
|
+
bindings
|
|
209
|
+
],
|
|
210
|
+
production: 'development' !== process.env.NODE_ENV,
|
|
211
|
+
selectRoute: (dataRequest, routeId, operation)=>(0, external_router_js_namespaceObject.selectApplicationDataRoute)(router, dataRequest, routeId, operation, application.dataModules)
|
|
212
|
+
});
|
|
213
|
+
if (dataResponse) return adapter.respond(session, dataResponse);
|
|
214
|
+
if (i18n && language?.kind === 'redirect') return adapter.respond(session, i18n.redirect(language.location));
|
|
215
|
+
const vary = detectedVary(language);
|
|
216
|
+
if (vary?.length) addOutcome(1 / 0, await (0, index_js_namespaceObject.normalizeDataResult)(new Response(null, {
|
|
217
|
+
headers: {
|
|
218
|
+
vary: vary.join(', ')
|
|
219
|
+
}
|
|
220
|
+
})));
|
|
221
|
+
const localized = await localize();
|
|
222
|
+
return adapter.renderRoutes({
|
|
223
|
+
request: nativeRequest,
|
|
224
|
+
context,
|
|
225
|
+
router,
|
|
226
|
+
outcomes,
|
|
227
|
+
document: localized.document,
|
|
228
|
+
forbiddenValues: [
|
|
229
|
+
context,
|
|
230
|
+
session,
|
|
231
|
+
session.platform,
|
|
232
|
+
bindings,
|
|
233
|
+
nativeRequest
|
|
234
|
+
],
|
|
235
|
+
...localized.localization ? {
|
|
236
|
+
i18n: localized.localization
|
|
237
|
+
} : {}
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
return {
|
|
241
|
+
rendererIdentity,
|
|
242
|
+
nativeRequestHandler,
|
|
243
|
+
nativeCSRRequestHandler,
|
|
244
|
+
nativeMatchRouteIds
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
exports.createNativeServerEntry = __webpack_exports__.createNativeServerEntry;
|
|
248
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
249
|
+
"createNativeServerEntry"
|
|
250
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
251
|
+
Object.defineProperty(exports, '__esModule', {
|
|
252
|
+
value: true
|
|
253
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
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
|
+
function getFederationHost(binding) {
|
|
31
|
+
if (void 0 === binding) return;
|
|
32
|
+
if ('function' != typeof binding?.instance) throw new TypeError('The native federation host binding is invalid.');
|
|
33
|
+
const instance = binding.instance();
|
|
34
|
+
if (!instance || 'function' != typeof instance.loadRemote) throw new TypeError('The application federation runtime has not started.');
|
|
35
|
+
return instance;
|
|
36
|
+
}
|
|
37
|
+
async function loadFederatedModule(instance, id) {
|
|
38
|
+
if (!instance) throw new Error(`Cannot load ${id}: this application has no Module Federation runtime. Add module-federation.config.ts with its remotes.`);
|
|
39
|
+
const module = await instance.loadRemote(id);
|
|
40
|
+
if (!module) throw new Error(`Remote module ${id} is unavailable`);
|
|
41
|
+
return module;
|
|
42
|
+
}
|
|
43
|
+
function remoteBrowserAssets(instance, id) {
|
|
44
|
+
const target = instance.remoteHandler?.idToRemoteMap?.[id];
|
|
45
|
+
const loaded = target && instance.moduleCache?.get(target.name);
|
|
46
|
+
const snapshot = loaded && instance.snapshotHandler?.getGlobalRemoteInfo(loaded.remoteInfo).remoteSnapshot;
|
|
47
|
+
if (!snapshot || 'string' != typeof snapshot.publicPath || !snapshot.publicPath || 'string' != typeof snapshot.remoteEntry || !snapshot.remoteEntry) return;
|
|
48
|
+
const expose = snapshot.modules?.find((module)=>module.modulePath === target.expose);
|
|
49
|
+
if (!expose?.assets) return;
|
|
50
|
+
const publicPath = snapshot.publicPath;
|
|
51
|
+
const url = (file)=>/^(?:https?:)?\/\//iu.test(file) ? file : `${publicPath.replace(/\/$/u, '')}/${file.replace(/^\//u, '')}`;
|
|
52
|
+
return {
|
|
53
|
+
js: [
|
|
54
|
+
url(snapshot.remoteEntry),
|
|
55
|
+
...(expose.assets.js?.sync ?? []).map(url)
|
|
56
|
+
],
|
|
57
|
+
css: [
|
|
58
|
+
...new Set([
|
|
59
|
+
...expose.assets.css?.sync ?? [],
|
|
60
|
+
...expose.assets.css?.async ?? []
|
|
61
|
+
].map(url))
|
|
62
|
+
]
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
66
|
+
getFederationHost: ()=>getFederationHost,
|
|
67
|
+
loadFederatedModule: ()=>loadFederatedModule,
|
|
68
|
+
remoteBrowserAssets: ()=>remoteBrowserAssets
|
|
69
|
+
});
|
|
70
|
+
exports.getFederationHost = __webpack_exports__.getFederationHost;
|
|
71
|
+
exports.loadFederatedModule = __webpack_exports__.loadFederatedModule;
|
|
72
|
+
exports.remoteBrowserAssets = __webpack_exports__.remoteBrowserAssets;
|
|
73
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
74
|
+
"getFederationHost",
|
|
75
|
+
"loadFederatedModule",
|
|
76
|
+
"remoteBrowserAssets"
|
|
77
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
78
|
+
Object.defineProperty(exports, '__esModule', {
|
|
79
|
+
value: true
|
|
80
|
+
});
|
|
@@ -0,0 +1,120 @@
|
|
|
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
|
+
function resolveRenderer(value = 'react') {
|
|
31
|
+
if ('string' == typeof value && value.trim() === value && /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(value)) return value;
|
|
32
|
+
throw new Error(`Unsupported UltraModern renderer: ${String(value)}`);
|
|
33
|
+
}
|
|
34
|
+
function identityCacheKey(identity) {
|
|
35
|
+
resolveRenderer(identity.renderer);
|
|
36
|
+
for (const key of [
|
|
37
|
+
'appId',
|
|
38
|
+
'entryName',
|
|
39
|
+
'buildId'
|
|
40
|
+
])if ('string' != typeof identity[key] || 0 === identity[key].trim().length) throw new Error(`Renderer identity requires a nonempty ${key}`);
|
|
41
|
+
if (1 !== identity.protocolVersion) throw new Error('Unsupported renderer data protocol version');
|
|
42
|
+
return JSON.stringify([
|
|
43
|
+
identity.renderer,
|
|
44
|
+
identity.appId,
|
|
45
|
+
identity.entryName,
|
|
46
|
+
identity.protocolVersion,
|
|
47
|
+
identity.buildId
|
|
48
|
+
]);
|
|
49
|
+
}
|
|
50
|
+
function assertRendererIdentity(actual, expected) {
|
|
51
|
+
if (identityCacheKey(actual) !== identityCacheKey(expected)) throw new Error('Renderer identity conflicts with the application build');
|
|
52
|
+
}
|
|
53
|
+
const IDENTITY_FIELDS = [
|
|
54
|
+
'renderer',
|
|
55
|
+
'appId',
|
|
56
|
+
'entryName',
|
|
57
|
+
'protocolVersion',
|
|
58
|
+
'buildId'
|
|
59
|
+
];
|
|
60
|
+
function readRendererIdentity(value, expected) {
|
|
61
|
+
if (!value || 'object' != typeof value || ![
|
|
62
|
+
Object.prototype,
|
|
63
|
+
null
|
|
64
|
+
].includes(Object.getPrototypeOf(value)) || Object.keys(value).some((key)=>!IDENTITY_FIELDS.includes(key))) throw new Error('A renderer identity must contain only identity fields.');
|
|
65
|
+
const identity = value;
|
|
66
|
+
assertRendererIdentity(identity, expected);
|
|
67
|
+
return Object.freeze({
|
|
68
|
+
renderer: identity.renderer,
|
|
69
|
+
appId: identity.appId,
|
|
70
|
+
entryName: identity.entryName,
|
|
71
|
+
protocolVersion: identity.protocolVersion,
|
|
72
|
+
buildId: identity.buildId
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function nativeModuleManifestFilename(renderer, entryName) {
|
|
76
|
+
if ('string' != typeof entryName || !entryName.trim()) throw new Error('Native module manifests require an application entry name.');
|
|
77
|
+
return `${resolveRenderer(renderer)}-module-manifest.${encodeURIComponent(entryName)}.json`;
|
|
78
|
+
}
|
|
79
|
+
const RENDERER_IDENTITY_HEADER = 'x-ultramodern-renderer-identity';
|
|
80
|
+
function serializeRendererIdentityHeader(identity) {
|
|
81
|
+
identityCacheKey(identity);
|
|
82
|
+
return JSON.stringify({
|
|
83
|
+
renderer: identity.renderer,
|
|
84
|
+
appId: identity.appId,
|
|
85
|
+
entryName: identity.entryName,
|
|
86
|
+
protocolVersion: identity.protocolVersion,
|
|
87
|
+
buildId: identity.buildId
|
|
88
|
+
}).replace(/[\u007f-\u{10ffff}]/gu, (character)=>Array.from({
|
|
89
|
+
length: character.length
|
|
90
|
+
}, (_, index)=>`\\u${character.charCodeAt(index).toString(16).padStart(4, '0')}`).join(''));
|
|
91
|
+
}
|
|
92
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
93
|
+
assertRendererIdentity: ()=>assertRendererIdentity,
|
|
94
|
+
identityCacheKey: ()=>identityCacheKey,
|
|
95
|
+
nativeModuleManifestFilename: ()=>nativeModuleManifestFilename,
|
|
96
|
+
readRendererIdentity: ()=>readRendererIdentity,
|
|
97
|
+
resolveRenderer: ()=>resolveRenderer,
|
|
98
|
+
serializeRendererIdentityHeader: ()=>serializeRendererIdentityHeader
|
|
99
|
+
}, {
|
|
100
|
+
RENDERER_IDENTITY_HEADER: RENDERER_IDENTITY_HEADER
|
|
101
|
+
});
|
|
102
|
+
exports.RENDERER_IDENTITY_HEADER = __webpack_exports__.RENDERER_IDENTITY_HEADER;
|
|
103
|
+
exports.assertRendererIdentity = __webpack_exports__.assertRendererIdentity;
|
|
104
|
+
exports.identityCacheKey = __webpack_exports__.identityCacheKey;
|
|
105
|
+
exports.nativeModuleManifestFilename = __webpack_exports__.nativeModuleManifestFilename;
|
|
106
|
+
exports.readRendererIdentity = __webpack_exports__.readRendererIdentity;
|
|
107
|
+
exports.resolveRenderer = __webpack_exports__.resolveRenderer;
|
|
108
|
+
exports.serializeRendererIdentityHeader = __webpack_exports__.serializeRendererIdentityHeader;
|
|
109
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
110
|
+
"RENDERER_IDENTITY_HEADER",
|
|
111
|
+
"assertRendererIdentity",
|
|
112
|
+
"identityCacheKey",
|
|
113
|
+
"nativeModuleManifestFilename",
|
|
114
|
+
"readRendererIdentity",
|
|
115
|
+
"resolveRenderer",
|
|
116
|
+
"serializeRendererIdentityHeader"
|
|
117
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
118
|
+
Object.defineProperty(exports, '__esModule', {
|
|
119
|
+
value: true
|
|
120
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
assertRendererIdentity: ()=>external_identity_js_namespaceObject.assertRendererIdentity,
|
|
32
|
+
identityCacheKey: ()=>external_identity_js_namespaceObject.identityCacheKey,
|
|
33
|
+
resolveRenderer: ()=>external_identity_js_namespaceObject.resolveRenderer
|
|
34
|
+
});
|
|
35
|
+
const external_identity_js_namespaceObject = require("./identity.js");
|
|
36
|
+
exports.assertRendererIdentity = __webpack_exports__.assertRendererIdentity;
|
|
37
|
+
exports.identityCacheKey = __webpack_exports__.identityCacheKey;
|
|
38
|
+
exports.resolveRenderer = __webpack_exports__.resolveRenderer;
|
|
39
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
40
|
+
"assertRendererIdentity",
|
|
41
|
+
"identityCacheKey",
|
|
42
|
+
"resolveRenderer"
|
|
43
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
44
|
+
Object.defineProperty(exports, '__esModule', {
|
|
45
|
+
value: true
|
|
46
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
function nativeI18nView(i18n, instance) {
|
|
31
|
+
return {
|
|
32
|
+
instance,
|
|
33
|
+
languages: i18n.languages,
|
|
34
|
+
...void 0 === i18n.localisedUrls ? {} : {
|
|
35
|
+
localisedUrls: i18n.localisedUrls
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
40
|
+
nativeI18nView: ()=>nativeI18nView
|
|
41
|
+
});
|
|
42
|
+
exports.nativeI18nView = __webpack_exports__.nativeI18nView;
|
|
43
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
44
|
+
"nativeI18nView"
|
|
45
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
46
|
+
Object.defineProperty(exports, '__esModule', {
|
|
47
|
+
value: true
|
|
48
|
+
});
|