jazz-tools 0.19.5 → 0.19.6

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.
Files changed (51) hide show
  1. package/.turbo/turbo-build.log +55 -55
  2. package/CHANGELOG.md +15 -0
  3. package/dist/{chunk-DFFRRRRF.js → chunk-GCBXV2KC.js} +67 -15
  4. package/dist/chunk-GCBXV2KC.js.map +1 -0
  5. package/dist/index.js +1 -1
  6. package/dist/inspector/index.d.ts +1 -1
  7. package/dist/inspector/index.d.ts.map +1 -1
  8. package/dist/inspector/index.js +8 -1
  9. package/dist/inspector/index.js.map +1 -1
  10. package/dist/react-core/hooks.d.ts +2 -1
  11. package/dist/react-core/hooks.d.ts.map +1 -1
  12. package/dist/react-core/index.js +39 -15
  13. package/dist/react-core/index.js.map +1 -1
  14. package/dist/react-native-core/crypto/RNQuickCrypto.d.ts +3 -1
  15. package/dist/react-native-core/crypto/RNQuickCrypto.d.ts.map +1 -1
  16. package/dist/react-native-core/crypto.js +23 -1
  17. package/dist/react-native-core/crypto.js.map +1 -1
  18. package/dist/testing.js +1 -1
  19. package/dist/tools/coValues/CoValueBase.d.ts +2 -1
  20. package/dist/tools/coValues/CoValueBase.d.ts.map +1 -1
  21. package/dist/tools/coValues/account.d.ts +3 -2
  22. package/dist/tools/coValues/account.d.ts.map +1 -1
  23. package/dist/tools/coValues/interfaces.d.ts +8 -0
  24. package/dist/tools/coValues/interfaces.d.ts.map +1 -1
  25. package/dist/tools/exports.d.ts +1 -1
  26. package/dist/tools/exports.d.ts.map +1 -1
  27. package/dist/tools/implementation/anonymousJazzAgent.d.ts +5 -0
  28. package/dist/tools/implementation/anonymousJazzAgent.d.ts.map +1 -1
  29. package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts +3 -3
  30. package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts.map +1 -1
  31. package/dist/tools/implementation/zodSchema/zodCo.d.ts.map +1 -1
  32. package/dist/tools/testing.d.ts.map +1 -1
  33. package/dist/tools/tests/utils.d.ts +6 -1
  34. package/dist/tools/tests/utils.d.ts.map +1 -1
  35. package/package.json +5 -5
  36. package/src/inspector/index.tsx +10 -1
  37. package/src/react-core/hooks.ts +65 -21
  38. package/src/react-core/tests/useCoState.test.ts +102 -2
  39. package/src/react-native-core/crypto/RNQuickCrypto.ts +32 -2
  40. package/src/tools/coValues/CoValueBase.ts +11 -1
  41. package/src/tools/coValues/account.ts +30 -6
  42. package/src/tools/coValues/interfaces.ts +25 -1
  43. package/src/tools/exports.ts +1 -0
  44. package/src/tools/implementation/anonymousJazzAgent.ts +21 -1
  45. package/src/tools/implementation/zodSchema/schemaTypes/AccountSchema.ts +9 -4
  46. package/src/tools/tests/account.test.ts +65 -0
  47. package/src/tools/tests/exportImport.test.ts +78 -0
  48. package/src/tools/tests/groupsAndAccounts.test.ts +21 -20
  49. package/src/tools/tests/schema.resolved.test.ts +26 -19
  50. package/src/tools/tests/utils.ts +27 -0
  51. package/dist/chunk-DFFRRRRF.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
 
2
- > jazz-tools@0.19.5 build /home/runner/_work/jazz/jazz/packages/jazz-tools
2
+ > jazz-tools@0.19.6 build /home/runner/_work/jazz/jazz/packages/jazz-tools
3
3
  > tsup && pnpm types && pnpm build:svelte
4
4
 
5
5
  CLI Building entry: {"index":"src/index.ts","testing":"src/testing.ts","tools/ssr":"src/tools/ssr/index.ts"}
