@solidjs/web 2.0.0-rc.21 → 2.0.0-rc.23

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.
@@ -20,7 +20,15 @@ function rewriteTree(value, visit, withPath) {
20
20
  } catch (err) {
21
21
  if (err !== CYCLE) throw err;
22
22
  }
23
- return clone(value, visit, path, state.memo || (state.memo = new Map()));
23
+ const memo = state.memo || (state.memo = new Map());
24
+ const marks = {
25
+ at: new Map(),
26
+ stack: [],
27
+ changed: new Set(),
28
+ next: 0
29
+ };
30
+ mark(value, visit, path, memo, marks);
31
+ return clone(value, memo, marks.changed);
24
32
  }
25
33
  function shape(value) {
26
34
  return Array.isArray(value) ? 1 : Object.getPrototypeOf(value) === Object.prototype ? 2 : 0;
@@ -68,28 +76,73 @@ function cow(value, visit, path, depth, state) {
68
76
  if (ancestors !== undefined) ancestors.delete(value);
69
77
  return out;
70
78
  }
71
- function clone(value, visit, path, memo) {
72
- if (memo.has(value)) return memo.get(value);
79
+ function mark(value, visit, path, memo, m) {
80
+ const seen = m.at.get(value);
81
+ if (seen !== undefined) return seen;
82
+ if (memo.has(value)) return -1;
73
83
  const r = visit(value, path);
74
84
  if (r !== DESCEND) {
75
85
  memo.set(value, r);
76
- return r;
86
+ return -1;
77
87
  }
78
88
  const s = shape(value);
79
- if (s === 0) return value;
80
- const out = s === 1 ? value.slice() : {
89
+ if (s === 0) return -1;
90
+ const index = m.next++;
91
+ let low = index;
92
+ let changed = false;
93
+ let open = false;
94
+ const keys = s === 1 ? value : Object.keys(value);
95
+ for (let i = 0; i < keys.length; i++) {
96
+ const k = s === 1 ? i : keys[i];
97
+ const c = value[k];
98
+ if (c === null || typeof c !== "object") continue;
99
+ if (!open) {
100
+ open = true;
101
+ m.at.set(value, index);
102
+ m.stack.push(value);
103
+ }
104
+ const l = mark(c, visit, path === undefined ? undefined : s === 1 ? `${path}[${k}]` : `${path}.${k}`, memo, m);
105
+ if (l >= 0 && l < low) low = l;
106
+ if (memo.has(c) && memo.get(c) !== c || l === Infinity && m.changed.has(c)) changed = true;
107
+ }
108
+ if (!open) return -1;
109
+ if (low === index) {
110
+ m.at.set(value, Infinity);
111
+ if (m.stack[m.stack.length - 1] === value) {
112
+ m.stack.pop();
113
+ if (changed) m.changed.add(value);
114
+ return Infinity;
115
+ }
116
+ const members = m.stack.splice(m.stack.lastIndexOf(value));
117
+ if (!changed) for (const n of members) if (m.changed.has(n)) {
118
+ changed = true;
119
+ break;
120
+ }
121
+ for (const n of members) {
122
+ m.at.set(n, Infinity);
123
+ if (changed) m.changed.add(n);
124
+ }
125
+ return Infinity;
126
+ }
127
+ if (changed) m.changed.add(value);
128
+ return low;
129
+ }
130
+ function clone(value, memo, changed) {
131
+ if (memo.has(value)) return memo.get(value);
132
+ if (!changed.has(value)) return value;
133
+ const out = Array.isArray(value) ? value.slice() : {
81
134
  ...value
82
135
  };
83
136
  memo.set(value, out);
84
- if (s === 1) {
137
+ if (Array.isArray(value)) {
85
138
  for (let i = 0; i < value.length; i++) {
86
139
  const c = value[i];
87
- if (c !== null && typeof c === "object") out[i] = clone(c, visit, path === undefined ? undefined : `${path}[${i}]`, memo);
140
+ if (c !== null && typeof c === "object") out[i] = clone(c, memo, changed);
88
141
  }
89
142
  } else {
90
143
  for (const k of Object.keys(value)) {
91
144
  const c = value[k];
92
- if (c !== null && typeof c === "object") out[k] = clone(c, visit, path === undefined ? undefined : `${path}.${k}`, memo);
145
+ if (c !== null && typeof c === "object") out[k] = clone(c, memo, changed);
93
146
  }
94
147
  }
95
148
  return out;
@@ -255,7 +308,7 @@ function createKeyedSerializer(serialize, onError, onDone) {
255
308
  stream = serialize(key, value, {
256
309
  onError: onError && (err => {
257
310
  failed = true;
258
- onError(err);
311
+ onError(err, key);
259
312
  if (cancel) {
260
313
  cancel();
261
314
  settle();
@@ -1017,10 +1070,9 @@ function frameStream(makeCode, options) {
1017
1070
  };
1018
1071
  }
1019
1072
  function slotRange(occurrence) {
1020
- return {
1021
- t: `<!--slot:${occurrence}:start--><!--slot:${occurrence}:end-->`,
1073
+ return Object.assign(markup(`<!--slot:${occurrence}:start--><!--slot:${occurrence}:end-->`), {
1022
1074
  $slot: true
1023
- };
1075
+ });
1024
1076
  }
1025
1077
  function argBorderForm(value, needs) {
1026
1078
  return toBorderForm(noteTraces(value, needs));
@@ -1157,6 +1209,16 @@ function suppressedFill(render) {
1157
1209
  live.suppressed--;
1158
1210
  }
1159
1211
  }
1212
+ const SSR_NODE = Symbol.for("solid.ssrNode");
1213
+ const markup = (t, h, p) => h ? {
1214
+ t,
1215
+ h,
1216
+ p,
1217
+ $: SSR_NODE
1218
+ } : {
1219
+ t,
1220
+ $: SSR_NODE
1221
+ };
1160
1222
  let parked = null;
1161
1223
  let parkedIds = 0;
1162
1224
  const PARKED = /<!--sc-n:(\d+)-->/;
@@ -1167,9 +1229,7 @@ function park(render) {
1167
1229
  render,
1168
1230
  out: undefined
1169
1231
  });
1170
- return {
1171
- t: `<!--sc-n:${id}-->`
1172
- };
1232
+ return markup(`<!--sc-n:${id}-->`);
1173
1233
  }
1174
1234
  const runParked = (entry, owner) => entry.out || (entry.out = entry.render(owner));
1175
1235
  function placeParked(node, nested, owner) {
@@ -1187,22 +1247,14 @@ function expandParked(node, nested, owner) {
1187
1247
  if (!node.h) return splitParked(node.t, nested, owner) || node;
1188
1248
  const out = [];
1189
1249
  node.t.forEach((t, i) => {
1190
- out.push(splitParked(t, nested, owner) || {
1191
- t
1192
- });
1193
- if (i < node.h.length) out.push({
1194
- t: ["", ""],
1195
- h: [node.h[i]],
1196
- p: [node.p[i]]
1197
- });
1250
+ out.push(splitParked(t, nested, owner) || markup(t));
1251
+ if (i < node.h.length) out.push(markup(["", ""], [node.h[i]], [node.p[i]]));
1198
1252
  });
1199
1253
  return out;
1200
1254
  }
1201
1255
  function splitParked(t, nested, owner) {
1202
1256
  const parts = typeof t === "string" ? t.split(PARKED) : [t];
1203
- return parts.length > 1 ? parts.map((part, i) => i & 1 ? runParked(nested.get(+part), owner) : {
1204
- t: part
1205
- }) : undefined;
1257
+ return parts.length > 1 ? parts.map((part, i) => i & 1 ? runParked(nested.get(+part), owner) : markup(part)) : undefined;
1206
1258
  }
1207
1259
  function createDocumentSlotProps(clientProps, frameId) {
1208
1260
  const counts = Object.create(null);
@@ -1235,11 +1287,7 @@ function createDocumentSlotProps(clientProps, frameId) {
1235
1287
  const getters = new Map();
1236
1288
  const repeats = new Map();
1237
1289
  const range = (occurrence, content, tail) => {
1238
- const r = [{
1239
- t: `<!--slot:${occurrence}:start-->`
1240
- }, content, tail, {
1241
- t: `<!--slot:${occurrence}:end-->`
1242
- }];
1290
+ const r = [markup(`<!--slot:${occurrence}:start-->`), content, tail, markup(`<!--slot:${occurrence}:end-->`)];
1243
1291
  r.$slot = true;
1244
1292
  return r;
1245
1293
  };
@@ -1360,11 +1408,7 @@ function createDocumentSlotProps(clientProps, frameId) {
1360
1408
  resolved[key] = () => {
1361
1409
  if (region.locked) return [];
1362
1410
  region.used = true;
1363
- return [{
1364
- t: frameElementOpen(childId)
1365
- }, region.nested && region.nested.size ? placeParked(value, region.nested, getOwner()) : value, {
1366
- t: FRAME_ELEMENT_CLOSE
1367
- }];
1411
+ return [markup(frameElementOpen(childId)), region.nested && region.nested.size ? placeParked(value, region.nested, getOwner()) : value, markup(FRAME_ELEMENT_CLOSE)];
1368
1412
  };
1369
1413
  } else if (ssrAsyncValue && isAsyncValue(value)) {
1370
1414
  let readable = value;
@@ -1659,9 +1703,7 @@ function frameTransformDirectResult(value, {
1659
1703
  const address = frameAddress(id, args);
1660
1704
  const wrapped = props => {
1661
1705
  const siteId = documentSiteId(id);
1662
- return [{
1663
- t: frameElementOpen(siteId, address.slice(id.length + 1))
1664
- },
1706
+ return [markup(frameElementOpen(siteId, address.slice(id.length + 1))),
1665
1707
  serverOwned(() => {
1666
1708
  const page = sharedConfig.context;
1667
1709
  armDocumentLiveHoles(page);
@@ -1677,9 +1719,7 @@ function frameTransformDirectResult(value, {
1677
1719
  } finally {
1678
1720
  sharedConfig.context = page;
1679
1721
  }
1680
- }), {
1681
- t: FRAME_ELEMENT_CLOSE
1682
- }];
1722
+ }), markup(FRAME_ELEMENT_CLOSE)];
1683
1723
  };
1684
1724
  wrapped[SERVER_COMPONENT] = id;
1685
1725
  wrapped[SERVER_COMPONENT_SOURCE] = component;
@@ -1822,10 +1862,9 @@ function createSlotProps(sink, frame) {
1822
1862
  if (repeat) return repeat;
1823
1863
  if (sweeping && !live.scope) {
1824
1864
  live.gateHit = true;
1825
- return {
1826
- t: "",
1865
+ return Object.assign(markup(""), {
1827
1866
  $slot: true
1828
- };
1867
+ });
1829
1868
  }
1830
1869
  const raw = callArgs[0];
1831
1870
  let occurrence = keyedId(prop, raw);
@@ -2227,25 +2266,23 @@ function snapshot(shared, have) {
2227
2266
  });
2228
2267
  open.r[k] = record;
2229
2268
  };
2230
- if (!conditional) {
2231
- for (const {
2269
+ const containers = [];
2270
+ const spliced = new Set();
2271
+ for (const entry of shared.records.values()) {
2272
+ const {
2232
2273
  id,
2233
- version,
2234
2274
  k,
2235
2275
  record
2236
- } of shared.records.values()) put(id, version, k, record);
2237
- return out;
2238
- }
2239
- const containers = [];
2240
- for (const e of shared.records.values()) if (e.id === shared.id && (e.k === "" || /^seg:[^:]+$/.test(e.k)) && e.record) containers.push({
2241
- e,
2242
- value: e.record.value
2243
- });
2244
- for (const {
2245
- k,
2246
- record
2247
- } of shared.records.values()) {
2248
- if (!k.startsWith("hole:lh:") || k.endsWith(":error") || !record || record.value == null) continue;
2276
+ } = entry;
2277
+ if (id !== shared.id || !record) continue;
2278
+ if (k === "" || /^seg:[^:]+$/.test(k)) {
2279
+ if (typeof record.value === "string") containers.push({
2280
+ e: entry,
2281
+ value: record.value
2282
+ });
2283
+ continue;
2284
+ }
2285
+ if (!k.startsWith("hole:lh:") || k.endsWith(":error") || record.value == null) continue;
2249
2286
  const n = k.slice(8);
2250
2287
  const startMark = `<!--lh:${n}-->`;
2251
2288
  const endMark = `<!--lh:/${n}-->`;
@@ -2255,9 +2292,32 @@ function snapshot(shared, have) {
2255
2292
  const end = c.value.indexOf(endMark, start);
2256
2293
  if (end < 0) continue;
2257
2294
  c.value = c.value.slice(0, start + startMark.length) + record.value + c.value.slice(end);
2295
+ spliced.add(entry);
2258
2296
  break;
2259
2297
  }
2260
2298
  }
2299
+ if (!conditional) {
2300
+ for (const e of shared.records.values()) {
2301
+ const {
2302
+ id,
2303
+ version,
2304
+ k,
2305
+ record
2306
+ } = e;
2307
+ if (spliced.has(e)) continue;
2308
+ const c = containers.find(c => c.e === e);
2309
+ if (c && c.value !== record.value) {
2310
+ const holes = {};
2311
+ if (record.holes) for (const key in record.holes) if (key.startsWith("lha:")) holes[key] = record.holes[key];
2312
+ put(id, version, k, withHoles({
2313
+ ...record,
2314
+ value: c.value,
2315
+ digest: k ? textDigest(c.value) : record.digest
2316
+ }, holeDigests(c.value, null, holes)));
2317
+ } else put(id, version, k, record);
2318
+ }
2319
+ return out;
2320
+ }
2261
2321
  for (const e of shared.records.values()) {
2262
2322
  const {
2263
2323
  id,
@@ -20,7 +20,15 @@ function rewriteTree(value, visit, withPath) {
20
20
  } catch (err) {
21
21
  if (err !== CYCLE) throw err;
22
22
  }
23
- return clone(value, visit, path, state.memo || (state.memo = new Map()));
23
+ const memo = state.memo || (state.memo = new Map());
24
+ const marks = {
25
+ at: new Map(),
26
+ stack: [],
27
+ changed: new Set(),
28
+ next: 0
29
+ };
30
+ mark(value, visit, path, memo, marks);
31
+ return clone(value, memo, marks.changed);
24
32
  }
25
33
  function shape(value) {
26
34
  return Array.isArray(value) ? 1 : Object.getPrototypeOf(value) === Object.prototype ? 2 : 0;
@@ -68,28 +76,73 @@ function cow(value, visit, path, depth, state) {
68
76
  if (ancestors !== undefined) ancestors.delete(value);
69
77
  return out;
70
78
  }
71
- function clone(value, visit, path, memo) {
72
- if (memo.has(value)) return memo.get(value);
79
+ function mark(value, visit, path, memo, m) {
80
+ const seen = m.at.get(value);
81
+ if (seen !== undefined) return seen;
82
+ if (memo.has(value)) return -1;
73
83
  const r = visit(value, path);
74
84
  if (r !== DESCEND) {
75
85
  memo.set(value, r);
76
- return r;
86
+ return -1;
77
87
  }
78
88
  const s = shape(value);
79
- if (s === 0) return value;
80
- const out = s === 1 ? value.slice() : {
89
+ if (s === 0) return -1;
90
+ const index = m.next++;
91
+ let low = index;
92
+ let changed = false;
93
+ let open = false;
94
+ const keys = s === 1 ? value : Object.keys(value);
95
+ for (let i = 0; i < keys.length; i++) {
96
+ const k = s === 1 ? i : keys[i];
97
+ const c = value[k];
98
+ if (c === null || typeof c !== "object") continue;
99
+ if (!open) {
100
+ open = true;
101
+ m.at.set(value, index);
102
+ m.stack.push(value);
103
+ }
104
+ const l = mark(c, visit, path === undefined ? undefined : s === 1 ? `${path}[${k}]` : `${path}.${k}`, memo, m);
105
+ if (l >= 0 && l < low) low = l;
106
+ if (memo.has(c) && memo.get(c) !== c || l === Infinity && m.changed.has(c)) changed = true;
107
+ }
108
+ if (!open) return -1;
109
+ if (low === index) {
110
+ m.at.set(value, Infinity);
111
+ if (m.stack[m.stack.length - 1] === value) {
112
+ m.stack.pop();
113
+ if (changed) m.changed.add(value);
114
+ return Infinity;
115
+ }
116
+ const members = m.stack.splice(m.stack.lastIndexOf(value));
117
+ if (!changed) for (const n of members) if (m.changed.has(n)) {
118
+ changed = true;
119
+ break;
120
+ }
121
+ for (const n of members) {
122
+ m.at.set(n, Infinity);
123
+ if (changed) m.changed.add(n);
124
+ }
125
+ return Infinity;
126
+ }
127
+ if (changed) m.changed.add(value);
128
+ return low;
129
+ }
130
+ function clone(value, memo, changed) {
131
+ if (memo.has(value)) return memo.get(value);
132
+ if (!changed.has(value)) return value;
133
+ const out = Array.isArray(value) ? value.slice() : {
81
134
  ...value
82
135
  };
83
136
  memo.set(value, out);
84
- if (s === 1) {
137
+ if (Array.isArray(value)) {
85
138
  for (let i = 0; i < value.length; i++) {
86
139
  const c = value[i];
87
- if (c !== null && typeof c === "object") out[i] = clone(c, visit, path === undefined ? undefined : `${path}[${i}]`, memo);
140
+ if (c !== null && typeof c === "object") out[i] = clone(c, memo, changed);
88
141
  }
89
142
  } else {
90
143
  for (const k of Object.keys(value)) {
91
144
  const c = value[k];
92
- if (c !== null && typeof c === "object") out[k] = clone(c, visit, path === undefined ? undefined : `${path}.${k}`, memo);
145
+ if (c !== null && typeof c === "object") out[k] = clone(c, memo, changed);
93
146
  }
94
147
  }
95
148
  return out;
@@ -255,7 +308,7 @@ function createKeyedSerializer(serialize, onError, onDone) {
255
308
  stream = serialize(key, value, {
256
309
  onError: onError && (err => {
257
310
  failed = true;
258
- onError(err);
311
+ onError(err, key);
259
312
  if (cancel) {
260
313
  cancel();
261
314
  settle();
@@ -1016,10 +1069,9 @@ function frameStream(makeCode, options) {
1016
1069
  };
1017
1070
  }
1018
1071
  function slotRange(occurrence) {
1019
- return {
1020
- t: `<!--slot:${occurrence}:start--><!--slot:${occurrence}:end-->`,
1072
+ return Object.assign(markup(`<!--slot:${occurrence}:start--><!--slot:${occurrence}:end-->`), {
1021
1073
  $slot: true
1022
- };
1074
+ });
1023
1075
  }
1024
1076
  function argBorderForm(value, needs) {
1025
1077
  return toBorderForm(noteTraces(value, needs));
@@ -1156,6 +1208,16 @@ function suppressedFill(render) {
1156
1208
  live.suppressed--;
1157
1209
  }
1158
1210
  }
1211
+ const SSR_NODE = Symbol.for("solid.ssrNode");
1212
+ const markup = (t, h, p) => h ? {
1213
+ t,
1214
+ h,
1215
+ p,
1216
+ $: SSR_NODE
1217
+ } : {
1218
+ t,
1219
+ $: SSR_NODE
1220
+ };
1159
1221
  let parked = null;
1160
1222
  let parkedIds = 0;
1161
1223
  const PARKED = /<!--sc-n:(\d+)-->/;
@@ -1166,9 +1228,7 @@ function park(render) {
1166
1228
  render,
1167
1229
  out: undefined
1168
1230
  });
1169
- return {
1170
- t: `<!--sc-n:${id}-->`
1171
- };
1231
+ return markup(`<!--sc-n:${id}-->`);
1172
1232
  }
1173
1233
  const runParked = (entry, owner) => entry.out || (entry.out = entry.render(owner));
1174
1234
  function placeParked(node, nested, owner) {
@@ -1186,22 +1246,14 @@ function expandParked(node, nested, owner) {
1186
1246
  if (!node.h) return splitParked(node.t, nested, owner) || node;
1187
1247
  const out = [];
1188
1248
  node.t.forEach((t, i) => {
1189
- out.push(splitParked(t, nested, owner) || {
1190
- t
1191
- });
1192
- if (i < node.h.length) out.push({
1193
- t: ["", ""],
1194
- h: [node.h[i]],
1195
- p: [node.p[i]]
1196
- });
1249
+ out.push(splitParked(t, nested, owner) || markup(t));
1250
+ if (i < node.h.length) out.push(markup(["", ""], [node.h[i]], [node.p[i]]));
1197
1251
  });
1198
1252
  return out;
1199
1253
  }
1200
1254
  function splitParked(t, nested, owner) {
1201
1255
  const parts = typeof t === "string" ? t.split(PARKED) : [t];
1202
- return parts.length > 1 ? parts.map((part, i) => i & 1 ? runParked(nested.get(+part), owner) : {
1203
- t: part
1204
- }) : undefined;
1256
+ return parts.length > 1 ? parts.map((part, i) => i & 1 ? runParked(nested.get(+part), owner) : markup(part)) : undefined;
1205
1257
  }
1206
1258
  function createDocumentSlotProps(clientProps, frameId) {
1207
1259
  const counts = Object.create(null);
@@ -1234,11 +1286,7 @@ function createDocumentSlotProps(clientProps, frameId) {
1234
1286
  const getters = new Map();
1235
1287
  const repeats = new Map();
1236
1288
  const range = (occurrence, content, tail) => {
1237
- const r = [{
1238
- t: `<!--slot:${occurrence}:start-->`
1239
- }, content, tail, {
1240
- t: `<!--slot:${occurrence}:end-->`
1241
- }];
1289
+ const r = [markup(`<!--slot:${occurrence}:start-->`), content, tail, markup(`<!--slot:${occurrence}:end-->`)];
1242
1290
  r.$slot = true;
1243
1291
  return r;
1244
1292
  };
@@ -1359,11 +1407,7 @@ function createDocumentSlotProps(clientProps, frameId) {
1359
1407
  resolved[key] = () => {
1360
1408
  if (region.locked) return [];
1361
1409
  region.used = true;
1362
- return [{
1363
- t: frameElementOpen(childId)
1364
- }, region.nested && region.nested.size ? placeParked(value, region.nested, getOwner()) : value, {
1365
- t: FRAME_ELEMENT_CLOSE
1366
- }];
1410
+ return [markup(frameElementOpen(childId)), region.nested && region.nested.size ? placeParked(value, region.nested, getOwner()) : value, markup(FRAME_ELEMENT_CLOSE)];
1367
1411
  };
1368
1412
  } else if (ssrAsyncValue && isAsyncValue(value)) {
1369
1413
  let readable = value;
@@ -1658,9 +1702,7 @@ function frameTransformDirectResult(value, {
1658
1702
  const address = frameAddress(id, args);
1659
1703
  const wrapped = props => {
1660
1704
  const siteId = documentSiteId(id);
1661
- return [{
1662
- t: frameElementOpen(siteId, address.slice(id.length + 1))
1663
- },
1705
+ return [markup(frameElementOpen(siteId, address.slice(id.length + 1))),
1664
1706
  serverOwned(() => {
1665
1707
  const page = sharedConfig.context;
1666
1708
  armDocumentLiveHoles(page);
@@ -1676,9 +1718,7 @@ function frameTransformDirectResult(value, {
1676
1718
  } finally {
1677
1719
  sharedConfig.context = page;
1678
1720
  }
1679
- }), {
1680
- t: FRAME_ELEMENT_CLOSE
1681
- }];
1721
+ }), markup(FRAME_ELEMENT_CLOSE)];
1682
1722
  };
1683
1723
  wrapped[SERVER_COMPONENT] = id;
1684
1724
  wrapped[SERVER_COMPONENT_SOURCE] = component;
@@ -1821,10 +1861,9 @@ function createSlotProps(sink, frame) {
1821
1861
  if (repeat) return repeat;
1822
1862
  if (sweeping && !live.scope) {
1823
1863
  live.gateHit = true;
1824
- return {
1825
- t: "",
1864
+ return Object.assign(markup(""), {
1826
1865
  $slot: true
1827
- };
1866
+ });
1828
1867
  }
1829
1868
  const raw = callArgs[0];
1830
1869
  let occurrence = keyedId(prop, raw);
@@ -2225,25 +2264,23 @@ function snapshot(shared, have) {
2225
2264
  });
2226
2265
  open.r[k] = record;
2227
2266
  };
2228
- if (!conditional) {
2229
- for (const {
2267
+ const containers = [];
2268
+ const spliced = new Set();
2269
+ for (const entry of shared.records.values()) {
2270
+ const {
2230
2271
  id,
2231
- version,
2232
2272
  k,
2233
2273
  record
2234
- } of shared.records.values()) put(id, version, k, record);
2235
- return out;
2236
- }
2237
- const containers = [];
2238
- for (const e of shared.records.values()) if (e.id === shared.id && (e.k === "" || /^seg:[^:]+$/.test(e.k)) && e.record) containers.push({
2239
- e,
2240
- value: e.record.value
2241
- });
2242
- for (const {
2243
- k,
2244
- record
2245
- } of shared.records.values()) {
2246
- if (!k.startsWith("hole:lh:") || k.endsWith(":error") || !record || record.value == null) continue;
2274
+ } = entry;
2275
+ if (id !== shared.id || !record) continue;
2276
+ if (k === "" || /^seg:[^:]+$/.test(k)) {
2277
+ if (typeof record.value === "string") containers.push({
2278
+ e: entry,
2279
+ value: record.value
2280
+ });
2281
+ continue;
2282
+ }
2283
+ if (!k.startsWith("hole:lh:") || k.endsWith(":error") || record.value == null) continue;
2247
2284
  const n = k.slice(8);
2248
2285
  const startMark = `<!--lh:${n}-->`;
2249
2286
  const endMark = `<!--lh:/${n}-->`;
@@ -2253,9 +2290,32 @@ function snapshot(shared, have) {
2253
2290
  const end = c.value.indexOf(endMark, start);
2254
2291
  if (end < 0) continue;
2255
2292
  c.value = c.value.slice(0, start + startMark.length) + record.value + c.value.slice(end);
2293
+ spliced.add(entry);
2256
2294
  break;
2257
2295
  }
2258
2296
  }
2297
+ if (!conditional) {
2298
+ for (const e of shared.records.values()) {
2299
+ const {
2300
+ id,
2301
+ version,
2302
+ k,
2303
+ record
2304
+ } = e;
2305
+ if (spliced.has(e)) continue;
2306
+ const c = containers.find(c => c.e === e);
2307
+ if (c && c.value !== record.value) {
2308
+ const holes = {};
2309
+ if (record.holes) for (const key in record.holes) if (key.startsWith("lha:")) holes[key] = record.holes[key];
2310
+ put(id, version, k, withHoles({
2311
+ ...record,
2312
+ value: c.value,
2313
+ digest: k ? textDigest(c.value) : record.digest
2314
+ }, holeDigests(c.value, null, holes)));
2315
+ } else put(id, version, k, record);
2316
+ }
2317
+ return out;
2318
+ }
2259
2319
  for (const e of shared.records.values()) {
2260
2320
  const {
2261
2321
  id,