@korajs/cli 1.0.0-beta.1 → 1.0.0-beta.10

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.
Files changed (74) hide show
  1. package/dist/bin.cjs +593 -290
  2. package/dist/bin.cjs.map +1 -1
  3. package/dist/bin.js +122 -35
  4. package/dist/bin.js.map +1 -1
  5. package/dist/{chunk-EOWLAAIV.js → chunk-4IKCHRJ6.js} +273 -57
  6. package/dist/chunk-4IKCHRJ6.js.map +1 -0
  7. package/dist/{chunk-B5YS4STN.js → chunk-G2PBYMMA.js} +2 -2
  8. package/dist/{chunk-B5YS4STN.js.map → chunk-G2PBYMMA.js.map} +1 -1
  9. package/dist/{chunk-BWTKRKNJ.js → chunk-Z7GCXMGW.js} +9 -5
  10. package/dist/chunk-Z7GCXMGW.js.map +1 -0
  11. package/dist/create.cjs +8 -4
  12. package/dist/create.cjs.map +1 -1
  13. package/dist/create.js +2 -2
  14. package/dist/index.cjs +389 -166
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.d.cts +58 -1
  17. package/dist/index.d.ts +58 -1
  18. package/dist/index.js +12 -2
  19. package/package.json +8 -8
  20. package/templates/react-basic/README.md.hbs +1 -1
  21. package/templates/react-basic/src/main.tsx +1 -1
  22. package/templates/react-basic/src/vite-env.d.ts +1 -0
  23. package/templates/react-basic/vite.config.ts +7 -4
  24. package/templates/react-sync/README.md.hbs +6 -5
  25. package/templates/react-sync/server.ts +46 -3
  26. package/templates/react-sync/src/main.tsx +1 -1
  27. package/templates/react-sync/src/vite-env.d.ts +1 -0
  28. package/templates/react-sync/vite.config.ts +14 -4
  29. package/templates/react-tailwind/README.md.hbs +1 -1
  30. package/templates/react-tailwind/src/main.tsx +1 -1
  31. package/templates/react-tailwind/src/vite-env.d.ts +1 -0
  32. package/templates/react-tailwind/vite.config.ts +7 -4
  33. package/templates/react-tailwind-sync/README.md.hbs +6 -5
  34. package/templates/react-tailwind-sync/server.ts +46 -3
  35. package/templates/react-tailwind-sync/src/main.tsx +1 -1
  36. package/templates/react-tailwind-sync/src/vite-env.d.ts +1 -0
  37. package/templates/react-tailwind-sync/vite.config.ts +14 -4
  38. package/templates/svelte-basic/README.md.hbs +1 -1
  39. package/templates/svelte-basic/src/main.ts +1 -1
  40. package/templates/svelte-basic/vite.config.ts +4 -2
  41. package/templates/svelte-sync/README.md.hbs +6 -5
  42. package/templates/svelte-sync/server.ts +46 -3
  43. package/templates/svelte-sync/src/main.ts +1 -1
  44. package/templates/svelte-sync/src/vite-env.d.ts +1 -0
  45. package/templates/svelte-sync/vite.config.ts +11 -2
  46. package/templates/svelte-tailwind/README.md.hbs +1 -1
  47. package/templates/svelte-tailwind/src/main.ts +1 -1
  48. package/templates/svelte-tailwind/vite.config.ts +4 -2
  49. package/templates/svelte-tailwind-sync/README.md.hbs +6 -5
  50. package/templates/svelte-tailwind-sync/server.ts +46 -3
  51. package/templates/svelte-tailwind-sync/src/main.ts +1 -1
  52. package/templates/svelte-tailwind-sync/src/vite-env.d.ts +1 -0
  53. package/templates/svelte-tailwind-sync/vite.config.ts +11 -2
  54. package/templates/tauri-react/server.ts +44 -1
  55. package/templates/tauri-react/src/AppShell.tsx +1 -1
  56. package/templates/tauri-react/src/vite-env.d.ts +1 -0
  57. package/templates/vue-basic/README.md.hbs +1 -1
  58. package/templates/vue-basic/src/main.ts +1 -1
  59. package/templates/vue-basic/vite.config.ts +4 -2
  60. package/templates/vue-sync/README.md.hbs +6 -5
  61. package/templates/vue-sync/server.ts +46 -3
  62. package/templates/vue-sync/src/main.ts +1 -1
  63. package/templates/vue-sync/src/vite-env.d.ts +1 -0
  64. package/templates/vue-sync/vite.config.ts +11 -2
  65. package/templates/vue-tailwind/README.md.hbs +1 -1
  66. package/templates/vue-tailwind/src/main.ts +1 -1
  67. package/templates/vue-tailwind/vite.config.ts +4 -2
  68. package/templates/vue-tailwind-sync/README.md.hbs +6 -5
  69. package/templates/vue-tailwind-sync/server.ts +46 -3
  70. package/templates/vue-tailwind-sync/src/main.ts +1 -1
  71. package/templates/vue-tailwind-sync/src/vite-env.d.ts +1 -0
  72. package/templates/vue-tailwind-sync/vite.config.ts +11 -2
  73. package/dist/chunk-BWTKRKNJ.js.map +0 -1
  74. package/dist/chunk-EOWLAAIV.js.map +0 -1
package/dist/index.d.cts CHANGED
@@ -59,6 +59,63 @@ declare class DevServerError extends KoraError {
59
59
  constructor(binary: string, searchPath: string);
60
60
  }
