@solidjs/web 2.0.0-rc.11 → 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,7 +1,7 @@
1
- import { getOwner, onCleanup, createMemo, runWithOwner, createSignal, createRenderEffect, createLoadingBoundary, createOwner, sharedConfig } from 'solid-js';
2
- import { delegateEvents, insert } from '@solidjs/web';
1
+ import { getOwner, onCleanup, createMemo, runWithOwner, createSignal, createRenderEffect, createOwner } from 'solid-js';
2
+ import { insert, assign } from '@solidjs/web';
3
3
  import { LIVE_WIRE, isEventStream, ChunkReader, frameAddress, SINGLE_FLIGHT_HEADER, deserializeStream, getServerFunctionsCodec, createChunk, deliverFlightData, ERROR_HEADER, hasFlightMetadata, configureServerFunctionsClient } from '@solidjs/web/server-functions/client';
4
- import { materializeContainerTrace } from 'solid-js/internal';
4
+ import { createLoadingBoundary, sharedConfig, materializeContainerTrace } from 'solid-js/internal';
5
5
 
6
6
  const ELEMENT_NODE = 1;
7
7
  const TEXT_NODE = 3;
@@ -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);
@@ -1576,7 +1659,7 @@ function createServerComponentHandler({
1576
1659
  }
1577
1660
  const version = bump(address);
1578
1661
  if (onStream) onStream(address, version, response);
1579
- applyFrameResponse(response, host, {
1662
+ const applied = applyFrameResponse(response, host, {
1580
1663
  as: address,
1581
1664
  version
1582
1665
  }).catch(err => host.apply({
@@ -1587,7 +1670,7 @@ function createServerComponentHandler({
1587
1670
  message: String(err && err.message)
1588
1671
  }
1589
1672
  }));
1590
- return binding;
1673
+ return host.get(address) ? applied.then(() => binding) : binding;
1591
1674
  },
1592
1675
  showing(address, functionId) {
1593
1676
  bindingFor(address, functionId);
@@ -1703,8 +1786,7 @@ function getFrameHost() {
1703
1786
  applyData: c => tableFor(c.id)?.apply(c),
1704
1787
  resolve: (ref, id) => tableFor(id)?.resolve(ref),
1705
1788
  revive: reviveContainerTraces,
1706
- isContainer: isMaterializedContainer,
1707
- delegate: delegateEvents
1789
+ isContainer: isMaterializedContainer
1708
1790
  });
1709
1791
  }
1710
1792
  return sharedHost;
@@ -1803,6 +1885,122 @@ function slotArgsProxy(args) {
1803
1885
  } : undefined
1804
1886
  });
1805
1887
  }
