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.
Files changed (58) hide show
  1. package/CHANGELOG.md +27 -1
  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 +305 -301
  11. package/build/Session.js +1198 -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 +189 -185
  36. package/build/types.js +2 -2
  37. package/build/types.js.map +1 -1
  38. package/build/utils.d.ts +17 -17
  39. package/build/utils.js +68 -68
  40. package/package.json +11 -4
  41. package/src/DependencyResolver.ts +0 -218
  42. package/src/DevSession.ts +0 -159
  43. package/src/FileUploader.ts +0 -135
  44. package/src/Logger.ts +0 -33
  45. package/src/Session.ts +0 -1293
  46. package/src/State.ts +0 -98
  47. package/src/WantedVersions.ts +0 -57
  48. package/src/defaultConfig.ts +0 -33
  49. package/src/index.ts +0 -59
  50. package/src/transports/CodeMessageBuilder.ts +0 -226
  51. package/src/transports/Protocol.ts +0 -78
  52. package/src/transports/Transport.ts +0 -270
  53. package/src/transports/index.ts +0 -8
  54. package/src/transports/types.ts +0 -89
  55. package/src/transports/webPlayer.ts +0 -93
  56. package/src/types.ts +0 -223
  57. package/src/utils.ts +0 -71
  58. package/tsconfig.json +0 -28
