cojson 0.7.0 → 0.7.9

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/CHANGELOG.md CHANGED
@@ -1,183 +1,189 @@
1
1
  # cojson
2
2
 
3
+ ## 0.7.9
4
+
5
+ ### Patch Changes
6
+
7
+ - Cache currentAgentID in RawAccount
8
+
3
9
  ## 0.7.0
4
10
 
5
11
  ### Minor Changes
6
12
 
7
- - e299c3e: New simplified API
13
+ - e299c3e: New simplified API
8
14
 
9
15
  ### Patch Changes
10
16
 
11
- - 1a35307: WIP working-ish version of LSM storage
12
- - 96c494f: Implement profile visibility based on groups & new migration signature
13
- - 19f52b7: Fixed bug with newRandomSessionID being called before crypto was ready
14
- - d8fe2b1: Expose experimental OPFS storage
15
- - 1200aae: CoJSON performance improvement
16
- - 52675c9: Fix CoList.splice / RawCoList.append
17
- - 1a35307: Optimizations for incoming sync messages
18
- - bf0f8ec: Fix noble curves dependency
19
- - c4151fc: Support stricter TS lint rules
20
- - 8636319: Factor out implementation of crypto provider and provide pure JS implementation
21
- - 952982e: Consistent proxy based API
22
- - 21771c4: Reintroduce changes from main
23
- - 69ac514: Use effect schema much less
24
- - f0f6f1b: Clean up API more & re-add jazz-nodejs
25
- - 1a44f87: Refactoring
26
- - 63374cc: Make sure delete on CoMaps deletes keys
17
+ - 1a35307: WIP working-ish version of LSM storage
18
+ - 96c494f: Implement profile visibility based on groups & new migration signature
19
+ - 19f52b7: Fixed bug with newRandomSessionID being called before crypto was ready
20
+ - d8fe2b1: Expose experimental OPFS storage
21
+ - 1200aae: CoJSON performance improvement
22
+ - 52675c9: Fix CoList.splice / RawCoList.append
23
+ - 1a35307: Optimizations for incoming sync messages
24
+ - bf0f8ec: Fix noble curves dependency
25
+ - c4151fc: Support stricter TS lint rules
26
+ - 8636319: Factor out implementation of crypto provider and provide pure JS implementation
27
+ - 952982e: Consistent proxy based API
28
+ - 21771c4: Reintroduce changes from main
29
+ - 69ac514: Use effect schema much less
30
+ - f0f6f1b: Clean up API more & re-add jazz-nodejs
31
+ - 1a44f87: Refactoring
32
+ - 63374cc: Make sure delete on CoMaps deletes keys
27
33
 
28
34
  ## 0.7.0-alpha.42
29
35
 
30
36
  ### Patch Changes
31
37
 
32
- - Fixed bug with newRandomSessionID being called before crypto was ready
38
+ - Fixed bug with newRandomSessionID being called before crypto was ready
33
39
 
34
40
  ## 0.7.0-alpha.39
35
41
 
36
42
  ### Patch Changes
37
43
 
38
- - Fix noble curves dependency
44
+ - Fix noble curves dependency
39
45
 
40
46
  ## 0.7.0-alpha.38
41
47
 
42
48
  ### Patch Changes
43
49
 
44
- - Factor out implementation of crypto provider and provide pure JS implementation
50
+ - Factor out implementation of crypto provider and provide pure JS implementation
45
51
 
46
52
  ## 0.7.0-alpha.37
47
53
 
48
54
  ### Patch Changes
49
55
 
50
- - Expose experimental OPFS storage
56
+ - Expose experimental OPFS storage
51
57
 
52
58
  ## 0.7.0-alpha.36
53
59
 
54
60
  ### Patch Changes
55
61
 
56
- - 1a35307: WIP working-ish version of LSM storage
57
- - 1a35307: Optimizations for incoming sync messages
62
+ - 1a35307: WIP working-ish version of LSM storage
63
+ - 1a35307: Optimizations for incoming sync messages
58
64
 
59
65
  ## 0.7.0-alpha.35
60
66
 
61
67
  ### Patch Changes
62
68
 
63
- - CoJSON performance improvement
69
+ - CoJSON performance improvement
64
70
 
65
71
  ## 0.7.0-alpha.29
66
72
 
67
73
  ### Patch Changes
68
74
 
69
- - Reintroduce changes from main
75
+ - Reintroduce changes from main
70
76
 
71
77
  ## 0.7.0-alpha.28
72
78
 
73
79
  ### Patch Changes
74
80
 
75
- - Implement profile visibility based on groups & new migration signature
81
+ - Implement profile visibility based on groups & new migration signature
76
82
 
77
83
  ## 0.7.0-alpha.27
78
84
 
79
85
  ### Patch Changes
80
86
 
81
- - Fix CoList.splice / RawCoList.append
87
+ - Fix CoList.splice / RawCoList.append
82
88
 
83
89
  ## 0.7.0-alpha.24
84
90
 
85
91
  ### Patch Changes
86
92
 
87
- - Make sure delete on CoMaps deletes keys
93
+ - Make sure delete on CoMaps deletes keys
88
94
 
89
95
  ## 0.7.0-alpha.11
90
96
 
91
97
  ### Patch Changes
92
98
 
93
- - Support stricter TS lint rules
99
+ - Support stricter TS lint rules
94
100
 
95
101
  ## 0.7.0-alpha.10
96
102
 
97
103
  ### Patch Changes
98
104
 
99
- - Clean up API more & re-add jazz-nodejs
105
+ - Clean up API more & re-add jazz-nodejs
100
106
 