61
61
 
62
+ /**
63
+ * Writes an AGENTS.md into an existing project so AI coding agents follow Kora
64
+ * conventions. Refuses to overwrite an existing file unless `--force` is passed.
65
+ */
66
+ declare const agentsCommand: citty.CommandDef<{
67
+ force: {
68
+ type: "boolean";
69
+ description: string;
70
+ default: false;
71
+ };
72
+ framework: {
73
+ type: "string";
74
+ description: string;
75
+ };
76
+ }>;
77
+
78
+ /**
79
+ * Canonical AGENTS.md generator.
80
+ *
81
+ * `kora agents-md` writes this file into an existing project so AI coding agents
82
+ * (and humans) build Kora apps correctly instead of drifting to fetch calls,
83
+ * hand-written types, and loading spinners. New projects scaffolded with
84
+ * `create-kora-app` already ship an AGENTS.md; this command covers the manual
85
+ * setup path and lets existing projects regenerate the guidance on demand.
86
+ */
87
+ /** UI framework whose bindings section the generated AGENTS.md documents. */
88
+ type AgentsFramework = 'react' | 'vue' | 'svelte';
89
+ /** All supported frameworks, for validation and help text. */
90
+ declare const AGENTS_FRAMEWORKS: readonly AgentsFramework[];
91
+ /**
92
+ * Narrows an arbitrary string to a supported {@link AgentsFramework}.
93
+ *
94
+ * @param value - Candidate framework identifier
95
+ * @returns `true` when `value` is one of the supported frameworks
96
+ */
97
+ declare function isAgentsFramework(value: string): value is AgentsFramework;
98
+ /**
99
+ * Detects the UI framework from a project's package manifest by looking for the
100
+ * matching `@korajs/*` binding package in dependencies or devDependencies.
101
+ *
102
+ * @param manifest - Parsed `package.json` contents
103
+ * @returns The detected framework, or `null` when no binding package is present
104
+ */
105
+ declare function detectFrameworkFromManifest(manifest: unknown): AgentsFramework | null;
106
+ /**
107
+ * Renders the full AGENTS.md document for the given framework.
108
+ *
109
+ * The body (golden rules, data API cheat sheet, conflict handling, sync notes,
110
+ * commands) is framework-agnostic; only the bindings section changes. File paths
111
+ * are described as conventions so the guidance is correct for both scaffolded and
112
+ * manually configured projects.
113
+ *
114
+ * @param framework - UI framework whose bindings to document
115
+ * @returns The complete AGENTS.md file contents, terminated with a trailing newline
116
+ */
117
+ declare function generateAgentsMd(framework: AgentsFramework): string;
118
+
62
119
  /**
63
120
  * Generates TypeScript interfaces from a SchemaDefinition.
64
121
  * For each collection, produces three interfaces:
@@ -692,4 +749,4 @@ interface SyncProviderPresetOptions {
692
749
  */
693
750
  declare function applySyncProviderPreset(options: SyncProviderPresetOptions): Promise<void>;
694
751
 
