@jskit-ai/shell-web 0.1.251 → 0.1.253

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.
Files changed (49) hide show
  1. package/README.md +5 -79
  2. package/fixtures/adaptive-shell/src/main.js +6 -3
  3. package/package.json +6 -7
  4. package/patterns/application-shell/example/src/pages/home/index.vue +15 -5
  5. package/patterns/application-shell/example/tests/e2e/adaptive-shell.spec.ts +1 -1
  6. package/src/architecture/cli.js +1 -33
  7. package/src/architecture/inspectVueArchitecture.js +1 -400
  8. package/src/client/asyncModuleRecovery/runtime.js +116 -0
  9. package/src/client/components/ShellLayout.vue +18 -288
  10. package/src/client/components/ShellMenuLinkItem.vue +3 -21
  11. package/src/client/components/ShellOutlet.vue +2 -24
  12. package/src/client/components/ShellRouteTransition.vue +16 -114
  13. package/src/client/components/ShellSurfaceAwareMenuLinkItem.vue +5 -100
  14. package/src/client/components/ShellTabLinkItem.vue +5 -101
  15. package/src/client/composables/useShellNavigationLink.js +85 -0
  16. package/src/client/composables/useShellPullToRefresh.js +260 -0
  17. package/src/client/error/index.js +1 -1
  18. package/src/client/error/inject.js +4 -1
  19. package/src/client/error/policy.js +4 -13
  20. package/src/client/error/presenters.js +4 -9
  21. package/src/client/error/store.js +1 -1
  22. package/src/client/navigation/linkResolver.js +5 -27
  23. package/src/client/navigation/usePaths.js +1 -21
  24. package/src/client/placement/index.js +2 -0
  25. package/src/client/placement/inject.js +4 -1
  26. package/src/client/placement/runtime.js +2 -4
  27. package/src/client/placement/surfaceContext.js +11 -8
  28. package/src/client/placement/validators.js +18 -65
  29. package/src/client/providers/ShellWebClientProvider.js +100 -356
  30. package/src/client/requestRecovery/runtime.js +29 -77
  31. package/src/client/runtime/bootstrapRuntime.js +5 -4
  32. package/src/client/runtime/refreshRuntime.js +122 -0
  33. package/src/client/support/gestureTargets.js +26 -0
  34. package/src/client/support/menuLinkTarget.js +35 -19
  35. package/src/client/support/routeParams.js +26 -0
  36. package/src/client/support/routeSwipeGesture.js +88 -0
  37. package/src/client/support/routeTransitionKey.js +1 -3
  38. package/src/client/support/shellLayoutClass.js +32 -0
  39. package/test/bootstrapRuntime.test.js +98 -0
  40. package/test/errorActions.test.js +2 -1
  41. package/test/errorRuntime.test.js +30 -0
  42. package/test/linkResolver.test.js +23 -1
  43. package/test/menuLinkTarget.test.js +77 -0
  44. package/test/routeSwipeGesture.test.js +49 -0
  45. package/test/settingsPlacementContract.test.js +16 -6
  46. package/test/shellGestureSupport.test.js +46 -0
  47. package/test/surfaceContext.test.js +53 -0
  48. package/test/useShellPullToRefresh.test.js +123 -0
  49. package/test/architecture.test.js +0 -154
@@ -1,108 +1,13 @@
1
1
  <script setup>
2
- import { computed } from "vue";
3
- import { useRoute } from "vue-router";
4
- import { resolveShellLinkPath } from "../navigation/linkResolver.js";
5
2
  import {
6
- resolveSurfaceIdFromPlacementPathname,
7
- resolveSurfaceNavigationTargetFromPlacementContext,
8
- useWebPlacementContext
9
- } from "../placement/index.js";
10
- import { resolveMenuLinkIcon } from "../lib/menuIcons.js";
11
- import { resolveMenuLinkTarget } from "../support/menuLinkTarget.js";
3
+ shellNavigationLinkProps,
4
+ useShellNavigationLink
5
+ } from "../composables/useShellNavigationLink.js";
12
6
  import { activateShellNavigationLinkOnSpace } from "../support/navigationLinkKeyboard.js";
