@ng-desktop/platform 0.0.0-stage → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +13 -2
- package/fesm2022/bridge-fs-compute.d.ts +19 -0
- package/fesm2022/bridge-fs-compute.d.ts.map +1 -0
- package/fesm2022/bridge-fs-compute.js +104 -0
- package/fesm2022/bridge-fs-compute.js.map +1 -0
- package/fesm2022/bridge-sqlite.d.ts +12 -0
- package/fesm2022/bridge-sqlite.d.ts.map +1 -0
- package/fesm2022/bridge-sqlite.js +250 -0
- package/fesm2022/bridge-sqlite.js.map +1 -0
- package/fesm2022/bridge.d.ts +108 -0
- package/fesm2022/bridge.d.ts.map +1 -0
- package/fesm2022/bridge.js +234 -0
- package/fesm2022/bridge.js.map +1 -0
- package/fesm2022/ecosystem-compat.d.ts +99 -0
- package/fesm2022/ecosystem-compat.d.ts.map +1 -0
- package/fesm2022/ecosystem-compat.js +282 -0
- package/fesm2022/ecosystem-compat.js.map +1 -0
- package/fesm2022/image-loader.d.ts +9 -0
- package/fesm2022/image-loader.d.ts.map +1 -0
- package/fesm2022/image-loader.js +14 -0
- package/fesm2022/image-loader.js.map +1 -0
- package/fesm2022/index.d.ts +10 -0
- package/fesm2022/index.d.ts.map +1 -0
- package/fesm2022/index.js +10 -0
- package/fesm2022/index.js.map +1 -0
- package/fesm2022/native-element.d.ts +68 -0
- package/fesm2022/native-element.d.ts.map +1 -0
- package/fesm2022/native-element.js +193 -0
- package/fesm2022/native-element.js.map +1 -0
- package/fesm2022/native-renderer.d.ts +52 -0
- package/fesm2022/native-renderer.d.ts.map +1 -0
- package/fesm2022/native-renderer.js +199 -0
- package/fesm2022/native-renderer.js.map +1 -0
- package/fesm2022/native-title.d.ts +18 -0
- package/fesm2022/native-title.d.ts.map +1 -0
- package/fesm2022/native-title.js +40 -0
- package/fesm2022/native-title.js.map +1 -0
- package/fesm2022/platform.d.ts +18 -0
- package/fesm2022/platform.d.ts.map +1 -0
- package/fesm2022/platform.js +40 -0
- package/fesm2022/platform.js.map +1 -0
- package/fesm2022/system-providers.d.ts +42 -0
- package/fesm2022/system-providers.d.ts.map +1 -0
- package/fesm2022/system-providers.js +113 -0
- package/fesm2022/system-providers.js.map +1 -0
- package/fesm2022/viewport-scroller.d.ts +23 -0
- package/fesm2022/viewport-scroller.d.ts.map +1 -0
- package/fesm2022/viewport-scroller.js +53 -0
- package/fesm2022/viewport-scroller.js.map +1 -0
- package/package.json +48 -4
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { computeFuzzyFilterFallback, computeHashFallback, InMemoryFsStore, } from './bridge-fs-compute.js';
|
|
2
|
+
import { InMemorySqliteStore, resolveNativeImageAsset } from './bridge-sqlite.js';
|
|
3
|
+
/**
|
|
4
|
+
* Ensures `globalThis.__NG_NATIVE__` is initialized.
|
|
5
|
+
* In the Rust native runtime (`JscEngine` / `QuickJsEngine`), the host injects this at startup;
|
|
6
|
+
* in Node/Vitest unit tests, this provides an identical in-memory command queue.
|
|
7
|
+
*/
|
|
8
|
+
export function ensureNgNativeBridge() {
|
|
9
|
+
if (globalThis.__NG_NATIVE__) {
|
|
10
|
+
return globalThis.__NG_NATIVE__;
|
|
11
|
+
}
|
|
12
|
+
let queue = [];
|
|
13
|
+
let systemTheme = 'dark';
|
|
14
|
+
let clipboardText = '';
|
|
15
|
+
const sqliteStore = new InMemorySqliteStore();
|
|
16
|
+
const fsStore = new InMemoryFsStore();
|
|
17
|
+
let networkStatus = {
|
|
18
|
+
online: true,
|
|
19
|
+
metered: false,
|
|
20
|
+
connectivity: 'full',
|
|
21
|
+
};
|
|
22
|
+
const systemLocale = (typeof Intl !== 'undefined' ? Intl.DateTimeFormat().resolvedOptions().locale : '') || 'en-US';
|
|
23
|
+
const systemTimezone = (typeof Intl !== 'undefined' ? Intl.DateTimeFormat().resolvedOptions().timeZone : '') || 'UTC';
|
|
24
|
+
const systemErrors = [];
|
|
25
|
+
const httpEndpoints = new Map();
|
|
26
|
+
let httpConfig = {
|
|
27
|
+
platform: 'js-fallback',
|
|
28
|
+
useFetchTransport: true,
|
|
29
|
+
interceptorsEnabled: true,
|
|
30
|
+
xsrfEnabled: true,
|
|
31
|
+
xsrfCookieName: 'XSRF-TOKEN',
|
|
32
|
+
xsrfHeaderName: 'X-XSRF-TOKEN',
|
|
33
|
+
xsrfTokenValue: '',
|
|
34
|
+
jsonpEnabled: false,
|
|
35
|
+
requestsViaParent: false,
|
|
36
|
+
maxParallelConnections: 24,
|
|
37
|
+
cacheEnabled: true,
|
|
38
|
+
timeoutMs: 15_000,
|
|
39
|
+
};
|
|
40
|
+
const listeners = new Map();
|
|
41
|
+
let nextListenerId = 1;
|
|
42
|
+
const fallbackBridge = {
|
|
43
|
+
registerStyle(cls, bg = 'none', fg = 'none', pad = 0, space = 0) {
|
|
44
|
+
queue.push(`style ${cls} ${bg} ${fg} ${pad} ${space}`);
|
|
45
|
+
},
|
|
46
|
+
declareSignal(name, initial = 0) {
|
|
47
|
+
queue.push(`signal ${name} ${initial}`);
|
|
48
|
+
},
|
|
49
|
+
createElement(id, tag) {
|
|
50
|
+
queue.push(`create ${id} ${tag}`);
|
|
51
|
+
return id;
|
|
52
|
+
},
|
|
53
|
+
createComment(id, text = 'anchor') {
|
|
54
|
+
queue.push(`comment ${id} ${text}`);
|
|
55
|
+
return id;
|
|
56
|
+
},
|
|
57
|
+
setText(id, text) {
|
|
58
|
+
queue.push(`text ${id} ${text}`);
|
|
59
|
+
},
|
|
60
|
+
setAttribute(id, key, value) {
|
|
61
|
+
queue.push(`attr ${id} ${key} ${value}`);
|
|
62
|
+
},
|
|
63
|
+
setWindowIcon(id, appId, icoPath) {
|
|
64
|
+
queue.push(`icon ${id} ${appId} ${icoPath}`);
|
|
65
|
+
},
|
|
66
|
+
appendChild(parent, child) {
|
|
67
|
+
queue.push(`append ${parent} ${child}`);
|
|
68
|
+
},
|
|
69
|
+
insertBefore(parent, child, refChild) {
|
|
70
|
+
if (refChild) {
|
|
71
|
+
queue.push(`insert_before ${parent} ${child} ${refChild}`);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
queue.push(`insert_before ${parent} ${child}`);
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
removeChild(parent, child) {
|
|
78
|
+
queue.push(`remove_child ${parent} ${child}`);
|
|
79
|
+
},
|
|
80
|
+
addClass(id, className) {
|
|
81
|
+
queue.push(`add_class ${id} ${className}`);
|
|
82
|
+
},
|
|
83
|
+
bindText(id, signalName, template) {
|
|
84
|
+
queue.push(`bind_text ${id} ${signalName} ${template}`);
|
|
85
|
+
},
|
|
86
|
+
bindAttr(id, attrKey, signalName, template = '{}') {
|
|
87
|
+
queue.push(`bind_attr ${id} ${attrKey} ${signalName} ${template}`);
|
|
88
|
+
},
|
|
89
|
+
bindVisible(id, signalName, op = '!=', rhs = 0) {
|
|
90
|
+
queue.push(`bind_visible ${id} ${signalName} ${op} ${rhs}`);
|
|
91
|
+
},
|
|
92
|
+
onAdd(id, eventName, signalName, delta = 1) {
|
|
93
|
+
queue.push(`on_add ${id} ${eventName} ${signalName} ${delta}`);
|
|
94
|
+
},
|
|
95
|
+
onSet(id, eventName, signalName, value = 0) {
|
|
96
|
+
queue.push(`on_set ${id} ${eventName} ${signalName} ${value}`);
|
|
97
|
+
},
|
|
98
|
+
listen(id, eventName, callback) {
|
|
99
|
+
const lid = nextListenerId++;
|
|
100
|
+
listeners.set(lid, { id, eventName, callback });
|
|
101
|
+
return () => {
|
|
102
|
+
listeners.delete(lid);
|
|
103
|
+
};
|
|
104
|
+
},
|
|
105
|
+
destroyNode(id) {
|
|
106
|
+
queue.push(`destroy ${id}`);
|
|
107
|
+
},
|
|
108
|
+
getSystemTheme() {
|
|
109
|
+
return systemTheme;
|
|
110
|
+
},
|
|
111
|
+
setSystemTheme(theme) {
|
|
112
|
+
systemTheme = theme === 'light' ? 'light' : 'dark';
|
|
113
|
+
},
|
|
114
|
+
getClipboard() {
|
|
115
|
+
return clipboardText;
|
|
116
|
+
},
|
|
117
|
+
setClipboard(text) {
|
|
118
|
+
clipboardText = text;
|
|
119
|
+
},
|
|
120
|
+
sendNotification(title, body, icon = 'ng-linux-counter') {
|
|
121
|
+
queue.push(`comment notify_${nextListenerId++} [${icon}] ${title}: ${body}`);
|
|
122
|
+
},
|
|
123
|
+
openFileDialog(_title = 'Open File', defaultPath = '/home/user/document.txt') {
|
|
124
|
+
return defaultPath;
|
|
125
|
+
},
|
|
126
|
+
saveFileDialog(_title = 'Save File', suggestedName = '/home/user/untitled.txt') {
|
|
127
|
+
return suggestedName;
|
|
128
|
+
},
|
|
129
|
+
configureHttp(config) {
|
|
130
|
+
httpConfig = { ...httpConfig, ...config };
|
|
131
|
+
return { ...httpConfig };
|
|
132
|
+
},
|
|
133
|
+
getHttpConfig() {
|
|
134
|
+
return { ...httpConfig };
|
|
135
|
+
},
|
|
136
|
+
registerHttpEndpoint(method, url, status, body) {
|
|
137
|
+
const key = `${method.trim().toUpperCase()} ${url.trim()}`;
|
|
138
|
+
httpEndpoints.set(key, {
|
|
139
|
+
status,
|
|
140
|
+
statusText: status < 400 ? 'OK' : 'Error',
|
|
141
|
+
body,
|
|
142
|
+
headers: {},
|
|
143
|
+
transport: 'mock-route',
|
|
144
|
+
callKind: 'json',
|
|
145
|
+
cached: false,
|
|
146
|
+
});
|
|
147
|
+
},
|
|
148
|
+
httpRequest(method, url, _body, options) {
|
|
149
|
+
const key = `${method.trim().toUpperCase()} ${url.trim()}`;
|
|
150
|
+
return (httpEndpoints.get(key) ?? {
|
|
151
|
+
status: 404,
|
|
152
|
+
statusText: 'Not Found',
|
|
153
|
+
body: '{"error":"Endpoint not registered"}',
|
|
154
|
+
headers: {},
|
|
155
|
+
transport: 'js-fallback',
|
|
156
|
+
callKind: options?.callKind ?? 'json',
|
|
157
|
+
cached: false,
|
|
158
|
+
});
|
|
159
|
+
},
|
|
160
|
+
httpBatchRequest(requests) {
|
|
161
|
+
return requests.map((req) => fallbackBridge.httpRequest(req.method, req.url, req.body, req.options));
|
|
162
|
+
},
|
|
163
|
+
sqliteExecute(sql) {
|
|
164
|
+
return sqliteStore.execute(sql);
|
|
165
|
+
},
|
|
166
|
+
sqliteQuery(sql) {
|
|
167
|
+
return sqliteStore.query(sql);
|
|
168
|
+
},
|
|
169
|
+
getNetworkStatus() {
|
|
170
|
+
return { ...networkStatus };
|
|
171
|
+
},
|
|
172
|
+
setNetworkStatus(online, metered = false) {
|
|
173
|
+
networkStatus = {
|
|
174
|
+
online,
|
|
175
|
+
metered,
|
|
176
|
+
connectivity: !online ? 'offline' : metered ? 'limited' : 'full',
|
|
177
|
+
};
|
|
178
|
+
},
|
|
179
|
+
getSystemLocale() {
|
|
180
|
+
return systemLocale;
|
|
181
|
+
},
|
|
182
|
+
getSystemTimezone() {
|
|
183
|
+
return systemTimezone;
|
|
184
|
+
},
|
|
185
|
+
resolveImageAsset(src, width) {
|
|
186
|
+
return resolveNativeImageAsset(src, width);
|
|
187
|
+
},
|
|
188
|
+
logSystemError(message) {
|
|
189
|
+
systemErrors.push(String(message));
|
|
190
|
+
},
|
|
191
|
+
getSystemErrors() {
|
|
192
|
+
return [...systemErrors];
|
|
193
|
+
},
|
|
194
|
+
computeFuzzyFilter(items, query, limit = 50) {
|
|
195
|
+
return computeFuzzyFilterFallback(items, query, limit);
|
|
196
|
+
},
|
|
197
|
+
computeHash(input) {
|
|
198
|
+
return computeHashFallback(input);
|
|
199
|
+
},
|
|
200
|
+
fsResolvePath(kind, relPath) {
|
|
201
|
+
return fsStore.resolvePath(kind, relPath);
|
|
202
|
+
},
|
|
203
|
+
fsReadText(path) {
|
|
204
|
+
return fsStore.readText(path);
|
|
205
|
+
},
|
|
206
|
+
fsWriteText(path, content) {
|
|
207
|
+
return fsStore.writeText(path, content);
|
|
208
|
+
},
|
|
209
|
+
fsWatchFile(path) {
|
|
210
|
+
return fsStore.watchFile(path);
|
|
211
|
+
},
|
|
212
|
+
fsPollChangedFiles() {
|
|
213
|
+
return fsStore.pollChangedFiles();
|
|
214
|
+
},
|
|
215
|
+
__dispatchEvent(id, eventName, eventPayload = {}) {
|
|
216
|
+
for (const entry of listeners.values()) {
|
|
217
|
+
if (entry.id === id && entry.eventName === eventName) {
|
|
218
|
+
entry.callback(eventPayload);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
__flushTimers() {
|
|
223
|
+
// No-op in synchronous fallback
|
|
224
|
+
},
|
|
225
|
+
__drainQueue() {
|
|
226
|
+
const out = queue.join('\n');
|
|
227
|
+
queue = [];
|
|
228
|
+
return out;
|
|
229
|
+
},
|
|
230
|
+
};
|
|
231
|
+
globalThis.__NG_NATIVE__ = fallbackBridge;
|
|
232
|
+
return fallbackBridge;
|
|
233
|
+
}
|
|
234
|
+
//# sourceMappingURL=bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.js","sourceRoot":"","sources":["../../../../packages/platform-native/src/bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,mBAAmB,EACnB,eAAe,GAGhB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAsH/E;;;;GAIG;AACH,MAAM,UAAU,oBAAoB;IAClC,IAAI,UAAU,CAAC,aAAa,EAAE,CAAC;QAC7B,OAAO,UAAU,CAAC,aAAa,CAAC;IAClC,CAAC;IAED,IAAI,KAAK,GAAa,EAAE,CAAC;IACzB,IAAI,WAAW,GAAqB,MAAM,CAAC;IAC3C,IAAI,aAAa,GAAG,EAAE,CAAC;IACvB,MAAM,WAAW,GAAG,IAAI,mBAAmB,EAAE,CAAC;IAC9C,MAAM,OAAO,GAAG,IAAI,eAAe,EAAE,CAAC;IACtC,IAAI,aAAa,GAAwB;QACvC,MAAM,EAAE,IAAI;QACZ,OAAO,EAAE,KAAK;QACd,YAAY,EAAE,MAAM;KACr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AAC,IAAI,CAAC,CAAC;QACjC,CAAC;QACD,kBAAkB;YAChB,OAAO,OAAO,CAAC,gBAAgB,EAAE,CAAC;QACpC,CAAC;QACD,eAAe,CAAC,EAAE,EAAE,SAAS,EAAE,YAAY,GAAG,EAAE;YAC9C,KAAK,MAAM,KAAK,IAAI,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC;gBACvC,IAAI,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,KAAK,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;oBACrD,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;gBAC/B,CAAC;YACH,CAAC;QACH,CAAC;QACD,aAAa;YACX,gCAAgC;QAClC,CAAC;QACD,YAAY;YACV,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC7B,KAAK,GAAG,EAAE,CAAC;YACX,OAAO,GAAG,CAAC;QACb,CAAC;KACF,CAAC;IAEF,UAAU,CAAC,aAAa,GAAG,cAAc,CAAC;IAC1C,OAAO,cAAc,CAAC;AACxB,CAAC","sourcesContent":["import {\n computeFuzzyFilterFallback,\n computeHashFallback,\n InMemoryFsStore,\n type NativeComputeMatch,\n type NativeXdgDirKind,\n} from './bridge-fs-compute';\nimport { InMemorySqliteStore, resolveNativeImageAsset } from './bridge-sqlite';\n\nexport type { NativeComputeMatch, NativeXdgDirKind } from './bridge-fs-compute';\n\nexport type NativeHttpCallKind = 'json' | 'graphql' | 'asset' | 'batch' | 'text';\n\nexport type NativeConnectivity = 'full' | 'limited' | 'offline';\n\nexport interface NativeNetworkStatus {\n online: boolean;\n metered: boolean;\n connectivity: NativeConnectivity;\n}\n\nexport interface NativeHttpRequestOptions {\n headers?: Record<string, string>;\n responseType?: string;\n callKind?: NativeHttpCallKind;\n withCredentials?: boolean;\n}\n\nexport interface NativeHttpConfig {\n platform?: string;\n useFetchTransport?: boolean;\n interceptorsEnabled?: boolean;\n xsrfEnabled?: boolean;\n xsrfCookieName?: string;\n xsrfHeaderName?: string;\n xsrfTokenValue?: string;\n jsonpEnabled?: boolean;\n requestsViaParent?: boolean;\n maxParallelConnections?: number;\n cacheEnabled?: boolean;\n timeoutMs?: number;\n}\n\nexport interface NativeHttpBridgeResponse {\n status: number;\n statusText: string;\n body: string;\n headers?: Record<string, string>;\n transport?: string;\n callKind?: NativeHttpCallKind;\n cached?: boolean;\n}\n\n/**\n * Host FFI bridge contract injected at `globalThis.__NG_NATIVE__` by the Rust `JsEngineBackend`\n * (`JscEngine` or `QuickJsEngine`).\n */\nexport interface NgNativeBridge {\n registerStyle(cls: string, bg?: string, fg?: string, pad?: number, space?: number): void;\n declareSignal(name: string, initial?: number): void;\n createElement(id: string, tag: string): string;\n createComment(id: string, text?: string): string;\n setText(id: string, text: string): void;\n setAttribute(id: string, key: string, value: string): void;\n setWindowIcon(id: string, appId: string, icoPath: string): void;\n appendChild(parent: string, child: string): void;\n insertBefore(parent: string, child: string, refChild?: string): void;\n removeChild(parent: string, child: string): void;\n addClass(id: string, className: string): void;\n bindText(id: string, signalName: string, template: string): void;\n bindAttr(id: string, attrKey: string, signalName: string, template?: string): void;\n bindVisible(id: string, signalName: string, op?: string, rhs?: number): void;\n onAdd(id: string, eventName: string, signalName: string, delta?: number): void;\n onSet(id: string, eventName: string, signalName: string, value?: number): void;\n listen(id: string, eventName: string, callback: (event?: unknown) => void): () => void;\n destroyNode(id: string): void;\n getSystemTheme(): 'dark' | 'light';\n setSystemTheme(theme: 'dark' | 'light'): void;\n getClipboard(): string;\n setClipboard(text: string): void;\n sendNotification(title: string, body: string, icon?: string): void;\n openFileDialog(title?: string, defaultPath?: string): string;\n saveFileDialog(title?: string, suggestedName?: string): string;\n configureHttp(config: NativeHttpConfig): NativeHttpConfig;\n getHttpConfig(): NativeHttpConfig;\n registerHttpEndpoint(method: string, url: string, status: number, body: string): void;\n httpRequest(\n method: string,\n url: string,\n body?: string,\n options?: NativeHttpRequestOptions,\n ): NativeHttpBridgeResponse;\n httpBatchRequest?(\n requests: Array<{\n method: string;\n url: string;\n body?: string;\n options?: NativeHttpRequestOptions;\n }>,\n ): NativeHttpBridgeResponse[];\n sqliteExecute(sql: string): boolean;\n sqliteQuery(sql: string): Array<Record<string, string>>;\n getNetworkStatus(): NativeNetworkStatus;\n setNetworkStatus(online: boolean, metered?: boolean): void;\n getSystemLocale(): string;\n getSystemTimezone(): string;\n resolveImageAsset(src: string, width?: number): string;\n logSystemError(message: string): void;\n getSystemErrors(): string[];\n computeFuzzyFilter(items: readonly string[], query: string, limit?: number): NativeComputeMatch[];\n computeHash(input: string): string;\n fsResolvePath(kind: NativeXdgDirKind, relPath: string): string;\n fsReadText(path: string): string | null;\n fsWriteText(path: string, content: string): boolean;\n fsWatchFile(path: string): boolean;\n fsPollChangedFiles(): string[];\n __dispatchEvent(id: string, eventName: string, eventPayload?: unknown): void;\n __flushTimers(): void;\n __drainQueue(): string;\n}\n\ndeclare global {\n var __NG_NATIVE__: NgNativeBridge | undefined;\n}\n\n/**\n * Ensures `globalThis.__NG_NATIVE__` is initialized.\n * In the Rust native runtime (`JscEngine` / `QuickJsEngine`), the host injects this at startup;\n * in Node/Vitest unit tests, this provides an identical in-memory command queue.\n */\nexport function ensureNgNativeBridge(): NgNativeBridge {\n if (globalThis.__NG_NATIVE__) {\n return globalThis.__NG_NATIVE__;\n }\n\n let queue: string[] = [];\n let systemTheme: 'dark' | 'light' = 'dark';\n let clipboardText = '';\n const sqliteStore = new InMemorySqliteStore();\n const fsStore = new InMemoryFsStore();\n let networkStatus: NativeNetworkStatus = {\n online: true,\n metered: false,\n connectivity: 'full',\n };\n const systemLocale =\n (typeof Intl !== 'undefined' ? Intl.DateTimeFormat().resolvedOptions().locale : '') || 'en-US';\n const systemTimezone =\n (typeof Intl !== 'undefined' ? Intl.DateTimeFormat().resolvedOptions().timeZone : '') || 'UTC';\n const systemErrors: string[] = [];\n const httpEndpoints = new Map<string, NativeHttpBridgeResponse>();\n let httpConfig: NativeHttpConfig = {\n platform: 'js-fallback',\n useFetchTransport: true,\n interceptorsEnabled: true,\n xsrfEnabled: true,\n xsrfCookieName: 'XSRF-TOKEN',\n xsrfHeaderName: 'X-XSRF-TOKEN',\n xsrfTokenValue: '',\n jsonpEnabled: false,\n requestsViaParent: false,\n maxParallelConnections: 24,\n cacheEnabled: true,\n timeoutMs: 15_000,\n };\n const listeners = new Map<\n number,\n { id: string; eventName: string; callback: (e?: unknown) => void }\n >();\n let nextListenerId = 1;\n\n const fallbackBridge: NgNativeBridge = {\n registerStyle(cls, bg = 'none', fg = 'none', pad = 0, space = 0) {\n queue.push(`style ${cls} ${bg} ${fg} ${pad} ${space}`);\n },\n declareSignal(name, initial = 0) {\n queue.push(`signal ${name} ${initial}`);\n },\n createElement(id, tag) {\n queue.push(`create ${id} ${tag}`);\n return id;\n },\n createComment(id, text = 'anchor') {\n queue.push(`comment ${id} ${text}`);\n return id;\n },\n setText(id, text) {\n queue.push(`text ${id} ${text}`);\n },\n setAttribute(id, key, value) {\n queue.push(`attr ${id} ${key} ${value}`);\n },\n setWindowIcon(id, appId, icoPath) {\n queue.push(`icon ${id} ${appId} ${icoPath}`);\n },\n appendChild(parent, child) {\n queue.push(`append ${parent} ${child}`);\n },\n insertBefore(parent, child, refChild) {\n if (refChild) {\n queue.push(`insert_before ${parent} ${child} ${refChild}`);\n } else {\n queue.push(`insert_before ${parent} ${child}`);\n }\n },\n removeChild(parent, child) {\n queue.push(`remove_child ${parent} ${child}`);\n },\n addClass(id, className) {\n queue.push(`add_class ${id} ${className}`);\n },\n bindText(id, signalName, template) {\n queue.push(`bind_text ${id} ${signalName} ${template}`);\n },\n bindAttr(id, attrKey, signalName, template = '{}') {\n queue.push(`bind_attr ${id} ${attrKey} ${signalName} ${template}`);\n },\n bindVisible(id, signalName, op = '!=', rhs = 0) {\n queue.push(`bind_visible ${id} ${signalName} ${op} ${rhs}`);\n },\n onAdd(id, eventName, signalName, delta = 1) {\n queue.push(`on_add ${id} ${eventName} ${signalName} ${delta}`);\n },\n onSet(id, eventName, signalName, value = 0) {\n queue.push(`on_set ${id} ${eventName} ${signalName} ${value}`);\n },\n listen(id, eventName, callback) {\n const lid = nextListenerId++;\n listeners.set(lid, { id, eventName, callback });\n return () => {\n listeners.delete(lid);\n };\n },\n destroyNode(id) {\n queue.push(`destroy ${id}`);\n },\n getSystemTheme() {\n return systemTheme;\n },\n setSystemTheme(theme) {\n systemTheme = theme === 'light' ? 'light' : 'dark';\n },\n getClipboard() {\n return clipboardText;\n },\n setClipboard(text) {\n clipboardText = text;\n },\n sendNotification(title, body, icon = 'ng-linux-counter') {\n queue.push(`comment notify_${nextListenerId++} [${icon}] ${title}: ${body}`);\n },\n openFileDialog(_title = 'Open File', defaultPath = '/home/user/document.txt') {\n return defaultPath;\n },\n saveFileDialog(_title = 'Save File', suggestedName = '/home/user/untitled.txt') {\n return suggestedName;\n },\n configureHttp(config) {\n httpConfig = { ...httpConfig, ...config };\n return { ...httpConfig };\n },\n getHttpConfig() {\n return { ...httpConfig };\n },\n registerHttpEndpoint(method, url, status, body) {\n const key = `${method.trim().toUpperCase()} ${url.trim()}`;\n httpEndpoints.set(key, {\n status,\n statusText: status < 400 ? 'OK' : 'Error',\n body,\n headers: {},\n transport: 'mock-route',\n callKind: 'json',\n cached: false,\n });\n },\n httpRequest(method, url, _body, options) {\n const key = `${method.trim().toUpperCase()} ${url.trim()}`;\n return (\n httpEndpoints.get(key) ?? {\n status: 404,\n statusText: 'Not Found',\n body: '{\"error\":\"Endpoint not registered\"}',\n headers: {},\n transport: 'js-fallback',\n callKind: options?.callKind ?? 'json',\n cached: false,\n }\n );\n },\n httpBatchRequest(requests) {\n return requests.map((req) =>\n fallbackBridge.httpRequest(req.method, req.url, req.body, req.options),\n );\n },\n sqliteExecute(sql) {\n return sqliteStore.execute(sql);\n },\n sqliteQuery(sql) {\n return sqliteStore.query(sql);\n },\n getNetworkStatus() {\n return { ...networkStatus };\n },\n setNetworkStatus(online, metered = false) {\n networkStatus = {\n online,\n metered,\n connectivity: !online ? 'offline' : metered ? 'limited' : 'full',\n };\n },\n getSystemLocale() {\n return systemLocale;\n },\n getSystemTimezone() {\n return systemTimezone;\n },\n resolveImageAsset(src, width) {\n return resolveNativeImageAsset(src, width);\n },\n logSystemError(message) {\n systemErrors.push(String(message));\n },\n getSystemErrors() {\n return [...systemErrors];\n },\n computeFuzzyFilter(items, query, limit = 50) {\n return computeFuzzyFilterFallback(items, query, limit);\n },\n computeHash(input) {\n return computeHashFallback(input);\n },\n fsResolvePath(kind, relPath) {\n return fsStore.resolvePath(kind, relPath);\n },\n fsReadText(path) {\n return fsStore.readText(path);\n },\n fsWriteText(path, content) {\n return fsStore.writeText(path, content);\n },\n fsWatchFile(path) {\n return fsStore.watchFile(path);\n },\n fsPollChangedFiles() {\n return fsStore.pollChangedFiles();\n },\n __dispatchEvent(id, eventName, eventPayload = {}) {\n for (const entry of listeners.values()) {\n if (entry.id === id && entry.eventName === eventName) {\n entry.callback(eventPayload);\n }\n }\n },\n __flushTimers() {\n // No-op in synchronous fallback\n },\n __drainQueue() {\n const out = queue.join('\\n');\n queue = [];\n return out;\n },\n };\n\n globalThis.__NG_NATIVE__ = fallbackBridge;\n return fallbackBridge;\n}\n"]}
|
|
@@ -0,0 +1,99 @@
|
|
|
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;
|
|
99
|
+
//# sourceMappingURL=ecosystem-compat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ecosystem-compat.d.ts","sourceRoot":"","sources":["../../../../packages/platform-native/src/ecosystem-compat.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EAGpB,cAAc,EAGf,MAAM,eAAe,CAAC;AACvB,OAAO,EAAwB,cAAc,EAAE,MAAM,UAAU,CAAC;AAChE,OAAO,EAA0B,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;;AAElG,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,QAAQ,GAAG,WAAW,CAAC;AAE5D,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,UAAU,EAAE,cAAc,CAAC;CACrC;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,CAAC,KAAK,EAAE,OAA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A4B,CAC1C,OAAO,GAAE,4BAAiC,GACzC,oBAAoB,CAwBtB"}
|
|
@@ -0,0 +1,282 @@
|
|
|
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
|
+
}
|
|
282
|
+
//# sourceMappingURL=ecosystem-compat.js.map
|