695
- export { type AuthOption, type BuildArtifacts, ClackPromptClient, CliError, type ClientBuildOptions, type ClientBuildResult, type ContextAwareDeployAdapter, type CreateFlags, type CreatePreferences, DEPLOY_PLATFORMS, type DatabaseOption, type DatabaseProviderOption, type DeployAdapter, type DeployPlatform, type DeployResult, type DeployState, type DeployStateCreateInput, type DeployStatePatch, type DeploymentStatus, DevServerError, type DockerfileOptions, FlyAdapter, type FlyAdapterContext, type FlyAdapterOptions, type FlyCommandResult, type FlyCommandRunner, type FlyTomlOptions, type FrameworkOption, InvalidProjectError, type LogLine, type LogOptions, NodeFlyCommandRunner, NodeRailwayCommandRunner, PACKAGE_MANAGERS, type PackageManager, type PreferenceResolutionResult, PreferenceStore, type ProjectConfig, ProjectExistsError, type ProjectNameValidationResult, PromptCancelledError, type PromptClient, type ProvisionResult, RailwayAdapter, type RailwayAdapterContext, type RailwayAdapterOptions, type RailwayCommandResult, type RailwayCommandRunner, type RailwayJsonOptions, ReadlinePromptClient, SchemaNotFoundError, type SelectOption, type ServerBundleOptions, type ServerBundleResult, StubDeployAdapter, TEMPLATES, TEMPLATE_INFO, type TemplateContext, type TemplateInfo, type TemplateName, type TemplateSelectionInput, applySyncProviderPreset, buildClient, bundleServer, createDeployAdapter, createPromptClient, deployCommand, determineTemplateFromSelections, generateDeployPackageJson, generateDockerIgnore, generateDockerfile, generateFlyToml, generateRailwayJson, generateTypes, getCreatePreferencesOrDefault, getDefaultCreatePreferences, isAuthValue, isDatabaseProviderValue, isDatabaseValue, isDeployPlatform, isFrameworkValue, readDeployState, resetDeployState, resolveCreatePreferencesFlow, resolveDeployDirectory, resolveDeployStatePath, saveResolvedPreferences, shouldSavePreferences, updateDeployState, validateProjectName, writeDeployState, writeDockerIgnoreArtifact, writeDockerfileArtifact, writeFlyTomlArtifact, writeRailwayJsonArtifact };
752
+ export { AGENTS_FRAMEWORKS, type AgentsFramework, type AuthOption, type BuildArtifacts, ClackPromptClient, CliError, type ClientBuildOptions, type ClientBuildResult, type ContextAwareDeployAdapter, type CreateFlags, type CreatePreferences, DEPLOY_PLATFORMS, type DatabaseOption, type DatabaseProviderOption, type DeployAdapter, type DeployPlatform, type DeployResult, type DeployState, type DeployStateCreateInput, type DeployStatePatch, type DeploymentStatus, DevServerError, type DockerfileOptions, FlyAdapter, type FlyAdapterContext, type FlyAdapterOptions, type FlyCommandResult, type FlyCommandRunner, type FlyTomlOptions, type FrameworkOption, InvalidProjectError, type LogLine, type LogOptions, NodeFlyCommandRunner, NodeRailwayCommandRunner, PACKAGE_MANAGERS, type PackageManager, type PreferenceResolutionResult, PreferenceStore, type ProjectConfig, ProjectExistsError, type ProjectNameValidationResult, PromptCancelledError, type PromptClient, type ProvisionResult, RailwayAdapter, type RailwayAdapterContext, type RailwayAdapterOptions, type RailwayCommandResult, type RailwayCommandRunner, type RailwayJsonOptions, ReadlinePromptClient, SchemaNotFoundError, type SelectOption, type ServerBundleOptions, type ServerBundleResult, StubDeployAdapter, TEMPLATES, TEMPLATE_INFO, type TemplateContext, type TemplateInfo, type TemplateName, type TemplateSelectionInput, agentsCommand, applySyncProviderPreset, buildClient, bundleServer, createDeployAdapter, createPromptClient, deployCommand, detectFrameworkFromManifest, determineTemplateFromSelections, generateAgentsMd, generateDeployPackageJson, generateDockerIgnore, generateDockerfile, generateFlyToml, generateRailwayJson, generateTypes, getCreatePreferencesOrDefault, getDefaultCreatePreferences, isAgentsFramework, isAuthValue, isDatabaseProviderValue, isDatabaseValue, isDeployPlatform, isFrameworkValue, readDeployState, resetDeployState, resolveCreatePreferencesFlow, resolveDeployDirectory, resolveDeployStatePath, saveResolvedPreferences, shouldSavePreferences, updateDeployState, validateProjectName, writeDeployState, writeDockerIgnoreArtifact, writeDockerfileArtifact, writeFlyTomlArtifact, writeRailwayJsonArtifact };
package/dist/index.d.ts CHANGED
@@ -59,6 +59,63 @@ declare class DevServerError extends KoraError {
59
59
  constructor(binary: string, searchPath: string);
60
60
  }
61
61
 
62
+ /**
63
+ * Writes an AGENTS.md into an existing project so AI coding agents follow Kora
64
+ * conventions. Refuses to overwrite an existing file unless `--force` is passed.
65
+ */
66
+ declare const agentsCommand: citty.CommandDef<{
67
+ force: {
68
+ type: "boolean";
69
+ description: string;
70
+ default: false;
71
+ };
72
+ framework: {
73
+ type: "string";
74
+ description: string;
75
+ };
76
+ }>;
77
+
78
+ /**
79
+ * Canonical AGENTS.md generator.
80
+ *
81
+ * `kora agents-md` writes this file into an existing project so AI coding agents
82
+ * (and humans) build Kora apps correctly instead of drifting to fetch calls,
83
+ * hand-written types, and loading spinners. New projects scaffolded with
84
+ * `create-kora-app` already ship an AGENTS.md; this command covers the manual
85
+ * setup path and lets existing projects regenerate the guidance on demand.
86
+ */
87
+ /** UI framework whose bindings section the generated AGENTS.md documents. */
88
+ type AgentsFramework = 'react' | 'vue' | 'svelte';
89
+ /** All supported frameworks, for validation and help text. */
90
+ declare const AGENTS_FRAMEWORKS: readonly AgentsFramework[];
91
+ /**
92
+ * Narrows an arbitrary string to a supported {@link AgentsFramework}.
93
+ *
94
+ * @param value - Candidate framework identifier
95
+ * @returns `true` when `value` is one of the supported frameworks
96
+ */
97
+ declare function isAgentsFramework(value: string): value is AgentsFramework;
98
+ /**
99
+ * Detects the UI framework from a project's package manifest by looking for the
100
+ * matching `@korajs/*` binding package in dependencies or devDependencies.
101
+ *
102
+ * @param manifest - Parsed `package.json` contents
103
+ * @returns The detected framework, or `null` when no binding package is present
104
+ */
105
+ declare function detectFrameworkFromManifest(manifest: unknown): AgentsFramework | null;
106
+ /**
107
+ * Renders the full AGENTS.md document for the given framework.
108
+ *
109
+ * The body (golden rules, data API cheat sheet, conflict handling, sync notes,
110
+ * commands) is framework-agnostic; only the bindings section changes. File paths
111
+ * are described as conventions so the guidance is correct for both scaffolded and
112
+ * manually configured projects.
113
+ *
114
+ * @param framework - UI framework whose bindings to document
115
+ * @returns The complete AGENTS.md file contents, terminated with a trailing newline
116
+ */
117
+ declare function generateAgentsMd(framework: AgentsFramework): string;
118
+
62
119
  /**
63
120
  * Generates TypeScript interfaces from a SchemaDefinition.
64
121
  * For each collection, produces three interfaces:
@@ -692,4 +749,4 @@ interface SyncProviderPresetOptions {
692
749
  */
