jazz-react-native 0.8.35 → 0.8.36
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +10 -0
- package/README.md +5 -5
- package/dist/index.d.ts +8 -8
- package/dist/index.js +0 -8
- package/dist/index.js.map +1 -1
- package/dist/provider.d.ts +2 -0
- package/dist/provider.js +6 -1
- package/dist/provider.js.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +13 -22
- package/src/provider.tsx +13 -5
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# jazz-browser
|
2
2
|
|
3
|
+
## 0.8.36
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- c84764a: feat: added jazz-react-native-auth-clerk package
|
8
|
+
- Updated dependencies [441fe27]
|
9
|
+
- cojson@0.8.36
|
10
|
+
- jazz-tools@0.8.36
|
11
|
+
- cojson-transport-ws@0.8.36
|
12
|
+
|
3
13
|
## 0.8.35
|
4
14
|
|
5
15
|
### Patch Changes
|
package/README.md
CHANGED
@@ -25,7 +25,7 @@ npx expo prebuild
|
|
25
25
|
### Install dependencies
|
26
26
|
|
27
27
|
```bash
|
28
|
-
npx expo install expo-linking expo-secure-store expo-file-system @react-native-community/netinfo @bam.tech/react-native-image-resizer
|
28
|
+
npx expo install expo-linking expo-secure-store expo-file-system @react-native-community/netinfo @bam.tech/react-native-image-resizer @azure/core-asynciterator-polyfill
|
29
29
|
|
30
30
|
npm i -S react-native-polyfill-globals react-native-url-polyfill web-streams-polyfill base-64 text-encoding react-native-fetch-api react-native-get-random-values buffer
|
31
31
|
|
@@ -196,8 +196,8 @@ You can optionally pass a custom `kvStore` and `AccountSchema` to `createJazzRNA
|
|
196
196
|
|
197
197
|
Refer to the Jazz + React Native demo projects for implementing authentication:
|
198
198
|
|
199
|
-
- [DemoAuth Example](https://github.com/
|
200
|
-
- [ClerkAuth Example](https://github.com/
|
199
|
+
- [DemoAuth Example](https://github.com/garden-co/jazz/tree/main/examples/chat-rn)
|
200
|
+
- [ClerkAuth Example](https://github.com/garden-co/jazz/tree/main/examples/chat-rn-clerk)
|
201
201
|
|
202
202
|
In the demos, you'll find details on:
|
203
203
|
|
@@ -208,7 +208,7 @@ In the demos, you'll find details on:
|
|
208
208
|
|
209
209
|
### 🖼️ Working with Images
|
210
210
|
|
211
|
-
To work with images in Jazz, import the `createImage` function from [`jazz-react-native-media-images`](https://github.com/
|
211
|
+
To work with images in Jazz, import the `createImage` function from [`jazz-react-native-media-images`](https://github.com/garden-co/jazz/tree/main/packages/jazz-react-native-media-images).
|
212
212
|
|
213
213
|
```js
|
214
214
|
import { createImage } from "jazz-react-native-media-images";
|
@@ -223,7 +223,7 @@ const image = await createImage(base64ImageDataURI, {
|
|
223
223
|
someCovalue.image = image;
|
224
224
|
```
|
225
225
|
|
226
|
-
For a complete implementation, please refer to [this](https://github.com/
|
226
|
+
For a complete implementation, please refer to [this](https://github.com/garden-co/jazz/blob/main/examples/pets/src/3_NewPetPostForm.tsx) demo.
|
227
227
|
|
228
228
|
### 📱 Running Your App
|
229
229
|
|
package/dist/index.d.ts
CHANGED
@@ -2,32 +2,32 @@ import { Account, AgentID, AnonymousJazzAgent, AuthMethod, CoValue, CoValueClass
|
|
2
2
|
import { RawAccountID } from "cojson";
|
3
3
|
export { RNDemoAuth } from "./auth/DemoAuthMethod.js";
|
4
4
|
/** @category Context Creation */
|
5
|
-
export type
|
5
|
+
export type ReactNativeContext<Acc extends Account> = {
|
6
6
|
me: Acc;
|
7
7
|
logOut: () => void;
|
8
8
|
done: () => void;
|
9
9
|
};
|
10
|
-
export type
|
10
|
+
export type ReactNativeGuestContext = {
|
11
11
|
guest: AnonymousJazzAgent;
|
12
12
|
logOut: () => void;
|
13
13
|
done: () => void;
|
14
14
|
};
|
15
|
-
export type
|
15
|
+
export type ReactNativeContextOptions<Acc extends Account> = {
|
16
16
|
auth: AuthMethod;
|
17
17
|
AccountSchema: CoValueClass<Acc> & {
|
18
18
|
fromNode: (typeof Account)["fromNode"];
|
19
19
|
};
|
20
|
-
} &
|
21
|
-
export type
|
20
|
+
} & BaseReactNativeContextOptions;
|
21
|
+
export type BaseReactNativeContextOptions = {
|
22
22
|
peer: `wss://${string}` | `ws://${string}`;
|
23
23
|
reconnectionTimeout?: number;
|
24
24
|
storage?: "indexedDB" | "singleTabOPFS";
|
25
25
|
crypto?: CryptoProvider;
|
26
26
|
};
|
27
27
|
/** @category Context Creation */
|
28
|
-
export declare function createJazzRNContext<Acc extends Account>(options:
|
29
|
-
export declare function createJazzRNContext(options:
|
30
|
-
export declare function createJazzRNContext<Acc extends Account>(options:
|
28
|
+
export declare function createJazzRNContext<Acc extends Account>(options: ReactNativeContextOptions<Acc>): Promise<ReactNativeContext<Acc>>;
|
29
|
+
export declare function createJazzRNContext(options: BaseReactNativeContextOptions): Promise<ReactNativeGuestContext>;
|
30
|
+
export declare function createJazzRNContext<Acc extends Account>(options: ReactNativeContextOptions<Acc> | BaseReactNativeContextOptions): Promise<ReactNativeContext<Acc> | ReactNativeGuestContext>;
|
31
31
|
/** @category Auth Providers */
|
32
32
|
export type SessionProvider = (accountID: ID<Account> | AgentID) => Promise<SessionID>;
|
33
33
|
export declare function provideLockSession(accountID: ID<Account> | AgentID, crypto: CryptoProvider): Promise<{
|
package/dist/index.js
CHANGED
@@ -98,14 +98,6 @@ export async function provideLockSession(accountID, crypto) {
|
|
98
98
|
sessionDone,
|
99
99
|
});
|
100
100
|
}
|
101
|
-
const window = {
|
102
|
-
location: {
|
103
|
-
href: "#",
|
104
|
-
},
|
105
|
-
history: {
|
106
|
-
replaceState: (a, b, c) => { },
|
107
|
-
},
|
108
|
-
};
|
109
101
|
/** @category Invite Links */
|
110
102
|
export function createInviteLink(value, role, { baseURL, valueHint } = {}) {
|
111
103
|
const coValueCore = value._raw.core;
|
package/dist/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,sDAAsD;AACtD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AC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,+BAA+B,CAAC"}
|
package/dist/provider.d.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import React from "react";
|
2
2
|
import { Account, AccountClass, AnonymousJazzAgent, AuthMethod, CoValue, CoValueClass, DeeplyLoaded, DepthsIn, ID } from "jazz-tools";
|
3
|
+
import { KvStore } from "./index.js";
|
3
4
|
import { ExpoSecureStoreAdapter } from "./storage/expo-secure-store-adapter.js";
|
4
5
|
/** @category Context & Hooks */
|
5
6
|
export declare function createJazzRNApp<Acc extends Account>({ kvStore, AccountSchema, }?: {
|
@@ -42,5 +43,6 @@ export interface JazzReactApp<Acc extends Account> {
|
|
42
43
|
onAccept: (projectID: ID<V>) => void;
|
43
44
|
forValueHint?: string;
|
44
45
|
}): void;
|
46
|
+
kvStore: KvStore;
|
45
47
|
}
|
46
48
|
export * from "./media.js";
|
package/dist/provider.js
CHANGED
@@ -36,7 +36,11 @@ export function createJazzRNApp({ kvStore = new ExpoSecureStoreAdapter(), Accoun
|
|
36
36
|
return context.done;
|
37
37
|
});
|
38
38
|
return () => {
|
39
|
-
void promiseWithDoneCallback
|
39
|
+
void promiseWithDoneCallback
|
40
|
+
.then((done) => done())
|
41
|
+
.catch((e) => {
|
42
|
+
console.error("Error in createJazzRNContext", e);
|
43
|
+
});
|
40
44
|
};
|
41
45
|
}, [AccountSchema, auth, peer, storage, sessionCount]);
|
42
46
|
return (<JazzContext.Provider value={ctx}>{ctx && children}</JazzContext.Provider>);
|
@@ -126,6 +130,7 @@ export function createJazzRNApp({ kvStore = new ExpoSecureStoreAdapter(), Accoun
|
|
126
130
|
useAccountOrGuest,
|
127
131
|
useCoState,
|
128
132
|
useAcceptInvite,
|
133
|
+
kvStore,
|
129
134
|
};
|
130
135
|
}
|
131
136
|
export * from "./media.js";
|
package/dist/provider.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.tsx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AAO,CAAC,EAAE;yBACP,YAAY,CACX,MAAM,CAAC,OAAO,EACd,MAAM,CAAC,YAAY,EACnB,mBAAmB,CACpB;yBACA,IAAI,CAAC,GAAG,EAAE;wBACT,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;oBAC3B,CAAC,CAAC;yBACD,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;wBACX,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,CAAC,CAAC,CAAC;oBAC9C,CAAC,CAAC,CAAC;gBACP,CAAC;YACH,CAAC,CAAC;YAEF,MAAM,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;YAExE,KAAK,OAAO,CAAC,aAAa,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;gBACxC,IAAI,GAAG;oBAAE,cAAc,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;YACnC,CAAC,CAAC,CAAC;YAEH,OAAO,GAAG,EAAE;gBACV,eAAe,CAAC,MAAM,EAAE,CAAC;YAC3B,CAAC,CAAC;QACJ,CAAC,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,YAAY,CAAC,CAAC,CAAC;IAC7D,CAAC;IAED,OAAO;QACL,QAAQ;QACR,UAAU;QACV,iBAAiB;QACjB,UAAU;QACV,eAAe;QACf,OAAO;KACR,CAAC;AACJ,CAAC;AAwDD,cAAc,YAAY,CAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "jazz-react-native",
|
3
|
-
"version": "0.8.
|
3
|
+
"version": "0.8.36",
|
4
4
|
"type": "module",
|
5
5
|
"main": "./dist/index.js",
|
6
6
|
"module": "./dist/index.js",
|
@@ -16,9 +16,9 @@
|
|
16
16
|
"license": "MIT",
|
17
17
|
"dependencies": {
|
18
18
|
"@scure/bip39": "^1.3.0",
|
19
|
-
"cojson": "0.8.
|
20
|
-
"cojson-transport-ws": "0.8.
|
21
|
-
"jazz-tools": "0.8.
|
19
|
+
"cojson": "0.8.36",
|
20
|
+
"cojson-transport-ws": "0.8.36",
|
21
|
+
"jazz-tools": "0.8.36"
|
22
22
|
},
|
23
23
|
"peerDependencies": {
|
24
24
|
"@react-native-community/netinfo": "*",
|
package/src/index.ts
CHANGED
@@ -26,27 +26,27 @@ export { RNDemoAuth } from "./auth/DemoAuthMethod.js";
|
|
26
26
|
import { KvStoreContext } from "./storage/kv-store-context.js";
|
27
27
|
|
28
28
|
/** @category Context Creation */
|
29
|
-
export type
|
29
|
+
export type ReactNativeContext<Acc extends Account> = {
|
30
30
|
me: Acc;
|
31
31
|
logOut: () => void;
|
32
32
|
// TODO: Symbol.dispose?
|
33
33
|
done: () => void;
|
34
34
|
};
|
35
35
|
|
36
|
-
export type
|
36
|
+
export type ReactNativeGuestContext = {
|
37
37
|
guest: AnonymousJazzAgent;
|
38
38
|
logOut: () => void;
|
39
39
|
done: () => void;
|
40
40
|
};
|
41
41
|
|
42
|
-
export type
|
42
|
+
export type ReactNativeContextOptions<Acc extends Account> = {
|
43
43
|
auth: AuthMethod;
|
44
44
|
AccountSchema: CoValueClass<Acc> & {
|
45
45
|
fromNode: (typeof Account)["fromNode"];
|
46
46
|
};
|
47
|
-
} &
|
47
|
+
} & BaseReactNativeContextOptions;
|
48
48
|
|
49
|
-
export type
|
49
|
+
export type BaseReactNativeContextOptions = {
|
50
50
|
peer: `wss://${string}` | `ws://${string}`;
|
51
51
|
reconnectionTimeout?: number;
|
52
52
|
storage?: "indexedDB" | "singleTabOPFS";
|
@@ -55,17 +55,17 @@ export type BaseBrowserContextOptions = {
|
|
55
55
|
|
56
56
|
/** @category Context Creation */
|
57
57
|
export async function createJazzRNContext<Acc extends Account>(
|
58
|
-
options:
|
59
|
-
): Promise<
|
58
|
+
options: ReactNativeContextOptions<Acc>,
|
59
|
+
): Promise<ReactNativeContext<Acc>>;
|
60
60
|
export async function createJazzRNContext(
|
61
|
-
options:
|
62
|
-
): Promise<
|
61
|
+
options: BaseReactNativeContextOptions,
|
62
|
+
): Promise<ReactNativeGuestContext>;
|
63
63
|
export async function createJazzRNContext<Acc extends Account>(
|
64
|
-
options:
|
65
|
-
): Promise<
|
64
|
+
options: ReactNativeContextOptions<Acc> | BaseReactNativeContextOptions,
|
65
|
+
): Promise<ReactNativeContext<Acc> | ReactNativeGuestContext>;
|
66
66
|
export async function createJazzRNContext<Acc extends Account>(
|
67
|
-
options:
|
68
|
-
): Promise<
|
67
|
+
options: ReactNativeContextOptions<Acc> | BaseReactNativeContextOptions,
|
68
|
+
): Promise<ReactNativeContext<Acc> | ReactNativeGuestContext> {
|
69
69
|
const firstWsPeer = createWebSocketPeer({
|
70
70
|
websocket: new WebSocket(options.peer),
|
71
71
|
id: options.peer + "@" + new Date().toISOString(),
|
@@ -192,15 +192,6 @@ export async function provideLockSession(
|
|
192
192
|
});
|
193
193
|
}
|
194
194
|
|
195
|
-
const window = {
|
196
|
-
location: {
|
197
|
-
href: "#",
|
198
|
-
},
|
199
|
-
history: {
|
200
|
-
replaceState: (a: any, b: any, c: any) => {},
|
201
|
-
},
|
202
|
-
};
|
203
|
-
|
204
195
|
/** @category Invite Links */
|
205
196
|
export function createInviteLink<C extends CoValue>(
|
206
197
|
value: C,
|
package/src/provider.tsx
CHANGED
@@ -14,9 +14,10 @@ import {
|
|
14
14
|
} from "jazz-tools";
|
15
15
|
import { Linking } from "react-native";
|
16
16
|
import {
|
17
|
-
|
18
|
-
BrowserGuestContext,
|
17
|
+
KvStore,
|
19
18
|
KvStoreContext,
|
19
|
+
ReactNativeContext,
|
20
|
+
ReactNativeGuestContext,
|
20
21
|
createJazzRNContext,
|
21
22
|
parseInviteLink,
|
22
23
|
} from "./index.js";
|
@@ -28,7 +29,7 @@ export function createJazzRNApp<Acc extends Account>({
|
|
28
29
|
AccountSchema = Account as unknown as AccountClass<Acc>,
|
29
30
|
} = {}): JazzReactApp<Acc> {
|
30
31
|
const JazzContext = React.createContext<
|
31
|
-
|
32
|
+
ReactNativeContext<Acc> | ReactNativeGuestContext | undefined
|
32
33
|
>(undefined);
|
33
34
|
|
34
35
|
if (!kvStore) {
|
@@ -49,7 +50,7 @@ export function createJazzRNApp<Acc extends Account>({
|
|
49
50
|
storage?: "indexedDB" | "singleTabOPFS";
|
50
51
|
}) {
|
51
52
|
const [ctx, setCtx] = useState<
|
52
|
-
|
53
|
+
ReactNativeContext<Acc> | ReactNativeGuestContext | undefined
|
53
54
|
>();
|
54
55
|
|
55
56
|
const [sessionCount, setSessionCount] = useState(0);
|
@@ -80,7 +81,11 @@ export function createJazzRNApp<Acc extends Account>({
|
|
80
81
|
});
|
81
82
|
|
82
83
|
return () => {
|
83
|
-
void promiseWithDoneCallback
|
84
|
+
void promiseWithDoneCallback
|
85
|
+
.then((done) => done())
|
86
|
+
.catch((e) => {
|
87
|
+
console.error("Error in createJazzRNContext", e);
|
88
|
+
});
|
84
89
|
};
|
85
90
|
}, [AccountSchema, auth, peer, storage, sessionCount]);
|
86
91
|
|
@@ -240,6 +245,7 @@ export function createJazzRNApp<Acc extends Account>({
|
|
240
245
|
useAccountOrGuest,
|
241
246
|
useCoState,
|
242
247
|
useAcceptInvite,
|
248
|
+
kvStore,
|
243
249
|
};
|
244
250
|
}
|
245
251
|
|
@@ -293,6 +299,8 @@ export interface JazzReactApp<Acc extends Account> {
|
|
293
299
|
onAccept: (projectID: ID<V>) => void;
|
294
300
|
forValueHint?: string;
|
295
301
|
}): void;
|
302
|
+
|
303
|
+
kvStore: KvStore;
|
296
304
|
}
|
297
305
|
|
298
306
|
export * from "./media.js";
|