@kubb/studio 5.2.2 → 5.2.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.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as __name } from "./rolldown-runtime-CRm0XQPb.js";
2
- import { a as AgentPermissions, c as ClientInfo } from "./index-Y-wkaxbL.js";
2
+ import { a as AgentPermissions, c as ClientInfo } from "./index-V3fjg2mj.js";
3
3
  import { Storage } from "unstorage";
4
4
  import { Config, Hookable, KubbHooks } from "@kubb/core";
5
5
  //#region src/api.d.ts
package/dist/index.js CHANGED
@@ -564,7 +564,7 @@ async function disconnect({ sessionId, token, studioUrl, slug }) {
564
564
  }
565
565
  //#endregion
566
566
  //#region package.json
567
- var version = "5.2.2";
567
+ var version = "5.2.4";
568
568
  //#endregion
569
569
  //#region src/hooks.ts
570
570
  /**
@@ -670,6 +670,20 @@ function toPluginName(packageName) {
670
670
  return packageName.split("/").pop() ?? packageName;
671
671
  }
672
672
  /**
673
+ * Adds the `@kubb/` scope a plugin's package carries but its `name` does not, the inverse of
674
+ * {@link toPluginName}. A name outside the `plugin-` convention is left alone, so a third-party
675
+ * plugin is not reported as one of Kubb's.
676
+ *
677
+ * @example
678
+ * ```ts
679
+ * toPackageName('plugin-ts') // '@kubb/plugin-ts'
680
+ * toPackageName('@acme/my-plugin') // '@acme/my-plugin'
681
+ * ```
682
+ */
683
+ function toPackageName(name) {
684
+ return name.startsWith("plugin-") ? `@kubb/${name}` : name;
685
+ }
686
+ /**
673
687
  * Derives the conventional named export for a `@kubb/*` plugin package from its package name.
674
688
  *
675
689
  * @example
@@ -1502,6 +1516,29 @@ const CONNECT_TIMEOUT_MS = 5e3;
1502
1516
  * automatically once the socket is collected.
1503
1517
  */
1504
1518
  const eventSeqCounters = /* @__PURE__ */ new WeakMap();
1519
+ const require = createRequire(import.meta.url);
1520
+ async function resolvePeerDependencies(names) {
1521
+ const uniqueNames = [...new Set(names.map(toPackageName))];
1522
+ const peerDependencies = {};
1523
+ const missingDependencies = [];
1524
+ const versions = await Promise.all(uniqueNames.map(async (name) => {
1525
+ try {
1526
+ const path = require.resolve(`${name}/package.json`);
1527
+ return JSON.parse(await readFile(path, "utf8")).version;
1528
+ } catch {
1529
+ return;
1530
+ }
1531
+ }));
1532
+ for (const [index, name] of uniqueNames.entries()) {
1533
+ const version = versions[index];
1534
+ if (version) peerDependencies[name] = version;
1535
+ else missingDependencies.push(name);
1536
+ }
1537
+ return {
1538
+ peerDependencies,
1539
+ missingDependencies
1540
+ };
1541
+ }
1505
1542
  function nextEventSeq(ws) {
1506
1543
  const seq = eventSeqCounters.get(ws) ?? 0;
1507
1544
  eventSeqCounters.set(ws, seq + 1);
@@ -1653,6 +1690,7 @@ function setupEventsStream(ws, hooks) {
1653
1690
  });
1654
1691
  });
1655
1692
  on("kubb:generation:end", async ({ config, storage, diagnostics = [], status, hrStart, filesCreated }) => {
1693
+ const { peerDependencies, missingDependencies } = await resolvePeerDependencies(config.plugins.map(({ name }) => name));
1656
1694
  const paths = await storage.readKeys();
1657
1695
  const files = {};
1658
1696
  await inParallel({
@@ -1667,7 +1705,9 @@ function setupEventsStream(ws, hooks) {
1667
1705
  type: "kubb:generation:end",
1668
1706
  data: [{
1669
1707
  config,
1670
- storage: files
1708
+ storage: files,
1709
+ peerDependencies,
1710
+ missingDependencies
1671
1711
  }]
1672
1712
  });
1673
1713
  if (!hrStart) return;
@@ -1924,7 +1964,7 @@ var StudioSession = class {
1924
1964
  path: configPath,
1925
1965
  file: await this.#readConfigFileView(),
1926
1966
  plugins: config.plugins.map((plugin) => ({
1927
- name: `@kubb/${plugin.name}`,
1967
+ name: toPackageName(plugin.name),
1928
1968
  options: plugin.options ?? {}
1929
1969
  }))
1930
1970
  },