@rdlabo/ionic-theme-ios27 1.2.1 → 2.0.0-beta.pr304.sha56daf151ad80

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 (195) hide show
  1. package/README.md +24 -280
  2. package/dist/css/components/ion-toolbar.css +1 -1
  3. package/dist/css/ionic-theme-ios27.css +1 -1
  4. package/dist/css/vertical-bars.css +1 -1
  5. package/dist/index.d.ts +3 -2
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +3 -2
  8. package/dist/index.js.map +1 -1
  9. package/dist/layout/index.d.ts +18 -0
  10. package/dist/layout/index.d.ts.map +1 -0
  11. package/dist/layout/index.js +26 -0
  12. package/dist/layout/index.js.map +1 -0
  13. package/dist/segment/index.js +3 -3
  14. package/dist/segment/index.js.map +1 -1
  15. package/dist/sheets-of-glass/index.js +7 -7
  16. package/dist/sheets-of-glass/index.js.map +1 -1
  17. package/dist/tab-bar-searchable/dismiss-button.js +53 -3
  18. package/dist/tab-bar-searchable/dismiss-button.js.map +1 -1
  19. package/dist/tab-bar-searchable/index.js +18 -3
  20. package/dist/tab-bar-searchable/index.js.map +1 -1
  21. package/dist/transition/ios.transition.d.ts.map +1 -1
  22. package/dist/transition/ios.transition.js +7 -4
  23. package/dist/transition/ios.transition.js.map +1 -1
  24. package/dist/transition/native-ui.d.ts +6 -0
  25. package/dist/transition/native-ui.d.ts.map +1 -0
  26. package/dist/{native-integration/index.js → transition/native-ui.js} +16 -30
  27. package/dist/transition/native-ui.js.map +1 -0
  28. package/docs/adaptive-themes.md +151 -0
  29. package/docs/add-native-ui.md +53 -0
  30. package/docs/animation.md +1 -1
  31. package/docs/eslint.md +1 -1
  32. package/docs/features.md +3 -3
  33. package/docs/iphone-duo-with-original-theme.md +44 -29
  34. package/docs/iphone-duo.md +29 -32
  35. package/docs/migration.md +12 -24
  36. package/docs/setup.md +82 -0
  37. package/docs/special-markup.md +5 -5
  38. package/docs/using-ion-item-group.md +2 -2
  39. package/docs/vertical-bars-layout.md +47 -0
  40. package/package.json +12 -42
  41. package/src/index.ts +3 -1
  42. package/src/layout/index.ts +29 -0
  43. package/src/segment/index.ts +3 -3
  44. package/src/sheets-of-glass/index.ts +7 -7
  45. package/src/styles/components/ion-toolbar.scss +1 -1
  46. package/src/styles/vertical-bars.scss +15 -18
  47. package/src/tab-bar-searchable/dismiss-button.ts +73 -4
  48. package/src/tab-bar-searchable/index.ts +20 -3
  49. package/src/transition/ios.transition.ts +7 -4
  50. package/src/{native-integration/index.ts → transition/native-ui.ts} +17 -46
  51. package/Package.swift +0 -21
  52. package/dist/_virtual/_rolldown/runtime.js +0 -13
  53. package/dist/native/components/index.d.ts +0 -19
  54. package/dist/native/components/index.d.ts.map +0 -1
  55. package/dist/native/components/index.js +0 -40
  56. package/dist/native/components/index.js.map +0 -1
  57. package/dist/native/components/ion-back-button.d.ts +0 -9
  58. package/dist/native/components/ion-back-button.d.ts.map +0 -1
  59. package/dist/native/components/ion-back-button.js +0 -20
  60. package/dist/native/components/ion-back-button.js.map +0 -1
  61. package/dist/native/components/ion-button.d.ts +0 -10
  62. package/dist/native/components/ion-button.d.ts.map +0 -1
  63. package/dist/native/components/ion-button.js +0 -23
  64. package/dist/native/components/ion-button.js.map +0 -1
  65. package/dist/native/components/ion-buttons.d.ts +0 -11
  66. package/dist/native/components/ion-buttons.d.ts.map +0 -1
  67. package/dist/native/components/ion-buttons.js +0 -30
  68. package/dist/native/components/ion-buttons.js.map +0 -1
  69. package/dist/native/components/ion-fab.d.ts +0 -10
  70. package/dist/native/components/ion-fab.d.ts.map +0 -1
  71. package/dist/native/components/ion-fab.js +0 -132
  72. package/dist/native/components/ion-fab.js.map +0 -1
  73. package/dist/native/components/ion-menu-button.d.ts +0 -13
  74. package/dist/native/components/ion-menu-button.d.ts.map +0 -1
  75. package/dist/native/components/ion-menu-button.js +0 -31
  76. package/dist/native/components/ion-menu-button.js.map +0 -1
  77. package/dist/native/components/ion-segment.d.ts +0 -11
  78. package/dist/native/components/ion-segment.d.ts.map +0 -1
  79. package/dist/native/components/ion-segment.js +0 -30
  80. package/dist/native/components/ion-segment.js.map +0 -1
  81. package/dist/native/components/ion-tab-bar.d.ts +0 -11
  82. package/dist/native/components/ion-tab-bar.d.ts.map +0 -1
  83. package/dist/native/components/ion-tab-bar.js +0 -50
  84. package/dist/native/components/ion-tab-bar.js.map +0 -1
  85. package/dist/native/components/searchable-tabs.d.ts +0 -20
  86. package/dist/native/components/searchable-tabs.d.ts.map +0 -1
  87. package/dist/native/components/searchable-tabs.js +0 -383
  88. package/dist/native/components/searchable-tabs.js.map +0 -1
  89. package/dist/native/definitions.d.ts +0 -152
  90. package/dist/native/definitions.d.ts.map +0 -1
  91. package/dist/native/definitions.js +0 -0
  92. package/dist/native/foldable/fold-state.d.ts +0 -5
  93. package/dist/native/foldable/fold-state.d.ts.map +0 -1
  94. package/dist/native/foldable/fold-state.js +0 -14
  95. package/dist/native/foldable/fold-state.js.map +0 -1
  96. package/dist/native/foldable/types.d.ts +0 -12
  97. package/dist/native/foldable/types.d.ts.map +0 -1
  98. package/dist/native/foldable/types.js +0 -0
  99. package/dist/native/index.d.ts +0 -11
  100. package/dist/native/index.d.ts.map +0 -1
  101. package/dist/native/index.js +0 -242
  102. package/dist/native/index.js.map +0 -1
  103. package/dist/native/prehide.d.ts +0 -7
  104. package/dist/native/prehide.d.ts.map +0 -1
  105. package/dist/native/prehide.js +0 -230
  106. package/dist/native/prehide.js.map +0 -1
  107. package/dist/native/runtime.d.ts +0 -5
  108. package/dist/native/runtime.d.ts.map +0 -1
  109. package/dist/native/runtime.js +0 -640
  110. package/dist/native/runtime.js.map +0 -1
  111. package/dist/native/shared/candidate.d.ts +0 -21
  112. package/dist/native/shared/candidate.d.ts.map +0 -1
  113. package/dist/native/shared/candidate.js +0 -98
  114. package/dist/native/shared/candidate.js.map +0 -1
  115. package/dist/native/shared/crossfade.d.ts +0 -10
  116. package/dist/native/shared/crossfade.d.ts.map +0 -1
  117. package/dist/native/shared/crossfade.js +0 -50
  118. package/dist/native/shared/crossfade.js.map +0 -1
  119. package/dist/native/shared/dom.d.ts +0 -46
  120. package/dist/native/shared/dom.d.ts.map +0 -1
  121. package/dist/native/shared/dom.js +0 -172
  122. package/dist/native/shared/dom.js.map +0 -1
  123. package/dist/native/shared/events.d.ts +0 -11
  124. package/dist/native/shared/events.d.ts.map +0 -1
  125. package/dist/native/shared/events.js +0 -13
  126. package/dist/native/shared/events.js.map +0 -1
  127. package/dist/native/shared/icons.d.ts +0 -8
  128. package/dist/native/shared/icons.d.ts.map +0 -1
  129. package/dist/native/shared/icons.js +0 -61
  130. package/dist/native/shared/icons.js.map +0 -1
  131. package/dist/native/shared/modal.d.ts +0 -10
  132. package/dist/native/shared/modal.d.ts.map +0 -1
  133. package/dist/native/shared/modal.js +0 -160
  134. package/dist/native/shared/modal.js.map +0 -1
  135. package/dist/native/vertical-bars-web-search.d.ts +0 -9
  136. package/dist/native/vertical-bars-web-search.d.ts.map +0 -1
  137. package/dist/native/vertical-bars-web-search.js +0 -84
  138. package/dist/native/vertical-bars-web-search.js.map +0 -1
  139. package/dist/native/vertical-bars-web.d.ts +0 -5
  140. package/dist/native/vertical-bars-web.d.ts.map +0 -1
  141. package/dist/native/vertical-bars-web.js +0 -341
  142. package/dist/native/vertical-bars-web.js.map +0 -1
  143. package/dist/native-integration/index.d.ts +0 -23
  144. package/dist/native-integration/index.d.ts.map +0 -1
  145. package/dist/native-integration/index.js.map +0 -1
  146. package/dist/native-integration/transition.d.ts +0 -5
  147. package/dist/native-integration/transition.d.ts.map +0 -1
  148. package/dist/native-integration/transition.js +0 -16
  149. package/dist/native-integration/transition.js.map +0 -1
  150. package/dist/vertical-bars.d.ts +0 -5
  151. package/dist/vertical-bars.js +0 -4
  152. package/docs/e2e-testing.md +0 -51
  153. package/docs/feedback.md +0 -65
  154. package/docs/native-ui-shell.md +0 -285
  155. package/docs/vertical-bars.md +0 -285
  156. package/ios/Sources/IonicNativeUIShellPlugin/Components/ShellButton.swift +0 -71
  157. package/ios/Sources/IonicNativeUIShellPlugin/Components/ShellButtons.swift +0 -24
  158. package/ios/Sources/IonicNativeUIShellPlugin/Components/ShellComponents.swift +0 -18
  159. package/ios/Sources/IonicNativeUIShellPlugin/Components/ShellFab.swift +0 -83
  160. package/ios/Sources/IonicNativeUIShellPlugin/Components/ShellSearchController.swift +0 -432
  161. package/ios/Sources/IonicNativeUIShellPlugin/Components/ShellSegment.swift +0 -91
  162. package/ios/Sources/IonicNativeUIShellPlugin/Components/ShellTabBar.swift +0 -221
  163. package/ios/Sources/IonicNativeUIShellPlugin/Components/ShellVerticalBars.swift +0 -437
  164. package/ios/Sources/IonicNativeUIShellPlugin/Components/ShellVerticalSearch.swift +0 -118
  165. package/ios/Sources/IonicNativeUIShellPlugin/IonicNativeUIShellPlugin.swift +0 -396
  166. package/ios/Sources/IonicNativeUIShellPlugin/Shared/ShellCrossfade.swift +0 -35
  167. package/ios/Sources/IonicNativeUIShellPlugin/Shared/ShellHost.swift +0 -8
  168. package/ios/Sources/IonicNativeUIShellPlugin/Shared/ShellRendering.swift +0 -27
  169. package/ios/Sources/IonicNativeUIShellPlugin/Shared/ShellSnapshot.swift +0 -135
  170. package/ios/Tests/IonicNativeUIShellPluginTests/ShellSnapshotTests.swift +0 -650
  171. package/src/native/components/index.ts +0 -53
  172. package/src/native/components/ion-back-button.ts +0 -19
  173. package/src/native/components/ion-button.ts +0 -24
  174. package/src/native/components/ion-buttons.ts +0 -38
  175. package/src/native/components/ion-fab.ts +0 -151
  176. package/src/native/components/ion-menu-button.ts +0 -24
  177. package/src/native/components/ion-segment.ts +0 -27
  178. package/src/native/components/ion-tab-bar.ts +0 -50
  179. package/src/native/components/searchable-tabs.ts +0 -459
  180. package/src/native/definitions.ts +0 -191
  181. package/src/native/foldable/fold-state.ts +0 -9
  182. package/src/native/foldable/types.ts +0 -4
  183. package/src/native/index.ts +0 -281
  184. package/src/native/prehide.ts +0 -265
  185. package/src/native/runtime.ts +0 -781
  186. package/src/native/shared/candidate.ts +0 -150
  187. package/src/native/shared/crossfade.ts +0 -50
  188. package/src/native/shared/dom.ts +0 -286
  189. package/src/native/shared/events.ts +0 -8
  190. package/src/native/shared/icons.ts +0 -57
  191. package/src/native/shared/modal.ts +0 -157
  192. package/src/native/vertical-bars-web-search.ts +0 -80
  193. package/src/native/vertical-bars-web.ts +0 -411
  194. package/src/native-integration/transition.ts +0 -15
  195. package/src/vertical-bars.ts +0 -11