13
7
  import ShellNavigationTooltip from "./ShellNavigationTooltip.vue";
14
8
 
15
- const props = defineProps({
16
- label: {
17
- type: String,
18
- default: ""
19
- },
20
- to: {
21
- type: String,
22
- default: ""
23
- },
24
- icon: {
25
- type: String,
26
- default: ""
27
- },
28
- surface: {
29
- type: String,
30
- default: ""
31
- },
32
- scopedSuffix: {
33
- type: String,
34
- default: "/"
35
- },
36
- unscopedSuffix: {
37
- type: String,
38
- default: "/"
39
- },
40
- disabled: {
41
- type: Boolean,
42
- default: false
43
- },
44
- exact: {
45
- type: Boolean,
46
- default: false
47
- }
48
- });
49
-
50
- const route = useRoute();
51
- const { context: placementContext } = useWebPlacementContext();
52
-
53
- const currentSurfaceId = computed(() => {
54
- return resolveSurfaceIdFromPlacementPathname(
55
- placementContext.value,
56
- String(route?.path || route?.fullPath || "").trim()
57
- );
58
- });
59
-
60
- const resolvedTo = computed(() => {
61
- return resolveMenuLinkTarget({
62
- to: props.to,
63
- surface: props.surface,
64
- currentSurfaceId: currentSurfaceId.value,
65
- placementContext: placementContext.value,
66
- scopedSuffix: props.scopedSuffix,
67
- unscopedSuffix: props.unscopedSuffix,
68
- routeParams: route.params || {},
69
- resolvePagePath(relativePath, options = {}) {
70
- return resolveShellLinkPath({
71
- context: placementContext.value,
72
- surface: options.surface,
73
- relativePath,
74
- params: route.params || {},
75
- strictParams: options.strictParams !== false
76
- });
77
- }
78
- });
79
- });
80
-
81
- const resolvedTarget = computed(() => {
82
- const target = String(resolvedTo.value || "").trim();
83
- if (!target) {
84
- return {
85
- href: "",
86
- sameOrigin: true
87
- };
88
- }
89
-
90
- const navigationTarget = resolveSurfaceNavigationTargetFromPlacementContext(placementContext.value, {
91
- path: target
92
- });
93
- return {
94
- href: navigationTarget.href,
95
- sameOrigin: navigationTarget.sameOrigin
96
- };
97
- });
98
-
99
- const resolvedIcon = computed(() =>
100
- resolveMenuLinkIcon({
101
- icon: props.icon,
102
- label: props.label,
103
- to: resolvedTarget.value.href || resolvedTo.value
104
- })
105
- );
9
+ const props = defineProps(shellNavigationLinkProps);
10
+ const { resolvedTarget, resolvedIcon } = useShellNavigationLink(props);
106
11
  </script>
107
12
 
108
13
  <template>
@@ -1,107 +1,11 @@
1
1
  <script setup>