693
750
  declare function applySyncProviderPreset(options: SyncProviderPresetOptions): Promise<void>;
694
751
 
695
- export { type AuthOption, type BuildArtifacts, ClackPromptClient, CliError, type ClientBuildOptions, type ClientBuildResult, type ContextAwareDeployAdapter, type CreateFlags, type CreatePreferences, DEPLOY_PLATFORMS, type DatabaseOption, type DatabaseProviderOption, type DeployAdapter, type DeployPlatform, type DeployResult, type DeployState, type DeployStateCreateInput, type DeployStatePatch, type DeploymentStatus, DevServerError, type DockerfileOptions, FlyAdapter, type FlyAdapterContext, type FlyAdapterOptions, type FlyCommandResult, type FlyCommandRunner, type FlyTomlOptions, type FrameworkOption, InvalidProjectError, type LogLine, type LogOptions, NodeFlyCommandRunner, NodeRailwayCommandRunner, PACKAGE_MANAGERS, type PackageManager, type PreferenceResolutionResult, PreferenceStore, type ProjectConfig, ProjectExistsError, type ProjectNameValidationResult, PromptCancelledError, type PromptClient, type ProvisionResult, RailwayAdapter, type RailwayAdapterContext, type RailwayAdapterOptions, type RailwayCommandResult, type RailwayCommandRunner, type RailwayJsonOptions, ReadlinePromptClient, SchemaNotFoundError, type SelectOption, type ServerBundleOptions, type ServerBundleResult, StubDeployAdapter, TEMPLATES, TEMPLATE_INFO, type TemplateContext, type TemplateInfo, type TemplateName, type TemplateSelectionInput, applySyncProviderPreset, buildClient, bundleServer, createDeployAdapter, createPromptClient, deployCommand, determineTemplateFromSelections, generateDeployPackageJson, generateDockerIgnore, generateDockerfile, generateFlyToml, generateRailwayJson, generateTypes, getCreatePreferencesOrDefault, getDefaultCreatePreferences, isAuthValue, isDatabaseProviderValue, isDatabaseValue, isDeployPlatform, isFrameworkValue, readDeployState, resetDeployState, resolveCreatePreferencesFlow, resolveDeployDirectory, resolveDeployStatePath, saveResolvedPreferences, shouldSavePreferences, updateDeployState, validateProjectName, writeDeployState, writeDockerIgnoreArtifact, writeDockerfileArtifact, writeFlyTomlArtifact, writeRailwayJsonArtifact };
752
+ export { AGENTS_FRAMEWORKS, type AgentsFramework, type AuthOption, type BuildArtifacts, ClackPromptClient, CliError, type ClientBuildOptions, type ClientBuildResult, type ContextAwareDeployAdapter, type CreateFlags, type CreatePreferences, DEPLOY_PLATFORMS, type DatabaseOption, type DatabaseProviderOption, type DeployAdapter, type DeployPlatform, type DeployResult, type DeployState, type DeployStateCreateInput, type DeployStatePatch, type DeploymentStatus, DevServerError, type DockerfileOptions, FlyAdapter, type FlyAdapterContext, type FlyAdapterOptions, type FlyCommandResult, type FlyCommandRunner, type FlyTomlOptions, type FrameworkOption, InvalidProjectError, type LogLine, type LogOptions, NodeFlyCommandRunner, NodeRailwayCommandRunner, PACKAGE_MANAGERS, type PackageManager, type PreferenceResolutionResult, PreferenceStore, type ProjectConfig, ProjectExistsError, type ProjectNameValidationResult, PromptCancelledError, type PromptClient, type ProvisionResult, RailwayAdapter, type RailwayAdapterContext, type RailwayAdapterOptions, type RailwayCommandResult, type RailwayCommandRunner, type RailwayJsonOptions, ReadlinePromptClient, SchemaNotFoundError, type SelectOption, type ServerBundleOptions, type ServerBundleResult, StubDeployAdapter, TEMPLATES, TEMPLATE_INFO, type TemplateContext, type TemplateInfo, type TemplateName, type TemplateSelectionInput, agentsCommand, applySyncProviderPreset, buildClient, bundleServer, createDeployAdapter, createPromptClient, deployCommand, detectFrameworkFromManifest, determineTemplateFromSelections, generateAgentsMd, generateDeployPackageJson, generateDockerIgnore, generateDockerfile, generateFlyToml, generateRailwayJson, generateTypes, getCreatePreferencesOrDefault, getDefaultCreatePreferences, isAgentsFramework, isAuthValue, isDatabaseProviderValue, isDatabaseValue, isDeployPlatform, isFrameworkValue, readDeployState, resetDeployState, resolveCreatePreferencesFlow, resolveDeployDirectory, resolveDeployStatePath, saveResolvedPreferences, shouldSavePreferences, updateDeployState, validateProjectName, writeDeployState, writeDockerIgnoreArtifact, writeDockerfileArtifact, writeFlyTomlArtifact, writeRailwayJsonArtifact };
package/dist/index.js CHANGED
@@ -1,21 +1,26 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
+ AGENTS_FRAMEWORKS,
3
4
  DEPLOY_PLATFORMS,
4
5
  FlyAdapter,
5
6
  NodeFlyCommandRunner,
