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/dist/index.js CHANGED
@@ -35,7 +35,7 @@ import {
35
35
  parseInviteLink,
36
36
  randomSessionProvider,
37
37
  subscribeToCoValue
38
- } from "./chunk-6OJCOJJ6.js";
38
+ } from "./chunk-RL7HVQ5Q.js";
39
39
 
40
40
  // src/index.ts
41
41
  import { MAX_RECOMMENDED_TX_SIZE, cojsonInternals } from "cojson";
package/dist/testing.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  createAnonymousJazzContext,
6
6
  createJazzContext,
7
7
  randomSessionProvider
8
- } from "./chunk-6OJCOJJ6.js";
8
+ } from "./chunk-RL7HVQ5Q.js";
9
9
 
10
10
  // src/testing.ts
11
11
  import { LocalNode } from "cojson";
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  },
18
18
  "type": "module",
19
19
  "license": "MIT",
20
- "version": "0.10.8",
20
+ "version": "0.10.12",
21
21
  "dependencies": {
22
22
  "@scure/bip39": "^1.3.0",
23
23
  "cojson": "0.10.8"
@@ -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<V>,
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<V>,
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<V>,
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<V>,
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: V | undefined) {
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<V>,
316
+ id: ID<CoValue>,
317
317
  as: Account | AnonymousJazzAgent,
318
318
  depth: Depth & DepthsIn<V>,
319
319
  listener: () => void,
@@ -26,7 +26,6 @@ import {
26
26
  setupJazzTestSync,
27
27
  } from "../testing";
28
28
 
29
- // @ts-ignore Typescript in VSCode doesn't like top level await
30
29
  const Crypto = await WasmCrypto.create();
31
30
 
32
31
  class TestJazzContextManager<Acc extends Account> extends JazzContextManager<
@@ -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
+ });