bertui 1.1.7 → 1.1.8
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 +10 -10
- package/index.js +32 -15
- package/package.json +6 -6
- package/src/client/compiler.js +46 -3
- package/src/image-optimizer/index.js +27 -0
- package/src/router/SSRRouter.js +1 -1
- package/src/router/index.js +2 -2
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ Zero configuration. 494ms dev server. 265ms builds. Perfect SEO with Server Isla
|
|
|
13
13
|
[](https://www.rust-lang.org)
|
|
14
14
|
[](LICENSE)
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
# One command. Zero config. Instant speed. 78% smaller images.
|
|
18
18
|
bunx create-bertui my-app && cd my-app && bun run dev
|
|
19
19
|
|
|
@@ -106,13 +106,13 @@ export default function About() {
|
|
|
106
106
|
|
|
107
107
|
At build time:
|
|
108
108
|
|
|
109
|
-
|
|
109
|
+
✅ Generates static HTML for instant loading
|
|
110
110
|
|
|
111
|
-
|
|
111
|
+
✅ Auto-adds to sitemap.xml
|
|
112
112
|
|
|
113
|
-
|
|
113
|
+
✅ Perfect SEO without SSR complexity
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
✅ Still builds in 265ms
|
|
116
116
|
|
|
117
117
|
🦀 Image Optimization (Just Works)
|
|
118
118
|
|
|
@@ -241,17 +241,17 @@ Rust Required ❌ NO N/A N/A N/A
|
|
|
241
241
|
|
|
242
242
|
Future packages (in development):
|
|
243
243
|
|
|
244
|
-
|
|
244
|
+
🔄 bertui-elysia - Full-stack addon (API routes, auth, database)
|
|
245
245
|
|
|
246
|
-
|
|
246
|
+
🎨 bertui-animation - GPU-accelerated animations (Zig)
|
|
247
247
|
|
|
248
|
-
|
|
248
|
+
📊 bertui-charts - High-performance charts (Rust)
|
|
249
249
|
|
|
250
250
|
🙏 Credits
|
|
251
251
|
|
|
252
|
-
|
|
252
|
+
Runtime: Bun - The fastest JavaScript runtime
|
|
253
253
|
|
|
254
|
-
|
|
254
|
+
Server: Elysia - Fast and elegant web framework
|
|
255
255
|
|
|
256
256
|
CSS: LightningCSS - Lightning-fast CSS processing
|
|
257
257
|
|
package/index.js
CHANGED
|
@@ -1,44 +1,61 @@
|
|
|
1
|
-
//
|
|
1
|
+
// ============================================
|
|
2
|
+
// FILE: bertui/index.js (Located in root)
|
|
3
|
+
// ============================================
|
|
2
4
|
|
|
3
5
|
// Compiler
|
|
4
|
-
export { compileProject } from './client/compiler.js';
|
|
5
|
-
export { compileForBuild } from './build/compiler/index.js';
|
|
6
|
-
export { discoverRoutes } from './build/compiler/route-discoverer.js';
|
|
6
|
+
export { compileProject, compileFile } from './src/client/compiler.js';
|
|
7
|
+
export { compileForBuild } from './src/build/compiler/index.js';
|
|
8
|
+
export { discoverRoutes } from './src/build/compiler/route-discoverer.js';
|
|
7
9
|
|
|
8
10
|
// HMR
|
|
9
|
-
export { hmr } from './client/hmr-runtime.js';
|
|
11
|
+
export { hmr } from './src/client/hmr-runtime.js';
|
|
10
12
|
|
|
11
|
-
// Image Optimizer
|
|
13
|
+
// Image Optimizer
|
|
12
14
|
export {
|
|
13
15
|
optimizeImage,
|
|
14
16
|
optimizeImagesBatch,
|
|
15
17
|
hasWasm,
|
|
16
18
|
version as optimizerVersion
|
|
17
|
-
} from './image-optimizer/index.js';
|
|
19
|
+
} from './src/image-optimizer/index.js';
|
|
18
20
|
|
|
19
21
|
// Build
|
|
20
|
-
export { buildProduction } from './build.js';
|
|
21
|
-
export { optimizeImages } from './build/image-optimizer.js';
|
|
22
|
+
export { buildProduction } from './src/build.js';
|
|
23
|
+
export { optimizeImages } from './src/build/image-optimizer.js';
|
|
22
24
|
|
|
23
25
|
// Router
|
|
24
|
-
export { Router, Link, useRouter } from './router/index.js';
|
|
25
|
-
export { SSRRouter } from './router/SSRRouter.
|
|
26
|
+
export { Router, Link, useRouter } from './src/router/index.js';
|
|
27
|
+
export { SSRRouter } from './src/router/SSRRouter.js';
|
|
26
28
|
|
|
27
29
|
// Config
|
|
28
|
-
export { loadConfig, defaultConfig } from './config/index.js';
|
|
30
|
+
export { loadConfig, defaultConfig } from './src/config/index.js';
|
|
29
31
|
|
|
30
32
|
// Logger
|
|
31
|
-
export { default as logger } from './logger/logger.js';
|
|
33
|
+
export { default as logger } from './src/logger/logger.js';
|
|
32
34
|
|
|
33
|
-
// CLI
|
|
34
|
-
export { program } from './cli.js';
|
|
35
|
+
// CLI
|
|
36
|
+
export { program } from './src/cli.js';
|
|
35
37
|
|
|
36
38
|
// Version
|
|
37
39
|
export const version = '1.2.0';
|
|
38
40
|
|
|
41
|
+
// Import for default export
|
|
42
|
+
import { compileProject, compileFile } from './src/client/compiler.js';
|
|
43
|
+
import { compileForBuild } from './src/build/compiler/index.js';
|
|
44
|
+
import { discoverRoutes } from './src/build/compiler/route-discoverer.js';
|
|
45
|
+
import { hmr } from './src/client/hmr-runtime.js';
|
|
46
|
+
import { optimizeImage, optimizeImagesBatch } from './src/image-optimizer/index.js';
|
|
47
|
+
import { optimizeImages } from './src/build/image-optimizer.js';
|
|
48
|
+
import { buildProduction } from './src/build.js';
|
|
49
|
+
import { Router, Link, useRouter } from './src/router/index.js';
|
|
50
|
+
import { SSRRouter } from './src/router/SSRRouter.js';
|
|
51
|
+
import { loadConfig, defaultConfig } from './src/config/index.js';
|
|
52
|
+
import logger from './src/logger/logger.js';
|
|
53
|
+
import { program } from './src/cli.js';
|
|
54
|
+
|
|
39
55
|
// Default export
|
|
40
56
|
export default {
|
|
41
57
|
compileProject,
|
|
58
|
+
compileFile,
|
|
42
59
|
compileForBuild,
|
|
43
60
|
discoverRoutes,
|
|
44
61
|
hmr,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bertui",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.8",
|
|
4
4
|
"description": "Lightning-fast React dev server powered by Bun - Now with Rust image optimization (WASM, no Rust required for users)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
13
|
"types": "./types/index.d.ts",
|
|
14
|
-
"import": "./
|
|
15
|
-
"default": "./
|
|
14
|
+
"import": "./index.js",
|
|
15
|
+
"default": "./index.js"
|
|
16
16
|
},
|
|
17
17
|
"./hmr": {
|
|
18
18
|
"import": "./src/client/hmr-runtime.js"
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"build": "bun bin/bertui.js build",
|
|
48
48
|
"build:wasm": "cd src/image-optimizer-rust && wasm-pack build --target web --out-dir ../../dist/image-optimizer/wasm && bun run fix:wasm",
|
|
49
49
|
"fix:wasm": "node scripts/fix-wasm-exports.js",
|
|
50
|
-
"prepublishOnly": "echo '
|
|
50
|
+
"prepublishOnly": "echo 'Note: Ensure WASM is built via build:wasm before publishing'",
|
|
51
51
|
"test": "cd test-app && bun run dev"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"bun": ">=1.0.0",
|
|
61
61
|
"react": "^18.0.0 || ^19.0.0",
|
|
62
|
-
"react-dom": "^19.
|
|
62
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@types/react": "^18.2.0",
|
|
@@ -94,4 +94,4 @@
|
|
|
94
94
|
"engines": {
|
|
95
95
|
"bun": ">=1.0.0"
|
|
96
96
|
}
|
|
97
|
-
}
|
|
97
|
+
}
|
package/src/client/compiler.js
CHANGED
|
@@ -63,6 +63,49 @@ export async function compileProject(root) {
|
|
|
63
63
|
return { outDir, stats, routes };
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
// NEW EXPORT - Single file compilation for HMR
|
|
67
|
+
export async function compileFile(srcPath, root) {
|
|
68
|
+
const srcDir = join(root, 'src');
|
|
69
|
+
const outDir = join(root, '.bertui', 'compiled');
|
|
70
|
+
const envVars = loadEnvVariables(root);
|
|
71
|
+
|
|
72
|
+
const relativePath = relative(srcDir, srcPath);
|
|
73
|
+
const ext = extname(srcPath);
|
|
74
|
+
|
|
75
|
+
if (!existsSync(outDir)) {
|
|
76
|
+
mkdirSync(outDir, { recursive: true });
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (['.jsx', '.tsx', '.ts'].includes(ext)) {
|
|
80
|
+
const fileName = srcPath.split('/').pop();
|
|
81
|
+
await compileFileInternal(srcPath, outDir, fileName, relativePath, root, envVars);
|
|
82
|
+
return {
|
|
83
|
+
outputPath: relativePath.replace(/\.(jsx|tsx|ts)$/, '.js'),
|
|
84
|
+
success: true
|
|
85
|
+
};
|
|
86
|
+
} else if (ext === '.js') {
|
|
87
|
+
const fileName = srcPath.split('/').pop();
|
|
88
|
+
const outPath = join(outDir, fileName);
|
|
89
|
+
let code = await Bun.file(srcPath).text();
|
|
90
|
+
|
|
91
|
+
code = removeCSSImports(code);
|
|
92
|
+
code = replaceEnvInCode(code, envVars);
|
|
93
|
+
code = fixRouterImports(code, outPath, root);
|
|
94
|
+
|
|
95
|
+
if (usesJSX(code) && !code.includes('import React')) {
|
|
96
|
+
code = `import React from 'react';\n${code}`;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
await Bun.write(outPath, code);
|
|
100
|
+
return {
|
|
101
|
+
outputPath: relativePath,
|
|
102
|
+
success: true
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return { success: false };
|
|
107
|
+
}
|
|
108
|
+
|
|
66
109
|
async function discoverRoutes(pagesDir) {
|
|
67
110
|
const routes = [];
|
|
68
111
|
|
|
@@ -248,7 +291,7 @@ async function compileDirectory(srcDir, outDir, root, envVars) {
|
|
|
248
291
|
logger.debug(`Copied CSS: ${relativePath}`);
|
|
249
292
|
stats.files++;
|
|
250
293
|
} else if (['.jsx', '.tsx', '.ts'].includes(ext)) {
|
|
251
|
-
await
|
|
294
|
+
await compileFileInternal(srcPath, outDir, file, relativePath, root, envVars);
|
|
252
295
|
stats.files++;
|
|
253
296
|
} else if (ext === '.js') {
|
|
254
297
|
const outPath = join(outDir, file);
|
|
@@ -275,7 +318,7 @@ async function compileDirectory(srcDir, outDir, root, envVars) {
|
|
|
275
318
|
return stats;
|
|
276
319
|
}
|
|
277
320
|
|
|
278
|
-
async function
|
|
321
|
+
async function compileFileInternal(srcPath, outDir, filename, relativePath, root, envVars) {
|
|
279
322
|
const ext = extname(filename);
|
|
280
323
|
const loader = ext === '.tsx' ? 'tsx' : ext === '.ts' ? 'ts' : 'jsx';
|
|
281
324
|
|
|
@@ -362,4 +405,4 @@ function fixRelativeImports(code) {
|
|
|
362
405
|
});
|
|
363
406
|
|
|
364
407
|
return code;
|
|
365
|
-
}
|
|
408
|
+
}
|
|
@@ -72,5 +72,32 @@ function detectFormat(buffer) {
|
|
|
72
72
|
return 'unknown';
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
// Batch optimization function
|
|
76
|
+
export async function optimizeImagesBatch(images, format = 'auto', options = {}) {
|
|
77
|
+
const results = [];
|
|
78
|
+
|
|
79
|
+
for (const image of images) {
|
|
80
|
+
try {
|
|
81
|
+
const result = await optimizeImage(image.buffer || image, {
|
|
82
|
+
format,
|
|
83
|
+
...options
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
results.push({
|
|
87
|
+
...result,
|
|
88
|
+
filename: image.filename || image.name || 'unknown'
|
|
89
|
+
});
|
|
90
|
+
} catch (error) {
|
|
91
|
+
results.push({
|
|
92
|
+
filename: image.filename || image.name || 'unknown',
|
|
93
|
+
error: error.message,
|
|
94
|
+
success: false
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return results;
|
|
100
|
+
}
|
|
101
|
+
|
|
75
102
|
export const hasWasm = () => false;
|
|
76
103
|
export const version = '1.1.7';
|
package/src/router/SSRRouter.js
CHANGED
|
@@ -22,7 +22,7 @@ export function useRouter() {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
// ✅ SSR-safe Router component
|
|
25
|
-
export function
|
|
25
|
+
export function SSRRouter({ routes, initialPath = '/' }) {
|
|
26
26
|
const [currentRoute, setCurrentRoute] = useState(null);
|
|
27
27
|
const [params, setParams] = useState({});
|
|
28
28
|
const [isClient, setIsClient] = useState(false);
|
package/src/router/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// bertui/src/router/index.js
|
|
2
|
-
export { Router, Link, useRouter } from './Router.
|
|
3
|
-
export { SSRRouter } from './SSRRouter.
|
|
2
|
+
export { Router, Link, useRouter } from './Router.js';
|
|
3
|
+
export { SSRRouter } from './SSRRouter.js';
|