@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.
- package/.reanimated-prebuilt/react-native-reanimated.mjs +29373 -0
- package/LICENSE +21 -0
- package/README.md +657 -2
- package/cli/bin.ts +379 -0
- package/cli/bundle.ts +32 -0
- package/cli/commands/do.ts +213 -0
- package/cli/commands/flow.ts +283 -0
- package/cli/commands/get.ts +584 -0
- package/cli/commands/shot.ts +312 -0
- package/cli/commands/trace.ts +293 -0
- package/cli/host.ts +714 -0
- package/cli/hotReload.ts +210 -0
- package/cli/run.ts +66 -0
- package/cli/selectors.ts +205 -0
- package/dist/Animated.d.ts +120 -0
- package/dist/ChatList.d.ts +28 -0
- package/dist/Dimensions.d.ts +31 -0
- package/dist/StyleSheet.d.ts +18 -0
- package/dist/Window.d.ts +33 -0
- package/dist/apis.d.ts +165 -0
- package/dist/app-state.d.ts +27 -0
- package/dist/chat-list-types.d.ts +136 -0
- package/dist/colors.d.ts +32 -0
- package/dist/commands.d.ts +230 -0
- package/dist/components.d.ts +419 -0
- package/dist/hotModules.d.ts +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.development.js +14876 -0
- package/dist/index.js +12 -0
- package/dist/keyboard.d.ts +140 -0
- package/dist/native-menu.d.ts +7 -0
- package/dist/platform-driver.d.ts +32 -0
- package/dist/platform-services.d.ts +35 -0
- package/dist/portal.d.ts +43 -0
- package/dist/raf.d.ts +4 -0
- package/dist/reanimated/colors-processor-shim.d.ts +10 -0
- package/dist/reanimated/reanimated-host.d.ts +10 -0
- package/dist/reanimated/seam.d.ts +34 -0
- package/dist/reanimated/ui-entry.d.ts +2 -0
- package/dist/reanimated/worklet-channel.d.ts +10 -0
- package/dist/reanimated/worklet-runtime.d.ts +466 -0
- package/dist/reanimated/worklets.d.ts +199 -0
- package/dist/reconciler.d.ts +102 -0
- package/dist/refresh.d.ts +1 -0
- package/dist/render.d.ts +37 -0
- package/dist/runtime.d.ts +235 -0
- package/dist/surfaces.d.ts +51 -0
- package/dist/types.d.ts +276 -0
- package/dist/ui-runtime.js +42276 -0
- package/dist/window-context.d.ts +7 -0
- package/dist/window-host.d.ts +41 -0
- package/dist/wire-delta.d.ts +20 -0
- package/package.json +176 -5
- package/scripts/bundle-app.mjs +88 -0
- package/scripts/conformance-utils.mjs +293 -0
- package/scripts/hot-update-alias-plugin.mjs +88 -0
- package/scripts/native-package-exports-plugin.mjs +235 -0
- package/scripts/pixel.mjs +152 -0
- package/scripts/png.mjs +198 -0
- package/scripts/react-refresh-swc.mjs +35 -0
- package/scripts/reanimated-bun-plugin.mjs +188 -0
- package/scripts/service-binary.d.mts +27 -0
- package/scripts/service-binary.mjs +100 -0
- package/src/reanimated/colors-processor-shim.ts +119 -0
- package/src/reanimated/reanimated-host.ts +69 -0
- package/src/reanimated/rngpui-reanimated-prebuilt.d.ts +7 -0
- package/src/reanimated/seam.ts +566 -0
- package/src/reanimated/ui-entry.ts +80 -0
- package/src/reanimated/worklet-channel.ts +64 -0
- package/src/reanimated/worklet-runtime.ts +2569 -0
- package/src/reanimated/worklets.ts +1334 -0
- 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
|
+
}
|