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 5.0.0 to 5.1.0

6

CHANGELOG.md

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

# 5.1.0
- Fix issue where emitting to new window could cause an infinite loop (closes #41, thanks @blutorange)
- Add `emitAsPromise` as convenience method when waiting for replies from `emit` calls
- Add `setPromise` static method for easy polyfilling environments that do not support promises
# 5.0.0

@@ -2,0 +8,0 @@

3

dist/framebus.d.ts

@@ -15,2 +15,4 @@ import type { FramebusSubscriberArg, FramebusOnHandler, FramebusReplyHandler } from "./lib/types";

constructor(options?: FramebusOptions);
static Promise: PromiseConstructor;
static setPromise(PromiseGlobal: typeof Framebus["Promise"]): void;
static target(options?: FramebusOptions): Framebus;

@@ -20,2 +22,3 @@ include(childWindow: Window): boolean;

emit(eventName: string, data?: FramebusSubscriberArg | FramebusReplyHandler, reply?: FramebusReplyHandler): boolean;
emitAsPromise<T = void>(eventName: string, data?: FramebusSubscriberArg): Promise<T>;
on(eventName: string, originalHandler: FramebusOnHandler): boolean;

@@ -22,0 +25,0 @@ off(eventName: string, originalHandler: FramebusOnHandler): boolean;

@@ -18,2 +18,5 @@ "use strict";

}
Framebus.setPromise = function (PromiseGlobal) {
Framebus.Promise = PromiseGlobal;
};
Framebus.target = function (options) {

@@ -61,2 +64,13 @@ return new Framebus(options);

};
Framebus.prototype.emitAsPromise = function (eventName, data) {
var _this = this;
return new Framebus.Promise(function (resolve, reject) {
var didAttachListener = _this.emit(eventName, data, function (payload) {
resolve(payload);
});
if (!didAttachListener) {
reject(new Error("Listener not added for \"" + eventName + "\""));
}
});
};
Framebus.prototype.on = function (eventName, originalHandler) {

@@ -167,4 +181,5 @@ if (this.isDestroyed) {

};
Framebus.Promise = Promise;
return Framebus;
}());
exports.Framebus = Framebus;

2

dist/lib/broadcast.js

@@ -10,3 +10,3 @@ "use strict";

frame.postMessage(payload, origin);
if (has_opener_1.hasOpener(frame)) {
if (has_opener_1.hasOpener(frame) && frame.opener.top !== window.top) {
broadcast(frame.opener.top, payload, origin);

@@ -13,0 +13,0 @@ }

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

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

@@ -25,2 +25,3 @@ "files": [

"test": "npm run test:unit && npm run test:functional",
"prestart": "npm run pretest:functional",
"start": "./bin/www"

@@ -34,14 +35,14 @@ },

"devDependencies": {
"@types/jest": "^26.0.14",
"@wdio/cli": "^6.5.2",
"@wdio/local-runner": "^6.5.2",
"@wdio/mocha-framework": "^6.5.0",
"@wdio/spec-reporter": "^6.4.7",
"@wdio/sync": "^6.5.0",
"@types/jest": "^26.0.19",
"@wdio/cli": "^6.11.3",
"@wdio/local-runner": "^6.11.3",
"@wdio/mocha-framework": "^6.11.0",
"@wdio/spec-reporter": "^6.11.0",
"@wdio/sync": "^6.11.0",
"async": "^3.2.0",
"browserify": "^16.5.2",
"chromedriver": "^85.0.1",
"browserify": "^17.0.0",
"chromedriver": "^87.0.5",
"del": "^6.0.0",
"ejs": "^3.1.5",
"eslint": "^7.10.0",
"eslint": "^7.17.0",
"eslint-config-braintree": "5.0.0-typescript-prep-rc.19",

@@ -55,8 +56,8 @@ "express": "^4.10.4",

"gulp-uglify": "^3.0.2",
"jest": "^26.4.2",
"jest": "^26.6.3",
"morgan": "^1.10.0",
"prettier": "^2.1.2",
"ts-jest": "^26.4.1",
"prettier": "^2.2.1",
"ts-jest": "^26.4.4",
"tsify": "^5.0.2",
"typescript": "^4.0.3",
"typescript": "^4.1.3",
"vinyl-buffer": "^1.0.1",

@@ -63,0 +64,0 @@ "vinyl-source-stream": "^2.0.0",

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

# Framebus [![Build Status](https://travis-ci.org/braintree/framebus.svg)](https://travis-ci.org/braintree/framebus) [![npm version](https://badge.fury.io/js/framebus.svg)](http://badge.fury.io/js/framebus)
# Framebus [![Build Status](https://github.com/braintree/framebus/workflows/Unit%20Tests/badge.svg)](https://github.com/braintree/framebus/actions?query=workflow%3A%22Unit+Tests%22) [![Build Status](https://github.com/braintree/framebus/workflows/Functional%20Tests/badge.svg)](https://github.com/braintree/framebus/actions?query=workflow%3A%22Functional+Tests%22) [![npm version](https://badge.fury.io/js/framebus.svg)](http://badge.fury.io/js/framebus)

@@ -74,3 +74,3 @@ Framebus allows you to easily send messages across frames (and iframes) with a simple bus.

#### `emit('event', data? , callback?): boolean`
#### `emit('event', data?, callback?): boolean`

@@ -85,2 +85,20 @@ **returns**: `true` if the event was successfully published, `false` otherwise

#### `emitAsPromise('event', data?): Promise`
**returns**: A promise that resolves when the emitted event is responded to the first time. It will reject if the event could not be succesfully published.
| Argument | Type | Description |
| -------- | ------ | ------------------------------- |
| `event` | String | The name of the event |
| `data` | Object | The data to give to subscribers |
Using this method assumes the browser context you are using supports Promises. If it does not, set a polyfill for the Framebus class with `setPromise`
```js
// or however you want to polyfill the promise
const PolyfilledPromise = require("promise-polyfill");
Framebus.setPromise(PolyfilledPromise);
```
#### `on('event', fn): boolean`

@@ -87,0 +105,0 @@

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