jazz-tools 0.18.20 → 0.18.22
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 +65 -65
- package/CHANGELOG.md +20 -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/inspector/{custom-element-G6SPZEBR.js → custom-element-XDJT5T57.js} +277 -206
- package/dist/inspector/custom-element-XDJT5T57.js.map +1 -0
- package/dist/inspector/index.js +282 -211
- package/dist/inspector/index.js.map +1 -1
- package/dist/inspector/register-custom-element.js +1 -1
- package/dist/inspector/ui/icon.d.ts +2 -0
- package/dist/inspector/ui/icon.d.ts.map +1 -1
- package/dist/inspector/ui/icons/caution.d.ts +2 -0
- package/dist/inspector/ui/icons/caution.d.ts.map +1 -0
- package/dist/inspector/viewer/table-viewer.d.ts.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/dist/worker/napi-crypto.d.ts +2 -0
- package/dist/worker/napi-crypto.d.ts.map +1 -0
- package/dist/worker/napi-crypto.js +3 -0
- package/dist/worker/napi-crypto.js.map +1 -0
- package/package.json +19 -9
- package/src/inspector/ui/icon.tsx +2 -0
- package/src/inspector/ui/icons/caution.tsx +18 -0
- package/src/inspector/viewer/table-viewer.tsx +79 -21
- 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/src/worker/napi-crypto.ts +1 -0
- package/tsup.config.ts +3 -7
- package/dist/inspector/custom-element-G6SPZEBR.js.map +0 -1
@@ -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
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from "cojson/crypto/NapiCrypto";
|
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) => {
|
@@ -136,6 +131,7 @@ export default defineConfig([
|
|
136
131
|
entry: {
|
137
132
|
index: "src/worker/index.ts",
|
138
133
|
"edge-wasm": "src/worker/edge-wasm.ts",
|
134
|
+
"napi-crypto": "src/worker/napi-crypto.ts",
|
139
135
|
},
|
140
136
|
outDir: "dist/worker",
|
141
137
|
},
|