6
7
  NodeRailwayCommandRunner,
7
8
  RailwayAdapter,
8
9
  StubDeployAdapter,
10
+ agentsCommand,
9
11
  buildClient,
10
12
  bundleServer,
11
13
  createDeployAdapter,
12
14
  deployCommand,
15
+ detectFrameworkFromManifest,
16
+ generateAgentsMd,
13
17
  generateDeployPackageJson,
14
18
  generateDockerIgnore,
15
19
  generateDockerfile,
16
20
  generateFlyToml,
17
21
  generateRailwayJson,
18
22
  generateTypes,
23
+ isAgentsFramework,
19
24
  isDeployPlatform,
20
25
  readDeployState,
21
26
  resetDeployState,
@@ -27,7 +32,7 @@ import {
27
32
  writeDockerfileArtifact,
28
33
  writeFlyTomlArtifact,
29
34
  writeRailwayJsonArtifact
30
- } from "./chunk-EOWLAAIV.js";
35
+ } from "./chunk-4IKCHRJ6.js";
31
36
  import {
32
37
  ClackPromptClient,
33
38
  CliError,
@@ -54,9 +59,10 @@ import {
54
59
  saveResolvedPreferences,
55
60
  shouldSavePreferences,
56
61
  validateProjectName
57
- } from "./chunk-B5YS4STN.js";
62
+ } from "./chunk-G2PBYMMA.js";
58
63
  import "./chunk-5NI2FEQL.js";
