jazz-tools 0.15.15 → 0.15.16

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 (40) hide show
  1. package/.turbo/turbo-build.log +36 -40
  2. package/CHANGELOG.md +10 -0
  3. package/dist/{chunk-4CFNXQE7.js → chunk-OSVAAVWQ.js} +103 -6
  4. package/dist/chunk-OSVAAVWQ.js.map +1 -0
  5. package/dist/index.js +357 -3
  6. package/dist/index.js.map +1 -1
  7. package/dist/react/index.js +2 -0
  8. package/dist/react/index.js.map +1 -1
  9. package/dist/react/testing.js +3 -1
  10. package/dist/react/testing.js.map +1 -1
  11. package/dist/testing.js +1 -1
  12. package/dist/tools/coValues/group.d.ts +1 -0
  13. package/dist/tools/coValues/group.d.ts.map +1 -1
  14. package/dist/tools/coValues/inbox.d.ts.map +1 -1
  15. package/dist/tools/coValues/interfaces.d.ts +58 -2
  16. package/dist/tools/coValues/interfaces.d.ts.map +1 -1
  17. package/dist/tools/coValues/request.d.ts +82 -0
  18. package/dist/tools/coValues/request.d.ts.map +1 -0
  19. package/dist/tools/exports.d.ts +2 -1
  20. package/dist/tools/exports.d.ts.map +1 -1
  21. package/dist/tools/lib/id.d.ts +2 -0
  22. package/dist/tools/lib/id.d.ts.map +1 -0
  23. package/dist/tools/subscribe/SubscriptionScope.d.ts +3 -2
  24. package/dist/tools/subscribe/SubscriptionScope.d.ts.map +1 -1
  25. package/dist/tools/tests/exportImport.test.d.ts +2 -0
  26. package/dist/tools/tests/exportImport.test.d.ts.map +1 -0
  27. package/dist/tools/tests/request.test.d.ts +2 -0
  28. package/dist/tools/tests/request.test.d.ts.map +1 -0
  29. package/package.json +6 -5
  30. package/src/tools/coValues/group.ts +1 -0
  31. package/src/tools/coValues/inbox.ts +4 -3
  32. package/src/tools/coValues/interfaces.ts +177 -2
  33. package/src/tools/coValues/request.ts +631 -0
  34. package/src/tools/exports.ts +8 -0
  35. package/src/tools/lib/id.ts +3 -0
  36. package/src/tools/subscribe/SubscriptionScope.ts +10 -1
  37. package/src/tools/tests/exportImport.test.ts +526 -0
  38. package/src/tools/tests/request.test.ts +951 -0
  39. package/tsup.config.ts +0 -2
  40. package/dist/chunk-4CFNXQE7.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
 
2
- > jazz-tools@0.15.15 build /home/runner/_work/jazz/jazz/packages/jazz-tools
2
+ > jazz-tools@0.15.16 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"}
@@ -16,7 +16,7 @@
16
16
  CLI Using tsconfig: tsconfig.json
17
17
  CLI Building entry: {"index":"src/prosemirror/index.ts"}
18
18
  CLI Using tsconfig: tsconfig.json
19
- CLI Building entry: {"index":"src/react/index.ts","testing":"src/react/testing.tsx","ssr":"src/react/ssr.ts"}
19
+ CLI Building entry: {"ssr":"src/react/ssr.ts"}
20
20
  CLI Using tsconfig: tsconfig.json
21
21
  CLI Building entry: {"index":"src/react/index.ts","testing":"src/react/testing.tsx"}
22
22
  CLI Using tsconfig: tsconfig.json
@@ -107,85 +107,81 @@
107
107
  ESM Build start
108
108
  CLI Cleaning output folder
109
109
  ESM Build start
110
+ ESM dist/react/ssr.js 688.00 B
111
+ ESM dist/react/ssr.js.map 1.12 KB
112
+ ESM ⚡️ Build success in 22ms
113
+ ESM dist/react-native-media-images/index.js 6.19 KB
114
+ ESM dist/react-native-media-images/index.js.map 10.96 KB
115
+ ESM ⚡️ Build success in 20ms
110
116
  ESM dist/browser-media-images/index.js 2.55 KB
111
117
  ESM dist/browser-media-images/index.js.map 5.44 KB
