@sigmacomputing/plugin 1.0.5 → 1.1.0-alpha.2
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/cjs/client/index.js +9 -0
- package/dist/cjs/client/index.js.map +1 -0
- package/dist/cjs/client/initialize.js +158 -0
- package/dist/cjs/client/initialize.js.map +1 -0
- package/dist/cjs/index.js +12 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/{utils → cjs/utils}/polyfillRequestAnimationFrame.js +9 -8
- package/dist/cjs/utils/polyfillRequestAnimationFrame.js.map +1 -0
- package/dist/esm/client/index.esm.js +6 -0
- package/dist/esm/client/index.esm.js.map +1 -0
- package/dist/esm/client/initialize.esm.js +156 -0
- package/dist/esm/client/initialize.esm.js.map +1 -0
- package/dist/esm/index.esm.js +4 -0
- package/dist/esm/index.esm.js.map +1 -0
- package/dist/esm/utils/polyfillRequestAnimationFrame.esm.js +15 -0
- package/dist/esm/utils/polyfillRequestAnimationFrame.esm.js.map +1 -0
- package/dist/mjs/client/index.mjs +6 -0
- package/dist/mjs/client/index.mjs.map +1 -0
- package/dist/mjs/client/initialize.mjs +156 -0
- package/dist/mjs/client/initialize.mjs.map +1 -0
- package/dist/mjs/index.mjs +4 -0
- package/dist/mjs/index.mjs.map +1 -0
- package/dist/mjs/utils/polyfillRequestAnimationFrame.mjs +15 -0
- package/dist/mjs/utils/polyfillRequestAnimationFrame.mjs.map +1 -0
- package/dist/types/.tsbuildinfo +1 -0
- package/dist/types/client/index.d.ts +4 -0
- package/dist/types/client/index.d.ts.map +1 -0
- package/dist/types/client/initialize.d.ts +3 -0
- package/dist/types/client/initialize.d.ts.map +1 -0
- package/dist/{index.d.ts → types/index.d.ts} +1 -2
- package/dist/types/index.d.ts.map +1 -0
- package/dist/{types.d.ts → types/types/index.d.ts} +1 -1
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/{utils → types/utils}/polyfillRequestAnimationFrame.d.ts +1 -1
- package/dist/types/utils/polyfillRequestAnimationFrame.d.ts.map +1 -0
- package/dist/umd/plugin.development.js +181 -0
- package/dist/umd/plugin.development.js.map +1 -0
- package/dist/umd/plugin.production.min.js +2 -0
- package/dist/umd/plugin.production.min.js.map +1 -0
- package/package.json +27 -39
- package/src/client/index.ts +5 -0
- package/src/client/initialize.ts +196 -0
- package/src/globals.d.ts +5 -0
- package/src/index.ts +4 -0
- package/src/types/index.ts +322 -0
- package/src/utils/polyfillRequestAnimationFrame.ts +13 -0
- package/LICENSE +0 -21
- package/README.md +0 -795
- package/dist/client/initialize.d.ts +0 -3
- package/dist/client/initialize.d.ts.map +0 -1
- package/dist/client/initialize.js +0 -157
- package/dist/client.d.ts +0 -2
- package/dist/client.d.ts.map +0 -1
- package/dist/client.js +0 -5
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -22
- package/dist/react/Context.d.ts +0 -4
- package/dist/react/Context.d.ts.map +0 -1
- package/dist/react/Context.js +0 -6
- package/dist/react/Provider.d.ts +0 -8
- package/dist/react/Provider.d.ts.map +0 -1
- package/dist/react/Provider.js +0 -9
- package/dist/react/hooks.d.ts +0 -48
- package/dist/react/hooks.d.ts.map +0 -1
- package/dist/react/hooks.js +0 -136
- package/dist/react.d.ts +0 -3
- package/dist/react.d.ts.map +0 -1
- package/dist/react.js +0 -20
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/utils/deepEqual.d.ts +0 -2
- package/dist/utils/deepEqual.d.ts.map +0 -1
- package/dist/utils/deepEqual.js +0 -28
- package/dist/utils/polyfillRequestAnimationFrame.d.ts.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.initialize = void 0;
|
|
4
|
-
function initialize() {
|
|
5
|
-
const pluginConfig = {
|
|
6
|
-
config: {},
|
|
7
|
-
};
|
|
8
|
-
let subscribedInteractions = {};
|
|
9
|
-
let subscribedWorkbookVars = {};
|
|
10
|
-
const listeners = {};
|
|
11
|
-
for (const [key, value] of new URL(document.location.toString()).searchParams.entries())
|
|
12
|
-
pluginConfig[key] = JSON.parse(value);
|
|
13
|
-
const listener = (e) => {
|
|
14
|
-
emit(e.data.type, e.data.result, e.data.error);
|
|
15
|
-
};
|
|
16
|
-
window.addEventListener('message', listener, false);
|
|
17
|
-
window.addEventListener('click', () => execPromise('wb:plugin:focus'));
|
|
18
|
-
on('wb:plugin:config:update', (config) => {
|
|
19
|
-
var _a;
|
|
20
|
-
Object.assign(pluginConfig, config);
|
|
21
|
-
emit('config', (_a = pluginConfig.config) !== null && _a !== void 0 ? _a : {});
|
|
22
|
-
});
|
|
23
|
-
// send initialize event
|
|
24
|
-
void execPromise('wb:plugin:init', require('../../package.json').version).then(config => {
|
|
25
|
-
Object.assign(pluginConfig, config);
|
|
26
|
-
emit('init', pluginConfig);
|
|
27
|
-
emit('config', pluginConfig.config);
|
|
28
|
-
});
|
|
29
|
-
on('wb:plugin:variable:update', (updatedVariables) => {
|
|
30
|
-
subscribedWorkbookVars = {};
|
|
31
|
-
Object.assign(subscribedWorkbookVars, updatedVariables);
|
|
32
|
-
});
|
|
33
|
-
on('wb:plugin:selection:update', (updatedInteractions) => {
|
|
34
|
-
subscribedInteractions = {};
|
|
35
|
-
Object.assign(subscribedInteractions, updatedInteractions);
|
|
36
|
-
});
|
|
37
|
-
function on(event, listener) {
|
|
38
|
-
listeners[event] = listeners[event] || [];
|
|
39
|
-
listeners[event].push(listener);
|
|
40
|
-
}
|
|
41
|
-
function off(event, listener) {
|
|
42
|
-
if (listeners[event] == null)
|
|
43
|
-
return;
|
|
44
|
-
listeners[event] = listeners[event].filter(a => a !== listener);
|
|
45
|
-
}
|
|
46
|
-
function emit(event, ...args) {
|
|
47
|
-
Object.values(listeners[event] || []).forEach(fn => fn(...args));
|
|
48
|
-
}
|
|
49
|
-
function execPromise(event, ...args) {
|
|
50
|
-
return new Promise((resolve, reject) => {
|
|
51
|
-
var _a;
|
|
52
|
-
const callback = (data, error) => {
|
|
53
|
-
if (error)
|
|
54
|
-
reject(error);
|
|
55
|
-
else
|
|
56
|
-
resolve(data);
|
|
57
|
-
off(event, callback);
|
|
58
|
-
};
|
|
59
|
-
on(event, callback);
|
|
60
|
-
window.parent.postMessage({ type: event, args, elementId: pluginConfig.id }, (_a = pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.wbOrigin) !== null && _a !== void 0 ? _a : '*');
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
return {
|
|
64
|
-
get sigmaEnv() {
|
|
65
|
-
return pluginConfig.sigmaEnv;
|
|
66
|
-
},
|
|
67
|
-
get isScreenshot() {
|
|
68
|
-
return pluginConfig.screenshot;
|
|
69
|
-
},
|
|
70
|
-
config: {
|
|
71
|
-
// @ts-ignore
|
|
72
|
-
getKey(key) {
|
|
73
|
-
var _a;
|
|
74
|
-
return (_a = pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.config) === null || _a === void 0 ? void 0 : _a[key];
|
|
75
|
-
},
|
|
76
|
-
get() {
|
|
77
|
-
return pluginConfig.config;
|
|
78
|
-
},
|
|
79
|
-
set(partialConfig) {
|
|
80
|
-
void execPromise('wb:plugin:config:update', partialConfig);
|
|
81
|
-
},
|
|
82
|
-
setKey(key, value) {
|
|
83
|
-
void execPromise('wb:plugin:config:update', {
|
|
84
|
-
[key]: value,
|
|
85
|
-
});
|
|
86
|
-
},
|
|
87
|
-
subscribe(listener) {
|
|
88
|
-
on('config', listener);
|
|
89
|
-
return () => off('config', listener);
|
|
90
|
-
},
|
|
91
|
-
getVariable(id) {
|
|
92
|
-
return subscribedWorkbookVars[id];
|
|
93
|
-
},
|
|
94
|
-
setVariable(id, ...values) {
|
|
95
|
-
void execPromise('wb:plugin:variable:set', id, ...values);
|
|
96
|
-
},
|
|
97
|
-
getInteraction(id) {
|
|
98
|
-
return subscribedInteractions[id];
|
|
99
|
-
},
|
|
100
|
-
setInteraction(id, elementId, selection) {
|
|
101
|
-
void execPromise('wb:plugin:selection:set', id, elementId, selection);
|
|
102
|
-
},
|
|
103
|
-
configureEditorPanel(options) {
|
|
104
|
-
void execPromise('wb:plugin:config:inspector', options);
|
|
105
|
-
},
|
|
106
|
-
setLoadingState(loadingState) {
|
|
107
|
-
void execPromise('wb:plugin:config:loading-state', loadingState);
|
|
108
|
-
},
|
|
109
|
-
subscribeToWorkbookVariable(id, callback) {
|
|
110
|
-
const setValues = (values) => {
|
|
111
|
-
callback(values[id]);
|
|
112
|
-
};
|
|
113
|
-
on('wb:plugin:variable:update', setValues);
|
|
114
|
-
return () => {
|
|
115
|
-
off('wb:plugin:variable:update', setValues);
|
|
116
|
-
};
|
|
117
|
-
},
|
|
118
|
-
subscribeToWorkbookInteraction(id, callback) {
|
|
119
|
-
const setValues = (values) => {
|
|
120
|
-
callback(values[id]);
|
|
121
|
-
};
|
|
122
|
-
on('wb:plugin:selection:update', setValues);
|
|
123
|
-
return () => {
|
|
124
|
-
off('wb:plugin:selection:update', setValues);
|
|
125
|
-
};
|
|
126
|
-
},
|
|
127
|
-
},
|
|
128
|
-
elements: {
|
|
129
|
-
getElementColumns(id) {
|
|
130
|
-
return execPromise('wb:plugin:element:columns:get', id);
|
|
131
|
-
},
|
|
132
|
-
subscribeToElementColumns(id, callback) {
|
|
133
|
-
const eventName = `wb:plugin:element:${id}:columns`;
|
|
134
|
-
on(eventName, callback);
|
|
135
|
-
void execPromise('wb:plugin:element:subscribe:columns', id);
|
|
136
|
-
return () => {
|
|
137
|
-
off(eventName, callback);
|
|
138
|
-
void execPromise('wb:plugin:element:unsubscribe:columns', id);
|
|
139
|
-
};
|
|
140
|
-
},
|
|
141
|
-
subscribeToElementData(id, callback) {
|
|
142
|
-
const eventName = `wb:plugin:element:${id}:data`;
|
|
143
|
-
on(eventName, callback);
|
|
144
|
-
void execPromise('wb:plugin:element:subscribe:data', id);
|
|
145
|
-
return () => {
|
|
146
|
-
off(eventName, callback);
|
|
147
|
-
void execPromise('wb:plugin:element:unsubscribe:data', id);
|
|
148
|
-
};
|
|
149
|
-
},
|
|
150
|
-
},
|
|
151
|
-
destroy() {
|
|
152
|
-
Object.keys(listeners).forEach(event => delete listeners[event]);
|
|
153
|
-
window.removeEventListener('message', listener, false);
|
|
154
|
-
},
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
exports.initialize = initialize;
|
package/dist/client.d.ts
DELETED
package/dist/client.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,sCAAe,CAAC"}
|
package/dist/client.js
DELETED
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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;AAEzB,OAAO,EAAC,6BAA6B,EAAC,MAAM,uCAAuC,CAAC"}
|
package/dist/index.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.polyfillRequestAnimationFrame = void 0;
|
|
18
|
-
__exportStar(require("./types"), exports);
|
|
19
|
-
__exportStar(require("./react"), exports);
|
|
20
|
-
__exportStar(require("./client"), exports);
|
|
21
|
-
var polyfillRequestAnimationFrame_1 = require("./utils/polyfillRequestAnimationFrame");
|
|
22
|
-
Object.defineProperty(exports, "polyfillRequestAnimationFrame", { enumerable: true, get: function () { return polyfillRequestAnimationFrame_1.polyfillRequestAnimationFrame; } });
|
package/dist/react/Context.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/react/Context.js
DELETED
package/dist/react/Provider.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
import { PluginInstance } from '../types';
|
|
3
|
-
export interface SigmaClientProviderProps<T = any> {
|
|
4
|
-
client: PluginInstance<T>;
|
|
5
|
-
children?: ReactNode;
|
|
6
|
-
}
|
|
7
|
-
export declare function SigmaClientProvider<T = any>(props: SigmaClientProviderProps<T>): JSX.Element;
|
|
8
|
-
//# sourceMappingURL=Provider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/react/Provider.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SigmaClientProvider = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const Context_1 = require("./Context");
|
|
6
|
-
function SigmaClientProvider(props) {
|
|
7
|
-
return ((0, jsx_runtime_1.jsx)(Context_1.PluginContext.Provider, Object.assign({ value: props.client }, { children: props.children })));
|
|
8
|
-
}
|
|
9
|
-
exports.SigmaClientProvider = SigmaClientProvider;
|
package/dist/react/hooks.d.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { PluginInstance, CustomPluginConfigOptions, WorkbookElementColumns, WorkbookElementData, WorkbookVariable } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Gets the entire plugin instance
|
|
4
|
-
* @returns {PluginInstance} Context for the current plugin instance
|
|
5
|
-
*/
|
|
6
|
-
export declare function usePlugin(): PluginInstance<any>;
|
|
7
|
-
/**
|
|
8
|
-
* Provides a setter for the Plugin's Config Options
|
|
9
|
-
* @param {CustomPluginConfigOptions[]} nextOptions Updated possible Config Options
|
|
10
|
-
*/
|
|
11
|
-
export declare function useEditorPanelConfig(nextOptions: CustomPluginConfigOptions[]): void;
|
|
12
|
-
/**
|
|
13
|
-
* React hook for Plugin Config loading state
|
|
14
|
-
* @param {boolean} initialState Initial value to set loading state to
|
|
15
|
-
* @returns {[boolean, Function]} Boolean value corresponding to loading state for plugin config and setter for loading state
|
|
16
|
-
*/
|
|
17
|
-
export declare function useLoadingState(initialState: boolean): [boolean, (nextState: boolean) => void];
|
|
18
|
-
/**
|
|
19
|
-
* Provides the latest column values from corresponding sheet
|
|
20
|
-
* @param {string} id Sheet ID to retrieve from workbook
|
|
21
|
-
* @returns {WorkbookElementColumns} Values of corresponding columns contained within the sheet
|
|
22
|
-
*/
|
|
23
|
-
export declare function useElementColumns(id: string): WorkbookElementColumns;
|
|
24
|
-
/**
|
|
25
|
-
* Provides the latest data values from corresponding sheet
|
|
26
|
-
* @param {string} id Sheet ID to get element data from
|
|
27
|
-
* @returns {WorkbookElementData} Element Data for corresponding sheet, if any
|
|
28
|
-
*/
|
|
29
|
-
export declare function useElementData(id: string): WorkbookElementData;
|
|
30
|
-
/**
|
|
31
|
-
* Provides the latest value for entire config or certain key within the config
|
|
32
|
-
* @param {string} key Key within Plugin Config, optional
|
|
33
|
-
* @returns Entire config if no key passed in or value for key within plugin config
|
|
34
|
-
*/
|
|
35
|
-
export declare function useConfig(key?: string): any;
|
|
36
|
-
/**
|
|
37
|
-
* React hook for accessing a workbook variable
|
|
38
|
-
* @param {string} id ID of variable within Plugin Config to use
|
|
39
|
-
* @returns {[(WorkbookVariable | undefined), Function]} Constantly updating value of the variable and setter for the variable
|
|
40
|
-
*/
|
|
41
|
-
export declare function useVariable(id: string): [WorkbookVariable | undefined, Function];
|
|
42
|
-
/**
|
|
43
|
-
* React hook for accessing a workbook interaction selections state
|
|
44
|
-
* @param {string} id ID of variable within Plugin Config to use
|
|
45
|
-
* @returns {[(WorkbookSelection | undefined), Function]} Constantly updating selection state and setter thereof
|
|
46
|
-
*/
|
|
47
|
-
export declare function useInteraction(id: string, elementId: string): [unknown, Function];
|
|
48
|
-
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/react/hooks.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useInteraction = exports.useVariable = exports.useConfig = exports.useElementData = exports.useElementColumns = exports.useLoadingState = exports.useEditorPanelConfig = exports.usePlugin = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const Context_1 = require("./Context");
|
|
6
|
-
const deepEqual_1 = require("../utils/deepEqual");
|
|
7
|
-
/**
|
|
8
|
-
* Gets the entire plugin instance
|
|
9
|
-
* @returns {PluginInstance} Context for the current plugin instance
|
|
10
|
-
*/
|
|
11
|
-
function usePlugin() {
|
|
12
|
-
return (0, react_1.useContext)(Context_1.PluginContext);
|
|
13
|
-
}
|
|
14
|
-
exports.usePlugin = usePlugin;
|
|
15
|
-
/**
|
|
16
|
-
* Provides a setter for the Plugin's Config Options
|
|
17
|
-
* @param {CustomPluginConfigOptions[]} nextOptions Updated possible Config Options
|
|
18
|
-
*/
|
|
19
|
-
function useEditorPanelConfig(nextOptions) {
|
|
20
|
-
const client = usePlugin();
|
|
21
|
-
const optionsRef = (0, react_1.useRef)({});
|
|
22
|
-
(0, react_1.useEffect)(() => {
|
|
23
|
-
if (nextOptions == null)
|
|
24
|
-
return;
|
|
25
|
-
if (!(0, deepEqual_1.deepEqual)(nextOptions, optionsRef.current)) {
|
|
26
|
-
client.config.configureEditorPanel(nextOptions);
|
|
27
|
-
optionsRef.current = nextOptions;
|
|
28
|
-
}
|
|
29
|
-
}, [client, nextOptions]);
|
|
30
|
-
}
|
|
31
|
-
exports.useEditorPanelConfig = useEditorPanelConfig;
|
|
32
|
-
/**
|
|
33
|
-
* React hook for Plugin Config loading state
|
|
34
|
-
* @param {boolean} initialState Initial value to set loading state to
|
|
35
|
-
* @returns {[boolean, Function]} Boolean value corresponding to loading state for plugin config and setter for loading state
|
|
36
|
-
*/
|
|
37
|
-
function useLoadingState(initialState) {
|
|
38
|
-
const client = usePlugin();
|
|
39
|
-
const [loading, setLoading] = (0, react_1.useState)(() => {
|
|
40
|
-
client.config.setLoadingState(initialState);
|
|
41
|
-
return initialState;
|
|
42
|
-
});
|
|
43
|
-
return [
|
|
44
|
-
loading,
|
|
45
|
-
nextState => {
|
|
46
|
-
if (nextState === loading)
|
|
47
|
-
return;
|
|
48
|
-
setLoading(nextState);
|
|
49
|
-
client.config.setLoadingState(nextState);
|
|
50
|
-
},
|
|
51
|
-
];
|
|
52
|
-
}
|
|
53
|
-
exports.useLoadingState = useLoadingState;
|
|
54
|
-
/**
|
|
55
|
-
* Provides the latest column values from corresponding sheet
|
|
56
|
-
* @param {string} id Sheet ID to retrieve from workbook
|
|
57
|
-
* @returns {WorkbookElementColumns} Values of corresponding columns contained within the sheet
|
|
58
|
-
*/
|
|
59
|
-
function useElementColumns(id) {
|
|
60
|
-
const client = usePlugin();
|
|
61
|
-
const [columns, setColumns] = (0, react_1.useState)({});
|
|
62
|
-
(0, react_1.useEffect)(() => {
|
|
63
|
-
if (id) {
|
|
64
|
-
return client.elements.subscribeToElementColumns(id, setColumns);
|
|
65
|
-
}
|
|
66
|
-
}, [client, id]);
|
|
67
|
-
return columns;
|
|
68
|
-
}
|
|
69
|
-
exports.useElementColumns = useElementColumns;
|
|
70
|
-
/**
|
|
71
|
-
* Provides the latest data values from corresponding sheet
|
|
72
|
-
* @param {string} id Sheet ID to get element data from
|
|
73
|
-
* @returns {WorkbookElementData} Element Data for corresponding sheet, if any
|
|
74
|
-
*/
|
|
75
|
-
function useElementData(id) {
|
|
76
|
-
const client = usePlugin();
|
|
77
|
-
const [data, setData] = (0, react_1.useState)({});
|
|
78
|
-
(0, react_1.useEffect)(() => {
|
|
79
|
-
if (id) {
|
|
80
|
-
return client.elements.subscribeToElementData(id, setData);
|
|
81
|
-
}
|
|
82
|
-
}, [client, id]);
|
|
83
|
-
return data;
|
|
84
|
-
}
|
|
85
|
-
exports.useElementData = useElementData;
|
|
86
|
-
/**
|
|
87
|
-
* Provides the latest value for entire config or certain key within the config
|
|
88
|
-
* @param {string} key Key within Plugin Config, optional
|
|
89
|
-
* @returns Entire config if no key passed in or value for key within plugin config
|
|
90
|
-
*/
|
|
91
|
-
function useConfig(key) {
|
|
92
|
-
const client = usePlugin();
|
|
93
|
-
const [config, setConfig] = (0, react_1.useState)(key != null ? client.config.getKey(key) : client.config.get());
|
|
94
|
-
(0, react_1.useEffect)(() => client.config.subscribe(newConfig => {
|
|
95
|
-
if (key != null && newConfig[key] !== config[key]) {
|
|
96
|
-
setConfig(newConfig[key]);
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
setConfig(newConfig);
|
|
100
|
-
}
|
|
101
|
-
}), [client]);
|
|
102
|
-
return config;
|
|
103
|
-
}
|
|
104
|
-
exports.useConfig = useConfig;
|
|
105
|
-
/**
|
|
106
|
-
* React hook for accessing a workbook variable
|
|
107
|
-
* @param {string} id ID of variable within Plugin Config to use
|
|
108
|
-
* @returns {[(WorkbookVariable | undefined), Function]} Constantly updating value of the variable and setter for the variable
|
|
109
|
-
*/
|
|
110
|
-
function useVariable(id) {
|
|
111
|
-
const client = usePlugin();
|
|
112
|
-
const [workbookVariable, setWorkbookVariable] = (0, react_1.useState)();
|
|
113
|
-
(0, react_1.useEffect)(() => {
|
|
114
|
-
return client.config.subscribeToWorkbookVariable(id, setWorkbookVariable);
|
|
115
|
-
}, [client, id]);
|
|
116
|
-
const setVariable = (0, react_1.useCallback)((...values) => client.config.setVariable(id, ...values), [id]);
|
|
117
|
-
return [workbookVariable, setVariable];
|
|
118
|
-
}
|
|
119
|
-
exports.useVariable = useVariable;
|
|
120
|
-
/**
|
|
121
|
-
* React hook for accessing a workbook interaction selections state
|
|
122
|
-
* @param {string} id ID of variable within Plugin Config to use
|
|
123
|
-
* @returns {[(WorkbookSelection | undefined), Function]} Constantly updating selection state and setter thereof
|
|
124
|
-
*/
|
|
125
|
-
function useInteraction(id, elementId) {
|
|
126
|
-
const client = usePlugin();
|
|
127
|
-
const [workbookInteraction, setWorkbookInteraction] = (0, react_1.useState)();
|
|
128
|
-
(0, react_1.useEffect)(() => {
|
|
129
|
-
return client.config.subscribeToWorkbookInteraction(id, setWorkbookInteraction);
|
|
130
|
-
}, [client, id]);
|
|
131
|
-
const setInteraction = (0, react_1.useCallback)((value) => {
|
|
132
|
-
client.config.setInteraction(id, elementId, value);
|
|
133
|
-
}, [id]);
|
|
134
|
-
return [workbookInteraction, setInteraction];
|
|
135
|
-
}
|
|
136
|
-
exports.useInteraction = useInteraction;
|
package/dist/react.d.ts
DELETED
package/dist/react.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/react.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.SigmaClientProvider = void 0;
|
|
18
|
-
__exportStar(require("./react/hooks"), exports);
|
|
19
|
-
var Provider_1 = require("./react/Provider");
|
|
20
|
-
Object.defineProperty(exports, "SigmaClientProvider", { enumerable: true, get: function () { return Provider_1.SigmaClientProvider; } });
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sour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;;;;WAIG;QACH,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;QAE/D;;;;;WAKG;QACH,yBAAyB,CACvB,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,CAAC,IAAI,EAAE,sBAAsB,KAAK,IAAI,GAC/C,YAAY,CAAC;QAEhB;;;;;WAKG;QACH,sBAAsB,CACpB,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,CAAC,IAAI,EAAE,mBAAmB,KAAK,IAAI,GAC5C,YAAY,CAAC;KACjB,CAAC;IAEF;;OAEG;IACH,OAAO,IAAI,IAAI,CAAC;CACjB"}
|
package/dist/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deepEqual.d.ts","sourceRoot":"","sources":["../../src/utils/deepEqual.ts"],"names":[],"mappings":"AAQA,wBAAgB,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,uBAc7C"}
|
package/dist/utils/deepEqual.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deepEqual = void 0;
|
|
4
|
-
function isObject(obj) {
|
|
5
|
-
if (typeof obj === 'object' && obj != null) {
|
|
6
|
-
return true;
|
|
7
|
-
}
|
|
8
|
-
else {
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
function deepEqual(obj1, obj2) {
|
|
13
|
-
if (obj1 === obj2) {
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
else if (isObject(obj1) && isObject(obj2)) {
|
|
17
|
-
if (Object.keys(obj1).length !== Object.keys(obj2).length) {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
for (const prop in obj1) {
|
|
21
|
-
if (!deepEqual(obj1[prop], obj2[prop])) {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
exports.deepEqual = deepEqual;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"polyfillRequestAnimationFrame.d.ts","sourceRoot":"","sources":["../../src/utils/polyfillRequestAnimationFrame.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,CAAC,EAAE,MAAM,QAKtD"}
|