@rainbow-robotics/preview-host 1.3.8-dev.2 → 1.10.1-dev.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.
- package/README.md +254 -254
- package/build.mjs +53 -53
- package/dist/assets/{AmrCapabilityControl.C4xiLjRl.js → AmrCapabilityControl.uMKnOOk0.js} +1 -1
- package/dist/assets/{RbLocalizationProvider.DXsc16pV.js → RbLocalizationProvider.c-57mWsf.js} +7 -7
- package/dist/assets/{__federation_expose_App.BMXng8Ke.js → __federation_expose_App.Cr76Vrqb.js} +297 -292
- package/dist/assets/__federation_fn_import.DdkEuT6t.js +2 -2
- package/dist/assets/{cssMode.DSgEs3Fy.js → cssMode.DWY0mg29.js} +1 -1
- package/dist/assets/{freemarker2.Di820O1V.js → freemarker2.BcQcIHbV.js} +1 -1
- package/dist/assets/{handlebars.8PwOoFy6.js → handlebars.apOy76CD.js} +1 -1
- package/dist/assets/{html.400C3t45.js → html.FOC5wcqt.js} +1 -1
- package/dist/assets/{htmlMode.CRheDnup.js → htmlMode.DZcYEntg.js} +1 -1
- package/dist/assets/{index.Da-y1HNK.js → index.Bxmeiw-f.js} +5 -5
- package/dist/assets/index.Dzu1iP6J.js +1 -0
- package/dist/assets/{index.BP0yBo-w.js → index.G9r3GUil.js} +1 -1
- package/dist/assets/{javascript.DXPB8Jbo.js → javascript.CEL3KJ9t.js} +1 -1
- package/dist/assets/{jsonMode.DVz0aIDE.js → jsonMode.Clw0nKgf.js} +1 -1
- package/dist/assets/{liquid.BP9dP7-Z.js → liquid.JBTTz117.js} +1 -1
- package/dist/assets/{lspLanguageFeatures.CpNhcIHE.js → lspLanguageFeatures.Ap43Ejq9.js} +1 -1
- package/dist/assets/{mdx.KhufbQQF.js → mdx.B2yIdDo_.js} +1 -1
- package/dist/assets/{python.C94rM7lW.js → python.DKT8_C5B.js} +1 -1
- package/dist/assets/{razor.DPjaPBcH.js → razor.z656zFnB.js} +1 -1
- package/dist/assets/remoteEntry.js +1 -1
- package/dist/assets/{tsMode.idfXhycx.js → tsMode.CJn1kWbF.js} +1 -1
- package/dist/assets/{typescript.Bg1XCf6a.js → typescript.B27DsFAh.js} +1 -1
- package/dist/assets/{useFileDownload.CmIfPP9S.js → useFileDownload.BVrgd27i.js} +199 -199
- package/dist/assets/{xml.Bg1Kn9mk.js → xml.D8-DrtSf.js} +1 -1
- package/dist/assets/{yaml.DJnG9bGb.js → yaml.c2GnKl-i.js} +1 -1
- package/dist/data/joint/joint_data_20250617_101757_1.csv +448 -448
- package/dist/data/robots/models.json +47 -47
- package/dist/data/robots/test.json +38 -38
- package/dist/data/service-info.json +174 -102
- package/dist/imgs/nexus/commands_tree_icons/color_folder.svg +9 -9
- package/dist/imgs/nexus/forms/gripper/g11_help.png +0 -0
- package/dist/imgs/nexus/forms/gripper/gripper_11.png +0 -0
- package/dist/imgs/nexus/forms/gripper/gripper_12.png +0 -0
- package/dist/imgs/nexus/forms/gripper/gripper_13.png +0 -0
- package/dist/imgs/nexus/forms/gripper/gripper_14.png +0 -0
- package/dist/imgs/nexus/forms/gripper/gripper_15.png +0 -0
- package/dist/imgs/nexus/forms/gripper/gripper_16.png +0 -0
- package/dist/imgs/nexus/forms/gripper/gripper_17.png +0 -0
- package/dist/imgs/nexus/forms/gripper/gripper_18.png +0 -0
- package/dist/imgs/nexus/forms/gripper/gripper_19_0.png +0 -0
- package/dist/imgs/nexus/forms/gripper/gripper_19_1.png +0 -0
- package/dist/imgs/nexus/forms/gripper/gripper_20.png +0 -0
- package/dist/imgs/nexus/forms/gripper/gripper_21.png +0 -0
- package/dist/imgs/nexus/forms/gripper/gripper_22.png +0 -0
- package/dist/imgs/profile.svg +4 -4
- package/dist/index.html +17 -17
- package/package.json +1 -1
- package/serve.mjs +193 -193
- package/dist/assets/index.1ZV6DMoI.js +0 -1
package/README.md
CHANGED
|
@@ -1,254 +1,254 @@
|
|
|
1
|
-
# `@rainbow-robotics/preview-host`
|
|
2
|
-
|
|
3
|
-
`@rainbow-robotics/preview-host` is a standalone **mini-Muscat (nexus) shell** for previewing Muscat plugins without a robot or backend.
|
|
4
|
-
|
|
5
|
-
It's built by building `apps/web/nexus` in `plugin-preview` mode.
|
|
6
|
-
|
|
7
|
-
This preview shell provides a UI as close as possible to the real Muscat environment.
|
|
8
|
-
|
|
9
|
-
* Real Header
|
|
10
|
-
* Real LNB
|
|
11
|
-
* Real panel structure
|
|
12
|
-
* Real `rb-components`
|
|
13
|
-
* Plugin manifest-based loading
|
|
14
|
-
|
|
15
|
-
Robot- and backend-related dependencies, on the other hand, are all mocked.
|
|
16
|
-
|
|
17
|
-
* No robot connection required
|
|
18
|
-
* No backend server required
|
|
19
|
-
* API-failure toasts hidden
|
|
20
|
-
* Query retry disabled
|
|
21
|
-
* RB static resources served locally
|
|
22
|
-
|
|
23
|
-
This package is used by `muscat-plugin-kit`'s:
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
muscat-pk dev:ui
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
This lets external plugin developers preview their plugin in a Muscat-like environment without the `web-rainbow-ui` monorepo source.
|
|
30
|
-
|
|
31
|
-
## Build
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
node build.mjs
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
Builds `nexus` in `plugin-preview` mode, then assembles the files needed to run into the `./dist` directory.
|
|
38
|
-
|
|
39
|
-
If `nexus` has already been built, you can use:
|
|
40
|
-
|
|
41
|
-
```bash
|
|
42
|
-
node build.mjs --skip-build
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
This skips rebuilding `nexus` and only reassembles `./dist` from the existing build output.
|
|
46
|
-
|
|
47
|
-
The generated `dist/` directory is excluded from Git.
|
|
48
|
-
|
|
49
|
-
`dist/` is structured to be runnable standalone.
|
|
50
|
-
|
|
51
|
-
Main contents:
|
|
52
|
-
|
|
53
|
-
* nexus bundle
|
|
54
|
-
* RB static resources
|
|
55
|
-
* images
|
|
56
|
-
* fonts
|
|
57
|
-
* other runtime resources
|
|
58
|
-
|
|
59
|
-
Static resources are served at the same paths used at real runtime.
|
|
60
|
-
|
|
61
|
-
```text
|
|
62
|
-
/imgs
|
|
63
|
-
/fonts
|
|
64
|
-
...
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
## Run
|
|
68
|
-
|
|
69
|
-
```bash
|
|
70
|
-
rb-preview-host --plugin <built-plugin-dir> [--port 4180] [--dist <dir>]
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
### Options
|
|
74
|
-
|
|
75
|
-
`--plugin` points to a plugin build directory produced by `muscat-pk build`.
|
|
76
|
-
|
|
77
|
-
```bash
|
|
78
|
-
rb-preview-host --plugin ./dist/plugin
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
`--port` sets the port preview-host runs on.
|
|
82
|
-
|
|
83
|
-
Defaults to `4180`.
|
|
84
|
-
|
|
85
|
-
```bash
|
|
86
|
-
rb-preview-host \
|
|
87
|
-
--plugin ./dist/plugin \
|
|
88
|
-
--port 4180
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
`--dist` overrides the preview-host static bundle directory.
|
|
92
|
-
|
|
93
|
-
```bash
|
|
94
|
-
rb-preview-host \
|
|
95
|
-
--plugin ./dist/plugin \
|
|
96
|
-
--dist ./preview-host-dist
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
The following options are also supported (all optional — `muscat-pk dev` fills them in internally).
|
|
100
|
-
|
|
101
|
-
* `--socket-url`: the Socket.IO URL the plugin connects to (`window.__RB_PLUGIN_PREVIEW_SOCKET_URL__`)
|
|
102
|
-
* `--robot-host`: robot host override (`window.__RB_ROBOT_HOST__`)
|
|
103
|
-
* `--dev-server-url`: the plugin's own Vite dev server URL (`window.__RB_PLUGIN_DEV_SERVER_URL__`) — used when mounting a `dev` UI entry directly
|
|
104
|
-
|
|
105
|
-
## Plugin build directory requirements
|
|
106
|
-
|
|
107
|
-
The directory passed to `--plugin` must be an output directory from `muscat-pk build`.
|
|
108
|
-
|
|
109
|
-
It must contain:
|
|
110
|
-
|
|
111
|
-
```text
|
|
112
|
-
manifest.json
|
|
113
|
-
<ui-entry>.js (e.g. content.js — one is generated per manifest contributes[].ui entry)
|
|
114
|
-
assets/
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
The host mounts `<ui-entry>.js` by importing it directly as a plain ESM module — no `sandbox.html`/iframe is involved.
|
|
118
|
-
|
|
119
|
-
`assets/` is only present if the plugin uses its own static resources.
|
|
120
|
-
|
|
121
|
-
The plugin directory you specify is mounted in preview host at:
|
|
122
|
-
|
|
123
|
-
```text
|
|
124
|
-
/plugin-dev/
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
The preview shell resolves the plugin and static-resource locations through the global variables `serve.mjs` injects.
|
|
128
|
-
|
|
129
|
-
## Global variables
|
|
130
|
-
|
|
131
|
-
### `window.__RB_PLUGIN_PREVIEW_HOST__`
|
|
132
|
-
|
|
133
|
-
Activates preview-host mode.
|
|
134
|
-
|
|
135
|
-
```ts
|
|
136
|
-
window.__RB_PLUGIN_PREVIEW_HOST__ = true;
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
When set, nexus runs against a mock environment instead of the real backend.
|
|
140
|
-
|
|
141
|
-
Typical effects:
|
|
142
|
-
|
|
143
|
-
* Mocked robot connection
|
|
144
|
-
* Mocked backend API
|
|
145
|
-
* Suppressed API-failure toasts
|
|
146
|
-
* Disabled query retry
|
|
147
|
-
|
|
148
|
-
### `window.__RB_PLUGIN_PREVIEW_BASE__`
|
|
149
|
-
|
|
150
|
-
The base URL the plugin is served from.
|
|
151
|
-
|
|
152
|
-
Defaults to:
|
|
153
|
-
|
|
154
|
-
```text
|
|
155
|
-
/plugin-dev
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
Example:
|
|
159
|
-
|
|
160
|
-
```ts
|
|
161
|
-
window.__RB_PLUGIN_PREVIEW_BASE__ = "/plugin-dev";
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
The preview shell reads the following files relative to this path:
|
|
165
|
-
|
|
166
|
-
```text
|
|
167
|
-
/plugin-dev/manifest.json
|
|
168
|
-
/plugin-dev/<ui-entry>.js
|
|
169
|
-
/plugin-dev/assets/*
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
### `window.__RB_ASSETS_BASE_URL__`
|
|
173
|
-
|
|
174
|
-
The origin RB static resources are served from.
|
|
175
|
-
|
|
176
|
-
Example:
|
|
177
|
-
|
|
178
|
-
```ts
|
|
179
|
-
window.__RB_ASSETS_BASE_URL__ = "http://localhost:4180";
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
This lets preview host load the static resources used by nexus and `rb-components`.
|
|
183
|
-
|
|
184
|
-
Typical resource paths:
|
|
185
|
-
|
|
186
|
-
```text
|
|
187
|
-
/imgs
|
|
188
|
-
/fonts
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
## Global variable summary
|
|
192
|
-
|
|
193
|
-
| Global variable | Meaning |
|
|
194
|
-
| ----------------------------------- | --------------------------------------- |
|
|
195
|
-
| `window.__RB_PLUGIN_PREVIEW_HOST__` | Activates preview-host mode and mocks backend dependencies |
|
|
196
|
-
| `window.__RB_PLUGIN_PREVIEW_BASE__` | Base URL the plugin is mounted at. Defaults to `/plugin-dev` |
|
|
197
|
-
| `window.__RB_ASSETS_BASE_URL__` | Origin serving RB images, fonts, and other static resources |
|
|
198
|
-
|
|
199
|
-
## Relationship to dev mode
|
|
200
|
-
|
|
201
|
-
`muscat-pk dev:ui` runs nexus's Vite dev server directly.
|
|
202
|
-
|
|
203
|
-
```bash
|
|
204
|
-
vite --mode plugin-preview
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
This is a dev-mode preview-host runtime with HMR enabled.
|
|
208
|
-
|
|
209
|
-
In other words, `muscat-pk dev:ui` and `@rainbow-robotics/preview-host` aren't separate implementations — they're the same preview-host runtime used in two different forms.
|
|
210
|
-
|
|
211
|
-
### `muscat-pk dev:ui`
|
|
212
|
-
|
|
213
|
-
Runs the Vite dev server directly against the monorepo source.
|
|
214
|
-
|
|
215
|
-
Characteristics:
|
|
216
|
-
|
|
217
|
-
* Vite-based dev server
|
|
218
|
-
* HMR support
|
|
219
|
-
* Source changes reflected immediately
|
|
220
|
-
* Suited for development
|
|
221
|
-
|
|
222
|
-
### `@rainbow-robotics/preview-host`
|
|
223
|
-
|
|
224
|
-
The same runtime packaged as a static bundle for distribution.
|
|
225
|
-
|
|
226
|
-
Characteristics:
|
|
227
|
-
|
|
228
|
-
* No monorepo source required
|
|
229
|
-
* Uses a prebuilt nexus bundle
|
|
230
|
-
* Runs standalone
|
|
231
|
-
* Distributable to external plugin developers
|
|
232
|
-
|
|
233
|
-
The overall relationship:
|
|
234
|
-
|
|
235
|
-
```text
|
|
236
|
-
apps/web/nexus
|
|
237
|
-
└─ plugin-preview mode
|
|
238
|
-
├─ muscat-pk dev:ui
|
|
239
|
-
│ └─ runs the Vite dev server directly
|
|
240
|
-
│ └─ HMR support
|
|
241
|
-
│
|
|
242
|
-
└─ @rainbow-robotics/preview-host
|
|
243
|
-
└─ packaged as a static bundle
|
|
244
|
-
└─ runs without the monorepo source
|
|
245
|
-
```
|
|
246
|
-
|
|
247
|
-
As a result, external developers get a Muscat-like preview environment — without holding a copy of the `web-rainbow-ui` source — that includes:
|
|
248
|
-
|
|
249
|
-
* Real nexus layout
|
|
250
|
-
* Real Header and LNB
|
|
251
|
-
* Real panels
|
|
252
|
-
* Real `rb-components`
|
|
253
|
-
* Real manifest-based plugin loading
|
|
254
|
-
* Mocked robot and backend environment
|
|
1
|
+
# `@rainbow-robotics/preview-host`
|
|
2
|
+
|
|
3
|
+
`@rainbow-robotics/preview-host` is a standalone **mini-Muscat (nexus) shell** for previewing Muscat plugins without a robot or backend.
|
|
4
|
+
|
|
5
|
+
It's built by building `apps/web/nexus` in `plugin-preview` mode.
|
|
6
|
+
|
|
7
|
+
This preview shell provides a UI as close as possible to the real Muscat environment.
|
|
8
|
+
|
|
9
|
+
* Real Header
|
|
10
|
+
* Real LNB
|
|
11
|
+
* Real panel structure
|
|
12
|
+
* Real `rb-components`
|
|
13
|
+
* Plugin manifest-based loading
|
|
14
|
+
|
|
15
|
+
Robot- and backend-related dependencies, on the other hand, are all mocked.
|
|
16
|
+
|
|
17
|
+
* No robot connection required
|
|
18
|
+
* No backend server required
|
|
19
|
+
* API-failure toasts hidden
|
|
20
|
+
* Query retry disabled
|
|
21
|
+
* RB static resources served locally
|
|
22
|
+
|
|
23
|
+
This package is used by `muscat-plugin-kit`'s:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
muscat-pk dev:ui
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
This lets external plugin developers preview their plugin in a Muscat-like environment without the `web-rainbow-ui` monorepo source.
|
|
30
|
+
|
|
31
|
+
## Build
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
node build.mjs
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Builds `nexus` in `plugin-preview` mode, then assembles the files needed to run into the `./dist` directory.
|
|
38
|
+
|
|
39
|
+
If `nexus` has already been built, you can use:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
node build.mjs --skip-build
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
This skips rebuilding `nexus` and only reassembles `./dist` from the existing build output.
|
|
46
|
+
|
|
47
|
+
The generated `dist/` directory is excluded from Git.
|
|
48
|
+
|
|
49
|
+
`dist/` is structured to be runnable standalone.
|
|
50
|
+
|
|
51
|
+
Main contents:
|
|
52
|
+
|
|
53
|
+
* nexus bundle
|
|
54
|
+
* RB static resources
|
|
55
|
+
* images
|
|
56
|
+
* fonts
|
|
57
|
+
* other runtime resources
|
|
58
|
+
|
|
59
|
+
Static resources are served at the same paths used at real runtime.
|
|
60
|
+
|
|
61
|
+
```text
|
|
62
|
+
/imgs
|
|
63
|
+
/fonts
|
|
64
|
+
...
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Run
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
rb-preview-host --plugin <built-plugin-dir> [--port 4180] [--dist <dir>]
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Options
|
|
74
|
+
|
|
75
|
+
`--plugin` points to a plugin build directory produced by `muscat-pk build`.
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
rb-preview-host --plugin ./dist/plugin
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
`--port` sets the port preview-host runs on.
|
|
82
|
+
|
|
83
|
+
Defaults to `4180`.
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
rb-preview-host \
|
|
87
|
+
--plugin ./dist/plugin \
|
|
88
|
+
--port 4180
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
`--dist` overrides the preview-host static bundle directory.
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
rb-preview-host \
|
|
95
|
+
--plugin ./dist/plugin \
|
|
96
|
+
--dist ./preview-host-dist
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
The following options are also supported (all optional — `muscat-pk dev` fills them in internally).
|
|
100
|
+
|
|
101
|
+
* `--socket-url`: the Socket.IO URL the plugin connects to (`window.__RB_PLUGIN_PREVIEW_SOCKET_URL__`)
|
|
102
|
+
* `--robot-host`: robot host override (`window.__RB_ROBOT_HOST__`)
|
|
103
|
+
* `--dev-server-url`: the plugin's own Vite dev server URL (`window.__RB_PLUGIN_DEV_SERVER_URL__`) — used when mounting a `dev` UI entry directly
|
|
104
|
+
|
|
105
|
+
## Plugin build directory requirements
|
|
106
|
+
|
|
107
|
+
The directory passed to `--plugin` must be an output directory from `muscat-pk build`.
|
|
108
|
+
|
|
109
|
+
It must contain:
|
|
110
|
+
|
|
111
|
+
```text
|
|
112
|
+
manifest.json
|
|
113
|
+
<ui-entry>.js (e.g. content.js — one is generated per manifest contributes[].ui entry)
|
|
114
|
+
assets/
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
The host mounts `<ui-entry>.js` by importing it directly as a plain ESM module — no `sandbox.html`/iframe is involved.
|
|
118
|
+
|
|
119
|
+
`assets/` is only present if the plugin uses its own static resources.
|
|
120
|
+
|
|
121
|
+
The plugin directory you specify is mounted in preview host at:
|
|
122
|
+
|
|
123
|
+
```text
|
|
124
|
+
/plugin-dev/
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
The preview shell resolves the plugin and static-resource locations through the global variables `serve.mjs` injects.
|
|
128
|
+
|
|
129
|
+
## Global variables
|
|
130
|
+
|
|
131
|
+
### `window.__RB_PLUGIN_PREVIEW_HOST__`
|
|
132
|
+
|
|
133
|
+
Activates preview-host mode.
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
window.__RB_PLUGIN_PREVIEW_HOST__ = true;
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
When set, nexus runs against a mock environment instead of the real backend.
|
|
140
|
+
|
|
141
|
+
Typical effects:
|
|
142
|
+
|
|
143
|
+
* Mocked robot connection
|
|
144
|
+
* Mocked backend API
|
|
145
|
+
* Suppressed API-failure toasts
|
|
146
|
+
* Disabled query retry
|
|
147
|
+
|
|
148
|
+
### `window.__RB_PLUGIN_PREVIEW_BASE__`
|
|
149
|
+
|
|
150
|
+
The base URL the plugin is served from.
|
|
151
|
+
|
|
152
|
+
Defaults to:
|
|
153
|
+
|
|
154
|
+
```text
|
|
155
|
+
/plugin-dev
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Example:
|
|
159
|
+
|
|
160
|
+
```ts
|
|
161
|
+
window.__RB_PLUGIN_PREVIEW_BASE__ = "/plugin-dev";
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
The preview shell reads the following files relative to this path:
|
|
165
|
+
|
|
166
|
+
```text
|
|
167
|
+
/plugin-dev/manifest.json
|
|
168
|
+
/plugin-dev/<ui-entry>.js
|
|
169
|
+
/plugin-dev/assets/*
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### `window.__RB_ASSETS_BASE_URL__`
|
|
173
|
+
|
|
174
|
+
The origin RB static resources are served from.
|
|
175
|
+
|
|
176
|
+
Example:
|
|
177
|
+
|
|
178
|
+
```ts
|
|
179
|
+
window.__RB_ASSETS_BASE_URL__ = "http://localhost:4180";
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
This lets preview host load the static resources used by nexus and `rb-components`.
|
|
183
|
+
|
|
184
|
+
Typical resource paths:
|
|
185
|
+
|
|
186
|
+
```text
|
|
187
|
+
/imgs
|
|
188
|
+
/fonts
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Global variable summary
|
|
192
|
+
|
|
193
|
+
| Global variable | Meaning |
|
|
194
|
+
| ----------------------------------- | --------------------------------------- |
|
|
195
|
+
| `window.__RB_PLUGIN_PREVIEW_HOST__` | Activates preview-host mode and mocks backend dependencies |
|
|
196
|
+
| `window.__RB_PLUGIN_PREVIEW_BASE__` | Base URL the plugin is mounted at. Defaults to `/plugin-dev` |
|
|
197
|
+
| `window.__RB_ASSETS_BASE_URL__` | Origin serving RB images, fonts, and other static resources |
|
|
198
|
+
|
|
199
|
+
## Relationship to dev mode
|
|
200
|
+
|
|
201
|
+
`muscat-pk dev:ui` runs nexus's Vite dev server directly.
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
vite --mode plugin-preview
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
This is a dev-mode preview-host runtime with HMR enabled.
|
|
208
|
+
|
|
209
|
+
In other words, `muscat-pk dev:ui` and `@rainbow-robotics/preview-host` aren't separate implementations — they're the same preview-host runtime used in two different forms.
|
|
210
|
+
|
|
211
|
+
### `muscat-pk dev:ui`
|
|
212
|
+
|
|
213
|
+
Runs the Vite dev server directly against the monorepo source.
|
|
214
|
+
|
|
215
|
+
Characteristics:
|
|
216
|
+
|
|
217
|
+
* Vite-based dev server
|
|
218
|
+
* HMR support
|
|
219
|
+
* Source changes reflected immediately
|
|
220
|
+
* Suited for development
|
|
221
|
+
|
|
222
|
+
### `@rainbow-robotics/preview-host`
|
|
223
|
+
|
|
224
|
+
The same runtime packaged as a static bundle for distribution.
|
|
225
|
+
|
|
226
|
+
Characteristics:
|
|
227
|
+
|
|
228
|
+
* No monorepo source required
|
|
229
|
+
* Uses a prebuilt nexus bundle
|
|
230
|
+
* Runs standalone
|
|
231
|
+
* Distributable to external plugin developers
|
|
232
|
+
|
|
233
|
+
The overall relationship:
|
|
234
|
+
|
|
235
|
+
```text
|
|
236
|
+
apps/web/nexus
|
|
237
|
+
└─ plugin-preview mode
|
|
238
|
+
├─ muscat-pk dev:ui
|
|
239
|
+
│ └─ runs the Vite dev server directly
|
|
240
|
+
│ └─ HMR support
|
|
241
|
+
│
|
|
242
|
+
└─ @rainbow-robotics/preview-host
|
|
243
|
+
└─ packaged as a static bundle
|
|
244
|
+
└─ runs without the monorepo source
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
As a result, external developers get a Muscat-like preview environment — without holding a copy of the `web-rainbow-ui` source — that includes:
|
|
248
|
+
|
|
249
|
+
* Real nexus layout
|
|
250
|
+
* Real Header and LNB
|
|
251
|
+
* Real panels
|
|
252
|
+
* Real `rb-components`
|
|
253
|
+
* Real manifest-based plugin loading
|
|
254
|
+
* Mocked robot and backend environment
|
package/build.mjs
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
// Builds the standalone preview-host bundle.
|
|
2
|
-
//
|
|
3
|
-
// 1. Builds nexus in `plugin-preview` mode (standalone mini-Muscat shell with
|
|
4
|
-
// the preview-host runtime flag baked into index.html).
|
|
5
|
-
// 2. Assembles a self-contained `dist/` here: the nexus bundle plus the rb
|
|
6
|
-
// static assets (imgs/fonts/...) served at their runtime paths.
|
|
7
|
-
//
|
|
8
|
-
// Run: node libraries/preview-host/build.mjs [--skip-build]
|
|
9
|
-
import { execSync } from "node:child_process";
|
|
10
|
-
import { cpSync, existsSync, mkdirSync, rmSync } from "node:fs";
|
|
11
|
-
import { dirname, resolve } from "node:path";
|
|
12
|
-
import { fileURLToPath } from "node:url";
|
|
13
|
-
|
|
14
|
-
// This file lives at <repo>/libraries/preview-host/build.mjs
|
|
15
|
-
const here = dirname(fileURLToPath(import.meta.url));
|
|
16
|
-
const repoRoot = resolve(here, "../..");
|
|
17
|
-
const nexusDir = resolve(repoRoot, "apps/web/nexus");
|
|
18
|
-
const nexusDist = resolve(nexusDir, "dist-preview");
|
|
19
|
-
const assetsPublic = resolve(repoRoot, "apps/web/assets/public");
|
|
20
|
-
const outDir = resolve(here, "dist");
|
|
21
|
-
|
|
22
|
-
const skipBuild = process.argv.includes("--skip-build");
|
|
23
|
-
|
|
24
|
-
if (!skipBuild) {
|
|
25
|
-
console.log("[preview-host] building mini-muscat (plugin-preview)…");
|
|
26
|
-
execSync("yarn workspace @app/nexus build:preview", {
|
|
27
|
-
cwd: repoRoot,
|
|
28
|
-
stdio: "inherit",
|
|
29
|
-
env: { ...process.env, VITE_PLUGIN_PREVIEW: "true" },
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (!existsSync(nexusDist)) {
|
|
34
|
-
throw new Error(
|
|
35
|
-
`nexus preview build not found at ${nexusDist}. Run without --skip-build.`,
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
console.log("[preview-host] assembling dist…");
|
|
40
|
-
rmSync(outDir, { recursive: true, force: true });
|
|
41
|
-
mkdirSync(outDir, { recursive: true });
|
|
42
|
-
|
|
43
|
-
// nexus bundle (index.html + assets/)
|
|
44
|
-
cpSync(nexusDist, outDir, { recursive: true });
|
|
45
|
-
|
|
46
|
-
// rb static assets served at runtime (/imgs, /fonts, ...)
|
|
47
|
-
// models/ excluded — too large for npm (700MB+), 3D robot view unavailable in external preview
|
|
48
|
-
for (const dir of ["imgs", "fonts", "sounds", "data"]) {
|
|
49
|
-
const src = resolve(assetsPublic, dir);
|
|
50
|
-
if (existsSync(src)) cpSync(src, resolve(outDir, dir), { recursive: true });
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
console.log("[preview-host] dist ready →", outDir);
|
|
1
|
+
// Builds the standalone preview-host bundle.
|
|
2
|
+
//
|
|
3
|
+
// 1. Builds nexus in `plugin-preview` mode (standalone mini-Muscat shell with
|
|
4
|
+
// the preview-host runtime flag baked into index.html).
|
|
5
|
+
// 2. Assembles a self-contained `dist/` here: the nexus bundle plus the rb
|
|
6
|
+
// static assets (imgs/fonts/...) served at their runtime paths.
|
|
7
|
+
//
|
|
8
|
+
// Run: node libraries/preview-host/build.mjs [--skip-build]
|
|
9
|
+
import { execSync } from "node:child_process";
|
|
10
|
+
import { cpSync, existsSync, mkdirSync, rmSync } from "node:fs";
|
|
11
|
+
import { dirname, resolve } from "node:path";
|
|
12
|
+
import { fileURLToPath } from "node:url";
|
|
13
|
+
|
|
14
|
+
// This file lives at <repo>/libraries/preview-host/build.mjs
|
|
15
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
16
|
+
const repoRoot = resolve(here, "../..");
|
|
17
|
+
const nexusDir = resolve(repoRoot, "apps/web/nexus");
|
|
18
|
+
const nexusDist = resolve(nexusDir, "dist-preview");
|
|
19
|
+
const assetsPublic = resolve(repoRoot, "apps/web/assets/public");
|
|
20
|
+
const outDir = resolve(here, "dist");
|
|
21
|
+
|
|
22
|
+
const skipBuild = process.argv.includes("--skip-build");
|
|
23
|
+
|
|
24
|
+
if (!skipBuild) {
|
|
25
|
+
console.log("[preview-host] building mini-muscat (plugin-preview)…");
|
|
26
|
+
execSync("yarn workspace @app/nexus build:preview", {
|
|
27
|
+
cwd: repoRoot,
|
|
28
|
+
stdio: "inherit",
|
|
29
|
+
env: { ...process.env, VITE_PLUGIN_PREVIEW: "true" },
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (!existsSync(nexusDist)) {
|
|
34
|
+
throw new Error(
|
|
35
|
+
`nexus preview build not found at ${nexusDist}. Run without --skip-build.`,
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
console.log("[preview-host] assembling dist…");
|
|
40
|
+
rmSync(outDir, { recursive: true, force: true });
|
|
41
|
+
mkdirSync(outDir, { recursive: true });
|
|
42
|
+
|
|
43
|
+
// nexus bundle (index.html + assets/)
|
|
44
|
+
cpSync(nexusDist, outDir, { recursive: true });
|
|
45
|
+
|
|
46
|
+
// rb static assets served at runtime (/imgs, /fonts, ...)
|
|
47
|
+
// models/ excluded — too large for npm (700MB+), 3D robot view unavailable in external preview
|
|
48
|
+
for (const dir of ["imgs", "fonts", "sounds", "data"]) {
|
|
49
|
+
const src = resolve(assetsPublic, dir);
|
|
50
|
+
if (existsSync(src)) cpSync(src, resolve(outDir, dir), { recursive: true });
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
console.log("[preview-host] dist ready →", outDir);
|