@node-projects/web-component-designer-visualization-addons 0.1.95 → 0.1.97

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.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ //@ts-ignore
2
+ class FieldObjectId extends Blockly.FieldTextInput {
3
+ }
4
+ //@ts-ignore
5
+ Blockly.FieldObjectId = FieldObjectId;
6
+ export {};
@@ -22,5 +22,6 @@ export declare class ScriptSystem {
22
22
  parseStringWithValues(text: string, context: contextType): Promise<string>;
23
23
  getSignaName(name: string, outerContext: contextType): string;
24
24
  static extractPart(obj: any, propertyPath: string): any;
25
- assignAllScripts(source: string, javascriptCode: string, shadowRoot: ShadowRoot, instance: HTMLElement, visualizationHandler: VisualizationHandler, context?: any, assignExternalScript?: (element: Element, event: string, scriptData: any) => void): Promise<VisualisationElementScript>;
25
+ createScriptContext(root: HTMLElement, event: Event, element: Element, parameters: Record<string, any>, relativeSignalsPath: string): any;
26
+ assignAllScripts(source: string, javascriptCode: string, shadowRoot: ShadowRoot, instance: HTMLElement, visualizationHandler: VisualizationHandler, assignExternalScript?: (element: Element, event: string, scriptData: any) => void): Promise<VisualisationElementScript>;
26
27
  }
@@ -398,7 +398,10 @@ export class ScriptSystem {
398
398
  }
399
399
  return retVal;
400
400
  }