@@ -1,197 +1,197 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.getFileDiff = void 0;
18
- var diff_1 = require("diff");
19
- var snack_content_1 = require("snack-content");
20
- var ua_parser_js_1 = require("ua-parser-js");
21
- var FileUploader_1 = __importDefault(require("../FileUploader"));
22
- var defaultConfig_1 = require("../defaultConfig");
23
- var SnackIdentityCode = {
24
- files: defaultConfig_1.SnackIdentityState.files,
25
- dependencies: defaultConfig_1.SnackIdentityState.dependencies,
26
- sdkVersion: defaultConfig_1.SnackIdentityState.sdkVersion,
27
- };
28
- function getFileDiff(oldCode, newCode) {
29
- var patch = diff_1.createPatch('code', oldCode, newCode, '', '', {
30
- context: 0,
31
- });
32
- if (patch) {
33
- return patch;
34
- }
35
- else {
36
- throw new Error('Error creating a file diff');
37
- }
38
- }
39
- exports.getFileDiff = getFileDiff;
40
- var PLACEHOLDER_URL = 'https://snack-code-uploads.s3.us-west-1.amazonaws.com/~asset/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
41
- var CodeMessageBuilder = /** @class */ (function () {
42
- function CodeMessageBuilder(options) {
43
- var _this = this;
44
- this.code = SnackIdentityCode;
45
- this.placeholderURLs = {};
46
- this.uploadedURLs = {};
47
- this.onFileUploaded = function (request, resultURL, _error) {
48
- var path = request.path;
49
- delete _this.placeholderURLs[path];
50
- if (resultURL) {
51
- _this.uploadedURLs[path] = resultURL;
52
- if (!Object.keys(_this.placeholderURLs).length) {
53
- var codeMessage = _this.createCodeMessage(_this.code, _this.codeMessage, _this.code);
54
- if (_this.verifyCodeMessageSize(codeMessage)) {
55
- _this.callback(codeMessage, _this.code);
56
- }
57
- }
58
- }
59
- };
60
- this.logger = options.logger;
61
- this.callback = options.callback;
62
- this.verifyCodeMessageSize = options.verifyCodeMessageSize;
63
- this.maxDiffPlaceholder = options.maxDiffPlaceholder;
64
- this.codeUploader = options.apiURL
65
- ? new FileUploader_1.default({
66
- apiURL: options.apiURL,
67
- logger: options.logger,
68
- callback: this.onFileUploaded,
69
- })
70
- : undefined;
71
- }
72
- CodeMessageBuilder.prototype.setCode = function (code) {
73
- var _a, _b, _c;
74
- if (code === this.code) {
75
- return;
76
- }
77
- var prevCode = this.code;
78
- var files = code.files;
79
- this.code = code;
80
- // Cancel any uploads for files that were removed or changed
81
- for (var path in prevCode.files) {
82
- if (prevCode.files[path].contents !== ((_a = files[path]) === null || _a === void 0 ? void 0 : _a.contents)) {
83
- delete this.placeholderURLs[path];
84
- delete this.uploadedURLs[path];
85
- (_b = this.codeUploader) === null || _b === void 0 ? void 0 : _b.remove(path, prevCode.files[path]);
86
- }
87
- }
88
- // Generate code message
89
- var codeMessage = this.createCodeMessage(code, this.codeMessage, prevCode);
90
- this.codeMessage = codeMessage;
91
- // When the code message size is valid and there are no pending
92
- // uploads, then fire the callback immediately
93
- if (this.verifyCodeMessageSize(codeMessage)) {
94
- if (!Object.keys(this.placeholderURLs).length) {
95
- this.callback(codeMessage, code);
96
- }
97
- return;
98
- }
99
- // Upload files if the code message exceeds the limit
100
- // Sort code files by size
101
- if (this.codeUploader) {
102
- var paths = Object.keys(files)
103
- .filter(function (path) { return files[path].type === 'CODE'; })
104
- // @ts-ignore
105
- .sort(function (a, b) { return files[b].contents.length - files[a].contents.length; });
106
- // Upload the largest file
107
- for (var i = 0; i < paths.length; i++) {
108
- var path = paths[i];
109
- if (!this.uploadedURLs[path] && !this.placeholderURLs[path]) {
110
- var file = files[path];
111
- this.placeholderURLs[path] = PLACEHOLDER_URL;
112
- // this.logger?.comm('Uploading file', path, `, ${file.contents.length} bytes ...`);
113
- this.codeUploader.add(path, file);
114
- codeMessage.diff[path] = '';
115
- codeMessage.s3url[path] = this.placeholderURLs[path];
116
- if (this.verifyCodeMessageSize(codeMessage)) {
117
- // Message size is now valid. When the upload completes, it
118
- // will try to call the callback
119
- return;
120
- }
121
- }
122
- }
123
- }
124
- // Message is still too large
125
- (_c = this.logger) === null || _c === void 0 ? void 0 : _c.error('Message size is too large');
126
- };
127
- CodeMessageBuilder.prototype.createCodeMessage = function (code, prevCodeMessage, prevCode) {
128
- var files = code.files, dependencies = code.dependencies, sdkVersion = code.sdkVersion;
129
- var diff = __assign({}, files);
130
- var s3url = {};
131
- for (var path in files) {
132
- var file = files[path];
133
- if (this.uploadedURLs[path] || this.placeholderURLs[path]) {
134
- diff[path] = '';
135
- s3url[path] = this.uploadedURLs[path] || this.placeholderURLs[path];
136
- }
137
- else {
138
- if (file.type === 'CODE') {
139
- if ((prevCodeMessage === null || prevCodeMessage === void 0 ? void 0 : prevCodeMessage.diff[path]) &&
140
- (prevCode === null || prevCode === void 0 ? void 0 : prevCode.files[path].contents) === code.files[path].contents) {
141
- diff[path] = prevCodeMessage.diff[path];
142
- }
143
- else {
144
- if (this.maxDiffPlaceholder && file.contents.length >= this.maxDiffPlaceholder.length) {
145
- diff[path] = this.maxDiffPlaceholder;
146
- }
147
- else {
148
- diff[path] = getFileDiff('', file.contents);
149
- }
150
- }
151
- }
152
- else {
153
- diff[path] = '';
154
- }
155
- if (file.type === 'ASSET' && typeof file.contents === 'string') {
156
- s3url[path] = file.contents;
157
- }
158
- }
159
- }
160
- var deps = {};
161
- for (var name_1 in dependencies) {
162
- var dep = dependencies[name_1];
163
- if (dep.handle && !snack_content_1.isModulePreloaded(name_1, sdkVersion)) {
164
- deps[name_1] = {
165
- version: dep.version,
166
- handle: dep.handle,
167
- // Resolved has been replaced by handle. It is still needed for pre SDK 37 runtimes
168
- resolved: dep.handle.substring(dep.handle.lastIndexOf('@') + 1),
169
- };
170
- }
171
- }
172
- var metadata = {
173
- expoSDKVersion: code.sdkVersion,
174
- };
175
- if (typeof navigator !== 'undefined' && navigator.userAgent) {
176
- var ua = new ua_parser_js_1.UAParser(navigator.userAgent).getResult();
177
- metadata.webHostName = window.location.hostname;
178
- metadata.webOSArchitecture = ua.cpu.architecture;
179
- metadata.webOSFamily = ua.os.name;
180
- metadata.webOSVersion = ua.os.version;
181
- metadata.webLayoutEngine = ua.engine.name;
182
- metadata.webDeviceType = ua.device.type;
183
- metadata.webBrowser = ua.browser.name;
184
- metadata.webBrowserVersion = ua.browser.version;
185
- }
186
- return {
187
- type: 'CODE',
188
- diff: diff,
189
- s3url: s3url,
190
- dependencies: deps,
191
- metadata: metadata,
192
- };
193
- };
194
- return CodeMessageBuilder;
195
- }());
196
- exports.default = CodeMessageBuilder;
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.getFileDiff = void 0;
18
+ var diff_1 = require("diff");
19
+ var snack_content_1 = require("snack-content");
20
+ var ua_parser_js_1 = require("ua-parser-js");
21
+ var FileUploader_1 = __importDefault(require("../FileUploader"));
22
+ var defaultConfig_1 = require("../defaultConfig");
23
+ var SnackIdentityCode = {
24
+ files: defaultConfig_1.SnackIdentityState.files,
25
+ dependencies: defaultConfig_1.SnackIdentityState.dependencies,
26
+ sdkVersion: defaultConfig_1.SnackIdentityState.sdkVersion,
27
+ };
28
+ function getFileDiff(oldCode, newCode) {
29
+ var patch = diff_1.createPatch('code', oldCode, newCode, '', '', {
30
+ context: 0,
31
+ });
32
+ if (patch) {
33
+ return patch;
34
+ }
35
+ else {
36
+ throw new Error('Error creating a file diff');
37
+ }
38
+ }
39
+ exports.getFileDiff = getFileDiff;
40
+ var PLACEHOLDER_URL = 'https://snack-code-uploads.s3.us-west-1.amazonaws.com/~asset/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
41
+ var CodeMessageBuilder = /** @class */ (function () {
42
+ function CodeMessageBuilder(options) {
43
+ var _this = this;
44
+ this.code = SnackIdentityCode;
45
+ this.placeholderURLs = {};
46
+ this.uploadedURLs = {};
47
+ this.onFileUploaded = function (request, resultURL, _error) {
48
+ var path = request.path;
49
+ delete _this.placeholderURLs[path];
50
+ if (resultURL) {
51
+ _this.uploadedURLs[path] = resultURL;
52
+ if (!Object.keys(_this.placeholderURLs).length) {
53
+ var codeMessage = _this.createCodeMessage(_this.code, _this.codeMessage, _this.code);
54
+ if (_this.verifyCodeMessageSize(codeMessage)) {
55
+ _this.callback(codeMessage, _this.code);
56
+ }
57
+ }
58
+ }
59
+ };
60
+ this.logger = options.logger;
61
+ this.callback = options.callback;
62
+ this.verifyCodeMessageSize = options.verifyCodeMessageSize;
63
+ this.maxDiffPlaceholder = options.maxDiffPlaceholder;
64
+ this.codeUploader = options.apiURL
65
+ ? new FileUploader_1.default({
66
+ apiURL: options.apiURL,
67
+ logger: options.logger,
68
+ callback: this.onFileUploaded,
69
+ })
70
+ : undefined;
71
+ }
72
+ CodeMessageBuilder.prototype.setCode = function (code) {
73
+ var _a, _b, _c;
74
+ if (code === this.code) {
75
+ return;
76
+ }
77
+ var prevCode = this.code;
78
+ var files = code.files;
79
+ this.code = code;
80
+ // Cancel any uploads for files that were removed or changed
81
+ for (var path in prevCode.files) {
82
+ if (prevCode.files[path].contents !== ((_a = files[path]) === null || _a === void 0 ? void 0 : _a.contents)) {
83
+ delete this.placeholderURLs[path];
84
+ delete this.uploadedURLs[path];
85
+ (_b = this.codeUploader) === null || _b === void 0 ? void 0 : _b.remove(path, prevCode.files[path]);
86
+ }
87
+ }
88
+ // Generate code message
89
+ var codeMessage = this.createCodeMessage(code, this.codeMessage, prevCode);
90
+ this.codeMessage = codeMessage;
91
+ // When the code message size is valid and there are no pending
92
+ // uploads, then fire the callback immediately
93
+ if (this.verifyCodeMessageSize(codeMessage)) {
94
+ if (!Object.keys(this.placeholderURLs).length) {
95
+ this.callback(codeMessage, code);
96
+ }
97
+ return;
98
+ }
99
+ // Upload files if the code message exceeds the limit
100
+ // Sort code files by size
101
+ if (this.codeUploader) {
102
+ var paths = Object.keys(files)
103
+ .filter(function (path) { return files[path].type === 'CODE'; })
104
+ // @ts-ignore
105
+ .sort(function (a, b) { return files[b].contents.length - files[a].contents.length; });
106
+ // Upload the largest file
107
+ for (var i = 0; i < paths.length; i++) {
108
+ var path = paths[i];
109
+ if (!this.uploadedURLs[path] && !this.placeholderURLs[path]) {
110
+ var file = files[path];
111
+ this.placeholderURLs[path] = PLACEHOLDER_URL;
112
+ // this.logger?.comm('Uploading file', path, `, ${file.contents.length} bytes ...`);
113
+ this.codeUploader.add(path, file);
114
+ codeMessage.diff[path] = '';
115
+ codeMessage.s3url[path] = this.placeholderURLs[path];
116
+ if (this.verifyCodeMessageSize(codeMessage)) {
117
+ // Message size is now valid. When the upload completes, it
118
+ // will try to call the callback
119
+ return;
120
+ }
121
+ }
122
+ }
123
+ }
124
+ // Message is still too large
125
+ (_c = this.logger) === null || _c === void 0 ? void 0 : _c.error('Message size is too large');
126
+ };
127
+ CodeMessageBuilder.prototype.createCodeMessage = function (code, prevCodeMessage, prevCode) {
128
+ var files = code.files, dependencies = code.dependencies, sdkVersion = code.sdkVersion;
129
+ var diff = __assign({}, files);
130
+ var s3url = {};
131
+ for (var path in files) {
132
+ var file = files[path];
133
+ if (this.uploadedURLs[path] || this.placeholderURLs[path]) {
134
+ diff[path] = '';
135
+ s3url[path] = this.uploadedURLs[path] || this.placeholderURLs[path];
136
+ }
137
+ else {
138
+ if (file.type === 'CODE') {
139
+ if ((prevCodeMessage === null || prevCodeMessage === void 0 ? void 0 : prevCodeMessage.diff[path]) &&
140
+ (prevCode === null || prevCode === void 0 ? void 0 : prevCode.files[path].contents) === code.files[path].contents) {
141
+ diff[path] = prevCodeMessage.diff[path];
142
+ }
143
+ else {
144
+ if (this.maxDiffPlaceholder && file.contents.length >= this.maxDiffPlaceholder.length) {
145
+ diff[path] = this.maxDiffPlaceholder;
146
+ }
147
+ else {
148
+ diff[path] = getFileDiff('', file.contents);
149
+ }
150
+ }
151
+ }
152
+ else {
153
+ diff[path] = '';
154
+ }
155
+ if (file.type === 'ASSET' && typeof file.contents === 'string') {
156
+ s3url[path] = file.contents;
157
+ }
158
+ }
159
+ }
160
+ var deps = {};
161
+ for (var name_1 in dependencies) {
162
+ var dep = dependencies[name_1];
163
+ if (dep.handle && !snack_content_1.isModulePreloaded(name_1, sdkVersion)) {
164
+ deps[name_1] = {
165
+ version: dep.version,
166
+ handle: dep.handle,
167
+ // Resolved has been replaced by handle. It is still needed for pre SDK 37 runtimes
168
+ resolved: dep.handle.substring(dep.handle.lastIndexOf('@') + 1),
169
+ };
170
+ }
171
+ }
172
+ var metadata = {
173
+ expoSDKVersion: code.sdkVersion,
174
+ };
175
+ if (typeof navigator !== 'undefined' && navigator.userAgent) {
176
+ var ua = new ua_parser_js_1.UAParser(navigator.userAgent).getResult();
177
+ metadata.webHostName = window.location.hostname;
178
+ metadata.webOSArchitecture = ua.cpu.architecture;
179
+ metadata.webOSFamily = ua.os.name;
180
+ metadata.webOSVersion = ua.os.version;
181
+ metadata.webLayoutEngine = ua.engine.name;
182
+ metadata.webDeviceType = ua.device.type;
183
+ metadata.webBrowser = ua.browser.name;
184
+ metadata.webBrowserVersion = ua.browser.version;
185
+ }
186
+ return {
187
+ type: 'CODE',
188
+ diff: diff,
189
+ s3url: s3url,
190
+ dependencies: deps,
191
+ metadata: metadata,
192
+ };
193
+ };
194
+ return CodeMessageBuilder;
195
+ }());
196
+ exports.default = CodeMessageBuilder;
197
197
  //# sourceMappingURL=CodeMessageBuilder.js.map
