Socket
Socket
Sign inDemoInstall

@wixc3/engine-core

Package Overview
Dependencies
Maintainers
67
Versions
332
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wixc3/engine-core - npm Package Compare versions

Comparing version 43.0.2 to 43.0.3

2

dist/com/communication.d.ts

@@ -104,3 +104,3 @@ import type { ContextualEnvironment, Environment, EnvironmentMode } from '../entities/env.js';

*/
dispose(): void;
dispose(): Promise<void>;
getEnvironmentId(): string;

@@ -107,0 +107,0 @@ getEnvironmentName(): string;

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

const symbols_js_1 = require("../symbols.js");
const types_js_1 = require("../types.js");
const logs_js_1 = require("./logs.js");

@@ -15,3 +14,3 @@ const helpers_js_1 = require("./helpers.js");

const message_types_js_1 = require("./message-types.js");
const types_js_2 = require("./types.js");
const types_js_1 = require("./types.js");
const environment_disconnected_error_js_1 = require("./environment-disconnected-error.js");

@@ -376,3 +375,3 @@ /**

*/
dispose() {
async dispose() {
this.disposing = true;

@@ -383,4 +382,4 @@ for (const { host, id } of Object.values(this.environments)) {

}
if ((0, types_js_1.isDisposable)(host)) {
host.dispose();
if ((0, patterns_1.isDisposable)(host)) {
await host.dispose();
}

@@ -597,3 +596,3 @@ this.removeMessageHandler(host);

if (!env) {
return types_js_2.HOST_REMOVED;
return types_js_1.HOST_REMOVED;
}

@@ -600,0 +599,0 @@ const { host } = env;

import { type SocketOptions } from 'socket.io-client';
import { BaseHost } from './base-host.js';
import { EventEmitter } from '@wixc3/patterns';
export declare class WsClientHost extends BaseHost {
import { EventEmitter, IDisposable } from '@wixc3/patterns';
export declare class WsClientHost extends BaseHost implements IDisposable {
private disposables;
dispose: () => Promise<void>;
isDisposed: () => boolean;
connected: Promise<void>;

@@ -13,4 +16,3 @@ private socketClient;

postMessage(data: any): void;
dispose(): void;
}
//# sourceMappingURL=ws-client-host.d.ts.map

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

super();
this.disposables = new patterns_1.SafeDisposable(WsClientHost.name);
this.dispose = this.disposables.dispose;
this.isDisposed = this.disposables.isDisposed;
this.subscribers = new patterns_1.EventEmitter();
this.disposables.add('close socket', () => this.socketClient.close());
this.disposables.add('clear subscribers', () => this.subscribers.clear());
const { path, ...query } = Object.fromEntries(new URL(url).searchParams);

@@ -45,8 +50,4 @@ const { promise, resolve, reject } = (0, promise_assist_1.deferred)();

}
dispose() {
this.subscribers.clear();
this.socketClient.close();
}
}
exports.WsClientHost = WsClientHost;
//# sourceMappingURL=ws-client-host.js.map

@@ -9,4 +9,4 @@ import type { SocketOptions } from 'socket.io-client';

onReconnect: (cb: () => void) => void;
dispose: () => void;
dispose: () => Promise<void>;
}>;
//# sourceMappingURL=socket-server.d.ts.map

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

communication.clearEnvironment(instanceId, undefined, false);
host.dispose();
void host.dispose();
throw e;

@@ -34,3 +34,3 @@ }

communication.clearEnvironment(instanceId, undefined, false);
host.dispose();
return host.dispose();
},

@@ -37,0 +37,0 @@ };

@@ -5,2 +5,3 @@ import type { RuntimeEngine } from './runtime-engine.js';

import { RUN } from './symbols.js';
import { IDisposable } from '@wixc3/patterns';
import type { DisposeFunction, Running } from './types.js';

