@aplazame/browser
Advanced tools
Comparing version 0.0.8 to 0.0.9
@@ -9,6 +9,7 @@ | ||
export class AplazameIFrame extends EventEmitter { | ||
#allowMessage = e => e.data?.source === 'aplazame' | ||
#allowFilter = e => e.data?.source === 'aplazame' | ||
#sendData = { source: 'aplazame' } | ||
#requestTimeout = 60000 | ||
constructor ({ url = null, searchParams = null, requestTimeout = null } = {}) { | ||
constructor ({ url = null, searchParams = null, requestTimeout = null, allowFilter = null, messageData = null } = {}) { | ||
super({ Event: AplazameEvent }) | ||
@@ -22,2 +23,4 @@ | ||
if (allowFilter) this.#allowFilter = allowFilter | ||
if (messageData) this.#messageData = messageData | ||
if (requestTimeout) this.#requestTimeout = requestTimeout | ||
@@ -27,3 +30,3 @@ } | ||
#onMessage (e) { | ||
if (!this.#allowMessage(e)) return | ||
if (!this.#allowFilter(e)) return | ||
@@ -39,3 +42,3 @@ if (e.data?.event) { | ||
return new Promise(resolve => { | ||
this.iframe.contentWindow.postMessage({ source: 'aplazame', request, payload }, '*') | ||
this.iframe.contentWindow.postMessage({ ...this.#sendData, request, payload }, '*') | ||
const onResponse = () => { | ||
@@ -51,2 +54,7 @@ this.off(request, onResponse) | ||
async send (event, _payload) { | ||
const payload = _payload ? copyObject(_payload) : _payload | ||
this.iframe.contentWindow.postMessage({ ...this.#sendData, event, payload }, '*') | ||
} | ||
mount (el) { | ||
@@ -53,0 +61,0 @@ this.mount_el = el |
{ | ||
"name": "@aplazame/browser", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "Aplazame SDK for browser", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6137
5
142