@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.
- package/LICENSE +21 -0
- package/README.md +13 -2
- package/fesm2022/bridge-fs-compute.d.ts +19 -0
- package/fesm2022/bridge-fs-compute.js +107 -0
- package/fesm2022/bridge-sqlite.d.ts +11 -0
- package/fesm2022/bridge-sqlite.js +240 -0
- package/fesm2022/bridge.d.ts +168 -0
- package/fesm2022/bridge.js +421 -0
- package/fesm2022/css-style-parser.d.ts +33 -0
- package/fesm2022/css-style-parser.js +259 -0
- package/fesm2022/ecosystem-compat.d.ts +98 -0
- package/fesm2022/ecosystem-compat.js +281 -0
- package/fesm2022/image-loader.d.ts +8 -0
- package/fesm2022/image-loader.js +13 -0
- package/fesm2022/index.d.ts +12 -0
- package/fesm2022/index.js +12 -0
- package/fesm2022/native-directives.d.ts +178 -0
- package/fesm2022/native-directives.js +724 -0
- package/fesm2022/native-element.d.ts +73 -0
- package/fesm2022/native-element.js +212 -0
- package/fesm2022/native-renderer.d.ts +93 -0
- package/fesm2022/native-renderer.js +1106 -0
- package/fesm2022/native-title.d.ts +18 -0
- package/fesm2022/native-title.js +52 -0
- package/fesm2022/platform.d.ts +18 -0
- package/fesm2022/platform.js +46 -0
- package/fesm2022/system-providers.d.ts +43 -0
- package/fesm2022/system-providers.js +163 -0
- package/fesm2022/viewport-scroller.d.ts +24 -0
- package/fesm2022/viewport-scroller.js +65 -0
- package/fesm2022/virtual-list.component.d.ts +57 -0
- package/fesm2022/virtual-list.component.js +200 -0
- package/package.json +50 -4
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { EnvironmentProviders, InjectionToken } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export declare const NATIVE_WINDOW_NODE_ID: InjectionToken<string>;
|
|
4
|
+
/**
|
|
5
|
+
* Native OS window title service replacing `@angular/platform-browser`'s DOM `Title`.
|
|
6
|
+
* Synchronizes `gtk_window_set_title` / `NSWindow.title` / `AppWindow.Title` via `__NG_NATIVE__`.
|
|
7
|
+
*/
|
|
8
|
+
export declare class NativeTitleService {
|
|
9
|
+
private readonly bridge;
|
|
10
|
+
private readonly windowNodeId;
|
|
11
|
+
private readonly rendererFactory;
|
|
12
|
+
readonly title: import("@angular/core").WritableSignal<string>;
|
|
13
|
+
getTitle(): string;
|
|
14
|
+
setTitle(newTitle: string): void;
|
|
15
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NativeTitleService, never>;
|
|
16
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
17
|
+
}
|
|
18
|
+
export declare function provideNativeTitle(windowNodeId?: string): EnvironmentProviders;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { inject, Injectable, InjectionToken, makeEnvironmentProviders, signal, } from '@angular/core';
|
|
2
|
+
import { Title } from '@angular/platform-browser';
|
|
3
|
+
import { ensureNgNativeBridge } from './bridge.js';
|
|
4
|
+
import { NativeRendererFactory2 } from './native-renderer.js';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
function injectOptionalRendererFactory() {
|
|
7
|
+
try {
|
|
8
|
+
return inject(NativeRendererFactory2, { optional: true });
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export const NATIVE_WINDOW_NODE_ID = new InjectionToken('NATIVE_WINDOW_NODE_ID', {
|
|
15
|
+
providedIn: 'root',
|
|
16
|
+
factory: () => 'win',
|
|
17
|
+
});
|
|
18
|
+
/**
|
|
19
|
+
* Native OS window title service replacing `@angular/platform-browser`'s DOM `Title`.
|
|
20
|
+
* Synchronizes `gtk_window_set_title` / `NSWindow.title` / `AppWindow.Title` via `__NG_NATIVE__`.
|
|
21
|
+
*/
|
|
22
|
+
export class NativeTitleService {
|
|
23
|
+
bridge = ensureNgNativeBridge();
|
|
24
|
+
windowNodeId = inject(NATIVE_WINDOW_NODE_ID);
|
|
25
|
+
rendererFactory = injectOptionalRendererFactory();
|
|
26
|
+
title = signal('ng-native-app', /* @ts-ignore */
|
|
27
|
+
...(ngDevMode ? [{ debugName: "title" }] : /* istanbul ignore next */ []));
|
|
28
|
+
getTitle() {
|
|
29
|
+
return this.title();
|
|
30
|
+
}
|
|
31
|
+
setTitle(newTitle) {
|
|
32
|
+
const normalized = String(newTitle ?? '').trim() || 'ng-native-app';
|
|
33
|
+
const targetId = this.windowNodeId === 'win'
|
|
34
|
+
? (this.rendererFactory?.getPrimaryWindowId() ?? this.windowNodeId)
|
|
35
|
+
: this.windowNodeId;
|
|
36
|
+
this.title.set(normalized);
|
|
37
|
+
this.bridge.setText(targetId, normalized);
|
|
38
|
+
}
|
|
39
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.6", ngImport: i0, type: NativeTitleService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
40
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.6", ngImport: i0, type: NativeTitleService, providedIn: 'root' });
|
|
41
|
+
}
|
|
42
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.6", ngImport: i0, type: NativeTitleService, decorators: [{
|
|
43
|
+
type: Injectable,
|
|
44
|
+
args: [{ providedIn: 'root' }]
|
|
45
|
+
}] });
|
|
46
|
+
export function provideNativeTitle(windowNodeId = 'win') {
|
|
47
|
+
return makeEnvironmentProviders([
|
|
48
|
+
{ provide: NATIVE_WINDOW_NODE_ID, useValue: windowNodeId },
|
|
49
|
+
NativeTitleService,
|
|
50
|
+
{ provide: Title, useExisting: NativeTitleService },
|
|
51
|
+
]);
|
|
52
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ApplicationConfig, ApplicationRef, EnvironmentProviders, Type } from '@angular/core';
|
|
2
|
+
import { NgNativeBridge } from './bridge';
|
|
3
|
+
/**
|
|
4
|
+
* Provides the Angular Native Desktop platform (`NativeRendererFactory2`, Zoneless reactivity,
|
|
5
|
+
* OS image asset loader, native window title, viewport scroller, system locale/timezone,
|
|
6
|
+
* key shortcut plugin, and native error handler).
|
|
7
|
+
*/
|
|
8
|
+
export declare function provideNativePlatform(): EnvironmentProviders;
|
|
9
|
+
export interface NativeBootstrapContext {
|
|
10
|
+
readonly rootComponent: Type<unknown>;
|
|
11
|
+
readonly bridge: NgNativeBridge;
|
|
12
|
+
readonly config: ApplicationConfig;
|
|
13
|
+
readonly appRefPromise?: Promise<ApplicationRef>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Bootstraps an Angular root component against the Rust `RenderEngine` via `globalThis.__NG_NATIVE__`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function bootstrapNativeApplication(rootComponent: Type<unknown>, appConfig?: ApplicationConfig): NativeBootstrapContext;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { makeEnvironmentProviders, provideZonelessChangeDetection, RendererFactory2, } from '@angular/core';
|
|
2
|
+
import { bootstrapApplication } from '@angular/platform-browser';
|
|
3
|
+
import { ensureNgNativeBridge } from './bridge.js';
|
|
4
|
+
import { provideNativeImageLoader } from './image-loader.js';
|
|
5
|
+
import { NativeRendererFactory2 } from './native-renderer.js';
|
|
6
|
+
import { provideNativeTitle } from './native-title.js';
|
|
7
|
+
import { provideNativeErrorHandler, provideNativeKeyEvents, provideSystemLocale, } from './system-providers.js';
|
|
8
|
+
import { provideNativeViewportScroller } from './viewport-scroller.js';
|
|
9
|
+
/**
|
|
10
|
+
* Provides the Angular Native Desktop platform (`NativeRendererFactory2`, Zoneless reactivity,
|
|
11
|
+
* OS image asset loader, native window title, viewport scroller, system locale/timezone,
|
|
12
|
+
* key shortcut plugin, and native error handler).
|
|
13
|
+
*/
|
|
14
|
+
export function provideNativePlatform() {
|
|
15
|
+
ensureNgNativeBridge();
|
|
16
|
+
return makeEnvironmentProviders([
|
|
17
|
+
provideZonelessChangeDetection(),
|
|
18
|
+
NativeRendererFactory2,
|
|
19
|
+
{ provide: RendererFactory2, useExisting: NativeRendererFactory2 },
|
|
20
|
+
provideNativeImageLoader(),
|
|
21
|
+
provideNativeTitle(),
|
|
22
|
+
provideNativeViewportScroller(),
|
|
23
|
+
provideSystemLocale(),
|
|
24
|
+
provideNativeErrorHandler(),
|
|
25
|
+
provideNativeKeyEvents(),
|
|
26
|
+
]);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Bootstraps an Angular root component against the Rust `RenderEngine` via `globalThis.__NG_NATIVE__`.
|
|
30
|
+
*/
|
|
31
|
+
export function bootstrapNativeApplication(rootComponent, appConfig) {
|
|
32
|
+
const bridge = ensureNgNativeBridge();
|
|
33
|
+
const mergedConfig = {
|
|
34
|
+
providers: [provideNativePlatform(), ...(appConfig?.providers ?? [])],
|
|
35
|
+
};
|
|
36
|
+
const isIvyComponent = 'ɵcmp' in rootComponent;
|
|
37
|
+
const appRefPromise = isIvyComponent
|
|
38
|
+
? bootstrapApplication(rootComponent, mergedConfig)
|
|
39
|
+
: undefined;
|
|
40
|
+
return {
|
|
41
|
+
rootComponent,
|
|
42
|
+
bridge,
|
|
43
|
+
config: mergedConfig,
|
|
44
|
+
...(appRefPromise ? { appRefPromise } : {}),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { EnvironmentProviders, ErrorHandler } from '@angular/core';
|
|
2
|
+
import { EventManagerPlugin } from '@angular/platform-browser';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
export interface NativeKeyEventPayload {
|
|
5
|
+
key?: string;
|
|
6
|
+
ctrlKey?: boolean;
|
|
7
|
+
shiftKey?: boolean;
|
|
8
|
+
altKey?: boolean;
|
|
9
|
+
metaKey?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Matches Angular template keyboard shorthand syntax (e.g. `keydown.control.f`,
|
|
13
|
+
* `keydown.escape`, `keydown.alt.arrowleft`) against native OS key event payloads.
|
|
14
|
+
*/
|
|
15
|
+
export declare function matchesKeyboardEvent(eventName: string, payload: NativeKeyEventPayload): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Angular `EventManagerPlugin` translating `(keydown.<mod>.<key>)` and `(keyup.<mod>.<key>)`
|
|
18
|
+
* bindings onto native `GtkShortcutController` / `GtkEventControllerKey` listeners.
|
|
19
|
+
*/
|
|
20
|
+
export declare class NativeKeyEventsPlugin extends EventManagerPlugin {
|
|
21
|
+
private readonly bridge;
|
|
22
|
+
private readonly rendererFactory;
|
|
23
|
+
private readonly enabledKeyboardNodes;
|
|
24
|
+
constructor();
|
|
25
|
+
supports(eventName: string): boolean;
|
|
26
|
+
addEventListener(element: unknown, eventName: string, handler: (event: unknown) => void): () => void;
|
|
27
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NativeKeyEventsPlugin, never>;
|
|
28
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Angular `ErrorHandler` forwarding unhandled exceptions into the Rust OS system log
|
|
32
|
+
* (`journald` / `os_log` / Windows Event Log) and updating a reactive `lastError` Signal.
|
|
33
|
+
*/
|
|
34
|
+
export declare class NativeSystemErrorHandler implements ErrorHandler {
|
|
35
|
+
private readonly bridge;
|
|
36
|
+
readonly lastError: import("@angular/core").WritableSignal<string | null>;
|
|
37
|
+
handleError(error: unknown): void;
|
|
38
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NativeSystemErrorHandler, never>;
|
|
39
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
40
|
+
}
|
|
41
|
+
export declare function provideSystemLocale(): EnvironmentProviders;
|
|
42
|
+
export declare function provideNativeErrorHandler(): EnvironmentProviders;
|
|
43
|
+
export declare function provideNativeKeyEvents(): EnvironmentProviders;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { DATE_PIPE_DEFAULT_TIMEZONE } from '@angular/common';
|
|
2
|
+
import { ErrorHandler, inject, Injectable, LOCALE_ID, makeEnvironmentProviders, signal, } from '@angular/core';
|
|
3
|
+
import { EVENT_MANAGER_PLUGINS, EventManagerPlugin } from '@angular/platform-browser';
|
|
4
|
+
import { ensureNgNativeBridge } from './bridge.js';
|
|
5
|
+
import { NativeRendererFactory2 } from './native-renderer.js';
|
|
6
|
+
import * as i0 from "@angular/core";
|
|
7
|
+
function injectOptionalRendererFactory() {
|
|
8
|
+
try {
|
|
9
|
+
return inject(NativeRendererFactory2, { optional: true });
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function normalizeKeyToken(raw) {
|
|
16
|
+
const lower = raw.trim().toLowerCase();
|
|
17
|
+
if (lower === 'esc')
|
|
18
|
+
return 'escape';
|
|
19
|
+
if (lower === 'spacebar' || lower === ' ')
|
|
20
|
+
return 'space';
|
|
21
|
+
if (lower === 'return')
|
|
22
|
+
return 'enter';
|
|
23
|
+
return lower;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Matches Angular template keyboard shorthand syntax (e.g. `keydown.control.f`,
|
|
27
|
+
* `keydown.escape`, `keydown.alt.arrowleft`) against native OS key event payloads.
|
|
28
|
+
*/
|
|
29
|
+
export function matchesKeyboardEvent(eventName, payload) {
|
|
30
|
+
const parts = eventName.trim().toLowerCase().split('.');
|
|
31
|
+
if (parts.length < 2 || (parts[0] !== 'keydown' && parts[0] !== 'keyup')) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
const targetKey = normalizeKeyToken(parts[parts.length - 1] ?? '');
|
|
35
|
+
const actualKey = normalizeKeyToken(payload.key ?? '');
|
|
36
|
+
if (!targetKey || actualKey !== targetKey) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
const modifiers = new Set(parts.slice(1, -1));
|
|
40
|
+
const wantCtrl = modifiers.has('control') || modifiers.has('ctrl');
|
|
41
|
+
const wantShift = modifiers.has('shift');
|
|
42
|
+
const wantAlt = modifiers.has('alt');
|
|
43
|
+
const wantMeta = modifiers.has('meta') || modifiers.has('cmd') || modifiers.has('super');
|
|
44
|
+
return (wantCtrl === Boolean(payload.ctrlKey) &&
|
|
45
|
+
wantShift === Boolean(payload.shiftKey) &&
|
|
46
|
+
wantAlt === Boolean(payload.altKey) &&
|
|
47
|
+
wantMeta === Boolean(payload.metaKey));
|
|
48
|
+
}
|
|
49
|
+
function normalizeKeyPayload(raw) {
|
|
50
|
+
if (typeof raw === 'string') {
|
|
51
|
+
const trimmed = raw.trim();
|
|
52
|
+
if (trimmed.startsWith('{') && trimmed.endsWith('}')) {
|
|
53
|
+
try {
|
|
54
|
+
return JSON.parse(trimmed);
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return { key: raw };
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return { key: raw };
|
|
61
|
+
}
|
|
62
|
+
if (raw && typeof raw === 'object' && !Array.isArray(raw)) {
|
|
63
|
+
const obj = raw;
|
|
64
|
+
const rawValue = obj['value'];
|
|
65
|
+
if (typeof rawValue === 'string') {
|
|
66
|
+
const trimmed = rawValue.trim();
|
|
67
|
+
if (trimmed.startsWith('{') && trimmed.endsWith('}')) {
|
|
68
|
+
try {
|
|
69
|
+
return { ...obj, ...JSON.parse(trimmed) };
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return obj;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return obj;
|
|
77
|
+
}
|
|
78
|
+
return {};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Angular `EventManagerPlugin` translating `(keydown.<mod>.<key>)` and `(keyup.<mod>.<key>)`
|
|
82
|
+
* bindings onto native `GtkShortcutController` / `GtkEventControllerKey` listeners.
|
|
83
|
+
*/
|
|
84
|
+
export class NativeKeyEventsPlugin extends EventManagerPlugin {
|
|
85
|
+
bridge = ensureNgNativeBridge();
|
|
86
|
+
rendererFactory = injectOptionalRendererFactory();
|
|
87
|
+
enabledKeyboardNodes = new Set();
|
|
88
|
+
constructor() {
|
|
89
|
+
super(null);
|
|
90
|
+
}
|
|
91
|
+
supports(eventName) {
|
|
92
|
+
const lower = eventName.trim().toLowerCase();
|
|
93
|
+
return (lower.startsWith('keydown.') || lower.startsWith('keyup.')) && lower.length > 8;
|
|
94
|
+
}
|
|
95
|
+
addEventListener(element, eventName, handler) {
|
|
96
|
+
const baseEvent = eventName.trim().toLowerCase().startsWith('keyup.') ? 'keyup' : 'keydown';
|
|
97
|
+
const primaryWin = this.rendererFactory?.getPrimaryWindowId() ?? 'win';
|
|
98
|
+
const nodeId = typeof element === 'string'
|
|
99
|
+
? element === 'window' || element === 'document' || element === 'body'
|
|
100
|
+
? primaryWin
|
|
101
|
+
: element
|
|
102
|
+
: typeof element === 'object' && element !== null && 'id' in element
|
|
103
|
+
? 'isVirtual' in element && element.isVirtual
|
|
104
|
+
? primaryWin
|
|
105
|
+
: String(element.id)
|
|
106
|
+
: primaryWin;
|
|
107
|
+
if (!this.enabledKeyboardNodes.has(nodeId)) {
|
|
108
|
+
this.enabledKeyboardNodes.add(nodeId);
|
|
109
|
+
this.bridge.setAttribute(nodeId, 'event-mask', 'keyboard');
|
|
110
|
+
}
|
|
111
|
+
return this.bridge.listen(nodeId, baseEvent, (rawEvent) => {
|
|
112
|
+
const payload = normalizeKeyPayload(rawEvent);
|
|
113
|
+
if (matchesKeyboardEvent(eventName, payload)) {
|
|
114
|
+
handler(payload);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.6", ngImport: i0, type: NativeKeyEventsPlugin, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
119
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.6", ngImport: i0, type: NativeKeyEventsPlugin });
|
|
120
|
+
}
|
|
121
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.6", ngImport: i0, type: NativeKeyEventsPlugin, decorators: [{
|
|
122
|
+
type: Injectable
|
|
123
|
+
}], ctorParameters: () => [] });
|
|
124
|
+
/**
|
|
125
|
+
* Angular `ErrorHandler` forwarding unhandled exceptions into the Rust OS system log
|
|
126
|
+
* (`journald` / `os_log` / Windows Event Log) and updating a reactive `lastError` Signal.
|
|
127
|
+
*/
|
|
128
|
+
export class NativeSystemErrorHandler {
|
|
129
|
+
bridge = ensureNgNativeBridge();
|
|
130
|
+
lastError = signal(null, /* @ts-ignore */
|
|
131
|
+
...(ngDevMode ? [{ debugName: "lastError" }] : /* istanbul ignore next */ []));
|
|
132
|
+
handleError(error) {
|
|
133
|
+
const message = error instanceof Error ? `${error.name}: ${error.message}` : String(error);
|
|
134
|
+
this.lastError.set(message);
|
|
135
|
+
this.bridge.logSystemError(message);
|
|
136
|
+
}
|
|
137
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.6", ngImport: i0, type: NativeSystemErrorHandler, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
138
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.6", ngImport: i0, type: NativeSystemErrorHandler, providedIn: 'root' });
|
|
139
|
+
}
|
|
140
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.6", ngImport: i0, type: NativeSystemErrorHandler, decorators: [{
|
|
141
|
+
type: Injectable,
|
|
142
|
+
args: [{ providedIn: 'root' }]
|
|
143
|
+
}] });
|
|
144
|
+
export function provideSystemLocale() {
|
|
145
|
+
return makeEnvironmentProviders([
|
|
146
|
+
{ provide: LOCALE_ID, useFactory: () => ensureNgNativeBridge().getSystemLocale() },
|
|
147
|
+
{
|
|
148
|
+
provide: DATE_PIPE_DEFAULT_TIMEZONE,
|
|
149
|
+
useFactory: () => ensureNgNativeBridge().getSystemTimezone(),
|
|
150
|
+
},
|
|
151
|
+
]);
|
|
152
|
+
}
|
|
153
|
+
export function provideNativeErrorHandler() {
|
|
154
|
+
return makeEnvironmentProviders([
|
|
155
|
+
NativeSystemErrorHandler,
|
|
156
|
+
{ provide: ErrorHandler, useExisting: NativeSystemErrorHandler },
|
|
157
|
+
]);
|
|
158
|
+
}
|
|
159
|
+
export function provideNativeKeyEvents() {
|
|
160
|
+
return makeEnvironmentProviders([
|
|
161
|
+
{ provide: EVENT_MANAGER_PLUGINS, useClass: NativeKeyEventsPlugin, multi: true },
|
|
162
|
+
]);
|
|
163
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ViewportScroller } from '@angular/common';
|
|
2
|
+
import { EnvironmentProviders } from '@angular/core';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* DOM-free Angular `ViewportScroller` backed by native `GtkScrolledWindow` adjustments
|
|
6
|
+
* (`NSScrollView` on macOS, `ScrollViewer` on WinUI 3).
|
|
7
|
+
*/
|
|
8
|
+
export declare class NativeViewportScroller extends ViewportScroller {
|
|
9
|
+
private readonly bridge;
|
|
10
|
+
private readonly rendererFactory;
|
|
11
|
+
private scrollPosition;
|
|
12
|
+
private offsetFn;
|
|
13
|
+
private scrollRestoration;
|
|
14
|
+
private targetScrollId;
|
|
15
|
+
setOffset(offset: [number, number] | (() => [number, number])): void;
|
|
16
|
+
getScrollPosition(): [number, number];
|
|
17
|
+
scrollToPosition(position: [number, number]): void;
|
|
18
|
+
scrollToAnchor(anchor: string): void;
|
|
19
|
+
setHistoryScrollRestoration(scrollRestoration: 'auto' | 'manual'): void;
|
|
20
|
+
getHistoryScrollRestoration(): 'auto' | 'manual';
|
|
21
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NativeViewportScroller, never>;
|
|
22
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
23
|
+
}
|
|
24
|
+
export declare function provideNativeViewportScroller(): EnvironmentProviders;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { ViewportScroller } from '@angular/common';
|
|
2
|
+
import { inject, Injectable, makeEnvironmentProviders } from '@angular/core';
|
|
3
|
+
import { ensureNgNativeBridge } from './bridge.js';
|
|
4
|
+
import { NativeRendererFactory2 } from './native-renderer.js';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
function injectOptionalRendererFactory() {
|
|
7
|
+
try {
|
|
8
|
+
return inject(NativeRendererFactory2, { optional: true });
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* DOM-free Angular `ViewportScroller` backed by native `GtkScrolledWindow` adjustments
|
|
16
|
+
* (`NSScrollView` on macOS, `ScrollViewer` on WinUI 3).
|
|
17
|
+
*/
|
|
18
|
+
export class NativeViewportScroller extends ViewportScroller {
|
|
19
|
+
bridge = ensureNgNativeBridge();
|
|
20
|
+
rendererFactory = injectOptionalRendererFactory();
|
|
21
|
+
scrollPosition = [0, 0];
|
|
22
|
+
offsetFn = () => [0, 0];
|
|
23
|
+
scrollRestoration = 'auto';
|
|
24
|
+
targetScrollId() {
|
|
25
|
+
return this.rendererFactory?.getPrimaryScrollId() ?? 'scroll';
|
|
26
|
+
}
|
|
27
|
+
setOffset(offset) {
|
|
28
|
+
this.offsetFn = typeof offset === 'function' ? offset : () => offset;
|
|
29
|
+
}
|
|
30
|
+
getScrollPosition() {
|
|
31
|
+
return [this.scrollPosition[0], this.scrollPosition[1]];
|
|
32
|
+
}
|
|
33
|
+
scrollToPosition(position) {
|
|
34
|
+
const [ox, oy] = this.offsetFn();
|
|
35
|
+
const x = Math.max(0, position[0] - ox);
|
|
36
|
+
const y = Math.max(0, position[1] - oy);
|
|
37
|
+
this.scrollPosition = [x, y];
|
|
38
|
+
this.bridge.setAttribute(this.targetScrollId(), 'scroll-to', `${x},${y}`);
|
|
39
|
+
}
|
|
40
|
+
scrollToAnchor(anchor) {
|
|
41
|
+
const clean = anchor.replace(/^#/, '').trim();
|
|
42
|
+
if (!clean) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
this.bridge.setAttribute(this.targetScrollId(), 'scroll-anchor', clean);
|
|
46
|
+
}
|
|
47
|
+
setHistoryScrollRestoration(scrollRestoration) {
|
|
48
|
+
this.scrollRestoration = scrollRestoration;
|
|
49
|
+
}
|
|
50
|
+
getHistoryScrollRestoration() {
|
|
51
|
+
return this.scrollRestoration;
|
|
52
|
+
}
|
|
53
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.6", ngImport: i0, type: NativeViewportScroller, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
54
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.6", ngImport: i0, type: NativeViewportScroller, providedIn: 'root' });
|
|
55
|
+
}
|
|
56
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.6", ngImport: i0, type: NativeViewportScroller, decorators: [{
|
|
57
|
+
type: Injectable,
|
|
58
|
+
args: [{ providedIn: 'root' }]
|
|
59
|
+
}] });
|
|
60
|
+
export function provideNativeViewportScroller() {
|
|
61
|
+
return makeEnvironmentProviders([
|
|
62
|
+
NativeViewportScroller,
|
|
63
|
+
{ provide: ViewportScroller, useExisting: NativeViewportScroller },
|
|
64
|
+
]);
|
|
65
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { TemplateRef } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
/** Inclusive start / exclusive end index range and spacer heights for a virtualized viewport. */
|
|
4
|
+
export interface VirtualSliceRange {
|
|
5
|
+
startIndex: number;
|
|
6
|
+
endIndex: number;
|
|
7
|
+
totalItems: number;
|
|
8
|
+
topSpacerHeight: number;
|
|
9
|
+
bottomSpacerHeight: number;
|
|
10
|
+
}
|
|
11
|
+
/** Template context provided to each rendered item row in `<ng-virtual-list>`. */
|
|
12
|
+
export interface NativeVirtualItemContext<T> {
|
|
13
|
+
$implicit: T;
|
|
14
|
+
index: number;
|
|
15
|
+
}
|
|
16
|
+
/** Internal materialized slice entry paired with its stable tracking key. */
|
|
17
|
+
export interface NativeVirtualListEntry<T> {
|
|
18
|
+
item: T;
|
|
19
|
+
index: number;
|
|
20
|
+
key: unknown;
|
|
21
|
+
}
|
|
22
|
+
/** Payload emitted when a row inside `<ng-virtual-list>` is activated natively. */
|
|
23
|
+
export interface NativeVirtualRowActivatedEvent<T> {
|
|
24
|
+
index: number;
|
|
25
|
+
item: T;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Computes the visible item slice and spacer heights for a fixed-row-height viewport.
|
|
29
|
+
*/
|
|
30
|
+
export declare function computeVirtualSliceRange(totalItems: number, scrollTop: number, viewportHeight: number, itemHeight: number, overscan?: number): VirtualSliceRange;
|
|
31
|
+
/**
|
|
32
|
+
* Virtualized native desktop list component rendering only the visible viewport slice + overscan
|
|
33
|
+
* inside an `<ng-scroll>` + `<ng-list>` hierarchy to keep native widget counts bounded at scale.
|
|
34
|
+
*/
|
|
35
|
+
export declare class NativeVirtualListComponent<T = unknown> {
|
|
36
|
+
readonly items: import("@angular/core").InputSignal<readonly T[]>;
|
|
37
|
+
readonly itemHeight: import("@angular/core").InputSignal<number>;
|
|
38
|
+
readonly viewportHeight: import("@angular/core").InputSignal<number>;
|
|
39
|
+
readonly overscan: import("@angular/core").InputSignal<number>;
|
|
40
|
+
readonly selectionMode: import("@angular/core").InputSignal<"none" | "single" | "browse" | "multiple">;
|
|
41
|
+
readonly showSeparators: import("@angular/core").InputSignal<boolean>;
|
|
42
|
+
readonly trackBy: import("@angular/core").InputSignal<(index: number, item: T) => unknown>;
|
|
43
|
+
readonly itemTemplateInput: import("@angular/core").InputSignal<TemplateRef<NativeVirtualItemContext<T>> | null>;
|
|
44
|
+
readonly projectedTemplate: import("@angular/core").Signal<TemplateRef<NativeVirtualItemContext<T>> | undefined>;
|
|
45
|
+
readonly rangeChange: import("@angular/core").OutputEmitterRef<VirtualSliceRange>;
|
|
46
|
+
readonly rowActivated: import("@angular/core").OutputEmitterRef<NativeVirtualRowActivatedEvent<T>>;
|
|
47
|
+
readonly scrollTop: import("@angular/core").WritableSignal<number>;
|
|
48
|
+
readonly resolvedTemplate: import("@angular/core").Signal<TemplateRef<NativeVirtualItemContext<T>> | null>;
|
|
49
|
+
readonly range: import("@angular/core").Signal<VirtualSliceRange>;
|
|
50
|
+
readonly visibleEntries: import("@angular/core").Signal<readonly NativeVirtualListEntry<T>[]>;
|
|
51
|
+
private lastEmittedRangeKey;
|
|
52
|
+
constructor();
|
|
53
|
+
onNativeScroll(event: unknown): void;
|
|
54
|
+
onRowActivated(event: unknown): void;
|
|
55
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NativeVirtualListComponent<any>, never>;
|
|
56
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<NativeVirtualListComponent<any>, "ng-virtual-list", never, { "items": { "alias": "items"; "required": false; "isSignal": true; }; "itemHeight": { "alias": "itemHeight"; "required": false; "isSignal": true; }; "viewportHeight": { "alias": "viewportHeight"; "required": false; "isSignal": true; }; "overscan": { "alias": "overscan"; "required": false; "isSignal": true; }; "selectionMode": { "alias": "selectionMode"; "required": false; "isSignal": true; }; "showSeparators": { "alias": "showSeparators"; "required": false; "isSignal": true; }; "trackBy": { "alias": "trackBy"; "required": false; "isSignal": true; }; "itemTemplateInput": { "alias": "itemTemplate"; "required": false; "isSignal": true; }; }, { "rangeChange": "rangeChange"; "rowActivated": "rowActivated"; }, ["projectedTemplate"], never, true, never>;
|
|
57
|
+
}
|