jazz-tools 0.7.0-alpha.37 → 0.7.0-alpha.39

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. package/.eslintrc.cjs +3 -10
  2. package/.prettierrc.js +9 -0
  3. package/.turbo/turbo-build.log +1 -95
  4. package/.turbo/turbo-lint.log +4 -0
  5. package/.turbo/turbo-test.log +140 -0
  6. package/CHANGELOG.md +19 -0
  7. package/README.md +10 -2
  8. package/dist/coValues/account.js +22 -12
  9. package/dist/coValues/account.js.map +1 -1
  10. package/dist/coValues/coList.js +7 -9
  11. package/dist/coValues/coList.js.map +1 -1
  12. package/dist/coValues/coMap.js +11 -3
  13. package/dist/coValues/coMap.js.map +1 -1
  14. package/dist/coValues/coStream.js +15 -8
  15. package/dist/coValues/coStream.js.map +1 -1
  16. package/dist/coValues/deepLoading.js +57 -0
  17. package/dist/coValues/deepLoading.js.map +1 -0
  18. package/dist/coValues/extensions/imageDef.js +1 -1
  19. package/dist/coValues/extensions/imageDef.js.map +1 -1
  20. package/dist/coValues/group.js +1 -0
  21. package/dist/coValues/group.js.map +1 -1
  22. package/dist/coValues/interfaces.js +34 -28
  23. package/dist/coValues/interfaces.js.map +1 -1
  24. package/dist/implementation/devtoolsFormatters.js +1 -0
  25. package/dist/implementation/devtoolsFormatters.js.map +1 -1
  26. package/dist/implementation/refs.js +4 -2
  27. package/dist/implementation/refs.js.map +1 -1
  28. package/dist/implementation/schema.js +5 -1
  29. package/dist/implementation/schema.js.map +1 -1
  30. package/dist/implementation/subscriptionScope.js +9 -4
  31. package/dist/implementation/subscriptionScope.js.map +1 -1
  32. package/dist/implementation/symbols.js.map +1 -1
  33. package/dist/index.js +2 -4
  34. package/dist/index.js.map +1 -1
  35. package/dist/internal.js +2 -1
  36. package/dist/internal.js.map +1 -1
  37. package/dist/tests/coList.test.js +20 -17
  38. package/dist/tests/coList.test.js.map +1 -1
  39. package/dist/tests/coMap.test.js +27 -17
  40. package/dist/tests/coMap.test.js.map +1 -1
  41. package/dist/tests/coStream.test.js +39 -24
  42. package/dist/tests/coStream.test.js.map +1 -1
  43. package/dist/tests/deepLoading.test.js +188 -0
  44. package/dist/tests/deepLoading.test.js.map +1 -0
  45. package/dist/tests/groupsAndAccounts.test.js +6 -11
  46. package/dist/tests/groupsAndAccounts.test.js.map +1 -1
  47. package/package.json +12 -6
  48. package/src/coValues/account.ts +60 -58
  49. package/src/coValues/coList.ts +31 -51
  50. package/src/coValues/coMap.ts +27 -21
  51. package/src/coValues/coStream.ts +44 -32
  52. package/src/coValues/deepLoading.ts +215 -0
  53. package/src/coValues/extensions/imageDef.ts +3 -3
  54. package/src/coValues/group.ts +11 -13
  55. package/src/coValues/interfaces.ts +151 -93
  56. package/src/implementation/devtoolsFormatters.ts +1 -0
  57. package/src/implementation/inspect.ts +1 -1
  58. package/src/implementation/refs.ts +29 -15
  59. package/src/implementation/schema.ts +21 -6
  60. package/src/implementation/subscriptionScope.ts +33 -17
  61. package/src/implementation/symbols.ts +0 -1
  62. package/src/index.ts +5 -3
  63. package/src/internal.ts +3 -2
  64. package/src/tests/coList.test.ts +33 -28
  65. package/src/tests/coMap.test.ts +63 -55
  66. package/src/tests/coStream.test.ts +82 -67
  67. package/src/tests/deepLoading.test.ts +301 -0
  68. package/src/tests/groupsAndAccounts.test.ts +9 -18
@@ -1,16 +1,7 @@
1
- import { expect, describe, test, beforeEach } from "vitest";
1
+ import { expect, describe, test } from "vitest";
2
+ import { Account, CoMap, co, Group, WasmCrypto } from "../index.js";
2
3
 
3
- import { webcrypto } from "node:crypto";
4
- import { Account, jazzReady, CoMap, co, Group } from "..";
5
-
6
- if (!("crypto" in globalThis)) {
7
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
- (globalThis as any).crypto = webcrypto;
9
- }
10
-
11
- beforeEach(async () => {
12
- await jazzReady;
13
- });
4
+ const Crypto = await WasmCrypto.create();
14
5
 
15
6
  describe("Custom accounts and groups", async () => {
16
7
  class CustomProfile extends CoMap {
@@ -28,7 +19,7 @@ describe("Custom accounts and groups", async () => {
28
19
  profileGroup.addMember("everyone", "reader");
29
20
  this.profile = CustomProfile.create(
30
21
  { name: creationProps.name, color: "blue" },
31
- { owner: this }
22
+ { owner: this },
32
23
  );
33
24
  }
34
25
  }
@@ -44,11 +35,10 @@ describe("Custom accounts and groups", async () => {
44
35
  }
45
36
  }
46
37
 
47
- type T = CustomGroup[typeof co.members];
48
-
49
38
  test("Custom account and group", async () => {
50
39
  const me = await CustomAccount.create({
51
40
  creationProps: { name: "Hermes Puggington" },
41
+ crypto: Crypto,
52
42
  });
53
43
 
54
44
  expect(me.profile).toBeDefined();
@@ -66,13 +56,13 @@ describe("Custom accounts and groups", async () => {
66
56
  expect(group.nMembers).toBe(2);
67
57
 
68
58
  await new Promise<void>((resolve) => {
69
- group.subscribe((update) => {
59
+ CustomGroup.subscribe(group, {}, (update) => {
70
60
  const meAsMember = update.members.find((member) => {
71
61
  return member.id === me.id && member.account?.profile;
72
62
  });
73
63
  if (meAsMember) {
74
64
  expect(meAsMember.account?.profile?.name).toBe(
75
- "Hermes Puggington"
65
+ "Hermes Puggington",
76
66
  );
77
67
  expect(meAsMember.account?.profile?.color).toBe("blue");
78
68
  resolve();
@@ -90,10 +80,11 @@ describe("Custom accounts and groups", async () => {
90
80
  .as(CustomGroup)
91
81
  .members.find((member) => member.id === me.id);
92
82
  expect(meAsCastMember?.account?.profile?.name).toBe(
93
- "Hermes Puggington"
83
+ "Hermes Puggington",
94
84
  );
95
85
  expect(meAsCastMember?.account?.profile?.color).toBe("blue");
96
86
 
87
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
97
88
  expect((map._owner as any).nMembers).toBeUndefined();
98
89
  expect(map._owner.as(CustomGroup).nMembers).toBe(2);
99
90
  });