@shopify/app-bridge-react 2.0.21 → 2.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/components/ClientRouter/ClientRouter.js +4 -2
  3. package/components/ClientRouter/hook.js +3 -3
  4. package/components/ClientRouter/index.js +6 -2
  5. package/components/ClientRouter/router.d.ts +1 -1
  6. package/components/ContextualSaveBar/ContextualSaveBar.js +5 -5
  7. package/components/Loading/Loading.js +3 -1
  8. package/components/Modal/Modal.js +5 -4
  9. package/components/Modal/ModalContent/ModalContent.js +3 -1
  10. package/components/Modal/index.js +2 -1
  11. package/components/Provider/Provider.js +12 -5
  12. package/components/ResourcePicker/ResourcePicker.js +3 -1
  13. package/components/RoutePropagator/RoutePropagator.js +5 -3
  14. package/components/RoutePropagator/globals.d.ts +1 -1
  15. package/components/RoutePropagator/hook.js +3 -3
  16. package/components/RoutePropagator/index.js +6 -2
  17. package/components/RoutePropagator/route-propagator.d.ts +1 -1
  18. package/components/RoutePropagator/route-propagator.js +5 -5
  19. package/components/TitleBar/TitleBar.js +5 -3
  20. package/components/Toast/Toast.js +3 -1
  21. package/components/index.js +17 -9
  22. package/context.d.ts +1 -1
  23. package/context.js +1 -1
  24. package/hooks/index.js +1 -0
  25. package/hooks/useContextualSaveBar/index.js +1 -0
  26. package/hooks/useContextualSaveBar/useContextualSaveBar.js +6 -6
  27. package/hooks/useNavigationHistory/index.js +1 -0
  28. package/hooks/useNavigationHistory/useNavigationHistory.js +2 -2
  29. package/hooks/useToast/index.js +1 -0
  30. package/hooks/useToast/useToast.js +4 -4
  31. package/index.js +7 -2
  32. package/package.json +3 -3
  33. package/umd/index.js +3 -3
  34. package/useAppBridge.d.ts +1 -1
  35. package/useAppBridge.js +1 -1
  36. package/utilities/transformers.d.ts +3 -3
  37. package/utilities/transformers.js +13 -11