112
- ESM ⚡️ Build success in 19ms
118
+ ESM ⚡️ Build success in 25ms
113
119
  ESM dist/tiptap/index.js 564.00 B
114
120
  ESM dist/tiptap/index.js.map 1.21 KB
115
- ESM ⚡️ Build success in 14ms
121
+ ESM ⚡️ Build success in 24ms
116
122
  ESM dist/worker/index.js 2.34 KB
117
123
  ESM dist/worker/index.js.map 4.82 KB
118
- ESM ⚡️ Build success in 14ms
119
- ESM dist/react-native-media-images/index.js 6.19 KB
120
- ESM dist/react-native-media-images/index.js.map 10.96 KB
121
- ESM ⚡️ Build success in 21ms
124
+ ESM ⚡️ Build success in 25ms
125
+ ESM dist/react-native/index.js 2.53 KB
126
+ ESM dist/react-native/crypto.js 117.00 B
127
+ ESM dist/react-native/testing.js 120.00 B
128
+ ESM dist/react-native/index.js.map 5.68 KB
129
+ ESM dist/react-native/testing.js.map 176.00 B
130
+ ESM dist/react-native/crypto.js.map 174.00 B
131
+ ESM ⚡️ Build success in 28ms
122
132
  ESM dist/react-core/index.js 8.37 KB
123
133
  ESM dist/react-core/testing.js 1.17 KB
124
134
  ESM dist/react-core/chunk-7DYMJ74I.js 279.00 B
125
135
  ESM dist/react-core/index.js.map 16.39 KB
126
136
  ESM dist/react-core/testing.js.map 1.82 KB
127
137
  ESM dist/react-core/chunk-7DYMJ74I.js.map 533.00 B
128
- ESM ⚡️ Build success in 22ms
129
- ESM dist/browser/index.js 13.43 KB
130
- ESM dist/browser/index.js.map 28.67 KB
131
- ESM ⚡️ Build success in 41ms
132
- ESM dist/react-native/index.js 2.53 KB
133
- ESM dist/react-native/testing.js 120.00 B
134
- ESM dist/react-native/crypto.js 117.00 B
135
- ESM dist/react-native/index.js.map 5.68 KB
136
- ESM dist/react-native/testing.js.map 176.00 B
137
- ESM dist/react-native/crypto.js.map 174.00 B
138
- ESM ⚡️ Build success in 36ms
138
+ ESM ⚡️ Build success in 29ms
139
139
  ESM dist/expo/index.js 4.65 KB
140
140
  ESM dist/expo/testing.js 112.00 B
141
141
  ESM dist/expo/crypto.js 109.00 B
142
142
  ESM dist/expo/index.js.map 10.17 KB
143
143
  ESM dist/expo/testing.js.map 168.00 B
144
144
  ESM dist/expo/crypto.js.map 166.00 B
145
+ ESM ⚡️ Build success in 41ms
146
+ ESM dist/browser/index.js 13.43 KB
147
+ ESM dist/browser/index.js.map 28.67 KB
145
148
  ESM ⚡️ Build success in 42ms
146
- ESM dist/prosemirror/index.js 76.90 KB
147
- ESM dist/prosemirror/index.js.map 305.53 KB
148
- ESM ⚡️ Build success in 46ms
149
149
  ESM dist/react/index.js 20.70 KB
150
150
  ESM dist/react/testing.js 122.00 B
151
151
  ESM dist/react/index.js.map 34.13 KB
152
152
  ESM dist/react/testing.js.map 165.00 B
153
- ESM ⚡️ Build success in 45ms
154
- ESM dist/react/testing.js 107.00 B
155
- ESM dist/react/ssr.js 688.00 B
156
- ESM dist/react/index.js 20.68 KB
157
- ESM dist/react/testing.js.map 163.00 B
158
- ESM dist/react/ssr.js.map 1.12 KB
159
- ESM dist/react/index.js.map 34.13 KB
160
- ESM ⚡️ Build success in 45ms
153
+ ESM ⚡️ Build success in 59ms
161
154
  ESM dist/react-native-core/index.js 16.95 KB
162
155
  ESM dist/react-native-core/testing.js 119.00 B
163
156
  ESM dist/react-native-core/crypto.js 2.10 KB
