@sigmacomputing/plugin 1.0.2 → 1.0.3
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/dist/client/initialize.d.ts +1 -1
- package/dist/client/initialize.d.ts.map +1 -1
- package/dist/client/initialize.js +1 -1
- package/dist/client.d.ts +2 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +5 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/{client/react → react}/Context.d.ts +1 -1
- package/dist/react/Context.d.ts.map +1 -0
- package/dist/{client/react → react}/Context.js +1 -1
- package/dist/{client/react → react}/Provider.d.ts +1 -1
- package/dist/react/Provider.d.ts.map +1 -0
- package/dist/{client/react → react}/Provider.js +0 -0
- package/dist/{client/react → react}/hooks.d.ts +1 -1
- package/dist/{client/react → react}/hooks.d.ts.map +1 -1
- package/dist/{client/react → react}/hooks.js +1 -1
- package/dist/react.d.ts +3 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/{client/react/index.js → react.js} +2 -4
- package/package.json +6 -16
- package/dist/client/index.d.ts +0 -4
- package/dist/client/index.d.ts.map +0 -1
- package/dist/client/index.js +0 -6
- package/dist/client/react/Context.d.ts.map +0 -1
- package/dist/client/react/Provider.d.ts.map +0 -1
- package/dist/client/react/index.d.ts +0 -5
- package/dist/client/react/index.d.ts.map +0 -1
- package/src/client/index.ts +0 -5
- package/src/client/initialize.ts +0 -199
- package/src/client/react/Context.ts +0 -6
- package/src/client/react/Provider.tsx +0 -19
- package/src/client/react/hooks.ts +0 -178
- package/src/client/react/index.tsx +0 -9
- package/src/index.ts +0 -2
- package/src/types.ts +0 -322
- package/src/utils/deepEqual.ts +0 -23
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.d.ts","sourceRoot":"","sources":["../../src/client/initialize.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EAKf,
|
|
1
|
+
{"version":3,"file":"initialize.d.ts","sourceRoot":"","sources":["../../src/client/initialize.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EAKf,MAAM,UAAU,CAAC;AAElB,wBAAgB,UAAU,CAAC,CAAC,GAAG,EAAE,KAAK,cAAc,CAAC,CAAC,CAAC,CA6LtD"}
|
|
@@ -21,7 +21,7 @@ function initialize() {
|
|
|
21
21
|
emit('config', (_a = pluginConfig.config) !== null && _a !== void 0 ? _a : {});
|
|
22
22
|
});
|
|
23
23
|
// send initialize event
|
|
24
|
-
void execPromise('wb:plugin:init', require(
|
|
24
|
+
void execPromise('wb:plugin:init', require('../../package.json').version).then(config => {
|
|
25
25
|
Object.assign(pluginConfig, config);
|
|
26
26
|
emit('init', pluginConfig);
|
|
27
27
|
emit('config', pluginConfig.config);
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,sCAAe,CAAC"}
|
package/dist/client.js
ADDED
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -14,5 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./client"), exports);
|
|
18
17
|
__exportStar(require("./types"), exports);
|
|
18
|
+
__exportStar(require("./react"), exports);
|
|
19
|
+
__exportStar(require("./client"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../src/react/Context.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,eAAO,MAAM,aAAa,8CAAwC,CAAC"}
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PluginContext = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
-
const client_1 = require("
|
|
5
|
+
const client_1 = require("../client");
|
|
6
6
|
exports.PluginContext = (0, react_1.createContext)(client_1.client);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../src/react/Provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,WAAW,wBAAwB,CAAC,CAAC,GAAG,GAAG;IAC/C,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;IAC1B,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,wBAAgB,mBAAmB,CAAC,CAAC,GAAG,GAAG,EACzC,KAAK,EAAE,wBAAwB,CAAC,CAAC,CAAC,eAOnC"}
|
|
File without changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PluginInstance, CustomPluginConfigOptions, WorkbookElementColumns, WorkbookElementData, WorkbookVariable } from
|
|
1
|
+
import { PluginInstance, CustomPluginConfigOptions, WorkbookElementColumns, WorkbookElementData, WorkbookVariable } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* Gets the entire plugin instance
|
|
4
4
|
* @returns {PluginInstance} Context for the current plugin instance
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/react/hooks.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,cAAc,EACd,yBAAyB,EACzB,sBAAsB,EACtB,mBAAmB,EAEnB,gBAAgB,EACjB,MAAM,UAAU,CAAC;AAGlB;;;GAGG;AACH,wBAAgB,SAAS,IAAI,cAAc,CAAC,GAAG,CAAC,CAE/C;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,yBAAyB,EAAE,GACvC,IAAI,CAWN;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,YAAY,EAAE,OAAO,GACpB,CAAC,OAAO,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC,CAezC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,sBAAsB,CAWpE;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,mBAAmB,CAW9D;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,GAAG,CAmB3C;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,EAAE,EAAE,MAAM,GACT,CAAC,gBAAgB,GAAG,SAAS,EAAE,QAAQ,CAAC,CAc1C;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,EAAE,EAAE,MAAM,EACV,SAAS,EAAE,MAAM,GAChB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAoBrB"}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useInteraction = exports.useVariable = exports.useConfig = exports.useElementData = exports.useElementColumns = exports.useLoadingState = exports.useEditorPanelConfig = exports.usePlugin = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const Context_1 = require("./Context");
|
|
6
|
-
const deepEqual_1 = require("
|
|
6
|
+
const deepEqual_1 = require("../utils/deepEqual");
|
|
7
7
|
/**
|
|
8
8
|
* Gets the entire plugin instance
|
|
9
9
|
* @returns {PluginInstance} Context for the current plugin instance
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,OAAO,EACL,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,kBAAkB,CAAC"}
|
|
@@ -15,8 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.SigmaClientProvider = void 0;
|
|
18
|
-
__exportStar(require("
|
|
19
|
-
|
|
20
|
-
var Provider_1 = require("./Provider");
|
|
18
|
+
__exportStar(require("./react/hooks"), exports);
|
|
19
|
+
var Provider_1 = require("./react/Provider");
|
|
21
20
|
Object.defineProperty(exports, "SigmaClientProvider", { enumerable: true, get: function () { return Provider_1.SigmaClientProvider; } });
|
|
22
|
-
__exportStar(require("../../types"), exports);
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sigmacomputing/plugin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Sigma Computing Plugin Client API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/sigmacomputing/plugin",
|
|
7
|
+
"main": "./dist/index.js",
|
|
7
8
|
"repository": {
|
|
8
9
|
"type": "git",
|
|
9
10
|
"url": "https://github.com/sigmacomputing/plugin.git"
|
|
@@ -12,23 +13,13 @@
|
|
|
12
13
|
"email": "support@sigmacomputing.com",
|
|
13
14
|
"url": "https://github.com/sigmacomputing/plugin/issues"
|
|
14
15
|
},
|
|
15
|
-
"module": "./src/index.ts",
|
|
16
|
-
"main": "./dist/index.js",
|
|
17
|
-
"types": "./dist/index.d.ts",
|
|
18
16
|
"files": [
|
|
19
|
-
"
|
|
20
|
-
"/src",
|
|
21
|
-
"!/src/**/__tests__/**"
|
|
17
|
+
"dist/*"
|
|
22
18
|
],
|
|
23
|
-
"exports": {
|
|
24
|
-
".": "./dist/index.js",
|
|
25
|
-
"./react": "./dist/client/react/index.js",
|
|
26
|
-
"./package.json": "./package.json"
|
|
27
|
-
},
|
|
28
19
|
"typesVersions": {
|
|
29
20
|
"*": {
|
|
30
21
|
"react": [
|
|
31
|
-
"dist/
|
|
22
|
+
"dist/react/index.d.ts"
|
|
32
23
|
]
|
|
33
24
|
}
|
|
34
25
|
},
|
|
@@ -44,7 +35,8 @@
|
|
|
44
35
|
"tsc": "ttsc --build tsconfig.build.json"
|
|
45
36
|
},
|
|
46
37
|
"peerDependencies": {
|
|
47
|
-
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
|
38
|
+
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
|
39
|
+
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
|
48
40
|
},
|
|
49
41
|
"devDependencies": {
|
|
50
42
|
"@jest/types": "^27.5.1",
|
|
@@ -56,8 +48,6 @@
|
|
|
56
48
|
"jest-watch-typeahead": "^2.1.1",
|
|
57
49
|
"lint-staged": "^13.0.3",
|
|
58
50
|
"prettier": "^2.7.1",
|
|
59
|
-
"react": "^18.2.0",
|
|
60
|
-
"react-dom": "^18.2.0",
|
|
61
51
|
"ts-jest": "^27.1.4",
|
|
62
52
|
"ts-node": "^10.9.1",
|
|
63
53
|
"ttypescript": "^1.5.13",
|
package/dist/client/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,qBAA0B;AAE/C,eAAO,MAAM,MAAM,iCAAe,CAAC;AAEnC,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
package/dist/client/index.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.initialize = exports.client = void 0;
|
|
4
|
-
const initialize_1 = require("./initialize");
|
|
5
|
-
Object.defineProperty(exports, "initialize", { enumerable: true, get: function () { return initialize_1.initialize; } });
|
|
6
|
-
exports.client = (0, initialize_1.initialize)();
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../../src/client/react/Context.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,cAAc,EAAE,oBAAc;AAEvC,eAAO,MAAM,aAAa,8CAAwC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/client/react/Provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,EAAE,cAAc,EAAE,oBAAc;AAEvC,MAAM,WAAW,wBAAwB,CAAC,CAAC,GAAG,GAAG;IAC/C,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;IAC1B,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,wBAAgB,mBAAmB,CAAC,CAAC,GAAG,GAAG,EACzC,KAAK,EAAE,wBAAwB,CAAC,CAAC,CAAC,eAOnC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/react/index.tsx"],"names":[],"mappings":"AAAA,mBAAuB;AAEvB,wBAAmC;AACnC,OAAO,EACL,wBAAwB,EACxB,mBAAmB,GACpB,mBAA8B;AAE/B,4BAAsB"}
|
package/src/client/index.ts
DELETED
package/src/client/initialize.ts
DELETED
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
PluginConfig,
|
|
3
|
-
PluginInstance,
|
|
4
|
-
PluginMessageResponse,
|
|
5
|
-
WorkbookSelection,
|
|
6
|
-
WorkbookVariable,
|
|
7
|
-
Unsubscriber,
|
|
8
|
-
} from 'types';
|
|
9
|
-
|
|
10
|
-
export function initialize<T = {}>(): PluginInstance<T> {
|
|
11
|
-
const pluginConfig: Partial<PluginConfig<T>> = {
|
|
12
|
-
config: {} as T,
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
let subscribedInteractions: Record<string, WorkbookSelection[]> = {};
|
|
16
|
-
let subscribedWorkbookVars: Record<string, WorkbookVariable> = {};
|
|
17
|
-
|
|
18
|
-
const listeners: {
|
|
19
|
-
[event: string]: Function[];
|
|
20
|
-
} = {};
|
|
21
|
-
|
|
22
|
-
for (const [key, value] of new URL(
|
|
23
|
-
document.location.toString(),
|
|
24
|
-
).searchParams.entries())
|
|
25
|
-
pluginConfig[key] = JSON.parse(value);
|
|
26
|
-
|
|
27
|
-
const listener = (e: PluginMessageResponse) => {
|
|
28
|
-
emit(e.data.type, e.data.result, e.data.error);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
window.addEventListener('message', listener, false);
|
|
32
|
-
window.addEventListener('click', () => execPromise('wb:plugin:focus'));
|
|
33
|
-
|
|
34
|
-
on('wb:plugin:config:update', (config: PluginConfig<T>) => {
|
|
35
|
-
Object.assign(pluginConfig, config);
|
|
36
|
-
emit('config', pluginConfig.config ?? {});
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
// send initialize event
|
|
40
|
-
void execPromise(
|
|
41
|
-
'wb:plugin:init',
|
|
42
|
-
require('../../package.json').version,
|
|
43
|
-
).then(config => {
|
|
44
|
-
Object.assign(pluginConfig, config);
|
|
45
|
-
emit('init', pluginConfig);
|
|
46
|
-
emit('config', pluginConfig.config);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
on(
|
|
50
|
-
'wb:plugin:variable:update',
|
|
51
|
-
(updatedVariables: Record<string, WorkbookVariable>) => {
|
|
52
|
-
subscribedWorkbookVars = {};
|
|
53
|
-
Object.assign(subscribedWorkbookVars, updatedVariables);
|
|
54
|
-
},
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
on('wb:plugin:selection:update', (updatedInteractions: unknown) => {
|
|
58
|
-
subscribedInteractions = {};
|
|
59
|
-
Object.assign(subscribedInteractions, updatedInteractions);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
function on(event: string, listener: Function) {
|
|
63
|
-
listeners[event] = listeners[event] || [];
|
|
64
|
-
listeners[event].push(listener);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function off(event: string, listener: Function) {
|
|
68
|
-
if (listeners[event] == null) return;
|
|
69
|
-
listeners[event] = listeners[event].filter(a => a !== listener);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function emit(event: string, ...args: any) {
|
|
73
|
-
Object.values(listeners[event] || []).forEach(fn => fn(...args));
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function execPromise<R>(event: string, ...args: any): Promise<R> {
|
|
77
|
-
return new Promise((resolve, reject) => {
|
|
78
|
-
const callback = (data: R, error: any) => {
|
|
79
|
-
if (error) reject(error);
|
|
80
|
-
else resolve(data);
|
|
81
|
-
off(event, callback);
|
|
82
|
-
};
|
|
83
|
-
on(event, callback);
|
|
84
|
-
window.parent.postMessage(
|
|
85
|
-
{ type: event, args, elementId: pluginConfig.id },
|
|
86
|
-
pluginConfig?.wbOrigin ?? '*',
|
|
87
|
-
);
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return {
|
|
92
|
-
get sigmaEnv() {
|
|
93
|
-
return pluginConfig.sigmaEnv;
|
|
94
|
-
},
|
|
95
|
-
|
|
96
|
-
get isScreenshot() {
|
|
97
|
-
return pluginConfig.screenshot;
|
|
98
|
-
},
|
|
99
|
-
|
|
100
|
-
config: {
|
|
101
|
-
// @ts-ignore
|
|
102
|
-
getKey(key) {
|
|
103
|
-
return pluginConfig?.config?.[key]!;
|
|
104
|
-
},
|
|
105
|
-
get() {
|
|
106
|
-
return pluginConfig.config;
|
|
107
|
-
},
|
|
108
|
-
set(partialConfig) {
|
|
109
|
-
void execPromise('wb:plugin:config:update', partialConfig);
|
|
110
|
-
},
|
|
111
|
-
setKey(key, value) {
|
|
112
|
-
void execPromise('wb:plugin:config:update', {
|
|
113
|
-
[key]: value,
|
|
114
|
-
});
|
|
115
|
-
},
|
|
116
|
-
subscribe(listener) {
|
|
117
|
-
on('config', listener);
|
|
118
|
-
return () => off('config', listener);
|
|
119
|
-
},
|
|
120
|
-
getVariable(id: string): WorkbookVariable {
|
|
121
|
-
return subscribedWorkbookVars[id];
|
|
122
|
-
},
|
|
123
|
-
setVariable(id: string, ...values: unknown[]) {
|
|
124
|
-
void execPromise('wb:plugin:variable:set', id, ...values);
|
|
125
|
-
},
|
|
126
|
-
getInteraction(id: string) {
|
|
127
|
-
return subscribedInteractions[id];
|
|
128
|
-
},
|
|
129
|
-
setInteraction(
|
|
130
|
-
id: string,
|
|
131
|
-
elementId: string,
|
|
132
|
-
selection:
|
|
133
|
-
| string[]
|
|
134
|
-
| Array<Record<string, { type: string; val?: unknown }>>,
|
|
135
|
-
) {
|
|
136
|
-
void execPromise('wb:plugin:selection:set', id, elementId, selection);
|
|
137
|
-
},
|
|
138
|
-
configureEditorPanel(options) {
|
|
139
|
-
void execPromise('wb:plugin:config:inspector', options);
|
|
140
|
-
},
|
|
141
|
-
setLoadingState(loadingState) {
|
|
142
|
-
void execPromise('wb:plugin:config:loading-state', loadingState);
|
|
143
|
-
},
|
|
144
|
-
subscribeToWorkbookVariable(
|
|
145
|
-
id: string,
|
|
146
|
-
callback: (input: WorkbookVariable) => void,
|
|
147
|
-
): Unsubscriber {
|
|
148
|
-
const setValues = (values: Record<string, WorkbookVariable>) => {
|
|
149
|
-
callback(values[id]);
|
|
150
|
-
};
|
|
151
|
-
on('wb:plugin:variable:update', setValues);
|
|
152
|
-
return () => {
|
|
153
|
-
off('wb:plugin:variable:update', setValues);
|
|
154
|
-
};
|
|
155
|
-
},
|
|
156
|
-
subscribeToWorkbookInteraction(
|
|
157
|
-
id: string,
|
|
158
|
-
callback: (input: WorkbookSelection[]) => void,
|
|
159
|
-
): Unsubscriber {
|
|
160
|
-
const setValues = (values: Record<string, WorkbookSelection[]>) => {
|
|
161
|
-
callback(values[id]);
|
|
162
|
-
};
|
|
163
|
-
on('wb:plugin:selection:update', setValues);
|
|
164
|
-
return () => {
|
|
165
|
-
off('wb:plugin:selection:update', setValues);
|
|
166
|
-
};
|
|
167
|
-
},
|
|
168
|
-
},
|
|
169
|
-
elements: {
|
|
170
|
-
getElementColumns(id) {
|
|
171
|
-
return execPromise('wb:plugin:element:columns:get', id);
|
|
172
|
-
},
|
|
173
|
-
subscribeToElementColumns(id, callback) {
|
|
174
|
-
const eventName = `wb:plugin:element:${id}:columns`;
|
|
175
|
-
on(eventName, callback);
|
|
176
|
-
void execPromise('wb:plugin:element:subscribe:columns', id);
|
|
177
|
-
|
|
178
|
-
return () => {
|
|
179
|
-
off(eventName, callback);
|
|
180
|
-
void execPromise('wb:plugin:element:unsubscribe:columns', id);
|
|
181
|
-
};
|
|
182
|
-
},
|
|
183
|
-
subscribeToElementData(id, callback) {
|
|
184
|
-
const eventName = `wb:plugin:element:${id}:data`;
|
|
185
|
-
on(eventName, callback);
|
|
186
|
-
void execPromise('wb:plugin:element:subscribe:data', id);
|
|
187
|
-
|
|
188
|
-
return () => {
|
|
189
|
-
off(eventName, callback);
|
|
190
|
-
void execPromise('wb:plugin:element:unsubscribe:data', id);
|
|
191
|
-
};
|
|
192
|
-
},
|
|
193
|
-
},
|
|
194
|
-
destroy() {
|
|
195
|
-
Object.keys(listeners).forEach(event => delete listeners[event]);
|
|
196
|
-
window.removeEventListener('message', listener, false);
|
|
197
|
-
},
|
|
198
|
-
};
|
|
199
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
|
|
3
|
-
import { PluginContext } from 'client/react/Context';
|
|
4
|
-
import { PluginInstance } from 'types';
|
|
5
|
-
|
|
6
|
-
export interface SigmaClientProviderProps<T = any> {
|
|
7
|
-
client: PluginInstance<T>;
|
|
8
|
-
children?: ReactNode;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function SigmaClientProvider<T = any>(
|
|
12
|
-
props: SigmaClientProviderProps<T>,
|
|
13
|
-
) {
|
|
14
|
-
return (
|
|
15
|
-
<PluginContext.Provider value={props.client}>
|
|
16
|
-
{props.children}
|
|
17
|
-
</PluginContext.Provider>
|
|
18
|
-
);
|
|
19
|
-
}
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import { useContext, useEffect, useCallback, useRef, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import { PluginContext } from 'client/react/Context';
|
|
4
|
-
import {
|
|
5
|
-
PluginInstance,
|
|
6
|
-
CustomPluginConfigOptions,
|
|
7
|
-
WorkbookElementColumns,
|
|
8
|
-
WorkbookElementData,
|
|
9
|
-
WorkbookSelection,
|
|
10
|
-
WorkbookVariable,
|
|
11
|
-
} from 'types';
|
|
12
|
-
import { deepEqual } from 'utils/deepEqual';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Gets the entire plugin instance
|
|
16
|
-
* @returns {PluginInstance} Context for the current plugin instance
|
|
17
|
-
*/
|
|
18
|
-
export function usePlugin(): PluginInstance<any> {
|
|
19
|
-
return useContext(PluginContext);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Provides a setter for the Plugin's Config Options
|
|
24
|
-
* @param {CustomPluginConfigOptions[]} nextOptions Updated possible Config Options
|
|
25
|
-
*/
|
|
26
|
-
export function useEditorPanelConfig(
|
|
27
|
-
nextOptions: CustomPluginConfigOptions[],
|
|
28
|
-
): void {
|
|
29
|
-
const client = usePlugin();
|
|
30
|
-
const optionsRef = useRef({});
|
|
31
|
-
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
if (nextOptions == null) return;
|
|
34
|
-
if (!deepEqual(nextOptions, optionsRef.current)) {
|
|
35
|
-
client.config.configureEditorPanel(nextOptions);
|
|
36
|
-
optionsRef.current = nextOptions;
|
|
37
|
-
}
|
|
38
|
-
}, [client, nextOptions]);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* React hook for Plugin Config loading state
|
|
43
|
-
* @param {boolean} initialState Initial value to set loading state to
|
|
44
|
-
* @returns {[boolean, Function]} Boolean value corresponding to loading state for plugin config and setter for loading state
|
|
45
|
-
*/
|
|
46
|
-
export function useLoadingState(
|
|
47
|
-
initialState: boolean,
|
|
48
|
-
): [boolean, (nextState: boolean) => void] {
|
|
49
|
-
const client = usePlugin();
|
|
50
|
-
const [loading, setLoading] = useState(() => {
|
|
51
|
-
client.config.setLoadingState(initialState);
|
|
52
|
-
return initialState;
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
return [
|
|
56
|
-
loading,
|
|
57
|
-
nextState => {
|
|
58
|
-
if (nextState === loading) return;
|
|
59
|
-
setLoading(nextState);
|
|
60
|
-
client.config.setLoadingState(nextState);
|
|
61
|
-
},
|
|
62
|
-
];
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Provides the latest column values from corresponding sheet
|
|
67
|
-
* @param {string} id Sheet ID to retrieve from workbook
|
|
68
|
-
* @returns {WorkbookElementColumns} Values of corresponding columns contained within the sheet
|
|
69
|
-
*/
|
|
70
|
-
export function useElementColumns(id: string): WorkbookElementColumns {
|
|
71
|
-
const client = usePlugin();
|
|
72
|
-
const [columns, setColumns] = useState<WorkbookElementColumns>({});
|
|
73
|
-
|
|
74
|
-
useEffect(() => {
|
|
75
|
-
if (id) {
|
|
76
|
-
return client.elements.subscribeToElementColumns(id, setColumns);
|
|
77
|
-
}
|
|
78
|
-
}, [client, id]);
|
|
79
|
-
|
|
80
|
-
return columns;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Provides the latest data values from corresponding sheet
|
|
85
|
-
* @param {string} id Sheet ID to get element data from
|
|
86
|
-
* @returns {WorkbookElementData} Element Data for corresponding sheet, if any
|
|
87
|
-
*/
|
|
88
|
-
export function useElementData(id: string): WorkbookElementData {
|
|
89
|
-
const client = usePlugin();
|
|
90
|
-
const [data, setData] = useState<WorkbookElementData>({});
|
|
91
|
-
|
|
92
|
-
useEffect(() => {
|
|
93
|
-
if (id) {
|
|
94
|
-
return client.elements.subscribeToElementData(id, setData);
|
|
95
|
-
}
|
|
96
|
-
}, [client, id]);
|
|
97
|
-
|
|
98
|
-
return data;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Provides the latest value for entire config or certain key within the config
|
|
103
|
-
* @param {string} key Key within Plugin Config, optional
|
|
104
|
-
* @returns Entire config if no key passed in or value for key within plugin config
|
|
105
|
-
*/
|
|
106
|
-
export function useConfig(key?: string): any {
|
|
107
|
-
const client = usePlugin();
|
|
108
|
-
const [config, setConfig] = useState<any>(
|
|
109
|
-
key != null ? client.config.getKey(key) : client.config.get(),
|
|
110
|
-
);
|
|
111
|
-
|
|
112
|
-
useEffect(
|
|
113
|
-
() =>
|
|
114
|
-
client.config.subscribe(newConfig => {
|
|
115
|
-
if (key != null && newConfig[key] !== config[key]) {
|
|
116
|
-
setConfig(newConfig[key]);
|
|
117
|
-
} else {
|
|
118
|
-
setConfig(newConfig);
|
|
119
|
-
}
|
|
120
|
-
}),
|
|
121
|
-
[client],
|
|
122
|
-
);
|
|
123
|
-
|
|
124
|
-
return config;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* React hook for accessing a workbook variable
|
|
129
|
-
* @param {string} id ID of variable within Plugin Config to use
|
|
130
|
-
* @returns {[(WorkbookVariable | undefined), Function]} Constantly updating value of the variable and setter for the variable
|
|
131
|
-
*/
|
|
132
|
-
export function useVariable(
|
|
133
|
-
id: string,
|
|
134
|
-
): [WorkbookVariable | undefined, Function] {
|
|
135
|
-
const client = usePlugin();
|
|
136
|
-
const [workbookVariable, setWorkbookVariable] = useState<WorkbookVariable>();
|
|
137
|
-
|
|
138
|
-
useEffect(() => {
|
|
139
|
-
return client.config.subscribeToWorkbookVariable(id, setWorkbookVariable);
|
|
140
|
-
}, [client, id]);
|
|
141
|
-
|
|
142
|
-
const setVariable = useCallback(
|
|
143
|
-
(...values: unknown[]) => client.config.setVariable(id, ...values),
|
|
144
|
-
[id],
|
|
145
|
-
);
|
|
146
|
-
|
|
147
|
-
return [workbookVariable, setVariable];
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* React hook for accessing a workbook interaction selections state
|
|
152
|
-
* @param {string} id ID of variable within Plugin Config to use
|
|
153
|
-
* @returns {[(WorkbookSelection | undefined), Function]} Constantly updating selection state and setter thereof
|
|
154
|
-
*/
|
|
155
|
-
export function useInteraction(
|
|
156
|
-
id: string,
|
|
157
|
-
elementId: string,
|
|
158
|
-
): [unknown, Function] {
|
|
159
|
-
const client = usePlugin();
|
|
160
|
-
const [workbookInteraction, setWorkbookInteraction] =
|
|
161
|
-
useState<WorkbookSelection[]>();
|
|
162
|
-
|
|
163
|
-
useEffect(() => {
|
|
164
|
-
return client.config.subscribeToWorkbookInteraction(
|
|
165
|
-
id,
|
|
166
|
-
setWorkbookInteraction,
|
|
167
|
-
);
|
|
168
|
-
}, [client, id]);
|
|
169
|
-
|
|
170
|
-
const setInteraction = useCallback(
|
|
171
|
-
(value: WorkbookSelection[]) => {
|
|
172
|
-
client.config.setInteraction(id, elementId, value);
|
|
173
|
-
},
|
|
174
|
-
[id],
|
|
175
|
-
);
|
|
176
|
-
|
|
177
|
-
return [workbookInteraction, setInteraction];
|
|
178
|
-
}
|
package/src/index.ts
DELETED
package/src/types.ts
DELETED
|
@@ -1,322 +0,0 @@
|
|
|
1
|
-
export type ScalarType = 'boolean' | 'datetime' | 'number' | 'integer' | 'text';
|
|
2
|
-
export type PrimitiveType = ScalarType | 'variant' | 'link';
|
|
3
|
-
export type ValueType = PrimitiveType | 'error';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* All mutable workbook control variable types
|
|
7
|
-
*/
|
|
8
|
-
export type ControlType =
|
|
9
|
-
| 'boolean'
|
|
10
|
-
| 'date'
|
|
11
|
-
| 'number'
|
|
12
|
-
| 'text'
|
|
13
|
-
| 'text-list'
|
|
14
|
-
| 'number-list'
|
|
15
|
-
| 'date-list'
|
|
16
|
-
| 'number-range'
|
|
17
|
-
| 'date-range';
|
|
18
|
-
|
|
19
|
-
export interface PluginConfig<T> {
|
|
20
|
-
id: string;
|
|
21
|
-
config: T;
|
|
22
|
-
screenshot: boolean;
|
|
23
|
-
[key: string]: any;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* @typedef {object} WorkbookVariable
|
|
28
|
-
* @property {string} name Name of Control Variable within Workbook
|
|
29
|
-
* @property {{string}} defaultValue Current Value containing at least type as string
|
|
30
|
-
*/
|
|
31
|
-
export interface WorkbookVariable {
|
|
32
|
-
name: string;
|
|
33
|
-
defaultValue: { type: string };
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export type WorkbookSelection = Record<string, { type: string; val?: unknown }>;
|
|
37
|
-
|
|
38
|
-
export type PluginMessageResponse = MessageEvent<{
|
|
39
|
-
type: string;
|
|
40
|
-
result: any[];
|
|
41
|
-
error: any;
|
|
42
|
-
}>;
|
|
43
|
-
|
|
44
|
-
export interface WbElement {
|
|
45
|
-
id: string;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* @typedef {object} WorkbookElementData
|
|
50
|
-
* @property {Object<string, any>} data Workbook data sorted by column ID
|
|
51
|
-
*/
|
|
52
|
-
export interface WorkbookElementData {
|
|
53
|
-
[colId: string]: any[];
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Column data
|
|
58
|
-
* @typedef {object} WorkbookElementColumn
|
|
59
|
-
* @property {string} id Column ID
|
|
60
|
-
* @property {string} name Column Name
|
|
61
|
-
* @property {string} columnType Type of data contained within column
|
|
62
|
-
*/
|
|
63
|
-
export interface WorkbookElementColumn {
|
|
64
|
-
id: string;
|
|
65
|
-
name: string;
|
|
66
|
-
columnType: ValueType;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Record of Column data with corresponding IDs
|
|
71
|
-
* @typedef {object} WorkbookElementColumns
|
|
72
|
-
* @property {Object<string, WorkbookElementColumn>} column Column ID and corresponding column data
|
|
73
|
-
*/
|
|
74
|
-
export interface WorkbookElementColumns {
|
|
75
|
-
[colId: string]: WorkbookElementColumn;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Function to Unsubscribe from the corresponding elements
|
|
80
|
-
* @typedef {() => void} Unsubscriber
|
|
81
|
-
*/
|
|
82
|
-
export type Unsubscriber = () => void;
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Different types Plugin Config Options
|
|
86
|
-
* @typedef {object} CustomPluginConfigOptions
|
|
87
|
-
* @property {string} type Type of config option
|
|
88
|
-
* @property {string} name Name ID of config option
|
|
89
|
-
* @property {(string | undefined)} label Displayed label for config option
|
|
90
|
-
*/
|
|
91
|
-
export type CustomPluginConfigOptions =
|
|
92
|
-
| {
|
|
93
|
-
type: 'group';
|
|
94
|
-
name: string;
|
|
95
|
-
label?: string;
|
|
96
|
-
}
|
|
97
|
-
| {
|
|
98
|
-
type: 'element';
|
|
99
|
-
name: string;
|
|
100
|
-
label?: string;
|
|
101
|
-
}
|
|
102
|
-
| {
|
|
103
|
-
type: 'column';
|
|
104
|
-
name: string;
|
|
105
|
-
label?: string;
|
|
106
|
-
allowedTypes?: ValueType[];
|
|
107
|
-
source: string;
|
|
108
|
-
allowMultiple: boolean;
|
|
109
|
-
}
|
|
110
|
-
| {
|
|
111
|
-
type: 'text';
|
|
112
|
-
name: string;
|
|
113
|
-
label?: string;
|
|
114
|
-
source?: string; // can point to a group or element config
|
|
115
|
-
// if true will omit from prehydrated configs passed through querystring
|
|
116
|
-
secure?: boolean;
|
|
117
|
-
multiline?: boolean;
|
|
118
|
-
placeholder?: string;
|
|
119
|
-
defaultValue?: string;
|
|
120
|
-
}
|
|
121
|
-
| {
|
|
122
|
-
type: 'toggle';
|
|
123
|
-
name: string;
|
|
124
|
-
label?: string;
|
|
125
|
-
source?: string;
|
|
126
|
-
defaultValue?: boolean;
|
|
127
|
-
}
|
|
128
|
-
| {
|
|
129
|
-
type: 'checkbox';
|
|
130
|
-
name: string;
|
|
131
|
-
label?: string;
|
|
132
|
-
source?: string;
|
|
133
|
-
defaultValue?: boolean;
|
|
134
|
-
}
|
|
135
|
-
| {
|
|
136
|
-
type: 'radio';
|
|
137
|
-
name: string;
|
|
138
|
-
label?: string;
|
|
139
|
-
source?: string;
|
|
140
|
-
values: string[];
|
|
141
|
-
singleLine?: boolean;
|
|
142
|
-
defaultValue?: string;
|
|
143
|
-
}
|
|
144
|
-
| {
|
|
145
|
-
type: 'dropdown';
|
|
146
|
-
name: string;
|
|
147
|
-
label?: string;
|
|
148
|
-
source?: string;
|
|
149
|
-
width?: string;
|
|
150
|
-
values: string[];
|
|
151
|
-
defaultValue?: string;
|
|
152
|
-
}
|
|
153
|
-
| {
|
|
154
|
-
type: 'color';
|
|
155
|
-
name: string;
|
|
156
|
-
label?: string;
|
|
157
|
-
source?: string;
|
|
158
|
-
}
|
|
159
|
-
| {
|
|
160
|
-
type: 'variable';
|
|
161
|
-
name: string;
|
|
162
|
-
label?: string;
|
|
163
|
-
allowedTypes?: ControlType[];
|
|
164
|
-
}
|
|
165
|
-
| {
|
|
166
|
-
type: 'interaction';
|
|
167
|
-
name: string;
|
|
168
|
-
label?: string;
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* @typedef {object} PluginInstance
|
|
173
|
-
* @template T Type of Config passed in
|
|
174
|
-
* @property {string} sigmaEnv Permissions within Sigma Environment
|
|
175
|
-
* @property {object} config Set of helper functions for interacting with Plugin Config
|
|
176
|
-
* @property {object} elements Set of helper functions for interacting with Workbook Element Data
|
|
177
|
-
* @property {Function} destroy Destroys Plugin Instance and removes all subscriptions
|
|
178
|
-
*/
|
|
179
|
-
export interface PluginInstance<T = any> {
|
|
180
|
-
sigmaEnv: 'author' | 'viewer' | 'explorer';
|
|
181
|
-
|
|
182
|
-
config: {
|
|
183
|
-
/**
|
|
184
|
-
* Getter for entire Plugin Config
|
|
185
|
-
* @template T Config type to be passed in
|
|
186
|
-
* @returns {Partial<T>} Current Plugin Config
|
|
187
|
-
*/
|
|
188
|
-
get(): Partial<T> | undefined;
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Performs a shallow merge between current config and passed in config
|
|
192
|
-
* @template T Config type to be passed in
|
|
193
|
-
* @param {Partial<T>} config Config to directly assign
|
|
194
|
-
*/
|
|
195
|
-
set(config: Partial<T>): void;
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Getter for key within plugin config
|
|
199
|
-
* @template K Possible key within CustomPluginConfigOptions
|
|
200
|
-
* @param {K} key Key within config to retrieve
|
|
201
|
-
* @returns Value within config for passed in key
|
|
202
|
-
*/
|
|
203
|
-
getKey<K extends keyof T>(key: K): Pick<T, K>;
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Assigns key value pair within plugin
|
|
207
|
-
* @template K Possible key within CustomPluginConfigOptions
|
|
208
|
-
* @template V Value corresponding to K
|
|
209
|
-
* @param {K} key Key within config to set
|
|
210
|
-
* @param {V} value New value to set key to
|
|
211
|
-
*/
|
|
212
|
-
setKey<K extends keyof T>(key: K, value: Pick<T, K>): void;
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* Subscriber for Plugin Config
|
|
216
|
-
* @param {Function} listener Function to be called upon changes to Plugin Config
|
|
217
|
-
*/
|
|
218
|
-
subscribe(listener: (arg0: T) => void): Unsubscriber;
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Set possible options for plugin config
|
|
222
|
-
* @param {CustomPluginConfigOptions[]} options Possible config options
|
|
223
|
-
*/
|
|
224
|
-
configureEditorPanel(options: CustomPluginConfigOptions[]): void;
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Gets a static image of a workbook variable
|
|
228
|
-
* @param {string} id ID of the workbook variable in config
|
|
229
|
-
* @returns {WorkbookVariable} Current value of the workbook variable
|
|
230
|
-
*/
|
|
231
|
-
getVariable(id: string): WorkbookVariable;
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Setter for workbook variable passed in
|
|
235
|
-
* @param {string} id ID of the workbook variable in config
|
|
236
|
-
* @param {unknown[]} values Values to assign to the workbook variable
|
|
237
|
-
*/
|
|
238
|
-
setVariable(id: string, ...values: unknown[]): void;
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* Getter for interaction selection state
|
|
242
|
-
* @param {string} id ID from interaction type in Plugin Config
|
|
243
|
-
*/
|
|
244
|
-
getInteraction(id: string): WorkbookSelection[];
|
|
245
|
-
|
|
246
|
-
/**
|
|
247
|
-
* Setter for interaction selection state
|
|
248
|
-
* @param {string} id ID from interaction type in Plugin Config
|
|
249
|
-
* @param {string} elementId Source element ID from element type in Plugin Config
|
|
250
|
-
* @param {Object} selection List of column IDs or Columns and values and key-value pairs to select
|
|
251
|
-
*/
|
|
252
|
-
setInteraction(
|
|
253
|
-
id: string,
|
|
254
|
-
elementId: string,
|
|
255
|
-
selection: WorkbookSelection[],
|
|
256
|
-
): void;
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* Overrider function for Config Ready state
|
|
260
|
-
* @param {boolean} loadingState Boolean representing if Plugin Config is still loading
|
|
261
|
-
*/
|
|
262
|
-
setLoadingState(ready: boolean): void;
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* Allows users to subscribe to changes in the passed in variable
|
|
266
|
-
* @param {string} id ID of the workbook variable in config
|
|
267
|
-
* @callback callback Function to be called upon receiving an updated workbook variable
|
|
268
|
-
* @returns {Unsubscriber} A callable unsubscriber
|
|
269
|
-
*/
|
|
270
|
-
subscribeToWorkbookVariable(
|
|
271
|
-
id: string,
|
|
272
|
-
callback: (input: WorkbookVariable) => void,
|
|
273
|
-
): Unsubscriber;
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* Allows users to subscribe to changes in the passed in interaction ID
|
|
277
|
-
* @param {string} id ID of the interaction variable within Plugin Config
|
|
278
|
-
* @callback callback Function to be called upon receiving an updated interaction selection state
|
|
279
|
-
* @returns {Unsubscriber} A callable unsubscriber
|
|
280
|
-
*/
|
|
281
|
-
subscribeToWorkbookInteraction(
|
|
282
|
-
id: string,
|
|
283
|
-
callback: (input: WorkbookSelection[]) => void,
|
|
284
|
-
): Unsubscriber;
|
|
285
|
-
};
|
|
286
|
-
|
|
287
|
-
elements: {
|
|
288
|
-
/**
|
|
289
|
-
* Getter for Column Data by parent sheet ID
|
|
290
|
-
* @param {string} id Sheet ID to retrieve columns from
|
|
291
|
-
* @returns {WorkbookElementColumns} Column values contained within corresponding sheet
|
|
292
|
-
*/
|
|
293
|
-
getElementColumns(id: string): Promise<WorkbookElementColumns>;
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* Subscriber to changes in column data by ID
|
|
297
|
-
* @param {string} id Column ID to subscribe to
|
|
298
|
-
* @callback callback Callback function to be called upon changes to column data
|
|
299
|
-
* @returns {Unsubscriber} Callable unsubscriber to column data changes
|
|
300
|
-
*/
|
|
301
|
-
subscribeToElementColumns(
|
|
302
|
-
id: string,
|
|
303
|
-
callback: (cols: WorkbookElementColumns) => void,
|
|
304
|
-
): Unsubscriber;
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
* Subscriber for the data within a given sheet
|
|
308
|
-
* @param {string} id Sheet ID to get element data from
|
|
309
|
-
* @callback callback Function to call on data passed in
|
|
310
|
-
* @returns {Unsubscriber} A callable unsubscriber to changes in the data
|
|
311
|
-
*/
|
|
312
|
-
subscribeToElementData(
|
|
313
|
-
id: string,
|
|
314
|
-
callback: (data: WorkbookElementData) => void,
|
|
315
|
-
): Unsubscriber;
|
|
316
|
-
};
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
* Destroys plugin instance and removes all subscribers
|
|
320
|
-
*/
|
|
321
|
-
destroy(): void;
|
|
322
|
-
}
|
package/src/utils/deepEqual.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
function isObject(obj: any) {
|
|
2
|
-
if (typeof obj === 'object' && obj != null) {
|
|
3
|
-
return true;
|
|
4
|
-
} else {
|
|
5
|
-
return false;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function deepEqual(obj1: any, obj2: any) {
|
|
10
|
-
if (obj1 === obj2) {
|
|
11
|
-
return true;
|
|
12
|
-
} else if (isObject(obj1) && isObject(obj2)) {
|
|
13
|
-
if (Object.keys(obj1).length !== Object.keys(obj2).length) {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
for (const prop in obj1) {
|
|
17
|
-
if (!deepEqual(obj1[prop], obj2[prop])) {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return true;
|
|
22
|
-
}
|
|
23
|
-
}
|