@sigmacomputing/plugin 1.1.1 → 1.2.0
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/CHANGELOG.md +0 -14
- package/LICENSE +1 -1
- package/README.md +19 -24
- package/dist/cjs/index.cjs +506 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.cts +438 -0
- package/dist/esm/index.d.ts +438 -0
- package/dist/esm/index.js +466 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/umd/sigmacomputing-plugin.umd.js +2 -0
- package/dist/umd/sigmacomputing-plugin.umd.js.map +1 -0
- package/package.json +69 -36
- package/src/client/initialize.ts +280 -0
- package/src/client.ts +3 -0
- package/src/globals.d.ts +2 -0
- package/{dist/index.d.ts → src/index.ts} +1 -1
- package/src/react/Context.ts +6 -0
- package/src/react/Provider.tsx +20 -0
- package/src/react/hooks.ts +298 -0
- package/src/react.ts +3 -0
- package/src/types.ts +412 -0
- package/src/utils/deepEqual.ts +23 -0
- package/src/utils/error.ts +10 -0
- package/src/utils/polyfillRequestAnimationFrame.ts +13 -0
- package/dist/client/initialize.d.ts +0 -3
- package/dist/client/initialize.d.ts.map +0 -1
- package/dist/client/initialize.js +0 -223
- package/dist/client.d.ts +0 -2
- package/dist/client.d.ts.map +0 -1
- package/dist/client.js +0 -5
- package/dist/error.d.ts +0 -3
- package/dist/error.d.ts.map +0 -1
- package/dist/error.js +0 -9
- 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 -83
- package/dist/react/hooks.d.ts.map +0 -1
- package/dist/react/hooks.js +0 -231
- 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 +0 -332
- 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 +0 -8
- package/dist/utils/polyfillRequestAnimationFrame.d.ts.map +0 -1
- package/dist/utils/polyfillRequestAnimationFrame.js +0 -16
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CustomPluginConfigOptions } from '../types';
|
|
2
|
+
|
|
3
|
+
export function validateConfigId(
|
|
4
|
+
configId: string,
|
|
5
|
+
expectedConfigType: CustomPluginConfigOptions['type'],
|
|
6
|
+
) {
|
|
7
|
+
if (configId === undefined) {
|
|
8
|
+
console.warn(`Invalid config ${expectedConfigType}: ${configId}`);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const FPS = 1000 / 60;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* requestAnimationFrame() calls are paused in most browsers when running in background tabs or hidden <iframe>s in order to improve performance and battery life
|
|
5
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
|
|
6
|
+
*/
|
|
7
|
+
export function polyfillRequestAnimationFrame(window: Window) {
|
|
8
|
+
if ('requestAnimationFrame' in window) {
|
|
9
|
+
window.requestAnimationFrame = callback => window.setTimeout(callback, FPS);
|
|
10
|
+
|
|
11
|
+
window.cancelAnimationFrame = id => window.clearTimeout(id);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.d.ts","sourceRoot":"","sources":["../../src/client/initialize.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,cAAc,EAMf,MAAM,UAAU,CAAC;AAElB,wBAAgB,UAAU,CAAC,CAAC,GAAG,EAAE,KAAK,cAAc,CAAC,CAAC,CAAC,CAqQtD"}
|
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.initialize = void 0;
|
|
4
|
-
const error_1 = require("../error");
|
|
5
|
-
function initialize() {
|
|
6
|
-
const pluginConfig = {
|
|
7
|
-
config: {},
|
|
8
|
-
};
|
|
9
|
-
let subscribedInteractions = {};
|
|
10
|
-
let subscribedWorkbookVars = {};
|
|
11
|
-
let subscribedUrlParameters = {};
|
|
12
|
-
const registeredEffects = {};
|
|
13
|
-
const listeners = {};
|
|
14
|
-
for (const [key, value] of new URL(document.location.toString()).searchParams.entries())
|
|
15
|
-
pluginConfig[key] = JSON.parse(value);
|
|
16
|
-
const listener = (e) => {
|
|
17
|
-
emit(e.data.type, e.data.result, e.data.error);
|
|
18
|
-
};
|
|
19
|
-
window.addEventListener('message', listener, false);
|
|
20
|
-
window.addEventListener('click', () => execPromise('wb:plugin:focus'));
|
|
21
|
-
on('wb:plugin:config:update', (config) => {
|
|
22
|
-
var _a;
|
|
23
|
-
Object.assign(pluginConfig, config);
|
|
24
|
-
emit('config', (_a = pluginConfig.config) !== null && _a !== void 0 ? _a : {});
|
|
25
|
-
});
|
|
26
|
-
// send initialize event
|
|
27
|
-
void execPromise('wb:plugin:init', require('../../package.json').version).then(config => {
|
|
28
|
-
Object.assign(pluginConfig, config);
|
|
29
|
-
emit('init', pluginConfig);
|
|
30
|
-
emit('config', pluginConfig.config);
|
|
31
|
-
});
|
|
32
|
-
on('wb:plugin:variable:update', (updatedVariables) => {
|
|
33
|
-
subscribedWorkbookVars = {};
|
|
34
|
-
Object.assign(subscribedWorkbookVars, updatedVariables);
|
|
35
|
-
});
|
|
36
|
-
on('wb:plugin:selection:update', (updatedInteractions) => {
|
|
37
|
-
subscribedInteractions = {};
|
|
38
|
-
Object.assign(subscribedInteractions, updatedInteractions);
|
|
39
|
-
});
|
|
40
|
-
on('wb:plugin:url-parameter:update', (updatedUrlParameters) => {
|
|
41
|
-
subscribedUrlParameters = {};
|
|
42
|
-
Object.assign(subscribedUrlParameters, updatedUrlParameters);
|
|
43
|
-
});
|
|
44
|
-
on('wb:plugin:action-effect:invoke', (configId) => {
|
|
45
|
-
const effect = registeredEffects[configId];
|
|
46
|
-
if (!effect) {
|
|
47
|
-
throw new Error(`Unknown action effect with name: ${configId}`);
|
|
48
|
-
}
|
|
49
|
-
effect();
|
|
50
|
-
});
|
|
51
|
-
function on(event, listener) {
|
|
52
|
-
listeners[event] = listeners[event] || [];
|
|
53
|
-
listeners[event].push(listener);
|
|
54
|
-
}
|
|
55
|
-
function off(event, listener) {
|
|
56
|
-
if (listeners[event] == null)
|
|
57
|
-
return;
|
|
58
|
-
listeners[event] = listeners[event].filter(a => a !== listener);
|
|
59
|
-
}
|
|
60
|
-
function emit(event, ...args) {
|
|
61
|
-
Object.values(listeners[event] || []).forEach(fn => fn(...args));
|
|
62
|
-
}
|
|
63
|
-
function execPromise(event, ...args) {
|
|
64
|
-
return new Promise((resolve, reject) => {
|
|
65
|
-
var _a;
|
|
66
|
-
const callback = (data, error) => {
|
|
67
|
-
if (error)
|
|
68
|
-
reject(error);
|
|
69
|
-
else
|
|
70
|
-
resolve(data);
|
|
71
|
-
off(event, callback);
|
|
72
|
-
};
|
|
73
|
-
on(event, callback);
|
|
74
|
-
window.parent.postMessage({ type: event, args, elementId: pluginConfig.id }, (_a = pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.wbOrigin) !== null && _a !== void 0 ? _a : '*');
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
return {
|
|
78
|
-
get sigmaEnv() {
|
|
79
|
-
return pluginConfig.sigmaEnv;
|
|
80
|
-
},
|
|
81
|
-
get isScreenshot() {
|
|
82
|
-
return pluginConfig.screenshot;
|
|
83
|
-
},
|
|
84
|
-
config: {
|
|
85
|
-
// @ts-ignore
|
|
86
|
-
getKey(key) {
|
|
87
|
-
var _a;
|
|
88
|
-
return (_a = pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.config) === null || _a === void 0 ? void 0 : _a[key];
|
|
89
|
-
},
|
|
90
|
-
get() {
|
|
91
|
-
return pluginConfig.config;
|
|
92
|
-
},
|
|
93
|
-
set(partialConfig) {
|
|
94
|
-
void execPromise('wb:plugin:config:update', partialConfig);
|
|
95
|
-
},
|
|
96
|
-
setKey(key, value) {
|
|
97
|
-
void execPromise('wb:plugin:config:update', {
|
|
98
|
-
[key]: value,
|
|
99
|
-
});
|
|
100
|
-
},
|
|
101
|
-
subscribe(listener) {
|
|
102
|
-
on('config', listener);
|
|
103
|
-
return () => off('config', listener);
|
|
104
|
-
},
|
|
105
|
-
getVariable(configId) {
|
|
106
|
-
(0, error_1.validateConfigId)(configId, 'variable');
|
|
107
|
-
return subscribedWorkbookVars[configId];
|
|
108
|
-
},
|
|
109
|
-
setVariable(configId, ...values) {
|
|
110
|
-
(0, error_1.validateConfigId)(configId, 'variable');
|
|
111
|
-
void execPromise('wb:plugin:variable:set', configId, ...values);
|
|
112
|
-
},
|
|
113
|
-
getInteraction(configId) {
|
|
114
|
-
(0, error_1.validateConfigId)(configId, 'interaction');
|
|
115
|
-
return subscribedInteractions[configId];
|
|
116
|
-
},
|
|
117
|
-
setInteraction(configId, elementId, selection) {
|
|
118
|
-
(0, error_1.validateConfigId)(configId, 'interaction');
|
|
119
|
-
void execPromise('wb:plugin:selection:set', configId, elementId, selection);
|
|
120
|
-
},
|
|
121
|
-
triggerAction(configId) {
|
|
122
|
-
(0, error_1.validateConfigId)(configId, 'action-trigger');
|
|
123
|
-
void execPromise('wb:plugin:action-trigger:invoke', configId);
|
|
124
|
-
},
|
|
125
|
-
registerEffect(configId, effect) {
|
|
126
|
-
(0, error_1.validateConfigId)(configId, 'action-effect');
|
|
127
|
-
registeredEffects[configId] = effect;
|
|
128
|
-
return () => {
|
|
129
|
-
delete registeredEffects[configId];
|
|
130
|
-
};
|
|
131
|
-
},
|
|
132
|
-
configureEditorPanel(options) {
|
|
133
|
-
void execPromise('wb:plugin:config:inspector', options);
|
|
134
|
-
},
|
|
135
|
-
setLoadingState(loadingState) {
|
|
136
|
-
void execPromise('wb:plugin:config:loading-state', loadingState);
|
|
137
|
-
},
|
|
138
|
-
subscribeToWorkbookVariable(configId, callback) {
|
|
139
|
-
(0, error_1.validateConfigId)(configId, 'variable');
|
|
140
|
-
const setValues = (values) => {
|
|
141
|
-
callback(values[configId]);
|
|
142
|
-
};
|
|
143
|
-
on('wb:plugin:variable:update', setValues);
|
|
144
|
-
return () => {
|
|
145
|
-
off('wb:plugin:variable:update', setValues);
|
|
146
|
-
};
|
|
147
|
-
},
|
|
148
|
-
subscribeToWorkbookInteraction(configId, callback) {
|
|
149
|
-
(0, error_1.validateConfigId)(configId, 'interaction');
|
|
150
|
-
const setValues = (values) => {
|
|
151
|
-
callback(values[configId]);
|
|
152
|
-
};
|
|
153
|
-
on('wb:plugin:selection:update', setValues);
|
|
154
|
-
return () => {
|
|
155
|
-
off('wb:plugin:selection:update', setValues);
|
|
156
|
-
};
|
|
157
|
-
},
|
|
158
|
-
subscribeToUrlParameter(configId, callback) {
|
|
159
|
-
(0, error_1.validateConfigId)(configId, 'url-parameter');
|
|
160
|
-
const setValues = (values) => {
|
|
161
|
-
callback(values[configId]);
|
|
162
|
-
};
|
|
163
|
-
setValues(subscribedUrlParameters);
|
|
164
|
-
on('wb:plugin:url-parameter:update', setValues);
|
|
165
|
-
return () => {
|
|
166
|
-
off('wb:plugin:url-parameter:update', setValues);
|
|
167
|
-
};
|
|
168
|
-
},
|
|
169
|
-
getUrlParameter(configId) {
|
|
170
|
-
(0, error_1.validateConfigId)(configId, 'url-parameter');
|
|
171
|
-
return subscribedUrlParameters[configId];
|
|
172
|
-
},
|
|
173
|
-
setUrlParameter(configId, value) {
|
|
174
|
-
(0, error_1.validateConfigId)(configId, 'url-parameter');
|
|
175
|
-
void execPromise('wb:plugin:url-parameter:set', configId, value);
|
|
176
|
-
}
|
|
177
|
-
},
|
|
178
|
-
elements: {
|
|
179
|
-
getElementColumns(configId) {
|
|
180
|
-
(0, error_1.validateConfigId)(configId, 'element');
|
|
181
|
-
return execPromise('wb:plugin:element:columns:get', configId);
|
|
182
|
-
},
|
|
183
|
-
subscribeToElementColumns(configId, callback) {
|
|
184
|
-
(0, error_1.validateConfigId)(configId, 'element');
|
|
185
|
-
const eventName = `wb:plugin:element:${configId}:columns`;
|
|
186
|
-
on(eventName, callback);
|
|
187
|
-
void execPromise('wb:plugin:element:subscribe:columns', configId);
|
|
188
|
-
return () => {
|
|
189
|
-
off(eventName, callback);
|
|
190
|
-
void execPromise('wb:plugin:element:unsubscribe:columns', configId);
|
|
191
|
-
};
|
|
192
|
-
},
|
|
193
|
-
subscribeToElementData(configId, callback) {
|
|
194
|
-
(0, error_1.validateConfigId)(configId, 'element');
|
|
195
|
-
const eventName = `wb:plugin:element:${configId}:data`;
|
|
196
|
-
on(eventName, callback);
|
|
197
|
-
void execPromise('wb:plugin:element:subscribe:data', configId);
|
|
198
|
-
return () => {
|
|
199
|
-
off(eventName, callback);
|
|
200
|
-
void execPromise('wb:plugin:element:unsubscribe:data', configId);
|
|
201
|
-
};
|
|
202
|
-
},
|
|
203
|
-
fetchMoreElementData(configId) {
|
|
204
|
-
(0, error_1.validateConfigId)(configId, 'element');
|
|
205
|
-
void execPromise('wb:plugin:element:fetch-more', configId);
|
|
206
|
-
},
|
|
207
|
-
},
|
|
208
|
-
style: {
|
|
209
|
-
subscribe(callback) {
|
|
210
|
-
on('wb:plugin:style:update', callback);
|
|
211
|
-
return () => off('wb:plugin:style:update', callback);
|
|
212
|
-
},
|
|
213
|
-
get() {
|
|
214
|
-
return execPromise('wb:plugin:style:get');
|
|
215
|
-
},
|
|
216
|
-
},
|
|
217
|
-
destroy() {
|
|
218
|
-
Object.keys(listeners).forEach(event => delete listeners[event]);
|
|
219
|
-
window.removeEventListener('message', listener, false);
|
|
220
|
-
},
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
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/error.d.ts
DELETED
package/dist/error.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAEpD,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,MAAM,EAChB,kBAAkB,EAAE,yBAAyB,CAAC,MAAM,CAAC,QAKtD"}
|
package/dist/error.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateConfigId = void 0;
|
|
4
|
-
function validateConfigId(configId, expectedConfigType) {
|
|
5
|
-
if (configId === undefined) {
|
|
6
|
-
console.warn(`Invalid config ${expectedConfigType}: ${configId}`);
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
exports.validateConfigId = validateConfigId;
|
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,EAAE,6BAA6B,EAAE,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>): import("react/jsx-runtime").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,2CAOnC"}
|
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,83 +0,0 @@
|
|
|
1
|
-
import { PluginInstance, CustomPluginConfigOptions, WorkbookElementColumns, WorkbookElementData, WorkbookVariable, PluginStyle, UrlParameter } 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 config element
|
|
20
|
-
* @param {string} configId ID from the config for fetching element columns, with type: 'element'
|
|
21
|
-
* @returns {WorkbookElementColumns} Values of corresponding columns contained
|
|
22
|
-
* within the config element
|
|
23
|
-
*/
|
|
24
|
-
export declare function useElementColumns(configId: string): WorkbookElementColumns;
|
|
25
|
-
/**
|
|
26
|
-
* Provides the latest data values from config element (max 25_000)
|
|
27
|
-
* @param {string} configId ID from the config for fetching element data, with type: 'element'
|
|
28
|
-
* @returns {WorkbookElementData} Element Data for config element, if any
|
|
29
|
-
*/
|
|
30
|
-
export declare function useElementData(configId: string): WorkbookElementData;
|
|
31
|
-
/**
|
|
32
|
-
* Provides the latest data values from corresponding config element with a callback to
|
|
33
|
-
* fetch more in chunks of 25_000 data points
|
|
34
|
-
* @param {string} configId ID from the config for fetching paginated
|
|
35
|
-
* element data, with type: 'element'
|
|
36
|
-
* @returns {WorkbookElementData} Element Data for configured config element, if any
|
|
37
|
-
*/
|
|
38
|
-
export declare function usePaginatedElementData(configId: string): [WorkbookElementData, () => void];
|
|
39
|
-
/**
|
|
40
|
-
* Provides the latest value for entire config or certain key within the config
|
|
41
|
-
* @param {string} key Key within Plugin Config, optional
|
|
42
|
-
* @returns Entire config if no key passed in or value for key within plugin config
|
|
43
|
-
*/
|
|
44
|
-
export declare function useConfig(key?: string): any;
|
|
45
|
-
/**
|
|
46
|
-
* React hook for accessing a workbook control variable
|
|
47
|
-
* @param {string} id ID from the config of type: 'variable'
|
|
48
|
-
* @returns {[(WorkbookVariable | undefined), Function]} Constantly updating
|
|
49
|
-
* value of the control variable and setter for the variable
|
|
50
|
-
*/
|
|
51
|
-
export declare function useVariable(id: string): [WorkbookVariable | undefined, Function];
|
|
52
|
-
/**
|
|
53
|
-
* React hook for accessing a url parameter
|
|
54
|
-
* @param {string} id ID from the config of type: 'url-parameter'
|
|
55
|
-
* @returns {[(UrlParameter | undefined), Function]} Constantly updating value of the url parameter and setter for the url parameter
|
|
56
|
-
*/
|
|
57
|
-
export declare function useUrlParameter(id: string): [UrlParameter | undefined, (value: string) => void];
|
|
58
|
-
/**
|
|
59
|
-
* @deprecated Use Action API instead
|
|
60
|
-
* React hook for accessing a workbook interaction selections state
|
|
61
|
-
* @param {string} id ID from the config of type: 'interaction'
|
|
62
|
-
* @returns {[(WorkbookSelection | undefined), Function]} Constantly updating selection state and setter thereof
|
|
63
|
-
*/
|
|
64
|
-
export declare function useInteraction(id: string, elementId: string): [unknown, Function];
|
|
65
|
-
/**
|
|
66
|
-
* React hook for returning a triggering callback function for the registered
|
|
67
|
-
* action trigger
|
|
68
|
-
* @param {string} configId ID from the config of type: 'action-trigger'
|
|
69
|
-
* @returns {Function} A callback function to trigger the action
|
|
70
|
-
*/
|
|
71
|
-
export declare function useActionTrigger(configId: string): () => void;
|
|
72
|
-
/**
|
|
73
|
-
* React hook for registering and unregistering an action effect
|
|
74
|
-
* @param {string} configId ID from the config of type: 'action-effect'
|
|
75
|
-
* @param {Function} effect The function to be called when the action is triggered
|
|
76
|
-
*/
|
|
77
|
-
export declare function useActionEffect(configId: string, effect: () => void): void;
|
|
78
|
-
/**
|
|
79
|
-
* React hook for accessing plugin style with live updates
|
|
80
|
-
* @returns {PluginStyle | undefined} Style properties from the workbook if available
|
|
81
|
-
*/
|
|
82
|
-
export declare function usePluginStyle(): PluginStyle | undefined;
|
|
83
|
-
//# 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,EAChB,WAAW,EACX,YAAY,EACb,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;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,sBAAsB,CAW1E;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,mBAAmB,CAWpE;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,MAAM,GACf,CAAC,mBAAmB,EAAE,MAAM,IAAI,CAAC,CAiBnC;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,GAAG,CAmB3C;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,EAAE,EAAE,MAAM,GACT,CAAC,gBAAgB,GAAG,SAAS,EAAE,QAAQ,CAAC,CAoB1C;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,EAAE,EAAE,MAAM,GACT,CAAC,YAAY,GAAG,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC,CAoBrD;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,EAAE,EAAE,MAAM,EACV,SAAS,EAAE,MAAM,GAChB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAoBrB;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,IAAI,CAM7D;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,IAAI,QAYnE;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,WAAW,GAAG,SAAS,CAWxD"}
|