jazz-tools 0.13.19 → 0.13.21

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.
@@ -96,7 +96,7 @@ export declare class Account extends CoValueBase implements CoValue {
96
96
  */
97
97
  waitForSync(options?: {
98
98
  timeout?: number;
99
- }): Promise<unknown[]>;
99
+ }): Promise<void>;
100
100
  /**
101
101
  * Wait for all the available `CoValues` to be uploaded to the other peers.
102
102
  *
@@ -104,7 +104,7 @@ export declare class Account extends CoValueBase implements CoValue {
104
104
  */
105
105
  waitForAllCoValuesSync(options?: {
106
106
  timeout?: number;
107
- }): Promise<unknown[][]>;
107
+ }): Promise<void[]>;
108
108
  }
109
109
  export declare const AccountAndGroupProxyHandler: ProxyHandler<Account | Group>;
110
110
  /** @category Identity & Permissions */
@@ -211,7 +211,7 @@ export declare class CoFeed<Item = any> extends CoValueBase implements CoValue {
211
211
  */
212
212
  waitForSync(options?: {
213
213
  timeout?: number;
214
- }): Promise<unknown[]>;
214
+ }): Promise<void>;
215
215
  }
216
216
  /**
217
217
  * The proxy handler for `CoFeed` instances
@@ -362,6 +362,6 @@ export declare class FileStream extends CoValueBase implements CoValue {
362
362
  */
363
363
  waitForSync(options?: {
364
364
  timeout?: number;
365
- }): Promise<unknown[]>;
365
+ }): Promise<void>;
366
366
  }
367
367
  //# sourceMappingURL=coFeed.d.ts.map
@@ -238,6 +238,6 @@ export declare class CoList<Item = any> extends Array<Item> implements CoValue {
238
238
  */
239
239
  waitForSync(options?: {
240
240
  timeout?: number;
241
- }): Promise<unknown[]>;
241
+ }): Promise<void>;
242
242
  }
243
243
  //# sourceMappingURL=coList.d.ts.map
@@ -268,7 +268,7 @@ export declare class CoMap extends CoValueBase implements CoValue {
268
268
  */
269
269
  waitForSync(options?: {
270
270
  timeout?: number;
271
- }): Promise<unknown[]>;
271
+ }): Promise<void>;
272
272
  [inspect](): any;
273
273
  _instanceID: string;
274
274
  readonly _owner: Account | Group;
@@ -468,7 +468,7 @@ export declare class CoMap extends CoValueBase implements CoValue {
468
468
  */
469
469
  waitForSync(options?: {
470
470
  timeout?: number;
471
- }): Promise<unknown[]>;
471
+ }): Promise<void>;
472
472
  }
473
473
  export type CoKeys<Map extends object> = Exclude<keyof Map & string, keyof CoMap>;
474
474
  /**
@@ -10,15 +10,30 @@ export declare class CoPlainText extends String implements CoValue {
10
10
  _raw: RawCoPlainText;
11
11
  get _owner(): Account | Group;
12
12
  get _loadedAs(): Account | AnonymousJazzAgent;
13
+ /** @internal */
13
14
  constructor(options: {
14
15
  fromRaw: RawCoPlainText;
15
16
  } | {
16
17
  text: string;
17
18
  owner: Account | Group;
18
- });
19
- static create<T extends CoPlainText>(this: CoValueClass<T>, text: string, options: {
19
+ } | undefined);
20
+ /**
21
+ * Create a new `CoPlainText` with the given text and owner.
22
+ *
23
+ * The owner (a Group or Account) determines access rights to the CoPlainText.
24
+ *
25
+ * The CoPlainText will immediately be persisted and synced to connected peers.
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * const text = CoPlainText.create("Hello, world!", { owner: me });
30
+ * ```
31
+ *
32
+ * @category Creation
33
+ */
34
+ static create<T extends CoPlainText>(this: CoValueClass<T>, text: string, options?: {
20
35
  owner: Account | Group;
21
- }): T;
36
+ } | Account | Group): T;
22
37
  get length(): number;
