@node-projects/web-component-designer-visualization-addons 0.1.126 → 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.
@@ -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
  /**
@@ -3,10 +3,9 @@ export declare type RunnableScriptCommands = OpenScreen | OpenUrl | OpenDialog |
3
3
  /**
4
4
  * signal - a signal (the default)
5
5
  * property - a property defined in the current screen/control
6
- * elementProperty - a property defined on the elment raising the event
7
- * rootProperty - a property defined on the root element
6
+ * elementProperty - a property defined on the element raising the event
8
7
  */
9
- export type signalTarget = 'signal' | 'property' | 'elementProperty' | 'rootProperty';
8
+ export declare type signalTarget = 'signal' | 'property' | 'elementProperty';
10
9
  export interface Comment {
11
10
  type: 'Comment';
12
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,13 +83,10 @@ export class ScriptSystem {
83
83
  }
84
84
  async getValueFromTarget(target, name, context) {
85
85
  if (target === 'property') {
86
- return context.instance[name];
86
+ return deepValue(context.root, name);
87
87
  }
88
88
  else if (target === 'elementProperty') {
89
- return context.element[name];
90
- }
91
- else if (target === 'rootProperty') {
92
- return context.root[name];
89
+ return deepValue(context.element, name);
93
90
  }
94
91
  else {
95
92
  return (await this._visualizationHandler.getState(this.getSignalName(name, context)))?.val;
@@ -97,13 +94,10 @@ export class ScriptSystem {
97
94
  }
98
95
  async setValueOnTarget(target, name, context, value) {
99
96
  if (target === 'property') {
100
- context.instance[name] = value;
97
+ setDeepValue(context.root, name, value);
101
98
  }
102
99
  else if (target === 'elementProperty') {
103
- context.element[name] = value;
104
- }
105
- else if (target === 'rootProperty') {
106
- context.root[name] = value;
100
+ setDeepValue(context.element, name, value);
107
101
  }
108
102
  else {
109
103
  await this._visualizationHandler.setState(this.getSignalName(name, context), value);
@@ -355,7 +349,10 @@ export class ScriptSystem {
355
349
  if (typeof value === 'object') {
356
350
  switch (value.source) {
357
351
  case 'property': {
358
- return outerContext.root[value.name];
352
+ return deepValue(outerContext.root, value.name);
353
+ }
354
+ case 'elementProperty': {
355
+ return deepValue(outerContext.element, value.name);
359
356
  }
360
357
  case 'signal': {
361
358
  let sng = await this._visualizationHandler.getState(this.getSignalName(value.name, outerContext));
@@ -364,15 +361,14 @@ export class ScriptSystem {
364
361
  case 'event': {
365
362
  let obj = outerContext.event;
366
363
  if (value.name)
367
- obj = ScriptSystem.extractPart(obj, value.name);
364
+ obj = deepValue(obj, value.name);
368
365
  return obj;
369
366
  }
370
367
  case 'parameter': {
371
368
  return outerContext.parameters[value.name];
372
369
  }
373
370
  case 'context': {
374
- const obj = ScriptSystem.extractPart(outerContext, value.name);
375
- return obj;
371
+ return deepValue(outerContext, value.name);
376
372
  }
377
373
  case 'complexString': {
378
374
  let text = value.name;
@@ -433,13 +429,6 @@ export class ScriptSystem {
433
429
  return outerContext.relativeSignalsPath + name;
434
430
  return name;
435
431
  }
436
- static extractPart(obj, propertyPath) {
437
- let retVal = obj;
438
- for (let p of propertyPath.split('.')) {
439
- retVal = retVal?.[p];
440
- }
441
- return retVal;
442
- }
443
432
  createScriptContext(root, event, element, parameters, relativeSignalsPath) {
444
433
  return { root, event, element, parameters, relativeSignalsPath };
445
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.126",
4
+ "version": "0.1.128",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "author": "jochen.kuehner@gmx.de",