@qualtrics/plugin-client 1.8.19

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 (49) hide show
  1. package/create-npm-package.js +39 -0
  2. package/dist/package.json +33 -0
  3. package/dist/src/constants.d.ts +12 -0
  4. package/dist/src/constants.js +21 -0
  5. package/dist/src/constants.js.map +1 -0
  6. package/dist/src/deferred.d.ts +6 -0
  7. package/dist/src/deferred.js +28 -0
  8. package/dist/src/deferred.js.map +1 -0
  9. package/dist/src/errors/encoder.d.ts +15 -0
  10. package/dist/src/errors/encoder.js +130 -0
  11. package/dist/src/errors/encoder.js.map +1 -0
  12. package/dist/src/errors/errorMessages.d.ts +4 -0
  13. package/dist/src/errors/errorMessages.js +14 -0
  14. package/dist/src/errors/errorMessages.js.map +1 -0
  15. package/dist/src/errors/errorTypes.d.ts +67 -0
  16. package/dist/src/errors/errorTypes.js +166 -0
  17. package/dist/src/errors/errorTypes.js.map +1 -0
  18. package/dist/src/errors/interfaceValidator.d.ts +30 -0
  19. package/dist/src/errors/interfaceValidator.js +54 -0
  20. package/dist/src/errors/interfaceValidator.js.map +1 -0
  21. package/dist/src/lib/messages/messageChannel.d.ts +126 -0
  22. package/dist/src/lib/messages/messageChannel.js +390 -0
  23. package/dist/src/lib/messages/messageChannel.js.map +1 -0
  24. package/dist/src/lib/plugin/buildConfig.d.ts +1 -0
  25. package/dist/src/lib/plugin/buildConfig.js +3 -0
  26. package/dist/src/lib/plugin/buildConfig.js.map +1 -0
  27. package/dist/src/lib/plugin/index.d.ts +3 -0
  28. package/dist/src/lib/plugin/index.js +4 -0
  29. package/dist/src/lib/plugin/index.js.map +1 -0
  30. package/dist/src/lib/plugin/models.d.ts +13 -0
  31. package/dist/src/lib/plugin/models.js +9 -0
  32. package/dist/src/lib/plugin/models.js.map +1 -0
  33. package/dist/src/lib/plugin/pluginClient.d.ts +155 -0
  34. package/dist/src/lib/plugin/pluginClient.js +436 -0
  35. package/dist/src/lib/plugin/pluginClient.js.map +1 -0
  36. package/dist/src/lib/plugin/translations.d.ts +15 -0
  37. package/dist/src/lib/plugin/translations.js +49 -0
  38. package/dist/src/lib/plugin/translations.js.map +1 -0
  39. package/dist/src/modelUtils.d.ts +6 -0
  40. package/dist/src/modelUtils.js +21 -0
  41. package/dist/src/modelUtils.js.map +1 -0
  42. package/dist/src/models.d.ts +125 -0
  43. package/dist/src/models.js +130 -0
  44. package/dist/src/models.js.map +1 -0
  45. package/dist/src/utils.d.ts +3 -0
  46. package/dist/src/utils.js +23 -0
  47. package/dist/src/utils.js.map +1 -0
  48. package/package.json +25 -0
  49. package/tsconfig.json +16 -0
