cursedbelt-core 2.13.2 → 2.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/dist/core/analytics/range.d.ts +2 -2
  2. package/dist/core/analytics/range.js +2 -2
  3. package/dist/core/analytics/schedule.d.ts +1 -1
  4. package/dist/core/analytics/schedule.js +3 -3
  5. package/dist/core/duplicates/index.d.ts +2 -2
  6. package/dist/core/duplicates/index.js +1 -1
  7. package/dist/core/file-tree/fileTreeModel.d.ts +3 -3
  8. package/dist/core/file-tree/fileTreeModel.js +2 -2
  9. package/dist/core/folder-tree/actions.d.ts +1 -1
  10. package/dist/core/folder-tree/actions.js +1 -1
  11. package/dist/core/master-lock/kdf.js +1 -1
  12. package/dist/core/master-lock/presence.d.ts +1 -1
  13. package/dist/core/master-lock/presence.js +1 -1
  14. package/dist/core/master-lock/wire.d.ts +1 -1
  15. package/dist/core/media/mediaItem.js +1 -1
  16. package/dist/core/media/types.d.ts +4 -4
  17. package/dist/core/media/videoCuts.d.ts +1 -1
  18. package/dist/core/media/videoCuts.js +2 -2
  19. package/dist/core/navigation/index.js +1 -1
  20. package/dist/core/navigation/navigationModel.d.ts +1 -1
  21. package/dist/core/navigation/navigationModel.js +1 -1
  22. package/dist/core/navigation/navigationSelectors.d.ts +2 -2
  23. package/dist/core/navigation/navigationSelectors.js +2 -2
  24. package/dist/core/navigation/searchCatalogue.d.ts +2 -2
  25. package/dist/core/navigation/searchCatalogue.js +4 -4
  26. package/dist/core/palette/fuzzyRank.d.ts +1 -1
  27. package/dist/core/palette/fuzzyRank.js +3 -3
  28. package/dist/core/tokens/registry.d.ts +1 -1
  29. package/dist/core/tokens/registry.js +1 -1
  30. package/dist/core/upload-precheck/contract.d.ts +71 -0
  31. package/dist/core/upload-precheck/contract.js +76 -0
  32. package/dist/core/upload-precheck/hash.d.ts +26 -0
  33. package/dist/core/upload-precheck/hash.js +46 -0
  34. package/dist/core/upload-precheck/index.d.ts +21 -0
  35. package/dist/core/upload-precheck/index.js +21 -0
  36. package/dist/core/upload-precheck/memo.d.ts +52 -0
  37. package/dist/core/upload-precheck/memo.js +160 -0
  38. package/dist/core/upload-precheck/plan.d.ts +112 -0
  39. package/dist/core/upload-precheck/plan.js +242 -0
  40. package/dist/core/upload-precheck/sha256.d.ts +27 -0
  41. package/dist/core/upload-precheck/sha256.js +124 -0
  42. package/dist/core/wire/__fixtures__/rowsMarshalWorker.js +2 -2
  43. package/dist/core/wire/index.d.ts +1 -1
  44. package/dist/core/wire/index.js +1 -1
  45. package/dist/core/wire/ingress.d.ts +4 -4
  46. package/dist/core/wire/ingress.js +12 -12
  47. package/dist/core/wire/marshalWorker.d.ts +1 -1
  48. package/dist/core/wire/marshalWorker.js +15 -15
  49. package/dist/core/wire/marshalling.d.ts +16 -16
  50. package/dist/core/wire/marshalling.js +13 -13
  51. package/dist/ctgrClient/convertRequest.js +2 -2
  52. package/dist/testing/bytes.d.ts +1 -1
  53. package/dist/testing/bytes.js +1 -1
  54. package/package.json +7 -1
  55. package/src/core/analytics/range.spec.ts +1 -1
  56. package/src/core/analytics/range.ts +2 -2
  57. package/src/core/analytics/schedule.spec.ts +3 -3
  58. package/src/core/analytics/schedule.ts +3 -3
  59. package/src/core/duplicates/index.ts +2 -2
  60. package/src/core/file-tree/fileTreeModel.ts +4 -4
  61. package/src/core/folder-tree/actions.ts +1 -1
  62. package/src/core/master-lock/kdf.ts +1 -1
  63. package/src/core/master-lock/presence.ts +1 -1
  64. package/src/core/master-lock/wire.ts +1 -1
  65. package/src/core/media/mediaItem.ts +1 -1
  66. package/src/core/media/types.ts +4 -4
  67. package/src/core/media/videoCuts.ts +2 -2
  68. package/src/core/navigation/index.ts +1 -1
  69. package/src/core/navigation/navigation.spec.ts +3 -3
  70. package/src/core/navigation/navigationModel.ts +2 -2
  71. package/src/core/navigation/navigationSelectors.ts +3 -3
  72. package/src/core/navigation/searchCatalogue.ts +4 -4
  73. package/src/core/palette/fuzzyRank.ts +3 -3
  74. package/src/core/tokens/registry.ts +2 -2
  75. package/src/core/upload-precheck/contract.spec.ts +67 -0
  76. package/src/core/upload-precheck/contract.ts +107 -0
  77. package/src/core/upload-precheck/hash.ts +57 -0
  78. package/src/core/upload-precheck/index.ts +46 -0
  79. package/src/core/upload-precheck/memo.ts +170 -0
  80. package/src/core/upload-precheck/plan.spec.ts +299 -0
  81. package/src/core/upload-precheck/plan.ts +315 -0
  82. package/src/core/upload-precheck/sha256.spec.ts +47 -0
  83. package/src/core/upload-precheck/sha256.ts +127 -0
  84. package/src/core/wire/__fixtures__/rowsMarshalWorker.ts +2 -2
  85. package/src/core/wire/index.ts +1 -1
  86. package/src/core/wire/ingress.spec.ts +12 -12
  87. package/src/core/wire/ingress.ts +15 -15
  88. package/src/core/wire/marshalWorker.spec.ts +7 -7
  89. package/src/core/wire/marshalWorker.ts +15 -15
  90. package/src/core/wire/marshalling.spec.ts +3 -3
  91. package/src/core/wire/marshalling.ts +25 -25
  92. package/src/ctgrClient/convertRequest.ts +2 -2
  93. package/src/namedSubpathsResolve.spec.ts +1 -1
  94. package/src/publishShape.spec.ts +1 -1
  95. package/src/shippedFilesAreTracked.spec.ts +2 -2
  96. package/src/testing/bytes.ts +1 -1
