@rainbow-robotics/preview-host 0.1.2-dev.8 → 0.1.2-dev.9

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 (3) hide show
  1. package/build.mjs +12 -0
  2. package/package.json +3 -3
  3. package/serve.mjs +2 -13
package/build.mjs CHANGED
@@ -18,6 +18,7 @@ const nexusDir = resolve(repoRoot, "apps/web/nexus");
18
18
  const nexusDist = resolve(nexusDir, "dist-preview");
19
19
  const assetsPublic = resolve(repoRoot, "apps/web/assets/public");
20
20
  const outDir = resolve(here, "dist");
21
+ const pluginUiRoot = resolve(here, "../plugin-ui");
21
22
 
22
23
  const skipBuild = process.argv.includes("--skip-build");
23
24
 
@@ -49,4 +50,15 @@ for (const dir of ["imgs", "fonts", "sounds", "data"]) {
49
50
  if (existsSync(src)) cpSync(src, resolve(outDir, dir), { recursive: true });
50
51
  }
51
52
 
53
+ // plugin-ui dist-browser — bundled in so preview-host has no npm runtime dep on plugin-ui.
54
+ // This lets `npm i -g muscat-plugin-kit` resolve cleanly (no react peerDep chain).
55
+ const distBrowser = resolve(pluginUiRoot, "dist-browser");
56
+ if (!existsSync(distBrowser)) {
57
+ throw new Error(
58
+ `plugin-ui dist-browser not found at ${distBrowser}.\nRun: yarn workspace @rainbow-robotics/plugin-ui build`,
59
+ );
60
+ }
61
+ cpSync(distBrowser, resolve(outDir, "plugin-runtime"), { recursive: true });
62
+ console.log("[preview-host] bundled plugin-runtime from plugin-ui/dist-browser");
63
+
52
64
  console.log("[preview-host] dist ready →", outDir);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rainbow-robotics/preview-host",
3
- "version": "0.1.2-dev.8",
3
+ "version": "0.1.2-dev.9",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=20"
@@ -26,7 +26,7 @@
26
26
  "build": "node build.mjs",
27
27
  "prepack": "node build.mjs"
28
28
  },
29
- "dependencies": {
30
- "@rainbow-robotics/plugin-ui": "0.1.2-dev.8"
29
+ "devDependencies": {
30
+ "@rainbow-robotics/plugin-ui": "0.1.2-dev.9"
31
31
  }
32
32
  }
package/serve.mjs CHANGED
@@ -9,7 +9,6 @@
9
9
  // assets/ — i.e. the output of `muscat-pk build`.
10
10
  import { createServer } from "node:http";
11
11
  import { createReadStream, existsSync, readFileSync, statSync } from "node:fs";
12
- import { createRequire } from "node:module";
13
12
  import { dirname, extname, join, resolve } from "node:path";
14
13
  import { fileURLToPath } from "node:url";
15
14
 
@@ -20,20 +19,10 @@ function arg(name, fallback) {
20
19
  return i !== -1 && process.argv[i + 1] ? process.argv[i + 1] : fallback;
21
20
  }
22
21
 
23
- function resolvePluginUiDistBrowser() {
24
- try {
25
- const req = createRequire(import.meta.url);
26
- const pkgPath = req.resolve("@rainbow-robotics/plugin-ui/package.json");
27
- return resolve(dirname(pkgPath), "dist-browser");
28
- } catch {
29
- // fallback for unusual install layouts
30
- return resolve(here, "../plugin-ui/dist-browser");
31
- }
32
- }
33
-
34
22
  const port = Number(arg("port", "4180"));
35
23
  const distDir = resolve(arg("dist", join(here, "dist")));
36
- const runtimeDir = resolve(arg("runtime", resolvePluginUiDistBrowser()));
24
+ // plugin-runtime is bundled into dist/ at build time — no runtime dep on @rainbow-robotics/plugin-ui
25
+ const runtimeDir = resolve(arg("runtime", join(here, "dist", "plugin-runtime")));
37
26
  const pluginDir = arg("plugin", "")
38
27
  ? resolve(arg("plugin", ""))
39
28
  : "";