jazz-tools 0.7.0-alpha.34 → 0.7.0-alpha.35
Sign up to get free protection for your applications and to get access to all the features.
package/.turbo/turbo-build.log
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
|
2
|
-
> jazz-tools@0.7.0-alpha.
|
2
|
+
> jazz-tools@0.7.0-alpha.34 build /Users/anselm/jazz/jazz/packages/jazz-tools
|
3
3
|
> npm run lint && rm -rf ./dist && tsc --sourceMap --outDir dist
|
4
4
|
|
5
5
|
|
6
|
-
> jazz-tools@0.7.0-alpha.
|
6
|
+
> jazz-tools@0.7.0-alpha.34 lint
|
7
7
|
> eslint src/**/*.ts
|
8
8
|
|
9
9
|
|
@@ -76,7 +76,9 @@
|
|
76
76
|
83:17 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
77
77
|
|
78
78
|
/Users/anselm/jazz/jazz/packages/jazz-tools/src/implementation/subscriptionScope.ts
|
79
|
-
|
79
|
+
13:23 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
80
|
+
67:32 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
81
|
+
69:32 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
|
80
82
|
|
81
83
|
/Users/anselm/jazz/jazz/packages/jazz-tools/src/tests/coList.test.ts
|
82
84
|
0:0 warning File ignored because of a matching ignore pattern. Use "--no-ignore" to override
|
@@ -90,5 +92,5 @@
|
|
90
92
|
/Users/anselm/jazz/jazz/packages/jazz-tools/src/tests/groupsAndAccounts.test.ts
|
91
93
|
0:0 warning File ignored because of a matching ignore pattern. Use "--no-ignore" to override
|
92
94
|
|
93
|
-
✖
|
95
|
+
✖ 61 problems (0 errors, 61 warnings)
|
94
96
|
|
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import { Effect } from "effect";
|
2
2
|
import { instantiateRefEncoded, isRefEncoded, subscriptionsScopes, } from "../internal.js";
|
3
|
+
const refCache = new WeakMap();
|
3
4
|
export class Ref {
|
4
5
|
constructor(id, controlledAccount, schema) {
|
5
6
|
this.id = id;
|
@@ -10,13 +11,17 @@ export class Ref {
|
|
10
11
|
}
|
11
12
|
}
|
12
13
|
get value() {
|
13
|
-
if (this.cachedValue)
|
14
|
-
return this.cachedValue;
|
15
14
|
// TODO: cache it for object identity!!!
|
16
15
|
const raw = this.controlledAccount._raw.core.node.getLoaded(this.id);
|
17
16
|
if (raw) {
|
18
|
-
|
19
|
-
|
17
|
+
let value = refCache.get(raw);
|
18
|
+
if (value) {
|
19
|
+
// console.log("Using cached value for " + this.id);
|
20
|
+
}
|
21
|
+
else {
|
22
|
+
value = instantiateRefEncoded(this.schema, raw);
|
23
|
+
refCache.set(raw, value);
|
24
|
+
}
|
20
25
|
return value;
|
21
26
|
}
|
22
27
|
else {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"refs.js","sourceRoot":"","sources":["../../src/implementation/refs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAUhC,OAAO,EACH,qBAAqB,EACrB,YAAY,EACZ,mBAAmB,GACtB,MAAM,gBAAgB,CAAC;AAExB,MAAM,OAAO,GAAG;
|
1
|
+
{"version":3,"file":"refs.js","sourceRoot":"","sources":["../../src/implementation/refs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAUhC,OAAO,EACH,qBAAqB,EACrB,YAAY,EACZ,mBAAmB,GACtB,MAAM,gBAAgB,CAAC;AAExB,MAAM,QAAQ,GAAG,IAAI,OAAO,EAAuB,CAAC;AAEpD,MAAM,OAAO,GAAG;IACZ,YACa,EAAS,EACT,iBAA+B,EAC/B,MAAqB;QAFrB,OAAE,GAAF,EAAE,CAAO;QACT,sBAAiB,GAAjB,iBAAiB,CAAc;QAC/B,WAAM,GAAN,MAAM,CAAe;QAE9B,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC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version": "0.7.0-alpha.35",
|
9
9
|
"dependencies": {
|
10
10
|
"@effect/schema": "^0.66.16",
|
11
11
|
"effect": "^3.1.3",
|
12
12
|
"fast-check": "^3.17.2",
|
13
|
-
"cojson": "0.7.0-alpha.
|
14
|
-
"cojson-transport-nodejs-ws": "0.7.0-alpha.
|
13
|
+
"cojson": "0.7.0-alpha.35",
|
14
|
+
"cojson-transport-nodejs-ws": "0.7.0-alpha.35"
|
15
15
|
},
|
16
16
|
"devDependencies": {
|
17
17
|
"typescript": "^5.3.3",
|
@@ -14,9 +14,9 @@ import {
|
|
14
14
|
subscriptionsScopes,
|
15
15
|
} from "../internal.js";
|
16
16
|
|
17
|
-
|
18
|
-
private cachedValue: V | undefined;
|
17
|
+
const refCache = new WeakMap<RawCoValue, CoValue>();
|
19
18
|
|
19
|
+
export class Ref<out V extends CoValue> {
|
20
20
|
constructor(
|
21
21
|
readonly id: ID<V>,
|
22
22
|
readonly controlledAccount: Account & Me,
|
@@ -28,15 +28,19 @@ export class Ref<out V extends CoValue> {
|
|
28
28
|
}
|
29
29
|
|
30
30
|
get value() {
|
31
|
-
if (this.cachedValue) return this.cachedValue;
|
32
31
|
// TODO: cache it for object identity!!!
|
33
32
|
const raw = this.controlledAccount._raw.core.node.getLoaded(
|
34
33
|
this.id as unknown as CoID<RawCoValue>
|
35
34
|
);
|
36
35
|
if (raw) {
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
let value = refCache.get(raw);
|
37
|
+
if (value) {
|
38
|
+
// console.log("Using cached value for " + this.id);
|
39
|
+
} else {
|
40
|
+
value = instantiateRefEncoded(this.schema, raw);
|
41
|
+
refCache.set(raw, value);
|
42
|
+
}
|
43
|
+
return value as V;
|
40
44
|
} else {
|
41
45
|
return null;
|
42
46
|
}
|