@nstudio/nativescript-effect-ui 0.0.0-stage → 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 (139) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +86 -2
  3. package/dist/crash/index.d.ts +49 -0
  4. package/dist/crash/index.d.ts.map +1 -0
  5. package/dist/crash/index.js +199 -0
  6. package/dist/crash/index.js.map +1 -0
  7. package/dist/desktop/html-services.d.ts +33 -0
  8. package/dist/desktop/html-services.d.ts.map +1 -0
  9. package/dist/desktop/html-services.js +113 -0
  10. package/dist/desktop/html-services.js.map +1 -0
  11. package/dist/devtools/index.d.ts +77 -0
  12. package/dist/devtools/index.d.ts.map +1 -0
  13. package/dist/devtools/index.js +158 -0
  14. package/dist/devtools/index.js.map +1 -0
  15. package/dist/index.d.ts +2 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +2 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/keyboard/index.d.ts +97 -0
  20. package/dist/keyboard/index.d.ts.map +1 -0
  21. package/dist/keyboard/index.js +226 -0
  22. package/dist/keyboard/index.js.map +1 -0
  23. package/dist/linux/LinuxHost.d.ts +108 -0
  24. package/dist/linux/LinuxHost.d.ts.map +1 -0
  25. package/dist/linux/LinuxHost.js +601 -0
  26. package/dist/linux/LinuxHost.js.map +1 -0
  27. package/dist/linux/index.d.ts +3 -0
  28. package/dist/linux/index.d.ts.map +1 -0
  29. package/dist/linux/index.js +3 -0
  30. package/dist/linux/index.js.map +1 -0
  31. package/dist/linux/platform.d.ts +17 -0
  32. package/dist/linux/platform.d.ts.map +1 -0
  33. package/dist/linux/platform.js +119 -0
  34. package/dist/linux/platform.js.map +1 -0
  35. package/dist/list/index.d.ts +91 -0
  36. package/dist/list/index.d.ts.map +1 -0
  37. package/dist/list/index.js +192 -0
  38. package/dist/list/index.js.map +1 -0
  39. package/dist/macos/MacosHost.d.ts +77 -0
  40. package/dist/macos/MacosHost.d.ts.map +1 -0
  41. package/dist/macos/MacosHost.js +878 -0
  42. package/dist/macos/MacosHost.js.map +1 -0
  43. package/dist/macos/index.d.ts +5 -0
  44. package/dist/macos/index.d.ts.map +1 -0
  45. package/dist/macos/index.js +5 -0
  46. package/dist/macos/index.js.map +1 -0
  47. package/dist/macos/layout.d.ts +39 -0
  48. package/dist/macos/layout.d.ts.map +1 -0
  49. package/dist/macos/layout.js +226 -0
  50. package/dist/macos/layout.js.map +1 -0
  51. package/dist/macos/platform.d.ts +12 -0
  52. package/dist/macos/platform.d.ts.map +1 -0
  53. package/dist/macos/platform.js +103 -0
  54. package/dist/macos/platform.js.map +1 -0
  55. package/dist/macos/styles.d.ts +66 -0
  56. package/dist/macos/styles.d.ts.map +1 -0
  57. package/dist/macos/styles.js +350 -0
  58. package/dist/macos/styles.js.map +1 -0
  59. package/dist/mason/MasonHost.d.ts +102 -0
  60. package/dist/mason/MasonHost.d.ts.map +1 -0
  61. package/dist/mason/MasonHost.js +413 -0
  62. package/dist/mason/MasonHost.js.map +1 -0
  63. package/dist/mason/dialog.d.ts +23 -0
  64. package/dist/mason/dialog.d.ts.map +1 -0
  65. package/dist/mason/dialog.js +186 -0
  66. package/dist/mason/dialog.js.map +1 -0
  67. package/dist/mason/elements.d.ts +50 -0
  68. package/dist/mason/elements.d.ts.map +1 -0
  69. package/dist/mason/elements.js +194 -0
  70. package/dist/mason/elements.js.map +1 -0
  71. package/dist/mason/events.d.ts +37 -0
  72. package/dist/mason/events.d.ts.map +1 -0
  73. package/dist/mason/events.js +304 -0
  74. package/dist/mason/events.js.map +1 -0
  75. package/dist/mason/index.d.ts +6 -0
  76. package/dist/mason/index.d.ts.map +1 -0
  77. package/dist/mason/index.js +6 -0
  78. package/dist/mason/index.js.map +1 -0
  79. package/dist/mason/services.d.ts +36 -0
  80. package/dist/mason/services.d.ts.map +1 -0
  81. package/dist/mason/services.js +268 -0
  82. package/dist/mason/services.js.map +1 -0
  83. package/dist/mason/styles.d.ts +20 -0
  84. package/dist/mason/styles.d.ts.map +1 -0
  85. package/dist/mason/styles.js +269 -0
  86. package/dist/mason/styles.js.map +1 -0
  87. package/dist/motion/index.d.ts +179 -0
  88. package/dist/motion/index.d.ts.map +1 -0
  89. package/dist/motion/index.js +332 -0
  90. package/dist/motion/index.js.map +1 -0
  91. package/dist/native/Native.d.ts +163 -0
  92. package/dist/native/Native.d.ts.map +1 -0
  93. package/dist/native/Native.js +144 -0
  94. package/dist/native/Native.js.map +1 -0
  95. package/dist/native/NativeCommand.d.ts +36 -0
  96. package/dist/native/NativeCommand.d.ts.map +1 -0
  97. package/dist/native/NativeCommand.js +38 -0
  98. package/dist/native/NativeCommand.js.map +1 -0
  99. package/dist/native/NativeHost.d.ts +46 -0
  100. package/dist/native/NativeHost.d.ts.map +1 -0
  101. package/dist/native/NativeHost.js +346 -0
  102. package/dist/native/NativeHost.js.map +1 -0
  103. package/dist/native/index.d.ts +4 -0
  104. package/dist/native/index.d.ts.map +1 -0
  105. package/dist/native/index.js +4 -0
  106. package/dist/native/index.js.map +1 -0
  107. package/dist/platform/index.d.ts +86 -0
  108. package/dist/platform/index.d.ts.map +1 -0
  109. package/dist/platform/index.js +131 -0
  110. package/dist/platform/index.js.map +1 -0
  111. package/dist/platform/native.d.ts +12 -0
  112. package/dist/platform/native.d.ts.map +1 -0
  113. package/dist/platform/native.js +202 -0
  114. package/dist/platform/native.js.map +1 -0
  115. package/dist/sheet/index.d.ts +113 -0
  116. package/dist/sheet/index.d.ts.map +1 -0
  117. package/dist/sheet/index.js +202 -0
  118. package/dist/sheet/index.js.map +1 -0
  119. package/dist/testing/MockMasonHost.d.ts +48 -0
  120. package/dist/testing/MockMasonHost.d.ts.map +1 -0
  121. package/dist/testing/MockMasonHost.js +142 -0
  122. package/dist/testing/MockMasonHost.js.map +1 -0
  123. package/dist/testing/index.d.ts +2 -0
  124. package/dist/testing/index.d.ts.map +1 -0
  125. package/dist/testing/index.js +2 -0
  126. package/dist/testing/index.js.map +1 -0
  127. package/dist/windows/WindowsHost.d.ts +107 -0
  128. package/dist/windows/WindowsHost.d.ts.map +1 -0
  129. package/dist/windows/WindowsHost.js +651 -0
  130. package/dist/windows/WindowsHost.js.map +1 -0
  131. package/dist/windows/index.d.ts +3 -0
  132. package/dist/windows/index.d.ts.map +1 -0
  133. package/dist/windows/index.js +3 -0
  134. package/dist/windows/index.js.map +1 -0
  135. package/dist/windows/platform.d.ts +12 -0
  136. package/dist/windows/platform.d.ts.map +1 -0
  137. package/dist/windows/platform.js +105 -0
  138. package/dist/windows/platform.js.map +1 -0
  139. package/package.json +145 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright OpenJS Foundation and other contributors, https://openjsf.org/
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,87 @@
1
- # Temporary Holding Version
1
+ # @nstudio/nativescript-effect-ui
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
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
+
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
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @nstudio/nativescript-effect-ui effect
11
+ ```
12
+
13
+ `@effect/ui` is currently in public preview on `pkg.pr.new`:
14
+
15
+ ```bash
16
+ npm install https://pkg.pr.new/Effect-TS/ui/@effect/ui@5cb34b2
17
+ ```
18
+
19
+ Install the optional platform peer dependencies for the targets you use:
20
+
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
+ - **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`
25
+
26
+ ## Quick Start
27
+
28
+ ### iOS, Android, Windows, and Linux (`MasonHost`)
29
+
30
+ Mounts unmodified `@effect/ui/html` components onto native views backed by MasonKit's Rust/Taffy CSS Flexbox and Grid layout engine.
31
+
32
+ ```ts
33
+ import { MasonHost } from '@nstudio/nativescript-effect-ui/mason';
34
+ import { NativePlatformLayer } from '@nstudio/nativescript-effect-ui/platform/native';
35
+ import { App } from './App';
36
+
37
+ MasonHost.run(App, {}, {
38
+ title: 'Effect Pulse',
39
+ layer: NativePlatformLayer,
40
+ });
41
+ ```
42
+
43
+ ### macOS, Windows, and Linux Desktop (`MacosHost` / `WindowsHost` / `LinuxHost`)
44
+
45
+ Mount the exact same `@effect/ui/html` components onto native AppKit, WinUI/WinRT, or GTK4 windows with zero WebViews or Electron:
46
+
47
+ ```ts
48
+ // macOS (AppKit)
49
+ import { MacosHost, MacosPlatformLayer } from '@nstudio/nativescript-effect-ui/macos';
50
+ await MacosHost.run(App, {}, { title: 'Effect Pulse', width: 460, height: 820, layer: MacosPlatformLayer });
51
+
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 });
59
+ ```
60
+
61
+ ## Subpath Exports
62
+
63
+ | Subpath | Description |
64
+ | --- | --- |
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 |
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) |
70
+ | `@nstudio/nativescript-effect-ui/native` | `NativeHost`, `Native`, and `NativeCommand` for direct NativeScript view vocabularies |
71
+ | `@nstudio/nativescript-effect-ui/platform` | Shared platform service interfaces and Web/fallback layers |
72
+ | `@nstudio/nativescript-effect-ui/platform/native` | NativeScript `NativePlatformLayer` implementations for iOS, Android, Windows, and Linux |
73
+ | `@nstudio/nativescript-effect-ui/motion` | UI-thread spring and timing motion (`UIViewPropertyAnimator` / Android `Animator`) |
74
+ | `@nstudio/nativescript-effect-ui/sheet` | Native bottom sheets (`UISheetPresentationController` / Android `BottomSheetDialog`) |
75
+ | `@nstudio/nativescript-effect-ui/list` | Virtualized recycled lists (`UITableView` / `RecyclerView`) |
76
+ | `@nstudio/nativescript-effect-ui/keyboard` | Keyboard-docked input accessories (`inputAccessoryView` / Android IME insets) |
77
+ | `@nstudio/nativescript-effect-ui/crash` | Unhandled fault boundary and recovery view |
78
+ | `@nstudio/nativescript-effect-ui/devtools` | Runtime inspector and `@effect/ui` devtools bridge |
79
+ | `@nstudio/nativescript-effect-ui/testing` | Host testing utilities and mock platform layers |
80
+
81
+ ## Examples and Documentation
82
+
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)
84
+
85
+ ## License
86
+
87
+ MIT License. Copyright OpenJS Foundation and other contributors. See [LICENSE](./LICENSE).
@@ -0,0 +1,49 @@
1
+ import * as Schema from 'effect/Schema';
2
+ export declare const CrashReport: Schema.Struct<{
3
+ readonly title: Schema.String;
4
+ readonly message: Schema.String;
5
+ readonly stack: Schema.String;
6
+ readonly componentName: Schema.String;
7
+ readonly timestamp: Schema.String;
8
+ }>;
9
+ export type CrashReport = typeof CrashReport.Type;
10
+ /**
11
+ * Builds a structured `CrashReport` from any Effect `AsyncResult.Failure`,
12
+ * `Cause`, or JS error value.
13
+ */
14
+ export declare function buildCrashReport(failure: unknown, componentName?: string, now?: () => Date): CrashReport;
15
+ /**
16
+ * Formats a `CrashReport` into a plain-text diagnostic block suitable for
17
+ * copying to the system clipboard or pasting into an issue tracker.
18
+ */
19
+ export declare function formatCrashText(report: CrashReport): string;
20
+ export interface CrashFallbackOptions {
21
+ readonly componentName?: string | undefined;
22
+ readonly onCopy?: ((text: string) => void) | undefined;
23
+ readonly onRestart?: (() => void) | undefined;
24
+ }
25
+ /**
26
+ * Drop-in `fallback` renderer for `MasonHost.mount(...)` / `BrowserHost.mount(...)`.
27
+ *
28
+ * Renders a high-contrast recovery card with diagnostic details, Copy button,
29
+ * and Start Again button using standard HTML elements.
30
+ */
31
+ export declare function makeHtmlCrashFallback(options?: CrashFallbackOptions | undefined): (failure: unknown, h: any) => any;
32
+ /**
33
+ * Drop-in `fallback` renderer for `NativeHost.mount(...)` (Strategy A).
34
+ */
35
+ export declare function makeNativeCrashFallback(options?: CrashFallbackOptions | undefined): (failure: unknown, h: any) => any;
36
+ export declare const NativeCrash: {
37
+ readonly CrashReport: Schema.Struct<{
38
+ readonly title: Schema.String;
39
+ readonly message: Schema.String;
40
+ readonly stack: Schema.String;
41
+ readonly componentName: Schema.String;
42
+ readonly timestamp: Schema.String;
43
+ }>;
44
+ readonly buildCrashReport: typeof buildCrashReport;
45
+ readonly formatCrashText: typeof formatCrashText;
46
+ readonly makeHtmlCrashFallback: typeof makeHtmlCrashFallback;
47
+ readonly makeNativeCrashFallback: typeof makeNativeCrashFallback;
48
+ };
49
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/crash/index.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,eAAO,MAAM,WAAW;;;;;;EAMtB,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAC,IAAI,CAAC;AAoClD;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,OAAO,EAChB,aAAa,SAAgB,EAC7B,GAAG,GAAE,MAAM,IAAuB,GACjC,WAAW,CASb;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAS3D;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5C,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IACvD,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC;CAC/C;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE,oBAAoB,GAAG,SAAS,IACtE,SAAS,OAAO,EAAE,GAAG,GAAG,KAAG,GAAG,CAsDvC;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,CAAC,EAAE,oBAAoB,GAAG,SAAS,IACxE,SAAS,OAAO,EAAE,GAAG,GAAG,KAAG,GAAG,CA0DvC;AAED,eAAO,MAAM,WAAW;;;;;;;;;;;;CAMd,CAAC"}
@@ -0,0 +1,199 @@
1
+ /**
2
+ * Crash recovery boundary (`NativeCrash`) for `@nstudio/nativescript-effect-ui`.
3
+ *
4
+ * Provides:
5
+ * - Clean `CrashReport` extraction from Effect `Cause`, `AsyncResult.Failure`,
6
+ * or raw JS exceptions.
7
+ * - Drop-in `fallback` view factories for both `MasonHost` (`Html`) and
8
+ * `NativeHost` (`Native`) with one-tap diagnostics copy and instant restart.
9
+ * - Optional hook into NativeScript's `Application.uncaughtErrorEvent` so an
10
+ * unexpected runtime error surfaces a recovery UI rather than a blank screen.
11
+ */
12
+ import * as Cause from 'effect/Cause';
13
+ import * as Schema from 'effect/Schema';
14
+ export const CrashReport = Schema.Struct({
15
+ title: Schema.String,
16
+ message: Schema.String,
17
+ stack: Schema.String,
18
+ componentName: Schema.String,
19
+ timestamp: Schema.String,
20
+ });
21
+ function extractErrorDetails(failure) {
22
+ if (failure && typeof failure === 'object') {
23
+ // Handle Effect AsyncResult.Failure ({ _tag: "Failure", cause })
24
+ const asFailure = failure;
25
+ if (asFailure._tag === 'Failure' && asFailure.cause !== undefined) {
26
+ try {
27
+ const pretty = Cause.pretty(asFailure.cause);
28
+ const lines = pretty.split('\n');
29
+ return {
30
+ message: lines[0] || 'Unhandled Effect failure',
31
+ stack: pretty,
32
+ };
33
+ }
34
+ catch {
35
+ // Fall through
36
+ }
37
+ }
38
+ if (failure instanceof Error) {
39
+ return {
40
+ message: failure.message || failure.name || 'Unexpected error',
41
+ stack: failure.stack ?? String(failure),
42
+ };
43
+ }
44
+ const maybeMsg = failure.message;
45
+ if (typeof maybeMsg === 'string') {
46
+ return {
47
+ message: maybeMsg,
48
+ stack: String(failure.stack ?? maybeMsg),
49
+ };
50
+ }
51
+ }
52
+ const text = String(failure ?? 'Unknown error');
53
+ return { message: text, stack: text };
54
+ }
55
+ /**
56
+ * Builds a structured `CrashReport` from any Effect `AsyncResult.Failure`,
57
+ * `Cause`, or JS error value.
58
+ */
59
+ export function buildCrashReport(failure, componentName = 'EffectUIApp', now = () => new Date()) {
60
+ const { message, stack } = extractErrorDetails(failure);
61
+ return {
62
+ title: `${componentName} encountered an error`,
63
+ message,
64
+ stack,
65
+ componentName,
66
+ timestamp: now().toISOString(),
67
+ };
68
+ }
69
+ /**
70
+ * Formats a `CrashReport` into a plain-text diagnostic block suitable for
71
+ * copying to the system clipboard or pasting into an issue tracker.
72
+ */
73
+ export function formatCrashText(report) {
74
+ return [
75
+ `[${report.componentName}] ${report.title}`,
76
+ `Time: ${report.timestamp}`,
77
+ `Message: ${report.message}`,
78
+ '',
79
+ 'Stack / Cause:',
80
+ report.stack,
81
+ ].join('\n');
82
+ }
83
+ /**
84
+ * Drop-in `fallback` renderer for `MasonHost.mount(...)` / `BrowserHost.mount(...)`.
85
+ *
86
+ * Renders a high-contrast recovery card with diagnostic details, Copy button,
87
+ * and Start Again button using standard HTML elements.
88
+ */
89
+ export function makeHtmlCrashFallback(options) {
90
+ return (failure, h) => {
91
+ const report = buildCrashReport(failure, options?.componentName ?? 'EffectUIApp');
92
+ const text = formatCrashText(report);
93
+ return h.section
94
+ .class('flex flex-col gap-3 p-4 rounded-xl')
95
+ .style({
96
+ backgroundColor: '#1b1414',
97
+ borderColor: '#ef4444',
98
+ borderWidth: '1px',
99
+ color: '#fef2f2',
100
+ })
101
+ .children(h.h2.style({ fontSize: '18px', fontWeight: '700', color: '#fca5a5' }).children(report.title), h.p.style({ fontSize: '14px', color: '#fee2e2' }).children(report.message), h.pre
102
+ .style({
103
+ fontSize: '11px',
104
+ color: '#e5e7eb',
105
+ backgroundColor: '#0f0c0c',
106
+ padding: '10px',
107
+ borderRadius: '8px',
108
+ })
109
+ .children(report.stack.slice(0, 600)), h.div.class('flex flex-row gap-2').children(h.button
110
+ .attr('id', 'crash-copy-btn')
111
+ .style({
112
+ backgroundColor: '#27272a',
113
+ color: '#ffffff',
114
+ padding: '10px 14px',
115
+ borderRadius: '8px',
116
+ fontWeight: '600',
117
+ })
118
+ .prop('__onNativeAction', () => {
119
+ options?.onCopy?.(text);
120
+ })
121
+ .children('Copy Diagnostics'), h.button
122
+ .attr('id', 'crash-restart-btn')
123
+ .style({
124
+ backgroundColor: '#dc2626',
125
+ color: '#ffffff',
126
+ padding: '10px 14px',
127
+ borderRadius: '8px',
128
+ fontWeight: '600',
129
+ })
130
+ .prop('__onNativeAction', () => {
131
+ options?.onRestart?.();
132
+ })
133
+ .children('Start Again')));
134
+ };
135
+ }
136
+ /**
137
+ * Drop-in `fallback` renderer for `NativeHost.mount(...)` (Strategy A).
138
+ */
139
+ export function makeNativeCrashFallback(options) {
140
+ return (failure, h) => {
141
+ const report = buildCrashReport(failure, options?.componentName ?? 'NativeEffectApp');
142
+ const text = formatCrashText(report);
143
+ return h.stackLayout
144
+ .style({
145
+ padding: 20,
146
+ margin: 16,
147
+ borderRadius: 16,
148
+ backgroundColor: '#1b1414',
149
+ borderColor: '#ef4444',
150
+ borderWidth: 1,
151
+ })
152
+ .children(h.label
153
+ .text(report.title)
154
+ .textWrap(true)
155
+ .style({ fontSize: 18, fontWeight: '700', color: '#fca5a5', marginBottom: 8 }), h.label
156
+ .text(report.message)
157
+ .textWrap(true)
158
+ .style({ fontSize: 14, color: '#fee2e2', marginBottom: 12 }), h.label
159
+ .text(report.stack.slice(0, 400))
160
+ .textWrap(true)
161
+ .style({
162
+ fontSize: 11,
163
+ color: '#d4d4d8',
164
+ backgroundColor: '#0f0c0c',
165
+ padding: 10,
166
+ borderRadius: 8,
167
+ marginBottom: 14,
168
+ }), h.button
169
+ .text('Copy Diagnostics')
170
+ .style({
171
+ backgroundColor: '#27272a',
172
+ color: '#ffffff',
173
+ borderRadius: 10,
174
+ padding: 12,
175
+ marginBottom: 8,
176
+ })
177
+ .prop('__onNativeAction', () => {
178
+ options?.onCopy?.(text);
179
+ }), h.button
180
+ .text('Start Again')
181
+ .style({
182
+ backgroundColor: '#dc2626',
183
+ color: '#ffffff',
184
+ borderRadius: 10,
185
+ padding: 12,
186
+ })
187
+ .prop('__onNativeAction', () => {
188
+ options?.onRestart?.();
189
+ }));
190
+ };
191
+ }
192
+ export const NativeCrash = {
193
+ CrashReport,
194
+ buildCrashReport,
195
+ formatCrashText,
196
+ makeHtmlCrashFallback,
197
+ makeNativeCrashFallback,
198
+ };
199
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/crash/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC;IACvC,KAAK,EAAE,MAAM,CAAC,MAAM;IACpB,OAAO,EAAE,MAAM,CAAC,MAAM;IACtB,KAAK,EAAE,MAAM,CAAC,MAAM;IACpB,aAAa,EAAE,MAAM,CAAC,MAAM;IAC5B,SAAS,EAAE,MAAM,CAAC,MAAM;CACzB,CAAC,CAAC;AAGH,SAAS,mBAAmB,CAAC,OAAgB;IAC3C,IAAI,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC3C,iEAAiE;QACjE,MAAM,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Y,EAAE,EAAE;YAChB,OAAO,EAAE,EAAE;YACX,YAAY,EAAE,CAAC;SAChB,CAAC;aACD,IAAI,CAAC,kBAAkB,EAAE,GAAG,EAAE;YAC7B,OAAO,EAAE,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC,CAAC,EACJ,CAAC,CAAC,MAAM;aACL,IAAI,CAAC,aAAa,CAAC;aACnB,KAAK,CAAC;YACL,eAAe,EAAE,SAAS;YAC1B,KAAK,EAAE,SAAS;YAChB,YAAY,EAAE,EAAE;YAChB,OAAO,EAAE,EAAE;SACZ,CAAC;aACD,IAAI,CAAC,kBAAkB,EAAE,GAAG,EAAE;YAC7B,OAAO,EAAE,SAAS,EAAE,EAAE,CAAC;QACzB,CAAC,CAAC,CACL,CAAC;IACN,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,WAAW;IACX,gBAAgB;IAChB,eAAe;IACf,qBAAqB;IACrB,uBAAuB;CACf,CAAC"}
@@ -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,E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AAC,GAAG,CAAC;AACxC,CAAC"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Live DevTools bridge (`NativeDevTools`) for `@nstudio/nativescript-effect-ui`.
3
+ *
4
+ * Uses `@effect/ui`'s built-in `MessageLog.makeEncoded` to encode Wire frames
5
+ * off the app's hot update path, retains a bounded ring buffer for in-app or
6
+ * test inspection, and streams newline-free JSON Wire frames (`Hello` +
7
+ * `WireEntry`) over WebSocket to an `@effect/ui-devtools` server (auto-resolving
8
+ * `127.0.0.1` on iOS Simulator and `10.0.2.2` on Android Emulator).
9
+ */
10
+ import * as MessageLog from '@effect/ui/MessageLog';
11
+ import * as Layer from 'effect/Layer';
12
+ export interface DevToolsWebSocketLike {
13
+ readonly readyState: number;
14
+ send(data: string): void;
15
+ close(): void;
16
+ onopen: ((ev?: unknown) => void) | null;
17
+ onclose: ((ev?: unknown) => void) | null;
18
+ onerror: ((ev?: unknown) => void) | null;
19
+ }
20
+ export type DevToolsWebSocketCtor = new (url: string) => DevToolsWebSocketLike;
21
+ export interface DevToolsStats {
22
+ readonly connected: boolean;
23
+ readonly bufferedFrames: number;
24
+ readonly totalEncoded: number;
25
+ readonly totalSent: number;
26
+ readonly serverUrl: string | undefined;
27
+ }
28
+ export interface DevToolsBridgeHandle {
29
+ /** Provides `MessageLog.MessageLog` to any mounted Effect UI root. */
30
+ readonly layer: Layer.Layer<never>;
31
+ /** Snapshot of all buffered Wire frames (in chronological order). */
32
+ readonly getFrames: () => ReadonlyArray<MessageLog.WireEntry>;
33
+ /** Current connection & throughput metrics. */
34
+ readonly getStats: () => DevToolsStats;
35
+ /** Subscribe to newly encoded Wire frames (e.g. for an in-app HUD or test). */
36
+ readonly subscribe: (listener: (frames: ReadonlyArray<MessageLog.WireEntry>) => void) => () => void;
37
+ }
38
+ export interface DevToolsBridgeOptions {
39
+ /** WebSocket endpoint of an `@effect/ui-devtools` server (e.g. `ws://127.0.0.1:4774`). */
40
+ readonly serverUrl?: string | undefined;
41
+ /** Maximum number of encoded Wire frames kept in the ring buffer. Defaults to `500`. */
42
+ readonly bufferSize?: number | undefined;
43
+ /** Max serialized bytes per Wire entry. */
44
+ readonly maxEntryBytes?: number | undefined;
45
+ /** Host tag reported in the Wire `Hello` frame. Defaults to `"browser"` (valid WireHost). */
46
+ readonly host?: MessageLog.WireHost | undefined;
47
+ /** Reconnect delay in ms after a WebSocket close. Defaults to `1500`. */
48
+ readonly reconnectMs?: number | undefined;
49
+ /** Optional WebSocket constructor override (used in tests or custom runtimes). */
50
+ readonly WebSocketCtor?: DevToolsWebSocketCtor | undefined;
51
+ }
52
+ /**
53
+ * Resolves the default local DevTools server URL for the current runtime:
54
+ * - Android Emulator maps host loopback to `10.0.2.2`
55
+ * - iOS Simulator / macOS / Web use `127.0.0.1`
56
+ */
57
+ export declare function resolveDevToolsUrl(port?: number, path?: string): string;
58
+ /**
59
+ * Creates a live `NativeDevTools` bridge handle (`layer` + live `getFrames` /
60
+ * `getStats` / `subscribe`).
61
+ *
62
+ * Provide `bridge.layer` alongside `MasonHost.mount` or `NativeHost.mount` to
63
+ * stream every `Update`, `Mounted`, `QueryChanged`, `CommandStarted`, and
64
+ * `Failed` Wire frame with zero impact on production builds.
65
+ */
66
+ export declare function makeBridge(options?: DevToolsBridgeOptions | undefined): DevToolsBridgeHandle;
67
+ /**
68
+ * Convenience Layer for dropping live DevTools streaming straight into a
69
+ * mounted NativeScript Effect UI tree.
70
+ */
71
+ export declare const layer: (options?: DevToolsBridgeOptions | undefined) => Layer.Layer<never>;
72
+ export declare const NativeDevTools: {
73
+ readonly makeBridge: typeof makeBridge;
74
+ readonly layer: (options?: DevToolsBridgeOptions | undefined) => Layer.Layer<never>;
75
+ readonly resolveDevToolsUrl: typeof resolveDevToolsUrl;
76
+ };
77
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/devtools/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,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