jazz-tools 0.19.10 → 0.19.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.
Files changed (112) hide show
  1. package/.turbo/turbo-build.log +58 -54
  2. package/CHANGELOG.md +23 -0
  3. package/dist/{chunk-FFEEPZEG.js → chunk-AGF4HEDH.js} +61 -28
  4. package/dist/chunk-AGF4HEDH.js.map +1 -0
  5. package/dist/index.js +1 -1
  6. package/dist/inspector/account-switcher.d.ts +4 -0
  7. package/dist/inspector/account-switcher.d.ts.map +1 -0
  8. package/dist/inspector/chunk-YQNK5Y7B.js +4108 -0
  9. package/dist/inspector/chunk-YQNK5Y7B.js.map +1 -0
  10. package/dist/inspector/contexts/node.d.ts +19 -0
  11. package/dist/inspector/contexts/node.d.ts.map +1 -0
  12. package/dist/inspector/{custom-element-P76EIWEV.js → custom-element-KYV64IOC.js} +1057 -918
  13. package/dist/inspector/custom-element-KYV64IOC.js.map +1 -0
  14. package/dist/inspector/{viewer/new-app.d.ts → in-app.d.ts} +3 -3
  15. package/dist/inspector/in-app.d.ts.map +1 -0
  16. package/dist/inspector/index.d.ts +0 -11
  17. package/dist/inspector/index.d.ts.map +1 -1
  18. package/dist/inspector/index.js +56 -3910
  19. package/dist/inspector/index.js.map +1 -1
  20. package/dist/inspector/pages/home.d.ts +2 -0
  21. package/dist/inspector/pages/home.d.ts.map +1 -0
  22. package/dist/inspector/register-custom-element.js +1 -1
  23. package/dist/inspector/router/context.d.ts +12 -0
  24. package/dist/inspector/router/context.d.ts.map +1 -0
  25. package/dist/inspector/router/hash-router.d.ts +7 -0
  26. package/dist/inspector/router/hash-router.d.ts.map +1 -0
  27. package/dist/inspector/router/in-memory-router.d.ts +7 -0
  28. package/dist/inspector/router/in-memory-router.d.ts.map +1 -0
  29. package/dist/inspector/router/index.d.ts +5 -0
  30. package/dist/inspector/router/index.d.ts.map +1 -0
  31. package/dist/inspector/standalone.d.ts +6 -0
  32. package/dist/inspector/standalone.d.ts.map +1 -0
  33. package/dist/inspector/standalone.js +420 -0
  34. package/dist/inspector/standalone.js.map +1 -0
  35. package/dist/inspector/tests/router/hash-router.test.d.ts +2 -0
  36. package/dist/inspector/tests/router/hash-router.test.d.ts.map +1 -0
  37. package/dist/inspector/tests/router/in-memory-router.test.d.ts +2 -0
  38. package/dist/inspector/tests/router/in-memory-router.test.d.ts.map +1 -0
  39. package/dist/inspector/tests/utils/transactions-changes.test.d.ts +2 -0
  40. package/dist/inspector/tests/utils/transactions-changes.test.d.ts.map +1 -0
  41. package/dist/inspector/ui/modal.d.ts +1 -0
  42. package/dist/inspector/ui/modal.d.ts.map +1 -1
  43. package/dist/inspector/utils/transactions-changes.d.ts +13 -13
  44. package/dist/inspector/utils/transactions-changes.d.ts.map +1 -1
  45. package/dist/inspector/viewer/breadcrumbs.d.ts +1 -7
  46. package/dist/inspector/viewer/breadcrumbs.d.ts.map +1 -1
  47. package/dist/inspector/viewer/header.d.ts +7 -0
  48. package/dist/inspector/viewer/header.d.ts.map +1 -0
  49. package/dist/inspector/viewer/page-stack.d.ts +4 -13
  50. package/dist/inspector/viewer/page-stack.d.ts.map +1 -1
  51. package/dist/inspector/viewer/page.d.ts.map +1 -1
  52. package/dist/react/index.js +4 -1
  53. package/dist/react/index.js.map +1 -1
  54. package/dist/react/provider.d.ts.map +1 -1
  55. package/dist/react-core/index.js +2 -2
  56. package/dist/react-core/index.js.map +1 -1
  57. package/dist/react-native/index.js +4 -1
  58. package/dist/react-native/index.js.map +1 -1
  59. package/dist/react-native-core/index.js +4 -1
  60. package/dist/react-native-core/index.js.map +1 -1
  61. package/dist/react-native-core/provider.d.ts.map +1 -1
  62. package/dist/testing.js +1 -1
  63. package/dist/tools/coValues/account.d.ts +7 -1
  64. package/dist/tools/coValues/account.d.ts.map +1 -1
  65. package/dist/tools/implementation/ContextManager.d.ts.map +1 -1
  66. package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts +8 -1
  67. package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts.map +1 -1
  68. package/dist/tools/implementation/zodSchema/zodCo.d.ts.map +1 -1
  69. package/dist/tools/subscribe/SubscriptionScope.d.ts +3 -6
  70. package/dist/tools/subscribe/SubscriptionScope.d.ts.map +1 -1
  71. package/dist/tools/testing.d.ts.map +1 -1
  72. package/package.json +9 -4
  73. package/src/inspector/account-switcher.tsx +440 -0
  74. package/src/inspector/contexts/node.tsx +129 -0
  75. package/src/inspector/custom-element.tsx +2 -2
  76. package/src/inspector/in-app.tsx +61 -0
  77. package/src/inspector/index.tsx +2 -22
  78. package/src/inspector/pages/home.tsx +77 -0
  79. package/src/inspector/router/context.ts +21 -0
  80. package/src/inspector/router/hash-router.tsx +128 -0
  81. package/src/inspector/{viewer/use-page-path.ts → router/in-memory-router.tsx} +31 -29
  82. package/src/inspector/router/index.ts +4 -0
  83. package/src/inspector/standalone.tsx +60 -0
  84. package/src/inspector/tests/router/hash-router.test.tsx +847 -0
  85. package/src/inspector/tests/router/in-memory-router.test.tsx +724 -0
  86. package/src/inspector/tests/utils/transactions-changes.test.ts +102 -0
  87. package/src/inspector/ui/icons/add-icon.tsx +3 -3
  88. package/src/inspector/ui/modal.tsx +5 -2
  89. package/src/inspector/utils/history.ts +6 -6
  90. package/src/inspector/utils/transactions-changes.ts +37 -3
  91. package/src/inspector/viewer/breadcrumbs.tsx +5 -11
  92. package/src/inspector/viewer/header.tsx +67 -0
  93. package/src/inspector/viewer/history-view.tsx +13 -13
  94. package/src/inspector/viewer/page-stack.tsx +18 -26
  95. package/src/inspector/viewer/page.tsx +0 -1
  96. package/src/react/provider.tsx +6 -1
  97. package/src/react-core/hooks.ts +2 -2
  98. package/src/react-core/tests/useSuspenseCoState.test.tsx +47 -0
  99. package/src/react-native-core/provider.tsx +6 -1
  100. package/src/tools/coValues/account.ts +13 -2
  101. package/src/tools/implementation/ContextManager.ts +10 -0
  102. package/src/tools/implementation/zodSchema/schemaTypes/AccountSchema.ts +8 -1
  103. package/src/tools/subscribe/SubscriptionScope.ts +61 -39
  104. package/src/tools/tests/account.test.ts +11 -4
  105. package/src/tools/tests/schema.resolved.test.ts +3 -3
  106. package/tsup.config.ts +1 -0
  107. package/dist/chunk-FFEEPZEG.js.map +0 -1
  108. package/dist/inspector/custom-element-P76EIWEV.js.map +0 -1
  109. package/dist/inspector/viewer/new-app.d.ts.map +0 -1
  110. package/dist/inspector/viewer/use-page-path.d.ts +0 -10
  111. package/dist/inspector/viewer/use-page-path.d.ts.map +0 -1
  112. package/src/inspector/viewer/new-app.tsx +0 -156
