@adobe/uix-guest 0.6.5-0 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,8 +1,13 @@
1
1
  var AdobeUIXGuest = (() => {
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJS = (cb, mod) => function __require() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
6
11
  var __export = (target, all) => {
7
12
  for (var name in all)
8
13
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -15,8 +20,271 @@ var AdobeUIXGuest = (() => {
15
20
  }
16
21
  return to;
17
22
  };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
18
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
28
 
29
+ // ../uix-core/dist/index.js
30
+ var require_dist = __commonJS({
31
+ "../uix-core/dist/index.js"(exports) {
32
+ "use strict";
33
+ var isDarkMode = () => typeof window.matchMedia === "function" && window.matchMedia("(prefers-color-scheme: dark)").matches;
34
+ var Layouts = {
35
+ medium: {
36
+ padX: 5,
37
+ padY: 3,
38
+ rounded: 4,
39
+ fontSize: 100,
40
+ emphasis: "font-weight: bold;"
41
+ },
42
+ small: {
43
+ padX: 3,
44
+ padY: 1,
45
+ rounded: 2,
46
+ fontSize: 95,
47
+ emphasis: "font-style: italic;"
48
+ }
49
+ };
50
+ var Colors = {
51
+ yellow: {
52
+ text: "#333333",
53
+ bg: "#EBD932",
54
+ hilight: "#F7E434",
55
+ shadow: "#D1C12C"
56
+ },
57
+ green: {
58
+ text: "#333333",
59
+ bg: "#96EB5E",
60
+ hilight: "#9EF763",
61
+ shadow: "#85D154"
62
+ },
63
+ blue: {
64
+ text: "#333333",
65
+ bg: "#8DD0EB",
66
+ hilight: "#88F0F7",
67
+ shadow: "#74AED4"
68
+ },
69
+ gray: isDarkMode() ? {
70
+ text: "#eeeeee",
71
+ bg: "transparent",
72
+ hilight: "#cecece",
73
+ shadow: "#cecece"
74
+ } : {
75
+ text: "#333333",
76
+ bg: "#eeeeee",
77
+ hilight: "#f6f6f6",
78
+ shadow: "#cecece"
79
+ }
80
+ };
81
+ function memoizeUnary(fn) {
82
+ const cache = /* @__PURE__ */ new Map();
83
+ return (arg) => {
84
+ if (!cache.has(arg)) {
85
+ const result = fn(arg);
86
+ cache.set(arg, result);
87
+ if (cache.size > 100) {
88
+ cache.delete(cache.keys().next().value);
89
+ }
90
+ return result;
91
+ }
92
+ return cache.get(arg);
93
+ };
94
+ }
95
+ var toTheme = memoizeUnary((theme) => {
96
+ if (typeof theme === "string") {
97
+ const [color, size] = theme.split(" ");
98
+ return {
99
+ ...Colors[color],
100
+ ...Layouts[size]
101
+ };
102
+ }
103
+ return theme;
104
+ });
105
+ var block = `display: inline-block; border: 1px solid;`;
106
+ var flatten = (side) => `padding-${side}: 0px; border-${side}-width: 0px; border-top-${side}-radius: 0px; border-bottom-${side}-radius: 0px;`;
107
+ var toColor = ({ bg, hilight, shadow, text }) => `color: ${text}; background: ${bg}; border-color: ${hilight} ${shadow} ${shadow} ${hilight};`;
108
+ var toLayout = ({ fontSize, padY, padX, rounded }) => `font-size: ${fontSize}%; padding: ${padY}px ${padX}px; border-radius: ${rounded}px;`;
109
+ var toBubbleStyle = memoizeUnary((theme) => {
110
+ const base = `${block}${toColor(theme)}${toLayout(theme)}`;
111
+ return [
112
+ `${base}${flatten("right")}`,
113
+ `${base}${flatten("left")}${theme.emphasis}`
114
+ ];
115
+ });
116
+ function toBubblePrepender(bubbleLeft, bubbleRight, theme) {
117
+ const prefix = `%c${bubbleLeft}%c ${bubbleRight}`;
118
+ const [left, right] = toBubbleStyle(theme);
119
+ return (args) => {
120
+ const bubbleArgs = [prefix, left, right];
121
+ if (typeof args[0] === "string") {
122
+ bubbleArgs[0] = `${prefix}%c ${args.shift()}`;
123
+ bubbleArgs.push("");
124
+ }
125
+ return [...bubbleArgs, ...args];
126
+ };
127
+ }
128
+ var stateTypes = {
129
+ event: "\uFE0F\u26A1\uFE0F"
130
+ };
131
+ var stateDelim = " \u293B ";
132
+ var getStateFormatter = memoizeUnary((stateJson) => {
133
+ const stateStack = JSON.parse(stateJson);
134
+ const firstState = stateStack.shift();
135
+ const left = stateTypes[firstState.type];
136
+ const right = [
137
+ firstState.name,
138
+ ...stateStack.map((state) => `${stateTypes[state.type]} ${state.name}`)
139
+ ].join(stateDelim);
140
+ return toBubblePrepender(left, right, toTheme("gray small"));
141
+ });
142
+ var getStatePrepender = (stateStack) => getStateFormatter(JSON.stringify(stateStack));
143
+ var overrideMethods = ["log", "error", "warn", "info", "debug"];
144
+ var identity = (x) => x;
145
+ var noop = () => void 0;
146
+ function _customConsole(theme, type, name) {
147
+ const prepender = toBubblePrepender(`X${type}`, name, toTheme(theme));
148
+ let statePrepender = identity;
149
+ const stateStack = [];
150
+ const loggerProto = {
151
+ detach: {
152
+ writable: true,
153
+ configurable: true,
154
+ value() {
155
+ overrideMethods.forEach((method) => {
156
+ this[method] = noop;
157
+ });
158
+ }
159
+ },
160
+ pushState: {
161
+ value(state) {
162
+ stateStack.push(state);
163
+ statePrepender = getStatePrepender(stateStack);
164
+ }
165
+ },
166
+ popState: {
167
+ value() {
168
+ stateStack.pop();
169
+ statePrepender = stateStack.length === 0 ? identity : getStatePrepender(stateStack);
170
+ }
171
+ }
172
+ };
173
+ const customConsole = Object.create(
174
+ console,
175
+ overrideMethods.reduce((out, level) => {
176
+ out[level] = {
177
+ writable: true,
178
+ configurable: true,
179
+ value(...args) {
180
+ console[level](...prepender(statePrepender(args)));
181
+ }
182
+ };
183
+ return out;
184
+ }, loggerProto)
185
+ );
186
+ return customConsole;
187
+ }
188
+ var quietConsole2 = new Proxy(console, {
189
+ get() {
190
+ return noop;
191
+ }
192
+ });
193
+ function debugEmitter2(emitter, opts) {
194
+ const logger = _customConsole(
195
+ opts.theme,
196
+ opts.type || Object.getPrototypeOf(emitter).constructor.name,
197
+ opts.id || emitter.id
198
+ );
199
+ const oldDispatch = emitter.dispatchEvent;
200
+ emitter.dispatchEvent = (event) => {
201
+ logger.pushState({ type: "event", name: event.type });
202
+ const retVal = oldDispatch.call(emitter, event);
203
+ logger.popState();
204
+ return retVal;
205
+ };
206
+ const subscriptions = [];
207
+ const oldDetach = logger.detach;
208
+ logger.detach = () => {
209
+ oldDetach.call(logger);
210
+ subscriptions.forEach((unsubscribe) => unsubscribe());
211
+ };
212
+ function listen(type, listener) {
213
+ subscriptions.push(
214
+ emitter.addEventListener(type, (event) => listener(logger, event))
215
+ );
216
+ return logger;
217
+ }
218
+ logger.listen = listen;
219
+ return logger;
220
+ }
221
+ var Emitter2 = class extends EventTarget {
222
+ constructor(id2) {
223
+ super();
224
+ this.id = id2;
225
+ }
226
+ emit(type, detail) {
227
+ const event = new CustomEvent(type, { detail });
228
+ this.dispatchEvent(event);
229
+ }
230
+ addEventListener(type, listener) {
231
+ super.addEventListener(type, listener);
232
+ return () => super.removeEventListener(type, listener);
233
+ }
234
+ };
235
+ function makeNamespaceProxy2(invoke, path = []) {
236
+ const handler = {
237
+ get: (target2, prop) => {
238
+ if (typeof prop === "string") {
239
+ if (!Reflect.has(target2, prop)) {
240
+ const next = makeNamespaceProxy2(invoke, path.concat(prop));
241
+ Reflect.set(target2, prop, next);
242
+ }
243
+ return Reflect.get(target2, prop);
244
+ } else {
245
+ throw new Error(
246
+ `Cannot look up a symbol ${String(prop)} on a host connection proxy.`
247
+ );
248
+ }
249
+ }
250
+ };
251
+ const target = {};
252
+ if (path.length < 2) {
253
+ return new Proxy(target, handler);
254
+ }
255
+ const invoker = (...args) => invoke({
256
+ path: path.slice(0, -1),
257
+ name: path[path.length - 1],
258
+ args
259
+ });
260
+ return new Proxy(invoker, {
261
+ ...handler,
262
+ apply(target2, _, args) {
263
+ return target2(...args);
264
+ }
265
+ });
266
+ }
267
+ function timeoutPromise2(timeoutMs, promise) {
268
+ return new Promise((resolve, reject) => {
269
+ const timeout = setTimeout(
270
+ () => reject(new Error(`Timed out after ${timeoutMs}ms`)),
271
+ timeoutMs
272
+ );
273
+ promise.then((result) => {
274
+ clearTimeout(timeout);
275
+ resolve(result);
276
+ }).catch(reject);
277
+ });
278
+ }
279
+ exports.Emitter = Emitter2;
280
+ exports._customConsole = _customConsole;
281
+ exports.debugEmitter = debugEmitter2;
282
+ exports.makeNamespaceProxy = makeNamespaceProxy2;
283
+ exports.quietConsole = quietConsole2;
284
+ exports.timeoutPromise = timeoutPromise2;
285
+ }
286
+ });
287
+
20
288
  // src/index.ts
21
289
  var src_exports = {};
22
290
  __export(src_exports, {
@@ -373,257 +641,13 @@ var AdobeUIXGuest = (() => {
373
641
  };
374
642
  };
375
643
 
376
- // ../uix-core/dist/esm/index.js
377
- var isDarkMode = () => typeof window.matchMedia === "function" && window.matchMedia("(prefers-color-scheme: dark)").matches;
378
- var Layouts = {
379
- medium: {
380
- padX: 5,
381
- padY: 3,
382
- rounded: 4,
383
- fontSize: 100,
384
- emphasis: "font-weight: bold;"
385
- },
386
- small: {
387
- padX: 3,
388
- padY: 1,
389
- rounded: 2,
390
- fontSize: 95,
391
- emphasis: "font-style: italic;"
392
- }
393
- };
394
- var Colors = {
395
- yellow: {
396
- text: "#333333",
397
- bg: "#EBD932",
398
- hilight: "#F7E434",
399
- shadow: "#D1C12C"
400
- },
401
- green: {
402
- text: "#333333",
403
- bg: "#96EB5E",
404
- hilight: "#9EF763",
405
- shadow: "#85D154"
406
- },
407
- blue: {
408
- text: "#333333",
409
- bg: "#8DD0EB",
410
- hilight: "#88F0F7",
411
- shadow: "#74AED4"
412
- },
413
- gray: isDarkMode() ? {
414
- text: "#eeeeee",
415
- bg: "transparent",
416
- hilight: "#cecece",
417
- shadow: "#cecece"
418
- } : {
419
- text: "#333333",
420
- bg: "#eeeeee",
421
- hilight: "#f6f6f6",
422
- shadow: "#cecece"
423
- }
424
- };
425
- function memoizeUnary(fn) {
426
- const cache = /* @__PURE__ */ new Map();
427
- return (arg) => {
428
- if (!cache.has(arg)) {
429
- const result = fn(arg);
430
- cache.set(arg, result);
431
- if (cache.size > 100) {
432
- cache.delete(cache.keys().next().value);
433
- }
434
- return result;
435
- }
436
- return cache.get(arg);
437
- };
438
- }
439
- var toTheme = memoizeUnary((theme) => {
440
- if (typeof theme === "string") {
441
- const [color, size] = theme.split(" ");
442
- return {
443
- ...Colors[color],
444
- ...Layouts[size]
445
- };
446
- }
447
- return theme;
448
- });
449
- var block = `display: inline-block; border: 1px solid;`;
450
- var flatten = (side) => `padding-${side}: 0px; border-${side}-width: 0px; border-top-${side}-radius: 0px; border-bottom-${side}-radius: 0px;`;
451
- var toColor = ({ bg, hilight, shadow, text }) => `color: ${text}; background: ${bg}; border-color: ${hilight} ${shadow} ${shadow} ${hilight};`;
452
- var toLayout = ({ fontSize, padY, padX, rounded }) => `font-size: ${fontSize}%; padding: ${padY}px ${padX}px; border-radius: ${rounded}px;`;
453
- var toBubbleStyle = memoizeUnary((theme) => {
454
- const base = `${block}${toColor(theme)}${toLayout(theme)}`;
455
- return [
456
- `${base}${flatten("right")}`,
457
- `${base}${flatten("left")}${theme.emphasis}`
458
- ];
459
- });
460
- function toBubblePrepender(bubbleLeft, bubbleRight, theme) {
461
- const prefix = `%c${bubbleLeft}%c ${bubbleRight}`;
462
- const [left, right] = toBubbleStyle(theme);
463
- return (args) => {
464
- const bubbleArgs = [prefix, left, right];
465
- if (typeof args[0] === "string") {
466
- bubbleArgs[0] = `${prefix}%c ${args.shift()}`;
467
- bubbleArgs.push("");
468
- }
469
- return [...bubbleArgs, ...args];
470
- };
471
- }
472
- var stateTypes = {
473
- event: "\uFE0F\u26A1\uFE0F"
474
- };
475
- var stateDelim = " \u293B ";
476
- var getStateFormatter = memoizeUnary((stateJson) => {
477
- const stateStack = JSON.parse(stateJson);
478
- const firstState = stateStack.shift();
479
- const left = stateTypes[firstState.type];
480
- const right = [
481
- firstState.name,
482
- ...stateStack.map((state) => `${stateTypes[state.type]} ${state.name}`)
483
- ].join(stateDelim);
484
- return toBubblePrepender(left, right, toTheme("gray small"));
485
- });
486
- var getStatePrepender = (stateStack) => getStateFormatter(JSON.stringify(stateStack));
487
- var overrideMethods = ["log", "error", "warn", "info", "debug"];
488
- var identity = (x) => x;
489
- var noop = () => void 0;
490
- function _customConsole(theme, type, name) {
491
- const prepender = toBubblePrepender(`X${type}`, name, toTheme(theme));
492
- let statePrepender = identity;
493
- const stateStack = [];
494
- const loggerProto = {
495
- detach: {
496
- writable: true,
497
- configurable: true,
498
- value() {
499
- overrideMethods.forEach((method) => {
500
- this[method] = noop;
501
- });
502
- }
503
- },
504
- pushState: {
505
- value(state) {
506
- stateStack.push(state);
507
- statePrepender = getStatePrepender(stateStack);
508
- }
509
- },
510
- popState: {
511
- value() {
512
- stateStack.pop();
513
- statePrepender = stateStack.length === 0 ? identity : getStatePrepender(stateStack);
514
- }
515
- }
516
- };
517
- const customConsole = Object.create(
518
- console,
519
- overrideMethods.reduce((out, level) => {
520
- out[level] = {
521
- writable: true,
522
- configurable: true,
523
- value(...args) {
524
- console[level](...prepender(statePrepender(args)));
525
- }
526
- };
527
- return out;
528
- }, loggerProto)
529
- );
530
- return customConsole;
531
- }
532
- var quietConsole = new Proxy(console, {
533
- get() {
534
- return noop;
535
- }
536
- });
537
- function debugEmitter(emitter, opts) {
538
- const logger = _customConsole(
539
- opts.theme,
540
- opts.type || Object.getPrototypeOf(emitter).constructor.name,
541
- opts.id || emitter.id
542
- );
543
- const oldDispatch = emitter.dispatchEvent;
544
- emitter.dispatchEvent = (event) => {
545
- logger.pushState({ type: "event", name: event.type });
546
- const retVal = oldDispatch.call(emitter, event);
547
- logger.popState();
548
- return retVal;
549
- };
550
- const subscriptions = [];
551
- const oldDetach = logger.detach;
552
- logger.detach = () => {
553
- oldDetach.call(logger);
554
- subscriptions.forEach((unsubscribe) => unsubscribe());
555
- };
556
- function listen(type, listener) {
557
- subscriptions.push(
558
- emitter.addEventListener(type, (event) => listener(logger, event))
559
- );
560
- return logger;
561
- }
562
- logger.listen = listen;
563
- return logger;
564
- }
565
- var Emitter = class extends EventTarget {
566
- constructor(id2) {
567
- super();
568
- this.id = id2;
569
- }
570
- emit(type, detail) {
571
- const event = new CustomEvent(type, { detail });
572
- this.dispatchEvent(event);
573
- }
574
- addEventListener(type, listener) {
575
- super.addEventListener(type, listener);
576
- return () => super.removeEventListener(type, listener);
577
- }
578
- };
579
- function makeNamespaceProxy(invoke, path = []) {
580
- const handler = {
581
- get: (target2, prop) => {
582
- if (typeof prop === "string") {
583
- if (!Reflect.has(target2, prop)) {
584
- const next = makeNamespaceProxy(invoke, path.concat(prop));
585
- Reflect.set(target2, prop, next);
586
- }
587
- return Reflect.get(target2, prop);
588
- } else {
589
- throw new Error(
590
- `Cannot look up a symbol ${String(prop)} on a host connection proxy.`
591
- );
592
- }
593
- }
594
- };
595
- const target = {};
596
- if (path.length < 2) {
597
- return new Proxy(target, handler);
598
- }
599
- const invoker = (...args) => invoke({
600
- path: path.slice(0, -1),
601
- name: path[path.length - 1],
602
- args
603
- });
604
- return new Proxy(invoker, {
605
- ...handler,
606
- apply(target2, _, args) {
607
- return target2(...args);
608
- }
609
- });
610
- }
611
- function timeoutPromise(timeoutMs, promise) {
612
- return new Promise((resolve, reject) => {
613
- const timeout = setTimeout(
614
- () => reject(new Error(`Timed out after ${timeoutMs}ms`)),
615
- timeoutMs
616
- );
617
- promise.then((result) => {
618
- clearTimeout(timeout);
619
- resolve(result);
620
- }).catch(reject);
621
- });
622
- }
644
+ // src/guest.ts
645
+ var import_uix_core2 = __toESM(require_dist());
623
646
 
624
647
  // src/debug-guest.ts
648
+ var import_uix_core = __toESM(require_dist());
625
649
  function debugGuest(guest) {
626
- return debugEmitter(guest, {
650
+ return (0, import_uix_core.debugEmitter)(guest, {
627
651
  theme: "yellow medium",
628
652
  type: "Guest"
629
653
  }).listen("beforeconnect", (log, { detail: { guest: guest2 } }) => {
@@ -654,15 +678,15 @@ var AdobeUIXGuest = (() => {
654
678
  return this._map.get(key);
655
679
  }
656
680
  };
657
- var Guest2 = class extends Emitter {
681
+ var Guest2 = class extends import_uix_core2.Emitter {
658
682
  constructor(config) {
659
683
  super(config.id);
660
- this.debugLogger = quietConsole;
661
- this.host = makeNamespaceProxy(
684
+ this.debugLogger = import_uix_core2.quietConsole;
685
+ this.host = (0, import_uix_core2.makeNamespaceProxy)(
662
686
  async (address) => {
663
687
  await this.hostConnectionPromise;
664
688
  try {
665
- const result = await timeoutPromise(
689
+ const result = await (0, import_uix_core2.timeoutPromise)(
666
690
  1e4,
667
691
  this.hostConnection.invokeHostMethod(address)
668
692
  );
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts","../../../../node_modules/penpal/lib/enums.js","../../../../node_modules/penpal/lib/createDestructor.js","../../../../node_modules/penpal/lib/createLogger.js","../../../../node_modules/penpal/lib/errorSerialization.js","../../../../node_modules/penpal/lib/connectCallReceiver.js","../../../../node_modules/penpal/lib/generateId.js","../../../../node_modules/penpal/lib/methodSerialization.js","../../../../node_modules/penpal/lib/connectCallSender.js","../../../../node_modules/penpal/lib/startConnectionTimeout.js","../../../../node_modules/penpal/lib/child/handleSynAckMessageFactory.js","../../../../node_modules/penpal/lib/child/connectToParent.js","../../../uix-core/src/debuglog.ts","../../../uix-core/src/debug-emitter.ts","../../../uix-core/src/emitter.ts","../../../uix-core/src/namespace-proxy.ts","../../../uix-core/src/timeout-promise.ts","../../src/debug-guest.ts","../../src/guest.ts","../../src/guest-ui.ts","../../src/guest-server.ts"],"sourcesContent":["/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\n/**\n * @packageDocumentation\n * Tools for UI Extensions meant to run inside extensible apps. Connects\n * Extensions running in their own window contexts with the host app, allowing\n * the host and guest to exchange method, events, and signals.\n *\n * @remarks The core object of this library, which extensions use for\n * communication, is the Guest object. There are two variants of the Guest\n * object {@link GuestServer} for the bootstrap frame which your extension keeps\n * running in the background, and {@link GuestUI} for frames meant to be\n * displayed in the host application. An extension must have one GuestServer\n * frame, and the host app may choose to use one or more GuestUI frames.\n *\n * @example Creating and connecting a GuestServer with {@link register}\n * ```typescript\n * import { register } from \"@adobe/uix-guest\";\n *\n * const server = await register({\n * // Must match extension ID from registry\n * id: \"My Custom View Extension\",\n * // enable logging in dev build\n * debug: process.env.NODE_ENV !== \"production\",\n * // Host can access these methods from its Port to this guest\n * methods: {\n * // Methods must be namespaced by one or more levels\n * myCustomView: {\n * async documentIsViewable(docId) {\n * const doc = await callMyRuntimeAction(docId);\n * return someValidation(doc);\n * },\n * renderView(docId, depth) {\n * // Use a host method\n * const tooltip = await server.host.editor.requestTooltip({\n * type: 'frame',\n * url: new URL(`/show/${docId}`, location).href\n * })\n * }\n * },\n * },\n * })\n * ```\n *\n * @example Connecting to an existing GuestServer with a GuestUI\n * ```typescript\n * import { attach } from \"@adobe/uix-guest\";\n *\n * const ui = await attach({\n * id: \"My Custom View Extension\",\n * })\n *\n * // when editing is done:\n * const saved = await ui.host.editor.saveChanges();\n * if (!saved) {\n * const editorState = ui.sharedContext.get('editorState');\n * if (editorState.tooltips[ui.id].invalid === true) {\n * putGuestUIInInvalidState();\n * }\n * } else {\n * ui.host.editor.dismissTooltip();\n * }\n * ```\n *\n */\nimport type { Guest, GuestConfig } from \"./guest.js\";\nimport { GuestUI } from \"./guest-ui.js\";\nimport { GuestServer } from \"./guest-server.js\";\nimport { GuestApis } from \"@adobe/uix-core\";\n\n/**\n * {@inheritdoc GuestConfig}\n * @public\n */\ntype GuestConfigWithMethods<Outgoing extends GuestApis> = GuestConfig & {\n methods: Outgoing;\n};\n\n/**\n * Create and immediately return a {@link GuestServer}.\n *\n * @deprecated Use {@link attach} or {@link register}, which return Promises\n * that resolve once the guest is connected.\n * @public\n */\nexport function createGuest(config: GuestConfig) {\n const guest = new GuestServer(config);\n return guest;\n}\n\n/**\n * Connect to a running {@link GuestServer} to share its context and render UI.\n *\n * @remarks Creates a guest object that shares most of the GuestServer API,\n * except it cannot register its own methods. Use `attach()` in an app or\n * document that is meant to render a UI in the host application; it will have\n * access to the sharedContext object shared by the host and GuestServer.\n *\n * @public\n */\nexport async function attach(config: GuestConfig) {\n const guest = new GuestUI(config);\n await guest._connect();\n return guest;\n}\n\n/**\n * Initiate a connection to the host app and its extension points.\n *\n * @remarks Creates the \"main\" {@link GuestServer}, which runs in the background\n * without UI. Registers methods passed in the `methods` parameter, then\n * resolves the returned Promise with the connected GuestServer object.\n *\n * @public\n */\nexport async function register<Outgoing extends GuestApis>(\n config: GuestConfigWithMethods<Outgoing>\n) {\n const guest = new GuestServer(config);\n await guest.register(config.methods);\n return guest;\n}\n\n// backwards compatibility\nexport {\n Guest,\n Guest as BaseGuest,\n GuestUI,\n GuestUI as UIGuest,\n GuestServer,\n GuestServer as PrimaryGuest,\n};\n","export var MessageType;\n(function (MessageType) {\n MessageType[\"Call\"] = \"call\";\n MessageType[\"Reply\"] = \"reply\";\n MessageType[\"Syn\"] = \"syn\";\n MessageType[\"SynAck\"] = \"synAck\";\n MessageType[\"Ack\"] = \"ack\";\n})(MessageType || (MessageType = {}));\nexport var Resolution;\n(function (Resolution) {\n Resolution[\"Fulfilled\"] = \"fulfilled\";\n Resolution[\"Rejected\"] = \"rejected\";\n})(Resolution || (Resolution = {}));\nexport var ErrorCode;\n(function (ErrorCode) {\n ErrorCode[\"ConnectionDestroyed\"] = \"ConnectionDestroyed\";\n ErrorCode[\"ConnectionTimeout\"] = \"ConnectionTimeout\";\n ErrorCode[\"NoIframeSrc\"] = \"NoIframeSrc\";\n})(ErrorCode || (ErrorCode = {}));\nexport var NativeErrorName;\n(function (NativeErrorName) {\n NativeErrorName[\"DataCloneError\"] = \"DataCloneError\";\n})(NativeErrorName || (NativeErrorName = {}));\nexport var NativeEventType;\n(function (NativeEventType) {\n NativeEventType[\"Message\"] = \"message\";\n})(NativeEventType || (NativeEventType = {}));\n","export default (localName, log) => {\n const callbacks = [];\n let destroyed = false;\n return {\n destroy(error) {\n if (!destroyed) {\n destroyed = true;\n log(`${localName}: Destroying connection`);\n callbacks.forEach((callback) => {\n callback(error);\n });\n }\n },\n onDestroy(callback) {\n destroyed ? callback() : callbacks.push(callback);\n },\n };\n};\n","export default (debug) => {\n /**\n * Logs a message if debug is enabled.\n */\n return (...args) => {\n if (debug) {\n console.log('[Penpal]', ...args); // eslint-disable-line no-console\n }\n };\n};\n","/**\n * Converts an error object into a plain object.\n */\nexport const serializeError = ({ name, message, stack, }) => ({\n name,\n message,\n stack,\n});\n/**\n * Converts a plain object into an error object.\n */\nexport const deserializeError = (obj) => {\n const deserializedError = new Error();\n // @ts-ignore\n Object.keys(obj).forEach((key) => (deserializedError[key] = obj[key]));\n return deserializedError;\n};\n","import { serializeError } from './errorSerialization';\nimport { MessageType, NativeEventType, NativeErrorName, Resolution, } from './enums';\n/**\n * Listens for \"call\" messages coming from the remote, executes the corresponding method, and\n * responds with the return value.\n */\nexport default (info, serializedMethods, log) => {\n const { localName, local, remote, originForSending, originForReceiving, } = info;\n let destroyed = false;\n const handleMessageEvent = (event) => {\n if (event.source !== remote || event.data.penpal !== MessageType.Call) {\n return;\n }\n if (originForReceiving !== '*' && event.origin !== originForReceiving) {\n log(`${localName} received message from origin ${event.origin} which did not match expected origin ${originForReceiving}`);\n return;\n }\n const callMessage = event.data;\n const { methodName, args, id } = callMessage;\n log(`${localName}: Received ${methodName}() call`);\n const createPromiseHandler = (resolution) => {\n return (returnValue) => {\n log(`${localName}: Sending ${methodName}() reply`);\n if (destroyed) {\n // It's possible to throw an error here, but it would need to be thrown asynchronously\n // and would only be catchable using window.onerror. This is because the consumer\n // is merely returning a value from their method and not calling any function\n // that they could wrap in a try-catch. Even if the consumer were to catch the error,\n // the value of doing so is questionable. Instead, we'll just log a message.\n log(`${localName}: Unable to send ${methodName}() reply due to destroyed connection`);\n return;\n }\n const message = {\n penpal: MessageType.Reply,\n id,\n resolution,\n returnValue,\n };\n if (resolution === Resolution.Rejected &&\n returnValue instanceof Error) {\n message.returnValue = serializeError(returnValue);\n message.returnValueIsError = true;\n }\n try {\n remote.postMessage(message, originForSending);\n }\n catch (err) {\n // If a consumer attempts to send an object that's not cloneable (e.g., window),\n // we want to ensure the receiver's promise gets rejected.\n if (err.name === NativeErrorName.DataCloneError) {\n const errorReplyMessage = {\n penpal: MessageType.Reply,\n id,\n resolution: Resolution.Rejected,\n returnValue: serializeError(err),\n returnValueIsError: true,\n };\n remote.postMessage(errorReplyMessage, originForSending);\n }\n throw err;\n }\n };\n };\n new Promise((resolve) => resolve(serializedMethods[methodName].apply(serializedMethods, args))).then(createPromiseHandler(Resolution.Fulfilled), createPromiseHandler(Resolution.Rejected));\n };\n local.addEventListener(NativeEventType.Message, handleMessageEvent);\n return () => {\n destroyed = true;\n local.removeEventListener(NativeEventType.Message, handleMessageEvent);\n };\n};\n","let id = 0;\n/**\n * @return {number} A unique ID (not universally unique)\n */\nexport default () => ++id;\n","const KEY_PATH_DELIMITER = '.';\nconst keyPathToSegments = (keyPath) => keyPath ? keyPath.split(KEY_PATH_DELIMITER) : [];\nconst segmentsToKeyPath = (segments) => segments.join(KEY_PATH_DELIMITER);\nconst createKeyPath = (key, prefix) => {\n const segments = keyPathToSegments(prefix || '');\n segments.push(key);\n return segmentsToKeyPath(segments);\n};\n/**\n * Given a `keyPath`, set it to be `value` on `subject`, creating any intermediate\n * objects along the way.\n *\n * @param {Object} subject The object on which to set value.\n * @param {string} keyPath The key path at which to set value.\n * @param {Object} value The value to store at the given key path.\n * @returns {Object} Updated subject.\n */\nexport const setAtKeyPath = (subject, keyPath, value) => {\n const segments = keyPathToSegments(keyPath);\n segments.reduce((prevSubject, key, idx) => {\n if (typeof prevSubject[key] === 'undefined') {\n prevSubject[key] = {};\n }\n if (idx === segments.length - 1) {\n prevSubject[key] = value;\n }\n return prevSubject[key];\n }, subject);\n return subject;\n};\n/**\n * Given a dictionary of (nested) keys to function, flatten them to a map\n * from key path to function.\n *\n * @param {Object} methods The (potentially nested) object to serialize.\n * @param {string} prefix A string with which to prefix entries. Typically not intended to be used by consumers.\n * @returns {Object} An map from key path in `methods` to functions.\n */\nexport const serializeMethods = (methods, prefix) => {\n const flattenedMethods = {};\n Object.keys(methods).forEach((key) => {\n const value = methods[key];\n const keyPath = createKeyPath(key, prefix);\n if (typeof value === 'object') {\n // Recurse into any nested children.\n Object.assign(flattenedMethods, serializeMethods(value, keyPath));\n }\n if (typeof value === 'function') {\n // If we've found a method, expose it.\n flattenedMethods[keyPath] = value;\n }\n });\n return flattenedMethods;\n};\n/**\n * Given a map of key paths to functions, unpack the key paths to an object.\n *\n * @param {Object} flattenedMethods A map of key paths to functions to unpack.\n * @returns {Object} A (potentially nested) map of functions.\n */\nexport const deserializeMethods = (flattenedMethods) => {\n const methods = {};\n for (const keyPath in flattenedMethods) {\n setAtKeyPath(methods, keyPath, flattenedMethods[keyPath]);\n }\n return methods;\n};\n","import generateId from './generateId';\nimport { deserializeError } from './errorSerialization';\nimport { deserializeMethods } from './methodSerialization';\nimport { ErrorCode, MessageType, NativeEventType, Resolution } from './enums';\n/**\n * Augments an object with methods that match those defined by the remote. When these methods are\n * called, a \"call\" message will be sent to the remote, the remote's corresponding method will be\n * executed, and the method's return value will be returned via a message.\n * @param {Object} callSender Sender object that should be augmented with methods.\n * @param {Object} info Information about the local and remote windows.\n * @param {Array} methodKeyPaths Key paths of methods available to be called on the remote.\n * @param {Promise} destructionPromise A promise resolved when destroy() is called on the penpal\n * connection.\n * @returns {Object} The call sender object with methods that may be called.\n */\nexport default (callSender, info, methodKeyPaths, destroyConnection, log) => {\n const { localName, local, remote, originForSending, originForReceiving, } = info;\n let destroyed = false;\n log(`${localName}: Connecting call sender`);\n const createMethodProxy = (methodName) => {\n return (...args) => {\n log(`${localName}: Sending ${methodName}() call`);\n // This handles the case where the iframe has been removed from the DOM\n // (and therefore its window closed), the consumer has not yet\n // called destroy(), and the user calls a method exposed by\n // the remote. We detect the iframe has been removed and force\n // a destroy() immediately so that the consumer sees the error saying\n // the connection has been destroyed. We wrap this check in a try catch\n // because Edge throws an \"Object expected\" error when accessing\n // contentWindow.closed on a contentWindow from an iframe that's been\n // removed from the DOM.\n let iframeRemoved;\n try {\n if (remote.closed) {\n iframeRemoved = true;\n }\n }\n catch (e) {\n iframeRemoved = true;\n }\n if (iframeRemoved) {\n destroyConnection();\n }\n if (destroyed) {\n const error = new Error(`Unable to send ${methodName}() call due ` + `to destroyed connection`);\n error.code = ErrorCode.ConnectionDestroyed;\n throw error;\n }\n return new Promise((resolve, reject) => {\n const id = generateId();\n const handleMessageEvent = (event) => {\n if (event.source !== remote ||\n event.data.penpal !== MessageType.Reply ||\n event.data.id !== id) {\n return;\n }\n if (originForReceiving !== '*' &&\n event.origin !== originForReceiving) {\n log(`${localName} received message from origin ${event.origin} which did not match expected origin ${originForReceiving}`);\n return;\n }\n const replyMessage = event.data;\n log(`${localName}: Received ${methodName}() reply`);\n local.removeEventListener(NativeEventType.Message, handleMessageEvent);\n let returnValue = replyMessage.returnValue;\n if (replyMessage.returnValueIsError) {\n returnValue = deserializeError(returnValue);\n }\n (replyMessage.resolution === Resolution.Fulfilled ? resolve : reject)(returnValue);\n };\n local.addEventListener(NativeEventType.Message, handleMessageEvent);\n const callMessage = {\n penpal: MessageType.Call,\n id,\n methodName,\n args,\n };\n remote.postMessage(callMessage, originForSending);\n });\n };\n };\n // Wrap each method in a proxy which sends it to the corresponding receiver.\n const flattenedMethods = methodKeyPaths.reduce((api, name) => {\n api[name] = createMethodProxy(name);\n return api;\n }, {});\n // Unpack the structure of the provided methods object onto the CallSender, exposing\n // the methods in the same shape they were provided.\n Object.assign(callSender, deserializeMethods(flattenedMethods));\n return () => {\n destroyed = true;\n };\n};\n","import { ErrorCode } from './enums';\n/**\n * Starts a timeout and calls the callback with an error\n * if the timeout completes before the stop function is called.\n */\nexport default (timeout, callback) => {\n let timeoutId;\n if (timeout !== undefined) {\n timeoutId = window.setTimeout(() => {\n const error = new Error(`Connection timed out after ${timeout}ms`);\n error.code = ErrorCode.ConnectionTimeout;\n callback(error);\n }, timeout);\n }\n return () => {\n clearTimeout(timeoutId);\n };\n};\n","import { MessageType } from '../enums';\nimport connectCallReceiver from '../connectCallReceiver';\nimport connectCallSender from '../connectCallSender';\n/**\n * Handles a SYN-ACK handshake message.\n */\nexport default (parentOrigin, serializedMethods, destructor, log) => {\n const { destroy, onDestroy } = destructor;\n return (event) => {\n let originQualifies = parentOrigin instanceof RegExp\n ? parentOrigin.test(event.origin)\n : parentOrigin === '*' || parentOrigin === event.origin;\n if (!originQualifies) {\n log(`Child: Handshake - Received SYN-ACK from origin ${event.origin} which did not match expected origin ${parentOrigin}`);\n return;\n }\n log('Child: Handshake - Received SYN-ACK, responding with ACK');\n // If event.origin is \"null\", the remote protocol is file: or data: and we\n // must post messages with \"*\" as targetOrigin when sending messages.\n // https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage#Using_window.postMessage_in_extensions\n const originForSending = event.origin === 'null' ? '*' : event.origin;\n const ackMessage = {\n penpal: MessageType.Ack,\n methodNames: Object.keys(serializedMethods),\n };\n window.parent.postMessage(ackMessage, originForSending);\n const info = {\n localName: 'Child',\n local: window,\n remote: window.parent,\n originForSending,\n originForReceiving: event.origin,\n };\n const destroyCallReceiver = connectCallReceiver(info, serializedMethods, log);\n onDestroy(destroyCallReceiver);\n const callSender = {};\n const destroyCallSender = connectCallSender(callSender, info, event.data.methodNames, destroy, log);\n onDestroy(destroyCallSender);\n return callSender;\n };\n};\n","import createDestructor from '../createDestructor';\nimport createLogger from '../createLogger';\nimport { MessageType, NativeEventType } from '../enums';\nimport handleSynAckMessageFactory from './handleSynAckMessageFactory';\nimport { serializeMethods } from '../methodSerialization';\nimport startConnectionTimeout from '../startConnectionTimeout';\nconst areGlobalsAccessible = () => {\n try {\n clearTimeout();\n }\n catch (e) {\n return false;\n }\n return true;\n};\n/**\n * Attempts to establish communication with the parent window.\n */\nexport default (options = {}) => {\n const { parentOrigin = '*', methods = {}, timeout, debug = false } = options;\n const log = createLogger(debug);\n const destructor = createDestructor('Child', log);\n const { destroy, onDestroy } = destructor;\n const serializedMethods = serializeMethods(methods);\n const handleSynAckMessage = handleSynAckMessageFactory(parentOrigin, serializedMethods, destructor, log);\n const sendSynMessage = () => {\n log('Child: Handshake - Sending SYN');\n const synMessage = { penpal: MessageType.Syn };\n const parentOriginForSyn = parentOrigin instanceof RegExp ? '*' : parentOrigin;\n window.parent.postMessage(synMessage, parentOriginForSyn);\n };\n const promise = new Promise((resolve, reject) => {\n const stopConnectionTimeout = startConnectionTimeout(timeout, destroy);\n const handleMessage = (event) => {\n // Under niche scenarios, we get into this function after\n // the iframe has been removed from the DOM. In Edge, this\n // results in \"Object expected\" errors being thrown when we\n // try to access properties on window (global properties).\n // For this reason, we try to access a global up front (clearTimeout)\n // and if it fails we can assume the iframe has been removed\n // and we ignore the message event.\n if (!areGlobalsAccessible()) {\n return;\n }\n if (event.source !== parent || !event.data) {\n return;\n }\n if (event.data.penpal === MessageType.SynAck) {\n const callSender = handleSynAckMessage(event);\n if (callSender) {\n window.removeEventListener(NativeEventType.Message, handleMessage);\n stopConnectionTimeout();\n resolve(callSender);\n }\n }\n };\n window.addEventListener(NativeEventType.Message, handleMessage);\n sendSynMessage();\n onDestroy((error) => {\n window.removeEventListener(NativeEventType.Message, handleMessage);\n if (error) {\n reject(error);\n }\n });\n });\n return {\n promise,\n destroy() {\n // Don't allow consumer to pass an error into destroy.\n destroy();\n },\n };\n};\n","/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\n/**\n * Fancy looking console decorator.\n * @hidden\n * @internal\n */\n\n/** @internal */\nconst isDarkMode = () =>\n typeof window.matchMedia === \"function\" &&\n window.matchMedia(\"(prefers-color-scheme: dark)\").matches;\n\n/** @internal */\ntype Layout = {\n padX: number;\n padY: number;\n rounded: number;\n fontSize: number;\n emphasis: Style;\n};\n/** @internal */\ntype HexColor = `#${string}` | \"transparent\";\n/** @internal */\ntype Color = {\n text: HexColor;\n bg: HexColor;\n hilight: HexColor;\n shadow: HexColor;\n};\n/** @internal */\ntype ThemeSpec = Color & Layout;\n\n/** @internal */\nconst Layouts: Record<string, Layout> = {\n medium: {\n padX: 5,\n padY: 3,\n rounded: 4,\n fontSize: 100,\n emphasis: \"font-weight: bold;\",\n },\n small: {\n padX: 3,\n padY: 1,\n rounded: 2,\n fontSize: 95,\n emphasis: \"font-style: italic;\",\n },\n};\n\n/** @internal */\nconst Colors: Record<string, Color> = {\n yellow: {\n text: \"#333333\",\n bg: \"#EBD932\",\n hilight: \"#F7E434\",\n shadow: \"#D1C12C\",\n },\n green: {\n text: \"#333333\",\n bg: \"#96EB5E\",\n hilight: \"#9EF763\",\n shadow: \"#85D154\",\n },\n blue: {\n text: \"#333333\",\n bg: \"#8DD0EB\",\n hilight: \"#88F0F7\",\n shadow: \"#74AED4\",\n },\n gray: isDarkMode()\n ? {\n text: \"#eeeeee\",\n bg: \"transparent\",\n hilight: \"#cecece\",\n shadow: \"#cecece\",\n }\n : {\n text: \"#333333\",\n bg: \"#eeeeee\",\n hilight: \"#f6f6f6\",\n shadow: \"#cecece\",\n },\n};\n\n/** @internal */\ntype ThemeTag = `${keyof typeof Colors} ${keyof typeof Layouts}`;\n\n/**\n * @internal\n */\nexport type Theme = ThemeSpec | ThemeTag;\n\n/** @internal */\ntype LogDecorator = (...args: unknown[]) => unknown[];\n\n/** @internal */\ntype Style = `${string};`;\n\nfunction memoizeUnary<T, U>(fn: (arg: T) => U): typeof fn {\n const cache: Map<T, U> = new Map();\n return (arg) => {\n if (!cache.has(arg)) {\n const result = fn(arg);\n cache.set(arg, result);\n if (cache.size > 100) {\n cache.delete(cache.keys().next().value as T);\n }\n return result;\n }\n return cache.get(arg);\n };\n}\n\nconst toTheme = memoizeUnary((theme: Theme): ThemeSpec => {\n if (typeof theme === \"string\") {\n const [color, size] = theme.split(\" \");\n return {\n ...Colors[color],\n ...Layouts[size],\n };\n }\n return theme;\n});\n\nconst block: Style = `display: inline-block; border: 1px solid;`;\n\nconst flatten = (side: \"left\" | \"right\"): Style =>\n `padding-${side}: 0px; border-${side}-width: 0px; border-top-${side}-radius: 0px; border-bottom-${side}-radius: 0px;`;\n\nconst toColor = ({ bg, hilight, shadow, text }: Color): Style =>\n `color: ${text}; background: ${bg}; border-color: ${hilight} ${shadow} ${shadow} ${hilight};`;\n\nconst toLayout = ({ fontSize, padY, padX, rounded }: Layout) =>\n `font-size: ${fontSize}%; padding: ${padY}px ${padX}px; border-radius: ${rounded}px;`;\n\nconst toBubbleStyle = memoizeUnary((theme: ThemeSpec): string[] => {\n const base = `${block}${toColor(theme)}${toLayout(theme)}`;\n return [\n `${base}${flatten(\"right\")}`,\n `${base}${flatten(\"left\")}${theme.emphasis}`,\n ] as Style[];\n});\n\nfunction toBubblePrepender(\n bubbleLeft: string,\n bubbleRight: string,\n theme: ThemeSpec\n): LogDecorator {\n const prefix = `%c${bubbleLeft}%c ${bubbleRight}`;\n const [left, right] = toBubbleStyle(theme);\n return (args: unknown[]) => {\n const bubbleArgs = [prefix, left, right];\n if (typeof args[0] === \"string\") {\n bubbleArgs[0] = `${prefix}%c ${args.shift() as string}`;\n bubbleArgs.push(\"\"); // reset style\n }\n return [...bubbleArgs, ...args];\n };\n}\n\n/** @internal */\nconst stateTypes = {\n event: \"️⚡️\",\n} as const;\n\nconst stateDelim = \" ⤻ \";\n\n/** @internal */\ntype DebugState = { type: keyof typeof stateTypes; name: string };\n\n// Serialize to memoize.\nconst getStateFormatter = memoizeUnary((stateJson: string) => {\n const stateStack = JSON.parse(stateJson) as unknown as DebugState[];\n const firstState = stateStack.shift();\n const left = stateTypes[firstState.type];\n const right = [\n firstState.name,\n ...stateStack.map((state) => `${stateTypes[state.type]} ${state.name}`),\n ].join(stateDelim);\n return toBubblePrepender(left, right, toTheme(\"gray small\"));\n});\nconst getStatePrepender = (stateStack: DebugState[]) =>\n getStateFormatter(JSON.stringify(stateStack));\n\nconst overrideMethods = [\"log\", \"error\", \"warn\", \"info\", \"debug\"] as const;\n\nconst identity = <T>(x: T) => x;\n\nconst noop = (): (() => undefined) => undefined;\n\n/**\n * A console, plus some methods to track event lifecycles.\n * @internal\n */\nexport interface DebugLogger extends Console {\n /**\n * Stop all logging; methods do nothing\n * @internal\n */\n detach(): void;\n /**\n * Add an event bubble to the log during handler.\n */\n pushState(state: DebugState): void;\n /**\n * Remove the bubble when event is done dispatching\n */\n popState(): void;\n}\n\n/**\n * Returns a console whose methods autoformat with bubbles.\n * @internal\n */\nexport function _customConsole(\n theme: Theme,\n type: string,\n name: string\n): DebugLogger {\n const prepender = toBubblePrepender(`X${type}`, name, toTheme(theme));\n let statePrepender: LogDecorator = identity as LogDecorator;\n const stateStack: DebugState[] = [];\n const loggerProto: PropertyDescriptorMap = {\n detach: {\n writable: true,\n configurable: true,\n value(this: DebugLogger) {\n overrideMethods.forEach((method) => {\n this[method] = noop;\n });\n },\n },\n pushState: {\n value(state: DebugState) {\n stateStack.push(state);\n statePrepender = getStatePrepender(stateStack);\n },\n },\n popState: {\n value() {\n stateStack.pop();\n statePrepender =\n stateStack.length === 0\n ? (identity as LogDecorator)\n : getStatePrepender(stateStack);\n },\n },\n };\n const customConsole = Object.create(\n console,\n overrideMethods.reduce((out, level) => {\n out[level] = {\n writable: true,\n configurable: true,\n value(...args: unknown[]) {\n console[level](...prepender(statePrepender(args)));\n },\n };\n return out;\n }, loggerProto)\n ) as DebugLogger;\n return customConsole;\n}\n\n/**\n * @internal\n */\nexport const quietConsole = new Proxy(console, {\n get() {\n return noop;\n },\n});\n","/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { _customConsole, DebugLogger, Theme } from \"./debuglog.js\";\nimport { Emits, Unsubscriber } from \"./types.js\";\n\n/**\n * Adds methods for logging events\n * @internal\n */\nexport interface EmitterDebugLogger extends DebugLogger {\n /**\n * Listen to an event and pass the logger to the handler\n * @internal\n */\n listen(\n type: string,\n listener: (logger: EmitterDebugLogger, ev: CustomEvent) => unknown\n ): this;\n}\n\n/**\n * Debugger for EventTarget objects like Hosts, Ports and Guests, which\n * patches dispatchEvent to log events\n * Adapter to attach console logging listeners to all events on an emitter.\n * @internal\n */\nexport function debugEmitter(\n emitter: Emits,\n opts: {\n theme: Theme;\n type?: string;\n id?: string;\n }\n): EmitterDebugLogger {\n const logger = _customConsole(\n opts.theme,\n opts.type ||\n (Object.getPrototypeOf(emitter) as typeof emitter).constructor.name,\n opts.id || emitter.id\n ) as EmitterDebugLogger;\n const oldDispatch = emitter.dispatchEvent;\n emitter.dispatchEvent = (event) => {\n logger.pushState({ type: \"event\", name: event.type });\n const retVal = oldDispatch.call(emitter, event) as boolean;\n logger.popState();\n return retVal;\n };\n\n const subscriptions: Unsubscriber[] = [];\n\n const oldDetach = logger.detach;\n logger.detach = () => {\n oldDetach.call(logger);\n subscriptions.forEach((unsubscribe) => unsubscribe());\n };\n\n /**\n * Listens and passes a logger to callbacks\n */\n function listen(\n type: string,\n listener: (logger: EmitterDebugLogger, ev: CustomEvent) => unknown\n ) {\n subscriptions.push(\n emitter.addEventListener(type, (event) => listener(logger, event))\n );\n return logger;\n }\n\n logger.listen = listen;\n\n return logger;\n}\n","/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { Emits, Unsubscriber, NamedEvent } from \"./types.js\";\n\n/**\n * Browser-native {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget | EventTarget}\n * whose {@link Emitter.addEventListener} method returns an anonymous function\n * which unsubscribes the original handler.\n *\n * Also provides typed events via generics. You can create or extend this class\n * to define custom emitters with known event names and signatures.\n *\n * @example\n * ```ts\n * import type { NamedEvent, Emitter } from '@adobe/uix-sdk'\n *\n * class FizzBuzzEmitter extends Emitter<\n * NamedEvent<\"fizz\", { fizzCount: number }> |\n * NamedEvent<\"buzz\", { buzzCount: number }> |\n * NamedEvent<\"fizzbuzz\">\n * > {\n * }\n * ```\n * The `FizzBuzzEmitter` class will now type check its events and event\n * listeners, providing autosuggest in editors.\n *\n * @see [EventTarget - MDN](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget)\n *\n * @public\n */\nexport class Emitter<Events extends NamedEvent>\n extends EventTarget\n implements Emits<Events>\n{\n /**\n * An arbitrary string to uniquely identify this emitter and its events.\n * @public\n */\n id: string;\n constructor(id: string) {\n super();\n this.id = id;\n }\n /**\n * Convenience method to construct and dispatch custom events.\n *\n * @param type - Name of one of the allowed events this can emit\n * @param detail - Object to expose in the {@link https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/detail | CustomEvent#detail}\n * property.\n * @public\n */\n protected emit<Event extends Events>(\n type: Event[\"type\"],\n detail: Event[\"detail\"]\n ): void {\n const event = new CustomEvent<typeof detail>(type, { detail });\n this.dispatchEvent(event);\n }\n /**\n * Subscribe to an event and receive an unsubscribe callback.\n * @see [EventTarget.addEventListener - MDN](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener)\n *\n * Identical to `EventTarget.addEventListener`, but returns an \"unsubscriber\"\n * function which detaches the listener when invoked. Solves an ergonomic\n * problem with native EventTargets where it's impossible to detach listeners\n * without having a reference to the original handler.\n *\n * @typeParam E - Name of one of the allowed events this can emit\n * @param type - Event type\n * @param listener - Event handler\n * @returns Call to unsubscribe listener.\n */\n addEventListener<\n Type extends Events[\"type\"],\n Event extends Extract<Events, { type: Type }>\n >(type: Type, listener: (ev: Event) => unknown): Unsubscriber {\n super.addEventListener(type, listener);\n return () => super.removeEventListener(type, listener);\n }\n}\n","/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { RemoteHostApis, RemoteMethodInvoker } from \"./types.js\";\n\n/**\n * Build a fake object that turns \"method calls\" into RPC messages\n * The resulting object will recursively make more fake proxies on demand until\n * one of the looked-up properties is invoked as a function.\n * Then it will call the passed `invoke` method with a {@link HostMethodAddress}\n * that can send the method invocation as an RPC message to another realm.\n *\n * @example\n * ```js\n * const invoker = (methodAddress) => console.log(\n * address.path,\n * address.name,\n * address.args\n * );\n * const ns = makeNamespaceProxy(invoker);\n *\n * // looking up any property on the object will work\n *\n * ns.example.builds.method.call.message(\"foo\", 1);\n *\n * // Console will log:\n * ['example','builds','method','call']\n * 'message'\n * [\"foo\", 1]\n *```\n * @internal\n *\n * @param invoke - Callback that receives address\n */\nexport function makeNamespaceProxy<ProxiedApi extends object>(\n invoke: RemoteMethodInvoker<unknown>,\n path: string[] = []\n): RemoteHostApis<ProxiedApi> {\n const handler: ProxyHandler<Record<string, any>> = {\n get: (target, prop) => {\n if (typeof prop === \"string\") {\n if (!Reflect.has(target, prop)) {\n const next = makeNamespaceProxy(invoke, path.concat(prop));\n Reflect.set(target, prop, next);\n }\n return Reflect.get(target, prop) as unknown;\n } else {\n throw new Error(\n `Cannot look up a symbol ${String(prop)} on a host connection proxy.`\n );\n }\n },\n };\n const target = {} as unknown as RemoteHostApis<ProxiedApi>;\n // Only trap the apply if there's at least two levels of namespace.\n // uix.host() is not a function, and neither is uix.host.bareMethod().\n if (path.length < 2) {\n return new Proxy<RemoteHostApis<ProxiedApi>>(target, handler);\n }\n const invoker = (...args: unknown[]) =>\n invoke({\n path: path.slice(0, -1),\n name: path[path.length - 1],\n args,\n });\n return new Proxy<typeof invoker>(invoker, {\n ...handler,\n apply(target, _, args: unknown[]) {\n return target(...args);\n },\n }) as unknown as typeof target;\n}\n","/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\n/**\n * Add a timeout to a Promise. The returned Promise will resolve to the value of\n * the original Promise, but if it doesn't resolve within the timeout interval,\n * it will reject with a timeout error.\n * @internal\n *\n * @param timeoutMs - Time to wait (ms) before rejecting\n * @param promise - Original promise to set a timeout for\n * @returns - Promise that rejects after X milliseconds have passed\n */\nexport function timeoutPromise<T>(timeoutMs: number, promise: Promise<T>) {\n return new Promise((resolve, reject) => {\n const timeout = setTimeout(\n () => reject(new Error(`Timed out after ${timeoutMs}ms`)),\n timeoutMs\n );\n promise\n .then((result) => {\n clearTimeout(timeout);\n resolve(result);\n })\n .catch(reject);\n });\n}\n","/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\n/**\n * Adapter to attach console logging listeners to a Guest running in a frame/\n * @internal @preapproved\n */\nimport { debugEmitter, Emits, EmitterDebugLogger } from \"@adobe/uix-core\";\nimport { GuestEvents } from \"./guest\";\n\nexport function debugGuest(guest: Emits<GuestEvents>): EmitterDebugLogger {\n return debugEmitter(guest, {\n theme: \"yellow medium\",\n type: \"Guest\",\n })\n .listen(\"beforeconnect\", (log, { detail: { guest } }) => {\n log.info(guest);\n })\n .listen(\"connecting\", (log, { detail: { connection } }) => {\n log.info(connection);\n })\n .listen(\"connected\", (log, { detail: { guest } }) => {\n log.info(guest);\n })\n .listen(\"error\", (log, { detail: { error, guest } }) => {\n log.error(\n \"❌ Failed to connect! %s\",\n (error as Error).message,\n guest,\n error\n );\n });\n}\n","/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\n/* eslint @typescript-eslint/no-explicit-any: \"off\" */\nimport { Connection, connectToParent } from \"penpal\";\nimport type {\n RemoteHostApis,\n HostConnection,\n NamedEvent,\n VirtualApi,\n} from \"@adobe/uix-core\";\nimport {\n Emitter,\n makeNamespaceProxy,\n timeoutPromise,\n quietConsole,\n} from \"@adobe/uix-core\";\nimport { debugGuest } from \"./debug-guest.js\";\n\n/**\n * @public\n */\nexport type GuestEvent<\n Type extends string = string,\n Detail = Record<string, unknown>\n> = NamedEvent<\n Type,\n Detail &\n Record<string, unknown> & {\n guest: Guest;\n }\n>;\n\n/**\n * @public\n */\nexport type GuestEventContextChange = GuestEvent<\n \"contextchange\",\n { context: Record<string, unknown> }\n>;\n\n/** @public */\nexport type GuestEventBeforeConnect = GuestEvent<\"beforeconnect\">;\n/** @public */\nexport type GuestEventConnected = GuestEvent<\n \"connected\",\n { connection: Connection }\n>;\n/** @public */\nexport type GuestEventError = GuestEvent<\"error\", { error: Error }>;\n\n/**\n * @public\n */\nexport type GuestEvents =\n | GuestEventContextChange\n | GuestEventBeforeConnect\n | GuestEventConnected\n | GuestEventError;\n\n/**\n * @public\n */\nexport interface GuestConfig {\n /**\n * String slug identifying extension. This may need to use IDs from an\n * external system in the future.\n */\n id: string;\n /**\n * Set debug flags on all libraries that have them, and add loggers to SDK\n * objects. Log a lot to the console.\n */\n debug?: boolean;\n /**\n * Time out and stop trying to reach the host after this many milliseconds\n */\n timeout?: number;\n}\n\n/**\n * A `Map` representing the {@link @adobe/uix-host#HostConfig.sharedContext}\n * object.\n *\n * @remarks While the Host object is a plain JavaScript object. the `sharedContext` in the Guest object implements the {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map | Map} interface.\n *\n * @example\n * In the host app window, the Host object shares context:\n * ```javascript\n *host.shareContext({\n * someAuthToken: 'abc'\n *});\n * ```\n *\n * After the `contentchange` event has fired in the guest window:\n * ```javascript\n * guest.sharedContext.get('someAuthToken') === 'abc'\n * ```\n * @public\n */\nexport class SharedContext {\n private _map: Map<string, unknown>;\n constructor(values: Record<string, unknown>) {\n this.reset(values);\n }\n private reset(values: Record<string, unknown>) {\n this._map = new Map(Object.entries(values));\n }\n /**\n * @public\n * Retrieve a copy of a value from the {@link @adobe/uix-host#HostConfig.sharedContext} object. *Note that this is not a reference to any actual objects from the parent. If the parent updates an \"inner object\" inside the SharedContext, that change will not be reflected in the Guest!*\n */\n get(key: string) {\n return this._map.get(key);\n }\n}\n\n/**\n * Generic Guest object, with methods shared by all types of Guest.\n * @internal\n */\nexport class Guest<\n Incoming extends object = VirtualApi\n> extends Emitter<GuestEvents> {\n /**\n * Shared context has been set or updated.\n * @eventProperty\n */\n public contextchange: GuestEventContextChange;\n /**\n * About to attempt connection to the host.\n * @eventProperty\n */\n public beforeconnect: GuestEventBeforeConnect;\n /**\n * Host connection has been established.\n * @eventProperty\n */\n public connected: GuestEventConnected;\n /**\n * Host connection has failed.\n * @eventProperty\n */\n public error: GuestEventError;\n /**\n * {@inheritdoc SharedContext}\n */\n sharedContext: SharedContext;\n private debugLogger: Console = quietConsole;\n\n /**\n * @param config - Initializer for guest object, including ID.\n */\n constructor(config: GuestConfig) {\n super(config.id);\n if (typeof config.timeout === \"number\") {\n this.timeout = config.timeout;\n }\n if (config.debug) {\n this.debugLogger = debugGuest(this);\n }\n this.addEventListener(\"contextchange\", (event) => {\n this.sharedContext = new SharedContext(event.detail.context);\n });\n }\n /**\n * Proxy object for calling methods on the host.\n *\n * @remarks Any APIs exposed to the extension via {@link @adobe/uix-host#Port.provide}\n * can be called on this object. Because these methods are called with RPC,\n * they are all asynchronous, The return types of all Host methods will be\n * Promises which resolve to the value the Host method returns.\n * @public\n */\n host: RemoteHostApis<Incoming> = makeNamespaceProxy<Incoming>(\n async (address) => {\n await this.hostConnectionPromise;\n try {\n const result = await timeoutPromise(\n 10000,\n this.hostConnection.invokeHostMethod(address)\n );\n return result;\n } catch (e) {\n const error =\n e instanceof Error ? e : new Error(e as unknown as string);\n const methodError = new Error(\n `Host method call host.${address.path.join(\".\")}() failed: ${\n error.message\n }`\n );\n this.debugLogger.error(methodError);\n throw methodError;\n }\n }\n );\n private timeout = 10000;\n private hostConnectionPromise: Promise<RemoteHostApis<HostConnection>>;\n private hostConnection!: RemoteHostApis<HostConnection>;\n /** @internal */\n protected getLocalMethods() {\n return {\n emit: (...args: Parameters<typeof this.emit>) => {\n this.debugLogger.log(`Event \"${args[0]}\" emitted from host`);\n this.emit(...args);\n },\n };\n }\n /**\n * Accept a connection from the Host.\n * @returns A Promise that resolves when the Host has established a connection.\n * @deprecated It is preferable to use {@link register} for primary frames,\n * and {@link attach} for UI frames and other secondary frames, than to\n * instantiate a Guest and then call `.connect()` on it. The latter style\n * returns an object that cannot be used until it is connected, and therefore\n * risks errors.\n * @public\n */\n async connect() {\n return this._connect();\n }\n\n /**\n * @internal\n */\n async _connect() {\n this.emit(\"beforeconnect\", { guest: this });\n try {\n const connection = connectToParent<HostConnection<Incoming>>({\n timeout: this.timeout,\n methods: this.getLocalMethods(),\n });\n\n this.hostConnectionPromise = connection.promise;\n this.hostConnection = await this.hostConnectionPromise;\n this.sharedContext = new SharedContext(\n await this.hostConnection.getSharedContext()\n );\n this.debugLogger.log(\"retrieved sharedContext\", this.sharedContext);\n this.emit(\"connected\", { guest: this, connection });\n } catch (e) {\n this.emit(\"error\", { guest: this, error: e });\n this.debugLogger.error(\"Connection failed!\", e);\n }\n }\n}\n","/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport type { RemoteHostApis, VirtualApi } from \"@adobe/uix-core\";\nimport {\n Guest,\n GuestConfig,\n GuestEventBeforeConnect,\n GuestEventConnected,\n GuestEventContextChange,\n GuestEventError,\n} from \"./guest\";\n\n/**\n * A Guest to be used in an extension-controlled frame, usually to display UI.\n *\n * @typeParam Incoming - Optional interface of host methods. If using\n * TypeScript, supply this type parameter and a promisified version of the\n * interface will be available at {@link Guest.host}\n *\n * @remarks\n * This is the object returned when calling {@link @adobe/uix-guest#attach}. It\n * represents an additional frame or runtime created by the host application, on\n * behalf of the extension's control frame which is running the {@link\n * GuestServer}. It is a \"secondary\" guest object, which a host won't use before\n * the control frame has connected. It exposes a subset of the functionality of\n * the {@link GuestServer}.\n *\n * Unlike the {@link GuestServer}, it cannot register methods or update the\n * {@link Guest.sharedContext}, but it remains in sync with the GuestServer and\n * can access the {@link Guest.sharedContext} of the control frame, as well as\n * any of the published methods on the host.\n *\n * Extensible host apps using the React bindings will likely render GuestUI\n * frames using the {@link @adobe/uix-host-react#GuestUIFrame} component.\n *\n * @example\n * When an extensible app renders this page, {@link @adobe/uix-guest#attach}\n * creates a GuestUI. Once it attaches to the host, it\n * ```javascript\n * import React, { useEffect, useState } from \"react\";\n * import { attach } from \"@adobe/uix-guest\";\n * import { Tooltip } from \"./tooltip\";\n *\n * export default function PopupOverlay(props) {\n * // how large am I?\n * const [dimensions, setDimensions] = useState(\n * document.body.getBoundingClientRect()\n * );\n * // if possible, use language preloaded in query parameters\n * const [language, setLanguage] = useState(props.params.lang)\n *\n * // attach only once, in a useEffect\n * useEffect(() => {\n * attach({\n * id: \"my-extension-id\",\n * debug: true,\n * })\n * .then(guestUI => {\n * // this event fires whenever the host, or the control frame, changes\n * // any sharedContext value\n * guestUI.addEventListener(\"contextchange\", ({ detail: { context }}) => {\n * setLanguage(context.lang)\n * });\n * // how large does the host want me to be?\n * return guestUI.host.tooltips.getDimensions()\n * .then(setDimensions)\n * })\n * .catch((e) => {\n * console.error(\"ui attach failed\", e);\n * });\n * }, []);\n * // render UI! Due to the setup and useState, this component will re-render\n * // once attach() is complete.\n * return (\n * <Tooltip {...props.params} lang={language} dimensions={dimensions} />\n * );\n * }\n * ```\n *\n * @public\n */\nexport class GuestUI<IHost extends VirtualApi> extends Guest<IHost> {\n /**\n * {@inheritDoc Guest.\"constructor\"}\n */\n constructor(config: GuestConfig) {\n super(config);\n }\n /**\n * {@inheritDoc Guest.contextchange}\n * @eventProperty\n */\n public contextchange: GuestEventContextChange;\n /**\n * {@inheritDoc Guest.beforeconnect}\n * @eventProperty\n */\n public beforeconnect: GuestEventBeforeConnect;\n /**\n * {@inheritDoc Guest.connected}\n * @eventProperty\n */\n public connected: GuestEventConnected;\n /**\n * {@inheritDoc Guest.error}\n * @eventProperty\n */\n public error: GuestEventError;\n /**\n * {@inheritDoc Guest.host}\n */\n host: RemoteHostApis<IHost>;\n}\n","/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport type { GuestApis } from \"@adobe/uix-core\";\nimport type { SharedContext } from \"./guest\";\nimport { Guest } from \"./guest\";\n\n/**\n * A Guest to be used in the \"main\" or primary frame of an extension, the frame\n * the Host loads first.\n *\n * @remarks This is the Guest object returned from {@link register}. It can\n * expose internal methods to the Host via the {@link GuestServer.register}\n * method.\n *\n *\n * @public\n */\nexport class GuestServer<Outgoing extends GuestApis> extends Guest<Outgoing> {\n private localMethods: Outgoing;\n protected getLocalMethods() {\n return {\n ...super.getLocalMethods(),\n apis: this.localMethods,\n };\n }\n /**\n * {@inheritDoc BaseGuest.sharedContext}\n */\n sharedContext: SharedContext;\n /**\n * {@inheritdoc BaseGuest.host}\n */\n host: Guest<Outgoing>[\"host\"];\n /**\n * Pass an interface of methods which Host may call as callbacks.\n *\n * @remarks It is preferable to use {@link register} to obtain a guest object\n * and register local methods in one step. The returned guest object will be\n * pre-registered and connected.\n * @public\n */\n async register(implementedMethods: Outgoing) {\n this.localMethods = implementedMethods;\n return this._connect();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,MAAI;AACX,GAAC,SAAUA,cAAa;AACpB,IAAAA,aAAY,UAAU;AACtB,IAAAA,aAAY,WAAW;AACvB,IAAAA,aAAY,SAAS;AACrB,IAAAA,aAAY,YAAY;AACxB,IAAAA,aAAY,SAAS;AAAA,EACzB,GAAG,gBAAgB,cAAc,CAAC,EAAE;AAC7B,MAAI;AACX,GAAC,SAAUC,aAAY;AACnB,IAAAA,YAAW,eAAe;AAC1B,IAAAA,YAAW,cAAc;AAAA,EAC7B,GAAG,eAAe,aAAa,CAAC,EAAE;AAC3B,MAAI;AACX,GAAC,SAAUC,YAAW;AAClB,IAAAA,WAAU,yBAAyB;AACnC,IAAAA,WAAU,uBAAuB;AACjC,IAAAA,WAAU,iBAAiB;AAAA,EAC/B,GAAG,cAAc,YAAY,CAAC,EAAE;AACzB,MAAI;AACX,GAAC,SAAUC,kBAAiB;AACxB,IAAAA,iBAAgB,oBAAoB;AAAA,EACxC,GAAG,oBAAoB,kBAAkB,CAAC,EAAE;AACrC,MAAI;AACX,GAAC,SAAUC,kBAAiB;AACxB,IAAAA,iBAAgB,aAAa;AAAA,EACjC,GAAG,oBAAoB,kBAAkB,CAAC,EAAE;;;AC1B5C,MAAO,2BAAQ,CAAC,WAAW,QAAQ;AAC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,OAAO;AACnC,WAAO;AAAA,EACT;","names":["MessageType","Resolution","ErrorCode","NativeErrorName","NativeEventType","id","id","id","target","guest","Guest","Guest","Guest"]}
1
+ {"version":3,"sources":["../../../uix-core/src/debuglog.ts","../../../uix-core/src/debug-emitter.ts","../../../uix-core/src/emitter.ts","../../../uix-core/src/namespace-proxy.ts","../../../uix-core/src/timeout-promise.ts","../../src/index.ts","../../../../node_modules/penpal/lib/enums.js","../../../../node_modules/penpal/lib/createDestructor.js","../../../../node_modules/penpal/lib/createLogger.js","../../../../node_modules/penpal/lib/errorSerialization.js","../../../../node_modules/penpal/lib/connectCallReceiver.js","../../../../node_modules/penpal/lib/generateId.js","../../../../node_modules/penpal/lib/methodSerialization.js","../../../../node_modules/penpal/lib/connectCallSender.js","../../../../node_modules/penpal/lib/startConnectionTimeout.js","../../../../node_modules/penpal/lib/child/handleSynAckMessageFactory.js","../../../../node_modules/penpal/lib/child/connectToParent.js","../../src/guest.ts","../../src/debug-guest.ts","../../src/guest-ui.ts","../../src/guest-server.ts"],"sourcesContent":["/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\n/**\n * Fancy looking console decorator.\n * @hidden\n * @internal\n */\n\n/** @internal */\nconst isDarkMode = () =>\n typeof window.matchMedia === \"function\" &&\n window.matchMedia(\"(prefers-color-scheme: dark)\").matches;\n\n/** @internal */\ntype Layout = {\n padX: number;\n padY: number;\n rounded: number;\n fontSize: number;\n emphasis: Style;\n};\n/** @internal */\ntype HexColor = `#${string}` | \"transparent\";\n/** @internal */\ntype Color = {\n text: HexColor;\n bg: HexColor;\n hilight: HexColor;\n shadow: HexColor;\n};\n/** @internal */\ntype ThemeSpec = Color & Layout;\n\n/** @internal */\nconst Layouts: Record<string, Layout> = {\n medium: {\n padX: 5,\n padY: 3,\n rounded: 4,\n fontSize: 100,\n emphasis: \"font-weight: bold;\",\n },\n small: {\n padX: 3,\n padY: 1,\n rounded: 2,\n fontSize: 95,\n emphasis: \"font-style: italic;\",\n },\n};\n\n/** @internal */\nconst Colors: Record<string, Color> = {\n yellow: {\n text: \"#333333\",\n bg: \"#EBD932\",\n hilight: \"#F7E434\",\n shadow: \"#D1C12C\",\n },\n green: {\n text: \"#333333\",\n bg: \"#96EB5E\",\n hilight: \"#9EF763\",\n shadow: \"#85D154\",\n },\n blue: {\n text: \"#333333\",\n bg: \"#8DD0EB\",\n hilight: \"#88F0F7\",\n shadow: \"#74AED4\",\n },\n gray: isDarkMode()\n ? {\n text: \"#eeeeee\",\n bg: \"transparent\",\n hilight: \"#cecece\",\n shadow: \"#cecece\",\n }\n : {\n text: \"#333333\",\n bg: \"#eeeeee\",\n hilight: \"#f6f6f6\",\n shadow: \"#cecece\",\n },\n};\n\n/** @internal */\ntype ThemeTag = `${keyof typeof Colors} ${keyof typeof Layouts}`;\n\n/**\n * @internal\n */\nexport type Theme = ThemeSpec | ThemeTag;\n\n/** @internal */\ntype LogDecorator = (...args: unknown[]) => unknown[];\n\n/** @internal */\ntype Style = `${string};`;\n\nfunction memoizeUnary<T, U>(fn: (arg: T) => U): typeof fn {\n const cache: Map<T, U> = new Map();\n return (arg) => {\n if (!cache.has(arg)) {\n const result = fn(arg);\n cache.set(arg, result);\n if (cache.size > 100) {\n cache.delete(cache.keys().next().value as T);\n }\n return result;\n }\n return cache.get(arg);\n };\n}\n\nconst toTheme = memoizeUnary((theme: Theme): ThemeSpec => {\n if (typeof theme === \"string\") {\n const [color, size] = theme.split(\" \");\n return {\n ...Colors[color],\n ...Layouts[size],\n };\n }\n return theme;\n});\n\nconst block: Style = `display: inline-block; border: 1px solid;`;\n\nconst flatten = (side: \"left\" | \"right\"): Style =>\n `padding-${side}: 0px; border-${side}-width: 0px; border-top-${side}-radius: 0px; border-bottom-${side}-radius: 0px;`;\n\nconst toColor = ({ bg, hilight, shadow, text }: Color): Style =>\n `color: ${text}; background: ${bg}; border-color: ${hilight} ${shadow} ${shadow} ${hilight};`;\n\nconst toLayout = ({ fontSize, padY, padX, rounded }: Layout) =>\n `font-size: ${fontSize}%; padding: ${padY}px ${padX}px; border-radius: ${rounded}px;`;\n\nconst toBubbleStyle = memoizeUnary((theme: ThemeSpec): string[] => {\n const base = `${block}${toColor(theme)}${toLayout(theme)}`;\n return [\n `${base}${flatten(\"right\")}`,\n `${base}${flatten(\"left\")}${theme.emphasis}`,\n ] as Style[];\n});\n\nfunction toBubblePrepender(\n bubbleLeft: string,\n bubbleRight: string,\n theme: ThemeSpec\n): LogDecorator {\n const prefix = `%c${bubbleLeft}%c ${bubbleRight}`;\n const [left, right] = toBubbleStyle(theme);\n return (args: unknown[]) => {\n const bubbleArgs = [prefix, left, right];\n if (typeof args[0] === \"string\") {\n bubbleArgs[0] = `${prefix}%c ${args.shift() as string}`;\n bubbleArgs.push(\"\"); // reset style\n }\n return [...bubbleArgs, ...args];\n };\n}\n\n/** @internal */\nconst stateTypes = {\n event: \"️⚡️\",\n} as const;\n\nconst stateDelim = \" ⤻ \";\n\n/** @internal */\ntype DebugState = { type: keyof typeof stateTypes; name: string };\n\n// Serialize to memoize.\nconst getStateFormatter = memoizeUnary((stateJson: string) => {\n const stateStack = JSON.parse(stateJson) as unknown as DebugState[];\n const firstState = stateStack.shift();\n const left = stateTypes[firstState.type];\n const right = [\n firstState.name,\n ...stateStack.map((state) => `${stateTypes[state.type]} ${state.name}`),\n ].join(stateDelim);\n return toBubblePrepender(left, right, toTheme(\"gray small\"));\n});\nconst getStatePrepender = (stateStack: DebugState[]) =>\n getStateFormatter(JSON.stringify(stateStack));\n\nconst overrideMethods = [\"log\", \"error\", \"warn\", \"info\", \"debug\"] as const;\n\nconst identity = <T>(x: T) => x;\n\nconst noop = (): (() => undefined) => undefined;\n\n/**\n * A console, plus some methods to track event lifecycles.\n * @internal\n */\nexport interface DebugLogger extends Console {\n /**\n * Stop all logging; methods do nothing\n * @internal\n */\n detach(): void;\n /**\n * Add an event bubble to the log during handler.\n */\n pushState(state: DebugState): void;\n /**\n * Remove the bubble when event is done dispatching\n */\n popState(): void;\n}\n\n/**\n * Returns a console whose methods autoformat with bubbles.\n * @internal\n */\nexport function _customConsole(\n theme: Theme,\n type: string,\n name: string\n): DebugLogger {\n const prepender = toBubblePrepender(`X${type}`, name, toTheme(theme));\n let statePrepender: LogDecorator = identity as LogDecorator;\n const stateStack: DebugState[] = [];\n const loggerProto: PropertyDescriptorMap = {\n detach: {\n writable: true,\n configurable: true,\n value(this: DebugLogger) {\n overrideMethods.forEach((method) => {\n this[method] = noop;\n });\n },\n },\n pushState: {\n value(state: DebugState) {\n stateStack.push(state);\n statePrepender = getStatePrepender(stateStack);\n },\n },\n popState: {\n value() {\n stateStack.pop();\n statePrepender =\n stateStack.length === 0\n ? (identity as LogDecorator)\n : getStatePrepender(stateStack);\n },\n },\n };\n const customConsole = Object.create(\n console,\n overrideMethods.reduce((out, level) => {\n out[level] = {\n writable: true,\n configurable: true,\n value(...args: unknown[]) {\n console[level](...prepender(statePrepender(args)));\n },\n };\n return out;\n }, loggerProto)\n ) as DebugLogger;\n return customConsole;\n}\n\n/**\n * @internal\n */\nexport const quietConsole = new Proxy(console, {\n get() {\n return noop;\n },\n});\n","/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { _customConsole, DebugLogger, Theme } from \"./debuglog.js\";\nimport { Emits, Unsubscriber } from \"./types.js\";\n\n/**\n * Adds methods for logging events\n * @internal\n */\nexport interface EmitterDebugLogger extends DebugLogger {\n /**\n * Listen to an event and pass the logger to the handler\n * @internal\n */\n listen(\n type: string,\n listener: (logger: EmitterDebugLogger, ev: CustomEvent) => unknown\n ): this;\n}\n\n/**\n * Debugger for EventTarget objects like Hosts, Ports and Guests, which\n * patches dispatchEvent to log events\n * Adapter to attach console logging listeners to all events on an emitter.\n * @internal\n */\nexport function debugEmitter(\n emitter: Emits,\n opts: {\n theme: Theme;\n type?: string;\n id?: string;\n }\n): EmitterDebugLogger {\n const logger = _customConsole(\n opts.theme,\n opts.type ||\n (Object.getPrototypeOf(emitter) as typeof emitter).constructor.name,\n opts.id || emitter.id\n ) as EmitterDebugLogger;\n const oldDispatch = emitter.dispatchEvent;\n emitter.dispatchEvent = (event) => {\n logger.pushState({ type: \"event\", name: event.type });\n const retVal = oldDispatch.call(emitter, event) as boolean;\n logger.popState();\n return retVal;\n };\n\n const subscriptions: Unsubscriber[] = [];\n\n const oldDetach = logger.detach;\n logger.detach = () => {\n oldDetach.call(logger);\n subscriptions.forEach((unsubscribe) => unsubscribe());\n };\n\n /**\n * Listens and passes a logger to callbacks\n */\n function listen(\n type: string,\n listener: (logger: EmitterDebugLogger, ev: CustomEvent) => unknown\n ) {\n subscriptions.push(\n emitter.addEventListener(type, (event) => listener(logger, event))\n );\n return logger;\n }\n\n logger.listen = listen;\n\n return logger;\n}\n","/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { Emits, Unsubscriber, NamedEvent } from \"./types.js\";\n\n/**\n * Browser-native {@link https://developer.mozilla.org/en-US/docs/Web/API/EventTarget | EventTarget}\n * whose {@link Emitter.addEventListener} method returns an anonymous function\n * which unsubscribes the original handler.\n *\n * Also provides typed events via generics. You can create or extend this class\n * to define custom emitters with known event names and signatures.\n *\n * @example\n * ```ts\n * import type { NamedEvent, Emitter } from '@adobe/uix-sdk'\n *\n * class FizzBuzzEmitter extends Emitter<\n * NamedEvent<\"fizz\", { fizzCount: number }> |\n * NamedEvent<\"buzz\", { buzzCount: number }> |\n * NamedEvent<\"fizzbuzz\">\n * > {\n * }\n * ```\n * The `FizzBuzzEmitter` class will now type check its events and event\n * listeners, providing autosuggest in editors.\n *\n * @see [EventTarget - MDN](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget)\n *\n * @public\n */\nexport class Emitter<Events extends NamedEvent>\n extends EventTarget\n implements Emits<Events>\n{\n /**\n * An arbitrary string to uniquely identify this emitter and its events.\n * @public\n */\n id: string;\n constructor(id: string) {\n super();\n this.id = id;\n }\n /**\n * Convenience method to construct and dispatch custom events.\n *\n * @param type - Name of one of the allowed events this can emit\n * @param detail - Object to expose in the {@link https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/detail | CustomEvent#detail}\n * property.\n * @public\n */\n protected emit<Event extends Events>(\n type: Event[\"type\"],\n detail: Event[\"detail\"]\n ): void {\n const event = new CustomEvent<typeof detail>(type, { detail });\n this.dispatchEvent(event);\n }\n /**\n * Subscribe to an event and receive an unsubscribe callback.\n * @see [EventTarget.addEventListener - MDN](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener)\n *\n * Identical to `EventTarget.addEventListener`, but returns an \"unsubscriber\"\n * function which detaches the listener when invoked. Solves an ergonomic\n * problem with native EventTargets where it's impossible to detach listeners\n * without having a reference to the original handler.\n *\n * @typeParam E - Name of one of the allowed events this can emit\n * @param type - Event type\n * @param listener - Event handler\n * @returns Call to unsubscribe listener.\n */\n addEventListener<\n Type extends Events[\"type\"],\n Event extends Extract<Events, { type: Type }>\n >(type: Type, listener: (ev: Event) => unknown): Unsubscriber {\n super.addEventListener(type, listener);\n return () => super.removeEventListener(type, listener);\n }\n}\n","/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { RemoteHostApis, RemoteMethodInvoker } from \"./types.js\";\n\n/**\n * Build a fake object that turns \"method calls\" into RPC messages\n * The resulting object will recursively make more fake proxies on demand until\n * one of the looked-up properties is invoked as a function.\n * Then it will call the passed `invoke` method with a {@link HostMethodAddress}\n * that can send the method invocation as an RPC message to another realm.\n *\n * @example\n * ```js\n * const invoker = (methodAddress) => console.log(\n * address.path,\n * address.name,\n * address.args\n * );\n * const ns = makeNamespaceProxy(invoker);\n *\n * // looking up any property on the object will work\n *\n * ns.example.builds.method.call.message(\"foo\", 1);\n *\n * // Console will log:\n * ['example','builds','method','call']\n * 'message'\n * [\"foo\", 1]\n *```\n * @internal\n *\n * @param invoke - Callback that receives address\n */\nexport function makeNamespaceProxy<ProxiedApi extends object>(\n invoke: RemoteMethodInvoker<unknown>,\n path: string[] = []\n): RemoteHostApis<ProxiedApi> {\n const handler: ProxyHandler<Record<string, any>> = {\n get: (target, prop) => {\n if (typeof prop === \"string\") {\n if (!Reflect.has(target, prop)) {\n const next = makeNamespaceProxy(invoke, path.concat(prop));\n Reflect.set(target, prop, next);\n }\n return Reflect.get(target, prop) as unknown;\n } else {\n throw new Error(\n `Cannot look up a symbol ${String(prop)} on a host connection proxy.`\n );\n }\n },\n };\n const target = {} as unknown as RemoteHostApis<ProxiedApi>;\n // Only trap the apply if there's at least two levels of namespace.\n // uix.host() is not a function, and neither is uix.host.bareMethod().\n if (path.length < 2) {\n return new Proxy<RemoteHostApis<ProxiedApi>>(target, handler);\n }\n const invoker = (...args: unknown[]) =>\n invoke({\n path: path.slice(0, -1),\n name: path[path.length - 1],\n args,\n });\n return new Proxy<typeof invoker>(invoker, {\n ...handler,\n apply(target, _, args: unknown[]) {\n return target(...args);\n },\n }) as unknown as typeof target;\n}\n","/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\n/**\n * Add a timeout to a Promise. The returned Promise will resolve to the value of\n * the original Promise, but if it doesn't resolve within the timeout interval,\n * it will reject with a timeout error.\n * @internal\n *\n * @param timeoutMs - Time to wait (ms) before rejecting\n * @param promise - Original promise to set a timeout for\n * @returns - Promise that rejects after X milliseconds have passed\n */\nexport function timeoutPromise<T>(timeoutMs: number, promise: Promise<T>) {\n return new Promise((resolve, reject) => {\n const timeout = setTimeout(\n () => reject(new Error(`Timed out after ${timeoutMs}ms`)),\n timeoutMs\n );\n promise\n .then((result) => {\n clearTimeout(timeout);\n resolve(result);\n })\n .catch(reject);\n });\n}\n","/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\n/**\n * @packageDocumentation\n * Tools for UI Extensions meant to run inside extensible apps. Connects\n * Extensions running in their own window contexts with the host app, allowing\n * the host and guest to exchange method, events, and signals.\n *\n * @remarks The core object of this library, which extensions use for\n * communication, is the Guest object. There are two variants of the Guest\n * object {@link GuestServer} for the bootstrap frame which your extension keeps\n * running in the background, and {@link GuestUI} for frames meant to be\n * displayed in the host application. An extension must have one GuestServer\n * frame, and the host app may choose to use one or more GuestUI frames.\n *\n * @example Creating and connecting a GuestServer with {@link register}\n * ```typescript\n * import { register } from \"@adobe/uix-guest\";\n *\n * const server = await register({\n * // Must match extension ID from registry\n * id: \"My Custom View Extension\",\n * // enable logging in dev build\n * debug: process.env.NODE_ENV !== \"production\",\n * // Host can access these methods from its Port to this guest\n * methods: {\n * // Methods must be namespaced by one or more levels\n * myCustomView: {\n * async documentIsViewable(docId) {\n * const doc = await callMyRuntimeAction(docId);\n * return someValidation(doc);\n * },\n * renderView(docId, depth) {\n * // Use a host method\n * const tooltip = await server.host.editor.requestTooltip({\n * type: 'frame',\n * url: new URL(`/show/${docId}`, location).href\n * })\n * }\n * },\n * },\n * })\n * ```\n *\n * @example Connecting to an existing GuestServer with a GuestUI\n * ```typescript\n * import { attach } from \"@adobe/uix-guest\";\n *\n * const ui = await attach({\n * id: \"My Custom View Extension\",\n * })\n *\n * // when editing is done:\n * const saved = await ui.host.editor.saveChanges();\n * if (!saved) {\n * const editorState = ui.sharedContext.get('editorState');\n * if (editorState.tooltips[ui.id].invalid === true) {\n * putGuestUIInInvalidState();\n * }\n * } else {\n * ui.host.editor.dismissTooltip();\n * }\n * ```\n *\n */\nimport type { Guest, GuestConfig } from \"./guest.js\";\nimport { GuestUI } from \"./guest-ui.js\";\nimport { GuestServer } from \"./guest-server.js\";\nimport { GuestApis } from \"@adobe/uix-core\";\n\n/**\n * {@inheritdoc GuestConfig}\n * @public\n */\ntype GuestConfigWithMethods<Outgoing extends GuestApis> = GuestConfig & {\n methods: Outgoing;\n};\n\n/**\n * Create and immediately return a {@link GuestServer}.\n *\n * @deprecated Use {@link attach} or {@link register}, which return Promises\n * that resolve once the guest is connected.\n * @public\n */\nexport function createGuest(config: GuestConfig) {\n const guest = new GuestServer(config);\n return guest;\n}\n\n/**\n * Connect to a running {@link GuestServer} to share its context and render UI.\n *\n * @remarks Creates a guest object that shares most of the GuestServer API,\n * except it cannot register its own methods. Use `attach()` in an app or\n * document that is meant to render a UI in the host application; it will have\n * access to the sharedContext object shared by the host and GuestServer.\n *\n * @public\n */\nexport async function attach(config: GuestConfig) {\n const guest = new GuestUI(config);\n await guest._connect();\n return guest;\n}\n\n/**\n * Initiate a connection to the host app and its extension points.\n *\n * @remarks Creates the \"main\" {@link GuestServer}, which runs in the background\n * without UI. Registers methods passed in the `methods` parameter, then\n * resolves the returned Promise with the connected GuestServer object.\n *\n * @public\n */\nexport async function register<Outgoing extends GuestApis>(\n config: GuestConfigWithMethods<Outgoing>\n) {\n const guest = new GuestServer(config);\n await guest.register(config.methods);\n return guest;\n}\n\n// backwards compatibility\nexport {\n Guest,\n Guest as BaseGuest,\n GuestUI,\n GuestUI as UIGuest,\n GuestServer,\n GuestServer as PrimaryGuest,\n};\n","export var MessageType;\n(function (MessageType) {\n MessageType[\"Call\"] = \"call\";\n MessageType[\"Reply\"] = \"reply\";\n MessageType[\"Syn\"] = \"syn\";\n MessageType[\"SynAck\"] = \"synAck\";\n MessageType[\"Ack\"] = \"ack\";\n})(MessageType || (MessageType = {}));\nexport var Resolution;\n(function (Resolution) {\n Resolution[\"Fulfilled\"] = \"fulfilled\";\n Resolution[\"Rejected\"] = \"rejected\";\n})(Resolution || (Resolution = {}));\nexport var ErrorCode;\n(function (ErrorCode) {\n ErrorCode[\"ConnectionDestroyed\"] = \"ConnectionDestroyed\";\n ErrorCode[\"ConnectionTimeout\"] = \"ConnectionTimeout\";\n ErrorCode[\"NoIframeSrc\"] = \"NoIframeSrc\";\n})(ErrorCode || (ErrorCode = {}));\nexport var NativeErrorName;\n(function (NativeErrorName) {\n NativeErrorName[\"DataCloneError\"] = \"DataCloneError\";\n})(NativeErrorName || (NativeErrorName = {}));\nexport var NativeEventType;\n(function (NativeEventType) {\n NativeEventType[\"Message\"] = \"message\";\n})(NativeEventType || (NativeEventType = {}));\n","export default (localName, log) => {\n const callbacks = [];\n let destroyed = false;\n return {\n destroy(error) {\n if (!destroyed) {\n destroyed = true;\n log(`${localName}: Destroying connection`);\n callbacks.forEach((callback) => {\n callback(error);\n });\n }\n },\n onDestroy(callback) {\n destroyed ? callback() : callbacks.push(callback);\n },\n };\n};\n","export default (debug) => {\n /**\n * Logs a message if debug is enabled.\n */\n return (...args) => {\n if (debug) {\n console.log('[Penpal]', ...args); // eslint-disable-line no-console\n }\n };\n};\n","/**\n * Converts an error object into a plain object.\n */\nexport const serializeError = ({ name, message, stack, }) => ({\n name,\n message,\n stack,\n});\n/**\n * Converts a plain object into an error object.\n */\nexport const deserializeError = (obj) => {\n const deserializedError = new Error();\n // @ts-ignore\n Object.keys(obj).forEach((key) => (deserializedError[key] = obj[key]));\n return deserializedError;\n};\n","import { serializeError } from './errorSerialization';\nimport { MessageType, NativeEventType, NativeErrorName, Resolution, } from './enums';\n/**\n * Listens for \"call\" messages coming from the remote, executes the corresponding method, and\n * responds with the return value.\n */\nexport default (info, serializedMethods, log) => {\n const { localName, local, remote, originForSending, originForReceiving, } = info;\n let destroyed = false;\n const handleMessageEvent = (event) => {\n if (event.source !== remote || event.data.penpal !== MessageType.Call) {\n return;\n }\n if (originForReceiving !== '*' && event.origin !== originForReceiving) {\n log(`${localName} received message from origin ${event.origin} which did not match expected origin ${originForReceiving}`);\n return;\n }\n const callMessage = event.data;\n const { methodName, args, id } = callMessage;\n log(`${localName}: Received ${methodName}() call`);\n const createPromiseHandler = (resolution) => {\n return (returnValue) => {\n log(`${localName}: Sending ${methodName}() reply`);\n if (destroyed) {\n // It's possible to throw an error here, but it would need to be thrown asynchronously\n // and would only be catchable using window.onerror. This is because the consumer\n // is merely returning a value from their method and not calling any function\n // that they could wrap in a try-catch. Even if the consumer were to catch the error,\n // the value of doing so is questionable. Instead, we'll just log a message.\n log(`${localName}: Unable to send ${methodName}() reply due to destroyed connection`);\n return;\n }\n const message = {\n penpal: MessageType.Reply,\n id,\n resolution,\n returnValue,\n };\n if (resolution === Resolution.Rejected &&\n returnValue instanceof Error) {\n message.returnValue = serializeError(returnValue);\n message.returnValueIsError = true;\n }\n try {\n remote.postMessage(message, originForSending);\n }\n catch (err) {\n // If a consumer attempts to send an object that's not cloneable (e.g., window),\n // we want to ensure the receiver's promise gets rejected.\n if (err.name === NativeErrorName.DataCloneError) {\n const errorReplyMessage = {\n penpal: MessageType.Reply,\n id,\n resolution: Resolution.Rejected,\n returnValue: serializeError(err),\n returnValueIsError: true,\n };\n remote.postMessage(errorReplyMessage, originForSending);\n }\n throw err;\n }\n };\n };\n new Promise((resolve) => resolve(serializedMethods[methodName].apply(serializedMethods, args))).then(createPromiseHandler(Resolution.Fulfilled), createPromiseHandler(Resolution.Rejected));\n };\n local.addEventListener(NativeEventType.Message, handleMessageEvent);\n return () => {\n destroyed = true;\n local.removeEventListener(NativeEventType.Message, handleMessageEvent);\n };\n};\n","let id = 0;\n/**\n * @return {number} A unique ID (not universally unique)\n */\nexport default () => ++id;\n","const KEY_PATH_DELIMITER = '.';\nconst keyPathToSegments = (keyPath) => keyPath ? keyPath.split(KEY_PATH_DELIMITER) : [];\nconst segmentsToKeyPath = (segments) => segments.join(KEY_PATH_DELIMITER);\nconst createKeyPath = (key, prefix) => {\n const segments = keyPathToSegments(prefix || '');\n segments.push(key);\n return segmentsToKeyPath(segments);\n};\n/**\n * Given a `keyPath`, set it to be `value` on `subject`, creating any intermediate\n * objects along the way.\n *\n * @param {Object} subject The object on which to set value.\n * @param {string} keyPath The key path at which to set value.\n * @param {Object} value The value to store at the given key path.\n * @returns {Object} Updated subject.\n */\nexport const setAtKeyPath = (subject, keyPath, value) => {\n const segments = keyPathToSegments(keyPath);\n segments.reduce((prevSubject, key, idx) => {\n if (typeof prevSubject[key] === 'undefined') {\n prevSubject[key] = {};\n }\n if (idx === segments.length - 1) {\n prevSubject[key] = value;\n }\n return prevSubject[key];\n }, subject);\n return subject;\n};\n/**\n * Given a dictionary of (nested) keys to function, flatten them to a map\n * from key path to function.\n *\n * @param {Object} methods The (potentially nested) object to serialize.\n * @param {string} prefix A string with which to prefix entries. Typically not intended to be used by consumers.\n * @returns {Object} An map from key path in `methods` to functions.\n */\nexport const serializeMethods = (methods, prefix) => {\n const flattenedMethods = {};\n Object.keys(methods).forEach((key) => {\n const value = methods[key];\n const keyPath = createKeyPath(key, prefix);\n if (typeof value === 'object') {\n // Recurse into any nested children.\n Object.assign(flattenedMethods, serializeMethods(value, keyPath));\n }\n if (typeof value === 'function') {\n // If we've found a method, expose it.\n flattenedMethods[keyPath] = value;\n }\n });\n return flattenedMethods;\n};\n/**\n * Given a map of key paths to functions, unpack the key paths to an object.\n *\n * @param {Object} flattenedMethods A map of key paths to functions to unpack.\n * @returns {Object} A (potentially nested) map of functions.\n */\nexport const deserializeMethods = (flattenedMethods) => {\n const methods = {};\n for (const keyPath in flattenedMethods) {\n setAtKeyPath(methods, keyPath, flattenedMethods[keyPath]);\n }\n return methods;\n};\n","import generateId from './generateId';\nimport { deserializeError } from './errorSerialization';\nimport { deserializeMethods } from './methodSerialization';\nimport { ErrorCode, MessageType, NativeEventType, Resolution } from './enums';\n/**\n * Augments an object with methods that match those defined by the remote. When these methods are\n * called, a \"call\" message will be sent to the remote, the remote's corresponding method will be\n * executed, and the method's return value will be returned via a message.\n * @param {Object} callSender Sender object that should be augmented with methods.\n * @param {Object} info Information about the local and remote windows.\n * @param {Array} methodKeyPaths Key paths of methods available to be called on the remote.\n * @param {Promise} destructionPromise A promise resolved when destroy() is called on the penpal\n * connection.\n * @returns {Object} The call sender object with methods that may be called.\n */\nexport default (callSender, info, methodKeyPaths, destroyConnection, log) => {\n const { localName, local, remote, originForSending, originForReceiving, } = info;\n let destroyed = false;\n log(`${localName}: Connecting call sender`);\n const createMethodProxy = (methodName) => {\n return (...args) => {\n log(`${localName}: Sending ${methodName}() call`);\n // This handles the case where the iframe has been removed from the DOM\n // (and therefore its window closed), the consumer has not yet\n // called destroy(), and the user calls a method exposed by\n // the remote. We detect the iframe has been removed and force\n // a destroy() immediately so that the consumer sees the error saying\n // the connection has been destroyed. We wrap this check in a try catch\n // because Edge throws an \"Object expected\" error when accessing\n // contentWindow.closed on a contentWindow from an iframe that's been\n // removed from the DOM.\n let iframeRemoved;\n try {\n if (remote.closed) {\n iframeRemoved = true;\n }\n }\n catch (e) {\n iframeRemoved = true;\n }\n if (iframeRemoved) {\n destroyConnection();\n }\n if (destroyed) {\n const error = new Error(`Unable to send ${methodName}() call due ` + `to destroyed connection`);\n error.code = ErrorCode.ConnectionDestroyed;\n throw error;\n }\n return new Promise((resolve, reject) => {\n const id = generateId();\n const handleMessageEvent = (event) => {\n if (event.source !== remote ||\n event.data.penpal !== MessageType.Reply ||\n event.data.id !== id) {\n return;\n }\n if (originForReceiving !== '*' &&\n event.origin !== originForReceiving) {\n log(`${localName} received message from origin ${event.origin} which did not match expected origin ${originForReceiving}`);\n return;\n }\n const replyMessage = event.data;\n log(`${localName}: Received ${methodName}() reply`);\n local.removeEventListener(NativeEventType.Message, handleMessageEvent);\n let returnValue = replyMessage.returnValue;\n if (replyMessage.returnValueIsError) {\n returnValue = deserializeError(returnValue);\n }\n (replyMessage.resolution === Resolution.Fulfilled ? resolve : reject)(returnValue);\n };\n local.addEventListener(NativeEventType.Message, handleMessageEvent);\n const callMessage = {\n penpal: MessageType.Call,\n id,\n methodName,\n args,\n };\n remote.postMessage(callMessage, originForSending);\n });\n };\n };\n // Wrap each method in a proxy which sends it to the corresponding receiver.\n const flattenedMethods = methodKeyPaths.reduce((api, name) => {\n api[name] = createMethodProxy(name);\n return api;\n }, {});\n // Unpack the structure of the provided methods object onto the CallSender, exposing\n // the methods in the same shape they were provided.\n Object.assign(callSender, deserializeMethods(flattenedMethods));\n return () => {\n destroyed = true;\n };\n};\n","import { ErrorCode } from './enums';\n/**\n * Starts a timeout and calls the callback with an error\n * if the timeout completes before the stop function is called.\n */\nexport default (timeout, callback) => {\n let timeoutId;\n if (timeout !== undefined) {\n timeoutId = window.setTimeout(() => {\n const error = new Error(`Connection timed out after ${timeout}ms`);\n error.code = ErrorCode.ConnectionTimeout;\n callback(error);\n }, timeout);\n }\n return () => {\n clearTimeout(timeoutId);\n };\n};\n","import { MessageType } from '../enums';\nimport connectCallReceiver from '../connectCallReceiver';\nimport connectCallSender from '../connectCallSender';\n/**\n * Handles a SYN-ACK handshake message.\n */\nexport default (parentOrigin, serializedMethods, destructor, log) => {\n const { destroy, onDestroy } = destructor;\n return (event) => {\n let originQualifies = parentOrigin instanceof RegExp\n ? parentOrigin.test(event.origin)\n : parentOrigin === '*' || parentOrigin === event.origin;\n if (!originQualifies) {\n log(`Child: Handshake - Received SYN-ACK from origin ${event.origin} which did not match expected origin ${parentOrigin}`);\n return;\n }\n log('Child: Handshake - Received SYN-ACK, responding with ACK');\n // If event.origin is \"null\", the remote protocol is file: or data: and we\n // must post messages with \"*\" as targetOrigin when sending messages.\n // https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage#Using_window.postMessage_in_extensions\n const originForSending = event.origin === 'null' ? '*' : event.origin;\n const ackMessage = {\n penpal: MessageType.Ack,\n methodNames: Object.keys(serializedMethods),\n };\n window.parent.postMessage(ackMessage, originForSending);\n const info = {\n localName: 'Child',\n local: window,\n remote: window.parent,\n originForSending,\n originForReceiving: event.origin,\n };\n const destroyCallReceiver = connectCallReceiver(info, serializedMethods, log);\n onDestroy(destroyCallReceiver);\n const callSender = {};\n const destroyCallSender = connectCallSender(callSender, info, event.data.methodNames, destroy, log);\n onDestroy(destroyCallSender);\n return callSender;\n };\n};\n","import createDestructor from '../createDestructor';\nimport createLogger from '../createLogger';\nimport { MessageType, NativeEventType } from '../enums';\nimport handleSynAckMessageFactory from './handleSynAckMessageFactory';\nimport { serializeMethods } from '../methodSerialization';\nimport startConnectionTimeout from '../startConnectionTimeout';\nconst areGlobalsAccessible = () => {\n try {\n clearTimeout();\n }\n catch (e) {\n return false;\n }\n return true;\n};\n/**\n * Attempts to establish communication with the parent window.\n */\nexport default (options = {}) => {\n const { parentOrigin = '*', methods = {}, timeout, debug = false } = options;\n const log = createLogger(debug);\n const destructor = createDestructor('Child', log);\n const { destroy, onDestroy } = destructor;\n const serializedMethods = serializeMethods(methods);\n const handleSynAckMessage = handleSynAckMessageFactory(parentOrigin, serializedMethods, destructor, log);\n const sendSynMessage = () => {\n log('Child: Handshake - Sending SYN');\n const synMessage = { penpal: MessageType.Syn };\n const parentOriginForSyn = parentOrigin instanceof RegExp ? '*' : parentOrigin;\n window.parent.postMessage(synMessage, parentOriginForSyn);\n };\n const promise = new Promise((resolve, reject) => {\n const stopConnectionTimeout = startConnectionTimeout(timeout, destroy);\n const handleMessage = (event) => {\n // Under niche scenarios, we get into this function after\n // the iframe has been removed from the DOM. In Edge, this\n // results in \"Object expected\" errors being thrown when we\n // try to access properties on window (global properties).\n // For this reason, we try to access a global up front (clearTimeout)\n // and if it fails we can assume the iframe has been removed\n // and we ignore the message event.\n if (!areGlobalsAccessible()) {\n return;\n }\n if (event.source !== parent || !event.data) {\n return;\n }\n if (event.data.penpal === MessageType.SynAck) {\n const callSender = handleSynAckMessage(event);\n if (callSender) {\n window.removeEventListener(NativeEventType.Message, handleMessage);\n stopConnectionTimeout();\n resolve(callSender);\n }\n }\n };\n window.addEventListener(NativeEventType.Message, handleMessage);\n sendSynMessage();\n onDestroy((error) => {\n window.removeEventListener(NativeEventType.Message, handleMessage);\n if (error) {\n reject(error);\n }\n });\n });\n return {\n promise,\n destroy() {\n // Don't allow consumer to pass an error into destroy.\n destroy();\n },\n };\n};\n","/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\n/* eslint @typescript-eslint/no-explicit-any: \"off\" */\nimport { Connection, connectToParent } from \"penpal\";\nimport type {\n RemoteHostApis,\n HostConnection,\n NamedEvent,\n VirtualApi,\n} from \"@adobe/uix-core\";\nimport {\n Emitter,\n makeNamespaceProxy,\n timeoutPromise,\n quietConsole,\n} from \"@adobe/uix-core\";\nimport { debugGuest } from \"./debug-guest.js\";\n\n/**\n * @public\n */\nexport type GuestEvent<\n Type extends string = string,\n Detail = Record<string, unknown>\n> = NamedEvent<\n Type,\n Detail &\n Record<string, unknown> & {\n guest: Guest;\n }\n>;\n\n/**\n * @public\n */\nexport type GuestEventContextChange = GuestEvent<\n \"contextchange\",\n { context: Record<string, unknown> }\n>;\n\n/** @public */\nexport type GuestEventBeforeConnect = GuestEvent<\"beforeconnect\">;\n/** @public */\nexport type GuestEventConnected = GuestEvent<\n \"connected\",\n { connection: Connection }\n>;\n/** @public */\nexport type GuestEventError = GuestEvent<\"error\", { error: Error }>;\n\n/**\n * @public\n */\nexport type GuestEvents =\n | GuestEventContextChange\n | GuestEventBeforeConnect\n | GuestEventConnected\n | GuestEventError;\n\n/**\n * @public\n */\nexport interface GuestConfig {\n /**\n * String slug identifying extension. This may need to use IDs from an\n * external system in the future.\n */\n id: string;\n /**\n * Set debug flags on all libraries that have them, and add loggers to SDK\n * objects. Log a lot to the console.\n */\n debug?: boolean;\n /**\n * Time out and stop trying to reach the host after this many milliseconds\n */\n timeout?: number;\n}\n\n/**\n * A `Map` representing the {@link @adobe/uix-host#HostConfig.sharedContext}\n * object.\n *\n * @remarks While the Host object is a plain JavaScript object. the `sharedContext` in the Guest object implements the {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map | Map} interface.\n *\n * @example\n * In the host app window, the Host object shares context:\n * ```javascript\n *host.shareContext({\n * someAuthToken: 'abc'\n *});\n * ```\n *\n * After the `contentchange` event has fired in the guest window:\n * ```javascript\n * guest.sharedContext.get('someAuthToken') === 'abc'\n * ```\n * @public\n */\nexport class SharedContext {\n private _map: Map<string, unknown>;\n constructor(values: Record<string, unknown>) {\n this.reset(values);\n }\n private reset(values: Record<string, unknown>) {\n this._map = new Map(Object.entries(values));\n }\n /**\n * @public\n * Retrieve a copy of a value from the {@link @adobe/uix-host#HostConfig.sharedContext} object. *Note that this is not a reference to any actual objects from the parent. If the parent updates an \"inner object\" inside the SharedContext, that change will not be reflected in the Guest!*\n */\n get(key: string) {\n return this._map.get(key);\n }\n}\n\n/**\n * Generic Guest object, with methods shared by all types of Guest.\n * @internal\n */\nexport class Guest<\n Incoming extends object = VirtualApi\n> extends Emitter<GuestEvents> {\n /**\n * Shared context has been set or updated.\n * @eventProperty\n */\n public contextchange: GuestEventContextChange;\n /**\n * About to attempt connection to the host.\n * @eventProperty\n */\n public beforeconnect: GuestEventBeforeConnect;\n /**\n * Host connection has been established.\n * @eventProperty\n */\n public connected: GuestEventConnected;\n /**\n * Host connection has failed.\n * @eventProperty\n */\n public error: GuestEventError;\n /**\n * {@inheritdoc SharedContext}\n */\n sharedContext: SharedContext;\n private debugLogger: Console = quietConsole;\n\n /**\n * @param config - Initializer for guest object, including ID.\n */\n constructor(config: GuestConfig) {\n super(config.id);\n if (typeof config.timeout === \"number\") {\n this.timeout = config.timeout;\n }\n if (config.debug) {\n this.debugLogger = debugGuest(this);\n }\n this.addEventListener(\"contextchange\", (event) => {\n this.sharedContext = new SharedContext(event.detail.context);\n });\n }\n /**\n * Proxy object for calling methods on the host.\n *\n * @remarks Any APIs exposed to the extension via {@link @adobe/uix-host#Port.provide}\n * can be called on this object. Because these methods are called with RPC,\n * they are all asynchronous, The return types of all Host methods will be\n * Promises which resolve to the value the Host method returns.\n * @public\n */\n host: RemoteHostApis<Incoming> = makeNamespaceProxy<Incoming>(\n async (address) => {\n await this.hostConnectionPromise;\n try {\n const result = await timeoutPromise(\n 10000,\n this.hostConnection.invokeHostMethod(address)\n );\n return result;\n } catch (e) {\n const error =\n e instanceof Error ? e : new Error(e as unknown as string);\n const methodError = new Error(\n `Host method call host.${address.path.join(\".\")}() failed: ${\n error.message\n }`\n );\n this.debugLogger.error(methodError);\n throw methodError;\n }\n }\n );\n private timeout = 10000;\n private hostConnectionPromise: Promise<RemoteHostApis<HostConnection>>;\n private hostConnection!: RemoteHostApis<HostConnection>;\n /** @internal */\n protected getLocalMethods() {\n return {\n emit: (...args: Parameters<typeof this.emit>) => {\n this.debugLogger.log(`Event \"${args[0]}\" emitted from host`);\n this.emit(...args);\n },\n };\n }\n /**\n * Accept a connection from the Host.\n * @returns A Promise that resolves when the Host has established a connection.\n * @deprecated It is preferable to use {@link register} for primary frames,\n * and {@link attach} for UI frames and other secondary frames, than to\n * instantiate a Guest and then call `.connect()` on it. The latter style\n * returns an object that cannot be used until it is connected, and therefore\n * risks errors.\n * @public\n */\n async connect() {\n return this._connect();\n }\n\n /**\n * @internal\n */\n async _connect() {\n this.emit(\"beforeconnect\", { guest: this });\n try {\n const connection = connectToParent<HostConnection<Incoming>>({\n timeout: this.timeout,\n methods: this.getLocalMethods(),\n });\n\n this.hostConnectionPromise = connection.promise;\n this.hostConnection = await this.hostConnectionPromise;\n this.sharedContext = new SharedContext(\n await this.hostConnection.getSharedContext()\n );\n this.debugLogger.log(\"retrieved sharedContext\", this.sharedContext);\n this.emit(\"connected\", { guest: this, connection });\n } catch (e) {\n this.emit(\"error\", { guest: this, error: e });\n this.debugLogger.error(\"Connection failed!\", e);\n }\n }\n}\n","/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\n/**\n * Adapter to attach console logging listeners to a Guest running in a frame/\n * @internal @preapproved\n */\nimport { debugEmitter, Emits, EmitterDebugLogger } from \"@adobe/uix-core\";\nimport { GuestEvents } from \"./guest\";\n\nexport function debugGuest(guest: Emits<GuestEvents>): EmitterDebugLogger {\n return debugEmitter(guest, {\n theme: \"yellow medium\",\n type: \"Guest\",\n })\n .listen(\"beforeconnect\", (log, { detail: { guest } }) => {\n log.info(guest);\n })\n .listen(\"connecting\", (log, { detail: { connection } }) => {\n log.info(connection);\n })\n .listen(\"connected\", (log, { detail: { guest } }) => {\n log.info(guest);\n })\n .listen(\"error\", (log, { detail: { error, guest } }) => {\n log.error(\n \"❌ Failed to connect! %s\",\n (error as Error).message,\n guest,\n error\n );\n });\n}\n","/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport type { RemoteHostApis, VirtualApi } from \"@adobe/uix-core\";\nimport {\n Guest,\n GuestConfig,\n GuestEventBeforeConnect,\n GuestEventConnected,\n GuestEventContextChange,\n GuestEventError,\n} from \"./guest\";\n\n/**\n * A Guest to be used in an extension-controlled frame, usually to display UI.\n *\n * @typeParam Incoming - Optional interface of host methods. If using\n * TypeScript, supply this type parameter and a promisified version of the\n * interface will be available at {@link Guest.host}\n *\n * @remarks\n * This is the object returned when calling {@link @adobe/uix-guest#attach}. It\n * represents an additional frame or runtime created by the host application, on\n * behalf of the extension's control frame which is running the {@link\n * GuestServer}. It is a \"secondary\" guest object, which a host won't use before\n * the control frame has connected. It exposes a subset of the functionality of\n * the {@link GuestServer}.\n *\n * Unlike the {@link GuestServer}, it cannot register methods or update the\n * {@link Guest.sharedContext}, but it remains in sync with the GuestServer and\n * can access the {@link Guest.sharedContext} of the control frame, as well as\n * any of the published methods on the host.\n *\n * Extensible host apps using the React bindings will likely render GuestUI\n * frames using the {@link @adobe/uix-host-react#GuestUIFrame} component.\n *\n * @example\n * When an extensible app renders this page, {@link @adobe/uix-guest#attach}\n * creates a GuestUI. Once it attaches to the host, it\n * ```javascript\n * import React, { useEffect, useState } from \"react\";\n * import { attach } from \"@adobe/uix-guest\";\n * import { Tooltip } from \"./tooltip\";\n *\n * export default function PopupOverlay(props) {\n * // how large am I?\n * const [dimensions, setDimensions] = useState(\n * document.body.getBoundingClientRect()\n * );\n * // if possible, use language preloaded in query parameters\n * const [language, setLanguage] = useState(props.params.lang)\n *\n * // attach only once, in a useEffect\n * useEffect(() => {\n * attach({\n * id: \"my-extension-id\",\n * debug: true,\n * })\n * .then(guestUI => {\n * // this event fires whenever the host, or the control frame, changes\n * // any sharedContext value\n * guestUI.addEventListener(\"contextchange\", ({ detail: { context }}) => {\n * setLanguage(context.lang)\n * });\n * // how large does the host want me to be?\n * return guestUI.host.tooltips.getDimensions()\n * .then(setDimensions)\n * })\n * .catch((e) => {\n * console.error(\"ui attach failed\", e);\n * });\n * }, []);\n * // render UI! Due to the setup and useState, this component will re-render\n * // once attach() is complete.\n * return (\n * <Tooltip {...props.params} lang={language} dimensions={dimensions} />\n * );\n * }\n * ```\n *\n * @public\n */\nexport class GuestUI<IHost extends VirtualApi> extends Guest<IHost> {\n /**\n * {@inheritDoc Guest.\"constructor\"}\n */\n constructor(config: GuestConfig) {\n super(config);\n }\n /**\n * {@inheritDoc Guest.contextchange}\n * @eventProperty\n */\n public contextchange: GuestEventContextChange;\n /**\n * {@inheritDoc Guest.beforeconnect}\n * @eventProperty\n */\n public beforeconnect: GuestEventBeforeConnect;\n /**\n * {@inheritDoc Guest.connected}\n * @eventProperty\n */\n public connected: GuestEventConnected;\n /**\n * {@inheritDoc Guest.error}\n * @eventProperty\n */\n public error: GuestEventError;\n /**\n * {@inheritDoc Guest.host}\n */\n host: RemoteHostApis<IHost>;\n}\n","/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport type { GuestApis } from \"@adobe/uix-core\";\nimport type { SharedContext } from \"./guest\";\nimport { Guest } from \"./guest\";\n\n/**\n * A Guest to be used in the \"main\" or primary frame of an extension, the frame\n * the Host loads first.\n *\n * @remarks This is the Guest object returned from {@link register}. It can\n * expose internal methods to the Host via the {@link GuestServer.register}\n * method.\n *\n *\n * @public\n */\nexport class GuestServer<Outgoing extends GuestApis> extends Guest<Outgoing> {\n private localMethods: Outgoing;\n protected getLocalMethods() {\n return {\n ...super.getLocalMethods(),\n apis: this.localMethods,\n };\n }\n /**\n * {@inheritDoc BaseGuest.sharedContext}\n */\n sharedContext: SharedContext;\n /**\n * {@inheritdoc BaseGuest.host}\n */\n host: Guest<Outgoing>[\"host\"];\n /**\n * Pass an interface of methods which Host may call as callbacks.\n *\n * @remarks It is preferable to use {@link register} to obtain a guest object\n * and register local methods in one step. The returned guest object will be\n * pre-registered and connected.\n * @public\n */\n async register(implementedMethods: Outgoing) {\n this.localMethods = implementedMethods;\n return this._connect();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CwC,UACtC,aAAQ,MAAA,OAAA,OAAA,eAAA,cAAA,OAAA,WAAA,8BAAA,EAAA;AAAA,UACN,UAAM;QAA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AAA,EACF;;;AEnKO,MAAM,UAAN,cAAgDC,OAAa;AAAA,IAIlE,YAAY,QAAqB;AAC/B,YAAM,MAAM;AAAA,IACd;AAAA,EAyBF;;;AC/FO,MAAM,cAAN,cAAsDC,OAAgB;AAAA,IAEjE,kBAAkB;AAC1B,aAAO;AAAA,QACL,GAAG,MAAM,gBAAgB;AAAA,QACzB,MAAM,KAAK;AAAA,MACb;AAAA,IACF;AAAA,IAiBA,MAAM,SAAS,oBAA8B;AAC3C,WAAK,eAAe;AACpB,aAAO,KAAK,SAAS;AAAA,IACvB;AAAA,EACF;;;AfwCO,WAAS,YAAY,QAAqB;AAC/C,UAAM,QAAQ,IAAI,YAAY,MAAM;AACpC,WAAO;AAAA,EACT;AAYA,iBAAsB,OAAO,QAAqB;AAChD,UAAM,QAAQ,IAAI,QAAQ,MAAM;AAChC,UAAM,MAAM,SAAS;AACrB,WAAO;AAAA,EACT;AAWA,iBAAsB,SACpB,QACA;AACA,UAAM,QAAQ,IAAI,YAAY,MAAM;AACpC,UAAM,MAAM,SAAS,OAAO,OAAO;AACnC,WAAO;AAAA,EACT;","names":["quietConsole","debugEmitter","Emitter","id","makeNamespaceProxy","target","timeoutPromise","MessageType","Resolution","ErrorCode","NativeErrorName","NativeEventType","id","id","import_uix_core","guest","Guest","Guest","Guest"]}
package/package.json CHANGED
@@ -1,18 +1,16 @@
1
1
  {
2
2
  "name": "@adobe/uix-guest",
3
- "version": "0.6.5-0",
3
+ "version": "0.6.5",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
4
7
  "description": "Tools for connecting to UIX Host apps from extension apps",
5
8
  "author": "Adobe, Inc,",
6
- "type": "module",
7
- "module": "dist/esm/index.js",
8
9
  "main": "dist/index.js",
9
- "exports": {
10
- "import": "./dist/esm/index.js",
11
- "require": "./dist/index.js"
12
- },
13
10
  "types": "dist/index.d.ts",
14
11
  "scripts": {
15
12
  "build": "tsup",
13
+ "build:esm": "tsup --format esm,cjs,iife",
16
14
  "watch": "tsup --watch --silent"
17
15
  },
18
16
  "browserslist": [
@@ -20,7 +18,7 @@
20
18
  ],
21
19
  "bugs": "https://github.com/adobe/uix-sdk/issues",
22
20
  "dependencies": {
23
- "@adobe/uix-core": "^0.6.5-0",
21
+ "@adobe/uix-core": "^0.6.5",
24
22
  "penpal": "~6.2.2"
25
23
  },
26
24
  "files": [
package/dist/esm/index.js DELETED
@@ -1,155 +0,0 @@
1
- // src/guest.ts
2
- import { connectToParent } from "penpal";
3
- import {
4
- Emitter,
5
- makeNamespaceProxy,
6
- timeoutPromise,
7
- quietConsole
8
- } from "@adobe/uix-core";
9
-
10
- // src/debug-guest.ts
11
- import { debugEmitter } from "@adobe/uix-core";
12
- function debugGuest(guest) {
13
- return debugEmitter(guest, {
14
- theme: "yellow medium",
15
- type: "Guest"
16
- }).listen("beforeconnect", (log, { detail: { guest: guest2 } }) => {
17
- log.info(guest2);
18
- }).listen("connecting", (log, { detail: { connection } }) => {
19
- log.info(connection);
20
- }).listen("connected", (log, { detail: { guest: guest2 } }) => {
21
- log.info(guest2);
22
- }).listen("error", (log, { detail: { error, guest: guest2 } }) => {
23
- log.error(
24
- "\u274C Failed to connect! %s",
25
- error.message,
26
- guest2,
27
- error
28
- );
29
- });
30
- }
31
-
32
- // src/guest.ts
33
- var SharedContext = class {
34
- constructor(values) {
35
- this.reset(values);
36
- }
37
- reset(values) {
38
- this._map = new Map(Object.entries(values));
39
- }
40
- get(key) {
41
- return this._map.get(key);
42
- }
43
- };
44
- var Guest2 = class extends Emitter {
45
- constructor(config) {
46
- super(config.id);
47
- this.debugLogger = quietConsole;
48
- this.host = makeNamespaceProxy(
49
- async (address) => {
50
- await this.hostConnectionPromise;
51
- try {
52
- const result = await timeoutPromise(
53
- 1e4,
54
- this.hostConnection.invokeHostMethod(address)
55
- );
56
- return result;
57
- } catch (e) {
58
- const error = e instanceof Error ? e : new Error(e);
59
- const methodError = new Error(
60
- `Host method call host.${address.path.join(".")}() failed: ${error.message}`
61
- );
62
- this.debugLogger.error(methodError);
63
- throw methodError;
64
- }
65
- }
66
- );
67
- this.timeout = 1e4;
68
- if (typeof config.timeout === "number") {
69
- this.timeout = config.timeout;
70
- }
71
- if (config.debug) {
72
- this.debugLogger = debugGuest(this);
73
- }
74
- this.addEventListener("contextchange", (event) => {
75
- this.sharedContext = new SharedContext(event.detail.context);
76
- });
77
- }
78
- getLocalMethods() {
79
- return {
80
- emit: (...args) => {
81
- this.debugLogger.log(`Event "${args[0]}" emitted from host`);
82
- this.emit(...args);
83
- }
84
- };
85
- }
86
- async connect() {
87
- return this._connect();
88
- }
89
- async _connect() {
90
- this.emit("beforeconnect", { guest: this });
91
- try {
92
- const connection = connectToParent({
93
- timeout: this.timeout,
94
- methods: this.getLocalMethods()
95
- });
96
- this.hostConnectionPromise = connection.promise;
97
- this.hostConnection = await this.hostConnectionPromise;
98
- this.sharedContext = new SharedContext(
99
- await this.hostConnection.getSharedContext()
100
- );
101
- this.debugLogger.log("retrieved sharedContext", this.sharedContext);
102
- this.emit("connected", { guest: this, connection });
103
- } catch (e) {
104
- this.emit("error", { guest: this, error: e });
105
- this.debugLogger.error("Connection failed!", e);
106
- }
107
- }
108
- };
109
-
110
- // src/guest-ui.ts
111
- var GuestUI = class extends Guest2 {
112
- constructor(config) {
113
- super(config);
114
- }
115
- };
116
-
117
- // src/guest-server.ts
118
- var GuestServer = class extends Guest2 {
119
- getLocalMethods() {
120
- return {
121
- ...super.getLocalMethods(),
122
- apis: this.localMethods
123
- };
124
- }
125
- async register(implementedMethods) {
126
- this.localMethods = implementedMethods;
127
- return this._connect();
128
- }
129
- };
130
-
131
- // src/index.ts
132
- function createGuest(config) {
133
- const guest = new GuestServer(config);
134
- return guest;
135
- }
136
- async function attach(config) {
137
- const guest = new GuestUI(config);
138
- await guest._connect();
139
- return guest;
140
- }
141
- async function register(config) {
142
- const guest = new GuestServer(config);
143
- await guest.register(config.methods);
144
- return guest;
145
- }
146
- export {
147
- GuestServer,
148
- GuestUI,
149
- GuestServer as PrimaryGuest,
150
- GuestUI as UIGuest,
151
- attach,
152
- createGuest,
153
- register
154
- };
155
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/guest.ts","../../src/debug-guest.ts","../../src/guest-ui.ts","../../src/guest-server.ts","../../src/index.ts"],"sourcesContent":["/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\n/* eslint @typescript-eslint/no-explicit-any: \"off\" */\nimport { Connection, connectToParent } from \"penpal\";\nimport type {\n RemoteHostApis,\n HostConnection,\n NamedEvent,\n VirtualApi,\n} from \"@adobe/uix-core\";\nimport {\n Emitter,\n makeNamespaceProxy,\n timeoutPromise,\n quietConsole,\n} from \"@adobe/uix-core\";\nimport { debugGuest } from \"./debug-guest.js\";\n\n/**\n * @public\n */\nexport type GuestEvent<\n Type extends string = string,\n Detail = Record<string, unknown>\n> = NamedEvent<\n Type,\n Detail &\n Record<string, unknown> & {\n guest: Guest;\n }\n>;\n\n/**\n * @public\n */\nexport type GuestEventContextChange = GuestEvent<\n \"contextchange\",\n { context: Record<string, unknown> }\n>;\n\n/** @public */\nexport type GuestEventBeforeConnect = GuestEvent<\"beforeconnect\">;\n/** @public */\nexport type GuestEventConnected = GuestEvent<\n \"connected\",\n { connection: Connection }\n>;\n/** @public */\nexport type GuestEventError = GuestEvent<\"error\", { error: Error }>;\n\n/**\n * @public\n */\nexport type GuestEvents =\n | GuestEventContextChange\n | GuestEventBeforeConnect\n | GuestEventConnected\n | GuestEventError;\n\n/**\n * @public\n */\nexport interface GuestConfig {\n /**\n * String slug identifying extension. This may need to use IDs from an\n * external system in the future.\n */\n id: string;\n /**\n * Set debug flags on all libraries that have them, and add loggers to SDK\n * objects. Log a lot to the console.\n */\n debug?: boolean;\n /**\n * Time out and stop trying to reach the host after this many milliseconds\n */\n timeout?: number;\n}\n\n/**\n * A `Map` representing the {@link @adobe/uix-host#HostConfig.sharedContext}\n * object.\n *\n * @remarks While the Host object is a plain JavaScript object. the `sharedContext` in the Guest object implements the {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map | Map} interface.\n *\n * @example\n * In the host app window, the Host object shares context:\n * ```javascript\n *host.shareContext({\n * someAuthToken: 'abc'\n *});\n * ```\n *\n * After the `contentchange` event has fired in the guest window:\n * ```javascript\n * guest.sharedContext.get('someAuthToken') === 'abc'\n * ```\n * @public\n */\nexport class SharedContext {\n private _map: Map<string, unknown>;\n constructor(values: Record<string, unknown>) {\n this.reset(values);\n }\n private reset(values: Record<string, unknown>) {\n this._map = new Map(Object.entries(values));\n }\n /**\n * @public\n * Retrieve a copy of a value from the {@link @adobe/uix-host#HostConfig.sharedContext} object. *Note that this is not a reference to any actual objects from the parent. If the parent updates an \"inner object\" inside the SharedContext, that change will not be reflected in the Guest!*\n */\n get(key: string) {\n return this._map.get(key);\n }\n}\n\n/**\n * Generic Guest object, with methods shared by all types of Guest.\n * @internal\n */\nexport class Guest<\n Incoming extends object = VirtualApi\n> extends Emitter<GuestEvents> {\n /**\n * Shared context has been set or updated.\n * @eventProperty\n */\n public contextchange: GuestEventContextChange;\n /**\n * About to attempt connection to the host.\n * @eventProperty\n */\n public beforeconnect: GuestEventBeforeConnect;\n /**\n * Host connection has been established.\n * @eventProperty\n */\n public connected: GuestEventConnected;\n /**\n * Host connection has failed.\n * @eventProperty\n */\n public error: GuestEventError;\n /**\n * {@inheritdoc SharedContext}\n */\n sharedContext: SharedContext;\n private debugLogger: Console = quietConsole;\n\n /**\n * @param config - Initializer for guest object, including ID.\n */\n constructor(config: GuestConfig) {\n super(config.id);\n if (typeof config.timeout === \"number\") {\n this.timeout = config.timeout;\n }\n if (config.debug) {\n this.debugLogger = debugGuest(this);\n }\n this.addEventListener(\"contextchange\", (event) => {\n this.sharedContext = new SharedContext(event.detail.context);\n });\n }\n /**\n * Proxy object for calling methods on the host.\n *\n * @remarks Any APIs exposed to the extension via {@link @adobe/uix-host#Port.provide}\n * can be called on this object. Because these methods are called with RPC,\n * they are all asynchronous, The return types of all Host methods will be\n * Promises which resolve to the value the Host method returns.\n * @public\n */\n host: RemoteHostApis<Incoming> = makeNamespaceProxy<Incoming>(\n async (address) => {\n await this.hostConnectionPromise;\n try {\n const result = await timeoutPromise(\n 10000,\n this.hostConnection.invokeHostMethod(address)\n );\n return result;\n } catch (e) {\n const error =\n e instanceof Error ? e : new Error(e as unknown as string);\n const methodError = new Error(\n `Host method call host.${address.path.join(\".\")}() failed: ${\n error.message\n }`\n );\n this.debugLogger.error(methodError);\n throw methodError;\n }\n }\n );\n private timeout = 10000;\n private hostConnectionPromise: Promise<RemoteHostApis<HostConnection>>;\n private hostConnection!: RemoteHostApis<HostConnection>;\n /** @internal */\n protected getLocalMethods() {\n return {\n emit: (...args: Parameters<typeof this.emit>) => {\n this.debugLogger.log(`Event \"${args[0]}\" emitted from host`);\n this.emit(...args);\n },\n };\n }\n /**\n * Accept a connection from the Host.\n * @returns A Promise that resolves when the Host has established a connection.\n * @deprecated It is preferable to use {@link register} for primary frames,\n * and {@link attach} for UI frames and other secondary frames, than to\n * instantiate a Guest and then call `.connect()` on it. The latter style\n * returns an object that cannot be used until it is connected, and therefore\n * risks errors.\n * @public\n */\n async connect() {\n return this._connect();\n }\n\n /**\n * @internal\n */\n async _connect() {\n this.emit(\"beforeconnect\", { guest: this });\n try {\n const connection = connectToParent<HostConnection<Incoming>>({\n timeout: this.timeout,\n methods: this.getLocalMethods(),\n });\n\n this.hostConnectionPromise = connection.promise;\n this.hostConnection = await this.hostConnectionPromise;\n this.sharedContext = new SharedContext(\n await this.hostConnection.getSharedContext()\n );\n this.debugLogger.log(\"retrieved sharedContext\", this.sharedContext);\n this.emit(\"connected\", { guest: this, connection });\n } catch (e) {\n this.emit(\"error\", { guest: this, error: e });\n this.debugLogger.error(\"Connection failed!\", e);\n }\n }\n}\n","/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\n/**\n * Adapter to attach console logging listeners to a Guest running in a frame/\n * @internal @preapproved\n */\nimport { debugEmitter, Emits, EmitterDebugLogger } from \"@adobe/uix-core\";\nimport { GuestEvents } from \"./guest\";\n\nexport function debugGuest(guest: Emits<GuestEvents>): EmitterDebugLogger {\n return debugEmitter(guest, {\n theme: \"yellow medium\",\n type: \"Guest\",\n })\n .listen(\"beforeconnect\", (log, { detail: { guest } }) => {\n log.info(guest);\n })\n .listen(\"connecting\", (log, { detail: { connection } }) => {\n log.info(connection);\n })\n .listen(\"connected\", (log, { detail: { guest } }) => {\n log.info(guest);\n })\n .listen(\"error\", (log, { detail: { error, guest } }) => {\n log.error(\n \"❌ Failed to connect! %s\",\n (error as Error).message,\n guest,\n error\n );\n });\n}\n","/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport type { RemoteHostApis, VirtualApi } from \"@adobe/uix-core\";\nimport {\n Guest,\n GuestConfig,\n GuestEventBeforeConnect,\n GuestEventConnected,\n GuestEventContextChange,\n GuestEventError,\n} from \"./guest\";\n\n/**\n * A Guest to be used in an extension-controlled frame, usually to display UI.\n *\n * @typeParam Incoming - Optional interface of host methods. If using\n * TypeScript, supply this type parameter and a promisified version of the\n * interface will be available at {@link Guest.host}\n *\n * @remarks\n * This is the object returned when calling {@link @adobe/uix-guest#attach}. It\n * represents an additional frame or runtime created by the host application, on\n * behalf of the extension's control frame which is running the {@link\n * GuestServer}. It is a \"secondary\" guest object, which a host won't use before\n * the control frame has connected. It exposes a subset of the functionality of\n * the {@link GuestServer}.\n *\n * Unlike the {@link GuestServer}, it cannot register methods or update the\n * {@link Guest.sharedContext}, but it remains in sync with the GuestServer and\n * can access the {@link Guest.sharedContext} of the control frame, as well as\n * any of the published methods on the host.\n *\n * Extensible host apps using the React bindings will likely render GuestUI\n * frames using the {@link @adobe/uix-host-react#GuestUIFrame} component.\n *\n * @example\n * When an extensible app renders this page, {@link @adobe/uix-guest#attach}\n * creates a GuestUI. Once it attaches to the host, it\n * ```javascript\n * import React, { useEffect, useState } from \"react\";\n * import { attach } from \"@adobe/uix-guest\";\n * import { Tooltip } from \"./tooltip\";\n *\n * export default function PopupOverlay(props) {\n * // how large am I?\n * const [dimensions, setDimensions] = useState(\n * document.body.getBoundingClientRect()\n * );\n * // if possible, use language preloaded in query parameters\n * const [language, setLanguage] = useState(props.params.lang)\n *\n * // attach only once, in a useEffect\n * useEffect(() => {\n * attach({\n * id: \"my-extension-id\",\n * debug: true,\n * })\n * .then(guestUI => {\n * // this event fires whenever the host, or the control frame, changes\n * // any sharedContext value\n * guestUI.addEventListener(\"contextchange\", ({ detail: { context }}) => {\n * setLanguage(context.lang)\n * });\n * // how large does the host want me to be?\n * return guestUI.host.tooltips.getDimensions()\n * .then(setDimensions)\n * })\n * .catch((e) => {\n * console.error(\"ui attach failed\", e);\n * });\n * }, []);\n * // render UI! Due to the setup and useState, this component will re-render\n * // once attach() is complete.\n * return (\n * <Tooltip {...props.params} lang={language} dimensions={dimensions} />\n * );\n * }\n * ```\n *\n * @public\n */\nexport class GuestUI<IHost extends VirtualApi> extends Guest<IHost> {\n /**\n * {@inheritDoc Guest.\"constructor\"}\n */\n constructor(config: GuestConfig) {\n super(config);\n }\n /**\n * {@inheritDoc Guest.contextchange}\n * @eventProperty\n */\n public contextchange: GuestEventContextChange;\n /**\n * {@inheritDoc Guest.beforeconnect}\n * @eventProperty\n */\n public beforeconnect: GuestEventBeforeConnect;\n /**\n * {@inheritDoc Guest.connected}\n * @eventProperty\n */\n public connected: GuestEventConnected;\n /**\n * {@inheritDoc Guest.error}\n * @eventProperty\n */\n public error: GuestEventError;\n /**\n * {@inheritDoc Guest.host}\n */\n host: RemoteHostApis<IHost>;\n}\n","/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport type { GuestApis } from \"@adobe/uix-core\";\nimport type { SharedContext } from \"./guest\";\nimport { Guest } from \"./guest\";\n\n/**\n * A Guest to be used in the \"main\" or primary frame of an extension, the frame\n * the Host loads first.\n *\n * @remarks This is the Guest object returned from {@link register}. It can\n * expose internal methods to the Host via the {@link GuestServer.register}\n * method.\n *\n *\n * @public\n */\nexport class GuestServer<Outgoing extends GuestApis> extends Guest<Outgoing> {\n private localMethods: Outgoing;\n protected getLocalMethods() {\n return {\n ...super.getLocalMethods(),\n apis: this.localMethods,\n };\n }\n /**\n * {@inheritDoc BaseGuest.sharedContext}\n */\n sharedContext: SharedContext;\n /**\n * {@inheritdoc BaseGuest.host}\n */\n host: Guest<Outgoing>[\"host\"];\n /**\n * Pass an interface of methods which Host may call as callbacks.\n *\n * @remarks It is preferable to use {@link register} to obtain a guest object\n * and register local methods in one step. The returned guest object will be\n * pre-registered and connected.\n * @public\n */\n async register(implementedMethods: Outgoing) {\n this.localMethods = implementedMethods;\n return this._connect();\n }\n}\n","/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\n/**\n * @packageDocumentation\n * Tools for UI Extensions meant to run inside extensible apps. Connects\n * Extensions running in their own window contexts with the host app, allowing\n * the host and guest to exchange method, events, and signals.\n *\n * @remarks The core object of this library, which extensions use for\n * communication, is the Guest object. There are two variants of the Guest\n * object {@link GuestServer} for the bootstrap frame which your extension keeps\n * running in the background, and {@link GuestUI} for frames meant to be\n * displayed in the host application. An extension must have one GuestServer\n * frame, and the host app may choose to use one or more GuestUI frames.\n *\n * @example Creating and connecting a GuestServer with {@link register}\n * ```typescript\n * import { register } from \"@adobe/uix-guest\";\n *\n * const server = await register({\n * // Must match extension ID from registry\n * id: \"My Custom View Extension\",\n * // enable logging in dev build\n * debug: process.env.NODE_ENV !== \"production\",\n * // Host can access these methods from its Port to this guest\n * methods: {\n * // Methods must be namespaced by one or more levels\n * myCustomView: {\n * async documentIsViewable(docId) {\n * const doc = await callMyRuntimeAction(docId);\n * return someValidation(doc);\n * },\n * renderView(docId, depth) {\n * // Use a host method\n * const tooltip = await server.host.editor.requestTooltip({\n * type: 'frame',\n * url: new URL(`/show/${docId}`, location).href\n * })\n * }\n * },\n * },\n * })\n * ```\n *\n * @example Connecting to an existing GuestServer with a GuestUI\n * ```typescript\n * import { attach } from \"@adobe/uix-guest\";\n *\n * const ui = await attach({\n * id: \"My Custom View Extension\",\n * })\n *\n * // when editing is done:\n * const saved = await ui.host.editor.saveChanges();\n * if (!saved) {\n * const editorState = ui.sharedContext.get('editorState');\n * if (editorState.tooltips[ui.id].invalid === true) {\n * putGuestUIInInvalidState();\n * }\n * } else {\n * ui.host.editor.dismissTooltip();\n * }\n * ```\n *\n */\nimport type { Guest, GuestConfig } from \"./guest.js\";\nimport { GuestUI } from \"./guest-ui.js\";\nimport { GuestServer } from \"./guest-server.js\";\nimport { GuestApis } from \"@adobe/uix-core\";\n\n/**\n * {@inheritdoc GuestConfig}\n * @public\n */\ntype GuestConfigWithMethods<Outgoing extends GuestApis> = GuestConfig & {\n methods: Outgoing;\n};\n\n/**\n * Create and immediately return a {@link GuestServer}.\n *\n * @deprecated Use {@link attach} or {@link register}, which return Promises\n * that resolve once the guest is connected.\n * @public\n */\nexport function createGuest(config: GuestConfig) {\n const guest = new GuestServer(config);\n return guest;\n}\n\n/**\n * Connect to a running {@link GuestServer} to share its context and render UI.\n *\n * @remarks Creates a guest object that shares most of the GuestServer API,\n * except it cannot register its own methods. Use `attach()` in an app or\n * document that is meant to render a UI in the host application; it will have\n * access to the sharedContext object shared by the host and GuestServer.\n *\n * @public\n */\nexport async function attach(config: GuestConfig) {\n const guest = new GuestUI(config);\n await guest._connect();\n return guest;\n}\n\n/**\n * Initiate a connection to the host app and its extension points.\n *\n * @remarks Creates the \"main\" {@link GuestServer}, which runs in the background\n * without UI. Registers methods passed in the `methods` parameter, then\n * resolves the returned Promise with the connected GuestServer object.\n *\n * @public\n */\nexport async function register<Outgoing extends GuestApis>(\n config: GuestConfigWithMethods<Outgoing>\n) {\n const guest = new GuestServer(config);\n await guest.register(config.methods);\n return guest;\n}\n\n// backwards compatibility\nexport {\n Guest,\n Guest as BaseGuest,\n GuestUI,\n GuestUI as UIGuest,\n GuestServer,\n GuestServer as PrimaryGuest,\n};\n"],"mappings":";AAaA,SAAqB,uBAAuB;AAO5C;AAAA,EACE;AAAA,E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