korajs 0.1.0 → 0.1.2
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 +80 -0
- package/package.json +6 -6
package/README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# korajs
|
|
2
|
+
|
|
3
|
+
Offline-first application framework. Local-first storage, reactive queries, automatic conflict resolution, and real-time sync -- with zero distributed systems code.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add korajs
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { createApp, defineSchema, t } from 'korajs'
|
|
15
|
+
|
|
16
|
+
const app = createApp({
|
|
17
|
+
schema: defineSchema({
|
|
18
|
+
version: 1,
|
|
19
|
+
collections: {
|
|
20
|
+
todos: {
|
|
21
|
+
fields: {
|
|
22
|
+
title: t.string(),
|
|
23
|
+
completed: t.boolean().default(false),
|
|
24
|
+
createdAt: t.timestamp().auto(),
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
}),
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
const todo = await app.todos.insert({ title: 'Ship Kora v1' })
|
|
32
|
+
const active = await app.todos.where({ completed: false }).orderBy('createdAt').exec()
|
|
33
|
+
await app.todos.update(todo.id, { completed: true })
|
|
34
|
+
app.todos.where({ completed: false }).subscribe((todos) => console.log(todos))
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Enable Sync
|
|
38
|
+
|
|
39
|
+
Add one line to sync across devices:
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
const app = createApp({
|
|
43
|
+
schema,
|
|
44
|
+
sync: { url: 'wss://my-server.com/kora' },
|
|
45
|
+
})
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Conflicts are resolved automatically. No distributed systems code required.
|
|
49
|
+
|
|
50
|
+
## React Integration
|
|
51
|
+
|
|
52
|
+
Install `@korajs/react` alongside this package (`pnpm add @korajs/react`):
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
import { KoraProvider, useQuery, useMutation } from '@korajs/react'
|
|
56
|
+
|
|
57
|
+
function App() {
|
|
58
|
+
return (
|
|
59
|
+
<KoraProvider app={app}>
|
|
60
|
+
<TodoList />
|
|
61
|
+
</KoraProvider>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function TodoList() {
|
|
66
|
+
const todos = useQuery(app.todos.where({ completed: false }))
|
|
67
|
+
const addTodo = useMutation(app.todos.insert)
|
|
68
|
+
return todos.map((todo) => <div key={todo.id}>{todo.title}</div>)
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Packages
|
|
73
|
+
|
|
74
|
+
`@korajs/core` | `@korajs/store` | `@korajs/merge` | `@korajs/sync` | `@korajs/server` | `@korajs/react` | `@korajs/devtools` | `@korajs/cli`
|
|
75
|
+
|
|
76
|
+
## License
|
|
77
|
+
|
|
78
|
+
MIT
|
|
79
|
+
|
|
80
|
+
See the [full documentation](https://github.com/ehoneahobed/kora) for guides, API reference, and examples.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "korajs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Kora.js — offline-first application framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
"dist"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@korajs/
|
|
36
|
-
"@korajs/
|
|
37
|
-
"@korajs/
|
|
38
|
-
"@korajs/
|
|
39
|
-
"@korajs/
|
|
35
|
+
"@korajs/core": "0.1.2",
|
|
36
|
+
"@korajs/store": "0.1.2",
|
|
37
|
+
"@korajs/devtools": "0.1.2",
|
|
38
|
+
"@korajs/sync": "0.1.2",
|
|
39
|
+
"@korajs/merge": "0.1.2"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/better-sqlite3": "^7.6.13",
|