@pmate/chat-sdk 0.13.0-profile.13 → 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.
@@ -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;
@@ -48,7 +49,7 @@ export declare class ProfileMemoryStore {
48
49
  private presented;
49
50
  private readingIndices;
50
51
  private presentedPages;
51
- constructor(onError?: (error: unknown) => void, profileId?: string);
52
+ constructor(onError?: (error: unknown) => void, profileId?: string, preparePresentation?: boolean);
52
53
  /** Release a disposed Profile without mutating snapshots held by React.
53
54
  * Worker replacement deliberately keeps this store alive; only final close
54
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();
@@ -32,9 +33,10 @@ export class ProfileMemoryStore {
32
33
  presented = new Map();
33
34
  readingIndices = new Map();
34
35
  presentedPages = new WeakMap();
35
- constructor(onError = () => { }, profileId = "") {
36
+ constructor(onError = () => { }, profileId = "", preparePresentation = true) {
36
37
  this.onError = onError;
37
38
  this.profileId = profileId;
39
+ this.preparePresentation = preparePresentation;
38
40
  }
39
41
  /** Release a disposed Profile without mutating snapshots held by React.
40
42
  * Worker replacement deliberately keeps this store alive; only final close
@@ -323,6 +325,8 @@ export class ProfileMemoryStore {
323
325
  this.readingIndices.set(message.threadId, index);
324
326
  }
325
327
  prepareMessageView(message) {
328
+ if (!this.preparePresentation)
329
+ return;
326
330
  const thread = this.threads.get(message.threadId);
327
331
  const source = thread?.readingSources.find(row => row.sourceThreadId === message.sourceThreadId);
328
332
  const mine = message.from === this.profileId;
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pmate/chat-sdk",
3
- "version": "0.13.0-profile.13",
3
+ "version": "0.13.0-profile.14",
4
4
  "description": "Local-first chat SDK, message subscriptions, reading state, and shared chat UI primitives",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",