@decido/shell 4.0.2 → 4.0.3

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 (37) hide show
  1. package/dist/CenterComposite-RPEGBKQU.mjs +1697 -0
  2. package/dist/DebugPanel-KEKDMHDN.mjs +14 -0
  3. package/dist/MorphShell-FKDBB7E5.mjs +14 -0
  4. package/dist/PlaygroundAppSidebar-ALYJJGAO.mjs +9 -0
  5. package/dist/PlaygroundChat-MI2KXMK6.mjs +15 -0
  6. package/dist/PlaygroundTerminal-5AV4BJAI.mjs +7 -0
  7. package/dist/PluginSandbox-WMNAUQOJ.mjs +188 -0
  8. package/dist/ReactFlowEditor-RTF2652X.mjs +3574 -0
  9. package/dist/ReactFlowEditor-ZW5MCN5Y.css +561 -0
  10. package/dist/TimelineEditor-N4HRMHTB.mjs +226 -0
  11. package/dist/WidgetSlotPanel-KJI4CHHD.mjs +11 -0
  12. package/dist/chunk-2YMI4N5I.mjs +2004 -0
  13. package/dist/chunk-3BZX7LF2.mjs +139 -0
  14. package/dist/chunk-3P4P3M54.mjs +136 -0
  15. package/dist/chunk-F3OTFHNO.mjs +40 -0
  16. package/dist/chunk-IMHORBTL.mjs +48 -0
  17. package/dist/chunk-JF5QSJYT.mjs +295 -0
  18. package/dist/chunk-LWMMFTJC.mjs +382 -0
  19. package/dist/chunk-MSVEFEXE.mjs +179 -0
  20. package/dist/chunk-OCHGY2MN.mjs +1662 -0
  21. package/dist/chunk-PMYAM764.mjs +813 -0
  22. package/dist/chunk-Q64KZXPK.mjs +43 -0
  23. package/dist/chunk-QHQW2HMU.mjs +155 -0
  24. package/dist/chunk-RWZ4BOIN.mjs +385 -0
  25. package/dist/chunk-UHT6FIYF.mjs +195 -0
  26. package/dist/chunk-UJCSKKID.mjs +30 -0
  27. package/dist/chunk-V3CYNPGL.mjs +8758 -0
  28. package/dist/chunk-VBPGEFNM.mjs +2381 -0
  29. package/dist/chunk-XMSU6UWD.mjs +158 -0
  30. package/dist/chunk-ZCCCBHE6.mjs +55 -0
  31. package/dist/index.css +561 -0
  32. package/dist/index.js +65130 -0
  33. package/dist/index.mjs +40248 -0
  34. package/dist/useIntentLens-LEQCAXCK.mjs +13 -0
  35. package/dist/useSuggestionsStore-4L2AIZ2D.mjs +7 -0
  36. package/dist/wasm-QFXGEYGP.mjs +81 -0
  37. package/package.json +17 -18
