@digo-org/digo-api 1.0.26 → 1.0.28

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@digo-org/digo-api",
3
3
  "private": false,
4
- "version": "1.0.26",
4
+ "version": "1.0.28",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
7
7
  "types": "src/index.ts",
package/src/constants.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export const API_MESSAGES = {
2
- setParameter: 'SET_PARAMETER',
3
- updateInstances: 'UPDATE_INSTANCES',
2
+ setParameter: 'SET_PARAMETER',
3
+ updateInstances: 'UPDATE_INSTANCES',
4
+ updateDefinition: 'UPDATE_DEFINITION',
4
5
  };
5
6
 
6
7
  export const KAKA = 'DIGO API';
package/src/digo-asset.ts CHANGED
@@ -1,11 +1,12 @@
1
- import { ReactNode } from 'react';
2
- import { API_MESSAGES } from '@digo-org/digo-api/src/constants';
3
- import { Instance, SingleParameterValue } from '@digo-org/digo-api/src/types';
1
+ import { API_MESSAGES } from '@digo-org/digo-api/src/constants';
2
+ import { Instance, ParametersValue, VizAssetDefinition } from '@digo-org/digo-api/src/types';
4
3
 
5
- export abstract class DigoAsset {
6
- protected rootElement: any = null;
4
+ import { ReactNode } from 'react';
7
5
 
8
- protected instances: Instance[] = [];
6
+ export abstract class DigoAsset {
7
+ protected rootElement: any = null;
8
+ protected instances: Instance[] = [];
9
+ protected globalParameters: ParametersValue = {};
9
10
 
10
11
  constructor() {
11
12
  this.handleMessage = this.handleMessage.bind(this);
@@ -35,39 +36,14 @@ export abstract class DigoAsset {
35
36
  if (!message) return;
36
37
 
37
38
  switch (message.command) {
38
- case API_MESSAGES.setParameter:{
39
- const parameterId = message.parameterId;
40
- const value = message.value;
41
- const isGlobal = message.isGlobal;
42
- const entityId = message.entityId;
43
-
44
- if (isGlobal) {
45
- this.onGlobalParameterChange(parameterId, value);
46
- } else {
47
- this.onEntityParameterChange(parameterId, entityId, value);
48
- }
49
-
50
- if (this.onParameterChange) this.onParameterChange(parameterId, entityId, value, isGlobal);
51
-
52
- break;
53
- }
54
-
55
- case API_MESSAGES.updateInstances:
56
- this.instances = message.instances;
57
-
58
- if (this.onInstancesUpdated) this.onInstancesUpdated();
59
-
39
+ case API_MESSAGES.updateDefinition:
40
+ this.instances = (message.definition as VizAssetDefinition).instances;
41
+ this.globalParameters = (message.definition as VizAssetDefinition).globalParameters;
60
42
  break;
61
43
  }
62
44
 
63
45
  this.updateUI();
64
46
  }
65
47
 
66
- onParameterChange?(parameterId: string, entityId: string, value: SingleParameterValue, isGlobal: boolean): void;
67
- onInstancesUpdated?(): void;
68
-
69
- abstract onGlobalParameterChange(parameterId: string, value: SingleParameterValue): void;
70
- abstract onEntityParameterChange(parameterId: string, entityId: string, value: SingleParameterValue): void;
71
-
72
48
  abstract render(): ReactNode;
73
49
  }