@node-projects/web-component-designer-visualization-addons 0.1.72 → 0.1.74

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.
@@ -196,19 +196,20 @@ export interface SetElementProperty {
196
196
  */
197
197
  target: 'property' | 'attribute' | 'css' | 'class';
198
198
  /**
199
- * where to search for the elements.
200
- * element
199
+ * where to search for the elements (used as a start)
200
+ * element = currentElement
201
201
  * container = screen or customControl
202
202
  * @default container
203
203
  */
204
204
  targetSelectorTarget: 'container' | 'element';
205
205
  /**
206
206
  * wich parent, 0 = current, 1 = first parent, 2 = ...
207
+ * of the targetSelectorTarget
207
208
  * @default 0
208
209
  */
209
210
  parentIndex: number;
210
211
  /**
211
- * css selector to find elements, if empty the targetSelectorTarget is used
212
+ * css selector to find elements on targetSelectorTarget, if empty the targetSelectorTarget directly is used
212
213
  */
213
214
  targetSelector: string;
214
215
  /**
@@ -100,12 +100,12 @@ export class ScriptSystem {
100
100
  break;
101
101
  }
102
102
  case 'Delay': {
103
- const value = await this.getValue(command.value, context);
103
+ const value = await this.getValue(command.value ?? 500, context);
104
104
  await sleep(value);
105
105
  break;
106
106
  }
107
107
  case 'Console': {
108
- const target = await this.getValue(command.target, context);
108
+ const target = await this.getValue(command.target ?? 'log', context);
109
109
  const message = await this.getValue(command.message, context);
110
110
  console[target](message);
111
111
  break;
@@ -143,16 +143,18 @@ export class ScriptSystem {
143
143
  }
144
144
  case 'SetBitInSignal': {
145
145
  const signal = await this.getValue(command.signal, context);
146
+ const bitNumber = await this.getValue(command.bitNumber ?? 0, context);
146
147
  let state = await this._visualizationHandler.getState(this.getSignaName(signal, context));
147
- let mask = Long.fromNumber(1).shiftLeft(command.bitNumber);
148
+ let mask = Long.fromNumber(1).shiftLeft(bitNumber);
148
149
  const newVal = Long.fromNumber(state.val).or(mask).toNumber();
149
150
  await this._visualizationHandler.setState(this.getSignaName(signal, context), newVal);
150
151
  break;
151
152
  }
152
153
  case 'ClearBitInSignal': {
153
154
  const signal = await this.getValue(command.signal, context);
155
+ const bitNumber = await this.getValue(command.bitNumber ?? 0, context);
154
156
  let state = await this._visualizationHandler.getState(this.getSignaName(signal, context));
155
- let mask = Long.fromNumber(1).shiftLeft(command.bitNumber);
157
+ let mask = Long.fromNumber(1).shiftLeft(bitNumber);
156
158
  mask.negate();
157
159
  const newVal = Long.fromNumber(state.val).and(mask).toNumber();
158
160
  await this._visualizationHandler.setState(this.getSignaName(signal, context), newVal);
@@ -160,8 +162,9 @@ export class ScriptSystem {
160
162
  }
161
163
  case 'ToggleBitInSignal': {
162
164
  const signal = await this.getValue(command.signal, context);
165
+ const bitNumber = await this.getValue(command.bitNumber ?? 0, context);
163
166
  let state = await this._visualizationHandler.getState(this.getSignaName(signal, context));
164
- let mask = Long.fromNumber(1).shiftLeft(command.bitNumber);
167
+ let mask = Long.fromNumber(1).shiftLeft(bitNumber);
165
168
  const newVal = Long.fromNumber(state.val).xor(mask).toNumber();
166
169
  await this._visualizationHandler.setState(this.getSignaName(signal, context), newVal);
167
170
  break;
@@ -181,23 +184,27 @@ export class ScriptSystem {
181
184
  command = ScriptUpgrades.upgradeSetElementProperty(command);
182
185
  const name = await this.getValue(command.name, context);
183
186
  const value = await this.getValue(command.value, context);
184
- const parentIndex = await this.getValue(command.parentIndex, context);
185
- let elements = this.getTargetFromTargetSelector(context, command.targetSelectorTarget, parentIndex, command.targetSelector);
187
+ const parentIndex = await this.getValue(command.parentIndex ?? 0, context);
188
+ const target = await this.getValue(command.target ?? 'property', context);
189
+ const targetSelectorTarget = await this.getValue(command.targetSelectorTarget ?? 'property', context);
190
+ const targetSelector = await this.getValue(command.targetSelector ?? 'container', context);
191
+ const mode = await this.getValue(command.mode, context);
192
+ let elements = this.getTargetFromTargetSelector(context, targetSelectorTarget, parentIndex, targetSelector);
186
193
  for (let e of elements) {
187
- if (command.target == 'attribute') {
194
+ if (target == 'attribute') {
188
195
  e.setAttribute(name, value);
189
196
  }
190
- else if (command.target == 'property') {
197
+ else if (target == 'property') {
191
198
  e[name] = value;
192
199
  }
193
- else if (command.target == 'css') {
200
+ else if (target == 'css') {
194
201
  e.style[name] = value;
195
202
  }
196
- else if (command.target == 'class') {
197
- if (command.mode === 'toggle') {
203
+ else if (target == 'class') {
204
+ if (mode === 'toggle') {
198
205
  e.classList.toggle(value);
199
206
  }
200
- else if (command.mode === 'remove') {
207
+ else if (mode === 'remove') {
201
208
  e.classList.remove(value);
202
209
  }
203
210
  else {
@@ -3,6 +3,7 @@ import { BindingsHelper } from "../helpers/BindingsHelper.js";
3
3
  export declare class VisualizationBindingsService implements IBindingService {
4
4
  constructor(bindingsHelper: BindingsHelper);
5
5
  private _bindingsHelper;
6
+ static type: string;
6
7
  getBindings(designItem: IDesignItem): (IBinding & {
7
8
  converter: Record<string, any>;
8
9
  })[];
@@ -4,6 +4,7 @@ export class VisualizationBindingsService {
4
4
  this._bindingsHelper = bindingsHelper;
5
5
  }
6
6
  _bindingsHelper;
7
+ static type = 'visualization-binding';
7
8
  getBindings(designItem) {
8
9
  const iobBindings = Array.from(this._bindingsHelper.getBindings(designItem.element));
9
10
  return iobBindings.map(x => ({
@@ -15,7 +16,9 @@ export class VisualizationBindingsService {
15
16
  expression: x[1].expression,
16
17
  expressionTwoWay: x[1].expressionTwoWay,
17
18
  converter: x[1].converter,
18
- type: x[1].type,
19
+ //type: x[1].type,
20
+ type: VisualizationBindingsService.type,
21
+ service: this,
19
22
  changedEvents: x[1].events,
20
23
  historic: x[1].historic,
21
24
  writeBackSignal: x[1].writeBackSignal,
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.72",
4
+ "version": "0.1.74",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "author": "jochen.kuehner@gmx.de",