jazz-tools 0.19.6 → 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 (111) hide show
  1. package/.turbo/turbo-build.log +51 -47
  2. package/CHANGELOG.md +24 -0
  3. package/dist/{chunk-GCBXV2KC.js → chunk-2S3Z2CN6.js} +122 -53
  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 +126 -36
  103. package/src/tools/subscribe/errorReporting.ts +67 -0
  104. package/src/tools/tests/coDiscriminatedUnion.test.ts +69 -2
  105. package/src/tools/tests/deepLoading.test.ts +47 -47
  106. package/src/tools/tests/errorReporting.test.ts +103 -0
  107. package/src/tools/tests/load.test.ts +21 -1
  108. package/src/tools/tests/request.test.ts +2 -1
  109. package/src/tools/tests/subscribe.test.ts +44 -0
  110. package/tsup.config.ts +16 -0
  111. package/dist/chunk-GCBXV2KC.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
 
2
- > jazz-tools@0.19.6 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,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
117
110
  ESM dist/tiptap/index.js 564.00 B
118
111
  ESM dist/tiptap/index.js.map 1.21 KB
119
- ESM ⚡️ Build success in 65ms
112
+ ESM ⚡️ Build success in 51ms
120
113
  ESM dist/worker/index.js 3.19 KB
121
114
  ESM dist/worker/edge-wasm.js 215.00 B
122
115
  ESM dist/worker/napi-crypto.js 110.00 B
123
116
  ESM dist/worker/index.js.map 6.24 KB
124
117
  ESM dist/worker/edge-wasm.js.map 434.00 B
125
118
  ESM dist/worker/napi-crypto.js.map 162.00 B
126
- ESM ⚡️ Build success in 63ms
119
+ ESM ⚡️ Build success in 50ms
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 51ms
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,78 +134,82 @@
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 63ms
138
- ESM dist/react-native/index.js 2.53 KB
139
- ESM dist/react-native/testing.js 120.00 B
140
- ESM dist/react-native/crypto.js 161.00 B
141
- ESM dist/react-native/index.js.map 5.68 KB
142
- ESM dist/react-native/testing.js.map 176.00 B
143
- ESM dist/react-native/crypto.js.map 197.00 B
144
- ESM ⚡️ Build success in 60ms
145
- ESM dist/react-core/index.js 14.41 KB
137
+ ESM ⚡️ Build success in 59ms
138
+ ESM dist/react-core/index.js 14.72 KB
146
139
  ESM dist/react-core/testing.js 1.22 KB
147
140
  ESM dist/react-core/chunk-7DYMJ74I.js 279.00 B
148
- ESM dist/react-core/index.js.map 40.79 KB
141
+ ESM dist/react-core/index.js.map 41.44 KB
149
142
  ESM dist/react-core/testing.js.map 1.86 KB
150
143
  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
159
- ESM dist/browser/index.js 14.06 KB
160
- ESM dist/browser/index.js.map 29.94 KB
161
- ESM ⚡️ Build success in 78ms
144
+ ESM ⚡️ Build success in 75ms
162
145
  ESM dist/prosemirror/index.js 77.76 KB
163
146
  ESM dist/prosemirror/index.js.map 307.20 KB
164
- ESM ⚡️ Build success in 99ms
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
165
151
  ESM dist/better-auth/database-adapter/index.js 26.65 KB
166
152
  ESM dist/better-auth/database-adapter/index.js.map 58.26 KB
167
- ESM ⚡️ Build success in 84ms
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
168
163
  ESM dist/react-native-core/index.js 18.97 KB
169
164
  ESM dist/react-native-core/testing.js 119.00 B
170
165
  ESM dist/react-native-core/crypto.js 2.58 KB
171
166
  ESM dist/react-native-core/index.js.map 38.60 KB
172
167
  ESM dist/react-native-core/testing.js.map 175.00 B
173
168
  ESM dist/react-native-core/crypto.js.map 5.25 KB
174
- ESM ⚡️ Build success in 109ms
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
178
182
  ESM dist/react/index.js.map 55.43 KB
179
183
  ESM dist/react/testing.js.map 165.00 B
180
184
  ESM dist/react/ssr.js.map 1.11 KB
181
- ESM ⚡️ Build success in 118ms
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 149ms
185
- ESM dist/index.js 29.30 KB
188
+ ESM ⚡️ Build success in 127ms
189
+ ESM dist/index.js 29.76 KB
186
190
  ESM dist/testing.js 8.51 KB
