jazz-tools 0.10.8 → 0.10.12
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 +4 -4
- package/CHANGELOG.md +6 -0
- package/dist/{chunk-6OJCOJJ6.js → chunk-RL7HVQ5Q.js} +1 -1
- package/dist/chunk-RL7HVQ5Q.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/testing.js +1 -1
- package/package.json +1 -1
- package/src/coValues/deepLoading.ts +0 -1
- package/src/coValues/interfaces.ts +6 -6
- package/src/tests/ContextManager.test.ts +0 -1
- package/src/tests/deepLoading.test.ts +44 -0
- package/dist/chunk-6OJCOJJ6.js.map +0 -1
package/dist/index.js
CHANGED
package/dist/testing.js
CHANGED
package/package.json
CHANGED
@@ -29,7 +29,6 @@ export function fulfillsDepth(depth: any, value: CoValue): boolean {
|
|
29
29
|
const map = value as unknown as {
|
30
30
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
31
31
|
[key: string]: any;
|
32
|
-
_refs: { [key: string]: Ref<CoValue> | undefined };
|
33
32
|
};
|
34
33
|
|
35
34
|
if (map._raw.get(key) === undefined) {
|
@@ -157,7 +157,7 @@ export class CoValueBase implements CoValue {
|
|
157
157
|
|
158
158
|
export function loadCoValueWithoutMe<V extends CoValue, Depth>(
|
159
159
|
cls: CoValueClass<V>,
|
160
|
-
id: ID<
|
160
|
+
id: ID<CoValue>,
|
161
161
|
asOrDepth: Account | AnonymousJazzAgent | (Depth & DepthsIn<V>),
|
162
162
|
depth?: Depth & DepthsIn<V>,
|
163
163
|
) {
|
@@ -175,7 +175,7 @@ export function loadCoValueWithoutMe<V extends CoValue, Depth>(
|
|
175
175
|
|
176
176
|
export function loadCoValue<V extends CoValue, Depth>(
|
177
177
|
cls: CoValueClass<V>,
|
178
|
-
id: ID<
|
178
|
+
id: ID<CoValue>,
|
179
179
|
as: Account | AnonymousJazzAgent,
|
180
180
|
depth: Depth & DepthsIn<V>,
|
181
181
|
): Promise<DeeplyLoaded<V, Depth> | undefined> {
|
@@ -216,7 +216,7 @@ export async function ensureCoValueLoaded<V extends CoValue, Depth>(
|
|
216
216
|
|
217
217
|
export function subscribeToCoValueWithoutMe<V extends CoValue, Depth>(
|
218
218
|
cls: CoValueClass<V>,
|
219
|
-
id: ID<
|
219
|
+
id: ID<CoValue>,
|
220
220
|
asOrDepth: Account | AnonymousJazzAgent | (Depth & DepthsIn<V>),
|
221
221
|
depthOrListener:
|
222
222
|
| (Depth & DepthsIn<V>)
|
@@ -251,7 +251,7 @@ export function subscribeToCoValueWithoutMe<V extends CoValue, Depth>(
|
|
251
251
|
|
252
252
|
export function subscribeToCoValue<V extends CoValue, Depth>(
|
253
253
|
cls: CoValueClass<V>,
|
254
|
-
id: ID<
|
254
|
+
id: ID<CoValue>,
|
255
255
|
as: Account | AnonymousJazzAgent,
|
256
256
|
depth: Depth & DepthsIn<V>,
|
257
257
|
listener: (value: DeeplyLoaded<V, Depth>, unsubscribe: () => void) => void,
|
@@ -263,7 +263,7 @@ export function subscribeToCoValue<V extends CoValue, Depth>(
|
|
263
263
|
let unsubscribed = false;
|
264
264
|
let unsubscribe: (() => void) | undefined;
|
265
265
|
|
266
|
-
function subscribe(value:
|
266
|
+
function subscribe(value: CoValue | undefined) {
|
267
267
|
if (!value) {
|
268
268
|
onUnavailable && onUnavailable();
|
269
269
|
return;
|
@@ -313,7 +313,7 @@ export function createCoValueObservable<V extends CoValue, Depth>(options?: {
|
|
313
313
|
|
314
314
|
function subscribe(
|
315
315
|
cls: CoValueClass<V>,
|
316
|
-
id: ID<
|
316
|
+
id: ID<CoValue>,
|
317
317
|
as: Account | AnonymousJazzAgent,
|
318
318
|
depth: Depth & DepthsIn<V>,
|
319
319
|
listener: () => void,
|
@@ -387,3 +387,47 @@ test("throw when calling ensureLoaded on a ref that is not defined in the schema
|
|
387
387
|
}),
|
388
388
|
).rejects.toThrow("Failed to deeply load CoValue " + root.id);
|
389
389
|
});
|
390
|
+
|
391
|
+
test("should not throw when calling ensureLoaded a record with a deleted ref", async () => {
|
392
|
+
class JazzProfile extends CoMap {
|
393
|
+
firstName = co.string;
|
394
|
+
}
|
395
|
+
|
396
|
+
class JazzySnapStore extends CoMap.Record(co.ref(JazzProfile)) {}
|
397
|
+
|
398
|
+
const me = await Account.create({
|
399
|
+
creationProps: { name: "Tester McTesterson" },
|
400
|
+
crypto: Crypto,
|
401
|
+
});
|
402
|
+
|
403
|
+
const root = JazzySnapStore.create(
|
404
|
+
{
|
405
|
+
profile: JazzProfile.create({ firstName: "John" }, me),
|
406
|
+
},
|
407
|
+
me,
|
408
|
+
);
|
409
|
+
|
410
|
+
let value: any;
|
411
|
+
let unsub = root.subscribe([{}], (v) => {
|
412
|
+
value = v;
|
413
|
+
});
|
414
|
+
|
415
|
+
await waitFor(() => expect(value.profile).toBeDefined());
|
416
|
+
|
417
|
+
delete root.profile;
|
418
|
+
|
419
|
+
await waitFor(() => expect(value.profile).toBeUndefined());
|
420
|
+
|
421
|
+
unsub();
|
422
|
+
|
423
|
+
value = undefined;
|
424
|
+
unsub = root.subscribe([{}], (v) => {
|
425
|
+
value = v;
|
426
|
+
});
|
427
|
+
|
428
|
+
await waitFor(() => expect(value).toBeDefined());
|
429
|
+
|
430
|
+
expect(value.profile).toBeUndefined();
|
431
|
+
|
432
|
+
unsub();
|
433
|
+
});
|