@@ -1,64 +1,64 @@
1
- import { SDKVersion } from 'snack-content';
2
- export declare type Device = {
3
- name: string;
4
- id: string;
5
- platform: string;
6
- };
7
- export declare type ProtocolConsoleMessage = {
8
- type: 'CONSOLE';
9
- device: Device;
10
- method: 'log' | 'error' | 'warn';
11
- payload: any[];
12
- };
13
- export declare type ProtocolErrorMessage = {
14
- type: 'ERROR';
15
- error: string;
16
- device: Device;
17
- };
18
- export declare type ProtocolResendCodeMessage = {
19
- type: 'RESEND_CODE';
20
- device: Device;
21
- };
22
- export declare type ProtocolCodeMessageDependencies = {
23
- [name: string]: {
24
- version: string;
25
- resolved: string;
26
- handle: string;
27
- };
28
- };
29
- export declare type ProtocolCodeMessage = {
30
- type: 'CODE';
31
- diff: {
32
- [path: string]: string;
33
- };
34
- s3url: {
35
- [path: string]: string;
36
- };
37
- dependencies: ProtocolCodeMessageDependencies;
38
- metadata: {
39
- expoSDKVersion: SDKVersion;
40
- webSnackSDKVersion: string;
41
- webHostname?: string;
42
- webOSArchitecture?: string;
43
- webOSFamily?: string;
44
- webOSVersion?: string;
45
- webLayoutEngine?: string;
46
- webDeviceType?: string;
47
- webBrowser?: string;
48
- webBrowserVersion?: string;
49
- webDescription?: string;
50
- };
51
- };
52
- export declare type ProtocolReloadMessage = {
53
- type: 'RELOAD_SNACK';
54
- };
55
- export declare type ProtocolRequestStatusMessage = {
56
- type: 'REQUEST_STATUS';
57
- };
58
- export declare type ProtocolStatusMessage = {
59
- type: 'STATUS_REPORT';
60
- previewLocation: string;
61
- status: 'FAILURE' | 'SUCCESS';
62
- };
63
- export declare type ProtocolOutgoingMessage = ProtocolCodeMessage | ProtocolReloadMessage | ProtocolRequestStatusMessage;
64
- export declare type ProtocolIncomingMessage = ProtocolConsoleMessage | ProtocolErrorMessage | ProtocolResendCodeMessage | ProtocolStatusMessage;
1
+ import { SDKVersion } from 'snack-content';
2
+ export declare type Device = {
3
+ name: string;
4
+ id: string;
5
+ platform: string;
6
+ };
7
+ export declare type ProtocolConsoleMessage = {
8
+ type: 'CONSOLE';
9
+ device: Device;
10
+ method: 'log' | 'error' | 'warn';
11
+ payload: any[];
12
+ };
13
+ export declare type ProtocolErrorMessage = {
14
+ type: 'ERROR';
15
+ error: string;
16
+ device: Device;
17
+ };
18
+ export declare type ProtocolResendCodeMessage = {
19
+ type: 'RESEND_CODE';
20
+ device: Device;
21
+ };
22
+ export declare type ProtocolCodeMessageDependencies = {
23
+ [name: string]: {
24
+ version: string;
25
+ resolved: string;
26
+ handle: string;
27
+ };
28
+ };
29
+ export declare type ProtocolCodeMessage = {
30
+ type: 'CODE';
31
+ diff: {
32
+ [path: string]: string;
33
+ };
34
+ s3url: {
35
+ [path: string]: string;
36
+ };
37
+ dependencies: ProtocolCodeMessageDependencies;
38
+ metadata: {
39
+ expoSDKVersion: SDKVersion;
40
+ webSnackSDKVersion: string;
41
+ webHostname?: string;
42
+ webOSArchitecture?: string;
43
+ webOSFamily?: string;
44
+ webOSVersion?: string;
45
+ webLayoutEngine?: string;
46
+ webDeviceType?: string;
47
+ webBrowser?: string;
48
+ webBrowserVersion?: string;
49
+ webDescription?: string;
50
+ };
51
+ };
52
+ export declare type ProtocolReloadMessage = {
53
+ type: 'RELOAD_SNACK';
54
+ };
55
+ export declare type ProtocolRequestStatusMessage = {
56
+ type: 'REQUEST_STATUS';
57
+ };
58
+ export declare type ProtocolStatusMessage = {
59
+ type: 'STATUS_REPORT';
60
+ previewLocation: string;
61
+ status: 'FAILURE' | 'SUCCESS';
62
+ };
63
+ export declare type ProtocolOutgoingMessage = ProtocolCodeMessage | ProtocolReloadMessage | ProtocolRequestStatusMessage;
64
+ export declare type ProtocolIncomingMessage = ProtocolConsoleMessage | ProtocolErrorMessage | ProtocolResendCodeMessage | ProtocolStatusMessage;
@@ -1,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  //# sourceMappingURL=Protocol.js.map
@@ -1,27 +1,28 @@
1
- import { ProtocolCodeMessage } from './Protocol';
2
- import { SnackTransport, SnackTransportListener, SnackTransportMessage, SnackTransportOptions } from './types';
3
- export declare function calcPubNubCodeMessageSize(channel: string, codeMessage: ProtocolCodeMessage): number;
4
- export default class Transport implements SnackTransport {
5
- private readonly channel;
6
- private readonly logger?;
7
- private callback?;
8
- private pubNub?;
9
- private codeMessageBuilder;
10
- private codeMessage?;
11
- private connectionsCount;
12
- private readonly logSuffix;
13
- constructor(options: SnackTransportOptions);
14
- addEventListener(_type: 'message', callback: SnackTransportListener): void;
15
- removeEventListener(_type: 'message', _callback: SnackTransportListener): void;
16
- postMessage(message: SnackTransportMessage): void;
17
- private start;
18
- private stop;
19
- private onProtocolMessage;
20
- private publish;
21
- private onPubNubPresence;
22
- private onPubNubMessage;
23
- private onPubNubStatus;
24
- private onPubNubVerifyCodeMessageSize;
25
- private onSyntheticEvent;
26
- private onCodeMessageReady;
27
- }
1
+ import { ProtocolCodeMessage } from './Protocol';
2
+ import { SnackTransport, SnackTransportListener, SnackTransportMessage, SnackTransportOptions } from './types';
3
+ export declare function calcPubNubCodeMessageSize(channel: string, codeMessage: ProtocolCodeMessage): number;
4
+ export default class Transport implements SnackTransport {
5
+ private readonly channel;
6
+ private readonly logger?;
7
+ private callback?;
8
+ private pubNub?;
9
+ private pubNubClientId?;
10
+ private codeMessageBuilder;
11
+ private codeMessage?;
12
+ private connectionsCount;
13
+ private readonly logSuffix;
14
+ constructor(options: SnackTransportOptions);
15
+ addEventListener(_type: 'message', callback: SnackTransportListener): void;
16
+ removeEventListener(_type: 'message', _callback: SnackTransportListener): void;
17
+ postMessage(message: SnackTransportMessage): void;
18
+ private start;
19
+ private stop;
20
+ private onProtocolMessage;
21
+ private publish;
22
+ private onPubNubPresence;
23
+ private onPubNubMessage;
24
+ private onPubNubStatus;
25
+ private onPubNubVerifyCodeMessageSize;
26
+ private onSyntheticEvent;
27
+ private onCodeMessageReady;
28
+ }