@nstudio/nativescript-effect-ui 0.1.0 → 0.1.2

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 (120) hide show
  1. package/CHANGELOG.md +79 -0
  2. package/README.md +52 -18
  3. package/dist/desktop/html-services.d.ts +33 -0
  4. package/dist/desktop/html-services.d.ts.map +1 -0
  5. package/dist/desktop/html-services.js +113 -0
  6. package/dist/desktop/html-services.js.map +1 -0
  7. package/dist/linux/LinuxHost.d.ts +108 -0
  8. package/dist/linux/LinuxHost.d.ts.map +1 -0
  9. package/dist/linux/LinuxHost.js +609 -0
  10. package/dist/linux/LinuxHost.js.map +1 -0
  11. package/dist/linux/index.d.ts +3 -0
  12. package/dist/linux/index.d.ts.map +1 -0
  13. package/dist/linux/index.js +3 -0
  14. package/dist/linux/index.js.map +1 -0
  15. package/dist/linux/platform.d.ts +17 -0
  16. package/dist/linux/platform.d.ts.map +1 -0
  17. package/dist/linux/platform.js +119 -0
  18. package/dist/linux/platform.js.map +1 -0
  19. package/dist/macos/MacosHost.d.ts +13 -0
  20. package/dist/macos/MacosHost.d.ts.map +1 -1
  21. package/dist/macos/MacosHost.js +373 -12
  22. package/dist/macos/MacosHost.js.map +1 -1
  23. package/dist/macos/styles.d.ts.map +1 -1
  24. package/dist/macos/styles.js +4 -1
  25. package/dist/macos/styles.js.map +1 -1
  26. package/dist/mason/MasonHost.d.ts +35 -1
  27. package/dist/mason/MasonHost.d.ts.map +1 -1
  28. package/dist/mason/MasonHost.js +330 -18
  29. package/dist/mason/MasonHost.js.map +1 -1
  30. package/dist/mason/dialog.d.ts +24 -1
  31. package/dist/mason/dialog.d.ts.map +1 -1
  32. package/dist/mason/dialog.js +162 -2
  33. package/dist/mason/dialog.js.map +1 -1
  34. package/dist/mason/elements.d.ts.map +1 -1
  35. package/dist/mason/elements.js +33 -6
  36. package/dist/mason/elements.js.map +1 -1
  37. package/dist/mason/events.d.ts +4 -0
  38. package/dist/mason/events.d.ts.map +1 -1
  39. package/dist/mason/events.js +110 -2
  40. package/dist/mason/events.js.map +1 -1
  41. package/dist/mason/index.d.ts +2 -1
  42. package/dist/mason/index.d.ts.map +1 -1
  43. package/dist/mason/index.js +2 -1
  44. package/dist/mason/index.js.map +1 -1
  45. package/dist/mason/input-native.d.ts +32 -0
  46. package/dist/mason/input-native.d.ts.map +1 -0
  47. package/dist/mason/input-native.js +280 -0
  48. package/dist/mason/input-native.js.map +1 -0
  49. package/dist/mason/media.d.ts +18 -0
  50. package/dist/mason/media.d.ts.map +1 -0
  51. package/dist/mason/media.js +255 -0
  52. package/dist/mason/media.js.map +1 -0
  53. package/dist/mason/select.d.ts +25 -0
  54. package/dist/mason/select.d.ts.map +1 -0
  55. package/dist/mason/select.js +75 -0
  56. package/dist/mason/select.js.map +1 -0
  57. package/dist/mason/services.d.ts +2 -1
  58. package/dist/mason/services.d.ts.map +1 -1
  59. package/dist/mason/services.js +61 -75
  60. package/dist/mason/services.js.map +1 -1
  61. package/dist/mason/styles.d.ts +16 -0
  62. package/dist/mason/styles.d.ts.map +1 -1
  63. package/dist/mason/styles.js +138 -19
  64. package/dist/mason/styles.js.map +1 -1
  65. package/dist/mason/svg.d.ts +86 -0
  66. package/dist/mason/svg.d.ts.map +1 -0
  67. package/dist/mason/svg.js +932 -0
  68. package/dist/mason/svg.js.map +1 -0
  69. package/dist/mason/video.d.ts +40 -0
  70. package/dist/mason/video.d.ts.map +1 -0
  71. package/dist/mason/video.js +641 -0
  72. package/dist/mason/video.js.map +1 -0
  73. package/dist/motion/index.d.ts +8 -8
  74. package/dist/platform/index.d.ts +1 -1
  75. package/dist/platform/index.d.ts.map +1 -1
  76. package/dist/platform/intl-mapping.d.ts +124 -0
  77. package/dist/platform/intl-mapping.d.ts.map +1 -0
  78. package/dist/platform/intl-mapping.js +540 -0
  79. package/dist/platform/intl-mapping.js.map +1 -0
  80. package/dist/platform/intl-polyfill.d.ts +60 -0
  81. package/dist/platform/intl-polyfill.d.ts.map +1 -0
  82. package/dist/platform/intl-polyfill.js +389 -0
  83. package/dist/platform/intl-polyfill.js.map +1 -0
  84. package/dist/platform/intl.d.ts +9 -0
  85. package/dist/platform/intl.d.ts.map +1 -0
  86. package/dist/platform/intl.js +219 -0
  87. package/dist/platform/intl.js.map +1 -0
  88. package/dist/platform/native.d.ts +1 -1
  89. package/dist/platform/native.d.ts.map +1 -1
  90. package/dist/platform/native.js +89 -14
  91. package/dist/platform/native.js.map +1 -1
  92. package/dist/postcss/color.d.ts +18 -0
  93. package/dist/postcss/color.d.ts.map +1 -0
  94. package/dist/postcss/color.js +620 -0
  95. package/dist/postcss/color.js.map +1 -0
  96. package/dist/postcss/index.d.ts +39 -0
  97. package/dist/postcss/index.d.ts.map +1 -0
  98. package/dist/postcss/index.js +249 -0
  99. package/dist/postcss/index.js.map +1 -0
  100. package/dist/postcss/values.d.ts +49 -0
  101. package/dist/postcss/values.d.ts.map +1 -0
  102. package/dist/postcss/values.js +259 -0
  103. package/dist/postcss/values.js.map +1 -0
  104. package/dist/testing/MockMasonHost.d.ts +2 -2
  105. package/dist/testing/MockMasonHost.d.ts.map +1 -1
  106. package/dist/testing/MockMasonHost.js +1 -1
  107. package/dist/testing/MockMasonHost.js.map +1 -1
  108. package/dist/windows/WindowsHost.d.ts +107 -0
  109. package/dist/windows/WindowsHost.d.ts.map +1 -0
  110. package/dist/windows/WindowsHost.js +659 -0
  111. package/dist/windows/WindowsHost.js.map +1 -0
  112. package/dist/windows/index.d.ts +3 -0
  113. package/dist/windows/index.d.ts.map +1 -0
  114. package/dist/windows/index.js +3 -0
  115. package/dist/windows/index.js.map +1 -0
  116. package/dist/windows/platform.d.ts +12 -0
  117. package/dist/windows/platform.d.ts.map +1 -0
  118. package/dist/windows/platform.js +105 -0
  119. package/dist/windows/platform.js.map +1 -0
  120. package/package.json +61 -4
