@bleedingdev/modern-js-renderer-octane 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/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 +211 -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
|
@@ -0,0 +1,99 @@
|
|
|
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
|
+
useLatestLanguageSync: ()=>useLatestLanguageSync
|
|
32
|
+
});
|
|
33
|
+
const controller_namespaceObject = require("@modern-js/i18n-runtime-extensions/language-sync/controller");
|
|
34
|
+
const external_octane_namespaceObject = require("octane");
|
|
35
|
+
const bindingSlot = Symbol((0, external_octane_namespaceObject.hookSlots)(1));
|
|
36
|
+
const callbacksSlot = Symbol((0, external_octane_namespaceObject.hookSlots)(1));
|
|
37
|
+
const activationSlot = Symbol((0, external_octane_namespaceObject.hookSlots)(1));
|
|
38
|
+
const requestSlot = Symbol((0, external_octane_namespaceObject.hookSlots)(1));
|
|
39
|
+
const retrySlot = Symbol((0, external_octane_namespaceObject.hookSlots)(1));
|
|
40
|
+
const requestCallbackSlot = Symbol((0, external_octane_namespaceObject.hookSlots)(1));
|
|
41
|
+
const useLatestLanguageSync = ({ changeLanguage, commitLanguage, desiredLanguage, enabled = true, policy, readLanguage, reportFailure, target })=>{
|
|
42
|
+
const bindingRef = (0, external_octane_namespaceObject.useRef)(null, bindingSlot);
|
|
43
|
+
if (null === bindingRef.current) bindingRef.current = (0, controller_namespaceObject.createLatestLanguageSyncBinding)(policy);
|
|
44
|
+
const binding = bindingRef.current;
|
|
45
|
+
(0, external_octane_namespaceObject.useEffect)(()=>{
|
|
46
|
+
binding.updateCallbacks({
|
|
47
|
+
changeLanguage,
|
|
48
|
+
commitLanguage,
|
|
49
|
+
readLanguage,
|
|
50
|
+
reportFailure
|
|
51
|
+
});
|
|
52
|
+
}, void 0, callbacksSlot);
|
|
53
|
+
(0, external_octane_namespaceObject.useEffect)(()=>{
|
|
54
|
+
if (!enabled || !target) return;
|
|
55
|
+
binding.activate(target);
|
|
56
|
+
return ()=>binding.deactivate();
|
|
57
|
+
}, [
|
|
58
|
+
binding,
|
|
59
|
+
enabled,
|
|
60
|
+
target
|
|
61
|
+
], activationSlot);
|
|
62
|
+
(0, external_octane_namespaceObject.useEffect)(()=>{
|
|
63
|
+
if (!enabled || !target || !desiredLanguage) return void binding.clearRequest();
|
|
64
|
+
binding.request(desiredLanguage);
|
|
65
|
+
}, [
|
|
66
|
+
binding,
|
|
67
|
+
desiredLanguage,
|
|
68
|
+
enabled,
|
|
69
|
+
target
|
|
70
|
+
], requestSlot);
|
|
71
|
+
(0, external_octane_namespaceObject.useEffect)(()=>{
|
|
72
|
+
if (!enabled || !target || !desiredLanguage || "u" < typeof window) return;
|
|
73
|
+
const retryCurrentIntent = ()=>binding.request(desiredLanguage);
|
|
74
|
+
const retryVisibleIntent = ()=>{
|
|
75
|
+
if ('visible' === document.visibilityState) retryCurrentIntent();
|
|
76
|
+
};
|
|
77
|
+
window.addEventListener('online', retryCurrentIntent);
|
|
78
|
+
document.addEventListener('visibilitychange', retryVisibleIntent);
|
|
79
|
+
return ()=>{
|
|
80
|
+
window.removeEventListener('online', retryCurrentIntent);
|
|
81
|
+
document.removeEventListener('visibilitychange', retryVisibleIntent);
|
|
82
|
+
};
|
|
83
|
+
}, [
|
|
84
|
+
binding,
|
|
85
|
+
desiredLanguage,
|
|
86
|
+
enabled,
|
|
87
|
+
target
|
|
88
|
+
], retrySlot);
|
|
89
|
+
return (0, external_octane_namespaceObject.useCallback)((language)=>binding.request(language), [
|
|
90
|
+
binding
|
|
91
|
+
], requestCallbackSlot);
|
|
92
|
+
};
|
|
93
|
+
exports.useLatestLanguageSync = __webpack_exports__.useLatestLanguageSync;
|
|
94
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
95
|
+
"useLatestLanguageSync"
|
|
96
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
97
|
+
Object.defineProperty(exports, '__esModule', {
|
|
98
|
+
value: true
|
|
99
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.r = (exports1)=>{
|
|
5
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
6
|
+
value: 'Module'
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
9
|
+
value: true
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
})();
|
|
13
|
+
var __webpack_exports__ = {};
|
|
14
|
+
__webpack_require__.r(__webpack_exports__);
|
|
15
|
+
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
16
|
+
Object.defineProperty(exports, '__esModule', {
|
|
17
|
+
value: true
|
|
18
|
+
});
|
|
@@ -0,0 +1,110 @@
|
|
|
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
|
+
useI18n: ()=>useI18n
|
|
32
|
+
});
|
|
33
|
+
const paths_namespaceObject = require("@modern-js/i18n-runtime-extensions/paths");
|
|
34
|
+
const request_language_namespaceObject = require("@modern-js/i18n-runtime-extensions/request-language");
|
|
35
|
+
const external_octane_namespaceObject = require("octane");
|
|
36
|
+
const external_router_js_namespaceObject = require("../router.js");
|
|
37
|
+
const external_context_js_namespaceObject = require("./context.js");
|
|
38
|
+
const languageSwitches = new WeakMap();
|
|
39
|
+
function useI18n() {
|
|
40
|
+
const context = (0, external_octane_namespaceObject.useContext)(external_context_js_namespaceObject.I18nContext);
|
|
41
|
+
if (!context) throw new Error('[renderer-octane] useI18n() was called outside of an I18nProvider.');
|
|
42
|
+
const { instance, languages, localisedUrls, language } = context;
|
|
43
|
+
const t = (key, options)=>instance.t(key, options);
|
|
44
|
+
const router = (0, external_router_js_namespaceObject.useRouter)({
|
|
45
|
+
warn: false
|
|
46
|
+
});
|
|
47
|
+
const changeLanguage = (requested)=>{
|
|
48
|
+
let nextLanguage;
|
|
49
|
+
try {
|
|
50
|
+
nextLanguage = (0, paths_namespaceObject.configuredLanguage)(requested, languages);
|
|
51
|
+
} catch (error) {
|
|
52
|
+
return Promise.reject(error);
|
|
53
|
+
}
|
|
54
|
+
const state = languageSwitches.get(instance) ?? {
|
|
55
|
+
latest: 0,
|
|
56
|
+
queue: Promise.resolve()
|
|
57
|
+
};
|
|
58
|
+
languageSwitches.set(instance, state);
|
|
59
|
+
const generation = ++state.latest;
|
|
60
|
+
const run = state.queue.then(async ()=>{
|
|
61
|
+
if (state.latest !== generation) return;
|
|
62
|
+
const committed = instance.language;
|
|
63
|
+
const publicLanguage = ()=>router ? (0, request_language_namespaceObject.languageFromPathname)(new URL(router.state.location.publicHref, 'http://localhost').pathname, languages, router.options.basepath) : void 0;
|
|
64
|
+
const reconcile = async ()=>{
|
|
65
|
+
const language = publicLanguage() ?? committed;
|
|
66
|
+
if (instance.language !== language) await instance.changeLanguage?.(language);
|
|
67
|
+
};
|
|
68
|
+
try {
|
|
69
|
+
await instance.changeLanguage?.(nextLanguage);
|
|
70
|
+
} catch (error) {
|
|
71
|
+
await reconcile();
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
74
|
+
if (!router) return;
|
|
75
|
+
const href = (0, paths_namespaceObject.localizePath)(router.state.location.href, nextLanguage, {
|
|
76
|
+
languages: [
|
|
77
|
+
...languages
|
|
78
|
+
],
|
|
79
|
+
localisedUrls
|
|
80
|
+
});
|
|
81
|
+
try {
|
|
82
|
+
await router.navigate({
|
|
83
|
+
to: '.',
|
|
84
|
+
href,
|
|
85
|
+
replace: true
|
|
86
|
+
});
|
|
87
|
+
} catch (error) {
|
|
88
|
+
await reconcile();
|
|
89
|
+
throw error;
|
|
90
|
+
}
|
|
91
|
+
if (publicLanguage() !== nextLanguage) await reconcile();
|
|
92
|
+
});
|
|
93
|
+
state.queue = run.catch(()=>{});
|
|
94
|
+
return run;
|
|
95
|
+
};
|
|
96
|
+
return {
|
|
97
|
+
t,
|
|
98
|
+
language,
|
|
99
|
+
languages,
|
|
100
|
+
instance,
|
|
101
|
+
changeLanguage
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
exports.useI18n = __webpack_exports__.useI18n;
|
|
105
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
106
|
+
"useI18n"
|
|
107
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
108
|
+
Object.defineProperty(exports, '__esModule', {
|
|
109
|
+
value: true
|
|
110
|
+
});
|
|
@@ -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
|
+
const OCTANE_RUNTIME_PROFILE = Object.freeze({
|
|
31
|
+
renderer: 'octane',
|
|
32
|
+
runtime: '0.7.1+ultramodern.1331985ea3b0',
|
|
33
|
+
router: '0.1.60+ultramodern.0b9f76ee3003',
|
|
34
|
+
routerCore: '1.171.15',
|
|
35
|
+
history: '1.162.0'
|
|
36
|
+
});
|
|
37
|
+
__webpack_require__.d(__webpack_exports__, {}, {
|
|
38
|
+
OCTANE_RUNTIME_PROFILE: OCTANE_RUNTIME_PROFILE
|
|
39
|
+
});
|
|
40
|
+
exports.OCTANE_RUNTIME_PROFILE = __webpack_exports__.OCTANE_RUNTIME_PROFILE;
|
|
41
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
42
|
+
"OCTANE_RUNTIME_PROFILE"
|
|
43
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
44
|
+
Object.defineProperty(exports, '__esModule', {
|
|
45
|
+
value: true
|
|
46
|
+
});
|
|
@@ -0,0 +1,167 @@
|
|
|
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
|
+
OCTANE_COMPILER_VERSION: ()=>OCTANE_COMPILER_VERSION,
|
|
32
|
+
OCTANE_RUNTIME_VERSION: ()=>OCTANE_RUNTIME_VERSION,
|
|
33
|
+
compilerArtifacts: ()=>compilerArtifacts,
|
|
34
|
+
octaneModuleManifestFileName: ()=>octaneModuleManifestFileName,
|
|
35
|
+
validateOctaneModuleManifest: ()=>validateOctaneModuleManifest
|
|
36
|
+
});
|
|
37
|
+
const identity_namespaceObject = require("@modern-js/renderer-core/identity");
|
|
38
|
+
const external_bootstrap_js_namespaceObject = require("./bootstrap.js");
|
|
39
|
+
const OCTANE_RUNTIME_VERSION = '0.7.1+ultramodern.1331985ea3b0';
|
|
40
|
+
const OCTANE_COMPILER_VERSION = '0.1.55';
|
|
41
|
+
function octaneModuleManifestFileName(entryName) {
|
|
42
|
+
return (0, identity_namespaceObject.nativeModuleManifestFilename)('octane', entryName);
|
|
43
|
+
}
|
|
44
|
+
function record(value, fields) {
|
|
45
|
+
if (!value || 'object' != typeof value || Array.isArray(value)) throw new Error('Malformed Octane compiler manifest object.');
|
|
46
|
+
if (Object.keys(value).some((key)=>!fields.includes(key))) throw new Error('Octane compiler manifest contains an unknown field.');
|
|
47
|
+
return value;
|
|
48
|
+
}
|
|
49
|
+
function digest(value) {
|
|
50
|
+
return 'string' == typeof value && /^[a-f\d]{64}$/u.test(value);
|
|
51
|
+
}
|
|
52
|
+
function nonempty(value) {
|
|
53
|
+
return 'string' == typeof value && value.trim().length > 0 && !value.includes('\0');
|
|
54
|
+
}
|
|
55
|
+
function assetPath(value) {
|
|
56
|
+
return nonempty(value) && value.endsWith('.js') && !value.startsWith('/') && !value.includes('\\') && !value.split('/').some((part)=>'..' === part || '.' === part || !part);
|
|
57
|
+
}
|
|
58
|
+
const validatedManifests = new WeakMap();
|
|
59
|
+
function validateOctaneModuleManifest(value, expectedIdentity, expectedNativeHydrationBuildId) {
|
|
60
|
+
(0, external_bootstrap_js_namespaceObject.assertOctaneIdentity)(expectedIdentity);
|
|
61
|
+
const cached = value && 'object' == typeof value ? validatedManifests.get(value) : void 0;
|
|
62
|
+
const manifest = cached ?? readOctaneModuleManifest(value);
|
|
63
|
+
(0, identity_namespaceObject.readRendererIdentity)(manifest.rendererIdentity, expectedIdentity);
|
|
64
|
+
if (void 0 !== expectedNativeHydrationBuildId) {
|
|
65
|
+
(0, external_bootstrap_js_namespaceObject.assertNativeHydrationBuildId)(expectedNativeHydrationBuildId);
|
|
66
|
+
if (manifest.nativeHydrationBuildId !== expectedNativeHydrationBuildId) throw new Error('Octane native hydration build differs from the compiled client.');
|
|
67
|
+
}
|
|
68
|
+
if (!cached) {
|
|
69
|
+
validatedManifests.set(value, manifest);
|
|
70
|
+
validatedManifests.set(manifest, manifest);
|
|
71
|
+
}
|
|
72
|
+
return manifest;
|
|
73
|
+
}
|
|
74
|
+
function readOctaneModuleManifest(value) {
|
|
75
|
+
const manifest = record(value, [
|
|
76
|
+
'schemaVersion',
|
|
77
|
+
'renderer',
|
|
78
|
+
'runtimeVersion',
|
|
79
|
+
'compilerVersion',
|
|
80
|
+
'rendererIdentity',
|
|
81
|
+
'nativeHydrationBuildId',
|
|
82
|
+
'sourceModules',
|
|
83
|
+
'assets'
|
|
84
|
+
]);
|
|
85
|
+
if (1 !== manifest.schemaVersion || 'octane' !== manifest.renderer || manifest.runtimeVersion !== OCTANE_RUNTIME_VERSION || manifest.compilerVersion !== OCTANE_COMPILER_VERSION) throw new Error('Octane compiler manifest ABI conflicts with the application.');
|
|
86
|
+
const rendererIdentity = (0, identity_namespaceObject.readRendererIdentity)(manifest.rendererIdentity, manifest.rendererIdentity);
|
|
87
|
+
const nativeHydrationBuildId = manifest.nativeHydrationBuildId;
|
|
88
|
+
(0, external_bootstrap_js_namespaceObject.assertNativeHydrationBuildId)(nativeHydrationBuildId);
|
|
89
|
+
if (!Array.isArray(manifest.assets) || !manifest.assets.length) throw new Error('Octane compiler manifest has no emitted JavaScript closure.');
|
|
90
|
+
const assetNames = new Set();
|
|
91
|
+
const assets = manifest.assets.map((value)=>{
|
|
92
|
+
const asset = record(value, [
|
|
93
|
+
'file',
|
|
94
|
+
'sha256'
|
|
95
|
+
]);
|
|
96
|
+
if (!assetPath(asset.file) || !digest(asset.sha256) || assetNames.has(asset.file)) throw new Error('Invalid Octane emitted asset digest.');
|
|
97
|
+
assetNames.add(asset.file);
|
|
98
|
+
return Object.freeze({
|
|
99
|
+
file: asset.file,
|
|
100
|
+
sha256: asset.sha256
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
if (!Array.isArray(manifest.sourceModules) || !manifest.sourceModules.length) throw new Error('Octane compiler manifest has no authenticated native sources.');
|
|
104
|
+
const resources = new Set();
|
|
105
|
+
const sourceModules = manifest.sourceModules.map((value)=>{
|
|
106
|
+
const source = record(value, [
|
|
107
|
+
'resource',
|
|
108
|
+
'canonicalId',
|
|
109
|
+
'moduleId',
|
|
110
|
+
'transformKind',
|
|
111
|
+
'emittedSourceSha256',
|
|
112
|
+
'assets'
|
|
113
|
+
]);
|
|
114
|
+
if (!nonempty(source.resource) || source.resource.startsWith('/') || source.resource.includes('\\') || !nonempty(source.canonicalId) || !('string' == typeof source.moduleId && nonempty(source.moduleId) || 'number' == typeof source.moduleId && Number.isFinite(source.moduleId)) || !('compile' === source.transformKind || 'slots' === source.transformKind || 'client-only-stub' === source.transformKind) || !digest(source.emittedSourceSha256) || !Array.isArray(source.assets) || !source.assets.length || source.assets.some((file)=>'string' != typeof file || !assetNames.has(file)) || new Set(source.assets).size !== source.assets.length || resources.has(source.resource)) throw new Error('Invalid Octane native source-to-asset provenance.');
|
|
115
|
+
resources.add(source.resource);
|
|
116
|
+
return Object.freeze({
|
|
117
|
+
resource: source.resource,
|
|
118
|
+
canonicalId: source.canonicalId,
|
|
119
|
+
moduleId: source.moduleId,
|
|
120
|
+
transformKind: source.transformKind,
|
|
121
|
+
emittedSourceSha256: source.emittedSourceSha256,
|
|
122
|
+
assets: Object.freeze([
|
|
123
|
+
...source.assets
|
|
124
|
+
])
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
return Object.freeze({
|
|
128
|
+
schemaVersion: 1,
|
|
129
|
+
renderer: 'octane',
|
|
130
|
+
runtimeVersion: OCTANE_RUNTIME_VERSION,
|
|
131
|
+
compilerVersion: OCTANE_COMPILER_VERSION,
|
|
132
|
+
rendererIdentity,
|
|
133
|
+
nativeHydrationBuildId,
|
|
134
|
+
sourceModules: Object.freeze(sourceModules),
|
|
135
|
+
assets: Object.freeze(assets)
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
const compilerArtifacts = {
|
|
139
|
+
clientManifestFile: octaneModuleManifestFileName,
|
|
140
|
+
async validateClientManifest (value, identity, context) {
|
|
141
|
+
const hydrationBuildId = context.compilationHash ?? context.hydrationBuildId;
|
|
142
|
+
if (context.development && ('string' != typeof hydrationBuildId || !hydrationBuildId.trim())) throw new Error('Octane development snapshot has no native hydration build.');
|
|
143
|
+
const nativeManifest = validateOctaneModuleManifest(value, identity, hydrationBuildId);
|
|
144
|
+
return {
|
|
145
|
+
nativeManifest,
|
|
146
|
+
hydrationBuildId: nativeManifest.nativeHydrationBuildId
|
|
147
|
+
};
|
|
148
|
+
},
|
|
149
|
+
isMutableDevelopmentAsset (filename, entryNames) {
|
|
150
|
+
return 'octane-client-build.json' === filename || entryNames.some((entry)=>filename === octaneModuleManifestFileName(entry));
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
exports.OCTANE_COMPILER_VERSION = __webpack_exports__.OCTANE_COMPILER_VERSION;
|
|
154
|
+
exports.OCTANE_RUNTIME_VERSION = __webpack_exports__.OCTANE_RUNTIME_VERSION;
|
|
155
|
+
exports.compilerArtifacts = __webpack_exports__.compilerArtifacts;
|
|
156
|
+
exports.octaneModuleManifestFileName = __webpack_exports__.octaneModuleManifestFileName;
|
|
157
|
+
exports.validateOctaneModuleManifest = __webpack_exports__.validateOctaneModuleManifest;
|
|
158
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
159
|
+
"OCTANE_COMPILER_VERSION",
|
|
160
|
+
"OCTANE_RUNTIME_VERSION",
|
|
161
|
+
"compilerArtifacts",
|
|
162
|
+
"octaneModuleManifestFileName",
|
|
163
|
+
"validateOctaneModuleManifest"
|
|
164
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
165
|
+
Object.defineProperty(exports, '__esModule', {
|
|
166
|
+
value: true
|
|
167
|
+
});
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const __rslib_import_meta_url__ = /*#__PURE__*/ function() {
|
|
3
|
+
return "u" < typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
|
|
4
|
+
}();
|
|
5
|
+
var __webpack_require__ = {};
|
|
6
|
+
(()=>{
|
|
7
|
+
__webpack_require__.n = (module)=>{
|
|
8
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
9
|
+
__webpack_require__.d(getter, {
|
|
10
|
+
a: getter
|
|
11
|
+
});
|
|
12
|
+
return getter;
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
17
|
+
var define = (defs, kind)=>{
|
|
18
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
[kind]: defs[key]
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
define(getters, "get");
|
|
24
|
+
define(values, "value");
|
|
25
|
+
};
|
|
26
|
+
})();
|
|
27
|
+
(()=>{
|
|
28
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
29
|
+
})();
|
|
30
|
+
(()=>{
|
|
31
|
+
__webpack_require__.r = (exports1)=>{
|
|
32
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
33
|
+
value: 'Module'
|
|
34
|
+
});
|
|
35
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
36
|
+
value: true
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
})();
|
|
40
|
+
var __webpack_exports__ = {};
|
|
41
|
+
__webpack_require__.r(__webpack_exports__);
|
|
42
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
43
|
+
createOctaneCompilerPlugin: ()=>createOctaneCompilerPlugin,
|
|
44
|
+
pluginSourceDirectory: ()=>pluginSourceDirectory
|
|
45
|
+
});
|
|
46
|
+
const external_node_fs_namespaceObject = require("node:fs");
|
|
47
|
+
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
48
|
+
const external_node_module_namespaceObject = require("node:module");
|
|
49
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
50
|
+
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
51
|
+
const external_node_url_namespaceObject = require("node:url");
|
|
52
|
+
const external_manifest_js_namespaceObject = require("../manifest.js");
|
|
53
|
+
function pluginSourceDirectory() {
|
|
54
|
+
let directory = external_node_path_default().dirname((0, external_node_url_namespaceObject.fileURLToPath)(__rslib_import_meta_url__));
|
|
55
|
+
while(true){
|
|
56
|
+
const compiler = external_node_path_default().join(directory, 'src/plugin');
|
|
57
|
+
if (external_node_fs_default().existsSync(external_node_path_default().join(directory, 'package.json')) && external_node_fs_default().existsSync(external_node_path_default().join(compiler, 'compiler-manifest.cjs'))) return compiler;
|
|
58
|
+
const parent = external_node_path_default().dirname(directory);
|
|
59
|
+
if (parent === directory) throw new Error('Cannot locate the UltraModern Octane compiler package.');
|
|
60
|
+
directory = parent;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function createOctaneCompilerPlugin(options) {
|
|
64
|
+
return {
|
|
65
|
+
name: 'ultramodern:octane:compiler',
|
|
66
|
+
setup (api) {
|
|
67
|
+
const directory = pluginSourceDirectory();
|
|
68
|
+
const require1 = (0, external_node_module_namespaceObject.createRequire)(external_node_path_default().join(directory, 'index.cjs'));
|
|
69
|
+
const { OctaneCompilerManifestPlugin } = require1('./compiler-manifest.cjs');
|
|
70
|
+
const { inferRspackEnvironment, OctaneRspackPlugin } = require1('@octanejs/rspack-plugin');
|
|
71
|
+
api.modifyRsbuildConfig((config, { mergeRsbuildConfig })=>mergeRsbuildConfig(config, {
|
|
72
|
+
source: {
|
|
73
|
+
include: [
|
|
74
|
+
/[/\\]@octanejs[/\\]/u
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
}));
|
|
78
|
+
api.modifyRspackConfig((config, { environment: rsbuildEnvironment })=>{
|
|
79
|
+
const environment = rsbuildEnvironment.name === options.workerEnvironmentName ? 'server' : inferRspackEnvironment(config.target);
|
|
80
|
+
config.resolve ??= {};
|
|
81
|
+
const extensions = (config.resolve.extensions ?? []).filter((extension)=>'.tsrx' !== extension);
|
|
82
|
+
extensions.splice(Math.max(extensions.indexOf('.ts'), extensions.indexOf('.tsx')) + 1, 0, '.tsrx');
|
|
83
|
+
config.resolve.extensions = extensions;
|
|
84
|
+
config.plugins ??= [];
|
|
85
|
+
config.plugins.push(new OctaneRspackPlugin({
|
|
86
|
+
root: api.context.rootPath,
|
|
87
|
+
environment,
|
|
88
|
+
transpile: false
|
|
89
|
+
}));
|
|
90
|
+
config.plugins.push(new OctaneCompilerManifestPlugin({
|
|
91
|
+
emitClientManifest: 'client' === environment,
|
|
92
|
+
root: api.context.rootPath,
|
|
93
|
+
runtimeVersion: external_manifest_js_namespaceObject.OCTANE_RUNTIME_VERSION,
|
|
94
|
+
compilerVersion: external_manifest_js_namespaceObject.OCTANE_COMPILER_VERSION,
|
|
95
|
+
rendererIdentities: options.rendererIdentities,
|
|
96
|
+
manifestFilename: external_manifest_js_namespaceObject.octaneModuleManifestFileName,
|
|
97
|
+
validateManifest: external_manifest_js_namespaceObject.validateOctaneModuleManifest
|
|
98
|
+
}));
|
|
99
|
+
config.module ??= {};
|
|
100
|
+
config.module.rules ??= [];
|
|
101
|
+
config.module.rules.push({
|
|
102
|
+
test: /\.tsrx$/u,
|
|
103
|
+
type: "javascript/auto",
|
|
104
|
+
use: [
|
|
105
|
+
{
|
|
106
|
+
loader: 'builtin:swc-loader',
|
|
107
|
+
options: {
|
|
108
|
+
detectSyntax: 'auto'
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
]
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
exports.createOctaneCompilerPlugin = __webpack_exports__.createOctaneCompilerPlugin;
|
|
118
|
+
exports.pluginSourceDirectory = __webpack_exports__.pluginSourceDirectory;
|
|
119
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
120
|
+
"createOctaneCompilerPlugin",
|
|
121
|
+
"pluginSourceDirectory"
|
|
122
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
123
|
+
Object.defineProperty(exports, '__esModule', {
|
|
124
|
+
value: true
|
|
125
|
+
});
|