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