package/CHANGELOG.md ADDED
@@ -0,0 +1,79 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@nstudio/nativescript-effect-ui` are documented here.
4
+
5
+ ## 0.1.2 (2026-11-29)
6
+
7
+ Fixes the `MasonHost` and CSS pipeline issues found porting an `@effect/ui` + `@effect/ui-kit` web app to iOS ([#3](https://github.com/nstudio/ns-effect-ui/issues/3)). Thanks to [@cliffordfajardo](https://github.com/cliffordfajardo) for the isolated repros, per-item issues and PRs.
8
+
9
+ ### Behavior changes
10
+
11
+ - **`runsMounts` defaults to `false`** on `MasonHost`. `@effect/ui-kit` mounts need a browser DOM. Set `runsMounts: true` in the host options to run host-neutral mounts such as `NativeMotion.track` or your own `onMount` ([#4](https://github.com/nstudio/ns-effect-ui/issues/4)).
12
+ - **`<dialog>` renders in an in-tree top layer** (a second MasonKit root stacked above the Frame) under `MasonHost.run`, instead of core's native `showModal`. Custom roots (`createRoot`/`mount`) and `data-presentation="sheet"` still use the native modal. `createTopLayerDialogPresenter` is exported for custom roots ([#5](https://github.com/nstudio/ns-effect-ui/issues/5)).
13
+ - **`position: fixed` is mapped to `absolute`** in stylesheets and inline styles until [triniwiz/nativescript-mason#237](https://github.com/triniwiz/nativescript-mason/issues/237) is fixed. Inside the full-window top layer this is equivalent, but a page-level `fixed` element now scrolls with its root.
14
+ - **The Tailwind pipeline ships in the package.** Replace a copied `vite.config.mts` pipeline with `masonPostcssPlugins()` from `@nstudio/nativescript-effect-ui/postcss`.
15
+
16
+ ### PostCSS pipeline (`@nstudio/nativescript-effect-ui/postcss`)
17
+
18
+ - New `masonPostcssPlugins()` export with the Tailwind v4 + `@nativescript/tailwind` pipeline. Runtime-safe value converters are exported from `./postcss/values`.
19
+ - CSS nesting is flattened after Tailwind (`postcss-nesting`), so NativeScript's parser never sees a nested rule. `postcss-preset-env` is no longer used ([#12](https://github.com/nstudio/ns-effect-ui/issues/12)).
20
+ - `oklch()`, `oklab()`, `lab()`, `lch()`, `color()` and resolvable `color-mix()` convert to sRGB at build time, and the same converter runs on inline `style` values ([#12](https://github.com/nstudio/ns-effect-ui/issues/12)).
21
+ - Length line-heights keep their unit (`leading-8` → `32px`). Unitless ratios stay multipliers ([#13](https://github.com/nstudio/ns-effect-ui/issues/13), [#15](https://github.com/nstudio/ns-effect-ui/pull/15)).
22
+ - `@media` rules survive `@nativescript/tailwind`, and Level 4 ranges such as `(width >= 48rem)` become `(min-width: 768)`. Declarations `@nativescript/tailwind` deletes are restored ([#13](https://github.com/nstudio/ns-effect-ui/issues/13)).
23
+ - `inline-flex`/`inline-grid`, `dvh`/`svh`/`lvh` and `position: sticky` are rewritten to forms MasonKit lays out.
24
+
25
+ ### MasonHost (`@nstudio/nativescript-effect-ui/mason`)
26
+
27
+ - `<dialog>` presents from the controlled `popoverOpen` prop and from the HTML `open` attribute. A closed popover on any other element is hidden ([#4](https://github.com/nstudio/ns-effect-ui/issues/4)).
28
+ - Dialog children keep MasonKit hit-testing and CSS scope. A collapsed (`0×0`) portal dialog gets the safe viewport box, and top-layer dialogs stay inside the window safe area while the scrim covers the window ([#5](https://github.com/nstudio/ns-effect-ui/issues/5)).
29
+ - `makeNativeMediaQueries` handles CSS Media Queries Level 4 range syntax, `rem`/`em` units, and `and`/`or`/`not` lists ([#6](https://github.com/nstudio/ns-effect-ui/issues/6), [#14](https://github.com/nstudio/ns-effect-ui/pull/14)).
30
+ - Tapping an `<a href>` calls `router.navigate(href)` on the `Router` in context, after the element's own click handler unless it prevented default. Absolute `http(s):`, `mailto:` and `tel:` URLs open with the system handler. The new `onNavigate` host option overrides this ([#7](https://github.com/nstudio/ns-effect-ui/issues/7)).
31
+ - `<a>` is MasonKit's inline, natively clickable `A`, so links inside text are tappable ([#10](https://github.com/nstudio/ns-effect-ui/issues/10)).
32
+ - Text inputs:
33
+ - Keyboard traits follow `type`, `inputmode`, `autocapitalize`, `autocorrect`, `spellcheck`, `enterkeyhint` and `autocomplete`.
34
+ - iOS `<input type="password">` reports controlled edits.
35
+ - Return submits the form, after a `keydown` `Enter`.
36
+ - Tapping outside a field dismisses the keyboard without cancelling the tap. `installTapToDismissKeyboard` and `dismissKeyboard` are exported for custom roots.
37
+
38
+ ([#8](https://github.com/nstudio/ns-effect-ui/issues/8))
39
+ - New `resolveUrl(url, { tag, attribute })` and `assetBaseUrl` host options rewrite `src`/`poster`, including `<source src>` ([#9](https://github.com/nstudio/ns-effect-ui/issues/9)).
40
+ - `<ul>`/`<ol>` render as block elements instead of MasonKit's native recycling list ([#10](https://github.com/nstudio/ns-effect-ui/issues/10)).
41
+ - `<select>` shows the selected option and opens the native picker. A choice dispatches `input` and `change`, and `value`, `selected`, `disabled` and `<optgroup>` are supported ([#11](https://github.com/nstudio/ns-effect-ui/issues/11)).
42
+ - `<svg>` is drawn natively: `path`, `circle`, `ellipse`, `rect`, `line`, `polyline`, `polygon`, and `g` with transforms and inherited presentation attributes, plus `viewBox`/`preserveAspectRatio` and `currentColor`. It uses CoreAnimation shape layers on iOS and a canvas overlay on Android ([#11](https://github.com/nstudio/ns-effect-ui/issues/11)).
43
+ - `<video>` embeds `AVPlayerViewController` on iOS and `VideoView` on Android. It supports `src`/`<source>`, `poster`, `controls`, `autoplay`, `muted` and `loop`, and raises `play`, `pause`, `ended` and `loadedmetadata` ([#11](https://github.com/nstudio/ns-effect-ui/issues/11)).
44
+ - Buttons, links and ARIA roles become native accessibility elements with labels, and `data-testid` becomes the accessibility identifier.
45
+ - Inline styles go through the same value normalizer as stylesheets.
46
+ - When an inline declaration is removed, a hidden element is shown again, or a dialog closes, the style property is reset with `unset`. The previous value no longer stays applied.
47
+
48
+ ### Platform
49
+
50
+ - New native-backed `Intl` polyfill for the ICU-less NativeScript V8 runtimes: `Intl.DateTimeFormat` and `Intl.NumberFormat` (`format`, `formatToParts`, `resolvedOptions`) and patched `Date`/`Number` `toLocale*`. It is backed by `NSDateFormatter`/`NSNumberFormatter` on Apple and `android.icu` on Android, and `ensureRuntimeGlobals()` installs it.
51
+ - macOS: native AppKit focus rings, a Tab/Shift+Tab key-view loop, and Space/Return/Escape support.
52
+ - macOS: buttons and checkmarks are centered correctly with 64-bit `NSTextAlignment` values.
53
+
54
+ ### Known limitations
55
+
56
+ - `<svg>` does not draw gradients, `<text>`, `<use>`, masks or clip paths yet.
57
+ - The Android `<svg>` and `<video>` paths have not been verified on a device yet.
58
+ - `overflow-y: auto` scroll containers with `flex-grow: 1` still collapse to their content height until a MasonKit release includes [triniwiz/nativescript-mason#235](https://github.com/triniwiz/nativescript-mason/pull/235).
59
+
60
+ ## 0.1.1 (2026-11-27)
61
+
62
+ ### Windows support (`@nstudio/nativescript-effect-ui/windows`)
63
+
64
+ - Added `WindowsHost` mounting unmodified `@effect/ui/html` (`Html.component`) views onto WinUI 3 (`Microsoft.UI.Xaml` under `@nativescript/windows`), XAML Islands (`Windows.UI.Xaml` via `XamlWindow`), and WinRT Composition (`Windows.UI.Composition` via `@nativescript/windows-napi`) with pointer hit-testing, controlled inputs, and modal `<dialog>` windows.
65
+ - Added `WindowsPlatformLayer` (`DeviceInfo` via WinRT `AnalyticsInfo` and `SystemSupportInfo`, `AppLifecycle` dark-mode detection via `UISettings`, `Clipboard` via `DataTransfer.Clipboard`, and `Haptics`).
66
+ - Added runnable Windows desktop demo in `apps/windows` (`pnpm windows`) and `ns run windows` script in `apps/native`.
67
+
68
+ ### Linux support (`@nstudio/nativescript-effect-ui/linux`)
69
+
70
+ - Added `LinuxHost` mounting unmodified `@effect/ui/html` components onto native GTK4 widgets (`GtkWindow`, `GtkScrolledWindow`, `GtkFixed`, `GtkBox`, `GtkLabel`, `GtkButton`, `GtkEntry`, `GtkCssProvider`, `interop.callback` signal trampolines, transient modal `<dialog>`, and `runGLib()`/`stopGLib()`) under `@nativescript/linux` or `@nativescript/linux-napi`.
71
+ - Added `LinuxPlatformLayer` (`DeviceInfo` from `/etc/os-release` and DMI, `AppLifecycle` via `GTK_THEME`, `Clipboard` via `gdk_clipboard_set_text`, and `Haptics`).
72
+ - Added runnable Linux GTK4 desktop demo in `apps/linux` (`pnpm linux`) and `ns run linux` script in `apps/native`.
73
+
74
+ ### Shared platform & package updates
75
+
76
+ - Extended `NativePlatformLayer` (`@nstudio/nativescript-effect-ui/platform/native`) to resolve `windows` and `linux` for `DeviceInfo` and native WinRT / GTK4 `Clipboard` when running `MasonHost` under `@nativescript/windows` or `@nativescript/linux`.
77
+ - Extracted shared desktop HTML services and color/text helpers in `src/desktop/html-services.ts`.
78
+ - Added behavioral Vitest suites covering `WindowsHost`, `LinuxHost`, `WindowsPlatformLayer`, and `LinuxPlatformLayer`.
79
+ - Updated package `README.md` and `exports` for `./windows` and `./linux`.
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,64 @@ MasonHost.run(App, {}, {
38
40
  });
39
41
  ```
