jazz-tools 0.13.19 → 0.13.20
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.
- package/.turbo/turbo-build.log +5 -5
- package/CHANGELOG.md +11 -0
- package/dist/{chunk-4HBHY4I7.js → chunk-S4BCSDTJ.js} +57 -12
- package/dist/{chunk-4HBHY4I7.js.map → chunk-S4BCSDTJ.js.map} +1 -1
- package/dist/coValues/account.d.ts +2 -2
- package/dist/coValues/coFeed.d.ts +2 -2
- package/dist/coValues/coList.d.ts +1 -1
- package/dist/coValues/coMap.d.ts +2 -2
- package/dist/coValues/coPlainText.d.ts +29 -3
- package/dist/coValues/coPlainText.d.ts.map +1 -1
- package/dist/coValues/group.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/testing.js +1 -1
- package/package.json +2 -2
- package/src/coValues/coPlainText.ts +64 -14
- package/src/tests/coPlainText.test.ts +70 -0
package/.turbo/turbo-build.log
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
> jazz-tools@0.13.
|
2
|
+
> jazz-tools@0.13.20 build /home/runner/_work/jazz/jazz/packages/jazz-tools
|
3
3
|
> tsup && pnpm types
|
4
4
|
|
5
5
|
[34mCLI[39m Building entry: {"index":"src/index.ts","testing":"src/testing.ts"}
|
@@ -11,12 +11,12 @@
|
|
11
11
|
[34mESM[39m Build start
|
12
12
|
[32mESM[39m [1mdist/index.js [22m[32m1.48 KB[39m
|
13
13
|
[32mESM[39m [1mdist/testing.js [22m[32m6.27 KB[39m
|
14
|
-
[32mESM[39m [1mdist/chunk-
|
14
|
+
[32mESM[39m [1mdist/chunk-S4BCSDTJ.js [22m[32m122.84 KB[39m
|
15
15
|
[32mESM[39m [1mdist/index.js.map [22m[32m258.00 B[39m
|
16
16
|
[32mESM[39m [1mdist/testing.js.map [22m[32m12.38 KB[39m
|
17
|
-
[32mESM[39m [1mdist/chunk-
|
18
|
-
[32mESM[39m ⚡️ Build success in
|
17
|
+
[32mESM[39m [1mdist/chunk-S4BCSDTJ.js.map [22m[32m281.38 KB[39m
|
18
|
+
[32mESM[39m ⚡️ Build success in 43ms
|
19
19
|
|
20
|
-
> jazz-tools@0.13.
|
20
|
+
> jazz-tools@0.13.20 types /home/runner/_work/jazz/jazz/packages/jazz-tools
|
21
21
|
> tsc --outDir dist
|
22
22
|
|
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# jazz-tools
|
2
2
|
|
3
|
+
## 0.13.20
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 439f0fe: Adds creation owner and consume-as-string shorthands to `CoPlainText`
|
8
|
+
- Updated dependencies [adfc9a6]
|
9
|
+
- Updated dependencies [1389207]
|
10
|
+
- Updated dependencies [d6e143e]
|
11
|
+
- Updated dependencies [3e6229d]
|
12
|
+
- cojson@0.13.20
|
13
|
+
|
3
14
|
## 0.13.19
|
4
15
|
|
5
16
|
### 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
|
-
|
3378
|
-
|
3378
|
+
if (!options) {
|
3379
|
+
super("");
|
3380
|
+
return;
|
3381
|
+
}
|
3379
3382
|
if ("fromRaw" in options) {
|
3380
|
-
|
3381
|
-
|
3382
|
-
|
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
|
-
|
3385
|
-
|
3386
|
-
|
3387
|
-
|
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
|
-
|
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-
|
4274
|
+
//# sourceMappingURL=chunk-S4BCSDTJ.js.map
|