jazz-tools 0.13.18 → 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 +17 -0
- package/dist/{chunk-ITSHLDQB.js → chunk-S4BCSDTJ.js} +74 -23
- package/dist/chunk-S4BCSDTJ.js.map +1 -0
- 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/subscribe/SubscriptionScope.d.ts +1 -0
- package/dist/subscribe/SubscriptionScope.d.ts.map +1 -1
- package/dist/testing.js +1 -1
- package/package.json +2 -2
- package/src/coValues/coPlainText.ts +64 -14
- package/src/subscribe/SubscriptionScope.ts +26 -13
- package/src/tests/coPlainText.test.ts +70 -0
- package/src/tests/subscribe.test.ts +257 -0
- package/dist/chunk-ITSHLDQB.js.map +0 -1
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,22 @@
|
|
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
|
+
|
14
|
+
## 0.13.19
|
15
|
+
|
16
|
+
### Patch Changes
|
17
|
+
|
18
|
+
- 80530a4: Improve error management for autoloaded values and fix autoloading on $each resolve
|
19
|
+
|
3
20
|
## 0.13.18
|
4
21
|
|
5
22
|
### Patch Changes
|
@@ -191,6 +191,7 @@ var SubscriptionScope = class _SubscriptionScope {
|
|
191
191
|
this.dirty = false;
|
192
192
|
this.idsSubscribed = /* @__PURE__ */ new Set();
|
193
193
|
this.autoloaded = /* @__PURE__ */ new Set();
|
194
|
+
this.autoloadedKeys = /* @__PURE__ */ new Set();
|
194
195
|
this.totalValidTransactions = 0;
|
195
196
|
this.silenceUpdates = false;
|
196
197
|
this.handleChildUpdate = (id, value, key) => {
|
@@ -289,7 +290,10 @@ var SubscriptionScope = class _SubscriptionScope {
|
|
289
290
|
if (this.childErrors.size === 0 && this.validationErrors.size === 0) {
|
290
291
|
return void 0;
|
291
292
|
}
|
292
|
-
for (const value of this.childErrors.
|
293
|
+
for (const [key, value] of this.childErrors.entries()) {
|
294
|
+
if (this.autoloaded.has(key)) {
|
295
|
+
continue;
|
296
|
+
}
|
293
297
|
errorType = value.type;
|
294
298
|
if (value.issues) {
|
295
299
|
issues.push(...value.issues);
|
@@ -301,7 +305,10 @@ var SubscriptionScope = class _SubscriptionScope {
|
|
301
305
|
issues.push(...value.issues);
|
302
306
|
}
|
303
307
|
}
|
304
|
-
|
308
|
+
if (issues.length) {
|
309
|
+
return new JazzError(this.id, errorType, issues);
|
310
|
+
}
|
311
|
+
return void 0;
|
305
312
|
}
|
306
313
|
shouldSendUpdates() {
|
307
314
|
if (this.value.type === "unloaded") return false;
|
@@ -345,6 +352,7 @@ var SubscriptionScope = class _SubscriptionScope {
|
|
345
352
|
return;
|
346
353
|
}
|
347
354
|
this.resolve[key] = true;
|
355
|
+
this.autoloadedKeys.add(key);
|
348
356
|
if (this.value.type !== "loaded") {
|
349
357
|
return;
|
350
358
|
}
|
@@ -352,16 +360,10 @@ var SubscriptionScope = class _SubscriptionScope {
|
|
352
360
|
this.silenceUpdates = true;
|
353
361
|
if (value._type === "CoMap" || value._type === "Account") {
|
354
362
|
const map = value;
|
355
|
-
|
356
|
-
if (id) {
|
357
|
-
this.autoloaded.add(id);
|
358
|
-
}
|
363
|
+
this.loadCoMapKey(map, key, true);
|
359
364
|
} else if (value._type === "CoList") {
|
360
365
|
const list = value;
|
361
|
-
|
362
|
-
if (id) {
|
363
|
-
this.autoloaded.add(id);
|
364
|
-
}
|
366
|
+
this.loadCoListKey(list, key, true);
|
365
367
|
}
|
366
368
|
this.silenceUpdates = false;
|
367
369
|
}
|
@@ -537,10 +539,14 @@ var SubscriptionScope = class _SubscriptionScope {
|
|
537
539
|
if (this.childValues.has(id)) {
|
538
540
|
return;
|
539
541
|
}
|
542
|
+
if (key && this.autoloadedKeys.has(key)) {
|
543
|
+
this.autoloaded.add(id);
|
544
|
+
}
|
545
|
+
const resolve = typeof query === "object" && query !== null ? { ...query } : query;
|
540
546
|
this.childValues.set(id, { type: "unloaded", id });
|
541
547
|
const child = new _SubscriptionScope(
|
542
548
|
this.node,
|
543
|
-
|
549
|
+
resolve,
|
544
550
|
id,
|
545
551
|
descriptor
|
546
552
|
);
|
@@ -3367,22 +3373,51 @@ var CoPlainText = class extends String {
|
|
3367
3373
|
}
|
3368
3374
|
return new AnonymousJazzAgent(this._raw.core.node);
|
3369
3375
|
}
|
3376
|
+
/** @internal */
|
3370
3377
|
constructor(options) {
|
3371
|
-
|
3372
|
-
|
3378
|
+
if (!options) {
|
3379
|
+
super("");
|
3380
|
+
return;
|
3381
|
+
}
|
3373
3382
|
if ("fromRaw" in options) {
|
3374
|
-
|
3375
|
-
|
3376
|
-
|
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;
|
3377
3391
|
}
|
3378
|
-
|
3379
|
-
|
3380
|
-
|
3381
|
-
|
3382
|
-
|
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");
|
3383
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
|
+
*/
|
3384
3418
|
static create(text, options) {
|
3385
|
-
|
3419
|
+
const { owner } = parseCoValueCreateOptions(options);
|
3420
|
+
return new this({ text, owner });
|
3386
3421
|
}
|
3387
3422
|
get length() {
|
3388
3423
|
return this._raw.toString().length;
|
@@ -3463,6 +3498,22 @@ var CoPlainText = class extends String {
|
|
3463
3498
|
subscribe(listener) {
|
3464
3499
|
return subscribeToExistingCoValue(this, {}, listener);
|
3465
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
|
+
}
|
3466
3517
|
};
|
3467
3518
|
|
3468
3519
|
// src/coValues/coRichText.ts
|
@@ -4220,4 +4271,4 @@ export {
|
|
4220
4271
|
consumeInviteLink
|
4221
4272
|
};
|
4222
4273
|
/* istanbul ignore file -- @preserve */
|
4223
|
-
//# sourceMappingURL=chunk-
|
4274
|
+
//# sourceMappingURL=chunk-S4BCSDTJ.js.map
|