@osdk/widget.api 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/CHANGELOG.md +128 -0
  2. package/build/browser/config.js +41 -0
  3. package/build/browser/config.js.map +1 -0
  4. package/build/browser/config.test.js +243 -0
  5. package/build/browser/config.test.js.map +1 -0
  6. package/build/browser/index.js +22 -0
  7. package/build/browser/index.js.map +1 -0
  8. package/build/browser/manifest.js +18 -0
  9. package/build/browser/manifest.js.map +1 -0
  10. package/build/browser/manifest.test.js +57 -0
  11. package/build/browser/manifest.test.js.map +1 -0
  12. package/build/browser/messages/hostMessages.js +40 -0
  13. package/build/browser/messages/hostMessages.js.map +1 -0
  14. package/build/browser/messages/widgetMessages.js +37 -0
  15. package/build/browser/messages/widgetMessages.js.map +1 -0
  16. package/build/browser/messages/widgetMessages.test.js +94 -0
  17. package/build/browser/messages/widgetMessages.test.js.map +1 -0
  18. package/build/browser/metaTags.js +18 -0
  19. package/build/browser/metaTags.js.map +1 -0
  20. package/build/browser/parameters.js +23 -0
  21. package/build/browser/parameters.js.map +1 -0
  22. package/build/browser/parameters.test.js +38 -0
  23. package/build/browser/parameters.test.js.map +1 -0
  24. package/build/browser/utils/asyncValue.js +2 -0
  25. package/build/browser/utils/asyncValue.js.map +1 -0
  26. package/build/cjs/index.cjs +64 -0
  27. package/build/cjs/index.cjs.map +1 -0
  28. package/build/cjs/index.d.cts +289 -0
  29. package/build/esm/config.js +41 -0
  30. package/build/esm/config.js.map +1 -0
  31. package/build/esm/config.test.js +243 -0
  32. package/build/esm/config.test.js.map +1 -0
  33. package/build/esm/index.js +22 -0
  34. package/build/esm/index.js.map +1 -0
  35. package/build/esm/manifest.js +18 -0
  36. package/build/esm/manifest.js.map +1 -0
  37. package/build/esm/manifest.test.js +57 -0
  38. package/build/esm/manifest.test.js.map +1 -0
  39. package/build/esm/messages/hostMessages.js +40 -0
  40. package/build/esm/messages/hostMessages.js.map +1 -0
  41. package/build/esm/messages/widgetMessages.js +37 -0
  42. package/build/esm/messages/widgetMessages.js.map +1 -0
  43. package/build/esm/messages/widgetMessages.test.js +94 -0
  44. package/build/esm/messages/widgetMessages.test.js.map +1 -0
  45. package/build/esm/metaTags.js +18 -0
  46. package/build/esm/metaTags.js.map +1 -0
  47. package/build/esm/parameters.js +23 -0
  48. package/build/esm/parameters.js.map +1 -0
  49. package/build/esm/parameters.test.js +38 -0
  50. package/build/esm/parameters.test.js.map +1 -0
  51. package/build/esm/utils/asyncValue.js +2 -0
  52. package/build/esm/utils/asyncValue.js.map +1 -0
  53. package/build/types/config.d.ts +74 -0
  54. package/build/types/config.d.ts.map +1 -0
  55. package/build/types/config.test.d.ts +1 -0
  56. package/build/types/config.test.d.ts.map +1 -0
  57. package/build/types/index.d.ts +10 -0
  58. package/build/types/index.d.ts.map +1 -0
  59. package/build/types/manifest.d.ts +64 -0
  60. package/build/types/manifest.d.ts.map +1 -0
  61. package/build/types/manifest.test.d.ts +1 -0
  62. package/build/types/manifest.test.d.ts.map +1 -0
  63. package/build/types/messages/hostMessages.d.ts +33 -0
  64. package/build/types/messages/hostMessages.d.ts.map +1 -0
  65. package/build/types/messages/widgetMessages.d.ts +36 -0
  66. package/build/types/messages/widgetMessages.d.ts.map +1 -0
  67. package/build/types/messages/widgetMessages.test.d.ts +1 -0
  68. package/build/types/messages/widgetMessages.test.d.ts.map +1 -0
  69. package/build/types/metaTags.d.ts +1 -0
  70. package/build/types/metaTags.d.ts.map +1 -0
  71. package/build/types/parameters.d.ts +43 -0
  72. package/build/types/parameters.d.ts.map +1 -0
  73. package/build/types/parameters.test.d.ts +1 -0
  74. package/build/types/parameters.test.d.ts.map +1 -0
  75. package/build/types/utils/asyncValue.d.ts +38 -0
  76. package/build/types/utils/asyncValue.d.ts.map +1 -0
  77. package/package.json +69 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,128 @@
