New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@saleor/app-bridge

Package Overview
Dependencies
Maintainers
5
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@saleor/app-bridge - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

dist/types.d.ts

7

dist/app-bridge.cjs.development.js

@@ -854,2 +854,3 @@ 'use strict';

var state = {
id: "",
domain: "",

@@ -977,2 +978,4 @@ ready: false

function createApp(targetDomain) {
var _URL$searchParams$get;
var domain;

@@ -987,4 +990,6 @@

var id = (_URL$searchParams$get = new URL(domain).searchParams.get("id")) != null ? _URL$searchParams$get : "";
app.setState({
domain: domain
domain: domain,
id: id
});

@@ -991,0 +996,0 @@ /**

2

dist/app-bridge.cjs.production.min.js

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("uuid");function e(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function r(t){return function(){var r=this,n=arguments;return new Promise((function(o,i){var a=t.apply(r,n);function c(t){e(a,o,i,c,u,"next",t)}function u(t){e(a,o,i,c,u,"throw",t)}c(void 0)}))}}function n(){return(n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}var o,i=(function(t){var e=function(t){var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=Object.create((e&&e.prototype instanceof l?e:l).prototype),i=new E(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=b(a,r);if(c){if(c===h)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,i),o}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var h={};function l(){}function f(){}function p(){}var d={};c(d,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(O([])));v&&v!==e&&r.call(v,o)&&(d=v);var g=p.prototype=l.prototype=Object.create(d);function w(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function m(t,e){var n;this._invoke=function(o,i){function a(){return new e((function(n,a){!function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var h=u.arg,l=h.value;return l&&"object"==typeof l&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(l).then((function(t){h.value=t,a(h)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return h;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return h}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,h;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function x(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function L(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function E(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function O(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:k}}function k(){return{value:void 0,done:!0}}return f.prototype=p,c(g,"constructor",p),c(p,"constructor",f),f.displayName=c(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===f||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,c(t,a,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},w(m.prototype),c(m.prototype,i,(function(){return this})),t.AsyncIterator=m,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new m(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(g),c(g,a,"Generator"),c(g,o,(function(){return this})),c(g,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=O,E.prototype={constructor:E,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(L),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,h):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),L(r),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;L(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:O(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}}(o={exports:{}}),o.exports),a="undefined"==typeof window,c={handshake:"handshake",response:"response"},u=function(){if(a)return console.warn("@saleor/app-bridge detected you're running this app in SSR mode. Make sure to call `createApp` when window object exists."),null;var t,e={domain:"",ready:!1},r={handshake:{},response:{}};try{t=new URL(document.referrer).origin}catch(t){console.warn("document.referrer is empty")}return window.addEventListener("message",(function(o){var i=o.data;if(o.origin===t){e=function(t,e){switch(e.type){case c.handshake:return n({},t,{ready:!0,token:e.payload.token});default:return t}}(e,i);var a=i.type,u=i.payload;c.hasOwnProperty(a)&&Object.getOwnPropertySymbols(r[a]).forEach((function(t){return r[a][t](u)}))}})),{subscribe:function(t,e){var n=Symbol();return r[t][n]=e,function(){delete r[t][n]}},unsubscribeAll:function(t){t?r[t]={}:r={handshake:{},response:{}}},getState:function(){return e},setState:function(t){return e=n({},e,t)}}}(),s={Redirect:function(e){return r={payload:e,type:"redirect"},o=t.v4(),n({},r,{payload:n({},r.payload,{actionId:o})});var r,o}};function h(t){var e;function n(){return(n=r(i.mark((function t(e){return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t,r){if(window.parent){var n;window.parent.postMessage({type:e.type,payload:e.payload},"*");var o=u.subscribe(c.response,(function(i){var a=i.ok;e.payload.actionId===i.actionId&&(o(),clearInterval(n),a?t():r("Error: Action responded with negative status. This indicates the action method was not used properly."))}));n=setInterval((function(){o(),r("Error: Action response timed out.")}),1e3)}else r("Error: Parent window does not exist.")})));case 1:case"end":return t.stop()}}),t)})))).apply(this,arguments)}return e=t||new URL(window.location.href).searchParams.get("domain")||"",u.setState({domain:e}),{dispatch:function(t){return n.apply(this,arguments)},subscribe:u.subscribe,unsubscribeAll:u.unsubscribeAll,getState:u.getState}}exports.ActionType={redirect:"redirect"},exports.EventType=c,exports.actions=s,exports.createApp=h,exports.default=h;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("uuid");function e(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function r(t){return function(){var r=this,n=arguments;return new Promise((function(o,i){var a=t.apply(r,n);function c(t){e(a,o,i,c,u,"next",t)}function u(t){e(a,o,i,c,u,"throw",t)}c(void 0)}))}}function n(){return(n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}var o,i=(function(t){var e=function(t){var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=Object.create((e&&e.prototype instanceof h?e:h).prototype),i=new E(n||[]);return o._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var c=b(a,r);if(c){if(c===l)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,i),o}function s(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function h(){}function f(){}function p(){}var d={};c(d,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(O([])));v&&v!==e&&r.call(v,o)&&(d=v);var g=p.prototype=h.prototype=Object.create(d);function w(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function m(t,e){var n;this._invoke=function(o,i){function a(){return new e((function(n,a){!function n(o,i,a,c){var u=s(t[o],t,i);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==typeof h&&r.call(h,"__await")?e.resolve(h.__await).then((function(t){n("next",t,a,c)}),(function(t){n("throw",t,a,c)})):e.resolve(h).then((function(t){l.value=t,a(l)}),(function(t){return n("throw",t,a,c)}))}c(u.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=s(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,l;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function x(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function L(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function E(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function O(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:k}}function k(){return{value:void 0,done:!0}}return f.prototype=p,c(g,"constructor",p),c(p,"constructor",f),f.displayName=c(p,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===f||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,p):(t.__proto__=p,c(t,a,"GeneratorFunction")),t.prototype=Object.create(g),t},t.awrap=function(t){return{__await:t}},w(m.prototype),c(m.prototype,i,(function(){return this})),t.AsyncIterator=m,t.async=function(e,r,n,o,i){void 0===i&&(i=Promise);var a=new m(u(e,r,n,o),i);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},w(g),c(g,a,"Generator"),c(g,o,(function(){return this})),c(g,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=O,E.prototype={constructor:E,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(L),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return a.type="throw",a.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,l):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),L(r),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;L(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:O(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},t}(t.exports);try{regeneratorRuntime=e}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}}(o={exports:{}}),o.exports),a="undefined"==typeof window,c={handshake:"handshake",response:"response"},u=function(){if(a)return console.warn("@saleor/app-bridge detected you're running this app in SSR mode. Make sure to call `createApp` when window object exists."),null;var t,e={id:"",domain:"",ready:!1},r={handshake:{},response:{}};try{t=new URL(document.referrer).origin}catch(t){console.warn("document.referrer is empty")}return window.addEventListener("message",(function(o){var i=o.data;if(o.origin===t){e=function(t,e){switch(e.type){case c.handshake:return n({},t,{ready:!0,token:e.payload.token});default:return t}}(e,i);var a=i.type,u=i.payload;c.hasOwnProperty(a)&&Object.getOwnPropertySymbols(r[a]).forEach((function(t){return r[a][t](u)}))}})),{subscribe:function(t,e){var n=Symbol();return r[t][n]=e,function(){delete r[t][n]}},unsubscribeAll:function(t){t?r[t]={}:r={handshake:{},response:{}}},getState:function(){return e},setState:function(t){return e=n({},e,t)}}}(),s={Redirect:function(e){return r={payload:e,type:"redirect"},o=t.v4(),n({},r,{payload:n({},r.payload,{actionId:o})});var r,o}};function l(t){var e,n;n=t||new URL(window.location.href).searchParams.get("domain")||"";var o=null!=(e=new URL(n).searchParams.get("id"))?e:"";function a(){return(a=r(i.mark((function t(e){return i.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t,r){if(window.parent){var n;window.parent.postMessage({type:e.type,payload:e.payload},"*");var o=u.subscribe(c.response,(function(i){var a=i.ok;e.payload.actionId===i.actionId&&(o(),clearInterval(n),a?t():r("Error: Action responded with negative status. This indicates the action method was not used properly."))}));n=setInterval((function(){o(),r("Error: Action response timed out.")}),1e3)}else r("Error: Parent window does not exist.")})));case 1:case"end":return t.stop()}}),t)})))).apply(this,arguments)}return u.setState({domain:n,id:o}),{dispatch:function(t){return a.apply(this,arguments)},subscribe:u.subscribe,unsubscribeAll:u.unsubscribeAll,getState:u.getState}}exports.ActionType={redirect:"redirect"},exports.EventType=c,exports.actions=s,exports.createApp=l,exports.default=l;
//# sourceMappingURL=app-bridge.cjs.production.min.js.map

@@ -850,2 +850,3 @@ import { v4 } from 'uuid';

var state = {
id: "",
domain: "",

@@ -973,2 +974,4 @@ ready: false

function createApp(targetDomain) {
var _URL$searchParams$get;
var domain;

@@ -983,4 +986,6 @@

var id = (_URL$searchParams$get = new URL(domain).searchParams.get("id")) != null ? _URL$searchParams$get : "";
app.setState({
domain: domain
domain: domain,
id: id
});

@@ -987,0 +992,0 @@ /**

import { PayloadOfEvent } from "./events";
declare type State = {
export declare type AppBridgeState = {
token?: string;
id: string;
ready: boolean;

@@ -23,5 +24,5 @@ domain: string;

unsubscribeAll: (eventType?: "handshake" | "response" | undefined) => void;
getState: () => State;
setState: (newState: Partial<State>) => State;
getState: () => AppBridgeState;
setState: (newState: Partial<AppBridgeState>) => AppBridgeState;
};
export {};

@@ -10,8 +10,3 @@ export declare function createApp(targetDomain?: string): {

payload: {
token: string; /**
* Dispatches Action to Saleor Dashboard.
*
* @param action - Action containing type and payload.
* @returns Promise resolved when Action is successfully completed.
*/
token: string;
version: 1;

@@ -28,10 +23,7 @@ };

unsubscribeAll: (eventType?: "handshake" | "response" | undefined) => void;
getState: () => {
token?: string | undefined;
ready: boolean;
domain: string;
};
getState: () => import("./app").AppBridgeState;
};
export * from "./events";
export * from "./actions";
export * from "./types";
export default createApp;
{
"version": "0.1.5",
"version": "0.1.6",
"license": "MIT",

@@ -4,0 +4,0 @@ "main": "dist/index.js",

@@ -20,3 +20,3 @@ # Saleor App Bridge

```js
const { token, domain, ready } = app.getState();
const { token, domain, ready, id } = app.getState();
```

@@ -23,0 +23,0 @@

import { SSR } from "./constants";
import { Events, EventType, PayloadOfEvent } from "./events";
type State = {
export type AppBridgeState = {
token?: string;
id: string;
ready: boolean;

@@ -14,3 +15,3 @@ domain: string;

function reducer(state: State, event: Events) {
function reducer(state: AppBridgeState, event: Events) {
switch (event.type) {

@@ -40,3 +41,4 @@ case EventType.handshake: {

let state: State = {
let state: AppBridgeState = {
id: "",
domain: "",

@@ -125,3 +127,3 @@ ready: false,

function setState(newState: Partial<State>) {
function setState(newState: Partial<AppBridgeState>) {
state = {

@@ -128,0 +130,0 @@ ...state,

@@ -15,4 +15,6 @@ import { Actions } from "./actions";

app.setState({ domain });
const id = new URL(domain).searchParams.get("id") ?? "";
app.setState({ domain, id });
/**

@@ -76,2 +78,3 @@ * Dispatches Action to Saleor Dashboard.

export * from "./actions";
export * from "./types";
export default createApp;

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

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