jazz-tools 0.11.6 → 0.11.7
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 +10 -0
- package/dist/{chunk-2LO7CLFD.js → chunk-HH3Z4JSB.js} +53 -35
- package/dist/chunk-HH3Z4JSB.js.map +1 -0
- package/dist/coValues/interfaces.d.ts.map +1 -1
- package/dist/exports.d.ts +1 -1
- package/dist/exports.d.ts.map +1 -1
- package/dist/implementation/subscriptionScope.d.ts +2 -1
- package/dist/implementation/subscriptionScope.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/testing.js +1 -1
- package/package.json +2 -2
- package/src/coValues/group.ts +1 -1
- package/src/coValues/interfaces.ts +12 -1
- package/src/exports.ts +1 -0
- package/src/implementation/subscriptionScope.ts +59 -32
- package/src/tests/subscribe.test.ts +52 -2
- package/dist/chunk-2LO7CLFD.js.map +0 -1
package/.turbo/turbo-build.log
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
> jazz-tools@0.11.
|
2
|
+
> jazz-tools@0.11.7 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.50 KB[39m
|
13
13
|
[32mESM[39m [1mdist/testing.js [22m[32m6.18 KB[39m
|
14
|
-
[32mESM[39m [1mdist/chunk-
|
14
|
+
[32mESM[39m [1mdist/chunk-HH3Z4JSB.js [22m[32m121.60 KB[39m
|
15
15
|
[32mESM[39m [1mdist/index.js.map [22m[32m259.00 B[39m
|
16
16
|
[32mESM[39m [1mdist/testing.js.map [22m[32m12.24 KB[39m
|
17
|
-
[32mESM[39m [1mdist/chunk-
|
18
|
-
[32mESM[39m ⚡️ Build success in
|
17
|
+
[32mESM[39m [1mdist/chunk-HH3Z4JSB.js.map [22m[32m289.35 KB[39m
|
18
|
+
[32mESM[39m ⚡️ Build success in 38ms
|
19
19
|
|
20
|
-
> jazz-tools@0.11.
|
20
|
+
> jazz-tools@0.11.7 types /home/runner/_work/jazz/jazz/packages/jazz-tools
|
21
21
|
> tsc --outDir dist
|
22
22
|
|
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# jazz-tools
|
2
2
|
|
3
|
+
## 0.11.7
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- a140f55: Bugfix: Trigger a single update when loading a locally available list of items
|
8
|
+
- 2b0d1b0: Export CoFeedEntry type
|
9
|
+
- Updated dependencies [2b94bc8]
|
10
|
+
- Updated dependencies [2957362]
|
11
|
+
- cojson@0.11.7
|
12
|
+
|
3
13
|
## 0.11.6
|
4
14
|
|
5
15
|
### Patch Changes
|
@@ -343,7 +343,6 @@ function instantiateRefEncoded(schema, raw) {
|
|
343
343
|
|
344
344
|
// src/implementation/subscriptionScope.ts
|
345
345
|
var subscriptionsScopes = /* @__PURE__ */ new WeakMap();
|
346
|
-
var TRACE_INVALIDATIONS = false;
|
347
346
|
var SubscriptionScope = class {
|
348
347
|
constructor(root, rootSchema, onUpdate) {
|
349
348
|
this.scopeID = `scope-${Math.random().toString(36).slice(2)}`;
|
@@ -351,6 +350,7 @@ var SubscriptionScope = class {
|
|
351
350
|
this.scheduledUpdate = false;
|
352
351
|
this.cachedValues = {};
|
353
352
|
this.parents = {};
|
353
|
+
this.syncResolution = false;
|
354
354
|
this.unsubscribeAll = () => {
|
355
355
|
for (const entry of this.entries.values()) {
|
356
356
|
if (entry.state === "loaded") {
|
@@ -397,38 +397,52 @@ var SubscriptionScope = class {
|
|
397
397
|
};
|
398
398
|
this.entries.set(accessedOrSetId, loadingEntry);
|
399
399
|
const node = this.subscriber._type === "Account" ? this.subscriber._raw.core.node : this.subscriber.node;
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
this.
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
400
|
+
loadCoValue(
|
401
|
+
node,
|
402
|
+
accessedOrSetId,
|
403
|
+
(core) => {
|
404
|
+
if (loadingEntry.state === "loading" && loadingEntry.immediatelyUnsub) {
|
405
|
+
return;
|
406
|
+
}
|
407
|
+
if (core !== "unavailable") {
|
408
|
+
const entry = {
|
409
|
+
state: "loaded",
|
410
|
+
rawUnsub: () => {
|
411
|
+
}
|
412
|
+
// placeholder
|
413
|
+
};
|
414
|
+
this.entries.set(accessedOrSetId, entry);
|
415
|
+
const rawUnsub = core.subscribe((rawUpdate) => {
|
416
|
+
if (!rawUpdate) return;
|
417
|
+
this.invalidate(accessedOrSetId);
|
418
|
+
this.scheduleUpdate();
|
419
|
+
});
|
420
|
+
entry.rawUnsub = rawUnsub;
|
421
|
+
}
|
422
|
+
},
|
423
|
+
this.syncResolution
|
424
|
+
);
|
420
425
|
}
|
421
426
|
}
|
422
|
-
invalidate(id,
|
427
|
+
invalidate(id, seen = /* @__PURE__ */ new Set()) {
|
423
428
|
if (seen.has(id)) return;
|
424
|
-
TRACE_INVALIDATIONS && console.log("invalidating", fromChild, "->", id, this.cachedValues[id]);
|
425
429
|
delete this.cachedValues[id];
|
426
430
|
seen.add(id);
|
427
431
|
for (const parent of this.parents[id] || []) {
|
428
|
-
this.invalidate(parent,
|
432
|
+
this.invalidate(parent, seen);
|
429
433
|
}
|
430
434
|
}
|
431
435
|
};
|
436
|
+
function loadCoValue(node, id, callback, syncResolution) {
|
437
|
+
const entry = node.coValuesStore.get(id);
|
438
|
+
if (entry.state.type === "available" && syncResolution) {
|
439
|
+
callback(entry.state.coValue);
|
440
|
+
} else {
|
441
|
+
void node.loadCoValueCore(id).then((core) => {
|
442
|
+
callback(core);
|
443
|
+
});
|
444
|
+
}
|
445
|
+
}
|
432
446
|
|
433
447
|
// src/implementation/createContext.ts
|
434
448
|
import {
|
@@ -741,11 +755,11 @@ function loadCoValueWithoutMe(cls, id, asOrDepth, depth) {
|
|
741
755
|
"Depth is required when loading a CoValue as an Account or AnonymousJazzAgent"
|
742
756
|
);
|
743
757
|
}
|
744
|
-
return
|
758
|
+
return loadCoValue2(cls, id, asOrDepth, depth);
|
745
759
|
}
|
746
|
-
return
|
760
|
+
return loadCoValue2(cls, id, activeAccountContext.get(), asOrDepth);
|
747
761
|
}
|
748
|
-
function
|
762
|
+
function loadCoValue2(cls, id, as, depth) {
|
749
763
|
return new Promise((resolve) => {
|
750
764
|
subscribeToCoValue(
|
751
765
|
cls,
|
@@ -763,7 +777,7 @@ function loadCoValue(cls, id, as, depth) {
|
|
763
777
|
});
|
764
778
|
}
|
765
779
|
async function ensureCoValueLoaded(existing, depth) {
|
766
|
-
const response = await
|
780
|
+
const response = await loadCoValue2(
|
767
781
|
existing.constructor,
|
768
782
|
existing.id,
|
769
783
|
existing._loadedAs,
|
@@ -812,7 +826,11 @@ function subscribeToCoValue(cls, id, as, depth, listener, onUnavailable, syncRes
|
|
812
826
|
value,
|
813
827
|
cls,
|
814
828
|
(update, subscription2) => {
|
815
|
-
if (
|
829
|
+
if (subscription2.syncResolution) return false;
|
830
|
+
subscription2.syncResolution = true;
|
831
|
+
const isLoaded = fulfillsDepth(depth, update);
|
832
|
+
subscription2.syncResolution = false;
|
833
|
+
if (isLoaded) {
|
816
834
|
listener(
|
817
835
|
update,
|
818
836
|
subscription2.unsubscribeAll
|
@@ -997,7 +1015,7 @@ var Inbox = class _Inbox {
|
|
997
1015
|
new Error("Unable to load inbox message " + id)
|
998
1016
|
);
|
999
1017
|
}
|
1000
|
-
return
|
1018
|
+
return loadCoValue2(
|
1001
1019
|
Schema,
|
1002
1020
|
message.get("payload"),
|
1003
1021
|
account,
|
@@ -1711,7 +1729,7 @@ var _Account = class _Account extends CoValueBase {
|
|
1711
1729
|
valueID,
|
1712
1730
|
inviteSecret
|
1713
1731
|
);
|
1714
|
-
return
|
1732
|
+
return loadCoValue2(coValueClass, valueID, this, []);
|
1715
1733
|
}
|
1716
1734
|
/** @private */
|
1717
1735
|
static async create(options) {
|
@@ -2909,7 +2927,7 @@ var _Group = class _Group extends CoValueBase {
|
|
2909
2927
|
);
|
2910
2928
|
}
|
2911
2929
|
getParentGroups() {
|
2912
|
-
return this._raw.getParentGroups().map((
|
2930
|
+
return this._raw.getParentGroups().map((group) => _Group.fromRaw(group));
|
2913
2931
|
}
|
2914
2932
|
extend(parent, roleMapping) {
|
2915
2933
|
this._raw.extend(parent._raw, roleMapping);
|
@@ -3034,7 +3052,7 @@ var CoPlainText = class extends String {
|
|
3034
3052
|
* @category Subscription & Loading
|
3035
3053
|
*/
|
3036
3054
|
static load(id, as) {
|
3037
|
-
return
|
3055
|
+
return loadCoValue2(this, id, as ?? activeAccountContext.get(), []);
|
3038
3056
|
}
|
3039
3057
|
static subscribe(id, asOrListener, listener) {
|
3040
3058
|
if (isAccountInstance(asOrListener)) {
|
@@ -4186,7 +4204,7 @@ export {
|
|
4186
4204
|
activeAccountContext,
|
4187
4205
|
AnonymousJazzAgent,
|
4188
4206
|
CoValueBase,
|
4189
|
-
loadCoValue,
|
4207
|
+
loadCoValue2 as loadCoValue,
|
4190
4208
|
subscribeToCoValue,
|
4191
4209
|
createCoValueObservable,
|
4192
4210
|
Encoders,
|
@@ -4222,4 +4240,4 @@ export {
|
|
4222
4240
|
consumeInviteLink
|
4223
4241
|
};
|
4224
4242
|
/* istanbul ignore file -- @preserve */
|
4225
|
-
//# sourceMappingURL=chunk-
|
4243
|
+
//# sourceMappingURL=chunk-HH3Z4JSB.js.map
|