@marimo-team/islands 0.22.1-dev42 → 0.22.1-dev43
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/dist/main.js +24 -3
- package/package.json +1 -1
- package/src/core/dom/uiregistry.ts +42 -8
package/dist/main.js
CHANGED
|
@@ -14080,7 +14080,11 @@ Defaulting to \`null\`.`;
|
|
|
14080
14080
|
]
|
|
14081
14081
|
});
|
|
14082
14082
|
}
|
|
14083
|
-
var import_client$1 = __toESM(require_client(), 1)
|
|
14083
|
+
var import_client$1 = __toESM(require_client(), 1);
|
|
14084
|
+
function isUIValueUpdateMessage(e) {
|
|
14085
|
+
return typeof e != "object" || !e ? false : "type" in e && e.type === "marimo-ui-value-update";
|
|
14086
|
+
}
|
|
14087
|
+
var UIElementRegistry = class e {
|
|
14084
14088
|
static get INSTANCE() {
|
|
14085
14089
|
let r = "_marimo_private_UIElementRegistry";
|
|
14086
14090
|
return window[r] || (window[r] = new e()), window[r];
|
|
@@ -14125,7 +14129,24 @@ Defaulting to \`null\`.`;
|
|
|
14125
14129
|
}
|
|
14126
14130
|
broadcastMessage(e2, r, c) {
|
|
14127
14131
|
let d = this.entries.get(e2);
|
|
14128
|
-
d === void 0
|
|
14132
|
+
if (d === void 0) {
|
|
14133
|
+
Logger.warn("UIElementRegistry missing entry", e2);
|
|
14134
|
+
return;
|
|
14135
|
+
}
|
|
14136
|
+
if (isUIValueUpdateMessage(r)) {
|
|
14137
|
+
d.value = r.value, d.elements.forEach((e3) => {
|
|
14138
|
+
e3.dispatchEvent(MarimoValueUpdateEvent.create({
|
|
14139
|
+
bubbles: false,
|
|
14140
|
+
composed: true,
|
|
14141
|
+
detail: {
|
|
14142
|
+
value: r.value,
|
|
14143
|
+
element: e3
|
|
14144
|
+
}
|
|
14145
|
+
}));
|
|
14146
|
+
});
|
|
14147
|
+
return;
|
|
14148
|
+
}
|
|
14149
|
+
d.elements.forEach((d2) => {
|
|
14129
14150
|
d2.dispatchEvent(MarimoIncomingMessageEvent.create({
|
|
14130
14151
|
bubbles: false,
|
|
14131
14152
|
composed: true,
|
|
@@ -65519,7 +65540,7 @@ ${c}
|
|
|
65519
65540
|
return Logger.warn("Failed to get version from mount config"), null;
|
|
65520
65541
|
}
|
|
65521
65542
|
}
|
|
65522
|
-
const marimoVersionAtom = atom(getVersionFromMountConfig() || "0.22.1-
|
|
65543
|
+
const marimoVersionAtom = atom(getVersionFromMountConfig() || "0.22.1-dev43"), showCodeInRunModeAtom = atom(true);
|
|
65523
65544
|
atom(null);
|
|
65524
65545
|
var VIRTUAL_FILE_REGEX = /\/@file\/([^\s"&'/]+)\.([\dA-Za-z]+)/g, VirtualFileTracker = class e {
|
|
65525
65546
|
constructor() {
|
package/package.json
CHANGED
|
@@ -10,6 +10,23 @@ import {
|
|
|
10
10
|
} from "./events";
|
|
11
11
|
import { parseInitialValue } from "./htmlUtils";
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Kernel-initiated UI value update, sent via the existing
|
|
15
|
+
* `send-ui-element-message` channel when `set_ui_value` (code_mode)
|
|
16
|
+
* changes a widget's value so the frontend can reflect the new state.
|
|
17
|
+
*/
|
|
18
|
+
interface UIValueUpdateMessage {
|
|
19
|
+
type: "marimo-ui-value-update";
|
|
20
|
+
value: ValueType;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function isUIValueUpdateMessage(msg: unknown): msg is UIValueUpdateMessage {
|
|
24
|
+
if (typeof msg !== "object" || msg === null) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
return "type" in msg && msg.type === "marimo-ui-value-update";
|
|
28
|
+
}
|
|
29
|
+
|
|
13
30
|
interface UIElementEntry {
|
|
14
31
|
objectId: string;
|
|
15
32
|
value: ValueType;
|
|
@@ -141,21 +158,38 @@ export class UIElementRegistry {
|
|
|
141
158
|
const entry = this.entries.get(objectId);
|
|
142
159
|
if (entry === undefined) {
|
|
143
160
|
Logger.warn("UIElementRegistry missing entry", objectId);
|
|
144
|
-
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Kernel-initiated value update — push into DOM elements without
|
|
165
|
+
// dispatching MarimoValueReadyEvent to avoid a round-trip.
|
|
166
|
+
if (isUIValueUpdateMessage(message)) {
|
|
167
|
+
entry.value = message.value;
|
|
145
168
|
entry.elements.forEach((element) => {
|
|
146
169
|
element.dispatchEvent(
|
|
147
|
-
|
|
148
|
-
bubbles: false,
|
|
170
|
+
MarimoValueUpdateEvent.create({
|
|
171
|
+
bubbles: false,
|
|
149
172
|
composed: true,
|
|
150
|
-
detail: {
|
|
151
|
-
objectId: objectId,
|
|
152
|
-
message: message,
|
|
153
|
-
buffers: buffers,
|
|
154
|
-
},
|
|
173
|
+
detail: { value: message.value, element: element },
|
|
155
174
|
}),
|
|
156
175
|
);
|
|
157
176
|
});
|
|
177
|
+
return;
|
|
158
178
|
}
|
|
179
|
+
|
|
180
|
+
entry.elements.forEach((element) => {
|
|
181
|
+
element.dispatchEvent(
|
|
182
|
+
MarimoIncomingMessageEvent.create({
|
|
183
|
+
bubbles: false, // only the intended target gets the message
|
|
184
|
+
composed: true,
|
|
185
|
+
detail: {
|
|
186
|
+
objectId: objectId,
|
|
187
|
+
message: message,
|
|
188
|
+
buffers: buffers,
|
|
189
|
+
},
|
|
190
|
+
}),
|
|
191
|
+
);
|
|
192
|
+
});
|
|
159
193
|
}
|
|
160
194
|
|
|
161
195
|
/**
|