@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.
- package/README.md +24 -280
- package/dist/css/components/ion-toolbar.css +1 -1
- package/dist/css/ionic-theme-ios27.css +1 -1
- package/dist/css/vertical-bars.css +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/layout/index.d.ts +18 -0
- package/dist/layout/index.d.ts.map +1 -0
- package/dist/layout/index.js +26 -0
- package/dist/layout/index.js.map +1 -0
- package/dist/segment/index.js +3 -3
- package/dist/segment/index.js.map +1 -1
- package/dist/sheets-of-glass/index.js +7 -7
- package/dist/sheets-of-glass/index.js.map +1 -1
- package/dist/tab-bar-searchable/dismiss-button.js +53 -3
- package/dist/tab-bar-searchable/dismiss-button.js.map +1 -1
- package/dist/tab-bar-searchable/index.js +18 -3
- package/dist/tab-bar-searchable/index.js.map +1 -1
- package/dist/transition/ios.transition.d.ts.map +1 -1
- package/dist/transition/ios.transition.js +7 -4
- package/dist/transition/ios.transition.js.map +1 -1
- package/dist/transition/native-ui.d.ts +6 -0
- package/dist/transition/native-ui.d.ts.map +1 -0
- package/dist/{native-integration/index.js → transition/native-ui.js} +16 -30
- package/dist/transition/native-ui.js.map +1 -0
- package/docs/adaptive-themes.md +151 -0
- package/docs/add-native-ui.md +53 -0
- package/docs/animation.md +1 -1
- package/docs/eslint.md +1 -1
- package/docs/features.md +3 -3
- package/docs/iphone-duo-with-original-theme.md +44 -29
- package/docs/iphone-duo.md +29 -32
- package/docs/migration.md +12 -24
- package/docs/setup.md +82 -0
- package/docs/special-markup.md +5 -5
- package/docs/using-ion-item-group.md +2 -2
- package/docs/vertical-bars-layout.md +47 -0
- package/package.json +12 -42
- package/src/index.ts +3 -1
- package/src/layout/index.ts +29 -0
- package/src/segment/index.ts +3 -3
- package/src/sheets-of-glass/index.ts +7 -7
- package/src/styles/components/ion-toolbar.scss +1 -1
- package/src/styles/vertical-bars.scss +15 -18
- package/src/tab-bar-searchable/dismiss-button.ts +73 -4
- package/src/tab-bar-searchable/index.ts +20 -3
- package/src/transition/ios.transition.ts +7 -4
- package/src/{native-integration/index.ts → transition/native-ui.ts} +17 -46
- package/Package.swift +0 -21
- package/dist/_virtual/_rolldown/runtime.js +0 -13
- package/dist/native/components/index.d.ts +0 -19
- package/dist/native/components/index.d.ts.map +0 -1
- package/dist/native/components/index.js +0 -40
- package/dist/native/components/index.js.map +0 -1
- package/dist/native/components/ion-back-button.d.ts +0 -9
- package/dist/native/components/ion-back-button.d.ts.map +0 -1
- package/dist/native/components/ion-back-button.js +0 -20
- package/dist/native/components/ion-back-button.js.map +0 -1
- package/dist/native/components/ion-button.d.ts +0 -10
- package/dist/native/components/ion-button.d.ts.map +0 -1
- package/dist/native/components/ion-button.js +0 -23
- package/dist/native/components/ion-button.js.map +0 -1
- package/dist/native/components/ion-buttons.d.ts +0 -11
- package/dist/native/components/ion-buttons.d.ts.map +0 -1
- package/dist/native/components/ion-buttons.js +0 -30
- package/dist/native/components/ion-buttons.js.map +0 -1
- package/dist/native/components/ion-fab.d.ts +0 -10
- package/dist/native/components/ion-fab.d.ts.map +0 -1
- package/dist/native/components/ion-fab.js +0 -132
- package/dist/native/components/ion-fab.js.map +0 -1
- package/dist/native/components/ion-menu-button.d.ts +0 -13
- package/dist/native/components/ion-menu-button.d.ts.map +0 -1
- package/dist/native/components/ion-menu-button.js +0 -31
- package/dist/native/components/ion-menu-button.js.map +0 -1
- package/dist/native/components/ion-segment.d.ts +0 -11
- package/dist/native/components/ion-segment.d.ts.map +0 -1
- package/dist/native/components/ion-segment.js +0 -30
- package/dist/native/components/ion-segment.js.map +0 -1
- package/dist/native/components/ion-tab-bar.d.ts +0 -11
- package/dist/native/components/ion-tab-bar.d.ts.map +0 -1
- package/dist/native/components/ion-tab-bar.js +0 -50
- package/dist/native/components/ion-tab-bar.js.map +0 -1
- package/dist/native/components/searchable-tabs.d.ts +0 -20
- package/dist/native/components/searchable-tabs.d.ts.map +0 -1
- package/dist/native/components/searchable-tabs.js +0 -383
- package/dist/native/components/searchable-tabs.js.map +0 -1
- package/dist/native/definitions.d.ts +0 -152
- package/dist/native/definitions.d.ts.map +0 -1
- package/dist/native/definitions.js +0 -0
- package/dist/native/foldable/fold-state.d.ts +0 -5
- package/dist/native/foldable/fold-state.d.ts.map +0 -1
- package/dist/native/foldable/fold-state.js +0 -14
- package/dist/native/foldable/fold-state.js.map +0 -1
- package/dist/native/foldable/types.d.ts +0 -12
- package/dist/native/foldable/types.d.ts.map +0 -1
- package/dist/native/foldable/types.js +0 -0
- package/dist/native/index.d.ts +0 -11
- package/dist/native/index.d.ts.map +0 -1
- package/dist/native/index.js +0 -242
- package/dist/native/index.js.map +0 -1
- package/dist/native/prehide.d.ts +0 -7
- package/dist/native/prehide.d.ts.map +0 -1
- package/dist/native/prehide.js +0 -230
- package/dist/native/prehide.js.map +0 -1
- package/dist/native/runtime.d.ts +0 -5
- package/dist/native/runtime.d.ts.map +0 -1
- package/dist/native/runtime.js +0 -640
- package/dist/native/runtime.js.map +0 -1
- package/dist/native/shared/candidate.d.ts +0 -21
- package/dist/native/shared/candidate.d.ts.map +0 -1
- package/dist/native/shared/candidate.js +0 -98
- package/dist/native/shared/candidate.js.map +0 -1
- package/dist/native/shared/crossfade.d.ts +0 -10
- package/dist/native/shared/crossfade.d.ts.map +0 -1
- package/dist/native/shared/crossfade.js +0 -50
- package/dist/native/shared/crossfade.js.map +0 -1
- package/dist/native/shared/dom.d.ts +0 -46
- package/dist/native/shared/dom.d.ts.map +0 -1
- package/dist/native/shared/dom.js +0 -172
- package/dist/native/shared/dom.js.map +0 -1
- package/dist/native/shared/events.d.ts +0 -11
- package/dist/native/shared/events.d.ts.map +0 -1
- package/dist/native/shared/events.js +0 -13
- package/dist/native/shared/events.js.map +0 -1
- package/dist/native/shared/icons.d.ts +0 -8
- package/dist/native/shared/icons.d.ts.map +0 -1
- package/dist/native/shared/icons.js +0 -61
- package/dist/native/shared/icons.js.map +0 -1
- package/dist/native/shared/modal.d.ts +0 -10
- package/dist/native/shared/modal.d.ts.map +0 -1
- package/dist/native/shared/modal.js +0 -160
- package/dist/native/shared/modal.js.map +0 -1
- package/dist/native/vertical-bars-web-search.d.ts +0 -9
- package/dist/native/vertical-bars-web-search.d.ts.map +0 -1
- package/dist/native/vertical-bars-web-search.js +0 -84
- package/dist/native/vertical-bars-web-search.js.map +0 -1
- package/dist/native/vertical-bars-web.d.ts +0 -5
- package/dist/native/vertical-bars-web.d.ts.map +0 -1
- package/dist/native/vertical-bars-web.js +0 -341
- package/dist/native/vertical-bars-web.js.map +0 -1
- package/dist/native-integration/index.d.ts +0 -23
- package/dist/native-integration/index.d.ts.map +0 -1
- package/dist/native-integration/index.js.map +0 -1
- package/dist/native-integration/transition.d.ts +0 -5
- package/dist/native-integration/transition.d.ts.map +0 -1
- package/dist/native-integration/transition.js +0 -16
- package/dist/native-integration/transition.js.map +0 -1
- package/dist/vertical-bars.d.ts +0 -5
- package/dist/vertical-bars.js +0 -4
- package/docs/e2e-testing.md +0 -51
- package/docs/feedback.md +0 -65
- package/docs/native-ui-shell.md +0 -285
- package/docs/vertical-bars.md +0 -285
- package/ios/Sources/IonicNativeUIShellPlugin/Components/ShellButton.swift +0 -71
- package/ios/Sources/IonicNativeUIShellPlugin/Components/ShellButtons.swift +0 -24
- package/ios/Sources/IonicNativeUIShellPlugin/Components/ShellComponents.swift +0 -18
- package/ios/Sources/IonicNativeUIShellPlugin/Components/ShellFab.swift +0 -83
- package/ios/Sources/IonicNativeUIShellPlugin/Components/ShellSearchController.swift +0 -432
- package/ios/Sources/IonicNativeUIShellPlugin/Components/ShellSegment.swift +0 -91
- package/ios/Sources/IonicNativeUIShellPlugin/Components/ShellTabBar.swift +0 -221
- package/ios/Sources/IonicNativeUIShellPlugin/Components/ShellVerticalBars.swift +0 -437
- package/ios/Sources/IonicNativeUIShellPlugin/Components/ShellVerticalSearch.swift +0 -118
- package/ios/Sources/IonicNativeUIShellPlugin/IonicNativeUIShellPlugin.swift +0 -396
- package/ios/Sources/IonicNativeUIShellPlugin/Shared/ShellCrossfade.swift +0 -35
- package/ios/Sources/IonicNativeUIShellPlugin/Shared/ShellHost.swift +0 -8
- package/ios/Sources/IonicNativeUIShellPlugin/Shared/ShellRendering.swift +0 -27
- package/ios/Sources/IonicNativeUIShellPlugin/Shared/ShellSnapshot.swift +0 -135
- package/ios/Tests/IonicNativeUIShellPluginTests/ShellSnapshotTests.swift +0 -650
- package/src/native/components/index.ts +0 -53
- package/src/native/components/ion-back-button.ts +0 -19
- package/src/native/components/ion-button.ts +0 -24
- package/src/native/components/ion-buttons.ts +0 -38
- package/src/native/components/ion-fab.ts +0 -151
- package/src/native/components/ion-menu-button.ts +0 -24
- package/src/native/components/ion-segment.ts +0 -27
- package/src/native/components/ion-tab-bar.ts +0 -50
- package/src/native/components/searchable-tabs.ts +0 -459
- package/src/native/definitions.ts +0 -191
- package/src/native/foldable/fold-state.ts +0 -9
- package/src/native/foldable/types.ts +0 -4
- package/src/native/index.ts +0 -281
- package/src/native/prehide.ts +0 -265
- package/src/native/runtime.ts +0 -781
- package/src/native/shared/candidate.ts +0 -150
- package/src/native/shared/crossfade.ts +0 -50
- package/src/native/shared/dom.ts +0 -286
- package/src/native/shared/events.ts +0 -8
- package/src/native/shared/icons.ts +0 -57
- package/src/native/shared/modal.ts +0 -157
- package/src/native/vertical-bars-web-search.ts +0 -80
- package/src/native/vertical-bars-web.ts +0 -411
- package/src/native-integration/transition.ts +0 -15
- package/src/vertical-bars.ts +0 -11
package/dist/native/index.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { NativeUIShellControls, NativeUIShellHandle, NativeUIShellOptions, NativeUIShellPlugin, NativeUIShellStatus, NativeUIShellSuspension, VerticalBarEdge, VerticalBarPlacement, VerticalControlAreaHandle, VerticalControlAreaOptions, WebViewMetrics } from "./definitions.js";
|
|
2
|
-
import { NativeUIShellComponent } from "./components/index.js";
|
|
3
|
-
//#region src/native/index.d.ts
|
|
4
|
-
export declare const IonicNativeUIShell: NativeUIShellPlugin;
|
|
5
|
-
export declare const configureNativeTransition: () => Promise<WebViewMetrics>;
|
|
6
|
-
export declare const setVerticalControlAreaPlacement: (placement: VerticalBarEdge | VerticalBarPlacement, rtl?: boolean) => void;
|
|
7
|
-
export declare const enableVerticalControlArea: (options?: VerticalControlAreaOptions) => Promise<VerticalControlAreaHandle>;
|
|
8
|
-
export declare const enableNativeUIShell: (options?: NativeUIShellOptions) => Promise<NativeUIShellHandle>;
|
|
9
|
-
//#endregion
|
|
10
|
-
export type { NativeUIShellComponent, NativeUIShellControls, NativeUIShellHandle, NativeUIShellOptions, NativeUIShellStatus, NativeUIShellSuspension, VerticalBarEdge, VerticalBarPlacement, VerticalControlAreaHandle, VerticalControlAreaOptions, WebViewMetrics };
|
|
11
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/native/index.ts"],"mappings":";;;qBA+Ba,oBAAkB;qBAoElB,iCAAsC,QAAQ;qBAiD9C,kCAAmC,WAAW,kBAAkB,sBAAsB;qBAqBtF,4BAAmC,UAAS,+BAAkC,QAAQ;qBAgBtF,sBAAuB,UAAS,yBAA4B,QAAQ"}
|
package/dist/native/index.js
DELETED
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
import { setConfig } from "../transition/ios.transition.js";
|
|
2
|
-
import { observeVerticalBarsModals } from "./shared/modal.js";
|
|
3
|
-
import { createRuntime } from "./runtime.js";
|
|
4
|
-
import { createVerticalBarsWebProjection } from "./vertical-bars-web.js";
|
|
5
|
-
import { prehideVerticalBarsToolbarSources } from "./prehide.js";
|
|
6
|
-
import { Capacitor, registerPlugin } from "@capacitor/core";
|
|
7
|
-
//#region src/native/index.ts
|
|
8
|
-
const plugin = registerPlugin("IonicNativeUIShell");
|
|
9
|
-
const IonicNativeUIShell = plugin;
|
|
10
|
-
let active;
|
|
11
|
-
let activeConfiguration;
|
|
12
|
-
const web = (reason) => ({
|
|
13
|
-
getStatus: () => ({
|
|
14
|
-
state: "web",
|
|
15
|
-
projected: 0,
|
|
16
|
-
updates: 0,
|
|
17
|
-
reason
|
|
18
|
-
}),
|
|
19
|
-
suspend: async () => ({ resume: async () => {} }),
|
|
20
|
-
destroy: async () => {}
|
|
21
|
-
});
|
|
22
|
-
const combine = (native, fallback) => ({
|
|
23
|
-
getStatus() {
|
|
24
|
-
const nativeStatus = native.getStatus();
|
|
25
|
-
const fallbackStatus = fallback.getStatus();
|
|
26
|
-
return {
|
|
27
|
-
...nativeStatus,
|
|
28
|
-
state: nativeStatus.state === "stopped" && fallbackStatus.state === "stopped" ? "stopped" : nativeStatus.projected > 0 ? "native" : "web",
|
|
29
|
-
projected: nativeStatus.projected + fallbackStatus.projected,
|
|
30
|
-
updates: nativeStatus.updates + fallbackStatus.updates
|
|
31
|
-
};
|
|
32
|
-
},
|
|
33
|
-
async suspend() {
|
|
34
|
-
const [nativeLease, fallbackLease] = await Promise.all([native.suspend(), fallback.suspend()]);
|
|
35
|
-
return { resume: async () => void await Promise.all([nativeLease.resume(), fallbackLease.resume()]) };
|
|
36
|
-
},
|
|
37
|
-
async destroy() {
|
|
38
|
-
await Promise.all([native.destroy(), fallback.destroy()]);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
/** Wraps a runtime handle with the shared enable-lifecycle: reason, suspend hooks and idempotent destroy. */
|
|
42
|
-
const manage = (handle, lifecycle = {}) => {
|
|
43
|
-
let destroyed = false;
|
|
44
|
-
return {
|
|
45
|
-
getStatus: () => lifecycle.reason ? {
|
|
46
|
-
...handle.getStatus(),
|
|
47
|
-
reason: lifecycle.reason
|
|
48
|
-
} : handle.getStatus(),
|
|
49
|
-
async suspend() {
|
|
50
|
-
const lease = await handle.suspend();
|
|
51
|
-
const resume = lifecycle.suspend?.();
|
|
52
|
-
return { async resume() {
|
|
53
|
-
await lease.resume();
|
|
54
|
-
resume?.();
|
|
55
|
-
} };
|
|
56
|
-
},
|
|
57
|
-
async destroy() {
|
|
58
|
-
if (destroyed) return;
|
|
59
|
-
destroyed = true;
|
|
60
|
-
try {
|
|
61
|
-
await handle.destroy();
|
|
62
|
-
} finally {
|
|
63
|
-
await lifecycle.destroy?.();
|
|
64
|
-
lifecycle.release?.();
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
/** Reads the current native WebView geometry and applies it to page transitions. */
|
|
70
|
-
const configureNativeTransition = async () => {
|
|
71
|
-
const metrics = typeof document !== "undefined" && Capacitor.getPlatform() === "ios" ? await plugin.getWebViewMetrics() : { radius: 0 };
|
|
72
|
-
setConfig({ radius: metrics.radius });
|
|
73
|
-
return metrics;
|
|
74
|
-
};
|
|
75
|
-
/** Resolves a logical vertical-bar edge to the physical side for the given direction. */
|
|
76
|
-
const physicalVerticalBarEdge = (edge, rtl) => edge === "leading" !== rtl ? "left" : "right";
|
|
77
|
-
const elementRtl = (element) => element.closest("[dir]")?.getAttribute("dir") === "rtl";
|
|
78
|
-
const nativePlacements = /* @__PURE__ */ new WeakMap();
|
|
79
|
-
const horizontalFallbackAttribute = "data-native-ui-shell-vertical-bars-suspended";
|
|
80
|
-
const observeNativeVerticalBarsLayout = (doc) => {
|
|
81
|
-
const reconcile = () => {
|
|
82
|
-
const app = doc.querySelector("ion-app");
|
|
83
|
-
if (!app) return;
|
|
84
|
-
const requested = app.classList.contains("ios-theme-vertical-bars") || app.hasAttribute(horizontalFallbackAttribute);
|
|
85
|
-
const suspended = requested && nativePlacements.get(app)?.edge == null;
|
|
86
|
-
if (app.hasAttribute(horizontalFallbackAttribute) !== suspended) app.toggleAttribute(horizontalFallbackAttribute, suspended);
|
|
87
|
-
if (app.classList.contains("ios-theme-vertical-bars") !== (requested && !suspended)) app.classList.toggle("ios-theme-vertical-bars", requested && !suspended);
|
|
88
|
-
};
|
|
89
|
-
const observer = new MutationObserver(reconcile);
|
|
90
|
-
observer.observe(doc.documentElement, {
|
|
91
|
-
childList: true,
|
|
92
|
-
subtree: true,
|
|
93
|
-
attributes: true,
|
|
94
|
-
attributeFilter: ["class"]
|
|
95
|
-
});
|
|
96
|
-
doc.defaultView?.addEventListener("nativeUIShellRefresh", reconcile);
|
|
97
|
-
reconcile();
|
|
98
|
-
return () => {
|
|
99
|
-
observer.disconnect();
|
|
100
|
-
doc.defaultView?.removeEventListener("nativeUIShellRefresh", reconcile);
|
|
101
|
-
const app = doc.querySelector(`ion-app[${horizontalFallbackAttribute}]`);
|
|
102
|
-
if (app) {
|
|
103
|
-
app.removeAttribute(horizontalFallbackAttribute);
|
|
104
|
-
app.classList.add("ios-theme-vertical-bars");
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
};
|
|
108
|
-
/**
|
|
109
|
-
* Applies one placement to the CSS layout and both Web/native projections.
|
|
110
|
-
* Pass `rtl` when the document direction is known; otherwise the nearest `dir` attribute is used.
|
|
111
|
-
*/
|
|
112
|
-
const setVerticalControlAreaPlacement = (placement, rtl) => {
|
|
113
|
-
if (typeof document === "undefined") return;
|
|
114
|
-
const app = document.querySelector("ion-app");
|
|
115
|
-
if (!app) throw new Error("Vertical Control Area requires ion-app");
|
|
116
|
-
const { edge, inset = 0 } = placement && typeof placement === "object" ? placement : {
|
|
117
|
-
edge: placement,
|
|
118
|
-
inset: 0
|
|
119
|
-
};
|
|
120
|
-
if (placement && typeof placement === "object" && placement.nativeEdge !== void 0) nativePlacements.set(app, {
|
|
121
|
-
edge: placement.nativeEdge,
|
|
122
|
-
rtl
|
|
123
|
-
});
|
|
124
|
-
app.removeAttribute(horizontalFallbackAttribute);
|
|
125
|
-
app.classList.toggle("ios-theme-vertical-bars", edge !== null);
|
|
126
|
-
app.classList.toggle("ios-theme-vertical-bars-left", edge !== null && physicalVerticalBarEdge(edge, rtl ?? elementRtl(app)) === "left");
|
|
127
|
-
if (edge && Number.isFinite(inset) && inset > 0) app.style.setProperty("--ios-theme-vertical-bars-native-inset", `${inset}px`);
|
|
128
|
-
else app.style.removeProperty("--ios-theme-vertical-bars-native-inset");
|
|
129
|
-
document.defaultView?.dispatchEvent(new Event("nativeUIShellRefresh"));
|
|
130
|
-
};
|
|
131
|
-
/**
|
|
132
|
-
* Call once after ion-app is mounted. Ionic markup remains the source of truth.
|
|
133
|
-
* Native vertical buttons default to SwiftUI appearance.
|
|
134
|
-
* See VerticalControlAreaOptions for source styling and local overrides.
|
|
135
|
-
*/
|
|
136
|
-
const enableVerticalControlArea = async (options = {}) => {
|
|
137
|
-
const handle = await enableNativeUIShell({
|
|
138
|
-
buttonProjection: options.buttonProjection,
|
|
139
|
-
buttonDefaultFill: options.buttonDefaultFill,
|
|
140
|
-
controls: {
|
|
141
|
-
tabs: true,
|
|
142
|
-
toolbar: true
|
|
143
|
-
},
|
|
144
|
-
verticalBarsOnly: true
|
|
145
|
-
});
|
|
146
|
-
return {
|
|
147
|
-
getStatus: () => handle.getStatus(),
|
|
148
|
-
suspend: () => handle.suspend(),
|
|
149
|
-
destroy: () => handle.destroy(),
|
|
150
|
-
setPlacement: setVerticalControlAreaPlacement
|
|
151
|
-
};
|
|
152
|
-
};
|
|
153
|
-
/** Call once at application startup. Ionic markup remains the source of truth. */
|
|
154
|
-
const enableNativeUIShell = (options = {}) => {
|
|
155
|
-
if (options.enabled === false) {
|
|
156
|
-
const current = active;
|
|
157
|
-
active = void 0;
|
|
158
|
-
activeConfiguration = void 0;
|
|
159
|
-
return current ? current.then(async (handle) => {
|
|
160
|
-
await handle.destroy();
|
|
161
|
-
return web("Disabled");
|
|
162
|
-
}) : Promise.resolve(web("Disabled"));
|
|
163
|
-
}
|
|
164
|
-
if (typeof document === "undefined") return Promise.resolve(web("Requires a document"));
|
|
165
|
-
const controls = options.controls;
|
|
166
|
-
const configuration = JSON.stringify([
|
|
167
|
-
options.verticalBarsOnly === true,
|
|
168
|
-
options.buttonProjection ?? "system",
|
|
169
|
-
options.buttonDefaultFill ?? null,
|
|
170
|
-
...[
|
|
171
|
-
"tabs",
|
|
172
|
-
"toolbar",
|
|
173
|
-
"segment",
|
|
174
|
-
"fab"
|
|
175
|
-
].map((component) => !controls || controls[component] === true)
|
|
176
|
-
]);
|
|
177
|
-
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
|
-
if (active) return active;
|
|
179
|
-
activeConfiguration = configuration;
|
|
180
|
-
const stopModals = observeVerticalBarsModals(document);
|
|
181
|
-
const prehide = options.controls === void 0 || options.controls.toolbar === true ? prehideVerticalBarsToolbarSources(document) : void 0;
|
|
182
|
-
let start;
|
|
183
|
-
const release = () => {
|
|
184
|
-
if (active === start) {
|
|
185
|
-
active = void 0;
|
|
186
|
-
activeConfiguration = void 0;
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
const fallback = (reason) => manage(createVerticalBarsWebProjection(document, options), {
|
|
190
|
-
reason,
|
|
191
|
-
suspend: () => prehide?.suspend(),
|
|
192
|
-
destroy: () => {
|
|
193
|
-
prehide?.stop();
|
|
194
|
-
stopModals();
|
|
195
|
-
},
|
|
196
|
-
release
|
|
197
|
-
});
|
|
198
|
-
return start = active = (async () => {
|
|
199
|
-
if (Capacitor.getPlatform() !== "ios") return fallback("Requires Capacitor iOS");
|
|
200
|
-
let runtime;
|
|
201
|
-
let metricsListener;
|
|
202
|
-
let stopVerticalBarsLayout;
|
|
203
|
-
try {
|
|
204
|
-
if (!(await plugin.configure({ verticalBarsOnly: options.verticalBarsOnly === true })).supported) return fallback("Requires iOS 26 or later");
|
|
205
|
-
if (!options.verticalBarsOnly) stopVerticalBarsLayout = observeNativeVerticalBarsLayout(document);
|
|
206
|
-
const nativeVerticalBars = () => {
|
|
207
|
-
const app = document.querySelector("ion-app.ios-theme-vertical-bars");
|
|
208
|
-
if (!app) return false;
|
|
209
|
-
const reported = nativePlacements.get(app);
|
|
210
|
-
if (!reported?.edge) return false;
|
|
211
|
-
return (app.classList.contains("ios-theme-vertical-bars-left") ? "left" : "right") === physicalVerticalBarEdge(reported.edge, reported.rtl ?? elementRtl(app));
|
|
212
|
-
};
|
|
213
|
-
if (!options.verticalBarsOnly) {
|
|
214
|
-
metricsListener = await plugin.addListener("webViewMetricsChange", (metrics) => {
|
|
215
|
-
setConfig({ radius: metrics.radius });
|
|
216
|
-
});
|
|
217
|
-
await configureNativeTransition().catch(() => void 0);
|
|
218
|
-
}
|
|
219
|
-
const native = await createRuntime(document, plugin, options, nativeVerticalBars, options.verticalBarsOnly === true);
|
|
220
|
-
runtime = combine(native, createVerticalBarsWebProjection(document, options, () => !nativeVerticalBars() || native.getStatus().state === "stopped"));
|
|
221
|
-
return manage(runtime, {
|
|
222
|
-
suspend: () => prehide?.suspend(),
|
|
223
|
-
release,
|
|
224
|
-
destroy: async () => {
|
|
225
|
-
await metricsListener?.remove().catch(() => {});
|
|
226
|
-
stopVerticalBarsLayout?.();
|
|
227
|
-
prehide?.stop();
|
|
228
|
-
stopModals();
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
} catch (error) {
|
|
232
|
-
await runtime?.destroy();
|
|
233
|
-
await metricsListener?.remove().catch(() => {});
|
|
234
|
-
stopVerticalBarsLayout?.();
|
|
235
|
-
return fallback(error instanceof Error ? error.message : String(error));
|
|
236
|
-
}
|
|
237
|
-
})();
|
|
238
|
-
};
|
|
239
|
-
//#endregion
|
|
240
|
-
export { IonicNativeUIShell, configureNativeTransition, enableNativeUIShell, enableVerticalControlArea, setVerticalControlAreaPlacement };
|
|
241
|
-
|
|
242
|
-
//# sourceMappingURL=index.js.map
|
package/dist/native/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,S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CAAC,KAAK,OAAO;IACjB,MAAM,WAAW,iBAAiB,IAAI,GAAG;IACzC,IAAI,CAAC,UAAU,MAAM,OAAO;IAE5B,QADqB,IAAI,UAAU,SAAS,8BAA8B,IAAI,SAAS,aAC/D,wBAAwB,SAAS,MAAM,SAAS,OAAO,WAAW,GAAG,CAAC;GAChG;GACA,IAAI,CAAC,QAAQ,kBAAkB;IAC7B,kBAAkB,MAAM,OAAO,YAAY,yBAAyB,YAAY;KAC9E,UAAU,EAAE,QAAQ,QAAQ,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"}
|
package/dist/native/prehide.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prehide.d.ts","names":[],"sources":["../../src/native/prehide.ts"],"mappings":";qBAmCa,oCAAqC,KAAK;EAAa;EAA2B"}
|
package/dist/native/prehide.js
DELETED
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
import { VERTICAL_BARS_TRANSITION_CANCELED } from "../native-integration/index.js";
|
|
2
|
-
import { modalUsesVerticalBars } from "./shared/modal.js";
|
|
3
|
-
import { childElements, clearVerticalBarsPlacement, createVerticalBarsPageState, isPermanentlyExcluded, isShellDisabled, isVerticalBarsToolbarActionShape, prehiddenClass, prehideRootClass, setVerticalBarsPlacement, syncToolbarText, verticalBarsActionCandidate, verticalBarsBackCandidate, verticalBarsBackWebClass, verticalBarsOwned } from "./shared/dom.js";
|
|
4
|
-
import { LIFECYCLE_DID_ENTER, LIFECYCLE_DID_LEAVE, LIFECYCLE_WILL_ENTER, LIFECYCLE_WILL_LEAVE } from "@ionic/core/components/index.js";
|
|
5
|
-
//#region src/native/prehide.ts
|
|
6
|
-
const overlays = "ion-menu, ion-popover";
|
|
7
|
-
const sourceSelector = "ion-back-button, ion-menu-button, ion-buttons, ion-button";
|
|
8
|
-
const isHtmlElement = (node) => !!node && node.nodeType === 1;
|
|
9
|
-
const asElement = (node) => isHtmlElement(node) ? node : void 0;
|
|
10
|
-
const backSupported = (element) => {
|
|
11
|
-
const back = element;
|
|
12
|
-
return back.icon === void 0 && back.color === void 0 && !!back.shadowRoot;
|
|
13
|
-
};
|
|
14
|
-
const eligibleBack = verticalBarsBackCandidate;
|
|
15
|
-
const eligible = verticalBarsActionCandidate;
|
|
16
|
-
/** Capture toolbar placement once per routed-page epoch, before Ionic paints its transition. */
|
|
17
|
-
const prehideVerticalBarsToolbarSources = (doc) => {
|
|
18
|
-
doc.documentElement.classList.add(prehideRootClass);
|
|
19
|
-
const scopes = /* @__PURE__ */ new Map();
|
|
20
|
-
const owner = /* @__PURE__ */ new WeakMap();
|
|
21
|
-
const pendingBacks = /* @__PURE__ */ new Map();
|
|
22
|
-
const verticalBarsPages = createVerticalBarsPageState();
|
|
23
|
-
const listeners = new AbortController();
|
|
24
|
-
const root = () => doc.querySelector("ion-app.ios-theme-vertical-bars");
|
|
25
|
-
let suspended = 0;
|
|
26
|
-
let stopped = false;
|
|
27
|
-
const routedPage = (element) => element.closest(".ion-page:not(ion-app, body)");
|
|
28
|
-
const release = (scope) => {
|
|
29
|
-
for (const [element, pending] of pendingBacks) {
|
|
30
|
-
if (pending.scope !== scope) continue;
|
|
31
|
-
clearTimeout(pending.timer);
|
|
32
|
-
pendingBacks.delete(element);
|
|
33
|
-
}
|
|
34
|
-
const owned = scopes.get(scope);
|
|
35
|
-
if (!owned) return;
|
|
36
|
-
owned.forEach((element) => {
|
|
37
|
-
if (owner.get(element) !== scope) return;
|
|
38
|
-
owner.delete(element);
|
|
39
|
-
element.classList.remove(prehiddenClass);
|
|
40
|
-
element.classList.remove(verticalBarsBackWebClass);
|
|
41
|
-
clearVerticalBarsPlacement(element);
|
|
42
|
-
});
|
|
43
|
-
scopes.delete(scope);
|
|
44
|
-
};
|
|
45
|
-
const capture = (scope) => {
|
|
46
|
-
if (!root()?.contains(scope) || scope.closest(overlays) || !modalUsesVerticalBars(scope) || verticalBarsPages.isDeparted(scope)) return;
|
|
47
|
-
const owned = scopes.get(scope) ?? /* @__PURE__ */ new Set();
|
|
48
|
-
const place = (element, rail) => {
|
|
49
|
-
if (owned.has(element)) return;
|
|
50
|
-
const previousScope = owner.get(element);
|
|
51
|
-
if (previousScope) scopes.get(previousScope)?.delete(element);
|
|
52
|
-
owner.set(element, scope);
|
|
53
|
-
setVerticalBarsPlacement(element, rail);
|
|
54
|
-
if (element.matches("ion-back-button")) element.classList.toggle(verticalBarsBackWebClass, !rail);
|
|
55
|
-
owned.add(element);
|
|
56
|
-
};
|
|
57
|
-
(scope.matches("ion-back-button") ? [scope] : Array.from(scope.querySelectorAll(sourceSelector))).forEach((element) => {
|
|
58
|
-
if (isShellDisabled(element)) return;
|
|
59
|
-
if (!modalUsesVerticalBars(element) || element.closest(overlays) || scope.matches(".ion-page") && routedPage(element) !== scope) return;
|
|
60
|
-
if (element.matches("ion-buttons")) {
|
|
61
|
-
const children = childElements(element);
|
|
62
|
-
const actions = children.filter((child) => eligible(child) && isVerticalBarsToolbarActionShape(child));
|
|
63
|
-
const group = eligible(element) && actions.length === children.length && (actions.length > 1 || actions.length === 1 && actions[0].matches("ion-menu-button"));
|
|
64
|
-
const freshGroup = !owned.has(element);
|
|
65
|
-
place(element, group);
|
|
66
|
-
children.forEach((child) => {
|
|
67
|
-
if (!child.matches("ion-back-button")) place(child, freshGroup && actions.includes(child));
|
|
68
|
-
});
|
|
69
|
-
} else if (element.matches("ion-back-button") || !element.parentElement?.matches("ion-buttons")) {
|
|
70
|
-
if (owned.has(element)) return;
|
|
71
|
-
if (element.matches("ion-back-button") && eligibleBack(element) && element.icon === void 0 && element.color === void 0 && !element.shadowRoot && !element.classList.contains("hydrated")) {
|
|
72
|
-
const previousPending = pendingBacks.get(element);
|
|
73
|
-
if (previousPending && previousPending.scope !== scope) {
|
|
74
|
-
clearTimeout(previousPending.timer);
|
|
75
|
-
pendingBacks.delete(element);
|
|
76
|
-
}
|
|
77
|
-
if (!pendingBacks.has(element)) {
|
|
78
|
-
const timer = setTimeout(() => {
|
|
79
|
-
if (pendingBacks.get(element)?.scope !== scope) return;
|
|
80
|
-
pendingBacks.delete(element);
|
|
81
|
-
place(element, false);
|
|
82
|
-
reconcile();
|
|
83
|
-
}, 1500);
|
|
84
|
-
pendingBacks.set(element, {
|
|
85
|
-
scope,
|
|
86
|
-
timer
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
const pending = pendingBacks.get(element);
|
|
92
|
-
if (pending) {
|
|
93
|
-
clearTimeout(pending.timer);
|
|
94
|
-
pendingBacks.delete(element);
|
|
95
|
-
}
|
|
96
|
-
place(element, element.matches("ion-back-button") ? eligibleBack(element) && backSupported(element) : eligible(element) && isVerticalBarsToolbarActionShape(element));
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
scopes.set(scope, owned);
|
|
100
|
-
};
|
|
101
|
-
const reconcile = () => {
|
|
102
|
-
syncToolbarText(doc);
|
|
103
|
-
const verticalBars = root();
|
|
104
|
-
if (!verticalBars) {
|
|
105
|
-
Array.from(scopes.keys()).forEach(release);
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
for (const scope of scopes.keys()) if (!scope.isConnected || !modalUsesVerticalBars(scope)) release(scope);
|
|
109
|
-
for (const [element, pending] of pendingBacks) if (element.shadowRoot || element.classList.contains("hydrated")) capture(pending.scope);
|
|
110
|
-
verticalBars.querySelectorAll(".ion-page:not(ion-app, body, .ion-page-hidden)").forEach(capture);
|
|
111
|
-
verticalBars.querySelectorAll(sourceSelector).forEach((element) => {
|
|
112
|
-
if (routedPage(element) || element.closest(overlays)) return;
|
|
113
|
-
const scope = element.closest("ion-toolbar") ?? (element.matches("ion-back-button") ? element : null);
|
|
114
|
-
if (scope) capture(scope);
|
|
115
|
-
});
|
|
116
|
-
for (const owned of scopes.values()) for (const element of owned) {
|
|
117
|
-
const groupOwnsChildren = element.parentElement?.matches("ion-buttons") && verticalBarsOwned(element.parentElement) && childElements(element.parentElement).every((child) => verticalBarsOwned(child));
|
|
118
|
-
const hide = !suspended && verticalBarsOwned(element) && !groupOwnsChildren && element.isConnected && !element.closest(`.ios-theme-native-ui-shell-rejected`) && !isPermanentlyExcluded(element) && !isShellDisabled(element) && (!element.matches("ion-back-button") || backSupported(element) || !element.classList.contains("hydrated")) && (!element.matches("ion-buttons") || childElements(element).every((child) => verticalBarsOwned(child)));
|
|
119
|
-
element.classList.toggle(prehiddenClass, hide);
|
|
120
|
-
if (element.matches("ion-back-button")) element.classList.toggle(verticalBarsBackWebClass, !hide);
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
const onWillEnter = (event) => {
|
|
124
|
-
const page = asElement(event.target);
|
|
125
|
-
if (page?.matches(".ion-page")) {
|
|
126
|
-
verticalBarsPages.lifecycle(event);
|
|
127
|
-
release(page);
|
|
128
|
-
capture(page);
|
|
129
|
-
reconcile();
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
const onPageLifecycle = (event) => {
|
|
133
|
-
verticalBarsPages.lifecycle(event);
|
|
134
|
-
if (event.type !== LIFECYCLE_DID_LEAVE) return;
|
|
135
|
-
const page = asElement(event.target);
|
|
136
|
-
if (page) release(page);
|
|
137
|
-
};
|
|
138
|
-
const onTransitionCanceled = (event) => {
|
|
139
|
-
const leaving = asElement(event.target);
|
|
140
|
-
if (!leaving) return;
|
|
141
|
-
const entering = event.detail?.entering;
|
|
142
|
-
verticalBarsPages.cancel(entering, leaving);
|
|
143
|
-
reconcile();
|
|
144
|
-
};
|
|
145
|
-
doc.addEventListener(LIFECYCLE_WILL_ENTER, onWillEnter, {
|
|
146
|
-
capture: true,
|
|
147
|
-
signal: listeners.signal
|
|
148
|
-
});
|
|
149
|
-
for (const name of [
|
|
150
|
-
LIFECYCLE_WILL_LEAVE,
|
|
151
|
-
LIFECYCLE_DID_ENTER,
|
|
152
|
-
LIFECYCLE_DID_LEAVE
|
|
153
|
-
]) doc.addEventListener(name, onPageLifecycle, {
|
|
154
|
-
capture: true,
|
|
155
|
-
signal: listeners.signal
|
|
156
|
-
});
|
|
157
|
-
doc.addEventListener(VERTICAL_BARS_TRANSITION_CANCELED, onTransitionCanceled, {
|
|
158
|
-
capture: true,
|
|
159
|
-
signal: listeners.signal
|
|
160
|
-
});
|
|
161
|
-
doc.defaultView?.addEventListener("nativeUIShellRefresh", reconcile, { signal: listeners.signal });
|
|
162
|
-
reconcile();
|
|
163
|
-
const mutationRelevant = (record) => {
|
|
164
|
-
if (record.type === "characterData") return record.target.parentElement?.matches("ion-toolbar") === true;
|
|
165
|
-
if (record.type === "childList" && asElement(record.target)?.matches("ion-toolbar")) return true;
|
|
166
|
-
if (record.type === "childList") return [...Array.from(record.addedNodes), ...Array.from(record.removedNodes)].some((node) => isHtmlElement(node) && (node.matches(`${sourceSelector}, .ion-page, ion-toolbar`) || !!node.querySelector(`${sourceSelector}, .ion-page, ion-toolbar`)));
|
|
167
|
-
if (record.attributeName !== "class") return true;
|
|
168
|
-
const current = record.target.className;
|
|
169
|
-
const previous = record.oldValue ?? "";
|
|
170
|
-
const withoutOwned = (value) => value.split(/\s+/).filter((name) => name && ![
|
|
171
|
-
"ios-theme-native-ui-shell-prehidden",
|
|
172
|
-
"ios-theme-native-ui-shell-prehide",
|
|
173
|
-
"ios-theme-vertical-bars-back-web-owned"
|
|
174
|
-
].includes(name)).join(" ");
|
|
175
|
-
return typeof current !== "string" || withoutOwned(previous) !== withoutOwned(current);
|
|
176
|
-
};
|
|
177
|
-
let scheduled = false;
|
|
178
|
-
const observer = new ((doc.defaultView?.MutationObserver) ?? MutationObserver)((records) => {
|
|
179
|
-
if (scheduled || stopped || !records.some(mutationRelevant)) return;
|
|
180
|
-
scheduled = true;
|
|
181
|
-
queueMicrotask(() => {
|
|
182
|
-
scheduled = false;
|
|
183
|
-
if (!stopped) reconcile();
|
|
184
|
-
});
|
|
185
|
-
});
|
|
186
|
-
observer.observe(doc.documentElement, {
|
|
187
|
-
subtree: true,
|
|
188
|
-
childList: true,
|
|
189
|
-
characterData: true,
|
|
190
|
-
attributes: true,
|
|
191
|
-
attributeOldValue: true,
|
|
192
|
-
attributeFilter: [
|
|
193
|
-
"class",
|
|
194
|
-
"data-shell",
|
|
195
|
-
"hidden",
|
|
196
|
-
"inert",
|
|
197
|
-
"icon",
|
|
198
|
-
"color"
|
|
199
|
-
]
|
|
200
|
-
});
|
|
201
|
-
return {
|
|
202
|
-
suspend: () => {
|
|
203
|
-
if (stopped) return () => {};
|
|
204
|
-
suspended++;
|
|
205
|
-
doc.documentElement.classList.remove(prehideRootClass);
|
|
206
|
-
reconcile();
|
|
207
|
-
let resumed = false;
|
|
208
|
-
return () => {
|
|
209
|
-
if (resumed || stopped) return;
|
|
210
|
-
resumed = true;
|
|
211
|
-
if (--suspended === 0) {
|
|
212
|
-
doc.documentElement.classList.add(prehideRootClass);
|
|
213
|
-
reconcile();
|
|
214
|
-
}
|
|
215
|
-
};
|
|
216
|
-
},
|
|
217
|
-
stop: () => {
|
|
218
|
-
if (stopped) return;
|
|
219
|
-
stopped = true;
|
|
220
|
-
observer.disconnect();
|
|
221
|
-
listeners.abort();
|
|
222
|
-
doc.documentElement.classList.remove(prehideRootClass);
|
|
223
|
-
Array.from(scopes.keys()).forEach(release);
|
|
224
|
-
}
|
|
225
|
-
};
|
|
226
|
-
};
|
|
227
|
-
//#endregion
|
|
228
|
-
export { prehideVerticalBarsToolbarSources };
|
|
229
|
-
|
|
230
|
-
//# sourceMappingURL=prehide.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prehide.js","names":[],"sources":["../../src/native/prehide.ts"],"sourcesContent":["import { modalUsesVerticalBars } from './shared/modal';\nimport { LIFECYCLE_DID_ENTER, LIFECYCLE_DID_LEAVE, LIFECYCLE_WILL_ENTER, LIFECYCLE_WILL_LEAVE } from '@ionic/core/components/index.js';\nimport { VERTICAL_BARS_TRANSITION_CANCELED } from '../native-integration';\nimport {\n childElements,\n clearVerticalBarsPlacement,\n createVerticalBarsPageState,\n verticalBarsActionCandidate,\n verticalBarsBackCandidate,\n verticalBarsBackWebClass,\n verticalBarsOwned,\n isVerticalBarsToolbarActionShape,\n isPermanentlyExcluded,\n isShellDisabled,\n prehiddenClass,\n prehideRootClass,\n rejectedClass,\n setVerticalBarsPlacement,\n syncToolbarText,\n} from './shared/dom';\n\nconst overlays = 'ion-menu, ion-popover';\nconst sourceSelector = 'ion-back-button, ion-menu-button, ion-buttons, ion-button';\n// Realm- and teardown-safe: globals such as Element/HTMLElement may be gone\n// when a queued mutation microtask or a stale listener still runs.\nconst isHtmlElement = (node: unknown): node is HTMLElement => !!node && (node as Node).nodeType === 1;\nconst asElement = (node: Node | EventTarget | null): HTMLElement | undefined => (isHtmlElement(node) ? node : undefined);\nconst backSupported = (element: HTMLElement): boolean => {\n const back = element as HTMLIonBackButtonElement;\n return back.icon === undefined && back.color === undefined && !!back.shadowRoot;\n};\nconst eligibleBack = verticalBarsBackCandidate;\nconst eligible = verticalBarsActionCandidate;\n\n/** Capture toolbar placement once per routed-page epoch, before Ionic paints its transition. */\nexport const prehideVerticalBarsToolbarSources = (doc: Document): { suspend: () => () => void; stop: () => void } => {\n doc.documentElement.classList.add(prehideRootClass);\n const scopes = new Map<HTMLElement, Set<HTMLElement>>();\n const owner = new WeakMap<HTMLElement, HTMLElement>();\n const pendingBacks = new Map<HTMLElement, { scope: HTMLElement; timer: ReturnType<typeof setTimeout> }>();\n const verticalBarsPages = createVerticalBarsPageState();\n const listeners = new AbortController();\n const root = () => doc.querySelector<HTMLElement>('ion-app.ios-theme-vertical-bars');\n let suspended = 0;\n let stopped = false;\n const routedPage = (element: HTMLElement) => element.closest<HTMLElement>('.ion-page:not(ion-app, body)');\n const release = (scope: HTMLElement) => {\n for (const [element, pending] of pendingBacks) {\n if (pending.scope !== scope) continue;\n clearTimeout(pending.timer);\n pendingBacks.delete(element);\n }\n const owned = scopes.get(scope);\n if (!owned) return;\n owned.forEach((element) => {\n if (owner.get(element) !== scope) return;\n owner.delete(element);\n element.classList.remove(prehiddenClass);\n element.classList.remove(verticalBarsBackWebClass);\n clearVerticalBarsPlacement(element);\n });\n scopes.delete(scope);\n };\n const capture = (scope: HTMLElement) => {\n if (!root()?.contains(scope) || scope.closest(overlays) || !modalUsesVerticalBars(scope) || verticalBarsPages.isDeparted(scope)) return;\n const owned = scopes.get(scope) ?? new Set<HTMLElement>();\n const place = (element: HTMLElement, rail: boolean) => {\n if (owned.has(element)) return;\n const previousScope = owner.get(element);\n if (previousScope) scopes.get(previousScope)?.delete(element);\n owner.set(element, scope);\n setVerticalBarsPlacement(element, rail);\n if (element.matches('ion-back-button')) element.classList.toggle(verticalBarsBackWebClass, !rail);\n owned.add(element);\n };\n const sources = scope.matches('ion-back-button') ? [scope] : Array.from(scope.querySelectorAll<HTMLElement>(sourceSelector));\n sources.forEach((element) => {\n // Shell opt-out is temporary; decide initial placement once it is lifted.\n if (isShellDisabled(element)) return;\n if (!modalUsesVerticalBars(element) || element.closest(overlays) || (scope.matches('.ion-page') && routedPage(element) !== scope))\n return;\n if (element.matches('ion-buttons')) {\n const children = childElements(element);\n const actions = children.filter((child) => eligible(child) && isVerticalBarsToolbarActionShape(child));\n const group =\n eligible(element) &&\n actions.length === children.length &&\n (actions.length > 1 || (actions.length === 1 && actions[0].matches('ion-menu-button')));\n const freshGroup = !owned.has(element);\n place(element, group);\n children.forEach((child) => {\n if (!child.matches('ion-back-button')) place(child, freshGroup && actions.includes(child));\n });\n } else if (element.matches('ion-back-button') || !element.parentElement?.matches('ion-buttons')) {\n if (owned.has(element)) return;\n if (\n element.matches('ion-back-button') &&\n eligibleBack(element) &&\n (element as HTMLIonBackButtonElement).icon === undefined &&\n (element as HTMLIonBackButtonElement).color === undefined &&\n !element.shadowRoot &&\n !element.classList.contains('hydrated')\n ) {\n const previousPending = pendingBacks.get(element);\n if (previousPending && previousPending.scope !== scope) {\n clearTimeout(previousPending.timer);\n pendingBacks.delete(element);\n }\n if (!pendingBacks.has(element)) {\n const timer = setTimeout(() => {\n if (pendingBacks.get(element)?.scope !== scope) return;\n pendingBacks.delete(element);\n // A custom element that never hydrates must remain usable on Web.\n place(element, false);\n reconcile();\n }, 1500);\n pendingBacks.set(element, { scope, timer });\n }\n return;\n }\n const pending = pendingBacks.get(element);\n if (pending) {\n clearTimeout(pending.timer);\n pendingBacks.delete(element);\n }\n place(\n element,\n element.matches('ion-back-button')\n ? eligibleBack(element) && backSupported(element)\n : eligible(element) && isVerticalBarsToolbarActionShape(element),\n );\n }\n });\n scopes.set(scope, owned);\n };\n const reconcile = () => {\n syncToolbarText(doc);\n const verticalBars = root();\n if (!verticalBars) {\n Array.from(scopes.keys()).forEach(release);\n return;\n }\n for (const scope of scopes.keys()) if (!scope.isConnected || !modalUsesVerticalBars(scope)) release(scope);\n for (const [element, pending] of pendingBacks) if (element.shadowRoot || element.classList.contains('hydrated')) capture(pending.scope);\n // Ionic inserts the destination as invisible before WillEnter. Hide its\n // sources in that same mutation microtask; capture new DOM identities on active pages too.\n verticalBars.querySelectorAll<HTMLElement>('.ion-page:not(ion-app, body, .ion-page-hidden)').forEach(capture);\n // Root toolbars can mount after startup; each new DOM identity is captured once.\n verticalBars.querySelectorAll<HTMLElement>(sourceSelector).forEach((element) => {\n if (routedPage(element) || element.closest(overlays)) return;\n const scope = element.closest<HTMLElement>('ion-toolbar') ?? (element.matches('ion-back-button') ? element : null);\n if (scope) capture(scope);\n });\n for (const owned of scopes.values()) {\n for (const element of owned) {\n const groupOwnsChildren =\n element.parentElement?.matches('ion-buttons') &&\n verticalBarsOwned(element.parentElement) &&\n childElements(element.parentElement).every((child) => verticalBarsOwned(child));\n const hide =\n !suspended &&\n verticalBarsOwned(element) &&\n !groupOwnsChildren &&\n element.isConnected &&\n !element.closest(`.${rejectedClass}`) &&\n !isPermanentlyExcluded(element) &&\n !isShellDisabled(element) &&\n (!element.matches('ion-back-button') || backSupported(element) || !element.classList.contains('hydrated')) &&\n (!element.matches('ion-buttons') || childElements(element).every((child) => verticalBarsOwned(child)));\n element.classList.toggle(prehiddenClass, hide);\n if (element.matches('ion-back-button')) element.classList.toggle(verticalBarsBackWebClass, !hide);\n }\n }\n };\n const onWillEnter = (event: Event) => {\n const page = asElement(event.target);\n if (page?.matches('.ion-page')) {\n verticalBarsPages.lifecycle(event);\n release(page); // Cached pages begin a new placement epoch.\n capture(page);\n reconcile();\n }\n };\n const onPageLifecycle: EventListener = (event) => {\n verticalBarsPages.lifecycle(event);\n if (event.type !== LIFECYCLE_DID_LEAVE) return;\n const page = asElement(event.target);\n if (page) release(page);\n };\n // A canceled transition keeps the leaving page active and abandons the entering one.\n const onTransitionCanceled: EventListener = (event) => {\n const leaving = asElement(event.target);\n if (!leaving) return;\n const entering = (event as CustomEvent<{ entering?: HTMLElement }>).detail?.entering;\n verticalBarsPages.cancel(entering, leaving);\n reconcile();\n };\n doc.addEventListener(LIFECYCLE_WILL_ENTER, onWillEnter, { capture: true, signal: listeners.signal });\n for (const name of [LIFECYCLE_WILL_LEAVE, LIFECYCLE_DID_ENTER, LIFECYCLE_DID_LEAVE])\n doc.addEventListener(name, onPageLifecycle, { capture: true, signal: listeners.signal });\n doc.addEventListener(VERTICAL_BARS_TRANSITION_CANCELED, onTransitionCanceled, { capture: true, signal: listeners.signal });\n doc.defaultView?.addEventListener('nativeUIShellRefresh', reconcile, { signal: listeners.signal });\n reconcile();\n const mutationRelevant = (record: MutationRecord) => {\n if (record.type === 'characterData') return record.target.parentElement?.matches('ion-toolbar') === true;\n if (record.type === 'childList' && asElement(record.target)?.matches('ion-toolbar')) return true;\n if (record.type === 'childList')\n return [...Array.from(record.addedNodes), ...Array.from(record.removedNodes)].some(\n (node) =>\n isHtmlElement(node) &&\n (node.matches(`${sourceSelector}, .ion-page, ion-toolbar`) || !!node.querySelector(`${sourceSelector}, .ion-page, ion-toolbar`)),\n );\n if (record.attributeName !== 'class') return true;\n const current = (record.target as Element).className;\n const previous = record.oldValue ?? '';\n const withoutOwned = (value: string) =>\n value\n .split(/\\s+/)\n .filter((name) => name && ![prehiddenClass, prehideRootClass, verticalBarsBackWebClass].includes(name))\n .join(' ');\n return typeof current !== 'string' || withoutOwned(previous) !== withoutOwned(current);\n };\n let scheduled = false;\n const observer = new (doc.defaultView?.MutationObserver ?? MutationObserver)((records) => {\n if (scheduled || stopped || !records.some(mutationRelevant)) return;\n scheduled = true;\n queueMicrotask(() => {\n scheduled = false;\n if (!stopped) reconcile();\n });\n });\n observer.observe(doc.documentElement, {\n subtree: true,\n childList: true,\n characterData: true,\n attributes: true,\n attributeOldValue: true,\n attributeFilter: ['class', 'data-shell', 'hidden', 'inert', 'icon', 'color'],\n });\n return {\n suspend: () => {\n if (stopped) return () => {};\n suspended++;\n doc.documentElement.classList.remove(prehideRootClass);\n reconcile();\n let resumed = false;\n return () => {\n if (resumed || stopped) return;\n resumed = true;\n if (--suspended === 0) {\n doc.documentElement.classList.add(prehideRootClass);\n reconcile();\n }\n };\n },\n stop: () => {\n if (stopped) return;\n stopped = true;\n observer.disconnect();\n listeners.abort();\n doc.documentElement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UIShellPlugin } from "./definitions.js";
|
|
2
|
-
//#region src/native/runtime.d.ts
|
|
3
|
-
export declare const createRuntime: (doc: Document, plugin: NativeUIShellPlugin, options?: NativeUIShellOptions, nativeVerticalBars?: () => boolean, verticalBarsOnly?: boolean) => Promise<NativeUIShellHandle>;
|
|
4
|
-
//#endregion
|
|
5
|
-
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","names":[],"sources":["../../src/native/runtime.ts"],"mappings":";;qBA2Ca,gBACX,KAAK,UACL,QAAQ,qBACR,UAAS,sBACT,oCACA,+BACC,QAAQ"}
|