@graview/core 0.2.0 → 0.2.2
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/binding-served.d.ts +5 -11
- package/dist/binding-served.d.ts.map +1 -1
- package/dist/binding-served.js +4 -15
- package/dist/binding-served.js.map +1 -1
- package/dist/binding-ungranted.d.ts +2 -0
- package/dist/binding-ungranted.d.ts.map +1 -0
- package/dist/binding-ungranted.js +9 -0
- package/dist/binding-ungranted.js.map +1 -0
- package/dist/binding.d.ts +1 -1
- package/dist/binding.d.ts.map +1 -1
- package/dist/binding.js +21 -23
- package/dist/binding.js.map +1 -1
- package/dist/capabilities.js +1 -1
- package/dist/capabilities.js.map +1 -1
- package/dist/cli/check/policy.d.ts +3 -0
- package/dist/cli/check/policy.d.ts.map +1 -1
- package/dist/cli/check/policy.js +28 -1
- package/dist/cli/check/policy.js.map +1 -1
- package/dist/document/compile.d.ts.map +1 -1
- package/dist/document/compile.js +14 -4
- package/dist/document/compile.js.map +1 -1
- package/dist/document/edit.d.ts.map +1 -1
- package/dist/document/edit.js +5 -0
- package/dist/document/edit.js.map +1 -1
- package/dist/document.schema.json +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mutations/vote-suggestion.d.ts +13 -0
- package/dist/mutations/vote-suggestion.d.ts.map +1 -1
- package/dist/mutations/vote-suggestion.js.map +1 -1
- package/dist/ops/declines.js +1 -1
- package/dist/ops/declines.js.map +1 -1
- package/dist/ops/suggestions.d.ts.map +1 -1
- package/dist/ops/suggestions.js +2 -1
- package/dist/ops/suggestions.js.map +1 -1
- package/dist/past.d.ts.map +1 -1
- package/dist/past.js +5 -2
- package/dist/past.js.map +1 -1
- package/dist/record-boxes.d.ts +73 -0
- package/dist/record-boxes.d.ts.map +1 -0
- package/dist/record-boxes.js +95 -0
- package/dist/record-boxes.js.map +1 -0
- package/dist/seat-of.d.ts +4 -0
- package/dist/seat-of.d.ts.map +1 -1
- package/dist/seat-of.js +12 -0
- package/dist/seat-of.js.map +1 -1
- package/dist/seen.d.ts +32 -5
- package/dist/seen.d.ts.map +1 -1
- package/dist/seen.js +249 -36
- package/dist/seen.js.map +1 -1
- package/dist/store.d.ts +25 -0
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +69 -6
- package/dist/store.js.map +1 -1
- package/dist/subscriptions.d.ts.map +1 -1
- package/dist/subscriptions.js +7 -5
- package/dist/subscriptions.js.map +1 -1
- package/dist/theme/layers.d.ts +2 -1
- package/dist/theme/layers.d.ts.map +1 -1
- package/dist/theme/layers.js +2 -2
- package/dist/theme/layers.js.map +1 -1
- package/dist/tidying.d.ts.map +1 -1
- package/dist/tidying.js +18 -3
- package/dist/tidying.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WHERE A DRAWING ANOTHER HAND MADE SHOWS ITS RECORDS (Graview HQ
|
|
3
|
+
* feature:f-one-face-lines-from-frame-views).
|
|
4
|
+
*
|
|
5
|
+
* The one face draws a line from each record a page shows to that record's
|
|
6
|
+
* building, read off the page's own marks. A view drawn somewhere the page
|
|
7
|
+
* cannot read — a worker view's shadow root, a frame guest's document —
|
|
8
|
+
* says which records it shows, and where, through the element it is drawn
|
|
9
|
+
* in instead: that element wears `data-graview-record-boxes`, holds what
|
|
10
|
+
* it says under `RECORD_BOXES`, and raises `RECORD_BOXES_MOVED` when the
|
|
11
|
+
* records it shows change. What it answers its host has already judged.
|
|
12
|
+
*/
|
|
13
|
+
/** The key what an element says is held under: one symbol for every copy of the framework on a page. */
|
|
14
|
+
export const RECORD_BOXES = Symbol.for("graview.record-boxes");
|
|
15
|
+
/** The event the element raises (bubbling, composed) when the records it shows change: a list of them is read again. */
|
|
16
|
+
export const RECORD_BOXES_MOVED = "graview-record-boxes";
|
|
17
|
+
/** The attribute the element wears while it holds one: what a page finds them by. */
|
|
18
|
+
export const RECORD_BOXES_ATTRIBUTE = "data-graview-record-boxes";
|
|
19
|
+
/** What an element holds, if it holds anything. */
|
|
20
|
+
export function recordBoxesOf(element) {
|
|
21
|
+
const held = element[RECORD_BOXES];
|
|
22
|
+
return held && typeof held.boxes === "function" && typeof held.shows === "function" ? held : undefined;
|
|
23
|
+
}
|
|
24
|
+
/** Give an element what it says, or take it away (`undefined`). */
|
|
25
|
+
export function holdRecordBoxes(element, held) {
|
|
26
|
+
const holder = element;
|
|
27
|
+
if (held) {
|
|
28
|
+
Object.defineProperty(holder, RECORD_BOXES, { value: held, configurable: true, enumerable: false, writable: true });
|
|
29
|
+
element.setAttribute(RECORD_BOXES_ATTRIBUTE, "");
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
delete holder[RECORD_BOXES];
|
|
33
|
+
element.removeAttribute(RECORD_BOXES_ATTRIBUTE);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** Say the records an element shows changed. */
|
|
37
|
+
export function recordBoxesMoved(element) {
|
|
38
|
+
const Event = element.ownerDocument?.defaultView?.Event;
|
|
39
|
+
if (Event)
|
|
40
|
+
element.dispatchEvent(new Event(RECORD_BOXES_MOVED, { bubbles: true, composed: true }));
|
|
41
|
+
}
|
|
42
|
+
/** The most boxes an element is believed: past it, the rest are not read. */
|
|
43
|
+
export const MOST_RECORD_BOXES = 200;
|
|
44
|
+
const idOk = (id) => typeof id === "string" && id.length > 0 && id.length <= 200;
|
|
45
|
+
/**
|
|
46
|
+
* WHAT A VIEW SAID OF ITS RECORDS, JUDGED: plain boxes inside the element,
|
|
47
|
+
* of records it may name, no more than the most, and nothing else of what
|
|
48
|
+
* it said.
|
|
49
|
+
*/
|
|
50
|
+
export function judgeRecordBoxes(said, input) {
|
|
51
|
+
if (!Array.isArray(said))
|
|
52
|
+
return [];
|
|
53
|
+
const most = Math.max(0, Math.min(input.most ?? MOST_RECORD_BOXES, MOST_RECORD_BOXES));
|
|
54
|
+
const width = Number.isFinite(input.width) ? Math.max(0, input.width) : 0;
|
|
55
|
+
const height = Number.isFinite(input.height) ? Math.max(0, input.height) : 0;
|
|
56
|
+
const kept = [];
|
|
57
|
+
const read = Math.min(said.length, most * 2);
|
|
58
|
+
for (let at = 0; at < read && kept.length < most; at++) {
|
|
59
|
+
const one = said[at];
|
|
60
|
+
if (!one || typeof one !== "object" || Array.isArray(one))
|
|
61
|
+
continue;
|
|
62
|
+
const { id, x, y, width: w, height: h } = one;
|
|
63
|
+
if (!idOk(id))
|
|
64
|
+
continue;
|
|
65
|
+
if (typeof x !== "number" || typeof y !== "number" || typeof w !== "number" || typeof h !== "number")
|
|
66
|
+
continue;
|
|
67
|
+
if (![x, y, w, h].every(Number.isFinite) || w <= 0 || h <= 0)
|
|
68
|
+
continue;
|
|
69
|
+
const left = Math.max(0, Math.min(width, x));
|
|
70
|
+
const top = Math.max(0, Math.min(height, y));
|
|
71
|
+
const right = Math.max(0, Math.min(width, x + w));
|
|
72
|
+
const bottom = Math.max(0, Math.min(height, y + h));
|
|
73
|
+
if (right - left < 1 || bottom - top < 1)
|
|
74
|
+
continue;
|
|
75
|
+
if (!input.sees(id))
|
|
76
|
+
continue;
|
|
77
|
+
kept.push({ id, x: left, y: top, width: right - left, height: bottom - top });
|
|
78
|
+
}
|
|
79
|
+
return kept;
|
|
80
|
+
}
|
|
81
|
+
/** The records a view said it shows, judged as its boxes are: ids it may name, each once, no more than the most. */
|
|
82
|
+
export function judgeRecordIds(said, sees, most = MOST_RECORD_BOXES) {
|
|
83
|
+
if (!Array.isArray(said))
|
|
84
|
+
return [];
|
|
85
|
+
const kept = new Set();
|
|
86
|
+
const cap = Math.max(0, Math.min(most, MOST_RECORD_BOXES));
|
|
87
|
+
const read = Math.min(said.length, cap * 2);
|
|
88
|
+
for (let at = 0; at < read && kept.size < cap; at++) {
|
|
89
|
+
const id = said[at];
|
|
90
|
+
if (idOk(id) && !kept.has(id) && sees(id))
|
|
91
|
+
kept.add(id);
|
|
92
|
+
}
|
|
93
|
+
return [...kept];
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=record-boxes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record-boxes.js","sourceRoot":"","sources":["../src/record-boxes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,wGAAwG;AACxG,MAAM,CAAC,MAAM,YAAY,GAAkB,MAAM,CAAC,GAAG,CAAC,sBAAsB,CAAU,CAAC;AAEvF,wHAAwH;AACxH,MAAM,CAAC,MAAM,kBAAkB,GAAG,sBAAsB,CAAC;AAEzD,qFAAqF;AACrF,MAAM,CAAC,MAAM,sBAAsB,GAAG,2BAA2B,CAAC;AA2BlE,mDAAmD;AACnD,MAAM,UAAU,aAAa,CAAC,OAAe;IAC3C,MAAM,IAAI,GAAI,OAA8C,CAAC,YAAY,CAAyC,CAAC;IACnH,OAAO,IAAI,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,UAAU,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,UAAU,CAAC,CAAC,CAAE,IAAwB,CAAC,CAAC,CAAC,SAAS,CAAC;AAC9H,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,eAAe,CAAC,OAA0B,EAAE,IAAiC;IAC3F,MAAM,MAAM,GAAG,OAA6C,CAAC;IAC7D,IAAI,IAAI,EAAE,CAAC;QACT,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QACpH,OAAO,CAAC,YAAY,CAAC,sBAAsB,EAAE,EAAE,CAAC,CAAC;IACnD,CAAC;SAAM,CAAC;QACN,OAAO,MAAM,CAAC,YAAY,CAAC,CAAC;QAC5B,OAAO,CAAC,eAAe,CAAC,sBAAsB,CAAC,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AAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,EAAE,CAAC;YAAE,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;AACnB,CAAC"}
|
package/dist/seat-of.d.ts
CHANGED
|
@@ -6,4 +6,8 @@ export declare const seatOf: <S extends AnySchema>(store: Store<S>) => {
|
|
|
6
6
|
readonly store: Store<S>;
|
|
7
7
|
readonly principal: Principal;
|
|
8
8
|
} | undefined;
|
|
9
|
+
/** The store a past is a moment of; undefined for a store that is no past. */
|
|
10
|
+
export declare const presentOf: (store: object) => object | undefined;
|
|
11
|
+
/** Say what a past is a moment of: the present itself, never another past. */
|
|
12
|
+
export declare const markPresent: (past: object, store: object) => void;
|
|
9
13
|
//# sourceMappingURL=seat-of.d.ts.map
|
package/dist/seat-of.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seat-of.d.ts","sourceRoot":"","sources":["../src/seat-of.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAcxC,iFAAiF;AACjF,eAAO,MAAM,MAAM,GAAI,CAAC,SAAS,SAAS,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC,KAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;CAAE,GAAG,SACP,CAAC"}
|
|
1
|
+
{"version":3,"file":"seat-of.d.ts","sourceRoot":"","sources":["../src/seat-of.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAcxC,iFAAiF;AACjF,eAAO,MAAM,MAAM,GAAI,CAAC,SAAS,SAAS,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC,KAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;CAAE,GAAG,SACP,CAAC;AAWtH,8EAA8E;AAC9E,eAAO,MAAM,SAAS,GAAI,OAAO,MAAM,KAAG,MAAM,GAAG,SAAmE,CAAC;AAEvH,8EAA8E;AAC9E,eAAO,MAAM,WAAW,GAAI,MAAM,MAAM,EAAE,OAAO,MAAM,KAAG,IAA0G,CAAC"}
|
package/dist/seat-of.js
CHANGED
|
@@ -11,4 +11,16 @@
|
|
|
11
11
|
const SEAT = Symbol.for("@graview/core:seat");
|
|
12
12
|
/** The store a seat's view is of, and the seat; undefined for a store itself. */
|
|
13
13
|
export const seatOf = (store) => store[SEAT];
|
|
14
|
+
/*
|
|
15
|
+
* WHAT A STORE OF THE PAST IS OF: the store whose moment it is (`pastOf`),
|
|
16
|
+
* so what is judged from the whole log — whom a seat was ever bound to —
|
|
17
|
+
* is judged from the present's, and a moment before a binding never says
|
|
18
|
+
* the account a member is told as a record now. Read off the past by a
|
|
19
|
+
* key it answers, as the seat is.
|
|
20
|
+
*/
|
|
21
|
+
const PRESENT = Symbol.for("@graview/core:present");
|
|
22
|
+
/** The store a past is a moment of; undefined for a store that is no past. */
|
|
23
|
+
export const presentOf = (store) => store[PRESENT];
|
|
24
|
+
/** Say what a past is a moment of: the present itself, never another past. */
|
|
25
|
+
export const markPresent = (past, store) => void Object.defineProperty(past, PRESENT, { value: presentOf(store) ?? store, enumerable: false });
|
|
14
26
|
//# sourceMappingURL=seat-of.js.map
|
package/dist/seat-of.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seat-of.js","sourceRoot":"","sources":["../src/seat-of.ts"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AACH,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;AAE9C,iFAAiF;AACjF,MAAM,CAAC,MAAM,MAAM,GAAG,CAAsB,KAAe,EAA2E,EAAE,CACrI,KAA4G,CAAC,IAAI,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"seat-of.js","sourceRoot":"","sources":["../src/seat-of.ts"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AACH,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;AAE9C,iFAAiF;AACjF,MAAM,CAAC,MAAM,MAAM,GAAG,CAAsB,KAAe,EAA2E,EAAE,CACrI,KAA4G,CAAC,IAAI,CAAC,CAAC;AAEtH;;;;;;GAMG;AACH,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;AAEpD,8EAA8E;AAC9E,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAa,EAAsB,EAAE,CAAE,KAA4C,CAAC,OAAO,CAAC,CAAC;AAEvH,8EAA8E;AAC9E,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAY,EAAE,KAAa,EAAQ,EAAE,CAAC,KAAK,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC"}
|
package/dist/seen.d.ts
CHANGED
|
@@ -134,14 +134,41 @@ export declare function viewsOf(store: object): Map<string, unknown>;
|
|
|
134
134
|
* `seenBy` for that seat makes its view anew.
|
|
135
135
|
*/
|
|
136
136
|
export declare function forgetSeatView(store: object, principal: Principal): void;
|
|
137
|
+
/**
|
|
138
|
+
* WHAT A READER IS TOLD OF A SEAT BOUND TO A PERSON: the record it is bound
|
|
139
|
+
* to now — else the one the log last bound it to — unless the reader may be
|
|
140
|
+
* told the seat itself (the seat's own, and the host's, `keepsSeat`); and
|
|
141
|
+
* whether the reader may see that record. Undefined for a seat bound to none.
|
|
142
|
+
*/
|
|
143
|
+
export declare function boundAs(store: Judged, lens: Pick<SeatLens, "shows" | "keepsSeat">): (seat: string) => {
|
|
144
|
+
readonly id: string;
|
|
145
|
+
readonly shown: boolean;
|
|
146
|
+
} | undefined;
|
|
147
|
+
/**
|
|
148
|
+
* WHO A SEAT BOUND TO A PERSON IS, TO THIS READER (Roadmap
|
|
149
|
+
* f-invite-binds-existing-person): what a host says of somebody beyond the
|
|
150
|
+
* log — who is here, for whom an agent acts — says the record, by its id
|
|
151
|
+
* and its name where the reader may see it, and never the account. Undefined
|
|
152
|
+
* for a seat bound to nobody, and for the reader's own seat and the host's.
|
|
153
|
+
*/
|
|
154
|
+
export declare function boundPeopleFor(store: Judged, principal: Principal): (seat: string) => {
|
|
155
|
+
readonly id: string;
|
|
156
|
+
readonly shown: boolean;
|
|
157
|
+
readonly name?: string;
|
|
158
|
+
} | undefined;
|
|
137
159
|
/**
|
|
138
160
|
* WHO DID IT, AS THE PERSON THEY WERE BOUND TO (Roadmap
|
|
139
|
-
* f-invite-binds-existing-person): an op by a seat bound to a record
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
* the
|
|
161
|
+
* f-invite-binds-existing-person): an op by a seat bound to a record is
|
|
162
|
+
* authored, to every reader but that seat and the host, by the record — its
|
|
163
|
+
* id and its name, where this reader may see it; by neither, only the name
|
|
164
|
+
* the author gave, where it may not — never by the account, which is the
|
|
165
|
+
* seat itself (`$seat`) and served to nobody else. So is who proposed it and
|
|
166
|
+
* who voted for it. To the seat itself and the host, its account, named as
|
|
167
|
+
* its record where it is served one, so Activity says "Bud". An author bound
|
|
168
|
+
* to nobody is as it was. Kept for one reading of the log while the store
|
|
169
|
+
* tells nothing new.
|
|
143
170
|
*/
|
|
144
|
-
export declare function namedAuthors(store: Judged, lens: Pick<SeatLens, "shows" | "served">, ops: readonly Operation[]): readonly Operation[];
|
|
171
|
+
export declare function namedAuthors(store: Judged, lens: Pick<SeatLens, "shows" | "served" | "keepsSeat">, ops: readonly Operation[]): readonly Operation[];
|
|
145
172
|
/** The app as a seat is served it at the head: what its sight reaches, as the store grows. */
|
|
146
173
|
export declare function seatView<T extends Viewed>(store: T, principal: Principal): T;
|
|
147
174
|
//# sourceMappingURL=seen.d.ts.map
|
package/dist/seen.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seen.d.ts","sourceRoot":"","sources":["../src/seen.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC3G,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAuB,KAAK,KAAK,EAAE,KAAK,UAAU,EAAE,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAEnG,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"seen.d.ts","sourceRoot":"","sources":["../src/seen.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC3G,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAuB,KAAK,KAAK,EAAE,KAAK,UAAU,EAAE,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAEnG,OAAO,KAAK,EAAiB,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG/D,OAAO,EAAmC,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAOnF,OAAO,EAA4D,KAAK,MAAM,EAAgB,MAAM,wBAAwB,CAAC;AAC7H,OAAO,KAAK,EAAE,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,CAkFnJ;AAED,8FAA8F;AAC9F,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,SAAS,EAAE,SAAS,GAAG,CAAC,CAsO5E"}
|
package/dist/seen.js
CHANGED
|
@@ -5,7 +5,9 @@ import { isWithheld, namesUnseen, redact } from "./ops/withheld.js";
|
|
|
5
5
|
import { labelOf } from "./schema/define-node.js";
|
|
6
6
|
import { actingAs, grantsTo, isSystem, meOf, profileOf, seatedIn, seatPersonOf } from "./permissions/policy.js";
|
|
7
7
|
import { PERSON_SEAT } from "./graph/archived.js";
|
|
8
|
-
import {
|
|
8
|
+
import { isUnset } from "./graph/primitives.js";
|
|
9
|
+
import { seatsKept, unseated } from "./binding-served.js";
|
|
10
|
+
import { presentOf } from "./seat-of.js";
|
|
9
11
|
import { FIELD_SIGHT, fieldsJudged, partialSight, recordsOf, sees } from "./permissions/sight.js";
|
|
10
12
|
import { diffSnapshots } from "./graph/diff.js";
|
|
11
13
|
import { nodeRefKinds } from "./mutations/node-ref.js";
|
|
@@ -27,12 +29,12 @@ function turnedOff(store, principal) {
|
|
|
27
29
|
export function hidesFrom(store, principal) {
|
|
28
30
|
if (isSystem(principal))
|
|
29
31
|
return false;
|
|
30
|
-
return (store.policy?.sees?.length ?? 0) > 0 || turnedOff(store, principal).size > 0 || (store
|
|
32
|
+
return (store.policy?.sees?.length ?? 0) > 0 || turnedOff(store, principal).size > 0 || anyBound(store);
|
|
31
33
|
}
|
|
32
34
|
/*
|
|
33
35
|
* AND WHILE A PERSON IS BOUND TO A SEAT (Roadmap f-invite-binds-existing-person):
|
|
34
|
-
* the seat is an account's id, told to that account itself
|
|
35
|
-
*
|
|
36
|
+
* the seat is an account's id, told to that account itself and to the host,
|
|
37
|
+
* which binds people (`seatsKept`), and served to nobody else.
|
|
36
38
|
*/
|
|
37
39
|
/**
|
|
38
40
|
* WHICH KINDS A SEAT SEES EVERY RECORD OF (FR-55): by a sight that is not
|
|
@@ -207,7 +209,7 @@ function lensFor(store, principal) {
|
|
|
207
209
|
* that guessed an id whether the guess was real.
|
|
208
210
|
*/
|
|
209
211
|
const actor = isSystem(principal) ? undefined : actingAs(principal).id;
|
|
210
|
-
const keepsSeat = seatsKept(
|
|
212
|
+
const keepsSeat = seatsKept(principal);
|
|
211
213
|
const length = () => store.log.length ?? store.log.all().length;
|
|
212
214
|
// The same record served the same way is the same object, so a view read twice is equal by identity.
|
|
213
215
|
const cleared = new WeakMap();
|
|
@@ -484,49 +486,254 @@ export function forgetSeatView(store, principal) {
|
|
|
484
486
|
}
|
|
485
487
|
/** Whether a kind here is the people, whom a seat could be bound to. */
|
|
486
488
|
const hasPeople = (store) => (store.schema?.definitions ?? []).some((definition) => definition.people === true);
|
|
489
|
+
/** An author whose record this reader may not see: somebody, as `WITHHELD_AUTHOR` is for a withheld op — never no id, which a page reads as the reader. */
|
|
490
|
+
const SOMEONE = { id: "someone", name: "Someone" };
|
|
487
491
|
const NAMED = new WeakMap();
|
|
492
|
+
/** Each seat the log ever bound to a person, and the last record it was bound to — kept though that record is removed since. */
|
|
493
|
+
const EVER_BOUND = new WeakMap();
|
|
494
|
+
/**
|
|
495
|
+
* WHOM A SEAT WAS BOUND TO, AS THE LOG SAYS (Roadmap
|
|
496
|
+
* f-invite-binds-existing-person): every binding the log holds, followed
|
|
497
|
+
* through an unbinding, but not through the record's removal or a second
|
|
498
|
+
* record bound to the same seat — so what an author did is never said as
|
|
499
|
+
* the account again once it was said as a record. Read once a growth.
|
|
500
|
+
*/
|
|
501
|
+
function everBound(store) {
|
|
502
|
+
const own = boundInLog(store);
|
|
503
|
+
// A moment of the past: what the present's log bound too, so nothing it says as a record is said as the account at an earlier seq.
|
|
504
|
+
const present = presentOf(store);
|
|
505
|
+
if (!present)
|
|
506
|
+
return own;
|
|
507
|
+
const now = boundInLog(present);
|
|
508
|
+
if (now.size === 0)
|
|
509
|
+
return own;
|
|
510
|
+
const lengths = `${logLength(store)}:${logLength(present)}`;
|
|
511
|
+
const held = PAST_BOUND.get(store);
|
|
512
|
+
if (held && held.lengths === lengths)
|
|
513
|
+
return held.bound;
|
|
514
|
+
const bound = new Map([...now, ...own]);
|
|
515
|
+
PAST_BOUND.set(store, { lengths, bound });
|
|
516
|
+
return bound;
|
|
517
|
+
}
|
|
518
|
+
/** A past's bindings read with the present's, kept while neither log grew. */
|
|
519
|
+
const PAST_BOUND = new WeakMap();
|
|
520
|
+
const logLength = (store) => {
|
|
521
|
+
const log = store.log;
|
|
522
|
+
return log.length ?? log.all().length;
|
|
523
|
+
};
|
|
524
|
+
/** Each seat this store's own log bound to a person, as `everBound` reads it. */
|
|
525
|
+
function boundInLog(store) {
|
|
526
|
+
const log = store.log;
|
|
527
|
+
const horizon = log.horizon ?? 0;
|
|
528
|
+
const length = log.length ?? log.all().length;
|
|
529
|
+
let held = EVER_BOUND.get(log);
|
|
530
|
+
if (held && held.horizon === horizon && held.length === length)
|
|
531
|
+
return held.bound;
|
|
532
|
+
// A compaction moves the horizon past ops already read: what they bound is kept, though the record is gone.
|
|
533
|
+
if (held && held.length <= length && held.length >= horizon)
|
|
534
|
+
held.horizon = horizon;
|
|
535
|
+
else {
|
|
536
|
+
held = { horizon, length: horizon, bound: new Map() };
|
|
537
|
+
EVER_BOUND.set(log, held);
|
|
538
|
+
// Behind a horizon, the graph's own bindings stand for what the archive said.
|
|
539
|
+
for (const node of store.graph.allNodes?.() ?? []) {
|
|
540
|
+
const seat = node[PERSON_SEAT];
|
|
541
|
+
if (typeof seat === "string")
|
|
542
|
+
held.bound.set(seat, node.id);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
const ops = log.all();
|
|
546
|
+
for (let at = held.length - horizon; at < ops.length; at++) {
|
|
547
|
+
for (const primitive of ops[at].primitives) {
|
|
548
|
+
if (primitive.op === "add-node") {
|
|
549
|
+
const seat = primitive.node[PERSON_SEAT];
|
|
550
|
+
if (typeof seat === "string")
|
|
551
|
+
held.bound.set(seat, primitive.node.id);
|
|
552
|
+
}
|
|
553
|
+
else if (primitive.op === "patch-node" && Object.hasOwn(primitive.after, PERSON_SEAT)) {
|
|
554
|
+
const seat = primitive.after[PERSON_SEAT];
|
|
555
|
+
const was = primitive.before[PERSON_SEAT];
|
|
556
|
+
if (typeof seat === "string" && !isUnset(seat))
|
|
557
|
+
held.bound.set(seat, primitive.id);
|
|
558
|
+
else if (typeof was === "string" && held.bound.get(was) === primitive.id)
|
|
559
|
+
held.bound.delete(was);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
held.length = length;
|
|
564
|
+
return held.bound;
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Whether a bare account has a profile bound to a person (`acct~prf`), which
|
|
568
|
+
* a reader may not be told: what names only the account (who proposed, who
|
|
569
|
+
* voted, who is here) is then nobody's to that reader, since it would pair
|
|
570
|
+
* the account with the person.
|
|
571
|
+
*/
|
|
572
|
+
function profileBound(store, keepsSeat, account) {
|
|
573
|
+
if (account.includes("~"))
|
|
574
|
+
return false;
|
|
575
|
+
for (const seat of everBound(store).keys())
|
|
576
|
+
if (seat.startsWith(`${account}~`) && keepsSeat?.(seat) !== true)
|
|
577
|
+
return true;
|
|
578
|
+
return false;
|
|
579
|
+
}
|
|
580
|
+
/** Whether the log ever bound a seat to a person: what a seat is served is judged from then on. */
|
|
581
|
+
const anyBound = (store) => store.graph.hasPersonSeats?.() === true || (store.schema?.definitions ?? []).some((one) => one.people === true) && everBound(store).size > 0;
|
|
582
|
+
/**
|
|
583
|
+
* WHAT A READER IS TOLD OF A SEAT BOUND TO A PERSON: the record it is bound
|
|
584
|
+
* to now — else the one the log last bound it to — unless the reader may be
|
|
585
|
+
* told the seat itself (the seat's own, and the host's, `keepsSeat`); and
|
|
586
|
+
* whether the reader may see that record. Undefined for a seat bound to none.
|
|
587
|
+
*/
|
|
588
|
+
export function boundAs(store, lens) {
|
|
589
|
+
if (!anyBound(store))
|
|
590
|
+
return () => undefined;
|
|
591
|
+
const graph = store.graph;
|
|
592
|
+
const bound = everBound(store);
|
|
593
|
+
return (seat) => {
|
|
594
|
+
if (lens.keepsSeat?.(seat) === true)
|
|
595
|
+
return undefined;
|
|
596
|
+
const id = graph.personBoundTo?.(seat) ?? bound.get(seat);
|
|
597
|
+
if (id !== undefined)
|
|
598
|
+
return { id, shown: lens.shows(id) };
|
|
599
|
+
// A bare account one of whose profiles is somebody's record here: no record this reader may be told.
|
|
600
|
+
return profileBound(store, lens.keepsSeat, seat) ? { id: seat, shown: false } : undefined;
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
/** A record's name as this seat is shown the record — its sight, field by field — and none where what it is shown names nobody. */
|
|
604
|
+
function shownName(store, lens, id) {
|
|
605
|
+
const whole = lens.shows(id) ? store.graph.getNode(id) : undefined;
|
|
606
|
+
const node = whole && lens.served(whole);
|
|
607
|
+
if (!node)
|
|
608
|
+
return undefined;
|
|
609
|
+
let name;
|
|
610
|
+
try {
|
|
611
|
+
name = labelOf(store.schema?.tryDefinition(node.kind), node);
|
|
612
|
+
}
|
|
613
|
+
catch {
|
|
614
|
+
name = undefined;
|
|
615
|
+
}
|
|
616
|
+
return typeof name === "string" && name.trim().length > 0 && name !== node.id ? name : undefined;
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* WHO A SEAT BOUND TO A PERSON IS, TO THIS READER (Roadmap
|
|
620
|
+
* f-invite-binds-existing-person): what a host says of somebody beyond the
|
|
621
|
+
* log — who is here, for whom an agent acts — says the record, by its id
|
|
622
|
+
* and its name where the reader may see it, and never the account. Undefined
|
|
623
|
+
* for a seat bound to nobody, and for the reader's own seat and the host's.
|
|
624
|
+
*/
|
|
625
|
+
export function boundPeopleFor(store, principal) {
|
|
626
|
+
if (!anyBound(store))
|
|
627
|
+
return () => undefined;
|
|
628
|
+
const lens = seatLens(store, principal);
|
|
629
|
+
const as = boundAs(store, lens);
|
|
630
|
+
return (seat) => {
|
|
631
|
+
const bound = as(seat);
|
|
632
|
+
if (bound === undefined)
|
|
633
|
+
return undefined;
|
|
634
|
+
const name = bound.shown ? shownName(store, lens, bound.id) : undefined;
|
|
635
|
+
return { ...bound, ...(name !== undefined ? { name } : {}) };
|
|
636
|
+
};
|
|
637
|
+
}
|
|
488
638
|
/**
|
|
489
639
|
* WHO DID IT, AS THE PERSON THEY WERE BOUND TO (Roadmap
|
|
490
|
-
* f-invite-binds-existing-person): an op by a seat bound to a record
|
|
491
|
-
*
|
|
492
|
-
*
|
|
493
|
-
* the
|
|
640
|
+
* f-invite-binds-existing-person): an op by a seat bound to a record is
|
|
641
|
+
* authored, to every reader but that seat and the host, by the record — its
|
|
642
|
+
* id and its name, where this reader may see it; by neither, only the name
|
|
643
|
+
* the author gave, where it may not — never by the account, which is the
|
|
644
|
+
* seat itself (`$seat`) and served to nobody else. So is who proposed it and
|
|
645
|
+
* who voted for it. To the seat itself and the host, its account, named as
|
|
646
|
+
* its record where it is served one, so Activity says "Bud". An author bound
|
|
647
|
+
* to nobody is as it was. Kept for one reading of the log while the store
|
|
648
|
+
* tells nothing new.
|
|
494
649
|
*/
|
|
495
650
|
export function namedAuthors(store, lens, ops) {
|
|
496
|
-
|
|
497
|
-
if (!graph.hasPersonSeats?.() || !graph.personBoundTo)
|
|
651
|
+
if (!anyBound(store))
|
|
498
652
|
return ops;
|
|
653
|
+
const graph = store.graph;
|
|
499
654
|
const told = store.version ?? store.log.all().length;
|
|
500
655
|
const held = NAMED.get(ops);
|
|
501
|
-
if (held && held.told === told)
|
|
656
|
+
if (held && held.told === told && held.lens === lens)
|
|
502
657
|
return held.ops;
|
|
658
|
+
const as = boundAs(store, lens);
|
|
659
|
+
const nameOf = (id) => shownName(store, lens, id);
|
|
660
|
+
/** A seat named in a lineage, as this reader is told it: its record where it may see it, else nobody's. */
|
|
661
|
+
const seatSaid = (seat) => {
|
|
662
|
+
const bound = as(seat);
|
|
663
|
+
return bound === undefined ? seat : bound.shown ? bound.id : undefined;
|
|
664
|
+
};
|
|
665
|
+
/*
|
|
666
|
+
* A person's seat, its account, and what this reader is told of it: the
|
|
667
|
+
* seat's own record — or, for a profile bound to nobody on an account that
|
|
668
|
+
* is somebody's record here, nobody this reader is told of, since its
|
|
669
|
+
* account is that person's and its session would pair the two.
|
|
670
|
+
*/
|
|
671
|
+
const seated = (person) => {
|
|
672
|
+
const seat = person.kind === "human" ? seatPersonOf(person) : undefined;
|
|
673
|
+
const account = actingAs(person).id;
|
|
674
|
+
const bound = seat === undefined ? undefined : (as(seat) ?? (account !== undefined && seat !== account && lens.keepsSeat?.(seat) !== true && as(account) !== undefined ? { id: account, shown: false } : undefined));
|
|
675
|
+
return { seat, account, bound };
|
|
676
|
+
};
|
|
503
677
|
let changed = false;
|
|
504
678
|
const named = ops.map((op) => {
|
|
505
|
-
|
|
506
|
-
if (isWithheld(op) || (author.onBehalfOf ?? author).kind !== "human")
|
|
679
|
+
if (isWithheld(op))
|
|
507
680
|
return op;
|
|
508
|
-
|
|
509
|
-
const
|
|
510
|
-
const
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
if (
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
name
|
|
681
|
+
let out = op;
|
|
682
|
+
const author = op.author;
|
|
683
|
+
const person = author.onBehalfOf ?? author;
|
|
684
|
+
const { seat, account, bound } = seated(person);
|
|
685
|
+
let said;
|
|
686
|
+
if (seat !== undefined && bound !== undefined) {
|
|
687
|
+
// Anybody else: the record, never the account — nor the profile, which is the account's.
|
|
688
|
+
said = bound.shown ? nameOf(bound.id) : undefined;
|
|
689
|
+
const { profile: _profile, name: own, id: _id, session: _session, ...rest } = person;
|
|
690
|
+
// Where the reader may not see the record: somebody, by no id and no name of the account's — as a withheld op's author is.
|
|
691
|
+
const whom = bound.shown ? { ...rest, id: bound.id, ...((said ?? own) !== undefined ? { name: said ?? own } : {}) } : { kind: rest.kind, id: SOMEONE.id, name: SOMEONE.name };
|
|
692
|
+
out = { ...out, author: author.onBehalfOf ? { ...author, onBehalfOf: whom } : whom };
|
|
518
693
|
}
|
|
519
|
-
|
|
520
|
-
|
|
694
|
+
else if (seat !== undefined && (graph.personBoundTo?.(seat) ?? everBound(store).get(seat)) !== undefined) {
|
|
695
|
+
// The seat itself, or the host: its own account, named as its record.
|
|
696
|
+
said = nameOf((graph.personBoundTo?.(seat) ?? everBound(store).get(seat)));
|
|
697
|
+
if (said !== undefined && person.name !== said)
|
|
698
|
+
out = { ...out, author: author.onBehalfOf ? { ...author, onBehalfOf: { ...person, name: said } } : { ...person, name: said } };
|
|
521
699
|
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
700
|
+
// Who proposed it, and who voted for it: never an account this reader may not be told.
|
|
701
|
+
const lineage = op.lineage;
|
|
702
|
+
if (lineage && (lineage.proposedBy !== undefined || lineage.voters !== undefined)) {
|
|
703
|
+
/*
|
|
704
|
+
* Who proposed it is a person by their account: read as that person is,
|
|
705
|
+
* profile and all — this op's author when they proposed it, the
|
|
706
|
+
* proposal's author when this op accepted it.
|
|
707
|
+
*/
|
|
708
|
+
const proposal = lineage.suggestion === undefined ? undefined : store.log.get?.(lineage.suggestion);
|
|
709
|
+
const proposer = proposal && !isWithheld(proposal) ? (proposal.author.onBehalfOf ?? proposal.author) : person;
|
|
710
|
+
const them = proposer === person ? { seat, account, bound } : seated(proposer);
|
|
711
|
+
const by = lineage.proposedBy === undefined ? undefined : them.seat !== undefined && lineage.proposedBy === them.account ? them.bound : as(lineage.proposedBy);
|
|
712
|
+
const voters = lineage.voters?.flatMap((voter) => seatSaid(voter) ?? []);
|
|
713
|
+
const votersMoved = voters !== undefined && (voters.length !== lineage.voters.length || voters.some((one, at) => one !== lineage.voters[at]));
|
|
714
|
+
if (by !== undefined || votersMoved) {
|
|
715
|
+
const { proposedBy, voters: _voters, ...rest } = lineage;
|
|
716
|
+
const name = by?.shown ? nameOf(by.id) : undefined;
|
|
717
|
+
// The default words name the proposer by their account's name: said again as the record — and, with the proposal behind a horizon, whatever name they gave.
|
|
718
|
+
const ownName = by !== undefined && rest.basis.startsWith("Proposed by ") && (proposal === undefined || [proposer.name, proposer.profile?.name, lineage.proposedBy].some((one) => one !== undefined && rest.basis === `Proposed by ${one}`));
|
|
719
|
+
out = {
|
|
720
|
+
...out,
|
|
721
|
+
lineage: {
|
|
722
|
+
...rest,
|
|
723
|
+
...(ownName ? { basis: name !== undefined ? `Proposed by ${name}` : "Proposed" } : {}),
|
|
724
|
+
// Somebody, where the reader may not see them: still a proposal, by nobody it may be told of.
|
|
725
|
+
...(proposedBy === undefined ? {} : by === undefined ? { proposedBy } : { proposedBy: by.shown ? by.id : SOMEONE.id }),
|
|
726
|
+
...(voters !== undefined ? { voters } : {}),
|
|
727
|
+
},
|
|
728
|
+
};
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
if (out !== op)
|
|
732
|
+
changed = true;
|
|
733
|
+
return out;
|
|
527
734
|
});
|
|
528
735
|
const out = changed ? named : ops;
|
|
529
|
-
NAMED.set(ops, { told, ops: out });
|
|
736
|
+
NAMED.set(ops, { told, lens, ops: out });
|
|
530
737
|
return out;
|
|
531
738
|
}
|
|
532
739
|
/** The app as a seat is served it at the head: what its sight reaches, as the store grows. */
|
|
@@ -592,7 +799,13 @@ export function seatView(store, principal) {
|
|
|
592
799
|
if (!epoch.creators)
|
|
593
800
|
return { ...rest, base };
|
|
594
801
|
const kept = new Set(base.nodes.map((node) => node.id));
|
|
595
|
-
|
|
802
|
+
// A maker bound to a person is that person's record to this seat, as an op's author is (`namedAuthors`), unless the seat is told its account.
|
|
803
|
+
const as = boundAs(store, lens);
|
|
804
|
+
const madeBy = (maker) => {
|
|
805
|
+
const bound = as(maker);
|
|
806
|
+
return bound === undefined ? maker : bound.shown ? bound.id : undefined;
|
|
807
|
+
};
|
|
808
|
+
const creators = Object.fromEntries(Object.entries(epoch.creators).flatMap(([id, maker]) => (kept.has(id) ? [[id, madeBy(maker)]] : [])).filter((entry) => entry[1] !== undefined && !namesUnseen(entry[1], lens.sees)));
|
|
596
809
|
return { ...rest, base, creators };
|
|
597
810
|
};
|
|
598
811
|
/** An epoch as this seat is served it, when there is one. */
|
|
@@ -615,7 +828,7 @@ export function seatView(store, principal) {
|
|
|
615
828
|
return (id) => served(target.getNode(id));
|
|
616
829
|
case "has":
|
|
617
830
|
return seenId;
|
|
618
|
-
// Whom a seat is bound to, asked only of the seats this one may be told of (its own
|
|
831
|
+
// Whom a seat is bound to, asked only of the seats this one may be told of (its own; every one is the host's alone), and only a record it is served.
|
|
619
832
|
case "personBoundTo":
|
|
620
833
|
return (seat) => {
|
|
621
834
|
if (!lens.keepsSeat?.(seat))
|
|
@@ -729,8 +942,8 @@ export function seatView(store, principal) {
|
|
|
729
942
|
// What no longer fits, about records this seat is served and naming none it may not see (FR-55).
|
|
730
943
|
case "findings":
|
|
731
944
|
return () => target.findings().filter((finding) => {
|
|
732
|
-
// Who is bound to whom is
|
|
733
|
-
if (finding.code === "person-seat-shared"
|
|
945
|
+
// Who is bound to whom is the host's alone, which binds people (Roadmap f-invite-binds-existing-person).
|
|
946
|
+
if (finding.code === "person-seat-shared")
|
|
734
947
|
return false;
|
|
735
948
|
const ids = finding.id.includes("->") ? finding.id.split("->").map((end, at) => (at === 0 ? end.slice(end.indexOf(":") + 1) : end)) : [finding.id];
|
|
736
949
|
return ids.every((id) => !full.has(id) || seenId(id)) && !namesUnseen(finding, lens.sees);
|