@sigmacomputing/plugin 1.1.0-alpha.2 → 1.1.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 +25 -0
- package/LICENSE +21 -0
- package/README.md +993 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +5 -0
- package/dist/error.d.ts +3 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/error.js +9 -0
- package/dist/{types/index.d.ts → index.d.ts} +2 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/react.d.ts +3 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +20 -0
- package/dist/{types/types/index.d.ts → types.d.ts} +132 -62
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/package.json +37 -29
- package/dist/cjs/client/index.js +0 -9
- package/dist/cjs/client/index.js.map +0 -1
- package/dist/cjs/client/initialize.js +0 -158
- package/dist/cjs/client/initialize.js.map +0 -1
- package/dist/cjs/index.js +0 -12
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/utils/polyfillRequestAnimationFrame.js +0 -17
- package/dist/cjs/utils/polyfillRequestAnimationFrame.js.map +0 -1
- package/dist/esm/client/index.esm.js +0 -6
- package/dist/esm/client/index.esm.js.map +0 -1
- package/dist/esm/client/initialize.esm.js +0 -156
- package/dist/esm/client/initialize.esm.js.map +0 -1
- package/dist/esm/index.esm.js +0 -4
- package/dist/esm/index.esm.js.map +0 -1
- package/dist/esm/utils/polyfillRequestAnimationFrame.esm.js +0 -15
- package/dist/esm/utils/polyfillRequestAnimationFrame.esm.js.map +0 -1
- package/dist/mjs/client/index.mjs +0 -6
- package/dist/mjs/client/index.mjs.map +0 -1
- package/dist/mjs/client/initialize.mjs +0 -156
- package/dist/mjs/client/initialize.mjs.map +0 -1
- package/dist/mjs/index.mjs +0 -4
- package/dist/mjs/index.mjs.map +0 -1
- package/dist/mjs/utils/polyfillRequestAnimationFrame.mjs +0 -15
- package/dist/mjs/utils/polyfillRequestAnimationFrame.mjs.map +0 -1
- package/dist/types/.tsbuildinfo +0 -1
- package/dist/types/client/index.d.ts +0 -4
- package/dist/types/client/index.d.ts.map +0 -1
- package/dist/types/client/initialize.d.ts +0 -3
- package/dist/types/client/initialize.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/types/index.d.ts.map +0 -1
- package/dist/types/utils/polyfillRequestAnimationFrame.d.ts +0 -8
- package/dist/types/utils/polyfillRequestAnimationFrame.d.ts.map +0 -1
- package/dist/umd/plugin.development.js +0 -181
- package/dist/umd/plugin.development.js.map +0 -1
- package/dist/umd/plugin.production.min.js +0 -2
- package/dist/umd/plugin.production.min.js.map +0 -1
- package/src/client/index.ts +0 -5
- package/src/client/initialize.ts +0 -196
- package/src/globals.d.ts +0 -5
- package/src/index.ts +0 -4
- package/src/types/index.ts +0 -322
- package/src/utils/polyfillRequestAnimationFrame.ts +0 -13
package/src/client/initialize.ts
DELETED
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
import type {
|
|
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('wb:plugin:init', __VERSION__).then(config => {
|
|
41
|
-
Object.assign(pluginConfig, config);
|
|
42
|
-
emit('init', pluginConfig);
|
|
43
|
-
emit('config', pluginConfig.config);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
on(
|
|
47
|
-
'wb:plugin:variable:update',
|
|
48
|
-
(updatedVariables: Record<string, WorkbookVariable>) => {
|
|
49
|
-
subscribedWorkbookVars = {};
|
|
50
|
-
Object.assign(subscribedWorkbookVars, updatedVariables);
|
|
51
|
-
},
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
on('wb:plugin:selection:update', (updatedInteractions: unknown) => {
|
|
55
|
-
subscribedInteractions = {};
|
|
56
|
-
Object.assign(subscribedInteractions, updatedInteractions);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
function on(event: string, listener: Function) {
|
|
60
|
-
listeners[event] = listeners[event] || [];
|
|
61
|
-
listeners[event].push(listener);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function off(event: string, listener: Function) {
|
|
65
|
-
if (listeners[event] == null) return;
|
|
66
|
-
listeners[event] = listeners[event].filter(a => a !== listener);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function emit(event: string, ...args: any) {
|
|
70
|
-
Object.values(listeners[event] || []).forEach(fn => fn(...args));
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function execPromise<R>(event: string, ...args: any): Promise<R> {
|
|
74
|
-
return new Promise((resolve, reject) => {
|
|
75
|
-
const callback = (data: R, error: any) => {
|
|
76
|
-
if (error) reject(error);
|
|
77
|
-
else resolve(data);
|
|
78
|
-
off(event, callback);
|
|
79
|
-
};
|
|
80
|
-
on(event, callback);
|
|
81
|
-
window.parent.postMessage(
|
|
82
|
-
{ type: event, args, elementId: pluginConfig.id },
|
|
83
|
-
pluginConfig?.wbOrigin ?? '*',
|
|
84
|
-
);
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return {
|
|
89
|
-
get sigmaEnv() {
|
|
90
|
-
return pluginConfig.sigmaEnv;
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
get isScreenshot() {
|
|
94
|
-
return pluginConfig.screenshot;
|
|
95
|
-
},
|
|
96
|
-
|
|
97
|
-
config: {
|
|
98
|
-
// @ts-ignore
|
|
99
|
-
getKey(key) {
|
|
100
|
-
return pluginConfig?.config?.[key]!;
|
|
101
|
-
},
|
|
102
|
-
get() {
|
|
103
|
-
return pluginConfig.config;
|
|
104
|
-
},
|
|
105
|
-
set(partialConfig) {
|
|
106
|
-
void execPromise('wb:plugin:config:update', partialConfig);
|
|
107
|
-
},
|
|
108
|
-
setKey(key, value) {
|
|
109
|
-
void execPromise('wb:plugin:config:update', {
|
|
110
|
-
[key]: value,
|
|
111
|
-
});
|
|
112
|
-
},
|
|
113
|
-
subscribe(listener) {
|
|
114
|
-
on('config', listener);
|
|
115
|
-
return () => off('config', listener);
|
|
116
|
-
},
|
|
117
|
-
getVariable(id: string): WorkbookVariable {
|
|
118
|
-
return subscribedWorkbookVars[id];
|
|
119
|
-
},
|
|
120
|
-
setVariable(id: string, ...values: unknown[]) {
|
|
121
|
-
void execPromise('wb:plugin:variable:set', id, ...values);
|
|
122
|
-
},
|
|
123
|
-
getInteraction(id: string) {
|
|
124
|
-
return subscribedInteractions[id];
|
|
125
|
-
},
|
|
126
|
-
setInteraction(
|
|
127
|
-
id: string,
|
|
128
|
-
elementId: string,
|
|
129
|
-
selection:
|
|
130
|
-
| string[]
|
|
131
|
-
| Array<Record<string, { type: string; val?: unknown }>>,
|
|
132
|
-
) {
|
|
133
|
-
void execPromise('wb:plugin:selection:set', id, elementId, selection);
|
|
134
|
-
},
|
|
135
|
-
configureEditorPanel(options) {
|
|
136
|
-
void execPromise('wb:plugin:config:inspector', options);
|
|
137
|
-
},
|
|
138
|
-
setLoadingState(loadingState) {
|
|
139
|
-
void execPromise('wb:plugin:config:loading-state', loadingState);
|
|
140
|
-
},
|
|
141
|
-
subscribeToWorkbookVariable(
|
|
142
|
-
id: string,
|
|
143
|
-
callback: (input: WorkbookVariable) => void,
|
|
144
|
-
): Unsubscriber {
|
|
145
|
-
const setValues = (values: Record<string, WorkbookVariable>) => {
|
|
146
|
-
callback(values[id]);
|
|
147
|
-
};
|
|
148
|
-
on('wb:plugin:variable:update', setValues);
|
|
149
|
-
return () => {
|
|
150
|
-
off('wb:plugin:variable:update', setValues);
|
|
151
|
-
};
|
|
152
|
-
},
|
|
153
|
-
subscribeToWorkbookInteraction(
|
|
154
|
-
id: string,
|
|
155
|
-
callback: (input: WorkbookSelection[]) => void,
|
|
156
|
-
): Unsubscriber {
|
|
157
|
-
const setValues = (values: Record<string, WorkbookSelection[]>) => {
|
|
158
|
-
callback(values[id]);
|
|
159
|
-
};
|
|
160
|
-
on('wb:plugin:selection:update', setValues);
|
|
161
|
-
return () => {
|
|
162
|
-
off('wb:plugin:selection:update', setValues);
|
|
163
|
-
};
|
|
164
|
-
},
|
|
165
|
-
},
|
|
166
|
-
elements: {
|
|
167
|
-
getElementColumns(id) {
|
|
168
|
-
return execPromise('wb:plugin:element:columns:get', id);
|
|
169
|
-
},
|
|
170
|
-
subscribeToElementColumns(id, callback) {
|
|
171
|
-
const eventName = `wb:plugin:element:${id}:columns`;
|
|
172
|
-
on(eventName, callback);
|
|
173
|
-
void execPromise('wb:plugin:element:subscribe:columns', id);
|
|
174
|
-
|
|
175
|
-
return () => {
|
|
176
|
-
off(eventName, callback);
|
|
177
|
-
void execPromise('wb:plugin:element:unsubscribe:columns', id);
|
|
178
|
-
};
|
|
179
|
-
},
|
|
180
|
-
subscribeToElementData(id, callback) {
|
|
181
|
-
const eventName = `wb:plugin:element:${id}:data`;
|
|
182
|
-
on(eventName, callback);
|
|
183
|
-
void execPromise('wb:plugin:element:subscribe:data', id);
|
|
184
|
-
|
|
185
|
-
return () => {
|
|
186
|
-
off(eventName, callback);
|
|
187
|
-
void execPromise('wb:plugin:element:unsubscribe:data', id);
|
|
188
|
-
};
|
|
189
|
-
},
|
|
190
|
-
},
|
|
191
|
-
destroy() {
|
|
192
|
-
Object.keys(listeners).forEach(event => delete listeners[event]);
|
|
193
|
-
window.removeEventListener('message', listener, false);
|
|
194
|
-
},
|
|
195
|
-
};
|
|
196
|
-
}
|
package/src/globals.d.ts
DELETED
package/src/index.ts
DELETED
package/src/types/index.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
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* requestAnimationFrame() calls are paused in most browsers when running in background tabs or hidden <iframe>s in order to improve performance and battery life
|
|
3
|
-
*
|
|
4
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
|
|
5
|
-
* @param w Window Object
|
|
6
|
-
*/
|
|
7
|
-
export function polyfillRequestAnimationFrame(window: Window) {
|
|
8
|
-
if ('requestAnimationFrame' in window) {
|
|
9
|
-
window.requestAnimationFrame = (handler: TimerHandler): number =>
|
|
10
|
-
window.setTimeout(handler, 1000 / 60);
|
|
11
|
-
window.cancelAnimationFrame = (id?: number) => window.clearTimeout(id);
|
|
12
|
-
}
|
|
13
|
-
}
|