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

@wixc3/engine-core

Package Overview
Dependencies
Maintainers
0
Versions
340
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 48.0.0 to 49.0.0

2

dist/com/communication-errors.d.ts

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

import type { Message } from './message-types';
import type { Message } from './message-types.js';
export declare class EngineCommunicationError extends Error {

@@ -3,0 +3,0 @@ readonly causedBy?: Message | undefined;

@@ -1,6 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CircularForwardingError = exports.EnvironmentDisconnectedError = exports.CallbackTimeoutError = exports.UnknownCallbackIdError = exports.UnConfiguredMethodError = exports.DuplicateRegistrationError = exports.EngineCommunicationError = void 0;
const helpers_1 = require("./helpers");
class EngineCommunicationError extends Error {
import { redactArguments } from './helpers.js';
export class EngineCommunicationError extends Error {
causedBy;

@@ -13,8 +10,7 @@ constructor(errorMessage, causedBy) {

if (this.causedBy) {
this.causedBy = (0, helpers_1.redactArguments)(this.causedBy);
this.causedBy = redactArguments(this.causedBy);
}
}
}
exports.EngineCommunicationError = EngineCommunicationError;
class DuplicateRegistrationError extends EngineCommunicationError {
export class DuplicateRegistrationError extends EngineCommunicationError {
constructor(id, type) {

@@ -24,4 +20,3 @@ super(`Cannot register ${type} "${id}" twice.`);

}
exports.DuplicateRegistrationError = DuplicateRegistrationError;
class UnConfiguredMethodError extends EngineCommunicationError {
export class UnConfiguredMethodError extends EngineCommunicationError {
constructor(api, method) {

@@ -31,4 +26,3 @@ super(`Cannot add listener to un-configured method ${api} ${method}.`);

}
exports.UnConfiguredMethodError = UnConfiguredMethodError;
class UnknownCallbackIdError extends EngineCommunicationError {
export class UnknownCallbackIdError extends EngineCommunicationError {
constructor(message, hostId) {

@@ -38,4 +32,3 @@ super(`Unknown callback "${message.callbackId}" at "${hostId}".`, message);

}
exports.UnknownCallbackIdError = UnknownCallbackIdError;
class CallbackTimeoutError extends EngineCommunicationError {
export class CallbackTimeoutError extends EngineCommunicationError {
constructor(callbackId, hostId, message) {

@@ -45,4 +38,3 @@ super(`Callback "${callbackId}" timed out at "${hostId}".`, message);

}
exports.CallbackTimeoutError = CallbackTimeoutError;
class EnvironmentDisconnectedError extends EngineCommunicationError {
export class EnvironmentDisconnectedError extends EngineCommunicationError {
constructor(environment, hostId, message) {

@@ -52,4 +44,3 @@ super(`Remote call failed in "${environment}" - environment disconnected at "${hostId}".`, message);

}
exports.EnvironmentDisconnectedError = EnvironmentDisconnectedError;
class CircularForwardingError extends EngineCommunicationError {
export class CircularForwardingError extends EngineCommunicationError {
constructor(message, fromEnv, toEnv) {

@@ -60,3 +51,2 @@ super(`Forwarding message from "${fromEnv}" to "${toEnv}" is stuck in circular messaging loop:\n\t${JSON.stringify(message.forwardingChain)}.

}
exports.CircularForwardingError = CircularForwardingError;
//# sourceMappingURL=communication-errors.js.map

@@ -1,16 +0,12 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Communication = void 0;
exports.declareComEmitter = declareComEmitter;
const patterns_1 = require("@wixc3/patterns");
const promise_assist_1 = require("promise-assist");
const index_js_1 = require("../helpers/index.js");
const symbols_js_1 = require("../symbols.js");
const logs_js_1 = require("./logs.js");
const helpers_js_1 = require("./helpers.js");
const base_host_js_1 = require("./hosts/base-host.js");
const ws_client_host_js_1 = require("./hosts/ws-client-host.js");
const message_types_js_1 = require("./message-types.js");
const types_js_1 = require("./types.js");
const communication_errors_1 = require("./communication-errors");
import { isDisposable, SetMultiMap } from '@wixc3/patterns';
import { deferred } from 'promise-assist';
import { errorToJson } from '../helpers/index.js';
import { SERVICE_CONFIG } from '../symbols.js';
import { REMOTE_CALL_FAILED, reportError, AUTO_REGISTER_ENVIRONMENT, FORWARDING_MESSAGE, MESSAGE_FROM_UNKNOWN_ENVIRONMENT, REGISTER_ENV, UNHANDLED, } from './logs.js';
import { deserializeApiCallArguments, isWindow, isWorkerContext, MultiCounter, serializeApiCallArguments, redactArguments, } from './helpers.js';
import { BaseHost } from './hosts/base-host.js';
import { WsClientHost } from './hosts/ws-client-host.js';
import { isMessage } from './message-types.js';
import { HOST_REMOVED, } from './types.js';
import { CallbackTimeoutError, CircularForwardingError, DuplicateRegistrationError, EnvironmentDisconnectedError, UnConfiguredMethodError, UnknownCallbackIdError, } from './communication-errors.js';
/**

@@ -20,3 +16,3 @@ * Manages all API registrations and message forwarding

*/
class Communication {
export class Communication {
host;

@@ -28,8 +24,8 @@ topology;

rootEnvName;
idsCounter = new helpers_js_1.MultiCounter();
idsCounter = new MultiCounter();
disposing = false;
callbackTimeout = 60_000 * 5; // 5 minutes
slowThreshold = 5_000; // 5 seconds
pendingEnvs = new patterns_1.SetMultiMap();
pendingMessages = new patterns_1.SetMultiMap();
pendingEnvs = new SetMultiMap();
pendingMessages = new SetMultiMap();
handlers = new Map();

@@ -83,3 +79,3 @@ eventDispatchers = {};

if (this.DEBUG) {
console.debug((0, logs_js_1.REGISTER_ENV)(id, this.rootEnvId));
console.debug(REGISTER_ENV(id, this.rootEnvId));
}

@@ -91,3 +87,3 @@ const existingEnv = this.environments[id];

else if (existingEnv.host !== host) {
throw new communication_errors_1.DuplicateRegistrationError(id, 'Environment');
throw new DuplicateRegistrationError(id, 'Environment');
}

@@ -105,3 +101,3 @@ }

else {
throw new communication_errors_1.DuplicateRegistrationError(id, 'RemoteService');
throw new DuplicateRegistrationError(id, 'RemoteService');
}

@@ -162,3 +158,3 @@ }

const onTargetMessage = ({ data, source }) => {
if ((0, message_types_js_1.isMessage)(data)) {
if (isMessage(data)) {
this.handleEvent({ data, source: source || envTarget });

@@ -201,3 +197,3 @@ }

type: 'call',
data: { api, method, args: (0, helpers_js_1.serializeApiCallArguments)(args) },
data: { api, method, args: serializeApiCallArguments(args) },
callbackId,

@@ -214,3 +210,3 @@ origin,

async handleMessage(message, source) {
if (!(0, message_types_js_1.isMessage)(message)) {
if (!isMessage(message)) {
return;

@@ -271,3 +267,3 @@ }

for (const envId of envs) {
const { promise, resolve, reject } = (0, promise_assist_1.deferred)();
const { promise, resolve, reject } = deferred();
const callbackId = this.idsCounter.next(this.messageIdPrefix);

@@ -358,3 +354,3 @@ this.callWithCallback(envId, {

if (this.DEBUG) {
console.debug((0, logs_js_1.AUTO_REGISTER_ENVIRONMENT)((0, helpers_js_1.redactArguments)(message), this.rootEnvId));
console.debug(AUTO_REGISTER_ENVIRONMENT(redactArguments(message), this.rootEnvId));
}

@@ -368,3 +364,3 @@ return false;

if (this.DEBUG) {
console.debug((0, logs_js_1.MESSAGE_FROM_UNKNOWN_ENVIRONMENT)((0, helpers_js_1.redactArguments)(message), this.rootEnvId));
console.debug(MESSAGE_FROM_UNKNOWN_ENVIRONMENT(redactArguments(message), this.rootEnvId));
}

@@ -377,3 +373,3 @@ if (this.validateRegistration(source, message)) {

if (this.DEBUG) {
console.debug((0, logs_js_1.MESSAGE_FROM_UNKNOWN_ENVIRONMENT)((0, helpers_js_1.redactArguments)(message), this.rootEnvId), 'origin');
console.debug(MESSAGE_FROM_UNKNOWN_ENVIRONMENT(redactArguments(message), this.rootEnvId), 'origin');
}

@@ -391,6 +387,6 @@ if (this.validateRegistration(source, message)) {

for (const { host, id } of Object.values(this.environments)) {
if (host instanceof ws_client_host_js_1.WsClientHost) {
if (host instanceof WsClientHost) {
host.subscribers.clear();
}
if ((0, patterns_1.isDisposable)(host)) {
if (isDisposable(host)) {
await host.dispose();

@@ -428,3 +424,3 @@ }

applyApiDirectives(id, api) {
const serviceConfig = api[symbols_js_1.SERVICE_CONFIG];
const serviceConfig = api[SERVICE_CONFIG];
if (serviceConfig) {

@@ -444,3 +440,3 @@ this.apisOverrides[id] = {};

}
const { promise, resolve } = (0, promise_assist_1.deferred)();
const { promise, resolve } = deferred();
this.pendingEnvs.add(instanceId, resolve);

@@ -472,3 +468,3 @@ return promise;

if (callbackRecord.message.to === instanceId) {
callbackRecord.reject(new communication_errors_1.EnvironmentDisconnectedError(instanceId, this.rootEnvId, callbackRecord.message));
callbackRecord.reject(new EnvironmentDisconnectedError(instanceId, this.rootEnvId, callbackRecord.message));
}

@@ -494,3 +490,3 @@ }

forwardingChain: message.forwardingChain,
error: new communication_errors_1.CircularForwardingError(message, this.rootEnvId, env.id),
error: new CircularForwardingError(message, this.rootEnvId, env.id),
});

@@ -500,3 +496,3 @@ return;

else if (this.DEBUG) {
console.debug((0, logs_js_1.FORWARDING_MESSAGE)((0, helpers_js_1.redactArguments)(message), this.rootEnvId, env.id));
console.debug(FORWARDING_MESSAGE(redactArguments(message), this.rootEnvId, env.id));
}

@@ -517,3 +513,3 @@ if (this.pendingEnvs.get(env.id)) {

if (this.DEBUG) {
console.debug((0, logs_js_1.UNHANDLED)((0, helpers_js_1.redactArguments)(message), this.rootEnvId));
console.debug(UNHANDLED(redactArguments(message), this.rootEnvId));
}

@@ -563,3 +559,3 @@ }

const handlerId = this.getHandlerId(envId, api, method);
throw new communication_errors_1.DuplicateRegistrationError(handlerId, 'Listener');
throw new DuplicateRegistrationError(handlerId, 'Listener');
}

@@ -586,3 +582,3 @@ handlersBucket.add(fn);

else {
throw new communication_errors_1.UnConfiguredMethodError(api, method);
throw new UnConfiguredMethodError(api, method);
}

@@ -609,3 +605,3 @@ }

post(target, message) {
if ((0, helpers_js_1.isWorkerContext)(target)) {
if (isWorkerContext(target)) {
target.postMessage(message);

@@ -620,3 +616,3 @@ }

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

@@ -628,3 +624,3 @@ const { host } = env;

else {
if (host instanceof base_host_js_1.BaseHost) {
if (host instanceof BaseHost) {
return host.parent || host;

@@ -636,3 +632,3 @@ }

getPostEndpoint(target) {
return (0, helpers_js_1.isWindow)(target) ? target.opener || target.parent : target;
return isWindow(target) ? target.opener || target.parent : target;
}

@@ -709,3 +705,3 @@ handleEventMessage(message) {

type: 'callback',
error: (0, index_js_1.errorToJson)(error),
error: errorToJson(error),
callbackId: message.callbackId,

@@ -718,3 +714,3 @@ origin: this.rootEnvId,

try {
const args = (0, helpers_js_1.deserializeApiCallArguments)(message.data.args);
const args = deserializeApiCallArguments(message.data.args);
const data = await this.apiCall(message.origin, message.data.api, message.data.method, args);

@@ -738,3 +734,3 @@ if (message.callbackId) {

type: 'callback',
error: (0, index_js_1.errorToJson)(error),
error: errorToJson(error),
callbackId: message.callbackId,

@@ -755,3 +751,3 @@ origin: this.rootEnvId,

const error = Object.assign(new Error(), message.error);
error.stack = (0, logs_js_1.REMOTE_CALL_FAILED)(message.from, error.stack);
error.stack = REMOTE_CALL_FAILED(message.from, error.stack);
rec.reject(error);

@@ -765,3 +761,3 @@ }

if (message.callbackId) {
throw new communication_errors_1.UnknownCallbackIdError(message, this.rootEnvId);
throw new UnknownCallbackIdError(message, this.rootEnvId);
}

@@ -787,3 +783,3 @@ }

handleEvent = ({ data, source }) => {
this.handleMessage(data, source).catch(logs_js_1.reportError);
this.handleMessage(data, source).catch(reportError);
};

@@ -820,3 +816,3 @@ getHandlerId(envId, api, method) {

if (this.DEBUG) {
error.cause = `Caused by: ${JSON.stringify((0, helpers_js_1.redactArguments)(message), null, 2)}`;
error.cause = `Caused by: ${JSON.stringify(redactArguments(message), null, 2)}`;
}

@@ -828,3 +824,3 @@ rej(error);

if (this.pendingCallbacks.has(callbackId)) {
console.warn(new communication_errors_1.CallbackTimeoutError(callbackId, this.rootEnvId, message).message);
console.warn(new CallbackTimeoutError(callbackId, this.rootEnvId, message).message);
}

@@ -835,3 +831,3 @@ }, this.slowThreshold);

callbackItem.timerId = setTimeout(() => {
callbackItem.reject(new communication_errors_1.CallbackTimeoutError(callbackId, this.rootEnvId, message));
callbackItem.reject(new CallbackTimeoutError(callbackId, this.rootEnvId, message));
}, this.callbackTimeout);

@@ -850,4 +846,3 @@ },

}
exports.Communication = Communication;
function declareComEmitter(onMethod, offMethod, removeAll) {
export function declareComEmitter(onMethod, offMethod, removeAll) {
if (typeof onMethod !== 'string') {

@@ -854,0 +849,0 @@ throw new Error('onMethod ref must be a string');

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

import { Message } from './message-types';
import { Message } from './message-types.js';
export declare function isWorkerContext(target: unknown): target is Worker;

@@ -21,19 +21,19 @@ export declare function isWindow(win: unknown): win is Window;

type: T;
}>) => Extract<import("./message-types").CallMessage, {
}>) => Extract<import("./message-types.js").CallMessage, {
type: T;
}> | Extract<import("./message-types").CallbackMessage, {
}> | Extract<import("./message-types.js").CallbackMessage, {
type: T;
}> | Extract<import("./message-types").ListenMessage, {
}> | Extract<import("./message-types.js").ListenMessage, {
type: T;
}> | Extract<import("./message-types").UnListenMessage, {
}> | Extract<import("./message-types.js").UnListenMessage, {
type: T;
}> | Extract<import("./message-types").EventMessage, {
}> | Extract<import("./message-types.js").EventMessage, {
type: T;
}> | Extract<import("./message-types").ReadyMessage, {
}> | Extract<import("./message-types.js").ReadyMessage, {
type: T;
}> | Extract<import("./message-types").DisposeMessage, {
}> | Extract<import("./message-types.js").DisposeMessage, {
type: T;
}> | Extract<import("./message-types").StatusMessage, {
}> | Extract<import("./message-types.js").StatusMessage, {
type: T;
}>;
//# sourceMappingURL=helpers.d.ts.map

@@ -1,18 +0,12 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.redactArguments = exports.deserializeApiCallArguments = exports.serializeApiCallArguments = exports.MultiCounter = void 0;
exports.isWorkerContext = isWorkerContext;
exports.isWindow = isWindow;
exports.isIframe = isIframe;
function isWorkerContext(target) {
export function isWorkerContext(target) {
return ((typeof Worker !== 'undefined' && target instanceof Worker) ||
(typeof WorkerGlobalScope !== 'undefined' && target instanceof WorkerGlobalScope));
}
function isWindow(win) {
export function isWindow(win) {
return typeof Window !== 'undefined' && win instanceof Window;
}
function isIframe(iframe) {
export function isIframe(iframe) {
return typeof HTMLIFrameElement !== 'undefined' && iframe instanceof HTMLIFrameElement;
}
class MultiCounter {
export class MultiCounter {
ids = {};

@@ -24,3 +18,2 @@ next(ns) {

}
exports.MultiCounter = MultiCounter;
const undefinedPlaceholder = '__undefined_placeholder__';

@@ -31,6 +24,4 @@ /**

*/
const serializeApiCallArguments = (args) => args.map((arg) => (arg === undefined ? undefinedPlaceholder : arg));
exports.serializeApiCallArguments = serializeApiCallArguments;
const deserializeApiCallArguments = (args) => args.map((arg) => (arg === undefinedPlaceholder ? undefined : arg));
exports.deserializeApiCallArguments = deserializeApiCallArguments;
export const serializeApiCallArguments = (args) => args.map((arg) => (arg === undefined ? undefinedPlaceholder : arg));
export const deserializeApiCallArguments = (args) => args.map((arg) => (arg === undefinedPlaceholder ? undefined : arg));
/**

@@ -40,3 +31,3 @@ * Redacts arguments from a message.

*/
const redactArguments = (message) => {
export const redactArguments = (message) => {
if ('data' in message &&

@@ -57,3 +48,2 @@ typeof message.data === 'object' &&

};
exports.redactArguments = redactArguments;
//# sourceMappingURL=helpers.js.map

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseHost = void 0;
class BaseHost {
export class BaseHost {
name;

@@ -40,3 +37,2 @@ constructor(name = 'base-host') {

}
exports.BaseHost = BaseHost;
//# sourceMappingURL=base-host.js.map

@@ -1,6 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EventEmitterHost = void 0;
const base_host_js_1 = require("./base-host.js");
class EventEmitterHost extends base_host_js_1.BaseHost {
import { BaseHost } from './base-host.js';
export class EventEmitterHost extends BaseHost {
host;

@@ -16,3 +13,2 @@ constructor(host) {

}
exports.EventEmitterHost = EventEmitterHost;
//# sourceMappingURL=event-emitter.js.map

@@ -1,21 +0,5 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./base-host.js"), exports);
__exportStar(require("./event-emitter.js"), exports);
__exportStar(require("./universal-worker-host.js"), exports);
__exportStar(require("./ws-client-host.js"), exports);
export * from './base-host.js';
export * from './event-emitter.js';
export * from './universal-worker-host.js';
export * from './ws-client-host.js';
//# sourceMappingURL=index.js.map

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UniversalWorkerHost = void 0;
class UniversalWorkerHost {
export class UniversalWorkerHost {
worker;

@@ -28,3 +25,2 @@ name;

}
exports.UniversalWorkerHost = UniversalWorkerHost;
//# sourceMappingURL=universal-worker-host.js.map

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.WsClientHost = void 0;
const socket_io_client_1 = require("socket.io-client");
const base_host_js_1 = require("./base-host.js");
const patterns_1 = require("@wixc3/patterns");
const promise_assist_1 = require("promise-assist");
class WsClientHost extends base_host_js_1.BaseHost {
disposables = new patterns_1.SafeDisposable(WsClientHost.name);
import { io } from 'socket.io-client';
import { BaseHost } from './base-host.js';
import { EventEmitter, SafeDisposable } from '@wixc3/patterns';
import { deferred } from 'promise-assist';
export class WsClientHost extends BaseHost {
disposables = new SafeDisposable(WsClientHost.name);
dispose = this.disposables.dispose;

@@ -14,3 +11,3 @@ isDisposed = this.disposables.isDisposed;

socketClient;
subscribers = new patterns_1.EventEmitter();
subscribers = new EventEmitter();
constructor(url, options) {

@@ -21,5 +18,5 @@ super();

const { path, ...query } = Object.fromEntries(new URL(url).searchParams);
const { promise, resolve, reject } = (0, promise_assist_1.deferred)();
const { promise, resolve, reject } = deferred();
this.connected = promise;
this.socketClient = (0, socket_io_client_1.io)(url, {
this.socketClient = io(url, {
transports: ['websocket'],

@@ -54,3 +51,2 @@ forceNew: true,

}
exports.WsClientHost = WsClientHost;
//# sourceMappingURL=ws-client-host.js.map

@@ -1,30 +0,14 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./hosts/base-host.js"), exports);
__exportStar(require("./communication.js"), exports);
__exportStar(require("./logs.js"), exports);
__exportStar(require("./helpers.js"), exports);
__exportStar(require("./logger-service.js"), exports);
__exportStar(require("./window-initializer-service.js"), exports);
__exportStar(require("./message-types.js"), exports);
__exportStar(require("./service-config.js"), exports);
__exportStar(require("./types.js"), exports);
__exportStar(require("./hosts/ws-client-host.js"), exports);
__exportStar(require("./initializers/index.js"), exports);
__exportStar(require("./hosts/index.js"), exports);
__exportStar(require("./communication-errors.js"), exports);
export * from './hosts/base-host.js';
export * from './communication.js';
export * from './logs.js';
export * from './helpers.js';
export * from './logger-service.js';
export * from './window-initializer-service.js';
export * from './message-types.js';
export * from './service-config.js';
export * from './types.js';
export * from './hosts/ws-client-host.js';
export * from './initializers/index.js';
export * from './hosts/index.js';
export * from './communication-errors.js';
//# sourceMappingURL=index.js.map

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.initializeContextualEnv = initializeContextualEnv;
function initializeContextualEnv({ communication, env: { env, environments }, envInitializers, }) {
export function initializeContextualEnv({ communication, env: { env, environments }, envInitializers, }) {
const runtimeEnvironmentName = communication.resolvedContexts[env];

@@ -6,0 +3,0 @@ const activeEnvironment = environments.find((contextualEnv) => contextualEnv.env === runtimeEnvironmentName);

@@ -1,10 +0,4 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.INSTANCE_ID_PARAM_NAME = void 0;
exports.iframeInitializer = iframeInitializer;
exports.deferredIframeInitializer = deferredIframeInitializer;
exports.startIframe = startIframe;
const window_initializer_service_js_1 = require("../window-initializer-service.js");
exports.INSTANCE_ID_PARAM_NAME = 'iframe-instance-id';
async function iframeInitializer({ communication, env, ...initializerOptions }) {
import { WindowInitializerService } from '../window-initializer-service.js';
export const INSTANCE_ID_PARAM_NAME = 'iframe-instance-id';
export async function iframeInitializer({ communication, env, ...initializerOptions }) {
const { initialize } = deferredIframeInitializer({ communication, env });

@@ -16,3 +10,3 @@ const id = await initialize(initializerOptions);

}
function deferredIframeInitializer({ communication: com, env: { env, endpointType } }) {
export function deferredIframeInitializer({ communication: com, env: { env, endpointType } }) {
const instanceId = com.getEnvironmentInstanceId(env, endpointType);

@@ -36,3 +30,3 @@ const envReadyPromise = com.envReady(instanceId);

const cancellationTriggers = new WeakMap();
async function startIframe({ com, iframe, instanceId, src, envReadyPromise }) {
export async function startIframe({ com, iframe, instanceId, src, envReadyPromise }) {
if (!iframe.contentWindow) {

@@ -56,6 +50,6 @@ throw new Error('Cannot initialize environment in a detached iframe');

// script that will run in the iframe can pick it up
url.searchParams.set(exports.INSTANCE_ID_PARAM_NAME, instanceId);
url.searchParams.set(INSTANCE_ID_PARAM_NAME, instanceId);
iframe.src = url.href;
await Promise.race([waitForCancel, envReadyPromise]);
const api = com.apiProxy({ id: instanceId }, { id: window_initializer_service_js_1.WindowInitializerService.apiId }, {
const api = com.apiProxy({ id: instanceId }, { id: WindowInitializerService.apiId }, {
oncePageHide: {

@@ -62,0 +56,0 @@ listener: true,

@@ -1,24 +0,8 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./socket-server.js"), exports);
__exportStar(require("./window.js"), exports);
__exportStar(require("./contextual.js"), exports);
__exportStar(require("./webworker.js"), exports);
__exportStar(require("./iframe.js"), exports);
__exportStar(require("./ipc.js"), exports);
__exportStar(require("./types.js"), exports);
export * from './socket-server.js';
export * from './window.js';
export * from './contextual.js';
export * from './webworker.js';
export * from './iframe.js';
export * from './ipc.js';
export * from './types.js';
//# sourceMappingURL=index.js.map

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ipcInitializer = void 0;
const ipcInitializer = async ({ communication, env: { env, endpointType } }) => {
export const ipcInitializer = async ({ communication, env: { env, endpointType } }) => {
const instanceId = communication.getEnvironmentInstanceId(env, endpointType);

@@ -16,3 +13,2 @@ const host = communication.getEnvironmentHost(env);

};
exports.ipcInitializer = ipcInitializer;
//# sourceMappingURL=ipc.js.map

@@ -1,9 +0,6 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.socketClientInitializer = void 0;
const ws_client_host_js_1 = require("../hosts/ws-client-host.js");
const socketClientInitializer = async ({ communication, env: { env }, ...socketClientOptions }) => {
import { WsClientHost } from '../hosts/ws-client-host.js';
export const socketClientInitializer = async ({ communication, env: { env }, ...socketClientOptions }) => {
const url = communication.topology[env] || location.origin;
const instanceId = env;
const host = new ws_client_host_js_1.WsClientHost(url, socketClientOptions);
const host = new WsClientHost(url, socketClientOptions);
if (communication.getEnvironmentHost(instanceId)) {

@@ -37,3 +34,2 @@ communication.clearEnvironment(instanceId, undefined, false);

};
exports.socketClientInitializer = socketClientInitializer;
//# sourceMappingURL=socket-server.js.map

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
export {};
//# sourceMappingURL=types.js.map

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.webWorkerInitializer = webWorkerInitializer;
const worker_1 = require("@wixc3/isomorphic-worker/worker");
const universal_worker_host_js_1 = require("../hosts/universal-worker-host.js");
async function webWorkerInitializer({ communication, env: { env, endpointType }, workerOptions = {}, workerExtension = '.js', }) {
import { Worker } from '@wixc3/isomorphic-worker/worker';
import { UniversalWorkerHost } from '../hosts/universal-worker-host.js';
export async function webWorkerInitializer({ communication, env: { env, endpointType }, workerOptions = {}, workerExtension = '.js', }) {
const instanceId = communication.getEnvironmentInstanceId(env, endpointType);
const url = `${communication.getPublicPath()}${env}.webworker${workerExtension}${location.search}`;
const webWorker = new worker_1.Worker(url, {
const webWorker = new Worker(url, {
/**

@@ -18,3 +15,3 @@ * in the new flow we inject this global in the top of each bundle.

});
const host = new universal_worker_host_js_1.UniversalWorkerHost(webWorker, instanceId);
const host = new UniversalWorkerHost(webWorker, instanceId);
communication.registerMessageHandler(host);

@@ -21,0 +18,0 @@ communication.registerEnv(instanceId, host);

@@ -1,13 +0,10 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.windowInitializer = windowInitializer;
const helpers_js_1 = require("../helpers.js");
const index_js_1 = require("../../helpers/index.js");
async function windowInitializer({ communication, env: { env, endpointType }, host }) {
import { isIframe } from '../helpers.js';
import { injectScript } from '../../helpers/index.js';
export async function windowInitializer({ communication, env: { env, endpointType }, host }) {
const instanceId = communication.getEnvironmentInstanceId(env, endpointType);
const win = (0, helpers_js_1.isIframe)(host) ? host.contentWindow : host;
const win = isIframe(host) ? host.contentWindow : host;
if (!win) {
throw new Error('cannot spawn detached iframe.');
}
await (0, index_js_1.injectScript)(win, instanceId, `${communication.getPublicPath()}${env}.web.js${location.search}`);
await injectScript(win, instanceId, `${communication.getPublicPath()}${env}.web.js${location.search}`);
return {

@@ -14,0 +11,0 @@ id: instanceId,

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LoggerService = void 0;
const patterns_1 = require("@wixc3/patterns");
const types_js_1 = require("../types.js");
class LoggerService extends patterns_1.EventEmitter {
import { EventEmitter } from '@wixc3/patterns';
import { LogLevel } from '../types.js';
export class LoggerService extends EventEmitter {
transports;

@@ -11,3 +8,3 @@ baseMetadata;

messages = [];
constructor(transports = [], baseMetadata = {}, config = { severity: types_js_1.LogLevel.DEBUG }) {
constructor(transports = [], baseMetadata = {}, config = { severity: LogLevel.DEBUG }) {
super();

@@ -21,6 +18,6 @@ this.transports = transports;

}
debug = (value) => this.log(value, types_js_1.LogLevel.DEBUG);
info = (value) => this.log(value, types_js_1.LogLevel.INFO);
warn = (value) => this.log(value, types_js_1.LogLevel.WARN);
error = (value) => this.log(value, types_js_1.LogLevel.ERROR);
debug = (value) => this.log(value, LogLevel.DEBUG);
info = (value) => this.log(value, LogLevel.INFO);
warn = (value) => this.log(value, LogLevel.WARN);
error = (value) => this.log(value, LogLevel.ERROR);
logMessage(message) {

@@ -57,3 +54,2 @@ if (message.level >= this.config.severity) {

}
exports.LoggerService = LoggerService;
function getValue(message) {

@@ -84,12 +80,12 @@ const logValue = {

switch (level) {
case types_js_1.LogLevel.DEBUG:
case LogLevel.DEBUG:
console.log(message, metadata);
break;
case types_js_1.LogLevel.INFO:
case LogLevel.INFO:
console.info(message, metadata);
break;
case types_js_1.LogLevel.WARN:
case LogLevel.WARN:
console.warn(message, metadata);
break;
case types_js_1.LogLevel.ERROR:
case LogLevel.ERROR:
console.error(message, metadata);

@@ -96,0 +92,0 @@ break;

@@ -1,32 +0,16 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UNHANDLED = exports.REGISTER_ENV = exports.FORWARDING_MESSAGE = exports.MESSAGE_FROM_UNKNOWN_ENVIRONMENT = exports.AUTO_REGISTER_ENVIRONMENT = exports.MISSING_CONTEXT_FOR_API_PROXY = exports.SPAWNED_MORE_THEN_ONCE = exports.MISSING_COM_CONTEXT = exports.MISSING_FORWARD_FOR_MESSAGE = exports.MISSING_ENV = exports.REMOTE_CALL_FAILED = exports.GLOBAL_REF = void 0;
exports.reportError = reportError;
const GLOBAL_REF = (id) => `Com with id "${id}" is already running.`;
exports.GLOBAL_REF = GLOBAL_REF;
const REMOTE_CALL_FAILED = (environment, stack) => `Remote call failed in "${environment}"${stack ? `\n${stack}` : ''}`;
exports.REMOTE_CALL_FAILED = REMOTE_CALL_FAILED;
const MISSING_ENV = (target, environments) => `Destination environment ${target} is not registered. available environments: [${environments.join(', ')}]`;
exports.MISSING_ENV = MISSING_ENV;
const MISSING_FORWARD_FOR_MESSAGE = (message) => `Not implemented forward for ${message.type}`;
exports.MISSING_FORWARD_FOR_MESSAGE = MISSING_FORWARD_FOR_MESSAGE;
const MISSING_COM_CONTEXT = (id, when) => `Missing communication context for "${id}" when ${when}`;
exports.MISSING_COM_CONTEXT = MISSING_COM_CONTEXT;
const SPAWNED_MORE_THEN_ONCE = (id) => `Environment with id ${id} can only spawned once`;
exports.SPAWNED_MORE_THEN_ONCE = SPAWNED_MORE_THEN_ONCE;
const MISSING_CONTEXT_FOR_API_PROXY = (type, remoteServiceId) => `Missing ${type} when trying to get remote service api proxy for ${remoteServiceId}`;
exports.MISSING_CONTEXT_FOR_API_PROXY = MISSING_CONTEXT_FOR_API_PROXY;
const AUTO_REGISTER_ENVIRONMENT = (message, hostId) => `[autoRegisterEnvironment]: skipping host self registration at "${hostId}" for message ${JSON.stringify(message)}`;
exports.AUTO_REGISTER_ENVIRONMENT = AUTO_REGISTER_ENVIRONMENT;
const MESSAGE_FROM_UNKNOWN_ENVIRONMENT = (message, hostId, origin = '') => `Received message from unknown environment ${origin ? origin + ' ' : ''} "${message.from}" at "${hostId}": ${JSON.stringify(message)}`;
exports.MESSAGE_FROM_UNKNOWN_ENVIRONMENT = MESSAGE_FROM_UNKNOWN_ENVIRONMENT;
const FORWARDING_MESSAGE = (message, fromEnv, toEnv) => `forwarding message ${JSON.stringify(message)} from ${fromEnv} to ${toEnv}`;
exports.FORWARDING_MESSAGE = FORWARDING_MESSAGE;
const REGISTER_ENV = (id, hostId) => `registering env ${id} at ${hostId}`;
exports.REGISTER_ENV = REGISTER_ENV;
const UNHANDLED = (message, hostId) => `[DEBUG] unhandledMessage received at ${hostId}. message:\n${JSON.stringify(message, null, 2)}`;
exports.UNHANDLED = UNHANDLED;
function reportError(e) {
export const GLOBAL_REF = (id) => `Com with id "${id}" is already running.`;
export const REMOTE_CALL_FAILED = (environment, stack) => `Remote call failed in "${environment}"${stack ? `\n${stack}` : ''}`;
export const MISSING_ENV = (target, environments) => `Destination environment ${target} is not registered. available environments: [${environments.join(', ')}]`;
export const MISSING_FORWARD_FOR_MESSAGE = (message) => `Not implemented forward for ${message.type}`;
export const MISSING_COM_CONTEXT = (id, when) => `Missing communication context for "${id}" when ${when}`;
export const SPAWNED_MORE_THEN_ONCE = (id) => `Environment with id ${id} can only spawned once`;
export const MISSING_CONTEXT_FOR_API_PROXY = (type, remoteServiceId) => `Missing ${type} when trying to get remote service api proxy for ${remoteServiceId}`;
export const AUTO_REGISTER_ENVIRONMENT = (message, hostId) => `[autoRegisterEnvironment]: skipping host self registration at "${hostId}" for message ${JSON.stringify(message)}`;
export const MESSAGE_FROM_UNKNOWN_ENVIRONMENT = (message, hostId, origin = '') => `Received message from unknown environment ${origin ? origin + ' ' : ''} "${message.from}" at "${hostId}": ${JSON.stringify(message)}`;
export const FORWARDING_MESSAGE = (message, fromEnv, toEnv) => `forwarding message ${JSON.stringify(message)} from ${fromEnv} to ${toEnv}`;
export const REGISTER_ENV = (id, hostId) => `registering env ${id} at ${hostId}`;
export const UNHANDLED = (message, hostId) => `[DEBUG] unhandledMessage received at ${hostId}. message:\n${JSON.stringify(message, null, 2)}`;
export function reportError(e) {
console.error(e);
}
//# sourceMappingURL=logs.js.map

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isMessage = isMessage;
function isMessage(arg) {
export function isMessage(arg) {
return typeof arg === 'object' && arg !== null && 'to' in arg && 'from' in arg && 'type' in arg;
}
//# sourceMappingURL=message-types.js.map

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.multiTenantMethod = multiTenantMethod;
function multiTenantMethod(method) {
export function multiTenantMethod(method) {
return (context) => {

@@ -6,0 +3,0 @@ function getArgs([_first, ...rest]) {

@@ -1,6 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HOST_REMOVED = void 0;
const symbols_js_1 = require("../symbols.js");
exports.HOST_REMOVED = {
import { SERVICE_CONFIG } from '../symbols.js';
export const HOST_REMOVED = {
name: 'HOST_REMOVED',

@@ -7,0 +4,0 @@ addEventListener: () => void 0,

@@ -1,8 +0,5 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.WindowInitializerService = void 0;
/**
* Service needed to complete window initialization
*/
class WindowInitializerService {
export class WindowInitializerService {
static apiId = 'WindowInitializerService';

@@ -16,3 +13,2 @@ oncePageHide(handler) {

}
exports.WindowInitializerService = WindowInitializerService;
//# sourceMappingURL=window-initializer-service.js.map

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
export {};
//# sourceMappingURL=common-types.js.map

@@ -1,20 +0,18 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const base_host_js_1 = require("./com/hosts/base-host.js");
const communication_js_1 = require("./com/communication.js");
const logger_service_js_1 = require("./com/logger-service.js");
const config_js_1 = require("./entities/config.js");
const env_js_1 = require("./entities/env.js");
const feature_js_1 = require("./entities/feature.js");
const value_js_1 = require("./entities/value.js");
const slot_js_1 = require("./entities/slot.js");
const symbols_js_1 = require("./symbols.js");
const types_js_1 = require("./types.js");
const window_initializer_service_js_1 = require("./com/window-initializer-service.js");
class COM extends feature_js_1.Feature {
import { BaseHost } from './com/hosts/base-host.js';
import { Communication } from './com/communication.js';
import { LoggerService } from './com/logger-service.js';
import { Config } from './entities/config.js';
import { AllEnvironments, Universal } from './entities/env.js';
import { Feature } from './entities/feature.js';
import { Value } from './entities/value.js';
import { Slot } from './entities/slot.js';
import { RUN_OPTIONS, ENGINE } from './symbols.js';
import { LogLevel } from './types.js';
import { WindowInitializerService } from './com/window-initializer-service.js';
export default class COM extends Feature {
id = 'COM';
api = {
config: config_js_1.Config.withType().defineEntity({
config: Config.withType().defineEntity({
id: '',
loggerSeverity: types_js_1.LogLevel.DEBUG,
loggerSeverity: LogLevel.DEBUG,
maxLogMessages: 100,

@@ -39,9 +37,8 @@ topology: {},

})),
loggerTransports: slot_js_1.Slot.withType().defineEntity(env_js_1.Universal),
loggerService: value_js_1.Value.withType().defineEntity(env_js_1.Universal),
communication: value_js_1.Value.withType().defineEntity(env_js_1.AllEnvironments),
loggerTransports: Slot.withType().defineEntity(Universal),
loggerService: Value.withType().defineEntity(Universal),
communication: Value.withType().defineEntity(AllEnvironments),
};
}
exports.default = COM;
COM.setup(env_js_1.Universal, ({ config: { host, id, topology, maxLogMessages, loggerSeverity, logToConsole, resolvedContexts, publicPath, connectedEnvironments = {}, }, loggerTransports, [symbols_js_1.RUN_OPTIONS]: runOptions, [symbols_js_1.ENGINE]: engine, onDispose, }) => {
COM.setup(Universal, ({ config: { host, id, topology, maxLogMessages, loggerSeverity, logToConsole, resolvedContexts, publicPath, connectedEnvironments = {}, }, loggerTransports, [RUN_OPTIONS]: runOptions, [ENGINE]: engine, onDispose, }) => {
const isNode = typeof process !== 'undefined' &&

@@ -62,7 +59,7 @@ !!process.versions?.node &&

};
const communication = new communication_js_1.Communication(isNode ? host || new base_host_js_1.BaseHost() : host || self, comId, topology, resolvedContexts, isNode, comOptions);
const communication = new Communication(isNode ? host || new BaseHost() : host || self, comId, topology, resolvedContexts, isNode, comOptions);
// manually register window initialization api service to be used during
// start of managed iframe in packages/core/src/com/initializers/iframe.ts
communication.registerAPI({ id: window_initializer_service_js_1.WindowInitializerService.apiId }, new window_initializer_service_js_1.WindowInitializerService());
const loggerService = new logger_service_js_1.LoggerService(loggerTransports, { environment: communication.getEnvironmentId() }, { severity: loggerSeverity, maxLogMessages, logToConsole });
communication.registerAPI({ id: WindowInitializerService.apiId }, new WindowInitializerService());
const loggerService = new LoggerService(loggerTransports, { environment: communication.getEnvironmentId() }, { severity: loggerSeverity, maxLogMessages, logToConsole });
onDispose(() => communication.dispose());

@@ -69,0 +66,0 @@ return {

@@ -1,8 +0,5 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Config = void 0;
const symbols_js_1 = require("../symbols.js");
const env_js_1 = require("./env.js");
const input_js_1 = require("./input.js");
class Config extends input_js_1.FeatureInput {
import { CONFIGURABLE, CREATE_RUNTIME, REGISTER_VALUE } from '../symbols.js';
import { AllEnvironments } from './env.js';
import { FeatureInput } from './input.js';
export class Config extends FeatureInput {
defaultValue;

@@ -17,9 +14,9 @@ mergeConfig;

}
[symbols_js_1.CONFIGURABLE] = true;
constructor(defaultValue, mergeConfig = (a, b) => ({ ...a, ...b }), visibleAt = env_js_1.AllEnvironments) {
super(env_js_1.AllEnvironments, visibleAt);
[CONFIGURABLE] = true;
constructor(defaultValue, mergeConfig = (a, b) => ({ ...a, ...b }), visibleAt = AllEnvironments) {
super(AllEnvironments, visibleAt);
this.defaultValue = defaultValue;
this.mergeConfig = mergeConfig;
}
[symbols_js_1.CREATE_RUNTIME](context, featureID, entityKey) {
[CREATE_RUNTIME](context, featureID, entityKey) {
const topConfig = context.getTopLevelConfig(featureID, entityKey);

@@ -30,7 +27,6 @@ return topConfig.reduce((current, next) => {

}
[symbols_js_1.REGISTER_VALUE](_context, _providedValue, inputValue, _featureID, _entityKey) {
[REGISTER_VALUE](_context, _providedValue, inputValue, _featureID, _entityKey) {
return inputValue;
}
}
exports.Config = Config;
//# sourceMappingURL=config.js.map

@@ -1,8 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ContextualEnvironment = exports.globallyProvidingEnvironments = exports.AllEnvironments = exports.Universal = exports.EnvironmentContext = exports.Environment = void 0;
exports.orderedEnvDependencies = orderedEnvDependencies;
exports.normEnvVisibility = normEnvVisibility;
const entity_helpers_js_1 = require("../entity-helpers.js");
class Environment {
import { runtimeType } from '../entity-helpers.js';
export class Environment {
env;

@@ -19,4 +14,3 @@ envType;

}
exports.Environment = Environment;
class EnvironmentContext {
export class EnvironmentContext {
env;

@@ -29,10 +23,9 @@ activeEnvironmentName;

}
exports.EnvironmentContext = EnvironmentContext;
exports.Universal = new Environment('<Universal>', 'window', 'multi');
exports.AllEnvironments = new Environment('<All>', 'window', 'multi');
exports.globallyProvidingEnvironments = new Set([exports.Universal.env, exports.AllEnvironments.env]);
function orderedEnvDependencies(env) {
export const Universal = new Environment('<Universal>', 'window', 'multi');
export const AllEnvironments = new Environment('<All>', 'window', 'multi');
export const globallyProvidingEnvironments = new Set([Universal.env, AllEnvironments.env]);
export function orderedEnvDependencies(env) {
return env.dependencies?.flatMap(orderedEnvDependencies).concat(env.env) ?? [];
}
class ContextualEnvironment extends Environment {
export class ContextualEnvironment extends Environment {
environments;

@@ -51,3 +44,3 @@ constructor(env, mode, environments) {

return {
type: (0, entity_helpers_js_1.runtimeType)(this.env + ' context'),
type: runtimeType(this.env + ' context'),
};

@@ -59,4 +52,3 @@ }

}
exports.ContextualEnvironment = ContextualEnvironment;
function normEnvVisibility(envVisibility, includeDependencies = true) {
export function normEnvVisibility(envVisibility, includeDependencies = true) {
const envSet = new Set();

@@ -63,0 +55,0 @@ const extractDependencies = (env) => {

@@ -1,12 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setup = exports.Feature = void 0;
exports.createRuntimeInfo = createRuntimeInfo;
exports.provideConfig = provideConfig;
exports.setupContext = setupContext;
exports.validateNoDuplicateEnvRegistration = validateNoDuplicateEnvRegistration;
exports.instantiateFeature = instantiateFeature;
exports.validateNoDuplicateContextRegistration = validateNoDuplicateContextRegistration;
const patterns_1 = require("@wixc3/patterns");
const symbols_js_1 = require("../symbols.js");
import { SetMultiMap } from '@wixc3/patterns';
import { ENGINE, IDENTIFY_API, RUN_OPTIONS } from '../symbols.js';
// this makes the constructor kind of private

@@ -29,3 +20,3 @@ const instantiateFeatureSymbol = Symbol('instantiateFeature');

*/
class Feature {
export class Feature {
id = '';

@@ -60,3 +51,3 @@ api = {};

static setup(environment, setupHandler) {
return (0, exports.setup)(this, environment, setupHandler);
return setup(this, environment, setupHandler);
}

@@ -67,6 +58,5 @@ static setupContext(environment, context, setupHandler) {

}
exports.Feature = Feature;
function createRuntimeInfo() {
export function createRuntimeInfo() {
return {
setups: new patterns_1.SetMultiMap(),
setups: new SetMultiMap(),
contexts: new Map(),

@@ -76,6 +66,6 @@ envs: new Set(),

}
function provideConfig(feature, config) {
export function provideConfig(feature, config) {
return [feature.id, config];
}
const setup = (feature, environment, setupHandler) => {
export const setup = (feature, environment, setupHandler) => {
const info = (feature.runtimeInfo ||= createRuntimeInfo());

@@ -86,4 +76,3 @@ validateNoDuplicateEnvRegistration(environment, feature.id, info.envs);

};
exports.setup = setup;
function setupContext(feature, _environment, // TODO: add handlers in environments buckets with validation per environment?
export function setupContext(feature, _environment, // TODO: add handlers in environments buckets with validation per environment?
environmentContextKey, contextHandler) {

@@ -95,3 +84,3 @@ const info = (feature.runtimeInfo ||= createRuntimeInfo());

}
function validateNoDuplicateEnvRegistration(env, featureId, registered) {
export function validateNoDuplicateEnvRegistration(env, featureId, registered) {
const hasCollision = testEnvironmentCollision(env, registered);

@@ -106,3 +95,3 @@ if (hasCollision.length) {

*/
function instantiateFeature(FeatureClass) {
export function instantiateFeature(FeatureClass) {
const Class = FeatureClass;

@@ -118,3 +107,3 @@ if (Class.instance) {

for (const [key, api] of Object.entries(feature.api)) {
const entityFn = api[symbols_js_1.IDENTIFY_API];
const entityFn = api[IDENTIFY_API];
if (entityFn) {

@@ -144,3 +133,3 @@ entityFn.call(api, feature.id, key);

}
function validateNoDuplicateContextRegistration(environmentContext, featureId, contextHandlers) {
export function validateNoDuplicateContextRegistration(environmentContext, featureId, contextHandlers) {
const registeredContext = contextHandlers.get(environmentContext);

@@ -147,0 +136,0 @@ if (registeredContext) {

@@ -1,27 +0,11 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./config.js"), exports);
__exportStar(require("./env.js"), exports);
__exportStar(require("./input.js"), exports);
__exportStar(require("./map-slot.js"), exports);
__exportStar(require("./ordered-slot.js"), exports);
__exportStar(require("./output.js"), exports);
__exportStar(require("./service.js"), exports);
__exportStar(require("./slot.js"), exports);
__exportStar(require("./feature.js"), exports);
__exportStar(require("./value.js"), exports);
export * from './config.js';
export * from './env.js';
export * from './input.js';
export * from './map-slot.js';
export * from './ordered-slot.js';
export * from './output.js';
export * from './service.js';
export * from './slot.js';
export * from './feature.js';
export * from './value.js';
//# sourceMappingURL=index.js.map

@@ -1,12 +0,9 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FeatureInput = void 0;
const entity_helpers_js_1 = require("../entity-helpers.js");
const symbols_js_1 = require("../symbols.js");
class FeatureInput {
import { runtimeType } from '../entity-helpers.js';
import { CREATE_RUNTIME, REGISTER_VALUE } from '../symbols.js';
export class FeatureInput {
providedFrom;
visibleAt;
mode = 'input';
type = (0, entity_helpers_js_1.runtimeType)();
proxyType = (0, entity_helpers_js_1.runtimeType)();
type = runtimeType();
proxyType = runtimeType();
remoteAccess = false;

@@ -17,7 +14,6 @@ constructor(providedFrom, visibleAt) {

}
[symbols_js_1.REGISTER_VALUE](_context, _providedValue, inputValue, _featureID, _entityKey) {
[REGISTER_VALUE](_context, _providedValue, inputValue, _featureID, _entityKey) {
return inputValue;
}
}
exports.FeatureInput = FeatureInput;
//# sourceMappingURL=input.js.map

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MapSlot = exports.MapRegistry = void 0;
const symbols_js_1 = require("../symbols.js");
const input_js_1 = require("./input.js");
class MapRegistry {
import { CREATE_RUNTIME } from '../symbols.js';
import { FeatureInput } from './input.js';
export class MapRegistry {
items = new Map();

@@ -41,4 +38,3 @@ callbacks = new Set();

}
exports.MapRegistry = MapRegistry;
class MapSlot extends input_js_1.FeatureInput {
export class MapSlot extends FeatureInput {
static withType() {

@@ -51,7 +47,6 @@ return {

}
[symbols_js_1.CREATE_RUNTIME]() {
[CREATE_RUNTIME]() {
return new MapRegistry();
}
}
exports.MapSlot = MapSlot;
//# sourceMappingURL=map-slot.js.map

@@ -1,6 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.OrderedSlot = exports.OrderedRegistry = void 0;
const symbols_js_1 = require("../symbols.js");
const input_js_1 = require("./input.js");
import { CREATE_RUNTIME } from '../symbols.js';
import { FeatureInput } from './input.js';
function getItemOrder(sortingOrder, item) {

@@ -39,3 +36,3 @@ const index = sortingOrder.indexOf(item);

}
class OrderedRegistry {
export class OrderedRegistry {
items = [];

@@ -81,4 +78,3 @@ callbacks = new Set();

}
exports.OrderedRegistry = OrderedRegistry;
class OrderedSlot extends input_js_1.FeatureInput {
export class OrderedSlot extends FeatureInput {
static withType() {

@@ -91,7 +87,6 @@ return {

}
[symbols_js_1.CREATE_RUNTIME]() {
[CREATE_RUNTIME]() {
return new OrderedRegistry();
}
}
exports.OrderedSlot = OrderedSlot;
//# sourceMappingURL=ordered-slot.js.map

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FeatureOutput = void 0;
const entity_helpers_js_1 = require("../entity-helpers.js");
const symbols_js_1 = require("../symbols.js");
class FeatureOutput {
import { runtimeType } from '../entity-helpers.js';
import { CREATE_RUNTIME, REGISTER_VALUE } from '../symbols.js';
export class FeatureOutput {
providedFrom;

@@ -11,4 +8,4 @@ visibleAt;

mode = 'output';
type = (0, entity_helpers_js_1.runtimeType)();
proxyType = (0, entity_helpers_js_1.runtimeType)();
type = runtimeType();
proxyType = runtimeType();
constructor(providedFrom, visibleAt, remoteAccess) {

@@ -20,3 +17,2 @@ this.providedFrom = providedFrom;

}
exports.FeatureOutput = FeatureOutput;
//# sourceMappingURL=output.js.map

@@ -1,12 +0,6 @@

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Service = void 0;
const communication_feature_js_1 = __importDefault(require("../communication.feature.js"));
const symbols_js_1 = require("../symbols.js");
const env_js_1 = require("./env.js");
const output_js_1 = require("./output.js");
class Service extends output_js_1.FeatureOutput {
import COM from '../communication.feature.js';
import { CREATE_RUNTIME, REGISTER_VALUE } from '../symbols.js';
import { AllEnvironments, normEnvVisibility, Universal } from './env.js';
import { FeatureOutput } from './output.js';
export class Service extends FeatureOutput {
providedFrom;

@@ -31,10 +25,10 @@ visibleAt;

allowRemoteAccess(options) {
return new Service(this.providedFrom, env_js_1.AllEnvironments, true, options);
return new Service(this.providedFrom, AllEnvironments, true, options);
}
[symbols_js_1.REGISTER_VALUE](runtimeEngine, providedValue, inputValue, featureID, entityKey) {
[REGISTER_VALUE](runtimeEngine, providedValue, inputValue, featureID, entityKey) {
if (this.remoteAccess) {
const { communication } = runtimeEngine.get(communication_feature_js_1.default).api;
const { communication } = runtimeEngine.get(COM).api;
const serviceKey = runtimeEngine.entityID(featureID, entityKey);
const providedFrom = (0, env_js_1.normEnvVisibility)(this.providedFrom, false);
const shouldIncludeService = providedFrom.has(env_js_1.Universal.env) || hasIntersection(providedFrom, runtimeEngine.runningEnvNames);
const providedFrom = normEnvVisibility(this.providedFrom, false);
const shouldIncludeService = providedFrom.has(Universal.env) || hasIntersection(providedFrom, runtimeEngine.runningEnvNames);
if (shouldIncludeService) {

@@ -56,3 +50,3 @@ if (!providedValue) {

}
[symbols_js_1.CREATE_RUNTIME](context, featureID, entityKey) {
[CREATE_RUNTIME](context, featureID, entityKey) {
if (this.remoteAccess) {

@@ -63,3 +57,3 @@ return this.getApiProxy(context, context.entityID(featureID, entityKey));

getApiProxy(context, serviceKey) {
const { communication } = context.get(communication_feature_js_1.default).api;
const { communication } = context.get(COM).api;
const instanceId = getSingleInstanceId(this.providedFrom);

@@ -78,3 +72,2 @@ if (instanceId) {

}
exports.Service = Service;
function getSingleInstanceId(providedFrom) {

@@ -81,0 +74,0 @@ if (isSingleInstance(providedFrom)) {

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Slot = exports.Registry = void 0;
const symbols_js_1 = require("../symbols.js");
const input_js_1 = require("./input.js");
class Registry {
import { CREATE_RUNTIME } from '../symbols.js';
import { FeatureInput } from './input.js';
export class Registry {
items = [];

@@ -35,3 +32,2 @@ callbacks = new Set();

}
exports.Registry = Registry;
/**

@@ -43,3 +39,3 @@ * Set of user typed values, consumed at any flow that requires this feature.

*/
class Slot extends input_js_1.FeatureInput {
export class Slot extends FeatureInput {
/**

@@ -59,7 +55,6 @@ * Provides the actual interface of each unit of the slot

}
[symbols_js_1.CREATE_RUNTIME]() {
[CREATE_RUNTIME]() {
return new Registry();
}
}
exports.Slot = Slot;
//# sourceMappingURL=slot.js.map

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Value = void 0;
const symbols_js_1 = require("../symbols.js");
const output_js_1 = require("./output.js");
class Value extends output_js_1.FeatureOutput {
import { CREATE_RUNTIME, REGISTER_VALUE } from '../symbols.js';
import { FeatureOutput } from './output.js';
export class Value extends FeatureOutput {
providedFrom;

@@ -19,10 +16,9 @@ static withType() {

}
[symbols_js_1.REGISTER_VALUE](_, providedValue) {
[REGISTER_VALUE](_, providedValue) {
return providedValue;
}
[symbols_js_1.CREATE_RUNTIME]() {
[CREATE_RUNTIME]() {
return;
}
}
exports.Value = Value;
//# sourceMappingURL=value.js.map

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.runtimeType = runtimeType;
/**
* Just a Symbol that is used as any type T at runtime.
*/
function runtimeType(name) {
export function runtimeType(name) {
return Symbol(name);
}
//# sourceMappingURL=entity-helpers.js.map

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.errorToJson = errorToJson;
/**

@@ -10,3 +7,3 @@ * Converts a caught exception into a plain error-like object. The result is

*/
function errorToJson(error) {
export function errorToJson(error) {
try {

@@ -13,0 +10,0 @@ if (!(error instanceof Error)) {

@@ -1,8 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.returnsTrue = void 0;
exports.flattenTree = flattenTree;
const returnsTrue = () => true;
exports.returnsTrue = returnsTrue;
function flattenTree(root, children, predicate = exports.returnsTrue) {
export const returnsTrue = () => true;
export function flattenTree(root, children, predicate = returnsTrue) {
const results = new Set();

@@ -9,0 +4,0 @@ const visited = new Set();

@@ -1,20 +0,4 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./flatten-tree.js"), exports);
__exportStar(require("./web.js"), exports);
__exportStar(require("./error-to-json.js"), exports);
export * from './flatten-tree.js';
export * from './web.js';
export * from './error-to-json.js';
//# sourceMappingURL=index.js.map

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

import { IRunOptions } from '../types';
import type { IRunOptions } from '../types.js';
export declare function injectScript(win: Window, rootComId: string, scriptUrl: string): Promise<Window>;

@@ -3,0 +3,0 @@ interface EngineWebEntryGlobalObj {

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.injectScript = injectScript;
exports.getEngineEntryOptions = getEngineEntryOptions;
function injectScript(win, rootComId, scriptUrl) {
export function injectScript(win, rootComId, scriptUrl) {
return new Promise((res, rej) => {

@@ -17,3 +13,3 @@ // This is the contract of the communication to get the root communication id

}
function getEngineEntryOptions(envName, globalObj) {
export function getEngineEntryOptions(envName, globalObj) {
const urlParams = new URLSearchParams(globalObj?.location?.search);

@@ -20,0 +16,0 @@ const currentScript = globalObj?.document?.currentScript;

@@ -1,36 +0,16 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.COM = void 0;
__exportStar(require("./com/index.js"), exports);
__exportStar(require("./helpers/index.js"), exports);
__exportStar(require("./entities/index.js"), exports);
__exportStar(require("./common-types.js"), exports);
__exportStar(require("./entity-helpers.js"), exports);
__exportStar(require("./run-engine-app.js"), exports);
__exportStar(require("./runtime-engine.js"), exports);
__exportStar(require("./runtime-feature.js"), exports);
__exportStar(require("./symbols.js"), exports);
__exportStar(require("./types.js"), exports);
__exportStar(require("./communication.feature.js"), exports);
__exportStar(require("./runtime-main.js"), exports);
__exportStar(require("./runtime-configurations.js"), exports);
const communication_feature_js_1 = __importDefault(require("./communication.feature.js"));
exports.COM = communication_feature_js_1.default;
export * from './com/index.js';
export * from './helpers/index.js';
export * from './entities/index.js';
export * from './common-types.js';
export * from './entity-helpers.js';
export * from './run-engine-app.js';
export * from './runtime-engine.js';
export * from './runtime-feature.js';
export * from './symbols.js';
export * from './types.js';
export * from './communication.feature.js';
export * from './runtime-main.js';
export * from './runtime-configurations.js';
import COM from './communication.feature.js';
export { COM };
//# sourceMappingURL=index.js.map

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const com_1 = require("../com");
import { reportError } from '../com/index.js';
/**

@@ -13,4 +11,4 @@ * This polyfill is not essential for the engine itself. But applications built

if (globalThis.reportError === undefined) {
globalThis.reportError = com_1.reportError;
globalThis.reportError = reportError;
}
//# sourceMappingURL=report-error-polyfill.js.map

@@ -1,15 +0,11 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FeatureLoadersRegistry = void 0;
exports.run = run;
/**
* Extends globalThis.Worker with a polyfill for web workers in safari.
*/
require("@wixc3/isomorphic-worker/worker");
const runtime_engine_js_1 = require("./runtime-engine.js");
const promise_assist_1 = require("promise-assist");
function run({ entryFeature, topLevelConfig = [], env, runOptions, }) {
return new runtime_engine_js_1.RuntimeEngine(env, topLevelConfig, runOptions).run(entryFeature);
import '@wixc3/isomorphic-worker/worker';
import { RuntimeEngine } from './runtime-engine.js';
import { deferred } from 'promise-assist';
export function run({ entryFeature, topLevelConfig = [], env, runOptions, }) {
return new RuntimeEngine(env, topLevelConfig, runOptions).run(entryFeature);
}
class FeatureLoadersRegistry {
export class FeatureLoadersRegistry {
featureMapping;

@@ -33,3 +29,3 @@ pendingLoaderRequests = new Map();

if (!loaderPromise) {
loaderPromise = (0, promise_assist_1.deferred)();
loaderPromise = deferred();
this.pendingLoaderRequests.set(featureName, loaderPromise);

@@ -106,3 +102,2 @@ }

}
exports.FeatureLoadersRegistry = FeatureLoadersRegistry;
function cjsEsmInterop(featureClass) {

@@ -109,0 +104,0 @@ return featureClass.__esModule ? featureClass.default : featureClass;

@@ -1,9 +0,5 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RuntimeConfigurations = void 0;
exports.parseInjectRuntimeConfigConfig = parseInjectRuntimeConfigConfig;
/**
* Manage for the runtime configurations loading flow
*/
class RuntimeConfigurations {
export class RuntimeConfigurations {
envName;

@@ -129,7 +125,6 @@ publicConfigsRoute;

}
exports.RuntimeConfigurations = RuntimeConfigurations;
function addTrailingSlashIfNotEmpty(route) {
return route ? (route.endsWith('/') ? route : route + '/') : '';
}
function parseInjectRuntimeConfigConfig(options) {
export function parseInjectRuntimeConfigConfig(options) {
const rawConfigOption = options.get('topLevelConfig');

@@ -136,0 +131,0 @@ if (typeof rawConfigOption === 'string') {

@@ -1,9 +0,6 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RuntimeEngine = void 0;
const promise_assist_1 = require("promise-assist");
const index_js_1 = require("./entities/index.js");
const runtime_feature_js_1 = require("./runtime-feature.js");
const symbols_js_1 = require("./symbols.js");
class RuntimeEngine {
import { timeout } from 'promise-assist';
import { globallyProvidingEnvironments, normEnvVisibility, orderedEnvDependencies, } from './entities/index.js';
import { createFeatureRuntime } from './runtime-feature.js';
import { RUN } from './symbols.js';
export class RuntimeEngine {
entryEnvironment;

@@ -25,4 +22,4 @@ runOptions;

this.topLevelConfigMap = this.createConfigMap(topLevelConfig);
this.referencedEnvs = new Set([...index_js_1.globallyProvidingEnvironments, ...(0, index_js_1.orderedEnvDependencies)(entryEnvironment)]);
this.runningEnvNames = (0, index_js_1.normEnvVisibility)(entryEnvironment);
this.referencedEnvs = new Set([...globallyProvidingEnvironments, ...orderedEnvDependencies(entryEnvironment)]);
this.runningEnvNames = normEnvVisibility(entryEnvironment);
}

@@ -71,3 +68,3 @@ get(feature) {

if (!instance) {
instance = (0, runtime_feature_js_1.createFeatureRuntime)(feature, this);
instance = createFeatureRuntime(feature, this);
}

@@ -87,3 +84,3 @@ return instance;

try {
await featureInstance[symbols_js_1.RUN](this);
await featureInstance[RUN](this);
}

@@ -115,3 +112,3 @@ finally {

try {
await (0, promise_assist_1.timeout)(feature.dispose(), this.featureShutdownTimeout, `Failed to dispose feature: ${feature.feature.id}`);
await timeout(feature.dispose(), this.featureShutdownTimeout, `Failed to dispose feature: ${feature.feature.id}`);
}

@@ -145,3 +142,2 @@ finally {

}
exports.RuntimeEngine = RuntimeEngine;
//# sourceMappingURL=runtime-engine.js.map

@@ -1,12 +0,8 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RuntimeFeature = void 0;
exports.createFeatureRuntime = createFeatureRuntime;
const feature_js_1 = require("./entities/feature.js");
const symbols_js_1 = require("./symbols.js");
const patterns_1 = require("@wixc3/patterns");
import { instantiateFeature, } from './entities/feature.js';
import { CREATE_RUNTIME, ENGINE, REGISTER_VALUE, RUN, RUN_OPTIONS } from './symbols.js';
import { SafeDisposable, SetMultiMap } from '@wixc3/patterns';
/**
* Represents a currently running feature instance.
**/
class RuntimeFeature {
export class RuntimeFeature {
feature;

@@ -16,8 +12,8 @@ api;

environment;
disposables = new patterns_1.SafeDisposable(RuntimeFeature.name);
disposables = new SafeDisposable(RuntimeFeature.name);
dispose = this.disposables.dispose;
isDisposed = this.disposables.isDisposed;
running = false;
runHandlers = new patterns_1.SetMultiMap();
disposeHandlers = new patterns_1.SetMultiMap();
runHandlers = new SetMultiMap();
disposeHandlers = new SetMultiMap();
constructor(feature, api, dependencies, environment) {

@@ -45,3 +41,3 @@ this.feature = feature;

};
async [symbols_js_1.RUN](engine) {
async [RUN](engine) {
if (this.running) {

@@ -66,6 +62,5 @@ return;

}
exports.RuntimeFeature = RuntimeFeature;
function createFeatureRuntime(FeatureClass, runningEngine) {
export function createFeatureRuntime(FeatureClass, runningEngine) {
const { features, runOptions, referencedEnvs, entryEnvironment } = runningEngine;
const feature = (0, feature_js_1.instantiateFeature)(FeatureClass);
const feature = instantiateFeature(FeatureClass);
const deps = {};

@@ -88,3 +83,3 @@ const depsApis = {};

for (const [key, entity] of apiEntries) {
const provided = entity[symbols_js_1.CREATE_RUNTIME](runningEngine, feature.id, key);
const provided = entity[CREATE_RUNTIME](runningEngine, feature.id, key);
if (provided !== undefined) {

@@ -100,4 +95,4 @@ inputApi[key] = provided;

engineShutdownSignal: runningEngine.shutdownSignal,
[symbols_js_1.RUN_OPTIONS]: runOptions,
[symbols_js_1.ENGINE]: runningEngine,
[RUN_OPTIONS]: runOptions,
[ENGINE]: runningEngine,
};

@@ -131,3 +126,3 @@ if (contextHandlers) {

for (const [key, entity] of apiEntries) {
const registered = entity[symbols_js_1.REGISTER_VALUE](runningEngine, providedApi[key], inputApi[key], feature.id, key);
const registered = entity[REGISTER_VALUE](runningEngine, providedApi[key], inputApi[key], feature.id, key);
if (registered !== undefined) {

@@ -134,0 +129,0 @@ runningApi[key] = registered;

@@ -1,9 +0,6 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.main = main;
require("./polyfills/report-error-polyfill.js");
const run_engine_app_js_1 = require("./run-engine-app.js");
const runtime_configurations_js_1 = require("./runtime-configurations.js");
const runtime_engine_js_1 = require("./runtime-engine.js");
const index_js_1 = require("./com/index.js");
import './polyfills/report-error-polyfill.js';
import { FeatureLoadersRegistry } from './run-engine-app.js';
import { RuntimeConfigurations } from './runtime-configurations.js';
import { RuntimeEngine } from './runtime-engine.js';
import { INSTANCE_ID_PARAM_NAME } from './com/index.js';
/**

@@ -13,9 +10,9 @@ * main engine environment entry point flow

*/
async function main({ env, contextualConfig, publicConfigsRoute, featureLoaders, configLoaders, featureName, configName, options, }) {
const runtimeConfiguration = new runtime_configurations_js_1.RuntimeConfigurations(env.env, publicConfigsRoute, configLoaders, options);
const featureLoader = new run_engine_app_js_1.FeatureLoadersRegistry(featureLoaders);
export async function main({ env, contextualConfig, publicConfigsRoute, featureLoaders, configLoaders, featureName, configName, options, }) {
const runtimeConfiguration = new RuntimeConfigurations(env.env, publicConfigsRoute, configLoaders, options);
const featureLoader = new FeatureLoadersRegistry(featureLoaders);
runtimeConfiguration.installChildEnvConfigFetcher(featureName, configName);
featureName = String(options.get('feature') || featureName);
configName = String(options.get('config') || configName);
const instanceId = options.get(index_js_1.INSTANCE_ID_PARAM_NAME);
const instanceId = options.get(INSTANCE_ID_PARAM_NAME);
if (typeof instanceId === 'string' && typeof self !== 'undefined') {

@@ -30,4 +27,4 @@ self.name = instanceId;

const { entryFeature, resolvedContexts } = await featureLoader.loadEntryFeature(featureName, {});
return new runtime_engine_js_1.RuntimeEngine(env, [...buildConfig, ...contextualConfig({ resolvedContexts }), ...runtimeConfig], options).run(entryFeature);
return new RuntimeEngine(env, [...buildConfig, ...contextualConfig({ resolvedContexts }), ...runtimeConfig], options).run(entryFeature);
}
//# sourceMappingURL=runtime-main.js.map

@@ -1,12 +0,9 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CONFIGURABLE = exports.ENGINE = exports.RUN_OPTIONS = exports.SERVICE_CONFIG = exports.REGISTER_VALUE = exports.CREATE_RUNTIME = exports.IDENTIFY_API = exports.RUN = void 0;
exports.RUN = Symbol.for('__ENGINE__RUN');
exports.IDENTIFY_API = Symbol.for('__ENGINE__IDENTIFY_API');
exports.CREATE_RUNTIME = Symbol.for('__ENGINE__CREATE');
exports.REGISTER_VALUE = Symbol.for('__ENGINE__REGISTER_VALUE');
exports.SERVICE_CONFIG = Symbol.for('__ENGINE__SERVICE_CONFIG');
exports.RUN_OPTIONS = Symbol.for('__ENGINE__RUN_OPTIONS');
exports.ENGINE = Symbol.for('__RUNTIME_ENGINE__');
exports.CONFIGURABLE = Symbol.for('__ENGINE__CONFIGURABLE');
export const RUN = Symbol.for('__ENGINE__RUN');
export const IDENTIFY_API = Symbol.for('__ENGINE__IDENTIFY_API');
export const CREATE_RUNTIME = Symbol.for('__ENGINE__CREATE');
export const REGISTER_VALUE = Symbol.for('__ENGINE__REGISTER_VALUE');
export const SERVICE_CONFIG = Symbol.for('__ENGINE__SERVICE_CONFIG');
export const RUN_OPTIONS = Symbol.for('__ENGINE__RUN_OPTIONS');
export const ENGINE = Symbol.for('__RUNTIME_ENGINE__');
export const CONFIGURABLE = Symbol.for('__ENGINE__CONFIGURABLE');
//# sourceMappingURL=symbols.js.map

@@ -1,6 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LogLevel = void 0;
const symbols_js_1 = require("./symbols.js");
var LogLevel;
import { CONFIGURABLE, CREATE_RUNTIME, IDENTIFY_API, REGISTER_VALUE } from './symbols.js';
export var LogLevel;
(function (LogLevel) {

@@ -11,3 +8,3 @@ LogLevel[LogLevel["DEBUG"] = 0] = "DEBUG";

LogLevel[LogLevel["ERROR"] = 3] = "ERROR";
})(LogLevel || (exports.LogLevel = LogLevel = {}));
})(LogLevel || (LogLevel = {}));
//# sourceMappingURL=types.js.map
{
"name": "@wixc3/engine-core",
"version": "48.0.0",
"version": "49.0.0",
"type": "module",
"main": "dist/index.js",

@@ -5,0 +6,0 @@ "exports": {

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

import type { Message } from './message-types';
import { redactArguments } from './helpers';
import type { Message } from './message-types.js';
import { redactArguments } from './helpers.js';

@@ -4,0 +4,0 @@ export class EngineCommunicationError extends Error {

@@ -58,3 +58,3 @@ import { isDisposable, SetMultiMap } from '@wixc3/patterns';

UnknownCallbackIdError,
} from './communication-errors';
} from './communication-errors.js';

@@ -61,0 +61,0 @@ export interface ConfigEnvironmentRecord extends EnvironmentRecord {

// we cannot mix types of "dom" and "webworker". tsc fails building.
declare let WorkerGlobalScope: new () => Worker;
import { Message } from './message-types';
import { Message } from './message-types.js';

@@ -6,0 +6,0 @@ export function isWorkerContext(target: unknown): target is Worker {

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

import { IRunOptions } from '../types';
import type { IRunOptions } from '../types.js';

@@ -3,0 +3,0 @@ export function injectScript(win: Window, rootComId: string, scriptUrl: string) {

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

import { reportError } from '../com';
import { reportError } from '../com/index.js';

@@ -3,0 +3,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

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

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

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

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

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