40
42
 
41
- ### macOS Desktop (`MacosHost`)
43
+ #### `MasonHost` options
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
+ Pass these as `host` (in `MasonHost.run`, `mount`, or `mountEffect`):
46
+
47
+ | Option | Default | Description |
48
+ | --- | --- | --- |
49
+ | `runsMounts` | `false` | Run `onMount` work. `@effect/ui-kit`'s mounts (Dialog/Drawer focus handling, swipe, ScrollArea and Toast tracking) need a browser DOM and fail their component natively; enable this only for host-neutral mounts such as `NativeMotion.track`. |
50
+ | `onNavigate` | — | Called for an `<a href>` tap no click handler prevented. Without it, hrefs the mounted `Router` parses navigate that Router, and `http(s):`, `mailto:` and `tel:` URLs open with the system handler. |
51
+ | `resolveUrl` / `assetBaseUrl` | — | Rewrite `src` / `poster`; there is no document origin natively, so root-relative URLs such as `/media/photo.jpg` need a base (e.g. `https://cdn.example.com` or `~/assets`). |
52
+ | `dialogPresenter` | top layer | `MasonHost.run` renders `<dialog>` in a MasonKit layer above the app (`createTopLayerDialogPresenter`); custom roots fall back to a native modal. `<dialog data-presentation="sheet">` always uses the native sheet. |
53
+
54
+ `MasonHost.run` also dismisses the keyboard when the user taps outside a text field (`installTapToDismissKeyboard` for custom roots), and `ensureRuntimeGlobals()` installs a native-backed `Intl` / `toLocale*` polyfill on runtimes built without ICU.
55
+
56
+ #### Tailwind v4 / PostCSS
44
57
 
