snack-sdk 3.8.0 → 3.9.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 +22 -0
- 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 +301 -301
- package/build/Session.js +1172 -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 +185 -185
- package/build/types.js +2 -2
- 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/src/utils.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import fetchPonyfill from 'fetch-ponyfill';
|
|
2
|
-
import { customAlphabet } from 'nanoid';
|
|
3
|
-
import { SDKVersion } from 'snack-content';
|
|
4
|
-
|
|
5
|
-
import { SnackError, SnackUser } from './types';
|
|
6
|
-
|
|
7
|
-
const { fetch } = fetchPonyfill();
|
|
8
|
-
export { fetch };
|
|
9
|
-
|
|
10
|
-
// + and - are used as delimiters in the uri, ensure they do not appear in the channel itself
|
|
11
|
-
const VALID_CHANNEL_CHARS = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!_';
|
|
12
|
-
const generateChannel = customAlphabet(VALID_CHANNEL_CHARS, 10);
|
|
13
|
-
|
|
14
|
-
export function createChannel(channel?: string): string {
|
|
15
|
-
channel = channel ?? generateChannel();
|
|
16
|
-
|
|
17
|
-
if (channel.length < 6) {
|
|
18
|
-
throw new Error('Please use a channel id with more entropy');
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
for (const char of channel) {
|
|
22
|
-
if (VALID_CHANNEL_CHARS.indexOf(char) < 0) {
|
|
23
|
-
throw new Error('Channel id contains invalid characters');
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return channel;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function createURL(host: string, sdkVersion: SDKVersion, channel?: string, id?: string) {
|
|
31
|
-
if (channel) {
|
|
32
|
-
return id
|
|
33
|
-
? id.startsWith('@')
|
|
34
|
-
? `exp://${host}/${id}+${channel}`
|
|
35
|
-
: `exp://${host}/@snack/${id}+${channel}`
|
|
36
|
-
: `exp://${host}/@snack/sdk.${sdkVersion}-${channel}`;
|
|
37
|
-
} else if (id) {
|
|
38
|
-
return `exp://${host}/${id.match(/.*\/.*/) ? id : `@snack/${id}`}`;
|
|
39
|
-
} else {
|
|
40
|
-
return '';
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function createError(config: {
|
|
45
|
-
message: string;
|
|
46
|
-
name?: string;
|
|
47
|
-
fileName?: string;
|
|
48
|
-
lineNumber?: number;
|
|
49
|
-
columnNumber?: number;
|
|
50
|
-
stack?: string;
|
|
51
|
-
}): SnackError {
|
|
52
|
-
const error: SnackError = new Error(config.message);
|
|
53
|
-
if (config.name) error.name = config.name;
|
|
54
|
-
if (config.fileName) error.fileName = config.fileName;
|
|
55
|
-
if (config.lineNumber) error.lineNumber = config.lineNumber;
|
|
56
|
-
if (config.columnNumber) error.columnNumber = config.columnNumber;
|
|
57
|
-
if (config.stack) error.stack = config.stack;
|
|
58
|
-
return error;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export function createUserHeader(user?: SnackUser): { [key: string]: string } {
|
|
62
|
-
if (user?.sessionSecret) {
|
|
63
|
-
return { 'Expo-Session': user.sessionSecret };
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (user?.accessToken) {
|
|
67
|
-
return { Authorization: `Bearer ${user.accessToken}` };
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return {};
|
|
71
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "es5",
|
|
4
|
-
"module": "commonjs",
|
|
5
|
-
"lib": ["dom", "esnext"],
|
|
6
|
-
"declaration": true,
|
|
7
|
-
"sourceMap": true,
|
|
8
|
-
"inlineSources": true,
|
|
9
|
-
"outDir": "./build",
|
|
10
|
-
"strict": true,
|
|
11
|
-
"noImplicitAny": true,
|
|
12
|
-
"strictNullChecks": true,
|
|
13
|
-
"strictFunctionTypes": true,
|
|
14
|
-
"strictBindCallApply": true,
|
|
15
|
-
"strictPropertyInitialization": true,
|
|
16
|
-
"noImplicitThis": true,
|
|
17
|
-
"noUnusedLocals": true,
|
|
18
|
-
"noUnusedParameters": true,
|
|
19
|
-
"noImplicitReturns": true,
|
|
20
|
-
"noFallthroughCasesInSwitch": true,
|
|
21
|
-
"allowSyntheticDefaultImports": true,
|
|
22
|
-
"esModuleInterop": true,
|
|
23
|
-
"moduleResolution": "node",
|
|
24
|
-
"skipLibCheck": true,
|
|
25
|
-
"forceConsistentCasingInFileNames": true
|
|
26
|
-
},
|
|
27
|
-
"include": ["./src"]
|
|
28
|
-
}
|