@@ -107,23 +107,23 @@
107
107
  ESM Build start
108
108
  CLI Cleaning output folder
109
109
  ESM Build start
110
+ ESM dist/better-auth/auth/client.js 4.50 KB
111
+ ESM dist/better-auth/auth/react.js 799.00 B
112
+ ESM dist/better-auth/auth/server.js 8.36 KB
113
+ ESM dist/better-auth/auth/client.js.map 8.32 KB
114
+ ESM dist/better-auth/auth/react.js.map 2.04 KB
115
+ ESM dist/better-auth/auth/server.js.map 15.31 KB
116
+ ESM ⚡️ Build success in 50ms
110
117
  ESM dist/tiptap/index.js 564.00 B
111
118
  ESM dist/tiptap/index.js.map 1.21 KB
112
- ESM ⚡️ Build success in 74ms
119
+ ESM ⚡️ Build success in 65ms
113
120
  ESM dist/worker/index.js 3.19 KB
114
121
  ESM dist/worker/edge-wasm.js 215.00 B
115
122
  ESM dist/worker/napi-crypto.js 110.00 B
116
123
  ESM dist/worker/index.js.map 6.24 KB
117
124
  ESM dist/worker/edge-wasm.js.map 434.00 B
118
125
  ESM dist/worker/napi-crypto.js.map 162.00 B
119
- ESM ⚡️ Build success in 73ms
120
- ESM dist/better-auth/auth/client.js 4.50 KB
121
- ESM dist/better-auth/auth/server.js 8.36 KB
122
- ESM dist/better-auth/auth/react.js 799.00 B
123
- ESM dist/better-auth/auth/client.js.map 8.32 KB
124
- ESM dist/better-auth/auth/server.js.map 15.31 KB
125
- ESM dist/better-auth/auth/react.js.map 2.04 KB
126
- ESM ⚡️ Build success in 64ms
126
+ ESM ⚡️ Build success in 63ms
127
127
  ESM dist/media/index.js 236.00 B
128
128
  ESM dist/media/index.browser.js 2.79 KB
129
129
  ESM dist/media/index.native.js 4.01 KB
@@ -131,81 +131,81 @@
131
131
  ESM dist/media/chunk-3LKBM3G3.js 6.69 KB
132
132
  ESM dist/media/index.js.map 71.00 B
133
133
  ESM dist/media/index.browser.js.map 6.15 KB
134
- ESM dist/media/index.server.js.map 6.37 KB
135
134
  ESM dist/media/index.native.js.map 8.10 KB
135
+ ESM dist/media/index.server.js.map 6.37 KB
136
136
  ESM dist/media/chunk-3LKBM3G3.js.map 16.99 KB
137
- ESM ⚡️ Build success in 74ms
138
- ESM dist/react-core/testing.js 1.22 KB
139
- ESM dist/react-core/index.js 13.77 KB
140
- ESM dist/react-core/chunk-7DYMJ74I.js 279.00 B
141
- ESM dist/react-core/testing.js.map 1.86 KB
142
- ESM dist/react-core/chunk-7DYMJ74I.js.map 533.00 B
143
- ESM dist/react-core/index.js.map 39.33 KB
144
- ESM ⚡️ Build success in 71ms
137
+ ESM ⚡️ Build success in 63ms
145
138
  ESM dist/react-native/index.js 2.53 KB
146
139
  ESM dist/react-native/testing.js 120.00 B
147
140
  ESM dist/react-native/crypto.js 161.00 B
148
141
  ESM dist/react-native/index.js.map 5.68 KB
149
142
  ESM dist/react-native/testing.js.map 176.00 B
150
143
  ESM dist/react-native/crypto.js.map 197.00 B