45
58
  ```ts
46
- import { MacosHost, MacosPlatformLayer } from '@nstudio/nativescript-effect-ui/macos';
47
- import { App } from './App';
59
+ // vite.config.mts
60
+ import { masonPostcssPlugins } from '@nstudio/nativescript-effect-ui/postcss';
48
61
 
49
- await MacosHost.run(App, {}, {
50
- title: 'Effect Pulse',
51
- width: 460,
52
- height: 820,
53
- layer: MacosPlatformLayer,
62
+ export default defineConfig({
63
+ css: { postcss: { plugins: masonPostcssPlugins({ projectRoot: import.meta.dirname }) } },
54
64
  });
55
65
  ```
56
66
 
67
+ Runs Tailwind v4 and `@nativescript/tailwind` (loaded from your app), keeps the CSS MasonKit lays out, flattens nesting, converts `oklch()` / `color-mix()` to sRGB, keeps `@media` rules (Level 4 ranges become `min-`/`max-` queries), emits length line-heights with units, and rewrites `inline-flex`, `dvh`, `position: sticky` and `position: fixed` to forms MasonKit 1.0.0-beta.135 handles. Inline `style` attributes go through the same rewrites at runtime.
68
+
69
+ ### macOS, Windows, and Linux Desktop (`MacosHost` / `WindowsHost` / `LinuxHost`)
70
+
71
+ Mount the exact same `@effect/ui/html` components onto native AppKit, WinUI/WinRT, or GTK4 windows with zero WebViews or Electron:
72
+
73
+ ```ts
74
+ // macOS (AppKit)
75
+ import { MacosHost, MacosPlatformLayer } from '@nstudio/nativescript-effect-ui/macos';
76
+ await MacosHost.run(App, {}, { title: 'Effect Pulse', width: 460, height: 820, layer: MacosPlatformLayer });
77
+
78
+ // Windows (WinUI 3 / XAML Islands / WinRT Composition)
79
+ import { WindowsHost, WindowsPlatformLayer } from '@nstudio/nativescript-effect-ui/windows';
80
+ await WindowsHost.run(App, {}, { title: 'Effect Pulse', width: 460, height: 820, layer: WindowsPlatformLayer });
81
+
82
+ // Linux (GTK4)
83
+ import { LinuxHost, LinuxPlatformLayer } from '@nstudio/nativescript-effect-ui/linux';
84
+ await LinuxHost.run(App, {}, { title: 'Effect Pulse', width: 460, height: 820, layer: LinuxPlatformLayer });
85
+ ```
86
+
57
87
  ## Subpath Exports
