@archilogic/extension-sdk 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @archilogic/extension-sdk
2
2
 
3
+ ## 0.2.4
4
+
5
+ ### Patch Changes
6
+
7
+ - c5b34f8: fix: update extension host url
8
+
3
9
  ## 0.2.3
4
10
 
5
11
  ### Patch Changes
@@ -34,11 +34,11 @@ var Pe = class extends Error {
34
34
  f(this, B, Se);
35
35
  this.value = e, this.transferables = t == null ? void 0 : t.transferables;
36
36
  }
37
- }, B = new WeakMap(), ae), me = Ce, M = "penpal", W = (e) => typeof e == "object" && e !== null, ce = (e) => typeof e == "function", Re = (e) => W(e) && e.namespace === M, j = (e) => e.type === "SYN", X = (e) => e.type === "ACK1", z = (e) => e.type === "ACK2", de = (e) => e.type === "CALL", le = (e) => e.type === "REPLY", Ne = (e) => e.type === "DESTROY", ue = (e, t = []) => {
37
+ }, B = new WeakMap(), ae), me = Ce, M = "penpal", W = (e) => typeof e == "object" && e !== null, de = (e) => typeof e == "function", Re = (e) => W(e) && e.namespace === M, j = (e) => e.type === "SYN", X = (e) => e.type === "ACK1", g = (e) => e.type === "ACK2", ce = (e) => e.type === "CALL", le = (e) => e.type === "REPLY", Ne = (e) => e.type === "DESTROY", ue = (e, t = []) => {
38
38
  const r = [];
39
39
  for (const a of Object.keys(e)) {
40
40
  const n = e[a];
41
- ce(n) ? r.push([...t, a]) : W(n) && r.push(
41
+ de(n) ? r.push([...t, a]) : W(n) && r.push(
42
42
  ...ue(n, [...t, a])
43
43
  );
44
44
  }
@@ -48,7 +48,7 @@ var Pe = class extends Error {
48
48
  (a, n) => W(a) ? a[n] : void 0,
49
49
  t
50
50
  );
51
- return ce(r) ? r : void 0;
51
+ return de(r) ? r : void 0;
52
52
  }, C = (e) => e.join("."), ee = (e, t, r) => ({
53
53
  namespace: M,
54
54
  channel: e,
@@ -58,8 +58,8 @@ var Pe = class extends Error {
58
58
  ...r instanceof Error ? { value: Ie(r), isSerializedErrorInstance: !0 } : { value: r }
59
59
  }), Te = (e, t, r, a) => {
60
60
  let n = !1;
61
- const d = async (l) => {
62
- if (n || !de(l))
61
+ const c = async (l) => {
62
+ if (n || !ce(l))
63
63
  return;
64
64
  a == null || a(`Received ${C(l.methodPath)}() call`, l);
65
65
  const { methodPath: v, args: h, id: o } = l;
@@ -89,12 +89,12 @@ var Pe = class extends Error {
89
89
  throw u.name === "DataCloneError" && (i = ee(r, o, u), a == null || a(`Sending ${C(v)}() reply`, i), e.sendMessage(i)), u;
90
90
  }
91
91
  };
92
- return e.addMessageHandler(d), () => {
93
- n = !0, e.removeMessageHandler(d);
92
+ return e.addMessageHandler(c), () => {
93
+ n = !0, e.removeMessageHandler(c);
94
94
  };
95
95
  }, De = Te, se, he = ((se = crypto.randomUUID) == null ? void 0 : se.bind(crypto)) ?? (() => new Array(4).fill(0).map(
96
96
  () => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)
97
- ).join("-")), Le = Symbol("CallOptions"), J, ie, be = (ie = class {
97
+ ).join("-")), Le = Symbol("CallOptions"), J, ie, ke = (ie = class {
98
98
  constructor(e) {
99
99
  P(this, "transferables");
100
100
  P(this, "timeout");
@@ -104,7 +104,7 @@ var Pe = class extends Error {
104
104
  f(this, J, Le);
105
105
  this.transferables = e == null ? void 0 : e.transferables, this.timeout = e == null ? void 0 : e.timeout;
106
106
  }
107
- }, J = new WeakMap(), ie), ke = be, Oe = /* @__PURE__ */ new Set(["apply", "call", "bind"]), pe = (e, t, r = []) => new Proxy(
107
+ }, J = new WeakMap(), ie), be = ke, Oe = /* @__PURE__ */ new Set(["apply", "call", "bind"]), pe = (e, t, r = []) => new Proxy(
108
108
  r.length ? () => {
109
109
  } : /* @__PURE__ */ Object.create(null),
110
110
  {
@@ -112,8 +112,8 @@ var Pe = class extends Error {
112
112
  if (n !== "then")
113
113
  return r.length && Oe.has(n) ? Reflect.get(a, n) : pe(e, t, [...r, n]);
114
114
  },
115
- apply(a, n, d) {
116
- return e(r, d);
115
+ apply(a, n, c) {
116
+ return e(r, c);
117
117
  }
118
118
  }
119
119
  ), te = (e) => new w(
@@ -123,7 +123,7 @@ var Pe = class extends Error {
123
123
  )}() failed due to destroyed connection`
124
124
  ), He = (e, t, r) => {
125
125
  let a = !1;
126
- const n = /* @__PURE__ */ new Map(), d = (h) => {
126
+ const n = /* @__PURE__ */ new Map(), c = (h) => {
127
127
  if (!le(h))
128
128
  return;
129
129
  const { callId: o, value: i, isError: E, isSerializedErrorInstance: u } = h, p = n.get(o);
@@ -134,13 +134,13 @@ var Pe = class extends Error {
134
134
  u ? Ae(i) : i
135
135
  ) : p.resolve(i));
136
136
  };
137
- return e.addMessageHandler(d), {
137
+ return e.addMessageHandler(c), {
138
138
  remoteProxy: pe((h, o) => {
139
139
  if (a)
140
140
  throw te(h);
141
- const i = he(), E = o[o.length - 1], u = E instanceof ke, { timeout: p, transferables: K } = u ? E : {}, F = u ? o.slice(0, -1) : o;
141
+ const i = he(), E = o[o.length - 1], u = E instanceof be, { timeout: p, transferables: K } = u ? E : {}, F = u ? o.slice(0, -1) : o;
142
142
  return new Promise((Y, O) => {
143
- const g = p !== void 0 ? window.setTimeout(() => {
143
+ const z = p !== void 0 ? window.setTimeout(() => {
144
144
  n.delete(i), O(
145
145
  new w(
146
146
  "METHOD_CALL_TIMEOUT",
@@ -150,7 +150,7 @@ var Pe = class extends Error {
150
150
  )
151
151
  );
152
152
  }, p) : void 0;
153
- n.set(i, { methodPath: h, resolve: Y, reject: O, timeoutId: g });
153
+ n.set(i, { methodPath: h, resolve: Y, reject: O, timeoutId: z });
154
154
  try {
155
155
  const T = {
156
156
  namespace: M,
@@ -169,7 +169,7 @@ var Pe = class extends Error {
169
169
  });
170
170
  }, r),
171
171
  destroy: () => {
172
- a = !0, e.removeMessageHandler(d);
172
+ a = !0, e.removeMessageHandler(c);
173
173
  for (const { methodPath: h, reject: o, timeoutId: i } of n.values())
174
174
  clearTimeout(i), o(te(h));
175
175
  n.clear();
@@ -245,7 +245,7 @@ var Pe = class extends Error {
245
245
  penpal: "synAck",
246
246
  methodNames: e.methodPaths.map(re)
247
247
  };
248
- if (de(e))
248
+ if (ce(e))
249
249
  return {
250
250
  penpal: "call",
251
251
  // Actually converting the ID to a number would break communication.
@@ -278,7 +278,7 @@ var Pe = class extends Error {
278
278
  channel: a,
279
279
  log: n
280
280
  }) => {
281
- const d = he();
281
+ const c = he();
282
282
  let l;
283
283
  const v = [];
284
284
  let h = !1;
@@ -290,33 +290,33 @@ var Pe = class extends Error {
290
290
  )
291
291
  );
292
292
  }, r) : void 0, K = () => {
293
- for (const c of v)
294
- c();
293
+ for (const d of v)
294
+ d();
295
295
  }, F = () => {
296
296
  if (h)
297
297
  return;
298
298
  v.push(De(e, t, a, n));
299
- const { remoteProxy: c, destroy: m } = xe(e, a, n);
299
+ const { remoteProxy: d, destroy: m } = xe(e, a, n);
300
300
  v.push(m), clearTimeout(p), h = !0, E({
301
- remoteProxy: c,
301
+ remoteProxy: d,
302
302
  destroy: K
303
303
  });
304
304
  }, Y = () => {
305
- const c = {
305
+ const d = {
306
306
  namespace: M,
307
307
  type: "SYN",
308
308
  channel: a,
309
- participantId: d
309
+ participantId: c
310
310
  };
311
- n == null || n("Sending handshake SYN", c);
311
+ n == null || n("Sending handshake SYN", d);
312
312
  try {
313
- e.sendMessage(c);
313
+ e.sendMessage(d);
314
314
  } catch (m) {
315
315
  u(new w("TRANSMISSION_FAILED", m.message));
316
316
  }
317
- }, O = (c) => {
318
- if (n == null || n("Received handshake SYN", c), c.participantId === l && // TODO: Used for backward-compatibility. Remove in next major version.
319
- l !== G || (l = c.participantId, Y(), !(d > l || // TODO: Used for backward-compatibility. Remove in next major version.
317
+ }, O = (d) => {
318
+ if (n == null || n("Received handshake SYN", d), d.participantId === l && // TODO: Used for backward-compatibility. Remove in next major version.
319
+ l !== G || (l = d.participantId, Y(), !(c > l || // TODO: Used for backward-compatibility. Remove in next major version.
320
320
  l === G)))
321
321
  return;
322
322
  const $ = {
@@ -332,8 +332,8 @@ var Pe = class extends Error {
332
332
  u(new w("TRANSMISSION_FAILED", Me.message));
333
333
  return;
334
334
  }
335
- }, g = (c) => {
336
- n == null || n("Received handshake ACK1", c);
335
+ }, z = (d) => {
336
+ n == null || n("Received handshake ACK1", d);
337
337
  const m = {
338
338
  namespace: M,
339
339
  channel: a,
@@ -347,16 +347,16 @@ var Pe = class extends Error {
347
347
  return;
348
348
  }
349
349
  F();
350
- }, T = (c) => {
351
- n == null || n("Received handshake ACK2", c), F();
352
- }, q = (c) => {
353
- j(c) && O(c), X(c) && g(c), z(c) && T(c);
350
+ }, T = (d) => {
351
+ n == null || n("Received handshake ACK2", d), F();
352
+ }, q = (d) => {
353
+ j(d) && O(d), X(d) && z(d), g(d) && T(d);
354
354
  };
355
355
  return e.addMessageHandler(q), v.push(() => e.removeMessageHandler(q)), Y(), i;
356
- }, ge = Ke, ze = (e) => {
356
+ }, ze = Ke, ge = (e) => {
357
357
  let t = !1, r;
358
358
  return (...a) => (t || (t = !0, r = e(...a)), r);
359
- }, Ge = ze, ne = /* @__PURE__ */ new WeakSet(), Be = ({
359
+ }, Ge = ge, ne = /* @__PURE__ */ new WeakSet(), Be = ({
360
360
  messenger: e,
361
361
  methods: t = {},
362
362
  timeout: r,
@@ -371,7 +371,7 @@ var Pe = class extends Error {
371
371
  "A messenger can only be used for a single connection"
372
372
  );
373
373
  ne.add(e);
374
- const d = [e.destroy], l = Ge((o) => {
374
+ const c = [e.destroy], l = Ge((o) => {
375
375
  if (o) {
376
376
  const i = {
377
377
  namespace: M,
@@ -383,7 +383,7 @@ var Pe = class extends Error {
383
383
  } catch {
384
384
  }
385
385
  }
386
- for (const i of d)
386
+ for (const i of c)
387
387
  i();
388
388
  n == null || n("Connection destroyed");
389
389
  }), v = (o) => Re(o) && o.channel === a;
@@ -393,14 +393,14 @@ var Pe = class extends Error {
393
393
  e.initialize({ log: n, validateReceivedMessage: v }), e.addMessageHandler((E) => {
394
394
  Ne(E) && l(!1);
395
395
  });
396
- const { remoteProxy: o, destroy: i } = await ge({
396
+ const { remoteProxy: o, destroy: i } = await ze({
397
397
  messenger: e,
398
398
  methods: t,
399
399
  timeout: r,
400
400
  channel: a,
401
401
  log: n
402
402
  });
403
- return d.push(i), o;
403
+ return c.push(i), o;
404
404
  } catch (o) {
405
405
  throw l(!0), o;
406
406
  }
@@ -411,7 +411,7 @@ var Pe = class extends Error {
411
411
  l(!0);
412
412
  }
413
413
  };
414
- }, ve = Be, A, R, D, L, N, S, y, _, V, b, H, x, k, oe, Je = (oe = class {
414
+ }, ve = Be, A, R, D, L, N, S, y, _, V, k, H, x, b, oe, Je = (oe = class {
415
415
  constructor({ remoteWindow: e, allowedOrigins: t }) {
416
416
  f(this, A);
417
417
  f(this, R);
@@ -430,7 +430,7 @@ var Pe = class extends Error {
430
430
  });
431
431
  P(this, "sendMessage", (e, t) => {
432
432
  if (j(e)) {
433
- const r = s(this, b).call(this, e);
433
+ const r = s(this, k).call(this, e);
434
434
  s(this, A).postMessage(e, {
435
435
  targetOrigin: r,
436
436
  transfer: t
@@ -441,19 +441,19 @@ var Pe = class extends Error {
441
441
  // downgrade the message and send it through the window rather than
442
442
  // the port because older versions of Penpal don't use MessagePorts.
443
443
  s(this, _)) {
444
- const r = s(this, _) ? We(e) : e, a = s(this, b).call(this, e);
444
+ const r = s(this, _) ? We(e) : e, a = s(this, k).call(this, e);
445
445
  s(this, A).postMessage(r, {
446
446
  targetOrigin: a,
447
447
  transfer: t
448
448
  });
449
449
  return;
450
450
  }
451
- if (z(e)) {
451
+ if (g(e)) {
452
452
  const { port1: r, port2: a } = new MessageChannel();
453
- I(this, y, r), r.addEventListener("message", s(this, k)), r.start();
454
- const n = [a, ...t || []], d = s(this, b).call(this, e);
453
+ I(this, y, r), r.addEventListener("message", s(this, b)), r.start();
454
+ const n = [a, ...t || []], c = s(this, k).call(this, e);
455
455
  s(this, A).postMessage(e, {
456
- targetOrigin: d,
456
+ targetOrigin: c,
457
457
  transfer: n
458
458
  });
459
459
  return;
@@ -478,7 +478,7 @@ var Pe = class extends Error {
478
478
  f(this, V, (e) => s(this, R).some(
479
479
  (t) => t instanceof RegExp ? t.test(e) : t === e || t === "*"
480
480
  ));
481
- f(this, b, (e) => {
481
+ f(this, k, (e) => {
482
482
  if (j(e))
483
483
  return "*";
484
484
  if (!s(this, N))
@@ -487,7 +487,7 @@ var Pe = class extends Error {
487
487
  });
488
488
  f(this, H, () => {
489
489
  var e, t;
490
- (e = s(this, y)) == null || e.removeEventListener("message", s(this, k)), (t = s(this, y)) == null || t.close(), I(this, y, void 0);
490
+ (e = s(this, y)) == null || e.removeEventListener("message", s(this, b)), (t = s(this, y)) == null || t.close(), I(this, y, void 0);
491
491
  });
492
492
  f(this, x, ({
493
493
  source: e,
@@ -495,11 +495,11 @@ var Pe = class extends Error {
495
495
  ports: r,
496
496
  data: a
497
497
  }) => {
498
- var n, d, l;
498
+ var n, c, l;
499
499
  if (e === s(this, A) && (je(a) && ((n = s(this, D)) == null || n.call(
500
500
  this,
501
501
  "Please upgrade the child window to the latest version of Penpal."
502
- ), I(this, _, !0), a = Ve(a)), !!((d = s(this, L)) != null && d.call(this, a)))) {
502
+ ), I(this, _, !0), a = Ve(a)), !!((c = s(this, L)) != null && c.call(this, a)))) {
503
503
  if (!s(this, V).call(this, t)) {
504
504
  (l = s(this, D)) == null || l.call(
505
505
  this,
@@ -507,18 +507,18 @@ var Pe = class extends Error {
507
507
  );
508
508
  return;
509
509
  }
510
- if (j(a) && (s(this, H).call(this), I(this, N, t)), z(a) && // Previous versions of Penpal don't use MessagePorts and do all
510
+ if (j(a) && (s(this, H).call(this), I(this, N, t)), g(a) && // Previous versions of Penpal don't use MessagePorts and do all
511
511
  // communication through the window.
512
512
  !s(this, _)) {
513
513
  if (I(this, y, r[0]), !s(this, y))
514
514
  throw new U("No port received on ACK2");
515
- s(this, y).addEventListener("message", s(this, k)), s(this, y).start();
515
+ s(this, y).addEventListener("message", s(this, b)), s(this, y).start();
516
516
  }
517
517
  for (const v of s(this, S))
518
518
  v(a);
519
519
  }
520
520
  });
521
- f(this, k, ({ data: e }) => {
521
+ f(this, b, ({ data: e }) => {
522
522
  var t;
523
523
  if ((t = s(this, L)) != null && t.call(this, e))
524
524
  for (const r of s(this, S))
@@ -528,12 +528,12 @@ var Pe = class extends Error {
528
528
  throw new w("INVALID_ARGUMENT", "remoteWindow must be defined");
529
529
  I(this, A, e), I(this, R, t != null && t.length ? t : [window.origin]);
530
530
  }
531
- }, A = new WeakMap(), R = new WeakMap(), D = new WeakMap(), L = new WeakMap(), N = new WeakMap(), S = new WeakMap(), y = new WeakMap(), _ = new WeakMap(), V = new WeakMap(), b = new WeakMap(), H = new WeakMap(), x = new WeakMap(), k = new WeakMap(), oe), ye = Je;
531
+ }, A = new WeakMap(), R = new WeakMap(), D = new WeakMap(), L = new WeakMap(), N = new WeakMap(), S = new WeakMap(), y = new WeakMap(), _ = new WeakMap(), V = new WeakMap(), k = new WeakMap(), H = new WeakMap(), x = new WeakMap(), b = new WeakMap(), oe), ye = Je;
532
532
  const Qe = (e, t) => {
533
533
  const r = new ye({
534
534
  remoteWindow: e.contentWindow,
535
535
  // Defaults to the current origin.
536
- allowedOrigins: [/^http:\/\/localhost(:\d+)/, "https://archilogic-com.github.io"]
536
+ allowedOrigins: [/^http:\/\/localhost(:\d+)/, "https://extensions.archilogic.io"]
537
537
  // Alternatively,
538
538
  // allowedOrigins: [new Url(iframe.src).origin]
539
539
  });
@@ -572,8 +572,8 @@ const Qe = (e, t) => {
572
572
  return new Proxy(
573
573
  {},
574
574
  {
575
- get(n, d) {
576
- return async (...l) => (await r.promise)[d](...l);
575
+ get(n, c) {
576
+ return async (...l) => (await r.promise)[c](...l);
577
577
  }
578
578
  }
579
579
  );
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@archilogic/extension-sdk",
3
3
  "description": "",
4
- "version": "0.2.3",
4
+ "version": "0.2.4",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },