- Modified:
  - cli.runNopeBackend: added the flag "noBaseServices" to prevent providing the base-services
  - communication.getLayer.nodejs/browser: adding default value for logger
  - dispatcher.getDispatcher: changed option "constructorClass" to "dispatcherConstructorClass"
  - helpers.limit.spec: Adapted Timings
  - loader.getPackageLoader.nodejs/browser: Changed the options.
This commit is contained in:
Martin Karkowski 2022-04-08 08:10:39 +02:00
parent ee1d690dc8
commit 4791914998
10 changed files with 97 additions and 45 deletions

View File

@ -44,5 +44,13 @@ Inital commit, which is working with the browser
# 1.0.32 # 1.0.32
- Fixes: - Fixes:
- helpers.singleton: work with `Symbol.for` - helpers.singleton: work with `Symbol.for` --> Can be used in different systems now.
- symbols.symbols: work with `Symbol.for` - symbols.symbols: work with `Symbol.for` --> Can be used in different systems now.
# 1.0.33
- Modified:
- cli.runNopeBackend: added the flag "noBaseServices" to prevent providing the base-services
- communication.getLayer.nodejs/browser: adding default value for logger
- dispatcher.getDispatcher: changed option "constructorClass" to "dispatcherConstructorClass"
- helpers.limit.spec: Adapted Timings
- loader.getPackageLoader.nodejs/browser: Changed the options.

View File

@ -1 +1 @@
1.0.32 1.0.33

View File

