@marimo-team/islands 0.23.14-dev60 → 0.23.14-dev61

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.
@@ -9,7 +9,7 @@ import { t as require_compiler_runtime } from "./compiler-runtime-CEbnTgxf.js";
9
9
  import { lt as kioskModeAtom, pt as outputIsStale } from "./html-to-image-_wGfk8V-.js";
10
10
  import "./chunk-5FQGJX7Z-BbqSm5gU.js";
11
11
  import { u as createLucideIcon } from "./dist--2Bqjvs0.js";
12
- import { a as DEFAULT_SLIDE_TYPE, c as Slide, ct as PanelGroup, i as DEFAULT_DECK_TRANSITION, lt as PanelResizeHandle, on as EyeOff, s as SlideSidebar, sn as Expand, st as Panel, t as useNotebookCodeAvailable, un as Code } from "./code-visibility-DQbr40fP.js";
12
+ import { a as DEFAULT_SLIDE_TYPE, c as Slide, ct as PanelGroup, i as DEFAULT_DECK_TRANSITION, lt as PanelResizeHandle, on as EyeOff, s as SlideSidebar, sn as Expand, st as Panel, t as useNotebookCodeAvailable, un as Code } from "./code-visibility-EvXXzjfW.js";
13
13
  import { X as useDebouncedCallback } from "./input-DtsN7xm-.js";
14
14
  import "./toDate-CWNNlFEX.js";
15
15
  import "./react-dom-BTJzcVJ9.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marimo-team/islands",
3
- "version": "0.23.14-dev60",
3
+ "version": "0.23.14-dev61",
4
4
  "main": "dist/main.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -310,7 +310,9 @@ export class WidgetRuntime {
310
310
 
311
311
  #mountStyle(view: RuntimeView): void {
312
312
  const root = view.el.getRootNode();
313
- if (!(root instanceof Document || root instanceof ShadowRoot)) {
313
+ // `instanceof` misses cross-realm roots (e.g. a Document
314
+ // Picture-in-Picture window); the guards check realm-independent nodeType.
315
+ if (!isDocument(root) && !isShadowRoot(root)) {
314
316
  return;
315
317
  }
316
318
  let mount = this.#styleMounts.get(root);
@@ -363,14 +365,26 @@ export class WidgetRuntime {
363
365
  }
364
366
  }
365
367
 
368
+ function isDocument(node: Node): node is Document {
369
+ return node.nodeType === Node.DOCUMENT_NODE;
370
+ }
371
+
372
+ function isShadowRoot(node: Node): node is ShadowRoot {
373
+ return node.nodeType === Node.DOCUMENT_FRAGMENT_NODE && "host" in node;
374
+ }
375
+
366
376
  function createStyleMount(root: StyleRoot, initialCss: string): StyleMount {
377
+ // Build stylesheets in the root's own realm so they apply in a cross-realm
378
+ // root (e.g. a Document Picture-in-Picture window).
379
+ const doc = isDocument(root) ? root : (root.ownerDocument ?? document);
380
+ const view = doc.defaultView ?? window;
367
381
  if (
368
382
  "adoptedStyleSheets" in root &&
369
- typeof CSSStyleSheet !== "undefined" &&
370
- typeof CSSStyleSheet.prototype.replaceSync === "function"
383
+ typeof view.CSSStyleSheet !== "undefined" &&
384
+ typeof view.CSSStyleSheet.prototype.replaceSync === "function"
371
385
  ) {
372
386
  try {
373
- const sheet = new CSSStyleSheet();
387
+ const sheet = new view.CSSStyleSheet();
374
388
  sheet.replaceSync(initialCss);
375
389
  root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet];
376
390
  return {
@@ -389,10 +403,10 @@ function createStyleMount(root: StyleRoot, initialCss: string): StyleMount {
389
403
  }
390
404
  }
391
405
 
392
- const style = document.createElement("style");
406
+ const style = doc.createElement("style");
393
407
  style.textContent = initialCss;
394
- if (root instanceof Document) {
395
- root.head.append(style);
408
+ if (isDocument(root)) {
409
+ doc.head.append(style);
396
410
  } else {
397
411
  root.append(style);
398
412
  }