ilha 0.14.7 → 0.14.8

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/define.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as mount } from "./mount-rXNnaIWf.js";
1
+ import { t as mount } from "./mount-BQ-zcg2x.js";
2
2
 
3
3
  //#region src/define.ts
4
4
  const define = (name, component) => {
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as makeFiber, a as interpret, c as handleOwner, d as structuralEqual, f as untrack, g as getFiber, h as closeFiber, i as runSetup, l as instr, m as clearFiberView, n as renderToString, o as atom, p as wrapHandle, r as unsafe, s as batch, t as mount, u as isAtomHandle } from "./mount-rXNnaIWf.js";
1
+ import { _ as makeFiber, a as interpret, c as handleOwner, d as structuralEqual, f as untrack, g as getFiber, h as closeFiber, i as runSetup, l as instr, m as clearFiberView, n as renderToString, o as atom, p as wrapHandle, r as unsafe, s as batch, t as mount, u as isAtomHandle } from "./mount-BQ-zcg2x.js";
2
2
  import { d as errorView, g as isString, i as Fragment, p as isFunction, t as h } from "./vnode-M-oJMKcv.js";
3
3
  import * as Atom from "effect/reactivity/Atom";
4
4
  import * as Effect from "effect/Effect";
@@ -441,15 +441,15 @@ const resource = (key, fetcher, opts) => {
441
441
  }
442
442
  if (!c.held) {
443
443
  c.held = true;
444
+ const onInvalidate = () => {
445
+ settleStart();
446
+ };
444
447
  watch.once(() => {
445
448
  let live = liveRefetchers.get(key);
446
449
  if (!live) {
447
450
  live = /* @__PURE__ */ new Set();
448
451
  liveRefetchers.set(key, live);
449
452
  }
450
- const onInvalidate = () => {
451
- settleStart();
452
- };
453
453
  live.add(onInvalidate);
454
454
  return () => {
455
455
  c.alive = false;
@@ -488,22 +488,22 @@ const connect = ({ cell: c, decode, event, retryBase, url }) => {
488
488
  for (const sink of c.sinks.values()) sink.latest.set(value);
489
489
  for (const push of c.targets) push(value);
490
490
  };
491
+ const onMessage = (ev) => {
492
+ const raw = ev.data;
493
+ if (!isString(raw)) return;
494
+ let value;
495
+ try {
496
+ value = decode(raw);
497
+ } catch {
498
+ return;
499
+ }
500
+ emit(value);
501
+ };
491
502
  const open = () => {
492
503
  if (disposed) return;
493
504
  setStatus(c, attempt === 0 ? "connecting" : "retrying");
494
505
  const es = new EventSource(url);
495
506
  source = es;
496
- const onMessage = (ev) => {
497
- const raw = ev.data;
498
- if (!isString(raw)) return;
499
- let value;
500
- try {
501
- value = decode(raw);
502
- } catch {
503
- return;
504
- }
505
- emit(value);
506
- };
507
507
  const onOpen = () => {
508
508
  attempt = 0;
509
509
  setStatus(c, "open");
@@ -897,6 +897,21 @@ const sweepComponentSlots = (fiber) => {
897
897
  }
898
898
  slots.length = cframe.i;
899
899
  };
900
+ const sweepIslandSlots = (fiber) => {
901
+ const frame = fiber.islandFrame;
902
+ if (!frame) return;
903
+ const active = new Set(frame.slots.slice(0, frame.i));
904
+ const keep = [];
905
+ for (const h of fiber.holes) {
906
+ if (h.islandSlot && !active.has(h.islandSlot)) {
907
+ h.dispose();
908
+ continue;
909
+ }
910
+ keep.push(h);
911
+ }
912
+ fiber.holes = keep;
913
+ frame.slots.length = Math.min(frame.slots.length, frame.i);
914
+ };
900
915
  const findReusableAtomHost = (fiber, atom) => {
901
916
  for (const h of fiber.holes) if (h.atom === atom && h.host?.isConnected && h.holeFiber && !h.holeFiber.closed) return {
902
917
  hole: h.holeFiber,
@@ -1038,13 +1053,16 @@ const createPainter = (ops) => {
1038
1053
  const list = Array.isArray(view) ? view : null;
1039
1054
  if (list && list.length > 0 && list.every((v) => isVNode(v) && v.key !== null && v.key !== void 0)) {
1040
1055
  paintFns.keyedPaintHole(fiber, list);
1056
+ sweepComponentSlots(fiber);
1057
+ sweepIslandSlots(fiber);
1041
1058
  return;
1042
1059
  }
1043
1060
  const kept = /* @__PURE__ */ new Set();
1044
1061
  for (const s of cframe.slots) if (s && !s.hole.closed) kept.add(s.hole);
1062
+ const keptIslands = new Set(frame.slots);
1045
1063
  const keep = [];
1046
1064
  for (const h of fiber.holes) {
1047
- if (h.holeFiber && kept.has(h.holeFiber)) {
1065
+ if (h.holeFiber && kept.has(h.holeFiber) || h.islandSlot && keptIslands.has(h.islandSlot)) {
1048
1066
  keep.push(h);
1049
1067
  continue;
1050
1068
  }
@@ -1061,6 +1079,7 @@ const createPainter = (ops) => {
1061
1079
  api.insert(fiber, fresh);
1062
1080
  }
1063
1081
  sweepComponentSlots(fiber);
1082
+ sweepIslandSlots(fiber);
1064
1083
  }
1065
1084
  };
1066
1085
  const materializeAtom = (view, fiber) => {
@@ -1116,7 +1135,14 @@ const createPainter = (ops) => {
1116
1135
  existing.updateProps(props);
1117
1136
  return [ops.asNode(existing.host)];
1118
1137
  }
1119
- existing?.unmount?.();
1138
+ if (existing) {
1139
+ const idx = fiber.holes.findIndex((h) => h.islandSlot === existing);
1140
+ if (idx === -1) existing.unmount?.();
1141
+ else {
1142
+ const [removed] = fiber.holes.splice(idx, 1);
1143
+ removed?.dispose();
1144
+ }
1145
+ }
1120
1146
  const tag = isString(type[ISLAND_SLOT_TAG]) ? type[ISLAND_SLOT_TAG] : "div";
1121
1147
  const el = ops.createElement(tag);
1122
1148
  el.dataset.ilha = "";
@@ -1136,6 +1162,7 @@ const createPainter = (ops) => {
1136
1162
  handle?.unmount?.();
1137
1163
  if (frame.slots[i] === slot) frame.slots[i] = void 0;
1138
1164
  },
1165
+ islandSlot: slot,
1139
1166
  keepOnMorph: true
1140
1167
  });
1141
1168
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ilha",
3
- "version": "0.14.7",
3
+ "version": "0.14.8",
4
4
  "description": "Generator-first island UI on Effect",
5
5
  "keywords": [
6
6
  "effect",