151
- ESM ⚡️ Build success in 70ms
144
+ ESM ⚡️ Build success in 60ms
145
+ ESM dist/react-core/index.js 14.41 KB
146
+ ESM dist/react-core/testing.js 1.22 KB
147
+ ESM dist/react-core/chunk-7DYMJ74I.js 279.00 B
148
+ ESM dist/react-core/index.js.map 40.79 KB
149
+ ESM dist/react-core/testing.js.map 1.86 KB
150
+ ESM dist/react-core/chunk-7DYMJ74I.js.map 533.00 B
151
+ ESM ⚡️ Build success in 61ms
152
+ ESM dist/expo/index.js 4.68 KB
153
+ ESM dist/expo/crypto.js 153.00 B
154
+ ESM dist/expo/testing.js 112.00 B
155
+ ESM dist/expo/crypto.js.map 189.00 B
156
+ ESM dist/expo/index.js.map 10.23 KB
157
+ ESM dist/expo/testing.js.map 168.00 B
158
+ ESM ⚡️ Build success in 65ms
152
159
  ESM dist/browser/index.js 14.06 KB
153
160
  ESM dist/browser/index.js.map 29.94 KB
154
- ESM ⚡️ Build success in 94ms
161
+ ESM ⚡️ Build success in 78ms
162
+ ESM dist/prosemirror/index.js 77.76 KB
163
+ ESM dist/prosemirror/index.js.map 307.20 KB
164
+ ESM ⚡️ Build success in 99ms
165
+ ESM dist/better-auth/database-adapter/index.js 26.65 KB
166
+ ESM dist/better-auth/database-adapter/index.js.map 58.26 KB
167
+ ESM ⚡️ Build success in 84ms
155
168
  ESM dist/react-native-core/index.js 18.97 KB
156
169
  ESM dist/react-native-core/testing.js 119.00 B
157
- ESM dist/react-native-core/crypto.js 2.10 KB
170
+ ESM dist/react-native-core/crypto.js 2.58 KB
158
171
  ESM dist/react-native-core/index.js.map 38.60 KB
159
172
  ESM dist/react-native-core/testing.js.map 175.00 B
160
- ESM dist/react-native-core/crypto.js.map 4.25 KB
161
- ESM ⚡️ Build success in 91ms
162
- ESM dist/react/testing.js 122.00 B
173
+ ESM dist/react-native-core/crypto.js.map 5.25 KB
174
+ ESM ⚡️ Build success in 109ms
163
175
  ESM dist/react/index.js 25.74 KB
176
+ ESM dist/react/testing.js 122.00 B
164
177
  ESM dist/react/ssr.js 697.00 B
178
+ ESM dist/react/index.js.map 55.43 KB
165
179
  ESM dist/react/testing.js.map 165.00 B
166
180
  ESM dist/react/ssr.js.map 1.11 KB
167
- ESM dist/react/index.js.map 55.43 KB
168
- ESM ⚡️ Build success in 84ms
169
- ESM dist/expo/index.js 4.68 KB
170
- ESM dist/expo/testing.js 112.00 B
171
- ESM dist/expo/crypto.js 153.00 B
172
- ESM dist/expo/index.js.map 10.23 KB
173
- ESM dist/expo/testing.js.map 168.00 B
174
- ESM dist/expo/crypto.js.map 189.00 B
175
- ESM ⚡️ Build success in 110ms
176
- ESM dist/better-auth/database-adapter/index.js 26.65 KB
177
- ESM dist/better-auth/database-adapter/index.js.map 58.26 KB
178
- ESM ⚡️ Build success in 101ms
179
- ESM dist/prosemirror/index.js 77.76 KB
180
- ESM dist/prosemirror/index.js.map 307.20 KB
181
- ESM ⚡️ Build success in 124ms
182
- ESM dist/inspector/index.js 125.62 KB
183
- ESM dist/inspector/index.js.map 215.96 KB
184
- ESM ⚡️ Build success in 154ms
181
+ ESM ⚡️ Build success in 118ms
182
+ ESM dist/inspector/index.js 125.80 KB
183
+ ESM dist/inspector/index.js.map 216.33 KB
184
+ ESM ⚡️ Build success in 149ms
185
+ ESM dist/index.js 29.30 KB
186
+ ESM dist/testing.js 8.51 KB
187
+ ESM dist/chunk-GCBXV2KC.js 204.27 KB
185
188
  ESM dist/tools/ssr.js 156.00 B
