@ng-native/device 0.22.2 → 0.24.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.
- package/dist/accessibility.d.ts +7 -0
- package/dist/accessibility.js +14 -2
- package/dist/accessibility.js.map +1 -1
- package/dist/app-lifecycle.d.ts +49 -0
- package/dist/app-lifecycle.js +67 -0
- package/dist/app-lifecycle.js.map +1 -0
- package/dist/app-state.d.ts +2 -0
- package/dist/app-state.js +2 -0
- package/dist/app-state.js.map +1 -1
- package/dist/app-windows.d.ts +321 -0
- package/dist/app-windows.js +526 -0
- package/dist/app-windows.js.map +1 -0
- package/dist/color-scheme.d.ts +5 -0
- package/dist/color-scheme.js +16 -0
- package/dist/color-scheme.js.map +1 -1
- package/dist/conditions.d.ts +11 -3
- package/dist/conditions.js +42 -9
- package/dist/conditions.js.map +1 -1
- package/dist/control-size.d.ts +6 -0
- package/dist/control-size.js +2 -0
- package/dist/control-size.js.map +1 -0
- package/dist/deep-links.d.ts +3 -1
- package/dist/deep-links.js +3 -1
- package/dist/deep-links.js.map +1 -1
- package/dist/desktop-options.d.ts +73 -0
- package/dist/desktop-options.js +182 -0
- package/dist/desktop-options.js.map +1 -0
- package/dist/desktop-permissions.d.ts +30 -0
- package/dist/desktop-permissions.js +169 -0
- package/dist/desktop-permissions.js.map +1 -0
- package/dist/dev-menu.d.ts +2 -2
- package/dist/dev-menu.js +3 -5
- package/dist/dev-menu.js.map +1 -1
- package/dist/dialogs.d.ts +9 -7
- package/dist/dialogs.js +15 -10
- package/dist/dialogs.js.map +1 -1
- package/dist/direction.d.ts +2 -0
- package/dist/direction.js +2 -0
- package/dist/direction.js.map +1 -1
- package/dist/dock.d.ts +48 -0
- package/dist/dock.js +70 -0
- package/dist/dock.js.map +1 -0
- package/dist/drag-and-drop.d.ts +67 -0
- package/dist/drag-and-drop.js +74 -0
- package/dist/drag-and-drop.js.map +1 -0
- package/dist/expo-view-name.d.ts +16 -0
- package/dist/expo-view-name.js +22 -0
- package/dist/expo-view-name.js.map +1 -0
- package/dist/hardware-back.d.ts +3 -10
- package/dist/hardware-back.js +4 -1
- package/dist/hardware-back.js.map +1 -1
- package/dist/index.d.ts +26 -2
- package/dist/index.js +26 -2
- package/dist/index.js.map +1 -1
- package/dist/interaction-observer.d.ts +117 -0
- package/dist/interaction-observer.js +241 -0
- package/dist/interaction-observer.js.map +1 -0
- package/dist/keyboard.d.ts +2 -8
- package/dist/keyboard.js +3 -0
- package/dist/keyboard.js.map +1 -1
- package/dist/layout-animation.d.ts +3 -1
- package/dist/layout-animation.js +3 -1
- package/dist/layout-animation.js.map +1 -1
- package/dist/menu-model.d.ts +108 -0
- package/dist/menu-model.js +259 -0
- package/dist/menu-model.js.map +1 -0
- package/dist/menu-template.d.ts +19 -0
- package/dist/menu-template.js +31 -0
- package/dist/menu-template.js.map +1 -0
- package/dist/menus.d.ts +225 -0
- package/dist/menus.js +341 -0
- package/dist/menus.js.map +1 -0
- package/dist/navigation-bar.d.ts +2 -12
- package/dist/navigation-bar.js +4 -1
- package/dist/navigation-bar.js.map +1 -1
- package/dist/os-support.d.ts +42 -0
- package/dist/os-support.js +207 -0
- package/dist/os-support.js.map +1 -0
- package/dist/os.d.ts +26 -5
- package/dist/os.js +35 -7
- package/dist/os.js.map +1 -1
- package/dist/own-host.d.ts +27 -0
- package/dist/own-host.js +79 -0
- package/dist/own-host.js.map +1 -0
- package/dist/processes.d.ts +116 -0
- package/dist/processes.js +177 -0
- package/dist/processes.js.map +1 -0
- package/dist/react-native.d.ts +19 -0
- package/dist/react-native.js.map +1 -1
- package/dist/safe-area.d.ts +12 -1
- package/dist/safe-area.js +16 -2
- package/dist/safe-area.js.map +1 -1
- package/dist/screen.d.ts +2 -0
- package/dist/screen.js +2 -0
- package/dist/screen.js.map +1 -1
- package/dist/sharing.d.ts +3 -1
- package/dist/sharing.js +8 -1
- package/dist/sharing.js.map +1 -1
- package/dist/shell.d.ts +33 -0
- package/dist/shell.js +73 -0
- package/dist/shell.js.map +1 -0
- package/dist/shortcut.d.ts +49 -0
- package/dist/shortcut.js +92 -0
- package/dist/shortcut.js.map +1 -0
- package/dist/sidebar-selection.d.ts +8 -0
- package/dist/sidebar-selection.js +9 -0
- package/dist/sidebar-selection.js.map +1 -0
- package/dist/spawn-rules.d.ts +108 -0
- package/dist/spawn-rules.js +313 -0
- package/dist/spawn-rules.js.map +1 -0
- package/dist/split-views.d.ts +7 -0
- package/dist/split-views.js +21 -0
- package/dist/split-views.js.map +1 -0
- package/dist/status-bar.d.ts +2 -12
- package/dist/status-bar.js +3 -0
- package/dist/status-bar.js.map +1 -1
- package/dist/tray.d.ts +63 -0
- package/dist/tray.js +76 -0
- package/dist/tray.js.map +1 -0
- package/dist/undo-stack.d.ts +64 -0
- package/dist/undo-stack.js +110 -0
- package/dist/undo-stack.js.map +1 -0
- package/dist/vibration.d.ts +3 -14
- package/dist/vibration.js +4 -1
- package/dist/vibration.js.map +1 -1
- package/dist/window-navigator.d.ts +25 -0
- package/dist/window-navigator.js +7 -0
- package/dist/window-navigator.js.map +1 -0
- package/dist/window-restore.d.ts +45 -0
- package/dist/window-restore.js +66 -0
- package/dist/window-restore.js.map +1 -0
- package/package.json +10 -2
package/dist/tray.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Icons in the macOS menu bar's status area, each with a menu or a press of its own. `<tray-icon>`
|
|
3
|
+
* in `@ng-native/components` registers here. Absent on iOS and Android, where nothing is drawn.
|
|
4
|
+
*
|
|
5
|
+
* The host contract, on the `NgNativeTray` module: `setIcons(icons)` takes every icon each time one
|
|
6
|
+
* changes, as `{ id, title, sfSymbol, image, tooltip, menu }`, `menu` as `serializeMenu` makes it
|
|
7
|
+
* (null for an icon with a press instead). It sends `{ type: 'press', icon }` and
|
|
8
|
+
* `{ type: 'menuSelect', icon, id }` on `ngNativeTray`.
|
|
9
|
+
*/
|
|
10
|
+
import { InjectionToken, Service, computed, effect, inject, signal, } from '@angular/core';
|
|
11
|
+
import { serializeMenu } from "./menus.js";
|
|
12
|
+
import { reactNative } from "./react-native.js";
|
|
13
|
+
import * as i0 from "@angular/core";
|
|
14
|
+
function traySource() {
|
|
15
|
+
const native = reactNative();
|
|
16
|
+
const module = native?.TurboModuleRegistry?.get?.('NgNativeTray');
|
|
17
|
+
if (!module)
|
|
18
|
+
return null;
|
|
19
|
+
return {
|
|
20
|
+
setIcons: (icons) => module.setIcons?.(icons),
|
|
21
|
+
subscribe: (listener) => {
|
|
22
|
+
const subscription = native?.DeviceEventEmitter?.addListener('ngNativeTray', (event) => listener(event));
|
|
23
|
+
return () => subscription?.remove();
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export class Tray {
|
|
28
|
+
/** Overridden in a test with a fake host. */
|
|
29
|
+
static SOURCE = new InjectionToken('angular-native.traySource', {
|
|
30
|
+
factory: traySource,
|
|
31
|
+
});
|
|
32
|
+
native = inject(Tray.SOURCE);
|
|
33
|
+
icons = signal([], /* @ts-ignore */
|
|
34
|
+
...(ngDevMode ? [{ debugName: "icons" }] : /* istanbul ignore next */ []));
|
|
35
|
+
next = 0;
|
|
36
|
+
/** Whether the OS has a status area for the app: macOS. */
|
|
37
|
+
available = signal(this.native !== null).asReadonly();
|
|
38
|
+
sent = computed(() => this.icons().map(({ id, model }) => {
|
|
39
|
+
const { menu, press, ...icon } = model();
|
|
40
|
+
const serialized = serializeMenu(menu, 'macos');
|
|
41
|
+
return {
|
|
42
|
+
icon: { id, ...icon, menu: serialized.entries.length ? serialized.entries : null },
|
|
43
|
+
actions: serialized.actions,
|
|
44
|
+
press,
|
|
45
|
+
};
|
|
46
|
+
}), /* @ts-ignore */
|
|
47
|
+
...(ngDevMode ? [{ debugName: "sent" }] : /* istanbul ignore next */ []));
|
|
48
|
+
unsubscribe = this.native?.subscribe((event) => this.hostSaid(event)) ?? null;
|
|
49
|
+
constructor() {
|
|
50
|
+
const native = this.native;
|
|
51
|
+
if (native)
|
|
52
|
+
effect(() => native.setIcons(this.sent().map((one) => one.icon)));
|
|
53
|
+
}
|
|
54
|
+
/** Show an icon for as long as the function answered is not called. */
|
|
55
|
+
add(model) {
|
|
56
|
+
const one = { id: `tray-${this.next++}`, model };
|
|
57
|
+
this.icons.update((all) => [...all, one]);
|
|
58
|
+
return () => this.icons.update((all) => all.filter((each) => each !== one));
|
|
59
|
+
}
|
|
60
|
+
hostSaid(event) {
|
|
61
|
+
const icon = this.sent().find((one) => one.icon.id === event.icon);
|
|
62
|
+
if (event.type === 'press')
|
|
63
|
+
icon?.press();
|
|
64
|
+
else
|
|
65
|
+
icon?.actions.get(event.id)?.();
|
|
66
|
+
}
|
|
67
|
+
ngOnDestroy() {
|
|
68
|
+
this.unsubscribe?.();
|
|
69
|
+
}
|
|
70
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: Tray, deps: [], target: i0.ɵɵFactoryTarget.Service });
|
|
71
|
+
static ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.2.0", ngImport: i0, type: Tray });
|
|
72
|
+
}
|
|
73
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: Tray, decorators: [{
|
|
74
|
+
type: Service
|
|
75
|
+
}], ctorParameters: () => [] });
|
|
76
|
+
//# sourceMappingURL=tray.js.map
|
package/dist/tray.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tray.js","sourceRoot":"","sources":["../src/tray.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EACL,cAAc,EACd,OAAO,EACP,QAAQ,EACR,MAAM,EACN,MAAM,EACN,MAAM,GAEP,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,aAAa,EAAwB,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;;AAqChD,SAAS,UAAU;I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IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,KAAK,KAAK,CAAC,IAAI,CAAC,CAAC;QACnE,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO;YAAE,IAAI,EAAE,KAAK,EAAE,CAAC;;YACrC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;IACvC,CAAC;IAED,WAAW;QACT,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;IACvB,CAAC;uGA/CU,IAAI;wGAAJ,IAAI;;2FAAJ,IAAI;kBADhB,OAAO","sourcesContent":["/**\n * Icons in the macOS menu bar's status area, each with a menu or a press of its own. `<tray-icon>`\n * in `@ng-native/components` registers here. Absent on iOS and Android, where nothing is drawn.\n *\n * The host contract, on the `NgNativeTray` module: `setIcons(icons)` takes every icon each time one\n * changes, as `{ id, title, sfSymbol, image, tooltip, menu }`, `menu` as `serializeMenu` makes it\n * (null for an icon with a press instead). It sends `{ type: 'press', icon }` and\n * `{ type: 'menuSelect', icon, id }` on `ngNativeTray`.\n */\nimport {\n InjectionToken,\n Service,\n computed,\n effect,\n inject,\n signal,\n type Signal,\n} from '@angular/core';\nimport type { MenuEntry } from './menu-model.ts';\nimport { serializeMenu, type NativeMenuEntry } from './menus.ts';\nimport { reactNative } from './react-native.ts';\n\n/** One icon as an app describes it. */\nexport interface TrayIconModel {\n readonly title?: string;\n /** An SF Symbol, drawn as a template image that follows the menu bar's appearance. */\n readonly sfSymbol?: string;\n /** An image asset's name, for an icon of the app's own. */\n readonly image?: string;\n readonly tooltip?: string;\n /** The menu a click opens; with none, a click is a press. */\n readonly menu: readonly MenuEntry[];\n readonly press: () => void;\n}\n\nexport interface NativeTrayIcon {\n readonly id: string;\n readonly title?: string;\n readonly sfSymbol?: string;\n readonly image?: string;\n readonly tooltip?: string;\n readonly menu: readonly NativeMenuEntry[] | null;\n}\n\nexport type NativeTrayEvent =\n | { readonly type: 'press'; readonly icon: string }\n | { readonly type: 'menuSelect'; readonly icon: string; readonly id: string };\n\nexport interface NativeTray {\n setIcons(icons: readonly NativeTrayIcon[]): void;\n subscribe(listener: (event: NativeTrayEvent) => void): () => void;\n}\n\ninterface TrayTurboModule {\n setIcons?(icons: readonly NativeTrayIcon[]): void;\n}\n\nfunction traySource(): NativeTray | null {\n const native = reactNative();\n const module = native?.TurboModuleRegistry?.get?.('NgNativeTray') as\n TrayTurboModule | null | undefined;\n if (!module) return null;\n return {\n setIcons: (icons) => module.setIcons?.(icons),\n subscribe: (listener) => {\n const subscription = native?.DeviceEventEmitter?.addListener('ngNativeTray', (event) =>\n listener(event as NativeTrayEvent),\n );\n return () => subscription?.remove();\n },\n };\n}\n\n@Service()\nexport class Tray {\n /** Overridden in a test with a fake host. */\n static readonly SOURCE = new InjectionToken<NativeTray | null>('angular-native.traySource', {\n factory: traySource,\n });\n\n private readonly native = inject(Tray.SOURCE);\n private readonly icons = signal<readonly { id: string; model: Signal<TrayIconModel> }[]>([]);\n private next = 0;\n\n /** Whether the OS has a status area for the app: macOS. */\n readonly available: Signal<boolean> = signal(this.native !== null).asReadonly();\n\n private readonly sent = computed(() =>\n this.icons().map(({ id, model }) => {\n const { menu, press, ...icon } = model();\n const serialized = serializeMenu(menu, 'macos');\n return {\n icon: { id, ...icon, menu: serialized.entries.length ? serialized.entries : null },\n actions: serialized.actions,\n press,\n };\n }),\n );\n\n private readonly unsubscribe = this.native?.subscribe((event) => this.hostSaid(event)) ?? null;\n\n constructor() {\n const native = this.native;\n if (native) effect(() => native.setIcons(this.sent().map((one) => one.icon)));\n }\n\n /** Show an icon for as long as the function answered is not called. */\n add(model: Signal<TrayIconModel>): () => void {\n const one = { id: `tray-${this.next++}`, model };\n this.icons.update((all) => [...all, one]);\n return () => this.icons.update((all) => all.filter((each) => each !== one));\n }\n\n private hostSaid(event: NativeTrayEvent): void {\n const icon = this.sent().find((one) => one.icon.id === event.icon);\n if (event.type === 'press') icon?.press();\n else icon?.actions.get(event.id)?.();\n }\n\n ngOnDestroy(): void {\n this.unsubscribe?.();\n }\n}\n"]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The app's own undo history, kept by the OS's undo manager, an NSUndoManager on macOS, iOS and
|
|
3
|
+
* iPadOS. Edit > Undo and Edit > Redo, mod+z and mod+shift+z, and iPhone's shake to
|
|
4
|
+
* undo reach the app's actions while no text input has focus; a focused text input keeps its own
|
|
5
|
+
* history. Absent on Android and in the web host, where each call does nothing.
|
|
6
|
+
*
|
|
7
|
+
* The host contract, on the `NgNativeUndo` module: `register(id, label)` registers an action with
|
|
8
|
+
* the one undo manager every window shares, named `label`; undoing it sends `{ type: 'undo', id }`
|
|
9
|
+
* on `ngNativeUndo` and registers its redo under the same id, and redoing sends
|
|
10
|
+
* `{ type: 'redo', id }`. Registering anything else clears the redo history. `undo()`, `redo()`
|
|
11
|
+
* and `clear()` do what Edit > Undo, Edit > Redo and removing every action do. The menu bar's
|
|
12
|
+
* `undo` and `redo` items stay the OS's own, which the undo manager titles and enables.
|
|
13
|
+
*/
|
|
14
|
+
import { InjectionToken, type Signal } from '@angular/core';
|
|
15
|
+
import * as i0 from "@angular/core";
|
|
16
|
+
/** Something the app has done, and how to take it back and do it again. */
|
|
17
|
+
export interface UndoAction {
|
|
18
|
+
/** What Edit > Undo names it: "Undo <label>". */
|
|
19
|
+
readonly label: string;
|
|
20
|
+
undo(): void;
|
|
21
|
+
redo(): void;
|
|
22
|
+
}
|
|
23
|
+
export type NativeUndoEvent = {
|
|
24
|
+
readonly type: 'undo' | 'redo';
|
|
25
|
+
readonly id: string;
|
|
26
|
+
};
|
|
27
|
+
export interface NativeUndo {
|
|
28
|
+
register(id: string, label: string): void;
|
|
29
|
+
undo(): void;
|
|
30
|
+
redo(): void;
|
|
31
|
+
clear(): void;
|
|
32
|
+
subscribe(listener: (event: NativeUndoEvent) => void): () => void;
|
|
33
|
+
}
|
|
34
|
+
export declare class UndoStack {
|
|
35
|
+
/** Overridden in a test with a fake host, such as `fakeUndo()` from `@ng-native/testing`. */
|
|
36
|
+
static readonly SOURCE: InjectionToken<NativeUndo | null>;
|
|
37
|
+
private readonly native;
|
|
38
|
+
private readonly done;
|
|
39
|
+
private readonly undone;
|
|
40
|
+
private readonly unsubscribe;
|
|
41
|
+
/** Whether the OS has an undo manager: macOS, iOS and iPadOS. */
|
|
42
|
+
readonly available: Signal<boolean>;
|
|
43
|
+
readonly canUndo: Signal<boolean>;
|
|
44
|
+
readonly canRedo: Signal<boolean>;
|
|
45
|
+
/** The label of the action Edit > Undo takes back, or null. */
|
|
46
|
+
readonly undoLabel: Signal<string | null>;
|
|
47
|
+
/** The label of the action Edit > Redo does again, or null. */
|
|
48
|
+
readonly redoLabel: Signal<string | null>;
|
|
49
|
+
/**
|
|
50
|
+
* Record `action`, which the app has just done, so Edit > Undo takes it back. Clears what
|
|
51
|
+
* Edit > Redo had.
|
|
52
|
+
*/
|
|
53
|
+
push(action: UndoAction): void;
|
|
54
|
+
/** Edit > Undo. The action's `undo` runs when the undo manager reaches it. */
|
|
55
|
+
undo(): void;
|
|
56
|
+
/** Edit > Redo. */
|
|
57
|
+
redo(): void;
|
|
58
|
+
/** Forget every action, as after the document they changed is closed. */
|
|
59
|
+
clear(): void;
|
|
60
|
+
private hostSaid;
|
|
61
|
+
ngOnDestroy(): void;
|
|
62
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<UndoStack, never>;
|
|
63
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
64
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The app's own undo history, kept by the OS's undo manager, an NSUndoManager on macOS, iOS and
|
|
3
|
+
* iPadOS. Edit > Undo and Edit > Redo, mod+z and mod+shift+z, and iPhone's shake to
|
|
4
|
+
* undo reach the app's actions while no text input has focus; a focused text input keeps its own
|
|
5
|
+
* history. Absent on Android and in the web host, where each call does nothing.
|
|
6
|
+
*
|
|
7
|
+
* The host contract, on the `NgNativeUndo` module: `register(id, label)` registers an action with
|
|
8
|
+
* the one undo manager every window shares, named `label`; undoing it sends `{ type: 'undo', id }`
|
|
9
|
+
* on `ngNativeUndo` and registers its redo under the same id, and redoing sends
|
|
10
|
+
* `{ type: 'redo', id }`. Registering anything else clears the redo history. `undo()`, `redo()`
|
|
11
|
+
* and `clear()` do what Edit > Undo, Edit > Redo and removing every action do. The menu bar's
|
|
12
|
+
* `undo` and `redo` items stay the OS's own, which the undo manager titles and enables.
|
|
13
|
+
*/
|
|
14
|
+
import { InjectionToken, Service, computed, inject, signal } from '@angular/core';
|
|
15
|
+
import { reactNative } from "./react-native.js";
|
|
16
|
+
import * as i0 from "@angular/core";
|
|
17
|
+
function undoSource() {
|
|
18
|
+
const native = reactNative();
|
|
19
|
+
const module = native?.TurboModuleRegistry?.get?.('NgNativeUndo');
|
|
20
|
+
if (!module)
|
|
21
|
+
return null;
|
|
22
|
+
return {
|
|
23
|
+
register: (id, label) => module.register?.(id, label),
|
|
24
|
+
undo: () => module.undo?.(),
|
|
25
|
+
redo: () => module.redo?.(),
|
|
26
|
+
clear: () => module.clear?.(),
|
|
27
|
+
subscribe: (listener) => {
|
|
28
|
+
const subscription = native?.DeviceEventEmitter?.addListener('ngNativeUndo', (event) => listener(event));
|
|
29
|
+
return () => subscription?.remove();
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Every window's `UndoStack` hears every event from the one undo manager, so action ids come from
|
|
35
|
+
* one counter, not one per stack.
|
|
36
|
+
*/
|
|
37
|
+
let nextId = 1;
|
|
38
|
+
export class UndoStack {
|
|
39
|
+
/** Overridden in a test with a fake host, such as `fakeUndo()` from `@ng-native/testing`. */
|
|
40
|
+
static SOURCE = new InjectionToken('angular-native.undoSource', {
|
|
41
|
+
factory: undoSource,
|
|
42
|
+
});
|
|
43
|
+
native = inject(UndoStack.SOURCE);
|
|
44
|
+
done = signal([], /* @ts-ignore */
|
|
45
|
+
...(ngDevMode ? [{ debugName: "done" }] : /* istanbul ignore next */ []));
|
|
46
|
+
undone = signal([], /* @ts-ignore */
|
|
47
|
+
...(ngDevMode ? [{ debugName: "undone" }] : /* istanbul ignore next */ []));
|
|
48
|
+
unsubscribe = this.native?.subscribe((event) => this.hostSaid(event)) ?? null;
|
|
49
|
+
/** Whether the OS has an undo manager: macOS, iOS and iPadOS. */
|
|
50
|
+
available = signal(this.native !== null).asReadonly();
|
|
51
|
+
canUndo = computed(() => this.done().length > 0, /* @ts-ignore */
|
|
52
|
+
...(ngDevMode ? [{ debugName: "canUndo" }] : /* istanbul ignore next */ []));
|
|
53
|
+
canRedo = computed(() => this.undone().length > 0, /* @ts-ignore */
|
|
54
|
+
...(ngDevMode ? [{ debugName: "canRedo" }] : /* istanbul ignore next */ []));
|
|
55
|
+
/** The label of the action Edit > Undo takes back, or null. */
|
|
56
|
+
undoLabel = computed(() => this.done().at(-1)?.action.label ?? null, /* @ts-ignore */
|
|
57
|
+
...(ngDevMode ? [{ debugName: "undoLabel" }] : /* istanbul ignore next */ []));
|
|
58
|
+
/** The label of the action Edit > Redo does again, or null. */
|
|
59
|
+
redoLabel = computed(() => this.undone().at(-1)?.action.label ?? null, /* @ts-ignore */
|
|
60
|
+
...(ngDevMode ? [{ debugName: "redoLabel" }] : /* istanbul ignore next */ []));
|
|
61
|
+
/**
|
|
62
|
+
* Record `action`, which the app has just done, so Edit > Undo takes it back. Clears what
|
|
63
|
+
* Edit > Redo had.
|
|
64
|
+
*/
|
|
65
|
+
push(action) {
|
|
66
|
+
if (!this.native)
|
|
67
|
+
return;
|
|
68
|
+
const entry = { id: String(nextId++), action };
|
|
69
|
+
this.done.update((all) => [...all, entry]);
|
|
70
|
+
this.undone.set([]);
|
|
71
|
+
this.native.register(entry.id, action.label);
|
|
72
|
+
}
|
|
73
|
+
/** Edit > Undo. The action's `undo` runs when the undo manager reaches it. */
|
|
74
|
+
undo() {
|
|
75
|
+
this.native?.undo();
|
|
76
|
+
}
|
|
77
|
+
/** Edit > Redo. */
|
|
78
|
+
redo() {
|
|
79
|
+
this.native?.redo();
|
|
80
|
+
}
|
|
81
|
+
/** Forget every action, as after the document they changed is closed. */
|
|
82
|
+
clear() {
|
|
83
|
+
if (!this.native)
|
|
84
|
+
return;
|
|
85
|
+
this.done.set([]);
|
|
86
|
+
this.undone.set([]);
|
|
87
|
+
this.native.clear();
|
|
88
|
+
}
|
|
89
|
+
hostSaid(event) {
|
|
90
|
+
const [from, to] = event.type === 'undo' ? [this.done, this.undone] : [this.undone, this.done];
|
|
91
|
+
const entry = from().find((one) => one.id === event.id);
|
|
92
|
+
if (!entry)
|
|
93
|
+
return;
|
|
94
|
+
from.update((all) => all.filter((one) => one !== entry));
|
|
95
|
+
to.update((all) => [...all, entry]);
|
|
96
|
+
if (event.type === 'undo')
|
|
97
|
+
entry.action.undo();
|
|
98
|
+
else
|
|
99
|
+
entry.action.redo();
|
|
100
|
+
}
|
|
101
|
+
ngOnDestroy() {
|
|
102
|
+
this.unsubscribe?.();
|
|
103
|
+
}
|
|
104
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: UndoStack, deps: [], target: i0.ɵɵFactoryTarget.Service });
|
|
105
|
+
static ɵprov = i0.ɵɵngDeclareService({ minVersion: "22.0.0", version: "22.2.0", ngImport: i0, type: UndoStack });
|
|
106
|
+
}
|
|
107
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: UndoStack, decorators: [{
|
|
108
|
+
type: Service
|
|
109
|
+
}] });
|
|
110
|
+
//# sourceMappingURL=undo-stack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"undo-stack.js","sourceRoot":"","sources":["../src/undo-stack.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,cAAc,EAAE,OAAO,EA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C,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM;YAAE,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;;YAC1C,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAC3B,CAAC;IAED,WAAW;QACT,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;IACvB,CAAC;uGAlEU,SAAS;wGAAT,SAAS;;2FAAT,SAAS;kBADrB,OAAO","sourcesContent":["/**\n * The app's own undo history, kept by the OS's undo manager, an NSUndoManager on macOS, iOS and\n * iPadOS. Edit > Undo and Edit > Redo, mod+z and mod+shift+z, and iPhone's shake to\n * undo reach the app's actions while no text input has focus; a focused text input keeps its own\n * history. Absent on Android and in the web host, where each call does nothing.\n *\n * The host contract, on the `NgNativeUndo` module: `register(id, label)` registers an action with\n * the one undo manager every window shares, named `label`; undoing it sends `{ type: 'undo', id }`\n * on `ngNativeUndo` and registers its redo under the same id, and redoing sends\n * `{ type: 'redo', id }`. Registering anything else clears the redo history. `undo()`, `redo()`\n * and `clear()` do what Edit > Undo, Edit > Redo and removing every action do. The menu bar's\n * `undo` and `redo` items stay the OS's own, which the undo manager titles and enables.\n */\nimport { InjectionToken, Service, computed, inject, signal, type Signal } from '@angular/core';\nimport { reactNative } from './react-native.ts';\n\n/** Something the app has done, and how to take it back and do it again. */\nexport interface UndoAction {\n /** What Edit > Undo names it: \"Undo <label>\". */\n readonly label: string;\n undo(): void;\n redo(): void;\n}\n\nexport type NativeUndoEvent = { readonly type: 'undo' | 'redo'; readonly id: string };\n\nexport interface NativeUndo {\n register(id: string, label: string): void;\n undo(): void;\n redo(): void;\n clear(): void;\n subscribe(listener: (event: NativeUndoEvent) => void): () => void;\n}\n\ninterface UndoTurboModule {\n register?(id: string, label: string): void;\n undo?(): void;\n redo?(): void;\n clear?(): void;\n}\n\nfunction undoSource(): NativeUndo | null {\n const native = reactNative();\n const module = native?.TurboModuleRegistry?.get?.('NgNativeUndo') as\n UndoTurboModule | null | undefined;\n if (!module) return null;\n return {\n register: (id, label) => module.register?.(id, label),\n undo: () => module.undo?.(),\n redo: () => module.redo?.(),\n clear: () => module.clear?.(),\n subscribe: (listener) => {\n const subscription = native?.DeviceEventEmitter?.addListener('ngNativeUndo', (event) =>\n listener(event as NativeUndoEvent),\n );\n return () => subscription?.remove();\n },\n };\n}\n\ntype Entry = { readonly id: string; readonly action: UndoAction };\n\n/**\n * Every window's `UndoStack` hears every event from the one undo manager, so action ids come from\n * one counter, not one per stack.\n */\nlet nextId = 1;\n\n@Service()\nexport class UndoStack {\n /** Overridden in a test with a fake host, such as `fakeUndo()` from `@ng-native/testing`. */\n static readonly SOURCE = new InjectionToken<NativeUndo | null>('angular-native.undoSource', {\n factory: undoSource,\n });\n\n private readonly native = inject(UndoStack.SOURCE);\n private readonly done = signal<readonly Entry[]>([]);\n private readonly undone = signal<readonly Entry[]>([]);\n private readonly unsubscribe = this.native?.subscribe((event) => this.hostSaid(event)) ?? null;\n\n /** Whether the OS has an undo manager: macOS, iOS and iPadOS. */\n readonly available: Signal<boolean> = signal(this.native !== null).asReadonly();\n readonly canUndo: Signal<boolean> = computed(() => this.done().length > 0);\n readonly canRedo: Signal<boolean> = computed(() => this.undone().length > 0);\n /** The label of the action Edit > Undo takes back, or null. */\n readonly undoLabel: Signal<string | null> = computed(\n () => this.done().at(-1)?.action.label ?? null,\n );\n /** The label of the action Edit > Redo does again, or null. */\n readonly redoLabel: Signal<string | null> = computed(\n () => this.undone().at(-1)?.action.label ?? null,\n );\n\n /**\n * Record `action`, which the app has just done, so Edit > Undo takes it back. Clears what\n * Edit > Redo had.\n */\n push(action: UndoAction): void {\n if (!this.native) return;\n const entry = { id: String(nextId++), action };\n this.done.update((all) => [...all, entry]);\n this.undone.set([]);\n this.native.register(entry.id, action.label);\n }\n\n /** Edit > Undo. The action's `undo` runs when the undo manager reaches it. */\n undo(): void {\n this.native?.undo();\n }\n\n /** Edit > Redo. */\n redo(): void {\n this.native?.redo();\n }\n\n /** Forget every action, as after the document they changed is closed. */\n clear(): void {\n if (!this.native) return;\n this.done.set([]);\n this.undone.set([]);\n this.native.clear();\n }\n\n private hostSaid(event: NativeUndoEvent): void {\n const [from, to] = event.type === 'undo' ? [this.done, this.undone] : [this.undone, this.done];\n const entry = from().find((one) => one.id === event.id);\n if (!entry) return;\n from.update((all) => all.filter((one) => one !== entry));\n to.update((all) => [...all, entry]);\n if (event.type === 'undo') entry.action.undo();\n else entry.action.redo();\n }\n\n ngOnDestroy(): void {\n this.unsubscribe?.();\n }\n}\n"]}
|
package/dist/vibration.d.ts
CHANGED
|
@@ -1,17 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Vibration, which is not haptics.
|
|
3
|
-
*
|
|
4
|
-
* `Haptics` is the Taptic Engine: a tap, a nudge, a success chime you feel rather than hear, tied
|
|
5
|
-
* to something the user just did. This is the motor - a buzz of a stated length, or a pattern -
|
|
6
|
-
* and it is what an alarm, a timer or an incoming call uses. An app that wants feedback for a
|
|
7
|
-
* button press wants the other one.
|
|
8
|
-
*
|
|
9
|
-
* iOS has one duration and ignores the number, so a pattern there is on and off at a fixed
|
|
10
|
-
* strength; Android takes the milliseconds as written. Both are said plainly rather than papered
|
|
11
|
-
* over, because a pattern designed on Android does not feel the same on iOS and nothing here can
|
|
12
|
-
* make it.
|
|
13
|
-
*/
|
|
14
|
-
import { InjectionToken } from '@angular/core';
|
|
1
|
+
import { InjectionToken, type Signal } from '@angular/core';
|
|
15
2
|
import * as i0 from "@angular/core";
|
|
16
3
|
export interface NativeVibration {
|
|
17
4
|
vibrate(pattern?: number | number[], repeat?: boolean): void;
|
|
@@ -21,6 +8,8 @@ export declare class Vibration {
|
|
|
21
8
|
/** Overridden in a test to record a buzz without one happening. */
|
|
22
9
|
static readonly SOURCE: InjectionToken<NativeVibration | null>;
|
|
23
10
|
private readonly native;
|
|
11
|
+
/** Whether the device can vibrate: absent on a Mac, which has no motor to drive. */
|
|
12
|
+
readonly available: Signal<boolean>;
|
|
24
13
|
/** A single buzz. The duration is Android's; iOS vibrates for its own fixed length. */
|
|
25
14
|
buzz(durationMs?: number): void;
|
|
26
15
|
/**
|
package/dist/vibration.js
CHANGED
|
@@ -11,13 +11,16 @@
|
|
|
11
11
|
* over, because a pattern designed on Android does not feel the same on iOS and nothing here can
|
|
12
12
|
* make it.
|
|
13
13
|
*/
|
|
14
|
-
import {
|
|
14
|
+
import { injectOs } from "./os.js";
|
|
15
|
+
import { InjectionToken, Service, inject, signal } from '@angular/core';
|
|
15
16
|
import { reactNative } from "./react-native.js";
|
|
16
17
|
import * as i0 from "@angular/core";
|
|
17
18
|
export class Vibration {
|
|
18
19
|
/** Overridden in a test to record a buzz without one happening. */
|
|
19
20
|
static SOURCE = new InjectionToken('angular-native.vibrationSource', { factory: () => reactNative()?.Vibration ?? null });
|
|
20
21
|
native = inject(Vibration.SOURCE);
|
|
22
|
+
/** Whether the device can vibrate: absent on a Mac, which has no motor to drive. */
|
|
23
|
+
available = signal(this.native !== null && injectOs() !== 'macos').asReadonly();
|
|
21
24
|
/** A single buzz. The duration is Android's; iOS vibrates for its own fixed length. */
|
|
22
25
|
buzz(durationMs = 400) {
|
|
23
26
|
this.native?.vibrate(durationMs);
|
package/dist/vibration.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vibration.js","sourceRoot":"","sources":["../src/vibration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"vibration.js","sourceRoot":"","sources":["../src/vibration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAe,MAAM,eAAe,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;;AAQhD,MAAM,OAAO,SAAS;IACpB,mEAAmE;IACnE,MAAM,CAAU,MAAM,GAAG,IAAI,cAAc,CACzC,gCAAgC,EAChC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,WAAW,EAAE,EAAE,SAAS,IAAI,IAAI,EAAE,CACpD,CAAC;IAEe,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAEnD,oFAAoF;IAC3E,SAAS,GAAoB,MAAM,CAC1C,IAAI,CAAC,MAAM,KAAK,IAAI,IAAI,QAAQ,EAAE,KAAK,OAAO,CAC/C,CAAC,UAAU,EAAE,CAAC;IAEf,uFAAuF;IACvF,IAAI,CAAC,UAAU,GAAG,GAAG;QACnB,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACnC,CAAC;IAED;;;;;OAKG;IACH,OAAO,CAAC,MAAyB,EAAE,UAAgC,EAAE;QACnE,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC;IAC7D,CAAC;IAED,IAAI;QACF,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;IACxB,CAAC;uGA/BU,SAAS;wGAAT,SAAS;;2FAAT,SAAS;kBADrB,OAAO","sourcesContent":["/**\n * Vibration, which is not haptics.\n *\n * `Haptics` is the Taptic Engine: a tap, a nudge, a success chime you feel rather than hear, tied\n * to something the user just did. This is the motor - a buzz of a stated length, or a pattern -\n * and it is what an alarm, a timer or an incoming call uses. An app that wants feedback for a\n * button press wants the other one.\n *\n * iOS has one duration and ignores the number, so a pattern there is on and off at a fixed\n * strength; Android takes the milliseconds as written. Both are said plainly rather than papered\n * over, because a pattern designed on Android does not feel the same on iOS and nothing here can\n * make it.\n */\n\nimport { injectOs } from './os.ts';\nimport { InjectionToken, Service, inject, signal, type Signal } from '@angular/core';\nimport { reactNative } from './react-native.ts';\n\nexport interface NativeVibration {\n vibrate(pattern?: number | number[], repeat?: boolean): void;\n cancel(): void;\n}\n\n@Service()\nexport class Vibration {\n /** Overridden in a test to record a buzz without one happening. */\n static readonly SOURCE = new InjectionToken<NativeVibration | null>(\n 'angular-native.vibrationSource',\n { factory: () => reactNative()?.Vibration ?? null },\n );\n\n private readonly native = inject(Vibration.SOURCE);\n\n /** Whether the device can vibrate: absent on a Mac, which has no motor to drive. */\n readonly available: Signal<boolean> = signal(\n this.native !== null && injectOs() !== 'macos',\n ).asReadonly();\n\n /** A single buzz. The duration is Android's; iOS vibrates for its own fixed length. */\n buzz(durationMs = 400): void {\n this.native?.vibrate(durationMs);\n }\n\n /**\n * A pattern of waits and buzzes, in milliseconds, starting with a wait.\n *\n * `repeat` runs it until `stop()`, which is for something that must be answered - an alarm, a\n * call - and is a promise to call `stop` rather than a decoration.\n */\n pattern(millis: readonly number[], options: { repeat?: boolean } = {}): void {\n this.native?.vibrate([...millis], options.repeat ?? false);\n }\n\n stop(): void {\n this.native?.cancel();\n }\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { InjectionToken, type Provider, type Type } from '@angular/core';
|
|
2
|
+
/**
|
|
3
|
+
* How `AppWindows` shows a route in a route window: each such window renders a named outlet of the
|
|
4
|
+
* app's one Router, and this navigates that outlet. `@ng-native/router` provides it, since this
|
|
5
|
+
* package cannot import the Router.
|
|
6
|
+
*/
|
|
7
|
+
export interface WindowNavigator {
|
|
8
|
+
/**
|
|
9
|
+
* What a route window for `outlet` renders: a component holding the outlet, and the providers
|
|
10
|
+
* its window's root needs for the outlet to take that name.
|
|
11
|
+
*/
|
|
12
|
+
window(outlet: string): {
|
|
13
|
+
component: Type<unknown>;
|
|
14
|
+
providers: Provider[];
|
|
15
|
+
};
|
|
16
|
+
/** Show `path` in the outlet named `outlet`. Resolves whether the navigation happened. */
|
|
17
|
+
navigate(outlet: string, path: string): Promise<boolean>;
|
|
18
|
+
/** Empty the outlet named `outlet`, as its window closes. Resolves whether it was emptied. */
|
|
19
|
+
clear(outlet: string): Promise<boolean>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The router's `WindowNavigator`, or null in an app with no native router, where a route window
|
|
23
|
+
* has nothing to show.
|
|
24
|
+
*/
|
|
25
|
+
export declare const WINDOW_NAVIGATOR: InjectionToken<WindowNavigator | null>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
/**
|
|
3
|
+
* The router's `WindowNavigator`, or null in an app with no native router, where a route window
|
|
4
|
+
* has nothing to show.
|
|
5
|
+
*/
|
|
6
|
+
export const WINDOW_NAVIGATOR = new InjectionToken('angular-native.windowNavigator', { factory: () => null });
|
|
7
|
+
//# sourceMappingURL=window-navigator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"window-navigator.js","sourceRoot":"","sources":["../src/window-navigator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA4B,MAAM,eAAe,CAAC;AAmBzE;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,cAAc,CAChD,gCAAgC,EAChC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,CACxB,CAAC","sourcesContent":["import { InjectionToken, type Provider, type Type } from '@angular/core';\n\n/**\n * How `AppWindows` shows a route in a route window: each such window renders a named outlet of the\n * app's one Router, and this navigates that outlet. `@ng-native/router` provides it, since this\n * package cannot import the Router.\n */\nexport interface WindowNavigator {\n /**\n * What a route window for `outlet` renders: a component holding the outlet, and the providers\n * its window's root needs for the outlet to take that name.\n */\n window(outlet: string): { component: Type<unknown>; providers: Provider[] };\n /** Show `path` in the outlet named `outlet`. Resolves whether the navigation happened. */\n navigate(outlet: string, path: string): Promise<boolean>;\n /** Empty the outlet named `outlet`, as its window closes. Resolves whether it was emptied. */\n clear(outlet: string): Promise<boolean>;\n}\n\n/**\n * The router's `WindowNavigator`, or null in an app with no native router, where a route window\n * has nothing to show.\n */\nexport const WINDOW_NAVIGATOR = new InjectionToken<WindowNavigator | null>(\n 'angular-native.windowNavigator',\n { factory: () => null },\n);\n"]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which windows open again after a reload or a relaunch, and what they rendered.
|
|
3
|
+
*
|
|
4
|
+
* The host, on macOS and on iPadOS, keeps a window that has a key across a reload, and closes it
|
|
5
|
+
* unless the reloaded app opens that key again within a few seconds. So `AppWindows` writes down each window
|
|
6
|
+
* with a key as it opens and forgets it as it closes, and a starting app opens every one it finds:
|
|
7
|
+
* the main window, a route window at the path it was last opened at, and a `restoreKey` component
|
|
8
|
+
* window with its inputs. A relaunch takes the same path, with the frames the host autosaved.
|
|
9
|
+
*
|
|
10
|
+
* A component is written down by the name `provideRestorableWindows` gives it, since a class name
|
|
11
|
+
* does not survive minifying.
|
|
12
|
+
*/
|
|
13
|
+
import { InjectionToken, type EnvironmentProviders, type Type } from '@angular/core';
|
|
14
|
+
import type { WindowOptions } from './app-windows.ts';
|
|
15
|
+
/** One window to open again. */
|
|
16
|
+
export type RestoredWindow = {
|
|
17
|
+
readonly kind: 'main';
|
|
18
|
+
} | {
|
|
19
|
+
readonly kind: 'route';
|
|
20
|
+
readonly outlet: string;
|
|
21
|
+
readonly path: string;
|
|
22
|
+
readonly options: WindowOptions;
|
|
23
|
+
} | {
|
|
24
|
+
readonly kind: 'component';
|
|
25
|
+
readonly key: string;
|
|
26
|
+
/** The name `provideRestorableWindows` gave the component. */
|
|
27
|
+
readonly component: string;
|
|
28
|
+
readonly inputs?: Readonly<Record<string, unknown>>;
|
|
29
|
+
readonly options: WindowOptions;
|
|
30
|
+
};
|
|
31
|
+
/** Where the windows to open again are kept between one run of the app and the next. */
|
|
32
|
+
export interface WindowRestoreStore {
|
|
33
|
+
read(): readonly RestoredWindow[];
|
|
34
|
+
write(windows: readonly RestoredWindow[]): void;
|
|
35
|
+
}
|
|
36
|
+
/** The store `AppWindows` keeps its windows in. Overridden in a test with one in memory. */
|
|
37
|
+
export declare const WINDOW_RESTORE_STORE: InjectionToken<WindowRestoreStore | null>;
|
|
38
|
+
/** The components a `restoreKey` window may render, named by `provideRestorableWindows`. */
|
|
39
|
+
export declare const RESTORABLE_WINDOWS: InjectionToken<Readonly<Record<string, Type<unknown>>>[]>;
|
|
40
|
+
/**
|
|
41
|
+
* Name the components that `AppWindows.open(component, { restoreKey })` may open, so the window
|
|
42
|
+
* opens again after a reload or a relaunch: `provideRestorableWindows({ note: NoteWindow })`. Its
|
|
43
|
+
* inputs are written down too, so they have to survive `JSON.stringify`.
|
|
44
|
+
*/
|
|
45
|
+
export declare function provideRestorableWindows(components: Readonly<Record<string, Type<unknown>>>): EnvironmentProviders;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which windows open again after a reload or a relaunch, and what they rendered.
|
|
3
|
+
*
|
|
4
|
+
* The host, on macOS and on iPadOS, keeps a window that has a key across a reload, and closes it
|
|
5
|
+
* unless the reloaded app opens that key again within a few seconds. So `AppWindows` writes down each window
|
|
6
|
+
* with a key as it opens and forgets it as it closes, and a starting app opens every one it finds:
|
|
7
|
+
* the main window, a route window at the path it was last opened at, and a `restoreKey` component
|
|
8
|
+
* window with its inputs. A relaunch takes the same path, with the frames the host autosaved.
|
|
9
|
+
*
|
|
10
|
+
* A component is written down by the name `provideRestorableWindows` gives it, since a class name
|
|
11
|
+
* does not survive minifying.
|
|
12
|
+
*/
|
|
13
|
+
import { InjectionToken, makeEnvironmentProviders, } from '@angular/core';
|
|
14
|
+
import { injectOs } from "./os.js";
|
|
15
|
+
import { reactNative } from "./react-native.js";
|
|
16
|
+
const SETTINGS_KEY = 'ngNative.windows';
|
|
17
|
+
/**
|
|
18
|
+
* React Native's `Settings`, the app's user defaults, on macOS and iOS; null elsewhere. On iPadOS
|
|
19
|
+
* the host keeps a window's scene across a reload, as the desktop host keeps the window, until the
|
|
20
|
+
* reloaded app opens its key again.
|
|
21
|
+
*/
|
|
22
|
+
function settingsStore() {
|
|
23
|
+
const os = injectOs();
|
|
24
|
+
if (os !== 'macos' && os !== 'ios')
|
|
25
|
+
return null;
|
|
26
|
+
const settings = reactNative()?.Settings;
|
|
27
|
+
if (!settings)
|
|
28
|
+
return null;
|
|
29
|
+
return {
|
|
30
|
+
read: () => {
|
|
31
|
+
const saved = settings.get(SETTINGS_KEY);
|
|
32
|
+
let records = saved;
|
|
33
|
+
if (typeof saved === 'string') {
|
|
34
|
+
try {
|
|
35
|
+
records = JSON.parse(saved);
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return [];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
// A list as a property list too: what an earlier version saved still opens. Only records,
|
|
42
|
+
// since a value written outside the app can hold anything.
|
|
43
|
+
return Array.isArray(records)
|
|
44
|
+
? records.filter((window) => typeof window === 'object' && window !== null)
|
|
45
|
+
: [];
|
|
46
|
+
},
|
|
47
|
+
// As JSON: a property list drops null, from an object and from an array, so a window's inputs
|
|
48
|
+
// would not come back as they were given.
|
|
49
|
+
write: (windows) => settings.set({ [SETTINGS_KEY]: JSON.stringify(windows) }),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/** The store `AppWindows` keeps its windows in. Overridden in a test with one in memory. */
|
|
53
|
+
export const WINDOW_RESTORE_STORE = new InjectionToken('angular-native.windowRestoreStore', { factory: settingsStore });
|
|
54
|
+
/** The components a `restoreKey` window may render, named by `provideRestorableWindows`. */
|
|
55
|
+
export const RESTORABLE_WINDOWS = new InjectionToken('angular-native.restorableWindows');
|
|
56
|
+
/**
|
|
57
|
+
* Name the components that `AppWindows.open(component, { restoreKey })` may open, so the window
|
|
58
|
+
* opens again after a reload or a relaunch: `provideRestorableWindows({ note: NoteWindow })`. Its
|
|
59
|
+
* inputs are written down too, so they have to survive `JSON.stringify`.
|
|
60
|
+
*/
|
|
61
|
+
export function provideRestorableWindows(components) {
|
|
62
|
+
return makeEnvironmentProviders([
|
|
63
|
+
{ provide: RESTORABLE_WINDOWS, useValue: components, multi: true },
|
|
64
|
+
]);
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=window-restore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"window-restore.js","sourceRoot":"","sources":["../src/window-restore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EACL,cAAc,EACd,wBAAwB,GAGzB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AA2BhD,MAAM,YAAY,GAAG,kBAAkB,CAAC;AAExC;;;;GAIG;AACH,SAAS,aAAa;IACpB,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAC;IACtB,IAAI,EAAE,KAAK,OAAO,IAAI,EAAE,KAAK,KAAK;QAAE,OAAO,IAAI,CAAC;IAChD,MAAM,QAAQ,GAAG,WAAW,EAAE,EAAE,QAAQ,CAAC;IACzC,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3B,OAAO;QACL,IAAI,EAAE,GAAG,EAAE;YACT,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;YACzC,IAAI,OAAO,GAAY,KAAK,CAAC;YAC7B,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC9B,IAAI,CAAC;oBACH,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;gBAC9B,CAAC;gBAAC,MAAM,CAAC;oBACP,OAAO,EAAE,CAAC;gBACZ,CAAC;YACH,CAAC;YACD,0FAA0F;YAC1F,2DAA2D;YAC3D,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;gBAC3B,CAAC,CAAC,OAAO,CAAC,MAAM,CACZ,CAAC,MAAM,EAA4B,EAAE,CAAC,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,CACpF;gBACH,CAAC,CAAC,EAAE,CAAC;QACT,CAAC;QACD,8FAA8F;QAC9F,0CAA0C;QAC1C,KAAK,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,YAAY,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;KAC9E,CAAC;AACJ,CAAC;AAED,4FAA4F;AAC5F,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,cAAc,CACpD,mCAAmC,EACnC,EAAE,OAAO,EAAE,aAAa,EAAE,CAC3B,CAAC;AAEF,4FAA4F;AAC5F,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,cAAc,CAClD,kCAAkC,CACnC,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CACtC,UAAmD;IAEnD,OAAO,wBAAwB,CAAC;QAC9B,EAAE,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE;KACnE,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * Which windows open again after a reload or a relaunch, and what they rendered.\n *\n * The host, on macOS and on iPadOS, keeps a window that has a key across a reload, and closes it\n * unless the reloaded app opens that key again within a few seconds. So `AppWindows` writes down each window\n * with a key as it opens and forgets it as it closes, and a starting app opens every one it finds:\n * the main window, a route window at the path it was last opened at, and a `restoreKey` component\n * window with its inputs. A relaunch takes the same path, with the frames the host autosaved.\n *\n * A component is written down by the name `provideRestorableWindows` gives it, since a class name\n * does not survive minifying.\n */\nimport {\n InjectionToken,\n makeEnvironmentProviders,\n type EnvironmentProviders,\n type Type,\n} from '@angular/core';\nimport { injectOs } from './os.ts';\nimport { reactNative } from './react-native.ts';\nimport type { WindowOptions } from './app-windows.ts';\n\n/** One window to open again. */\nexport type RestoredWindow =\n | { readonly kind: 'main' }\n | {\n readonly kind: 'route';\n readonly outlet: string;\n readonly path: string;\n readonly options: WindowOptions;\n }\n | {\n readonly kind: 'component';\n readonly key: string;\n /** The name `provideRestorableWindows` gave the component. */\n readonly component: string;\n readonly inputs?: Readonly<Record<string, unknown>>;\n readonly options: WindowOptions;\n };\n\n/** Where the windows to open again are kept between one run of the app and the next. */\nexport interface WindowRestoreStore {\n read(): readonly RestoredWindow[];\n write(windows: readonly RestoredWindow[]): void;\n}\n\nconst SETTINGS_KEY = 'ngNative.windows';\n\n/**\n * React Native's `Settings`, the app's user defaults, on macOS and iOS; null elsewhere. On iPadOS\n * the host keeps a window's scene across a reload, as the desktop host keeps the window, until the\n * reloaded app opens its key again.\n */\nfunction settingsStore(): WindowRestoreStore | null {\n const os = injectOs();\n if (os !== 'macos' && os !== 'ios') return null;\n const settings = reactNative()?.Settings;\n if (!settings) return null;\n return {\n read: () => {\n const saved = settings.get(SETTINGS_KEY);\n let records: unknown = saved;\n if (typeof saved === 'string') {\n try {\n records = JSON.parse(saved);\n } catch {\n return [];\n }\n }\n // A list as a property list too: what an earlier version saved still opens. Only records,\n // since a value written outside the app can hold anything.\n return Array.isArray(records)\n ? records.filter(\n (window): window is RestoredWindow => typeof window === 'object' && window !== null,\n )\n : [];\n },\n // As JSON: a property list drops null, from an object and from an array, so a window's inputs\n // would not come back as they were given.\n write: (windows) => settings.set({ [SETTINGS_KEY]: JSON.stringify(windows) }),\n };\n}\n\n/** The store `AppWindows` keeps its windows in. Overridden in a test with one in memory. */\nexport const WINDOW_RESTORE_STORE = new InjectionToken<WindowRestoreStore | null>(\n 'angular-native.windowRestoreStore',\n { factory: settingsStore },\n);\n\n/** The components a `restoreKey` window may render, named by `provideRestorableWindows`. */\nexport const RESTORABLE_WINDOWS = new InjectionToken<Readonly<Record<string, Type<unknown>>>[]>(\n 'angular-native.restorableWindows',\n);\n\n/**\n * Name the components that `AppWindows.open(component, { restoreKey })` may open, so the window\n * opens again after a reload or a relaunch: `provideRestorableWindows({ note: NoteWindow })`. Its\n * inputs are written down too, so they have to survive `JSON.stringify`.\n */\nexport function provideRestorableWindows(\n components: Readonly<Record<string, Type<unknown>>>,\n): EnvironmentProviders {\n return makeEnvironmentProviders([\n { provide: RESTORABLE_WINDOWS, useValue: components, multi: true },\n ]);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ng-native/device",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"description": "Angular Native device services: keyboard, screen, color scheme, app state, accessibility, hardware back and deep links.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"type": "module",
|
|
18
18
|
"main": "dist/index.js",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@ng-native/fabric": "0.
|
|
20
|
+
"@ng-native/fabric": "0.24.0"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"@angular/core": "^22.0.0",
|
|
@@ -56,6 +56,14 @@
|
|
|
56
56
|
"types": "./dist/index.d.ts",
|
|
57
57
|
"default": "./dist/index.js"
|
|
58
58
|
},
|
|
59
|
+
"./desktop-options": {
|
|
60
|
+
"types": "./dist/desktop-options.d.ts",
|
|
61
|
+
"default": "./dist/desktop-options.js"
|
|
62
|
+
},
|
|
63
|
+
"./os-support": {
|
|
64
|
+
"types": "./dist/os-support.d.ts",
|
|
65
|
+
"default": "./dist/os-support.js"
|
|
66
|
+
},
|
|
59
67
|
"./package.json": "./package.json"
|
|
60
68
|
},
|
|
61
69
|
"publishConfig": {
|