jazz-tools 0.19.7 → 0.19.8

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 (110) hide show
  1. package/.turbo/turbo-build.log +61 -57
  2. package/CHANGELOG.md +15 -0
  3. package/dist/{chunk-CUS6O5NE.js → chunk-2S3Z2CN6.js} +116 -49
  4. package/dist/chunk-2S3Z2CN6.js.map +1 -0
  5. package/dist/expo/polyfills.js +22 -0
  6. package/dist/expo/polyfills.js.map +1 -0
  7. package/dist/index.js +26 -6
  8. package/dist/index.js.map +1 -1
  9. package/dist/react-core/hooks.d.ts.map +1 -1
  10. package/dist/react-core/index.js +17 -6
  11. package/dist/react-core/index.js.map +1 -1
  12. package/dist/react-native/index.d.ts +1 -1
  13. package/dist/react-native/index.d.ts.map +1 -1
  14. package/dist/react-native/index.js +713 -9
  15. package/dist/react-native/index.js.map +1 -1
  16. package/dist/react-native/polyfills.js +22 -0
  17. package/dist/react-native/polyfills.js.map +1 -0
  18. package/dist/react-native-core/index.d.ts.map +1 -1
  19. package/dist/react-native-core/index.js.map +1 -1
  20. package/dist/testing.js +1 -1
  21. package/dist/tools/coValues/account.d.ts +3 -3
  22. package/dist/tools/coValues/account.d.ts.map +1 -1
  23. package/dist/tools/coValues/coFeed.d.ts +3 -3
  24. package/dist/tools/coValues/coFeed.d.ts.map +1 -1
  25. package/dist/tools/coValues/coList.d.ts +4 -4
  26. package/dist/tools/coValues/coList.d.ts.map +1 -1
  27. package/dist/tools/coValues/coMap.d.ts +7 -7
  28. package/dist/tools/coValues/coMap.d.ts.map +1 -1
  29. package/dist/tools/coValues/coPlainText.d.ts +2 -2
  30. package/dist/tools/coValues/coPlainText.d.ts.map +1 -1
  31. package/dist/tools/coValues/coVector.d.ts +2 -2
  32. package/dist/tools/coValues/coVector.d.ts.map +1 -1
  33. package/dist/tools/coValues/deepLoading.d.ts +24 -0
  34. package/dist/tools/coValues/deepLoading.d.ts.map +1 -1
  35. package/dist/tools/coValues/group.d.ts +2 -2
  36. package/dist/tools/coValues/group.d.ts.map +1 -1
  37. package/dist/tools/coValues/interfaces.d.ts +6 -6
  38. package/dist/tools/coValues/interfaces.d.ts.map +1 -1
  39. package/dist/tools/coValues/schemaUnion.d.ts +2 -2
  40. package/dist/tools/coValues/schemaUnion.d.ts.map +1 -1
  41. package/dist/tools/config.d.ts +3 -0
  42. package/dist/tools/config.d.ts.map +1 -0
  43. package/dist/tools/exports.d.ts +2 -0
  44. package/dist/tools/exports.d.ts.map +1 -1
  45. package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts +2 -2
  46. package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts.map +1 -1
  47. package/dist/tools/implementation/zodSchema/schemaTypes/CoDiscriminatedUnionSchema.d.ts +2 -2
  48. package/dist/tools/implementation/zodSchema/schemaTypes/CoDiscriminatedUnionSchema.d.ts.map +1 -1
  49. package/dist/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts +2 -2
  50. package/dist/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts.map +1 -1
  51. package/dist/tools/implementation/zodSchema/schemaTypes/CoListSchema.d.ts +4 -4
  52. package/dist/tools/implementation/zodSchema/schemaTypes/CoListSchema.d.ts.map +1 -1
  53. package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts +4 -4
  54. package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts.map +1 -1
  55. package/dist/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts +4 -4
  56. package/dist/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts.map +1 -1
  57. package/dist/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts +2 -2
  58. package/dist/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts.map +1 -1
  59. package/dist/tools/implementation/zodSchema/schemaTypes/GroupSchema.d.ts +2 -2
  60. package/dist/tools/implementation/zodSchema/schemaTypes/GroupSchema.d.ts.map +1 -1
  61. package/dist/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts +2 -2
  62. package/dist/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts.map +1 -1
  63. package/dist/tools/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts +2 -2
  64. package/dist/tools/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts.map +1 -1
  65. package/dist/tools/implementation/zodSchema/zodCo.d.ts.map +1 -1
  66. package/dist/tools/subscribe/JazzError.d.ts.map +1 -1
  67. package/dist/tools/subscribe/SubscriptionScope.d.ts +10 -1
  68. package/dist/tools/subscribe/SubscriptionScope.d.ts.map +1 -1
  69. package/dist/tools/subscribe/errorReporting.d.ts +31 -0
  70. package/dist/tools/subscribe/errorReporting.d.ts.map +1 -0
  71. package/dist/tools/testing.d.ts.map +1 -1
  72. package/dist/tools/tests/errorReporting.test.d.ts +2 -0
  73. package/dist/tools/tests/errorReporting.test.d.ts.map +1 -0
  74. package/package.json +13 -5
  75. package/src/react-core/hooks.ts +16 -0
  76. package/src/react-native/index.ts +1 -1
  77. package/src/react-native-core/index.ts +2 -0
  78. package/src/react-native-core/polyfills/index.js +28 -0
  79. package/src/tools/coValues/account.ts +3 -4
  80. package/src/tools/coValues/coFeed.ts +3 -2
  81. package/src/tools/coValues/coList.ts +4 -4
  82. package/src/tools/coValues/coMap.ts +4 -4
  83. package/src/tools/coValues/coPlainText.ts +2 -2
  84. package/src/tools/coValues/coVector.ts +2 -2
  85. package/src/tools/coValues/deepLoading.ts +31 -0
  86. package/src/tools/coValues/group.ts +2 -2
  87. package/src/tools/coValues/interfaces.ts +19 -23
  88. package/src/tools/coValues/schemaUnion.ts +2 -2
  89. package/src/tools/config.ts +9 -0
  90. package/src/tools/exports.ts +4 -0
  91. package/src/tools/implementation/zodSchema/schemaTypes/AccountSchema.ts +2 -2
  92. package/src/tools/implementation/zodSchema/schemaTypes/CoDiscriminatedUnionSchema.ts +2 -2
  93. package/src/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.ts +2 -2
  94. package/src/tools/implementation/zodSchema/schemaTypes/CoListSchema.ts +4 -4
  95. package/src/tools/implementation/zodSchema/schemaTypes/CoMapSchema.ts +4 -4
  96. package/src/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.ts +4 -10
  97. package/src/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.ts +2 -2
  98. package/src/tools/implementation/zodSchema/schemaTypes/GroupSchema.ts +2 -2
  99. package/src/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.ts +2 -2
  100. package/src/tools/implementation/zodSchema/schemaTypes/RichTextSchema.ts +2 -2
  101. package/src/tools/subscribe/JazzError.ts +9 -6
  102. package/src/tools/subscribe/SubscriptionScope.ts +110 -27
  103. package/src/tools/subscribe/errorReporting.ts +67 -0
  104. package/src/tools/tests/deepLoading.test.ts +47 -47
  105. package/src/tools/tests/errorReporting.test.ts +103 -0
  106. package/src/tools/tests/load.test.ts +21 -1
  107. package/src/tools/tests/request.test.ts +2 -1
  108. package/src/tools/tests/subscribe.test.ts +44 -0
  109. package/tsup.config.ts +16 -0
  110. package/dist/chunk-CUS6O5NE.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
 
