@bleedingdev/modern-js-renderer-octane 0.0.0-stage → 3.9.3-ultramodern.2
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/bin/octane-tsc.mjs +4 -0
- package/dist/cjs/bootstrap.js +68 -0
- package/dist/cjs/client.js +371 -0
- package/dist/cjs/entry-application.js +83 -0
- package/dist/cjs/entry-client.js +92 -0
- package/dist/cjs/entry-server.js +127 -0
- package/dist/cjs/federation-context.js +72 -0
- package/dist/cjs/federation.js +103 -0
- package/dist/cjs/i18n/I18nProvider.js +67 -0
- package/dist/cjs/i18n/LocalizedLink.js +89 -0
- package/dist/cjs/i18n/context.js +41 -0
- package/dist/cjs/i18n/index.js +86 -0
- package/dist/cjs/i18n/languageSync.js +99 -0
- package/dist/cjs/i18n/types.js +18 -0
- package/dist/cjs/i18n/useI18n.js +110 -0
- package/dist/cjs/index.js +46 -0
- package/dist/cjs/manifest.js +167 -0
- package/dist/cjs/plugin/compiler.js +125 -0
- package/dist/cjs/plugin/create.js +265 -0
- package/dist/cjs/plugin/index.js +151 -0
- package/dist/cjs/plugin/profile.js +89 -0
- package/dist/cjs/plugin/source.js +56 -0
- package/dist/cjs/router-client.js +139 -0
- package/dist/cjs/router-handler.js +168 -0
- package/dist/cjs/router-injection.js +139 -0
- package/dist/cjs/router-server-cleanup.js +46 -0
- package/dist/cjs/router-server-snapshot.js +405 -0
- package/dist/cjs/router-server.js +108 -0
- package/dist/cjs/router-snapshot.js +270 -0
- package/dist/cjs/router.js +218 -0
- package/dist/cjs/routes.js +187 -0
- package/dist/cjs/server.js +224 -0
- package/dist/cjs/typecheck.js +615 -0
- package/dist/esm/bootstrap.mjs +24 -0
- package/dist/esm/client.mjs +327 -0
- package/dist/esm/entry-application.mjs +39 -0
- package/dist/esm/entry-client.mjs +54 -0
- package/dist/esm/entry-server.mjs +86 -0
- package/dist/esm/federation-context.mjs +25 -0
- package/dist/esm/federation.mjs +65 -0
- package/dist/esm/i18n/I18nProvider.mjs +29 -0
- package/dist/esm/i18n/LocalizedLink.mjs +48 -0
- package/dist/esm/i18n/context.mjs +3 -0
- package/dist/esm/i18n/index.mjs +8 -0
- package/dist/esm/i18n/languageSync.mjs +61 -0
- package/dist/esm/i18n/types.mjs +0 -0
- package/dist/esm/i18n/useI18n.mjs +72 -0
- package/dist/esm/index.mjs +8 -0
- package/dist/esm/manifest.mjs +117 -0
- package/dist/esm/router-client.mjs +98 -0
- package/dist/esm/router-handler.mjs +130 -0
- package/dist/esm/router-injection.mjs +101 -0
- package/dist/esm/router-server-cleanup.mjs +8 -0
- package/dist/esm/router-server-snapshot.mjs +367 -0
- package/dist/esm/router-server.mjs +12 -0
- package/dist/esm/router-snapshot.mjs +199 -0
- package/dist/esm/router.mjs +94 -0
- package/dist/esm/routes.mjs +134 -0
- package/dist/esm/server.mjs +183 -0
- package/dist/esm-node/bootstrap.mjs +24 -0
- package/dist/esm-node/manifest.mjs +117 -0
- package/dist/esm-node/plugin/compiler.mjs +70 -0
- package/dist/esm-node/plugin/create.mjs +227 -0
- package/dist/esm-node/plugin/index.mjs +103 -0
- package/dist/esm-node/plugin/profile.mjs +51 -0
- package/dist/esm-node/plugin/source.mjs +7 -0
- package/dist/esm-node/typecheck.mjs +560 -0
- package/dist/types/bootstrap.d.ts +10 -0
- package/dist/types/client.d.ts +36 -0
- package/dist/types/entry-application.d.ts +19 -0
- package/dist/types/entry-client.d.ts +8 -0
- package/dist/types/entry-server.d.ts +11 -0
- package/dist/types/federation-context.d.ts +28 -0
- package/dist/types/federation.d.ts +18 -0
- package/dist/types/i18n/I18nProvider.d.ts +8 -0
- package/dist/types/i18n/LocalizedLink.d.ts +41 -0
- package/dist/types/i18n/context.d.ts +9 -0
- package/dist/types/i18n/index.d.ts +9 -0
- package/dist/types/i18n/languageSync.d.ts +26 -0
- package/dist/types/i18n/types.d.ts +34 -0
- package/dist/types/i18n/useI18n.d.ts +21 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/manifest.d.ts +34 -0
- package/dist/types/plugin/compiler-manifest.d.cts +10 -0
- package/dist/types/plugin/compiler.d.ts +5 -0
- package/dist/types/plugin/create.d.ts +23 -0
- package/dist/types/plugin/index.d.ts +3 -0
- package/dist/types/plugin/profile.d.ts +2 -0
- package/dist/types/plugin/source.d.ts +1 -0
- package/dist/types/plugin/svg-component-template.d.cts +6 -0
- package/dist/types/router-client.d.ts +12 -0
- package/dist/types/router-handler.d.ts +13 -0
- package/dist/types/router-injection.d.ts +8 -0
- package/dist/types/router-server-cleanup.d.ts +3 -0
- package/dist/types/router-server-snapshot.d.ts +15 -0
- package/dist/types/router-server.d.ts +13 -0
- package/dist/types/router-snapshot.d.ts +14 -0
- package/dist/types/router.d.ts +30 -0
- package/dist/types/routes.d.ts +18 -0
- package/dist/types/server.d.ts +41 -0
- package/dist/types/typecheck.d.ts +31 -0
- package/package.json +216 -4
- package/src/bootstrap.ts +60 -0
- package/src/client.ts +485 -0
- package/src/entry-application.ts +72 -0
- package/src/entry-client.ts +80 -0
- package/src/entry-server.ts +142 -0
- package/src/federation-context.ts +53 -0
- package/src/federation.ts +158 -0
- package/src/i18n/I18nProvider.ts +56 -0
- package/src/i18n/LocalizedLink.ts +112 -0
- package/src/i18n/context.ts +12 -0
- package/src/i18n/index.ts +35 -0
- package/src/i18n/languageSync.ts +132 -0
- package/src/i18n/types.ts +36 -0
- package/src/i18n/useI18n.ts +119 -0
- package/src/index.ts +10 -0
- package/src/manifest.ts +253 -0
- package/src/plugin/compiler-manifest.cjs +178 -0
- package/src/plugin/compiler.ts +112 -0
- package/src/plugin/create.ts +272 -0
- package/src/plugin/index.ts +105 -0
- package/src/plugin/profile.ts +46 -0
- package/src/plugin/source.ts +16 -0
- package/src/plugin/svg-component-template.cjs +17 -0
- package/src/router-client.ts +144 -0
- package/src/router-handler.ts +182 -0
- package/src/router-injection.ts +145 -0
- package/src/router-server-cleanup.ts +11 -0
- package/src/router-server-snapshot.ts +564 -0
- package/src/router-server.ts +23 -0
- package/src/router-snapshot.ts +251 -0
- package/src/router.ts +192 -0
- package/src/routes.ts +263 -0
- package/src/server.ts +300 -0
- package/src/typecheck.ts +723 -0
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021-present Modern.js
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
assertNativeHydrationBuildId: ()=>assertNativeHydrationBuildId,
|
|
32
|
+
assertOctaneIdentity: ()=>assertOctaneIdentity,
|
|
33
|
+
readOctaneDocumentBootstrap: ()=>readOctaneDocumentBootstrap
|
|
34
|
+
});
|
|
35
|
+
const document_namespaceObject = require("@modern-js/renderer-core/document");
|
|
36
|
+
const identity_namespaceObject = require("@modern-js/renderer-core/identity");
|
|
37
|
+
function assertNativeHydrationBuildId(value) {
|
|
38
|
+
if ('string' != typeof value || 0 === value.trim().length) throw new Error('An Octane document requires its native client compilation identity.');
|
|
39
|
+
}
|
|
40
|
+
function assertOctaneIdentity(identity) {
|
|
41
|
+
(0, identity_namespaceObject.readRendererIdentity)(identity, identity);
|
|
42
|
+
if ('octane' !== identity.renderer) throw new Error('An Octane application requires an Octane renderer identity.');
|
|
43
|
+
}
|
|
44
|
+
function readOctaneDocumentBootstrap(document, expectedIdentity, expectedNativeHydrationBuildId) {
|
|
45
|
+
assertOctaneIdentity(expectedIdentity);
|
|
46
|
+
const { identity, documentId, hydrating, nativeHydrationBuildId } = (0, document_namespaceObject.readDocumentBootstrap)(document, expectedIdentity, [
|
|
47
|
+
'nativeHydrationBuildId'
|
|
48
|
+
]);
|
|
49
|
+
assertNativeHydrationBuildId(nativeHydrationBuildId);
|
|
50
|
+
if (void 0 !== expectedNativeHydrationBuildId && nativeHydrationBuildId !== expectedNativeHydrationBuildId) throw new Error('Octane hydration bytes belong to a different native client compilation.');
|
|
51
|
+
return Object.freeze({
|
|
52
|
+
identity,
|
|
53
|
+
documentId,
|
|
54
|
+
hydrating,
|
|
55
|
+
nativeHydrationBuildId
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
exports.assertNativeHydrationBuildId = __webpack_exports__.assertNativeHydrationBuildId;
|
|
59
|
+
exports.assertOctaneIdentity = __webpack_exports__.assertOctaneIdentity;
|
|
60
|
+
exports.readOctaneDocumentBootstrap = __webpack_exports__.readOctaneDocumentBootstrap;
|
|
61
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
62
|
+
"assertNativeHydrationBuildId",
|
|
63
|
+
"assertOctaneIdentity",
|
|
64
|
+
"readOctaneDocumentBootstrap"
|
|
65
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
66
|
+
Object.defineProperty(exports, '__esModule', {
|
|
67
|
+
value: true
|
|
68
|
+
});
|
|
@@ -0,0 +1,371 @@
|
|
|
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
|
+
hydrateOctaneApplication: ()=>hydrateOctaneApplication,
|
|
32
|
+
mountOctaneApplication: ()=>mountOctaneApplication,
|
|
33
|
+
readOctaneDocumentBootstrap: ()=>external_bootstrap_js_namespaceObject.readOctaneDocumentBootstrap
|
|
34
|
+
});
|
|
35
|
+
const identity_namespaceObject = require("@modern-js/renderer-core/identity");
|
|
36
|
+
const external_octane_namespaceObject = require("octane");
|
|
37
|
+
const streamed_signals_namespaceObject = require("octane/hydration/streamed-signals");
|
|
38
|
+
const external_bootstrap_js_namespaceObject = require("./bootstrap.js");
|
|
39
|
+
const external_federation_context_js_namespaceObject = require("./federation-context.js");
|
|
40
|
+
const roots = new WeakMap();
|
|
41
|
+
const documents = new WeakMap();
|
|
42
|
+
const moduleResources = new WeakMap();
|
|
43
|
+
function claimModuleResources(application) {
|
|
44
|
+
const dispose = application.dispose;
|
|
45
|
+
if (!dispose) return ()=>{};
|
|
46
|
+
let resources = moduleResources.get(dispose);
|
|
47
|
+
if (resources?.retired) throw new Error('A retired Octane application requires a fresh module resource instance.');
|
|
48
|
+
if (!resources) {
|
|
49
|
+
resources = {
|
|
50
|
+
users: 0,
|
|
51
|
+
retired: false
|
|
52
|
+
};
|
|
53
|
+
moduleResources.set(dispose, resources);
|
|
54
|
+
}
|
|
55
|
+
resources.users++;
|
|
56
|
+
let released = false;
|
|
57
|
+
return ()=>{
|
|
58
|
+
if (released) return;
|
|
59
|
+
released = true;
|
|
60
|
+
resources.users--;
|
|
61
|
+
if (0 === resources.users && !resources.retired) {
|
|
62
|
+
resources.retired = true;
|
|
63
|
+
dispose();
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function retireAbandonedModule(application) {
|
|
68
|
+
if (application.dispose && moduleResources.get(application.dispose)?.users) return;
|
|
69
|
+
if (application.dispose && moduleResources.get(application.dispose)?.retired) return;
|
|
70
|
+
claimModuleResources(application)();
|
|
71
|
+
}
|
|
72
|
+
function observeRootErrors(options) {
|
|
73
|
+
let failed = false;
|
|
74
|
+
let failure;
|
|
75
|
+
let handle;
|
|
76
|
+
return {
|
|
77
|
+
options: {
|
|
78
|
+
...options,
|
|
79
|
+
onUncaughtError (error) {
|
|
80
|
+
if (failed) return;
|
|
81
|
+
failed = true;
|
|
82
|
+
failure = error;
|
|
83
|
+
if (handle) {
|
|
84
|
+
const failedHandle = handle;
|
|
85
|
+
queueMicrotask(()=>{
|
|
86
|
+
try {
|
|
87
|
+
failedHandle.dispose();
|
|
88
|
+
} catch (cleanupError) {
|
|
89
|
+
failure = new AggregateError([
|
|
90
|
+
error,
|
|
91
|
+
cleanupError
|
|
92
|
+
], 'Octane rendering and cleanup failed.');
|
|
93
|
+
}
|
|
94
|
+
if (options?.onUncaughtError) options.onUncaughtError(failure);
|
|
95
|
+
else throw failure;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
attach (next) {
|
|
101
|
+
handle = next;
|
|
102
|
+
},
|
|
103
|
+
assertInitialRender () {
|
|
104
|
+
if (failed) {
|
|
105
|
+
options?.onUncaughtError?.(failure);
|
|
106
|
+
throw failure;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function claimRoot(container) {
|
|
112
|
+
if (9 === container.nodeType) throw new Error('An Octane application requires a subtree root in its framework-owned document.');
|
|
113
|
+
if (roots.has(container)) throw new Error('An Octane application already owns this root container.');
|
|
114
|
+
const owner = Symbol('Octane root owner');
|
|
115
|
+
roots.set(container, owner);
|
|
116
|
+
return ()=>{
|
|
117
|
+
if (roots.get(container) === owner) roots.delete(container);
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function cleanupResources(cleanups) {
|
|
121
|
+
const errors = [];
|
|
122
|
+
for (const cleanup of cleanups)try {
|
|
123
|
+
cleanup();
|
|
124
|
+
} catch (error) {
|
|
125
|
+
errors.push(error);
|
|
126
|
+
}
|
|
127
|
+
if (errors.length) throw new AggregateError(errors, 'Octane application cleanup failed.');
|
|
128
|
+
}
|
|
129
|
+
function reportCleanupError(input, error) {
|
|
130
|
+
if (input.options?.onUncaughtError) input.options.onUncaughtError(error);
|
|
131
|
+
else queueMicrotask(()=>{
|
|
132
|
+
throw error;
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
function loadApplication(input, abandon) {
|
|
136
|
+
const acquire = (application)=>{
|
|
137
|
+
try {
|
|
138
|
+
validateModule(application);
|
|
139
|
+
} catch (error) {
|
|
140
|
+
if (application && 'function' == typeof application.dispose) retireAbandonedModule(application);
|
|
141
|
+
throw error;
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
application,
|
|
145
|
+
releaseModule: claimModuleResources(application)
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
const { signal } = input;
|
|
149
|
+
if (!signal) return input.load().then(acquire);
|
|
150
|
+
return new Promise((resolve, reject)=>{
|
|
151
|
+
let settled = false;
|
|
152
|
+
let abandoned = false;
|
|
153
|
+
const onAbort = ()=>{
|
|
154
|
+
if (settled) return;
|
|
155
|
+
settled = true;
|
|
156
|
+
abandoned = true;
|
|
157
|
+
signal.removeEventListener('abort', onAbort);
|
|
158
|
+
try {
|
|
159
|
+
abandon();
|
|
160
|
+
reject(signal.reason);
|
|
161
|
+
} catch (cleanupError) {
|
|
162
|
+
reject(new AggregateError([
|
|
163
|
+
signal.reason,
|
|
164
|
+
cleanupError
|
|
165
|
+
], 'Octane startup cancellation failed.'));
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
signal.addEventListener('abort', onAbort, {
|
|
169
|
+
once: true
|
|
170
|
+
});
|
|
171
|
+
if (signal.aborted) return void onAbort();
|
|
172
|
+
let loading;
|
|
173
|
+
try {
|
|
174
|
+
loading = input.load();
|
|
175
|
+
} catch (error) {
|
|
176
|
+
settled = true;
|
|
177
|
+
signal.removeEventListener('abort', onAbort);
|
|
178
|
+
reject(error);
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
loading.then((application)=>{
|
|
182
|
+
if (abandoned) return void queueMicrotask(()=>{
|
|
183
|
+
try {
|
|
184
|
+
retireAbandonedModule(application);
|
|
185
|
+
} catch (error) {
|
|
186
|
+
reportCleanupError(input, error);
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
settled = true;
|
|
190
|
+
signal.removeEventListener('abort', onAbort);
|
|
191
|
+
try {
|
|
192
|
+
resolve(acquire(application));
|
|
193
|
+
} catch (error) {
|
|
194
|
+
reject(error);
|
|
195
|
+
}
|
|
196
|
+
}, (error)=>{
|
|
197
|
+
if (settled) return;
|
|
198
|
+
settled = true;
|
|
199
|
+
signal.removeEventListener('abort', onAbort);
|
|
200
|
+
reject(error);
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
function validateModule(application) {
|
|
205
|
+
if (!application || 'function' != typeof application.default) throw new TypeError('An Octane application module must default-export a native component.');
|
|
206
|
+
if (void 0 !== application.dispose && 'function' != typeof application.dispose) throw new TypeError('An Octane application disposer must be a function.');
|
|
207
|
+
}
|
|
208
|
+
function createHandle(input) {
|
|
209
|
+
let releaseModule = input.releaseModule;
|
|
210
|
+
let disposed = false;
|
|
211
|
+
const handle = {
|
|
212
|
+
root: input.root,
|
|
213
|
+
identity: Object.freeze({
|
|
214
|
+
...input.identity
|
|
215
|
+
}),
|
|
216
|
+
update (next) {
|
|
217
|
+
if (disposed) throw new Error('Cannot update a disposed Octane application.');
|
|
218
|
+
validateModule(next);
|
|
219
|
+
const previousRelease = releaseModule;
|
|
220
|
+
const nextRelease = claimModuleResources(next);
|
|
221
|
+
releaseModule = nextRelease;
|
|
222
|
+
try {
|
|
223
|
+
input.federation ? input.root.render(external_federation_context_js_namespaceObject.FederationApplication, {
|
|
224
|
+
scope: input.federation,
|
|
225
|
+
application: next
|
|
226
|
+
}) : input.root.render(next.default, next.props);
|
|
227
|
+
previousRelease();
|
|
228
|
+
} catch (error) {
|
|
229
|
+
cleanupResources([
|
|
230
|
+
previousRelease,
|
|
231
|
+
()=>handle.dispose()
|
|
232
|
+
]);
|
|
233
|
+
throw error;
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
dispose () {
|
|
237
|
+
if (disposed) return;
|
|
238
|
+
disposed = true;
|
|
239
|
+
input.signal?.removeEventListener('abort', onAbort);
|
|
240
|
+
cleanupResources([
|
|
241
|
+
()=>input.root.unmount(),
|
|
242
|
+
()=>releaseModule(),
|
|
243
|
+
()=>input.bridge?.dispose(),
|
|
244
|
+
input.release
|
|
245
|
+
]);
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
function onAbort() {
|
|
249
|
+
queueMicrotask(()=>{
|
|
250
|
+
try {
|
|
251
|
+
handle.dispose();
|
|
252
|
+
} catch (error) {
|
|
253
|
+
input.onCleanupError?.(error);
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
input.signal?.addEventListener('abort', onAbort, {
|
|
258
|
+
once: true
|
|
259
|
+
});
|
|
260
|
+
return handle;
|
|
261
|
+
}
|
|
262
|
+
async function startApplication(input, release, hydration) {
|
|
263
|
+
const errors = observeRootErrors(input.options);
|
|
264
|
+
let bridge;
|
|
265
|
+
let root;
|
|
266
|
+
let releaseModule;
|
|
267
|
+
let handle;
|
|
268
|
+
let cleaned = false;
|
|
269
|
+
const cleanup = ()=>{
|
|
270
|
+
if (handle) return void handle.dispose();
|
|
271
|
+
if (cleaned) return;
|
|
272
|
+
cleaned = true;
|
|
273
|
+
cleanupResources([
|
|
274
|
+
()=>root?.unmount(),
|
|
275
|
+
()=>releaseModule?.(),
|
|
276
|
+
()=>bridge?.dispose(),
|
|
277
|
+
release
|
|
278
|
+
]);
|
|
279
|
+
};
|
|
280
|
+
try {
|
|
281
|
+
const federation = input.federation ? (0, external_federation_context_js_namespaceObject.createFederationScope)(input.federation, false) : void 0;
|
|
282
|
+
if (hydration) {
|
|
283
|
+
const { document, documentId } = hydration;
|
|
284
|
+
bridge = (0, streamed_signals_namespaceObject.bootstrapStreamedSignalHydration)({
|
|
285
|
+
buildId: input.nativeHydrationBuildId,
|
|
286
|
+
documentId,
|
|
287
|
+
...null === document.defaultView ? {} : {
|
|
288
|
+
target: document.defaultView
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
const loaded = await loadApplication(input, cleanup);
|
|
293
|
+
const application = loaded.application;
|
|
294
|
+
releaseModule = loaded.releaseModule;
|
|
295
|
+
input.signal?.throwIfAborted();
|
|
296
|
+
if (bridge) root = (0, external_octane_namespaceObject.hydrateRoot)(input.container, federation ? external_federation_context_js_namespaceObject.FederationApplication : application.default, federation ? {
|
|
297
|
+
scope: federation,
|
|
298
|
+
application
|
|
299
|
+
} : application.props, {
|
|
300
|
+
...errors.options,
|
|
301
|
+
signalOwner: bridge.signalOwner
|
|
302
|
+
});
|
|
303
|
+
else {
|
|
304
|
+
root = (0, external_octane_namespaceObject.createRoot)(input.container, errors.options);
|
|
305
|
+
federation ? root.render(external_federation_context_js_namespaceObject.FederationApplication, {
|
|
306
|
+
scope: federation,
|
|
307
|
+
application
|
|
308
|
+
}) : root.render(application.default, application.props);
|
|
309
|
+
}
|
|
310
|
+
errors.assertInitialRender();
|
|
311
|
+
input.signal?.throwIfAborted();
|
|
312
|
+
handle = createHandle({
|
|
313
|
+
root,
|
|
314
|
+
identity: input.identity,
|
|
315
|
+
releaseModule,
|
|
316
|
+
release,
|
|
317
|
+
bridge,
|
|
318
|
+
federation,
|
|
319
|
+
...void 0 === input.signal ? {} : {
|
|
320
|
+
signal: input.signal
|
|
321
|
+
},
|
|
322
|
+
onCleanupError: (error)=>reportCleanupError(input, error)
|
|
323
|
+
});
|
|
324
|
+
errors.attach(handle);
|
|
325
|
+
return handle;
|
|
326
|
+
} catch (error) {
|
|
327
|
+
cleanup();
|
|
328
|
+
throw error;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
async function mountOctaneApplication(input) {
|
|
332
|
+
(0, external_bootstrap_js_namespaceObject.assertOctaneIdentity)(input.identity);
|
|
333
|
+
(0, external_bootstrap_js_namespaceObject.assertNativeHydrationBuildId)(input.nativeHydrationBuildId);
|
|
334
|
+
input.signal?.throwIfAborted();
|
|
335
|
+
return startApplication(input, claimRoot(input.container));
|
|
336
|
+
}
|
|
337
|
+
async function hydrateOctaneApplication(input) {
|
|
338
|
+
(0, external_bootstrap_js_namespaceObject.assertOctaneIdentity)(input.identity);
|
|
339
|
+
(0, external_bootstrap_js_namespaceObject.assertNativeHydrationBuildId)(input.nativeHydrationBuildId);
|
|
340
|
+
(0, external_bootstrap_js_namespaceObject.assertNativeHydrationBuildId)(input.documentNativeHydrationBuildId);
|
|
341
|
+
if (input.nativeHydrationBuildId !== input.documentNativeHydrationBuildId) throw new Error('Octane hydration bytes belong to a different native client compilation.');
|
|
342
|
+
(0, identity_namespaceObject.assertRendererIdentity)(input.documentIdentity, input.identity);
|
|
343
|
+
input.signal?.throwIfAborted();
|
|
344
|
+
if ('string' != typeof input.documentId || 0 === input.documentId.trim().length) throw new Error('Octane hydration requires a nonempty document identity.');
|
|
345
|
+
const document = input.container.ownerDocument;
|
|
346
|
+
if (!document) throw new Error('An Octane hydration root requires a document.');
|
|
347
|
+
if (document !== globalThis.document) throw new Error('Octane hydration requires a root in the active browser document.');
|
|
348
|
+
if (documents.has(document)) throw new Error('An Octane signal bridge already owns this document.');
|
|
349
|
+
const releaseRoot = claimRoot(input.container);
|
|
350
|
+
const documentOwner = Symbol(input.documentId);
|
|
351
|
+
documents.set(document, documentOwner);
|
|
352
|
+
const release = ()=>{
|
|
353
|
+
releaseRoot();
|
|
354
|
+
if (documents.get(document) === documentOwner) documents.delete(document);
|
|
355
|
+
};
|
|
356
|
+
return startApplication(input, release, {
|
|
357
|
+
document,
|
|
358
|
+
documentId: input.documentId
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
exports.hydrateOctaneApplication = __webpack_exports__.hydrateOctaneApplication;
|
|
362
|
+
exports.mountOctaneApplication = __webpack_exports__.mountOctaneApplication;
|
|
363
|
+
exports.readOctaneDocumentBootstrap = __webpack_exports__.readOctaneDocumentBootstrap;
|
|
364
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
365
|
+
"hydrateOctaneApplication",
|
|
366
|
+
"mountOctaneApplication",
|
|
367
|
+
"readOctaneDocumentBootstrap"
|
|
368
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
369
|
+
Object.defineProperty(exports, '__esModule', {
|
|
370
|
+
value: true
|
|
371
|
+
});
|
|
@@ -0,0 +1,83 @@
|
|
|
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
|
+
componentView: ()=>componentView,
|
|
32
|
+
localizedRouterRoot: ()=>localizedRouterRoot,
|
|
33
|
+
octaneRouterFactory: ()=>octaneRouterFactory
|
|
34
|
+
});
|
|
35
|
+
const tanstack_router_namespaceObject = require("@octanejs/tanstack-router");
|
|
36
|
+
const external_octane_namespaceObject = require("octane");
|
|
37
|
+
const I18nProvider_js_namespaceObject = require("./i18n/I18nProvider.js");
|
|
38
|
+
const external_routes_js_namespaceObject = require("./routes.js");
|
|
39
|
+
function componentView(component, i18n) {
|
|
40
|
+
const App = component;
|
|
41
|
+
if (!i18n) return App;
|
|
42
|
+
return ()=>(0, external_octane_namespaceObject.createElement)(I18nProvider_js_namespaceObject.I18nProvider, {
|
|
43
|
+
instance: i18n.instance,
|
|
44
|
+
languages: i18n.languages,
|
|
45
|
+
localisedUrls: i18n.localisedUrls,
|
|
46
|
+
children: (0, external_octane_namespaceObject.createElement)(App)
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
const octaneRouterFactory = {
|
|
50
|
+
routeTree: (routes, modules, options)=>(0, external_routes_js_namespaceObject.createFileSystemRouteTree)(routes, modules, options),
|
|
51
|
+
router: ({ location, ...options })=>(0, tanstack_router_namespaceObject.createRouter)({
|
|
52
|
+
...options,
|
|
53
|
+
...location ? {
|
|
54
|
+
origin: location.origin,
|
|
55
|
+
history: (0, tanstack_router_namespaceObject.createMemoryHistory)({
|
|
56
|
+
initialEntries: [
|
|
57
|
+
location.href
|
|
58
|
+
]
|
|
59
|
+
})
|
|
60
|
+
} : {}
|
|
61
|
+
})
|
|
62
|
+
};
|
|
63
|
+
function localizedRouterRoot(Root) {
|
|
64
|
+
return ({ router, i18n })=>(0, external_octane_namespaceObject.createElement)(I18nProvider_js_namespaceObject.I18nProvider, {
|
|
65
|
+
instance: i18n.instance,
|
|
66
|
+
languages: i18n.languages,
|
|
67
|
+
localisedUrls: i18n.localisedUrls,
|
|
68
|
+
children: (0, external_octane_namespaceObject.createElement)(Root, {
|
|
69
|
+
router
|
|
70
|
+
})
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
exports.componentView = __webpack_exports__.componentView;
|
|
74
|
+
exports.localizedRouterRoot = __webpack_exports__.localizedRouterRoot;
|
|
75
|
+
exports.octaneRouterFactory = __webpack_exports__.octaneRouterFactory;
|
|
76
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
77
|
+
"componentView",
|
|
78
|
+
"localizedRouterRoot",
|
|
79
|
+
"octaneRouterFactory"
|
|
80
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
81
|
+
Object.defineProperty(exports, '__esModule', {
|
|
82
|
+
value: true
|
|
83
|
+
});
|
|
@@ -0,0 +1,92 @@
|
|
|
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
|
+
startNativeClient: ()=>startNativeClient
|
|
32
|
+
});
|
|
33
|
+
const entry_client_namespaceObject = require("@modern-js/renderer-core/entry-client");
|
|
34
|
+
const router_namespaceObject = require("@modern-js/renderer-core/router");
|
|
35
|
+
const external_client_js_namespaceObject = require("./client.js");
|
|
36
|
+
const external_entry_application_js_namespaceObject = require("./entry-application.js");
|
|
37
|
+
const external_router_client_js_namespaceObject = require("./router-client.js");
|
|
38
|
+
const LocalizedRouterRoot = (0, external_entry_application_js_namespaceObject.localizedRouterRoot)(external_router_client_js_namespaceObject.OctaneRouterRoot);
|
|
39
|
+
function startNativeClient(options) {
|
|
40
|
+
const { nativeHydrationBuildId } = options;
|
|
41
|
+
(0, entry_client_namespaceObject.startNativeClientEntry)(options, {
|
|
42
|
+
readBootstrap: (document, identity)=>(0, external_client_js_namespaceObject.readOctaneDocumentBootstrap)(document, identity, nativeHydrationBuildId),
|
|
43
|
+
createRouter: (application, routerOptions)=>(0, router_namespaceObject.createNativeRouter)(application, routerOptions, external_entry_application_js_namespaceObject.octaneRouterFactory),
|
|
44
|
+
async prepareRouter (router, hydrating, signal) {
|
|
45
|
+
if (hydrating) await (0, external_router_client_js_namespaceObject.prepareOctaneRouterHydration)(router, {
|
|
46
|
+
signal
|
|
47
|
+
});
|
|
48
|
+
else await router.load();
|
|
49
|
+
},
|
|
50
|
+
async start ({ root, identity, bootstrap, signal, load }) {
|
|
51
|
+
const application = {
|
|
52
|
+
container: root,
|
|
53
|
+
identity,
|
|
54
|
+
nativeHydrationBuildId,
|
|
55
|
+
federation: options.federation,
|
|
56
|
+
signal,
|
|
57
|
+
load: async ()=>{
|
|
58
|
+
const view = await load();
|
|
59
|
+
if ('component' === view.kind) return {
|
|
60
|
+
default: (0, external_entry_application_js_namespaceObject.componentView)(view.component, view.i18n)
|
|
61
|
+
};
|
|
62
|
+
return view.i18n ? {
|
|
63
|
+
default: LocalizedRouterRoot,
|
|
64
|
+
props: {
|
|
65
|
+
router: view.router,
|
|
66
|
+
i18n: view.i18n
|
|
67
|
+
}
|
|
68
|
+
} : {
|
|
69
|
+
default: external_router_client_js_namespaceObject.OctaneRouterRoot,
|
|
70
|
+
props: {
|
|
71
|
+
router: view.router
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
const handle = bootstrap?.hydrating ? await (0, external_client_js_namespaceObject.hydrateOctaneApplication)({
|
|
77
|
+
...application,
|
|
78
|
+
documentIdentity: bootstrap.identity,
|
|
79
|
+
documentId: bootstrap.documentId,
|
|
80
|
+
documentNativeHydrationBuildId: bootstrap.nativeHydrationBuildId
|
|
81
|
+
}) : await (0, external_client_js_namespaceObject.mountOctaneApplication)(application);
|
|
82
|
+
return ()=>handle.dispose();
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
exports.startNativeClient = __webpack_exports__.startNativeClient;
|
|
87
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
88
|
+
"startNativeClient"
|
|
89
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
90
|
+
Object.defineProperty(exports, '__esModule', {
|
|
91
|
+
value: true
|
|
92
|
+
});
|