@marimo-team/frontend 0.19.10-dev49 → 0.19.10-dev51
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/index.html
CHANGED
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
<marimo-server-token data-token="{{ server_token }}" hidden></marimo-server-token>
|
|
67
67
|
<!-- /TODO -->
|
|
68
68
|
<title>{{ title }}</title>
|
|
69
|
-
<script type="module" crossorigin src="./assets/index-
|
|
69
|
+
<script type="module" crossorigin src="./assets/index-B5Sirmey.js"></script>
|
|
70
70
|
<link rel="modulepreload" crossorigin href="./assets/preload-helper-D2MJg03u.js">
|
|
71
71
|
<link rel="modulepreload" crossorigin href="./assets/clsx-D8GwTfvk.js">
|
|
72
72
|
<link rel="modulepreload" crossorigin href="./assets/cn-BKtXLv3a.js">
|
package/package.json
CHANGED
|
@@ -21,7 +21,6 @@ import { BINDING_MANAGER, WIDGET_DEF_REGISTRY } from "./widget-binding";
|
|
|
21
21
|
interface Data {
|
|
22
22
|
jsUrl: string;
|
|
23
23
|
jsHash: string;
|
|
24
|
-
css?: string | null;
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
type AnyWidgetState = ModelState;
|
|
@@ -118,21 +117,18 @@ export const AnyWidgetPlugin = createPlugin<ModelIdRef>("marimo-anywidget")
|
|
|
118
117
|
z.object({
|
|
119
118
|
jsUrl: z.string(),
|
|
120
119
|
jsHash: z.string(),
|
|
121
|
-
css: z.string().nullish(),
|
|
122
120
|
}),
|
|
123
121
|
)
|
|
124
122
|
.withFunctions({})
|
|
125
123
|
.renderer((props) => <AnyWidgetSlot {...props} />);
|
|
126
124
|
|
|
127
125
|
const AnyWidgetSlot = (props: IPluginProps<ModelIdRef, Data>) => {
|
|
128
|
-
const {
|
|
126
|
+
const { jsUrl, jsHash } = props.data;
|
|
129
127
|
const { model_id: modelId } = props.value;
|
|
130
128
|
const host = props.host as HTMLElementNotDerivedFromRef;
|
|
131
129
|
|
|
132
130
|
const { jsModule, error } = useAnyWidgetModule({ jsUrl, jsHash });
|
|
133
131
|
|
|
134
|
-
useMountCss(css, host);
|
|
135
|
-
|
|
136
132
|
if (error) {
|
|
137
133
|
return <ErrorBanner error={error} />;
|
|
138
134
|
}
|
|
@@ -160,6 +156,7 @@ const AnyWidgetSlot = (props: IPluginProps<ModelIdRef, Data>) => {
|
|
|
160
156
|
key={key}
|
|
161
157
|
widget={jsModule.default}
|
|
162
158
|
modelId={modelId}
|
|
159
|
+
host={host}
|
|
163
160
|
/>
|
|
164
161
|
);
|
|
165
162
|
};
|
|
@@ -207,11 +204,13 @@ function isAnyWidgetModule(mod: any): mod is { default: AnyWidget } {
|
|
|
207
204
|
interface Props<T extends AnyWidgetState> {
|
|
208
205
|
widget: AnyWidget<T>;
|
|
209
206
|
modelId: WidgetModelId;
|
|
207
|
+
host: HTMLElementNotDerivedFromRef;
|
|
210
208
|
}
|
|
211
209
|
|
|
212
210
|
const LoadedSlot = <T extends AnyWidgetState>({
|
|
213
211
|
widget,
|
|
214
212
|
modelId,
|
|
213
|
+
host,
|
|
215
214
|
}: Props<T> & { widget: AnyWidget<T> }) => {
|
|
216
215
|
const htmlRef = useRef<HTMLDivElement>(null);
|
|
217
216
|
|
|
@@ -222,6 +221,9 @@ const LoadedSlot = <T extends AnyWidgetState>({
|
|
|
222
221
|
Logger.error("Model not found for modelId", modelId);
|
|
223
222
|
}
|
|
224
223
|
|
|
224
|
+
const css = model?.get("_css");
|
|
225
|
+
useMountCss(css, host);
|
|
226
|
+
|
|
225
227
|
useEffect(() => {
|
|
226
228
|
if (!htmlRef.current || !model) {
|
|
227
229
|
return;
|