@node-projects/web-component-designer-visualization-addons 0.1.96 → 0.1.98

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, contextCreator?: (root: HTMLElement, event: Event, element: Element, parameters: Record<string, any>, relativeSignalsPath: string) => any, assignExternalScript?: (element: Element, event: string, scriptData: any) => void): Promise<VisualisationElementScript>;
26
27
  }
@@ -398,8 +398,12 @@ 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, contextCreator, assignExternalScript) {
402
405
  const allElements = shadowRoot.querySelectorAll('*');
406
+ contextCreator ??= this.createScriptContext;
403
407
  let jsObject = null;
404
408
  if (javascriptCode) {
405
409
  try {
@@ -422,14 +426,14 @@ export class ScriptSystem {
422
426
  if (script[0] == '{') {
423
427
  let scriptObj = JSON.parse(script);
424
428
  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 }));
429
+ e.addEventListener(evtName, (evt) => this.execute(scriptObj.commands, this.createScriptContext(instance, evt, e, scriptObj.parameters, scriptObj.relativeSignalsPath)));
426
430
  }
427
431
  else if ('blocks' in scriptObj) {
428
432
  let compiledFunc = null;
429
433
  e.addEventListener(evtName, async (evt) => {
430
434
  if (!compiledFunc)
431
435
  compiledFunc = await generateEventCodeFromBlockly(scriptObj);
432
- compiledFunc(evt, shadowRoot, scriptObj.parameters, scriptObj.relativeSignalsPath ?? '', visualizationHandler, context);
436
+ compiledFunc(evt, shadowRoot, scriptObj.parameters, scriptObj.relativeSignalsPath ?? '', visualizationHandler, this.createScriptContext(instance, evt, e, scriptObj.parameters, scriptObj.relativeSignalsPath));
433
437
  });
434
438
  }
435
439
  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
  }
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.96",
4
+ "version": "0.1.98",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "author": "jochen.kuehner@gmx.de",