Compare commits

...

4 Commits

Author SHA1 Message Date
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
22 changed files with 101 additions and 16 deletions

View File

@@ -1,5 +1,13 @@
# jazz-example-chat
## 0.0.59
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.12
- jazz-react@0.7.12
## 0.0.58
### Patch Changes

View File

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

View File

@@ -1,5 +1,14 @@
# jazz-example-pets
## 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

View File

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

View File

@@ -1,5 +1,13 @@
# jazz-example-todo
## 0.0.76
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.12
- jazz-react@0.7.12
## 0.0.75
### Patch Changes

View File

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

View File

@@ -1,5 +1,13 @@
# jazz-browser-media-images
## 0.7.12
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.12
- jazz-browser@0.7.12
## 0.7.11
### Patch Changes

View File

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

View File

@@ -1,5 +1,12 @@
# jazz-browser
## 0.7.12
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.12
## 0.7.11
### Patch Changes

View File

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

View File

@@ -1,5 +1,12 @@
# jazz-autosub
## 0.7.12
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.12
## 0.7.11
### Patch Changes

View File

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

View File

@@ -1,5 +1,13 @@
# jazz-react
## 0.7.12
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.12
- jazz-browser@0.7.12
## 0.7.11
### Patch Changes

View File

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

View File

@@ -104,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,5 +1,12 @@
# jazz-autosub
## 0.7.12
### Patch Changes
- Updated dependencies
- jazz-tools@0.7.12
## 0.7.11
### Patch Changes

View File

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

View File

@@ -1,5 +1,11 @@
# jazz-autosub
## 0.7.12
### Patch Changes
- Fix: toJSON infinitely recurses on circular CoValue structures
## 0.7.11
### Patch Changes

View File

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

View File

@@ -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 [];
}

View File

@@ -254,7 +254,8 @@ export class CoMap extends CoValueBase implements CoValue {
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] ||
@@ -264,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];

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,