2
- import { computed } from "vue";
3
- import { useRoute } from "vue-router";
4
- import { resolveShellLinkPath } from "../navigation/linkResolver.js";
5
2
  import {
6
- resolveSurfaceIdFromPlacementPathname,
7
- resolveSurfaceNavigationTargetFromPlacementContext,
8
- useWebPlacementContext
9
- } from "../placement/index.js";
10
- import { resolveMenuLinkIcon } from "../lib/menuIcons.js";
11
- import { resolveMenuLinkTarget } from "../support/menuLinkTarget.js";
12
-
13
- const props = defineProps({
14
- label: {
15
- type: String,
16
- default: ""
17
- },
18
- to: {
19
- type: String,
20
- default: ""
21
- },
22
- icon: {
23
- type: String,
24
- default: ""
25
- },
26
- surface: {
27
- type: String,
28
- default: ""
29
- },
30
- scopedSuffix: {
31
- type: String,
32
- default: "/"
33
- },
34
- unscopedSuffix: {
35
- type: String,
36
- default: "/"
37
- },
38
- disabled: {
39
- type: Boolean,
40
- default: false
41
- },
42
- exact: {
43
- type: Boolean,
44
- default: false
45
- }
46
- });
47
-
48
- const route = useRoute();
49
- const { context: placementContext } = useWebPlacementContext();
50
-
51
- const currentSurfaceId = computed(() => {
52
- return resolveSurfaceIdFromPlacementPathname(
53
- placementContext.value,
54
- String(route?.path || route?.fullPath || "").trim()
55
- );
56
- });
57
-
58
- const resolvedTo = computed(() => {
59
- return resolveMenuLinkTarget({
60
- to: props.to,
61
- surface: props.surface,
62
- currentSurfaceId: currentSurfaceId.value,
63
- placementContext: placementContext.value,
64
- scopedSuffix: props.scopedSuffix,
65
- unscopedSuffix: props.unscopedSuffix,
66
- routeParams: route.params || {},
67
- resolvePagePath(relativePath, options = {}) {
68
- return resolveShellLinkPath({
69
- context: placementContext.value,
70
- surface: options.surface,
71
- relativePath,
72
- params: route.params || {},
73
- strictParams: options.strictParams !== false
74
- });
75
- }
76
- });
77
- });
78
-
79
- const resolvedTarget = computed(() => {
80
- const target = String(resolvedTo.value || "").trim();
81
- if (!target) {
82
- return {
83
- href: "",
84
- sameOrigin: true
85
- };
86
- }
87
-
88
- const navigationTarget = resolveSurfaceNavigationTargetFromPlacementContext(placementContext.value, {
89
- path: target
90
- });
91
- return {
92
- href: navigationTarget.href,
93
- sameOrigin: navigationTarget.sameOrigin
94
- };
95
- });
96
-
97
- const resolvedIcon = computed(() =>
98
- resolveMenuLinkIcon({
99
- icon: props.icon,
100
- label: props.label,
101
- to: resolvedTarget.value.href || resolvedTo.value
102
- })
103
- );
3
+ shellNavigationLinkProps,
4
+ useShellNavigationLink
5
+ } from "../composables/useShellNavigationLink.js";
104
6
 
7
+ const props = defineProps(shellNavigationLinkProps);
8
+ const { resolvedTarget, resolvedIcon } = useShellNavigationLink(props);
105
9
  </script>
106
10
 
107
11
  <template>
