@jam-overture/loom 0.2.0 → 0.3.0

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.
Files changed (194) hide show
  1. package/dist/audience/compose.d.ts +112 -0
  2. package/dist/audience/compose.js +134 -0
  3. package/dist/audience/memory.d.ts +14 -0
  4. package/dist/audience/memory.js +71 -0
  5. package/dist/audience/overlay-store.d.ts +343 -0
  6. package/dist/audience/overlay-store.js +217 -0
  7. package/dist/audience/rule.d.ts +121 -0
  8. package/dist/audience/rule.js +78 -0
  9. package/dist/cli/index.d.ts +3 -4
  10. package/dist/cli/index.js +3 -4
  11. package/dist/data/adapter.d.ts +9 -1
  12. package/dist/data/adapter.js +2 -0
  13. package/dist/data/resolve.d.ts +1 -1
  14. package/dist/interpretation/anthropic.d.ts +1 -1
  15. package/dist/interpretation/anthropic.js +2 -22
  16. package/dist/interpretation/client.d.ts +1 -1
  17. package/dist/interpretation/materialize.js +67 -22
  18. package/dist/interpretation/openai-compatible.d.ts +36 -0
  19. package/dist/interpretation/openai-compatible.js +79 -0
  20. package/dist/interpretation/status.d.ts +19 -0
  21. package/dist/interpretation/status.js +26 -0
  22. package/dist/live/index.d.ts +73 -0
  23. package/dist/live/index.js +73 -0
  24. package/dist/live/pages.d.ts +187 -0
  25. package/dist/live/pages.js +161 -0
  26. package/dist/live/pull.d.ts +147 -0
  27. package/dist/live/pull.js +398 -0
  28. package/dist/live/pulling.d.ts +79 -0
  29. package/dist/live/pulling.js +117 -0
  30. package/dist/live/window.d.ts +129 -0
  31. package/dist/live/window.js +132 -0
  32. package/dist/render/addressed.d.ts +35 -0
  33. package/dist/render/addressed.js +79 -0
  34. package/dist/render/document-theme.d.ts +70 -0
  35. package/dist/render/document-theme.js +139 -0
  36. package/dist/render/editable.d.ts +15 -1
  37. package/dist/render/editable.js +13 -1
  38. package/dist/render/expected.d.ts +98 -0
  39. package/dist/render/expected.js +88 -0
  40. package/dist/render/index.d.ts +2 -0
  41. package/dist/render/index.js +2 -0
  42. package/dist/render/render.d.ts +11 -0
  43. package/dist/render/render.js +192 -46
  44. package/dist/render/request.d.ts +8 -1
  45. package/dist/render/request.js +1 -0
  46. package/dist/runtime/auto-apply-ceiling.d.ts +54 -0
  47. package/dist/runtime/auto-apply-ceiling.js +66 -0
  48. package/dist/runtime/gate.js +69 -10
  49. package/dist/runtime/index.d.ts +1 -0
  50. package/dist/runtime/index.js +1 -0
  51. package/dist/runtime/nesting.d.ts +13 -1
  52. package/dist/runtime/nesting.js +41 -24
  53. package/dist/runtime/policy-change.js +8 -2
  54. package/dist/runtime/policy-log.d.ts +5 -5
  55. package/dist/runtime/policy.d.ts +8 -6
  56. package/dist/runtime/policy.js +5 -2
  57. package/dist/runtime/repointing.js +0 -0
  58. package/dist/sdk/definition.d.ts +65 -6
  59. package/dist/sdk/definition.js +44 -0
  60. package/dist/sdk/registry.d.ts +17 -1
  61. package/dist/sdk/registry.js +39 -0
  62. package/dist/signals/acted.contract.d.ts +21 -0
  63. package/dist/signals/acted.contract.js +236 -0
  64. package/dist/signals/acted.d.ts +359 -0
  65. package/dist/signals/acted.js +135 -0
  66. package/dist/signals/agenda.d.ts +585 -0
  67. package/dist/signals/agenda.js +295 -0
  68. package/dist/signals/arrivals.contract.d.ts +21 -0
  69. package/dist/signals/arrivals.contract.js +180 -0
  70. package/dist/signals/arrivals.d.ts +375 -0
  71. package/dist/signals/arrivals.js +254 -0
  72. package/dist/signals/broadcast.d.ts +25 -15
  73. package/dist/signals/broadcast.js +209 -36
  74. package/dist/signals/collect.d.ts +137 -43
  75. package/dist/signals/collect.js +103 -36
  76. package/dist/signals/conversion.d.ts +348 -0
  77. package/dist/signals/conversion.js +235 -0
  78. package/dist/signals/correlated.contract.d.ts +24 -0
  79. package/dist/signals/correlated.contract.js +94 -0
  80. package/dist/signals/counters.d.ts +51 -0
  81. package/dist/signals/counters.js +58 -0
  82. package/dist/signals/deployment-change.d.ts +28 -4
  83. package/dist/signals/deployment-change.js +57 -16
  84. package/dist/signals/deployment.d.ts +18 -5
  85. package/dist/signals/deployment.js +37 -11
  86. package/dist/signals/door.d.ts +34 -12
  87. package/dist/signals/door.js +37 -13
  88. package/dist/signals/expire.d.ts +192 -0
  89. package/dist/signals/expire.js +213 -0
  90. package/dist/signals/frontier.d.ts +268 -0
  91. package/dist/signals/frontier.js +145 -0
  92. package/dist/signals/funnel-hours.contract.d.ts +21 -0
  93. package/dist/signals/funnel-hours.contract.js +221 -0
  94. package/dist/signals/funnel-hours.d.ts +293 -0
  95. package/dist/signals/funnel-hours.js +99 -0
  96. package/dist/signals/funnel.d.ts +60 -0
  97. package/dist/signals/funnel.js +35 -20
  98. package/dist/signals/health.d.ts +201 -4
  99. package/dist/signals/health.js +214 -2
  100. package/dist/signals/index.d.ts +19 -0
  101. package/dist/signals/index.js +19 -0
  102. package/dist/signals/inside.d.ts +190 -0
  103. package/dist/signals/inside.js +263 -0
  104. package/dist/signals/join.d.ts +56 -0
  105. package/dist/signals/join.js +60 -0
  106. package/dist/signals/journal.d.ts +112 -9
  107. package/dist/signals/kept.contract.d.ts +22 -0
  108. package/dist/signals/kept.contract.js +111 -0
  109. package/dist/signals/library-agenda-change.d.ts +324 -0
  110. package/dist/signals/library-agenda-change.js +199 -0
  111. package/dist/signals/library-agenda.d.ts +258 -0
  112. package/dist/signals/library-agenda.js +167 -0
  113. package/dist/signals/library-reach-change.d.ts +10 -0
  114. package/dist/signals/library-reach-change.js +11 -3
  115. package/dist/signals/library-senders-change.d.ts +457 -0
  116. package/dist/signals/library-senders-change.js +367 -0
  117. package/dist/signals/library-senders-reach-change.d.ts +486 -0
  118. package/dist/signals/library-senders-reach-change.js +538 -0
  119. package/dist/signals/library-senders-reach.d.ts +340 -0
  120. package/dist/signals/library-senders-reach.js +252 -0
  121. package/dist/signals/library-senders.d.ts +271 -0
  122. package/dist/signals/library-senders.js +180 -0
  123. package/dist/signals/library-word-reach-change.js +2 -6
  124. package/dist/signals/memory.js +142 -1
  125. package/dist/signals/migrate.d.ts +6 -5
  126. package/dist/signals/migrate.js +150 -6
  127. package/dist/signals/notice.d.ts +88 -33
  128. package/dist/signals/notice.js +38 -16
  129. package/dist/signals/part-pace.d.ts +378 -0
  130. package/dist/signals/part-pace.js +333 -0
  131. package/dist/signals/parts.d.ts +25 -15
  132. package/dist/signals/parts.js +32 -73
  133. package/dist/signals/postgres.js +400 -26
  134. package/dist/signals/region.d.ts +1 -1
  135. package/dist/signals/retention.d.ts +43 -21
  136. package/dist/signals/retention.js +25 -8
  137. package/dist/signals/rhythm.d.ts +302 -0
  138. package/dist/signals/rhythm.js +262 -0
  139. package/dist/signals/rollup.d.ts +127 -1
  140. package/dist/signals/rollup.js +211 -24
  141. package/dist/signals/schema.d.ts +640 -3
  142. package/dist/signals/schema.js +239 -3
  143. package/dist/signals/silences.d.ts +310 -11
  144. package/dist/signals/silences.js +243 -0
  145. package/dist/signals/subtrees.d.ts +123 -0
  146. package/dist/signals/subtrees.js +102 -0
  147. package/dist/signals/tally.d.ts +125 -4
  148. package/dist/signals/unread.d.ts +292 -0
  149. package/dist/signals/unread.js +137 -0
  150. package/dist/signals/window-agenda.d.ts +276 -0
  151. package/dist/signals/window-agenda.js +83 -0
  152. package/dist/signals/window-funnels.d.ts +88 -0
  153. package/dist/signals/window-funnels.js +47 -0
  154. package/dist/store/cache.d.ts +101 -0
  155. package/dist/store/cache.js +149 -0
  156. package/dist/store/history.d.ts +82 -0
  157. package/dist/store/history.js +36 -0
  158. package/dist/store/index.d.ts +11 -0
  159. package/dist/store/index.js +11 -0
  160. package/dist/store/migrate.d.ts +26 -0
  161. package/dist/store/migrate.js +64 -0
  162. package/dist/store/postgres-audience.d.ts +14 -0
  163. package/dist/store/postgres-audience.js +272 -0
  164. package/dist/store/postgres.d.ts +1 -0
  165. package/dist/store/postgres.js +1 -0
  166. package/dist/store/schema.d.ts +312 -0
  167. package/dist/store/schema.js +77 -0
  168. package/dist/store/source.d.ts +57 -1
  169. package/dist/store/source.js +65 -1
  170. package/dist/submit/resolve.d.ts +1 -1
  171. package/dist/telemetry/index.d.ts +1 -0
  172. package/dist/telemetry/index.js +1 -0
  173. package/dist/telemetry/journal.d.ts +32 -0
  174. package/dist/telemetry/memory.js +10 -1
  175. package/dist/telemetry/postgres.js +18 -2
  176. package/dist/telemetry/window.d.ts +135 -0
  177. package/dist/telemetry/window.js +101 -0
  178. package/dist/testing/audience-overlay-contract.d.ts +31 -0
  179. package/dist/testing/audience-overlay-contract.js +354 -0
  180. package/dist/testing/contracts.d.ts +1 -0
  181. package/dist/testing/contracts.js +1 -0
  182. package/dist/testing/journal-contract.js +158 -5
  183. package/dist/theme/contrast.d.ts +19 -14
  184. package/dist/theme/contrast.js +181 -17
  185. package/dist/tree/apply.js +13 -0
  186. package/dist/tree/mutation.d.ts +18 -0
  187. package/dist/tree/mutation.js +24 -12
  188. package/dist/tree/navigation.d.ts +5 -0
  189. package/dist/tree/navigation.js +32 -10
  190. package/dist/tree/outline.d.ts +7 -0
  191. package/dist/tree/outline.js +9 -5
  192. package/package.json +39 -96
  193. package/dist/runtime/inverse-interpreter.d.ts +0 -90
  194. package/dist/runtime/inverse-interpreter.js +0 -56
@@ -0,0 +1,367 @@
1
+ import { everyMemberOf } from "../closed-set.js";
2
+ import { PRIMITIVE_ROLES } from "../role.js";
3
+ import { inFormOrder } from "./audiences.js";
4
+ import { pairedWindowOf, partsByNodeIn } from "./library-change.js";
5
+ import { kindKeyOf } from "./library.js";
6
+ import { senderStatesOf, witnessedState } from "./subtrees.js";
7
+ export const SENDER_FIX_SILENCES = everyMemberOf()([
8
+ "unplaced",
9
+ "unpaired",
10
+ "unwitnessable",
11
+ "uncheckable",
12
+ "unclaimable",
13
+ ]);
14
+ /** One line per silence, for a surface saying why a kind has no before and after. */
15
+ export const describeSenderFixSilence = (silence) => {
16
+ switch (silence) {
17
+ case "unplaced":
18
+ return "nothing in the pages read, in either window, is of this kind";
19
+ case "unpaired":
20
+ return "no place this kind of part stands is in both windows";
21
+ case "unwitnessable":
22
+ return "no place it stands in both windows has anything inside it on both sides";
23
+ case "uncheckable":
24
+ return "no place it stands in both windows could be checked in both";
25
+ case "unclaimable":
26
+ return "every place that could be checked in both reported something other than a view in one of them";
27
+ }
28
+ };
29
+ export const SENDER_MOVEMENTS = everyMemberOf()([
30
+ "repaired",
31
+ "regressed",
32
+ "held",
33
+ "still-silent",
34
+ "unknown",
35
+ ]);
36
+ /** One line per movement, for a surface putting a component's before and after in front of a person. */
37
+ export const describeSenderMovement = (movement) => {
38
+ switch (movement) {
39
+ case "repaired":
40
+ return "more of the places it stands report themselves now";
41
+ case "regressed":
42
+ return "fewer of the places it stands report themselves now";
43
+ case "held":
44
+ return "as many of the places it stands report themselves now as did";
45
+ case "still-silent":
46
+ return "no place it stands reported itself in either window";
47
+ case "unknown":
48
+ return "nothing can be said about what changed";
49
+ }
50
+ };
51
+ /** How many newly silent nodes a row carries as examples. */
52
+ export const SILENCED_EXAMPLES = 5;
53
+ const tallying = (kind) => ({
54
+ kind,
55
+ role: null,
56
+ places: 0,
57
+ gained: 0,
58
+ lost: 0,
59
+ checkableWas: 0,
60
+ checkableNow: 0,
61
+ inhabited: 0,
62
+ checkable: 0,
63
+ indeterminate: 0,
64
+ repaired: 0,
65
+ wentSilent: 0,
66
+ keptSilent: 0,
67
+ keptReporting: 0,
68
+ repairedIn: new Set(),
69
+ silencedIn: new Set(),
70
+ silencedExamples: [],
71
+ });
72
+ /** The two keys one placement is counted under, which is the pair of questions this answers. */
73
+ const keysOf = (part) => [
74
+ { by: "type", type: part.type },
75
+ { by: "role", role: part.role },
76
+ ];
77
+ const rowFor = (rows, kind) => {
78
+ const key = kindKeyOf(kind);
79
+ const row = rows.get(key) ?? tallying(kind);
80
+ rows.set(key, row);
81
+ return row;
82
+ };
83
+ const add = (into, at) => {
84
+ const checkableWas = witnessedState(at.was);
85
+ const checkableNow = witnessedState(at.now);
86
+ into.places += 1;
87
+ into.checkableWas += checkableWas ? 1 : 0;
88
+ into.checkableNow += checkableNow ? 1 : 0;
89
+ into.inhabited += at.was !== "leaf" && at.now !== "leaf" ? 1 : 0;
90
+ if (!checkableWas || !checkableNow)
91
+ return;
92
+ into.checkable += 1;
93
+ if (at.was === "indeterminate" || at.now === "indeterminate") {
94
+ into.indeterminate += 1;
95
+ return;
96
+ }
97
+ if (at.was === "silent" && at.now !== "silent") {
98
+ into.repaired += 1;
99
+ into.repairedIn.add(at.treeId);
100
+ }
101
+ else if (at.was !== "silent" && at.now === "silent") {
102
+ into.wentSilent += 1;
103
+ into.silencedIn.add(at.treeId);
104
+ if (into.silencedExamples.length < SILENCED_EXAMPLES)
105
+ into.silencedExamples.push(at.nodeId);
106
+ }
107
+ else if (at.was === "silent")
108
+ into.keptSilent += 1;
109
+ else
110
+ into.keptReporting += 1;
111
+ };
112
+ /**
113
+ * The silence, with the reasons tried in the order they have to be tried in.
114
+ *
115
+ * Nothing of the kind first, because *there is no such part in this library* is
116
+ * a better answer than anything said about its places. Then nothing held still,
117
+ * because a kind whose places all moved is a fact about the library. Then the
118
+ * places that could not be checked, because *come back with readers* and
119
+ * *nothing claimed what it was* are different instructions and the first is the
120
+ * one that covers the second's places too.
121
+ *
122
+ * **The empty population is two reasons and not one** (0414). The structural
123
+ * half is reserved the way the census reserves it (0393): `unwitnessable` only
124
+ * where *no* paired place has anything inside it on both sides, so the mixed
125
+ * row — some leaves, some places short of readers — says *come back with
126
+ * readers*, which is the half of it a deployment can act on. This order is the
127
+ * only place that asymmetry lives, and it is why the two members are not
128
+ * interchangeable.
129
+ */
130
+ const silenceOf = (of, comparable) => {
131
+ if (of.places + of.gained + of.lost === 0)
132
+ return "unplaced";
133
+ if (of.places === 0)
134
+ return "unpaired";
135
+ if (of.checkable === 0)
136
+ return of.inhabited === 0 ? "unwitnessable" : "uncheckable";
137
+ return comparable === 0 ? "unclaimable" : null;
138
+ };
139
+ /**
140
+ * The verdict, off the two counts of places and never off the two shares.
141
+ *
142
+ * The shares have one denominator by construction, so their difference has the
143
+ * sign of `wentSilent − repaired` exactly; taking it from the counts keeps a
144
+ * division out of a verdict.
145
+ */
146
+ const movementOf = (of, silence) => {
147
+ if (silence !== null)
148
+ return "unknown";
149
+ if (of.repaired > of.wentSilent)
150
+ return "repaired";
151
+ if (of.wentSilent > of.repaired)
152
+ return "regressed";
153
+ return of.keptReporting === 0 && of.repaired === 0 ? "still-silent" : "held";
154
+ };
155
+ const rowOf = (of) => {
156
+ const comparable = of.repaired + of.wentSilent + of.keptSilent + of.keptReporting;
157
+ const silence = silenceOf(of, comparable);
158
+ return {
159
+ kind: of.kind,
160
+ role: of.kind.by === "type" ? of.role : null,
161
+ places: of.places,
162
+ gained: of.gained,
163
+ lost: of.lost,
164
+ checkableWas: of.checkableWas,
165
+ checkableNow: of.checkableNow,
166
+ inhabited: of.inhabited,
167
+ checkable: of.checkable,
168
+ indeterminate: of.indeterminate,
169
+ comparable,
170
+ repaired: of.repaired,
171
+ wentSilent: of.wentSilent,
172
+ keptSilent: of.keptSilent,
173
+ keptReporting: of.keptReporting,
174
+ silentShareWas: comparable === 0 ? null : (of.keptSilent + of.repaired) / comparable,
175
+ silentShareNow: comparable === 0 ? null : (of.keptSilent + of.wentSilent) / comparable,
176
+ movement: movementOf(of, silence),
177
+ silence,
178
+ repairedTrees: of.repairedIn.size,
179
+ silencedTrees: of.silencedIn.size,
180
+ silencedExamples: [...of.silencedExamples],
181
+ };
182
+ };
183
+ /** The name a row is ordered by, which is the key's own and never the row's position. */
184
+ const nameOf = (kind) => (kind.by === "type" ? kind.type : (kind.role ?? ""));
185
+ /**
186
+ * The kind to look at first, which is the ranking rule spelled once.
187
+ *
188
+ * Most places gone silent, then the higher silent share now, then by name — so a
189
+ * kind with no share at all sorts after one with a share of nought rather than
190
+ * above it, because `null` is *nothing can be said* and not *every sender works*.
191
+ *
192
+ * Silenced before repaired, because a component that has just stopped reporting
193
+ * is the thing to act on and a repair is the thing to read.
194
+ */
195
+ const worseOf = (one, other) => other.wentSilent - one.wentSilent ||
196
+ (other.silentShareNow ?? -1) - (one.silentShareNow ?? -1) ||
197
+ nameOf(one.kind).localeCompare(nameOf(other.kind));
198
+ /** The states of one window's parts, by node, which is what a paired place is read off. */
199
+ const sendersByNodeIn = (reading) => new Map(senderStatesOf(reading.parts).map(({ part, state }) => [part.nodeId, state]));
200
+ /**
201
+ * What a change did to a deployment's senders, across every page a kind of part
202
+ * stands on.
203
+ *
204
+ * Takes the two windows' readings rather than two `LibrarySenders`, and the
205
+ * reason is the method: a census publishes a kind's places added up, and the
206
+ * places have to be **paired** before anything can be held still.
207
+ *
208
+ * The labels are the caller's. Two readings of one window come back as every
209
+ * place held and nothing repaired or silenced — which is asserted against the
210
+ * census term for term — and a caller holding the two sides backwards gets a
211
+ * comparison with every movement reversed rather than a refusal, exactly as
212
+ * every other before-and-after reading here does.
213
+ */
214
+ export const librarySendersChangeOf = (was, now) => {
215
+ const earlier = pairedWindowOf(was);
216
+ const later = pairedWindowOf(now);
217
+ const rows = new Map();
218
+ const roleWas = new Map();
219
+ const roleNow = new Map();
220
+ const ambiguous = new Map([...earlier.ambiguous, ...later.ambiguous]);
221
+ let pages = 0;
222
+ let pagesGained = 0;
223
+ let pagesLost = 0;
224
+ let republished = 0;
225
+ let placements = 0;
226
+ let gained = 0;
227
+ let lost = 0;
228
+ let recast = 0;
229
+ let viewsWas = 0;
230
+ let viewsNow = 0;
231
+ /**
232
+ * Every role in the vocabulary gets a row whether or not anything plays it, as
233
+ * the census's role rows do: a role nothing in the library plays is a fact
234
+ * about the library, and a surface that had to tell a missing row from an
235
+ * empty one would be reading the vocabulary itself.
236
+ */
237
+ for (const role of [...PRIMITIVE_ROLES, null])
238
+ rowFor(rows, { by: "role", role });
239
+ for (const [form, reading] of earlier.byForm) {
240
+ if (ambiguous.has(form))
241
+ continue;
242
+ for (const part of reading.parts) {
243
+ roleWas.set(part.type, part.role);
244
+ rowFor(rows, { by: "type", type: part.type }).role = part.role;
245
+ }
246
+ if (later.byForm.has(form))
247
+ continue;
248
+ pagesLost += 1;
249
+ for (const part of reading.parts) {
250
+ lost += 1;
251
+ for (const kind of keysOf(part))
252
+ rowFor(rows, kind).lost += 1;
253
+ }
254
+ }
255
+ for (const [form, reading] of later.byForm) {
256
+ if (ambiguous.has(form))
257
+ continue;
258
+ for (const part of reading.parts) {
259
+ roleNow.set(part.type, part.role);
260
+ rowFor(rows, { by: "type", type: part.type }).role = part.role;
261
+ }
262
+ if (earlier.byForm.has(form))
263
+ continue;
264
+ pagesGained += 1;
265
+ for (const part of reading.parts) {
266
+ gained += 1;
267
+ for (const kind of keysOf(part))
268
+ rowFor(rows, kind).gained += 1;
269
+ }
270
+ }
271
+ for (const [form, before] of earlier.byForm) {
272
+ const after = later.byForm.get(form);
273
+ if (after === undefined || ambiguous.has(form))
274
+ continue;
275
+ const beforeParts = partsByNodeIn(before);
276
+ const afterParts = partsByNodeIn(after);
277
+ const beforeStates = sendersByNodeIn(before);
278
+ const afterStates = sendersByNodeIn(after);
279
+ pages += 1;
280
+ republished += before.revision === after.revision ? 0 : 1;
281
+ viewsWas += before.views;
282
+ viewsNow += after.views;
283
+ for (const part of before.parts) {
284
+ const counterpart = afterParts.get(part.nodeId);
285
+ if (counterpart === undefined) {
286
+ lost += 1;
287
+ for (const kind of keysOf(part))
288
+ rowFor(rows, kind).lost += 1;
289
+ continue;
290
+ }
291
+ if (part.type === counterpart.type) {
292
+ placements += 1;
293
+ }
294
+ else {
295
+ recast += 1;
296
+ lost += 1;
297
+ gained += 1;
298
+ rowFor(rows, { by: "type", type: part.type }).lost += 1;
299
+ rowFor(rows, { by: "type", type: counterpart.type }).gained += 1;
300
+ }
301
+ if (part.role !== counterpart.role) {
302
+ rowFor(rows, { by: "role", role: part.role }).lost += 1;
303
+ rowFor(rows, { by: "role", role: counterpart.role }).gained += 1;
304
+ }
305
+ /**
306
+ * A place is paired under a key only where it is of that kind on both
307
+ * sides, which is where the two keys answer differently: a node recast
308
+ * into another type is a place one type left and another took, while the
309
+ * role rows hold it still wherever the two types play the same part.
310
+ */
311
+ const sameType = part.type === counterpart.type ? [{ by: "type", type: part.type }] : [];
312
+ const sameRole = part.role === counterpart.role ? [{ by: "role", role: part.role }] : [];
313
+ const paired = {
314
+ nodeId: part.nodeId,
315
+ treeId: before.treeId,
316
+ was: beforeStates.get(part.nodeId) ?? "leaf",
317
+ now: afterStates.get(part.nodeId) ?? "leaf",
318
+ };
319
+ for (const kind of [...sameType, ...sameRole])
320
+ add(rowFor(rows, kind), paired);
321
+ }
322
+ for (const part of after.parts) {
323
+ if (beforeParts.has(part.nodeId))
324
+ continue;
325
+ gained += 1;
326
+ for (const kind of keysOf(part))
327
+ rowFor(rows, kind).gained += 1;
328
+ }
329
+ }
330
+ const built = [...rows.values()].map(rowOf);
331
+ const byType = built.filter((row) => row.kind.by === "type").sort(worseOf);
332
+ const disagreed = [...roleNow.keys()]
333
+ .filter((type) => roleWas.has(type) && roleWas.get(type) !== roleNow.get(type))
334
+ .sort((one, other) => one.localeCompare(other));
335
+ const totalOf = (figure) => byType.reduce((total, row) => total + figure(row), 0);
336
+ return {
337
+ byType,
338
+ byRole: built.filter((row) => row.kind.by === "role").sort(worseOf),
339
+ pages,
340
+ pagesGained,
341
+ pagesLost,
342
+ audiences: { was: earlier.audiences, now: later.audiences },
343
+ republished,
344
+ placements,
345
+ gained,
346
+ lost,
347
+ recast,
348
+ checkable: totalOf((row) => row.checkable),
349
+ inhabited: totalOf((row) => row.inhabited),
350
+ comparable: totalOf((row) => row.comparable),
351
+ repaired: totalOf((row) => row.repaired),
352
+ wentSilent: totalOf((row) => row.wentSilent),
353
+ keptSilent: totalOf((row) => row.keptSilent),
354
+ keptReporting: totalOf((row) => row.keptReporting),
355
+ indeterminate: totalOf((row) => row.indeterminate),
356
+ viewsWas,
357
+ viewsNow,
358
+ mostRepaired: byType
359
+ .filter((row) => row.repaired > 0)
360
+ .sort((one, other) => other.repaired - one.repaired || nameOf(one.kind).localeCompare(nameOf(other.kind)))[0] ?? null,
361
+ mostSilenced: byType.find((row) => row.wentSilent > 0) ?? null,
362
+ ambiguous: [...ambiguous.values()].sort(inFormOrder),
363
+ duplicated: earlier.duplicated + later.duplicated,
364
+ roleDisagreed: disagreed,
365
+ };
366
+ };
367
+ //# sourceMappingURL=library-senders-change.js.map