cojson 0.6.7 → 0.7.0-alpha.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.
Files changed (53) hide show
  1. package/.eslintrc.cjs +1 -0
  2. package/.turbo/turbo-build.log +2 -2
  3. package/CHANGELOG.md +3 -3
  4. package/dist/coValue.js.map +1 -1
  5. package/dist/coValueCore.js.map +1 -1
  6. package/dist/coValues/account.js +5 -5
  7. package/dist/coValues/account.js.map +1 -1
  8. package/dist/coValues/coList.js +39 -58
  9. package/dist/coValues/coList.js.map +1 -1
  10. package/dist/coValues/coMap.js +20 -61
  11. package/dist/coValues/coMap.js.map +1 -1
  12. package/dist/coValues/coStream.js +14 -64
  13. package/dist/coValues/coStream.js.map +1 -1
  14. package/dist/coValues/group.js +57 -59
  15. package/dist/coValues/group.js.map +1 -1
  16. package/dist/coreToCoValue.js +17 -12
  17. package/dist/coreToCoValue.js.map +1 -1
  18. package/dist/index.js +8 -8
  19. package/dist/index.js.map +1 -1
  20. package/dist/localNode.js +54 -38
  21. package/dist/localNode.js.map +1 -1
  22. package/dist/permissions.js +2 -2
  23. package/dist/permissions.js.map +1 -1
  24. package/dist/tests/testUtils.js +6 -11
  25. package/dist/tests/testUtils.js.map +1 -1
  26. package/dist/typeUtils/expectGroup.js +2 -2
  27. package/dist/typeUtils/expectGroup.js.map +1 -1
  28. package/dist/typeUtils/isCoValue.js +8 -8
  29. package/dist/typeUtils/isCoValue.js.map +1 -1
  30. package/package.json +3 -4
  31. package/src/coValue.ts +21 -21
  32. package/src/coValueCore.ts +8 -8
  33. package/src/coValues/account.ts +14 -26
  34. package/src/coValues/coList.ts +58 -97
  35. package/src/coValues/coMap.ts +27 -129
  36. package/src/coValues/coStream.ts +31 -137
  37. package/src/coValues/group.ts +52 -46
  38. package/src/coreToCoValue.ts +16 -12
  39. package/src/index.ts +27 -36
  40. package/src/jsonValue.ts +1 -1
  41. package/src/localNode.ts +88 -75
  42. package/src/media.ts +4 -4
  43. package/src/permissions.ts +2 -2
  44. package/src/tests/account.test.ts +12 -12
  45. package/src/tests/coValue.test.ts +149 -182
  46. package/src/tests/coValueCore.test.ts +8 -3
  47. package/src/tests/crypto.test.ts +7 -0
  48. package/src/tests/group.test.ts +13 -6
  49. package/src/tests/permissions.test.ts +648 -840
  50. package/src/tests/sync.test.ts +44 -68
  51. package/src/tests/testUtils.ts +6 -11
  52. package/src/typeUtils/expectGroup.ts +4 -4
  53. package/src/typeUtils/isCoValue.ts +11 -11
@@ -1,5 +1,5 @@
1
1
  import { CoValueCore, CoValueHeader } from "../coValueCore.js";
