@jam-overture/loom 0.1.0 → 0.2.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.
- package/README.md +3 -1
- package/dist/application/application.d.ts +109 -0
- package/dist/application/application.js +97 -0
- package/dist/application/memory.d.ts +20 -0
- package/dist/application/memory.js +79 -0
- package/dist/application/store.d.ts +101 -0
- package/dist/application/store.js +25 -0
- package/dist/audience/audience.d.ts +36 -0
- package/dist/audience/audience.js +41 -0
- package/dist/cli/templates.js +19 -0
- package/dist/data/plan.js +0 -0
- package/dist/data/resolution.d.ts +23 -1
- package/dist/data/resolve.d.ts +30 -3
- package/dist/data/resolve.js +11 -3
- package/dist/ids.d.ts +10 -0
- package/dist/ids.js +11 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/patch.d.ts +54 -0
- package/dist/patch.js +44 -0
- package/dist/project/closing.d.ts +51 -0
- package/dist/project/closing.js +53 -0
- package/dist/project/memory.d.ts +20 -0
- package/dist/project/memory.js +97 -0
- package/dist/project/project.d.ts +90 -0
- package/dist/project/project.js +91 -0
- package/dist/project/store.d.ts +135 -0
- package/dist/project/store.js +41 -0
- package/dist/registered.d.ts +64 -0
- package/dist/registered.js +118 -0
- package/dist/render/behaviour-adjust.d.ts +11 -19
- package/dist/render/behaviour-adjust.js +75 -21
- package/dist/render/behaviour-present.d.ts +8 -0
- package/dist/render/behaviour-present.js +57 -6
- package/dist/render/behaviour.d.ts +98 -17
- package/dist/render/behaviour.js +91 -26
- package/dist/render/control-name.d.ts +68 -0
- package/dist/render/control-name.js +37 -0
- package/dist/render/diagnostics.d.ts +72 -0
- package/dist/render/diagnostics.js +7 -0
- package/dist/render/index.d.ts +2 -0
- package/dist/render/index.js +2 -0
- package/dist/render/reads.d.ts +11 -0
- package/dist/render/reads.js +12 -1
- package/dist/render/render.js +102 -7
- package/dist/render/slots.d.ts +52 -0
- package/dist/render/slots.js +24 -0
- package/dist/render/theme.d.ts +54 -1
- package/dist/render/theme.js +23 -1
- package/dist/render/unshown.d.ts +152 -0
- package/dist/render/unshown.js +80 -0
- package/dist/runtime/analysis.d.ts +94 -9
- package/dist/runtime/analysis.js +54 -9
- package/dist/runtime/assessment.d.ts +36 -2
- package/dist/runtime/assessment.js +27 -2
- package/dist/runtime/checks.d.ts +148 -0
- package/dist/runtime/checks.js +112 -0
- package/dist/runtime/disposition.d.ts +96 -0
- package/dist/runtime/disposition.js +46 -0
- package/dist/runtime/gate.js +22 -0
- package/dist/runtime/index.d.ts +3 -0
- package/dist/runtime/index.js +3 -0
- package/dist/runtime/irreversibility.d.ts +64 -0
- package/dist/runtime/irreversibility.js +45 -0
- package/dist/runtime/pipeline.d.ts +43 -0
- package/dist/runtime/pipeline.js +10 -2
- package/dist/runtime/policy-change.d.ts +93 -0
- package/dist/runtime/policy-change.js +299 -0
- package/dist/runtime/policy-log.d.ts +406 -0
- package/dist/runtime/policy-log.js +285 -0
- package/dist/runtime/reversibility.d.ts +11 -9
- package/dist/runtime/stakes.d.ts +129 -1
- package/dist/runtime/stakes.js +240 -26
- package/dist/runtime/vocabulary.d.ts +164 -7
- package/dist/runtime/vocabulary.js +181 -8
- package/dist/sdk/audit.d.ts +174 -3
- package/dist/sdk/audit.js +176 -17
- package/dist/sdk/catalogue.d.ts +9 -1
- package/dist/sdk/conformance.d.ts +37 -3
- package/dist/sdk/conformance.js +25 -4
- package/dist/sdk/definition.d.ts +65 -0
- package/dist/sdk/definition.js +22 -0
- package/dist/sdk/registry.d.ts +29 -2
- package/dist/sdk/registry.js +63 -1
- package/dist/signals/action-change.d.ts +507 -0
- package/dist/signals/action-change.js +265 -0
- package/dist/signals/action.d.ts +331 -0
- package/dist/signals/action.js +182 -0
- package/dist/signals/applied-window.contract.d.ts +23 -0
- package/dist/signals/applied-window.contract.js +160 -0
- package/dist/signals/arriving.d.ts +210 -0
- package/dist/signals/arriving.js +133 -0
- package/dist/signals/audiences.d.ts +528 -0
- package/dist/signals/audiences.js +255 -0
- package/dist/signals/broadcast.d.ts +8 -2
- package/dist/signals/broadcast.js +58 -8
- package/dist/signals/change.d.ts +378 -0
- package/dist/signals/change.js +327 -0
- package/dist/signals/collect.d.ts +41 -0
- package/dist/signals/collect.js +88 -7
- package/dist/signals/copy-change.d.ts +553 -0
- package/dist/signals/copy-change.js +377 -0
- package/dist/signals/copy.d.ts +337 -0
- package/dist/signals/copy.js +211 -0
- package/dist/signals/counters.d.ts +46 -0
- package/dist/signals/counters.js +102 -0
- package/dist/signals/deliver.d.ts +23 -4
- package/dist/signals/deliver.js +34 -6
- package/dist/signals/deployment-change.d.ts +371 -0
- package/dist/signals/deployment-change.js +268 -0
- package/dist/signals/deployment.d.ts +265 -0
- package/dist/signals/deployment.js +152 -0
- package/dist/signals/door.d.ts +92 -0
- package/dist/signals/door.js +53 -0
- package/dist/signals/fold.d.ts +10 -0
- package/dist/signals/fold.js +5 -1
- package/dist/signals/form-action.d.ts +302 -0
- package/dist/signals/form-action.js +169 -0
- package/dist/signals/form-copy.d.ts +523 -0
- package/dist/signals/form-copy.js +346 -0
- package/dist/signals/forms.d.ts +247 -0
- package/dist/signals/forms.js +147 -0
- package/dist/signals/funnel-change.d.ts +548 -0
- package/dist/signals/funnel-change.js +361 -0
- package/dist/signals/funnel.d.ts +532 -0
- package/dist/signals/funnel.js +216 -0
- package/dist/signals/health.d.ts +497 -0
- package/dist/signals/health.js +361 -0
- package/dist/signals/index.d.ts +41 -0
- package/dist/signals/index.js +41 -0
- package/dist/signals/ingest.d.ts +56 -1
- package/dist/signals/ingest.js +91 -1
- package/dist/signals/journal.d.ts +11 -0
- package/dist/signals/kinds.d.ts +8 -6
- package/dist/signals/kinds.js +14 -6
- package/dist/signals/library-action.d.ts +430 -0
- package/dist/signals/library-action.js +336 -0
- package/dist/signals/library-change.d.ts +477 -0
- package/dist/signals/library-change.js +335 -0
- package/dist/signals/library-copy-change.d.ts +498 -0
- package/dist/signals/library-copy-change.js +476 -0
- package/dist/signals/library-pace.d.ts +319 -0
- package/dist/signals/library-pace.js +305 -0
- package/dist/signals/library-reach-change.d.ts +636 -0
- package/dist/signals/library-reach-change.js +534 -0
- package/dist/signals/library-reach.d.ts +377 -0
- package/dist/signals/library-reach.js +227 -0
- package/dist/signals/library-word-reach-change.d.ts +567 -0
- package/dist/signals/library-word-reach-change.js +568 -0
- package/dist/signals/library.d.ts +306 -0
- package/dist/signals/library.js +178 -0
- package/dist/signals/memory.d.ts +9 -0
- package/dist/signals/memory.js +105 -14
- package/dist/signals/migrate.d.ts +17 -2
- package/dist/signals/migrate.js +122 -5
- package/dist/signals/notice.d.ts +334 -0
- package/dist/signals/notice.js +228 -0
- package/dist/signals/pace-change.d.ts +501 -0
- package/dist/signals/pace-change.js +310 -0
- package/dist/signals/pace.d.ts +296 -0
- package/dist/signals/pace.js +291 -0
- package/dist/signals/page-views.d.ts +365 -0
- package/dist/signals/page-views.js +218 -0
- package/dist/signals/parts.d.ts +344 -0
- package/dist/signals/parts.js +273 -0
- package/dist/signals/postgres.d.ts +16 -2
- package/dist/signals/postgres.js +390 -87
- package/dist/signals/progress.d.ts +212 -0
- package/dist/signals/progress.js +150 -0
- package/dist/signals/ratios.d.ts +108 -0
- package/dist/signals/ratios.js +40 -0
- package/dist/signals/reach.d.ts +309 -0
- package/dist/signals/reach.js +93 -0
- package/dist/signals/readable.d.ts +34 -0
- package/dist/signals/readable.js +34 -0
- package/dist/signals/readership.d.ts +381 -0
- package/dist/signals/readership.js +308 -0
- package/dist/signals/region-pages.d.ts +173 -0
- package/dist/signals/region-pages.js +62 -0
- package/dist/signals/region.d.ts +287 -0
- package/dist/signals/region.js +198 -0
- package/dist/signals/retention.d.ts +141 -0
- package/dist/signals/retention.js +58 -0
- package/dist/signals/rollup.d.ts +67 -3
- package/dist/signals/rollup.js +0 -0
- package/dist/signals/schema.d.ts +432 -1
- package/dist/signals/schema.js +157 -3
- package/dist/signals/signal.d.ts +237 -11
- package/dist/signals/signal.js +70 -10
- package/dist/signals/silence-census.d.ts +205 -0
- package/dist/signals/silence-census.js +87 -0
- package/dist/signals/silences.d.ts +848 -0
- package/dist/signals/silences.js +753 -0
- package/dist/signals/tally.d.ts +140 -11
- package/dist/signals/window-figures.d.ts +148 -0
- package/dist/signals/window-figures.js +42 -0
- package/dist/signals/window.d.ts +866 -0
- package/dist/signals/window.js +693 -0
- package/dist/signals/words.d.ts +24 -0
- package/dist/signals/words.js +24 -0
- package/dist/store/index.d.ts +19 -0
- package/dist/store/index.js +19 -0
- package/dist/store/memory.d.ts +2 -1
- package/dist/store/memory.js +48 -12
- package/dist/store/migrate.d.ts +80 -0
- package/dist/store/migrate.js +259 -7
- package/dist/store/postgres-applications.d.ts +4 -0
- package/dist/store/postgres-applications.js +197 -0
- package/dist/store/postgres-holds.d.ts +10 -1
- package/dist/store/postgres-holds.js +116 -101
- package/dist/store/postgres-policy-log.d.ts +14 -0
- package/dist/store/postgres-policy-log.js +240 -0
- package/dist/store/postgres-projects.d.ts +4 -0
- package/dist/store/postgres-projects.js +217 -0
- package/dist/store/postgres.d.ts +16 -1
- package/dist/store/postgres.js +59 -9
- package/dist/store/replay.d.ts +102 -1
- package/dist/store/replay.js +190 -19
- package/dist/store/reseed.d.ts +238 -0
- package/dist/store/reseed.js +308 -0
- package/dist/store/schema.d.ts +450 -2
- package/dist/store/schema.js +141 -5
- package/dist/store/store.d.ts +29 -6
- package/dist/submit/resolve.js +2 -1
- package/dist/telemetry/calibration.d.ts +25 -0
- package/dist/telemetry/calibration.js +27 -1
- package/dist/telemetry/event.d.ts +391 -33
- package/dist/telemetry/event.js +84 -20
- package/dist/telemetry/index.d.ts +1 -0
- package/dist/telemetry/index.js +1 -0
- package/dist/telemetry/journal.d.ts +72 -3
- package/dist/telemetry/journal.js +9 -0
- package/dist/telemetry/lookup.d.ts +27 -0
- package/dist/telemetry/lookup.js +18 -0
- package/dist/telemetry/memory.js +23 -0
- package/dist/telemetry/migrate.js +22 -1
- package/dist/telemetry/postgres.d.ts +10 -1
- package/dist/telemetry/postgres.js +172 -90
- package/dist/telemetry/remeasure.d.ts +78 -0
- package/dist/telemetry/remeasure.js +83 -0
- package/dist/telemetry/retention.d.ts +2 -2
- package/dist/telemetry/schema.d.ts +17 -0
- package/dist/telemetry/schema.js +27 -1
- package/dist/telemetry/sink.d.ts +2 -2
- package/dist/testing/application-contract.d.ts +14 -0
- package/dist/testing/application-contract.js +270 -0
- package/dist/testing/contracts.d.ts +12 -7
- package/dist/testing/contracts.js +12 -7
- package/dist/testing/definitions.d.ts +78 -0
- package/dist/testing/definitions.js +134 -9
- package/dist/testing/doubles.d.ts +103 -0
- package/dist/testing/doubles.js +143 -0
- package/dist/testing/index.d.ts +2 -2
- package/dist/testing/index.js +2 -2
- package/dist/testing/journal-contract.js +140 -2
- package/dist/testing/model-contract.d.ts +110 -0
- package/dist/testing/model-contract.js +150 -0
- package/dist/testing/policy-log-contract.d.ts +26 -0
- package/dist/testing/policy-log-contract.js +344 -0
- package/dist/testing/project-contract.d.ts +14 -0
- package/dist/testing/project-contract.js +266 -0
- package/dist/testing/reader-signal-contract.d.ts +27 -2
- package/dist/testing/reader-signal-contract.js +475 -5
- package/dist/testing/store-contract.d.ts +7 -1
- package/dist/testing/store-contract.js +84 -3
- package/dist/theme/apply.d.ts +20 -1
- package/dist/theme/apply.js +5 -3
- package/dist/theme/derive.d.ts +22 -0
- package/dist/theme/derive.js +54 -1
- package/dist/theme/library.js +1 -1
- package/dist/theme/measure.d.ts +34 -0
- package/dist/theme/measure.js +30 -1
- package/dist/theme/palettes.js +7 -7
- package/dist/theme/ramp.d.ts +64 -0
- package/dist/theme/ramp.js +114 -0
- package/dist/theme/registry.d.ts +9 -0
- package/dist/theme/registry.js +11 -1
- package/dist/theme/separation.d.ts +97 -3
- package/dist/theme/separation.js +75 -0
- package/dist/tree/compare.d.ts +9 -0
- package/dist/tree/compare.js +18 -0
- package/dist/write/computed.d.ts +60 -0
- package/dist/write/computed.js +61 -0
- package/dist/write/held.d.ts +59 -0
- package/dist/write/index.d.ts +5 -2
- package/dist/write/index.js +5 -2
- package/dist/write/reseed.d.ts +151 -0
- package/dist/write/reseed.js +184 -0
- package/dist/write/revert.js +2 -16
- package/package.json +98 -19
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { everyMemberOf } from "../closed-set.js";
|
|
2
|
+
import { PRIMITIVE_ROLES } from "../role.js";
|
|
3
|
+
import { copyIn } from "../sdk/copy.js";
|
|
4
|
+
import { outlineTree } from "../tree/outline.js";
|
|
5
|
+
import { audienceScopeOf, audiencesIn } from "./audiences.js";
|
|
6
|
+
export const PART_STANDINGS = everyMemberOf()([
|
|
7
|
+
"read",
|
|
8
|
+
"skipped",
|
|
9
|
+
"unknown",
|
|
10
|
+
]);
|
|
11
|
+
/**
|
|
12
|
+
* Whether the window can say either way, which is the one question every
|
|
13
|
+
* figure over a page's words is restricted by.
|
|
14
|
+
*
|
|
15
|
+
* `read` and `skipped` are claims about readers; `unknown` is the absence of
|
|
16
|
+
* one (0282). A passage nothing can be said about is in no mass, out of every
|
|
17
|
+
* list a person acts on, and outside the denominator of every share
|
|
18
|
+
* ([0287](../../decisions/0287-a-share-of-a-pages-words-is-a-share-of-the-words-the-window-can-speak-for-and-spoken-for-is-one-predicate.md)).
|
|
19
|
+
*
|
|
20
|
+
* **Published here rather than spelled where it is asked.** Three modules
|
|
21
|
+
* enumerated the standing by hand and a fourth was about to, and the way that
|
|
22
|
+
* breaks is a sixth `PartStanding`: one spelling has to be revisited and the
|
|
23
|
+
* others go on agreeing with the version of the vocabulary they were written
|
|
24
|
+
* against. Two spellings of a projection that agree today are what the counter
|
|
25
|
+
* keys were before they were published once.
|
|
26
|
+
*
|
|
27
|
+
* **It is not `anchors`.** `change.ts` and `progress.ts` ask the same question
|
|
28
|
+
* of a part under a different name, because what 0221 needs is *can this part
|
|
29
|
+
* anchor a stop* and the answer coincides. A predicate shared because two
|
|
30
|
+
* rules agree is the thing this is fixing.
|
|
31
|
+
*/
|
|
32
|
+
export const spokenFor = (standing) => standing !== "unknown";
|
|
33
|
+
/** One line per standing, for a surface putting the reading in front of a person. */
|
|
34
|
+
export const describePartStanding = (standing) => {
|
|
35
|
+
switch (standing) {
|
|
36
|
+
case "read":
|
|
37
|
+
return "came into view in at least one page view";
|
|
38
|
+
case "skipped":
|
|
39
|
+
return "was on the page and in nobody's viewport";
|
|
40
|
+
case "unknown":
|
|
41
|
+
return "nothing was reported that could say either way";
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const NO_STANDINGS = Object.freeze({
|
|
45
|
+
read: 0,
|
|
46
|
+
skipped: 0,
|
|
47
|
+
unknown: 0,
|
|
48
|
+
});
|
|
49
|
+
/**
|
|
50
|
+
* A type's role, inverted from the vocabulary once per reading.
|
|
51
|
+
*
|
|
52
|
+
* Linear in the vocabulary rather than per part: the alternative is asking
|
|
53
|
+
* `typesWithRole` for every part, which is a registry call and a list scan per
|
|
54
|
+
* node on a page that may have thousands.
|
|
55
|
+
*/
|
|
56
|
+
const rolesByType = (declarations) => {
|
|
57
|
+
const byType = new Map();
|
|
58
|
+
for (const role of PRIMITIVE_ROLES) {
|
|
59
|
+
for (const type of declarations.typesWithRole(role)) {
|
|
60
|
+
/**
|
|
61
|
+
* First declaration wins, and it cannot legitimately happen twice: a
|
|
62
|
+
* definition carries one `role`. A registry that answered the same type
|
|
63
|
+
* for two roles is wrong about something this reading cannot fix, and
|
|
64
|
+
* picking the earlier keeps the answer stable rather than dependent on
|
|
65
|
+
* the vocabulary's order.
|
|
66
|
+
*/
|
|
67
|
+
if (!byType.has(type))
|
|
68
|
+
byType.set(type, role);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return byType;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* The children that are not parts in their own right, which is what a node
|
|
75
|
+
* contributes itself.
|
|
76
|
+
*
|
|
77
|
+
* Text is kept and an element is dropped, because every element is a part of
|
|
78
|
+
* this reading and would otherwise be counted at two depths. **A slot is kept
|
|
79
|
+
* and pruned the same way**, because a slot is not an element and so is never a
|
|
80
|
+
* part: text handed into one belongs to the nearest element above it, and a slot
|
|
81
|
+
* treated as an element would lose those words to a node this reading never
|
|
82
|
+
* reports. The words of a page are partitioned across its parts exactly once,
|
|
83
|
+
* and that sentence is only true with this clause in it.
|
|
84
|
+
*/
|
|
85
|
+
const ownChildren = (children) => children.flatMap((child) => {
|
|
86
|
+
switch (child.kind) {
|
|
87
|
+
case "element":
|
|
88
|
+
return [];
|
|
89
|
+
case "text":
|
|
90
|
+
return [child];
|
|
91
|
+
case "slot":
|
|
92
|
+
return [{ ...child, children: ownChildren(child.children) }];
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
/**
|
|
96
|
+
* What a part says on its own, read with `copyIn` against a node stripped of
|
|
97
|
+
* everything that is a part in its own right.
|
|
98
|
+
*
|
|
99
|
+
* `copyIn` walks a subtree, which is right for its callers and wrong here — a
|
|
100
|
+
* root would carry every word on the page and so would every band on the way
|
|
101
|
+
* down. Rather than reimplement its rules about blank strings, non-string values
|
|
102
|
+
* and what counts as declared, this hands it the node with only the children
|
|
103
|
+
* that are nobody else's, which is exactly the part's own contribution.
|
|
104
|
+
*/
|
|
105
|
+
const ownCopy = (node, declarations) => copyIn({ ...node, children: ownChildren(node.children) }, declarations);
|
|
106
|
+
const standingOf = (counters, views) => {
|
|
107
|
+
if (counters !== undefined && counters.reached > 0)
|
|
108
|
+
return "read";
|
|
109
|
+
if (views === 0)
|
|
110
|
+
return "unknown";
|
|
111
|
+
if (counters === undefined)
|
|
112
|
+
return "skipped";
|
|
113
|
+
return "unknown";
|
|
114
|
+
};
|
|
115
|
+
const countedStandings = (parts) => {
|
|
116
|
+
const counts = { ...NO_STANDINGS };
|
|
117
|
+
for (const part of parts)
|
|
118
|
+
counts[part.standing] += 1;
|
|
119
|
+
return counts;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Every row, in one pass over the parts.
|
|
123
|
+
*
|
|
124
|
+
* A pass per row would be a scan of the page per member of the vocabulary, and
|
|
125
|
+
* the vocabulary grows while the page is what it is. One pass keeps this linear
|
|
126
|
+
* in the parts, which is the standard rule 4 holds the ledger to — it was
|
|
127
|
+
* quadratic once, and a 6,000-node page took 314 ms.
|
|
128
|
+
*/
|
|
129
|
+
const roleReadingsOf = (parts) => {
|
|
130
|
+
const rows = new Map([...PRIMITIVE_ROLES, null].map((role) => [
|
|
131
|
+
role,
|
|
132
|
+
{
|
|
133
|
+
role,
|
|
134
|
+
parts: 0,
|
|
135
|
+
standings: { ...NO_STANDINGS },
|
|
136
|
+
dwellMs: 0,
|
|
137
|
+
activations: 0,
|
|
138
|
+
opens: 0,
|
|
139
|
+
closes: 0,
|
|
140
|
+
completions: 0,
|
|
141
|
+
},
|
|
142
|
+
]));
|
|
143
|
+
for (const part of parts) {
|
|
144
|
+
const row = rows.get(part.role);
|
|
145
|
+
/**
|
|
146
|
+
* A role this runtime does not know cannot reach here — `rolesByType` only
|
|
147
|
+
* ever yields members of `PRIMITIVE_ROLES` — so a missing row would be this
|
|
148
|
+
* module disagreeing with itself rather than a host doing something. Skipped
|
|
149
|
+
* rather than thrown: a reading is not worth failing over, and a row that
|
|
150
|
+
* does not exist cannot be drawn.
|
|
151
|
+
*/
|
|
152
|
+
if (row === undefined)
|
|
153
|
+
continue;
|
|
154
|
+
rows.set(part.role, {
|
|
155
|
+
...row,
|
|
156
|
+
parts: row.parts + 1,
|
|
157
|
+
standings: { ...row.standings, [part.standing]: row.standings[part.standing] + 1 },
|
|
158
|
+
dwellMs: row.dwellMs + (part.counters?.dwellMs ?? 0),
|
|
159
|
+
activations: row.activations + (part.counters?.activations ?? 0),
|
|
160
|
+
opens: row.opens + (part.counters?.opens ?? 0),
|
|
161
|
+
closes: row.closes + (part.counters?.closes ?? 0),
|
|
162
|
+
completions: row.completions + (part.counters?.completions ?? 0),
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
return [...rows.values()];
|
|
166
|
+
};
|
|
167
|
+
/**
|
|
168
|
+
* Join a window's counters to the tree and registry they were filed against.
|
|
169
|
+
*
|
|
170
|
+
* The tree carries the pair the counters are keyed by, so there is no way to ask
|
|
171
|
+
* this question about a revision without holding the revision — which is the
|
|
172
|
+
* property that makes the answer trustworthy. Rows filed under anything else are
|
|
173
|
+
* dropped and counted.
|
|
174
|
+
*
|
|
175
|
+
* **A reading is of one audience.** A page is one base tree and the deltas an
|
|
176
|
+
* audience earns (0263), so two forms of it are two sets of counters over one
|
|
177
|
+
* tree at one revision, told apart by a column and nothing else (0284). Name
|
|
178
|
+
* the audience and the rest of the window is `otherAudience`; name none and a
|
|
179
|
+
* window holding one audience, or none at all, is read whole. A window holding
|
|
180
|
+
* two with none named is read as neither, because the only other answers are
|
|
181
|
+
* summing two populations and picking one of them by row order.
|
|
182
|
+
*/
|
|
183
|
+
export const pageReadingOf = (tree, tallies, declarations, audience) => {
|
|
184
|
+
const byNode = new Map();
|
|
185
|
+
const duplicated = [];
|
|
186
|
+
let foreign = 0;
|
|
187
|
+
let otherAudience = 0;
|
|
188
|
+
const here = tallies.filter((tally) => tally.treeId === tree.treeId && tally.revision === tree.revision);
|
|
189
|
+
const audiences = audiencesIn(here);
|
|
190
|
+
/**
|
|
191
|
+
* One member is the window's own audience and needs no caller to say so; none
|
|
192
|
+
* is a window that never carried the column. Two with nothing asked for is
|
|
193
|
+
* the refusal, and it is spelled as *no audience to read* rather than as a
|
|
194
|
+
* throw, because a reading is not worth failing over and a surface can draw
|
|
195
|
+
* `audiences` — a reading that names why its answer is absent (0240).
|
|
196
|
+
*
|
|
197
|
+
* Taken from `audienceScopeOf` rather than spelled here. The rule is the same
|
|
198
|
+
* one it was, and it is now the published one: two other readings pick a
|
|
199
|
+
* page's rows out of a window and both had to be corrected for treating the
|
|
200
|
+
* two kinds of *no audience* alike (0297, 0299).
|
|
201
|
+
*/
|
|
202
|
+
const scope = audienceScopeOf(audiences, audience);
|
|
203
|
+
const reading = scope.audienceId;
|
|
204
|
+
const mixed = scope.reading === "mixed";
|
|
205
|
+
for (const tally of tallies) {
|
|
206
|
+
if (tally.treeId !== tree.treeId || tally.revision !== tree.revision) {
|
|
207
|
+
foreign += 1;
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
if (mixed || (reading !== null && tally.audienceId !== reading)) {
|
|
211
|
+
otherAudience += 1;
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
if (byNode.has(tally.nodeId)) {
|
|
215
|
+
duplicated.push(tally.nodeId);
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
byNode.set(tally.nodeId, tally);
|
|
219
|
+
}
|
|
220
|
+
const views = [...byNode.values()].reduce((most, tally) => Math.max(most, tally.views), 0);
|
|
221
|
+
const roles = rolesByType(declarations);
|
|
222
|
+
const parts = outlineTree(tree.root).flatMap((entry) => {
|
|
223
|
+
const { node } = entry;
|
|
224
|
+
/**
|
|
225
|
+
* Elements only, and that is the whole universe rather than a narrowing: a
|
|
226
|
+
* text or slot node carries no identity attributes, so no signal can ever
|
|
227
|
+
* name one. A text node's words are read as its parent's (`ownCopy`), so
|
|
228
|
+
* nothing in the tree goes unaccounted for.
|
|
229
|
+
*/
|
|
230
|
+
if (node.kind !== "element")
|
|
231
|
+
return [];
|
|
232
|
+
const counters = byNode.get(node.id);
|
|
233
|
+
return [
|
|
234
|
+
{
|
|
235
|
+
nodeId: node.id,
|
|
236
|
+
type: node.type,
|
|
237
|
+
role: roles.get(node.type) ?? null,
|
|
238
|
+
depth: entry.depth,
|
|
239
|
+
parentId: entry.parentId,
|
|
240
|
+
standing: standingOf(counters, views),
|
|
241
|
+
counters,
|
|
242
|
+
copy: ownCopy(node, declarations),
|
|
243
|
+
},
|
|
244
|
+
];
|
|
245
|
+
});
|
|
246
|
+
const addressed = new Set(parts.map((part) => part.nodeId));
|
|
247
|
+
return {
|
|
248
|
+
treeId: tree.treeId,
|
|
249
|
+
revision: tree.revision,
|
|
250
|
+
audienceId: reading,
|
|
251
|
+
audiences,
|
|
252
|
+
otherAudience,
|
|
253
|
+
views,
|
|
254
|
+
parts,
|
|
255
|
+
roles: roleReadingsOf(parts),
|
|
256
|
+
standings: countedStandings(parts),
|
|
257
|
+
foreign,
|
|
258
|
+
orphaned: [...byNode.keys()].filter((nodeId) => !addressed.has(nodeId)),
|
|
259
|
+
duplicated,
|
|
260
|
+
};
|
|
261
|
+
};
|
|
262
|
+
/**
|
|
263
|
+
* The words readers actually reached, in reading order.
|
|
264
|
+
*
|
|
265
|
+
* The third question step 6 names, and it is a filter rather than a build: a
|
|
266
|
+
* part's words are its own, so concatenating the read ones double-counts
|
|
267
|
+
* nothing. What it cannot include is a word whose part declared no `copy` —
|
|
268
|
+
* those are in each part's `copy.unread`, named, because a reading that returned
|
|
269
|
+
* them would be guessing and one that dropped them silently would be the failure
|
|
270
|
+
* 0122 exists to prevent.
|
|
271
|
+
*/
|
|
272
|
+
export const wordsReadIn = (reading) => reading.parts.filter((part) => part.standing === "read").flatMap((part) => [...part.copy.words]);
|
|
273
|
+
//# sourceMappingURL=parts.js.map
|
|
@@ -1,7 +1,21 @@
|
|
|
1
|
+
import { type StoreScope } from "../application/application.js";
|
|
1
2
|
import type { LoomDatabase } from "../store/database.js";
|
|
2
3
|
import { type ReaderSignalJournal } from "./journal.js";
|
|
4
|
+
import { type ReaderRegionStore } from "./region.js";
|
|
3
5
|
import type { ReaderTallyStore } from "./tally.js";
|
|
4
6
|
export * from "./migrate.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Every read is filtered by the application this handle speaks for (0269), and
|
|
9
|
+
* every write sets it.
|
|
10
|
+
*
|
|
11
|
+
* A reader is filed against the application whose page they read. Folding two
|
|
12
|
+
* would add two customers' counts together, and the addition is not
|
|
13
|
+
* recoverable from the rows afterwards — which is why this landed before
|
|
14
|
+
* anything could construct a second application rather than after.
|
|
15
|
+
*/
|
|
16
|
+
export declare const postgresReaderSignalJournal: (db: LoomDatabase, scope?: StoreScope) => ReaderSignalJournal;
|
|
17
|
+
/** Scoped on the same terms as the journal — see its note. */
|
|
18
|
+
export declare const postgresReaderTallyStore: (db: LoomDatabase, scope?: StoreScope) => ReaderTallyStore;
|
|
19
|
+
/** Scoped on the same terms as the journal — see its note. */
|
|
20
|
+
export declare const postgresReaderRegionStore: (db: LoomDatabase, scope?: StoreScope) => ReaderRegionStore;
|
|
7
21
|
//# sourceMappingURL=postgres.d.ts.map
|