@@ -0,0 +1,85 @@
1
+ import { computed } from "vue";
2
+ import { useRoute } from "vue-router";
3
+ import {
4
+ resolveSurfaceIdFromPlacementPathname,
5
+ useWebPlacementContext
6
+ } from "../placement/index.js";
7
+ import { resolveMenuLinkIcon } from "../lib/menuIcons.js";
8
+ import { resolveMenuLinkHref, resolveMenuLinkTarget } from "../support/menuLinkTarget.js";
9
+
10
+ const shellNavigationLinkProps = Object.freeze({
11
+ label: {
12
+ type: String,
13
+ default: ""
14
+ },
15
+ to: {
16
+ type: String,
17
+ default: ""
18
+ },
19
+ icon: {
20
+ type: String,
21
+ default: ""
22
+ },
23
+ surface: {
24
+ type: String,
25
+ default: ""
26
+ },
27
+ scopedSuffix: {
28
+ type: String,
29
+ default: "/"
30
+ },
31
+ unscopedSuffix: {
32
+ type: String,
33
+ default: "/"
34
+ },
35
+ disabled: {
36
+ type: Boolean,
37
+ default: false
38
+ },
39
+ exact: {
40
+ type: Boolean,
41
+ default: false
42
+ }
43
+ });
44
+
45
+ // Surface-aware link resolution shared by the shell menu and tab link items.
46
+ function useShellNavigationLink(props) {
47
+ const route = useRoute();
48
+ const { context: placementContext } = useWebPlacementContext();
49
+
50
+ const resolvedTo = computed(() => {
51
+ const currentSurfaceId = resolveSurfaceIdFromPlacementPathname(
52
+ placementContext.value,
53
+ String(route?.path || route?.fullPath || "").trim()
54
+ );
55
+ return resolveMenuLinkTarget({
56
+ to: props.to,
57
+ surface: props.surface,
58
+ currentSurfaceId,
59
+ placementContext: placementContext.value,
60
+ scopedSuffix: props.scopedSuffix,
61
+ unscopedSuffix: props.unscopedSuffix,
62
+ routeParams: route.params || {}
63
+ });
64
+ });
65
+
66
+ const resolvedTarget = computed(() => resolveMenuLinkHref(placementContext.value, resolvedTo.value));
67
+
68
+ const resolvedIcon = computed(() =>
69
+ resolveMenuLinkIcon({
70
+ icon: props.icon,
71
+ label: props.label,
72
+ to: resolvedTarget.value.href || resolvedTo.value
73
+ })
74
+ );
75
+
76
+ return {
77
+ resolvedTarget,
78
+ resolvedIcon
79
+ };
80
+ }
81
+
82
+ export {
83
+ shellNavigationLinkProps,
84
+ useShellNavigationLink
85
+ };
@@ -0,0 +1,260 @@
1
+ import { computed, onBeforeUnmount, onMounted, ref, unref } from "vue";
2
+ import { isPrimaryTouchPointer, isShellGestureIgnoredTarget } from "../support/gestureTargets.js";
3
+
4
+ const PULL_REFRESH_TRIGGER_DISTANCE = 72;
5
+ const PULL_REFRESH_MAX_DISTANCE = 112;
6
+ const PULL_REFRESH_IGNORED_SELECTORS = Object.freeze(["[data-shell-pull-refresh-ignore]"]);
7
+
8
+ function isAtPageTop() {
9
+ if (typeof window !== "object" || typeof document !== "object") {
10
+ return false;
11
+ }
12
+
13
+ const documentScrollTop = Number(document.documentElement?.scrollTop || 0);
14
+ const bodyScrollTop = Number(document.body?.scrollTop || 0);
15
+ return Math.max(Number(window.scrollY || 0), documentScrollTop, bodyScrollTop) <= 0;
16
+ }
17
+
18
+ // Compact-layout pull-to-refresh. Pointer events start the gesture where the
19
+ // browser supports them; touch events carry it on after the browser cancels the
20
+ // pointer to scroll, and start it where pointer events are missing.
21
+ function useShellPullToRefresh({ enabled, refreshRuntime = null } = {}) {
22
+ const pullDistance = ref(0);
23
+ const pullRefreshing = ref(false);
24
+ let activePull = null;
25
+
26
+ const pullProgress = computed(() =>
27
+ Math.min(100, Math.round((pullDistance.value / PULL_REFRESH_TRIGGER_DISTANCE) * 100))
28
+ );
29
+ const pullIndicatorVisible = computed(() =>
30
+ Boolean(unref(enabled) && (pullDistance.value > 0 || pullRefreshing.value))
31
+ );
32
+ const pullRefreshLabel = computed(() => {
33
+ if (pullRefreshing.value) {
34
+ return "Refreshing";
35
+ }
36
+ return pullProgress.value >= 100 ? "Release to refresh" : "Pull to refresh";
37
+ });
38
+ const pullRefreshStyle = computed(() => ({
39
+ "--shell-pull-refresh-distance": `${Math.round(Math.min(pullDistance.value, PULL_REFRESH_MAX_DISTANCE))}px`
40
+ }));
41
+
42
+ onMounted(() => {
43
+ if (typeof window !== "object") {
44
+ return;
45
+ }
46
+ window.addEventListener("pointerdown", handlePullPointerDown, { capture: true, passive: true });
47
+ window.addEventListener("pointermove", handlePullPointerMove, { capture: true, passive: false });
48
+ window.addEventListener("pointerup", handlePullPointerEnd, { capture: true, passive: true });
49
+ window.addEventListener("pointercancel", handlePullPointerCancel, { capture: true, passive: true });
50
+ window.addEventListener("touchstart", handlePullTouchStart, { capture: true, passive: true });
51
+ window.addEventListener("touchmove", handlePullTouchMove, { capture: true, passive: false });
52
+ window.addEventListener("touchend", handlePullTouchEnd, { capture: true, passive: true });
53
+ window.addEventListener("touchcancel", handlePullTouchCancel, { capture: true, passive: true });
54
+ });
55
+
56
+ onBeforeUnmount(() => {
57
+ if (typeof window !== "object") {
58
+ return;
59
+ }
60
+ window.removeEventListener("pointerdown", handlePullPointerDown, { capture: true });
61
+ window.removeEventListener("pointermove", handlePullPointerMove, { capture: true });
62
+ window.removeEventListener("pointerup", handlePullPointerEnd, { capture: true });
63
+ window.removeEventListener("pointercancel", handlePullPointerCancel, { capture: true });
64
+ window.removeEventListener("touchstart", handlePullTouchStart, { capture: true });
65
+ window.removeEventListener("touchmove", handlePullTouchMove, { capture: true });
66
+ window.removeEventListener("touchend", handlePullTouchEnd, { capture: true });
67
+ window.removeEventListener("touchcancel", handlePullTouchCancel, { capture: true });
68
+ });
69
+
70
+ function canRefresh() {
71
+ return Boolean(refreshRuntime && typeof refreshRuntime.refresh === "function");
72
+ }
73
+
74
+ function canStartFromTarget(target) {
75
+ return Boolean(
76
+ unref(enabled) &&
77
+ canRefresh() &&
78
+ !pullRefreshing.value &&
79
+ isAtPageTop() &&
80
+ !isShellGestureIgnoredTarget(target, { extraSelectors: PULL_REFRESH_IGNORED_SELECTORS })
81
+ );
82
+ }
83
+
84
+ function handlePullPointerDown(event) {
85
+ if (!isPrimaryTouchPointer(event) || !canStartFromTarget(event.target)) {
86
+ activePull = null;
87
+ return;
88
+ }
89
+
90
+ activePull = {
91
+ pointerId: event.pointerId,
92
+ touchIdentifier: null,
93
+ startX: event.clientX,
94
+ startY: event.clientY
95
+ };
96
+ }
97
+
98
+ function handlePullPointerMove(event) {
99
+ if (!activePull || event.pointerId !== activePull.pointerId) {
100
+ return;
101
+ }
102
+
103
+ updatePullGesture(event.clientX, event.clientY, event);
104
+ }
105
+
106
+ function handlePullPointerEnd(event) {
107
+ if (!activePull || event.pointerId !== activePull.pointerId) {
108
+ return;
109
+ }
110
+
111
+ finishPullGesture();
112
+ }
113
+
114
+ // The browser cancels the pointer when it takes over scrolling; touch events
115
+ // keep following the same finger.
116
+ function handlePullPointerCancel(event) {
117
+ if (!activePull || event.pointerId !== activePull.pointerId) {
118
+ return;
119
+ }
120
+
121
+ activePull.pointerId = null;
122
+ }
123
+
124
+ function handlePullTouchStart(event) {
125
+ if (activePull || event?.touches?.length !== 1 || !canStartFromTarget(event.target)) {
126
+ return;
127
+ }
128
+
129
+ const touch = event.touches[0];
130
+ activePull = {
131
+ pointerId: null,
132
+ touchIdentifier: touch.identifier,
133
+ startX: touch.clientX,
134
+ startY: touch.clientY
135
+ };
136
+ }
137
+
138
+ function handlePullTouchMove(event) {
139
+ const touch = findActiveTouch(event.touches);
140
+ if (!activePull || !touch) {
141
+ return;
142
+ }
143
+
144
+ updatePullGesture(touch.clientX, touch.clientY, event);
145
+ }
146
+
147
+ function handlePullTouchEnd(event) {
148
+ if (!activePull || !touchListIncludesActiveTouch(event.changedTouches)) {
149
+ return;
150
+ }
151
+
152
+ finishPullGesture();
153
+ }
154
+
155
+ function handlePullTouchCancel(event) {
156
+ if (activePull && touchListIncludesActiveTouch(event.changedTouches)) {
157
+ cancelPullRefresh();
158
+ }
159
+ }
160
+
161
+ function updatePullGesture(clientX, clientY, event) {
162
+ if (!activePull) {
163
+ return;
164
+ }
165
+
166
+ const deltaX = clientX - activePull.startX;
167
+ const deltaY = clientY - activePull.startY;
168
+ const absX = Math.abs(deltaX);
169
+
170
+ if (deltaY < -4 || (absX > 24 && absX > deltaY * 1.15)) {
171
+ cancelPullRefresh();
172
+ return;
173
+ }
174
+
175
+ if (deltaY <= 6 || !isAtPageTop()) {
176
+ return;
177
+ }
178
+
179
+ if (event?.cancelable) {
180
+ event.preventDefault();
181
+ }
182
+ pullDistance.value = Math.min(PULL_REFRESH_MAX_DISTANCE, Math.round(deltaY * 0.55));
183
+ }
184
+
185
+ function finishPullGesture() {
186
+ const shouldRefresh = pullDistance.value >= PULL_REFRESH_TRIGGER_DISTANCE;
187
+ activePull = null;
188
+
189
+ if (!shouldRefresh) {
190
+ pullDistance.value = 0;
191
+ return;
192
+ }
193
+
194
+ void refreshFromPullGesture();
195
+ }
196
+
197
+ function cancelPullRefresh() {
198
+ activePull = null;
199
+ if (!pullRefreshing.value) {
200
+ pullDistance.value = 0;
201
+ }
202
+ }
203
+
204
+ async function refreshFromPullGesture() {
205
+ if (!canRefresh() || pullRefreshing.value) {
206
+ pullDistance.value = 0;
207
+ return;
208
+ }
209
+
210
+ pullRefreshing.value = true;
211
+ pullDistance.value = PULL_REFRESH_TRIGGER_DISTANCE;
212
+ try {
213
+ await refreshRuntime.refresh("pull-to-refresh");
214
+ } finally {
215
+ pullRefreshing.value = false;
216
+ pullDistance.value = 0;
217
+ }
218
+ }
219
+
220
+ function findActiveTouch(touchList) {
221
+ if (!activePull || !touchList || touchList.length < 1) {
222
+ return null;
223
+ }
224
+
225
+ if (activePull.touchIdentifier === null && touchList.length === 1) {
226
+ return touchList[0];
227
+ }
228
+
229
+ for (const touch of touchList) {
230
+ if (touch.identifier === activePull.touchIdentifier) {
231
+ return touch;
232
+ }
233
+ }
234
+
235
+ return null;
236
+ }
237
+
238
+ function touchListIncludesActiveTouch(touchList) {
239
+ if (!activePull) {
240
+ return false;
241
+ }
242
+
243
+ if (activePull.touchIdentifier === null) {
244
+ return !touchList || touchList.length <= 1;
245
+ }
246
+
247
+ return Boolean(findActiveTouch(touchList));
248
+ }
249
+
250
+ return {
251
+ pullDistance,
252
+ pullRefreshing,
253
+ pullProgress,
254
+ pullIndicatorVisible,
255
+ pullRefreshLabel,
256
+ pullRefreshStyle
257
+ };
258
+ }
259
+
260
+ export { useShellPullToRefresh };
@@ -1,3 +1,3 @@
1
1
  export { createDefaultErrorPolicy } from "./policy.js";
