@shopware-ag/admin-extension-sdk
Advanced tools
Comparing version 0.0.23 to 0.0.24
@@ -1,1 +0,1 @@ | ||
var ee=Object.defineProperty;var D=Object.getOwnPropertySymbols;var te=Object.prototype.hasOwnProperty,ne=Object.prototype.propertyIsEnumerable;var I=(o,s,i)=>s in o?ee(o,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[s]=i,w=(o,s)=>{for(var i in s||(s={}))te.call(s,i)&&I(o,i,s[i]);if(D)for(var i of D(s))ne.call(s,i)&&I(o,i,s[i]);return o};(function(o,s){typeof exports=="object"&&typeof module!="undefined"?s(exports):typeof define=="function"&&define.amd?define(["exports"],s):(o=typeof globalThis!="undefined"?globalThis:o||self,s(o.sw={}))})(this,function(o){"use strict";function s(){return String(Date.now().toString(36)+Math.random().toString(36).substr(2))}function i(e,t){for(let r in e){const n=e[r];t.apply(this,[e,r,n]),y(n)&&i(n,t)}}function y(e){return e!==null&&typeof e=="object"}function O(e){E(e)}function x(e){R(e)}const h={};let b=!1;function z(){b||(b=!0,p("__function__",async({args:e,id:t})=>await Promise.resolve(h[t](...e))))}function E(e){i(e,(t,r,n)=>{if(typeof n=="function"){const a=s();h[a]=n,t[r]={__type__:"__function__",id:a},z()}})}function R(e){i(e,(t,r,n)=>{if(y(n)&&n.__type__&&n.__type__==="__function__"&&typeof n.id=="string"){const a=n.id;t[r]=(...d)=>f("__function__",{args:d,id:a})}})}const m=new Set;function f(e,t,r){const n=s(),a=t!=null?t:{},d={_type:e,_data:a,_callbackId:n};O(d);const u=JSON.stringify(d);let _=!1;const g=3e3;return new Promise((Z,V)=>{const S=function(L){if(typeof L.data!="string")return;let l;try{l=JSON.parse(L.data)}catch{return}!j(l)||l._callbackId===n&&(!l.hasOwnProperty("_response")||(window.removeEventListener("message",S),_||(_=!0,Z(l._response))))};window.addEventListener("message",S),window.parent.__Cypress__?r?r.postMessage(u,window.parent.origin):window.postMessage(u,window.parent.origin):r?r.postMessage(u,window.parent.origin):window.parent.postMessage(u,window.parent.origin),setTimeout(()=>{_||V("Send timeout expired. It could be possible that no handler for the postMessage request exists or that the handler freezed.")},g)})}function p(e,t){const r=async function(n){var g;if(typeof n.data!="string")return;let a;try{a=JSON.parse(n.data)}catch{return}if(!T(a)||a._type!==e)return;x(a);const d=await Promise.resolve(t(a._data,{_event_:n})),u={_callbackId:a._callbackId,_type:a._type,_response:d!=null?d:null},_=JSON.stringify(u);n.source?n.source.postMessage(_,{targetOrigin:(g=n.source.origin)!=null?g:"*"}):window.postMessage(_,window.origin)};return window.addEventListener("message",r),()=>window.removeEventListener("message",r)}function P(e,t){return p(e,t)}function c(e,t){return r=>f(e,w(w({},t),r))}function M(e){return t=>P(e,t)}(async()=>{p("__registerWindow__",(e,t)=>{t._event_.source?m.add(t._event_.source):m.add(window)}),await f("__registerWindow__",{})})().catch(e=>console.error(e));function T(e){const t=e;return!!t._type&&!!t._data&&!!t._callbackId}function j(e){const t=e;return!!t._type&&!!t.hasOwnProperty("_response")&&!!t._callbackId}const k=c("windowRedirect"),v=c("windowReload",{});var N=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",redirect:k,reload:v});const C=c("notificationDispatch");var H=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",dispatch:C});const J=c("contextLanguage",{}),$=M("contextLanguage"),q=c("contextEnvironment",{}),A=c("contextLocale",{}),U=M("contextLocale"),W=c("contextCurrency",{});var B=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",getLanguage:J,subscribeLanguage:$,getEnvironment:q,getLocale:A,subscribeLocale:U,getCurrency:W});const F=c("uiComponentSectionRenderer");var G=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",add:F});const K=e=>new URLSearchParams(window.location.search).get("location-id")===e,Q="sw-main-hidden";var X=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",is:K,MAIN_HIDDEN:Q});const Y={componentSection:G};o.context=B,o.location=X,o.notification=H,o.ui=Y,o.window=N,Object.defineProperty(o,"__esModule",{value:!0}),o[Symbol.toStringTag]="Module"}); | ||
var te=Object.defineProperty;var D=Object.getOwnPropertySymbols;var ne=Object.prototype.hasOwnProperty,oe=Object.prototype.propertyIsEnumerable;var I=(o,r,i)=>r in o?te(o,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):o[r]=i,w=(o,r)=>{for(var i in r||(r={}))ne.call(r,i)&&I(o,i,r[i]);if(D)for(var i of D(r))oe.call(r,i)&&I(o,i,r[i]);return o};(function(o,r){typeof exports=="object"&&typeof module!="undefined"?r(exports):typeof define=="function"&&define.amd?define(["exports"],r):(o=typeof globalThis!="undefined"?globalThis:o||self,r(o.sw={}))})(this,function(o){"use strict";function r(){return String(Date.now().toString(36)+Math.random().toString(36).substr(2))}function i(e,t){for(let s in e){const n=e[s];t.apply(this,[e,s,n]),h(n)&&i(n,t)}}function h(e){return e!==null&&typeof e=="object"}function O(e){H(e)}function x(e){z(e)}const y={};let m=!1;function E(){m||(m=!0,p("__function__",async({args:e,id:t})=>await Promise.resolve(y[t](...e))))}function H(e){i(e,(t,s,n)=>{if(typeof n=="function"){const a=r();y[a]=n,t[s]={__type__:"__function__",id:a},E()}})}function z(e){i(e,(t,s,n)=>{if(h(n)&&n.__type__&&n.__type__==="__function__"&&typeof n.id=="string"){const a=n.id;t[s]=(...d)=>l("__function__",{args:d,id:a})}})}const b=new Set;function l(e,t,s){const n=r(),a=t!=null?t:{},d={_type:e,_data:a,_callbackId:n};O(d);const u=JSON.stringify(d);let _=!1;const f=3e3;return new Promise((V,ee)=>{const S=function(L){if(typeof L.data!="string")return;let g;try{g=JSON.parse(L.data)}catch{return}!T(g)||g._callbackId===n&&(!g.hasOwnProperty("_response")||(window.removeEventListener("message",S),_||(_=!0,V(g._response))))};window.addEventListener("message",S),window.parent.__Cypress__?s?s.postMessage(u,window.parent.origin):window.postMessage(u,window.parent.origin):s?s.postMessage(u,window.parent.origin):window.parent.postMessage(u,window.parent.origin),setTimeout(()=>{_||ee("Send timeout expired. It could be possible that no handler for the postMessage request exists or that the handler freezed.")},f)})}function p(e,t){const s=async function(n){var f;if(typeof n.data!="string")return;let a;try{a=JSON.parse(n.data)}catch{return}if(!P(a)||a._type!==e)return;x(a);const d=await Promise.resolve(t(a._data,{_event_:n})),u={_callbackId:a._callbackId,_type:a._type,_response:d!=null?d:null},_=JSON.stringify(u);n.source?n.source.postMessage(_,{targetOrigin:(f=n.source.origin)!=null?f:"*"}):window.postMessage(_,window.origin)};return window.addEventListener("message",s),()=>window.removeEventListener("message",s)}function R(e,t){return p(e,t)}function c(e,t){return s=>l(e,w(w({},t),s))}function M(e){return t=>R(e,t)}(async()=>{p("__registerWindow__",(e,t)=>{t._event_.source?b.add(t._event_.source):b.add(window)}),await l("__registerWindow__",{})})().catch(e=>console.error(e));function P(e){const t=e;return!!t._type&&!!t._data&&!!t._callbackId}function T(e){const t=e;return!!t._type&&!!t.hasOwnProperty("_response")&&!!t._callbackId}const j=c("windowRedirect"),k=c("windowReload",{});var v=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",redirect:j,reload:k});const N=c("notificationDispatch");var C=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",dispatch:N});const J=c("contextLanguage",{}),U=M("contextLanguage"),$=c("contextEnvironment",{}),q=c("contextLocale",{}),A=M("contextLocale"),W=c("contextCurrency",{});var B=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",getLanguage:J,subscribeLanguage:U,getEnvironment:$,getLocale:q,subscribeLocale:A,getCurrency:W});const F=c("uiComponentSectionRenderer");var G=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",add:F});const K=e=>new URLSearchParams(window.location.search).get("location-id")===e,Q=e=>{if(e)return l("locationUpdateHeight",{height:e});const t=document.documentElement.scrollHeight;return l("locationUpdateHeight",{height:t})},X="sw-main-hidden";var Y=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",is:K,updateHeight:Q,MAIN_HIDDEN:X});const Z={componentSection:G};o.context=B,o.location=Y,o.notification=C,o.ui=Z,o.window=v,Object.defineProperty(o,"__esModule",{value:!0}),o[Symbol.toStringTag]="Module"}); |
@@ -52,3 +52,3 @@ import { ShopwareMessageTypes } from './messages.types'; | ||
}) => Promise<ShopwareMessageTypes[MESSAGE_TYPE]['responseType']> | ShopwareMessageTypes[MESSAGE_TYPE]['responseType']): () => void; | ||
export declare function publish<MESSAGE_TYPE extends keyof ShopwareMessageTypes>(type: MESSAGE_TYPE, data: ShopwareMessageTypes[MESSAGE_TYPE]['responseType']): Promise<(void | Awaited<ShopwareMessageTypes[MESSAGE_TYPE]["responseType"]> | null)[]>; | ||
export declare function publish<MESSAGE_TYPE extends keyof ShopwareMessageTypes>(type: MESSAGE_TYPE, data: ShopwareMessageTypes[MESSAGE_TYPE]['responseType']): Promise<(void | Awaited<ShopwareMessageTypes[MESSAGE_TYPE]['responseType']> | null)[]>; | ||
export declare function subscribe<MESSAGE_TYPE extends keyof ShopwareMessageTypes>(type: MESSAGE_TYPE, method: (data: ShopwareMessageTypes[MESSAGE_TYPE]['responseType']) => void | Promise<unknown>): () => void; | ||
@@ -55,0 +55,0 @@ /** |
@@ -176,3 +176,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
export function createSender(messageType, baseMessageOptions) { | ||
return (messageOptions) => send(messageType, Object.assign(Object.assign({}, baseMessageOptions), messageOptions)); | ||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type | ||
return (messageOptions) => { | ||
return send(messageType, Object.assign(Object.assign({}, baseMessageOptions), messageOptions)); | ||
}; | ||
} | ||
@@ -184,3 +187,6 @@ /** | ||
export function createHandler(messageType) { | ||
return (method) => handle(messageType, method); | ||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type | ||
return (method) => { | ||
return handle(messageType, method); | ||
}; | ||
} | ||
@@ -192,3 +198,6 @@ /** | ||
export function createSubscriber(messageType) { | ||
return (method) => subscribe(messageType, method); | ||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type | ||
return (method) => { | ||
return subscribe(messageType, method); | ||
}; | ||
} | ||
@@ -195,0 +204,0 @@ /** |
export declare const is: (location: string) => boolean; | ||
export declare const updateHeight: (height?: number | undefined) => Promise<void | null>; | ||
export declare const MAIN_HIDDEN = "sw-main-hidden"; | ||
export declare type locationUpdateHeight = { | ||
responseType: void; | ||
/** | ||
* The height of the iFrame | ||
*/ | ||
height: number; | ||
}; |
@@ -0,1 +1,2 @@ | ||
import { send } from '../channel'; | ||
// TODO: add documentation | ||
@@ -6,3 +7,13 @@ export const is = (location) => { | ||
}; | ||
export const updateHeight = (height) => { | ||
if (height) { | ||
return send('locationUpdateHeight', { height }); | ||
} | ||
// if no height is defined then send the current document height | ||
const currentHeight = document.documentElement.scrollHeight; | ||
return send('locationUpdateHeight', { height: currentHeight }); | ||
}; | ||
// TODO: add startAutoResizer to update the height automatically | ||
// TODO: add stopAutoResizer to stop the auto-update of the height | ||
export const MAIN_HIDDEN = 'sw-main-hidden'; | ||
//# sourceMappingURL=index.js.map |
@@ -5,2 +5,3 @@ import { notificationDispatch } from './notification/index'; | ||
import { uiComponentSectionRenderer } from './ui/componentSection/index'; | ||
import { locationUpdateHeight } from './location/index'; | ||
/** | ||
@@ -20,2 +21,3 @@ * Contains all shopware send types. | ||
uiComponentSectionRenderer: uiComponentSectionRenderer; | ||
locationUpdateHeight: locationUpdateHeight; | ||
__function__: __function__; | ||
@@ -22,0 +24,0 @@ __registerWindow__: __registerWindow__; |
{ | ||
"name": "@shopware-ag/admin-extension-sdk", | ||
"version": "0.0.23", | ||
"version": "0.0.24", | ||
"repository": "git://github.com/shopware/admin-extension-sdk.git", | ||
@@ -5,0 +5,0 @@ "description": "The SDK for App iframes to communicate with the Shopware Adminstration", |
@@ -52,3 +52,3 @@ import { ShopwareMessageTypes } from './messages.types'; | ||
}) => Promise<ShopwareMessageTypes[MESSAGE_TYPE]['responseType']> | ShopwareMessageTypes[MESSAGE_TYPE]['responseType']): () => void; | ||
export declare function publish<MESSAGE_TYPE extends keyof ShopwareMessageTypes>(type: MESSAGE_TYPE, data: ShopwareMessageTypes[MESSAGE_TYPE]['responseType']): Promise<(void | Awaited<ShopwareMessageTypes[MESSAGE_TYPE]["responseType"]> | null)[]>; | ||
export declare function publish<MESSAGE_TYPE extends keyof ShopwareMessageTypes>(type: MESSAGE_TYPE, data: ShopwareMessageTypes[MESSAGE_TYPE]['responseType']): Promise<(void | Awaited<ShopwareMessageTypes[MESSAGE_TYPE]['responseType']> | null)[]>; | ||
export declare function subscribe<MESSAGE_TYPE extends keyof ShopwareMessageTypes>(type: MESSAGE_TYPE, method: (data: ShopwareMessageTypes[MESSAGE_TYPE]['responseType']) => void | Promise<unknown>): () => void; | ||
@@ -55,0 +55,0 @@ /** |
@@ -192,3 +192,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function createSender(messageType, baseMessageOptions) { | ||
return (messageOptions) => send(messageType, Object.assign(Object.assign({}, baseMessageOptions), messageOptions)); | ||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type | ||
return (messageOptions) => { | ||
return send(messageType, Object.assign(Object.assign({}, baseMessageOptions), messageOptions)); | ||
}; | ||
} | ||
@@ -201,3 +204,6 @@ exports.createSender = createSender; | ||
function createHandler(messageType) { | ||
return (method) => handle(messageType, method); | ||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type | ||
return (method) => { | ||
return handle(messageType, method); | ||
}; | ||
} | ||
@@ -210,3 +216,6 @@ exports.createHandler = createHandler; | ||
function createSubscriber(messageType) { | ||
return (method) => subscribe(messageType, method); | ||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type | ||
return (method) => { | ||
return subscribe(messageType, method); | ||
}; | ||
} | ||
@@ -213,0 +222,0 @@ exports.createSubscriber = createSubscriber; |
export declare const is: (location: string) => boolean; | ||
export declare const updateHeight: (height?: number | undefined) => Promise<void | null>; | ||
export declare const MAIN_HIDDEN = "sw-main-hidden"; | ||
export declare type locationUpdateHeight = { | ||
responseType: void; | ||
/** | ||
* The height of the iFrame | ||
*/ | ||
height: number; | ||
}; |
@@ -7,3 +7,3 @@ (function (factory) { | ||
else if (typeof define === "function" && define.amd) { | ||
define(["require", "exports"], factory); | ||
define(["require", "exports", "../channel"], factory); | ||
} | ||
@@ -13,3 +13,4 @@ })(function (require, exports) { | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.MAIN_HIDDEN = exports.is = void 0; | ||
exports.MAIN_HIDDEN = exports.updateHeight = exports.is = void 0; | ||
const channel_1 = require("../channel"); | ||
// TODO: add documentation | ||
@@ -21,4 +22,15 @@ const is = (location) => { | ||
exports.is = is; | ||
const updateHeight = (height) => { | ||
if (height) { | ||
return (0, channel_1.send)('locationUpdateHeight', { height }); | ||
} | ||
// if no height is defined then send the current document height | ||
const currentHeight = document.documentElement.scrollHeight; | ||
return (0, channel_1.send)('locationUpdateHeight', { height: currentHeight }); | ||
}; | ||
exports.updateHeight = updateHeight; | ||
// TODO: add startAutoResizer to update the height automatically | ||
// TODO: add stopAutoResizer to stop the auto-update of the height | ||
exports.MAIN_HIDDEN = 'sw-main-hidden'; | ||
}); | ||
//# sourceMappingURL=index.js.map |
@@ -5,2 +5,3 @@ import { notificationDispatch } from './notification/index'; | ||
import { uiComponentSectionRenderer } from './ui/componentSection/index'; | ||
import { locationUpdateHeight } from './location/index'; | ||
/** | ||
@@ -20,2 +21,3 @@ * Contains all shopware send types. | ||
uiComponentSectionRenderer: uiComponentSectionRenderer; | ||
locationUpdateHeight: locationUpdateHeight; | ||
__function__: __function__; | ||
@@ -22,0 +24,0 @@ __registerWindow__: __registerWindow__; |
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
115956
1778