58
88
 
59
89
  | Subpath | Description |
60
90
  | --- | --- |
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 |
91
+ | `@nstudio/nativescript-effect-ui` | Platform service contracts (`Haptics`, `DeviceInfo`, `AppLifecycle`, `Clipboard`) |
92
+ | `@nstudio/nativescript-effect-ui/mason` | `MasonHost` for standard `@effect/ui/html` on iOS, Android, Windows, and Linux |
93
+ | `@nstudio/nativescript-effect-ui/postcss` | Tailwind v4 + MasonKit PostCSS pipeline for Vite (Node) |
94
+ | `@nstudio/nativescript-effect-ui/postcss/values` | Runtime-safe CSS value converters used by that pipeline and inline styles |
63
95
  | `@nstudio/nativescript-effect-ui/macos` | `MacosHost` and `MacosPlatformLayer` for native macOS AppKit |
96
+ | `@nstudio/nativescript-effect-ui/windows` | `WindowsHost` and `WindowsPlatformLayer` for native Windows (WinUI 3 / WinRT) |
97
+ | `@nstudio/nativescript-effect-ui/linux` | `LinuxHost` and `LinuxPlatformLayer` for native Linux (GTK4) |
64
98
  | `@nstudio/nativescript-effect-ui/native` | `NativeHost`, `Native`, and `NativeCommand` for direct NativeScript view vocabularies |
