@ng-desktop/platform 0.0.0-stage → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,259 @@
1
+ const RUNTIME_STYLE_EXTENSIONS = [
2
+ ['borderRadius', 'radius'],
3
+ ['fontSize', 'font-size'],
4
+ ['fontWeight', 'font-weight'],
5
+ ['minWidth', 'min-width'],
6
+ ['minHeight', 'min-height'],
7
+ ['orientation', 'orientation'],
8
+ ['hexpand', 'hexpand'],
9
+ ['vexpand', 'vexpand'],
10
+ ['halign', 'halign'],
11
+ ['valign', 'valign'],
12
+ ['minChildren', 'min-children'],
13
+ ['maxChildren', 'max-children'],
14
+ ['homogeneous', 'homogeneous'],
15
+ ];
16
+ export function parsePixelInt(raw) {
17
+ const parsed = Number.parseInt(raw.trim().replace(/px$/, ''), 10);
18
+ return Number.isFinite(parsed) && parsed >= 0 ? parsed : null;
19
+ }
20
+ export function mapAlignKeyword(raw) {
21
+ switch (raw.trim().toLowerCase()) {
22
+ case 'center':
23
+ return 'center';
24
+ case 'flex-start':
25
+ case 'start':
26
+ return 'start';
27
+ case 'flex-end':
28
+ case 'end':
29
+ return 'end';
30
+ case 'stretch':
31
+ case 'fill':
32
+ return 'fill';
33
+ case 'baseline':
34
+ return 'baseline';
35
+ default:
36
+ return null;
37
+ }
38
+ }
39
+ function applyRuntimeGridColumns(rule, val) {
40
+ const match = val
41
+ .trim()
42
+ .match(/repeat\(\s*(auto-fit|auto-fill|\d+)\s*,\s*(?:minmax\(\s*(\d+)px\s*,[^)]+\)|[^)]+)\)/i);
43
+ if (!match)
44
+ return;
45
+ const track = match[1].toLowerCase();
46
+ if (track === 'auto-fit' || track === 'auto-fill') {
47
+ rule.minChildren = 1;
48
+ rule.maxChildren = 12;
49
+ }
50
+ else {
51
+ const cols = Number.parseInt(track, 10);
52
+ if (!Number.isFinite(cols) || cols < 1)
53
+ return;
54
+ rule.minChildren = cols;
55
+ rule.maxChildren = cols;
56
+ }
57
+ rule.homogeneous = true;
58
+ rule.hexpand = true;
59
+ if (match[2] && rule.minWidth === null) {
60
+ rule.minWidth = Number.parseInt(match[2], 10);
61
+ }
62
+ }
63
+ function applyRuntimeLayoutDeclaration(rule, prop, val) {
64
+ const lower = val.trim().toLowerCase();
65
+ if (prop === 'flex-direction') {
66
+ if (lower.startsWith('row'))
67
+ rule.orientation = 'horizontal';
68
+ else if (lower.startsWith('column'))
69
+ rule.orientation = 'vertical';
70
+ }
71
+ else if (prop === 'flex-wrap' && lower.startsWith('wrap')) {
72
+ rule.minChildren ??= 1;
73
+ rule.maxChildren ??= 12;
74
+ rule.homogeneous = true;
75
+ rule.hexpand = true;
76
+ }
77
+ else if (prop === 'flex' || prop === 'flex-grow') {
78
+ const grow = Number.parseFloat(lower);
79
+ if (Number.isFinite(grow) && grow >= 1)
80
+ rule.hexpand = true;
81
+ if (prop === 'flex') {
82
+ const basisMatch = lower.match(/(\d+)px/);
83
+ if (basisMatch && rule.minWidth === null) {
84
+ rule.minWidth = Number.parseInt(basisMatch[1], 10);
85
+ }
86
+ }
87
+ }
88
+ else if (prop === 'width') {
89
+ if (lower === '100%')
90
+ rule.hexpand = true;
91
+ else {
92
+ const px = parsePixelInt(val);
93
+ if (px !== null && rule.minWidth === null)
94
+ rule.minWidth = px;
95
+ }
96
+ }
97
+ else if (prop === 'height') {
98
+ if (lower === '100%')
99
+ rule.vexpand = true;
100
+ else {
101
+ const px = parsePixelInt(val);
102
+ if (px !== null && rule.minHeight === null)
103
+ rule.minHeight = px;
104
+ }
105
+ }
106
+ else if (prop === 'grid-template-columns') {
107
+ applyRuntimeGridColumns(rule, val);
108
+ }
109
+ else if (prop === 'justify-self') {
110
+ const aligned = mapAlignKeyword(val);
111
+ if (aligned)
112
+ rule.halign = aligned;
113
+ }
114
+ else if (prop === 'align-self') {
115
+ const aligned = mapAlignKeyword(val);
116
+ if (aligned)
117
+ rule.valign = aligned;
118
+ }
119
+ else if (prop === 'justify-content') {
120
+ const aligned = mapAlignKeyword(val);
121
+ if (!rule.hexpand && aligned && rule.halign === null)
122
+ rule.halign = aligned;
123
+ }
124
+ else if (prop === 'align-items') {
125
+ const aligned = mapAlignKeyword(val);
126
+ if (!rule.vexpand && aligned && rule.valign === null)
127
+ rule.valign = aligned;
128
+ }
129
+ }
130
+ /**
131
+ * Parses component CSS rules at runtime into `ParsedStyleRule` descriptors compatible with
132
+ * the Rust engine's CSS Flexbox/Grid and typography/radius extension syntax.
133
+ */
134
+ export function parseRuntimeStyles(cssSource) {
135
+ const cleaned = cssSource
136
+ .replace(/\/\*[\s\S]*?\*\//g, '')
137
+ .replace(/\[_ng(?:content|host)-[^\]]+\]/g, '');
138
+ const rulesByClass = new Map();
139
+ const blockRe = /([^{}@]+)\{([^{}]*)\}/g;
140
+ for (const match of cleaned.matchAll(blockRe)) {
141
+ const selectorList = match[1];
142
+ const body = match[2];
143
+ const declarations = body.split(';');
144
+ for (const rawSelector of selectorList.split(',')) {
145
+ const clsMatch = rawSelector.trim().match(/^\.([a-zA-Z0-9_-]+)$/);
146
+ if (!clsMatch) {
147
+ continue;
148
+ }
149
+ const className = clsMatch[1];
150
+ const rule = rulesByClass.get(className) ?? {
151
+ className,
152
+ background: 'none',
153
+ color: 'none',
154
+ padding: 0,
155
+ spacing: 0,
156
+ borderRadius: null,
157
+ fontSize: null,
158
+ fontWeight: null,
159
+ minWidth: null,
160
+ minHeight: null,
161
+ orientation: null,
162
+ hexpand: null,
163
+ vexpand: null,
164
+ halign: null,
165
+ valign: null,
166
+ minChildren: null,
167
+ maxChildren: null,
168
+ homogeneous: null,
169
+ };
170
+ for (const decl of declarations) {
171
+ const colon = decl.indexOf(':');
172
+ if (colon === -1) {
173
+ continue;
174
+ }
175
+ const prop = decl.slice(0, colon).trim().toLowerCase();
176
+ const val = decl.slice(colon + 1).trim();
177
+ if (!val) {
178
+ continue;
179
+ }
180
+ if (prop === 'background' || prop === 'background-color') {
181
+ rule.background = val;
182
+ }
183
+ else if (prop === 'color') {
184
+ rule.color = val;
185
+ }
186
+ else if (prop === 'padding') {
187
+ const px = parsePixelInt(val);
188
+ if (px !== null)
189
+ rule.padding = px;
190
+ }
191
+ else if (prop === 'gap' || prop === 'spacing') {
192
+ const px = parsePixelInt(val);
193
+ if (px !== null)
194
+ rule.spacing = px;
195
+ }
196
+ else if (prop === 'row-gap' || prop === 'column-gap') {
197
+ if (rule.spacing === 0) {
198
+ const px = parsePixelInt(val);
199
+ if (px !== null)
200
+ rule.spacing = px;
201
+ }
202
+ }
203
+ else if (prop === 'border-radius') {
204
+ const px = parsePixelInt(val);
205
+ if (px !== null)
206
+ rule.borderRadius = px;
207
+ }
208
+ else if (prop === 'font-size') {
209
+ const px = parsePixelInt(val);
210
+ if (px !== null)
211
+ rule.fontSize = px;
212
+ }
213
+ else if (prop === 'font-weight') {
214
+ const kw = val === 'bold' ? 700 : val === 'normal' ? 400 : parsePixelInt(val);
215
+ if (kw !== null)
216
+ rule.fontWeight = kw;
217
+ }
218
+ else if (prop === 'min-width') {
219
+ const px = parsePixelInt(val);
220
+ if (px !== null)
221
+ rule.minWidth = px;
222
+ }
223
+ else if (prop === 'min-height') {
224
+ const px = parsePixelInt(val);
225
+ if (px !== null)
226
+ rule.minHeight = px;
227
+ }
228
+ else {
229
+ applyRuntimeLayoutDeclaration(rule, prop, val);
230
+ }
231
+ }
232
+ rulesByClass.set(className, rule);
233
+ }
234
+ }
235
+ return [...rulesByClass.values()];
236
+ }
237
+ /**
238
+ * Formats optional `ParsedStyleRule` layout/typography fields as space-separated `key=value` tokens.
239
+ */
240
+ export function formatParsedStyleExtensions(rule) {
241
+ const extensions = [];
242
+ for (const [prop, key] of RUNTIME_STYLE_EXTENSIONS) {
243
+ const value = rule[prop];
244
+ if (value !== null && value !== undefined) {
245
+ extensions.push(`${key}=${value}`);
246
+ }
247
+ }
248
+ return extensions.join(' ');
249
+ }
250
+ export function registerParsedStyles(bridge, styles) {
251
+ for (const css of styles) {
252
+ if (typeof css !== 'string' || css.trim().length === 0) {
253
+ continue;
254
+ }
255
+ for (const rule of parseRuntimeStyles(css)) {
256
+ bridge.registerStyle(rule.className, rule.background, rule.color, rule.padding, rule.spacing, formatParsedStyleExtensions(rule));
257
+ }
258
+ }
259
+ }
@@ -0,0 +1,98 @@
1
+ import { EnvironmentProviders, InjectionToken } from '@angular/core';
2
+ import { NgNativeBridge } from './bridge';
3
+ import { NativeElementNode, NativeEventListener } from './native-element';
4
+ import * as i0 from "@angular/core";
5
+ export type AriaPoliteness = 'off' | 'polite' | 'assertive';
6
+ export interface NativeAriaAnnouncement {
7
+ readonly message: string;
8
+ readonly politeness: AriaPoliteness;
9
+ }
10
+ export interface NativeDevToolsRecord {
11
+ readonly action: unknown;
12
+ readonly state: unknown;
13
+ }
14
+ export interface NativeDevToolsConnection {
15
+ init(state: unknown): void;
16
+ send(action: unknown, state: unknown): void;
17
+ subscribe(listener: (message: unknown) => void): () => void;
18
+ unsubscribe(): void;
19
+ }
20
+ export interface NativeDocumentFacade {
21
+ readonly activeElement: NativeElementNode | null;
22
+ readonly body: NativeElementNode;
23
+ createElement(tag: string): NativeElementNode;
24
+ createComment(text?: string): NativeElementNode;
25
+ createTextNode(text: string): NativeElementNode;
26
+ getElementById(id: string): NativeElementNode | null;
27
+ querySelector(selector: string): NativeElementNode | null;
28
+ addEventListener(type: string, listener: NativeEventListener): void;
29
+ removeEventListener(type: string, listener: NativeEventListener): void;
30
+ }
31
+ export interface NativeEcosystemCompatOptions {
32
+ /** Install `NativeStorage` onto `globalThis.localStorage` when absent. Defaults to `true`. */
33
+ installGlobalStorage?: boolean;
34
+ /** Install `NativeDevToolsHook` onto `globalThis.__REDUX_DEVTOOLS_EXTENSION__`. Defaults to `true`. */
35
+ installDevToolsExtension?: boolean;
36
+ }
37
+ export declare const NATIVE_BRIDGE: InjectionToken<NgNativeBridge>;
38
+ /**
39
+ * Web `Storage`-compatible persistence adapter backed by the native SQLite engine (`ng_native_storage`)
40
+ * and an in-memory map, enabling `@ngrx/store` meta-reducers and state hydration without a browser DOM.
41
+ */
42
+ export declare class NativeStorage implements Storage {
43
+ private readonly store;
44
+ private readonly bridge;
45
+ private nextId;
46
+ constructor(bridge?: NgNativeBridge | null);
47
+ private ensureTable;
48
+ get length(): number;
49
+ key(index: number): string | null;
50
+ getItem(key: string): string | null;
51
+ setItem(key: string, value: string): void;
52
+ removeItem(key: string): void;
53
+ clear(): void;
54
+ static ɵfac: i0.ɵɵFactoryDeclaration<NativeStorage, [{ optional: true; }]>;
55
+ static ɵprov: i0.ɵɵInjectableDeclaration<any>;
56
+ }
57
+ /**
58
+ * Headless `@angular/cdk/a11y` `LiveAnnouncer`-compatible service for `@angular/aria` and native
59
+ * GTK4/WinUI/AppKit accessibility announcements.
60
+ */
61
+ export declare class NativeAriaAnnouncer {
62
+ private readonly announcements;
63
+ private readonly bridge;
64
+ constructor(bridge?: NgNativeBridge | null);
65
+ announce(message: string, politeness?: AriaPoliteness): Promise<void>;
66
+ clear(): void;
67
+ history(): readonly NativeAriaAnnouncement[];
68
+ static ɵfac: i0.ɵɵFactoryDeclaration<NativeAriaAnnouncer, [{ optional: true; }]>;
69
+ static ɵprov: i0.ɵɵInjectableDeclaration<any>;
70
+ }
71
+ /**
72
+ * Redux DevTools (`__REDUX_DEVTOOLS_EXTENSION__`) bridge allowing `@ngrx/store-devtools`
73
+ * to attach cleanly inside JavaScriptCore / QuickJS without browser extensions.
74
+ */
75
+ export declare class NativeDevToolsHook {
76
+ private readonly records;
77
+ private readonly subscribers;
78
+ private latestState;
79
+ connect(): NativeDevToolsConnection;
80
+ history(): readonly NativeDevToolsRecord[];
81
+ currentState(): unknown;
82
+ static ɵfac: i0.ɵɵFactoryDeclaration<NativeDevToolsHook, never>;
83
+ static ɵprov: i0.ɵɵInjectableDeclaration<any>;
84
+ }
85
+ /**
86
+ * Creates a lightweight headless `Document` facade backed by `NativeElementNode` for
87
+ * `@angular/cdk`, `@angular/aria`, and DOM-agnostic UI primitives.
88
+ */
89
+ export declare function createNativeDocument(root?: NativeElementNode): NativeDocumentFacade;
90
+ export declare const NATIVE_STORAGE: InjectionToken<Storage>;
91
+ export declare const NATIVE_DOCUMENT: InjectionToken<NativeDocumentFacade>;
92
+ export declare const NATIVE_DEVTOOLS_HOOK: InjectionToken<NativeDevToolsHook>;
93
+ /**
94
+ * Registers compatibility providers (`NativeStorage`, `NativeAriaAnnouncer`, `NativeDevToolsHook`,
95
+ * and `NativeDocumentFacade`) so state & headless UI libraries (`NgRx`, `@angular/aria`,
96
+ * `@angular/cdk`) work smoothly inside the native desktop runtime.
97
+ */
98
+ export declare function provideNativeEcosystemCompat(options?: NativeEcosystemCompatOptions): EnvironmentProviders;
@@ -0,0 +1,281 @@
1
+ import { Inject, Injectable, InjectionToken, makeEnvironmentProviders, Optional, } from '@angular/core';
2
+ import { ensureNgNativeBridge } from './bridge.js';
3
+ import { getNativeActiveElement, NativeElementNode } from './native-element.js';
4
+ import * as i0 from "@angular/core";
5
+ function escapeSqlLiteral(value) {
6
+ return value.replaceAll("'", "''");
7
+ }
8
+ export const NATIVE_BRIDGE = new InjectionToken('NATIVE_BRIDGE', {
9
+ providedIn: 'root',
10
+ factory: () => ensureNgNativeBridge(),
11
+ });
12
+ /**
13
+ * Web `Storage`-compatible persistence adapter backed by the native SQLite engine (`ng_native_storage`)
14
+ * and an in-memory map, enabling `@ngrx/store` meta-reducers and state hydration without a browser DOM.
15
+ */
16
+ export class NativeStorage {
17
+ store = new Map();
18
+ bridge;
19
+ nextId = 1;
20
+ constructor(bridge) {
21
+ this.bridge = bridge ?? ensureNgNativeBridge();
22
+ this.ensureTable();
23
+ }
24
+ ensureTable() {
25
+ try {
26
+ this.bridge.sqliteExecute('CREATE TABLE IF NOT EXISTS ng_native_storage (key TEXT PRIMARY KEY, val TEXT NOT NULL)');
27
+ const rows = this.bridge.sqliteQuery('SELECT key, val FROM ng_native_storage');
28
+ for (const row of rows) {
29
+ const key = row['key'];
30
+ const val = row['val'];
31
+ if (typeof key === 'string' && typeof val === 'string') {
32
+ this.store.set(key, val);
33
+ }
34
+ }
35
+ }
36
+ catch {
37
+ // Fall back silently to in-memory storage if sqlite capability is restricted at runtime
38
+ }
39
+ }
40
+ get length() {
41
+ return this.store.size;
42
+ }
43
+ key(index) {
44
+ if (index < 0 || index >= this.store.size) {
45
+ return null;
46
+ }
47
+ return Array.from(this.store.keys())[index] ?? null;
48
+ }
49
+ getItem(key) {
50
+ return this.store.get(key) ?? null;
51
+ }
52
+ setItem(key, value) {
53
+ const strValue = String(value);
54
+ const idNum = this.nextId++;
55
+ this.store.set(key, strValue);
56
+ try {
57
+ this.bridge.sqliteExecute(`INSERT OR REPLACE INTO ng_native_storage (key, val) VALUES ('${escapeSqlLiteral(key)}', '${escapeSqlLiteral(strValue)}')`);
58
+ this.bridge.setAttribute('__ng_native_storage__', `k_${idNum}`, key);
59
+ }
60
+ catch {
61
+ // In-memory store remains consistent when disk persistence is unavailable
62
+ }
63
+ }
64
+ removeItem(key) {
65
+ this.store.delete(key);
66
+ try {
67
+ this.bridge.sqliteExecute(`DELETE FROM ng_native_storage WHERE key = '${escapeSqlLiteral(key)}'`);
68
+ }
69
+ catch {
70
+ // Ignore bridge persistence error in restricted sandboxes
71
+ }
72
+ }
73
+ clear() {
74
+ this.store.clear();
75
+ try {
76
+ this.bridge.sqliteExecute('DELETE FROM ng_native_storage');
77
+ }
78
+ catch {
79
+ // Ignore bridge persistence error in restricted sandboxes
80
+ }
81
+ }
82
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.6", ngImport: i0, type: NativeStorage, deps: [{ token: NATIVE_BRIDGE, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
83
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.6", ngImport: i0, type: NativeStorage, providedIn: 'root' });
84
+ }
85
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.6", ngImport: i0, type: NativeStorage, decorators: [{
86
+ type: Injectable,
87
+ args: [{ providedIn: 'root' }]
88
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
89
+ type: Optional
90
+ }, {
91
+ type: Inject,
92
+ args: [NATIVE_BRIDGE]
93
+ }] }] });
94
+ /**
95
+ * Headless `@angular/cdk/a11y` `LiveAnnouncer`-compatible service for `@angular/aria` and native
96
+ * GTK4/WinUI/AppKit accessibility announcements.
97
+ */
98
+ export class NativeAriaAnnouncer {
99
+ announcements = [];
100
+ bridge;
101
+ constructor(bridge) {
102
+ this.bridge = bridge ?? ensureNgNativeBridge();
103
+ }
104
+ announce(message, politeness = 'polite') {
105
+ const clean = String(message ?? '').trim();
106
+ if (!clean) {
107
+ return Promise.resolve();
108
+ }
109
+ this.announcements.push({ message: clean, politeness });
110
+ this.bridge.createComment(`aria_live_${this.announcements.length}`, `${politeness}:${clean}`);
111
+ return Promise.resolve();
112
+ }
113
+ clear() {
114
+ this.announcements.length = 0;
115
+ }
116
+ history() {
117
+ return this.announcements;
118
+ }
119
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.6", ngImport: i0, type: NativeAriaAnnouncer, deps: [{ token: NATIVE_BRIDGE, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
120
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.6", ngImport: i0, type: NativeAriaAnnouncer, providedIn: 'root' });
121
+ }
122
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.6", ngImport: i0, type: NativeAriaAnnouncer, decorators: [{
123
+ type: Injectable,
124
+ args: [{ providedIn: 'root' }]
125
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
126
+ type: Optional
127
+ }, {
128
+ type: Inject,
129
+ args: [NATIVE_BRIDGE]
130
+ }] }] });
131
+ /**
132
+ * Redux DevTools (`__REDUX_DEVTOOLS_EXTENSION__`) bridge allowing `@ngrx/store-devtools`
133
+ * to attach cleanly inside JavaScriptCore / QuickJS without browser extensions.
134
+ */
135
+ export class NativeDevToolsHook {
136
+ records = [];
137
+ subscribers = new Set();
138
+ latestState = undefined;
139
+ connect() {
140
+ return {
141
+ init: (state) => {
142
+ this.latestState = state;
143
+ this.records.push({ action: { type: '@@INIT' }, state });
144
+ },
145
+ send: (action, state) => {
146
+ this.latestState = state;
147
+ const record = { action, state };
148
+ this.records.push(record);
149
+ for (const listener of this.subscribers) {
150
+ listener({ type: 'ACTION_RECORDED', payload: record });
151
+ }
152
+ },
153
+ subscribe: (listener) => {
154
+ this.subscribers.add(listener);
155
+ return () => {
156
+ this.subscribers.delete(listener);
157
+ };
158
+ },
159
+ unsubscribe: () => {
160
+ this.subscribers.clear();
161
+ },
162
+ };
163
+ }
164
+ history() {
165
+ return this.records;
166
+ }
167
+ currentState() {
168
+ return this.latestState;
169
+ }
170
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.6", ngImport: i0, type: NativeDevToolsHook, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
171
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.6", ngImport: i0, type: NativeDevToolsHook, providedIn: 'root' });
172
+ }
173
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.6", ngImport: i0, type: NativeDevToolsHook, decorators: [{
174
+ type: Injectable,
175
+ args: [{ providedIn: 'root' }]
176
+ }] });
177
+ function findNodeById(root, id) {
178
+ if (root.id === id || root.getAttribute('id') === id) {
179
+ return root;
180
+ }
181
+ for (const child of root.children) {
182
+ const found = findNodeById(child, id);
183
+ if (found) {
184
+ return found;
185
+ }
186
+ }
187
+ return null;
188
+ }
189
+ function findNodeBySelector(root, selector) {
190
+ const clean = selector.trim();
191
+ if (!clean) {
192
+ return null;
193
+ }
194
+ if (clean.startsWith('#')) {
195
+ return findNodeById(root, clean.slice(1));
196
+ }
197
+ if (clean.startsWith('.')) {
198
+ const className = clean.slice(1);
199
+ if (root.classList.contains(className)) {
200
+ return root;
201
+ }
202
+ }
203
+ else if (root.tag.toLowerCase() === clean.toLowerCase()) {
204
+ return root;
205
+ }
206
+ for (const child of root.children) {
207
+ const match = findNodeBySelector(child, clean);
208
+ if (match) {
209
+ return match;
210
+ }
211
+ }
212
+ return null;
213
+ }
214
+ /**
215
+ * Creates a lightweight headless `Document` facade backed by `NativeElementNode` for
216
+ * `@angular/cdk`, `@angular/aria`, and DOM-agnostic UI primitives.
217
+ */
218
+ export function createNativeDocument(root) {
219
+ const body = root ?? new NativeElementNode('__body__', 'ng-window');
220
+ let nextSeq = 1;
221
+ return {
222
+ get activeElement() {
223
+ return getNativeActiveElement();
224
+ },
225
+ body,
226
+ createElement(tag) {
227
+ return new NativeElementNode(`doc_el_${nextSeq++}`, tag);
228
+ },
229
+ createComment(text = '') {
230
+ const node = new NativeElementNode(`doc_comment_${nextSeq++}`, '#comment', true);
231
+ node.textContent = text;
232
+ return node;
233
+ },
234
+ createTextNode(text) {
235
+ const node = new NativeElementNode(`doc_text_${nextSeq++}`, '#text');
236
+ node.textContent = text;
237
+ return node;
238
+ },
239
+ getElementById(id) {
240
+ return findNodeById(body, id);
241
+ },
242
+ querySelector(selector) {
243
+ return findNodeBySelector(body, selector);
244
+ },
245
+ addEventListener(type, listener) {
246
+ body.addEventListener(type, listener);
247
+ },
248
+ removeEventListener(type, listener) {
249
+ body.removeEventListener(type, listener);
250
+ },
251
+ };
252
+ }
253
+ export const NATIVE_STORAGE = new InjectionToken('NATIVE_STORAGE');
254
+ export const NATIVE_DOCUMENT = new InjectionToken('NATIVE_DOCUMENT');
255
+ export const NATIVE_DEVTOOLS_HOOK = new InjectionToken('NATIVE_DEVTOOLS_HOOK');
256
+ /**
257
+ * Registers compatibility providers (`NativeStorage`, `NativeAriaAnnouncer`, `NativeDevToolsHook`,
258
+ * and `NativeDocumentFacade`) so state & headless UI libraries (`NgRx`, `@angular/aria`,
259
+ * `@angular/cdk`) work smoothly inside the native desktop runtime.
260
+ */
261
+ export function provideNativeEcosystemCompat(options = {}) {
262
+ const storage = new NativeStorage();
263
+ const devTools = new NativeDevToolsHook();
264
+ const nativeDocument = createNativeDocument();
265
+ const globalBag = globalThis;
266
+ if (options.installGlobalStorage !== false && globalBag['localStorage'] === undefined) {
267
+ globalBag['localStorage'] = storage;
268
+ }
269
+ if (options.installDevToolsExtension !== false &&
270
+ globalBag['__REDUX_DEVTOOLS_EXTENSION__'] === undefined) {
271
+ globalBag['__REDUX_DEVTOOLS_EXTENSION__'] = devTools;
272
+ }
273
+ return makeEnvironmentProviders([
274
+ { provide: NativeStorage, useValue: storage },
275
+ { provide: NATIVE_STORAGE, useValue: storage },
276
+ NativeAriaAnnouncer,
277
+ { provide: NativeDevToolsHook, useValue: devTools },
278
+ { provide: NATIVE_DEVTOOLS_HOOK, useValue: devTools },
279
+ { provide: NATIVE_DOCUMENT, useValue: nativeDocument },
280
+ ]);
281
+ }
@@ -0,0 +1,8 @@
1
+ import { ImageLoader } from '@angular/common';
2
+ import { EnvironmentProviders } from '@angular/core';
3
+ /**
4
+ * Angular `IMAGE_LOADER` backed by the Rust OS asset resolver and disk cache
5
+ * (`$XDG_CACHE_HOME/<appId>/images`).
6
+ */
7
+ export declare const nativeImageLoader: ImageLoader;
8
+ export declare function provideNativeImageLoader(): EnvironmentProviders;
@@ -0,0 +1,13 @@
1
+ import { IMAGE_LOADER } from '@angular/common';
2
+ import { makeEnvironmentProviders } from '@angular/core';
3
+ import { ensureNgNativeBridge } from './bridge.js';
4
+ /**
5
+ * Angular `IMAGE_LOADER` backed by the Rust OS asset resolver and disk cache
6
+ * (`$XDG_CACHE_HOME/<appId>/images`).
7
+ */
8
+ export const nativeImageLoader = (config) => {
9
+ return ensureNgNativeBridge().resolveImageAsset(config.src, config.width);
10
+ };
11
+ export function provideNativeImageLoader() {
12
+ return makeEnvironmentProviders([{ provide: IMAGE_LOADER, useValue: nativeImageLoader }]);
13
+ }
@@ -0,0 +1,12 @@
1
+ export { ensureNgNativeBridge, type NativeComputeMatch, type NativeConfirmDialogOptions, type NativeConnectivity, type NativeHttpBridgeResponse, type NativeHttpCallKind, type NativeHttpConfig, type NativeHttpRequestOptions, type NativeMenuItem, type NativeNetworkStatus, type NativeShortcutBinding, type NativeTrayState, type NativeWindowGeometry, type NativeXdgDirKind, type NgNativeBridge, } from './bridge';
2
+ export { formatParsedStyleExtensions, parseRuntimeStyles, type ParsedStyleRule, } from './css-style-parser';
3
+ export { createNativeDocument, NATIVE_BRIDGE, NATIVE_DEVTOOLS_HOOK, NATIVE_DOCUMENT, NATIVE_STORAGE, NativeAriaAnnouncer, NativeDevToolsHook, NativeStorage, provideNativeEcosystemCompat, type AriaPoliteness, type NativeAriaAnnouncement, type NativeDevToolsConnection, type NativeDevToolsRecord, type NativeDocumentFacade, type NativeEcosystemCompatOptions, } from './ecosystem-compat';
4
+ export { nativeImageLoader, provideNativeImageLoader } from './image-loader';
5
+ export { NATIVE_UI_DIRECTIVES, NativeContainerDirective, NativeElementDirective, NativeInputWidgetDirective, NativeListDirective, NativeMediaAndMeterDirective, NativePopoverDirective, NativeTextWidgetDirective, NativeWindowDirective, type NativeAttrInput, type NativeBoolInput, type NativeNumberInput, } from './native-directives';
6
+ export { getNativeActiveElement, NativeElementNode, setNativeActiveElement, type NativeDomRect, type NativeElementEvent, type NativeEventListener, } from './native-element';
7
+ export { HTML_TO_NATIVE_TAG, NativeRenderer2, NativeRendererFactory2, resolveNativeTag, } from './native-renderer';
8
+ export { NATIVE_WINDOW_NODE_ID, NativeTitleService, provideNativeTitle } from './native-title';
9
+ export { bootstrapNativeApplication, provideNativePlatform, type NativeBootstrapContext, } from './platform';
10
+ export { matchesKeyboardEvent, NativeKeyEventsPlugin, NativeSystemErrorHandler, provideNativeErrorHandler, provideNativeKeyEvents, provideSystemLocale, type NativeKeyEventPayload, } from './system-providers';
11
+ export { NativeViewportScroller, provideNativeViewportScroller } from './viewport-scroller';
12
+ export { computeVirtualSliceRange, NativeVirtualListComponent, type NativeVirtualItemContext, type NativeVirtualListEntry, type NativeVirtualRowActivatedEvent, type VirtualSliceRange, } from './virtual-list.component';