@@ -1,5 +1,5 @@
1
1
 
2
- > jazz-tools@0.19.10 build /home/runner/_work/jazz/jazz/packages/jazz-tools
2
+ > jazz-tools@0.19.12 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"}
@@ -10,7 +10,7 @@
10
10
  CLI Using tsconfig: tsconfig.json
11
11
  CLI Building entry: {"index":"src/expo/index.ts","testing":"src/expo/testing.ts","crypto":"src/expo/crypto.ts","polyfills":"src/react-native-core/polyfills/index.js"}
12
12
  CLI Using tsconfig: tsconfig.json
13
- CLI Building entry: {"index":"src/inspector/index.tsx"}
13
+ CLI Building entry: {"index":"src/inspector/index.tsx","standalone":"src/inspector/standalone.tsx"}
14
14
  CLI Using tsconfig: tsconfig.json
15
15
  CLI Building entry: {"register-custom-element":"src/inspector/register-custom-element.ts"}
16
16
  CLI Using tsconfig: tsconfig.json
@@ -107,23 +107,23 @@
107
107
  ESM Build start
108
108
  CLI Cleaning output folder
109
109
  ESM Build start
110
- ESM dist/tiptap/index.js 564.00 B
111
- ESM dist/tiptap/index.js.map 1.21 KB
112
- ESM ⚡️ Build success in 57ms
113
110
  ESM dist/worker/index.js 3.19 KB
