UNPKG

1.88 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 utils_1 = require("./validate/utils");
20var redirect_1 = require("./client/redirect");
21var client_1 = require("./client");
22var shared_1 = require("./util/shared");
23/**
24 * Creates your application instance with validator middleware.
25 * @param config - Both `apiKey` and `shopOrigin` are required.
26 * @remarks
27 * Please note that `forceRedirect` only works in production environment (`shopname.myshopify.com/admin`).
28 * You will need to store `shopOrigin` during the authentication process and then retrieve it for the code
29 * to work properly. To learn more about this process, see
30 * {@link https://help.shopify.com/api/embedded-apps/shop-origin | Getting and storing the shop origin}.
31 * @public
32 */
33function createApp(config) {
34 var currentWindow = redirect_1.getWindow();
35 if (!currentWindow) {
36 return shared_1.serverAppBridge;
37 }
38 utils_1.mixedAppClientCheck(currentWindow);
39 return client_1.createAppWrapper(currentWindow.top, currentWindow.location.origin, [validate_1.default])(config);
40}
41exports.createApp = createApp;
42exports.default = createApp;
43__export(require("./MessageTransport"));
44__export(require("./client"));