2
- > jazz-tools@0.19.7 build /home/runner/_work/jazz/jazz/packages/jazz-tools
2
+ > jazz-tools@0.19.8 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"}
@@ -8,7 +8,7 @@
8
8
  CLI Using tsconfig: tsconfig.json
9
9
  CLI Building entry: {"index":"src/media/index.ts","index.browser":"src/media/index.browser.ts","index.native":"src/media/index.native.ts","index.server":"src/media/index.server.ts"}
10
10
  CLI Using tsconfig: tsconfig.json
11
- CLI Building entry: {"index":"src/expo/index.ts","testing":"src/expo/testing.ts","crypto":"src/expo/crypto.ts"}
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
13
  CLI Building entry: {"index":"src/inspector/index.tsx"}
14
14
  CLI Using tsconfig: tsconfig.json
@@ -20,7 +20,7 @@
20
20
  CLI Using tsconfig: tsconfig.json
21
21
  CLI Building entry: {"index":"src/react-core/index.ts","testing":"src/react-core/testing.tsx"}
22
22
  CLI Using tsconfig: tsconfig.json
23
- CLI Building entry: {"index":"src/react-native/index.ts","testing":"src/react-native/testing.ts","crypto":"src/react-native/crypto.ts"}
23
+ CLI Building entry: {"index":"src/react-native/index.ts","testing":"src/react-native/testing.ts","crypto":"src/react-native/crypto.ts","polyfills":"src/react-native-core/polyfills/index.js"}
24
24
  CLI Using tsconfig: tsconfig.json
