Socket
Socket
Sign inDemoInstall

@metamask/post-message-stream

Package Overview
Dependencies
Maintainers
12
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@metamask/post-message-stream - npm Package Compare versions

Comparing version 8.0.0 to 8.1.0

3

dist/BasePostMessageStream.d.ts
import { Duplex } from 'readable-stream';
import type { DuplexOptions } from 'readable-stream';
import { StreamData } from './utils';

@@ -16,3 +17,3 @@ declare type Log = (data: unknown, out: boolean) => void;

private _log;
constructor();
constructor(streamOptions?: DuplexOptions);
/**

@@ -19,0 +20,0 @@ * Must be called at end of child constructor to initiate

@@ -12,6 +12,4 @@ "use strict";

class BasePostMessageStream extends readable_stream_1.Duplex {
constructor() {
super({
objectMode: true,
});
constructor(streamOptions) {
super(Object.assign({ objectMode: true }, streamOptions));
// Initialization flags

@@ -18,0 +16,0 @@ this._init = false;

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

import type { DuplexOptions } from 'readable-stream';
import { BasePostMessageStream } from '../BasePostMessageStream';

@@ -7,3 +8,3 @@ import { StreamData } from '../utils';

export declare class ProcessMessageStream extends BasePostMessageStream {
constructor();
constructor(streamOptions?: DuplexOptions);
protected _postMessage(data: StreamData): void;

@@ -10,0 +11,0 @@ private _onMessage;

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

class ProcessMessageStream extends BasePostMessageStream_1.BasePostMessageStream {
constructor() {
super();
constructor(streamOptions = {}) {
super(streamOptions);
if (typeof globalThis.process.send !== 'function') {

@@ -14,0 +14,0 @@ throw new Error('Parent IPC channel not found. This class should only be instantiated in a Node.js child process.');

/// <reference types="node" />
import type { ChildProcess } from 'child_process';
import type { DuplexOptions } from 'readable-stream';
import { BasePostMessageStream } from '../BasePostMessageStream';
import { StreamData } from '../utils';
interface ProcessParentMessageStreamArgs {
interface ProcessParentMessageStreamArgs extends DuplexOptions {
process: ChildProcess;

@@ -19,3 +20,3 @@ }

*/
constructor({ process }: ProcessParentMessageStreamArgs);
constructor({ process, ...streamOptions }: ProcessParentMessageStreamArgs);
protected _postMessage(data: StreamData): void;

@@ -22,0 +23,0 @@ private _onMessage;

"use strict";
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -16,4 +27,5 @@ exports.ProcessParentMessageStream = void 0;