114
111
  ESM dist/worker/edge-wasm.js 215.00 B
115
112
  ESM dist/worker/napi-crypto.js 110.00 B
116
113
  ESM dist/worker/index.js.map 6.24 KB
117
114
  ESM dist/worker/edge-wasm.js.map 434.00 B
118
115
  ESM dist/worker/napi-crypto.js.map 162.00 B
119
- ESM ⚡️ Build success in 56ms
116
+ ESM ⚡️ Build success in 49ms
117
+ ESM dist/tiptap/index.js 564.00 B
118
+ ESM dist/tiptap/index.js.map 1.21 KB
119
+ ESM ⚡️ Build success in 52ms
120
120
  ESM dist/better-auth/auth/client.js 4.50 KB
121
121
  ESM dist/better-auth/auth/server.js 8.36 KB
122
122
  ESM dist/better-auth/auth/react.js 799.00 B
123
123
  ESM dist/better-auth/auth/client.js.map 8.32 KB
124
124
  ESM dist/better-auth/auth/server.js.map 15.31 KB
125
125
  ESM dist/better-auth/auth/react.js.map 2.04 KB
126
- ESM ⚡️ Build success in 48ms
126
+ ESM ⚡️ Build success in 43ms
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
@@ -134,84 +134,88 @@
134
134
  ESM dist/media/index.native.js.map 8.10 KB
135
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 71ms
137
+ ESM ⚡️ Build success in 48ms
138
+ ESM dist/react-core/testing.js 1.22 KB
139
+ ESM dist/react-core/index.js 17.05 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/index.js.map 49.77 KB
143
+ ESM dist/react-core/chunk-7DYMJ74I.js.map 533.00 B
144
+ ESM ⚡️ Build success in 47ms
138
145
  ESM dist/expo/index.js 4.68 KB
139
146
  ESM dist/expo/testing.js 112.00 B
140
- ESM dist/expo/crypto.js 153.00 B
141
147
  ESM dist/expo/polyfills.js 858.00 B
148
+ ESM dist/expo/crypto.js 153.00 B
142
149
  ESM dist/expo/index.js.map 10.23 KB
143
150
  ESM dist/expo/testing.js.map 168.00 B
144
- ESM dist/expo/crypto.js.map 189.00 B
145
151
  ESM dist/expo/polyfills.js.map 1.61 KB
146
- ESM ⚡️ Build success in 63ms
147
- ESM dist/react-core/index.js 17.04 KB
148
- ESM dist/react-core/testing.js 1.22 KB
149
- ESM dist/react-core/chunk-7DYMJ74I.js 279.00 B
150
- ESM dist/react-core/index.js.map 49.75 KB
151
- ESM dist/react-core/testing.js.map 1.86 KB
152
- ESM dist/react-core/chunk-7DYMJ74I.js.map 533.00 B
153
- ESM ⚡️ Build success in 86ms
154
- ESM dist/prosemirror/index.js 77.76 KB
155
- ESM dist/prosemirror/index.js.map 307.20 KB
156
- ESM ⚡️ Build success in 97ms
157
- ESM dist/browser/index.js 14.06 KB
158
- ESM dist/browser/index.js.map 29.94 KB
159
- ESM ⚡️ Build success in 103ms
152
+ ESM dist/expo/crypto.js.map 189.00 B
153
+ ESM ⚡️ Build success in 52ms
160
154
  ESM dist/better-auth/database-adapter/index.js 26.65 KB
161
155
  ESM dist/better-auth/database-adapter/index.js.map 58.26 KB
