kilatjs 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.
File without changes
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Live Reload Server for KilatJS
3
+ *
4
+ * Provides browser auto-refresh when files change.
5
+ * Works with pure SSR - no client-side hydration needed.
6
+ */
7
+ /**
8
+ * Start the live reload WebSocket server
9
+ */
10
+ export declare function startLiveReload(port?: number): void;
11
+ /**
12
+ * Notify all connected browsers to reload
13
+ */
14
+ export declare function notifyReload(): void;
15
+ /**
16
+ * Get the live reload client script to inject into HTML
17
+ */
18
+ export declare function getLiveReloadScript(port?: number): string;
19
+ /**
20
+ * Watch a directory for changes and trigger reload
21
+ * Uses a polling-based approach that works reliably with Bun
22
+ */
23
+ export declare function watchDirectory(dir: string, onChange: () => void): Promise<void>;
24
+ /**
25
+ * Stop the live reload server
26
+ */
27
+ export declare function stopLiveReload(): void;
@@ -2,14 +2,24 @@ import { KilatConfig } from "../core/types";
2
2
  export declare class KilatServer {
3
3
  private router;
4
4
  private config;
5
+ private appDir;
6
+ private routesDir;
5
7
  constructor(config: KilatConfig);
8
+ /**
9
+ * Resolve appDir and routesDir from config
10
+ * Auto-detects routes/ or pages/ folder inside appDir
11
+ */
12
+ private resolvePaths;
6
13
  start(): Promise<Bun.Server<undefined>>;
7
14
  buildStatic(): Promise<void>;
15
+ /**
16
+ * Analyze routes and display detailed information
17
+ */
18
+ private displayRouteAnalysis;
8
19
  /**
9
20
  * Generate a production server file that uses Bun's FileSystemRouter
10
21
  */
11
22
  private generateProductionServer;
12
- private formatSize;
13
23
  private runTailwind;
14
24
  private copyStaticAssets;
15
25
  private copyDir;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Vite Dev Server Integration for KilatJS
3
+ *
4
+ * Provides true module-level HMR instead of full process restarts.
5
+ * Uses Vite's ssrLoadModule for hot-reloading SSR modules.
6
+ */
7
+ import type { KilatConfig } from "../core/types";
8
+ type ViteDevServer = any;
9
+ export interface ViteDevOptions {
10
+ config: KilatConfig;
11
+ routesDir: string;
12
+ }
13
+ /**
14
+ * Create and start Vite dev server in middleware mode
15
+ */
16
+ export declare function createViteDevServer(options: ViteDevOptions): Promise<ViteDevServer>;
17
+ /**
18
+ * Load a module through Vite's SSR module loader
19
+ * This enables true HMR - modules are hot-reloaded without process restart
20
+ */
21
+ export declare function ssrLoadModule(modulePath: string): Promise<any>;
22
+ /**
23
+ * Transform HTML to inject Vite HMR client
24
+ */
25
+ export declare function injectViteClient(html: string): string;
26
+ /**
27
+ * Handle Vite middleware requests (HMR, assets, etc.)
28
+ */
29
+ export declare function handleViteRequest(request: Request): Promise<Response | null>;
30
+ /**
31
+ * Close Vite dev server
32
+ */
33
+ export declare function closeViteDevServer(): Promise<void>;
34
+ /**
35
+ * Get the Vite dev server instance
36
+ */
37
+ export declare function getViteServer(): ViteDevServer | null;
38
+ export {};
@@ -0,0 +1,17 @@
1
+ /**
2
+ * KilatJS Vite-enabled Server
3
+ *
4
+ * Uses Vite for true module-level HMR in development.
5
+ * No process restarts - just hot module replacement.
6
+ */
7
+ import { KilatConfig } from "../core/types";
8
+ export declare class ViteKilatServer {
9
+ private router;
10
+ private config;
11
+ private appDir;
12
+ private routesDir;
13
+ constructor(config: KilatConfig);
14
+ private resolvePaths;
15
+ start(): Promise<Bun.Server<undefined>>;
16
+ private runTailwind;
17
+ }
package/package.json CHANGED
@@ -1,10 +1,13 @@
1
1
  {
2
2
  "name": "kilatjs",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "A Bun-native, HTML-first framework that renders real pages, treats UI frameworks as renderers, and makes SEO the default.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "module": "dist/index.js",
8
+ "bin": {
9
+ "kilat": "./dist/cli.js"
10
+ },
8
11
  "exports": {
9
12
  ".": {
10
13
  "types": "./dist/index.d.ts",
@@ -19,11 +22,14 @@
19
22
  ],
20
23
  "scripts": {
21
24
  "build": "bun run build:lib && bun run build:types",
22
- "build:lib": "bun build ./src/index.ts --outdir ./dist --external react --external react-dom --external fs --external path --external bun",
25
+ "build:lib": "bun build ./src/index.ts --outdir ./dist --external react --external react-dom --external fs --external path --external bun && bun build ./src/cli.ts --outdir ./dist --external react --external react-dom --external fs --external path --external bun",
23
26
  "build:types": "tsc --declaration --emitDeclarationOnly --outDir ./dist",
24
27
  "build:example": "cd example && bun run ../src/cli.ts build",
25
28
  "start": "cd example && bun run ../src/cli.ts dev --production",
26
- "dev": "cd example && bun --watch run ../src/cli.ts dev",
29
+ "serve": "cd example && bun run ../src/cli.ts serve",
30
+ "dev": "cd example && bun run ../src/cli.ts dev",
31
+ "dev:watch": "bun --watch run build:lib",
32
+ "watch": "bun --watch run build:lib",
27
33
  "test": "bun test",
28
34
  "typecheck": "tsc --noEmit",
29
35
  "prepublishOnly": "bun run build"
@@ -67,4 +73,4 @@
67
73
  "url": "https://github.com/Haslab-dev/KilatJS/issues"
68
74
  },
69
75
  "homepage": "https://github.com/Haslab-dev/KilatJS#readme"
70
- }
76
+ }