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

@wixc3/engine-runtime-node

Package Overview
Dependencies
Maintainers
67
Versions
202
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wixc3/engine-runtime-node - npm Package Compare versions

Comparing version 43.0.2 to 43.0.3

9

dist/core-node/ipc-host.d.ts

@@ -7,8 +7,11 @@ /// <reference types="node" />

/// <reference types="node" />
import { BaseHost, type IDisposable, type Message } from '@wixc3/engine-core';
import { BaseHost, type Message } from '@wixc3/engine-core';
import type { ChildProcess } from 'node:child_process';
import { type IDisposable } from '@wixc3/patterns';
export declare const isParentProcess: (process: NodeJS.Process | ChildProcess) => process is NodeJS.Process;
export declare class IPCHost extends BaseHost implements IDisposable {
private process;
private disposed;
private disposables;
dispose: () => Promise<void>;
isDisposed: () => boolean;
private envs;

@@ -18,5 +21,3 @@ constructor(process: NodeJS.Process | ChildProcess);

postMessage(data: Message): void;
dispose(): void;
isDisposed(): boolean;
}
//# sourceMappingURL=ipc-host.d.ts.map

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

const engine_core_1 = require("@wixc3/engine-core");
const patterns_1 = require("@wixc3/patterns");
const isParentProcess = (process) => {

@@ -14,3 +15,5 @@ return process.constructor.name === 'process';

this.process = process;
this.disposed = false;
this.disposables = new patterns_1.SafeDisposable(IPCHost.name);
this.dispose = this.disposables.dispose;
this.isDisposed = this.disposables.isDisposed;
this.envs = new Set();

@@ -33,2 +36,4 @@ this.onMessage = (message) => {

});
this.disposables.add('process listeners', () => this.process.removeAllListeners());
this.disposables.add('clear handlers', () => this.handlers.clear());
}

@@ -58,12 +63,4 @@ postMessage(data) {

}
dispose() {
this.handlers.clear();
this.process.removeAllListeners();
this.disposed = true;
}
isDisposed() {
return this.disposed;
}
}
exports.IPCHost = IPCHost;
//# sourceMappingURL=ipc-host.js.map
import type io from 'socket.io';
import { BaseHost, type IDisposable, type Message } from '@wixc3/engine-core';
import { BaseHost, type Message } from '@wixc3/engine-core';
import { type IDisposable } from '@wixc3/patterns';
export declare class WsHost extends BaseHost {

@@ -8,15 +9,12 @@ private socket;

}
/**
* TODO: handle disconnect
*/
export declare class WsServerHost extends BaseHost implements IDisposable {
private server;
private socketToEnvId;
private disposed;
private disposables;
dispose: () => Promise<void>;
isDisposed: () => boolean;
constructor(server: io.Server | io.Namespace);
postMessage(data: Message): void;
dispose(): void;
isDisposed(): boolean;
private onConnection;
}
//# sourceMappingURL=ws-node-host.d.ts.map

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

