@rainbow-robotics/preview-host 0.1.2-dev.7 → 0.1.2-dev.8
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/package.json +2 -2
- package/serve.mjs +12 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rainbow-robotics/preview-host",
|
|
3
|
-
"version": "0.1.2-dev.
|
|
3
|
+
"version": "0.1.2-dev.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=20"
|
|
@@ -27,6 +27,6 @@
|
|
|
27
27
|
"prepack": "node build.mjs"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@rainbow-robotics/plugin-ui": "0.1.2-dev.
|
|
30
|
+
"@rainbow-robotics/plugin-ui": "0.1.2-dev.8"
|
|
31
31
|
}
|
|
32
32
|
}
|
package/serve.mjs
CHANGED
|
@@ -37,6 +37,7 @@ const runtimeDir = resolve(arg("runtime", resolvePluginUiDistBrowser()));
|
|
|
37
37
|
const pluginDir = arg("plugin", "")
|
|
38
38
|
? resolve(arg("plugin", ""))
|
|
39
39
|
: "";
|
|
40
|
+
const socketUrl = arg("socket-url", "");
|
|
40
41
|
const PLUGIN_BASE = "/plugin-dev";
|
|
41
42
|
const RUNTIME_BASE = "/plugin-runtime";
|
|
42
43
|
|
|
@@ -67,16 +68,19 @@ if (!existsSync(distDir)) {
|
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
// index.html with the preview-host globals injected (host flag + plugin base).
|
|
71
|
+
const injectedLines = [
|
|
72
|
+
" <script>",
|
|
73
|
+
" window.__RB_PLUGIN_PREVIEW_HOST__ = true;",
|
|
74
|
+
" window.__RB_ASSETS_BASE_URL__ = window.location.origin;",
|
|
75
|
+
` window.__RB_PLUGIN_PREVIEW_BASE__ = ${JSON.stringify(PLUGIN_BASE)};`,
|
|
76
|
+
];
|
|
77
|
+
if (socketUrl) {
|
|
78
|
+
injectedLines.push(` window.__RB_PLUGIN_PREVIEW_SOCKET_URL__ = ${JSON.stringify(socketUrl)};`);
|
|
79
|
+
}
|
|
80
|
+
injectedLines.push(" </script>", " </head>");
|
|
70
81
|
const indexHtml = readFileSync(join(distDir, "index.html"), "utf8").replace(
|
|
71
82
|
"</head>",
|
|
72
|
-
|
|
73
|
-
" <script>",
|
|
74
|
-
" window.__RB_PLUGIN_PREVIEW_HOST__ = true;",
|
|
75
|
-
" window.__RB_ASSETS_BASE_URL__ = window.location.origin;",
|
|
76
|
-
` window.__RB_PLUGIN_PREVIEW_BASE__ = ${JSON.stringify(PLUGIN_BASE)};`,
|
|
77
|
-
" </script>",
|
|
78
|
-
" </head>",
|
|
79
|
-
].join("\n"),
|
|
83
|
+
injectedLines.join("\n"),
|
|
80
84
|
);
|
|
81
85
|
|
|
82
86
|
function sendFile(res, filePath) {
|