jazz-tools 0.18.19 → 0.18.21

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 (61) hide show
  1. package/.svelte-kit/__package__/Provider.svelte +61 -53
  2. package/.svelte-kit/__package__/Provider.svelte.d.ts.map +1 -1
  3. package/.turbo/turbo-build.log +60 -62
  4. package/CHANGELOG.md +25 -0
  5. package/dist/browser/index.js +2 -2
  6. package/dist/browser/index.js.map +1 -1
  7. package/dist/chunk-BOMSRY5H.js +26 -0
  8. package/dist/chunk-BOMSRY5H.js.map +1 -0
  9. package/dist/{chunk-RN3Y24WX.js → chunk-D5L6ES2M.js} +51 -6
  10. package/dist/chunk-D5L6ES2M.js.map +1 -0
  11. package/dist/chunk-PZ5AY32C.js +10 -0
  12. package/dist/chunk-PZ5AY32C.js.map +1 -0
  13. package/dist/index.js +6 -1
  14. package/dist/index.js.map +1 -1
  15. package/dist/react/ssr.d.ts +1 -3
  16. package/dist/react/ssr.d.ts.map +1 -1
  17. package/dist/react/ssr.js +3 -1
  18. package/dist/react/ssr.js.map +1 -1
  19. package/dist/react-core/hooks.d.ts.map +1 -1
  20. package/dist/react-core/index.js +2 -2
  21. package/dist/react-core/index.js.map +1 -1
  22. package/dist/svelte/Provider.svelte +61 -53
  23. package/dist/svelte/Provider.svelte.d.ts.map +1 -1
  24. package/dist/testing.js +2 -1
  25. package/dist/testing.js.map +1 -1
  26. package/dist/tools/coValues/coList.d.ts.map +1 -1
  27. package/dist/tools/coValues/coPlainText.d.ts.map +1 -1
  28. package/dist/tools/exports.d.ts +1 -0
  29. package/dist/tools/exports.d.ts.map +1 -1
  30. package/dist/tools/implementation/zodSchema/runtimeConverters/schemaFieldToCoFieldDef.d.ts +1 -1
  31. package/dist/tools/implementation/zodSchema/runtimeConverters/schemaFieldToCoFieldDef.d.ts.map +1 -1
  32. package/dist/tools/implementation/zodSchema/typeConverters/TypeOfZodSchema.d.ts +1 -1
  33. package/dist/tools/implementation/zodSchema/typeConverters/TypeOfZodSchema.d.ts.map +1 -1
  34. package/dist/tools/implementation/zodSchema/zodReExport.d.ts +1 -1
  35. package/dist/tools/implementation/zodSchema/zodReExport.d.ts.map +1 -1
  36. package/dist/tools/ssr/index.d.ts +2 -0
  37. package/dist/tools/ssr/index.d.ts.map +1 -0
  38. package/dist/tools/ssr/ssr.d.ts +4 -0
  39. package/dist/tools/ssr/ssr.d.ts.map +1 -0
  40. package/dist/tools/ssr.js +8 -0
  41. package/dist/tools/ssr.js.map +1 -0
  42. package/package.json +15 -10
  43. package/src/browser/auth/PasskeyAuth.ts +2 -2
  44. package/src/react/ssr.ts +2 -23
  45. package/src/react-core/hooks.ts +3 -2
  46. package/src/react-core/tests/useInboxSender.test.ts +37 -3
  47. package/src/svelte/Provider.svelte +61 -53
  48. package/src/tools/coValues/coList.ts +11 -0
  49. package/src/tools/coValues/coPlainText.ts +9 -0
  50. package/src/tools/exports.ts +2 -0
  51. package/src/tools/implementation/zodSchema/runtimeConverters/schemaFieldToCoFieldDef.ts +47 -2
  52. package/src/tools/implementation/zodSchema/typeConverters/TypeOfZodSchema.ts +9 -4
  53. package/src/tools/implementation/zodSchema/zodReExport.ts +1 -0
  54. package/src/tools/ssr/index.ts +1 -0
  55. package/src/tools/ssr/ssr.ts +23 -0
  56. package/src/tools/tests/coList.test.ts +34 -0
  57. package/src/tools/tests/coPlainText.test.ts +25 -1
  58. package/src/tools/tests/zod.test.ts +131 -0
  59. package/tsup.config.ts +2 -7
  60. package/dist/chunk-RN3Y24WX.js.map +0 -1
  61. package/jazz-tools-0.18.6.tgz +0 -0
@@ -1,8 +1,6 @@
1
- var __defProp = Object.defineProperty;
2
- var __export = (target, all) => {
3
- for (var name in all)
4
- __defProp(target, name, { get: all[name], enumerable: true });
5
- };
1
+ import {
2
+ __export
3
+ } from "./chunk-PZ5AY32C.js";
6
4
 
7
5
  // src/tools/implementation/zodSchema/zodReExport.ts
8
6
  var zodReExport_exports = {};