@@ -10,3 +11,3 @@ /**

**/
export declare class RuntimeFeature<T extends FeatureClass, ENV extends AnyEnvironment> {
export declare class RuntimeFeature<T extends FeatureClass, ENV extends AnyEnvironment> implements IDisposable {
feature: InstanceType<T>;

@@ -16,10 +17,11 @@ api: Running<T, ENV>;

environment: ENV;
private disposables;
dispose: () => Promise<void>;
isDisposed: () => boolean;
private running;
private runHandlers;
private disposeHandlers;
private disposing;
constructor(feature: InstanceType<T>, api: Running<T, ENV>, dependencies: RunningFeatures<InstanceType<T>['dependencies'], ENV>, environment: ENV);
addRunHandler: (fn: () => unknown) => void;
addOnDisposeHandler: (fn: DisposeFunction) => void;
dispose(): Promise<void>;
[RUN](engine: RuntimeEngine): Promise<void>;

@@ -26,0 +28,0 @@ }

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

const patterns_1 = require("@wixc3/patterns");
const promise_assist_1 = require("promise-assist");
/**

@@ -18,2 +17,5 @@ * Represents a currently running feature instance.

this.environment = environment;
this.disposables = new patterns_1.SafeDisposable(RuntimeFeature.name);
this.dispose = this.disposables.dispose;
this.isDisposed = this.disposables.isDisposed;
this.running = false;

@@ -28,14 +30,9 @@ this.runHandlers = new patterns_1.SetMultiMap();

};
this.disposables.add('disposal handlers', async () => {
const featureDisposeHandlers = this.disposeHandlers.get(this.environment.env) || new Set();
for (const handler of featureDisposeHandlers) {
await handler();
}
});
}
async dispose() {
if (this.disposing) {
return this.disposing.promise;
}
this.disposing = (0, promise_assist_1.deferred)();
const featureDisposeHandlers = this.disposeHandlers.get(this.environment.env) || new Set();
for (const handler of featureDisposeHandlers) {
await handler();
}
this.disposing.resolve();
}
async [symbols_js_1.RUN](engine) {

@@ -42,0 +39,0 @@ if (this.running) {

@@ -103,13 +103,2 @@ import type { LogMessage } from './common-types.js';

}
export interface IDisposable {
/**
* disposes the instance removing all event listeners
*/
dispose(): void;
/**
* is the instance disposed
*/
isDisposed(): boolean;
}
export declare function isDisposable(value: any): value is IDisposable;
export type OmitCompositeEnvironment<T extends AnyEnvironment> = Environment<T['env'], T['envType'], T['endpointType'], [

@@ -116,0 +105,0 @@ ]>;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LogLevel = exports.isDisposable = void 0;
exports.LogLevel = void 0;
const symbols_js_1 = require("./symbols.js");
function isDisposable(value) {
return ('dispose' in value &&
typeof value.dispose === 'function' &&
'isDisposed' in value &&
typeof value.isDisposed === 'function');
}
exports.isDisposable = isDisposable;
var LogLevel;