401
- async assignAllScripts(source, javascriptCode, shadowRoot, instance, visualizationHandler, context, assignExternalScript) {
401
+ createScriptContext(root, event, element, parameters, relativeSignalsPath) {
402
+ return { root, event, element, parameters, relativeSignalsPath };
403
+ }
404
+ async assignAllScripts(source, javascriptCode, shadowRoot, instance, visualizationHandler, assignExternalScript) {
402
405
  const allElements = shadowRoot.querySelectorAll('*');
403
406
  let jsObject = null;
404
407
  if (javascriptCode) {
@@ -422,14 +425,14 @@ export class ScriptSystem {
422
425
  if (script[0] == '{') {
423
426
  let scriptObj = JSON.parse(script);
424
427
  if ('commands' in scriptObj) {
425
- e.addEventListener(evtName, (evt) => this.execute(scriptObj.commands, { event: evt, element: e, root: instance, parameters: scriptObj.parameters, relativeSignalsPath: scriptObj.relativeSignalsPath }));
428
+ e.addEventListener(evtName, (evt) => this.execute(scriptObj.commands, this.createScriptContext(instance, evt, e, scriptObj.parameters, scriptObj.relativeSignalsPath)));
426
429
  }
427
430
  else if ('blocks' in scriptObj) {
428
431
  let compiledFunc = null;
429
432
  e.addEventListener(evtName, async (evt) => {
430
433
  if (!compiledFunc)
431
434
  compiledFunc = await generateEventCodeFromBlockly(scriptObj);
432
- compiledFunc(evt, shadowRoot, scriptObj.parameters, scriptObj.relativeSignalsPath ?? '', visualizationHandler, context);
435
+ compiledFunc(evt, shadowRoot, scriptObj.parameters, scriptObj.relativeSignalsPath ?? '', visualizationHandler, this.createScriptContext(instance, evt, e, scriptObj.parameters, scriptObj.relativeSignalsPath));
433
436
  });
434
437
  }
435
438
  else {
@@ -1,5 +1,5 @@
1
1
  import { ScriptCommands, SetElementProperty } from "./ScriptCommands";
2
2
  export declare class ScriptUpgrades {
3
- static upgradeScriptCommand(scriptCommand: ScriptCommands): import("./ScriptCommands").Comment | import("./ScriptCommands").OpenScreen | import("./ScriptCommands").OpenUrl | import("./ScriptCommands").OpenDialog | import("./ScriptCommands").CloseDialog | import("./ScriptCommands").ToggleSignalValue | import("./ScriptCommands").SetSignalValue | import("./ScriptCommands").IncrementSignalValue | import("./ScriptCommands").DecrementSignalValue | import("./ScriptCommands").SetBitInSignal | import("./ScriptCommands").ClearBitInSignal | import("./ScriptCommands").ToggleBitInSignal | import("./ScriptCommands").Console | import("./ScriptCommands").CalculateSignalValue | import("./ScriptCommands").Javascript | SetElementProperty | import("./ScriptCommands").Delay | import("./ScriptCommands").SwitchLanguage | import("./ScriptCommands").Login | import("./ScriptCommands").Logout | import("./ScriptCommands").SubscribeSignal | import("./ScriptCommands").UnsubscribeSignal | import("./ScriptCommands").WriteSignalsInGroup | import("./ScriptCommands").ClearSiganlsInGroup | import("./ScriptCommands").Condition | import("./ScriptCommands").Exit | import("./ScriptCommands").Label | import("./ScriptCommands").RunScript | import("./ScriptCommands").Goto | import("./ScriptCommands").CopySignalValuesFromFolder | import("./ScriptCommands").ShowMessageBox | import("./ScriptCommands").ExportSignalValuesAsJson | import("./ScriptCommands").ImportSignalValuesFromJson;
3
+ static upgradeScriptCommand(scriptCommand: ScriptCommands): SetElementProperty | import("./ScriptCommands").Comment | import("./ScriptCommands").OpenScreen | import("./ScriptCommands").OpenUrl | import("./ScriptCommands").OpenDialog | import("./ScriptCommands").CloseDialog | import("./ScriptCommands").ToggleSignalValue | import("./ScriptCommands").SetSignalValue | import("./ScriptCommands").IncrementSignalValue | import("./ScriptCommands").DecrementSignalValue | import("./ScriptCommands").SetBitInSignal | import("./ScriptCommands").ClearBitInSignal | import("./ScriptCommands").ToggleBitInSignal | import("./ScriptCommands").Console | import("./ScriptCommands").CalculateSignalValue | import("./ScriptCommands").Javascript | import("./ScriptCommands").Delay | import("./ScriptCommands").SwitchLanguage | import("./ScriptCommands").Login | import("./ScriptCommands").Logout | import("./ScriptCommands").SubscribeSignal | import("./ScriptCommands").UnsubscribeSignal | import("./ScriptCommands").WriteSignalsInGroup | import("./ScriptCommands").ClearSiganlsInGroup | import("./ScriptCommands").Condition | import("./ScriptCommands").Exit | import("./ScriptCommands").Label | import("./ScriptCommands").RunScript | import("./ScriptCommands").Goto | import("./ScriptCommands").CopySignalValuesFromFolder | import("./ScriptCommands").ShowMessageBox | import("./ScriptCommands").ExportSignalValuesAsJson | import("./ScriptCommands").ImportSignalValuesFromJson;
4
4
  static upgradeSetElementProperty(scriptCommand: SetElementProperty): SetElementProperty;
5
5
  }
@@ -15,10 +15,10 @@ export class ScriptRefactorService {
15
15
  if (cp != null && typeof cp === 'object') {
16
16
  let mp = cp;
17
17
  if (mp.source === 'signal') {
18
- refactorings.push({ name: mp.name, itemType: 'signal', target: BindingTarget.event, targetName: a[0], service: this, designItem: d, type: 'script', sourceObject: script, display: c.type + '/' + p + '[signal]', refactor: newValue => mp.name = newValue });
18
+ refactorings.push({ name: mp.name, itemType: 'signal', target: BindingTarget.event, targetName: a[0], service: this, designItem: d, type: 'script', sourceObject: script, display: c.type + '/' + a[0].substring(1) + '/' + p + '[signal]', refactor: newValue => mp.name = newValue });
19
19
  }
20
20
  else if (mp.source === 'property') {
21
- refactorings.push({ name: mp.name, itemType: 'property', target: BindingTarget.event, targetName: a[0], service: this, designItem: d, type: 'script', sourceObject: script, display: c.type + '/' + p + '[property]', refactor: newValue => mp.name = newValue });
21
+ refactorings.push({ name: mp.name, itemType: 'property', target: BindingTarget.event, targetName: a[0], service: this, designItem: d, type: 'script', sourceObject: script, display: c.type + '/' + a[0].substring(1) + '/' + p + '[property]', refactor: newValue => mp.name = newValue });
22
22
  }
23
23
  else if (mp.source === 'complexString') {
24
24
  for (let m of mp.name.matchAll(/\{(.*?)\}/g)) {
@@ -31,10 +31,10 @@ export class ScriptRefactorService {
31
31
  prefix = '??';
32
32
  nm = nm.substring(1);
33
33
  }
34
- refactorings.push({ name: nm, itemType: 'property', target: BindingTarget.event, targetName: a[0], service: this, designItem: d, type: 'script', sourceObject: script, display: c.type + '/' + p + '[complexString]->property', refactor: newValue => mp.name = mp.name.replace(full, '{' + prefix + newValue + '}') });
34
+ refactorings.push({ name: nm, itemType: 'property', target: BindingTarget.event, targetName: a[0], service: this, designItem: d, type: 'script', sourceObject: script, display: c.type + '/' + a[0].substring(1) + '/' + p + '[complexString]->property', refactor: newValue => mp.name = mp.name.replace(full, '{' + prefix + newValue + '}') });
35
35
  }
36
36
  else {
37
- refactorings.push({ name: nm, itemType: 'signal', target: BindingTarget.event, targetName: a[0], service: this, designItem: d, type: 'script', sourceObject: script, display: c.type + '/' + p + '[complexString]->signal', refactor: newValue => mp.name = mp.name.replace(full, '{' + newValue + '}') });
37
+ refactorings.push({ name: nm, itemType: 'signal', target: BindingTarget.event, targetName: a[0], service: this, designItem: d, type: 'script', sourceObject: script, display: c.type + '/' + a[0].substring(1) + '/' + p + '[complexString]->signal', refactor: newValue => mp.name = mp.name.replace(full, '{' + newValue + '}') });
38
38
  }
39
39
  }
40
40
  }
@@ -43,55 +43,55 @@ export class ScriptRefactorService {
43
43
  switch (c.type) {
44
44
  case 'SetSignalValue':
45
45
  if (c.signal && typeof c.signal === 'string')
46
- refactorings.push({ name: c.signal, itemType: 'signal', target: BindingTarget.event, targetName: a[0], display: c.type + '/signal', service: this, designItem: d, type: 'script', sourceObject: script, refactor: newValue => c.signal = newValue });
46
+ refactorings.push({ name: c.signal, itemType: 'signal', target: BindingTarget.event, targetName: a[0], display: c.type + '/' + a[0].substring(1) + '/signal', service: this, designItem: d, type: 'script', sourceObject: script, refactor: newValue => c.signal = newValue });
47
47
  break;
48
48
  case 'ToggleSignalValue':
49
49
  if (c.signal && typeof c.signal === 'string')
50
- refactorings.push({ name: c.signal, itemType: 'signal', target: BindingTarget.event, targetName: a[0], display: c.type + '/signal', service: this, designItem: d, type: 'script', sourceObject: script, refactor: newValue => c.signal = newValue });
50
+ refactorings.push({ name: c.signal, itemType: 'signal', target: BindingTarget.event, targetName: a[0], display: c.type + '/' + a[0].substring(1) + '/signal', service: this, designItem: d, type: 'script', sourceObject: script, refactor: newValue => c.signal = newValue });
51
51
  break;
52
52
  case 'IncrementSignalValue':
53
53
  if (c.signal && typeof c.signal === 'string')
54
- refactorings.push({ name: c.signal, itemType: 'signal', target: BindingTarget.event, targetName: a[0], display: c.type + '/signal', service: this, designItem: d, type: 'script', sourceObject: script, refactor: newValue => c.signal = newValue });
54
+ refactorings.push({ name: c.signal, itemType: 'signal', target: BindingTarget.event, targetName: a[0], display: c.type + '/' + a[0].substring(1) + '/signal', service: this, designItem: d, type: 'script', sourceObject: script, refactor: newValue => c.signal = newValue });
55
55
  break;
56
56
  case 'DecrementSignalValue':
57
57
  if (c.signal && typeof c.signal === 'string')
58
- refactorings.push({ name: c.signal, itemType: 'signal', target: BindingTarget.event, targetName: a[0], display: c.type + '/signal', service: this, designItem: d, type: 'script', sourceObject: script, refactor: newValue => c.signal = newValue });
58
+ refactorings.push({ name: c.signal, itemType: 'signal', target: BindingTarget.event, targetName: a[0], display: c.type + '/' + a[0].substring(1) + '/signal', service: this, designItem: d, type: 'script', sourceObject: script, refactor: newValue => c.signal = newValue });
59
59
  break;
60
60
  case 'SetBitInSignal':
61
61
  if (c.signal && typeof c.signal === 'string')
62
- refactorings.push({ name: c.signal, itemType: 'signal', target: BindingTarget.event, targetName: a[0], display: c.type + '/signal', service: this, designItem: d, type: 'script', sourceObject: script, refactor: newValue => c.signal = newValue });
62
+ refactorings.push({ name: c.signal, itemType: 'signal', target: BindingTarget.event, targetName: a[0], display: c.type + '/' + a[0].substring(1) + '/signal', service: this, designItem: d, type: 'script', sourceObject: script, refactor: newValue => c.signal = newValue });
63
63
  break;
64
64
  case 'ClearBitInSignal':
65
65
  if (c.signal && typeof c.signal === 'string')
66
- refactorings.push({ name: c.signal, itemType: 'signal', target: BindingTarget.event, targetName: a[0], display: c.type + '/signal', service: this, designItem: d, type: 'script', sourceObject: script, refactor: newValue => c.signal = newValue });
66
+ refactorings.push({ name: c.signal, itemType: 'signal', target: BindingTarget.event, targetName: a[0], display: c.type + '/' + a[0].substring(1) + '/signal', service: this, designItem: d, type: 'script', sourceObject: script, refactor: newValue => c.signal = newValue });
67
67
  break;
68
68
  case 'ToggleBitInSignal':
69
69
  if (c.signal && typeof c.signal === 'string')
70
- refactorings.push({ name: c.signal, itemType: 'signal', target: BindingTarget.event, targetName: a[0], display: c.type + '/signal', service: this, designItem: d, type: 'script', sourceObject: script, refactor: newValue => c.signal = newValue });
70
+ refactorings.push({ name: c.signal, itemType: 'signal', target: BindingTarget.event, targetName: a[0], display: c.type + '/' + a[0].substring(1) + '/signal', service: this, designItem: d, type: 'script', sourceObject: script, refactor: newValue => c.signal = newValue });
71
71
  break;
72
72
  case 'OpenScreen':
73
73
  if (c.screen && typeof c.screen === 'string')
74
- refactorings.push({ name: c.screen, itemType: 'screen', target: BindingTarget.event, targetName: a[0], display: c.type + '/screen', service: this, designItem: d, type: 'script', sourceObject: script, refactor: newValue => c.screen = newValue });
74
+ refactorings.push({ name: c.screen, itemType: 'screen', target: BindingTarget.event, targetName: a[0], display: c.type + '/' + a[0].substring(1) + '/screen', service: this, designItem: d, type: 'script', sourceObject: script, refactor: newValue => c.screen = newValue });
75
75
  break;
76
76
  case 'OpenDialog':
77
77
  if (c.screen && typeof c.screen === 'string')
78
- refactorings.push({ name: c.screen, itemType: 'screen', target: BindingTarget.event, targetName: a[0], display: c.type + '/screen', service: this, designItem: d, type: 'script', sourceObject: script, refactor: newValue => c.screen = newValue });
78
+ refactorings.push({ name: c.screen, itemType: 'screen', target: BindingTarget.event, targetName: a[0], display: c.type + '/' + a[0].substring(1) + '/screen', service: this, designItem: d, type: 'script', sourceObject: script, refactor: newValue => c.screen = newValue });
79
79
  break;
80
80
  case 'CalculateSignalValue':
81
81
  if (c.targetSignal && typeof c.targetSignal === 'string')
82
- refactorings.push({ name: c.targetSignal, itemType: 'signal', target: BindingTarget.event, targetName: a[0], display: c.type + '/targetSignal', service: this, designItem: d, type: 'script', sourceObject: script, refactor: newValue => c.targetSignal = newValue });
82
+ refactorings.push({ name: c.targetSignal, itemType: 'signal', target: BindingTarget.event, targetName: a[0], display: c.type + '/' + a[0].substring(1) + '/targetSignal', service: this, designItem: d, type: 'script', sourceObject: script, refactor: newValue => c.targetSignal = newValue });
83
83
  break;
84
84
  case 'SubscribeSignal':
85
85
  if (c.signal && typeof c.signal === 'string')
86
- refactorings.push({ name: c.signal, itemType: 'signal', target: BindingTarget.event, targetName: a[0], display: c.type + '/signal', service: this, designItem: d, type: 'script', sourceObject: script, refactor: newValue => c.signal = newValue });
86
+ refactorings.push({ name: c.signal, itemType: 'signal', target: BindingTarget.event, targetName: a[0], display: c.type + '/' + a[0].substring(1) + '/signal', service: this, designItem: d, type: 'script', sourceObject: script, refactor: newValue => c.signal = newValue });
87
87
  break;
88
88
  case 'UnsubscribeSignal':
89
89
  if (c.signal && typeof c.signal === 'string')
90
- refactorings.push({ name: c.signal, itemType: 'signal', target: BindingTarget.event, targetName: a[0], display: c.type + '/signal', service: this, designItem: d, type: 'script', sourceObject: script, refactor: newValue => c.signal = newValue });
90
+ refactorings.push({ name: c.signal, itemType: 'signal', target: BindingTarget.event, targetName: a[0], display: c.type + '/' + a[0].substring(1) + '/signal', service: this, designItem: d, type: 'script', sourceObject: script, refactor: newValue => c.signal = newValue });
91
91
  break;
92
92
  case 'ShowMessageBox':
93
93
  if (c.resultSignal && typeof c.resultSignal === 'string')
94
- refactorings.push({ name: c.resultSignal, itemType: 'signal', target: BindingTarget.event, targetName: a[0], display: c.type + '/resultSignal', service: this, designItem: d, type: 'script', sourceObject: script, refactor: newValue => c.resultSignal = newValue });
94
+ refactorings.push({ name: c.resultSignal, itemType: 'signal', target: BindingTarget.event, targetName: a[0], display: c.type + '/' + a[0].substring(1) + '/resultSignal', service: this, designItem: d, type: 'script', sourceObject: script, refactor: newValue => c.resultSignal = newValue });
95
95
  break;
96
96
  }
97
97
  }
@@ -101,7 +101,7 @@ export class ScriptRefactorService {
101
101
  if ('parameters' in script) {
102
102
  for (let p in script.parameters) {
103
103
  if (typeof script.parameters[p] === 'string') {
104
- refactorings.push({ name: script.parameters[p], itemType: 'parameter', target: BindingTarget.event, targetName: a[0], service: this, designItem: d, type: 'script', sourceObject: script, display: 'parameters/' + p, refactor: newValue => script.parameters[p] = newValue });
104
+ refactorings.push({ name: script.parameters[p], itemType: 'parameter', target: BindingTarget.event, targetName: a[0], service: this, designItem: d, type: 'script', sourceObject: script, display: a[0].substring(1) + '/parameters/' + p, refactor: newValue => script.parameters[p] = newValue });
105
105
  }
106
106
  }
107
107
  }
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.95",
4
+ "version": "0.1.97",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "author": "jochen.kuehner@gmx.de",