Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@shopify/app-bridge

Package Overview
Dependencies
Maintainers
11
Versions
322
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shopify/app-bridge - npm Package Compare versions

Comparing version 1.0.0-0 to 1.0.0-1

6

actions/Error/types.d.ts

@@ -25,6 +25,8 @@ import { AnyAction, MetaAction } from '../types';

export declare enum AppActionType {
INVALID_CONFIG = "APP::ERROR:INVALID_CONFIG",
INVALID_CONFIG = "APP::ERROR::INVALID_CONFIG",
MISSING_CONFIG = "APP::APP_ERROR::MISSING_CONFIG",
MISSING_APP_BRIDGE_MIDDLEWARE = "APP::APP_ERROR::MISSING_APP_BRIDGE_MIDDLEWARE"
MISSING_APP_BRIDGE_MIDDLEWARE = "APP::APP_ERROR::MISSING_APP_BRIDGE_MIDDLEWARE",
WINDOW_UNDEFINED = "APP::APP_ERROR::WINDOW_UNDEFINED",
MISSING_LOCAL_ORIGIN = "APP::APP_ERROR::MISSING_LOCAL_ORIGIN"
}
export declare type Payload = MetaAction | AnyAction;

@@ -29,6 +29,8 @@ "use strict";

(function (AppActionType) {
AppActionType["INVALID_CONFIG"] = "APP::ERROR:INVALID_CONFIG";
AppActionType["INVALID_CONFIG"] = "APP::ERROR::INVALID_CONFIG";
AppActionType["MISSING_CONFIG"] = "APP::APP_ERROR::MISSING_CONFIG";
AppActionType["MISSING_APP_BRIDGE_MIDDLEWARE"] = "APP::APP_ERROR::MISSING_APP_BRIDGE_MIDDLEWARE";
AppActionType["WINDOW_UNDEFINED"] = "APP::APP_ERROR::WINDOW_UNDEFINED";
AppActionType["MISSING_LOCAL_ORIGIN"] = "APP::APP_ERROR::MISSING_LOCAL_ORIGIN";
})(AppActionType = exports.AppActionType || (exports.AppActionType = {}));
//# sourceMappingURL=types.js.map

