admin-shell-messaging
Advanced tools
Comparing version
@@ -1,2 +0,2 @@ | ||
import { CommonParams, InsertOnBreadcrumbParams } from "./types"; | ||
import { InsertOnBreadcrumbParams } from "./types"; | ||
export declare enum ACTION_TYPES { | ||
@@ -9,15 +9,13 @@ START_LOADING = "START_LOADING", | ||
export declare const ACTIONS: { | ||
START_LOADING: ({ executeOnShell }: CommonParams) => { | ||
START_LOADING: () => { | ||
action: { | ||
type: ACTION_TYPES; | ||
executeOnShell: boolean; | ||
}; | ||
}; | ||
STOP_LOADING: ({ executeOnShell }: CommonParams) => { | ||
STOP_LOADING: () => { | ||
action: { | ||
type: ACTION_TYPES; | ||
executeOnShell: boolean; | ||
}; | ||
}; | ||
INSERT_BREADCRUMB_EXTRA_LEVEL: ({ newLevelName, previousLevelUrl, executeOnShell, }: InsertOnBreadcrumbParams) => { | ||
INSERT_BREADCRUMB_EXTRA_LEVEL: ({ newLevelName, previousLevelUrl, }: InsertOnBreadcrumbParams) => { | ||
action: { | ||
@@ -27,11 +25,9 @@ type: ACTION_TYPES; | ||
previousLevelUrl: string; | ||
executeOnShell: boolean; | ||
}; | ||
}; | ||
CLEAR_BREADCRUMB_EXTRA_LEVELS: ({ executeOnShell, }: CommonParams) => { | ||
CLEAR_BREADCRUMB_EXTRA_LEVELS: () => { | ||
action: { | ||
type: ACTION_TYPES; | ||
executeOnShell: boolean; | ||
}; | ||
}; | ||
}; |
@@ -12,9 +12,9 @@ "use strict"; | ||
exports.ACTIONS = { | ||
START_LOADING: ({ executeOnShell = false }) => ({ | ||
action: { type: ACTION_TYPES.START_LOADING, executeOnShell }, | ||
START_LOADING: () => ({ | ||
action: { type: ACTION_TYPES.START_LOADING }, | ||
}), | ||
STOP_LOADING: ({ executeOnShell = false }) => ({ | ||
action: { type: ACTION_TYPES.STOP_LOADING, executeOnShell }, | ||
STOP_LOADING: () => ({ | ||
action: { type: ACTION_TYPES.STOP_LOADING }, | ||
}), | ||
INSERT_BREADCRUMB_EXTRA_LEVEL: ({ newLevelName, previousLevelUrl = window.location.pathname, executeOnShell = false, }) => ({ | ||
INSERT_BREADCRUMB_EXTRA_LEVEL: ({ newLevelName, previousLevelUrl = window.location.pathname, }) => ({ | ||
action: { | ||
@@ -24,9 +24,7 @@ type: ACTION_TYPES.INSERT_BREADCRUMB_EXTRA_LEVEL, | ||
previousLevelUrl, | ||
executeOnShell, | ||
}, | ||
}), | ||
CLEAR_BREADCRUMB_EXTRA_LEVELS: ({ executeOnShell = false, }) => ({ | ||
CLEAR_BREADCRUMB_EXTRA_LEVELS: () => ({ | ||
action: { | ||
type: ACTION_TYPES.CLEAR_BREADCRUMB_EXTRA_LEVELS, | ||
executeOnShell, | ||
}, | ||
@@ -33,0 +31,0 @@ }), |
@@ -43,13 +43,11 @@ "use strict"; | ||
function insertNewBreadcrumbLevel({ newLevelName, previousLevelUrl, executeOnShell, }) { | ||
const params = actions_1.ACTIONS.INSERT_BREADCRUMB_EXTRA_LEVEL({ | ||
newLevelName, | ||
previousLevelUrl, | ||
}); | ||
if (executeOnShell) { | ||
window.postMessage(actions_1.ACTIONS.INSERT_BREADCRUMB_EXTRA_LEVEL({ | ||
newLevelName, | ||
previousLevelUrl, | ||
}), "*"); | ||
window.postMessage(params, "*"); | ||
} | ||
else { | ||
window.top.postMessage(actions_1.ACTIONS.INSERT_BREADCRUMB_EXTRA_LEVEL({ | ||
newLevelName, | ||
previousLevelUrl, | ||
}), "*"); | ||
window.top.postMessage(params, "*"); | ||
} | ||
@@ -89,7 +87,8 @@ } | ||
function clearBreadcrumbExtraLevels({ executeOnShell }) { | ||
const params = actions_1.ACTIONS.CLEAR_BREADCRUMB_EXTRA_LEVELS(); | ||
if (executeOnShell) { | ||
window.postMessage(actions_1.ACTIONS.CLEAR_BREADCRUMB_EXTRA_LEVELS, "*"); | ||
window.postMessage(params, "*"); | ||
} | ||
else { | ||
window.top.postMessage(actions_1.ACTIONS.CLEAR_BREADCRUMB_EXTRA_LEVELS, "*"); | ||
window.top.postMessage(params, "*"); | ||
} | ||
@@ -96,0 +95,0 @@ } |
@@ -70,7 +70,8 @@ "use strict"; | ||
function startLoading({ executeOnShell }) { | ||
const params = actions_1.ACTIONS.START_LOADING(); | ||
if (executeOnShell) { | ||
window.postMessage(actions_1.ACTIONS.START_LOADING, "*"); | ||
window.postMessage(params, "*"); | ||
} | ||
else { | ||
window.top.postMessage(actions_1.ACTIONS.START_LOADING, "*"); | ||
window.top.postMessage(params, "*"); | ||
} | ||
@@ -142,7 +143,8 @@ return true; | ||
function stopLoading({ executeOnShell }) { | ||
const params = actions_1.ACTIONS.STOP_LOADING(); | ||
if (executeOnShell) { | ||
window.postMessage(actions_1.ACTIONS.START_LOADING, "*"); | ||
window.postMessage(params, "*"); | ||
} | ||
else { | ||
window.top.postMessage(actions_1.ACTIONS.START_LOADING, "*"); | ||
window.top.postMessage(params, "*"); | ||
} | ||
@@ -149,0 +151,0 @@ return true; |
{ | ||
"name": "admin-shell-messaging", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Admin shell Iframe messaging package", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -1,2 +0,2 @@ | ||
import { CommonParams, InsertOnBreadcrumbParams } from "./types"; | ||
import { InsertOnBreadcrumbParams } from "./types"; | ||
@@ -11,7 +11,7 @@ export enum ACTION_TYPES { | ||
export const ACTIONS = { | ||
START_LOADING: ({ executeOnShell = false }: CommonParams) => ({ | ||
action: { type: ACTION_TYPES.START_LOADING, executeOnShell }, | ||
START_LOADING: () => ({ | ||
action: { type: ACTION_TYPES.START_LOADING }, | ||
}), | ||
STOP_LOADING: ({ executeOnShell = false }: CommonParams) => ({ | ||
action: { type: ACTION_TYPES.STOP_LOADING, executeOnShell }, | ||
STOP_LOADING: () => ({ | ||
action: { type: ACTION_TYPES.STOP_LOADING }, | ||
}), | ||
@@ -21,3 +21,2 @@ INSERT_BREADCRUMB_EXTRA_LEVEL: ({ | ||
previousLevelUrl = window.location.pathname, | ||
executeOnShell = false, | ||
}: InsertOnBreadcrumbParams) => ({ | ||
@@ -28,13 +27,9 @@ action: { | ||
previousLevelUrl, | ||
executeOnShell, | ||
}, | ||
}), | ||
CLEAR_BREADCRUMB_EXTRA_LEVELS: ({ | ||
executeOnShell = false, | ||
}: CommonParams) => ({ | ||
CLEAR_BREADCRUMB_EXTRA_LEVELS: () => ({ | ||
action: { | ||
type: ACTION_TYPES.CLEAR_BREADCRUMB_EXTRA_LEVELS, | ||
executeOnShell, | ||
}, | ||
}), | ||
}; |
@@ -46,18 +46,11 @@ import { ACTIONS } from "./actions"; | ||
}: InsertOnBreadcrumbParams) { | ||
const params = ACTIONS.INSERT_BREADCRUMB_EXTRA_LEVEL({ | ||
newLevelName, | ||
previousLevelUrl, | ||
}); | ||
if (executeOnShell) { | ||
window.postMessage( | ||
ACTIONS.INSERT_BREADCRUMB_EXTRA_LEVEL({ | ||
newLevelName, | ||
previousLevelUrl, | ||
}), | ||
"*" | ||
); | ||
window.postMessage(params, "*"); | ||
} else { | ||
window.top.postMessage( | ||
ACTIONS.INSERT_BREADCRUMB_EXTRA_LEVEL({ | ||
newLevelName, | ||
previousLevelUrl, | ||
}), | ||
"*" | ||
); | ||
window.top.postMessage(params, "*"); | ||
} | ||
@@ -97,7 +90,9 @@ } | ||
export function clearBreadcrumbExtraLevels({ executeOnShell }: CommonParams) { | ||
const params = ACTIONS.CLEAR_BREADCRUMB_EXTRA_LEVELS(); | ||
if (executeOnShell) { | ||
window.postMessage(ACTIONS.CLEAR_BREADCRUMB_EXTRA_LEVELS, "*"); | ||
window.postMessage(params, "*"); | ||
} else { | ||
window.top.postMessage(ACTIONS.CLEAR_BREADCRUMB_EXTRA_LEVELS, "*"); | ||
window.top.postMessage(params, "*"); | ||
} | ||
} |
@@ -69,6 +69,8 @@ import { ACTIONS } from "./actions"; | ||
export function startLoading({ executeOnShell }: CommonParams) { | ||
const params = ACTIONS.START_LOADING(); | ||
if (executeOnShell) { | ||
window.postMessage(ACTIONS.START_LOADING, "*"); | ||
window.postMessage(params, "*"); | ||
} else { | ||
window.top.postMessage(ACTIONS.START_LOADING, "*"); | ||
window.top.postMessage(params, "*"); | ||
} | ||
@@ -141,6 +143,8 @@ | ||
export function stopLoading({ executeOnShell }: CommonParams) { | ||
const params = ACTIONS.STOP_LOADING(); | ||
if (executeOnShell) { | ||
window.postMessage(ACTIONS.START_LOADING, "*"); | ||
window.postMessage(params, "*"); | ||
} else { | ||
window.top.postMessage(ACTIONS.START_LOADING, "*"); | ||
window.top.postMessage(params, "*"); | ||
} | ||
@@ -147,0 +151,0 @@ |
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
28244
-3.44%840
-1.75%