@@ -0,0 +1,14 @@
1
+ import {
2
+ DebugPanel
3
+ } from "./chunk-VBPGEFNM.mjs";
4
+ import "./chunk-JF5QSJYT.mjs";
5
+ import "./chunk-ZCCCBHE6.mjs";
6
+ import "./chunk-UHT6FIYF.mjs";
7
+ import "./chunk-3BZX7LF2.mjs";
8
+ import "./chunk-MSVEFEXE.mjs";
9
+ import "./chunk-3P4P3M54.mjs";
10
+ import "./chunk-XMSU6UWD.mjs";
11
+ import "./chunk-UJCSKKID.mjs";
12
+ export {
13
+ DebugPanel
14
+ };
@@ -0,0 +1,14 @@
1
+ import {
2
+ MorphShell
3
+ } from "./chunk-2YMI4N5I.mjs";
4
+ import "./chunk-IMHORBTL.mjs";
5
+ import "./chunk-JF5QSJYT.mjs";
6
+ import "./chunk-ZCCCBHE6.mjs";
7
+ import "./chunk-UHT6FIYF.mjs";
8
+ import "./chunk-MSVEFEXE.mjs";
9
+ import "./chunk-3P4P3M54.mjs";
10
+ import "./chunk-XMSU6UWD.mjs";
11
+ import "./chunk-UJCSKKID.mjs";
12
+ export {
13
+ MorphShell
14
+ };
@@ -0,0 +1,9 @@
1
+ import {
2
+ PlaygroundAppSidebar
3
+ } from "./chunk-RWZ4BOIN.mjs";
4
+ import "./chunk-F3OTFHNO.mjs";
5
+ import "./chunk-XMSU6UWD.mjs";
6
+ import "./chunk-UJCSKKID.mjs";
7
+ export {
8
+ PlaygroundAppSidebar
9
+ };
@@ -0,0 +1,15 @@
1
+ import {
2
+ PlaygroundChat
3
+ } from "./chunk-OCHGY2MN.mjs";
4
+ import "./chunk-IMHORBTL.mjs";
5
+ import "./chunk-F3OTFHNO.mjs";
6
+ import "./chunk-QHQW2HMU.mjs";
7
+ import "./chunk-UHT6FIYF.mjs";
8
+ import "./chunk-3BZX7LF2.mjs";
9
+ import "./chunk-MSVEFEXE.mjs";
10
+ import "./chunk-3P4P3M54.mjs";
11
+ import "./chunk-XMSU6UWD.mjs";
12
+ import "./chunk-UJCSKKID.mjs";
13
+ export {
14
+ PlaygroundChat
15
+ };
@@ -0,0 +1,7 @@
1
+ import {
2
+ PlaygroundTerminal
3
+ } from "./chunk-Q64KZXPK.mjs";
4
+ import "./chunk-UJCSKKID.mjs";
5
+ export {
6
+ PlaygroundTerminal
7
+ };
@@ -0,0 +1,188 @@
1
+ import "./chunk-UJCSKKID.mjs";
2
+
3
+ // ../sdk/src/sandbox/PluginSandbox.ts
4
+ import { probe, probeStart } from "@decido/logger";
5
+ var PluginSandbox = class {
6
+ worker = null;
7
+ config;
8
+ pendingRequests = /* @__PURE__ */ new Map();
9
+ isReady = false;
10
+ readyPromise;
11
+ readyResolve;
12
+ /** Callbacks for host-side handling */
13
+ onRpcRequest;
14
+ onWidgetRegister;
15
+ onLog;
16
+ onError;
17
+ constructor(config) {
18
+ this.config = config;
19
+ this.readyPromise = new Promise((resolve) => {
20
+ this.readyResolve = resolve;
21
+ });
22
+ }
23
+ /** Start the sandbox Worker and load the plugin */
24
+ async start() {
25
+ const endProbe = probeStart("sandbox.start", { context: { module: "sdk", component: "PluginSandbox" } });
26
+ if (this.config.trusted) {
27
+ this.isReady = true;
28
+ this.readyResolve();
29
+ endProbe({ pluginId: this.config.pluginId, trusted: true });
30
+ return;
31
+ }
32
+ const workerUrl = new URL("./sandbox-worker.js", import.meta.url);
33
+ this.worker = new Worker(workerUrl, { type: "module", name: `plugin-${this.config.pluginId}` });
34
+ this.worker.onmessage = (event) => {
35
+ this.handleWorkerMessage(event.data);
36
+ };
37
+ this.worker.onerror = (event) => {
38
+ probe("sandbox.error", { pluginId: this.config.pluginId, error: event.message }, { level: "error", context: { module: "sdk", component: "PluginSandbox" } });
39
+ console.error(`[Sandbox:${this.config.pluginId}] Worker error:`, event.message);
40
+ if (this.onError) this.onError(event.message);
41
+ };
42
+ this.sendToWorker({
43
+ type: "SANDBOX_INIT",
44
+ pluginId: this.config.pluginId,
45
+ payload: {
46
+ pluginUrl: this.config.pluginUrl,
47
+ tenantId: this.config.tenantId,
48
+ permissions: this.config.permissions || []
49
+ }
50
+ });
51
+ const timeout = this.config.timeout || 1e4;
52
+ await Promise.race([
53
+ this.readyPromise,
54
+ new Promise(
55
+ (_, reject) => setTimeout(() => reject(new Error(`Plugin "${this.config.pluginId}" sandbox init timed out after ${timeout}ms`)), timeout)
56
+ )
57
+ ]);
58
+ endProbe({ pluginId: this.config.pluginId, trusted: false });
59
+ }
60
+ /** Request the plugin to mount */
61
+ async mount() {
62
+ if (this.config.trusted) return;
63
+ this.sendToWorker({
64
+ type: "SANDBOX_MOUNT",
65
+ pluginId: this.config.pluginId
66
+ });
67
+ }
68
+ /** Request the plugin to unmount */
69
+ async unmount() {
70
+ if (this.config.trusted) return;
71
+ this.sendToWorker({
72
+ type: "SANDBOX_UNMOUNT",
73
+ pluginId: this.config.pluginId
74
+ });
75
+ }
76
+ /** Broadcast an event into the sandbox */
77
+ broadcastEvent(topic, payload) {
78
+ if (!this.worker) return;
79
+ this.sendToWorker({
80
+ type: "SANDBOX_EVENT_BROADCAST",
81
+ pluginId: this.config.pluginId,
82
+ payload: { topic, data: payload }
83
+ });
84
+ }
85
+ /** Destroy the sandbox — terminates the Worker */
86
+ destroy() {
87
+ probe("sandbox.destroy", { pluginId: this.config.pluginId, pendingRequests: this.pendingRequests.size }, { context: { module: "sdk", component: "PluginSandbox" } });
88
+ if (this.worker) {
89
+ this.sendToWorker({
90
+ type: "SANDBOX_DESTROY",
91
+ pluginId: this.config.pluginId
92
+ });
93
+ setTimeout(() => {
94
+ this.worker?.terminate();
95
+ this.worker = null;
96
+ }, 500);
97
+ }
98
+ for (const [, pending] of this.pendingRequests) {
99
+ clearTimeout(pending.timer);
100
+ pending.reject(new Error("Sandbox destroyed"));
101
+ }
102
+ this.pendingRequests.clear();
103
+ }
104
+ // ── Internal ──
105
+ sendToWorker(message) {
106
+ this.worker?.postMessage(message);
107
+ }
108
+ handleWorkerMessage(msg) {
109
+ switch (msg.type) {
110
+ case "SANDBOX_READY":
111
+ this.isReady = true;
112
+ this.readyResolve();
113
+ break;
114
+ case "SANDBOX_RPC_REQUEST":
115
+ probe("sandbox.rpc.request", { pluginId: msg.pluginId, action: msg.payload?.action }, { context: { module: "sdk", component: "PluginSandbox" }, security: { tier: 1 } });
116
+ this.handleRpcFromPlugin(msg);
117
+ break;
118
+ case "SANDBOX_RPC_RESPONSE":
119
+ this.handleRpcResponse(msg);
120
+ break;
121
+ case "SANDBOX_EVENT_EMIT":
122
+ break;
123
+ case "SANDBOX_WIDGET_REGISTER":
124
+ if (this.onWidgetRegister) {
125
+ this.onWidgetRegister(msg.payload);
126
+ }
127
+ break;
128
+ case "SANDBOX_LOG":
129
+ if (this.onLog) {
130
+ this.onLog(msg.payload?.level || "log", msg.payload?.args || []);
131
+ } else {
132
+ const level = msg.payload?.level || "log";
133
+ const prefix = `[Sandbox:${msg.pluginId}]`;
134
+ console[level]?.(prefix, ...msg.payload?.args || []);
135
+ }
136
+ break;
137
+ case "SANDBOX_ERROR":
138
+ console.error(`[Sandbox:${msg.pluginId}] Error:`, msg.error);
139
+ if (this.onError) this.onError(msg.error || "Unknown error");
140
+ break;
141
+ default:
142
+ console.warn(`[Sandbox:${msg.pluginId}] Unknown message type: ${msg.type}`);
143
+ }
144
+ }
145
+ async handleRpcFromPlugin(msg) {
146
+ if (!msg.requestId || !this.onRpcRequest) {
147
+ this.sendToWorker({
148
+ type: "SANDBOX_RPC_RESPONSE",
149
+ pluginId: msg.pluginId,
150
+ requestId: msg.requestId,
151
+ error: "No RPC handler available"
152
+ });
153
+ return;
154
+ }
155
+ try {
156
+ const result = await this.onRpcRequest(msg.payload?.action, msg.payload?.data);
157
+ this.sendToWorker({
158
+ type: "SANDBOX_RPC_RESPONSE",
159
+ pluginId: msg.pluginId,
160
+ requestId: msg.requestId,
161
+ payload: result
162
+ });
163
+ } catch (error) {
164
+ this.sendToWorker({
165
+ type: "SANDBOX_RPC_RESPONSE",
166
+ pluginId: msg.pluginId,
167
+ requestId: msg.requestId,
168
+ error: error.message
169
+ });
170
+ }
171
+ }
172
+ handleRpcResponse(msg) {
173
+ const requestId = msg.requestId;
174
+ if (!requestId) return;
175
+ const pending = this.pendingRequests.get(requestId);
176
+ if (!pending) return;
177
+ clearTimeout(pending.timer);
178
+ this.pendingRequests.delete(requestId);
179
+ if (msg.error) {
180
+ pending.reject(new Error(msg.error));
181
+ } else {
182
+ pending.resolve(msg.payload);
183
+ }
184
+ }
185
+ };
186
+ export {
187
+ PluginSandbox
188
+ };