UNPKG

1.79 kBJavaScriptView Raw
1"use strict";
2function __export(m) {
3 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
4}
5var __importStar = (this && this.__importStar) || function (mod) {
6 if (mod && mod.__esModule) return mod;
7 var result = {};
8 if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
9 result["default"] = mod;
10 return result;
11};
12var __importDefault = (this && this.__importDefault) || function (mod) {
13 return (mod && mod.__esModule) ? mod : { "default": mod };
14};
15Object.defineProperty(exports, "__esModule", { value: true });
16var actions = __importStar(require("./actions"));
17exports.actions = actions;
18var validate_1 = __importDefault(require("./validate"));
19var redirect_1 = require("./client/redirect");
20var client_1 = require("./client");
21var shared_1 = require("./util/shared");
22/**
23 * Creates your application instance with validator middleware.
24 * @param config - Both `apiKey` and `shopOrigin` are required.
25 * @remarks
26 * Please note that `forceRedirect` only works in production environment (`shopname.myshopify.com/admin`).
27 * You will need to store `shopOrigin` during the authentication process and then retrieve it for the code
28 * to work properly. To learn more about this process, see
29 * {@link https://help.shopify.com/api/embedded-apps/shop-origin | Getting and storing the shop origin}.
30 * @public
31 */
32function createApp(config) {
33 var currentWindow = redirect_1.getWindow();
34 if (!currentWindow) {
35 return shared_1.serverAppBridge;
36 }
37 return client_1.createAppWrapper(currentWindow.top, currentWindow.location.origin, [validate_1.default])(config);
38}
39exports.createApp = createApp;
40exports.default = createApp;
41__export(require("./MessageTransport"));
42__export(require("./client"));