101
107
  ## 0.7.0-alpha.7
102
108
 
103
109
  ### Patch Changes
104
110
 
105
- - Consistent proxy based API
111
+ - Consistent proxy based API
106
112
 
107
113
  ## 0.7.0-alpha.5
108
114
 
109
115
  ### Patch Changes
110
116
 
111
- - Refactoring
117
+ - Refactoring
112
118
 
113
119
  ## 0.7.0-alpha.1
114
120
 
115
121
  ### Patch Changes
116
122
 
117
- - Use effect schema much less
123
+ - Use effect schema much less
118
124
 
119
125
  ## 0.7.0-alpha.0
120
126
 
121
127
  ### Minor Changes
122
128
 
123
- - New simplified API
129
+ - New simplified API
124
130
 
125
131
  ## 0.6.6
126
132
 
127
133
  ### Patch Changes
128
134
 
129
- - Fix migration changes being lost on loaded account
135
+ - Fix migration changes being lost on loaded account
130
136
 
131
137
  ## 0.6.5
132
138
 
133
139
  ### Patch Changes
134
140
 
135
- - Fix loading of accounts
141
+ - Fix loading of accounts
136
142
 
137
143
  ## 0.6.4
138
144
 
139
145
  ### Patch Changes
140
146
 
141
- - IndexedDB & timer perf improvements
147
+ - IndexedDB & timer perf improvements
142
148
 
143
149
  ## 0.6.3
144
150
 
145
151
  ### Patch Changes
146
152
 
147
- - Implement passphrase based auth
153
+ - Implement passphrase based auth
148
154
 
149
155
  ## 0.6.2
150
156
 
151
157
  ### Patch Changes
152
158
 
153
- - Add peersToLoadFrom for node creation as well
159
+ - Add peersToLoadFrom for node creation as well
154
160
 
155
161
  ## 0.6.1
156
162
 
157
163
  ### Patch Changes
158
164
 
159
- - Provide localNode to AccountMigrations
165
+ - Provide localNode to AccountMigrations
160
166
 
161
167
  ## 0.6.0
162
168
 
163
169
  ### Minor Changes
164
170
 
165
- - Make addMember and removeMember take loaded Accounts instead of just IDs
171
+ - Make addMember and removeMember take loaded Accounts instead of just IDs
166
172
 
167
173
  ## 0.5.2
168
174
 
169
175
  ### Patch Changes
170
176
 
171
- - Allow account migrations to be async
177
+ - Allow account migrations to be async
172
178
 
173
179
  ## 0.5.1
174
180
 
175
181
  ### Patch Changes
176
182
 
177
- - Fix bug where accounts, profiles and data created in migrations isn't synced on account creation
183
+ - Fix bug where accounts, profiles and data created in migrations isn't synced on account creation
178
184
 
179
185
  ## 0.5.0
180
186
 
181
187
  ### Minor Changes
182
188
 
183
- - Adding a lot of performance improvements to cojson, add a stresstest for the twit example and make that run smoother in a lot of ways.
189
+ - Adding a lot of performance improvements to cojson, add a stresstest for the twit example and make that run smoother in a lot of ways.
package/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2023, Garden Computing, Inc.
1
+ Copyright 2024, Garden Computing, Inc.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
@@ -14,10 +14,14 @@ export function accountHeaderForInitialAgentSecret(agentSecret, crypto) {
14
14
  }
15
15
  export class RawAccount extends RawGroup {
16
16
  currentAgentID() {
17
+ if (this._cachedCurrentAgentID) {
18
+ return this._cachedCurrentAgentID;
19
+ }
17
20
  const agents = this.keys().filter((k) => k.startsWith("sealer_"));
18
21
  if (agents.length !== 1) {
19
22
  throw new Error("Expected exactly one agent in account, got " + agents.length);
20
23
  }
24
+ this._cachedCurrentAgentID = agents[0];
21
25
  return agents[0];
22
26
  }
23
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"account.js","sourceRoot":"","sources":["../../src/coValues/account.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EA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AC;IACpD,CAAC;IAED,cAAc;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACpD,CAAC;IAED,eAAe;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;IAC/D,CAAC;IAED,mBAAmB;QACf,OAAO,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC9D,CAAC;IAED,eAAe;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;IAC/D,CAAC;IAED,mBAAmB;QACf,OAAO,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC9D,CAAC;CACJ;AASD,MAAM,OAAO,UAGX,SAAQ,QAAqB;CAAG"}
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "types": "src/index.ts",
6
6
  "type": "module",
7
7
  "license": "MIT",
8
- "version": "0.7.0",
8
+ "version": "0.7.9",
9
9
  "devDependencies": {
10
10
  "@types/jest": "^29.5.3",
11
11
  "@typescript-eslint/eslint-plugin": "^6.2.1",
@@ -33,7 +33,12 @@ export function accountHeaderForInitialAgentSecret(
33
33
  export class RawAccount<
34
34
  Meta extends AccountMeta = AccountMeta,
35
35
  > extends RawGroup<Meta> {
36
+ _cachedCurrentAgentID: AgentID | undefined;
37
+
36
38
  currentAgentID(): AgentID {
39
+ if (this._cachedCurrentAgentID) {
40
+ return this._cachedCurrentAgentID;
41
+ }
37
42
  const agents = this.keys().filter((k): k is AgentID =>
38
43
  k.startsWith("sealer_"),
39
44
  );
@@ -44,6 +49,8 @@ export class RawAccount<
44
49
  );
45
50
  }
46
51
 
52
+ this._cachedCurrentAgentID = agents[0];
53
+
47
54
  return agents[0]!;
48
55
  }
49
56
  }