@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,92 @@
|
|
|
1
|
+
import type { RevisionPageViews } from "./page-views.js";
|
|
2
|
+
import type { ReachSilence } from "./reach.js";
|
|
3
|
+
/**
|
|
4
|
+
* The scale a page's door counts in, which three readings of a library share.
|
|
5
|
+
*
|
|
6
|
+
* A share of the readers who met something is a weighted mean of per-page
|
|
7
|
+
* shares, and every term of it has to be put on the scale the door counts in
|
|
8
|
+
* before two pages can be added together
|
|
9
|
+
* ([0250](../../decisions/0250-a-deployment-is-ordered-by-readers-lost-at-the-doors-scale-and-a-page-the-door-cannot-scale-is-out-of-the-order.md),
|
|
10
|
+
* [0256](../../decisions/0256-a-kinds-share-of-the-readers-who-met-it-is-a-weighted-mean-of-sound-shares-at-the-doors-scale.md)).
|
|
11
|
+
* That scaling is one rule, and until a third reading needed it, it was **two
|
|
12
|
+
* hand-written copies of one rule**: a kind's share of the readers who met it
|
|
13
|
+
* and a census of what readers do inside a kind of part
|
|
14
|
+
* ([0265](../../decisions/0265-what-readers-do-inside-a-kind-of-part-is-a-share-of-the-readers-who-met-it-and-the-door-is-only-a-weight.md))
|
|
15
|
+
* each carried their own, and a comparison of two windows of the first would
|
|
16
|
+
* have carried a third.
|
|
17
|
+
*
|
|
18
|
+
* Two spellings of one rule that agree today are a thing this subsystem has
|
|
19
|
+
* been bitten by before — the upsert keys of the four counter tables, moved
|
|
20
|
+
* into `counters.ts` so that two stores could not drift about what one row is
|
|
21
|
+
* — so the rule is written once here and the readings import it.
|
|
22
|
+
*
|
|
23
|
+
* The numbers are the page's rather than any part's, so a reading works one of
|
|
24
|
+
* these out per page and not per placement: a library of forty pages is tens of
|
|
25
|
+
* thousands of placements, and the row lookup is a filter over the rows.
|
|
26
|
+
*
|
|
27
|
+
* Pure, and the arithmetic is a minimum of two whole numbers. It reaches no
|
|
28
|
+
* store, no clock and no DOM, and nothing in it survives into a browser bundle.
|
|
29
|
+
*/
|
|
30
|
+
/** What one page's door contributes to every figure taken against its readers. */
|
|
31
|
+
export type PageDoor = {
|
|
32
|
+
/**
|
|
33
|
+
* `min(appearances, opened)`: the page views a rollup folded, at the door's
|
|
34
|
+
* scale.
|
|
35
|
+
*
|
|
36
|
+
* It is `appearances ÷ (1 + inflation)` and is **taken as that minimum of two
|
|
37
|
+
* whole numbers**, because the division of three floats agrees with it to
|
|
38
|
+
* fifteen places and not to sixteen — which a share of readers has already
|
|
39
|
+
* been bitten by (0229).
|
|
40
|
+
*/
|
|
41
|
+
readonly counted: number;
|
|
42
|
+
/**
|
|
43
|
+
* The row's openings, whatever the silence.
|
|
44
|
+
*
|
|
45
|
+
* Carried even where this page cannot be scaled, because a reading's own
|
|
46
|
+
* count of arrivals is a count of page views the door made and not a count of
|
|
47
|
+
* the ones a share could be taken of.
|
|
48
|
+
*/
|
|
49
|
+
readonly opened: number;
|
|
50
|
+
readonly appearances: number;
|
|
51
|
+
readonly drift: number;
|
|
52
|
+
readonly pending: number;
|
|
53
|
+
/** Set where this page cannot be scaled, in the page's own vocabulary. */
|
|
54
|
+
readonly silence: ReachSilence | null;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* The page's door, with the three reasons tried in the order a page's own
|
|
58
|
+
* reading tries them in.
|
|
59
|
+
*
|
|
60
|
+
* No row before nothing opened, because *there is no row* is the state a
|
|
61
|
+
* deployment can be in without its senders being at fault.
|
|
62
|
+
*/
|
|
63
|
+
export declare const doorOf: (row: RevisionPageViews | null) => PageDoor;
|
|
64
|
+
/**
|
|
65
|
+
* A count taken against one page, put on the scale its door counts in.
|
|
66
|
+
*
|
|
67
|
+
* `count × counted ÷ appearances`: the count's own sound share of that page's
|
|
68
|
+
* appearances (0229), weighted by the page views a rollup actually folded
|
|
69
|
+
* (0250). It is the expression every reader-weighted figure over a library is
|
|
70
|
+
* built out of, and until now it was **five hand-written copies of it** — one
|
|
71
|
+
* in a kind's share of readers, two in what readers do inside a kind, two in a
|
|
72
|
+
* comparison of the first — which is the state this module was created to end
|
|
73
|
+
* and did not quite reach: {@link PageDoor} held the per-page half of the rule
|
|
74
|
+
* and the per-placement half stayed at each call site.
|
|
75
|
+
*
|
|
76
|
+
* **The multiplication comes before the division**, which is not a style: the
|
|
77
|
+
* three floats agree to fifteen places in either order and not to sixteen, and
|
|
78
|
+
* 0229 has already been bitten by exactly that. Written this way the helper is
|
|
79
|
+
* bit-identical to every copy it replaces.
|
|
80
|
+
*
|
|
81
|
+
* `scaledBy` is a **second** door, for the one caller that needs one: a
|
|
82
|
+
* comparison asks what one side's reading would have come to with the other
|
|
83
|
+
* side's traffic behind it, so the share is of the door the count came from and
|
|
84
|
+
* the weight is the other's. It defaults to the door the count came from, which
|
|
85
|
+
* is every other caller.
|
|
86
|
+
*
|
|
87
|
+
* Only ever called for a door with no silence, where `appearances` is
|
|
88
|
+
* positive — a page the door cannot scale has no term in any of these figures
|
|
89
|
+
* at all.
|
|
90
|
+
*/
|
|
91
|
+
export declare const atDoorScale: (count: number, of: PageDoor, scaledBy?: PageDoor) => number;
|
|
92
|
+
//# sourceMappingURL=door.d.ts.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The page's door, with the three reasons tried in the order a page's own
|
|
3
|
+
* reading tries them in.
|
|
4
|
+
*
|
|
5
|
+
* No row before nothing opened, because *there is no row* is the state a
|
|
6
|
+
* deployment can be in without its senders being at fault.
|
|
7
|
+
*/
|
|
8
|
+
export const doorOf = (row) => {
|
|
9
|
+
if (row === null) {
|
|
10
|
+
return { counted: 0, opened: 0, appearances: 0, drift: 0, pending: 0, silence: "unmeasured" };
|
|
11
|
+
}
|
|
12
|
+
const of = {
|
|
13
|
+
counted: Math.min(row.appearances, row.opened),
|
|
14
|
+
opened: row.opened,
|
|
15
|
+
appearances: row.appearances,
|
|
16
|
+
drift: row.drift,
|
|
17
|
+
pending: row.pending,
|
|
18
|
+
};
|
|
19
|
+
if (row.opened === 0)
|
|
20
|
+
return { ...of, silence: "unopened" };
|
|
21
|
+
if (row.appearances === 0)
|
|
22
|
+
return { ...of, silence: "uncounted" };
|
|
23
|
+
return { ...of, silence: null };
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* A count taken against one page, put on the scale its door counts in.
|
|
27
|
+
*
|
|
28
|
+
* `count × counted ÷ appearances`: the count's own sound share of that page's
|
|
29
|
+
* appearances (0229), weighted by the page views a rollup actually folded
|
|
30
|
+
* (0250). It is the expression every reader-weighted figure over a library is
|
|
31
|
+
* built out of, and until now it was **five hand-written copies of it** — one
|
|
32
|
+
* in a kind's share of readers, two in what readers do inside a kind, two in a
|
|
33
|
+
* comparison of the first — which is the state this module was created to end
|
|
34
|
+
* and did not quite reach: {@link PageDoor} held the per-page half of the rule
|
|
35
|
+
* and the per-placement half stayed at each call site.
|
|
36
|
+
*
|
|
37
|
+
* **The multiplication comes before the division**, which is not a style: the
|
|
38
|
+
* three floats agree to fifteen places in either order and not to sixteen, and
|
|
39
|
+
* 0229 has already been bitten by exactly that. Written this way the helper is
|
|
40
|
+
* bit-identical to every copy it replaces.
|
|
41
|
+
*
|
|
42
|
+
* `scaledBy` is a **second** door, for the one caller that needs one: a
|
|
43
|
+
* comparison asks what one side's reading would have come to with the other
|
|
44
|
+
* side's traffic behind it, so the share is of the door the count came from and
|
|
45
|
+
* the weight is the other's. It defaults to the door the count came from, which
|
|
46
|
+
* is every other caller.
|
|
47
|
+
*
|
|
48
|
+
* Only ever called for a door with no silence, where `appearances` is
|
|
49
|
+
* positive — a page the door cannot scale has no term in any of these figures
|
|
50
|
+
* at all.
|
|
51
|
+
*/
|
|
52
|
+
export const atDoorScale = (count, of, scaledBy = of) => (count * scaledBy.counted) / of.appearances;
|
|
53
|
+
//# sourceMappingURL=door.js.map
|
package/dist/signals/fold.d.ts
CHANGED
|
@@ -50,6 +50,14 @@ export type ReaderReadings = {
|
|
|
50
50
|
readonly activations: Readonly<Record<NodeId, number>>;
|
|
51
51
|
readonly opens: Readonly<Record<NodeId, number>>;
|
|
52
52
|
readonly closes: Readonly<Record<NodeId, number>>;
|
|
53
|
+
/**
|
|
54
|
+
* Times a form inside the node was submitted and the browser let it go.
|
|
55
|
+
*
|
|
56
|
+
* Filed against the node the signal names, which for the starter library's
|
|
57
|
+
* `loom.form` is the form itself. The band it was the end of is in
|
|
58
|
+
* `engagements`, like every other delegated kind.
|
|
59
|
+
*/
|
|
60
|
+
readonly completions: Readonly<Record<NodeId, number>>;
|
|
53
61
|
/**
|
|
54
62
|
* Times a reader used something *inside* the node — pressed, followed, filled,
|
|
55
63
|
* opened or closed, at any depth.
|
|
@@ -97,6 +105,8 @@ export type NodeReading = {
|
|
|
97
105
|
readonly activations: number;
|
|
98
106
|
readonly opens: number;
|
|
99
107
|
readonly closes: number;
|
|
108
|
+
/** Times a form inside it was submitted and the browser let it go. */
|
|
109
|
+
readonly completions: number;
|
|
100
110
|
/** Times a reader used something inside it, at any depth. */
|
|
101
111
|
readonly engagements: number;
|
|
102
112
|
};
|
package/dist/signals/fold.js
CHANGED
|
@@ -4,6 +4,7 @@ export const EMPTY_READINGS = {
|
|
|
4
4
|
activations: {},
|
|
5
5
|
opens: {},
|
|
6
6
|
closes: {},
|
|
7
|
+
completions: {},
|
|
7
8
|
engagements: {},
|
|
8
9
|
types: {},
|
|
9
10
|
batches: 0,
|
|
@@ -14,7 +15,8 @@ const bumped = (counts, nodeId, by) => ({ ...counts, [nodeId]: (counts[nodeId] ?
|
|
|
14
15
|
* The regions a delegated signal says it happened inside, and their types, which
|
|
15
16
|
* a reading knows exactly as it knows the node's own.
|
|
16
17
|
*/
|
|
17
|
-
const withinOf = (signal) => (signal.kind === "activated" || signal.kind === "disclosed"
|
|
18
|
+
const withinOf = (signal) => (signal.kind === "activated" || signal.kind === "disclosed" || signal.kind === "completed") &&
|
|
19
|
+
signal.within !== undefined
|
|
18
20
|
? signal.within
|
|
19
21
|
: [];
|
|
20
22
|
/** Every node a signal mentions is one this reading now knows the type of. */
|
|
@@ -29,6 +31,7 @@ const foldSignal = (readings, signal) => {
|
|
|
29
31
|
activations: signal.kind === "activated" ? bumped(readings.activations, nodeId, 1) : readings.activations,
|
|
30
32
|
opens: signal.kind === "disclosed" && signal.open ? bumped(readings.opens, nodeId, 1) : readings.opens,
|
|
31
33
|
closes: signal.kind === "disclosed" && !signal.open ? bumped(readings.closes, nodeId, 1) : readings.closes,
|
|
34
|
+
completions: signal.kind === "completed" ? bumped(readings.completions, nodeId, 1) : readings.completions,
|
|
32
35
|
types: {
|
|
33
36
|
...readings.types,
|
|
34
37
|
...Object.fromEntries(within.map((region) => [region.nodeId, region.type])),
|
|
@@ -69,6 +72,7 @@ export const nodeReadingsOf = (readings) => Object.keys(readings.types)
|
|
|
69
72
|
activations: readings.activations[nodeId] ?? 0,
|
|
70
73
|
opens: readings.opens[nodeId] ?? 0,
|
|
71
74
|
closes: readings.closes[nodeId] ?? 0,
|
|
75
|
+
completions: readings.completions[nodeId] ?? 0,
|
|
72
76
|
engagements: readings.engagements[nodeId] ?? 0,
|
|
73
77
|
};
|
|
74
78
|
})
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import type { AudienceId } from "../audience/audience.js";
|
|
2
|
+
import type { NodeId, TreeId } from "../ids.js";
|
|
3
|
+
import type { PrimitiveType } from "../primitive-type.js";
|
|
4
|
+
import type { PrimitiveRole } from "../role.js";
|
|
5
|
+
import { type PageAction, type PartAction } from "./action.js";
|
|
6
|
+
import { type FormPairRefusal } from "./audiences.js";
|
|
7
|
+
import type { PageReading } from "./parts.js";
|
|
8
|
+
/**
|
|
9
|
+
* What readers *do* inside a page, form by form.
|
|
10
|
+
*
|
|
11
|
+
* The second of the two comparisons [0302](../../decisions/0302-two-forms-of-one-page-are-compared-at-each-forms-own-share-and-neither-side-is-earlier.md)
|
|
12
|
+
* named and did not build. `formComparisonOf` holds two forms of one page
|
|
13
|
+
* against each other on each part's **reach** — did this audience's readers
|
|
14
|
+
* get here. This one asks the next question of the same pair: having got here,
|
|
15
|
+
* did they *do* anything. *The riders open the size guide twice as often as
|
|
16
|
+
* the skiers, and neither of them touches the finance band.*
|
|
17
|
+
*
|
|
18
|
+
* Nothing is collected for it. Two readings go in and a comparison comes out,
|
|
19
|
+
* which makes it the thirty-fourth thing taken out of the server-side join
|
|
20
|
+
* rather than added to a payload, a browser, a column or the vocabulary of
|
|
21
|
+
* kinds.
|
|
22
|
+
*
|
|
23
|
+
* ## What it borrows, and the reason borrowing is the unit
|
|
24
|
+
*
|
|
25
|
+
* The five states in which two readings are **not** two forms of one page are
|
|
26
|
+
* `FormPairRefusal` in [`audiences.ts`](audiences.ts), imported here and in
|
|
27
|
+
* `forms.ts` rather than spelled twice. That is not tidying: 0302's six clauses
|
|
28
|
+
* are about the **pair** — one tree, one revision, two provable populations,
|
|
29
|
+
* neither of them earlier — and a second reading of the same pair restates none
|
|
30
|
+
* of them. A rule written in two places is a rule one of its copies will
|
|
31
|
+
* disagree with, which is what `readingKeyOf` and `formKeyOf` exist to stop one
|
|
32
|
+
* level up, and this is the same argument at the comparison.
|
|
33
|
+
*
|
|
34
|
+
* So what is this module's own is one figure and the two things that figure
|
|
35
|
+
* cannot survive.
|
|
36
|
+
*
|
|
37
|
+
* ## The figure, and why this reading has a page-level one where its sibling does not
|
|
38
|
+
*
|
|
39
|
+
* The comparable figure is {@link PartAction.share} — `within ÷ reached`, the
|
|
40
|
+
* readers who reached a part and did something strictly inside it (0167, 0242).
|
|
41
|
+
* Both terms are distinct page-view counts off **one row**, so the straddle
|
|
42
|
+
* over-count (0147) is very nearly common to the numerator and the denominator
|
|
43
|
+
* and divides out before the two populations meet, exactly as a reach share
|
|
44
|
+
* does in `forms.ts` and a fall does in `progress.ts` (0221).
|
|
45
|
+
*
|
|
46
|
+
* **And here the page as a whole has an honest figure, where the reach
|
|
47
|
+
* comparison refuses one.** 0302 clause 5 refuses a page-level verdict for two
|
|
48
|
+
* reasons: a mean over parts charges one reader once per part they got through,
|
|
49
|
+
* and two forms do not have the same parts, so two such means have two
|
|
50
|
+
* denominators that are not the same page. Neither reaches the root.
|
|
51
|
+
* {@link PageAction.whole} is **one part's own row** — every action anywhere on
|
|
52
|
+
* the page is strictly inside the root (0242) — so *three in ten skiers did
|
|
53
|
+
* something on this page and one in ten riders did* is one division per side
|
|
54
|
+
* and no addition at all. {@link FormActionComparison.whole} is that row, held
|
|
55
|
+
* against itself across the two forms, and it is the only page-level claim
|
|
56
|
+
* either form comparison makes.
|
|
57
|
+
*
|
|
58
|
+
* It is kept out of {@link FormActionComparison.sharpest} because the page
|
|
59
|
+
* contains every part it would outrank, which is how `pageActionOf` treats it
|
|
60
|
+
* for `mostIgnored` and `pageReadingOf` before that. It stays **inside**
|
|
61
|
+
* {@link FormActionComparison.counted}, because that is a census of the shared
|
|
62
|
+
* parts and a census that leaves one out does not account for the page.
|
|
63
|
+
*
|
|
64
|
+
* ## The two states the figure cannot survive
|
|
65
|
+
*
|
|
66
|
+
* **A leaf has no inside**, so `engaged` is structurally nought on it and a
|
|
67
|
+
* share built from that nought is a filing rule misread as a finding about
|
|
68
|
+
* readers (0167, 0242). `PartAction.share` is already withheld there, and on a
|
|
69
|
+
* part with no row and on a part whose `reached` is nought — the three states
|
|
70
|
+
* its standing calls `unknown`. So the withholding rule here is **one check
|
|
71
|
+
* where `forms.ts` needs two**: a withheld share and an unknown standing are
|
|
72
|
+
* the same fact said twice and never disagree, which `action.ts` guarantees and
|
|
73
|
+
* this module relies on rather than re-deriving.
|
|
74
|
+
*
|
|
75
|
+
* **A sender that does not walk** is the other, and it is this reading's own
|
|
76
|
+
* silence. A press is filed against the control and credited to its addressed
|
|
77
|
+
* ancestors from the ancestry the signal carries (0167), so a window whose
|
|
78
|
+
* delegated signals have no `within` reports occurrences and credits no reader
|
|
79
|
+
* with acting inside anything: every share on that side is a **nought that is a
|
|
80
|
+
* filing artefact**, not a reader who did nothing. Subtracting the other form's
|
|
81
|
+
* real share against it would publish that form's whole share as a difference
|
|
82
|
+
* between two populations — which is the rule 0282 already applies to an
|
|
83
|
+
* unknown standing, reaching a second state by the same argument. So
|
|
84
|
+
* {@link ComparedFormAction.gap} is withheld on **every** shared part where
|
|
85
|
+
* either side is unwalked, the parts fall into `unknown`, and
|
|
86
|
+
* {@link FormActionSilence.unwalked} says which state the reading is in.
|
|
87
|
+
*
|
|
88
|
+
* That withholding is **`pageActionOf`'s own** since 0304 — 0303 spelled it
|
|
89
|
+
* here, in a second clause of `gapOf`, and the rule moved down to the reading
|
|
90
|
+
* that can see the fault once the before-and-after needed it too. Nothing about
|
|
91
|
+
* this reading's answer changed, which is what its suite asserts.
|
|
92
|
+
*
|
|
93
|
+
* Pure, linear in the parts of the two readings, and reaches no store, clock or
|
|
94
|
+
* DOM. A caller checks `PageReading.orphaned` on both readings before trusting
|
|
95
|
+
* either, exactly as it must before trusting either on its own.
|
|
96
|
+
*/
|
|
97
|
+
/** Why a comparison of what two forms' readers did answered nothing, or less than all of it. */
|
|
98
|
+
export type FormActionSilence =
|
|
99
|
+
/**
|
|
100
|
+
* The five states in which two readings are not two forms of one page.
|
|
101
|
+
*
|
|
102
|
+
* Imported from {@link FormPairRefusal} rather than restated, for the reason
|
|
103
|
+
* the module documentation gives: every one of them is a fact about the pair
|
|
104
|
+
* and none of them is about the counter.
|
|
105
|
+
*/
|
|
106
|
+
FormPairRefusal
|
|
107
|
+
/**
|
|
108
|
+
* One of the two windows holds uses and credits no reader with acting inside
|
|
109
|
+
* anything.
|
|
110
|
+
*
|
|
111
|
+
* `PageAction.unwalked` on either side: a sender whose delegated signals
|
|
112
|
+
* carry no `within` (0167), a server synthesising batches, a fixture
|
|
113
|
+
* replayed. Every share on that side is a nought that is a filing artefact,
|
|
114
|
+
* so every gap across it would be the other form's whole share reported as a
|
|
115
|
+
* difference between two populations.
|
|
116
|
+
*
|
|
117
|
+
* **The figures are withheld as well as the state named.** The spurious
|
|
118
|
+
* nought would be read as *this audience does nothing on your page*, which is
|
|
119
|
+
* the most confident wrong sentence this reading could print. That was argued
|
|
120
|
+
* here first (0303), with `ActionChangeSilence.unwalked` left naming the state
|
|
121
|
+
* alone, and settled for both by moving the rule into the reading (0304), so
|
|
122
|
+
* the two no longer differ. The census of what each form has still answers,
|
|
123
|
+
* because which parts a form carries is a fact about the deltas and about no
|
|
124
|
+
* counter.
|
|
125
|
+
*
|
|
126
|
+
* Checked before `nothing-measured`, and **a single
|
|
127
|
+
* window can reach both**, so the order is a decision rather than reading
|
|
128
|
+
* order: a side with no page views and occurrences filed against its parts is
|
|
129
|
+
* a sender that is not one, and *this window does not report where actions
|
|
130
|
+
* happened* is the sharper of the two things to say about it.
|
|
131
|
+
*/
|
|
132
|
+
| "unwalked"
|
|
133
|
+
/**
|
|
134
|
+
* One of the two windows held no page views.
|
|
135
|
+
*
|
|
136
|
+
* Every standing on that side is `unknown` (0242), so there is no share to
|
|
137
|
+
* compare and every gap is already withheld. **The census still answers**,
|
|
138
|
+
* which is what this member has in common with its spelling everywhere else:
|
|
139
|
+
* *the pro form has three bands the free form does not, and nothing has been
|
|
140
|
+
* measured on either* is a sentence worth printing.
|
|
141
|
+
*/
|
|
142
|
+
| "nothing-measured";
|
|
143
|
+
/** The closed set, for a surface that has to account for every absent figure. */
|
|
144
|
+
export declare const FORM_ACTION_SILENCES: readonly FormActionSilence[];
|
|
145
|
+
/** One line per silence, for a surface saying why a figure is not there. */
|
|
146
|
+
export declare const describeFormActionSilence: (silence: FormActionSilence) => string;
|
|
147
|
+
/** One side of the comparison, as the reading of what its readers did leaves it. */
|
|
148
|
+
export type FormActionSide = {
|
|
149
|
+
readonly treeId: TreeId;
|
|
150
|
+
readonly revision: number;
|
|
151
|
+
/** `null` where the window named none, or named two with neither asked for. */
|
|
152
|
+
readonly audienceId: AudienceId | null;
|
|
153
|
+
/**
|
|
154
|
+
* That side's page-view floor, carried through unchanged.
|
|
155
|
+
*
|
|
156
|
+
* A floor rather than a count, for the reason `parts.ts` gives: distinct view
|
|
157
|
+
* counts cannot be added across rows (0147), so the largest row is the most
|
|
158
|
+
* that can be said from counters alone. Nothing here divides by it — every
|
|
159
|
+
* share in this reading is off one row — and it is carried so a surface can
|
|
160
|
+
* say how big each population was beside what it did.
|
|
161
|
+
*/
|
|
162
|
+
readonly views: number;
|
|
163
|
+
/** Element nodes this form has, which two forms of one page need not share. */
|
|
164
|
+
readonly parts: number;
|
|
165
|
+
/** Parts with no element parts under them, whose share is withheld structurally. */
|
|
166
|
+
readonly leaves: number;
|
|
167
|
+
/** Whether this side holds uses and credits them to nobody (0167). */
|
|
168
|
+
readonly unwalked: boolean;
|
|
169
|
+
};
|
|
170
|
+
/** A part exactly one of the two forms has, with the form that has it named. */
|
|
171
|
+
export type PartActionOfForm = {
|
|
172
|
+
readonly nodeId: NodeId;
|
|
173
|
+
readonly type: PrimitiveType;
|
|
174
|
+
readonly role: PrimitiveRole | null;
|
|
175
|
+
/** The form this part is in. The other form does not have this node at all. */
|
|
176
|
+
readonly audienceId: AudienceId;
|
|
177
|
+
readonly side: PartAction;
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* A part both forms have, as each form's own readers used it.
|
|
181
|
+
*
|
|
182
|
+
* Each side is the whole {@link PartAction} rather than a narrowed copy of it,
|
|
183
|
+
* because that reading already withholds its share in exactly the states where
|
|
184
|
+
* a share is not a measurement, and a second type restating three of its fields
|
|
185
|
+
* would be a second place to get that wrong.
|
|
186
|
+
*/
|
|
187
|
+
export type ComparedFormAction = {
|
|
188
|
+
readonly nodeId: NodeId;
|
|
189
|
+
/** The type {@link FormActionComparison.one} gives it; `disagreed` names the pair if the other differs. */
|
|
190
|
+
readonly type: PrimitiveType;
|
|
191
|
+
readonly role: PrimitiveRole | null;
|
|
192
|
+
readonly one: PartAction;
|
|
193
|
+
readonly other: PartAction;
|
|
194
|
+
/**
|
|
195
|
+
* The form whose readers acted inside it more often, or `null` where no claim
|
|
196
|
+
* stands.
|
|
197
|
+
*
|
|
198
|
+
* `null` with a {@link ComparedFormAction.gap} of nought is the two forms
|
|
199
|
+
* acting alike; `null` with a `gap` of `null` is nothing being sayable. The
|
|
200
|
+
* two are a long way apart and are deliberately not one value.
|
|
201
|
+
*/
|
|
202
|
+
readonly favours: AudienceId | null;
|
|
203
|
+
/**
|
|
204
|
+
* The distance between the two shares, which is never signed.
|
|
205
|
+
*
|
|
206
|
+
* `|one.share − other.share|`, with the direction in
|
|
207
|
+
* {@link ComparedFormAction.favours} rather than in the sign — because a sign
|
|
208
|
+
* is read against an order, and the order here is the alphabet of two
|
|
209
|
+
* audience names and means nothing (0302).
|
|
210
|
+
*
|
|
211
|
+
* `null` where either side withholds its share — a leaf, a part with no row,
|
|
212
|
+
* a part nobody reached — **and on every part of a pair where either side is
|
|
213
|
+
* unwalked**, where the noughts are a filing artefact rather than readers who
|
|
214
|
+
* did nothing.
|
|
215
|
+
*/
|
|
216
|
+
readonly gap: number | null;
|
|
217
|
+
};
|
|
218
|
+
/** How the shared parts fell, as a count over one set and never a mean. */
|
|
219
|
+
export type FormActionsCounted = {
|
|
220
|
+
/** Parts {@link FormActionComparison.one}'s readers acted inside more often. */
|
|
221
|
+
readonly one: number;
|
|
222
|
+
/** Parts {@link FormActionComparison.other}'s readers acted inside more often. */
|
|
223
|
+
readonly other: number;
|
|
224
|
+
/** Parts the two forms acted inside alike. */
|
|
225
|
+
readonly alike: number;
|
|
226
|
+
/** Parts where one side or the other cannot say. */
|
|
227
|
+
readonly unknown: number;
|
|
228
|
+
};
|
|
229
|
+
/**
|
|
230
|
+
* What two forms' readers did inside one page, held against each other.
|
|
231
|
+
*
|
|
232
|
+
* There is no `treeId` or `revision` at the top, where every reading of one
|
|
233
|
+
* page has one, for the reason 0302 gives: this is a reading of two sides
|
|
234
|
+
* rather than of one page, and the two refusals that matter most are exactly
|
|
235
|
+
* the two where picking one side's would be picking one of two answers.
|
|
236
|
+
*/
|
|
237
|
+
export type FormActionComparison = {
|
|
238
|
+
/** The side whose audience id sorts lower, or the first argument where no pair of names stands. */
|
|
239
|
+
readonly one: FormActionSide;
|
|
240
|
+
readonly other: FormActionSide;
|
|
241
|
+
/** The two readings this comparison was taken from, so nothing downstream derives them twice. */
|
|
242
|
+
readonly readings: {
|
|
243
|
+
readonly one: PageAction;
|
|
244
|
+
readonly other: PageAction;
|
|
245
|
+
};
|
|
246
|
+
/** Parts both forms have, in the reading order of {@link FormActionComparison.one}. */
|
|
247
|
+
readonly compared: readonly ComparedFormAction[];
|
|
248
|
+
/** Parts exactly one form has, by audience and then by node. */
|
|
249
|
+
readonly onlyIn: readonly PartActionOfForm[];
|
|
250
|
+
/**
|
|
251
|
+
* Shared nodes the two forms give different primitive types.
|
|
252
|
+
*
|
|
253
|
+
* Reported and not dropped, as `FormComparison.disagreed` is: the two shares
|
|
254
|
+
* are each their own form's and stay comparable, while a pair that is a band
|
|
255
|
+
* on one side and a card on the other is a fact about the deltas nobody would
|
|
256
|
+
* otherwise see.
|
|
257
|
+
*/
|
|
258
|
+
readonly disagreed: readonly NodeId[];
|
|
259
|
+
/**
|
|
260
|
+
* Shared nodes one form gives an inside and the other does not.
|
|
261
|
+
*
|
|
262
|
+
* The diagnosis this reading needs and its sibling does not. A share is
|
|
263
|
+
* withheld on a leaf for a structural reason, so a part the deltas filled for
|
|
264
|
+
* one audience and left bare for the other has a share on one side and none
|
|
265
|
+
* on the other — and the pair lands in `unknown` with nothing saying why.
|
|
266
|
+
* *The riders' version of this band has nothing in it* is the answer, and it
|
|
267
|
+
* is a fact about the deltas rather than about either readership.
|
|
268
|
+
*/
|
|
269
|
+
readonly insideDisagreed: readonly NodeId[];
|
|
270
|
+
readonly counted: FormActionsCounted;
|
|
271
|
+
/**
|
|
272
|
+
* The root, held against itself across the two forms.
|
|
273
|
+
*
|
|
274
|
+
* The one page-level claim either form comparison makes, and it is a division
|
|
275
|
+
* rather than an addition: see the module documentation. `null` where the
|
|
276
|
+
* revision's root is not an element part of both forms.
|
|
277
|
+
*/
|
|
278
|
+
readonly whole: ComparedFormAction | null;
|
|
279
|
+
/**
|
|
280
|
+
* The shared part with the widest gap, by node id where two tie.
|
|
281
|
+
*
|
|
282
|
+
* The page itself is never it, because it contains every part it would
|
|
283
|
+
* outrank. `null` where nothing can say.
|
|
284
|
+
*/
|
|
285
|
+
readonly sharpest: ComparedFormAction | null;
|
|
286
|
+
readonly silence: FormActionSilence | null;
|
|
287
|
+
};
|
|
288
|
+
/**
|
|
289
|
+
* Hold what two forms' readers did against each other.
|
|
290
|
+
*
|
|
291
|
+
* Takes two page readings, each of one audience, of one tree at one revision,
|
|
292
|
+
* and derives what readers did on each — handed two readings rather than two
|
|
293
|
+
* finished `PageAction`s for the reason `actionChangeOf` is: one input per side
|
|
294
|
+
* cannot be a mismatched pair, and the two it derives travel on the comparison
|
|
295
|
+
* so nothing downstream pays for them twice.
|
|
296
|
+
*
|
|
297
|
+
* The labels are not `was` and `now` and the order of the arguments does not
|
|
298
|
+
* reach the answer: see `formPairOf`, and {@link FormActionSilence} for the
|
|
299
|
+
* seven states in which there is no figure.
|
|
300
|
+
*/
|
|
301
|
+
export declare const formActionComparisonOf: (one: PageReading, other: PageReading) => FormActionComparison;
|
|
302
|
+
//# sourceMappingURL=form-action.d.ts.map
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { everyMemberOf } from "../closed-set.js";
|
|
2
|
+
import { pageActionOf } from "./action.js";
|
|
3
|
+
import { describeFormPairRefusal, formPairOf, FORM_PAIR_REFUSALS, } from "./audiences.js";
|
|
4
|
+
/** The closed set, for a surface that has to account for every absent figure. */
|
|
5
|
+
export const FORM_ACTION_SILENCES = everyMemberOf()([...FORM_PAIR_REFUSALS, "unwalked", "nothing-measured"]);
|
|
6
|
+
/** One line per silence, for a surface saying why a figure is not there. */
|
|
7
|
+
export const describeFormActionSilence = (silence) => {
|
|
8
|
+
switch (silence) {
|
|
9
|
+
case "unwalked":
|
|
10
|
+
return "one of the two windows does not report where actions happened, so its shares are noughts";
|
|
11
|
+
case "nothing-measured":
|
|
12
|
+
return "one of the two windows held no page views";
|
|
13
|
+
default:
|
|
14
|
+
return describeFormPairRefusal(silence);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const NOTHING_COUNTED = Object.freeze({
|
|
18
|
+
one: 0,
|
|
19
|
+
other: 0,
|
|
20
|
+
alike: 0,
|
|
21
|
+
unknown: 0,
|
|
22
|
+
});
|
|
23
|
+
const sideOf = (reading, audienceId) => ({
|
|
24
|
+
treeId: reading.treeId,
|
|
25
|
+
revision: reading.revision,
|
|
26
|
+
audienceId,
|
|
27
|
+
views: reading.views,
|
|
28
|
+
parts: reading.parts.length,
|
|
29
|
+
leaves: reading.leaves,
|
|
30
|
+
unwalked: reading.unwalked,
|
|
31
|
+
});
|
|
32
|
+
/**
|
|
33
|
+
* The gap, and the one rule that withholds it.
|
|
34
|
+
*
|
|
35
|
+
* A share is absent wherever it is not a measurement, which is the whole of it:
|
|
36
|
+
* a leaf, a part with no row and a part nobody reached (0242), **and every part
|
|
37
|
+
* of an unwalked window** (0304). 0303 withheld the second case here, with a
|
|
38
|
+
* `walked` argument of its own; the rule now lives in the reading that can see
|
|
39
|
+
* the fault, so this is one check again and the cases cannot disagree.
|
|
40
|
+
*/
|
|
41
|
+
const gapOf = (one, other) => one.share === undefined || other.share === undefined
|
|
42
|
+
? null
|
|
43
|
+
: Math.abs(one.share - other.share);
|
|
44
|
+
const favouredBy = (gap, one, other, audiences) => {
|
|
45
|
+
if (gap === null || gap === 0)
|
|
46
|
+
return null;
|
|
47
|
+
return (one.share ?? 0) > (other.share ?? 0) ? audiences.one : audiences.other;
|
|
48
|
+
};
|
|
49
|
+
/** The parts of a reading by node, which the two sides are joined on. */
|
|
50
|
+
const partsOf = (reading) => new Map(reading.parts.map((part) => [part.nodeId, part]));
|
|
51
|
+
/**
|
|
52
|
+
* Hold what two forms' readers did against each other.
|
|
53
|
+
*
|
|
54
|
+
* Takes two page readings, each of one audience, of one tree at one revision,
|
|
55
|
+
* and derives what readers did on each — handed two readings rather than two
|
|
56
|
+
* finished `PageAction`s for the reason `actionChangeOf` is: one input per side
|
|
57
|
+
* cannot be a mismatched pair, and the two it derives travel on the comparison
|
|
58
|
+
* so nothing downstream pays for them twice.
|
|
59
|
+
*
|
|
60
|
+
* The labels are not `was` and `now` and the order of the arguments does not
|
|
61
|
+
* reach the answer: see `formPairOf`, and {@link FormActionSilence} for the
|
|
62
|
+
* seven states in which there is no figure.
|
|
63
|
+
*/
|
|
64
|
+
export const formActionComparisonOf = (one, other) => {
|
|
65
|
+
const pair = formPairOf(one, other);
|
|
66
|
+
const readings = { one: pageActionOf(pair.one), other: pageActionOf(pair.other) };
|
|
67
|
+
if (pair.pairing === "refused")
|
|
68
|
+
return {
|
|
69
|
+
one: sideOf(readings.one, pair.one.audienceId),
|
|
70
|
+
other: sideOf(readings.other, pair.other.audienceId),
|
|
71
|
+
readings,
|
|
72
|
+
compared: [],
|
|
73
|
+
onlyIn: [],
|
|
74
|
+
disagreed: [],
|
|
75
|
+
insideDisagreed: [],
|
|
76
|
+
counted: NOTHING_COUNTED,
|
|
77
|
+
whole: null,
|
|
78
|
+
sharpest: null,
|
|
79
|
+
silence: pair.refusal,
|
|
80
|
+
};
|
|
81
|
+
const audiences = pair.audiences;
|
|
82
|
+
const held = { one: partsOf(readings.one), other: partsOf(readings.other) };
|
|
83
|
+
const compared = [];
|
|
84
|
+
const onlyIn = [];
|
|
85
|
+
const disagreed = [];
|
|
86
|
+
const insideDisagreed = [];
|
|
87
|
+
const counted = { ...NOTHING_COUNTED };
|
|
88
|
+
for (const part of readings.one.parts) {
|
|
89
|
+
const across = held.other.get(part.nodeId);
|
|
90
|
+
if (across === undefined) {
|
|
91
|
+
onlyIn.push({
|
|
92
|
+
nodeId: part.nodeId,
|
|
93
|
+
type: part.type,
|
|
94
|
+
role: part.role,
|
|
95
|
+
audienceId: audiences.one,
|
|
96
|
+
side: part,
|
|
97
|
+
});
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (across.type !== part.type)
|
|
101
|
+
disagreed.push(part.nodeId);
|
|
102
|
+
if (across.bearsParts !== part.bearsParts)
|
|
103
|
+
insideDisagreed.push(part.nodeId);
|
|
104
|
+
const gap = gapOf(part, across);
|
|
105
|
+
const favours = favouredBy(gap, part, across, audiences);
|
|
106
|
+
if (gap === null)
|
|
107
|
+
counted.unknown += 1;
|
|
108
|
+
else if (favours === null)
|
|
109
|
+
counted.alike += 1;
|
|
110
|
+
else if (favours === audiences.one)
|
|
111
|
+
counted.one += 1;
|
|
112
|
+
else
|
|
113
|
+
counted.other += 1;
|
|
114
|
+
compared.push({
|
|
115
|
+
nodeId: part.nodeId,
|
|
116
|
+
type: part.type,
|
|
117
|
+
role: part.role,
|
|
118
|
+
one: part,
|
|
119
|
+
other: across,
|
|
120
|
+
favours,
|
|
121
|
+
gap,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
for (const part of readings.other.parts) {
|
|
125
|
+
if (held.one.has(part.nodeId))
|
|
126
|
+
continue;
|
|
127
|
+
onlyIn.push({
|
|
128
|
+
nodeId: part.nodeId,
|
|
129
|
+
type: part.type,
|
|
130
|
+
role: part.role,
|
|
131
|
+
audienceId: audiences.other,
|
|
132
|
+
side: part,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
const whole = compared.find((part) => part.one.depth === 0 && part.other.depth === 0) ?? null;
|
|
136
|
+
/**
|
|
137
|
+
* The widest gap, with the node id as the tiebreak so that two parts a form
|
|
138
|
+
* acts in equally differently do not swap places between two reads of one
|
|
139
|
+
* store.
|
|
140
|
+
*/
|
|
141
|
+
const sharpest = compared.reduce((widest, part) => {
|
|
142
|
+
if (part.gap === null || part === whole)
|
|
143
|
+
return widest;
|
|
144
|
+
if (widest === null || widest.gap === null)
|
|
145
|
+
return part;
|
|
146
|
+
if (part.gap > widest.gap)
|
|
147
|
+
return part;
|
|
148
|
+
return part.gap === widest.gap && part.nodeId.localeCompare(widest.nodeId) < 0 ? part : widest;
|
|
149
|
+
}, null);
|
|
150
|
+
const silence = () => {
|
|
151
|
+
if (readings.one.unwalked || readings.other.unwalked)
|
|
152
|
+
return "unwalked";
|
|
153
|
+
return readings.one.views === 0 || readings.other.views === 0 ? "nothing-measured" : null;
|
|
154
|
+
};
|
|
155
|
+
return {
|
|
156
|
+
one: sideOf(readings.one, audiences.one),
|
|
157
|
+
other: sideOf(readings.other, audiences.other),
|
|
158
|
+
readings,
|
|
159
|
+
compared,
|
|
160
|
+
onlyIn: [...onlyIn].sort((a, b) => a.audienceId.localeCompare(b.audienceId) || a.nodeId.localeCompare(b.nodeId)),
|
|
161
|
+
disagreed: [...disagreed].sort((a, b) => a.localeCompare(b)),
|
|
162
|
+
insideDisagreed: [...insideDisagreed].sort((a, b) => a.localeCompare(b)),
|
|
163
|
+
counted,
|
|
164
|
+
whole,
|
|
165
|
+
sharpest,
|
|
166
|
+
silence: silence(),
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
//# sourceMappingURL=form-action.js.map
|