@ng-desktop/platform 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.
Files changed (56) hide show
  1. package/README.md +43 -7
  2. package/fesm2022/bridge-fs-compute.d.ts +1 -1
  3. package/fesm2022/bridge-fs-compute.js +5 -2
  4. package/fesm2022/bridge-sqlite.d.ts +0 -1
  5. package/fesm2022/bridge-sqlite.js +2 -12
  6. package/fesm2022/bridge.d.ts +62 -2
  7. package/fesm2022/bridge.js +406 -219
  8. package/fesm2022/css-style-parser.d.ts +33 -0
  9. package/fesm2022/css-style-parser.js +259 -0
  10. package/fesm2022/ecosystem-compat.d.ts +0 -1
  11. package/fesm2022/ecosystem-compat.js +9 -10
  12. package/fesm2022/image-loader.d.ts +1 -2
  13. package/fesm2022/image-loader.js +1 -2
  14. package/fesm2022/index.d.ts +5 -3
  15. package/fesm2022/index.js +4 -2
  16. package/fesm2022/native-directives.d.ts +188 -0
  17. package/fesm2022/native-directives.js +742 -0
  18. package/fesm2022/native-element.d.ts +7 -2
  19. package/fesm2022/native-element.js +21 -2
  20. package/fesm2022/native-renderer.d.ts +44 -3
  21. package/fesm2022/native-renderer.js +951 -44
  22. package/fesm2022/native-title.d.ts +1 -1
  23. package/fesm2022/native-title.js +17 -5
  24. package/fesm2022/platform.d.ts +2 -2
  25. package/fesm2022/platform.js +8 -2
  26. package/fesm2022/system-providers.d.ts +2 -1
  27. package/fesm2022/system-providers.js +63 -13
  28. package/fesm2022/viewport-scroller.d.ts +2 -1
  29. package/fesm2022/viewport-scroller.js +19 -7
  30. package/fesm2022/virtual-list.component.d.ts +57 -0
  31. package/fesm2022/virtual-list.component.js +200 -0
  32. package/package.json +4 -2
  33. package/fesm2022/bridge-fs-compute.d.ts.map +0 -1
  34. package/fesm2022/bridge-fs-compute.js.map +0 -1
  35. package/fesm2022/bridge-sqlite.d.ts.map +0 -1
  36. package/fesm2022/bridge-sqlite.js.map +0 -1
  37. package/fesm2022/bridge.d.ts.map +0 -1
  38. package/fesm2022/bridge.js.map +0 -1
  39. package/fesm2022/ecosystem-compat.d.ts.map +0 -1
  40. package/fesm2022/ecosystem-compat.js.map +0 -1
  41. package/fesm2022/image-loader.d.ts.map +0 -1
  42. package/fesm2022/image-loader.js.map +0 -1
  43. package/fesm2022/index.d.ts.map +0 -1
  44. package/fesm2022/index.js.map +0 -1
  45. package/fesm2022/native-element.d.ts.map +0 -1
  46. package/fesm2022/native-element.js.map +0 -1
  47. package/fesm2022/native-renderer.d.ts.map +0 -1
  48. package/fesm2022/native-renderer.js.map +0 -1
  49. package/fesm2022/native-title.d.ts.map +0 -1
  50. package/fesm2022/native-title.js.map +0 -1
  51. package/fesm2022/platform.d.ts.map +0 -1
  52. package/fesm2022/platform.js.map +0 -1
  53. package/fesm2022/system-providers.d.ts.map +0 -1
  54. package/fesm2022/system-providers.js.map +0 -1
  55. package/fesm2022/viewport-scroller.d.ts.map +0 -1
  56. package/fesm2022/viewport-scroller.js.map +0 -1
package/README.md CHANGED
@@ -1,14 +1,50 @@
1
- # @ng-desktop/platform
1
+ # `@ng-desktop/platform`
2
2
 
3
- @ng-desktop/platform for Angular Desktop Engine
3
+ Custom Zoneless Angular `Renderer2` platform, typed native widget directives (`NATIVE_UI_DIRECTIVES`), CSS Flexbox/Grid projector, virtualized list (`<ng-virtual-list>`), and headless ecosystem compatibility bridges (`NgRx`, `Angular Aria`, `CDK`).
4
4
 
