@solidjs/web 2.0.0-rc.10 → 2.0.0-rc.13

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.
@@ -1,6 +1,6 @@
1
1
  import * as core from 'solid-js';
2
- import { getOwner, onCleanup, createMemo, runWithOwner, createSignal, createRenderEffect, createLoadingBoundary, createOwner, sharedConfig } from 'solid-js';
3
- import { delegateEvents, insert } from '@solidjs/web';
2
+ import { getOwner, onCleanup, createMemo, runWithOwner, createSignal, createRenderEffect, createOwner } from 'solid-js';
3
+ import { insert, assign } from '@solidjs/web';
4
4
  import { frameAddress, SINGLE_FLIGHT_HEADER, LIVE_WIRE, deserializeStream, getServerFunctionsCodec, createChunk, deliverFlightData, ERROR_HEADER, hasFlightMetadata, isEventStream, ChunkReader, configureServerFunctionsClient } from '@solidjs/web/server-functions/client';
5
5
 
6
6
  const ELEMENT_NODE = 1;
@@ -16,71 +16,6 @@ function claimNode(handlers, el) {
16
16
  for (let i = 0; i < handlers.length; i++) handlers[i](el);
17
17
  }
18
18
  const claimedAttr = name => name === "href" || name === "action";
19
- const BOUND_SEAM = Symbol.for("solid.bnd");
20
- const boundSeam = globalThis[BOUND_SEAM] || (globalThis[BOUND_SEAM] = {});
21
- const BND_ATTR = "_bnd";
22
- const BND_SELECTOR = "[_bnd]";
23
- function bndMap(el) {
24
- const s = el.getAttribute(BND_ATTR);
25
- if (!s) return undefined;
26
- const map = {};
27
- for (const entry of s.split(",")) {
28
- const eq = entry.indexOf("=");
29
- if (eq < 1) continue;
30
- const pos = entry.slice(0, eq);
31
- const prop = decodeURIComponent(entry.slice(eq + 1));
32
- const prev = map[pos];
33
- if (prev === undefined) map[pos] = prop;else if (Array.isArray(prev)) prev.push(prop);else map[pos] = [prev, prop];
34
- }
35
- return map;
36
- }
37
- boundSeam.resolve = (el, type) => {
38
- const frame = el._$bndFrame;
39
- if (!frame) return undefined;
40
- const map = bndMap(el);
41
- const prop = map && map[type];
42
- if (typeof prop !== "string") return undefined;
43
- return claimFn(frame, type, prop);
44
- };
45
- function claimFn(frame, pos, prop) {
46
- const fn = frame.clientProp(prop);
47
- if (typeof fn === "function") return fn;
48
- return undefined;
49
- }
50
- function sweepBound(root, frame, delegate, scope) {
51
- const isElement = root.nodeType === ELEMENT_NODE;
52
- if (!isElement && root.nodeType !== 11 ) return;
53
- let els;
54
- if (isElement && root.hasAttribute(BND_ATTR)) (els = []).push(root);
55
- const found = root.querySelectorAll(BND_SELECTOR);
56
- if (found.length) {
57
- els || (els = []);
58
- for (let i = 0; i < found.length; i++) els.push(found[i]);
59
- }
60
- if (!els) return;
61
- const run = () => {
62
- let types;
63
- for (const el of els) {
64
- el._$bndFrame = frame;
65
- const map = bndMap(el);
66
- if (!map) continue;
67
- for (const pos in map) {
68
- if (pos === "ref") fireRefs(frame, el, map.ref);else (types || (types = [])).push(pos);
69
- }
70
- }
71
- if (types && delegate) delegate(types);
72
- };
73
- scope ? scope(run) : run();
74
- }
75
- function fireRefs(frame, el, prop) {
76
- const fired = el._$bndFired || (el._$bndFired = new Set());
77
- for (const p of Array.isArray(prop) ? prop : [prop]) {
78
- if (fired.has(p)) continue;
79
- fired.add(p);
80
- const fn = claimFn(frame, "ref", p);
81
- if (fn) fn(el);
82
- }
83
- }
84
19
  function claimTree(handlers, root) {
85
20
  const isElement = root.nodeType === ELEMENT_NODE;
86
21
  if (!isElement && root.nodeType !== 11 ) return;
@@ -92,6 +27,45 @@ const placeholderId = name => `pl-${name}`;
92
27
  const SLOT_START = /^slot:(.+):start$/;
93
28
  const SLOT_END = /^slot:(.+):end$/;
94
29
  const slotEnd = id => `slot:${id}:end`;
30
+ const SLOT_MARKER = "_s:";
31
+ function slotPositions(el) {
32
+ const attrs = el.attributes;
33
+ let out = null;
34
+ for (let i = 0; i < attrs.length; i++) {
35
+ const attr = attrs[i];
36
+ if (!attr.name.startsWith(SLOT_MARKER)) continue;
37
+ const pos = attr.name.slice(SLOT_MARKER.length);
38
+ for (const entry of attr.value.split(",")) {
39
+ const colon = entry.indexOf(":");
40
+ if (colon < 1) continue;
41
+ const occurrence = entry.slice(0, colon);
42
+ const eq = entry.indexOf("=", colon);
43
+ const key = decodeURIComponent(eq === -1 ? entry.slice(colon + 1) : entry.slice(colon + 1, eq));
44
+ const name = eq === -1 ? undefined : decodeURIComponent(entry.slice(eq + 1));
45
+ out || (out = Object.create(null));
46
+ (out[occurrence] || (out[occurrence] = [])).push({
47
+ pos,
48
+ key,
49
+ name
50
+ });
51
+ }
52
+ }
53
+ return out;
54
+ }
55
+ function consumersEqual(a, b) {
56
+ if (a.length !== b.length) return false;
57
+ for (let i = 0; i < a.length; i++) {
58
+ const x = a[i];
59
+ const y = b[i];
60
+ if (x.element !== y.element || x.positions.length !== y.positions.length) return false;
61
+ for (let j = 0; j < x.positions.length; j++) {
62
+ const p = x.positions[j];
63
+ const q = y.positions[j];
64
+ if (p.pos !== q.pos || p.key !== q.key || p.name !== q.name) return false;
65
+ }
66
+ }
67
+ return true;
68
+ }
95
69
  function chunkToRecords(chunk) {
96
70
  switch (chunk.type) {
97
71
  case "start":
@@ -198,7 +172,6 @@ function createFrameHost(options = {}) {
198
172
  return true;
199
173
  };
200
174
  return {
201
- delegate: options.delegate,
202
175
  register(id, frame) {
203
176
  let set = frames.get(id);
204
177
  if (!set) frames.set(id, set = new Set());
@@ -287,6 +260,8 @@ class FrameImpl {
287
260
  #slotRegions = new Map();
288
261
  #slotResolvedRefs = new Map();
289
262
  #slotNodes = new Map();
263
+ #slotConsumers = new Map();
264
+ #slotRebinders = new Map();
290
265
  #processedAssets = new WeakSet();
291
266
  #recordRefresh = null;
292
267
  #disposed = false;
@@ -294,18 +269,10 @@ class FrameImpl {
294
269
  if (!this.#disposed) this.#flush();
295
270
  };
296
271
  #claimTree = (node, direct) => {
297
- if (!direct && node.nodeType !== TEXT_NODE && node.nodeType !== COMMENT_NODE) {
298
- const o = this.#options;
299
- sweepBound(node, this, o.delegate || o.host && o.host.delegate, o.ownerScope);
300
- }
301
272
  const handlers = claimHandlers();
302
273
  if (!handlers) return;
303
274
  this.#scoped(() => direct ? claimNode(handlers, node) : claimTree(handlers, node));
304
275
  };
305
- clientProp(name) {
306
- const props = this.#options.props;
307
- return props ? props[name] : undefined;
308
- }
309
276
  #scoped(fn) {
310
277
  const scope = this.#options.ownerScope;
311
278
  return scope ? scope(fn) : fn();
@@ -485,15 +452,18 @@ class FrameImpl {
485
452
  #syncSlots(root) {
486
453
  if (!this.#slots && !this.#options.resolveSlot) return;
487
454
  const found = new Map();
488
- if (root) collectSlots(root.firstChild, null, found);else this.#collectSlots(found);
455
+ if (root) collectSlots(root.firstChild, null, found, found);else this.#collectSlots(found, found);
489
456
  for (const [occurrence, start] of found) {
490
457
  const callback = this.#resolveSlot(propOf(occurrence));
491
- if (!callback) continue;
458
+ const consumers = Array.isArray(start) ? start : null;
459
+ if (!callback) {
460
+ continue;
461
+ }
492
462
  const record = this.#resolveSlotRecord(occurrence);
493
463
  if (record && record.kind === "slot" && this.#refsUnresolved(record.args)) continue;
494
464
  const prev = this.#slotNodes.get(occurrence);
495
465
  const prevFirst = Array.isArray(prev) ? prev[0] : prev;
496
- const zombie = this.#mountedSlots.has(occurrence) && prevFirst && !prevFirst.parentNode;
466
+ const zombie = !consumers && this.#mountedSlots.has(occurrence) && prevFirst && !prevFirst.parentNode;
497
467
  if (zombie) {
498
468
  this.#mountedSlots.delete(occurrence);
499
469
  this.#runSlotCleanups(occurrence);
@@ -510,12 +480,25 @@ class FrameImpl {
510
480
  }
511
481
  if (this.#options.adopt) this.#discoverRegions(occurrence, start);
512
482
  const nodes = this.#invokeSlot(occurrence, callback, record, start, this.#options.adopt);
513
- if (nodes) this.#replaceRange(occurrence, start, nodes);
514
- this.#slotNodes.set(occurrence, nodes);
483
+ if (consumers) {
484
+ this.#slotNodes.set(occurrence, consumers.map(c => c.element));
485
+ this.#slotConsumers.set(occurrence, consumers);
486
+ } else {
487
+ if (nodes) this.#replaceRange(occurrence, start, nodes);
488
+ this.#slotNodes.set(occurrence, nodes);
489
+ }
515
490
  this.#mountedSlots.add(occurrence);
516
491
  if (!this.#options.adopt || nodes) this.#discoverRegions(occurrence, start);
517
492
  this.#bindRegions(occurrence);
518
- } else if (record !== this.#slotArgs.get(occurrence)) {
493
+ continue;
494
+ }
495
+ if (consumers && !consumersEqual(this.#slotConsumers.get(occurrence), consumers)) {
496
+ this.#slotConsumers.set(occurrence, consumers);
497
+ this.#slotNodes.set(occurrence, consumers.map(c => c.element));
498
+ const rebind = this.#slotRebinders.get(occurrence);
499
+ if (rebind) rebind(consumers);
500
+ }
501
+ if (record !== this.#slotArgs.get(occurrence)) {
519
502
  if (this.#refArgsUnchanged(occurrence, record)) {
520
503
  this.#slotArgs.set(occurrence, record);
521
504
  this.#reconcileRegions(occurrence, record);
@@ -530,8 +513,10 @@ class FrameImpl {
530
513
  continue;
531
514
  }
532
515
  const nodes = this.#invokeSlot(occurrence, callback, record, start);
533
- if (nodes) this.#replaceRange(occurrence, start, nodes);
534
- this.#slotNodes.set(occurrence, nodes);
516
+ if (consumers) this.#slotNodes.set(occurrence, consumers.map(c => c.element));else {
517
+ if (nodes) this.#replaceRange(occurrence, start, nodes);
518
+ this.#slotNodes.set(occurrence, nodes);
519
+ }
535
520
  this.#bindRegions(occurrence);
536
521
  }
537
522
  }
@@ -543,10 +528,12 @@ class FrameImpl {
543
528
  }
544
529
  #invokeSlot(occurrence, callback, record, start, adopted) {
545
530
  this.#slotUpdaters.delete(occurrence);
531
+ this.#slotRebinders.delete(occurrence);
546
532
  const cleanups = this.#slotCleanups.get(occurrence) ?? [];
547
533
  let existing = [];
548
534
  let end = null;
549
- if (start) end = eachInRange(start, occurrence, n => existing.push(n));
535
+ const positions = Array.isArray(start) ? start : undefined;
536
+ if (start && !positions) end = eachInRange(start, occurrence, n => existing.push(n));
550
537
  const ctx = {
551
538
  frame: this.#options.claimScope ?? this.#options.id,
552
539
  key: occurrence,
@@ -558,7 +545,9 @@ class FrameImpl {
558
545
  range: end ? {
559
546
  start,
560
547
  end
561
- } : undefined
548
+ } : undefined,
549
+ positions,
550
+ onRebind: positions ? fn => this.#slotRebinders.set(occurrence, fn) : undefined
562
551
  };
563
552
  const props = record && record.kind === "slot" ? this.#resolveArgs(occurrence, record.args) : {};
564
553
  const content = this.#scoped(() => callback(props, ctx));
@@ -575,8 +564,10 @@ class FrameImpl {
575
564
  #unmountSlot(key) {
576
565
  this.#mountedSlots.delete(key);
577
566
  this.#slotNodes.delete(key);
567
+ this.#slotConsumers.delete(key);
578
568
  this.#slotArgs.delete(key);
579
569
  this.#slotUpdaters.delete(key);
570
+ this.#slotRebinders.delete(key);
580
571
  this.#slotResolvedRefs.delete(key);
581
572
  this.#removeSlotRecord(key);
582
573
  this.#runSlotCleanups(key);
@@ -640,7 +631,7 @@ class FrameImpl {
640
631
  return props;
641
632
  }
642
633
  #discoverRegions(slotKey, start) {
643
- if (!start) return;
634
+ if (!start || Array.isArray(start)) return;
644
635
  const regions = this.#regionsFor(slotKey);
645
636
  eachInRange(start, slotKey, n => collectRegionElements(n, regions));
646
637
  }
@@ -707,8 +698,8 @@ class FrameImpl {
707
698
  }
708
699
  }
709
700
  }
710
- #collectSlots(found) {
711
- collectSlots(this.#firstContent(), this.#end, found);
701
+ #collectSlots(found, elements) {
702
+ collectSlots(this.#firstContent(), this.#end, found, elements);
712
703
  }
713
704
  #findPlaceholder(name) {
714
705
  return findPlaceholder(this.#firstContent(), this.#end, placeholderId(name));
@@ -799,11 +790,15 @@ class FrameImpl {
799
790
  if (!el) return false;
800
791
  const parsed = parseFragment(`<i${text}></i>`).firstChild;
801
792
  const keepOpen = preservesOpen(el);
793
+ const owned = parsed ? ownedPositions(parsed) : null;
802
794
  const current = el.attributes;
803
795
  for (let i = current.length - 1; i >= 0; i--) {
804
796
  const name = current[i].name;
805
797
  if (name === "data-lha" || keepOpen && name === "open") continue;
806
- if (!parsed || !parsed.hasAttribute(name)) el.removeAttribute(name);
798
+ if (!parsed || !parsed.hasAttribute(name)) {
799
+ if (applyOwned(el, name, "", owned) !== undefined) continue;
800
+ el.removeAttribute(name);
801
+ }
807
802
  }
808
803
  if (parsed) {
809
804
  for (let i = 0; i < parsed.attributes.length; i++) {
@@ -812,10 +807,15 @@ class FrameImpl {
812
807
  value
813
808
  } = parsed.attributes[i];
814
809
  if (keepOpen && name === "open") continue;
810
+ if (applyOwned(el, name, value, owned) !== undefined) continue;
815
811
  if (el.getAttribute(name) !== value) el.setAttribute(name, value);
816
812
  }
817
813
  }
818
- if (removed) for (const name of removed) if (!(keepOpen && name === "open")) el.removeAttribute(name);
814
+ if (removed) for (const name of removed) {
815
+ if (keepOpen && name === "open") continue;
816
+ if (applyOwned(el, name, "", owned) !== undefined) continue;
817
+ el.removeAttribute(name);
818
+ }
819
819
  return true;
820
820
  }
821
821
  #clearContent() {
@@ -1060,7 +1060,7 @@ function findPlaceholder(n, end, id) {
1060
1060
  }
1061
1061
  return null;
1062
1062
  }
1063
- function collectSlots(n, end, out) {
1063
+ function collectSlots(n, end, out, elements) {
1064
1064
  while (n && n !== end) {
1065
1065
  const id = slotStartId(n);
1066
1066
  if (id !== null) {
@@ -1068,7 +1068,22 @@ function collectSlots(n, end, out) {
1068
1068
  n = afterRange(n, id);
1069
1069
  continue;
1070
1070
  }
1071
- if (n.nodeType === ELEMENT_NODE && !isFrameElement(n)) collectSlots(n.firstChild, null, out);
1071
+ if (n.nodeType === ELEMENT_NODE && !isFrameElement(n)) {
1072
+ if (elements !== undefined && n.hasAttributes()) {
1073
+ const byOccurrence = slotPositions(n);
1074
+ if (byOccurrence !== null) {
1075
+ for (const occurrence in byOccurrence) {
1076
+ let consumers = elements.get(occurrence);
1077
+ if (consumers === undefined) elements.set(occurrence, consumers = []);else if (!Array.isArray(consumers)) continue;
1078
+ consumers.push({
1079
+ element: n,
1080
+ positions: byOccurrence[occurrence]
1081
+ });
1082
+ }
1083
+ }
1084
+ }
1085
+ collectSlots(n.firstChild, null, out, elements);
1086
+ }
1072
1087
  n = n.nextSibling;
1073
1088
  }
1074
1089
  }
@@ -1146,15 +1161,77 @@ function preservesOpen(el) {
1146
1161
  const t = el.tagName;
1147
1162
  return t === "DETAILS" || t === "DIALOG";
1148
1163
  }
1164
+ function ownedPositions(el) {
1165
+ const attrs = el.attributes;
1166
+ let out = null;
1167
+ for (let i = 0; i < attrs.length; i++) {
1168
+ const name = attrs[i].name;
1169
+ if (!name.startsWith(SLOT_MARKER)) continue;
1170
+ const pos = name.slice(SLOT_MARKER.length);
1171
+ if (pos === "ref" || pos.startsWith("on:")) continue;
1172
+ out || (out = {
1173
+ attrs: new Set(),
1174
+ class: null,
1175
+ style: null
1176
+ });
1177
+ if (pos !== "class" && pos !== "style") {
1178
+ out.attrs.add(pos);
1179
+ continue;
1180
+ }
1181
+ for (const entry of attrs[i].value.split(",")) {
1182
+ const eq = entry.indexOf("=");
1183
+ if (eq === -1) {
1184
+ out.attrs.add(pos);
1185
+ continue;
1186
+ }
1187
+ (out[pos] || (out[pos] = [])).push(decodeURIComponent(entry.slice(eq + 1)));
1188
+ }
1189
+ }
1190
+ return out;
1191
+ }
1192
+ function morphOwnedClass(oldEl, value, names) {
1193
+ const list = oldEl.classList;
1194
+ const set = new Set(value ? value.split(/\s+/) : []);
1195
+ set.delete("");
1196
+ for (const name of names) list.contains(name) ? set.add(name) : set.delete(name);
1197
+ const next = [...set].join(" ");
1198
+ if (next === (oldEl.getAttribute("class") || "")) return false;
1199
+ next ? oldEl.setAttribute("class", next) : oldEl.removeAttribute("class");
1200
+ return true;
1201
+ }
1202
+ function morphOwnedStyle(oldEl, value, names) {
1203
+ const style = oldEl.style;
1204
+ const saved = names.map(name => [name, style.getPropertyValue(name), style.getPropertyPriority(name)]);
1205
+ const before = oldEl.getAttribute("style");
1206
+ value ? oldEl.setAttribute("style", value) : oldEl.removeAttribute("style");
1207
+ for (const [name, v, priority] of saved) {
1208
+ v ? style.setProperty(name, v, priority) : style.removeProperty(name);
1209
+ }
1210
+ return oldEl.getAttribute("style") !== before;
1211
+ }
1212
+ function applyOwned(oldEl, name, value, owned) {
1213
+ if (owned === null) return undefined;
1214
+ if (owned.attrs.has(name)) return false;
1215
+ if ((name === "class" || name === "style") && owned[name] !== null) {
1216
+ return name === "class" ? morphOwnedClass(oldEl, value, owned.class) : morphOwnedStyle(oldEl, value, owned.style);
1217
+ }
1218
+ return undefined;
1219
+ }
1149
1220
  function morphAttributes(oldEl, newEl, claim) {
1150
1221
  let reclaim = false;
1151
1222
  let changed = false;
1152
1223
  const keepOpen = preservesOpen(oldEl);
1224
+ const owned = ownedPositions(newEl);
1153
1225
  const oldAttrs = oldEl.attributes;
1154
1226
  for (let i = oldAttrs.length - 1; i >= 0; i--) {
1155
1227
  const name = oldAttrs[i].name;
1156
1228
  if (keepOpen && name === "open") continue;
1157
1229
  if (!newEl.hasAttribute(name)) {
1230
+ const handled = applyOwned(oldEl, name, "", owned);
1231
+ if (handled !== undefined) {
1232
+ changed = handled || changed;
1233
+ continue;
1234
+ }
1158
1235
  oldEl.removeAttribute(name);
1159
1236
  changed = true;
1160
1237
  reclaim ||= claimedAttr(name);
@@ -1163,11 +1240,17 @@ function morphAttributes(oldEl, newEl, claim) {
1163
1240
  const newAttrs = newEl.attributes;
1164
1241
  for (let i = 0; i < newAttrs.length; i++) {
1165
1242
  const attr = newAttrs[i];
1166
- if (keepOpen && attr.name === "open") continue;
1167
- if (oldEl.getAttribute(attr.name) !== attr.value) {
1168
- oldEl.setAttribute(attr.name, attr.value);
1243
+ const name = attr.name;
1244
+ if (keepOpen && name === "open") continue;
1245
+ const handled = applyOwned(oldEl, name, attr.value, owned);
1246
+ if (handled !== undefined) {
1247
+ changed = handled || changed;
1248
+ continue;
1249
+ }
1250
+ if (oldEl.getAttribute(name) !== attr.value) {
1251
+ oldEl.setAttribute(name, attr.value);
1169
1252
  changed = true;
1170
- reclaim ||= claimedAttr(attr.name);
1253
+ reclaim ||= claimedAttr(name);
1171
1254
  }
1172
1255
  }
1173
1256
  if (claim && (reclaim || changed && oldEl.matches(CLAIMED_ELEMENTS))) claim(oldEl, true);
@@ -1663,7 +1746,7 @@ function createServerComponentHandler({
1663
1746
  }
1664
1747
  const version = bump(address);
1665
1748
  if (onStream) onStream(address, version, response);
1666
- applyFrameResponse(response, host, {
1749
+ const applied = applyFrameResponse(response, host, {
1667
1750
  as: address,
1668
1751
  version
1669
1752
  }).catch(err => host.apply({
@@ -1674,7 +1757,7 @@ function createServerComponentHandler({
1674
1757
  message: String(err && err.message)
1675
1758
  }
1676
1759
  }));
1677
- return binding;
1760
+ return host.get(address) ? applied.then(() => binding) : binding;
1678
1761
  },
1679
1762
  showing(address, functionId) {
1680
1763
  bindingFor(address, functionId);
@@ -1758,6 +1841,8 @@ function reviveContainerTraces(value) {
1758
1841
  }
1759
1842
 
1760
1843
  const materializeContainerTrace = core.materializeContainerTrace;
1844
+ const createLoadingBoundary = core.createLoadingBoundary;
1845
+ const sharedConfig = core.sharedConfig;
1761
1846
 
1762
1847
  setContainerTraceMaterializer(materializeContainerTrace);
1763
1848
  function asyncArg(value) {
@@ -1792,8 +1877,7 @@ function getFrameHost() {
1792
1877
  applyData: c => tableFor(c.id)?.apply(c),
1793
1878
  resolve: (ref, id) => tableFor(id)?.resolve(ref),
1794
1879
  revive: reviveContainerTraces,
1795
- isContainer: isMaterializedContainer,
1796
- delegate: delegateEvents
1880
+ isContainer: isMaterializedContainer
1797
1881
  });
1798
1882
  }
1799
1883
  return sharedHost;
@@ -1892,6 +1976,122 @@ function slotArgsProxy(args) {
1892
1976
  } : undefined
1893
1977
  });
1894
1978
  }
1979
+ function bindDataOccurrence(fill, args, ctx) {
1980
+ const [consumers, setConsumers] = createSignal(ctx.positions);
1981
+ ctx.onRebind(setConsumers);
1982
+ const output = createMemo(() => {
1983
+ const out = fill(args);
1984
+ const node = typeof Node === "function" && out instanceof Node;
1985
+ return out == null || typeof out !== "object" || node ? {} : out;
1986
+ });
1987
+ const state = new WeakMap();
1988
+ let bound = new Set();
1989
+ createRenderEffect(() => {
1990
+ const out = output();
1991
+ return consumers().map(({
1992
+ element,
1993
+ positions
1994
+ }) => ({
1995
+ element,
1996
+ ...propsFor(element, positions, out)
1997
+ }));
1998
+ }, writes => {
1999
+ const next = new Set();
2000
+ for (const {
2001
+ element,
2002
+ props,
2003
+ handlers
2004
+ } of writes) {
2005
+ next.add(element);
2006
+ write(element, props, handlers);
2007
+ }
2008
+ for (const element of bound) if (!next.has(element)) write(element, {}, {});
2009
+ bound = next;
2010
+ });
2011
+ onCleanup(() => {
2012
+ for (const element of bound) write(element, {}, {});
2013
+ });
2014
+ function write(element, props, handlers) {
2015
+ const st = state.get(element);
2016
+ for (const k in st.prev) if (!(k in props) && k !== "ref") delete st.prev[k];
2017
+ assign(element, props, true, st.prev);
2018
+ st.keys = handlers;
2019
+ for (const name of st.on) {
2020
+ if (!(name in handlers)) {
2021
+ element.removeEventListener(name, st.listener);
2022
+ st.on.delete(name);
2023
+ }
2024
+ }
2025
+ for (const name in handlers) {
2026
+ if (!st.on.has(name)) {
2027
+ element.addEventListener(name, st.listener);
2028
+ st.on.add(name);
2029
+ }
2030
+ }
2031
+ }
2032
+ function propsFor(element, positions, out) {
2033
+ let st = state.get(element);
2034
+ if (!st) {
2035
+ const s = {
2036
+ prev: {},
2037
+ ref: undefined,
2038
+ refId: "",
2039
+ on: new Set(),
2040
+ keys: {},
2041
+ listener(e) {
2042
+ const o = output();
2043
+ const keys = s.keys[e.type];
2044
+ if (keys === undefined) return;
2045
+ for (const k of keys) {
2046
+ const h = o[k];
2047
+ if (Array.isArray(h)) h[0].call(this, h[1], e);else if (typeof h === "function") h.call(this, e);
2048
+ }
2049
+ }
2050
+ };
2051
+ state.set(element, st = s);
2052
+ }
2053
+ const props = {};
2054
+ const handlers = {};
2055
+ let classNames = null;
2056
+ let styleProps = null;
2057
+ let refKeys = null;
2058
+ for (const {
2059
+ pos,
2060
+ key,
2061
+ name
2062
+ } of positions) {
2063
+ if (pos === "class" || pos === "style") {
2064
+ if (name === undefined) props[pos] = out[key];else if (pos === "class") (classNames || (classNames = {}))[name] = !!out[key];else (styleProps || (styleProps = {}))[name] = out[key];
2065
+ } else if (pos === "ref") {
2066
+ (refKeys || (refKeys = [])).push(key);
2067
+ } else if (pos.startsWith("on:")) {
2068
+ const event = pos.slice(3);
2069
+ (handlers[event] || (handlers[event] = [])).push(key);
2070
+ } else props[pos] = out[key];
2071
+ }
2072
+ if (classNames !== null && !("class" in props)) props.class = classNames;
2073
+ if (styleProps !== null && !("style" in props)) props.style = styleProps;
2074
+ if (refKeys !== null) {
2075
+ const id = refKeys.join(",");
2076
+ if (st.refId !== id) {
2077
+ const keys = refKeys;
2078
+ st.refId = id;
2079
+ st.ref = el => {
2080
+ const o = output();
2081
+ for (const k of keys) {
2082
+ const r = o[k];
2083
+ typeof r === "function" && r(el);
2084
+ }
2085
+ };
2086
+ }
2087
+ props.ref = st.ref;
2088
+ }
2089
+ return {
2090
+ props,
2091
+ handlers
2092
+ };
2093
+ }
2094
+ }
1895
2095
  function isReactiveContent(value) {
1896
2096
  if (typeof value === "function") return true;
1897
2097
  if (Array.isArray(value)) {
@@ -1917,6 +2117,23 @@ function slotsFor(props) {
1917
2117
  fillScopes.delete(key);
1918
2118
  prevFill.dispose();
1919
2119
  }
2120
+ if (ctx && ctx.positions) {
2121
+ const fill = props[prop];
2122
+ if (typeof fill !== "function") {
2123
+ return undefined;
2124
+ }
2125
+ const owner = createOwner();
2126
+ fillScopes.set(key, owner);
2127
+ ctx.onCleanup(() => {
2128
+ if (fillScopes.get(key) === owner) fillScopes.delete(key);
2129
+ owner.dispose();
2130
+ });
2131
+ runWithOwner(owner, () => {
2132
+ const args = ctx.onUpdate ? liveSlotProps(slotProps, ctx) : slotArgsProxy(() => slotProps);
2133
+ bindDataOccurrence(fill, args, ctx);
2134
+ });
2135
+ return undefined;
2136
+ }
1920
2137
  const fillOwner = streamInvoke ? createOwner() : null;
1921
2138
  if (fillOwner && key !== undefined && ctx) {
1922
2139
  fillScopes.set(key, fillOwner);
@@ -1997,7 +2214,6 @@ function boundaryComponent(host, fnId) {
1997
2214
  host,
1998
2215
  id,
1999
2216
  slots: slotsFor(props),
2000
- props,
2001
2217
  ownerScope: boundaryScope(owner),
2002
2218
  reveal: revealSeam(owner),
2003
2219
  onApply: () => {
@@ -2201,7 +2417,6 @@ function adoptBoundary(host, id, el, props, binding) {
2201
2417
  host,
2202
2418
  id: address,
2203
2419
  slots: slotsFor(props),
2204
- props,
2205
2420
  ownerScope: boundaryScope(owner),
2206
2421
  reveal: revealSeam(owner),
2207
2422
  onApply: () => {