@osdk/widget.vite-plugin 3.1.0-beta.3 → 3.1.0-beta.4

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 (35) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/build/esm/build-plugin/FoundryWidgetBuildPlugin.js +3 -1
  3. package/build/esm/build-plugin/FoundryWidgetBuildPlugin.js.map +1 -1
  4. package/build/esm/build-plugin/__tests__/getWidgetSetInputSpec.test.js +96 -0
  5. package/build/esm/build-plugin/__tests__/getWidgetSetInputSpec.test.js.map +1 -0
  6. package/build/esm/build-plugin/__tests__/isConfigFile.test.js +26 -0
  7. package/build/esm/build-plugin/__tests__/isConfigFile.test.js.map +1 -0
  8. package/build/esm/build-plugin/buildWidgetSetManifest.js +3 -2
  9. package/build/esm/build-plugin/buildWidgetSetManifest.js.map +1 -1
  10. package/build/esm/build-plugin/getWidgetSetInputSpec.js +44 -0
  11. package/build/esm/build-plugin/getWidgetSetInputSpec.js.map +1 -0
  12. package/build/esm/build-plugin/isConfigFile.js +1 -1
  13. package/build/esm/build-plugin/isConfigFile.js.map +1 -1
  14. package/build/esm/common/PackageJson.js +2 -0
  15. package/build/esm/common/PackageJson.js.map +1 -0
  16. package/build/esm/common/__tests__/visitNpmPackages.test.js +74 -0
  17. package/build/esm/common/__tests__/visitNpmPackages.test.js.map +1 -0
  18. package/build/esm/common/visitNpmPackages.js +62 -0
  19. package/build/esm/common/visitNpmPackages.js.map +1 -0
  20. package/build/types/build-plugin/FoundryWidgetBuildPlugin.d.ts.map +1 -1
  21. package/build/types/build-plugin/__tests__/getWidgetSetInputSpec.test.d.ts +1 -0
  22. package/build/types/build-plugin/__tests__/getWidgetSetInputSpec.test.d.ts.map +1 -0
  23. package/build/types/build-plugin/__tests__/isConfigFile.test.d.ts +1 -0
  24. package/build/types/build-plugin/__tests__/isConfigFile.test.d.ts.map +1 -0
  25. package/build/types/build-plugin/buildWidgetSetManifest.d.ts +2 -2
  26. package/build/types/build-plugin/buildWidgetSetManifest.d.ts.map +1 -1
  27. package/build/types/build-plugin/getWidgetSetInputSpec.d.ts +2 -0
  28. package/build/types/build-plugin/getWidgetSetInputSpec.d.ts.map +1 -0
  29. package/build/types/common/PackageJson.d.ts +10 -0
  30. package/build/types/common/PackageJson.d.ts.map +1 -0
  31. package/build/types/common/__tests__/visitNpmPackages.test.d.ts +1 -0
  32. package/build/types/common/__tests__/visitNpmPackages.test.d.ts.map +1 -0
  33. package/build/types/common/visitNpmPackages.d.ts +4 -0
  34. package/build/types/common/visitNpmPackages.d.ts.map +1 -0
  35. package/package.json +3 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @osdk/widget.vite-plugin
2
2
 
3
+ ## 3.1.0-beta.4
4
+
5
+ ### Minor Changes
6
+
7
+ - 3744571: Discover widget set input specs
8
+ - 21c4954: fix isConfigFile to identify non-suffixed imports
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies [3744571]
13
+ - @osdk/widget.api@3.1.0-beta.4
14
+
3
15
  ## 3.1.0-beta.3
4
16
 
5
17
  ### Patch Changes
@@ -23,6 +23,7 @@ import { getInputHtmlEntrypoints } from "../common/getInputHtmlEntrypoints.js";
23
23
  import { standardizeFileExtension } from "../common/standardizeFileExtension.js";
24
24
  import { buildWidgetSetManifest } from "./buildWidgetSetManifest.js";
25
25
  import { getWidgetBuildOutputs } from "./getWidgetBuildOutputs.js";
26
+ import { getWidgetSetInputSpec } from "./getWidgetSetInputSpec.js";
26
27
  import { isConfigFile } from "./isConfigFile.js";