*/
constructor({ process }) {
super();
constructor(_a) {
var { process } = _a, streamOptions = __rest(_a, ["process"]);
super(streamOptions);
this._process = process;

@@ -20,0 +32,0 @@ this._onMessage = this._onMessage.bind(this);

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

import type { DuplexOptions } from 'readable-stream';
import { BasePostMessageStream } from '../BasePostMessageStream';

@@ -8,3 +9,3 @@ import { StreamData } from '../utils';

#private;
constructor();
constructor(streamOptions?: DuplexOptions);
protected _postMessage(data: StreamData): void;

@@ -11,0 +12,0 @@ private _onMessage;

@@ -23,4 +23,4 @@ "use strict";

class ThreadMessageStream extends BasePostMessageStream_1.BasePostMessageStream {
constructor() {
super();
constructor(streamOptions = {}) {
super(streamOptions);
_ThreadMessageStream_parentPort.set(this, void 0);

@@ -27,0 +27,0 @@ if (!worker_threads_1.parentPort) {

/// <reference types="node" />
import { Worker } from 'worker_threads';
import type { DuplexOptions } from 'readable-stream';
import { BasePostMessageStream } from '../BasePostMessageStream';
import { StreamData } from '../utils';
interface ThreadParentMessageStreamArgs {
interface ThreadParentMessageStreamArgs extends DuplexOptions {
thread: Worker;

@@ -19,3 +20,3 @@ }

*/
constructor({ thread }: ThreadParentMessageStreamArgs);
constructor({ thread, ...streamOptions }: ThreadParentMessageStreamArgs);
protected _postMessage(data: StreamData): void;

@@ -22,0 +23,0 @@ private _onMessage;

"use strict";
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -16,4 +27,5 @@ exports.ThreadParentMessageStream = void 0;

*/
constructor({ thread }) {
super();
constructor(_a) {
var { thread } = _a, streamOptions = __rest(_a, ["thread"]);
super(streamOptions);
this._thread = thread;

@@ -20,0 +32,0 @@ this._onMessage = this._onMessage.bind(this);

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

import type { DuplexOptions } from 'readable-stream';
import { BasePostMessageStream } from '../BasePostMessageStream';
export interface BrowserRuntimePostMessageStreamArgs {
export interface BrowserRuntimePostMessageStreamArgs extends DuplexOptions {
name: string;

@@ -20,3 +21,3 @@ target: string;

*/
constructor({ name, target }: BrowserRuntimePostMessageStreamArgs);
constructor({ name, target, ...streamOptions }: BrowserRuntimePostMessageStreamArgs);
protected _postMessage(data: unknown): void;

@@ -23,0 +24,0 @@ private _onMessage;

@@ -13,2 +13,13 @@ "use strict";

};
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
var _BrowserRuntimePostMessageStream_name, _BrowserRuntimePostMessageStream_target;

@@ -32,4 +43,5 @@ Object.defineProperty(exports, "__esModule", { value: true });

*/
constructor({ name, target }) {
super();
constructor(_a) {
var { name, target } = _a, streamOptions = __rest(_a, ["name", "target"]);
super(streamOptions);
_BrowserRuntimePostMessageStream_name.set(this, void 0);

@@ -36,0 +48,0 @@ _BrowserRuntimePostMessageStream_target.set(this, void 0);

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

import type { DuplexOptions } from 'readable-stream';
import { BasePostMessageStream } from '../BasePostMessageStream';
interface WorkerParentStreamArgs {
interface WorkerParentStreamArgs extends DuplexOptions {
worker: Worker;

@@ -19,3 +20,3 @@ }

*/
constructor({ worker }: WorkerParentStreamArgs);
constructor({ worker, ...streamOptions }: WorkerParentStreamArgs);
protected _postMessage(data: unknown): void;

@@ -22,0 +23,0 @@ private _onMessage;

"use strict";
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -18,4 +29,5 @@ exports.WebWorkerParentPostMessageStream = void 0;

*/
constructor({ worker }) {
super();
constructor(_a) {
var { worker } = _a, streamOptions = __rest(_a, ["worker"]);
super(streamOptions);
this._target = utils_1.DEDICATED_WORKER_NAME;

@@ -22,0 +34,0 @@ this._worker = worker;

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

import type { DuplexOptions } from 'readable-stream';
import { BasePostMessageStream } from '../BasePostMessageStream';

@@ -9,3 +10,3 @@ import { StreamData } from '../utils';

private _name;
constructor();
constructor(streamOptions?: DuplexOptions);
protected _postMessage(data: StreamData): void;

@@ -12,0 +13,0 @@ private _onMessage;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.WebWorkerPostMessageStream = void 0;
// We ignore coverage for the entire file due to limits on our instrumentation,
// but it is in fact covered by our tests.
const BasePostMessageStream_1 = require("../BasePostMessageStream");

@@ -13,3 +11,3 @@ const utils_1 = require("../utils");

class WebWorkerPostMessageStream extends BasePostMessageStream_1.BasePostMessageStream {
constructor() {
constructor(streamOptions = {}) {
// Kudos: https://stackoverflow.com/a/18002694

@@ -21,3 +19,3 @@ if (typeof self === 'undefined' ||

}
super();
super(streamOptions);
this._name = utils_1.DEDICATED_WORKER_NAME;

@@ -24,0 +22,0 @@ self.addEventListener('message', this._onMessage.bind(this));

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

import type { DuplexOptions } from 'readable-stream';
import { BasePostMessageStream } from '../BasePostMessageStream';
interface WindowPostMessageStreamArgs {
interface WindowPostMessageStreamArgs extends DuplexOptions {
name: string;

@@ -29,3 +30,3 @@ target: string;

*/
constructor({ name, target, targetOrigin, targetWindow, }: WindowPostMessageStreamArgs);
constructor({ name, target, targetOrigin, targetWindow, ...streamOptions }: WindowPostMessageStreamArgs);
protected _postMessage(data: unknown): void;

@@ -32,0 +33,0 @@ private _onMessage;

"use strict";
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
var _a, _b;

@@ -31,4 +42,5 @@ Object.defineProperty(exports, "__esModule", { value: true });

*/
constructor({ name, target, targetOrigin = location.origin, targetWindow = window, }) {
super();
constructor(_a) {
var { name, target, targetOrigin = location.origin, targetWindow = window } = _a, streamOptions = __rest(_a, ["name", "target", "targetOrigin", "targetWindow"]);
super(streamOptions);
if (typeof window === 'undefined' ||

@@ -35,0 +47,0 @@ typeof window.postMessage !== 'function') {

{
"name": "@metamask/post-message-stream",
"version": "8.0.0",
"version": "8.1.0",
"description": "Sets up a duplex object stream over window.postMessage",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/MetaMask/post-message-stream#readme",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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