@node-projects/web-component-designer-visualization-addons 0.1.144 → 0.1.146

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/index.d.ts CHANGED
@@ -5,6 +5,8 @@ export * from './blockly/components/components.js';
5
5
  export * from './components/BindingsEditor.js';
6
6
  export * from './components/BindingsEditorHistoric.js';
7
7
  export * from './components/SimpleScriptEditor.js';
8
+ export * from './components/SimpleScriptCommandPicker.js';
9
+ export * from './components/SimpleScriptEditorHelp.js';
8
10
  export * from './components/VisualizationPropertyGrid.js';
9
11
  export * from './components/ParameterEditor.js';
10
12
  export * from './components/EventAssignment.js';
@@ -16,6 +18,7 @@ export type * from './interfaces/VisualizationHandler.js';
16
18
  export type * from './interfaces/VisualizationShell.js';
17
19
  export * from './scripting/Script.js';
18
20
  export * from './scripting/ScriptCommands.js';
21
+ export * from './scripting/ScriptCommandsDescriptions.js';
19
22
  export * from './scripting/ScriptSystem.js';
20
23
  export * from './services/BindableObjectDragDropService.js';
21
24
  export * from './services/VisualizationBindingsService.js';
package/dist/index.js CHANGED
@@ -5,12 +5,15 @@ export * from './blockly/components/components.js';
5
5
  export * from './components/BindingsEditor.js';
6
6
  export * from './components/BindingsEditorHistoric.js';
7
7
  export * from './components/SimpleScriptEditor.js';
8
+ export * from './components/SimpleScriptCommandPicker.js';
9
+ export * from './components/SimpleScriptEditorHelp.js';
8
10
  export * from './components/VisualizationPropertyGrid.js';
9
11
  export * from './components/ParameterEditor.js';
10
12
  export * from './components/EventAssignment.js';
11
13
  export * from './helpers/BindingsHelper.js';
12
14
  export * from './scripting/Script.js';
13
15
  export * from './scripting/ScriptCommands.js';
16
+ export * from './scripting/ScriptCommandsDescriptions.js';
14
17
  export * from './scripting/ScriptSystem.js';
15
18
  export * from './services/BindableObjectDragDropService.js';
16
19
  export * from './services/VisualizationBindingsService.js';
@@ -1,6 +1,7 @@
1
1
  import { IBindableObjectsBrowser } from "@node-projects/web-component-designer";
