@felipe-software/react-native-gpui 0.0.0-stage → 1.0.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 (72) hide show
  1. package/.reanimated-prebuilt/react-native-reanimated.mjs +29373 -0
  2. package/LICENSE +21 -0
  3. package/README.md +657 -2
  4. package/cli/bin.ts +379 -0
  5. package/cli/bundle.ts +32 -0
  6. package/cli/commands/do.ts +213 -0
  7. package/cli/commands/flow.ts +283 -0
  8. package/cli/commands/get.ts +584 -0
  9. package/cli/commands/shot.ts +312 -0
  10. package/cli/commands/trace.ts +293 -0
  11. package/cli/host.ts +714 -0
  12. package/cli/hotReload.ts +210 -0
  13. package/cli/run.ts +66 -0
  14. package/cli/selectors.ts +205 -0
  15. package/dist/Animated.d.ts +120 -0
  16. package/dist/ChatList.d.ts +28 -0
  17. package/dist/Dimensions.d.ts +31 -0
  18. package/dist/StyleSheet.d.ts +18 -0
  19. package/dist/Window.d.ts +33 -0
  20. package/dist/apis.d.ts +165 -0
  21. package/dist/app-state.d.ts +27 -0
  22. package/dist/chat-list-types.d.ts +136 -0
  23. package/dist/colors.d.ts +32 -0
  24. package/dist/commands.d.ts +230 -0
  25. package/dist/components.d.ts +419 -0
  26. package/dist/hotModules.d.ts +1 -0
  27. package/dist/index.d.ts +31 -0
  28. package/dist/index.development.js +14876 -0
  29. package/dist/index.js +12 -0
  30. package/dist/keyboard.d.ts +140 -0
  31. package/dist/native-menu.d.ts +7 -0
  32. package/dist/platform-driver.d.ts +32 -0
  33. package/dist/platform-services.d.ts +35 -0
  34. package/dist/portal.d.ts +43 -0
  35. package/dist/raf.d.ts +4 -0
  36. package/dist/reanimated/colors-processor-shim.d.ts +10 -0
  37. package/dist/reanimated/reanimated-host.d.ts +10 -0
  38. package/dist/reanimated/seam.d.ts +34 -0
  39. package/dist/reanimated/ui-entry.d.ts +2 -0
  40. package/dist/reanimated/worklet-channel.d.ts +10 -0
  41. package/dist/reanimated/worklet-runtime.d.ts +466 -0
  42. package/dist/reanimated/worklets.d.ts +199 -0
  43. package/dist/reconciler.d.ts +102 -0
  44. package/dist/refresh.d.ts +1 -0
  45. package/dist/render.d.ts +37 -0
  46. package/dist/runtime.d.ts +235 -0
  47. package/dist/surfaces.d.ts +51 -0
  48. package/dist/types.d.ts +276 -0
  49. package/dist/ui-runtime.js +42276 -0
  50. package/dist/window-context.d.ts +7 -0
  51. package/dist/window-host.d.ts +41 -0
  52. package/dist/wire-delta.d.ts +20 -0
  53. package/package.json +176 -5
  54. package/scripts/bundle-app.mjs +88 -0
  55. package/scripts/conformance-utils.mjs +293 -0
  56. package/scripts/hot-update-alias-plugin.mjs +88 -0
  57. package/scripts/native-package-exports-plugin.mjs +235 -0
  58. package/scripts/pixel.mjs +152 -0
  59. package/scripts/png.mjs +198 -0
  60. package/scripts/react-refresh-swc.mjs +35 -0
  61. package/scripts/reanimated-bun-plugin.mjs +188 -0
  62. package/scripts/service-binary.d.mts +27 -0
  63. package/scripts/service-binary.mjs +100 -0
  64. package/src/reanimated/colors-processor-shim.ts +119 -0
  65. package/src/reanimated/reanimated-host.ts +69 -0
  66. package/src/reanimated/rngpui-reanimated-prebuilt.d.ts +7 -0
  67. package/src/reanimated/seam.ts +566 -0
  68. package/src/reanimated/ui-entry.ts +80 -0
  69. package/src/reanimated/worklet-channel.ts +64 -0
  70. package/src/reanimated/worklet-runtime.ts +2569 -0
  71. package/src/reanimated/worklets.ts +1334 -0
  72. package/src/refresh.ts +33 -0