@@ -94,8 +94,8 @@ export declare const startOfBucket: (t: number, unit: BucketUnit) => number;
94
94
  * duplicated or missing bar exactly once every spring and autumn — the kind of
95
95
  * bug nobody reproduces.
96
96
  *
97
- * The time-of-day is carried through rather than normalised to midnight: every
98
- * caller here passes an already-aligned value, so normalising would be
97
+ * The time-of-day is carried through rather than normalized to midnight: every
98
+ * caller here passes an already-aligned value, so normalizing would be
99
99
  * invisible in this file and a trap for the first caller that does not.
100
100
  */
101
101
  export declare const addDays: (t: number, n: number) => number;
@@ -102,8 +102,8 @@ export const startOfBucket = (t, unit) => unit === 'hour' ? startOfHour(t) : sta
102
102
  * duplicated or missing bar exactly once every spring and autumn — the kind of
103
103
  * bug nobody reproduces.
104
104
  *
105
- * The time-of-day is carried through rather than normalised to midnight: every
106
- * caller here passes an already-aligned value, so normalising would be
105
+ * The time-of-day is carried through rather than normalized to midnight: every
106
+ * caller here passes an already-aligned value, so normalizing would be
107
107
  * invisible in this file and a trap for the first caller that does not.
108
108
  */
