@nstudio/nativescript-effect-ui 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/README.md +24 -18
  2. package/dist/desktop/html-services.d.ts +33 -0
  3. package/dist/desktop/html-services.d.ts.map +1 -0
  4. package/dist/desktop/html-services.js +113 -0
  5. package/dist/desktop/html-services.js.map +1 -0
  6. package/dist/linux/LinuxHost.d.ts +108 -0
  7. package/dist/linux/LinuxHost.d.ts.map +1 -0
  8. package/dist/linux/LinuxHost.js +601 -0
  9. package/dist/linux/LinuxHost.js.map +1 -0
  10. package/dist/linux/index.d.ts +3 -0
  11. package/dist/linux/index.d.ts.map +1 -0
  12. package/dist/linux/index.js +3 -0
  13. package/dist/linux/index.js.map +1 -0
  14. package/dist/linux/platform.d.ts +17 -0
  15. package/dist/linux/platform.d.ts.map +1 -0
  16. package/dist/linux/platform.js +119 -0
  17. package/dist/linux/platform.js.map +1 -0
  18. package/dist/platform/index.d.ts +1 -1
  19. package/dist/platform/index.d.ts.map +1 -1
  20. package/dist/platform/native.d.ts +1 -1
  21. package/dist/platform/native.d.ts.map +1 -1
  22. package/dist/platform/native.js +89 -14
  23. package/dist/platform/native.js.map +1 -1
  24. package/dist/windows/WindowsHost.d.ts +107 -0
  25. package/dist/windows/WindowsHost.d.ts.map +1 -0
  26. package/dist/windows/WindowsHost.js +651 -0
  27. package/dist/windows/WindowsHost.js.map +1 -0
  28. package/dist/windows/index.d.ts +3 -0
  29. package/dist/windows/index.d.ts.map +1 -0
  30. package/dist/windows/index.js +3 -0
  31. package/dist/windows/index.js.map +1 -0
  32. package/dist/windows/platform.d.ts +12 -0
  33. package/dist/windows/platform.d.ts.map +1 -0
  34. package/dist/windows/platform.js +105 -0
  35. package/dist/windows/platform.js.map +1 -0
  36. package/package.json +31 -2
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # @nstudio/nativescript-effect-ui
2
2
 
