Compare commits
30 Commits
jazz-bette
...
gio/chat-q
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d10111117 | ||
|
|
511ae983d5 | ||
|
|
f61a120560 | ||
|
|
2f1307a0ba | ||
|
|
fa15ea56d1 | ||
|
|
ceeabfaf89 | ||
|
|
b0b2b85a6f | ||
|
|
28c19c134f | ||
|
|
0924c9baaa | ||
|
|
b2712e18a2 | ||
|
|
66894b63d7 | ||
|
|
b1a05143e3 | ||
|
|
fb761ce66d | ||
|
|
07a6c340dc | ||
|
|
0fea904dd0 | ||
|
|
373aef313f | ||
|
|
efff4d0f4f | ||
|
|
ea2b01d8a2 | ||
|
|
55cb83e6e0 | ||
|
|
6290088fec | ||
|
|
b9c17b37db | ||
|
|
6c76ff8fbf | ||
|
|
3c6a2a6092 | ||
|
|
e8a950e61a | ||
|
|
e2cbf035de | ||
|
|
47599b6307 | ||
|
|
901d0762ee | ||
|
|
d1c1b0c5cc | ||
|
|
cf4ad7285d | ||
|
|
2983c7bd58 |
5
.changeset/cuddly-lemons-perform.md
Normal file
5
.changeset/cuddly-lemons-perform.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"quint-ui": patch
|
||||
---
|
||||
|
||||
Initial Quint-UI release
|
||||
@@ -1,5 +1,20 @@
|
||||
# passkey-svelte
|
||||
|
||||
## 0.0.102
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [6c76ff8]
|
||||
- jazz-tools@0.15.13
|
||||
|
||||
## 0.0.101
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [d1c1b0c]
|
||||
- Updated dependencies [cf4ad72]
|
||||
- jazz-tools@0.15.12
|
||||
|
||||
## 0.0.100
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "chat-svelte",
|
||||
"version": "0.0.100",
|
||||
"version": "0.0.102",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
|
||||
@@ -12,10 +12,10 @@
|
||||
"test:e2e:ui": "playwright test --ui"
|
||||
},
|
||||
"dependencies": {
|
||||
"clsx": "^2.0.0",
|
||||
"hash-slash": "workspace:*",
|
||||
"jazz-tools": "workspace:*",
|
||||
"lucide-react": "^0.274.0",
|
||||
"quint-ui": "workspace:*",
|
||||
"react": "19.1.0",
|
||||
"react-dom": "19.1.0",
|
||||
"zod": "3.25.28"
|
||||
@@ -32,4 +32,4 @@
|
||||
"typescript": "5.6.2",
|
||||
"vite": "^6.3.5"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import { useIframeHashRouter } from "hash-slash";
|
||||
import { Group } from "jazz-tools";
|
||||
import { JazzInspector } from "jazz-tools/inspector";
|
||||
import { JazzReactProvider, useAccount } from "jazz-tools/react";
|
||||
import { Button } from "quint-ui";
|
||||
import { StrictMode } from "react";
|
||||
import { createRoot } from "react-dom/client";
|
||||
import { ChatScreen } from "./chatScreen.tsx";
|
||||
@@ -39,7 +40,11 @@ export function App() {
|
||||
}}
|
||||
placeholder="Set username"
|
||||
/>
|
||||
{!inIframe && <button onClick={logOut}>Log out</button>}
|
||||
{!inIframe && (
|
||||
<Button intent="danger" onClick={logOut} variant="outline">
|
||||
Log out
|
||||
</Button>
|
||||
)}
|
||||
</TopBar>
|
||||
{router.route({
|
||||
"/": () => createChat() as never,
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
@import "tailwindcss";
|
||||
@import "quint-ui/styles.css";
|
||||
/* We need to tell tailwind to detect classes from quint components */
|
||||
@source "../node_modules/quint-ui";
|
||||
|
||||
/* Custom stone color palette */
|
||||
@theme {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import clsx from "clsx";
|
||||
import { CoPlainText, ImageDefinition } from "jazz-tools";
|
||||
import type { CoPlainText, ImageDefinition } from "jazz-tools";
|
||||
import { ProgressiveImg } from "jazz-tools/react";
|
||||
import { ImageIcon } from "lucide-react";
|
||||
import { cn } from "quint-ui";
|
||||
import { useId, useRef } from "react";
|
||||
|
||||
export function AppContainer(props: { children: React.ReactNode }) {
|
||||
@@ -57,7 +57,7 @@ export function BubbleBody(props: {
|
||||
}) {
|
||||
return (
|
||||
<div
|
||||
className={clsx(
|
||||
className={cn(
|
||||
"line-clamp-10 text-ellipsis whitespace-pre-wrap",
|
||||
"rounded-2xl overflow-hidden max-w-[calc(100%-5rem)] shadow-sm p-1",
|
||||
props.fromMe
|
||||
@@ -75,9 +75,7 @@ export function BubbleText(props: {
|
||||
className?: string;
|
||||
}) {
|
||||
return (
|
||||
<p className={clsx("px-2 leading-relaxed", props.className)}>
|
||||
{props.text}
|
||||
</p>
|
||||
<p className={cn("px-2 leading-relaxed", props.className)}>{props.text}</p>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
3
examples/server-side-validation/vercel.json
Normal file
3
examples/server-side-validation/vercel.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"ignoreCommand": "echo true"
|
||||
}
|
||||
@@ -1,5 +1,17 @@
|
||||
# cojson-storage-indexeddb
|
||||
|
||||
## 0.15.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- cojson@0.15.13
|
||||
|
||||
## 0.15.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- cojson@0.15.12
|
||||
|
||||
## 0.15.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cojson-storage-indexeddb",
|
||||
"version": "0.15.11",
|
||||
"version": "0.15.13",
|
||||
"main": "dist/index.js",
|
||||
"type": "module",
|
||||
"types": "dist/index.d.ts",
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
# cojson-storage-sqlite
|
||||
|
||||
## 0.15.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- cojson@0.15.13
|
||||
|
||||
## 0.15.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- cojson@0.15.12
|
||||
|
||||
## 0.15.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "cojson-storage-sqlite",
|
||||
"type": "module",
|
||||
"version": "0.15.11",
|
||||
"version": "0.15.13",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
# cojson-transport-nodejs-ws
|
||||
|
||||
## 0.15.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- cojson@0.15.13
|
||||
|
||||
## 0.15.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- cojson@0.15.12
|
||||
|
||||
## 0.15.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "cojson-transport-ws",
|
||||
"type": "module",
|
||||
"version": "0.15.11",
|
||||
"version": "0.15.13",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
# cojson
|
||||
|
||||
## 0.15.13
|
||||
|
||||
## 0.15.12
|
||||
|
||||
## 0.15.11
|
||||
|
||||
## 0.15.10
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
},
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"version": "0.15.11",
|
||||
"version": "0.15.13",
|
||||
"devDependencies": {
|
||||
"@opentelemetry/sdk-metrics": "^2.0.0",
|
||||
"libsql": "^0.5.13",
|
||||
|
||||
@@ -82,6 +82,11 @@ export class LocalNode {
|
||||
this.storage = storage;
|
||||
}
|
||||
|
||||
removeStorage() {
|
||||
this.storage?.close();
|
||||
this.storage = undefined;
|
||||
}
|
||||
|
||||
getCoValue(id: RawCoID) {
|
||||
let entry = this.coValues.get(id);
|
||||
|
||||
@@ -348,12 +353,10 @@ export class LocalNode {
|
||||
skipLoadingFromPeer?: PeerID,
|
||||
skipRetry?: boolean,
|
||||
): Promise<CoValueCore> {
|
||||
if (!id) {
|
||||
throw new Error("Trying to load CoValue with undefined id");
|
||||
}
|
||||
|
||||
if (!id.startsWith("co_z")) {
|
||||
throw new Error(`Trying to load CoValue with invalid id ${id}`);
|
||||
if (typeof id !== "string" || !id.startsWith("co_z")) {
|
||||
throw new TypeError(
|
||||
`Trying to load CoValue with invalid id ${Array.isArray(id) ? JSON.stringify(id) : id}`,
|
||||
);
|
||||
}
|
||||
|
||||
if (this.crashed) {
|
||||
|
||||
@@ -54,6 +54,43 @@ describe("loading coValues from server", () => {
|
||||
`);
|
||||
});
|
||||
|
||||
test("coValue load throws on invalid id", async () => {
|
||||
const { node } = setupTestNode({
|
||||
connected: true,
|
||||
});
|
||||
|
||||
await expect(async () => await node.load("test" as any)).rejects.toThrow(
|
||||
"Trying to load CoValue with invalid id test",
|
||||
);
|
||||
await expect(async () => await node.load(null as any)).rejects.toThrow(
|
||||
"Trying to load CoValue with invalid id null",
|
||||
);
|
||||
await expect(async () => await node.load(undefined as any)).rejects.toThrow(
|
||||
"Trying to load CoValue with invalid id undefined",
|
||||
);
|
||||
await expect(async () => await node.load(1 as any)).rejects.toThrow(
|
||||
"Trying to load CoValue with invalid id 1",
|
||||
);
|
||||
await expect(async () => await node.load({} as any)).rejects.toThrow(
|
||||
"Trying to load CoValue with invalid id [object Object]",
|
||||
);
|
||||
await expect(async () => await node.load([] as any)).rejects.toThrow(
|
||||
"Trying to load CoValue with invalid id []",
|
||||
);
|
||||
await expect(async () => await node.load(["test"] as any)).rejects.toThrow(
|
||||
'Trying to load CoValue with invalid id ["test"]',
|
||||
);
|
||||
await expect(
|
||||
async () => await node.load((() => {}) as any),
|
||||
).rejects.toMatchInlineSnapshot(`
|
||||
[TypeError: Trying to load CoValue with invalid id () => {
|
||||
}]
|
||||
`);
|
||||
await expect(
|
||||
async () => await node.load(new Date() as any),
|
||||
).rejects.toThrow();
|
||||
});
|
||||
|
||||
test("unavailable coValue retry with skipRetry set to true", async () => {
|
||||
const client = setupTestNode();
|
||||
const client2 = setupTestNode();
|
||||
|
||||
@@ -991,7 +991,7 @@ describe("LocalNode.load", () => {
|
||||
|
||||
// @ts-expect-error Testing with undefined ID
|
||||
await expect(client.node.load(undefined)).rejects.toThrow(
|
||||
"Trying to load CoValue with undefined id",
|
||||
"Trying to load CoValue with invalid id undefined",
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
# jazz-auth-betterauth
|
||||
|
||||
## 0.15.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [6c76ff8]
|
||||
- jazz-tools@0.15.13
|
||||
- jazz-betterauth-client-plugin@0.15.13
|
||||
- cojson@0.15.13
|
||||
|
||||
## 0.15.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [d1c1b0c]
|
||||
- Updated dependencies [cf4ad72]
|
||||
- jazz-tools@0.15.12
|
||||
- jazz-betterauth-client-plugin@0.15.12
|
||||
- cojson@0.15.12
|
||||
|
||||
## 0.15.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "jazz-auth-betterauth",
|
||||
"version": "0.15.11",
|
||||
"version": "0.15.13",
|
||||
"type": "module",
|
||||
"main": "dist/index.js",
|
||||
"types": "src/index.ts",
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
# jazz-betterauth-client-plugin
|
||||
|
||||
## 0.15.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-betterauth-server-plugin@0.15.13
|
||||
|
||||
## 0.15.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- jazz-betterauth-server-plugin@0.15.12
|
||||
|
||||
## 0.15.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "jazz-betterauth-client-plugin",
|
||||
"version": "0.15.11",
|
||||
"version": "0.15.13",
|
||||
"type": "module",
|
||||
"main": "dist/index.js",
|
||||
"types": "src/index.ts",
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
# jazz-betterauth-server-plugin
|
||||
|
||||
## 0.15.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [6c76ff8]
|
||||
- jazz-tools@0.15.13
|
||||
- cojson@0.15.13
|
||||
|
||||
## 0.15.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [d1c1b0c]
|
||||
- Updated dependencies [cf4ad72]
|
||||
- jazz-tools@0.15.12
|
||||
- cojson@0.15.12
|
||||
|
||||
## 0.15.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "jazz-betterauth-server-plugin",
|
||||
"version": "0.15.11",
|
||||
"version": "0.15.13",
|
||||
"type": "module",
|
||||
"main": "dist/index.js",
|
||||
"types": "src/index.ts",
|
||||
|
||||
@@ -1,5 +1,26 @@
|
||||
# jazz-react-auth-betterauth
|
||||
|
||||
## 0.15.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [6c76ff8]
|
||||
- jazz-tools@0.15.13
|
||||
- jazz-auth-betterauth@0.15.13
|
||||
- jazz-betterauth-client-plugin@0.15.13
|
||||
- cojson@0.15.13
|
||||
|
||||
## 0.15.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [d1c1b0c]
|
||||
- Updated dependencies [cf4ad72]
|
||||
- jazz-tools@0.15.12
|
||||
- jazz-auth-betterauth@0.15.12
|
||||
- jazz-betterauth-client-plugin@0.15.12
|
||||
- cojson@0.15.12
|
||||
|
||||
## 0.15.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "jazz-react-auth-betterauth",
|
||||
"version": "0.15.11",
|
||||
"version": "0.15.13",
|
||||
"type": "module",
|
||||
"main": "dist/index.js",
|
||||
"types": "src/index.tsx",
|
||||
|
||||
@@ -1,5 +1,26 @@
|
||||
# jazz-run
|
||||
|
||||
## 0.15.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [6c76ff8]
|
||||
- jazz-tools@0.15.13
|
||||
- cojson@0.15.13
|
||||
- cojson-storage-sqlite@0.15.13
|
||||
- cojson-transport-ws@0.15.13
|
||||
|
||||
## 0.15.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [d1c1b0c]
|
||||
- Updated dependencies [cf4ad72]
|
||||
- jazz-tools@0.15.12
|
||||
- cojson@0.15.12
|
||||
- cojson-storage-sqlite@0.15.12
|
||||
- cojson-transport-ws@0.15.12
|
||||
|
||||
## 0.15.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"bin": "./dist/index.js",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"version": "0.15.11",
|
||||
"version": "0.15.13",
|
||||
"exports": {
|
||||
"./startSyncServer": {
|
||||
"import": "./dist/startSyncServer.js",
|
||||
@@ -28,11 +28,11 @@
|
||||
"@effect/printer-ansi": "^0.34.5",
|
||||
"@effect/schema": "^0.71.1",
|
||||
"@effect/typeclass": "^0.25.5",
|
||||
"cojson": "workspace:0.15.11",
|
||||
"cojson-storage-sqlite": "workspace:0.15.11",
|
||||
"cojson-transport-ws": "workspace:0.15.11",
|
||||
"cojson": "workspace:0.15.13",
|
||||
"cojson-storage-sqlite": "workspace:0.15.13",
|
||||
"cojson-transport-ws": "workspace:0.15.13",
|
||||
"effect": "^3.6.5",
|
||||
"jazz-tools": "workspace:0.15.11",
|
||||
"jazz-tools": "workspace:0.15.13",
|
||||
"ws": "^8.14.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
# jazz-tools
|
||||
|
||||
## 0.15.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 6c76ff8: Fix load failures when loading a missing ref declared with z.optional and Schema.optional
|
||||
- cojson@0.15.13
|
||||
- cojson-storage-indexeddb@0.15.13
|
||||
- cojson-transport-ws@0.15.13
|
||||
|
||||
## 0.15.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- d1c1b0c: Fix stuck authentication when using onAnonymousAccountDiscarded with a storage
|
||||
- cf4ad72: fix unhandled rejection on CoValue.load
|
||||
- cojson@0.15.12
|
||||
- cojson-storage-indexeddb@0.15.12
|
||||
- cojson-transport-ws@0.15.12
|
||||
|
||||
## 0.15.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -139,7 +139,7 @@
|
||||
},
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"version": "0.15.11",
|
||||
"version": "0.15.13",
|
||||
"dependencies": {
|
||||
"@manuscripts/prosemirror-recreate-steps": "^0.1.4",
|
||||
"@scure/base": "1.2.1",
|
||||
|
||||
@@ -47,6 +47,26 @@ describe("useCoState", () => {
|
||||
expect(result.current?.value).toBe("123");
|
||||
});
|
||||
|
||||
it("should return null on invalid id", async () => {
|
||||
const TestMap = co.map({
|
||||
value: z.string(),
|
||||
});
|
||||
|
||||
const account = await createJazzTestAccount({
|
||||
isCurrentActiveAccount: true,
|
||||
});
|
||||
|
||||
const { result } = renderHook(() => useCoState(TestMap, "test", {}), {
|
||||
account,
|
||||
});
|
||||
|
||||
expect(result.current).toBeUndefined();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
it("should update the value when the coValue changes", async () => {
|
||||
const TestMap = co.map({
|
||||
value: z.string(),
|
||||
|
||||
@@ -279,8 +279,12 @@ export class JazzContextManager<
|
||||
},
|
||||
);
|
||||
|
||||
prevContext.node.syncManager.addPeer(currentAccountAsPeer);
|
||||
// Closing storage on the prevContext to avoid conflicting transactions and getting stuck on waitForAllCoValuesSync
|
||||
// The storage is reachable through currentContext using the connectedPeers
|
||||
prevContext.node.removeStorage();
|
||||
|
||||
currentContext.node.syncManager.addPeer(prevAccountAsPeer);
|
||||
prevContext.node.syncManager.addPeer(currentAccountAsPeer);
|
||||
|
||||
try {
|
||||
await this.props.onAnonymousAccountDiscarded?.(prevContext.me);
|
||||
|
||||
@@ -43,27 +43,35 @@ type SchemaField =
|
||||
| z.core.$ZodCatch<z.core.$ZodType>
|
||||
| (z.core.$ZodCustom<any, any> & { builtin: any });
|
||||
|
||||
export function schemaFieldToCoFieldDef(schema: SchemaField) {
|
||||
export function schemaFieldToCoFieldDef(
|
||||
schema: SchemaField,
|
||||
isOptional = false,
|
||||
) {
|
||||
if (isCoValueClass(schema)) {
|
||||
return coField.ref(schema);
|
||||
if (isOptional) {
|
||||
return coField.ref(schema, { optional: true });
|
||||
} else {
|
||||
return coField.ref(schema);
|
||||
}
|
||||
} else if (isCoValueSchema(schema)) {
|
||||
if (isAnyCoOptionalSchema(schema)) {
|
||||
return coField.ref(schema.getCoValueClass(), {
|
||||
optional: true,
|
||||
});
|
||||
}
|
||||
return coField.ref(schema.getCoValueClass());
|
||||
|
||||
if (isOptional) {
|
||||
return coField.ref(schema.getCoValueClass(), { optional: true });
|
||||
} else {
|
||||
return coField.ref(schema.getCoValueClass());
|
||||
}
|
||||
} else {
|
||||
if ("_zod" in schema) {
|
||||
if (schema._zod.def.type === "optional") {
|
||||
const inner = zodSchemaToCoSchemaOrKeepPrimitive(
|
||||
schema._zod.def.innerType,
|
||||
);
|
||||
if (isCoValueClass(inner)) {
|
||||
return coField.ref(inner, { optional: true });
|
||||
} else {
|
||||
return schemaFieldToCoFieldDef(inner);
|
||||
}
|
||||
return schemaFieldToCoFieldDef(inner, true);
|
||||
} else if (schema._zod.def.type === "string") {
|
||||
return coField.string;
|
||||
} else if (schema._zod.def.type === "number") {
|
||||
@@ -77,6 +85,7 @@ export function schemaFieldToCoFieldDef(schema: SchemaField) {
|
||||
} else if (schema._zod.def.type === "readonly") {
|
||||
return schemaFieldToCoFieldDef(
|
||||
(schema as unknown as ZodReadonly).def.innerType as SchemaField,
|
||||
isOptional,
|
||||
);
|
||||
} else if (schema._zod.def.type === "date") {
|
||||
return coField.optional.Date;
|
||||
@@ -86,6 +95,7 @@ export function schemaFieldToCoFieldDef(schema: SchemaField) {
|
||||
// Mostly to support z.json()
|
||||
return schemaFieldToCoFieldDef(
|
||||
(schema as unknown as ZodLazy).unwrap() as SchemaField,
|
||||
isOptional,
|
||||
);
|
||||
} else if (
|
||||
schema._zod.def.type === "default" ||
|
||||
@@ -98,6 +108,7 @@ export function schemaFieldToCoFieldDef(schema: SchemaField) {
|
||||
return schemaFieldToCoFieldDef(
|
||||
(schema as unknown as ZodDefault | ZodCatch).def
|
||||
.innerType as SchemaField,
|
||||
isOptional,
|
||||
);
|
||||
} else if (schema._zod.def.type === "literal") {
|
||||
if (
|
||||
@@ -129,7 +140,7 @@ export function schemaFieldToCoFieldDef(schema: SchemaField) {
|
||||
return coField.json();
|
||||
} else if (schema._zod.def.type === "custom") {
|
||||
if ("builtin" in schema) {
|
||||
return schemaFieldToCoFieldDef(schema.builtin);
|
||||
return schemaFieldToCoFieldDef(schema.builtin, isOptional);
|
||||
} else {
|
||||
throw new Error(`Unsupported custom zod type`);
|
||||
}
|
||||
@@ -137,9 +148,13 @@ export function schemaFieldToCoFieldDef(schema: SchemaField) {
|
||||
if (isUnionOfPrimitivesDeeply(schema)) {
|
||||
return coField.json();
|
||||
} else if (isUnionOfCoMapsDeeply(schema)) {
|
||||
return coField.ref<CoValueClass<CoMap>>(
|
||||
schemaUnionDiscriminatorFor(schema),
|
||||
);
|
||||
const result = schemaUnionDiscriminatorFor(schema);
|
||||
|
||||
if (isOptional) {
|
||||
return coField.ref<CoValueClass<CoMap>>(result, { optional: true });
|
||||
} else {
|
||||
return coField.ref<CoValueClass<CoMap>>(result);
|
||||
}
|
||||
} else {
|
||||
throw new Error(
|
||||
"z.union()/z.discriminatedUnion() of mixed collaborative and non-collaborative types is not supported",
|
||||
|
||||
@@ -28,6 +28,10 @@ export class CoValueCoreSubscription {
|
||||
this.subscribeToState();
|
||||
this.listener("unavailable");
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Unexpected error loading CoValue: ", error);
|
||||
this.listener("unavailable");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { StorageAPI } from "cojson";
|
||||
import { WasmCrypto } from "cojson/crypto/WasmCrypto";
|
||||
import { beforeEach, describe, expect, test, vi } from "vitest";
|
||||
import {
|
||||
@@ -32,6 +33,7 @@ import {
|
||||
getPeerConnectedToTestSyncServer,
|
||||
setupJazzTestSync,
|
||||
} from "../testing";
|
||||
import { createAsyncStorage, getDbPath } from "./testStorage";
|
||||
|
||||
const Crypto = await WasmCrypto.create();
|
||||
|
||||
@@ -40,12 +42,14 @@ class TestJazzContextManager<Acc extends Account> extends JazzContextManager<
|
||||
JazzContextManagerBaseProps<Acc> & {
|
||||
defaultProfileName?: string;
|
||||
AccountSchema?: AccountClass<Acc>;
|
||||
storage?: string;
|
||||
}
|
||||
> {
|
||||
async getNewContext(
|
||||
props: JazzContextManagerBaseProps<Acc> & {
|
||||
defaultProfileName?: string;
|
||||
AccountSchema?: AccountClass<Acc> & CoValueFromRaw<Acc>;
|
||||
storage?: string;
|
||||
},
|
||||
authProps?: JazzContextManagerAuthProps,
|
||||
) {
|
||||
@@ -58,6 +62,7 @@ class TestJazzContextManager<Acc extends Account> extends JazzContextManager<
|
||||
sessionProvider: randomSessionProvider,
|
||||
authSecretStorage: this.getAuthSecretStorage(),
|
||||
AccountSchema: props.AccountSchema,
|
||||
storage: await createAsyncStorage({ filename: props.storage }),
|
||||
});
|
||||
|
||||
return {
|
||||
@@ -76,12 +81,14 @@ class TestJazzContextManager<Acc extends Account> extends JazzContextManager<
|
||||
describe("ContextManager", () => {
|
||||
let manager: TestJazzContextManager<Account>;
|
||||
let authSecretStorage: AuthSecretStorage;
|
||||
let storage: StorageAPI;
|
||||
|
||||
function getCurrentValue() {
|
||||
return manager.getCurrentValue() as JazzAuthContext<Account>;
|
||||
}
|
||||
|
||||
beforeEach(async () => {
|
||||
storage = await createAsyncStorage({});
|
||||
KvStoreContext.getInstance().initialize(new InMemoryKVStore());
|
||||
authSecretStorage = new AuthSecretStorage();
|
||||
await authSecretStorage.clear();
|
||||
@@ -232,6 +239,78 @@ describe("ContextManager", () => {
|
||||
expect(onAnonymousAccountDiscarded).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test("onAnonymousAccountDiscarded should not block the authentication when storage is active", async () => {
|
||||
const dbFilename = getDbPath();
|
||||
|
||||
const AccountRoot = co.map({
|
||||
value: z.string(),
|
||||
get transferredRoot(): z.ZodOptional<typeof AccountRoot> {
|
||||
return co.optional(AccountRoot);
|
||||
},
|
||||
});
|
||||
|
||||
let lastRootId: string | undefined;
|
||||
|
||||
const CustomAccount = co
|
||||
.account({
|
||||
root: AccountRoot,
|
||||
profile: co.profile(),
|
||||
})
|
||||
.withMigration(async (account) => {
|
||||
account.root = AccountRoot.create(
|
||||
{
|
||||
value: "Hello",
|
||||
},
|
||||
Group.create(this).makePublic(),
|
||||
);
|
||||
});
|
||||
|
||||
const customManager = new TestJazzContextManager<
|
||||
InstanceOfSchema<typeof CustomAccount>
|
||||
>();
|
||||
|
||||
await customManager.createContext({
|
||||
AccountSchema: anySchemaToCoSchema(CustomAccount),
|
||||
storage: dbFilename,
|
||||
onAnonymousAccountDiscarded: async (anonymousAccount) => {
|
||||
const anonymousAccountWithRoot = await anonymousAccount.ensureLoaded({
|
||||
resolve: { root: true },
|
||||
});
|
||||
|
||||
const me = await CustomAccount.getMe().ensureLoaded({
|
||||
resolve: { root: true },
|
||||
});
|
||||
|
||||
me.root.transferredRoot = anonymousAccountWithRoot.root;
|
||||
},
|
||||
});
|
||||
|
||||
const prevContextNode = customManager.getCurrentValue()!.node;
|
||||
|
||||
expect(prevContextNode.storage).toBeDefined();
|
||||
|
||||
const account = (
|
||||
customManager.getCurrentValue() as JazzAuthContext<
|
||||
InstanceOfSchema<typeof CustomAccount>
|
||||
>
|
||||
).me;
|
||||
|
||||
await customManager.authenticate({
|
||||
accountID: account.id,
|
||||
accountSecret: account._raw.core.node.getCurrentAgent().agentSecret,
|
||||
provider: "test",
|
||||
});
|
||||
|
||||
// The storage should be closed and set to undefined
|
||||
expect(prevContextNode.storage).toBeUndefined();
|
||||
|
||||
const me = await CustomAccount.getMe().ensureLoaded({
|
||||
resolve: { root: { transferredRoot: true } },
|
||||
});
|
||||
|
||||
expect(me.root.transferredRoot?.value).toBe("Hello");
|
||||
});
|
||||
|
||||
test("the migration should be applied correctly on existing accounts", async () => {
|
||||
const AccountRoot = co.map({
|
||||
value: z.string(),
|
||||
@@ -266,8 +345,6 @@ describe("ContextManager", () => {
|
||||
>
|
||||
).me;
|
||||
|
||||
console.log("before", account._refs.root?.id);
|
||||
|
||||
await customManager.authenticate({
|
||||
accountID: account.id,
|
||||
accountSecret: account._raw.core.node.getCurrentAgent().agentSecret,
|
||||
@@ -278,8 +355,6 @@ describe("ContextManager", () => {
|
||||
resolve: { root: true },
|
||||
});
|
||||
|
||||
console.log("after", me._refs.root?.id);
|
||||
|
||||
expect(me.root.id).toBe(lastRootId);
|
||||
});
|
||||
|
||||
|
||||
@@ -33,6 +33,129 @@ test("load a value", async () => {
|
||||
expect(john?.name).toBe("John");
|
||||
});
|
||||
|
||||
test("return null if id is invalid", async () => {
|
||||
const Person = co.map({
|
||||
name: z.string(),
|
||||
});
|
||||
|
||||
const john = await Person.load("test");
|
||||
expect(john).toBeNull();
|
||||
});
|
||||
|
||||
test("load a missing optional value (co.optional)", async () => {
|
||||
const Dog = co.map({
|
||||
name: z.string(),
|
||||
});
|
||||
|
||||
const Person = co.map({
|
||||
name: z.string(),
|
||||
dog: co.optional(Dog),
|
||||
});
|
||||
|
||||
const group = Group.create();
|
||||
const map = Person.create({ name: "John" }, group);
|
||||
group.addMember("everyone", "reader");
|
||||
|
||||
const alice = await createJazzTestAccount();
|
||||
|
||||
const john = await Person.load(map.id, {
|
||||
loadAs: alice,
|
||||
resolve: { dog: true },
|
||||
});
|
||||
|
||||
assert(john);
|
||||
|
||||
expect(john.name).toBe("John");
|
||||
expect(john.dog).toBeUndefined();
|
||||
});
|
||||
|
||||
test("load a missing optional value (z.optional)", async () => {
|
||||
const Dog = co.map({
|
||||
name: z.string(),
|
||||
});
|
||||
|
||||
const Person = co.map({
|
||||
name: z.string(),
|
||||
dog: z.optional(Dog),
|
||||
});
|
||||
|
||||
const group = Group.create();
|
||||
const map = Person.create({ name: "John" }, group);
|
||||
group.addMember("everyone", "reader");
|
||||
|
||||
const alice = await createJazzTestAccount();
|
||||
|
||||
const john = await Person.load(map.id, {
|
||||
loadAs: alice,
|
||||
resolve: { dog: true },
|
||||
});
|
||||
|
||||
assert(john);
|
||||
|
||||
expect(john.name).toBe("John");
|
||||
expect(john.dog).toBeUndefined();
|
||||
});
|
||||
|
||||
test("load a missing optional value (Schema.optional)", async () => {
|
||||
const Dog = co.map({
|
||||
name: z.string(),
|
||||
});
|
||||
|
||||
const Person = co.map({
|
||||
name: z.string(),
|
||||
dog: Dog.optional(),
|
||||
});
|
||||
|
||||
const group = Group.create();
|
||||
const map = Person.create({ name: "John" }, group);
|
||||
group.addMember("everyone", "reader");
|
||||
|
||||
const alice = await createJazzTestAccount();
|
||||
|
||||
const john = await Person.load(map.id, {
|
||||
loadAs: alice,
|
||||
resolve: { dog: true },
|
||||
});
|
||||
|
||||
assert(john);
|
||||
|
||||
expect(john.name).toBe("John");
|
||||
expect(john.dog).toBeUndefined();
|
||||
});
|
||||
|
||||
test("load a missing optional value (optional discrminatedUnion)", async () => {
|
||||
const Dog = co.map({
|
||||
type: z.literal("dog"),
|
||||
name: z.string(),
|
||||
});
|
||||
|
||||
const Cat = co.map({
|
||||
type: z.literal("cat"),
|
||||
name: z.string(),
|
||||
});
|
||||
|
||||
const Person = co.map({
|
||||
name: z.string(),
|
||||
pet: co.discriminatedUnion("type", [Dog, Cat]).optional(),
|
||||
});
|
||||
|
||||
const group = Group.create();
|
||||
const map = Person.create({ name: "John" }, group);
|
||||
group.addMember("everyone", "reader");
|
||||
|
||||
const alice = await createJazzTestAccount();
|
||||
|
||||
const john = await Person.load(map.id, {
|
||||
loadAs: alice,
|
||||
resolve: { pet: true },
|
||||
});
|
||||
|
||||
assert(john);
|
||||
|
||||
expect(john.name).toBe("John");
|
||||
expect(john.pet).toBeUndefined();
|
||||
});
|
||||
|
||||
test("retry an unavailable value", async () => {
|
||||
const Person = co.map({
|
||||
name: z.string(),
|
||||
|
||||
70
packages/jazz-tools/src/tools/tests/testStorage.ts
Normal file
70
packages/jazz-tools/src/tools/tests/testStorage.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { unlinkSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { SQLiteDatabaseDriverAsync, getSqliteStorageAsync } from "cojson";
|
||||
import Database, { type Database as DatabaseT } from "libsql";
|
||||
import { onTestFinished } from "vitest";
|
||||
|
||||
class LibSQLSqliteAsyncDriver implements SQLiteDatabaseDriverAsync {
|
||||
private readonly db: DatabaseT;
|
||||
|
||||
constructor(filename: string) {
|
||||
this.db = new Database(filename, {});
|
||||
}
|
||||
|
||||
async initialize() {
|
||||
await this.db.pragma("journal_mode = WAL");
|
||||
}
|
||||
|
||||
async run(sql: string, params: unknown[]) {
|
||||
this.db.prepare(sql).run(params);
|
||||
}
|
||||
|
||||
async query<T>(sql: string, params: unknown[]): Promise<T[]> {
|
||||
return this.db.prepare(sql).all(params) as T[];
|
||||
}
|
||||
|
||||
async get<T>(sql: string, params: unknown[]): Promise<T | undefined> {
|
||||
return this.db.prepare(sql).get(params) as T | undefined;
|
||||
}
|
||||
|
||||
async transaction(callback: () => unknown) {
|
||||
await this.run("BEGIN TRANSACTION", []);
|
||||
|
||||
try {
|
||||
await callback();
|
||||
await this.run("COMMIT", []);
|
||||
} catch (error) {
|
||||
await this.run("ROLLBACK", []);
|
||||
}
|
||||
}
|
||||
|
||||
async closeDb() {
|
||||
this.db.close();
|
||||
}
|
||||
}
|
||||
|
||||
export async function createAsyncStorage({ filename }: { filename?: string }) {
|
||||
const storage = await getSqliteStorageAsync(
|
||||
new LibSQLSqliteAsyncDriver(getDbPath(filename)),
|
||||
);
|
||||
|
||||
onTestFinished(() => {
|
||||
storage.close();
|
||||
});
|
||||
|
||||
return storage;
|
||||
}
|
||||
|
||||
export function getDbPath(defaultDbPath?: string) {
|
||||
const dbPath = defaultDbPath ?? join(tmpdir(), `test-${randomUUID()}.db`);
|
||||
|
||||
if (!defaultDbPath) {
|
||||
onTestFinished(() => {
|
||||
unlinkSync(dbPath);
|
||||
});
|
||||
}
|
||||
|
||||
return dbPath;
|
||||
}
|
||||
@@ -1,22 +1,16 @@
|
||||
import { defineConfig } from "vitest/config";
|
||||
import { defineProject } from "vitest/config";
|
||||
|
||||
export default defineConfig({
|
||||
export default defineProject({
|
||||
test: {
|
||||
workspace: [
|
||||
{
|
||||
test: {
|
||||
typecheck: {
|
||||
enabled: true,
|
||||
checker: "tsc",
|
||||
},
|
||||
include: ["src/**/*.test.ts"],
|
||||
name: "unit",
|
||||
},
|
||||
},
|
||||
name: "jazz-tools",
|
||||
typecheck: {
|
||||
enabled: true,
|
||||
checker: "tsc",
|
||||
},
|
||||
projects: [
|
||||
{
|
||||
test: {
|
||||
include: ["src/**/*.test.browser.ts"],
|
||||
name: "browser",
|
||||
browser: {
|
||||
enabled: true,
|
||||
provider: "playwright",
|
||||
@@ -24,6 +18,13 @@ export default defineConfig({
|
||||
screenshotFailures: false,
|
||||
instances: [{ browser: "chromium" }],
|
||||
},
|
||||
name: "browser",
|
||||
},
|
||||
},
|
||||
{
|
||||
test: {
|
||||
include: ["src/**/*.test.{js,ts,svelte}"],
|
||||
name: "unit",
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
1
packages/quint-ui/.gitignore
vendored
Normal file
1
packages/quint-ui/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
next-env.d.ts
|
||||
69
packages/quint-ui/README.md
Normal file
69
packages/quint-ui/README.md
Normal file
@@ -0,0 +1,69 @@
|
||||
# Quint UI
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
pnpm add quint-ui tailwindcss
|
||||
```
|
||||
|
||||
then in your tailwind styles (ie. `styles.css`) add:
|
||||
```css
|
||||
@import "quint-ui/styles.css";
|
||||
@source "../node_modules/quint-ui";
|
||||
```
|
||||
> [!TIP]
|
||||
> There's no need to do
|
||||
> ```css
|
||||
> @import "tailwindcss";
|
||||
> ```
|
||||
> Quint does this for you.
|
||||
|
||||
|
||||
### Usage
|
||||
|
||||
```tsx
|
||||
import { Button } from "quint-ui";
|
||||
|
||||
<Button>Click me</Button>
|
||||
```
|
||||
|
||||
## Development workflow
|
||||
|
||||
### In Quint
|
||||
|
||||
In this directory, run:
|
||||
```sh
|
||||
pnpm dev:docs
|
||||
```
|
||||
This starts a nextjs app you can use to write docs and/or test components.
|
||||
|
||||
### In example apps
|
||||
|
||||
In this directory, run:
|
||||
```sh
|
||||
pnpm dev
|
||||
```
|
||||
This starts typescript in watch mode.
|
||||
|
||||
> [!IMPORTANT]
|
||||
> Make sure quint-ui is installed in the example via
|
||||
> ```json
|
||||
> "dependencies": {
|
||||
> "quint-ui": "workspace:*"
|
||||
> }
|
||||
> ```
|
||||
|
||||
## Building
|
||||
|
||||
### Docs website
|
||||
|
||||
```sh
|
||||
pnpm build:docs
|
||||
```
|
||||
|
||||
### Package
|
||||
|
||||
```sh
|
||||
pnpm build
|
||||
```
|
||||
|
||||
25
packages/quint-ui/app/docs/button/page.tsx
Normal file
25
packages/quint-ui/app/docs/button/page.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
import { Button } from "@/src/components/button";
|
||||
|
||||
export default function ButtonDocsPage() {
|
||||
return (
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold">Button</h1>
|
||||
|
||||
<div className="flex gap-2">
|
||||
<Button intent="primary">Default</Button>
|
||||
<Button intent="primary" variant="outline">
|
||||
Outline
|
||||
</Button>
|
||||
<Button intent="primary" variant="ghost">
|
||||
Ghost
|
||||
</Button>
|
||||
<Button intent="primary" variant="link">
|
||||
Link
|
||||
</Button>
|
||||
<Button intent="primary" variant="inverted">
|
||||
Inverted
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
14
packages/quint-ui/app/docs/page.tsx
Normal file
14
packages/quint-ui/app/docs/page.tsx
Normal file
@@ -0,0 +1,14 @@
|
||||
import Link from "next/link";
|
||||
|
||||
export default function DocsPage() {
|
||||
return (
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold">Components</h1>
|
||||
<ul>
|
||||
<li>
|
||||
<Link href="/docs/button">Button</Link>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
18
packages/quint-ui/app/layout.tsx
Normal file
18
packages/quint-ui/app/layout.tsx
Normal file
@@ -0,0 +1,18 @@
|
||||
import "@/src/globals.css";
|
||||
|
||||
export default function RootLayout({
|
||||
children,
|
||||
}: Readonly<{
|
||||
children: React.ReactNode;
|
||||
}>) {
|
||||
return (
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Quint UI</title>
|
||||
</head>
|
||||
<body>
|
||||
<div className="container mx-auto">{children}</div>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
22
packages/quint-ui/app/page.tsx
Normal file
22
packages/quint-ui/app/page.tsx
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Button } from "@/src/components/button";
|
||||
import { BookIcon } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
<main className="flex flex-col gap-8">
|
||||
<h1 className="text-3xl font-bold tracking-tight">Quint UI</h1>
|
||||
|
||||
{/* Example usage of the button component with an icon and rendered as a nextjs link */}
|
||||
<Button
|
||||
variant="default"
|
||||
intent="primary"
|
||||
size="lg"
|
||||
render={<Link href="/docs" />}
|
||||
>
|
||||
<BookIcon />
|
||||
Read the docs!
|
||||
</Button>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
6
packages/quint-ui/next.config.ts
Normal file
6
packages/quint-ui/next.config.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
/** @type {import('next').NextConfig} */
|
||||
export default {
|
||||
typescript: {
|
||||
ignoreBuildErrors: true,
|
||||
},
|
||||
};
|
||||
44
packages/quint-ui/package.json
Normal file
44
packages/quint-ui/package.json
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"name": "quint-ui",
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".":{
|
||||
"types": "./dist/index.d.ts",
|
||||
"default": "./dist/index.js"
|
||||
},
|
||||
"./styles.css": "./src/globals.css"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "pnpm clean && tsc --project tsconfig.build.json --watch",
|
||||
"dev:website": "next dev --turbopack",
|
||||
"build": "pnpm clean && tsc --project tsconfig.build.json",
|
||||
"build:website": "next build",
|
||||
"clean": "rm -rf ./dist",
|
||||
"start": "next start"
|
||||
},
|
||||
"dependencies": {
|
||||
"@base-ui-components/react": "1.0.0-beta.1",
|
||||
"clsx": "^2.1.1",
|
||||
"tailwind-merge": "^3.3.1",
|
||||
"tailwind-variants": "^1.0.0",
|
||||
"tw-animate-css": "^1.3.5"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": ">=19.0.0",
|
||||
"react-dom": ">=19.0.0",
|
||||
"tailwindcss": ">=4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"next": "15.4.2",
|
||||
"react": "19.1.0",
|
||||
"react-dom": "19.1.0",
|
||||
"@tailwindcss/postcss": "^4.1.11",
|
||||
"@types/node": "^22.16.5",
|
||||
"@types/react": "19.1.8",
|
||||
"@types/react-dom": "19.1.6",
|
||||
"lucide-react": "^0.525.0",
|
||||
"tailwindcss": "^4.1.11",
|
||||
"typescript": "^5.8.3"
|
||||
}
|
||||
}
|
||||
6
packages/quint-ui/postcss.config.mjs
Normal file
6
packages/quint-ui/postcss.config.mjs
Normal file
@@ -0,0 +1,6 @@
|
||||
const config = {
|
||||
plugins: {
|
||||
"@tailwindcss/postcss": {},
|
||||
},
|
||||
};
|
||||
export default config;
|
||||
160
packages/quint-ui/src/components/button.tsx
Normal file
160
packages/quint-ui/src/components/button.tsx
Normal file
@@ -0,0 +1,160 @@
|
||||
import { mergeProps } from "@base-ui-components/react/merge-props";
|
||||
import { useRender } from "@base-ui-components/react/use-render";
|
||||
import { type VariantProps, tv } from "tailwind-variants";
|
||||
|
||||
const button = tv({
|
||||
base: "inline-flex items-center justify-center gap-2 rounded-sm text-center transition-colors w-fit text-nowrap disabled:pointer-events-none disabled:opacity-70 disabled:cursor-not-allowed disabled:pointer-events-none font-medium",
|
||||
variants: {
|
||||
variant: {
|
||||
default:
|
||||
"focus:outline-none focus-visible:ring focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-opacity-10",
|
||||
ghost: "",
|
||||
outline: "shadow-sm border",
|
||||
link: "",
|
||||
inverted: "",
|
||||
},
|
||||
intent: {
|
||||
default: "border-secondary",
|
||||
primary: "border-primary",
|
||||
success: "border-success",
|
||||
danger: "border-danger",
|
||||
},
|
||||
size: {
|
||||
sm: "text-sm py-1 px-2 [&>svg]:size-4",
|
||||
md: "py-1.5 px-3 h-[36px] [&>svg]:size-4",
|
||||
lg: "py-2 px-5 md:px-6 md:py-2.5 [&>svg]:size-5",
|
||||
icon: "p-2 [&>svg]:size-4",
|
||||
},
|
||||
},
|
||||
compoundVariants: [
|
||||
// Default Variants
|
||||
{
|
||||
variant: "default",
|
||||
intent: ["primary", "success", "danger", "default"],
|
||||
className: "bg-gradient-to-t from-7% via-50% to-95%",
|
||||
},
|
||||
{
|
||||
variant: "default",
|
||||
intent: "primary",
|
||||
className: [
|
||||
"text-primary-foreground",
|
||||
"from-primary-dark via-primary to-primary-light",
|
||||
"hover:from-primary-brightLight hover:to-primary-light",
|
||||
"active:from-primary-brightDark active:to-primary-light active:border-primary-transparent ",
|
||||
"focus:ring-primary focus:border-primary-transparent",
|
||||
],
|
||||
},
|
||||
{
|
||||
variant: "default",
|
||||
intent: "success",
|
||||
className: [
|
||||
"text-success-foreground",
|
||||
"from-success-dark via-success to-success-light",
|
||||
"hover:from-success-brightLight hover:to-success-light",
|
||||
"active:from-success-brightDark active:to-success-light",
|
||||
"focus:ring-success",
|
||||
],
|
||||
},
|
||||
{
|
||||
variant: "default",
|
||||
intent: "danger",
|
||||
className: [
|
||||
"text-danger-foreground",
|
||||
"from-danger-dark via-danger to-danger-light",
|
||||
"hover:from-danger-brightLight hover:to-danger-light",
|
||||
"active:from-danger-brightDark active:to-danger-light",
|
||||
"focus:ring-danger",
|
||||
],
|
||||
},
|
||||
// Outline Variants
|
||||
{
|
||||
variant: "outline",
|
||||
intent: "primary",
|
||||
className: [
|
||||
"text-primary",
|
||||
"active:bg-primary/30",
|
||||
"hover:text-primary-light hover:border-primary-light",
|
||||
],
|
||||
},
|
||||
{
|
||||
variant: "outline",
|
||||
intent: "danger",
|
||||
className: [
|
||||
"text-danger",
|
||||
"active:bg-danger/30",
|
||||
"hover:text-danger-light hover:border-danger-light",
|
||||
],
|
||||
},
|
||||
{
|
||||
variant: "outline",
|
||||
intent: "success",
|
||||
className: [
|
||||
"text-success-dark",
|
||||
"active:bg-success/30",
|
||||
"hover:text-success-light hover:border-success-light",
|
||||
],
|
||||
},
|
||||
// Ghost Variants
|
||||
{
|
||||
variant: "ghost",
|
||||
intent: "primary",
|
||||
className: [
|
||||
"text-primary",
|
||||
"hover:bg-primary/10",
|
||||
"active:bg-primary/30",
|
||||
],
|
||||
},
|
||||
{
|
||||
variant: "ghost",
|
||||
intent: "primary",
|
||||
className: [
|
||||
"text-primary",
|
||||
"hover:bg-primary/10",
|
||||
"active:bg-primary/30",
|
||||
],
|
||||
},
|
||||
{
|
||||
variant: "ghost",
|
||||
intent: "danger",
|
||||
className: ["text-danger", "hover:bg-danger/10", "active:bg-danger/30"],
|
||||
},
|
||||
{
|
||||
variant: "ghost",
|
||||
intent: "success",
|
||||
className: [
|
||||
"text-success",
|
||||
"hover:bg-success/10",
|
||||
"active:bg-success/30",
|
||||
],
|
||||
},
|
||||
],
|
||||
defaultVariants: {
|
||||
size: "md",
|
||||
variant: "default",
|
||||
intent: "default",
|
||||
},
|
||||
});
|
||||
|
||||
type ButtonVariants = VariantProps<typeof button>;
|
||||
|
||||
interface ButtonProps
|
||||
extends Omit<useRender.ComponentProps<"button">, keyof ButtonVariants>,
|
||||
ButtonVariants {}
|
||||
|
||||
export function Button({ render = <button />, ...props }: ButtonProps) {
|
||||
const element = useRender({
|
||||
render,
|
||||
props: mergeProps<"button">(
|
||||
{
|
||||
className: button({
|
||||
size: props.size,
|
||||
variant: props.variant,
|
||||
intent: props.intent,
|
||||
}),
|
||||
},
|
||||
props,
|
||||
),
|
||||
});
|
||||
|
||||
return element;
|
||||
}
|
||||
152
packages/quint-ui/src/globals.css
Normal file
152
packages/quint-ui/src/globals.css
Normal file
@@ -0,0 +1,152 @@
|
||||
@import "tailwindcss";
|
||||
@import "tw-animate-css";
|
||||
|
||||
/* Dark mode. If you want to use dark mode, you can add the dark class to the body/head element. */
|
||||
@custom-variant dark (&:is(.dark *));
|
||||
|
||||
@theme inline {
|
||||
--color-primary: var(--primary);
|
||||
--color-primary-foreground: var(--primary-foreground);
|
||||
--color-primary-transparent: var(--primary-transparent);
|
||||
--color-primary-dark: var(--primary-dark);
|
||||
--color-primary-light: var(--primary-light);
|
||||
--color-primary-brightLight: var(--primary-brightLight);
|
||||
--color-primary-brightDark: var(--primary-brightDark);
|
||||
|
||||
--color-alert: var(--alert);
|
||||
--color-alert-foreground: var(--alert-foreground);
|
||||
--color-alert-transparent: var(--alert-transparent);
|
||||
--color-alert-dark: var(--alert-dark);
|
||||
--color-alert-light: var(--alert-light);
|
||||
--color-alert-brightLight: var(--alert-brightLight);
|
||||
--color-alert-brightDark: var(--alert-brightDark);
|
||||
|
||||
--color-success: var(--success);
|
||||
--color-success-foreground: var(--success-foreground);
|
||||
--color-success-transparent: var(--success-transparent);
|
||||
--color-success-dark: var(--success-dark);
|
||||
--color-success-light: var(--success-light);
|
||||
--color-success-brightLight: var(--success-brightLight);
|
||||
--color-success-brightDark: var(--success-brightDark);
|
||||
|
||||
--color-info: var(--info);
|
||||
--color-info-foreground: var(--info-foreground);
|
||||
--color-info-transparent: var(--info-transparent);
|
||||
--color-info-dark: var(--info-dark);
|
||||
--color-info-light: var(--info-light);
|
||||
--color-info-brightLight: var(--info-brightLight);
|
||||
--color-info-brightDark: var(--info-brightDark);
|
||||
|
||||
--color-warning: var(--warning);
|
||||
--color-warning-foreground: var(--warning-foreground);
|
||||
--color-warning-transparent: var(--warning-transparent);
|
||||
--color-warning-light: var(--warning-light);
|
||||
--color-warning-dark: var(--warning-dark);
|
||||
--color-warning-brightLight: var(--warning-brightLight);
|
||||
--color-warning-brightDark: var(--warning-brightDark);
|
||||
|
||||
--color-tip: var(--tip);
|
||||
--color-tip-foreground: var(--tip-foreground);
|
||||
--color-tip-transparent: var(--tip-transparent);
|
||||
--color-tip-dark: var(--tip-dark);
|
||||
--color-tip-light: var(--tip-light);
|
||||
--color-tip-brightLight: var(--tip-brightLight);
|
||||
--color-tip-brightDark: var(--tip-brightDark);
|
||||
|
||||
--color-danger: var(--danger);
|
||||
--color-danger-foreground: var(--danger-foreground);
|
||||
--color-danger-transparent: var(--danger-transparent);
|
||||
--color-danger-dark: var(--danger-dark);
|
||||
--color-danger-light: var(--danger-light);
|
||||
--color-danger-brightLight: var(--danger-brightLight);
|
||||
--color-danger-brightDark: var(--danger-brightDark);
|
||||
}
|
||||
|
||||
:root {
|
||||
--primary: oklch(57.29% 0.235 261.2);
|
||||
--primary-transparent: lch(from var(--color-primary) l c h / 0.1);
|
||||
--primary-dark: lch(
|
||||
from var(--color-primary) calc(l - 10) calc(c - 1) calc(h + 5)
|
||||
);
|
||||
--primary-light: lch(
|
||||
from var(--color-primary) calc(l + 10) calc(c + 1) calc(h - 5)
|
||||
);
|
||||
--primary-brightLight: lch(
|
||||
from var(--color-primary) calc(l - 1) calc(c + 20) calc(h + 5)
|
||||
);
|
||||
--primary-brightDark: lch(
|
||||
from var(--color-primary) calc(l - 6) calc(c + 20) calc(h + 5)
|
||||
);
|
||||
--primary-foreground: oklch(0.985 0.045 264.32);
|
||||
|
||||
--alert: oklch(80.54% 0.169 76.45);
|
||||
--alert-transparent: oklch(0.843 0.222 85.04 / 0.3);
|
||||
--alert-dark: oklch(0.773 0.212 90.04);
|
||||
--alert-light: oklch(0.883 0.232 80.04);
|
||||
--alert-brightLight: oklch(0.833 0.522 100.04);
|
||||
--alert-brightDark: oklch(0.803 0.522 100.04);
|
||||
--alert-foreground: oklch(0.28 0.07 46);
|
||||
|
||||
--success: oklch(70.49% 0.16 150.62);
|
||||
--success-transparent: lch(from var(--color-success) l c h / 0.3);
|
||||
--success-dark: lch(
|
||||
from var(--color-success) calc(l - 7) calc(c - 1) calc(h + 5)
|
||||
);
|
||||
--success-light: lch(
|
||||
from var(--color-success) calc(l + 4) calc(c + 1) calc(h - 5)
|
||||
);
|
||||
--success-brightLight: lch(
|
||||
from var(--color-success) calc(l - 1) calc(c + 20) calc(h + 10)
|
||||
);
|
||||
--success-brightDark: lch(
|
||||
from var(--color-success) calc(l - 6) calc(c + 20) calc(h + 10)
|
||||
);
|
||||
--success-foreground: oklch(0.28 0.07 46);
|
||||
|
||||
--info: oklch(61.13% 0.248 312.2);
|
||||
--info-transparent: oklch(0.514 0.247 291.21 / 0.3);
|
||||
--info-dark: oklch(0.444 0.237 296.21);
|
||||
--info-light: oklch(0.554 0.257 286.21);
|
||||
--info-brightLight: oklch(0.504 0.447 296.21);
|
||||
--info-brightDark: oklch(0.474 0.447 296.21);
|
||||
--info-foreground: oklch(0.28 0.07 46);
|
||||
|
||||
--warning: oklch(68.92% 0.206 39.71);
|
||||
--warning-transparent: oklch(0.661 0.372 75.45 / 0.3);
|
||||
--warning-dark: oklch(0.591 0.362 80.45);
|
||||
--warning-light: oklch(0.701 0.382 70.45);
|
||||
--warning-brightLight: oklch(0.651 0.672 90.45);
|
||||
--warning-brightDark: oklch(0.621 0.672 90.45);
|
||||
--warning-foreground: oklch(0.28 0.07 46);
|
||||
|
||||
--tip: oklch(76.08% 0.122 194.9);
|
||||
--tip-transparent: oklch(0.595 0.317 176.3 / 0.3);
|
||||
--tip-dark: oklch(0.525 0.307 181.3);
|
||||
--tip-light: oklch(0.635 0.327 171.3);
|
||||
--tip-brightLight: oklch(0.585 0.617 186.3);
|
||||
--tip-brightDark: oklch(0.555 0.617 186.3);
|
||||
--tip-foreground: oklch(0.28 0.07 46);
|
||||
|
||||
--danger: oklch(64.11% 0.202 23.95);
|
||||
--danger-transparent: lch(from var(--color-danger) l c h / 0.3);
|
||||
--danger-dark: lch(
|
||||
from var(--color-danger) calc(l - 7) calc(c - 1) calc(h + 5)
|
||||
);
|
||||
--danger-light: lch(
|
||||
from var(--color-danger) calc(l + 4) calc(c + 1) calc(h - 5)
|
||||
);
|
||||
--danger-brightLight: lch(
|
||||
from var(--color-danger) calc(l - 2) calc(c + 20) calc(h + 10)
|
||||
);
|
||||
--danger-brightDark: lch(
|
||||
from var(--color-danger) calc(l - 6) calc(c + 10) calc(h + 10)
|
||||
);
|
||||
--danger-foreground: oklch(0.28 0.07 46);
|
||||
}
|
||||
|
||||
.dark {
|
||||
/*
|
||||
* Dark mode styles.
|
||||
* Here you can override the css variables above for dark mode.
|
||||
*/
|
||||
}
|
||||
5
packages/quint-ui/src/index.ts
Normal file
5
packages/quint-ui/src/index.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
// COMPONENTS
|
||||
export { Button } from "./components/button.js";
|
||||
|
||||
// UTILS
|
||||
export { cn } from "./lib/utils.js";
|
||||
7
packages/quint-ui/src/lib/utils.ts
Normal file
7
packages/quint-ui/src/lib/utils.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import type { ClassValue } from "clsx";
|
||||
import { clsx } from "clsx";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs));
|
||||
}
|
||||
21
packages/quint-ui/tsconfig.build.json
Normal file
21
packages/quint-ui/tsconfig.build.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"declaration": true,
|
||||
"jsx": "react-jsx",
|
||||
"outDir": "./dist"
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
35
packages/quint-ui/tsconfig.json
Normal file
35
packages/quint-ui/tsconfig.json
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2017",
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
"noEmit": true,
|
||||
"esModuleInterop": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "bundler",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"jsx": "preserve",
|
||||
"incremental": true,
|
||||
"plugins": [
|
||||
{
|
||||
"name": "next"
|
||||
}
|
||||
],
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": ["./*"],
|
||||
"react": ["./node_modules/@types/react"]
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
"next-env.d.ts",
|
||||
"**/*.ts",
|
||||
"**/*.tsx",
|
||||
".next/types/**/*.ts",
|
||||
"next.config.mjs"
|
||||
],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
1800
pnpm-lock.yaml
generated
1800
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -8,8 +8,8 @@ catalog:
|
||||
"@biomejs/biome": 1.9.4
|
||||
typescript: 5.6.2
|
||||
vite: 6.3.5
|
||||
vitest: 3.1.3
|
||||
"@vitest/browser": 3.1.3
|
||||
"@vitest/coverage-istanbul": 3.1.3
|
||||
"@vitest/coverage-v8": 3.1.3
|
||||
"@vitest/ui": 3.1.3
|
||||
vitest: 3.2.4
|
||||
"@vitest/browser": 3.2.4
|
||||
"@vitest/coverage-istanbul": 3.2.4
|
||||
"@vitest/coverage-v8": 3.2.4
|
||||
"@vitest/ui": 3.2.4
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
# jazz-react-tailwind-starter
|
||||
|
||||
## 0.0.133
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [6c76ff8]
|
||||
- jazz-tools@0.15.13
|
||||
|
||||
## 0.0.132
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [d1c1b0c]
|
||||
- Updated dependencies [cf4ad72]
|
||||
- jazz-tools@0.15.12
|
||||
|
||||
## 0.0.131
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "jazz-react-passkey-auth-starter",
|
||||
"private": true,
|
||||
"version": "0.0.131",
|
||||
"version": "0.0.133",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
# svelte-passkey-auth
|
||||
|
||||
## 0.0.107
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [6c76ff8]
|
||||
- jazz-tools@0.15.13
|
||||
|
||||
## 0.0.106
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [d1c1b0c]
|
||||
- Updated dependencies [cf4ad72]
|
||||
- jazz-tools@0.15.12
|
||||
|
||||
## 0.0.105
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "svelte-passkey-auth",
|
||||
"version": "0.0.105",
|
||||
"version": "0.0.107",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
|
||||
@@ -33,7 +33,7 @@ describe("Images upload", () => {
|
||||
|
||||
await userEvent.upload(
|
||||
page.getByRole("textbox"),
|
||||
"./fixtures/jazz-icon.png",
|
||||
"./src/fixtures/jazz-icon.png",
|
||||
);
|
||||
|
||||
assert(file);
|
||||
|
||||
8
tests/cloudflare-workers/vitest.config.ts
Normal file
8
tests/cloudflare-workers/vitest.config.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { defineProject } from "vitest/config";
|
||||
|
||||
export default defineProject({
|
||||
test: {
|
||||
name: "cloudflare-workers",
|
||||
testTimeout: 10_000,
|
||||
},
|
||||
});
|
||||
@@ -9,22 +9,6 @@ export default defineConfig({
|
||||
"tests/browser-integration",
|
||||
"tests/cloudflare-workers",
|
||||
],
|
||||
coverage: {
|
||||
enabled: false,
|
||||
provider: "istanbul",
|
||||
include: ["packages/*/src/**/*.ts"],
|
||||
exclude: ["packages/*/src/tests", "packages/jazz-svelte/**"],
|
||||
reporter: ["html"],
|
||||
thresholds: {
|
||||
global: {
|
||||
branches: 80,
|
||||
functions: 80,
|
||||
lines: 80,
|
||||
statements: 80,
|
||||
},
|
||||
},
|
||||
},
|
||||
include: ["packages/*/tests/**/*.test.{js,ts,svelte}"],
|
||||
maxConcurrency: 5,
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user