@jskit-ai/shell-web 0.1.16 → 0.1.17
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/package.descriptor.mjs +5 -3
- package/package.json +2 -2
- package/src/client/error/inject.js +2 -6
- package/src/client/error/presenters.js +3 -12
- package/src/client/index.js +2 -4
- package/src/client/placement/index.js +0 -4
- package/src/client/placement/inject.js +1 -2
- package/src/client/placement/runtime.js +2 -5
- package/src/client/placement/validators.js +4 -6
- package/src/client/providers/ShellWebClientProvider.js +27 -48
- package/test/provider.test.js +14 -29
- package/src/client/error/tokens.js +0 -14
- package/src/client/placement/tokens.js +0 -29
package/package.descriptor.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export default Object.freeze({
|
|
2
2
|
packageVersion: 1,
|
|
3
3
|
packageId: "@jskit-ai/shell-web",
|
|
4
|
-
version: "0.1.
|
|
4
|
+
version: "0.1.17",
|
|
5
|
+
kind: "runtime",
|
|
5
6
|
description: "Web shell layout runtime with outlet-based placement contributions.",
|
|
6
7
|
dependsOn: [],
|
|
7
8
|
capabilities: {
|
|
@@ -45,7 +46,8 @@ export default Object.freeze({
|
|
|
45
46
|
client: [
|
|
46
47
|
"runtime.web-placement.client",
|
|
47
48
|
"runtime.web-error.client",
|
|
48
|
-
"runtime.web-error.presentation-store.client"
|
|
49
|
+
"runtime.web-error.presentation-store.client",
|
|
50
|
+
"shell.web.query-client"
|
|
49
51
|
]
|
|
50
52
|
}
|
|
51
53
|
},
|
|
@@ -85,7 +87,7 @@ export default Object.freeze({
|
|
|
85
87
|
dependencies: {
|
|
86
88
|
runtime: {
|
|
87
89
|
"@tanstack/vue-query": "^5.90.5",
|
|
88
|
-
"@jskit-ai/kernel": "0.1.
|
|
90
|
+
"@jskit-ai/kernel": "0.1.18",
|
|
89
91
|
"vuetify": "^4.0.0"
|
|
90
92
|
},
|
|
91
93
|
dev: {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jskit-ai/shell-web",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "node --test"
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@tanstack/vue-query": "^5.90.5",
|
|
20
|
-
"@jskit-ai/kernel": "0.1.
|
|
20
|
+
"@jskit-ai/kernel": "0.1.18",
|
|
21
21
|
"vuetify": "^4.0.0"
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -4,10 +4,6 @@ import {
|
|
|
4
4
|
onMounted,
|
|
5
5
|
shallowRef
|
|
6
6
|
} from "vue";
|
|
7
|
-
import {
|
|
8
|
-
SHELL_WEB_ERROR_RUNTIME_INJECTION_KEY,
|
|
9
|
-
SHELL_WEB_ERROR_PRESENTATION_STORE_INJECTION_KEY
|
|
10
|
-
} from "./tokens.js";
|
|
11
7
|
|
|
12
8
|
const EMPTY_PRESENTATION_STATE = Object.freeze({
|
|
13
9
|
revision: 0,
|
|
@@ -83,7 +79,7 @@ const EMPTY_PRESENTATION_STORE = Object.freeze({
|
|
|
83
79
|
});
|
|
84
80
|
|
|
85
81
|
function useShellWebErrorRuntime({ required = false } = {}) {
|
|
86
|
-
const runtime = inject(
|
|
82
|
+
const runtime = inject("jskit.shell-web.runtime.web-error.client", null);
|
|
87
83
|
if (runtime && typeof runtime.report === "function") {
|
|
88
84
|
return runtime;
|
|
89
85
|
}
|
|
@@ -96,7 +92,7 @@ function useShellWebErrorRuntime({ required = false } = {}) {
|
|
|
96
92
|
}
|
|
97
93
|
|
|
98
94
|
function useShellWebErrorPresentationStore({ required = false } = {}) {
|
|
99
|
-
const store = inject(
|
|
95
|
+
const store = inject("jskit.shell-web.runtime.web-error.presentation-store.client", null);
|
|
100
96
|
if (store && typeof store.getState === "function" && typeof store.subscribe === "function") {
|
|
101
97
|
return store;
|
|
102
98
|
}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { normalizeText } from "./normalize.js";
|
|
2
2
|
|
|
3
|
-
const MATERIAL_SNACKBAR_PRESENTER_ID = "material.snackbar";
|
|
4
|
-
const MATERIAL_BANNER_PRESENTER_ID = "material.banner";
|
|
5
|
-
const MATERIAL_DIALOG_PRESENTER_ID = "material.dialog";
|
|
6
|
-
const MODULE_DEFAULT_PRESENTER_ID = MATERIAL_SNACKBAR_PRESENTER_ID;
|
|
7
|
-
|
|
8
3
|
function createStoreBackedPresenter({
|
|
9
4
|
id,
|
|
10
5
|
channel,
|
|
@@ -43,7 +38,7 @@ function createStoreBackedPresenter({
|
|
|
43
38
|
|
|
44
39
|
function createMaterialSnackbarPresenter({ store } = {}) {
|
|
45
40
|
return createStoreBackedPresenter({
|
|
46
|
-
id:
|
|
41
|
+
id: "material.snackbar",
|
|
47
42
|
channel: "snackbar",
|
|
48
43
|
store,
|
|
49
44
|
defaultPersist: false
|
|
@@ -52,7 +47,7 @@ function createMaterialSnackbarPresenter({ store } = {}) {
|
|
|
52
47
|
|
|
53
48
|
function createMaterialBannerPresenter({ store } = {}) {
|
|
54
49
|
return createStoreBackedPresenter({
|
|
55
|
-
id:
|
|
50
|
+
id: "material.banner",
|
|
56
51
|
channel: "banner",
|
|
57
52
|
store,
|
|
58
53
|
defaultPersist: true
|
|
@@ -61,7 +56,7 @@ function createMaterialBannerPresenter({ store } = {}) {
|
|
|
61
56
|
|
|
62
57
|
function createMaterialDialogPresenter({ store } = {}) {
|
|
63
58
|
return createStoreBackedPresenter({
|
|
64
|
-
id:
|
|
59
|
+
id: "material.dialog",
|
|
65
60
|
channel: "dialog",
|
|
66
61
|
store,
|
|
67
62
|
defaultPersist: true
|
|
@@ -77,10 +72,6 @@ function createDefaultMaterialErrorPresenters({ store } = {}) {
|
|
|
77
72
|
}
|
|
78
73
|
|
|
79
74
|
export {
|
|
80
|
-
MATERIAL_SNACKBAR_PRESENTER_ID,
|
|
81
|
-
MATERIAL_BANNER_PRESENTER_ID,
|
|
82
|
-
MATERIAL_DIALOG_PRESENTER_ID,
|
|
83
|
-
MODULE_DEFAULT_PRESENTER_ID,
|
|
84
75
|
createStoreBackedPresenter,
|
|
85
76
|
createMaterialSnackbarPresenter,
|
|
86
77
|
createMaterialBannerPresenter,
|
package/src/client/index.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
ShellWebClientProvider
|
|
3
|
-
SHELL_WEB_QUERY_CLIENT_TOKEN
|
|
2
|
+
ShellWebClientProvider
|
|
4
3
|
} from "./providers/ShellWebClientProvider.js";
|
|
5
4
|
|
|
6
5
|
export {
|
|
7
|
-
ShellWebClientProvider
|
|
8
|
-
SHELL_WEB_QUERY_CLIENT_TOKEN
|
|
6
|
+
ShellWebClientProvider
|
|
9
7
|
} from "./providers/ShellWebClientProvider.js";
|
|
10
8
|
|
|
11
9
|
export { default as ShellLayout } from "./components/ShellLayout.vue";
|
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
onMounted,
|
|
5
5
|
shallowRef
|
|
6
6
|
} from "vue";
|
|
7
|
-
import { WEB_PLACEMENT_RUNTIME_INJECTION_KEY } from "./tokens.js";
|
|
8
7
|
|
|
9
8
|
const EMPTY_WEB_PLACEMENT_RUNTIME = Object.freeze({
|
|
10
9
|
getContext() {
|
|
@@ -37,7 +36,7 @@ const EMPTY_WEB_PLACEMENT_CONTEXT = Object.freeze({
|
|
|
37
36
|
});
|
|
38
37
|
|
|
39
38
|
function useWebPlacementRuntime({ required = false } = {}) {
|
|
40
|
-
const runtime = inject(
|
|
39
|
+
const runtime = inject("jskit.shell-web.runtime.web-placement.client", null);
|
|
41
40
|
if (runtime && typeof runtime.getPlacements === "function") {
|
|
42
41
|
return runtime;
|
|
43
42
|
}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
WEB_PLACEMENT_CONTEXT_CONTRIBUTOR_TAG,
|
|
3
|
-
WEB_PLACEMENT_SURFACE_ANY
|
|
4
|
-
} from "./tokens.js";
|
|
5
1
|
import { DEFAULT_DEBUG_DEPTH, explodePayload } from "./debug.js";
|
|
6
2
|
import { createListenerSubscription } from "@jskit-ai/kernel/shared/support/listenerSet";
|
|
7
3
|
import { isRecord } from "@jskit-ai/kernel/shared/support/normalize";
|
|
@@ -25,6 +21,7 @@ function ensureArray(value) {
|
|
|
25
21
|
|
|
26
22
|
const PLACEMENT_DEBUG_PREFIX = "[placement-debug]";
|
|
27
23
|
const PLACEMENT_DEBUG_FLAG = "__JSKIT_PLACEMENT_DEBUG__";
|
|
24
|
+
const WEB_PLACEMENT_SURFACE_ANY = "*";
|
|
28
25
|
const NOOP = () => {};
|
|
29
26
|
|
|
30
27
|
function isPlacementDebugEnabled() {
|
|
@@ -107,7 +104,7 @@ function matchesSurface(placementSurfaces, requestedSurface) {
|
|
|
107
104
|
}
|
|
108
105
|
|
|
109
106
|
function resolveContextContributors(app, baseContext = {}, logger) {
|
|
110
|
-
const contributors = app.resolveTag(
|
|
107
|
+
const contributors = app.resolveTag("web-placement.context.client");
|
|
111
108
|
let merged = {};
|
|
112
109
|
|
|
113
110
|
for (const contributor of ensureArray(contributors)) {
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DEFAULT_WEB_PLACEMENT_ORDER,
|
|
3
|
-
WEB_PLACEMENT_SURFACE_ANY
|
|
4
|
-
} from "./tokens.js";
|
|
5
1
|
import { isRecord, normalizeText } from "@jskit-ai/kernel/shared/support/normalize";
|
|
6
2
|
|
|
3
|
+
const WEB_PLACEMENT_SURFACE_ANY = "*";
|
|
4
|
+
|
|
7
5
|
function isRenderableComponent(value) {
|
|
8
6
|
if (typeof value === "function") {
|
|
9
7
|
return true;
|
|
@@ -53,7 +51,7 @@ function normalizePlacementSurface(value, { strict = false, source = "placement"
|
|
|
53
51
|
return "";
|
|
54
52
|
}
|
|
55
53
|
|
|
56
|
-
function toInteger(value, fallback =
|
|
54
|
+
function toInteger(value, fallback = 1000) {
|
|
57
55
|
const numeric = Number(value);
|
|
58
56
|
if (!Number.isFinite(numeric)) {
|
|
59
57
|
return fallback;
|
|
@@ -182,7 +180,7 @@ function normalizePlacementDefinition(value, { strict = false, source = "placeme
|
|
|
182
180
|
host,
|
|
183
181
|
position,
|
|
184
182
|
surfaces,
|
|
185
|
-
order: toInteger(value.order,
|
|
183
|
+
order: toInteger(value.order, 1000),
|
|
186
184
|
componentToken,
|
|
187
185
|
props,
|
|
188
186
|
when,
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CLIENT_MODULE_ROUTER_TOKEN,
|
|
3
|
-
CLIENT_MODULE_SURFACE_RUNTIME_TOKEN,
|
|
4
|
-
CLIENT_MODULE_VUE_APP_TOKEN
|
|
5
|
-
} from "@jskit-ai/kernel/client/moduleBootstrap";
|
|
6
1
|
import { getClientAppConfig } from "@jskit-ai/kernel/client";
|
|
7
2
|
import {
|
|
8
3
|
isRecord,
|
|
@@ -18,8 +13,7 @@ import {
|
|
|
18
13
|
createDefaultMaterialErrorPresenters,
|
|
19
14
|
createMaterialBannerPresenter,
|
|
20
15
|
createMaterialDialogPresenter,
|
|
21
|
-
createMaterialSnackbarPresenter
|
|
22
|
-
MODULE_DEFAULT_PRESENTER_ID
|
|
16
|
+
createMaterialSnackbarPresenter
|
|
23
17
|
} from "../error/presenters.js";
|
|
24
18
|
import {
|
|
25
19
|
createErrorRuntime
|
|
@@ -27,26 +21,12 @@ import {
|
|
|
27
21
|
import {
|
|
28
22
|
createErrorPresentationStore
|
|
29
23
|
} from "../error/store.js";
|
|
30
|
-
import {
|
|
31
|
-
SHELL_WEB_ERROR_PRESENTATION_STORE_CLIENT_TOKEN,
|
|
32
|
-
SHELL_WEB_ERROR_PRESENTATION_STORE_INJECTION_KEY,
|
|
33
|
-
SHELL_WEB_ERROR_RUNTIME_CLIENT_TOKEN,
|
|
34
|
-
SHELL_WEB_ERROR_RUNTIME_INJECTION_KEY
|
|
35
|
-
} from "../error/tokens.js";
|
|
36
|
-
import {
|
|
37
|
-
WEB_PLACEMENT_RUNTIME_CLIENT_TOKEN,
|
|
38
|
-
WEB_PLACEMENT_RUNTIME_INJECTION_KEY
|
|
39
|
-
} from "../placement/tokens.js";
|
|
40
24
|
import { createWebPlacementRuntime } from "../placement/runtime.js";
|
|
41
25
|
import { buildSurfaceConfigContext } from "../placement/surfaceContext.js";
|
|
42
26
|
|
|
43
27
|
// Keep this constant for diagnostics, but keep import() below as a literal string so Vite can statically analyze it.
|
|
44
28
|
const APP_PLACEMENT_MODULE_SPECIFIER = "/src/placement.js";
|
|
45
29
|
const APP_ERROR_MODULE_SPECIFIER = "/src/error.js";
|
|
46
|
-
const SURFACE_CONTEXT_SOURCE = "shell-web.surface-config";
|
|
47
|
-
const SHELL_WEB_QUERY_CLIENT_TOKEN = "shell.web.query-client";
|
|
48
|
-
const VUE_ERROR_SOURCE = "shell-web.vue.error-handler";
|
|
49
|
-
const ROUTER_ERROR_SOURCE = "shell-web.router.on-error";
|
|
50
30
|
|
|
51
31
|
function createShellWebQueryClient() {
|
|
52
32
|
return new QueryClient({
|
|
@@ -107,7 +87,7 @@ async function loadAppPlacementDefinitions(logger) {
|
|
|
107
87
|
function createErrorConfigToolkit(errorRuntime) {
|
|
108
88
|
return Object.freeze({
|
|
109
89
|
createDefaultErrorPolicy,
|
|
110
|
-
moduleDefaultPresenterId:
|
|
90
|
+
moduleDefaultPresenterId: "material.snackbar",
|
|
111
91
|
presenterFactories: Object.freeze({
|
|
112
92
|
createMaterialSnackbarPresenter,
|
|
113
93
|
createMaterialBannerPresenter,
|
|
@@ -186,7 +166,7 @@ function installVueErrorBridge(vueApp, errorRuntime, logger) {
|
|
|
186
166
|
vueApp.config.errorHandler = (error, instance, info) => {
|
|
187
167
|
try {
|
|
188
168
|
errorRuntime.report({
|
|
189
|
-
source:
|
|
169
|
+
source: "shell-web.vue.error-handler",
|
|
190
170
|
message: String(error?.message || "Unexpected UI error."),
|
|
191
171
|
cause: error,
|
|
192
172
|
severity: "error",
|
|
@@ -198,7 +178,7 @@ function installVueErrorBridge(vueApp, errorRuntime, logger) {
|
|
|
198
178
|
} catch (reportError) {
|
|
199
179
|
logger.error(
|
|
200
180
|
{
|
|
201
|
-
source:
|
|
181
|
+
source: "shell-web.vue.error-handler",
|
|
202
182
|
error: String(reportError?.message || reportError || "unknown error")
|
|
203
183
|
},
|
|
204
184
|
"Shell web error runtime failed to report a Vue error."
|
|
@@ -212,11 +192,11 @@ function installVueErrorBridge(vueApp, errorRuntime, logger) {
|
|
|
212
192
|
}
|
|
213
193
|
|
|
214
194
|
function installRouterErrorBridge(app, errorRuntime, logger) {
|
|
215
|
-
if (!app.has(
|
|
195
|
+
if (!app.has("jskit.client.router")) {
|
|
216
196
|
return;
|
|
217
197
|
}
|
|
218
198
|
|
|
219
|
-
const router = app.make(
|
|
199
|
+
const router = app.make("jskit.client.router");
|
|
220
200
|
if (!router || typeof router.onError !== "function") {
|
|
221
201
|
return;
|
|
222
202
|
}
|
|
@@ -224,7 +204,7 @@ function installRouterErrorBridge(app, errorRuntime, logger) {
|
|
|
224
204
|
router.onError((error) => {
|
|
225
205
|
try {
|
|
226
206
|
errorRuntime.report({
|
|
227
|
-
source:
|
|
207
|
+
source: "shell-web.router.on-error",
|
|
228
208
|
message: String(error?.message || "Navigation failed."),
|
|
229
209
|
cause: error,
|
|
230
210
|
severity: "error",
|
|
@@ -235,7 +215,7 @@ function installRouterErrorBridge(app, errorRuntime, logger) {
|
|
|
235
215
|
} catch (reportError) {
|
|
236
216
|
logger.error(
|
|
237
217
|
{
|
|
238
|
-
source:
|
|
218
|
+
source: "shell-web.router.on-error",
|
|
239
219
|
error: String(reportError?.message || reportError || "unknown error")
|
|
240
220
|
},
|
|
241
221
|
"Shell web error runtime failed to report a router error."
|
|
@@ -253,16 +233,16 @@ class ShellWebClientProvider {
|
|
|
253
233
|
}
|
|
254
234
|
|
|
255
235
|
const logger = createSharedProviderLogger(isRecord(app) ? app : null);
|
|
256
|
-
app.singleton(
|
|
257
|
-
app.singleton(
|
|
258
|
-
app.singleton(
|
|
259
|
-
app.singleton(
|
|
236
|
+
app.singleton("runtime.web-placement.client", () => createWebPlacementRuntime({ app, logger }));
|
|
237
|
+
app.singleton("shell.web.query-client", () => createShellWebQueryClient());
|
|
238
|
+
app.singleton("runtime.web-error.presentation-store.client", () => createErrorPresentationStore());
|
|
239
|
+
app.singleton("runtime.web-error.client", (scope) =>
|
|
260
240
|
createErrorRuntime({
|
|
261
241
|
presenters: createDefaultMaterialErrorPresenters({
|
|
262
|
-
store: scope.make(
|
|
242
|
+
store: scope.make("runtime.web-error.presentation-store.client")
|
|
263
243
|
}),
|
|
264
244
|
policy: createDefaultErrorPolicy(),
|
|
265
|
-
moduleDefaultPresenterId:
|
|
245
|
+
moduleDefaultPresenterId: "material.snackbar",
|
|
266
246
|
logger
|
|
267
247
|
})
|
|
268
248
|
);
|
|
@@ -274,13 +254,13 @@ class ShellWebClientProvider {
|
|
|
274
254
|
}
|
|
275
255
|
|
|
276
256
|
const logger = createSharedProviderLogger(isRecord(app) ? app : null);
|
|
277
|
-
const placementRuntime = app.make(
|
|
257
|
+
const placementRuntime = app.make("runtime.web-placement.client");
|
|
278
258
|
if (placementRuntime && typeof placementRuntime.replacePlacements === "function") {
|
|
279
259
|
const placements = await loadAppPlacementDefinitions(logger);
|
|
280
260
|
placementRuntime.replacePlacements(placements, { source: APP_PLACEMENT_MODULE_SPECIFIER });
|
|
281
261
|
const appConfig = getClientAppConfig();
|
|
282
|
-
const surfaceRuntime = app.has(
|
|
283
|
-
? app.make(
|
|
262
|
+
const surfaceRuntime = app.has("jskit.client.surface.runtime")
|
|
263
|
+
? app.make("jskit.client.surface.runtime")
|
|
284
264
|
: null;
|
|
285
265
|
const surfaceConfig = buildSurfaceConfigContext(surfaceRuntime, {
|
|
286
266
|
tenancyMode: appConfig?.tenancyMode
|
|
@@ -295,32 +275,32 @@ class ShellWebClientProvider {
|
|
|
295
275
|
surfaceAccessPolicies
|
|
296
276
|
},
|
|
297
277
|
{
|
|
298
|
-
source:
|
|
278
|
+
source: "shell-web.surface-config"
|
|
299
279
|
}
|
|
300
280
|
);
|
|
301
281
|
}
|
|
302
282
|
|
|
303
|
-
const errorRuntime = app.make(
|
|
283
|
+
const errorRuntime = app.make("runtime.web-error.client");
|
|
304
284
|
const errorConfig = await loadAppErrorConfig(logger, errorRuntime);
|
|
305
285
|
applyAppErrorConfig(errorRuntime, errorConfig);
|
|
306
286
|
|
|
307
|
-
if (!app.has(
|
|
287
|
+
if (!app.has("jskit.client.vue.app")) {
|
|
308
288
|
return;
|
|
309
289
|
}
|
|
310
290
|
|
|
311
|
-
const vueApp = app.make(
|
|
291
|
+
const vueApp = app.make("jskit.client.vue.app");
|
|
312
292
|
if (!vueApp || typeof vueApp.provide !== "function" || typeof vueApp.use !== "function") {
|
|
313
293
|
return;
|
|
314
294
|
}
|
|
315
295
|
|
|
316
296
|
vueApp.use(VueQueryPlugin, {
|
|
317
|
-
queryClient: app.make(
|
|
297
|
+
queryClient: app.make("shell.web.query-client")
|
|
318
298
|
});
|
|
319
|
-
vueApp.provide(
|
|
320
|
-
vueApp.provide(
|
|
299
|
+
vueApp.provide("jskit.shell-web.runtime.web-placement.client", placementRuntime);
|
|
300
|
+
vueApp.provide("jskit.shell-web.runtime.web-error.client", errorRuntime);
|
|
321
301
|
vueApp.provide(
|
|
322
|
-
|
|
323
|
-
app.make(
|
|
302
|
+
"jskit.shell-web.runtime.web-error.presentation-store.client",
|
|
303
|
+
app.make("runtime.web-error.presentation-store.client")
|
|
324
304
|
);
|
|
325
305
|
|
|
326
306
|
installVueErrorBridge(vueApp, errorRuntime, logger);
|
|
@@ -329,6 +309,5 @@ class ShellWebClientProvider {
|
|
|
329
309
|
}
|
|
330
310
|
|
|
331
311
|
export {
|
|
332
|
-
ShellWebClientProvider
|
|
333
|
-
SHELL_WEB_QUERY_CLIENT_TOKEN
|
|
312
|
+
ShellWebClientProvider
|
|
334
313
|
};
|
package/test/provider.test.js
CHANGED
|
@@ -1,21 +1,6 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import test from "node:test";
|
|
3
3
|
import { ShellWebClientProvider } from "../src/client/providers/ShellWebClientProvider.js";
|
|
4
|
-
import {
|
|
5
|
-
WEB_PLACEMENT_RUNTIME_CLIENT_TOKEN,
|
|
6
|
-
WEB_PLACEMENT_RUNTIME_INJECTION_KEY
|
|
7
|
-
} from "../src/client/placement/tokens.js";
|
|
8
|
-
import {
|
|
9
|
-
SHELL_WEB_ERROR_PRESENTATION_STORE_CLIENT_TOKEN,
|
|
10
|
-
SHELL_WEB_ERROR_PRESENTATION_STORE_INJECTION_KEY,
|
|
11
|
-
SHELL_WEB_ERROR_RUNTIME_CLIENT_TOKEN,
|
|
12
|
-
SHELL_WEB_ERROR_RUNTIME_INJECTION_KEY
|
|
13
|
-
} from "../src/client/error/tokens.js";
|
|
14
|
-
import {
|
|
15
|
-
CLIENT_MODULE_SURFACE_RUNTIME_TOKEN,
|
|
16
|
-
CLIENT_MODULE_VUE_APP_TOKEN
|
|
17
|
-
} from "@jskit-ai/kernel/client/moduleBootstrap";
|
|
18
|
-
|
|
19
4
|
const CLIENT_APP_CONFIG_GLOBAL_KEY = "__JSKIT_CLIENT_APP_CONFIG__";
|
|
20
5
|
|
|
21
6
|
function setClientAppConfig(source = {}) {
|
|
@@ -53,19 +38,19 @@ function createAppDouble({ surfaceRuntime = null } = {}) {
|
|
|
53
38
|
singletons.set(token, factory);
|
|
54
39
|
},
|
|
55
40
|
has(token) {
|
|
56
|
-
if (token ===
|
|
41
|
+
if (token === "jskit.client.vue.app") {
|
|
57
42
|
return true;
|
|
58
43
|
}
|
|
59
|
-
if (token ===
|
|
44
|
+
if (token === "jskit.client.surface.runtime") {
|
|
60
45
|
return Boolean(surfaceRuntime);
|
|
61
46
|
}
|
|
62
47
|
return singletons.has(token) || singletonInstances.has(token);
|
|
63
48
|
},
|
|
64
49
|
make(token) {
|
|
65
|
-
if (token ===
|
|
50
|
+
if (token === "jskit.client.vue.app") {
|
|
66
51
|
return vueApp;
|
|
67
52
|
}
|
|
68
|
-
if (token ===
|
|
53
|
+
if (token === "jskit.client.surface.runtime" && surfaceRuntime) {
|
|
69
54
|
return surfaceRuntime;
|
|
70
55
|
}
|
|
71
56
|
if (singletonInstances.has(token)) {
|
|
@@ -90,9 +75,9 @@ test("shell web client provider binds runtime and injects it into Vue app", asyn
|
|
|
90
75
|
const provider = new ShellWebClientProvider();
|
|
91
76
|
|
|
92
77
|
provider.register(app);
|
|
93
|
-
assert.equal(app.singletons.has(
|
|
94
|
-
assert.equal(app.singletons.has(
|
|
95
|
-
assert.equal(app.singletons.has(
|
|
78
|
+
assert.equal(app.singletons.has("runtime.web-placement.client"), true);
|
|
79
|
+
assert.equal(app.singletons.has("runtime.web-error.client"), true);
|
|
80
|
+
assert.equal(app.singletons.has("runtime.web-error.presentation-store.client"), true);
|
|
96
81
|
|
|
97
82
|
await provider.boot(app);
|
|
98
83
|
assert.equal(app.plugins.length, 1);
|
|
@@ -101,21 +86,21 @@ test("shell web client provider binds runtime and injects it into Vue app", asyn
|
|
|
101
86
|
|
|
102
87
|
const providedByKey = new Map(app.provided.map((entry) => [entry.key, entry.value]));
|
|
103
88
|
|
|
104
|
-
assert.equal(providedByKey.has(
|
|
105
|
-
assert.equal(providedByKey.has(
|
|
106
|
-
assert.equal(providedByKey.has(
|
|
89
|
+
assert.equal(providedByKey.has("jskit.shell-web.runtime.web-placement.client"), true);
|
|
90
|
+
assert.equal(providedByKey.has("jskit.shell-web.runtime.web-error.client"), true);
|
|
91
|
+
assert.equal(providedByKey.has("jskit.shell-web.runtime.web-error.presentation-store.client"), true);
|
|
107
92
|
|
|
108
|
-
const placementRuntime = providedByKey.get(
|
|
93
|
+
const placementRuntime = providedByKey.get("jskit.shell-web.runtime.web-placement.client");
|
|
109
94
|
assert.equal(typeof placementRuntime.getPlacements, "function");
|
|
110
95
|
assert.equal(typeof placementRuntime.getContext, "function");
|
|
111
96
|
assert.equal(typeof placementRuntime.setContext, "function");
|
|
112
97
|
assert.equal(typeof placementRuntime.getContext().surfaceConfig, "object");
|
|
113
98
|
|
|
114
|
-
const errorRuntime = providedByKey.get(
|
|
99
|
+
const errorRuntime = providedByKey.get("jskit.shell-web.runtime.web-error.client");
|
|
115
100
|
assert.equal(typeof errorRuntime.report, "function");
|
|
116
101
|
assert.equal(typeof errorRuntime.configure, "function");
|
|
117
102
|
|
|
118
|
-
const errorStore = providedByKey.get(
|
|
103
|
+
const errorStore = providedByKey.get("jskit.shell-web.runtime.web-error.presentation-store.client");
|
|
119
104
|
assert.equal(typeof errorStore.getState, "function");
|
|
120
105
|
assert.equal(typeof errorStore.present, "function");
|
|
121
106
|
});
|
|
@@ -149,7 +134,7 @@ test("shell web client provider resolves surface config from client app config",
|
|
|
149
134
|
|
|
150
135
|
await provider.boot(app);
|
|
151
136
|
|
|
152
|
-
const placementRuntime = app.make(
|
|
137
|
+
const placementRuntime = app.make("runtime.web-placement.client");
|
|
153
138
|
const context = placementRuntime.getContext();
|
|
154
139
|
assert.equal(context.surfaceConfig.tenancyMode, "workspaces");
|
|
155
140
|
assert.equal(context.surfaceConfig.defaultSurfaceId, "app");
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const SHELL_WEB_ERROR_RUNTIME_CLIENT_TOKEN = "runtime.web-error.client";
|
|
2
|
-
const SHELL_WEB_ERROR_PRESENTATION_STORE_CLIENT_TOKEN = "runtime.web-error.presentation-store.client";
|
|
3
|
-
|
|
4
|
-
const SHELL_WEB_ERROR_RUNTIME_INJECTION_KEY = Symbol.for("jskit.shell-web.runtime.web-error.client");
|
|
5
|
-
const SHELL_WEB_ERROR_PRESENTATION_STORE_INJECTION_KEY = Symbol.for(
|
|
6
|
-
"jskit.shell-web.runtime.web-error.presentation-store.client"
|
|
7
|
-
);
|
|
8
|
-
|
|
9
|
-
export {
|
|
10
|
-
SHELL_WEB_ERROR_RUNTIME_CLIENT_TOKEN,
|
|
11
|
-
SHELL_WEB_ERROR_PRESENTATION_STORE_CLIENT_TOKEN,
|
|
12
|
-
SHELL_WEB_ERROR_RUNTIME_INJECTION_KEY,
|
|
13
|
-
SHELL_WEB_ERROR_PRESENTATION_STORE_INJECTION_KEY
|
|
14
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
const WEB_PLACEMENT_RUNTIME_CLIENT_TOKEN = "runtime.web-placement.client";
|
|
2
|
-
const WEB_PLACEMENT_CONTEXT_CONTRIBUTOR_TAG = "web-placement.context.client";
|
|
3
|
-
const WEB_PLACEMENT_RUNTIME_INJECTION_KEY = Symbol.for("jskit.shell-web.runtime.web-placement.client");
|
|
4
|
-
|
|
5
|
-
const WEB_PLACEMENT_SURFACE_ANY = "*";
|
|
6
|
-
const DEFAULT_WEB_PLACEMENT_ORDER = 1000;
|
|
7
|
-
|
|
8
|
-
const WEB_PLACEMENT_POSITIONS = Object.freeze([
|
|
9
|
-
"top",
|
|
10
|
-
"top-left",
|
|
11
|
-
"left",
|
|
12
|
-
"bottom-left",
|
|
13
|
-
"bottom",
|
|
14
|
-
"bottom-right",
|
|
15
|
-
"right",
|
|
16
|
-
"top-right",
|
|
17
|
-
"center",
|
|
18
|
-
"primary-menu",
|
|
19
|
-
"secondary-menu"
|
|
20
|
-
]);
|
|
21
|
-
|
|
22
|
-
export {
|
|
23
|
-
WEB_PLACEMENT_RUNTIME_CLIENT_TOKEN,
|
|
24
|
-
WEB_PLACEMENT_CONTEXT_CONTRIBUTOR_TAG,
|
|
25
|
-
WEB_PLACEMENT_RUNTIME_INJECTION_KEY,
|
|
26
|
-
WEB_PLACEMENT_SURFACE_ANY,
|
|
27
|
-
DEFAULT_WEB_PLACEMENT_ORDER,
|
|
28
|
-
WEB_PLACEMENT_POSITIONS
|
|
29
|
-
};
|