@rdlabo/ionic-theme-ios27 1.2.1-beta.pr270.shac2166fdf91be → 1.2.1-beta.pr273.shae866fb1dca9f
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/dist/native/definitions.d.ts +32 -0
- package/dist/native/definitions.d.ts.map +1 -1
- package/dist/native/index.d.ts.map +1 -1
- package/dist/native/index.js +23 -6
- package/dist/native/index.js.map +1 -1
- package/dist/native/overlays/content.d.ts +4 -0
- package/dist/native/overlays/content.d.ts.map +1 -0
- package/dist/native/overlays/content.js +51 -0
- package/dist/native/overlays/content.js.map +1 -0
- package/dist/native/overlays/controller.d.ts +8 -0
- package/dist/native/overlays/controller.d.ts.map +1 -0
- package/dist/native/overlays/controller.js +266 -0
- package/dist/native/overlays/controller.js.map +1 -0
- package/dist/native/overlays/dialog-animation.d.ts +8 -0
- package/dist/native/overlays/dialog-animation.d.ts.map +1 -0
- package/dist/native/overlays/dialog-animation.js +31 -0
- package/dist/native/overlays/dialog-animation.js.map +1 -0
- package/dist/native/overlays/dismiss-animation.d.ts +4 -0
- package/dist/native/overlays/dismiss-animation.d.ts.map +1 -0
- package/dist/native/overlays/dismiss-animation.js +18 -0
- package/dist/native/overlays/dismiss-animation.js.map +1 -0
- package/dist/native/overlays/focus.d.ts +5 -0
- package/dist/native/overlays/focus.d.ts.map +1 -0
- package/dist/native/overlays/focus.js +59 -0
- package/dist/native/overlays/focus.js.map +1 -0
- package/dist/native/overlays/popover.d.ts +11 -0
- package/dist/native/overlays/popover.d.ts.map +1 -0
- package/dist/native/overlays/popover.js +78 -0
- package/dist/native/overlays/popover.js.map +1 -0
- package/dist/native/overlays/styles.d.ts +9 -0
- package/dist/native/overlays/styles.d.ts.map +1 -0
- package/dist/native/overlays/styles.js +82 -0
- package/dist/native/overlays/styles.js.map +1 -0
- package/dist/native/runtime.d.ts +4 -1
- package/dist/native/runtime.d.ts.map +1 -1
- package/dist/native/runtime.js +25 -5
- package/dist/native/runtime.js.map +1 -1
- package/dist/native/shared/projection-id.d.ts +4 -0
- package/dist/native/shared/projection-id.d.ts.map +1 -0
- package/dist/native/shared/projection-id.js +7 -0
- package/dist/native/shared/projection-id.js.map +1 -0
- package/docs/native-ui-shell.md +18 -2
- package/ios/Sources/IonicNativeUIShellPlugin/Components/ShellVerticalBars.swift +75 -1
- package/ios/Sources/IonicNativeUIShellPlugin/IonicNativeUIShellPlugin.swift +57 -1
- package/ios/Sources/IonicNativeUIShellPlugin/Overlays/ShellOverlayController.swift +116 -0
- package/ios/Sources/IonicNativeUIShellPlugin/Overlays/ShellOverlayHost.swift +36 -0
- package/ios/Tests/IonicNativeUIShellPluginTests/ShellSnapshotTests.swift +27 -0
- package/package.json +1 -1
- package/src/native/definitions.ts +27 -1
- package/src/native/index.ts +23 -6
- package/src/native/overlays/content.ts +51 -0
- package/src/native/overlays/controller.ts +322 -0
- package/src/native/overlays/dialog-animation.ts +30 -0
- package/src/native/overlays/dismiss-animation.ts +15 -0
- package/src/native/overlays/focus.ts +64 -0
- package/src/native/overlays/popover.ts +80 -0
- package/src/native/overlays/styles.ts +80 -0
- package/src/native/runtime.ts +34 -14
- package/src/native/shared/projection-id.ts +2 -0
|
@@ -8,6 +8,7 @@ export interface NativeUIShellStatus {
|
|
|
8
8
|
reason?: string;
|
|
9
9
|
}
|
|
10
10
|
export interface VerticalControlAreaOptions {
|
|
11
|
+
controls?: Pick<NativeUIShellControls, 'popover'>;
|
|
11
12
|
buttonProjection?: 'source' | 'system';
|
|
12
13
|
buttonDefaultFill?: 'solid' | null;
|
|
13
14
|
}
|
|
@@ -21,6 +22,7 @@ export interface NativeUIShellControls {
|
|
|
21
22
|
toolbar?: boolean;
|
|
22
23
|
segment?: boolean;
|
|
23
24
|
fab?: boolean;
|
|
25
|
+
popover?: boolean;
|
|
24
26
|
}
|
|
25
27
|
export interface NativeUIShellHandle {
|
|
26
28
|
getStatus(): NativeUIShellStatus;
|
|
@@ -135,6 +137,21 @@ export interface NativeUIShellPlugin {
|
|
|
135
137
|
supported: boolean;
|
|
136
138
|
}>;
|
|
137
139
|
getWebViewMetrics(): Promise<WebViewMetrics>;
|
|
140
|
+
prepareOverlay(options: {
|
|
141
|
+
id: string;
|
|
142
|
+
}): Promise<void>;
|
|
143
|
+
presentOverlay(options: {
|
|
144
|
+
id: string;
|
|
145
|
+
presentation?: ShellPopoverPresentation;
|
|
146
|
+
}): Promise<void>;
|
|
147
|
+
dismissOverlay(options: {
|
|
148
|
+
id: string;
|
|
149
|
+
animated: boolean;
|
|
150
|
+
}): Promise<void>;
|
|
151
|
+
closeOverlay(options: {
|
|
152
|
+
id: string;
|
|
153
|
+
}): Promise<void>;
|
|
154
|
+
stopOverlays(): Promise<void>;
|
|
138
155
|
update(snapshot: ShellSnapshot): Promise<{
|
|
139
156
|
revision: number;
|
|
140
157
|
rejectedSearches?: string[];
|
|
@@ -146,6 +163,21 @@ export interface NativeUIShellPlugin {
|
|
|
146
163
|
addListener(name: 'activate', listener: (event: ShellActivation) => void): Promise<PluginListenerHandle>;
|
|
147
164
|
addListener(name: 'search', listener: (event: ShellSearchEvent) => void): Promise<PluginListenerHandle>;
|
|
148
165
|
addListener(name: 'webViewMetricsChange', listener: (event: WebViewMetrics) => void): Promise<PluginListenerHandle>;
|
|
166
|
+
addListener(name: 'overlay', listener: (event: ShellOverlayEvent) => void): Promise<PluginListenerHandle>;
|
|
167
|
+
}
|
|
168
|
+
export interface ShellPopoverPresentation {
|
|
169
|
+
kind: 'popover';
|
|
170
|
+
animated: boolean;
|
|
171
|
+
dark: boolean;
|
|
172
|
+
anchorId: string;
|
|
173
|
+
width: number;
|
|
174
|
+
height: number;
|
|
175
|
+
backgroundColor: string;
|
|
176
|
+
backdropDismiss: boolean;
|
|
177
|
+
}
|
|
178
|
+
export interface ShellOverlayEvent {
|
|
179
|
+
id: string;
|
|
180
|
+
action: 'dismiss';
|
|
149
181
|
}
|
|
150
182
|
//#endregion
|
|
151
183
|
export type { NativeUIShellComponent };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.d.ts","names":[],"sources":["../../src/native/definitions.ts"],"mappings":";;;iBAKiB;EACf;EACA;EACA;EACA;;iBAGe;
|
|
1
|
+
{"version":3,"file":"definitions.d.ts","names":[],"sources":["../../src/native/definitions.ts"],"mappings":";;;iBAKiB;EACf;EACA;EACA;EACA;;iBAGe;EAEf,WAAW,KAAK;EAShB;EAOA;;iBAGe,6BAA6B;EAE5C;EAEA,WAAW;EAEX;;iBAGe;EAEf;EAEA;EAEA;EAEA;EAEA;;iBAGe;EAEf,aAAa;EAEb,WAAW,QAAQ;EAEnB,WAAW;;YAID;iBAEK;EACf,MAAM;EAEN;EAEA,aAAa;;iBAGE,kCAAkC;EAEjD,aAAa,WAAW,kBAAkB,sBAAsB;;iBAGjD;EAEf,UAAU;;iBAGK;EACf;EACA;EACA;EACA;;iBAGe;EACf;EACA;EACA;;iBAGe,kBAAkB;EACjC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACA;EACA;EACA;EACA,QAAQ;EACR;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;iBAGe,qBAAqB;EACpC;EACA,MAAM;EAEN;EAEA;EACA,OAAO;EACP;EACA;EACA;IAAiB;IAAgB;;EACjC,SAAS;;iBAGM;EACf;EACA,OAAO;EACP,SAAS;EACT;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;iBAGe,yBAAyB;EACxC;EACA;EACA;EACA;;iBAGe;EACf;EACA;EACA;EAEA;EAEA,mBAAmB;EACnB,UAAU;;iBAGK;EACf;EACA;EACA;;iBAGe;EAEf;;iBAGe;EACf,UAAU;IAAY;MAA+B;IAAU;;EAC/D,qBAAqB,QAAQ;EAC7B,eAAe;IAAW;MAAe;EACzC,eAAe;IAAW;IAAY,eAAe;MAA6B;EAClF,eAAe;IAAW;IAAY;MAAsB;EAC5D,aAAa;IAAW;MAAe;EACvC,gBAAgB;EAChB,OAAO,UAAU,gBAAgB;IAAU;IAAkB;IAA6B;;EAC1F,MAAM;IAAW;MAAqB;EACtC,YAAY,kBAAkB,WAAW,OAAO,2BAA2B,QAAQ;EACnF,YAAY,gBAAgB,WAAW,OAAO,4BAA4B,QAAQ;EAClF,YAAY,8BAA8B,WAAW,OAAO,0BAA0B,QAAQ;EAC9F,YAAY,iBAAiB,WAAW,OAAO,6BAA6B,QAAQ;;iBAGrE;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;iBAGe;EACf;EACA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/native/index.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/native/index.ts"],"mappings":";;;qBAgCa,oBAAkB;qBAuElB,iCAAsC,QAAQ;qBAiD9C,kCAAmC,WAAW,kBAAkB,sBAAsB;qBAqBtF,4BAAmC,UAAS,+BAAkC,QAAQ;qBAgBtF,sBAAuB,UAAS,yBAA4B,QAAQ"}
|
package/dist/native/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { setConfig } from "../transition/ios.transition.js";
|
|
2
2
|
import { observeVerticalBarsModals } from "./shared/modal.js";
|
|
3
3
|
import { createRuntime } from "./runtime.js";
|
|
4
|
+
import { createOverlayController } from "./overlays/controller.js";
|
|
4
5
|
import { createVerticalBarsWebProjection } from "./vertical-bars-web.js";
|
|
5
6
|
import { prehideVerticalBarsToolbarSources } from "./prehide.js";
|
|
6
7
|
import { Capacitor, registerPlugin } from "@capacitor/core";
|
|
@@ -48,7 +49,7 @@ const manage = (handle, lifecycle = {}) => {
|
|
|
48
49
|
} : handle.getStatus(),
|
|
49
50
|
async suspend() {
|
|
50
51
|
const lease = await handle.suspend();
|
|
51
|
-
const resume = lifecycle.suspend?.();
|
|
52
|
+
const resume = await lifecycle.suspend?.();
|
|
52
53
|
return { async resume() {
|
|
53
54
|
await lease.resume();
|
|
54
55
|
resume?.();
|
|
@@ -60,8 +61,11 @@ const manage = (handle, lifecycle = {}) => {
|
|
|
60
61
|
try {
|
|
61
62
|
await handle.destroy();
|
|
62
63
|
} finally {
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
try {
|
|
65
|
+
await lifecycle.destroy?.();
|
|
66
|
+
} finally {
|
|
67
|
+
lifecycle.release?.();
|
|
68
|
+
}
|
|
65
69
|
}
|
|
66
70
|
}
|
|
67
71
|
};
|
|
@@ -139,7 +143,8 @@ const enableVerticalControlArea = async (options = {}) => {
|
|
|
139
143
|
buttonDefaultFill: options.buttonDefaultFill,
|
|
140
144
|
controls: {
|
|
141
145
|
tabs: true,
|
|
142
|
-
toolbar: true
|
|
146
|
+
toolbar: true,
|
|
147
|
+
popover: options.controls?.popover === true
|
|
143
148
|
},
|
|
144
149
|
verticalBarsOnly: true
|
|
145
150
|
});
|
|
@@ -172,7 +177,8 @@ const enableNativeUIShell = (options = {}) => {
|
|
|
172
177
|
"toolbar",
|
|
173
178
|
"segment",
|
|
174
179
|
"fab"
|
|
175
|
-
].map((component) => !controls || controls[component] === true)
|
|
180
|
+
].map((component) => !controls || controls[component] === true),
|
|
181
|
+
controls?.popover === true
|
|
176
182
|
]);
|
|
177
183
|
if (active && activeConfiguration !== configuration) return Promise.reject(/* @__PURE__ */ new Error("Native UI Shell is already running with different controls; destroy it before changing configuration."));
|
|
178
184
|
if (active) return active;
|
|
@@ -198,6 +204,7 @@ const enableNativeUIShell = (options = {}) => {
|
|
|
198
204
|
return start = active = (async () => {
|
|
199
205
|
if (Capacitor.getPlatform() !== "ios") return fallback("Requires Capacitor iOS");
|
|
200
206
|
let runtime;
|
|
207
|
+
let overlays;
|
|
201
208
|
let metricsListener;
|
|
202
209
|
let stopVerticalBarsLayout;
|
|
203
210
|
try {
|
|
@@ -218,10 +225,19 @@ const enableNativeUIShell = (options = {}) => {
|
|
|
218
225
|
}
|
|
219
226
|
const native = await createRuntime(document, plugin, options, nativeVerticalBars, options.verticalBarsOnly === true);
|
|
220
227
|
runtime = combine(native, createVerticalBarsWebProjection(document, options, () => !nativeVerticalBars() || native.getStatus().state === "stopped"));
|
|
228
|
+
if (controls?.popover === true) overlays = await createOverlayController(document, plugin, options, native.retain, nativeVerticalBars);
|
|
221
229
|
return manage(runtime, {
|
|
222
|
-
suspend: () =>
|
|
230
|
+
suspend: async () => {
|
|
231
|
+
const restorePrehide = prehide?.suspend();
|
|
232
|
+
const resumeOverlays = await overlays?.suspend();
|
|
233
|
+
return () => {
|
|
234
|
+
restorePrehide?.();
|
|
235
|
+
resumeOverlays?.();
|
|
236
|
+
};
|
|
237
|
+
},
|
|
223
238
|
release,
|
|
224
239
|
destroy: async () => {
|
|
240
|
+
await overlays?.destroy();
|
|
225
241
|
await metricsListener?.remove().catch(() => {});
|
|
226
242
|
stopVerticalBarsLayout?.();
|
|
227
243
|
prehide?.stop();
|
|
@@ -229,6 +245,7 @@ const enableNativeUIShell = (options = {}) => {
|
|
|
229
245
|
}
|
|
230
246
|
});
|
|
231
247
|
} catch (error) {
|
|
248
|
+
await overlays?.destroy();
|
|
232
249
|
await runtime?.destroy();
|
|
233
250
|
await metricsListener?.remove().catch(() => {});
|
|
234
251
|
stopVerticalBarsLayout?.();
|
package/dist/native/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/native/index.ts"],"sourcesContent":["import { Capacitor, registerPlugin } from '@capacitor/core';\nimport { setConfig } from '../transition/ios.transition';\nimport type {\n NativeUIShellHandle,\n NativeUIShellOptions,\n NativeUIShellPlugin,\n VerticalBarEdge,\n VerticalBarPlacement,\n VerticalControlAreaHandle,\n VerticalControlAreaOptions,\n WebViewMetrics,\n} from './definitions';\nimport { createRuntime } from './runtime';\nimport { createVerticalBarsWebProjection } from './vertical-bars-web';\nimport { prehideVerticalBarsToolbarSources } from './prehide';\nimport { observeVerticalBarsModals } from './shared/modal';\nexport type {\n NativeUIShellComponent,\n NativeUIShellControls,\n NativeUIShellHandle,\n NativeUIShellOptions,\n NativeUIShellStatus,\n NativeUIShellSuspension,\n VerticalBarEdge,\n VerticalBarPlacement,\n VerticalControlAreaHandle,\n VerticalControlAreaOptions,\n WebViewMetrics,\n} from './definitions';\n\nconst plugin = registerPlugin<NativeUIShellPlugin>('IonicNativeUIShell');\nexport const IonicNativeUIShell = plugin;\nlet active: Promise<NativeUIShellHandle> | undefined;\nlet activeConfiguration: string | undefined;\nconst web = (reason: string): NativeUIShellHandle => ({\n getStatus: () => ({ state: 'web', projected: 0, updates: 0, reason }),\n suspend: async () => ({ resume: async () => {} }),\n destroy: async () => {},\n});\n\nconst combine = (native: NativeUIShellHandle, fallback: NativeUIShellHandle): NativeUIShellHandle => ({\n getStatus() {\n const nativeStatus = native.getStatus();\n const fallbackStatus = fallback.getStatus();\n return {\n ...nativeStatus,\n state:\n nativeStatus.state === 'stopped' && fallbackStatus.state === 'stopped' ? 'stopped' : nativeStatus.projected > 0 ? 'native' : 'web',\n projected: nativeStatus.projected + fallbackStatus.projected,\n updates: nativeStatus.updates + fallbackStatus.updates,\n };\n },\n async suspend() {\n const [nativeLease, fallbackLease] = await Promise.all([native.suspend(), fallback.suspend()]);\n return { resume: async () => void (await Promise.all([nativeLease.resume(), fallbackLease.resume()])) };\n },\n async destroy() {\n await Promise.all([native.destroy(), fallback.destroy()]);\n },\n});\n\n/** Wraps a runtime handle with the shared enable-lifecycle: reason, suspend hooks and idempotent destroy. */\nconst manage = (\n handle: NativeUIShellHandle,\n lifecycle: {\n reason?: string;\n suspend?: () => (() => void) | undefined;\n /** Runs after teardown; clears the shared slot only while this activation owns it. */\n release?: () => void;\n destroy?: () => void | Promise<void>;\n } = {},\n): NativeUIShellHandle => {\n let destroyed = false;\n return {\n getStatus: () => (lifecycle.reason ? { ...handle.getStatus(), reason: lifecycle.reason } : handle.getStatus()),\n async suspend() {\n const lease = await handle.suspend();\n const resume = lifecycle.suspend?.();\n return {\n async resume() {\n await lease.resume();\n resume?.();\n },\n };\n },\n async destroy() {\n if (destroyed) return;\n destroyed = true;\n try {\n await handle.destroy();\n } finally {\n await lifecycle.destroy?.();\n lifecycle.release?.();\n }\n },\n };\n};\n\n/** Reads the current native WebView geometry and applies it to page transitions. */\nexport const configureNativeTransition = async (): Promise<WebViewMetrics> => {\n const metrics = typeof document !== 'undefined' && Capacitor.getPlatform() === 'ios' ? await plugin.getWebViewMetrics() : { radius: 0 };\n setConfig({ radius: metrics.radius });\n return metrics;\n};\n\n/** Resolves a logical vertical-bar edge to the physical side for the given direction. */\nconst physicalVerticalBarEdge = (edge: Exclude<VerticalBarEdge, null>, rtl: boolean): 'left' | 'right' =>\n (edge === 'leading') !== rtl ? 'left' : 'right';\n\nconst elementRtl = (element: Element): boolean => element.closest('[dir]')?.getAttribute('dir') === 'rtl';\n\n// Device facts are supplied by the application; the theme only compares placement.\nconst nativePlacements = new WeakMap<HTMLElement, { edge: VerticalBarEdge; rtl?: boolean }>();\nconst horizontalFallbackAttribute = 'data-native-ui-shell-vertical-bars-suspended';\n\n// Keep the requested rail while ordinary Native UI Shell temporarily uses its\n// horizontal layout. Removing the effective class restores normal measurements,\n// toolbar ownership and safe areas throughout the existing rendering pipeline.\nconst observeNativeVerticalBarsLayout = (doc: Document): (() => void) => {\n const reconcile = () => {\n const app = doc.querySelector<HTMLElement>('ion-app');\n if (!app) return;\n const requested = app.classList.contains('ios-theme-vertical-bars') || app.hasAttribute(horizontalFallbackAttribute);\n const suspended = requested && nativePlacements.get(app)?.edge == null;\n if (app.hasAttribute(horizontalFallbackAttribute) !== suspended) app.toggleAttribute(horizontalFallbackAttribute, suspended);\n if (app.classList.contains('ios-theme-vertical-bars') !== (requested && !suspended)) {\n app.classList.toggle('ios-theme-vertical-bars', requested && !suspended);\n }\n };\n const observer = new MutationObserver(reconcile);\n observer.observe(doc.documentElement, { childList: true, subtree: true, attributes: true, attributeFilter: ['class'] });\n doc.defaultView?.addEventListener('nativeUIShellRefresh', reconcile);\n reconcile();\n return () => {\n observer.disconnect();\n doc.defaultView?.removeEventListener('nativeUIShellRefresh', reconcile);\n const app = doc.querySelector<HTMLElement>(`ion-app[${horizontalFallbackAttribute}]`);\n if (app) {\n app.removeAttribute(horizontalFallbackAttribute);\n app.classList.add('ios-theme-vertical-bars');\n }\n };\n};\n\n/**\n * Applies one placement to the CSS layout and both Web/native projections.\n * Pass `rtl` when the document direction is known; otherwise the nearest `dir` attribute is used.\n */\nexport const setVerticalControlAreaPlacement = (placement: VerticalBarEdge | VerticalBarPlacement, rtl?: boolean): void => {\n if (typeof document === 'undefined') return;\n const app = document.querySelector<HTMLElement>('ion-app');\n if (!app) throw new Error('Vertical Control Area requires ion-app');\n const { edge, inset = 0 } = placement && typeof placement === 'object' ? placement : { edge: placement, inset: 0 };\n if (placement && typeof placement === 'object' && placement.nativeEdge !== undefined) {\n nativePlacements.set(app, { edge: placement.nativeEdge, rtl });\n }\n app.removeAttribute(horizontalFallbackAttribute);\n app.classList.toggle('ios-theme-vertical-bars', edge !== null);\n app.classList.toggle('ios-theme-vertical-bars-left', edge !== null && physicalVerticalBarEdge(edge, rtl ?? elementRtl(app)) === 'left');\n if (edge && Number.isFinite(inset) && inset > 0) app.style.setProperty('--ios-theme-vertical-bars-native-inset', `${inset}px`);\n else app.style.removeProperty('--ios-theme-vertical-bars-native-inset');\n document.defaultView?.dispatchEvent(new Event('nativeUIShellRefresh'));\n};\n\n/**\n * Call once after ion-app is mounted. Ionic markup remains the source of truth.\n * Native vertical buttons default to SwiftUI appearance.\n * See VerticalControlAreaOptions for source styling and local overrides.\n */\nexport const enableVerticalControlArea = async (options: VerticalControlAreaOptions = {}): Promise<VerticalControlAreaHandle> => {\n const handle = await enableNativeUIShell({\n buttonProjection: options.buttonProjection,\n buttonDefaultFill: options.buttonDefaultFill,\n controls: { tabs: true, toolbar: true },\n verticalBarsOnly: true,\n });\n return {\n getStatus: () => handle.getStatus(),\n suspend: () => handle.suspend(),\n destroy: () => handle.destroy(),\n setPlacement: setVerticalControlAreaPlacement,\n };\n};\n\n/** Call once at application startup. Ionic markup remains the source of truth. */\nexport const enableNativeUIShell = (options: NativeUIShellOptions = {}): Promise<NativeUIShellHandle> => {\n if (options.enabled === false) {\n const current = active;\n active = undefined;\n activeConfiguration = undefined;\n return current\n ? current.then(async (handle) => {\n await handle.destroy();\n return web('Disabled');\n })\n : Promise.resolve(web('Disabled'));\n }\n if (typeof document === 'undefined') return Promise.resolve(web('Requires a document'));\n const controls = options.controls;\n const configuration = JSON.stringify([\n options.verticalBarsOnly === true,\n options.buttonProjection ?? 'system',\n // Local source overrides can use this even when the startup projection is system.\n options.buttonDefaultFill ?? null,\n ...(['tabs', 'toolbar', 'segment', 'fab'] as const).map((component) => !controls || controls[component] === true),\n ]);\n if (active && activeConfiguration !== configuration)\n return Promise.reject(\n new Error('Native UI Shell is already running with different controls; destroy it before changing configuration.'),\n );\n if (active) return active;\n activeConfiguration = configuration;\n const stopModals = observeVerticalBarsModals(document);\n const prehide =\n options.controls === undefined || options.controls.toolbar === true ? prehideVerticalBarsToolbarSources(document) : undefined;\n // A slow destroy of a superseded activation must not release a newer one.\n let start: Promise<NativeUIShellHandle>;\n const release = () => {\n if (active === start) {\n active = undefined;\n activeConfiguration = undefined;\n }\n };\n const fallback = (reason: string) =>\n manage(createVerticalBarsWebProjection(document, options), {\n reason,\n suspend: () => prehide?.suspend(),\n destroy: () => {\n prehide?.stop();\n stopModals();\n },\n release,\n });\n return (start = active =\n (async () => {\n if (Capacitor.getPlatform() !== 'ios') return fallback('Requires Capacitor iOS');\n let runtime: NativeUIShellHandle | undefined;\n let metricsListener: Awaited<ReturnType<typeof plugin.addListener>> | undefined;\n let stopVerticalBarsLayout: (() => void) | undefined;\n try {\n const capabilities = await plugin.configure({ verticalBarsOnly: options.verticalBarsOnly === true });\n if (!capabilities.supported) return fallback('Requires iOS 26 or later');\n if (!options.verticalBarsOnly) stopVerticalBarsLayout = observeNativeVerticalBarsLayout(document);\n // The application owns device state and selects the rail through placement classes.\n const nativeVerticalBars = () => {\n const app = document.querySelector<HTMLElement>('ion-app.ios-theme-vertical-bars');\n if (!app) return false;\n const reported = nativePlacements.get(app);\n if (!reported?.edge) return false;\n const physicalEdge = app.classList.contains('ios-theme-vertical-bars-left') ? 'left' : 'right';\n return physicalEdge === physicalVerticalBarEdge(reported.edge, reported.rtl ?? elementRtl(app));\n };\n if (!options.verticalBarsOnly) {\n metricsListener = await plugin.addListener('webViewMetricsChange', (metrics) => {\n setConfig({ radius: metrics.radius });\n });\n await configureNativeTransition().catch(() => undefined);\n }\n const native = await createRuntime(document, plugin, options, nativeVerticalBars, options.verticalBarsOnly === true);\n runtime = combine(\n native,\n createVerticalBarsWebProjection(document, options, () => !nativeVerticalBars() || native.getStatus().state === 'stopped'),\n );\n return manage(runtime, {\n suspend: () => prehide?.suspend(),\n release,\n destroy: async () => {\n await metricsListener?.remove().catch(() => {});\n stopVerticalBarsLayout?.();\n prehide?.stop();\n stopModals();\n },\n });\n } catch (error) {\n await runtime?.destroy();\n await metricsListener?.remove().catch(() => {});\n stopVerticalBarsLayout?.();\n return fallback(error instanceof Error ? error.message : String(error));\n }\n })());\n};\n"],"mappings":";;;;;;;AA8BA,MAAM,SAAS,eAAoC,oBAAoB;AACvE,MAAa,qBAAqB;AAClC,IAAI;AACJ,IAAI;AACJ,MAAM,OAAO,YAAyC;CACpD,kBAAkB;EAAE,OAAO;EAAO,WAAW;EAAG,SAAS;EAAG;CAAO;CACnE,SAAS,aAAa,EAAE,QAAQ,YAAY,CAAC,EAAE;CAC/C,SAAS,YAAY,CAAC;AACxB;AAEA,MAAM,WAAW,QAA6B,cAAwD;CACpG,YAAY;EACV,MAAM,eAAe,OAAO,UAAU;EACtC,MAAM,iBAAiB,SAAS,UAAU;EAC1C,OAAO;GACL,GAAG;GACH,OACE,aAAa,UAAU,aAAa,eAAe,UAAU,YAAY,YAAY,aAAa,YAAY,IAAI,WAAW;GAC/H,WAAW,aAAa,YAAY,eAAe;GACnD,S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AQ,OAAO,CAAC;IACtC,CAAC;IACD,MAAM,0BAA0B,CAAC,CAAC,YAAY,KAAA,CAAS;GACzD;GACA,MAAM,SAAS,MAAM,cAAc,UAAU,QAAQ,SAAS,oBAAoB,QAAQ,qBAAqB,IAAI;GACnH,UAAU,QACR,QACA,gCAAgC,UAAU,eAAe,CAAC,mBAAmB,KAAK,OAAO,UAAU,CAAC,CAAC,UAAU,SAAS,CAC1H;GACA,OAAO,OAAO,SAAS;IACrB,eAAe,SAAS,QAAQ;IAChC;IACA,SAAS,YAAY;KACnB,MAAM,iBAAiB,OAAO,CAAC,CAAC,YAAY,CAAC,CAAC;KAC9C,yBAAyB;KACzB,SAAS,KAAK;KACd,WAAW;IACb;GACF,CAAC;EACH,SAAS,OAAO;GACd,MAAM,SAAS,QAAQ;GACvB,MAAM,iBAAiB,OAAO,CAAC,CAAC,YAAY,CAAC,CAAC;GAC9C,yBAAyB;GACzB,OAAO,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;EACxE;CACF,EAAA,CAAG;AACP"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/native/index.ts"],"sourcesContent":["import { Capacitor, registerPlugin } from '@capacitor/core';\nimport { setConfig } from '../transition/ios.transition';\nimport type {\n NativeUIShellHandle,\n NativeUIShellOptions,\n NativeUIShellPlugin,\n VerticalBarEdge,\n VerticalBarPlacement,\n VerticalControlAreaHandle,\n VerticalControlAreaOptions,\n WebViewMetrics,\n} from './definitions';\nimport { createRuntime } from './runtime';\nimport { createOverlayController } from './overlays/controller';\nimport { createVerticalBarsWebProjection } from './vertical-bars-web';\nimport { prehideVerticalBarsToolbarSources } from './prehide';\nimport { observeVerticalBarsModals } from './shared/modal';\nexport type {\n NativeUIShellComponent,\n NativeUIShellControls,\n NativeUIShellHandle,\n NativeUIShellOptions,\n NativeUIShellStatus,\n NativeUIShellSuspension,\n VerticalBarEdge,\n VerticalBarPlacement,\n VerticalControlAreaHandle,\n VerticalControlAreaOptions,\n WebViewMetrics,\n} from './definitions';\n\nconst plugin = registerPlugin<NativeUIShellPlugin>('IonicNativeUIShell');\nexport const IonicNativeUIShell = plugin;\nlet active: Promise<NativeUIShellHandle> | undefined;\nlet activeConfiguration: string | undefined;\nconst web = (reason: string): NativeUIShellHandle => ({\n getStatus: () => ({ state: 'web', projected: 0, updates: 0, reason }),\n suspend: async () => ({ resume: async () => {} }),\n destroy: async () => {},\n});\n\nconst combine = (native: NativeUIShellHandle, fallback: NativeUIShellHandle): NativeUIShellHandle => ({\n getStatus() {\n const nativeStatus = native.getStatus();\n const fallbackStatus = fallback.getStatus();\n return {\n ...nativeStatus,\n state:\n nativeStatus.state === 'stopped' && fallbackStatus.state === 'stopped' ? 'stopped' : nativeStatus.projected > 0 ? 'native' : 'web',\n projected: nativeStatus.projected + fallbackStatus.projected,\n updates: nativeStatus.updates + fallbackStatus.updates,\n };\n },\n async suspend() {\n const [nativeLease, fallbackLease] = await Promise.all([native.suspend(), fallback.suspend()]);\n return { resume: async () => void (await Promise.all([nativeLease.resume(), fallbackLease.resume()])) };\n },\n async destroy() {\n await Promise.all([native.destroy(), fallback.destroy()]);\n },\n});\n\n/** Wraps a runtime handle with the shared enable-lifecycle: reason, suspend hooks and idempotent destroy. */\nconst manage = (\n handle: NativeUIShellHandle,\n lifecycle: {\n reason?: string;\n suspend?: () => (() => void) | undefined | Promise<(() => void) | undefined>;\n /** Runs after teardown; clears the shared slot only while this activation owns it. */\n release?: () => void;\n destroy?: () => void | Promise<void>;\n } = {},\n): NativeUIShellHandle => {\n let destroyed = false;\n return {\n getStatus: () => (lifecycle.reason ? { ...handle.getStatus(), reason: lifecycle.reason } : handle.getStatus()),\n async suspend() {\n const lease = await handle.suspend();\n const resume = await lifecycle.suspend?.();\n return {\n async resume() {\n await lease.resume();\n resume?.();\n },\n };\n },\n async destroy() {\n if (destroyed) return;\n destroyed = true;\n try {\n await handle.destroy();\n } finally {\n try {\n await lifecycle.destroy?.();\n } finally {\n lifecycle.release?.();\n }\n }\n },\n };\n};\n\n/** Reads the current native WebView geometry and applies it to page transitions. */\nexport const configureNativeTransition = async (): Promise<WebViewMetrics> => {\n const metrics = typeof document !== 'undefined' && Capacitor.getPlatform() === 'ios' ? await plugin.getWebViewMetrics() : { radius: 0 };\n setConfig({ radius: metrics.radius });\n return metrics;\n};\n\n/** Resolves a logical vertical-bar edge to the physical side for the given direction. */\nconst physicalVerticalBarEdge = (edge: Exclude<VerticalBarEdge, null>, rtl: boolean): 'left' | 'right' =>\n (edge === 'leading') !== rtl ? 'left' : 'right';\n\nconst elementRtl = (element: Element): boolean => element.closest('[dir]')?.getAttribute('dir') === 'rtl';\n\n// Device facts are supplied by the application; the theme only compares placement.\nconst nativePlacements = new WeakMap<HTMLElement, { edge: VerticalBarEdge; rtl?: boolean }>();\nconst horizontalFallbackAttribute = 'data-native-ui-shell-vertical-bars-suspended';\n\n// Keep the requested rail while ordinary Native UI Shell temporarily uses its\n// horizontal layout. Removing the effective class restores normal measurements,\n// toolbar ownership and safe areas throughout the existing rendering pipeline.\nconst observeNativeVerticalBarsLayout = (doc: Document): (() => void) => {\n const reconcile = () => {\n const app = doc.querySelector<HTMLElement>('ion-app');\n if (!app) return;\n const requested = app.classList.contains('ios-theme-vertical-bars') || app.hasAttribute(horizontalFallbackAttribute);\n const suspended = requested && nativePlacements.get(app)?.edge == null;\n if (app.hasAttribute(horizontalFallbackAttribute) !== suspended) app.toggleAttribute(horizontalFallbackAttribute, suspended);\n if (app.classList.contains('ios-theme-vertical-bars') !== (requested && !suspended)) {\n app.classList.toggle('ios-theme-vertical-bars', requested && !suspended);\n }\n };\n const observer = new MutationObserver(reconcile);\n observer.observe(doc.documentElement, { childList: true, subtree: true, attributes: true, attributeFilter: ['class'] });\n doc.defaultView?.addEventListener('nativeUIShellRefresh', reconcile);\n reconcile();\n return () => {\n observer.disconnect();\n doc.defaultView?.removeEventListener('nativeUIShellRefresh', reconcile);\n const app = doc.querySelector<HTMLElement>(`ion-app[${horizontalFallbackAttribute}]`);\n if (app) {\n app.removeAttribute(horizontalFallbackAttribute);\n app.classList.add('ios-theme-vertical-bars');\n }\n };\n};\n\n/**\n * Applies one placement to the CSS layout and both Web/native projections.\n * Pass `rtl` when the document direction is known; otherwise the nearest `dir` attribute is used.\n */\nexport const setVerticalControlAreaPlacement = (placement: VerticalBarEdge | VerticalBarPlacement, rtl?: boolean): void => {\n if (typeof document === 'undefined') return;\n const app = document.querySelector<HTMLElement>('ion-app');\n if (!app) throw new Error('Vertical Control Area requires ion-app');\n const { edge, inset = 0 } = placement && typeof placement === 'object' ? placement : { edge: placement, inset: 0 };\n if (placement && typeof placement === 'object' && placement.nativeEdge !== undefined) {\n nativePlacements.set(app, { edge: placement.nativeEdge, rtl });\n }\n app.removeAttribute(horizontalFallbackAttribute);\n app.classList.toggle('ios-theme-vertical-bars', edge !== null);\n app.classList.toggle('ios-theme-vertical-bars-left', edge !== null && physicalVerticalBarEdge(edge, rtl ?? elementRtl(app)) === 'left');\n if (edge && Number.isFinite(inset) && inset > 0) app.style.setProperty('--ios-theme-vertical-bars-native-inset', `${inset}px`);\n else app.style.removeProperty('--ios-theme-vertical-bars-native-inset');\n document.defaultView?.dispatchEvent(new Event('nativeUIShellRefresh'));\n};\n\n/**\n * Call once after ion-app is mounted. Ionic markup remains the source of truth.\n * Native vertical buttons default to SwiftUI appearance.\n * See VerticalControlAreaOptions for source styling and local overrides.\n */\nexport const enableVerticalControlArea = async (options: VerticalControlAreaOptions = {}): Promise<VerticalControlAreaHandle> => {\n const handle = await enableNativeUIShell({\n buttonProjection: options.buttonProjection,\n buttonDefaultFill: options.buttonDefaultFill,\n controls: { tabs: true, toolbar: true, popover: options.controls?.popover === true },\n verticalBarsOnly: true,\n });\n return {\n getStatus: () => handle.getStatus(),\n suspend: () => handle.suspend(),\n destroy: () => handle.destroy(),\n setPlacement: setVerticalControlAreaPlacement,\n };\n};\n\n/** Call once at application startup. Ionic markup remains the source of truth. */\nexport const enableNativeUIShell = (options: NativeUIShellOptions = {}): Promise<NativeUIShellHandle> => {\n if (options.enabled === false) {\n const current = active;\n active = undefined;\n activeConfiguration = undefined;\n return current\n ? current.then(async (handle) => {\n await handle.destroy();\n return web('Disabled');\n })\n : Promise.resolve(web('Disabled'));\n }\n if (typeof document === 'undefined') return Promise.resolve(web('Requires a document'));\n const controls = options.controls;\n const configuration = JSON.stringify([\n options.verticalBarsOnly === true,\n options.buttonProjection ?? 'system',\n // Local source overrides can use this even when the startup projection is system.\n options.buttonDefaultFill ?? null,\n ...(['tabs', 'toolbar', 'segment', 'fab'] as const).map((component) => !controls || controls[component] === true),\n controls?.popover === true,\n ]);\n if (active && activeConfiguration !== configuration)\n return Promise.reject(\n new Error('Native UI Shell is already running with different controls; destroy it before changing configuration.'),\n );\n if (active) return active;\n activeConfiguration = configuration;\n const stopModals = observeVerticalBarsModals(document);\n const prehide =\n options.controls === undefined || options.controls.toolbar === true ? prehideVerticalBarsToolbarSources(document) : undefined;\n // A slow destroy of a superseded activation must not release a newer one.\n let start: Promise<NativeUIShellHandle>;\n const release = () => {\n if (active === start) {\n active = undefined;\n activeConfiguration = undefined;\n }\n };\n const fallback = (reason: string) =>\n manage(createVerticalBarsWebProjection(document, options), {\n reason,\n suspend: () => prehide?.suspend(),\n destroy: () => {\n prehide?.stop();\n stopModals();\n },\n release,\n });\n return (start = active =\n (async () => {\n if (Capacitor.getPlatform() !== 'ios') return fallback('Requires Capacitor iOS');\n let runtime: NativeUIShellHandle | undefined;\n let overlays: Awaited<ReturnType<typeof createOverlayController>> | undefined;\n let metricsListener: Awaited<ReturnType<typeof plugin.addListener>> | undefined;\n let stopVerticalBarsLayout: (() => void) | undefined;\n try {\n const capabilities = await plugin.configure({ verticalBarsOnly: options.verticalBarsOnly === true });\n if (!capabilities.supported) return fallback('Requires iOS 26 or later');\n if (!options.verticalBarsOnly) stopVerticalBarsLayout = observeNativeVerticalBarsLayout(document);\n // The application owns device state and selects the rail through placement classes.\n const nativeVerticalBars = () => {\n const app = document.querySelector<HTMLElement>('ion-app.ios-theme-vertical-bars');\n if (!app) return false;\n const reported = nativePlacements.get(app);\n if (!reported?.edge) return false;\n const physicalEdge = app.classList.contains('ios-theme-vertical-bars-left') ? 'left' : 'right';\n return physicalEdge === physicalVerticalBarEdge(reported.edge, reported.rtl ?? elementRtl(app));\n };\n if (!options.verticalBarsOnly) {\n metricsListener = await plugin.addListener('webViewMetricsChange', (metrics) => {\n setConfig({ radius: metrics.radius });\n });\n await configureNativeTransition().catch(() => undefined);\n }\n const native = await createRuntime(document, plugin, options, nativeVerticalBars, options.verticalBarsOnly === true);\n runtime = combine(\n native,\n createVerticalBarsWebProjection(document, options, () => !nativeVerticalBars() || native.getStatus().state === 'stopped'),\n );\n if (controls?.popover === true)\n overlays = await createOverlayController(document, plugin, options, native.retain, nativeVerticalBars);\n return manage(runtime, {\n suspend: async () => {\n const restorePrehide = prehide?.suspend();\n const resumeOverlays = await overlays?.suspend();\n return () => {\n restorePrehide?.();\n resumeOverlays?.();\n };\n },\n release,\n destroy: async () => {\n await overlays?.destroy();\n await metricsListener?.remove().catch(() => {});\n stopVerticalBarsLayout?.();\n prehide?.stop();\n stopModals();\n },\n });\n } catch (error) {\n await overlays?.destroy();\n await runtime?.destroy();\n await metricsListener?.remove().catch(() => {});\n stopVerticalBarsLayout?.();\n return fallback(error instanceof Error ? error.message : String(error));\n }\n })());\n};\n"],"mappings":";;;;;;;;AA+BA,MAAM,SAAS,eAAoC,oBAAoB;AACvE,MAAa,qBAAqB;AAClC,IAAI;AACJ,IAAI;AACJ,MAAM,OAAO,YAAyC;CACpD,kBAAkB;EAAE,OAAO;EAAO,WAAW;EAAG,SAAS;EAAG;CAAO;CACnE,SAAS,aAAa,EAAE,QAAQ,YAAY,CAAC,EAAE;CAC/C,SAAS,YAAY,CAAC;AACxB;AAEA,MAAM,WAAW,QAA6B,cAAwD;CACpG,YAAY;EACV,MAAM,eAAe,OAAO,UAAU;EACtC,MAAM,iBAAiB,SAAS,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/native/overlays/content.ts"],"mappings":";qBAGa,cAAe,SAAS,eAAe,aAAa"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { sheetText } from "./styles.js";
|
|
2
|
+
//#region src/native/overlays/content.ts
|
|
3
|
+
/** Constructed stylesheets cannot cross documents with their nodes. */
|
|
4
|
+
const moveContent = (content, destination) => {
|
|
5
|
+
const home = content.map((element) => ({
|
|
6
|
+
element,
|
|
7
|
+
parent: element.parentNode,
|
|
8
|
+
next: element.nextSibling
|
|
9
|
+
}));
|
|
10
|
+
const roots = [];
|
|
11
|
+
const collect = (node) => {
|
|
12
|
+
if (node.shadowRoot) {
|
|
13
|
+
roots.push({
|
|
14
|
+
root: node.shadowRoot,
|
|
15
|
+
css: sheetText(node.shadowRoot.adoptedStyleSheets),
|
|
16
|
+
sheets: [...node.shadowRoot.adoptedStyleSheets]
|
|
17
|
+
});
|
|
18
|
+
for (const child of Array.from(node.shadowRoot.children)) collect(child);
|
|
19
|
+
}
|
|
20
|
+
for (const child of Array.from(node.children)) collect(child);
|
|
21
|
+
};
|
|
22
|
+
content.forEach(collect);
|
|
23
|
+
for (const element of content) destination.append(destination.ownerDocument.adoptNode(element));
|
|
24
|
+
const styles = roots.filter(({ css }) => css).map(({ root, css }) => {
|
|
25
|
+
const style = destination.ownerDocument.createElement("style");
|
|
26
|
+
style.textContent = css;
|
|
27
|
+
root.append(style);
|
|
28
|
+
return style;
|
|
29
|
+
});
|
|
30
|
+
return () => {
|
|
31
|
+
styles.forEach((style) => style.remove());
|
|
32
|
+
for (const { element, parent, next } of home) {
|
|
33
|
+
const connected = element.isConnected;
|
|
34
|
+
parent.ownerDocument.adoptNode(element);
|
|
35
|
+
if (connected) parent.insertBefore(element, next?.parentNode === parent ? next : null);
|
|
36
|
+
}
|
|
37
|
+
for (const { root, css, sheets } of roots) try {
|
|
38
|
+
root.adoptedStyleSheets = sheets;
|
|
39
|
+
} catch {
|
|
40
|
+
if (css) {
|
|
41
|
+
const style = root.ownerDocument.createElement("style");
|
|
42
|
+
style.textContent = css;
|
|
43
|
+
root.append(style);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
//#endregion
|
|
49
|
+
export { moveContent };
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content.js","names":[],"sources":["../../../src/native/overlays/content.ts"],"sourcesContent":["import { sheetText } from './styles';\n\n/** Constructed stylesheets cannot cross documents with their nodes. */\nexport const moveContent = (content: HTMLElement[], destination: HTMLElement): (() => void) => {\n const home = content.map((element) => ({ element, parent: element.parentNode!, next: element.nextSibling }));\n const roots: { root: ShadowRoot; css: string; sheets: CSSStyleSheet[] }[] = [];\n const collect = (node: Element) => {\n if (node.shadowRoot) {\n roots.push({\n root: node.shadowRoot,\n css: sheetText(node.shadowRoot.adoptedStyleSheets),\n sheets: [...node.shadowRoot.adoptedStyleSheets],\n });\n for (const child of Array.from(node.shadowRoot.children)) collect(child);\n }\n for (const child of Array.from(node.children)) collect(child);\n };\n content.forEach(collect);\n for (const element of content) destination.append(destination.ownerDocument.adoptNode(element));\n const styles = roots\n .filter(({ css }) => css)\n .map(({ root, css }) => {\n const style = destination.ownerDocument.createElement('style');\n style.textContent = css;\n root.append(style);\n return style;\n });\n return () => {\n styles.forEach((style) => style.remove());\n for (const { element, parent, next } of home) {\n const connected = element.isConnected;\n parent.ownerDocument!.adoptNode(element);\n // Ionic may already have destroyed the Angular component on dismiss.\n if (connected) parent.insertBefore(element, next?.parentNode === parent ? next : null);\n }\n for (const { root, css, sheets } of roots) {\n // WebKit re-associates adopted sheets with the new document across\n // adoptNode, so they may no longer match this root; fall back to the\n // inline copy instead of aborting the remaining restore.\n try {\n root.adoptedStyleSheets = sheets;\n } catch {\n if (css) {\n const style = root.ownerDocument.createElement('style');\n style.textContent = css;\n root.append(style);\n }\n }\n }\n };\n};\n"],"mappings":";;;AAGA,MAA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,0 +1,8 @@
|
|
|
1
|
+
import { NativeUIShellOptions, NativeUIShellPlugin } from "../definitions.js";
|
|
2
|
+
//#region src/native/overlays/controller.d.ts
|
|
3
|
+
export declare const createOverlayController: (doc: Document, plugin: NativeUIShellPlugin, options: NativeUIShellOptions, retainProjection: (deferActivation?: (id: string) => boolean) => () => void, nativeVerticalBars: () => boolean) => Promise<{
|
|
4
|
+
suspend(): Promise<() => void>;
|
|
5
|
+
destroy(): Promise<void>;
|
|
6
|
+
}>;
|
|
7
|
+
//#endregion
|
|
8
|
+
//# sourceMappingURL=controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller.d.ts","names":[],"sources":["../../../src/native/overlays/controller.ts"],"mappings":";;qBAkCa,0BACX,KAAK,UACL,QAAQ,qBACR,SAAS,sBACT,mBAAmB,mBAAmB,uCACtC,sCAAiC"}
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { isExcluded, isPermanentlyExcluded, isShellDisabled } from "../shared/dom.js";
|
|
2
|
+
import { bounded } from "../runtime.js";
|
|
3
|
+
import { activeElement, trapFocus } from "./focus.js";
|
|
4
|
+
import { relayStyles } from "./styles.js";
|
|
5
|
+
import { popoverPresentation, relayPopover, verticalBarsPopoverAnchor } from "./popover.js";
|
|
6
|
+
import { nativeDialogAnimation } from "./dialog-animation.js";
|
|
7
|
+
//#region src/native/overlays/controller.ts
|
|
8
|
+
const lifecycle = (overlay, phase) => `ion${overlay.localName.slice(4, 5).toUpperCase()}${overlay.localName.slice(5)}${phase}`;
|
|
9
|
+
/** Ionic owns lifecycle and dismissal; only one overlay is relayed at a time. */
|
|
10
|
+
const createOverlayController = async (doc, plugin, options, retainProjection, nativeVerticalBars) => {
|
|
11
|
+
let current;
|
|
12
|
+
let opening = Promise.resolve();
|
|
13
|
+
let sequence = 0;
|
|
14
|
+
let stopped = false;
|
|
15
|
+
const suspensions = /* @__PURE__ */ new Set();
|
|
16
|
+
const events = [
|
|
17
|
+
"Modal",
|
|
18
|
+
"Popover",
|
|
19
|
+
"Alert",
|
|
20
|
+
"ActionSheet",
|
|
21
|
+
"Loading",
|
|
22
|
+
"Picker",
|
|
23
|
+
"Toast"
|
|
24
|
+
].map((name) => `ion${name}WillPresent`);
|
|
25
|
+
const cleanup = async (connection) => {
|
|
26
|
+
const stage = async (label, run) => {
|
|
27
|
+
try {
|
|
28
|
+
await bounded(Promise.resolve(run?.()));
|
|
29
|
+
} catch (error) {
|
|
30
|
+
console.error(`Native overlay teardown failed at ${label}; continuing cleanup anyway.`, error);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
try {
|
|
34
|
+
await stage("events", connection.stopEvents);
|
|
35
|
+
await stage("lifecycle", connection.stopLifecycle);
|
|
36
|
+
await stage("childEvents", connection.stopChildEvents);
|
|
37
|
+
await stage("exclusions", connection.stopExclusions);
|
|
38
|
+
await stage("focus", connection.stopFocus);
|
|
39
|
+
await connection.nativeClosing?.catch((error) => {
|
|
40
|
+
console.error("Native overlay dismissal did not complete; restoring the Web content anyway.", error);
|
|
41
|
+
});
|
|
42
|
+
await stage("content", connection.stopContent);
|
|
43
|
+
await stage("animation", connection.stopAnimation);
|
|
44
|
+
await stage("styles", connection.stopStyles);
|
|
45
|
+
await stage("close", () => bounded(plugin.closeOverlay({ id: connection.id })));
|
|
46
|
+
} finally {
|
|
47
|
+
connection.releaseProjection?.();
|
|
48
|
+
connection.releaseProjection = void 0;
|
|
49
|
+
try {
|
|
50
|
+
connection.win?.close();
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.error("Native overlay window was already gone.", error);
|
|
53
|
+
}
|
|
54
|
+
if (current === connection) current = void 0;
|
|
55
|
+
const focus = connection.focus;
|
|
56
|
+
if (focus?.isConnected && focus.tabIndex >= 0) focus.focus({ preventScroll: true });
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const release = (connection) => connection.closing ?? (connection.closing = cleanup(connection));
|
|
60
|
+
const restoreWeb = async () => {
|
|
61
|
+
if (current) await release(current);
|
|
62
|
+
};
|
|
63
|
+
const excluded = (overlay) => isPermanentlyExcluded(overlay) || isExcluded(overlay) || isShellDisabled(overlay);
|
|
64
|
+
const connect = async (connection, ready, presentation) => {
|
|
65
|
+
const { overlay } = connection;
|
|
66
|
+
const gone = () => current !== connection || stopped || suspensions.size || connection.dismissed || !overlay.isConnected || !nativeVerticalBars() || excluded(overlay);
|
|
67
|
+
connection.hideAnimation?.();
|
|
68
|
+
try {
|
|
69
|
+
const staging = (async () => {
|
|
70
|
+
await bounded(plugin.prepareOverlay({ id: connection.id }));
|
|
71
|
+
if (gone()) return void 0;
|
|
72
|
+
const win = doc.defaultView.open(`about:blank#${connection.id}`, "_blank");
|
|
73
|
+
if (!win) throw new Error("Native overlay window unavailable");
|
|
74
|
+
connection.win = win;
|
|
75
|
+
if (decodeURIComponent(win.document.URL) !== `about:blank#${connection.id}` || win.document.readyState !== "complete") await bounded(new Promise((resolve) => win.addEventListener("load", () => resolve(), { once: true })));
|
|
76
|
+
if (gone()) return void 0;
|
|
77
|
+
win.document.open();
|
|
78
|
+
win.document.write("<!doctype html><html><head></head><body></body></html>");
|
|
79
|
+
win.document.close();
|
|
80
|
+
connection.stopChildEvents = observe(win.document);
|
|
81
|
+
const environment = relayStyles(doc, win.document, overlay);
|
|
82
|
+
connection.stopStyles = environment.stop;
|
|
83
|
+
await bounded(environment.ready);
|
|
84
|
+
if (gone()) return void 0;
|
|
85
|
+
return {
|
|
86
|
+
destination: environment.destination,
|
|
87
|
+
win
|
|
88
|
+
};
|
|
89
|
+
})();
|
|
90
|
+
staging.catch(() => {});
|
|
91
|
+
await bounded(ready);
|
|
92
|
+
await bounded(new Promise((resolve) => doc.defaultView.requestAnimationFrame(() => resolve())));
|
|
93
|
+
const staged = await staging;
|
|
94
|
+
if (gone() || !staged) {
|
|
95
|
+
await release(connection);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const focused = activeElement(doc);
|
|
99
|
+
const nativePresentation = popoverPresentation(overlay);
|
|
100
|
+
const content = relayPopover(overlay, staged.destination);
|
|
101
|
+
connection.stopContent = content.stop;
|
|
102
|
+
connection.hideAnimation?.();
|
|
103
|
+
const exclusions = new MutationObserver(() => {
|
|
104
|
+
if (!overlay.isConnected || !nativeVerticalBars() || excluded(overlay) || isShellDisabled(content.root)) release(connection).catch(console.error);
|
|
105
|
+
});
|
|
106
|
+
const attributes = {
|
|
107
|
+
attributes: true,
|
|
108
|
+
attributeFilter: [
|
|
109
|
+
"class",
|
|
110
|
+
"data-shell",
|
|
111
|
+
"hidden",
|
|
112
|
+
"inert"
|
|
113
|
+
]
|
|
114
|
+
};
|
|
115
|
+
for (let node = overlay; node; node = node.parentElement) {
|
|
116
|
+
exclusions.observe(node, attributes);
|
|
117
|
+
exclusions.observe(node, { childList: true });
|
|
118
|
+
}
|
|
119
|
+
exclusions.observe(content.root, {
|
|
120
|
+
...attributes,
|
|
121
|
+
subtree: true
|
|
122
|
+
});
|
|
123
|
+
connection.stopExclusions = () => exclusions.disconnect();
|
|
124
|
+
connection.stopFocus = trapFocus(content.root, () => !connection.dismissed && (!("focusTrap" in overlay) || overlay.focusTrap !== false) && !overlay.classList.contains("ion-disable-focus-trap"));
|
|
125
|
+
const close = () => {
|
|
126
|
+
release(connection).catch(console.error);
|
|
127
|
+
};
|
|
128
|
+
const escape = (event) => {
|
|
129
|
+
if (event.key === "Escape" && overlay.backdropDismiss) overlay.dismiss(void 0, "backdrop");
|
|
130
|
+
};
|
|
131
|
+
staged.win.document.addEventListener("keydown", escape);
|
|
132
|
+
overlay.addEventListener(lifecycle(overlay, "DidDismiss"), close, { once: true });
|
|
133
|
+
connection.stopEvents = () => {
|
|
134
|
+
staged.win.document.removeEventListener("keydown", escape);
|
|
135
|
+
overlay.removeEventListener(lifecycle(overlay, "DidDismiss"), close);
|
|
136
|
+
};
|
|
137
|
+
await bounded(plugin.presentOverlay({
|
|
138
|
+
id: connection.id,
|
|
139
|
+
presentation: {
|
|
140
|
+
...nativePresentation,
|
|
141
|
+
animated: presentation.animated
|
|
142
|
+
}
|
|
143
|
+
}));
|
|
144
|
+
(focused?.isConnected && focused.ownerDocument === staged.win.document ? focused : content.root).focus({ preventScroll: true });
|
|
145
|
+
} catch (error) {
|
|
146
|
+
await release(connection);
|
|
147
|
+
console.error("Native overlay projection failed; keeping Ionic content in the source WebView.", error);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
const present = (event) => {
|
|
151
|
+
const overlay = event.target;
|
|
152
|
+
if (current) {
|
|
153
|
+
const connection = current;
|
|
154
|
+
current = void 0;
|
|
155
|
+
opening = opening.then(() => release(connection)).catch(console.error);
|
|
156
|
+
if (!connection.dismissed) return;
|
|
157
|
+
connection.stopAnimation?.();
|
|
158
|
+
connection.stopAnimation = void 0;
|
|
159
|
+
}
|
|
160
|
+
const enabled = overlay.localName === "ion-popover" && options.controls?.popover === true && nativeVerticalBars() && verticalBarsPopoverAnchor(overlay) !== void 0;
|
|
161
|
+
if (stopped || suspensions.size || !enabled || excluded(overlay)) {
|
|
162
|
+
opening = opening.then(restoreWeb).catch(console.error);
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const connection = {
|
|
166
|
+
id: `ios-theme-overlay-${++sequence}`,
|
|
167
|
+
overlay,
|
|
168
|
+
dismissed: false,
|
|
169
|
+
focus: activeElement(doc)
|
|
170
|
+
};
|
|
171
|
+
const presentation = {
|
|
172
|
+
kind: "popover",
|
|
173
|
+
animated: overlay.animated
|
|
174
|
+
};
|
|
175
|
+
current = connection;
|
|
176
|
+
const anchorId = verticalBarsPopoverAnchor(overlay);
|
|
177
|
+
connection.releaseProjection = retainProjection((id) => id === anchorId && current === connection && !!connection.nativeClosing && !stopped && !suspensions.size && nativeVerticalBars() && !excluded(overlay));
|
|
178
|
+
const closed = () => {
|
|
179
|
+
connection.dismissed = true;
|
|
180
|
+
};
|
|
181
|
+
overlay.addEventListener(lifecycle(overlay, "DidDismiss"), closed, { once: true });
|
|
182
|
+
let resolveReady;
|
|
183
|
+
const readyPromise = new Promise((resolve) => {
|
|
184
|
+
resolveReady = resolve;
|
|
185
|
+
});
|
|
186
|
+
const ready = () => {
|
|
187
|
+
resolveReady();
|
|
188
|
+
};
|
|
189
|
+
const closeNative = () => connection.nativeClosing ?? (connection.nativeClosing = bounded(plugin.dismissOverlay({
|
|
190
|
+
id: connection.id,
|
|
191
|
+
animated: presentation.animated
|
|
192
|
+
})));
|
|
193
|
+
const animation = nativeDialogAnimation(overlay, closeNative);
|
|
194
|
+
connection.stopAnimation = animation.stop;
|
|
195
|
+
connection.hideAnimation = animation.hide;
|
|
196
|
+
animation.hide();
|
|
197
|
+
overlay.addEventListener(lifecycle(overlay, "DidPresent"), ready, { once: true });
|
|
198
|
+
connection.stopLifecycle = () => overlay.removeEventListener(lifecycle(overlay, "DidDismiss"), closed);
|
|
199
|
+
opening = opening.then(() => connect(connection, readyPromise, presentation)).catch(console.error).finally(() => {
|
|
200
|
+
overlay.removeEventListener(lifecycle(overlay, "DidPresent"), ready);
|
|
201
|
+
});
|
|
202
|
+
};
|
|
203
|
+
const menuOpen = (event) => {
|
|
204
|
+
if (!event.composedPath().some((node) => node instanceof HTMLElement && node.matches("ion-menu"))) return;
|
|
205
|
+
const connection = current;
|
|
206
|
+
current = void 0;
|
|
207
|
+
if (connection) opening = opening.then(() => release(connection)).catch(console.error);
|
|
208
|
+
};
|
|
209
|
+
const observe = (target) => {
|
|
210
|
+
for (const name of events) target.addEventListener(name, present);
|
|
211
|
+
target.addEventListener("ionWillOpen", menuOpen);
|
|
212
|
+
return () => {
|
|
213
|
+
for (const name of events) target.removeEventListener(name, present);
|
|
214
|
+
target.removeEventListener("ionWillOpen", menuOpen);
|
|
215
|
+
};
|
|
216
|
+
};
|
|
217
|
+
const invalidate = () => {
|
|
218
|
+
const connection = current;
|
|
219
|
+
current = void 0;
|
|
220
|
+
if (connection) opening = opening.then(() => release(connection)).catch(console.error);
|
|
221
|
+
};
|
|
222
|
+
const win = doc.defaultView;
|
|
223
|
+
win.addEventListener("resize", invalidate);
|
|
224
|
+
doc.addEventListener("ionViewWillLeave", invalidate);
|
|
225
|
+
const visibility = () => {
|
|
226
|
+
if (doc.hidden) invalidate();
|
|
227
|
+
};
|
|
228
|
+
doc.addEventListener("visibilitychange", visibility);
|
|
229
|
+
const listener = await bounded(plugin.addListener("overlay", (event) => {
|
|
230
|
+
if (event.id !== current?.id) return;
|
|
231
|
+
if (event.action === "dismiss" && current.overlay.backdropDismiss) current.overlay.dismiss(void 0, "backdrop").catch(console.error);
|
|
232
|
+
}));
|
|
233
|
+
const stopEvents = observe(doc);
|
|
234
|
+
return {
|
|
235
|
+
async suspend() {
|
|
236
|
+
const lease = Symbol();
|
|
237
|
+
suspensions.add(lease);
|
|
238
|
+
await opening;
|
|
239
|
+
await restoreWeb();
|
|
240
|
+
return () => {
|
|
241
|
+
suspensions.delete(lease);
|
|
242
|
+
};
|
|
243
|
+
},
|
|
244
|
+
async destroy() {
|
|
245
|
+
stopped = true;
|
|
246
|
+
stopEvents();
|
|
247
|
+
win.removeEventListener("resize", invalidate);
|
|
248
|
+
doc.removeEventListener("ionViewWillLeave", invalidate);
|
|
249
|
+
doc.removeEventListener("visibilitychange", visibility);
|
|
250
|
+
try {
|
|
251
|
+
await opening;
|
|
252
|
+
await restoreWeb();
|
|
253
|
+
} finally {
|
|
254
|
+
try {
|
|
255
|
+
await bounded(plugin.stopOverlays());
|
|
256
|
+
} finally {
|
|
257
|
+
await listener.remove();
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
};
|
|
263
|
+
//#endregion
|
|
264
|
+
export { createOverlayController };
|
|
265
|
+
|
|
266
|
+
//# sourceMappingURL=controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller.js","names":[],"sources":["../../../src/native/overlays/controller.ts"],"sourcesContent":["import type { NativeUIShellOptions, NativeUIShellPlugin } from '../definitions';\nimport { bounded } from '../runtime';\nimport { isExcluded, isPermanentlyExcluded, isShellDisabled } from '../shared/dom';\nimport { activeElement, trapFocus } from './focus';\nimport { relayPopover, popoverPresentation, verticalBarsPopoverAnchor } from './popover';\nimport { nativeDialogAnimation } from './dialog-animation';\nimport { relayStyles } from './styles';\n\ntype Presentation = { kind: 'popover'; animated: boolean };\ntype Overlay = HTMLIonPopoverElement;\nconst lifecycle = (overlay: Overlay, phase: string) =>\n `ion${overlay.localName.slice(4, 5).toUpperCase()}${overlay.localName.slice(5)}${phase}`;\n\ninterface Connection {\n id: string;\n overlay: Overlay;\n dismissed: boolean;\n win?: Window;\n focus: Element | null;\n stopStyles?: () => void;\n releaseProjection?: () => void;\n stopContent?: () => void;\n stopFocus?: () => void;\n stopEvents?: () => void;\n stopChildEvents?: () => void;\n stopExclusions?: () => void;\n closing?: Promise<void>;\n nativeClosing?: Promise<void>;\n stopAnimation?: () => void;\n hideAnimation?: () => void;\n stopLifecycle?: () => void;\n}\n\n/** Ionic owns lifecycle and dismissal; only one overlay is relayed at a time. */\nexport const createOverlayController = async (\n doc: Document,\n plugin: NativeUIShellPlugin,\n options: NativeUIShellOptions,\n retainProjection: (deferActivation?: (id: string) => boolean) => () => void,\n nativeVerticalBars: () => boolean,\n) => {\n let current: Connection | undefined;\n let opening = Promise.resolve();\n let sequence = 0;\n let stopped = false;\n const suspensions = new Set<symbol>();\n const events = ['Modal', 'Popover', 'Alert', 'ActionSheet', 'Loading', 'Picker', 'Toast'].map((name) => `ion${name}WillPresent`);\n const cleanup = async (connection: Connection) => {\n // Every teardown step is isolated and bounded: a throwing or hanging step\n // must not strand the retained page projections or the child window.\n const stage = async (label: string, run?: () => void | Promise<void>) => {\n try {\n await bounded(Promise.resolve(run?.()));\n } catch (error) {\n console.error(`Native overlay teardown failed at ${label}; continuing cleanup anyway.`, error);\n }\n };\n try {\n await stage('events', connection.stopEvents);\n await stage('lifecycle', connection.stopLifecycle);\n await stage('childEvents', connection.stopChildEvents);\n await stage('exclusions', connection.stopExclusions);\n await stage('focus', connection.stopFocus);\n // A timed-out dismissal must not strand the relayed content in the child window.\n await connection.nativeClosing?.catch((error) => {\n console.error('Native overlay dismissal did not complete; restoring the Web content anyway.', error);\n });\n await stage('content', connection.stopContent);\n await stage('animation', connection.stopAnimation);\n await stage('styles', connection.stopStyles);\n await stage('close', () => bounded(plugin.closeOverlay({ id: connection.id })));\n } finally {\n // The page projections must be released even if teardown throws above.\n connection.releaseProjection?.();\n connection.releaseProjection = undefined;\n try {\n connection.win?.close();\n } catch (error) {\n console.error('Native overlay window was already gone.', error);\n }\n if (current === connection) current = undefined;\n const focus = connection.focus as HTMLElement | null;\n if (focus?.isConnected && focus.tabIndex >= 0) focus.focus({ preventScroll: true });\n }\n };\n const release = (connection: Connection): Promise<void> => (connection.closing ??= cleanup(connection));\n const restoreWeb = async () => {\n if (current) await release(current);\n };\n const excluded = (overlay: HTMLElement) => isPermanentlyExcluded(overlay) || isExcluded(overlay) || isShellDisabled(overlay);\n const connect = async (connection: Connection, ready: Promise<void>, presentation: Presentation) => {\n const { overlay } = connection;\n const gone = () =>\n current !== connection ||\n stopped ||\n suspensions.size ||\n connection.dismissed ||\n !overlay.isConnected ||\n !nativeVerticalBars() ||\n excluded(overlay);\n // Keep the source invisible while the native toolbar prepares its popover.\n connection.hideAnimation?.();\n try {\n // Prepare the child window concurrently with Ionic's content initialization.\n const staging = (async () => {\n await bounded(\n plugin.prepareOverlay({\n id: connection.id,\n }),\n );\n if (gone()) return undefined;\n const win = doc.defaultView!.open(`about:blank#${connection.id}`, '_blank');\n if (!win) throw new Error('Native overlay window unavailable');\n connection.win = win;\n // The requested blank page replaces the initial document created by window.open.\n // WebKit percent-encodes the '#' marker in the popup URL; compare decoded.\n // Adopt nodes only after that navigation; otherwise WebKit discards the relay.\n if (decodeURIComponent(win.document.URL) !== `about:blank#${connection.id}` || win.document.readyState !== 'complete')\n await bounded(new Promise<void>((resolve) => win.addEventListener('load', () => resolve(), { once: true })));\n if (gone()) return undefined;\n // about:blank is a quirks-mode document in WebKit. Initialize standards\n // mode before adopting live content: otherwise percentage button heights\n // can resolve against the entire popover viewport.\n win.document.open();\n win.document.write('<!doctype html><html><head></head><body></body></html>');\n win.document.close();\n connection.stopChildEvents = observe(win.document);\n const environment = relayStyles(doc, win.document, overlay);\n connection.stopStyles = environment.stop;\n await bounded(environment.ready);\n if (gone()) return undefined;\n return { destination: environment.destination, win };\n })();\n // The staging join is awaited below; settle early rejections quietly.\n staging.catch(() => {});\n // Ionic initializes its gestures after didPresent. Let that turn finish before adopting their content.\n // A stalled presentation must not park the opening queue forever.\n await bounded(ready);\n // Placement is captured after Ionic has laid out the overlay.\n await bounded(new Promise<void>((resolve) => doc.defaultView!.requestAnimationFrame(() => resolve())));\n const staged = await staging;\n if (gone() || !staged) {\n await release(connection);\n return;\n }\n const focused = activeElement(doc) as HTMLElement | null;\n const nativePresentation = popoverPresentation(overlay);\n const content = relayPopover(overlay, staged.destination);\n connection.stopContent = content.stop;\n connection.hideAnimation?.();\n // Ionic does not dismiss a presented overlay when its page is hidden or\n // destroyed; without this a popover could retain the page projections\n // forever and freeze every later control update.\n const exclusions = new MutationObserver(() => {\n if (!overlay.isConnected || !nativeVerticalBars() || excluded(overlay) || isShellDisabled(content.root))\n void release(connection).catch(console.error);\n });\n const attributes = { attributes: true, attributeFilter: ['class', 'data-shell', 'hidden', 'inert'] };\n for (let node: HTMLElement | null = overlay; node; node = node.parentElement) {\n exclusions.observe(node, attributes);\n exclusions.observe(node, { childList: true });\n }\n exclusions.observe(content.root, { ...attributes, subtree: true });\n connection.stopExclusions = () => exclusions.disconnect();\n connection.stopFocus = trapFocus(\n content.root,\n () =>\n !connection.dismissed &&\n (!('focusTrap' in overlay) || overlay.focusTrap !== false) &&\n !overlay.classList.contains('ion-disable-focus-trap'),\n );\n const close = () => {\n void release(connection).catch(console.error);\n };\n const escape = (event: KeyboardEvent) => {\n if (event.key === 'Escape' && overlay.backdropDismiss) void overlay.dismiss(undefined, 'backdrop');\n };\n staged.win.document.addEventListener('keydown', escape);\n overlay.addEventListener(lifecycle(overlay, 'DidDismiss'), close, { once: true });\n connection.stopEvents = () => {\n staged.win.document.removeEventListener('keydown', escape);\n overlay.removeEventListener(lifecycle(overlay, 'DidDismiss'), close);\n };\n // SwiftUI owns the only visible presentation animation.\n await bounded(\n plugin.presentOverlay({\n id: connection.id,\n presentation: { ...nativePresentation, animated: presentation.animated },\n }),\n );\n (focused?.isConnected && focused.ownerDocument === staged.win.document ? focused : content.root).focus({ preventScroll: true });\n } catch (error) {\n await release(connection);\n console.error('Native overlay projection failed; keeping Ionic content in the source WebView.', error);\n }\n };\n const present = (event: Event) => {\n const overlay = event.target as Overlay;\n if (current) {\n const connection = current;\n current = undefined;\n opening = opening.then(() => release(connection)).catch(console.error);\n if (!connection.dismissed) return;\n // A didDismiss handler may immediately open the next popover while SwiftUI is still closing this one.\n connection.stopAnimation?.();\n connection.stopAnimation = undefined;\n }\n const enabled =\n overlay.localName === 'ion-popover' &&\n options.controls?.popover === true &&\n nativeVerticalBars() &&\n verticalBarsPopoverAnchor(overlay) !== undefined;\n if (stopped || suspensions.size || !enabled || excluded(overlay)) {\n opening = opening.then(restoreWeb).catch(console.error);\n return;\n }\n const connection: Connection = { id: `ios-theme-overlay-${++sequence}`, overlay, dismissed: false, focus: activeElement(doc) };\n const presentation: Presentation = { kind: 'popover', animated: overlay.animated };\n current = connection;\n // Retain synchronously, before the scheduled projection update can retire the rail.\n const anchorId = verticalBarsPopoverAnchor(overlay);\n connection.releaseProjection = retainProjection(\n (id) =>\n id === anchorId &&\n current === connection &&\n !!connection.nativeClosing &&\n !stopped &&\n !suspensions.size &&\n nativeVerticalBars() &&\n !excluded(overlay),\n );\n const closed = () => {\n connection.dismissed = true;\n };\n overlay.addEventListener(lifecycle(overlay, 'DidDismiss'), closed, { once: true });\n let resolveReady!: () => void;\n const readyPromise = new Promise<void>((resolve) => {\n resolveReady = resolve;\n });\n const ready = () => {\n resolveReady();\n };\n const closeNative = () =>\n (connection.nativeClosing ??= bounded(plugin.dismissOverlay({ id: connection.id, animated: presentation.animated })));\n const animation = nativeDialogAnimation(overlay, closeNative);\n connection.stopAnimation = animation.stop;\n connection.hideAnimation = animation.hide;\n animation.hide();\n overlay.addEventListener(lifecycle(overlay, 'DidPresent'), ready, { once: true });\n connection.stopLifecycle = () => overlay.removeEventListener(lifecycle(overlay, 'DidDismiss'), closed);\n opening = opening\n .then(() => connect(connection, readyPromise, presentation))\n .catch(console.error)\n .finally(() => {\n overlay.removeEventListener(lifecycle(overlay, 'DidPresent'), ready);\n });\n };\n const menuOpen = (event: Event) => {\n if (!event.composedPath().some((node): node is HTMLElement => node instanceof HTMLElement && node.matches('ion-menu'))) return;\n // Menus render in the source document below the native overlay; release the relay.\n const connection = current;\n current = undefined;\n if (connection) opening = opening.then(() => release(connection)).catch(console.error);\n };\n const observe = (target: Document) => {\n for (const name of events) target.addEventListener(name, present);\n target.addEventListener('ionWillOpen', menuOpen);\n return () => {\n for (const name of events) target.removeEventListener(name, present);\n target.removeEventListener('ionWillOpen', menuOpen);\n };\n };\n const invalidate = () => {\n const connection = current;\n current = undefined;\n if (connection) opening = opening.then(() => release(connection)).catch(console.error);\n };\n // Retention must not freeze an obsolete layout or a departed page.\n const win = doc.defaultView!;\n win.addEventListener('resize', invalidate);\n doc.addEventListener('ionViewWillLeave', invalidate);\n const visibility = () => {\n if (doc.hidden) invalidate();\n };\n doc.addEventListener('visibilitychange', visibility);\n const listener = await bounded(\n plugin.addListener('overlay', (event) => {\n if (event.id !== current?.id) return;\n if (event.action === 'dismiss' && current.overlay.backdropDismiss)\n void current.overlay.dismiss(undefined, 'backdrop').catch(console.error);\n }),\n );\n const stopEvents = observe(doc);\n return {\n async suspend() {\n const lease = Symbol();\n suspensions.add(lease);\n await opening;\n await restoreWeb();\n return () => {\n suspensions.delete(lease);\n };\n },\n async destroy() {\n stopped = true;\n stopEvents();\n win.removeEventListener('resize', invalidate);\n doc.removeEventListener('ionViewWillLeave', invalidate);\n doc.removeEventListener('visibilitychange', visibility);\n try {\n await opening;\n await restoreWeb();\n } finally {\n try {\n await bounded(plugin.stopOverlays());\n } finally {\n await listener.remove();\n }\n }\n },\n };\n};\n"],"mappings":";;;;;;;AAUA,MAAM,aAAa,SAAkB,UACnC,MAAM,QAAQ,UAAU,MAAM,GAAG,CAAC,CAAC,CAAC,YAAY,IAAI,QAAQ,UAAU,MAAM,CAAC,IAAI;;AAuBnF,MAAa,0BAA0B,OACrC,KACA,QACA,SACA,kBACA,uBACG;CACH,IAAI;CACJ,IAAI,UAAU,QAAQ,QAAQ;CAC9B,IAAI,WAAW;CACf,IAAI,UAAU;CACd,MAAM,8BAAc,IAAI,IAAY;CACpC,MAAM,SAAS;EAAC;EAAS;EAAW;EAAS;EAAe;EAAW;EAAU;CAAO,CAAC,CAAC,KAAK,SAAS,MAAM,KAAK,YAAY;CAC/H,MAAM,UAAU,OAAO,eAA2B;EAGhD,MAAM,QAAQ,OAAO,OAAe,QAAqC;GACvE,IAAI;IACF,MAAM,QAAQ,QAAQ,QAAQ,MAAM,CAAC,CAAC;GACxC,SAAS,OAAO;IACd,QAAQ,MAAM,qCAAqC,MAAM,+BAA+B,KAAK;GAC/F;EACF;EACA,IAAI;GACF,MAAM,MAAM,UAAU,WAAW,UAAU;GAC3C,MAAM,MAAM,aAAa,WAAW,aAAa;GACjD,MAAM,MAAM,eAAe,WAAW,eAAe;GACrD,MAAM,MAAM,cAAc,WAAW,cAAc;GACnD,MAAM,MAAM,SAAS,WAAW,SAAS;GAEzC,MAAM,WAAW,eAAe,OAAO,UAAU;IAC/C,QAAQ,MAAM,gFAAgF,KAAK;GACrG,CAAC;GACD,MAAM,MAAM,WAAW,WAAW,WAAW;GAC7C,MAAM,MAAM,aAAa,WAAW,aAAa;GACjD,MAAM,MAAM,UAAU,WAAW,UAAU;GAC3C,MAAM,MAAM,eAAe,QAAQ,OAAO,aAAa,EAAE,IAAI,WAAW,GAAG,CAAC,CAA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