@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.
Files changed (56) hide show
  1. package/CHANGELOG.md +0 -14
  2. package/LICENSE +1 -1
  3. package/README.md +19 -24
  4. package/dist/cjs/index.cjs +506 -0
  5. package/dist/cjs/index.cjs.map +1 -0
  6. package/dist/cjs/index.d.cts +438 -0
  7. package/dist/esm/index.d.ts +438 -0
  8. package/dist/esm/index.js +466 -0
  9. package/dist/esm/index.js.map +1 -0
  10. package/dist/umd/sigmacomputing-plugin.umd.js +2 -0
  11. package/dist/umd/sigmacomputing-plugin.umd.js.map +1 -0
  12. package/package.json +69 -36
  13. package/src/client/initialize.ts +280 -0
  14. package/src/client.ts +3 -0
  15. package/src/globals.d.ts +2 -0
  16. package/{dist/index.d.ts → src/index.ts} +1 -1
  17. package/src/react/Context.ts +6 -0
  18. package/src/react/Provider.tsx +20 -0
  19. package/src/react/hooks.ts +298 -0
  20. package/src/react.ts +3 -0
  21. package/src/types.ts +412 -0
  22. package/src/utils/deepEqual.ts +23 -0
  23. package/src/utils/error.ts +10 -0
  24. package/src/utils/polyfillRequestAnimationFrame.ts +13 -0
  25. package/dist/client/initialize.d.ts +0 -3
  26. package/dist/client/initialize.d.ts.map +0 -1
  27. package/dist/client/initialize.js +0 -223
  28. package/dist/client.d.ts +0 -2
  29. package/dist/client.d.ts.map +0 -1
  30. package/dist/client.js +0 -5
  31. package/dist/error.d.ts +0 -3
  32. package/dist/error.d.ts.map +0 -1
  33. package/dist/error.js +0 -9
  34. package/dist/index.d.ts.map +0 -1
  35. package/dist/index.js +0 -22
  36. package/dist/react/Context.d.ts +0 -4
  37. package/dist/react/Context.d.ts.map +0 -1
  38. package/dist/react/Context.js +0 -6
  39. package/dist/react/Provider.d.ts +0 -8
  40. package/dist/react/Provider.d.ts.map +0 -1
  41. package/dist/react/Provider.js +0 -9
  42. package/dist/react/hooks.d.ts +0 -83
  43. package/dist/react/hooks.d.ts.map +0 -1
  44. package/dist/react/hooks.js +0 -231
  45. package/dist/react.d.ts +0 -3
  46. package/dist/react.d.ts.map +0 -1
  47. package/dist/react.js +0 -20
  48. package/dist/types.d.ts +0 -332
  49. package/dist/types.d.ts.map +0 -1
  50. package/dist/types.js +0 -2
  51. package/dist/utils/deepEqual.d.ts +0 -2
  52. package/dist/utils/deepEqual.d.ts.map +0 -1
  53. package/dist/utils/deepEqual.js +0 -28
  54. package/dist/utils/polyfillRequestAnimationFrame.d.ts +0 -8
  55. package/dist/utils/polyfillRequestAnimationFrame.d.ts.map +0 -1
  56. package/dist/utils/polyfillRequestAnimationFrame.js +0 -16
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["React","React"],"sources":["../../src/utils/deepEqual.ts","../../src/utils/error.ts","../../src/client/initialize.ts","../../src/client.ts","../../src/react/Context.ts","../../src/react/hooks.ts","../../src/react/Provider.tsx","../../src/utils/polyfillRequestAnimationFrame.ts"],"sourcesContent":["function isObject(obj: any) {\n if (typeof obj === 'object' && obj != null) {\n return true;\n } else {\n return false;\n }\n}\n\nexport function deepEqual(obj1: any, obj2: any) {\n if (obj1 === obj2) {\n return true;\n } else if (isObject(obj1) && isObject(obj2)) {\n if (Object.keys(obj1).length !== Object.keys(obj2).length) {\n return false;\n }\n for (const prop in obj1) {\n if (!deepEqual(obj1[prop], obj2[prop])) {\n return false;\n }\n }\n return true;\n }\n}\n","import { CustomPluginConfigOptions } from '../types';\n\nexport function validateConfigId(\n configId: string,\n expectedConfigType: CustomPluginConfigOptions['type'],\n) {\n if (configId === undefined) {\n console.warn(`Invalid config ${expectedConfigType}: ${configId}`);\n }\n}\n","import {\n PluginConfig,\n PluginInstance,\n PluginMessageResponse,\n PluginStyle,\n UrlParameter,\n WorkbookSelection,\n WorkbookVariable,\n} from '../types';\nimport { validateConfigId } from '../utils/error';\n\nexport function initialize<T = {}>(): PluginInstance<T> {\n const pluginConfig: Partial<PluginConfig<T>> = {\n config: {} as T,\n };\n\n let subscribedInteractions: Record<string, WorkbookSelection[]> = {};\n let subscribedWorkbookVars: Record<string, WorkbookVariable> = {};\n let subscribedUrlParameters: Record<string, UrlParameter> = {};\n const registeredEffects: Record<string, () => void> = {};\n\n const listeners: {\n [event: string]: Function[];\n } = {};\n\n const location = new URL(document.location.href);\n for (const [key, value] of location.searchParams.entries()) {\n try {\n pluginConfig[key] = JSON.parse(value);\n } catch (_err: unknown) {\n if (__VITEST_BROWSER__ && (key === 'iframeId' || key === 'sessionId')) {\n // noop: vitest browser injects these into the test iframe URL\n } else {\n console.error(\n `Failed to parse URL param ${key} with value ${value} as JSON.`,\n );\n }\n }\n }\n\n const listener = (e: PluginMessageResponse) => {\n emit(e.data.type, e.data.result, e.data.error);\n };\n\n window.addEventListener('message', listener, false);\n window.addEventListener('click', () => execPromise('wb:plugin:focus'));\n\n on('wb:plugin:config:update', (config: PluginConfig<T>) => {\n Object.assign(pluginConfig, config);\n emit('config', pluginConfig.config ?? {});\n });\n\n // send initialize event\n void execPromise('wb:plugin:init', __VERSION__).then(config => {\n Object.assign(pluginConfig, config);\n emit('init', pluginConfig);\n emit('config', pluginConfig.config);\n });\n\n on(\n 'wb:plugin:variable:update',\n (updatedVariables: Record<string, WorkbookVariable>) => {\n subscribedWorkbookVars = {};\n Object.assign(subscribedWorkbookVars, updatedVariables);\n },\n );\n\n on('wb:plugin:selection:update', (updatedInteractions: unknown) => {\n subscribedInteractions = {};\n Object.assign(subscribedInteractions, updatedInteractions);\n });\n\n on(\n 'wb:plugin:url-parameter:update',\n (updatedUrlParameters: Record<string, UrlParameter>) => {\n subscribedUrlParameters = {};\n Object.assign(subscribedUrlParameters, updatedUrlParameters);\n },\n );\n\n on('wb:plugin:action-effect:invoke', (configId: string) => {\n const effect = registeredEffects[configId];\n if (!effect) {\n throw new Error(`Unknown action effect with name: ${configId}`);\n }\n effect();\n });\n\n function on(event: string, listener: Function) {\n listeners[event] = listeners[event] || [];\n listeners[event].push(listener);\n }\n\n function off(event: string, listener: Function) {\n if (listeners[event] == null) return;\n listeners[event] = listeners[event].filter(a => a !== listener);\n }\n\n function emit(event: string, ...args: any) {\n Object.values(listeners[event] || []).forEach(fn => fn(...args));\n }\n\n function execPromise<R>(event: string, ...args: any): Promise<R> {\n return new Promise((resolve, reject) => {\n const callback = (data: R, error: any) => {\n if (error) reject(error);\n else resolve(data);\n off(event, callback);\n };\n on(event, callback);\n window.parent.postMessage(\n { type: event, args, elementId: pluginConfig.id },\n pluginConfig?.wbOrigin ?? '*',\n );\n });\n }\n\n return {\n get sigmaEnv() {\n return pluginConfig.sigmaEnv;\n },\n\n get isScreenshot() {\n return pluginConfig.screenshot;\n },\n\n config: {\n // @ts-ignore TODO: Fix\n getKey(key) {\n return pluginConfig?.config?.[key];\n },\n get() {\n return pluginConfig.config;\n },\n set(partialConfig) {\n void execPromise('wb:plugin:config:update', partialConfig);\n },\n setKey(key, value) {\n void execPromise('wb:plugin:config:update', {\n [key]: value,\n });\n },\n subscribe(listener) {\n on('config', listener);\n return () => off('config', listener);\n },\n getVariable(configId: string) {\n validateConfigId(configId, 'variable');\n return subscribedWorkbookVars[configId];\n },\n setVariable(configId: string, ...values: unknown[]) {\n validateConfigId(configId, 'variable');\n void execPromise('wb:plugin:variable:set', configId, ...values);\n },\n getInteraction(configId: string) {\n validateConfigId(configId, 'interaction');\n return subscribedInteractions[configId];\n },\n setInteraction(\n configId: string,\n elementId: string,\n selection:\n | string[]\n | Array<Record<string, { type: string; val?: unknown }>>,\n ) {\n validateConfigId(configId, 'interaction');\n void execPromise(\n 'wb:plugin:selection:set',\n configId,\n elementId,\n selection,\n );\n },\n triggerAction(configId: string) {\n validateConfigId(configId, 'action-trigger');\n void execPromise('wb:plugin:action-trigger:invoke', configId);\n },\n registerEffect(configId: string, effect: () => void) {\n validateConfigId(configId, 'action-effect');\n registeredEffects[configId] = effect;\n return () => {\n delete registeredEffects[configId];\n };\n },\n configureEditorPanel(options) {\n void execPromise('wb:plugin:config:inspector', options);\n },\n setLoadingState(loadingState) {\n void execPromise('wb:plugin:config:loading-state', loadingState);\n },\n subscribeToWorkbookVariable(configId, callback) {\n validateConfigId(configId, 'variable');\n const setValues = (values: Record<string, WorkbookVariable>) => {\n callback(values[configId]);\n };\n on('wb:plugin:variable:update', setValues);\n return () => {\n off('wb:plugin:variable:update', setValues);\n };\n },\n subscribeToWorkbookInteraction(configId, callback) {\n validateConfigId(configId, 'interaction');\n const setValues = (values: Record<string, WorkbookSelection[]>) => {\n callback(values[configId]);\n };\n on('wb:plugin:selection:update', setValues);\n return () => {\n off('wb:plugin:selection:update', setValues);\n };\n },\n subscribeToUrlParameter(configId, callback) {\n validateConfigId(configId, 'url-parameter');\n const setValues = (values: Record<string, UrlParameter>) => {\n callback(values[configId]);\n };\n setValues(subscribedUrlParameters);\n on('wb:plugin:url-parameter:update', setValues);\n return () => {\n off('wb:plugin:url-parameter:update', setValues);\n };\n },\n getUrlParameter(configId: string) {\n validateConfigId(configId, 'url-parameter');\n return subscribedUrlParameters[configId];\n },\n setUrlParameter(configId: string, value: string) {\n validateConfigId(configId, 'url-parameter');\n void execPromise('wb:plugin:url-parameter:set', configId, value);\n },\n },\n elements: {\n getElementColumns(configId) {\n validateConfigId(configId, 'element');\n return execPromise('wb:plugin:element:columns:get', configId);\n },\n subscribeToElementColumns(configId, callback) {\n validateConfigId(configId, 'element');\n const eventName = `wb:plugin:element:${configId}:columns`;\n on(eventName, callback);\n void execPromise('wb:plugin:element:subscribe:columns', configId);\n\n return () => {\n off(eventName, callback);\n void execPromise('wb:plugin:element:unsubscribe:columns', configId);\n };\n },\n subscribeToElementData(configId, callback) {\n validateConfigId(configId, 'element');\n const eventName = `wb:plugin:element:${configId}:data`;\n on(eventName, callback);\n void execPromise('wb:plugin:element:subscribe:data', configId);\n\n return () => {\n off(eventName, callback);\n void execPromise('wb:plugin:element:unsubscribe:data', configId);\n };\n },\n fetchMoreElementData(configId) {\n validateConfigId(configId, 'element');\n void execPromise('wb:plugin:element:fetch-more', configId);\n },\n },\n\n style: {\n subscribe(callback: (style: PluginStyle) => void) {\n on('wb:plugin:style:update', callback);\n return () => off('wb:plugin:style:update', callback);\n },\n\n get() {\n return execPromise('wb:plugin:style:get');\n },\n },\n\n destroy() {\n Object.keys(listeners).forEach(event => delete listeners[event]);\n window.removeEventListener('message', listener, false);\n },\n };\n}\n","import { initialize } from './client/initialize';\n\nexport const client = initialize();\n","import * as React from 'react';\n\nimport { client } from '../client';\nimport { PluginInstance } from '../types';\n\nexport const PluginContext = React.createContext<PluginInstance>(client);\n","import * as React from 'react';\n\nimport {\n PluginInstance,\n CustomPluginConfigOptions,\n WorkbookElementColumns,\n WorkbookElementData,\n WorkbookSelection,\n WorkbookVariable,\n PluginStyle,\n UrlParameter,\n} from '../types';\nimport { deepEqual } from '../utils/deepEqual';\n\nimport { PluginContext } from './Context';\n\n/**\n * Gets the entire plugin instance\n * @returns {PluginInstance} Context for the current plugin instance\n */\nexport function usePlugin(): PluginInstance<any> {\n return React.useContext(PluginContext);\n}\n\n/**\n * Provides a setter for the Plugin's Config Options\n * @param {CustomPluginConfigOptions[]} nextOptions Updated possible Config Options\n */\nexport function useEditorPanelConfig(\n nextOptions: CustomPluginConfigOptions[],\n): void {\n const client = usePlugin();\n const optionsRef = React.useRef({});\n\n React.useEffect(() => {\n if (nextOptions == null) return;\n if (!deepEqual(nextOptions, optionsRef.current)) {\n client.config.configureEditorPanel(nextOptions);\n optionsRef.current = nextOptions;\n }\n }, [client, nextOptions]);\n}\n\n/**\n * React hook for Plugin Config loading state\n * @param {boolean} initialState Initial value to set loading state to\n * @returns {[boolean, Function]} Boolean value corresponding to loading state for plugin config and setter for loading state\n */\nexport function useLoadingState(\n initialState: boolean,\n): [boolean, (nextState: boolean) => void] {\n const client = usePlugin();\n const [loading, setLoading] = React.useState(() => {\n client.config.setLoadingState(initialState);\n return initialState;\n });\n\n return [\n loading,\n nextState => {\n if (nextState === loading) return;\n setLoading(nextState);\n client.config.setLoadingState(nextState);\n },\n ];\n}\n\n/**\n * Provides the latest column values from corresponding config element\n * @param {string} configId ID from the config for fetching element columns, with type: 'element'\n * @returns {WorkbookElementColumns} Values of corresponding columns contained\n * within the config element\n */\nexport function useElementColumns(configId: string): WorkbookElementColumns {\n const client = usePlugin();\n const [columns, setColumns] = React.useState<WorkbookElementColumns>({});\n\n React.useEffect(() => {\n if (configId) {\n return client.elements.subscribeToElementColumns(configId, setColumns);\n }\n }, [client, configId]);\n\n return columns;\n}\n\n/**\n * Provides the latest data values from config element (max 25_000)\n * @param {string} configId ID from the config for fetching element data, with type: 'element'\n * @returns {WorkbookElementData} Element Data for config element, if any\n */\nexport function useElementData(configId: string): WorkbookElementData {\n const client = usePlugin();\n const [data, setData] = React.useState<WorkbookElementData>({});\n\n React.useEffect(() => {\n if (configId) {\n return client.elements.subscribeToElementData(configId, setData);\n }\n }, [client, configId]);\n\n return data;\n}\n\n/**\n * Provides the latest data values from corresponding config element with a callback to\n * fetch more in chunks of 25_000 data points\n * @param {string} configId ID from the config for fetching paginated\n * element data, with type: 'element'\n * @returns {WorkbookElementData} Element Data for configured config element, if any\n */\nexport function usePaginatedElementData(\n configId: string,\n): [WorkbookElementData, () => void] {\n const client = usePlugin();\n const [data, setData] = React.useState<WorkbookElementData>({});\n\n const loadMore = React.useCallback(() => {\n if (configId) {\n client.elements.fetchMoreElementData(configId);\n }\n }, [configId, client.elements]);\n\n React.useEffect(() => {\n if (configId) {\n return client.elements.subscribeToElementData(configId, setData);\n }\n }, [client, configId]);\n\n return [data, loadMore];\n}\n\n/**\n * Provides the latest value for entire config or certain key within the config\n * @param {string} key Key within Plugin Config, optional\n * @returns Entire config if no key passed in or value for key within plugin config\n */\nexport function useConfig(key?: string): any {\n const client = usePlugin();\n const [config, setConfig] = React.useState<any>(\n key != null ? client.config.getKey(key) : client.config.get(),\n );\n\n React.useEffect(\n () =>\n client.config.subscribe(newConfig => {\n if (key != null && newConfig[key] !== config[key]) {\n setConfig(newConfig[key]);\n } else {\n setConfig(newConfig);\n }\n }),\n [client, key, config],\n );\n\n return config;\n}\n\n/**\n * React hook for accessing a workbook control variable\n * @param {string} id ID from the config of type: 'variable'\n * @returns {[(WorkbookVariable | undefined), Function]} Constantly updating\n * value of the control variable and setter for the variable\n */\nexport function useVariable(\n id: string,\n): [WorkbookVariable | undefined, Function] {\n const client = usePlugin();\n const [workbookVariable, setWorkbookVariable] =\n React.useState<WorkbookVariable>();\n\n const isFirstRender = React.useRef<boolean>(true);\n\n React.useEffect(() => {\n if (isFirstRender.current) {\n setWorkbookVariable(client.config.getVariable(id));\n isFirstRender.current = false;\n }\n return client.config.subscribeToWorkbookVariable(id, setWorkbookVariable);\n }, [client, id]);\n\n const setVariable = React.useCallback(\n (...values: unknown[]) => client.config.setVariable(id, ...values),\n [id, client.config],\n );\n\n return [workbookVariable, setVariable];\n}\n\n/**\n * React hook for accessing a url parameter\n * @param {string} id ID from the config of type: 'url-parameter'\n * @returns {[(UrlParameter | undefined), Function]} Constantly updating value of the url parameter and setter for the url parameter\n */\nexport function useUrlParameter(\n id: string,\n): [UrlParameter | undefined, (value: string) => void] {\n const client = usePlugin();\n const [urlParameter, setUrlParameter] = React.useState<UrlParameter>();\n\n const isFirstRender = React.useRef<boolean>(true);\n\n React.useEffect(() => {\n if (isFirstRender.current) {\n setUrlParameter(client.config.getUrlParameter(id));\n isFirstRender.current = false;\n }\n return client.config.subscribeToUrlParameter(id, setUrlParameter);\n }, [client, id]);\n\n const setter = React.useCallback(\n (value: string) => client.config.setUrlParameter(id, value),\n [client, id],\n );\n\n return [urlParameter, setter];\n}\n\n/**\n * @deprecated Use Action API instead\n * React hook for accessing a workbook interaction selections state\n * @param {string} id ID from the config of type: 'interaction'\n * @returns {[(WorkbookSelection | undefined), Function]} Constantly updating selection state and setter thereof\n */\nexport function useInteraction(\n id: string,\n elementId: string,\n): [unknown, Function] {\n const client = usePlugin();\n const [workbookInteraction, setWorkbookInteraction] =\n React.useState<WorkbookSelection[]>();\n\n React.useEffect(() => {\n return client.config.subscribeToWorkbookInteraction(\n id,\n setWorkbookInteraction,\n );\n }, [client, id]);\n\n const setInteraction = React.useCallback(\n (value: WorkbookSelection[]) => {\n client.config.setInteraction(id, elementId, value);\n },\n [id, elementId, client.config],\n );\n\n return [workbookInteraction, setInteraction];\n}\n\n/**\n * React hook for returning a triggering callback function for the registered\n * action trigger\n * @param {string} configId ID from the config of type: 'action-trigger'\n * @returns {Function} A callback function to trigger the action\n */\nexport function useActionTrigger(configId: string): () => void {\n const client = usePlugin();\n\n return React.useCallback(() => {\n client.config.triggerAction(configId);\n }, [client, configId]);\n}\n\n/**\n * React hook for registering and unregistering an action effect\n * @param {string} configId ID from the config of type: 'action-effect'\n * @param {Function} effect The function to be called when the action is triggered\n */\nexport function useActionEffect(configId: string, effect: () => void) {\n const client = usePlugin();\n\n const effectRef = React.useRef(effect);\n\n React.useEffect(() => {\n effectRef.current = effect;\n });\n\n React.useEffect(() => {\n return client.config.registerEffect(configId, effectRef.current);\n }, [client, configId, effect]);\n}\n\n/**\n * React hook for accessing plugin style with live updates\n * @returns {PluginStyle | undefined} Style properties from the workbook if available\n */\nexport function usePluginStyle(): PluginStyle | undefined {\n const client = usePlugin();\n const [style, setStyle] = React.useState<PluginStyle | undefined>();\n\n React.useEffect(() => {\n // Request initial style data on mount and subscribe to updates\n void client.style.get().then(response => setStyle(response));\n return client.style.subscribe(setStyle);\n }, [client]);\n\n return style;\n}\n","import * as React from 'react';\n\nimport { PluginInstance } from '../types';\n\nimport { PluginContext } from './Context';\n\nexport interface SigmaClientProviderProps<T = any> {\n client: PluginInstance<T>;\n children?: React.ReactNode;\n}\n\nexport function SigmaClientProvider<T = any>(\n props: SigmaClientProviderProps<T>,\n) {\n return (\n <PluginContext.Provider value={props.client}>\n {props.children}\n </PluginContext.Provider>\n );\n}\n","const FPS = 1000 / 60;\n\n/**\n * requestAnimationFrame() calls are paused in most browsers when running in background tabs or hidden <iframe>s in order to improve performance and battery life\n * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame\n */\nexport function polyfillRequestAnimationFrame(window: Window) {\n if ('requestAnimationFrame' in window) {\n window.requestAnimationFrame = callback => window.setTimeout(callback, FPS);\n\n window.cancelAnimationFrame = id => window.clearTimeout(id);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,SAAS,KAAU;AAC1B,KAAI,OAAO,QAAQ,YAAY,OAAO,KACpC,QAAO;KAEP,QAAO;;AAIX,SAAgB,UAAU,MAAW,MAAW;AAC9C,KAAI,SAAS,KACX,QAAO;UACE,SAAS,KAAK,IAAI,SAAS,KAAK,EAAE;AAC3C,MAAI,OAAO,KAAK,KAAK,CAAC,WAAW,OAAO,KAAK,KAAK,CAAC,OACjD,QAAO;AAET,OAAK,MAAM,QAAQ,KACjB,KAAI,CAAC,UAAU,KAAK,OAAO,KAAK,MAAM,CACpC,QAAO;AAGX,SAAO;;;;;AClBX,SAAgB,iBACd,UACA,oBACA;AACA,KAAI,aAAa,KAAA,EACf,SAAQ,KAAK,kBAAkB,mBAAmB,IAAI,WAAW;;;;ACIrE,SAAgB,aAAwC;CACtD,MAAM,eAAyC,EAC7C,QAAQ,EAAE,EACX;CAED,IAAI,yBAA8D,EAAE;CACpE,IAAI,yBAA2D,EAAE;CACjE,IAAI,0BAAwD,EAAE;CAC9D,MAAM,oBAAgD,EAAE;CAExD,MAAM,YAEF,EAAE;CAEN,MAAM,WAAW,IAAI,IAAI,SAAS,SAAS,KAAK;AAChD,MAAK,MAAM,CAAC,KAAK,UAAU,SAAS,aAAa,SAAS,CACxD,KAAI;AACF,eAAa,OAAO,KAAK,MAAM,MAAM;UAC9B,MAAe;AAIpB,UAAQ,MACN,6BAA6B,IAAI,cAAc,MAAM,WACtD;;CAKP,MAAM,YAAY,MAA6B;AAC7C,OAAK,EAAE,KAAK,MAAM,EAAE,KAAK,QAAQ,EAAE,KAAK,MAAM;;AAGhD,QAAO,iBAAiB,WAAW,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AAM,gBAAgB;AACpB,SAAO,OAAO,OAAO,eAAe,UAAU,UAAU,QAAQ;IAC/D;EAAC;EAAQ;EAAU;EAAO,CAAC;;;;;;AAOhC,SAAgB,iBAA0C;CACxD,MAAM,SAAS,WAAW;CAC1B,MAAM,CAAC,OAAO,YAAYA,QAAM,UAAmC;AAEnE,SAAM,gBAAgB;AAEf,SAAO,MAAM,KAAK,CAAC,MAAK,aAAY,SAAS,SAAS,CAAC;AAC5D,SAAO,OAAO,MAAM,UAAU,SAAS;IACtC,CAAC,OAAO,CAAC;AAEZ,QAAO;;;;AC7RT,SAAgB,oBACd,OACA;AACA,QACE,sBAAA,cAAC,cAAc,UAAf,EAAwB,OAAO,MAAM,QAEZ,EADtB,MAAM,SACgB;;;;ACjB7B,MAAM,MAAM,MAAO;;;;;AAMnB,SAAgB,8BAA8B,QAAgB;AAC5D,KAAI,2BAA2B,QAAQ;AACrC,SAAO,yBAAwB,aAAY,OAAO,WAAW,UAAU,IAAI;AAE3E,SAAO,wBAAuB,OAAM,OAAO,aAAa,GAAG"}
@@ -0,0 +1,438 @@
1
+ import * as React from "react";
2
+
3
+ //#region src/types.d.ts
4
+ type ScalarType = 'boolean' | 'datetime' | 'number' | 'integer' | 'text';
5
+ type PrimitiveType = ScalarType | 'variant' | 'link';
6
+ type ValueType = PrimitiveType | 'error';
7
+ /**
8
+ * All mutable workbook control variable types
9
+ */
10
+ type ControlType = 'boolean' | 'date' | 'number' | 'text' | 'text-list' | 'number-list' | 'date-list' | 'number-range' | 'date-range';
11
+ interface PluginConfig<T> {
12
+ id: string;
13
+ config: T;
14
+ screenshot: boolean;
15
+ [key: string]: any;
16
+ }
17
+ /**
18
+ * Style colors available to plugins
19
+ * @typedef {object} PluginStyle
20
+ * @property {string} backgroundColor Background color set from workbook if any
21
+ */
22
+ interface PluginStyle {
23
+ backgroundColor: string;
24
+ }
25
+ /**
26
+ * @typedef {object} WorkbookVariable
27
+ * @property {string} name Name of control variable within workbook
28
+ * @property {{string}} defaultValue Current value containing at least type as string
29
+ */
30
+ interface WorkbookVariable {
31
+ name: string;
32
+ defaultValue: {
33
+ type: string;
34
+ value: any;
35
+ };
36
+ }
37
+ /**
38
+ * @typedef {object} UrlParameter
39
+ * @property {string} value Current url value
40
+ */
41
+ interface UrlParameter {
42
+ value: string;
43
+ }
44
+ type WorkbookSelection = Record<string, {
45
+ type: string;
46
+ val?: unknown;
47
+ }>;
48
+ type PluginMessageResponse = MessageEvent<{
49
+ type: string;
50
+ result: any[];
51
+ error: any;
52
+ }>;
53
+ interface WbElement {
54
+ id: string;
55
+ }
56
+ /**
57
+ * @typedef {object} WorkbookElementData
58
+ * @property {Object<string, any>} data Workbook data sorted by column ID
59
+ */
60
+ interface WorkbookElementData {
61
+ [colId: string]: any[];
62
+ }
63
+ /**
64
+ * Column data
65
+ * @typedef {object} WorkbookElementColumn
66
+ * @property {string} id Column ID
67
+ * @property {string} name Column Name
68
+ * @property {string} columnType Type of data contained within column
69
+ */
70
+ interface WorkbookElementColumn {
71
+ id: string;
72
+ name: string;
73
+ columnType: ValueType;
74
+ }
75
+ /**
76
+ * Record of Column data with corresponding IDs
77
+ * @typedef {object} WorkbookElementColumns
78
+ * @property {Object<string, WorkbookElementColumn>} column Column ID and corresponding column data
79
+ */
80
+ interface WorkbookElementColumns {
81
+ [colId: string]: WorkbookElementColumn;
82
+ }
83
+ /**
84
+ * Function to Unsubscribe from the corresponding elements
85
+ * @typedef {() => void} Unsubscriber
86
+ */
87
+ type Unsubscriber = () => void;
88
+ interface CustomPluginConfigOptionBase {
89
+ name: string;
90
+ label?: string;
91
+ }
92
+ interface CustomPluginConfigGroup extends CustomPluginConfigOptionBase {
93
+ type: 'group';
94
+ }
95
+ interface CustomPluginConfigElement extends CustomPluginConfigOptionBase {
96
+ type: 'element';
97
+ }
98
+ interface CustomPluginConfigColumn extends CustomPluginConfigOptionBase {
99
+ type: 'column';
100
+ allowedTypes?: ValueType[];
101
+ source: string;
102
+ allowMultiple: boolean;
103
+ }
104
+ interface CustomPluginConfigText extends CustomPluginConfigOptionBase {
105
+ type: 'text';
106
+ source?: string;
107
+ secure?: boolean;
108
+ multiline?: boolean;
109
+ placeholder?: string;
110
+ defaultValue?: string;
111
+ }
112
+ interface CustomPluginConfigToggle extends CustomPluginConfigOptionBase {
113
+ type: 'toggle';
114
+ source?: string;
115
+ defaultValue?: boolean;
116
+ }
117
+ interface CustomPluginConfigCheckbox extends CustomPluginConfigOptionBase {
118
+ type: 'checkbox';
119
+ source?: string;
120
+ defaultValue?: boolean;
121
+ }
122
+ interface CustomPluginConfigRadio extends CustomPluginConfigOptionBase {
123
+ type: 'radio';
124
+ source?: string;
125
+ singleLine?: boolean;
126
+ values: string[];
127
+ defaultValue?: string;
128
+ }
129
+ interface CustomPluginConfigDropdown extends CustomPluginConfigOptionBase {
130
+ type: 'dropdown';
131
+ source?: string;
132
+ width?: string;
133
+ values: string[];
134
+ defaultValue?: string;
135
+ }
136
+ interface CustomPluginConfigColor extends CustomPluginConfigOptionBase {
137
+ type: 'color';
138
+ source?: string;
139
+ }
140
+ interface CustomPluginConfigVariable extends CustomPluginConfigOptionBase {
141
+ type: 'variable';
142
+ allowedTypes?: ControlType[];
143
+ }
144
+ interface CustomPluginConfigInteraction extends CustomPluginConfigOptionBase {
145
+ type: 'interaction';
146
+ }
147
+ interface CustomPluginConfigActionTrigger extends CustomPluginConfigOptionBase {
148
+ type: 'action-trigger';
149
+ }
150
+ interface CustomPluginConfigActionEffect extends CustomPluginConfigOptionBase {
151
+ type: 'action-effect';
152
+ }
153
+ interface CustomPluginConfigUrlParameter extends Omit<CustomPluginConfigOptionBase, 'label'> {
154
+ type: 'url-parameter';
155
+ }
156
+ /**
157
+ * Different types Plugin Config Options
158
+ * @typedef {object} CustomPluginConfigOptions
159
+ * @property {string} type Type of config option
160
+ * @property {string} name Name ID of config option
161
+ * @property {(string | undefined)} label Displayed label for config option
162
+ */
163
+ type CustomPluginConfigOptions = CustomPluginConfigGroup | CustomPluginConfigElement | CustomPluginConfigColumn | CustomPluginConfigText | CustomPluginConfigToggle | CustomPluginConfigCheckbox | CustomPluginConfigRadio | CustomPluginConfigDropdown | CustomPluginConfigColor | CustomPluginConfigVariable | CustomPluginConfigInteraction | CustomPluginConfigActionTrigger | CustomPluginConfigActionEffect | CustomPluginConfigUrlParameter;
164
+ /**
165
+ * @typedef {object} PluginInstance
166
+ * @template T Type of Config passed in
167
+ * @property {string} sigmaEnv Permissions within Sigma Environment
168
+ * @property {object} config Set of helper functions for interacting with Plugin Config
169
+ * @property {object} elements Set of helper functions for interacting with Workbook Element Data
170
+ * @property {Function} destroy Destroys Plugin Instance and removes all subscriptions
171
+ */
172
+ interface PluginInstance<T = any> {
173
+ sigmaEnv: 'author' | 'viewer' | 'explorer';
174
+ config: {
175
+ /**
176
+ * Getter for entire Plugin Config
177
+ * @template T Config type to be passed in
178
+ * @returns {Partial<T>} Current Plugin Config
179
+ */
180
+ get(): Partial<T> | undefined;
181
+ /**
182
+ * Performs a shallow merge between current config and passed in config
183
+ * @template T Config type to be passed in
184
+ * @param {Partial<T>} config Config to directly assign
185
+ */
186
+ set(config: Partial<T>): void;
187
+ /**
188
+ * Getter for key within plugin config
189
+ * @template K Possible key within CustomPluginConfigOptions
190
+ * @param {K} key Key within config to retrieve
191
+ * @returns Value within config for passed in key
192
+ */
193
+ getKey<K extends keyof T>(key: K): Pick<T, K>;
194
+ /**
195
+ * Assigns key value pair within plugin
196
+ * @template K Possible key within CustomPluginConfigOptions
197
+ * @template V Value corresponding to K
198
+ * @param {K} key Key within config to set
199
+ * @param {V} value New value to set key to
200
+ */
201
+ setKey<K extends keyof T>(key: K, value: Pick<T, K>): void;
202
+ /**
203
+ * Subscriber for Plugin Config
204
+ * @param {Function} listener Function to be called upon changes to Plugin Config
205
+ */
206
+ subscribe(listener: (arg0: T) => void): Unsubscriber;
207
+ /**
208
+ * Set possible options for plugin config
209
+ * @param {CustomPluginConfigOptions[]} options Possible config options
210
+ */
211
+ configureEditorPanel(options: CustomPluginConfigOptions[]): void;
212
+ /**
213
+ * Gets a static image of a workbook variable
214
+ * @param {string} configId ID from config of type: 'variable'
215
+ * @returns {WorkbookVariable} Current value of the workbook variable
216
+ */
217
+ getVariable(configId: string): WorkbookVariable;
218
+ /**
219
+ * Setter for workbook variable passed in
220
+ * @param {string} configId ID from config of type: 'variable'
221
+ * @param {unknown[]} values Values to assign to the workbook variable
222
+ */
223
+ setVariable(configId: string, ...values: unknown[]): void;
224
+ /**
225
+ * @deprecated Use Action API instead
226
+ * Getter for interaction selection state
227
+ * @param {string} configId ID from config of type: 'interaction'
228
+ */
229
+ getInteraction(configId: string): WorkbookSelection[];
230
+ /**
231
+ * @deprecated Use Action API instead
232
+ * Setter for interaction selection state
233
+ * @param {string} configId ID from config of type: 'interaction'
234
+ * @param {string} elementId Source element ID from element type in Plugin Config
235
+ * @param {Object} selection List of column IDs or Columns and values and key-value pairs to select
236
+ */
237
+ setInteraction(configId: string, elementId: string, selection: WorkbookSelection[]): void;
238
+ /**
239
+ * Triggers an action based on the provided action trigger ID
240
+ * @param {string} configId ID from config of type: 'action-trigger'
241
+ */
242
+ triggerAction(configId: string): void;
243
+ /**
244
+ * Registers an effect with the provided action effect ID
245
+ * @param {string} configId ID from config of type: 'action-effect'
246
+ * @param {Function} effect The effect function to register
247
+ * @returns {Unsubscriber} A callable unsubscriber
248
+ */
249
+ registerEffect(configId: string, effect: () => void): () => void;
250
+ /**
251
+ * Tell the workbook whether the plugin is still loading. Pass false when the plugin
252
+ * has finished loading and is ready to be used.
253
+ * @param {boolean} isLoading Boolean representing if Plugin Config is still loading
254
+ */
255
+ setLoadingState(isLoading: boolean): void;
256
+ /**
257
+ * Allows users to subscribe to changes in the passed in variable
258
+ * @param {string} configId ID from config of type: 'variable'
259
+ * @callback callback Function to be called upon receiving an updated workbook variable
260
+ * @returns {Unsubscriber} A callable unsubscriber
261
+ */
262
+ subscribeToWorkbookVariable(configId: string, callback: (input: WorkbookVariable) => void): Unsubscriber;
263
+ /**
264
+ * Allows users to subscribe to changes in the url parameter
265
+ * @param {string} configId ID from config of type: 'url-parameter'
266
+ * @callback callback Function to be called upon receiving an updated url parameter
267
+ * @returns {Unsubscriber} A callable unsubscriber
268
+ */
269
+ subscribeToUrlParameter(configId: string, callback: (input: UrlParameter) => void): Unsubscriber;
270
+ /**
271
+ * Gets the current value of a url parameter
272
+ * @param {string} configId ID from config of type: 'url-parameter'
273
+ * @returns {UrlParameter} Current value of the url parameter
274
+ */
275
+ getUrlParameter(configId: string): UrlParameter;
276
+ /**
277
+ * Setter for url parameter
278
+ * @param {string} configId ID from config of type: 'url-parameter'
279
+ * @param {string} value Value to assign to the url parameter
280
+ */
281
+ setUrlParameter(configId: string, value: string): void;
282
+ /**
283
+ * @deprecated Use Action API instead
284
+ * Allows users to subscribe to changes in the passed in interaction ID
285
+ * @param {string} configId ID from the config of type: 'interaction'
286
+ * @callback callback Function to be called upon receiving an updated interaction selection state
287
+ * @returns {Unsubscriber} A callable unsubscriber
288
+ */
289
+ subscribeToWorkbookInteraction(configId: string, callback: (input: WorkbookSelection[]) => void): Unsubscriber;
290
+ };
291
+ elements: {
292
+ /**
293
+ * Getter for Column Data by parent sheet ID
294
+ * @param {string} configId ID from config of type: 'element'
295
+ * @returns {WorkbookElementColumns} Column values contained within corresponding sheet
296
+ */
297
+ getElementColumns(configId: string): Promise<WorkbookElementColumns>;
298
+ /**
299
+ * Subscriber to changes in column data by ID
300
+ * @param {string} configId ID from config of type: 'element'
301
+ * @callback callback Callback function to be called upon changes to column data
302
+ * @returns {Unsubscriber} Callable unsubscriber to column data changes
303
+ */
304
+ subscribeToElementColumns(configId: string, callback: (cols: WorkbookElementColumns) => void): Unsubscriber;
305
+ /**
306
+ * Subscriber for the data within a given sheet
307
+ * @param {string} configId ID from config of type: 'element'
308
+ * @callback callback Function to call on data passed in
309
+ * @returns {Unsubscriber} A callable unsubscriber to changes in the data
310
+ */
311
+ subscribeToElementData(configId: string, callback: (data: WorkbookElementData) => void): Unsubscriber;
312
+ /**
313
+ * Ask sigma to load more data
314
+ * @param {string} configId ID from config of type: 'element'
315
+ */
316
+ fetchMoreElementData(configId: string): void;
317
+ };
318
+ style: {
319
+ /**
320
+ * Subscribe to style updates
321
+ * @param callback Function to call when style updates
322
+ * @returns Unsubscriber function
323
+ */
324
+ subscribe(callback: (style: PluginStyle) => void): () => void;
325
+ /**
326
+ * Request current style from workbook
327
+ * @returns Promise with current style
328
+ */
329
+ get(): Promise<PluginStyle>;
330
+ };
331
+ /**
332
+ * Destroys plugin instance and removes all subscribers
333
+ */
334
+ destroy(): void;
335
+ }
336
+ //#endregion
337
+ //#region src/react/hooks.d.ts
338
+ /**
339
+ * Gets the entire plugin instance
340
+ * @returns {PluginInstance} Context for the current plugin instance
341
+ */
342
+ declare function usePlugin(): PluginInstance<any>;
343
+ /**
344
+ * Provides a setter for the Plugin's Config Options
345
+ * @param {CustomPluginConfigOptions[]} nextOptions Updated possible Config Options
346
+ */
347
+ declare function useEditorPanelConfig(nextOptions: CustomPluginConfigOptions[]): void;
348
+ /**
349
+ * React hook for Plugin Config loading state
350
+ * @param {boolean} initialState Initial value to set loading state to
351
+ * @returns {[boolean, Function]} Boolean value corresponding to loading state for plugin config and setter for loading state
352
+ */
353
+ declare function useLoadingState(initialState: boolean): [boolean, (nextState: boolean) => void];
354
+ /**
355
+ * Provides the latest column values from corresponding config element
356
+ * @param {string} configId ID from the config for fetching element columns, with type: 'element'
357
+ * @returns {WorkbookElementColumns} Values of corresponding columns contained
358
+ * within the config element
359
+ */
360
+ declare function useElementColumns(configId: string): WorkbookElementColumns;
361
+ /**
362
+ * Provides the latest data values from config element (max 25_000)
363
+ * @param {string} configId ID from the config for fetching element data, with type: 'element'
364
+ * @returns {WorkbookElementData} Element Data for config element, if any
365
+ */
366
+ declare function useElementData(configId: string): WorkbookElementData;
367
+ /**
368
+ * Provides the latest data values from corresponding config element with a callback to
369
+ * fetch more in chunks of 25_000 data points
370
+ * @param {string} configId ID from the config for fetching paginated
371
+ * element data, with type: 'element'
372
+ * @returns {WorkbookElementData} Element Data for configured config element, if any
373
+ */
374
+ declare function usePaginatedElementData(configId: string): [WorkbookElementData, () => void];
375
+ /**
376
+ * Provides the latest value for entire config or certain key within the config
377
+ * @param {string} key Key within Plugin Config, optional
378
+ * @returns Entire config if no key passed in or value for key within plugin config
379
+ */
380
+ declare function useConfig(key?: string): any;
381
+ /**
382
+ * React hook for accessing a workbook control variable
383
+ * @param {string} id ID from the config of type: 'variable'
384
+ * @returns {[(WorkbookVariable | undefined), Function]} Constantly updating
385
+ * value of the control variable and setter for the variable
386
+ */
387
+ declare function useVariable(id: string): [WorkbookVariable | undefined, Function];
388
+ /**
389
+ * React hook for accessing a url parameter
390
+ * @param {string} id ID from the config of type: 'url-parameter'
391
+ * @returns {[(UrlParameter | undefined), Function]} Constantly updating value of the url parameter and setter for the url parameter
392
+ */
393
+ declare function useUrlParameter(id: string): [UrlParameter | undefined, (value: string) => void];
394
+ /**
395
+ * @deprecated Use Action API instead
396
+ * React hook for accessing a workbook interaction selections state
397
+ * @param {string} id ID from the config of type: 'interaction'
398
+ * @returns {[(WorkbookSelection | undefined), Function]} Constantly updating selection state and setter thereof
399
+ */
400
+ declare function useInteraction(id: string, elementId: string): [unknown, Function];
401
+ /**
402
+ * React hook for returning a triggering callback function for the registered
403
+ * action trigger
404
+ * @param {string} configId ID from the config of type: 'action-trigger'
405
+ * @returns {Function} A callback function to trigger the action
406
+ */
407
+ declare function useActionTrigger(configId: string): () => void;
408
+ /**
409
+ * React hook for registering and unregistering an action effect
410
+ * @param {string} configId ID from the config of type: 'action-effect'
411
+ * @param {Function} effect The function to be called when the action is triggered
412
+ */
413
+ declare function useActionEffect(configId: string, effect: () => void): void;
414
+ /**
415
+ * React hook for accessing plugin style with live updates
416
+ * @returns {PluginStyle | undefined} Style properties from the workbook if available
417
+ */
418
+ declare function usePluginStyle(): PluginStyle | undefined;
419
+ //#endregion
420
+ //#region src/react/Provider.d.ts
421
+ interface SigmaClientProviderProps<T = any> {
422
+ client: PluginInstance<T>;
423
+ children?: React.ReactNode;
424
+ }
425
+ declare function SigmaClientProvider<T = any>(props: SigmaClientProviderProps<T>): React.JSX.Element;
426
+ //#endregion
427
+ //#region src/client.d.ts
428
+ declare const client: PluginInstance<{}>;
429
+ //#endregion
430
+ //#region src/utils/polyfillRequestAnimationFrame.d.ts
431
+ /**
432
+ * requestAnimationFrame() calls are paused in most browsers when running in background tabs or hidden <iframe>s in order to improve performance and battery life
433
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
434
+ */
435
+ declare function polyfillRequestAnimationFrame(window: Window): void;
436
+ //#endregion
437
+ export { ControlType, CustomPluginConfigActionEffect, CustomPluginConfigActionTrigger, CustomPluginConfigCheckbox, CustomPluginConfigColor, CustomPluginConfigColumn, CustomPluginConfigDropdown, CustomPluginConfigElement, CustomPluginConfigGroup, CustomPluginConfigInteraction, CustomPluginConfigOptionBase, CustomPluginConfigOptions, CustomPluginConfigRadio, CustomPluginConfigText, CustomPluginConfigToggle, CustomPluginConfigUrlParameter, CustomPluginConfigVariable, PluginConfig, PluginInstance, PluginMessageResponse, PluginStyle, PrimitiveType, ScalarType, SigmaClientProvider, type SigmaClientProviderProps, Unsubscriber, UrlParameter, ValueType, WbElement, WorkbookElementColumn, WorkbookElementColumns, WorkbookElementData, WorkbookSelection, WorkbookVariable, client, polyfillRequestAnimationFrame, useActionEffect, useActionTrigger, useConfig, useEditorPanelConfig, useElementColumns, useElementData, useInteraction, useLoadingState, usePaginatedElementData, usePlugin, usePluginStyle, useUrlParameter, useVariable };
438
+ //# sourceMappingURL=index.d.cts.map