187
- ESM dist/chunk-GCBXV2KC.js 204.27 KB
191
+ ESM dist/chunk-2S3Z2CN6.js 206.41 KB
188
192
  ESM dist/tools/ssr.js 156.00 B
189
193
  ESM dist/chunk-M2HGBOXS.js 694.00 B
190
194
  ESM dist/chunk-PZ5AY32C.js 233.00 B
191
- ESM dist/index.js.map 60.30 KB
195
+ ESM dist/index.js.map 60.59 KB
192
196
  ESM dist/testing.js.map 16.17 KB
193
- ESM dist/chunk-GCBXV2KC.js.map 481.22 KB
197
+ ESM dist/chunk-2S3Z2CN6.js.map 486.44 KB
194
198
  ESM dist/tools/ssr.js.map 71.00 B
195
199
  ESM dist/chunk-M2HGBOXS.js.map 1.10 KB
196
200
  ESM dist/chunk-PZ5AY32C.js.map 71.00 B
197
- ESM ⚡️ Build success in 210ms
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 236ms
206
+ ESM ⚡️ Build success in 217ms
203
207
 
204
- > jazz-tools@0.19.6 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.6 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,29 @@
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
+
18
+ ## 0.19.7
19
+
20
+ ### Patch Changes
21
+
22
+ - e113a79: Avoid migrating unauthorized CoValues
23
+ - cojson@0.19.7
24
+ - cojson-storage-indexeddb@0.19.7
25
+ - cojson-transport-ws@0.19.7
26
+
3
27
  ## 0.19.6
4
28
 
5
29
  ### 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;
@@ -4256,7 +4286,7 @@ var SubscriptionScope = class _SubscriptionScope {
4256
4286
  this.handleUpdate(value);
4257
4287
  return;
4258
4288
  }
