@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.
- 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/audience/compose.d.ts +112 -0
- package/dist/audience/compose.js +134 -0
- package/dist/audience/memory.d.ts +14 -0
- package/dist/audience/memory.js +71 -0
- package/dist/audience/overlay-store.d.ts +343 -0
- package/dist/audience/overlay-store.js +217 -0
- package/dist/audience/rule.d.ts +121 -0
- package/dist/audience/rule.js +78 -0
- package/dist/cli/index.d.ts +3 -4
- package/dist/cli/index.js +3 -4
- package/dist/cli/templates.js +19 -0
- package/dist/data/adapter.d.ts +9 -1
- package/dist/data/adapter.js +2 -0
- package/dist/data/plan.js +0 -0
- package/dist/data/resolution.d.ts +23 -1
- package/dist/data/resolve.d.ts +31 -4
- 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/interpretation/anthropic.d.ts +1 -1
- package/dist/interpretation/anthropic.js +2 -22
- package/dist/interpretation/client.d.ts +1 -1
- package/dist/interpretation/materialize.js +67 -22
- package/dist/interpretation/openai-compatible.d.ts +36 -0
- package/dist/interpretation/openai-compatible.js +79 -0
- package/dist/interpretation/status.d.ts +19 -0
- package/dist/interpretation/status.js +26 -0
- package/dist/live/index.d.ts +73 -0
- package/dist/live/index.js +73 -0
- package/dist/live/pages.d.ts +187 -0
- package/dist/live/pages.js +161 -0
- package/dist/live/pull.d.ts +147 -0
- package/dist/live/pull.js +398 -0
- package/dist/live/pulling.d.ts +79 -0
- package/dist/live/pulling.js +117 -0
- package/dist/live/window.d.ts +129 -0
- package/dist/live/window.js +132 -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/addressed.d.ts +35 -0
- package/dist/render/addressed.js +79 -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/document-theme.d.ts +70 -0
- package/dist/render/document-theme.js +139 -0
- package/dist/render/editable.d.ts +15 -1
- package/dist/render/editable.js +13 -1
- package/dist/render/expected.d.ts +98 -0
- package/dist/render/expected.js +88 -0
- package/dist/render/index.d.ts +4 -0
- package/dist/render/index.js +4 -0
- package/dist/render/reads.d.ts +11 -0
- package/dist/render/reads.js +12 -1
- package/dist/render/render.d.ts +11 -0
- package/dist/render/render.js +294 -53
- package/dist/render/request.d.ts +8 -1
- package/dist/render/request.js +1 -0
- 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/auto-apply-ceiling.d.ts +54 -0
- package/dist/runtime/auto-apply-ceiling.js +66 -0
- 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 +91 -10
- package/dist/runtime/index.d.ts +4 -0
- package/dist/runtime/index.js +4 -0
- package/dist/runtime/irreversibility.d.ts +64 -0
- package/dist/runtime/irreversibility.js +45 -0
- package/dist/runtime/nesting.d.ts +13 -1
- package/dist/runtime/nesting.js +41 -24
- 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 +305 -0
- package/dist/runtime/policy-log.d.ts +406 -0
- package/dist/runtime/policy-log.js +285 -0
- package/dist/runtime/policy.d.ts +8 -6
- package/dist/runtime/policy.js +5 -2
- package/dist/runtime/repointing.js +0 -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 +129 -5
- package/dist/sdk/definition.js +66 -0
- package/dist/sdk/registry.d.ts +45 -2
- package/dist/sdk/registry.js +102 -1
- package/dist/signals/acted.contract.d.ts +21 -0
- package/dist/signals/acted.contract.js +236 -0
- package/dist/signals/acted.d.ts +359 -0
- package/dist/signals/acted.js +135 -0
- 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/agenda.d.ts +585 -0
- package/dist/signals/agenda.js +295 -0
- package/dist/signals/applied-window.contract.d.ts +23 -0
- package/dist/signals/applied-window.contract.js +160 -0
- package/dist/signals/arrivals.contract.d.ts +21 -0
- package/dist/signals/arrivals.contract.js +180 -0
- package/dist/signals/arrivals.d.ts +375 -0
- package/dist/signals/arrivals.js +254 -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 +33 -17
- package/dist/signals/broadcast.js +255 -32
- package/dist/signals/change.d.ts +378 -0
- package/dist/signals/change.js +327 -0
- package/dist/signals/collect.d.ts +169 -34
- package/dist/signals/collect.js +186 -38
- package/dist/signals/conversion.d.ts +348 -0
- package/dist/signals/conversion.js +235 -0
- 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/correlated.contract.d.ts +24 -0
- package/dist/signals/correlated.contract.js +94 -0
- package/dist/signals/counters.d.ts +97 -0
- package/dist/signals/counters.js +160 -0
- package/dist/signals/deliver.d.ts +23 -4
- package/dist/signals/deliver.js +34 -6
- package/dist/signals/deployment-change.d.ts +395 -0
- package/dist/signals/deployment-change.js +309 -0
- package/dist/signals/deployment.d.ts +278 -0
- package/dist/signals/deployment.js +178 -0
- package/dist/signals/door.d.ts +114 -0
- package/dist/signals/door.js +77 -0
- package/dist/signals/expire.d.ts +192 -0
- package/dist/signals/expire.js +213 -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/frontier.d.ts +268 -0
- package/dist/signals/frontier.js +145 -0
- package/dist/signals/funnel-change.d.ts +548 -0
- package/dist/signals/funnel-change.js +361 -0
- package/dist/signals/funnel-hours.contract.d.ts +21 -0
- package/dist/signals/funnel-hours.contract.js +221 -0
- package/dist/signals/funnel-hours.d.ts +293 -0
- package/dist/signals/funnel-hours.js +99 -0
- package/dist/signals/funnel.d.ts +592 -0
- package/dist/signals/funnel.js +231 -0
- package/dist/signals/health.d.ts +694 -0
- package/dist/signals/health.js +573 -0
- package/dist/signals/index.d.ts +60 -0
- package/dist/signals/index.js +60 -0
- package/dist/signals/ingest.d.ts +56 -1
- package/dist/signals/ingest.js +91 -1
- package/dist/signals/inside.d.ts +190 -0
- package/dist/signals/inside.js +263 -0
- package/dist/signals/join.d.ts +56 -0
- package/dist/signals/join.js +60 -0
- package/dist/signals/journal.d.ts +123 -9
- package/dist/signals/kept.contract.d.ts +22 -0
- package/dist/signals/kept.contract.js +111 -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-agenda-change.d.ts +324 -0
- package/dist/signals/library-agenda-change.js +199 -0
- package/dist/signals/library-agenda.d.ts +258 -0
- package/dist/signals/library-agenda.js +167 -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 +646 -0
- package/dist/signals/library-reach-change.js +542 -0
- package/dist/signals/library-reach.d.ts +377 -0
- package/dist/signals/library-reach.js +227 -0
- package/dist/signals/library-senders-change.d.ts +457 -0
- package/dist/signals/library-senders-change.js +367 -0
- package/dist/signals/library-senders-reach-change.d.ts +486 -0
- package/dist/signals/library-senders-reach-change.js +538 -0
- package/dist/signals/library-senders-reach.d.ts +340 -0
- package/dist/signals/library-senders-reach.js +252 -0
- package/dist/signals/library-senders.d.ts +271 -0
- package/dist/signals/library-senders.js +180 -0
- package/dist/signals/library-word-reach-change.d.ts +567 -0
- package/dist/signals/library-word-reach-change.js +564 -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 +246 -14
- package/dist/signals/migrate.d.ts +20 -4
- package/dist/signals/migrate.js +269 -8
- package/dist/signals/notice.d.ts +389 -0
- package/dist/signals/notice.js +250 -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/part-pace.d.ts +378 -0
- package/dist/signals/part-pace.js +333 -0
- package/dist/signals/parts.d.ts +354 -0
- package/dist/signals/parts.js +232 -0
- package/dist/signals/postgres.d.ts +16 -2
- package/dist/signals/postgres.js +753 -76
- 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 +163 -0
- package/dist/signals/retention.js +75 -0
- package/dist/signals/rhythm.d.ts +302 -0
- package/dist/signals/rhythm.js +262 -0
- package/dist/signals/rollup.d.ts +194 -4
- package/dist/signals/rollup.js +0 -0
- package/dist/signals/schema.d.ts +1069 -1
- package/dist/signals/schema.js +393 -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 +1147 -0
- package/dist/signals/silences.js +996 -0
- package/dist/signals/subtrees.d.ts +123 -0
- package/dist/signals/subtrees.js +102 -0
- package/dist/signals/tally.d.ts +262 -12
- package/dist/signals/unread.d.ts +292 -0
- package/dist/signals/unread.js +137 -0
- package/dist/signals/window-agenda.d.ts +276 -0
- package/dist/signals/window-agenda.js +83 -0
- package/dist/signals/window-figures.d.ts +148 -0
- package/dist/signals/window-figures.js +42 -0
- package/dist/signals/window-funnels.d.ts +88 -0
- package/dist/signals/window-funnels.js +47 -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/cache.d.ts +101 -0
- package/dist/store/cache.js +149 -0
- package/dist/store/history.d.ts +82 -0
- package/dist/store/history.js +36 -0
- package/dist/store/index.d.ts +30 -0
- package/dist/store/index.js +30 -0
- package/dist/store/memory.d.ts +2 -1
- package/dist/store/memory.js +48 -12
- package/dist/store/migrate.d.ts +106 -0
- package/dist/store/migrate.js +323 -7
- package/dist/store/postgres-applications.d.ts +4 -0
- package/dist/store/postgres-applications.js +197 -0
- package/dist/store/postgres-audience.d.ts +14 -0
- package/dist/store/postgres-audience.js +272 -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 +17 -1
- package/dist/store/postgres.js +60 -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 +762 -2
- package/dist/store/schema.js +218 -5
- package/dist/store/source.d.ts +57 -1
- package/dist/store/source.js +65 -1
- package/dist/store/store.d.ts +29 -6
- package/dist/submit/resolve.d.ts +1 -1
- 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 +2 -0
- package/dist/telemetry/index.js +2 -0
- package/dist/telemetry/journal.d.ts +104 -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 +33 -1
- package/dist/telemetry/migrate.js +22 -1
- package/dist/telemetry/postgres.d.ts +10 -1
- package/dist/telemetry/postgres.js +188 -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/telemetry/window.d.ts +135 -0
- package/dist/telemetry/window.js +101 -0
- package/dist/testing/application-contract.d.ts +14 -0
- package/dist/testing/application-contract.js +270 -0
- package/dist/testing/audience-overlay-contract.d.ts +31 -0
- package/dist/testing/audience-overlay-contract.js +354 -0
- package/dist/testing/contracts.d.ts +13 -7
- package/dist/testing/contracts.js +13 -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 +297 -6
- 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/contrast.d.ts +19 -14
- package/dist/theme/contrast.js +181 -17
- 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/apply.js +13 -0
- package/dist/tree/compare.d.ts +9 -0
- package/dist/tree/compare.js +18 -0
- package/dist/tree/mutation.d.ts +18 -0
- package/dist/tree/mutation.js +24 -12
- package/dist/tree/navigation.d.ts +5 -0
- package/dist/tree/navigation.js +32 -10
- package/dist/tree/outline.d.ts +7 -0
- package/dist/tree/outline.js +9 -5
- 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 +25 -3
- package/dist/runtime/inverse-interpreter.d.ts +0 -90
- package/dist/runtime/inverse-interpreter.js +0 -56
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { everyMemberOf } from "../closed-set.js";
|
|
2
|
+
import { describeFormPairRefusal, formPairOf, FORM_PAIR_REFUSALS, } from "./audiences.js";
|
|
3
|
+
import { spokenFor } from "./parts.js";
|
|
4
|
+
/** The closed set, for a surface that has to account for every absent figure. */
|
|
5
|
+
export const FORM_COMPARISON_SILENCES = everyMemberOf()([...FORM_PAIR_REFUSALS, "nothing-measured"]);
|
|
6
|
+
/** One line per silence, for a surface saying why a figure is not there. */
|
|
7
|
+
export const describeFormComparisonSilence = (silence) => silence === "nothing-measured"
|
|
8
|
+
? "one of the two windows held no page views"
|
|
9
|
+
: describeFormPairRefusal(silence);
|
|
10
|
+
const NOTHING_COUNTED = Object.freeze({ one: 0, other: 0, alike: 0, unknown: 0 });
|
|
11
|
+
const sideOf = (reading) => ({
|
|
12
|
+
treeId: reading.treeId,
|
|
13
|
+
revision: reading.revision,
|
|
14
|
+
audienceId: reading.audienceId,
|
|
15
|
+
views: reading.views,
|
|
16
|
+
parts: reading.parts.length,
|
|
17
|
+
});
|
|
18
|
+
const partSideOf = (part, views) => {
|
|
19
|
+
const readers = part.counters?.reached ?? 0;
|
|
20
|
+
return {
|
|
21
|
+
standing: part.standing,
|
|
22
|
+
readers,
|
|
23
|
+
views,
|
|
24
|
+
reach: views > 0 ? readers / views : null,
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* The gap, and the rule that withholds it.
|
|
29
|
+
*
|
|
30
|
+
* Both sides have to be spoken for before a difference between them is a
|
|
31
|
+
* difference between two populations rather than between a measurement and a
|
|
32
|
+
* missing row (0282) — which is the same restriction `ComparedPassage.gain`
|
|
33
|
+
* carries, said of a part instead of a passage.
|
|
34
|
+
*/
|
|
35
|
+
const gapOf = (one, other) => one.reach === null || other.reach === null || !spokenFor(one.standing) || !spokenFor(other.standing)
|
|
36
|
+
? null
|
|
37
|
+
: Math.abs(one.reach - other.reach);
|
|
38
|
+
const favouredBy = (gap, one, other, audiences) => {
|
|
39
|
+
if (gap === null || gap === 0)
|
|
40
|
+
return null;
|
|
41
|
+
return (one.reach ?? 0) > (other.reach ?? 0) ? audiences.one : audiences.other;
|
|
42
|
+
};
|
|
43
|
+
/** The parts of a reading by node, which the two sides are joined on. */
|
|
44
|
+
const partsOf = (reading) => new Map(reading.parts.map((part) => [part.nodeId, part]));
|
|
45
|
+
/**
|
|
46
|
+
* Hold two forms of one page against each other.
|
|
47
|
+
*
|
|
48
|
+
* Takes two page readings, each of one audience, of one tree at one revision.
|
|
49
|
+
* The labels are not `was` and `now` and the order of the arguments does not
|
|
50
|
+
* reach the answer: see the module documentation, and
|
|
51
|
+
* {@link FormComparisonSilence} for the five states in which there is no pair.
|
|
52
|
+
*/
|
|
53
|
+
export const formComparisonOf = (one, other) => {
|
|
54
|
+
const pair = formPairOf(one, other);
|
|
55
|
+
const [first, second] = [pair.one, pair.other];
|
|
56
|
+
if (pair.pairing === "refused")
|
|
57
|
+
return {
|
|
58
|
+
one: sideOf(first),
|
|
59
|
+
other: sideOf(second),
|
|
60
|
+
compared: [],
|
|
61
|
+
onlyIn: [],
|
|
62
|
+
disagreed: [],
|
|
63
|
+
counted: NOTHING_COUNTED,
|
|
64
|
+
sharpest: null,
|
|
65
|
+
silence: pair.refusal,
|
|
66
|
+
};
|
|
67
|
+
const audiences = pair.audiences;
|
|
68
|
+
const held = { one: partsOf(first), other: partsOf(second) };
|
|
69
|
+
const compared = [];
|
|
70
|
+
const onlyIn = [];
|
|
71
|
+
const disagreed = [];
|
|
72
|
+
const counted = { ...NOTHING_COUNTED };
|
|
73
|
+
for (const part of first.parts) {
|
|
74
|
+
const across = held.other.get(part.nodeId);
|
|
75
|
+
if (across === undefined) {
|
|
76
|
+
onlyIn.push({
|
|
77
|
+
nodeId: part.nodeId,
|
|
78
|
+
type: part.type,
|
|
79
|
+
role: part.role,
|
|
80
|
+
audienceId: audiences.one,
|
|
81
|
+
side: partSideOf(part, first.views),
|
|
82
|
+
});
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (across.type !== part.type)
|
|
86
|
+
disagreed.push(part.nodeId);
|
|
87
|
+
const sides = {
|
|
88
|
+
one: partSideOf(part, first.views),
|
|
89
|
+
other: partSideOf(across, second.views),
|
|
90
|
+
};
|
|
91
|
+
const gap = gapOf(sides.one, sides.other);
|
|
92
|
+
const favours = favouredBy(gap, sides.one, sides.other, audiences);
|
|
93
|
+
if (gap === null)
|
|
94
|
+
counted.unknown += 1;
|
|
95
|
+
else if (favours === null)
|
|
96
|
+
counted.alike += 1;
|
|
97
|
+
else if (favours === audiences.one)
|
|
98
|
+
counted.one += 1;
|
|
99
|
+
else
|
|
100
|
+
counted.other += 1;
|
|
101
|
+
compared.push({
|
|
102
|
+
nodeId: part.nodeId,
|
|
103
|
+
type: part.type,
|
|
104
|
+
role: part.role,
|
|
105
|
+
one: sides.one,
|
|
106
|
+
other: sides.other,
|
|
107
|
+
favours,
|
|
108
|
+
gap,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
for (const part of second.parts) {
|
|
112
|
+
if (held.one.has(part.nodeId))
|
|
113
|
+
continue;
|
|
114
|
+
onlyIn.push({
|
|
115
|
+
nodeId: part.nodeId,
|
|
116
|
+
type: part.type,
|
|
117
|
+
role: part.role,
|
|
118
|
+
audienceId: audiences.other,
|
|
119
|
+
side: partSideOf(part, second.views),
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* The widest gap, with the node id as the tiebreak so that two parts a form
|
|
124
|
+
* reaches equally differently do not swap places between two reads of one
|
|
125
|
+
* store.
|
|
126
|
+
*/
|
|
127
|
+
const sharpest = compared.reduce((widest, part) => {
|
|
128
|
+
if (part.gap === null)
|
|
129
|
+
return widest;
|
|
130
|
+
if (widest === null || widest.gap === null)
|
|
131
|
+
return part;
|
|
132
|
+
if (part.gap > widest.gap)
|
|
133
|
+
return part;
|
|
134
|
+
return part.gap === widest.gap && part.nodeId.localeCompare(widest.nodeId) < 0 ? part : widest;
|
|
135
|
+
}, null);
|
|
136
|
+
return {
|
|
137
|
+
one: sideOf(first),
|
|
138
|
+
other: sideOf(second),
|
|
139
|
+
compared,
|
|
140
|
+
onlyIn: [...onlyIn].sort((a, b) => a.audienceId.localeCompare(b.audienceId) || a.nodeId.localeCompare(b.nodeId)),
|
|
141
|
+
disagreed: [...disagreed].sort((a, b) => a.localeCompare(b)),
|
|
142
|
+
counted,
|
|
143
|
+
sharpest,
|
|
144
|
+
silence: first.views === 0 || second.views === 0 ? "nothing-measured" : null,
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
//# sourceMappingURL=forms.js.map
|
|
@@ -0,0 +1,268 @@
|
|
|
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 { PageReading, PartStanding } from "./parts.js";
|
|
6
|
+
/**
|
|
7
|
+
* **Where a window's reading of a page stopped.**
|
|
8
|
+
*
|
|
9
|
+
* [`parts.ts`](parts.ts) says, for every part of one revision, whether any view
|
|
10
|
+
* reported reaching it. That is the question *which parts of a page are read and
|
|
11
|
+
* which are scrolled past* answered part by part, and part by part is not how
|
|
12
|
+
* the answer is true.
|
|
13
|
+
*
|
|
14
|
+
* ## Forty skipped parts are usually one skipped part
|
|
15
|
+
*
|
|
16
|
+
* A page whose pricing band never came into anybody's viewport has a band, the
|
|
17
|
+
* rows inside it, the cells inside those and every heading and price among them
|
|
18
|
+
* all reporting `skipped` — because none of them was reached, which is one fact
|
|
19
|
+
* about one band restated once per node underneath it.
|
|
20
|
+
* {@link PageReading.standings} counts forty, and a screen drawing that number
|
|
21
|
+
* says *forty parts of this page go unread* about a page with **one** place a
|
|
22
|
+
* reader stopped.
|
|
23
|
+
*
|
|
24
|
+
* It is the plausible-false-number failure in its worst direction: the figure is
|
|
25
|
+
* the right shape, it moves when the page changes, and it is forty times the
|
|
26
|
+
* size of the thing to fix. A fix-list built on it would list the forty and lead
|
|
27
|
+
* with whichever one happened to sort first.
|
|
28
|
+
*
|
|
29
|
+
* **So the reading a surface wants is the frontier**: the parts that were not
|
|
30
|
+
* reached and whose containing part *was* — every place the reading of the page
|
|
31
|
+
* actually stopped — with everything beneath each of them counted as what that
|
|
32
|
+
* one stop costs.
|
|
33
|
+
*
|
|
34
|
+
* ## It is derivable, which is why it is here and not on the wire
|
|
35
|
+
*
|
|
36
|
+
* Nothing new is collected, stored or sent. A stop is *a part with no row whose
|
|
37
|
+
* container has one*, and the container is
|
|
38
|
+
* {@link PartReading.withinId} — the nearest addressed ancestor, derived from
|
|
39
|
+
* the tree the counters already name
|
|
40
|
+
* ([0368](../../decisions/0368-what-readers-did-inside-a-part-is-derived-from-the-tree-and-the-sum-is-exact-because-occurrences-add.md)
|
|
41
|
+
* clause 4). The browser has two attributes on an element and could not answer
|
|
42
|
+
* this at any payload: it does not know which of the nodes it is reporting on
|
|
43
|
+
* contains which others, and
|
|
44
|
+
* [0167](../../decisions/0167-a-delegated-signal-names-the-regions-it-happened-inside.md)
|
|
45
|
+
* refused to teach it for the high-volume kinds, which are exactly the kinds
|
|
46
|
+
* this reads.
|
|
47
|
+
*
|
|
48
|
+
* ## Every part is accounted for exactly once
|
|
49
|
+
*
|
|
50
|
+
* Each part that went unreached belongs to exactly one stop — itself where it is
|
|
51
|
+
* one, and otherwise the nearest stop above it — so the stops partition the
|
|
52
|
+
* unreached parts and their `unseen` figures add to
|
|
53
|
+
* {@link PageReading.standings}' `skipped` without a caller checking anything.
|
|
54
|
+
* The same partition carries the words: a part's `copy` is its own and never its
|
|
55
|
+
* subtree's (0122), so *the words nobody reached* is a concatenation rather than
|
|
56
|
+
* a deduplication.
|
|
57
|
+
*
|
|
58
|
+
* **Stops can nest, and only because of a defect.** A part that reported nothing
|
|
59
|
+
* while a part inside it reported reach was plainly on a reader's screen, so a
|
|
60
|
+
* skipped part containing a read one is a primitive not spreading its identity
|
|
61
|
+
* attributes — the failure `sdk/conformance.ts` exists to catch — and the read
|
|
62
|
+
* part's own children, if they went unreached, are a second stop inside the
|
|
63
|
+
* first. The partition is on the *nearest* stop for exactly this case, so the
|
|
64
|
+
* arithmetic holds while the defect is reported
|
|
65
|
+
* ({@link PageFrontier.notReporting}, {@link UnreachedPart.reportedBelow}) rather
|
|
66
|
+
* than quietly double-counted.
|
|
67
|
+
*
|
|
68
|
+
* ## A page nobody opened has no frontier
|
|
69
|
+
*
|
|
70
|
+
* `skipped` means *the window held views of this revision and none of them said
|
|
71
|
+
* anything about this part*, so a window with no views makes every part
|
|
72
|
+
* `unknown` and this reading empty — which is the honest answer and the one
|
|
73
|
+
* `parts.ts` was careful to make reachable. *A page every part of which was
|
|
74
|
+
* skipped* is not a state counters can produce.
|
|
75
|
+
*
|
|
76
|
+
* ## It is not `progress.ts`' stop, and the two words had to be kept apart
|
|
77
|
+
*
|
|
78
|
+
* [`progress.ts`](progress.ts) measures a **fall**: of the views that reached
|
|
79
|
+
* one part, how many reached the next part of the same run. That is a question
|
|
80
|
+
* about how many readers got past something, it is a ratio of two `reached`
|
|
81
|
+
* counts, and it needs both ends to have reported. This measures the opposite
|
|
82
|
+
* end of the same page: the parts that reported **nothing at all**, where there
|
|
83
|
+
* is no ratio to take and the only figure available is how much of the page one
|
|
84
|
+
* absence accounts for. A fall says *a third of them stopped here*; a frontier
|
|
85
|
+
* part says *this is as far as the reading goes, and nineteen parts are behind
|
|
86
|
+
* it*. `ReadingStop` is already that lane's word for the first, so nothing here
|
|
87
|
+
* is called a stop.
|
|
88
|
+
*
|
|
89
|
+
* Pure, and a function of a reading rather than of a tree: it reaches no store,
|
|
90
|
+
* no clock, no registry and no DOM, adds nothing to the broadcaster's import
|
|
91
|
+
* graph, and is linear in the parts of the page.
|
|
92
|
+
*/
|
|
93
|
+
/**
|
|
94
|
+
* One place the reading of a page stopped: a part no view reported reaching,
|
|
95
|
+
* sitting inside a part that was reached.
|
|
96
|
+
*/
|
|
97
|
+
export type UnreachedPart = {
|
|
98
|
+
readonly nodeId: NodeId;
|
|
99
|
+
readonly type: PrimitiveType;
|
|
100
|
+
/** What part it plays (0114), or `null` where its type declared none. */
|
|
101
|
+
readonly role: PrimitiveRole | null;
|
|
102
|
+
/** Depth in the tree, counting every node; 0 at the root. */
|
|
103
|
+
readonly depth: number;
|
|
104
|
+
/**
|
|
105
|
+
* The part it sits inside, and `null` at the outermost part — which is the
|
|
106
|
+
* one stop that means *the page itself was never reported on*.
|
|
107
|
+
*
|
|
108
|
+
* Never a part that was skipped as well: a skipped part inside a skipped part
|
|
109
|
+
* is the same stop stated twice, and only the outer one is here.
|
|
110
|
+
*/
|
|
111
|
+
readonly withinId: NodeId | null;
|
|
112
|
+
/**
|
|
113
|
+
* What that containing part's standing was.
|
|
114
|
+
*
|
|
115
|
+
* `read` is the ordinary stop — a reader had the container in front of them
|
|
116
|
+
* and went no further into it. `unknown` is the sharper one: the container
|
|
117
|
+
* reported something other than coming into view, so a reader acted on a part
|
|
118
|
+
* that no `viewed` ever named. `null` goes with a `null` container.
|
|
119
|
+
*/
|
|
120
|
+
readonly within: PartStanding | null;
|
|
121
|
+
/** Parts in its subtree, itself excluded, whatever each of them reported. */
|
|
122
|
+
readonly beneath: number;
|
|
123
|
+
/**
|
|
124
|
+
* Parts this stop accounts for, itself included — so 1 for a stop with
|
|
125
|
+
* nothing inside it.
|
|
126
|
+
*
|
|
127
|
+
* The unreached parts whose nearest stop is this one. Every stop's figure adds
|
|
128
|
+
* into {@link PageFrontier.unseen} and no part is in two of them, which is
|
|
129
|
+
* what makes *this is the one place to fix and it costs you this much of the
|
|
130
|
+
* page* a sentence rather than an estimate.
|
|
131
|
+
*/
|
|
132
|
+
readonly unseen: number;
|
|
133
|
+
/**
|
|
134
|
+
* Parts in its subtree that **did** report reach, which should be none.
|
|
135
|
+
*
|
|
136
|
+
* Above zero says a reader was below a part that said nothing about itself, so
|
|
137
|
+
* this stop is not the whole truth about what went unseen and the part is
|
|
138
|
+
* named in {@link PageFrontier.notReporting}.
|
|
139
|
+
*/
|
|
140
|
+
readonly reportedBelow: number;
|
|
141
|
+
/**
|
|
142
|
+
* The words nobody reached here, in reading order: this part's own and those
|
|
143
|
+
* of every part it accounts for.
|
|
144
|
+
*
|
|
145
|
+
* A part's words are its own and never its subtree's (0122), so these
|
|
146
|
+
* concatenate across stops without a headline being read twice.
|
|
147
|
+
*/
|
|
148
|
+
readonly words: readonly string[];
|
|
149
|
+
};
|
|
150
|
+
/** Where one window's reading of one revision of one page stopped. */
|
|
151
|
+
export type PageFrontier = {
|
|
152
|
+
readonly treeId: TreeId;
|
|
153
|
+
readonly revision: number;
|
|
154
|
+
/**
|
|
155
|
+
* The audience the reading was of, carried through from
|
|
156
|
+
* {@link PageReading.audienceId} unchanged.
|
|
157
|
+
*
|
|
158
|
+
* Carried rather than derived, and carried for one reason: an order over a
|
|
159
|
+
* deployment's pages tells two readings apart by this trio and refuses to
|
|
160
|
+
* count a page twice by it (`readingKeyOf`), and a frontier that dropped the
|
|
161
|
+
* audience would hand such an order two forms of one page it could not tell
|
|
162
|
+
* apart. It is the field `ReadingProgress.audienceId` is, for the reading
|
|
163
|
+
* beside it (0300).
|
|
164
|
+
*/
|
|
165
|
+
readonly audienceId: AudienceId | null;
|
|
166
|
+
/**
|
|
167
|
+
* Every audience the window named, carried through from
|
|
168
|
+
* {@link PageReading.audiences} unchanged.
|
|
169
|
+
*
|
|
170
|
+
* Carried for the reason above, one step further on. A window holding two
|
|
171
|
+
* forms with none asked for is read as neither, so every part is `unknown`,
|
|
172
|
+
* {@link PageFrontier.views} is nought and this reading is empty — which is
|
|
173
|
+
* the **same shape** an unopened page produces and a different sentence
|
|
174
|
+
* entirely. The pair of fields is what `audienceScopeRead` needs to tell them
|
|
175
|
+
* apart, and nothing else can (0290, 0300).
|
|
176
|
+
*/
|
|
177
|
+
readonly audiences: readonly AudienceId[];
|
|
178
|
+
/**
|
|
179
|
+
* The floor on page views the reading was drawn from, carried through from
|
|
180
|
+
* {@link PageReading.views}.
|
|
181
|
+
*
|
|
182
|
+
* Zero is what makes this reading empty, and the two are not the same
|
|
183
|
+
* sentence: *nobody opened this page* is not *every reader stopped at the
|
|
184
|
+
* top*.
|
|
185
|
+
*/
|
|
186
|
+
readonly views: number;
|
|
187
|
+
/** Every place the reading stopped, in reading order. */
|
|
188
|
+
readonly frontier: readonly UnreachedPart[];
|
|
189
|
+
/**
|
|
190
|
+
* Parts no view reported reaching — the sum of every stop's `unseen`, and so
|
|
191
|
+
* equal to `skipped` in {@link PageReading.standings}.
|
|
192
|
+
*/
|
|
193
|
+
readonly unseen: number;
|
|
194
|
+
/** Parts at least one view reported reaching. */
|
|
195
|
+
readonly read: number;
|
|
196
|
+
/** Parts nothing can be said about. */
|
|
197
|
+
readonly unknown: number;
|
|
198
|
+
/** Every addressed node of the revision, which is the universe the rest is out of. */
|
|
199
|
+
readonly parts: number;
|
|
200
|
+
/**
|
|
201
|
+
* Parts that were reached, hold at least one part, and whose every part went
|
|
202
|
+
* unreached.
|
|
203
|
+
*
|
|
204
|
+
* A reader had it on screen and went past the whole of what it holds, which is
|
|
205
|
+
* the one statement of *scrolled past* that is about a reader's behaviour
|
|
206
|
+
* rather than about a part's absence from a table. A part with an `unknown`
|
|
207
|
+
* anywhere inside it is absent from this list: what happened there cannot be
|
|
208
|
+
* spoken for, so *every part of it* cannot be claimed.
|
|
209
|
+
*/
|
|
210
|
+
readonly passedOver: readonly NodeId[];
|
|
211
|
+
/**
|
|
212
|
+
* Parts that reported nothing while a part inside them reported reach.
|
|
213
|
+
*
|
|
214
|
+
* A defect rather than a reading: a reader was demonstrably below it, so it was
|
|
215
|
+
* on screen and did not say so. The usual cause is a primitive that does not
|
|
216
|
+
* spread the identity attributes a broadcaster reads, which
|
|
217
|
+
* `sdk/conformance.ts` checks; a sender switched on mid-release is the other.
|
|
218
|
+
*/
|
|
219
|
+
readonly notReporting: readonly NodeId[];
|
|
220
|
+
/**
|
|
221
|
+
* Rows of the reading that named a node this revision does not contain,
|
|
222
|
+
* carried through from {@link PageReading.orphaned}.
|
|
223
|
+
*
|
|
224
|
+
* Above zero means the tree and the window do not belong together, and this
|
|
225
|
+
* reading is the one that looks most plausible when they do not: a wrong pair
|
|
226
|
+
* reads as a page a reader stopped at the top of. A surface should refuse to
|
|
227
|
+
* draw rather than render it, which is what `parts.ts` already says about the
|
|
228
|
+
* list itself.
|
|
229
|
+
*/
|
|
230
|
+
readonly orphaned: number;
|
|
231
|
+
};
|
|
232
|
+
/**
|
|
233
|
+
* Read a page's reading as the places it stopped.
|
|
234
|
+
*
|
|
235
|
+
* One pass to find each part's containing part and the end of its subtree, one
|
|
236
|
+
* to assign each unreached part to the frontier part that accounts for it, and
|
|
237
|
+
* prefix counts for the rest — so the whole reading is linear in the parts of the page.
|
|
238
|
+
* The ledger's bound (rule 4 of [`docs/signals.md`](../../docs/signals.md)) is
|
|
239
|
+
* the standard every reading here is held to, and walking a part's ancestors per
|
|
240
|
+
* part is the shape it forbids.
|
|
241
|
+
*/
|
|
242
|
+
export declare const pageFrontierOf: (reading: PageReading) => PageFrontier;
|
|
243
|
+
/**
|
|
244
|
+
* The frontier parts that cost the page the most, largest first.
|
|
245
|
+
*
|
|
246
|
+
* By {@link UnreachedPart.unseen} — the parts one of them accounts for — which
|
|
247
|
+
* is the figure a fix-list is ordered by: *the pricing band costs you nineteen
|
|
248
|
+
* parts of this page, the footnote costs you one*. Ordering by `beneath`
|
|
249
|
+
* instead would rank a part by how much is inside it whether or not this reading
|
|
250
|
+
* lost any of it, and ordering by depth would put the top of the page first on
|
|
251
|
+
* every page there is.
|
|
252
|
+
*
|
|
253
|
+
* Ties keep reading order, so two of one size are drawn in the order the page is
|
|
254
|
+
* written rather than in the order a sort happened to leave them.
|
|
255
|
+
*/
|
|
256
|
+
export declare const largestUnreachedIn: (frontier: PageFrontier, limit?: number) => readonly UnreachedPart[];
|
|
257
|
+
/**
|
|
258
|
+
* The words nobody reached, in reading order.
|
|
259
|
+
*
|
|
260
|
+
* The complement of `wordsReadIn` and exact for the same reason: a part's words
|
|
261
|
+
* are its own, every unreached part belongs to exactly one frontier part, and so
|
|
262
|
+
* this concatenates rather than deduplicates. What it cannot include is a word whose
|
|
263
|
+
* part declared no `copy` — those are in each part's `copy.unread`, named,
|
|
264
|
+
* because a reading that guessed at them and one that dropped them silently are
|
|
265
|
+
* the two failures 0122 exists to prevent.
|
|
266
|
+
*/
|
|
267
|
+
export declare const unreachedWordsIn: (frontier: PageFrontier) => readonly string[];
|
|
268
|
+
//# sourceMappingURL=frontier.d.ts.map
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { between, extentsOf, prefixOf } from "./subtrees.js";
|
|
2
|
+
/**
|
|
3
|
+
* Read a page's reading as the places it stopped.
|
|
4
|
+
*
|
|
5
|
+
* One pass to find each part's containing part and the end of its subtree, one
|
|
6
|
+
* to assign each unreached part to the frontier part that accounts for it, and
|
|
7
|
+
* prefix counts for the rest — so the whole reading is linear in the parts of the page.
|
|
8
|
+
* The ledger's bound (rule 4 of [`docs/signals.md`](../../docs/signals.md)) is
|
|
9
|
+
* the standard every reading here is held to, and walking a part's ancestors per
|
|
10
|
+
* part is the shape it forbids.
|
|
11
|
+
*/
|
|
12
|
+
export const pageFrontierOf = (reading) => {
|
|
13
|
+
const parts = reading.parts;
|
|
14
|
+
const total = parts.length;
|
|
15
|
+
/**
|
|
16
|
+
* The index of the part each part sits inside, and the exclusive end of each
|
|
17
|
+
* part's subtree, both from one pre-order pass over a stack of open parts.
|
|
18
|
+
*
|
|
19
|
+
* Spelled in [`subtrees.ts`](subtrees.ts) rather than here, because the
|
|
20
|
+
* library's reading of the same defect needs the same two projections and a
|
|
21
|
+
* second spelling of them is the failure this subsystem already has a name
|
|
22
|
+
* for (0393).
|
|
23
|
+
*/
|
|
24
|
+
const { containers, ends } = extentsOf(parts);
|
|
25
|
+
/**
|
|
26
|
+
* The frontier part that accounts for each unreached part: itself where its
|
|
27
|
+
* container was reached or cannot be spoken for, and otherwise whatever
|
|
28
|
+
* accounts for its container — which pre-order guarantees has already been
|
|
29
|
+
* decided, because a container always precedes what it contains.
|
|
30
|
+
*/
|
|
31
|
+
const accountedBy = [];
|
|
32
|
+
for (const [at, part] of parts.entries()) {
|
|
33
|
+
if (part.standing !== "skipped") {
|
|
34
|
+
accountedBy.push(null);
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
const container = containers[at] ?? null;
|
|
38
|
+
const above = container === null ? undefined : parts[container];
|
|
39
|
+
const nested = above !== undefined && above.standing === "skipped";
|
|
40
|
+
/**
|
|
41
|
+
* The fallback is a guard rather than a branch nothing takes, and the two
|
|
42
|
+
* halves of this line say the same thing twice on purpose. A container that
|
|
43
|
+
* cannot be spoken for has no accounting part of its own, so if `nested`
|
|
44
|
+
* were ever widened to *not read* the `??` would still land this part on
|
|
45
|
+
* itself — which is the right answer, and a mutation that widens it cannot
|
|
46
|
+
* be made to fail. Either guard alone is correct; neither alone says why.
|
|
47
|
+
*/
|
|
48
|
+
accountedBy.push(nested && container !== null ? (accountedBy[container] ?? at) : at);
|
|
49
|
+
}
|
|
50
|
+
const reads = prefixOf(parts, "read");
|
|
51
|
+
const skips = prefixOf(parts, "skipped");
|
|
52
|
+
/**
|
|
53
|
+
* What each frontier part accounts for, gathered in reading order in one pass.
|
|
54
|
+
*
|
|
55
|
+
* The words are pushed into one array per frontier part rather than
|
|
56
|
+
* reassembled per part. A page whose whole body is one frontier part would
|
|
57
|
+
* otherwise copy a growing array once per part beneath it, which is the
|
|
58
|
+
* quadratic shape rule 4 exists to keep out of these readings.
|
|
59
|
+
*/
|
|
60
|
+
const accounted = new Map();
|
|
61
|
+
const unreadWords = new Map();
|
|
62
|
+
for (const [at, part] of parts.entries()) {
|
|
63
|
+
const owner = accountedBy[at] ?? null;
|
|
64
|
+
if (owner === null)
|
|
65
|
+
continue;
|
|
66
|
+
accounted.set(owner, (accounted.get(owner) ?? 0) + 1);
|
|
67
|
+
const into = unreadWords.get(owner) ?? [];
|
|
68
|
+
for (const word of part.copy.words)
|
|
69
|
+
into.push(word);
|
|
70
|
+
unreadWords.set(owner, into);
|
|
71
|
+
}
|
|
72
|
+
const frontier = [];
|
|
73
|
+
const passedOver = [];
|
|
74
|
+
const notReporting = [];
|
|
75
|
+
for (const [at, part] of parts.entries()) {
|
|
76
|
+
const end = ends[at] ?? total;
|
|
77
|
+
const beneath = end - at - 1;
|
|
78
|
+
const readBelow = between(reads, at + 1, end);
|
|
79
|
+
if (part.standing === "skipped" && readBelow > 0)
|
|
80
|
+
notReporting.push(part.nodeId);
|
|
81
|
+
if (part.standing === "read" && beneath > 0 && between(skips, at + 1, end) === beneath) {
|
|
82
|
+
passedOver.push(part.nodeId);
|
|
83
|
+
}
|
|
84
|
+
if ((accountedBy[at] ?? null) !== at)
|
|
85
|
+
continue;
|
|
86
|
+
const container = containers[at] ?? null;
|
|
87
|
+
const above = container === null ? undefined : parts[container];
|
|
88
|
+
frontier.push({
|
|
89
|
+
nodeId: part.nodeId,
|
|
90
|
+
type: part.type,
|
|
91
|
+
role: part.role,
|
|
92
|
+
depth: part.depth,
|
|
93
|
+
withinId: part.withinId,
|
|
94
|
+
within: above?.standing ?? null,
|
|
95
|
+
beneath,
|
|
96
|
+
unseen: accounted.get(at) ?? 1,
|
|
97
|
+
reportedBelow: readBelow,
|
|
98
|
+
words: unreadWords.get(at) ?? [],
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
treeId: reading.treeId,
|
|
103
|
+
revision: reading.revision,
|
|
104
|
+
audienceId: reading.audienceId,
|
|
105
|
+
audiences: reading.audiences,
|
|
106
|
+
views: reading.views,
|
|
107
|
+
frontier,
|
|
108
|
+
unseen: reading.standings.skipped,
|
|
109
|
+
read: reading.standings.read,
|
|
110
|
+
unknown: reading.standings.unknown,
|
|
111
|
+
parts: total,
|
|
112
|
+
passedOver,
|
|
113
|
+
notReporting,
|
|
114
|
+
orphaned: reading.orphaned.length,
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* The frontier parts that cost the page the most, largest first.
|
|
119
|
+
*
|
|
120
|
+
* By {@link UnreachedPart.unseen} — the parts one of them accounts for — which
|
|
121
|
+
* is the figure a fix-list is ordered by: *the pricing band costs you nineteen
|
|
122
|
+
* parts of this page, the footnote costs you one*. Ordering by `beneath`
|
|
123
|
+
* instead would rank a part by how much is inside it whether or not this reading
|
|
124
|
+
* lost any of it, and ordering by depth would put the top of the page first on
|
|
125
|
+
* every page there is.
|
|
126
|
+
*
|
|
127
|
+
* Ties keep reading order, so two of one size are drawn in the order the page is
|
|
128
|
+
* written rather than in the order a sort happened to leave them.
|
|
129
|
+
*/
|
|
130
|
+
export const largestUnreachedIn = (frontier, limit) => {
|
|
131
|
+
const ordered = [...frontier.frontier].sort((left, right) => right.unseen - left.unseen);
|
|
132
|
+
return limit === undefined ? ordered : ordered.slice(0, limit);
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* The words nobody reached, in reading order.
|
|
136
|
+
*
|
|
137
|
+
* The complement of `wordsReadIn` and exact for the same reason: a part's words
|
|
138
|
+
* are its own, every unreached part belongs to exactly one frontier part, and so
|
|
139
|
+
* this concatenates rather than deduplicates. What it cannot include is a word whose
|
|
140
|
+
* part declared no `copy` — those are in each part's `copy.unread`, named,
|
|
141
|
+
* because a reading that guessed at them and one that dropped them silently are
|
|
142
|
+
* the two failures 0122 exists to prevent.
|
|
143
|
+
*/
|
|
144
|
+
export const unreachedWordsIn = (frontier) => frontier.frontier.flatMap((part) => [...part.words]);
|
|
145
|
+
//# sourceMappingURL=frontier.js.map
|