25
25
  CLI Building entry: {"index":"src/react-native-core/index.ts","testing":"src/react-native-core/testing.tsx","crypto":"src/react-native-core/crypto/index.ts"}
26
26
  CLI Using tsconfig: tsconfig.json
@@ -107,105 +107,109 @@
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 51ms
110
113
  ESM dist/worker/index.js 3.19 KB
111
- ESM dist/worker/napi-crypto.js 110.00 B
112
114
  ESM dist/worker/edge-wasm.js 215.00 B
115
+ ESM dist/worker/napi-crypto.js 110.00 B
113
116
  ESM dist/worker/index.js.map 6.24 KB
114
- ESM dist/worker/napi-crypto.js.map 162.00 B
115
117
  ESM dist/worker/edge-wasm.js.map 434.00 B
116
- ESM ⚡️ Build success in 39ms
117
- ESM dist/tiptap/index.js 564.00 B
118
- ESM dist/tiptap/index.js.map 1.21 KB
119
- ESM ⚡️ Build success in 54ms
118
+ ESM dist/worker/napi-crypto.js.map 162.00 B
119
+ ESM ⚡️ Build success in 50ms
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 43ms
127
- ESM dist/react-native/index.js 2.53 KB
128
- ESM dist/react-native/testing.js 120.00 B
129
- ESM dist/react-native/crypto.js 161.00 B
130
- ESM dist/react-native/testing.js.map 176.00 B
131
- ESM dist/react-native/index.js.map 5.68 KB
132
- ESM dist/react-native/crypto.js.map 197.00 B
133
- ESM ⚡️ Build success in 45ms
126
+ ESM ⚡️ Build success in 51ms
134
127
  ESM dist/media/index.js 236.00 B
135
- ESM dist/media/index.server.js 2.95 KB
136
128
  ESM dist/media/index.browser.js 2.79 KB
137
129
  ESM dist/media/index.native.js 4.01 KB
130
+ ESM dist/media/index.server.js 2.95 KB
138
131
  ESM dist/media/chunk-3LKBM3G3.js 6.69 KB
139
132
  ESM dist/media/index.js.map 71.00 B
140
133
  ESM dist/media/index.browser.js.map 6.15 KB
141
- ESM dist/media/index.server.js.map 6.37 KB
142
134
  ESM dist/media/index.native.js.map 8.10 KB
135
+ ESM dist/media/index.server.js.map 6.37 KB
143
136
  ESM dist/media/chunk-3LKBM3G3.js.map 16.99 KB
144
- ESM ⚡️ Build success in 50ms
145
- ESM dist/expo/index.js 4.68 KB
146
- ESM dist/expo/testing.js 112.00 B
147
- ESM dist/expo/crypto.js 153.00 B
148
- ESM dist/expo/testing.js.map 168.00 B
149
- ESM dist/expo/index.js.map 10.23 KB
150
- ESM dist/expo/crypto.js.map 189.00 B
151
- ESM ⚡️ Build success in 42ms
152
- ESM dist/browser/index.js 14.06 KB
153
- ESM dist/browser/index.js.map 29.94 KB
154
- ESM ⚡️ Build success in 52ms
137
+ ESM ⚡️ Build success in 59ms
138
+ ESM dist/react-core/index.js 14.72 KB
155
139
  ESM dist/react-core/testing.js 1.22 KB
156
140
  ESM dist/react-core/chunk-7DYMJ74I.js 279.00 B
