@korajs/cli 0.4.0 → 0.6.0
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/dist/bin.cjs +1636 -601
- package/dist/bin.cjs.map +1 -1
- package/dist/bin.js +1086 -139
- package/dist/bin.js.map +1 -1
- package/dist/{chunk-MVP5PDT4.js → chunk-EEZNRI5W.js} +51 -6
- package/dist/chunk-EEZNRI5W.js.map +1 -0
- package/dist/{chunk-YGVO4POI.js → chunk-Q2FBCOQD.js} +27 -15
- package/dist/chunk-Q2FBCOQD.js.map +1 -0
- package/dist/{chunk-CMSX76KM.js → chunk-VLTPEATY.js} +172 -99
- package/dist/chunk-VLTPEATY.js.map +1 -0
- package/dist/create.cjs +130 -54
- package/dist/create.cjs.map +1 -1
- package/dist/create.js +2 -2
- package/dist/index.cjs +143 -62
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -6
- package/dist/index.d.ts +8 -6
- package/dist/index.js +2 -2
- package/package.json +9 -3
- package/templates/react-basic/README.md.hbs +10 -1
- package/templates/react-basic/src/App.tsx +112 -126
- package/templates/react-basic/src/index.css +165 -159
- package/templates/react-basic/src/kora-worker.ts +0 -1
- package/templates/react-basic/src/main.tsx +12 -12
- package/templates/react-basic/src/modules/todos/todo.mutations.ts +25 -0
- package/templates/react-basic/src/modules/todos/todo.queries.ts +5 -0
- package/templates/react-basic/src/modules/todos/todo.schema.ts +10 -0
- package/templates/react-basic/src/modules/todos/useTodos.ts +31 -0
- package/templates/react-basic/src/schema.ts +6 -12
- package/templates/react-basic/src/vite-env.d.ts +17 -0
- package/templates/react-basic/{tsconfig.json → tsconfig.json.hbs} +1 -2
- package/templates/react-basic/vite.config.ts +57 -50
- package/templates/react-sync/.env.example +19 -0
- package/templates/react-sync/README.md.hbs +43 -1
- package/templates/react-sync/package.json.hbs +3 -0
- package/templates/react-sync/server.ts +90 -26
- package/templates/react-sync/src/App.tsx +132 -130
- package/templates/react-sync/src/auth.ts +25 -0
- package/templates/react-sync/src/index.css +212 -165
- package/templates/react-sync/src/kora-worker.ts +0 -1
- package/templates/react-sync/src/main.tsx +34 -18
- package/templates/react-sync/src/modules/todos/todo.mutations.ts +25 -0
- package/templates/react-sync/src/modules/todos/todo.queries.ts +5 -0
- package/templates/react-sync/src/modules/todos/todo.schema.ts +10 -0
- package/templates/react-sync/src/modules/todos/useTodos.ts +31 -0
- package/templates/react-sync/src/schema.ts +6 -12
- package/templates/react-sync/src/vite-env.d.ts +17 -0
- package/templates/react-sync/{tsconfig.json → tsconfig.json.hbs} +1 -2
- package/templates/react-sync/vite.config.ts +67 -60
- package/templates/react-tailwind/README.md.hbs +10 -1
- package/templates/react-tailwind/src/App.tsx +186 -197
- package/templates/react-tailwind/src/index.css +3 -3
- package/templates/react-tailwind/src/kora-worker.ts +0 -1
- package/templates/react-tailwind/src/main.tsx +19 -12
- package/templates/react-tailwind/src/modules/todos/todo.mutations.ts +25 -0
- package/templates/react-tailwind/src/modules/todos/todo.queries.ts +5 -0
- package/templates/react-tailwind/src/modules/todos/todo.schema.ts +10 -0
- package/templates/react-tailwind/src/modules/todos/useTodos.ts +31 -0
- package/templates/react-tailwind/src/schema.ts +6 -12
- package/templates/react-tailwind/src/vite-env.d.ts +17 -0
- package/templates/react-tailwind/{tsconfig.json → tsconfig.json.hbs} +1 -2
- package/templates/react-tailwind/vite.config.ts +57 -50
- package/templates/react-tailwind-sync/.env.example +19 -0
- package/templates/react-tailwind-sync/README.md.hbs +43 -1
- package/templates/react-tailwind-sync/package.json.hbs +3 -0
- package/templates/react-tailwind-sync/server.ts +90 -26
- package/templates/react-tailwind-sync/src/App.tsx +246 -222
- package/templates/react-tailwind-sync/src/auth.ts +25 -0
- package/templates/react-tailwind-sync/src/index.css +3 -3
- package/templates/react-tailwind-sync/src/kora-worker.ts +0 -1
- package/templates/react-tailwind-sync/src/main.tsx +48 -18
- package/templates/react-tailwind-sync/src/modules/todos/todo.mutations.ts +25 -0
- package/templates/react-tailwind-sync/src/modules/todos/todo.queries.ts +5 -0
- package/templates/react-tailwind-sync/src/modules/todos/todo.schema.ts +10 -0
- package/templates/react-tailwind-sync/src/modules/todos/useTodos.ts +31 -0
- package/templates/react-tailwind-sync/src/schema.ts +6 -12
- package/templates/react-tailwind-sync/src/vite-env.d.ts +17 -0
- package/templates/react-tailwind-sync/{tsconfig.json → tsconfig.json.hbs} +1 -2
- package/templates/react-tailwind-sync/vite.config.ts +67 -60
- package/templates/svelte-basic/.env.example +3 -0
- package/templates/svelte-basic/README.md.hbs +62 -0
- package/templates/svelte-basic/index.html.hbs +12 -0
- package/templates/svelte-basic/kora.config.ts +12 -0
- package/templates/svelte-basic/package.json.hbs +27 -0
- package/templates/svelte-basic/src/App.svelte +131 -0
- package/templates/svelte-basic/src/Root.svelte +14 -0
- package/templates/svelte-basic/src/index.css +287 -0
- package/templates/svelte-basic/src/kora-worker.ts +9 -0
- package/templates/svelte-basic/src/main.ts +16 -0
- package/templates/svelte-basic/src/modules/todos/todo.mutations.ts +25 -0
- package/templates/svelte-basic/src/modules/todos/todo.queries.ts +5 -0
- package/templates/svelte-basic/src/modules/todos/todo.schema.ts +10 -0
- package/templates/svelte-basic/src/modules/todos/useTodos.ts +25 -0
- package/templates/svelte-basic/src/schema.ts +9 -0
- package/templates/svelte-basic/src/vite-env.d.ts +12 -0
- package/templates/svelte-basic/svelte.config.js +5 -0
- package/templates/svelte-basic/tsconfig.json.hbs +14 -0
- package/templates/svelte-basic/vite.config.ts +52 -0
- package/templates/svelte-sync/.env.example +25 -0
- package/templates/svelte-sync/README.md.hbs +105 -0
- package/templates/svelte-sync/index.html.hbs +12 -0
- package/templates/svelte-sync/kora.config.ts +17 -0
- package/templates/svelte-sync/package.json.hbs +43 -0
- package/templates/svelte-sync/server.ts +90 -0
- package/templates/svelte-sync/src/App.svelte +154 -0
- package/templates/svelte-sync/src/Root.svelte +22 -0
- package/templates/svelte-sync/src/auth.ts +25 -0
- package/templates/svelte-sync/src/index.css +339 -0
- package/templates/svelte-sync/src/kora-worker.ts +9 -0
- package/templates/svelte-sync/src/main.ts +32 -0
- package/templates/svelte-sync/src/modules/todos/todo.mutations.ts +25 -0
- package/templates/svelte-sync/src/modules/todos/todo.queries.ts +5 -0
- package/templates/svelte-sync/src/modules/todos/todo.schema.ts +10 -0
- package/templates/svelte-sync/src/modules/todos/useTodos.ts +25 -0
- package/templates/svelte-sync/src/schema.ts +9 -0
- package/templates/svelte-sync/src/vite-env.d.ts +21 -0
- package/templates/svelte-sync/svelte.config.js +5 -0
- package/templates/svelte-sync/tsconfig.json.hbs +14 -0
- package/templates/svelte-sync/vite.config.ts +79 -0
- package/templates/svelte-tailwind/README.md.hbs +62 -0
- package/templates/svelte-tailwind/index.html.hbs +12 -0
- package/templates/svelte-tailwind/kora.config.ts +12 -0
- package/templates/svelte-tailwind/package.json.hbs +30 -0
- package/templates/svelte-tailwind/src/App.svelte +79 -0
- package/templates/svelte-tailwind/src/Root.svelte +14 -0
- package/templates/svelte-tailwind/src/index.css +7 -0
- package/templates/svelte-tailwind/src/kora-worker.ts +9 -0
- package/templates/svelte-tailwind/src/main.ts +16 -0
- package/templates/svelte-tailwind/src/modules/todos/todo.mutations.ts +25 -0
- package/templates/svelte-tailwind/src/modules/todos/todo.queries.ts +5 -0
- package/templates/svelte-tailwind/src/modules/todos/todo.schema.ts +10 -0
- package/templates/svelte-tailwind/src/modules/todos/useTodos.ts +25 -0
- package/templates/svelte-tailwind/src/schema.ts +9 -0
- package/templates/svelte-tailwind/src/vite-env.d.ts +12 -0
- package/templates/svelte-tailwind/svelte.config.js +5 -0
- package/templates/svelte-tailwind/tsconfig.json.hbs +14 -0
- package/templates/svelte-tailwind/vite.config.ts +53 -0
- package/templates/svelte-tailwind-sync/.env.example +25 -0
- package/templates/svelte-tailwind-sync/README.md.hbs +105 -0
- package/templates/svelte-tailwind-sync/index.html.hbs +12 -0
- package/templates/svelte-tailwind-sync/kora.config.ts +17 -0
- package/templates/svelte-tailwind-sync/package.json.hbs +46 -0
- package/templates/svelte-tailwind-sync/server.ts +90 -0
- package/templates/svelte-tailwind-sync/src/App.svelte +196 -0
- package/templates/svelte-tailwind-sync/src/Root.svelte +26 -0
- package/templates/svelte-tailwind-sync/src/auth.ts +25 -0
- package/templates/svelte-tailwind-sync/src/index.css +7 -0
- package/templates/svelte-tailwind-sync/src/kora-worker.ts +9 -0
- package/templates/svelte-tailwind-sync/src/main.ts +32 -0
- package/templates/svelte-tailwind-sync/src/modules/todos/todo.mutations.ts +25 -0
- package/templates/svelte-tailwind-sync/src/modules/todos/todo.queries.ts +5 -0
- package/templates/svelte-tailwind-sync/src/modules/todos/todo.schema.ts +10 -0
- package/templates/svelte-tailwind-sync/src/modules/todos/useTodos.ts +25 -0
- package/templates/svelte-tailwind-sync/src/schema.ts +9 -0
- package/templates/svelte-tailwind-sync/src/vite-env.d.ts +21 -0
- package/templates/svelte-tailwind-sync/svelte.config.js +5 -0
- package/templates/svelte-tailwind-sync/tsconfig.json.hbs +14 -0
- package/templates/svelte-tailwind-sync/vite.config.ts +80 -0
- package/templates/tauri-react/.env.example +20 -0
- package/templates/tauri-react/README.md.hbs +36 -1
- package/templates/tauri-react/dev.ts +11 -11
- package/templates/tauri-react/package.json.hbs +2 -0
- package/templates/tauri-react/server.ts +86 -12
- package/templates/tauri-react/src/App.tsx +769 -544
- package/templates/tauri-react/src/AppShell.tsx +125 -83
- package/templates/tauri-react/src/SetupScreen.tsx +257 -208
- package/templates/tauri-react/src/auth.ts +45 -0
- package/templates/tauri-react/src/main.tsx +3 -3
- package/templates/tauri-react/src/modules/todos/todo.mutations.ts +25 -0
- package/templates/tauri-react/src/modules/todos/todo.queries.ts +5 -0
- package/templates/tauri-react/src/modules/todos/todo.schema.ts +10 -0
- package/templates/tauri-react/src/modules/todos/useTodos.ts +31 -0
- package/templates/tauri-react/src/schema.ts +6 -12
- package/templates/tauri-react/src/sync-config.ts +47 -47
- package/templates/tauri-react/src/updater.ts +15 -15
- package/templates/tauri-react/src/vite-env.d.ts +17 -0
- package/templates/tauri-react/src-tauri/tauri.conf.json +1 -1
- package/templates/tauri-react/tsconfig.json.hbs +14 -0
- package/templates/tauri-react/vite.config.ts +9 -9
- package/templates/vue-basic/README.md.hbs +62 -0
- package/templates/vue-basic/index.html.hbs +12 -0
- package/templates/vue-basic/kora.config.ts +12 -0
- package/templates/vue-basic/package.json.hbs +26 -0
- package/templates/vue-basic/src/App.vue +117 -0
- package/templates/vue-basic/src/index.css +287 -0
- package/templates/vue-basic/src/kora-worker.ts +9 -0
- package/templates/vue-basic/src/main.ts +20 -0
- package/templates/vue-basic/src/modules/todos/todo.mutations.ts +25 -0
- package/templates/vue-basic/src/modules/todos/todo.queries.ts +5 -0
- package/templates/vue-basic/src/modules/todos/todo.schema.ts +10 -0
- package/templates/vue-basic/src/modules/todos/useTodos.ts +32 -0
- package/templates/vue-basic/src/schema.ts +9 -0
- package/templates/vue-basic/src/vite-env.d.ts +17 -0
- package/templates/vue-basic/tsconfig.json.hbs +15 -0
- package/templates/vue-basic/vite.config.ts +69 -0
- package/templates/vue-sync/.env.example +25 -0
- package/templates/vue-sync/README.md.hbs +105 -0
- package/templates/vue-sync/index.html.hbs +12 -0
- package/templates/vue-sync/kora.config.ts +17 -0
- package/templates/vue-sync/package.json.hbs +42 -0
- package/templates/vue-sync/server.ts +90 -0
- package/templates/vue-sync/src/App.vue +135 -0
- package/templates/vue-sync/src/auth.ts +25 -0
- package/templates/vue-sync/src/index.css +339 -0
- package/templates/vue-sync/src/kora-worker.ts +9 -0
- package/templates/vue-sync/src/main.ts +43 -0
- package/templates/vue-sync/src/modules/todos/todo.mutations.ts +25 -0
- package/templates/vue-sync/src/modules/todos/todo.queries.ts +5 -0
- package/templates/vue-sync/src/modules/todos/todo.schema.ts +10 -0
- package/templates/vue-sync/src/modules/todos/useTodos.ts +32 -0
- package/templates/vue-sync/src/schema.ts +9 -0
- package/templates/vue-sync/src/vite-env.d.ts +26 -0
- package/templates/vue-sync/tsconfig.json.hbs +15 -0
- package/templates/vue-sync/vite.config.ts +79 -0
- package/templates/vue-tailwind/README.md.hbs +62 -0
- package/templates/vue-tailwind/index.html.hbs +12 -0
- package/templates/vue-tailwind/kora.config.ts +12 -0
- package/templates/vue-tailwind/package.json.hbs +29 -0
- package/templates/vue-tailwind/src/App.vue +142 -0
- package/templates/vue-tailwind/src/index.css +7 -0
- package/templates/vue-tailwind/src/kora-worker.ts +9 -0
- package/templates/vue-tailwind/src/main.ts +31 -0
- package/templates/vue-tailwind/src/modules/todos/todo.mutations.ts +25 -0
- package/templates/vue-tailwind/src/modules/todos/todo.queries.ts +5 -0
- package/templates/vue-tailwind/src/modules/todos/todo.schema.ts +10 -0
- package/templates/vue-tailwind/src/modules/todos/useTodos.ts +32 -0
- package/templates/vue-tailwind/src/schema.ts +9 -0
- package/templates/vue-tailwind/src/vite-env.d.ts +17 -0
- package/templates/vue-tailwind/tsconfig.json.hbs +15 -0
- package/templates/vue-tailwind/vite.config.ts +70 -0
- package/templates/vue-tailwind-sync/.env.example +25 -0
- package/templates/vue-tailwind-sync/README.md.hbs +105 -0
- package/templates/vue-tailwind-sync/index.html.hbs +12 -0
- package/templates/vue-tailwind-sync/kora.config.ts +17 -0
- package/templates/vue-tailwind-sync/package.json.hbs +45 -0
- package/templates/vue-tailwind-sync/server.ts +90 -0
- package/templates/vue-tailwind-sync/src/App.vue +245 -0
- package/templates/vue-tailwind-sync/src/auth.ts +25 -0
- package/templates/vue-tailwind-sync/src/index.css +7 -0
- package/templates/vue-tailwind-sync/src/kora-worker.ts +9 -0
- package/templates/vue-tailwind-sync/src/main.ts +56 -0
- package/templates/vue-tailwind-sync/src/modules/todos/todo.mutations.ts +25 -0
- package/templates/vue-tailwind-sync/src/modules/todos/todo.queries.ts +5 -0
- package/templates/vue-tailwind-sync/src/modules/todos/todo.schema.ts +10 -0
- package/templates/vue-tailwind-sync/src/modules/todos/useTodos.ts +32 -0
- package/templates/vue-tailwind-sync/src/schema.ts +9 -0
- package/templates/vue-tailwind-sync/src/vite-env.d.ts +26 -0
- package/templates/vue-tailwind-sync/tsconfig.json.hbs +15 -0
- package/templates/vue-tailwind-sync/vite.config.ts +80 -0
- package/dist/chunk-CMSX76KM.js.map +0 -1
- package/dist/chunk-MVP5PDT4.js.map +0 -1
- package/dist/chunk-YGVO4POI.js.map +0 -1
- package/templates/tauri-react/tsconfig.json +0 -15
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { AlertCircle, ArrowRight, Loader2, Monitor, Wifi } from 'lucide-react'
|
|
1
2
|
import { useState } from 'react'
|
|
2
|
-
import { Monitor, Wifi, ArrowRight, Loader2, AlertCircle } from 'lucide-react'
|
|
3
3
|
import { testConnection } from './sync-config'
|
|
4
4
|
|
|
5
5
|
interface SetupScreenProps {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
onConnect: (syncUrl: string) => void
|
|
7
|
+
onSkip: () => void
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -18,222 +18,271 @@ interface SetupScreenProps {
|
|
|
18
18
|
* connect when the server comes back.
|
|
19
19
|
*/
|
|
20
20
|
export function SetupScreen({ onConnect, onSkip }: SetupScreenProps) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
const [url, setUrl] = useState('')
|
|
22
|
+
const [testing, setTesting] = useState(false)
|
|
23
|
+
const [error, setError] = useState<string | null>(null)
|
|
24
|
+
const [unreachable, setUnreachable] = useState(false)
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
const validateUrl = (value: string): string | null => {
|
|
27
|
+
if (!value.startsWith('ws://') && !value.startsWith('wss://')) {
|
|
28
|
+
return 'URL must start with ws:// or wss://'
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
new URL(value.replace(/^ws/, 'http'))
|
|
32
|
+
} catch {
|
|
33
|
+
return 'Invalid URL format'
|
|
34
|
+
}
|
|
35
|
+
return null
|
|
36
|
+
}
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
const handleSubmit = async (e: React.FormEvent) => {
|
|
39
|
+
e.preventDefault()
|
|
40
|
+
const syncUrl = url.trim()
|
|
41
|
+
if (!syncUrl) return
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
const validationError = validateUrl(syncUrl)
|
|
44
|
+
if (validationError) {
|
|
45
|
+
setError(validationError)
|
|
46
|
+
return
|
|
47
|
+
}
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
setTesting(true)
|
|
50
|
+
setError(null)
|
|
51
|
+
setUnreachable(false)
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
const reachable = await testConnection(syncUrl)
|
|
54
|
+
setTesting(false)
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
56
|
+
if (reachable) {
|
|
57
|
+
onConnect(syncUrl)
|
|
58
|
+
} else {
|
|
59
|
+
// Server unreachable — let the user save anyway
|
|
60
|
+
setUnreachable(true)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
const handleSaveAnyway = () => {
|
|
65
|
+
onConnect(url.trim())
|
|
66
|
+
}
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
68
|
+
return (
|
|
69
|
+
<div
|
|
70
|
+
style={{
|
|
71
|
+
minHeight: '100vh',
|
|
72
|
+
background: '#0a0a0a',
|
|
73
|
+
color: '#f3f4f6',
|
|
74
|
+
display: 'flex',
|
|
75
|
+
alignItems: 'center',
|
|
76
|
+
justifyContent: 'center',
|
|
77
|
+
}}
|
|
78
|
+
>
|
|
79
|
+
<div style={{ maxWidth: '480px', width: '100%', padding: '0 24px' }}>
|
|
80
|
+
{/* Logo */}
|
|
81
|
+
<div style={{ textAlign: 'center', marginBottom: '48px' }}>
|
|
82
|
+
<Monitor
|
|
83
|
+
style={{ width: '48px', height: '48px', color: '#818cf8', margin: '0 auto 16px' }}
|
|
84
|
+
/>
|
|
85
|
+
<h1 style={{ fontSize: '28px', fontWeight: 'bold', marginBottom: '8px' }}>Welcome</h1>
|
|
86
|
+
<p style={{ color: '#6b7280', fontSize: '15px' }}>
|
|
87
|
+
Connect to your organization's sync server to sync data across devices.
|
|
88
|
+
</p>
|
|
89
|
+
</div>
|
|
79
90
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
91
|
+
{/* Connection form */}
|
|
92
|
+
<form onSubmit={handleSubmit}>
|
|
93
|
+
<div style={{ marginBottom: '16px' }}>
|
|
94
|
+
<label
|
|
95
|
+
htmlFor="sync-server-url"
|
|
96
|
+
style={{
|
|
97
|
+
display: 'block',
|
|
98
|
+
fontSize: '14px',
|
|
99
|
+
fontWeight: '500',
|
|
100
|
+
marginBottom: '8px',
|
|
101
|
+
color: '#d1d5db',
|
|
102
|
+
}}
|
|
103
|
+
>
|
|
104
|
+
Sync server URL
|
|
105
|
+
</label>
|
|
106
|
+
<div style={{ position: 'relative' }}>
|
|
107
|
+
<Wifi
|
|
108
|
+
style={{
|
|
109
|
+
position: 'absolute',
|
|
110
|
+
left: '12px',
|
|
111
|
+
top: '50%',
|
|
112
|
+
transform: 'translateY(-50%)',
|
|
113
|
+
width: '18px',
|
|
114
|
+
height: '18px',
|
|
115
|
+
color: '#6b7280',
|
|
116
|
+
}}
|
|
117
|
+
/>
|
|
118
|
+
<input
|
|
119
|
+
id="sync-server-url"
|
|
120
|
+
type="text"
|
|
121
|
+
value={url}
|
|
122
|
+
onChange={(e) => {
|
|
123
|
+
setUrl(e.target.value)
|
|
124
|
+
setError(null)
|
|
125
|
+
setUnreachable(false)
|
|
126
|
+
}}
|
|
127
|
+
placeholder="wss://your-server.example.com/kora-sync"
|
|
128
|
+
style={{
|
|
129
|
+
width: '100%',
|
|
130
|
+
borderRadius: '8px',
|
|
131
|
+
border: `1px solid ${error ? '#ef4444' : '#374151'}`,
|
|
132
|
+
background: '#111827',
|
|
133
|
+
padding: '12px 16px 12px 40px',
|
|
134
|
+
color: '#f3f4f6',
|
|
135
|
+
outline: 'none',
|
|
136
|
+
fontSize: '14px',
|
|
137
|
+
boxSizing: 'border-box',
|
|
138
|
+
}}
|
|
139
|
+
/>
|
|
140
|
+
</div>
|
|
141
|
+
{error && (
|
|
142
|
+
<p style={{ color: '#ef4444', fontSize: '13px', marginTop: '8px' }}>{error}</p>
|
|
143
|
+
)}
|
|
144
|
+
</div>
|
|
111
145
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
146
|
+
{/* Server unreachable — offer to save anyway */}
|
|
147
|
+
{unreachable && (
|
|
148
|
+
<div
|
|
149
|
+
style={{
|
|
150
|
+
marginBottom: '16px',
|
|
151
|
+
padding: '12px 16px',
|
|
152
|
+
borderRadius: '8px',
|
|
153
|
+
border: '1px solid #92400e',
|
|
154
|
+
background: '#451a03',
|
|
155
|
+
}}
|
|
156
|
+
>
|
|
157
|
+
<div style={{ display: 'flex', gap: '8px', alignItems: 'flex-start' }}>
|
|
158
|
+
<AlertCircle
|
|
159
|
+
style={{
|
|
160
|
+
width: '16px',
|
|
161
|
+
height: '16px',
|
|
162
|
+
color: '#fbbf24',
|
|
163
|
+
flexShrink: 0,
|
|
164
|
+
marginTop: '2px',
|
|
165
|
+
}}
|
|
166
|
+
/>
|
|
167
|
+
<div>
|
|
168
|
+
<p style={{ fontSize: '13px', color: '#fde68a', marginBottom: '8px' }}>
|
|
169
|
+
Server is not reachable right now. This could be temporary (maintenance, network
|
|
170
|
+
issues).
|
|
171
|
+
</p>
|
|
172
|
+
<div style={{ display: 'flex', gap: '8px' }}>
|
|
173
|
+
<button
|
|
174
|
+
type="button"
|
|
175
|
+
onClick={handleSaveAnyway}
|
|
176
|
+
style={{
|
|
177
|
+
fontSize: '13px',
|
|
178
|
+
color: '#fbbf24',
|
|
179
|
+
background: 'none',
|
|
180
|
+
border: '1px solid #92400e',
|
|
181
|
+
borderRadius: '6px',
|
|
182
|
+
padding: '4px 12px',
|
|
183
|
+
cursor: 'pointer',
|
|
184
|
+
}}
|
|
185
|
+
>
|
|
186
|
+
Save anyway — connect later
|
|
187
|
+
</button>
|
|
188
|
+
<button
|
|
189
|
+
type="submit"
|
|
190
|
+
style={{
|
|
191
|
+
fontSize: '13px',
|
|
192
|
+
color: '#9ca3af',
|
|
193
|
+
background: 'none',
|
|
194
|
+
border: '1px solid #374151',
|
|
195
|
+
borderRadius: '6px',
|
|
196
|
+
padding: '4px 12px',
|
|
197
|
+
cursor: 'pointer',
|
|
198
|
+
}}
|
|
199
|
+
>
|
|
200
|
+
Retry
|
|
201
|
+
</button>
|
|
202
|
+
</div>
|
|
203
|
+
</div>
|
|
204
|
+
</div>
|
|
205
|
+
</div>
|
|
206
|
+
)}
|
|
162
207
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
208
|
+
{!unreachable && (
|
|
209
|
+
<button
|
|
210
|
+
type="submit"
|
|
211
|
+
disabled={testing || !url.trim()}
|
|
212
|
+
style={{
|
|
213
|
+
width: '100%',
|
|
214
|
+
display: 'flex',
|
|
215
|
+
alignItems: 'center',
|
|
216
|
+
justifyContent: 'center',
|
|
217
|
+
gap: '8px',
|
|
218
|
+
borderRadius: '8px',
|
|
219
|
+
background: '#4f46e5',
|
|
220
|
+
padding: '12px 20px',
|
|
221
|
+
fontWeight: '500',
|
|
222
|
+
color: 'white',
|
|
223
|
+
border: 'none',
|
|
224
|
+
cursor: testing || !url.trim() ? 'default' : 'pointer',
|
|
225
|
+
opacity: testing || !url.trim() ? 0.5 : 1,
|
|
226
|
+
fontSize: '14px',
|
|
227
|
+
marginBottom: '12px',
|
|
228
|
+
}}
|
|
229
|
+
>
|
|
230
|
+
{testing ? (
|
|
231
|
+
<>
|
|
232
|
+
<Loader2
|
|
233
|
+
style={{ width: '16px', height: '16px', animation: 'spin 1s linear infinite' }}
|
|
234
|
+
/>
|
|
235
|
+
Testing connection...
|
|
236
|
+
</>
|
|
237
|
+
) : (
|
|
238
|
+
<>
|
|
239
|
+
Connect
|
|
240
|
+
<ArrowRight style={{ width: '16px', height: '16px' }} />
|
|
241
|
+
</>
|
|
242
|
+
)}
|
|
243
|
+
</button>
|
|
244
|
+
)}
|
|
245
|
+
</form>
|
|
199
246
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
247
|
+
{/* Skip option */}
|
|
248
|
+
<div style={{ textAlign: 'center', marginTop: '24px' }}>
|
|
249
|
+
<button
|
|
250
|
+
onClick={onSkip}
|
|
251
|
+
style={{
|
|
252
|
+
background: 'none',
|
|
253
|
+
border: 'none',
|
|
254
|
+
color: '#6b7280',
|
|
255
|
+
cursor: 'pointer',
|
|
256
|
+
fontSize: '14px',
|
|
257
|
+
textDecoration: 'underline',
|
|
258
|
+
textUnderlineOffset: '3px',
|
|
259
|
+
}}
|
|
260
|
+
>
|
|
261
|
+
Skip — use offline only
|
|
262
|
+
</button>
|
|
263
|
+
<p style={{ color: '#374151', fontSize: '12px', marginTop: '8px' }}>
|
|
264
|
+
You can connect to a sync server later from settings.
|
|
265
|
+
</p>
|
|
266
|
+
</div>
|
|
220
267
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
268
|
+
{/* Help text */}
|
|
269
|
+
<div
|
|
270
|
+
style={{
|
|
271
|
+
marginTop: '48px',
|
|
272
|
+
padding: '16px',
|
|
273
|
+
borderRadius: '8px',
|
|
274
|
+
border: '1px solid #1f2937',
|
|
275
|
+
background: '#111827',
|
|
276
|
+
}}
|
|
277
|
+
>
|
|
278
|
+
<p style={{ fontSize: '13px', color: '#9ca3af', lineHeight: '1.6' }}>
|
|
279
|
+
<strong style={{ color: '#d1d5db' }}>Don't have a server URL?</strong>
|
|
280
|
+
<br />
|
|
281
|
+
Ask your administrator for the sync server address. For local development, use{' '}
|
|
282
|
+
<code style={{ color: '#818cf8' }}>ws://localhost:3001/kora-sync</code>.
|
|
283
|
+
</p>
|
|
284
|
+
</div>
|
|
285
|
+
</div>
|
|
286
|
+
</div>
|
|
287
|
+
)
|
|
239
288
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type AuthClient, createKoraAuth } from '@korajs/auth'
|
|
2
|
+
|
|
3
|
+
export function createDesktopAuthClient(syncUrl: string | null): AuthClient {
|
|
4
|
+
return createKoraAuth({
|
|
5
|
+
serverUrl: getAuthServerUrl(syncUrl),
|
|
6
|
+
})
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function getAuthServerUrl(syncUrl: string | null): string {
|
|
10
|
+
if (import.meta.env.VITE_AUTH_URL) {
|
|
11
|
+
return import.meta.env.VITE_AUTH_URL
|
|
12
|
+
}
|
|
13
|
+
if (!syncUrl) {
|
|
14
|
+
return 'http://localhost:3001'
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const url = new URL(syncUrl)
|
|
18
|
+
url.protocol = url.protocol === 'wss:' ? 'https:' : 'http:'
|
|
19
|
+
url.pathname = url.pathname.replace(/\/kora-sync\/?$/, '') || '/'
|
|
20
|
+
url.search = ''
|
|
21
|
+
url.hash = ''
|
|
22
|
+
return url.toString().replace(/\/+$/, '')
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export async function openOAuthSignIn(authClient: AuthClient, provider = 'google'): Promise<void> {
|
|
26
|
+
const { url } = await authClient.getOAuthAuthorizationUrl(provider)
|
|
27
|
+
window.open(url, '_blank', 'noopener,noreferrer')
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export async function completeOAuthCallbackFromLocation(authClient: AuthClient): Promise<void> {
|
|
31
|
+
const url = new URL(window.location.href)
|
|
32
|
+
const code = url.searchParams.get('code')
|
|
33
|
+
const state = url.searchParams.get('state')
|
|
34
|
+
const provider = url.searchParams.get('provider') || 'google'
|
|
35
|
+
|
|
36
|
+
if (!code || !state) {
|
|
37
|
+
return
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
await authClient.completeOAuthSignIn(provider, { code, state })
|
|
41
|
+
url.searchParams.delete('code')
|
|
42
|
+
url.searchParams.delete('state')
|
|
43
|
+
url.searchParams.delete('provider')
|
|
44
|
+
window.history.replaceState({}, document.title, `${url.pathname}${url.search}${url.hash}`)
|
|
45
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { CollectionAccessor } from 'korajs'
|
|
2
|
+
|
|
3
|
+
export interface CreateTodoInput {
|
|
4
|
+
title: string
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface UpdateTodoStatusInput {
|
|
8
|
+
completed: boolean
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function createTodo(todos: CollectionAccessor, data: CreateTodoInput) {
|
|
12
|
+
return todos.insert({ title: data.title })
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function updateTodoStatus(
|
|
16
|
+
todos: CollectionAccessor,
|
|
17
|
+
id: string,
|
|
18
|
+
data: UpdateTodoStatusInput,
|
|
19
|
+
) {
|
|
20
|
+
return todos.update(id, { completed: data.completed })
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function deleteTodo(todos: CollectionAccessor, id: string) {
|
|
24
|
+
return todos.delete(id)
|
|
25
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useCollection, useMutation, useQuery } from '@korajs/react'
|
|
2
|
+
import {
|
|
3
|
+
type CreateTodoInput,
|
|
4
|
+
type UpdateTodoStatusInput,
|
|
5
|
+
createTodo,
|
|
6
|
+
deleteTodo,
|
|
7
|
+
updateTodoStatus,
|
|
8
|
+
} from './todo.mutations'
|
|
9
|
+
import { orderedTodos } from './todo.queries'
|
|
10
|
+
|
|
11
|
+
export function useTodos() {
|
|
12
|
+
const todos = useCollection('todos')
|
|
13
|
+
const allTodos = useQuery(orderedTodos(todos))
|
|
14
|
+
const addTodo = useMutation((data: CreateTodoInput) => createTodo(todos, data))
|
|
15
|
+
const toggleTodo = useMutation((id: string, data: UpdateTodoStatusInput) =>
|
|
16
|
+
updateTodoStatus(todos, id, data),
|
|
17
|
+
)
|
|
18
|
+
const removeTodo = useMutation((id: string) => deleteTodo(todos, id))
|
|
19
|
+
|
|
20
|
+
const activeTodos = allTodos.filter((todo) => !todo.completed)
|
|
21
|
+
const completedTodos = allTodos.filter((todo) => !!todo.completed)
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
allTodos,
|
|
25
|
+
activeTodos,
|
|
26
|
+
completedTodos,
|
|
27
|
+
addTodo,
|
|
28
|
+
toggleTodo,
|
|
29
|
+
deleteTodo: removeTodo,
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
import { defineSchema
|
|
1
|
+
import { defineSchema } from '@korajs/core'
|
|
2
|
+
import { todos } from './modules/todos/todo.schema'
|
|
2
3
|
|
|
3
4
|
export default defineSchema({
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
title: t.string(),
|
|
9
|
-
completed: t.boolean().default(false),
|
|
10
|
-
createdAt: t.timestamp().auto(),
|
|
11
|
-
},
|
|
12
|
-
indexes: ['completed'],
|
|
13
|
-
},
|
|
14
|
-
},
|
|
5
|
+
version: 1,
|
|
6
|
+
collections: {
|
|
7
|
+
todos,
|
|
8
|
+
},
|
|
15
9
|
})
|