snack-sdk 3.7.0 → 3.8.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 +1 -1
- package/build/DependencyResolver.d.ts +26 -25
- package/build/DependencyResolver.js +258 -257
- package/build/DependencyResolver.js.map +1 -1
- package/build/DevSession.d.ts +20 -20
- package/build/DevSession.js +203 -203
- package/build/FileUploader.d.ts +23 -22
- package/build/FileUploader.js +174 -174
- package/build/FileUploader.js.map +1 -1
- package/build/Logger.d.ts +11 -11
- package/build/Logger.js +33 -33
- package/build/Session.d.ts +301 -300
- package/build/Session.js +1171 -1171
- package/build/Session.js.map +1 -1
- package/build/State.d.ts +16 -16
- package/build/State.js +90 -90
- package/build/State.js.map +1 -1
- package/build/WantedVersions.d.ts +17 -16
- package/build/WantedVersions.js +93 -96
- package/build/WantedVersions.js.map +1 -1
- package/build/defaultConfig.d.ts +12 -13
- package/build/defaultConfig.js +29 -29
- package/build/defaultConfig.js.map +1 -1
- package/build/index.d.ts +7 -7
- package/build/index.js +30 -30
- package/build/index.js.map +1 -1
- package/build/transports/CodeMessageBuilder.d.ts +31 -31
- package/build/transports/CodeMessageBuilder.js +196 -196
- package/build/transports/CodeMessageBuilder.js.map +1 -1
- package/build/transports/Protocol.d.ts +64 -64
- package/build/transports/Protocol.js +2 -2
- package/build/transports/Protocol.js.map +1 -1
- package/build/transports/Transport.d.ts +27 -27
- package/build/transports/Transport.js +298 -298
- 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/types.js.map +1 -1
- package/build/transports/webPlayer.d.ts +12 -11
- package/build/transports/webPlayer.js +70 -70
- package/build/transports/webPlayer.js.map +1 -1
- package/build/types.d.ts +185 -258
- package/build/types.js +2 -2
- package/build/types.js.map +1 -1
- package/build/utils.d.ts +17 -16
- package/build/utils.js +68 -68
- package/build/utils.js.map +1 -1
- package/package.json +3 -2
- package/src/DependencyResolver.ts +11 -7
- package/src/FileUploader.ts +3 -1
- package/src/Session.ts +9 -6
- package/src/State.ts +1 -1
- package/src/WantedVersions.ts +3 -2
- package/src/defaultConfig.ts +5 -5
- package/src/index.ts +37 -9
- package/src/transports/CodeMessageBuilder.ts +7 -2
- package/src/transports/Protocol.ts +1 -1
- package/src/transports/types.ts +2 -1
- package/src/transports/webPlayer.ts +3 -1
- package/src/types.ts +8 -82
- package/src/utils.ts +2 -1
- package/build/sdk.d.ts +0 -34
- package/build/sdk.js +0 -139
- package/build/sdk.js.map +0 -1
- package/build/sdks/features.d.ts +0 -9
- package/build/sdks/features.js +0 -13
- package/build/sdks/features.js.map +0 -1
- package/build/sdks/index.d.ts +0 -5
- package/build/sdks/index.js +0 -124
- package/build/sdks/index.js.map +0 -1
- package/build/sdks/types.d.ts +0 -21
- package/build/sdks/types.js +0 -3
- package/build/sdks/types.js.map +0 -1
- package/src/sdk.ts +0 -135
- package/src/sdks/features.ts +0 -11
- package/src/sdks/index.ts +0 -159
- package/src/sdks/types.ts +0 -49
package/build/utils.js
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createUserHeader = exports.createError = exports.createURL = exports.createChannel = exports.fetch = void 0;
|
|
7
|
-
var fetch_ponyfill_1 = __importDefault(require("fetch-ponyfill"));
|
|
8
|
-
var nanoid_1 = require("nanoid");
|
|
9
|
-
var fetch = fetch_ponyfill_1.default().fetch;
|
|
10
|
-
exports.fetch = fetch;
|
|
11
|
-
// + and - are used as delimiters in the uri, ensure they do not appear in the channel itself
|
|
12
|
-
var VALID_CHANNEL_CHARS = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!_';
|
|
13
|
-
var generateChannel = nanoid_1.customAlphabet(VALID_CHANNEL_CHARS, 10);
|
|
14
|
-
function createChannel(channel) {
|
|
15
|
-
channel = channel !== null && channel !== void 0 ? channel : generateChannel();
|
|
16
|
-
if (channel.length < 6) {
|
|
17
|
-
throw new Error('Please use a channel id with more entropy');
|
|
18
|
-
}
|
|
19
|
-
for (var _i = 0, channel_1 = channel; _i < channel_1.length; _i++) {
|
|
20
|
-
var char = channel_1[_i];
|
|
21
|
-
if (VALID_CHANNEL_CHARS.indexOf(char) < 0) {
|
|
22
|
-
throw new Error('Channel id contains invalid characters');
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return channel;
|
|
26
|
-
}
|
|
27
|
-
exports.createChannel = createChannel;
|
|
28
|
-
function createURL(host, sdkVersion, channel, id) {
|
|
29
|
-
if (channel) {
|
|
30
|
-
return id
|
|
31
|
-
? id.startsWith('@')
|
|
32
|
-
? "exp://" + host + "/" + id + "+" + channel
|
|
33
|
-
: "exp://" + host + "/@snack/" + id + "+" + channel
|
|
34
|
-
: "exp://" + host + "/@snack/sdk." + sdkVersion + "-" + channel;
|
|
35
|
-
}
|
|
36
|
-
else if (id) {
|
|
37
|
-
return "exp://" + host + "/" + (id.match(/.*\/.*/) ? id : "@snack/" + id);
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
return '';
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.createURL = createURL;
|
|
44
|
-
function createError(config) {
|
|
45
|
-
var error = new Error(config.message);
|
|
46
|
-
if (config.name)
|
|
47
|
-
error.name = config.name;
|
|
48
|
-
if (config.fileName)
|
|
49
|
-
error.fileName = config.fileName;
|
|
50
|
-
if (config.lineNumber)
|
|
51
|
-
error.lineNumber = config.lineNumber;
|
|
52
|
-
if (config.columnNumber)
|
|
53
|
-
error.columnNumber = config.columnNumber;
|
|
54
|
-
if (config.stack)
|
|
55
|
-
error.stack = config.stack;
|
|
56
|
-
return error;
|
|
57
|
-
}
|
|
58
|
-
exports.createError = createError;
|
|
59
|
-
function createUserHeader(user) {
|
|
60
|
-
if (user === null || user === void 0 ? void 0 : user.sessionSecret) {
|
|
61
|
-
return { 'Expo-Session': user.sessionSecret };
|
|
62
|
-
}
|
|
63
|
-
if (user === null || user === void 0 ? void 0 : user.accessToken) {
|
|
64
|
-
return { Authorization: "Bearer " + user.accessToken };
|
|
65
|
-
}
|
|
66
|
-
return {};
|
|
67
|
-
}
|
|
68
|
-
exports.createUserHeader = createUserHeader;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createUserHeader = exports.createError = exports.createURL = exports.createChannel = exports.fetch = void 0;
|
|
7
|
+
var fetch_ponyfill_1 = __importDefault(require("fetch-ponyfill"));
|
|
8
|
+
var nanoid_1 = require("nanoid");
|
|
9
|
+
var fetch = fetch_ponyfill_1.default().fetch;
|
|
10
|
+
exports.fetch = fetch;
|
|
11
|
+
// + and - are used as delimiters in the uri, ensure they do not appear in the channel itself
|
|
12
|
+
var VALID_CHANNEL_CHARS = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!_';
|
|
13
|
+
var generateChannel = nanoid_1.customAlphabet(VALID_CHANNEL_CHARS, 10);
|
|
14
|
+
function createChannel(channel) {
|
|
15
|
+
channel = channel !== null && channel !== void 0 ? channel : generateChannel();
|
|
16
|
+
if (channel.length < 6) {
|
|
17
|
+
throw new Error('Please use a channel id with more entropy');
|
|
18
|
+
}
|
|
19
|
+
for (var _i = 0, channel_1 = channel; _i < channel_1.length; _i++) {
|
|
20
|
+
var char = channel_1[_i];
|
|
21
|
+
if (VALID_CHANNEL_CHARS.indexOf(char) < 0) {
|
|
22
|
+
throw new Error('Channel id contains invalid characters');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return channel;
|
|
26
|
+
}
|
|
27
|
+
exports.createChannel = createChannel;
|
|
28
|
+
function createURL(host, sdkVersion, channel, id) {
|
|
29
|
+
if (channel) {
|
|
30
|
+
return id
|
|
31
|
+
? id.startsWith('@')
|
|
32
|
+
? "exp://" + host + "/" + id + "+" + channel
|
|
33
|
+
: "exp://" + host + "/@snack/" + id + "+" + channel
|
|
34
|
+
: "exp://" + host + "/@snack/sdk." + sdkVersion + "-" + channel;
|
|
35
|
+
}
|
|
36
|
+
else if (id) {
|
|
37
|
+
return "exp://" + host + "/" + (id.match(/.*\/.*/) ? id : "@snack/" + id);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
return '';
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.createURL = createURL;
|
|
44
|
+
function createError(config) {
|
|
45
|
+
var error = new Error(config.message);
|
|
46
|
+
if (config.name)
|
|
47
|
+
error.name = config.name;
|
|
48
|
+
if (config.fileName)
|
|
49
|
+
error.fileName = config.fileName;
|
|
50
|
+
if (config.lineNumber)
|
|
51
|
+
error.lineNumber = config.lineNumber;
|
|
52
|
+
if (config.columnNumber)
|
|
53
|
+
error.columnNumber = config.columnNumber;
|
|
54
|
+
if (config.stack)
|
|
55
|
+
error.stack = config.stack;
|
|
56
|
+
return error;
|
|
57
|
+
}
|
|
58
|
+
exports.createError = createError;
|
|
59
|
+
function createUserHeader(user) {
|
|
60
|
+
if (user === null || user === void 0 ? void 0 : user.sessionSecret) {
|
|
61
|
+
return { 'Expo-Session': user.sessionSecret };
|
|
62
|
+
}
|
|
63
|
+
if (user === null || user === void 0 ? void 0 : user.accessToken) {
|
|
64
|
+
return { Authorization: "Bearer " + user.accessToken };
|
|
65
|
+
}
|
|
66
|
+
return {};
|
|
67
|
+
}
|
|
68
|
+
exports.createUserHeader = createUserHeader;
|
|
69
69
|
//# sourceMappingURL=utils.js.map
|
package/build/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;AAAA,kEAA2C;AAC3C,iCAAwC;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;AAAA,kEAA2C;AAC3C,iCAAwC;AAKhC,IAAA,KAAK,GAAK,wBAAa,EAAE,MAApB,CAAqB;AACzB,sBAAK;AAEd,6FAA6F;AAC7F,IAAM,mBAAmB,GAAG,kEAAkE,CAAC;AAC/F,IAAM,eAAe,GAAG,uBAAc,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC;AAEhE,SAAgB,aAAa,CAAC,OAAgB;IAC5C,OAAO,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,eAAe,EAAE,CAAC;IAEvC,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;QACtB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;KAC9D;IAED,KAAmB,UAAO,EAAP,mBAAO,EAAP,qBAAO,EAAP,IAAO,EAAE;QAAvB,IAAM,IAAI,gBAAA;QACb,IAAI,mBAAmB,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;YACzC,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;SAC3D;KACF;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAdD,sCAcC;AAED,SAAgB,SAAS,CAAC,IAAY,EAAE,UAAsB,EAAE,OAAgB,EAAE,EAAW;IAC3F,IAAI,OAAO,EAAE;QACX,OAAO,EAAE;YACP,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC;gBAClB,CAAC,CAAC,WAAS,IAAI,SAAI,EAAE,SAAI,OAAS;gBAClC,CAAC,CAAC,WAAS,IAAI,gBAAW,EAAE,SAAI,OAAS;YAC3C,CAAC,CAAC,WAAS,IAAI,oBAAe,UAAU,SAAI,OAAS,CAAC;KACzD;SAAM,IAAI,EAAE,EAAE;QACb,OAAO,WAAS,IAAI,UAAI,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAU,EAAI,CAAE,CAAC;KACpE;SAAM;QACL,OAAO,EAAE,CAAC;KACX;AACH,CAAC;AAZD,8BAYC;AAED,SAAgB,WAAW,CAAC,MAO3B;IACC,IAAM,KAAK,GAAe,IAAI,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACpD,IAAI,MAAM,CAAC,IAAI;QAAE,KAAK,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;IAC1C,IAAI,MAAM,CAAC,QAAQ;QAAE,KAAK,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IACtD,IAAI,MAAM,CAAC,UAAU;QAAE,KAAK,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;IAC5D,IAAI,MAAM,CAAC,YAAY;QAAE,KAAK,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;IAClE,IAAI,MAAM,CAAC,KAAK;QAAE,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;IAC7C,OAAO,KAAK,CAAC;AACf,CAAC;AAfD,kCAeC;AAED,SAAgB,gBAAgB,CAAC,IAAgB;IAC/C,IAAI,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,aAAa,EAAE;QACvB,OAAO,EAAE,cAAc,EAAE,IAAI,CAAC,aAAa,EAAE,CAAC;KAC/C;IAED,IAAI,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,WAAW,EAAE;QACrB,OAAO,EAAE,aAAa,EAAE,YAAU,IAAI,CAAC,WAAa,EAAE,CAAC;KACxD;IAED,OAAO,EAAE,CAAC;AACZ,CAAC;AAVD,4CAUC","sourcesContent":["import fetchPonyfill from 'fetch-ponyfill';\nimport { customAlphabet } from 'nanoid';\nimport { SDKVersion } from 'snack-content';\n\nimport { SnackError, SnackUser } from './types';\n\nconst { fetch } = fetchPonyfill();\nexport { fetch };\n\n// + and - are used as delimiters in the uri, ensure they do not appear in the channel itself\nconst VALID_CHANNEL_CHARS = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!_';\nconst generateChannel = customAlphabet(VALID_CHANNEL_CHARS, 10);\n\nexport function createChannel(channel?: string): string {\n channel = channel ?? generateChannel();\n\n if (channel.length < 6) {\n throw new Error('Please use a channel id with more entropy');\n }\n\n for (const char of channel) {\n if (VALID_CHANNEL_CHARS.indexOf(char) < 0) {\n throw new Error('Channel id contains invalid characters');\n }\n }\n\n return channel;\n}\n\nexport function createURL(host: string, sdkVersion: SDKVersion, channel?: string, id?: string) {\n if (channel) {\n return id\n ? id.startsWith('@')\n ? `exp://${host}/${id}+${channel}`\n : `exp://${host}/@snack/${id}+${channel}`\n : `exp://${host}/@snack/sdk.${sdkVersion}-${channel}`;\n } else if (id) {\n return `exp://${host}/${id.match(/.*\\/.*/) ? id : `@snack/${id}`}`;\n } else {\n return '';\n }\n}\n\nexport function createError(config: {\n message: string;\n name?: string;\n fileName?: string;\n lineNumber?: number;\n columnNumber?: number;\n stack?: string;\n}): SnackError {\n const error: SnackError = new Error(config.message);\n if (config.name) error.name = config.name;\n if (config.fileName) error.fileName = config.fileName;\n if (config.lineNumber) error.lineNumber = config.lineNumber;\n if (config.columnNumber) error.columnNumber = config.columnNumber;\n if (config.stack) error.stack = config.stack;\n return error;\n}\n\nexport function createUserHeader(user?: SnackUser): { [key: string]: string } {\n if (user?.sessionSecret) {\n return { 'Expo-Session': user.sessionSecret };\n }\n\n if (user?.accessToken) {\n return { Authorization: `Bearer ${user.accessToken}` };\n }\n\n return {};\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "snack-sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.0",
|
|
4
4
|
"description": "The Expo Snack SDK",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"author": "Expo <support@expo.dev>",
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"volta": {
|
|
29
|
-
"node": "12.
|
|
29
|
+
"node": "12.22.11"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@expo/spawn-async": "^1.5.0",
|
|
@@ -61,6 +61,7 @@
|
|
|
61
61
|
"nullthrows": "^1.1.1",
|
|
62
62
|
"pubnub": "^4.29.10",
|
|
63
63
|
"semver": "^7.3.4",
|
|
64
|
+
"snack-content": "^1.1.0",
|
|
64
65
|
"ua-parser-js": "^0.7.22",
|
|
65
66
|
"validate-npm-package-name": "^3.0.0"
|
|
66
67
|
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import semver from 'semver';
|
|
2
|
-
import validate from 'validate-npm-package-name';
|
|
3
|
-
|
|
4
|
-
import { Logger } from './Logger';
|
|
5
|
-
import { isModulePreloaded, isValidSemver } from './sdk';
|
|
6
2
|
import {
|
|
7
3
|
SDKVersion,
|
|
8
4
|
SnackDependencies,
|
|
9
5
|
SnackMissingDependencies,
|
|
10
6
|
SnackDependencyVersions,
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
isModulePreloaded,
|
|
8
|
+
isValidSemver,
|
|
9
|
+
} from 'snack-content';
|
|
10
|
+
import validate from 'validate-npm-package-name';
|
|
11
|
+
|
|
12
|
+
import { Logger } from './Logger';
|
|
13
|
+
import { SnackError } from './types';
|
|
13
14
|
import { fetch, createError } from './utils';
|
|
14
15
|
|
|
15
16
|
export type DependencyResolverCallback = (
|
|
@@ -111,7 +112,10 @@ export default class DependencyResolver {
|
|
|
111
112
|
fileName: key,
|
|
112
113
|
});
|
|
113
114
|
this.logger?.error(error);
|
|
114
|
-
if
|
|
115
|
+
// TypeScript thinks we need to await this promise, but we are actually checking if there is a promise or not. TS2801
|
|
116
|
+
// ESLint doesn't like when we cast to a boolean inside of an if statement. no-extra-boolean-cast
|
|
117
|
+
const promiseExists = !!this.status[key];
|
|
118
|
+
if (promiseExists) {
|
|
115
119
|
delete this.status[key];
|
|
116
120
|
this.callback(
|
|
117
121
|
{
|
package/src/FileUploader.ts
CHANGED
package/src/Session.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import mapValues from 'lodash/mapValues';
|
|
2
2
|
import nullthrows from 'nullthrows';
|
|
3
|
+
import {
|
|
4
|
+
SDKVersion,
|
|
5
|
+
SnackDependencies,
|
|
6
|
+
SnackDependency,
|
|
7
|
+
SnackFile,
|
|
8
|
+
SnackFiles,
|
|
9
|
+
isModulePreloaded,
|
|
10
|
+
validateSDKVersion,
|
|
11
|
+
} from 'snack-content';
|
|
3
12
|
|
|
4
13
|
import DependencyResolver, {
|
|
5
14
|
DependencyResolverCallback,
|
|
@@ -13,7 +22,6 @@ import { Logger, createLogger } from './Logger';
|
|
|
13
22
|
import * as State from './State';
|
|
14
23
|
import { WantedDependencyVersions, WantedDependencyVersionsCallback } from './WantedVersions';
|
|
15
24
|
import defaultConfig, { SnackIdentityState } from './defaultConfig';
|
|
16
|
-
import { validateSDKVersion, isModulePreloaded } from './sdk';
|
|
17
25
|
import {
|
|
18
26
|
createTransport,
|
|
19
27
|
SnackTransport,
|
|
@@ -31,16 +39,11 @@ import {
|
|
|
31
39
|
} from './transports/Protocol';
|
|
32
40
|
import { createWebPlayerTransport, getWebPlayerIFrameURL } from './transports/webPlayer';
|
|
33
41
|
import {
|
|
34
|
-
SDKVersion,
|
|
35
|
-
SnackDependencies,
|
|
36
|
-
SnackFiles,
|
|
37
|
-
SnackFile,
|
|
38
42
|
SnackState,
|
|
39
43
|
SnackUser,
|
|
40
44
|
SnackSendBeaconRequest,
|
|
41
45
|
SnackLogEvent,
|
|
42
46
|
SnackListenerSubscription,
|
|
43
|
-
SnackDependency,
|
|
44
47
|
SnackConnectedClients,
|
|
45
48
|
SnackWindowRef,
|
|
46
49
|
} from './types';
|
package/src/State.ts
CHANGED
package/src/WantedVersions.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { SDKVersion, SnackDependencyVersions, sdks } from 'snack-content';
|
|
2
|
+
|
|
1
3
|
import { Logger } from './Logger';
|
|
2
|
-
import
|
|
3
|
-
import { SDKVersion, SnackDependencyVersions, SnackError } from './types';
|
|
4
|
+
import { SnackError } from './types';
|
|
4
5
|
import { fetch } from './utils';
|
|
5
6
|
|
|
6
7
|
export type WantedDependencyVersionsCallback = (
|
package/src/defaultConfig.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defaultSdkVersion } from 'snack-content';
|
|
2
|
+
|
|
3
|
+
import { SnackState } from './types';
|
|
2
4
|
|
|
3
5
|
export const apiURL: string = 'https://exp.host';
|
|
4
6
|
export const snackagerURL: string = 'https://snackager.expo.io';
|
|
5
7
|
export const webPlayerURL: string =
|
|
6
8
|
'https://snack-web-player.s3.us-west-1.amazonaws.com/v2/%%SDK_VERSION%%';
|
|
7
9
|
|
|
8
|
-
export const sdkVersion: SDKVersion = '42.0.0';
|
|
9
|
-
|
|
10
10
|
export const SnackIdentityState: SnackState = {
|
|
11
|
-
sdkVersion,
|
|
11
|
+
sdkVersion: defaultSdkVersion,
|
|
12
12
|
name: '',
|
|
13
13
|
description: '',
|
|
14
14
|
dependencies: {},
|
|
@@ -26,7 +26,7 @@ export const SnackIdentityState: SnackState = {
|
|
|
26
26
|
const defaultConfig = {
|
|
27
27
|
apiURL,
|
|
28
28
|
snackagerURL,
|
|
29
|
-
sdkVersion,
|
|
29
|
+
sdkVersion: defaultSdkVersion,
|
|
30
30
|
webPlayerURL,
|
|
31
31
|
};
|
|
32
32
|
|
package/src/index.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import Snack, {
|
|
2
|
-
SnackOptions,
|
|
3
|
-
SnackSaveOptions,
|
|
4
|
-
SnackStateListener,
|
|
5
|
-
SnackLogListener,
|
|
6
|
-
} from './Session';
|
|
7
|
-
import defaultConfig from './defaultConfig';
|
|
8
1
|
import {
|
|
2
|
+
SDKFeature,
|
|
3
|
+
SDKVersion,
|
|
4
|
+
SnackAssetFile,
|
|
5
|
+
SnackCodeFile,
|
|
6
|
+
SnackFile,
|
|
7
|
+
SnackFiles,
|
|
8
|
+
SnackDependency,
|
|
9
|
+
SnackDependencyVersions,
|
|
10
|
+
SnackDependencies,
|
|
11
|
+
SnackMissingDependency,
|
|
12
|
+
SnackMissingDependencies,
|
|
9
13
|
isModulePreloaded,
|
|
10
14
|
getPreloadedModules,
|
|
11
15
|
isValidSemver,
|
|
@@ -13,11 +17,35 @@ import {
|
|
|
13
17
|
isFeatureSupported,
|
|
14
18
|
standardizeDependencies,
|
|
15
19
|
getDeprecatedModule,
|
|
16
|
-
} from '
|
|
20
|
+
} from 'snack-content';
|
|
21
|
+
|
|
22
|
+
import Snack, {
|
|
23
|
+
SnackOptions,
|
|
24
|
+
SnackSaveOptions,
|
|
25
|
+
SnackStateListener,
|
|
26
|
+
SnackLogListener,
|
|
27
|
+
} from './Session';
|
|
28
|
+
import defaultConfig from './defaultConfig';
|
|
17
29
|
|
|
18
30
|
export * from './transports';
|
|
19
31
|
export * from './types';
|
|
20
|
-
export type {
|
|
32
|
+
export type {
|
|
33
|
+
SnackOptions,
|
|
34
|
+
SnackSaveOptions,
|
|
35
|
+
SnackStateListener,
|
|
36
|
+
SnackLogListener,
|
|
37
|
+
SDKFeature,
|
|
38
|
+
SDKVersion,
|
|
39
|
+
SnackAssetFile,
|
|
40
|
+
SnackCodeFile,
|
|
41
|
+
SnackFile,
|
|
42
|
+
SnackFiles,
|
|
43
|
+
SnackDependency,
|
|
44
|
+
SnackDependencyVersions,
|
|
45
|
+
SnackDependencies,
|
|
46
|
+
SnackMissingDependency,
|
|
47
|
+
SnackMissingDependencies,
|
|
48
|
+
};
|
|
21
49
|
export {
|
|
22
50
|
isModulePreloaded,
|
|
23
51
|
getPreloadedModules,
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { createPatch } from 'diff';
|
|
2
|
+
import {
|
|
3
|
+
SnackFiles,
|
|
4
|
+
SDKVersion,
|
|
5
|
+
SnackCodeFile,
|
|
6
|
+
SnackDependencies,
|
|
7
|
+
isModulePreloaded,
|
|
8
|
+
} from 'snack-content';
|
|
2
9
|
import { UAParser } from 'ua-parser-js';
|
|
3
10
|
|
|
4
11
|
import FileUploader, { FileUploaderCallback } from '../FileUploader';
|
|
5
12
|
import { Logger } from '../Logger';
|
|
6
13
|
import { SnackIdentityState } from '../defaultConfig';
|
|
7
|
-
import { isModulePreloaded } from '../sdk';
|
|
8
|
-
import { SnackFiles, SDKVersion, SnackCodeFile, SnackDependencies } from '../types';
|
|
9
14
|
import { ProtocolCodeMessage, ProtocolCodeMessageDependencies } from './Protocol';
|
|
10
15
|
|
|
11
16
|
export type SnackCode = {
|
package/src/transports/types.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { SnackFiles, SnackDependencies, SDKVersion } from '
|
|
1
|
+
import { SnackFiles, SnackDependencies, SDKVersion } from 'snack-content';
|
|
2
|
+
|
|
2
3
|
import { ProtocolOutgoingMessage, ProtocolIncomingMessage } from './Protocol';
|
|
3
4
|
|
|
4
5
|
export type SnackTransportStartMessage = {
|
package/src/types.ts
CHANGED
|
@@ -1,86 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* This can be either a code file (.js/.tsx) or a support
|
|
9
|
-
* file such as a markdown or json file.
|
|
10
|
-
*/
|
|
11
|
-
export type SnackCodeFile = {
|
|
12
|
-
type: 'CODE';
|
|
13
|
-
contents: string;
|
|
14
|
-
error?: Error;
|
|
15
|
-
};
|
|
1
|
+
import {
|
|
2
|
+
SDKVersion,
|
|
3
|
+
SnackDependencies,
|
|
4
|
+
SnackDependencyVersions,
|
|
5
|
+
SnackFiles,
|
|
6
|
+
SnackMissingDependencies,
|
|
7
|
+
} from 'snack-content';
|
|
16
8
|
|
|
17
|
-
|
|
18
|
-
* An asset file that refers to externaly available
|
|
19
|
-
* content such as an image or font.
|
|
20
|
-
*
|
|
21
|
-
* When resolved, the `contents` field is an URL to the
|
|
22
|
-
* uploaded asset. A File, Blob or FormData object may
|
|
23
|
-
* also be provided after which it is automatically uploaded
|
|
24
|
-
* and converted into an URL.
|
|
25
|
-
*/
|
|
26
|
-
export type SnackAssetFile = {
|
|
27
|
-
type: 'ASSET';
|
|
28
|
-
contents: string | File | Blob | FormData; // string = url
|
|
29
|
-
error?: Error;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* The content of a Snack code or asset file.
|
|
34
|
-
*/
|
|
35
|
-
export type SnackFile = SnackCodeFile | SnackAssetFile;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Dictionary of file-names and their content that make up
|
|
39
|
-
* the files of the Snack.
|
|
40
|
-
*/
|
|
41
|
-
export type SnackFiles = {
|
|
42
|
-
[path: string]: SnackFile;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Dictionary of dependencies and their version.
|
|
47
|
-
*/
|
|
48
|
-
export type SnackDependencyVersions = { [name: string]: string };
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* The version, resolved handle, peer-dependencies and optional
|
|
52
|
-
* error of a dependency.
|
|
53
|
-
*/
|
|
54
|
-
export type SnackDependency = {
|
|
55
|
-
version: string;
|
|
56
|
-
handle?: string;
|
|
57
|
-
peerDependencies?: SnackDependencyVersions;
|
|
58
|
-
error?: Error;
|
|
59
|
-
wantedVersion?: string;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Dictionary of dependency names and their (resolved) versions.
|
|
64
|
-
*/
|
|
65
|
-
export type SnackDependencies = {
|
|
66
|
-
[name: string]: SnackDependency;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Wanted version of the dependency that is missing, including the
|
|
71
|
-
* dependents which have this dependency as a peer-dependency.
|
|
72
|
-
*/
|
|
73
|
-
export type SnackMissingDependency = {
|
|
74
|
-
dependents: string[];
|
|
75
|
-
wantedVersion?: string;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Dictionary of dependencies that are missing.
|
|
80
|
-
*/
|
|
81
|
-
export type SnackMissingDependencies = {
|
|
82
|
-
[name: string]: SnackMissingDependency;
|
|
83
|
-
};
|
|
9
|
+
import { SnackTransport } from './transports';
|
|
84
10
|
|
|
85
11
|
/**
|
|
86
12
|
* An error that can optionally hold a file-name and line/column location.
|
package/src/utils.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import fetchPonyfill from 'fetch-ponyfill';
|
|
2
2
|
import { customAlphabet } from 'nanoid';
|
|
3
|
+
import { SDKVersion } from 'snack-content';
|
|
3
4
|
|
|
4
|
-
import {
|
|
5
|
+
import { SnackError, SnackUser } from './types';
|
|
5
6
|
|
|
6
7
|
const { fetch } = fetchPonyfill();
|
|
7
8
|
export { fetch };
|
package/build/sdk.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { SDKVersion, SDKFeature, SnackDependencies } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Checks whether a specific module/dependency is preloaded for the given SDK version.
|
|
4
|
-
*/
|
|
5
|
-
export declare function isModulePreloaded(name: string, sdkVersion: SDKVersion, coreModulesOnly?: boolean): boolean;
|
|
6
|
-
/**
|
|
7
|
-
* Returns the list of pre-loaded modules for the given SDK version.
|
|
8
|
-
*/
|
|
9
|
-
export declare function getPreloadedModules(sdkVersion: SDKVersion, coreModulesOnly?: boolean): {
|
|
10
|
-
[name: string]: string;
|
|
11
|
-
};
|
|
12
|
-
export declare function validateSDKVersion(sdkVersion: SDKVersion): SDKVersion;
|
|
13
|
-
/**
|
|
14
|
-
* Checks whether the module is deprecated for the given sdk-version and returns
|
|
15
|
-
* the alternative module or error description instead. If the module is not deprecated
|
|
16
|
-
* `undefined` is returned.
|
|
17
|
-
*/
|
|
18
|
-
export declare function getDeprecatedModule(name: string, sdkVersion: SDKVersion): string | undefined;
|
|
19
|
-
/**
|
|
20
|
-
* Returns the list of supported SDK versions.
|
|
21
|
-
*/
|
|
22
|
-
export declare function getSupportedSDKVersions(): SDKVersion[];
|
|
23
|
-
/**
|
|
24
|
-
* Verifies whether a string is a valid semver.
|
|
25
|
-
*/
|
|
26
|
-
export declare function isValidSemver(version: string): boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Checks whether a feature is supported by the given SDK version.
|
|
29
|
-
*/
|
|
30
|
-
export declare function isFeatureSupported(feature: SDKFeature, sdkVersion: string): boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Converts older dependency formats into the SnackDependencies type.
|
|
33
|
-
*/
|
|
34
|
-
export declare function standardizeDependencies(dependencies: any): SnackDependencies;
|