1
+ # @osdk/widget.api
2
+
3
+ ## 2.1.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 322c5bc: Simulated release
8
+ - 317b555: Release
9
+
10
+ ## 2.1.0-beta.11
11
+
12
+ ## 2.1.0-beta.10
13
+
14
+ ### Minor Changes
15
+
16
+ - 317b555: Release
17
+
18
+ ## 2.1.0-beta.9
19
+
20
+ ## 2.1.0-beta.8
21
+
22
+ ## 2.1.0-beta.7
23
+
24
+ ## 2.1.0-beta.6
25
+
26
+ ## 2.1.0-beta.5
27
+
28
+ ## 2.1.0-beta.4
29
+
30
+ ## 2.1.0-beta.3
31
+
32
+ ## 2.1.0-beta.2
33
+
34
+ ## 2.0.0
35
+
36
+ ### Major Changes
37
+
38
+ - 5a4ebd7: Bump unstable widget packages to v1 to avoid undesired v0.x version behavior
39
+
40
+ ### Minor Changes
41
+
42
+ - 009650f: Add initial views API
43
+ - f0b519d: Upgrade to vitest 3 and vite 6
44
+ - 5f36612: Add support for events
45
+ - c691c8b: Package now has experimental support for commonjs
46
+ - 314ae66: Move from "views" naming to "widgets"
47
+ - 21d2dd1: Add fetch proxy
48
+ - 01c02e5: Add vite plugin to parse out parameter config into a generated config file
49
+ - 121475a: Release versions 1.1.0 of Custom Widget client libraries
50
+ - 7c13070: Change manifest to support script types for entrypoint JS
51
+ - 83e7ea3: Move from a single-widget to widget set model for custom widget libraries
52
+ - e4839b9: Add target type to widget manifest
53
+ - 7d1355e: Initial release of widget API
54
+
55
+ ## 2.0.0-beta.16
56
+
57
+ ## 2.0.0-beta.15
58
+
59
+ ## 2.0.0-beta.14
60
+
61
+ ## 2.0.0-beta.13
62
+
63
+ ### Minor Changes
64
+
65
+ - 121475a: Release versions 1.1.0 of Custom Widget client libraries
66
+
67
+ ## 2.0.0-beta.12
68
+
69
+ ## 2.0.0-beta.11
70
+
71
+ ## 2.0.0-beta.10
72
+
73
+ ## 2.0.0-beta.9
74
+
75
+ ### Minor Changes
76
+
77
+ - c691c8b: Package now has experimental support for commonjs
78
+
79
+ ## 2.0.0-beta.8
80
+
81
+ ### Minor Changes
82
+
83
+ - f0b519d: Upgrade to vitest 3 and vite 6
84
+ - 83e7ea3: Move from a single-widget to widget set model for custom widget libraries
85
+
86
+ ## 2.0.0-beta.7
87
+
88
+ ## 2.0.0-beta.6
89
+
90
+ ### Minor Changes
91
+
92
+ - 314ae66: Move from "views" naming to "widgets"
93
+
94
+ ## 2.0.0-beta.5
95
+
96
+ ## 2.0.0-beta.4
97
+
98
+ ### Major Changes
99
+
100
+ - 5a4ebd7: Bump unstable widget packages to v1 to avoid undesired v0.x version behavior
101
+
102
+ ## 0.3.0-beta.3
103
+
104
+ ## 0.3.0-beta.2
105
+
106
+ ## 0.3.0-beta.1
107
+
108
+ ## 0.2.0
109
+
110
+ ### Minor Changes
111
+
112
+ - e4839b9: Add target type to widget manifest
113
+
114
+ ## 0.1.0
115
+
116
+ ## 0.1.0-beta.1
117
+
118
+ ### Minor Changes
119
+
120
+ - 21d2dd1: Add fetch proxy
121
+ - 7c13070: Change manifest to support script types for entrypoint JS
122
+
123
+ ## 0.1.0-beta.0
124
+
125
+ ### Minor Changes
126
+
127
+ - 01c02e5: Add vite plugin to parse out parameter config into a generated config file
128
+ - 7d1355e: Initial release of widget API
@@ -0,0 +1,41 @@
1
+ /*
2
+ * Copyright 2024 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ /**
18
+ * Extracts the parameter ID strings as types from the given ParameterConfig.
19
+ */
20
+
21
+ /**
22
+ * Extracts a map of parameter IDs to their async-wrapped value types from the given ParameterConfig.
23
+ */
24
+
25
+ /**
26
+ * Extracts a map of parameter IDs to the raw parameter values from the given ParameterConfig.
27
+ */
28
+
29
+ /**
30
+ * Extracts a list of strongly-typed parameter IDs from the given WidgetConfig for a given event ID.
31
+ * If a parameter ID is referenced by an event but does not exist, its type will be never
32
+ */
33
+
34
+ /**
35
+ * Extracts a map of event IDs to their raw parameter value types from the given WidgetConfig.
36
+ */
37
+
38
+ export function defineConfig(c) {
39
+ return c;
40
+ }
41
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","names":["defineConfig","c"],"sources":["config.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 { ParameterValue } from \"./parameters.js\";\nimport type { AsyncValue } from \"./utils/asyncValue.js\";\n\ninterface PrimitiveParameterDefinition<T extends ParameterValue.PrimitiveType> {\n type: T;\n displayName: string;\n}\ninterface ArrayParameterDefinition<S extends ParameterValue.PrimitiveType> {\n type: ParameterValue.Array[\"type\"];\n displayName: string;\n subType: S;\n}\nexport type ParameterDefinition =\n | PrimitiveParameterDefinition<ParameterValue.PrimitiveType>\n | ArrayParameterDefinition<ParameterValue.PrimitiveType>;\n\nexport interface EventDefinition<P extends ParameterConfig> {\n displayName: string;\n parameterUpdateIds: Array<ParameterId<P>>;\n}\n\nexport type ParameterConfig = Record<string, ParameterDefinition>;\n\nexport interface WidgetConfig<P extends ParameterConfig> {\n id: string;\n name: string;\n description?: string;\n // TODO: Add specific config for each type of widget. For now, all the config is generic and can be used by any widget.\n type: \"workshop\";\n parameters: ParameterConfig;\n events: { [eventId: string]: EventDefinition<NoInfer<P>> };\n}\n\n/**\n * Extracts the parameter ID strings as types from the given ParameterConfig.\n */\nexport type ParameterId<C extends ParameterConfig> = Extract<keyof C, string>;\n\n/**\n * Extracts a map of parameter IDs to their async-wrapped value types from the given ParameterConfig.\n */\nexport type AsyncParameterValueMap<C extends WidgetConfig<C[\"parameters\"]>> = {\n [\n K in ParameterId<\n C[\"parameters\"]\n >\n ]: C[\"parameters\"][K] extends ArrayParameterDefinition<infer S>\n // If it's an array, pull out the subtype correctly\n ? Extract<\n ParameterValue.Array,\n { type: C[\"parameters\"][K][\"type\"]; subType: S }\n >[\"value\"] extends AsyncValue<infer P> ? {\n type: \"array\";\n subType: S;\n value: AsyncValue<P>;\n }\n : never\n : Extract<\n ParameterValue,\n { type: C[\"parameters\"][K][\"type\"] }\n >[\"value\"] extends AsyncValue<infer P> ? {\n type: C[\"parameters\"][K][\"type\"];\n value: AsyncValue<P>;\n }\n : never;\n};\n\n/**\n * Extracts a map of parameter IDs to the raw parameter values from the given ParameterConfig.\n */\nexport type ParameterValueMap<C extends WidgetConfig<C[\"parameters\"]>> = {\n [\n K in ParameterId<\n C[\"parameters\"]\n >\n ]: C[\"parameters\"][K] extends ArrayParameterDefinition<infer S> ? Extract<\n ParameterValue.Array,\n { type: C[\"parameters\"][K][\"type\"]; subType: S }\n >[\"value\"] extends AsyncValue<infer P> ? P\n : never\n : Extract<\n ParameterValue,\n { type: C[\"parameters\"][K][\"type\"] }\n >[\"value\"] extends AsyncValue<infer P> ? P\n : never;\n};\n\nexport type EventId<C extends WidgetConfig<C[\"parameters\"]>> =\n keyof C[\"events\"];\n\n/**\n * Extracts a list of strongly-typed parameter IDs from the given WidgetConfig for a given event ID.\n * If a parameter ID is referenced by an event but does not exist, its type will be never\n */\nexport type EventParameterIdList<\n C extends WidgetConfig<C[\"parameters\"]>,\n K extends EventId<C>,\n> = C[\"events\"][K][\"parameterUpdateIds\"] extends\n Array<ParameterId<C[\"parameters\"]>> ? C[\"events\"][K][\"parameterUpdateIds\"]\n : never;\n\n/**\n * Extracts a map of event IDs to their raw parameter value types from the given WidgetConfig.\n */\nexport type EventParameterValueMap<\n C extends WidgetConfig<C[\"parameters\"]>,\n K extends EventId<C>,\n> = {\n [P in EventParameterIdList<C, K>[number]]: ParameterValueMap<C>[P];\n};\n\nexport function defineConfig<const C extends WidgetConfig<any>>(c: C): C {\n return c as any;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAmCA;AACA;AACA;;AAGA;AACA;AACA;;AA2BA;AACA;AACA;;AAqBA;AACA;AACA;AACA;;AAQA;AACA;AACA;;AAQA,OAAO,SAASA,YAAYA,CAAoCC,CAAI,EAAK;EACvE,OAAOA,CAAC;AACV","ignoreList":[]}
@@ -0,0 +1,243 @@
1
+ /*
2
+ * Copyright 2024 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { describe, expectTypeOf, it } from "vitest";
18
+ import { defineConfig } from "./config.js";
19
+ describe("WidgetConfig", () => {
20
+ describe("ParameterConfigId", () => {
21
+ it("should be able to infer the type of the parameter ID", () => {
22
+ defineConfig({
23
+ id: "widgetId",
24
+ name: "Widget Name",
25
+ description: "Widget Description",
26
+ type: "workshop",
27
+ parameters: {
28
+ test: {
29
+ displayName: "Testing",
30
+ type: "boolean"
31
+ },
32
+ test2: {
33
+ displayName: "Testing 2",
34
+ type: "string"
35
+ }
36
+ },
37
+ events: {}
38
+ });
39
+ expectTypeOf().toEqualTypeOf();
40
+ });
41
+ it("should construct a type safe map of async parameter values", () => {
42
+ defineConfig({
43
+ id: "widgetId",
44
+ name: "Widget Name",
45
+ description: "Widget Description",
46
+ type: "workshop",
47
+ parameters: {
48
+ test: {
49
+ displayName: "Testing",
50
+ type: "boolean"
51
+ },
52
+ test2: {
53
+ displayName: "Testing 2",
54
+ type: "string"
55
+ }
56
+ },
57
+ events: {}
58
+ });
59
+ expectTypeOf().toMatchTypeOf();
60
+ });
61
+ it("should construct a type safe map of async parameter values with arrays", () => {
62
+ defineConfig({
63
+ id: "widgetId",
64
+ name: "Widget Name",
65
+ description: "Widget Description",
66
+ type: "workshop",
67
+ parameters: {
68
+ test: {
69
+ displayName: "Testing",
70
+ type: "array",
71
+ subType: "boolean"
72
+ },
73
+ test2: {
74
+ displayName: "Testing 2",
75
+ type: "array",
76
+ subType: "string"
77
+ },
78
+ test3: {
79
+ displayName: "Testing 3",
80
+ type: "number"
81
+ }
82
+ },
83
+ events: {}
84
+ });
85
+ expectTypeOf().toMatchTypeOf();
86
+ });
87
+ it("should construct a type safe map of parameter values", () => {
88
+ defineConfig({
89
+ id: "widgetId",
90
+ name: "Widget Name",
91
+ description: "Widget Description",
92
+ type: "workshop",
93
+ parameters: {
94
+ test: {
95
+ displayName: "Testing",
96
+ type: "array",
97
+ subType: "boolean"
98
+ },
99
+ test2: {
100
+ displayName: "Testing 2",
101
+ type: "array",
102
+ subType: "string"
103
+ },
104
+ test3: {
105
+ displayName: "Testing 3",
106
+ type: "number"
107
+ }
108
+ },
109
+ events: {}
110
+ });
111
+ expectTypeOf().toMatchTypeOf();
112
+ });
113
+ it("should construct a type safe map of events that reference parameters", () => {
114
+ defineConfig({
115
+ id: "widgetId",
116
+ name: "Widget Name",
117
+ description: "Widget Description",
118
+ type: "workshop",
119
+ parameters: {
120
+ test: {
121
+ displayName: "Testing",
122
+ type: "array",
123
+ subType: "boolean"
124
+ },
125
+ test2: {
126
+ displayName: "Testing 2",
127
+ type: "array",
128
+ subType: "string"
129
+ },
130
+ test3: {
131
+ displayName: "Testing 3",
132
+ type: "number"
133
+ }
134
+ },
135
+ events: {
136
+ myEvent: {
137
+ displayName: "My Event",
138
+ parameterUpdateIds: ["test"]
139
+ }
140
+ }
141
+ });
142
+ expectTypeOf().toMatchTypeOf();
143
+ });
144
+ it("will not extract an event that references a parameter ID that doesn't exist", () => {
145
+ defineConfig({
146
+ id: "widgetId",
147
+ name: "Widget Name",
148
+ description: "Widget Description",
149
+ type: "workshop",
150
+ parameters: {
151
+ test: {
152
+ displayName: "Testing",
153
+ type: "array",
154
+ subType: "boolean"
155
+ },
156
+ test2: {
157
+ displayName: "Testing 2",
158
+ type: "array",
159
+ subType: "string"
160
+ },
161
+ test3: {
162
+ displayName: "Testing 3",
163
+ type: "number"
164
+ }
165
+ },
166
+ events: {
167
+ myEvent: {
168
+ displayName: "My Event",
169
+ parameterUpdateIds: ["test4"]
170
+ }
171
+ }
172
+ });
173
+ expectTypeOf().toMatchTypeOf();
174
+ });
175
+ it("should extract event IDs correctly", () => {
176
+ defineConfig({
177
+ id: "widgetId",
178
+ name: "Widget Name",
179
+ description: "Widget Description",
180
+ type: "workshop",
181
+ parameters: {
182
+ test: {
183
+ displayName: "Testing",
184
+ type: "array",
185
+ subType: "boolean"
186
+ },
187
+ test2: {
188
+ displayName: "Testing 2",
189
+ type: "array",
190
+ subType: "string"
191
+ },
192
+ test3: {
193
+ displayName: "Testing 3",
194
+ type: "number"
195
+ }
196
+ },
197
+ events: {
198
+ myEvent: {
199
+ displayName: "My Event",
200
+ parameterUpdateIds: ["test", "test2"]
201
+ },
202
+ myEvent2: {
203
+ displayName: "My second event",
204
+ parameterUpdateIds: []
205
+ }
206
+ }
207
+ });
208
+ expectTypeOf().toEqualTypeOf();
209
+ });
210
+ it("should extract an event to the parameter values", () => {
211
+ defineConfig({
212
+ id: "widgetId",
213
+ name: "Widget Name",
214
+ description: "Widget Description",
215
+ type: "workshop",
216
+ parameters: {
217
+ test: {
218
+ displayName: "Testing",
219
+ type: "array",
220
+ subType: "boolean"
221
+ },
222
+ test2: {
223
+ displayName: "Testing 2",
224
+ type: "array",
225
+ subType: "string"
226
+ },
227
+ test3: {
228
+ displayName: "Testing 3",
229
+ type: "number"
230
+ }
231
+ },
232
+ events: {
233
+ myEvent: {
234
+ displayName: "My Event",
235
+ parameterUpdateIds: ["test", "test2"]
236
+ }
237
+ }
238
+ });
239
+ expectTypeOf().toMatchTypeOf();
240
+ });
241
+ });
242
+ });
243
+ //# sourceMappingURL=config.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.test.js","names":["describe","expectTypeOf","it","defineConfig","id","name","description","type","parameters","test","displayName","test2","events","toEqualTypeOf","toMatchTypeOf","subType","test3","myEvent","parameterUpdateIds","myEvent2"],"sources":["config.test.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 { describe, expectTypeOf, it } from \"vitest\";\nimport {\n type AsyncParameterValueMap,\n defineConfig,\n type EventId,\n type EventParameterIdList,\n type EventParameterValueMap,\n type ParameterId,\n type ParameterValueMap,\n} from \"./config.js\";\nimport type { ParameterValue } from \"./parameters.js\";\n\ndescribe(\"WidgetConfig\", () => {\n describe(\"ParameterConfigId\", () => {\n it(\"should be able to infer the type of the parameter ID\", () => {\n const test = defineConfig({\n id: \"widgetId\",\n name: \"Widget Name\",\n description: \"Widget Description\",\n type: \"workshop\",\n parameters: {\n test: {\n displayName: \"Testing\",\n type: \"boolean\",\n },\n test2: {\n displayName: \"Testing 2\",\n type: \"string\",\n },\n },\n events: {},\n });\n expectTypeOf<ParameterId<(typeof test)[\"parameters\"]>>().toEqualTypeOf<\n \"test\" | \"test2\"\n >();\n });\n\n it(\"should construct a type safe map of async parameter values\", () => {\n const test = defineConfig({\n id: \"widgetId\",\n name: \"Widget Name\",\n description: \"Widget Description\",\n type: \"workshop\",\n parameters: {\n test: {\n displayName: \"Testing\",\n type: \"boolean\",\n },\n test2: {\n displayName: \"Testing 2\",\n type: \"string\",\n },\n },\n events: {},\n });\n expectTypeOf<AsyncParameterValueMap<typeof test>>().toMatchTypeOf<{\n test: ParameterValue.Boolean;\n test2: ParameterValue.String;\n }>();\n });\n\n it(\"should construct a type safe map of async parameter values with arrays\", () => {\n const test = defineConfig({\n id: \"widgetId\",\n name: \"Widget Name\",\n description: \"Widget Description\",\n type: \"workshop\",\n parameters: {\n test: {\n displayName: \"Testing\",\n type: \"array\",\n subType: \"boolean\",\n },\n test2: {\n displayName: \"Testing 2\",\n type: \"array\",\n subType: \"string\",\n },\n test3: {\n displayName: \"Testing 3\",\n type: \"number\",\n },\n },\n events: {},\n });\n expectTypeOf<AsyncParameterValueMap<typeof test>>().toMatchTypeOf<{\n test: ParameterValue.BooleanArray;\n test2: ParameterValue.StringArray;\n test3: ParameterValue.Number;\n }>();\n });\n\n it(\"should construct a type safe map of parameter values\", () => {\n const test = defineConfig({\n id: \"widgetId\",\n name: \"Widget Name\",\n description: \"Widget Description\",\n type: \"workshop\",\n parameters: {\n test: {\n displayName: \"Testing\",\n type: \"array\",\n subType: \"boolean\",\n },\n test2: {\n displayName: \"Testing 2\",\n type: \"array\",\n subType: \"string\",\n },\n test3: {\n displayName: \"Testing 3\",\n type: \"number\",\n },\n },\n events: {},\n });\n expectTypeOf<ParameterValueMap<typeof test>>().toMatchTypeOf<{\n test: boolean[];\n test2: string[];\n test3: number;\n }>();\n });\n\n it(\"should construct a type safe map of events that reference parameters\", () => {\n const test = defineConfig({\n id: \"widgetId\",\n name: \"Widget Name\",\n description: \"Widget Description\",\n type: \"workshop\",\n parameters: {\n test: {\n displayName: \"Testing\",\n type: \"array\",\n subType: \"boolean\",\n },\n test2: {\n displayName: \"Testing 2\",\n type: \"array\",\n subType: \"string\",\n },\n test3: {\n displayName: \"Testing 3\",\n type: \"number\",\n },\n },\n events: {\n myEvent: {\n displayName: \"My Event\",\n parameterUpdateIds: [\"test\"],\n },\n },\n });\n expectTypeOf<\n EventParameterIdList<typeof test, \"myEvent\">\n >().toMatchTypeOf<[\"test\"]>();\n });\n\n it(\"will not extract an event that references a parameter ID that doesn't exist\", () => {\n const test = defineConfig({\n id: \"widgetId\",\n name: \"Widget Name\",\n description: \"Widget Description\",\n type: \"workshop\",\n parameters: {\n test: {\n displayName: \"Testing\",\n type: \"array\",\n subType: \"boolean\",\n },\n test2: {\n displayName: \"Testing 2\",\n type: \"array\",\n subType: \"string\",\n },\n test3: {\n displayName: \"Testing 3\",\n type: \"number\",\n },\n },\n events: {\n myEvent: {\n displayName: \"My Event\",\n parameterUpdateIds: [\"test4\"],\n },\n },\n });\n expectTypeOf<\n // @ts-expect-error\n EventParameterIdList<typeof test, \"myEvent\">\n >().toMatchTypeOf<never>();\n });\n\n it(\"should extract event IDs correctly\", () => {\n const test = defineConfig({\n id: \"widgetId\",\n name: \"Widget Name\",\n description: \"Widget Description\",\n type: \"workshop\",\n parameters: {\n test: {\n displayName: \"Testing\",\n type: \"array\",\n subType: \"boolean\",\n },\n test2: {\n displayName: \"Testing 2\",\n type: \"array\",\n subType: \"string\",\n },\n test3: {\n displayName: \"Testing 3\",\n type: \"number\",\n },\n },\n events: {\n myEvent: {\n displayName: \"My Event\",\n parameterUpdateIds: [\"test\", \"test2\"],\n },\n myEvent2: {\n displayName: \"My second event\",\n parameterUpdateIds: [],\n },\n },\n });\n expectTypeOf<EventId<typeof test>>().toEqualTypeOf<\n \"myEvent\" | \"myEvent2\"\n >();\n });\n\n it(\"should extract an event to the parameter values\", () => {\n const test = defineConfig({\n id: \"widgetId\",\n name: \"Widget Name\",\n description: \"Widget Description\",\n type: \"workshop\",\n parameters: {\n test: {\n displayName: \"Testing\",\n type: \"array\",\n subType: \"boolean\",\n },\n test2: {\n displayName: \"Testing 2\",\n type: \"array\",\n subType: \"string\",\n },\n test3: {\n displayName: \"Testing 3\",\n type: \"number\",\n },\n },\n events: {\n myEvent: {\n displayName: \"My Event\",\n parameterUpdateIds: [\"test\", \"test2\"],\n },\n },\n });\n expectTypeOf<\n EventParameterValueMap<typeof test, \"myEvent\">\n >().toMatchTypeOf<{\n test: boolean[];\n test2: string[];\n }>();\n });\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,QAAQ,EAAEC,YAAY,EAAEC,EAAE,QAAQ,QAAQ;AACnD,SAEEC,YAAY,QAMP,aAAa;AAGpBH,QAAQ,CAAC,cAAc,EAAE,MAAM;EAC7BA,QAAQ,CAAC,mBAAmB,EAAE,MAAM;IAClCE,EAAE,CAAC,sDAAsD,EAAE,MAAM;MAClDC,YAAY,CAAC;QACxBC,EAAE,EAAE,UAAU;QACdC,IAAI,EAAE,aAAa;QACnBC,WAAW,EAAE,oBAAoB;QACjCC,IAAI,EAAE,UAAU;QAChBC,UAAU,EAAE;UACVC,IAAI,EAAE;YACJC,WAAW,EAAE,SAAS;YACtBH,IAAI,EAAE;UACR,CAAC;UACDI,KAAK,EAAE;YACLD,WAAW,EAAE,WAAW;YACxBH,IAAI,EAAE;UACR;QACF,CAAC;QACDK,MAAM,EAAE,CAAC;MACX,CAAC,CAAC;MACFX,YAAY,CAA2C,CAAC,CAACY,aAAa,CAEpE,CAAC;IACL,CAAC,CAAC;IAEFX,EAAE,CAAC,4DAA4D,EAAE,MAAM;MACxDC,YAAY,CAAC;QACxBC,EAAE,EAAE,UAAU;QACdC,IAAI,EAAE,aAAa;QACnBC,WAAW,EAAE,oBAAoB;QACjCC,IAAI,EAAE,UAAU;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AAO,EAAE;UACX,CAAC;UACDJ,KAAK,EAAE;YACLD,WAAW,EAAE,WAAW;YACxBH,IAAI,EAAE,OAAO;YACbQ,OAAO,EAAE;UACX,CAAC;UACDC,KAAK,EAAE;YACLN,WAAW,EAAE,WAAW;YACxBH,IAAI,EAAE;UACR;QACF,CAAC;QACDK,MAAM,EAAE;UACNK,OAAO,EAAE;YACPP,WAAW,EAAE,UAAU;YACvBQ,kBAAkB,EAAE,CAAC,MAAM,EAAE,OAAO;UACtC;QACF;MACF,CAAC,CAAC;MACFjB,YAAY,CAEV,CAAC,CAACa,aAAa,CAGd,CAAC;IACN,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,22 @@
1
+ /*
2
+ * Copyright 2024 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ export { defineConfig } from "./config.js";
18
+ export { MANIFEST_FILE_LOCATION } from "./manifest.js";
19
+ export { HostMessage, isHostParametersUpdatedMessage, visitHostMessage } from "./messages/hostMessages.js";
20
+ export { isWidgetEmitEventMessage, isWidgetReadyMessage, visitWidgetMessage } from "./messages/widgetMessages.js";
21
+ export { META_TAG_HOST_ORIGIN } from "./metaTags.js";
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["defineConfig","MANIFEST_FILE_LOCATION","HostMessage","isHostParametersUpdatedMessage","visitHostMessage","isWidgetEmitEventMessage","isWidgetReadyMessage","visitWidgetMessage","META_TAG_HOST_ORIGIN"],"sources":["index.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\nexport type {\n AsyncParameterValueMap,\n EventId,\n EventParameterValueMap,\n ParameterConfig,\n ParameterDefinition,\n ParameterValueMap,\n WidgetConfig,\n} from \"./config.js\";\nexport { defineConfig } from \"./config.js\";\nexport type {\n WidgetManifestConfigV1 as WidgetManifestConfig,\n WidgetSetManifestV1 as WidgetSetManifest,\n} from \"./manifest.js\";\nexport { MANIFEST_FILE_LOCATION } from \"./manifest.js\";\nexport {\n HostMessage,\n isHostParametersUpdatedMessage,\n visitHostMessage,\n} from \"./messages/hostMessages.js\";\nexport {\n isWidgetEmitEventMessage,\n isWidgetReadyMessage,\n visitWidgetMessage,\n} from \"./messages/widgetMessages.js\";\nexport type { WidgetMessage } from \"./messages/widgetMessages.js\";\nexport { META_TAG_HOST_ORIGIN } from \"./metaTags.js\";\nexport type { ParameterValue } from \"./parameters.js\";\nexport type {\n AsyncFailedValue,\n AsyncLoadedValue,\n AsyncLoadingValue,\n AsyncNotStartedLoadingValue,\n AsyncReloadingValue,\n AsyncValue,\n} from \"./utils/asyncValue.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAWA,SAASA,YAAY,QAAQ,aAAa;AAK1C,SAASC,sBAAsB,QAAQ,eAAe;AACtD,SACEC,WAAW,EACXC,8BAA8B,EAC9BC,gBAAgB,QACX,4BAA4B;AACnC,SACEC,wBAAwB,EACxBC,oBAAoB,EACpBC,kBAAkB,QACb,8BAA8B;AAErC,SAASC,oBAAoB,QAAQ,eAAe","ignoreList":[]}
@@ -0,0 +1,18 @@
1
+ /*
2
+ * Copyright 2024 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ export const MANIFEST_FILE_LOCATION = ".palantir/widgets.config.json";
18
+ //# sourceMappingURL=manifest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.js","names":["MANIFEST_FILE_LOCATION"],"sources":["manifest.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 {\n EventDefinition,\n ParameterConfig,\n ParameterDefinition,\n} from \"./config.js\";\n\nexport interface WidgetSetManifestV1 {\n manifestVersion: \"1.0.0\";\n widgetSet: WidgetSetManifestContentV1;\n}\n\nexport interface WidgetSetManifestContentV1 {\n /**\n * RID of the widget set that this config corresponds to\n */\n rid: string;\n\n /**\n * The version of the widget to publish as\n */\n version: string;\n\n /**\n * Set of widgets that are available to be rendered.\n * The key can be arbitrary, and is usually the name of your entrypoint, e.g. \"main\"\n */\n widgets: Record<string, WidgetManifestConfigV1>;\n}\n\nexport interface WidgetManifestConfigV1 {\n /**\n * The ID of this widget. Must be unique within the widget set\n */\n id: string;\n\n /**\n * The user friendly name of this widget\n */\n name: string;\n\n /**\n * A user friendly description of this widget\n */\n description?: string;\n\n /**\n * The target Foundry UI that this widget is intended to be used in\n */\n type: \"workshopWidgetV1\";\n\n /**\n * List of entrypoint JS files to be loaded, in order. These will be placed on the page in script tags\n */\n entrypointJs: Array<{\n /** Relative path of the JS file to load */\n path: string;\n\n /** The type to use in the script tag when loading this JS file */\n type: \"module\" | \"text/javascript\";\n }>;\n\n /**\n * Any CSS files to be loaded, in order.\n * @optional\n */\n entrypointCss?: Array<{\n /** Relative path of the CSS file to load */\n path: string;\n }>;\n\n /**\n * The map of parameter IDs to their definition\n */\n parameters: Record<string, ParameterDefinition>;\n\n /**\n * The map of events to their definition. Any parameter IDs referenced must be defined in the `parameters` field\n */\n events: Record<string, EventDefinition<ParameterConfig>>;\n}\n\nexport const MANIFEST_FILE_LOCATION = \".palantir/widgets.config.json\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAmFA,OAAO,MAAMA,sBAAsB,GAAG,+BAA+B","ignoreList":[]}
@@ -0,0 +1,57 @@
1
+ /*
2
+ * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import { expectTypeOf, test } from "vitest";
18
+ const EXAMPLE_WIDGET_SET_MANIFEST = {
19
+ "manifestVersion": "1.0.0",
20
+ "widgetSet": {
21
+ "rid": "ri.widgetregistry..widget-set.placeholder",
22
+ "version": "0.1.0",
23
+ "widgets": {
24
+ "widget1": {
25
+ "id": "widget1",
26
+ "name": "My name",
27
+ "description": "My description",
28
+ "type": "workshopWidgetV1",
29
+ "entrypointJs": [{
30
+ "path": "app.js",
31
+ "type": "module"
32
+ }],
33
+ "entrypointCss": [{
34
+ "path": "app.css"
35
+ }],
36
+ "parameters": {
37
+ "myString": {
38
+ "displayName": "My String",
39
+ "type": "string"
40
+ }
41
+ },
42
+ "events": {
43
+ "event1": {
44
+ "displayName": "Event 1",
45
+ "parameterUpdateIds": ["myString"]
46
+ }
47
+ }
48
+ }
49
+ }
50
+ }
51
+ };
52
+
53
+ // These tests don't actually need executing, as compilation is enough to verify the types are correct
54
+ test("WidgetSetManifestV1", () => {
55
+ expectTypeOf(EXAMPLE_WIDGET_SET_MANIFEST).toEqualTypeOf();
56
+ });
57
+ //# sourceMappingURL=manifest.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.test.js","names":["expectTypeOf","test","EXAMPLE_WIDGET_SET_MANIFEST","toEqualTypeOf"],"sources":["manifest.test.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 { expectTypeOf, test } from \"vitest\";\nimport type { WidgetSetManifestV1 } from \"./manifest.js\";\n\nconst EXAMPLE_WIDGET_SET_MANIFEST: WidgetSetManifestV1 = {\n \"manifestVersion\": \"1.0.0\" as const,\n \"widgetSet\": {\n \"rid\": \"ri.widgetregistry..widget-set.placeholder\",\n \"version\": \"0.1.0\",\n \"widgets\": {\n \"widget1\": {\n \"id\": \"widget1\",\n \"name\": \"My name\",\n \"description\": \"My description\",\n \"type\": \"workshopWidgetV1\",\n \"entrypointJs\": [\n {\n \"path\": \"app.js\",\n \"type\": \"module\",\n },\n ],\n \"entrypointCss\": [\n {\n \"path\": \"app.css\",\n },\n ],\n \"parameters\": {\n \"myString\": {\n \"displayName\": \"My String\",\n \"type\": \"string\",\n },\n },\n \"events\": {\n \"event1\": {\n \"displayName\": \"Event 1\",\n \"parameterUpdateIds\": [\n \"myString\",\n ],\n },\n },\n },\n },\n },\n};\n\n// These tests don't actually need executing, as compilation is enough to verify the types are correct\ntest(\"WidgetSetManifestV1\", () => {\n expectTypeOf(EXAMPLE_WIDGET_SET_MANIFEST).toEqualTypeOf<\n WidgetSetManifestV1\n >();\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,YAAY,EAAEC,IAAI,QAAQ,QAAQ;AAG3C,MAAMC,2BAAgD,GAAG;EACvD,iBAAiB,EAAE,OAAgB;EACnC,WAAW,EAAE;IACX,KAAK,EAAE,2CAA2C;IAClD,SAAS,EAAE,OAAO;IAClB,SAAS,EAAE;MACT,SAAS,EAAE;QACT,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,SAAS;QACjB,aAAa,EAAE,gBAAgB;QAC/B,MAAM,EAAE,kBAAkB;QAC1B,cAAc,EAAE,CACd;UACE,MAAM,EAAE,QAAQ;UAChB,MAAM,EAAE;QACV,CAAC,CACF;QACD,eAAe,EAAE,CACf;UACE,MAAM,EAAE;QACV,CAAC,CACF;QACD,YAAY,EAAE;UACZ,UAAU,EAAE;YACV,aAAa,EAAE,WAAW;YAC1B,MAAM,EAAE;UACV;QACF,CAAC;QACD,QAAQ,EAAE;UACR,QAAQ,EAAE;YACR,aAAa,EAAE,SAAS;YACxB,oBAAoB,EAAE,CACpB,UAAU;UAEd;QACF;MACF;IACF;EACF;AACF,CAAC;;AAED;AACAD,IAAI,CAAC,qBAAqB,EAAE,MAAM;EAChCD,YAAY,CAACE,2BAA2B,CAAC,CAACC,aAAa,CAErD,CAAC;AACL,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,40 @@
1
+ /*
2
+ * Copyright 2024 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ // Interfaces and type guards for messages passed from the host Foundry UI to the widget
17
+ export let HostMessage;
18
+ (function (_HostMessage) {
19
+ _HostMessage.Version = "1.0.0";
20
+ })(HostMessage || (HostMessage = {}));
21
+ export function isHostParametersUpdatedMessage(event) {
22
+ return event.type === "host.update-parameters";
23
+ }
24
+ /**
25
+ * Strongly typed visitor to handle every type of host message
26
+ */
27
+ export function visitHostMessage(message, visitor) {
28
+ const {
29
+ type,
30
+ payload
31
+ } = message;
32
+ const handler = visitor[type];
33
+ if (handler) {
34
+ // Typescript creates an & of the parameters instead of a union
35
+ handler(payload);
36
+ } else {
37
+ visitor._unknown(type);
38
+ }
39
+ }
40
+ //# sourceMappingURL=hostMessages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hostMessages.js","names":["HostMessage","_HostMessage","Version","isHostParametersUpdatedMessage","event","type","visitHostMessage","message","visitor","payload","handler","_unknown"],"sources":["hostMessages.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 { AsyncParameterValueMap, WidgetConfig } from \"../config.js\";\n\n// Interfaces and type guards for messages passed from the host Foundry UI to the widget\ninterface HostBaseMessage<T extends string, P = unknown> {\n type: T;\n payload: P;\n}\n\nexport namespace HostMessage {\n export const Version = \"1.0.0\";\n export type Version = typeof Version;\n\n export namespace Payload {\n export interface UpdateParameters<C extends WidgetConfig<C[\"parameters\"]>> {\n parameters: AsyncParameterValueMap<C>;\n }\n }\n\n export type Payload = Payload.UpdateParameters<any>;\n\n export interface UpdateParameters<C extends WidgetConfig<C[\"parameters\"]>>\n extends\n HostBaseMessage<\n \"host.update-parameters\",\n Payload.UpdateParameters<C>\n >\n {}\n}\n\nexport type HostMessage<C extends WidgetConfig<C[\"parameters\"]>> =\n HostMessage.UpdateParameters<C>;\n\nexport function isHostParametersUpdatedMessage<\n C extends WidgetConfig<C[\"parameters\"]>,\n>(event: HostMessage<C>): event is HostMessage.UpdateParameters<C> {\n return event.type === \"host.update-parameters\";\n}\n\ntype HostMessageVisitor<C extends WidgetConfig<C[\"parameters\"]>> =\n & {\n [T in HostMessage<C>[\"type\"]]: (\n payload: Extract<HostMessage<C>, { type: T }> extends {\n payload: infer P;\n } ? P\n : never,\n ) => void;\n }\n & {\n _unknown: (type: string) => void;\n };\n\n/**\n * Strongly typed visitor to handle every type of host message\n */\nexport function visitHostMessage<C extends WidgetConfig<C[\"parameters\"]>>(\n message: HostMessage<C>,\n visitor: HostMessageVisitor<C>,\n): void {\n const { type, payload } = message;\n const handler = visitor[type];\n if (handler) {\n // Typescript creates an & of the parameters instead of a union\n (handler as any)(payload);\n } else {\n visitor._unknown(type);\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA;AAAA,WAMiBA,WAAW;AAAA,WAAAC,YAAA;EAAAA,YAAA,CAAAC,OAAA,GACH,OAAO;AAAA,GADfF,WAAW,KAAXA,WAAW;AAwB5B,OAAO,SAASG,8BAA8BA,CAE5CC,KAAqB,EAA4C;EACjE,OAAOA,KAAK,CAACC,IAAI,KAAK,wBAAwB;AAChD;AAeA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAC9BC,OAAuB,EACvBC,OAA8B,EACxB;EACN,MAAM;IAAEH,IAAI;IAAEI;EAAQ,CAAC,GAAGF,OAAO;EACjC,MAAMG,OAAO,GAAGF,OAAO,CAACH,IAAI,CAAC;EAC7B,IAAIK,OAAO,EAAE;IACX;IACCA,OAAO,CAASD,OAAO,CAAC;EAC3B,CAAC,MAAM;IACLD,OAAO,CAACG,QAAQ,CAACN,IAAI,CAAC;EACxB;AACF","ignoreList":[]}
@@ -0,0 +1,37 @@
1
+ /*
2
+ * Copyright 2024 Palantir Technologies, Inc. All rights reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ // Interfaces and type guards for messages passed from the widget to the host Foundry UI
17
+ export let WidgetMessage;
18
+ export function isWidgetReadyMessage(event) {
19
+ return event.type === "widget.ready";
20
+ }
21
+ export function isWidgetEmitEventMessage(event) {
22
+ return event.type === "widget.emit-event";
23
+ }
24
+ export function visitWidgetMessage(message, visitor) {
25
+ const {
26
+ type,
27
+ payload
28
+ } = message;
29
+ const handler = visitor[type];
30
+ if (handler) {
31
+ // Typescript creates an & of the parameters instead of a union
32
+ handler(payload);
33
+ } else {
34
+ visitor._unknown(type);
35
+ }
36
+ }
37
+ //# sourceMappingURL=widgetMessages.js.map