jazz-tools 0.18.10 → 0.18.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.
@@ -32,7 +32,7 @@ export declare function getAuthSecretStorage(): AuthSecretStorage;
32
32
  export declare class InviteListener<V extends CoValueClassOrSchema> {
33
33
  constructor({ invitedObjectSchema, onAccept, forValueHint, }: {
34
34
  invitedObjectSchema: V;
35
- onAccept: (projectID: ID<V>) => void;
35
+ onAccept: (coValueID: ID<V>) => void;
36
36
  forValueHint?: string;
37
37
  });
38
38
  }
@@ -1 +1 @@
1
- {"version":3,"file":"jazz.svelte.d.ts","sourceRoot":"","sources":["../../../src/svelte/jazz.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,iBAAiB,EACjB,oBAAoB,EACpB,EAAE,EAEF,eAAe,EAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAGrC,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,CAAC;AAE1C;;GAEG;AACH,eAAO,MAAM,QAAQ,IAAK,CAAC;AAC3B,eAAO,MAAM,aAAa,IAAK,CAAC;AAEhC;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,GAAG,SAAS,OAAO,IAAI;IAC7C,OAAO,CAAC,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC;CAChC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,cAAc,CAAC,GAAG,SAAS,OAAO,KAW9B;IAChB,OAAO,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC;CAC/B,CACF;AAED,wBAAgB,oBAAoB,sBAUnC;AAED;;;;;;;GAOG;AACH,qBAAa,cAAc,CAAC,CAAC,SAAS,oBAAoB;gBAC5C,EACV,mBAAmB,EACnB,QAAQ,EACR,YAAY,GACb,EAAE;QACD,mBAAmB,EAAE,CAAC,CAAC;QACvB,QAAQ,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;QACrC,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB;CA+BF"}
1
+ {"version":3,"file":"jazz.svelte.d.ts","sourceRoot":"","sources":["../../../src/svelte/jazz.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,iBAAiB,EACjB,oBAAoB,EACpB,EAAE,EAEF,eAAe,EAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAGrC,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,QAAQ,IAAI,kBAAkB,EAAE,CAAC;AAE1C;;GAEG;AACH,eAAO,MAAM,QAAQ,IAAK,CAAC;AAC3B,eAAO,MAAM,aAAa,IAAK,CAAC;AAEhC;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,GAAG,SAAS,OAAO,IAAI;IAC7C,OAAO,CAAC,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC;CAChC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,cAAc,CAAC,GAAG,SAAS,OAAO,KAW9B;IAChB,OAAO,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC;CAC/B,CACF;AAED,wBAAgB,oBAAoB,sBAUnC;AAED;;;;;;;GAOG;AACH,qBAAa,cAAc,CAAC,CAAC,SAAS,oBAAoB;gBAC5C,EACV,mBAAmB,EACnB,QAAQ,EACR,YAAY,GACb,EAAE;QACD,mBAAmB,EAAE,CAAC,CAAC;QACvB,QAAQ,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;QACrC,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB;CA2BF"}
@@ -1,5 +1,5 @@
1
1
  import { consumeInviteLinkFromWindowLocation } from "jazz-tools/browser";
2
- import { getContext, untrack } from "svelte";
2
+ import { getContext, onDestroy, untrack } from "svelte";
3
3
  import Provider from "./Provider.svelte";
4
4
  export { Provider as JazzSvelteProvider };
5
5
  /**
@@ -38,33 +38,26 @@ export function getAuthSecretStorage() {
38
38
  */
39
39
  export class InviteListener {
40
40
  constructor({ invitedObjectSchema, onAccept, forValueHint, }) {
41
- // TODO Listen to the hashchange event
42
41
  const _onAccept = onAccept;
43
- // Subscribe to the onAccept function.
42
+ const ctx = getJazzContext();
43
+ const tryConsume = () => {
44
+ if (!ctx.current || !("me" in ctx.current))
45
+ return;
46
+ consumeInviteLinkFromWindowLocation({
47
+ as: ctx.current.me,
48
+ invitedObjectSchema,
49
+ forValueHint,
50
+ })
51
+ .then((result) => result && _onAccept(result.valueID))
52
+ .catch((e) => console.error("Failed to accept invite", e));
53
+ };
54
+ // run once when instantiated
44
55
  $effect(() => {
45
- const ctx = getJazzContext();
46
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions
47
- _onAccept;
48
- // Subscribe to the onAccept function.
49
- untrack(() => {
50
- // If there is no context, return.
51
- if (!ctx.current)
52
- return;
53
- if (!("me" in ctx.current))
54
- return;
55
- // Consume the invite link from the window location.
56
- const result = consumeInviteLinkFromWindowLocation({
57
- as: ctx.current.me,
58
- invitedObjectSchema,
59
- forValueHint,
60
- });
61
- // If the result is valid, call the onAccept function.
62
- result
63
- .then((result) => result && _onAccept(result?.valueID))
64
- .catch((e) => {
65
- console.error("Failed to accept invite", e);
66
- });
67
- });
56
+ untrack(tryConsume);
57
+ });
58
+ window.addEventListener("hashchange", tryConsume);
59
+ onDestroy(() => {
60
+ window.removeEventListener("hashchange", tryConsume);
68
61
  });
69
62
  }
70
63
  }
@@ -1,5 +1,5 @@
1
1
 
2
- > jazz-tools@0.18.10 build /home/runner/_work/jazz/jazz/packages/jazz-tools
2
+ > jazz-tools@0.18.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"}
@@ -107,15 +107,15 @@
107
107
  ESM Build start
108
108
  CLI Cleaning output folder
109
109
  ESM Build start
110
+ ESM dist/worker/index.js 3.19 KB
111
+ ESM dist/worker/index.js.map 6.17 KB
112
+ ESM ⚡️ Build success in 21ms
110
113
  ESM dist/react/ssr.js 688.00 B
111
114
  ESM dist/react/ssr.js.map 1.12 KB
112
- ESM ⚡️ Build success in 26ms
113
- ESM dist/worker/index.js 2.47 KB
114
- ESM dist/worker/index.js.map 5.26 KB
115
- ESM ⚡️ Build success in 22ms
115
+ ESM ⚡️ Build success in 27ms
116
116
  ESM dist/tiptap/index.js 564.00 B
117
117
  ESM dist/tiptap/index.js.map 1.21 KB
118
- ESM ⚡️ Build success in 22ms
118
+ ESM ⚡️ Build success in 23ms
119
119
  ESM dist/better-auth/auth/client.js 4.44 KB
120
120
  ESM dist/better-auth/auth/server.js 8.36 KB
121
121
  ESM dist/better-auth/auth/react.js 799.00 B
@@ -126,74 +126,74 @@
126
126
  ESM dist/media/index.js 236.00 B
127
127
  ESM dist/media/index.browser.js 2.79 KB
128
128
  ESM dist/media/index.native.js 2.90 KB
129
- ESM dist/media/index.server.js 2.95 KB
130
129
  ESM dist/media/chunk-W3S526L3.js 6.47 KB
130
+ ESM dist/media/index.server.js 2.95 KB
131
131
  ESM dist/media/index.js.map 71.00 B
132
132
  ESM dist/media/index.browser.js.map 6.15 KB
133
133
  ESM dist/media/index.native.js.map 6.09 KB
134
- ESM dist/media/index.server.js.map 6.37 KB
135
134
  ESM dist/media/chunk-W3S526L3.js.map 16.57 KB
136
- ESM ⚡️ Build success in 40ms
135
+ ESM dist/media/index.server.js.map 6.37 KB
136
+ ESM ⚡️ Build success in 33ms
137
+ ESM dist/browser/index.js 13.64 KB
138
+ ESM dist/browser/index.js.map 29.14 KB
139
+ ESM ⚡️ Build success in 43ms
137
140
  ESM dist/expo/index.js 4.68 KB
138
141
  ESM dist/expo/testing.js 112.00 B
139
142
  ESM dist/expo/crypto.js 153.00 B
140
143
  ESM dist/expo/index.js.map 10.23 KB
141
144
  ESM dist/expo/testing.js.map 168.00 B
142
145
  ESM dist/expo/crypto.js.map 189.00 B
143
- ESM ⚡️ Build success in 40ms
146
+ ESM ⚡️ Build success in 44ms
144
147
  ESM dist/react-native/index.js 2.53 KB
145
148
  ESM dist/react-native/testing.js 120.00 B
146
149
  ESM dist/react-native/crypto.js 161.00 B
147
150
  ESM dist/react-native/index.js.map 5.68 KB
148
151
  ESM dist/react-native/testing.js.map 176.00 B
149
152
  ESM dist/react-native/crypto.js.map 197.00 B
150
- ESM ⚡️ Build success in 36ms
151
- ESM dist/browser/index.js 13.64 KB
152
- ESM dist/browser/index.js.map 29.14 KB
153
- ESM ⚡️ Build success in 41ms
154
- ESM dist/react-native-core/index.js 18.00 KB
153
+ ESM ⚡️ Build success in 42ms
154
+ ESM dist/react-native-core/index.js 18.03 KB
155
155
  ESM dist/react-native-core/testing.js 119.00 B
156
156
  ESM dist/react-native-core/crypto.js 2.10 KB
157
- ESM dist/react-native-core/index.js.map 36.73 KB
157
+ ESM dist/react-native-core/index.js.map 36.85 KB
158
158
  ESM dist/react-native-core/testing.js.map 175.00 B
159
159
  ESM dist/react-native-core/crypto.js.map 4.25 KB
160
160
  ESM ⚡️ Build success in 46ms
161
161
  ESM dist/prosemirror/index.js 77.63 KB
162
162
  ESM dist/prosemirror/index.js.map 306.98 KB
163
- ESM ⚡️ Build success in 49ms
163
+ ESM ⚡️ Build success in 50ms
164
164
  ESM dist/react/index.js 24.76 KB
165
165
  ESM dist/react/testing.js 122.00 B
166
166
  ESM dist/react/index.js.map 53.56 KB
167
167
  ESM dist/react/testing.js.map 165.00 B
168
- ESM ⚡️ Build success in 49ms
168
+ ESM ⚡️ Build success in 50ms
169
169
  ESM dist/inspector/index.js 69.71 KB
170
170
  ESM dist/inspector/index.js.map 121.38 KB
171
- ESM ⚡️ Build success in 61ms
171
+ ESM ⚡️ Build success in 72ms
172
172
  ESM dist/testing.js 7.17 KB
173
+ ESM dist/chunk-PRSMJMJR.js 169.84 KB
173
174
  ESM dist/index.js 26.13 KB
174
- ESM dist/chunk-RQHJFPIB.js 169.74 KB
175
175
  ESM dist/testing.js.map 14.10 KB
176
+ ESM dist/chunk-PRSMJMJR.js.map 402.81 KB
176
177
  ESM dist/index.js.map 52.92 KB
177
- ESM dist/chunk-RQHJFPIB.js.map 402.59 KB
178
- ESM ⚡️ Build success in 88ms
179
- ESM dist/react-core/index.js 146.19 KB
178
+ ESM ⚡️ Build success in 96ms
179
+ ESM dist/react-core/index.js 146.29 KB
180
180
  ESM dist/react-core/testing.js 1.17 KB
181
181
  ESM dist/react-core/chunk-7DYMJ74I.js 279.00 B
182
+ ESM dist/react-core/index.js.map 404.67 KB
182
183
  ESM dist/react-core/testing.js.map 1.82 KB
183
184
  ESM dist/react-core/chunk-7DYMJ74I.js.map 533.00 B
184
- ESM dist/react-core/index.js.map 404.45 KB
185
- ESM ⚡️ Build success in 90ms
185
+ ESM ⚡️ Build success in 91ms
186
186
  ESM dist/inspector/register-custom-element.js 218.00 B
187
187
  ESM dist/inspector/register-custom-element.js.map 314.00 B
188
188
  ESM dist/inspector/custom-element-G6SPZEBR.js 1.54 MB
189
189
  ESM dist/inspector/custom-element-G6SPZEBR.js.map 2.36 MB
190
- ESM ⚡️ Build success in 122ms
190
+ ESM ⚡️ Build success in 135ms
191
191
 
192
- > jazz-tools@0.18.10 types /home/runner/_work/jazz/jazz/packages/jazz-tools
192
+ > jazz-tools@0.18.12 types /home/runner/_work/jazz/jazz/packages/jazz-tools
193
193
  > tsc --outDir dist
194
194
 
195
195
 
196
- > jazz-tools@0.18.10 build:svelte /home/runner/_work/jazz/jazz/packages/jazz-tools
196
+ > jazz-tools@0.18.12 build:svelte /home/runner/_work/jazz/jazz/packages/jazz-tools
197
197
  > rm -rf dist/svelte && svelte-package -i src/svelte -o dist/svelte --tsconfig tsconfig.svelte.json
198
198
 
199
199
  src/svelte -> dist/svelte
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # jazz-tools
2
2
 
3
+ ## 0.18.12
4
+
5
+ ### Patch Changes
6
+
7
+ - c16ce4b: Fix addMember with account owners, by detecting the accounts from their raw value
8
+ - 0b1b050: Export ReactNativeContextManager from react-native-core
9
+ - cojson@0.18.12
10
+ - cojson-storage-indexeddb@0.18.12
11
+ - cojson-transport-ws@0.18.12
12
+
13
+ ## 0.18.11
14
+
15
+ ### Patch Changes
16
+
17
+ - 06b4617: Update the Svelte InviteListener to listen to hash change events
18
+ - 70eb465: Add docs to the worker API and deprecate done in favor of shutdownWorker
19
+ - Updated dependencies [a4a9a1e]
20
+ - cojson@0.18.11
21
+ - cojson-storage-indexeddb@0.18.11
22
+ - cojson-transport-ws@0.18.11
23
+
3
24
  ## 0.18.10
4
25
 
5
26
  ### Patch Changes
@@ -2486,6 +2486,9 @@ function isControlledAccount(account) {
2486
2486
  RegisteredSchemas["Account"] = Account;
2487
2487
 
2488
2488
  // src/tools/coValues/group.ts
2489
+ import {
2490
+ RawAccount as RawAccount2
2491
+ } from "cojson";
2489
2492
  var _Group = class _Group extends CoValueBase {
2490
2493
  /** @deprecated Don't use constructor directly, use .create */
2491
2494
  constructor(options) {
@@ -2522,7 +2525,7 @@ var _Group = class _Group extends CoValueBase {
2522
2525
  return this.$jazz.raw.myRole();
2523
2526
  }
2524
2527
  addMember(member, role) {
2525
- if (member !== "everyone" && member[TypeSym] === "Group") {
2528
+ if (isGroupValue(member)) {
2526
2529
  if (role === "writeOnly")
2527
2530
  throw new Error("Cannot add group as member with write-only role");
2528
2531
  this.$jazz.raw.extend(member.$jazz.raw, role);
@@ -2534,7 +2537,7 @@ var _Group = class _Group extends CoValueBase {
2534
2537
  }
2535
2538
  }
2536
2539
  removeMember(member) {
2537
- if (member !== "everyone" && member[TypeSym] === "Group") {
2540
+ if (isGroupValue(member)) {
2538
2541
  this.$jazz.raw.revokeExtend(member.$jazz.raw);
2539
2542
  } else {
2540
2543
  return this.$jazz.raw.removeMember(
@@ -2693,6 +2696,9 @@ function getCoValueOwner(coValue) {
2693
2696
  }
2694
2697
  return group;
2695
2698
  }
2699
+ function isGroupValue(value) {
2700
+ return value !== "everyone" && !(value.$jazz.raw instanceof RawAccount2);
2701
+ }
2696
2702
 
2697
2703
  // src/tools/coValues/profile.ts
2698
2704
  var Profile = class extends CoMap {
@@ -2721,7 +2727,7 @@ var Profile = class extends CoMap {
2721
2727
 
2722
2728
  // src/tools/coValues/inbox.ts
2723
2729
  import {
2724
- RawAccount as RawAccount2
2730
+ RawAccount as RawAccount3
2725
2731
  } from "cojson";
2726
2732
 
2727
2733
  // src/tools/lib/id.ts
@@ -2765,7 +2771,7 @@ var IncrementalFeed = class {
2765
2771
  };
2766
2772
  async function createInboxMessage(payload, inboxOwner) {
2767
2773
  const group = payload.$jazz.raw.group;
2768
- if (group instanceof RawAccount2) {
2774
+ if (group instanceof RawAccount3) {
2769
2775
  throw new Error("Inbox messages should be owned by a group");
2770
2776
  }
2771
2777
  group.addMember(inboxOwner, "writer");
@@ -3677,7 +3683,7 @@ var JazzError = class _JazzError {
3677
3683
  };
3678
3684
 
3679
3685
  // src/tools/subscribe/utils.ts
3680
- import { RawAccount as RawAccount3 } from "cojson";
3686
+ import { RawAccount as RawAccount4 } from "cojson";
3681
3687
 
3682
3688
  // src/tools/lib/cache.ts
3683
3689
  var weakMap = /* @__PURE__ */ new WeakMap();
@@ -3698,7 +3704,7 @@ function myRoleForRawValue(raw) {
3698
3704
  const rawOwner = raw.group;
3699
3705
  const owner = coValuesCache.get(
3700
3706
  rawOwner,
3701
- () => rawOwner instanceof RawAccount3 ? RegisteredSchemas["Account"].fromRaw(rawOwner) : RegisteredSchemas["Group"].fromRaw(rawOwner)
3707
+ () => rawOwner instanceof RawAccount4 ? RegisteredSchemas["Account"].fromRaw(rawOwner) : RegisteredSchemas["Group"].fromRaw(rawOwner)
3702
3708
  );
3703
3709
  return accountOrGroupToGroup(owner).myRole();
3704
3710
  }
@@ -5942,4 +5948,4 @@ export {
5942
5948
  JazzContextManager
5943
5949
  };
5944
5950
  /* istanbul ignore file -- @preserve */
5945
- //# sourceMappingURL=chunk-RQHJFPIB.js.map
5951
+ //# sourceMappingURL=chunk-PRSMJMJR.js.map