@digo-org/digo-api 1.0.18 → 1.0.20

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.18",
4
+ "version": "1.0.20",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
7
7
  "types": "src/index.ts",
package/src/digo-asset.ts CHANGED
@@ -2,6 +2,8 @@ import { ReactNode } from 'react';
2
2
  import { SingleParameterValue } from 'src/types';
3
3
 
4
4
  export abstract class DigoAsset {
5
+ protected rootElement: any = null;
6
+
5
7
  constructor() {
6
8
  this.handleMessage = this.handleMessage.bind(this);
7
9
 
@@ -12,8 +14,21 @@ export abstract class DigoAsset {
12
14
  window.removeEventListener('message', this.handleMessage);
13
15
  }
14
16
 
17
+ public setRootElement(element: any): void {
18
+ this.rootElement = element;
19
+
20
+ this.updateUI();
21
+ }
22
+
23
+ public updateUI(): void {
24
+ if (!this.rootElement) return;
25
+
26
+ this.rootElement.render(this.render());
27
+ }
28
+
15
29
  private handleMessage(event: MessageEvent): void {
16
30
  const message = event.data;
31
+ console.log(message);
17
32
 
18
33
  if (message && message.command === 'SET_PARAMETER' && message.value) {
19
34
  const parameterId = message.parameterId;
@@ -30,6 +45,7 @@ export abstract class DigoAsset {
30
45
  this.onParameterChange(parameterId, entityId, value, isGlobal);
31
46
  }
32
47
  }
48
+ this.updateUI();
33
49
  }
34
50
 
35
51
  onParameterChange?(parameterId: string, entityId: string, value: SingleParameterValue, isGlobal: boolean): void;
package/src/types.ts CHANGED
@@ -4,7 +4,7 @@ export interface VizAsset {
4
4
  description: string;
5
5
  tags: string[];
6
6
  definition: VizAssetDefinition;
7
- template_id: string;
7
+ files: VizAssetFiles;
8
8
  last_updated: string;
9
9
  }
10
10
 
@@ -13,6 +13,17 @@ export interface VizAssetDefinition {
13
13
  instances: Instance[];
14
14
  }
15
15
 
16
+ export type VizAssetParameters = VizParameterProperties[];
17
+
18
+ export interface VizAssetFile {
19
+ code: string;
20
+ hidden?: boolean;
21
+ active?: boolean;
22
+ readOnly?: boolean;
23
+ }
24
+
25
+ export type VizAssetFiles = Record<string, VizAssetFile>;
26
+
16
27
  export interface Instance {
17
28
  id: string;
18
29
  [parameterId: string]: SingleParameterValue;