@shopify/app-bridge
Advanced tools
Comparing version 2.0.5 to 2.0.6
@@ -30,3 +30,3 @@ import { Group, MetaAction } from '../types'; | ||
export interface RespondWithAuthCodeAction extends ActionBase { | ||
readonly type: typeof Action.RESPOND; | ||
readonly type: typeof Action.REQUEST; | ||
payload?: ResponsePayload; | ||
@@ -33,0 +33,0 @@ } |
@@ -117,6 +117,7 @@ "use strict"; | ||
break; | ||
case Action.UPDATE: | ||
case Action.UPDATE: { | ||
var updateAction = update(this.group, this.component, this.payload); | ||
this.app.dispatch(updateAction); | ||
break; | ||
} | ||
} | ||
@@ -123,0 +124,0 @@ return this; |
@@ -96,6 +96,7 @@ "use strict"; | ||
switch (action) { | ||
case Action.UPDATE: | ||
case Action.UPDATE: { | ||
var updateAction = update(this.group, this.component, this.payload); | ||
this.app.dispatch(updateAction); | ||
break; | ||
} | ||
} | ||
@@ -102,0 +103,0 @@ return this; |
@@ -148,11 +148,15 @@ "use strict"; | ||
function throwError() { | ||
var type = arguments[0]; | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
var type = args[0]; | ||
var message; | ||
var action; | ||
if (typeof arguments[1] === 'string') { | ||
message = arguments[1]; | ||
if (typeof args[1] === 'string') { | ||
message = args[1]; | ||
} | ||
else { | ||
action = arguments[1]; | ||
message = arguments[2] || ''; | ||
action = args[1]; | ||
message = args[2] || ''; | ||
} | ||
@@ -159,0 +163,0 @@ throw fromAction(message, type, action); |
@@ -91,10 +91,12 @@ "use strict"; | ||
switch (action) { | ||
case Action.OPEN: | ||
case Action.OPEN: { | ||
var openAction = open(this.payload); | ||
this.app.dispatch(openAction); | ||
break; | ||
case Action.CLOSE: | ||
} | ||
case Action.CLOSE: { | ||
var closeAction = close(this.payload); | ||
this.app.dispatch(closeAction); | ||
break; | ||
} | ||
} | ||
@@ -101,0 +103,0 @@ return this; |
@@ -45,2 +45,3 @@ "use strict"; | ||
var uuid_1 = __importDefault(require("./uuid")); | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
var packageJson = require('../package.json'); | ||
@@ -188,3 +189,3 @@ function actionWrapper(action) { | ||
updateSubscribe: function (group, subgroups) { | ||
return _this.updateSubscription.call(_this, subscription, group, subgroups); | ||
return _this.updateSubscription(subscription, group, subgroups); | ||
}, | ||
@@ -222,3 +223,3 @@ }; | ||
this.children.forEach(function (child) { | ||
if (ActionSetWithChildren.prototype.isPrototypeOf(child)) { | ||
if (child instanceof ActionSetWithChildren) { | ||
child.unsubscribe(unsubscribeChildren, !unsubscribeChildren); | ||
@@ -260,4 +261,6 @@ } | ||
// Update child's children subscriptions | ||
if (ActionSetWithChildren.prototype.isPrototypeOf(child)) { | ||
child.children.forEach(function (c) { return _this.addChild(c, group, subgroups); }); | ||
if (child instanceof ActionSetWithChildren) { | ||
child.children.forEach(function (childIter) { | ||
return _this.addChild(childIter, group, subgroups); | ||
}); | ||
} | ||
@@ -282,3 +285,3 @@ return this; | ||
if (eventName instanceof Array) { | ||
eventName.forEach(function (e) { return _this.subscribeToChild(child, e, callback); }); | ||
eventName.forEach(function (eventNameIter) { return _this.subscribeToChild(child, eventNameIter, callback); }); | ||
return this; | ||
@@ -340,2 +343,3 @@ } | ||
var updateSubscribe = subscription.updateSubscribe; | ||
// eslint-disable-next-line no-warning-comments | ||
// TODO: Support cases where we don't wipe out group and subgroups to defaults | ||
@@ -388,3 +392,3 @@ updateSubscribe(defaultGroup, []); | ||
return value.replace(/([A-Z])/g, function (matcher, _val, index) { | ||
return "" + (index !== 0 ? '_' : '') + matcher[0].toLowerCase(); | ||
return "" + (index === 0 ? '' : '_') + matcher[0].toLowerCase(); | ||
}); | ||
@@ -391,0 +395,0 @@ } |
@@ -104,14 +104,17 @@ "use strict"; | ||
switch (action) { | ||
case Action.ENABLE: | ||
case Action.ENABLE: { | ||
var enableAction = enable(this.payload); | ||
this.app.dispatch(enableAction); | ||
break; | ||
case Action.DISABLE: | ||
} | ||
case Action.DISABLE: { | ||
var disableAction = disable(this.payload); | ||
this.app.dispatch(disableAction); | ||
break; | ||
case Action.CONFIRM: | ||
} | ||
case Action.CONFIRM: { | ||
var confirmAction = confirm(this.payload); | ||
this.app.dispatch(confirmAction); | ||
break; | ||
} | ||
} | ||
@@ -118,0 +121,0 @@ return this; |
@@ -95,6 +95,7 @@ "use strict"; | ||
switch (action) { | ||
case Action.UPDATE: | ||
case Action.UPDATE: { | ||
var updateAction = update(this.group, this.component, this.payload); | ||
this.app.dispatch(updateAction); | ||
break; | ||
} | ||
} | ||
@@ -101,0 +102,0 @@ return this; |
@@ -15,3 +15,3 @@ "use strict"; | ||
if (typeof obj === 'undefined' || | ||
!Object.getPrototypeOf(obj).isPrototypeOf(newObj) || | ||
!Object.prototype.isPrototypeOf.call(Object.getPrototypeOf(obj), newObj) || | ||
(newObj.constructor.name !== 'Object' && newObj.constructor.name !== 'Array')) { | ||
@@ -22,3 +22,3 @@ return newObj; | ||
Object.keys(newObj).forEach(function (key) { | ||
var exists = obj.hasOwnProperty(key); | ||
var exists = Object.prototype.hasOwnProperty.call(obj, key); | ||
if (!exists) { | ||
@@ -36,3 +36,3 @@ clone[key] = newObj[key]; | ||
Object.keys(obj).forEach(function (key) { | ||
var exists = newObj.hasOwnProperty(key); | ||
var exists = Object.prototype.hasOwnProperty.call(newObj, key); | ||
if (!exists) { | ||
@@ -39,0 +39,0 @@ clone[key] = obj[key]; |
@@ -102,9 +102,11 @@ "use strict"; | ||
switch (action) { | ||
case Action.APP: | ||
case Action.APP: { | ||
var appPayload = isAppPayload(payload) ? payload : { path: payload }; | ||
return toApp(__assign({ id: id }, appPayload)); | ||
case Action.ADMIN_PATH: | ||
} | ||
case Action.ADMIN_PATH: { | ||
var adminPathPayload = isAdminPathPayload(payload) ? payload : { path: payload }; | ||
return toAdminPath(__assign({ id: id }, adminPathPayload)); | ||
case Action.ADMIN_SECTION: | ||
} | ||
case Action.ADMIN_SECTION: { | ||
var adminSectionPayload = isAdminSectionPayload(payload) | ||
@@ -114,5 +116,7 @@ ? payload | ||
return toAdminSection(__assign({ id: id }, adminSectionPayload)); | ||
case Action.REMOTE: | ||
} | ||
case Action.REMOTE: { | ||
var remotePayload = isRemotePayload(payload) ? payload : { url: payload }; | ||
return toRemote(__assign({ id: id }, remotePayload)); | ||
} | ||
} | ||
@@ -122,17 +126,15 @@ } | ||
function isAppPayload(payload) { | ||
return typeof payload === 'object' && payload.hasOwnProperty('path'); | ||
return typeof payload === 'object' && payload.path; | ||
} | ||
exports.isAppPayload = isAppPayload; | ||
function isAdminPathPayload(payload) { | ||
return typeof payload === 'object' && payload.hasOwnProperty('path'); | ||
return typeof payload === 'object' && payload.path; | ||
} | ||
exports.isAdminPathPayload = isAdminPathPayload; | ||
function isAdminSectionPayload(payload) { | ||
return (typeof payload === 'object' && | ||
typeof payload.section === 'object' && | ||
payload.section.hasOwnProperty('name')); | ||
return typeof payload === 'object' && typeof payload.section === 'object' && payload.section.name; | ||
} | ||
exports.isAdminSectionPayload = isAdminSectionPayload; | ||
function isRemotePayload(payload) { | ||
return typeof payload === 'object' && payload.hasOwnProperty('url'); | ||
return typeof payload === 'object' && payload.url; | ||
} | ||
@@ -139,0 +141,0 @@ exports.isRemotePayload = isRemotePayload; |
@@ -34,2 +34,3 @@ "use strict"; | ||
Action["SELECT"] = "APP::RESOURCE_PICKER::SELECT"; | ||
// Deprecated in 0.5.0 | ||
Action["CLOSE"] = "APP::RESOURCE_PICKER::CLOSE"; | ||
@@ -36,0 +37,0 @@ Action["UPDATE"] = "APP::RESOURCE_PICKER::UPDATE"; |
@@ -62,3 +62,3 @@ "use strict"; | ||
default: | ||
throw "Action: " + action + " not supported"; | ||
throw new Error("Action: " + action + " not supported"); | ||
} | ||
@@ -65,0 +65,0 @@ return this; |
@@ -88,6 +88,7 @@ "use strict"; | ||
switch (action) { | ||
case Action.SHOW: | ||
case Action.SHOW: { | ||
var openAction = show(this.payload); | ||
this.app.dispatch(openAction); | ||
break; | ||
} | ||
case Action.CLEAR: | ||
@@ -94,0 +95,0 @@ this.app.dispatch(clear({ id: this.id })); |
@@ -40,11 +40,17 @@ "use strict"; | ||
return [ | ||
// time-low | ||
asHex(getRandomBytes(4)), | ||
'-', | ||
// time-mid | ||
asHex(getRandomBytes(2)), | ||
'-', | ||
// time-high-and-version | ||
asHex(timeHiAndVersion), | ||
'-', | ||
// clock-seq-and-reserved | ||
asHex(clockSeqHiAndReserved), | ||
// clock-seq-loq | ||
asHex(getRandomBytes(1)), | ||
'-', | ||
// node | ||
asHex(getRandomBytes(6)), | ||
@@ -51,0 +57,0 @@ ].join(''); |
@@ -12,5 +12,3 @@ "use strict"; | ||
function isAppBridgeAction(action) { | ||
return (action instanceof Object && | ||
action.hasOwnProperty('type') && | ||
action.type.toString().startsWith(constants_1.PREFIX)); | ||
return (action instanceof Object && Boolean(action.type) && action.type.toString().startsWith(constants_1.PREFIX)); | ||
} | ||
@@ -43,3 +41,3 @@ exports.isAppBridgeAction = isAppBridgeAction; | ||
var group = _a.group, type = _a.type; | ||
if (!group || !features.hasOwnProperty(group)) { | ||
if (!group) { | ||
return false; | ||
@@ -64,4 +62,4 @@ } | ||
var data = event.data; | ||
return data.hasOwnProperty('type') && helper_1.findMatchInEnum(types_1.MessageType, data.type) !== undefined; | ||
return data.type && helper_1.findMatchInEnum(types_1.MessageType, data.type) !== undefined; | ||
} | ||
exports.isAppMessage = isAppMessage; |
@@ -6,2 +6,14 @@ # Change Log | ||
## [2.0.6](https://github.com/Shopify/app-bridge/compare/v2.0.5...v2.0.6) (2022-01-25) | ||
### Bug Fixes | ||
* added back dependencies in package.json ([0e220d3](https://github.com/Shopify/app-bridge/commit/0e220d3f47d0a226d4451095a524483c533da416)) | ||
* made prototype calls more readable and cleaned up imports ([365f63e](https://github.com/Shopify/app-bridge/commit/365f63ec8076de232ae3e685f7ceb4e5530da4f4)) | ||
## [2.0.5](https://github.com/Shopify/app-bridge/compare/v2.0.4...v2.0.5) (2021-10-20) | ||
@@ -8,0 +20,0 @@ |
@@ -54,7 +54,8 @@ "use strict"; | ||
switch (type) { | ||
case 'getState': | ||
case 'getState': { | ||
var resolvers = getStateListeners.splice(0); | ||
resolvers.forEach(function (resolver) { return resolver(payload); }); | ||
break; | ||
case 'dispatch': | ||
} | ||
case 'dispatch': { | ||
transportListener.handleMessage(payload); | ||
@@ -71,2 +72,3 @@ var hasCallback = transportListener.handleActionDispatch(payload); | ||
break; | ||
} | ||
default: | ||
@@ -129,13 +131,14 @@ // Silently swallow unknown actions | ||
}).then(function (state) { | ||
var newState = state; | ||
if (query) { | ||
return query.split('.').reduce(function (value, key) { | ||
return query.split('.').reduce(function (_, key) { | ||
if (typeof state !== 'object' || Array.isArray(state)) { | ||
return undefined; | ||
} | ||
value = state[key]; | ||
state = value; | ||
return value; | ||
var stateValue = state[key]; | ||
newState = state[key]; | ||
return stateValue; | ||
}, undefined); | ||
} | ||
return state; | ||
return newState; | ||
}); | ||
@@ -142,0 +145,0 @@ }, |
@@ -51,3 +51,3 @@ "use strict"; | ||
Hooks.prototype.set = function (hook, handler) { | ||
if (!this.map.hasOwnProperty(hook)) { | ||
if (!this.map[hook]) { | ||
this.map[hook] = []; | ||
@@ -54,0 +54,0 @@ } |
@@ -22,3 +22,2 @@ "use strict"; | ||
} | ||
// @ts-ignore: Fixed in TypeScript 2.8.2 | ||
window.print(); | ||
@@ -25,0 +24,0 @@ } |
@@ -128,3 +128,3 @@ "use strict"; | ||
var payload = { type: type, id: id }; | ||
if (!Object.prototype.hasOwnProperty.call(actionListeners, type)) { | ||
if (!actionListeners[type]) { | ||
actionListeners[type] = []; | ||
@@ -151,3 +151,3 @@ } | ||
var hasCallback = false; | ||
if (Object.prototype.hasOwnProperty.call(actionListeners, type)) { | ||
if (actionListeners[type]) { | ||
for (var _i = 0, _b = actionListeners[type]; _i < _b.length; _i++) { | ||
@@ -154,0 +154,0 @@ var listener = _b[_i]; |
{ | ||
"name": "@shopify/app-bridge", | ||
"version": "2.0.5", | ||
"version": "2.0.6", | ||
"types": "index.d.ts", | ||
@@ -56,3 +56,3 @@ "main": "index.js", | ||
}, | ||
"gitHead": "34f24f749cde5eeb742adf968895fc75a9b5391a" | ||
"gitHead": "3b74e2850234c72339d7d73670ba69276b44cb7a" | ||
} |
@@ -8,11 +8,11 @@ "use strict"; | ||
Object.defineProperty(exports, "Action", { enumerable: true, get: function () { return AppLink_1.Action; } }); | ||
var allowedRedirectTypes; | ||
(function (allowedRedirectTypes) { | ||
allowedRedirectTypes["APP"] = "APP::NAVIGATION::REDIRECT::APP"; | ||
allowedRedirectTypes["LEGACY_APP"] = "APP"; | ||
})(allowedRedirectTypes || (allowedRedirectTypes = {})); | ||
var AllowedRedirectType; | ||
(function (AllowedRedirectType) { | ||
AllowedRedirectType["APP"] = "APP::NAVIGATION::REDIRECT::APP"; | ||
AllowedRedirectType["LEGACY_APP"] = "APP"; | ||
})(AllowedRedirectType || (AllowedRedirectType = {})); | ||
exports.linkPropsSchema = type_validate_1.matchesObject({ | ||
label: type_validate_1.matchesString(), | ||
destination: utils_1.relativeUrlSchema, | ||
redirectType: type_validate_1.matchesEnum(allowedRedirectTypes), | ||
redirectType: type_validate_1.matchesEnum(AllowedRedirectType), | ||
}); | ||
@@ -22,3 +22,3 @@ exports.linkActionSchema = type_validate_1.matchesObject({ | ||
destination: utils_1.relativePathSchema, | ||
redirectType: type_validate_1.matchesEnum(allowedRedirectTypes), | ||
redirectType: type_validate_1.matchesEnum(AllowedRedirectType), | ||
}); | ||
@@ -25,0 +25,0 @@ function validateProps(props) { |
@@ -15,3 +15,3 @@ "use strict"; | ||
} | ||
return action.payload.hasOwnProperty('url') ? urlError : textError; | ||
return action.payload.url ? urlError : textError; | ||
} | ||
@@ -18,0 +18,0 @@ exports.validateAction = validateAction; |
@@ -40,3 +40,3 @@ "use strict"; | ||
} | ||
return error.map(function (o) { return (__assign(__assign({}, o), { path: "" + (path || '') + (o.path || '') || undefined })); }); | ||
return error.map(function (errorObj) { return (__assign(__assign({}, errorObj), { path: "" + (path || '') + (errorObj.path || '') || undefined })); }); | ||
} | ||
@@ -43,0 +43,0 @@ function matchesBoolean(options) { |
@@ -45,5 +45,6 @@ "use strict"; | ||
window.addEventListener('DOMContentLoaded', function () { | ||
if (!window.hasOwnProperty('ShopifyApp')) { | ||
if (!window.ShopifyApp) { | ||
return; | ||
} | ||
// eslint-disable-next-line no-console | ||
console.error("%cException Detected \uD83D\uDEAB\n\n%cAn instance of the EASDK client was detected while initializing Shopify App Bridge. Using Shopify App Bridge and the EASDK simultaneously is not supported.\n\nIf you're migrating an existing app that was built with the shopify_app gem, then the EASDK client might have been included in the home page view template. In this case, remove it from your app before initializing Shopify App Bridge again.", 'font-size: large;', 'font-size: normal;'); | ||
@@ -50,0 +51,0 @@ }, { once: true }); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
863218
18254