@rainbow-robotics/plugin-ui 0.1.2-dev.5 → 0.1.2-dev.6
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/build-browser.mjs +39 -1
- package/dist/connect.d.ts +2 -3
- package/dist/connect.d.ts.map +1 -1
- package/dist/connect.js +8 -3
- package/dist/connect.js.map +2 -2
- package/dist/sdk.d.ts +18 -4
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +17 -8
- package/dist/sdk.js.map +2 -2
- package/dist/zenoh.d.ts +29 -0
- package/dist/zenoh.d.ts.map +1 -0
- package/dist-browser/@rainbow-robotics/plugin-ui/chunks/{chunk-JRCDA3EG.js → chunk-3DOWEHFU.js} +1 -1
- package/dist-browser/@rainbow-robotics/plugin-ui/chunks/chunk-HJVATDC6.js +1 -0
- package/dist-browser/@rainbow-robotics/plugin-ui/chunks/chunk-Q6XGCIPE.js +1 -0
- package/dist-browser/@rainbow-robotics/plugin-ui/connect.js +1 -1
- package/dist-browser/@rainbow-robotics/plugin-ui/elements.js +1 -1
- package/dist-browser/@rainbow-robotics/plugin-ui/react.js +1 -1
- package/dist-browser/@rainbow-robotics/plugin-ui/sdk.js +1 -1
- package/package.json +2 -1
- package/src/connect.ts +17 -21
- package/src/sdk.ts +50 -17
- package/src/zenoh.ts +122 -0
- package/dist-browser/@rainbow-robotics/plugin-ui/chunks/chunk-AMCIKVG7.js +0 -1
- package/dist-browser/@rainbow-robotics/plugin-ui/chunks/chunk-GJWPOWHG.js +0 -1
package/build-browser.mjs
CHANGED
|
@@ -8,10 +8,47 @@
|
|
|
8
8
|
//
|
|
9
9
|
// Run: node libraries/plugin-ui/build-browser.mjs
|
|
10
10
|
import { build } from "esbuild";
|
|
11
|
-
import { mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
11
|
+
import { mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
12
12
|
import { dirname, resolve } from "node:path";
|
|
13
13
|
import { fileURLToPath } from "node:url";
|
|
14
14
|
|
|
15
|
+
// esbuild plugin: handle wasm-bindgen "bundler" target .wasm ESM imports.
|
|
16
|
+
// These are `import * as wasm from "./foo_bg.wasm"` patterns generated by wasm-bindgen.
|
|
17
|
+
// esbuild has no native WASM loader for this pattern; we inline the binary as base64
|
|
18
|
+
// and synchronously instantiate it with the _bg.js imports at module evaluation time.
|
|
19
|
+
const wasmBindgenPlugin = {
|
|
20
|
+
name: "wasm-bindgen",
|
|
21
|
+
setup(build) {
|
|
22
|
+
build.onResolve({ filter: /\.wasm$/ }, (args) => ({
|
|
23
|
+
path: resolve(args.resolveDir, args.path),
|
|
24
|
+
namespace: "wasm-bindgen",
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
build.onLoad({ filter: /.*/, namespace: "wasm-bindgen" }, (args) => {
|
|
28
|
+
const bytes = readFileSync(args.path);
|
|
29
|
+
const mod = new WebAssembly.Module(bytes);
|
|
30
|
+
|
|
31
|
+
const importMods = [...new Set(WebAssembly.Module.imports(mod).map((i) => i.module))];
|
|
32
|
+
const exportNames = WebAssembly.Module.exports(mod).map((e) => e.name);
|
|
33
|
+
const b64 = bytes.toString("base64");
|
|
34
|
+
|
|
35
|
+
const lines = [
|
|
36
|
+
// Import JS glue modules that the WASM binary needs
|
|
37
|
+
...importMods.map((m, i) => `import * as __wimp${i} from ${JSON.stringify(m)};`),
|
|
38
|
+
// Inline the WASM binary as base64 and instantiate synchronously
|
|
39
|
+
`const __wb64=${JSON.stringify(b64)};`,
|
|
40
|
+
`const __wbytes=Uint8Array.from(atob(__wb64),c=>c.charCodeAt(0));`,
|
|
41
|
+
`const __wbmod=new WebAssembly.Module(__wbytes);`,
|
|
42
|
+
`const __wbinst=new WebAssembly.Instance(__wbmod,{${importMods.map((m, i) => `${JSON.stringify(m)}:__wimp${i}`).join(",")}});`,
|
|
43
|
+
// Named-export every WASM export so `import * as wasm` gets the right shape
|
|
44
|
+
...exportNames.map((n) => `export const ${n}=__wbinst.exports[${JSON.stringify(n)}];`),
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
return { contents: lines.join("\n"), loader: "js", resolveDir: dirname(args.path) };
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
|
|
15
52
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
16
53
|
const src = resolve(here, "src");
|
|
17
54
|
const out = resolve(here, "dist-browser");
|
|
@@ -47,6 +84,7 @@ await build({
|
|
|
47
84
|
chunkNames: "chunks/[name]-[hash]",
|
|
48
85
|
splitting: true,
|
|
49
86
|
external: ["react", "react-dom/client"],
|
|
87
|
+
plugins: [wasmBindgenPlugin],
|
|
50
88
|
});
|
|
51
89
|
|
|
52
90
|
// Single vendor bundle: React + ReactDOM (sandbox loads this once via import map)
|
package/dist/connect.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { type ComponentType } from "react";
|
|
2
2
|
/**
|
|
3
|
-
* Mount a plugin. Call this once from the sandbox entry (
|
|
4
|
-
* the plugin's root component.
|
|
3
|
+
* Mount a plugin. Call this once from the sandbox entry (content.tsx).
|
|
5
4
|
*
|
|
6
5
|
* @example
|
|
7
6
|
* import { connect } from "@rainbow-robotics/plugin-ui/connect";
|
|
8
|
-
* import App from "./
|
|
7
|
+
* import App from "./App";
|
|
9
8
|
* connect(App);
|
|
10
9
|
*/
|
|
11
10
|
export declare function connect(App: ComponentType): void;
|
package/dist/connect.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":"AAYA,OAAO,EAAiB,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAe1D;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CA4BhD"}
|
package/dist/connect.js
CHANGED
|
@@ -4,15 +4,20 @@ import { createElement } from "react";
|
|
|
4
4
|
import { createRoot } from "react-dom/client";
|
|
5
5
|
import { defineElements } from "./elements";
|
|
6
6
|
import { RbContext } from "./sdk";
|
|
7
|
+
import { RbZenoh } from "./zenoh";
|
|
7
8
|
function connect(App) {
|
|
8
9
|
defineElements();
|
|
9
10
|
const host = ThreadWindow.parent.import({
|
|
10
11
|
targetOrigin: "*"
|
|
11
12
|
});
|
|
12
|
-
void host.connect().then(({ connection,
|
|
13
|
+
void host.connect().then(async ({ connection, toast, zenohUrl, pluginId }) => {
|
|
14
|
+
const zenoh = await RbZenoh.open(zenohUrl, pluginId);
|
|
13
15
|
const rb = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
pub: (topic, payload) => zenoh.pub(topic, payload),
|
|
17
|
+
sub: (topic, handler) => zenoh.sub(topic, handler),
|
|
18
|
+
action: (topic, payload) => zenoh.action(topic, payload),
|
|
19
|
+
serve: (topic, handler) => zenoh.serve(topic, handler),
|
|
20
|
+
toast: (message, type) => toast(message, type)
|
|
16
21
|
};
|
|
17
22
|
const root = document.createElement("remote-root");
|
|
18
23
|
document.body.append(root);
|
package/dist/connect.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/connect.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Sandbox bootstrap \u2014 runs *inside* the plugin iframe.\n *\n * The sandbox initiates the handshake
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/**\n * Sandbox bootstrap \u2014 runs *inside* the plugin iframe.\n *\n * The sandbox initiates the handshake: imports the host's `connect()` and calls\n * it. The host responds with the RemoteConnection, toast(), and Zenoh config\n * (url + pluginId). We open a Zenoh session and wire up the rb object.\n *\n * Verified against @remote-dom/core@1.11.x + @quilted/threads@4.x.\n */\nimport { RemoteMutationObserver } from \"@remote-dom/core/elements\";\nimport type { RemoteConnection } from \"@remote-dom/core\";\nimport { ThreadWindow } from \"@quilted/threads\";\nimport { createElement, type ComponentType } from \"react\";\nimport { createRoot } from \"react-dom/client\";\nimport { defineElements } from \"./elements\";\nimport { RbContext, type RbSdk } from \"./sdk\";\nimport { RbZenoh } from \"./zenoh\";\n\ninterface HostExports {\n connect: () => Promise<{\n connection: RemoteConnection;\n toast: (message: string, type?: string) => void;\n zenohUrl: string;\n pluginId: string;\n }>;\n}\n\n/**\n * Mount a plugin. Call this once from the sandbox entry (content.tsx).\n *\n * @example\n * import { connect } from \"@rainbow-robotics/plugin-ui/connect\";\n * import App from \"./App\";\n * connect(App);\n */\nexport function connect(App: ComponentType): void {\n defineElements();\n\n const host = ThreadWindow.parent.import<HostExports>({\n targetOrigin: \"*\",\n });\n\n void host.connect().then(async ({ connection, toast, zenohUrl, pluginId }) => {\n const zenoh = await RbZenoh.open(zenohUrl, pluginId);\n\n const rb: RbSdk = {\n pub: (topic, payload) => zenoh.pub(topic, payload),\n sub: (topic, handler) => zenoh.sub(topic, handler),\n action: (topic, payload) => zenoh.action(topic, payload),\n serve: (topic, handler) => zenoh.serve(topic, handler),\n toast: (message, type) => toast(message, type),\n };\n\n const root = document.createElement(\"remote-root\");\n document.body.append(root);\n\n const observer = new RemoteMutationObserver(connection);\n observer.observe(root);\n\n createRoot(root).render(\n createElement(RbContext.Provider, { value: rb }, createElement(App)),\n );\n });\n}\n"],
|
|
5
|
+
"mappings": "AASA,SAAS,8BAA8B;AAEvC,SAAS,oBAAoB;AAC7B,SAAS,qBAAyC;AAClD,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;AAC/B,SAAS,iBAA6B;AACtC,SAAS,eAAe;AAmBjB,SAAS,QAAQ,KAA0B;AAChD,iBAAe;AAEf,QAAM,OAAO,aAAa,OAAO,OAAoB;AAAA,IACnD,cAAc;AAAA,EAChB,CAAC;AAED,OAAK,KAAK,QAAQ,EAAE,KAAK,OAAO,EAAE,YAAY,OAAO,UAAU,SAAS,MAAM;AAC5E,UAAM,QAAQ,MAAM,QAAQ,KAAK,UAAU,QAAQ;AAEnD,UAAM,KAAY;AAAA,MAChB,KAAQ,CAAC,OAAO,YAAa,MAAM,IAAI,OAAO,OAAO;AAAA,MACrD,KAAQ,CAAC,OAAO,YAAa,MAAM,IAAI,OAAO,OAAO;AAAA,MACrD,QAAQ,CAAC,OAAO,YAAa,MAAM,OAAO,OAAO,OAAO;AAAA,MACxD,OAAQ,CAAC,OAAO,YAAa,MAAM,MAAM,OAAO,OAAO;AAAA,MACvD,OAAO,CAAC,SAAS,SAAW,MAAM,SAAS,IAAI;AAAA,IACjD;AAEA,UAAM,OAAO,SAAS,cAAc,aAAa;AACjD,aAAS,KAAK,OAAO,IAAI;AAEzB,UAAM,WAAW,IAAI,uBAAuB,UAAU;AACtD,aAAS,QAAQ,IAAI;AAErB,eAAW,IAAI,EAAE;AAAA,MACf,cAAc,UAAU,UAAU,EAAE,OAAO,GAAG,GAAG,cAAc,GAAG,CAAC;AAAA,IACrE;AAAA,EACF,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/sdk.d.ts
CHANGED
|
@@ -1,12 +1,26 @@
|
|
|
1
|
+
import type { Subscriber, Queryable } from "./zenoh";
|
|
1
2
|
export type RbNotifyType = "info" | "success" | "warning" | "error";
|
|
2
3
|
export interface RbSdk {
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
5
|
+
* Publish JSON payload to a topic.
|
|
6
|
+
* "sensor/data" → plugin/{pluginId}/sensor/data
|
|
7
|
+
* "/broadcast/x" → broadcast/x (absolute)
|
|
6
8
|
*/
|
|
7
|
-
|
|
9
|
+
pub: <P = any>(topic: string, payload: P) => Promise<void>;
|
|
10
|
+
/** Subscribe to a topic. Returns a handle with undeclare(). */
|
|
11
|
+
sub: <P = any>(topic: string, handler: (payload: P) => void) => Promise<Subscriber>;
|
|
12
|
+
/**
|
|
13
|
+
* Send a request and await the first reply (Zenoh query).
|
|
14
|
+
* Use this to call a backend handler registered with rb.serve() / ZenohRouter.
|
|
15
|
+
*/
|
|
16
|
+
action: <R = any, P = any>(topic: string, payload?: P) => Promise<R>;
|
|
17
|
+
/**
|
|
18
|
+
* Register a queryable — the frontend responds to backend queries.
|
|
19
|
+
* Mirror of rb.action() on the other side.
|
|
20
|
+
*/
|
|
21
|
+
serve: <P = any, R = any>(topic: string, handler: (payload?: P) => R | Promise<R>) => Promise<Queryable>;
|
|
8
22
|
/** Show a transient notification through the host's toast system. */
|
|
9
|
-
|
|
23
|
+
toast: (message: string, type?: RbNotifyType) => void;
|
|
10
24
|
}
|
|
11
25
|
export declare const RbContext: import("react").Context<RbSdk>;
|
|
12
26
|
/** Access the host SDK from within a plugin component. */
|
package/dist/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAErD,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;AAEpE,MAAM,WAAW,KAAK;IACpB;;;;OAIG;IACH,GAAG,EAAE,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3D,+DAA+D;IAC/D,GAAG,EAAE,CAAC,CAAC,GAAG,GAAG,EACX,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,IAAI,KAC1B,OAAO,CAAC,UAAU,CAAC,CAAC;IAEzB;;;OAGG;IACH,MAAM,EAAE,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;IAErE;;;OAGG;IACH,KAAK,EAAE,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,EACtB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,KACrC,OAAO,CAAC,SAAS,CAAC,CAAC;IAExB,qEAAqE;IACrE,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,YAAY,KAAK,IAAI,CAAC;CACvD;AAuBD,eAAO,MAAM,SAAS,gCAAgC,CAAC;AAEvD,0DAA0D;AAC1D,wBAAgB,KAAK,IAAI,KAAK,CAE7B"}
|
package/dist/sdk.js
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
import { createContext, useContext } from "react";
|
|
2
2
|
const noopSdk = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
pub: async (_topic, _payload) => {
|
|
4
|
+
console.warn("[plugin-ui] rb.pub called outside of a host context");
|
|
5
|
+
},
|
|
6
|
+
sub: async (_topic, _handler) => {
|
|
7
|
+
console.warn("[plugin-ui] rb.sub called outside of a host context");
|
|
8
|
+
return { undeclare: async () => {
|
|
9
|
+
} };
|
|
10
|
+
},
|
|
11
|
+
action: async (_topic, _payload) => {
|
|
12
|
+
console.warn("[plugin-ui] rb.action called outside of a host context");
|
|
7
13
|
return void 0;
|
|
8
14
|
},
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
15
|
+
serve: async (_topic, _handler) => {
|
|
16
|
+
console.warn("[plugin-ui] rb.serve called outside of a host context");
|
|
17
|
+
return { undeclare: async () => {
|
|
18
|
+
} };
|
|
19
|
+
},
|
|
20
|
+
toast: (message) => {
|
|
21
|
+
console.warn("[plugin-ui] rb.toast (no host):", message);
|
|
13
22
|
}
|
|
14
23
|
};
|
|
15
24
|
const RbContext = createContext(noopSdk);
|
package/dist/sdk.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/sdk.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Plugin runtime SDK \u2014 the
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/**\n * Plugin runtime SDK \u2014 the surface a plugin author calls from inside the sandbox.\n *\n * Zenoh methods (pub/sub/action/serve) talk directly to the Zenoh router via\n * WebSocket. Topics are auto-namespaced to plugin/{pluginId}/... to prevent\n * cross-plugin collisions. A leading \"/\" bypasses namespacing (absolute path).\n *\n * notify() is still host-mediated (goes through the Muscat shell).\n */\nimport { createContext, useContext } from \"react\";\nimport type { Subscriber, Queryable } from \"./zenoh\";\n\nexport type RbNotifyType = \"info\" | \"success\" | \"warning\" | \"error\";\n\nexport interface RbSdk {\n /**\n * Publish JSON payload to a topic.\n * \"sensor/data\" \u2192 plugin/{pluginId}/sensor/data\n * \"/broadcast/x\" \u2192 broadcast/x (absolute)\n */\n pub: <P = any>(topic: string, payload: P) => Promise<void>;\n\n /** Subscribe to a topic. Returns a handle with undeclare(). */\n sub: <P = any>(\n topic: string,\n handler: (payload: P) => void,\n ) => Promise<Subscriber>;\n\n /**\n * Send a request and await the first reply (Zenoh query).\n * Use this to call a backend handler registered with rb.serve() / ZenohRouter.\n */\n action: <R = any, P = any>(topic: string, payload?: P) => Promise<R>;\n\n /**\n * Register a queryable \u2014 the frontend responds to backend queries.\n * Mirror of rb.action() on the other side.\n */\n serve: <P = any, R = any>(\n topic: string,\n handler: (payload?: P) => R | Promise<R>,\n ) => Promise<Queryable>;\n\n /** Show a transient notification through the host's toast system. */\n toast: (message: string, type?: RbNotifyType) => void;\n}\n\nconst noopSdk: RbSdk = {\n pub: async <P = any>(_topic?: string, _payload?: P) => {\n console.warn(\"[plugin-ui] rb.pub called outside of a host context\");\n },\n sub: async <P = any>(_topic?: string, _handler?: (payload: P) => void) => {\n console.warn(\"[plugin-ui] rb.sub called outside of a host context\");\n return { undeclare: async () => {} } as unknown as Subscriber;\n },\n action: async <R = any, P = any>(_topic?: string, _payload?: P) => {\n console.warn(\"[plugin-ui] rb.action called outside of a host context\");\n return undefined as R;\n },\n serve: async <P = any, R = any>(_topic?: string, _handler?: (payload?: P) => R) => {\n console.warn(\"[plugin-ui] rb.serve called outside of a host context\");\n return { undeclare: async () => {} } as unknown as Queryable;\n },\n toast: (message) => {\n console.warn(\"[plugin-ui] rb.toast (no host):\", message);\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": "AASA,SAAS,eAAe,kBAAkB;AAsC1C,MAAM,UAAiB;AAAA,EACrB,KAAK,OAAgB,QAAiB,aAAiB;AACrD,YAAQ,KAAK,qDAAqD;AAAA,EACpE;AAAA,EACA,KAAK,OAAgB,QAAiB,aAAoC;AACxE,YAAQ,KAAK,qDAAqD;AAClE,WAAO,EAAE,WAAW,YAAY;AAAA,IAAC,EAAE;AAAA,EACrC;AAAA,EACA,QAAQ,OAAyB,QAAiB,aAAiB;AACjE,YAAQ,KAAK,wDAAwD;AACrE,WAAO;AAAA,EACT;AAAA,EACA,OAAO,OAAyB,QAAiB,aAAkC;AACjF,YAAQ,KAAK,uDAAuD;AACpE,WAAO,EAAE,WAAW,YAAY;AAAA,IAAC,EAAE;AAAA,EACrC;AAAA,EACA,OAAO,CAAC,YAAY;AAClB,YAAQ,KAAK,mCAAmC,OAAO;AAAA,EACzD;AACF;AAEO,MAAM,YAAY,cAAqB,OAAO;AAG9C,SAAS,QAAe;AAC7B,SAAO,WAAW,SAAS;AAC7B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/zenoh.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Subscriber, Queryable } from "@eclipse-zenoh/zenoh-ts";
|
|
2
|
+
export type { Subscriber, Queryable };
|
|
3
|
+
export interface ZenohHandle {
|
|
4
|
+
undeclare(): Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
export declare class RbZenoh {
|
|
7
|
+
private readonly _session;
|
|
8
|
+
private readonly _pluginId;
|
|
9
|
+
private readonly _pubs;
|
|
10
|
+
private constructor();
|
|
11
|
+
static open(url: string, pluginId: string): Promise<RbZenoh>;
|
|
12
|
+
private _key;
|
|
13
|
+
/** Publish JSON payload to a topic. Publisher is cached per topic. */
|
|
14
|
+
pub<P = any>(topic: string, payload: P): Promise<void>;
|
|
15
|
+
/** Subscribe to a topic. Returns a handle with undeclare(). */
|
|
16
|
+
sub<P = any>(topic: string, handler: (payload: P) => void): Promise<Subscriber>;
|
|
17
|
+
/**
|
|
18
|
+
* Send a request and await the first reply (Zenoh query).
|
|
19
|
+
* Equivalent to a remote procedure call.
|
|
20
|
+
*/
|
|
21
|
+
action<R = any, P = any>(topic: string, payload?: P): Promise<R>;
|
|
22
|
+
/**
|
|
23
|
+
* Register a queryable handler (Zenoh queryable).
|
|
24
|
+
* The backend calls action(), this side responds.
|
|
25
|
+
*/
|
|
26
|
+
serve<P = any, R = any>(topic: string, handler: (payload?: P) => R | Promise<R>): Promise<Queryable>;
|
|
27
|
+
close(): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=zenoh.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zenoh.d.ts","sourceRoot":"","sources":["../src/zenoh.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAa,UAAU,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEhF,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;AAEtC,MAAM,WAAW,WAAW;IAC1B,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B;AAmBD,qBAAa,OAAO;IAClB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAU;IACnC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAgC;IAEtD,OAAO;WAKM,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKlE,OAAO,CAAC,IAAI;IAIZ,sEAAsE;IAEhE,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAU5D,+DAA+D;IAEzD,GAAG,CAAC,CAAC,GAAG,GAAG,EACf,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,IAAI,GAC5B,OAAO,CAAC,UAAU,CAAC;IAQtB;;;OAGG;IAEG,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IActE;;;OAGG;IAEG,KAAK,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,EAC1B,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GACvC,OAAO,CAAC,SAAS,CAAC;IAaf,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAK7B"}
|
package/dist-browser/@rainbow-robotics/plugin-ui/chunks/{chunk-JRCDA3EG.js → chunk-3DOWEHFU.js}
RENAMED
|
@@ -1 +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};
|
|
1
|
+
import{d as v,e as P,f as Q,g as ee}from"./chunk-HJVATDC6.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
|
+
var i=Object.create;var f=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var l=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty;var h=b=>{throw TypeError(b)};var n=(b,a,c)=>a in b?f(b,a,{enumerable:!0,configurable:!0,writable:!0,value:c}):b[a]=c;var p=(b,a)=>()=>(a||b((a={exports:{}}).exports,a),a.exports),q=(b,a)=>{for(var c in a)f(b,c,{get:a[c],enumerable:!0})},o=(b,a,c,d)=>{if(a&&typeof a=="object"||typeof a=="function")for(let e of k(a))!m.call(b,e)&&e!==c&&f(b,e,{get:()=>a[e],enumerable:!(d=j(a,e))||d.enumerable});return b};var r=(b,a,c)=>(c=b!=null?i(l(b)):{},o(a||!b||!b.__esModule?f(c,"default",{value:b,enumerable:!0}):c,b));var s=(b,a,c)=>n(b,typeof a!="symbol"?a+"":a,c),g=(b,a,c)=>a.has(b)||h("Cannot "+c);var t=(b,a,c)=>(g(b,a,"read from private field"),c?c.call(b):a.get(b)),u=(b,a,c)=>a.has(b)?h("Cannot add the same private member more than once"):a instanceof WeakSet?a.add(b):a.set(b,c),v=(b,a,c,d)=>(g(b,a,"write to private field"),d?d.call(b,c):a.set(b,c),c),w=(b,a,c)=>(g(b,a,"access private method"),c);export{p as a,q as b,r as c,s as d,t as e,u as f,v as g,w as h};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createContext as e,useContext as a}from"react";var t={pub:async(o,n)=>{console.warn("[plugin-ui] rb.pub called outside of a host context")},sub:async(o,n)=>(console.warn("[plugin-ui] rb.sub called outside of a host context"),{undeclare:async()=>{}}),action:async(o,n)=>{console.warn("[plugin-ui] rb.action called outside of a host context")},serve:async(o,n)=>(console.warn("[plugin-ui] rb.serve called outside of a host context"),{undeclare:async()=>{}}),toast:o=>{console.warn("[plugin-ui] rb.toast (no host):",o)}},r=e(t);function i(){return a(r)}export{r as a,i as b};
|