4259
- if (!this.migrated && value !== CoValueLoadingState.UNAVAILABLE) {
4289
+ if (!this.migrated && value !== CoValueLoadingState.UNAVAILABLE && hasAccessToCoValue(value)) {
4260
4290
  if (this.migrating) {
4261
4291
  return;
4262
4292
  }
@@ -4281,38 +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
- const ruleset = update.core.verified.header.ruleset;
4301
- const hasAccess = ruleset.type !== "ownedByGroup" || myRoleForRawValue(update) !== void 0;
4302
- if (!hasAccess) {
4329
+ if (!hasAccessToCoValue(update)) {
4303
4330
  if (this.value.type !== CoValueLoadingState.UNAUTHORIZED) {
4304
- this.updateValue(
4305
- new JazzError(this.id, CoValueLoadingState.UNAUTHORIZED, [
4306
- {
4307
- code: CoValueLoadingState.UNAUTHORIZED,
4308
- message: `The current user (${this.node.getCurrentAgent().id}) is not authorized to access this value`,
4309
- params: {
4310
- id: this.id
4311
- },
4312
- path: []
4313
- }
4314
- ])
4315
- );
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);
4316
4343
  this.triggerUpdate();
4317
4344
  }
4318
4345
  return;
@@ -4385,20 +4412,19 @@ var SubscriptionScope = class _SubscriptionScope {
4385
4412
  getCurrentValue() {
4386
4413
  const rawValue = this.getCurrentRawValue();
4387
4414
  if (rawValue === CoValueLoadingState.UNAUTHORIZED || rawValue === CoValueLoadingState.UNAVAILABLE || rawValue === CoValueLoadingState.LOADING) {
4415
+ this.logError();
4388
4416
  return this.getUnloadedValue(rawValue);
4389
4417
  }
4390
4418
  return rawValue;
4391
4419
  }
4392
4420
  getCurrentRawValue() {
4393
4421
  if (this.value.type === CoValueLoadingState.UNAUTHORIZED || this.value.type === CoValueLoadingState.UNAVAILABLE) {
4394
- console.error(this.value.toString());
4395
4422
  return this.value.type;
4396
4423
  }
4397
4424
  if (!this.shouldSendUpdates()) {
4398
4425
  return CoValueLoadingState.LOADING;
4399
4426
  }
4400
4427
  if (this.errorFromChildren) {
4401
- console.error(this.errorFromChildren.toString());
4402
4428
  return this.errorFromChildren.type;
4403
4429
  }
4404
4430
  if (this.value.type === CoValueLoadingState.LOADED) {
@@ -4406,6 +4432,49 @@ var SubscriptionScope = class _SubscriptionScope {
4406
4432
  }
4407
4433
  return CoValueLoadingState.LOADING;
4408
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
+ }
4409
4478
  triggerUpdate() {
4410
4479
  if (!this.shouldSendUpdates()) return;
4411
4480
  if (!this.dirty) return;
@@ -4565,7 +4634,7 @@ var SubscriptionScope = class _SubscriptionScope {
4565
4634
  new JazzError(void 0, CoValueLoadingState.UNAVAILABLE, [
4566
4635
  {
4567
4636
  code: "validationError",
4568
- 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`,
4569
4638
  params: {},
4570
4639
  path: [key]
4571
4640
  }
@@ -4617,7 +4686,7 @@ var SubscriptionScope = class _SubscriptionScope {
4617
4686
  new JazzError(void 0, CoValueLoadingState.UNAVAILABLE, [
4618
4687
  {
4619
4688
  code: "validationError",
4620
- message: `The ref ${key} requested on ${map.constructor.name} is missing`,
4689
+ message: `Jazz Validation Error: The ref ${key} is required but missing`,
4621
4690
  params: {},
4622
4691
  path: [key]
4623
4692
  }
@@ -4648,7 +4717,7 @@ var SubscriptionScope = class _SubscriptionScope {
4648
4717
  new JazzError(void 0, CoValueLoadingState.UNAVAILABLE, [
4649
4718
  {
4650
4719
  code: "validationError",
4651
- 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`,
4652
4721
  params: {},
4653
4722
  path: [key]
4654
4723
  }
@@ -4700,6 +4769,10 @@ var SubscriptionScope = class _SubscriptionScope {
4700
4769
  this.childNodes.forEach((child) => child.destroy());
4701
4770
  }
4702
4771
  };
4772
+ function hasAccessToCoValue(rawCoValue) {
4773
+ const ruleset = rawCoValue.core.verified.header.ruleset;
4774
+ return ruleset.type !== "ownedByGroup" || myRoleForRawValue(rawCoValue) !== void 0;
4775
+ }
4703
4776
 
4704
4777
  // src/tools/subscribe/index.ts
4705
4778
  function getSubscriptionScope(value) {
@@ -6747,13 +6820,9 @@ function subscribeToCoValue(cls, id, options, listener) {
6747
6820
  switch (value.$jazz.loadingState) {
6748
6821
  case CoValueLoadingState.UNAVAILABLE:
6749
6822
  options.onUnavailable?.(value);
6750
- if (!options.skipRetry) {
6751
- console.error(value.toString());
6752
- }
6753
6823
  break;
6754
6824
  case CoValueLoadingState.UNAUTHORIZED:
6755
6825
  options.onUnauthorized?.(value);
6756
- console.error(value.toString());
6757
6826
  break;
6758
6827
  }
6759
6828
  };
@@ -6896,17 +6965,14 @@ async function exportCoValue(cls, id, options) {
6896
6965
  options.unstable_branch
6897
6966
  );
6898
6967
  const value = await new Promise((resolve2) => {
6899
- rootNode.setListener((value2) => {
6900
- 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) {
6901
6973
  resolve2(null);
6902
- console.error(value2.toString());
6903
- } else if (value2.type === CoValueLoadingState.UNAUTHORIZED) {
6904
- resolve2(null);
6905
- console.error(value2.toString());
6906
- } else if (value2.type === CoValueLoadingState.LOADED) {
6907
- resolve2(value2.value);
6974
+ rootNode.destroy();
6908
6975
  }
6909
- rootNode.destroy();
6910
6976
  });
6911
6977
  });
6912
6978
  if (!value) {
@@ -7044,6 +7110,9 @@ export {
7044
7110
  Encoders,
7045
7111
  coField,
7046
7112
  CoValueLoadingState,
7113
+ enableCaptureErrorCause,
7114
+ setCustomErrorReporter,
7115
+ captureStack,
7047
7116
  SubscriptionScope,
7048
7117
  randomSessionProvider,
7049
7118
  createJazzContextFromExistingCredentials,
@@ -7060,4 +7129,4 @@ export {
7060
7129
  JazzContextManager
7061
7130
  };
7062
7131
  /* istanbul ignore file -- @preserve */
7063
- //# sourceMappingURL=chunk-GCBXV2KC.js.map
7132
+ //# sourceMappingURL=chunk-2S3Z2CN6.js.map