jazz-tools 0.7.0-alpha.4 → 0.7.0-alpha.42
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintrc.cjs +3 -10
- package/.prettierrc.js +9 -0
- package/.turbo/turbo-build.log +3 -19
- package/.turbo/turbo-lint.log +4 -0
- package/.turbo/turbo-test.log +140 -0
- package/CHANGELOG.md +252 -0
- package/README.md +10 -2
- package/dist/coValues/account.js +104 -50
- package/dist/coValues/account.js.map +1 -1
- package/dist/coValues/coList.js +165 -112
- package/dist/coValues/coList.js.map +1 -1
- package/dist/coValues/coMap.js +243 -163
- package/dist/coValues/coMap.js.map +1 -1
- package/dist/coValues/coStream.js +256 -73
- package/dist/coValues/coStream.js.map +1 -1
- package/dist/coValues/deepLoading.js +57 -0
- package/dist/coValues/deepLoading.js.map +1 -0
- package/dist/coValues/extensions/imageDef.js +14 -8
- package/dist/coValues/extensions/imageDef.js.map +1 -1
- package/dist/coValues/group.js +49 -38
- package/dist/coValues/group.js.map +1 -1
- package/dist/coValues/interfaces.js +66 -26
- package/dist/coValues/interfaces.js.map +1 -1
- package/dist/implementation/devtoolsFormatters.js +114 -0
- package/dist/implementation/devtoolsFormatters.js.map +1 -0
- package/dist/implementation/refs.js +60 -19
- package/dist/implementation/refs.js.map +1 -1
- package/dist/implementation/schema.js +44 -1
- package/dist/implementation/schema.js.map +1 -1
- package/dist/implementation/subscriptionScope.js +19 -1
- package/dist/implementation/subscriptionScope.js.map +1 -1
- package/dist/implementation/symbols.js +5 -0
- package/dist/implementation/symbols.js.map +1 -0
- package/dist/index.js +4 -5
- package/dist/index.js.map +1 -1
- package/dist/internal.js +4 -1
- package/dist/internal.js.map +1 -1
- package/dist/tests/coList.test.js +51 -52
- package/dist/tests/coList.test.js.map +1 -1
- package/dist/tests/coMap.test.js +196 -75
- package/dist/tests/coMap.test.js.map +1 -1
- package/dist/tests/coStream.test.js +95 -85
- package/dist/tests/coStream.test.js.map +1 -1
- package/dist/tests/deepLoading.test.js +188 -0
- package/dist/tests/deepLoading.test.js.map +1 -0
- package/dist/tests/groupsAndAccounts.test.js +83 -0
- package/dist/tests/groupsAndAccounts.test.js.map +1 -0
- package/package.json +17 -9
- package/src/coValues/account.ts +184 -153
- package/src/coValues/coList.ts +220 -173
- package/src/coValues/coMap.ts +322 -312
- package/src/coValues/coStream.ts +397 -135
- package/src/coValues/deepLoading.ts +215 -0
- package/src/coValues/extensions/imageDef.ts +16 -17
- package/src/coValues/group.ts +95 -111
- package/src/coValues/interfaces.ts +217 -115
- package/src/implementation/devtoolsFormatters.ts +110 -0
- package/src/implementation/inspect.ts +1 -1
- package/src/implementation/refs.ts +91 -38
- package/src/implementation/schema.ts +87 -46
- package/src/implementation/subscriptionScope.ts +44 -12
- package/src/implementation/symbols.ts +11 -0
- package/src/index.ts +13 -9
- package/src/internal.ts +6 -2
- package/src/tests/coList.test.ts +67 -66
- package/src/tests/coMap.test.ts +226 -123
- package/src/tests/coStream.test.ts +141 -131
- package/src/tests/deepLoading.test.ts +301 -0
- package/src/tests/groupsAndAccounts.test.ts +91 -0
@@ -4,34 +4,44 @@ import type {
|
|
4
4
|
Account,
|
5
5
|
CoValue,
|
6
6
|
ID,
|
7
|
-
|
8
|
-
|
7
|
+
RefEncoded,
|
8
|
+
UnCo,
|
9
9
|
UnavailableError,
|
10
|
-
indexSignature,
|
11
10
|
} from "../internal.js";
|
12
|
-
import {
|
11
|
+
import {
|
12
|
+
instantiateRefEncoded,
|
13
|
+
isRefEncoded,
|
14
|
+
subscriptionsScopes,
|
15
|
+
} from "../internal.js";
|
16
|
+
|
17
|
+
const refCache = new WeakMap<RawCoValue, CoValue>();
|
13
18
|
|
14
|
-
|
15
|
-
private cachedValue: V | undefined;
|
19
|
+
const TRACE_ACCESSES = false;
|
16
20
|
|
21
|
+
export class Ref<out V extends CoValue> {
|
17
22
|
constructor(
|
18
23
|
readonly id: ID<V>,
|
19
|
-
readonly controlledAccount: Account
|
20
|
-
readonly
|
21
|
-
) {
|
24
|
+
readonly controlledAccount: Account,
|
25
|
+
readonly schema: RefEncoded<V>,
|
26
|
+
) {
|
27
|
+
if (!isRefEncoded(schema)) {
|
28
|
+
throw new Error("Ref must be constructed with a ref schema");
|
29
|
+
}
|
30
|
+
}
|
22
31
|
|
23
32
|
get value() {
|
24
|
-
if (this.cachedValue) return this.cachedValue;
|
25
|
-
// TODO: cache it for object identity!!!
|
26
33
|
const raw = this.controlledAccount._raw.core.node.getLoaded(
|
27
|
-
this.id as unknown as CoID<RawCoValue
|
34
|
+
this.id as unknown as CoID<RawCoValue>,
|
28
35
|
);
|
29
36
|
if (raw) {
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
37
|
+
let value = refCache.get(raw);
|
38
|
+
if (value) {
|
39
|
+
// console.log("Using cached value for " + this.id);
|
40
|
+
} else {
|
41
|
+
value = instantiateRefEncoded(this.schema, raw);
|
42
|
+
refCache.set(raw, value);
|
43
|
+
}
|
44
|
+
return value as V;
|
35
45
|
} else {
|
36
46
|
return null;
|
37
47
|
}
|
@@ -58,16 +68,12 @@ export class ValueRef<V extends CoValue> {
|
|
58
68
|
}): Promise<V | "unavailable"> {
|
59
69
|
const raw = await this.controlledAccount._raw.core.node.load(
|
60
70
|
this.id as unknown as CoID<RawCoValue>,
|
61
|
-
options?.onProgress
|
71
|
+
options?.onProgress,
|
62
72
|
);
|
63
73
|
if (raw === "unavailable") {
|
64
74
|
return "unavailable";
|
65
75
|
} else {
|
66
|
-
return new
|
67
|
-
this.id,
|
68
|
-
this.controlledAccount,
|
69
|
-
this.valueConstructor
|
70
|
-
).value!;
|
76
|
+
return new Ref(this.id, this.controlledAccount, this.schema).value!;
|
71
77
|
}
|
72
78
|
}
|
73
79
|
|
@@ -82,41 +88,72 @@ export class ValueRef<V extends CoValue> {
|
|
82
88
|
}
|
83
89
|
}
|
84
90
|
|
85
|
-
accessFrom(
|
91
|
+
accessFrom(
|
92
|
+
fromScopeValue: CoValue,
|
93
|
+
key: string | number | symbol,
|
94
|
+
): V | null {
|
86
95
|
const subScope = subscriptionsScopes.get(fromScopeValue);
|
87
96
|
|
88
|
-
subScope?.onRefAccessedOrSet(this.id);
|
97
|
+
subScope?.onRefAccessedOrSet(fromScopeValue.id, this.id);
|
98
|
+
TRACE_ACCESSES &&
|
99
|
+
console.log(
|
100
|
+
subScope?.scopeID,
|
101
|
+
"accessing",
|
102
|
+
fromScopeValue,
|
103
|
+
key,
|
104
|
+
this.id,
|
105
|
+
);
|
89
106
|
|
90
107
|
if (this.value && subScope) {
|
91
108
|
subscriptionsScopes.set(this.value, subScope);
|
92
109
|
}
|
93
110
|
|
94
|
-
|
111
|
+
if (subScope) {
|
112
|
+
const cached = subScope.cachedValues[this.id];
|
113
|
+
if (cached) {
|
114
|
+
TRACE_ACCESSES && console.log("cached", cached);
|
115
|
+
return cached as V;
|
116
|
+
} else if (this.value !== null) {
|
117
|
+
const freshValueInstance = instantiateRefEncoded(
|
118
|
+
this.schema,
|
119
|
+
this.value?._raw,
|
120
|
+
);
|
121
|
+
TRACE_ACCESSES &&
|
122
|
+
console.log("freshValueInstance", freshValueInstance);
|
123
|
+
subScope.cachedValues[this.id] = freshValueInstance;
|
124
|
+
subscriptionsScopes.set(freshValueInstance, subScope);
|
125
|
+
return freshValueInstance as V;
|
126
|
+
} else {
|
127
|
+
return null;
|
128
|
+
}
|
129
|
+
} else {
|
130
|
+
return this.value;
|
131
|
+
}
|
95
132
|
}
|
96
133
|
}
|
97
134
|
|
98
|
-
export function makeRefs<Keys extends string | number
|
135
|
+
export function makeRefs<Keys extends string | number>(
|
99
136
|
getIdForKey: (key: Keys) => ID<CoValue> | undefined,
|
100
137
|
getKeysWithIds: () => Keys[],
|
101
|
-
controlledAccount: Account
|
102
|
-
|
103
|
-
): { [K in Keys]:
|
104
|
-
[Symbol.iterator]: () => IterableIterator<
|
138
|
+
controlledAccount: Account,
|
139
|
+
refSchemaForKey: (key: Keys) => RefEncoded<CoValue>,
|
140
|
+
): { [K in Keys]: Ref<CoValue> } & {
|
141
|
+
[Symbol.iterator]: () => IterableIterator<Ref<CoValue>>;
|
105
142
|
length: number;
|
106
143
|
} {
|
107
|
-
const refs = {} as { [K in Keys]:
|
108
|
-
[Symbol.iterator]: () => IterableIterator<
|
144
|
+
const refs = {} as { [K in Keys]: Ref<CoValue> } & {
|
145
|
+
[Symbol.iterator]: () => IterableIterator<Ref<CoValue>>;
|
109
146
|
length: number;
|
110
147
|
};
|
111
148
|
return new Proxy(refs, {
|
112
|
-
get(
|
149
|
+
get(_target, key) {
|
113
150
|
if (key === Symbol.iterator) {
|
114
151
|
return function* () {
|
115
152
|
for (const key of getKeysWithIds()) {
|
116
|
-
yield new
|
153
|
+
yield new Ref(
|
117
154
|
getIdForKey(key)!,
|
118
155
|
controlledAccount,
|
119
|
-
|
156
|
+
refSchemaForKey(key),
|
120
157
|
);
|
121
158
|
}
|
122
159
|
};
|
@@ -127,14 +164,30 @@ export function makeRefs<Keys extends string | number | indexSignature>(
|
|
127
164
|
}
|
128
165
|
const id = getIdForKey(key as Keys);
|
129
166
|
if (!id) return undefined;
|
130
|
-
return new
|
167
|
+
return new Ref(
|
131
168
|
id as ID<CoValue>,
|
132
169
|
controlledAccount,
|
133
|
-
|
170
|
+
refSchemaForKey(key as Keys),
|
134
171
|
);
|
135
172
|
},
|
136
173
|
ownKeys() {
|
137
174
|
return getKeysWithIds().map((key) => key.toString());
|
138
175
|
},
|
176
|
+
getOwnPropertyDescriptor(target, key) {
|
177
|
+
const id = getIdForKey(key as Keys);
|
178
|
+
if (id) {
|
179
|
+
return {
|
180
|
+
enumerable: true,
|
181
|
+
configurable: true,
|
182
|
+
writable: true,
|
183
|
+
};
|
184
|
+
} else {
|
185
|
+
return Reflect.getOwnPropertyDescriptor(target, key);
|
186
|
+
}
|
187
|
+
},
|
139
188
|
});
|
140
189
|
}
|
190
|
+
|
191
|
+
export type RefIfCoValue<V> = NonNullable<V> extends CoValue
|
192
|
+
? Ref<UnCo<NonNullable<V>>>
|
193
|
+
: never;
|
@@ -1,31 +1,100 @@
|
|
1
|
-
import type { JsonValue } from "cojson";
|
2
|
-
import
|
3
|
-
|
1
|
+
import type { JsonValue, RawCoValue } from "cojson";
|
2
|
+
import {
|
3
|
+
type CoValue,
|
4
|
+
type CoValueClass,
|
5
|
+
isCoValueClass,
|
6
|
+
} from "../internal.js";
|
7
|
+
import type { Schema as EffectSchema, TypeId } from "@effect/schema/Schema";
|
4
8
|
|
5
|
-
export type
|
6
|
-
|
7
|
-
export type
|
8
|
-
|
9
|
+
export type CoMarker = { readonly __co: unique symbol };
|
10
|
+
/** @category Schema definition */
|
11
|
+
export type co<T> = T | (T & CoMarker);
|
12
|
+
export type IfCo<C, R> = C extends infer _A | infer B
|
13
|
+
? B extends CoMarker
|
14
|
+
? R
|
15
|
+
: never
|
16
|
+
: never;
|
17
|
+
export type UnCo<T> = T extends co<infer A> ? A : T;
|
18
|
+
|
19
|
+
/** @category Schema definition */
|
20
|
+
export const co = {
|
21
|
+
string: {
|
22
|
+
[SchemaInit]: "json" satisfies Schema,
|
23
|
+
} as unknown as co<string>,
|
24
|
+
number: {
|
25
|
+
[SchemaInit]: "json" satisfies Schema,
|
26
|
+
} as unknown as co<number>,
|
27
|
+
boolean: {
|
28
|
+
[SchemaInit]: "json" satisfies Schema,
|
29
|
+
} as unknown as co<boolean>,
|
30
|
+
null: {
|
31
|
+
[SchemaInit]: "json" satisfies Schema,
|
32
|
+
} as unknown as co<null>,
|
33
|
+
literal: <T extends (string | number | boolean)[]>(
|
34
|
+
..._lit: T
|
35
|
+
): co<T[number]> => {
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
37
|
+
return { [SchemaInit]: "json" satisfies Schema } as any;
|
38
|
+
},
|
39
|
+
json: <T extends JsonValue>(): co<T> => {
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
41
|
+
return { [SchemaInit]: "json" satisfies Schema } as any;
|
42
|
+
},
|
43
|
+
encoded: <T>(arg: Encoder<T>): co<T> => {
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
45
|
+
return { [SchemaInit]: { encoded: arg } satisfies Schema } as any;
|
46
|
+
},
|
47
|
+
ref: <C extends CoValueClass>(
|
48
|
+
arg: C | ((_raw: InstanceType<C>["_raw"]) => C),
|
49
|
+
): co<InstanceType<C> | null> => {
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
51
|
+
return { [SchemaInit]: arg satisfies Schema } as any;
|
52
|
+
},
|
53
|
+
items: ItemsSym as ItemsSym,
|
54
|
+
members: MembersSym as MembersSym,
|
9
55
|
};
|
10
56
|
|
11
|
-
export type
|
12
|
-
|
13
|
-
|
14
|
-
|
|
57
|
+
export type JsonEncoded = "json";
|
58
|
+
export type EncodedAs<V> = { encoded: Encoder<V> };
|
59
|
+
export type RefEncoded<V extends CoValue> =
|
60
|
+
| CoValueClass<V>
|
61
|
+
| ((raw: RawCoValue) => CoValueClass<V>);
|
62
|
+
|
63
|
+
export function isRefEncoded<V extends CoValue>(
|
64
|
+
schema: Schema,
|
65
|
+
): schema is RefEncoded<V> {
|
66
|
+
return typeof schema === "function";
|
67
|
+
}
|
68
|
+
|
69
|
+
export function instantiateRefEncoded<V extends CoValue>(
|
70
|
+
schema: RefEncoded<V>,
|
71
|
+
raw: RawCoValue,
|
72
|
+
): V {
|
73
|
+
return isCoValueClass(schema)
|
74
|
+
? schema.fromRaw(raw)
|
75
|
+
: (schema as (raw: RawCoValue) => CoValueClass<V>)(raw).fromRaw(raw);
|
76
|
+
}
|
77
|
+
|
78
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
79
|
+
export type Schema = JsonEncoded | RefEncoded<CoValue> | EncodedAs<any>;
|
15
80
|
|
16
|
-
export type
|
17
|
-
?
|
81
|
+
export type SchemaFor<Field> = NonNullable<Field> extends CoValue
|
82
|
+
? RefEncoded<NonNullable<Field>>
|
18
83
|
: NonNullable<Field> extends JsonValue
|
19
|
-
?
|
20
|
-
:
|
84
|
+
? JsonEncoded
|
85
|
+
: EncodedAs<NonNullable<Field>>;
|
21
86
|
|
22
|
-
export type EffectSchemaWithInputAndOutput<A, I = A> =
|
87
|
+
export type EffectSchemaWithInputAndOutput<A, I = A> = EffectSchema<
|
88
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
23
89
|
any,
|
90
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
24
91
|
any,
|
25
92
|
never
|
26
93
|
> & {
|
27
94
|
[TypeId]: {
|
95
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
28
96
|
_A: (_: any) => A;
|
97
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
29
98
|
_I: (_: any) => I;
|
30
99
|
};
|
31
100
|
};
|
@@ -33,37 +102,9 @@ export type EffectSchemaWithInputAndOutput<A, I = A> = Schema<
|
|
33
102
|
export type Encoder<V> = EffectSchemaWithInputAndOutput<V, JsonValue>;
|
34
103
|
|
35
104
|
import { Date } from "@effect/schema/Schema";
|
105
|
+
import { SchemaInit, ItemsSym, MembersSym } from "./symbols.js";
|
36
106
|
|
107
|
+
/** @category Schema definition */
|
37
108
|
export const Encoders = {
|
38
109
|
Date,
|
39
110
|
};
|
40
|
-
|
41
|
-
export const indexSignature = Symbol.for("indexSignature");
|
42
|
-
export type indexSignature = typeof indexSignature;
|
43
|
-
|
44
|
-
export type EnsureCoValueNullable<
|
45
|
-
V,
|
46
|
-
Key extends string | indexSignature,
|
47
|
-
> = NonNullable<V> extends CoValue
|
48
|
-
? null extends V
|
49
|
-
? V
|
50
|
-
: Key extends string
|
51
|
-
? [
|
52
|
-
`👋 CoMap fields that are CoValue references should be nullable, declare ${Key} as:`,
|
53
|
-
V | null,
|
54
|
-
]
|
55
|
-
: [
|
56
|
-
`👋 CoMap fields that are CoValue references should be nullable, declare [indexSignature] as:`,
|
57
|
-
V | null,
|
58
|
-
]
|
59
|
-
: V;
|
60
|
-
|
61
|
-
export type EnsureItemNullable<Item, ContainerType extends string> =
|
62
|
-
NonNullable<Item> extends CoValue
|
63
|
-
? null extends Item
|
64
|
-
? any
|
65
|
-
: [
|
66
|
-
`👋 CoList items that are CoValue references should be nullable, make sure the Item generic parameter of ${ContainerType} is:`,
|
67
|
-
Item | null
|
68
|
-
]
|
69
|
-
: any;
|
@@ -1,16 +1,23 @@
|
|
1
1
|
import type { RawCoValue } from "cojson";
|
2
|
-
import type {
|
2
|
+
import type {
|
3
|
+
Account,
|
4
|
+
CoValue,
|
5
|
+
CoValueBase,
|
6
|
+
ID,
|
7
|
+
ClassOf,
|
8
|
+
} from "../internal.js";
|
3
9
|
|
4
10
|
export const subscriptionsScopes = new WeakMap<
|
5
11
|
CoValue,
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
6
13
|
SubscriptionScope<any>
|
7
14
|
>();
|
8
15
|
|
9
|
-
|
10
|
-
|
11
|
-
> {
|
16
|
+
const TRACE_INVALIDATIONS = false;
|
17
|
+
|
18
|
+
export class SubscriptionScope<Root extends CoValue> {
|
12
19
|
scopeID: string = `scope-${Math.random().toString(36).slice(2)}`;
|
13
|
-
subscriber: Account
|
20
|
+
subscriber: Account;
|
14
21
|
entries = new Map<
|
15
22
|
ID<CoValue>,
|
16
23
|
| { state: "loading"; immediatelyUnsub?: boolean }
|
@@ -23,11 +30,13 @@ export class SubscriptionScope<
|
|
23
30
|
};
|
24
31
|
onUpdate: (newRoot: Root) => void;
|
25
32
|
scheduledUpdate: boolean = false;
|
33
|
+
cachedValues: { [id: ID<CoValue>]: CoValue } = {};
|
34
|
+
parents: { [id: ID<CoValue>]: Set<ID<CoValue>> } = {};
|
26
35
|
|
27
36
|
constructor(
|
28
37
|
root: Root,
|
29
|
-
rootSchema:
|
30
|
-
onUpdate: (newRoot: Root) => void
|
38
|
+
rootSchema: ClassOf<Root> & typeof CoValueBase,
|
39
|
+
onUpdate: (newRoot: Root) => void,
|
31
40
|
) {
|
32
41
|
this.rootEntry = {
|
33
42
|
state: "loaded" as const,
|
@@ -43,13 +52,11 @@ export class SubscriptionScope<
|
|
43
52
|
this.rootEntry.rawUnsub = root._raw.core.subscribe(
|
44
53
|
(rawUpdate: RawCoValue | undefined) => {
|
45
54
|
if (!rawUpdate) return;
|
46
|
-
this.rootEntry.value = rootSchema.fromRaw(
|
47
|
-
rawUpdate
|
48
|
-
) as Root;
|
55
|
+
this.rootEntry.value = rootSchema.fromRaw(rawUpdate) as Root;
|
49
56
|
// console.log("root update", this.rootEntry.value.toJSON());
|
50
57
|
subscriptionsScopes.set(this.rootEntry.value, this);
|
51
58
|
this.scheduleUpdate();
|
52
|
-
}
|
59
|
+
},
|
53
60
|
);
|
54
61
|
}
|
55
62
|
|
@@ -63,12 +70,19 @@ export class SubscriptionScope<
|
|
63
70
|
}
|
64
71
|
}
|
65
72
|
|
66
|
-
onRefAccessedOrSet(
|
73
|
+
onRefAccessedOrSet(
|
74
|
+
fromId: ID<CoValue>,
|
75
|
+
accessedOrSetId: ID<CoValue> | undefined,
|
76
|
+
) {
|
67
77
|
// console.log("onRefAccessedOrSet", this.scopeID, accessedOrSetId);
|
68
78
|
if (!accessedOrSetId) {
|
69
79
|
return;
|
70
80
|
}
|
71
81
|
|
82
|
+
this.parents[accessedOrSetId] =
|
83
|
+
this.parents[accessedOrSetId] || new Set();
|
84
|
+
this.parents[accessedOrSetId]!.add(fromId);
|
85
|
+
|
72
86
|
if (!this.entries.has(accessedOrSetId)) {
|
73
87
|
const loadingEntry = {
|
74
88
|
state: "loading",
|
@@ -94,6 +108,7 @@ export class SubscriptionScope<
|
|
94
108
|
const rawUnsub = core.subscribe((rawUpdate) => {
|
95
109
|
// console.log("ref update", this.scopeID, accessedOrSetId, JSON.stringify(rawUpdate))
|
96
110
|
if (!rawUpdate) return;
|
111
|
+
this.invalidate(accessedOrSetId);
|
97
112
|
this.scheduleUpdate();
|
98
113
|
});
|
99
114
|
|
@@ -103,6 +118,23 @@ export class SubscriptionScope<
|
|
103
118
|
}
|
104
119
|
}
|
105
120
|
|
121
|
+
invalidate(id: ID<CoValue>, fromChild?: ID<CoValue>, seen: Set<ID<CoValue>> = new Set()) {
|
122
|
+
if (seen.has(id)) return;
|
123
|
+
TRACE_INVALIDATIONS &&
|
124
|
+
console.log(
|
125
|
+
"invalidating",
|
126
|
+
fromChild,
|
127
|
+
"->",
|
128
|
+
id,
|
129
|
+
this.cachedValues[id],
|
130
|
+
);
|
131
|
+
delete this.cachedValues[id];
|
132
|
+
seen.add(id);
|
133
|
+
for (const parent of this.parents[id] || []) {
|
134
|
+
this.invalidate(parent, id, seen);
|
135
|
+
}
|
136
|
+
}
|
137
|
+
|
106
138
|
unsubscribeAll() {
|
107
139
|
for (const entry of this.entries.values()) {
|
108
140
|
if (entry.state === "loaded") {
|
@@ -0,0 +1,11 @@
|
|
1
|
+
export const SchemaInit = Symbol.for("SchemaInit");
|
2
|
+
export type SchemaInit = typeof SchemaInit;
|
3
|
+
|
4
|
+
export const InitValues = Symbol.for("InitValues");
|
5
|
+
export type InitValues = typeof InitValues;
|
6
|
+
|
7
|
+
export const ItemsSym = Symbol.for("items");
|
8
|
+
export type ItemsSym = typeof ItemsSym;
|
9
|
+
|
10
|
+
export const MembersSym = Symbol.for("members");
|
11
|
+
export type MembersSym = typeof MembersSym;
|
package/src/index.ts
CHANGED
@@ -1,23 +1,27 @@
|
|
1
|
-
/** @category Internal types */
|
2
1
|
export {
|
3
|
-
|
2
|
+
cojsonInternals,
|
3
|
+
MAX_RECOMMENDED_TX_SIZE,
|
4
|
+
WasmCrypto,
|
5
|
+
PureJSCrypto,
|
6
|
+
} from "cojson";
|
7
|
+
export type {
|
4
8
|
InviteSecret,
|
5
9
|
Peer,
|
6
10
|
SessionID,
|
7
11
|
AgentID,
|
8
12
|
SyncMessage,
|
9
|
-
|
10
|
-
MAX_RECOMMENDED_TX_SIZE,
|
13
|
+
CryptoProvider,
|
11
14
|
} from "cojson";
|
12
15
|
|
13
|
-
export { ID, CoValue } from "./internal.js";
|
16
|
+
export type { ID, CoValue } from "./internal.js";
|
14
17
|
|
15
|
-
export { Encoders } from "./internal.js";
|
18
|
+
export { Encoders, co } from "./internal.js";
|
16
19
|
|
17
|
-
export { CoMap
|
20
|
+
export { CoMap } from "./internal.js";
|
18
21
|
export { CoList } from "./internal.js";
|
19
22
|
export { CoStream, BinaryCoStream } from "./internal.js";
|
20
23
|
export { Group, Profile } from "./internal.js";
|
21
|
-
export { Account,
|
24
|
+
export { Account, isControlledAccount } from "./internal.js";
|
22
25
|
export { ImageDefinition } from "./internal.js";
|
23
|
-
export { CoValueBase, CoValueClass } from "./internal.js";
|
26
|
+
export { CoValueBase, type CoValueClass } from "./internal.js";
|
27
|
+
export type { DepthsIn, DeeplyLoaded } from "./internal.js";
|
package/src/internal.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
export * from
|
1
|
+
export * from "./implementation/symbols.js";
|
2
|
+
export * from "./implementation/inspect.js";
|
2
3
|
export * from "./coValues/interfaces.js";
|
3
4
|
|
4
5
|
export * from "./coValues/coMap.js";
|
@@ -11,5 +12,8 @@ export * from "./implementation/errors.js";
|
|
11
12
|
export * from "./implementation/refs.js";
|
12
13
|
export * from "./implementation/schema.js";
|
13
14
|
export * from "./implementation/subscriptionScope.js";
|
15
|
+
export * from "./coValues/deepLoading.js";
|
14
16
|
|
15
|
-
export * from "./coValues/extensions/imageDef.js";
|
17
|
+
export * from "./coValues/extensions/imageDef.js";
|
18
|
+
|
19
|
+
import "./implementation/devtoolsFormatters.js";
|