@sigmacomputing/plugin 1.1.0-alpha.3 → 1.1.1

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.
Files changed (78) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/LICENSE +21 -0
  3. package/README.md +993 -0
  4. package/dist/client/initialize.d.ts +3 -0
  5. package/dist/client/initialize.d.ts.map +1 -0
  6. package/dist/client/initialize.js +223 -0
  7. package/dist/client.d.ts +2 -0
  8. package/dist/client.d.ts.map +1 -0
  9. package/dist/client.js +5 -0
  10. package/dist/error.d.ts +3 -0
  11. package/dist/error.d.ts.map +1 -0
  12. package/dist/error.js +9 -0
  13. package/dist/{types/index.d.ts → index.d.ts} +2 -1
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.js +22 -0
  16. package/dist/react/Context.d.ts +4 -0
  17. package/dist/react/Context.d.ts.map +1 -0
  18. package/dist/react/Context.js +6 -0
  19. package/dist/react/Provider.d.ts +8 -0
  20. package/dist/react/Provider.d.ts.map +1 -0
  21. package/dist/react/Provider.js +9 -0
  22. package/dist/react/hooks.d.ts +83 -0
  23. package/dist/react/hooks.d.ts.map +1 -0
  24. package/dist/react/hooks.js +231 -0
  25. package/dist/react.d.ts +3 -0
  26. package/dist/react.d.ts.map +1 -0
  27. package/dist/react.js +20 -0
  28. package/dist/{types/types/index.d.ts → types.d.ts} +132 -62
  29. package/dist/types.d.ts.map +1 -0
  30. package/dist/types.js +2 -0
  31. package/dist/utils/deepEqual.d.ts +2 -0
  32. package/dist/utils/deepEqual.d.ts.map +1 -0
  33. package/dist/utils/deepEqual.js +28 -0
  34. package/dist/{types/utils → utils}/polyfillRequestAnimationFrame.d.ts +1 -1
  35. package/dist/utils/polyfillRequestAnimationFrame.d.ts.map +1 -0
  36. package/dist/{cjs/utils → utils}/polyfillRequestAnimationFrame.js +8 -9
  37. package/package.json +40 -29
  38. package/dist/cjs/client/index.js +0 -9
  39. package/dist/cjs/client/index.js.map +0 -1
  40. package/dist/cjs/client/initialize.js +0 -158
  41. package/dist/cjs/client/initialize.js.map +0 -1
  42. package/dist/cjs/index.js +0 -12
  43. package/dist/cjs/index.js.map +0 -1
  44. package/dist/cjs/utils/polyfillRequestAnimationFrame.js.map +0 -1
  45. package/dist/esm/client/index.esm.js +0 -6
  46. package/dist/esm/client/index.esm.js.map +0 -1
  47. package/dist/esm/client/initialize.esm.js +0 -156
  48. package/dist/esm/client/initialize.esm.js.map +0 -1
  49. package/dist/esm/index.esm.js +0 -4
  50. package/dist/esm/index.esm.js.map +0 -1
  51. package/dist/esm/utils/polyfillRequestAnimationFrame.esm.js +0 -15
  52. package/dist/esm/utils/polyfillRequestAnimationFrame.esm.js.map +0 -1
  53. package/dist/mjs/client/index.mjs +0 -6
  54. package/dist/mjs/client/index.mjs.map +0 -1
  55. package/dist/mjs/client/initialize.mjs +0 -156
  56. package/dist/mjs/client/initialize.mjs.map +0 -1
  57. package/dist/mjs/index.mjs +0 -4
  58. package/dist/mjs/index.mjs.map +0 -1
  59. package/dist/mjs/utils/polyfillRequestAnimationFrame.mjs +0 -15
  60. package/dist/mjs/utils/polyfillRequestAnimationFrame.mjs.map +0 -1
  61. package/dist/types/.tsbuildinfo +0 -1
  62. package/dist/types/client/index.d.ts +0 -4
  63. package/dist/types/client/index.d.ts.map +0 -1
  64. package/dist/types/client/initialize.d.ts +0 -3
  65. package/dist/types/client/initialize.d.ts.map +0 -1
  66. package/dist/types/index.d.ts.map +0 -1
  67. package/dist/types/types/index.d.ts.map +0 -1
  68. package/dist/types/utils/polyfillRequestAnimationFrame.d.ts.map +0 -1
  69. package/dist/umd/plugin.development.js +0 -181
  70. package/dist/umd/plugin.development.js.map +0 -1
  71. package/dist/umd/plugin.production.min.js +0 -2
  72. package/dist/umd/plugin.production.min.js.map +0 -1
  73. package/src/client/index.ts +0 -5
  74. package/src/client/initialize.ts +0 -196
  75. package/src/globals.d.ts +0 -5
  76. package/src/index.ts +0 -4
  77. package/src/types/index.ts +0 -322
  78. package/src/utils/polyfillRequestAnimationFrame.ts +0 -13
@@ -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
- }