@@ -13,0 +6,0 @@ (function (LogLevel) {

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

@@ -21,3 +21,3 @@ "exports": {

"@wixc3/isomorphic-worker": "^1.2.5",
"@wixc3/patterns": "^15.3.1",
"@wixc3/patterns": "^16.1.0",
"promise-assist": "^2.0.1",

@@ -24,0 +24,0 @@ "socket.io-client": "^4.7.4",

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

import { SetMultiMap } from '@wixc3/patterns';
import { SetMultiMap, isDisposable } from '@wixc3/patterns';
import { deferred } from 'promise-assist';

@@ -6,3 +6,3 @@ import type { ContextualEnvironment, Environment, EnvironmentMode } from '../entities/env.js';

import { SERVICE_CONFIG } from '../symbols.js';
import { isDisposable, type IDTag } from '../types.js';
import { type IDTag } from '../types.js';
import {

@@ -489,3 +489,3 @@ CALLBACK_TIMEOUT,

*/
public dispose(): void {
public async dispose(): Promise<void> {
this.disposing = true;

@@ -497,3 +497,3 @@ for (const { host, id } of Object.values(this.environments)) {

if (isDisposable(host)) {
host.dispose();
await host.dispose();
}

@@ -500,0 +500,0 @@ this.removeMessageHandler(host);

import { io, Socket, type SocketOptions } from 'socket.io-client';
import type { Message } from '../message-types.js';
import { BaseHost } from './base-host.js';
import { EventEmitter } from '@wixc3/patterns';
import { EventEmitter, IDisposable, SafeDisposable } from '@wixc3/patterns';
import { deferred } from 'promise-assist';
export class WsClientHost extends BaseHost {
export class WsClientHost extends BaseHost implements IDisposable {
private disposables = new SafeDisposable(WsClientHost.name);
dispose = this.disposables.dispose;
isDisposed = this.disposables.isDisposed;
public connected: Promise<void>;

@@ -14,2 +17,4 @@ private socketClient: Socket;

super();
this.disposables.add('close socket', () => this.socketClient.close());
this.disposables.add('clear subscribers', () => this.subscribers.clear());

@@ -56,7 +61,2 @@ const { path, ...query } = Object.fromEntries(new URL(url).searchParams);

}
public dispose() {
this.subscribers.clear();
this.socketClient.close();
}
}

@@ -25,3 +25,3 @@ import type { SocketOptions } from 'socket.io-client';

communication.clearEnvironment(instanceId, undefined, false);
host.dispose();
void host.dispose();
throw e;

@@ -42,5 +42,5 @@ }

communication.clearEnvironment(instanceId, undefined, false);
host.dispose();
return host.dispose();
},
};
};

@@ -10,5 +10,4 @@ import type { RuntimeEngine } from './runtime-engine.js';

import { CREATE_RUNTIME, ENGINE, REGISTER_VALUE, RUN, RUN_OPTIONS } from './symbols.js';
import { SetMultiMap } from '@wixc3/patterns';
import { IDisposable, SafeDisposable, SetMultiMap } from '@wixc3/patterns';
import type { Context, DisposeFunction, Running } from './types.js';
import { deferred, type IDeferredPromise } from 'promise-assist';

@@ -18,7 +17,9 @@ /**

**/
export class RuntimeFeature<T extends FeatureClass, ENV extends AnyEnvironment> {
export class RuntimeFeature<T extends FeatureClass, ENV extends AnyEnvironment> implements IDisposable {
private disposables = new SafeDisposable(RuntimeFeature.name);
public dispose = this.disposables.dispose;
public isDisposed = this.disposables.isDisposed;
private running = false;
private runHandlers = new SetMultiMap<string, () => unknown>();
private disposeHandlers = new SetMultiMap<string, DisposeFunction>();
private disposing: IDeferredPromise<void> | undefined;
constructor(

@@ -29,3 +30,10 @@ public feature: InstanceType<T>,

public environment: ENV,
) {}
) {
this.disposables.add('disposal handlers', async () => {
const featureDisposeHandlers = this.disposeHandlers.get(this.environment.env) || new Set();
for (const handler of featureDisposeHandlers) {
await handler();
}
});
}
public addRunHandler = (fn: () => unknown) => {

@@ -37,13 +45,2 @@ this.runHandlers.add(this.environment.env, fn);

};
public async dispose() {
if (this.disposing) {
return this.disposing.promise;
}
this.disposing = deferred();
const featureDisposeHandlers = this.disposeHandlers.get(this.environment.env) || new Set();
for (const handler of featureDisposeHandlers) {
await handler();
}
this.disposing.resolve();
}
public async [RUN](engine: RuntimeEngine): Promise<void> {

@@ -50,0 +47,0 @@ if (this.running) {

@@ -97,6 +97,6 @@ import type { LogMessage } from './common-types.js';

: T extends { env: infer U1 }
? U1 extends string
? U1
: never
: never;
? U1 extends string
? U1
: never
: never;

@@ -191,22 +191,2 @@ type FilterENVKeys<T extends EntityRecord, ENV extends AnyEnvironment, Key extends 'visibleAt' | 'providedFrom'> = {

export interface IDisposable {
/**
* disposes the instance removing all event listeners
*/
dispose(): void;
/**
* is the instance disposed
*/
isDisposed(): boolean;
}
export function isDisposable(value: any): value is IDisposable {
return (
'dispose' in value &&
typeof value.dispose === 'function' &&
'isDisposed' in value &&
typeof value.isDisposed === 'function'
);
}
export type OmitCompositeEnvironment<T extends AnyEnvironment> = Environment<

@@ -213,0 +193,0 @@ T['env'],

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 too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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