@symbiote-native/engine 0.1.0
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/LICENSE +21 -0
- package/README.md +124 -0
- package/build/accessibility-info/index.android.d.ts +3 -0
- package/build/accessibility-info/index.android.js +166 -0
- package/build/accessibility-info/index.d.ts +1 -0
- package/build/accessibility-info/index.ios.d.ts +3 -0
- package/build/accessibility-info/index.ios.js +219 -0
- package/build/accessibility-info/index.js +5 -0
- package/build/accessibility-info/shared.d.ts +34 -0
- package/build/accessibility-info/shared.js +13 -0
- package/build/action-sheet-ios/index.d.ts +36 -0
- package/build/action-sheet-ios/index.js +74 -0
- package/build/alert/index.android.d.ts +5 -0
- package/build/alert/index.android.js +117 -0
- package/build/alert/index.d.ts +1 -0
- package/build/alert/index.ios.d.ts +7 -0
- package/build/alert/index.ios.js +83 -0
- package/build/alert/index.js +8 -0
- package/build/alert/shared.d.ts +19 -0
- package/build/alert/shared.js +17 -0
- package/build/animated/animated-component-shared.d.ts +5 -0
- package/build/animated/animated-component-shared.js +54 -0
- package/build/animated/animation.d.ts +9 -0
- package/build/animated/animation.js +6 -0
- package/build/animated/animations/base.d.ts +27 -0
- package/build/animated/animations/base.js +90 -0
- package/build/animated/animations/composition.d.ts +38 -0
- package/build/animated/animations/composition.js +236 -0
- package/build/animated/animations/decay.d.ts +22 -0
- package/build/animated/animations/decay.js +65 -0
- package/build/animated/animations/raf.d.ts +5 -0
- package/build/animated/animations/raf.js +39 -0
- package/build/animated/animations/spring-config.d.ts +6 -0
- package/build/animated/animations/spring-config.js +55 -0
- package/build/animated/animations/spring.d.ts +50 -0
- package/build/animated/animations/spring.js +207 -0
- package/build/animated/animations/timing.d.ts +27 -0
- package/build/animated/animations/timing.js +101 -0
- package/build/animated/animations/tracking.d.ts +14 -0
- package/build/animated/animations/tracking.js +43 -0
- package/build/animated/bezier.d.ts +1 -0
- package/build/animated/bezier.js +101 -0
- package/build/animated/color.d.ts +37 -0
- package/build/animated/color.js +183 -0
- package/build/animated/easing.d.ts +20 -0
- package/build/animated/easing.js +96 -0
- package/build/animated/event.d.ts +36 -0
- package/build/animated/event.js +252 -0
- package/build/animated/graph.d.ts +38 -0
- package/build/animated/graph.js +227 -0
- package/build/animated/index.d.ts +20 -0
- package/build/animated/index.js +28 -0
- package/build/animated/interpolation-node.d.ts +16 -0
- package/build/animated/interpolation-node.js +57 -0
- package/build/animated/interpolation.d.ts +22 -0
- package/build/animated/interpolation.js +199 -0
- package/build/animated/mock.d.ts +56 -0
- package/build/animated/mock.js +127 -0
- package/build/animated/native/native-animated.d.ts +43 -0
- package/build/animated/native/native-animated.js +146 -0
- package/build/animated/operators.d.ts +80 -0
- package/build/animated/operators.js +266 -0
- package/build/animated/props.d.ts +20 -0
- package/build/animated/props.js +187 -0
- package/build/animated/style.d.ts +26 -0
- package/build/animated/style.js +187 -0
- package/build/animated/value-xy.d.ts +35 -0
- package/build/animated/value-xy.js +106 -0
- package/build/animated/value.d.ts +36 -0
- package/build/animated/value.js +185 -0
- package/build/app-registry/index.d.ts +40 -0
- package/build/app-registry/index.js +144 -0
- package/build/app-state/index.d.ts +16 -0
- package/build/app-state/index.js +105 -0
- package/build/appearance/index.d.ts +12 -0
- package/build/appearance/index.js +84 -0
- package/build/back-handler/index.d.ts +14 -0
- package/build/back-handler/index.js +106 -0
- package/build/commit.d.ts +16 -0
- package/build/commit.js +678 -0
- package/build/debug.d.ts +5 -0
- package/build/debug.js +18 -0
- package/build/dimensions/index.d.ts +28 -0
- package/build/dimensions/index.js +148 -0
- package/build/dispatch.d.ts +2 -0
- package/build/dispatch.js +18 -0
- package/build/events/index.d.ts +1 -0
- package/build/events/index.js +691 -0
- package/build/fabric.d.ts +32 -0
- package/build/fabric.js +59 -0
- package/build/host-instance/index.d.ts +11 -0
- package/build/host-instance/index.js +49 -0
- package/build/i18n-manager/index.d.ts +13 -0
- package/build/i18n-manager/index.js +91 -0
- package/build/index.d.ts +80 -0
- package/build/index.js +72 -0
- package/build/interaction-manager/index.d.ts +45 -0
- package/build/interaction-manager/index.js +222 -0
- package/build/keyboard/index.d.ts +31 -0
- package/build/keyboard/index.js +142 -0
- package/build/layout-animation/index.d.ts +66 -0
- package/build/layout-animation/index.js +183 -0
- package/build/linking/index.android.d.ts +2 -0
- package/build/linking/index.android.js +18 -0
- package/build/linking/index.d.ts +1 -0
- package/build/linking/index.ios.d.ts +2 -0
- package/build/linking/index.ios.js +9 -0
- package/build/linking/index.js +6 -0
- package/build/linking/shared.d.ts +32 -0
- package/build/linking/shared.js +98 -0
- package/build/native-events.d.ts +24 -0
- package/build/native-events.js +129 -0
- package/build/native-modules.d.ts +6 -0
- package/build/native-modules.js +57 -0
- package/build/node.d.ts +36 -0
- package/build/node.js +194 -0
- package/build/pan-responder/index.d.ts +53 -0
- package/build/pan-responder/index.js +353 -0
- package/build/permissions-android/index.d.ts +115 -0
- package/build/permissions-android/index.js +185 -0
- package/build/pixel-ratio/index.d.ts +8 -0
- package/build/pixel-ratio/index.js +27 -0
- package/build/platform/index.android.d.ts +22 -0
- package/build/platform/index.android.js +60 -0
- package/build/platform/index.d.ts +1 -0
- package/build/platform/index.ios.d.ts +18 -0
- package/build/platform/index.ios.js +62 -0
- package/build/platform/index.js +5 -0
- package/build/platform/shared.d.ts +25 -0
- package/build/platform/shared.js +41 -0
- package/build/platform-color.d.ts +19 -0
- package/build/platform-color.js +25 -0
- package/build/post-commit.d.ts +4 -0
- package/build/post-commit.js +16 -0
- package/build/process-aspect-ratio.d.ts +1 -0
- package/build/process-aspect-ratio.js +34 -0
- package/build/process-background-image/index.d.ts +28 -0
- package/build/process-background-image/index.js +557 -0
- package/build/process-box-shadow/index.d.ts +11 -0
- package/build/process-box-shadow/index.js +193 -0
- package/build/process-filter.d.ts +31 -0
- package/build/process-filter.js +304 -0
- package/build/process-font-variant.d.ts +1 -0
- package/build/process-font-variant.js +17 -0
- package/build/process-transform/index.d.ts +5 -0
- package/build/process-transform/index.js +120 -0
- package/build/process-transform-origin/index.d.ts +3 -0
- package/build/process-transform-origin/index.js +108 -0
- package/build/registry.d.ts +31 -0
- package/build/registry.js +145 -0
- package/build/settings/index.d.ts +8 -0
- package/build/settings/index.js +126 -0
- package/build/share/index.android.d.ts +3 -0
- package/build/share/index.android.js +56 -0
- package/build/share/index.d.ts +1 -0
- package/build/share/index.ios.d.ts +3 -0
- package/build/share/index.ios.js +47 -0
- package/build/share/index.js +6 -0
- package/build/share/shared.d.ts +32 -0
- package/build/share/shared.js +32 -0
- package/build/status-bar/index.android.d.ts +5 -0
- package/build/status-bar/index.android.js +83 -0
- package/build/status-bar/index.d.ts +1 -0
- package/build/status-bar/index.ios.d.ts +5 -0
- package/build/status-bar/index.ios.js +66 -0
- package/build/status-bar/index.js +4 -0
- package/build/status-bar/shared.d.ts +22 -0
- package/build/status-bar/shared.js +22 -0
- package/build/style/index.d.ts +1 -0
- package/build/style/index.js +30 -0
- package/build/style-registry/index.d.ts +11 -0
- package/build/style-registry/index.js +165 -0
- package/build/style-sheet/index.d.ts +20 -0
- package/build/style-sheet/index.js +121 -0
- package/build/styles.d.ts +220 -0
- package/build/styles.js +7 -0
- package/build/surface.d.ts +16 -0
- package/build/surface.js +67 -0
- package/build/tags.d.ts +1 -0
- package/build/tags.js +10 -0
- package/build/text-input-state.d.ts +5 -0
- package/build/text-input-state.js +29 -0
- package/build/toast-android/index.d.ts +10 -0
- package/build/toast-android/index.js +108 -0
- package/build/vibration/index.android.d.ts +2 -0
- package/build/vibration/index.android.js +18 -0
- package/build/vibration/index.d.ts +1 -0
- package/build/vibration/index.ios.d.ts +2 -0
- package/build/vibration/index.ios.js +54 -0
- package/build/vibration/index.js +6 -0
- package/build/vibration/shared.d.ts +15 -0
- package/build/vibration/shared.js +68 -0
- package/build/view-config.d.ts +1 -0
- package/build/view-config.js +114 -0
- package/package.json +41 -0
package/build/debug.d.ts
ADDED
package/build/debug.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Opt-in diagnostic logging, off by default. Two switches, either flips it on:
|
|
2
|
+
// - env: DEBUG=1 — read directly off process.env.DEBUG at call time (Node,
|
|
3
|
+
// headless smokes); each example's index.js also mirrors it onto
|
|
4
|
+
// globalThis.__SYMBIOTE_DEBUG__ once at start, so changing it needs a fresh
|
|
5
|
+
// Metro start (--reset-cache), not a rebuild.
|
|
6
|
+
// - runtime: globalThis.__SYMBIOTE_DEBUG__ = true, an escape hatch for hosts
|
|
7
|
+
// where the env isn't reachable.
|
|
8
|
+
// Production with neither set pays one property read per call and nothing else.
|
|
9
|
+
function envEnabled() {
|
|
10
|
+
return typeof process !== 'undefined' && process.env.DEBUG === '1';
|
|
11
|
+
}
|
|
12
|
+
export function isDebug() {
|
|
13
|
+
return globalThis.__SYMBIOTE_DEBUG__ === true || envEnabled();
|
|
14
|
+
}
|
|
15
|
+
export function dlog(message) {
|
|
16
|
+
if (isDebug())
|
|
17
|
+
console.log(`[symbiote] ${message}`);
|
|
18
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type IEventSubscription } from '../native-events';
|
|
2
|
+
export interface IDisplayMetrics {
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
scale: number;
|
|
6
|
+
fontScale: number;
|
|
7
|
+
}
|
|
8
|
+
export interface IDisplayMetricsAndroid extends IDisplayMetrics {
|
|
9
|
+
densityDpi: number;
|
|
10
|
+
}
|
|
11
|
+
export interface IDimensionsPayload {
|
|
12
|
+
window?: IDisplayMetrics;
|
|
13
|
+
screen?: IDisplayMetrics;
|
|
14
|
+
windowPhysicalPixels?: IDisplayMetricsAndroid;
|
|
15
|
+
screenPhysicalPixels?: IDisplayMetricsAndroid;
|
|
16
|
+
}
|
|
17
|
+
export interface IDimensionsSet {
|
|
18
|
+
window: IDisplayMetrics;
|
|
19
|
+
screen: IDisplayMetrics;
|
|
20
|
+
}
|
|
21
|
+
export type IDimensionsKey = keyof IDimensionsSet;
|
|
22
|
+
export type IDimensionsChangeListener = (set: IDimensionsSet) => void;
|
|
23
|
+
export interface IDimensionsStatic {
|
|
24
|
+
get(dim: IDimensionsKey): IDisplayMetrics;
|
|
25
|
+
set(dims: IDimensionsPayload): void;
|
|
26
|
+
addEventListener(type: 'change', listener: IDimensionsChangeListener): IEventSubscription;
|
|
27
|
+
}
|
|
28
|
+
export declare const Dimensions: IDimensionsStatic;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
// Screen metrics: a faithful, iOS-first port of React Native's
|
|
2
|
+
// Libraries/Utilities/Dimensions.js. Native ships initial window/screen metrics in
|
|
3
|
+
// the DeviceInfo module's getConstants().Dimensions, and pushes later updates (e.g.
|
|
4
|
+
// rotation, font-scale change) through the device hub as a 'didUpdateDimensions'
|
|
5
|
+
// event whose payload IS a fresh IDimensionsPayload. We cache the metrics and notify
|
|
6
|
+
// 'change' listeners on each update, exactly as RN does.
|
|
7
|
+
//
|
|
8
|
+
// The native contract is confirmed from RN's TurboModule spec at
|
|
9
|
+
// .vendors/.../specs_DEPRECATED/modules/INativeDeviceInfo.js:
|
|
10
|
+
// getConstants(): { Dimensions: { window?, screen?, windowPhysicalPixels?,
|
|
11
|
+
// screenPhysicalPixels? } }
|
|
12
|
+
// We resolve it through the same generic native-module bridge as Platform
|
|
13
|
+
// (getNativeModule), so this module stays importable headless before a fake proxy
|
|
14
|
+
// is installed.
|
|
15
|
+
import { getNativeModule } from '../native-modules';
|
|
16
|
+
import { installDeviceEventHub, NativeEventEmitter, } from '../native-events';
|
|
17
|
+
import { dlog } from '../debug';
|
|
18
|
+
// The native module name RN registers device metrics under.
|
|
19
|
+
const DEVICE_INFO_MODULE = 'DeviceInfo';
|
|
20
|
+
// The device event native emits when metrics change; its payload is a fresh
|
|
21
|
+
// IDimensionsPayload (INativeDeviceInfo / Dimensions.js subscribe to this name).
|
|
22
|
+
const DID_UPDATE_DIMENSIONS = 'didUpdateDimensions';
|
|
23
|
+
// Used when the native module is unresolvable (headless, or a binary without it):
|
|
24
|
+
// RN's getConstants() would throw, but a Dimensions read must never crash a render.
|
|
25
|
+
// A scale of 1 is the neutral "non-retina" default PixelRatio falls back to.
|
|
26
|
+
const DEFAULT_SCALE = 1;
|
|
27
|
+
const ZERO_METRICS = {
|
|
28
|
+
width: 0,
|
|
29
|
+
height: 0,
|
|
30
|
+
scale: DEFAULT_SCALE,
|
|
31
|
+
fontScale: DEFAULT_SCALE,
|
|
32
|
+
};
|
|
33
|
+
// The trust boundary: native getConstants() crosses from an untyped HostObject into
|
|
34
|
+
// our types here, behind a structural guard (no per-call cast). A shape that fails
|
|
35
|
+
// the guard is treated as "module absent".
|
|
36
|
+
function isRecord(value) {
|
|
37
|
+
return typeof value === 'object' && value !== null;
|
|
38
|
+
}
|
|
39
|
+
function isDimensionsConstants(value) {
|
|
40
|
+
return isRecord(value) && isRecord(value.Dimensions);
|
|
41
|
+
}
|
|
42
|
+
function isDimensionsPayload(value) {
|
|
43
|
+
return isRecord(value);
|
|
44
|
+
}
|
|
45
|
+
const changeListeners = new Set();
|
|
46
|
+
// Cached, resolved metrics. `undefined` = not yet set, so we know to swallow the
|
|
47
|
+
// first 'change' (RN's dimensionsInitialized flag: native pushes an initial set we
|
|
48
|
+
// must not surface as a change).
|
|
49
|
+
let cached;
|
|
50
|
+
// Derive point-space metrics from a payload, mirroring Dimensions.set(): the Android
|
|
51
|
+
// *PhysicalPixels variants divide by scale into points; absent a screen, it mirrors
|
|
52
|
+
// the window.
|
|
53
|
+
function resolveMetrics(payload) {
|
|
54
|
+
let window = payload.window;
|
|
55
|
+
if (payload.windowPhysicalPixels !== undefined) {
|
|
56
|
+
window = toPointSpace(payload.windowPhysicalPixels);
|
|
57
|
+
}
|
|
58
|
+
let screen = payload.screen;
|
|
59
|
+
if (payload.screenPhysicalPixels !== undefined) {
|
|
60
|
+
screen = toPointSpace(payload.screenPhysicalPixels);
|
|
61
|
+
}
|
|
62
|
+
else if (screen === undefined) {
|
|
63
|
+
screen = window;
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
window: window ?? ZERO_METRICS,
|
|
67
|
+
screen: screen ?? window ?? ZERO_METRICS,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function toPointSpace(pixels) {
|
|
71
|
+
return {
|
|
72
|
+
width: pixels.width / pixels.scale,
|
|
73
|
+
height: pixels.height / pixels.scale,
|
|
74
|
+
scale: pixels.scale,
|
|
75
|
+
fontScale: pixels.fontScale,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
// Apply a fresh payload and notify 'change' subscribers, except the very first
|
|
79
|
+
// set, which seeds the cache without firing (the initial native push is not a
|
|
80
|
+
// "change"). This is the sink for both getConstants() and 'didUpdateDimensions'.
|
|
81
|
+
function setDimensions(payload) {
|
|
82
|
+
const isFirst = cached === undefined;
|
|
83
|
+
cached = resolveMetrics(payload);
|
|
84
|
+
if (isFirst)
|
|
85
|
+
return;
|
|
86
|
+
dlog(`Dimensions: 'change' -> window ${cached.window.width}x${cached.window.height}`);
|
|
87
|
+
for (const listener of [...changeListeners])
|
|
88
|
+
listener(cached);
|
|
89
|
+
}
|
|
90
|
+
// Resolve initial metrics lazily and subscribe to native updates once. Re-attempts
|
|
91
|
+
// on each call until a valid module is cached, so a later-installed DeviceInfo still
|
|
92
|
+
// gets picked up (same pattern as platform.ts).
|
|
93
|
+
let updateSubscription;
|
|
94
|
+
function ensureResolved() {
|
|
95
|
+
if (cached !== undefined)
|
|
96
|
+
return cached;
|
|
97
|
+
// Subscribe BEFORE reading constants so an update fired in between isn't missed
|
|
98
|
+
// (RN orders the addListener before the getConstants call for the same reason).
|
|
99
|
+
if (updateSubscription === undefined) {
|
|
100
|
+
const module = getNativeModule(DEVICE_INFO_MODULE);
|
|
101
|
+
installDeviceEventHub();
|
|
102
|
+
const emitter = new NativeEventEmitter(undefined);
|
|
103
|
+
updateSubscription = emitter.addListener(DID_UPDATE_DIMENSIONS, payload => {
|
|
104
|
+
if (isDimensionsPayload(payload))
|
|
105
|
+
setDimensions(payload);
|
|
106
|
+
});
|
|
107
|
+
if (module === null) {
|
|
108
|
+
dlog('Dimensions: DeviceInfo not resolvable via native bridge — using zero metrics');
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
const constants = module.getConstants();
|
|
112
|
+
if (isDimensionsConstants(constants)) {
|
|
113
|
+
dlog('Dimensions: resolved initial metrics from DeviceInfo.getConstants()');
|
|
114
|
+
setDimensions(constants.Dimensions);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
dlog('Dimensions: DeviceInfo.getConstants() returned an unexpected shape — using zero metrics');
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return cached ?? { window: ZERO_METRICS, screen: ZERO_METRICS };
|
|
122
|
+
}
|
|
123
|
+
export const Dimensions = {
|
|
124
|
+
get(dim) {
|
|
125
|
+
return ensureResolved()[dim];
|
|
126
|
+
},
|
|
127
|
+
// RN exposes this as a public static (Dimensions.js:63); native pushes metrics
|
|
128
|
+
// through it. Delegates to the internal setter, which caches and fires 'change'.
|
|
129
|
+
set(dims) {
|
|
130
|
+
setDimensions(dims);
|
|
131
|
+
},
|
|
132
|
+
// `_type` is fixed to 'change' for RN signature parity; Dimensions emits no other.
|
|
133
|
+
addEventListener(_type, listener) {
|
|
134
|
+
// Resolve on first subscribe too, so the native update bridge is wired even if
|
|
135
|
+
// get() was never called first.
|
|
136
|
+
ensureResolved();
|
|
137
|
+
changeListeners.add(listener);
|
|
138
|
+
let removed = false;
|
|
139
|
+
return {
|
|
140
|
+
remove: () => {
|
|
141
|
+
if (removed)
|
|
142
|
+
return;
|
|
143
|
+
removed = true;
|
|
144
|
+
changeListeners.delete(listener);
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
},
|
|
148
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// The one place a native event re-enters a framework's update loop. A native
|
|
2
|
+
// event (a touch from Fabric, a keyboard event from the device hub) runs its
|
|
3
|
+
// listener (which may call setState) OUTSIDE the framework's own loop. The
|
|
4
|
+
// adapter injects a wrapper that runs the listener at the right priority and
|
|
5
|
+
// flushes synchronously so the result paints (React: discrete lane +
|
|
6
|
+
// flushSyncWork). Both event rails, Fabric events (events.ts) and device-module
|
|
7
|
+
// events (native-events.ts), route through this single seam, so the adapter
|
|
8
|
+
// wires it once and both are covered. Default is a pass-through for adapters (and
|
|
9
|
+
// the headless harness) that need no wrapping.
|
|
10
|
+
let wrapDispatch = run => {
|
|
11
|
+
run();
|
|
12
|
+
};
|
|
13
|
+
export function setEventDispatcher(wrap) {
|
|
14
|
+
wrapDispatch = wrap;
|
|
15
|
+
}
|
|
16
|
+
export function runWrapped(run) {
|
|
17
|
+
wrapDispatch(run);
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function installEventHandler(): void;
|