Compare commits

..

22 Commits

Author SHA1 Message Date
Anselm
41554e0e0b Release 2024-06-25 13:57:24 +01:00
Anselm
93c4d8155e Fix CoList.toJSON() 2024-06-25 13:56:20 +01:00
Anselm
24eefd49f1 Release 2024-06-25 13:46:54 +01:00
Anselm
e712f1e8ef Fix circular toJSON bug #215 2024-06-25 13:46:14 +01:00
Anselm Eickhoff
1ba40806ec Merge pull request #213 from tobiaslins/fix-demo-auth-nextjs
Fix DemoAuth for Next.js
2024-06-13 17:43:11 +01:00
Tobias Lins
73ae281e4a Fix demoAuth for next.js 2024-06-13 18:41:29 +02:00
Anselm
1cb91003cc Release 2024-06-12 15:12:00 +01:00
Anselm
d850022491 Fix #210 2024-06-12 15:10:22 +01:00
Anselm
93792ab6f6 Remove lofi conf badge 2024-06-06 12:02:31 +01:00
Anselm
95dfe7af6a Guide fix 2024-06-04 17:56:34 +01:00
Anselm
734258eb17 Release 2024-06-04 12:14:59 +01:00
Anselm
f3bcf96fad Also cache agent ID in RawControlledAccount 2024-06-04 12:13:54 +01:00
Anselm
5cf0bc1911 Release 2024-06-04 12:09:35 +01:00
Anselm
d32a6b275f Formatting 2024-06-04 12:09:16 +01:00
Anselm
6caba9f8e7 Cache currentAgentID in RawAccount 2024-06-04 12:06:13 +01:00
Anselm
641f1dbfbe Release 2024-06-03 17:33:59 +01:00
Anselm
58d9a104d6 Fix CoMaps not initialising properly when passing too many init options 2024-06-03 17:33:24 +01:00
Anselm
7b9d24c8ef Release 2024-06-01 17:25:06 +02:00
Anselm Eickhoff
4225fdd537 Merge pull request #200 from gdorsi/main
fix: improve compatibility with React compiler and concurrent features
2024-06-01 17:24:17 +02:00
Anselm
9fdc91c6de Add changeset 2024-06-01 17:23:18 +02:00
Anselm
93d8c85e5c Formatting 2024-06-01 17:22:38 +02:00
Guido D'Orsi
3325ff1cd6 fix: make Jazz react compiler ready 2024-05-31 10:19:33 +02:00
45 changed files with 952 additions and 457 deletions

View File

