@flighthq/app 0.5.0-next.1944.cd6b6e7 → 0.5.1-edge.638.d4dbd4e
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 +2 -2
- package/dist/app.d.ts +41 -44
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +139 -329
- package/dist/app.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
- package/src/app.test.ts +255 -682
- package/src/appHost.test.ts +72 -0
package/README.md
CHANGED
|
@@ -13,5 +13,5 @@ Import the supported application-facing API from `@flighthq/app`. The `@flighthq
|
|
|
13
13
|
This package is part of the locked-version Flight SDK graph. Applications may instead install and import `@flighthq/sdk` when package-level tree shaking is sufficient.
|
|
14
14
|
|
|
15
15
|
- [Flight project](https://github.com/flighthq/flight)
|
|
16
|
-
- [Source for @flighthq/app@0.5.
|
|
17
|
-
- [License](https://github.com/flighthq/flight/blob/
|
|
16
|
+
- [Source for @flighthq/app@0.5.1-edge.638.d4dbd4e](https://github.com/flighthq/flight/tree/d4dbd4e347dc8be10b180c85a766ab50333dcb51/packages/app)
|
|
17
|
+
- [License](https://github.com/flighthq/flight/blob/d4dbd4e347dc8be10b180c85a766ab50333dcb51/LICENSE.md)
|
package/dist/app.d.ts
CHANGED
|
@@ -1,48 +1,45 @@
|
|
|
1
|
-
import type { App, AppActivationPolicy,
|
|
2
|
-
|
|
3
|
-
export declare function addAppRecentDocument(path: string): void;
|
|
4
|
-
export declare function attachApp(app: App): void;
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function
|
|
1
|
+
import type { App, AppActivationPolicy, AppLoginItem, AppLoginItemLike, AppPathKind, HasAppActivate, HasAppActivationPolicy, HasAppAllWindowsClosed, HasAppBadge, HasAppDock, HasAppFocus, HasAppHiddenQuery, HasAppHide, HasAppLocale, HasAppLoginItem, HasAppName, HasAppNameWrite, HasAppOpenFile, HasAppPath, HasAppQuit, HasAppQuitRequest, HasAppReady, HasAppRecentDocuments, HasAppRelaunch, HasAppSecondInstance, HasAppShow, HasAppSingleInstance, HasAppUserModelId, HasAppVersion, MenuItemTemplate } from '@flighthq/types/contract';
|
|
2
|
+
type HasAllAppEvents = HasAppActivate & HasAppAllWindowsClosed & HasAppOpenFile & HasAppQuitRequest & HasAppReady & HasAppSecondInstance;
|
|
3
|
+
export declare function addAppRecentDocument(host: HasAppRecentDocuments, path: string): void;
|
|
4
|
+
export declare function attachApp(host: HasAllAppEvents, app: App): void;
|
|
5
|
+
export declare function attachAppActivate(host: HasAppActivate, app: App): void;
|
|
6
|
+
export declare function attachAppAllWindowsClosed(host: HasAppAllWindowsClosed, app: App): void;
|
|
7
|
+
export declare function attachAppOpenFile(host: HasAppOpenFile, app: App): void;
|
|
8
|
+
export declare function attachAppQuitRequest(host: HasAppQuitRequest, app: App): void;
|
|
9
|
+
export declare function attachAppReady(host: HasAppReady, app: App): void;
|
|
10
|
+
export declare function attachAppSecondInstance(host: HasAppSecondInstance, app: App): void;
|
|
11
|
+
export declare function bounceAppDock(host: HasAppDock): number;
|
|
12
|
+
export declare function cancelAppAttention(host: HasAppDock, id: number): void;
|
|
13
|
+
export declare function cancelAppDockBounce(host: HasAppDock, id: number): void;
|
|
14
|
+
export declare function clearAppRecentDocuments(host: HasAppRecentDocuments): void;
|
|
9
15
|
export declare function createApp(): App;
|
|
10
|
-
export declare function createAppLoginItem(): AppLoginItem;
|
|
11
16
|
export declare function detachApp(app: App): void;
|
|
12
17
|
export declare function disposeApp(app: App): void;
|
|
13
|
-
export declare function
|
|
14
|
-
export declare function
|
|
15
|
-
export declare function
|
|
16
|
-
export declare function
|
|
17
|
-
export declare function
|
|
18
|
-
export declare function
|
|
19
|
-
export declare function
|
|
20
|
-
export declare function
|
|
21
|
-
export declare function
|
|
22
|
-
export declare function
|
|
23
|
-
export declare function
|
|
24
|
-
export declare function
|
|
25
|
-
export declare function
|
|
26
|
-
export declare function
|
|
27
|
-
export declare function
|
|
28
|
-
export declare function
|
|
29
|
-
export declare function
|
|
30
|
-
export declare function
|
|
31
|
-
export declare function
|
|
32
|
-
export declare function
|
|
33
|
-
export declare function
|
|
34
|
-
export declare function
|
|
35
|
-
export declare function
|
|
36
|
-
export declare function
|
|
37
|
-
export declare function
|
|
38
|
-
export declare function
|
|
39
|
-
export
|
|
40
|
-
export declare function setAppBackend(backend: AppBackend | null): void;
|
|
41
|
-
export declare function setAppBadgeCount(count: number): boolean;
|
|
42
|
-
export declare function setAppDockBadge(text: string): void;
|
|
43
|
-
export declare function setAppDockMenu(items: readonly MenuItemTemplate[]): void;
|
|
44
|
-
export declare function setAppLoginItem(settings: Readonly<AppLoginItemLike>): boolean;
|
|
45
|
-
export declare function setAppName(name: string): boolean;
|
|
46
|
-
export declare function setAppUserModelId(id: string): boolean;
|
|
47
|
-
export declare function showApp(): boolean;
|
|
18
|
+
export declare function focusApp(host: HasAppFocus): void;
|
|
19
|
+
export declare function getAppDirectoryPath(host: HasAppPath, kind: AppPathKind): string;
|
|
20
|
+
export declare function getAppExecutablePath(host: HasAppPath): string;
|
|
21
|
+
export declare function getAppLocale(host: HasAppLocale): string;
|
|
22
|
+
export declare function getAppLoginItem(host: HasAppLoginItem): AppLoginItem;
|
|
23
|
+
export declare function getAppName(host: HasAppName): string;
|
|
24
|
+
export declare function getAppPath(host: HasAppPath): string;
|
|
25
|
+
export declare function getAppPreferredSystemLanguages(host: HasAppLocale): readonly string[];
|
|
26
|
+
export declare function getAppSystemLocale(host: HasAppLocale): string;
|
|
27
|
+
export declare function getAppVersion(host: HasAppVersion): string;
|
|
28
|
+
export declare function hasAppSingleInstanceLock(host: HasAppSingleInstance): boolean;
|
|
29
|
+
export declare function hideApp(host: HasAppHide): void;
|
|
30
|
+
export declare function isAppHidden(host: HasAppHiddenQuery): boolean;
|
|
31
|
+
export declare function quitApp(host: HasAppQuit): void;
|
|
32
|
+
export declare function relaunchApp(host: HasAppRelaunch): void;
|
|
33
|
+
export declare function releaseAppSingleInstanceLock(host: HasAppSingleInstance): void;
|
|
34
|
+
export declare function requestAppAttention(host: HasAppDock, critical: boolean): number;
|
|
35
|
+
export declare function requestAppSingleInstanceLock(host: HasAppSingleInstance): boolean;
|
|
36
|
+
export declare function setAppActivationPolicy(host: HasAppActivationPolicy, policy: AppActivationPolicy): void;
|
|
37
|
+
export declare function setAppBadgeCount(host: HasAppBadge, count: number): Promise<boolean>;
|
|
38
|
+
export declare function setAppDockBadge(host: HasAppDock, text: string): void;
|
|
39
|
+
export declare function setAppDockMenu(host: HasAppDock, items: readonly MenuItemTemplate[]): void;
|
|
40
|
+
export declare function setAppLoginItem(host: HasAppLoginItem, settings: Readonly<AppLoginItemLike>): void;
|
|
41
|
+
export declare function setAppName(host: HasAppNameWrite, name: string): void;
|
|
42
|
+
export declare function setAppUserModelId(host: HasAppUserModelId, id: string): void;
|
|
43
|
+
export declare function showApp(host: HasAppShow): void;
|
|
44
|
+
export {};
|
|
48
45
|
//# sourceMappingURL=app.d.ts.map
|
package/dist/app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,GAAG,EACH,mBAAmB,EACnB,YAAY,EACZ,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,sBAAsB,EACtB,sBAAsB,EACtB,WAAW,EACX,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,UAAU,EACV,YAAY,EACZ,eAAe,EACf,UAAU,EACV,eAAe,EACf,cAAc,EACd,UAAU,EACV,UAAU,EACV,iBAAiB,EACjB,WAAW,EACX,qBAAqB,EACrB,cAAc,EACd,oBAAoB,EACpB,UAAU,EACV,oBAA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AU,EAAE,QAAQ,EAAE,OAAO,GAAG,MAAM,CAE/E;AAED,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAEhF;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,sBAAsB,EAAE,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAEtG;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAEnF;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAEpE;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,gBAAgB,EAAE,GAAG,IAAI,CAEzF;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,eAAe,EAAE,QAAQ,EAAE,QAAQ,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAEjG;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAEpE;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,iBAAiB,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAE3E;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAE9C"}
|
package/dist/app.js
CHANGED
|
@@ -1,351 +1,161 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// Begins delivering app events to `app`'s signals by subscribing to the active backend. Wires
|
|
8
|
-
// subscribeActivate→onActivate, subscribeAllWindowsClosed→onAllWindowsClosed,
|
|
9
|
-
// subscribeOpenFile→onOpenFile, subscribeQuitRequest→onQuitRequest,
|
|
10
|
-
// subscribeReady→onReady, subscribeSecondInstance→onSecondInstance.
|
|
11
|
-
// Idempotent: a prior subscription is torn down first. Pair with detachApp/disposeApp.
|
|
12
|
-
export function attachApp(app) {
|
|
1
|
+
import { createEntity } from '@flighthq/entity/contract';
|
|
2
|
+
import { clearSignal, createSignal, emitSignal } from '@flighthq/signals/contract';
|
|
3
|
+
export function addAppRecentDocument(host, path) {
|
|
4
|
+
host.app.recentDocuments.addRecentDocument(path);
|
|
5
|
+
}
|
|
6
|
+
export function attachApp(host, app) {
|
|
13
7
|
detachApp(app);
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
attachAppActivate(host, app);
|
|
9
|
+
attachAppAllWindowsClosed(host, app);
|
|
10
|
+
attachAppOpenFile(host, app);
|
|
11
|
+
attachAppQuitRequest(host, app);
|
|
12
|
+
attachAppReady(host, app);
|
|
13
|
+
attachAppSecondInstance(host, app);
|
|
14
|
+
}
|
|
15
|
+
export function attachAppActivate(host, app) {
|
|
16
|
+
replaceAppSubscription(app, 'activate', host.app.activate.subscribe(() => emitSignal(app.onActivate)));
|
|
17
|
+
}
|
|
18
|
+
export function attachAppAllWindowsClosed(host, app) {
|
|
19
|
+
replaceAppSubscription(app, 'allWindowsClosed', host.app.allWindowsClosed.subscribe(() => emitSignal(app.onAllWindowsClosed)));
|
|
20
|
+
}
|
|
21
|
+
export function attachAppOpenFile(host, app) {
|
|
22
|
+
replaceAppSubscription(app, 'openFile', host.app.openFile.subscribe((path) => emitSignal(app.onOpenFile, path)));
|
|
23
|
+
}
|
|
24
|
+
export function attachAppQuitRequest(host, app) {
|
|
25
|
+
replaceAppSubscription(app, 'quitRequest', host.app.quitRequest.subscribe((cancelHost) => {
|
|
19
26
|
emitSignal(app.onQuitRequest);
|
|
20
|
-
if (app.onQuitRequest.data?.cancelled === true)
|
|
21
|
-
// A Flight listener vetoed the quit — cancel at the host level too so that Electron (and other
|
|
22
|
-
// native hosts) can call event.preventDefault() and prevent the OS from forcing a quit.
|
|
27
|
+
if (app.onQuitRequest.data?.cancelled === true)
|
|
23
28
|
cancelHost();
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
_subscriptions.set(app, () => {
|
|
32
|
-
unsubscribeActivate();
|
|
33
|
-
unsubscribeAllWindowsClosed();
|
|
34
|
-
unsubscribeOpenFile();
|
|
35
|
-
unsubscribeQuitRequest();
|
|
36
|
-
unsubscribeReady();
|
|
37
|
-
unsubscribeSecondInstance();
|
|
38
|
-
});
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
export function attachAppReady(host, app) {
|
|
32
|
+
replaceAppSubscription(app, 'ready', host.app.ready.subscribe(() => emitSignal(app.onReady)));
|
|
33
|
+
}
|
|
34
|
+
export function attachAppSecondInstance(host, app) {
|
|
35
|
+
replaceAppSubscription(app, 'secondInstance', host.app.secondInstance.subscribe((argv) => emitSignal(app.onSecondInstance, argv)));
|
|
39
36
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return getAppBackend().bounceDock();
|
|
37
|
+
export function bounceAppDock(host) {
|
|
38
|
+
return host.app.dock.bounceDock();
|
|
43
39
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
getAppBackend().cancelAttention(id);
|
|
40
|
+
export function cancelAppAttention(host, id) {
|
|
41
|
+
host.app.dock.cancelAttention(id);
|
|
47
42
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
getAppBackend().cancelDockBounce(id);
|
|
43
|
+
export function cancelAppDockBounce(host, id) {
|
|
44
|
+
host.app.dock.cancelDockBounce(id);
|
|
51
45
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
getAppBackend().clearRecentDocuments();
|
|
46
|
+
export function clearAppRecentDocuments(host) {
|
|
47
|
+
host.app.recentDocuments.clearRecentDocuments();
|
|
55
48
|
}
|
|
56
|
-
// Allocates an App event entity with inert signals; call attachApp to start delivery.
|
|
57
49
|
export function createApp() {
|
|
58
|
-
return {
|
|
50
|
+
return createEntity({
|
|
59
51
|
onActivate: createSignal(),
|
|
60
52
|
onAllWindowsClosed: createSignal(),
|
|
61
53
|
onOpenFile: createSignal(),
|
|
62
54
|
onQuitRequest: createSignal(),
|
|
63
55
|
onReady: createSignal(),
|
|
64
56
|
onSecondInstance: createSignal(),
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
// Allocates an AppLoginItem with default values.
|
|
68
|
-
export function createAppLoginItem() {
|
|
69
|
-
return { args: [], openAsHidden: false, openAtLogin: false, path: '' };
|
|
57
|
+
});
|
|
70
58
|
}
|
|
71
|
-
// Stops delivery to `app` and forgets its subscription. Safe to call when not attached.
|
|
72
59
|
export function detachApp(app) {
|
|
73
|
-
const
|
|
74
|
-
if (
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
// plain GC-managed memory afterward.
|
|
60
|
+
const subscriptions = _subscriptions.get(app);
|
|
61
|
+
if (subscriptions === undefined)
|
|
62
|
+
return;
|
|
63
|
+
_subscriptions.delete(app);
|
|
64
|
+
for (const unsubscribe of Object.values(subscriptions))
|
|
65
|
+
unsubscribe?.();
|
|
66
|
+
}
|
|
81
67
|
export function disposeApp(app) {
|
|
82
68
|
detachApp(app);
|
|
69
|
+
clearSignal(app.onActivate);
|
|
70
|
+
clearSignal(app.onAllWindowsClosed);
|
|
71
|
+
clearSignal(app.onOpenFile);
|
|
72
|
+
clearSignal(app.onQuitRequest);
|
|
73
|
+
clearSignal(app.onReady);
|
|
74
|
+
clearSignal(app.onSecondInstance);
|
|
75
|
+
}
|
|
76
|
+
export function focusApp(host) {
|
|
77
|
+
host.app.focus.focus();
|
|
78
|
+
}
|
|
79
|
+
export function getAppDirectoryPath(host, kind) {
|
|
80
|
+
return host.app.path.getAppDirectoryPath(kind);
|
|
81
|
+
}
|
|
82
|
+
export function getAppExecutablePath(host) {
|
|
83
|
+
return host.app.path.getExecutablePath();
|
|
84
|
+
}
|
|
85
|
+
export function getAppLocale(host) {
|
|
86
|
+
return host.app.locale.getLocale();
|
|
87
|
+
}
|
|
88
|
+
export function getAppLoginItem(host) {
|
|
89
|
+
return host.app.loginItem.getLoginItem();
|
|
90
|
+
}
|
|
91
|
+
export function getAppName(host) {
|
|
92
|
+
return host.app.name.getName();
|
|
93
|
+
}
|
|
94
|
+
export function getAppPath(host) {
|
|
95
|
+
return host.app.path.getAppPath();
|
|
96
|
+
}
|
|
97
|
+
export function getAppPreferredSystemLanguages(host) {
|
|
98
|
+
return host.app.locale.getPreferredSystemLanguages();
|
|
99
|
+
}
|
|
100
|
+
export function getAppSystemLocale(host) {
|
|
101
|
+
return host.app.locale.getSystemLocale();
|
|
102
|
+
}
|
|
103
|
+
export function getAppVersion(host) {
|
|
104
|
+
return host.app.version.getVersion();
|
|
105
|
+
}
|
|
106
|
+
export function hasAppSingleInstanceLock(host) {
|
|
107
|
+
return host.app.singleInstance.hasSingleInstanceLock();
|
|
108
|
+
}
|
|
109
|
+
export function hideApp(host) {
|
|
110
|
+
host.app.hide.hideApp();
|
|
111
|
+
}
|
|
112
|
+
export function isAppHidden(host) {
|
|
113
|
+
return host.app.hiddenQuery.isAppHidden();
|
|
114
|
+
}
|
|
115
|
+
export function quitApp(host) {
|
|
116
|
+
host.app.quit.quit();
|
|
117
|
+
}
|
|
118
|
+
export function relaunchApp(host) {
|
|
119
|
+
host.app.relaunch.relaunch();
|
|
120
|
+
}
|
|
121
|
+
export function releaseAppSingleInstanceLock(host) {
|
|
122
|
+
host.app.singleInstance.releaseSingleInstanceLock();
|
|
123
|
+
}
|
|
124
|
+
export function requestAppAttention(host, critical) {
|
|
125
|
+
return host.app.dock.requestAttention(critical);
|
|
126
|
+
}
|
|
127
|
+
export function requestAppSingleInstanceLock(host) {
|
|
128
|
+
return host.app.singleInstance.requestSingleInstanceLock();
|
|
129
|
+
}
|
|
130
|
+
export function setAppActivationPolicy(host, policy) {
|
|
131
|
+
host.app.activationPolicy.setActivationPolicy(policy);
|
|
132
|
+
}
|
|
133
|
+
export function setAppBadgeCount(host, count) {
|
|
134
|
+
return host.app.badge.setBadgeCount(count);
|
|
135
|
+
}
|
|
136
|
+
export function setAppDockBadge(host, text) {
|
|
137
|
+
host.app.dock.setDockBadge(text);
|
|
138
|
+
}
|
|
139
|
+
export function setAppDockMenu(host, items) {
|
|
140
|
+
host.app.dock.setDockMenu(items);
|
|
141
|
+
}
|
|
142
|
+
export function setAppLoginItem(host, settings) {
|
|
143
|
+
host.app.loginItem.setLoginItem(settings);
|
|
144
|
+
}
|
|
145
|
+
export function setAppName(host, name) {
|
|
146
|
+
host.app.nameWrite.setName(name);
|
|
147
|
+
}
|
|
148
|
+
export function setAppUserModelId(host, id) {
|
|
149
|
+
host.app.userModelId.setUserModelId(id);
|
|
150
|
+
}
|
|
151
|
+
export function showApp(host) {
|
|
152
|
+
host.app.show.showApp();
|
|
83
153
|
}
|
|
84
|
-
export function explainAppBackend() {
|
|
85
|
-
if (_custom !== null) {
|
|
86
|
-
return { conflict: _hostConflict, layer: 'custom', operation: null, viability: 'unobserved' };
|
|
87
|
-
}
|
|
88
|
-
if (_host !== null) {
|
|
89
|
-
return {
|
|
90
|
-
conflict: _hostConflict,
|
|
91
|
-
layer: 'host',
|
|
92
|
-
operation: _hostObservation !== null ? _hostObservation.operation : null,
|
|
93
|
-
viability: _hostObservation !== null ? _hostObservation.viability : 'unobserved',
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
return { conflict: false, layer: 'host-not-enabled', operation: null, viability: 'unobserved' };
|
|
97
|
-
}
|
|
98
|
-
// Brings the application to the foreground.
|
|
99
|
-
export function focusApp() {
|
|
100
|
-
getAppBackend().focus();
|
|
101
|
-
}
|
|
102
|
-
export function getAppBackend() {
|
|
103
|
-
return _custom ?? _host ?? _sentinel;
|
|
104
|
-
}
|
|
105
|
-
// The command-line arguments for this process, or [] on web.
|
|
106
|
-
export function getAppCommandLine() {
|
|
107
|
-
return getAppBackend().getCommandLine();
|
|
108
|
-
}
|
|
109
|
-
// The value of a named command-line switch, or null when the switch is absent.
|
|
110
|
-
export function getAppCommandLineSwitch(name) {
|
|
111
|
-
const prefix = `--${name}=`;
|
|
112
|
-
const args = getAppBackend().getCommandLine();
|
|
113
|
-
for (const arg of args) {
|
|
114
|
-
if (arg === `--${name}`)
|
|
115
|
-
return '';
|
|
116
|
-
if (arg.startsWith(prefix))
|
|
117
|
-
return arg.slice(prefix.length);
|
|
118
|
-
}
|
|
119
|
-
return null;
|
|
120
|
-
}
|
|
121
|
-
// The app-identity-relative directory path for the given kind (userData/logs/crashDumps); '' on web.
|
|
122
|
-
// Note: bare OS directories (home, documents, downloads, appData, etc.) live in @flighthq/filesystem.
|
|
123
|
-
export function getAppDirectoryPath(kind) {
|
|
124
|
-
return getAppBackend().getAppDirectoryPath(kind);
|
|
125
|
-
}
|
|
126
|
-
// The application executable path, or '' on web.
|
|
127
|
-
export function getAppExecutablePath() {
|
|
128
|
-
return getAppBackend().getExecutablePath();
|
|
129
|
-
}
|
|
130
|
-
// The host UI locale (for example 'en-US'), or '' when unknown.
|
|
131
|
-
export function getAppLocale() {
|
|
132
|
-
return getAppBackend().getLocale();
|
|
133
|
-
}
|
|
134
|
-
// The application login-item settings. Returns a default with openAtLogin: false on web.
|
|
135
|
-
export function getAppLoginItem() {
|
|
136
|
-
return getAppBackend().getLoginItem();
|
|
137
|
-
}
|
|
138
|
-
// The application name, or '' when unknown.
|
|
139
|
-
export function getAppName() {
|
|
140
|
-
return getAppBackend().getName();
|
|
141
|
-
}
|
|
142
|
-
// The application bundle/exe directory path, or '' on web.
|
|
143
|
-
export function getAppPath() {
|
|
144
|
-
return getAppBackend().getAppPath();
|
|
145
|
-
}
|
|
146
|
-
// The ranked list of preferred system languages (for example ['en-US', 'fr-FR']), in preference
|
|
147
|
-
// order; [] when unavailable (on web: navigator.languages).
|
|
148
|
-
export function getAppPreferredSystemLanguages() {
|
|
149
|
-
return getAppBackend().getPreferredSystemLanguages();
|
|
150
|
-
}
|
|
151
|
-
// The OS-level system locale (for example 'en_US'), which may differ from the UI locale returned
|
|
152
|
-
// by getAppLocale; '' when unavailable.
|
|
153
|
-
export function getAppSystemLocale() {
|
|
154
|
-
return getAppBackend().getSystemLocale();
|
|
155
|
-
}
|
|
156
|
-
// The application version string, or '' when unknown.
|
|
157
|
-
export function getAppVersion() {
|
|
158
|
-
return getAppBackend().getVersion();
|
|
159
|
-
}
|
|
160
|
-
// True when the switch is present in the command line; false otherwise.
|
|
161
|
-
export function hasAppCommandLineSwitch(name) {
|
|
162
|
-
return getAppCommandLineSwitch(name) !== null;
|
|
163
|
-
}
|
|
164
|
-
// True when this process currently holds the single-instance lock.
|
|
165
|
-
export function hasAppSingleInstanceLock() {
|
|
166
|
-
return getAppBackend().hasSingleInstanceLock();
|
|
167
|
-
}
|
|
168
|
-
// Hides the application (macOS hide-all-windows). Returns true when supported. No-op on web.
|
|
169
|
-
export function hideApp() {
|
|
170
|
-
return getAppBackend().hideApp();
|
|
171
|
-
}
|
|
172
|
-
export function installAppHostBackend(backend) {
|
|
173
|
-
if (_host !== null) {
|
|
174
|
-
if (_host !== backend)
|
|
175
|
-
_hostConflict = true;
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
_host = backend;
|
|
179
|
-
}
|
|
180
|
-
// True when the application is hidden (macOS only). Always false on web.
|
|
181
|
-
export function isAppHidden() {
|
|
182
|
-
return getAppBackend().isAppHidden();
|
|
183
|
-
}
|
|
184
|
-
export function observeAppHostResult(operation, succeeded) {
|
|
185
|
-
_hostObservation = {
|
|
186
|
-
operation,
|
|
187
|
-
viability: succeeded ? 'available' : 'runtime-api-unavailable',
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
// Quits the application.
|
|
191
|
-
export function quitApp() {
|
|
192
|
-
getAppBackend().quit();
|
|
193
|
-
}
|
|
194
|
-
// Relaunches the application.
|
|
195
|
-
export function relaunchApp() {
|
|
196
|
-
getAppBackend().relaunch();
|
|
197
|
-
}
|
|
198
|
-
// Releases a previously acquired single-instance lock.
|
|
199
|
-
export function releaseAppSingleInstanceLock() {
|
|
200
|
-
getAppBackend().releaseSingleInstanceLock();
|
|
201
|
-
}
|
|
202
|
-
// Draws attention to the application at the OS level (taskbar flash / dock bounce). Returns a
|
|
203
|
-
// request id for cancelAppAttention, or -1 when unsupported.
|
|
204
|
-
export function requestAppAttention(critical) {
|
|
205
|
-
return getAppBackend().requestAttention(critical);
|
|
206
|
-
}
|
|
207
|
-
// Attempts to acquire the single-instance lock. Returns true when this process owns it; false when
|
|
208
|
-
// another instance already holds it.
|
|
209
|
-
export function requestAppSingleInstanceLock() {
|
|
210
|
-
return getAppBackend().requestSingleInstanceLock();
|
|
211
|
-
}
|
|
212
|
-
export function resetAppBackendForTest() {
|
|
213
|
-
_custom = null;
|
|
214
|
-
_host = null;
|
|
215
|
-
_hostConflict = false;
|
|
216
|
-
_hostObservation = null;
|
|
217
|
-
}
|
|
218
|
-
// Sets the macOS activation policy, controlling dock presence and Command-Tab visibility. No-op on
|
|
219
|
-
// non-macOS and web.
|
|
220
|
-
export function setAppActivationPolicy(policy) {
|
|
221
|
-
getAppBackend().setActivationPolicy(policy);
|
|
222
|
-
}
|
|
223
|
-
export function setAppBackend(backend) {
|
|
224
|
-
_custom = backend;
|
|
225
|
-
}
|
|
226
|
-
// Sets the numeric application badge (taskbar overlay / dock / PWA badge). Returns false when
|
|
227
|
-
// unsupported. Canonical home for the app badge — the tray package no longer carries it.
|
|
228
|
-
export function setAppBadgeCount(count) {
|
|
229
|
-
return getAppBackend().setBadgeCount(count);
|
|
230
|
-
}
|
|
231
|
-
// Sets the dock/taskbar badge text. Pass '' to clear it.
|
|
232
|
-
export function setAppDockBadge(text) {
|
|
233
|
-
getAppBackend().setDockBadge(text);
|
|
234
|
-
}
|
|
235
|
-
// Sets the macOs dock menu (shown when right-clicking the dock icon). No-op where there is no dock.
|
|
236
|
-
export function setAppDockMenu(items) {
|
|
237
|
-
getAppBackend().setDockMenu(items);
|
|
238
|
-
}
|
|
239
|
-
// Updates login-item (launch-at-startup) settings. Returns false when unsupported (web, some Linux
|
|
240
|
-
// environments). Settings fields not provided keep their current values.
|
|
241
|
-
export function setAppLoginItem(settings) {
|
|
242
|
-
return getAppBackend().setLoginItem(settings);
|
|
243
|
-
}
|
|
244
|
-
// Sets the application name. Returns false when unsupported (web). On macOS/Windows this updates
|
|
245
|
-
// the display name shown in the dock/taskbar.
|
|
246
|
-
export function setAppName(name) {
|
|
247
|
-
return getAppBackend().setName(name);
|
|
248
|
-
}
|
|
249
|
-
// Sets the Windows AppUserModelID used for taskbar grouping, badging, and Jump Lists. Returns false
|
|
250
|
-
// when unsupported. Should be set at startup before creating any windows.
|
|
251
|
-
export function setAppUserModelId(id) {
|
|
252
|
-
return getAppBackend().setUserModelId(id);
|
|
253
|
-
}
|
|
254
|
-
// Shows the application after hideApp (macOS). Returns true when supported. No-op on web.
|
|
255
|
-
export function showApp() {
|
|
256
|
-
return getAppBackend().showApp();
|
|
257
|
-
}
|
|
258
|
-
const _noop = () => () => { };
|
|
259
|
-
const _sentinel = {
|
|
260
|
-
addRecentDocument() { },
|
|
261
|
-
bounceDock() {
|
|
262
|
-
return -1;
|
|
263
|
-
},
|
|
264
|
-
cancelAttention() { },
|
|
265
|
-
cancelDockBounce() { },
|
|
266
|
-
clearRecentDocuments() { },
|
|
267
|
-
focus() { },
|
|
268
|
-
getAppDirectoryPath() {
|
|
269
|
-
return '';
|
|
270
|
-
},
|
|
271
|
-
getAppPath() {
|
|
272
|
-
return '';
|
|
273
|
-
},
|
|
274
|
-
getCommandLine() {
|
|
275
|
-
return [];
|
|
276
|
-
},
|
|
277
|
-
getExecutablePath() {
|
|
278
|
-
return '';
|
|
279
|
-
},
|
|
280
|
-
getLocale() {
|
|
281
|
-
return '';
|
|
282
|
-
},
|
|
283
|
-
getLoginItem() {
|
|
284
|
-
return { args: [], openAsHidden: false, openAtLogin: false, path: '' };
|
|
285
|
-
},
|
|
286
|
-
getName() {
|
|
287
|
-
return '';
|
|
288
|
-
},
|
|
289
|
-
getPreferredSystemLanguages() {
|
|
290
|
-
return [];
|
|
291
|
-
},
|
|
292
|
-
getSystemLocale() {
|
|
293
|
-
try {
|
|
294
|
-
return typeof Intl !== 'undefined' ? new Intl.DateTimeFormat().resolvedOptions().locale : '';
|
|
295
|
-
}
|
|
296
|
-
catch {
|
|
297
|
-
return '';
|
|
298
|
-
}
|
|
299
|
-
},
|
|
300
|
-
getVersion() {
|
|
301
|
-
return '';
|
|
302
|
-
},
|
|
303
|
-
hasSingleInstanceLock() {
|
|
304
|
-
return false;
|
|
305
|
-
},
|
|
306
|
-
hideApp() {
|
|
307
|
-
return false;
|
|
308
|
-
},
|
|
309
|
-
isAppHidden() {
|
|
310
|
-
return false;
|
|
311
|
-
},
|
|
312
|
-
quit() { },
|
|
313
|
-
relaunch() { },
|
|
314
|
-
releaseSingleInstanceLock() { },
|
|
315
|
-
requestAttention() {
|
|
316
|
-
return -1;
|
|
317
|
-
},
|
|
318
|
-
requestSingleInstanceLock() {
|
|
319
|
-
return false;
|
|
320
|
-
},
|
|
321
|
-
setActivationPolicy() { },
|
|
322
|
-
setBadgeCount() {
|
|
323
|
-
return false;
|
|
324
|
-
},
|
|
325
|
-
setDockBadge() { },
|
|
326
|
-
setDockMenu() { },
|
|
327
|
-
setLoginItem() {
|
|
328
|
-
return false;
|
|
329
|
-
},
|
|
330
|
-
setName() {
|
|
331
|
-
return false;
|
|
332
|
-
},
|
|
333
|
-
setUserModelId() {
|
|
334
|
-
return false;
|
|
335
|
-
},
|
|
336
|
-
showApp() {
|
|
337
|
-
return false;
|
|
338
|
-
},
|
|
339
|
-
subscribeActivate: _noop,
|
|
340
|
-
subscribeAllWindowsClosed: _noop,
|
|
341
|
-
subscribeOpenFile: _noop,
|
|
342
|
-
subscribeQuitRequest: _noop,
|
|
343
|
-
subscribeReady: _noop,
|
|
344
|
-
subscribeSecondInstance: _noop,
|
|
345
|
-
};
|
|
346
|
-
let _custom = null;
|
|
347
|
-
let _host = null;
|
|
348
|
-
let _hostConflict = false;
|
|
349
|
-
let _hostObservation = null;
|
|
350
154
|
const _subscriptions = new WeakMap();
|
|
155
|
+
function replaceAppSubscription(app, key, unsubscribe) {
|
|
156
|
+
const subscriptions = _subscriptions.get(app) ?? {};
|
|
157
|
+
subscriptions[key]?.();
|
|
158
|
+
subscriptions[key] = unsubscribe;
|
|
159
|
+
_subscriptions.set(app, subscriptions);
|
|
160
|
+
}
|
|
351
161
|
//# sourceMappingURL=app.js.map
|