27
28
  export function FoundryWidgetBuildPlugin() {
28
29
  // The root HTML entrypoints of the build process
@@ -74,7 +75,8 @@ export function FoundryWidgetBuildPlugin() {
74
75
  // Build widget set manifest
75
76
  const widgetSetVersion = await computeWidgetSetVersion(foundryConfig);
76
77
  const widgetBuilds = htmlEntrypoints.map(input => getWidgetBuildOutputs(bundle, input, config.build.outDir, configFiles));
77
- const widgetSetManifest = buildWidgetSetManifest(foundryConfig.foundryConfig.widgetSet.rid, widgetSetVersion, widgetBuilds);
78
+ const widgetSetInputSpec = await getWidgetSetInputSpec(path.resolve(process.cwd(), "package.json"));
79
+ const widgetSetManifest = buildWidgetSetManifest(foundryConfig.foundryConfig.widgetSet.rid, widgetSetVersion, widgetBuilds, widgetSetInputSpec);
78
80
 
79
81
  // Write the manifest to the dist directory
80
82
  const manifestPath = path.join(config.build.outDir, MANIFEST_FILE_LOCATION);
@@ -1 +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;;AAGA,SAASA,WAAW,EAAEC,iBAAiB,QAAQ,2BAA2B;AAE1E,SAASC,sBAAsB,QAAQ,kBAAkB;AACzD,OAAOC,EAAE,MAAM,IAAI;AACnB,OAAOC,IAAI,MAAM,MAAM;AAEvB,SAASC,mBAAmB,QAAQ,kCAAkC;AACtE,SAASC,uBAAuB,QAAQ,sCAAsC;AAC9E,SAASC,wBAAwB,QAAQ,uCAAuC;AAChF,SAASC,sBAAsB,QAAQ,6BAA6B;AACpE,SAASC,qBAAqB,QAAQ,4BAA4B;AAClE,SAASC,YAAY,QAAQ,mBAAmB;AAEhD,OAAO,SAASC,wBAAwBA,CAAA,EAAW;EACjD;EACA,IAAIC,eAAyB;EAC7B;EACA,MAAMC,WAA0D,GAAG,CAAC,CAAC;EACrE,IAAIC,MAAsB;EAE1B,OAAO;IACLC,IAAI,EAAE,2BAA2B;IACjCC,OAAO,EAAE,KAAK;IAEd;AACJ;AACA;IACIC,UAAUA,CAACC,OAAO,EAAE;MAClBN,eAAe,GAAGN,uBAAuB,CAACY,OAAO,CAAC;IACpD,CAAC;IAED;AACJ;AACA;IACIC,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QAAEI,SAAS,EAAE;MAAK,CAAC,CAAC;MAC7D3C,EAAE,CAAC4C,aAAa,CACdL,YAAY,EACZM,IAAI,CAACC,SAAS,CAACV,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAC3C,CAAC;IACH;EACF,CAAC;AACH;AAEA,eAAeN,uBAAuBA,CACpCH,aAA+C,EAC9B;EACjB,OAAO9B,WAAW,CAChB8B,aAAa,CAACA,aAAa,CAACU,SAAS,CAACxC,WAAW,IAC5C;IAAE,MAAM,EAAE;EAAe,CAChC,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"FoundryWidgetBuildPlugin.js","names":["autoVersion","loadFoundryConfig","MANIFEST_FILE_LOCATION","fs","path","extractWidgetConfig","getInputHtmlEntrypoints","standardizeFileExtension","buildWidgetSetManifest","getWidgetBuildOutputs","getWidgetSetInputSpec","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","widgetSetInputSpec","resolve","process","cwd","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 { getWidgetSetInputSpec } from \"./getWidgetSetInputSpec.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 widgetSetInputSpec = await getWidgetSetInputSpec(\n path.resolve(process.cwd(), \"package.json\"),\n );\n const widgetSetManifest = buildWidgetSetManifest(\n foundryConfig.foundryConfig.widgetSet.rid,\n widgetSetVersion,\n widgetBuilds,\n widgetSetInputSpec,\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;;AAGA,SAASA,WAAW,EAAEC,iBAAiB,QAAQ,2BAA2B;AAE1E,SAASC,sBAAsB,QAAQ,kBAAkB;AACzD,OAAOC,EAAE,MAAM,IAAI;AACnB,OAAOC,IAAI,MAAM,MAAM;AAEvB,SAASC,mBAAmB,QAAQ,kCAAkC;AACtE,SAASC,uBAAuB,QAAQ,sCAAsC;AAC9E,SAASC,wBAAwB,QAAQ,uCAAuC;AAChF,SAASC,sBAAsB,QAAQ,6BAA6B;AACpE,SAASC,qBAAqB,QAAQ,4BAA4B;AAClE,SAASC,qBAAqB,QAAQ,4BAA4B;AAClE,SAASC,YAAY,QAAQ,mBAAmB;AAEhD,OAAO,SAASC,wBAAwBA,CAAA,EAAW;EACjD;EACA,IAAIC,eAAyB;EAC7B;EACA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OAAO,CAACC,OAAO,CAACC,GAAG,CAAC,CAAC,EAAE,cAAc,CAC5C,CAAC;MACD,MAAMC,iBAAiB,GAAGpC,sBAAsB,CAC9CuB,aAAa,CAACA,aAAa,CAACc,SAAS,CAACC,GAAG,EACzCb,gBAAgB,EAChBE,YAAY,EACZK,kBACF,CAAC;;MAED;MACA,MAAMO,YAAY,GAAG3C,IAAI,CAAC4C,IAAI,CAC5BjC,MAAM,CAACuB,KAAK,CAACC,MAAM,EACnBrC,sBACF,CAAC;MACDC,EAAE,CAAC8C,SAAS,CAAC7C,IAAI,CAAC8C,OAAO,CAACH,YAAY,CAAC,EAAE;QAAEI,SAAS,EAAE;MAAK,CAAC,CAAC;MAC7DhD,EAAE,CAACiD,aAAa,CACdL,YAAY,EACZM,IAAI,CAACC,SAAS,CAACV,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAC3C,CAAC;IACH;EACF,CAAC;AACH;AAEA,eAAeV,uBAAuBA,CACpCH,aAA+C,EAC9B;EACjB,OAAO/B,WAAW,CAChB+B,aAAa,CAACA,aAAa,CAACc,SAAS,CAAC7C,WAAW,IAC5C;IAAE,MAAM,EAAE;EAAe,CAChC,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,96 @@
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 { resolve } from "path";
18
+ import { expect, test, vi } from "vitest";
19
+ import { visitNpmPackages } from "../../common/visitNpmPackages.js";
20
+ import { getWidgetSetInputSpec } from "../getWidgetSetInputSpec.js";
21
+ vi.mock("../../common/visitNpmPackages.ts");
22
+ test("getWidgetSetInputSpec successfully discovers OSDK packages", async () => {
23
+ const packageJson1 = {
24
+ name: "package1",
25
+ version: "0.1.0",
26
+ dependencies: {
27
+ "package2": "0.2.0",
28
+ "package3": "0.3.0"
29
+ }
30
+ };
31
+ const packageJson2 = {
32
+ name: "package2",
33
+ version: "0.2.0",
34
+ dependencies: {
35
+ "package3": "0.3.0",
36
+ "package4": "0.4.0"
37
+ },
38
+ osdk: {
39
+ packageRid: "ridPackage2"
40
+ }
41
+ };
42
+ const packageJson3 = {
43
+ name: "package3",
44
+ version: "0.3.0",
45
+ dependencies: {
46
+ "package4": "0.4.1"
47
+ },
48
+ osdk: {
49
+ packageRid: "ridPackage3"
50
+ }
51
+ };
52
+ const packageJson4 = {
53
+ name: "package4",
54
+ version: "0.4.0",
55
+ osdk: {
56
+ packageRid: "ridPackage4"
57
+ }
58
+ };
59
+ const packageJson4_1 = {
60
+ name: "package4",
61
+ version: "0.4.1",
62
+ osdk: {
63
+ packageRid: "ridPackage4"
64
+ }
65
+ };
66
+ vi.mocked(visitNpmPackages).mockImplementation((packageJsonPath, onVisit) => {
67
+ onVisit(packageJsonPath, packageJson1);
68
+ onVisit(resolve(packageJsonPath, "/node_modules/package2@0.2.0/package.json"), packageJson2);
69
+ onVisit(resolve(packageJsonPath, "/node_modules/package3@0.3.0/package.json"), packageJson3);
70
+ // Handle multiple versions of same OSDK package
71
+ onVisit(resolve(packageJsonPath, "/node_modules/package4@0.4.0/package.json"), packageJson4);
72
+ onVisit(resolve(packageJsonPath, "/node_modules/package4@0.4.1/package.json"), packageJson4_1);
73
+ // Handle multiple occurrences of same version of OSDK package
74
+ onVisit(resolve(packageJsonPath, "/node_modules/package4@0.4.1/package.json"), packageJson4_1);
75
+ return Promise.resolve();
76
+ });
77
+ const widgetSetInputSpec = await getWidgetSetInputSpec("/path/to/package.json");
78
+ expect(widgetSetInputSpec).toEqual({
79
+ discovered: {
80
+ sdks: [{
81
+ rid: "ridPackage2",
82
+ version: "0.2.0"
83
+ }, {
84
+ rid: "ridPackage3",
85
+ version: "0.3.0"
86
+ }, {
87
+ rid: "ridPackage4",
88
+ version: "0.4.0"
89
+ }, {
90
+ rid: "ridPackage4",
91
+ version: "0.4.1"
92
+ }]
93
+ }
94
+ });
95
+ });
96
+ //# sourceMappingURL=getWidgetSetInputSpec.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getWidgetSetInputSpec.test.js","names":["resolve","expect","test","vi","visitNpmPackages","getWidgetSetInputSpec","mock","packageJson1","name","version","dependencies","packageJson2","osdk","packageRid","packageJson3","packageJson4","packageJson4_1","mocked","mockImplementation","packageJsonPath","onVisit","Promise","widgetSetInputSpec","toEqual","discovered","sdks","rid"],"sources":["getWidgetSetInputSpec.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 { resolve } from \"path\";\nimport { expect, test, vi } from \"vitest\";\nimport type { PackageJson } from \"../../common/PackageJson.js\";\nimport { visitNpmPackages } from \"../../common/visitNpmPackages.js\";\nimport { getWidgetSetInputSpec } from \"../getWidgetSetInputSpec.js\";\n\nvi.mock(\"../../common/visitNpmPackages.ts\");\n\ntest(\"getWidgetSetInputSpec successfully discovers OSDK packages\", async () => {\n const packageJson1: PackageJson = {\n name: \"package1\",\n version: \"0.1.0\",\n dependencies: {\n \"package2\": \"0.2.0\",\n \"package3\": \"0.3.0\",\n },\n };\n const packageJson2: PackageJson = {\n name: \"package2\",\n version: \"0.2.0\",\n dependencies: {\n \"package3\": \"0.3.0\",\n \"package4\": \"0.4.0\",\n },\n osdk: {\n packageRid: \"ridPackage2\",\n },\n };\n const packageJson3: PackageJson = {\n name: \"package3\",\n version: \"0.3.0\",\n dependencies: {\n \"package4\": \"0.4.1\",\n },\n osdk: {\n packageRid: \"ridPackage3\",\n },\n };\n const packageJson4: PackageJson = {\n name: \"package4\",\n version: \"0.4.0\",\n osdk: {\n packageRid: \"ridPackage4\",\n },\n };\n const packageJson4_1: PackageJson = {\n name: \"package4\",\n version: \"0.4.1\",\n osdk: {\n packageRid: \"ridPackage4\",\n },\n };\n\n vi.mocked(visitNpmPackages).mockImplementation(\n (packageJsonPath, onVisit) => {\n onVisit(packageJsonPath, packageJson1);\n onVisit(\n resolve(packageJsonPath, \"/node_modules/package2@0.2.0/package.json\"),\n packageJson2,\n );\n onVisit(\n resolve(packageJsonPath, \"/node_modules/package3@0.3.0/package.json\"),\n packageJson3,\n );\n // Handle multiple versions of same OSDK package\n onVisit(\n resolve(packageJsonPath, \"/node_modules/package4@0.4.0/package.json\"),\n packageJson4,\n );\n onVisit(\n resolve(packageJsonPath, \"/node_modules/package4@0.4.1/package.json\"),\n packageJson4_1,\n );\n // Handle multiple occurrences of same version of OSDK package\n onVisit(\n resolve(packageJsonPath, \"/node_modules/package4@0.4.1/package.json\"),\n packageJson4_1,\n );\n return Promise.resolve();\n },\n );\n const widgetSetInputSpec = await getWidgetSetInputSpec(\n \"/path/to/package.json\",\n );\n\n expect(widgetSetInputSpec).toEqual({\n discovered: {\n sdks: [\n { rid: \"ridPackage2\", version: \"0.2.0\" },\n { rid: \"ridPackage3\", version: \"0.3.0\" },\n { rid: \"ridPackage4\", version: \"0.4.0\" },\n { rid: \"ridPackage4\", version: \"0.4.1\" },\n ],\n },\n });\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,OAAO,QAAQ,MAAM;AAC9B,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AAO,CACLpB,OAAO,CAACmB,eAAe,EAAE,2CAA2C,CAAC,EACrEL,YACF,CAAC;IACD;IACAM,OAAO,CACLpB,OAAO,CAACmB,eAAe,EAAE,2CAA2C,CAAC,EACrEJ,YACF,CAAC;IACDK,OAAO,CACLpB,OAAO,CAACmB,eAAe,EAAE,2CAA2C,CAAC,EACrEH,cACF,CAAC;IACD;IACAI,OAAO,CACLpB,OAAO,CAACmB,eAAe,EAAE,2CAA2C,CAAC,EACrEH,cACF,CAAC;IACD,OAAOK,OAAO,CAACrB,OAAO,CAAC,CAAC;EAC1B,CACF,CAAC;EACD,MAAMsB,kBAAkB,GAAG,MAAMjB,qBAAqB,CACpD,uBACF,CAAC;EAEDJ,MAAM,CAACqB,kBAAkB,CAAC,CAACC,OAAO,CAAC;IACjCC,UAAU,EAAE;MACVC,IAAI,EAAE,CACJ;QAAEC,GAAG,EAAE,aAAa;QAAEjB,OAAO,EAAE;MAAQ,CAAC,EACxC;QAAEiB,GAAG,EAAE,aAAa;QAAEjB,OAAO,EAAE;MAAQ,CAAC,EACxC;QAAEiB,GAAG,EAAE,aAAa;QAAEjB,OAAO,EAAE;MAAQ,CAAC,EACxC;QAAEiB,GAAG,EAAE,aAAa;QAAEjB,OAAO,EAAE;MAAQ,CAAC;IAE5C;EACF,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,26 @@
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 { isConfigFile } from "../isConfigFile.js";
19
+ test("isConfigFile identifies config files", () => {
20
+ expect(isConfigFile("./widget.config.ts")).toBe(true);
21
+ expect(isConfigFile("./widget.config.js")).toBe(true);
22
+ expect(isConfigFile("/my-assets/widget.config")).toBe(true);
23
+ expect(isConfigFile("/assets/config")).toBe(false);
24
+ expect(isConfigFile("")).toBe(false);
25
+ });
26
+ //# sourceMappingURL=isConfigFile.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isConfigFile.test.js","names":["expect","test","isConfigFile","toBe"],"sources":["isConfigFile.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 { expect, test } from \"vitest\";\nimport { isConfigFile } from \"../isConfigFile.js\";\n\ntest(\"isConfigFile identifies config files\", () => {\n expect(isConfigFile(\"./widget.config.ts\")).toBe(true);\n expect(isConfigFile(\"./widget.config.js\")).toBe(true);\n expect(isConfigFile(\"/my-assets/widget.config\")).toBe(true);\n\n expect(isConfigFile(\"/assets/config\")).toBe(false);\n expect(isConfigFile(\"\")).toBe(false);\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,MAAM,EAAEC,IAAI,QAAQ,QAAQ;AACrC,SAASC,YAAY,QAAQ,oBAAoB;AAEjDD,IAAI,CAAC,sCAAsC,EAAE,MAAM;EACjDD,MAAM,CAACE,YAAY,CAAC,oBAAoB,CAAC,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC;EACrDH,MAAM,CAACE,YAAY,CAAC,oBAAoB,CAAC,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC;EACrDH,MAAM,CAACE,YAAY,CAAC,0BAA0B,CAAC,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC;EAE3DH,MAAM,CAACE,YAAY,CAAC,gBAAgB,CAAC,CAAC,CAACC,IAAI,CAAC,KAAK,CAAC;EAClDH,MAAM,CAACE,YAAY,CAAC,EAAE,CAAC,CAAC,CAACC,IAAI,CAAC,KAAK,CAAC;AACtC,CAAC,CAAC","ignoreList":[]}
@@ -14,13 +14,14 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- export function buildWidgetSetManifest(widgetSetRid, widgetSetVersion, widgetBuilds) {
17
+ export function buildWidgetSetManifest(widgetSetRid, widgetSetVersion, widgetBuilds, widgetSetInputSpec) {
18
18
  return {
19
19
  manifestVersion: "1.0.0",
20
20
  widgetSet: {
21
21
  rid: widgetSetRid,
22
22
  version: widgetSetVersion,
23
- widgets: Object.fromEntries(widgetBuilds.map(buildWidgetManifest).map(widgetManifest => [widgetManifest.id, widgetManifest]))
23
+ widgets: Object.fromEntries(widgetBuilds.map(buildWidgetManifest).map(widgetManifest => [widgetManifest.id, widgetManifest])),
24
+ inputSpec: widgetSetInputSpec
24
25
  }
25
26
  };
26
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"buildWidgetSetManifest.js","names":["buildWidgetSetManifest","widgetSetRid","widgetSetVersion","widgetBuilds","manifestVersion","widgetSet","rid","version","widgets","Object","fromEntries","map","buildWidgetManifest","widgetManifest","id","widgetBuild","widgetConfig","name","description","type","entrypointJs","scripts","script","path","trimLeadingSlash","src","scriptType","entrypointCss","stylesheets","parameters","events","startsWith","slice"],"sources":["buildWidgetSetManifest.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 { WidgetManifestConfig, WidgetSetManifest } from \"@osdk/widget.api\";\nimport type { WidgetBuildOutputs } from \"./getWidgetBuildOutputs.js\";\n\nexport function buildWidgetSetManifest(\n widgetSetRid: string,\n widgetSetVersion: string,\n widgetBuilds: WidgetBuildOutputs[],\n): WidgetSetManifest {\n return {\n manifestVersion: \"1.0.0\",\n widgetSet: {\n rid: widgetSetRid,\n version: widgetSetVersion,\n widgets: Object.fromEntries(\n widgetBuilds\n .map(buildWidgetManifest)\n .map((widgetManifest) => [widgetManifest.id, widgetManifest]),\n ),\n },\n };\n}\n\nfunction buildWidgetManifest(\n widgetBuild: WidgetBuildOutputs,\n): WidgetManifestConfig {\n const widgetConfig = widgetBuild.widgetConfig;\n return {\n id: widgetConfig.id,\n name: widgetConfig.name,\n description: widgetConfig.description,\n type: \"workshopWidgetV1\",\n entrypointJs: widgetBuild.scripts.map((script) => ({\n path: trimLeadingSlash(script.src),\n type: script.scriptType,\n })),\n entrypointCss: widgetBuild.stylesheets.map((path) => ({\n path: trimLeadingSlash(path),\n })),\n parameters: widgetConfig.parameters,\n events: widgetConfig.events,\n };\n}\n\nfunction trimLeadingSlash(path: string): string {\n return path.startsWith(\"/\") ? path.slice(1) : path;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA,OAAO,SAASA,sBAAsBA,CACpCC,YAAoB,EACpBC,gBAAwB,EACxBC,YAAkC,EACf;EACnB,OAAO;IACLC,eAAe,EAAE,OAAO;IACxBC,SAAS,EAAE;MACTC,GAAG,EAAEL,YAAY;MACjBM,OAAO,EAAEL,gBAAgB;MACzBM,OAAO,EAAEC,MAAM,CAACC,WAAW,CACzBP,YAAY,CACTQ,GAAG,CAACC,mBAAmB,CAAC,CACxBD,GAAG,CAAEE,cAAc,IAAK,CAACA,cAAc,CAACC,EAAE,EAAED,cAAc,CAAC,CAChE;IACF;EACF,CAAC;AACH;AAEA,SAASD,mBAAmBA,CAC1BG,WAA+B,EACT;EACtB,MAAMC,YAAY,GAAGD,WAAW,CAACC,YAAY;EAC7C,OAAO;IACLF,EAAE,EAAEE,YAAY,CAACF,EAAE;IACnBG,IAAI,EAAED,YAAY,CAACC,IAAI;IACvBC,WAAW,EAAEF,YAAY,CAACE,WAAW;IACrCC,IAAI,EAAE,kBAAkB;IACxBC,YAAY,EAAEL,WAAW,CAACM,OAAO,CAACV,GAAG,CAAEW,MAAM,KAAM;MACjDC,IAAI,EAAEC,gBAAgB,CAACF,MAAM,CAACG,GAAG,CAAC;MAClCN,IAAI,EAAEG,MAAM,CAACI;IACf,CAAC,CAAC,CAAC;IACHC,aAAa,EAAEZ,WAAW,CAACa,WAAW,CAACjB,GAAG,CAAEY,IAAI,KAAM;MACpDA,IAAI,EAAEC,gBAAgB,CAACD,IAAI;IAC7B,CAAC,CAAC,CAAC;IACHM,UAAU,EAAEb,YAAY,CAACa,UAAU;IACnCC,MAAM,EAAEd,YAAY,CAACc;EACvB,CAAC;AACH;AAEA,SAASN,gBAAgBA,CAACD,IAAY,EAAU;EAC9C,OAAOA,IAAI,CAACQ,UAAU,CAAC,GAAG,CAAC,GAAGR,IAAI,CAACS,KAAK,CAAC,CAAC,CAAC,GAAGT,IAAI;AACpD","ignoreList":[]}
1
+ {"version":3,"file":"buildWidgetSetManifest.js","names":["buildWidgetSetManifest","widgetSetRid","widgetSetVersion","widgetBuilds","widgetSetInputSpec","manifestVersion","widgetSet","rid","version","widgets","Object","fromEntries","map","buildWidgetManifest","widgetManifest","id","inputSpec","widgetBuild","widgetConfig","name","description","type","entrypointJs","scripts","script","path","trimLeadingSlash","src","scriptType","entrypointCss","stylesheets","parameters","events","startsWith","slice"],"sources":["buildWidgetSetManifest.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 {\n WidgetManifestConfig,\n WidgetSetInputSpec,\n WidgetSetManifest,\n} from \"@osdk/widget.api\";\nimport type { WidgetBuildOutputs } from \"./getWidgetBuildOutputs.js\";\n\nexport function buildWidgetSetManifest(\n widgetSetRid: string,\n widgetSetVersion: string,\n widgetBuilds: WidgetBuildOutputs[],\n widgetSetInputSpec: WidgetSetInputSpec,\n): WidgetSetManifest {\n return {\n manifestVersion: \"1.0.0\",\n widgetSet: {\n rid: widgetSetRid,\n version: widgetSetVersion,\n widgets: Object.fromEntries(\n widgetBuilds\n .map(buildWidgetManifest)\n .map((widgetManifest) => [widgetManifest.id, widgetManifest]),\n ),\n inputSpec: widgetSetInputSpec,\n },\n };\n}\n\nfunction buildWidgetManifest(\n widgetBuild: WidgetBuildOutputs,\n): WidgetManifestConfig {\n const widgetConfig = widgetBuild.widgetConfig;\n return {\n id: widgetConfig.id,\n name: widgetConfig.name,\n description: widgetConfig.description,\n type: \"workshopWidgetV1\",\n entrypointJs: widgetBuild.scripts.map((script) => ({\n path: trimLeadingSlash(script.src),\n type: script.scriptType,\n })),\n entrypointCss: widgetBuild.stylesheets.map((path) => ({\n path: trimLeadingSlash(path),\n })),\n parameters: widgetConfig.parameters,\n events: widgetConfig.events,\n };\n}\n\nfunction trimLeadingSlash(path: string): string {\n return path.startsWith(\"/\") ? path.slice(1) : path;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;A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CAAC,CAAC,CAAC,GAAGT,IAAI;AACpD","ignoreList":[]}
@@ -0,0 +1,44 @@
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 { visitNpmPackages } from "../common/visitNpmPackages.js";
18
+ export async function getWidgetSetInputSpec(packageJsonPath) {
19
+ const sdks = await discoverOntologySdkInputSpecs(packageJsonPath);
20
+ return {
21
+ discovered: {
22
+ sdks
23
+ }
24
+ };
25
+ }
26
+ async function discoverOntologySdkInputSpecs(packageJsonPath) {
27
+ const sdks = new Set();
28
+ await visitNpmPackages(packageJsonPath, (_packageJsonPath, packageJson) => {
29
+ if (packageJson.osdk?.packageRid != null) {
30
+ sdks.add(toKey(packageJson.osdk.packageRid, packageJson.version));
31
+ }
32
+ });
33
+ return [...sdks].map(fromKey);
34
+ }
35
+ const SEPARATOR = "//";
36
+ const toKey = (rid, version) => `${rid}${SEPARATOR}${version}`;
37
+ const fromKey = key => {
38
+ const [rid, version] = key.split(SEPARATOR);
39
+ return {
40
+ rid,
41
+ version
42
+ };
43
+ };
44
+ //# sourceMappingURL=getWidgetSetInputSpec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getWidgetSetInputSpec.js","names":["visitNpmPackages","getWidgetSetInputSpec","packageJsonPath","sdks","discoverOntologySdkInputSpecs","discovered","Set","_packageJsonPath","packageJson","osdk","packageRid","add","toKey","version","map","fromKey","SEPARATOR","rid","key","split"],"sources":["getWidgetSetInputSpec.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 {\n OntologySdkInputSpec,\n WidgetSetInputSpec,\n} from \"@osdk/widget.api\";\nimport type { PackageJson } from \"../common/PackageJson.js\";\nimport { visitNpmPackages } from \"../common/visitNpmPackages.js\";\n\nexport async function getWidgetSetInputSpec(\n packageJsonPath: string,\n): Promise<WidgetSetInputSpec> {\n const sdks = await discoverOntologySdkInputSpecs(packageJsonPath);\n return {\n discovered: {\n sdks,\n },\n };\n}\n\nasync function discoverOntologySdkInputSpecs(\n packageJsonPath: string,\n): Promise<Array<OntologySdkInputSpec>> {\n const sdks = new Set<string>();\n const onVisit = (_packageJsonPath: string, packageJson: PackageJson) => {\n if (packageJson.osdk?.packageRid != null) {\n sdks.add(toKey(packageJson.osdk.packageRid, packageJson.version));\n }\n };\n await visitNpmPackages(packageJsonPath, onVisit);\n return [...sdks].map(fromKey);\n}\n\nconst SEPARATOR = \"//\";\nconst toKey = (rid: string, version: string) => `${rid}${SEPARATOR}${version}`;\nconst fromKey = (key: string): OntologySdkInputSpec => {\n const [rid, version] = key.split(SEPARATOR);\n return {\n rid,\n version,\n };\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA,SAASA,gBAAgB,QAAQ,+BAA+B;AAEhE,OAAO,eAAeC,qBAAqBA,CACzCC,eAAuB,EACM;EAC7B,MAAMC,IAAI,GAAG,MAAMC,6BAA6B,CAACF,eAAe,CAAC;EACjE,OAAO;IACLG,UAAU,EAAE;MACVF;IACF;EACF,CAAC;AACH;AAEA,eAAeC,6BAA6BA,CAC1CF,eAAuB,EACe;EACtC,MAAMC,IAAI,GAAG,IAAIG,GAAG,CAAS,CAAC;EAM9B,MAAMN,gBAAgB,CAACE,eAAe,EALtB,CAACK,gBAAwB,EAAEC,WAAwB,KAAK;IACtE,IAAIA,WAAW,CAACC,IAAI,EAAEC,UAAU,IAAI,IAAI,EAAE;MACxCP,IAAI,CAACQ,GAAG,CAACC,KAAK,CAACJ,WAAW,CAACC,IAAI,CAACC,UAAU,EAAEF,WAAW,CAACK,OAAO,CAAC,CAAC;IACnE;EACF,CAC+C,CAAC;EAChD,OAAO,CAAC,GAAGV,IAAI,CAAC,CAACW,GAAG,CAACC,OAAO,CAAC;AAC/B;AAEA,MAAMC,SAAS,GAAG,IAAI;AACtB,MAAMJ,KAAK,GAAGA,CAACK,GAAW,EAAEJ,OAAe,KAAK,GAAGI,GAAG,GAAGD,SAAS,GAAGH,OAAO,EAAE;AAC9E,MAAME,OAAO,GAAIG,GAAW,IAA2B;EACrD,MAAM,CAACD,GAAG,EAAEJ,OAAO,CAAC,GAAGK,GAAG,CAACC,KAAK,CAACH,SAAS,CAAC;EAC3C,OAAO;IACLC,GAAG;IACHJ;EACF,CAAC;AACH,CAAC","ignoreList":[]}
@@ -17,6 +17,6 @@
17
17
  import { CONFIG_FILE_SUFFIX } from "../common/constants.js";
18
18
  export function isConfigFile(filePath) {
19
19
  const trimmedFilePath = filePath.replace(/\.[^/.]+$/, "");
20
- return trimmedFilePath.endsWith(CONFIG_FILE_SUFFIX);
20
+ return filePath.endsWith(CONFIG_FILE_SUFFIX) || trimmedFilePath.endsWith(CONFIG_FILE_SUFFIX);
21
21
  }
22
22
  //# sourceMappingURL=isConfigFile.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"isConfigFile.js","names":["CONFIG_FILE_SUFFIX","isConfigFile","filePath","trimmedFilePath","replace","endsWith"],"sources":["isConfigFile.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 { CONFIG_FILE_SUFFIX } from \"../common/constants.js\";\n\nexport function isConfigFile(filePath: string): boolean {\n const trimmedFilePath = filePath.replace(/\\.[^/.]+$/, \"\");\n return trimmedFilePath.endsWith(CONFIG_FILE_SUFFIX);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,kBAAkB,QAAQ,wBAAwB;AAE3D,OAAO,SAASC,YAAYA,CAACC,QAAgB,EAAW;EACtD,MAAMC,eAAe,GAAGD,QAAQ,CAACE,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;EACzD,OAAOD,eAAe,CAACE,QAAQ,CAACL,kBAAkB,CAAC;AACrD","ignoreList":[]}
1
+ {"version":3,"file":"isConfigFile.js","names":["CONFIG_FILE_SUFFIX","isConfigFile","filePath","trimmedFilePath","replace","endsWith"],"sources":["isConfigFile.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 { CONFIG_FILE_SUFFIX } from \"../common/constants.js\";\n\nexport function isConfigFile(filePath: string): boolean {\n const trimmedFilePath = filePath.replace(/\\.[^/.]+$/, \"\");\n return filePath.endsWith(CONFIG_FILE_SUFFIX)\n || trimmedFilePath.endsWith(CONFIG_FILE_SUFFIX);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,kBAAkB,QAAQ,wBAAwB;AAE3D,OAAO,SAASC,YAAYA,CAACC,QAAgB,EAAW;EACtD,MAAMC,eAAe,GAAGD,QAAQ,CAACE,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;EACzD,OAAOF,QAAQ,CAACG,QAAQ,CAACL,kBAAkB,CAAC,IACvCG,eAAe,CAACE,QAAQ,CAACL,kBAAkB,CAAC;AACnD","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=PackageJson.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PackageJson.js","names":[],"sources":["PackageJson.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 interface PackageJson {\n name: string;\n version: string;\n osdk?: {\n packageRid?: string;\n };\n dependencies?: {\n [key: string]: string;\n };\n}\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,74 @@
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 { readFile } from "fs/promises";
18
+ import resolvePackagePath from "resolve-package-path";
19
+ import { expect, test, vi } from "vitest";
20
+ import { visitNpmPackages } from "../visitNpmPackages.js";
21
+ vi.mock("fs/promises");
22
+ vi.mock("resolve-package-path");
23
+ test("visitNpmPackages", async () => {
24
+ const packageJson1 = {
25
+ name: "package1",
26
+ version: "0.1.0",
27
+ dependencies: {
28
+ "package2": "0.2.0",
29
+ "package3": "0.3.0"
30
+ }
31
+ };
32
+ const packageJson2 = {
33
+ name: "package2",
34
+ version: "0.2.0",
35
+ dependencies: {
36
+ "package3": "0.3.0"
37
+ }
38
+ };
39
+ const packageJson3 = {
40
+ name: "package3",
41
+ version: "0.3.0"
42
+ };
43
+ const packageJsonPaths = {
44
+ [packageJson1.name]: "/path/to/package.json",
45
+ [packageJson2.name]: "/path/to/node_modules/package2/package.json",
46
+ [packageJson3.name]: "/path/to/node_modules/package3/package.json"
47
+ };
48
+ const packageJsons = {
49
+ [packageJsonPaths[packageJson1.name]]: packageJson1,
50
+ [packageJsonPaths[packageJson2.name]]: packageJson2,
51
+ [packageJsonPaths[packageJson3.name]]: packageJson3
52
+ };
53
+ vi.mocked(resolvePackagePath).mockImplementation(target => {
54
+ const path = packageJsonPaths[target];
55
+ if (path == null) {
56
+ throw new Error(`Unexpected target: ${target}`);
57
+ }
58
+ return path;
59
+ });
60
+ vi.mocked(readFile).mockImplementation(path => {
61
+ const packageJson = packageJsons[path.toString()];
62
+ if (packageJson == null) {
63
+ throw new Error(`Unexpected path: ${path.toString()}`);
64
+ }
65
+ return Promise.resolve(JSON.stringify(packageJson));
66
+ });
67
+ const onVisit = vi.fn();
68
+ await visitNpmPackages("/path/to/package.json", onVisit);
69
+ expect(onVisit).toHaveBeenCalledTimes(3);
70
+ expect(onVisit).toHaveBeenNthCalledWith(1, "/path/to/package.json", packageJson1);
71
+ expect(onVisit).toHaveBeenNthCalledWith(2, "/path/to/node_modules/package2/package.json", packageJson2);
72
+ expect(onVisit).toHaveBeenNthCalledWith(3, "/path/to/node_modules/package3/package.json", packageJson3);
73
+ });
74
+ //# sourceMappingURL=visitNpmPackages.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"visitNpmPackages.test.js","names":["readFile","resolvePackagePath","expect","test","vi","visitNpmPackages","mock","packageJson1","name","version","dependencies","packageJson2","packageJson3","packageJsonPaths","packageJsons","mocked","mockImplementation","target","path","Error","packageJson","toString","Promise","resolve","JSON","stringify","onVisit","fn","toHaveBeenCalledTimes","toHaveBeenNthCalledWith"],"sources":["visitNpmPackages.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 { readFile } from \"fs/promises\";\nimport resolvePackagePath from \"resolve-package-path\";\nimport { expect, test, vi } from \"vitest\";\nimport type { PackageJson } from \"../../common/PackageJson.js\";\nimport { visitNpmPackages } from \"../visitNpmPackages.js\";\n\nvi.mock(\"fs/promises\");\nvi.mock(\"resolve-package-path\");\n\ntest(\"visitNpmPackages\", async () => {\n const packageJson1: PackageJson = {\n name: \"package1\",\n version: \"0.1.0\",\n dependencies: {\n \"package2\": \"0.2.0\",\n \"package3\": \"0.3.0\",\n },\n };\n const packageJson2: PackageJson = {\n name: \"package2\",\n version: \"0.2.0\",\n dependencies: {\n \"package3\": \"0.3.0\",\n },\n };\n const packageJson3: PackageJson = {\n name: \"package3\",\n version: \"0.3.0\",\n };\n\n const packageJsonPaths: Record<string, string> = {\n [packageJson1.name]: \"/path/to/package.json\",\n [packageJson2.name]: \"/path/to/node_modules/package2/package.json\",\n [packageJson3.name]: \"/path/to/node_modules/package3/package.json\",\n } as const;\n const packageJsons: Record<typeof packageJsonPaths[string], PackageJson> = {\n [packageJsonPaths[packageJson1.name]]: packageJson1,\n [packageJsonPaths[packageJson2.name]]: packageJson2,\n [packageJsonPaths[packageJson3.name]]: packageJson3,\n } as const;\n\n vi.mocked(resolvePackagePath).mockImplementation((target) => {\n const path = packageJsonPaths[target];\n if (path == null) {\n throw new Error(`Unexpected target: ${target}`);\n }\n return path;\n });\n vi.mocked(readFile).mockImplementation((path) => {\n const packageJson = packageJsons[path.toString()];\n if (packageJson == null) {\n throw new Error(`Unexpected path: ${path.toString()}`);\n }\n return Promise.resolve(JSON.stringify(packageJson));\n });\n\n const onVisit = vi.fn();\n await visitNpmPackages(\"/path/to/package.json\", onVisit);\n\n expect(onVisit).toHaveBeenCalledTimes(3);\n expect(onVisit).toHaveBeenNthCalledWith(\n 1,\n \"/path/to/package.json\",\n packageJson1,\n );\n expect(onVisit).toHaveBeenNthCalledWith(\n 2,\n \"/path/to/node_modules/package2/package.json\",\n packageJson2,\n );\n expect(onVisit).toHaveBeenNthCalledWith(\n 3,\n \"/path/to/node_modules/package3/package.json\",\n packageJson3,\n );\n});\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,QAAQ,QAAQ,aAAa;AACtC,OAAOC,kBAAkB,MAAM,sBAAsB;AACrD,SAASC,MAAM,EAAEC,IAAI,EAAEC,EAAE,QAAQ,QAAQ;AAEzC,SAASC,gBAAgB,QAAQ,wBAAwB;AAEzDD,EAAE,CAACE,IAAI,CAAC,aAAa,CAAC;AACtBF,EAAE,CA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CAAC,CAAC,CAAC;IACjD,IAAID,WAAW,IAAI,IAAI,EAAE;MACvB,MAAM,IAAID,KAAK,CAAC,oBAAoBD,IAAI,CAACG,QAAQ,CAAC,CAAC,EAAE,CAAC;IACxD;IACA,OAAOC,OAAO,CAACC,OAAO,CAACC,IAAI,CAACC,SAAS,CAACL,WAAW,CAAC,CAAC;EACrD,CAAC,CAAC;EAEF,MAAMM,OAAO,GAAGtB,EAAE,CAACuB,EAAE,CAAC,CAAC;EACvB,MAAMtB,gBAAgB,CAAC,uBAAuB,EAAEqB,OAAO,CAAC;EAExDxB,MAAM,CAACwB,OAAO,CAAC,CAACE,qBAAqB,CAAC,CAAC,CAAC;EACxC1B,MAAM,CAACwB,OAAO,CAAC,CAACG,uBAAuB,CACrC,CAAC,EACD,uBAAuB,EACvBtB,YACF,CAAC;EACDL,MAAM,CAACwB,OAAO,CAAC,CAACG,uBAAuB,CACrC,CAAC,EACD,6CAA6C,EAC7ClB,YACF,CAAC;EACDT,MAAM,CAACwB,OAAO,CAAC,CAACG,uBAAuB,CACrC,CAAC,EACD,6CAA6C,EAC7CjB,YACF,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,62 @@
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 { readFile } from "fs/promises";
18
+ import path from "path";
19
+ import resolvePackagePath from "resolve-package-path";
20
+ export async function visitNpmPackages(rootPackageJsonPath, onVisit) {
21
+ const visited = new Set();
22
+ const visitNpmPackagesInternal = async function (packageJsonPath) {
23
+ if (visited.has(packageJsonPath)) {
24
+ return;
25
+ }
26
+ const packageJson = await parsePackageJson(packageJsonPath);
27
+ onVisit(packageJsonPath, packageJson);
28
+ visited.add(packageJsonPath);
29
+ const context = path.dirname(packageJsonPath);
30
+ const npmDependencies = Object.keys(packageJson.dependencies ?? {});
31
+ for (const childName of npmDependencies) {
32
+ const childPackageJsonPath = findPackageJsonPath(childName, context);
33
+ await visitNpmPackagesInternal(childPackageJsonPath);
34
+ }
35
+ };
36
+ return visitNpmPackagesInternal(rootPackageJsonPath);
37
+ }
38
+ export function findPackageJsonPath(dependency, baseDir) {
39
+ const packagePath = resolvePackagePath(dependency, baseDir);
40
+ if (packagePath == null) {
41
+ throw new Error(`Could not resolve ${dependency} from ${baseDir}`);
42
+ }
43
+ return packagePath;
44
+ }
45
+ export async function parsePackageJson(packageJsonPath) {
46
+ let packageJsonContent;
47
+ try {
48
+ packageJsonContent = await readFile(packageJsonPath, "utf-8");
49
+ } catch (err) {
50
+ throw new Error(`Failed to read file at path. Does it exist?: "${packageJsonPath}"`, {
51
+ cause: err
52
+ });
53
+ }
54
+ try {
55
+ return JSON.parse(packageJsonContent);
56
+ } catch (err) {
57
+ throw new Error(`Failed to parse package.json content from file "${packageJsonPath}"`, {
58
+ cause: err
59
+ });
60
+ }
61
+ }
62
+ //# sourceMappingURL=visitNpmPackages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"visitNpmPackages.js","names":["readFile","path","resolvePackagePath","visitNpmPackages","rootPackageJsonPath","onVisit","visited","Set","visitNpmPackagesInternal","packageJsonPath","has","packageJson","parsePackageJson","add","context","dirname","npmDependencies","Object","keys","dependencies","childName","childPackageJsonPath","findPackageJsonPath","dependency","baseDir","packagePath","Error","packageJsonContent","err","cause","JSON","parse"],"sources":["visitNpmPackages.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 { readFile } from \"fs/promises\";\nimport path from \"path\";\nimport resolvePackagePath from \"resolve-package-path\";\nimport type { PackageJson } from \"./PackageJson.js\";\n\nexport async function visitNpmPackages(\n rootPackageJsonPath: string,\n onVisit: (packageJsonPath: string, packageJson: PackageJson) => void,\n): Promise<void> {\n const visited = new Set<string>();\n\n const visitNpmPackagesInternal = async function(\n packageJsonPath: string,\n ): Promise<void> {\n if (visited.has(packageJsonPath)) {\n return;\n }\n\n const packageJson = await parsePackageJson(packageJsonPath);\n onVisit(\n packageJsonPath,\n packageJson,\n );\n visited.add(packageJsonPath);\n\n const context = path.dirname(packageJsonPath);\n const npmDependencies = Object.keys(packageJson.dependencies ?? {});\n for (const childName of npmDependencies) {\n const childPackageJsonPath = findPackageJsonPath(\n childName,\n context,\n );\n await visitNpmPackagesInternal(childPackageJsonPath);\n }\n };\n\n return visitNpmPackagesInternal(rootPackageJsonPath);\n}\n\nexport function findPackageJsonPath(\n dependency: string,\n baseDir: string,\n): string {\n const packagePath = resolvePackagePath(dependency, baseDir);\n if (packagePath == null) {\n throw new Error(`Could not resolve ${dependency} from ${baseDir}`);\n }\n return packagePath;\n}\n\nexport async function parsePackageJson(\n packageJsonPath: string,\n): Promise<PackageJson> {\n let packageJsonContent;\n try {\n packageJsonContent = await readFile(packageJsonPath, \"utf-8\");\n } catch (err) {\n throw new Error(\n `Failed to read file at path. Does it exist?: \"${packageJsonPath}\"`,\n { cause: err },\n );\n }\n try {\n return JSON.parse(packageJsonContent);\n } catch (err) {\n throw new Error(\n `Failed to parse package.json content from file \"${packageJsonPath}\"`,\n { cause: err },\n );\n }\n}\n"],"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BAAgBA,CACpCH,eAAuB,EACD;EACtB,IAAIkB,kBAAkB;EACtB,IAAI;IACFA,kBAAkB,GAAG,MAAM3B,QAAQ,CAACS,eAAe,EAAE,OAAO,CAAC;EAC/D,CAAC,CAAC,OAAOmB,GAAG,EAAE;IACZ,MAAM,IAAIF,KAAK,CACb,iDAAiDjB,eAAe,GAAG,EACnE;MAAEoB,KAAK,EAAED;IAAI,CACf,CAAC;EACH;EACA,IAAI;IACF,OAAOE,IAAI,CAACC,KAAK,CAACJ,kBAAkB,CAAC;EACvC,CAAC,CAAC,OAAOC,GAAG,EAAE;IACZ,MAAM,IAAIF,KAAK,CACb,mDAAmDjB,eAAe,GAAG,EACrE;MAAEoB,KAAK,EAAED;IAAI,CACf,CAAC;EACH;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"mappings":"AAsBA,cAAc,cAA8B,MAAO;AAQnD,OAAO,iBAAS,4BAA4B","names":[],"sources":["../../../src/build-plugin/FoundryWidgetBuildPlugin.ts"],"version":3,"file":"FoundryWidgetBuildPlugin.d.ts"}
1
+ {"mappings":"AAsBA,cAAc,cAA8B,MAAO;AASnD,OAAO,iBAAS,4BAA4B","names":[],"sources":["../../../src/build-plugin/FoundryWidgetBuildPlugin.ts"],"version":3,"file":"FoundryWidgetBuildPlugin.d.ts"}
@@ -0,0 +1 @@
1
+ {"mappings":"","names":[],"sources":["../../../../src/build-plugin/__tests__/getWidgetSetInputSpec.test.ts"],"version":3,"file":"getWidgetSetInputSpec.test.d.ts"}
@@ -0,0 +1 @@
1
+ {"mappings":"","names":[],"sources":["../../../../src/build-plugin/__tests__/isConfigFile.test.ts"],"version":3,"file":"isConfigFile.test.d.ts"}
@@ -1,3 +1,3 @@
1
- import type { WidgetSetManifest } from "@osdk/widget.api";
1
+ import type { WidgetSetInputSpec, WidgetSetManifest } from "@osdk/widget.api";
2
2
  import type { WidgetBuildOutputs } from "./getWidgetBuildOutputs.js";
3
- export declare function buildWidgetSetManifest(widgetSetRid: string, widgetSetVersion: string, widgetBuilds: WidgetBuildOutputs[]): WidgetSetManifest;
3
+ export declare function buildWidgetSetManifest(widgetSetRid: string, widgetSetVersion: string, widgetBuilds: WidgetBuildOutputs[], widgetSetInputSpec: WidgetSetInputSpec): WidgetSetManifest;
@@ -1 +1 @@
1
- {"mappings":"AAgBA,cAAoC,yBAAyB,kBAAmB;AAChF,cAAc,0BAA0B,4BAA6B;AAErE,OAAO,iBAAS,uBACdA,sBACAC,0BACAC,cAAc,uBACb","names":["widgetSetRid: string","widgetSetVersion: string","widgetBuilds: WidgetBuildOutputs[]"],"sources":["../../../src/build-plugin/buildWidgetSetManifest.ts"],"version":3,"file":"buildWidgetSetManifest.d.ts"}
1
+ {"mappings":"AAgBA,cAEE,oBACA,yBACK,kBAAmB;AAC1B,cAAc,0BAA0B,4BAA6B;AAErE,OAAO,iBAAS,uBACdA,sBACAC,0BACAC,cAAc,sBACdC,oBAAoB,qBACnB","names":["widgetSetRid: string","widgetSetVersion: string","widgetBuilds: WidgetBuildOutputs[]","widgetSetInputSpec: WidgetSetInputSpec"],"sources":["../../../src/build-plugin/buildWidgetSetManifest.ts"],"version":3,"file":"buildWidgetSetManifest.d.ts"}
@@ -0,0 +1,2 @@
1
+ import type { WidgetSetInputSpec } from "@osdk/widget.api";
2
+ export declare function getWidgetSetInputSpec(packageJsonPath: string): Promise<WidgetSetInputSpec>;
@@ -0,0 +1 @@
1
+ {"mappings":"AAgBA,cAEE,0BACK,kBAAmB;AAI1B,OAAO,iBAAe,sBACpBA,0BACC,QAAQ","names":["packageJsonPath: string"],"sources":["../../../src/build-plugin/getWidgetSetInputSpec.ts"],"version":3,"file":"getWidgetSetInputSpec.d.ts"}
@@ -0,0 +1,10 @@
1
+ export interface PackageJson {
2
+ name: string;
3
+ version: string;
4
+ osdk?: {
5
+ packageRid?: string
6
+ };
7
+ dependencies?: {
8
+ [key: string]: string
9
+ };
10
+ }
@@ -0,0 +1 @@
1
+ {"mappings":"AAgBA,iBAAiB,YAAY;CAC3B;CACA;CACA,OAAO;EACL;CACD;CACD,eAAe;;CAEd;AACF","names":[],"sources":["../../../src/common/PackageJson.ts"],"version":3,"file":"PackageJson.d.ts"}
@@ -0,0 +1 @@
1
+ {"mappings":"","names":[],"sources":["../../../../src/common/__tests__/visitNpmPackages.test.ts"],"version":3,"file":"visitNpmPackages.test.d.ts"}
@@ -0,0 +1,4 @@
1
+ import type { PackageJson } from "./PackageJson.js";
2
+ export declare function visitNpmPackages(rootPackageJsonPath: string, onVisit: (packageJsonPath: string, packageJson: PackageJson) => void): Promise<void>;
3
+ export declare function findPackageJsonPath(dependency: string, baseDir: string): string;
4
+ export declare function parsePackageJson(packageJsonPath: string): Promise<PackageJson>;
@@ -0,0 +1 @@
1
+ {"mappings":"AAmBA,cAAc,mBAAmB,kBAAmB;AAEpD,OAAO,iBAAe,iBACpBA,6BACAC,UAAUC,yBAAyBC,aAAa,uBAC/C;AA+BH,OAAO,iBAAS,oBACdC,oBACAC;AASF,OAAO,iBAAe,iBACpBH,0BACC,QAAQ","names":["rootPackageJsonPath: string","onVisit: (packageJsonPath: string, packageJson: PackageJson) => void","packageJsonPath: string","packageJson: PackageJson","dependency: string","baseDir: string"],"sources":["../../../src/common/visitNpmPackages.ts"],"version":3,"file":"visitNpmPackages.d.ts"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@osdk/widget.vite-plugin",
3
- "version": "3.1.0-beta.3",
3
+ "version": "3.1.0-beta.4",
4
4
  "description": "A vite plugin that will extract parameter definitions from TS/JS files + entrypoint info into a manifest file to be uploaded to Foundry ",
5
5
  "access": "public",
6
6
  "license": "Apache-2.0",
@@ -31,7 +31,7 @@
31
31
  "picocolors": "^1.1.1",
32
32
  "sirv": "^3.0.0",
33
33
  "@osdk/foundry-config-json": "~1.3.0-beta.1",
34
- "@osdk/widget.api": "~3.1.0-beta.3"
34
+ "@osdk/widget.api": "~3.1.0-beta.4"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "vite": "^6.3.5"
@@ -47,6 +47,7 @@
47
47
  "@vitejs/plugin-react": "^4.2.0",
48
48
  "react": "^18",
49
49
  "react-dom": "^18",
50
+ "resolve-package-path": "^4.0.3",
50
51
  "ts-expect": "^1.3.0",
51
52
  "typescript": "~5.5.4",
52
53
  "vite": "^6.3.5",