162
- ESM ⚡️ Build success in 89ms
163
- ESM dist/react-native-core/index.js 19.05 KB
164
- ESM dist/react-native-core/crypto.js 2.58 KB
156
+ ESM ⚡️ Build success in 47ms
157
+ ESM dist/browser/index.js 14.06 KB
158
+ ESM dist/browser/index.js.map 29.94 KB
159
+ ESM ⚡️ Build success in 70ms
160
+ ESM dist/prosemirror/index.js 77.76 KB
161
+ ESM dist/prosemirror/index.js.map 307.20 KB
162
+ ESM ⚡️ Build success in 79ms
165
163
  ESM dist/react-native-core/testing.js 119.00 B
164
+ ESM dist/react-native-core/index.js 19.19 KB
166
165
  ESM dist/react-native-core/crypto/RNCrypto.js 120.00 B
167
- ESM dist/react-native-core/index.js.map 38.74 KB
168
- ESM dist/react-native-core/crypto.js.map 5.25 KB
166
+ ESM dist/react-native-core/crypto.js 2.58 KB
169
167
  ESM dist/react-native-core/testing.js.map 175.00 B
168
+ ESM dist/react-native-core/index.js.map 38.96 KB
170
169
  ESM dist/react-native-core/crypto/RNCrypto.js.map 178.00 B
171
- ESM ⚡️ Build success in 105ms
172
- ESM dist/react-native/index.js 21.59 KB
170
+ ESM dist/react-native-core/crypto.js.map 5.25 KB
171
+ ESM ⚡️ Build success in 78ms
172
+ ESM dist/react/testing.js 122.00 B
173
+ ESM dist/react/index.js 25.96 KB
174
+ ESM dist/react/ssr.js 697.00 B
175
+ ESM dist/react/testing.js.map 165.00 B
176
+ ESM dist/react/ssr.js.map 1.11 KB
177
+ ESM dist/react/index.js.map 55.44 KB
178
+ ESM ⚡️ Build success in 70ms
173
179
  ESM dist/react-native/testing.js 120.00 B
174
180
  ESM dist/react-native/crypto.js 161.00 B
175
181
  ESM dist/react-native/polyfills.js 858.00 B
176
- ESM dist/react-native/index.js.map 44.29 KB
182
+ ESM dist/react-native/index.js 21.73 KB
177
183
  ESM dist/react-native/testing.js.map 176.00 B
178
184
  ESM dist/react-native/crypto.js.map 197.00 B
179
185
  ESM dist/react-native/polyfills.js.map 1.61 KB
180
- ESM ⚡️ Build success in 111ms
181
- ESM dist/react/index.js 25.83 KB
182
- ESM dist/react/testing.js 122.00 B
183
- ESM dist/react/ssr.js 697.00 B
184
- ESM dist/react/index.js.map 55.23 KB
185
- ESM dist/react/testing.js.map 165.00 B
186
- ESM dist/react/ssr.js.map 1.11 KB
187
- ESM ⚡️ Build success in 101ms
188
- ESM dist/inspector/index.js 125.80 KB
189
- ESM dist/inspector/index.js.map 216.33 KB
190
- ESM ⚡️ Build success in 164ms
186
+ ESM dist/react-native/index.js.map 44.50 KB
187
+ ESM ⚡️ Build success in 80ms
188
+ ESM dist/inspector/index.js 6.29 KB
189
+ ESM dist/inspector/standalone.js 12.61 KB
190
+ ESM dist/inspector/chunk-YQNK5Y7B.js 127.21 KB
191
+ ESM dist/inspector/index.js.map 9.65 KB
192
+ ESM dist/inspector/standalone.js.map 20.11 KB
193
+ ESM dist/inspector/chunk-YQNK5Y7B.js.map 221.30 KB
194
+ ESM ⚡️ Build success in 91ms
191
195
  ESM dist/index.js 29.76 KB
192
196
  ESM dist/testing.js 8.51 KB
193
- ESM dist/chunk-FFEEPZEG.js 213.13 KB
197
+ ESM dist/chunk-AGF4HEDH.js 214.23 KB
194
198
  ESM dist/tools/ssr.js 156.00 B
195
199
  ESM dist/chunk-M2HGBOXS.js 694.00 B
196
200
  ESM dist/chunk-PZ5AY32C.js 233.00 B
197
- ESM dist/index.js.map 60.59 KB
198
- ESM dist/testing.js.map 16.13 KB
199
- ESM dist/chunk-FFEEPZEG.js.map 502.18 KB
200
201
  ESM dist/tools/ssr.js.map 71.00 B