23
38
  toString(): string;
24
39
  valueOf(): string;
@@ -74,5 +89,16 @@ export declare class CoPlainText extends String implements CoValue {
74
89
  * @category Subscription & Loading
75
90
  **/
76
91
  subscribe<T extends CoPlainText>(this: T, listener: (value: Resolved<T, true>, unsubscribe: () => void) => void): () => void;
92
+ /**
93
+ * Allow CoPlainText to behave like a primitive string in most contexts (e.g.,
94
+ * string concatenation, template literals, React rendering, etc.) by implementing
95
+ * Symbol.toPrimitive. This eliminates the need to call .toString() explicitly.
96
+ *
97
+ * The 'hint' parameter indicates the preferred type of conversion:
98
+ * - 'string': prefer string conversion
99
+ * - 'number': prefer number conversion (not meaningful for text, so return NaN)
100
+ * - 'default': usually treat as string
101
+ */
102
+ [Symbol.toPrimitive](hint: string): string | number;
77
103
  }
78
104
  //# sourceMappingURL=coPlainText.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"coPlainText.d.ts","sourceRoot":"","sources":["../../src/coValues/coPlainText.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,IAAI,EAET,KAAK,cAAc,EAEpB,MAAM,QAAQ,CAAC;AAEhB,OAAO,EACL,kBAAkB,EAClB,OAAO,EACP,YAAY,EACZ,EAAE,EACF,QAAQ,EACR,wBAAwB,EAEzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,OAAO,EAKR,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGnC,MAAM,MAAM,OAAO,GAAG,IAAI,CAAC;AAE3B,qBAAa,WAAY,SAAQ,MAAO,YAAW,OAAO;IAChD,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;IACb,KAAK,EAAE,aAAa,CAAC;IACrB,IAAI,EAAE,cAAc,CAAC;IAE7B,IAAI,MAAM,IAAI,OAAO,GAAG,KAAK,CAI5B;IAED,IAAI,SAAS,iCAUZ;gBAGC,OAAO,EACH;QAAE,OAAO,EAAE,cAAc,CAAA;KAAE,GAC3B;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CAAA;KAAE;IAmB9C,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,WAAW,EACjC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,EACrB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;QAAE,KAAK,EAAE,OAAO,GAAG,KAAK,CAAA;KAAE;IAKrC,IAAI,MAAM,WAET;IAED,QAAQ;IAIR,OAAO;IAIP,MAAM,IAAI,MAAM;IAIhB,CAAC,OAAO,CAAC;IAIT,YAAY,CAAC,GAA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known[]>;
71
+ }): Promise<void>;
72
72
  }
73
73
  export declare function isAccountID(id: RawAccountID | AgentID): id is RawAccountID;
74
74
  //# sourceMappingURL=group.d.ts.map
package/dist/index.js CHANGED
@@ -34,7 +34,7 @@ import {
34
34
  parseInviteLink,
35
35
  randomSessionProvider,
36
36
  subscribeToCoValue
37
- } from "./chunk-4HBHY4I7.js";
37
+ } from "./chunk-S4BCSDTJ.js";
38
38
 
39
39
  // src/index.ts
40
40
  import { MAX_RECOMMENDED_TX_SIZE, cojsonInternals } from "cojson";
package/dist/testing.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  createAnonymousJazzContext,
6
6
  createJazzContext,
7
7
  randomSessionProvider
8
- } from "./chunk-4HBHY4I7.js";
8
+ } from "./chunk-S4BCSDTJ.js";
9
9
 
10
10
  // src/testing.ts
11
11
  import { LocalNode } from "cojson";
package/package.json CHANGED
@@ -17,11 +17,11 @@
17
17
  },
18
18
  "type": "module",
19
19
  "license": "MIT",
