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.
@@ -1,5 +1,5 @@
1
1
 
2
- > jazz-tools@0.13.19 build /home/runner/_work/jazz/jazz/packages/jazz-tools
2
+ > jazz-tools@0.13.21 build /home/runner/_work/jazz/jazz/packages/jazz-tools
3
3
  > tsup && pnpm types
4
4
 
5
5
  CLI Building entry: {"index":"src/index.ts","testing":"src/testing.ts"}
@@ -11,12 +11,12 @@
11
11
  ESM Build start
12
12
  ESM dist/index.js 1.48 KB
13
13
  ESM dist/testing.js 6.27 KB
14
- ESM dist/chunk-4HBHY4I7.js 121.39 KB
14
+ ESM dist/chunk-S4BCSDTJ.js 122.84 KB
15
15
  ESM dist/index.js.map 258.00 B
16
16
  ESM dist/testing.js.map 12.38 KB
17
- ESM dist/chunk-4HBHY4I7.js.map 279.08 KB
18
- ESM ⚡️ Build success in 39ms
17
+ ESM dist/chunk-S4BCSDTJ.js.map 281.38 KB
18
+ ESM ⚡️ Build success in 40ms
19
19
 
20
- > jazz-tools@0.13.19 types /home/runner/_work/jazz/jazz/packages/jazz-tools
20
+ > jazz-tools@0.13.21 types /home/runner/_work/jazz/jazz/packages/jazz-tools
21
21
  > tsc --outDir dist
22
22
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # jazz-tools
2
2
 
3
+ ## 0.13.21
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [e14e61f]
8
+ - cojson@0.13.21
9
+
10
+ ## 0.13.20
11
+
12
+ ### Patch Changes
13
+
14
+ - 439f0fe: Adds creation owner and consume-as-string shorthands to `CoPlainText`
15
+ - Updated dependencies [adfc9a6]
16
+ - Updated dependencies [1389207]
17
+ - Updated dependencies [d6e143e]
18
+ - Updated dependencies [3e6229d]
19
+ - cojson@0.13.20
20
+
3
21
  ## 0.13.19
4
22
 
5
23
  ### Patch Changes
@@ -3373,22 +3373,51 @@ var CoPlainText = class extends String {
3373
3373
  }
3374
3374
  return new AnonymousJazzAgent(this._raw.core.node);
3375
3375
  }
3376
+ /** @internal */
3376
3377
  constructor(options) {
3377
- super("fromRaw" in options ? options.fromRaw.toString() : options.text);
3378
- let raw;
3378
+ if (!options) {
3379
+ super("");
3380
+ return;
3381
+ }
3379
3382
  if ("fromRaw" in options) {
3380
- raw = options.fromRaw;
3381
- } else {
3382
- raw = options.owner._raw.createPlainText(options.text);
3383
+ super(options.fromRaw.toString());
3384
+ const raw = options.fromRaw;
3385
+ Object.defineProperties(this, {
3386
+ id: { value: raw.id, enumerable: false },
3387
+ _type: { value: "CoPlainText", enumerable: false },
3388
+ _raw: { value: raw, enumerable: false }
3389
+ });
3390
+ return;
3383
3391
  }
3384
- Object.defineProperties(this, {
3385
- id: { value: raw.id, enumerable: false },
3386
- _type: { value: "CoPlainText", enumerable: false },
3387
- _raw: { value: raw, enumerable: false }
3388
- });
3392
+ if ("text" in options && "owner" in options) {
3393
+ super(options.text);
3394
+ const raw = options.owner._raw.createPlainText(options.text);
3395
+ Object.defineProperties(this, {
3396
+ id: { value: raw.id, enumerable: false },
3397
+ _type: { value: "CoPlainText", enumerable: false },
3398
+ _raw: { value: raw, enumerable: false }
3399
+ });
3400
+ return;
3401
+ }
3402
+ throw new Error("Invalid constructor arguments");
3389
3403
  }
3404
+ /**
3405
+ * Create a new `CoPlainText` with the given text and owner.
3406
+ *
3407
+ * The owner (a Group or Account) determines access rights to the CoPlainText.
3408
+ *
3409
+ * The CoPlainText will immediately be persisted and synced to connected peers.
3410
+ *
3411
+ * @example
3412
+ * ```ts
3413
+ * const text = CoPlainText.create("Hello, world!", { owner: me });
3414
+ * ```
3415
+ *
3416
+ * @category Creation
3417
+ */
3390
3418
  static create(text, options) {
3391
- return new this({ text, owner: options.owner });
3419
+ const { owner } = parseCoValueCreateOptions(options);
3420
+ return new this({ text, owner });
3392
3421
  }
3393
3422
  get length() {
3394
3423
  return this._raw.toString().length;
@@ -3469,6 +3498,22 @@ var CoPlainText = class extends String {
3469
3498
  subscribe(listener) {
3470
3499
  return subscribeToExistingCoValue(this, {}, listener);
3471
3500
  }
3501
+ /**
3502
+ * Allow CoPlainText to behave like a primitive string in most contexts (e.g.,
3503
+ * string concatenation, template literals, React rendering, etc.) by implementing
3504
+ * Symbol.toPrimitive. This eliminates the need to call .toString() explicitly.
3505
+ *
3506
+ * The 'hint' parameter indicates the preferred type of conversion:
3507
+ * - 'string': prefer string conversion
3508
+ * - 'number': prefer number conversion (not meaningful for text, so return NaN)
3509
+ * - 'default': usually treat as string
3510
+ */
3511
+ [Symbol.toPrimitive](hint) {
3512
+ if (hint === "number") {
3513
+ return Number(this._raw.toString());
3514
+ }
3515
+ return this._raw.toString();
3516
+ }
3472
3517
  };
3473
3518
 
3474
3519
  // src/coValues/coRichText.ts
@@ -4226,4 +4271,4 @@ export {
4226
4271
  consumeInviteLink
4227
4272
  };
4228
4273
  /* istanbul ignore file -- @preserve */
4229
- //# sourceMappingURL=chunk-4HBHY4I7.js.map
4274
+ //# sourceMappingURL=chunk-S4BCSDTJ.js.map