@osdk/widget.client-react 3.36.0 → 3.36.1-main-010b12661f90af7da692db4ee09ea6b0dcdce3c6

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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # @osdk/widget.client-react
2
2
 
3
+ ## 3.36.1-main-010b12661f90af7da692db4ee09ea6b0dcdce3c6
4
+
5
+ ### Patch Changes
6
+
7
+ - 010b126: Migrate @osdk/widget.client-react to lint with oxlint and format with oxfmt (configured via Ultracite) instead of ESLint and dprint (third increment of the repo-wide oxc migration; first React package, validating the Ultracite React preset)
8
+ - Updated dependencies [3e915ee]
9
+ - @osdk/client@2.39.1-main-010b12661f90af7da692db4ee09ea6b0dcdce3c6
10
+ - @osdk/widget.client@3.36.1-main-010b12661f90af7da692db4ee09ea6b0dcdce3c6
11
+
3
12
  ## 3.36.0
4
13
 
5
14
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"ErrorBoundary.js","names":["React","ErrorBoundary","Component","state","error","getDerivedStateFromError","render","errorDetails","Error","stack","createElement","style","padding","margin","color","process","env","NODE_ENV","Fragment","backgroundColor","overflow","fontSize","props","children"],"sources":["ErrorBoundary.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as React from \"react\";\n\ninterface State {\n error: unknown;\n}\n\n/**\n * Error boundary to catch and display errors in widget code.\n */\nexport class ErrorBoundary extends React.Component<\n React.PropsWithChildren,\n State\n> {\n state: State = { error: null };\n\n static getDerivedStateFromError(error: unknown): Partial<State> {\n return { error };\n }\n\n render(): React.ReactNode {\n if (this.state.error) {\n const errorDetails = this.state.error instanceof Error\n ? this.state.error.stack\n : \"See browser console for more details.\";\n\n return (\n <section style={{ padding: \"16px\" }}>\n <h3 style={{ margin: \"0 0 12px 0\", color: \"#c00\" }}>\n An uncaught error occurred\n </h3>\n {process.env.NODE_ENV !== \"production\" && (\n <>\n <p style={{ margin: \"0 0 8px 0\" }}>\n This error was caught by the widget framework's fallback error\n boundary.\n </p>\n <ul style={{ margin: \"0 0 16px 0\" }}>\n <li>\n Ensure errors are properly handled in your code with try-catch\n blocks and promise rejection handling.\n </li>\n <li>\n Add your own error boundary to replace this fallback with a\n custom error message or recovery options for your users.\n </li>\n <li>\n See:{\" \"}\n <code>\n https://react.dev/reference/react/Component#catching-rendering-errors-with-an-error-boundary\n </code>\n </li>\n </ul>\n </>\n )}\n <pre\n style={{\n backgroundColor: \"#f5f5f5\",\n padding: \"12px\",\n overflow: \"auto\",\n fontSize: \"12px\",\n margin: 0,\n }}\n >\n {errorDetails}\n </pre>\n </section>\n );\n }\n\n return this.props.children;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAM9B;AACA;AACA;AACA,OAAO,MAAMC,aAAa,SAASD,KAAK,CAACE,SAAS,CAGhD;EACAC,KAAK,GAAU;IAAEC,KAAK,EAAE;EAAK,CAAC;EAE9B,OAAOC,wBAAwBA,CAACD,KAAc,EAAkB;IAC9D,OAAO;MAAEA;IAAM,CAAC;EAClB;EAEAE,MAAMA,CAAA,EAAoB;IACxB,IAAI,IAAI,CAACH,KAAK,CAACC,KAAK,EAAE;MACpB,MAAMG,YAAY,GAAG,IAAI,CAACJ,KAAK,CAACC,KAAK,YAAYI,KAAK,GAClD,IAAI,CAACL,KAAK,CAACC,KAAK,CAACK,KAAK,GACtB,uCAAuC;MAE3C,oBACET,KAAA,CAAAU,aAAA;QAASC,KAAK,EAAE;UAAEC,OAAO,EAAE;QAAO;MAAE,gBAClCZ,KAAA,CAAAU,aAAA;QAAIC,KAAK,EAAE;UAAEE,MAAM,EAAE,YAAY;UAAEC,KAAK,EAAE;QAAO;MAAE,GAAC,4BAEhD,CAAC,EACJC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,iBACpCjB,KAAA,CAAAU,aAAA,CAAAV,KAAA,CAAAkB,QAAA,qBACElB,KAAA,CAAAU,aAAA;QAAGC,KAAK,EAAE;UAAEE,MAAM,EAAE;QAAY;MAAE,GAAC,0EAGhC,CAAC,eACJb,KAAA,CAAAU,aAAA;QAAIC,KAAK,EAAE;UAAEE,MAAM,EAAE;QAAa;MAAE,gBAClCb,KAAA,CAAAU,aAAA,aAAI,uGAGA,CAAC,eACLV,KAAA,CAAAU,aAAA,aAAI,sHAGA,CAAC,eACLV,KAAA,CAAAU,aAAA,aAAI,MACE,EAAC,GAAG,eACRV,KAAA,CAAAU,aAAA,eAAM,8FAEA,CACJ,CACF,CACJ,CACH,eACDV,KAAA,CAAAU,aAAA;QACEC,KAAK,EAAE;UACLQ,eAAe,EAAE,SAAS;UAC1BP,OAAO,EAAE,MAAM;UACfQ,QAAQ,EAAE,MAAM;UAChBC,QAAQ,EAAE,MAAM;UAChBR,MAAM,EAAE;QACV;MAAE,GAEDN,YACE,CACE,CAAC;IAEd;IAEA,OAAO,IAAI,CAACe,KAAK,CAACC,QAAQ;EAC5B;AACF","ignoreList":[]}
1
+ {"version":3,"file":"ErrorBoundary.js","names":["React","ErrorBoundary","Component","state","error","getDerivedStateFromError","render","errorDetails","Error","stack","createElement","style","padding","margin","color","process","env","NODE_ENV","Fragment","backgroundColor","overflow","fontSize","props","children"],"sources":["ErrorBoundary.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as React from \"react\";\n\ninterface State {\n error: unknown;\n}\n\n/**\n * Error boundary to catch and display errors in widget code.\n */\nexport class ErrorBoundary extends React.Component<\n React.PropsWithChildren,\n State\n> {\n state: State = { error: null };\n\n static getDerivedStateFromError(error: unknown): Partial<State> {\n return { error };\n }\n\n render(): React.ReactNode {\n if (this.state.error) {\n const errorDetails =\n this.state.error instanceof Error\n ? this.state.error.stack\n : \"See browser console for more details.\";\n\n return (\n <section style={{ padding: \"16px\" }}>\n <h3 style={{ margin: \"0 0 12px 0\", color: \"#c00\" }}>\n An uncaught error occurred\n </h3>\n {process.env.NODE_ENV !== \"production\" && (\n <>\n <p style={{ margin: \"0 0 8px 0\" }}>\n This error was caught by the widget framework's fallback error\n boundary.\n </p>\n <ul style={{ margin: \"0 0 16px 0\" }}>\n <li>\n Ensure errors are properly handled in your code with try-catch\n blocks and promise rejection handling.\n </li>\n <li>\n Add your own error boundary to replace this fallback with a\n custom error message or recovery options for your users.\n </li>\n <li>\n See:{\" \"}\n <code>\n https://react.dev/reference/react/Component#catching-rendering-errors-with-an-error-boundary\n </code>\n </li>\n </ul>\n </>\n )}\n <pre\n style={{\n backgroundColor: \"#f5f5f5\",\n padding: \"12px\",\n overflow: \"auto\",\n fontSize: \"12px\",\n margin: 0,\n }}\n >\n {errorDetails}\n </pre>\n </section>\n );\n }\n\n return this.props.children;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAM9B;AACA;AACA;AACA,OAAO,M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AAE;QACV;MAAE,GAEDN,YACE,CACE,CAAC;IAEd;IAEA,OAAO,IAAI,CAACe,KAAK,CAACC,QAAQ;EAC5B;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","names":["createFoundryWidgetClient","React","useCallback","useEffect","useMemo","useRef","FoundryWidgetContext","ErrorBoundary","extendParametersWithObjectSets","initializeParameters","transformEmitEventPayload","FoundryWidget","children","config","initialValues","client","osdkClient","asyncParameterValues","setAsyncParameterValues","useState","allParameterValues","setAllParameterValues","type","objectSetCache","Map","emitEventCallIds","emitEvent","eventId","payload","transformResult","eventKey","String","thisCallId","current","get","set","transformedPayload","subscribe","hostEventTarget","addEventListener","processedParameters","detail","parameters","currentParameters","aggregatedLoadedState","firstError","newParameterValues","key","value","error","currentParameterValue","updatedValue","Error","ready","resizeObserver","ResizeObserver","entries","length","console","entry","borderBoxSize","inlineSize","width","blockSize","height","resize","observe","document","body","box","handleFullReload","reload","import","meta","hot","on","unsubscribe","disconnect","off","createElement","Provider","values","state"],"sources":["client.tsx"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Client, ObjectSet } from \"@osdk/client\";\nimport type { AllowedObjectSetParameterType } from \"@osdk/widget.api\";\nimport {\n type AsyncValue,\n createFoundryWidgetClient,\n type FoundryWidgetClient,\n type ParameterConfig,\n type WidgetConfig,\n} from \"@osdk/widget.client\";\nimport React, { useCallback, useEffect, useMemo, useRef } from \"react\";\nimport type {\n AugmentedEmitEvent,\n ExtendedAsyncParameterValueMap,\n ExtendedParameterValueMap,\n FoundryWidgetClientContext,\n} from \"./context.js\";\nimport { FoundryWidgetContext } from \"./context.js\";\nimport { ErrorBoundary } from \"./ErrorBoundary.js\";\nimport { extendParametersWithObjectSets } from \"./utils/extendParametersWithObjectSets.js\";\nimport { initializeParameters } from \"./utils/initializeParameters.js\";\nimport { transformEmitEventPayload } from \"./utils/transformEmitEventPayload.js\";\n\ntype ExtractObjectTypes<C extends WidgetConfig<C[\"parameters\"]>> =\n C[\"parameters\"][keyof C[\"parameters\"]] extends infer Param\n ? Param extends { type: \"objectSet\"; allowedType: infer AT }\n ? AT extends AllowedObjectSetParameterType ? AT\n : never\n : never\n : never;\n\ntype HasObjectSetParameters<C extends WidgetConfig<C[\"parameters\"]>> =\n ExtractObjectTypes<C> extends never ? false : true;\n\ntype ObjectSetProps<C extends WidgetConfig<C[\"parameters\"]>> = {\n /**\n * Used to hydrate object sets from their RIDs for object set parameters\n */\n client: Client;\n};\n\ntype FoundryWidgetProps<C extends WidgetConfig<C[\"parameters\"]>> =\n & {\n children: React.ReactNode;\n\n /**\n * Parameter configuration for the widget\n */\n config: C;\n\n /**\n * Customize what the initial value of each parameter should be\n *\n * @default Sets all parameters to the \"not-started\" loading state\n */\n initialValues?: ExtendedAsyncParameterValueMap<C>;\n }\n & Partial<ObjectSetProps<C>>\n & (HasObjectSetParameters<C> extends true ? ObjectSetProps<C> : {});\n\n/**\n * Handles subscribing to messages from the host Foundry UI and updating the widget's parameter values accordingly via React context\n */\nexport const FoundryWidget = <C extends WidgetConfig<C[\"parameters\"]>>({\n children,\n config,\n initialValues,\n client: osdkClient,\n}: FoundryWidgetProps<C>): React.ReactElement<FoundryWidgetProps<C>> => {\n const client = useMemo(() => createFoundryWidgetClient<C>(), []);\n const [asyncParameterValues, setAsyncParameterValues] = React.useState<\n ExtendedAsyncParameterValueMap<C>\n >(initialValues ?? initializeParameters(config, \"not-started\"));\n const [allParameterValues, setAllParameterValues] = React.useState<\n AsyncValue<ExtendedParameterValueMap<C>>\n >({\n type: \"not-started\",\n });\n\n const objectSetCache = useRef<\n Map<string, { objectSetRid: string; objectSet: ObjectSet }>\n >(new Map());\n\n const emitEventCallIds = useRef<Map<string, number>>(new Map());\n\n const emitEvent: AugmentedEmitEvent<C> = useCallback(\n (eventId: Parameters<FoundryWidgetClient<C>[\"emitEvent\"]>[0], payload) => {\n const transformResult = transformEmitEventPayload(\n config,\n eventId,\n payload,\n osdkClient,\n );\n if (transformResult.type === \"passThrough\") {\n client.emitEvent(\n eventId,\n transformResult.payload as Parameters<\n FoundryWidgetClient<C>[\"emitEvent\"]\n >[1],\n );\n return;\n }\n\n async function handleAsyncEmitEvent() {\n const eventKey = String(eventId);\n const thisCallId = (emitEventCallIds.current.get(eventKey) ?? 0) + 1;\n emitEventCallIds.current.set(eventKey, thisCallId);\n\n const transformedPayload = await transformResult.payload;\n\n if (thisCallId !== emitEventCallIds.current.get(eventKey)) {\n return;\n }\n\n client.emitEvent(\n eventId,\n transformedPayload as Parameters<\n FoundryWidgetClient<C>[\"emitEvent\"]\n >[1],\n );\n }\n\n void handleAsyncEmitEvent();\n },\n [osdkClient, config, client],\n );\n\n useEffect(() => {\n client.subscribe();\n client.hostEventTarget.addEventListener(\n \"host.update-parameters\",\n (payload) => {\n const processedParameters = extendParametersWithObjectSets(\n osdkClient,\n config,\n payload.detail.parameters,\n objectSetCache.current,\n );\n setAsyncParameterValues((currentParameters) => ({\n ...currentParameters,\n ...processedParameters,\n }));\n setAllParameterValues((currentParameters) => {\n let aggregatedLoadedState: AsyncValue<any>[\"type\"] = \"loaded\";\n let firstError: Error | undefined;\n const newParameterValues: ExtendedParameterValueMap<\n WidgetConfig<ParameterConfig>\n > = {};\n for (const key in processedParameters) {\n const value = processedParameters[key].value;\n // If any fails, consider the whole thing failed\n if (value.type === \"failed\") {\n aggregatedLoadedState = \"failed\";\n firstError = firstError ?? value.error;\n newParameterValues[key as any] = value.value as any;\n continue;\n }\n // If any is loading, consider all of it loading unless we have failed somewhere\n if (\n value.type === \"loading\"\n && aggregatedLoadedState !== \"failed\"\n ) {\n aggregatedLoadedState = \"loading\";\n continue;\n }\n // If any is reloading, consider it loading unless something is failed or loading for the first time\n if (\n value.type === \"reloading\"\n && aggregatedLoadedState !== \"failed\"\n && aggregatedLoadedState !== \"loading\"\n ) {\n aggregatedLoadedState = \"reloading\";\n newParameterValues[key as any] = value.value as any;\n continue;\n }\n if (\n value.type === \"not-started\"\n && aggregatedLoadedState !== \"failed\"\n && aggregatedLoadedState !== \"loading\"\n && aggregatedLoadedState !== \"reloading\"\n ) {\n aggregatedLoadedState = \"not-started\";\n }\n\n if (value.type === \"loaded\") {\n newParameterValues[key as any] = value.value as any;\n }\n }\n const currentParameterValue = currentParameters.type !== \"not-started\"\n && currentParameters.type !== \"loading\"\n ? currentParameters.value\n : {};\n if (\n aggregatedLoadedState !== \"not-started\"\n && aggregatedLoadedState !== \"loading\"\n ) {\n const updatedValue = {\n ...currentParameterValue,\n ...newParameterValues,\n } as ExtendedParameterValueMap<C>;\n return aggregatedLoadedState === \"failed\"\n ? {\n type: aggregatedLoadedState,\n value: updatedValue,\n error: firstError ?? new Error(\"Failed to load parameters\"),\n }\n : {\n type: aggregatedLoadedState,\n value: updatedValue,\n };\n } else {\n return { type: aggregatedLoadedState };\n }\n });\n },\n );\n client.ready();\n\n const resizeObserver = new ResizeObserver((entries) => {\n if (entries.length !== 1) {\n // eslint-disable-next-line no-console\n console.error(\n \"Expected exactly one resize observer entry but received:\",\n entries,\n );\n return;\n }\n const entry = entries[0];\n if (entry.borderBoxSize.length !== 1) {\n // eslint-disable-next-line no-console\n console.error(\n \"Expected exactly one border box size but received:\",\n entry.borderBoxSize,\n );\n return;\n }\n const { inlineSize: width, blockSize: height } = entry.borderBoxSize[0];\n client.resize({ width, height });\n });\n resizeObserver.observe(document.body, { box: \"border-box\" });\n\n const handleFullReload = () => client.reload();\n if (import.meta.hot?.on) {\n import.meta.hot.on(\"vite:beforeFullReload\", handleFullReload);\n }\n\n return () => {\n client.unsubscribe();\n resizeObserver.disconnect();\n if (import.meta.hot?.off) {\n import.meta.hot.off(\"vite:beforeFullReload\", handleFullReload);\n }\n };\n }, []);\n\n return (\n <FoundryWidgetContext.Provider\n value={{\n emitEvent,\n hostEventTarget: client.hostEventTarget,\n asyncParameterValues,\n parameters: {\n values: allParameterValues.value ?? {},\n state: allParameterValues.type,\n },\n // Unfortunately the context is statically defined so we can't use the generic type, hence the cast\n } as FoundryWidgetClientContext<WidgetConfig<ParameterConfig>>}\n >\n <ErrorBoundary>\n {children}\n </ErrorBoundary>\n </FoundryWidgetContext.Provider>\n );\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAEEA,yBAAyB,QAIpB,qBAAqB;AAC5B,OAAOC,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAOtE,SAASC,oBAAoB,QAAQ,cAAc;AACnD,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SAASC,8BAA8B,QAAQ,2CAA2C;AAC1F,SAASC,oBAAoB,QAAQ,iCAAiC;AACtE,SAASC,yBAAyB,QAAQ,sCAAsC;AAuChF;AACA;AACA;AACA,OAAO,MAAMC,aAAa,GAAGA,CAA0C;EACrEC,QAAQ;EACRC,MAAM;EACNC,aAAa;EACbC,MAAM,EAAEC;AACa,CAAC,KAAgD;EACtE,MAAMD,MAAM,GAAGX,OAAO,CAAC,MAAMJ,yBAAyB,CAAI,CAAC,EAAE,EAAE,CAAC;EAChE,MAAM,CAACiB,oBAAoB,EAAEC,uBAAuB,CAAC,GAAGjB,KAAK,CAACkB,QAAQ,CAEpEL,aAAa,IAAIL,oBAAoB,CAACI,MAAM,EAAE,aAAa,CAAC,CAAC;EAC/D,MAAM,CAACO,kBAAkB,EAAEC,qBAAqB,CAAC,GAAGpB,KAAK,CAACkB,QAAQ,CAEhE;IACAG,IAAI,EAAE;E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;IAClC,CAAC,CAAC;IACFV,cAAc,CAACY,OAAO,CAACC,QAAQ,CAACC,IAAI,EAAE;MAAEC,GAAG,EAAE;IAAa,CAAC,CAAC;IAE5D,MAAMC,gBAAgB,GAAGA,CAAA,KAAMvD,MAAM,CAACwD,MAAM,CAAC,CAAC;IAC9C,IAAIC,MAAM,CAACC,IAAI,CAACC,GAAG,EAAEC,EAAE,EAAE;MACvBH,MAAM,CAACC,IAAI,CAACC,GAAG,CAACC,EAAE,CAAC,uBAAuB,EAAEL,gBAAgB,CAAC;IAC/D;IAEA,OAAO,MAAM;MACXvD,MAAM,CAAC6D,WAAW,CAAC,CAAC;MACpBtB,cAAc,CAACuB,UAAU,CAAC,CAAC;MAC3B,IAAIL,MAAM,CAACC,IAAI,CAACC,GAAG,EAAEI,GAAG,EAAE;QACxBN,MAAM,CAACC,IAAI,CAACC,GAAG,CAACI,GAAG,CAAC,uBAAuB,EAAER,gBAAgB,CAAC;MAChE;IACF,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,oBACErE,KAAA,CAAA8E,aAAA,CAACzE,oBAAoB,CAAC0E,QAAQ;IAC5BhC,KAAK,EAAE;MACLtB,SAAS;MACTY,eAAe,EAAEvB,MAAM,CAACuB,eAAe;MACvCrB,oBAAoB;MACpByB,UAAU,EAAE;QACVuC,MAAM,EAAE7D,kBAAkB,CAAC4B,KAAK,IAAI,CAAC,CAAC;QACtCkC,KAAK,EAAE9D,kBAAkB,CAACE;MAC5B;MACA;IACF;EAA+D,gBAE/DrB,KAAA,CAAA8E,aAAA,CAACxE,aAAa,QACXK,QACY,CACc,CAAC;AAEpC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"client.js","names":["createFoundryWidgetClient","React","useCallback","useEffect","useMemo","useRef","FoundryWidgetContext","ErrorBoundary","extendParametersWithObjectSets","initializeParameters","transformEmitEventPayload","FoundryWidget","children","config","initialValues","client","osdkClient","asyncParameterValues","setAsyncParameterValues","useState","allParameterValues","setAllParameterValues","type","objectSetCache","Map","emitEventCallIds","emitEvent","eventId","payload","transformResult","eventKey","String","thisCallId","current","get","set","transformedPayload","subscribe","hostEventTarget","addEventListener","processedParameters","detail","parameters","currentParameters","aggregatedLoadedState","firstError","newParameterValues","key","value","error","currentParameterValue","updatedValue","Error","ready","resizeObserver","ResizeObserver","entries","length","console","entry","borderBoxSize","inlineSize","width","blockSize","height","resize","observe","document","body","box","handleFullReload","reload","import","meta","hot","on","unsubscribe","disconnect","off","createElement","Provider","values","state"],"sources":["client.tsx"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Client, ObjectSet } from \"@osdk/client\";\nimport type { AllowedObjectSetParameterType } from \"@osdk/widget.api\";\nimport {\n type AsyncValue,\n createFoundryWidgetClient,\n type FoundryWidgetClient,\n type ParameterConfig,\n type WidgetConfig,\n} from \"@osdk/widget.client\";\nimport React, { useCallback, useEffect, useMemo, useRef } from \"react\";\n\nimport type {\n AugmentedEmitEvent,\n ExtendedAsyncParameterValueMap,\n ExtendedParameterValueMap,\n FoundryWidgetClientContext,\n} from \"./context.js\";\nimport { FoundryWidgetContext } from \"./context.js\";\nimport { ErrorBoundary } from \"./ErrorBoundary.js\";\nimport { extendParametersWithObjectSets } from \"./utils/extendParametersWithObjectSets.js\";\nimport { initializeParameters } from \"./utils/initializeParameters.js\";\nimport { transformEmitEventPayload } from \"./utils/transformEmitEventPayload.js\";\n\ntype ExtractObjectTypes<C extends WidgetConfig<C[\"parameters\"]>> =\n C[\"parameters\"][keyof C[\"parameters\"]] extends infer Param\n ? Param extends { type: \"objectSet\"; allowedType: infer AT }\n ? AT extends AllowedObjectSetParameterType\n ? AT\n : never\n : never\n : never;\n\ntype HasObjectSetParameters<C extends WidgetConfig<C[\"parameters\"]>> =\n ExtractObjectTypes<C> extends never ? false : true;\n\ntype ObjectSetProps<_C extends WidgetConfig<_C[\"parameters\"]>> = {\n /**\n * Used to hydrate object sets from their RIDs for object set parameters\n */\n client: Client;\n};\n\ntype FoundryWidgetProps<C extends WidgetConfig<C[\"parameters\"]>> = {\n children: React.ReactNode;\n\n /**\n * Parameter configuration for the widget\n */\n config: C;\n\n /**\n * Customize what the initial value of each parameter should be\n *\n * @default Sets all parameters to the \"not-started\" loading state\n */\n initialValues?: ExtendedAsyncParameterValueMap<C>;\n} & Partial<ObjectSetProps<C>> &\n (HasObjectSetParameters<C> extends true ? ObjectSetProps<C> : {});\n\n/**\n * Handles subscribing to messages from the host Foundry UI and updating the widget's parameter values accordingly via React context\n */\nexport const FoundryWidget = <C extends WidgetConfig<C[\"parameters\"]>>({\n children,\n config,\n initialValues,\n client: osdkClient,\n}: FoundryWidgetProps<C>): React.ReactElement<FoundryWidgetProps<C>> => {\n const client = useMemo(() => createFoundryWidgetClient<C>(), []);\n const [asyncParameterValues, setAsyncParameterValues] = React.useState<\n ExtendedAsyncParameterValueMap<C>\n >(initialValues ?? initializeParameters(config, \"not-started\"));\n const [allParameterValues, setAllParameterValues] = React.useState<\n AsyncValue<ExtendedParameterValueMap<C>>\n >({\n type: \"not-started\",\n });\n\n const objectSetCache = useRef<\n Map<string, { objectSetRid: string; objectSet: ObjectSet }>\n >(new Map());\n\n const emitEventCallIds = useRef<Map<string, number>>(new Map());\n\n const emitEvent: AugmentedEmitEvent<C> = useCallback(\n (eventId: Parameters<FoundryWidgetClient<C>[\"emitEvent\"]>[0], payload) => {\n const transformResult = transformEmitEventPayload(\n config,\n eventId,\n payload,\n osdkClient\n );\n if (transformResult.type === \"passThrough\") {\n client.emitEvent(\n eventId,\n transformResult.payload as Parameters<\n FoundryWidgetClient<C>[\"emitEvent\"]\n >[1]\n );\n return;\n }\n\n async function handleAsyncEmitEvent() {\n const eventKey = String(eventId);\n const thisCallId = (emitEventCallIds.current.get(eventKey) ?? 0) + 1;\n emitEventCallIds.current.set(eventKey, thisCallId);\n\n const transformedPayload = await transformResult.payload;\n\n if (thisCallId !== emitEventCallIds.current.get(eventKey)) {\n return;\n }\n\n client.emitEvent(\n eventId,\n transformedPayload as Parameters<\n FoundryWidgetClient<C>[\"emitEvent\"]\n >[1]\n );\n }\n\n void handleAsyncEmitEvent();\n },\n [osdkClient, config, client]\n );\n\n useEffect(() => {\n client.subscribe();\n client.hostEventTarget.addEventListener(\n \"host.update-parameters\",\n (payload) => {\n const processedParameters = extendParametersWithObjectSets(\n osdkClient,\n config,\n payload.detail.parameters,\n objectSetCache.current\n );\n setAsyncParameterValues((currentParameters) => ({\n ...currentParameters,\n ...processedParameters,\n }));\n setAllParameterValues((currentParameters) => {\n let aggregatedLoadedState: AsyncValue<any>[\"type\"] = \"loaded\";\n let firstError: Error | undefined;\n const newParameterValues: ExtendedParameterValueMap<\n WidgetConfig<ParameterConfig>\n > = {};\n for (const key in processedParameters) {\n const value = processedParameters[key].value;\n // If any fails, consider the whole thing failed\n if (value.type === \"failed\") {\n aggregatedLoadedState = \"failed\";\n firstError = firstError ?? value.error;\n newParameterValues[key as any] = value.value as any;\n continue;\n }\n // If any is loading, consider all of it loading unless we have failed somewhere\n if (\n value.type === \"loading\" &&\n aggregatedLoadedState !== \"failed\"\n ) {\n aggregatedLoadedState = \"loading\";\n continue;\n }\n // If any is reloading, consider it loading unless something is failed or loading for the first time\n if (\n value.type === \"reloading\" &&\n aggregatedLoadedState !== \"failed\" &&\n aggregatedLoadedState !== \"loading\"\n ) {\n aggregatedLoadedState = \"reloading\";\n newParameterValues[key as any] = value.value as any;\n continue;\n }\n if (\n value.type === \"not-started\" &&\n aggregatedLoadedState !== \"failed\" &&\n aggregatedLoadedState !== \"loading\" &&\n aggregatedLoadedState !== \"reloading\"\n ) {\n aggregatedLoadedState = \"not-started\";\n }\n\n if (value.type === \"loaded\") {\n newParameterValues[key as any] = value.value as any;\n }\n }\n const currentParameterValue =\n currentParameters.type !== \"not-started\" &&\n currentParameters.type !== \"loading\"\n ? currentParameters.value\n : {};\n if (\n aggregatedLoadedState !== \"not-started\" &&\n aggregatedLoadedState !== \"loading\"\n ) {\n const updatedValue = {\n ...currentParameterValue,\n ...newParameterValues,\n } as ExtendedParameterValueMap<C>;\n return aggregatedLoadedState === \"failed\"\n ? {\n type: aggregatedLoadedState,\n value: updatedValue,\n error: firstError ?? new Error(\"Failed to load parameters\"),\n }\n : {\n type: aggregatedLoadedState,\n value: updatedValue,\n };\n } else {\n return { type: aggregatedLoadedState };\n }\n });\n }\n );\n client.ready();\n\n const resizeObserver = new ResizeObserver((entries) => {\n if (entries.length !== 1) {\n // eslint-disable-next-line no-console\n console.error(\n \"Expected exactly one resize observer entry but received:\",\n entries\n );\n return;\n }\n const entry = entries[0];\n if (entry.borderBoxSize.length !== 1) {\n // eslint-disable-next-line no-console\n console.error(\n \"Expected exactly one border box size but received:\",\n entry.borderBoxSize\n );\n return;\n }\n const { inlineSize: width, blockSize: height } = entry.borderBoxSize[0];\n client.resize({ width, height });\n });\n resizeObserver.observe(document.body, { box: \"border-box\" });\n\n const handleFullReload = () => client.reload();\n if (import.meta.hot?.on) {\n import.meta.hot.on(\"vite:beforeFullReload\", handleFullReload);\n }\n\n return () => {\n client.unsubscribe();\n resizeObserver.disconnect();\n if (import.meta.hot?.off) {\n import.meta.hot.off(\"vite:beforeFullReload\", handleFullReload);\n }\n };\n }, []);\n\n return (\n <FoundryWidgetContext.Provider\n value={\n {\n emitEvent,\n hostEventTarget: client.hostEventTarget,\n asyncParameterValues,\n parameters: {\n values: allParameterValues.value ?? {},\n state: allParameterValues.type,\n },\n // Unfortunately the context is statically defined so we can't use the generic type, hence the cast\n } as FoundryWidgetClientContext<WidgetConfig<ParameterConfig>>\n }\n >\n <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,gBAAgB,CAAC;IAC/D;IAEA,OAAO,MAAM;MACXvD,MAAM,CAAC6D,WAAW,CAAC,CAAC;MACpBtB,cAAc,CAACuB,UAAU,CAAC,CAAC;MAC3B,IAAIL,MAAM,CAACC,IAAI,CAACC,GAAG,EAAEI,GAAG,EAAE;QACxBN,MAAM,CAACC,IAAI,CAACC,GAAG,CAACI,GAAG,CAAC,uBAAuB,EAAER,gBAAgB,CAAC;MAChE;IACF,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,oBACErE,KAAA,CAAA8E,aAAA,CAACzE,oBAAoB,CAAC0E,QAAQ;IAC5BhC,KAAK,EACH;MACEtB,SAAS;MACTY,eAAe,EAAEvB,MAAM,CAACuB,eAAe;MACvCrB,oBAAoB;MACpByB,UAAU,EAAE;QACVuC,MAAM,EAAE7D,kBAAkB,CAAC4B,KAAK,IAAI,CAAC,CAAC;QACtCkC,KAAK,EAAE9D,kBAAkB,CAACE;MAC5B;MACA;IACF;EACD,gBAEDrB,KAAA,CAAA8E,aAAA,CAACxE,aAAa,QAAEK,QAAwB,CACX,CAAC;AAEpC,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","names":["FoundryHostEventTarget","React","useContext","FoundryWidgetContext","createContext","emitEvent","hostEventTarget","asyncParameterValues","parameters","state","values","useFoundryWidgetContext","_useFoundryWidgetContext","withTypes"],"sources":["context.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software=\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ObjectSet } from \"@osdk/client\";\nimport type {\n AllowedObjectSetParameterType,\n EventId,\n EventParameterValueMap,\n WidgetMessage,\n} from \"@osdk/widget.api\";\nimport {\n type AsyncParameterValueMap,\n type AsyncValue,\n FoundryHostEventTarget,\n type ParameterConfig,\n type ParameterValueMap,\n type WidgetConfig,\n} from \"@osdk/widget.client\";\nimport React, { useContext } from \"react\";\n\nexport type AugmentedEventParameterValueMap<\n C extends WidgetConfig<C[\"parameters\"]>,\n K extends EventId<C>,\n> = {\n [P in keyof EventParameterValueMap<C, K>]: P extends keyof C[\"parameters\"]\n ? C[\"parameters\"][P] extends { type: \"objectSet\"; allowedType: infer T }\n ? T extends AllowedObjectSetParameterType ? ObjectSet<T>\n : EventParameterValueMap<C, K>[P]\n : EventParameterValueMap<C, K>[P]\n : EventParameterValueMap<C, K>[P];\n};\n\ntype AugmentedEmitEventIdMap<C extends WidgetConfig<C[\"parameters\"]>> = {\n [K in EventId<C>]: {\n eventId: K;\n parameterUpdates: AugmentedEventParameterValueMap<C, K>;\n };\n};\n\ninterface AugmentedWidgetEmitEvent<C extends WidgetConfig<C[\"parameters\"]>>\n extends Omit<WidgetMessage.EmitEvent<C>, \"payload\">\n{\n payload: AugmentedEmitEventIdMap<C>[EventId<C>];\n}\n\n/**\n * Emits a widget event with parameter updates to the host Foundry UI.\n *\n * For object set parameters, pass `ObjectSet<T>` directly.\n * If the same event is emitted multiple times in quick succession and involves Object Set parameters, only the last call will be sent.\n * Errors (e.g., network failures when serializing ObjectSet parameters) are not surfaced to the caller.\n */\nexport type AugmentedEmitEvent<C extends WidgetConfig<C[\"parameters\"]>> = <\n M extends AugmentedWidgetEmitEvent<C>,\n ID extends M[\"payload\"][\"eventId\"],\n>(\n eventId: ID,\n payload: Omit<Extract<M[\"payload\"], { eventId: ID }>, \"eventId\">,\n) => void;\n\nexport interface FoundryWidgetClientContext<\n C extends WidgetConfig<C[\"parameters\"]>,\n> {\n /**\n * Emits a widget event with parameter updates to the host Foundry UI.\n *\n * - For ObjectSet parameters, pass `ObjectSet<T>` directly\n * - If the same event is emitted multiple times rapidly and involves Object Set parameters, only the last call is sent\n * - Errors are not surfaced to the caller\n */\n emitEvent: AugmentedEmitEvent<C>;\n hostEventTarget: FoundryHostEventTarget<C>;\n\n /**\n * Object where the individual parameters have their async state represented\n */\n asyncParameterValues: ExtendedAsyncParameterValueMap<C>;\n\n /**\n * Convenience object that aggregates the value of all parameters, accounting for their loading states\n */\n parameters: {\n values: Partial<ExtendedParameterValueMap<C>>;\n state: AsyncValue<ParameterValueMap<C>>[\"type\"];\n };\n}\n\nexport type ExtendedParameterValueMap<C extends WidgetConfig<C[\"parameters\"]>> =\n {\n [K in keyof C[\"parameters\"]]: K extends keyof ParameterValueMap<C>\n ? C[\"parameters\"][K] extends { type: \"objectSet\"; allowedType: infer T }\n ? T extends AllowedObjectSetParameterType\n ? ParameterValueMap<C>[K] & { objectSet: ObjectSet<T> }\n : ParameterValueMap<C>[K]\n : ParameterValueMap<C>[K]\n : never;\n };\n\nexport type ExtendedAsyncParameterValueMap<\n C extends WidgetConfig<C[\"parameters\"]>,\n> = {\n [K in keyof C[\"parameters\"]]: K extends keyof AsyncParameterValueMap<C>\n ? C[\"parameters\"][K] extends { type: \"objectSet\"; allowedType: infer T }\n ? T extends AllowedObjectSetParameterType\n ? AsyncParameterValueMap<C>[K] & {\n value: AsyncValue<\n ParameterValueMap<C>[K] & { objectSet: ObjectSet<T> }\n >;\n }\n : AsyncParameterValueMap<C>[K]\n : AsyncParameterValueMap<C>[K]\n : never;\n};\n\nexport const FoundryWidgetContext: React.Context<\n FoundryWidgetClientContext<WidgetConfig<ParameterConfig>>\n> = React.createContext<\n FoundryWidgetClientContext<WidgetConfig<ParameterConfig>>\n>({\n emitEvent: () => {},\n hostEventTarget: new FoundryHostEventTarget<WidgetConfig<ParameterConfig>>(),\n asyncParameterValues: {},\n parameters: {\n state: \"not-started\",\n values: {},\n },\n});\n\n/**\n * @returns The current FoundryWidgetClientContext, in the context of your specific parameter configuration\n */\nexport function useFoundryWidgetContext<\n C extends WidgetConfig<C[\"parameters\"]>,\n>(): FoundryWidgetClientContext<C> {\n return useContext(FoundryWidgetContext) as FoundryWidgetClientContext<C>;\n}\n\nexport namespace useFoundryWidgetContext {\n export function withTypes<\n C extends WidgetConfig<C[\"parameters\"]>,\n >(): () => FoundryWidgetClientContext<C> {\n return () => {\n return useFoundryWidgetContext<C>();\n };\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,SAGEA,sBAAsB,QAIjB,qBAAqB;AAC5B,OAAOC,KAAK,IAAIC,UAAU,QAAQ,OAAO;;AA2BzC;AACA;AACA;AACA;AACA;AACA;AACA;;AA+DA,OAAO,MAAMC,oBAEZ,gBAAGF,KAAK,CAACG,aAAa,CAErB;EACAC,SAAS,EAAEA,CAAA,KAAM,CAAC,CAAC;EACnBC,eAAe,EAAE,IAAIN,sBAAsB,CAAgC,CAAC;EAC5EO,oBAAoB,EAAE,CAAC,CAAC;EACxBC,UAAU,EAAE;IACVC,KAAK,EAAE,aAAa;IACpBC,MAAM,EAAE,CAAC;EACX;AACF,CAAC,CAAC;;AAEF;AACA;AACA;AACA,OAAO,SAASC,uBAAuBA,CAAA,EAEJ;EACjC,OAAOT,UAAU,CAACC,oBAAoB,CAAC;AACzC;AAAC,WAAAS,wBAAA;EAAAA,wBAAA,CAAAC,SAAA,GAGQ,YAEkC;IACvC,OAAO,MAAM;MACX,OAAOF,uBAAuB,CAAI,CAAC;IACrC,CAAC;EACH,CAAC;AAAA,GAPcA,uBAAuB,KAAvBA,uBAAuB","ignoreList":[]}
1
+ {"version":3,"file":"context.js","names":["FoundryHostEventTarget","React","useContext","FoundryWidgetContext","createContext","emitEvent","hostEventTarget","asyncParameterValues","parameters","state","values","useFoundryWidgetContext","_useFoundryWidgetContext","withTypes"],"sources":["context.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software=\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ObjectSet } from \"@osdk/client\";\nimport type {\n AllowedObjectSetParameterType,\n EventId,\n EventParameterValueMap,\n WidgetMessage,\n} from \"@osdk/widget.api\";\nimport {\n type AsyncParameterValueMap,\n type AsyncValue,\n FoundryHostEventTarget,\n type ParameterConfig,\n type ParameterValueMap,\n type WidgetConfig,\n} from \"@osdk/widget.client\";\nimport React, { useContext } from \"react\";\n\nexport type AugmentedEventParameterValueMap<\n C extends WidgetConfig<C[\"parameters\"]>,\n K extends EventId<C>,\n> = {\n [P in keyof EventParameterValueMap<C, K>]: P extends keyof C[\"parameters\"]\n ? C[\"parameters\"][P] extends { type: \"objectSet\"; allowedType: infer T }\n ? T extends AllowedObjectSetParameterType\n ? ObjectSet<T>\n : EventParameterValueMap<C, K>[P]\n : EventParameterValueMap<C, K>[P]\n : EventParameterValueMap<C, K>[P];\n};\n\ntype AugmentedEmitEventIdMap<C extends WidgetConfig<C[\"parameters\"]>> = {\n [K in EventId<C>]: {\n eventId: K;\n parameterUpdates: AugmentedEventParameterValueMap<C, K>;\n };\n};\n\ninterface AugmentedWidgetEmitEvent<\n C extends WidgetConfig<C[\"parameters\"]>,\n> extends Omit<WidgetMessage.EmitEvent<C>, \"payload\"> {\n payload: AugmentedEmitEventIdMap<C>[EventId<C>];\n}\n\n/**\n * Emits a widget event with parameter updates to the host Foundry UI.\n *\n * For object set parameters, pass `ObjectSet<T>` directly.\n * If the same event is emitted multiple times in quick succession and involves Object Set parameters, only the last call will be sent.\n * Errors (e.g., network failures when serializing ObjectSet parameters) are not surfaced to the caller.\n */\nexport type AugmentedEmitEvent<C extends WidgetConfig<C[\"parameters\"]>> = <\n M extends AugmentedWidgetEmitEvent<C>,\n ID extends M[\"payload\"][\"eventId\"],\n>(\n eventId: ID,\n payload: Omit<Extract<M[\"payload\"], { eventId: ID }>, \"eventId\">\n) => void;\n\nexport interface FoundryWidgetClientContext<\n C extends WidgetConfig<C[\"parameters\"]>,\n> {\n /**\n * Emits a widget event with parameter updates to the host Foundry UI.\n *\n * - For ObjectSet parameters, pass `ObjectSet<T>` directly\n * - If the same event is emitted multiple times rapidly and involves Object Set parameters, only the last call is sent\n * - Errors are not surfaced to the caller\n */\n emitEvent: AugmentedEmitEvent<C>;\n hostEventTarget: FoundryHostEventTarget<C>;\n\n /**\n * Object where the individual parameters have their async state represented\n */\n asyncParameterValues: ExtendedAsyncParameterValueMap<C>;\n\n /**\n * Convenience object that aggregates the value of all parameters, accounting for their loading states\n */\n parameters: {\n values: Partial<ExtendedParameterValueMap<C>>;\n state: AsyncValue<ParameterValueMap<C>>[\"type\"];\n };\n}\n\nexport type ExtendedParameterValueMap<C extends WidgetConfig<C[\"parameters\"]>> =\n {\n [K in keyof C[\"parameters\"]]: K extends keyof ParameterValueMap<C>\n ? C[\"parameters\"][K] extends { type: \"objectSet\"; allowedType: infer T }\n ? T extends AllowedObjectSetParameterType\n ? ParameterValueMap<C>[K] & { objectSet: ObjectSet<T> }\n : ParameterValueMap<C>[K]\n : ParameterValueMap<C>[K]\n : never;\n };\n\nexport type ExtendedAsyncParameterValueMap<\n C extends WidgetConfig<C[\"parameters\"]>,\n> = {\n [K in keyof C[\"parameters\"]]: K extends keyof AsyncParameterValueMap<C>\n ? C[\"parameters\"][K] extends { type: \"objectSet\"; allowedType: infer T }\n ? T extends AllowedObjectSetParameterType\n ? AsyncParameterValueMap<C>[K] & {\n value: AsyncValue<\n ParameterValueMap<C>[K] & { objectSet: ObjectSet<T> }\n >;\n }\n : AsyncParameterValueMap<C>[K]\n : AsyncParameterValueMap<C>[K]\n : never;\n};\n\nexport const FoundryWidgetContext: React.Context<\n FoundryWidgetClientContext<WidgetConfig<ParameterConfig>>\n> = React.createContext<\n FoundryWidgetClientContext<WidgetConfig<ParameterConfig>>\n>({\n emitEvent: () => {},\n hostEventTarget: new FoundryHostEventTarget<WidgetConfig<ParameterConfig>>(),\n asyncParameterValues: {},\n parameters: {\n state: \"not-started\",\n values: {},\n },\n});\n\n/**\n * @returns The current FoundryWidgetClientContext, in the context of your specific parameter configuration\n */\nexport function useFoundryWidgetContext<\n C extends WidgetConfig<C[\"parameters\"]>,\n>(): FoundryWidgetClientContext<C> {\n return useContext(FoundryWidgetContext) as FoundryWidgetClientContext<C>;\n}\n\nexport namespace useFoundryWidgetContext {\n export function withTypes<\n C extends WidgetConfig<C[\"parameters\"]>,\n >(): () => FoundryWidgetClientContext<C> {\n return () => {\n return useFoundryWidgetContext<C>();\n };\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,SAGEA,sBAAsB,QAIjB,qBAAqB;AAC5B,OAAOC,KAAK,IAAIC,UAAU,QAAQ,OAAO;;AA4BzC;AACA;AACA;AACA;AACA;AACA;AACA;;AA+DA,OAAO,MAAMC,oBAEZ,gBAAGF,KAAK,CAACG,aAAa,CAErB;EACAC,SAAS,EAAEA,CAAA,KAAM,CAAC,CAAC;EACnBC,eAAe,EAAE,IAAIN,sBAAsB,CAAgC,CAAC;EAC5EO,oBAAoB,EAAE,CAAC,CAAC;EACxBC,UAAU,EAAE;IACVC,KAAK,EAAE,aAAa;IACpBC,MAAM,EAAE,CAAC;EACX;AACF,CAAC,CAAC;;AAEF;AACA;AACA;AACA,OAAO,SAASC,uBAAuBA,CAAA,EAEJ;EACjC,OAAOT,UAAU,CAACC,oBAAoB,CAAC;AACzC;AAAC,WAAAS,wBAAA;EAAAA,wBAAA,CAAAC,SAAA,GAGQ,YAEkC;IACvC,OAAO,MAAM;MACX,OAAOF,uBAAuB,CAAI,CAAC;IACrC,CAAC;EACH,CAAC;AAAA,GAPcA,uBAAuB,KAAvBA,uBAAuB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"extendParametersWithObjectSets.js","names":["hydrateObjectSetFromRid","extendParametersWithObjectSets","osdkClient","config","parameters","cache","extendedParameters","parameterId","Object","keys","param","type","parameterValue","value","objectSetRid","objectSet","getOrHydrateObjectSet","allowedType","Error","delete","paramKey","definition","cached","get","set"],"sources":["extendParametersWithObjectSets.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Client, ObjectSet } from \"@osdk/client\";\nimport { hydrateObjectSetFromRid } from \"@osdk/client/internal\";\nimport type {\n AllowedObjectSetParameterType,\n AsyncParameterValueMap,\n WidgetConfig,\n} from \"@osdk/widget.api\";\nimport type { ExtendedAsyncParameterValueMap } from \"../context.js\";\n\n/**\n * Patches parameter values with hydrated object sets for object set parameters.\n *\n * The cache is used to avoid redundant hydration of the same object set RID, which\n * can cause unnecessary re-renders in React components consuming the parameters.\n */\nexport function extendParametersWithObjectSets<\n C extends WidgetConfig<C[\"parameters\"]>,\n>(\n osdkClient: Client | undefined,\n config: C,\n parameters: AsyncParameterValueMap<C>,\n cache: Map<string, { objectSetRid: string; objectSet: ObjectSet }>,\n): ExtendedAsyncParameterValueMap<C> {\n const extendedParameters = {\n ...parameters,\n } as ExtendedAsyncParameterValueMap<C>;\n\n for (const parameterId of Object.keys(extendedParameters)) {\n const param = config.parameters[parameterId];\n if (\n param.type === \"objectSet\"\n && extendedParameters[parameterId].type === \"objectSet\"\n ) {\n const parameterValue = extendedParameters[parameterId].value.value;\n if (parameterValue != null) {\n if (\n typeof parameterValue === \"object\"\n && \"objectSetRid\" in parameterValue\n && typeof parameterValue.objectSetRid === \"string\"\n ) {\n const objectSetRid = parameterValue.objectSetRid;\n const objectSet = getOrHydrateObjectSet(\n osdkClient,\n cache,\n parameterId,\n objectSetRid,\n param.allowedType,\n );\n (parameterValue as any).objectSet = objectSet;\n } else {\n throw new Error(\n `Invalid object set parameter value for parameter \"${parameterId}\"`,\n );\n }\n } else {\n cache.delete(parameterId);\n }\n }\n }\n\n return extendedParameters;\n}\n\nfunction getOrHydrateObjectSet<T extends AllowedObjectSetParameterType>(\n osdkClient: Client | undefined,\n cache: Map<string, { objectSetRid: string; objectSet: ObjectSet<T> }>,\n paramKey: string,\n objectSetRid: string,\n definition: T,\n) {\n if (osdkClient == null) {\n throw new Error(\"Not provided an OSDK client\");\n }\n const cached = cache.get(paramKey);\n if (cached?.objectSetRid === objectSetRid) {\n return cached.objectSet;\n }\n const objectSet = hydrateObjectSetFromRid(\n osdkClient,\n definition,\n objectSetRid,\n );\n cache.set(paramKey, { objectSetRid, objectSet });\n return objectSet;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,uBAAuB,QAAQ,uBAAuB;AAQ/D;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,8BAA8BA,CAG5CC,UAA8B,EAC9BC,MAAS,EACTC,UAAqC,EACrCC,KAAkE,EAC/B;EACnC,MAAMC,kBAAkB,GAAG;IACzB,GAAGF;EACL,CAAsC;EAEtC,KAAK,MAAMG,WAAW,IAAIC,MAAM,CAACC,IAAI,CAACH,kBAAkB,CAAC,EAAE;IACzD,MAAMI,KAAK,GAAGP,MAAM,CAACC,UAAU,CAACG,WAAW,CAAC;IAC5C,IACEG,KAAK,CAACC,IAAI,KAAK,WAAW,IACvBL,kBAAkB,CAACC,WAA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ateObjectSetFromRid","extendParametersWithObjectSets","osdkClient","config","parameters","cache","extendedParameters","parameterId","Object","keys","param","type","parameterValue","value","objectSetRid","objectSet","getOrHydrateObjectSet","allowedType","Error","delete","paramKey","definition","cached","get","set"],"sources":["extendParametersWithObjectSets.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Client, ObjectSet } from \"@osdk/client\";\nimport { hydrateObjectSetFromRid } from \"@osdk/client/internal\";\nimport type {\n AllowedObjectSetParameterType,\n AsyncParameterValueMap,\n WidgetConfig,\n} from \"@osdk/widget.api\";\n\nimport type { ExtendedAsyncParameterValueMap } from \"../context.js\";\n\n/**\n * Patches parameter values with hydrated object sets for object set parameters.\n *\n * The cache is used to avoid redundant hydration of the same object set RID, which\n * can cause unnecessary re-renders in React components consuming the parameters.\n */\nexport function extendParametersWithObjectSets<\n C extends WidgetConfig<C[\"parameters\"]>,\n>(\n osdkClient: Client | undefined,\n config: C,\n parameters: AsyncParameterValueMap<C>,\n cache: Map<string, { objectSetRid: string; objectSet: ObjectSet }>\n): ExtendedAsyncParameterValueMap<C> {\n const extendedParameters = {\n ...parameters,\n } as ExtendedAsyncParameterValueMap<C>;\n\n for (const parameterId of Object.keys(extendedParameters)) {\n const param = config.parameters[parameterId];\n if (\n param.type === \"objectSet\" &&\n extendedParameters[parameterId].type === \"objectSet\"\n ) {\n const parameterValue = extendedParameters[parameterId].value.value;\n if (parameterValue != null) {\n if (\n typeof parameterValue === \"object\" &&\n \"objectSetRid\" in parameterValue &&\n typeof parameterValue.objectSetRid === \"string\"\n ) {\n const objectSetRid = parameterValue.objectSetRid;\n const objectSet = getOrHydrateObjectSet(\n osdkClient,\n cache,\n parameterId,\n objectSetRid,\n param.allowedType\n );\n (parameterValue as any).objectSet = objectSet;\n } else {\n throw new Error(\n `Invalid object set parameter value for parameter \"${parameterId}\"`\n );\n }\n } else {\n cache.delete(parameterId);\n }\n }\n }\n\n return extendedParameters;\n}\n\nfunction getOrHydrateObjectSet<T extends AllowedObjectSetParameterType>(\n osdkClient: Client | undefined,\n cache: Map<string, { objectSetRid: string; objectSet: ObjectSet<T> }>,\n paramKey: string,\n objectSetRid: string,\n definition: T\n) {\n if (osdkClient == null) {\n throw new Error(\"Not provided an OSDK client\");\n }\n const cached = cache.get(paramKey);\n if (cached?.objectSetRid === objectSetRid) {\n return cached.objectSet;\n }\n const objectSet = hydrateObjectSetFromRid(\n osdkClient,\n definition,\n objectSetRid\n );\n cache.set(paramKey, { objectSetRid, objectSet });\n return objectSet;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,uBAAuB,QAAQ,uBAAuB;AAS/D;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,8BAA8BA,CAG5CC,UAA8B,EAC9BC,MAAS,EACTC,UAAqC,EACrCC,KAAkE,EAC/B;EACnC,MAAMC,kBAAkB,GAAG;IACzB,GAAGF;EACL,CAAsC;EAEtC,KAAK,MAAMG,WAAW,IAAIC,MAAM,CAACC,IAAI,CAACH,kBAAkB,CAAC,EAAE;IACzD,MAAMI,KAAK,GAAGP,MAAM,CAACC,UAAU,CAACG,WAAW,CAAC;IAC5C,IACEG,KAAK,CAACC,IAAI,KAAK,WAAW,IAC1BL,kBAAkB,CAACC,WAAW,CAAC,CAACI,IAAI,KAAK,WAAW,EACpD;MACA,MAAMC,cAAc,GAAGN,kBAAkB,CAACC,WAAW,CAAC,CAACM,KAAK,CAACA,KAAK;MAClE,IAAID,cAAc,IAAI,IAAI,EAAE;QAC1B,IACE,OAAOA,cAAc,KAAK,QAAQ,IAClC,cAAc,IAAIA,cAAc,IAChC,OAAOA,cAAc,CAACE,YAAY,KAAK,QAAQ,EAC/C;UACA,MAAMA,YAAY,GAAGF,cAAc,CAACE,YAAY;UAChD,MAAMC,SAAS,GAAGC,qBAAqB,CACrCd,UAAU,EACVG,KAAK,EACLE,WAAW,EACXO,YAAY,EACZJ,KAAK,CAACO,WACR,CAAC;UACAL,cAAc,CAASG,SAAS,GAAGA,SAAS;QAC/C,CAAC,MAAM;UACL,MAAM,IAAIG,KAAK,CACb,qDAAqDX,WAAW,GAClE,CAAC;QACH;MACF,CAAC,MAAM;QACLF,KAAK,CAACc,MAAM,CAACZ,WAAW,CAAC;MAC3B;IACF;EACF;EAEA,OAAOD,kBAAkB;AAC3B;AAEA,SAASU,qBAAqBA,CAC5Bd,UAA8B,EAC9BG,KAAqE,EACrEe,QAAgB,EAChBN,YAAoB,EACpBO,UAAa,EACb;EACA,IAAInB,UAAU,IAAI,IAAI,EAAE;IACtB,MAAM,IAAIgB,KAAK,CAAC,6BAA6B,CAAC;EAChD;EACA,MAAMI,MAAM,GAAGjB,KAAK,CAACkB,GAAG,CAACH,QAAQ,CAAC;EAClC,IAAIE,MAAM,EAAER,YAAY,KAAKA,YAAY,EAAE;IACzC,OAAOQ,MAAM,CAACP,SAAS;EACzB;EACA,MAAMA,SAAS,GAAGf,uBAAuB,CACvCE,UAAU,EACVmB,UAAU,EACVP,YACF,CAAC;EACDT,KAAK,CAACmB,GAAG,CAACJ,QAAQ,EAAE;IAAEN,YAAY;IAAEC;EAAU,CAAC,CAAC;EAChD,OAAOA,SAAS;AAClB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"initializeParameters.js","names":["initializeParameters","config","initialLoadingState","Object","fromEntries","entries","parameters","map","key","parameterConfig","type","value"],"sources":["initializeParameters.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { WidgetConfig } from \"@osdk/widget.client\";\nimport type { ExtendedAsyncParameterValueMap } from \"../context.js\";\n\n/**\n * Utility function to initialize a map of parameter values to either a loading or not-started loading state\n */\nexport function initializeParameters<C extends WidgetConfig<C[\"parameters\"]>>(\n config: C,\n initialLoadingState: \"loading\" | \"not-started\",\n): ExtendedAsyncParameterValueMap<C> {\n return Object.fromEntries(\n Object.entries(config.parameters).map(([key, parameterConfig]) => [\n key,\n { type: parameterConfig.type, value: { type: initialLoadingState } },\n ]),\n ) as ExtendedAsyncParameterValueMap<C>;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA,OAAO,SAASA,oBAAoBA,CAClCC,MAAS,EACTC,mBAA8C,EACX;EACnC,OAAOC,MAAM,CAACC,WAAW,CACvBD,MAAM,CAACE,OAAO,CAACJ,MAAM,CAACK,UAAU,CAAC,CAACC,GAAG,CAAC,CAAC,CAACC,GAAG,EAAEC,eAAe,CAAC,KAAK,CAChED,GAAG,EACH;IAAEE,IAAI,EAAED,eAAe,CAACC,IAAI;IAAEC,KAAK,EAAE;MAAED,IAAI,EAAER;IAAoB;EAAE,CAAC,CACrE,CACH,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"initializeParameters.js","names":["initializeParameters","config","initialLoadingState","Object","fromEntries","entries","parameters","map","key","parameterConfig","type","value"],"sources":["initializeParameters.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { WidgetConfig } from \"@osdk/widget.client\";\n\nimport type { ExtendedAsyncParameterValueMap } from \"../context.js\";\n\n/**\n * Utility function to initialize a map of parameter values to either a loading or not-started loading state\n */\nexport function initializeParameters<C extends WidgetConfig<C[\"parameters\"]>>(\n config: C,\n initialLoadingState: \"loading\" | \"not-started\"\n): ExtendedAsyncParameterValueMap<C> {\n return Object.fromEntries(\n Object.entries(config.parameters).map(([key, parameterConfig]) => [\n key,\n { type: parameterConfig.type, value: { type: initialLoadingState } },\n ])\n ) as ExtendedAsyncParameterValueMap<C>;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA,OAAO,SAASA,oBAAoBA,CAClCC,MAAS,EACTC,mBAA8C,EACX;EACnC,OAAOC,MAAM,CAACC,WAAW,CACvBD,MAAM,CAACE,OAAO,CAACJ,MAAM,CAACK,UAAU,CAAC,CAACC,GAAG,CAAC,CAAC,CAACC,GAAG,EAAEC,eAAe,CAAC,KAAK,CAChED,GAAG,EACH;IAAEE,IAAI,EAAED,eAAe,CAACC,IAAI;IAAEC,KAAK,EAAE;MAAED,IAAI,EAAER;IAAoB;EAAE,CAAC,CACrE,CACH,CAAC;AACH","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"transformEmitEventPayload.js","names":["createAndFetchTempObjectSetRid","transformEmitEventPayload","config","eventId","payload","osdkClient","paramId","Object","keys","parameterUpdates","paramConfig","parameters","type","transformEmitEventPayloadAsync","event","events","Error","toString","entries","transformedEntries","Promise","all","map","paramValue","objectSetRid","fromEntries"],"sources":["transformEmitEventPayload.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Client, ObjectSet } from \"@osdk/client\";\nimport { createAndFetchTempObjectSetRid } from \"@osdk/client/internal\";\nimport type {\n AsyncValue,\n EventId,\n EventParameterValueMap,\n ParameterValue,\n} from \"@osdk/widget.api\";\nimport type { WidgetConfig } from \"@osdk/widget.client\";\nimport type { AugmentedEventParameterValueMap } from \"../context.js\";\n\ntype ObjectSetEmitEventPayload = ParameterValue.ObjectSet[\"value\"] extends\n AsyncValue<infer T> ? T : never;\n\ntype TransformedEmitEventPayload<\n C extends WidgetConfig<C[\"parameters\"]>,\n K extends EventId<C>,\n> = {\n parameterUpdates: EventParameterValueMap<C, K>;\n};\n\ntype TransformedEmitEventPayloadResult<\n C extends WidgetConfig<C[\"parameters\"]>,\n K extends EventId<C>,\n> = {\n type: \"async\";\n payload: Promise<TransformedEmitEventPayload<C, K>>;\n} | {\n type: \"passThrough\";\n payload: TransformedEmitEventPayload<C, K>;\n};\n\nexport function transformEmitEventPayload<\n C extends WidgetConfig<C[\"parameters\"]>,\n K extends EventId<C>,\n>(\n config: C,\n eventId: K,\n payload: { parameterUpdates: AugmentedEventParameterValueMap<C, K> },\n osdkClient?: Client,\n): TransformedEmitEventPayloadResult<C, K> {\n for (const paramId of Object.keys(payload.parameterUpdates)) {\n const paramConfig = config.parameters[paramId];\n if (paramConfig?.type === \"objectSet\") {\n return {\n type: \"async\",\n payload: transformEmitEventPayloadAsync(\n config,\n eventId,\n payload,\n osdkClient,\n ),\n };\n }\n }\n\n // No object set parameters, pass through synchronously\n return {\n type: \"passThrough\",\n payload: {\n parameterUpdates: payload.parameterUpdates as EventParameterValueMap<\n C,\n K\n >,\n },\n };\n}\n\n/**\n * Transforms an augmented emit event payload by creating temporary object sets\n * from ObjectSet instances.\n *\n * Multiple ObjectSet parameters are transformed in parallel for better performance.\n */\nexport async function transformEmitEventPayloadAsync<\n C extends WidgetConfig<C[\"parameters\"]>,\n K extends EventId<C>,\n>(\n config: C,\n eventId: K,\n payload: { parameterUpdates: AugmentedEventParameterValueMap<C, K> },\n osdkClient?: Client,\n): Promise<{ parameterUpdates: EventParameterValueMap<C, K> }> {\n const event = config.events[eventId as string];\n if (event == null) {\n throw new Error(\n `Event with ID \"${eventId.toString()}\" not found in widget config`,\n );\n }\n\n const entries = Object.entries(payload.parameterUpdates);\n\n const transformedEntries = await Promise.all(\n entries.map(async ([paramId, paramValue]): Promise<[string, unknown]> => {\n const paramConfig = config.parameters[paramId];\n if (paramConfig?.type === \"objectSet\") {\n if (osdkClient == null) {\n throw new Error(\n `Cannot emit event \"${eventId.toString()}\" with ObjectSet parameter \"${paramId}\" without an osdk client`,\n );\n }\n const objectSetRid = await createAndFetchTempObjectSetRid(\n osdkClient,\n paramValue as ObjectSet,\n );\n return [paramId, { objectSetRid } satisfies ObjectSetEmitEventPayload];\n }\n return [paramId, paramValue];\n }),\n );\n\n return {\n parameterUpdates: Object.fromEntries(\n transformedEntries,\n ) as EventParameterValueMap<C, K>,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,8BAA8B,QAAQ,uBAAuB;AA+BtE,OAAO,SAASC,yBAAyBA,CAIvCC,MAAS,EACTC,OAAU,EACVC,OAAoE,EACpEC,UAAmB,EACsB;EACzC,KAAK,MAAMC,OAAO,IAAIC,MAA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AA8B,CACvDK,UAAU,EACVkB,UACF,CAAC;MACD,OAAO,CAACjB,OAAO,EAAE;QAAEkB;MAAa,CAAC,CAAqC;IACxE;IACA,OAAO,CAAClB,OAAO,EAAEiB,UAAU,CAAC;EAC9B,CAAC,CACH,CAAC;EAED,OAAO;IACLd,gBAAgB,EAAEF,MAAM,CAACkB,WAAW,CAClCN,kBACF;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"transformEmitEventPayload.js","names":["createAndFetchTempObjectSetRid","transformEmitEventPayload","config","eventId","payload","osdkClient","paramId","Object","keys","parameterUpdates","paramConfig","parameters","type","transformEmitEventPayloadAsync","event","events","Error","toString","entries","transformedEntries","Promise","all","map","paramValue","objectSetRid","fromEntries"],"sources":["transformEmitEventPayload.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Client, ObjectSet } from \"@osdk/client\";\nimport { createAndFetchTempObjectSetRid } from \"@osdk/client/internal\";\nimport type {\n AsyncValue,\n EventId,\n EventParameterValueMap,\n ParameterValue,\n} from \"@osdk/widget.api\";\nimport type { WidgetConfig } from \"@osdk/widget.client\";\n\nimport type { AugmentedEventParameterValueMap } from \"../context.js\";\n\ntype ObjectSetEmitEventPayload =\n ParameterValue.ObjectSet[\"value\"] extends AsyncValue<infer T> ? T : never;\n\ntype TransformedEmitEventPayload<\n C extends WidgetConfig<C[\"parameters\"]>,\n K extends EventId<C>,\n> = {\n parameterUpdates: EventParameterValueMap<C, K>;\n};\n\ntype TransformedEmitEventPayloadResult<\n C extends WidgetConfig<C[\"parameters\"]>,\n K extends EventId<C>,\n> =\n | {\n type: \"async\";\n payload: Promise<TransformedEmitEventPayload<C, K>>;\n }\n | {\n type: \"passThrough\";\n payload: TransformedEmitEventPayload<C, K>;\n };\n\nexport function transformEmitEventPayload<\n C extends WidgetConfig<C[\"parameters\"]>,\n K extends EventId<C>,\n>(\n config: C,\n eventId: K,\n payload: { parameterUpdates: AugmentedEventParameterValueMap<C, K> },\n osdkClient?: Client\n): TransformedEmitEventPayloadResult<C, K> {\n for (const paramId of Object.keys(payload.parameterUpdates)) {\n const paramConfig = config.parameters[paramId];\n if (paramConfig?.type === \"objectSet\") {\n return {\n type: \"async\",\n payload: transformEmitEventPayloadAsync(\n config,\n eventId,\n payload,\n osdkClient\n ),\n };\n }\n }\n\n // No object set parameters, pass through synchronously\n return {\n type: \"passThrough\",\n payload: {\n parameterUpdates: payload.parameterUpdates as EventParameterValueMap<\n C,\n K\n >,\n },\n };\n}\n\n/**\n * Transforms an augmented emit event payload by creating temporary object sets\n * from ObjectSet instances.\n *\n * Multiple ObjectSet parameters are transformed in parallel for better performance.\n */\nexport async function transformEmitEventPayloadAsync<\n C extends WidgetConfig<C[\"parameters\"]>,\n K extends EventId<C>,\n>(\n config: C,\n eventId: K,\n payload: { parameterUpdates: AugmentedEventParameterValueMap<C, K> },\n osdkClient?: Client\n): Promise<{ parameterUpdates: EventParameterValueMap<C, K> }> {\n const event = config.events[eventId as string];\n if (event == null) {\n throw new Error(\n `Event with ID \"${eventId.toString()}\" not found in widget config`\n );\n }\n\n const entries = Object.entries(payload.parameterUpdates);\n\n const transformedEntries = await Promise.all(\n entries.map(async ([paramId, paramValue]): Promise<[string, unknown]> => {\n const paramConfig = config.parameters[paramId];\n if (paramConfig?.type === \"objectSet\") {\n if (osdkClient == null) {\n throw new Error(\n `Cannot emit event \"${eventId.toString()}\" with ObjectSet parameter \"${paramId}\" without an osdk client`\n );\n }\n const objectSetRid = await createAndFetchTempObjectSetRid(\n osdkClient,\n paramValue as ObjectSet\n );\n return [paramId, { objectSetRid } satisfies ObjectSetEmitEventPayload];\n }\n return [paramId, paramValue];\n })\n );\n\n return {\n parameterUpdates: Object.fromEntries(\n transformedEntries\n ) as EventParameterValueMap<C, K>,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,8BAA8B,QAAQ,uBAAuB;AAkCtE,OAAO,SAASC,yBAAyBA,CAIvCC,MAAS,EACTC,OAAU,EACVC,OAAoE,EACpEC,UAAmB,EACsB;EACzC,KAAK,MAAMC,OAAO,IAAIC,MAAM,CAACC,IAAI,CAACJ,OAAO,CAACK,gBAAgB,CAAC,EAAE;IAC3D,MAAMC,WAAW,GAAGR,MAAM,CAACS,UAAU,CAACL,OAAO,CAAC;IAC9C,IAAII,WAAW,EAAEE,IAAI,KAAK,WAAW,EAAE;MACrC,OAAO;QACLA,IAAI,EAAE,OAAO;QACbR,OAAO,EAAES,8BAA8B,CACrCX,MAAM,EACNC,OAAO,EACPC,OAAO,EACPC,UACF;MACF,CAAC;IACH;EACF;;EAEA;EACA,OAAO;IACLO,IAAI,EAAE,aAAa;IACnBR,OAAO,EAAE;MACPK,gBAAgB,EAAEL,OAAO,CAACK;IAI5B;EACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeI,8BAA8BA,CAIlDX,MAAS,EACTC,OAAU,EACVC,OAAoE,EACpEC,UAAmB,EAC0C;EAC7D,MAAMS,KAAK,GAAGZ,MAAM,CAACa,MAAM,CAACZ,OAAO,CAAW;EAC9C,IAAIW,KAAK,IAAI,IAAI,EAAE;IACjB,MAAM,IAAIE,KAAK,CACb,kBAAkBb,OAAO,CAACc,QAAQ,CAAC,CAAC,8BACtC,CAAC;EACH;EAEA,MAAMC,OAAO,GAAGX,MAAM,CAACW,OAAO,CAACd,OAAO,CAACK,gBAAgB,CAAC;EAExD,MAAMU,kBAAkB,GAAG,MAAMC,OAAO,CAACC,GAAG,CAC1CH,OAAO,CAACI,GAAG,CAAC,OAAO,CAAChB,OAAO,EAAEiB,UAAU,CAAC,KAAiC;IACvE,MAAMb,WAAW,GAAGR,MAAM,CAACS,UAAU,CAACL,OAAO,CAAC;IAC9C,IAAII,WAAW,EAAEE,IAAI,KAAK,WAAW,EAAE;MACrC,IAAIP,UAAU,IAAI,IAAI,EAAE;QACtB,MAAM,IAAIW,KAAK,CACb,sBAAsBb,OAAO,CAACc,QAAQ,CAAC,CAAC,+BAA+BX,OAAO,0BAChF,CAAC;MACH;MACA,MAAMkB,YAAY,GAAG,MAAMxB,8BAA8B,CACvDK,UAAU,EACVkB,UACF,CAAC;MACD,OAAO,CAACjB,OAAO,EAAE;QAAEkB;MAAa,CAAC,CAAqC;IACxE;IACA,OAAO,CAAClB,OAAO,EAAEiB,UAAU,CAAC;EAC9B,CAAC,CACH,CAAC;EAED,OAAO;IACLd,gBAAgB,EAAEF,MAAM,CAACkB,WAAW,CAClCN,kBACF;EACF,CAAC;AACH","ignoreList":[]}
@@ -20,7 +20,7 @@ interface ImportMetaHot {
20
20
  on?: (event: "vite:beforeFullReload", cb: (payload: unknown) => void) => void;
21
21
  off?: (
22
22
  event: "vite:beforeFullReload",
23
- cb: (payload: unknown) => void,
23
+ cb: (payload: unknown) => void
24
24
  ) => void;
25
25
  }
