@shopfront/bridge 3.0.4 → 3.0.5--canary.24.ea644cd.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -38,3 +38,17 @@ export const execute = application.communicator.execute;
38
38
  export const registerSendMessage = application.communicator.registerSendMessage;
39
39
  export const onReceiveMessage = application.communicator.onReceiveMessage;
40
40
  ```
41
+
42
+ Alternatively, you can export the application as the default item and Shopfront will automatically infer the functions
43
+ from it.
44
+
45
+ ```javascript
46
+ import { Bridge } from "@shopfront/bridge";
47
+
48
+ const application = Bridge.createApplication({
49
+ id : "<< my client id >>",
50
+ communicator: "javascript",
51
+ });
52
+
53
+ export default application;
54
+ ```
package/lib/Bridge.d.ts CHANGED
@@ -17,11 +17,10 @@ type JavaScriptSendMessageCallback = (message: {
17
17
  data: unknown;
18
18
  id?: string;
19
19
  }) => void;
20
- export type JavaScriptReceiveMessageCallback = (type: keyof FromShopfront | keyof FromShopfrontInternal, data: Record<string, unknown>, id: string) => void;
21
20
  export interface JavaScriptCommunicatorExports {
22
21
  execute: () => void;
23
22
  registerSendMessage: (callback: JavaScriptSendMessageCallback) => void;
24
- onReceiveMessage: JavaScriptReceiveMessageCallback;
23
+ onReceiveMessage: (type: keyof FromShopfront | keyof FromShopfrontInternal, data: Record<string, unknown>, id: string) => void;
25
24
  }
26
25
  export declare class Bridge extends BaseBridge {
27
26
  protected communicateVia: "frame" | "javascript";
package/lib/index.mjs CHANGED
@@ -903,7 +903,7 @@ class pe extends d {
903
903
  return this.callback(e, void 0);
904
904
  }
905
905
  }
906
- class fe extends d {
906
+ class ge extends d {
907
907
  constructor(e) {
908
908
  super(e);
909
909
  }
@@ -917,7 +917,7 @@ class fe extends d {
917
917
  }, void 0);
918
918
  }
919
919
  }
920
- class ge extends d {
920
+ class fe extends d {
921
921
  constructor(e) {
922
922
  super(e);
923
923
  }
@@ -1117,7 +1117,7 @@ class K extends d {
1117
1117
  e.sendMessage(a.RESPONSE_SALE_KEYS, i, s);
1118
1118
  }
1119
1119
  }
1120
- class f extends d {
1120
+ class g extends d {
1121
1121
  constructor(e) {
1122
1122
  super(e);
1123
1123
  }
@@ -1148,7 +1148,7 @@ class f extends d {
1148
1148
  for (let s = 0, i = t.length; s < i; s++) {
1149
1149
  if (!t[s].url || !t[s].title)
1150
1150
  throw new TypeError("You must specify both a URL and a title");
1151
- f.validateURL(t[s].url), t[s].id = f.getOptionId(t[s].url);
1151
+ g.validateURL(t[s].url), t[s].id = g.getOptionId(t[s].url);
1152
1152
  }
1153
1153
  return t;
1154
1154
  }
@@ -1628,13 +1628,13 @@ class me extends J {
1628
1628
  return e.wasQuantityModified() && (t.quantity = e.getQuantity()), e.wasPriceModified() && (t.price = e.getPrice()), e.wasMetaDataModified() && (t.metaData = e.getMetaData()), e.clearModificationFlags(), this.sendSaleUpdate(new l("PRODUCT_UPDATE", t));
1629
1629
  }
1630
1630
  }
1631
- class g {
1631
+ class f {
1632
1632
  callback;
1633
1633
  constructor(e) {
1634
1634
  this.callback = e;
1635
1635
  }
1636
1636
  }
1637
- class Ae extends g {
1637
+ class Ae extends f {
1638
1638
  constructor(e) {
1639
1639
  super(e);
1640
1640
  }
@@ -1652,7 +1652,7 @@ class Ae extends g {
1652
1652
  return this.callback(e);
1653
1653
  }
1654
1654
  }
1655
- class Le extends g {
1655
+ class Le extends f {
1656
1656
  constructor(e) {
1657
1657
  super(e);
1658
1658
  }
@@ -1670,7 +1670,7 @@ class Le extends g {
1670
1670
  return this.callback(e);
1671
1671
  }
1672
1672
  }
1673
- class Oe extends g {
1673
+ class Oe extends f {
1674
1674
  constructor(e) {
1675
1675
  super(e);
1676
1676
  }
@@ -1688,7 +1688,7 @@ class Oe extends g {
1688
1688
  return this.callback(e);
1689
1689
  }
1690
1690
  }
1691
- class Ie extends g {
1691
+ class Ie extends f {
1692
1692
  constructor(e) {
1693
1693
  super(e);
1694
1694
  }
@@ -1706,7 +1706,7 @@ class Ie extends g {
1706
1706
  return this.callback();
1707
1707
  }
1708
1708
  }
1709
- class we extends g {
1709
+ class we extends f {
1710
1710
  constructor(e) {
1711
1711
  super(e);
1712
1712
  }
@@ -1724,7 +1724,7 @@ class we extends g {
1724
1724
  return this.callback();
1725
1725
  }
1726
1726
  }
1727
- class Pe extends g {
1727
+ class Pe extends f {
1728
1728
  constructor(e) {
1729
1729
  super(e);
1730
1730
  }
@@ -1742,7 +1742,7 @@ class Pe extends g {
1742
1742
  return this.callback(e);
1743
1743
  }
1744
1744
  }
1745
- class De extends g {
1745
+ class De extends f {
1746
1746
  constructor(e) {
1747
1747
  super(e);
1748
1748
  }
@@ -1866,7 +1866,7 @@ class W {
1866
1866
  s = new V(t), this.listeners[e].set(t, s);
1867
1867
  break;
1868
1868
  case "REQUEST_SELL_SCREEN_OPTIONS":
1869
- s = new f(t), this.listeners[e].set(t, s);
1869
+ s = new g(t), this.listeners[e].set(t, s);
1870
1870
  break;
1871
1871
  case "INTERNAL_PAGE_MESSAGE":
1872
1872
  s = new Se(
@@ -1907,10 +1907,10 @@ class W {
1907
1907
  s = new Q(t), this.listeners[e].set(t, s);
1908
1908
  break;
1909
1909
  case "FULFILMENT_VOID_ORDER":
1910
- s = new ge(t), this.listeners[e].set(t, s);
1910
+ s = new fe(t), this.listeners[e].set(t, s);
1911
1911
  break;
1912
1912
  case "FULFILMENT_PROCESS_ORDER":
1913
- s = new fe(t), this.listeners[e].set(t, s);
1913
+ s = new ge(t), this.listeners[e].set(t, s);
1914
1914
  break;
1915
1915
  case "FULFILMENT_ORDER_APPROVAL":
1916
1916
  s = new pe(t), this.listeners[e].set(t, s);
@@ -2087,7 +2087,7 @@ class Ue extends W {
2087
2087
  case "REQUEST_TABLE_COLUMNS":
2088
2088
  return i = i, Promise.all(i).then((n) => V.respond(this.bridge, n.flat(), s));
2089
2089
  case "REQUEST_SELL_SCREEN_OPTIONS":
2090
- return i = i, Promise.all(i).then((n) => f.respond(this.bridge, n.flat(), s));
2090
+ return i = i, Promise.all(i).then((n) => g.respond(this.bridge, n.flat(), s));
2091
2091
  case "FORMAT_INTEGRATED_PRODUCT":
2092
2092
  return i = i, Promise.all(i).then((n) => G.respond(this.bridge, n.flat(), s));
2093
2093
  case "REQUEST_CUSTOMER_LIST_OPTIONS":
@@ -2365,8 +2365,7 @@ class Ue extends W {
2365
2365
  const i = JSON.parse(new TextDecoder().decode(t));
2366
2366
  if (i.app !== this.bridge.key)
2367
2367
  throw new O();
2368
- let n = location.href;
2369
- if (typeof import.meta < "u" && window.parent === window && (n = import.meta.url), i.url.loaded !== n)
2368
+ if (i.url.loaded !== location.href)
2370
2369
  throw new O();
2371
2370
  return s ? i : i.auth;
2372
2371
  }
@@ -2462,8 +2461,8 @@ class Ve extends h {
2462
2461
  }
2463
2462
  class $e extends h {
2464
2463
  constructor(e, t) {
2465
- f.validateURL(e), super(a.SELL_SCREEN_OPTION_CHANGE, {
2466
- id: f.getOptionId(e),
2464
+ g.validateURL(e), super(a.SELL_SCREEN_OPTION_CHANGE, {
2465
+ id: g.getOptionId(e),
2467
2466
  url: e,
2468
2467
  title: t
2469
2468
  });