164
157
  ESM dist/react-native-core/index.js.map 33.57 KB
165
158
  ESM dist/react-native-core/testing.js.map 175.00 B
166
159
  ESM dist/react-native-core/crypto.js.map 4.25 KB
167
- ESM ⚡️ Build success in 44ms
160
+ ESM ⚡️ Build success in 57ms
161
+ ESM dist/prosemirror/index.js 76.90 KB
162
+ ESM dist/prosemirror/index.js.map 305.53 KB
163
+ ESM ⚡️ Build success in 60ms
168
164
  ESM dist/inspector/index.js 60.37 KB
169
165
  ESM dist/inspector/index.js.map 107.85 KB
170
- ESM ⚡️ Build success in 60ms
166
+ ESM ⚡️ Build success in 76ms
167
+ ESM dist/chunk-OSVAAVWQ.js 149.48 KB
171
168
  ESM dist/testing.js 6.72 KB
172
- ESM dist/index.js 16.19 KB
173
- ESM dist/chunk-4CFNXQE7.js 146.58 KB
169
+ ESM dist/index.js 26.04 KB
174
170
  ESM dist/testing.js.map 13.03 KB
175
- ESM dist/index.js.map 29.03 KB
176
- ESM dist/chunk-4CFNXQE7.js.map 356.50 KB
177
- ESM ⚡️ Build success in 78ms
171
+ ESM dist/index.js.map 52.58 KB
172
+ ESM dist/chunk-OSVAAVWQ.js.map 363.53 KB
173
+ ESM ⚡️ Build success in 96ms
178
174
  ESM dist/inspector/register-custom-element.js 218.00 B
179
175
  ESM dist/inspector/register-custom-element.js.map 314.00 B
180
176
  ESM dist/inspector/custom-element-TUXKXSZU.js 1.53 MB
181
177
  ESM dist/inspector/custom-element-TUXKXSZU.js.map 2.35 MB
182
- ESM ⚡️ Build success in 116ms
178
+ ESM ⚡️ Build success in 145ms
183
179
 
184
- > jazz-tools@0.15.15 types /home/runner/_work/jazz/jazz/packages/jazz-tools
180
+ > jazz-tools@0.15.16 types /home/runner/_work/jazz/jazz/packages/jazz-tools
185
181
  > tsc --outDir dist
186
182
 
187
183
 
188
- > jazz-tools@0.15.15 build:svelte /home/runner/_work/jazz/jazz/packages/jazz-tools
184
+ > jazz-tools@0.15.16 build:svelte /home/runner/_work/jazz/jazz/packages/jazz-tools
189
185
  > rm -rf dist/svelte && svelte-package -i src/svelte -o dist/svelte --tsconfig tsconfig.svelte.json
190
186
 
191
187
  src/svelte -> dist/svelte
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # jazz-tools
2
2
 
3
+ ## 0.15.16
4
+
5
+ ### Patch Changes
6
+
7
+ - 9633d01: Introduced a new HTTP based API to talk with Server Workers
8
+ - 4beafb7: Fix property update when assigning an optional reference on CoMap
9
+ - cojson@0.15.16
10
+ - cojson-storage-indexeddb@0.15.16
11
+ - cojson-transport-ws@0.15.16
12
+
3
13
  ## 0.15.15
4
14
 
5
15
  ### Patch Changes
@@ -88,6 +88,11 @@ function tuple(options, params) {
88
88
  return zodTuple(options, params);
89
89
  }
90
90
 
91
+ // src/tools/coValues/interfaces.ts
92
+ import {
93
+ emptyKnownState
94
+ } from "cojson";
95
+
91
96
  // src/tools/coValues/CoValueBase.ts
92
97
  import { ControlledAccount, RawAccount } from "cojson";