const engine_core_1 = require("@wixc3/engine-core");
const patterns_1 = require("@wixc3/patterns");
class WsHost extends engine_core_1.BaseHost {

@@ -19,5 +20,2 @@ constructor(socket) {

exports.WsHost = WsHost;
/**
* TODO: handle disconnect
*/
class WsServerHost extends engine_core_1.BaseHost {

@@ -28,3 +26,5 @@ constructor(server) {

this.socketToEnvId = new Map();
this.disposed = false;
this.disposables = new patterns_1.SafeDisposable(WsServerHost.name);
this.dispose = this.disposables.dispose;
this.isDisposed = this.disposables.isDisposed;
this.onConnection = (socket) => {

@@ -64,2 +64,4 @@ const nameSpace = (original) => `${socket.id}/${original}`;

this.server.on('connection', this.onConnection);
this.disposables.add('connection', () => this.server.off('connection', this.onConnection));
this.disposables.add('clear handlers', () => this.handlers.clear());
}

@@ -81,12 +83,4 @@ postMessage(data) {

}
dispose() {
this.handlers.clear();
this.server.off('connection', this.onConnection);
this.disposed = true;
}
isDisposed() {
return this.disposed;
}
}
exports.WsServerHost = WsServerHost;
//# sourceMappingURL=ws-node-host.js.map
import { AnyEnvironment, MultiCounter } from '@wixc3/engine-core';
import { SetMultiMap } from '@wixc3/patterns';
import { IDisposable, SafeDisposable, SetMultiMap } from '@wixc3/patterns';
import { IStaticFeatureDefinition, PerformanceMetrics } from './types';

@@ -15,10 +15,12 @@ export type ConfigFilePath = string;

}
export declare class NodeEnvManager {
export declare class NodeEnvManager implements IDisposable {
private importMeta;
private featureEnvironmentsMapping;
private configMapping;
disposables: SafeDisposable;
dispose: () => Promise<void>;
isDisposed: () => boolean;
envInstanceIdCounter: MultiCounter;
id: string;
openEnvironments: SetMultiMap<string, RunningNodeEnvironment>;
autoLaunchDispose?: () => Promise<void>;
constructor(importMeta: {

@@ -38,3 +40,2 @@ url: string;

}>;
dispose(): Promise<void>;
}

@@ -41,0 +42,0 @@ export declare function parseRuntimeOptions(): Map<string, string | boolean | undefined>;

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

this.configMapping = configMapping;
this.disposables = new patterns_1.SafeDisposable(NodeEnvManager.name);
this.dispose = this.disposables.dispose;
this.isDisposed = this.disposables.isDisposed;
this.envInstanceIdCounter = new engine_core_1.MultiCounter();
this.id = 'node-environment-manager';
this.openEnvironments = new patterns_1.SetMultiMap();
this.disposables.add('open environments', () => Promise.all([...this.openEnvironments.values()].map((env) => env.dispose())));
}

@@ -54,7 +58,7 @@ async autoLaunch(runtimeOptions = parseRuntimeOptions()) {

const host = new ws_node_host_1.WsServerHost(socketServer);
this.autoLaunchDispose = async () => {
host.dispose();
this.disposables.add('auto launch', async () => {
await host.dispose();
disposeListener();
await close();
};
});
await this.runFeatureEnvironments(verbose, runtimeOptions, host);

@@ -141,6 +145,2 @@ if (process.send) {

}
async dispose() {
await Promise.all([...this.openEnvironments.values()].map((env) => env.dispose()));
await this.autoLaunchDispose?.();
}
}

@@ -147,0 +147,0 @@ exports.NodeEnvManager = NodeEnvManager;

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

}
com.dispose();
await com.dispose();
for (const env of Object.values(runningEnvironments)) {

@@ -252,3 +252,3 @@ await env.close();

for (const runningEnvironmentForFeature of this.runningFeatures.values()) {
runningEnvironmentForFeature.com.dispose();
await runningEnvironmentForFeature.com.dispose();
for (const env of Object.values(runningEnvironmentForFeature.runningEnvironments)) {

@@ -255,0 +255,0 @@ allClosed.push(env.close());

/// <reference types="node" />
import type { ServerOptions } from 'socket.io';
import { type ICommunicationMessage, type RemoteProcess } from './types.js';
import { IDisposable } from '@wixc3/patterns';
export interface IStartRemoteNodeEnvironmentOptions {

@@ -14,4 +15,7 @@ port: number;

}>;
export declare class RemoteNodeEnvironment {
export declare class RemoteNodeEnvironment implements IDisposable {
private childEnv;
private disposables;
dispose: () => Promise<void>;
isDisposed: () => boolean;
private messageHandlers;

@@ -23,4 +27,3 @@ constructor(childEnv: RemoteProcess);

postMessage(message: ICommunicationMessage): void;
dispose(): void;
}
//# sourceMappingURL=remote-node-environment.d.ts.map

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

const types_js_1 = require("./types.js");
const patterns_1 = require("@wixc3/patterns");
async function startRemoteNodeEnvironment(entryFilePath, { inspect, port, socketServerOptions = {}, requiredPaths = [] }) {

@@ -32,3 +33,13 @@ const execArgv = inspect ? ['--inspect'] : [];

this.childEnv = childEnv;
this.disposables = new patterns_1.SafeDisposable(RemoteNodeEnvironment.name);
this.dispose = this.disposables.dispose;
this.isDisposed = this.disposables.isDisposed;
this.messageHandlers = new Set();
this.disposables.add('child environment', () => {
for (const handler of this.messageHandlers) {
this.childEnv.off('message', handler);
}
this.messageHandlers.clear();
this.childEnv?.terminate?.();
});
}

@@ -57,13 +68,4 @@ async getRemotePort() {

}
dispose() {
for (const handler of this.messageHandlers) {
this.childEnv.off('message', handler);
}
this.messageHandlers.clear();
if (this.childEnv && this.childEnv.terminate) {
this.childEnv.terminate();
}
}
}
exports.RemoteNodeEnvironment = RemoteNodeEnvironment;
//# sourceMappingURL=remote-node-environment.js.map

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

close: async () => {
wsHost.dispose();
await wsHost.dispose();
await engine.shutdown();

@@ -27,3 +27,3 @@ },

catch (e) {
wsHost.dispose();
void wsHost.dispose();
throw e;

@@ -30,0 +30,0 @@ }

{
"name": "@wixc3/engine-runtime-node",
"version": "43.0.2",
"version": "43.0.3",
"main": "dist/index.js",

@@ -14,5 +14,5 @@ "exports": {

"dependencies": {
"@wixc3/common": "^15.1.1",
"@wixc3/engine-core": "^43.0.2",
"@wixc3/patterns": "^15.3.1",
"@wixc3/common": "^16.1.0",
"@wixc3/engine-core": "^43.0.3",
"@wixc3/patterns": "^16.1.0",
"create-listening-server": "^2.1.0",

@@ -19,0 +19,0 @@ "express": "^4.18.2",

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

import { BaseHost, type IDisposable, type Message } from '@wixc3/engine-core';
import { BaseHost, type Message } from '@wixc3/engine-core';
import type { ChildProcess } from 'node:child_process';
import { SafeDisposable, type IDisposable } from '@wixc3/patterns';

@@ -9,3 +10,5 @@ export const isParentProcess = (process: NodeJS.Process | ChildProcess): process is NodeJS.Process => {

export class IPCHost extends BaseHost implements IDisposable {
private disposed = false;
private disposables = new SafeDisposable(IPCHost.name);
dispose = this.disposables.dispose;
isDisposed = this.disposables.isDisposed;
private envs = new Set<string>();

@@ -28,2 +31,4 @@

});
this.disposables.add('process listeners', () => this.process.removeAllListeners());
this.disposables.add('clear handlers', () => this.handlers.clear());
}

@@ -58,12 +63,2 @@

}
public dispose() {
this.handlers.clear();
this.process.removeAllListeners();
this.disposed = true;
}
public isDisposed() {
return this.disposed;
}
}
import type io from 'socket.io';
import { BaseHost, type IDisposable, type Message } from '@wixc3/engine-core';
import { BaseHost, type Message } from '@wixc3/engine-core';
import { SafeDisposable, type IDisposable } from '@wixc3/patterns';

@@ -16,8 +17,7 @@ export class WsHost extends BaseHost {

/**
* TODO: handle disconnect
*/
export class WsServerHost extends BaseHost implements IDisposable {
private socketToEnvId = new Map<string, { socket: io.Socket; clientID: string }>();
private disposed = false;
private disposables = new SafeDisposable(WsServerHost.name);
dispose = this.disposables.dispose;
isDisposed = this.disposables.isDisposed;

@@ -27,2 +27,4 @@ constructor(private server: io.Server | io.Namespace) {

this.server.on('connection', this.onConnection);
this.disposables.add('connection', () => this.server.off('connection', this.onConnection));
this.disposables.add('clear handlers', () => this.handlers.clear());
}

@@ -44,12 +46,2 @@

public dispose() {
this.handlers.clear();
this.server.off('connection', this.onConnection);
this.disposed = true;
}
public isDisposed() {
return this.disposed;
}
private onConnection = (socket: io.Socket): void => {

@@ -56,0 +48,0 @@ const nameSpace = (original: string) => `${socket.id}/${original}`;

@@ -8,3 +8,3 @@ import {

} from '@wixc3/engine-core';
import { SetMultiMap } from '@wixc3/patterns';
import { IDisposable, SafeDisposable, SetMultiMap } from '@wixc3/patterns';
import { fileURLToPath } from 'node:url';

@@ -34,7 +34,9 @@ import { parseArgs } from 'node:util';

export class NodeEnvManager {
export class NodeEnvManager implements IDisposable {
disposables = new SafeDisposable(NodeEnvManager.name);
dispose = this.disposables.dispose;
isDisposed = this.disposables.isDisposed;
envInstanceIdCounter = new MultiCounter();
id = 'node-environment-manager';
openEnvironments = new SetMultiMap<string, RunningNodeEnvironment>();
autoLaunchDispose?: () => Promise<void>;
constructor(

@@ -44,3 +46,7 @@ private importMeta: { url: string },

private configMapping: ConfigurationEnvironmentMapping,
) {}
) {
this.disposables.add('open environments', () =>
Promise.all([...this.openEnvironments.values()].map((env) => env.dispose())),
);
}
public async autoLaunch(runtimeOptions = parseRuntimeOptions()) {

@@ -84,7 +90,7 @@ process.env.ENGINE_FLOW_V2_DIST_URL = this.importMeta.url;

this.autoLaunchDispose = async () => {
host.dispose();
this.disposables.add('auto launch', async () => {
await host.dispose();
disposeListener();
await close();
};
});
await this.runFeatureEnvironments(verbose, runtimeOptions, host);

@@ -198,6 +204,2 @@

}
async dispose() {
await Promise.all([...this.openEnvironments.values()].map((env) => env.dispose()));
await this.autoLaunchDispose?.();
}
}

@@ -204,0 +206,0 @@

@@ -341,3 +341,3 @@ import {

}
com.dispose();
await com.dispose();
for (const env of Object.values(runningEnvironments)) {

@@ -364,3 +364,3 @@ await env.close();

for (const runningEnvironmentForFeature of this.runningFeatures.values()) {
runningEnvironmentForFeature.com.dispose();
await runningEnvironmentForFeature.com.dispose();
for (const env of Object.values(runningEnvironmentForFeature.runningEnvironments)) {

@@ -367,0 +367,0 @@ allClosed.push(env.close());

@@ -6,2 +6,3 @@ import { fork } from 'node:child_process';

import { isEnvironmentPortMessage, type ICommunicationMessage, type RemoteProcess } from './types.js';
import { IDisposable, SafeDisposable } from '@wixc3/patterns';

@@ -43,6 +44,17 @@ export interface IStartRemoteNodeEnvironmentOptions {

export class RemoteNodeEnvironment {
export class RemoteNodeEnvironment implements IDisposable {
private disposables = new SafeDisposable(RemoteNodeEnvironment.name);
dispose = this.disposables.dispose;
isDisposed = this.disposables.isDisposed;
private messageHandlers = new Set<(message: ICommunicationMessage) => void>();
constructor(private childEnv: RemoteProcess) {}
constructor(private childEnv: RemoteProcess) {
this.disposables.add('child environment', () => {
for (const handler of this.messageHandlers) {
this.childEnv.off('message', handler);
}
this.messageHandlers.clear();
this.childEnv?.terminate?.();
});
}

@@ -74,12 +86,2 @@ public async getRemotePort(): Promise<number> {

}
public dispose() {
for (const handler of this.messageHandlers) {
this.childEnv.off('message', handler);
}
this.messageHandlers.clear();
if (this.childEnv && this.childEnv.terminate) {
this.childEnv.terminate();
}
}
}

@@ -21,3 +21,3 @@ import type io from 'socket.io';

close: async () => {
wsHost.dispose();
await wsHost.dispose();
await engine.shutdown();

@@ -28,3 +28,3 @@ },

} catch (e) {
wsHost.dispose();
void wsHost.dispose();
throw e;

@@ -31,0 +31,0 @@ }

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

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