@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
@@ -0,0 +1,97 @@
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 { NonIdealState, Spinner, SpinnerSize } from "@blueprintjs/core";
18
+ import React, { useEffect } from "react";
19
+ const POLLING_INTERVAL = 250;
20
+ const REDIRECT_DELAY = 500;
21
+ export const App = () => {
22
+ const [entrypointPaths, setEntrypointPaths] = React.useState([]);
23
+ const [pageState, setPageState] = React.useState({
24
+ state: "loading"
25
+ });
26
+
27
+ // Load entrypoints values on mount
28
+ useEffect(() => {
29
+ void loadEntrypoints().then(setEntrypointPaths);
30
+ }, []);
31
+
32
+ // Poll the finish endpoint until it returns a success or error
33
+ useEffect(() => {
34
+ const poll = window.setInterval(() => {
35
+ void finish().then(result => {
36
+ if (result.status === "pending") {
37
+ return;
38
+ }
39
+
40
+ // On success or failure, we clear the poll and end the loading state
41
+ window.clearInterval(poll);
42
+ setPageState(result.status === "success" ? {
43
+ state: "success",
44
+ isRedirecting: result.redirectUrl != null
45
+ } : {
46
+ state: "failed",
47
+ error: result.error
48
+ });
49
+
50
+ // When running in Code Workspaces the parent app will handle the redirect
51
+ if (result.status === "success" && result.redirectUrl != null) {
52
+ setTimeout(() => {
53
+ window.location.href = result.redirectUrl;
54
+ }, REDIRECT_DELAY);
55
+ }
56
+ }).catch(error => {
57
+ window.clearInterval(poll);
58
+ setPageState({
59
+ state: "failed",
60
+ error: error instanceof Error ? error.message : undefined
61
+ });
62
+ });
63
+ }, POLLING_INTERVAL);
64
+ return () => window.clearInterval(poll);
65
+ }, []);
66
+ return /*#__PURE__*/React.createElement("div", {
67
+ className: "body"
68
+ }, pageState.state === "loading" && /*#__PURE__*/React.createElement(NonIdealState, {
69
+ title: "Generating developer mode manifest\u2026",
70
+ icon: /*#__PURE__*/React.createElement(Spinner, {
71
+ intent: "primary"
72
+ })
73
+ }), pageState.state === "success" && /*#__PURE__*/React.createElement(NonIdealState, {
74
+ title: "Started dev mode",
75
+ icon: "tick-circle",
76
+ description: /*#__PURE__*/React.createElement("div", {
77
+ className: "description"
78
+ }, /*#__PURE__*/React.createElement(Spinner, {
79
+ intent: "primary",
80
+ size: SpinnerSize.SMALL
81
+ }), " ", pageState.isRedirecting ? /*#__PURE__*/React.createElement("span", null, "Redirecting you\u2026") : /*#__PURE__*/React.createElement("span", null, "Loading preview\u2026"))
82
+ }), pageState.state === "failed" && /*#__PURE__*/React.createElement(NonIdealState, {
83
+ title: "Failed to start dev mode",
84
+ icon: "error",
85
+ description: pageState.error
86
+ }), entrypointPaths.map(entrypointPath => /*#__PURE__*/React.createElement("iframe", {
87
+ key: entrypointPath,
88
+ src: entrypointPath
89
+ })));
90
+ };
91
+ function loadEntrypoints() {
92
+ return fetch("../entrypoints").then(res => res.json());
93
+ }
94
+ function finish() {
95
+ return fetch("../finish").then(res => res.json());
96
+ }
97
+ //# sourceMappingURL=app.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.js","names":["NonIdealState","Spinner","SpinnerSize","React","useEffect","POLLING_INTERVAL","REDIRECT_DELAY","App","entrypointPaths","setEntrypointPaths","useState","pageState","setPageState","state","loadEntrypoints","then","poll","window","setInterval","finish","result","status","clearInterval","isRedirecting","redirectUrl","error","setTimeout","location","href","catch","Error","message","undefined","createElement","className","title","icon","intent","description","size","SMALL","map","entrypointPath","key","src","fetch","res","json"],"sources":["app.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 { NonIdealState, Spinner, SpinnerSize } from \"@blueprintjs/core\";\nimport React, { useEffect } from \"react\";\n\ntype PageState =\n | {\n state: \"loading\";\n }\n | {\n state: \"failed\";\n error?: string;\n }\n | {\n state: \"success\";\n isRedirecting: boolean;\n };\n\nconst POLLING_INTERVAL = 250;\nconst REDIRECT_DELAY = 500;\n\nexport const App: React.FC = () => {\n const [entrypointPaths, setEntrypointPaths] = React.useState<string[]>([]);\n const [pageState, setPageState] = React.useState<PageState>({\n state: \"loading\",\n });\n\n // Load entrypoints values on mount\n useEffect(() => {\n void loadEntrypoints().then(setEntrypointPaths);\n }, []);\n\n // Poll the finish endpoint until it returns a success or error\n useEffect(() => {\n const poll = window.setInterval(() => {\n void finish()\n .then((result) => {\n if (result.status === \"pending\") {\n return;\n }\n\n // On success or failure, we clear the poll and end the loading state\n window.clearInterval(poll);\n setPageState(\n result.status === \"success\"\n ? { state: \"success\", isRedirecting: result.redirectUrl != null }\n : { state: \"failed\", error: result.error },\n );\n\n // When running in Code Workspaces the parent app will handle the redirect\n if (result.status === \"success\" && result.redirectUrl != null) {\n setTimeout(() => {\n window.location.href = result.redirectUrl!;\n }, REDIRECT_DELAY);\n }\n })\n .catch((error: unknown) => {\n window.clearInterval(poll);\n setPageState({\n state: \"failed\",\n error: error instanceof Error ? error.message : undefined,\n });\n });\n }, POLLING_INTERVAL);\n return () => window.clearInterval(poll);\n }, []);\n\n return (\n <div className=\"body\">\n {pageState.state === \"loading\" && (\n <NonIdealState\n title=\"Generating developer mode manifest…\"\n icon={<Spinner intent=\"primary\" />}\n />\n )}\n {pageState.state === \"success\" && (\n <NonIdealState\n title=\"Started dev mode\"\n icon=\"tick-circle\"\n description={\n <div className=\"description\">\n <Spinner intent=\"primary\" size={SpinnerSize.SMALL} />{\" \"}\n {pageState.isRedirecting\n ? <span>Redirecting you…</span>\n : <span>Loading preview…</span>}\n </div>\n }\n />\n )}\n {pageState.state === \"failed\" && (\n <NonIdealState\n title=\"Failed to start dev mode\"\n icon=\"error\"\n description={pageState.error}\n />\n )}\n {/* To load the entrypoint info, we have to actually load it in the browser to get vite to follow the module graph. Since we know these files will fail, we just load them in iframes set to display: none to trigger the load hook in vite */}\n {entrypointPaths.map((entrypointPath) => (\n <iframe key={entrypointPath} src={entrypointPath} />\n ))}\n </div>\n );\n};\n\nfunction loadEntrypoints(): Promise<string[]> {\n return fetch(\"../entrypoints\").then((res) => res.json());\n}\n\nfunction finish(): Promise<\n | {\n status: \"success\";\n redirectUrl: string | null;\n }\n | {\n status: \"error\";\n error: string;\n }\n | {\n status: \"pending\";\n }\n> {\n return fetch(\"../finish\").then((res) => res.json());\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,aAAa,EAAEC,OAAO,EAAEC,WAAW,QAAQ,mBAAmB;AACvE,OAAOC,KAAK,IAAIC,SAAS,QAAQ,OAAO;AAexC,MAAMC,gBAAgB,GAAG,GAAG;AAC5B,MAAMC,cAAc,GAAG,GAAG;AAE1B,OAAO,MAAMC,GAAa,GAAGA,CAAA,KA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E,CACpD,CACE,CAAC;AAEV,CAAC;AAED,SAAS5B,eAAeA,CAAA,EAAsB;EAC5C,OAAO+B,KAAK,CAAC,gBAAgB,CAAC,CAAC9B,IAAI,CAAE+B,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC;AAC1D;AAEA,SAAS5B,MAAMA,CAAA,EAYb;EACA,OAAO0B,KAAK,CAAC,WAAW,CAAC,CAAC9B,IAAI,CAAE+B,GAAG,IAAKA,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC;AACrD","ignoreList":[]}
@@ -0,0 +1,23 @@
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 "@blueprintjs/core/lib/css/blueprint.css";
18
+ import "./main.css";
19
+ import { createRoot } from "react-dom/client";
20
+ import { App } from "./app.js";
21
+ const root = document.querySelector("body");
22
+ createRoot(root).render(/*#__PURE__*/React.createElement(App, null));
23
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","names":["createRoot","App","root","document","querySelector","render","React","createElement"],"sources":["main.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 \"@blueprintjs/core/lib/css/blueprint.css\";\nimport \"./main.css\";\n\nimport { createRoot } from \"react-dom/client\";\nimport { App } from \"./app.js\";\n\nconst root = document.querySelector(\"body\")!;\n\ncreateRoot(root).render(\n <App />,\n);\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,yCAAyC;AAChD,OAAO,YAAY;AAEnB,SAASA,UAAU,QAAQ,kBAAkB;AAC7C,SAASC,GAAG,QAAQ,UAAU;AAE9B,MAAMC,IAAI,GAAGC,QAAQ,CAACC,aAAa,CAAC,MAAM,CAAE;AAE5CJ,UAAU,CAACE,IAAI,CAAC,CAACG,MAAM,cACrBC,KAAA,CAAAC,aAAA,CAACN,GAAG,MAAE,CACR,CAAC","ignoreList":[]}
@@ -0,0 +1,38 @@
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 { expect, test } from "vitest";
18
+ import { getInputHtmlEntrypoints } from "../getInputHtmlEntrypoints.js";
19
+ function mockOptions(input) {
20
+ return {
21
+ input
22
+ };
23
+ }
24
+ test("getInputHtmlEntrypoints with array input", () => {
25
+ const options = mockOptions(["one.html", "two.html", "three.html"]);
26
+ const result = getInputHtmlEntrypoints(options);
27
+ expect(result).toEqual(["one.html", "two.html", "three.html"]);
28
+ });
29
+ test("getInputHtmlEntrypoints with object input", () => {
30
+ const options = mockOptions({
31
+ main: "one.html",
32
+ unrelated: "two.html",
33
+ three: "three.html"
34
+ });
35
+ const result = getInputHtmlEntrypoints(options);
36
+ expect(result).toEqual(["one.html", "two.html", "three.html"]);
37
+ });
38
+ //# sourceMappingURL=getInputHtmlEntrypoints.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getInputHtmlEntrypoints.test.js","names":["expect","test","getInputHtmlEntrypoints","mockOptions","input","options","result","toEqual","main","unrelated","three"],"sources":["getInputHtmlEntrypoints.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 type { Rollup } from \"vite\";\nimport { expect, test } from \"vitest\";\nimport { getInputHtmlEntrypoints } from \"../getInputHtmlEntrypoints.js\";\n\nfunction mockOptions(\n input: Rollup.NormalizedInputOptions[\"input\"],\n) {\n return { input } as Rollup.NormalizedInputOptions;\n}\n\ntest(\"getInputHtmlEntrypoints with array input\", () => {\n const options = mockOptions([\"one.html\", \"two.html\", \"three.html\"]);\n const result = getInputHtmlEntrypoints(options);\n expect(result).toEqual([\"one.html\", \"two.html\", \"three.html\"]);\n});\n\ntest(\"getInputHtmlEntrypoints with object input\", () => {\n const options = mockOptions({\n main: \"one.html\",\n unrelated: \"two.html\",\n three: \"three.html\",\n });\n\n const result = getInputHtmlEntrypoints(options);\n expect(result).toEqual([\"one.html\", \"two.html\", \"three.html\"]);\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,MAAM,EAAEC,IAAI,QAAQ,QAAQ;AACrC,SAASC,uBAAuB,QAAQ,+BAA+B;AAEvE,SAASC,WAAWA,CAClBC,KAA6C,EAC7C;EACA,OAAO;IAAEA;EAAM,CAAC;AAClB;AAEAH,IAAI,CAAC,0CAA0C,EAAE,MAAM;EACrD,MAAMI,OAAO,GAAGF,WAAW,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;EACnE,MAAMG,MAAM,GAAGJ,uBAAuB,CAACG,OAAO,CAAC;EAC/CL,MAAM,CAACM,MAAM,CAAC,CAACC,OAAO,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;AAChE,CAAC,CAAC;AAEFN,IAAI,CAAC,2CAA2C,EAAE,MAAM;EACtD,MAAMI,OAAO,GAAGF,WAAW,CAAC;IAC1BK,IAAI,EAAE,UAAU;IAChBC,SAAS,EAAE,UAAU;IACrBC,KAAK,EAAE;EACT,CAAC,CAAC;EAEF,MAAMJ,MAAM,GAAGJ,uBAAuB,CAACG,OAAO,CAAC;EAC/CL,MAAM,CAACM,MAAM,CAAC,CAACC,OAAO,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;AAChE,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,23 @@
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 PALANTIR_PATH = ".palantir";
18
+ export const SETUP_PATH = `${PALANTIR_PATH}/setup`;
19
+ export const ENTRYPOINTS_PATH = `${PALANTIR_PATH}/entrypoints`;
20
+ export const FINISH_PATH = `${PALANTIR_PATH}/finish`;
21
+ export const VITE_INJECTIONS_PATH = `${PALANTIR_PATH}/vite-injections.js`;
22
+ export const CONFIG_FILE_SUFFIX = ".config";
23
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","names":["PALANTIR_PATH","SETUP_PATH","ENTRYPOINTS_PATH","FINISH_PATH","VITE_INJECTIONS_PATH","CONFIG_FILE_SUFFIX"],"sources":["constants.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 const PALANTIR_PATH: string = \".palantir\";\nexport const SETUP_PATH: string = `${PALANTIR_PATH}/setup`;\nexport const ENTRYPOINTS_PATH: string = `${PALANTIR_PATH}/entrypoints`;\nexport const FINISH_PATH: string = `${PALANTIR_PATH}/finish`;\nexport const VITE_INJECTIONS_PATH: string =\n `${PALANTIR_PATH}/vite-injections.js`;\nexport const CONFIG_FILE_SUFFIX = \".config\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMA,aAAqB,GAAG,WAAW;AAChD,OAAO,MAAMC,UAAkB,GAAG,GAAGD,aAAa,QAAQ;AAC1D,OAAO,MAAME,gBAAwB,GAAG,GAAGF,aAAa,cAAc;AACtE,OAAO,MAAMG,WAAmB,GAAG,GAAGH,aAAa,SAAS;AAC5D,OAAO,MAAMI,oBAA4B,GACvC,GAAGJ,aAAa,qBAAqB;AACvC,OAAO,MAAMK,kBAAkB,GAAG,SAAS","ignoreList":[]}
@@ -0,0 +1,69 @@
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 escodegen from "escodegen";
18
+ const DEFINE_CONFIG_FUNCTION = "defineConfig";
19
+ export function extractWidgetConfig(moduleId, ast) {
20
+ // Lightly traverse the AST of the config file to extract out the actual object
21
+ const defaultExport = ast?.body.find(node => node.type === "ExportDefaultDeclaration");
22
+ if (defaultExport == null) {
23
+ throw new Error("Widget configuration object must be the default export in " + moduleId);
24
+ }
25
+
26
+ /**
27
+ * export default defineConfig({
28
+ * })
29
+ */
30
+ if (defaultExport.declaration.type === "CallExpression" && defaultExport.declaration.callee.type === "Identifier" && defaultExport.declaration.callee.name === DEFINE_CONFIG_FUNCTION && defaultExport.declaration.arguments[0].type === "ObjectExpression") {
31
+ return parseWidgetConfig(defaultExport.declaration.arguments[0]);
32
+ }
33
+
34
+ /**
35
+ * const MyConfig = defineConfig({
36
+ * })
37
+ * export default MyConfig;
38
+ */
39
+ if (defaultExport.declaration.type === "Identifier") {
40
+ const variableName = defaultExport.declaration.name;
41
+ for (const node of ast?.body ?? []) {
42
+ const declaration = node.type === "VariableDeclaration" ? node : node.type === "ExportNamedDeclaration" ? node.declaration : undefined;
43
+ if (declaration == null || declaration.type !== "VariableDeclaration") {
44
+ continue;
45
+ }
46
+ if (declaration.declarations.some(inner => inner.id.type === "Identifier" && inner.id.name === variableName)) {
47
+ const variableDeclarator = declaration.declarations.find(declarator => declarator.id.type === "Identifier" && declarator.id.name === variableName);
48
+ if (variableDeclarator?.init?.type === "CallExpression" && variableDeclarator.init.callee.type === "Identifier" && variableDeclarator.init.callee.name === DEFINE_CONFIG_FUNCTION && variableDeclarator.init.arguments[0].type === "ObjectExpression") {
49
+ return parseWidgetConfig(variableDeclarator.init.arguments[0]);
50
+ }
51
+ }
52
+ }
53
+ }
54
+ }
55
+ function parseWidgetConfig(objectExpression) {
56
+ // Convert from AST -> JS string
57
+ let widgetConfigString = escodegen.generate(objectExpression);
58
+ // The output JS string is not valid JSON, so we force it into JSON that we can then print out into a JSON file
59
+
60
+ // Wrap keys in double quotes
61
+ widgetConfigString = widgetConfigString.replace(/([^\s:]+):/g, "\"$1\":");
62
+ // Convert single quote string values to double quotes
63
+ widgetConfigString = widgetConfigString.replace(/: '(.+)'/g, ": \"$1\"");
64
+
65
+ // Convert single quote string values in arrays to double quotes
66
+ widgetConfigString = widgetConfigString.replace(/: \['(.+)'\]/g, ": [\"$1\"]");
67
+ return JSON.parse(widgetConfigString);
68
+ }
69
+ //# sourceMappingURL=extractWidgetConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extractWidgetConfig.js","names":["escodegen","DEFINE_CONFIG_FUNCTION","extractWidgetConfig","moduleId","ast","defaultExport","body","find","node","type","Error","declaration","callee","name","arguments","parseWidgetConfig","variableName","undefined","declarations","some","inner","id","variableDeclarator","declarator","init","objectExpression","widgetConfigString","generate","replace","JSON","parse"],"sources":["extractWidgetConfig.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 { ParameterConfig, WidgetConfig } from \"@osdk/widget.api\";\nimport escodegen from \"escodegen\";\nimport type { ObjectExpression } from \"estree\";\nimport type { Rollup } from \"vite\";\n\nconst DEFINE_CONFIG_FUNCTION = \"defineConfig\";\n\nexport function extractWidgetConfig(\n moduleId: string,\n ast: Rollup.ProgramNode | null,\n): WidgetConfig<ParameterConfig> | undefined {\n // Lightly traverse the AST of the config file to extract out the actual object\n const defaultExport = ast?.body.find(\n (node) => node.type === \"ExportDefaultDeclaration\",\n );\n if (defaultExport == null) {\n throw new Error(\n \"Widget configuration object must be the default export in \"\n + moduleId,\n );\n }\n\n /**\n * export default defineConfig({\n * })\n */\n if (\n defaultExport.declaration.type === \"CallExpression\"\n && defaultExport.declaration.callee.type === \"Identifier\"\n && defaultExport.declaration.callee.name === DEFINE_CONFIG_FUNCTION\n && defaultExport.declaration.arguments[0].type === \"ObjectExpression\"\n ) {\n return parseWidgetConfig(defaultExport.declaration.arguments[0]);\n }\n\n /**\n * const MyConfig = defineConfig({\n * })\n * export default MyConfig;\n */\n if (defaultExport.declaration.type === \"Identifier\") {\n const variableName = defaultExport.declaration.name;\n for (const node of ast?.body ?? []) {\n const declaration = node.type === \"VariableDeclaration\"\n ? node\n : node.type === \"ExportNamedDeclaration\"\n ? node.declaration\n : undefined;\n if (\n declaration == null\n || declaration.type !== \"VariableDeclaration\"\n ) {\n continue;\n }\n if (\n declaration.declarations.some(\n (inner) =>\n inner.id.type === \"Identifier\"\n && inner.id.name === variableName,\n )\n ) {\n const variableDeclarator = declaration.declarations.find(\n (declarator) =>\n declarator.id.type === \"Identifier\"\n && declarator.id.name === variableName,\n );\n if (\n variableDeclarator?.init?.type === \"CallExpression\"\n && variableDeclarator.init.callee.type === \"Identifier\"\n && variableDeclarator.init.callee.name === DEFINE_CONFIG_FUNCTION\n && variableDeclarator.init.arguments[0].type\n === \"ObjectExpression\"\n ) {\n return parseWidgetConfig(variableDeclarator.init.arguments[0]);\n }\n }\n }\n }\n}\n\nfunction parseWidgetConfig(\n objectExpression: ObjectExpression,\n): WidgetConfig<ParameterConfig> {\n // Convert from AST -> JS string\n let widgetConfigString = escodegen.generate(objectExpression);\n // The output JS string is not valid JSON, so we force it into JSON that we can then print out into a JSON file\n\n // Wrap keys in double quotes\n widgetConfigString = widgetConfigString.replace(/([^\\s:]+):/g, \"\\\"$1\\\":\");\n // Convert single quote string values to double quotes\n widgetConfigString = widgetConfigString.replace(/: '(.+)'/g, \": \\\"$1\\\"\");\n\n // Convert single quote string values in arrays to double quotes\n widgetConfigString = widgetConfigString.replace(\n /: \\['(.+)'\\]/g,\n \": [\\\"$1\\\"]\",\n );\n\n return JSON.parse(widgetConfigString) as WidgetConfig<ParameterConfig>;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAOA,SAAS,MAAM,WAAW;AAIjC,MAAMC,sBAAsB,GAAG,cAAc;AAE7C,OAAO,SAASC,mBAAmBA,CACjCC,QAAgB,EAChBC,GAA8B,EACa;EAC3C;EACA,MAAMC,aAAa,GAAGD,GAAG,EAAEE,IAAI,CAACC,IAAI,CACjCC,IAAI,IAAKA,IAAI,CAACC,IAAI,KAAK,0BAC1B,CAAC;EACD,IAAIJ,aAAa,IAAI,IAAI,EAAE;IACzB,MAAM,IAAIK,KAAK,CACb,4DAA4D,GACxDP,QACN,CAAC;EACH;;EAEA;AACF;AACA;AACA;EACE,IACEE,aAAa,CAACM,WAAW,CAACF,IAAI,KAAK,gBAAgB,IAChDJ,aAAa,CAACM,WAAW,CAACC,MAAM,CAACH,IAAI,KAAK,YAAY,IACtDJ,aAAa,CAACM,WAAW,CAACC,MAAM,CAACC,IAAI,KAAKZ,sBAAsB,IAChEI,aAAa,CAACM,WAAW,CAACG,SAA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,iBAAiB,CAACO,kBAAkB,CAACE,IAAI,CAACV,SAAS,CAAC,CAAC,CAAC,CAAC;QAChE;MACF;IACF;EACF;AACF;AAEA,SAASC,iBAAiBA,CACxBU,gBAAkC,EACH;EAC/B;EACA,IAAIC,kBAAkB,GAAG1B,SAAS,CAAC2B,QAAQ,CAACF,gBAAgB,CAAC;EAC7D;;EAEA;EACAC,kBAAkB,GAAGA,kBAAkB,CAACE,OAAO,CAAC,aAAa,EAAE,SAAS,CAAC;EACzE;EACAF,kBAAkB,GAAGA,kBAAkB,CAACE,OAAO,CAAC,WAAW,EAAE,UAAU,CAAC;;EAExE;EACAF,kBAAkB,GAAGA,kBAAkB,CAACE,OAAO,CAC7C,eAAe,EACf,YACF,CAAC;EAED,OAAOC,IAAI,CAACC,KAAK,CAACJ,kBAAkB,CAAC;AACvC","ignoreList":[]}
@@ -0,0 +1,29 @@
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
+ /**
18
+ * Get a standardize list of entrypoints from the possible Vite config formats.
19
+ */
20
+ export function getInputHtmlEntrypoints(options) {
21
+ if (Array.isArray(options.input)) {
22
+ return options.input;
23
+ }
24
+ if (options.input != null) {
25
+ return Object.values(options.input);
26
+ }
27
+ throw new Error("Widget entrypoints were not found in the expected Vite config format");
28
+ }
29
+ //# sourceMappingURL=getInputHtmlEntrypoints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getInputHtmlEntrypoints.js","names":["getInputHtmlEntrypoints","options","Array","isArray","input","Object","values","Error"],"sources":["getInputHtmlEntrypoints.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 { Rollup } from \"vite\";\n\n/**\n * Get a standardize list of entrypoints from the possible Vite config formats.\n */\nexport function getInputHtmlEntrypoints(\n options: Rollup.NormalizedInputOptions,\n): string[] {\n if (Array.isArray(options.input)) {\n return options.input;\n }\n if (options.input != null) {\n return Object.values(options.input);\n }\n throw new Error(\n \"Widget entrypoints were not found in the expected Vite config format\",\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA;AACA;AACA,OAAO,SAASA,uBAAuBA,CACrCC,OAAsC,EAC5B;EACV,IAAIC,KAAK,CAACC,OAAO,CAACF,OAAO,CAACG,KAAK,CAAC,EAAE;IAChC,OAAOH,OAAO,CAACG,KAAK;EACtB;EACA,IAAIH,OAAO,CAACG,KAAK,IAAI,IAAI,EAAE;IACzB,OAAOC,MAAM,CAACC,MAAM,CAACL,OAAO,CAACG,KAAK,CAAC;EACrC;EACA,MAAM,IAAIG,KAAK,CACb,sEACF,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,24 @@
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
+ export function safeGetEnvVar(env, name, errorMessage) {
18
+ const envVar = env[name];
19
+ if (envVar == null) {
20
+ throw new Error(`${name} environment variable not found. ${errorMessage}`);
21
+ }
22
+ return envVar;
23
+ }
24
+ //# sourceMappingURL=safeGetEnvVar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safeGetEnvVar.js","names":["safeGetEnvVar","env","name","errorMessage","envVar","Error"],"sources":["safeGetEnvVar.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\nexport function safeGetEnvVar(\n env: NodeJS.ProcessEnv,\n name: string,\n errorMessage: string,\n): string {\n const envVar = env[name];\n if (envVar == null) {\n throw new Error(`${name} environment variable not found. ${errorMessage}`);\n }\n return envVar;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,SAASA,aAAaA,CAC3BC,GAAsB,EACtBC,IAAY,EACZC,YAAoB,EACZ;EACR,MAAMC,MAAM,GAAGH,GAAG,CAACC,IAAI,CAAC;EACxB,IAAIE,MAAM,IAAI,IAAI,EAAE;IAClB,MAAM,IAAIC,KAAK,CAAC,GAAGH,IAAI,oCAAoCC,YAAY,EAAE,CAAC;EAC5E;EACA,OAAOC,MAAM;AACf","ignoreList":[]}
@@ -0,0 +1,25 @@
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
+ /**
18
+ * Users may import `.js` files in their code, where the source file is actually a `.ts`, `.tsx`, or
19
+ * `.jsx` file on disk. This standardizes these file extension to `.js` so that we can match imports
20
+ * to source files.
21
+ */
22
+ export function standardizeFileExtension(file) {
23
+ return file.replace(/\.[jt]sx?$/, ".js");
24
+ }
25
+ //# sourceMappingURL=standardizeFileExtension.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standardizeFileExtension.js","names":["standardizeFileExtension","file","replace"],"sources":["standardizeFileExtension.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\n/**\n * Users may import `.js` files in their code, where the source file is actually a `.ts`, `.tsx`, or\n * `.jsx` file on disk. This standardizes these file extension to `.js` so that we can match imports\n * to source files.\n */\nexport function standardizeFileExtension(file: string): string {\n return file.replace(/\\.[jt]sx?$/, \".js\");\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,wBAAwBA,CAACC,IAAY,EAAU;EAC7D,OAAOA,IAAI,CAACC,OAAO,CAAC,YAAY,EAAE,KAAK,CAAC;AAC1C","ignoreList":[]}
@@ -0,0 +1,193 @@
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 path from "node:path";
18
+ import { fileURLToPath } from "node:url";
19
+ import color from "picocolors";
20
+ import sirv from "sirv";
21
+ import { CONFIG_FILE_SUFFIX, ENTRYPOINTS_PATH, FINISH_PATH, SETUP_PATH, VITE_INJECTIONS_PATH } from "../common/constants.js";
22
+ import { extractWidgetConfig } from "../common/extractWidgetConfig.js";
23
+ import { getInputHtmlEntrypoints } from "../common/getInputHtmlEntrypoints.js";
24
+ import { standardizeFileExtension } from "../common/standardizeFileExtension.js";
25
+ import { extractInjectedScripts } from "./extractInjectedScripts.js";
26
+ import { getBaseHref } from "./getBaseHref.js";
27
+ import { getFoundryToken } from "./getFoundryToken.js";
28
+ import { getWidgetIdOverrideMap } from "./getWidgetIdOverrideMap.js";
29
+ import { publishDevModeSettings } from "./publishDevModeSettings.js";
30
+
31
+ // Location of the setup page assets
32
+ const DIR_DIST = typeof __dirname !== "undefined" ? __dirname : path.dirname(fileURLToPath(import.meta.url));
33
+ export function FoundryWidgetDevPlugin() {
34
+ // The root HTML entrypoints of the build process
35
+ let htmlEntrypoints;
36
+ // Fully resolved paths to the entrypoint files, mapped to relative paths
37
+ const codeEntrypoints = {};
38
+ // Store the map of fully resolved config file paths to entrypoint file paths
39
+ const configFileToEntrypoint = {};
40
+ // Store the configuration per module ID, e.g. /repo/src/widget-one.config.ts -> { ... }
41
+ const configFiles = {};
42
+ return {
43
+ name: "@osdk:widget-dev-plugin",
44
+ enforce: "pre",
45
+ /**
46
+ * Capture the entrypoints from the Vite config so that we can manually load them on our
47
+ * setup page and trigger module parsing.
48
+ */
49
+ buildStart(options) {
50
+ htmlEntrypoints = getInputHtmlEntrypoints(options);
51
+ },
52
+ /**
53
+ * Check for the required token environment variable in dev mode.
54
+ */
55
+ config(resolvedConfig, {
56
+ command
57
+ }) {
58
+ // Only check for the token environment variable when running in dev mode.
59
+ // When command is "serve" and not in test mode (VITEST).
60
+ if (command === "serve" && process.env.VITEST == null) {
61
+ getFoundryToken(resolvedConfig.mode);
62
+ }
63
+ },
64
+ /**
65
+ * Configure the Vite server to serve the setup page and handle the finish endpoint. This
66
+ * endpoint will set the widget overrides in Foundry and enable dev mode.
67
+ */
68
+ configureServer(server) {
69
+ // Override the printUrls function to print the setup page URL
70
+ server.printUrls = () => printSetupPageUrl(server);
71
+
72
+ /**
73
+ * Redirect `./.palantir/setup` to `./.palantir/setup/` to ensure that relative paths work
74
+ * correctly. Relative paths must be used so that the dev server UI can be accessed on
75
+ * non-root paths.
76
+ */
77
+ server.middlewares.use(serverPath(server, SETUP_PATH), (req, res, next) => {
78
+ if (req.originalUrl?.endsWith(serverPath(server, SETUP_PATH))) {
79
+ res.statusCode = 301;
80
+ res.setHeader("Location", `${serverPath(server, SETUP_PATH)}/`);
81
+ res.end();
82
+ } else {
83
+ next();
84
+ }
85
+ });
86
+
87
+ /**
88
+ * Serve the setup page that will load the entrypoints in iframes and trigger the finish
89
+ * endpoint once widgets have been loaded.
90
+ */
91
+ server.middlewares.use(serverPath(server, SETUP_PATH), sirv(path.resolve(DIR_DIST, "../../site"), {
92
+ single: true,
93
+ dev: true
94
+ }));
95
+
96
+ /**
97
+ * Make the entrypoints available to the setup page so that it can load them in iframes in
98
+ * order to trigger module parsing.
99
+ */
100
+ server.middlewares.use(serverPath(server, ENTRYPOINTS_PATH), (_, res) => {
101
+ res.setHeader("Content-Type", "application/json");
102
+ res.end(JSON.stringify(htmlEntrypoints.map(entrypoint => serverPath(server, entrypoint))));
103
+ });
104
+
105
+ /**
106
+ * Finish the setup process by setting the widget overrides in Foundry and enabling dev mode.
107
+ */
108
+ server.middlewares.use(serverPath(server, FINISH_PATH), async (_, res) => {
109
+ // Wait for the setup page to trigger the parsing of the config files
110
+ const numEntrypoints = htmlEntrypoints.length;
111
+ const numConfigFiles = Object.keys(configFiles).length;
112
+ if (numConfigFiles < numEntrypoints) {
113
+ res.setHeader("Content-Type", "application/json");
114
+ res.end(JSON.stringify({
115
+ status: "pending"
116
+ }));
117
+ return;
118
+ }
119
+
120
+ // Prepare the widget overrides and finish the setup process
121
+ const widgetIdToOverrides = await getWidgetIdOverrideMap(server, codeEntrypoints, configFileToEntrypoint, configFiles, getBaseHref(server));
122
+ await publishDevModeSettings(server, widgetIdToOverrides, getBaseHref(server), res);
123
+ });
124
+
125
+ /**
126
+ * Serve scripts that would usually be injected into the HTML if Vite had control over the
127
+ * serving of index HTML pages. This is necessary to ensure that plugins like React refresh
128
+ * work correctly.
129
+ */
130
+ server.middlewares.use(serverPath(server, VITE_INJECTIONS_PATH), async (_, res) => {
131
+ res.setHeader("Access-Control-Allow-Origin", "*");
132
+ res.setHeader("Content-Type", "application/javascript");
133
+ const injectedScripts = await extractInjectedScripts(server);
134
+ res.end(injectedScripts.inlineScripts.join("\n"));
135
+ });
136
+ },
137
+ /**
138
+ * As module imports are resolved, we need to capture the entrypoint file paths and the config
139
+ * file paths that are imported from them.
140
+ */
141
+ resolveId(source, importer) {
142
+ if (importer == null) {
143
+ return;
144
+ }
145
+
146
+ // Standardize the source file extension and get the full path
147
+ const standardizedSource = standardizeFileExtension(getFullSourcePath(source.slice(1), importer));
148
+ // Importers are already full paths, so just standardize the extension
149
+ const standardizedImporter = standardizeFileExtension(importer);
150
+
151
+ // In dev mode all entrypoints have a generic HTML importer value
152
+ if (importer.endsWith("index.html") && !standardizedSource.includes("@fs")) {
153
+ // Store the fully resolved path and the relative path, as we need the former for mapping
154
+ // config files to entrypoints and the latter as a dev mode override script
155
+ codeEntrypoints[standardizedSource] = source;
156
+ }
157
+
158
+ // Look for config files that are imported from an entrypoint file
159
+ if (standardizedSource.replace(/\.[^/.]+$/, "").endsWith(CONFIG_FILE_SUFFIX) && codeEntrypoints[standardizedImporter] != null) {
160
+ const fullSourcePath = standardizeFileExtension(getFullSourcePath(source, standardizedImporter));
161
+ configFileToEntrypoint[fullSourcePath] = standardizedImporter;
162
+ }
163
+ },
164
+ /**
165
+ * During dev mode we need to parse the AST of the config files to extract the widget config
166
+ * object manually, as Vite doesn't compile files during dev mode.
167
+ */
168
+ transform(code, id) {
169
+ const standardizedSource = standardizeFileExtension(id);
170
+ if (configFileToEntrypoint[standardizedSource] != null) {
171
+ const configObject = extractWidgetConfig(id, this.parse(code));
172
+ if (configObject != null) {
173
+ configFiles[standardizedSource] = configObject;
174
+ }
175
+ }
176
+ }
177
+ };
178
+ }
179
+
180
+ /**
181
+ * During the resolution phase source are given as relative paths to the importer
182
+ */
183
+ function getFullSourcePath(source, importer) {
184
+ return path.resolve(path.dirname(importer), source);
185
+ }
186
+ function serverPath(server, subPath) {
187
+ return path.resolve(server.config.base, subPath);
188
+ }
189
+ function printSetupPageUrl(server) {
190
+ const setupRoute = `${getBaseHref(server)}${SETUP_PATH}/`;
191
+ server.config.logger.info(` ${color.green("➜")} ${color.bold("Click to enter developer mode for your widget set")}: ${color.green(setupRoute)}`);
192
+ }
193
+ //# sourceMappingURL=FoundryWidgetDevPlugin.js.map