93
98
  var CoValueBase = class {
@@ -2179,6 +2184,13 @@ var Profile = class extends CoMap {
2179
2184
 
2180
2185
  // src/tools/coValues/inbox.ts
2181
2186
  import { RawAccount as RawAccount4 } from "cojson";
2187
+
2188
+ // src/tools/lib/id.ts
2189
+ function isCoValueId(id) {
2190
+ return typeof id === "string" && id.startsWith("co_z");
2191
+ }
2192
+
2193
+ // src/tools/coValues/inbox.ts
2182
2194
  function createInboxRoot(account) {
2183
2195
  if (!account.isLocalNodeOwner) {
2184
2196
  throw new Error("Account is not controlled");
@@ -2403,7 +2415,7 @@ async function acceptInvite(invite, account) {
2403
2415
  account ||= activeAccountContext.get();
2404
2416
  const id = invite.slice(0, invite.indexOf("/"));
2405
2417
  const inviteSecret = invite.slice(invite.indexOf("/") + 1);
2406
- if (!id?.startsWith("co_z") || !inviteSecret.startsWith("inviteSecret_")) {
2418
+ if (!isCoValueId(id) || !inviteSecret.startsWith("inviteSecret_")) {
2407
2419
  throw new Error("Invalid inbox ticket");
2408
2420
  }
2409
2421
  if (!account.isLocalNodeOwner) {
@@ -2415,7 +2427,7 @@ async function acceptInvite(invite, account) {
2415
2427
  function getAccountIDfromSessionID(sessionID) {
2416
2428
  const until = sessionID.indexOf("_session");
2417
2429
  const accountID = sessionID.slice(0, until);
2418
- if (accountID.startsWith("co_z")) {
2430
+ if (isCoValueId(accountID)) {
2419
2431
  return accountID;
2420
2432
  }
2421
2433
  return;
@@ -3027,11 +3039,12 @@ function createCoValue(ref2, raw, subscriptionScope) {
3027
3039
 
3028
3040
  // src/tools/subscribe/SubscriptionScope.ts
3029
3041
  var SubscriptionScope = class _SubscriptionScope {
3030
- constructor(node, resolve, id, schema, skipRetry) {
3042
+ constructor(node, resolve, id, schema, skipRetry = false, bestEffortResolution = false) {
3031
3043
  this.node = node;
3032
3044
  this.id = id;
3033
3045
  this.schema = schema;
3034
3046
  this.skipRetry = skipRetry;
3047
+ this.bestEffortResolution = bestEffortResolution;
3035
3048
  this.childNodes = /* @__PURE__ */ new Map();
3036
3049
  this.childValues = /* @__PURE__ */ new Map();
3037
3050
  this.childErrors = /* @__PURE__ */ new Map();
@@ -3162,6 +3175,9 @@ var SubscriptionScope = class _SubscriptionScope {
3162
3175
  if (this.childErrors.size === 0 && this.validationErrors.size === 0) {
3163
3176
  return void 0;
3164
3177
  }
3178
+ if (this.bestEffortResolution) {
3179
+ return void 0;
3180
+ }
3165
3181
  for (const [key, value] of this.childErrors.entries()) {
3166
3182
  if (this.autoloaded.has(key)) {
3167
3183
  continue;
@@ -3289,7 +3305,9 @@ var SubscriptionScope = class _SubscriptionScope {
3289
3305
  this.node,
3290
3306
  true,
3291
3307
  id,
3292
- descriptor
3308
+ descriptor,
3309
+ this.skipRetry,
3310
+ this.bestEffortResolution
3293
3311
  );
3294
3312
  this.childNodes.set(id, child);
3295
3313
  child.setListener((value) => this.handleChildUpdate(id, value));
@@ -3468,7 +3486,9 @@ var SubscriptionScope = class _SubscriptionScope {
3468
3486
  this.node,
3469
3487
  resolve,
3470
3488
  id,
3471
- descriptor
3489
+ descriptor,
3490
+ this.skipRetry,
3491
+ this.bestEffortResolution
3472
3492
  );
3473
3493
  this.childNodes.set(id, child);
3474
3494
  child.setListener((value) => this.handleChildUpdate(id, value, key));
@@ -5074,12 +5094,87 @@ function parseGroupCreateOptions(options) {
5074
5094
  }
5075
5095
  return "_type" in options && isAccountInstance(options) ? { owner: options } : { owner: options.owner ?? activeAccountContext.get() };
5076
5096
  }
5097
+ async function exportCoValue(cls, id, options) {
5098
+ const loadAs = options.loadAs ?? activeAccountContext.get();
5099
+ const node = "node" in loadAs ? loadAs.node : loadAs._raw.core.node;
5100
+ const resolve = options.resolve ?? true;
5101
+ const rootNode = new SubscriptionScope(
5102
+ node,
5103
+ resolve,
5104
+ id,
5105
+ {
5106
+ ref: anySchemaToCoSchema(cls),
5107
+ optional: false
5108
+ },
5109
+ options.skipRetry,
5110
+ options.bestEffortResolution
5111
+ );
5112
+ const value = await new Promise((resolve2) => {
5113
+ rootNode.setListener((value2) => {
5114
+ if (value2.type === "unavailable") {
5115
+ resolve2(null);
5116
+ console.error(value2.toString());
5117
+ } else if (value2.type === "unauthorized") {
5118
+ resolve2(null);
5119
+ console.error(value2.toString());
5120
+ } else if (value2.type === "loaded") {
5121
+ resolve2(value2.value);
5122
+ }
5123
+ rootNode.destroy();
5124
+ });
5125
+ });
5126
+ if (!value) {
5127
+ return null;
5128
+ }
5129
+ const valuesExported = /* @__PURE__ */ new Set();
5130
+ const contentPieces = [];
5131
+ loadContentPiecesFromSubscription(rootNode, valuesExported, contentPieces);
5132
+ return contentPieces;
5133
+ }
5134
+ function loadContentPiecesFromSubscription(subscription, valuesExported, contentPieces) {
5135
+ if (valuesExported.has(subscription.id)) {
5136
+ return;
5137
+ }
5138
+ valuesExported.add(subscription.id);
5139
+ const core2 = subscription.getCurrentValue()?._raw.core;
5140
+ if (core2) {
5141
+ loadContentPiecesFromCoValue(core2, valuesExported, contentPieces);
5142
+ }
5143
+ for (const child of subscription.childNodes.values()) {
5144
+ loadContentPiecesFromSubscription(child, valuesExported, contentPieces);
5145
+ }
5146
+ }
5147
+ function loadContentPiecesFromCoValue(core2, valuesExported, contentPieces) {
5148
+ for (const dependency of core2.getDependedOnCoValues()) {
5149
+ if (valuesExported.has(dependency)) {
5150
+ continue;
5151
+ }
5152
+ const depCoValue = core2.node.getCoValue(dependency);
5153
+ if (depCoValue.isAvailable()) {
5154
+ valuesExported.add(dependency);
5155
+ loadContentPiecesFromCoValue(depCoValue, valuesExported, contentPieces);
5156
+ }
5157
+ }
5158
+ const pieces = core2.verified.newContentSince(emptyKnownState(core2.id));
5159
+ for (const piece of pieces ?? []) {
5160
+ contentPieces.push(piece);
5161
+ }
5162
+ }
5163
+ function importContentPieces(contentPieces, loadAs) {
5164
+ const account = loadAs ?? Account.getMe();
5165
+ const node = "node" in account ? account.node : account._raw.core.node;
5166
+ for (const piece of contentPieces) {
5167
+ node.syncManager.handleNewContent(piece, "import");
5168
+ }
5169
+ }
5077
5170
 
5078
5171
  export {
5079
5172
  zodReExport_exports,
5080
5173
  loadCoValue,
5081
5174
  subscribeToCoValue,
5082
5175
  createCoValueObservable,
5176
+ exportCoValue,
5177
+ importContentPieces,
5083
5178
  CoValueBase,
5084
5179
  CoMap,
5085
5180
  CoList,
@@ -5089,6 +5184,7 @@ export {
5089
5184
  isControlledAccount,
5090
5185
  Group,
5091
5186
  Profile,
5187
+ isCoValueId,
5092
5188
  Inbox,
5093
5189
  InboxSender,
5094
5190
  CoPlainText,
@@ -5106,6 +5202,7 @@ export {
5106
5202
  createAnonymousJazzContext,
5107
5203
  zodSchemaToCoSchema,
5108
5204
  anySchemaToCoSchema,
5205
+ coMapDefiner,
5109
5206
  coExport_exports,
5110
5207
  ImageDefinition,
5111
5208
  KvStoreContext,
@@ -5114,4 +5211,4 @@ export {
5114
5211
  JazzContextManager
5115
5212
  };
5116
5213
  /* istanbul ignore file -- @preserve */
5117
- //# sourceMappingURL=chunk-4CFNXQE7.js.map
5214
+ //# sourceMappingURL=chunk-OSVAAVWQ.js.map