@ng-desktop/desktop 0.3.0 → 0.4.1
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 +48 -8
- package/fesm2022/compute-service.d.ts +0 -1
- package/fesm2022/compute-service.js +3 -4
- package/fesm2022/desktop-service.d.ts +45 -1
- package/fesm2022/desktop-service.js +230 -5
- package/fesm2022/drop-target.directive.d.ts +0 -1
- package/fesm2022/drop-target.directive.js +3 -4
- package/fesm2022/fs-service.d.ts +0 -1
- package/fesm2022/fs-service.js +3 -4
- package/fesm2022/index.d.ts +1 -2
- package/fesm2022/index.js +0 -1
- package/fesm2022/network-service.d.ts +0 -1
- package/fesm2022/network-service.js +3 -4
- package/fesm2022/sqlite-service.d.ts +1 -1
- package/fesm2022/sqlite-service.js +16 -5
- package/package.json +4 -3
- package/fesm2022/compute-service.d.ts.map +0 -1
- package/fesm2022/compute-service.js.map +0 -1
- package/fesm2022/desktop-service.d.ts.map +0 -1
- package/fesm2022/desktop-service.js.map +0 -1
- package/fesm2022/drop-target.directive.d.ts.map +0 -1
- package/fesm2022/drop-target.directive.js.map +0 -1
- package/fesm2022/fs-service.d.ts.map +0 -1
- package/fesm2022/fs-service.js.map +0 -1
- package/fesm2022/index.d.ts.map +0 -1
- package/fesm2022/index.js.map +0 -1
- package/fesm2022/network-service.d.ts.map +0 -1
- package/fesm2022/network-service.js.map +0 -1
- package/fesm2022/sqlite-service.d.ts.map +0 -1
- package/fesm2022/sqlite-service.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,14 +1,54 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@ng-desktop/desktop`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Angular desktop OS services powered by the Rust host bridge: theme signals, notifications, clipboard, file/confirm dialogs, `(closeRequest)` guards, scroll telemetry, SQLite WAL live queries, XDG filesystem + kernel file watching, network monitoring, drag-and-drop, and multithreaded fuzzy compute.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
## Installation
|
|
5
|
+
## Install
|
|
8
6
|
|
|
9
7
|
```bash
|
|
10
|
-
pnpm add @ng-desktop/desktop
|
|
8
|
+
pnpm add @ng-desktop/desktop @ng-desktop/platform
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Peer dependencies: `@angular/core >= 22.0.0`, `@ng-desktop/platform`.
|
|
12
|
+
|
|
13
|
+
## Quick Usage
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { inject, Injectable } from '@angular/core';
|
|
17
|
+
import {
|
|
18
|
+
NativeDesktopService,
|
|
19
|
+
NativeFileSystemService,
|
|
20
|
+
NativeSqliteService,
|
|
21
|
+
} from '@ng-desktop/desktop';
|
|
22
|
+
|
|
23
|
+
@Injectable({ providedIn: 'root' })
|
|
24
|
+
export class WorkspaceStore {
|
|
25
|
+
private readonly desktop = inject(NativeDesktopService);
|
|
26
|
+
private readonly sqlite = inject(NativeSqliteService);
|
|
27
|
+
private readonly fs = inject(NativeFileSystemService);
|
|
28
|
+
|
|
29
|
+
readonly tasks = this.sqlite.liveQuery<{ id: string; title: string }>(
|
|
30
|
+
'SELECT id, title FROM tasks ORDER BY id DESC;',
|
|
31
|
+
);
|
|
32
|
+
readonly config = this.fs.watchJson(this.fs.resolveXdgPath('config', 'settings.json'), {
|
|
33
|
+
dark: true,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
notifySaved(title: string): void {
|
|
37
|
+
this.desktop.notify('Saved', title);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
11
40
|
```
|
|
12
41
|
|
|
13
|
-
|
|
14
|
-
|
|
42
|
+
Add `provideNativeDesktop()` to `appConfig.providers`.
|
|
43
|
+
|
|
44
|
+
## Key Exports
|
|
45
|
+
|
|
46
|
+
- **OS Hub & Lifecycle:** `provideNativeDesktop`, `NativeDesktopService` (`theme`, `notify`, `confirmDialog`, `openFileDialog`, `saveFileDialog`, `onScroll`, `onScrollBottom`, `onWindowCloseRequest`, `setPreventClose`, `closeWindow`, `setAppMenu`, `setTray`, `registerShortcut`)
|
|
47
|
+
- **SQLite & Storage:** `NativeSqliteService` (`execute`, `query`, `liveQuery`)
|
|
48
|
+
- **Filesystem & Watcher:** `NativeFileSystemService` (`resolveXdgPath`, `readText`, `writeText`, `readJson`, `writeJson`, `watchFile`, `watchJson`)
|
|
49
|
+
- **Networking, Compute & Drop:** `NativeNetworkService`, `NativeComputeService` (`fuzzyFilter`, `hash`), `NativeDropTargetDirective`
|
|
50
|
+
|
|
51
|
+
## Documentation
|
|
52
|
+
|
|
53
|
+
- [Getting Started with External Angular 22+ & Nx Apps](../../docs/GETTING_STARTED.md)
|
|
54
|
+
- [Architectural Roadmap & OS Maturity Matrix](../../ROADMAP.md)
|
|
@@ -22,11 +22,10 @@ export class NativeComputeService {
|
|
|
22
22
|
hash(input) {
|
|
23
23
|
return this.bridge.computeHash(input);
|
|
24
24
|
}
|
|
25
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
26
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.
|
|
25
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: NativeComputeService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
26
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: NativeComputeService, providedIn: 'root' });
|
|
27
27
|
}
|
|
28
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
28
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: NativeComputeService, decorators: [{
|
|
29
29
|
type: Injectable,
|
|
30
30
|
args: [{ providedIn: 'root' }]
|
|
31
31
|
}] });
|
|
32
|
-
//# sourceMappingURL=compute-service.js.map
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { EnvironmentProviders, WritableSignal } from '@angular/core';
|
|
2
|
+
import { type NativeConfirmDialogOptions, type NativeMenuItem, type NativeShortcutBinding, type NativeTrayState, type NativeWindowGeometry } from '@ng-desktop/platform';
|
|
2
3
|
import * as i0 from "@angular/core";
|
|
3
4
|
export type NativeThemeMode = 'dark' | 'light';
|
|
5
|
+
export type { NativeMenuItem, NativeShortcutBinding, NativeTrayState, NativeWindowGeometry, } from '@ng-desktop/platform';
|
|
6
|
+
export type ConfirmDialogOptions = NativeConfirmDialogOptions;
|
|
4
7
|
export interface OpenFileDialogOptions {
|
|
5
8
|
title?: string;
|
|
6
9
|
defaultPath?: string;
|
|
@@ -9,6 +12,22 @@ export interface SaveFileDialogOptions {
|
|
|
9
12
|
title?: string;
|
|
10
13
|
suggestedName?: string;
|
|
11
14
|
}
|
|
15
|
+
export interface NativeScrollEvent {
|
|
16
|
+
scrollTop: number;
|
|
17
|
+
scrollHeight: number;
|
|
18
|
+
clientHeight: number;
|
|
19
|
+
atTop: boolean;
|
|
20
|
+
atBottom: boolean;
|
|
21
|
+
progress: number;
|
|
22
|
+
}
|
|
23
|
+
export interface NativeResizeEvent {
|
|
24
|
+
width: number;
|
|
25
|
+
height: number;
|
|
26
|
+
maximized: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface NativeCloseRequestEvent {
|
|
29
|
+
preventable: boolean;
|
|
30
|
+
}
|
|
12
31
|
/**
|
|
13
32
|
* Injectable Angular service providing reactive access to native Desktop OS capabilities:
|
|
14
33
|
* - System Dark/Light theme (`theme` signal synchronized with `GtkSettings` / `AdwStyleManager`)
|
|
@@ -18,7 +37,13 @@ export interface SaveFileDialogOptions {
|
|
|
18
37
|
*/
|
|
19
38
|
export declare class NativeDesktopService {
|
|
20
39
|
private readonly bridge;
|
|
40
|
+
private readonly actionHandlers;
|
|
21
41
|
readonly theme: WritableSignal<NativeThemeMode>;
|
|
42
|
+
readonly windowGeometry: WritableSignal<NativeWindowGeometry>;
|
|
43
|
+
readonly appMenu: WritableSignal<readonly NativeMenuItem[]>;
|
|
44
|
+
readonly trayState: WritableSignal<NativeTrayState>;
|
|
45
|
+
readonly shortcuts: WritableSignal<readonly NativeShortcutBinding[]>;
|
|
46
|
+
readonly windowFocused: WritableSignal<boolean>;
|
|
22
47
|
constructor();
|
|
23
48
|
setTheme(mode: NativeThemeMode): void;
|
|
24
49
|
toggleTheme(): NativeThemeMode;
|
|
@@ -27,8 +52,27 @@ export declare class NativeDesktopService {
|
|
|
27
52
|
notify(title: string, body: string, icon?: string): void;
|
|
28
53
|
openFileDialog(options?: OpenFileDialogOptions): string;
|
|
29
54
|
saveFileDialog(options?: SaveFileDialogOptions): string;
|
|
55
|
+
confirmDialog(options?: ConfirmDialogOptions): boolean;
|
|
56
|
+
setNextConfirmDialogResponse(confirmed: boolean): void;
|
|
57
|
+
loadWindowGeometry(): NativeWindowGeometry;
|
|
58
|
+
saveWindowGeometry(patch: Partial<NativeWindowGeometry>): NativeWindowGeometry;
|
|
59
|
+
setAppMenu(items: readonly NativeMenuItem[], handlers?: Record<string, () => void>): readonly NativeMenuItem[];
|
|
60
|
+
triggerMenuAction(actionId: string): boolean;
|
|
61
|
+
setTray(patch: Partial<NativeTrayState>): NativeTrayState;
|
|
62
|
+
registerShortcut(accelerator: string, actionId: string, handler?: () => void): readonly NativeShortcutBinding[];
|
|
63
|
+
unregisterShortcut(accelerator: string): readonly NativeShortcutBinding[];
|
|
64
|
+
triggerShortcut(accelerator: string): boolean;
|
|
65
|
+
onWindowResize(handler: (event: NativeResizeEvent) => void, windowNodeId?: string): () => void;
|
|
66
|
+
onWindowFocusChange(handler: (focused: boolean) => void, windowNodeId?: string): () => void;
|
|
67
|
+
onScroll(scrollNodeId: string, handler: (event: NativeScrollEvent) => void): () => void;
|
|
68
|
+
onScrollBottom(scrollNodeId: string, handler: () => void): () => void;
|
|
69
|
+
setPreventClose(prevent: boolean, windowNodeId?: string): void;
|
|
70
|
+
closeWindow(windowNodeId?: string): void;
|
|
71
|
+
onWindowCloseRequest(handler: (event: NativeCloseRequestEvent) => void, options?: {
|
|
72
|
+
preventClose?: boolean;
|
|
73
|
+
windowNodeId?: string;
|
|
74
|
+
}): () => void;
|
|
30
75
|
static ɵfac: i0.ɵɵFactoryDeclaration<NativeDesktopService, never>;
|
|
31
76
|
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
32
77
|
}
|
|
33
78
|
export declare function provideNativeDesktop(): EnvironmentProviders;
|
|
34
|
-
//# sourceMappingURL=desktop-service.d.ts.map
|
|
@@ -1,10 +1,45 @@
|
|
|
1
1
|
import { Injectable, makeEnvironmentProviders, signal, } from '@angular/core';
|
|
2
|
-
import { ensureNgNativeBridge } from '@ng-desktop/platform';
|
|
2
|
+
import { ensureNgNativeBridge, } from '@ng-desktop/platform';
|
|
3
3
|
import { NativeComputeService } from './compute-service.js';
|
|
4
4
|
import { NativeFileSystemService } from './fs-service.js';
|
|
5
5
|
import { NativeNetworkService } from './network-service.js';
|
|
6
6
|
import { NativeSqliteService } from './sqlite-service.js';
|
|
7
7
|
import * as i0 from "@angular/core";
|
|
8
|
+
const WINDOW_STATE_FILE = 'window-state.json';
|
|
9
|
+
const DEFAULT_WINDOW_GEOMETRY = {
|
|
10
|
+
width: 1020,
|
|
11
|
+
height: 720,
|
|
12
|
+
x: null,
|
|
13
|
+
y: null,
|
|
14
|
+
maximized: false,
|
|
15
|
+
};
|
|
16
|
+
function parseBridgePayloadObject(raw) {
|
|
17
|
+
const tryParse = (candidate) => {
|
|
18
|
+
if (typeof candidate !== 'string')
|
|
19
|
+
return null;
|
|
20
|
+
const trimmed = candidate.trim();
|
|
21
|
+
if (!trimmed.startsWith('{') || !trimmed.endsWith('}'))
|
|
22
|
+
return null;
|
|
23
|
+
try {
|
|
24
|
+
const parsed = JSON.parse(trimmed);
|
|
25
|
+
return parsed && typeof parsed === 'object' && !Array.isArray(parsed)
|
|
26
|
+
? parsed
|
|
27
|
+
: null;
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const direct = tryParse(raw);
|
|
34
|
+
if (direct)
|
|
35
|
+
return direct;
|
|
36
|
+
if (raw && typeof raw === 'object' && !Array.isArray(raw)) {
|
|
37
|
+
const obj = raw;
|
|
38
|
+
const nested = tryParse(obj['value']);
|
|
39
|
+
return nested ? { ...obj, ...nested } : obj;
|
|
40
|
+
}
|
|
41
|
+
return {};
|
|
42
|
+
}
|
|
8
43
|
/**
|
|
9
44
|
* Injectable Angular service providing reactive access to native Desktop OS capabilities:
|
|
10
45
|
* - System Dark/Light theme (`theme` signal synchronized with `GtkSettings` / `AdwStyleManager`)
|
|
@@ -14,10 +49,30 @@ import * as i0 from "@angular/core";
|
|
|
14
49
|
*/
|
|
15
50
|
export class NativeDesktopService {
|
|
16
51
|
bridge = ensureNgNativeBridge();
|
|
52
|
+
actionHandlers = new Map();
|
|
17
53
|
theme;
|
|
54
|
+
windowGeometry;
|
|
55
|
+
appMenu;
|
|
56
|
+
trayState;
|
|
57
|
+
shortcuts;
|
|
58
|
+
windowFocused = signal(true, /* @ts-ignore */
|
|
59
|
+
...(ngDevMode ? [{ debugName: "windowFocused" }] : /* istanbul ignore next */ []));
|
|
18
60
|
constructor() {
|
|
19
61
|
this.theme = signal(this.bridge.getSystemTheme(), /* @ts-ignore */
|
|
20
62
|
...(ngDevMode ? [{ debugName: "theme" }] : /* istanbul ignore next */ []));
|
|
63
|
+
this.windowGeometry = signal(this.bridge.getWindowGeometry?.() ?? { ...DEFAULT_WINDOW_GEOMETRY }, /* @ts-ignore */
|
|
64
|
+
...(ngDevMode ? [{ debugName: "windowGeometry" }] : /* istanbul ignore next */ []));
|
|
65
|
+
this.appMenu = signal(this.bridge.getAppMenu?.() ?? [], /* @ts-ignore */
|
|
66
|
+
...(ngDevMode ? [{ debugName: "appMenu" }] : /* istanbul ignore next */ []));
|
|
67
|
+
this.trayState = signal(this.bridge.getTrayState?.() ?? {
|
|
68
|
+
visible: false,
|
|
69
|
+
icon: '',
|
|
70
|
+
tooltip: '',
|
|
71
|
+
menuItems: [],
|
|
72
|
+
}, /* @ts-ignore */
|
|
73
|
+
...(ngDevMode ? [{ debugName: "trayState" }] : /* istanbul ignore next */ []));
|
|
74
|
+
this.shortcuts = signal(this.bridge.getRegisteredShortcuts?.() ?? [], /* @ts-ignore */
|
|
75
|
+
...(ngDevMode ? [{ debugName: "shortcuts" }] : /* istanbul ignore next */ []));
|
|
21
76
|
}
|
|
22
77
|
setTheme(mode) {
|
|
23
78
|
this.bridge.setSystemTheme(mode);
|
|
@@ -43,10 +98,181 @@ export class NativeDesktopService {
|
|
|
43
98
|
saveFileDialog(options) {
|
|
44
99
|
return this.bridge.saveFileDialog(options?.title, options?.suggestedName);
|
|
45
100
|
}
|
|
46
|
-
|
|
47
|
-
|
|
101
|
+
confirmDialog(options) {
|
|
102
|
+
if (typeof this.bridge.confirmDialog === 'function') {
|
|
103
|
+
return this.bridge.confirmDialog(options);
|
|
104
|
+
}
|
|
105
|
+
return options?.defaultConfirmed !== false;
|
|
106
|
+
}
|
|
107
|
+
setNextConfirmDialogResponse(confirmed) {
|
|
108
|
+
this.bridge.setNextConfirmDialogResponse?.(confirmed);
|
|
109
|
+
}
|
|
110
|
+
loadWindowGeometry() {
|
|
111
|
+
let geometry = this.bridge.getWindowGeometry?.() ?? { ...DEFAULT_WINDOW_GEOMETRY };
|
|
112
|
+
try {
|
|
113
|
+
const statePath = this.bridge.fsResolvePath('config', WINDOW_STATE_FILE);
|
|
114
|
+
const raw = this.bridge.fsReadText(statePath);
|
|
115
|
+
if (raw) {
|
|
116
|
+
const parsed = JSON.parse(raw);
|
|
117
|
+
geometry = this.bridge.setWindowGeometry?.(parsed) ?? { ...geometry, ...parsed };
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
// Keep current bridge geometry when XDG storage is unavailable or invalid
|
|
122
|
+
}
|
|
123
|
+
this.windowGeometry.set(geometry);
|
|
124
|
+
return geometry;
|
|
125
|
+
}
|
|
126
|
+
saveWindowGeometry(patch) {
|
|
127
|
+
const next = this.bridge.setWindowGeometry?.(patch) ?? {
|
|
128
|
+
...this.windowGeometry(),
|
|
129
|
+
...patch,
|
|
130
|
+
};
|
|
131
|
+
this.windowGeometry.set(next);
|
|
132
|
+
try {
|
|
133
|
+
const statePath = this.bridge.fsResolvePath('config', WINDOW_STATE_FILE);
|
|
134
|
+
this.bridge.fsWriteText(statePath, JSON.stringify(next));
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
// Best-effort persistence when XDG filesystem access is restricted
|
|
138
|
+
}
|
|
139
|
+
return next;
|
|
140
|
+
}
|
|
141
|
+
setAppMenu(items, handlers) {
|
|
142
|
+
if (handlers) {
|
|
143
|
+
for (const [id, handler] of Object.entries(handlers)) {
|
|
144
|
+
this.actionHandlers.set(id, handler);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
const updated = this.bridge.setAppMenu?.(items) ??
|
|
148
|
+
items.map((item) => ({ ...item, enabled: item.enabled !== false }));
|
|
149
|
+
this.appMenu.set(updated);
|
|
150
|
+
return updated;
|
|
151
|
+
}
|
|
152
|
+
triggerMenuAction(actionId) {
|
|
153
|
+
const menuItem = this.appMenu().find((item) => item.id === actionId);
|
|
154
|
+
if (menuItem?.enabled === false) {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
const handler = this.actionHandlers.get(actionId);
|
|
158
|
+
if (!handler) {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
handler();
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
setTray(patch) {
|
|
165
|
+
const next = this.bridge.setTrayState?.(patch) ?? {
|
|
166
|
+
...this.trayState(),
|
|
167
|
+
...patch,
|
|
168
|
+
};
|
|
169
|
+
this.trayState.set(next);
|
|
170
|
+
return next;
|
|
171
|
+
}
|
|
172
|
+
registerShortcut(accelerator, actionId, handler) {
|
|
173
|
+
if (handler) {
|
|
174
|
+
this.actionHandlers.set(actionId, handler);
|
|
175
|
+
}
|
|
176
|
+
const next = this.bridge.registerShortcut?.(accelerator, actionId) ?? [
|
|
177
|
+
...this.shortcuts().filter((item) => item.accelerator !== accelerator.trim()),
|
|
178
|
+
{ accelerator: accelerator.trim(), actionId: actionId.trim() },
|
|
179
|
+
];
|
|
180
|
+
this.shortcuts.set(next);
|
|
181
|
+
return next;
|
|
182
|
+
}
|
|
183
|
+
unregisterShortcut(accelerator) {
|
|
184
|
+
const next = this.bridge.unregisterShortcut?.(accelerator) ??
|
|
185
|
+
this.shortcuts().filter((item) => item.accelerator !== accelerator.trim());
|
|
186
|
+
this.shortcuts.set(next);
|
|
187
|
+
return next;
|
|
188
|
+
}
|
|
189
|
+
triggerShortcut(accelerator) {
|
|
190
|
+
const normalized = accelerator.trim().toLowerCase();
|
|
191
|
+
const binding = this.shortcuts().find((item) => item.accelerator.trim().toLowerCase() === normalized);
|
|
192
|
+
if (!binding) {
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
const handler = this.actionHandlers.get(binding.actionId);
|
|
196
|
+
if (!handler) {
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
handler();
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
onWindowResize(handler, windowNodeId = 'win') {
|
|
203
|
+
return this.bridge.listen(windowNodeId, 'resize', (raw) => {
|
|
204
|
+
const parsed = parseBridgePayloadObject(raw);
|
|
205
|
+
const current = this.windowGeometry();
|
|
206
|
+
const event = {
|
|
207
|
+
width: Number(parsed['width'] ?? current.width),
|
|
208
|
+
height: Number(parsed['height'] ?? current.height),
|
|
209
|
+
maximized: Boolean(parsed['maximized'] ?? current.maximized),
|
|
210
|
+
};
|
|
211
|
+
this.windowGeometry.set({ ...current, ...event });
|
|
212
|
+
handler(event);
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
onWindowFocusChange(handler, windowNodeId = 'win') {
|
|
216
|
+
const unFocus = this.bridge.listen(windowNodeId, 'focus', () => {
|
|
217
|
+
this.windowFocused.set(true);
|
|
218
|
+
handler(true);
|
|
219
|
+
});
|
|
220
|
+
const unBlur = this.bridge.listen(windowNodeId, 'blur', () => {
|
|
221
|
+
this.windowFocused.set(false);
|
|
222
|
+
handler(false);
|
|
223
|
+
});
|
|
224
|
+
return () => {
|
|
225
|
+
unFocus();
|
|
226
|
+
unBlur();
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
onScroll(scrollNodeId, handler) {
|
|
230
|
+
return this.bridge.listen(scrollNodeId, 'scroll', (raw) => {
|
|
231
|
+
const parsed = parseBridgePayloadObject(raw);
|
|
232
|
+
handler({
|
|
233
|
+
scrollTop: Number(parsed['scrollTop'] ?? 0),
|
|
234
|
+
scrollHeight: Number(parsed['scrollHeight'] ?? 0),
|
|
235
|
+
clientHeight: Number(parsed['clientHeight'] ?? 0),
|
|
236
|
+
atTop: Boolean(parsed['atTop'] ?? false),
|
|
237
|
+
atBottom: Boolean(parsed['atBottom'] ?? false),
|
|
238
|
+
progress: Number(parsed['progress'] ?? 0),
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
onScrollBottom(scrollNodeId, handler) {
|
|
243
|
+
return this.bridge.listen(scrollNodeId, 'scroll-bottom', () => {
|
|
244
|
+
handler();
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
setPreventClose(prevent, windowNodeId = 'win') {
|
|
248
|
+
this.bridge.setAttribute(windowNodeId, 'prevent-close', prevent ? 'true' : 'false');
|
|
249
|
+
}
|
|
250
|
+
closeWindow(windowNodeId = 'win') {
|
|
251
|
+
this.bridge.setAttribute(windowNodeId, 'close-window', 'true');
|
|
252
|
+
}
|
|
253
|
+
onWindowCloseRequest(handler, options) {
|
|
254
|
+
const windowNodeId = options?.windowNodeId ?? 'win';
|
|
255
|
+
if (options?.preventClose !== undefined) {
|
|
256
|
+
this.setPreventClose(options.preventClose, windowNodeId);
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
this.bridge.setAttribute(windowNodeId, 'event-mask', 'close-request');
|
|
260
|
+
}
|
|
261
|
+
const unlisten = this.bridge.listen(windowNodeId, 'close-request', (raw) => {
|
|
262
|
+
const parsed = parseBridgePayloadObject(raw);
|
|
263
|
+
handler({ preventable: Boolean(parsed['preventable']) });
|
|
264
|
+
});
|
|
265
|
+
return () => {
|
|
266
|
+
if (options?.preventClose) {
|
|
267
|
+
this.setPreventClose(false, windowNodeId);
|
|
268
|
+
}
|
|
269
|
+
unlisten();
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: NativeDesktopService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
273
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: NativeDesktopService, providedIn: 'root' });
|
|
48
274
|
}
|
|
49
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
275
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: NativeDesktopService, decorators: [{
|
|
50
276
|
type: Injectable,
|
|
51
277
|
args: [{ providedIn: 'root' }]
|
|
52
278
|
}], ctorParameters: () => [] });
|
|
@@ -59,4 +285,3 @@ export function provideNativeDesktop() {
|
|
|
59
285
|
NativeFileSystemService,
|
|
60
286
|
]);
|
|
61
287
|
}
|
|
62
|
-
//# sourceMappingURL=desktop-service.js.map
|
|
@@ -18,4 +18,3 @@ export declare class NativeDropTargetDirective implements OnDestroy {
|
|
|
18
18
|
static ɵfac: i0.ɵɵFactoryDeclaration<NativeDropTargetDirective, never>;
|
|
19
19
|
static ɵdir: i0.ɵɵDirectiveDeclaration<NativeDropTargetDirective, "[ngNativeDropTarget]", never, {}, { "fileDrop": "fileDrop"; }, never, never, true, never>;
|
|
20
20
|
}
|
|
21
|
-
//# sourceMappingURL=drop-target.directive.d.ts.map
|
|
@@ -44,14 +44,13 @@ export class NativeDropTargetDirective {
|
|
|
44
44
|
ngOnDestroy() {
|
|
45
45
|
this.unlisten();
|
|
46
46
|
}
|
|
47
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
48
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.
|
|
47
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: NativeDropTargetDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
48
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.3.0", type: NativeDropTargetDirective, isStandalone: true, selector: "[ngNativeDropTarget]", outputs: { fileDrop: "fileDrop" }, ngImport: i0 });
|
|
49
49
|
}
|
|
50
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
50
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: NativeDropTargetDirective, decorators: [{
|
|
51
51
|
type: Directive,
|
|
52
52
|
args: [{
|
|
53
53
|
selector: '[ngNativeDropTarget]',
|
|
54
54
|
standalone: true,
|
|
55
55
|
}]
|
|
56
56
|
}], ctorParameters: () => [], propDecorators: { fileDrop: [{ type: i0.Output, args: ["fileDrop"] }] } });
|
|
57
|
-
//# sourceMappingURL=drop-target.directive.js.map
|
package/fesm2022/fs-service.d.ts
CHANGED
package/fesm2022/fs-service.js
CHANGED
|
@@ -74,11 +74,10 @@ export class NativeFileSystemService {
|
|
|
74
74
|
}
|
|
75
75
|
return changed;
|
|
76
76
|
}
|
|
77
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
78
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.
|
|
77
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: NativeFileSystemService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
78
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: NativeFileSystemService, providedIn: 'root' });
|
|
79
79
|
}
|
|
80
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
80
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: NativeFileSystemService, decorators: [{
|
|
81
81
|
type: Injectable,
|
|
82
82
|
args: [{ providedIn: 'root' }]
|
|
83
83
|
}] });
|
|
84
|
-
//# sourceMappingURL=fs-service.js.map
|
package/fesm2022/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export { NativeComputeService, type NativeScoredItem } from './compute-service';
|
|
2
|
-
export { NativeDesktopService, provideNativeDesktop, type NativeThemeMode, type OpenFileDialogOptions, type SaveFileDialogOptions, } from './desktop-service';
|
|
2
|
+
export { NativeDesktopService, provideNativeDesktop, type ConfirmDialogOptions, type NativeCloseRequestEvent, type NativeMenuItem, type NativeResizeEvent, type NativeScrollEvent, type NativeShortcutBinding, type NativeThemeMode, type NativeTrayState, type NativeWindowGeometry, type OpenFileDialogOptions, type SaveFileDialogOptions, } from './desktop-service';
|
|
3
3
|
export { NativeDropTargetDirective, type NativeFileDropPayload } from './drop-target.directive';
|
|
4
4
|
export { NativeFileSystemService, type NativeWatchedFileRef } from './fs-service';
|
|
5
5
|
export { NativeNetworkService } from './network-service';
|
|
6
6
|
export { NativeSqliteService, type NativeLiveQueryRef } from './sqlite-service';
|
|
7
|
-
//# sourceMappingURL=index.d.ts.map
|
package/fesm2022/index.js
CHANGED
|
@@ -4,4 +4,3 @@ export { NativeDropTargetDirective } from './drop-target.directive.js';
|
|
|
4
4
|
export { NativeFileSystemService } from './fs-service.js';
|
|
5
5
|
export { NativeNetworkService } from './network-service.js';
|
|
6
6
|
export { NativeSqliteService } from './sqlite-service.js';
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -33,11 +33,10 @@ export class NativeNetworkService {
|
|
|
33
33
|
this.isOnline.set(online);
|
|
34
34
|
this.isMetered.set(metered);
|
|
35
35
|
}
|
|
36
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
37
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.
|
|
36
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: NativeNetworkService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
37
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: NativeNetworkService, providedIn: 'root' });
|
|
38
38
|
}
|
|
39
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
39
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: NativeNetworkService, decorators: [{
|
|
40
40
|
type: Injectable,
|
|
41
41
|
args: [{ providedIn: 'root' }]
|
|
42
42
|
}], ctorParameters: () => [] });
|
|
43
|
-
//# sourceMappingURL=network-service.js.map
|
|
@@ -4,6 +4,7 @@ export interface NativeLiveQueryRef<T> {
|
|
|
4
4
|
readonly rows: Signal<T[]>;
|
|
5
5
|
readonly count: Signal<number>;
|
|
6
6
|
refresh(): T[];
|
|
7
|
+
destroy(): void;
|
|
7
8
|
}
|
|
8
9
|
/**
|
|
9
10
|
* Reactive native SQLite service backed by Rust `libsqlite3.so.0` FFI (`NativeSqliteDatabase`)
|
|
@@ -19,4 +20,3 @@ export declare class NativeSqliteService {
|
|
|
19
20
|
static ɵfac: i0.ɵɵFactoryDeclaration<NativeSqliteService, never>;
|
|
20
21
|
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
21
22
|
}
|
|
22
|
-
//# sourceMappingURL=sqlite-service.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { computed, Injectable, signal } from '@angular/core';
|
|
1
|
+
import { computed, DestroyRef, inject, Injectable, signal } from '@angular/core';
|
|
2
2
|
import { ensureNgNativeBridge } from '@ng-desktop/platform';
|
|
3
3
|
import * as i0 from "@angular/core";
|
|
4
4
|
/**
|
|
@@ -35,17 +35,28 @@ export class NativeSqliteService {
|
|
|
35
35
|
};
|
|
36
36
|
refresh();
|
|
37
37
|
this.liveQueryRefreshers.add(refresh);
|
|
38
|
+
const destroy = () => {
|
|
39
|
+
this.liveQueryRefreshers.delete(refresh);
|
|
40
|
+
};
|
|
41
|
+
let destroyRef = null;
|
|
42
|
+
try {
|
|
43
|
+
destroyRef = inject(DestroyRef, { optional: true });
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
destroyRef = null;
|
|
47
|
+
}
|
|
48
|
+
destroyRef?.onDestroy(destroy);
|
|
38
49
|
return {
|
|
39
50
|
rows: rowsSignal.asReadonly(),
|
|
40
51
|
count: computed(() => rowsSignal().length),
|
|
41
52
|
refresh,
|
|
53
|
+
destroy,
|
|
42
54
|
};
|
|
43
55
|
}
|
|
44
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
45
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.
|
|
56
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: NativeSqliteService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
57
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: NativeSqliteService, providedIn: 'root' });
|
|
46
58
|
}
|
|
47
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
59
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: NativeSqliteService, decorators: [{
|
|
48
60
|
type: Injectable,
|
|
49
61
|
args: [{ providedIn: 'root' }]
|
|
50
62
|
}] });
|
|
51
|
-
//# sourceMappingURL=sqlite-service.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ng-desktop/desktop",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Linux GTK4 / Desktop OS system services (Theme, Clipboard, Notifications, Dialogs, SQLite, Network, Compute, FileSystem, DropTarget)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
"files": [
|
|
31
31
|
"fesm2022",
|
|
32
32
|
"README.md",
|
|
33
|
-
"LICENSE"
|
|
33
|
+
"LICENSE",
|
|
34
|
+
"!**/*.map"
|
|
34
35
|
],
|
|
35
36
|
"main": "./fesm2022/index.js",
|
|
36
37
|
"module": "./fesm2022/index.js",
|
|
@@ -46,6 +47,6 @@
|
|
|
46
47
|
},
|
|
47
48
|
"peerDependencies": {
|
|
48
49
|
"@angular/core": ">=22.0.0",
|
|
49
|
-
"@ng-desktop/platform": ">=0.
|
|
50
|
+
"@ng-desktop/platform": ">=0.4.0"
|
|
50
51
|
}
|
|
51
52
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"compute-service.d.ts","sourceRoot":"","sources":["../../../../packages/desktop-native/src/compute-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,KAAK,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;;AAErF,MAAM,WAAW,gBAAgB,CAAC,CAAC;IACjC,IAAI,EAAE,CAAC,CAAC;IACR,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,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,KAAK,CAAC,CAAC;QACnE,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACzB,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;YACpB,KAAK,EAAE,CAAC,CAAC,KAAK;YACd,KAAK,EAAE,CAAC,CAAC,KAAK;SACf,CAAC,CAAC,CAAC;IACN,CAAC;IAED,IAAI,CAAC,KAAa;QAChB,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;uGAxBU,oBAAoB;2GAApB,oBAAoB,cADP,MAAM;;2FACnB,oBAAoB;kBADhC,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE","sourcesContent":["import { Injectable } from '@angular/core';\nimport { ensureNgNativeBridge, type NativeComputeMatch } from '@ng-desktop/platform';\n\nexport interface NativeScoredItem<T> {\n item: T;\n index: number;\n score: number;\n}\n\n/**\n * Injectable Angular service delegating CPU-intensive fuzzy search, scoring, and FNV-1a hashing\n * to the multithreaded Rust `NativeComputePool` without blocking the UI thread.\n */\n@Injectable({ providedIn: 'root' })\nexport class NativeComputeService {\n private readonly bridge = ensureNgNativeBridge();\n\n fuzzyFilterStrings(items: readonly string[], query: string, limit = 50): NativeComputeMatch[] {\n return this.bridge.computeFuzzyFilter(items, query, limit);\n }\n\n fuzzyFilter<T>(\n items: readonly T[],\n selector: (item: T) => string,\n query: string,\n limit = 50,\n ): NativeScoredItem<T>[] {\n const keys = items.map((item) => selector(item));\n const matches = this.bridge.computeFuzzyFilter(keys, query, limit);\n return matches.map((m) => ({\n item: items[m.index],\n index: m.index,\n score: m.score,\n }));\n }\n\n hash(input: string): string {\n return this.bridge.computeHash(input);\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"desktop-service.d.ts","sourceRoot":"","sources":["../../../../packages/desktop-native/src/desktop-service.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,o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c,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC;IAC5E,CAAC;uGArCU,oBAAoB;2GAApB,oBAAoB,cADP,MAAM;;2FACnB,oBAAoB;kBADhC,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;AAyClC,MAAM,UAAU,oBAAoB;IAClC,OAAO,wBAAwB,CAAC;QAC9B,oBAAoB;QACpB,mBAAmB;QACnB,oBAAoB;QACpB,oBAAoB;QACpB,uBAAuB;KACxB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n EnvironmentProviders,\n Injectable,\n makeEnvironmentProviders,\n signal,\n WritableSignal,\n} from '@angular/core';\nimport { ensureNgNativeBridge } from '@ng-desktop/platform';\nimport { NativeComputeService } from './compute-service';\nimport { NativeFileSystemService } from './fs-service';\nimport { NativeNetworkService } from './network-service';\nimport { NativeSqliteService } from './sqlite-service';\n\nexport type NativeThemeMode = 'dark' | 'light';\n\nexport interface OpenFileDialogOptions {\n title?: string;\n defaultPath?: string;\n}\n\nexport interface SaveFileDialogOptions {\n title?: string;\n suggestedName?: string;\n}\n\n/**\n * Injectable Angular service providing reactive access to native Desktop OS capabilities:\n * - System Dark/Light theme (`theme` signal synchronized with `GtkSettings` / `AdwStyleManager`)\n * - Native Clipboard (`GdkClipboard`)\n * - Desktop Notifications (`GNotification`)\n * - Native File Dialogs (`GtkFileDialog` open/save)\n */\n@Injectable({ providedIn: 'root' })\nexport class NativeDesktopService {\n private readonly bridge = ensureNgNativeBridge();\n readonly theme: WritableSignal<NativeThemeMode>;\n\n constructor() {\n this.theme = signal<NativeThemeMode>(this.bridge.getSystemTheme());\n }\n\n setTheme(mode: NativeThemeMode): void {\n this.bridge.setSystemTheme(mode);\n this.theme.set(mode);\n }\n\n toggleTheme(): NativeThemeMode {\n const next: NativeThemeMode = this.theme() === 'dark' ? 'light' : 'dark';\n this.setTheme(next);\n return next;\n }\n\n getClipboardText(): string {\n return this.bridge.getClipboard();\n }\n\n setClipboardText(text: string): void {\n this.bridge.setClipboard(text);\n }\n\n notify(title: string, body: string, icon?: string): void {\n this.bridge.sendNotification(title, body, icon);\n }\n\n openFileDialog(options?: OpenFileDialogOptions): string {\n return this.bridge.openFileDialog(options?.title, options?.defaultPath);\n }\n\n saveFileDialog(options?: SaveFileDialogOptions): string {\n return this.bridge.saveFileDialog(options?.title, options?.suggestedName);\n }\n}\n\nexport function provideNativeDesktop(): EnvironmentProviders {\n return makeEnvironmentProviders([\n NativeDesktopService,\n NativeSqliteService,\n NativeNetworkService,\n NativeComputeService,\n NativeFileSystemService,\n ]);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"drop-target.directive.d.ts","sourceRoot":"","sources":["../../../../packages/desktop-native/src/drop-target.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiC,SAAS,EAAqB,MAAM,eAAe,CAAC;;AAE5F,MAAM,WAAW,qBAAqB;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB;AAED;;;;GAIG;AACH,qBAIa,yBAA0B,YAAW,SAAS;IACzD,QAAQ,CAAC,QAAQ,qDAAsB;IACvC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAa;;IAgBtC,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,EAAE;IAsB7C,WAAW,IAAI,IAAI;yCAxCR,yBAAyB;2CAAzB,yBAAyB;CA2CrC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"drop-target.directive.js","sourceRoot":"","sources":["../../../../packages/desktop-native/src/drop-target.directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAa,MAAM,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;;AAO5F;;;;GAIG;AAKH,MAAM,OAAO,yBAAyB;IAC3B,QAAQ,GAAG,MAAM,EAAY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,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YAChF,CAAC;YACD,IAAI,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;gBACtC,OAAO,OAAO,CAAC,KAAK;qBACjB,KAAK,CAAC,SAAS,CAAC;qBAChB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;qBACpB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YACjC,CAAC;QACH,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,WAAW;QACT,IAAI,CAAC,QAAQ,EAAE,CAAC;IAClB,CAAC;uGA1CU,yBAAyB;2FAAzB,yBAAyB;;2FAAzB,yBAAyB;kBAJrC,SAAS;mBAAC;oBACT,QAAQ,EAAE,sBAAsB;oBAChC,UAAU,EAAE,IAAI;iBACjB","sourcesContent":["import { Directive, ElementRef, inject, OnDestroy, output, Renderer2 } from '@angular/core';\n\nexport interface NativeFileDropPayload {\n value?: string;\n paths?: string[];\n}\n\n/**\n * Standalone directive (`[ngNativeDropTarget]`) that enables OS-native file drag-and-drop\n * (`GtkDropTarget` on Linux GTK4, `AllowDrop` on WinUI 3, `registerForDraggedTypes` on macOS AppKit)\n * and emits dropped file paths through `(fileDrop)`.\n */\n@Directive({\n selector: '[ngNativeDropTarget]',\n standalone: true,\n})\nexport class NativeDropTargetDirective implements OnDestroy {\n readonly fileDrop = output<string[]>();\n private readonly unlisten: () => void;\n\n constructor() {\n const renderer = inject(Renderer2);\n const elRef = inject<ElementRef<unknown>>(ElementRef);\n const nativeEl = elRef.nativeElement;\n\n renderer.setAttribute(nativeEl, 'drop-target', 'true');\n this.unlisten = renderer.listen(nativeEl, 'file-drop', (event?: unknown) => {\n const paths = NativeDropTargetDirective.extractPaths(event);\n if (paths.length > 0) {\n this.fileDrop.emit(paths);\n }\n });\n }\n\n static extractPaths(event: unknown): string[] {\n if (typeof event === 'string') {\n return event\n .split(/\\r?\\n|,/)\n .map((p) => p.trim())\n .filter((p) => p.length > 0);\n }\n if (event && typeof event === 'object') {\n const payload = event as NativeFileDropPayload;\n if (Array.isArray(payload.paths)) {\n return payload.paths.map((p) => String(p).trim()).filter((p) => p.length > 0);\n }\n if (typeof payload.value === 'string') {\n return payload.value\n .split(/\\r?\\n|,/)\n .map((p) => p.trim())\n .filter((p) => p.length > 0);\n }\n }\n return [];\n }\n\n ngOnDestroy(): void {\n this.unlisten();\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fs-service.d.ts","sourceRoot":"","sources":["../../../../packages/desktop-native/src/fs-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,MAAM,EAA0B,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAwB,KAAK,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;;AAEnF,MAAM,WAAW,oBAAoB,CAAC,CAAC;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IAC1B,MAAM,IAAI,IAAI,CAAC;CAChB;AAOD;;;GAGG;AACH,qBACa,uBAAuB;IAClC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0B;IACjD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAmC;IAElE,cAAc,CAAC,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM;IAI/D,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAIrC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO;IAQjD,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC;IAYzC,SAA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AI,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;gFAAC,CAAC;QACrE,MAAM,MAAM,GAAG,GAAS,EAAE;YACxB,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC;QACzC,CAAC,CAAC;QACF,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;QAChD,OAAO;YACL,IAAI;YACJ,KAAK,EAAE,GAAG,CAAC,UAAU,EAAE;YACvB,MAAM;SACP,CAAC;IACJ,CAAC;IAED,mBAAmB;QACjB,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,kBAAkB,EAAE,CAAC;QACjD,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;YAC3B,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;QAC1C,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;uGAzEU,uBAAuB;2GAAvB,uBAAuB,cADV,MAAM;;2FACnB,uBAAuB;kBADnC,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE","sourcesContent":["import { Injectable, Signal, signal, WritableSignal } from '@angular/core';\nimport { ensureNgNativeBridge, type NativeXdgDirKind } from '@ng-desktop/platform';\n\nexport interface NativeWatchedFileRef<T> {\n readonly path: string;\n readonly value: Signal<T>;\n reload(): void;\n}\n\ninterface WatchedEntry {\n path: string;\n reload: () => void;\n}\n\n/**\n * Injectable Angular service for XDG Base Directory resolution (`config`, `data`, `cache`),\n * atomic file writes, and reactive file watching backed by OS kernel notifications (`inotify` / `FSEvents` / `ReadDirectoryChangesW`).\n */\n@Injectable({ providedIn: 'root' })\nexport class NativeFileSystemService {\n private readonly bridge = ensureNgNativeBridge();\n private readonly watchedEntries = new Map<string, WatchedEntry>();\n\n resolveXdgPath(kind: NativeXdgDirKind, relPath: string): string {\n return this.bridge.fsResolvePath(kind, relPath);\n }\n\n readText(path: string): string | null {\n return this.bridge.fsReadText(path);\n }\n\n writeText(path: string, content: string): boolean {\n const ok = this.bridge.fsWriteText(path, content);\n if (ok) {\n this.refreshWatchedFiles();\n }\n return ok;\n }\n\n readJson<T>(path: string, fallback: T): T {\n const raw = this.readText(path);\n if (raw === null || raw.trim().length === 0) {\n return fallback;\n }\n try {\n return JSON.parse(raw) as T;\n } catch {\n return fallback;\n }\n }\n\n writeJson(path: string, data: unknown): boolean {\n return this.writeText(path, JSON.stringify(data, null, 2));\n }\n\n watchFile(path: string, initialContent = ''): NativeWatchedFileRef<string> {\n this.bridge.fsWatchFile(path);\n const sig: WritableSignal<string> = signal(this.readText(path) ?? initialContent);\n const reload = (): void => {\n const latest = this.readText(path);\n if (latest !== null) {\n sig.set(latest);\n }\n };\n this.watchedEntries.set(path, { path, reload });\n return {\n path,\n value: sig.asReadonly(),\n reload,\n };\n }\n\n watchJson<T>(path: string, fallback: T): NativeWatchedFileRef<T> {\n this.bridge.fsWatchFile(path);\n const sig: WritableSignal<T> = signal(this.readJson(path, fallback));\n const reload = (): void => {\n sig.set(this.readJson(path, fallback));\n };\n this.watchedEntries.set(path, { path, reload });\n return {\n path,\n value: sig.asReadonly(),\n reload,\n };\n }\n\n refreshWatchedFiles(): string[] {\n const changed = this.bridge.fsPollChangedFiles();\n for (const path of changed) {\n this.watchedEntries.get(path)?.reload();\n }\n return changed;\n }\n}\n"]}
|
package/fesm2022/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../packages/desktop-native/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,KAAK,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,GAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,yBAAyB,EAAE,KAAK,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChG,OAAO,EAAE,uBAAuB,EAAE,KAAK,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAClF,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAC"}
|
package/fesm2022/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/desktop-native/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAyB,MAAM,mBAAmB,CAAC;AAChF,OAAO,EACL,oBAAoB,EACpB,oBAAoB,GAIrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,yBAAyB,EAA8B,MAAM,yBAAyB,CAAC;AAChG,OAAO,EAAE,uBAAuB,EAA6B,MAAM,cAAc,CAAC;AAClF,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAA2B,MAAM,kBAAkB,CAAC","sourcesContent":["export { NativeComputeService, type NativeScoredItem } from './compute-service';\nexport {\n NativeDesktopService,\n provideNativeDesktop,\n type NativeThemeMode,\n type OpenFileDialogOptions,\n type SaveFileDialogOptions,\n} from './desktop-service';\nexport { NativeDropTargetDirective, type NativeFileDropPayload } from './drop-target.directive';\nexport { NativeFileSystemService, type NativeWatchedFileRef } from './fs-service';\nexport { NativeNetworkService } from './network-service';\nexport { NativeSqliteService, type NativeLiveQueryRef } from './sqlite-service';\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"network-service.d.ts","sourceRoot":"","sources":["../../../../packages/desktop-native/src/network-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,MAAM,EAAU,cAAc,EAAE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,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC;QAC/C,CAAC;yFAAC,CAAC;IACL,CAAC;IAED,OAAO;QACL,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC;QAC/C,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAClC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IAED,eAAe,CAAC,MAAe,EAAE,OAAO,GAAG,KAAK;QAC9C,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC9C,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC1B,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;uGA1BU,oBAAoB;2GAApB,oBAAoB,cADP,MAAM;;2FACnB,oBAAoB;kBADhC,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE","sourcesContent":["import { computed, Injectable, Signal, signal, WritableSignal } from '@angular/core';\nimport { ensureNgNativeBridge, NativeConnectivity } from '@ng-desktop/platform';\n\n/**\n * Reactive OS Network Monitor backed by `GNetworkMonitor` (Linux GIO), `NWPathMonitor` (macOS),\n * or `NetworkInformation` (Windows), exposing Signal-based online/metered state.\n */\n@Injectable({ providedIn: 'root' })\nexport class NativeNetworkService {\n private readonly bridge = ensureNgNativeBridge();\n readonly isOnline: WritableSignal<boolean>;\n readonly isMetered: WritableSignal<boolean>;\n readonly connectivity: Signal<NativeConnectivity>;\n\n constructor() {\n const initial = this.bridge.getNetworkStatus();\n this.isOnline = signal<boolean>(initial.online);\n this.isMetered = signal<boolean>(initial.metered);\n this.connectivity = computed<NativeConnectivity>(() => {\n if (!this.isOnline()) return 'offline';\n return this.isMetered() ? 'limited' : 'full';\n });\n }\n\n refresh(): void {\n const current = this.bridge.getNetworkStatus();\n this.isOnline.set(current.online);\n this.isMetered.set(current.metered);\n }\n\n setOnlineStatus(online: boolean, metered = false): void {\n this.bridge.setNetworkStatus(online, metered);\n this.isOnline.set(online);\n this.isMetered.set(metered);\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sqlite-service.d.ts","sourceRoot":"","sources":["../../../../packages/desktop-native/src/sqlite-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,MAAM,EAAU,MAAM,eAAe,CAAC;;AAGrE,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC/B,OAAO,IAAI,CAAC,EAAE,CAAC;CAChB;AAED;;;GAGG;AACH,qBACa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA0B;IACjD,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAA4B;IAEhE,QAAQ,CAAC,eAAe,iDAAa;IAErC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAW7B,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;IAKhG,SAAS,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAClC,OAAO,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,EAChC,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,GAC1C,kBAAkB,CAAC,CAAC,CAAC;yCAzBb,mB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U,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;YAChE,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;YACrC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACrB,OAAO,IAAI,CAAC;QACd,CAAC,CAAC;QAEF,OAAO,EAAE,CAAC;QACV,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAEtC,OAAO;YACL,IAAI,EAAE,UAAU,CAAC,UAAU,EAAE;YAC7B,KAAK,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC,UAAU,EAAE,CAAC,MAAM,CAAC;YAC1C,OAAO;SACR,CAAC;IACJ,CAAC;uGA1CU,mBAAmB;2GAAnB,mBAAmB,cADN,MAAM;;2FACnB,mBAAmB;kBAD/B,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE","sourcesContent":["import { computed, Injectable, Signal, signal } from '@angular/core';\nimport { ensureNgNativeBridge } from '@ng-desktop/platform';\n\nexport interface NativeLiveQueryRef<T> {\n readonly rows: Signal<T[]>;\n readonly count: Signal<number>;\n refresh(): T[];\n}\n\n/**\n * Reactive native SQLite service backed by Rust `libsqlite3.so.0` FFI (`NativeSqliteDatabase`)\n * with Signal-based `liveQuery()` subscriptions that refresh automatically after mutations.\n */\n@Injectable({ providedIn: 'root' })\nexport class NativeSqliteService {\n private readonly bridge = ensureNgNativeBridge();\n private readonly liveQueryRefreshers = new Set<() => unknown>();\n\n readonly mutationVersion = signal(0);\n\n execute(sql: string): boolean {\n const ok = this.bridge.sqliteExecute(sql);\n if (ok) {\n this.mutationVersion.update((v) => v + 1);\n for (const refresh of this.liveQueryRefreshers) {\n refresh();\n }\n }\n return ok;\n }\n\n query<T = Record<string, string>>(sql: string, mapRow?: (row: Record<string, string>) => T): T[] {\n const rawRows = this.bridge.sqliteQuery(sql);\n return mapRow ? rawRows.map(mapRow) : (rawRows as unknown as T[]);\n }\n\n liveQuery<T = Record<string, string>>(\n sqlOrFn: string | (() => string),\n mapRow?: (row: Record<string, string>) => T,\n ): NativeLiveQueryRef<T> {\n const rowsSignal = signal<T[]>([]);\n const refresh = (): T[] => {\n const sql = typeof sqlOrFn === 'function' ? sqlOrFn() : sqlOrFn;\n const next = this.query(sql, mapRow);\n rowsSignal.set(next);\n return next;\n };\n\n refresh();\n this.liveQueryRefreshers.add(refresh);\n\n return {\n rows: rowsSignal.asReadonly(),\n count: computed(() => rowsSignal().length),\n refresh,\n };\n }\n}\n"]}
|