@rainbow-robotics/plugin-ui 0.1.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.
Files changed (42) hide show
  1. package/README.md +85 -0
  2. package/build-browser.mjs +84 -0
  3. package/build-dist.mjs +42 -0
  4. package/dist/connect.d.ts +12 -0
  5. package/dist/connect.d.ts.map +1 -0
  6. package/dist/connect.js +29 -0
  7. package/dist/connect.js.map +7 -0
  8. package/dist/elements.d.ts +195 -0
  9. package/dist/elements.d.ts.map +1 -0
  10. package/dist/elements.js +115 -0
  11. package/dist/elements.js.map +7 -0
  12. package/dist/manifest.d.ts +65 -0
  13. package/dist/manifest.d.ts.map +1 -0
  14. package/dist/manifest.js +29 -0
  15. package/dist/manifest.js.map +7 -0
  16. package/dist/react.d.ts +47 -0
  17. package/dist/react.d.ts.map +1 -0
  18. package/dist/react.js +57 -0
  19. package/dist/react.js.map +7 -0
  20. package/dist/sdk.d.ts +14 -0
  21. package/dist/sdk.d.ts.map +1 -0
  22. package/dist/sdk.js +23 -0
  23. package/dist/sdk.js.map +7 -0
  24. package/dist-browser/@rainbow-robotics/plugin-ui/chunks/chunk-AMCIKVG7.js +1 -0
  25. package/dist-browser/@rainbow-robotics/plugin-ui/chunks/chunk-GJWPOWHG.js +1 -0
  26. package/dist-browser/@rainbow-robotics/plugin-ui/chunks/chunk-JRCDA3EG.js +1 -0
  27. package/dist-browser/@rainbow-robotics/plugin-ui/connect.js +1 -0
  28. package/dist-browser/@rainbow-robotics/plugin-ui/elements.js +1 -0
  29. package/dist-browser/@rainbow-robotics/plugin-ui/react.js +1 -0
  30. package/dist-browser/@rainbow-robotics/plugin-ui/sdk.js +1 -0
  31. package/dist-browser/vendor/react-dom-client.js +1 -0
  32. package/dist-browser/vendor/react-jsx-dev-runtime.js +1 -0
  33. package/dist-browser/vendor/react-jsx-runtime.js +1 -0
  34. package/dist-browser/vendor/react-runtime.js +65 -0
  35. package/dist-browser/vendor/react.js +1 -0
  36. package/package.json +73 -0
  37. package/src/connect.ts +68 -0
  38. package/src/elements.ts +257 -0
  39. package/src/host.tsx +343 -0
  40. package/src/manifest.ts +92 -0
  41. package/src/react.tsx +131 -0
  42. package/src/sdk.ts +41 -0
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Plugin manifest schema — the single source of truth shared by the front end
3
+ * (nexus reads it) and the back end (rby2 mirrors it for validation).
4
+ *
5
+ * Evolve additively only.
6
+ */
7
+ /** Known contribution points the host understands. */
8
+ export declare const CONTRIBUTION_POINTS: readonly ["header.toolbar", "lnb", "move.panel", "program.panel"];
9
+ export type ContributionPoint = (typeof CONTRIBUTION_POINTS)[number];
10
+ /** How a header.toolbar contribution opens when clicked. */
11
+ export type ContributionOpens = "popover" | "panel" | "page";
12
+ export interface PluginContribution {
13
+ /** Where this contribution mounts. */
14
+ point: ContributionPoint | (string & {});
15
+ /** Icon path relative to the plugin root (e.g. "assets/icon.svg"). */
16
+ icon?: string;
17
+ /** Display label. */
18
+ label?: string;
19
+ /** For header.toolbar: how the contribution surfaces. */
20
+ opens?: ContributionOpens;
21
+ }
22
+ export interface PluginAction {
23
+ /** Action id referenced by `rb.action(id, payload)`. */
24
+ id: string;
25
+ /** Transport topic (Zenoh / ROS2) the back end routes to. */
26
+ topic: string;
27
+ /** Optional payload schema hint (field → type name). */
28
+ schema?: Record<string, string>;
29
+ }
30
+ export type PluginRuntime = {
31
+ type: "none";
32
+ } | {
33
+ type: "python";
34
+ entry: string;
35
+ } | {
36
+ type: "ros2";
37
+ package: string;
38
+ launch: string;
39
+ rosClient: "rclpy" | "rclcpp";
40
+ };
41
+ export interface PluginManifest {
42
+ /** Reverse-DNS unique id, e.g. "com.rainbow.gripper-tool". */
43
+ id: string;
44
+ /** Human-readable name. */
45
+ name: string;
46
+ /** Plugin version (semver). */
47
+ version: string;
48
+ /** Minimum host (Muscat) version this plugin supports. */
49
+ minAppVersion?: string;
50
+ /** Icon path relative to plugin root. */
51
+ icon?: string;
52
+ /** UI / chrome contributions. */
53
+ contributes?: PluginContribution[];
54
+ /** Host actions the plugin can invoke. */
55
+ actions?: PluginAction[];
56
+ /** Back-end runtime declaration. */
57
+ runtime?: PluginRuntime;
58
+ }
59
+ /**
60
+ * Lightweight structural check. Returns the list of problems (empty = valid).
61
+ * Kept dependency-free so both front and back ends can reuse it; richer
62
+ * validation (zod) can layer on top later without breaking this contract.
63
+ */
64
+ export declare function validateManifest(value: unknown): string[];
65
+ //# sourceMappingURL=manifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../src/manifest.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,sDAAsD;AACtD,eAAO,MAAM,mBAAmB,mEAKtB,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC;AAErE,4DAA4D;AAC5D,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;AAE7D,MAAM,WAAW,kBAAkB;IACjC,sCAAsC;IACtC,KAAK,EAAE,iBAAiB,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IACzC,sEAAsE;IACtE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qBAAqB;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yDAAyD;IACzD,KAAK,CAAC,EAAE,iBAAiB,CAAC;CAC3B;AAED,MAAM,WAAW,YAAY;IAC3B,wDAAwD;IACxD,EAAE,EAAE,MAAM,CAAC;IACX,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd,wDAAwD;IACxD,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACjC;IACE,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,OAAO,GAAG,QAAQ,CAAC;CAC/B,CAAC;AAEN,MAAM,WAAW,cAAc;IAC7B,8DAA8D;IAC9D,EAAE,EAAE,MAAM,CAAC;IACX,2BAA2B;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,+BAA+B;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,0DAA0D;IAC1D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,yCAAyC;IACzC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iCAAiC;IACjC,WAAW,CAAC,EAAE,kBAAkB,EAAE,CAAC;IACnC,0CAA0C;IAC1C,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IACzB,oCAAoC;IACpC,OAAO,CAAC,EAAE,aAAa,CAAC;CACzB;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,EAAE,CAiBzD"}
@@ -0,0 +1,29 @@
1
+ const CONTRIBUTION_POINTS = [
2
+ "header.toolbar",
3
+ "lnb",
4
+ "move.panel",
5
+ "program.panel"
6
+ ];
7
+ function validateManifest(value) {
8
+ const errors = [];
9
+ if (typeof value !== "object" || value === null) {
10
+ return ["manifest must be an object"];
11
+ }
12
+ const m = value;
13
+ if (typeof m.id !== "string" || m.id.length === 0)
14
+ errors.push("manifest.id is required (string)");
15
+ if (typeof m.name !== "string" || m.name.length === 0)
16
+ errors.push("manifest.name is required (string)");
17
+ if (typeof m.version !== "string" || m.version.length === 0)
18
+ errors.push("manifest.version is required (string)");
19
+ if (m.contributes !== void 0 && !Array.isArray(m.contributes))
20
+ errors.push("manifest.contributes must be an array");
21
+ if (m.actions !== void 0 && !Array.isArray(m.actions))
22
+ errors.push("manifest.actions must be an array");
23
+ return errors;
24
+ }
25
+ export {
26
+ CONTRIBUTION_POINTS,
27
+ validateManifest
28
+ };
29
+ //# sourceMappingURL=manifest.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/manifest.ts"],
4
+ "sourcesContent": ["/**\n * Plugin manifest schema \u2014 the single source of truth shared by the front end\n * (nexus reads it) and the back end (rby2 mirrors it for validation).\n *\n * Evolve additively only.\n */\n\n/** Known contribution points the host understands. */\nexport const CONTRIBUTION_POINTS = [\n \"header.toolbar\",\n \"lnb\",\n \"move.panel\",\n \"program.panel\",\n] as const;\n\nexport type ContributionPoint = (typeof CONTRIBUTION_POINTS)[number];\n\n/** How a header.toolbar contribution opens when clicked. */\nexport type ContributionOpens = \"popover\" | \"panel\" | \"page\";\n\nexport interface PluginContribution {\n /** Where this contribution mounts. */\n point: ContributionPoint | (string & {});\n /** Icon path relative to the plugin root (e.g. \"assets/icon.svg\"). */\n icon?: string;\n /** Display label. */\n label?: string;\n /** For header.toolbar: how the contribution surfaces. */\n opens?: ContributionOpens;\n}\n\nexport interface PluginAction {\n /** Action id referenced by `rb.action(id, payload)`. */\n id: string;\n /** Transport topic (Zenoh / ROS2) the back end routes to. */\n topic: string;\n /** Optional payload schema hint (field \u2192 type name). */\n schema?: Record<string, string>;\n}\n\nexport type PluginRuntime =\n | { type: \"none\" }\n | { type: \"python\"; entry: string }\n | {\n type: \"ros2\";\n package: string;\n launch: string;\n rosClient: \"rclpy\" | \"rclcpp\";\n };\n\nexport interface PluginManifest {\n /** Reverse-DNS unique id, e.g. \"com.rainbow.gripper-tool\". */\n id: string;\n /** Human-readable name. */\n name: string;\n /** Plugin version (semver). */\n version: string;\n /** Minimum host (Muscat) version this plugin supports. */\n minAppVersion?: string;\n /** Icon path relative to plugin root. */\n icon?: string;\n /** UI / chrome contributions. */\n contributes?: PluginContribution[];\n /** Host actions the plugin can invoke. */\n actions?: PluginAction[];\n /** Back-end runtime declaration. */\n runtime?: PluginRuntime;\n}\n\n/**\n * Lightweight structural check. Returns the list of problems (empty = valid).\n * Kept dependency-free so both front and back ends can reuse it; richer\n * validation (zod) can layer on top later without breaking this contract.\n */\nexport function validateManifest(value: unknown): string[] {\n const errors: string[] = [];\n if (typeof value !== \"object\" || value === null) {\n return [\"manifest must be an object\"];\n }\n const m = value as Record<string, unknown>;\n if (typeof m.id !== \"string\" || m.id.length === 0)\n errors.push(\"manifest.id is required (string)\");\n if (typeof m.name !== \"string\" || m.name.length === 0)\n errors.push(\"manifest.name is required (string)\");\n if (typeof m.version !== \"string\" || m.version.length === 0)\n errors.push(\"manifest.version is required (string)\");\n if (m.contributes !== undefined && !Array.isArray(m.contributes))\n errors.push(\"manifest.contributes must be an array\");\n if (m.actions !== undefined && !Array.isArray(m.actions))\n errors.push(\"manifest.actions must be an array\");\n return errors;\n}\n"],
5
+ "mappings": "AAQO,MAAM,sBAAsB;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AA6DO,SAAS,iBAAiB,OAA0B;AACzD,QAAM,SAAmB,CAAC;AAC1B,MAAI,OAAO,UAAU,YAAY,UAAU,MAAM;AAC/C,WAAO,CAAC,4BAA4B;AAAA,EACtC;AACA,QAAM,IAAI;AACV,MAAI,OAAO,EAAE,OAAO,YAAY,EAAE,GAAG,WAAW;AAC9C,WAAO,KAAK,kCAAkC;AAChD,MAAI,OAAO,EAAE,SAAS,YAAY,EAAE,KAAK,WAAW;AAClD,WAAO,KAAK,oCAAoC;AAClD,MAAI,OAAO,EAAE,YAAY,YAAY,EAAE,QAAQ,WAAW;AACxD,WAAO,KAAK,uCAAuC;AACrD,MAAI,EAAE,gBAAgB,UAAa,CAAC,MAAM,QAAQ,EAAE,WAAW;AAC7D,WAAO,KAAK,uCAAuC;AACrD,MAAI,EAAE,YAAY,UAAa,CAAC,MAAM,QAAQ,EAAE,OAAO;AACrD,WAAO,KAAK,mCAAmC;AACjD,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -0,0 +1,47 @@
1
+ import type { ComponentType, ReactNode, Ref } from "react";
2
+ import { RbSliderElement, RbButtonElement, RbIconButtonElement, RbTextElement, RbTextInputElement, RbSwitchElement, RbSelectElement, type RbButtonProps, type RbIconButtonProps, type RbSelectProps, type RbSliderProps, type RbSwitchProps, type RbTextInputProps, type RbTextProps } from "./elements";
3
+ type NoEventProps = Record<never, never>;
4
+ type RemoteElementComponentProps<Element, Props, EventProps = NoEventProps> = Props & EventProps & {
5
+ children?: ReactNode;
6
+ ref?: Ref<Element>;
7
+ slot?: string;
8
+ };
9
+ type RemoteElementComponent<Element, Props, EventProps = NoEventProps> = ComponentType<RemoteElementComponentProps<Element, Props, EventProps>>;
10
+ export type RbSliderChangeEvent = {
11
+ detail: number;
12
+ };
13
+ export type RbTextInputEvent = {
14
+ detail: string;
15
+ };
16
+ export type RbSwitchChangeEvent = {
17
+ detail: boolean;
18
+ };
19
+ export type RbSelectChangeEvent = {
20
+ detail: string;
21
+ };
22
+ export interface RbSliderEventProps {
23
+ onChange?: (event: RbSliderChangeEvent) => void;
24
+ }
25
+ export interface RbPressEventProps {
26
+ onPress?: () => void;
27
+ }
28
+ export interface RbTextInputEventProps {
29
+ onInput?: (event: RbTextInputEvent) => void;
30
+ }
31
+ export interface RbSwitchEventProps {
32
+ onChange?: (event: RbSwitchChangeEvent) => void;
33
+ }
34
+ export interface RbSelectEventProps {
35
+ onChange?: (event: RbSelectChangeEvent) => void;
36
+ }
37
+ export declare const Slider: RemoteElementComponent<RbSliderElement, RbSliderProps, RbSliderEventProps>;
38
+ export declare const Button: RemoteElementComponent<RbButtonElement, RbButtonProps, RbPressEventProps>;
39
+ export declare const IconButton: RemoteElementComponent<RbIconButtonElement, RbIconButtonProps, RbPressEventProps>;
40
+ export declare const Text: RemoteElementComponent<RbTextElement, RbTextProps>;
41
+ export declare const TextInput: RemoteElementComponent<RbTextInputElement, RbTextInputProps, RbTextInputEventProps>;
42
+ export declare const Switch: RemoteElementComponent<RbSwitchElement, RbSwitchProps, RbSwitchEventProps>;
43
+ export declare const Select: RemoteElementComponent<RbSelectElement, RbSelectProps, RbSelectEventProps>;
44
+ export { useRb } from "./sdk";
45
+ export type { RbSdk, RbNotifyType } from "./sdk";
46
+ export type { RbSelectOption } from "./elements";
47
+ //# sourceMappingURL=react.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,EACL,eAAe,EACf,eAAe,EACf,mBAAmB,EACnB,aAAa,EACb,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EACjB,MAAM,YAAY,CAAC;AAcpB,KAAK,YAAY,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AAEzC,KAAK,2BAA2B,CAC9B,OAAO,EACP,KAAK,EACL,UAAU,GAAG,YAAY,IACvB,KAAK,GACP,UAAU,GAAG;IACX,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,GAAG,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEJ,KAAK,sBAAsB,CACzB,OAAO,EACP,KAAK,EACL,UAAU,GAAG,YAAY,IACvB,aAAa,CAAC,2BAA2B,CAAC,OAAO,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC;AAE3E,MAAM,MAAM,mBAAmB,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AACrD,MAAM,MAAM,gBAAgB,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAClD,MAAM,MAAM,mBAAmB,GAAG;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,CAAC;AACtD,MAAM,MAAM,mBAAmB,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAErD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAC;CACjD;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC;CAC7C;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAC;CACjD;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAC;CACjD;AAED,eAAO,MAAM,MAAM,EAId,sBAAsB,CAAC,eAAe,EAAE,aAAa,EAAE,kBAAkB,CAAC,CAAC;AAChF,eAAO,MAAM,MAAM,EAId,sBAAsB,CAAC,eAAe,EAAE,aAAa,EAAE,iBAAiB,CAAC,CAAC;AAC/E,eAAO,MAAM,UAAU,EAIlB,sBAAsB,CACzB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,CAClB,CAAC;AACF,eAAO,MAAM,IAAI,EAGZ,sBAAsB,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;AACxD,eAAO,MAAM,SAAS,EAIjB,sBAAsB,CACzB,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,CACtB,CAAC;AACF,eAAO,MAAM,MAAM,EAId,sBAAsB,CAAC,eAAe,EAAE,aAAa,EAAE,kBAAkB,CAAC,CAAC;AAChF,eAAO,MAAM,MAAM,EAId,sBAAsB,CAAC,eAAe,EAAE,aAAa,EAAE,kBAAkB,CAAC,CAAC;AAEhF,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACjD,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
package/dist/react.js ADDED
@@ -0,0 +1,57 @@
1
+ import { createRemoteComponent } from "@remote-dom/react";
2
+ import {
3
+ RbSliderElement,
4
+ RbButtonElement,
5
+ RbIconButtonElement,
6
+ RbTextElement,
7
+ RbTextInputElement,
8
+ RbSwitchElement,
9
+ RbSelectElement
10
+ } from "./elements";
11
+ const events = (map) => ({ eventProps: map });
12
+ const Slider = createRemoteComponent(
13
+ "rb-slider",
14
+ RbSliderElement,
15
+ events({ onChange: { event: "change" } })
16
+ );
17
+ const Button = createRemoteComponent(
18
+ "rb-button",
19
+ RbButtonElement,
20
+ events({ onPress: { event: "press" } })
21
+ );
22
+ const IconButton = createRemoteComponent(
23
+ "rb-icon-button",
24
+ RbIconButtonElement,
25
+ events({ onPress: { event: "press" } })
26
+ );
27
+ const Text = createRemoteComponent(
28
+ "rb-text",
29
+ RbTextElement
30
+ );
31
+ const TextInput = createRemoteComponent(
32
+ "rb-text-input",
33
+ RbTextInputElement,
34
+ events({ onInput: { event: "input" } })
35
+ );
36
+ const Switch = createRemoteComponent(
37
+ "rb-switch",
38
+ RbSwitchElement,
39
+ events({ onChange: { event: "change" } })
40
+ );
41
+ const Select = createRemoteComponent(
42
+ "rb-select",
43
+ RbSelectElement,
44
+ events({ onChange: { event: "change" } })
45
+ );
46
+ import { useRb } from "./sdk";
47
+ export {
48
+ Button,
49
+ IconButton,
50
+ Select,
51
+ Slider,
52
+ Switch,
53
+ Text,
54
+ TextInput,
55
+ useRb
56
+ };
57
+ //# sourceMappingURL=react.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/react.tsx"],
4
+ "sourcesContent": ["/**\n * Author bindings \u2014 the React components a plugin author imports from\n * `@rainbow-robotics/plugin-ui/react`.\n *\n * These are *name tags*: they render rb-* custom elements into the sandbox's\n * remote DOM. The real rb-components are rendered by the host (see ./host).\n * Event names from each element's `remoteEvents` surface as `onX` props\n * (e.g. `change` \u2192 `onChange`) carrying a `RemoteEvent` whose `detail` holds\n * the payload.\n */\nimport { createRemoteComponent } from \"@remote-dom/react\";\nimport type { ComponentType, ReactNode, Ref } from \"react\";\nimport {\n RbSliderElement,\n RbButtonElement,\n RbIconButtonElement,\n RbTextElement,\n RbTextInputElement,\n RbSwitchElement,\n RbSelectElement,\n type RbButtonProps,\n type RbIconButtonProps,\n type RbSelectProps,\n type RbSliderProps,\n type RbSwitchProps,\n type RbTextInputProps,\n type RbTextProps,\n} from \"./elements\";\n\n// NOTE: createRemoteComponent only treats a prop as an event listener when it is\n// declared in `eventProps`; it does NOT auto-derive from the element's\n// `remoteEvents`. These maps MUST mirror the host's eventProps (see ./host).\n//\n// `eventProps` is typed against the element's *typed* EventListeners generic.\n// Fully typing those generics would also force typing every `remoteProperties`\n// shape on the classes (remote-dom itself uses @ts-expect-error around this), so\n// we cast the event maps here. The values are verified by the demo e2e, and the\n// returned components keep their element-derived prop types for plugin authors.\ntype EventMap = Record<string, { event: string }>;\nconst events = (map: EventMap) => ({ eventProps: map }) as never;\n\ntype NoEventProps = Record<never, never>;\n\ntype RemoteElementComponentProps<\n Element,\n Props,\n EventProps = NoEventProps,\n> = Props &\n EventProps & {\n children?: ReactNode;\n ref?: Ref<Element>;\n slot?: string;\n };\n\ntype RemoteElementComponent<\n Element,\n Props,\n EventProps = NoEventProps,\n> = ComponentType<RemoteElementComponentProps<Element, Props, EventProps>>;\n\nexport type RbSliderChangeEvent = { detail: number };\nexport type RbTextInputEvent = { detail: string };\nexport type RbSwitchChangeEvent = { detail: boolean };\nexport type RbSelectChangeEvent = { detail: string };\n\nexport interface RbSliderEventProps {\n onChange?: (event: RbSliderChangeEvent) => void;\n}\n\nexport interface RbPressEventProps {\n onPress?: () => void;\n}\n\nexport interface RbTextInputEventProps {\n onInput?: (event: RbTextInputEvent) => void;\n}\n\nexport interface RbSwitchEventProps {\n onChange?: (event: RbSwitchChangeEvent) => void;\n}\n\nexport interface RbSelectEventProps {\n onChange?: (event: RbSelectChangeEvent) => void;\n}\n\nexport const Slider = createRemoteComponent(\n \"rb-slider\",\n RbSliderElement,\n events({ onChange: { event: \"change\" } }),\n) as RemoteElementComponent<RbSliderElement, RbSliderProps, RbSliderEventProps>;\nexport const Button = createRemoteComponent(\n \"rb-button\",\n RbButtonElement,\n events({ onPress: { event: \"press\" } }),\n) as RemoteElementComponent<RbButtonElement, RbButtonProps, RbPressEventProps>;\nexport const IconButton = createRemoteComponent(\n \"rb-icon-button\",\n RbIconButtonElement,\n events({ onPress: { event: \"press\" } }),\n) as RemoteElementComponent<\n RbIconButtonElement,\n RbIconButtonProps,\n RbPressEventProps\n>;\nexport const Text = createRemoteComponent(\n \"rb-text\",\n RbTextElement,\n) as RemoteElementComponent<RbTextElement, RbTextProps>;\nexport const TextInput = createRemoteComponent(\n \"rb-text-input\",\n RbTextInputElement,\n events({ onInput: { event: \"input\" } }),\n) as RemoteElementComponent<\n RbTextInputElement,\n RbTextInputProps,\n RbTextInputEventProps\n>;\nexport const Switch = createRemoteComponent(\n \"rb-switch\",\n RbSwitchElement,\n events({ onChange: { event: \"change\" } }),\n) as RemoteElementComponent<RbSwitchElement, RbSwitchProps, RbSwitchEventProps>;\nexport const Select = createRemoteComponent(\n \"rb-select\",\n RbSelectElement,\n events({ onChange: { event: \"change\" } }),\n) as RemoteElementComponent<RbSelectElement, RbSelectProps, RbSelectEventProps>;\n\nexport { useRb } from \"./sdk\";\nexport type { RbSdk, RbNotifyType } from \"./sdk\";\nexport type { RbSelectOption } from \"./elements\";\n"],
5
+ "mappings": "AAUA,SAAS,6BAA6B;AAEtC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAQK;AAYP,MAAM,SAAS,CAAC,SAAmB,EAAE,YAAY,IAAI;AA8C9C,MAAM,SAAS;AAAA,EACpB;AAAA,EACA;AAAA,EACA,OAAO,EAAE,UAAU,EAAE,OAAO,SAAS,EAAE,CAAC;AAC1C;AACO,MAAM,SAAS;AAAA,EACpB;AAAA,EACA;AAAA,EACA,OAAO,EAAE,SAAS,EAAE,OAAO,QAAQ,EAAE,CAAC;AACxC;AACO,MAAM,aAAa;AAAA,EACxB;AAAA,EACA;AAAA,EACA,OAAO,EAAE,SAAS,EAAE,OAAO,QAAQ,EAAE,CAAC;AACxC;AAKO,MAAM,OAAO;AAAA,EAClB;AAAA,EACA;AACF;AACO,MAAM,YAAY;AAAA,EACvB;AAAA,EACA;AAAA,EACA,OAAO,EAAE,SAAS,EAAE,OAAO,QAAQ,EAAE,CAAC;AACxC;AAKO,MAAM,SAAS;AAAA,EACpB;AAAA,EACA;AAAA,EACA,OAAO,EAAE,UAAU,EAAE,OAAO,SAAS,EAAE,CAAC;AAC1C;AACO,MAAM,SAAS;AAAA,EACpB;AAAA,EACA;AAAA,EACA,OAAO,EAAE,UAAU,EAAE,OAAO,SAAS,EAAE,CAAC;AAC1C;AAEA,SAAS,aAAa;",
6
+ "names": []
7
+ }
package/dist/sdk.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ export type RbNotifyType = "info" | "success" | "warning" | "error";
2
+ export interface RbSdk {
3
+ /**
4
+ * Invoke a host-side action (declared in manifest.actions). Resolves with
5
+ * whatever the host/back end returns.
6
+ */
7
+ action: (id: string, payload?: unknown) => Promise<unknown>;
8
+ /** Show a transient notification through the host's toast system. */
9
+ notify: (message: string, type?: RbNotifyType) => void;
10
+ }
11
+ export declare const RbContext: import("react").Context<RbSdk>;
12
+ /** Access the host SDK from within a plugin component. */
13
+ export declare function useRb(): RbSdk;
14
+ //# sourceMappingURL=sdk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;AAEpE,MAAM,WAAW,KAAK;IACpB;;;OAGG;IACH,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5D,qEAAqE;IACrE,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,YAAY,KAAK,IAAI,CAAC;CACxD;AAgBD,eAAO,MAAM,SAAS,gCAAgC,CAAC;AAEvD,0DAA0D;AAC1D,wBAAgB,KAAK,IAAI,KAAK,CAE7B"}
package/dist/sdk.js ADDED
@@ -0,0 +1,23 @@
1
+ import { createContext, useContext } from "react";
2
+ const noopSdk = {
3
+ action: async () => {
4
+ if (typeof console !== "undefined") {
5
+ console.warn("[plugin-ui] rb.action called outside of a host context");
6
+ }
7
+ return void 0;
8
+ },
9
+ notify: (message) => {
10
+ if (typeof console !== "undefined") {
11
+ console.warn("[plugin-ui] rb.notify (no host):", message);
12
+ }
13
+ }
14
+ };
15
+ const RbContext = createContext(noopSdk);
16
+ function useRb() {
17
+ return useContext(RbContext);
18
+ }
19
+ export {
20
+ RbContext,
21
+ useRb
22
+ };
23
+ //# sourceMappingURL=sdk.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/sdk.ts"],
4
+ "sourcesContent": ["/**\n * Plugin runtime SDK \u2014 the small, stable surface a plugin author calls from\n * inside the sandbox to talk to the host (Muscat / nexus).\n *\n * The concrete implementation is injected by the host across the iframe thread\n * (see ./connect for the sandbox side, ./host for the host side).\n */\nimport { createContext, useContext } from \"react\";\n\nexport type RbNotifyType = \"info\" | \"success\" | \"warning\" | \"error\";\n\nexport interface RbSdk {\n /**\n * Invoke a host-side action (declared in manifest.actions). Resolves with\n * whatever the host/back end returns.\n */\n action: (id: string, payload?: unknown) => Promise<unknown>;\n /** Show a transient notification through the host's toast system. */\n notify: (message: string, type?: RbNotifyType) => void;\n}\n\nconst noopSdk: RbSdk = {\n action: async () => {\n if (typeof console !== \"undefined\") {\n console.warn(\"[plugin-ui] rb.action called outside of a host context\");\n }\n return undefined;\n },\n notify: (message) => {\n if (typeof console !== \"undefined\") {\n console.warn(\"[plugin-ui] rb.notify (no host):\", message);\n }\n },\n};\n\nexport const RbContext = createContext<RbSdk>(noopSdk);\n\n/** Access the host SDK from within a plugin component. */\nexport function useRb(): RbSdk {\n return useContext(RbContext);\n}\n"],
5
+ "mappings": "AAOA,SAAS,eAAe,kBAAkB;AAc1C,MAAM,UAAiB;AAAA,EACrB,QAAQ,YAAY;AAClB,QAAI,OAAO,YAAY,aAAa;AAClC,cAAQ,KAAK,wDAAwD;AAAA,IACvE;AACA,WAAO;AAAA,EACT;AAAA,EACA,QAAQ,CAAC,YAAY;AACnB,QAAI,OAAO,YAAY,aAAa;AAClC,cAAQ,KAAK,oCAAoC,OAAO;AAAA,IAC1D;AAAA,EACF;AACF;AAEO,MAAM,YAAY,cAAqB,OAAO;AAG9C,SAAS,QAAe;AAC7B,SAAO,WAAW,SAAS;AAC7B;",
6
+ "names": []
7
+ }
@@ -0,0 +1 @@
1
+ var g=Object.defineProperty;var f=a=>{throw TypeError(a)};var h=(a,b,c)=>b in a?g(a,b,{enumerable:!0,configurable:!0,writable:!0,value:c}):a[b]=c;var i=(a,b,c)=>h(a,typeof b!="symbol"?b+"":b,c),d=(a,b,c)=>b.has(a)||f("Cannot "+c);var j=(a,b,c)=>(d(a,b,"read from private field"),c?c.call(a):b.get(a)),k=(a,b,c)=>b.has(a)?f("Cannot add the same private member more than once"):b instanceof WeakSet?b.add(a):b.set(a,c),l=(a,b,c,e)=>(d(a,b,"write to private field"),e?e.call(a,c):b.set(a,c),c),m=(a,b,c)=>(d(a,b,"access private method"),c);export{i as a,j as b,k as c,l as d,m as e};
@@ -0,0 +1 @@
1
+ import{createContext as o,useContext as e}from"react";var t={action:async()=>{typeof console<"u"&&console.warn("[plugin-ui] rb.action called outside of a host context")},notify:n=>{typeof console<"u"&&console.warn("[plugin-ui] rb.notify (no host):",n)}},i=o(t);function s(){return e(i)}export{i as a,s as b};
@@ -0,0 +1 @@
1
+ import{a as v,b as P,c as Q,d as ee}from"./chunk-AMCIKVG7.js";var M=class extends CustomEvent{respondWith(t){this.response=t}};var g=new WeakMap;var B=new WeakMap,ce=0;function y(e){let t=B.get(e);return t==null&&(t=String(ce++),k(e,t)),t}function k(e,t){B.set(e,t)}var L=new WeakMap;function S(e){return L.get(e)}var I=new WeakMap;function ae(e){let t=I.get(e);if(t!=null)return t;if(!(!(e instanceof Element)||e.tagName.includes("-"))){t={};for(let{name:r,value:n}of e.attributes)t[r]=n;return t}}var z=new WeakMap;function Y(e){return z.get(e)}function _(e,t,r){let n=L.get(e);if(n==null&&(n={},L.set(e,n)),n[t]===r)return;n[t]=r;let o=g.get(e);o?.mutate([[3,y(e),t,r,1]])}function A(e,t,r){let n=I.get(e);if(n==null&&(n={},I.set(e,n)),n[t]===r)return;r==null?delete n[t]:n[t]=String(r);let o=g.get(e);o?.mutate([[3,y(e),t,r,2]])}function j(e,t,r){let n=z.get(e);if(n==null&&(n={},z.set(e,n)),n[t]===r)return;r==null?delete n[t]:n[t]=r;let o=g.get(e);o?.mutate([[3,y(e),t,r,3]])}function D(e,t){if(g.get(e)!==t&&(g.set(e,t),e.childNodes))for(let n=0;n<e.childNodes.length;n++)D(e.childNodes[n],t)}function O(e){if(g.get(e)!=null&&(g.delete(e),e.childNodes))for(let r=0;r<e.childNodes.length;r++)O(e.childNodes[r])}function T(e){let{nodeType:t}=e;switch(t){case 1:return{id:y(e),type:t,element:e.localName,properties:w(S(e)),attributes:w(ae(e)),eventListeners:w(Y(e)),children:Array.from(e.childNodes).map(T)};case 3:case 8:return{id:y(e),type:t,data:e.data};default:throw new Error(`Cannot serialize node of type ${e.nodeType} (${typeof e.nodeType})`)}}function w(e){return e?{...e}:void 0}function te(e,t,...r){let n=B.get(e),o=g.get(e);if(n==null||o==null)throw new Error(`Cannot call method ${t} on an unconnected node`);return o.call(n,t,...r)}var U=Object.freeze({});var p=class extends HTMLElement{static get observedAttributes(){return this.finalize().__observedAttributes}static get remotePropertyDefinitions(){return this.finalize().__remotePropertyDefinitions}static get remoteAttributeDefinitions(){return this.finalize().__remoteAttributeDefinitions}static get remoteEventDefinitions(){return this.finalize().__remoteEventDefinitions}static get remoteSlotDefinitions(){return this.finalize().__remoteSlotDefinitions}static createProperty(t,r){F(t,r,this.observedAttributes,this.remotePropertyDefinitions,this.__attributeToPropertyMap,this.__eventToPropertyMap)}static finalize(){if(this.hasOwnProperty("__finalized"))return this;this.__finalized=!0;let{slottable:t,remoteSlots:r,remoteProperties:n,remoteAttributes:o,remoteEvents:i,remoteMethods:s}=this,c=Object.getPrototypeOf(this),a=new Set;t&&a.add("slot");let u=new Map,d=new Map,f=new Map,h=new Map,b=new Map,E=new Map;if(typeof c.finalize=="function"&&(c.finalize(),c.observedAttributes.forEach(l=>{a.add(l)}),c.remotePropertyDefinitions.forEach((l,m)=>{h.set(m,l)}),c.remoteAttributeDefinitions.forEach((l,m)=>{b.set(m,l)}),c.remoteEventDefinitions.forEach((l,m)=>{E.set(m,l)}),c.remoteSlotDefinitions.forEach((l,m)=>{f.set(m,l)})),r!=null&&(Array.isArray(r)?r:Object.keys(r)).forEach(m=>{f.set(m,U)}),n!=null&&(Array.isArray(n)?n.forEach(l=>{F(l,void 0,a,h,u,d)}):Object.keys(n).forEach(l=>{F(l,n[l],a,h,u,d)})),o?.forEach(l=>{b.set(l,U),a.add(l)}),i!=null&&(Array.isArray(i)?i.forEach(l=>{E.set(l,U)}):Object.keys(i).forEach(l=>{E.set(l,i[l])})),s!=null)if(Array.isArray(s))for(let l of s)this.prototype[l]=function(...m){return this.callRemoteMethod(l,...m)};else Object.assign(this,s);return Object.defineProperties(this,{__observedAttributes:{value:[...a],enumerable:!1},__remoteSlotDefinitions:{value:f,enumerable:!1},__remotePropertyDefinitions:{value:h,enumerable:!1},__remoteAttributeDefinitions:{value:b,enumerable:!1},__remoteEventDefinitions:{value:E,enumerable:!1},__attributeToPropertyMap:{value:u,enumerable:!1},__eventToPropertyMap:{value:d,enumerable:!1}}),this}constructor(){super(),this.constructor.finalize();let t={},r={},n=Object.getPrototypeOf(this),o=this.constructor;for(let[i,s]of o.remotePropertyDefinitions.entries()){let c=s.name;if(n.hasOwnProperty(i))continue;i===c&&(r[i]=s.default);let a={configurable:!0,enumerable:i===c,get:()=>S(this)?.[c],set:u=>{_(this,c,u)}};t[i]=a}for(let[i,s]of o.remoteEventDefinitions.entries()){let c=s.property??!0;if(!c)continue;let a=c===!0?`on${i}`:c;t[a]={configurable:!0,enumerable:!0,get:()=>N(this).properties.get(a)??null,set:u=>{let d=N(this),f=d.properties.get(a);if(typeof u=="function"){let h=function(...b){return u.call(this,...b)};d.properties.set(a,h),this.addEventListener(i,h)}else d.properties.delete(a);f&&this.removeEventListener(i,f)}}}Object.defineProperties(this,t),Object.assign(this,r)}attributeChangedCallback(t,r,n){if(t==="slot"&&this.constructor.slottable){A(this,t,n?String(n):void 0);return}let{remotePropertyDefinitions:o,remoteAttributeDefinitions:i,__attributeToPropertyMap:s}=this.constructor;if(i.has(t)){A(this,t,n);return}let c=s.get(t),a=c==null?c:o.get(c);a!=null&&(this[c]=ue(n,a.type))}connectedCallback(){for(let[t,r]of this.constructor.remoteEventDefinitions.entries())r.bubbles&&this.addEventListener(t,ne)}disconnectedCallback(){for(let[t,r]of this.constructor.remoteEventDefinitions.entries())r.bubbles&&this.removeEventListener(t,ne)}addEventListener(t,r,n){let{remoteEventDefinitions:o,__eventToPropertyMap:i}=this.constructor,s=o.get(t),c=i.get(t);if(s==null&&c==null)return super.addEventListener(t,r,n);let a=N(this),u=le.call(this,t,{property:c,definition:s}),d=typeof n=="object"&&n?.once?(...h)=>{let b=typeof r=="object"?r.handleEvent(...h):r.call(this,...h);return W.call(this,t,r,f),b}:r,f=[d,u];u.listeners.add(r),a.listeners.set(r,f),super.addEventListener(t,d,n),typeof n=="object"&&n.signal&&n.signal.addEventListener("abort",()=>{W.call(this,t,r,f)},{once:!0}),s?j(this,t,u.dispatch):_(this,c,u.dispatch)}removeEventListener(t,r,n){let o=$.get(this)?.listeners.get(r),i=o?o[0]:r;super.removeEventListener(t,i,n),o!=null&&W.call(this,t,r,o)}updateRemoteProperty(t,r){_(this,t,r)}updateRemoteAttribute(t,r){A(this,t,r)}callRemoteMethod(t,...r){return te(this,t,...r)}};v(p,"slottable",!0),v(p,"__finalized",!0),v(p,"__observedAttributes",[]),v(p,"__attributeToPropertyMap",new Map),v(p,"__eventToPropertyMap",new Map),v(p,"__remotePropertyDefinitions",new Map),v(p,"__remoteAttributeDefinitions",new Map),v(p,"__remoteEventDefinitions",new Map),v(p,"__remoteSlotDefinitions",new Map);var $=new WeakMap;function N(e){let t=$.get(e);return t||(t={events:new Map,properties:new Map,listeners:new WeakMap},$.set(e,t),t)}function le(e,{property:t,definition:r}){let n=N(this),o=n.events.get(e);return o==null&&(o={name:e,property:t,definition:r,listeners:new Set,dispatch:(...i)=>{let s=r?.dispatchEvent?.apply(this,i)??new M(e,{detail:i[0],bubbles:r?.bubbles});return this.dispatchEvent(s),s.response}},n.events.set(e,o)),o}function W(e,t,r){let n=N(this),o=r[1];o.listeners.delete(t),n.listeners.delete(t),!(o.listeners.size>0)&&(n.events.delete(e),o.property?S(this)?.[o.property]===o.dispatch&&_(this,o.property,void 0):Y(this)?.[e]===o.dispatch&&j(this,e,void 0))}function F(e,t,r,n,o,i){if(n.has(e))return n.get(e);let s=e[0]==="o"&&e[1]==="n",c=t??{},{alias:a}=c,{type:u=s?Function:String,attribute:d=u!==Function,event:f=s,default:h=u===Boolean?!1:void 0}=c;if(a==null){let m=e.toLowerCase();m!==e&&(a=[m]),s&&(a??(a=[]),a.unshift(`_${e}`))}let b;d===!0?b=re(e):typeof d=="string"&&(b=d),b&&(Array.isArray(r)?r.push(b):r.add(b),o.set(b,e));let E;f===!0?E=re(s?e.slice(2):e):typeof f=="string"&&(E=f),E&&i.set(E,e);let l={name:e,type:u,alias:a,event:E,attribute:b,default:h};if(n.set(e,l),a)for(let m of a)n.set(m,l);return l}function ue(e,t){if(e!=null)switch(t){case Boolean:return e!=null&&e!=="false";case Object:case Array:try{return JSON.parse(e)}catch{return}case String:return String(e);case Number:return Number.parseFloat(e);case Function:return;default:return t.parse?.(e)}}function re(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function ne(){}var R,H=class extends MutationObserver{constructor(r){super(n=>{let o=[],i=[];for(let s of n){let c=y(s.target);if(s.type==="childList"){let a=s.previousSibling?pe(s.previousSibling,s.target.childNodes)+1:0;s.removedNodes.forEach(u=>{O(u),i.push([1,c,a])}),s.addedNodes.forEach((u,d)=>{o.some(f=>f===u||f.contains(u))||(o.push(u),D(u,r),i.push([0,c,T(u),a+d]))})}else s.type==="characterData"?i.push([2,c,s.target.textContent??""]):s.type==="attributes"&&s.attributeName!=null&&s.target instanceof Element&&!s.target.tagName.includes("-")&&i.push([3,c,s.attributeName,s.target.getAttribute(s.attributeName)])}r.mutate(i)});Q(this,R);this.connection=r,ee(this,R,new Set)}observe(r,n){let o=n?.id??"~";if(k(r,o),P(this,R).add(r),n?.initial!==!1&&r.childNodes.length>0){if(o!=="~")this.connection.mutate([[0,"~",T(r),P(this,R).size-1]]);else if(r.childNodes.length>0){let i=[];for(let s=0;s<r.childNodes.length;s++){let c=r.childNodes[s];D(c,this.connection),i.push([0,"~",T(c),s])}this.connection.mutate(i)}}super.observe(r,{subtree:!0,childList:!0,attributes:!0,characterData:!0,...n})}disconnect({empty:r=!1}={}){if(r&&P(this,R).size>0){let n=[];for(let o of P(this,R)){O(o);let i=y(o);if(i==="~")for(let s=0;s<o.childNodes.length;s++)n.push([1,i,0]);else n.push([1,"~",0])}this.connection.mutate(n)}P(this,R).clear(),super.disconnect()}};R=new WeakMap;function pe(e,t){for(let r=0;r<t.length;r++)if(t[r]===e)return r;return-1}var V=class extends p{static get remoteProperties(){return{value:{type:Number},min:{type:Number},max:{type:Number},step:{type:Number},disabled:{type:Boolean}}}static get remoteEvents(){return["change"]}},J=class extends p{static get remoteProperties(){return{label:{type:String},variant:{type:String},size:{type:String},disabled:{type:Boolean}}}static get remoteEvents(){return["press"]}},K=class extends p{static get remoteProperties(){return{icon:{type:String},variant:{type:String},size:{type:String},disabled:{type:Boolean}}}static get remoteEvents(){return["press"]}},X=class extends p{static get remoteProperties(){return{}}},Z=class extends p{static get remoteProperties(){return{value:{type:String},placeholder:{type:String},disabled:{type:Boolean}}}static get remoteEvents(){return["input"]}},q=class extends p{static get remoteProperties(){return{checked:{type:Boolean},disabled:{type:Boolean}}}static get remoteEvents(){return["change"]}},G=class extends p{static get remoteProperties(){return{value:{type:String},options:{type:Array},placeholder:{type:String},disabled:{type:Boolean}}}static get remoteEvents(){return["change"]}},De=["rb-slider","rb-button","rb-icon-button","rb-text","rb-text-input","rb-switch","rb-select"],ie=!1;function Oe(){ie||typeof customElements>"u"||(ie=!0,customElements.define("rb-slider",V),customElements.define("rb-button",J),customElements.define("rb-icon-button",K),customElements.define("rb-text",X),customElements.define("rb-text-input",Z),customElements.define("rb-switch",q),customElements.define("rb-select",G))}export{H as a,V as b,J as c,K as d,X as e,Z as f,q as g,G as h,De as i,Oe as j};
@@ -0,0 +1 @@
1
+ import{a as v}from"./chunks/chunk-GJWPOWHG.js";import{a as Q,j as X}from"./chunks/chunk-JRCDA3EG.js";import{a as I,b as c,c as p,d as L,e as m}from"./chunks/chunk-AMCIKVG7.js";var W=Symbol.for("quilt.threads.serialize"),tt=Symbol.for("quilt.threads.transferable");var z=class extends AbortController{constructor(...t){super();let e=t.find(r=>r.aborted);if(e)this.abort(e.reason);else{let r=n=>this.abort(n.target.reason),o={signal:this.signal};for(let n of t)n.addEventListener("abort",r,o)}}};var C=class extends Error{constructor(){super("You attempted to call a function on a closed thread.")}};var at="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";function N(a=21){let t="",e=crypto.getRandomValues(new Uint8Array(a));for(let r=0;r<a;r++)t+=at[63&e[r]];return t}var A,y,x,O,_,et,F=class{constructor(){p(this,_);p(this,A,new Map);p(this,y,new Map);p(this,x,new Map);p(this,O,new WeakMap)}get(t){return c(this,y).get(t)}release(t){let e=c(this,y).get(t);return e&&(c(this,y).delete(t),c(this,A).delete(e)),!!e}serialize(t){let e=c(this,A).get(t);return e==null&&(e=N(),c(this,A).set(t,e),c(this,y).set(e,t)),e}deserialize(t,e){let r=c(this,x).get(t)?.deref();return r||(r=(...o)=>{if(!c(this,x).has(t))throw new Error("You attempted to call a function that was already revoked.");return e.call((n,s,l)=>{e.messages.send([3,n,t,s],l)},o)},m(this,_,et).call(this,e)?.register(r,t),c(this,x).set(t,new WeakRef(r)),r)}};A=new WeakMap,y=new WeakMap,x=new WeakMap,O=new WeakMap,_=new WeakSet,et=function(t){let e=c(this,O).get(t);if(!(typeof FinalizationRegistry>"u"))return e||(e=new FinalizationRegistry(r=>{t.messages.send([5,r])}),c(this,O).set(t,e)),e};function rt(a){return a!=null&&(Symbol.asyncIterator in a||Symbol.iterator in a)&&typeof a.next=="function"}function Y(a){if(a==null||typeof a!="object")return!1;let t=Object.getPrototypeOf(a);return t==null||t===Object.prototype}var V="_@f",ot="_@i",T,M,h,k,w,U=class{constructor(t){p(this,h);p(this,T);p(this,M);L(this,T,t?.serialize),L(this,M,t?.deserialize)}serialize(t,e,r){return m(this,h,k).call(this,t,e,r)}deserialize(t,e){return m(this,h,w).call(this,t,e)}};T=new WeakMap,M=new WeakMap,h=new WeakSet,k=function(t,e,r,o=new Map,n=!1){if(t==null)return t;if(o.has(t))return o.get(t);if(o.set(t,void 0),typeof t=="object"){if(c(this,T)&&!n){let i=c(this,T).call(this,t,f=>m(this,h,k).call(this,f,e,r,o,!0),e,r);if(i!==void 0)return o.set(t,i),i}if(t[tt])return r?.push(t),o.set(t,t),t;let s=i=>m(this,h,k).call(this,i,e,r,o);if(typeof t[W]=="function"){let i=t[W]({serialize:s});return o.set(t,i),i}if(Array.isArray(t)){let i=t.map(f=>s(f));return o.set(t,i),i}if(t instanceof Map){let i=[...t.entries()].map(([E,g])=>[s(E),s(g)]),f=new Map(i);return o.set(t,f),f}if(t instanceof Set){let i=[...t].map(E=>s(E)),f=new Set(i);return o.set(t,f),f}let l=rt(t);if(Y(t)||l){let i={};for(let f of Object.keys(t))i[f]=s(t[f]);return l&&(i.next??(i.next=s(t.next.bind(t))),i.return??(i.return=s(t.return.bind(t))),i.throw??(i.throw=s(t.throw.bind(t))),i[ot]=!0),o.set(t,i),i}}if(typeof t=="function"){let s=e.functions.serialize(t,e,r),l={[V]:s};return o.set(t,l),l}return o.set(t,t),t},w=function(t,e,r=!1){if(t==null)return t;if(typeof t=="object"){if(c(this,M)&&!r){let n=c(this,M).call(this,t,s=>m(this,h,w).call(this,s,e,!0),e);if(n!==void 0)return n}if(t==null)return t;if(Array.isArray(t))return t.map(n=>m(this,h,w).call(this,n,e));if(t instanceof Map)return new Map([...t].map(([n,s])=>[m(this,h,w).call(this,n,e),m(this,h,w).call(this,s,e)]));if(t instanceof Set)return new Set([...t].map(n=>m(this,h,w).call(this,n,e)));if(V in t)return e.functions.deserialize(t[V],e);if(!Y(t))return t;let o={};for(let n of Object.keys(t))n===ot?o[Symbol.asyncIterator]=()=>o:o[n]=m(this,h,w).call(this,t[n],e);return o}return t};var b,S,u,Z,nt,q,it,j=class{constructor(t,{imports:e,exports:r,functions:o=new F,serialization:n=new U,signal:s}={}){p(this,u);p(this,b);p(this,S,new Map);this.messages=t,L(this,b,s?new z(s):new AbortController),this.exports=r??{},this.imports=pt(m(this,u,nt).bind(this),e),this.functions=o,this.serialization=n,this.functions.start?.(this),this.serialization.start?.(this),this.signal.addEventListener("abort",()=>{for(let l of c(this,S).keys())m(this,u,q).call(this,l,void 0,new C);c(this,S).clear()},{once:!0}),t.listen(async l=>{if(!(Array.isArray(l)&&typeof l[0]=="number"))return;let f=l;switch(f[0]){case 1:{let[,E,g,P]=f,G=this.exports[g]??(()=>{throw new Error(`No '${g}' method is exported from this thread`)});await m(this,u,Z).call(this,G,P,(D,B,H)=>{this.messages.send([2,E,D,B],H)});break}case 3:{let[,E,g,P]=f,G=this.functions.get(g,this)??ht;await m(this,u,Z).call(this,G,P,(D,B,H)=>{this.messages.send([4,E,D,B],H)});break}case 2:case 4:{m(this,u,q).call(this,...f.slice(1));break}case 5:{let E=f[1];this.functions.release(E,this);break}}},{signal:this.signal})}get signal(){return c(this,b).signal}get closed(){return c(this,b).signal.aborted}close(){c(this,b).abort()}call(t,e){if(this.closed)return Promise.reject(new C);let r=[],o=this.serialization.serialize(e,this,r),n=N(),s=m(this,u,it).call(this,n);return t(n,o,r),s}};b=new WeakMap,S=new WeakMap,u=new WeakSet,Z=async function(t,e,r){try{let o=this.functions.call?await this.functions.call(t,e,this):await t(...this.serialization.deserialize(e,this)),n=[],s=this.serialization.serialize(o,this,n);r(s,void 0,n)}catch(o){r(void 0,this.serialization.serialize(o,this))}},nt=function(t){return(...e)=>{try{if(typeof t!="string"&&typeof t!="number")throw new Error(`Can\u2019t call a symbol method on a thread: ${t.toString()}`);return this.call((r,o,n)=>{this.messages.send([1,r,t,o],n)},e)}catch(r){return Promise.reject(r)}}},q=function(...t){let e=t[0],r=c(this,S).get(e);r&&(r(...t),c(this,S).delete(e))},it=function(t){let e=new Promise((r,o)=>{c(this,S).set(t,(n,s,l)=>{l==null?r(this.serialization.deserialize(s,this)):o(this.serialization.deserialize(l,this))})});return Object.defineProperty(e,Symbol.asyncIterator,{async*value(){let r=await e;Object.defineProperty(r,Symbol.asyncIterator,{value:()=>r}),yield*r}}),e};function pt(a,t){let e;if(t==null){if(typeof Proxy!="function")throw new Error("You must pass an array of callable methods in environments without Proxies.");let r=new Map;e=new Proxy({},{get(o,n){if(r.has(n))return r.get(n);let s=a(n);return r.set(n,s),s}})}else{e={};for(let r of t)Object.defineProperty(e,r,{value:a(r),writable:!1,configurable:!0,enumerable:!0})}return e}function ht(){throw new Error("You attempted to call a function that is not stored. It may have already been released.")}var d=class d extends j{static from(t,e){return new d(t,e)}static import(t,e){return new d(t,e).imports}static export(t,e,r){new d(t,{...r,exports:e})}constructor(t,{targetOrigin:e="*",...r}={}){super(ut(t,{targetOrigin:e}),r),this.window=t}};I(d,"iframe",Object.assign((t,e)=>d.from(K(t),e),{import:(t,e)=>d.import(K(t),e),export:(t,e,r)=>d.export(K(t),e,r)})),I(d,"parent",Object.assign(t=>d.from($(),t),{import:t=>d.import($(),t),export:(t,e)=>d.export($(),t,e)})),I(d,"opener",Object.assign(t=>d.from(J(),t),{import:t=>d.import(J(),t),export:(t,e)=>d.export(J(),t,e)}));var R=d;function J(){if(typeof window>"u"||window.opener==null)throw new Error("No opener window found");return window.opener}function $(){if(typeof window>"u"||window.parent==null||window.parent===window)throw new Error("No parent window found");return window.parent}function K(a){if(a.contentWindow==null)throw new Error("No content window found");return a.contentWindow}function ut(a,{targetOrigin:t="*"}={}){let e=function(o,n){a.postMessage(o,t,n)};return{send(r,o){return e(r,o)},listen(r,{signal:o}){self.addEventListener("message",n=>{n.source===a&&r(n.data)},{signal:o})}}}import{createElement as st}from"react";import{createRoot as Et}from"react-dom/client";function $t(a){X(),R.parent.import({targetOrigin:"*"}).connect().then(({connection:e,action:r,notify:o})=>{let n={action:(i,f)=>Promise.resolve(r(i,f)),notify:(i,f)=>o(i,f)},s=document.createElement("remote-root");document.body.append(s),new Q(e).observe(s),Et(s).render(st(v.Provider,{value:n},st(a)))})}export{$t as connect};
@@ -0,0 +1 @@
1
+ import{b as a,c as b,d as c,e as d,f as e,g as f,h as g,i as h,j as i}from"./chunks/chunk-JRCDA3EG.js";import"./chunks/chunk-AMCIKVG7.js";export{h as RB_ELEMENT_NAMES,b as RbButtonElement,c as RbIconButtonElement,g as RbSelectElement,a as RbSliderElement,f as RbSwitchElement,d as RbTextElement,e as RbTextInputElement,i as defineElements};
@@ -0,0 +1 @@
1
+ import{b as A}from"./chunks/chunk-GJWPOWHG.js";import{b as d,c as x,d as h,e as S,f as C,g as y,h as g}from"./chunks/chunk-JRCDA3EG.js";import"./chunks/chunk-AMCIKVG7.js";import{forwardRef as L,useRef as T,isValidElement as k,cloneElement as M,createElement as I,useLayoutEffect as O}from"react";function o(n,w=customElements.get(n),{slotProps:m=!0,eventProps:B={}}={}){let N=!!m,c=(typeof m=="object"?m.wrapper:void 0)??!0,E=typeof c=="string"?c:c?"remote-fragment":!1,u=L(function(l,i){let a=T(),v=T(),r={},R=V(l.children);for(let e in l){let t=l[e];if(e==="slot"){r.slot=t;continue}if(N&&w.remoteSlotDefinitions.has(e)&&k(t)){E?R.push(I(E,{slot:e},t)):R.push(M(t,{slot:e}));continue}r[e]=t}return O(()=>{let e=a.current;if(e!=null){for(let t in r){if(t==="children")continue;let b=v.current?.[t],s=r[t];if(b===s)continue;let P=B[t];if(P){let f=P.event;b&&e.removeEventListener(f,b),s&&e.addEventListener(f,s);continue}if(t in e){e[t]=r[t];continue}s==null?e.removeAttribute(t):e.setAttribute(t,String(s))}v.current=r}}),I(n,{ref:e=>{a.current=e,typeof i=="function"?i(e):i!=null&&(i.current=e)}},...R)});return u.displayName=`RemoteComponent(${n})`,u}function V(n){return n==null?[]:Array.isArray(n)?[...n]:[n]}var p=n=>({eventProps:n}),G=o("rb-slider",d,p({onChange:{event:"change"}})),H=o("rb-button",x,p({onPress:{event:"press"}})),J=o("rb-icon-button",h,p({onPress:{event:"press"}})),K=o("rb-text",S),Q=o("rb-text-input",C,p({onInput:{event:"input"}})),U=o("rb-switch",y,p({onChange:{event:"change"}})),X=o("rb-select",g,p({onChange:{event:"change"}}));export{H as Button,J as IconButton,X as Select,G as Slider,U as Switch,K as Text,Q as TextInput,A as useRb};
@@ -0,0 +1 @@
1
+ import{a,b}from"./chunks/chunk-GJWPOWHG.js";import"./chunks/chunk-AMCIKVG7.js";export{a as RbContext,b as useRb};
@@ -0,0 +1 @@
1
+ export * from "./react-runtime.js"; export { default } from "./react-runtime.js";
@@ -0,0 +1 @@
1
+ export * from "./react-runtime.js"; export { default } from "./react-runtime.js";
@@ -0,0 +1 @@
1
+ export * from "./react-runtime.js"; export { default } from "./react-runtime.js";