@nebula-rn/sdk 0.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/dist/NebulaAPI.d.ts +56 -0
- package/dist/NebulaAPI.js +429 -0
- package/dist/hostApi.d.ts +64 -0
- package/dist/hostApi.js +185 -0
- package/dist/hostProtocol.d.ts +9 -0
- package/dist/hostProtocol.js +153 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +3 -0
- package/dist/miniappLoading.d.ts +18 -0
- package/dist/miniappLoading.js +103 -0
- package/dist/miniappPage.d.ts +7 -0
- package/dist/miniappPage.js +93 -0
- package/dist/miniappRuntime.d.ts +33 -0
- package/dist/miniappRuntime.js +233 -0
- package/dist/nebulaNative.d.ts +12 -0
- package/dist/nebulaNative.js +49 -0
- package/dist/nebulaTypes.d.ts +232 -0
- package/dist/nebulaTypes.js +1 -0
- package/dist/pageConfig.d.ts +10 -0
- package/dist/pageConfig.js +3 -0
- package/dist/specs/NativeNebulaModule.d.ts +86 -0
- package/dist/specs/NativeNebulaModule.js +2 -0
- package/package.json +40 -0
- package/src/NebulaAPI.ts +691 -0
- package/src/hostApi.tsx +364 -0
- package/src/hostProtocol.ts +209 -0
- package/src/index.ts +49 -0
- package/src/miniappLoading.tsx +153 -0
- package/src/miniappPage.tsx +140 -0
- package/src/miniappRuntime.ts +344 -0
- package/src/nebulaNative.ts +87 -0
- package/src/nebulaTypes.ts +328 -0
- package/src/pageConfig.ts +13 -0
- package/src/specs/NativeNebulaModule.ts +140 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { NativeEventEmitter, NativeModules } from 'react-native';
|
|
2
|
+
import type { EmitterSubscription, NativeModule } from 'react-native';
|
|
3
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
4
|
+
import NebulaNativeModuleSpec from './specs/NativeNebulaModule';
|
|
5
|
+
import type {
|
|
6
|
+
BridgeMessage,
|
|
7
|
+
NebulaNativeModuleType,
|
|
8
|
+
NebulaProtocolRequest,
|
|
9
|
+
NebulaProtocolResponse,
|
|
10
|
+
} from './nebulaTypes';
|
|
11
|
+
|
|
12
|
+
const turboNebulaNativeModule =
|
|
13
|
+
(NebulaNativeModuleSpec as unknown as NebulaNativeModuleType | null) ??
|
|
14
|
+
TurboModuleRegistry.get<NebulaNativeModuleType>('NebulaNativeModule');
|
|
15
|
+
|
|
16
|
+
const { NebulaNativeModule: legacyNebulaNativeModule } = NativeModules as {
|
|
17
|
+
NebulaNativeModule?: NebulaNativeModuleType;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const NebulaNativeModule = turboNebulaNativeModule ?? legacyNebulaNativeModule;
|
|
21
|
+
|
|
22
|
+
export const nebulaEventEmitter = legacyNebulaNativeModule
|
|
23
|
+
? new NativeEventEmitter(legacyNebulaNativeModule as unknown as NativeModule)
|
|
24
|
+
: null;
|
|
25
|
+
|
|
26
|
+
export const NEBULA_HOST_MESSAGE_EVENT = 'NebulaHostMessage';
|
|
27
|
+
export const NEBULA_MINI_APP_MESSAGE_EVENT = 'NebulaMiniAppMessage';
|
|
28
|
+
export const NEBULA_PAGE_LIFECYCLE_EVENT = 'NebulaPageLifecycle';
|
|
29
|
+
export const NEBULA_INTERNAL_MINIAPP_LOADING_MODULE =
|
|
30
|
+
'NebulaInternalMiniappLoading';
|
|
31
|
+
|
|
32
|
+
export const PAGE_RESERVED_PROP_KEYS = new Set([
|
|
33
|
+
'appId',
|
|
34
|
+
'instanceId',
|
|
35
|
+
'sandboxPath',
|
|
36
|
+
'title',
|
|
37
|
+
'__pageConfig',
|
|
38
|
+
'__routePath',
|
|
39
|
+
'__routeUrl',
|
|
40
|
+
]);
|
|
41
|
+
|
|
42
|
+
if (!NebulaNativeModule) {
|
|
43
|
+
console.warn(
|
|
44
|
+
'[Nebula] NebulaNativeModule not found. Make sure Nebula framework is integrated.',
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function getNebulaNativeModule(): NebulaNativeModuleType {
|
|
49
|
+
if (!NebulaNativeModule) {
|
|
50
|
+
throw new Error('[Nebula] NebulaNativeModule not available');
|
|
51
|
+
}
|
|
52
|
+
return NebulaNativeModule;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function addNebulaEventListener<TEvent = BridgeMessage>(
|
|
56
|
+
eventName: string,
|
|
57
|
+
listener: (event: TEvent) => void,
|
|
58
|
+
): (() => void) | null {
|
|
59
|
+
if (!nebulaEventEmitter) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
const sub: EmitterSubscription = nebulaEventEmitter.addListener(
|
|
63
|
+
eventName,
|
|
64
|
+
listener,
|
|
65
|
+
);
|
|
66
|
+
return () => sub.remove();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function isProtocolRequest(
|
|
70
|
+
message: Record<string, unknown>,
|
|
71
|
+
): message is NebulaProtocolRequest {
|
|
72
|
+
return (
|
|
73
|
+
message.__nebulaProtocol === 'api.v1' &&
|
|
74
|
+
typeof message.kind === 'string' &&
|
|
75
|
+
typeof message.requestId === 'string'
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function isProtocolResponse(
|
|
80
|
+
message: Record<string, unknown>,
|
|
81
|
+
): message is NebulaProtocolResponse {
|
|
82
|
+
return (
|
|
83
|
+
message.__nebulaProtocol === 'api.v1' &&
|
|
84
|
+
typeof message.kind === 'string' &&
|
|
85
|
+
typeof message.requestId === 'string'
|
|
86
|
+
);
|
|
87
|
+
}
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { TurboModule } from 'react-native';
|
|
3
|
+
import type { NebulaPageStyle } from './specs/NativeNebulaModule';
|
|
4
|
+
|
|
5
|
+
export type { MiniAppUpdateStrategy } from './specs/NativeNebulaModule';
|
|
6
|
+
export type { NebulaPageStyle } from './specs/NativeNebulaModule';
|
|
7
|
+
export type {
|
|
8
|
+
NebulaCapabilitiesResult as NebulaNativeCapabilitiesResult,
|
|
9
|
+
NebulaCapabilityMap as NebulaNativeCapabilityMap,
|
|
10
|
+
} from './specs/NativeNebulaModule';
|
|
11
|
+
|
|
12
|
+
export type MiniAppResult = {
|
|
13
|
+
success: boolean;
|
|
14
|
+
appId: string;
|
|
15
|
+
mode?: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type InstalledMiniAppsResult = {
|
|
19
|
+
apps: string[];
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type InstalledMiniAppInfo = {
|
|
23
|
+
appId: string;
|
|
24
|
+
mode?: string | null;
|
|
25
|
+
bundlePath?: string | null;
|
|
26
|
+
sourceUrl?: string | null;
|
|
27
|
+
version?: string | null;
|
|
28
|
+
updateStrategy?: 'auto' | 'manual' | null;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type InstalledMiniAppInfoResult = {
|
|
32
|
+
installed: boolean;
|
|
33
|
+
app?: InstalledMiniAppInfo | null;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export type MiniAppUpdateInfo = {
|
|
37
|
+
appId: string;
|
|
38
|
+
currentVersion?: string | null;
|
|
39
|
+
latestVersion?: string | null;
|
|
40
|
+
hasUpdate: boolean;
|
|
41
|
+
updateStrategy: 'auto' | 'manual';
|
|
42
|
+
mode?: string | null;
|
|
43
|
+
sourceUrl?: string | null;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export type MiniAppVersionType = 'release' | 'experience';
|
|
47
|
+
|
|
48
|
+
export type MiniappLoadingStatus = 'installing' | 'loading' | 'ready' | 'error';
|
|
49
|
+
|
|
50
|
+
export type MiniappLoadingExtraData = Record<string, unknown>;
|
|
51
|
+
|
|
52
|
+
export type MiniappLoadingProps = {
|
|
53
|
+
appId: string;
|
|
54
|
+
mode: 'development' | 'production';
|
|
55
|
+
status: MiniappLoadingStatus;
|
|
56
|
+
title?: string | null;
|
|
57
|
+
icon?: ReactNode;
|
|
58
|
+
extraData?: MiniappLoadingExtraData | null;
|
|
59
|
+
errorMessage?: string | null;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export type MiniappLoadingResolveContext = {
|
|
63
|
+
appId: string;
|
|
64
|
+
mode: 'development' | 'production';
|
|
65
|
+
status: MiniappLoadingStatus;
|
|
66
|
+
title?: string | null;
|
|
67
|
+
icon?: ReactNode;
|
|
68
|
+
extraData?: MiniappLoadingExtraData | null;
|
|
69
|
+
errorMessage?: string | null;
|
|
70
|
+
installedInfo?: InstalledMiniAppInfo | null;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export type MiniappLoadingResolvedProps = Partial<
|
|
74
|
+
Pick<MiniappLoadingProps, 'title' | 'icon' | 'extraData'>
|
|
75
|
+
>;
|
|
76
|
+
|
|
77
|
+
export type ServerBaseURLResult = {
|
|
78
|
+
serverBaseURL?: string | null;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export type MiniappLoadingDelayResult = {
|
|
82
|
+
delayMs: number;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export type NavigationResult = {
|
|
86
|
+
errMsg: string;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export type HostVisibilityResult = {
|
|
90
|
+
success: boolean;
|
|
91
|
+
token?: string | null;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export type RegisteredMiniAppManifest = {
|
|
95
|
+
entryPagePath?: string;
|
|
96
|
+
pageConfigs?: Record<string, NebulaPageStyle>;
|
|
97
|
+
pages: Record<string, string>;
|
|
98
|
+
updateStrategy?: 'auto' | 'manual';
|
|
99
|
+
version?: string;
|
|
100
|
+
window?: NebulaPageStyle;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export type BridgeMessage = {
|
|
104
|
+
appId: string;
|
|
105
|
+
message: Record<string, unknown>;
|
|
106
|
+
timestamp?: number;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export type NebulaApiError = {
|
|
110
|
+
code: string;
|
|
111
|
+
message: string;
|
|
112
|
+
details?: Record<string, unknown>;
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export type NebulaApiInvokeResult<T = unknown> =
|
|
116
|
+
| {
|
|
117
|
+
ok: true;
|
|
118
|
+
data: T;
|
|
119
|
+
}
|
|
120
|
+
| {
|
|
121
|
+
ok: false;
|
|
122
|
+
error: NebulaApiError;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export type NebulaHostCapabilityDescriptor = {
|
|
126
|
+
supported: boolean;
|
|
127
|
+
version: string;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export type NebulaHostCapabilityMap = Record<
|
|
131
|
+
string,
|
|
132
|
+
NebulaHostCapabilityDescriptor
|
|
133
|
+
>;
|
|
134
|
+
|
|
135
|
+
export type NebulaApiFieldDescriptor = {
|
|
136
|
+
name: string;
|
|
137
|
+
type: string;
|
|
138
|
+
required?: boolean;
|
|
139
|
+
description: string;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export type NebulaApiExampleDescriptor = {
|
|
143
|
+
title: string;
|
|
144
|
+
code: string;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
export type NebulaHostApiDescription = {
|
|
148
|
+
summary: string;
|
|
149
|
+
description?: string;
|
|
150
|
+
params?: NebulaApiFieldDescriptor[];
|
|
151
|
+
returns?: {
|
|
152
|
+
type: string;
|
|
153
|
+
description: string;
|
|
154
|
+
};
|
|
155
|
+
tags?: string[];
|
|
156
|
+
examples?: NebulaApiExampleDescriptor[];
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export type NebulaHostApiDescriptionMap = Record<
|
|
160
|
+
string,
|
|
161
|
+
NebulaHostApiDescription
|
|
162
|
+
>;
|
|
163
|
+
|
|
164
|
+
export type NebulaProtocolRequest =
|
|
165
|
+
| {
|
|
166
|
+
__nebulaProtocol: 'api.v1';
|
|
167
|
+
kind: 'getCapabilities';
|
|
168
|
+
requestId: string;
|
|
169
|
+
}
|
|
170
|
+
| {
|
|
171
|
+
__nebulaProtocol: 'api.v1';
|
|
172
|
+
kind: 'getApiDescriptions';
|
|
173
|
+
requestId: string;
|
|
174
|
+
}
|
|
175
|
+
| {
|
|
176
|
+
__nebulaProtocol: 'api.v1';
|
|
177
|
+
kind: 'invoke';
|
|
178
|
+
requestId: string;
|
|
179
|
+
api: string;
|
|
180
|
+
version?: string;
|
|
181
|
+
payload?: Record<string, unknown>;
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
export type NebulaProtocolResponse =
|
|
185
|
+
| {
|
|
186
|
+
__nebulaProtocol: 'api.v1';
|
|
187
|
+
kind: 'capabilities';
|
|
188
|
+
requestId: string;
|
|
189
|
+
data: {
|
|
190
|
+
bridgeVersion: string;
|
|
191
|
+
capabilities: NebulaHostCapabilityMap;
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
| {
|
|
195
|
+
__nebulaProtocol: 'api.v1';
|
|
196
|
+
kind: 'apiDescriptions';
|
|
197
|
+
requestId: string;
|
|
198
|
+
data: NebulaHostApiDescriptionMap;
|
|
199
|
+
}
|
|
200
|
+
| {
|
|
201
|
+
__nebulaProtocol: 'api.v1';
|
|
202
|
+
kind: 'invokeResult';
|
|
203
|
+
requestId: string;
|
|
204
|
+
result: NebulaApiInvokeResult;
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
export type NebulaHostApiContext = {
|
|
208
|
+
appId: string;
|
|
209
|
+
requestId: string;
|
|
210
|
+
version?: string;
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
export type NebulaHostApiHandler = {
|
|
214
|
+
version: string;
|
|
215
|
+
supported?: boolean | (() => boolean | Promise<boolean>);
|
|
216
|
+
description?: NebulaHostApiDescription;
|
|
217
|
+
handle: (
|
|
218
|
+
payload: Record<string, unknown>,
|
|
219
|
+
context: NebulaHostApiContext,
|
|
220
|
+
) => Promise<NebulaApiInvokeResult> | NebulaApiInvokeResult;
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
export type PendingProtocolRequest = {
|
|
224
|
+
reject: (reason?: unknown) => void;
|
|
225
|
+
resolve: (value: any) => void;
|
|
226
|
+
timeoutId: ReturnType<typeof setTimeout>;
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
export type PageLifecycleEvent = {
|
|
230
|
+
appId: string;
|
|
231
|
+
instanceId: string;
|
|
232
|
+
routePath?: string;
|
|
233
|
+
type: 'show' | 'hide' | 'unload' | 'ready';
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
export type MiniAppPageContextValue = {
|
|
237
|
+
appId: string | null;
|
|
238
|
+
instanceId: string | null;
|
|
239
|
+
params: Record<string, unknown>;
|
|
240
|
+
routePath: string;
|
|
241
|
+
routeUrl: string;
|
|
242
|
+
pageStyle: Record<string, unknown>;
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
export type NebulaNativeModuleType = TurboModule & {
|
|
246
|
+
openMiniApp: (
|
|
247
|
+
appId: string,
|
|
248
|
+
initialProps: Record<string, unknown>,
|
|
249
|
+
) => Promise<MiniAppResult>;
|
|
250
|
+
openMiniAppWithBundleURL: (
|
|
251
|
+
appId: string,
|
|
252
|
+
bundleURL: string,
|
|
253
|
+
connectToURLMetroServer: boolean,
|
|
254
|
+
initialProps: Record<string, unknown>,
|
|
255
|
+
) => Promise<MiniAppResult>;
|
|
256
|
+
preloadMiniApp: (appId: string) => Promise<MiniAppResult>;
|
|
257
|
+
preloadMiniAppWithBundleURL: (
|
|
258
|
+
appId: string,
|
|
259
|
+
bundleURL: string,
|
|
260
|
+
connectToURLMetroServer: boolean,
|
|
261
|
+
) => Promise<MiniAppResult>;
|
|
262
|
+
installMiniApp: (appId: string, bundleURL: string) => Promise<MiniAppResult>;
|
|
263
|
+
installMiniAppWithBundleURL: (
|
|
264
|
+
appId: string,
|
|
265
|
+
bundleURL: string,
|
|
266
|
+
connectToURLMetroServer: boolean,
|
|
267
|
+
) => Promise<MiniAppResult>;
|
|
268
|
+
installMiniAppFromURLs: (
|
|
269
|
+
appId: string,
|
|
270
|
+
bundleURL: string,
|
|
271
|
+
manifestURL: string,
|
|
272
|
+
assetsURL: string,
|
|
273
|
+
connectToURLMetroServer: boolean,
|
|
274
|
+
) => Promise<MiniAppResult>;
|
|
275
|
+
closeMiniApp: (appId: string) => Promise<MiniAppResult>;
|
|
276
|
+
uninstallMiniApp: (appId: string) => Promise<MiniAppResult>;
|
|
277
|
+
getCapabilities: () => Promise<{
|
|
278
|
+
bridgeVersion: string;
|
|
279
|
+
capabilities: Record<string, string>;
|
|
280
|
+
}>;
|
|
281
|
+
getServerBaseURL: () => Promise<ServerBaseURLResult>;
|
|
282
|
+
setServerBaseURL: (
|
|
283
|
+
serverBaseURL?: string | null,
|
|
284
|
+
) => Promise<ServerBaseURLResult>;
|
|
285
|
+
setMiniappLoadingDelay: (
|
|
286
|
+
delayMs?: number | null,
|
|
287
|
+
) => Promise<MiniappLoadingDelayResult>;
|
|
288
|
+
setMiniappLoadingEnterContentDelay: (
|
|
289
|
+
delayMs?: number | null,
|
|
290
|
+
) => Promise<MiniappLoadingDelayResult>;
|
|
291
|
+
registerRoutes: (
|
|
292
|
+
appId: string,
|
|
293
|
+
routes: Record<string, string>,
|
|
294
|
+
) => Promise<{ success: boolean; appId: string; count: number }>;
|
|
295
|
+
registerManifest: (
|
|
296
|
+
appId: string,
|
|
297
|
+
manifest: RegisteredMiniAppManifest,
|
|
298
|
+
) => Promise<{ success: boolean; appId: string; count: number }>;
|
|
299
|
+
postMessageToHost: (
|
|
300
|
+
appId: string,
|
|
301
|
+
message: Record<string, unknown>,
|
|
302
|
+
) => Promise<NavigationResult>;
|
|
303
|
+
postMessageToMiniApp: (
|
|
304
|
+
appId: string,
|
|
305
|
+
message: Record<string, unknown>,
|
|
306
|
+
) => Promise<NavigationResult>;
|
|
307
|
+
bringHostToFront: () => Promise<HostVisibilityResult>;
|
|
308
|
+
restoreMiniApp: (token?: string | null) => Promise<HostVisibilityResult>;
|
|
309
|
+
presentHostModal: (
|
|
310
|
+
moduleName: string,
|
|
311
|
+
props: Record<string, unknown>,
|
|
312
|
+
) => Promise<NavigationResult>;
|
|
313
|
+
dismissHostModal: () => Promise<NavigationResult>;
|
|
314
|
+
getInstalledMiniApps: () => Promise<InstalledMiniAppsResult>;
|
|
315
|
+
getInstalledMiniAppInfo: (
|
|
316
|
+
appId: string,
|
|
317
|
+
) => Promise<InstalledMiniAppInfoResult>;
|
|
318
|
+
navigateTo: (appId: string, url: string) => Promise<NavigationResult>;
|
|
319
|
+
redirectTo: (appId: string, url: string) => Promise<NavigationResult>;
|
|
320
|
+
reLaunch: (appId: string, url: string) => Promise<NavigationResult>;
|
|
321
|
+
navigateBack: (appId: string, delta: number) => Promise<NavigationResult>;
|
|
322
|
+
setPageStyle: (
|
|
323
|
+
appId: string,
|
|
324
|
+
style: NebulaPageStyle,
|
|
325
|
+
) => Promise<NavigationResult>;
|
|
326
|
+
showToast: (title: string) => Promise<NavigationResult>;
|
|
327
|
+
getDeviceInfo: () => Record<string, unknown>;
|
|
328
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type MiniAppPageConfig = {
|
|
2
|
+
route?: string;
|
|
3
|
+
backgroundColor?: string;
|
|
4
|
+
navigationBarBackgroundColor?: string;
|
|
5
|
+
navigationBarTextColor?: string;
|
|
6
|
+
navigationBarTitleText?: string;
|
|
7
|
+
navigationStyle?: 'default' | 'custom';
|
|
8
|
+
visualEffectInBackground?: 'blur' | 'none';
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export function definePageConfig<T extends MiniAppPageConfig>(config: T): T {
|
|
12
|
+
return config;
|
|
13
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
3
|
+
import type { UnsafeObject } from 'react-native/Libraries/Types/CodegenTypes';
|
|
4
|
+
|
|
5
|
+
export type MiniAppUpdateStrategy = 'auto' | 'manual';
|
|
6
|
+
|
|
7
|
+
export type MiniAppResult = {
|
|
8
|
+
success: boolean;
|
|
9
|
+
appId: string;
|
|
10
|
+
mode?: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type InstalledMiniAppsResult = {
|
|
14
|
+
apps: string[];
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type InstalledMiniAppInfo = {
|
|
18
|
+
appId: string;
|
|
19
|
+
mode?: string | null;
|
|
20
|
+
bundlePath?: string | null;
|
|
21
|
+
sourceUrl?: string | null;
|
|
22
|
+
version?: string | null;
|
|
23
|
+
updateStrategy?: MiniAppUpdateStrategy | null;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type InstalledMiniAppInfoResult = {
|
|
27
|
+
installed: boolean;
|
|
28
|
+
app?: InstalledMiniAppInfo | null;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type ServerBaseURLResult = {
|
|
32
|
+
serverBaseURL?: string | null;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type MiniappLoadingDelayResult = {
|
|
36
|
+
delayMs: number;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export type NebulaCapabilityMap = {
|
|
40
|
+
[capabilityName: string]: string;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type NebulaCapabilitiesResult = {
|
|
44
|
+
bridgeVersion: string;
|
|
45
|
+
capabilities: NebulaCapabilityMap;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export type NavigationResult = {
|
|
49
|
+
errMsg: string;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export type HostVisibilityResult = {
|
|
53
|
+
success: boolean;
|
|
54
|
+
token?: string | null;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export type NebulaPageStyle = {
|
|
58
|
+
backgroundColor?: string;
|
|
59
|
+
navigationBarBackgroundColor?: string;
|
|
60
|
+
navigationBarTextColor?: string;
|
|
61
|
+
navigationBarTitleText?: string;
|
|
62
|
+
navigationStyle?: 'default' | 'custom';
|
|
63
|
+
visualEffectInBackground?: 'blur' | 'none';
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export interface Spec extends TurboModule {
|
|
67
|
+
openMiniApp(
|
|
68
|
+
appId: string,
|
|
69
|
+
initialProps: UnsafeObject,
|
|
70
|
+
): Promise<MiniAppResult>;
|
|
71
|
+
openMiniAppWithBundleURL(
|
|
72
|
+
appId: string,
|
|
73
|
+
bundleURL: string,
|
|
74
|
+
connectToURLMetroServer: boolean,
|
|
75
|
+
initialProps: UnsafeObject,
|
|
76
|
+
): Promise<MiniAppResult>;
|
|
77
|
+
preloadMiniApp(appId: string): Promise<MiniAppResult>;
|
|
78
|
+
preloadMiniAppWithBundleURL(
|
|
79
|
+
appId: string,
|
|
80
|
+
bundleURL: string,
|
|
81
|
+
connectToURLMetroServer: boolean,
|
|
82
|
+
): Promise<MiniAppResult>;
|
|
83
|
+
installMiniApp(appId: string, bundleURL: string): Promise<MiniAppResult>;
|
|
84
|
+
installMiniAppWithBundleURL(
|
|
85
|
+
appId: string,
|
|
86
|
+
bundleURL: string,
|
|
87
|
+
connectToURLMetroServer: boolean,
|
|
88
|
+
): Promise<MiniAppResult>;
|
|
89
|
+
installMiniAppFromURLs(
|
|
90
|
+
appId: string,
|
|
91
|
+
bundleURL: string,
|
|
92
|
+
manifestURL: string,
|
|
93
|
+
assetsURL: string,
|
|
94
|
+
connectToURLMetroServer: boolean,
|
|
95
|
+
): Promise<MiniAppResult>;
|
|
96
|
+
closeMiniApp(appId: string): Promise<MiniAppResult>;
|
|
97
|
+
uninstallMiniApp(appId: string): Promise<MiniAppResult>;
|
|
98
|
+
getCapabilities(): Promise<NebulaCapabilitiesResult>;
|
|
99
|
+
getServerBaseURL(): Promise<ServerBaseURLResult>;
|
|
100
|
+
setServerBaseURL(serverBaseURL?: string | null): Promise<ServerBaseURLResult>;
|
|
101
|
+
setMiniappLoadingDelay(
|
|
102
|
+
delayMs?: number | null,
|
|
103
|
+
): Promise<MiniappLoadingDelayResult>;
|
|
104
|
+
setMiniappLoadingEnterContentDelay(
|
|
105
|
+
delayMs?: number | null,
|
|
106
|
+
): Promise<MiniappLoadingDelayResult>;
|
|
107
|
+
getInstalledMiniApps(): Promise<InstalledMiniAppsResult>;
|
|
108
|
+
getInstalledMiniAppInfo(appId: string): Promise<InstalledMiniAppInfoResult>;
|
|
109
|
+
registerRoutes(appId: string, routes: UnsafeObject): Promise<UnsafeObject>;
|
|
110
|
+
registerManifest(
|
|
111
|
+
appId: string,
|
|
112
|
+
manifest: UnsafeObject,
|
|
113
|
+
): Promise<UnsafeObject>;
|
|
114
|
+
postMessageToHost(
|
|
115
|
+
appId: string,
|
|
116
|
+
message: UnsafeObject,
|
|
117
|
+
): Promise<NavigationResult>;
|
|
118
|
+
postMessageToMiniApp(
|
|
119
|
+
appId: string,
|
|
120
|
+
message: UnsafeObject,
|
|
121
|
+
): Promise<NavigationResult>;
|
|
122
|
+
bringHostToFront(): Promise<HostVisibilityResult>;
|
|
123
|
+
restoreMiniApp(token?: string | null): Promise<HostVisibilityResult>;
|
|
124
|
+
presentHostModal(
|
|
125
|
+
moduleName: string,
|
|
126
|
+
props: UnsafeObject,
|
|
127
|
+
): Promise<NavigationResult>;
|
|
128
|
+
dismissHostModal(): Promise<NavigationResult>;
|
|
129
|
+
|
|
130
|
+
// Mini-app navigation APIs
|
|
131
|
+
navigateTo(appId: string, url: string): Promise<NavigationResult>;
|
|
132
|
+
redirectTo(appId: string, url: string): Promise<NavigationResult>;
|
|
133
|
+
reLaunch(appId: string, url: string): Promise<NavigationResult>;
|
|
134
|
+
navigateBack(appId: string, delta: number): Promise<NavigationResult>;
|
|
135
|
+
setPageStyle(appId: string, style: UnsafeObject): Promise<NavigationResult>;
|
|
136
|
+
showToast(title: string): Promise<NavigationResult>;
|
|
137
|
+
getDeviceInfo(): UnsafeObject;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export default TurboModuleRegistry.get<Spec>('NebulaNativeModule');
|