@lynxship/expo 0.1.6 → 0.1.8
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/README.md +77 -4
- package/android/build.gradle +1 -0
- package/android/src/main/java/com/lynxship/expo/LynxShipExpoModule.kt +51 -3
- package/android/src/main/java/com/lynxship/expo/LynxShipExpoView.kt +262 -6
- package/app.plugin.cjs +58 -1
- package/asset-sync.cjs.d.cts +43 -0
- package/dist/config.d.ts +11 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +13 -0
- package/dist/index.d.ts +72 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -11
- package/ios/LynxShipExpoModule.swift +39 -3
- package/ios/LynxShipExpoView.swift +234 -7
- package/package.json +12 -5
- package/src/config.ts +36 -0
- package/src/externals.d.ts +14 -1
- package/src/index.ts +103 -10
package/src/externals.d.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
declare module "react" {
|
|
2
|
-
export
|
|
2
|
+
export interface ReactElement {
|
|
3
|
+
readonly type: unknown;
|
|
4
|
+
readonly props: unknown;
|
|
5
|
+
}
|
|
6
|
+
export type ReactNode =
|
|
7
|
+
| ReactElement
|
|
8
|
+
| string
|
|
9
|
+
| number
|
|
10
|
+
| boolean
|
|
11
|
+
| null
|
|
12
|
+
| undefined;
|
|
3
13
|
export type ComponentType<Props = Record<string, unknown>> = (
|
|
4
14
|
props: Props,
|
|
5
15
|
) => ReactNode;
|
|
@@ -7,6 +17,9 @@ declare module "react" {
|
|
|
7
17
|
type: unknown,
|
|
8
18
|
props: Record<string, unknown> | null,
|
|
9
19
|
): ReactNode;
|
|
20
|
+
export function forwardRef<T, Props>(
|
|
21
|
+
render: (props: Props, ref: T | null) => ReactNode,
|
|
22
|
+
): ComponentType<Props & { ref?: T | null }>;
|
|
10
23
|
}
|
|
11
24
|
|
|
12
25
|
declare module "react-native" {
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
createElement,
|
|
3
|
+
forwardRef,
|
|
4
|
+
type ComponentType,
|
|
5
|
+
type ReactNode,
|
|
6
|
+
} from "react";
|
|
2
7
|
import { requireNativeViewManager } from "expo-modules-core";
|
|
3
8
|
import type { ViewProps } from "react-native";
|
|
4
9
|
import {
|
|
@@ -15,24 +20,112 @@ export interface LynxViewProps extends ViewProps {
|
|
|
15
20
|
bundle?: string;
|
|
16
21
|
/** Optional initial data passed to Lynx when the view is rendered. */
|
|
17
22
|
initialData?: string;
|
|
23
|
+
/** Global props exposed as `lynx.__globalProps` in the loaded Lynx page. */
|
|
24
|
+
globalProps?: Readonly<Record<string, unknown>>;
|
|
25
|
+
/** Injects the standard OS, size, safe-area and lifecycle host props. */
|
|
26
|
+
autoGlobalProps?: boolean;
|
|
18
27
|
/** Requests a fresh render after an OTA candidate has been activated. */
|
|
19
28
|
reloadOnUpdate?: boolean;
|
|
29
|
+
/** Emitted after Lynx reports that the first screen layout completed. */
|
|
30
|
+
onReady?: (event: LynxViewReadyEvent) => void;
|
|
31
|
+
/** Emitted when Lynx begins loading a bundle. */
|
|
32
|
+
onLoadStart?: (event: LynxViewLoadStartEvent) => void;
|
|
33
|
+
/** Emitted when the native provider starts fetching bundle bytes. */
|
|
34
|
+
onResourceFetchStart?: (event: LynxViewResourceFetchStartEvent) => void;
|
|
35
|
+
/** Emitted when the first rendered screen is available. */
|
|
36
|
+
onLoadSuccess?: (event: LynxViewReadyEvent) => void;
|
|
37
|
+
/** Emitted when the native host or bundle provider reports an error. */
|
|
38
|
+
onError?: (event: LynxViewErrorEvent) => void;
|
|
39
|
+
/** Emitted after a verified OTA candidate has been activated. */
|
|
40
|
+
onUpdate?: (event: LynxViewUpdateEvent) => void;
|
|
41
|
+
/** Emitted when the native Lynx view becomes visible. */
|
|
42
|
+
onShow?: () => void;
|
|
43
|
+
/** Emitted when the native Lynx view leaves the window. */
|
|
44
|
+
onHide?: () => void;
|
|
20
45
|
}
|
|
21
46
|
|
|
22
|
-
|
|
47
|
+
export interface LynxViewLoadStartEvent {
|
|
48
|
+
readonly nativeEvent: { readonly bundle: string };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface LynxViewResourceFetchStartEvent {
|
|
52
|
+
readonly nativeEvent: { readonly bundle: string };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface LynxViewReadyEvent {
|
|
56
|
+
readonly nativeEvent: {
|
|
57
|
+
readonly bundle: string;
|
|
58
|
+
readonly sequence: number;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface LynxViewErrorEvent {
|
|
63
|
+
readonly nativeEvent: {
|
|
64
|
+
readonly message: string;
|
|
65
|
+
readonly recoverable?: boolean;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface LynxViewUpdateEvent {
|
|
70
|
+
readonly nativeEvent: {
|
|
71
|
+
readonly sequence: number;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface LynxViewViewport {
|
|
76
|
+
readonly width: number;
|
|
77
|
+
readonly height: number;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export type LynxViewLoadState =
|
|
81
|
+
| "idle"
|
|
82
|
+
| "loading"
|
|
83
|
+
| "loaded"
|
|
84
|
+
| "failed"
|
|
85
|
+
| "released";
|
|
86
|
+
|
|
87
|
+
/** Imperative controls implemented by the native LynxView ref. */
|
|
88
|
+
export interface LynxViewRef {
|
|
89
|
+
getContainerId(): Promise<string>;
|
|
90
|
+
getLoadState(): Promise<LynxViewLoadState>;
|
|
91
|
+
isLoadSuccess(): Promise<boolean>;
|
|
92
|
+
reload(): Promise<void>;
|
|
93
|
+
/** Updates Lynx initData without remounting the native view. */
|
|
94
|
+
updateData(data: string, processorName?: string): Promise<void>;
|
|
95
|
+
updateGlobalProps(props: Readonly<Record<string, unknown>>): Promise<void>;
|
|
96
|
+
/** Merges a partial global-props patch without remounting the Lynx page. */
|
|
97
|
+
updateGlobalPropsByIncrement(
|
|
98
|
+
props: Readonly<Record<string, unknown>>,
|
|
99
|
+
): Promise<void>;
|
|
100
|
+
sendGlobalEvent(
|
|
101
|
+
eventName: string,
|
|
102
|
+
params?: readonly unknown[],
|
|
103
|
+
): Promise<void>;
|
|
104
|
+
show(): Promise<void>;
|
|
105
|
+
hide(): Promise<void>;
|
|
106
|
+
updateViewport(viewport: LynxViewViewport): Promise<void>;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const NativeLynxView = requireNativeViewManager<
|
|
110
|
+
LynxViewProps & { ref?: LynxViewRef | null }
|
|
111
|
+
>("LynxShip");
|
|
23
112
|
|
|
24
113
|
/**
|
|
25
114
|
* A LynxView that can be placed anywhere in an Expo/React Native view tree.
|
|
26
115
|
* Native OTA configuration is supplied by the LynxShip config plugin.
|
|
27
116
|
*/
|
|
28
|
-
export
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
117
|
+
export const LynxView = forwardRef<LynxViewRef, LynxViewProps>(
|
|
118
|
+
(props, ref): ReactNode =>
|
|
119
|
+
createElement(NativeLynxView, {
|
|
120
|
+
bundle: props.bundle ?? "main.lynx.bundle",
|
|
121
|
+
initialData: props.initialData ?? "",
|
|
122
|
+
globalProps: props.globalProps ?? {},
|
|
123
|
+
autoGlobalProps: props.autoGlobalProps ?? true,
|
|
124
|
+
reloadOnUpdate: props.reloadOnUpdate ?? true,
|
|
125
|
+
...props,
|
|
126
|
+
ref,
|
|
127
|
+
}),
|
|
128
|
+
);
|
|
36
129
|
|
|
37
130
|
export const LynxShipView: ComponentType<LynxViewProps> = LynxView;
|
|
38
131
|
|