@@ -1,781 +0,0 @@
1
- import { inVerticalBarsSurface, topModal, modalUsesVerticalBars, modalVerticalBarFrame } from './shared/modal';
2
- import type { PluginListenerHandle } from '@capacitor/core';
3
- import { LIFECYCLE_WILL_ENTER, LIFECYCLE_WILL_LEAVE, LIFECYCLE_DID_ENTER, LIFECYCLE_DID_LEAVE } from '@ionic/core/components/index.js';
4
- import { VERTICAL_BARS_TRANSITION_CANCELED, getNativeSearchBindings, setNativeUIShellIntegration } from '../native-integration';
5
- import { createSearchSupport } from './components/searchable-tabs';
6
- import type {
7
- ShellActivation,
8
- ShellSnapshot,
9
- NativeUIShellHandle,
10
- NativeUIShellOptions,
11
- NativeUIShellPlugin,
12
- NativeUIShellStatus,
13
- } from './definitions';
14
- import { readCandidate, selector, shadowSelector, motionSelector, isVerticalBarsCandidate } from './components';
15
- import {
16
- activateProjectedElement,
17
- createVerticalBarsPageState,
18
- isVerticalBarsSource,
19
- preferredVerticalBarsBack,
20
- marker,
21
- syncToolbarText,
22
- toolbarTextMarker,
23
- prehideOnlyMutation,
24
- rejectedClass,
25
- unprojected,
26
- } from './shared/dom';
27
- import { createIconRenderer } from './shared/icons';
28
- import type { Candidate } from './shared/candidate';
29
- import { CSS_MOTION_EVENTS } from './shared/events';
30
- import { createCrossfade, fadeMarker } from './shared/crossfade';
31
-
32
- const overlays = 'ion-modal, ion-popover, ion-alert, ion-action-sheet, ion-loading, ion-picker, ion-toast, ion-menu';
33
- const overlayNames = ['Modal', 'Popover', 'Alert', 'ActionSheet', 'Loading', 'Picker', 'Toast'];
34
- const verticalBarsMarker = 'data-native-ui-shell-vertical-bars';
35
- const verticalBarsMemberMarker = 'data-native-ui-shell-vertical-bars-member';
36
-
37
- // A failed bridge must not leave the source inaccessible indefinitely.
38
- const bounded = <T>(promise: Promise<T>): Promise<T> =>
39
- new Promise((resolve, reject) => {
40
- const timer = setTimeout(() => reject(new Error('Native UI Shell bridge timed out')), 5000);
41
- promise.then(resolve, reject).finally(() => clearTimeout(timer));
42
- });
43
-
44
- export const createRuntime = async (
45
- doc: Document,
46
- plugin: NativeUIShellPlugin,
47
- options: NativeUIShellOptions = {},
48
- nativeVerticalBars: () => boolean = () => true,
49
- verticalBarsOnly = false,
50
- ): Promise<NativeUIShellHandle> => {
51
- const win = doc.defaultView!;
52
- const icons = createIconRenderer();
53
- const crossfade = createCrossfade(win);
54
- const ids = new WeakMap<Element, string>();
55
- let rejected = new WeakMap<HTMLElement, string>();
56
- const sources = new Map<HTMLElement, string | null>();
57
- const verticalBarsOwners = new Set<HTMLElement>();
58
- const verticalBarsMembers = new Set<HTMLElement>();
59
- const suspended = new Set<HTMLElement[]>();
60
- const pages = new Set<HTMLElement>();
61
- const verticalBarsPages = createVerticalBarsPageState();
62
- const presented = new Set<HTMLElement>();
63
- const manualSuspensions = new Set<symbol>();
64
- const moving = new Map<HTMLElement, Set<string>>();
65
- const observed = new Set<Element | ShadowRoot>();
66
- const listeners = new AbortController();
67
- let actions = new Map<string, HTMLElement>();
68
- let nextId = 0;
69
- let revision = 0;
70
- let acceptedRevision = 0;
71
- let updatingRevision: number | undefined;
72
- let pendingActivations: ShellActivation[] = [];
73
- let lastSequence = 0;
74
- let lastSnapshot = '';
75
- let viewport = `${win.innerWidth}:${win.innerHeight}`;
76
- let forceRefresh = false;
77
- let dirty = false;
78
- let pending = false;
79
- let stopped = false;
80
- /** True while a tab-switch handoff should skip crossfade. */
81
- let tabSwitchHandoff = false;
82
- /** Keep instant updates until this time — DidLeave often precedes the retire sync. */
83
- let handoffUntil = 0;
84
- /** Tab switch armed while a sync was already in flight; extend instant past that sync. */
85
- let handoffAcrossPending = false;
86
- /** Captured at the start of each sync so an in-flight update keeps a stable duration. */
87
- let handoffInstant = false;
88
- /** Retire native controls immediately as a modal starts covering the page. */
89
- let modalPresentHandoff = false;
90
- let frame = 0;
91
- let updates = 0;
92
- let reason: string | undefined;
93
- let listener: PluginListenerHandle | undefined;
94
- let searchListener: PluginListenerHandle | undefined;
95
- let waiters: (() => void)[] = [];
96
- const control = (kind: Candidate['control']['kind']): keyof NonNullable<NativeUIShellOptions['controls']> => {
97
- if (kind === 'ion-tab-bar') return 'tabs';
98
- if (kind === 'ion-segment') return 'segment';
99
- if (kind === 'ion-fab') return 'fab';
100
- return 'toolbar';
101
- };
102
- const controlEnabled = (candidate: Candidate) => {
103
- const controls = options.controls;
104
- return controls === undefined || controls[control(candidate.control.kind)] === true;
105
- };
106
- const id = (element: Element) => {
107
- let value = ids.get(element);
108
- if (!value) {
109
- value = `shell-${++nextId}`;
110
- ids.set(element, value);
111
- }
112
- return value;
113
- };
114
- const style = doc.createElement('style');
115
- const hidden = `[${marker}]:not([${fadeMarker}])`;
116
- style.textContent = `${hidden}, ${hidden} *, ${hidden}::before, ${hidden}::after, ${hidden}::part(native) { visibility: hidden !important; }
117
- [${marker}], [${marker}] * { pointer-events: none !important; }
118
- /* Ionic disables the covered page while a menu is open. VerticalBars rail
119
- controls remain outside that page; zero specificity preserves any
120
- pointer-events rule supplied by the application itself. */
121
- :where(.menu-content-open) :where([${verticalBarsMarker}]) {
122
- pointer-events: auto;
123
- }
124
- :where(.menu-content-open) :where([${verticalBarsMarker}]) > :where(:not([${verticalBarsMemberMarker}])) {
125
- pointer-events: none;
126
- }`;
127
-
128
- const restore = (element: HTMLElement) => {
129
- lastSnapshot = '';
130
- search.release(element);
131
- element.removeAttribute(marker);
132
- if (!stopped) crossfade.play(element, false, isVerticalBarsSource(element) ? !element.matches('ion-tab-bar') : handoffInstant);
133
- if (element.getAttribute('aria-hidden') === 'true') {
134
- const previous = sources.get(element);
135
- if (previous == null) element.removeAttribute('aria-hidden');
136
- else element.setAttribute('aria-hidden', previous);
137
- }
138
- sources.delete(element);
139
- element.dispatchEvent(new CustomEvent('nativeUIShellChange'));
140
- };
141
- const restoreAll = () => {
142
- Array.from(sources.keys()).forEach(restore);
143
- verticalBarsOwners.forEach((element) => element.removeAttribute(verticalBarsMarker));
144
- verticalBarsOwners.clear();
145
- verticalBarsMembers.forEach((element) => element.removeAttribute(verticalBarsMemberMarker));
146
- verticalBarsMembers.clear();
147
- };
148
- const finishWaiters = () => {
149
- const current = waiters;
150
- waiters = [];
151
- current.forEach((resolve) => resolve());
152
- };
153
- const schedule = () => {
154
- if (stopped) return;
155
- dirty = true;
156
- if (!pending && !frame) frame = win.requestAnimationFrame(() => void sync());
157
- };
158
- const search = createSearchSupport(doc, id, schedule);
159
- const candidateSources = (candidate: Candidate) => candidate.sources ?? [candidate.element];
160
- const setRejected = (element: HTMLElement, value: boolean) => {
161
- element.classList.toggle(rejectedClass, value);
162
- };
163
- const measuringPointerPages = new WeakSet<HTMLElement>();
164
- const readEnabledCandidate = (element: HTMLElement): Candidate | undefined => {
165
- if (element.matches('ion-back-button') && element.closest('ion-app.ios-theme-vertical-bars') && !isVerticalBarsCandidate(element))
166
- return;
167
- if (verticalBarsOnly && !isVerticalBarsCandidate(element)) return;
168
- const pointerPage = isVerticalBarsCandidate(element) ? element.closest<HTMLElement>('.ion-page') : undefined;
169
- let candidate: Candidate | undefined;
170
- if (pointerPage && getComputedStyle(pointerPage).pointerEvents === 'none') {
171
- const previous = pointerPage.style.getPropertyValue('pointer-events');
172
- const priority = pointerPage.style.getPropertyPriority('pointer-events');
173
- const hadStyle = pointerPage.hasAttribute('style');
174
- measuringPointerPages.add(pointerPage);
175
- pointerPage.style.setProperty('pointer-events', 'auto', 'important');
176
- try {
177
- candidate = readCandidate(element, id, options);
178
- } finally {
179
- if (previous) pointerPage.style.setProperty('pointer-events', previous, priority);
180
- else pointerPage.style.removeProperty('pointer-events');
181
- if (!hadStyle && !pointerPage.style.length) pointerPage.removeAttribute('style');
182
- win.setTimeout(() => measuringPointerPages.delete(pointerPage), 0);
183
- }
184
- } else candidate = readCandidate(element, id, options);
185
- if (candidate && isVerticalBarsCandidate(element)) {
186
- if (!nativeVerticalBars()) return undefined;
187
- candidate.control.placement = 'vertical-bars';
188
- if (['ion-button', 'ion-buttons', 'ion-menu-button'].includes(candidate.control.kind)) {
189
- const slot = (element.matches('ion-buttons') ? element : (element.closest('ion-buttons') ?? element)).getAttribute('slot');
190
- if (slot === 'start' || slot === 'end') candidate.control.toolbarSlot = slot;
191
- }
192
- }
193
- return candidate && controlEnabled(candidate) ? candidate : undefined;
194
- };
195
- const flush = async () => {
196
- if (stopped) return;
197
- schedule();
198
- try {
199
- await bounded(new Promise<void>((resolve) => waiters.push(resolve)));
200
- } catch (error) {
201
- await fail(error);
202
- }
203
- };
204
- const blocked = (element: HTMLElement) =>
205
- verticalBarsPages.isDeparted(element) ||
206
- (!isVerticalBarsSource(element) &&
207
- (Array.from(suspended).some((scopes) => scopes.some((scope) => scope.contains(element))) ||
208
- Array.from(pages).some((scope) => scope.contains(element)) ||
209
- Array.from(moving.keys()).some((surface) => surface.contains(element))));
210
- const painted = () => new Promise<void>((resolve) => win.requestAnimationFrame(() => win.requestAnimationFrame(() => resolve())));
211
- const overlayOpen = (includeMenu = true, allowModal = false) => {
212
- const modal = topModal(doc);
213
- const ignored = (element: Element) => allowModal && !!modal && modalUsesVerticalBars(modal) && element.matches('ion-modal');
214
- for (const element of presented) if (!element.isConnected) presented.delete(element);
215
- const presentedOverlayOpen = Array.from(presented).some(
216
- (element) => !ignored(element) && (includeMenu || !element.matches('ion-menu')),
217
- );
218
- return (
219
- manualSuspensions.size > 0 ||
220
- presentedOverlayOpen ||
221
- Array.from(doc.querySelectorAll(overlays)).some(
222
- (element) =>
223
- !ignored(element) &&
224
- (includeMenu || !element.matches('ion-menu')) &&
225
- ((element as Element & { presented?: boolean }).presented || element.classList.contains('show-menu')),
226
- )
227
- );
228
- };
229
- // Compare source data before PNG rendering mutates each item's payload.
230
- const signature = (candidate: Candidate) =>
231
- JSON.stringify({ control: candidate.control, icons: candidate.icons.map(({ source }) => source) });
232
- const read = (): Candidate[] => {
233
- search.keepSearchTabsVisible();
234
- for (const page of pages) if (!page.isConnected) pages.delete(page);
235
- for (const surface of moving.keys()) if (!surface.isConnected) moving.delete(surface);
236
- if (doc.hidden || overlayOpen(false, true)) return [];
237
- if (win.visualViewport && (win.visualViewport.scale !== 1 || win.visualViewport.offsetTop !== 0) && !search.hasActive()) return [];
238
- const menuOpen = overlayOpen();
239
- const candidates = unprojected(sources.keys(), () =>
240
- search
241
- .decorate(
242
- Array.from(doc.querySelectorAll<HTMLElement>(selector))
243
- .filter(
244
- (element) =>
245
- inVerticalBarsSurface(element) &&
246
- !verticalBarsPages.isDeparted(element) &&
247
- (!blocked(element) || (menuOpen && isVerticalBarsSource(element))),
248
- )
249
- .map(readEnabledCandidate)
250
- .filter((candidate): candidate is Candidate => !!candidate),
251
- blocked,
252
- )
253
- .filter((candidate) => !rejected.has(candidate.element) || rejected.get(candidate.element) !== signature(candidate)),
254
- );
255
- const back = preferredVerticalBarsBack(
256
- candidates
257
- .filter((candidate) => candidate.control.kind === 'ion-back-button' && isVerticalBarsCandidate(candidate.element))
258
- .map((candidate) => candidate.element),
259
- doc,
260
- );
261
- const selected = candidates.filter(
262
- (candidate) =>
263
- candidate.control.kind !== 'ion-back-button' || !isVerticalBarsCandidate(candidate.element) || candidate.element === back,
264
- );
265
- return menuOpen ? selected.filter((candidate) => isVerticalBarsCandidate(candidate.element)) : selected;
266
- };
267
- const observe = () => {
268
- const wanted = new Set<Element | ShadowRoot>();
269
- for (const element of Array.from(doc.querySelectorAll<HTMLElement>(selector))) {
270
- wanted.add(element);
271
- if (element.parentElement) wanted.add(element.parentElement);
272
- const inspectShadow = (node: Element) => {
273
- if (node.shadowRoot) {
274
- wanted.add(node.shadowRoot);
275
- node.shadowRoot.querySelectorAll('ion-icon').forEach(inspectShadow);
276
- }
277
- };
278
- inspectShadow(element);
279
- element.querySelectorAll(shadowSelector).forEach(inspectShadow);
280
- }
281
- // Reconnect only when the set changes; no per-frame observer allocation.
282
- if (wanted.size === observed.size && Array.from(wanted).every((element) => observed.has(element))) return;
283
- observer.disconnect();
284
- resize.disconnect();
285
- observed.clear();
286
- observer.observe(doc.documentElement, observation);
287
- for (const element of wanted) {
288
- observed.add(element);
289
- if (element instanceof ShadowRoot) observer.observe(element, observation);
290
- else resize.observe(element);
291
- }
292
- };
293
- const fail = async (error: unknown) => {
294
- reason = error instanceof Error ? error.message : String(error);
295
- console.warn('[Native UI Shell] Returning to Web:', reason);
296
- await handle.destroy();
297
- // The Web fallback re-evaluates eligibility once native projection is stopped.
298
- win.dispatchEvent(new Event('nativeUIShellRefresh'));
299
- };
300
- const sync = async () => {
301
- frame = 0;
302
- dirty = false;
303
- pending = true;
304
- syncToolbarText(doc);
305
- handoffInstant = tabSwitchHandoff || handoffAcrossPending || modalPresentHandoff || win.performance.now() < handoffUntil;
306
- modalPresentHandoff = false;
307
- try {
308
- const size = `${win.innerWidth}:${win.innerHeight}`;
309
- // WebKit can resize before Ionic's fixed DOM positions catch up.
310
- // Measure on the next frame instead of retiring a valid native search.
311
- if (viewport !== size) {
312
- viewport = size;
313
- dirty = true;
314
- return;
315
- }
316
- observe();
317
- const candidates = read();
318
- const signatures = new Map(candidates.map((candidate) => [candidate.element, signature(candidate)]));
319
- for (const candidate of candidates) {
320
- for (const icon of candidate.icons) {
321
- const field = icon.field ?? 'icon';
322
- icon.item[field] = await icons.render(
323
- icon.source,
324
- field === 'icon' ? icon.item.iconWidth! : icon.item.closeIconWidth!,
325
- field === 'icon' ? icon.item.iconHeight! : icon.item.closeIconHeight!,
326
- );
327
- }
328
- }
329
- if (stopped || dirty) return;
330
- const retained = new Set(candidates.flatMap(candidateSources));
331
- const removed = Array.from(sources.keys()).filter((element) => !retained.has(element));
332
- if (removed.length) {
333
- // Restore the source and let WebKit paint before removing its native cover.
334
- removed.forEach(restore);
335
- // The outgoing tab is no longer visible, so waiting two frames only leaves its
336
- // native snapshot over the destination. Stack transitions still need the paint.
337
- if (!handoffInstant && removed.some((element) => !isVerticalBarsSource(element))) {
338
- await painted();
339
- if (stopped || dirty) return;
340
- }
341
- }
342
- const root = doc.querySelector('ion-app.ios-theme-vertical-bars');
343
- const verticalBarEdge: 'left' | 'right' | undefined = root
344
- ? root.classList.contains('ios-theme-vertical-bars-left')
345
- ? 'left'
346
- : 'right'
347
- : undefined;
348
- const modal = topModal(doc);
349
- const verticalBarFrame = modal && modalUsesVerticalBars(modal) ? modalVerticalBarFrame(modal) : undefined;
350
- const data = {
351
- verticalBarFrame,
352
- viewportWidth: win.innerWidth,
353
- verticalBarEdge,
354
- controls: candidates.map((candidate) => candidate.control),
355
- };
356
- const serialized = JSON.stringify(data);
357
- if (serialized === lastSnapshot && !forceRefresh) return;
358
- const snapshot: ShellSnapshot = { ...data, revision: ++revision, transitionDuration: crossfade.duration(handoffInstant) };
359
- // A native visibility notification during this update must survive its ack.
360
- forceRefresh = false;
361
- updates++;
362
- updatingRevision = snapshot.revision;
363
- const result = await bounded(plugin.update(snapshot));
364
- if (stopped) return;
365
- if (result.revision !== snapshot.revision) throw new Error('Native UI Shell revision mismatch');
366
- if (`${win.innerWidth}:${win.innerHeight}` !== size) {
367
- lastSnapshot = '';
368
- dirty = true;
369
- return;
370
- }
371
- if (result.rejectedSearches?.length) {
372
- search.reject(result.rejectedSearches);
373
- lastSnapshot = '';
374
- dirty = true;
375
- }
376
- for (const candidate of candidates) {
377
- if (result.rejectedControls?.includes(candidate.control.id)) {
378
- rejected.set(candidate.element, signatures.get(candidate.element)!);
379
- setRejected(candidate.element, true);
380
- dirty = true;
381
- }
382
- }
383
- // A page mutation must not tear down unchanged shared controls such as tabs.
384
- const currentCandidates = dirty ? read() : candidates;
385
- const current = dirty ? new Map(currentCandidates.map((candidate) => [candidate.element, signature(candidate)])) : signatures;
386
- const currentSources = new Set(currentCandidates.flatMap(candidateSources));
387
- const accepted = candidates.filter((candidate) => current.get(candidate.element) === signatures.get(candidate.element));
388
- accepted.forEach((candidate) => setRejected(candidate.element, false));
389
- const acceptedVerticalBarsOwners = new Set(
390
- accepted.filter((candidate) => candidate.control.placement === 'vertical-bars').map((candidate) => candidate.element),
391
- );
392
- const acceptedVerticalBarsMembers = new Set(
393
- accepted
394
- .filter((candidate) => candidate.control.placement === 'vertical-bars')
395
- .flatMap((candidate) => Array.from(candidate.actions.values())),
396
- );
397
- const invalidated = candidates.length !== accepted.length;
398
- acceptedRevision = result.revision;
399
- lastSnapshot = invalidated ? '' : serialized;
400
- actions = new Map(
401
- candidates.filter((candidate) => current.has(candidate.element)).flatMap((candidate) => Array.from(candidate.actions)),
402
- );
403
- // Keep an existing cover while its content catches up. Only an ineligible
404
- // source needs to return to Web; new sources still require an exact ack.
405
- for (const element of sources.keys()) if (!currentSources.has(element)) restore(element);
406
- for (const element of verticalBarsOwners) {
407
- if (acceptedVerticalBarsOwners.has(element)) continue;
408
- element.removeAttribute(verticalBarsMarker);
409
- verticalBarsOwners.delete(element);
410
- }
411
- for (const element of acceptedVerticalBarsOwners) {
412
- element.setAttribute(verticalBarsMarker, '');
413
- verticalBarsOwners.add(element);
414
- }
415
- for (const element of verticalBarsMembers) {
416
- if (acceptedVerticalBarsMembers.has(element)) continue;
417
- element.removeAttribute(verticalBarsMemberMarker);
418
- verticalBarsMembers.delete(element);
419
- }
420
- for (const element of acceptedVerticalBarsMembers) {
421
- element.setAttribute(verticalBarsMemberMarker, '');
422
- verticalBarsMembers.add(element);
423
- }
424
- for (const element of accepted.flatMap(candidateSources)) {
425
- const newlyProjected = !sources.has(element) || !element.hasAttribute(marker);
426
- if (!sources.has(element)) {
427
- sources.set(element, element.getAttribute('aria-hidden'));
428
- crossfade.play(element, true, handoffInstant || isVerticalBarsSource(element));
429
- }
430
- element.setAttribute(marker, '');
431
- element.setAttribute('aria-hidden', 'true');
432
- if (newlyProjected) element.dispatchEvent(new CustomEvent('nativeUIShellChange'));
433
- }
434
- const received = pendingActivations;
435
- pendingActivations = [];
436
- received.forEach(activate);
437
- await crossfade.settled();
438
- if (invalidated) {
439
- dirty = true;
440
- // Sources that became ineligible must paint before their cover is removed.
441
- await painted();
442
- }
443
- } catch (error) {
444
- await fail(error);
445
- } finally {
446
- updatingRevision = undefined;
447
- pendingActivations = [];
448
- // A refresh received before the ack must also invalidate that ack's rejects.
449
- if (forceRefresh) rejected = new WeakMap();
450
- // A tab switch mid-update (or a dirty follow-up) must keep instant through the retire sync.
451
- if (!stopped && (handoffAcrossPending || (handoffInstant && dirty))) {
452
- handoffUntil = Math.max(handoffUntil, win.performance.now() + 400);
453
- }
454
- handoffAcrossPending = false;
455
- pending = false;
456
- if (dirty && !stopped) schedule();
457
- else finishWaiters();
458
- }
459
- };
460
- const observation: MutationObserverInit = {
461
- subtree: true,
462
- childList: true,
463
- characterData: true,
464
- attributes: true,
465
- attributeOldValue: true,
466
- };
467
- const observer = new MutationObserver((records) => {
468
- if (
469
- records.some(
470
- (record) =>
471
- record.attributeName !== marker &&
472
- record.attributeName !== toolbarTextMarker &&
473
- record.attributeName !== fadeMarker &&
474
- !prehideOnlyMutation(record) &&
475
- !(record.attributeName === 'style' && measuringPointerPages.has(record.target as HTMLElement)) &&
476
- !(
477
- record.attributeName === 'aria-hidden' &&
478
- sources.has(record.target as HTMLElement) &&
479
- (record.target as Element).getAttribute('aria-hidden') === 'true'
480
- ),
481
- )
482
- )
483
- schedule();
484
- });
485
- const resize = new ResizeObserver(schedule);
486
- const on = (target: EventTarget, name: string, callback: EventListener = schedule) =>
487
- target.addEventListener(name, callback, { capture: true, signal: listeners.signal });
488
- const pageWill: EventListener = (event) => {
489
- const page = event.target as HTMLElement;
490
- verticalBarsPages.lifecycle(event);
491
- getNativeSearchBindings(doc)
492
- .filter((binding) => page.contains(binding.footer))
493
- .forEach((binding) => search.retire(binding));
494
- // Angular updates the URL before willLeave, but keeps ion-tab-bar.selectedTab on the
495
- // leaving tab until DidChange. A mismatch means this leave is a tab switch, not a stack push.
496
- if (event.type === LIFECYCLE_WILL_LEAVE) beginTabSwitchHandoffIfNeeded(page);
497
- pages.add(page);
498
- schedule();
499
- };
500
- const pageDid: EventListener = (event) => {
501
- const page = event.target as HTMLElement;
502
- verticalBarsPages.lifecycle(event);
503
- pages.delete(page);
504
- schedule();
505
- if (tabSwitchHandoff && pages.size === 0) endTabSwitchHandoff();
506
- };
507
- const tabOfPath = (tabs: Element, pathname: string) => {
508
- let best: { tab: string; length: number } | undefined;
509
- for (const button of Array.from(tabs.querySelectorAll('ion-tab-button'))) {
510
- const tab = button.getAttribute('tab');
511
- const href = button.getAttribute('href')?.split(/[?#]/)[0];
512
- if (!tab || !href) continue;
513
- if (pathname === href || pathname.startsWith(`${href}/`)) {
514
- if (!best || href.length > best.length) best = { tab, length: href.length };
515
- }
516
- }
517
- return best?.tab;
518
- };
519
- const armTabSwitchHandoff = () => {
520
- tabSwitchHandoff = true;
521
- // Retiring outgoing controls often lands in a later async sync than WillLeave/DidChange.
522
- handoffUntil = Math.max(handoffUntil, win.performance.now() + 400);
523
- // The in-flight sync already captured handoffInstant=false; hold instant for the next one.
524
- if (pending) handoffAcrossPending = true;
525
- };
526
- const beginTabSwitchHandoffIfNeeded = (page: HTMLElement) => {
527
- const tabs = page.closest('ion-tabs');
528
- if (!tabs) return;
529
- const bar = tabs.querySelector('ion-tab-bar');
530
- const selected =
531
- (bar && 'selectedTab' in bar ? String((bar as HTMLElement & { selectedTab?: string }).selectedTab ?? '') : '') ||
532
- tabs.querySelector('ion-tab-button.tab-selected')?.getAttribute('tab') ||
533
- undefined;
534
- const destination = tabOfPath(tabs, win.location.pathname);
535
- if (selected && destination && selected !== destination) armTabSwitchHandoff();
536
- };
537
- // DidChange / pageDid can land in the same turn as WillLeave. Clear the sticky flag on the
538
- // next frame; handoffUntil / handoffAcrossPending still cover the async retire sync.
539
- const endTabSwitchHandoff = () => {
540
- win.requestAnimationFrame(() => {
541
- if (stopped || !tabSwitchHandoff) return;
542
- tabSwitchHandoff = false;
543
- schedule();
544
- });
545
- };
546
- const motion: EventListener = (event) => {
547
- const target = event.target as HTMLElement;
548
- if (!target.matches?.(motionSelector)) return;
549
- const key = (event as TransitionEvent).propertyName ?? (event as AnimationEvent).animationName;
550
- if (event.type === CSS_MOTION_EVENTS.transitionRun || event.type === CSS_MOTION_EVENTS.animationStart) {
551
- const keys = moving.get(target) ?? new Set<string>();
552
- keys.add(key);
553
- moving.set(target, keys);
554
- } else {
555
- moving.get(target)?.delete(key);
556
- if (!moving.get(target)?.size) moving.delete(target);
557
- }
558
- schedule();
559
- };
560
- for (const name of Object.values(CSS_MOTION_EVENTS)) on(doc, name, motion);
561
- for (const name of [LIFECYCLE_WILL_ENTER, LIFECYCLE_WILL_LEAVE]) on(doc, name, pageWill);
562
- for (const name of [LIFECYCLE_DID_ENTER, LIFECYCLE_DID_LEAVE]) on(doc, name, pageDid);
563
- on(doc, VERTICAL_BARS_TRANSITION_CANCELED, (event) => {
564
- const leaving = event.target as HTMLElement;
565
- const entering = (event as CustomEvent<{ entering?: HTMLElement }>).detail?.entering;
566
- verticalBarsPages.cancel(entering, leaving);
567
- pages.delete(leaving);
568
- if (entering) pages.delete(entering);
569
- schedule();
570
- });
571
- on(doc, 'ionTabsWillChange', () => {
572
- // Vanilla ion-tabs dispatches DOM events; @ionic/angular uses EventEmitters instead.
573
- armTabSwitchHandoff();
574
- schedule();
575
- });
576
- on(doc, 'ionTabsDidChange', endTabSwitchHandoff);
577
- for (const name of overlayNames) {
578
- on(doc, `ion${name}WillPresent`, (event) => {
579
- presented.add(event.target as HTMLElement);
580
- if (name === 'Modal') {
581
- modalPresentHandoff = true;
582
- // WillPresent may arrive while another bridge update is awaiting its ack.
583
- // Make that retirement instant too instead of racing the modal animation.
584
- if (pending) handoffInstant = true;
585
- }
586
- schedule();
587
- });
588
- on(doc, `ion${name}DidDismiss`, (event) => {
589
- presented.delete(event.target as HTMLElement);
590
- schedule();
591
- });
592
- }
593
- const eventMenu = (event: Event) =>
594
- event.composedPath().find((target): target is HTMLElement => target instanceof HTMLElement && target.matches('ion-menu'));
595
- on(doc, 'ionWillOpen', (event) => {
596
- const menu = eventMenu(event);
597
- if (menu) presented.add(menu);
598
- schedule();
599
- });
600
- on(doc, 'ionDidClose', (event) => {
601
- const menu = eventMenu(event);
602
- if (menu) presented.delete(menu);
603
- schedule();
604
- });
605
- for (const name of [
606
- 'ionChange',
607
- 'ionSelect',
608
- 'ionImgDidLoad',
609
- CSS_MOTION_EVENTS.transitionEnd,
610
- CSS_MOTION_EVENTS.animationEnd,
611
- 'focusin',
612
- 'focusout',
613
- ])
614
- on(doc, name);
615
- const refreshLayout = () => {
616
- rejected = new WeakMap();
617
- forceRefresh = true;
618
- schedule();
619
- };
620
- on(doc, 'visibilitychange', () => {
621
- if (doc.hidden) {
622
- getNativeSearchBindings(doc).forEach((binding) => search.retire(binding));
623
- schedule();
624
- } else refreshLayout();
625
- });
626
- on(win, 'resize', refreshLayout);
627
- on(win, 'keyboardWillShow', () => search.keyboard(true));
628
- on(win, 'keyboardWillHide', () => search.keyboard(false));
629
- on(win, 'scroll');
630
- on(win.matchMedia('(prefers-color-scheme: dark)'), 'change');
631
- on(win, 'nativeUIShellRefresh', (event) => {
632
- if ((event as Event & { retireSearch?: boolean }).retireSearch)
633
- getNativeSearchBindings(doc).forEach((binding) => search.retire(binding));
634
- refreshLayout();
635
- });
636
- if (win.visualViewport) {
637
- on(win.visualViewport, 'resize', refreshLayout);
638
- on(win.visualViewport, 'scroll');
639
- }
640
- const handle: NativeUIShellHandle = {
641
- getStatus: (): NativeUIShellStatus => ({
642
- state: stopped ? 'stopped' : sources.size ? 'native' : 'web',
643
- projected: sources.size,
644
- updates,
645
- reason,
646
- }),
647
- async suspend() {
648
- const token = Symbol();
649
- let resumed = false;
650
- if (!stopped) {
651
- manualSuspensions.add(token);
652
- getNativeSearchBindings(doc).forEach((binding) => search.retire(binding));
653
- await flush();
654
- }
655
- return {
656
- async resume() {
657
- if (resumed) return;
658
- resumed = true;
659
- if (stopped || !manualSuspensions.delete(token)) return;
660
- await flush();
661
- },
662
- };
663
- },
664
- async destroy() {
665
- if (stopped) return;
666
- stopped = true;
667
- setNativeUIShellIntegration(doc);
668
- win.cancelAnimationFrame(frame);
669
- listeners.abort();
670
- observer.disconnect();
671
- resize.disconnect();
672
- observed.clear();
673
- actions.clear();
674
- pendingActivations = [];
675
- search.destroy();
676
- crossfade.destroy();
677
- restoreAll();
678
- if (!doc.hidden) await painted();
679
- try {
680
- await bounded(plugin.clear({ revision: ++revision }));
681
- } catch {
682
- /* Always restore the Web, even after bridge loss. */
683
- }
684
- style.remove();
685
- doc.querySelectorAll<HTMLElement>(`.${rejectedClass}`).forEach((element) => setRejected(element, false));
686
- icons.clear();
687
- pages.clear();
688
- presented.clear();
689
- manualSuspensions.clear();
690
- moving.clear();
691
- suspended.clear();
692
- await listener?.remove().catch(() => {});
693
- await searchListener?.remove().catch(() => {});
694
- finishWaiters();
695
- },
696
- };
697
- const activate = (event: ShellActivation) => {
698
- if (
699
- stopped ||
700
- doc.hidden ||
701
- event.revision < acceptedRevision ||
702
- event.revision > revision ||
703
- event.sequence <= lastSequence ||
704
- overlayOpen(false, true)
705
- )
706
- return;
707
- // Native may send input before update() resolves on the JS bridge.
708
- // Revalidate it after ownership is accepted, using the same action path.
709
- if (event.revision > acceptedRevision && event.revision === updatingRevision) {
710
- pendingActivations.push(event);
711
- return;
712
- }
713
- lastSequence = event.sequence;
714
- const element = actions.get(event.id);
715
- if (!element) return;
716
- const owner = Array.from(sources.keys()).find((source) => source === element || source.contains(element));
717
- if (!owner || !inVerticalBarsSurface(owner)) return;
718
- const direct = !blocked(owner) && unprojected(sources.keys(), () => readEnabledCandidate(owner));
719
- const candidate = direct || read().find((candidate) => candidate.actions.has(event.id));
720
- const item = candidate?.control.items.find((item) => item.id === event.id);
721
- const searchAction =
722
- candidate?.control.search && [candidate.control.search.trigger.id, candidate.control.search.closeId].includes(event.id);
723
- if (!searchAction && (!item || item.disabled || item.visible === false)) return;
724
- // The original Ionic host owns form submission, routerLink and selection events.
725
- activateProjectedElement(element);
726
- lastSnapshot = ''; // Reconcile even if Ionic rejects the proposed native selection.
727
- schedule();
728
- };
729
- try {
730
- listener = await bounded(plugin.addListener('activate', activate));
731
- searchListener = await bounded(
732
- plugin.addListener('search', (event) => {
733
- if (stopped || doc.hidden || event.revision < acceptedRevision || event.revision > revision || overlayOpen()) return;
734
- search.event(event);
735
- }),
736
- );
737
- doc.head.append(style);
738
- observer.observe(doc.documentElement, observation);
739
- setNativeUIShellIntegration(doc, {
740
- async search(binding, active, focus) {
741
- if (!getNativeSearchBindings(doc).includes(binding) || !search.projected(binding)) return false;
742
- if (!active) {
743
- search.setStatus(binding, false);
744
- } else {
745
- const entering = !binding.active;
746
- if (entering) search.begin(binding, revision + 1);
747
- const nextFocused = focus === true ? true : focus === false ? false : entering ? false : binding.focused;
748
- search.setStatus(binding, true, nextFocused);
749
- }
750
- await flush();
751
- return !stopped && search.projected(binding);
752
- },
753
- async suspend(scopes) {
754
- getNativeSearchBindings(doc)
755
- .filter((binding) => scopes.some((scope) => scope.contains(binding.footer) || scope.contains(binding.tabBar)))
756
- .forEach((binding) => search.retire(binding));
757
- suspended.add(scopes);
758
- await flush();
759
- // Source DOM has been restored before Ionic starts moving it.
760
- await new Promise<void>((resolve) => win.requestAnimationFrame(() => resolve()));
761
- return (canceled = false) => {
762
- suspended.delete(scopes);
763
- if (canceled || !scopes.some((scope) => scope.closest('ion-app.ios-theme-vertical-bars'))) {
764
- scopes.forEach((scope) => pages.delete(scope)); // Preserve ordinary iPhone handoff; cancellation has no DidLeave.
765
- if (canceled) {
766
- verticalBarsPages.cancel(scopes[0], scopes[1]); // The entering page is abandoned; the leaving page stays active.
767
- }
768
- }
769
- schedule();
770
- };
771
- },
772
- });
773
- on(win, 'pagehide', () => {
774
- void handle.destroy();
775
- });
776
- schedule();
777
- } catch (error) {
778
- await fail(error);
779
- }
780
- return handle;
781
- };