Comparing version 1.17.2 to 1.17.3
{ | ||
"name": "sysend", | ||
"version": "1.17.2", | ||
"version": "1.17.3", | ||
"description": "Communication and Synchronization between browser tabs/windows. Works cross-domain.", | ||
@@ -5,0 +5,0 @@ "main": "sysend.js", |
@@ -5,4 +5,4 @@ <p align="center"> | ||
[![npm](https://img.shields.io/badge/npm-1.17.2-blue.svg)](https://www.npmjs.com/package/sysend) | ||
![bower](https://img.shields.io/badge/bower-1.17.2-yellow.svg) | ||
[![npm](https://img.shields.io/badge/npm-1.17.3-blue.svg)](https://www.npmjs.com/package/sysend) | ||
![bower](https://img.shields.io/badge/bower-1.17.3-yellow.svg) | ||
![downloads](https://img.shields.io/npm/dt/sysend.svg) | ||
@@ -302,3 +302,3 @@ [![jsdelivr](https://img.shields.io/jsdelivr/npm/hm/sysend)](https://www.jsdelivr.com/package/npm/sysend) | ||
Copyright (C) 2014-2023 [Jakub T. Jankiewicz](https://jcubic.pl/me)<br/> | ||
Copyright (C) 2014 [Jakub T. Jankiewicz](https://jcubic.pl/me)<br/> | ||
Released under the [MIT license](https://opensource.org/licenses/MIT) | ||
@@ -305,0 +305,0 @@ |
/**@license | ||
* sysend.js - send messages between browser windows/tabs version 1.17.1 | ||
* sysend.js - send messages between browser windows/tabs version 1.17.3 | ||
* | ||
* Copyright (C) 2014-2023 Jakub T. Jankiewicz <https://jcubic.pl/me> | ||
* Copyright (C) 2014 Jakub T. Jankiewicz <https://jcubic.pl/me> | ||
* Released under the MIT license | ||
@@ -32,9 +32,4 @@ * | ||
//Promise<Record<string, (id: string, ...args: T) => Promise<U>>; | ||
//type RPC<args extend Array | ||
declare const sysend: Sysend; | ||
export default sysend; |
/**@license | ||
* sysend.js - send messages between browser windows/tabs version 1.17.2 | ||
* sysend.js - send messages between browser windows/tabs version 1.17.3 | ||
* | ||
* Copyright (C) 2014-2023 Jakub T. Jankiewicz <https://jcubic.pl/me> | ||
* Copyright (C) 2014 Jakub T. Jankiewicz <https://jcubic.pl/me> | ||
* Released under the MIT license | ||
@@ -90,3 +90,3 @@ * | ||
serializer: function(to, from) { | ||
if (typeof to !== 'function' || typeof from !== 'function') { | ||
if (!(is_function(to) && is_function(from))) { | ||
throw new Error('sysend::serializer: Invalid argument, expecting' + | ||
@@ -101,5 +101,14 @@ ' function'); | ||
args.forEach(function(url) { | ||
if (typeof url === 'string' && host(url) !== window.location.host) { | ||
if (is_string(url) && host(url) !== window.location.host) { | ||
domains = domains || []; | ||
domains.push(origin(url)); | ||
var orig = origin(url); | ||
if (domains.includes(orig)) { | ||
var selector = 'iframe[src="' + url + '"]'; | ||
if (document.querySelector(selector)) { | ||
warn('You already called proxy on ' + url + | ||
' you only need to call this function once'); | ||
return; | ||
} | ||
} | ||
domains.push(orig); | ||
var iframe = document.createElement('iframe'); | ||
@@ -329,7 +338,2 @@ iframe.style.width = iframe.style.height = 0; | ||
// ------------------------------------------------------------------------- | ||
function is_promise(obj) { | ||
return obj && typeof object == 'object' && | ||
typeof object.then === 'function'; | ||
} | ||
// ------------------------------------------------------------------------- | ||
function unpromise(obj, callback, error = null) { | ||
@@ -418,2 +422,14 @@ if (is_promise(obj)) { | ||
// ------------------------------------------------------------------------- | ||
function is_promise(obj) { | ||
return obj && typeof object == 'object' && is_function(object.then); | ||
} | ||
// ------------------------------------------------------------------------- | ||
function is_function(o) { | ||
return typeof o === 'function'; | ||
} | ||
// ------------------------------------------------------------------------- | ||
function is_string(o) { | ||
return typeof o === 'string'; | ||
} | ||
// ------------------------------------------------------------------------- | ||
function is_internal(name) { | ||
@@ -426,5 +442,9 @@ return name.match(prefix_re); | ||
function is_sysend_post_message(e) { | ||
return typeof e.data === 'string' && is_internal(e.data); | ||
return is_string(e.data) && is_internal(e.data); | ||
} | ||
// ------------------------------------------------------------------------- | ||
function is_secured_iframe() { | ||
return is_proxy_iframe() && window.isSecureContext; | ||
} | ||
// ------------------------------------------------------------------------- | ||
function is_valid_origin(origin) { | ||
@@ -597,3 +617,3 @@ if (!domains) { | ||
} | ||
if (typeof document.addEventListener === 'function' && hidden) { | ||
if (is_function(document.addEventListener) && hidden) { | ||
document.addEventListener(visibilityChange, function() { | ||
@@ -853,4 +873,4 @@ trigger(handlers.visbility, !document[hidden]); | ||
function init() { | ||
if (typeof window.BroadcastChannel === 'function') { | ||
if (is_proxy_iframe() && document.requestStorageAccess) { | ||
if (is_function(window.BroadcastChannel)) { | ||
if (is_secured_iframe() && document.requestStorageAccess) { | ||
document.requestStorageAccess({ | ||
@@ -857,0 +877,0 @@ all: true |
Sorry, the diff of this file is not supported yet
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
51862
897