@rainbow-robotics/plugin-ui 0.1.2-dev.43 → 0.1.2-dev.45
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 +222 -75
- package/build-dist.mjs +55 -17
- package/dist/host-ui.d.ts +49 -0
- package/dist/host-ui.d.ts.map +1 -0
- package/dist/host-ui.js +33 -0
- package/dist/host-ui.js.map +7 -0
- package/dist/manifest.d.ts +20 -4
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +1 -1
- package/dist/manifest.js.map +2 -2
- package/dist/pluginData.d.ts +68 -0
- package/dist/pluginData.d.ts.map +1 -0
- package/dist/react.d.ts +3430 -36
- package/dist/react.js +5 -54
- package/dist/react.js.map +2 -2
- package/dist/sdk.d.ts +38 -2
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +29 -4
- package/dist/sdk.js.map +2 -2
- package/dist/viteHost.d.ts +48 -0
- package/dist/viteHost.d.ts.map +1 -0
- package/dist/viteHost.js +262 -0
- package/dist/viteHost.js.map +7 -0
- package/dist/ws.d.ts +53 -0
- package/dist/ws.d.ts.map +1 -1
- package/dist/ws.js +128 -0
- package/dist/ws.js.map +7 -0
- package/package.json +43 -20
- package/src/host-ui.ts +80 -0
- package/src/host.tsx +236 -308
- package/src/index.d.ts +1 -0
- package/src/manifest.ts +25 -4
- package/src/pluginData.tsx +241 -0
- package/src/react.tsx +16 -127
- package/src/sdk.ts +74 -7
- package/src/viteHost.ts +316 -0
- package/src/ws.ts +47 -0
- package/build-browser.mjs +0 -84
- package/dist/connect.d.ts +0 -11
- package/dist/connect.d.ts.map +0 -1
- package/dist/connect.js +0 -34
- package/dist/connect.js.map +0 -7
- package/dist/elements.d.ts +0 -195
- package/dist/elements.d.ts.map +0 -1
- package/dist/elements.js +0 -115
- package/dist/elements.js.map +0 -7
- package/dist/react.d.ts.map +0 -1
- package/dist-browser/@rainbow-robotics/plugin-ui/chunks/chunk-37HVFFJB.js +0 -1
- package/dist-browser/@rainbow-robotics/plugin-ui/chunks/chunk-4MGSRUAS.js +0 -1
- package/dist-browser/@rainbow-robotics/plugin-ui/chunks/chunk-Q6XGCIPE.js +0 -1
- package/dist-browser/@rainbow-robotics/plugin-ui/connect.js +0 -1
- package/dist-browser/@rainbow-robotics/plugin-ui/elements.js +0 -1
- package/dist-browser/@rainbow-robotics/plugin-ui/react.js +0 -1
- package/dist-browser/@rainbow-robotics/plugin-ui/sdk.js +0 -1
- package/dist-browser/vendor/react-dom-client.js +0 -1
- package/dist-browser/vendor/react-jsx-dev-runtime.js +0 -1
- package/dist-browser/vendor/react-jsx-runtime.js +0 -1
- package/dist-browser/vendor/react-runtime.js +0 -65
- package/dist-browser/vendor/react.js +0 -1
- package/src/connect.ts +0 -64
- package/src/elements.ts +0 -257
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin data seam (host-side).
|
|
3
|
+
*
|
|
4
|
+
* A single source serves both the real back end and the locally-developed
|
|
5
|
+
* plugin. `muscat-pk dev` injects `window.__RB_PREVIEW_PLUGIN_ID__`; any request
|
|
6
|
+
* for that id is routed to preview-host (dev plugin), everything else to the
|
|
7
|
+
* host's back end. So the dev plugin and installed plugins coexist.
|
|
8
|
+
*
|
|
9
|
+
* Host-agnostic: no app-stack dependency (no react-query). The host passes its
|
|
10
|
+
* real dialog/toast as `hostServices` — the provider registers them via
|
|
11
|
+
* setHostServices so plugins' useDialog/toast delegate to the host's single
|
|
12
|
+
* instance (see ./host-ui).
|
|
13
|
+
*/
|
|
14
|
+
import { type PropsWithChildren } from "react";
|
|
15
|
+
import type { PluginManifest } from "./manifest";
|
|
16
|
+
import { type PluginUIServices } from "@rainbow-robotics/plugin-ui/host-ui";
|
|
17
|
+
/**
|
|
18
|
+
* Where/how to load a plugin's UI module — no iframe involved, the host
|
|
19
|
+
* mounts it directly.
|
|
20
|
+
*
|
|
21
|
+
* - "dev": the plugin's own Vite dev server (muscat-pk dev). `bootstrapUrl` is
|
|
22
|
+
* a plain ESM module exposing `mount(container, rb, hostServices)`; react
|
|
23
|
+
* and plugin-ui resolve from that dev server's own module graph, so this
|
|
24
|
+
* mount is a fully self-consistent, independently-rooted React tree.
|
|
25
|
+
* - "esm": a built plugin (`muscat-pk build` / robot runtime), a plain ESM
|
|
26
|
+
* module the host dynamically imports. react / rb-components / plugin-ui
|
|
27
|
+
* context modules are left external as bare specifiers, resolved by the host
|
|
28
|
+
* page's import map to the host's own already-loaded instances — so it mounts
|
|
29
|
+
* as a genuine nested React tree with working Context (RbContext, host-ui)
|
|
30
|
+
* and no duplicate React instance.
|
|
31
|
+
*/
|
|
32
|
+
export type PluginModuleSource = {
|
|
33
|
+
kind: "dev";
|
|
34
|
+
bootstrapUrl: string;
|
|
35
|
+
} | {
|
|
36
|
+
kind: "esm";
|
|
37
|
+
entryUrl: string;
|
|
38
|
+
};
|
|
39
|
+
export interface PluginDataSource {
|
|
40
|
+
/** Preview plugin manifest (only while a dev plugin is being previewed). */
|
|
41
|
+
usePluginManifest: () => {
|
|
42
|
+
data: PluginManifest | null;
|
|
43
|
+
isLoading: boolean;
|
|
44
|
+
};
|
|
45
|
+
/** Where/how to load a plugin's UI module for a given UI entry. */
|
|
46
|
+
getModuleSource: (pluginId: string, ui: string) => PluginModuleSource;
|
|
47
|
+
/** URL of a plugin asset (e.g. an icon) by its manifest-relative path. */
|
|
48
|
+
getAssetUrl: (pluginId: string, assetPath: string) => string;
|
|
49
|
+
/** Socket.IO server URL the plugin connects to. */
|
|
50
|
+
getSocketUrl: (pluginId: string) => string;
|
|
51
|
+
}
|
|
52
|
+
export declare function usePluginData(): PluginDataSource;
|
|
53
|
+
export interface PluginDataProviderProps {
|
|
54
|
+
/**
|
|
55
|
+
* The host's real dialog/toast, registered for plugins to use via
|
|
56
|
+
* `@rainbow-robotics/plugin-ui/host-ui`. The host builds these ONCE inside
|
|
57
|
+
* its own React tree (calling its real useDialog) and passes the resulting
|
|
58
|
+
* plain functions here — safe to call from a plugin's separate React
|
|
59
|
+
* instance (dev). See ./host-ui.
|
|
60
|
+
*/
|
|
61
|
+
hostServices: PluginUIServices;
|
|
62
|
+
/** Socket.IO URL for installed (non-preview) plugins. */
|
|
63
|
+
wsUrl?: string;
|
|
64
|
+
/** URL prefix the host serves installed plugins from. */
|
|
65
|
+
liveBase?: string;
|
|
66
|
+
}
|
|
67
|
+
export declare function PluginDataProvider({ children, hostServices, wsUrl, liveBase, }: PropsWithChildren<PluginDataProviderProps>): import("react/jsx-runtime").JSX.Element;
|
|
68
|
+
//# sourceMappingURL=pluginData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pluginData.d.ts","sourceRoot":"","sources":["../src/pluginData.tsx"],"names":[],"mappings":"AACA;;;;;;;;;;;;GAYG;AACH,OAAO,EAML,KAAK,iBAAiB,EACvB,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAMjD,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,qCAAqC,CAAC;AAE7C;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,kBAAkB,GAC1B;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,GACrC;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtC,MAAM,WAAW,gBAAgB;IAC/B,4EAA4E;IAC5E,iBAAiB,EAAE,MAAM;QAAE,IAAI,EAAE,cAAc,GAAG,IAAI,CAAC;QAAC,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC;IAC7E,mEAAmE;IACnE,eAAe,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,kBAAkB,CAAC;IACtE,0EAA0E;IAC1E,WAAW,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC;IAC7D,mDAAmD;IACnD,YAAY,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;CAC5C;AAID,wBAAgB,aAAa,IAAI,gBAAgB,CAMhD;AAgHD,MAAM,WAAW,uBAAuB;IACtC;;;;;;OAMG;IACH,YAAY,EAAE,gBAAgB,CAAC;IAC/B,yDAAyD;IACzD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yDAAyD;IACzD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,kBAAkB,CAAC,EACjC,QAAQ,EACR,YAAY,EACZ,KAA8B,EAC9B,QAAoB,GACrB,EAAE,iBAAiB,CAAC,uBAAuB,CAAC,2CAqC5C"}
|