201
- ESM dist/chunk-M2HGBOXS.js.map 1.10 KB
202
+ ESM dist/testing.js.map 16.13 KB
202
203
  ESM dist/chunk-PZ5AY32C.js.map 71.00 B
203
- ESM ⚡️ Build success in 188ms
204
+ ESM dist/chunk-M2HGBOXS.js.map 1.10 KB
205
+ ESM dist/index.js.map 60.59 KB
206
+ ESM dist/chunk-AGF4HEDH.js.map 504.49 KB
207
+ ESM ⚡️ Build success in 93ms
204
208
  ESM dist/inspector/register-custom-element.js 218.00 B
205
209
  ESM dist/inspector/register-custom-element.js.map 314.00 B
206
- ESM dist/inspector/custom-element-P76EIWEV.js 1.60 MB
207
- ESM dist/inspector/custom-element-P76EIWEV.js.map 2.45 MB
208
- ESM ⚡️ Build success in 238ms
210
+ ESM dist/inspector/custom-element-KYV64IOC.js 1.60 MB
211
+ ESM dist/inspector/custom-element-KYV64IOC.js.map 2.47 MB
212
+ ESM ⚡️ Build success in 141ms
209
213
 
210
- > jazz-tools@0.19.10 types /home/runner/_work/jazz/jazz/packages/jazz-tools
214
+ > jazz-tools@0.19.12 types /home/runner/_work/jazz/jazz/packages/jazz-tools
211
215
  > tsc --outDir dist
212
216
 
213
217
 
214
- > jazz-tools@0.19.10 build:svelte /home/runner/_work/jazz/jazz/packages/jazz-tools
218
+ > jazz-tools@0.19.12 build:svelte /home/runner/_work/jazz/jazz/packages/jazz-tools
215
219
  > rm -rf dist/svelte && svelte-package -i src/svelte -o dist/svelte --tsconfig tsconfig.svelte.json
216
220
 
217
221
  src/svelte -> dist/svelte
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # jazz-tools
2
2
 
3
+ ## 0.19.12
4
+
5
+ ### Patch Changes
6
+
7
+ - 9ca9e72: Fix the inspector to guess correctly Group's transactions
8
+ - 5b0bb7d: Bugfix: ensure that the promises used for Suspense is always cached
9
+ - fa0759b: Bugfix: close the server peers before calling the onAnonymousAccountDiscarded hook, to ensure that there won't be conflicting issues with the new context sync
10
+ - a2372db: Bugfix: ensure onAnonymousAccountDiscarded hook is conditionally applied in React providers
11
+ - cojson@0.19.12
12
+ - cojson-storage-indexeddb@0.19.12
13
+ - cojson-transport-ws@0.19.12
14
+
15
+ ## 0.19.11
16
+
17
+ ### Patch Changes
18
+
19
+ - 68acca4: Sync Server is now configurable in inspector.jazz.tools
20
+ - c00a454: Resolve footgun in Account.createAs() that made it easy to save the wrong credentials.
21
+ - Updated dependencies [c00a454]
22
+ - cojson@0.19.11
23
+ - cojson-storage-indexeddb@0.19.11
24
+ - cojson-transport-ws@0.19.11
25
+
3
26
  ## 0.19.10
4
27
 
5
28
  ### Patch Changes
@@ -2308,6 +2308,10 @@ var _Account = class _Account extends CoValueBase {
2308
2308
  crypto,
2309
2309
  peers: [connectedPeers[0]]
2310
2310
  });
2311
+ const credentials = {
2312
+ accountID: account.$jazz.id,
2313
+ accountSecret: account.$jazz.localNode.getCurrentAgent().agentSecret
2314
+ };
2311
2315
  const loadedWorker = await _Account.load(worker.$jazz.id, {
2312
2316
  loadAs: account
2313
2317
  });
@@ -2321,7 +2325,7 @@ var _Account = class _Account extends CoValueBase {
2321
2325
  if (!createdAccount.$isLoaded)
2322
2326
  throw new Error("Unable to load the created account");
2323
2327
  account.$jazz.localNode.gracefulShutdown();
2324
- return createdAccount;
2328
+ return { credentials, account: createdAccount };
2325
2329
  }