2
- import { CoID, CoValue } from "../coValue.js";
2
+ import { CoID, RawCoValue } from "../coValue.js";
3
3
  import {
4
4
  AgentSecret,
5
5
  SealerID,
@@ -13,8 +13,8 @@ import {
13
13
  getAgentSignerSecret,
14
14
  } from "../crypto.js";
15
15
  import { AgentID } from "../ids.js";
16
- import { CoMap } from "./coMap.js";
17
- import { Group, InviteSecret } from "./group.js";
16
+ import { RawCoMap } from "./coMap.js";
17
+ import { RawGroup, InviteSecret } from "./group.js";
18
18
  import { LocalNode } from "../index.js";
19
19
 
20
20
  export function accountHeaderForInitialAgentSecret(
@@ -32,11 +32,9 @@ export function accountHeaderForInitialAgentSecret(
32
32
  };
33
33
  }
34
34
 
35
- export class Account<
36
- P extends Profile = Profile,
37
- R extends CoMap = CoMap,
35
+ export class RawAccount<
38
36
  Meta extends AccountMeta = AccountMeta
39
- > extends Group<P, R, Meta> {
37
+ > extends RawGroup<Meta> {
40
38
  currentAgentID(): AgentID {
41
39
  const agents = this.keys().filter((k): k is AgentID =>
42
40
  k.startsWith("sealer_")
@@ -64,12 +62,8 @@ export interface ControlledAccountOrAgent {
64
62
  }
65
63
 
66
64
  /** @hidden */
67
- export class ControlledAccount<
68
- P extends Profile = Profile,
69
- R extends CoMap = CoMap,
70
- Meta extends AccountMeta = AccountMeta
71
- >
72
- extends Account<P, R, Meta>
65
+ export class RawControlledAccount<Meta extends AccountMeta = AccountMeta>
66
+ extends RawAccount<Meta>
73
67
  implements ControlledAccountOrAgent
74
68
  {
75
69
  agentSecret: AgentSecret;
@@ -88,7 +82,7 @@ export class ControlledAccount<
88
82
  return this.core.node.createGroup();
89
83
  }
90
84
 
91
- async acceptInvite<T extends CoValue>(
85
+ async acceptInvite<T extends RawCoValue>(
92
86
  groupOrOwnedValueID: CoID<T>,
93
87
  inviteSecret: InviteSecret
94
88
  ): Promise<void> {
@@ -117,9 +111,7 @@ export class ControlledAccount<
117
111
  }
118
112
 
119
113
  /** @hidden */
120
- export class ControlledAgent
121
- implements ControlledAccountOrAgent
122
- {
114
+ export class ControlledAgent implements ControlledAccountOrAgent {
123
115
  agentSecret: AgentSecret;
124
116
 
125
117
  constructor(agentSecret: AgentSecret) {
@@ -152,7 +144,7 @@ export class ControlledAgent
152
144
  }
153
145
 
154
146
  export type AccountMeta = { type: "account" };
155
- export type AccountID = CoID<Account>;
147
+ export type AccountID = CoID<RawAccount>;
156
148
 
157
149
  export type ProfileShape = {
158
150
  name: string;
@@ -162,14 +154,10 @@ export type ProfileMeta = { type: "profile" };
162
154
  export class Profile<
163
155
  Shape extends ProfileShape = ProfileShape,
164
156
  Meta extends ProfileMeta = ProfileMeta
165
- > extends CoMap<Shape, Meta> {}
157
+ > extends RawCoMap<Shape, Meta> {}
166
158
 
167
- export type AccountMigration<
168
- P extends Profile = Profile,
169
- R extends CoMap = CoMap,
170
- Meta extends AccountMeta = AccountMeta
171
- > = (
172
- account: ControlledAccount<P, R, Meta>,
173
- profile: P,
159
+ export type RawAccountMigration<Meta extends AccountMeta = AccountMeta> = (
160
+ account: RawControlledAccount<Meta>,
161
+ profile: RawCoMap,
174
162
  localNode: LocalNode
175
163
  ) => void | Promise<void>;
@@ -1,11 +1,11 @@
1
1
  import { JsonObject, JsonValue } from "../jsonValue.js";
2
- import { CoID, CoValue } from "../coValue.js";
2
+ import { CoID, RawCoValue } from "../coValue.js";
3
3
  import { isCoValue } from "../typeUtils/isCoValue.js";
4
4
  import { CoValueCore } from "../coValueCore.js";
5
5
  import { accountOrAgentIDfromSessionID } from "../typeUtils/accountOrAgentIDfromSessionID.js";
6
6
  import { AgentID, SessionID, TransactionID } from "../ids.js";
7
7
  import { AccountID } from "./account.js";
8
- import { Group } from "./group.js";
8
+ import { RawGroup } from "./group.js";
9
9
 
10
10
  type OpID = TransactionID & { changeIdx: number };
11
11
 
@@ -41,10 +41,10 @@ type DeletionEntry = {
41
41
  deletionID: OpID;
42
42
  } & DeletionOpPayload;
43
43
 
44
- export class CoListView<
44
+ export class RawCoListView<
45
45
  Item extends JsonValue = JsonValue,
46
- Meta extends JsonObject | null = null
47
- > implements CoValue
46
+ Meta extends JsonObject | null = null,
47
+ > implements RawCoValue
48
48
  {
49
49
  /** @category 6. Meta */
50
50
  id: CoID<this>;
@@ -209,7 +209,7 @@ export class CoListView<
209
209
  }
210
210
 
211
211
  /** @category 6. Meta */
212
- get group(): Group {
212
+ get group(): RawGroup {
213
213
  return this.core.getGroup();
214
214
  }
215
215
 
@@ -306,7 +306,9 @@ export class CoListView<
306
306
  opID,
307
307
  });
308
308
  }
309
- for (const successor of entry.successors) {
309
+ // traverse successors in reverse for correct insertion behavior
310
+ for (let i = entry.successors.length - 1; i >= 0; i--) {
311
+ const successor = entry.successors[i]!;
310
312
  this.fillArrayFromOpID(successor, arr);
311
313
  }
312
314
  }
@@ -393,14 +395,14 @@ export class CoListView<
393
395
  }
394
396
  }
395
397
 
396
- export class CoList<
398
+ export class RawCoList<
397
399
  Item extends JsonValue = JsonValue,
398
- Meta extends JsonObject | null = JsonObject | null
400
+ Meta extends JsonObject | null = JsonObject | null,
399
401
  >
400
- extends CoListView<Item, Meta>
401
- implements CoValue
402
+ extends RawCoListView<Item, Meta>
403
+ implements RawCoValue
402
404
  {
403
- /** Returns a new version of this CoList with `item` appended after the item currently at index `after`.
405
+ /** Appends `item` after the item currently at index `after`.
404
406
  *
405
407
  * If `privacy` is `"private"` **(default)**, `item` is encrypted in the transaction, only readable by other members of the group this `CoList` belongs to. Not even sync servers can see the content in plaintext.
406
408
  *
@@ -412,7 +414,7 @@ export class CoList<
412
414
  item: Item,
413
415
  after?: number,
414
416
  privacy: "private" | "trusting" = "private"
415
- ): this {
417
+ ) {
416
418
  const entries = this.entries();
417
419
  after =
418
420
  after === undefined
@@ -444,11 +446,17 @@ export class CoList<
444
446
  privacy
445
447
  );
446
448
 
447
- return new CoList(this.core) as this;
449
+ const listAfter = new RawCoList(this.core) as this;
450
+
451
+ this.afterStart = listAfter.afterStart;
452
+ this.beforeEnd = listAfter.beforeEnd;
453
+ this.insertions = listAfter.insertions;
454
+ this.deletionsByInsertion = listAfter.deletionsByInsertion;
455
+ this._cachedEntries = undefined;
448
456
  }
449
457
 
450
458
  /**
451
- * Returns a new version of this CoList with `item` prepended before the item currently at index `before`.
459
+ * Prepends `item` before the item currently at index `before`.
452
460
  *
453
461
  * If `privacy` is `"private"` **(default)**, `item` is encrypted in the transaction, only readable by other members of the group this `CoList` belongs to. Not even sync servers can see the content in plaintext.
454
462
  *
@@ -460,7 +468,7 @@ export class CoList<
460
468
  item: Item,
461
469
  before?: number,
462
470
  privacy: "private" | "trusting" = "private"
463
- ): this {
471
+ ) {
464
472
  const entries = this.entries();
465
473
  before = before === undefined ? 0 : before;
466
474
  let opIDAfter;
@@ -491,10 +499,16 @@ export class CoList<
491
499
  privacy
492
500
  );
493
501
 
494
- return new CoList(this.core) as this;
502
+ const listAfter = new RawCoList(this.core) as this;
503
+
504
+ this.afterStart = listAfter.afterStart;
505
+ this.beforeEnd = listAfter.beforeEnd;
506
+ this.insertions = listAfter.insertions;
507
+ this.deletionsByInsertion = listAfter.deletionsByInsertion;
508
+ this._cachedEntries = undefined;
495
509
  }
496
510
 
497
- /** Returns a new version of this CoList with the item at index `at` deleted from the list.
511
+ /** Deletes the item at index `at`.
498
512
  *
499
513
  * If `privacy` is `"private"` **(default)**, the fact of this deletion is encrypted in the transaction, only readable by other members of the group this `CoList` belongs to. Not even sync servers can see the content in plaintext.
500
514
  *
@@ -502,7 +516,7 @@ export class CoList<
502
516
  *
503
517
  * @category 2. Editing
504
518
  **/
505
- delete(at: number, privacy: "private" | "trusting" = "private"): this {
519
+ delete(at: number, privacy: "private" | "trusting" = "private") {
506
520
  const entries = this.entries();
507
521
  const entry = entries[at];
508
522
  if (!entry) {
@@ -518,48 +532,8 @@ export class CoList<
518
532
  privacy
519
533
  );
520
534
 
521
- return new CoList(this.core) as this;
522
- }
523
-
524
- /** @category 2. Editing */
525
- mutate(mutator: (mutable: MutableCoList<Item, Meta>) => void): this {
526
- const mutable = new MutableCoList<Item, Meta>(this.core);
527
- mutator(mutable);
528
- return new CoList(this.core) as this;
529
- }
530
-
531
- /** @deprecated Use `mutate` instead. */
532
- edit(mutator: (mutable: MutableCoList<Item, Meta>) => void): this {
533
- return this.mutate(mutator);
534
- }
535
- }
535
+ const listAfter = new RawCoList(this.core) as this;
536
536
 
537
- export class MutableCoList<
538
- Item extends JsonValue = JsonValue,
539
- Meta extends JsonObject | null = JsonObject | null
540
- >
541
- extends CoListView<Item, Meta>
542
- implements CoValue
543
- {
544
- /** Appends `item` after the item currently at index `after`.
545
- *
546
- * If `privacy` is `"private"` **(default)**, `item` is encrypted in the transaction, only readable by other members of the group this `CoList` belongs to. Not even sync servers can see the content in plaintext.
547
- *
548
- * If `privacy` is `"trusting"`, `item` is stored in plaintext in the transaction, visible to everyone who gets a hold of it, including sync servers.
549
- *
550
- * @category 2. Mutating
551
- **/
552
- append(
553
- item: Item,
554
- after?: number,
555
- privacy: "private" | "trusting" = "private"
556
- ): void {
557
- const listAfter = CoList.prototype.append.call(
558
- this,
559
- item,
560
- after,
561
- privacy
562
- ) as CoList<Item, Meta>;
563
537
  this.afterStart = listAfter.afterStart;
564
538
  this.beforeEnd = listAfter.beforeEnd;
565
539
  this.insertions = listAfter.insertions;
@@ -567,46 +541,33 @@ export class MutableCoList<
567
541
  this._cachedEntries = undefined;
568
542
  }
569
543
 
570
- /** Prepends `item` before the item currently at index `before`.
571
- *
572
- * If `privacy` is `"private"` **(default)**, `item` is encrypted in the transaction, only readable by other members of the group this `CoList` belongs to. Not even sync servers can see the content in plaintext.
573
- *
574
- * If `privacy` is `"trusting"`, `item` is stored in plaintext in the transaction, visible to everyone who gets a hold of it, including sync servers.
575
- *
576
- * * @category 2. Mutating
577
- **/
578
- prepend(
579
- item: Item,
580
- before?: number,
544
+ replace(
545
+ at: number,
546
+ newItem: Item,
581
547
  privacy: "private" | "trusting" = "private"
582
- ): void {
583
- const listAfter = CoList.prototype.prepend.call(
584
- this,
585
- item,
586
- before,
587
- privacy
588
- ) as CoList<Item, Meta>;
589
- this.afterStart = listAfter.afterStart;
590
- this.beforeEnd = listAfter.beforeEnd;
591
- this.insertions = listAfter.insertions;
592
- this.deletionsByInsertion = listAfter.deletionsByInsertion;
593
- this._cachedEntries = undefined;
594
- }
548
+ ) {
549
+ const entries = this.entries();
550
+ const entry = entries[at];
551
+ if (!entry) {
552
+ throw new Error("Invalid index " + at);
553
+ }
595
554
 
596
- /** Deletes the item at index `at` from the list.
597
- *
598
- * If `privacy` is `"private"` **(default)**, the fact of this deletion is encrypted in the transaction, only readable by other members of the group this `CoList` belongs to. Not even sync servers can see the content in plaintext.
599
- *
600
- * If `privacy` is `"trusting"`, the fact of this deletion is stored in plaintext in the transaction, visible to everyone who gets a hold of it, including sync servers.
601
- *
602
- * * @category 2. Mutating
603
- **/
604
- delete(at: number, privacy: "private" | "trusting" = "private"): void {
605
- const listAfter = CoList.prototype.delete.call(
606
- this,
607
- at,
555
+ this.core.makeTransaction(
556
+ [
557
+ {
558
+ op: "app",
559
+ value: isCoValue(newItem) ? newItem.id : newItem,
560
+ after: entry.opID,
561
+ },
562
+ {
563
+ op: "del",
564
+ insertion: entry.opID,
565
+ },
566
+ ],
608
567
  privacy
609
- ) as CoList<Item, Meta>;
568
+ );
569
+ const listAfter = new RawCoList(this.core) as this;
570
+
610
571
  this.afterStart = listAfter.afterStart;
611
572
  this.beforeEnd = listAfter.beforeEnd;
612
573
  this.insertions = listAfter.insertions;
@@ -1,11 +1,11 @@
1
1
  import { JsonObject, JsonValue } from "../jsonValue.js";
2
2
  import { AgentID, TransactionID } from "../ids.js";
3
- import { CoID, CoValue } from "../coValue.js";
3
+ import { CoID, RawCoValue } from "../coValue.js";
4
4
  import { isCoValue } from "../typeUtils/isCoValue.js";
5
5
  import { CoValueCore } from "../coValueCore.js";
6
6
  import { accountOrAgentIDfromSessionID } from "../typeUtils/accountOrAgentIDfromSessionID.js";
7
7
  import { AccountID } from "./account.js";
8
- import type { Group } from "./group.js";
8
+ import type { RawGroup } from "./group.js";
9
9
 
10
10
  type MapOp<K extends string, V extends JsonValue | undefined> = {
11
11
  txID: TransactionID;
@@ -25,12 +25,12 @@ export type MapOpPayload<K extends string, V extends JsonValue | undefined> =
25
25
  key: K;
26
26
  };
27
27
 
28
- export class CoMapView<
28
+ export class RawCoMapView<
29
29
  Shape extends { [key: string]: JsonValue | undefined } = {
30
30
  [key: string]: JsonValue | undefined;
31
31
  },
32
- Meta extends JsonObject | null = JsonObject | null
33
- > implements CoValue
32
+ Meta extends JsonObject | null = JsonObject | null,
33
+ > implements RawCoValue
34
34
  {
35
35
  /** @category 6. Meta */
36
36
  id: CoID<this>;
@@ -88,7 +88,7 @@ export class CoMapView<
88
88
  }
89
89
 
90
90
  /** @category 6. Meta */
91
- get group(): Group {
91
+ get group(): RawGroup {
92
92
  return this.core.getGroup();
93
93
  }
94
94
 
@@ -250,16 +250,16 @@ export class CoMapView<
250
250
  }
251
251
 
252
252
  /** A collaborative map with precise shape `Shape` and optional static metadata `Meta` */
253
- export class CoMap<
253
+ export class RawCoMap<
254
254
  Shape extends { [key: string]: JsonValue | undefined } = {
255
255
  [key: string]: JsonValue | undefined;
256
256
  },
257
- Meta extends JsonObject | null = JsonObject | null
257
+ Meta extends JsonObject | null = JsonObject | null,
258
258
  >
259
- extends CoMapView<Shape, Meta>
260
- implements CoValue
259
+ extends RawCoMapView<Shape, Meta>
260
+ implements RawCoValue
261
261
  {
262
- /** Returns a new version of this CoMap with a new value for the given key.
262
+ /** Set a new value for the given key.
263
263
  *
264
264
  * If `privacy` is `"private"` **(default)**, both `key` and `value` are encrypted in the transaction, only readable by other members of the group this `CoMap` belongs to. Not even sync servers can see the content in plaintext.
265
265
  *
@@ -270,64 +270,25 @@ export class CoMap<
270
270
  set<K extends keyof Shape & string>(
271
271
  key: K,
272
272
  value: Shape[K],
273
- privacy?: "private" | "trusting"
274
- ): this;
275
- set(
276
- kv: {
277
- [K in keyof Shape & string]?: Shape[K];
278
- },
279
- privacy?: "private" | "trusting"
280
- ): this;
281
- set<K extends keyof Shape & string>(
282
- ...args:
283
- | [
284
- {
285
- [K in keyof Shape & string]?: Shape[K];
286
- },
287
- ("private" | "trusting")?
288
- ]
289
- | [K, Shape[K], ("private" | "trusting")?]
290
- ): this {
291
- if (typeof args[0] === "string") {
292
- const [key, value, privacy = "private"] = args;
293
- this.core.makeTransaction(
294
- [
295
- {
296
- op: "set",
297
- key,
298
- value: isCoValue(value) ? value.id : value,
299
- },
300
- ],
301
- privacy
302
- );
303
- } else {
304
- const [kv, privacy = "private"] = args as [
273
+ privacy: "private" | "trusting" = "private"
274
+ ): void {
275
+ this.core.makeTransaction(
276
+ [
305
277
  {
306
- [K in keyof Shape & string]: Shape[K] extends CoValue
307
- ? Shape[K] | CoID<Shape[K]>
308
- : Shape[K];
278
+ op: "set",
279
+ key,
280
+ value: isCoValue(value) ? value.id : value,
309
281
  },
310
- "private" | "trusting" | undefined
311
- ];
312
-
313
- for (const [key, value] of Object.entries(kv)) {
314
- this.core.makeTransaction(
315
- [
316
- {
317
- op: "set",
318
- key,
319
- value: isCoValue(value) ? value.id : value,
320
- },
321
- ],
322
- privacy
323
- );
324
- }
325
- }
282
+ ],
283
+ privacy
284
+ );
285
+
286
+ const after = new RawCoMap(this.core) as this;
326
287
 
327
- return new CoMap(this.core) as this;
288
+ this.ops = after.ops;
328
289
  }
329
290
 
330
- /** Returns a new version of this CoMap with the given key deleted (setting it to undefined).
291
+ /** Delete the given key (setting it to undefined).
331
292
  *
332
293
  * If `privacy` is `"private"` **(default)**, `key` is encrypted in the transaction, only readable by other members of the group this `CoMap` belongs to. Not even sync servers can see the content in plaintext.
333
294
  *
@@ -338,7 +299,7 @@ export class CoMap<
338
299
  delete(
339
300
  key: keyof Shape & string,
340
301
  privacy: "private" | "trusting" = "private"
341
- ): this {
302
+ ) {
342
303
  this.core.makeTransaction(
343
304
  [
344
305
  {
@@ -349,71 +310,8 @@ export class CoMap<
349
310
  privacy
350
311
  );
351
312
 
352
- return new CoMap(this.core) as this;
353
- }
313
+ const after = new RawCoMap(this.core) as this;
354
314
 
355
- /** @category 2. Editing */
356
- mutate(mutator: (mutable: MutableCoMap<Shape, Meta>) => void): this {
357
- const mutable = new MutableCoMap<Shape, Meta>(this.core);
358
- mutator(mutable);
359
- return new (this.constructor as new (core: CoValueCore) => this)(
360
- this.core
361
- );
362
- }
363
-
364
- /** @deprecated Use `mutate` instead. */
365
- edit(mutator: (mutable: MutableCoMap<Shape, Meta>) => void): this {
366
- return this.mutate(mutator);
367
- }
368
- }
369
-
370
- export class MutableCoMap<
371
- Shape extends { [key: string]: JsonValue | undefined } = {
372
- [key: string]: JsonValue | undefined;
373
- },
374
- Meta extends JsonObject | null = JsonObject | null
375
- >
376
- extends CoMapView<Shape, Meta>
377
- implements CoValue
378
- {
379
- /** Sets a new value for the given key.
380
- *
381
- * If `privacy` is `"private"` **(default)**, both `key` and `value` are encrypted in the transaction, only readable by other members of the group this `CoMap` belongs to. Not even sync servers can see the content in plaintext.
382
- *
383
- * If `privacy` is `"trusting"`, both `key` and `value` are stored in plaintext in the transaction, visible to everyone who gets a hold of it, including sync servers.
384
- *
385
- * @category 2. Mutation
386
- */
387
- set<K extends keyof Shape & string>(
388
- key: K,
389
- value: Shape[K],
390
- privacy: "private" | "trusting" = "private"
391
- ): void {
392
- // eslint-disable-next-line @typescript-eslint/ban-types
393
- const after = (CoMap.prototype.set as Function).call(
394
- this,
395
- key,
396
- value,
397
- privacy
398
- ) as CoMap<Shape, Meta>;
399
- this.ops = after.ops;
400
- }
401
-
402
- /** Deletes the value for the given key (setting it to undefined).
403
- *
404
- * If `privacy` is `"private"` **(default)**, `key` is encrypted in the transaction, only readable by other members of the group this `CoMap` belongs to. Not even sync servers can see the content in plaintext.
405
- *
406
- * If `privacy` is `"trusting"`, `key` is stored in plaintext in the transaction, visible to everyone who gets a hold of it, including sync servers.
407
- * @category 2. Mutation
408
- */
409
- delete(
410
- key: keyof Shape & string,
411
- privacy: "private" | "trusting" = "private"
412
- ): void {
413
- const after = CoMap.prototype.delete.call(this, key, privacy) as CoMap<
414
- Shape,
415
- Meta
416
- >;
417
315
  this.ops = after.ops;
418
316
  }
419
317
  }