3
- NativeScript and macOS AppKit rendering hosts, platform Effect Layers, and pure-TypeScript native primitives for [`@effect/ui`](https://github.com/Effect-TS/ui).
3
+ NativeScript rendering hosts for iOS, Android, macOS, Windows, and Linux, platform Effect Layers, and pure-TypeScript native primitives for [`@effect/ui`](https://github.com/Effect-TS/ui).
4
4
 
5
- Mount standard `@effect/ui/html` (`Html.component`) trees directly onto native iOS, Android, and macOS views with zero WebViews, or compose native UIKit/AppKit/Android views directly via `NativeHost`.
5
+ Mount standard `@effect/ui/html` (`Html.component`) trees directly onto native iOS, Android, macOS (AppKit), Windows (WinUI 3 / WinRT), and Linux (GTK4) views with zero WebViews, or compose native views directly via `NativeHost`.
6
6
 
7
7
  ## Installation
8
8
 
@@ -18,14 +18,16 @@ npm install https://pkg.pr.new/Effect-TS/ui/@effect/ui@5cb34b2
18
18
 
19
19
  Install the optional platform peer dependencies for the targets you use:
20
20
 
21
- - **iOS and Android (`MasonHost` / `NativeHost`)**: `@nativescript/core` and `@triniwiz/nativescript-masonkit`
21
+ - **iOS, Android, Windows, and Linux (`MasonHost` / `NativeHost`)**: `@nativescript/core` and `@triniwiz/nativescript-masonkit` (plus `@nativescript/windows` or `@nativescript/linux` for desktop V8 runtimes)
22
22
  - **macOS Desktop (`MacosHost`)**: `@nativescript/macos-node-api`
23
+ - **Windows Desktop (`WindowsHost`)**: `@nativescript/windows` or `@nativescript/windows-napi`
24
+ - **Linux Desktop (`LinuxHost`)**: `@nativescript/linux` or `@nativescript/linux-napi`
23
25
 
24
26
  ## Quick Start
25
27
 
26
- ### iOS and Android (`MasonHost`)
28
+ ### iOS, Android, Windows, and Linux (`MasonHost`)
27
29
 
28
- Mounts unmodified `@effect/ui/html` components onto native iOS and Android views backed by MasonKit's Rust/Taffy CSS Flexbox and Grid layout engine.
30
+ Mounts unmodified `@effect/ui/html` components onto native views backed by MasonKit's Rust/Taffy CSS Flexbox and Grid layout engine.
29
31
 
30
32
  ```ts
31
33
  import { MasonHost } from '@nstudio/nativescript-effect-ui/mason';
@@ -38,32 +40,36 @@ MasonHost.run(App, {}, {
38
40
  });
39
41
  ```
40
42
 
41
- ### macOS Desktop (`MacosHost`)
43
+ ### macOS, Windows, and Linux Desktop (`MacosHost` / `WindowsHost` / `LinuxHost`)
42
44
 
43
- Mounts the same `@effect/ui/html` components onto real AppKit views (`NSWindow`, `NSView`, `NSTextField`, `NSButton`, `NSScrollView`) with zero WebViews or Electron.
45
+ Mount the exact same `@effect/ui/html` components onto native AppKit, WinUI/WinRT, or GTK4 windows with zero WebViews or Electron:
44
46
 
45
47
  ```ts
48
+ // macOS (AppKit)
46
49
  import { MacosHost, MacosPlatformLayer } from '@nstudio/nativescript-effect-ui/macos';
47
- import { App } from './App';
50
+ await MacosHost.run(App, {}, { title: 'Effect Pulse', width: 460, height: 820, layer: MacosPlatformLayer });
48
51
 
49
- await MacosHost.run(App, {}, {
50
- title: 'Effect Pulse',
51
- width: 460,
52
- height: 820,
53
- layer: MacosPlatformLayer,
54
- });
52
+ // Windows (WinUI 3 / XAML Islands / WinRT Composition)
53
+ import { WindowsHost, WindowsPlatformLayer } from '@nstudio/nativescript-effect-ui/windows';
54
+ await WindowsHost.run(App, {}, { title: 'Effect Pulse', width: 460, height: 820, layer: WindowsPlatformLayer });
55
+
56
+ // Linux (GTK4)
57
+ import { LinuxHost, LinuxPlatformLayer } from '@nstudio/nativescript-effect-ui/linux';
58
+ await LinuxHost.run(App, {}, { title: 'Effect Pulse', width: 460, height: 820, layer: LinuxPlatformLayer });
55
59
  ```
56
60
 
57
61
  ## Subpath Exports
58
62
 
59
63
  | Subpath | Description |
60
64
  | --- | --- |
61
- | `@nstudio/nativescript-effect-ui` | Platform service contracts (`Haptics`, `Share`, `Storage`, `DeviceInfo`, `PlatformAppearance`) |
62
- | `@nstudio/nativescript-effect-ui/mason` | `MasonHost` for standard `@effect/ui/html` on native iOS and Android |
65
+ | `@nstudio/nativescript-effect-ui` | Platform service contracts (`Haptics`, `DeviceInfo`, `AppLifecycle`, `Clipboard`) |
66
+ | `@nstudio/nativescript-effect-ui/mason` | `MasonHost` for standard `@effect/ui/html` on iOS, Android, Windows, and Linux |
63
67
  | `@nstudio/nativescript-effect-ui/macos` | `MacosHost` and `MacosPlatformLayer` for native macOS AppKit |
68
+ | `@nstudio/nativescript-effect-ui/windows` | `WindowsHost` and `WindowsPlatformLayer` for native Windows (WinUI 3 / WinRT) |
69
+ | `@nstudio/nativescript-effect-ui/linux` | `LinuxHost` and `LinuxPlatformLayer` for native Linux (GTK4) |
64
70
  | `@nstudio/nativescript-effect-ui/native` | `NativeHost`, `Native`, and `NativeCommand` for direct NativeScript view vocabularies |
65
71
  | `@nstudio/nativescript-effect-ui/platform` | Shared platform service interfaces and Web/fallback layers |
66
- | `@nstudio/nativescript-effect-ui/platform/native` | NativeScript `NativePlatformLayer` implementations for iOS and Android |
72
+ | `@nstudio/nativescript-effect-ui/platform/native` | NativeScript `NativePlatformLayer` implementations for iOS, Android, Windows, and Linux |
67
73
  | `@nstudio/nativescript-effect-ui/motion` | UI-thread spring and timing motion (`UIViewPropertyAnimator` / Android `Animator`) |
68
74
  | `@nstudio/nativescript-effect-ui/sheet` | Native bottom sheets (`UISheetPresentationController` / Android `BottomSheetDialog`) |
69
75
  | `@nstudio/nativescript-effect-ui/list` | Virtualized recycled lists (`UITableView` / `RecyclerView`) |
@@ -74,7 +80,7 @@ await MacosHost.run(App, {}, {
74
80
 
75
81
  ## Examples and Documentation
76
82
 
77
- Full monorepo with shared Web, iOS, Android, and macOS apps: [github.com/nstudio/ns-effect-ui](https://github.com/nstudio/ns-effect-ui)
83
+ Full monorepo with shared Web, iOS, Android, macOS, Windows, and Linux apps: [github.com/nstudio/ns-effect-ui](https://github.com/nstudio/ns-effect-ui)
78
84
 
79
85
  ## License
80
86
 
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Shared desktop host utilities reused across `MacosHost`, `WindowsHost`,
3
+ * and `LinuxHost`: Effect UI HTML services (`Html.Host` + `HtmlSubscription`),
4
+ * RGBA formatting helpers, and deterministic fallback text measurement.
5
+ */
6
+ import { Html } from '@effect/ui/html';
7
+ import * as Context from 'effect/Context';
8
+ import type { ComputedBoxStyle, RgbaColor } from '../macos/styles.js';
9
+ export { layoutTree, measureNode, type LayoutNode, type Rect, type TextMeasurer, } from '../macos/layout.js';
10
+ export { darkPalette, hex, lightPalette, resolveMacosStyle as resolveDesktopStyle, type ComputedBoxStyle, type RgbaColor, type ThemePalette, } from '../macos/styles.js';
11
+ /**
12
+ * Provides the standard `@effect/ui/html` host services (`Html.Host`,
13
+ * `AnimationFrames`, `MediaQueries`, `GlobalEvents`) on desktop runtimes.
14
+ */
15
+ export declare function makeDesktopHtmlServices(getDarkMode?: () => boolean): Context.Context<Html.Host>;
16
+ /**
17
+ * Deterministic cross-platform text size estimator used by desktop hosts when
18
+ * a native platform text layout engine is unavailable or in headless tests.
19
+ */
20
+ export declare function estimateDesktopTextSize(text: string, style: ComputedBoxStyle, maxWidth: number): {
21
+ readonly width: number;
22
+ readonly height: number;
23
+ };
24
+ /** Converts normalized `[0..1]` RGBA to 8-bit `{ A, R, G, B }` (WinRT / WinUI `Color`). */
25
+ export declare function toByteArgb(c: RgbaColor): {
26
+ readonly A: number;
27
+ readonly R: number;
28
+ readonly G: number;
29
+ readonly B: number;
30
+ };
31
+ /** Converts normalized `[0..1]` RGBA to CSS `rgba(r, g, b, a)` (GTK4 CSS provider). */
32
+ export declare function toCssRgba(c: RgbaColor): string;
33
+ //# sourceMappingURL=html-services.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html-services.d.ts","sourceRoot":"","sources":["../../src/desktop/html-services.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,IAAI,EAAoB,MAAM,iBAAiB,CAAC;AACzD,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEtE,OAAO,EACL,UAAU,EACV,WAAW,EACX,KAAK,UAAU,EACf,KAAK,IAAI,EACT,KAAK,YAAY,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,WAAW,EACX,GAAG,EACH,YAAY,EACZ,iBAAiB,IAAI,mBAAmB,EACxC,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,YAAY,GAClB,MAAM,oBAAoB,CAAC;AAE5B;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,WAAW,CAAC,EAAE,MAAM,OAAO,GAC1B,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAoD5B;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,gBAAgB,EACvB,QAAQ,EAAE,MAAM,GACf;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CA0BrD;AAED,2FAA2F;AAC3F,wBAAgB,UAAU,CAAC,CAAC,EAAE,SAAS,GAAG;IACxC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;CACpB,CAOA;AAED,uFAAuF;AACvF,wBAAgB,SAAS,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM,CAM9C"}
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Shared desktop host utilities reused across `MacosHost`, `WindowsHost`,
3
+ * and `LinuxHost`: Effect UI HTML services (`Html.Host` + `HtmlSubscription`),
4
+ * RGBA formatting helpers, and deterministic fallback text measurement.
5
+ */
6
+ import { Html, HtmlSubscription } from '@effect/ui/html';
7
+ import * as Context from 'effect/Context';
8
+ export { layoutTree, measureNode, } from '../macos/layout.js';
9
+ export { darkPalette, hex, lightPalette, resolveMacosStyle as resolveDesktopStyle, } from '../macos/styles.js';
10
+ /**
11
+ * Provides the standard `@effect/ui/html` host services (`Html.Host`,
12
+ * `AnimationFrames`, `MediaQueries`, `GlobalEvents`) on desktop runtimes.
13
+ */
14
+ export function makeDesktopHtmlServices(getDarkMode) {
15
+ return Context.make(Html.Host, {
16
+ focus: () => { },
17
+ blur: () => { },
18
+ scrollIntoView: () => { },
19
+ measure: (el) => {
20
+ const f = el?.layoutNode?.frame;
21
+ return {
22
+ x: f?.x ?? 0,
23
+ y: f?.y ?? 0,
24
+ width: f?.width ?? 0,
25
+ height: f?.height ?? 0,
26
+ top: f?.y ?? 0,
27
+ left: f?.x ?? 0,
28
+ right: (f?.x ?? 0) + (f?.width ?? 0),
29
+ bottom: (f?.y ?? 0) + (f?.height ?? 0),
30
+ };
31
+ },
32
+ select: () => { },
33
+ requestSubmit: () => false,
34
+ showPicker: () => false,
35
+ }).pipe(Context.add(HtmlSubscription.AnimationFrames, {
36
+ now: () => Date.now(),
37
+ listen: (cb) => {
38
+ let stopped = false;
39
+ let id;
40
+ const tick = () => {
41
+ if (stopped)
42
+ return;
43
+ cb(Date.now());
44
+ if (!stopped)
45
+ id = setTimeout(tick, 16);
46
+ };
47
+ id = setTimeout(tick, 16);
48
+ return () => {
49
+ stopped = true;
50
+ if (id !== undefined)
51
+ clearTimeout(id);
52
+ };
53
+ },
54
+ }), Context.add(HtmlSubscription.MediaQueries, {
55
+ matches: (query) => {
56
+ if (query.includes('prefers-color-scheme: dark')) {
57
+ return Boolean(getDarkMode?.());
58
+ }
59
+ return undefined;
60
+ },
61
+ listen: () => () => { },
62
+ }), Context.add(HtmlSubscription.GlobalEvents, {
63
+ listen: () => () => { },
64
+ }));
65
+ }
66
+ /**
67
+ * Deterministic cross-platform text size estimator used by desktop hosts when
68
+ * a native platform text layout engine is unavailable or in headless tests.
69
+ */
70
+ export function estimateDesktopTextSize(text, style, maxWidth) {
71
+ if (!text)
72
+ return { width: 0, height: Math.ceil(style.fontSize * 1.35) };
73
+ const charW = style.fontSize * (style.fontWeight === 'bold' || style.fontWeight === 'semibold' ? 0.6 : 0.55);
74
+ const lineH = Math.ceil(style.fontSize * 1.38);
75
+ const paragraphs = text.split('\n');
76
+ const limit = Math.max(24, maxWidth);
77
+ let lines = 0;
78
+ let widest = 0;
79
+ for (const para of paragraphs) {
80
+ const rawW = para.length * charW;
81
+ if (rawW <= limit) {
82
+ lines += 1;
83
+ widest = Math.max(widest, rawW);
84
+ }
85
+ else {
86
+ const wrapped = Math.max(1, Math.ceil(rawW / limit));
87
+ lines += wrapped;
88
+ widest = limit;
89
+ }
90
+ }
91
+ return {
92
+ width: Math.min(limit, Math.ceil(widest) + 4),
93
+ height: Math.max(lineH, lines * lineH + 2),
94
+ };
95
+ }
96
+ /** Converts normalized `[0..1]` RGBA to 8-bit `{ A, R, G, B }` (WinRT / WinUI `Color`). */
97
+ export function toByteArgb(c) {
98
+ return {
99
+ A: Math.max(0, Math.min(255, Math.round(c.a * 255))),
100
+ R: Math.max(0, Math.min(255, Math.round(c.r * 255))),
101
+ G: Math.max(0, Math.min(255, Math.round(c.g * 255))),
102
+ B: Math.max(0, Math.min(255, Math.round(c.b * 255))),
103
+ };
104
+ }
105
+ /** Converts normalized `[0..1]` RGBA to CSS `rgba(r, g, b, a)` (GTK4 CSS provider). */
106
+ export function toCssRgba(c) {
107
+ const r = Math.max(0, Math.min(255, Math.round(c.r * 255)));
108
+ const g = Math.max(0, Math.min(255, Math.round(c.g * 255)));
109
+ const b = Math.max(0, Math.min(255, Math.round(c.b * 255)));
110
+ const a = Number(Math.max(0, Math.min(1, c.a)).toFixed(3));
111
+ return `rgba(${r}, ${g}, ${b}, ${a})`;
112
+ }
113
+ //# sourceMappingURL=html-services.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html-services.js","sourceRoot":"","sources":["../../src/desktop/html-services.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,iBAA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AC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;IAC5D,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;IAC5D,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3D,OAAO,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;AACxC,CAAC"}
@@ -0,0 +1,108 @@
1
+ /**
2
+ * `LinuxHost`: a native Linux GTK4 `Renderer.Host` for `@effect/ui`, powered by
3
+ * `@nativescript/linux` (V8 runtime) or `@nativescript/linux-napi` (Node-API
4
+ * GTK4 / GLib addon for Node, Bun, and Deno).
5
+ *
6
+ * Mounts unmodified `@effect/ui/html` (`Html.component(...)`) views directly
7
+ * onto real GTK4 widgets (`GtkWindow`, `GtkScrolledWindow`, `GtkFixed`,
8
+ * `GtkBox`, `GtkLabel`, `GtkButton`, `GtkEntry`) with zero WebViews and zero
9
+ * Electron.
10
+ */
11
+ import type * as Component from '@effect/ui/Component';
12
+ import { Html } from '@effect/ui/html';
13
+ import * as Renderer from '@effect/ui/Renderer';
14
+ import type * as View from '@effect/ui/View';
15
+ import * as Effect from 'effect/Effect';
16
+ import * as Layer from 'effect/Layer';
17
+ import type * as AsyncResult from 'effect/reactivity/AsyncResult';
18
+ import { type ComputedBoxStyle, type LayoutNode, type Rect } from '../desktop/html-services.js';
19
+ export type LinuxRoot<V> = [Renderer.HostOf<V>] extends [Html.Host] ? unknown : {
20
+ readonly 'LinuxHost.mount shows HTML elements. This root vocabulary needs': Renderer.HostOf<V>;
21
+ };
22
+ export interface LinuxNode {
23
+ readonly kind: 'element' | 'text' | 'container';
24
+ readonly tag: string;
25
+ parent: LinuxNode | undefined;
26
+ readonly children: Array<LinuxNode>;
27
+ text: string;
28
+ className: string;
29
+ id: string;
30
+ readonly attrs: Record<string, string | undefined>;
31
+ readonly props: Record<string, unknown>;
32
+ handlers: Readonly<Record<string, View.Handler<unknown, any>>>;
33
+ dispatch: Renderer.Dispatch | undefined;
34
+ gtkWidget: any;
35
+ dialogWindow: any;
36
+ layoutNode: LayoutNode | undefined;
37
+ }
38
+ export interface LinuxWidgetItem {
39
+ readonly node: LinuxNode;
40
+ readonly widgetKey: string;
41
+ readonly frame: Rect;
42
+ readonly style: ComputedBoxStyle;
43
+ readonly cssClass: string;
44
+ readonly cssRule: string;
45
+ readonly text: string | undefined;
46
+ readonly isInteractive: boolean;
47
+ readonly isInput: boolean;
48
+ readonly inputValue: string;
49
+ readonly placeholder: string;
50
+ }
51
+ /**
52
+ * Pluggable rendering backend for `LinuxHost`.
53
+ * Implemented automatically for GTK4 via `@nativescript/linux` or
54
+ * `@nativescript/linux-napi`, or injected directly in unit tests.
55
+ */
56
+ export interface LinuxHostBackend {
57
+ readonly mode: 'gtk4' | 'custom';
58
+ readonly renderFrame: (items: ReadonlyArray<LinuxWidgetItem>, stylesheet: string, contentHeight: number, viewportWidth: number, dark: boolean) => void;
59
+ readonly openDialog?: (dialogNode: LinuxNode, items: ReadonlyArray<LinuxWidgetItem>, stylesheet: string, width: number, height: number, dark: boolean, onClose: () => void) => any;
60
+ readonly updateDialog?: (handle: any, items: ReadonlyArray<LinuxWidgetItem>, stylesheet: string, width: number, height: number, dark: boolean) => void;
61
+ readonly closeDialog?: (handle: any) => void;
62
+ readonly setTitle?: (title: string) => void;
63
+ readonly dispose?: () => void;
64
+ }
65
+ export interface MakeLinuxHostOptions {
66
+ readonly getViewportWidth: () => number;
67
+ readonly getDarkMode: () => boolean;
68
+ readonly backend: LinuxHostBackend;
69
+ readonly onTitle?: ((title: string) => void) | undefined;
70
+ }
71
+ export interface LinuxRunOptions<V extends View.Elements, RF = never, Events = unknown, R = never> {
72
+ readonly title?: string | undefined;
73
+ readonly width?: number | undefined;
74
+ readonly height?: number | undefined;
75
+ readonly appearance?: 'system' | 'light' | 'dark' | undefined;
76
+ readonly layer?: Layer.Layer<R, never, never> | undefined;
77
+ readonly onEmit?: ((event: Events) => void) | undefined;
78
+ readonly fallback?: ((failure: AsyncResult.Failure<never, unknown>, h: View.Helper<never, {}> & View.Tags<V, never>) => View.Content<never, RF>) | undefined;
79
+ /** Optional auto-close timeout in milliseconds (useful for CI/smoke verification). */
80
+ readonly autoCloseMs?: number | undefined;
81
+ }
82
+ export declare function fireLinuxEvent(start: LinuxNode, eventName: string, eventPayload: Record<string, unknown>): void;
83
+ /**
84
+ * Creates a `Renderer.Host<LinuxNode>` bound to any `LinuxHostBackend`
85
+ * (GTK4 via `@nativescript/linux` / `@nativescript/linux-napi`, or test backend).
86
+ */
87
+ export declare function makeLinuxHost(options: MakeLinuxHostOptions): {
88
+ readonly host: Renderer.Host<LinuxNode>;
89
+ readonly rootContainer: LinuxNode;
90
+ readonly relayout: () => void;
91
+ readonly getItems: () => ReadonlyArray<LinuxWidgetItem>;
92
+ readonly getStylesheet: () => string;
93
+ readonly getDialogItems: (dialog: LinuxNode) => ReadonlyArray<LinuxWidgetItem>;
94
+ readonly triggerClick: (node: LinuxNode) => void;
95
+ readonly triggerInput: (node: LinuxNode, value: string) => void;
96
+ readonly dispose: () => void;
97
+ };
98
+ /**
99
+ * Launches a native Linux GTK4 desktop application rendering any shared
100
+ * `@effect/ui` HTML component (`PulseApp`, `@effect/ui-kit`, etc.) via
101
+ * `@nativescript/linux` (V8 runtime) or `@nativescript/linux-napi` (Node/Bun/Deno).
102
+ */
103
+ export declare function run<Name extends string, Props, Model, Msg, Events, R, V extends View.Elements, RF = never, RP = never>(component: Component.Members<Name, Props, Model, Msg, Events, R, V, any> & LinuxRoot<V>, props: Props | Effect.Effect<Props, never, RP>, options?: LinuxRunOptions<V, RF, Events, Exclude<R | RF | RP, Html.Host>>): Promise<void>;
104
+ export declare const LinuxHost: {
105
+ readonly makeLinuxHost: typeof makeLinuxHost;
106
+ readonly run: typeof run;
107
+ };
108
+ //# sourceMappingURL=LinuxHost.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LinuxHost.d.ts","sourceRoot":"","sources":["../../src/linux/LinuxHost.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,KAAK,SAAS,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,KAAK,IAAI,MAAM,iBAAiB,CAAC;AAE7C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,KAAK,WAAW,MAAM,+BAA+B,CAAC;AAClE,OAAO,EASL,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,KAAK,IAAI,EAEV,MAAM,6BAA6B,CAAC;AAGrC,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,GAC/D,OAAO,GACP;IACE,QAAQ,CAAC,iEAAiE,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;CAChG,CAAC;AAEN,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,GAAG,WAAW,CAAC;IAChD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,SAAS,GAAG,SAAS,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IACpC,IAAI,EAAE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