snack-sdk 3.8.0 → 3.10.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/CHANGELOG.md +27 -1
- package/build/DependencyResolver.d.ts +26 -26
- package/build/DependencyResolver.js +258 -258
- package/build/DevSession.d.ts +20 -20
- package/build/DevSession.js +203 -203
- package/build/FileUploader.d.ts +23 -23
- package/build/FileUploader.js +174 -174
- package/build/Logger.d.ts +11 -11
- package/build/Logger.js +33 -33
- package/build/Session.d.ts +305 -301
- package/build/Session.js +1198 -1171
- package/build/Session.js.map +1 -1
- package/build/State.d.ts +16 -16
- package/build/State.js +90 -90
- package/build/WantedVersions.d.ts +40 -17
- package/build/WantedVersions.js +156 -93
- package/build/WantedVersions.js.map +1 -1
- package/build/defaultConfig.d.ts +12 -12
- package/build/defaultConfig.js +29 -29
- package/build/index.d.ts +7 -7
- package/build/index.js +30 -30
- package/build/transports/CodeMessageBuilder.d.ts +31 -31
- package/build/transports/CodeMessageBuilder.js +196 -196
- package/build/transports/Protocol.d.ts +64 -64
- package/build/transports/Protocol.js +2 -2
- package/build/transports/Transport.d.ts +28 -27
- package/build/transports/Transport.js +303 -298
- package/build/transports/Transport.js.map +1 -1
- package/build/transports/index.d.ts +3 -3
- package/build/transports/index.js +22 -22
- package/build/transports/types.d.ts +63 -63
- package/build/transports/types.js +2 -2
- package/build/transports/webPlayer.d.ts +12 -12
- package/build/transports/webPlayer.js +70 -70
- package/build/types.d.ts +189 -185
- package/build/types.js +2 -2
- package/build/types.js.map +1 -1
- package/build/utils.d.ts +17 -17
- package/build/utils.js +68 -68
- package/package.json +11 -4
- package/src/DependencyResolver.ts +0 -218
- package/src/DevSession.ts +0 -159
- package/src/FileUploader.ts +0 -135
- package/src/Logger.ts +0 -33
- package/src/Session.ts +0 -1293
- package/src/State.ts +0 -98
- package/src/WantedVersions.ts +0 -57
- package/src/defaultConfig.ts +0 -33
- package/src/index.ts +0 -59
- package/src/transports/CodeMessageBuilder.ts +0 -226
- package/src/transports/Protocol.ts +0 -78
- package/src/transports/Transport.ts +0 -270
- package/src/transports/index.ts +0 -8
- package/src/transports/types.ts +0 -89
- package/src/transports/webPlayer.ts +0 -93
- package/src/types.ts +0 -223
- package/src/utils.ts +0 -71
- package/tsconfig.json +0 -28
package/build/Session.d.ts
CHANGED
|
@@ -1,301 +1,305 @@
|
|
|
1
|
-
import { SDKVersion, SnackDependencies, SnackDependency, SnackFile, SnackFiles } from 'snack-content';
|
|
2
|
-
import { SnackTransport, SnackTransportOptions } from './transports';
|
|
3
|
-
import { SnackState, SnackUser, SnackLogEvent, SnackListenerSubscription, SnackConnectedClients, SnackWindowRef } from './types';
|
|
4
|
-
export declare type SnackOptions = {
|
|
5
|
-
sdkVersion?: SDKVersion;
|
|
6
|
-
name?: string;
|
|
7
|
-
description?: string;
|
|
8
|
-
dependencies?: SnackDependencies;
|
|
9
|
-
files?: SnackFiles;
|
|
10
|
-
apiURL?: string;
|
|
11
|
-
host?: string;
|
|
12
|
-
snackagerURL?: string;
|
|
13
|
-
verbose?: boolean;
|
|
14
|
-
disabled?: boolean;
|
|
15
|
-
online?: boolean;
|
|
16
|
-
channel?: string;
|
|
17
|
-
deviceId?: string;
|
|
18
|
-
transports?: {
|
|
19
|
-
[id: string]: SnackTransport;
|
|
20
|
-
};
|
|
21
|
-
createTransport?: (options: SnackTransportOptions) => SnackTransport;
|
|
22
|
-
codeChangesDelay?: number;
|
|
23
|
-
reloadTimeout?: number;
|
|
24
|
-
previewTimeout?: number;
|
|
25
|
-
user?: SnackUser;
|
|
26
|
-
id?: string;
|
|
27
|
-
snackId?: string;
|
|
28
|
-
accountSnackId?: string;
|
|
29
|
-
webPlayerURL?: string;
|
|
30
|
-
webPreviewRef?: SnackWindowRef;
|
|
31
|
-
};
|
|
32
|
-
export declare type SnackSaveOptions = {
|
|
33
|
-
isDraft?: boolean;
|
|
34
|
-
ignoreUser?: boolean;
|
|
35
|
-
};
|
|
36
|
-
export declare type SnackStateListener = (state: SnackState, prevState: SnackState) => any;
|
|
37
|
-
export declare type SnackLogListener = (log: SnackLogEvent) => any;
|
|
38
|
-
export default class Snack {
|
|
39
|
-
private state;
|
|
40
|
-
private stateListeners;
|
|
41
|
-
private logListeners;
|
|
42
|
-
private readonly
|
|
43
|
-
private readonly
|
|
44
|
-
private readonly
|
|
45
|
-
private readonly
|
|
46
|
-
private readonly
|
|
47
|
-
private readonly
|
|
48
|
-
private readonly
|
|
49
|
-
private
|
|
50
|
-
private
|
|
51
|
-
private
|
|
52
|
-
private
|
|
53
|
-
private readonly
|
|
54
|
-
private readonly
|
|
55
|
-
private pruneConnectionsTimer;
|
|
56
|
-
private readonly transportListeners;
|
|
57
|
-
constructor(options: SnackOptions);
|
|
58
|
-
/**
|
|
59
|
-
* Sets the Expo SDK version.
|
|
60
|
-
* @param sdkVersion Valid SDK version (e.g. "38.0.0")
|
|
61
|
-
*/
|
|
62
|
-
setSDKVersion(sdkVersion: SDKVersion): void;
|
|
63
|
-
/**
|
|
64
|
-
* Sets the name of the Snack.
|
|
65
|
-
* @param name E.g. "conspicious orange"
|
|
66
|
-
*/
|
|
67
|
-
setName(name: string): void;
|
|
68
|
-
/**
|
|
69
|
-
* Sets the description of the Snack.
|
|
70
|
-
* @param name E.g. "My awesome Snack"
|
|
71
|
-
*/
|
|
72
|
-
setDescription(description: string): void;
|
|
73
|
-
/**
|
|
74
|
-
* Sets the associated user account.
|
|
75
|
-
*
|
|
76
|
-
* When set and `online` is true, causes this Snack to appear on the
|
|
77
|
-
* "Recently in Development" section of all Expo clients that are signed
|
|
78
|
-
* in with that account.
|
|
79
|
-
*/
|
|
80
|
-
setUser(user?: SnackUser): void;
|
|
81
|
-
/**
|
|
82
|
-
* Sets the device-id of an Expo client. When set and `online` is true, causes this
|
|
83
|
-
* Snack to appear on the "Recently in Development" section of that Expo client.
|
|
84
|
-
*/
|
|
85
|
-
setDeviceId(deviceId?: string): void;
|
|
86
|
-
/**
|
|
87
|
-
* Sets the focus to this Snack.
|
|
88
|
-
*
|
|
89
|
-
* Causes this Snack to be moved to the top of the "Recently in Development" list
|
|
90
|
-
* in the Expo client.
|
|
91
|
-
*/
|
|
92
|
-
setFocus(): void;
|
|
93
|
-
/**
|
|
94
|
-
* Sets the delay that is used before sending code updates to the connected clients.
|
|
95
|
-
* Use this method to set the "debounce" timeout to use for sending code changes
|
|
96
|
-
* over pubnub.
|
|
97
|
-
*
|
|
98
|
-
* ```
|
|
99
|
-
* -1 = Disable automatic sending of code changes (use `sendCodeChanges` to trigger the send)
|
|
100
|
-
* 0 = Code changes are sent immediately to the connected clients
|
|
101
|
-
* 1..n = Code changes are debounced and sent after the wait time
|
|
102
|
-
* ```
|
|
103
|
-
*
|
|
104
|
-
* @param delay Timeout in milliseconds (or -1 to disable automatic code updates)
|
|
105
|
-
*/
|
|
106
|
-
setCodeChangesDelay(delay: number): void;
|
|
107
|
-
/**
|
|
108
|
-
*
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
*
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
*
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
* //
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
*
|
|
220
|
-
*
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
private
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
*
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
*
|
|
270
|
-
*
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
*
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
*
|
|
289
|
-
*
|
|
290
|
-
*
|
|
291
|
-
*
|
|
292
|
-
* unsubscribe()
|
|
293
|
-
*
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
private
|
|
301
|
-
|
|
1
|
+
import { SDKVersion, SnackDependencies, SnackDependency, SnackFile, SnackFiles } from 'snack-content';
|
|
2
|
+
import { SnackTransport, SnackTransportOptions } from './transports';
|
|
3
|
+
import { SnackState, SnackUser, SnackLogEvent, SnackListenerSubscription, SnackConnectedClients, SnackWindowRef } from './types';
|
|
4
|
+
export declare type SnackOptions = {
|
|
5
|
+
sdkVersion?: SDKVersion;
|
|
6
|
+
name?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
dependencies?: SnackDependencies;
|
|
9
|
+
files?: SnackFiles;
|
|
10
|
+
apiURL?: string;
|
|
11
|
+
host?: string;
|
|
12
|
+
snackagerURL?: string;
|
|
13
|
+
verbose?: boolean;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
online?: boolean;
|
|
16
|
+
channel?: string;
|
|
17
|
+
deviceId?: string;
|
|
18
|
+
transports?: {
|
|
19
|
+
[id: string]: SnackTransport;
|
|
20
|
+
};
|
|
21
|
+
createTransport?: (options: SnackTransportOptions) => SnackTransport;
|
|
22
|
+
codeChangesDelay?: number;
|
|
23
|
+
reloadTimeout?: number;
|
|
24
|
+
previewTimeout?: number;
|
|
25
|
+
user?: SnackUser;
|
|
26
|
+
id?: string;
|
|
27
|
+
snackId?: string;
|
|
28
|
+
accountSnackId?: string;
|
|
29
|
+
webPlayerURL?: string;
|
|
30
|
+
webPreviewRef?: SnackWindowRef;
|
|
31
|
+
};
|
|
32
|
+
export declare type SnackSaveOptions = {
|
|
33
|
+
isDraft?: boolean;
|
|
34
|
+
ignoreUser?: boolean;
|
|
35
|
+
};
|
|
36
|
+
export declare type SnackStateListener = (state: SnackState, prevState: SnackState) => any;
|
|
37
|
+
export declare type SnackLogListener = (log: SnackLogEvent) => any;
|
|
38
|
+
export default class Snack {
|
|
39
|
+
private state;
|
|
40
|
+
private stateListeners;
|
|
41
|
+
private logListeners;
|
|
42
|
+
private readonly options;
|
|
43
|
+
private readonly createTransport;
|
|
44
|
+
private readonly logger?;
|
|
45
|
+
private readonly apiURL;
|
|
46
|
+
private readonly host;
|
|
47
|
+
private readonly dependencyResolver;
|
|
48
|
+
private readonly fileUploader;
|
|
49
|
+
private readonly DevSession;
|
|
50
|
+
private wantedDependencyVersions;
|
|
51
|
+
private codeChangesDelay;
|
|
52
|
+
private codeChangesTimer;
|
|
53
|
+
private readonly reloadTimeout;
|
|
54
|
+
private readonly previewTimeout;
|
|
55
|
+
private pruneConnectionsTimer;
|
|
56
|
+
private readonly transportListeners;
|
|
57
|
+
constructor(options: SnackOptions);
|
|
58
|
+
/**
|
|
59
|
+
* Sets the Expo SDK version.
|
|
60
|
+
* @param sdkVersion Valid SDK version (e.g. "38.0.0")
|
|
61
|
+
*/
|
|
62
|
+
setSDKVersion(sdkVersion: SDKVersion): void;
|
|
63
|
+
/**
|
|
64
|
+
* Sets the name of the Snack.
|
|
65
|
+
* @param name E.g. "conspicious orange"
|
|
66
|
+
*/
|
|
67
|
+
setName(name: string): void;
|
|
68
|
+
/**
|
|
69
|
+
* Sets the description of the Snack.
|
|
70
|
+
* @param name E.g. "My awesome Snack"
|
|
71
|
+
*/
|
|
72
|
+
setDescription(description: string): void;
|
|
73
|
+
/**
|
|
74
|
+
* Sets the associated user account.
|
|
75
|
+
*
|
|
76
|
+
* When set and `online` is true, causes this Snack to appear on the
|
|
77
|
+
* "Recently in Development" section of all Expo clients that are signed
|
|
78
|
+
* in with that account.
|
|
79
|
+
*/
|
|
80
|
+
setUser(user?: SnackUser): void;
|
|
81
|
+
/**
|
|
82
|
+
* Sets the device-id of an Expo client. When set and `online` is true, causes this
|
|
83
|
+
* Snack to appear on the "Recently in Development" section of that Expo client.
|
|
84
|
+
*/
|
|
85
|
+
setDeviceId(deviceId?: string): void;
|
|
86
|
+
/**
|
|
87
|
+
* Sets the focus to this Snack.
|
|
88
|
+
*
|
|
89
|
+
* Causes this Snack to be moved to the top of the "Recently in Development" list
|
|
90
|
+
* in the Expo client.
|
|
91
|
+
*/
|
|
92
|
+
setFocus(): void;
|
|
93
|
+
/**
|
|
94
|
+
* Sets the delay that is used before sending code updates to the connected clients.
|
|
95
|
+
* Use this method to set the "debounce" timeout to use for sending code changes
|
|
96
|
+
* over pubnub.
|
|
97
|
+
*
|
|
98
|
+
* ```
|
|
99
|
+
* -1 = Disable automatic sending of code changes (use `sendCodeChanges` to trigger the send)
|
|
100
|
+
* 0 = Code changes are sent immediately to the connected clients
|
|
101
|
+
* 1..n = Code changes are debounced and sent after the wait time
|
|
102
|
+
* ```
|
|
103
|
+
*
|
|
104
|
+
* @param delay Timeout in milliseconds (or -1 to disable automatic code updates)
|
|
105
|
+
*/
|
|
106
|
+
setCodeChangesDelay(delay: number): void;
|
|
107
|
+
/**
|
|
108
|
+
* Update the `webPlayerURL` which serves the webPlayer runtime.
|
|
109
|
+
*/
|
|
110
|
+
setWebPlayerURL(webPlayerURL: string | null): void;
|
|
111
|
+
/**
|
|
112
|
+
* Sends any pending code changes to the connected clients.
|
|
113
|
+
* No changes are send if all clients are already up to date.
|
|
114
|
+
*/
|
|
115
|
+
sendCodeChanges(): void;
|
|
116
|
+
private _sendCodeChangesDebounced;
|
|
117
|
+
/**
|
|
118
|
+
* Uploads the current code to Expo's servers and return a url that points to that version of the code.
|
|
119
|
+
*/
|
|
120
|
+
saveAsync(options?: SnackSaveOptions): Promise<{
|
|
121
|
+
id: string;
|
|
122
|
+
url: string;
|
|
123
|
+
hashId: string | undefined;
|
|
124
|
+
accountSnackId: string | undefined;
|
|
125
|
+
snackId: string | undefined;
|
|
126
|
+
}>;
|
|
127
|
+
/**
|
|
128
|
+
* Gets the URL at which the Snack can be downloaded as a zip file. Will automatically
|
|
129
|
+
* save the Snack if it contains unsaved changes.
|
|
130
|
+
*/
|
|
131
|
+
getDownloadURLAsync(saveOptions?: SnackSaveOptions): Promise<string>;
|
|
132
|
+
private uploadPreview;
|
|
133
|
+
/**
|
|
134
|
+
* Returns the current state of the Snack. This includes files, dependencies
|
|
135
|
+
* and other meta-data about the Snack.
|
|
136
|
+
*/
|
|
137
|
+
getState(): SnackState;
|
|
138
|
+
/**
|
|
139
|
+
* Waits for any pending operations such as running dependencies resolutions
|
|
140
|
+
* before returning the state.
|
|
141
|
+
*/
|
|
142
|
+
getStateAsync(): Promise<SnackState>;
|
|
143
|
+
/**
|
|
144
|
+
* Adds a callback for listening for any state changes.
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```
|
|
148
|
+
* const unsubscribe = Snack.addStateListener((state, prevState) => {
|
|
149
|
+
* if (state.name !== prevState.name) {
|
|
150
|
+
* console.log('name changed: ', state.name);
|
|
151
|
+
* }
|
|
152
|
+
* });
|
|
153
|
+
*
|
|
154
|
+
* Snack.setName('unforgiven orange'); // // Make a change to the state
|
|
155
|
+
*
|
|
156
|
+
* unsubscribe(); // Remove listener
|
|
157
|
+
* ```
|
|
158
|
+
*/
|
|
159
|
+
addStateListener(listener: SnackStateListener): SnackListenerSubscription;
|
|
160
|
+
private setState;
|
|
161
|
+
private updateDerivedState;
|
|
162
|
+
private onStateChanged;
|
|
163
|
+
/**
|
|
164
|
+
* Updates code or asset files.
|
|
165
|
+
*
|
|
166
|
+
* Use this method to add/remove/update files and upload assets.
|
|
167
|
+
* To remove a file specify `null` as the value of the file.
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```ts
|
|
171
|
+
* const Snack = new Snack({
|
|
172
|
+
* files: {
|
|
173
|
+
* 'App.js': { type: 'CODE', contents: 'console.log("hello world!");' },
|
|
174
|
+
* 'data.json': { type: 'CODE', contents: '{}' },
|
|
175
|
+
* }
|
|
176
|
+
* });
|
|
177
|
+
*
|
|
178
|
+
* // Add or update files
|
|
179
|
+
* Snack.updateFiles({
|
|
180
|
+
* 'App.js': {
|
|
181
|
+
* type: 'CODE',
|
|
182
|
+
* contents: 'console.log("Hello Snack!");'
|
|
183
|
+
* }
|
|
184
|
+
* });
|
|
185
|
+
*
|
|
186
|
+
* // Upload an asset
|
|
187
|
+
* Snack.updateFiles({
|
|
188
|
+
* 'assets/logo.png': {
|
|
189
|
+
* type: 'ASSET',
|
|
190
|
+
* contents: file // File, Blob or FormData
|
|
191
|
+
* }
|
|
192
|
+
* });
|
|
193
|
+
*
|
|
194
|
+
* // Add a pre-uploaded asset
|
|
195
|
+
* Snack.updateFiles({
|
|
196
|
+
* 'assets/expo.jpg': {
|
|
197
|
+
* type: 'ASSET',
|
|
198
|
+
* contents: 'https://mysite/expo.jpg'
|
|
199
|
+
* }
|
|
200
|
+
* });
|
|
201
|
+
*
|
|
202
|
+
* // Remove files
|
|
203
|
+
* Snack.updateFiles({
|
|
204
|
+
* 'data.json': null,
|
|
205
|
+
* 'assets/expo.jpg': null
|
|
206
|
+
* });
|
|
207
|
+
* ```
|
|
208
|
+
*/
|
|
209
|
+
updateFiles(files: {
|
|
210
|
+
[path: string]: SnackFile | null;
|
|
211
|
+
}): void;
|
|
212
|
+
/**
|
|
213
|
+
* Helper function that uploads an asset and returns its url.
|
|
214
|
+
*/
|
|
215
|
+
uploadAssetAsync: (contents: File | Blob | FormData) => Promise<string>;
|
|
216
|
+
private updateFileUploader;
|
|
217
|
+
private onFileUploaded;
|
|
218
|
+
/**
|
|
219
|
+
* Updates dependencies.
|
|
220
|
+
*
|
|
221
|
+
* Use this method to add/remove/update dependencies.
|
|
222
|
+
* To remove a dependency specify `null` as the value of the key/value pair.
|
|
223
|
+
*
|
|
224
|
+
* @example
|
|
225
|
+
* ```ts
|
|
226
|
+
* const Snack = new Snack({
|
|
227
|
+
* dependencies: {
|
|
228
|
+
* 'react-native-paper': '~2.0.0'
|
|
229
|
+
* }
|
|
230
|
+
* });
|
|
231
|
+
*
|
|
232
|
+
* // Add dependency
|
|
233
|
+
* Snack.updateDependencies({
|
|
234
|
+
* 'expo-font': '9.0.0'
|
|
235
|
+
* });
|
|
236
|
+
*
|
|
237
|
+
* // Remove dependency
|
|
238
|
+
* Snack.updateDependencies({
|
|
239
|
+
* 'expo-font': null
|
|
240
|
+
* });
|
|
241
|
+
* ```
|
|
242
|
+
*/
|
|
243
|
+
updateDependencies(dependencies: {
|
|
244
|
+
[name: string]: SnackDependency | null;
|
|
245
|
+
}): void;
|
|
246
|
+
private updateDerivedDependenciesState;
|
|
247
|
+
private updateWantedDependencyVersions;
|
|
248
|
+
private onWantedDependencyVersions;
|
|
249
|
+
private updateDependencyResolver;
|
|
250
|
+
private onDependencyResolved;
|
|
251
|
+
/**
|
|
252
|
+
* Enables or disables the Snack.
|
|
253
|
+
*
|
|
254
|
+
* When disabled, no uploads or dependency resolve operations
|
|
255
|
+
* are performed.
|
|
256
|
+
*/
|
|
257
|
+
setDisabled(disabled: boolean): void;
|
|
258
|
+
/**
|
|
259
|
+
* Makes the Snack available online.
|
|
260
|
+
*
|
|
261
|
+
* When online, a pubnub channel is created to which clients can
|
|
262
|
+
* connect.
|
|
263
|
+
*/
|
|
264
|
+
setOnline(enabled: boolean): void;
|
|
265
|
+
private updateDerivedOnlineState;
|
|
266
|
+
private updateDerivedWebPreviewState;
|
|
267
|
+
private onDevSessionSendBeaconCloseRequest;
|
|
268
|
+
/**
|
|
269
|
+
* Reloads all connected clients.
|
|
270
|
+
*
|
|
271
|
+
* Note: During the reload proces, clients may get disconnected which
|
|
272
|
+
* causes the connectedClient to disappear and re-appear. The `reloadTimeout`
|
|
273
|
+
* option in the constructor can be used to keep connectedClients "alive"
|
|
274
|
+
* during the reload process.
|
|
275
|
+
*/
|
|
276
|
+
reloadConnectedClients(): void;
|
|
277
|
+
/**
|
|
278
|
+
* Requests a preview from the connected clients.
|
|
279
|
+
*
|
|
280
|
+
* The previews are returned in the `previewURL` field of each connectedClient.
|
|
281
|
+
*/
|
|
282
|
+
getPreviewAsync(): Promise<SnackConnectedClients>;
|
|
283
|
+
private updateTransports;
|
|
284
|
+
private onTransportEvent;
|
|
285
|
+
private onClientConnected;
|
|
286
|
+
private onClientDisconnected;
|
|
287
|
+
/**
|
|
288
|
+
* Adds a callback for listening for any client generated log messages.
|
|
289
|
+
*
|
|
290
|
+
* @example
|
|
291
|
+
* ```
|
|
292
|
+
* const unsubscribe = Snack.addLogListener((log) => {
|
|
293
|
+
* console.log('log message received: ', log);
|
|
294
|
+
* });
|
|
295
|
+
*
|
|
296
|
+
* unsubscribe(); // Remove listener
|
|
297
|
+
* ```
|
|
298
|
+
*/
|
|
299
|
+
addLogListener(listener: SnackLogListener): SnackListenerSubscription;
|
|
300
|
+
private onProtocolMessageReceived;
|
|
301
|
+
private onProtocolMessageSent;
|
|
302
|
+
private onConsoleMessageReceived;
|
|
303
|
+
private onErrorMessageReceived;
|
|
304
|
+
private onStatusReportMessageReceived;
|
|
305
|
+
}
|