157
- ESM dist/react-core/index.js 14.41 KB
141
+ ESM dist/react-core/index.js.map 41.44 KB
158
142
  ESM dist/react-core/testing.js.map 1.86 KB
159
143
  ESM dist/react-core/chunk-7DYMJ74I.js.map 533.00 B
160
- ESM dist/react-core/index.js.map 40.79 KB
161
- ESM ⚡️ Build success in 48ms
162
- ESM dist/react-native-core/testing.js 119.00 B
163
- ESM dist/react-native-core/index.js 18.97 KB
164
- ESM dist/react-native-core/crypto.js 2.58 KB
165
- ESM dist/react-native-core/testing.js.map 175.00 B
166
- ESM dist/react-native-core/index.js.map 38.60 KB
167
- ESM dist/react-native-core/crypto.js.map 5.25 KB
168
- ESM ⚡️ Build success in 62ms
144
+ ESM ⚡️ Build success in 75ms
169
145
  ESM dist/prosemirror/index.js 77.76 KB
170
146
  ESM dist/prosemirror/index.js.map 307.20 KB
171
- ESM ⚡️ Build success in 69ms
147
+ ESM ⚡️ Build success in 77ms
148
+ ESM dist/browser/index.js 14.06 KB
149
+ ESM dist/browser/index.js.map 29.94 KB
150
+ ESM ⚡️ Build success in 80ms
172
151
  ESM dist/better-auth/database-adapter/index.js 26.65 KB
173
152
  ESM dist/better-auth/database-adapter/index.js.map 58.26 KB
174
- ESM ⚡️ Build success in 56ms
153
+ ESM ⚡️ Build success in 78ms
154
+ ESM dist/expo/index.js 4.68 KB
155
+ ESM dist/expo/testing.js 112.00 B
156
+ ESM dist/expo/crypto.js 153.00 B
157
+ ESM dist/expo/polyfills.js 858.00 B
158
+ ESM dist/expo/index.js.map 10.23 KB
159
+ ESM dist/expo/testing.js.map 168.00 B
160
+ ESM dist/expo/crypto.js.map 189.00 B
161
+ ESM dist/expo/polyfills.js.map 1.61 KB
162
+ ESM ⚡️ Build success in 85ms
163
+ ESM dist/react-native-core/index.js 18.97 KB
164
+ ESM dist/react-native-core/testing.js 119.00 B
165
+ ESM dist/react-native-core/crypto.js 2.58 KB
166
+ ESM dist/react-native-core/index.js.map 38.60 KB
167
+ ESM dist/react-native-core/testing.js.map 175.00 B
168
+ ESM dist/react-native-core/crypto.js.map 5.25 KB
169
+ ESM ⚡️ Build success in 91ms
170
+ ESM dist/react-native/index.js 21.51 KB
171
+ ESM dist/react-native/testing.js 120.00 B
172
+ ESM dist/react-native/crypto.js 161.00 B
173
+ ESM dist/react-native/polyfills.js 858.00 B
174
+ ESM dist/react-native/index.js.map 44.15 KB
175
+ ESM dist/react-native/testing.js.map 176.00 B
176
+ ESM dist/react-native/crypto.js.map 197.00 B
177
+ ESM dist/react-native/polyfills.js.map 1.61 KB
178
+ ESM ⚡️ Build success in 110ms
175
179
  ESM dist/react/index.js 25.74 KB
176
180
  ESM dist/react/testing.js 122.00 B
177
181
  ESM dist/react/ssr.js 697.00 B
182
+ ESM dist/react/index.js.map 55.43 KB
178
183
  ESM dist/react/testing.js.map 165.00 B
179
184
  ESM dist/react/ssr.js.map 1.11 KB
180
- ESM dist/react/index.js.map 55.43 KB
181
- ESM ⚡️ Build success in 60ms
185
+ ESM ⚡️ Build success in 101ms
182
186
  ESM dist/inspector/index.js 125.80 KB
183
187
  ESM dist/inspector/index.js.map 216.33 KB
184
- ESM ⚡️ Build success in 86ms
188
+ ESM ⚡️ Build success in 127ms
189
+ ESM dist/index.js 29.76 KB
185
190
  ESM dist/testing.js 8.51 KB
