@node-projects/web-component-designer-visualization-addons 0.1.0
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/README.md +19 -0
- package/dist/blockly/BlocklyJavascriptHelper.d.ts +2 -0
- package/dist/blockly/BlocklyJavascriptHelper.js +35 -0
- package/dist/blockly/BlocklyScriptEditor.d.ts +16 -0
- package/dist/blockly/BlocklyScriptEditor.js +106 -0
- package/dist/blockly/BlocklyToolbox.d.ts +1117 -0
- package/dist/blockly/BlocklyToolbox.js +980 -0
- package/dist/blockly/components/Console.d.ts +0 -0
- package/dist/blockly/components/Console.js +26 -0
- package/dist/blockly/components/Debugger.d.ts +0 -0
- package/dist/blockly/components/Debugger.js +15 -0
- package/dist/blockly/components/GetState.d.ts +0 -0
- package/dist/blockly/components/GetState.js +21 -0
- package/dist/blockly/components/GetSubProperty.d.ts +0 -0
- package/dist/blockly/components/GetSubProperty.js +27 -0
- package/dist/blockly/components/OpenScreen.d.ts +0 -0
- package/dist/blockly/components/OpenScreen.js +31 -0
- package/dist/blockly/components/QuerySelector.d.ts +0 -0
- package/dist/blockly/components/QuerySelector.js +30 -0
- package/dist/blockly/components/QuerySelectorAll.d.ts +0 -0
- package/dist/blockly/components/QuerySelectorAll.js +30 -0
- package/dist/blockly/components/Return.d.ts +0 -0
- package/dist/blockly/components/Return.js +21 -0
- package/dist/blockly/components/SetElement.d.ts +0 -0
- package/dist/blockly/components/SetElement.js +44 -0
- package/dist/blockly/components/SetState.d.ts +0 -0
- package/dist/blockly/components/SetState.js +26 -0
- package/dist/blockly/components/StartEvent.d.ts +0 -0
- package/dist/blockly/components/StartEvent.js +23 -0
- package/dist/blockly/components/components.d.ts +11 -0
- package/dist/blockly/components/components.js +11 -0
- package/dist/blockly/components/fields/FieldObjectId.d.ts +1 -0
- package/dist/blockly/components/fields/FieldObjectId.js +6 -0
- package/dist/components/BindingsEditor.d.ts +49 -0
- package/dist/components/BindingsEditor.js +298 -0
- package/dist/components/BindingsEditorHistoric.d.ts +14 -0
- package/dist/components/BindingsEditorHistoric.js +97 -0
- package/dist/components/PropertyGridExt.d.ts +0 -0
- package/dist/components/PropertyGridExt.js +1 -0
- package/dist/components/ScriptEditor.d.ts +28 -0
- package/dist/components/ScriptEditor.js +254 -0
- package/dist/components/VisualizationPropertyGrid.d.ts +12 -0
- package/dist/components/VisualizationPropertyGrid.js +104 -0
- package/dist/helpers/BindingsHelper.d.ts +47 -0
- package/dist/helpers/BindingsHelper.js +642 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +22 -0
- package/dist/interfaces/IScriptMultiplexValue.d.ts +15 -0
- package/dist/interfaces/IScriptMultiplexValue.js +15 -0
- package/dist/interfaces/VisualisationElementScript.d.ts +5 -0
- package/dist/interfaces/VisualisationElementScript.js +1 -0
- package/dist/interfaces/VisualizationBinding.d.ts +20 -0
- package/dist/interfaces/VisualizationBinding.js +4 -0
- package/dist/interfaces/VisualizationHandler.d.ts +24 -0
- package/dist/interfaces/VisualizationHandler.js +2 -0
- package/dist/interfaces/VisualizationShell.d.ts +13 -0
- package/dist/interfaces/VisualizationShell.js +1 -0
- package/dist/interfaces/VisualizationUiHandler.d.ts +5 -0
- package/dist/interfaces/VisualizationUiHandler.js +2 -0
- package/dist/scripting/Script.d.ts +6 -0
- package/dist/scripting/Script.js +5 -0
- package/dist/scripting/ScriptCommands.d.ts +192 -0
- package/dist/scripting/ScriptCommands.js +1 -0
- package/dist/scripting/ScriptSystem.d.ts +23 -0
- package/dist/scripting/ScriptSystem.js +224 -0
- package/dist/services/BindableObjectDragDropService.d.ts +16 -0
- package/dist/services/BindableObjectDragDropService.js +145 -0
- package/dist/services/BindingsService.d.ts +11 -0
- package/dist/services/BindingsService.js +46 -0
- package/dist/services/PropertyGridDragDropService.d.ts +7 -0
- package/dist/services/PropertyGridDragDropService.js +10 -0
- package/dist/services/ScriptRefactorService.d.ts +9 -0
- package/dist/services/ScriptRefactorService.js +79 -0
- package/dist/services/SignalPropertyEditor.d.ts +7 -0
- package/dist/services/SignalPropertyEditor.js +43 -0
- package/dist/setupVisuService.d.ts +0 -0
- package/dist/setupVisuService.js +1 -0
- package/package.json +29 -0
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# web-component-designer-visualization-addons
|
|
2
|
+
|
|
3
|
+
## NPM Package
|
|
4
|
+
|
|
5
|
+
https://www.npmjs.com/package/@node-projects/web-component-designer-visualization-addons
|
|
6
|
+
|
|
7
|
+
npm i @node-projects/web-component-designer-visualization-addons
|
|
8
|
+
|
|
9
|
+
## Description
|
|
10
|
+
|
|
11
|
+
This package contains basic elements for a custom visualization, like a script system, a bindings system, ...
|
|
12
|
+
It is used for example by the iobroker.webui.
|
|
13
|
+
|
|
14
|
+
## Dependencies
|
|
15
|
+
|
|
16
|
+
- long
|
|
17
|
+
- blockly
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//import Blockly from 'blockly';
|
|
2
|
+
import './components/components.js';
|
|
3
|
+
//TODO: remove imports, only leave Runtime
|
|
4
|
+
const prefix = `function extractPart(obj: any, propertyPath: string) {
|
|
5
|
+
let retVal = obj;
|
|
6
|
+
for (let p of propertyPath.split('.')) {
|
|
7
|
+
retVal = retVal?.[p];
|
|
8
|
+
}
|
|
9
|
+
return retVal;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export async function run(eventData, shadowRoot) {
|
|
13
|
+
`;
|
|
14
|
+
const postfix = `}`;
|
|
15
|
+
export async function generateEventCodeFromBlockly(data) {
|
|
16
|
+
//@ts-ignore
|
|
17
|
+
const workspace = new Blockly.Workspace();
|
|
18
|
+
//@ts-ignore
|
|
19
|
+
Blockly.serialization.workspaces.load(data, workspace);
|
|
20
|
+
//@ts-ignore
|
|
21
|
+
Blockly.JavaScript.addReservedWords('eventData');
|
|
22
|
+
//@ts-ignore
|
|
23
|
+
Blockly.JavaScript.addReservedWords('shadowRoot');
|
|
24
|
+
//@ts-ignore
|
|
25
|
+
Blockly.JavaScript.addReservedWords('extractPart');
|
|
26
|
+
//@ts-ignore
|
|
27
|
+
Blockly.JavaScript.addReservedWords('IOB');
|
|
28
|
+
//@ts-ignore
|
|
29
|
+
Blockly.JavaScript.addReservedWords('RUNTIME');
|
|
30
|
+
//@ts-ignore
|
|
31
|
+
let code = Blockly.JavaScript.workspaceToCode(workspace);
|
|
32
|
+
const scriptUrl = URL.createObjectURL(new Blob([prefix + code + postfix], { type: 'application/javascript' }));
|
|
33
|
+
const scripObj = await import(scriptUrl);
|
|
34
|
+
return scripObj.run;
|
|
35
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseCustomWebComponentConstructorAppend } from '@node-projects/base-custom-webcomponent';
|
|
2
|
+
export declare class BlocklyScriptEditor extends BaseCustomWebComponentConstructorAppend {
|
|
3
|
+
static readonly template: HTMLTemplateElement;
|
|
4
|
+
static readonly style: CSSStyleSheet;
|
|
5
|
+
static readonly is = "node-projects-blockly-script-editor";
|
|
6
|
+
blocklyDiv: HTMLDivElement;
|
|
7
|
+
workspace: any;
|
|
8
|
+
static blocklyStyle1: CSSStyleSheet;
|
|
9
|
+
static blocklyStyle2: CSSStyleSheet;
|
|
10
|
+
resizeObserver: ResizeObserver;
|
|
11
|
+
constructor();
|
|
12
|
+
createBlockly(): void;
|
|
13
|
+
ready(): void;
|
|
14
|
+
save(): any;
|
|
15
|
+
load(data: any): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { BaseCustomWebComponentConstructorAppend, html, css } from '@node-projects/base-custom-webcomponent';
|
|
2
|
+
import toolbox from './BlocklyToolbox.js';
|
|
3
|
+
//import Blockly from 'blockly';
|
|
4
|
+
export class BlocklyScriptEditor extends BaseCustomWebComponentConstructorAppend {
|
|
5
|
+
static template = html `
|
|
6
|
+
<div id="blocklyDiv" style="position: absolute; width: 100%; height: 100%;"></div>
|
|
7
|
+
`;
|
|
8
|
+
static style = css `
|
|
9
|
+
:host {
|
|
10
|
+
box-sizing: border-box;
|
|
11
|
+
position: absolute;
|
|
12
|
+
height: 100%;
|
|
13
|
+
width: 100%;
|
|
14
|
+
}`;
|
|
15
|
+
static is = 'node-projects-blockly-script-editor';
|
|
16
|
+
blocklyDiv;
|
|
17
|
+
workspace;
|
|
18
|
+
static blocklyStyle1;
|
|
19
|
+
static blocklyStyle2;
|
|
20
|
+
resizeObserver;
|
|
21
|
+
constructor() {
|
|
22
|
+
super();
|
|
23
|
+
super._restoreCachedInititalValues();
|
|
24
|
+
this.blocklyDiv = this._getDomElement('blocklyDiv');
|
|
25
|
+
this._assignEvents();
|
|
26
|
+
this.createBlockly();
|
|
27
|
+
}
|
|
28
|
+
createBlockly() {
|
|
29
|
+
const renderer = 'zelos';
|
|
30
|
+
const themename = 'webui';
|
|
31
|
+
//@ts-ignore
|
|
32
|
+
const theme = Blockly.Theme.defineTheme(themename, {
|
|
33
|
+
//@ts-ignore
|
|
34
|
+
'base': Blockly.Themes.Classic,
|
|
35
|
+
'blockStyles': {
|
|
36
|
+
"hat_blocks": {
|
|
37
|
+
"colourPrimary": "#4a148c"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
'categoryStyles': {
|
|
41
|
+
'start_category': {
|
|
42
|
+
colour: '#4a148c'
|
|
43
|
+
},
|
|
44
|
+
'system_category': {
|
|
45
|
+
colour: '#01579b',
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
//@ts-ignore
|
|
50
|
+
this.workspace = Blockly.inject(this.blocklyDiv, {
|
|
51
|
+
theme: theme,
|
|
52
|
+
toolbox: toolbox,
|
|
53
|
+
renderer: renderer,
|
|
54
|
+
trashcan: true,
|
|
55
|
+
zoom: {
|
|
56
|
+
controls: true,
|
|
57
|
+
wheel: false,
|
|
58
|
+
startScale: 0.7,
|
|
59
|
+
maxScale: 3,
|
|
60
|
+
minScale: 0.3,
|
|
61
|
+
scaleSpeed: 1.2,
|
|
62
|
+
pinch: false
|
|
63
|
+
},
|
|
64
|
+
move: {
|
|
65
|
+
scrollbars: {
|
|
66
|
+
horizontal: true,
|
|
67
|
+
vertical: true
|
|
68
|
+
},
|
|
69
|
+
drag: true,
|
|
70
|
+
wheel: true
|
|
71
|
+
},
|
|
72
|
+
maxInstances: { 'start_event': 1 },
|
|
73
|
+
});
|
|
74
|
+
if (!BlocklyScriptEditor.blocklyStyle1) {
|
|
75
|
+
BlocklyScriptEditor.blocklyStyle1 = new CSSStyleSheet();
|
|
76
|
+
//@ts-ignore
|
|
77
|
+
BlocklyScriptEditor.blocklyStyle1.replaceSync(document.getElementById('blockly-renderer-style-' + renderer + '-' + themename).innerText);
|
|
78
|
+
BlocklyScriptEditor.blocklyStyle2 = new CSSStyleSheet();
|
|
79
|
+
//@ts-ignore
|
|
80
|
+
BlocklyScriptEditor.blocklyStyle2.replaceSync(document.getElementById('blockly-common-style').innerText);
|
|
81
|
+
}
|
|
82
|
+
this.shadowRoot.adoptedStyleSheets = [BlocklyScriptEditor.blocklyStyle1, BlocklyScriptEditor.blocklyStyle2, BlocklyScriptEditor.style];
|
|
83
|
+
//@ts-ignore
|
|
84
|
+
const zoomToFit = new ZoomToFitControl(this.workspace);
|
|
85
|
+
zoomToFit.init();
|
|
86
|
+
}
|
|
87
|
+
ready() {
|
|
88
|
+
//@ts-ignore
|
|
89
|
+
Blockly.svgResize(this.workspace);
|
|
90
|
+
this.resizeObserver = new ResizeObserver((entries) => {
|
|
91
|
+
//@ts-ignore
|
|
92
|
+
Blockly.svgResize(this.workspace);
|
|
93
|
+
});
|
|
94
|
+
this.resizeObserver.observe(this);
|
|
95
|
+
}
|
|
96
|
+
save() {
|
|
97
|
+
//@ts-ignore
|
|
98
|
+
const state = Blockly.serialization.workspaces.save(this.workspace);
|
|
99
|
+
return state;
|
|
100
|
+
}
|
|
101
|
+
load(data) {
|
|
102
|
+
//@ts-ignore
|
|
103
|
+
Blockly.serialization.workspaces.load(data, this.workspace);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
customElements.define(BlocklyScriptEditor.is, BlocklyScriptEditor);
|