@@ -1,5 +1,63 @@
# jazz-example-chat
## 0.0.60
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.13
- jazz-react@0.7.13
## 0.0.59
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.12
- jazz-react@0.7.12
## 0.0.58
### Patch Changes
- Updated dependencies
- cojson@0.7.11
- jazz-react@0.7.11
- jazz-tools@0.7.11
## 0.0.57
### Patch Changes
- Updated dependencies
- cojson@0.7.10
- jazz-react@0.7.10
- jazz-tools@0.7.10
## 0.0.56
### Patch Changes
- Updated dependencies
- cojson@0.7.9
- jazz-react@0.7.9
- jazz-tools@0.7.9
## 0.0.55
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.8
- jazz-react@0.7.8
## 0.0.54
### Patch Changes
- Updated dependencies [9fdc91c]
- jazz-react@0.7.7
## 0.0.53
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "jazz-example-chat",
"private": true,
"version": "0.0.53",
"version": "0.0.60",
"type": "module",
"scripts": {
"dev": "vite",

View File

@@ -1,5 +1,63 @@
# jazz-example-pets
## 0.0.78
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.13
- jazz-browser-media-images@0.7.13
- jazz-react@0.7.13
## 0.0.77
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.12
- jazz-browser-media-images@0.7.12
- jazz-react@0.7.12
## 0.0.76
### Patch Changes
- jazz-react@0.7.11
- jazz-tools@0.7.11
- jazz-browser-media-images@0.7.11
## 0.0.75
### Patch Changes
- jazz-react@0.7.10
- jazz-tools@0.7.10
- jazz-browser-media-images@0.7.10
## 0.0.74
### Patch Changes
- jazz-react@0.7.9
- jazz-tools@0.7.9
- jazz-browser-media-images@0.7.9
## 0.0.73
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.8
- jazz-browser-media-images@0.7.8
- jazz-react@0.7.8
## 0.0.72
### Patch Changes
- Updated dependencies [9fdc91c]
- jazz-react@0.7.7
## 0.0.71
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "jazz-example-pets",
"private": true,
"version": "0.0.71",
"version": "0.0.78",
"type": "module",
"scripts": {
"dev": "vite",

View File

@@ -1,5 +1,57 @@
# jazz-example-todo
## 0.0.77
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.13
- jazz-react@0.7.13
## 0.0.76
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.12
- jazz-react@0.7.12
## 0.0.75
### Patch Changes
- jazz-react@0.7.11
- jazz-tools@0.7.11
## 0.0.74
### Patch Changes
- jazz-react@0.7.10
- jazz-tools@0.7.10
## 0.0.73
### Patch Changes
- jazz-react@0.7.9
- jazz-tools@0.7.9
## 0.0.72
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.8
- jazz-react@0.7.8
## 0.0.71
### Patch Changes
- Updated dependencies [9fdc91c]
- jazz-react@0.7.7
## 0.0.70
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "jazz-example-todo",
"private": true,
"version": "0.0.70",
"version": "0.0.77",
"type": "module",
"scripts": {
"dev": "vite",

View File

@@ -178,7 +178,7 @@ function App() {// old
if (issue) {// old
return <IssueComponent issue={issue} />; // old
} else { // old
return <button onClick={createIssue}>Create Issue</button>; // old
return <button onClick={createIssue}>Create Issue</button>;
} // old
} // old
// old

View File

@@ -49,11 +49,11 @@ export default function Page() {
</Prose>
<div className="text-stone-800 dark:text-stone-200">
<PackageDocs package="jazz-tools" />
<PackageDocs package="jazz-react" />
<PackageDocs package="jazz-browser" />
<PackageDocs package="jazz-browser-media-images" />
<PackageDocs package="jazz-nodejs" />
<PackageDocs package="jazz-tools" />
<PackageDocs package="jazz-react" />
<PackageDocs package="jazz-browser" />
<PackageDocs package="jazz-browser-media-images" />
<PackageDocs package="jazz-nodejs" />
</div>
</div>
</div>

View File

@@ -28,12 +28,6 @@ import Link from "next/link";
<Prose>
<a href="https://app.localfirstconf.com/schedule/conference/every-app-secretly-wants-to-be-local-first" className="-mt-8 md:-mt-20 float-right top-[5rem] right-4 border border-stone-700 dark:border-stone-300 rounded flex gap-3 items-center px-4 py-2 mb-4 rotate-2 md:rotate-6 no-underline hover:scale-105 transition-transform">
<div className="text-sm font-bold uppercase">See you in Berlin<br/>May 30-31!</div>
<LocalFirstConfLogo className="w-24"/>
</a>
# Instant sync.
<Slogan>A new way to build apps with distributed state.</Slogan>

View File

@@ -213,10 +213,14 @@ function RenderClassOrInterface({
function renderSummary(commentSummary: CommentDisplayPart[] | undefined) {
return commentSummary?.map((part, idx) =>
part.kind === "text" ? (
<span key={idx}>{part.text.split("\n").map((line, i, lines) => <>
{line}
{i !== lines.length - 1 && <br />}
</>)}</span>
<span key={idx}>
{part.text.split("\n").map((line, i, lines) => (
<>
{line}
{i !== lines.length - 1 && <br />}
</>
))}
</span>
) : part.kind === "inline-tag" ? (
<code key={idx}>
{part.tag} {part.text}

View File

@@ -1,4 +1,4 @@
export function Prose(props: { children: ReactNode, className?: string }) {
export function Prose(props: { children: ReactNode; className?: string }) {
return (
<div
className={[
@@ -11,7 +11,7 @@ export function Prose(props: { children: ReactNode, className?: string }) {
"prose-code:font-normal prose-code:leading-tight prose-code:before:content-none prose-code:after:content-none prose-code:bg-stone-100 prose-code:dark:bg-stone-900 prose-code:p-1 prose-code:rounded",
"prose-pre:text-black dark:prose-pre:text-white prose-pre:max-w-3xl prose-pre:text-[0.8em] prose-pre:leading-[1.3] prose-pre:-mt-2 prose-pre:my-4 prose-pre:px-10 prose-pre:py-2 prose-pre:-mx-10 prose-pre:bg-transparent",
"[&_pre_.line]:relative [&_pre_.line]:min-h-[1.3em] [&_pre_.lineNo]:text-[0.75em] [&_pre_.lineNo]:text-stone-300 [&_pre_.lineNo]:dark:text-stone-700 [&_pre_.lineNo]:absolute [&_pre_.lineNo]:text-right [&_pre_.lineNo]:w-8 [&_pre_.lineNo]:-left-10 [&_pre_.lineNo]:top-[0.3em] [&_pre_.lineNo]:select-none",
props.className || "prose lg:prose-lg"
props.className || "prose lg:prose-lg",
].join(" ")}
>
{props.children}

File diff suppressed because one or more lines are too long

View File

@@ -92,9 +92,6 @@ const config: Config = {
},
},
},
plugins: [
tailwindCSSAnimate,
typography(),
],
plugins: [tailwindCSSAnimate, typography()],
};
export default config;

View File

@@ -1,198 +1,219 @@
# cojson-storage-indexeddb
## 0.7.11
### Patch Changes
- Updated dependencies
- cojson@0.7.11
## 0.7.10
### Patch Changes
- Updated dependencies
- cojson@0.7.10
## 0.7.9
### Patch Changes
- Updated dependencies
- cojson@0.7.9
## 0.7.0
### Patch Changes
- c4151fc: Support stricter TS lint rules
- 952982e: Consistent proxy based API
- 21771c4: Reintroduce changes from main
- 69ac514: Use effect schema much less
- f0f6f1b: Clean up API more & re-add jazz-nodejs
- 1a44f87: Refactoring
- 627d895: Get rid of Co namespace
- Updated dependencies [1a35307]
- Updated dependencies [96c494f]
- Updated dependencies [19f52b7]
- Updated dependencies [d8fe2b1]
- Updated dependencies [1200aae]
- Updated dependencies [52675c9]
- Updated dependencies [1a35307]
- Updated dependencies [e299c3e]
- Updated dependencies [bf0f8ec]
- Updated dependencies [c4151fc]
- Updated dependencies [8636319]
- Updated dependencies [952982e]
- Updated dependencies [21771c4]
- Updated dependencies [69ac514]
- Updated dependencies [f0f6f1b]
- Updated dependencies [1a44f87]
- Updated dependencies [63374cc]
- cojson@0.7.0
- c4151fc: Support stricter TS lint rules
- 952982e: Consistent proxy based API
- 21771c4: Reintroduce changes from main
- 69ac514: Use effect schema much less
- f0f6f1b: Clean up API more & re-add jazz-nodejs
- 1a44f87: Refactoring
- 627d895: Get rid of Co namespace
- Updated dependencies [1a35307]
- Updated dependencies [96c494f]
- Updated dependencies [19f52b7]
- Updated dependencies [d8fe2b1]
- Updated dependencies [1200aae]
- Updated dependencies [52675c9]
- Updated dependencies [1a35307]
- Updated dependencies [e299c3e]
- Updated dependencies [bf0f8ec]
- Updated dependencies [c4151fc]
- Updated dependencies [8636319]
- Updated dependencies [952982e]
- Updated dependencies [21771c4]
- Updated dependencies [69ac514]
- Updated dependencies [f0f6f1b]
- Updated dependencies [1a44f87]
- Updated dependencies [63374cc]
- cojson@0.7.0
## 0.7.0-alpha.42
### Patch Changes
- Updated dependencies
- cojson@0.7.0-alpha.42
- Updated dependencies
- cojson@0.7.0-alpha.42
## 0.7.0-alpha.39
### Patch Changes
- Updated dependencies
- cojson@0.7.0-alpha.39
- Updated dependencies
- cojson@0.7.0-alpha.39
## 0.7.0-alpha.38
### Patch Changes
- Updated dependencies
- cojson@0.7.0-alpha.38
- Updated dependencies
- cojson@0.7.0-alpha.38
## 0.7.0-alpha.37
### Patch Changes
- Updated dependencies
- cojson@0.7.0-alpha.37
- Updated dependencies
- cojson@0.7.0-alpha.37
## 0.7.0-alpha.36
### Patch Changes
- Updated dependencies [1a35307]
- Updated dependencies [1a35307]
- cojson@0.7.0-alpha.36
- Updated dependencies [1a35307]
- Updated dependencies [1a35307]
- cojson@0.7.0-alpha.36
## 0.7.0-alpha.35
### Patch Changes
- Updated dependencies
- cojson@0.7.0-alpha.35
- Updated dependencies
- cojson@0.7.0-alpha.35
## 0.7.0-alpha.29
### Patch Changes
- Reintroduce changes from main
- Updated dependencies
- cojson@0.7.0-alpha.29
- Reintroduce changes from main
- Updated dependencies
- cojson@0.7.0-alpha.29
## 0.7.0-alpha.28
### Patch Changes
- Updated dependencies
- cojson@0.7.0-alpha.28
- Updated dependencies
- cojson@0.7.0-alpha.28
## 0.7.0-alpha.27
### Patch Changes
- Updated dependencies
- cojson@0.7.0-alpha.27
- Updated dependencies
- cojson@0.7.0-alpha.27
## 0.7.0-alpha.24
### Patch Changes
- Updated dependencies
- cojson@0.7.0-alpha.24
- Updated dependencies
- cojson@0.7.0-alpha.24
## 0.7.0-alpha.11
### Patch Changes
- Support stricter TS lint rules
- Updated dependencies
- cojson@0.7.0-alpha.11
- Support stricter TS lint rules
- Updated dependencies
- cojson@0.7.0-alpha.11
## 0.7.0-alpha.10
### Patch Changes
- Clean up API more & re-add jazz-nodejs
- Updated dependencies
- cojson@0.7.0-alpha.10
- Clean up API more & re-add jazz-nodejs
- Updated dependencies
- cojson@0.7.0-alpha.10
## 0.6.4-alpha.4
### Patch Changes
- Consistent proxy based API
- Updated dependencies
- cojson@0.7.0-alpha.7
- Consistent proxy based API
- Updated dependencies
- cojson@0.7.0-alpha.7
## 0.6.4-alpha.3
### Patch Changes
- Refactoring
- Updated dependencies
- cojson@0.7.0-alpha.5
- Refactoring
- Updated dependencies
- cojson@0.7.0-alpha.5
## 0.6.4-alpha.2
### Patch Changes
- Get rid of Co namespace
- Get rid of Co namespace
## 0.6.4-alpha.1
### Patch Changes
- Use effect schema much less
- Updated dependencies
- cojson@0.7.0-alpha.1
- Use effect schema much less
- Updated dependencies
- cojson@0.7.0-alpha.1
## 0.6.4-alpha.0
### Patch Changes
- Updated dependencies
- cojson@0.7.0-alpha.0
- Updated dependencies
- cojson@0.7.0-alpha.0
## 0.6.3
### Patch Changes
- Fix ordering bugs with indexeddb
- Fix ordering bugs with indexeddb
## 0.6.2
### Patch Changes
- Fix TypeScript lint
- Fix TypeScript lint
## 0.6.1
### Patch Changes
- IndexedDB & timer perf improvements
- Updated dependencies
- cojson@0.6.4
- IndexedDB & timer perf improvements
- Updated dependencies
- cojson@0.6.4
## 0.6.0
### Minor Changes
- Make addMember and removeMember take loaded Accounts instead of just IDs
- Make addMember and removeMember take loaded Accounts instead of just IDs
### Patch Changes
- Updated dependencies
- cojson@0.6.0
- Updated dependencies
- cojson@0.6.0
## 0.5.0
### Minor Changes
- Adding a lot of performance improvements to cojson, add a stresstest for the twit example and make that run smoother in a lot of ways.
- Adding a lot of performance improvements to cojson, add a stresstest for the twit example and make that run smoother in a lot of ways.
### Patch Changes
- Updated dependencies
- cojson@0.5.0
- Updated dependencies
- cojson@0.5.0

View File

@@ -1,6 +1,6 @@
{
"name": "cojson-storage-indexeddb",
"version": "0.7.0",
"version": "0.7.11",
"main": "dist/index.js",
"type": "module",
"types": "src/index.ts",

View File

@@ -1,155 +1,176 @@
# cojson-storage-sqlite
## 0.7.11
### Patch Changes
- Updated dependencies
- cojson@0.7.11
## 0.7.10
### Patch Changes
- Updated dependencies
- cojson@0.7.10
## 0.7.9
### Patch Changes
- Updated dependencies
- cojson@0.7.9
## 0.7.0
### Patch Changes
- c4151fc: Support stricter TS lint rules
- 21771c4: Reintroduce changes from main
- 69ac514: Use effect schema much less
- f0f6f1b: Clean up API more & re-add jazz-nodejs
- Updated dependencies [1a35307]
- Updated dependencies [96c494f]
- Updated dependencies [19f52b7]
- Updated dependencies [d8fe2b1]
- Updated dependencies [1200aae]
- Updated dependencies [52675c9]
- Updated dependencies [1a35307]
- Updated dependencies [e299c3e]
- Updated dependencies [bf0f8ec]
- Updated dependencies [c4151fc]
- Updated dependencies [8636319]
- Updated dependencies [952982e]
- Updated dependencies [21771c4]
- Updated dependencies [69ac514]
- Updated dependencies [f0f6f1b]
- Updated dependencies [1a44f87]
- Updated dependencies [63374cc]
- cojson@0.7.0
- c4151fc: Support stricter TS lint rules
- 21771c4: Reintroduce changes from main
- 69ac514: Use effect schema much less
- f0f6f1b: Clean up API more & re-add jazz-nodejs
- Updated dependencies [1a35307]
- Updated dependencies [96c494f]
- Updated dependencies [19f52b7]
- Updated dependencies [d8fe2b1]
- Updated dependencies [1200aae]
- Updated dependencies [52675c9]
- Updated dependencies [1a35307]
- Updated dependencies [e299c3e]
- Updated dependencies [bf0f8ec]
- Updated dependencies [c4151fc]
- Updated dependencies [8636319]
- Updated dependencies [952982e]
- Updated dependencies [21771c4]
- Updated dependencies [69ac514]
- Updated dependencies [f0f6f1b]
- Updated dependencies [1a44f87]
- Updated dependencies [63374cc]
- cojson@0.7.0
## 0.7.0-alpha.42
### Patch Changes
- Updated dependencies
- cojson@0.7.0-alpha.42
- Updated dependencies
- cojson@0.7.0-alpha.42
## 0.7.0-alpha.39
### Patch Changes
- Updated dependencies
- cojson@0.7.0-alpha.39
- Updated dependencies
- cojson@0.7.0-alpha.39
## 0.7.0-alpha.38
### Patch Changes
- Updated dependencies
- cojson@0.7.0-alpha.38
- Updated dependencies
- cojson@0.7.0-alpha.38
## 0.7.0-alpha.37
### Patch Changes
- Updated dependencies
- cojson@0.7.0-alpha.37
- Updated dependencies
- cojson@0.7.0-alpha.37
## 0.7.0-alpha.36
### Patch Changes
- Updated dependencies [1a35307]
- Updated dependencies [1a35307]
- cojson@0.7.0-alpha.36
- Updated dependencies [1a35307]
- Updated dependencies [1a35307]
- cojson@0.7.0-alpha.36
## 0.7.0-alpha.35
### Patch Changes
- Updated dependencies
- cojson@0.7.0-alpha.35
- Updated dependencies
- cojson@0.7.0-alpha.35
## 0.7.0-alpha.29
### Patch Changes
- Reintroduce changes from main
- Updated dependencies
- cojson@0.7.0-alpha.29
- Reintroduce changes from main
- Updated dependencies
- cojson@0.7.0-alpha.29
## 0.7.0-alpha.28
### Patch Changes
- Updated dependencies
- cojson@0.7.0-alpha.28
- Updated dependencies
- cojson@0.7.0-alpha.28
## 0.7.0-alpha.27
### Patch Changes
- Updated dependencies
- cojson@0.7.0-alpha.27
- Updated dependencies
- cojson@0.7.0-alpha.27
## 0.7.0-alpha.24
### Patch Changes
- Updated dependencies
- cojson@0.7.0-alpha.24
- Updated dependencies
- cojson@0.7.0-alpha.24
## 0.7.0-alpha.11
### Patch Changes
- Support stricter TS lint rules
- Updated dependencies
- cojson@0.7.0-alpha.11
- Support stricter TS lint rules
- Updated dependencies
- cojson@0.7.0-alpha.11
## 0.7.0-alpha.10
### Patch Changes
- Clean up API more & re-add jazz-nodejs
- Updated dependencies
- cojson@0.7.0-alpha.10
- Clean up API more & re-add jazz-nodejs
- Updated dependencies
- cojson@0.7.0-alpha.10
## 0.5.3-alpha.1
### Patch Changes
- Use effect schema much less
- Updated dependencies
- cojson@0.7.0-alpha.1
- Use effect schema much less
- Updated dependencies
- cojson@0.7.0-alpha.1
## 0.5.3-alpha.0
### Patch Changes
- Updated dependencies
- cojson@0.7.0-alpha.0
- Updated dependencies
- cojson@0.7.0-alpha.0
## 0.5.2
### Patch Changes
- Updated dependencies
- cojson@0.6.0
- Updated dependencies
- cojson@0.6.0
## 0.5.1
### Patch Changes
- Make typedefs for better-sqlite3 a normal dependency
- Make typedefs for better-sqlite3 a normal dependency
## 0.5.0
### Minor Changes
- Adding a lot of performance improvements to cojson, add a stresstest for the twit example and make that run smoother in a lot of ways.
- Adding a lot of performance improvements to cojson, add a stresstest for the twit example and make that run smoother in a lot of ways.
### Patch Changes
- Updated dependencies
- cojson@0.5.0
- Updated dependencies
- cojson@0.5.0

View File

@@ -1,7 +1,7 @@
{
"name": "cojson-storage-sqlite",
"type": "module",
"version": "0.7.0",
"version": "0.7.11",
"main": "dist/index.js",
"types": "src/index.ts",
"license": "MIT",

View File

@@ -1,161 +1,182 @@
# cojson-transport-nodejs-ws
## 0.7.11
### Patch Changes
- Updated dependencies
- cojson@0.7.11
## 0.7.10
### Patch Changes
- Updated dependencies
- cojson@0.7.10
## 0.7.9
### Patch Changes
- Updated dependencies
- cojson@0.7.9
## 0.7.0
### Patch Changes
- c4151fc: Support stricter TS lint rules
- 21771c4: Reintroduce changes from main
- f0f6f1b: Clean up API more & re-add jazz-nodejs
- 627d895: Get rid of Co namespace
- a423eee: ignore error on ws close, fixing "Invalid state: Controller is already closed"
- Updated dependencies [1a35307]
- Updated dependencies [96c494f]
- Updated dependencies [19f52b7]
- Updated dependencies [d8fe2b1]
- Updated dependencies [1200aae]
- Updated dependencies [52675c9]
- Updated dependencies [1a35307]
- Updated dependencies [e299c3e]
- Updated dependencies [bf0f8ec]
- Updated dependencies [c4151fc]
- Updated dependencies [8636319]
- Updated dependencies [952982e]
- Updated dependencies [21771c4]
- Updated dependencies [69ac514]
- Updated dependencies [f0f6f1b]
- Updated dependencies [1a44f87]
- Updated dependencies [63374cc]
- cojson@0.7.0
- c4151fc: Support stricter TS lint rules
- 21771c4: Reintroduce changes from main
- f0f6f1b: Clean up API more & re-add jazz-nodejs
- 627d895: Get rid of Co namespace
- a423eee: ignore error on ws close, fixing "Invalid state: Controller is already closed"
- Updated dependencies [1a35307]
- Updated dependencies [96c494f]
- Updated dependencies [19f52b7]
- Updated dependencies [d8fe2b1]
- Updated dependencies [1200aae]
- Updated dependencies [52675c9]
- Updated dependencies [1a35307]
- Updated dependencies [e299c3e]
- Updated dependencies [bf0f8ec]
- Updated dependencies [c4151fc]
- Updated dependencies [8636319]
- Updated dependencies [952982e]
- Updated dependencies [21771c4]
- Updated dependencies [69ac514]
- Updated dependencies [f0f6f1b]
- Updated dependencies [1a44f87]
- Updated dependencies [63374cc]
- cojson@0.7.0
## 0.7.0-alpha.42
### Patch Changes
- Updated dependencies
- cojson@0.7.0-alpha.42
- Updated dependencies
- cojson@0.7.0-alpha.42
## 0.7.0-alpha.41
### Patch Changes
- ignore error on ws close, fixing "Invalid state: Controller is already closed"
- ignore error on ws close, fixing "Invalid state: Controller is already closed"
## 0.7.0-alpha.39
### Patch Changes
- Updated dependencies
- cojson@0.7.0-alpha.39
- Updated dependencies
- cojson@0.7.0-alpha.39
## 0.7.0-alpha.38
### Patch Changes
- Updated dependencies
- cojson@0.7.0-alpha.38
- Updated dependencies
- cojson@0.7.0-alpha.38
## 0.7.0-alpha.37
### Patch Changes
- Updated dependencies
- cojson@0.7.0-alpha.37
- Updated dependencies
- cojson@0.7.0-alpha.37
## 0.7.0-alpha.36
### Patch Changes
- Updated dependencies [1a35307]
- Updated dependencies [1a35307]
- cojson@0.7.0-alpha.36
- Updated dependencies [1a35307]
- Updated dependencies [1a35307]
- cojson@0.7.0-alpha.36
## 0.7.0-alpha.35
### Patch Changes
- Updated dependencies
- cojson@0.7.0-alpha.35
- Updated dependencies
- cojson@0.7.0-alpha.35
## 0.7.0-alpha.29
### Patch Changes
- Reintroduce changes from main
- Updated dependencies
- cojson@0.7.0-alpha.29
- Reintroduce changes from main
- Updated dependencies
- cojson@0.7.0-alpha.29
## 0.7.0-alpha.28
### Patch Changes
- Updated dependencies
- cojson@0.7.0-alpha.28
- Updated dependencies
- cojson@0.7.0-alpha.28
## 0.7.0-alpha.27
### Patch Changes
- Updated dependencies
- cojson@0.7.0-alpha.27
- Updated dependencies
- cojson@0.7.0-alpha.27
## 0.7.0-alpha.24
### Patch Changes
- Updated dependencies
- cojson@0.7.0-alpha.24
- Updated dependencies
- cojson@0.7.0-alpha.24
## 0.7.0-alpha.11
### Patch Changes
- Support stricter TS lint rules
- Updated dependencies
- cojson@0.7.0-alpha.11
- Support stricter TS lint rules
- Updated dependencies
- cojson@0.7.0-alpha.11
## 0.7.0-alpha.10
### Patch Changes
- Clean up API more & re-add jazz-nodejs
- Updated dependencies
- cojson@0.7.0-alpha.10
- Clean up API more & re-add jazz-nodejs
- Updated dependencies
- cojson@0.7.0-alpha.10
## 0.5.2-alpha.2
### Patch Changes
- Get rid of Co namespace
- Get rid of Co namespace
## 0.5.2-alpha.1
### Patch Changes
- Updated dependencies
- cojson@0.7.0-alpha.1
- Updated dependencies
- cojson@0.7.0-alpha.1
## 0.5.2-alpha.0
### Patch Changes
- Updated dependencies
- cojson@0.7.0-alpha.0
- Updated dependencies
- cojson@0.7.0-alpha.0
## 0.5.1
### Patch Changes
- Updated dependencies
- cojson@0.6.0
- Updated dependencies
- cojson@0.6.0
## 0.5.0
### Minor Changes
- Adding a lot of performance improvements to cojson, add a stresstest for the twit example and make that run smoother in a lot of ways.
- Adding a lot of performance improvements to cojson, add a stresstest for the twit example and make that run smoother in a lot of ways.
### Patch Changes
- Updated dependencies
- cojson@0.5.0
- Updated dependencies
- cojson@0.5.0

View File

@@ -1,7 +1,7 @@
{
"name": "cojson-transport-nodejs-ws",
"type": "module",
"version": "0.7.0",
"version": "0.7.11",
"main": "dist/index.js",
"types": "src/index.ts",
"license": "MIT",

View File

@@ -1,183 +1,201 @@
# cojson
## 0.7.11
### Patch Changes
- Fix webpack import of node:crypto module
## 0.7.10
### Patch Changes
- Also cache agent ID in RawControlledAccount
## 0.7.9
### Patch Changes
- Cache currentAgentID in RawAccount
## 0.7.0
### Minor Changes
- e299c3e: New simplified API
- e299c3e: New simplified API
### Patch Changes
- 1a35307: WIP working-ish version of LSM storage
- 96c494f: Implement profile visibility based on groups & new migration signature
- 19f52b7: Fixed bug with newRandomSessionID being called before crypto was ready
- d8fe2b1: Expose experimental OPFS storage
- 1200aae: CoJSON performance improvement
- 52675c9: Fix CoList.splice / RawCoList.append
- 1a35307: Optimizations for incoming sync messages
- bf0f8ec: Fix noble curves dependency
- c4151fc: Support stricter TS lint rules
- 8636319: Factor out implementation of crypto provider and provide pure JS implementation
- 952982e: Consistent proxy based API
- 21771c4: Reintroduce changes from main
- 69ac514: Use effect schema much less
- f0f6f1b: Clean up API more & re-add jazz-nodejs
- 1a44f87: Refactoring
- 63374cc: Make sure delete on CoMaps deletes keys
- 1a35307: WIP working-ish version of LSM storage
- 96c494f: Implement profile visibility based on groups & new migration signature
- 19f52b7: Fixed bug with newRandomSessionID being called before crypto was ready
- d8fe2b1: Expose experimental OPFS storage
- 1200aae: CoJSON performance improvement
- 52675c9: Fix CoList.splice / RawCoList.append
- 1a35307: Optimizations for incoming sync messages
- bf0f8ec: Fix noble curves dependency
- c4151fc: Support stricter TS lint rules
- 8636319: Factor out implementation of crypto provider and provide pure JS implementation
- 952982e: Consistent proxy based API
- 21771c4: Reintroduce changes from main
- 69ac514: Use effect schema much less
- f0f6f1b: Clean up API more & re-add jazz-nodejs
- 1a44f87: Refactoring
- 63374cc: Make sure delete on CoMaps deletes keys
## 0.7.0-alpha.42
### Patch Changes
- Fixed bug with newRandomSessionID being called before crypto was ready
- Fixed bug with newRandomSessionID being called before crypto was ready
## 0.7.0-alpha.39
### Patch Changes
- Fix noble curves dependency
- Fix noble curves dependency
## 0.7.0-alpha.38
### Patch Changes
- Factor out implementation of crypto provider and provide pure JS implementation
- Factor out implementation of crypto provider and provide pure JS implementation
## 0.7.0-alpha.37
### Patch Changes
- Expose experimental OPFS storage
- Expose experimental OPFS storage
## 0.7.0-alpha.36
### Patch Changes
- 1a35307: WIP working-ish version of LSM storage
- 1a35307: Optimizations for incoming sync messages
- 1a35307: WIP working-ish version of LSM storage
- 1a35307: Optimizations for incoming sync messages
## 0.7.0-alpha.35
### Patch Changes
- CoJSON performance improvement
- CoJSON performance improvement
## 0.7.0-alpha.29
### Patch Changes
- Reintroduce changes from main
- Reintroduce changes from main
## 0.7.0-alpha.28
### Patch Changes
- Implement profile visibility based on groups & new migration signature
- Implement profile visibility based on groups & new migration signature
## 0.7.0-alpha.27
### Patch Changes
- Fix CoList.splice / RawCoList.append
- Fix CoList.splice / RawCoList.append
## 0.7.0-alpha.24
### Patch Changes
- Make sure delete on CoMaps deletes keys
- Make sure delete on CoMaps deletes keys
## 0.7.0-alpha.11
### Patch Changes
- Support stricter TS lint rules
- Support stricter TS lint rules
## 0.7.0-alpha.10
### Patch Changes
- Clean up API more & re-add jazz-nodejs
- Clean up API more & re-add jazz-nodejs
## 0.7.0-alpha.7
### Patch Changes
- Consistent proxy based API
- Consistent proxy based API
## 0.7.0-alpha.5
### Patch Changes
- Refactoring
- Refactoring
## 0.7.0-alpha.1
### Patch Changes
- Use effect schema much less
- Use effect schema much less
## 0.7.0-alpha.0
### Minor Changes
- New simplified API
- New simplified API
## 0.6.6
### Patch Changes
- Fix migration changes being lost on loaded account
- Fix migration changes being lost on loaded account
## 0.6.5
### Patch Changes
- Fix loading of accounts
- Fix loading of accounts
## 0.6.4
### Patch Changes
- IndexedDB & timer perf improvements
- IndexedDB & timer perf improvements
## 0.6.3
### Patch Changes
- Implement passphrase based auth
- Implement passphrase based auth
## 0.6.2
### Patch Changes
- Add peersToLoadFrom for node creation as well
- Add peersToLoadFrom for node creation as well
## 0.6.1
### Patch Changes
- Provide localNode to AccountMigrations
- Provide localNode to AccountMigrations
## 0.6.0
### Minor Changes
- Make addMember and removeMember take loaded Accounts instead of just IDs
- Make addMember and removeMember take loaded Accounts instead of just IDs
## 0.5.2
### Patch Changes
- Allow account migrations to be async
- Allow account migrations to be async
## 0.5.1
### Patch Changes
- Fix bug where accounts, profiles and data created in migrations isn't synced on account creation
- Fix bug where accounts, profiles and data created in migrations isn't synced on account creation
## 0.5.0
### Minor Changes
- Adding a lot of performance improvements to cojson, add a stresstest for the twit example and make that run smoother in a lot of ways.
- Adding a lot of performance improvements to cojson, add a stresstest for the twit example and make that run smoother in a lot of ways.

View File

@@ -5,7 +5,7 @@
"types": "src/index.ts",
"type": "module",
"license": "MIT",
"version": "0.7.0",
"version": "0.7.11",
"devDependencies": {
"@types/jest": "^29.5.3",
"@typescript-eslint/eslint-plugin": "^6.2.1",

View File

@@ -33,7 +33,12 @@ export function accountHeaderForInitialAgentSecret(
export class RawAccount<
Meta extends AccountMeta = AccountMeta,
> extends RawGroup<Meta> {
_cachedCurrentAgentID: AgentID | undefined;
currentAgentID(): AgentID {
if (this._cachedCurrentAgentID) {
return this._cachedCurrentAgentID;
}
const agents = this.keys().filter((k): k is AgentID =>
k.startsWith("sealer_"),
);
@@ -44,6 +49,8 @@ export class RawAccount<
);
}
this._cachedCurrentAgentID = agents[0];
return agents[0]!;
}
}
@@ -90,7 +97,12 @@ export class RawControlledAccount<Meta extends AccountMeta = AccountMeta>
}
currentAgentID(): AgentID {
return this.crypto.getAgentID(this.agentSecret);
if (this._cachedCurrentAgentID) {
return this._cachedCurrentAgentID;
}
const agentID = this.crypto.getAgentID(this.agentSecret);
this._cachedCurrentAgentID = agentID;
return agentID;
}
currentSignerID(): SignerID {

View File

@@ -44,11 +44,13 @@ export class WasmCrypto extends CryptoProvider<Uint8Array> {
if ("crypto" in globalThis) {
resolve();
} else {
return import("node:crypto").then(({ webcrypto }) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(globalThis as any).crypto = webcrypto;
resolve();
});
return import(/*webpackIgnore: true*/ "node:crypto").then(
({ webcrypto }) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(globalThis as any).crypto = webcrypto;
resolve();
},
);
}
}),
]).then(([blake3instance]) => new WasmCrypto(blake3instance));

View File

@@ -1,5 +1,50 @@
# jazz-browser-media-images
## 0.7.13
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.13
- jazz-browser@0.7.13
## 0.7.12
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.12
- jazz-browser@0.7.12
## 0.7.11
### Patch Changes
- jazz-browser@0.7.11
- jazz-tools@0.7.11
## 0.7.10
### Patch Changes
- jazz-browser@0.7.10
- jazz-tools@0.7.10
## 0.7.9
### Patch Changes
- jazz-browser@0.7.9
- jazz-tools@0.7.9
## 0.7.8
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.8
- jazz-browser@0.7.8
## 0.7.6
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "jazz-browser-media-images",
"version": "0.7.6",
"version": "0.7.13",
"type": "module",
"main": "dist/index.js",
"types": "src/index.ts",

View File

@@ -1,5 +1,53 @@
# jazz-browser
## 0.7.13
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.13
## 0.7.12
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.12
## 0.7.11
### Patch Changes
- Updated dependencies
- cojson@0.7.11
- cojson-storage-indexeddb@0.7.11
- jazz-tools@0.7.11
## 0.7.10
### Patch Changes
- Updated dependencies
- cojson@0.7.10
- cojson-storage-indexeddb@0.7.10
- jazz-tools@0.7.10
## 0.7.9
### Patch Changes
- Updated dependencies
- cojson@0.7.9
- cojson-storage-indexeddb@0.7.9
- jazz-tools@0.7.9
## 0.7.8
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.8
## 0.7.6
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "jazz-browser",
"version": "0.7.6",
"version": "0.7.13",
"type": "module",
"main": "dist/index.js",
"types": "src/index.ts",

View File

@@ -26,7 +26,13 @@ export class BrowserDemoAuth<Acc extends Account> implements AuthProvider<Acc> {
const storageData = JSON.stringify(
credentials satisfies StorageData,
);
if (!(localStorage["demo-auth-existing-users"]?.split(",") as string[] | undefined)?.includes(name)) {
if (
!(
localStorage["demo-auth-existing-users"]?.split(",") as
| string[]
| undefined
)?.includes(name)
) {
localStorage["demo-auth-existing-users"] = localStorage[
"demo-auth-existing-users"
]

View File

@@ -1,5 +1,53 @@
# jazz-autosub
## 0.7.13
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.13
## 0.7.12
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.12
## 0.7.11
### Patch Changes
- Updated dependencies
- cojson@0.7.11
- cojson-transport-nodejs-ws@0.7.11
- jazz-tools@0.7.11
## 0.7.10
### Patch Changes
- Updated dependencies
- cojson@0.7.10
- cojson-transport-nodejs-ws@0.7.10
- jazz-tools@0.7.10
## 0.7.9
### Patch Changes
- Updated dependencies
- cojson@0.7.9
- cojson-transport-nodejs-ws@0.7.9
- jazz-tools@0.7.9
## 0.7.8
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.8
## 0.7.6
### Patch Changes

View File

@@ -5,7 +5,7 @@
"types": "src/index.ts",
"type": "module",
"license": "MIT",
"version": "0.7.6",
"version": "0.7.13",
"dependencies": {
"cojson": "workspace:*",
"cojson-transport-nodejs-ws": "workspace:*",

View File

@@ -1,5 +1,62 @@
# jazz-react
## 0.7.13
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.13
- jazz-browser@0.7.13
## 0.7.12
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.12
- jazz-browser@0.7.12
## 0.7.11
### Patch Changes
- Updated dependencies
- cojson@0.7.11
- jazz-browser@0.7.11
- jazz-tools@0.7.11
## 0.7.10
### Patch Changes
- Updated dependencies
- cojson@0.7.10
- jazz-browser@0.7.10
- jazz-tools@0.7.10
## 0.7.9
### Patch Changes
- Updated dependencies
- cojson@0.7.9
- jazz-browser@0.7.9
- jazz-tools@0.7.9
## 0.7.8
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.8
- jazz-browser@0.7.8
## 0.7.7
### Patch Changes
- 9fdc91c: Improve compatibility with React compiler and concurrent features
## 0.7.6
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "jazz-react",
"version": "0.7.6",
"version": "0.7.13",
"type": "module",
"main": "dist/index.js",
"types": "src/index.ts",

View File

@@ -10,13 +10,15 @@ export function DemoAuth<Acc extends Account = Account>({
appName,
appHostname,
Component = DemoAuth.BasicUI,
seedAccounts
seedAccounts,
}: {
accountSchema?: CoValueClass<Acc> & typeof Account;
appName: string;
appHostname?: string;
Component?: DemoAuth.Component;
seedAccounts?: {[name: string]: {accountID: ID<Account>, accountSecret: AgentSecret}}
seedAccounts?: {
[name: string]: { accountID: ID<Account>; accountSecret: AgentSecret };
};
}): ReactAuthHook<Acc> {
return function useLocalAuth(setJazzAuthState) {
const [authState, setAuthState] = useState<
@@ -60,7 +62,7 @@ export function DemoAuth<Acc extends Account = Account>({
},
},
appName,
seedAccounts
seedAccounts,
);
}, [appName, appHostname, logOutCounter, seedAccounts]);
@@ -102,7 +104,7 @@ const DemoAuthBasicUI = ({
signUp: (username: string) => void;
}) => {
const [username, setUsername] = useState<string>("");
const darkMode = window.matchMedia("(prefers-color-scheme: dark)").matches;
const darkMode = typeof window !== 'undefined' ? window.matchMedia("(prefers-color-scheme: dark)").matches : false;
return (
<div

View File

@@ -1,10 +1,9 @@
import React, { useEffect, useRef, useState } from "react";
import React, { useEffect, useState } from "react";
import {
consumeInviteLinkFromWindowLocation,
createJazzBrowserContext,
} from "jazz-browser";
import {
Account,
CoValue,
@@ -18,7 +17,7 @@ import { AuthState, ReactAuthHook } from "./auth/auth.js";
/** @category Context & Hooks */
export function createJazzReactContext<Acc extends Account>({
auth: authHook,
auth: useAuthHook,
peer,
storage = "indexedDB",
}: {
@@ -43,7 +42,7 @@ export function createJazzReactContext<Acc extends Account>({
}) {
const [me, setMe] = useState<Acc | undefined>();
const [authState, setAuthState] = useState<AuthState>("loading");
const { auth, AuthUI, logOut } = authHook(setAuthState);
const { auth, AuthUI, logOut } = useAuthHook(setAuthState);
useEffect(() => {
let done: (() => void) | undefined = undefined;
@@ -128,24 +127,20 @@ export function createJazzReactContext<Acc extends Account>({
id: ID<V> | undefined,
depth: D & DepthsIn<V> = [] as D & DepthsIn<V>,
): DeeplyLoaded<V, D> | undefined {
// for some reason (at least in React 18) - if we use state directly,
// some updates get swallowed/UI doesn't update
const [_, setUpdates] = useState<number>(0);
const state = useRef<DeeplyLoaded<V, D> | undefined>(undefined);
const [state, setState] = useState<{
value: DeeplyLoaded<V, D> | undefined;
}>({ value: undefined });
const me = React.useContext(JazzContext)?.me;
useEffect(() => {
if (!id || !me) return;
return subscribeToCoValue(Schema, id, me, depth, (update) => {
state.current = update as DeeplyLoaded<V, D>;
setUpdates((u) => {
return u + 1;
});
return subscribeToCoValue(Schema, id, me, depth, (value) => {
setState({ value });
});
}, [Schema, id, me]);
return state.current;
return state.value;
}
function useAcceptInvite<V extends CoValue>({

View File

@@ -1,5 +1,53 @@
# jazz-autosub
## 0.7.13
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.13
## 0.7.12
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.12
## 0.7.11
### Patch Changes
- Updated dependencies
- cojson@0.7.11
- cojson-transport-nodejs-ws@0.7.11
- jazz-tools@0.7.11
## 0.7.10
### Patch Changes
- Updated dependencies
- cojson@0.7.10
- cojson-transport-nodejs-ws@0.7.10
- jazz-tools@0.7.10
## 0.7.9
### Patch Changes
- Updated dependencies
- cojson@0.7.9
- cojson-transport-nodejs-ws@0.7.9
- jazz-tools@0.7.9
## 0.7.8
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.8
## 0.7.6
### Patch Changes

View File

@@ -3,7 +3,7 @@
"bin": "./dist/index.js",
"type": "module",
"license": "MIT",
"version": "0.7.6",
"version": "0.7.13",
"scripts": {
"lint": "eslint . --ext ts,tsx",
"format": "prettier --write './src/**/*.{ts,tsx}'",

View File

@@ -1,5 +1,47 @@
# jazz-autosub
## 0.7.13
### Patch Changes
- Fix CoList.toJSON()
## 0.7.12
### Patch Changes
- Fix: toJSON infinitely recurses on circular CoValue structures
## 0.7.11
### Patch Changes
- Updated dependencies
- cojson@0.7.11
- cojson-transport-nodejs-ws@0.7.11
## 0.7.10
### Patch Changes
- Updated dependencies
- cojson@0.7.10
- cojson-transport-nodejs-ws@0.7.10
## 0.7.9
### Patch Changes
- Updated dependencies
- cojson@0.7.9
- cojson-transport-nodejs-ws@0.7.9
## 0.7.8
### Patch Changes
- Fix CoMaps not initialising properly when passing too many init options
## 0.7.6
### Patch Changes

View File

@@ -5,7 +5,7 @@
"types": "./src/index.ts",
"type": "module",
"license": "MIT",
"version": "0.7.6",
"version": "0.7.13",
"dependencies": {
"@effect/schema": "^0.66.16",
"cojson": "workspace:*",

View File

@@ -17,7 +17,6 @@ import type {
import {
Account,
Group,
InitValues,
ItemsSym,
Ref,
SchemaInit,
@@ -172,18 +171,11 @@ export class CoList<Item = any> extends Array<Item> implements CoValue {
return Account.fromNode(this._raw.core.node);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[InitValues]?: any;
static get [Symbol.species]() {
return Array;
}
constructor(
options:
| { init: Item[]; owner: Account | Group }
| { fromRaw: RawCoList },
) {
constructor(options: { fromRaw: RawCoList } | undefined) {
super();
Object.defineProperty(this, "_instanceID", {
@@ -191,12 +183,7 @@ export class CoList<Item = any> extends Array<Item> implements CoValue {
enumerable: false,
});
if ("owner" in options) {
this[InitValues] = {
init: options.init,
owner: options.owner,
};
} else if ("fromRaw" in options) {
if (options && "fromRaw" in options) {
Object.defineProperties(this, {
id: {
value: options.fromRaw.id,
@@ -235,7 +222,20 @@ export class CoList<Item = any> extends Array<Item> implements CoValue {
items: UnCo<L[number]>[],
options: { owner: Account | Group },
) {
return new this({ init: items, owner: options.owner });
const instance = new this({ init: items, owner: options.owner });
const raw = options.owner._raw.createList(
toRawItems(items, instance._schema[ItemsSym]),
);
Object.defineProperties(instance, {
id: {
value: raw.id,
enumerable: false,
},
_raw: { value: raw, enumerable: false },
});
return instance;
}
push(...items: Item[]): number {
@@ -300,7 +300,8 @@ export class CoList<Item = any> extends Array<Item> implements CoValue {
return deleted;
}
toJSON() {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
toJSON(_key?: string, seenAbove?: ID<CoValue>[]): any[] {
const itemDescriptor = this._schema[ItemsSym] as Schema;
if (itemDescriptor === "json") {
return this._raw.asArray();
@@ -309,7 +310,14 @@ export class CoList<Item = any> extends Array<Item> implements CoValue {
.asArray()
.map((e) => encodeSync(itemDescriptor.encoded)(e));
} else if (isRefEncoded(itemDescriptor)) {
return this.map((item) => (item as unknown as CoValue)?.toJSON());
return this.map((item, idx) =>
seenAbove?.includes((item as CoValue)?.id)
? { _circular: (item as CoValue).id }
: (item as unknown as CoValue)?.toJSON(idx + "", [
...(seenAbove || []),
this.id,
]),
);
} else {
return [];
}
@@ -489,24 +497,6 @@ function toRawItems<Item>(items: Item[], itemDescriptor: Schema) {
return rawItems;
}
function init(list: CoList) {
if (list[InitValues]) {
const { init, owner } = list[InitValues];
const raw = owner._raw.createList(
toRawItems(init, list._schema[ItemsSym]),
);
Object.defineProperties(list, {
id: {
value: raw.id,
enumerable: false,
},
_raw: { value: raw, enumerable: false },
});
delete list[InitValues];
}
}
const CoListProxyHandler: ProxyHandler<CoList> = {
get(target, key, receiver) {
if (typeof key === "string" && !isNaN(+key)) {
@@ -542,7 +532,6 @@ const CoListProxyHandler: ProxyHandler<CoList> = {
(target.constructor as typeof CoList)._schema ||= {};
(target.constructor as typeof CoList)._schema[ItemsSym] =
value[SchemaInit];
init(target);
return true;
}
if (typeof key === "string" && !isNaN(+key)) {
@@ -571,7 +560,6 @@ const CoListProxyHandler: ProxyHandler<CoList> = {
(target.constructor as typeof CoList)._schema ||= {};
(target.constructor as typeof CoList)._schema[ItemsSym] =
descriptor.value[SchemaInit];
init(target);
return true;
} else {
return Reflect.defineProperty(target, key, descriptor);

View File

@@ -24,7 +24,6 @@ import {
makeRefs,
subscriptionsScopes,
ItemsSym,
InitValues,
isRefEncoded,
loadCoValue,
loadCoValueEf,
@@ -42,11 +41,6 @@ type CoMapEdit<V> = {
madeAt: Date;
};
type InitValuesFor<C extends CoMap> = {
init: Simplify<CoMapInit<C>>;
owner: Account | Group;
};
/**
* CoMaps are collaborative versions of plain objects, mapping string-like keys to values.
*
@@ -201,32 +195,25 @@ export class CoMap extends CoValueBase implements CoValue {
return Account.fromNode(this._raw.core.node);
}
/** @internal */
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[InitValues]?: any;
/** @internal */
constructor(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
options: { fromRaw: RawCoMap } | { init: any; owner: Account | Group },
options: { fromRaw: RawCoMap } | undefined,
) {
super();
if ("owner" in options) {
this[InitValues] = {
init: options.init,
owner: options.owner,
} as InitValuesFor<this>;
} else if ("fromRaw" in options) {
Object.defineProperties(this, {
id: {
value: options.fromRaw.id as unknown as ID<this>,
enumerable: false,
},
_raw: { value: options.fromRaw, enumerable: false },
});
} else {
throw new Error("Invalid CoMap constructor arguments");
if (options) {
if ("fromRaw" in options) {
Object.defineProperties(this, {
id: {
value: options.fromRaw.id as unknown as ID<this>,
enumerable: false,
},
_raw: { value: options.fromRaw, enumerable: false },
});
} else {
throw new Error("Invalid CoMap constructor arguments");
}
}
return new Proxy(this, CoMapProxyHandler as ProxyHandler<this>);
@@ -255,10 +242,20 @@ export class CoMap extends CoValueBase implements CoValue {
init: Simplify<CoMapInit<M>>,
options: { owner: Account | Group },
) {
return new this({ init, owner: options.owner });
const instance = new this();
const raw = instance.rawFromInit(init, options.owner);
Object.defineProperties(instance, {
id: {
value: raw.id,
enumerable: false,
},
_raw: { value: raw, enumerable: false },
});
return instance;
}
toJSON() {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
toJSON(_key?: string, seenAbove?: ID<CoValue>[]): any[] {
const jsonedFields = this._raw.keys().map((key) => {
const tKey = key as CoKeys<this>;
const descriptor = (this._schema[tKey] ||
@@ -268,7 +265,15 @@ export class CoMap extends CoValueBase implements CoValue {
return [key, this._raw.get(key)];
} else if (isRefEncoded(descriptor)) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const jsonedRef = (this as any)[tKey]?.toJSON();
if (seenAbove?.includes((this as any)[tKey]?.id)) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return [key, { _circular: (this as any)[tKey]?.id }];
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const jsonedRef = (this as any)[tKey]?.toJSON(tKey, [
...(seenAbove || []),
this.id,
]);
return [key, jsonedRef];
} else {
return [key, undefined];
@@ -306,6 +311,10 @@ export class CoMap extends CoValueBase implements CoValue {
key as keyof typeof this._schema
] || this._schema[ItemsSym]) as Schema;
if (!descriptor) {
continue;
}
if (descriptor === "json") {
rawInit[key] = initValue as JsonValue;
} else if (isRefEncoded(descriptor)) {
@@ -493,30 +502,6 @@ export type CoMapInit<Map extends object> = {
: IfCo<Map[Key], Key>]: Map[Key];
} & { [Key in CoKeys<Map> as IfCo<Map[Key], Key>]?: Map[Key] };
function tryInit(map: CoMap) {
if (
map[InitValues] &&
(map._schema[ItemsSym] ||
Object.keys(map[InitValues].init).every(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(key) => (map._schema as any)[key],
))
) {
const raw = map.rawFromInit(
map[InitValues].init,
map[InitValues].owner,
);
Object.defineProperties(map, {
id: {
value: raw.id,
enumerable: false,
},
_raw: { value: raw, enumerable: false },
});
delete map[InitValues];
}
}
// TODO: cache handlers per descriptor for performance?
const CoMapProxyHandler: ProxyHandler<CoMap> = {
get(target, key, receiver) {
@@ -559,7 +544,6 @@ const CoMapProxyHandler: ProxyHandler<CoMap> = {
(target.constructor as typeof CoMap)._schema ||= {};
(target.constructor as typeof CoMap)._schema[key] =
value[SchemaInit];
tryInit(target);
return true;
}
@@ -590,7 +574,6 @@ const CoMapProxyHandler: ProxyHandler<CoMap> = {
(target.constructor as typeof CoMap)._schema ||= {};
(target.constructor as typeof CoMap)._schema[key as string] =
attributes.value[SchemaInit];
tryInit(target);
return true;
} else {
return Reflect.defineProperty(target, key, attributes);

View File

@@ -30,7 +30,6 @@ import {
Ref,
inspect,
co,
InitValues,
SchemaInit,
isRefEncoded,
loadCoValue,
@@ -93,9 +92,6 @@ export class CoStream<Item = any> extends CoValueBase implements CoValue {
return this.perSession[this._loadedAs.sessionID!];
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[InitValues]?: any;
constructor(
options:
| { init: Item[]; owner: Account | Group }
@@ -103,7 +99,7 @@ export class CoStream<Item = any> extends CoValueBase implements CoValue {
) {
super();
if ("fromRaw" in options) {
if (options && "fromRaw" in options) {
Object.defineProperties(this, {
id: {
value: options.fromRaw.id,
@@ -111,11 +107,6 @@ export class CoStream<Item = any> extends CoValueBase implements CoValue {
},
_raw: { value: options.fromRaw, enumerable: false },
});
} else {
this[InitValues] = {
init: options.init,
owner: options.owner,
};
}
return new Proxy(this, CoStreamProxyHandler as ProxyHandler<this>);
@@ -126,7 +117,21 @@ export class CoStream<Item = any> extends CoValueBase implements CoValue {
init: S extends CoStream<infer Item> ? UnCo<Item>[] : never,
options: { owner: Account | Group },
) {
return new this({ init, owner: options.owner });
const instance = new this({ init, owner: options.owner });
const raw = options.owner._raw.createStream();
Object.defineProperties(instance, {
id: {
value: raw.id,
enumerable: false,
},
_raw: { value: raw, enumerable: false },
});
if (init) {
instance.push(...init);
}
return instance;
}
push(...items: Item[]) {
@@ -317,27 +322,6 @@ function entryFromRawEntry<Item>(
};
}
function init(stream: CoStream) {
const init = stream[InitValues];
if (!init) return;
const raw = init.owner._raw.createStream();
Object.defineProperties(stream, {
id: {
value: raw.id,
enumerable: false,
},
_raw: { value: raw, enumerable: false },
});
if (init.init) {
stream.push(...init.init);
}
delete stream[InitValues];
}
export const CoStreamProxyHandler: ProxyHandler<CoStream> = {
get(target, key, receiver) {
if (typeof key === "string" && key.startsWith("co_")) {
@@ -391,7 +375,6 @@ export const CoStreamProxyHandler: ProxyHandler<CoStream> = {
(target.constructor as typeof CoStream)._schema ||= {};
(target.constructor as typeof CoStream)._schema[ItemsSym] =
value[SchemaInit];
init(target);
return true;
} else {
return Reflect.set(target, key, value, receiver);
@@ -407,7 +390,6 @@ export const CoStreamProxyHandler: ProxyHandler<CoStream> = {
(target.constructor as typeof CoStream)._schema ||= {};
(target.constructor as typeof CoStream)._schema[ItemsSym] =
descriptor.value[SchemaInit];
init(target);
return true;
} else {
return Reflect.defineProperty(target, key, descriptor);

View File

@@ -40,7 +40,7 @@ export interface CoValue {
readonly _loadedAs: Account;
/** @category Stringifying & Inspection */
// eslint-disable-next-line @typescript-eslint/no-explicit-any
toJSON(): any[] | object;
toJSON(key?: string, seenAbove?: ID<CoValue>[]): any[] | object | string;
/** @category Stringifying & Inspection */
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[inspect](): any;
@@ -108,7 +108,7 @@ export class CoValueBase implements CoValue {
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
toJSON(): object | any[] {
toJSON(): object | any[] | string {
return {
id: this.id,
type: this._type,

View File

@@ -1,9 +1,6 @@
export const SchemaInit = Symbol.for("SchemaInit");
export type SchemaInit = typeof SchemaInit;
export const InitValues = Symbol.for("InitValues");
export type InitValues = typeof InitValues;
export const ItemsSym = Symbol.for("items");
export type ItemsSym = typeof ItemsSym;

View File

@@ -17,7 +17,7 @@ export type { ID, CoValue } from "./internal.js";
export { Encoders, co } from "./internal.js";
export { CoMap } from "./internal.js";
export { CoMap, type CoMapInit } from "./internal.js";
export { CoList } from "./internal.js";
export { CoStream, BinaryCoStream } from "./internal.js";
export { Group, Profile } from "./internal.js";

View File

@@ -52,6 +52,22 @@ describe("Simple CoMap operations", async () => {
expect(Object.keys(map)).toEqual(["color", "_height", "birthday"]);
});
test("Construction with too many things provided", () => {
const mapWithExtra = TestMap.create(
{
color: "red",
_height: 10,
birthday: birthday,
name: "Hermes",
extra: "extra",
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any,
{ owner: me },
);
expect(mapWithExtra.color).toEqual("red");
});
describe("Mutation", () => {
test("assignment & deletion", () => {
map.color = "blue";