26
26
 
@@ -81,7 +81,7 @@ type ExtractObjectTypes<C extends WidgetConfig<C["parameters"]>> = C["parameters
81
81
  allowedType: infer AT;
82
82
  } ? AT extends AllowedObjectSetParameterType ? AT : never : never : never;
83
83
  type HasObjectSetParameters<C extends WidgetConfig<C["parameters"]>> = ExtractObjectTypes<C> extends never ? false : true;
84
- type ObjectSetProps<C extends WidgetConfig<C["parameters"]>> = {
84
+ type ObjectSetProps<_C extends WidgetConfig<_C["parameters"]>> = {
85
85
  /**
86
86
  * Used to hydrate object sets from their RIDs for object set parameters
87
87
  */
@@ -1 +1 @@
1
- {"version":3,"file":"ErrorBoundary.js","names":["React","ErrorBoundary","Component","state","error","getDerivedStateFromError","render","errorDetails","Error","stack","createElement","style","padding","margin","color","process","env","NODE_ENV","Fragment","backgroundColor","overflow","fontSize","props","children"],"sources":["ErrorBoundary.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as React from \"react\";\n\ninterface State {\n error: unknown;\n}\n\n/**\n * Error boundary to catch and display errors in widget code.\n */\nexport class ErrorBoundary extends React.Component<\n React.PropsWithChildren,\n State\n> {\n state: State = { error: null };\n\n static getDerivedStateFromError(error: unknown): Partial<State> {\n return { error };\n }\n\n render(): React.ReactNode {\n if (this.state.error) {\n const errorDetails = this.state.error instanceof Error\n ? this.state.error.stack\n : \"See browser console for more details.\";\n\n return (\n <section style={{ padding: \"16px\" }}>\n <h3 style={{ margin: \"0 0 12px 0\", color: \"#c00\" }}>\n An uncaught error occurred\n </h3>\n {process.env.NODE_ENV !== \"production\" && (\n <>\n <p style={{ margin: \"0 0 8px 0\" }}>\n This error was caught by the widget framework's fallback error\n boundary.\n </p>\n <ul style={{ margin: \"0 0 16px 0\" }}>\n <li>\n Ensure errors are properly handled in your code with try-catch\n blocks and promise rejection handling.\n </li>\n <li>\n Add your own error boundary to replace this fallback with a\n custom error message or recovery options for your users.\n </li>\n <li>\n See:{\" \"}\n <code>\n https://react.dev/reference/react/Component#catching-rendering-errors-with-an-error-boundary\n </code>\n </li>\n </ul>\n </>\n )}\n <pre\n style={{\n backgroundColor: \"#f5f5f5\",\n padding: \"12px\",\n overflow: \"auto\",\n fontSize: \"12px\",\n margin: 0,\n }}\n >\n {errorDetails}\n </pre>\n </section>\n );\n }\n\n return this.props.children;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAM9B;AACA;AACA;AACA,OAAO,MAAMC,aAAa,SAASD,KAAK,CAACE,SAAS,CAGhD;EACAC,KAAK,GAAU;IAAEC,KAAK,EAAE;EAAK,CAAC;EAE9B,OAAOC,wBAAwBA,CAACD,KAAc,EAAkB;IAC9D,OAAO;MAAEA;IAAM,CAAC;EAClB;EAEAE,MAAMA,CAAA,EAAoB;IACxB,IAAI,IAAI,CAACH,KAAK,CAACC,KAAK,EAAE;MACpB,MAAMG,YAAY,GAAG,IAAI,CAACJ,KAAK,CAACC,KAAK,YAAYI,KAAK,GAClD,IAAI,CAACL,KAAK,CAACC,KAAK,CAACK,KAAK,GACtB,uCAAuC;MAE3C,oBACET,KAAA,CAAAU,aAAA;QAASC,KAAK,EAAE;UAAEC,OAAO,EAAE;QAAO;MAAE,gBAClCZ,KAAA,CAAAU,aAAA;QAAIC,KAAK,EAAE;UAAEE,MAAM,EAAE,YAAY;UAAEC,KAAK,EAAE;QAAO;MAAE,GAAC,4BAEhD,CAAC,EACJC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,iBACpCjB,KAAA,CAAAU,aAAA,CAAAV,KAAA,CAAAkB,QAAA,qBACElB,KAAA,CAAAU,aAAA;QAAGC,KAAK,EAAE;UAAEE,MAAM,EAAE;QAAY;MAAE,GAAC,0EAGhC,CAAC,eACJb,KAAA,CAAAU,aAAA;QAAIC,KAAK,EAAE;UAAEE,MAAM,EAAE;QAAa;MAAE,gBAClCb,KAAA,CAAAU,aAAA,aAAI,uGAGA,CAAC,eACLV,KAAA,CAAAU,aAAA,aAAI,sHAGA,CAAC,eACLV,KAAA,CAAAU,aAAA,aAAI,MACE,EAAC,GAAG,eACRV,KAAA,CAAAU,aAAA,eAAM,8FAEA,CACJ,CACF,CACJ,CACH,eACDV,KAAA,CAAAU,aAAA;QACEC,KAAK,EAAE;UACLQ,eAAe,EAAE,SAAS;UAC1BP,OAAO,EAAE,MAAM;UACfQ,QAAQ,EAAE,MAAM;UAChBC,QAAQ,EAAE,MAAM;UAChBR,MAAM,EAAE;QACV;MAAE,GAEDN,YACE,CACE,CAAC;IAEd;IAEA,OAAO,IAAI,CAACe,KAAK,CAACC,QAAQ;EAC5B;AACF","ignoreList":[]}
1
+ {"version":3,"file":"ErrorBoundary.js","names":["React","ErrorBoundary","Component","state","error","getDerivedStateFromError","render","errorDetails","Error","stack","createElement","style","padding","margin","color","process","env","NODE_ENV","Fragment","backgroundColor","overflow","fontSize","props","children"],"sources":["ErrorBoundary.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as React from \"react\";\n\ninterface State {\n error: unknown;\n}\n\n/**\n * Error boundary to catch and display errors in widget code.\n */\nexport class ErrorBoundary extends React.Component<\n React.PropsWithChildren,\n State\n> {\n state: State = { error: null };\n\n static getDerivedStateFromError(error: unknown): Partial<State> {\n return { error };\n }\n\n render(): React.ReactNode {\n if (this.state.error) {\n const errorDetails =\n this.state.error instanceof Error\n ? this.state.error.stack\n : \"See browser console for more details.\";\n\n return (\n <section style={{ padding: \"16px\" }}>\n <h3 style={{ margin: \"0 0 12px 0\", color: \"#c00\" }}>\n An uncaught error occurred\n </h3>\n {process.env.NODE_ENV !== \"production\" && (\n <>\n <p style={{ margin: \"0 0 8px 0\" }}>\n This error was caught by the widget framework's fallback error\n boundary.\n </p>\n <ul style={{ margin: \"0 0 16px 0\" }}>\n <li>\n Ensure errors are properly handled in your code with try-catch\n blocks and promise rejection handling.\n </li>\n <li>\n Add your own error boundary to replace this fallback with a\n custom error message or recovery options for your users.\n </li>\n <li>\n See:{\" \"}\n <code>\n https://react.dev/reference/react/Component#catching-rendering-errors-with-an-error-boundary\n </code>\n </li>\n </ul>\n </>\n )}\n <pre\n style={{\n backgroundColor: \"#f5f5f5\",\n padding: \"12px\",\n overflow: \"auto\",\n fontSize: \"12px\",\n margin: 0,\n }}\n >\n {errorDetails}\n </pre>\n </section>\n );\n }\n\n return this.props.children;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAM9B;AACA;AACA;AACA,OAAO,MAAMC,aAAa,SAASD,KAAK,CAACE,SAAS,CAGhD;EACAC,KAAK,GAAU;IAAEC,KAAK,EAAE;EAAK,CAAC;EAE9B,OAAOC,wBAAwBA,CAACD,KAAc,EAAkB;IAC9D,OAAO;MAAEA;IAAM,CAAC;EAClB;EAEAE,MAAMA,CAAA,EAAoB;IACxB,IAAI,IAAI,CAACH,KAAK,CAACC,KAAK,EAAE;MACpB,MAAMG,YAAY,GAChB,IAAI,CAACJ,KAAK,CAACC,KAAK,YAAYI,KAAK,GAC7B,IAAI,CAACL,KAAK,CAACC,KAAK,CAACK,KAAK,GACtB,uCAAuC;MAE7C,oBACET,KAAA,CAAAU,aAAA;QAASC,KAAK,EAAE;UAAEC,OAAO,EAAE;QAAO;MAAE,gBAClCZ,KAAA,CAAAU,aAAA;QAAIC,KAAK,EAAE;UAAEE,MAAM,EAAE,YAAY;UAAEC,KAAK,EAAE;QAAO;MAAE,GAAC,4BAEhD,CAAC,EACJC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,iBACpCjB,KAAA,CAAAU,aAAA,CAAAV,KAAA,CAAAkB,QAAA,qBACElB,KAAA,CAAAU,aAAA;QAAGC,KAAK,EAAE;UAAEE,MAAM,EAAE;QAAY;MAAE,GAAC,0EAGhC,CAAC,eACJb,KAAA,CAAAU,aAAA;QAAIC,KAAK,EAAE;UAAEE,MAAM,EAAE;QAAa;MAAE,gBAClCb,KAAA,CAAAU,aAAA,aAAI,uGAGA,CAAC,eACLV,KAAA,CAAAU,aAAA,aAAI,sHAGA,CAAC,eACLV,KAAA,CAAAU,aAAA,aAAI,MACE,EAAC,GAAG,eACRV,KAAA,CAAAU,aAAA,eAAM,8FAEA,CACJ,CACF,CACJ,CACH,eACDV,KAAA,CAAAU,aAAA;QACEC,KAAK,EAAE;UACLQ,eAAe,EAAE,SAAS;UAC1BP,OAAO,EAAE,MAAM;UACfQ,QAAQ,EAAE,MAAM;UAChBC,QAAQ,EAAE,MAAM;UAChBR,MAAM,EAAE;QACV;MAAE,GAEDN,YACE,CACE,CAAC;IAEd;IAEA,OAAO,IAAI,CAACe,KAAK,CAACC,QAAQ;EAC5B;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","names":["createFoundryWidgetClient","React","useCallback","useEffect","useMemo","useRef","FoundryWidgetContext","ErrorBoundary","extendParametersWithObjectSets","initializeParameters","transformEmitEventPayload","FoundryWidget","children","config","initialValues","client","osdkClient","asyncParameterValues","setAsyncParameterValues","useState","allParameterValues","setAllParameterValues","type","objectSetCache","Map","emitEventCallIds","emitEvent","eventId","payload","transformResult","eventKey","String","thisCallId","current","get","set","transformedPayload","subscribe","hostEventTarget","addEventListener","processedParameters","detail","parameters","currentParameters","aggregatedLoadedState","firstError","newParameterValues","key","value","error","currentParameterValue","updatedValue","Error","ready","resizeObserver","ResizeObserver","entries","length","console","entry","borderBoxSize","inlineSize","width","blockSize","height","resize","observe","document","body","box","handleFullReload","reload","import","meta","hot","on","unsubscribe","disconnect","off","createElement","Provider","values","state"],"sources":["client.tsx"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Client, ObjectSet } from \"@osdk/client\";\nimport type { AllowedObjectSetParameterType } from \"@osdk/widget.api\";\nimport {\n type AsyncValue,\n createFoundryWidgetClient,\n type FoundryWidgetClient,\n type ParameterConfig,\n type WidgetConfig,\n} from \"@osdk/widget.client\";\nimport React, { useCallback, useEffect, useMemo, useRef } from \"react\";\nimport type {\n AugmentedEmitEvent,\n ExtendedAsyncParameterValueMap,\n ExtendedParameterValueMap,\n FoundryWidgetClientContext,\n} from \"./context.js\";\nimport { FoundryWidgetContext } from \"./context.js\";\nimport { ErrorBoundary } from \"./ErrorBoundary.js\";\nimport { extendParametersWithObjectSets } from \"./utils/extendParametersWithObjectSets.js\";\nimport { initializeParameters } from \"./utils/initializeParameters.js\";\nimport { transformEmitEventPayload } from \"./utils/transformEmitEventPayload.js\";\n\ntype ExtractObjectTypes<C extends WidgetConfig<C[\"parameters\"]>> =\n C[\"parameters\"][keyof C[\"parameters\"]] extends infer Param\n ? Param extends { type: \"objectSet\"; allowedType: infer AT }\n ? AT extends AllowedObjectSetParameterType ? AT\n : never\n : never\n : never;\n\ntype HasObjectSetParameters<C extends WidgetConfig<C[\"parameters\"]>> =\n ExtractObjectTypes<C> extends never ? false : true;\n\ntype ObjectSetProps<C extends WidgetConfig<C[\"parameters\"]>> = {\n /**\n * Used to hydrate object sets from their RIDs for object set parameters\n */\n client: Client;\n};\n\ntype FoundryWidgetProps<C extends WidgetConfig<C[\"parameters\"]>> =\n & {\n children: React.ReactNode;\n\n /**\n * Parameter configuration for the widget\n */\n config: C;\n\n /**\n * Customize what the initial value of each parameter should be\n *\n * @default Sets all parameters to the \"not-started\" loading state\n */\n initialValues?: ExtendedAsyncParameterValueMap<C>;\n }\n & Partial<ObjectSetProps<C>>\n & (HasObjectSetParameters<C> extends true ? ObjectSetProps<C> : {});\n\n/**\n * Handles subscribing to messages from the host Foundry UI and updating the widget's parameter values accordingly via React context\n */\nexport const FoundryWidget = <C extends WidgetConfig<C[\"parameters\"]>>({\n children,\n config,\n initialValues,\n client: osdkClient,\n}: FoundryWidgetProps<C>): React.ReactElement<FoundryWidgetProps<C>> => {\n const client = useMemo(() => createFoundryWidgetClient<C>(), []);\n const [asyncParameterValues, setAsyncParameterValues] = React.useState<\n ExtendedAsyncParameterValueMap<C>\n >(initialValues ?? initializeParameters(config, \"not-started\"));\n const [allParameterValues, setAllParameterValues] = React.useState<\n AsyncValue<ExtendedParameterValueMap<C>>\n >({\n type: \"not-started\",\n });\n\n const objectSetCache = useRef<\n Map<string, { objectSetRid: string; objectSet: ObjectSet }>\n >(new Map());\n\n const emitEventCallIds = useRef<Map<string, number>>(new Map());\n\n const emitEvent: AugmentedEmitEvent<C> = useCallback(\n (eventId: Parameters<FoundryWidgetClient<C>[\"emitEvent\"]>[0], payload) => {\n const transformResult = transformEmitEventPayload(\n config,\n eventId,\n payload,\n osdkClient,\n );\n if (transformResult.type === \"passThrough\") {\n client.emitEvent(\n eventId,\n transformResult.payload as Parameters<\n FoundryWidgetClient<C>[\"emitEvent\"]\n >[1],\n );\n return;\n }\n\n async function handleAsyncEmitEvent() {\n const eventKey = String(eventId);\n const thisCallId = (emitEventCallIds.current.get(eventKey) ?? 0) + 1;\n emitEventCallIds.current.set(eventKey, thisCallId);\n\n const transformedPayload = await transformResult.payload;\n\n if (thisCallId !== emitEventCallIds.current.get(eventKey)) {\n return;\n }\n\n client.emitEvent(\n eventId,\n transformedPayload as Parameters<\n FoundryWidgetClient<C>[\"emitEvent\"]\n >[1],\n );\n }\n\n void handleAsyncEmitEvent();\n },\n [osdkClient, config, client],\n );\n\n useEffect(() => {\n client.subscribe();\n client.hostEventTarget.addEventListener(\n \"host.update-parameters\",\n (payload) => {\n const processedParameters = extendParametersWithObjectSets(\n osdkClient,\n config,\n payload.detail.parameters,\n objectSetCache.current,\n );\n setAsyncParameterValues((currentParameters) => ({\n ...currentParameters,\n ...processedParameters,\n }));\n setAllParameterValues((currentParameters) => {\n let aggregatedLoadedState: AsyncValue<any>[\"type\"] = \"loaded\";\n let firstError: Error | undefined;\n const newParameterValues: ExtendedParameterValueMap<\n WidgetConfig<ParameterConfig>\n > = {};\n for (const key in processedParameters) {\n const value = processedParameters[key].value;\n // If any fails, consider the whole thing failed\n if (value.type === \"failed\") {\n aggregatedLoadedState = \"failed\";\n firstError = firstError ?? value.error;\n newParameterValues[key as any] = value.value as any;\n continue;\n }\n // If any is loading, consider all of it loading unless we have failed somewhere\n if (\n value.type === \"loading\"\n && aggregatedLoadedState !== \"failed\"\n ) {\n aggregatedLoadedState = \"loading\";\n continue;\n }\n // If any is reloading, consider it loading unless something is failed or loading for the first time\n if (\n value.type === \"reloading\"\n && aggregatedLoadedState !== \"failed\"\n && aggregatedLoadedState !== \"loading\"\n ) {\n aggregatedLoadedState = \"reloading\";\n newParameterValues[key as any] = value.value as any;\n continue;\n }\n if (\n value.type === \"not-started\"\n && aggregatedLoadedState !== \"failed\"\n && aggregatedLoadedState !== \"loading\"\n && aggregatedLoadedState !== \"reloading\"\n ) {\n aggregatedLoadedState = \"not-started\";\n }\n\n if (value.type === \"loaded\") {\n newParameterValues[key as any] = value.value as any;\n }\n }\n const currentParameterValue = currentParameters.type !== \"not-started\"\n && currentParameters.type !== \"loading\"\n ? currentParameters.value\n : {};\n if (\n aggregatedLoadedState !== \"not-started\"\n && aggregatedLoadedState !== \"loading\"\n ) {\n const updatedValue = {\n ...currentParameterValue,\n ...newParameterValues,\n } as ExtendedParameterValueMap<C>;\n return aggregatedLoadedState === \"failed\"\n ? {\n type: aggregatedLoadedState,\n value: updatedValue,\n error: firstError ?? new Error(\"Failed to load parameters\"),\n }\n : {\n type: aggregatedLoadedState,\n value: updatedValue,\n };\n } else {\n return { type: aggregatedLoadedState };\n }\n });\n },\n );\n client.ready();\n\n const resizeObserver = new ResizeObserver((entries) => {\n if (entries.length !== 1) {\n // eslint-disable-next-line no-console\n console.error(\n \"Expected exactly one resize observer entry but received:\",\n entries,\n );\n return;\n }\n const entry = entries[0];\n if (entry.borderBoxSize.length !== 1) {\n // eslint-disable-next-line no-console\n console.error(\n \"Expected exactly one border box size but received:\",\n entry.borderBoxSize,\n );\n return;\n }\n const { inlineSize: width, blockSize: height } = entry.borderBoxSize[0];\n client.resize({ width, height });\n });\n resizeObserver.observe(document.body, { box: \"border-box\" });\n\n const handleFullReload = () => client.reload();\n if (import.meta.hot?.on) {\n import.meta.hot.on(\"vite:beforeFullReload\", handleFullReload);\n }\n\n return () => {\n client.unsubscribe();\n resizeObserver.disconnect();\n if (import.meta.hot?.off) {\n import.meta.hot.off(\"vite:beforeFullReload\", handleFullReload);\n }\n };\n }, []);\n\n return (\n <FoundryWidgetContext.Provider\n value={{\n emitEvent,\n hostEventTarget: client.hostEventTarget,\n asyncParameterValues,\n parameters: {\n values: allParameterValues.value ?? {},\n state: allParameterValues.type,\n },\n // Unfortunately the context is statically defined so we can't use the generic type, hence the cast\n } as FoundryWidgetClientContext<WidgetConfig<ParameterConfig>>}\n >\n <ErrorBoundary>\n {children}\n </ErrorBoundary>\n </FoundryWidgetContext.Provider>\n );\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAEEA,yBAAyB,QAIpB,qBAAqB;AAC5B,OAAOC,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAOtE,SAASC,oBAAoB,QAAQ,cAAc;AACnD,S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AAC;EAEN,oBACErE,KAAA,CAAA8E,aAAA,CAACzE,oBAAoB,CAAC0E,QAAQ;IAC5BhC,KAAK,EAAE;MACLtB,SAAS;MACTY,eAAe,EAAEvB,MAAM,CAACuB,eAAe;MACvCrB,oBAAoB;MACpByB,UAAU,EAAE;QACVuC,MAAM,EAAE7D,kBAAkB,CAAC4B,KAAK,IAAI,CAAC,CAAC;QACtCkC,KAAK,EAAE9D,kBAAkB,CAACE;MAC5B;MACA;IACF;EAA+D,gBAE/DrB,KAAA,CAAA8E,aAAA,CAACxE,aAAa,QACXK,QACY,CACc,CAAC;AAEpC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"client.js","names":["createFoundryWidgetClient","React","useCallback","useEffect","useMemo","useRef","FoundryWidgetContext","ErrorBoundary","extendParametersWithObjectSets","initializeParameters","transformEmitEventPayload","FoundryWidget","children","config","initialValues","client","osdkClient","asyncParameterValues","setAsyncParameterValues","useState","allParameterValues","setAllParameterValues","type","objectSetCache","Map","emitEventCallIds","emitEvent","eventId","payload","transformResult","eventKey","String","thisCallId","current","get","set","transformedPayload","subscribe","hostEventTarget","addEventListener","processedParameters","detail","parameters","currentParameters","aggregatedLoadedState","firstError","newParameterValues","key","value","error","currentParameterValue","updatedValue","Error","ready","resizeObserver","ResizeObserver","entries","length","console","entry","borderBoxSize","inlineSize","width","blockSize","height","resize","observe","document","body","box","handleFullReload","reload","import","meta","hot","on","unsubscribe","disconnect","off","createElement","Provider","values","state"],"sources":["client.tsx"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Client, ObjectSet } from \"@osdk/client\";\nimport type { AllowedObjectSetParameterType } from \"@osdk/widget.api\";\nimport {\n type AsyncValue,\n createFoundryWidgetClient,\n type FoundryWidgetClient,\n type ParameterConfig,\n type WidgetConfig,\n} from \"@osdk/widget.client\";\nimport React, { useCallback, useEffect, useMemo, useRef } from \"react\";\n\nimport type {\n AugmentedEmitEvent,\n ExtendedAsyncParameterValueMap,\n ExtendedParameterValueMap,\n FoundryWidgetClientContext,\n} from \"./context.js\";\nimport { FoundryWidgetContext } from \"./context.js\";\nimport { ErrorBoundary } from \"./ErrorBoundary.js\";\nimport { extendParametersWithObjectSets } from \"./utils/extendParametersWithObjectSets.js\";\nimport { initializeParameters } from \"./utils/initializeParameters.js\";\nimport { transformEmitEventPayload } from \"./utils/transformEmitEventPayload.js\";\n\ntype ExtractObjectTypes<C extends WidgetConfig<C[\"parameters\"]>> =\n C[\"parameters\"][keyof C[\"parameters\"]] extends infer Param\n ? Param extends { type: \"objectSet\"; allowedType: infer AT }\n ? AT extends AllowedObjectSetParameterType\n ? AT\n : never\n : never\n : never;\n\ntype HasObjectSetParameters<C extends WidgetConfig<C[\"parameters\"]>> =\n ExtractObjectTypes<C> extends never ? false : true;\n\ntype ObjectSetProps<_C extends WidgetConfig<_C[\"parameters\"]>> = {\n /**\n * Used to hydrate object sets from their RIDs for object set parameters\n */\n client: Client;\n};\n\ntype FoundryWidgetProps<C extends WidgetConfig<C[\"parameters\"]>> = {\n children: React.ReactNode;\n\n /**\n * Parameter configuration for the widget\n */\n config: C;\n\n /**\n * Customize what the initial value of each parameter should be\n *\n * @default Sets all parameters to the \"not-started\" loading state\n */\n initialValues?: ExtendedAsyncParameterValueMap<C>;\n} & Partial<ObjectSetProps<C>> &\n (HasObjectSetParameters<C> extends true ? ObjectSetProps<C> : {});\n\n/**\n * Handles subscribing to messages from the host Foundry UI and updating the widget's parameter values accordingly via React context\n */\nexport const FoundryWidget = <C extends WidgetConfig<C[\"parameters\"]>>({\n children,\n config,\n initialValues,\n client: osdkClient,\n}: FoundryWidgetProps<C>): React.ReactElement<FoundryWidgetProps<C>> => {\n const client = useMemo(() => createFoundryWidgetClient<C>(), []);\n const [asyncParameterValues, setAsyncParameterValues] = React.useState<\n ExtendedAsyncParameterValueMap<C>\n >(initialValues ?? initializeParameters(config, \"not-started\"));\n const [allParameterValues, setAllParameterValues] = React.useState<\n AsyncValue<ExtendedParameterValueMap<C>>\n >({\n type: \"not-started\",\n });\n\n const objectSetCache = useRef<\n Map<string, { objectSetRid: string; objectSet: ObjectSet }>\n >(new Map());\n\n const emitEventCallIds = useRef<Map<string, number>>(new Map());\n\n const emitEvent: AugmentedEmitEvent<C> = useCallback(\n (eventId: Parameters<FoundryWidgetClient<C>[\"emitEvent\"]>[0], payload) => {\n const transformResult = transformEmitEventPayload(\n config,\n eventId,\n payload,\n osdkClient\n );\n if (transformResult.type === \"passThrough\") {\n client.emitEvent(\n eventId,\n transformResult.payload as Parameters<\n FoundryWidgetClient<C>[\"emitEvent\"]\n >[1]\n );\n return;\n }\n\n async function handleAsyncEmitEvent() {\n const eventKey = String(eventId);\n const thisCallId = (emitEventCallIds.current.get(eventKey) ?? 0) + 1;\n emitEventCallIds.current.set(eventKey, thisCallId);\n\n const transformedPayload = await transformResult.payload;\n\n if (thisCallId !== emitEventCallIds.current.get(eventKey)) {\n return;\n }\n\n client.emitEvent(\n eventId,\n transformedPayload as Parameters<\n FoundryWidgetClient<C>[\"emitEvent\"]\n >[1]\n );\n }\n\n void handleAsyncEmitEvent();\n },\n [osdkClient, config, client]\n );\n\n useEffect(() => {\n client.subscribe();\n client.hostEventTarget.addEventListener(\n \"host.update-parameters\",\n (payload) => {\n const processedParameters = extendParametersWithObjectSets(\n osdkClient,\n config,\n payload.detail.parameters,\n objectSetCache.current\n );\n setAsyncParameterValues((currentParameters) => ({\n ...currentParameters,\n ...processedParameters,\n }));\n setAllParameterValues((currentParameters) => {\n let aggregatedLoadedState: AsyncValue<any>[\"type\"] = \"loaded\";\n let firstError: Error | undefined;\n const newParameterValues: ExtendedParameterValueMap<\n WidgetConfig<ParameterConfig>\n > = {};\n for (const key in processedParameters) {\n const value = processedParameters[key].value;\n // If any fails, consider the whole thing failed\n if (value.type === \"failed\") {\n aggregatedLoadedState = \"failed\";\n firstError = firstError ?? value.error;\n newParameterValues[key as any] = value.value as any;\n continue;\n }\n // If any is loading, consider all of it loading unless we have failed somewhere\n if (\n value.type === \"loading\" &&\n aggregatedLoadedState !== \"failed\"\n ) {\n aggregatedLoadedState = \"loading\";\n continue;\n }\n // If any is reloading, consider it loading unless something is failed or loading for the first time\n if (\n value.type === \"reloading\" &&\n aggregatedLoadedState !== \"failed\" &&\n aggregatedLoadedState !== \"loading\"\n ) {\n aggregatedLoadedState = \"reloading\";\n newParameterValues[key as any] = value.value as any;\n continue;\n }\n if (\n value.type === \"not-started\" &&\n aggregatedLoadedState !== \"failed\" &&\n aggregatedLoadedState !== \"loading\" &&\n aggregatedLoadedState !== \"reloading\"\n ) {\n aggregatedLoadedState = \"not-started\";\n }\n\n if (value.type === \"loaded\") {\n newParameterValues[key as any] = value.value as any;\n }\n }\n const currentParameterValue =\n currentParameters.type !== \"not-started\" &&\n currentParameters.type !== \"loading\"\n ? currentParameters.value\n : {};\n if (\n aggregatedLoadedState !== \"not-started\" &&\n aggregatedLoadedState !== \"loading\"\n ) {\n const updatedValue = {\n ...currentParameterValue,\n ...newParameterValues,\n } as ExtendedParameterValueMap<C>;\n return aggregatedLoadedState === \"failed\"\n ? {\n type: aggregatedLoadedState,\n value: updatedValue,\n error: firstError ?? new Error(\"Failed to load parameters\"),\n }\n : {\n type: aggregatedLoadedState,\n value: updatedValue,\n };\n } else {\n return { type: aggregatedLoadedState };\n }\n });\n }\n );\n client.ready();\n\n const resizeObserver = new ResizeObserver((entries) => {\n if (entries.length !== 1) {\n // eslint-disable-next-line no-console\n console.error(\n \"Expected exactly one resize observer entry but received:\",\n entries\n );\n return;\n }\n const entry = entries[0];\n if (entry.borderBoxSize.length !== 1) {\n // eslint-disable-next-line no-console\n console.error(\n \"Expected exactly one border box size but received:\",\n entry.borderBoxSize\n );\n return;\n }\n const { inlineSize: width, blockSize: height } = entry.borderBoxSize[0];\n client.resize({ width, height });\n });\n resizeObserver.observe(document.body, { box: \"border-box\" });\n\n const handleFullReload = () => client.reload();\n if (import.meta.hot?.on) {\n import.meta.hot.on(\"vite:beforeFullReload\", handleFullReload);\n }\n\n return () => {\n client.unsubscribe();\n resizeObserver.disconnect();\n if (import.meta.hot?.off) {\n import.meta.hot.off(\"vite:beforeFullReload\", handleFullReload);\n }\n };\n }, []);\n\n return (\n <FoundryWidgetContext.Provider\n value={\n {\n emitEvent,\n hostEventTarget: client.hostEventTarget,\n asyncParameterValues,\n parameters: {\n values: allParameterValues.value ?? {},\n state: allParameterValues.type,\n },\n // Unfortunately the context is statically defined so we can't use the generic type, hence the cast\n } as FoundryWidgetClientContext<WidgetConfig<ParameterConfig>>\n }\n >\n <ErrorBoundary>{children}</ErrorBoundary>\n </FoundryWidgetContext.Provider>\n );\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,SAEEA,yBAAyB,QAIpB,qBAAqB;AAC5B,OAAOC,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAQtE,SAASC,oBAAoB,QAAQ,cAAc;AACnD,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SAASC,8BAA8B,QAAQ,2CAA2C;AAC1F,SAASC,oBAAoB,QAAQ,iCAAiC;AACtE,SAASC,yBAAyB,QAAQ,sCAAsC;AAsChF;AACA;AACA;AACA,OAAO,MAAMC,aAAa,GAAGA,CAA0C;EACrEC,QAAQ;EACRC,MAAM;EACNC,aAAa;EACbC,MAAM,EAAEC;AACa,CAAC,KAAgD;EACtE,MAAMD,MAAM,GAAGX,OAAO,CAAC,MAAMJ,yBAAyB,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8E,aAAA,CAACxE,aAAa,QAAEK,QAAwB,CACX,CAAC;AAEpC,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","names":["FoundryHostEventTarget","React","useContext","FoundryWidgetContext","createContext","emitEvent","hostEventTarget","asyncParameterValues","parameters","state","values","useFoundryWidgetContext","_useFoundryWidgetContext","withTypes"],"sources":["context.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software=\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ObjectSet } from \"@osdk/client\";\nimport type {\n AllowedObjectSetParameterType,\n EventId,\n EventParameterValueMap,\n WidgetMessage,\n} from \"@osdk/widget.api\";\nimport {\n type AsyncParameterValueMap,\n type AsyncValue,\n FoundryHostEventTarget,\n type ParameterConfig,\n type ParameterValueMap,\n type WidgetConfig,\n} from \"@osdk/widget.client\";\nimport React, { useContext } from \"react\";\n\nexport type AugmentedEventParameterValueMap<\n C extends WidgetConfig<C[\"parameters\"]>,\n K extends EventId<C>,\n> = {\n [P in keyof EventParameterValueMap<C, K>]: P extends keyof C[\"parameters\"]\n ? C[\"parameters\"][P] extends { type: \"objectSet\"; allowedType: infer T }\n ? T extends AllowedObjectSetParameterType ? ObjectSet<T>\n : EventParameterValueMap<C, K>[P]\n : EventParameterValueMap<C, K>[P]\n : EventParameterValueMap<C, K>[P];\n};\n\ntype AugmentedEmitEventIdMap<C extends WidgetConfig<C[\"parameters\"]>> = {\n [K in EventId<C>]: {\n eventId: K;\n parameterUpdates: AugmentedEventParameterValueMap<C, K>;\n };\n};\n\ninterface AugmentedWidgetEmitEvent<C extends WidgetConfig<C[\"parameters\"]>>\n extends Omit<WidgetMessage.EmitEvent<C>, \"payload\">\n{\n payload: AugmentedEmitEventIdMap<C>[EventId<C>];\n}\n\n/**\n * Emits a widget event with parameter updates to the host Foundry UI.\n *\n * For object set parameters, pass `ObjectSet<T>` directly.\n * If the same event is emitted multiple times in quick succession and involves Object Set parameters, only the last call will be sent.\n * Errors (e.g., network failures when serializing ObjectSet parameters) are not surfaced to the caller.\n */\nexport type AugmentedEmitEvent<C extends WidgetConfig<C[\"parameters\"]>> = <\n M extends AugmentedWidgetEmitEvent<C>,\n ID extends M[\"payload\"][\"eventId\"],\n>(\n eventId: ID,\n payload: Omit<Extract<M[\"payload\"], { eventId: ID }>, \"eventId\">,\n) => void;\n\nexport interface FoundryWidgetClientContext<\n C extends WidgetConfig<C[\"parameters\"]>,\n> {\n /**\n * Emits a widget event with parameter updates to the host Foundry UI.\n *\n * - For ObjectSet parameters, pass `ObjectSet<T>` directly\n * - If the same event is emitted multiple times rapidly and involves Object Set parameters, only the last call is sent\n * - Errors are not surfaced to the caller\n */\n emitEvent: AugmentedEmitEvent<C>;\n hostEventTarget: FoundryHostEventTarget<C>;\n\n /**\n * Object where the individual parameters have their async state represented\n */\n asyncParameterValues: ExtendedAsyncParameterValueMap<C>;\n\n /**\n * Convenience object that aggregates the value of all parameters, accounting for their loading states\n */\n parameters: {\n values: Partial<ExtendedParameterValueMap<C>>;\n state: AsyncValue<ParameterValueMap<C>>[\"type\"];\n };\n}\n\nexport type ExtendedParameterValueMap<C extends WidgetConfig<C[\"parameters\"]>> =\n {\n [K in keyof C[\"parameters\"]]: K extends keyof ParameterValueMap<C>\n ? C[\"parameters\"][K] extends { type: \"objectSet\"; allowedType: infer T }\n ? T extends AllowedObjectSetParameterType\n ? ParameterValueMap<C>[K] & { objectSet: ObjectSet<T> }\n : ParameterValueMap<C>[K]\n : ParameterValueMap<C>[K]\n : never;\n };\n\nexport type ExtendedAsyncParameterValueMap<\n C extends WidgetConfig<C[\"parameters\"]>,\n> = {\n [K in keyof C[\"parameters\"]]: K extends keyof AsyncParameterValueMap<C>\n ? C[\"parameters\"][K] extends { type: \"objectSet\"; allowedType: infer T }\n ? T extends AllowedObjectSetParameterType\n ? AsyncParameterValueMap<C>[K] & {\n value: AsyncValue<\n ParameterValueMap<C>[K] & { objectSet: ObjectSet<T> }\n >;\n }\n : AsyncParameterValueMap<C>[K]\n : AsyncParameterValueMap<C>[K]\n : never;\n};\n\nexport const FoundryWidgetContext: React.Context<\n FoundryWidgetClientContext<WidgetConfig<ParameterConfig>>\n> = React.createContext<\n FoundryWidgetClientContext<WidgetConfig<ParameterConfig>>\n>({\n emitEvent: () => {},\n hostEventTarget: new FoundryHostEventTarget<WidgetConfig<ParameterConfig>>(),\n asyncParameterValues: {},\n parameters: {\n state: \"not-started\",\n values: {},\n },\n});\n\n/**\n * @returns The current FoundryWidgetClientContext, in the context of your specific parameter configuration\n */\nexport function useFoundryWidgetContext<\n C extends WidgetConfig<C[\"parameters\"]>,\n>(): FoundryWidgetClientContext<C> {\n return useContext(FoundryWidgetContext) as FoundryWidgetClientContext<C>;\n}\n\nexport namespace useFoundryWidgetContext {\n export function withTypes<\n C extends WidgetConfig<C[\"parameters\"]>,\n >(): () => FoundryWidgetClientContext<C> {\n return () => {\n return useFoundryWidgetContext<C>();\n };\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,SAGEA,sBAAsB,QAIjB,qBAAqB;AAC5B,OAAOC,KAAK,IAAIC,UAAU,QAAQ,OAAO;;AA2BzC;AACA;AACA;AACA;AACA;AACA;AACA;;AA+DA,OAAO,MAAMC,oBAEZ,gBAAGF,KAAK,CAACG,aAAa,CAErB;EACAC,SAAS,EAAEA,CAAA,KAAM,CAAC,CAAC;EACnBC,eAAe,EAAE,IAAIN,sBAAsB,CAAgC,CAAC;EAC5EO,oBAAoB,EAAE,CAAC,CAAC;EACxBC,UAAU,EAAE;IACVC,KAAK,EAAE,aAAa;IACpBC,MAAM,EAAE,CAAC;EACX;AACF,CAAC,CAAC;;AAEF;AACA;AACA;AACA,OAAO,SAASC,uBAAuBA,CAAA,EAEJ;EACjC,OAAOT,UAAU,CAACC,oBAAoB,CAAC;AACzC;AAAC,WAAAS,wBAAA;EAAAA,wBAAA,CAAAC,SAAA,GAGQ,YAEkC;IACvC,OAAO,MAAM;MACX,OAAOF,uBAAuB,CAAI,CAAC;IACrC,CAAC;EACH,CAAC;AAAA,GAPcA,uBAAuB,KAAvBA,uBAAuB","ignoreList":[]}
1
+ {"version":3,"file":"context.js","names":["FoundryHostEventTarget","React","useContext","FoundryWidgetContext","createContext","emitEvent","hostEventTarget","asyncParameterValues","parameters","state","values","useFoundryWidgetContext","_useFoundryWidgetContext","withTypes"],"sources":["context.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software=\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ObjectSet } from \"@osdk/client\";\nimport type {\n AllowedObjectSetParameterType,\n EventId,\n EventParameterValueMap,\n WidgetMessage,\n} from \"@osdk/widget.api\";\nimport {\n type AsyncParameterValueMap,\n type AsyncValue,\n FoundryHostEventTarget,\n type ParameterConfig,\n type ParameterValueMap,\n type WidgetConfig,\n} from \"@osdk/widget.client\";\nimport React, { useContext } from \"react\";\n\nexport type AugmentedEventParameterValueMap<\n C extends WidgetConfig<C[\"parameters\"]>,\n K extends EventId<C>,\n> = {\n [P in keyof EventParameterValueMap<C, K>]: P extends keyof C[\"parameters\"]\n ? C[\"parameters\"][P] extends { type: \"objectSet\"; allowedType: infer T }\n ? T extends AllowedObjectSetParameterType\n ? ObjectSet<T>\n : EventParameterValueMap<C, K>[P]\n : EventParameterValueMap<C, K>[P]\n : EventParameterValueMap<C, K>[P];\n};\n\ntype AugmentedEmitEventIdMap<C extends WidgetConfig<C[\"parameters\"]>> = {\n [K in EventId<C>]: {\n eventId: K;\n parameterUpdates: AugmentedEventParameterValueMap<C, K>;\n };\n};\n\ninterface AugmentedWidgetEmitEvent<\n C extends WidgetConfig<C[\"parameters\"]>,\n> extends Omit<WidgetMessage.EmitEvent<C>, \"payload\"> {\n payload: AugmentedEmitEventIdMap<C>[EventId<C>];\n}\n\n/**\n * Emits a widget event with parameter updates to the host Foundry UI.\n *\n * For object set parameters, pass `ObjectSet<T>` directly.\n * If the same event is emitted multiple times in quick succession and involves Object Set parameters, only the last call will be sent.\n * Errors (e.g., network failures when serializing ObjectSet parameters) are not surfaced to the caller.\n */\nexport type AugmentedEmitEvent<C extends WidgetConfig<C[\"parameters\"]>> = <\n M extends AugmentedWidgetEmitEvent<C>,\n ID extends M[\"payload\"][\"eventId\"],\n>(\n eventId: ID,\n payload: Omit<Extract<M[\"payload\"], { eventId: ID }>, \"eventId\">\n) => void;\n\nexport interface FoundryWidgetClientContext<\n C extends WidgetConfig<C[\"parameters\"]>,\n> {\n /**\n * Emits a widget event with parameter updates to the host Foundry UI.\n *\n * - For ObjectSet parameters, pass `ObjectSet<T>` directly\n * - If the same event is emitted multiple times rapidly and involves Object Set parameters, only the last call is sent\n * - Errors are not surfaced to the caller\n */\n emitEvent: AugmentedEmitEvent<C>;\n hostEventTarget: FoundryHostEventTarget<C>;\n\n /**\n * Object where the individual parameters have their async state represented\n */\n asyncParameterValues: ExtendedAsyncParameterValueMap<C>;\n\n /**\n * Convenience object that aggregates the value of all parameters, accounting for their loading states\n */\n parameters: {\n values: Partial<ExtendedParameterValueMap<C>>;\n state: AsyncValue<ParameterValueMap<C>>[\"type\"];\n };\n}\n\nexport type ExtendedParameterValueMap<C extends WidgetConfig<C[\"parameters\"]>> =\n {\n [K in keyof C[\"parameters\"]]: K extends keyof ParameterValueMap<C>\n ? C[\"parameters\"][K] extends { type: \"objectSet\"; allowedType: infer T }\n ? T extends AllowedObjectSetParameterType\n ? ParameterValueMap<C>[K] & { objectSet: ObjectSet<T> }\n : ParameterValueMap<C>[K]\n : ParameterValueMap<C>[K]\n : never;\n };\n\nexport type ExtendedAsyncParameterValueMap<\n C extends WidgetConfig<C[\"parameters\"]>,\n> = {\n [K in keyof C[\"parameters\"]]: K extends keyof AsyncParameterValueMap<C>\n ? C[\"parameters\"][K] extends { type: \"objectSet\"; allowedType: infer T }\n ? T extends AllowedObjectSetParameterType\n ? AsyncParameterValueMap<C>[K] & {\n value: AsyncValue<\n ParameterValueMap<C>[K] & { objectSet: ObjectSet<T> }\n >;\n }\n : AsyncParameterValueMap<C>[K]\n : AsyncParameterValueMap<C>[K]\n : never;\n};\n\nexport const FoundryWidgetContext: React.Context<\n FoundryWidgetClientContext<WidgetConfig<ParameterConfig>>\n> = React.createContext<\n FoundryWidgetClientContext<WidgetConfig<ParameterConfig>>\n>({\n emitEvent: () => {},\n hostEventTarget: new FoundryHostEventTarget<WidgetConfig<ParameterConfig>>(),\n asyncParameterValues: {},\n parameters: {\n state: \"not-started\",\n values: {},\n },\n});\n\n/**\n * @returns The current FoundryWidgetClientContext, in the context of your specific parameter configuration\n */\nexport function useFoundryWidgetContext<\n C extends WidgetConfig<C[\"parameters\"]>,\n>(): FoundryWidgetClientContext<C> {\n return useContext(FoundryWidgetContext) as FoundryWidgetClientContext<C>;\n}\n\nexport namespace useFoundryWidgetContext {\n export function withTypes<\n C extends WidgetConfig<C[\"parameters\"]>,\n >(): () => FoundryWidgetClientContext<C> {\n return () => {\n return useFoundryWidgetContext<C>();\n };\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,SAGEA,sBAAsB,QAIjB,qBAAqB;AAC5B,OAAOC,KAAK,IAAIC,UAAU,QAAQ,OAAO;;AA4BzC;AACA;AACA;AACA;AACA;AACA;AACA;;AA+DA,OAAO,MAAMC,oBAEZ,gBAAGF,KAAK,CAACG,aAAa,CAErB;EACAC,SAAS,EAAEA,CAAA,KAAM,CAAC,CAAC;EACnBC,eAAe,EAAE,IAAIN,sBAAsB,CAAgC,CAAC;EAC5EO,oBAAoB,EAAE,CAAC,CAAC;EACxBC,UAAU,EAAE;IACVC,KAAK,EAAE,aAAa;IACpBC,MAAM,EAAE,CAAC;EACX;AACF,CAAC,CAAC;;AAEF;AACA;AACA;AACA,OAAO,SAASC,uBAAuBA,CAAA,EAEJ;EACjC,OAAOT,UAAU,CAACC,oBAAoB,CAAC;AACzC;AAAC,WAAAS,wBAAA;EAAAA,wBAAA,CAAAC,SAAA,GAGQ,YAEkC;IACvC,OAAO,MAAM;MACX,OAAOF,uBAAuB,CAAI,CAAC;IACrC,CAAC;EACH,CAAC;AAAA,GAPcA,uBAAuB,KAAvBA,uBAAuB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"extendParametersWithObjectSets.js","names":["hydrateObjectSetFromRid","extendParametersWithObjectSets","osdkClient","config","parameters","cache","extendedParameters","parameterId","Object","keys","param","type","parameterValue","value","objectSetRid","objectSet","getOrHydrateObjectSet","allowedType","Error","delete","paramKey","definition","cached","get","set"],"sources":["extendParametersWithObjectSets.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Client, ObjectSet } from \"@osdk/client\";\nimport { hydrateObjectSetFromRid } from \"@osdk/client/internal\";\nimport type {\n AllowedObjectSetParameterType,\n AsyncParameterValueMap,\n WidgetConfig,\n} from \"@osdk/widget.api\";\nimport type { ExtendedAsyncParameterValueMap } from \"../context.js\";\n\n/**\n * Patches parameter values with hydrated object sets for object set parameters.\n *\n * The cache is used to avoid redundant hydration of the same object set RID, which\n * can cause unnecessary re-renders in React components consuming the parameters.\n */\nexport function extendParametersWithObjectSets<\n C extends WidgetConfig<C[\"parameters\"]>,\n>(\n osdkClient: Client | undefined,\n config: C,\n parameters: AsyncParameterValueMap<C>,\n cache: Map<string, { objectSetRid: string; objectSet: ObjectSet }>,\n): ExtendedAsyncParameterValueMap<C> {\n const extendedParameters = {\n ...parameters,\n } as ExtendedAsyncParameterValueMap<C>;\n\n for (const parameterId of Object.keys(extendedParameters)) {\n const param = config.parameters[parameterId];\n if (\n param.type === \"objectSet\"\n && extendedParameters[parameterId].type === \"objectSet\"\n ) {\n const parameterValue = extendedParameters[parameterId].value.value;\n if (parameterValue != null) {\n if (\n typeof parameterValue === \"object\"\n && \"objectSetRid\" in parameterValue\n && typeof parameterValue.objectSetRid === \"string\"\n ) {\n const objectSetRid = parameterValue.objectSetRid;\n const objectSet = getOrHydrateObjectSet(\n osdkClient,\n cache,\n parameterId,\n objectSetRid,\n param.allowedType,\n );\n (parameterValue as any).objectSet = objectSet;\n } else {\n throw new Error(\n `Invalid object set parameter value for parameter \"${parameterId}\"`,\n );\n }\n } else {\n cache.delete(parameterId);\n }\n }\n }\n\n return extendedParameters;\n}\n\nfunction getOrHydrateObjectSet<T extends AllowedObjectSetParameterType>(\n osdkClient: Client | undefined,\n cache: Map<string, { objectSetRid: string; objectSet: ObjectSet<T> }>,\n paramKey: string,\n objectSetRid: string,\n definition: T,\n) {\n if (osdkClient == null) {\n throw new Error(\"Not provided an OSDK client\");\n }\n const cached = cache.get(paramKey);\n if (cached?.objectSetRid === objectSetRid) {\n return cached.objectSet;\n }\n const objectSet = hydrateObjectSetFromRid(\n osdkClient,\n definition,\n objectSetRid,\n );\n cache.set(paramKey, { objectSetRid, objectSet });\n return objectSet;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,uBAAuB,QAAQ,uBAAuB;AAQ/D;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,8BAA8BA,CAG5CC,UAA8B,EAC9BC,MAAS,EACTC,UAAqC,EACrCC,KAAkE,EAC/B;EACnC,MAAMC,kBAAkB,GAAG;IACzB,GAAGF;EACL,CAAsC;EAEtC,KAAK,MAAMG,WAAW,IAAIC,MAAM,CAACC,IAAI,CAACH,kBAAkB,CAAC,EAAE;IACzD,MAAMI,KAAK,GAAGP,MAAM,CAACC,UAAU,CAACG,WAAW,CAAC;IAC5C,IACEG,KAAK,CAACC,IAAI,KAAK,WAAW,IACvBL,kBAAkB,CAACC,WAAW,CAAC,CAACI,IAAI,KAAK,WAAW,EACvD;MACA,MAAMC,cAAc,GAAGN,kBAAkB,CAACC,WAAW,CAAC,CAACM,KAAK,CAACA,KAAK;MAClE,IAAID,cAAc,IAAI,IAAI,EAAE;QAC1B,IACE,OAAOA,cAAc,KAAK,QAAQ,IAC/B,cAAc,IAAIA,cAAc,IAChC,OAAOA,cAAc,CAACE,YAAY,KAAK,QAAQ,EAClD;UACA,MAAMA,YAAY,GAAGF,cAAc,CAACE,YAAY;UAChD,MAAMC,SAAS,GAAGC,qBAAqB,CACrCd,UAAU,EACVG,KAAK,EACLE,WAAW,EACXO,YAAY,EACZJ,KAAK,CAACO,WACR,CAAC;UACAL,cAAc,CAASG,SAAS,GAAGA,SAAS;QAC/C,CAAC,MAAM;UACL,MAAM,IAAIG,KAAK,CACb,qDAAqDX,WAAW,GAClE,CAAC;QACH;MACF,CAAC,MAAM;QACLF,KAAK,CAACc,MAAM,CAACZ,WAAW,CAAC;MAC3B;IACF;EACF;EAEA,OAAOD,kBAAkB;AAC3B;AAEA,SAASU,qBAAqBA,CAC5Bd,UAA8B,EAC9BG,KAAqE,EACrEe,QAAgB,EAChBN,YAAoB,EACpBO,UAAa,EACb;EACA,IAAInB,UAAU,IAAI,IAAI,EAAE;IACtB,MAAM,IAAIgB,KAAK,CAAC,6BAA6B,CAAC;EAChD;EACA,MAAMI,MAAM,GAAGjB,KAAK,CAACkB,GAAG,CAACH,QAAQ,CAAC;EAClC,IAAIE,MAAM,EAAER,YAAY,KAAKA,YAAY,EAAE;IACzC,OAAOQ,MAAM,CAACP,SAAS;EACzB;EACA,MAAMA,SAAS,GAAGf,uBAAuB,CACvCE,UAAU,EACVmB,UAAU,EACVP,YACF,CAAC;EACDT,KAAK,CAACmB,GAAG,CAACJ,QAAQ,EAAE;IAAEN,YAAY;IAAEC;EAAU,CAAC,CAAC;EAChD,OAAOA,SAAS;AAClB","ignoreList":[]}
1
+ {"version":3,"file":"extendParametersWithObjectSets.js","names":["hydrateObjectSetFromRid","extendParametersWithObjectSets","osdkClient","config","parameters","cache","extendedParameters","parameterId","Object","keys","param","type","parameterValue","value","objectSetRid","objectSet","getOrHydrateObjectSet","allowedType","Error","delete","paramKey","definition","cached","get","set"],"sources":["extendParametersWithObjectSets.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Client, ObjectSet } from \"@osdk/client\";\nimport { hydrateObjectSetFromRid } from \"@osdk/client/internal\";\nimport type {\n AllowedObjectSetParameterType,\n AsyncParameterValueMap,\n WidgetConfig,\n} from \"@osdk/widget.api\";\n\nimport type { ExtendedAsyncParameterValueMap } from \"../context.js\";\n\n/**\n * Patches parameter values with hydrated object sets for object set parameters.\n *\n * The cache is used to avoid redundant hydration of the same object set RID, which\n * can cause unnecessary re-renders in React components consuming the parameters.\n */\nexport function extendParametersWithObjectSets<\n C extends WidgetConfig<C[\"parameters\"]>,\n>(\n osdkClient: Client | undefined,\n config: C,\n parameters: AsyncParameterValueMap<C>,\n cache: Map<string, { objectSetRid: string; objectSet: ObjectSet }>\n): ExtendedAsyncParameterValueMap<C> {\n const extendedParameters = {\n ...parameters,\n } as ExtendedAsyncParameterValueMap<C>;\n\n for (const parameterId of Object.keys(extendedParameters)) {\n const param = config.parameters[parameterId];\n if (\n param.type === \"objectSet\" &&\n extendedParameters[parameterId].type === \"objectSet\"\n ) {\n const parameterValue = extendedParameters[parameterId].value.value;\n if (parameterValue != null) {\n if (\n typeof parameterValue === \"object\" &&\n \"objectSetRid\" in parameterValue &&\n typeof parameterValue.objectSetRid === \"string\"\n ) {\n const objectSetRid = parameterValue.objectSetRid;\n const objectSet = getOrHydrateObjectSet(\n osdkClient,\n cache,\n parameterId,\n objectSetRid,\n param.allowedType\n );\n (parameterValue as any).objectSet = objectSet;\n } else {\n throw new Error(\n `Invalid object set parameter value for parameter \"${parameterId}\"`\n );\n }\n } else {\n cache.delete(parameterId);\n }\n }\n }\n\n return extendedParameters;\n}\n\nfunction getOrHydrateObjectSet<T extends AllowedObjectSetParameterType>(\n osdkClient: Client | undefined,\n cache: Map<string, { objectSetRid: string; objectSet: ObjectSet<T> }>,\n paramKey: string,\n objectSetRid: string,\n definition: T\n) {\n if (osdkClient == null) {\n throw new Error(\"Not provided an OSDK client\");\n }\n const cached = cache.get(paramKey);\n if (cached?.objectSetRid === objectSetRid) {\n return cached.objectSet;\n }\n const objectSet = hydrateObjectSetFromRid(\n osdkClient,\n definition,\n objectSetRid\n );\n cache.set(paramKey, { objectSetRid, objectSet });\n return objectSet;\n}\n"],"mappings":"AAAA;AACA;AACA;A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,IAAInB,UAAU,IAAI,IAAI,EAAE;IACtB,MAAM,IAAIgB,KAAK,CAAC,6BAA6B,CAAC;EAChD;EACA,MAAMI,MAAM,GAAGjB,KAAK,CAACkB,GAAG,CAACH,QAAQ,CAAC;EAClC,IAAIE,MAAM,EAAER,YAAY,KAAKA,YAAY,EAAE;IACzC,OAAOQ,MAAM,CAACP,SAAS;EACzB;EACA,MAAMA,SAAS,GAAGf,uBAAuB,CACvCE,UAAU,EACVmB,UAAU,EACVP,YACF,CAAC;EACDT,KAAK,CAACmB,GAAG,CAACJ,QAAQ,EAAE;IAAEN,YAAY;IAAEC;EAAU,CAAC,CAAC;EAChD,OAAOA,SAAS;AAClB","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"initializeParameters.js","names":["initializeParameters","config","initialLoadingState","Object","fromEntries","entries","parameters","map","key","parameterConfig","type","value"],"sources":["initializeParameters.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { WidgetConfig } from \"@osdk/widget.client\";\nimport type { ExtendedAsyncParameterValueMap } from \"../context.js\";\n\n/**\n * Utility function to initialize a map of parameter values to either a loading or not-started loading state\n */\nexport function initializeParameters<C extends WidgetConfig<C[\"parameters\"]>>(\n config: C,\n initialLoadingState: \"loading\" | \"not-started\",\n): ExtendedAsyncParameterValueMap<C> {\n return Object.fromEntries(\n Object.entries(config.parameters).map(([key, parameterConfig]) => [\n key,\n { type: parameterConfig.type, value: { type: initialLoadingState } },\n ]),\n ) as ExtendedAsyncParameterValueMap<C>;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA,OAAO,SAASA,oBAAoBA,CAClCC,MAAS,EACTC,mBAA8C,EACX;EACnC,OAAOC,MAAM,CAACC,WAAW,CACvBD,MAAM,CAACE,OAAO,CAACJ,MAAM,CAACK,UAAU,CAAC,CAACC,GAAG,CAAC,CAAC,CAACC,GAAG,EAAEC,eAAe,CAAC,KAAK,CAChED,GAAG,EACH;IAAEE,IAAI,EAAED,eAAe,CAACC,IAAI;IAAEC,KAAK,EAAE;MAAED,IAAI,EAAER;IAAoB;EAAE,CAAC,CACrE,CACH,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"initializeParameters.js","names":["initializeParameters","config","initialLoadingState","Object","fromEntries","entries","parameters","map","key","parameterConfig","type","value"],"sources":["initializeParameters.ts"],"sourcesContent":["/*\n * Copyright 2024 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { WidgetConfig } from \"@osdk/widget.client\";\n\nimport type { ExtendedAsyncParameterValueMap } from \"../context.js\";\n\n/**\n * Utility function to initialize a map of parameter values to either a loading or not-started loading state\n */\nexport function initializeParameters<C extends WidgetConfig<C[\"parameters\"]>>(\n config: C,\n initialLoadingState: \"loading\" | \"not-started\"\n): ExtendedAsyncParameterValueMap<C> {\n return Object.fromEntries(\n Object.entries(config.parameters).map(([key, parameterConfig]) => [\n key,\n { type: parameterConfig.type, value: { type: initialLoadingState } },\n ])\n ) as ExtendedAsyncParameterValueMap<C>;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA,OAAO,SAASA,oBAAoBA,CAClCC,MAAS,EACTC,mBAA8C,EACX;EACnC,OAAOC,MAAM,CAACC,WAAW,CACvBD,MAAM,CAACE,OAAO,CAACJ,MAAM,CAACK,UAAU,CAAC,CAACC,GAAG,CAAC,CAAC,CAACC,GAAG,EAAEC,eAAe,CAAC,KAAK,CAChED,GAAG,EACH;IAAEE,IAAI,EAAED,eAAe,CAACC,IAAI;IAAEC,KAAK,EAAE;MAAED,IAAI,EAAER;IAAoB;EAAE,CAAC,CACrE,CACH,CAAC;AACH","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"transformEmitEventPayload.js","names":["createAndFetchTempObjectSetRid","transformEmitEventPayload","config","eventId","payload","osdkClient","paramId","Object","keys","parameterUpdates","paramConfig","parameters","type","transformEmitEventPayloadAsync","event","events","Error","toString","entries","transformedEntries","Promise","all","map","paramValue","objectSetRid","fromEntries"],"sources":["transformEmitEventPayload.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Client, ObjectSet } from \"@osdk/client\";\nimport { createAndFetchTempObjectSetRid } from \"@osdk/client/internal\";\nimport type {\n AsyncValue,\n EventId,\n EventParameterValueMap,\n ParameterValue,\n} from \"@osdk/widget.api\";\nimport type { WidgetConfig } from \"@osdk/widget.client\";\nimport type { AugmentedEventParameterValueMap } from \"../context.js\";\n\ntype ObjectSetEmitEventPayload = ParameterValue.ObjectSet[\"value\"] extends\n AsyncValue<infer T> ? T : never;\n\ntype TransformedEmitEventPayload<\n C extends WidgetConfig<C[\"parameters\"]>,\n K extends EventId<C>,\n> = {\n parameterUpdates: EventParameterValueMap<C, K>;\n};\n\ntype TransformedEmitEventPayloadResult<\n C extends WidgetConfig<C[\"parameters\"]>,\n K extends EventId<C>,\n> = {\n type: \"async\";\n payload: Promise<TransformedEmitEventPayload<C, K>>;\n} | {\n type: \"passThrough\";\n payload: TransformedEmitEventPayload<C, K>;\n};\n\nexport function transformEmitEventPayload<\n C extends WidgetConfig<C[\"parameters\"]>,\n K extends EventId<C>,\n>(\n config: C,\n eventId: K,\n payload: { parameterUpdates: AugmentedEventParameterValueMap<C, K> },\n osdkClient?: Client,\n): TransformedEmitEventPayloadResult<C, K> {\n for (const paramId of Object.keys(payload.parameterUpdates)) {\n const paramConfig = config.parameters[paramId];\n if (paramConfig?.type === \"objectSet\") {\n return {\n type: \"async\",\n payload: transformEmitEventPayloadAsync(\n config,\n eventId,\n payload,\n osdkClient,\n ),\n };\n }\n }\n\n // No object set parameters, pass through synchronously\n return {\n type: \"passThrough\",\n payload: {\n parameterUpdates: payload.parameterUpdates as EventParameterValueMap<\n C,\n K\n >,\n },\n };\n}\n\n/**\n * Transforms an augmented emit event payload by creating temporary object sets\n * from ObjectSet instances.\n *\n * Multiple ObjectSet parameters are transformed in parallel for better performance.\n */\nexport async function transformEmitEventPayloadAsync<\n C extends WidgetConfig<C[\"parameters\"]>,\n K extends EventId<C>,\n>(\n config: C,\n eventId: K,\n payload: { parameterUpdates: AugmentedEventParameterValueMap<C, K> },\n osdkClient?: Client,\n): Promise<{ parameterUpdates: EventParameterValueMap<C, K> }> {\n const event = config.events[eventId as string];\n if (event == null) {\n throw new Error(\n `Event with ID \"${eventId.toString()}\" not found in widget config`,\n );\n }\n\n const entries = Object.entries(payload.parameterUpdates);\n\n const transformedEntries = await Promise.all(\n entries.map(async ([paramId, paramValue]): Promise<[string, unknown]> => {\n const paramConfig = config.parameters[paramId];\n if (paramConfig?.type === \"objectSet\") {\n if (osdkClient == null) {\n throw new Error(\n `Cannot emit event \"${eventId.toString()}\" with ObjectSet parameter \"${paramId}\" without an osdk client`,\n );\n }\n const objectSetRid = await createAndFetchTempObjectSetRid(\n osdkClient,\n paramValue as ObjectSet,\n );\n return [paramId, { objectSetRid } satisfies ObjectSetEmitEventPayload];\n }\n return [paramId, paramValue];\n }),\n );\n\n return {\n parameterUpdates: Object.fromEntries(\n transformedEntries,\n ) as EventParameterValueMap<C, K>,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,8BAA8B,QAAQ,uBAAuB;AA+BtE,OAAO,SAASC,yBAAyBA,CAIvCC,MAAS,EACTC,OAAU,EACVC,OAAoE,EACpEC,UAAmB,EACsB;EACzC,KAAK,MAAMC,OAAO,IAAIC,MAAM,CAACC,IAAI,CAACJ,OAAO,CAACK,gBAAgB,CAAC,EAAE;IAC3D,MAAMC,WAAW,GAAGR,MAAM,CAACS,UAAU,CAACL,OAAO,CAAC;IAC9C,IAAII,WAAW,EAAEE,IAAI,KAAK,WAAW,EAAE;MACrC,OAAO;QACLA,IAAI,EAAE,OAAO;QACbR,OAAO,EAAES,8BAA8B,CACrCX,MAAM,EACNC,OAAO,EACPC,OAAO,EACPC,UACF;MACF,CAAC;IACH;EACF;;EAEA;EACA,OAAO;IACLO,IAAI,EAAE,aAAa;IACnBR,OAAO,EAAE;MACPK,gBAAgB,EAAEL,OAAO,CAACK;IAI5B;EACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeI,8BAA8BA,CAIlDX,MAAS,EACTC,OAAU,EACVC,OAAoE,EACpEC,UAAmB,EAC0C;EAC7D,MAAMS,KAAK,GAAGZ,MAAM,CAACa,MAAM,CAACZ,OAAO,CAAW;EAC9C,IAAIW,KAAK,IAAI,IAAI,EAAE;IACjB,MAAM,IAAIE,KAAK,CACb,kBAAkBb,OAAO,CAACc,QAAQ,CAAC,CAAC,8BACtC,CAAC;EACH;EAEA,MAAMC,OAAO,GAAGX,MAAM,CAACW,OAAO,CAACd,OAAO,CAACK,gBAAgB,CAAC;EAExD,MAAMU,kBAAkB,GAAG,MAAMC,OAAO,CAACC,GAAG,CAC1CH,OAAO,CAACI,GAAG,CAAC,OAAO,CAAChB,OAAO,EAAEiB,UAAU,CAAC,KAAiC;IACvE,MAAMb,WAAW,GAAGR,MAAM,CAACS,UAAU,CAACL,OAAO,CAAC;IAC9C,IAAII,WAAW,EAAEE,IAAI,KAAK,WAAW,EAAE;MACrC,IAAIP,UAAU,IAAI,IAAI,EAAE;QACtB,MAAM,IAAIW,KAAK,CACb,sBAAsBb,OAAO,CAACc,QAAQ,CAAC,CAAC,+BAA+BX,OAAO,0BAChF,CAAC;MACH;MACA,MAAMkB,YAAY,GAAG,MAAMxB,8BAA8B,CACvDK,UAAU,EACVkB,UACF,CAAC;MACD,OAAO,CAACjB,OAAO,EAAE;QAAEkB;MAAa,CAAC,CAAqC;IACxE;IACA,OAAO,CAAClB,OAAO,EAAEiB,UAAU,CAAC;EAC9B,CAAC,CACH,CAAC;EAED,OAAO;IACLd,gBAAgB,EAAEF,MAAM,CAACkB,WAAW,CAClCN,kBACF;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"transformEmitEventPayload.js","names":["createAndFetchTempObjectSetRid","transformEmitEventPayload","config","eventId","payload","osdkClient","paramId","Object","keys","parameterUpdates","paramConfig","parameters","type","transformEmitEventPayloadAsync","event","events","Error","toString","entries","transformedEntries","Promise","all","map","paramValue","objectSetRid","fromEntries"],"sources":["transformEmitEventPayload.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Client, ObjectSet } from \"@osdk/client\";\nimport { createAndFetchTempObjectSetRid } from \"@osdk/client/internal\";\nimport type {\n AsyncValue,\n EventId,\n EventParameterValueMap,\n ParameterValue,\n} from \"@osdk/widget.api\";\nimport type { WidgetConfig } from \"@osdk/widget.client\";\n\nimport type { AugmentedEventParameterValueMap } from \"../context.js\";\n\ntype ObjectSetEmitEventPayload =\n ParameterValue.ObjectSet[\"value\"] extends AsyncValue<infer T> ? T : never;\n\ntype TransformedEmitEventPayload<\n C extends WidgetConfig<C[\"parameters\"]>,\n K extends EventId<C>,\n> = {\n parameterUpdates: EventParameterValueMap<C, K>;\n};\n\ntype TransformedEmitEventPayloadResult<\n C extends WidgetConfig<C[\"parameters\"]>,\n K extends EventId<C>,\n> =\n | {\n type: \"async\";\n payload: Promise<TransformedEmitEventPayload<C, K>>;\n }\n | {\n type: \"passThrough\";\n payload: TransformedEmitEventPayload<C, K>;\n };\n\nexport function transformEmitEventPayload<\n C extends WidgetConfig<C[\"parameters\"]>,\n K extends EventId<C>,\n>(\n config: C,\n eventId: K,\n payload: { parameterUpdates: AugmentedEventParameterValueMap<C, K> },\n osdkClient?: Client\n): TransformedEmitEventPayloadResult<C, K> {\n for (const paramId of Object.keys(payload.parameterUpdates)) {\n const paramConfig = config.parameters[paramId];\n if (paramConfig?.type === \"objectSet\") {\n return {\n type: \"async\",\n payload: transformEmitEventPayloadAsync(\n config,\n eventId,\n payload,\n osdkClient\n ),\n };\n }\n }\n\n // No object set parameters, pass through synchronously\n return {\n type: \"passThrough\",\n payload: {\n parameterUpdates: payload.parameterUpdates as EventParameterValueMap<\n C,\n K\n >,\n },\n };\n}\n\n/**\n * Transforms an augmented emit event payload by creating temporary object sets\n * from ObjectSet instances.\n *\n * Multiple ObjectSet parameters are transformed in parallel for better performance.\n */\nexport async function transformEmitEventPayloadAsync<\n C extends WidgetConfig<C[\"parameters\"]>,\n K extends EventId<C>,\n>(\n config: C,\n eventId: K,\n payload: { parameterUpdates: AugmentedEventParameterValueMap<C, K> },\n osdkClient?: Client\n): Promise<{ parameterUpdates: EventParameterValueMap<C, K> }> {\n const event = config.events[eventId as string];\n if (event == null) {\n throw new Error(\n `Event with ID \"${eventId.toString()}\" not found in widget config`\n );\n }\n\n const entries = Object.entries(payload.parameterUpdates);\n\n const transformedEntries = await Promise.all(\n entries.map(async ([paramId, paramValue]): Promise<[string, unknown]> => {\n const paramConfig = config.parameters[paramId];\n if (paramConfig?.type === \"objectSet\") {\n if (osdkClient == null) {\n throw new Error(\n `Cannot emit event \"${eventId.toString()}\" with ObjectSet parameter \"${paramId}\" without an osdk client`\n );\n }\n const objectSetRid = await createAndFetchTempObjectSetRid(\n osdkClient,\n paramValue as ObjectSet\n );\n return [paramId, { objectSetRid } satisfies ObjectSetEmitEventPayload];\n }\n return [paramId, paramValue];\n })\n );\n\n return {\n parameterUpdates: Object.fromEntries(\n transformedEntries\n ) as EventParameterValueMap<C, K>,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,8BAA8B,QAAQ,uBAAuB;AAkCtE,OAAO,SAASC,yBAAyBA,CAIvCC,MAAS,EACTC,OAAU,EACVC,OAAoE,EACpEC,UAAmB,EACsB;EACzC,KAAK,MAAMC,OAAO,IAAIC,MAAM,CAACC,IAAI,CAACJ,OAAO,CAACK,gBAAgB,CAAC,EAAE;IAC3D,MAAMC,WAAW,GAAGR,MAAM,CAACS,UAAU,CAACL,OAAO,CAAC;IAC9C,IAAII,WAAW,EAAEE,IAAI,KAAK,WAAW,EAAE;MACrC,OAAO;QACLA,IAAI,EAAE,OAAO;QACbR,OAAO,EAAES,8BAA8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kBACF;EACF,CAAC;AACH","ignoreList":[]}
@@ -20,7 +20,7 @@ interface ImportMetaHot {
20
20
  on?: (event: "vite:beforeFullReload", cb: (payload: unknown) => void) => void;
21
21
  off?: (
22
22
  event: "vite:beforeFullReload",
23
- cb: (payload: unknown) => void,
23
+ cb: (payload: unknown) => void
24
24
  ) => void;
25
25
  }
26
26
 
@@ -1 +1 @@
1
- {"mappings":"AAgBA,YAAY,WAAW,OAAQ;UAErB,MAAM;CACd;AACD;;;;AAKD,OAAO,cAAM,sBAAsB,MAAM,UACvC,MAAM,mBACN,OACA;CACA,OAAO;CAEP,OAAO,yBAAyBA,iBAAiB,QAAQ;CAIzD,UAAU,MAAM;AAoDjB","names":["error: unknown"],"sources":["../../src/ErrorBoundary.tsx"],"version":3,"file":"ErrorBoundary.d.ts"}
1
+ {"mappings":"AAgBA,YAAY,WAAW,OAAQ;UAErB,MAAM;CACd;AACD;;;;AAKD,OAAO,cAAM,sBAAsB,MAAM,UACvC,MAAM,mBACN,OACA;CACA,OAAO;CAEP,OAAO,yBAAyBA,iBAAiB,QAAQ;CAIzD,UAAU,MAAM;AAqDjB","names":["error: unknown"],"sources":["../../src/ErrorBoundary.tsx"],"version":3,"file":"ErrorBoundary.d.ts"}
@@ -8,7 +8,7 @@ type ExtractObjectTypes<C extends WidgetConfig<C["parameters"]>> = C["parameters
8
8
  allowedType: infer AT
9
9
  } ? AT extends AllowedObjectSetParameterType ? AT : never : never : never;
10
10
  type HasObjectSetParameters<C extends WidgetConfig<C["parameters"]>> = ExtractObjectTypes<C> extends never ? false : true;
11
- type ObjectSetProps<C extends WidgetConfig<C["parameters"]>> = {
11
+ type ObjectSetProps<_C extends WidgetConfig<_C["parameters"]>> = {
12
12
  /**
13
13
  * Used to hydrate object sets from their RIDs for object set parameters
14
14
  */
@@ -1 +1 @@
1
- {"mappings":"AAgBA,cAAc,cAAyB,cAAe;AACtD,cAAc,qCAAqC,kBAAmB;AACtE,cAKO,oBACA,qBAAsB;AAC7B,O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ACF;AAED,YAAY,0BAA0B,UAAU,aAAa,EAAE,qBAE1D,WAAW,EAAE,iBAAgB,gBAAgB,kBAAkB,KAC5D,EAAE,cAAc,WAAW;CAAE,MAAM;CAAa,mBAAmB;AAAG,IACpE,UAAU,gCACR,kBAAkB,GAAG,KAAK;CAAE,WAAW,UAAU;AAAI,IACvD,kBAAkB,GAAG,KACvB,kBAAkB,GAAG;AAI7B,YAAY,+BACV,UAAU,aAAa,EAAE,qBAExB,WAAW,EAAE,iBAAgB,gBAAgB,uBAAuB,KACjE,EAAE,cAAc,WAAW;CAAE,MAAM;CAAa,mBAAmB;AAAG,IACpE,UAAU,gCACR,uBAAuB,GAAG,KAAK;CAC/B,OAAO,WACL,kBAAkB,GAAG,KAAK;EAAE,WAAW,UAAU;CAAI;AAExD,IACD,uBAAuB,GAAG,KAC5B,uBAAuB,GAAG;AAIhC,OAAO,cAAMC,sBAAsB,MAAM,QACvC,2BAA2B,aAAa;;;;AAgB1C,OAAO,iBAAS,wBACd,UAAU,aAAa,EAAE,mBACtB,2BAA2B;AAIhC,yBAAiB;CACR,SAAS,UACd,UAAU,aAAa,EAAE,yBAChB,2BAA2B","names":["eventId: ID","payload: Omit<Extract<M[\"payload\"], { eventId: ID }>, \"eventId\">","FoundryWidgetContext: React.Context<\n FoundryWidgetClientContext<WidgetConfig<ParameterConfig>>\n>"],"sources":["../../src/context.ts"],"version":3,"file":"context.d.ts"}
1
+ {"mappings":"AAgBA,cAAc,iBAAiB,cAAe;AAC9C,cACE,+BACA,SACA,wBACA,qBACK,kBAAmB;AAC1B,cACO,6BACA,YACL,6BACK,sBACA,wBACA,oBACA,qBAAsB;AAC7B,OAAO,WAA2B,OAAQ;AAE1C,YAAY;CACV,UAAU,aAAa,EAAE;CACzB,UAAU,QAAQ;OAEjB,WAAW,uBAAuB,GAAG,MAAK,gBAAgB,EAAE,gBACzD,EAAE,cAAc,WAAW;CAAE,MAAM;CAAa,mBAAmB;AAAG,IACpE,UAAU,gCACR,UAAU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AsB,MAAM,QACvC,2BAA2B,aAAa;;;;AAgB1C,OAAO,iBAAS,wBACd,UAAU,aAAa,EAAE,mBACtB,2BAA2B;AAIhC,yBAAiB;CACR,SAAS,UACd,UAAU,aAAa,EAAE,yBAChB,2BAA2B","names":["eventId: ID","payload: Omit<Extract<M[\"payload\"], { eventId: ID }>, \"eventId\">","FoundryWidgetContext: React.Context<\n FoundryWidgetClientContext<WidgetConfig<ParameterConfig>>\n>"],"sources":["../../src/context.ts"],"version":3,"file":"context.d.ts"}
@@ -1 +1 @@
1
- {"mappings":"AAgBA,cAAc,QAAQ,iBAAiB,cAAe;AAEtD,cAEE,wBACA,oBACK,kBAAmB;AAC1B,cAAc,sCAAsC,eAAgB;;;;;;;AAQpE,OAAO,iBAAS,+BACd,UAAU,aAAa,EAAE,gBAEzBA,YAAY,oBACZC,QAAQ,GACRC,YAAY,uBAAuB,IACnCC,OAAO,YAAY;CAAE;CAAsB,WAAW;AAAW,KAChE,+BAA+B","names":["osdkClient: Client | undefined","config: C","parameters: AsyncParameterValueMap<C>","cache: Map<string, { objectSetRid: string; objectSet: ObjectSet }>"],"sources":["../../../src/utils/extendParametersWithObjectSets.ts"],"version":3,"file":"extendParametersWithObjectSets.d.ts"}
1
+ {"mappings":"AAgBA,cAAc,QAAQ,iBAAiB,cAAe;AAEtD,cAEE,wBACA,oBACK,kBAAmB;AAE1B,cAAc,sCAAsC,eAAgB;;;;;;;AAQpE,OAAO,iBAAS,+BACd,UAAU,aAAa,EAAE,gBAEzBA,YAAY,oBACZC,QAAQ,GACRC,YAAY,uBAAuB,IACnCC,OAAO,YAAY;CAAE;CAAsB,WAAW;AAAW,KAChE,+BAA+B","names":["osdkClient: Client | undefined","config: C","parameters: AsyncParameterValueMap<C>","cache: Map<string, { objectSetRid: string; objectSet: ObjectSet }>"],"sources":["../../../src/utils/extendParametersWithObjectSets.ts"],"version":3,"file":"extendParametersWithObjectSets.d.ts"}
@@ -1 +1 @@
1
- {"mappings":"AAgBA,cAAc,oBAAoB,qBAAsB;AACxD,cAAc,sCAAsC,eAAgB;;;;AAKpE,OAAO,iBAAS,qBAAqB,UAAU,aAAa,EAAE,gBAC5DA,QAAQ,GACRC,qBAAqB,YAAY,gBAChC,+BAA+B","names":["config: C","initialLoadingState: \"loading\" | \"not-started\""],"sources":["../../../src/utils/initializeParameters.ts"],"version":3,"file":"initializeParameters.d.ts"}
1
+ {"mappings":"AAgBA,cAAc,oBAAoB,qBAAsB;AAExD,cAAc,sCAAsC,eAAgB;;;;AAKpE,OAAO,iBAAS,qBAAqB,UAAU,aAAa,EAAE,gBAC5DA,QAAQ,GACRC,qBAAqB,YAAY,gBAChC,+BAA+B","names":["config: C","initialLoadingState: \"loading\" | \"not-started\""],"sources":["../../../src/utils/initializeParameters.ts"],"version":3,"file":"initializeParameters.d.ts"}
@@ -1 +1 @@
1
- {"mappings":"AAgBA,cAAc,cAAyB,cAAe;AAEtD,cAEE,SACA,8BAEK,kBAAmB;AAC1B,cAAc,oBAAoB,qBAAsB;AACxD,cAAc,uCAAuC,eAAgB;KAKhE;CACH,UAAU,aAAa,EAAE;CACzB,UAAU,QAAQ;IAChB;CACF,kBAAkB,uBAAuB,GAAG;AAC7C;KAEI;CACH,UAAU,aAAa,EAAE;CACzB,UAAU,QAAQ;IAChB;CACF,MAAM;CACN,SAAS,QAAQ,4BAA4B,GAAG;AACjD,IAAG;CACF,MAAM;CACN,SAAS,4BAA4B,GAAG;AACzC;AAED,OAAO,iBAAS;CACd,UAAU,aAAa,EAAE;CACzB,UAAU,QAAQ;EAElBA,QAAQ,GACRC,SAAS,GACTC,SAAS;CAAE,kBAAkB,gCAAgC,GAAG;AAAI,GACpEC,aAAa,SACZ,kCAAkC,GAAG;;;;;;;AAkCxC,OAAO,iBAAe;CACpB,UAAU,aAAa,EAAE;CACzB,UAAU,QAAQ;EAElBH,QAAQ,GACRC,SAAS,GACTC,SAAS;CAAE,kBAAkB,gCAAgC,GAAG;AAAI,GACpEC,aAAa,SACZ,QAAQ;CAAE,kBAAkB,uBAAuB,GAAG;AAAI","names":["config: C","eventId: K","payload: { parameterUpdates: AugmentedEventParameterValueMap<C, K> }","osdkClient?: Client"],"sources":["../../../src/utils/transformEmitEventPayload.ts"],"version":3,"file":"transformEmitEventPayload.d.ts"}
1
+ {"mappings":"AAgBA,cAAc,cAAyB,cAAe;AAEtD,cAEE,SACA,8BAEK,kBAAmB;AAC1B,cAAc,oBAAoB,qBAAsB;AAExD,cAAc,uCAAuC,eAAgB;KAKhE;CACH,UAAU,aAAa,EAAE;CACzB,UAAU,QAAQ;IAChB;CACF,kBAAkB,uBAAuB,GAAG;AAC7C;KAEI;CACH,UAAU,aAAa,EAAE;CACzB,UAAU,QAAQ;IAEhB;CACE,MAAM;CACN,SAAS,QAAQ,4BAA4B,GAAG;AACjD,IACD;CACE,MAAM;CACN,SAAS,4BAA4B,GAAG;AACzC;AAEL,OAAO,iBAAS;CACd,UAAU,aAAa,EAAE;CACzB,UAAU,QAAQ;EAElBA,QAAQ,GACRC,SAAS,GACTC,SAAS;CAAE,kBAAkB,gCAAgC,GAAG;AAAI,GACpEC,aAAa,SACZ,kCAAkC,GAAG;;;;;;;AAkCxC,OAAO,iBAAe;CACpB,UAAU,aAAa,EAAE;CACzB,UAAU,QAAQ;EAElBH,QAAQ,GACRC,SAAS,GACTC,SAAS;CAAE,kBAAkB,gCAAgC,GAAG;AAAI,GACpEC,aAAa,SACZ,QAAQ;CAAE,kBAAkB,uBAAuB,GAAG;AAAI","names":["config: C","eventId: K","payload: { parameterUpdates: AugmentedEventParameterValueMap<C, K> }","osdkClient?: Client"],"sources":["../../../src/utils/transformEmitEventPayload.ts"],"version":3,"file":"transformEmitEventPayload.d.ts"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osdk/widget.client-react",
3
- "version": "3.36.0",
3
+ "version": "3.36.1-main-010b12661f90af7da692db4ee09ea6b0dcdce3c6",
4
4
  "description": "Wrapper around @osdk/widget.client",
5
5
  "access": "public",
6
6
  "license": "Apache-2.0",
@@ -33,8 +33,8 @@
33
33
  "@types/react-dom": "^18 || ^19",
34
34
  "react": "^18 || ^19",
35
35
  "react-dom": "^18 || ^19",
36
- "@osdk/client": "^2.39.0",
37
- "@osdk/widget.client": "^3.36.0"
36
+ "@osdk/client": "^2.39.1-main-010b12661f90af7da692db4ee09ea6b0dcdce3c6",
37
+ "@osdk/widget.client": "^3.36.1-main-010b12661f90af7da692db4ee09ea6b0dcdce3c6"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/react": "^18.3.24",
@@ -43,11 +43,11 @@
43
43
  "react-dom": "18.3.1",
44
44
  "ts-expect": "^1.3.0",
45
45
  "typescript": "~5.5.4",
46
- "@osdk/client": "~2.39.0",
46
+ "@osdk/client": "~2.39.1-main-010b12661f90af7da692db4ee09ea6b0dcdce3c6",
47
47
  "@osdk/monorepo.api-extractor": "~0.7.0",
48
48
  "@osdk/monorepo.tsconfig": "~0.7.0",
49
- "@osdk/widget.api": "~3.36.0",
50
- "@osdk/widget.client": "~3.36.0"
49
+ "@osdk/widget.client": "~3.36.1-main-010b12661f90af7da692db4ee09ea6b0dcdce3c6",
50
+ "@osdk/widget.api": "~3.36.1-main-010b12661f90af7da692db4ee09ea6b0dcdce3c6"
51
51
  },
52
52
  "publishConfig": {
53
53
  "access": "public"
@@ -71,8 +71,8 @@
71
71
  "check-attw": "attw --pack .",
72
72
  "check-spelling": "cspell --quiet .",
73
73
  "clean": "rm -rf lib dist types build tsconfig.tsbuildinfo",
74
- "fix-lint": "eslint . --fix && dprint fmt",
75
- "lint": "eslint . && dprint check",
74
+ "fix-lint": "oxlint -c ../../oxlint.config.ts --fix . && oxfmt -c ../../oxfmt.config.ts .",
75
+ "lint": "oxlint -c ../../oxlint.config.ts . && oxfmt -c ../../oxfmt.config.ts --check .",
76
76
  "test": "vitest run",
77
77
  "transpileBrowser": "monorepo.tool.transpile -f esm -m normal -t browser",
78
78
  "transpileCjs": "monorepo.tool.transpile -f cjs -m bundle -t node",