@pmate/chat-sdk 0.13.0-profile.12 → 0.13.0-profile.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -421,3 +421,12 @@ now indexes only nonempty blocks. Reading a small page no longer walks interveni
|
|
|
421
421
|
empty block contents. A 10,002-Window regression with only two populated blocks
|
|
422
422
|
checks older/newer anchors, retained block identities and forked directories.
|
|
423
423
|
No storage schema or Window merge behavior changes.
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
### Empty Window display directory (0.13.0-profile.13)
|
|
427
|
+
|
|
428
|
+
Prepared `getWindowIds()` now returns only nonempty display blocks. Durable empty
|
|
429
|
+
sealed Windows still retain their identities and remain directly readable for
|
|
430
|
+
historical routing; they no longer consume load-older steps. Empty/refilled
|
|
431
|
+
transitions notify Window-list subscribers. Message-only changes retain the same
|
|
432
|
+
published ID array, and previously published arrays stay unchanged.
|
|
@@ -24,6 +24,7 @@ export type ProfileDelta = {
|
|
|
24
24
|
export declare class ProfileMemoryStore {
|
|
25
25
|
private onError;
|
|
26
26
|
private profileId;
|
|
27
|
+
private preparePresentation;
|
|
27
28
|
private windowRows;
|
|
28
29
|
private messageWindows;
|
|
29
30
|
private windowPages;
|
|
@@ -32,6 +33,7 @@ export declare class ProfileMemoryStore {
|
|
|
32
33
|
private windowListeners;
|
|
33
34
|
private windowListListeners;
|
|
34
35
|
private dirtyWindows;
|
|
36
|
+
private dirtyWindowLists;
|
|
35
37
|
private readonly emptyWindowIds;
|
|
36
38
|
private current?;
|
|
37
39
|
private entities;
|
|
@@ -47,7 +49,7 @@ export declare class ProfileMemoryStore {
|
|
|
47
49
|
private presented;
|
|
48
50
|
private readingIndices;
|
|
49
51
|
private presentedPages;
|
|
50
|
-
constructor(onError?: (error: unknown) => void, profileId?: string);
|
|
52
|
+
constructor(onError?: (error: unknown) => void, profileId?: string, preparePresentation?: boolean);
|
|
51
53
|
/** Release a disposed Profile without mutating snapshots held by React.
|
|
52
54
|
* Worker replacement deliberately keeps this store alive; only final close
|
|
53
55
|
* may discard its entities and subscriptions. */
|
|
@@ -8,6 +8,7 @@ export const PROFILE_PROJECTION_VERSION = 2;
|
|
|
8
8
|
export class ProfileMemoryStore {
|
|
9
9
|
onError;
|
|
10
10
|
profileId;
|
|
11
|
+
preparePresentation;
|
|
11
12
|
windowRows = new Map();
|
|
12
13
|
messageWindows = new Map();
|
|
13
14
|
windowPages = new Map();
|
|
@@ -16,6 +17,7 @@ export class ProfileMemoryStore {
|
|
|
16
17
|
windowListeners = new Map();
|
|
17
18
|
windowListListeners = new Map();
|
|
18
19
|
dirtyWindows = new Set();
|
|
20
|
+
dirtyWindowLists = new Set();
|
|
19
21
|
emptyWindowIds = [];
|
|
20
22
|
current;
|
|
21
23
|
entities = new Map();
|
|
@@ -31,9 +33,10 @@ export class ProfileMemoryStore {
|
|
|
31
33
|
presented = new Map();
|
|
32
34
|
readingIndices = new Map();
|
|
33
35
|
presentedPages = new WeakMap();
|
|
34
|
-
constructor(onError = () => { }, profileId = "") {
|
|
36
|
+
constructor(onError = () => { }, profileId = "", preparePresentation = true) {
|
|
35
37
|
this.onError = onError;
|
|
36
38
|
this.profileId = profileId;
|
|
39
|
+
this.preparePresentation = preparePresentation;
|
|
37
40
|
}
|
|
38
41
|
/** Release a disposed Profile without mutating snapshots held by React.
|
|
39
42
|
* Worker replacement deliberately keeps this store alive; only final close
|
|
@@ -47,6 +50,7 @@ export class ProfileMemoryStore {
|
|
|
47
50
|
this.windowListeners.clear();
|
|
48
51
|
this.windowListListeners.clear();
|
|
49
52
|
this.dirtyWindows.clear();
|
|
53
|
+
this.dirtyWindowLists.clear();
|
|
50
54
|
this.entities.clear();
|
|
51
55
|
this.threads.clear();
|
|
52
56
|
this.directories.clear();
|
|
@@ -100,6 +104,9 @@ export class ProfileMemoryStore {
|
|
|
100
104
|
windowKey(threadId, windowId) { return JSON.stringify([threadId, windowId]); }
|
|
101
105
|
installWindow(window) {
|
|
102
106
|
const key = this.windowKey(window.threadId, window.windowId);
|
|
107
|
+
const previous = this.windowRows.get(key);
|
|
108
|
+
if (!previous || (previous.count === 0) !== (window.count === 0))
|
|
109
|
+
this.dirtyWindowLists.add(window.threadId);
|
|
103
110
|
for (const ref of this.windowRows.get(key)?.refs ?? [])
|
|
104
111
|
if (this.messageWindows.get(ref.messageId) === key)
|
|
105
112
|
this.messageWindows.delete(ref.messageId);
|
|
@@ -318,6 +325,8 @@ export class ProfileMemoryStore {
|
|
|
318
325
|
this.readingIndices.set(message.threadId, index);
|
|
319
326
|
}
|
|
320
327
|
prepareMessageView(message) {
|
|
328
|
+
if (!this.preparePresentation)
|
|
329
|
+
return;
|
|
321
330
|
const thread = this.threads.get(message.threadId);
|
|
322
331
|
const source = thread?.readingSources.find(row => row.sourceThreadId === message.sourceThreadId);
|
|
323
332
|
const mine = message.from === this.profileId;
|
|
@@ -350,12 +359,16 @@ export class ProfileMemoryStore {
|
|
|
350
359
|
for (const threadId of affected) {
|
|
351
360
|
const blocks = this.directories.get(threadId)?.blocks ?? [];
|
|
352
361
|
const previous = this.windowIds.get(threadId);
|
|
353
|
-
//
|
|
354
|
-
//
|
|
355
|
-
if (!previous ||
|
|
356
|
-
|
|
357
|
-
|
|
362
|
+
// Durable empty blocks keep their IDs and routing boundaries, but are
|
|
363
|
+
// omitted from the display directory. Entity-only updates keep its array.
|
|
364
|
+
if (!previous || this.dirtyWindowLists.has(threadId)) {
|
|
365
|
+
const ids = blocks.filter(window => window.count > 0).map(window => window.windowId);
|
|
366
|
+
if (!previous || ids.length !== previous.length || ids.some((id, index) => id !== previous[index])) {
|
|
367
|
+
this.windowIds.set(threadId, ids);
|
|
368
|
+
changedLists.add(threadId);
|
|
369
|
+
}
|
|
358
370
|
}
|
|
371
|
+
this.dirtyWindowLists.delete(threadId);
|
|
359
372
|
const available = this.isThreadAvailable(threadId);
|
|
360
373
|
if (this.windowAccess.get(threadId) !== available) {
|
|
361
374
|
this.windowAccess.set(threadId, available);
|
|
@@ -11,6 +11,8 @@ export type ProfileOwnerOptions = {
|
|
|
11
11
|
onError?: (error: unknown) => void;
|
|
12
12
|
windowMs?: number;
|
|
13
13
|
readingWindowMs?: number;
|
|
14
|
+
/** Worker authority needs raw committed rows; its UI consumer prepares presentation. */
|
|
15
|
+
preparePresentation?: boolean;
|
|
14
16
|
retryMs?: number;
|
|
15
17
|
};
|
|
16
18
|
/** The durable owner publishes only after commit. Network requests belong to
|
|
@@ -21,7 +21,7 @@ export class ProfileOwner {
|
|
|
21
21
|
credentialUpdater = () => { throw Error("PROFILE_NETWORK_UNAVAILABLE"); };
|
|
22
22
|
constructor(options) {
|
|
23
23
|
this.options = options;
|
|
24
|
-
this.memory = new ProfileMemoryStore(options.onError, options.database.identity.profileId);
|
|
24
|
+
this.memory = new ProfileMemoryStore(options.onError, options.database.identity.profileId, options.preparePresentation);
|
|
25
25
|
}
|
|
26
26
|
static async open(options) {
|
|
27
27
|
const owner = new ProfileOwner(options);
|
|
@@ -64,7 +64,7 @@ export function installProfileWorker(port, options = {}) {
|
|
|
64
64
|
throw Error("PROFILE_LOCKS_UNAVAILABLE");
|
|
65
65
|
database = options.database?.(config.identity) ?? new ProfileDatabase(config.identity);
|
|
66
66
|
const stored = await database.inboxState.get("current");
|
|
67
|
-
owner = await ProfileOwner.open({ database, epoch: stored?.epoch ?? config.epoch ?? "uninitialized", windowStart: config.windowStart,
|
|
67
|
+
owner = await ProfileOwner.open({ database, preparePresentation: false, epoch: stored?.epoch ?? config.epoch ?? "uninitialized", windowStart: config.windowStart,
|
|
68
68
|
onError: error => port.postMessage({ profileControl: "error", error: error instanceof Error ? error.message : "PROFILE_OWNER_FAILED" }) });
|
|
69
69
|
disposers.push(serveProfileWorker(owner, port, nextScope));
|
|
70
70
|
if (network) {
|
package/package.json
CHANGED