@danxbot/ui 3.7.0 → 3.9.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/dist/index.js +13332 -11864
- package/dist/index.js.map +1 -1
- package/dist/pure.js +17 -0
- package/dist/pure.js.map +1 -0
- package/dist/types/components/Badge.d.ts +29 -1
- package/dist/types/components/StatusSelect.d.ts +33 -2
- package/dist/types/components/Table.d.ts +26 -1
- package/dist/types/components/Toggle.d.ts +62 -0
- package/dist/types/components/chat/Attachment.d.ts +31 -4
- package/dist/types/components/chat/ContextMeter.d.ts +0 -10
- package/dist/types/index.d.ts +8 -4
- package/dist/types/lib/format.d.ts +12 -0
- package/dist/types/lib/reads/hooks.d.ts +49 -0
- package/dist/types/lib/reads/index.d.ts +4 -0
- package/dist/types/lib/reads/refetch.d.ts +52 -0
- package/dist/types/lib/reads/slots.d.ts +52 -0
- package/dist/types/lib/reads/types.d.ts +139 -0
- package/dist/types/lib/realtime/hooks.d.ts +38 -0
- package/dist/types/lib/realtime/index.d.ts +4 -0
- package/dist/types/lib/realtime/provider.d.ts +38 -0
- package/dist/types/lib/realtime/registry.d.ts +172 -0
- package/dist/types/lib/realtime/types.d.ts +202 -0
- package/dist/types/lib/records/define-record-type.d.ts +29 -0
- package/dist/types/lib/records/hooks.d.ts +46 -0
- package/dist/types/lib/records/index.d.ts +5 -0
- package/dist/types/lib/records/store.d.ts +117 -0
- package/dist/types/lib/records/types.d.ts +188 -0
- package/dist/types/lib/records/wire.d.ts +96 -0
- package/dist/types/pure.d.ts +36 -0
- package/package.json +6 -2
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { defineRecordType, resetRecordTypes } from "./define-record-type";
|
|
2
|
+
export { useRecord, useRecords, useStaleness } from "./hooks";
|
|
3
|
+
export { write, writeAll, peekRecord, readState, readStaleness, subscribeToKey, subscribeToStaleness, retainKeys, sweepRecords, setRecordStoreTenant, getRecordStoreTenant, flushRecordNotifications, resetRecordStore, recordStoreStats, UNKNOWN_STATE, } from "./store";
|
|
4
|
+
export { normalizeTypeName, normalizeTimestamp, recordKey, isRecordRef, type RecordRef } from "./wire";
|
|
5
|
+
export type { ReadOptions, RecordPayload, RecordState, RecordTypeOptions, RecordTypeToken, StalenessEntry, WriteAllResult, WriteOptions, WriteResult, WriteSource, WriteVerdict, } from "./types";
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import type { RecordPayload, RecordState, StalenessEntry, WriteAllResult, WriteOptions, WriteResult } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Declare which tenant this store is holding records for.
|
|
4
|
+
*
|
|
5
|
+
* Changing it CLEARS the store. The keys are `Type:id` with no tenant in them,
|
|
6
|
+
* so team B's demand #7 would merge onto team A's demand #7 — in an app whose
|
|
7
|
+
* read key is deliberately team-scoped precisely to prevent that. Clearing
|
|
8
|
+
* handles what is already written; the `tenant` parameter on `write` handles
|
|
9
|
+
* what is still in the air.
|
|
10
|
+
*/
|
|
11
|
+
export declare function setRecordStoreTenant(tenant: string | number | undefined): void;
|
|
12
|
+
export declare function getRecordStoreTenant(): string | number | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* The single writer. A fetch response, a mutation's returned item and a
|
|
15
|
+
* broadcast all arrive here, so fetch-versus-broadcast reconciliation lives in
|
|
16
|
+
* ONE place rather than split across two modules that would each hold half the
|
|
17
|
+
* rule.
|
|
18
|
+
*/
|
|
19
|
+
export declare function write(payload: RecordPayload, options: WriteOptions): WriteResult;
|
|
20
|
+
/**
|
|
21
|
+
* The plural form — REQUIRED, not a convenience.
|
|
22
|
+
*
|
|
23
|
+
* A list page is fifty payloads, and fifty singular writes are fifty
|
|
24
|
+
* notification passes and fifty render passes for one page load. Every write
|
|
25
|
+
* in one call coalesces into a single notification.
|
|
26
|
+
*/
|
|
27
|
+
export declare function writeAll(payloads: readonly RecordPayload[], options: WriteOptions): WriteAllResult;
|
|
28
|
+
/**
|
|
29
|
+
* The `unknown` state, as ONE module-level frozen constant.
|
|
30
|
+
*
|
|
31
|
+
* `getServerSnapshot` returns this. A fresh literal there throws under the only
|
|
32
|
+
* condition it exists for.
|
|
33
|
+
*/
|
|
34
|
+
export declare const UNKNOWN_STATE: RecordState<never>;
|
|
35
|
+
export declare function getUnknownState(): RecordState<never>;
|
|
36
|
+
/**
|
|
37
|
+
* What a reader is told about one key, gated on the field set it declared it
|
|
38
|
+
* needs.
|
|
39
|
+
*
|
|
40
|
+
* The gate is what stops a record seeded ONLY by a broadcast from reaching a
|
|
41
|
+
* projection function that assumes absent means empty — which renders a
|
|
42
|
+
* confident "0 documents" for a record with hundreds.
|
|
43
|
+
*/
|
|
44
|
+
export declare function readState(key: string, needs: string): RecordState<unknown>;
|
|
45
|
+
/** Non-reactive read, for callers outside a component. */
|
|
46
|
+
export declare function peekRecord(type: string, id: string | number, needs: string): RecordState<unknown>;
|
|
47
|
+
/**
|
|
48
|
+
* NOTIFICATION IS COALESCED PER ANIMATION FRAME, and that is a requirement.
|
|
49
|
+
*
|
|
50
|
+
* A document transcoding page by page broadcasts once per row. Un-coalesced,
|
|
51
|
+
* every one of those is a separate notification, a separate dep scan per
|
|
52
|
+
* subscriber and a separate render pass. Coalescing collapses a burst into a
|
|
53
|
+
* handful.
|
|
54
|
+
*
|
|
55
|
+
* Exported so a caller that must observe the effect of a write synchronously —
|
|
56
|
+
* a test, or a measurement taken immediately after a write — can flush rather
|
|
57
|
+
* than wait for a frame.
|
|
58
|
+
*/
|
|
59
|
+
export declare function flushRecordNotifications(): void;
|
|
60
|
+
export declare function subscribeToKey(key: string, listener: () => void): () => void;
|
|
61
|
+
export declare function subscribeToStaleness(listener: () => void): () => void;
|
|
62
|
+
/**
|
|
63
|
+
* Affected ROOTS and their now-stale field sets.
|
|
64
|
+
*
|
|
65
|
+
* The signal names ROOTS rather than the key that went stale, because the key
|
|
66
|
+
* that goes stale is often a nested one — a run under a demand — and a list of
|
|
67
|
+
* demands can never match a run's key. Roots come from the hydration memo's
|
|
68
|
+
* deps map, so a root is by definition something a mounted read or a list slot
|
|
69
|
+
* is already holding.
|
|
70
|
+
*
|
|
71
|
+
* The library names no type it understands and no endpoint: the layer that
|
|
72
|
+
* performed the original fetch re-issues it, because it is the only layer that
|
|
73
|
+
* knows which field set it asked for.
|
|
74
|
+
*/
|
|
75
|
+
export declare function readStaleness(): readonly StalenessEntry[];
|
|
76
|
+
export declare function getEmptyStaleness(): readonly StalenessEntry[];
|
|
77
|
+
/**
|
|
78
|
+
* Pin keys as ROOTS for the duration of the returned release.
|
|
79
|
+
*
|
|
80
|
+
* A key is retained if it is REACHABLE from a root, never if it is itself
|
|
81
|
+
* pinned: a file is never independently subscribed — it is reached only by
|
|
82
|
+
* hydrating its demand — so evicting by direct subscription would evict exactly
|
|
83
|
+
* what hydration walks and leave dangling refs everywhere.
|
|
84
|
+
*
|
|
85
|
+
* Release is IDEMPOTENT and exactly paired with acquire, which is what makes
|
|
86
|
+
* StrictMode's mount / unmount / mount survivable. A subscription whose
|
|
87
|
+
* teardown is not idempotent tears down the one it just created — and it
|
|
88
|
+
* misbehaves only in development, which is the worst place for that to live,
|
|
89
|
+
* because that is where it is being debugged.
|
|
90
|
+
*/
|
|
91
|
+
export declare function retainKeys(keys: readonly string[]): () => void;
|
|
92
|
+
/**
|
|
93
|
+
* Mark from the roots, then sweep everything unreachable.
|
|
94
|
+
*
|
|
95
|
+
* AN IDENTITY MAP THAT ONLY GROWS IS A LEAK, and the failure mode is a tab that
|
|
96
|
+
* gets slower over an afternoon with nobody connecting it to this. Browsing ten
|
|
97
|
+
* documents at 435 rows each is roughly 4,000 entries nothing releases.
|
|
98
|
+
*
|
|
99
|
+
* WHEN TO CALL IT IS THE CALLER'S DECISION, and it needs to be more than a
|
|
100
|
+
* navigation boundary: a broadcast can CREATE a key no root reaches, and on a
|
|
101
|
+
* screen nobody navigates away from — a long extraction, say — those accumulate
|
|
102
|
+
* for as long as the tab is open. A navigation boundary AND a bounded schedule.
|
|
103
|
+
* This module deliberately installs no timer of its own; a design-system module
|
|
104
|
+
* that starts an interval on import is a worse defect than the leak.
|
|
105
|
+
*
|
|
106
|
+
* @returns how many keys were dropped
|
|
107
|
+
*/
|
|
108
|
+
export declare function sweepRecords(): number;
|
|
109
|
+
/** Wipes everything, including listeners, roots and the tenant. */
|
|
110
|
+
export declare function resetRecordStore(): void;
|
|
111
|
+
/** What the store holds right now, for a devtools panel or a test. */
|
|
112
|
+
export declare function recordStoreStats(): {
|
|
113
|
+
records: number;
|
|
114
|
+
memos: number;
|
|
115
|
+
roots: number;
|
|
116
|
+
listeners: number;
|
|
117
|
+
};
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A payload as it arrives off the wire — from a fetch response, from a
|
|
3
|
+
* mutation's returned item, or from a broadcast.
|
|
4
|
+
*
|
|
5
|
+
* DELIBERATELY LOOSE. The store requires exactly two things of it (`__type`
|
|
6
|
+
* and `id`) and interprets five more (`__timestamp`, `__deleted_at`,
|
|
7
|
+
* `deleted_at`, `__stale`, `__model`). Everything else is data it carries
|
|
8
|
+
* without understanding — which is the whole of this module's claim to being
|
|
9
|
+
* domain-agnostic.
|
|
10
|
+
*/
|
|
11
|
+
export interface RecordPayload {
|
|
12
|
+
readonly [field: string]: unknown;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* How a payload arrived. NOT telemetry — each value changes real behaviour:
|
|
16
|
+
*
|
|
17
|
+
* - `"fetch"` may SATISFY a field-set tag and CLEARS staleness on every field
|
|
18
|
+
* it carries. A broadcast can never do either, because a broadcast is
|
|
19
|
+
* partial by whitelist and can never complete a record.
|
|
20
|
+
* - `"broadcast"` is the only source that MARKS a field stale, using the
|
|
21
|
+
* `staleFields` its type declared. Saying so out loud prevents the obvious
|
|
22
|
+
* wrong reading, in which a fetch that omits a stale-declared field re-marks
|
|
23
|
+
* it and the refetch loop never settles.
|
|
24
|
+
*
|
|
25
|
+
* A mutation's returned item is a `"fetch"`: it is a full server answer to a
|
|
26
|
+
* request this client made, so it may satisfy a tag.
|
|
27
|
+
*/
|
|
28
|
+
export type WriteSource = "fetch" | "broadcast";
|
|
29
|
+
/** Options every write carries. */
|
|
30
|
+
export interface WriteOptions {
|
|
31
|
+
readonly source: WriteSource;
|
|
32
|
+
/**
|
|
33
|
+
* The tenant the REQUEST was issued under — stamped by the caller at request
|
|
34
|
+
* time, never read from module state inside `write`.
|
|
35
|
+
*
|
|
36
|
+
* Reading it inside `write` would read the tenant as it is NOW, which is
|
|
37
|
+
* precisely the bug this parameter exists to prevent: a team-A response that
|
|
38
|
+
* resolves after a switch to team B would write team A's records into a
|
|
39
|
+
* store now being read as team B's. A broadcast is stamped with the tenant
|
|
40
|
+
* whose channel delivered it, which the subscription already knows. So both
|
|
41
|
+
* sources carry it and neither infers it.
|
|
42
|
+
*/
|
|
43
|
+
readonly tenant?: string | number;
|
|
44
|
+
/**
|
|
45
|
+
* An OPAQUE field-set name — `"card"`, `"detail"`, whatever the caller's own
|
|
46
|
+
* api layer already calls the selector it asked for. The store never
|
|
47
|
+
* interprets it; it records which tags a key has satisfied and compares them
|
|
48
|
+
* for equality, so the library still knows nothing about any type's fields.
|
|
49
|
+
*
|
|
50
|
+
* Only a `"fetch"` may satisfy a tag. It is what makes `useRecord(…,
|
|
51
|
+
* {needs:"card"})` report `unknown` for a record seeded only by a broadcast,
|
|
52
|
+
* rather than handing a projection function a record with no `files` and no
|
|
53
|
+
* `workflow_runs` — which renders a confident "0 documents" card for a
|
|
54
|
+
* 434-page demand.
|
|
55
|
+
*/
|
|
56
|
+
readonly tag?: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* What a write did. Every value is observable so a refusal leaves a trace: the
|
|
60
|
+
* prior art in this codebase records nothing at all on rejection, which is why
|
|
61
|
+
* its out-of-order guard was inert for years without anyone noticing.
|
|
62
|
+
*
|
|
63
|
+
* - `applied` — accepted, and something a reader can observe changed.
|
|
64
|
+
* - `unchanged` — accepted, and nothing changed. NOBODY IS NOTIFIED. A
|
|
65
|
+
* redelivered duplicate must not invalidate every hydration memo that
|
|
66
|
+
* touched the key and re-render every subscriber.
|
|
67
|
+
* - `dropped-older` — strictly older than the record's own stored timestamp.
|
|
68
|
+
* - `dropped-tenant` — stamped for a tenant this store is no longer serving.
|
|
69
|
+
* - `rejected-shape` — not a record at all: no `__type`, no `id`, or a
|
|
70
|
+
* `{__stale:true}` ping, which carries neither.
|
|
71
|
+
*/
|
|
72
|
+
export type WriteVerdict = "applied" | "unchanged" | "dropped-older" | "dropped-tenant" | "rejected-shape";
|
|
73
|
+
/** The result of one `write`. */
|
|
74
|
+
export interface WriteResult {
|
|
75
|
+
readonly verdict: WriteVerdict;
|
|
76
|
+
/**
|
|
77
|
+
* Every key this write touched, INCLUDING nested ones — a demand payload
|
|
78
|
+
* carrying 434 files returns 435 keys.
|
|
79
|
+
*
|
|
80
|
+
* The caller that issued a refetch to clear a staleness signal needs this to
|
|
81
|
+
* decide whether the write it just made actually satisfied what it was
|
|
82
|
+
* issued for. Empty for every dropped or rejected verdict.
|
|
83
|
+
*/
|
|
84
|
+
readonly keys: readonly string[];
|
|
85
|
+
/** Why, for the verdicts that are refusals. Present only when it helps. */
|
|
86
|
+
readonly reason?: string;
|
|
87
|
+
}
|
|
88
|
+
/** The result of one `writeAll`. */
|
|
89
|
+
export interface WriteAllResult {
|
|
90
|
+
/** One entry per payload, in the order they were given. */
|
|
91
|
+
readonly results: readonly WriteResult[];
|
|
92
|
+
/** The union of every payload's touched keys, de-duplicated. */
|
|
93
|
+
readonly keys: readonly string[];
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* What a reader is told about one key.
|
|
97
|
+
*
|
|
98
|
+
* FOUR ABSENCES, NOT ONE. Never-fetched, deleted and broadcast-partial are
|
|
99
|
+
* different answers and a screen renders each of them differently. The fourth —
|
|
100
|
+
* a 404 — is deliberately NOT a member: a refusal carries a message and a
|
|
101
|
+
* remedy that the store has no way to build, so it belongs to whatever layer
|
|
102
|
+
* performed the request.
|
|
103
|
+
*
|
|
104
|
+
* `stale` is part of the state rather than a side channel because a write that
|
|
105
|
+
* changes no value but marks a field stale must still notify — and notifying
|
|
106
|
+
* for something no reader can observe is worse than not notifying at all.
|
|
107
|
+
*/
|
|
108
|
+
export type RecordState<T> = {
|
|
109
|
+
readonly status: "unknown";
|
|
110
|
+
} | {
|
|
111
|
+
readonly status: "present";
|
|
112
|
+
readonly record: T;
|
|
113
|
+
/** Bumps on every accepted write that changed something observable. */
|
|
114
|
+
readonly version: number;
|
|
115
|
+
/**
|
|
116
|
+
* Fields the last broadcast could not carry. Sorted, so two structurally
|
|
117
|
+
* equal stale sets compare equal.
|
|
118
|
+
*
|
|
119
|
+
* A held stale value can only be stale-LOW for a monotonic high-water
|
|
120
|
+
* mark, never stale-high, so holding the last number on screen while the
|
|
121
|
+
* refetch lands is honest. Dimming it is available, not mandatory.
|
|
122
|
+
*/
|
|
123
|
+
readonly stale: readonly string[];
|
|
124
|
+
} | {
|
|
125
|
+
readonly status: "deleted";
|
|
126
|
+
readonly at: string;
|
|
127
|
+
};
|
|
128
|
+
/** What `useRecord`/`useRecords` require of their caller. */
|
|
129
|
+
export interface ReadOptions {
|
|
130
|
+
/**
|
|
131
|
+
* REQUIRED, not optional. The tag a `"fetch"` must have satisfied before
|
|
132
|
+
* this key reports `present`.
|
|
133
|
+
*
|
|
134
|
+
* The tag mechanism existed once as an optional parameter and nothing forced
|
|
135
|
+
* a caller to use it, which reopened the exact hole it was introduced to
|
|
136
|
+
* close. One word in the signature is the whole fix.
|
|
137
|
+
*/
|
|
138
|
+
readonly needs: string;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* A registered record type: the runtime string and the compile-time type, so
|
|
142
|
+
* the two can never drift.
|
|
143
|
+
*
|
|
144
|
+
* `_record` is a phantom — it carries `T` through inference and holds no value
|
|
145
|
+
* at runtime.
|
|
146
|
+
*/
|
|
147
|
+
export interface RecordTypeToken<T> {
|
|
148
|
+
/** The NORMALIZED model name. Never carries a `Resource` suffix. */
|
|
149
|
+
readonly type: string;
|
|
150
|
+
/** @see RecordTypeOptions.staleFields */
|
|
151
|
+
readonly staleFields: readonly string[] | "*";
|
|
152
|
+
/** Phantom. Never read. */
|
|
153
|
+
readonly _record?: T;
|
|
154
|
+
}
|
|
155
|
+
/** What a type may declare at registration. */
|
|
156
|
+
export interface RecordTypeOptions {
|
|
157
|
+
/**
|
|
158
|
+
* The fields this type's BROADCAST cannot carry — because they are computed,
|
|
159
|
+
* or deliberately withheld from the whitelist. Everything else in a
|
|
160
|
+
* broadcast merges normally.
|
|
161
|
+
*
|
|
162
|
+
* Staleness is PER FIELD and never a whole-type on/off switch. A per-type
|
|
163
|
+
* binary discards the twelve real fields a broadcast does carry in order to
|
|
164
|
+
* signal the two it does not.
|
|
165
|
+
*
|
|
166
|
+
* `"*"` means every data field — the case where a type's broadcast carries
|
|
167
|
+
* identity and nothing else, and where the field set is not knowable at
|
|
168
|
+
* registration because it is a bag of dynamic attributes. It resolves at
|
|
169
|
+
* write time against the keys the record actually holds; see
|
|
170
|
+
* `resolveStaleFields` in `store.ts` for what that buys and what it costs.
|
|
171
|
+
*/
|
|
172
|
+
readonly staleFields?: readonly string[] | "*";
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* One root affected by a staleness mark, and the fields under it that are now
|
|
176
|
+
* suspect.
|
|
177
|
+
*
|
|
178
|
+
* `key` is a ROOT, not the key that went stale. For a queue, the key that goes
|
|
179
|
+
* stale is a run while the list holds demands; naming the raw key would match
|
|
180
|
+
* no list slot and nothing would ever refetch. Roots are resolved through the
|
|
181
|
+
* hydration memo's deps map, which is safe in a way a maintained reverse index
|
|
182
|
+
* is not: it is rebuilt by the same walk that reads it, so there is no separate
|
|
183
|
+
* maintenance step to get wrong.
|
|
184
|
+
*/
|
|
185
|
+
export interface StalenessEntry {
|
|
186
|
+
readonly key: string;
|
|
187
|
+
readonly fields: readonly string[];
|
|
188
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { RecordPayload } from "./types";
|
|
2
|
+
/** A relation, once normalized: a pointer to another record's key. */
|
|
3
|
+
export interface RecordRef {
|
|
4
|
+
readonly __ref: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function isRecordRef(value: unknown): value is RecordRef;
|
|
7
|
+
/**
|
|
8
|
+
* Strip a trailing `Resource` so a delete and the record it deletes land on
|
|
9
|
+
* the same key.
|
|
10
|
+
*
|
|
11
|
+
* CREATED AND DELETED PAYLOADS DISAGREE ABOUT `__type`, verified in the
|
|
12
|
+
* backend twice: created/updated take it from a resource class name that no
|
|
13
|
+
* resource overrides, so it keeps the suffix (`"WorkflowRunResource"`), while
|
|
14
|
+
* deletes take it from a helper that strips the suffix (`"WorkflowRun"`).
|
|
15
|
+
*
|
|
16
|
+
* A store keyed on the raw string files a delete under a different key than
|
|
17
|
+
* the record it is deleting, so the tombstone never lands and the row stays on
|
|
18
|
+
* screen forever. One line, and without it a whole class of update silently
|
|
19
|
+
* does nothing.
|
|
20
|
+
*/
|
|
21
|
+
export declare function normalizeTypeName(raw: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* `Type:id`, with the id COERCED TO A STRING.
|
|
24
|
+
*
|
|
25
|
+
* Ids are not uniformly numeric — a file's id is a UUID while a run's is an
|
|
26
|
+
* integer — and a Map keyed on the raw value would file `7` and `"7"`
|
|
27
|
+
* separately. There is deliberately NO `id || name` fallback: that is a quirk
|
|
28
|
+
* of one prior implementation, not part of any contract, and a record keyed on
|
|
29
|
+
* a name silently merges two different rows the day two of them share one.
|
|
30
|
+
*/
|
|
31
|
+
export declare function recordKey(type: string, id: string | number): string;
|
|
32
|
+
/** The identity a payload carries, or `undefined` if it is not a record. */
|
|
33
|
+
export interface PayloadIdentity {
|
|
34
|
+
readonly key: string;
|
|
35
|
+
readonly type: string;
|
|
36
|
+
readonly id: string;
|
|
37
|
+
}
|
|
38
|
+
export declare function payloadIdentity(payload: RecordPayload): PayloadIdentity | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* A `{__stale:true, id, __model}` ping: an invalidation the backend sends
|
|
41
|
+
* under the normal event name with NO `__type` at all.
|
|
42
|
+
*
|
|
43
|
+
* Recognised by name and dropped, because keying it would need a type it does
|
|
44
|
+
* not have — and guessing one from `__model` (a PHP class name) is exactly the
|
|
45
|
+
* sort of inference that produces a store full of records nothing reads.
|
|
46
|
+
*/
|
|
47
|
+
export declare function isStalePing(payload: RecordPayload): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* The tombstone marker, or `undefined`.
|
|
50
|
+
*
|
|
51
|
+
* BOTH SPELLINGS, deliberately. A `deleted` event carries `deleted_at`; a
|
|
52
|
+
* soft-delete arriving as an `updated` event carries `__deleted_at`. The prior
|
|
53
|
+
* art in this codebase checks only the second, so its delete handling has never
|
|
54
|
+
* run once — the payload says `deleted_at` and the store asks for
|
|
55
|
+
* `__deleted_at`.
|
|
56
|
+
*/
|
|
57
|
+
export declare function tombstoneAt(payload: RecordPayload): string | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* True when the payload says, in so many words, that the record is NOT
|
|
60
|
+
* deleted — which is what un-deletes a tombstoned record.
|
|
61
|
+
*
|
|
62
|
+
* Needed because absent keeps the previous value: without this, a record that
|
|
63
|
+
* was tombstoned could never come back, even when the server says it has.
|
|
64
|
+
*/
|
|
65
|
+
export declare function explicitlyUndeleted(payload: RecordPayload): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Normalize `__timestamp` to milliseconds.
|
|
68
|
+
*
|
|
69
|
+
* IT ARRIVES IN TWO UNITS, 1000x APART, and this is verified rather than
|
|
70
|
+
* theoretical: the backend reads the model's `updated_at` in MILLISECONDS when
|
|
71
|
+
* the model has that column, and falls back to a SECONDS-resolution wall clock
|
|
72
|
+
* when it does not. At least one real model has no `updated_at` column at all.
|
|
73
|
+
*
|
|
74
|
+
* A comparison across the two units is not merely wrong, it is CONSISTENTLY
|
|
75
|
+
* wrong in one direction: a seconds value is ~1000x smaller, so it always
|
|
76
|
+
* loses to a milliseconds value and such a record would never update again.
|
|
77
|
+
*
|
|
78
|
+
* An implausible magnitude — below either window — is a contract violation,
|
|
79
|
+
* and it is surfaced rather than coerced. It returns `undefined`, which means
|
|
80
|
+
* "cannot adjudicate": the write is still ACCEPTED (a bogus tiny number must
|
|
81
|
+
* not be allowed to make a record permanently un-writable), it just cannot
|
|
82
|
+
* refuse anything.
|
|
83
|
+
*/
|
|
84
|
+
export declare function normalizeTimestamp(raw: unknown): number | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* Keys the store INTERPRETS rather than stores.
|
|
87
|
+
*
|
|
88
|
+
* Everything `__`-prefixed is envelope by this wire format's own convention,
|
|
89
|
+
* and two of them would actively break the store if kept as data:
|
|
90
|
+
* `__broadcasted_at` moves on every delivery, so storing it would make an
|
|
91
|
+
* identical redelivered payload look like a change and re-render the world —
|
|
92
|
+
* which is the exact cost the notify-only-if-changed rule exists to avoid.
|
|
93
|
+
*
|
|
94
|
+
* `deleted_at` is here because it is the tombstone marker, not a field.
|
|
95
|
+
*/
|
|
96
|
+
export declare function isEnvelopeKey(key: string): boolean;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@danxbot/ui/pure` — the half of this package that is not a UI.
|
|
3
|
+
*
|
|
4
|
+
* WHY A SECOND ENTRY EXISTS. The package exported exactly one, `.`, which is
|
|
5
|
+
* the whole design system. So an application's own formatting layer — a plain
|
|
6
|
+
* module that turns records into strings, imported by workers, tests, server
|
|
7
|
+
* code and components alike — could not reach `formatBytes` without importing
|
|
8
|
+
* React and every component in this library into a layer that is deliberately
|
|
9
|
+
* framework-free. The consumer's answer was to copy the function, which is how
|
|
10
|
+
* two places start rendering the same quantity to different precision.
|
|
11
|
+
*
|
|
12
|
+
* THE CONTRACT, AND IT IS THE ONLY REASON THIS ENTRY IS WORTH HAVING: nothing
|
|
13
|
+
* reachable from here imports React, `react-dom`, or the JSX runtime. An entry
|
|
14
|
+
* that quietly pulls the React graph back in is not a smaller import, it is the
|
|
15
|
+
* same import with a second name — and it would fail silently, because a
|
|
16
|
+
* consumer's bundle does not announce what got dragged into it.
|
|
17
|
+
*
|
|
18
|
+
* So the claim is checked against the BUILT ARTIFACT rather than reasoned about
|
|
19
|
+
* from the source: `pure-entry.test.ts` reads `dist/pure.js`, extracts every
|
|
20
|
+
* import specifier it actually emitted, and asserts none of them is React —
|
|
21
|
+
* plus a size ceiling, so React cannot have been inlined instead of imported.
|
|
22
|
+
* A source-graph sweep in the same file catches it one step earlier, before a
|
|
23
|
+
* build has run.
|
|
24
|
+
*
|
|
25
|
+
* WHAT BELONGS HERE. Decisions about how a value READS, with no dependencies:
|
|
26
|
+
* precision, units, the point at which a rounded figure stops telling the
|
|
27
|
+
* truth. Deliberately NOT the calendar and time layers — `formatDateRange`,
|
|
28
|
+
* `hoursInDay` and the rest are equally pure and would drag the whole `Intl`
|
|
29
|
+
* time layer behind them, which is a bigger entry answering a question nobody
|
|
30
|
+
* has asked yet. That is a separate decision, to be made when a consumer needs
|
|
31
|
+
* it and not before.
|
|
32
|
+
*
|
|
33
|
+
* Everything exported here is ALSO exported from the main entry, so nothing
|
|
34
|
+
* about this is a migration and no existing import has to change.
|
|
35
|
+
*/
|
|
36
|
+
export { formatBytes, formatTokens } from "./lib/format";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danxbot/ui",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Danxbot — a domain-agnostic React design system with motion as a first-class primitive.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,6 +35,10 @@
|
|
|
35
35
|
"types": "./dist/types/index.d.ts",
|
|
36
36
|
"import": "./dist/index.js"
|
|
37
37
|
},
|
|
38
|
+
"./pure": {
|
|
39
|
+
"types": "./dist/types/pure.d.ts",
|
|
40
|
+
"import": "./dist/pure.js"
|
|
41
|
+
},
|
|
38
42
|
"./styles.css": "./dist/styles.css",
|
|
39
43
|
"./theme.css": "./dist/theme.css",
|
|
40
44
|
"./fonts.css": "./dist/fonts.css",
|
|
@@ -56,7 +60,7 @@
|
|
|
56
60
|
"audit:cards": "node scripts/audit-card-theme.mjs",
|
|
57
61
|
"audit:hover": "node scripts/audit-hover.mjs",
|
|
58
62
|
"test": "vitest run",
|
|
59
|
-
"build:lib": "vite build --config vite.lib.config.ts && node scripts/postbuild-css.mjs && npm run build:types",
|
|
63
|
+
"build:lib": "vite build --config vite.lib.config.ts && vite build --config vite.pure.config.ts && node scripts/postbuild-css.mjs && npm run build:types",
|
|
60
64
|
"fonts": "node scripts/fetch-fonts.mjs",
|
|
61
65
|
"icons": "node scripts/build-icons.mjs",
|
|
62
66
|
"build:types": "tsc -p tsconfig.build.json",
|