109
109
  export const addDays = (t, n) => {
@@ -11,7 +11,7 @@
11
11
  * Three separate claims hide in that, and a `remaining / rate` division answers
12
12
  * none of them:
13
13
  *
14
- * 1. **Work does not parallelise freely.** Two tasks that write the same files
14
+ * 1. **Work does not parallelize freely.** Two tasks that write the same files
15
15
  * may not run together whatever the fleet size — that is the orchestrator's
16
16
  * own scope rule, and it is why a queue of ten tasks all scoped to one app
17
17
  * drains at exactly the same speed with eight workers as with one.
@@ -11,7 +11,7 @@
11
11
  * Three separate claims hide in that, and a `remaining / rate` division answers
12
12
  * none of them:
13
13
  *
14
- * 1. **Work does not parallelise freely.** Two tasks that write the same files
14
+ * 1. **Work does not parallelize freely.** Two tasks that write the same files
15
15
  * may not run together whatever the fleet size — that is the orchestrator's
16
16
  * own scope rule, and it is why a queue of ten tasks all scoped to one app
17
17
  * drains at exactly the same speed with eight workers as with one.
@@ -179,10 +179,10 @@ function blocks(candidate, other) {
179
179
  /**
180
180
  * A best-effort reason an item started late — for the table behind the chart.
181
181
  *
182
- * Deliberately approximate and labelled as such: the precise answer would need
182
+ * Deliberately approximate and labeled as such: the precise answer would need
183
183
  * the admission loop to record every refusal at every event, which is a lot of
184
184
  * bookkeeping for a column. "Was it waiting on a dependency, on a conflicting
185
- * neighbour, or simply for a free worker" is the distinction a reader acts on,
185
+ * neighbor, or simply for a free worker" is the distinction a reader acts on,
186
186
  * and that is decidable from the item alone.
187
187
  */
188
188
  function whyWaited(item, _timeline, known) {
@@ -17,7 +17,7 @@
17
17
  *
18
18
  * ── What is NOT here, deliberately ──────────────────────────────────────────────────────
19
19
  * Anything that needs a database, a filesystem, a fetch or a picture decoder. This module is
20
- * pure so both consumers can prove their behaviour with `bun test` instead of against a live
20
+ * pure so both consumers can prove their behavior with `bun test` instead of against a live
21
21
  * store, and so a browser bundle may import it (music renders the pair side by side).
22
22
  */
23
23
  /**
@@ -93,7 +93,7 @@ export declare function durationsClose(a: number | null | undefined, b: number |
93
93
  /** One file, reduced to what this module can reason about. Units are the caller's — pass
94
94
  * both durations in the same unit or not at all. */
95
95
  export interface NamedFileFacts {
96
- /** The name a person would recognise: a display title, else the last path segment. */
96
+ /** The name a person would recognize: a display title, else the last path segment. */
97
97
  name: string | null | undefined;
98
98
  sizeBytes: number;
99
99
  /** Playing time, in whatever unit the caller uses consistently. Null = never measured. */
@@ -17,7 +17,7 @@
17
17
  *
18
18
  * ── What is NOT here, deliberately ──────────────────────────────────────────────────────
19
19
  * Anything that needs a database, a filesystem, a fetch or a picture decoder. This module is
20
- * pure so both consumers can prove their behaviour with `bun test` instead of against a live
20
+ * pure so both consumers can prove their behavior with `bun test` instead of against a live
21
21
  * store, and so a browser bundle may import it (music renders the pair side by side).
22
22
  */
23
23
  /**
@@ -22,7 +22,7 @@
22
22
  /** What a row IS. `folder` may hold children and accept drops; `file` is a leaf. */
23
23
  export type FileTreeNodeKind = 'folder' | 'file';
24
24
  /**
25
- * How visible a node is, generalised from collections' private/locked folders.
25
+ * How visible a node is, generalized from collections' private/locked folders.
26
26
  *
27
27
  * 🔴 It is a LABEL, never an enforcement. The server decides what a session may see, and a
28
28
  * tree that hides a row the server sent (or shows one it did not) is a second, weaker
@@ -114,7 +114,7 @@ export interface FileTreeNode {
114
114
  *
115
115
  * For a consumer that narrows the tree itself (by content, not only by name) and keeps
116
116
  * the folders on the way to each hit: the hits are what the eye is scanning for, and the
117
- * folders kept around them are context. Omit it and nothing is emphasised.
117
+ * folders kept around them are context. Omit it and nothing is emphasized.
118
118
  */
119
119
  matched?: boolean;
120
120
  /**
@@ -280,7 +280,7 @@ export interface KeyboardMoveOptions {
280
280
  * without asking which of several folders was meant — and **← promotes out to the folder its
281
281
  * own folder is in**, which is `root` at depth 1.
282
282
  *
283
- * 🔴 Every refusal the DRAG honours is honoured here, from the same fields: `acceptsDrop`,
283
+ * 🔴 Every refusal the DRAG honors is honored here, from the same fields: `acceptsDrop`,
284
284
  * the consumer's `canDrop`, and the descendant rule. A keyboard route that can reach a
285
285
  * destination the pointer refuses is a second, weaker opinion about what is legal — and it
286
286
  * is the one nobody looks at, because the pointer is what gets tested by hand.
@@ -68,7 +68,7 @@ export function flattenFileTree(nodes, collapsed) {
68
68
  * "A row that claims to open onto nothing is its own small lie" was the old reasoning
69
69
  * and it is answered by what VS Code does: the chevron says *folder*, not *occupied*,
70
70
  * and opening an empty one onto nothing is the honest answer, not a broken promise.
71
- * `node.expandable === false` is still honoured for a row that can never hold anything.
71
+ * `node.expandable === false` is still honored for a row that can never hold anything.
72
72
  */
73
73
  const expandable = node.kind === 'folder' && (node.expandable ?? true);
74
74
  const expanded = expandable && !shut.has(node.id);
@@ -210,7 +210,7 @@ export function resolveDrop({ nodes, row, offsetRatio, dragId, allowReorder = fa
210
210
  * without asking which of several folders was meant — and **← promotes out to the folder its
211
211
  * own folder is in**, which is `root` at depth 1.
212
212
  *
213
- * 🔴 Every refusal the DRAG honours is honoured here, from the same fields: `acceptsDrop`,
213
+ * 🔴 Every refusal the DRAG honors is honored here, from the same fields: `acceptsDrop`,
214
214
  * the consumer's `canDrop`, and the descendant rule. A keyboard route that can reach a
215
215
  * destination the pointer refuses is a second, weaker opinion about what is legal — and it
216
216
  * is the one nobody looks at, because the pointer is what gets tested by hand.
@@ -25,7 +25,7 @@
25
25
  * applies, with nothing destroyed. Deleting the CONTENTS destroys items, and this module
26
26
  * has never seen an item; it only ever sees the paths they carry. So `purge` is a mode the
27
27
  * menu offers and the CONSUMER implements against its own store, which is also the only
28
- * place that can count what is about to be lost or refuse the operation. Modelling it here
28
+ * place that can count what is about to be lost or refuse the operation. Modeling it here
29
29
  * would mean inventing an item, and an item this model cannot see is one it cannot protect.
30
30
  */
31
31
  import type { FolderNode, FolderRemap } from "./tree.js";
@@ -25,7 +25,7 @@
25
25
  * applies, with nothing destroyed. Deleting the CONTENTS destroys items, and this module
26
26
  * has never seen an item; it only ever sees the paths they carry. So `purge` is a mode the
27
27
  * menu offers and the CONSUMER implements against its own store, which is also the only
28
- * place that can count what is about to be lost or refuse the operation. Modelling it here
28
+ * place that can count what is about to be lost or refuse the operation. Modeling it here
29
29
  * would mean inventing an item, and an item this model cannot see is one it cannot protect.
30
30
  */
31
31
  import { folderPathKey, isFolderPathUnder, parseFolderPath, serializeFolderPath, } from "./path.js";
@@ -70,7 +70,7 @@ export async function deriveMasterLockVerifier(masterPassword, params) {
70
70
  }
71
71
  const salt = unb64u(params.salt);
72
72
  const kek = await pbkdf2(utf8(masterPassword), salt, params.iter);
73
- // Same salt as the KEK, by design: it individualises the verifier without a second
73
+ // Same salt as the KEK, by design: it individualizes the verifier without a second
74
74
  // stored value. One round, over KEK ‖ password.
75
75
  const verifier = await pbkdf2(concat(kek, utf8(masterPassword)), salt, 1);
76
76
  return b64u(verifier);
@@ -23,7 +23,7 @@
23
23
  * ── 🔴 Why a decorative loop is NOT presence ────────────────────────────────
24
24
  * The failure mode that would make this a security hole is an ambient background clip
25
25
  * — muted, looping, autoplaying, running forever with nobody in the building. That is
26
- * a recognisable signature (`muted` AND `loop`) and it is refused. A film the owner is
26
+ * a recognizable signature (`muted` AND `loop`) and it is refused. A film the owner is
27
27
  * actually watching is not both at once; a muted film that loops is not something this
28
28
  * fleet renders. Where a component knows better than the heuristic, it says so:
29
29
  * `data-master-lock-presence="watch"` counts unconditionally, `"ignore"` never does.
@@ -23,7 +23,7 @@
23
23
  * ── 🔴 Why a decorative loop is NOT presence ────────────────────────────────
24
24
  * The failure mode that would make this a security hole is an ambient background clip
25
25
  * — muted, looping, autoplaying, running forever with nobody in the building. That is
26
- * a recognisable signature (`muted` AND `loop`) and it is refused. A film the owner is
26
+ * a recognizable signature (`muted` AND `loop`) and it is refused. A film the owner is
27
27
  * actually watching is not both at once; a muted film that loops is not something this
28
28
  * fleet renders. Where a component knows better than the heuristic, it says so:
29
29
  * `data-master-lock-presence="watch"` counts unconditionally, `"ignore"` never does.
@@ -112,7 +112,7 @@ export declare const MASTER_LOCK_STATE_HEADER = "x-master-lock-state";
112
112
  * nothing in the fleet constructs one. So adding a required field to it is
113
113
  * additive, and without this annotation it is the residual false MAJOR that
114
114
  * Phase −1's M-B measured and had no cheap fix for (F4). `release/surface.ts`
115
- * records the annotation; `release/classify.ts` honours it. */
115
+ * records the annotation; `release/classify.ts` honors it. */
116
116
  export interface MasterLockStatus {
117
117
  /** Is a master password set at all? False only on an app that was never seeded,
118
118
  * or — in per-person mode — for a person who has not chosen one yet. */
@@ -1,5 +1,5 @@
1
1
  // Pure MediaItem helpers — kind predicates + dimension/aspect resolution. The React
2
- // catalogue maps items to layout photos through these, so the "what size is this
2
+ // catalog maps items to layout photos through these, so the "what size is this
3
3
  // thumbnail" logic is tested here, not buried in a component.
4
4
  export const isImageItem = (item) => item.type === 'image';
5
5
  export const isVideoItem = (item) => item.type === 'video';
@@ -71,10 +71,10 @@ export type VideoProgressEvent = {
71
71
  progressPercent?: number;
72
72
  error?: string;
73
73
  };
74
- /** The three media kinds the catalogue + lightbox understand. */
74
+ /** The three media kinds the catalog + lightbox understand. */
75
75
  export type MediaKind = 'image' | 'video' | 'audio';
76
76
  /**
77
- * A URL-only catalogue item — the unit the `<MediaCatalogueViewer>` renders. It
77
+ * A URL-only catalog item — the unit the `<MediaCatalogueViewer>` renders. It
78
78
  * holds NO storage identity (no FsNode, no binary id): the app maps its own records
79
79
  * to this and pre-resolves `url`/`thumbnailUrl` (signing private files as needed).
80
80
  */
@@ -95,7 +95,7 @@ export type MediaItem = {
95
95
  durationSeconds?: number;
96
96
  };
97
97
  /**
98
- * A gallery photo — a {@link MediaItem} specialized to images, plus the catalogue affordances a
98
+ * A gallery photo — a {@link MediaItem} specialized to images, plus the catalog affordances a
99
99
  * photo grid renders (tags for the filter strip, createdAt for ordering, favorite for the ♥).
100
100
  * Like every media-core unit it carries only resolved URLs — no storage identity.
101
101
  */
@@ -124,7 +124,7 @@ export type ProcessingStatus = 'pending' | 'processing' | 'ready' | 'failed';
124
124
  /**
125
125
  * A surface-agnostic description of a playable video with every URL already resolved —
126
126
  * the unit the `<VideoPlayer>` primitive consumes (distinct from {@link MediaItem}, which
127
- * is the lightbox catalogue unit). It carries NO storage identity: a source pre-resolves
127
+ * is the lightbox catalog unit). It carries NO storage identity: a source pre-resolves
128
128
  * the streaming URLs (signing/tokenising private ones), so the player couples to nothing.
129
129
  * Richer than `MediaItem`: an HLS master + scrub-preview track for a real player HUD.
130
130
  */
@@ -43,7 +43,7 @@ export interface VideoCut {
43
43
  * The shortest span worth cutting, in seconds.
44
44
  *
45
45
  * 🔴 Not zero, and not "whatever the person dragged". Below roughly a frame the request is
46
- * indistinguishable from a mis-click, and it is a request ffmpeg cannot honour anyway — a
46
+ * indistinguishable from a mis-click, and it is a request ffmpeg cannot honor anyway — a
47
47
  * cut has to land on a frame boundary, so a 4 ms span asks the encoder to remove nothing and
48
48
  * charges a full re-encode of the file for it. 40 ms is one frame at 25fps, the slowest rate
49
49
  * anything in this library was shot at.
@@ -38,7 +38,7 @@
38
38
  * The shortest span worth cutting, in seconds.
39
39
  *
40
40
  * 🔴 Not zero, and not "whatever the person dragged". Below roughly a frame the request is
41
- * indistinguishable from a mis-click, and it is a request ffmpeg cannot honour anyway — a
41
+ * indistinguishable from a mis-click, and it is a request ffmpeg cannot honor anyway — a
42
42
  * cut has to land on a frame boundary, so a 4 ms span asks the encoder to remove nothing and
43
43
  * charges a full re-encode of the file for it. 40 ms is one frame at 25fps, the slowest rate
44
44
  * anything in this library was shot at.
@@ -252,7 +252,7 @@ export function toggleSegment(plan, segment, duration) {
252
252
  splits: plan.splits,
253
253
  // Drop every removal this segment sits inside, then put back the parts of a WIDER
254
254
  // removal that are still meant to go — un-marking one piece of a span that was marked
255
- // before it was split must not resurrect its neighbours.
255
+ // before it was split must not resurrect its neighbors.
256
256
  removed: plan.removed.flatMap((cut) => {
257
257
  if (!(cut.start <= current.start + 1e-6 && cut.end >= current.end - 1e-6))
258
258
  return [cut];
@@ -1,6 +1,6 @@
1
1
  // `cursedbelt-core/navigation` — the navigation contract + pure selectors. React-free and
2
2
  // routing-free: the single source of truth (the IA tree) plus every derivation off
3
- // it (side nav, hub tiles, breadcrumbs, search catalogue, coverage test, prefs
3
+ // it (side nav, hub tiles, breadcrumbs, search catalog, coverage test, prefs
4
4
  // migration). The React components in `cursedbelt/react` consume exactly this.
5
5
  export { buildBreadcrumbTrail, } from './breadcrumbCompat.js';
6
6
  export { createCoverageTest, findCoverageGaps, } from './coverageTest.js';
@@ -118,7 +118,7 @@ export interface NavDomain {
118
118
  * again the same as on a {@link NavItem}.
119
119
  *
120
120
  * Both of these exist because a domain IS a destination: `deriveSearchCatalogue`
121
- * emits one catalogue entry per domain, so a rail of leaf-shaped domains (an app
121
+ * emits one catalog entry per domain, so a rail of leaf-shaped domains (an app
122
122
  * whose places have no sub-items) had no way to be found by synonym while an
123
123
  * otherwise identical rail of items did. That asymmetry was in the data model,
124
124
  * not in the ranker.
@@ -1,6 +1,6 @@
1
1
  // The single navigation source of truth — a declarative Information-Architecture
2
2
  // tree (Domain → Group → Item) every nav surface derives from: the side nav, hub
3
- // landing tiles, breadcrumbs, the universal-search catalogue, and the command
3
+ // landing tiles, breadcrumbs, the universal-search catalog, and the command
4
4
  // palette. Authoring a feature into the model is the *only* way to surface it, so
5
5
  // the historical "four hand-maintained lists drift out of sync → features get
6
6
  // buried" bug is structurally impossible (the coverage test enforces it in CI).
@@ -12,7 +12,7 @@ import { type GateFn, type NavDomain, type NavGroup, type NavItem, type Navigati
12
12
  * stands before it and it starts with `/` — `/tools#tab=curl` is still `/tools`.
13
13
  */
14
14
  export declare function normalizeNavPath(path: string): string;
15
- /** A flattened, gated catalogue entry — a leaf plus where it lives (for grouping). */
15
+ /** A flattened, gated catalog entry — a leaf plus where it lives (for grouping). */
16
16
  export interface SearchCatalogueEntry extends NavItem {
17
17
  /** Owning domain id (absent for ungrouped items). */
18
18
  domainId?: string;
@@ -57,7 +57,7 @@ export declare function deriveBreadcrumbTrail(model: NavigationModel, path: stri
57
57
  * The flat list of searchable destinations — every visible (gated,
58
58
  * non-`deepLinkOnly`) domain landing + item, `searchOnly` ones included, each tagged with its domain/group so
59
59
  * results can be grouped. Drives HeaderSearch's instant pages layer *and* the
60
- * command palette; replaces every hand-listed search catalogue (so a feature is
60
+ * command palette; replaces every hand-listed search catalog (so a feature is
61
61
  * findable the moment it's registered).
62
62
  */
63
63
  export declare function deriveSearchCatalogue(model: NavigationModel, gate?: GateFn): SearchCatalogueEntry[];
@@ -1,5 +1,5 @@
1
1
  // Pure derivations off the {@link NavigationModel}. Every nav surface (side nav,
2
- // hub tiles, breadcrumbs, search catalogue, palette, the coverage test) reads the
2
+ // hub tiles, breadcrumbs, search catalog, palette, the coverage test) reads the
3
3
  // model exclusively through these — there is no second list to keep in sync. They
4
4
  // import nothing from React, so they run identically in the client, in a server
5
5
  // test, and in the CI coverage check.
@@ -118,7 +118,7 @@ export function deriveBreadcrumbTrail(model, path, gate = allowAllGate) {
118
118
  * The flat list of searchable destinations — every visible (gated,
119
119
  * non-`deepLinkOnly`) domain landing + item, `searchOnly` ones included, each tagged with its domain/group so
120
120
  * results can be grouped. Drives HeaderSearch's instant pages layer *and* the
121
- * command palette; replaces every hand-listed search catalogue (so a feature is
121
+ * command palette; replaces every hand-listed search catalog (so a feature is
122
122
  * findable the moment it's registered).
123
123
  */
124
124
  export function deriveSearchCatalogue(model, gate = allowAllGate) {
@@ -12,8 +12,8 @@ export interface CatalogueResultGroup {
12
12
  items: CatalogueHit[];
13
13
  }
14
14
  /**
15
- * Filter + rank a catalogue by `query`. Empty/blank query → `[]` (the instant layer
16
- * shows nothing until the user types). Stable: equal scores keep catalogue order.
15
+ * Filter + rank a catalog by `query`. Empty/blank query → `[]` (the instant layer
16
+ * shows nothing until the user types). Stable: equal scores keep catalog order.
17
17
  */
18
18
  export declare function rankCatalogue(catalogue: SearchCatalogueEntry[], query: string): CatalogueHit[];
19
19
  /**
@@ -1,5 +1,5 @@
1
1
  // Pure matcher + grouper for the instant client-side "pages" search layer. Ranks a
2
- // derived catalogue ({@link deriveSearchCatalogue}) against a query and buckets the
2
+ // derived catalog ({@link deriveSearchCatalogue}) against a query and buckets the
3
3
  // hits by their owning domain. Kept pure + framework-free so it's unit-testable and
4
4
  // shared by HeaderSearch and (task 14) the command palette. The palette upgrades the
5
5
  // *ranking* to uFuzzy; this is the dependency-free baseline both can fall back to.
@@ -39,8 +39,8 @@ function scoreEntry(entry, q) {
39
39
  return 0;
40
40
  }
41
41
  /**
42
- * Filter + rank a catalogue by `query`. Empty/blank query → `[]` (the instant layer
43
- * shows nothing until the user types). Stable: equal scores keep catalogue order.
42
+ * Filter + rank a catalog by `query`. Empty/blank query → `[]` (the instant layer
43
+ * shows nothing until the user types). Stable: equal scores keep catalog order.
44
44
  */
45
45
  export function rankCatalogue(catalogue, query) {
46
46
  const q = norm(query);
@@ -53,7 +53,7 @@ export function rankCatalogue(catalogue, query) {
53
53
  scored.push({ ...entry, score });
54
54
  }
55
55
  // Stable sort by score desc — Array.prototype.sort is stable in modern engines, so
56
- // equal scores retain catalogue (authoring) order.
56
+ // equal scores retain catalog (authoring) order.
57
57
  return scored.sort((a, b) => b.score - a.score);
58
58
  }
59
59
  /**
@@ -7,7 +7,7 @@ import type { NavItem } from '../navigation/index.js';
7
7
  export declare function searchInitials(label: string): string;
8
8
  /**
9
9
  * Rank `items` against `query`, best match first; non-matches dropped. Generic over the
10
- * item type (so callers can pass plain {@link NavItem}s *or* richer catalogue entries
10
+ * item type (so callers can pass plain {@link NavItem}s *or* richer catalog entries
11
11
  * that carry domain/group tags for grouping — the extra fields ride straight through).
12
12
  * An empty/blank query returns `[]` (the palette shows its cold state instead).
13
13
  *
@@ -1,4 +1,4 @@
1
- // The command-palette ranking layer — uFuzzy over the nav catalogue. This is the
1
+ // The command-palette ranking layer — uFuzzy over the nav catalog. This is the
2
2
  // *upgrade* HeaderSearch's `rankCatalogue` (a substring scorer) cannot match: uFuzzy
3
3
  // scores by contiguous-match proximity, so abbreviated/typeahead input ranks the
4
4
  // right page first. Pure + synchronous + React-free (uFuzzy is regex-based, no DOM),
@@ -42,7 +42,7 @@ function haystackFor(item) {
42
42
  }
43
43
  /**
44
44
  * The SECOND tier: what a destination holds rather than what it is called — its description,
45
- * and the group and place it sits under when the entry carries them (catalogue entries do).
45
+ * and the group and place it sits under when the entry carries them (catalog entries do).
46
46
  * Owner, 2026-10-09: *"I may not know where to go but typing something like 'api' brings up the
47
47
  * relevant page links quickly"* — a page found only by its exact name is not found by someone
48
48
  * who does not know the name.
@@ -63,7 +63,7 @@ function rankedIndexes(haystack, q) {
63
63
  }
64
64
  /**
65
65
  * Rank `items` against `query`, best match first; non-matches dropped. Generic over the
66
- * item type (so callers can pass plain {@link NavItem}s *or* richer catalogue entries
66
+ * item type (so callers can pass plain {@link NavItem}s *or* richer catalog entries
67
67
  * that carry domain/group tags for grouping — the extra fields ride straight through).
68
68
  * An empty/blank query returns `[]` (the palette shows its cold state instead).
69
69
  *
@@ -36,7 +36,7 @@ export interface TokenDef<S extends z.ZodType = z.ZodType> {
36
36
  subtypeOf?: string;
37
37
  /** Canonical payload injected by the V7.4 wire smoke probe. Must satisfy `schema`. */
38
38
  sample: z.infer<S>;
39
- /** True when this token receives third-party traffic — triggers the V3 marshaller gates. */
39
+ /** True when this token receives third-party traffic — triggers the V3 marshaler gates. */
40
40
  external?: boolean;
41
41
  deprecated?: TokenDeprecation;
42
42
  description: string;
@@ -405,7 +405,7 @@ export const BASE_TOKENS = [
405
405
  id: 'knowledge:records',
406
406
  mode: 'value',
407
407
  external: true,
408
- description: 'Imported record rows (CSV/sheet/webhook) — external traffic, marshaller-gated (02 §7.1).',
408
+ description: 'Imported record rows (CSV/sheet/webhook) — external traffic, marshaler-gated (02 §7.1).',
409
409
  schema: z.object({ rows: z.array(z.record(z.string(), z.unknown())) }),
410
410
  sample: { rows: [{ id: '1' }] },
411
411
  },
@@ -0,0 +1,71 @@
1
+ /**
2
+ * The wire contract of an upload PRE-CHECK — "which of these do you already have?", asked before
3
+ * a single byte of the files is sent (forge task 3579).
4
+ *
5
+ * The owner, 2026-10-22: *"They should find and skip dups efficiently without wasting bandwidth or
6
+ * processing power … They need to know dups based on the hashes rather than a long check such as
7
+ * copying the file first … I will sometimes reimport from huge directories just in case they have a
8
+ * new file that was missed on previous uploads and I want it to be fast."*
9
+ *
10
+ * ── Two questions, one route ───────────────────────────────────────────────────────────────
11
+ * 1. **`sizes`** — which of these byte sizes does the library hold at all? A file whose size
12
+ * matches nothing stored CANNOT be a byte-identical copy, so it is uploaded without being hashed
13
+ * first (binary-server hashes what it receives, as it always has). On a folder of mostly new
14
+ * videos that is nearly every file, and nearly all of the hashing.
15
+ * 2. **`sha256`** — which of these whole-file SHA-256s does the library hold? Asked only for the
16
+ * files whose size DID match, so the proof (the hash) is paid exactly where it can decide
17
+ * something. A hit is never sent.
18
+ *
19
+ * A route answers both in one body, so a client may ask either or both. Every app's library is
20
+ * scoped by the app's own rules (an account, an owner) — the route answers for the CALLER only,
21
+ * which is also what keeps the answer from saying anything about anyone else's files.
22
+ *
23
+ * ── SQL: one bound parameter, any length ───────────────────────────────────────────────────
24
+ * D1 refuses a statement with more than 100 bound parameters, so `IN (?, ?, …)` over a batch of
25
+ * 1,000 hashes cannot be written. Bind the list ONCE as JSON instead —
26
+ * `WHERE checksum IN (SELECT value FROM json_each(?))` with {@link jsonList} — which D1 and
27
+ * `bun:sqlite` both run against the column's index.
28
+ */
29
+ /** The most sizes one pre-check may ask about. A drop of 5,000 files asks once. */
30
+ export declare const PRECHECK_MAX_SIZES = 5000;
31
+ /** The most hashes one pre-check may ask about — a client sends them in batches this size or less. */
32
+ export declare const PRECHECK_MAX_HASHES = 1000;
33
+ /** What the client sends. Either list may be absent or empty. */
34
+ export interface PrecheckRequest {
35
+ sizes?: number[];
36
+ sha256?: string[];
37
+ }
38
+ /** Why a hash is refused: the library holds it, or once held it and its owner deleted it. */
39
+ export type PrecheckReason = "exists" | "deleted";
40
+ /** One hash the library already answers for. */
41
+ export interface PrecheckHit {
42
+ reason: PrecheckReason;
43
+ /** What the library calls it — shown to the person beside the skipped file. */
44
+ name?: string;
45
+ /** The app's own id for the item, when it has one worth linking to. */
46
+ id?: string;
47
+ }
48
+ /** What the route answers. */
49
+ export interface PrecheckResponse {
50
+ /** The asked sizes that the library holds at least one file of. */
51
+ sizes: number[];
52
+ /** The asked hashes the library already answers for; any hash absent here is new. */
53
+ have: Record<string, PrecheckHit>;
54
+ }
55
+ /** Is this a lowercase hex SHA-256 — the only spelling every store in the fleet records? */
56
+ export declare function isSha256Hex(value: unknown): value is string;
57
+ export type ParsedPrecheck = {
58
+ ok: true;
59
+ sizes: number[];
60
+ sha256: string[];
61
+ } | {
62
+ ok: false;
63
+ error: string;
64
+ };
65
+ /**
66
+ * Validate a pre-check body — the ONE parser every app's route calls, so the limits and the
67
+ * spelling are the same everywhere. Duplicates collapse; order is not kept.
68
+ */
69
+ export declare function parsePrecheckRequest(body: unknown): ParsedPrecheck;
70
+ /** A list bound as ONE SQL parameter, for `IN (SELECT value FROM json_each(?))`. */
71
+ export declare function jsonList(values: readonly (string | number)[]): string;
@@ -0,0 +1,76 @@
1
+ /**
2
+ * The wire contract of an upload PRE-CHECK — "which of these do you already have?", asked before
3
+ * a single byte of the files is sent (forge task 3579).
4
+ *
5
+ * The owner, 2026-10-22: *"They should find and skip dups efficiently without wasting bandwidth or
6
+ * processing power … They need to know dups based on the hashes rather than a long check such as
7
+ * copying the file first … I will sometimes reimport from huge directories just in case they have a
8
+ * new file that was missed on previous uploads and I want it to be fast."*
9
+ *
10
+ * ── Two questions, one route ───────────────────────────────────────────────────────────────
11
+ * 1. **`sizes`** — which of these byte sizes does the library hold at all? A file whose size
12
+ * matches nothing stored CANNOT be a byte-identical copy, so it is uploaded without being hashed
13
+ * first (binary-server hashes what it receives, as it always has). On a folder of mostly new
14
+ * videos that is nearly every file, and nearly all of the hashing.
15
+ * 2. **`sha256`** — which of these whole-file SHA-256s does the library hold? Asked only for the
16
+ * files whose size DID match, so the proof (the hash) is paid exactly where it can decide
17
+ * something. A hit is never sent.
18
+ *
19
+ * A route answers both in one body, so a client may ask either or both. Every app's library is
20
+ * scoped by the app's own rules (an account, an owner) — the route answers for the CALLER only,
21
+ * which is also what keeps the answer from saying anything about anyone else's files.
22
+ *
23
+ * ── SQL: one bound parameter, any length ───────────────────────────────────────────────────
24
+ * D1 refuses a statement with more than 100 bound parameters, so `IN (?, ?, …)` over a batch of
25
+ * 1,000 hashes cannot be written. Bind the list ONCE as JSON instead —
26
+ * `WHERE checksum IN (SELECT value FROM json_each(?))` with {@link jsonList} — which D1 and
27
+ * `bun:sqlite` both run against the column's index.
28
+ */
29
+ /** The most sizes one pre-check may ask about. A drop of 5,000 files asks once. */
30
+ export const PRECHECK_MAX_SIZES = 5000;
31
+ /** The most hashes one pre-check may ask about — a client sends them in batches this size or less. */
32
+ export const PRECHECK_MAX_HASHES = 1000;
33
+ const SHA256_HEX = /^[0-9a-f]{64}$/;
34
+ /** Is this a lowercase hex SHA-256 — the only spelling every store in the fleet records? */
35
+ export function isSha256Hex(value) {
36
+ return typeof value === "string" && SHA256_HEX.test(value);
37
+ }
38
+ /**
39
+ * Validate a pre-check body — the ONE parser every app's route calls, so the limits and the
40
+ * spelling are the same everywhere. Duplicates collapse; order is not kept.
41
+ */
42
+ export function parsePrecheckRequest(body) {
43
+ if (typeof body !== "object" || body === null || Array.isArray(body)) {
44
+ return { ok: false, error: "expected a JSON object with `sizes` and/or `sha256`" };
45
+ }
46
+ const { sizes: rawSizes, sha256: rawHashes } = body;
47
+ if (rawSizes !== undefined && !Array.isArray(rawSizes))
48
+ return { ok: false, error: "`sizes` must be an array" };
49
+ if (rawHashes !== undefined && !Array.isArray(rawHashes))
50
+ return { ok: false, error: "`sha256` must be an array" };
51
+ const sizes = new Set();
52
+ for (const size of rawSizes ?? []) {
53
+ if (!Number.isSafeInteger(size) || size < 0) {
54
+ return { ok: false, error: "every size must be a whole number of bytes" };
55
+ }
56
+ sizes.add(size);
57
+ }
58
+ const hashes = new Set();
59
+ for (const hash of rawHashes ?? []) {
60
+ const spelled = typeof hash === "string" ? hash.toLowerCase() : hash;
61
+ if (!isSha256Hex(spelled))
62
+ return { ok: false, error: "every sha256 must be 64 hex characters" };
63
+ hashes.add(spelled);
64
+ }
65
+ if (sizes.size > PRECHECK_MAX_SIZES) {
66
+ return { ok: false, error: `at most ${PRECHECK_MAX_SIZES} sizes per pre-check` };
67
+ }
68
+ if (hashes.size > PRECHECK_MAX_HASHES) {
69
+ return { ok: false, error: `at most ${PRECHECK_MAX_HASHES} hashes per pre-check` };
70
+ }
71
+ return { ok: true, sizes: [...sizes], sha256: [...hashes] };
72
+ }
73
+ /** A list bound as ONE SQL parameter, for `IN (SELECT value FROM json_each(?))`. */
74
+ export function jsonList(values) {
75
+ return JSON.stringify(values);
76
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The largest file hashed in ONE native `crypto.subtle.digest` call — read whole into memory.
3
+ *
4
+ * Native hashing ran 1,960 MiB/s on this Mac against 184 MiB/s for the incremental one, so a
5
+ * file is read whole whenever that is safe. 256 MiB is far under what a phone tab survives, and
6
+ * covers every photo, every song and most clips; past it the incremental hasher streams in
7
+ * {@link STREAM_SLICE_BYTES} slices at roughly the speed an external drive reads anyway.
8
+ */
9
+ export declare const NATIVE_HASH_MAX_BYTES: number;
10
+ /**
11
+ * One read while streaming. Small enough that the incremental hasher returns to the event loop
12
+ * every ~10 ms (a 2 MiB slice at ~190 MiB/s), so a tab hashing an 8 GB disc stays responsive.
13
+ */
14
+ export declare const STREAM_SLICE_BYTES: number;
15
+ export interface HashOptions {
16
+ /** 0..1 as the bytes are read. */
17
+ onProgress?: (fraction: number) => void;
18
+ signal?: AbortSignal;
19
+ /** Override {@link NATIVE_HASH_MAX_BYTES} — the specs force the streaming road with it. */
20
+ nativeMaxBytes?: number;
21
+ }
22
+ /**
23
+ * The whole-file SHA-256 of a Blob (a browser `File`, a `Bun.file`) of any size, as lowercase hex
24
+ * — the same digest binary-server records in `file_index.checksum` for the same bytes.
25
+ */
26
+ export declare function sha256OfBlob(blob: Blob, options?: HashOptions): Promise<string>;