korajs 1.0.0-beta.12 → 1.0.0-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -22
- package/dist/{chunk-3WMSWJAQ.js → chunk-JLKS237Z.js} +456 -215
- package/dist/chunk-JLKS237Z.js.map +1 -0
- package/dist/index.cjs +1227 -378
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +426 -35
- package/dist/index.d.ts +426 -35
- package/dist/index.js +712 -99
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +4 -0
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +4 -0
- package/dist/react.js.map +1 -1
- package/dist/svelte.cjs +4 -0
- package/dist/svelte.cjs.map +1 -1
- package/dist/svelte.d.cts +1 -1
- package/dist/svelte.d.ts +1 -1
- package/dist/svelte.js +4 -0
- package/dist/svelte.js.map +1 -1
- package/dist/testing.cjs +448 -210
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +125 -56
- package/dist/testing.d.ts +125 -56
- package/dist/testing.js +1 -1
- package/dist/vue.cjs +2 -0
- package/dist/vue.cjs.map +1 -1
- package/dist/vue.d.cts +1 -1
- package/dist/vue.d.ts +1 -1
- package/dist/vue.js +2 -0
- package/dist/vue.js.map +1 -1
- package/package.json +13 -13
- package/dist/chunk-3WMSWJAQ.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# korajs
|
|
2
2
|
|
|
3
|
-
Offline-first application framework
|
|
3
|
+
Offline-first application framework: local storage, reactive queries, automatic conflict resolution and real-time sync, with zero distributed-systems code.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
pnpm add korajs
|
|
8
|
+
pnpm add korajs@beta
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Quick Start
|
|
@@ -13,21 +13,22 @@ pnpm add korajs
|
|
|
13
13
|
```typescript
|
|
14
14
|
import { createApp, defineSchema, t } from 'korajs'
|
|
15
15
|
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
createdAt: t.timestamp().auto(),
|
|
25
|
-
},
|
|
16
|
+
const schema = defineSchema({
|
|
17
|
+
version: 1,
|
|
18
|
+
collections: {
|
|
19
|
+
todos: {
|
|
20
|
+
fields: {
|
|
21
|
+
title: t.string(),
|
|
22
|
+
completed: t.boolean().default(false),
|
|
23
|
+
createdAt: t.timestamp().auto(),
|
|
26
24
|
},
|
|
27
25
|
},
|
|
28
|
-
}
|
|
26
|
+
},
|
|
29
27
|
})
|
|
30
28
|
|
|
29
|
+
const app = createApp({ schema })
|
|
30
|
+
await app.ready
|
|
31
|
+
|
|
31
32
|
const todo = await app.todos.insert({ title: 'Ship Kora v1' })
|
|
32
33
|
const active = await app.todos.where({ completed: false }).orderBy('createdAt').exec()
|
|
33
34
|
await app.todos.update(todo.id, { completed: true })
|
|
@@ -36,20 +37,22 @@ app.todos.where({ completed: false }).subscribe((todos) => console.log(todos))
|
|
|
36
37
|
|
|
37
38
|
## Enable Sync
|
|
38
39
|
|
|
39
|
-
|
|
40
|
+
Point the app at a [Kora sync server](https://korajs.dev/guide/production-server):
|
|
40
41
|
|
|
42
|
+
<!-- docs-check: continue -->
|
|
41
43
|
```typescript
|
|
42
|
-
const
|
|
44
|
+
const syncedApp = createApp({
|
|
43
45
|
schema,
|
|
44
|
-
sync: { url: 'wss://
|
|
46
|
+
sync: { url: 'wss://sync.example.com/kora-sync', autoConnect: true },
|
|
45
47
|
})
|
|
46
48
|
```
|
|
47
49
|
|
|
48
|
-
|
|
50
|
+
Writes still land locally first and upload when a connection exists; concurrent edits merge per
|
|
51
|
+
field the same way on every device.
|
|
49
52
|
|
|
50
53
|
## React Integration
|
|
51
54
|
|
|
52
|
-
Install `@korajs/react
|
|
55
|
+
Install `@korajs/react@beta`, then import from it or from `korajs/react`:
|
|
53
56
|
|
|
54
57
|
```tsx
|
|
55
58
|
import { KoraProvider, useQuery, useMutation } from 'korajs/react'
|
|
@@ -61,7 +64,7 @@ import { KoraProvider, useQuery, useMutation } from 'korajs/react'
|
|
|
61
64
|
import { KoraProvider, useQuery, useMutation } from 'korajs/vue'
|
|
62
65
|
```
|
|
63
66
|
|
|
64
|
-
Requires `vue` and `@korajs/vue`
|
|
67
|
+
Requires `vue` and `@korajs/vue` (peer dependencies).
|
|
65
68
|
|
|
66
69
|
## Svelte Integration
|
|
67
70
|
|
|
@@ -70,14 +73,14 @@ import { createQueryStore, useQuery, useMutation } from 'korajs/svelte'
|
|
|
70
73
|
import KoraProvider from '@korajs/svelte/KoraProvider.svelte'
|
|
71
74
|
```
|
|
72
75
|
|
|
73
|
-
Requires `svelte` and `@korajs/svelte`
|
|
76
|
+
Requires `svelte` and `@korajs/svelte` (peer dependencies). Wrap your app with `<KoraProvider app={kora}>` (see the `@korajs/svelte` README).
|
|
74
77
|
|
|
75
78
|
## Packages
|
|
76
79
|
|
|
77
|
-
`@korajs/core` | `@korajs/store` | `@korajs/merge` | `@korajs/sync` | `@korajs/server` | `@korajs/react` | `@korajs/vue` | `@korajs/svelte` | `@korajs/devtools` | `@korajs/cli`
|
|
80
|
+
`@korajs/core` | `@korajs/store` | `@korajs/merge` | `@korajs/sync` | `@korajs/server` | `@korajs/auth` | `@korajs/react` | `@korajs/vue` | `@korajs/svelte` | `@korajs/tauri` | `@korajs/devtools` | `@korajs/cli` | `@korajs/test` | `create-kora-app`
|
|
78
81
|
|
|
79
82
|
## License
|
|
80
83
|
|
|
81
84
|
MIT
|
|
82
85
|
|
|
83
|
-
|
|
86
|
+
Documentation: [korajs.dev](https://korajs.dev).
|