@rainbow-robotics/plugin-ui 0.1.2-dev.9 → 1.0.1
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 +236 -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 +62 -0
- package/dist/pluginData.d.ts.map +1 -0
- package/dist/react.d.ts +3436 -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 +46 -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 +141 -0
- package/dist/ws.js.map +7 -0
- package/package.json +45 -21
- package/src/host-ui.ts +80 -0
- package/src/host.tsx +229 -308
- package/src/index.d.ts +1 -0
- package/src/manifest.ts +25 -4
- package/src/pluginData.tsx +232 -0
- package/src/react.tsx +9 -127
- package/src/sdk.ts +81 -13
- package/src/viteHost.ts +309 -0
- package/src/ws.ts +127 -20
- 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 -62
- package/src/elements.ts +0 -257
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin data seam (host-side). Resolves where each plugin's UI/assets load
|
|
3
|
+
* from. `muscat-pk dev` sets `window.__RB_PREVIEW_PLUGIN_ID__`; that id routes
|
|
4
|
+
* to preview-host, everything else to the installed-plugin back end, so both
|
|
5
|
+
* coexist. The host passes its dialog/toast as `hostServices`, registered via
|
|
6
|
+
* setHostServices (see ./host-ui).
|
|
7
|
+
*/
|
|
8
|
+
import { type PropsWithChildren } from "react";
|
|
9
|
+
import type { PluginManifest } from "./manifest";
|
|
10
|
+
import { type PluginUIServices } from "@rainbow-robotics/plugin-ui/host-ui";
|
|
11
|
+
/**
|
|
12
|
+
* Where/how to load a plugin's UI module — no iframe involved, the host
|
|
13
|
+
* mounts it directly.
|
|
14
|
+
*
|
|
15
|
+
* - "dev": the plugin's own Vite dev server (muscat-pk dev). `bootstrapUrl` is
|
|
16
|
+
* a plain ESM module exposing `mount(container, rb, hostServices)`; react
|
|
17
|
+
* and plugin-ui resolve from that dev server's own module graph, so this
|
|
18
|
+
* mount is a fully self-consistent, independently-rooted React tree.
|
|
19
|
+
* - "esm": a built plugin (`muscat-pk build` / robot runtime), a plain ESM
|
|
20
|
+
* module the host dynamically imports. react / rb-components / plugin-ui
|
|
21
|
+
* context modules are left external as bare specifiers, resolved by the host
|
|
22
|
+
* page's import map to the host's own already-loaded instances — so it mounts
|
|
23
|
+
* as a genuine nested React tree with working Context (RbContext, host-ui)
|
|
24
|
+
* and no duplicate React instance.
|
|
25
|
+
*/
|
|
26
|
+
export type PluginModuleSource = {
|
|
27
|
+
kind: "dev";
|
|
28
|
+
bootstrapUrl: string;
|
|
29
|
+
} | {
|
|
30
|
+
kind: "esm";
|
|
31
|
+
entryUrl: string;
|
|
32
|
+
};
|
|
33
|
+
export interface PluginDataSource {
|
|
34
|
+
/** Preview plugin manifest (only while a dev plugin is being previewed). */
|
|
35
|
+
usePluginManifest: () => {
|
|
36
|
+
data: PluginManifest | null;
|
|
37
|
+
isLoading: boolean;
|
|
38
|
+
};
|
|
39
|
+
/** Where/how to load a plugin's UI module for a given UI entry. */
|
|
40
|
+
getModuleSource: (pluginId: string, ui: string) => PluginModuleSource;
|
|
41
|
+
/** URL of a plugin asset (e.g. an icon) by its manifest-relative path. */
|
|
42
|
+
getAssetUrl: (pluginId: string, assetPath: string) => string;
|
|
43
|
+
/** Socket.IO server URL the plugin connects to. */
|
|
44
|
+
getSocketUrl: (pluginId: string) => string;
|
|
45
|
+
}
|
|
46
|
+
export declare function usePluginData(): PluginDataSource;
|
|
47
|
+
export interface PluginDataProviderProps {
|
|
48
|
+
/**
|
|
49
|
+
* The host's real dialog/toast, registered for plugins to use via
|
|
50
|
+
* `@rainbow-robotics/plugin-ui/host-ui`. The host builds these ONCE inside
|
|
51
|
+
* its own React tree (calling its real useDialog) and passes the resulting
|
|
52
|
+
* plain functions here — safe to call from a plugin's separate React
|
|
53
|
+
* instance (dev). See ./host-ui.
|
|
54
|
+
*/
|
|
55
|
+
hostServices: PluginUIServices;
|
|
56
|
+
/** Socket.IO URL for installed (non-preview) plugins. */
|
|
57
|
+
wsUrl?: string;
|
|
58
|
+
/** URL prefix the host serves installed plugins from. */
|
|
59
|
+
liveBase?: string;
|
|
60
|
+
}
|
|
61
|
+
export declare function PluginDataProvider({ children, hostServices, wsUrl, liveBase, }: PropsWithChildren<PluginDataProviderProps>): import("react/jsx-runtime").JSX.Element;
|
|
62
|
+
//# sourceMappingURL=pluginData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pluginData.d.ts","sourceRoot":"","sources":["../src/pluginData.tsx"],"names":[],"mappings":"AACA;;;;;;GAMG;AACH,OAAO,EAML,KAAK,iBAAiB,EACvB,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGjD,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,QAAgD,GACjD,EAAE,iBAAiB,CAAC,uBAAuB,CAAC,2CAqC5C"}
|