@ -57,12 +57,12 @@ export interface RunArgs {
forceUsingSelectors: boolean; forceUsingSelectors: boolean;
// Define the Timingsparameter // Define the Timingsparameter
timings: Partial<INopeINopeConnectivityTimeOptions>; timings: Partial<INopeINopeConnectivityTimeOptions>;
// Forces the Selectors
forceSelectors: boolean;
// The Id to use. // The Id to use.
id: string; id: string;
// Flag to enable profiling. Defaults to false. // Flag to enable profiling. Defaults to false.
profile: boolean; profile: boolean;
// Flag to controll whether base-services should be loaded or not.
useBaseServices: boolean;
} }
export const DEFAULT_SETTINGS: RunArgs = { export const DEFAULT_SETTINGS: RunArgs = {
@ -75,13 +75,13 @@ export const DEFAULT_SETTINGS: RunArgs = {
dispatcherLogLevel: "info", dispatcherLogLevel: "info",
communicationLogLevel: "info", communicationLogLevel: "info",
delay: 2, delay: 2,
forceSelectors: false,
timings: {}, timings: {},
defaultSelector: "first", defaultSelector: "first",
forceUsingSelectors: false, forceUsingSelectors: false,
logToFile: false, logToFile: false,
id: generateId(), id: generateId(),
profile: false, profile: false,
useBaseServices: false,
}; };
/** /**
@ -225,6 +225,13 @@ export async function readInArgs(
dest: "profile", dest: "profile",
}); });
parser.add_argument("--noBaseServices", {
help: "Flag to enable prevent the base Services to be loaded",
action: "append",
nargs: "?",
dest: "useBaseServices",
});
const args: RunArgs = parser.parse_args(); const args: RunArgs = parser.parse_args();
if (args.params === "not-provided") { if (args.params === "not-provided") {
@ -235,6 +242,7 @@ export async function readInArgs(
args.profile = Array.isArray(args.profile); args.profile = Array.isArray(args.profile);
args.logToFile = Array.isArray(args.logToFile); args.logToFile = Array.isArray(args.logToFile);
args.forceUsingSelectors = Array.isArray(args.forceUsingSelectors); args.forceUsingSelectors = Array.isArray(args.forceUsingSelectors);
args.useBaseServices = !Array.isArray(args.useBaseServices);
return Object.assign(args, forcedArgs); return Object.assign(args, forcedArgs);
} }
@ -403,7 +411,10 @@ export async function runNopeBackend(
forceUsingSelectors: args.forceUsingSelectors, forceUsingSelectors: args.forceUsingSelectors,
id: args.id, id: args.id,
}, },
_args.singleton {
singleton: _args.singleton,
useBaseServices: _args.useBaseServices,
}
); );
// Add the Dispatcher // Add the Dispatcher

View File

@ -35,13 +35,13 @@ export const layerDefaultParameters = {
* @export * @export
* @param {validLayerOrMirror} layer the layer to add * @param {validLayerOrMirror} layer the layer to add
* @param {(number | string)} [parameter=null] the parameter required for the additonal layer / mirror * @param {(number | string)} [parameter=null] the parameter required for the additonal layer / mirror
* @param {LoggerLevel} level the level of the debugger * @param {LoggerLevel} [level=false] the level of the debugger
* @return {*} {ICommunicationBridge} * @return {*} {ICommunicationBridge}
*/ */
export function getLayer( export function getLayer(
layer: validLayerOrMirror, layer: validLayerOrMirror,
parameter: number | string = null, parameter: number | string = null,
logger: ValidLoggerDefinition logger: ValidLoggerDefinition = false
): ICommunicationBridge { ): ICommunicationBridge {
// Create the Bridge // Create the Bridge
const communicationBridge = new Bridge(generateId(), logger); const communicationBridge = new Bridge(generateId(), logger);

View File

@ -44,13 +44,13 @@ export const layerDefaultParameters = {
* @export * @export
* @param {validLayerOrMirror} layer the layer to add * @param {validLayerOrMirror} layer the layer to add
* @param {(number | string)} [parameter=null] the parameter required for the additonal layer / mirror * @param {(number | string)} [parameter=null] the parameter required for the additonal layer / mirror
* @param {LoggerLevel} logger the level of the debugger * @param {LoggerLevel} [logger=false] the level of the debugger
* @return {*} {ICommunicationBridge} * @return {*} {ICommunicationBridge}
*/ */
export function getLayer( export function getLayer(
layer: validLayerOrMirror, layer: validLayerOrMirror,
parameter: number | string = null, parameter: number | string = null,
logger: ValidLoggerDefinition logger: ValidLoggerDefinition = false
): ICommunicationBridge { ): ICommunicationBridge {
// Create the Bridge // Create the Bridge
const communicationBridge = new Bridge(generateId(), logger); const communicationBridge = new Bridge(generateId(), logger);

View File

@ -1,9 +1,6 @@
/** /**
* @author Martin Karkowski * @author Martin Karkowski
* @email m.karkowski@zema.de * @email m.karkowski@zema.de
* @create date 2020-11-06 08:52:48
* @modify date 2022-01-10 14:17:09
* @desc [description]
*/ */
import { getSingleton } from "../helpers/singletonMethod"; import { getSingleton } from "../helpers/singletonMethod";
@ -18,26 +15,31 @@ import { addAllBaseServices } from "./baseServices";
import { NopeDispatcher } from "./nopeDispatcher"; import { NopeDispatcher } from "./nopeDispatcher";
/** /**
* Function to extract a Singleton Dispatcher *
* @param dispatcherOptions The provided options for the Dispatcher * @param {INopeDispatcherOptions} dispatcherOptions The options, that will be used for the dispathcer.
* @param options Additional Options. You can provide a different Dispatcher-Class; Controll the scope (Singleton or not.) and define wehter the Base-Services should be added.
* @returns {INopeDispatcher} The dispatcher.
* *
* ```typescript * ```typescript
* * // Create a communication layer:
* const communicator = getLayer("event");
* // Now create the Dispatcher.
* const dispatcher = getDispatcher({communicator});
* ``` * ```
*/ */
export function getDispatcher( export function getDispatcher(
dispatcherOptions: INopeDispatcherOptions, dispatcherOptions: INopeDispatcherOptions,
options: { options: {
constructorClass?: IDispatcherConstructor; dispatcherConstructorClass?: IDispatcherConstructor;
singleton?: boolean; singleton?: boolean;
useBaseServices?: boolean; useBaseServices?: boolean;
} = {} } = {}
): INopeDispatcher { ): INopeDispatcher {
if ( if (
options.constructorClass === null || options.dispatcherConstructorClass === null ||
options.constructorClass === undefined options.dispatcherConstructorClass === undefined
) { ) {
options.constructorClass = NopeDispatcher; options.dispatcherConstructorClass = NopeDispatcher;
} }
options = Object.assign( options = Object.assign(
@ -50,7 +52,7 @@ export function getDispatcher(
); );
const create = () => { const create = () => {
const dispatcher = new options.constructorClass( const dispatcher = new options.dispatcherConstructorClass(
dispatcherOptions, dispatcherOptions,
() => new NopeObservable() () => new NopeObservable()
); );

View File

@ -20,7 +20,7 @@ describe("limit", function () {
const promises = [f(100), f(100)]; const promises = [f(100), f(100)];
await Promise.all(promises); await Promise.all(promises);
const end = Date.now(); const end = Date.now();
if (end - start < 120) { if (end - start < 200) {
throw Error("Failed to call sync"); throw Error("Failed to call sync");
} }
}); });
@ -32,7 +32,7 @@ describe("limit", function () {
const promises = [f(100), f(100)]; const promises = [f(100), f(100)];
await Promise.all(promises); await Promise.all(promises);
const end = Date.now(); const end = Date.now();
if (end - start > 120) { if (end - start > 200) {
throw Error("Failed to call parallel"); throw Error("Failed to call parallel");
} }
}); });

View File

@ -5,6 +5,7 @@
import { getSingleton } from "../helpers/singletonMethod"; import { getSingleton } from "../helpers/singletonMethod";
import { import {
IDispatcherConstructor,
INopeDispatcherOptions, INopeDispatcherOptions,
INopePackageLoader, INopePackageLoader,
INopePackageLoaderConstructor, INopePackageLoaderConstructor,
@ -13,25 +14,46 @@ import { generateNopeBasicPackage } from "./generateNopeBasicPackage";
import { NopePackageLoader } from "./nopePackageLoader"; import { NopePackageLoader } from "./nopePackageLoader";
/** /**
* Function to extract a Singleton Dispatcher * Function to extract the Package-Loader.
* @param options The provided options for the Dispatcher * @param {INopeDispatcherOptions} dispatcherOptions The provided options for the Dispatcher
* @param options Settings for the creation of the Dispatcher etc.
* @returns {INopePackageLoader} The Package loader.
*/ */
export function getPackageLoader( export function getPackageLoader(
options: INopeDispatcherOptions, dispatcherOptions: INopeDispatcherOptions,
singleton = true, options: {
constructorClass: INopePackageLoaderConstructor = null packageLoaderConstructorClass?: INopePackageLoaderConstructor;
dispatcherConstructorClass?: IDispatcherConstructor;
singleton?: boolean;
useBaseServices?: boolean;
} = {}
): INopePackageLoader { ): INopePackageLoader {
if (constructorClass === null || constructorClass === undefined) { if (
constructorClass = NopePackageLoader; options.packageLoaderConstructorClass === null ||
options.packageLoaderConstructorClass === undefined
) {
options.packageLoaderConstructorClass = NopePackageLoader;
} }
options = Object.assign(
{
packageLoaderConstructorClass: null,
dispatcherConstructorClass: null,
singleton: true,
useBaseServices: true,
},
options
);
const create = () => { const create = () => {
// Create a loader // Create a loader
const loader = new constructorClass(); const loader = new options.packageLoaderConstructorClass();
// load the default Package: // load the default Package:
loader loader
.addPackage(generateNopeBasicPackage(options, singleton)) .addPackage(
generateNopeBasicPackage(dispatcherOptions, options.singleton)
)
.catch((e) => { .catch((e) => {
throw e; throw e;
}); });
@ -39,7 +61,7 @@ export function getPackageLoader(
return loader; return loader;
}; };
if (singleton) { if (options.singleton) {
// Create a singaleton if required. // Create a singaleton if required.
// use the container to receive the // use the container to receive the
// singleton object // singleton object

View File

@ -4,21 +4,30 @@
* @desc [description] * @desc [description]
*/ */
import { INopeDispatcherOptions } from "../types/nope/nopeDispatcher.interface"; import { INopePackageLoaderConstructor } from "../index.browser";
import {
IDispatcherConstructor,
INopeDispatcherOptions,
} from "../types/nope/nopeDispatcher.interface";
import { getPackageLoader as getBrowserPackageLoader } from "./getPackageLoader.browser"; import { getPackageLoader as getBrowserPackageLoader } from "./getPackageLoader.browser";
import { NopePackageLoaderFileAccess } from "./nopePackageLoader.nodejs"; import { NopePackageLoaderFileAccess } from "./nopePackageLoader.nodejs";
/** /**
* Function to extract a Singleton Dispatcher * Function to extract the Package-Loader. This one here includes file access.
* @param options The provided options for the Dispatcher * @param {INopeDispatcherOptions} dispatcherOptions The provided options for the Dispatcher
* @param options Settings for the creation of the Dispatcher etc.
* @returns {INopePackageLoader} The Package loader.
*/ */
export function getPackageLoader( export function getPackageLoader(
options: INopeDispatcherOptions, dispatcherOptions: INopeDispatcherOptions,
singleton = true options: {
packageLoaderConstructorClass?: INopePackageLoaderConstructor;
dispatcherConstructorClass?: IDispatcherConstructor;
singleton?: boolean;
useBaseServices?: boolean;
} = {}
) { ) {
return getBrowserPackageLoader( options.packageLoaderConstructorClass = NopePackageLoaderFileAccess;
options,
singleton, return getBrowserPackageLoader(dispatcherOptions, options);
NopePackageLoaderFileAccess
);
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "nope", "name": "nope",
"version": "1.0.31", "version": "1.0.33",
"description": "NoPE Runtime for Nodejs. For Browser-Support please use nope-browser", "description": "NoPE Runtime for Nodejs. For Browser-Support please use nope-browser",
"files": [ "files": [
"dist-nodejs/**/*", "dist-nodejs/**/*",