186
- ESM dist/chunk-PZ5AY32C.js 233.00 B
187
- ESM dist/chunk-M2HGBOXS.js 694.00 B
188
- ESM dist/index.js 29.30 KB
191
+ ESM dist/chunk-2S3Z2CN6.js 206.41 KB
189
192
  ESM dist/tools/ssr.js 156.00 B
190
- ESM dist/chunk-CUS6O5NE.js 204.35 KB
193
+ ESM dist/chunk-M2HGBOXS.js 694.00 B
194
+ ESM dist/chunk-PZ5AY32C.js 233.00 B
195
+ ESM dist/index.js.map 60.59 KB
191
196
  ESM dist/testing.js.map 16.17 KB
197
+ ESM dist/chunk-2S3Z2CN6.js.map 486.44 KB
198
+ ESM dist/tools/ssr.js.map 71.00 B
192
199
  ESM dist/chunk-M2HGBOXS.js.map 1.10 KB
193
200
  ESM dist/chunk-PZ5AY32C.js.map 71.00 B
194
- ESM dist/tools/ssr.js.map 71.00 B
195
- ESM dist/index.js.map 60.30 KB
196
- ESM dist/chunk-CUS6O5NE.js.map 481.42 KB
197
- ESM ⚡️ Build success in 97ms
201
+ ESM ⚡️ Build success in 174ms
198
202
  ESM dist/inspector/register-custom-element.js 218.00 B
199
- ESM dist/inspector/register-custom-element.js.map 314.00 B
200
203
  ESM dist/inspector/custom-element-P76EIWEV.js 1.60 MB
204
+ ESM dist/inspector/register-custom-element.js.map 314.00 B
201
205
  ESM dist/inspector/custom-element-P76EIWEV.js.map 2.45 MB
202
- ESM ⚡️ Build success in 157ms
206
+ ESM ⚡️ Build success in 217ms
203
207
 
204
- > jazz-tools@0.19.7 types /home/runner/_work/jazz/jazz/packages/jazz-tools
208
+ > jazz-tools@0.19.8 types /home/runner/_work/jazz/jazz/packages/jazz-tools
205
209
  > tsc --outDir dist
206
210
 
207
211
 
208
- > jazz-tools@0.19.7 build:svelte /home/runner/_work/jazz/jazz/packages/jazz-tools
212
+ > jazz-tools@0.19.8 build:svelte /home/runner/_work/jazz/jazz/packages/jazz-tools
209
213
  > rm -rf dist/svelte && svelte-package -i src/svelte -o dist/svelte --tsconfig tsconfig.svelte.json
210
214
 
211
215
  src/svelte -> dist/svelte
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # jazz-tools
2
2
 
3
+ ## 0.19.8
4
+
5
+ ### Patch Changes
6
+
7
+ - 21f7d34: Improve error logging in subscriptions and add stacktraces on errors coming from React hooks.
8
+
9
+ Added jazzConfig.setCustomErrorReporter API to intercept subscription errors and send them to an error tracker.
10
+
11
+ - b22ad89: Narrow down `.load` return type to not include `loading` CoValues
12
+ - 28b23dd: Added polyfills helper to React Native and Expo exports
13
+ - Updated dependencies [93e4a34]
14
+ - cojson@0.19.8
15
+ - cojson-storage-indexeddb@0.19.8
16
+ - cojson-transport-ws@0.19.8
17
+
3
18
  ## 0.19.7
4
19
 
5
20
  ### Patch Changes
@@ -4122,16 +4122,17 @@ var JazzError = class _JazzError {
4122
4122
  this.issues = issues;
4123
4123
  }
