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

framecast

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

framecast - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

31

lib/index.js

@@ -62,3 +62,2 @@ "use strict";

exports.Framecast = void 0;
var debug = require('debug')('framecast');
var Framecast = /** @class */ (function () {

@@ -90,3 +89,2 @@ function Framecast(target, config) {

this.self.addEventListener('message', this.handlePostedMessage.bind(this));
debug('Created framecast');
}

@@ -126,3 +124,2 @@ Object.defineProperty(Framecast.prototype, "origin", {

Framecast.prototype.postMessage = function (type, message) {
debug('Sending message', type, __assign(__assign({}, message), { type: type, channel: this.channel }));
this.target.postMessage(JSON.parse(JSON.stringify(__assign(__assign({}, message), { type: type, channel: this.channel }))), this.origin);

@@ -144,3 +141,2 @@ };

}
debug("Added listener for ".concat(eventType));
this.listeners[eventType].add(listener);

@@ -155,3 +151,2 @@ };

if (this.listeners[eventType]) {
debug("Removed listener for ".concat(eventType));
this.listeners[eventType].delete(listener);

@@ -222,16 +217,9 @@ }

if (this.origin !== '*' && event.origin !== this.origin) {
debug('Origin did not match target', {
origin: event.origin,
target: this.config.origin,
});
// Origin did not match target
return [2 /*return*/];
}
if (this.channel !== data.channel) {
debug('Channel did not match target', {
channel: data.channel,
target: this.channel,
});
// Channel did not match target
return [2 /*return*/];
}
debug('Received data', data);
if (data.type === 'broadcast') {

@@ -247,8 +235,7 @@ this.handleBroadcast(data.data);

else {
debug('Unknown message type', data.type);
// Unknown message type
}
}
catch (error) {
debug('Could not handle message', event.data);
debug(error);
// could not handle message
}

@@ -269,3 +256,2 @@ return [2 /*return*/];

return __generator(this, function (_e) {
debug("Emitting broadcast");
try {

@@ -301,5 +287,3 @@ for (_b = __values((_a = this.listeners['broadcast']) !== null && _a !== void 0 ? _a : []), _c = _b.next(); !_c.done; _c = _b.next()) {

case 0:
debug("Calling ".concat(eventType, " with ").concat(args === null || args === void 0 ? void 0 : args.length, " arguments"));
if (!this.listeners[eventType] || this.listeners[eventType].size === 0) {
debug("No listeners for ".concat(eventType, ", sending back error"));
this.postMessage('functionResult', {

@@ -342,3 +326,2 @@ id: id,

case 9:
debug("Sending back result for id: ".concat(id), result);
this.postMessage('functionResult', { id: id, result: result });

@@ -348,3 +331,3 @@ return [3 /*break*/, 11];

error_1 = _e.sent();
debug("Error calling ".concat(eventType, ", sending back error"), error_1);
// `Error calling function, sending back error
this.postMessage('functionResult', { id: id, error: error_1 });

@@ -366,3 +349,3 @@ return [2 /*return*/];

if (pendingCall) {
debug('Received function result', data);
// Received function result
this.clearPendingFunctionCall(data.id);

@@ -377,3 +360,3 @@ if (data.error) {

else {
debug('Received function result for unknown id', data);
// Received function result for unknown id
}

@@ -380,0 +363,0 @@ return [2 /*return*/];

{
"name": "framecast",
"version": "0.0.3",
"version": "0.0.4",
"description": "TypeScript cross-frame communication library.",

@@ -56,6 +56,3 @@ "main": "lib/index.js",

"typescript": "^4.7.4"
},
"dependencies": {
"debug": "^4.3.4"
}
}
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