Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

framebus

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

framebus - npm Package Compare versions

Comparing version 4.0.1 to 4.0.2

4

CHANGELOG.md

@@ -0,1 +1,5 @@

# v4.0.2
- Fix issue where rollup bundlers could not import framebus (see [braintree-web#504](https://github.com/braintree/braintree-web/issues/504))
# v4.0.1

@@ -2,0 +6,0 @@

22

dist/framebus.d.ts

@@ -1,10 +0,12 @@

import type { FramebusSubscriberArg, FramebusOnHandler, FramebusReplyHandler } from "./lib/types";
export default class Framebus {
origin: string;
constructor(origin?: string);
include(childWindow: Window): boolean;
target(origin?: string): Framebus;
emit(event: string, data?: FramebusSubscriberArg | FramebusReplyHandler, reply?: FramebusReplyHandler): boolean;
on(event: string, fn: FramebusOnHandler): boolean;
off(event: string, fn: FramebusOnHandler): boolean;
}
import type { FramebusOnHandler, FramebusReplyHandler } from "./lib/types";
declare const _default: {
new (origin?: string): {
origin: string;
include(childWindow: Window): boolean;
target(origin?: string): any;
emit(event: string, data?: Record<string, unknown> | FramebusReplyHandler | undefined, reply?: FramebusReplyHandler | undefined): boolean;
on(event: string, fn: FramebusOnHandler): boolean;
off(event: string, fn: FramebusOnHandler): boolean;
};
};
export = _default;
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var is_not_string_1 = __importDefault(require("./lib/is-not-string"));
var subscription_args_invalid_1 = __importDefault(require("./lib/subscription-args-invalid"));
var broadcast_1 = __importDefault(require("./lib/broadcast"));
var package_payload_1 = __importDefault(require("./lib/package-payload"));
var is_not_string_1 = require("./lib/is-not-string");
var subscription_args_invalid_1 = require("./lib/subscription-args-invalid");
var broadcast_1 = require("./lib/broadcast");
var package_payload_1 = require("./lib/package-payload");
var constants_1 = require("./lib/constants");
var Framebus = /** @class */ (function () {
module.exports = /** @class */ (function () {
function Framebus(origin) {

@@ -35,6 +31,6 @@ if (origin === void 0) { origin = "*"; }

var origin = this.origin;
if (is_not_string_1.default(event)) {
if (is_not_string_1.isntString(event)) {
return false;
}
if (is_not_string_1.default(origin)) {
if (is_not_string_1.isntString(origin)) {
return false;

@@ -46,7 +42,7 @@ }

}
var payload = package_payload_1.default(event, origin, data, reply);
var payload = package_payload_1.packagePayload(event, origin, data, reply);
if (!payload) {
return false;
}
broadcast_1.default(window.top || window.self, payload, origin);
broadcast_1.broadcast(window.top || window.self, payload, origin);
return true;

@@ -56,3 +52,3 @@ };

var origin = this.origin;
if (subscription_args_invalid_1.default(event, fn, origin)) {
if (subscription_args_invalid_1.subscriptionArgsInvalid(event, fn, origin)) {
return false;

@@ -67,3 +63,3 @@ }

var origin = this.origin;
if (subscription_args_invalid_1.default(event, fn, origin)) {
if (subscription_args_invalid_1.subscriptionArgsInvalid(event, fn, origin)) {
return false;

@@ -85,2 +81,1 @@ }

}());
exports.default = Framebus;

@@ -1,3 +0,3 @@

import Framebus from "./framebus";
import Framebus = require("./framebus");
declare const bus: Framebus;
export = bus;
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var attach_1 = require("./lib/attach");
var framebus_1 = __importDefault(require("./framebus"));
var bus = new framebus_1.default();
var Framebus = require("./framebus");
var bus = new Framebus();
attach_1.attach();
module.exports = bus;
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.detach = exports.attach = void 0;
var message_1 = __importDefault(require("./message"));
var message_1 = require("./message");
var isAttached = false;

@@ -14,3 +11,3 @@ function attach() {

isAttached = true;
window.addEventListener("message", message_1.default, false);
window.addEventListener("message", message_1.onmessage, false);
}

@@ -21,5 +18,5 @@ exports.attach = attach;

isAttached = false;
window.removeEventListener("message", message_1.default, false);
window.removeEventListener("message", message_1.onmessage, false);
}
exports.detach = detach;
// endRemoveIf(production)

@@ -1,1 +0,1 @@

export default function broadcastToChildWindows(payload: string, origin: string, source: Window): void;
export declare function broadcastToChildWindows(payload: string, origin: string, source: Window): void;
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var broadcast_1 = __importDefault(require("./broadcast"));
exports.broadcastToChildWindows = void 0;
var broadcast_1 = require("./broadcast");
var constants_1 = require("./constants");

@@ -15,6 +13,6 @@ function broadcastToChildWindows(payload, origin, source) {

else if (source !== childWindow) {
broadcast_1.default(childWindow.top, payload, origin);
broadcast_1.broadcast(childWindow.top, payload, origin);
}
}
}
exports.default = broadcastToChildWindows;
exports.broadcastToChildWindows = broadcastToChildWindows;

@@ -1,1 +0,1 @@

export default function broadcast(frame: Window, payload: string, origin: string): void;
export declare function broadcast(frame: Window, payload: string, origin: string): void;
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var has_opener_1 = __importDefault(require("./has-opener"));
exports.broadcast = void 0;
var has_opener_1 = require("./has-opener");
function broadcast(frame, payload, origin) {

@@ -12,3 +10,3 @@ var i = 0;

frame.postMessage(payload, origin);
if (has_opener_1.default(frame)) {
if (has_opener_1.hasOpener(frame)) {
broadcast(frame.opener.top, payload, origin);

@@ -33,2 +31,2 @@ }

}
exports.default = broadcast;
exports.broadcast = broadcast;
import type { FramebusSubscriberArg, FramebusSubscribeHandler } from "./types";
export default function dispatch(origin: string, event: string, data?: FramebusSubscriberArg, reply?: FramebusSubscribeHandler, e?: MessageEvent): void;
export declare function dispatch(origin: string, event: string, data?: FramebusSubscriberArg, reply?: FramebusSubscribeHandler, e?: MessageEvent): void;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.dispatch = void 0;
var constants_1 = require("./constants");

@@ -22,2 +23,2 @@ function dispatch(origin, event, data, reply, e) {

}
exports.default = dispatch;
exports.dispatch = dispatch;

@@ -1,1 +0,1 @@

export default function hasOpener(frame: Window): boolean;
export declare function hasOpener(frame: Window): boolean;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.hasOpener = void 0;
function hasOpener(frame) {

@@ -18,2 +19,2 @@ if (frame.top !== frame) {

}
exports.default = hasOpener;
exports.hasOpener = hasOpener;

@@ -1,1 +0,1 @@

export default function isntString(str: unknown): boolean;
export declare function isntString(str: unknown): boolean;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isntString = void 0;
function isntString(str) {
return typeof str !== "string";
}
exports.default = isntString;
exports.isntString = isntString;

@@ -1,1 +0,1 @@

export default function onmessage(e: MessageEvent): void;
export declare function onmessage(e: MessageEvent): void;
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var is_not_string_1 = __importDefault(require("./is-not-string"));
var unpack_payload_1 = __importDefault(require("./unpack-payload"));
var dispatch_1 = __importDefault(require("./dispatch"));
var broadcast_to_child_windows_1 = __importDefault(require("./broadcast-to-child-windows"));
exports.onmessage = void 0;
var is_not_string_1 = require("./is-not-string");
var unpack_payload_1 = require("./unpack-payload");
var dispatch_1 = require("./dispatch");
var broadcast_to_child_windows_1 = require("./broadcast-to-child-windows");
function onmessage(e) {
if (is_not_string_1.default(e.data)) {
if (is_not_string_1.isntString(e.data)) {
return;
}
var payload = unpack_payload_1.default(e);
var payload = unpack_payload_1.unpackPayload(e);
if (!payload) {

@@ -20,6 +18,6 @@ return;

var reply = payload.reply;
dispatch_1.default("*", payload.event, data, reply, e);
dispatch_1.default(e.origin, payload.event, data, reply, e);
broadcast_to_child_windows_1.default(e.data, payload.origin, e.source);
dispatch_1.dispatch("*", payload.event, data, reply, e);
dispatch_1.dispatch(e.origin, payload.event, data, reply, e);
broadcast_to_child_windows_1.broadcastToChildWindows(e.data, payload.origin, e.source);
}
exports.default = onmessage;
exports.onmessage = onmessage;
import type { FramebusSubscriberArg, FramebusSubscribeHandler } from "./types";
export default function packagePayload(event: string, origin: string, data?: FramebusSubscriberArg, reply?: FramebusSubscribeHandler): string;
export declare function packagePayload(event: string, origin: string, data?: FramebusSubscriberArg, reply?: FramebusSubscribeHandler): string;
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var subscribe_replier_1 = __importDefault(require("./subscribe-replier"));
exports.packagePayload = void 0;
var subscribe_replier_1 = require("./subscribe-replier");
var constants_1 = require("./constants");

@@ -15,3 +13,3 @@ function packagePayload(event, origin, data, reply) {

if (typeof reply === "function") {
payload.reply = subscribe_replier_1.default(reply, origin);
payload.reply = subscribe_replier_1.subscribeReplier(reply, origin);
}

@@ -27,2 +25,2 @@ payload.eventData = data;

}
exports.default = packagePayload;
exports.packagePayload = packagePayload;
import type { FramebusSubscribeHandler } from "./types";
export default function subscribeReplier(fn: FramebusSubscribeHandler, origin: string): string;
export declare function subscribeReplier(fn: FramebusSubscribeHandler, origin: string): string;
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var framebus_1 = __importDefault(require("../framebus"));
var uuid_1 = __importDefault(require("./uuid"));
exports.subscribeReplier = void 0;
var Framebus = require("../framebus");
var uuid_1 = require("./uuid");
function subscribeReplier(fn, origin) {
var uuid = uuid_1.default();
var uuid = uuid_1.uuid();
function replier(data, replyOriginHandler) {
fn(data, replyOriginHandler);
new framebus_1.default().target(origin).off(uuid, replier);
new Framebus().target(origin).off(uuid, replier);
}
new framebus_1.default().target(origin).on(uuid, replier);
new Framebus().target(origin).on(uuid, replier);
return uuid;
}
exports.default = subscribeReplier;
exports.subscribeReplier = subscribeReplier;
import type { FramebusOnHandler } from "./types";
export default function subscriptionArgsInvalid(event: string, fn: FramebusOnHandler, origin: string): boolean;
export declare function subscriptionArgsInvalid(event: string, fn: FramebusOnHandler, origin: string): boolean;
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var is_not_string_1 = __importDefault(require("./is-not-string"));
exports.subscriptionArgsInvalid = void 0;
var is_not_string_1 = require("./is-not-string");
function subscriptionArgsInvalid(event, fn, origin) {
if (is_not_string_1.default(event)) {
if (is_not_string_1.isntString(event)) {
return true;

@@ -14,4 +12,4 @@ }

}
return is_not_string_1.default(origin);
return is_not_string_1.isntString(origin);
}
exports.default = subscriptionArgsInvalid;
exports.subscriptionArgsInvalid = subscriptionArgsInvalid;
import type { FramebusPayload } from "./types";
export default function unpackPayload(e: MessageEvent): FramebusPayload | false;
export declare function unpackPayload(e: MessageEvent): FramebusPayload | false;
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.unpackPayload = void 0;
var constants_1 = require("./constants");
var package_payload_1 = __importDefault(require("./package-payload"));
var package_payload_1 = require("./package-payload");
function unpackPayload(e) {

@@ -27,3 +25,3 @@ var payload;

}
var replyPayload = package_payload_1.default(replyEvent_1, replyOrigin_1, replyData);
var replyPayload = package_payload_1.packagePayload(replyEvent_1, replyOrigin_1, replyData);
if (!replyPayload) {

@@ -37,2 +35,2 @@ return;

}
exports.default = unpackPayload;
exports.unpackPayload = unpackPayload;

@@ -1,1 +0,1 @@

export default function uuid(): string;
export declare function uuid(): string;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.uuid = void 0;
/* eslint-disable no-mixed-operators */

@@ -11,2 +12,2 @@ function uuid() {

}
exports.default = uuid;
exports.uuid = uuid;

@@ -9,3 +9,3 @@ {

"homepage": "https://github.com/braintree/framebus",
"version": "4.0.1",
"version": "4.0.2",
"main": "dist/index.js",

@@ -12,0 +12,0 @@ "files": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc