@jam-overture/loom 0.1.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 (414) hide show
  1. package/README.md +3 -1
  2. package/dist/application/application.d.ts +109 -0
  3. package/dist/application/application.js +97 -0
  4. package/dist/application/memory.d.ts +20 -0
  5. package/dist/application/memory.js +79 -0
  6. package/dist/application/store.d.ts +101 -0
  7. package/dist/application/store.js +25 -0
  8. package/dist/audience/audience.d.ts +36 -0
  9. package/dist/audience/audience.js +41 -0
  10. package/dist/audience/compose.d.ts +112 -0
  11. package/dist/audience/compose.js +134 -0
  12. package/dist/audience/memory.d.ts +14 -0
  13. package/dist/audience/memory.js +71 -0
  14. package/dist/audience/overlay-store.d.ts +343 -0
  15. package/dist/audience/overlay-store.js +217 -0
  16. package/dist/audience/rule.d.ts +121 -0
  17. package/dist/audience/rule.js +78 -0
  18. package/dist/cli/index.d.ts +3 -4
  19. package/dist/cli/index.js +3 -4
  20. package/dist/cli/templates.js +19 -0
  21. package/dist/data/adapter.d.ts +9 -1
  22. package/dist/data/adapter.js +2 -0
  23. package/dist/data/plan.js +0 -0
  24. package/dist/data/resolution.d.ts +23 -1
  25. package/dist/data/resolve.d.ts +31 -4
  26. package/dist/data/resolve.js +11 -3
  27. package/dist/ids.d.ts +10 -0
  28. package/dist/ids.js +11 -1
  29. package/dist/index.d.ts +1 -0
  30. package/dist/index.js +1 -0
  31. package/dist/interpretation/anthropic.d.ts +1 -1
  32. package/dist/interpretation/anthropic.js +2 -22
  33. package/dist/interpretation/client.d.ts +1 -1
  34. package/dist/interpretation/materialize.js +67 -22
  35. package/dist/interpretation/openai-compatible.d.ts +36 -0
  36. package/dist/interpretation/openai-compatible.js +79 -0
  37. package/dist/interpretation/status.d.ts +19 -0
  38. package/dist/interpretation/status.js +26 -0
  39. package/dist/live/index.d.ts +73 -0
  40. package/dist/live/index.js +73 -0
  41. package/dist/live/pages.d.ts +187 -0
  42. package/dist/live/pages.js +161 -0
  43. package/dist/live/pull.d.ts +147 -0
  44. package/dist/live/pull.js +398 -0
  45. package/dist/live/pulling.d.ts +79 -0
  46. package/dist/live/pulling.js +117 -0
  47. package/dist/live/window.d.ts +129 -0
  48. package/dist/live/window.js +132 -0
  49. package/dist/patch.d.ts +54 -0
  50. package/dist/patch.js +44 -0
  51. package/dist/project/closing.d.ts +51 -0
  52. package/dist/project/closing.js +53 -0
  53. package/dist/project/memory.d.ts +20 -0
  54. package/dist/project/memory.js +97 -0
  55. package/dist/project/project.d.ts +90 -0
  56. package/dist/project/project.js +91 -0
  57. package/dist/project/store.d.ts +135 -0
  58. package/dist/project/store.js +41 -0
  59. package/dist/registered.d.ts +64 -0
  60. package/dist/registered.js +118 -0
  61. package/dist/render/addressed.d.ts +35 -0
  62. package/dist/render/addressed.js +79 -0
  63. package/dist/render/behaviour-adjust.d.ts +11 -19
  64. package/dist/render/behaviour-adjust.js +75 -21
  65. package/dist/render/behaviour-present.d.ts +8 -0
  66. package/dist/render/behaviour-present.js +57 -6
  67. package/dist/render/behaviour.d.ts +98 -17
  68. package/dist/render/behaviour.js +91 -26
  69. package/dist/render/control-name.d.ts +68 -0
  70. package/dist/render/control-name.js +37 -0
  71. package/dist/render/diagnostics.d.ts +72 -0
  72. package/dist/render/diagnostics.js +7 -0
  73. package/dist/render/document-theme.d.ts +70 -0
  74. package/dist/render/document-theme.js +139 -0
  75. package/dist/render/editable.d.ts +15 -1
  76. package/dist/render/editable.js +13 -1
  77. package/dist/render/expected.d.ts +98 -0
  78. package/dist/render/expected.js +88 -0
  79. package/dist/render/index.d.ts +4 -0
  80. package/dist/render/index.js +4 -0
  81. package/dist/render/reads.d.ts +11 -0
  82. package/dist/render/reads.js +12 -1
  83. package/dist/render/render.d.ts +11 -0
  84. package/dist/render/render.js +294 -53
  85. package/dist/render/request.d.ts +8 -1
  86. package/dist/render/request.js +1 -0
  87. package/dist/render/slots.d.ts +52 -0
  88. package/dist/render/slots.js +24 -0
  89. package/dist/render/theme.d.ts +54 -1
  90. package/dist/render/theme.js +23 -1
  91. package/dist/render/unshown.d.ts +152 -0
  92. package/dist/render/unshown.js +80 -0
  93. package/dist/runtime/analysis.d.ts +94 -9
  94. package/dist/runtime/analysis.js +54 -9
  95. package/dist/runtime/assessment.d.ts +36 -2
  96. package/dist/runtime/assessment.js +27 -2
  97. package/dist/runtime/auto-apply-ceiling.d.ts +54 -0
  98. package/dist/runtime/auto-apply-ceiling.js +66 -0
  99. package/dist/runtime/checks.d.ts +148 -0
  100. package/dist/runtime/checks.js +112 -0
  101. package/dist/runtime/disposition.d.ts +96 -0
  102. package/dist/runtime/disposition.js +46 -0
  103. package/dist/runtime/gate.js +91 -10
  104. package/dist/runtime/index.d.ts +4 -0
  105. package/dist/runtime/index.js +4 -0
  106. package/dist/runtime/irreversibility.d.ts +64 -0
  107. package/dist/runtime/irreversibility.js +45 -0
  108. package/dist/runtime/nesting.d.ts +13 -1
  109. package/dist/runtime/nesting.js +41 -24
  110. package/dist/runtime/pipeline.d.ts +43 -0
  111. package/dist/runtime/pipeline.js +10 -2
  112. package/dist/runtime/policy-change.d.ts +93 -0
  113. package/dist/runtime/policy-change.js +305 -0
  114. package/dist/runtime/policy-log.d.ts +406 -0
  115. package/dist/runtime/policy-log.js +285 -0
  116. package/dist/runtime/policy.d.ts +8 -6
  117. package/dist/runtime/policy.js +5 -2
  118. package/dist/runtime/repointing.js +0 -0
  119. package/dist/runtime/reversibility.d.ts +11 -9
  120. package/dist/runtime/stakes.d.ts +129 -1
  121. package/dist/runtime/stakes.js +240 -26
  122. package/dist/runtime/vocabulary.d.ts +164 -7
  123. package/dist/runtime/vocabulary.js +181 -8
  124. package/dist/sdk/audit.d.ts +174 -3
  125. package/dist/sdk/audit.js +176 -17
  126. package/dist/sdk/catalogue.d.ts +9 -1
  127. package/dist/sdk/conformance.d.ts +37 -3
  128. package/dist/sdk/conformance.js +25 -4
  129. package/dist/sdk/definition.d.ts +129 -5
  130. package/dist/sdk/definition.js +66 -0
  131. package/dist/sdk/registry.d.ts +45 -2
  132. package/dist/sdk/registry.js +102 -1
  133. package/dist/signals/acted.contract.d.ts +21 -0
  134. package/dist/signals/acted.contract.js +236 -0
  135. package/dist/signals/acted.d.ts +359 -0
  136. package/dist/signals/acted.js +135 -0
  137. package/dist/signals/action-change.d.ts +507 -0
  138. package/dist/signals/action-change.js +265 -0
  139. package/dist/signals/action.d.ts +331 -0
  140. package/dist/signals/action.js +182 -0
  141. package/dist/signals/agenda.d.ts +585 -0
  142. package/dist/signals/agenda.js +295 -0
  143. package/dist/signals/applied-window.contract.d.ts +23 -0
  144. package/dist/signals/applied-window.contract.js +160 -0
  145. package/dist/signals/arrivals.contract.d.ts +21 -0
  146. package/dist/signals/arrivals.contract.js +180 -0
  147. package/dist/signals/arrivals.d.ts +375 -0
  148. package/dist/signals/arrivals.js +254 -0
  149. package/dist/signals/arriving.d.ts +210 -0
  150. package/dist/signals/arriving.js +133 -0
  151. package/dist/signals/audiences.d.ts +528 -0
  152. package/dist/signals/audiences.js +255 -0
  153. package/dist/signals/broadcast.d.ts +33 -17
  154. package/dist/signals/broadcast.js +255 -32
  155. package/dist/signals/change.d.ts +378 -0
  156. package/dist/signals/change.js +327 -0
  157. package/dist/signals/collect.d.ts +169 -34
  158. package/dist/signals/collect.js +186 -38
  159. package/dist/signals/conversion.d.ts +348 -0
  160. package/dist/signals/conversion.js +235 -0
  161. package/dist/signals/copy-change.d.ts +553 -0
  162. package/dist/signals/copy-change.js +377 -0
  163. package/dist/signals/copy.d.ts +337 -0
  164. package/dist/signals/copy.js +211 -0
  165. package/dist/signals/correlated.contract.d.ts +24 -0
  166. package/dist/signals/correlated.contract.js +94 -0
  167. package/dist/signals/counters.d.ts +97 -0
  168. package/dist/signals/counters.js +160 -0
  169. package/dist/signals/deliver.d.ts +23 -4
  170. package/dist/signals/deliver.js +34 -6
  171. package/dist/signals/deployment-change.d.ts +395 -0
  172. package/dist/signals/deployment-change.js +309 -0
  173. package/dist/signals/deployment.d.ts +278 -0
  174. package/dist/signals/deployment.js +178 -0
  175. package/dist/signals/door.d.ts +114 -0
  176. package/dist/signals/door.js +77 -0
  177. package/dist/signals/expire.d.ts +192 -0
  178. package/dist/signals/expire.js +213 -0
  179. package/dist/signals/fold.d.ts +10 -0
  180. package/dist/signals/fold.js +5 -1
  181. package/dist/signals/form-action.d.ts +302 -0
  182. package/dist/signals/form-action.js +169 -0
  183. package/dist/signals/form-copy.d.ts +523 -0
  184. package/dist/signals/form-copy.js +346 -0
  185. package/dist/signals/forms.d.ts +247 -0
  186. package/dist/signals/forms.js +147 -0
  187. package/dist/signals/frontier.d.ts +268 -0
  188. package/dist/signals/frontier.js +145 -0
  189. package/dist/signals/funnel-change.d.ts +548 -0
  190. package/dist/signals/funnel-change.js +361 -0
  191. package/dist/signals/funnel-hours.contract.d.ts +21 -0
  192. package/dist/signals/funnel-hours.contract.js +221 -0
  193. package/dist/signals/funnel-hours.d.ts +293 -0
  194. package/dist/signals/funnel-hours.js +99 -0
  195. package/dist/signals/funnel.d.ts +592 -0
  196. package/dist/signals/funnel.js +231 -0
  197. package/dist/signals/health.d.ts +694 -0
  198. package/dist/signals/health.js +573 -0
  199. package/dist/signals/index.d.ts +60 -0
  200. package/dist/signals/index.js +60 -0
  201. package/dist/signals/ingest.d.ts +56 -1
  202. package/dist/signals/ingest.js +91 -1
  203. package/dist/signals/inside.d.ts +190 -0
  204. package/dist/signals/inside.js +263 -0
  205. package/dist/signals/join.d.ts +56 -0
  206. package/dist/signals/join.js +60 -0
  207. package/dist/signals/journal.d.ts +123 -9
  208. package/dist/signals/kept.contract.d.ts +22 -0
  209. package/dist/signals/kept.contract.js +111 -0
  210. package/dist/signals/kinds.d.ts +8 -6
  211. package/dist/signals/kinds.js +14 -6
  212. package/dist/signals/library-action.d.ts +430 -0
  213. package/dist/signals/library-action.js +336 -0
  214. package/dist/signals/library-agenda-change.d.ts +324 -0
  215. package/dist/signals/library-agenda-change.js +199 -0
  216. package/dist/signals/library-agenda.d.ts +258 -0
  217. package/dist/signals/library-agenda.js +167 -0
  218. package/dist/signals/library-change.d.ts +477 -0
  219. package/dist/signals/library-change.js +335 -0
  220. package/dist/signals/library-copy-change.d.ts +498 -0
  221. package/dist/signals/library-copy-change.js +476 -0
  222. package/dist/signals/library-pace.d.ts +319 -0
  223. package/dist/signals/library-pace.js +305 -0
  224. package/dist/signals/library-reach-change.d.ts +646 -0
  225. package/dist/signals/library-reach-change.js +542 -0
  226. package/dist/signals/library-reach.d.ts +377 -0
  227. package/dist/signals/library-reach.js +227 -0
  228. package/dist/signals/library-senders-change.d.ts +457 -0
  229. package/dist/signals/library-senders-change.js +367 -0
  230. package/dist/signals/library-senders-reach-change.d.ts +486 -0
  231. package/dist/signals/library-senders-reach-change.js +538 -0
  232. package/dist/signals/library-senders-reach.d.ts +340 -0
  233. package/dist/signals/library-senders-reach.js +252 -0
  234. package/dist/signals/library-senders.d.ts +271 -0
  235. package/dist/signals/library-senders.js +180 -0
  236. package/dist/signals/library-word-reach-change.d.ts +567 -0
  237. package/dist/signals/library-word-reach-change.js +564 -0
  238. package/dist/signals/library.d.ts +306 -0
  239. package/dist/signals/library.js +178 -0
  240. package/dist/signals/memory.d.ts +9 -0
  241. package/dist/signals/memory.js +246 -14
  242. package/dist/signals/migrate.d.ts +20 -4
  243. package/dist/signals/migrate.js +269 -8
  244. package/dist/signals/notice.d.ts +389 -0
  245. package/dist/signals/notice.js +250 -0
  246. package/dist/signals/pace-change.d.ts +501 -0
  247. package/dist/signals/pace-change.js +310 -0
  248. package/dist/signals/pace.d.ts +296 -0
  249. package/dist/signals/pace.js +291 -0
  250. package/dist/signals/page-views.d.ts +365 -0
  251. package/dist/signals/page-views.js +218 -0
  252. package/dist/signals/part-pace.d.ts +378 -0
  253. package/dist/signals/part-pace.js +333 -0
  254. package/dist/signals/parts.d.ts +354 -0
  255. package/dist/signals/parts.js +232 -0
  256. package/dist/signals/postgres.d.ts +16 -2
  257. package/dist/signals/postgres.js +753 -76
  258. package/dist/signals/progress.d.ts +212 -0
  259. package/dist/signals/progress.js +150 -0
  260. package/dist/signals/ratios.d.ts +108 -0
  261. package/dist/signals/ratios.js +40 -0
  262. package/dist/signals/reach.d.ts +309 -0
  263. package/dist/signals/reach.js +93 -0
  264. package/dist/signals/readable.d.ts +34 -0
  265. package/dist/signals/readable.js +34 -0
  266. package/dist/signals/readership.d.ts +381 -0
  267. package/dist/signals/readership.js +308 -0
  268. package/dist/signals/region-pages.d.ts +173 -0
  269. package/dist/signals/region-pages.js +62 -0
  270. package/dist/signals/region.d.ts +287 -0
  271. package/dist/signals/region.js +198 -0
  272. package/dist/signals/retention.d.ts +163 -0
  273. package/dist/signals/retention.js +75 -0
  274. package/dist/signals/rhythm.d.ts +302 -0
  275. package/dist/signals/rhythm.js +262 -0
  276. package/dist/signals/rollup.d.ts +194 -4
  277. package/dist/signals/rollup.js +0 -0
  278. package/dist/signals/schema.d.ts +1069 -1
  279. package/dist/signals/schema.js +393 -3
  280. package/dist/signals/signal.d.ts +237 -11
  281. package/dist/signals/signal.js +70 -10
  282. package/dist/signals/silence-census.d.ts +205 -0
  283. package/dist/signals/silence-census.js +87 -0
  284. package/dist/signals/silences.d.ts +1147 -0
  285. package/dist/signals/silences.js +996 -0
  286. package/dist/signals/subtrees.d.ts +123 -0
  287. package/dist/signals/subtrees.js +102 -0
  288. package/dist/signals/tally.d.ts +262 -12
  289. package/dist/signals/unread.d.ts +292 -0
  290. package/dist/signals/unread.js +137 -0
  291. package/dist/signals/window-agenda.d.ts +276 -0
  292. package/dist/signals/window-agenda.js +83 -0
  293. package/dist/signals/window-figures.d.ts +148 -0
  294. package/dist/signals/window-figures.js +42 -0
  295. package/dist/signals/window-funnels.d.ts +88 -0
  296. package/dist/signals/window-funnels.js +47 -0
  297. package/dist/signals/window.d.ts +866 -0
  298. package/dist/signals/window.js +693 -0
  299. package/dist/signals/words.d.ts +24 -0
  300. package/dist/signals/words.js +24 -0
  301. package/dist/store/cache.d.ts +101 -0
  302. package/dist/store/cache.js +149 -0
  303. package/dist/store/history.d.ts +82 -0
  304. package/dist/store/history.js +36 -0
  305. package/dist/store/index.d.ts +30 -0
  306. package/dist/store/index.js +30 -0
  307. package/dist/store/memory.d.ts +2 -1
  308. package/dist/store/memory.js +48 -12
  309. package/dist/store/migrate.d.ts +106 -0
  310. package/dist/store/migrate.js +323 -7
  311. package/dist/store/postgres-applications.d.ts +4 -0
  312. package/dist/store/postgres-applications.js +197 -0
  313. package/dist/store/postgres-audience.d.ts +14 -0
  314. package/dist/store/postgres-audience.js +272 -0
  315. package/dist/store/postgres-holds.d.ts +10 -1
  316. package/dist/store/postgres-holds.js +116 -101
  317. package/dist/store/postgres-policy-log.d.ts +14 -0
  318. package/dist/store/postgres-policy-log.js +240 -0
  319. package/dist/store/postgres-projects.d.ts +4 -0
  320. package/dist/store/postgres-projects.js +217 -0
  321. package/dist/store/postgres.d.ts +17 -1
  322. package/dist/store/postgres.js +60 -9
  323. package/dist/store/replay.d.ts +102 -1
  324. package/dist/store/replay.js +190 -19
  325. package/dist/store/reseed.d.ts +238 -0
  326. package/dist/store/reseed.js +308 -0
  327. package/dist/store/schema.d.ts +762 -2
  328. package/dist/store/schema.js +218 -5
  329. package/dist/store/source.d.ts +57 -1
  330. package/dist/store/source.js +65 -1
  331. package/dist/store/store.d.ts +29 -6
  332. package/dist/submit/resolve.d.ts +1 -1
  333. package/dist/submit/resolve.js +2 -1
  334. package/dist/telemetry/calibration.d.ts +25 -0
  335. package/dist/telemetry/calibration.js +27 -1
  336. package/dist/telemetry/event.d.ts +391 -33
  337. package/dist/telemetry/event.js +84 -20
  338. package/dist/telemetry/index.d.ts +2 -0
  339. package/dist/telemetry/index.js +2 -0
  340. package/dist/telemetry/journal.d.ts +104 -3
  341. package/dist/telemetry/journal.js +9 -0
  342. package/dist/telemetry/lookup.d.ts +27 -0
  343. package/dist/telemetry/lookup.js +18 -0
  344. package/dist/telemetry/memory.js +33 -1
  345. package/dist/telemetry/migrate.js +22 -1
  346. package/dist/telemetry/postgres.d.ts +10 -1
  347. package/dist/telemetry/postgres.js +188 -90
  348. package/dist/telemetry/remeasure.d.ts +78 -0
  349. package/dist/telemetry/remeasure.js +83 -0
  350. package/dist/telemetry/retention.d.ts +2 -2
  351. package/dist/telemetry/schema.d.ts +17 -0
  352. package/dist/telemetry/schema.js +27 -1
  353. package/dist/telemetry/sink.d.ts +2 -2
  354. package/dist/telemetry/window.d.ts +135 -0
  355. package/dist/telemetry/window.js +101 -0
  356. package/dist/testing/application-contract.d.ts +14 -0
  357. package/dist/testing/application-contract.js +270 -0
  358. package/dist/testing/audience-overlay-contract.d.ts +31 -0
  359. package/dist/testing/audience-overlay-contract.js +354 -0
  360. package/dist/testing/contracts.d.ts +13 -7
  361. package/dist/testing/contracts.js +13 -7
  362. package/dist/testing/definitions.d.ts +78 -0
  363. package/dist/testing/definitions.js +134 -9
  364. package/dist/testing/doubles.d.ts +103 -0
  365. package/dist/testing/doubles.js +143 -0
  366. package/dist/testing/index.d.ts +2 -2
  367. package/dist/testing/index.js +2 -2
  368. package/dist/testing/journal-contract.js +297 -6
  369. package/dist/testing/model-contract.d.ts +110 -0
  370. package/dist/testing/model-contract.js +150 -0
  371. package/dist/testing/policy-log-contract.d.ts +26 -0
  372. package/dist/testing/policy-log-contract.js +344 -0
  373. package/dist/testing/project-contract.d.ts +14 -0
  374. package/dist/testing/project-contract.js +266 -0
  375. package/dist/testing/reader-signal-contract.d.ts +27 -2
  376. package/dist/testing/reader-signal-contract.js +475 -5
  377. package/dist/testing/store-contract.d.ts +7 -1
  378. package/dist/testing/store-contract.js +84 -3
  379. package/dist/theme/apply.d.ts +20 -1
  380. package/dist/theme/apply.js +5 -3
  381. package/dist/theme/contrast.d.ts +19 -14
  382. package/dist/theme/contrast.js +181 -17
  383. package/dist/theme/derive.d.ts +22 -0
  384. package/dist/theme/derive.js +54 -1
  385. package/dist/theme/library.js +1 -1
  386. package/dist/theme/measure.d.ts +34 -0
  387. package/dist/theme/measure.js +30 -1
  388. package/dist/theme/palettes.js +7 -7
  389. package/dist/theme/ramp.d.ts +64 -0
  390. package/dist/theme/ramp.js +114 -0
  391. package/dist/theme/registry.d.ts +9 -0
  392. package/dist/theme/registry.js +11 -1
  393. package/dist/theme/separation.d.ts +97 -3
  394. package/dist/theme/separation.js +75 -0
  395. package/dist/tree/apply.js +13 -0
  396. package/dist/tree/compare.d.ts +9 -0
  397. package/dist/tree/compare.js +18 -0
  398. package/dist/tree/mutation.d.ts +18 -0
  399. package/dist/tree/mutation.js +24 -12
  400. package/dist/tree/navigation.d.ts +5 -0
  401. package/dist/tree/navigation.js +32 -10
  402. package/dist/tree/outline.d.ts +7 -0
  403. package/dist/tree/outline.js +9 -5
  404. package/dist/write/computed.d.ts +60 -0
  405. package/dist/write/computed.js +61 -0
  406. package/dist/write/held.d.ts +59 -0
  407. package/dist/write/index.d.ts +5 -2
  408. package/dist/write/index.js +5 -2
  409. package/dist/write/reseed.d.ts +151 -0
  410. package/dist/write/reseed.js +184 -0
  411. package/dist/write/revert.js +2 -16
  412. package/package.json +25 -3
  413. package/dist/runtime/inverse-interpreter.d.ts +0 -90
  414. package/dist/runtime/inverse-interpreter.js +0 -56
@@ -0,0 +1,564 @@
1
+ import { everyMemberOf } from "../closed-set.js";
2
+ import { PRIMITIVE_ROLES } from "../role.js";
3
+ import { inFormOrder } from "./audiences.js";
4
+ import { copyChangeOf, spokenForOnBothSides } from "./copy-change.js";
5
+ import { kindKeyOf } from "./library.js";
6
+ import { partsByNodeIn } from "./library-change.js";
7
+ import { inUnscaledSideOrder, readerShareCauseOf, librarySideOf, weightMovedOver, } from "./library-reach-change.js";
8
+ export const KIND_WORD_REACH_CHANGE_SILENCES = everyMemberOf()([
9
+ "unplaced",
10
+ "unpaired",
11
+ "wordless",
12
+ "unread",
13
+ "unscaled",
14
+ "unopened",
15
+ "uncounted",
16
+ "floored",
17
+ ]);
18
+ /** One line per silence, for a surface saying why a kind has no before and after. */
19
+ export const describeKindWordReachChangeSilence = (silence) => {
20
+ switch (silence) {
21
+ case "unplaced":
22
+ return "nothing in the pages read, in either window, is of this kind";
23
+ case "unpaired":
24
+ return "no place this kind of part stands is in both windows";
25
+ case "wordless":
26
+ return "no place it stands in both windows carries a passage both revisions say alike";
27
+ case "unread":
28
+ return "no word it kept can be spoken for in both windows";
29
+ case "unscaled":
30
+ return "a page it stands on has no page views counted at the door in one of the two windows";
31
+ case "unopened":
32
+ return "a page it stands on has a row and nothing has said a page view began";
33
+ case "uncounted":
34
+ return "a page it stands on has readers in one window whose reading has not been counted yet";
35
+ case "floored":
36
+ return "some word it kept is a floor, so the movement cannot be signed";
37
+ }
38
+ };
39
+ export const KIND_WORD_REACH_MOVEMENTS = everyMemberOf()([
40
+ "taken-up",
41
+ "abandoned",
42
+ "held",
43
+ "still-unread",
44
+ "unknown",
45
+ ]);
46
+ /** One line per movement, for a surface putting a kind's words in front of a person. */
47
+ export const describeKindWordReachMovement = (movement) => {
48
+ switch (movement) {
49
+ case "taken-up":
50
+ return "the typical reader who met it reaches more of its words now";
51
+ case "abandoned":
52
+ return "the typical reader who met it reaches fewer of its words now";
53
+ case "held":
54
+ return "the typical reader who met it reaches exactly as many of its words";
55
+ case "still-unread":
56
+ return "no reader reached a word it kept, in either window";
57
+ case "unknown":
58
+ return "nothing can be said about what changed";
59
+ }
60
+ };
61
+ const counting = () => ({
62
+ passages: 0,
63
+ carried: 0,
64
+ spoken: 0,
65
+ comparable: 0,
66
+ unspoken: 0,
67
+ floored: 0,
68
+ flooredWords: 0,
69
+ countedWas: 0,
70
+ countedNow: 0,
71
+ reachedWas: 0,
72
+ reachedNow: 0,
73
+ heldTraffic: 0,
74
+ heldReading: 0,
75
+ weights: [],
76
+ driftWas: 0,
77
+ driftNow: 0,
78
+ pendingWas: 0,
79
+ pendingNow: 0,
80
+ unreconciled: 0,
81
+ blocked: null,
82
+ });
83
+ const tallying = (kind) => ({
84
+ kind,
85
+ role: null,
86
+ places: 0,
87
+ gained: 0,
88
+ lost: 0,
89
+ rewritten: 0,
90
+ pages: new Set(),
91
+ ...counting(),
92
+ });
93
+ /** The two keys one placement is counted under, which is the pair of questions this answers. */
94
+ const keysOf = (of) => [
95
+ { by: "type", type: of.type },
96
+ { by: "role", role: of.role },
97
+ ];
98
+ /**
99
+ * The keys a paired placement is held still under.
100
+ *
101
+ * A placement is carried under a key only where it is of that kind on **both**
102
+ * sides, which is where the two keys answer differently: a node recast into
103
+ * another type is a place one type left and another took, while the role rows
104
+ * hold it still wherever the two types play the same part (0266).
105
+ */
106
+ const heldKeysOf = (before, after) => [
107
+ ...(before.type === after.type ? [{ by: "type", type: after.type }] : []),
108
+ ...(before.role === after.role ? [{ by: "role", role: after.role }] : []),
109
+ ];
110
+ const rowFor = (rows, kind) => {
111
+ const key = kindKeyOf(kind);
112
+ const row = rows.get(key) ?? tallying(kind);
113
+ rows.set(key, row);
114
+ return row;
115
+ };
116
+ /** The kind-level reason a page's reason causes, which is the same state at the other subject. */
117
+ const KIND_WORD_REACH_CHANGE_OF_REACH = Object.freeze({
118
+ unmeasured: "unscaled",
119
+ unopened: "unopened",
120
+ uncounted: "uncounted",
121
+ });
122
+ /**
123
+ * The silence, with the reasons tried in the order they have to be tried in.
124
+ *
125
+ * Nothing of the kind first, because *there is no such part in this library* is
126
+ * a better answer than anything said about its words. Then nothing held still,
127
+ * then nothing carried, because a kind whose every word was rewritten is a fact
128
+ * about the change and would otherwise be reported as nobody having read it.
129
+ * Then nothing spoken for, because a kind no window can speak for has no figure
130
+ * whether or not its pages could be scaled. The door next, and the floor last,
131
+ * because it is the only one of the eight that withholds some figures rather
132
+ * than the whole row.
133
+ */
134
+ const silenceOf = (of) => {
135
+ if (of.places + of.gained + of.lost === 0)
136
+ return "unplaced";
137
+ if (of.places === 0)
138
+ return "unpaired";
139
+ if (of.passages === 0)
140
+ return "wordless";
141
+ if (of.spoken === 0)
142
+ return "unread";
143
+ if (of.blocked !== null)
144
+ return KIND_WORD_REACH_CHANGE_OF_REACH[of.blocked];
145
+ return of.floored > 0 ? "floored" : null;
146
+ };
147
+ const figuresOf = (of) => {
148
+ const measured = of.spoken > 0 && of.blocked === null;
149
+ return {
150
+ measured,
151
+ signed: measured && of.floored === 0,
152
+ typicalWas: of.reachedWas / of.countedWas,
153
+ typicalNow: of.reachedNow / of.countedNow,
154
+ ifTrafficHeld: of.heldTraffic / of.countedWas,
155
+ ifReadingHeld: of.heldReading / of.countedNow,
156
+ };
157
+ };
158
+ const wordsOf = (of, figures) => ({
159
+ passages: of.passages,
160
+ carried: of.carried,
161
+ spoken: of.spoken,
162
+ comparable: of.comparable,
163
+ unspoken: of.unspoken,
164
+ floored: of.floored,
165
+ flooredWords: of.flooredWords,
166
+ countedWas: figures.measured ? of.countedWas : null,
167
+ countedNow: figures.measured ? of.countedNow : null,
168
+ reachedWas: figures.measured ? of.reachedWas : null,
169
+ reachedNow: figures.measured ? of.reachedNow : null,
170
+ typicalWas: figures.measured ? figures.typicalWas : null,
171
+ typicalNow: figures.measured ? figures.typicalNow : null,
172
+ shift: figures.signed ? figures.typicalNow - figures.typicalWas : null,
173
+ wordsMoved: figures.signed ? (figures.typicalNow - figures.typicalWas) * of.countedNow : null,
174
+ ifTrafficHeld: figures.signed ? figures.ifTrafficHeld : null,
175
+ ifReadingHeld: figures.signed ? figures.ifReadingHeld : null,
176
+ weightMoved: figures.measured
177
+ ? weightMovedOver(of.weights, { was: of.countedWas, now: of.countedNow })
178
+ : null,
179
+ driftWas: of.driftWas,
180
+ driftNow: of.driftNow,
181
+ pendingWas: of.pendingWas,
182
+ pendingNow: of.pendingNow,
183
+ unreconciled: of.unreconciled,
184
+ exact: figures.signed &&
185
+ of.driftWas === 0 &&
186
+ of.driftNow === 0 &&
187
+ of.pendingWas === 0 &&
188
+ of.pendingNow === 0 &&
189
+ of.unreconciled === 0,
190
+ });
191
+ /**
192
+ * The verdict, off the two levels and never off the two masses.
193
+ *
194
+ * The opposite of the places comparison's rule and for the opposite reason
195
+ * (0266): there the denominator is the same count of places on both sides, so
196
+ * the sign of a subtraction of two whole numbers is the whole answer. Here the
197
+ * two denominators are two windows' traffic, so the levels are the only
198
+ * comparable pair and the subtraction has to be done on them.
199
+ */
200
+ const movementOf = (of, figures) => {
201
+ if (!figures.signed)
202
+ return "unknown";
203
+ if (of.reachedWas === 0 && of.reachedNow === 0)
204
+ return "still-unread";
205
+ if (figures.typicalNow > figures.typicalWas)
206
+ return "taken-up";
207
+ if (figures.typicalNow < figures.typicalWas)
208
+ return "abandoned";
209
+ return "held";
210
+ };
211
+ const rowOf = (of) => {
212
+ const figures = figuresOf(of);
213
+ return {
214
+ kind: of.kind,
215
+ role: of.kind.by === "type" ? of.role : null,
216
+ places: of.places,
217
+ gained: of.gained,
218
+ lost: of.lost,
219
+ rewritten: of.rewritten,
220
+ pages: of.pages.size,
221
+ words: wordsOf(of, figures),
222
+ movement: movementOf(of, figures),
223
+ cause: figures.signed
224
+ ? readerShareCauseOf(figures.typicalWas, figures.typicalNow, figures.ifTrafficHeld, figures.ifReadingHeld)
225
+ : null,
226
+ silence: silenceOf(of),
227
+ };
228
+ };
229
+ /** The name a row is ordered by, which is the key's own and never the row's position. */
230
+ const nameOf = (kind) => (kind.by === "type" ? kind.type : (kind.role ?? ""));
231
+ /**
232
+ * The worse of two, which is the ranking rule spelled once.
233
+ *
234
+ * Most reader-words lost, then the lower figure now, then by name. A kind with
235
+ * no figures at all sorts after every kind that has them — infinity rather than
236
+ * a nought, because `null` is *nothing can be said* and a nought would rank a
237
+ * withheld row among the kinds that merely held.
238
+ */
239
+ const worseOf = (one, other) => (one.words.wordsMoved ?? Number.POSITIVE_INFINITY) -
240
+ (other.words.wordsMoved ?? Number.POSITIVE_INFINITY) ||
241
+ (one.words.typicalNow ?? Number.POSITIVE_INFINITY) -
242
+ (other.words.typicalNow ?? Number.POSITIVE_INFINITY) ||
243
+ nameOf(one.kind).localeCompare(nameOf(other.kind));
244
+ /**
245
+ * One carried passage's words, filed under what can be said about them.
246
+ *
247
+ * Returns whether the passage's readers belong in a mass, which is true only
248
+ * where both windows can speak for it and both doors can scale its page.
249
+ */
250
+ const bank = (into, passage, spoken, doors, unreconciled) => {
251
+ into.passages += 1;
252
+ into.carried += passage.words;
253
+ if (!spoken) {
254
+ into.unspoken += passage.words;
255
+ return false;
256
+ }
257
+ into.spoken += 1;
258
+ into.comparable += passage.words;
259
+ if (passage.floored) {
260
+ into.floored += 1;
261
+ into.flooredWords += passage.words;
262
+ }
263
+ if (doors.was.silence !== null || doors.now.silence !== null) {
264
+ into.blocked ??= doors.was.silence ?? doors.now.silence;
265
+ return false;
266
+ }
267
+ if (unreconciled)
268
+ into.unreconciled += 1;
269
+ return true;
270
+ };
271
+ /**
272
+ * One page's mass put on the door's scale, added once per page.
273
+ *
274
+ * `mass × counted ÷ appearances`, in that order, because it is the published
275
+ * order of a share of readers (0256): a surface drawing this beside a figure
276
+ * taken the other way round is drawing the same number, and three floats
277
+ * multiplied and divided in two orders agree to fifteen places and not to
278
+ * sixteen.
279
+ */
280
+ const weigh = (into, mass, doors) => {
281
+ into.countedWas += doors.was.counted;
282
+ into.countedNow += doors.now.counted;
283
+ into.reachedWas += (mass.was * doors.was.counted) / doors.was.appearances;
284
+ into.reachedNow += (mass.now * doors.now.counted) / doors.now.appearances;
285
+ /** The same term with the other side's weight, which is the whole of a counterfactual. */
286
+ into.heldTraffic += (mass.now * doors.was.counted) / doors.now.appearances;
287
+ into.heldReading += (mass.was * doors.now.counted) / doors.was.appearances;
288
+ into.weights.push({ was: doors.was.counted, now: doors.now.counted });
289
+ into.driftWas += doors.was.drift;
290
+ into.driftNow += doors.now.drift;
291
+ into.pendingWas += doors.was.pending;
292
+ into.pendingNow += doors.now.pending;
293
+ };
294
+ const massFor = (masses, into) => {
295
+ const mass = masses.get(into) ?? { was: 0, now: 0 };
296
+ masses.set(into, mass);
297
+ return mass;
298
+ };
299
+ /**
300
+ * The words of a kind of part the typical reader who met it reached, before and
301
+ * after.
302
+ *
303
+ * Takes each window as its readings and the whole window of door rows a
304
+ * deployment holds for it, because the figure needs the door on both sides: the
305
+ * pages are paired by the places comparison's rule (0266) and each page's mass
306
+ * is put on its own door's scale by a share of readers' rule (0256).
307
+ *
308
+ * The labels are the caller's. Two readings of one window and one library come
309
+ * back as every word carried, both levels identical and nothing gained, lost or
310
+ * rewritten; a caller who holds the two sides backwards gets a comparison with
311
+ * every movement reversed rather than a refusal, exactly as a before-and-after
312
+ * reading of one page does.
313
+ *
314
+ * Linear in the parts of the readings times the rows, with one comparison per
315
+ * paired page.
316
+ */
317
+ export const libraryWordReachChangeOf = (was, now) => {
318
+ const earlier = librarySideOf(was);
319
+ const later = librarySideOf(now);
320
+ const rows = new Map();
321
+ const roleWas = new Map();
322
+ const roleNow = new Map();
323
+ const ambiguous = new Map([...earlier.pages.ambiguous, ...later.pages.ambiguous]);
324
+ const unscaled = [];
325
+ const whole = counting();
326
+ let pages = 0;
327
+ let pagesGained = 0;
328
+ let pagesLost = 0;
329
+ let formsGained = 0;
330
+ let formsLost = 0;
331
+ let republished = 0;
332
+ let placements = 0;
333
+ let gained = 0;
334
+ let lost = 0;
335
+ let recast = 0;
336
+ let rewritten = 0;
337
+ let arrivalsWas = 0;
338
+ let arrivalsNow = 0;
339
+ let scaled = 0;
340
+ /**
341
+ * Every role in the vocabulary gets a row whether or not anything plays it,
342
+ * as a census's role rows do: a role nothing in the library plays is a fact
343
+ * about the library, and a surface that had to tell a missing row from an
344
+ * empty one would be reading the vocabulary itself.
345
+ */
346
+ for (const role of [...PRIMITIVE_ROLES, null])
347
+ rowFor(rows, { by: "role", role });
348
+ for (const [form, reading] of earlier.pages.byForm) {
349
+ if (ambiguous.has(form))
350
+ continue;
351
+ for (const part of reading.parts) {
352
+ roleWas.set(part.type, part.role);
353
+ rowFor(rows, { by: "type", type: part.type }).role = part.role;
354
+ }
355
+ if (later.pages.byForm.has(form))
356
+ continue;
357
+ pagesLost += 1;
358
+ /** The page is still served, in the other form: a form left the library and the page did not (0295). */
359
+ if (later.pages.pagesHeld.has(reading.treeId))
360
+ formsLost += 1;
361
+ for (const part of reading.parts) {
362
+ lost += 1;
363
+ for (const kind of keysOf(part))
364
+ rowFor(rows, kind).lost += 1;
365
+ }
366
+ }
367
+ for (const [form, reading] of later.pages.byForm) {
368
+ if (ambiguous.has(form))
369
+ continue;
370
+ for (const part of reading.parts) {
371
+ roleNow.set(part.type, part.role);
372
+ rowFor(rows, { by: "type", type: part.type }).role = part.role;
373
+ }
374
+ if (earlier.pages.byForm.has(form))
375
+ continue;
376
+ pagesGained += 1;
377
+ /** The page was already served, in the other form: a second form began rather than a page being published. */
378
+ if (earlier.pages.pagesHeld.has(reading.treeId))
379
+ formsGained += 1;
380
+ for (const part of reading.parts) {
381
+ gained += 1;
382
+ for (const kind of keysOf(part))
383
+ rowFor(rows, kind).gained += 1;
384
+ }
385
+ }
386
+ for (const [form, before] of earlier.pages.byForm) {
387
+ const after = later.pages.byForm.get(form);
388
+ const doorWas = earlier.scaled.get(form);
389
+ const doorNow = later.scaled.get(form);
390
+ if (after === undefined || doorWas === undefined || doorNow === undefined)
391
+ continue;
392
+ if (ambiguous.has(form))
393
+ continue;
394
+ const beforeParts = partsByNodeIn(before);
395
+ const afterParts = partsByNodeIn(after);
396
+ const doors = { was: doorWas.door, now: doorNow.door };
397
+ const masses = new Map();
398
+ let spokenFor = false;
399
+ pages += 1;
400
+ republished += before.revision === after.revision ? 0 : 1;
401
+ arrivalsWas += doors.was.opened;
402
+ arrivalsNow += doors.now.opened;
403
+ if (doors.was.silence === null && doors.now.silence === null)
404
+ scaled += 1;
405
+ for (const part of before.parts) {
406
+ const counterpart = afterParts.get(part.nodeId);
407
+ if (counterpart === undefined) {
408
+ lost += 1;
409
+ for (const kind of keysOf(part))
410
+ rowFor(rows, kind).lost += 1;
411
+ continue;
412
+ }
413
+ if (part.type === counterpart.type) {
414
+ placements += 1;
415
+ }
416
+ else {
417
+ recast += 1;
418
+ lost += 1;
419
+ gained += 1;
420
+ rowFor(rows, { by: "type", type: part.type }).lost += 1;
421
+ rowFor(rows, { by: "type", type: counterpart.type }).gained += 1;
422
+ }
423
+ if (part.role !== counterpart.role) {
424
+ rowFor(rows, { by: "role", role: part.role }).lost += 1;
425
+ rowFor(rows, { by: "role", role: counterpart.role }).gained += 1;
426
+ }
427
+ for (const kind of heldKeysOf(part, counterpart))
428
+ rowFor(rows, kind).places += 1;
429
+ }
430
+ for (const part of after.parts) {
431
+ if (beforeParts.has(part.nodeId))
432
+ continue;
433
+ gained += 1;
434
+ for (const kind of keysOf(part))
435
+ rowFor(rows, kind).gained += 1;
436
+ }
437
+ const change = copyChangeOf(before, after);
438
+ for (const passage of change.reworded) {
439
+ const part = beforeParts.get(passage.nodeId);
440
+ /**
441
+ * A reworded passage is a node both readings hold, so the earlier part is
442
+ * always there. Skipped rather than thrown, as every join in this
443
+ * subsystem is: a row that cannot be built cannot be drawn, and a reading
444
+ * is not worth failing over.
445
+ */
446
+ if (part === undefined)
447
+ continue;
448
+ if (part.type === passage.type)
449
+ rewritten += 1;
450
+ for (const kind of heldKeysOf(part, passage))
451
+ rowFor(rows, kind).rewritten += 1;
452
+ }
453
+ for (const passage of change.compared) {
454
+ const part = beforeParts.get(passage.nodeId);
455
+ if (part === undefined)
456
+ continue;
457
+ const spoken = spokenForOnBothSides(passage);
458
+ const unreconciled = passage.was.readers > doors.was.appearances ||
459
+ passage.now.readers > doors.now.appearances;
460
+ spokenFor ||= spoken;
461
+ for (const kind of heldKeysOf(part, passage)) {
462
+ const row = rowFor(rows, kind);
463
+ const banked = bank(row, passage, spoken, doors, unreconciled);
464
+ /**
465
+ * A page bearing a word both windows can speak for is one of this
466
+ * kind's pages whether or not the door could scale it, so that a
467
+ * withheld row still says how much is behind the figure it is not
468
+ * publishing.
469
+ */
470
+ /**
471
+ * The form and not the tree, for the reason the pairing is per form:
472
+ * counting two forms of a page as one page would understate a kind's
473
+ * pages by exactly the pages a deployment serves twice.
474
+ */
475
+ if (spoken)
476
+ row.pages.add(form);
477
+ if (!banked)
478
+ continue;
479
+ const mass = massFor(masses, row);
480
+ mass.was += passage.was.readers * passage.words;
481
+ mass.now += passage.now.readers * passage.words;
482
+ }
483
+ /**
484
+ * The whole library takes each passage once and never once per key, and
485
+ * takes no recast place at all: a node whose type changed is a place one
486
+ * kind left and another took, so its words are carried by neither.
487
+ */
488
+ if (part.type !== passage.type)
489
+ continue;
490
+ if (!bank(whole, passage, spoken, doors, unreconciled))
491
+ continue;
492
+ const mass = massFor(masses, whole);
493
+ mass.was += passage.was.readers * passage.words;
494
+ mass.now += passage.now.readers * passage.words;
495
+ }
496
+ for (const [into, mass] of masses)
497
+ weigh(into, mass, doors);
498
+ /**
499
+ * A page the door cannot scale is listed once per side it is unscalable on,
500
+ * and only where a window could speak for a word on it: a page nobody read
501
+ * in either window is not a page whose readers could not be counted, and
502
+ * listing it would put the commonest healthy state on the one list here
503
+ * that is meant to be empty.
504
+ */
505
+ if (spokenFor) {
506
+ if (doors.was.silence !== null) {
507
+ unscaled.push({
508
+ treeId: before.treeId,
509
+ revision: before.revision,
510
+ audienceId: before.audienceId,
511
+ against: after.revision,
512
+ side: "was",
513
+ silence: doors.was.silence,
514
+ });
515
+ }
516
+ if (doors.now.silence !== null) {
517
+ unscaled.push({
518
+ treeId: after.treeId,
519
+ revision: after.revision,
520
+ audienceId: after.audienceId,
521
+ against: before.revision,
522
+ side: "now",
523
+ silence: doors.now.silence,
524
+ });
525
+ }
526
+ }
527
+ }
528
+ const built = [...rows.values()].map(rowOf);
529
+ const byType = built.filter((row) => row.kind.by === "type").sort(worseOf);
530
+ const disagreed = [...roleNow.keys()]
531
+ .filter((type) => roleWas.has(type) && roleWas.get(type) !== roleNow.get(type))
532
+ .sort((one, other) => one.localeCompare(other));
533
+ return {
534
+ byType,
535
+ byRole: built.filter((row) => row.kind.by === "role").sort(worseOf),
536
+ words: wordsOf(whole, figuresOf(whole)),
537
+ pages,
538
+ pagesGained,
539
+ formsGained,
540
+ pagesLost,
541
+ formsLost,
542
+ audiences: { was: earlier.pages.audiences, now: later.pages.audiences },
543
+ republished,
544
+ placements,
545
+ gained,
546
+ lost,
547
+ recast,
548
+ rewritten,
549
+ arrivalsWas,
550
+ arrivalsNow,
551
+ scaled,
552
+ unscaled: [...unscaled].sort(inUnscaledSideOrder),
553
+ mostAbandoned: byType.find((row) => (row.words.wordsMoved ?? 0) < 0) ?? null,
554
+ mostTakenUp: byType
555
+ .filter((row) => (row.words.wordsMoved ?? 0) > 0)
556
+ .sort((one, other) => (other.words.wordsMoved ?? 0) - (one.words.wordsMoved ?? 0) ||
557
+ nameOf(one.kind).localeCompare(nameOf(other.kind)))[0] ?? null,
558
+ ambiguous: [...ambiguous.values()].sort(inFormOrder),
559
+ duplicated: earlier.pages.duplicated + later.pages.duplicated,
560
+ duplicatedRows: earlier.duplicatedRows + later.duplicatedRows,
561
+ roleDisagreed: disagreed,
562
+ };
563
+ };
564
+ //# sourceMappingURL=library-word-reach-change.js.map