65
99
  | `@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 |
100
+ | `@nstudio/nativescript-effect-ui/platform/native` | NativeScript `NativePlatformLayer` implementations for iOS, Android, Windows, and Linux |
67
101
  | `@nstudio/nativescript-effect-ui/motion` | UI-thread spring and timing motion (`UIViewPropertyAnimator` / Android `Animator`) |
68
102
  | `@nstudio/nativescript-effect-ui/sheet` | Native bottom sheets (`UISheetPresentationController` / Android `BottomSheetDialog`) |
69
103
  | `@nstudio/nativescript-effect-ui/list` | Virtualized recycled lists (`UITableView` / `RecyclerView`) |
@@ -74,7 +108,7 @@ await MacosHost.run(App, {}, {
74
108
 
75
109
  ## Examples and Documentation
76
110
 
77
- Full monorepo with shared Web, iOS, Android, and macOS apps: [github.com/nstudio/ns-effect-ui](https://github.com/nstudio/ns-effect-ui)
111
+ 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
112
 
79
113
  ## License
80
114
 
@@ -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,iBAAiB,CAAC;AACzD,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAG1C,OAAO,EACL,UAAU,EACV,WAAW,GAIZ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,WAAW,EACX,GAAG,EACH,YAAY,EACZ,iBAAiB,IAAI,mBAAmB,GAIzC,MAAM,oBAAoB,CAAC;AAE5B;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CACrC,WAA2B;IAE3B,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;QAC7B,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;QACf,IAAI,EAAE,GAAG,EAAE,GAAE,CAAC;QACd,cAAc,EAAE,GAAG,EAAE,GAAE,CAAC;QACxB,OAAO,EAAE,CAAC,EAAO,EAAE,EAAE;YACnB,MAAM,CAAC,GAAG,EAAE,EAAE,UAAU,EAAE,KAAK,CAAC;YAChC,OAAO;gBACL,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;gBACZ,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;gBACZ,KAAK,EAAE,CAAC,EAAE,KA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ACpD,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;KACrD,CAAC;AACJ,CAAC;AAED,uFAAuF;AACvF,MAAM,UAAU,SAAS,CAAC,CAAY;IACpC,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,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,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,KAA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