186
189
  ESM dist/chunk-M2HGBOXS.js 694.00 B
187
- ESM dist/testing.js 8.51 KB
188
190
  ESM dist/chunk-PZ5AY32C.js 233.00 B
189
- ESM dist/index.js 29.30 KB
190
- ESM dist/chunk-DFFRRRRF.js 202.73 KB
191
- ESM dist/chunk-M2HGBOXS.js.map 1.10 KB
191
+ ESM dist/index.js.map 60.30 KB
192
192
  ESM dist/testing.js.map 16.17 KB
193
- ESM dist/chunk-PZ5AY32C.js.map 71.00 B
193
+ ESM dist/chunk-GCBXV2KC.js.map 481.22 KB
194
194
  ESM dist/tools/ssr.js.map 71.00 B
195
- ESM dist/chunk-DFFRRRRF.js.map 477.64 KB
196
- ESM dist/index.js.map 60.30 KB
197
- ESM ⚡️ Build success in 208ms
195
+ ESM dist/chunk-M2HGBOXS.js.map 1.10 KB
196
+ ESM dist/chunk-PZ5AY32C.js.map 71.00 B
197
+ ESM ⚡️ Build success in 210ms
198
198
  ESM dist/inspector/register-custom-element.js 218.00 B
199
- ESM dist/inspector/custom-element-P76EIWEV.js 1.60 MB
200
199
  ESM dist/inspector/register-custom-element.js.map 314.00 B
200
+ ESM dist/inspector/custom-element-P76EIWEV.js 1.60 MB
201
201
  ESM dist/inspector/custom-element-P76EIWEV.js.map 2.45 MB
202
- ESM ⚡️ Build success in 229ms
202
+ ESM ⚡️ Build success in 236ms
203
203
 
204
- > jazz-tools@0.19.5 types /home/runner/_work/jazz/jazz/packages/jazz-tools
204
+ > jazz-tools@0.19.6 types /home/runner/_work/jazz/jazz/packages/jazz-tools
205
205
  > tsc --outDir dist
206
206
 
207
207
 
208
- > jazz-tools@0.19.5 build:svelte /home/runner/_work/jazz/jazz/packages/jazz-tools
208
+ > jazz-tools@0.19.6 build:svelte /home/runner/_work/jazz/jazz/packages/jazz-tools
209
209
  > rm -rf dist/svelte && svelte-package -i src/svelte -o dist/svelte --tsconfig tsconfig.svelte.json
210
210
 
211
211
  src/svelte -> dist/svelte
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # jazz-tools
2
2
 
3
+ ## 0.19.6
4
+
5
+ ### Patch Changes
6
+
7
+ - 23782f0: Upgraded `react-native-quick-crypto` to version 1.0.0-beta.21 and switch to using the native blake3 in RNQuickCrypto
8
+
9
+ Breaking: any app that uses RNQuickCrypto will have to upgrade to `react-native-quick-crypto@1.0.0-beta.21`
10
+
11
+ - 56d74e4: Make createAs a public API that can be used to create controlled accounts from workers
12
+ - bc9120b: - Added value.$jazz.export() API and preloaded option in React hooks, to make it possible to pass raw covalue data from React server components to client components
13
+ - Prevent the inspector from rendering during SSR
14
+ - cojson@0.19.6
15
+ - cojson-storage-indexeddb@0.19.6
16
+ - cojson-transport-ws@0.19.6
17
+
3
18
  ## 0.19.5
4
19
 
5
20
  ### Patch Changes
@@ -240,6 +240,12 @@ var CoValueJazzApi = class {
240
240
  }
241
241
  unstable_mergeBranch(subscriptionScope);
242
242
  }
243
+ export() {
244
+ const subscriptionScope = getSubscriptionScope(this.coValue);
245
+ return exportCoValueFromSubscription(
246
+ subscriptionScope
247
+ );
248
+ }
243
249
  };
244
250
 
245
251
  // src/tools/implementation/inspect.ts
@@ -2160,7 +2166,7 @@ import {
2160
2166
  cojsonInternals as cojsonInternals2,
2161
2167
  isAccountRole
2162
2168
  } from "cojson";