5
- Part of **[NgDesktop Engine](https://github.com/Gaspar1992/ng-desktop-engine)** — Native desktop rendering engine for Angular 22+ (`GTK4`, `WinUI 3`, `AppKit`).
6
-
7
- ## Installation
5
+ ## Install
8
6
 
9
7
  ```bash
10
8
  pnpm add @ng-desktop/platform
11
9
  ```
12
10
 
13
- - Repository path: `packages/platform-native`
14
- - Documentation & Ecosystem Guide: https://github.com/Gaspar1992/ng-desktop-engine/blob/main/docs/ECOSYSTEM_COMPATIBILITY.md
11
+ Peer dependency: `@angular/core >= 22.0.0`.
12
+
13
+ ## Quick Usage
14
+
15
+ ```ts
16
+ import { Component, signal } from '@angular/core';
17
+ import { bootstrapNativeApplication, NATIVE_UI_DIRECTIVES } from '@ng-desktop/platform';
18
+
19
+ @Component({
20
+ selector: 'app-root',
21
+ standalone: true,
22
+ imports: [NATIVE_UI_DIRECTIVES],
23
+ template: `
24
+ <ng-window id="win" title="Desktop App">
25
+ <ng-box orientation="vertical" spacing="12px">
26
+ <ng-label [text]="'Count: ' + count()" />
27
+ <ng-button (click)="count.update((n) => n + 1)">Increment</ng-button>
28
+ </ng-box>
29
+ </ng-window>
30
+ `,
31
+ })
32
+ export class AppComponent {
33
+ readonly count = signal(0);
34
+ }
35
+
36
+ bootstrapNativeApplication(AppComponent);
37
+ ```
38
+
39
+ ## Key Exports
40
+
41
+ - **Bootstrap & Platform:** `bootstrapNativeApplication`, `provideNativePlatform`, `NativeRendererFactory2`, `NativeRenderer2`
42
+ - **No-Schema Directives & Virtual List:** `NATIVE_UI_DIRECTIVES`, `HTML_TO_NATIVE_TAG`, `NativeVirtualListComponent`, `computeVirtualSliceRange`
43
+ - **Styles & System:** `parseRuntimeStyles`, `formatParsedStyleExtensions`, `provideNativeImageLoader`, `provideNativeTitle`, `provideSystemLocale`
44
+ - **Ecosystem Compat:** `provideNativeEcosystemCompat`, `NativeStorage`, `NativeAriaAnnouncer`, `NativeDevToolsHook`, `createNativeDocument`
45
+
46
+ ## Documentation
47
+
48
+ - [Getting Started with External Angular 22+ & Nx Apps](../../docs/GETTING_STARTED.md)
49
+ - [Ecosystem Compatibility Guide](../../docs/ECOSYSTEM_COMPATIBILITY.md)
50
+ - [Architectural Roadmap & OS Maturity Matrix](../../ROADMAP.md)
@@ -1,4 +1,5 @@
1
1
  export type NativeXdgDirKind = 'config' | 'data' | 'cache';
2
+ export declare function resolveDefaultAppId(): string;
2
3
  export interface NativeComputeMatch {
3
4
  index: number;
4
5
  score: number;
@@ -16,4 +17,3 @@ export declare class InMemoryFsStore {
16
17
  watchFile(path: string): boolean;
17
18
  pollChangedFiles(): string[];
18
19
  }
19
- //# sourceMappingURL=bridge-fs-compute.d.ts.map
@@ -1,3 +1,7 @@
1
+ export function resolveDefaultAppId() {
2
+ const raw = globalThis.__NG_NATIVE_APP_ID__;
3
+ return typeof raw === 'string' && raw.trim().length > 0 ? raw.trim() : 'ng-desktop-app';
4
+ }
1
5
  function scoreCandidate(candidate, needleLower) {
2
6
  if (needleLower.length === 0) {
3
7
  return 1;
@@ -61,7 +65,7 @@ export class InMemoryFsStore {
61
65
  files = new Map();
62
66
  watched = new Set();
63
67
  changed = new Set();
64
- resolvePath(kind, relPath, appId = 'ng-linux-counter') {
68
+ resolvePath(kind, relPath, appId = resolveDefaultAppId()) {
65
69
  const clean = relPath.trim().replace(/^[/\\]+/, '');
66
70
  if (clean.length === 0 || clean.split(/[/\\]/).includes('..')) {
67
71
  throw new Error(`Invalid or unsafe XDG relative path: '${relPath}'`);
@@ -101,4 +105,3 @@ export class InMemoryFsStore {
101
105
  return out;
102
106
  }
103
107
  }
104
- //# sourceMappingURL=bridge-fs-compute.js.map
@@ -9,4 +9,3 @@ export declare class InMemorySqliteStore {
9
9
  private executeSingle;
10
10
  }
11
11
  export declare function resolveNativeImageAsset(src: string, width?: number, cacheDir?: string): string;
12
- //# sourceMappingURL=bridge-sqlite.d.ts.map
@@ -1,3 +1,4 @@
1
+ import { resolveDefaultAppId } from './bridge-fs-compute.js';
1
2
  function splitSqlValues(input) {
2
3
  const parts = [];
3
4
  let current = '';
@@ -226,18 +227,8 @@ function fnv1aHex(input) {
226
227
  }
227
228
  return hash.toString(16).padStart(8, '0');
228
229
  }
229
- export function resolveNativeImageAsset(src, width, cacheDir = '/tmp/ng_native_cache') {
230
+ export function resolveNativeImageAsset(src, width, cacheDir = `/home/user/.cache/${resolveDefaultAppId()}/images`) {
230
231
  const trimmed = src.trim();
231
- const artworkIdx = trimmed.indexOf('/official-artwork/');
232
- if (artworkIdx !== -1) {
233
- const filePart = trimmed.slice(artworkIdx + '/official-artwork/'.length).split('?')[0];
234
- if (filePart.endsWith('.png')) {
235
- const stem = filePart.slice(0, -4);
236
- if (/^\d+$/.test(stem)) {
237
- return `/tmp/ng_native_pokedex/${stem}.png`;
238
- }
239
- }
240
- }
241
232
  if (trimmed.startsWith('http://') || trimmed.startsWith('https://')) {
242
233
  const clean = trimmed.split('?')[0].toLowerCase();
243
234
  const extMatch = clean.match(/\.(png|jpg|jpeg|webp|svg|ico)$/);
@@ -247,4 +238,3 @@ export function resolveNativeImageAsset(src, width, cacheDir = '/tmp/ng_native_c
247
238
  }
248
239
  return trimmed;
249
240
  }
250
- //# sourceMappingURL=bridge-sqlite.js.map
@@ -36,12 +36,42 @@ export interface NativeHttpBridgeResponse {
36
36
  callKind?: NativeHttpCallKind;
37
37
  cached?: boolean;
38
38
  }
39
+ export interface NativeWindowGeometry {
40
+ width: number;
41
+ height: number;
42
+ x?: number | null;
43
+ y?: number | null;
44
+ maximized: boolean;
45
+ }
46
+ export interface NativeMenuItem {
47
+ id: string;
48
+ label: string;
49
+ accelerator?: string | null;
50
+ enabled?: boolean;
51
+ }
52
+ export interface NativeTrayState {
53
+ visible: boolean;
54
+ icon: string;
55
+ tooltip: string;
56
+ menuItems?: readonly NativeMenuItem[];
57
+ }
58
+ export interface NativeShortcutBinding {
59
+ accelerator: string;
60
+ actionId: string;
61
+ }
62
+ export interface NativeConfirmDialogOptions {
63
+ title?: string;
64
+ message?: string;
65
+ confirmLabel?: string;
66
+ cancelLabel?: string;
67
+ defaultConfirmed?: boolean;
68
+ }
39
69
  /**
40
70
  * Host FFI bridge contract injected at `globalThis.__NG_NATIVE__` by the Rust `JsEngineBackend`
41
71
  * (`JscEngine` or `QuickJsEngine`).
42
72
  */
43
73
  export interface NgNativeBridge {
44
- registerStyle(cls: string, bg?: string, fg?: string, pad?: number, space?: number): void;
74
+ registerStyle(cls: string, bg?: string, fg?: string, pad?: number, space?: number, extras?: string): void;
45
75
  declareSignal(name: string, initial?: number): void;
46
76
  createElement(id: string, tag: string): string;
47
77
  createComment(id: string, text?: string): string;
@@ -52,6 +82,7 @@ export interface NgNativeBridge {
52
82
  insertBefore(parent: string, child: string, refChild?: string): void;
53
83
  removeChild(parent: string, child: string): void;
54
84
  addClass(id: string, className: string): void;
85
+ removeClass(id: string, className: string): void;
55
86
  bindText(id: string, signalName: string, template: string): void;
56
87
  bindAttr(id: string, attrKey: string, signalName: string, template?: string): void;
57
88
  bindVisible(id: string, signalName: string, op?: string, rhs?: number): void;
@@ -66,6 +97,8 @@ export interface NgNativeBridge {
66
97
  sendNotification(title: string, body: string, icon?: string): void;
67
98
  openFileDialog(title?: string, defaultPath?: string): string;
68
99
  saveFileDialog(title?: string, suggestedName?: string): string;
100
+ confirmDialog?(options?: NativeConfirmDialogOptions): boolean;
101
+ setNextConfirmDialogResponse?(confirmed: boolean): void;
69
102
  configureHttp(config: NativeHttpConfig): NativeHttpConfig;
70
103
  getHttpConfig(): NativeHttpConfig;
71
104
  registerHttpEndpoint(method: string, url: string, status: number, body: string): void;
@@ -76,6 +109,19 @@ export interface NgNativeBridge {
76
109
  body?: string;
77
110
  options?: NativeHttpRequestOptions;
78
111
  }>): NativeHttpBridgeResponse[];
112
+ httpRequestAsync?(method: string, url: string, body?: string, options?: NativeHttpRequestOptions): Promise<NativeHttpBridgeResponse>;
113
+ httpBatchRequestAsync?(requests: Array<{
114
+ method: string;
115
+ url: string;
116
+ body?: string;
117
+ options?: NativeHttpRequestOptions;
118
+ }>): Promise<NativeHttpBridgeResponse[]>;
119
+ downloadImageAsync?(url: string, width?: number): Promise<{
120
+ ok: boolean;
121
+ cached?: boolean;
122
+ path: string;
123
+ error?: string;
124
+ }>;
79
125
  sqliteExecute(sql: string): boolean;
80
126
  sqliteQuery(sql: string): Array<Record<string, string>>;
81
127
  getNetworkStatus(): NativeNetworkStatus;
@@ -92,8 +138,23 @@ export interface NgNativeBridge {
92
138
  fsWriteText(path: string, content: string): boolean;
93
139
  fsWatchFile(path: string): boolean;
94
140
  fsPollChangedFiles(): string[];
141
+ getWindowGeometry?(): NativeWindowGeometry;
142
+ setWindowGeometry?(geometry: Partial<NativeWindowGeometry>): NativeWindowGeometry;
143
+ getAppMenu?(): NativeMenuItem[];
144
+ setAppMenu?(items: readonly NativeMenuItem[]): NativeMenuItem[];
145
+ getTrayState?(): NativeTrayState;
146
+ setTrayState?(state: Partial<NativeTrayState>): NativeTrayState;
147
+ registerShortcut?(accelerator: string, actionId: string): NativeShortcutBinding[];
148
+ unregisterShortcut?(accelerator: string): NativeShortcutBinding[];
149
+ getRegisteredShortcuts?(): NativeShortcutBinding[];
95
150
  __dispatchEvent(id: string, eventName: string, eventPayload?: unknown): void;
151
+ __dispatchAndDrain?(id: string, eventName: string, eventPayload?: unknown): string;
96
152
  __flushTimers(): void;
153
+ __tickTimers?(nowMs?: number): void;
154
+ __tickAndDrain?(nowMs?: number, completions?: Array<[number, unknown]>): string;
155
+ __resolveHostCallback?(id: number, payload: unknown): void;
156
+ beginBatch?(): void;
157
+ endBatch?(): void;
97
158
  __drainQueue(): string;
98
159
  }
99
160
  declare global {
@@ -105,4 +166,3 @@ declare global {
105
166
  * in Node/Vitest unit tests, this provides an identical in-memory command queue.
106
167
  */
107
168
  export declare function ensureNgNativeBridge(): NgNativeBridge;
108
- //# sourceMappingURL=bridge.d.ts.map