@jskit-ai/shell-web 0.1.255 → 0.2.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/CHANGELOG.md +45 -0
- package/locales/en.json +49 -0
- package/package.json +4 -3
- package/src/client/asyncModuleRecovery/runtime.js +14 -7
- package/src/client/clientUpdate/runtime.js +86 -0
- package/src/client/components/ShellErrorHost.vue +15 -10
- package/src/client/components/ShellLayout.vue +9 -6
- package/src/client/components/ShellMenuLinkItem.vue +10 -5
- package/src/client/components/ShellNavigationTooltip.vue +4 -2
- package/src/client/components/ShellOutlet.vue +25 -1
- package/src/client/components/ShellOutletMenuWidget.vue +6 -2
- package/src/client/components/ShellSurfaceAwareMenuLinkItem.vue +4 -4
- package/src/client/components/ShellTabLinkItem.vue +4 -2
- package/src/client/composables/useShellLayoutState.js +7 -3
- package/src/client/composables/useShellNavigationLink.js +8 -2
- package/src/client/composables/useShellPullToRefresh.js +4 -2
- package/src/client/error/runtime.js +25 -3
- package/src/client/error/store.js +17 -1
- package/src/client/i18n.js +8 -0
- package/src/client/providers/ShellWebClientProvider.js +22 -6
- package/src/client/providers/appModuleLoadFailure.js +4 -1
- package/src/client/requestRecovery/runtime.js +21 -14
- package/src/client/runtime/bootstrapRuntime.js +4 -1
- package/src/client/runtime/refreshRuntime.js +5 -2
- package/src/client/support/drawerPresentation.js +5 -2
- package/test/clientUpdate.test.js +241 -0
- package/test/i18nCatalog.test.js +16 -0
- package/test/provider.test.js +1 -0
- package/test/translation.test.js +110 -0
|
@@ -6,10 +6,12 @@ import {
|
|
|
6
6
|
} from "../placement/index.js";
|
|
7
7
|
import { resolveMenuLinkIcon } from "../lib/menuIcons.js";
|
|
8
8
|
import { resolveMenuLinkHref, resolveMenuLinkTarget } from "../support/menuLinkTarget.js";
|
|
9
|
+
import { useJskitText } from "../i18n.js";
|
|
9
10
|
|
|
10
11
|
const shellNavigationLinkProps = Object.freeze({
|
|
12
|
+
// A message key, { key, fallback } or plain text.
|
|
11
13
|
label: {
|
|
12
|
-
type: String,
|
|
14
|
+
type: [String, Object],
|
|
13
15
|
default: ""
|
|
14
16
|
},
|
|
15
17
|
to: {
|
|
@@ -46,6 +48,8 @@ const shellNavigationLinkProps = Object.freeze({
|
|
|
46
48
|
function useShellNavigationLink(props) {
|
|
47
49
|
const route = useRoute();
|
|
48
50
|
const { context: placementContext } = useWebPlacementContext();
|
|
51
|
+
const { text } = useJskitText();
|
|
52
|
+
const resolvedLabel = computed(() => text(props.label));
|
|
49
53
|
|
|
50
54
|
const resolvedTo = computed(() => {
|
|
51
55
|
const currentSurfaceId = resolveSurfaceIdFromPlacementPathname(
|
|
@@ -68,12 +72,14 @@ function useShellNavigationLink(props) {
|
|
|
68
72
|
const resolvedIcon = computed(() =>
|
|
69
73
|
resolveMenuLinkIcon({
|
|
70
74
|
icon: props.icon,
|
|
71
|
-
label
|
|
75
|
+
// Icons follow the English label, so they do not change with the language.
|
|
76
|
+
label: text(props.label, { locale: "en" }),
|
|
72
77
|
to: resolvedTarget.value.href || resolvedTo.value
|
|
73
78
|
})
|
|
74
79
|
);
|
|
75
80
|
|
|
76
81
|
return {
|
|
82
|
+
resolvedLabel,
|
|
77
83
|
resolvedTarget,
|
|
78
84
|
resolvedIcon
|
|
79
85
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { computed, onBeforeUnmount, onMounted, ref, unref } from "vue";
|
|
2
2
|
import { isPrimaryTouchPointer, isShellGestureIgnoredTarget } from "../support/gestureTargets.js";
|
|
3
|
+
import { useJskitText } from "../i18n.js";
|
|
3
4
|
|
|
4
5
|
const PULL_REFRESH_TRIGGER_DISTANCE = 72;
|
|
5
6
|
const PULL_REFRESH_MAX_DISTANCE = 112;
|
|
@@ -19,6 +20,7 @@ function isAtPageTop() {
|
|
|
19
20
|
// browser supports them; touch events carry it on after the browser cancels the
|
|
20
21
|
// pointer to scroll, and start it where pointer events are missing.
|
|
21
22
|
function useShellPullToRefresh({ enabled, refreshRuntime = null } = {}) {
|
|
23
|
+
const { t } = useJskitText();
|
|
22
24
|
const pullDistance = ref(0);
|
|
23
25
|
const pullRefreshing = ref(false);
|
|
24
26
|
let activePull = null;
|
|
@@ -31,9 +33,9 @@ function useShellPullToRefresh({ enabled, refreshRuntime = null } = {}) {
|
|
|
31
33
|
);
|
|
32
34
|
const pullRefreshLabel = computed(() => {
|
|
33
35
|
if (pullRefreshing.value) {
|
|
34
|
-
return "
|
|
36
|
+
return t("jskit.shell.pullToRefresh.refreshing");
|
|
35
37
|
}
|
|
36
|
-
return pullProgress.value >= 100 ? "
|
|
38
|
+
return pullProgress.value >= 100 ? t("jskit.shell.pullToRefresh.release") : t("jskit.shell.pullToRefresh.pull");
|
|
37
39
|
});
|
|
38
40
|
const pullRefreshStyle = computed(() => ({
|
|
39
41
|
"--shell-pull-refresh-distance": `${Math.round(Math.min(pullDistance.value, PULL_REFRESH_MAX_DISTANCE))}px`
|
|
@@ -10,6 +10,9 @@ import {
|
|
|
10
10
|
} from "./normalize.js";
|
|
11
11
|
import { createListenerSubscription } from "@jskit-ai/kernel/shared/support/listenerSet";
|
|
12
12
|
import { createDefaultErrorPolicy } from "./policy.js";
|
|
13
|
+
import { useJskitText } from "../i18n.js";
|
|
14
|
+
|
|
15
|
+
const { t } = useJskitText();
|
|
13
16
|
|
|
14
17
|
function createRuntimeLogger(logger = null) {
|
|
15
18
|
const source = isRecord(logger) ? logger : null;
|
|
@@ -19,6 +22,24 @@ function createRuntimeLogger(logger = null) {
|
|
|
19
22
|
});
|
|
20
23
|
}
|
|
21
24
|
|
|
25
|
+
function freezeParams(params) {
|
|
26
|
+
return Object.freeze(isRecord(params) ? { ...params } : {});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// The server code and the client messageCode travel with the message, each
|
|
30
|
+
// from the event when it names one and otherwise from its cause, so the error
|
|
31
|
+
// host can show the message in the user's language.
|
|
32
|
+
function messageCodeFields(source = {}, fallback = {}) {
|
|
33
|
+
const codeSource = source.code ? source : fallback;
|
|
34
|
+
const messageCodeSource = source.messageCode ? source : fallback;
|
|
35
|
+
return {
|
|
36
|
+
code: normalizeText(codeSource?.code),
|
|
37
|
+
params: freezeParams(codeSource?.params),
|
|
38
|
+
messageCode: normalizeText(messageCodeSource?.messageCode),
|
|
39
|
+
messageParams: freezeParams(messageCodeSource?.messageParams)
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
22
43
|
function normalizeErrorEvent(rawEvent = {}) {
|
|
23
44
|
const source = isRecord(rawEvent) ? rawEvent : { message: rawEvent };
|
|
24
45
|
const cause = source.cause !== undefined ? source.cause : source.error;
|
|
@@ -40,10 +61,10 @@ function normalizeErrorEvent(rawEvent = {}) {
|
|
|
40
61
|
const runtimeMessage = normalizeText(source.message || cause?.message);
|
|
41
62
|
|
|
42
63
|
return Object.freeze({
|
|
43
|
-
|
|
64
|
+
...messageCodeFields(source, isRecord(cause) ? cause : {}),
|
|
44
65
|
status,
|
|
45
66
|
source: normalizeText(source.source, "app"),
|
|
46
|
-
message: normalizeText(userMessage || runtimeMessage, "
|
|
67
|
+
message: normalizeText(userMessage || runtimeMessage, t("jskit.shell.error.requestFailed")),
|
|
47
68
|
userMessage,
|
|
48
69
|
intent: normalizeErrorIntent(source.intent || source.kind),
|
|
49
70
|
severity: normalizeSeverity(source.severity, "error"),
|
|
@@ -70,7 +91,8 @@ function normalizePolicyDecision(policyDecision = {}, event = {}) {
|
|
|
70
91
|
return Object.freeze({
|
|
71
92
|
channel,
|
|
72
93
|
presenterId: normalizeText(source.presenterId || event.presenterId),
|
|
73
|
-
message: normalizeText(source.message || event.userMessage || event.message, "
|
|
94
|
+
message: normalizeText(source.message || event.userMessage || event.message, t("jskit.shell.error.requestFailed")),
|
|
95
|
+
...messageCodeFields(source, event),
|
|
74
96
|
severity: normalizeSeverity(source.severity || event.severity, "error"),
|
|
75
97
|
action: normalizeAction(source.action || event.action),
|
|
76
98
|
additionalActions: normalizeAdditionalActions(source.additionalActions ?? event.additionalActions),
|
|
@@ -5,6 +5,9 @@ import {
|
|
|
5
5
|
normalizeText
|
|
6
6
|
} from "./normalize.js";
|
|
7
7
|
import { createListenerSubscription } from "@jskit-ai/kernel/shared/support/listenerSet";
|
|
8
|
+
import { useJskitText } from "../i18n.js";
|
|
9
|
+
|
|
10
|
+
const { t } = useJskitText();
|
|
8
11
|
|
|
9
12
|
const PRESENTATION_CHANNELS = Object.freeze(["snackbar", "banner", "dialog"]);
|
|
10
13
|
const SINGLETON_CHANNELS = new Set(["banner"]);
|
|
@@ -17,11 +20,19 @@ function createEmptyChannelState() {
|
|
|
17
20
|
};
|
|
18
21
|
}
|
|
19
22
|
|
|
23
|
+
function freezeParams(params) {
|
|
24
|
+
return Object.freeze(params && typeof params === "object" && !Array.isArray(params) ? { ...params } : {});
|
|
25
|
+
}
|
|
26
|
+
|
|
20
27
|
function cloneEntry(entry = {}) {
|
|
21
28
|
return Object.freeze({
|
|
22
29
|
id: String(entry.id || "").trim(),
|
|
23
30
|
channel: String(entry.channel || "").trim(),
|
|
24
31
|
message: String(entry.message || "").trim(),
|
|
32
|
+
code: String(entry.code || "").trim(),
|
|
33
|
+
params: freezeParams(entry.params),
|
|
34
|
+
messageCode: String(entry.messageCode || "").trim(),
|
|
35
|
+
messageParams: freezeParams(entry.messageParams),
|
|
25
36
|
severity: String(entry.severity || "error").trim(),
|
|
26
37
|
persist: Boolean(entry.persist),
|
|
27
38
|
action: entry.action || null,
|
|
@@ -78,7 +89,12 @@ function createErrorPresentationStore({
|
|
|
78
89
|
const entry = Object.freeze({
|
|
79
90
|
id: normalizeText(payload.id, `${normalizedChannel}-${sequence}`),
|
|
80
91
|
channel: normalizedChannel,
|
|
81
|
-
message: normalizeText(payload.message, "
|
|
92
|
+
message: normalizeText(payload.message, t("jskit.shell.error.requestFailed")),
|
|
93
|
+
// The error host renders the message through these codes when they match it.
|
|
94
|
+
code: normalizeText(payload.code),
|
|
95
|
+
params: freezeParams(payload.params),
|
|
96
|
+
messageCode: normalizeText(payload.messageCode),
|
|
97
|
+
messageParams: freezeParams(payload.messageParams),
|
|
82
98
|
severity: normalizeSeverity(payload.severity, "error"),
|
|
83
99
|
persist: payload.persist === true,
|
|
84
100
|
action: normalizeAction(payload.action),
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { registerJskitMessages, useJskitText } from "@jskit-ai/kernel/client/i18n";
|
|
2
|
+
import en from "../../locales/en.json" with { type: "json" };
|
|
3
|
+
|
|
4
|
+
// shell-web's English, registered on import so its components and runtimes
|
|
5
|
+
// translate in fixtures and tests as well as in a bootstrapped app.
|
|
6
|
+
registerJskitMessages(en);
|
|
7
|
+
|
|
8
|
+
export { useJskitText };
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
SHELL_ASYNC_MODULE_RECOVERY_RUNTIME_KEY
|
|
10
10
|
} from "../asyncModuleRecovery/inject.js";
|
|
11
11
|
import { createShellAsyncModuleRecoveryRuntime } from "../asyncModuleRecovery/runtime.js";
|
|
12
|
+
import { createShellClientUpdateRuntime } from "../clientUpdate/runtime.js";
|
|
12
13
|
import {
|
|
13
14
|
SHELL_REQUEST_RECOVERY_RUNTIME_KEY
|
|
14
15
|
} from "../requestRecovery/inject.js";
|
|
@@ -46,6 +47,9 @@ import {
|
|
|
46
47
|
} from "../runtime/refreshRuntime.js";
|
|
47
48
|
import { createBootstrapPayloadHandlerRegistry } from "../bootstrap/bootstrapPayloadHandlerRegistry.js";
|
|
48
49
|
import { resolveBootstrapErrorStatusCode } from "../bootstrap/bootstrapErrorStatus.js";
|
|
50
|
+
import { useJskitText } from "../i18n.js";
|
|
51
|
+
|
|
52
|
+
const { t } = useJskitText();
|
|
49
53
|
|
|
50
54
|
// Keep these constants for diagnostics, but keep each import() below as a literal string so Vite can statically analyze it.
|
|
51
55
|
const APP_PLACEMENT_MODULE_SPECIFIER = "/src/placement.js";
|
|
@@ -102,7 +106,7 @@ function loadAppPlacementDefinitions(logger, asyncModuleRecoveryRuntime = null)
|
|
|
102
106
|
return loadAppModule({
|
|
103
107
|
importModule: () => import("/src/placement.js"),
|
|
104
108
|
specifier: APP_PLACEMENT_MODULE_SPECIFIER,
|
|
105
|
-
label: "
|
|
109
|
+
label: t("jskit.shell.recovery.placementConfigLabel"),
|
|
106
110
|
resolve(exported) {
|
|
107
111
|
const resolved = typeof exported === "function" ? exported() : exported;
|
|
108
112
|
return Array.isArray(resolved) ? resolved : undefined;
|
|
@@ -119,7 +123,7 @@ function loadAppPlacementTopology(logger, asyncModuleRecoveryRuntime = null) {
|
|
|
119
123
|
return loadAppModule({
|
|
120
124
|
importModule: () => import("/src/placementTopology.js"),
|
|
121
125
|
specifier: APP_PLACEMENT_TOPOLOGY_MODULE_SPECIFIER,
|
|
122
|
-
label: "
|
|
126
|
+
label: t("jskit.shell.recovery.placementTopologyLabel"),
|
|
123
127
|
resolve: (exported) => resolveAppPlacementTopologyExport(exported, logger),
|
|
124
128
|
loadFailureMessage: "Failed to load app placement topology module; using empty topology.",
|
|
125
129
|
fallback: [],
|
|
@@ -164,7 +168,7 @@ function loadAppErrorConfig(logger, errorRuntime, asyncModuleRecoveryRuntime = n
|
|
|
164
168
|
return loadAppModule({
|
|
165
169
|
importModule: () => import("/src/error.js"),
|
|
166
170
|
specifier: APP_ERROR_MODULE_SPECIFIER,
|
|
167
|
-
label: "
|
|
171
|
+
label: t("jskit.shell.recovery.errorConfigLabel"),
|
|
168
172
|
async resolve(exported) {
|
|
169
173
|
const toolkit = createErrorConfigToolkit(errorRuntime);
|
|
170
174
|
const resolved = typeof exported === "function" ? await exported(toolkit) : exported;
|
|
@@ -189,7 +193,7 @@ function installVueErrorBridge(vueApp, errorRuntime, logger) {
|
|
|
189
193
|
try {
|
|
190
194
|
errorRuntime.report({
|
|
191
195
|
source: "shell-web.vue.error-handler",
|
|
192
|
-
message: String(error?.message || "
|
|
196
|
+
message: String(error?.message || t("jskit.shell.error.unexpectedUi")),
|
|
193
197
|
cause: error,
|
|
194
198
|
intent: "blocking",
|
|
195
199
|
severity: "error",
|
|
@@ -226,7 +230,7 @@ function installRouterErrorBridge(router, errorRuntime, logger) {
|
|
|
226
230
|
try {
|
|
227
231
|
errorRuntime.report({
|
|
228
232
|
source: "shell-web.router.on-error",
|
|
229
|
-
message: String(error?.message || "
|
|
233
|
+
message: String(error?.message || t("jskit.shell.error.navigationFailed")),
|
|
230
234
|
cause: error,
|
|
231
235
|
intent: "app-recoverable",
|
|
232
236
|
severity: "error",
|
|
@@ -256,6 +260,9 @@ const ShellWebClientProvider = defineProvider({
|
|
|
256
260
|
surfaceRuntime: "client.surface",
|
|
257
261
|
vueApp: "client.vue"
|
|
258
262
|
},
|
|
263
|
+
optional: {
|
|
264
|
+
realtime: "client.realtime"
|
|
265
|
+
},
|
|
259
266
|
provides: {
|
|
260
267
|
shell: "client.shell"
|
|
261
268
|
},
|
|
@@ -302,6 +309,10 @@ const ShellWebClientProvider = defineProvider({
|
|
|
302
309
|
errorRuntime,
|
|
303
310
|
logger
|
|
304
311
|
});
|
|
312
|
+
const clientUpdateRuntime = createShellClientUpdateRuntime({
|
|
313
|
+
errorRuntime,
|
|
314
|
+
reload: () => asyncModuleRecoveryRuntime.reload()
|
|
315
|
+
});
|
|
305
316
|
const bootstrapRuntime = createShellBootstrapRuntime({
|
|
306
317
|
handlers: bootstrapHandlers,
|
|
307
318
|
placementRuntime,
|
|
@@ -321,6 +332,7 @@ const ShellWebClientProvider = defineProvider({
|
|
|
321
332
|
asyncModuleRecovery: asyncModuleRecoveryRuntime,
|
|
322
333
|
bootstrap: bootstrapRuntime,
|
|
323
334
|
bootstrapHandlers,
|
|
335
|
+
clientUpdate: clientUpdateRuntime,
|
|
324
336
|
error: errorRuntime,
|
|
325
337
|
errorPresentationStore,
|
|
326
338
|
placement: placementRuntime,
|
|
@@ -329,11 +341,12 @@ const ShellWebClientProvider = defineProvider({
|
|
|
329
341
|
})
|
|
330
342
|
};
|
|
331
343
|
},
|
|
332
|
-
async boot({ loggerInput, pinia, router, surfaceRuntime, vueApp }, { outputs }) {
|
|
344
|
+
async boot({ loggerInput, pinia, realtime, router, surfaceRuntime, vueApp }, { outputs }) {
|
|
333
345
|
const logger = createSharedProviderLogger(loggerInput);
|
|
334
346
|
const {
|
|
335
347
|
asyncModuleRecovery: asyncModuleRecoveryRuntime,
|
|
336
348
|
bootstrap: bootstrapRuntime,
|
|
349
|
+
clientUpdate: clientUpdateRuntime,
|
|
337
350
|
error: errorRuntime,
|
|
338
351
|
errorPresentationStore,
|
|
339
352
|
placement: placementRuntime,
|
|
@@ -367,6 +380,8 @@ const ShellWebClientProvider = defineProvider({
|
|
|
367
380
|
const errorConfig = await loadAppErrorConfig(logger, errorRuntime, asyncModuleRecoveryRuntime);
|
|
368
381
|
errorRuntime.configure(errorConfig);
|
|
369
382
|
requestRecoveryRuntime.install();
|
|
383
|
+
// After the app's error configuration, so the offer follows its policy.
|
|
384
|
+
clientUpdateRuntime.watch(realtime);
|
|
370
385
|
|
|
371
386
|
await bootstrapRuntime.initialize();
|
|
372
387
|
|
|
@@ -388,6 +403,7 @@ const ShellWebClientProvider = defineProvider({
|
|
|
388
403
|
installRouterErrorBridge(router, errorRuntime, logger);
|
|
389
404
|
},
|
|
390
405
|
shutdown(_dependencies, { outputs }) {
|
|
406
|
+
outputs.shell.clientUpdate.dispose();
|
|
391
407
|
outputs.shell.requestRecovery.dispose();
|
|
392
408
|
outputs.shell.asyncModuleRecovery.dispose();
|
|
393
409
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isDynamicImportError
|
|
3
3
|
} from "@jskit-ai/kernel/client/asyncModuleRecovery";
|
|
4
|
+
import { useJskitText } from "../i18n.js";
|
|
5
|
+
|
|
6
|
+
const { t } = useJskitText();
|
|
4
7
|
|
|
5
8
|
function isMissingDynamicModule(error, moduleSpecifier) {
|
|
6
9
|
const message = String(error?.message || error || "");
|
|
@@ -12,7 +15,7 @@ function isMissingDynamicModule(error, moduleSpecifier) {
|
|
|
12
15
|
}
|
|
13
16
|
|
|
14
17
|
function notifyDynamicImportFailure(asyncModuleRecoveryRuntime, error, {
|
|
15
|
-
label = "
|
|
18
|
+
label = t("jskit.shell.recovery.appModuleLabel")
|
|
16
19
|
} = {}) {
|
|
17
20
|
if (!isDynamicImportError(error) || typeof asyncModuleRecoveryRuntime?.notify !== "function") {
|
|
18
21
|
return;
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { guardedReloadApp } from "@jskit-ai/kernel/client/asyncModuleRecovery";
|
|
2
2
|
import { isRecord, normalizeText } from "@jskit-ai/kernel/shared/support/normalize";
|
|
3
3
|
import { createProviderLogger as createSharedProviderLogger } from "@jskit-ai/kernel/shared/support/providerLogger";
|
|
4
|
+
import { useJskitText } from "../i18n.js";
|
|
4
5
|
|
|
5
|
-
const
|
|
6
|
-
|
|
6
|
+
const { t, text } = useJskitText();
|
|
7
|
+
// The label callers passed before labels were translated; it still means "no label".
|
|
8
|
+
const GENERIC_REQUEST_LABEL = "Request";
|
|
9
|
+
|
|
10
|
+
function appReloadFailureMessage() {
|
|
11
|
+
return t("jskit.shell.recovery.reloadFailed");
|
|
12
|
+
}
|
|
7
13
|
|
|
8
14
|
const RECOVERABLE_REQUEST_ERROR_MESSAGES = Object.freeze([
|
|
9
15
|
/Failed to fetch/iu,
|
|
@@ -92,8 +98,9 @@ function isRecoverableRequestError(error = null) {
|
|
|
92
98
|
);
|
|
93
99
|
}
|
|
94
100
|
|
|
101
|
+
// The label may be a message key; without one the sentence names the app.
|
|
95
102
|
function requestRecoveryMessage(error = null, {
|
|
96
|
-
label = "
|
|
103
|
+
label = "",
|
|
97
104
|
message = ""
|
|
98
105
|
} = {}) {
|
|
99
106
|
const explicitMessage = normalizeText(message);
|
|
@@ -101,11 +108,11 @@ function requestRecoveryMessage(error = null, {
|
|
|
101
108
|
return explicitMessage;
|
|
102
109
|
}
|
|
103
110
|
|
|
104
|
-
const requestLabel = normalizeText(label
|
|
105
|
-
if (requestLabel ===
|
|
106
|
-
return "
|
|
111
|
+
const requestLabel = normalizeText(text(label));
|
|
112
|
+
if (!requestLabel || requestLabel === GENERIC_REQUEST_LABEL) {
|
|
113
|
+
return t("jskit.shell.recovery.appUnreachable");
|
|
107
114
|
}
|
|
108
|
-
return
|
|
115
|
+
return t("jskit.shell.recovery.unreachable", { label: requestLabel });
|
|
109
116
|
}
|
|
110
117
|
|
|
111
118
|
function resolveQueryMeta(query = null) {
|
|
@@ -125,7 +132,7 @@ function readQueryRecoveryMeta(query = null) {
|
|
|
125
132
|
|
|
126
133
|
return Object.freeze({
|
|
127
134
|
disabled: jskitMeta.requestRecovery === false,
|
|
128
|
-
label: normalizeText(jskitMeta.requestRecoveryLabel
|
|
135
|
+
label: normalizeText(jskitMeta.requestRecoveryLabel),
|
|
129
136
|
source: normalizeText(jskitMeta.requestRecoverySource, { fallback: "shell-web.request-recovery.query" }),
|
|
130
137
|
dedupeKey: normalizeText(jskitMeta.requestRecoveryDedupeKey),
|
|
131
138
|
dedupeWindowMs: Number.isFinite(Number(dedupeWindowMs)) ? Math.max(0, Number(dedupeWindowMs)) : null,
|
|
@@ -326,8 +333,8 @@ function createShellRequestRecoveryRuntime({
|
|
|
326
333
|
let reloadAttempt = 0;
|
|
327
334
|
|
|
328
335
|
async function reload({
|
|
329
|
-
label = "
|
|
330
|
-
message =
|
|
336
|
+
label = t("jskit.shell.recovery.appLabel"),
|
|
337
|
+
message = appReloadFailureMessage()
|
|
331
338
|
} = {}) {
|
|
332
339
|
const reloaded = await guardedReloadApp({
|
|
333
340
|
label,
|
|
@@ -349,7 +356,7 @@ function createShellRequestRecoveryRuntime({
|
|
|
349
356
|
|
|
350
357
|
function retryAction(options, retry) {
|
|
351
358
|
return {
|
|
352
|
-
label: normalizeText(options.actionLabel, { fallback: "
|
|
359
|
+
label: normalizeText(text(options.actionLabel), { fallback: t("jskit.shell.actions.retry") }),
|
|
353
360
|
dismissOnRun: true,
|
|
354
361
|
async handler() {
|
|
355
362
|
try {
|
|
@@ -366,12 +373,12 @@ function createShellRequestRecoveryRuntime({
|
|
|
366
373
|
|
|
367
374
|
function reloadAction(options) {
|
|
368
375
|
return {
|
|
369
|
-
label: normalizeText(options.actionLabel, { fallback: "
|
|
376
|
+
label: normalizeText(text(options.actionLabel), { fallback: t("jskit.shell.actions.reload") }),
|
|
370
377
|
dismissOnRun: true,
|
|
371
378
|
handler() {
|
|
372
379
|
return reload({
|
|
373
380
|
label: options.label,
|
|
374
|
-
message: options.reloadFailureMessage ||
|
|
381
|
+
message: options.reloadFailureMessage || appReloadFailureMessage()
|
|
375
382
|
});
|
|
376
383
|
}
|
|
377
384
|
};
|
|
@@ -464,7 +471,7 @@ function createShellRequestRecoveryRuntime({
|
|
|
464
471
|
}
|
|
465
472
|
|
|
466
473
|
export {
|
|
467
|
-
|
|
474
|
+
appReloadFailureMessage,
|
|
468
475
|
createShellRequestRecoveryRuntime,
|
|
469
476
|
isRecoverableRequestError,
|
|
470
477
|
requestRecoveryMessage
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { createProviderLogger } from "@jskit-ai/kernel/shared/support/providerLogger";
|
|
2
|
+
import { useJskitText } from "../i18n.js";
|
|
3
|
+
|
|
4
|
+
const { t } = useJskitText();
|
|
2
5
|
|
|
3
6
|
const DEFAULT_BOOTSTRAP_PATH = "/api/bootstrap";
|
|
4
7
|
|
|
@@ -161,7 +164,7 @@ function createShellBootstrapRuntime({
|
|
|
161
164
|
} catch (error) {
|
|
162
165
|
await applyBootstrapError(error, reason, request);
|
|
163
166
|
requestRecoveryRuntime?.report?.(error, {
|
|
164
|
-
label: "
|
|
167
|
+
label: t("jskit.shell.recovery.appDataLabel"),
|
|
165
168
|
retry: () => refresh(reason),
|
|
166
169
|
source: "shell-web.bootstrap",
|
|
167
170
|
dedupeKey: `shell-web.bootstrap.${String(reason || "manual").trim() || "manual"}.request-failed`
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { isRecord } from "@jskit-ai/kernel/shared/support";
|
|
2
2
|
import { createProviderLogger as createSharedProviderLogger } from "@jskit-ai/kernel/shared/support/providerLogger";
|
|
3
|
+
import { useJskitText } from "../i18n.js";
|
|
4
|
+
|
|
5
|
+
const { t } = useJskitText();
|
|
3
6
|
|
|
4
7
|
const SHELL_WEB_REFRESH_RUNTIME_KEY = "jskit.shell-web.runtime.web-refresh.client";
|
|
5
8
|
|
|
@@ -65,13 +68,13 @@ function createShellRefreshRuntime({
|
|
|
65
68
|
|
|
66
69
|
errorRuntime.report({
|
|
67
70
|
source: "shell-web.refresh",
|
|
68
|
-
message: "
|
|
71
|
+
message: t("jskit.shell.recovery.refreshFailed"),
|
|
69
72
|
intent: "app-recoverable",
|
|
70
73
|
severity: "error",
|
|
71
74
|
dedupeKey: "shell-web.refresh.failed",
|
|
72
75
|
dedupeWindowMs: 2000,
|
|
73
76
|
action: {
|
|
74
|
-
label: "
|
|
77
|
+
label: t("jskit.shell.actions.retry"),
|
|
75
78
|
dismissOnRun: true,
|
|
76
79
|
handler() {
|
|
77
80
|
void refresh("retry");
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { useJskitText } from "../i18n.js";
|
|
2
|
+
|
|
3
|
+
const { t } = useJskitText();
|
|
1
4
|
const DESKTOP_DRAWER_CLOSED_MODES = Object.freeze(["rail", "hidden"]);
|
|
2
5
|
|
|
3
6
|
function normalizeDesktopDrawerClosedMode(value = "rail") {
|
|
@@ -45,9 +48,9 @@ function resolveShellDrawerPresentation({
|
|
|
45
48
|
|
|
46
49
|
function resolveShellDrawerToggleLabel({ compact = false, open = false } = {}) {
|
|
47
50
|
if (compact) {
|
|
48
|
-
return open ? "
|
|
51
|
+
return open ? t("jskit.shell.layout.closeNavigationMenu") : t("jskit.shell.layout.openNavigationMenu");
|
|
49
52
|
}
|
|
50
|
-
return open ? "
|
|
53
|
+
return open ? t("jskit.shell.layout.collapseNavigationDrawer") : t("jskit.shell.layout.expandNavigationDrawer");
|
|
51
54
|
}
|
|
52
55
|
|
|
53
56
|
export {
|