@verdant-web/common 2.4.0 → 2.5.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.
@@ -8,7 +8,8 @@ export * from './utils.js';
8
8
  export * from './indexes.js';
9
9
  export { migrate, migrationRange, createDefaultMigration, createMigration, } from './migration.js';
10
10
  export type { Migration, MigrationIndexDescription, MigrationEngine, } from './migration.js';
11
- export type { UserInfo } from './presence.js';
11
+ export type * from './presence.js';
12
+ export { initialInternalPresence } from './presence.js';
12
13
  export * from './patch.js';
13
14
  export * from './oids.js';
14
15
  export * from './oidsLegacy.js';
package/dist/esm/index.js CHANGED
@@ -7,6 +7,7 @@ export * from './schema/index.js';
7
7
  export * from './utils.js';
8
8
  export * from './indexes.js';
9
9
  export { migrate, migrationRange, createDefaultMigration, createMigration, } from './migration.js';
10
+ export { initialInternalPresence } from './presence.js';
10
11
  export * from './patch.js';
11
12
  export * from './oids.js';
12
13
  export * from './oidsLegacy.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,OAAO,EACN,OAAO,EACP,cAAc,EACd,sBAAsB,EACtB,eAAe,GACf,MAAM,gBAAgB,CAAC;AAOxB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAE3B,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC3E,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,OAAO,EACN,OAAO,EACP,cAAc,EACd,sBAAsB,EACtB,eAAe,GACf,MAAM,gBAAgB,CAAC;AAOxB,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACxD,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAE3B,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC3E,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
@@ -24,4 +24,17 @@ export interface UserInfo<Profile, Presence> {
24
24
  * makes changes. The shape of presence is up to you.
25
25
  */
26
26
  presence: Presence;
27
+ /**
28
+ * This is the internal presence data that Verdant uses
29
+ * for some built-in presence functionality. The client
30
+ * should manage it transparently to the user.
31
+ */
32
+ internal: VerdantInternalPresence;
33
+ }
34
+ export type UserInfoUpdate<Profile = any, Presence = any> = Omit<UserInfo<Profile, Presence>, 'internal' | 'profile'> & {
35
+ internal?: VerdantInternalPresence;
36
+ };
37
+ export interface VerdantInternalPresence {
38
+ viewId?: string;
27
39
  }
40
+ export declare const initialInternalPresence: VerdantInternalPresence;
@@ -1,2 +1,2 @@
1
- export {};
1
+ export const initialInternalPresence = {};
2
2
  //# sourceMappingURL=presence.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"presence.js","sourceRoot":"","sources":["../../src/presence.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"presence.js","sourceRoot":"","sources":["../../src/presence.ts"],"names":[],"mappings":"AAgDA,MAAM,CAAC,MAAM,uBAAuB,GAA4B,EAAE,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { DocumentBaseline } from './baseline.js';
2
2
  import { Operation } from './operation.js';
3
- import { UserInfo } from './presence.js';
3
+ import { UserInfo, VerdantInternalPresence } from './presence.js';
4
4
  export type HeartbeatMessage = {
5
5
  type: 'heartbeat';
6
6
  timestamp: string;
@@ -108,7 +108,9 @@ export type PresenceUpdateMessage = {
108
108
  /** The client's replica ID */
109
109
  replicaId: string;
110
110
  /** new presence value */
111
- presence: any;
111
+ presence?: any;
112
+ /** presence that is internal to verdant */
113
+ internal?: VerdantInternalPresence;
112
114
  };
113
115
  export type PresenceChangedMessage = {
114
116
  type: 'presence-changed';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdant-web/common",
3
- "version": "2.4.0",
3
+ "version": "2.5.0",
4
4
  "access": "public",
5
5
  "type": "module",
6
6
  "exports": {
package/src/index.ts CHANGED
@@ -17,7 +17,8 @@ export type {
17
17
  MigrationIndexDescription,
18
18
  MigrationEngine,
19
19
  } from './migration.js';
20
- export type { UserInfo } from './presence.js';
20
+ export type * from './presence.js';
21
+ export { initialInternalPresence } from './presence.js';
21
22
  export * from './patch.js';
22
23
  export * from './oids.js';
23
24
  export * from './oidsLegacy.js';
package/src/presence.ts CHANGED
@@ -26,4 +26,24 @@ export interface UserInfo<Profile, Presence> {
26
26
  * makes changes. The shape of presence is up to you.
27
27
  */
28
28
  presence: Presence;
29
+
30
+ /**
31
+ * This is the internal presence data that Verdant uses
32
+ * for some built-in presence functionality. The client
33
+ * should manage it transparently to the user.
34
+ */
35
+ internal: VerdantInternalPresence;
29
36
  }
37
+
38
+ export type UserInfoUpdate<Profile = any, Presence = any> = Omit<
39
+ UserInfo<Profile, Presence>,
40
+ 'internal' | 'profile'
41
+ > & {
42
+ internal?: VerdantInternalPresence;
43
+ };
44
+
45
+ export interface VerdantInternalPresence {
46
+ viewId?: string;
47
+ }
48
+
49
+ export const initialInternalPresence: VerdantInternalPresence = {};
package/src/protocol.ts CHANGED
@@ -1,8 +1,12 @@
1
1
  // client ID, and therefore library ID, is inferred
2
2
 
3
3
  import { DocumentBaseline } from './baseline.js';
4
- import { Operation, OperationPatch } from './operation.js';
5
- import { UserInfo } from './presence.js';
4
+ import { Operation } from './operation.js';
5
+ import {
6
+ UserInfo,
7
+ UserInfoUpdate,
8
+ VerdantInternalPresence,
9
+ } from './presence.js';
6
10
 
7
11
  export type HeartbeatMessage = {
8
12
  type: 'heartbeat';
@@ -124,7 +128,9 @@ export type PresenceUpdateMessage = {
124
128
  /** The client's replica ID */
125
129
  replicaId: string;
126
130
  /** new presence value */
127
- presence: any;
131
+ presence?: any;
132
+ /** presence that is internal to verdant */
133
+ internal?: VerdantInternalPresence;
128
134
  };
129
135
 
130
136
  export type PresenceChangedMessage = {