@@ -0,0 +1,64 @@
1
+ // host-fn channel adapter for the worklet runtime.
2
+ //
3
+ // the two JavaScriptCore runtimes (React + UI) cross only as JSON strings through rust
4
+ // host fns (see plans/off-thread-reanimated.md §Crossings):
5
+ // - React→UI: __rngpui_uiPost(json) (host fn present on the React runtime)
6
+ // - UI→React: __rngpui_jsPost(json) (host fn present on the UI runtime)
7
+ // rust posts the decoded string onto the OTHER runtime's queue by calling that
8
+ // runtime's `__rngpui_peerRecv(json)`, which this adapter installs.
9
+ //
10
+ // this adapter implements the WorkletChannel interface the runtime expects:
11
+ // - send(msg) → JSON.stringify → the role-appropriate host post fn.
12
+ // - hasPeer() → whether that host post fn exists in this runtime.
13
+ // inbound: globalThis.__rngpui_peerRecv = (json) => runtime.onMessage(JSON.parse(json)).
14
+
15
+ import type { WorkletChannel, WorkletMessage, WorkletRuntime, WorkletRuntimeRole } from './worklet-runtime'
16
+
17
+ // the React runtime posts to the UI runtime via __rngpui_uiPost; the UI runtime
18
+ // posts back via __rngpui_jsPost.
19
+ function postFnName(role: WorkletRuntimeRole): '__rngpui_uiPost' | '__rngpui_jsPost' {
20
+ return role === 'react' ? '__rngpui_uiPost' : '__rngpui_jsPost'
21
+ }
22
+
23
+ function getPostFn(role: WorkletRuntimeRole): ((json: string) => void) | null {
24
+ const fn = (globalThis as Record<string, unknown>)[postFnName(role)]
25
+ return typeof fn === 'function' ? (fn as (json: string) => void) : null
26
+ }
27
+
28
+ const BRIDGE_TRACE_RAW =
29
+ (typeof process !== 'undefined' && (process as { env?: Record<string, string> }).env?.RNGPUI_BRIDGE_TRACE) || ''
30
+ const BRIDGE_TRACE = !!BRIDGE_TRACE_RAW
31
+ // RNGPUI_BRIDGE_TRACE=full dumps entire payloads (closure specs are deep).
32
+ const BRIDGE_TRACE_LIMIT = BRIDGE_TRACE_RAW === 'full' ? Number.POSITIVE_INFINITY : 600
33
+
34
+ export function makeChannel(role: WorkletRuntimeRole): WorkletChannel {
35
+ return {
36
+ send(msg: WorkletMessage): void {
37
+ const post = getPostFn(role)
38
+ if (!post) return
39
+ const json = JSON.stringify(msg)
40
+ if (BRIDGE_TRACE) console.error(`[bridge ${role}→] ${json.slice(0, BRIDGE_TRACE_LIMIT)}`)
41
+ post(json)
42
+ },
43
+ hasPeer(): boolean {
44
+ return getPostFn(role) !== null
45
+ },
46
+ }
47
+ }
48
+
49
+ /**
50
+ * Install the inbound receiver so rust can deliver peer messages into this
51
+ * runtime. `__rngpui_peerRecv(json)` is the single entry point rust calls on the
52
+ * receiving runtime's queue; it decodes and hands the message to the runtime,
53
+ * console.erroring (rather than throwing into the rust caller) on a malformed
54
+ * payload.
55
+ */
56
+ export function installChannel(_role: WorkletRuntimeRole, runtime: WorkletRuntime): void {
57
+ ;(globalThis as Record<string, unknown>).__rngpui_peerRecv = (json: string) => {
58
+ try {
59
+ runtime.onMessage(JSON.parse(json) as WorkletMessage)
60
+ } catch (err) {
61
+ console.error('[worklet-channel] malformed peer payload:', err, json)
62
+ }
63
+ }
64
+ }