2326
2330
  static fromNode(node) {
2327
2331
  return new this({
@@ -4417,14 +4421,6 @@ var SubscriptionScope = class _SubscriptionScope {
4417
4421
  if (this.value.type !== CoValueLoadingState.LOADED) return true;
4418
4422
  return this.pendingLoadedChildren.size === 0;
4419
4423
  }
4420
- cachePromise(value, callback) {
4421
- if (this.lastPromise?.value === value) {
4422
- return this.lastPromise.promise;
4423
- }
4424
- const promise = callback();
4425
- this.lastPromise = { value, promise };
4426
- return promise;
4427
- }
4428
4424
  getPromise() {
4429
4425
  const currentValue = this.getCurrentValue();
4430
4426
  if (currentValue.$isLoaded) {
@@ -4438,26 +4434,57 @@ var SubscriptionScope = class _SubscriptionScope {
4438
4434
  })
4439
4435
  );
4440
4436
  }
4441
- return this.cachePromise(currentValue, () => {
4442
- return new Promise((resolve, reject) => {
4443
- const unsubscribe = this.subscribe(() => {
4444
- const currentValue2 = this.getCurrentValue();
4445
- if (currentValue2.$jazz.loadingState === CoValueLoadingState.LOADING) {
4446
- return;
4447
- }
4448
- if (currentValue2.$isLoaded) {
4449
- resolve(currentValue2);
4450
- } else {
4451
- reject(
4452
- new Error(this.getError()?.toString() ?? "Unknown error", {
4453
- cause: this.callerStack
4454
- })
4455
- );
4456
- }
4457
- unsubscribe();
4458
- });
4437
+ const promise = new Promise((resolve, reject) => {
4438
+ const unsubscribe = this.subscribe(() => {
4439
+ const currentValue2 = this.getCurrentValue();
4440
+ if (currentValue2.$jazz.loadingState === CoValueLoadingState.LOADING) {
4441
+ return;
4442
+ }
4443
+ if (currentValue2.$isLoaded) {
4444
+ promise.status = "fulfilled";
4445
+ promise.value = currentValue2;
4446
+ resolve(currentValue2);
4447
+ } else {
4448
+ promise.status = "rejected";
4449
+ promise.reason = new Error(
4450
+ this.getError()?.toString() ?? "Unknown error",
4451
+ {
4452
+ cause: this.callerStack
4453
+ }
4454
+ );
4455
+ reject(
4456
+ new Error(this.getError()?.toString() ?? "Unknown error", {
4457
+ cause: this.callerStack
4458
+ })
4459
+ );
4460
+ }
4461
+ unsubscribe();
4459
4462
  });
4460
4463
  });
4464
+ promise.status = "pending";
4465
+ return promise;
4466
+ }
4467
+ getCachedPromise() {
4468
+ if (this.lastPromise) {
4469
+ const value = this.getCurrentValue();
4470
+ if (value.$isLoaded) {
4471
+ this.lastPromise.status = "fulfilled";
4472
+ this.lastPromise.value = value;
4473
+ } else if (value.$jazz.loadingState !== CoValueLoadingState.LOADING) {
4474
+ this.lastPromise.status = "rejected";
4475
+ this.lastPromise.reason = new Error(
4476
+ this.getError()?.toString() ?? "Unknown error",
4477
+ {
4478
+ cause: this.callerStack
4479
+ }
4480
+ );
4481
+ } else if (this.lastPromise.status !== "pending") {
4482
+ this.lastPromise = this.getPromise();
4483
+ }
4484
+ } else {
4485
+ this.lastPromise = this.getPromise();
4486
+ }
4487
+ return this.lastPromise;
4461
4488
  }
4462
4489
  getUnloadedValue(reason) {
4463
4490
  if (this.unloadedValue?.$jazz.loadingState === reason) {
@@ -6856,6 +6883,12 @@ var JazzContextManager = class {
6856
6883
  }
6857
6884
  );
6858
6885
  prevContext.node.removeStorage();
6886
+ for (const peer of Object.values(prevContext.node.syncManager.peers)) {
6887
+ if (!peer.closed) {
6888
+ peer.gracefulShutdown();
6889
+ }
6890
+ }
6891
+ prevContext.node.syncManager.peers = {};
6859
6892
  currentContext.node.syncManager.addPeer(prevAccountAsPeer);
6860
6893
  prevContext.node.syncManager.addPeer(currentAccountAsPeer);
6861
6894
  try {
@@ -7394,4 +7427,4 @@ export {
7394
7427
  JazzContextManager
7395
7428
  };
7396
7429
  /* istanbul ignore file -- @preserve */
7397
- //# sourceMappingURL=chunk-FFEEPZEG.js.map
7430
+ //# sourceMappingURL=chunk-AGF4HEDH.js.map