20
- "version": "0.13.19",
20
+ "version": "0.13.21",
21
21
  "dependencies": {
22
22
  "@scure/bip39": "^1.3.0",
23
23
  "fast-myers-diff": "^3.2.0",
24
- "cojson": "0.13.18"
24
+ "cojson": "0.13.21"
25
25
  },
26
26
  "devDependencies": {
27
27
  "tsup": "8.3.5",
@@ -14,6 +14,7 @@ import {
14
14
  Resolved,
15
15
  SubscribeListenerOptions,
16
16
  SubscribeRestArgs,
17
+ parseCoValueCreateOptions,
17
18
  } from "../internal.js";
18
19
  import {
19
20
  inspect,
@@ -52,34 +53,64 @@ export class CoPlainText extends String implements CoValue {
52
53
  return new AnonymousJazzAgent(this._raw.core.node);
53
54
  }
54
55
 
56
+ /** @internal */
55
57
  constructor(
56
58
  options:
57
59
  | { fromRaw: RawCoPlainText }
58
- | { text: string; owner: Account | Group },
60
+ | { text: string; owner: Account | Group }
61
+ | undefined,
59
62
  ) {
60
- super("fromRaw" in options ? options.fromRaw.toString() : options.text);
61
-
62
- let raw;
63
+ if (!options) {
64
+ super(""); // Intialise as empty string
65
+ return;
66
+ }
63
67
 
64
68
  if ("fromRaw" in options) {
65
- raw = options.fromRaw;
66
- } else {
67
- raw = options.owner._raw.createPlainText(options.text);
69
+ super(options.fromRaw.toString());
70
+ const raw = options.fromRaw;
71
+ Object.defineProperties(this, {
72
+ id: { value: raw.id, enumerable: false },
73
+ _type: { value: "CoPlainText", enumerable: false },
74
+ _raw: { value: raw, enumerable: false },
75
+ });
76
+ return;
68
77
  }
69
78
 
70
- Object.defineProperties(this, {
71
- id: { value: raw.id, enumerable: false },
72
- _type: { value: "CoPlainText", enumerable: false },
73
- _raw: { value: raw, enumerable: false },
74
- });
79
+ if ("text" in options && "owner" in options) {
80
+ super(options.text);
81
+ const raw = options.owner._raw.createPlainText(options.text);
82
+ Object.defineProperties(this, {
83
+ id: { value: raw.id, enumerable: false },
84
+ _type: { value: "CoPlainText", enumerable: false },
85
+ _raw: { value: raw, enumerable: false },
86
+ });
87
+ return;
88
+ }
89
+
90
+ throw new Error("Invalid constructor arguments");
75
91
  }
76
92
 
93
+ /**
94
+ * Create a new `CoPlainText` with the given text and owner.
95
+ *
96
+ * The owner (a Group or Account) determines access rights to the CoPlainText.
97
+ *
98
+ * The CoPlainText will immediately be persisted and synced to connected peers.
99
+ *
100
+ * @example
101
+ * ```ts
102
+ * const text = CoPlainText.create("Hello, world!", { owner: me });
103
+ * ```
104
+ *
105
+ * @category Creation
106
+ */
77
107
  static create<T extends CoPlainText>(
78
108
  this: CoValueClass<T>,
79
109
  text: string,
80
- options: { owner: Account | Group },
110
+ options?: { owner: Account | Group } | Account | Group,
81
111
  ) {
82
- return new this({ text, owner: options.owner });
112
+ const { owner } = parseCoValueCreateOptions(options);
113
+ return new this({ text, owner });
83
114
  }
84
115
 
85
116
  get length() {
@@ -229,4 +260,23 @@ export class CoPlainText extends String implements CoValue {
229
260
  ): () => void {
230
261
  return subscribeToExistingCoValue(this, {}, listener);
231
262
  }
263
+
264
+ /**
265
+ * Allow CoPlainText to behave like a primitive string in most contexts (e.g.,
266
+ * string concatenation, template literals, React rendering, etc.) by implementing
267
+ * Symbol.toPrimitive. This eliminates the need to call .toString() explicitly.
268
+ *
269
+ * The 'hint' parameter indicates the preferred type of conversion:
270
+ * - 'string': prefer string conversion
271
+ * - 'number': prefer number conversion (not meaningful for text, so return NaN)
272
+ * - 'default': usually treat as string
273
+ */
274
+ [Symbol.toPrimitive](hint: string) {
275
+ if (hint === "number") {
276
+ // Not meaningful for text, but required for completeness
277
+ return Number(this._raw.toString());
278
+ }
279
+ // For 'string' and 'default', return the string representation
280
+ return this._raw.toString();
281
+ }
232
282
  }
@@ -25,6 +25,56 @@ describe("CoPlainText", () => {
25
25
  return { me, text };
26
26
  };
27
27
 
28
+ describe("Creation", () => {
29
+ test("should allow `create`", async () => {
30
+ const me = await Account.create({
31
+ creationProps: { name: "Hermes Puggington" },
32
+ crypto: Crypto,
33
+ });
34
+ const text = CoPlainText.create("hello world", me);
35
+ expect(text._owner.id).toBe(me.id);
36
+ });
37
+
38
+ test("should allow `new CoPlainText`", async () => {
39
+ const me = await Account.create({
40
+ creationProps: { name: "Hermes Puggington" },
41
+ crypto: Crypto,
42
+ });
43
+ const text = new CoPlainText({ text: "hello world", owner: me });
44
+ expect(text._owner.id).toBe(me.id);
45
+ });
46
+
47
+ test("should allow `create` from raw", async () => {
48
+ const me = await Account.create({
49
+ creationProps: { name: "Hermes Puggington" },
50
+ crypto: Crypto,
51
+ });
52
+ const text = CoPlainText.create("hello world", me);
53
+ const raw = text._raw;
54
+ const text2 = CoPlainText.fromRaw(raw);
55
+ expect(text2._owner.id).toBe(me.id);
56
+ });
57
+
58
+ test("should allow creation of new instance from raw", async () => {
59
+ const me = await Account.create({
60
+ creationProps: { name: "Hermes Puggington" },
61
+ crypto: Crypto,
62
+ });
63
+ const raw = me._raw.createPlainText("hello world");
64
+ const text = new CoPlainText({ fromRaw: raw });
65
+ expect(text._owner.id).toBe(me.id);
66
+ });
67
+
68
+ test("should allow owner shorthand", async () => {
69
+ const me = await Account.create({
70
+ creationProps: { name: "Hermes Puggington" },
71
+ crypto: Crypto,
72
+ });
73
+ const text = CoPlainText.create("hello world", me);
74
+ expect(text._owner.id).toBe(me.id);
75
+ });
76
+ });
77
+
28
78
  describe("Simple CoPlainText operations", async () => {
29
79
  const { me, text } = await initNodeAndText();
30
80
 
@@ -63,6 +113,26 @@ describe("CoPlainText", () => {
63
113
  expect(text.length).toBe(11);
64
114
  });
65
115
 
116
+ test("as string", () => {
117
+ const text = CoPlainText.create("hello world", { owner: me });
118
+ expect(`${text}`).toBe("hello world");
119
+ });
120
+
121
+ test("as number", () => {
122
+ const text = CoPlainText.create("hello world", { owner: me });
123
+ expect(Number(text)).toBe(NaN);
124
+ });
125
+
126
+ test("as number", () => {
127
+ const text = CoPlainText.create("123", { owner: me });
128
+ expect(Number(text)).toBe(123);
129
+ });
130
+
131
+ test("toJSON", () => {
132
+ const text = CoPlainText.create("hello world", { owner: me });
133
+ expect(text.toJSON()).toBe("hello world");
134
+ });
135
+
66
136
  test("toString", () => {
67
137
  const text = CoPlainText.create("hello world", { owner: me });
68
138
  expect(text.toString()).toBe("hello world");