@@ -13,6 +11,7 @@ __export(zodReExport_exports, {
13
11
  boolean: () => boolean,
14
12
  cidrv4: () => cidrv4,
15
13
  cidrv6: () => cidrv6,
14
+ codec: () => codec,
16
15
  cuid: () => cuid,
17
16
  cuid2: () => cuid2,
18
17
  date: () => date,
@@ -87,6 +86,7 @@ import {
87
86
  union,
88
87
  discriminatedUnion,
89
88
  int,
89
+ codec,
90
90
  optional,
91
91
  array,
92
92
  tuple,
@@ -1314,9 +1314,14 @@ var CoListJazzApi = class extends CoValueJazzApi {
1314
1314
  return isSame;
1315
1315
  } : void 0;
1316
1316
  const patches = [...calcPatch(current, result, comparator)];
1317
+ if (patches.length === 0) {
1318
+ return this.coList;
1319
+ }
1320
+ this.raw.core.pauseNotifyUpdate();
1317
1321
  for (const [from, to, insert] of patches.reverse()) {
1318
1322
  this.splice(from, to - from, ...insert);
1319
1323
  }
1324
+ this.raw.core.resumeNotifyUpdate();
1320
1325
  return this.coList;
1321
1326
  }
1322
1327
  /**
@@ -3160,6 +3165,10 @@ var CoTextJazzApi = class extends CoValueJazzApi {
3160
3165
  const currentGraphemes = this.raw.toGraphemes(current);
3161
3166
  const otherGraphemes = this.raw.toGraphemes(other);
3162
3167
  const patches = [...calcPatch2(currentGraphemes, otherGraphemes)];
3168
+ if (patches.length === 0) {
3169
+ return;
3170
+ }
3171
+ this.raw.core.pauseNotifyUpdate();
3163
3172
  for (const [from, to, insert] of patches.reverse()) {
3164
3173
  if (to > from) {
3165
3174
  this.coText.deleteRange({ from, to });
@@ -3168,6 +3177,7 @@ var CoTextJazzApi = class extends CoValueJazzApi {
3168
3177
  this.coText.insertBefore(from, this.raw.fromGraphemes(insert));
3169
3178
  }
3170
3179
  }
3180
+ this.raw.core.resumeNotifyUpdate();
3171
3181
  }
3172
3182
  /**
3173
3183
  * Given an already loaded `CoPlainText`, subscribe to updates to the `CoPlainText` and ensure that the specified fields are loaded to the specified depth.
@@ -5153,6 +5163,23 @@ function isUnionOfPrimitivesDeeply(schema) {
5153
5163
  }
5154
5164
 
5155
5165
  // src/tools/implementation/zodSchema/runtimeConverters/schemaFieldToCoFieldDef.ts
5166
+ function makeCodecCoField(codec2) {
5167
+ return coField.optional.encoded({
5168
+ encode: (value) => {
5169
+ if (value === void 0) return void 0;
5170
+ if (value === null) return null;
5171
+ return codec2._zod.def.reverseTransform(value, {
5172
+ value,
5173
+ issues: []
5174
+ });
5175
+ },
5176
+ decode: (value) => {
5177
+ if (value === null) return null;
5178
+ if (value === void 0) return void 0;
5179
+ return codec2._zod.def.transform(value, { value, issues: [] });
5180
+ }
5181
+ });
5182
+ }
5156
5183
  function schemaFieldToCoFieldDef(schema) {
5157
5184
  if (isCoValueClass(schema)) {
5158
5185
  return coField.ref(schema);
@@ -5225,6 +5252,24 @@ function schemaFieldToCoFieldDef(schema) {
5225
5252
  "z.union()/z.discriminatedUnion() of collaborative types is not supported. Use co.discriminatedUnion() instead."
5226
5253
  );
5227
5254
  }
5255
+ } else if (zodSchemaDef.type === "pipe") {
5256
+ const isCodec = zodSchemaDef.transform !== void 0 && zodSchemaDef.reverseTransform !== void 0;
5257
+ if (!isCodec) {
5258
+ throw new Error(
5259
+ "z.pipe() is not supported. Only z.codec() is supported."
5260
+ );
5261
+ }
5262
+ try {
5263
+ schemaFieldToCoFieldDef(zodSchemaDef.in);
5264
+ } catch (error) {
5265
+ if (error instanceof Error) {
5266
+ error.message = `z.codec() is only supported if the input schema is already supported. ${error.message}`;
5267
+ }
5268
+ throw error;
5269
+ }
5270
+ return makeCodecCoField(
5271
+ schema
5272
+ );
5228
5273
  } else {
5229
5274
  throw new Error(
5230
5275
  `Unsupported zod type: ${schema._zod?.def?.type || JSON.stringify(schema)}`
@@ -6152,4 +6197,4 @@ export {
6152
6197
  JazzContextManager
6153
6198
  };
6154
6199
  /* istanbul ignore file -- @preserve */
6155
- //# sourceMappingURL=chunk-RN3Y24WX.js.map
6200
+ //# sourceMappingURL=chunk-D5L6ES2M.js.map