1888
+ function bindDataOccurrence(fill, args, ctx) {
1889
+ const [consumers, setConsumers] = createSignal(ctx.positions);
1890
+ ctx.onRebind(setConsumers);
1891
+ const output = createMemo(() => {
1892
+ const out = fill(args);
1893
+ const node = typeof Node === "function" && out instanceof Node;
1894
+ return out == null || typeof out !== "object" || node ? {} : out;
1895
+ });
1896
+ const state = new WeakMap();
1897
+ let bound = new Set();
1898
+ createRenderEffect(() => {
1899
+ const out = output();
1900
+ return consumers().map(({
1901
+ element,
1902
+ positions
1903
+ }) => ({
1904
+ element,
1905
+ ...propsFor(element, positions, out)
1906
+ }));
1907
+ }, writes => {
1908
+ const next = new Set();
1909
+ for (const {
1910
+ element,
1911
+ props,
1912
+ handlers
1913
+ } of writes) {
1914
+ next.add(element);
1915
+ write(element, props, handlers);
1916
+ }
1917
+ for (const element of bound) if (!next.has(element)) write(element, {}, {});
1918
+ bound = next;
1919
+ });
1920
+ onCleanup(() => {
1921
+ for (const element of bound) write(element, {}, {});
1922
+ });
1923
+ function write(element, props, handlers) {
1924
+ const st = state.get(element);
1925
+ for (const k in st.prev) if (!(k in props) && k !== "ref") delete st.prev[k];
1926
+ assign(element, props, true, st.prev);
1927
+ st.keys = handlers;
1928
+ for (const name of st.on) {
1929
+ if (!(name in handlers)) {
1930
+ element.removeEventListener(name, st.listener);
1931
+ st.on.delete(name);
1932
+ }
1933
+ }
1934
+ for (const name in handlers) {
1935
+ if (!st.on.has(name)) {
1936
+ element.addEventListener(name, st.listener);
1937
+ st.on.add(name);
1938
+ }
1939
+ }
1940
+ }
1941
+ function propsFor(element, positions, out) {
1942
+ let st = state.get(element);
1943
+ if (!st) {
1944
+ const s = {
1945
+ prev: {},
1946
+ ref: undefined,
1947
+ refId: "",
1948
+ on: new Set(),
1949
+ keys: {},
1950
+ listener(e) {
1951
+ const o = output();
1952
+ const keys = s.keys[e.type];
1953
+ if (keys === undefined) return;
1954
+ for (const k of keys) {
1955
+ const h = o[k];
1956
+ if (Array.isArray(h)) h[0].call(this, h[1], e);else if (typeof h === "function") h.call(this, e);
1957
+ }
1958
+ }
1959
+ };
1960
+ state.set(element, st = s);
1961
+ }
1962
+ const props = {};
1963
+ const handlers = {};
1964
+ let classNames = null;
1965
+ let styleProps = null;
1966
+ let refKeys = null;
1967
+ for (const {
1968
+ pos,
1969
+ key,
1970
+ name
1971
+ } of positions) {
1972
+ if (pos === "class" || pos === "style") {
1973
+ if (name === undefined) props[pos] = out[key];else if (pos === "class") (classNames || (classNames = {}))[name] = !!out[key];else (styleProps || (styleProps = {}))[name] = out[key];
1974
+ } else if (pos === "ref") {
1975
+ (refKeys || (refKeys = [])).push(key);
1976
+ } else if (pos.startsWith("on:")) {
1977
+ const event = pos.slice(3);
1978
+ (handlers[event] || (handlers[event] = [])).push(key);
1979
+ } else props[pos] = out[key];
1980
+ }
1981
+ if (classNames !== null && !("class" in props)) props.class = classNames;
1982
+ if (styleProps !== null && !("style" in props)) props.style = styleProps;
1983
+ if (refKeys !== null) {
1984
+ const id = refKeys.join(",");
1985
+ if (st.refId !== id) {
1986
+ const keys = refKeys;
1987
+ st.refId = id;
1988
+ st.ref = el => {
1989
+ const o = output();
1990
+ for (const k of keys) {
1991
+ const r = o[k];
1992
+ typeof r === "function" && r(el);
1993
+ }
1994
+ };
1995
+ }
1996
+ props.ref = st.ref;
1997
+ }
1998
+ return {
1999
+ props,
2000
+ handlers
2001
+ };
2002
+ }
2003
+ }
1806
2004
  function isReactiveContent(value) {
1807
2005
  if (typeof value === "function") return true;
1808
2006
  if (Array.isArray(value)) {
@@ -1828,6 +2026,23 @@ function slotsFor(props) {
1828
2026
  fillScopes.delete(key);
1829
2027
  prevFill.dispose();
1830
2028
  }
2029
+ if (ctx && ctx.positions) {
2030
+ const fill = props[prop];
2031
+ if (typeof fill !== "function") {
2032
+ return undefined;
2033
+ }
2034
+ const owner = createOwner();
2035
+ fillScopes.set(key, owner);
2036
+ ctx.onCleanup(() => {
2037
+ if (fillScopes.get(key) === owner) fillScopes.delete(key);
2038
+ owner.dispose();
2039
+ });
2040
+ runWithOwner(owner, () => {
2041
+ const args = ctx.onUpdate ? liveSlotProps(slotProps, ctx) : slotArgsProxy(() => slotProps);
2042
+ bindDataOccurrence(fill, args, ctx);
2043
+ });
2044
+ return undefined;
2045
+ }
1831
2046
  const fillOwner = streamInvoke ? createOwner() : null;
1832
2047
  if (fillOwner && key !== undefined && ctx) {
1833
2048
  fillScopes.set(key, fillOwner);
@@ -1908,7 +2123,6 @@ function boundaryComponent(host, fnId) {
1908
2123
  host,
1909
2124
  id,
1910
2125
  slots: slotsFor(props),
1911
- props,
1912
2126
  ownerScope: boundaryScope(owner),
1913
2127
  reveal: revealSeam(owner),
1914
2128
  onApply: () => {
@@ -2112,7 +2326,6 @@ function adoptBoundary(host, id, el, props, binding) {
2112
2326
  host,
2113
2327
  id: address,
2114
2328
  slots: slotsFor(props),
2115
- props,
2116
2329
  ownerScope: boundaryScope(owner),
2117
2330
  reveal: revealSeam(owner),
2118
2331
  onApply: () => {