2
- export { useShellWebErrorRuntime } from "./inject.js";
2
+ export { SHELL_WEB_ERROR_RUNTIME_KEY, useShellWebErrorRuntime } from "./inject.js";
3
3
  export { useShellErrorPresentationStore } from "../stores/useShellErrorPresentationStore.js";
@@ -2,6 +2,8 @@ import {
2
2
  inject
3
3
  } from "vue";
4
4
 
5
+ const SHELL_WEB_ERROR_RUNTIME_KEY = "jskit.shell-web.runtime.web-error.client";
6
+
5
7
  const EMPTY_ERROR_RUNTIME = Object.freeze({
6
8
  report() {
7
9
  return Object.freeze({
@@ -49,7 +51,7 @@ const EMPTY_ERROR_RUNTIME = Object.freeze({
49
51
  });
50
52
 
51
53
  function useShellWebErrorRuntime({ required = false } = {}) {
52
- const runtime = inject("jskit.shell-web.runtime.web-error.client", null);
54
+ const runtime = inject(SHELL_WEB_ERROR_RUNTIME_KEY, null);
53
55
  if (runtime && typeof runtime.report === "function") {
54
56
  return runtime;
55
57
  }
@@ -62,6 +64,7 @@ function useShellWebErrorRuntime({ required = false } = {}) {
62
64
  }
63
65
 
64
66
  export {
67
+ SHELL_WEB_ERROR_RUNTIME_KEY,
65
68
  EMPTY_ERROR_RUNTIME,
66
69
  useShellWebErrorRuntime
67
70
  };
@@ -1,10 +1,7 @@
1
1
  import {
2
- normalizeAction,
3
- normalizeAdditionalActions,
4
2
  normalizeChannel,
5
3
  normalizeErrorIntent,
6
- normalizeSeverity,
7
- normalizeText
4
+ normalizeSeverity
8
5
  } from "./normalize.js";
9
6
 
10
7
  function createDefaultErrorPolicy({
@@ -46,17 +43,11 @@ function createDefaultErrorPolicy({
46
43
  }
47
44
  }
48
45
 
49
- const message = normalizeText(event.userMessage || event.message, "Request failed.");
50
-
46
+ // The runtime owns every other default, including message, actions,
47
+ // presenter, dedupe and persistence.
51
48
  return Object.freeze({
52
49
  channel,
53
- message,
54
- severity: normalizeSeverity(event.severity, normalizedDefaultSeverity),
55
- presenterId: normalizeText(event.presenterId),
56
- action: normalizeAction(event.action),
57
- additionalActions: normalizeAdditionalActions(event.additionalActions),
58
- persist: channel !== "snackbar",
59
- dedupeKey: normalizeText(event.dedupeKey)
50
+ severity: normalizeSeverity(event.severity, normalizedDefaultSeverity)
60
51
  });
61
52
  };
62
53
  }
@@ -3,8 +3,7 @@ import { normalizeText } from "./normalize.js";
3
3
  function createStoreBackedPresenter({
4
4
  id,
5
5
  channel,
6
- store,
7
- defaultPersist = false
6
+ store
8
7
  } = {}) {
9
8
  const normalizedId = normalizeText(id);
10
9
  const normalizedChannel = normalizeText(channel).toLowerCase();
@@ -26,7 +25,6 @@ function createStoreBackedPresenter({
26
25
  present(payload = {}) {
27
26
  return store.present(normalizedChannel, {
28
27
  ...payload,
29
- persist: typeof payload.persist === "boolean" ? payload.persist : defaultPersist,
30
28
  presenterId: normalizedId
31
29
  });
32
30
  },
@@ -40,8 +38,7 @@ function createMaterialSnackbarPresenter({ store } = {}) {
40
38
  return createStoreBackedPresenter({
41
39
  id: "material.snackbar",
42
40
  channel: "snackbar",
43
- store,
44
- defaultPersist: false
41
+ store
45
42
  });
46
43
  }
47
44
 
@@ -49,8 +46,7 @@ function createMaterialBannerPresenter({ store } = {}) {
49
46
  return createStoreBackedPresenter({
50
47
  id: "material.banner",
51
48
  channel: "banner",
52
- store,
53
- defaultPersist: true
49
+ store
54
50
  });
55
51
  }
56
52
 
@@ -58,8 +54,7 @@ function createMaterialDialogPresenter({ store } = {}) {
58
54
  return createStoreBackedPresenter({
59
55
  id: "material.dialog",
60
56
  channel: "dialog",
61
- store,
62
- defaultPersist: true
57
+ store
63
58
  });
64
59
  }
65
60
 
@@ -80,7 +80,7 @@ function createErrorPresentationStore({
80
80
  channel: normalizedChannel,
81
81
  message: normalizeText(payload.message, "Request failed."),
82
82
  severity: normalizeSeverity(payload.severity, "error"),
83
- persist: typeof payload.persist === "boolean" ? payload.persist : normalizedChannel !== "snackbar",
83
+ persist: payload.persist === true,
84
84
  action: normalizeAction(payload.action),
85
85
  additionalActions: normalizeAdditionalActions(payload.additionalActions),
86
86
  presenterId: normalizeText(payload.presenterId),