nope/lib/decorators/moduleDecorators.ts

89 lines
2.4 KiB
TypeScript
Raw Normal View History

2020-11-06 08:10:30 +00:00
/**
* @author Martin Karkowski
* @email m.karkowski@zema.de
*/
2022-01-26 12:03:03 +00:00
import { rgetattr, rsetattr } from "../helpers/objectMethods";
import {
2022-01-26 12:03:03 +00:00
IEventOptions,
IFunctionOptions,
INopeModule,
} from "../types/nope/nopeModule.interface";
# 1.2.0 - Added: - `lib/cli/nope` adding scan for ui service - `lib/decorators/container`: Main Container, holding all `methods` and `classes`. Use `getCentralDecoratedContainer()` to get this decorator. - `types/nope/nopePackage.interface` added `IClassDescription` which contains the class description used in the Package Description. - `logger/nopeLogger`: added methods: `enabledFor`, `enableFor`, `shouldLog` - `package.json`: installed types of `ace` text editor. - `ui/helpers.browser`: Created `convertInstanceRenderPage` and `IUiDefinition` - `ui/helpers.nodejs`: Added a Helper to write the Ui-File (`writeUiFile`) and parse its arguments (`readInwriteUiFileArgs`) - `ui/index.*`: Crated the corresponding exports. - Modified: - `lib/decorators/*` Adding the main `container` where every function, service method etc is added. All decorators now safe the decorated elements in the container. - `helpers/json`: Adding `BEGIN_STR` and `END_STR` for parsing functions as constants. - `logger/eventLogging`: simplify `useEventLogger` - `logger/index.browser`: Adating exports. - `loader/loadPackages`: Modifing `IPackageConfig` now extends Partial the `IPackageDescription` - `types/ui/editor/IEditPage`: adapting Type of `getData` to `T`->`any`. Adapting the return of `getPorts` (The Ports will be generated in the ui then) - `types/ui/editor/helpers.interface`: Adapting the `w2ui` and added `w2uiHelpers` and added `ace`. Rearanging `IRenderData` element. to compact the data. - `types/ui/editor/render.callbacks`: Rearange the Generic Type of `TRenderInstancePage` and Renaming `TCreatorPage` to `TInstanceManagerPage`. Adapting the `option` of `TInstanceManagerPage` regarding the `createInstance` and `instances` - `types/ui/editor/index`: Adapting the Exports. - `lib/index.browser`: Exporting `ui` elements - `lib/index.nodejs`: Exporting `ui` elements - `lib/types/index`: Exporting `ui` elements - Fixes: - `types/nope/nopeInstanceManager.interface`: Fixing Type of createInstance. Now the Type `I` extends `INopeModule` instead of being set to `IGenericNopeModule`
2022-07-02 09:30:10 +00:00
import { getCentralDecoratedContainer } from "./container";
const CONTAINER = getCentralDecoratedContainer();
2020-11-05 17:01:38 +00:00
/**
2022-01-10 06:52:05 +00:00
* Decorator, used to export the Method as Service to Nope..
* @param options The options used for linking.
2020-11-05 17:01:38 +00:00
*/
2022-01-10 06:52:05 +00:00
export function nopeMethod(options: IFunctionOptions) {
2022-01-26 12:03:03 +00:00
// Now lets make shure, we are using the correct type
// provide inputs and outputs.
rsetattr(options, "schema/type", "function");
rsetattr(options, "schema/inputs", rgetattr(options, "schema/inputs", []));
rsetattr(options, "schema/outputs", rgetattr(options, "schema/outputs", []));
return function (
target: INopeModule,
methodName: string,
descriptor: PropertyDescriptor
) {
# 1.2.0 - Added: - `lib/cli/nope` adding scan for ui service - `lib/decorators/container`: Main Container, holding all `methods` and `classes`. Use `getCentralDecoratedContainer()` to get this decorator. - `types/nope/nopePackage.interface` added `IClassDescription` which contains the class description used in the Package Description. - `logger/nopeLogger`: added methods: `enabledFor`, `enableFor`, `shouldLog` - `package.json`: installed types of `ace` text editor. - `ui/helpers.browser`: Created `convertInstanceRenderPage` and `IUiDefinition` - `ui/helpers.nodejs`: Added a Helper to write the Ui-File (`writeUiFile`) and parse its arguments (`readInwriteUiFileArgs`) - `ui/index.*`: Crated the corresponding exports. - Modified: - `lib/decorators/*` Adding the main `container` where every function, service method etc is added. All decorators now safe the decorated elements in the container. - `helpers/json`: Adding `BEGIN_STR` and `END_STR` for parsing functions as constants. - `logger/eventLogging`: simplify `useEventLogger` - `logger/index.browser`: Adating exports. - `loader/loadPackages`: Modifing `IPackageConfig` now extends Partial the `IPackageDescription` - `types/ui/editor/IEditPage`: adapting Type of `getData` to `T`->`any`. Adapting the return of `getPorts` (The Ports will be generated in the ui then) - `types/ui/editor/helpers.interface`: Adapting the `w2ui` and added `w2uiHelpers` and added `ace`. Rearanging `IRenderData` element. to compact the data. - `types/ui/editor/render.callbacks`: Rearange the Generic Type of `TRenderInstancePage` and Renaming `TCreatorPage` to `TInstanceManagerPage`. Adapting the `option` of `TInstanceManagerPage` regarding the `createInstance` and `instances` - `types/ui/editor/index`: Adapting the Exports. - `lib/index.browser`: Exporting `ui` elements - `lib/index.nodejs`: Exporting `ui` elements - `lib/types/index`: Exporting `ui` elements - Fixes: - `types/nope/nopeInstanceManager.interface`: Fixing Type of createInstance. Now the Type `I` extends `INopeModule` instead of being set to `IGenericNopeModule`
2022-07-02 09:30:10 +00:00
// Add the Target to the class.
CONTAINER.classes.set(target.constructor.name, target);
target._markedElements = target._markedElements || [];
target._markedElements.push({
accessor: methodName,
options,
2021-12-04 07:25:26 +00:00
type: "method",
});
};
2020-11-05 17:01:38 +00:00
}
/**
2022-01-10 06:52:05 +00:00
* Decorator, will link the Parameter to Nope and make it available. it available as
* Nope-Property.
* @param options The Options, describing the settings for linking.
2020-11-05 17:01:38 +00:00
*/
2022-01-10 06:52:05 +00:00
export function nopeProperty(options: IEventOptions) {
return function (
target: INopeModule,
propertyKey: string,
descriptor: PropertyDescriptor
) {
# 1.2.0 - Added: - `lib/cli/nope` adding scan for ui service - `lib/decorators/container`: Main Container, holding all `methods` and `classes`. Use `getCentralDecoratedContainer()` to get this decorator. - `types/nope/nopePackage.interface` added `IClassDescription` which contains the class description used in the Package Description. - `logger/nopeLogger`: added methods: `enabledFor`, `enableFor`, `shouldLog` - `package.json`: installed types of `ace` text editor. - `ui/helpers.browser`: Created `convertInstanceRenderPage` and `IUiDefinition` - `ui/helpers.nodejs`: Added a Helper to write the Ui-File (`writeUiFile`) and parse its arguments (`readInwriteUiFileArgs`) - `ui/index.*`: Crated the corresponding exports. - Modified: - `lib/decorators/*` Adding the main `container` where every function, service method etc is added. All decorators now safe the decorated elements in the container. - `helpers/json`: Adding `BEGIN_STR` and `END_STR` for parsing functions as constants. - `logger/eventLogging`: simplify `useEventLogger` - `logger/index.browser`: Adating exports. - `loader/loadPackages`: Modifing `IPackageConfig` now extends Partial the `IPackageDescription` - `types/ui/editor/IEditPage`: adapting Type of `getData` to `T`->`any`. Adapting the return of `getPorts` (The Ports will be generated in the ui then) - `types/ui/editor/helpers.interface`: Adapting the `w2ui` and added `w2uiHelpers` and added `ace`. Rearanging `IRenderData` element. to compact the data. - `types/ui/editor/render.callbacks`: Rearange the Generic Type of `TRenderInstancePage` and Renaming `TCreatorPage` to `TInstanceManagerPage`. Adapting the `option` of `TInstanceManagerPage` regarding the `createInstance` and `instances` - `types/ui/editor/index`: Adapting the Exports. - `lib/index.browser`: Exporting `ui` elements - `lib/index.nodejs`: Exporting `ui` elements - `lib/types/index`: Exporting `ui` elements - Fixes: - `types/nope/nopeInstanceManager.interface`: Fixing Type of createInstance. Now the Type `I` extends `INopeModule` instead of being set to `IGenericNopeModule`
2022-07-02 09:30:10 +00:00
// Add the Target to the class.
CONTAINER.classes.set(target.constructor.name, target);
target._markedElements = target._markedElements || [];
target._markedElements.push({
accessor: propertyKey,
options,
2021-12-04 07:25:26 +00:00
type: "prop",
});
};
}
2022-01-10 06:52:05 +00:00
/**
* Decorator, that will link the Parameter to Nope and make it available as
* Event Emitter.
* @param options The Options, describing the settings for linking.
*/
export function nopeEmitter(options: IEventOptions) {
return function (
target: INopeModule,
propertyKey: string,
descriptor: PropertyDescriptor
) {
# 1.2.0 - Added: - `lib/cli/nope` adding scan for ui service - `lib/decorators/container`: Main Container, holding all `methods` and `classes`. Use `getCentralDecoratedContainer()` to get this decorator. - `types/nope/nopePackage.interface` added `IClassDescription` which contains the class description used in the Package Description. - `logger/nopeLogger`: added methods: `enabledFor`, `enableFor`, `shouldLog` - `package.json`: installed types of `ace` text editor. - `ui/helpers.browser`: Created `convertInstanceRenderPage` and `IUiDefinition` - `ui/helpers.nodejs`: Added a Helper to write the Ui-File (`writeUiFile`) and parse its arguments (`readInwriteUiFileArgs`) - `ui/index.*`: Crated the corresponding exports. - Modified: - `lib/decorators/*` Adding the main `container` where every function, service method etc is added. All decorators now safe the decorated elements in the container. - `helpers/json`: Adding `BEGIN_STR` and `END_STR` for parsing functions as constants. - `logger/eventLogging`: simplify `useEventLogger` - `logger/index.browser`: Adating exports. - `loader/loadPackages`: Modifing `IPackageConfig` now extends Partial the `IPackageDescription` - `types/ui/editor/IEditPage`: adapting Type of `getData` to `T`->`any`. Adapting the return of `getPorts` (The Ports will be generated in the ui then) - `types/ui/editor/helpers.interface`: Adapting the `w2ui` and added `w2uiHelpers` and added `ace`. Rearanging `IRenderData` element. to compact the data. - `types/ui/editor/render.callbacks`: Rearange the Generic Type of `TRenderInstancePage` and Renaming `TCreatorPage` to `TInstanceManagerPage`. Adapting the `option` of `TInstanceManagerPage` regarding the `createInstance` and `instances` - `types/ui/editor/index`: Adapting the Exports. - `lib/index.browser`: Exporting `ui` elements - `lib/index.nodejs`: Exporting `ui` elements - `lib/types/index`: Exporting `ui` elements - Fixes: - `types/nope/nopeInstanceManager.interface`: Fixing Type of createInstance. Now the Type `I` extends `INopeModule` instead of being set to `IGenericNopeModule`
2022-07-02 09:30:10 +00:00
// Add the Target to the class.
CONTAINER.classes.set(target.constructor.name, target);
2022-01-10 06:52:05 +00:00
target._markedElements = target._markedElements || [];
target._markedElements.push({
accessor: propertyKey,
options,
type: "event",
});
};
}