package/CHANGELOG.md CHANGED
@@ -3,6 +3,18 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.0.22](https://github.com/Shopify/app-bridge/compare/v2.0.21...v2.0.22) (2022-03-30)
7
+
8
+
9
+ ### Features
10
+
11
+ * **app-bridge:** add TypeScript interface for App Bridge State ([7a4a0f2](https://github.com/Shopify/app-bridge/commit/7a4a0f24bb8f4eeb8093c25b6580167ce100e200))
12
+ * **app-bridge:** improve app.getState TypeScript support when using dot notation ([7cf14f6](https://github.com/Shopify/app-bridge/commit/7cf14f6f6a703356114953a119c23adb93c8ca9a))
13
+
14
+
15
+
16
+
17
+
6
18
  ## [2.0.21](https://github.com/Shopify/app-bridge/compare/v2.0.20...v2.0.21) (2022-03-23)
7
19
 
8
20
  **Note:** Version bump only for package @shopify/app-bridge-react
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
3
3
  var extendStatics = function (d, b) {
4
4
  extendStatics = Object.setPrototypeOf ||
5
5
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
7
  return extendStatics(d, b);
8
8
  };
9
9
  return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
10
12
  extendStatics(d, b);
11
13
  function __() { this.constructor = d; }
12
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
@@ -34,7 +36,7 @@ var ClientRouter = /** @class */ (function (_super) {
34
36
  }
35
37
  ClientRouter.prototype.componentDidMount = function () {
36
38
  var history = this.props.history;
37
- this.unsubscribe = router_1.handleRouteChange(this.context, history);
39
+ this.unsubscribe = (0, router_1.handleRouteChange)(this.context, history);
38
40
  };
39
41
  ClientRouter.prototype.componentWillUnmount = function () {
40
42
  if (this.unsubscribe) {
@@ -12,9 +12,9 @@ var router_1 = require("./router");
12
12
  * @public
13
13
  */
14
14
  function useClientRouting(history) {
15
- var app = useAppBridge_1.useAppBridge();
16
- react_1.useEffect(function () {
17
- return router_1.handleRouteChange(app, history);
15
+ var app = (0, useAppBridge_1.useAppBridge)();
16
+ (0, react_1.useEffect)(function () {
17
+ return (0, router_1.handleRouteChange)(app, history);
18
18
  }, [app, history]);
19
19
  }
20
20
  exports.default = useClientRouting;
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.useClientRouting = exports.ClientRouter = void 0;
3
7
  var ClientRouter_1 = require("./ClientRouter");
4
- Object.defineProperty(exports, "ClientRouter", { enumerable: true, get: function () { return ClientRouter_1.default; } });
8
+ Object.defineProperty(exports, "ClientRouter", { enumerable: true, get: function () { return __importDefault(ClientRouter_1).default; } });
5
9
  var hook_1 = require("./hook");
6
- Object.defineProperty(exports, "useClientRouting", { enumerable: true, get: function () { return hook_1.default; } });
10
+ Object.defineProperty(exports, "useClientRouting", { enumerable: true, get: function () { return __importDefault(hook_1).default; } });
@@ -2,4 +2,4 @@ import { ClientApplication } from '@shopify/app-bridge';
2
2
  export interface History {
3
3
  replace(path: string): void;
4
4
  }
5
- export declare function handleRouteChange(app: ClientApplication<any>, history: History): import("@shopify/app-bridge").Unsubscribe;
5
+ export declare function handleRouteChange(app: ClientApplication, history: History): import("@shopify/app-bridge").Unsubscribe;
@@ -17,10 +17,10 @@ var useAppBridge_1 = require("../../useAppBridge");
17
17
  var Action = actions_1.ContextualSaveBar.Action, create = actions_1.ContextualSaveBar.create;
18
18
  function ContextualSaveBar(_a) {
19
19
  var discardAction = _a.discardAction, saveAction = _a.saveAction, fullWidth = _a.fullWidth, leaveConfirmationDisable = _a.leaveConfirmationDisable, visible = _a.visible;
20
- var app = useAppBridge_1.useAppBridge();
20
+ var app = (0, useAppBridge_1.useAppBridge)();
21
21
  var onSaveAction = saveAction.onAction, saveActionProps = __rest(saveAction, ["onAction"]);
22
22
  var onDiscardAction = discardAction.onAction, discardActionProps = __rest(discardAction, ["onAction"]);
23
- var contextualSaveBar = react_1.useMemo(function () {
23
+ var contextualSaveBar = (0, react_1.useMemo)(function () {
24
24
  return create(app, {
25
25
  saveAction: saveActionProps,
26
26
  discardAction: discardActionProps,
@@ -28,7 +28,7 @@ function ContextualSaveBar(_a) {
28
28
  leaveConfirmationDisable: leaveConfirmationDisable,
29
29
  });
30
30
  }, [app]);
31
- react_1.useEffect(function () {
31
+ (0, react_1.useEffect)(function () {
32
32
  contextualSaveBar.set({
33
33
  saveAction: saveActionProps,
34
34
  discardAction: discardActionProps,
@@ -44,14 +44,14 @@ function ContextualSaveBar(_a) {
44
44
  leaveConfirmationDisable,
45
45
  visible,
46
46
  ]);
47
- react_1.useEffect(function () {
47
+ (0, react_1.useEffect)(function () {
48
48
  contextualSaveBar.subscribe(Action.DISCARD, onDiscardAction);
49
49
  contextualSaveBar.subscribe(Action.SAVE, onSaveAction);
50
50
  return function () {
51
51
  contextualSaveBar.unsubscribe();
52
52
  };
53
53
  }, [contextualSaveBar]);
54
- react_1.useEffect(function () {
54
+ (0, react_1.useEffect)(function () {
55
55
  if (visible) {
56
56
  contextualSaveBar.dispatch(Action.SHOW);
57
57
  }
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
3
3
  var extendStatics = function (d, b) {
4
4
  extendStatics = Object.setPrototypeOf ||
5
5
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
7
  return extendStatics(d, b);
8
8
  };
9
9
  return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
10
12
  extendStatics(d, b);
11
13
  function __() { this.constructor = d; }
12
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
3
3
  var extendStatics = function (d, b) {
4
4
  extendStatics = Object.setPrototypeOf ||
5
5
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
7
  return extendStatics(d, b);
8
8
  };
9
9
  return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
10
12
  extendStatics(d, b);
11
13
  function __() { this.constructor = d; }
12
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
@@ -113,9 +115,8 @@ var Modal = /** @class */ (function (_super) {
113
115
  srcPayload.path = src;
114
116
  }
115
117
  }
116
- return __assign(__assign({ title: title,
117
- message: message, size: safeSize }, srcPayload), { footer: {
118
- buttons: transformers_1.transformActions(app, {
118
+ return __assign(__assign({ title: title, message: message, size: safeSize }, srcPayload), { footer: {
119
+ buttons: (0, transformers_1.transformActions)(app, {
119
120
  primaryAction: primaryAction,
120
121
  secondaryActions: secondaryActions,
121
122
  }),
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
3
3
  var extendStatics = function (d, b) {
4
4
  extendStatics = Object.setPrototypeOf ||
5
5
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
7
  return extendStatics(d, b);
8
8
  };
9
9
  return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
10
12
  extendStatics(d, b);
11
13
  function __() { this.constructor = d; }
12
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ModalContent = void 0;
6
7
  var Modal_1 = __importDefault(require("./Modal"));
7
8
  var ModalContent_1 = require("./ModalContent");
8
- Object.defineProperty(exports, "ModalContent", { enumerable: true, get: function () { return ModalContent_1.default; } });
9
+ Object.defineProperty(exports, "ModalContent", { enumerable: true, get: function () { return __importDefault(ModalContent_1).default; } });
9
10
  exports.default = Modal_1.default;
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
3
3
  var extendStatics = function (d, b) {
4
4
  extendStatics = Object.setPrototypeOf ||
5
5
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
7
  return extendStatics(d, b);
8
8
  };
9
9
  return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
10
12
  extendStatics(d, b);
11
13
  function __() { this.constructor = d; }
12
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
@@ -14,7 +16,11 @@ var __extends = (this && this.__extends) || (function () {
14
16
  })();
15
17
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
16
18
  if (k2 === undefined) k2 = k;
17
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
19
+ var desc = Object.getOwnPropertyDescriptor(m, k);
20
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
+ desc = { enumerable: true, get: function() { return m[k]; } };
22
+ }
23
+ Object.defineProperty(o, k2, desc);
18
24
  }) : (function(o, m, k, k2) {
19
25
  if (k2 === undefined) k2 = k;
20
26
  o[k2] = m[k];
@@ -27,7 +33,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
27
33
  var __importStar = (this && this.__importStar) || function (mod) {
28
34
  if (mod && mod.__esModule) return mod;
29
35
  var result = {};
30
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
36
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
31
37
  __setModuleDefault(result, mod);
32
38
  return result;
33
39
  };
@@ -61,7 +67,7 @@ var Provider = /** @class */ (function (_super) {
61
67
  Object.defineProperty(Provider.prototype, "appInstance", {
62
68
  get: function () {
63
69
  if (!this.app) {
64
- this.app = app_bridge_1.default(this.props.config);
70
+ this.app = (0, app_bridge_1.default)(this.props.config);
65
71
  if (this.app && this.app.hooks) {
66
72
  this.app.hooks.set(app_bridge_1.LifecycleHook.DispatchAction, exports.setClientInterfaceHook);
67
73
  }
@@ -82,7 +88,7 @@ exports.default = Provider;
82
88
  *
83
89
  * @internal
84
90
  */
85
- exports.setClientInterfaceHook = function (next) {
91
+ var setClientInterfaceHook = function (next) {
86
92
  return function (action) {
87
93
  action.clientInterface = {
88
94
  name: '@shopify/app-bridge-react',
@@ -91,3 +97,4 @@ exports.setClientInterfaceHook = function (next) {
91
97
  return next(action);
92
98
  };
93
99
  };
100
+ exports.setClientInterfaceHook = setClientInterfaceHook;
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
3
3
  var extendStatics = function (d, b) {
4
4
  extendStatics = Object.setPrototypeOf ||
5
5
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
7
  return extendStatics(d, b);
8
8
  };
9
9
  return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
10
12
  extendStatics(d, b);
11
13
  function __() { this.constructor = d; }
12
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
3
3
  var extendStatics = function (d, b) {
4
4
  extendStatics = Object.setPrototypeOf ||
5
5
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
7
  return extendStatics(d, b);
8
8
  };
9
9
  return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
10
12
  extendStatics(d, b);
11
13
  function __() { this.constructor = d; }
12
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
@@ -34,13 +36,13 @@ var RoutePropagator = /** @class */ (function (_super) {
34
36
  }
35
37
  RoutePropagator.prototype.componentDidMount = function () {
36
38
  var location = this.props.location;
37
- route_propagator_1.updateHistory(this.context, location);
39
+ (0, route_propagator_1.updateHistory)(this.context, location);
38
40
  };
39
41
  RoutePropagator.prototype.componentDidUpdate = function (_a) {
40
42
  var prevLocation = _a.location;
41
43
  var location = this.props.location;
42
44
  if (location !== prevLocation) {
43
- route_propagator_1.updateHistory(this.context, location);
45
+ (0, route_propagator_1.updateHistory)(this.context, location);
44
46
  }
45
47
  };
46
48
  RoutePropagator.prototype.render = function () {
@@ -1,3 +1,3 @@
1
1
  export declare function getSelfWindow(): Window & typeof globalThis;
2
- export declare function getTopWindow(): Window;
2
+ export declare function getTopWindow(): Window | null;
3
3
  export declare function getOrigin(): string;
@@ -12,9 +12,9 @@ var route_propagator_1 = require("./route-propagator");
12
12
  * @public
13
13
  */
14
14
  function useRoutePropagation(location) {
15
- var app = useAppBridge_1.useAppBridge();
16
- react_1.useEffect(function () {
17
- route_propagator_1.updateHistory(app, location);
15
+ var app = (0, useAppBridge_1.useAppBridge)();
16
+ (0, react_1.useEffect)(function () {
17
+ (0, route_propagator_1.updateHistory)(app, location);
18
18
  }, [app, location]);
19
19
  }
20
20
  exports.default = useRoutePropagation;
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.useRoutePropagation = exports.RoutePropagator = void 0;
3
7
  var RoutePropagator_1 = require("./RoutePropagator");
4
- Object.defineProperty(exports, "RoutePropagator", { enumerable: true, get: function () { return RoutePropagator_1.default; } });
8
+ Object.defineProperty(exports, "RoutePropagator", { enumerable: true, get: function () { return __importDefault(RoutePropagator_1).default; } });
5
9
  var hook_1 = require("./hook");
6
- Object.defineProperty(exports, "useRoutePropagation", { enumerable: true, get: function () { return hook_1.default; } });
10
+ Object.defineProperty(exports, "useRoutePropagation", { enumerable: true, get: function () { return __importDefault(hook_1).default; } });
@@ -4,4 +4,4 @@ export declare type LocationOrHref = string | {
4
4
  hash: string;
5
5
  pathname: string;
6
6
  };
7
- export declare function updateHistory(app: ClientApplication<any>, location: LocationOrHref): Promise<void>;
7
+ export declare function updateHistory(app: ClientApplication, location: LocationOrHref): Promise<void>;
@@ -59,8 +59,8 @@ function updateHistory(app, location) {
59
59
  return __generator(this, function (_a) {
60
60
  switch (_a.label) {
61
61
  case 0:
62
- selfWindow = globals_1.getSelfWindow();
63
- topWindow = globals_1.getTopWindow();
62
+ selfWindow = (0, globals_1.getSelfWindow)();
63
+ topWindow = (0, globals_1.getTopWindow)();
64
64
  renderedInTheTopWindow = selfWindow === topWindow;
65
65
  return [4 /*yield*/, app.getState('context').then(function (context) {
66
66
  return context === MessageTransport_1.Context.Main;
@@ -73,7 +73,7 @@ function updateHistory(app, location) {
73
73
  normalizedLocation = getNormalizedURL(location);
74
74
  embeddedFrameParamsToRemove.forEach(function (param) { return normalizedLocation.searchParams.delete(param); });
75
75
  pathname = normalizedLocation.pathname, search = normalizedLocation.search, hash = normalizedLocation.hash;
76
- locationStr = "" + pathname + search + hash;
76
+ locationStr = "".concat(pathname).concat(search).concat(hash);
77
77
  actions_1.History.create(app).dispatch(actions_1.History.Action.REPLACE, locationStr);
78
78
  return [2 /*return*/];
79
79
  }
@@ -82,10 +82,10 @@ function updateHistory(app, location) {
82
82
  }
83
83
  exports.updateHistory = updateHistory;
84
84
  function getNormalizedURL(location) {
85
- var origin = globals_1.getOrigin();
85
+ var origin = (0, globals_1.getOrigin)();
86
86
  if (typeof location === 'string') {
87
87
  return new URL(location, origin);
88
88
  }
89
89
  var pathname = location.pathname, search = location.search, hash = location.hash;
90
- return new URL("" + pathname + search + hash, origin);
90
+ return new URL("".concat(pathname).concat(search).concat(hash), origin);
91
91
  }
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
3
3
  var extendStatics = function (d, b) {
4
4
  extendStatics = Object.setPrototypeOf ||
5
5
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
7
  return extendStatics(d, b);
8
8
  };
9
9
  return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
10
12
  extendStatics(d, b);
11
13
  function __() { this.constructor = d; }
12
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
@@ -44,7 +46,7 @@ var TitleBar = /** @class */ (function (_super) {
44
46
  var _a = this.props, title = _a.title, primaryAction = _a.primaryAction, secondaryActions = _a.secondaryActions, actionGroups = _a.actionGroups;
45
47
  return {
46
48
  title: title,
47
- buttons: transformers_1.transformActions(app, {
49
+ buttons: (0, transformers_1.transformActions)(app, {
48
50
  primaryAction: primaryAction,
49
51
  secondaryActions: secondaryActions,
50
52
  actionGroups: actionGroups,
@@ -63,7 +65,7 @@ var TitleBar = /** @class */ (function (_super) {
63
65
  var button = actions_1.Button.create(app, {
64
66
  label: content || '',
65
67
  });
66
- var redirect = transformers_1.generateRedirect(app, url, target);
68
+ var redirect = (0, transformers_1.generateRedirect)(app, url, target);
67
69
  if (redirect != null) {
68
70
  button.subscribe(actions_1.Button.Action.CLICK, redirect);
69
71
  }
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
3
3
  var extendStatics = function (d, b) {
4
4
  extendStatics = Object.setPrototypeOf ||
5
5
  ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
7
  return extendStatics(d, b);
8
8
  };
9
9
  return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
10
12
  extendStatics(d, b);
11
13
  function __() { this.constructor = d; }
12
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
@@ -1,29 +1,37 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
8
12
  }));
9
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
11
18
  };
12
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.ResourcePicker = exports.ModalContent = exports.Modal = exports.TitleBar = exports.Toast = exports.Loading = exports.Provider = exports.ContextualSaveBar = void 0;
13
21
  var ContextualSaveBar_1 = require("./ContextualSaveBar");
14
- Object.defineProperty(exports, "ContextualSaveBar", { enumerable: true, get: function () { return ContextualSaveBar_1.default; } });
22
+ Object.defineProperty(exports, "ContextualSaveBar", { enumerable: true, get: function () { return __importDefault(ContextualSaveBar_1).default; } });
15
23
  var Provider_1 = require("./Provider");
16
- Object.defineProperty(exports, "Provider", { enumerable: true, get: function () { return Provider_1.default; } });
24
+ Object.defineProperty(exports, "Provider", { enumerable: true, get: function () { return __importDefault(Provider_1).default; } });
17
25
  var Loading_1 = require("./Loading");
18
- Object.defineProperty(exports, "Loading", { enumerable: true, get: function () { return Loading_1.default; } });
26
+ Object.defineProperty(exports, "Loading", { enumerable: true, get: function () { return __importDefault(Loading_1).default; } });
19
27
  var Toast_1 = require("./Toast");
20
- Object.defineProperty(exports, "Toast", { enumerable: true, get: function () { return Toast_1.default; } });
28
+ Object.defineProperty(exports, "Toast", { enumerable: true, get: function () { return __importDefault(Toast_1).default; } });
21
29
  var TitleBar_1 = require("./TitleBar");
22
- Object.defineProperty(exports, "TitleBar", { enumerable: true, get: function () { return TitleBar_1.default; } });
30
+ Object.defineProperty(exports, "TitleBar", { enumerable: true, get: function () { return __importDefault(TitleBar_1).default; } });
23
31
  var Modal_1 = require("./Modal");
24
- Object.defineProperty(exports, "Modal", { enumerable: true, get: function () { return Modal_1.default; } });
32
+ Object.defineProperty(exports, "Modal", { enumerable: true, get: function () { return __importDefault(Modal_1).default; } });
25
33
  Object.defineProperty(exports, "ModalContent", { enumerable: true, get: function () { return Modal_1.ModalContent; } });
26
34
  var ResourcePicker_1 = require("./ResourcePicker");
27
- Object.defineProperty(exports, "ResourcePicker", { enumerable: true, get: function () { return ResourcePicker_1.default; } });
35
+ Object.defineProperty(exports, "ResourcePicker", { enumerable: true, get: function () { return __importDefault(ResourcePicker_1).default; } });
28
36
  __exportStar(require("./RoutePropagator"), exports);
29
37
  __exportStar(require("./ClientRouter"), exports);
package/context.d.ts CHANGED
@@ -4,7 +4,7 @@ import { ClientApplication } from '@shopify/app-bridge/client';
4
4
  *
5
5
  * @public
6
6
  */
7
- export declare type IAppBridgeContext = ClientApplication<any> | null;
7
+ export declare type IAppBridgeContext = ClientApplication | null;
8
8
  /**
9
9
  * App Bridge context.
10
10
  *
package/context.js CHANGED
@@ -7,4 +7,4 @@ var react_1 = require("react");
7
7
  *
8
8
  * @public
9
9
  */
10
- exports.AppBridgeContext = react_1.createContext(null);
10
+ exports.AppBridgeContext = (0, react_1.createContext)(null);
package/hooks/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useToast = exports.useNavigationHistory = exports.useContextualSaveBar = void 0;
3
4
  var useContextualSaveBar_1 = require("./useContextualSaveBar");
4
5
  Object.defineProperty(exports, "useContextualSaveBar", { enumerable: true, get: function () { return useContextualSaveBar_1.useContextualSaveBar; } });
5
6
  var useNavigationHistory_1 = require("./useNavigationHistory");
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useContextualSaveBar = void 0;
3
4
  var useContextualSaveBar_1 = require("./useContextualSaveBar");
4
5
  Object.defineProperty(exports, "useContextualSaveBar", { enumerable: true, get: function () { return useContextualSaveBar_1.useContextualSaveBar; } });
@@ -17,7 +17,7 @@ var ContextualSaveBar_1 = require("@shopify/app-bridge/actions/ContextualSaveBar
17
17
  var useAppBridge_1 = require("../../useAppBridge");
18
18
  function useContextualSaveBar(_a) {
19
19
  var discardAction = _a.discardAction, saveAction = _a.saveAction, fullWidth = _a.fullWidth, leaveConfirmationDisable = _a.leaveConfirmationDisable, visible = _a.visible;
20
- var app = useAppBridge_1.useAppBridge();
20
+ var app = (0, useAppBridge_1.useAppBridge)();
21
21
  var onSaveAction = saveAction.onAction, saveActionProps = __rest(saveAction, ["onAction"]);
22
22
  var onDiscardAction = discardAction.onAction, discardActionProps = __rest(discardAction, ["onAction"]);
23
23
  /* We want to reuse the same ContextualSaveBar instance, even when props change
@@ -25,15 +25,15 @@ function useContextualSaveBar(_a) {
25
25
  * Instead of recreating the component on every change, we use the set method,
26
26
  * in the useEffect block below, to dispatch updates when props change.
27
27
  */
28
- var contextualSaveBar = react_1.useMemo(function () {
29
- return ContextualSaveBar_1.create(app, {
28
+ var contextualSaveBar = (0, react_1.useMemo)(function () {
29
+ return (0, ContextualSaveBar_1.create)(app, {
30
30
  saveAction: saveActionProps,
31
31
  discardAction: discardActionProps,
32
32
  fullWidth: fullWidth,
33
33
  leaveConfirmationDisable: leaveConfirmationDisable,
34
34
  });
35
35
  }, [app]);
36
- react_1.useEffect(function () {
36
+ (0, react_1.useEffect)(function () {
37
37
  contextualSaveBar.set({
38
38
  saveAction: saveActionProps,
39
39
  discardAction: discardActionProps,
@@ -48,14 +48,14 @@ function useContextualSaveBar(_a) {
48
48
  leaveConfirmationDisable,
49
49
  visible,
50
50
  ]);
51
- react_1.useEffect(function () {
51
+ (0, react_1.useEffect)(function () {
52
52
  contextualSaveBar.subscribe(ContextualSaveBar_1.Action.DISCARD, onDiscardAction);
53
53
  contextualSaveBar.subscribe(ContextualSaveBar_1.Action.SAVE, onSaveAction);
54
54
  return function () {
55
55
  contextualSaveBar.unsubscribe();
56
56
  };
57
57
  }, [contextualSaveBar]);
58
- react_1.useEffect(function () {
58
+ (0, react_1.useEffect)(function () {
59
59
  if (visible) {
60
60
  contextualSaveBar.dispatch(ContextualSaveBar_1.Action.SHOW);
61
61
  }
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useNavigationHistory = void 0;
3
4
  var useNavigationHistory_1 = require("./useNavigationHistory");
4
5
  Object.defineProperty(exports, "useNavigationHistory", { enumerable: true, get: function () { return useNavigationHistory_1.useNavigationHistory; } });
@@ -13,8 +13,8 @@ var useAppBridge_1 = require("../../useAppBridge");
13
13
  * @public
14
14
  */
15
15
  function useNavigationHistory() {
16
- var app = useAppBridge_1.useAppBridge();
17
- return react_1.useMemo(function () {
16
+ var app = (0, useAppBridge_1.useAppBridge)();
17
+ return (0, react_1.useMemo)(function () {
18
18
  var history = actions_1.History.create(app);
19
19
  function push(location) {
20
20
  history.dispatch(actions_1.History.Action.PUSH, location.pathname);
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useToast = void 0;
3
4
  var useToast_1 = require("./useToast");
4
5
  Object.defineProperty(exports, "useToast", { enumerable: true, get: function () { return useToast_1.useToast; } });
@@ -14,11 +14,11 @@ exports.DEFAULT_TOAST_DURATION = 5000;
14
14
  * @public
15
15
  */
16
16
  function useToast() {
17
- var app = useAppBridge_1.useAppBridge();
17
+ var app = (0, useAppBridge_1.useAppBridge)();
18
18
  var toast;
19
- var show = react_1.useCallback(function (_a) {
19
+ var show = (0, react_1.useCallback)(function (_a) {
20
20
  var message = _a.content, _b = _a.duration, duration = _b === void 0 ? exports.DEFAULT_TOAST_DURATION : _b, isError = _a.isError, onDismiss = _a.onDismiss;
21
- toast = Toast_1.create(app, {
21
+ toast = (0, Toast_1.create)(app, {
22
22
  message: message,
23
23
  isError: isError,
24
24
  duration: duration,
@@ -28,7 +28,7 @@ function useToast() {
28
28
  toast.subscribe(Toast_1.Action.CLEAR, onDismiss);
29
29
  }
30
30
  }, [app]);
31
- react_1.useEffect(function () {
31
+ (0, react_1.useEffect)(function () {
32
32
  return function () {
33
33
  toast.unsubscribe();
34
34
  };
package/index.js CHANGED
@@ -1,15 +1,20 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
8
12
  }));
9
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
15
  };
12
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.useAppBridge = exports.Context = void 0;
13
18
  __exportStar(require("./components"), exports);
14
19
  var context_1 = require("./context");
15
20
  Object.defineProperty(exports, "Context", { enumerable: true, get: function () { return context_1.AppBridgeContext; } });