59
64
  export {
65
+ AGENTS_FRAMEWORKS,
60
66
  ClackPromptClient,
61
67
  CliError,
62
68
  DEPLOY_PLATFORMS,
@@ -75,13 +81,16 @@ export {
75
81
  StubDeployAdapter,
76
82
  TEMPLATES,
77
83
  TEMPLATE_INFO,
84
+ agentsCommand,
78
85
  applySyncProviderPreset,
79
86
  buildClient,
80
87
  bundleServer,
81
88
  createDeployAdapter,
82
89
  createPromptClient,
83
90
  deployCommand,
91
+ detectFrameworkFromManifest,
84
92
  determineTemplateFromSelections,
93
+ generateAgentsMd,
85
94
  generateDeployPackageJson,
86
95
  generateDockerIgnore,
87
96
  generateDockerfile,
@@ -90,6 +99,7 @@ export {
90
99
  generateTypes,
91
100
  getCreatePreferencesOrDefault,
92
101
  getDefaultCreatePreferences,
102
+ isAgentsFramework,
93
103
  isAuthValue,
94
104
  isDatabaseProviderValue,
95
105
  isDatabaseValue,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@korajs/cli",
3
- "version": "1.0.0-beta.1",
3
+ "version": "1.0.0-beta.10",
4
4
  "description": "Kora.js CLI tooling and project scaffolding",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -37,7 +37,7 @@
37
37
  "conf": "^15.1.0",
38
38
  "esbuild": "^0.28.0",
39
39
  "validate-npm-package-name": "^7.0.2",
40
- "@korajs/core": "1.0.0-beta.1"
40
+ "@korajs/core": "1.0.0-beta.10"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/better-sqlite3": "^7.6.13",
@@ -47,12 +47,12 @@
47
47
  "tsup": "^8.3.6",
48
48
  "typescript": "^5.7.3",
49
49
  "vitest": "^3.0.4",
50
- "@korajs/store": "1.0.0-beta.1",
51
- "@korajs/server": "1.0.0-beta.1",
52
- "@korajs/merge": "1.0.0-beta.1",
53
- "korajs": "1.0.0-beta.1",
54
- "@korajs/sync": "1.0.0-beta.1",
55
- "@korajs/test": "1.0.0-beta.1"
50
+ "@korajs/server": "1.0.0-beta.10",
51
+ "@korajs/store": "1.0.0-beta.10",
52
+ "@korajs/sync": "1.0.0-beta.10",
53
+ "@korajs/merge": "1.0.0-beta.10",
54
+ "@korajs/test": "1.0.0-beta.10",
55
+ "korajs": "1.0.0-beta.10"
56
56
  },
57
57
  "license": "MIT",
58
58
  "scripts": {
@@ -47,7 +47,7 @@ To enable real-time sync across devices, update `src/main.tsx`:
47
47
  const app = createApp({
48
48
  schema,
49
49
  sync: {
50
- url: import.meta.env.VITE_SYNC_URL || 'ws://localhost:3001',
50
+ url: import.meta.env.VITE_SYNC_URL || 'ws://localhost:3001/kora-sync',
51
51
  },
52
52
  // ...
53
53
  })
@@ -12,7 +12,7 @@ const app = createApp({
12
12
  store: {
13
13
  workerUrl: koraWorkerUrl,
14
14
  },
15
- devtools: true,
15
+ devtools: import.meta.env.DEV,
16
16
  })
17
17
 
18
18
  createRoot(document.getElementById('root')!).render(
@@ -1,4 +1,5 @@
1
1
  interface ImportMetaEnv {
2
+ readonly DEV: boolean
2
3
  readonly VITE_SYNC_URL?: string
3
4
  }
4
5
 
@@ -6,23 +6,26 @@ import { defineConfig } from 'vite'
6
6
 
7
7
  /**
8
8
  * Adds Cross-Origin-Opener-Policy and Cross-Origin-Embedder-Policy headers
9
- * required for SharedArrayBuffer. Without these headers, OPFS SAH Pool VFS
10
- * cannot be used and SQLite WASM falls back to in-memory storage (no persistence).
9
+ * enabling SharedArrayBuffer where browsers support it while keeping common
10
+ * third-party embeds such as YouTube and Vimeo usable. Kora falls back to
11
+ * durable IndexedDB storage when SharedArrayBuffer is unavailable.
11
12
  */
12
13
  function crossOriginIsolation(): Plugin {
14
+ const embedderPolicy = process.env.KORA_COEP_POLICY || 'credentialless'
15
+
13
16
  return {
14
17
  name: 'cross-origin-isolation',
15
18
  configureServer(server) {
16
19
  server.middlewares.use((_req, res, next) => {
17
20
  res.setHeader('Cross-Origin-Opener-Policy', 'same-origin')
18
- res.setHeader('Cross-Origin-Embedder-Policy', 'require-corp')
21
+ res.setHeader('Cross-Origin-Embedder-Policy', embedderPolicy)
19
22
  next()
20
23
  })
21
24
  },
22
25
  configurePreviewServer(server) {
23
26
  server.middlewares.use((_req, res, next) => {
24
27
  res.setHeader('Cross-Origin-Opener-Policy', 'same-origin')
25
- res.setHeader('Cross-Origin-Embedder-Policy', 'require-corp')
28
+ res.setHeader('Cross-Origin-Embedder-Policy', embedderPolicy)
26
29
  next()
27
30
  })
28
31
  },
@@ -11,7 +11,7 @@ npm run dev
11
11
  This starts both the Vite dev server and the Kora sync server.
12
12
 
13
13
  - **App**: http://localhost:5173
14
- - **Sync server**: ws://localhost:3001
14
+ - **Sync server**: ws://localhost:3001/kora-sync
15
15
 
16
16
  ## Project Structure
17
17
 
@@ -40,11 +40,12 @@ writes, and `useTodos.ts` is the React binding that exposes todo data and action
40
40
 
41
41
  | Variable | Default | Description |
42
42
  |----------|---------|-------------|
43
- | `VITE_SYNC_URL` | `ws://localhost:3001` | WebSocket URL for the sync server |
43
+ | `VITE_SYNC_URL` | `ws://localhost:3001/kora-sync` | WebSocket URL for the sync endpoint |
44
44
  | `VITE_AUTH_URL` | current origin | HTTP URL for `/auth/*` routes |
45
45
  | `PORT` | `3001` | Sync server port |
46
- | `KORA_SERVER_DB` | `./kora-server.db` | SQLite file used by the sync server when `DATABASE_URL` is empty |
47
- | `KORA_AUTH_DB` | `./kora-auth.db` | SQLite file used by OAuth state and linked identities when `DATABASE_URL` is empty |
46
+ | `KORA_SERVER_DB` | `./.kora/kora-server.db` | SQLite file used by the sync server when `DATABASE_URL` is empty |
47
+ | `KORA_AUTH_DB` | `./.kora/kora-auth.db` | SQLite file used by OAuth state and linked identities when `DATABASE_URL` is empty |
48
+ | `KORA_COEP_POLICY` | `credentialless` | Dev/preview Cross-Origin-Embedder-Policy. Use `require-corp` only when every embedded resource opts in. |
48
49
  | `DATABASE_URL` | (none) | PostgreSQL connection string for production sync server deployments |
49
50
  | `KORA_SYNC_PATH` | `/kora-sync` | WebSocket path exposed by the sync server |
50
51
  | `KORA_AUTH_SECRET` | (none) | Enables built-in `/auth/*` routes and authenticated sync when set |
@@ -94,7 +95,7 @@ The client and sync server must be deployed separately:
94
95
  Set `VITE_SYNC_URL` to your deployed sync server URL when building:
95
96
 
96
97
  ```bash
97
- VITE_SYNC_URL=wss://your-server.example.com npm run build
98
+ VITE_SYNC_URL=wss://your-server.example.com/kora-sync npm run build
98
99
  ```
99
100
 
100
101
  ## Learn More
@@ -1,3 +1,4 @@
1
+ import { existsSync, readFileSync } from 'node:fs'
1
2
  import {
2
3
  type CreateKoraAuthServerOptions,
3
4
  createKoraAuthServer,
@@ -12,6 +13,45 @@ import {
12
13
  } from '@korajs/server'
13
14
  import schema from './src/schema'
14
15
 
16
+ loadLocalEnv()
17
+
18
+ function loadLocalEnv(mode = process.env.NODE_ENV || 'development') {
19
+ const existingKeys = new Set(Object.keys(process.env))
20
+ for (const file of ['.env', '.env.local', `.env.${mode}`, `.env.${mode}.local`]) {
21
+ if (!existsSync(file)) continue
22
+ for (const [key, value] of Object.entries(parseEnvFile(readFileSync(file, 'utf8')))) {
23
+ if (!existingKeys.has(key)) {
24
+ process.env[key] = value
25
+ }
26
+ }
27
+ }
28
+ }
29
+
30
+ function parseEnvFile(contents: string): Record<string, string> {
31
+ const env: Record<string, string> = {}
32
+ for (const rawLine of contents.split(/\r?\n/)) {
33
+ const line = rawLine.trim()
34
+ if (!line || line.startsWith('#')) continue
35
+ const normalized = line.startsWith('export ') ? line.slice('export '.length).trim() : line
36
+ const equalsIndex = normalized.indexOf('=')
37
+ if (equalsIndex <= 0) continue
38
+ const key = normalized.slice(0, equalsIndex).trim()
39
+ if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(key)) continue
40
+ env[key] = parseEnvValue(normalized.slice(equalsIndex + 1).trim())
41
+ }
42
+ return env
43
+ }
44
+
45
+ function parseEnvValue(value: string): string {
46
+ const quote = value[0]
47
+ if ((quote === '"' || quote === "'") && value[value.length - 1] === quote) {
48
+ const inner = value.slice(1, -1)
49
+ return quote === '"' ? inner.replace(/\\n/g, '\n').replace(/\\r/g, '\r') : inner
50
+ }
51
+ const commentIndex = value.search(/\s#/)
52
+ return (commentIndex >= 0 ? value.slice(0, commentIndex) : value).trim()
53
+ }
54
+
15
55
  async function createStore() {
16
56
  if (process.env.DATABASE_URL) {
17
57
  return createPostgresServerStore({
@@ -20,7 +60,7 @@ async function createStore() {
20
60
  }
21
61
 
22
62
  return createSqliteServerStore({
23
- filename: process.env.KORA_SERVER_DB || './kora-server.db',
63
+ filename: process.env.KORA_SERVER_DB || './.kora/kora-server.db',
24
64
  })
25
65
  }
26
66
 
@@ -36,7 +76,10 @@ async function start() {
36
76
  staticDir: './dist',
37
77
  syncPath,
38
78
  httpRoutes: auth ? [{ path: '/auth', handle: auth.handleRequest }] : undefined,
39
- syncOptions: auth ? { auth: auth.auth } : undefined,
79
+ syncOptions: {
80
+ schemaVersion: schema.version,
81
+ ...(auth ? { auth: auth.auth } : {}),
82
+ },
40
83
  operationalAuth: {
41
84
  adminToken: process.env.KORA_ADMIN_TOKEN,
42
85
  metricsToken: process.env.KORA_METRICS_TOKEN,
@@ -72,7 +115,7 @@ async function createOAuthConfig(): Promise<CreateKoraAuthServerOptions['oauth']
72
115
  const oauthStores = process.env.DATABASE_URL
73
116
  ? await createPostgresOAuthStores({ connectionString: process.env.DATABASE_URL })
74
117
  : await createSqliteOAuthStores({
75
- filename: process.env.KORA_AUTH_DB || './kora-auth.db',
118
+ filename: process.env.KORA_AUTH_DB || './.kora/kora-auth.db',
76
119
  })
77
120
 
78
121
  return {
@@ -26,7 +26,7 @@ const app = createApp({
26
26
  store: {
27
27
  workerUrl: koraWorkerUrl,
28
28
  },
29
- devtools: true,
29
+ devtools: import.meta.env.DEV,
30
30
  })
31
31
 
32
32
  // Connect to sync server once the app is ready
@@ -1,4 +1,5 @@
1
1
  interface ImportMetaEnv {
2
+ readonly DEV: boolean
2
3
  readonly VITE_SYNC_URL?: string
3
4
  }
4
5
 
@@ -6,23 +6,26 @@ import { defineConfig } from 'vite'
6
6
 
7
7
  /**
8
8
  * Adds Cross-Origin-Opener-Policy and Cross-Origin-Embedder-Policy headers
9
- * required for SharedArrayBuffer. Without these headers, OPFS SAH Pool VFS
10
- * cannot be used and SQLite WASM falls back to in-memory storage (no persistence).
9
+ * enabling SharedArrayBuffer where browsers support it while keeping common
10
+ * third-party embeds such as YouTube and Vimeo usable. Kora falls back to
11
+ * durable IndexedDB storage when SharedArrayBuffer is unavailable.
11
12
  */
12
13
  function crossOriginIsolation(): Plugin {
14
+ const embedderPolicy = process.env.KORA_COEP_POLICY || 'credentialless'
15
+
13
16
  return {
14
17
  name: 'cross-origin-isolation',
15
18
  configureServer(server) {
16
19
  server.middlewares.use((_req, res, next) => {
17
20
  res.setHeader('Cross-Origin-Opener-Policy', 'same-origin')
18
- res.setHeader('Cross-Origin-Embedder-Policy', 'require-corp')
21
+ res.setHeader('Cross-Origin-Embedder-Policy', embedderPolicy)
19
22
  next()
20
23
  })
21
24
  },
22
25
  configurePreviewServer(server) {
23
26
  server.middlewares.use((_req, res, next) => {
24
27
  res.setHeader('Cross-Origin-Opener-Policy', 'same-origin')
25
- res.setHeader('Cross-Origin-Embedder-Policy', 'require-corp')
28
+ res.setHeader('Cross-Origin-Embedder-Policy', embedderPolicy)
26
29
  next()
27
30
  })
28
31
  },
@@ -81,12 +84,19 @@ export default defineConfig({
81
84
  },
82
85
  server: {
83
86
  allowedHosts: true,
87
+ watch: {
88
+ ignored: ['**/.kora/**', '**/kora/generated/**', '**/*.db', '**/*.db-shm', '**/*.db-wal'],
89
+ },
84
90
  proxy: {
85
91
  '/kora-sync': {
86
92
  target: 'ws://localhost:3001',
87
93
  ws: true,
88
94
  rewriteWsOrigin: true,
89
95
  },
96
+ '/auth': {
97
+ target: 'http://localhost:3001',
98
+ changeOrigin: true,
99
+ },
90
100
  },
91
101
  },
92
102
  })
@@ -47,7 +47,7 @@ To enable real-time sync across devices, update `src/main.tsx`:
47
47
  const app = createApp({
48
48
  schema,
49
49
  sync: {
50
- url: import.meta.env.VITE_SYNC_URL || 'ws://localhost:3001',
50
+ url: import.meta.env.VITE_SYNC_URL || 'ws://localhost:3001/kora-sync',
51
51
  },
52
52
  // ...
53
53
  })
@@ -12,7 +12,7 @@ const app = createApp({
12
12
  store: {
13
13
  workerUrl: koraWorkerUrl,
14
14
  },
15
- devtools: true,
15
+ devtools: import.meta.env.DEV,
16
16
  })
17
17
 
18
18
  createRoot(document.getElementById('root')!).render(
@@ -1,4 +1,5 @@
1
1
  interface ImportMetaEnv {
2
+ readonly DEV: boolean
2
3
  readonly VITE_SYNC_URL?: string
3
4
  }
4
5
 
@@ -7,23 +7,26 @@ import { defineConfig } from 'vite'
7
7
 
8
8
  /**
9
9
  * Adds Cross-Origin-Opener-Policy and Cross-Origin-Embedder-Policy headers
10
- * required for SharedArrayBuffer. Without these headers, OPFS SAH Pool VFS
11
- * cannot be used and SQLite WASM falls back to in-memory storage (no persistence).
10
+ * enabling SharedArrayBuffer where browsers support it while keeping common
11
+ * third-party embeds such as YouTube and Vimeo usable. Kora falls back to
12
+ * durable IndexedDB storage when SharedArrayBuffer is unavailable.
12
13
  */
13
14
  function crossOriginIsolation(): Plugin {
15
+ const embedderPolicy = process.env.KORA_COEP_POLICY || 'credentialless'
16
+
14
17
  return {
15
18
  name: 'cross-origin-isolation',
16
19
  configureServer(server) {
17
20
  server.middlewares.use((_req, res, next) => {
18
21
  res.setHeader('Cross-Origin-Opener-Policy', 'same-origin')
19
- res.setHeader('Cross-Origin-Embedder-Policy', 'require-corp')
22
+ res.setHeader('Cross-Origin-Embedder-Policy', embedderPolicy)
20
23
  next()
21
24
  })
22
25
  },
23
26
  configurePreviewServer(server) {
24
27
  server.middlewares.use((_req, res, next) => {
25
28
  res.setHeader('Cross-Origin-Opener-Policy', 'same-origin')
26
- res.setHeader('Cross-Origin-Embedder-Policy', 'require-corp')
29
+ res.setHeader('Cross-Origin-Embedder-Policy', embedderPolicy)
27
30
  next()
28
31
  })
29
32
  },
@@ -11,7 +11,7 @@ npm run dev
11
11
  This starts both the Vite dev server and the Kora sync server.
12
12
 
13
13
  - **App**: http://localhost:5173
14
- - **Sync server**: ws://localhost:3001
14
+ - **Sync server**: ws://localhost:3001/kora-sync
15
15
 
16
16
  ## Project Structure
17
17
 
@@ -40,11 +40,12 @@ writes, and `useTodos.ts` is the React binding that exposes todo data and action
40
40
 
41
41
  | Variable | Default | Description |
42
42
  |----------|---------|-------------|
43
- | `VITE_SYNC_URL` | `ws://localhost:3001` | WebSocket URL for the sync server |
43
+ | `VITE_SYNC_URL` | `ws://localhost:3001/kora-sync` | WebSocket URL for the sync endpoint |
44
44
  | `VITE_AUTH_URL` | current origin | HTTP URL for `/auth/*` routes |
45
45
  | `PORT` | `3001` | Sync server port |
46
- | `KORA_SERVER_DB` | `./kora-server.db` | SQLite file used by the sync server when `DATABASE_URL` is empty |
47
- | `KORA_AUTH_DB` | `./kora-auth.db` | SQLite file used by OAuth state and linked identities when `DATABASE_URL` is empty |
46
+ | `KORA_SERVER_DB` | `./.kora/kora-server.db` | SQLite file used by the sync server when `DATABASE_URL` is empty |
47
+ | `KORA_AUTH_DB` | `./.kora/kora-auth.db` | SQLite file used by OAuth state and linked identities when `DATABASE_URL` is empty |
48
+ | `KORA_COEP_POLICY` | `credentialless` | Dev/preview Cross-Origin-Embedder-Policy. Use `require-corp` only when every embedded resource opts in. |
48
49
  | `DATABASE_URL` | (none) | PostgreSQL connection string for production sync server deployments |
49
50
  | `KORA_SYNC_PATH` | `/kora-sync` | WebSocket path exposed by the sync server |
50
51
  | `KORA_AUTH_SECRET` | (none) | Enables built-in `/auth/*` routes and authenticated sync when set |
@@ -94,7 +95,7 @@ The client and sync server must be deployed separately:
94
95
  Set `VITE_SYNC_URL` to your deployed sync server URL when building:
95
96
 
96
97
  ```bash
97
- VITE_SYNC_URL=wss://your-server.example.com npm run build
98
+ VITE_SYNC_URL=wss://your-server.example.com/kora-sync npm run build
98
99
  ```
99
100
 
100
101
  ## Learn More