2
2
  export interface VisualizationShell {
3
3
  openConfirmation(element: HTMLElement, options: {
4
+ title?: string;
4
5
  x?: number;
5
6
  y?: number;
6
7
  width?: number;
@@ -11,5 +12,15 @@ export interface VisualizationShell {
11
12
  confirmText?: string;
12
13
  cancelText?: string;
13
14
  }): Promise<boolean>;
15
+ openModal(element: HTMLElement, options: {
16
+ title?: string;
17
+ x?: number;
18
+ y?: number;
19
+ width?: number;
20
+ height?: number;
21
+ parent?: HTMLElement;
22
+ abortSignal?: AbortSignal;
23
+ disableResize?: boolean;
24
+ }): Promise<void>;
14
25
  createBindableObjectBrowser: () => IBindableObjectsBrowser;
15
26
  }
@@ -0,0 +1,3 @@
1
+ export declare function escapeHtml(text: string): string;
2
+ /** Minimal JSON syntax highlighter for short code-snippet examples - not a real parser. */
3
+ export declare function highlightJson(json: string): string;
@@ -0,0 +1,16 @@
1
+ export function escapeHtml(text) {
2
+ return text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
3
+ }
4
+ /** Minimal JSON syntax highlighter for short code-snippet examples - not a real parser. */
5
+ export function highlightJson(json) {
6
+ const escaped = escapeHtml(json);
7
+ return escaped.replace(/("(?:\\.|[^"\\])*")(\s*:)?|\b(true|false|null)\b|\b(-?\d+(?:\.\d+)?)\b/g, (match, str, colon, keyword, num) => {
8
+ if (str)
9
+ return `<span class="${colon ? 'cs-key' : 'cs-str'}">${str}</span>${colon ?? ''}`;
10
+ if (keyword)
11
+ return `<span class="cs-bool">${keyword}</span>`;
12
+ if (num)
13
+ return `<span class="cs-num">${num}</span>`;
14
+ return match;
15
+ });
16
+ }
@@ -0,0 +1,9 @@
1
+ export interface ScriptCommandHelp {
2
+ /** short hint shown next to the command name */
3
+ description: string;
4
+ /** a single command object, as JSON */
5
+ example: string;
6
+ /** optional longer clarification, shown below the example */
7
+ note?: string;
8
+ }
9
+ export declare const nativeScriptCommandDescriptions: Record<string, ScriptCommandHelp>;
@@ -0,0 +1,154 @@
1
+ export const nativeScriptCommandDescriptions = {
2
+ Comment: {
3
+ description: 'has no effect on script execution',
4
+ example: '{ "type": "Comment", "comment": "explains the next step" }',
5
+ },
6
+ OpenScreen: {
7
+ description: 'navigate to a screen (with history)',
8
+ example: '{ "type": "OpenScreen", "screen": "MyScreen" }',
9
+ },
10
+ OpenDialog: {
11
+ description: 'open a screen as a movable/closable dialog',
12
+ example: '{ "type": "OpenDialog", "screen": "MyScreen", "title": "My Dialog",\n "moveable": true, "closeable": true }',
13
+ },
14
+ CloseDialog: {
15
+ description: 'close the parent dialog this command runs in',
16
+ example: '{ "type": "CloseDialog" }',
17
+ },
18
+ OpenUrl: {
19
+ description: 'open an URL, optionally as an in-app dialog',
20
+ example: '{ "type": "OpenUrl", "url": "https://example.com", "target": "_blank", "openInDialog": false }',
21
+ },
22
+ ShowMessageBox: {
23
+ description: 'ask the user to confirm before continuing',
24
+ example: '{ "type": "ShowMessageBox", "title": "Confirm", "message": "Are you sure?",\n "messageType": "warning", "buttons": "yesNo", "resultSignal": ".Local.Result",\n "exitScriptOnCancel": true }',
25
+ note: 'exitScriptOnCancel: true stops the chain when the user picks a negative button.',
26
+ },
27
+ ShowPrompt: {
28
+ description: 'ask the user for text input',
29
+ example: '{ "type": "ShowPrompt", "title": "Name?", "message": "Enter a name",\n "resultSignal": ".Local.Name", "exitScriptOnCancel": true }',
30
+ },
31
+ SetSignalValue: {
32
+ description: 'write a signal / property',
33
+ example: '{ "type": "SetSignalValue", "signal": ".Some.Signal", "value": true }',
34
+ note: 'target: "signal" (default) | "property" (a screen/control property) | "elementProperty" (a property of the element raising the event).',
35
+ },
36
+ ToggleSignalValue: {
37
+ description: 'toggle a boolean signal / property',
38
+ example: '{ "type": "ToggleSignalValue", "signal": ".Some.Toggle" }',
39
+ },
40
+ ToggleSignalValueThroughList: {
41
+ description: 'cycle a signal / property through a fixed list of values',
42
+ example: '{ "type": "ToggleSignalValueThroughList", "signal": ".Some.Mode", "valueList": [1, 2, 3] }',
43
+ },
44
+ IncrementSignalValue: {
45
+ description: 'increment a numeric signal / property',
46
+ example: '{ "type": "IncrementSignalValue", "signal": ".Some.Counter", "value": 1 }',
47
+ },
48
+ DecrementSignalValue: {
49
+ description: 'decrement a numeric signal / property',
50
+ example: '{ "type": "DecrementSignalValue", "signal": ".Some.Counter", "value": 1 }',
51
+ },
52
+ CalculateSignalValue: {
53
+ description: 'calculate a new signal value from a formula',
54
+ example: '{ "type": "CalculateSignalValue", "targetSignal": ".Some.Result",\n "formula": "{adapter.0.level} * 100 + 30" }',
55
+ note: 'The formula can reference other signals in curly braces: {signalName}.',
56
+ },
57
+ SetBitInSignal: {
58
+ description: 'set a single bit (by number) in a signal / property',
59
+ example: '{ "type": "SetBitInSignal", "signal": ".Some.Bits", "bitNumber": 3 }',
60
+ },
61
+ ClearBitInSignal: {
62
+ description: 'clear a single bit (by number) in a signal / property',
63
+ example: '{ "type": "ClearBitInSignal", "signal": ".Some.Bits", "bitNumber": 3 }',
64
+ },
65
+ ToggleBitInSignal: {
66
+ description: 'toggle a single bit (by number) in a signal / property',
67
+ example: '{ "type": "ToggleBitInSignal", "signal": ".Some.Bits", "bitNumber": 3 }',
68
+ },
69
+ Javascript: {
70
+ description: 'run a JavaScript snippet',
71
+ example: '{ "type": "Javascript", "script": "console.log(context.element)" }',
72
+ note: 'context: { event, element, shadowRoot, instance }.',
73
+ },
74
+ SetElementProperty: {
75
+ description: 'set a property/attribute/CSS value/class on matching elements',
76
+ example: '{ "type": "SetElementProperty", "target": "property", "targetSelectorTarget": "container",\n "targetSelector": ".my-class", "name": "disabled", "value": true }',
77
+ note: 'target: "property" (default) | "attribute" | "css" | "class". targetSelectorTarget: "container" (screen/customControl, default) | "element" (current element).',
78
+ },
79
+ Delay: {
80
+ description: 'pause the script chain',
81
+ example: '{ "type": "Delay", "value": 500 }',
82
+ },
83
+ Console: {
84
+ description: 'write a message to the browser console',
85
+ example: '{ "type": "Console", "target": "log", "message": "done" }',
86
+ note: 'target: "log" (default) | "info" | "debug" | "warn" | "error".',
87
+ },
88
+ SwitchLanguage: {
89
+ description: 'switch the active UI language',
90
+ example: '{ "type": "SwitchLanguage", "language": "en" }',
91
+ },
92
+ Login: {
93
+ description: 'log a user in',
94
+ example: '{ "type": "Login", "username": "user", "password": "pass" }',
95
+ },
96
+ Logout: {
97
+ description: 'log the current user out',
98
+ example: '{ "type": "Logout" }',
99
+ },
100
+ SubscribeSignal: {
101
+ description: 'subscribe to a signal so its updates are pushed to the client',
102
+ example: '{ "type": "SubscribeSignal", "signal": ".Some.Signal", "oneTime": false }',
103
+ },
104
+ UnsubscribeSignal: {
105
+ description: 'unsubscribe from a previously subscribed signal',
106
+ example: '{ "type": "UnsubscribeSignal", "signal": ".Some.Signal" }',
107
+ },
108
+ WriteSignalsInGroup: {
109
+ description: 'write all pending signal values of a named group',
110
+ example: '{ "type": "WriteSignalsInGroup", "group": "MyGroup" }',
111
+ },
112
+ ClearSignalsInGroup: {
113
+ description: 'clear all pending signal values of a named group',
114
+ example: '{ "type": "ClearSignalsInGroup", "group": "MyGroup" }',
115
+ },
116
+ RunScript: {
117
+ description: 'run another named script',
118
+ example: '{ "type": "RunScript", "name": "MyScript", "scriptType": "SimpleScript" }',
119
+ },
120
+ CopySignalValuesFromFolder: {
121
+ description: 'copy signal values from one signal folder to another',
122
+ example: '{ "type": "CopySignalValuesFromFolder", "sourceFolder": ".Source", "destinationFolder": ".Target" }',
123
+ },
124
+ ExportSignalValuesAsJson: {
125
+ description: 'export matching signal values as a downloadable JSON file',
126
+ example: '{ "type": "ExportSignalValuesAsJson", "regex": "^\\\\.Some\\\\..*", "fileName": "export.json" }',
127
+ },
128
+ ImportSignalValuesFromJson: {
129
+ description: 'import signal values from a JSON string',
130
+ example: '{ "type": "ImportSignalValuesFromJson", "data": "{ \\".Some.Signal\\": true }" }',
131
+ },
132
+ Repeat: {
133
+ description: 'jump back to a label a number of times, or indefinitely',
134
+ example: '{ "type": "Repeat", "label": "lbl_loop", "count": 0, "mode": "eventValid" }',
135
+ note: 'mode: "eventValid" (default, repeats until the event is no longer active) | "always" (repeats until count is 0 or indefinitely when count is 0).',
136
+ },
137
+ Condition: {
138
+ description: 'compare two values and jump to a label depending on the result',
139
+ example: '{ "type": "Condition", "value1": {"source":"signal","name":".Is.On"}, "value2": true,\n "comparisonType": "==", "trueGotoLabel": "lbl_off", "falseGotoLabel": "lbl_on" }',
140
+ note: 'comparisonType: ==null | !=null | ==true | ==false | == | != | > | < | >= | <= | && | ||.',
141
+ },
142
+ Exit: {
143
+ description: 'stop executing the current script chain',
144
+ example: '{ "type": "Exit" }',
145
+ },
146
+ Label: {
147
+ description: 'a named jump target for Condition / Goto / Repeat',
148
+ example: '{ "type": "Label", "label": "lbl_on" }',
149
+ },
150
+ Goto: {
151
+ description: 'jump unconditionally to a label',
152
+ example: '{ "type": "Goto", "label": "lbl_on" }',
153
+ },
154
+ };
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.144",
4
+ "version": "0.1.146",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "author": "jochen.kuehner@gmx.de",
@@ -14,7 +14,7 @@
14
14
  "bundle": "esbuild ./dist/index.js --format=esm --minify --external:@node-projects/css-parser --external:@blockly/* --external:blockly --external:long --external:wunderbaum --external:@node-projects/* --platform=neutral --bundle --outfile=./dist/index-min.js"
15
15
  },
16
16
  "dependencies": {
17
- "@blockly/zoom-to-fit": ">=6.0.9",
17
+ "@blockly/zoom-to-fit": ">=13.0.0",
18
18
  "@node-projects/base-custom-webcomponent": ">=0.27.8",
19
19
  "@node-projects/css-parser": "^5.2.0",
20
20
  "@node-projects/propertygrid.webcomponent": ">=1.2.3",
@@ -22,7 +22,7 @@
22
22
  "@node-projects/web-component-designer": ">=0.1.224",
23
23
  "@node-projects/web-component-designer-codeview-monaco": ">=0.1.32",
24
24
  "@node-projects/web-component-designer-widgets-wunderbaum": ">=0.1.29",
25
- "blockly": ">=11.1.1",
25
+ "blockly": ">=13.0.0",
26
26
  "long": ">=5.2.3"
27
27
  },
28
28
  "devDependencies": {