@solidnative-dev/runtime 0.0.0-stage → 0.1.0-beta.0

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.
@@ -0,0 +1,138 @@
1
+ import { createCausalDebugSnapshot, serializeSolidDiagnosticsDebugEnvelope, serializeTreeDebugSnapshot, } from "@solidnative-dev/observability";
2
+ export const NATIVE_DEBUG_OPERATION_CAUSAL_SNAPSHOT = "causal-snapshot";
3
+ export const NATIVE_DEBUG_OPERATION_SOLID_DIAGNOSTICS_BEGIN = "solid-diagnostics-begin";
4
+ export const NATIVE_DEBUG_OPERATION_SOLID_DIAGNOSTICS_END = "solid-diagnostics-end";
5
+ export const NATIVE_DEBUG_OPERATION_TREE_SNAPSHOT = "tree-snapshot";
6
+ const REQUEST_ID_PATTERN = /^[a-f0-9]{32}$/u;
7
+ function debugRequest(value) {
8
+ if (typeof value !== "object" ||
9
+ value === null ||
10
+ !("requestId" in value) ||
11
+ typeof value.requestId !== "string" ||
12
+ !REQUEST_ID_PATTERN.test(value.requestId)) {
13
+ throw new TypeError("Native debug request is invalid.");
14
+ }
15
+ const operation = !("operation" in value) || value.operation === undefined
16
+ ? NATIVE_DEBUG_OPERATION_CAUSAL_SNAPSHOT
17
+ : value.operation;
18
+ if (operation !== NATIVE_DEBUG_OPERATION_CAUSAL_SNAPSHOT &&
19
+ operation !== NATIVE_DEBUG_OPERATION_SOLID_DIAGNOSTICS_BEGIN &&
20
+ operation !== NATIVE_DEBUG_OPERATION_SOLID_DIAGNOSTICS_END &&
21
+ operation !== NATIVE_DEBUG_OPERATION_TREE_SNAPSHOT) {
22
+ throw new TypeError("Native debug request operation is invalid.");
23
+ }
24
+ const sessionId = "sessionId" in value ? value.sessionId : undefined;
25
+ if (operation === NATIVE_DEBUG_OPERATION_SOLID_DIAGNOSTICS_END) {
26
+ if (typeof sessionId !== "string" || !REQUEST_ID_PATTERN.test(sessionId)) {
27
+ throw new TypeError("Native diagnostics end request session is invalid.");
28
+ }
29
+ }
30
+ else if (sessionId !== undefined) {
31
+ throw new TypeError("Native debug request session is unexpected.");
32
+ }
33
+ return {
34
+ requestId: value.requestId,
35
+ operation,
36
+ ...(sessionId === undefined ? {} : { sessionId }),
37
+ };
38
+ }
39
+ function diagnosticsControlPayload(operation, active, ok, error) {
40
+ return JSON.stringify({
41
+ schemaVersion: 0,
42
+ kind: "solid-native.solid-diagnostics-debug-control",
43
+ operation,
44
+ ok,
45
+ active,
46
+ ...(error === undefined ? {} : { error }),
47
+ });
48
+ }
49
+ function treeControlPayload(error) {
50
+ return JSON.stringify({
51
+ schemaVersion: 0,
52
+ kind: "solid-native.tree-debug-control",
53
+ operation: NATIVE_DEBUG_OPERATION_TREE_SNAPSHOT,
54
+ ok: false,
55
+ error,
56
+ });
57
+ }
58
+ export function reportNativeDebugError(reporter, error) {
59
+ if (reporter === undefined)
60
+ return;
61
+ try {
62
+ reporter(error);
63
+ }
64
+ catch {
65
+ // A diagnostic callback cannot affect the request transport.
66
+ }
67
+ }
68
+ /** Pure request dispatcher shared by the React Native transport and tests. */
69
+ export function createNativeDebugRequestHandler(timeline, options, publish) {
70
+ const diagnostics = options.solidDiagnostics;
71
+ let diagnosticsSessionId;
72
+ return (event) => {
73
+ let request;
74
+ let payload;
75
+ try {
76
+ request = debugRequest(event);
77
+ if (request.operation === NATIVE_DEBUG_OPERATION_CAUSAL_SNAPSHOT) {
78
+ payload = JSON.stringify(createCausalDebugSnapshot(timeline.snapshot()));
79
+ }
80
+ else if (request.operation === NATIVE_DEBUG_OPERATION_TREE_SNAPSHOT) {
81
+ const snapshot = options.snapshotTree?.();
82
+ payload =
83
+ snapshot === undefined
84
+ ? treeControlPayload("unavailable")
85
+ : serializeTreeDebugSnapshot(snapshot);
86
+ }
87
+ else if (diagnostics === undefined || !diagnostics.available) {
88
+ payload = diagnosticsControlPayload(request.operation, diagnostics?.active ?? false, false, "unavailable");
89
+ }
90
+ else if (request.operation === NATIVE_DEBUG_OPERATION_SOLID_DIAGNOSTICS_BEGIN) {
91
+ if (diagnostics.active || diagnosticsSessionId !== undefined) {
92
+ payload = diagnosticsControlPayload(request.operation, diagnostics.active, false, "invalid-state");
93
+ }
94
+ else {
95
+ diagnostics.begin();
96
+ if (!diagnostics.active) {
97
+ diagnostics.dispose();
98
+ throw new Error("Solid diagnostics controller did not activate capture.");
99
+ }
100
+ diagnosticsSessionId = request.requestId;
101
+ payload = diagnosticsControlPayload(request.operation, diagnostics.active, true);
102
+ }
103
+ }
104
+ else if (!diagnostics.active ||
105
+ diagnosticsSessionId === undefined ||
106
+ request.sessionId !== diagnosticsSessionId) {
107
+ payload = diagnosticsControlPayload(request.operation, diagnostics.active, false, "invalid-state");
108
+ }
109
+ else {
110
+ try {
111
+ payload = serializeSolidDiagnosticsDebugEnvelope(diagnostics.end());
112
+ }
113
+ finally {
114
+ diagnosticsSessionId = undefined;
115
+ }
116
+ }
117
+ }
118
+ catch (error) {
119
+ reportNativeDebugError(options.reportError, error);
120
+ if (request === undefined)
121
+ return;
122
+ if (request.operation === NATIVE_DEBUG_OPERATION_CAUSAL_SNAPSHOT)
123
+ return;
124
+ if (request.operation === NATIVE_DEBUG_OPERATION_TREE_SNAPSHOT) {
125
+ payload = treeControlPayload("capture-failed");
126
+ }
127
+ else {
128
+ payload = diagnosticsControlPayload(request.operation, diagnostics?.active ?? false, false, "capture-failed");
129
+ }
130
+ }
131
+ if (request === undefined || payload === undefined)
132
+ return;
133
+ void publish(request.requestId, payload).catch((error) => {
134
+ reportNativeDebugError(options.reportError, error);
135
+ });
136
+ };
137
+ }
138
+ //# sourceMappingURL=native-debug-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-debug-handler.js","sourceRoot":"","sources":["../src/native-debug-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,sCAAsC,EACtC,0BAA0B,GAI3B,MAAM,gCAAgC,CAAC;AAExC,MAAM,CAAC,MAAM,sCAAsC,GACjD,iBAA0B,C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AW,EAAE,KAAK,CAAC,CAAC;QACrD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,97 @@
1
+ import { REACT_NATIVE_0_88_RELEASE } from "@solidnative-dev/react-native-compat";
2
+ export type NativeAppState = "active" | "background" | "extension" | "inactive" | "unknown";
3
+ export declare const NATIVE_PLATFORM_MAX_URL_LENGTH = 8192;
4
+ export interface NativeSubscription {
5
+ remove(): void;
6
+ }
7
+ export interface NativeURLEvent {
8
+ readonly url: string;
9
+ }
10
+ export interface NativeKeyboardMetrics {
11
+ readonly screenX: number;
12
+ readonly screenY: number;
13
+ readonly width: number;
14
+ readonly height: number;
15
+ }
16
+ export interface NativeWindowMetrics {
17
+ readonly width: number;
18
+ readonly height: number;
19
+ readonly scale: number;
20
+ readonly fontScale: number;
21
+ }
22
+ export type NativeColorScheme = "light" | "dark";
23
+ export type NativeColorSchemeOverride = NativeColorScheme | "system";
24
+ export type NativeStatusBarStyle = "default" | "auto" | "light-content" | "dark-content";
25
+ export type NativeStatusBarAnimation = "none" | "fade" | "slide";
26
+ export interface NativeStatusBarConfiguration {
27
+ readonly animated?: boolean;
28
+ readonly barStyle?: NativeStatusBarStyle;
29
+ readonly hidden?: boolean;
30
+ readonly showHideTransition?: NativeStatusBarAnimation;
31
+ }
32
+ export interface NativeStatusBarStackEntry {
33
+ replace(configuration: NativeStatusBarConfiguration): void;
34
+ remove(): void;
35
+ }
36
+ export type NativeKeyboardState = {
37
+ readonly visible: false;
38
+ readonly metrics?: undefined;
39
+ } | {
40
+ readonly visible: true;
41
+ readonly metrics: NativeKeyboardMetrics;
42
+ };
43
+ export interface NativePlatformFingerprint {
44
+ readonly backend: "react-native";
45
+ readonly backendVersion: typeof REACT_NATIVE_0_88_RELEASE.runtimeVersion;
46
+ readonly platform: "android" | "ios";
47
+ }
48
+ export interface NativePlatformServices extends NativePlatformFingerprint {
49
+ readonly initialAppState: NativeAppState;
50
+ canOpenURL(url: string): Promise<boolean>;
51
+ dismissKeyboard(): void;
52
+ getColorScheme(): NativeColorScheme;
53
+ getKeyboardState(): NativeKeyboardState;
54
+ getInitialURL(): Promise<string | null>;
55
+ getWindowMetrics(): NativeWindowMetrics;
56
+ openSettings(): Promise<void>;
57
+ openURL(url: string): Promise<void>;
58
+ pushStatusBarEntry(configuration: NativeStatusBarConfiguration): NativeStatusBarStackEntry;
59
+ setColorSchemeOverride(scheme: NativeColorSchemeOverride): void;
60
+ subscribeAppState(listener: (state: NativeAppState) => void): NativeSubscription;
61
+ subscribeColorScheme(listener: (scheme: NativeColorScheme) => void): NativeSubscription;
62
+ subscribeHardwareBack(listener: () => boolean): NativeSubscription;
63
+ subscribeKeyboard(listener: (state: NativeKeyboardState) => void): NativeSubscription;
64
+ /** Emits when the backend reports platform memory pressure. */
65
+ subscribeMemoryWarning(listener: () => void): NativeSubscription;
66
+ subscribeURL(listener: (event: NativeURLEvent) => void): NativeSubscription;
67
+ subscribeWindowMetrics(listener: (metrics: NativeWindowMetrics) => void): NativeSubscription;
68
+ }
69
+ export interface NativePlatformServicesAdapter {
70
+ canOpenURL(url: string): Promise<unknown>;
71
+ getPlatformConstants(): unknown;
72
+ getColorScheme(): unknown;
73
+ getInitialAppState(): unknown;
74
+ getKeyboardMetrics(): unknown;
75
+ getWindowMetrics(): unknown;
76
+ dismissKeyboard(): void;
77
+ getInitialURL(): Promise<unknown>;
78
+ openSettings(): Promise<unknown>;
79
+ openURL(url: string): Promise<unknown>;
80
+ setColorSchemeOverride(scheme: NativeColorSchemeOverride): void;
81
+ setStatusBarHidden(hidden: boolean, animation: NativeStatusBarAnimation): void;
82
+ setStatusBarStyle(style: Exclude<NativeStatusBarStyle, "auto">, animated: boolean): void;
83
+ subscribeAppState(listener: (state: unknown) => void): NativeSubscription;
84
+ subscribeColorScheme(listener: (scheme: unknown) => void): NativeSubscription;
85
+ subscribeHardwareBack(listener: () => boolean): NativeSubscription;
86
+ subscribeKeyboard(listener: (state: unknown) => void): NativeSubscription;
87
+ subscribeMemoryWarning(listener: () => void): NativeSubscription;
88
+ subscribeURL(listener: (event: unknown) => void): NativeSubscription;
89
+ subscribeWindowMetrics(listener: (metrics: unknown) => void): NativeSubscription;
90
+ }
91
+ /**
92
+ * Validates and narrows the backend-specific native-module surface once. The
93
+ * adapter keeps React Native implementation imports out of portable runtime
94
+ * and application code.
95
+ */
96
+ export declare function createNativePlatformServices(adapter: NativePlatformServicesAdapter): NativePlatformServices;
97
+ //# sourceMappingURL=platform-services.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform-services.d.ts","sourceRoot":"","sources":["../src/platform-services.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EAE1B,MAAM,sCAAsC,CAAC;AAE9C,MAAM,MAAM,cAAc,GACxB,QAAQ,GAAG,YAAY,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,CAAC;AAEjE,eAAO,MAAM,8BAA8B,OAAQ,CAAC;AAEpD,MAAM,WAAW,kBAAkB;IACjC,MAAM,IAAI,IAAI,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,MAAM,CAAC;AACjD,MAAM,MAAM,yBAAyB,GAAG,iBAAiB,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ENGTH = 8_192;
3
+ function record(value, path) {
4
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
5
+ throw new TypeError(`${path} must be an object.`);
6
+ }
7
+ return value;
8
+ }
9
+ function outboundURL(value) {
10
+ if (typeof value !== "string" ||
11
+ value.length === 0 ||
12
+ value.length > NATIVE_PLATFORM_MAX_URL_LENGTH) {
13
+ throw new TypeError(`Native outbound URLs must contain between 1 and ${NATIVE_PLATFORM_MAX_URL_LENGTH} characters.`);
14
+ }
15
+ if (!/^[A-Za-z][A-Za-z\d+.-]*:/u.test(value)) {
16
+ throw new TypeError("Native outbound URLs must include a valid scheme.");
17
+ }
18
+ if (/[\u0000-\u001f\u007f]/u.test(value)) {
19
+ throw new TypeError("Native outbound URLs must not contain control characters.");
20
+ }
21
+ return value;
22
+ }
23
+ function platformFingerprint(constantsValue) {
24
+ const verified = assertVerifiedReactNativePlatform(constantsValue, "Native platform services");
25
+ return Object.freeze({
26
+ backend: "react-native",
27
+ backendVersion: verified.runtimeVersion,
28
+ platform: verified.platform,
29
+ });
30
+ }
31
+ function subscription(value, path) {
32
+ if (typeof value !== "object" ||
33
+ value === null ||
34
+ typeof value.remove !== "function") {
35
+ throw new TypeError(`${path} did not return a removable subscription.`);
36
+ }
37
+ let active = true;
38
+ return {
39
+ remove() {
40
+ if (!active)
41
+ return;
42
+ active = false;
43
+ value.remove();
44
+ },
45
+ };
46
+ }
47
+ function appState(value) {
48
+ if (value !== "active" &&
49
+ value !== "background" &&
50
+ value !== "extension" &&
51
+ value !== "inactive" &&
52
+ value !== "unknown") {
53
+ throw new TypeError(`The native AppState module emitted an invalid state: ${String(value)}.`);
54
+ }
55
+ return value;
56
+ }
57
+ function colorScheme(value, path) {
58
+ if (value !== "light" && value !== "dark") {
59
+ throw new TypeError(`${path} must be light or dark.`);
60
+ }
61
+ return value;
62
+ }
63
+ function colorSchemeOverride(value) {
64
+ if (value !== "light" && value !== "dark" && value !== "system") {
65
+ throw new TypeError("The color-scheme override must be light, dark, or system.");
66
+ }
67
+ return value;
68
+ }
69
+ function booleanValue(value, path) {
70
+ if (typeof value !== "boolean") {
71
+ throw new TypeError(`${path} must be a boolean.`);
72
+ }
73
+ return value;
74
+ }
75
+ function statusBarStyle(value) {
76
+ if (value !== "default" &&
77
+ value !== "auto" &&
78
+ value !== "light-content" &&
79
+ value !== "dark-content") {
80
+ throw new TypeError("StatusBar.barStyle must be default, auto, light-content, or dark-content.");
81
+ }
82
+ return value;
83
+ }
84
+ function statusBarAnimation(value) {
85
+ if (value !== "none" && value !== "fade" && value !== "slide") {
86
+ throw new TypeError("StatusBar.showHideTransition must be none, fade, or slide.");
87
+ }
88
+ return value;
89
+ }
90
+ function statusBarConfiguration(value) {
91
+ const configuration = record(value, "status-bar configuration");
92
+ const animated = configuration.animated === undefined
93
+ ? false
94
+ : booleanValue(configuration.animated, "StatusBar.animated");
95
+ const transition = configuration.showHideTransition === undefined
96
+ ? "fade"
97
+ : statusBarAnimation(configuration.showHideTransition);
98
+ return Object.freeze({
99
+ barStyle: configuration.barStyle === undefined
100
+ ? undefined
101
+ : Object.freeze({
102
+ animated,
103
+ value: statusBarStyle(configuration.barStyle),
104
+ }),
105
+ hidden: configuration.hidden === undefined
106
+ ? undefined
107
+ : Object.freeze({
108
+ animation: animated ? transition : "none",
109
+ value: booleanValue(configuration.hidden, "StatusBar.hidden"),
110
+ }),
111
+ });
112
+ }
113
+ function urlEvent(value) {
114
+ const event = record(value, "native URL event");
115
+ if (typeof event.url !== "string" || event.url.length === 0) {
116
+ throw new TypeError("The native URL event must contain a non-empty URL.");
117
+ }
118
+ return Object.freeze({ url: event.url });
119
+ }
120
+ function finiteCoordinate(value, path) {
121
+ if (typeof value !== "number" || !Number.isFinite(value)) {
122
+ throw new TypeError(`${path} must be a finite number.`);
123
+ }
124
+ return value;
125
+ }
126
+ function keyboardMetrics(value, path) {
127
+ const metrics = record(value, path);
128
+ const width = finiteCoordinate(metrics.width, `${path}.width`);
129
+ const height = finiteCoordinate(metrics.height, `${path}.height`);
130
+ if (width < 0 || height < 0) {
131
+ throw new TypeError(`${path} width and height must be non-negative.`);
132
+ }
133
+ return Object.freeze({
134
+ screenX: finiteCoordinate(metrics.screenX, `${path}.screenX`),
135
+ screenY: finiteCoordinate(metrics.screenY, `${path}.screenY`),
136
+ width,
137
+ height,
138
+ });
139
+ }
140
+ function windowMetrics(value, path) {
141
+ const metrics = record(value, path);
142
+ const width = finiteCoordinate(metrics.width, `${path}.width`);
143
+ const height = finiteCoordinate(metrics.height, `${path}.height`);
144
+ const scale = finiteCoordinate(metrics.scale, `${path}.scale`);
145
+ const fontScale = finiteCoordinate(metrics.fontScale, `${path}.fontScale`);
146
+ if (width < 0 || height < 0) {
147
+ throw new TypeError(`${path} width and height must be non-negative.`);
148
+ }
149
+ if (scale <= 0 || fontScale <= 0) {
150
+ throw new TypeError(`${path} scale and fontScale must be positive.`);
151
+ }
152
+ return Object.freeze({ width, height, scale, fontScale });
153
+ }
154
+ function initialKeyboardState(value) {
155
+ if (value === undefined || value === null) {
156
+ return Object.freeze({ visible: false });
157
+ }
158
+ return Object.freeze({
159
+ visible: true,
160
+ metrics: keyboardMetrics(value, "initial keyboard metrics"),
161
+ });
162
+ }
163
+ function keyboardState(value) {
164
+ const state = record(value, "native keyboard state");
165
+ if (state.visible === false) {
166
+ if (state.metrics !== undefined) {
167
+ throw new TypeError("A hidden native keyboard state must not include metrics.");
168
+ }
169
+ return Object.freeze({ visible: false });
170
+ }
171
+ if (state.visible !== true) {
172
+ throw new TypeError("The native keyboard state must include a boolean visible field.");
173
+ }
174
+ return Object.freeze({
175
+ visible: true,
176
+ metrics: keyboardMetrics(state.metrics, "native keyboard metrics"),
177
+ });
178
+ }
179
+ /**
180
+ * Validates and narrows the backend-specific native-module surface once. The
181
+ * adapter keeps React Native implementation imports out of portable runtime
182
+ * and application code.
183
+ */
184
+ export function createNativePlatformServices(adapter) {
185
+ const fingerprint = platformFingerprint(adapter.getPlatformConstants());
186
+ const statusBarEntries = [];
187
+ let appliedStatusBarState;
188
+ let statusBarAppearance;
189
+ let statusBarAppearanceSubscription;
190
+ const mergedStatusBarState = () => {
191
+ let barStyle = {
192
+ animated: false,
193
+ value: "default",
194
+ };
195
+ let hidden = {
196
+ animation: "none",
197
+ value: false,
198
+ };
199
+ for (const entry of statusBarEntries) {
200
+ barStyle = entry.barStyle ?? barStyle;
201
+ hidden = entry.hidden ?? hidden;
202
+ }
203
+ const resolvedStyle = barStyle.value === "auto"
204
+ ? statusBarAppearance === "dark"
205
+ ? "light-content"
206
+ : "dark-content"
207
+ : barStyle.value;
208
+ return {
209
+ barStyle: { animated: barStyle.animated, value: resolvedStyle },
210
+ hidden,
211
+ };
212
+ };
213
+ const applyStatusBarState = () => {
214
+ const next = mergedStatusBarState();
215
+ if (appliedStatusBarState === undefined ||
216
+ appliedStatusBarState.barStyle.value !== next.barStyle.value) {
217
+ adapter.setStatusBarStyle(next.barStyle.value, next.barStyle.animated);
218
+ }
219
+ if (appliedStatusBarState === undefined ||
220
+ appliedStatusBarState.hidden.value !== next.hidden.value) {
221
+ adapter.setStatusBarHidden(next.hidden.value, next.hidden.animation);
222
+ }
223
+ appliedStatusBarState = next;
224
+ };
225
+ const usesAutomaticStatusBarStyle = () => statusBarEntries.some((entry) => entry.barStyle?.value === "auto");
226
+ const ensureStatusBarAppearanceSubscription = () => {
227
+ if (statusBarAppearanceSubscription !== undefined)
228
+ return;
229
+ const nativeSubscription = subscription(adapter.subscribeColorScheme((value) => {
230
+ statusBarAppearance = colorScheme(value, "native color scheme");
231
+ applyStatusBarState();
232
+ }), "subscribeColorScheme for automatic status-bar style");
233
+ try {
234
+ statusBarAppearance = colorScheme(adapter.getColorScheme(), "current color scheme");
235
+ }
236
+ catch (error) {
237
+ nativeSubscription.remove();
238
+ throw error;
239
+ }
240
+ statusBarAppearanceSubscription = nativeSubscription;
241
+ };
242
+ const updateStatusBarStack = () => {
243
+ const automatic = usesAutomaticStatusBarStyle();
244
+ if (automatic)
245
+ ensureStatusBarAppearanceSubscription();
246
+ applyStatusBarState();
247
+ if (!automatic && statusBarAppearanceSubscription !== undefined) {
248
+ const nativeSubscription = statusBarAppearanceSubscription;
249
+ statusBarAppearanceSubscription = undefined;
250
+ statusBarAppearance = undefined;
251
+ nativeSubscription.remove();
252
+ }
253
+ };
254
+ const services = {
255
+ ...fingerprint,
256
+ initialAppState: appState(adapter.getInitialAppState()),
257
+ async canOpenURL(url) {
258
+ const result = await adapter.canOpenURL(outboundURL(url));
259
+ if (typeof result !== "boolean") {
260
+ throw new TypeError("The native Linking module returned a non-boolean canOpenURL result.");
261
+ }
262
+ return result;
263
+ },
264
+ dismissKeyboard() {
265
+ adapter.dismissKeyboard();
266
+ },
267
+ getColorScheme() {
268
+ return colorScheme(adapter.getColorScheme(), "current color scheme");
269
+ },
270
+ getKeyboardState() {
271
+ return initialKeyboardState(adapter.getKeyboardMetrics());
272
+ },
273
+ getWindowMetrics() {
274
+ return windowMetrics(adapter.getWindowMetrics(), "current window metrics");
275
+ },
276
+ pushStatusBarEntry(configuration) {
277
+ let normalized = statusBarConfiguration(configuration);
278
+ statusBarEntries.push(normalized);
279
+ let active = true;
280
+ try {
281
+ updateStatusBarStack();
282
+ }
283
+ catch (error) {
284
+ statusBarEntries.pop();
285
+ try {
286
+ updateStatusBarStack();
287
+ }
288
+ catch {
289
+ // Preserve the failure from the requested status-bar operation.
290
+ }
291
+ throw error;
292
+ }
293
+ return Object.freeze({
294
+ replace(nextConfiguration) {
295
+ if (!active) {
296
+ throw new Error("Cannot replace a removed status-bar stack entry.");
297
+ }
298
+ const next = statusBarConfiguration(nextConfiguration);
299
+ const index = statusBarEntries.indexOf(normalized);
300
+ if (index === -1) {
301
+ throw new Error("The status-bar stack entry is no longer active.");
302
+ }
303
+ statusBarEntries[index] = next;
304
+ const previous = normalized;
305
+ normalized = next;
306
+ try {
307
+ updateStatusBarStack();
308
+ }
309
+ catch (error) {
310
+ statusBarEntries[index] = previous;
311
+ normalized = previous;
312
+ try {
313
+ updateStatusBarStack();
314
+ }
315
+ catch {
316
+ // Preserve the failure from the requested status-bar operation.
317
+ }
318
+ throw error;
319
+ }
320
+ },
321
+ remove() {
322
+ if (!active)
323
+ return;
324
+ active = false;
325
+ const index = statusBarEntries.indexOf(normalized);
326
+ if (index !== -1)
327
+ statusBarEntries.splice(index, 1);
328
+ updateStatusBarStack();
329
+ },
330
+ });
331
+ },
332
+ setColorSchemeOverride(scheme) {
333
+ adapter.setColorSchemeOverride(colorSchemeOverride(scheme));
334
+ if (statusBarAppearanceSubscription !== undefined) {
335
+ statusBarAppearance = colorScheme(adapter.getColorScheme(), "current color scheme");
336
+ applyStatusBarState();
337
+ }
338
+ },
339
+ async getInitialURL() {
340
+ const value = await adapter.getInitialURL();
341
+ if (value !== null && (typeof value !== "string" || value.length === 0)) {
342
+ throw new TypeError("The native Linking module returned an invalid initial URL.");
343
+ }
344
+ return value;
345
+ },
346
+ async openSettings() {
347
+ await adapter.openSettings();
348
+ },
349
+ async openURL(url) {
350
+ await adapter.openURL(outboundURL(url));
351
+ },
352
+ subscribeAppState(listener) {
353
+ return subscription(adapter.subscribeAppState((value) => listener(appState(value))), "subscribeAppState");
354
+ },
355
+ subscribeColorScheme(listener) {
356
+ const nativeSubscription = subscription(adapter.subscribeColorScheme((value) => listener(colorScheme(value, "native color scheme"))), "subscribeColorScheme");
357
+ try {
358
+ listener(colorScheme(adapter.getColorScheme(), "current color scheme"));
359
+ }
360
+ catch (error) {
361
+ nativeSubscription.remove();
362
+ throw error;
363
+ }
364
+ return nativeSubscription;
365
+ },
366
+ subscribeHardwareBack(listener) {
367
+ return subscription(adapter.subscribeHardwareBack(listener), "subscribeHardwareBack");
368
+ },
369
+ subscribeKeyboard(listener) {
370
+ const nativeSubscription = subscription(adapter.subscribeKeyboard((value) => listener(keyboardState(value))), "subscribeKeyboard");
371
+ try {
372
+ listener(initialKeyboardState(adapter.getKeyboardMetrics()));
373
+ }
374
+ catch (error) {
375
+ nativeSubscription.remove();
376
+ throw error;
377
+ }
378
+ return nativeSubscription;
379
+ },
380
+ subscribeMemoryWarning(listener) {
381
+ return subscription(adapter.subscribeMemoryWarning(listener), "subscribeMemoryWarning");
382
+ },
383
+ subscribeURL(listener) {
384
+ return subscription(adapter.subscribeURL((value) => listener(urlEvent(value))), "subscribeURL");
385
+ },
386
+ subscribeWindowMetrics(listener) {
387
+ const nativeSubscription = subscription(adapter.subscribeWindowMetrics((value) => listener(windowMetrics(value, "native window metrics"))), "subscribeWindowMetrics");
388
+ try {
389
+ listener(windowMetrics(adapter.getWindowMetrics(), "current window metrics"));
390
+ }
391
+ catch (error) {
392
+ nativeSubscription.remove();
393
+ throw error;
394
+ }
395
+ return nativeSubscription;
396
+ },
397
+ };
398
+ return Object.freeze(services);
399
+ }
400
+ //# sourceMappingURL=platform-services.js.map