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.
Files changed (57) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/build/DependencyResolver.d.ts +26 -26
  3. package/build/DependencyResolver.js +258 -258
  4. package/build/DevSession.d.ts +20 -20
  5. package/build/DevSession.js +203 -203
  6. package/build/FileUploader.d.ts +23 -23
  7. package/build/FileUploader.js +174 -174
  8. package/build/Logger.d.ts +11 -11
  9. package/build/Logger.js +33 -33
  10. package/build/Session.d.ts +301 -301
  11. package/build/Session.js +1172 -1171
  12. package/build/Session.js.map +1 -1
  13. package/build/State.d.ts +16 -16
  14. package/build/State.js +90 -90
  15. package/build/WantedVersions.d.ts +40 -17
  16. package/build/WantedVersions.js +156 -93
  17. package/build/WantedVersions.js.map +1 -1
  18. package/build/defaultConfig.d.ts +12 -12
  19. package/build/defaultConfig.js +29 -29
  20. package/build/index.d.ts +7 -7
  21. package/build/index.js +30 -30
  22. package/build/transports/CodeMessageBuilder.d.ts +31 -31
  23. package/build/transports/CodeMessageBuilder.js +196 -196
  24. package/build/transports/Protocol.d.ts +64 -64
  25. package/build/transports/Protocol.js +2 -2
  26. package/build/transports/Transport.d.ts +28 -27
  27. package/build/transports/Transport.js +303 -298
  28. package/build/transports/Transport.js.map +1 -1
  29. package/build/transports/index.d.ts +3 -3
  30. package/build/transports/index.js +22 -22
  31. package/build/transports/types.d.ts +63 -63
  32. package/build/transports/types.js +2 -2
  33. package/build/transports/webPlayer.d.ts +12 -12
  34. package/build/transports/webPlayer.js +70 -70
  35. package/build/types.d.ts +185 -185
  36. package/build/types.js +2 -2
  37. package/build/utils.d.ts +17 -17
  38. package/build/utils.js +68 -68
  39. package/package.json +11 -4
  40. package/src/DependencyResolver.ts +0 -218
  41. package/src/DevSession.ts +0 -159
  42. package/src/FileUploader.ts +0 -135
  43. package/src/Logger.ts +0 -33
  44. package/src/Session.ts +0 -1293
  45. package/src/State.ts +0 -98
  46. package/src/WantedVersions.ts +0 -57
  47. package/src/defaultConfig.ts +0 -33
  48. package/src/index.ts +0 -59
  49. package/src/transports/CodeMessageBuilder.ts +0 -226
  50. package/src/transports/Protocol.ts +0 -78
  51. package/src/transports/Transport.ts +0 -270
  52. package/src/transports/index.ts +0 -8
  53. package/src/transports/types.ts +0 -89
  54. package/src/transports/webPlayer.ts +0 -93
  55. package/src/types.ts +0 -223
  56. package/src/utils.ts +0 -71
  57. 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
- }