@marimo-team/islands 0.21.2-dev2 → 0.21.2-dev20

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 CHANGED
@@ -29325,6 +29325,8 @@ ${c.sqlString}
29325
29325
  var NotebookLanguageServerClient = (_a = class {
29326
29326
  constructor(e, r, c = defaultGetNotebookEditors) {
29327
29327
  __publicField(this, "completionItemCache", new LRUCache(10));
29328
+ __publicField(this, "latestDiagnosticsVersion", null);
29329
+ __publicField(this, "forwardedDiagnosticsVersion", 0);
29328
29330
  this.documentUri = getLSPDocument(), this.getNotebookEditors = c, this.initialSettings = r, this.client = e, this.patchProcessNotification(), this.initializePromise.then(() => {
29329
29331
  invariant(isClientWithNotify(this.client), "notify is not a method on the client"), this.client.notify("workspace/didChangeConfiguration", {
29330
29332
  settings: r
@@ -29372,7 +29374,7 @@ ${c.sqlString}
29372
29374
  settings: this.initialSettings
29373
29375
  });
29374
29376
  let { lens: e, version: r } = this.snapshotter.snapshot();
29375
- await this.client.textDocumentDidOpen({
29377
+ this.latestDiagnosticsVersion = null, this.forwardedDiagnosticsVersion = 0, await this.client.textDocumentDidOpen({
29376
29378
  textDocument: {
29377
29379
  languageId: "python",
29378
29380
  text: e.mergedText,
@@ -29570,39 +29572,49 @@ ${c.sqlString}
29570
29572
  invariant("processNotification" in this.client, "processNotification is not a method on the client");
29571
29573
  let r = this.client.processNotification.bind(this.client), c = (c2) => {
29572
29574
  if (c2.method === "textDocument/publishDiagnostics") {
29575
+ let d = c2.params.version;
29576
+ if (d != null) {
29577
+ let e = this.latestDiagnosticsVersion;
29578
+ if (e !== null && Number.isFinite(d) && d < e) {
29579
+ Logger.debug("[lsp] dropping stale diagnostics notification", c2);
29580
+ return;
29581
+ }
29582
+ this.latestDiagnosticsVersion = d;
29583
+ }
29573
29584
  Logger.debug("[lsp] handling diagnostics", c2);
29574
- let d = this.snapshotter.getLatestSnapshot(), f = c2.params.diagnostics, { lens: _, version: v } = d, y = /* @__PURE__ */ new Map();
29575
- for (let e of f) for (let r2 of _.cellIds) if (_.isInRange(e.range, r2)) {
29576
- y.has(r2) || y.set(r2, []);
29585
+ let f = this.snapshotter.getLatestSnapshot(), _ = c2.params.diagnostics, { lens: v } = f, y = ++this.forwardedDiagnosticsVersion, S = /* @__PURE__ */ new Map();
29586
+ for (let e of _) for (let r2 of v.cellIds) if (v.isInRange(e.range, r2)) {
29587
+ S.has(r2) || S.set(r2, []);
29577
29588
  let c3 = {
29578
29589
  ...e,
29579
- range: _.reverseRange(e.range, r2)
29590
+ range: v.reverseRange(e.range, r2)
29580
29591
  };
29581
- y.get(r2).push(c3);
29592
+ S.get(r2).push(c3);
29582
29593
  break;
29583
29594
  }
29584
- let S = new Set(_.cellIds);
29585
- _a.pruneSeenCellUris(S);
29586
- let w = new Set(_a.SEEN_CELL_DOCUMENT_URIS);
29587
- for (let [e, d2] of y.entries()) {
29595
+ let w = new Set(v.cellIds);
29596
+ _a.pruneSeenCellUris(w);
29597
+ let E = new Set(_a.SEEN_CELL_DOCUMENT_URIS);
29598
+ for (let [e, d2] of S.entries()) {
29588
29599
  Logger.debug("[lsp] diagnostics for cell", e, d2);
29589
29600
  let f2 = CellDocumentUri.of(e);
29590
- w.delete(f2), r({
29601
+ E.delete(f2), r({
29591
29602
  ...c2,
29592
29603
  params: {
29593
29604
  ...c2.params,
29594
29605
  uri: f2,
29595
- version: v,
29606
+ version: y,
29596
29607
  diagnostics: d2
29597
29608
  }
29598
29609
  });
29599
29610
  }
29600
- if (w.size > 0) {
29601
- Logger.debug("[lsp] clearing diagnostics", w);
29602
- for (let e of w) r({
29611
+ if (E.size > 0) {
29612
+ Logger.debug("[lsp] clearing diagnostics", E);
29613
+ for (let e of E) r({
29603
29614
  method: "textDocument/publishDiagnostics",
29604
29615
  params: {
29605
29616
  uri: e,
29617
+ version: y,
29606
29618
  diagnostics: []
29607
29619
  }
29608
29620
  });
@@ -32264,12 +32276,14 @@ ${c.sqlString}
32264
32276
  afterCursorCode: getEditorCodeAsPython(e, v)
32265
32277
  };
32266
32278
  }
32267
- var TEMPORARY_ATTRIBUTE = "data-temp-href-target";
32268
- purify.addHook("beforeSanitizeAttributes", (e) => {
32269
- e.tagName === "A" && (e.hasAttribute("target") || e.setAttribute("target", "_self"), e.hasAttribute("target") && e.setAttribute(TEMPORARY_ATTRIBUTE, e.getAttribute("target") || ""));
32270
- }), purify.addHook("afterSanitizeAttributes", (e) => {
32271
- e.tagName === "A" && e.hasAttribute(TEMPORARY_ATTRIBUTE) && (e.setAttribute("target", e.getAttribute(TEMPORARY_ATTRIBUTE) || ""), e.removeAttribute(TEMPORARY_ATTRIBUTE), e.getAttribute("target") === "_blank" && e.setAttribute("rel", "noopener noreferrer"));
32272
- });
32279
+ if (typeof document < "u") {
32280
+ let e = "data-temp-href-target";
32281
+ purify.addHook("beforeSanitizeAttributes", (r) => {
32282
+ r.tagName === "A" && (r.hasAttribute("target") || r.setAttribute("target", "_self"), r.hasAttribute("target") && r.setAttribute(e, r.getAttribute("target") || ""));
32283
+ }), purify.addHook("afterSanitizeAttributes", (r) => {
32284
+ r.tagName === "A" && r.hasAttribute(e) && (r.setAttribute("target", r.getAttribute(e) || ""), r.removeAttribute(e), r.getAttribute("target") === "_blank" && r.setAttribute("rel", "noopener noreferrer"));
32285
+ });
32286
+ }
32273
32287
  function sanitizeHtml(e) {
32274
32288
  let r = {
32275
32289
  USE_PROFILES: {
@@ -58976,9 +58990,16 @@ ${r}
58976
58990
  }
58977
58991
  var isSlotElement = (e) => e.tagName != null && e.tagName.toUpperCase() === "SLOT", isSVGElement = (e) => e.tagName != null && e.tagName.toUpperCase() === "SVG";
58978
58992
  async function cloneChildren(e, r, c) {
58993
+ var _a3;
58979
58994
  if (isSVGElement(r)) return r;
58980
58995
  let d = [];
58981
- return d = isSlotElement(e) && e.assignedNodes ? toArray(e.assignedNodes()) : toArray((e.shadowRoot ?? e).childNodes), d.length === 0 || isInstanceOfElement(e, HTMLVideoElement) || await d.reduce((e2, d2) => e2.then(() => cloneNode(d2, c)).then((e3) => {
58996
+ if (isSlotElement(e) && e.assignedNodes) d = toArray(e.assignedNodes());
58997
+ else if (isInstanceOfElement(e, HTMLIFrameElement)) try {
58998
+ ((_a3 = e.contentDocument) == null ? void 0 : _a3.body) && (d = toArray(e.contentDocument.body.childNodes));
58999
+ } catch {
59000
+ }
59001
+ else d = toArray((e.shadowRoot ?? e).childNodes);
59002
+ return d.length === 0 || isInstanceOfElement(e, HTMLVideoElement) || await d.reduce((e2, d2) => e2.then(() => cloneNode(d2, c)).then((e3) => {
58982
59003
  e3 && r.appendChild(e3);
58983
59004
  }), Promise.resolve()), r;
58984
59005
  }
@@ -59190,12 +59211,13 @@ ${r}
59190
59211
  return getWebFontRules(await getCSSRules(toArray(e.ownerDocument.styleSheets), r));
59191
59212
  }
59192
59213
  function normalizeFontFamily(e) {
59193
- return e.trim().replace(/["']/g, "");
59214
+ return (e || "").trim().replace(/["']/g, "");
59194
59215
  }
59195
59216
  function getUsedFonts(e) {
59196
59217
  let r = /* @__PURE__ */ new Set();
59197
59218
  function c(e2) {
59198
- (e2.style.fontFamily || getComputedStyle(e2).fontFamily).split(",").forEach((e3) => {
59219
+ let d = e2.style.fontFamily || getComputedStyle(e2).fontFamily;
59220
+ d && d.split(",").forEach((e3) => {
59199
59221
  r.add(normalizeFontFamily(e3));
59200
59222
  }), Array.from(e2.children).forEach((e3) => {
59201
59223
  e3 instanceof HTMLElement && c(e3);
@@ -59211,7 +59233,7 @@ ${r}
59211
59233
  }))).join("\n");
59212
59234
  }
59213
59235
  async function embedWebFonts(e, r) {
59214
- let c = r.fontEmbedCSS == null ? r.skipFonts ? null : await getWebFontCSS(e, r) : r.fontEmbedCSS, d = r.extraStyleContent == null ? c : r.extraStyleContent.concat(c || "");
59236
+ let c = r.fontEmbedCSS == null ? r.skipFonts ? null : await getWebFontCSS(e, r) : r.fontEmbedCSS, d = r.extraStyleContent == null ? c : (c || "").concat(r.extraStyleContent);
59215
59237
  if (d) {
59216
59238
  let r2 = document.createElement("style"), c2 = document.createTextNode(d);
59217
59239
  r2.appendChild(c2), e.firstChild ? e.insertBefore(r2, e.firstChild) : e.appendChild(r2);
@@ -59240,6 +59262,7 @@ ${r}
59240
59262
  return Logger.error("Error filtering node:", e2), true;
59241
59263
  }
59242
59264
  },
59265
+ imagePlaceholder: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQI12NgAAIABQABNjN9GQAAAAlwSFlzAAAWJQAAFiUBSVIk8AAAAA0lEQVQI12P4z8BQDwAEgAF/QualIQAAAABJRU5ErkJggg==",
59243
59266
  onImageErrorHandler: (e) => {
59244
59267
  Logger.error("Error loading image:", e);
59245
59268
  },
@@ -59423,10 +59446,10 @@ Defaulting to \`null\`.`;
59423
59446
  d && (v = d(r));
59424
59447
  try {
59425
59448
  downloadByURL(await toPng(r), Filenames.toPNG(c));
59426
- } catch {
59427
- toast({
59428
- title: "Error",
59429
- description: "Failed to download as PNG.",
59449
+ } catch (e2) {
59450
+ Logger.error("Error downloading as PNG", e2), toast({
59451
+ title: "Failed to download as PNG",
59452
+ description: prettyError(e2),
59430
59453
  variant: "danger"
59431
59454
  });
59432
59455
  } finally {
@@ -70777,7 +70800,7 @@ Image URL: ${r.imageUrl}`)), contextToXml({
70777
70800
  return Logger.warn("Failed to get version from mount config"), null;
70778
70801
  }
70779
70802
  }
70780
- const marimoVersionAtom = atom(getVersionFromMountConfig() || "0.21.2-dev2"), showCodeInRunModeAtom = atom(true);
70803
+ const marimoVersionAtom = atom(getVersionFromMountConfig() || "0.21.2-dev20"), showCodeInRunModeAtom = atom(true);
70781
70804
  atom(null);
70782
70805
  var import_compiler_runtime$89 = require_compiler_runtime();
70783
70806
  function useKeydownOnElement(e, r) {
@@ -93082,7 +93105,7 @@ ${c}
93082
93105
  });
93083
93106
  }
93084
93107
  }, SliderComponent = (e) => {
93085
- let r = (0, import_compiler_runtime$26.c)(55), { label: c, setValue: d, value: f, start: _, stop: v, step: y, debounce: S, orientation: w, showValue: E, fullWidth: O, valueMap: M, includeInput: I, disabled: z } = e, G = (0, import_react.useId)(), { locale: q } = $18f2051aff69b9bf$export$43bb16f9c6d9e3f7(), [IY, LY] = (0, import_react.useState)(f), RY, zY;
93108
+ let r = (0, import_compiler_runtime$26.c)(54), { label: c, setValue: d, value: f, start: _, stop: v, step: y, debounce: S, orientation: w, showValue: E, fullWidth: O, valueMap: M, includeInput: I, disabled: z } = e, G = (0, import_react.useId)(), { locale: q } = $18f2051aff69b9bf$export$43bb16f9c6d9e3f7(), [IY, LY] = (0, import_react.useState)(f), RY, zY;
93086
93109
  r[0] === f ? (RY = r[1], zY = r[2]) : (RY = () => {
93087
93110
  LY(f);
93088
93111
  }, zY = [
@@ -93128,10 +93151,10 @@ ${c}
93128
93151
  })
93129
93152
  }), r[27] = IY, r[28] = q, r[29] = E, r[30] = M, r[31] = ZY) : ZY = r[31];
93130
93153
  let QY;
93131
- r[32] !== S || r[33] !== z || r[34] !== I || r[35] !== IY || r[36] !== c || r[37] !== d || r[38] !== _ || r[39] !== y || r[40] !== v || r[41] !== M ? (QY = I && (0, import_jsx_runtime.jsx)(NumberField, {
93154
+ r[32] !== z || r[33] !== I || r[34] !== IY || r[35] !== c || r[36] !== d || r[37] !== _ || r[38] !== y || r[39] !== v || r[40] !== M ? (QY = I && (0, import_jsx_runtime.jsx)(NumberField, {
93132
93155
  value: M(IY),
93133
93156
  onChange: (e2) => {
93134
- (e2 == null || Number.isNaN(e2)) && (e2 = Number(_)), LY(e2), S || d(e2);
93157
+ (e2 == null || Number.isNaN(e2)) && (e2 = Number(_)), LY(e2), d(e2);
93135
93158
  },
93136
93159
  minValue: _,
93137
93160
  maxValue: v,
@@ -93139,25 +93162,25 @@ ${c}
93139
93162
  className: "w-24",
93140
93163
  "aria-label": `${c || "Slider"} value input`,
93141
93164
  isDisabled: z
93142
- }), r[32] = S, r[33] = z, r[34] = I, r[35] = IY, r[36] = c, r[37] = d, r[38] = _, r[39] = y, r[40] = v, r[41] = M, r[42] = QY) : QY = r[42];
93165
+ }), r[32] = z, r[33] = I, r[34] = IY, r[35] = c, r[36] = d, r[37] = _, r[38] = y, r[39] = v, r[40] = M, r[41] = QY) : QY = r[41];
93143
93166
  let $Y;
93144
- r[43] !== XY || r[44] !== ZY || r[45] !== QY || r[46] !== WY ? ($Y = (0, import_jsx_runtime.jsxs)("div", {
93167
+ r[42] !== XY || r[43] !== ZY || r[44] !== QY || r[45] !== WY ? ($Y = (0, import_jsx_runtime.jsxs)("div", {
93145
93168
  className: WY,
93146
93169
  children: [
93147
93170
  XY,
93148
93171
  ZY,
93149
93172
  QY
93150
93173
  ]
93151
- }), r[43] = XY, r[44] = ZY, r[45] = QY, r[46] = WY, r[47] = $Y) : $Y = r[47];
93174
+ }), r[42] = XY, r[43] = ZY, r[44] = QY, r[45] = WY, r[46] = $Y) : $Y = r[46];
93152
93175
  let eX;
93153
- return r[48] !== O || r[49] !== G || r[50] !== c || r[51] !== $Y || r[52] !== BY || r[53] !== HY ? (eX = (0, import_jsx_runtime.jsx)(Labeled, {
93176
+ return r[47] !== O || r[48] !== G || r[49] !== c || r[50] !== $Y || r[51] !== BY || r[52] !== HY ? (eX = (0, import_jsx_runtime.jsx)(Labeled, {
93154
93177
  label: c,
93155
93178
  id: G,
93156
93179
  align: BY,
93157
93180
  fullWidth: O,
93158
93181
  className: HY,
93159
93182
  children: $Y
93160
- }), r[48] = O, r[49] = G, r[50] = c, r[51] = $Y, r[52] = BY, r[53] = HY, r[54] = eX) : eX = r[54], eX;
93183
+ }), r[47] = O, r[48] = G, r[49] = c, r[50] = $Y, r[51] = BY, r[52] = HY, r[53] = eX) : eX = r[53], eX;
93161
93184
  }, import_compiler_runtime$25 = require_compiler_runtime(), SwitchPlugin = class {
93162
93185
  constructor() {
93163
93186
  __publicField(this, "tagName", "marimo-switch");