@dsh-plugin/dsh-loader 1.3.1-dev.33057703930 → 1.3.1-dev.33147177576
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/lib/client.js +35 -4
- package/lib/client.js.map +1 -1
- package/lib/types/client-ui.d.ts +18 -5
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -58,6 +58,32 @@ window.__ModuleLoader__.load({
|
|
|
58
58
|
//#endregion
|
|
59
59
|
//#region src/client.ts
|
|
60
60
|
/**
|
|
61
|
+
* Compatibility shim: mount `window.__DSH_MODULES__` for plugins that read the
|
|
62
|
+
* client module system off the global.
|
|
63
|
+
*
|
|
64
|
+
* dsh ≤ 0.1.0-rc.7 set `globalThis.__DSH_MODULES__ = <ClientModuleSystem>`
|
|
65
|
+
* during web boot; 0.1.0-rc.8+ stopped exposing it globally and instead hands
|
|
66
|
+
* the same instance to the cordis client loader as `ctx.loader.internal`.
|
|
67
|
+
* Plugins built against the old global (e.g. dsh-better-sidebar's lazy chunks)
|
|
68
|
+
* break with "client module system unavailable" on the new versions. dshloader
|
|
69
|
+
* bridges the gap so those plugins need no change across every dsh version:
|
|
70
|
+
* when the global is missing but the cordis loader carries the module system,
|
|
71
|
+
* mirror it back onto the global.
|
|
72
|
+
*
|
|
73
|
+
* Returns true when the global is present after this call (either it already
|
|
74
|
+
* was, or we just mirrored it).
|
|
75
|
+
*/
|
|
76
|
+
function ensureDshModulesGlobal(win, ctx) {
|
|
77
|
+
const scope = globalThis;
|
|
78
|
+
if (scope.__DSH_MODULES__ !== void 0) return true;
|
|
79
|
+
const internal = ctx?.loader?.internal;
|
|
80
|
+
if (internal !== void 0 && typeof internal.import === "function") {
|
|
81
|
+
scope.__DSH_MODULES__ = internal;
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
61
87
|
* The ambient browser `window`, when this module runs in a browser-like realm.
|
|
62
88
|
* Read off `globalThis` so no DOM lib and no global declaration is required.
|
|
63
89
|
*/
|
|
@@ -2983,14 +3009,18 @@ window.__ModuleLoader__.load({
|
|
|
2983
3009
|
/**
|
|
2984
3010
|
* cordis client-plugin entry.
|
|
2985
3011
|
*
|
|
2986
|
-
*
|
|
2987
|
-
*
|
|
2988
|
-
*
|
|
2989
|
-
*
|
|
3012
|
+
* Mirrors the client module system back onto `window.__DSH_MODULES__` first
|
|
3013
|
+
* (legacy plugins' lazy chunks read the global; dsh 0.1.0-rc.8+ stopped
|
|
3014
|
+
* installing it), then mounts the infrastructure (so the `__ModuleLoader__`
|
|
3015
|
+
* wrapper is in place before any sibling bundle materialises), then the UI
|
|
3016
|
+
* facade, then publishes it both as the `dshLoaderUi` cordis service
|
|
3017
|
+
* (ordered access) and on `window.__dshLoader__.ui` (ad-hoc access from
|
|
3018
|
+
* non-cordis code).
|
|
2990
3019
|
*/
|
|
2991
3020
|
function apply(ctx) {
|
|
2992
3021
|
const win = ambientWindow();
|
|
2993
3022
|
if (win === void 0) return;
|
|
3023
|
+
ensureDshModulesGlobal(win, ctx);
|
|
2994
3024
|
const api = installClient({
|
|
2995
3025
|
window: win,
|
|
2996
3026
|
clientCtx: ctx
|
|
@@ -3037,6 +3067,7 @@ window.__ModuleLoader__.load({
|
|
|
3037
3067
|
exports.createUi = createUi;
|
|
3038
3068
|
exports.createUiAPI = createUiAPI;
|
|
3039
3069
|
exports.cx = cx;
|
|
3070
|
+
exports.ensureDshModulesGlobal = ensureDshModulesGlobal;
|
|
3040
3071
|
exports.ensureStyles = ensureStyles;
|
|
3041
3072
|
exports.getUi = getUi;
|
|
3042
3073
|
exports.icon = icon;
|