@gooddata/js-utils
Advanced tools
Comparing version 3.10.4 to 3.10.5-lanhuynh-lhq-sd-886-2020-04-23T01-42-25-359Z
@@ -1,13 +0,2 @@ | ||
export interface IGdcMessageEvent extends MessageEvent { | ||
data: { | ||
gdc: { | ||
product: string; | ||
event: { | ||
name: string; | ||
data: any; | ||
}; | ||
}; | ||
}; | ||
} | ||
export declare type GdcMessageEventListener = (event: IGdcMessageEvent) => boolean; | ||
import { GdcMessageEventListener } from '@gooddata/typings'; | ||
export interface IHost { | ||
@@ -18,5 +7,5 @@ postMessage?: Window['postMessage']; | ||
export declare const setHost: (h: IHost) => void; | ||
export declare const postEvent: (product: string, name: string, data: any) => void; | ||
export declare const postEvent: (product: string, name: string, data: any, contextId?: string | undefined) => void; | ||
export declare function setConfig(product: string, validReceivedPostEvents: string[]): void; | ||
export declare function addListener(listener: GdcMessageEventListener, target?: Window): void; | ||
export declare function removeListener(listener: GdcMessageEventListener, target?: Window): void; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// (C) 2007-2019 GoodData Corporation | ||
// (C) 2007-2020 GoodData Corporation | ||
var get_1 = __importDefault(require("lodash/get")); | ||
@@ -21,3 +21,3 @@ var host; | ||
}; | ||
exports.postEvent = function (product, name, data) { | ||
exports.postEvent = function (product, name, data, contextId) { | ||
if (!host.postMessage) { | ||
@@ -29,3 +29,3 @@ return; | ||
product: product, | ||
event: { name: name, data: data } | ||
event: { name: name, data: data, contextId: contextId } | ||
} | ||
@@ -32,0 +32,0 @@ }, '*'); |
{ | ||
"name": "@gooddata/js-utils", | ||
"version": "3.10.4", | ||
"version": "3.10.5-lanhuynh-lhq-sd-886-2020-04-23T01-42-25-359Z", | ||
"description": "Various utils shared on GoodData frontend", | ||
@@ -49,2 +49,3 @@ "repository": { | ||
"dependencies": { | ||
"@gooddata/typings": "^2.24.0", | ||
"js-cookie": "^2.1.4", | ||
@@ -51,0 +52,0 @@ "lodash": "^4.17.15" |
@@ -1,17 +0,5 @@ | ||
// (C) 2007-2019 GoodData Corporation | ||
// (C) 2007-2020 GoodData Corporation | ||
import get from 'lodash/get'; | ||
import { IGdcMessageEvent, GdcMessageEventListener, IGdcMessageEventListenerConfig } from '@gooddata/typings'; | ||
export interface IGdcMessageEvent extends MessageEvent { | ||
data: { | ||
gdc: { | ||
product: string; | ||
event: { | ||
name: string; | ||
data: any; | ||
} | ||
} | ||
}; | ||
} | ||
export type GdcMessageEventListener = (event: IGdcMessageEvent) => boolean; | ||
export interface IHost { | ||
@@ -35,3 +23,3 @@ postMessage?: Window['postMessage']; | ||
export const postEvent = (product: string, name: string, data: any): void => { | ||
export const postEvent = (product: string, name: string, data: any, contextId?: string): void => { | ||
if (!host.postMessage) { | ||
@@ -43,3 +31,3 @@ return; | ||
product, | ||
event: { name, data } | ||
event: { name, data, contextId } | ||
} | ||
@@ -53,8 +41,6 @@ }, '*'); | ||
} | ||
const receivers: IReceiverEntry[] = []; | ||
interface IConfig { | ||
product: string; | ||
validReceivedPostEvents: string[]; | ||
} | ||
let config: IConfig = { | ||
let config: IGdcMessageEventListenerConfig = { | ||
product: '', | ||
@@ -64,3 +50,5 @@ validReceivedPostEvents: [] | ||
const receiveListener = (listener: GdcMessageEventListener): GdcMessageEventListener => (event: IGdcMessageEvent) => { | ||
const receiveListener = ( | ||
listener: GdcMessageEventListener | ||
): GdcMessageEventListener => (event: IGdcMessageEvent<string, string, any>) => { | ||
return ( | ||
@@ -67,0 +55,0 @@ get(event, 'data.gdc.product') === config.product && |
@@ -1,3 +0,4 @@ | ||
// (C) 2007-2018 GoodData Corporation | ||
import { setHost, postEvent, setConfig, addListener, removeListener, IGdcMessageEvent } from '../post-events'; | ||
// (C) 2007-2020 GoodData Corporation | ||
import { IGdcMessageEvent } from '@gooddata/typings'; | ||
import { setHost, postEvent, setConfig, addListener, removeListener } from '../post-events'; | ||
@@ -34,3 +35,3 @@ describe('Post events', () => { | ||
beforeEach(() => { | ||
listener = (e: IGdcMessageEvent) => e.data.gdc.event.data; | ||
listener = (e: IGdcMessageEvent<string, string, any>) => e.data.gdc.event.data; | ||
target = { | ||
@@ -37,0 +38,0 @@ addEventListener: jest.fn(), |
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
73107
3
1475
2
+ Added@gooddata/typings@^2.24.0
+ Added@gooddata/typings@2.29.0(transitive)