jazz-tools 0.18.20 → 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.
- package/.svelte-kit/__package__/Provider.svelte +61 -53
- package/.svelte-kit/__package__/Provider.svelte.d.ts.map +1 -1
- package/.turbo/turbo-build.log +48 -50
- package/CHANGELOG.md +9 -0
- package/dist/chunk-BOMSRY5H.js +26 -0
- package/dist/chunk-BOMSRY5H.js.map +1 -0
- package/dist/{chunk-TVHI2UMO.js → chunk-D5L6ES2M.js} +4 -6
- package/dist/{chunk-TVHI2UMO.js.map → chunk-D5L6ES2M.js.map} +1 -1
- package/dist/chunk-PZ5AY32C.js +10 -0
- package/dist/chunk-PZ5AY32C.js.map +1 -0
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/react/ssr.d.ts +1 -3
- package/dist/react/ssr.d.ts.map +1 -1
- package/dist/react/ssr.js +3 -1
- package/dist/react/ssr.js.map +1 -1
- package/dist/svelte/Provider.svelte +61 -53
- package/dist/svelte/Provider.svelte.d.ts.map +1 -1
- package/dist/testing.js +2 -1
- package/dist/testing.js.map +1 -1
- package/dist/tools/exports.d.ts +1 -0
- package/dist/tools/exports.d.ts.map +1 -1
- package/dist/tools/ssr/index.d.ts +2 -0
- package/dist/tools/ssr/index.d.ts.map +1 -0
- package/dist/tools/ssr/ssr.d.ts +4 -0
- package/dist/tools/ssr/ssr.d.ts.map +1 -0
- package/dist/tools/ssr.js +8 -0
- package/dist/tools/ssr.js.map +1 -0
- package/package.json +14 -9
- package/src/react/ssr.ts +2 -23
- package/src/svelte/Provider.svelte +61 -53
- package/src/tools/exports.ts +2 -0
- package/src/tools/ssr/index.ts +1 -0
- package/src/tools/ssr/ssr.ts +23 -0
- package/tsup.config.ts +2 -7
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
CHANGED
@@ -14,6 +14,11 @@
|
|
14
14
|
"types": "./dist/testing.d.ts",
|
15
15
|
"default": "./dist/testing.js"
|
16
16
|
},
|
17
|
+
"./ssr": {
|
18
|
+
"@jazz-tools/source": "./src/tools/ssr/index.ts",
|
19
|
+
"types": "./dist/tools/ssr/ssr.d.ts",
|
20
|
+
"default": "./dist/tools/ssr.js"
|
21
|
+
},
|
17
22
|
"./browser": {
|
18
23
|
"@jazz-tools/source": "./src/browser/index.ts",
|
19
24
|
"types": "./dist/browser/index.d.ts",
|
@@ -77,16 +82,16 @@
|
|
77
82
|
"types": "./dist/react/index.d.ts",
|
78
83
|
"default": "./dist/react/index.js"
|
79
84
|
},
|
80
|
-
"./react/testing": {
|
81
|
-
"@jazz-tools/source": "./src/react/testing.tsx",
|
82
|
-
"types": "./dist/react/testing.d.ts",
|
83
|
-
"default": "./dist/react/testing.js"
|
84
|
-
},
|
85
85
|
"./react/ssr": {
|
86
86
|
"@jazz-tools/source": "./src/react/ssr.ts",
|
87
87
|
"types": "./dist/react/ssr.d.ts",
|
88
88
|
"default": "./dist/react/ssr.js"
|
89
89
|
},
|
90
|
+
"./react/testing": {
|
91
|
+
"@jazz-tools/source": "./src/react/testing.tsx",
|
92
|
+
"types": "./dist/react/testing.d.ts",
|
93
|
+
"default": "./dist/react/testing.js"
|
94
|
+
},
|
90
95
|
"./react-core": {
|
91
96
|
"@jazz-tools/source": "./src/react-core/index.ts",
|
92
97
|
"types": "./dist/react-core/index.d.ts",
|
@@ -177,7 +182,7 @@
|
|
177
182
|
},
|
178
183
|
"type": "module",
|
179
184
|
"license": "MIT",
|
180
|
-
"version": "0.18.
|
185
|
+
"version": "0.18.21",
|
181
186
|
"dependencies": {
|
182
187
|
"@manuscripts/prosemirror-recreate-steps": "^0.1.4",
|
183
188
|
"@scure/base": "1.2.1",
|
@@ -194,9 +199,9 @@
|
|
194
199
|
"prosemirror-transform": "^1.9.0",
|
195
200
|
"use-sync-external-store": "^1.5.0",
|
196
201
|
"zod": "4.1.11",
|
197
|
-
"cojson": "0.18.
|
198
|
-
"cojson-storage-indexeddb": "0.18.
|
199
|
-
"cojson-transport-ws": "0.18.
|
202
|
+
"cojson": "0.18.21",
|
203
|
+
"cojson-storage-indexeddb": "0.18.21",
|
204
|
+
"cojson-transport-ws": "0.18.21"
|
200
205
|
},
|
201
206
|
"devDependencies": {
|
202
207
|
"@scure/bip39": "^1.3.0",
|
package/src/react/ssr.ts
CHANGED
@@ -1,23 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
import { createAnonymousJazzContext } from "jazz-tools";
|
4
|
-
|
5
|
-
export function createSSRJazzAgent(opts: { peer: string }) {
|
6
|
-
const ssrNode = createAnonymousJazzContext({
|
7
|
-
crypto: new PureJSCrypto(),
|
8
|
-
peersToLoadFrom: [],
|
9
|
-
});
|
10
|
-
|
11
|
-
const wsPeer = new WebSocketPeerWithReconnection({
|
12
|
-
peer: opts.peer,
|
13
|
-
reconnectionTimeout: 100,
|
14
|
-
addPeer: (peer) => {
|
15
|
-
ssrNode.agent.node.syncManager.addPeer(peer);
|
16
|
-
},
|
17
|
-
removePeer: () => {},
|
18
|
-
});
|
19
|
-
|
20
|
-
wsPeer.enable();
|
21
|
-
|
22
|
-
return ssrNode.agent;
|
23
|
-
}
|
1
|
+
// Maintain backward compatibility
|
2
|
+
export { createSSRJazzAgent } from "../tools/ssr/index.js";
|
@@ -1,59 +1,67 @@
|
|
1
|
-
<script
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
type
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
);
|
27
|
-
|
28
|
-
$
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
1
|
+
<script
|
2
|
+
lang="ts"
|
3
|
+
generics="S extends (AccountClass<Account> & CoValueFromRaw<Account>) | AnyAccountSchema"
|
4
|
+
>
|
5
|
+
import type { AuthSecretStorage, InstanceOfSchema } from "jazz-tools";
|
6
|
+
import {
|
7
|
+
Account,
|
8
|
+
type AccountClass,
|
9
|
+
type AnyAccountSchema,
|
10
|
+
type CoValueFromRaw,
|
11
|
+
} from "jazz-tools";
|
12
|
+
import {
|
13
|
+
JazzBrowserContextManager,
|
14
|
+
type JazzContextManagerProps,
|
15
|
+
} from "jazz-tools/browser";
|
16
|
+
import { type Snippet, setContext, untrack } from "svelte";
|
17
|
+
import { JAZZ_AUTH_CTX, JAZZ_CTX, type JazzContext } from "./jazz.svelte.js";
|
18
|
+
|
19
|
+
let props: JazzContextManagerProps<S> & {
|
20
|
+
children?: Snippet;
|
21
|
+
enableSSR?: boolean;
|
22
|
+
} = $props();
|
23
|
+
|
24
|
+
const contextManager = new JazzBrowserContextManager<S>({
|
25
|
+
useAnonymousFallback: props.enableSSR,
|
26
|
+
});
|
27
|
+
|
28
|
+
const ctx = $state<JazzContext<InstanceOfSchema<S>>>({ current: undefined });
|
29
|
+
|
30
|
+
setContext<JazzContext<InstanceOfSchema<S>>>(JAZZ_CTX, ctx);
|
31
|
+
setContext<AuthSecretStorage>(
|
32
|
+
JAZZ_AUTH_CTX,
|
33
|
+
contextManager.getAuthSecretStorage(),
|
34
|
+
);
|
35
|
+
|
36
|
+
$effect(() => {
|
37
|
+
props.sync.when;
|
38
|
+
props.sync.peer;
|
39
|
+
props.storage;
|
40
|
+
props.guestMode;
|
41
|
+
return untrack(() => {
|
42
|
+
if (!props.sync) return;
|
43
|
+
|
44
|
+
contextManager
|
45
|
+
.createContext({
|
46
|
+
sync: props.sync,
|
47
|
+
storage: props.storage,
|
48
|
+
guestMode: props.guestMode,
|
49
|
+
AccountSchema: props.AccountSchema,
|
50
|
+
defaultProfileName: props.defaultProfileName,
|
51
|
+
onAnonymousAccountDiscarded: props.onAnonymousAccountDiscarded,
|
52
|
+
onLogOut: props.onLogOut,
|
53
|
+
})
|
54
|
+
.catch((error) => {
|
55
|
+
console.error("Error creating Jazz browser context:", error);
|
56
|
+
});
|
57
|
+
});
|
49
58
|
});
|
50
|
-
});
|
51
59
|
|
52
|
-
$effect(() => {
|
53
|
-
|
54
|
-
|
60
|
+
$effect(() => {
|
61
|
+
return contextManager.subscribe(() => {
|
62
|
+
ctx.current = contextManager.getCurrentValue();
|
63
|
+
});
|
55
64
|
});
|
56
|
-
});
|
57
65
|
</script>
|
58
66
|
|
59
67
|
{#if ctx.current}
|
package/src/tools/exports.ts
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
export * from "./ssr.js";
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { WebSocketPeerWithReconnection } from "cojson-transport-ws";
|
2
|
+
import { PureJSCrypto } from "cojson/dist/crypto/PureJSCrypto";
|
3
|
+
import { createAnonymousJazzContext } from "jazz-tools";
|
4
|
+
|
5
|
+
export function createSSRJazzAgent(opts: { peer: string }) {
|
6
|
+
const ssrNode = createAnonymousJazzContext({
|
7
|
+
crypto: new PureJSCrypto(),
|
8
|
+
peersToLoadFrom: [],
|
9
|
+
});
|
10
|
+
|
11
|
+
const wsPeer = new WebSocketPeerWithReconnection({
|
12
|
+
peer: opts.peer,
|
13
|
+
reconnectionTimeout: 100,
|
14
|
+
addPeer: (peer) => {
|
15
|
+
ssrNode.agent.node.syncManager.addPeer(peer);
|
16
|
+
},
|
17
|
+
removePeer: () => {},
|
18
|
+
});
|
19
|
+
|
20
|
+
wsPeer.enable();
|
21
|
+
|
22
|
+
return ssrNode.agent;
|
23
|
+
}
|
package/tsup.config.ts
CHANGED
@@ -16,6 +16,7 @@ export default defineConfig([
|
|
16
16
|
entry: {
|
17
17
|
index: "src/index.ts",
|
18
18
|
testing: "src/testing.ts",
|
19
|
+
"tools/ssr": "src/tools/ssr/index.ts",
|
19
20
|
},
|
20
21
|
outDir: "dist",
|
21
22
|
},
|
@@ -73,18 +74,12 @@ export default defineConfig([
|
|
73
74
|
},
|
74
75
|
outDir: "dist/prosemirror",
|
75
76
|
},
|
76
|
-
{
|
77
|
-
...cfg,
|
78
|
-
entry: {
|
79
|
-
ssr: "src/react/ssr.ts",
|
80
|
-
},
|
81
|
-
outDir: "dist/react",
|
82
|
-
},
|
83
77
|
{
|
84
78
|
...cfg,
|
85
79
|
entry: {
|
86
80
|
index: "src/react/index.ts",
|
87
81
|
testing: "src/react/testing.tsx",
|
82
|
+
ssr: "src/react/ssr.ts",
|
88
83
|
},
|
89
84
|
outDir: "dist/react",
|
90
85
|
esbuildOptions: (options) => {
|