4124
4124
  toString() {
4125
- return this.issues.map((issue) => {
4125
+ let result = this.issues.map((issue) => {
4126
4126
  let message = `${issue.message}`;
4127
- if (this.id) {
4128
- message += ` from ${this.id}`;
4129
- }
4130
4127
  if (issue.path.length > 0) {
4131
- message += ` on path ${issue.path.join(".")}`;
4128
+ if (this.id) {
4129
+ message += `. Subscription starts from ${this.id}`;
4130
+ }
4131
+ message += ` and the value is on path ${issue.path.join(".")}`;
4132
4132
  }
4133
4133
  return message;
4134
4134
  }).join("\n");
4135
+ return result;
4135
4136
  }
4136
4137
  prependPath(item) {
4137
4138
  if (this.issues.length === 0) {
@@ -4188,9 +4189,37 @@ function createCoValue(ref2, raw, subscriptionScope) {
4188
4189
  };
4189
4190
  }
4190
4191
 
4192
+ // src/tools/subscribe/errorReporting.ts
4193
+ var isDev = function() {
4194
+ try {
4195
+ return process.env.NODE_ENV === "development";
4196
+ } catch {
4197
+ return false;
4198
+ }
4199
+ }();
4200
+ var customErrorReporter;
4201
+ var captureErrorCause = isDev;
4202
+ function enableCaptureErrorCause(capture) {
4203
+ captureErrorCause = capture;
4204
+ }
4205
+ function setCustomErrorReporter(reporter) {
4206
+ customErrorReporter = reporter;
4207
+ }
4208
+ function isCustomErrorReportingEnabled() {
4209
+ return customErrorReporter !== void 0;
4210
+ }
4211
+ function captureStack() {
4212
+ return captureErrorCause ? new Error() : void 0;
4213
+ }
4214
+ function captureError(error, props) {
4215
+ if (customErrorReporter) {
4216
+ customErrorReporter(error, props);
4217
+ }
4218
+ }
4219
+
4191
4220
  // src/tools/subscribe/SubscriptionScope.ts
4192
4221
  var SubscriptionScope = class _SubscriptionScope {
4193
- constructor(node, resolve, id, schema, skipRetry = false, bestEffortResolution = false, unstable_branch) {
4222
+ constructor(node, resolve, id, schema, skipRetry = false, bestEffortResolution = false, unstable_branch, callerStack) {
4194
4223
  this.node = node;
4195
4224
  this.id = id;
4196
4225
  this.schema = schema;
@@ -4244,6 +4273,7 @@ var SubscriptionScope = class _SubscriptionScope {
4244
4273
  this.triggerUpdate();
4245
4274
  };
4246
4275
  this.subscribers = /* @__PURE__ */ new Set();
4276
+ this.callerStack = callerStack;
4247
4277
  this.resolve = resolve;
4248
4278
  this.value = { type: CoValueLoadingState.LOADING, id };
4249
4279
  let lastUpdate;
@@ -4281,36 +4311,35 @@ var SubscriptionScope = class _SubscriptionScope {
4281
4311
  handleUpdate(update) {
4282
4312
  if (update === CoValueLoadingState.UNAVAILABLE) {
4283
4313
  if (this.value.type === CoValueLoadingState.LOADING) {
4284
- this.updateValue(
4285
- new JazzError(this.id, CoValueLoadingState.UNAVAILABLE, [
4286
- {
4287
- code: CoValueLoadingState.UNAVAILABLE,
4288
- message: "The value is unavailable",
4289
- params: {
4290
- id: this.id
4291
- },
4292
- path: []
4293
- }
4294
- ])
4295
- );
4314
+ const error = new JazzError(this.id, CoValueLoadingState.UNAVAILABLE, [
4315
+ {
4316
+ code: CoValueLoadingState.UNAVAILABLE,
4317
+ message: `Jazz Unavailable Error: unable to load ${this.id}`,
4318
+ params: {
4319
+ id: this.id
4320
+ },
4321
+ path: []
4322
+ }
4323
+ ]);
4324
+ this.updateValue(error);
4296
4325
  }
4297
4326
  this.triggerUpdate();
4298
4327
  return;
4299
4328
  }
4300
4329
  if (!hasAccessToCoValue(update)) {
4301
4330
  if (this.value.type !== CoValueLoadingState.UNAUTHORIZED) {
4302
- this.updateValue(
4303
- new JazzError(this.id, CoValueLoadingState.UNAUTHORIZED, [
4304
- {
4305
- code: CoValueLoadingState.UNAUTHORIZED,
4306
- message: `The current user (${this.node.getCurrentAgent().id}) is not authorized to access this value`,
4307
- params: {
4308
- id: this.id
4309
- },
4310
- path: []
4311
- }
4312
- ])
4313
- );
4331
+ const message = `Jazz Authorization Error: The current user (${this.node.getCurrentAgent().id}) is not authorized to access ${this.id}`;
4332
+ const error = new JazzError(this.id, CoValueLoadingState.UNAUTHORIZED, [
4333
+ {
4334
+ code: CoValueLoadingState.UNAUTHORIZED,
4335
+ message,
4336
+ params: {
4337
+ id: this.id
4338
+ },
4339
+ path: []
4340
+ }
4341
+ ]);
4342
+ this.updateValue(error);
4314
4343
  this.triggerUpdate();
4315
4344
  }
4316
4345
  return;
@@ -4383,20 +4412,19 @@ var SubscriptionScope = class _SubscriptionScope {
4383
4412
  getCurrentValue() {
4384
4413
  const rawValue = this.getCurrentRawValue();
4385
4414
  if (rawValue === CoValueLoadingState.UNAUTHORIZED || rawValue === CoValueLoadingState.UNAVAILABLE || rawValue === CoValueLoadingState.LOADING) {
4415
+ this.logError();
4386
4416
  return this.getUnloadedValue(rawValue);
4387
4417
  }
4388
4418
  return rawValue;
4389
4419
  }
4390
4420
  getCurrentRawValue() {
4391
4421
  if (this.value.type === CoValueLoadingState.UNAUTHORIZED || this.value.type === CoValueLoadingState.UNAVAILABLE) {
4392
- console.error(this.value.toString());
4393
4422
  return this.value.type;
4394
4423
  }
4395
4424
  if (!this.shouldSendUpdates()) {
4396
4425
  return CoValueLoadingState.LOADING;
4397
4426
  }
4398
4427
  if (this.errorFromChildren) {
4399
- console.error(this.errorFromChildren.toString());
4400
4428
  return this.errorFromChildren.type;
4401
4429
  }
4402
4430
  if (this.value.type === CoValueLoadingState.LOADED) {
@@ -4404,6 +4432,49 @@ var SubscriptionScope = class _SubscriptionScope {
4404
4432
  }
4405
4433
  return CoValueLoadingState.LOADING;
4406
4434
  }
4435
+ getCreationStackLines() {
4436
+ const stack = this.callerStack?.stack;
4437
+ if (!stack) {
4438
+ return "";
4439
+ }
4440
+ const creationStackLines = stack.split("\n").slice(2, 15);
4441
+ const creationAppFrame = creationStackLines.find(
4442
+ (line) => !line.includes("node_modules") && !line.includes("useCoValueSubscription") && !line.includes("useCoState") && !line.includes("useAccount") && !line.includes("jazz-tools")
4443
+ );
4444
+ let result = "\n\n";
4445
+ if (creationAppFrame) {
4446
+ result += "Subscription created ", result += creationAppFrame.trim();
4447
+ }
4448
+ result += "\nFull subscription creation stack:";
4449
+ for (const line of creationStackLines.slice(0, 8)) {
4450
+ result += "\n " + line.trim();
4451
+ }
4452
+ return result;
4453
+ }
4454
+ logError() {
4455
+ let error;
4456
+ if (this.value.type === CoValueLoadingState.UNAUTHORIZED || this.value.type === CoValueLoadingState.UNAVAILABLE) {
4457
+ error = this.value;
4458
+ }
4459
+ if (this.errorFromChildren) {
4460
+ error = this.errorFromChildren;
4461
+ }
4462
+ if (!error || this.lastErrorLogged === error) {
4463
+ return;
4464
+ }
4465
+ if (error.type === CoValueLoadingState.UNAVAILABLE && this.skipRetry) {
4466
+ return;
4467
+ }
4468
+ this.lastErrorLogged = error;
4469
+ if (isCustomErrorReportingEnabled()) {
4470
+ captureError(new Error(error.toString(), { cause: this.callerStack }), {
4471
+ getPrettyStackTrace: () => this.getCreationStackLines(),
4472
+ jazzError: error
4473
+ });
4474
+ } else {
4475
+ console.error(`${error.toString()}${this.getCreationStackLines()}`);
4476
+ }
4477
+ }
4407
4478
  triggerUpdate() {
4408
4479
  if (!this.shouldSendUpdates()) return;
4409
4480
  if (!this.dirty) return;
@@ -4563,7 +4634,7 @@ var SubscriptionScope = class _SubscriptionScope {
4563
4634
  new JazzError(void 0, CoValueLoadingState.UNAVAILABLE, [
4564
4635
  {
4565
4636
  code: "validationError",
4566
- message: `The ref on position ${key} requested on ${stream.constructor.name} is missing`,
4637
+ message: `Jazz Validation Error: The ref on position ${key} is missing`,
4567
4638
  params: {},
4568
4639
  path: [key]
4569
4640
  }
@@ -4615,7 +4686,7 @@ var SubscriptionScope = class _SubscriptionScope {
4615
4686
  new JazzError(void 0, CoValueLoadingState.UNAVAILABLE, [
4616
4687
  {
4617
4688
  code: "validationError",
4618
- message: `The ref ${key} requested on ${map.constructor.name} is missing`,
4689
+ message: `Jazz Validation Error: The ref ${key} is required but missing`,
4619
4690
  params: {},
4620
4691
  path: [key]
4621
4692
  }
@@ -4646,7 +4717,7 @@ var SubscriptionScope = class _SubscriptionScope {
4646
4717
  new JazzError(void 0, CoValueLoadingState.UNAVAILABLE, [
4647
4718
  {
4648
4719
  code: "validationError",
4649
- message: `The ref on position ${key} requested on ${list.constructor.name} is missing`,
4720
+ message: `Jazz Validation Error: The ref on position ${key} is required but missing`,
4650
4721
  params: {},
4651
4722
  path: [key]
4652
4723
  }
@@ -6749,13 +6820,9 @@ function subscribeToCoValue(cls, id, options, listener) {
6749
6820
  switch (value.$jazz.loadingState) {
6750
6821
  case CoValueLoadingState.UNAVAILABLE:
6751
6822
  options.onUnavailable?.(value);
6752
- if (!options.skipRetry) {
6753
- console.error(value.toString());
6754
- }
6755
6823
  break;
6756
6824
  case CoValueLoadingState.UNAUTHORIZED:
6757
6825
  options.onUnauthorized?.(value);
6758
- console.error(value.toString());
6759
6826
  break;
6760
6827
  }
6761
6828
  };
@@ -6898,17 +6965,14 @@ async function exportCoValue(cls, id, options) {
6898
6965
  options.unstable_branch
6899
6966
  );
6900
6967
  const value = await new Promise((resolve2) => {
6901
- rootNode.setListener((value2) => {
6902
- if (value2.type === CoValueLoadingState.UNAVAILABLE) {
6968
+ rootNode.setListener(() => {
6969
+ const value2 = rootNode.getCurrentValue();
6970
+ if (value2.$isLoaded) {
6971
+ resolve2(value2);
6972
+ } else if (value2.$jazz.loadingState === CoValueLoadingState.UNAVAILABLE || value2.$jazz.loadingState === CoValueLoadingState.UNAUTHORIZED) {
6903
6973
  resolve2(null);
6904
- console.error(value2.toString());
6905
- } else if (value2.type === CoValueLoadingState.UNAUTHORIZED) {
6906
- resolve2(null);
6907
- console.error(value2.toString());
6908
- } else if (value2.type === CoValueLoadingState.LOADED) {
6909
- resolve2(value2.value);
6974
+ rootNode.destroy();
6910
6975
  }
6911
- rootNode.destroy();
6912
6976
  });
6913
6977
  });
6914
6978
  if (!value) {
@@ -7046,6 +7110,9 @@ export {
7046
7110
  Encoders,
7047
7111
  coField,
7048
7112
  CoValueLoadingState,
7113
+ enableCaptureErrorCause,
7114
+ setCustomErrorReporter,
7115
+ captureStack,
7049
7116
  SubscriptionScope,
7050
7117
  randomSessionProvider,
7051
7118
  createJazzContextFromExistingCredentials,
@@ -7062,4 +7129,4 @@ export {
7062
7129
  JazzContextManager
7063
7130
  };
7064
7131
  /* istanbul ignore file -- @preserve */
7065
- //# sourceMappingURL=chunk-CUS6O5NE.js.map
7132
+ //# sourceMappingURL=chunk-2S3Z2CN6.js.map