@@ -0,0 +1,126 @@
1
+ import { BaseHandler, MessageData } from "../../models";
2
+ /**
3
+ * MessageChannel handles the sending and receiving of messages via
4
+ * `postMessage`.
5
+ *
6
+ * It defines the message-passing protocol between the Plugin Manager, the
7
+ * Plugin Client, and credential selector pieces; it should be used by all of
8
+ * them.
9
+ *
10
+ * There should be one of these on each end of a connection. The Plugin Manager
11
+ * may have several: One for each entity it's communicating with.
12
+ */
13
+ declare class MessageChannel {
14
+ protected name: string;
15
+ other: Window;
16
+ otherOrigin: string | null;
17
+ private handlers;
18
+ protected window: Window;
19
+ private instanceId;
20
+ private pendingMessages;
21
+ private nextMessageId;
22
+ private readonly handleMessageFunc;
23
+ /**
24
+ * Create a MessageChannel
25
+ *
26
+ * @param {Object} options Configuration for the channel. See below
27
+ * descriptions for valid fields.
28
+ *
29
+ * @param {string} options.name What this window will be called. Messages
30
+ * will be sent with this name as a prefix. For backward compatibility with
31
+ * the pre-1.0.0 Plugin Client, the Plugin Manager must choose "host".
32
+ *
33
+ * @param {Object} options.other The Window that will receive sent messages,
34
+ * and from which messages will be received.
35
+ *
36
+ * @param {string | null} options.otherOrigin The origin of the Window. This
37
+ * can't be automatically computed from the Window itself, because accessing
38
+ * a Window across domains is disallowed. If the Window will be sandboxed,
39
+ * set this to null to disable origin checking.
40
+ *
41
+ * @param {Object} options.handlers An object containing message handlers.
42
+ * Each key of the object should be a message name, with the corresponding
43
+ * value being a function that will be called when a message of that name is
44
+ * received.
45
+ *
46
+ * @param {string} options.instanceId [DEPRECATED] If `options.instanceId` is
47
+ * set, each message sent by this MessageChannel will include the field
48
+ * "instanceID", with its value equal to `options.instanceId`. This field was
49
+ * historically used by the host to disambiguate responses from different
50
+ * plugins, though the source window is now used for that.
51
+ */
52
+ constructor(params?: {
53
+ name?: string;
54
+ other?: Window;
55
+ otherOrigin?: string | null;
56
+ handlers?: Record<string, BaseHandler>;
57
+ instanceId?: string;
58
+ });
59
+ /**
60
+ * Tear down the MessageChannel, removing the event listener on the window.
61
+ */
62
+ destroy(): void;
63
+ /**
64
+ * Set the instanceId for this channel.
65
+ */
66
+ setInstanceId(instanceId: string): void;
67
+ /**
68
+ * postMessage sends a message through the channel. It returns a Promise that
69
+ * will be resolved with the other's response, or rejected if the message
70
+ * isn't responded to within the timeout.
71
+ */
72
+ postMessage(name: string, data?: MessageData, timeout?: number): Promise<MessageData>;
73
+ registerHandler(name: string, handlerFunc: BaseHandler): boolean;
74
+ removeHandler(name: string): boolean;
75
+ /**
76
+ * Handle an incoming message. A bound version of this function is set as an
77
+ * event listener on the Window.
78
+ *
79
+ * @param {MessageEvent} message - The message to be handled.
80
+ *
81
+ * @returns {Promise} that resolves to undefined after the message is
82
+ * handled, including any necessary responses sent to the plugin (which may
83
+ * await Promises as needed to evaluate the response).
84
+ */
85
+ protected handleMessage(messageEvent: MessageEvent): Promise<void>;
86
+ private generateResponseFields;
87
+ /**
88
+ * @returns {Object|undefined} The parsed message body, or undefined if the
89
+ * message isn't valid.
90
+ */
91
+ private parseMessage;
92
+ private _isValidOrigin;
93
+ private _sendResponse;
94
+ /**
95
+ * Find the right handler for a message and call it, returning the handler's
96
+ * return value.
97
+ *
98
+ * This is a very simple function but is on its own because the plugin client
99
+ * calls it directly for init messages (pretending that the host has sent an
100
+ * init message, when actually the client starts sends the init event).
101
+ *
102
+ * @param {string} name - The message name, the key on which dispatch is
103
+ * based.
104
+ *
105
+ * @param {Object} data - The data to be passed to the correct handler.
106
+ *
107
+ * @returns The handler's return value
108
+ */
109
+ private dispatchMessage;
110
+ /**
111
+ * Find the right handler for a message, using its name.
112
+ *
113
+ * @param {string} name - The message name, the key on which dispatch is
114
+ * based.
115
+ *
116
+ * @returns {function | undefined} The correct handler function, which should be
117
+ * invoked with the message data. May return undefined, if there is no matching
118
+ * handler.
119
+ */
120
+ private getHandler;
121
+ private _resolvePromise;
122
+ private _getMessageId;
123
+ protected _postMessage(message: string): void;
124
+ protected _getTargetOrigin(): string;
125
+ }
126
+ export default MessageChannel;
@@ -0,0 +1,390 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ import { Deferred } from "../../deferred";
38
+ import { decodeError, encodeError, isEncodedError } from "../../errors/encoder";
39
+ import { addTimeout } from "../../utils";
40
+ var LONG_TIMEOUT = 10000;
41
+ /**
42
+ * MessageChannel handles the sending and receiving of messages via
43
+ * `postMessage`.
44
+ *
45
+ * It defines the message-passing protocol between the Plugin Manager, the
46
+ * Plugin Client, and credential selector pieces; it should be used by all of
47
+ * them.
48
+ *
49
+ * There should be one of these on each end of a connection. The Plugin Manager
50
+ * may have several: One for each entity it's communicating with.
51
+ */
52
+ var MessageChannel = /** @class */ (function () {
53
+ /**
54
+ * Create a MessageChannel
55
+ *
56
+ * @param {Object} options Configuration for the channel. See below
57
+ * descriptions for valid fields.
58
+ *
59
+ * @param {string} options.name What this window will be called. Messages
60
+ * will be sent with this name as a prefix. For backward compatibility with
61
+ * the pre-1.0.0 Plugin Client, the Plugin Manager must choose "host".
62
+ *
63
+ * @param {Object} options.other The Window that will receive sent messages,
64
+ * and from which messages will be received.
65
+ *
66
+ * @param {string | null} options.otherOrigin The origin of the Window. This
67
+ * can't be automatically computed from the Window itself, because accessing
68
+ * a Window across domains is disallowed. If the Window will be sandboxed,
69
+ * set this to null to disable origin checking.
70
+ *
71
+ * @param {Object} options.handlers An object containing message handlers.
72
+ * Each key of the object should be a message name, with the corresponding
73
+ * value being a function that will be called when a message of that name is
74
+ * received.
75
+ *
76
+ * @param {string} options.instanceId [DEPRECATED] If `options.instanceId` is
77
+ * set, each message sent by this MessageChannel will include the field
78
+ * "instanceID", with its value equal to `options.instanceId`. This field was
79
+ * historically used by the host to disambiguate responses from different
80
+ * plugins, though the source window is now used for that.
81
+ */
82
+ function MessageChannel(params) {
83
+ if (params === void 0) { params = {}; }
84
+ var _a = params.name, name = _a === void 0 ? 'unknown' : _a, _b = params.other, other = _b === void 0 ? window : _b, _c = params.otherOrigin, otherOrigin = _c === void 0 ? '' : _c, _d = params.handlers, handlers = _d === void 0 ? {} : _d, instanceId = params.instanceId;
85
+ this.name = name;
86
+ this.other = other;
87
+ this.otherOrigin = otherOrigin;
88
+ this.handlers = handlers;
89
+ this.window = window;
90
+ this.instanceId = instanceId;
91
+ this.pendingMessages = {};
92
+ this.nextMessageId = 1; // unique per message
93
+ var asyncBoundHandleMessage = this.handleMessage.bind(this);
94
+ this.handleMessageFunc = function (messageEvent) {
95
+ void asyncBoundHandleMessage(messageEvent);
96
+ };
97
+ this.window.addEventListener('message', this.handleMessageFunc);
98
+ }
99
+ /**
100
+ * Tear down the MessageChannel, removing the event listener on the window.
101
+ */
102
+ MessageChannel.prototype.destroy = function () {
103
+ this.window.removeEventListener('message', this.handleMessageFunc);
104
+ };
105
+ /**
106
+ * Set the instanceId for this channel.
107
+ */
108
+ MessageChannel.prototype.setInstanceId = function (instanceId) {
109
+ this.instanceId = instanceId;
110
+ };
111
+ /**
112
+ * postMessage sends a message through the channel. It returns a Promise that
113
+ * will be resolved with the other's response, or rejected if the message
114
+ * isn't responded to within the timeout.
115
+ */
116
+ MessageChannel.prototype.postMessage = function (name, data, timeout) {
117
+ if (timeout === void 0) { timeout = LONG_TIMEOUT; }
118
+ return __awaiter(this, void 0, void 0, function () {
119
+ var id, messageName, message, timeoutPromise, response;
120
+ return __generator(this, function (_a) {
121
+ id = "".concat(this.name, ".").concat(this._getMessageId());
122
+ messageName = "".concat(this.name, ".").concat(name);
123
+ message = JSON.stringify({
124
+ id: id,
125
+ instanceID: this.instanceId,
126
+ name: messageName,
127
+ data: data,
128
+ });
129
+ timeoutPromise = new Promise(function (resolve, reject) {
130
+ addTimeout(timeout, reject, { name: name, data: data });
131
+ });
132
+ response = new Deferred();
133
+ this.pendingMessages[id] = response;
134
+ this._postMessage(message);
135
+ return [2 /*return*/, Promise.race([response.promise, timeoutPromise])];
136
+ });
137
+ });
138
+ };
139
+ /*
140
+ Registers a function to be called when the given event name is posted to the iframe.
141
+ */
142
+ MessageChannel.prototype.registerHandler = function (name, handlerFunc) {
143
+ if (typeof handlerFunc !== 'function') {
144
+ return false;
145
+ }
146
+ this.handlers[name] = handlerFunc;
147
+ return true;
148
+ };
149
+ /*
150
+ Removes the handler associated with the event given.
151
+ */
152
+ MessageChannel.prototype.removeHandler = function (name) {
153
+ if (!this.handlers[name]) {
154
+ return false;
155
+ }
156
+ delete this.handlers[name];
157
+ return true;
158
+ };
159
+ /**
160
+ * Handle an incoming message. A bound version of this function is set as an
161
+ * event listener on the Window.
162
+ *
163
+ * @param {MessageEvent} message - The message to be handled.
164
+ *
165
+ * @returns {Promise} that resolves to undefined after the message is
166
+ * handled, including any necessary responses sent to the plugin (which may
167
+ * await Promises as needed to evaluate the response).
168
+ */
169
+ MessageChannel.prototype.handleMessage = function (messageEvent) {
170
+ return __awaiter(this, void 0, void 0, function () {
171
+ var maybeMessage, message, resultPromise, _a, _b;
172
+ return __generator(this, function (_c) {
173
+ switch (_c.label) {
174
+ case 0:
175
+ maybeMessage = this.parseMessage(messageEvent);
176
+ if (!maybeMessage) {
177
+ return [2 /*return*/];
178
+ }
179
+ message = maybeMessage;
180
+ if (message.id && message.id in this.pendingMessages) {
181
+ // This message is a reply. Resolve the relevant Promise.
182
+ this._resolvePromise(message.id, message);
183
+ return [2 /*return*/];
184
+ }
185
+ if (message.id && message.id.startsWith(this.name)) {
186
+ // Error: The id indicates this is originally from our side of the
187
+ // channel, but it wasn't caught by the reply filter above.
188
+ return [2 /*return*/];
189
+ }
190
+ resultPromise = this.dispatchMessage(message.name, message.data);
191
+ _a = this._sendResponse;
192
+ _b = [message];
193
+ return [4 /*yield*/, this.generateResponseFields(resultPromise)];
194
+ case 1:
195
+ _a.apply(this, _b.concat([_c.sent()]));
196
+ return [2 /*return*/];
197
+ }
198
+ });
199
+ });
200
+ };
201
+ MessageChannel.prototype.generateResponseFields = function (p) {
202
+ return __awaiter(this, void 0, void 0, function () {
203
+ var e_1;
204
+ var _a;
205
+ return __generator(this, function (_b) {
206
+ switch (_b.label) {
207
+ case 0:
208
+ _b.trys.push([0, 2, , 3]);
209
+ _a = {};
210
+ return [4 /*yield*/, p];
211
+ case 1: return [2 /*return*/, (_a.result = _b.sent(), _a.error = '', _a)];
212
+ case 2:
213
+ e_1 = _b.sent();
214
+ if (e_1 instanceof Error) {
215
+ return [2 /*return*/, {
216
+ error: e_1.message,
217
+ richError: encodeError(e_1),
218
+ }];
219
+ }
220
+ else if (typeof e_1 === 'string') {
221
+ return [2 /*return*/, { error: e_1 }];
222
+ }
223
+ else if (e_1 && typeof e_1 === 'object') {
224
+ return [2 /*return*/, { error: e_1 }];
225
+ }
226
+ else {
227
+ throw e_1;
228
+ }
229
+ return [3 /*break*/, 3];
230
+ case 3: return [2 /*return*/];
231
+ }
232
+ });
233
+ });
234
+ };
235
+ /**
236
+ * @returns {Object|undefined} The parsed message body, or undefined if the
237
+ * message isn't valid.
238
+ */
239
+ MessageChannel.prototype.parseMessage = function (message) {
240
+ if (message.source !== this.other) {
241
+ return; // wrong source
242
+ }
243
+ if (!this._isValidOrigin(message.origin)) {
244
+ return; // wrong origin
245
+ }
246
+ var rawMessageData = message.data;
247
+ if (!rawMessageData) {
248
+ return; // no data in message
249
+ }
250
+ if (typeof rawMessageData !== 'string') {
251
+ return; // unexpected data format in message
252
+ }
253
+ var messageData;
254
+ try {
255
+ messageData = JSON.parse(rawMessageData);
256
+ }
257
+ catch (err) {
258
+ return; // could not parse data
259
+ }
260
+ if (typeof messageData !== 'object') {
261
+ return; // unexpected data format in parsed message
262
+ }
263
+ if (!messageData) {
264
+ return; // unexpected data format in parsed message
265
+ }
266
+ if ('name' in messageData === false) {
267
+ return; // no message name found
268
+ }
269
+ return messageData;
270
+ };
271
+ MessageChannel.prototype._isValidOrigin = function (origin) {
272
+ // Plugins can (and should) be sandboxed, which means they have no origin
273
+ // (or, more accurately, "a special origin that always fails the
274
+ // same-origin policy" -- Chrome uses the string "null"). To allow
275
+ // cross-window communication anyway, don't check the origin. (Callers
276
+ // should always being verifying the source of the message as well.)
277
+ if (this.otherOrigin === null)
278
+ return true;
279
+ return origin === this.otherOrigin;
280
+ };
281
+ MessageChannel.prototype._sendResponse = function (originalMessage, result) {
282
+ var name = originalMessage.name.includes('.')
283
+ ? originalMessage.name.split('.')[1]
284
+ : originalMessage.name;
285
+ var messageObject = Object.assign({}, result, {
286
+ name: "".concat(this.name, ".").concat(name),
287
+ id: originalMessage.id || "".concat(this.name, ".").concat(this._getMessageId()),
288
+ instanceID: this.instanceId,
289
+ });
290
+ var message = JSON.stringify(messageObject);
291
+ this._postMessage(message);
292
+ };
293
+ /**
294
+ * Find the right handler for a message and call it, returning the handler's
295
+ * return value.
296
+ *
297
+ * This is a very simple function but is on its own because the plugin client
298
+ * calls it directly for init messages (pretending that the host has sent an
299
+ * init message, when actually the client starts sends the init event).
300
+ *
301
+ * @param {string} name - The message name, the key on which dispatch is
302
+ * based.
303
+ *
304
+ * @param {Object} data - The data to be passed to the correct handler.
305
+ *
306
+ * @returns The handler's return value
307
+ */
308
+ MessageChannel.prototype.dispatchMessage = function (name, data) {
309
+ return __awaiter(this, void 0, void 0, function () {
310
+ var handler;
311
+ return __generator(this, function (_a) {
312
+ switch (_a.label) {
313
+ case 0:
314
+ handler = this.getHandler(name);
315
+ if (!handler) {
316
+ throw new Error("No handlers found for message '".concat(name, "'."));
317
+ }
318
+ return [4 /*yield*/, handler(data)];
319
+ case 1: return [2 /*return*/, _a.sent()];
320
+ }
321
+ });
322
+ });
323
+ };
324
+ /**
325
+ * Find the right handler for a message, using its name.
326
+ *
327
+ * @param {string} name - The message name, the key on which dispatch is
328
+ * based.
329
+ *
330
+ * @returns {function | undefined} The correct handler function, which should be
331
+ * invoked with the message data. May return undefined, if there is no matching
332
+ * handler.
333
+ */
334
+ MessageChannel.prototype.getHandler = function (name) {
335
+ // Some components (e.g. credential selector) route messages with full
336
+ // names. The manager and client, though, use the non-prefixed names. Try
337
+ // both, starting with the full name.
338
+ if (name in this.handlers) {
339
+ return this.handlers[name];
340
+ }
341
+ // No matches with the full name. Try the short name, cutting off the
342
+ // prefix.
343
+ var prefixEnd = name.indexOf('.');
344
+ if (prefixEnd !== -1) {
345
+ var shortName = name.slice(prefixEnd + 1);
346
+ if (shortName in this.handlers) {
347
+ return this.handlers[shortName];
348
+ }
349
+ }
350
+ return;
351
+ };
352
+ MessageChannel.prototype._resolvePromise = function (id, data) {
353
+ if (id in this.pendingMessages === false) {
354
+ throw new Error("Tried to resolve unknown pending message ".concat(id));
355
+ }
356
+ var messageController = this.pendingMessages[id];
357
+ delete this.pendingMessages[id];
358
+ if (isEncodedError(data.richError)) {
359
+ messageController.reject(decodeError(data.richError));
360
+ }
361
+ if (data.error) {
362
+ if (typeof data.error === 'string') {
363
+ messageController.reject(new Error(data.error));
364
+ }
365
+ else {
366
+ messageController.reject(data.error);
367
+ }
368
+ return;
369
+ }
370
+ messageController.resolve(data.result);
371
+ };
372
+ MessageChannel.prototype._getMessageId = function () {
373
+ return this.nextMessageId++;
374
+ };
375
+ MessageChannel.prototype._postMessage = function (message) {
376
+ this.other.postMessage(message, this._getTargetOrigin());
377
+ };
378
+ MessageChannel.prototype._getTargetOrigin = function () {
379
+ // If we're communicating with a sandboxed plugin (i.e. the otherOrigin is
380
+ // null), we must send the message with a target origin of '*', indicating
381
+ // no preference.
382
+ if (this.otherOrigin === null) {
383
+ return '*';
384
+ }
385
+ return this.otherOrigin;
386
+ };
387
+ return MessageChannel;
388
+ }());
389
+ export default MessageChannel;
390
+ //# sourceMappingURL=messageChannel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messageChannel.js","sourceRoot":"","sources":["../../../../../plugin-sdk/src/lib/messages/messageChannel.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAC,QAAQ,EAAC,uBAAqB;AACtC,OAAO,EAAC,WAAW,EAAgB,WAAW,EAAE,cAAc,EAAC,6BAA2B;AAE1F,OAAO,EAAC,UAAU,EAAC,oBAAkB;AAErC,IAAM,YAAY,GAAG,KAAK,CAAA;AAmB1B;;;;;;;;;;GAUG;AACH;IAWE;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,wBACE,MAMM;QANN,uBAAA,EAAA,WAMM;QAGJ,IAAA,KAKE,MAAM,KALQ,EAAhB,IAAI,mBAAG,SAAS,KAAA,EAChB,KAIE,MAAM,MAJ2B,EAAnC,KAAK,mBAAG,MAA2B,KAAA,EACnC,KAGE,MAAM,YAHQ,EAAhB,WAAW,mBAAG,EAAE,KAAA,EAChB,KAEE,MAAM,SAFK,EAAb,QAAQ,mBAAG,EAAE,KAAA,EACb,UAAU,GACR,MAAM,WADE,CACF;QACV,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAE5B,IAAI,CAAC,eAAe,GAAG,E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AG,CAAA;QACZ,CAAC;QACD,OAAO,IAAI,CAAC,WAAW,CAAA;IACzB,CAAC;IACH,qBAAC;AAAD,CAAC,AA5WD,IA4WC;AAED,eAAe,cAAc,CAAA"}
@@ -0,0 +1 @@
1
+ export declare const getClientVersion: () => string;
@@ -0,0 +1,3 @@
1
+ // Provide configuration that is supplied at build time.
2
+ export var getClientVersion = function () { return "1.9.0-rc.1922.6ed97d"; };
3
+ //# sourceMappingURL=buildConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildConfig.js","sourceRoot":"","sources":["../../../../../plugin-sdk/src/lib/plugin/buildConfig.ts"],"names":[],"mappings":"AAAA,wDAAwD;AAIxD,MAAM,CAAC,IAAM,gBAAgB,GAAG,8CAA2C,CAAA"}
@@ -0,0 +1,3 @@
1
+ export { default } from "./pluginClient";
2
+ export { Context, FetchResponse, MessageData } from "../../models";
3
+ export { Handler as PluginClientHandler, Handler } from "./models";
@@ -0,0 +1,4 @@
1
+ export { default } from "./pluginClient";
2
+ export { MessageData } from "../../models";
3
+ export { Handler as PluginClientHandler, Handler } from "./models";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../plugin-sdk/src/lib/plugin/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,uBAA4B;AAE5C,OAAO,EAAyB,WAAW,EAAC,qBAAmB;AAE/D,OAAO,EAAC,OAAO,IAAI,mBAAmB,EAAE,OAAO,EAAC,iBAAsB"}
@@ -0,0 +1,13 @@
1
+ import * as t from 'io-ts';
2
+ import { MessageData } from "../../models";
3
+ import PluginClient from "./pluginClient";
4
+ /**
5
+ * Plugin handlers called on messages from host.
6
+ */
7
+ export type Handler = (m: MessageData, p: PluginClient) => MessageData;
8
+ export declare const Handler: t.Type<Handler, Handler, unknown>;
9
+ /**
10
+ * Object defining Plugin's handlers
11
+ */
12
+ export type PluginClientHandlerCollection = Record<string, Handler>;
13
+ export declare const PluginClientHandlerCollection: t.RecordC<t.StringC, t.Type<Handler, Handler, unknown>>;
@@ -0,0 +1,9 @@
1
+ import * as t from 'io-ts';
2
+ import { BaseHandler } from "../../models";
3
+ import { createCodec } from "../../modelUtils";
4
+ import PluginClient from "./pluginClient";
5
+ export var Handler = createCodec('Handler', function (h) {
6
+ return BaseHandler.is(h);
7
+ });
8
+ export var PluginClientHandlerCollection = t.record(t.string, Handler);
9
+ //# sourceMappingURL=models.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.js","sourceRoot":"","sources":["../../../../../plugin-sdk/src/lib/plugin/models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,OAAO,CAAA;AAE1B,OAAO,EAAC,WAAW,EAAc,qBAAmB;AACpD,OAAO,EAAC,WAAW,EAAC,yBAAuB;AAC3C,OAAO,YAAY,uBAA4B;AAO/C,MAAM,CAAC,IAAM,OAAO,GAAG,WAAW,CAAC,SAAS,EAAE,UAAC,CAAU;IACvD,OAAO,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;AAC1B,CAAC,CAAC,CAAA;AAOF,MAAM,CAAC,IAAM,6BAA6B,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA"}