@node-projects/web-component-designer-visualization-addons 0.1.127 → 0.1.128
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/SimpleScriptEditor.js +1 -1
- package/dist/interfaces/IScriptMultiplexValue.d.ts +2 -1
- package/dist/interfaces/IScriptMultiplexValue.js +1 -0
- package/dist/scripting/ScriptCommands.d.ts +1 -1
- package/dist/scripting/ScriptSystem.d.ts +0 -1
- package/dist/scripting/ScriptSystem.js +11 -16
- package/package.json +1 -1
|
@@ -207,7 +207,7 @@ export class SimpleScriptEditor extends BaseCustomWebComponentConstructorAppend
|
|
|
207
207
|
}
|
|
208
208
|
//Converter from TypscriptJsonSchema to our Property list...
|
|
209
209
|
async addPossibleCommands() {
|
|
210
|
-
let commands = Object.keys(this.scriptCommandsTypeInfo.definitions);
|
|
210
|
+
let commands = Object.keys(this.scriptCommandsTypeInfo.definitions).filter(x => this.scriptCommandsTypeInfo.definitions[x].type == 'object');
|
|
211
211
|
for (let c of commands) {
|
|
212
212
|
if (c == 'ScriptCommands')
|
|
213
213
|
continue;
|
|
@@ -8,8 +8,9 @@ export declare class IScriptMultiplexValue {
|
|
|
8
8
|
* complexString - a string with signals (contained in {})
|
|
9
9
|
* complexSignal - read the value from a signal wich name is build here (it can contain other signals in {})
|
|
10
10
|
* expression - js expression, 'ctx' is context object
|
|
11
|
+
* elementProperty - a property defined on the element raising the event
|
|
11
12
|
*/
|
|
12
|
-
source: 'signal' | 'property' | 'event' | 'parameter' | 'complexString' | 'complexSignal' | 'expression' | 'context';
|
|
13
|
+
source: 'signal' | 'property' | 'event' | 'parameter' | 'complexString' | 'complexSignal' | 'expression' | 'context' | 'elementProperty';
|
|
13
14
|
/**
|
|
14
15
|
* Name of the signal, the property of the component or the parameter of the script
|
|
15
16
|
* or for example in a event : srcElement.value to get the value of a input wich raises the event
|
|
@@ -8,6 +8,7 @@ export class IScriptMultiplexValue {
|
|
|
8
8
|
* complexString - a string with signals (contained in {})
|
|
9
9
|
* complexSignal - read the value from a signal wich name is build here (it can contain other signals in {})
|
|
10
10
|
* expression - js expression, 'ctx' is context object
|
|
11
|
+
* elementProperty - a property defined on the element raising the event
|
|
11
12
|
*/
|
|
12
13
|
source;
|
|
13
14
|
/**
|
|
@@ -5,7 +5,7 @@ export declare type RunnableScriptCommands = OpenScreen | OpenUrl | OpenDialog |
|
|
|
5
5
|
* property - a property defined in the current screen/control
|
|
6
6
|
* elementProperty - a property defined on the element raising the event
|
|
7
7
|
*/
|
|
8
|
-
export type signalTarget = 'signal' | 'property' | 'elementProperty';
|
|
8
|
+
export declare type signalTarget = 'signal' | 'property' | 'elementProperty';
|
|
9
9
|
export interface Comment {
|
|
10
10
|
type: 'Comment';
|
|
11
11
|
comment: string;
|
|
@@ -23,7 +23,6 @@ export declare class ScriptSystem {
|
|
|
23
23
|
getStateOrFieldOrParameter(name: string, context: contextType): Promise<any>;
|
|
24
24
|
parseStringWithValues(text: string, context: contextType): Promise<string>;
|
|
25
25
|
getSignalName(name: string, outerContext: contextType): string;
|
|
26
|
-
static extractPart(obj: any, propertyPath: string): any;
|
|
27
26
|
createScriptContext(root: HTMLElement, event: Event, element: Element, parameters: Record<string, any>, relativeSignalsPath: string): any;
|
|
28
27
|
assignAllScripts(source: string, javascriptCode: string, shadowRoot: ShadowRoot, instance: HTMLElement, visualizationHandler: VisualizationHandler, contextCreator?: (root: HTMLElement, event: Event, element: Element, parameters: Record<string, any>, relativeSignalsPath: string) => any, assignExternalScript?: (element: Element, event: string, scriptData: any) => void, runInitalization?: (jsObject: VisualisationElementScript) => void): Promise<VisualisationElementScript>;
|
|
29
28
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { sleep } from "@node-projects/web-component-designer/dist/elements/helper/Helper.js";
|
|
1
|
+
import { deepValue, setDeepValue, sleep } from "@node-projects/web-component-designer/dist/elements/helper/Helper.js";
|
|
2
2
|
import { generateEventCodeFromBlockly } from "../blockly/BlocklyJavascriptHelper.js";
|
|
3
3
|
import { parseBindingString } from "../helpers/BindingsHelper.js";
|
|
4
4
|
import Long from 'long';
|
|
@@ -83,10 +83,10 @@ export class ScriptSystem {
|
|
|
83
83
|
}
|
|
84
84
|
async getValueFromTarget(target, name, context) {
|
|
85
85
|
if (target === 'property') {
|
|
86
|
-
return context.root
|
|
86
|
+
return deepValue(context.root, name);
|
|
87
87
|
}
|
|
88
88
|
else if (target === 'elementProperty') {
|
|
89
|
-
return context.element
|
|
89
|
+
return deepValue(context.element, name);
|
|
90
90
|
}
|
|
91
91
|
else {
|
|
92
92
|
return (await this._visualizationHandler.getState(this.getSignalName(name, context)))?.val;
|
|
@@ -94,10 +94,10 @@ export class ScriptSystem {
|
|
|
94
94
|
}
|
|
95
95
|
async setValueOnTarget(target, name, context, value) {
|
|
96
96
|
if (target === 'property') {
|
|
97
|
-
context.root
|
|
97
|
+
setDeepValue(context.root, name, value);
|
|
98
98
|
}
|
|
99
99
|
else if (target === 'elementProperty') {
|
|
100
|
-
context.element
|
|
100
|
+
setDeepValue(context.element, name, value);
|
|
101
101
|
}
|
|
102
102
|
else {
|
|
103
103
|
await this._visualizationHandler.setState(this.getSignalName(name, context), value);
|
|
@@ -349,7 +349,10 @@ export class ScriptSystem {
|
|
|
349
349
|
if (typeof value === 'object') {
|
|
350
350
|
switch (value.source) {
|
|
351
351
|
case 'property': {
|
|
352
|
-
return outerContext.root
|
|
352
|
+
return deepValue(outerContext.root, value.name);
|
|
353
|
+
}
|
|
354
|
+
case 'elementProperty': {
|
|
355
|
+
return deepValue(outerContext.element, value.name);
|
|
353
356
|
}
|
|
354
357
|
case 'signal': {
|
|
355
358
|
let sng = await this._visualizationHandler.getState(this.getSignalName(value.name, outerContext));
|
|
@@ -358,15 +361,14 @@ export class ScriptSystem {
|
|
|
358
361
|
case 'event': {
|
|
359
362
|
let obj = outerContext.event;
|
|
360
363
|
if (value.name)
|
|
361
|
-
obj =
|
|
364
|
+
obj = deepValue(obj, value.name);
|
|
362
365
|
return obj;
|
|
363
366
|
}
|
|
364
367
|
case 'parameter': {
|
|
365
368
|
return outerContext.parameters[value.name];
|
|
366
369
|
}
|
|
367
370
|
case 'context': {
|
|
368
|
-
|
|
369
|
-
return obj;
|
|
371
|
+
return deepValue(outerContext, value.name);
|
|
370
372
|
}
|
|
371
373
|
case 'complexString': {
|
|
372
374
|
let text = value.name;
|
|
@@ -427,13 +429,6 @@ export class ScriptSystem {
|
|
|
427
429
|
return outerContext.relativeSignalsPath + name;
|
|
428
430
|
return name;
|
|
429
431
|
}
|
|
430
|
-
static extractPart(obj, propertyPath) {
|
|
431
|
-
let retVal = obj;
|
|
432
|
-
for (let p of propertyPath.split('.')) {
|
|
433
|
-
retVal = retVal?.[p];
|
|
434
|
-
}
|
|
435
|
-
return retVal;
|
|
436
|
-
}
|
|
437
432
|
createScriptContext(root, event, element, parameters, relativeSignalsPath) {
|
|
438
433
|
return { root, event, element, parameters, relativeSignalsPath };
|
|
439
434
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"description": "web-component-designer addon for visualizations",
|
|
3
3
|
"name": "@node-projects/web-component-designer-visualization-addons",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.128",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"author": "jochen.kuehner@gmx.de",
|