@@ -10,5 +10,4 @@ /**

import { Action, ActionType, ClosePayload, Footer, FooterOptions, IframeOptions, IframePayload, MessageOptions, MessagePayload, Size } from './types';
export declare const GROUP = Group.Modal;
export interface ActionBase extends MetaAction {
readonly group: typeof GROUP;
readonly group: typeof Group.Modal;
}

@@ -15,0 +14,0 @@ export interface OpenAction extends ActionBase {

@@ -35,5 +35,4 @@ "use strict";

var types_2 = require("./types");
exports.GROUP = types_1.Group.Modal;
var FOOTER_BUTTON_PROPS = {
group: exports.GROUP,
group: types_1.Group.Modal,
subgroups: ['Footer'],

@@ -44,3 +43,3 @@ type: types_1.ComponentType.Button,

return helper_1.actionWrapper({
group: exports.GROUP,
group: types_1.Group.Modal,
payload: modalPayload,

@@ -53,3 +52,3 @@ type: types_2.ActionType.OPEN,

return helper_1.actionWrapper({
group: exports.GROUP,
group: types_1.Group.Modal,
payload: modalClosePayload,

@@ -62,3 +61,3 @@ type: types_2.ActionType.CLOSE,

var component = __assign({ id: id }, FOOTER_BUTTON_PROPS);
return Button_1.clickButton(exports.GROUP, component, payload);
return Button_1.clickButton(types_1.Group.Modal, component, payload);
}

@@ -69,3 +68,3 @@ exports.clickFooterButton = clickFooterButton;

payload: payload,
group: exports.GROUP,
group: types_1.Group.Modal,
type: types_2.ActionType.UPDATE,

@@ -316,3 +315,3 @@ });

function ModalMessage(app, options) {
var _this = _super.call(this, app, exports.GROUP, exports.GROUP) || this;
var _this = _super.call(this, app, types_1.Group.Modal, types_1.Group.Modal) || this;
_this.set(options, false);

@@ -387,3 +386,3 @@ return _this;

function ModalIframe(app, options) {
var _this = _super.call(this, app, exports.GROUP, exports.GROUP) || this;
var _this = _super.call(this, app, types_1.Group.Modal, types_1.Group.Modal) || this;
_this.set(options, false);

@@ -390,0 +389,0 @@ return _this;

@@ -9,5 +9,4 @@ /**

import { Action, ActionType, AdminPathPayload, AdminSectionPayload, AppPayload, CreateResource, ProductVariantResource, RemotePayload, ResourceInfo, Section } from './types';
export declare const GROUP = Group.Navigation;
export interface ActionBase extends MetaAction {
readonly group: typeof GROUP;
readonly group: typeof Group.Navigation;
}

@@ -14,0 +13,0 @@ export interface AdminPathAction extends ActionBase {

@@ -35,3 +35,2 @@ "use strict";

var types_2 = require("./types");
exports.GROUP = types_1.Group.Navigation;
function isResourcePayload(resource) {

@@ -63,3 +62,3 @@ // tslint:disable-next-line:no-boolean-literal-compare

payload: payload,
group: exports.GROUP,
group: types_1.Group.Navigation,
type: types_2.ActionType.ADMIN_PATH,

@@ -72,3 +71,3 @@ });

payload: payload,
group: exports.GROUP,
group: types_1.Group.Navigation,
type: types_2.ActionType.ADMIN_SECTION,

@@ -81,3 +80,3 @@ });

payload: payload,
group: exports.GROUP,
group: types_1.Group.Navigation,
type: types_2.ActionType.REMOTE,

@@ -90,3 +89,3 @@ });

payload: payload,
group: exports.GROUP,
group: types_1.Group.Navigation,
type: types_2.ActionType.APP,

@@ -93,0 +92,0 @@ });

@@ -9,5 +9,4 @@ /**

import { Action, ActionType, BaseOptions, CancelPayload, ClosePayload, Options, Payload, ProductOptions, ResourceSelection, ResourceType, SelectPayload } from './types';
export declare const GROUP = Group.ResourcePicker;
export interface ActionBase extends MetaAction {
readonly group: typeof GROUP;
readonly group: typeof Group.ResourcePicker;
}

@@ -14,0 +13,0 @@ export interface SelectAction extends ActionBase {

@@ -34,7 +34,6 @@ "use strict";

var types_2 = require("./types");
exports.GROUP = types_1.Group.ResourcePicker;
function select(payload) {
return helper_1.actionWrapper({
payload: payload,
group: exports.GROUP,
group: types_1.Group.ResourcePicker,
type: types_2.ActionType.SELECT,

@@ -47,3 +46,3 @@ });

payload: payload,
group: exports.GROUP,
group: types_1.Group.ResourcePicker,
type: types_2.ActionType.OPEN,

@@ -56,3 +55,3 @@ });

payload: payload,
group: exports.GROUP,
group: types_1.Group.ResourcePicker,
type: types_2.ActionType.CANCEL,

@@ -65,3 +64,3 @@ });

payload: payload,
group: exports.GROUP,
group: types_1.Group.ResourcePicker,
type: types_2.ActionType.CANCEL,

@@ -74,3 +73,3 @@ });

payload: payload,
group: exports.GROUP,
group: types_1.Group.ResourcePicker,
type: types_2.ActionType.UPDATE,

@@ -114,7 +113,7 @@ });

function ResourcePicker(app, options, resourceType) {
var _this = _super.call(this, app, exports.GROUP, exports.GROUP) || this;
var _this = _super.call(this, app, types_1.Group.ResourcePicker, types_1.Group.ResourcePicker) || this;
_this.selection = [];
if (!isValidResourceType(resourceType)) {
var errorAction = helper_1.actionWrapper({
group: exports.GROUP,
group: types_1.Group.ResourcePicker,
payload: __assign({ id: _this.id }, options, { resourceType: resourceType }),

@@ -121,0 +120,0 @@ });

@@ -11,5 +11,4 @@ /**

import { Action, ButtonsOptions as TitleBarButtonsOptions, ButtonsPayload as TitleBarButtonsPayload, Options, Payload } from './types';
export declare const GROUP = Group.TitleBar;
export interface UpdateAction extends MetaAction {
readonly group: typeof GROUP;
readonly group: typeof Group.TitleBar;
payload: Payload;

@@ -16,0 +15,0 @@ }

@@ -38,9 +38,8 @@ "use strict";

var types_2 = require("./types");
exports.GROUP = types_1.Group.TitleBar;
var TITLEBAR_BUTTON_PROPS = {
group: exports.GROUP,
group: types_1.Group.TitleBar,
subgroups: ['Buttons'],
};
var BREADCRUMB_BUTTON_PROPS = {
group: exports.GROUP,
group: types_1.Group.TitleBar,
subgroups: ['Breadcrumbs'],

@@ -52,3 +51,3 @@ type: types_1.ComponentType.Button,

var component = __assign({ id: id, type: type }, TITLEBAR_BUTTON_PROPS);
return Button_1.clickButton(exports.GROUP, component, payload);
return Button_1.clickButton(types_1.Group.TitleBar, component, payload);
}

@@ -58,3 +57,3 @@ exports.clickActionButton = clickActionButton;

var component = __assign({ id: id }, BREADCRUMB_BUTTON_PROPS);
return Button_1.clickButton(exports.GROUP, component, payload);
return Button_1.clickButton(types_1.Group.TitleBar, component, payload);
}

@@ -65,3 +64,3 @@ exports.clickBreadcrumb = clickBreadcrumb;

payload: payload,
group: exports.GROUP,
group: types_1.Group.TitleBar,
type: types_2.ActionType.UPDATE,

@@ -149,3 +148,3 @@ });

function TitleBar(app, options) {
var _this = _super.call(this, app, exports.GROUP, exports.GROUP) || this;
var _this = _super.call(this, app, types_1.Group.TitleBar, types_1.Group.TitleBar) || this;
// Trigger 'update' on creation

@@ -152,0 +151,0 @@ _this.set(options);

@@ -6,2 +6,16 @@ # Change Log

<a name="1.0.0-1"></a>
# [1.0.0-1](https://github.com/Shopify/app-bridge/compare/v1.0.0-0...v1.0.0-1) (2018-12-03)
### Bug Fixes
* ensure window exists before accessing its methods and props ([443650d](https://github.com/Shopify/app-bridge/commit/443650d))
* error handling for undefined shopOrigin and apiKey ([ffccd9a](https://github.com/Shopify/app-bridge/commit/ffccd9a))
* **app-bridge:** add webpack config to gitignore exclusion ([e55dece](https://github.com/Shopify/app-bridge/commit/e55dece))
* **app-bridge:** fix typescript lib generation for older clients ([451d300](https://github.com/Shopify/app-bridge/commit/451d300))
<a name="1.0.0-0"></a>

@@ -8,0 +22,0 @@ # [1.0.0-0](https://github.com/Shopify/app-bridge/compare/v0.1.2-2...v1.0.0-0) (2018-11-29)

@@ -9,2 +9,2 @@ import { AppConfig, ClientApplication, ClientApplicationCreator, ClientApplicationTransportInjector } from './types';

export declare function createAppWrapper(frame: Window, localOrigin?: string): ClientApplicationCreator;
export default function (config: AppConfig): ClientApplication<{}>;
export default function (config: AppConfig): ClientApplication<any>;

@@ -28,5 +28,9 @@ "use strict";

var redirect_1 = require("./redirect");
var WINDOW_UNDEFINED_MESSAGE = 'window is not defined. Running an app outside a browser is not supported';
function redirectHandler(hostFrame, config) {
var apiKey = config.apiKey, shopOrigin = config.shopOrigin, _a = config.forceRedirect, forceRedirect = _a === void 0 ? !env_1.isDevelopmentClient : _a;
var location = redirect_1.getLocation();
if (!location) {
return;
}
if (forceRedirect && redirect_1.shouldRedirect(hostFrame) && apiKey && shopOrigin) {

@@ -42,5 +46,8 @@ var url = "https://" + shopOrigin + "/admin/apps/" + apiKey + location.pathname + (location.search ||

function getUrlParams() {
var params = {};
var location = redirect_1.getLocation();
if (!location) {
return params;
}
var hashes = location.search.slice(location.search.indexOf('?') + 1).split('&');
var params = {};
return hashes.reduce(function (acc, hash) {

@@ -102,2 +109,8 @@ var _a;

return function (config /*initialState*/) {
if (!config.shopOrigin) {
throw Error_1.fromAction('shopOrigin must be provided', Error_1.AppActionType.INVALID_CONFIG);
}
if (!config.apiKey) {
throw Error_1.fromAction('apiKey must be provided', Error_1.AppActionType.INVALID_CONFIG);
}
redirectHandler(transport.hostFrame, config);

@@ -169,3 +182,11 @@ var app = {

function createAppWrapper(frame, localOrigin) {
var transport = MessageTransport_1.fromWindow(frame, localOrigin || window.location.origin);
if (!frame) {
throw Error_1.fromAction(WINDOW_UNDEFINED_MESSAGE, Error_1.AppActionType.WINDOW_UNDEFINED);
}
var location = redirect_1.getLocation();
var origin = localOrigin || (location && location.origin);
if (!origin) {
throw Error_1.fromAction('local origin cannot be blank', Error_1.AppActionType.MISSING_LOCAL_ORIGIN);
}
var transport = MessageTransport_1.fromWindow(frame, origin);
return exports.createClientApp(transport);

@@ -175,5 +196,9 @@ }

function default_1(config) {
return createAppWrapper(window.top)(config);
var currentWindow = redirect_1.getWindow();
if (!currentWindow) {
throw Error_1.fromAction(WINDOW_UNDEFINED_MESSAGE, Error_1.AppActionType.WINDOW_UNDEFINED);
}
return createAppWrapper(currentWindow.top)(config);
}
exports.default = default_1;
//# sourceMappingURL=Client.js.map

@@ -7,2 +7,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var redirect_1 = require("./redirect");
function isRunningOniOS() {

@@ -12,3 +13,4 @@ return navigator.userAgent.indexOf('iOS') >= 0;

function createHiddenInput() {
if (!window.document || !window.document.body) {
var currentWindow = redirect_1.getWindow();
if (!currentWindow || !currentWindow.document || !currentWindow.document.body) {
return;

@@ -22,2 +24,5 @@ }

function printWindow() {
if (!redirect_1.getWindow()) {
return;
}
// @ts-ignore: Fixed in TypeScript 2.8.2

@@ -24,0 +29,0 @@ window.print();

@@ -7,2 +7,3 @@ /**

export declare function redirect(url: string): void;
export declare function getLocation(): Location;
export declare function getLocation(): Location | undefined;
export declare function getWindow(): Window | undefined;

@@ -12,9 +12,20 @@ "use strict";

function redirect(url) {
window.location.assign(url);
var location = getLocation();
if (!location) {
return;
}
location.assign(url);
}
exports.redirect = redirect;
function getLocation() {
return window.location;
return hasWindow() ? window.location : undefined;
}
exports.getLocation = getLocation;
function getWindow() {
return hasWindow() ? window : undefined;
}
exports.getWindow = getWindow;
function hasWindow() {
return typeof window !== 'undefined';
}
//# sourceMappingURL=redirect.js.map

@@ -6,2 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var Error_1 = require("./actions/Error");
var validator_1 = require("./actions/validator");

@@ -14,2 +15,5 @@ var collection_1 = require("./util/collection");

var handlers = [];
if (typeof frame === 'undefined' || !frame.ownerDocument || !frame.ownerDocument.defaultView) {
throw Error_1.fromAction('App frame is undefined', Error_1.AppActionType.WINDOW_UNDEFINED);
}
var parent = frame.ownerDocument.defaultView;

@@ -45,3 +49,3 @@ parent.addEventListener('message', function (event) {

var handlers = [];
if (contentWindow !== window) {
if (typeof window !== undefined && contentWindow !== window) {
window.addEventListener('message', function (event) {

@@ -48,0 +52,0 @@ if (event.source !== contentWindow ||

{
"name": "@shopify/app-bridge",
"version": "1.0.0-0",
"version": "1.0.0-1",
"types": "index.d.ts",

@@ -33,9 +33,19 @@ "main": "index.js",

"clean": "cat package.json | node -pe \"JSON.parse(require('fs').readFileSync('/dev/stdin').toString()).files.join(' ')\" | xargs rm -rf",
"pack": "yarn pack"
"pack": "yarn pack",
"size": "size-limit"
},
"sideEffects": false,
"size-limit": [
{
"limit": "14 KB",
"path": "index.js"
}
],
"devDependencies": {
"@types/node": "^10.12.5",
"typescript": "^3.2.0-dev.20181115"
"typescript": "3.2.1"
},
"resolutions": {
"sqlite3": "4.0.1"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc