@osdk/widget.vite-plugin 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 (123) hide show
  1. package/CHANGELOG.md +342 -0
  2. package/README.md +175 -0
  3. package/build/esm/build-plugin/FoundryWidgetBuildPlugin.js +93 -0
  4. package/build/esm/build-plugin/FoundryWidgetBuildPlugin.js.map +1 -0
  5. package/build/esm/build-plugin/__tests__/extractBuildOutputs.test.js +133 -0
  6. package/build/esm/build-plugin/__tests__/extractBuildOutputs.test.js.map +1 -0
  7. package/build/esm/build-plugin/__tests__/getWidgetBuildOutputs.test.js +148 -0
  8. package/build/esm/build-plugin/__tests__/getWidgetBuildOutputs.test.js.map +1 -0
  9. package/build/esm/build-plugin/buildWidgetSetManifest.js +48 -0
  10. package/build/esm/build-plugin/buildWidgetSetManifest.js.map +1 -0
  11. package/build/esm/build-plugin/extractBuildOutputs.js +107 -0
  12. package/build/esm/build-plugin/extractBuildOutputs.js.map +1 -0
  13. package/build/esm/build-plugin/getWidgetBuildOutputs.js +50 -0
  14. package/build/esm/build-plugin/getWidgetBuildOutputs.js.map +1 -0
  15. package/build/esm/build-plugin/isConfigFile.js +22 -0
  16. package/build/esm/build-plugin/isConfigFile.js.map +1 -0
  17. package/build/esm/client/app.js +97 -0
  18. package/build/esm/client/app.js.map +1 -0
  19. package/build/esm/client/main.js +23 -0
  20. package/build/esm/client/main.js.map +1 -0
  21. package/build/esm/common/__tests__/getInputHtmlEntrypoints.test.js +38 -0
  22. package/build/esm/common/__tests__/getInputHtmlEntrypoints.test.js.map +1 -0
  23. package/build/esm/common/constants.js +23 -0
  24. package/build/esm/common/constants.js.map +1 -0
  25. package/build/esm/common/extractWidgetConfig.js +69 -0
  26. package/build/esm/common/extractWidgetConfig.js.map +1 -0
  27. package/build/esm/common/getInputHtmlEntrypoints.js +29 -0
  28. package/build/esm/common/getInputHtmlEntrypoints.js.map +1 -0
  29. package/build/esm/common/safeGetEnvVar.js +24 -0
  30. package/build/esm/common/safeGetEnvVar.js.map +1 -0
  31. package/build/esm/common/standardizeFileExtension.js +25 -0
  32. package/build/esm/common/standardizeFileExtension.js.map +1 -0
  33. package/build/esm/dev-plugin/FoundryWidgetDevPlugin.js +193 -0
  34. package/build/esm/dev-plugin/FoundryWidgetDevPlugin.js.map +1 -0
  35. package/build/esm/dev-plugin/__tests__/codeWorkspacesMode.test.js +87 -0
  36. package/build/esm/dev-plugin/__tests__/codeWorkspacesMode.test.js.map +1 -0
  37. package/build/esm/dev-plugin/__tests__/extractInjectedScripts.test.js +34 -0
  38. package/build/esm/dev-plugin/__tests__/extractInjectedScripts.test.js.map +1 -0
  39. package/build/esm/dev-plugin/__tests__/getBaseHref.test.js +48 -0
  40. package/build/esm/dev-plugin/__tests__/getBaseHref.test.js.map +1 -0
  41. package/build/esm/dev-plugin/__tests__/getWidgetIdOverrideMap.test.js +62 -0
  42. package/build/esm/dev-plugin/__tests__/getWidgetIdOverrideMap.test.js.map +1 -0
  43. package/build/esm/dev-plugin/codeWorkspacesMode.js +50 -0
  44. package/build/esm/dev-plugin/codeWorkspacesMode.js.map +1 -0
  45. package/build/esm/dev-plugin/extractInjectedScripts.js +62 -0
  46. package/build/esm/dev-plugin/extractInjectedScripts.js.map +1 -0
  47. package/build/esm/dev-plugin/getBaseHref.js +26 -0
  48. package/build/esm/dev-plugin/getBaseHref.js.map +1 -0
  49. package/build/esm/dev-plugin/getFoundryToken.js +28 -0
  50. package/build/esm/dev-plugin/getFoundryToken.js.map +1 -0
  51. package/build/esm/dev-plugin/getWidgetIdOverrideMap.js +39 -0
  52. package/build/esm/dev-plugin/getWidgetIdOverrideMap.js.map +1 -0
  53. package/build/esm/dev-plugin/network.js +51 -0
  54. package/build/esm/dev-plugin/network.js.map +1 -0
  55. package/build/esm/dev-plugin/publishDevModeSettings.js +63 -0
  56. package/build/esm/dev-plugin/publishDevModeSettings.js.map +1 -0
  57. package/build/esm/index.js +22 -0
  58. package/build/esm/index.js.map +1 -0
  59. package/build/site/assets/allPaths-CoV91acR.js +1 -0
  60. package/build/site/assets/allPathsLoader-abVMVrnV.js +2 -0
  61. package/build/site/assets/index-62l0mIXD.css +1 -0
  62. package/build/site/assets/index-BrAe7gTM.js +1 -0
  63. package/build/site/assets/index-DLUL2ZpM.js +44 -0
  64. package/build/site/assets/index-Zx5rUdU4.js +1 -0
  65. package/build/site/assets/splitPathsBySizeLoader--OyNgZuW.js +1 -0
  66. package/build/site/index.html +15 -0
  67. package/build/types/build-plugin/FoundryWidgetBuildPlugin.d.ts +2 -0
  68. package/build/types/build-plugin/FoundryWidgetBuildPlugin.d.ts.map +1 -0
  69. package/build/types/build-plugin/__tests__/extractBuildOutputs.test.d.ts +1 -0
  70. package/build/types/build-plugin/__tests__/extractBuildOutputs.test.d.ts.map +1 -0
  71. package/build/types/build-plugin/__tests__/getWidgetBuildOutputs.test.d.ts +1 -0
  72. package/build/types/build-plugin/__tests__/getWidgetBuildOutputs.test.d.ts.map +1 -0
  73. package/build/types/build-plugin/buildWidgetSetManifest.d.ts +3 -0
  74. package/build/types/build-plugin/buildWidgetSetManifest.d.ts.map +1 -0
  75. package/build/types/build-plugin/extractBuildOutputs.d.ts +12 -0
  76. package/build/types/build-plugin/extractBuildOutputs.d.ts.map +1 -0
  77. package/build/types/build-plugin/getWidgetBuildOutputs.d.ts +7 -0
  78. package/build/types/build-plugin/getWidgetBuildOutputs.d.ts.map +1 -0
  79. package/build/types/build-plugin/isConfigFile.d.ts +1 -0
  80. package/build/types/build-plugin/isConfigFile.d.ts.map +1 -0
  81. package/build/types/client/app.d.ts +2 -0
  82. package/build/types/client/app.d.ts.map +1 -0
  83. package/build/types/client/main.d.ts +3 -0
  84. package/build/types/client/main.d.ts.map +1 -0
  85. package/build/types/common/__tests__/getInputHtmlEntrypoints.test.d.ts +1 -0
  86. package/build/types/common/__tests__/getInputHtmlEntrypoints.test.d.ts.map +1 -0
  87. package/build/types/common/constants.d.ts +6 -0
  88. package/build/types/common/constants.d.ts.map +1 -0
  89. package/build/types/common/extractWidgetConfig.d.ts +3 -0
  90. package/build/types/common/extractWidgetConfig.d.ts.map +1 -0
  91. package/build/types/common/getInputHtmlEntrypoints.d.ts +5 -0
  92. package/build/types/common/getInputHtmlEntrypoints.d.ts.map +1 -0
  93. package/build/types/common/safeGetEnvVar.d.ts +1 -0
  94. package/build/types/common/safeGetEnvVar.d.ts.map +1 -0
  95. package/build/types/common/standardizeFileExtension.d.ts +6 -0
  96. package/build/types/common/standardizeFileExtension.d.ts.map +1 -0
  97. package/build/types/dev-plugin/FoundryWidgetDevPlugin.d.ts +2 -0
  98. package/build/types/dev-plugin/FoundryWidgetDevPlugin.d.ts.map +1 -0
  99. package/build/types/dev-plugin/__tests__/codeWorkspacesMode.test.d.ts +1 -0
  100. package/build/types/dev-plugin/__tests__/codeWorkspacesMode.test.d.ts.map +1 -0
  101. package/build/types/dev-plugin/__tests__/extractInjectedScripts.test.d.ts +1 -0
  102. package/build/types/dev-plugin/__tests__/extractInjectedScripts.test.d.ts.map +1 -0
  103. package/build/types/dev-plugin/__tests__/getBaseHref.test.d.ts +1 -0
  104. package/build/types/dev-plugin/__tests__/getBaseHref.test.d.ts.map +1 -0
  105. package/build/types/dev-plugin/__tests__/getWidgetIdOverrideMap.test.d.ts +1 -0
  106. package/build/types/dev-plugin/__tests__/getWidgetIdOverrideMap.test.d.ts.map +1 -0
  107. package/build/types/dev-plugin/codeWorkspacesMode.d.ts +8 -0
  108. package/build/types/dev-plugin/codeWorkspacesMode.d.ts.map +1 -0
  109. package/build/types/dev-plugin/extractInjectedScripts.d.ts +16 -0
  110. package/build/types/dev-plugin/extractInjectedScripts.d.ts.map +1 -0
  111. package/build/types/dev-plugin/getBaseHref.d.ts +2 -0
  112. package/build/types/dev-plugin/getBaseHref.d.ts.map +1 -0
  113. package/build/types/dev-plugin/getFoundryToken.d.ts +1 -0
  114. package/build/types/dev-plugin/getFoundryToken.d.ts.map +1 -0
  115. package/build/types/dev-plugin/getWidgetIdOverrideMap.d.ts +3 -0
  116. package/build/types/dev-plugin/getWidgetIdOverrideMap.d.ts.map +1 -0
  117. package/build/types/dev-plugin/network.d.ts +2 -0
  118. package/build/types/dev-plugin/network.d.ts.map +1 -0
  119. package/build/types/dev-plugin/publishDevModeSettings.d.ts +6 -0
  120. package/build/types/dev-plugin/publishDevModeSettings.d.ts.map +1 -0
  121. package/build/types/index.d.ts +2 -0
  122. package/build/types/index.d.ts.map +1 -0
  123. package/package.json +89 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,342 @@
1
+ # @osdk/widget.vite-plugin
2
+
3
+ ## 2.1.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 322c5bc: Simulated release
8
+ - 3ba0499: Move Vite plugin to API Gateway public endpoints
9
+ - d4c962c: Fix typos for widgets libraries
10
+ - a9f2596: Send baseHref when setting widget set settings
11
+ - 0caa7b8: Use HTML parsing for Vite post-build widget manifest creation
12
+ - 87b747c: Code Workspaces awareness for the Widgets Vite plugin
13
+ - 317b555: Release
14
+ - 994ab25: Support widget dev server on non-root paths
15
+ - 9673e54: Fixes for custom widgets Vite plugin in Code Workspaces mode
16
+ - Updated dependencies [322c5bc]
17
+ - Updated dependencies [322c5bc]
18
+ - Updated dependencies [317b555]
19
+ - @osdk/foundry-config-json@1.1.0
20
+ - @osdk/widget.api.unstable@2.1.0
21
+
22
+ ## 2.1.0-beta.11
23
+
24
+ ### Patch Changes
25
+
26
+ - @osdk/widget.api.unstable@2.1.0-beta.11
27
+
28
+ ## 2.1.0-beta.10
29
+
30
+ ### Minor Changes
31
+
32
+ - 317b555: Release
33
+ - 9673e54: Fixes for custom widgets Vite plugin in Code Workspaces mode
34
+
35
+ ### Patch Changes
36
+
37
+ - Updated dependencies [317b555]
38
+ - @osdk/widget.api.unstable@2.1.0-beta.10
39
+
40
+ ## 2.1.0-beta.9
41
+
42
+ ### Minor Changes
43
+
44
+ - d4c962c: Fix typos for widgets libraries
45
+
46
+ ### Patch Changes
47
+
48
+ - @osdk/widget.api.unstable@2.1.0-beta.9
49
+
50
+ ## 2.1.0-beta.8
51
+
52
+ ### Minor Changes
53
+
54
+ - 87b747c: Code Workspaces awareness for the Widgets Vite plugin
55
+
56
+ ### Patch Changes
57
+
58
+ - @osdk/widget.api.unstable@2.1.0-beta.8
59
+
60
+ ## 2.1.0-beta.7
61
+
62
+ ### Minor Changes
63
+
64
+ - 3ba0499: Move Vite plugin to API Gateway public endpoints
65
+ - a9f2596: Send baseHref when setting widget set settings
66
+
67
+ ### Patch Changes
68
+
69
+ - @osdk/widget.api.unstable@2.1.0-beta.7
70
+
71
+ ## 2.1.0-beta.6
72
+
73
+ ### Patch Changes
74
+
75
+ - @osdk/widget.api.unstable@2.1.0-beta.6
76
+
77
+ ## 2.1.0-beta.5
78
+
79
+ ### Minor Changes
80
+
81
+ - 994ab25: Support widget dev server on non-root paths
82
+
83
+ ### Patch Changes
84
+
85
+ - @osdk/widget.api.unstable@2.1.0-beta.5
86
+
87
+ ## 2.1.0-beta.4
88
+
89
+ ### Patch Changes
90
+
91
+ - @osdk/widget.api.unstable@2.1.0-beta.4
92
+
93
+ ## 2.1.0-beta.3
94
+
95
+ ### Patch Changes
96
+
97
+ - @osdk/widget.api.unstable@2.1.0-beta.3
98
+
99
+ ## 2.1.0-beta.2
100
+
101
+ ### Minor Changes
102
+
103
+ - 0caa7b8: Use HTML parsing for Vite post-build widget manifest creation
104
+
105
+ ### Patch Changes
106
+
107
+ - @osdk/widget.api.unstable@2.1.0-beta.2
108
+
109
+ ## 2.0.0
110
+
111
+ ### Minor Changes
112
+
113
+ - f0b519d: Upgrade to vitest 3 and vite 6
114
+ - 1dca4cb: Use @osdk/foundry-config-json in @osdk/widget.vite-plugin.unstable for shared config and auto versioning
115
+ - c5f9fe0: Rename widget template component name consistent
116
+ - 314ae66: Move from "views" naming to "widgets"
117
+ - e1649c2: Handle Vite plugin injections in Custom Widget Vite plugin
118
+ - c9da74c: Improves code quality by fixing linting errors
119
+ - adf3b12: Rename @osdk/widget.manifest-vite-plugin to @osdk/widget.vite-plugin.unstable
120
+ - 121475a: Release versions 1.1.0 of Custom Widget client libraries
121
+ - 7c13070: Change manifest to support script types for entrypoint JS
122
+ - 83e7ea3: Move from a single-widget to widget set model for custom widget libraries
123
+ - b463be5: Fix custom widget Vite 6 CORS issues and release @osdk/widget.vite-plugin.unstable 1.1.1
124
+ - 7507ed7: Upgrade to Vite v6
125
+ - e4839b9: Add target type to widget manifest
126
+ - da8585b: Updated implementation for the custom widget Vite plugin
127
+ - 7d1355e: Initial release of widget API
128
+ - 991e0d1: Fix Vite plugin @osdk/foundry-config-json dependency
129
+ - 91a54a3: Support basic manifest in vite serve mode
130
+ - 55db99e: Fix listing entrypoint CSS files for imported chunks
131
+
132
+ ### Patch Changes
133
+
134
+ - Updated dependencies [5a4ebd7]
135
+ - Updated dependencies [009650f]
136
+ - Updated dependencies [f0b519d]
137
+ - Updated dependencies [5f36612]
138
+ - Updated dependencies [1dca4cb]
139
+ - Updated dependencies [cf9dcbe]
140
+ - Updated dependencies [8766327]
141
+ - Updated dependencies [c691c8b]
142
+ - Updated dependencies [314ae66]
143
+ - Updated dependencies [21d2dd1]
144
+ - Updated dependencies [01c02e5]
145
+ - Updated dependencies [c4fdca1]
146
+ - Updated dependencies [121475a]
147
+ - Updated dependencies [7c13070]
148
+ - Updated dependencies [83e7ea3]
149
+ - Updated dependencies [e4839b9]
150
+ - Updated dependencies [7d1355e]
151
+ - @osdk/widget.api.unstable@2.0.0
152
+ - @osdk/foundry-config-json@1.0.0
153
+
154
+ ## 2.0.0-beta.16
155
+
156
+ ### Patch Changes
157
+
158
+ - @osdk/widget.api.unstable@2.0.0-beta.16
159
+
160
+ ## 2.0.0-beta.15
161
+
162
+ ### Minor Changes
163
+
164
+ - c5f9fe0: Rename widget template component name consistent
165
+
166
+ ### Patch Changes
167
+
168
+ - @osdk/widget.api.unstable@2.0.0-beta.15
169
+
170
+ ## 2.0.0-beta.14
171
+
172
+ ### Minor Changes
173
+
174
+ - b463be5: Fix custom widget Vite 6 CORS issues and release @osdk/widget.vite-plugin.unstable 1.1.1
175
+
176
+ ### Patch Changes
177
+
178
+ - @osdk/widget.api.unstable@2.0.0-beta.14
179
+
180
+ ## 2.0.0-beta.13
181
+
182
+ ### Minor Changes
183
+
184
+ - 121475a: Release versions 1.1.0 of Custom Widget client libraries
185
+ - da8585b: Updated implementation for the custom widget Vite plugin
186
+
187
+ ### Patch Changes
188
+
189
+ - Updated dependencies [121475a]
190
+ - @osdk/widget.api.unstable@2.0.0-beta.13
191
+
192
+ ## 2.0.0-beta.12
193
+
194
+ ### Patch Changes
195
+
196
+ - @osdk/widget-api.unstable@2.0.0-beta.12
197
+
198
+ ## 2.0.0-beta.11
199
+
200
+ ### Patch Changes
201
+
202
+ - Updated dependencies [8766327]
203
+ - @osdk/foundry-config-json@1.0.0-beta.4
204
+ - @osdk/widget.api.unstable@2.0.0-beta.11
205
+
206
+ ## 2.0.0-beta.10
207
+
208
+ ### Patch Changes
209
+
210
+ - Updated dependencies [c4fdca1]
211
+ - @osdk/foundry-config-json@1.0.0-beta.3
212
+ - @osdk/widget.api.unstable@2.0.0-beta.10
213
+
214
+ ## 2.0.0-beta.9
215
+
216
+ ### Patch Changes
217
+
218
+ - Updated dependencies [c691c8b]
219
+ - @osdk/widget.api.unstable@2.0.0-beta.9
220
+
221
+ ## 2.0.0-beta.8
222
+
223
+ ### Minor Changes
224
+
225
+ - f0b519d: Upgrade to vitest 3 and vite 6
226
+ - 83e7ea3: Move from a single-widget to widget set model for custom widget libraries
227
+ - 7507ed7: Upgrade to Vite v6
228
+
229
+ ### Patch Changes
230
+
231
+ - Updated dependencies [f0b519d]
232
+ - Updated dependencies [83e7ea3]
233
+ - @osdk/widget.api.unstable@2.0.0-beta.8
234
+ - @osdk/foundry-config-json@0.1.0-beta.2
235
+
236
+ ## 2.0.0-beta.7
237
+
238
+ ### Minor Changes
239
+
240
+ - c9da74c: Improves code quality by fixing linting errors
241
+ - 991e0d1: Fix Vite plugin @osdk/foundry-config-json dependency
242
+
243
+ ### Patch Changes
244
+
245
+ - @osdk/widget.api.unstable@2.0.0-beta.7
246
+
247
+ ## 2.0.0-beta.6
248
+
249
+ ### Minor Changes
250
+
251
+ - 1dca4cb: Use @osdk/foundry-config-json in @osdk/widget.vite-plugin.unstable for shared config and auto versioning
252
+ - 314ae66: Move from "views" naming to "widgets"
253
+
254
+ ### Patch Changes
255
+
256
+ - Updated dependencies [314ae66]
257
+ - @osdk/widget.api.unstable@2.0.0-beta.6
258
+
259
+ ## 2.0.0-beta.5
260
+
261
+ ### Minor Changes
262
+
263
+ - e1649c2: Handle Vite plugin injections in Custom Widget Vite plugin
264
+ - adf3b12: Rename @osdk/widget.manifest-vite-plugin to @osdk/widget.vite-plugin.unstable
265
+
266
+ ### Patch Changes
267
+
268
+ - @osdk/widget.api.unstable@2.0.0-beta.5
269
+
270
+ ## 2.0.0-beta.4
271
+
272
+ ### Patch Changes
273
+
274
+ - Updated dependencies [5a4ebd7]
275
+ - @osdk/widget.api.unstable@2.0.0-beta.4
276
+
277
+ ## 0.3.0-beta.3
278
+
279
+ ### Patch Changes
280
+
281
+ - @osdk/widget.api.unstable@0.3.0-beta.3
282
+
283
+ ## 0.3.0-beta.2
284
+
285
+ ### Patch Changes
286
+
287
+ - @osdk/widget.api.unstable@0.3.0-beta.2
288
+
289
+ ## 0.3.0-beta.1
290
+
291
+ ### Minor Changes
292
+
293
+ - 91a54a3: Support basic manifest in vite serve mode
294
+
295
+ ### Patch Changes
296
+
297
+ - @osdk/widget.api.unstable@0.3.0-beta.1
298
+
299
+ ## 0.2.0
300
+
301
+ ### Minor Changes
302
+
303
+ - e4839b9: Add target type to widget manifest
304
+
305
+ ### Patch Changes
306
+
307
+ - Updated dependencies [e4839b9]
308
+ - @osdk/widget.api.unstable@0.2.0-beta.0
309
+
310
+ ## 0.1.0
311
+
312
+ ### Minor Changes
313
+
314
+ - 55db99e: Fix listing entrypoint CSS files for imported chunks
315
+
316
+ ### Patch Changes
317
+
318
+ - @osdk/widget.api.unstable@0.1.0-beta.2
319
+
320
+ ## 0.1.0-beta.1
321
+
322
+ ### Minor Changes
323
+
324
+ - 7c13070: Change manifest to support script types for entrypoint JS
325
+
326
+ ### Patch Changes
327
+
328
+ - Updated dependencies [21d2dd1]
329
+ - Updated dependencies [7c13070]
330
+ - @osdk/widget.api.unstable@0.1.0-beta.1
331
+
332
+ ## 0.1.0-beta.0
333
+
334
+ ### Minor Changes
335
+
336
+ - 7d1355e: Initial release of widget API
337
+
338
+ ### Patch Changes
339
+
340
+ - Updated dependencies [01c02e5]
341
+ - Updated dependencies [7d1355e]
342
+ - @osdk/widget.api.unstable@0.1.0-beta.0
package/README.md ADDED
@@ -0,0 +1,175 @@
1
+ # @osdk/widget.vite-plugin
2
+
3
+ This is a Vite plugin that will automatically discover `*.config.(j|t)s` files that are imported into entrypoint files and generates a `.palantir/widgets.config.json` file for Foundry to read from. This allows developers to write out their configuration for custom widgets in Foundry in a single, type-safe file and not worry about generating a manifest file needed for publishing new versions of the widget within Foundry.
4
+
5
+ ## Usage
6
+
7
+ To use the plugin, add it to the `plugins` list of your [vite configuration](https://vitejs.dev/config/):
8
+
9
+ ```js
10
+ import foundryWidgetPlugin from "@osdk/widget.vite-plugin";
11
+ import { defineConfig } from "vite";
12
+
13
+ export default defineConfig({
14
+ plugins: [foundryWidgetPlugin()],
15
+ // Rest of configuration...
16
+ });
17
+ ```
18
+
19
+ ## Defining configuration
20
+
21
+ The `@osdk/widget.client` package exports a `defineConfig` helper so that you can define a configuration object in the shape that this plugin requires. You can define your config like so:
22
+
23
+ ```js
24
+ // main.config.ts
25
+ import { defineConfig } from "@osdk/widget.client";
26
+
27
+ export default defineConfig({
28
+ id: "<Widget ID>", // The unique identifier of the widget within your project
29
+ name: "<Widget Name>", // A user friendly name for your widget
30
+ description: "<Widget Description>", // A user friendly description of your widget
31
+ type: "workshop",
32
+ parameters: {
33
+ headerText: {
34
+ displayName: "Widget title",
35
+ type: "string",
36
+ },
37
+ showWarning: {
38
+ displayName: "Show warning callout",
39
+ type: "boolean",
40
+ },
41
+ todoItems: {
42
+ displayName: "Todo items",
43
+ type: "array",
44
+ subType: "string",
45
+ },
46
+ },
47
+ events: {
48
+ updateHeader: {
49
+ displayName: "Update header",
50
+ parameterUpdateIds: ["headerText"],
51
+ },
52
+ updateTodoItems: {
53
+ displayName: "Update todo items",
54
+ parameterUpdateIds: ["todoItems"],
55
+ },
56
+ },
57
+ });
58
+ ```
59
+
60
+ To be able to build your manifest and run developer mode, we require some configuration for your target widget set, and the stack you'll be deploying to. This plugin requires a `foundry.config.json` file to be present containing this information (auto-generated when using `@osdk/create-widget`), like so:
61
+
62
+ ```json
63
+ {
64
+ "foundryUrl": "https://{YOUR_STACK_URL}",
65
+ "widgetSet": {
66
+ "rid": "{YOUR_WIDGET_SET_RID}"
67
+ // Rest of config
68
+ }
69
+ }
70
+ ```
71
+
72
+ ## Importing the configuration
73
+
74
+ Import your `*.config.ts` file in any entrypoint JavaScript/TypeScript file so the plugin can pick it up. Entrypoint files are any that are imported from your root HTML file. For example, if you have the following setup:
75
+
76
+ ```
77
+ src/
78
+ main.tsx
79
+ main.config.ts
80
+ index.html
81
+ ```
82
+
83
+ And in `index.html`, you import `main.tsx`:
84
+
85
+ ```html
86
+ <!doctype html>
87
+ <html lang="en">
88
+ <!-- rest of HTML -->
89
+ <body>
90
+ <!-- rest of body -->
91
+ <script type="module" src="/src/main.tsx"></script>
92
+ </body>
93
+ </html>
94
+ ```
95
+
96
+ Import your configuration file in `src/main.tsx` so the vite plugin will discover it:
97
+
98
+ ```js
99
+ import { FoundryWidget } from "@osdk/widget.client-react";
100
+ import React from "react";
101
+ import { createRoot } from "react-dom/client";
102
+ import { Widget } from "./Widget.js";
103
+ import MainConfig from "./main.config.js";
104
+
105
+ const root = document.querySelector("body")!;
106
+ createRoot(root).render(
107
+ <FoundryWidget config={MainConfig}>
108
+ <Widget />
109
+ </FoundryWidget>
110
+ );
111
+ ```
112
+
113
+ Then the vite plugin will automatically find `src/main.config.ts` file and produce a `.palantir/widgets.config.json` file in the configured output directory of your vite config. If you don't actually need the config object in your code, you can also just have a simple import statement like `import "./main.config.js";` so that the plugin can find it.
114
+
115
+ ## Multiple entrypoints
116
+
117
+ You can configure vite and this plugin to output multiple widgets simultaneously. Vite's entrypoints are based on HTML files, so to add more entrypoints, first add another HTML file:
118
+
119
+ ```
120
+ src/
121
+ main.tsx
122
+ main.config.ts
123
+ second.tsx // Imported by second.html
124
+ second.config.ts // Imported by second.tsx
125
+ index.html
126
+ second.html // Second entrypoint
127
+ ```
128
+
129
+ And then in your vite config, you will need to configure the [`build.rollupOptions.input`](https://rollupjs.org/configuration-options/#input) option to discover both entrypoints:
130
+
131
+ ```js
132
+ import foundryWidgetPlugin from "@osdk/widget.vite-plugin";
133
+ import { defineConfig } from "vite";
134
+
135
+ export default defineConfig({
136
+ plugins: [foundryWidgetPlugin()],
137
+ build: {
138
+ rollupOptions: {
139
+ input: ["./index.html", "./second.html"],
140
+ },
141
+ },
142
+ });
143
+ ```
144
+
145
+ This vite plugin will then discover both entrypoints and output a combined `.palantir/widget.config.json` file such as:
146
+
147
+ ```json
148
+ {
149
+ "manifestVersion": "1.0.0",
150
+ "widgetSet": {
151
+ "rid": "ri.widgetregistry..widget-set.abc",
152
+ "version": "0.0.0",
153
+ "widgets": {
154
+ "main": {
155
+ "entrypointJs": [
156
+ "assets/main-D7Z1E0qk.js"
157
+ ],
158
+ "entrypointCss": []
159
+ // Rest of config
160
+ },
161
+ "second": {
162
+ "entrypointJs": [
163
+ "assets/second-CULz-_Ck.js"
164
+ ],
165
+ "entrypointCss": []
166
+ // Rest of config
167
+ }
168
+ }
169
+ }
170
+ }
171
+ ```
172
+
173
+ ## Developer mode
174
+
175
+ The vite plugin also automatically configures developer mode so that you can preview the changes you make locally live on your Foundry environment. For developer mode to work, make sure you set a `FOUNDRY_TOKEN` environment variable that has a token with access to your Foundry stack.
@@ -0,0 +1,93 @@
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 { autoVersion, loadFoundryConfig } from "@osdk/foundry-config-json";
18
+ import { MANIFEST_FILE_LOCATION } from "@osdk/widget.api";
19
+ import fs from "fs";
20
+ import path from "path";
21
+ import { extractWidgetConfig } from "../common/extractWidgetConfig.js";
22
+ import { getInputHtmlEntrypoints } from "../common/getInputHtmlEntrypoints.js";
23
+ import { standardizeFileExtension } from "../common/standardizeFileExtension.js";
24
+ import { buildWidgetSetManifest } from "./buildWidgetSetManifest.js";
25
+ import { getWidgetBuildOutputs } from "./getWidgetBuildOutputs.js";
26
+ import { isConfigFile } from "./isConfigFile.js";
27
+ export function FoundryWidgetBuildPlugin() {
28
+ // The root HTML entrypoints of the build process
29
+ let htmlEntrypoints;
30
+ // Store the configuration per module ID, e.g. /repo/src/widget-one.config.ts -> { ... }
31
+ const configFiles = {};
32
+ let config;
33
+ return {
34
+ name: "@osdk:widget-build-plugin",
35
+ enforce: "pre",
36
+ /**
37
+ * Capture the entrypoints from the Vite config for use in later build steps.
38
+ */
39
+ buildStart(options) {
40
+ htmlEntrypoints = getInputHtmlEntrypoints(options);
41
+ },
42
+ /**
43
+ * Store the resolved Vite config for use in later build steps.
44
+ */
45
+ configResolved(_config) {
46
+ config = _config;
47
+ },
48
+ /**
49
+ * Attempt to parse any module that looks like a widget configuration file, storing the result
50
+ * to be matched to entrypoints later.
51
+ */
52
+ moduleParsed(moduleInfo) {
53
+ if (!isConfigFile(moduleInfo.id)) {
54
+ return;
55
+ }
56
+ const widgetConfig = extractWidgetConfig(moduleInfo.id, moduleInfo.ast);
57
+ if (widgetConfig != null) {
58
+ const standardizedSource = standardizeFileExtension(moduleInfo.id);
59
+ configFiles[standardizedSource] = widgetConfig;
60
+ }
61
+ },
62
+ /**
63
+ * Once the build is complete, generate the widget set manifest based on the entrypoints and
64
+ * configuration files that were found.
65
+ *
66
+ * Write the manifest to the expected location in the dist directory.
67
+ */
68
+ async writeBundle(_, bundle) {
69
+ const foundryConfig = await loadFoundryConfig("widgetSet");
70
+ if (foundryConfig == null) {
71
+ throw new Error("foundry.config.json file not found.");
72
+ }
73
+
74
+ // Build widget set manifest
75
+ const widgetSetVersion = await computeWidgetSetVersion(foundryConfig);
76
+ const widgetBuilds = htmlEntrypoints.map(input => getWidgetBuildOutputs(bundle, input, config.build.outDir, configFiles));
77
+ const widgetSetManifest = buildWidgetSetManifest(foundryConfig.foundryConfig.widgetSet.rid, widgetSetVersion, widgetBuilds);
78
+
79
+ // Write the manifest to the dist directory
80
+ const manifestPath = path.join(config.build.outDir, MANIFEST_FILE_LOCATION);
81
+ fs.mkdirSync(path.dirname(manifestPath), {
82
+ recursive: true
83
+ });
84
+ fs.writeFileSync(manifestPath, JSON.stringify(widgetSetManifest, null, 2));
85
+ }
86
+ };
87
+ }
88
+ async function computeWidgetSetVersion(foundryConfig) {
89
+ return autoVersion(foundryConfig.foundryConfig.widgetSet.autoVersion ?? {
90
+ "type": "package-json"
91
+ });
92
+ }
93
+ //# sourceMappingURL=FoundryWidgetBuildPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FoundryWidgetBuildPlugin.js","names":["autoVersion","loadFoundryConfig","MANIFEST_FILE_LOCATION","fs","path","extractWidgetConfig","getInputHtmlEntrypoints","standardizeFileExtension","buildWidgetSetManifest","getWidgetBuildOutputs","isConfigFile","FoundryWidgetBuildPlugin","htmlEntrypoints","configFiles","config","name","enforce","buildStart","options","configResolved","_config","moduleParsed","moduleInfo","id","widgetConfig","ast","standardizedSource","writeBundle","_","bundle","foundryConfig","Error","widgetSetVersion","computeWidgetSetVersion","widgetBuilds","map","input","build","outDir","widgetSetManifest","widgetSet","rid","manifestPath","join","mkdirSync","dirname","recursive","writeFileSync","JSON","stringify"],"sources":["FoundryWidgetBuildPlugin.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 { LoadedFoundryConfig } from \"@osdk/foundry-config-json\";\nimport { autoVersion, loadFoundryConfig } from \"@osdk/foundry-config-json\";\nimport type { ParameterConfig, WidgetConfig } from \"@osdk/widget.api\";\nimport { MANIFEST_FILE_LOCATION } from \"@osdk/widget.api\";\nimport fs from \"fs\";\nimport path from \"path\";\nimport type { Plugin, ResolvedConfig } from \"vite\";\nimport { extractWidgetConfig } from \"../common/extractWidgetConfig.js\";\nimport { getInputHtmlEntrypoints } from \"../common/getInputHtmlEntrypoints.js\";\nimport { standardizeFileExtension } from \"../common/standardizeFileExtension.js\";\nimport { buildWidgetSetManifest } from \"./buildWidgetSetManifest.js\";\nimport { getWidgetBuildOutputs } from \"./getWidgetBuildOutputs.js\";\nimport { isConfigFile } from \"./isConfigFile.js\";\n\nexport function FoundryWidgetBuildPlugin(): Plugin {\n // The root HTML entrypoints of the build process\n let htmlEntrypoints: string[];\n // Store the configuration per module ID, e.g. /repo/src/widget-one.config.ts -> { ... }\n const configFiles: Record<string, WidgetConfig<ParameterConfig>> = {};\n let config: ResolvedConfig;\n\n return {\n name: \"@osdk:widget-build-plugin\",\n enforce: \"pre\",\n\n /**\n * Capture the entrypoints from the Vite config for use in later build steps.\n */\n buildStart(options) {\n htmlEntrypoints = getInputHtmlEntrypoints(options);\n },\n\n /**\n * Store the resolved Vite config for use in later build steps.\n */\n configResolved(_config) {\n config = _config;\n },\n\n /**\n * Attempt to parse any module that looks like a widget configuration file, storing the result\n * to be matched to entrypoints later.\n */\n moduleParsed(moduleInfo) {\n if (!isConfigFile(moduleInfo.id)) {\n return;\n }\n\n const widgetConfig = extractWidgetConfig(moduleInfo.id, moduleInfo.ast);\n if (widgetConfig != null) {\n const standardizedSource = standardizeFileExtension(moduleInfo.id);\n configFiles[standardizedSource] = widgetConfig;\n }\n },\n\n /**\n * Once the build is complete, generate the widget set manifest based on the entrypoints and\n * configuration files that were found.\n *\n * Write the manifest to the expected location in the dist directory.\n */\n async writeBundle(_, bundle) {\n const foundryConfig = await loadFoundryConfig(\"widgetSet\");\n if (foundryConfig == null) {\n throw new Error(\"foundry.config.json file not found.\");\n }\n\n // Build widget set manifest\n const widgetSetVersion = await computeWidgetSetVersion(foundryConfig);\n const widgetBuilds = htmlEntrypoints.map((input) =>\n getWidgetBuildOutputs(bundle, input, config.build.outDir, configFiles)\n );\n const widgetSetManifest = buildWidgetSetManifest(\n foundryConfig.foundryConfig.widgetSet.rid,\n widgetSetVersion,\n widgetBuilds,\n );\n\n // Write the manifest to the dist directory\n const manifestPath = path.join(\n config.build.outDir,\n MANIFEST_FILE_LOCATION,\n );\n fs.mkdirSync(path.dirname(manifestPath), { recursive: true });\n fs.writeFileSync(\n manifestPath,\n JSON.stringify(widgetSetManifest, null, 2),\n );\n },\n };\n}\n\nasync function computeWidgetSetVersion(\n foundryConfig: LoadedFoundryConfig<\"widgetSet\">,\n): Promise<string> {\n return autoVersion(\n foundryConfig.foundryConfig.widgetSet.autoVersion\n ?? { \"type\": \"package-json\" },\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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