2163
- var Account = class extends CoValueBase {
2169
+ var _Account = class _Account extends CoValueBase {
2164
2170
  constructor(options) {
2165
2171
  super();
2166
2172
  if (!("fromRaw" in options)) {
@@ -2288,20 +2294,34 @@ var Account = class extends CoValueBase {
2288
2294
  /**
2289
2295
  * @deprecated Use `co.account(...).createAs` instead.
2290
2296
  */
2291
- static async createAs(as, options) {
2297
+ static async createAs(worker, options) {
2298
+ const crypto = worker.$jazz.localNode.crypto;
2292
2299
  const connectedPeers = cojsonInternals2.connectedPeers(
2293
2300
  "creatingAccount",
2294
- "createdAccount",
2301
+ crypto.uniquenessForHeader(),
2302
+ // Use a unique id for the client peer, so we don't have clashes in the worker node
2295
2303
  { peer1role: "server", peer2role: "client" }
2296
2304
  );
2297
- as.$jazz.localNode.syncManager.addPeer(connectedPeers[1]);
2305
+ worker.$jazz.localNode.syncManager.addPeer(connectedPeers[1]);
2298
2306
  const account = await this.create({
2299
2307
  creationProps: options.creationProps,
2300
- crypto: as.$jazz.localNode.crypto,
2308
+ crypto,
2301
2309
  peers: [connectedPeers[0]]
2302
2310
  });
2311
+ const loadedWorker = await _Account.load(worker.$jazz.id, {
2312
+ loadAs: account
2313
+ });
2314
+ if (!loadedWorker.$isLoaded)
2315
+ throw new Error("Unable to load the worker account");
2316
+ if (options.onCreate) await options.onCreate(account, loadedWorker);
2303
2317
  await account.$jazz.waitForAllCoValuesSync();
2304
- return account;
2318
+ const createdAccount = await this.load(account.$jazz.id, {
2319
+ loadAs: worker
2320
+ });
2321
+ if (!createdAccount.$isLoaded)
2322
+ throw new Error("Unable to load the created account");
2323
+ account.$jazz.localNode.gracefulShutdown();
2324
+ return createdAccount;
2305
2325
  }
2306
2326
  static fromNode(node) {
2307
2327
  return new this({
@@ -2352,7 +2372,7 @@ var Account = class extends CoValueBase {
2352
2372
  }
2353
2373
  };
2354
2374
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2355
- Account._schema = {
2375
+ _Account._schema = {
2356
2376
  profile: {
2357
2377
  ref: () => Profile,
2358
2378
  optional: false
@@ -2362,6 +2382,7 @@ Account._schema = {
2362
2382
  optional: true
2363
2383
  }
2364
2384
  };
2385
+ var Account = _Account;
2365
2386
  var AccountJazzApi = class extends CoValueJazzApi {
2366
2387
  constructor(account, raw) {
2367
2388
  super(account);
@@ -3636,6 +3657,7 @@ var VectorCalculation = {
3636
3657
  };
3637
3658
 
3638
3659
  // src/tools/implementation/anonymousJazzAgent.ts
3660
+ import { isAccountRole as isAccountRole3 } from "cojson";
3639
3661
  var _a;
3640
3662
  _a = TypeSym;
3641
3663
  var AnonymousJazzAgent = class {
@@ -3643,6 +3665,23 @@ var AnonymousJazzAgent = class {
3643
3665
  this.node = node;
3644
3666
  this[_a] = "Anonymous";
3645
3667
  }
3668
+ canWrite(_) {
3669
+ return false;
3670
+ }
3671
+ canRead(value) {
3672
+ const valueOwner = value.$jazz.owner;
3673
+ if (!valueOwner) {
3674
+ return true;
3675
+ }
3676
+ const role = valueOwner.getRoleOf("everyone");
3677
+ return isAccountRole3(role);
3678
+ }
3679
+ canManage(_) {
3680
+ return false;
3681
+ }
3682
+ canAdmin(_) {
3683
+ return false;
3684
+ }
3646
3685
  };
3647
3686
 
3648
3687
  // src/tools/implementation/activeAccountContext.ts
@@ -4720,7 +4759,7 @@ function accessChildById(parent, childId, schema) {
4720
4759
 
4721
4760
  // src/tools/implementation/createContext.ts
4722
4761
  import {
4723
- LocalNode as LocalNode4
4762
+ LocalNode as LocalNode5
4724
4763
  } from "cojson";
4725
4764
  async function randomSessionProvider(accountID, crypto) {
4726
4765
  return {
@@ -4745,7 +4784,7 @@ async function createJazzContextFromExistingCredentials({
4745
4784
  );
4746
4785
  const CurrentAccountSchema = PropsAccountSchema ?? RegisteredSchemas["Account"];
4747
4786
  const AccountClass = coValueClassFromCoValueClassOrSchema(CurrentAccountSchema);
4748
- const node = await LocalNode4.withLoadedAccount({
4787
+ const node = await LocalNode5.withLoadedAccount({
4749
4788
  accountID: credentials.accountID,
4750
4789
  accountSecret: credentials.secret,
4751
4790
  sessionID,
@@ -4789,7 +4828,7 @@ async function createJazzContextForNewAccount({
4789
4828
  }) {
4790
4829
  const CurrentAccountSchema = PropsAccountSchema ?? RegisteredSchemas["Account"];
4791
4830
  const AccountClass = coValueClassFromCoValueClassOrSchema(CurrentAccountSchema);
4792
- const { node } = await LocalNode4.withNewlyCreatedAccount({
4831
+ const { node } = await LocalNode5.withNewlyCreatedAccount({
4793
4832
  creationProps,
4794
4833
  peers,
4795
4834
  crypto,
@@ -4874,7 +4913,7 @@ function createAnonymousJazzContext({
4874
4913
  storage
4875
4914
  }) {
4876
4915
  const agentSecret = crypto.newRandomAgentSecret();
4877
- const node = new LocalNode4(
4916
+ const node = new LocalNode5(
4878
4917
  agentSecret,
4879
4918
  crypto.newRandomSessionID(crypto.getAgentID(agentSecret)),
4880
4919
  crypto
@@ -5675,9 +5714,9 @@ var AccountSchema = class _AccountSchema {
5675
5714
  withSchemaResolveQuery(options, this.resolveQuery)
5676
5715
  );
5677
5716
  }
5678
- /** @internal */
5679
- createAs(as, options) {
5680
- return this.coValueClass.createAs(as, options);
5717
+ // Create an account via worker, useful to generate controlled accounts from the server
5718
+ createAs(worker, options) {
5719
+ return this.coValueClass.createAs(worker, options);
5681
5720
  }
5682
5721
  unstable_merge(id, options) {
5683
5722
  return unstable_mergeBranchWithResolve(
@@ -6878,6 +6917,19 @@ async function exportCoValue(cls, id, options) {
6878
6917
  loadContentPiecesFromSubscription(rootNode, valuesExported, contentPieces);
6879
6918
  return contentPieces;
6880
6919
  }
6920
+ function exportCoValueFromSubscription(subscription) {
6921
+ const valuesExported = /* @__PURE__ */ new Set();
6922
+ const contentPieces = [];
6923
+ loadContentPiecesFromSubscription(
6924
+ subscription,
6925
+ valuesExported,
6926
+ contentPieces
6927
+ );
6928
+ return {
6929
+ id: subscription.id,
6930
+ contentPieces
6931
+ };
6932
+ }
6881
6933
  function loadContentPiecesFromSubscription(subscription, valuesExported, contentPieces) {
6882
6934
  if (valuesExported.has(subscription.id)) {
6883
6935
  return;
@@ -7008,4 +7060,4 @@ export {
7008
7060
  JazzContextManager
7009
7061
  };
7010
7062
  /* istanbul ignore file -- @preserve */
7011
- //# sourceMappingURL=chunk-DFFRRRRF.js.map
7063
+ //# sourceMappingURL=chunk-GCBXV2KC.js.map