bertui 1.1.2 → 1.1.3
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/package.json +1 -1
- package/src/build/compiler/file-transpiler.js +44 -48
- package/src/build/generators/html-generator.js +3 -3
- package/src/build.js +19 -28
- package/src/client/compiler.js +7 -13
- package/types/index.d.ts +65 -4
- package/types/react.d.ts +7 -4
package/package.json
CHANGED
|
@@ -1,40 +1,21 @@
|
|
|
1
|
-
// bertui/src/build/compiler/file-transpiler.js -
|
|
1
|
+
// bertui/src/build/compiler/file-transpiler.js - FORCE PRODUCTION JSX
|
|
2
2
|
import { join, relative, dirname, extname } from 'path';
|
|
3
|
-
import { readdirSync, statSync, mkdirSync } from 'fs';
|
|
3
|
+
import { readdirSync, statSync, mkdirSync, writeFileSync } from 'fs';
|
|
4
4
|
import logger from '../../logger/logger.js';
|
|
5
5
|
import { replaceEnvInCode } from '../../utils/env.js';
|
|
6
6
|
|
|
7
|
-
// ✅ CRITICAL FIX: Create transpilers ONCE at module level
|
|
8
|
-
const jsxTranspiler = new Bun.Transpiler({ loader: 'jsx' });
|
|
9
|
-
|
|
10
|
-
const tsxTranspiler = new Bun.Transpiler({
|
|
11
|
-
loader: 'tsx',
|
|
12
|
-
tsconfig: {
|
|
13
|
-
compilerOptions: {
|
|
14
|
-
jsx: 'react',
|
|
15
|
-
jsxFactory: 'React.createElement',
|
|
16
|
-
jsxFragmentFactory: 'React.Fragment'
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
const tsTranspiler = new Bun.Transpiler({
|
|
22
|
-
loader: 'ts',
|
|
23
|
-
tsconfig: {
|
|
24
|
-
compilerOptions: {
|
|
25
|
-
jsx: 'preserve'
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
function getTranspiler(loader) {
|
|
31
|
-
// Just return the pre-created instances
|
|
32
|
-
return loader === 'tsx' ? tsxTranspiler :
|
|
33
|
-
loader === 'ts' ? tsTranspiler :
|
|
34
|
-
jsxTranspiler;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
7
|
export async function compileBuildDirectory(srcDir, buildDir, root, envVars) {
|
|
8
|
+
// Create bunfig.toml in build directory
|
|
9
|
+
const bunfigContent = `
|
|
10
|
+
[build]
|
|
11
|
+
jsx = "react"
|
|
12
|
+
jsxFactory = "React.createElement"
|
|
13
|
+
jsxFragment = "React.Fragment"
|
|
14
|
+
`.trim();
|
|
15
|
+
|
|
16
|
+
writeFileSync(join(buildDir, 'bunfig.toml'), bunfigContent);
|
|
17
|
+
logger.info('Created bunfig.toml for classic JSX');
|
|
18
|
+
|
|
38
19
|
const files = readdirSync(srcDir);
|
|
39
20
|
const filesToCompile = [];
|
|
40
21
|
|
|
@@ -60,20 +41,18 @@ export async function compileBuildDirectory(srcDir, buildDir, root, envVars) {
|
|
|
60
41
|
|
|
61
42
|
if (filesToCompile.length === 0) return;
|
|
62
43
|
|
|
63
|
-
|
|
64
|
-
logger.info(`📦 Compiling ${filesToCompile.length} files sequentially...`);
|
|
44
|
+
logger.info(`📦 Compiling ${filesToCompile.length} files...`);
|
|
65
45
|
|
|
66
46
|
for (let i = 0; i < filesToCompile.length; i++) {
|
|
67
47
|
const file = filesToCompile[i];
|
|
68
48
|
|
|
69
49
|
try {
|
|
70
50
|
if (file.type === 'tsx') {
|
|
71
|
-
await compileBuildFile(file.path, file.dir, file.name, root, envVars);
|
|
51
|
+
await compileBuildFile(file.path, file.dir, file.name, root, envVars, buildDir);
|
|
72
52
|
} else {
|
|
73
53
|
await compileJSFile(file.path, file.dir, file.name, root, envVars);
|
|
74
54
|
}
|
|
75
55
|
|
|
76
|
-
// Progress every 10 files
|
|
77
56
|
if ((i + 1) % 10 === 0 || i === filesToCompile.length - 1) {
|
|
78
57
|
const percent = (((i + 1) / filesToCompile.length) * 100).toFixed(0);
|
|
79
58
|
logger.info(` Progress: ${i + 1}/${filesToCompile.length} (${percent}%)`);
|
|
@@ -81,16 +60,14 @@ export async function compileBuildDirectory(srcDir, buildDir, root, envVars) {
|
|
|
81
60
|
|
|
82
61
|
} catch (error) {
|
|
83
62
|
logger.error(`Failed to compile ${file.name}: ${error.message}`);
|
|
84
|
-
// Continue with other files
|
|
85
63
|
}
|
|
86
64
|
}
|
|
87
65
|
|
|
88
66
|
logger.success(`✅ Compiled ${filesToCompile.length} files`);
|
|
89
67
|
}
|
|
90
68
|
|
|
91
|
-
async function compileBuildFile(srcPath, buildDir, filename, root, envVars) {
|
|
69
|
+
async function compileBuildFile(srcPath, buildDir, filename, root, envVars, configDir) {
|
|
92
70
|
const ext = extname(filename);
|
|
93
|
-
const loader = ext === '.tsx' ? 'tsx' : ext === '.ts' ? 'ts' : 'jsx';
|
|
94
71
|
|
|
95
72
|
try {
|
|
96
73
|
let code = await Bun.file(srcPath).text();
|
|
@@ -101,18 +78,39 @@ async function compileBuildFile(srcPath, buildDir, filename, root, envVars) {
|
|
|
101
78
|
const outPath = join(buildDir, outFilename);
|
|
102
79
|
code = fixBuildImports(code, srcPath, outPath, root);
|
|
103
80
|
|
|
104
|
-
//
|
|
105
|
-
|
|
81
|
+
// Add React import BEFORE transpiling
|
|
82
|
+
if (!code.includes('import React')) {
|
|
83
|
+
code = `import React from 'react';\n${code}`;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Use Bun.Transpiler with explicit production settings
|
|
87
|
+
const transpiler = new Bun.Transpiler({
|
|
88
|
+
loader: ext === '.tsx' ? 'tsx' : ext === '.ts' ? 'ts' : 'jsx',
|
|
89
|
+
target: 'browser',
|
|
90
|
+
define: {
|
|
91
|
+
'process.env.NODE_ENV': '"production"'
|
|
92
|
+
},
|
|
93
|
+
tsconfig: {
|
|
94
|
+
compilerOptions: {
|
|
95
|
+
jsx: 'react',
|
|
96
|
+
jsxFactory: 'React.createElement',
|
|
97
|
+
jsxFragmentFactory: 'React.Fragment',
|
|
98
|
+
target: 'ES2020'
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
106
103
|
let compiled = await transpiler.transform(code);
|
|
107
104
|
|
|
108
|
-
|
|
109
|
-
|
|
105
|
+
// Verify no dev JSX leaked through
|
|
106
|
+
if (compiled.includes('jsxDEV')) {
|
|
107
|
+
logger.warn(`⚠️ Dev JSX detected in ${filename}, fixing...`);
|
|
108
|
+
compiled = compiled.replace(/jsxDEV/g, 'jsx');
|
|
110
109
|
}
|
|
111
110
|
|
|
112
111
|
compiled = fixRelativeImports(compiled);
|
|
113
112
|
await Bun.write(outPath, compiled);
|
|
114
113
|
|
|
115
|
-
// Help GC
|
|
116
114
|
code = null;
|
|
117
115
|
compiled = null;
|
|
118
116
|
|
|
@@ -140,9 +138,7 @@ async function compileJSFile(srcPath, buildDir, filename, root, envVars) {
|
|
|
140
138
|
function usesJSX(code) {
|
|
141
139
|
return code.includes('React.createElement') ||
|
|
142
140
|
code.includes('React.Fragment') ||
|
|
143
|
-
/<[A-Z]/.test(code)
|
|
144
|
-
code.includes('jsx(') ||
|
|
145
|
-
code.includes('jsxs(');
|
|
141
|
+
/<[A-Z]/.test(code);
|
|
146
142
|
}
|
|
147
143
|
|
|
148
144
|
function removeCSSImports(code) {
|
|
@@ -168,4 +164,4 @@ function fixRelativeImports(code) {
|
|
|
168
164
|
return `from '${prefix}${path}.js';`;
|
|
169
165
|
});
|
|
170
166
|
return code;
|
|
171
|
-
}
|
|
167
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// bertui/src/build/generators/html-generator.js - FIXED
|
|
1
|
+
// bertui/src/build/generators/html-generator.js - FIXED JSX RUNTIME
|
|
2
2
|
import { join, relative } from 'path';
|
|
3
3
|
import { mkdirSync, existsSync, cpSync } from 'fs';
|
|
4
4
|
import logger from '../../logger/logger.js';
|
|
@@ -239,7 +239,7 @@ async function extractStaticHTMLFromComponent(sourceCode, filePath) {
|
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
241
|
|
|
242
|
-
// ✅ FIXED: Add
|
|
242
|
+
// ✅ FIXED: Add jsx-runtime to import map
|
|
243
243
|
function generateHTML(meta, route, bundlePath, staticHTML = '', isServerIsland = false, bertuiIconsInstalled = false) {
|
|
244
244
|
const rootContent = staticHTML
|
|
245
245
|
? `<div id="root">${staticHTML}</div>`
|
|
@@ -249,7 +249,7 @@ function generateHTML(meta, route, bundlePath, staticHTML = '', isServerIsland =
|
|
|
249
249
|
? '<!-- 🏝️ Server Island: Static content rendered at build time -->'
|
|
250
250
|
: '<!-- ⚡ Client-only: Content rendered by JavaScript -->';
|
|
251
251
|
|
|
252
|
-
// ✅ FIX: Add
|
|
252
|
+
// ✅ FIX: Add jsx-runtime to import map for production
|
|
253
253
|
const bertuiIconsImport = bertuiIconsInstalled
|
|
254
254
|
? ',\n "bertui-icons": "/node_modules/bertui-icons/generated/index.js"'
|
|
255
255
|
: '';
|
package/src/build.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
// bertui/src/build.js -
|
|
1
|
+
// bertui/src/build.js - FORCE PRODUCTION MODE
|
|
2
2
|
import { join } from 'path';
|
|
3
|
-
import { existsSync, mkdirSync, rmSync } from 'fs';
|
|
3
|
+
import { existsSync, mkdirSync, rmSync, writeFileSync } from 'fs';
|
|
4
4
|
import logger from './logger/logger.js';
|
|
5
5
|
import { loadEnvVariables } from './utils/env.js';
|
|
6
6
|
import { runPageBuilder } from './pagebuilder/core.js';
|
|
7
7
|
|
|
8
|
-
// Import modular components
|
|
9
8
|
import { compileForBuild } from './build/compiler/index.js';
|
|
10
9
|
import { buildAllCSS } from './build/processors/css-builder.js';
|
|
11
10
|
import { copyAllStaticAssets } from './build/processors/asset-processor.js';
|
|
@@ -18,10 +17,12 @@ export async function buildProduction(options = {}) {
|
|
|
18
17
|
const buildDir = join(root, '.bertuibuild');
|
|
19
18
|
const outDir = join(root, 'dist');
|
|
20
19
|
|
|
20
|
+
// Force production environment
|
|
21
|
+
process.env.NODE_ENV = 'production';
|
|
22
|
+
|
|
21
23
|
logger.bigLog('BUILDING WITH SERVER ISLANDS 🏝️', { color: 'green' });
|
|
22
24
|
logger.info('🔥 OPTIONAL SERVER CONTENT - THE GAME CHANGER');
|
|
23
25
|
|
|
24
|
-
// Clean directories
|
|
25
26
|
if (existsSync(buildDir)) rmSync(buildDir, { recursive: true });
|
|
26
27
|
if (existsSync(outDir)) rmSync(outDir, { recursive: true });
|
|
27
28
|
mkdirSync(buildDir, { recursive: true });
|
|
@@ -30,11 +31,9 @@ export async function buildProduction(options = {}) {
|
|
|
30
31
|
const startTime = Date.now();
|
|
31
32
|
|
|
32
33
|
try {
|
|
33
|
-
// Step 0: Environment
|
|
34
34
|
logger.info('Step 0: Loading environment variables...');
|
|
35
35
|
const envVars = loadEnvVariables(root);
|
|
36
36
|
|
|
37
|
-
// Step 0.5: Load config and run Page Builder
|
|
38
37
|
const { loadConfig } = await import('./config/loadConfig.js');
|
|
39
38
|
const config = await loadConfig(root);
|
|
40
39
|
|
|
@@ -43,7 +42,6 @@ export async function buildProduction(options = {}) {
|
|
|
43
42
|
await runPageBuilder(root, config);
|
|
44
43
|
}
|
|
45
44
|
|
|
46
|
-
// Step 1: Compilation
|
|
47
45
|
logger.info('Step 1: Compiling and detecting Server Islands...');
|
|
48
46
|
const { routes, serverIslands, clientRoutes } = await compileForBuild(root, buildDir, envVars);
|
|
49
47
|
|
|
@@ -56,43 +54,33 @@ export async function buildProduction(options = {}) {
|
|
|
56
54
|
})));
|
|
57
55
|
}
|
|
58
56
|
|
|
59
|
-
// Step 2: CSS Processing
|
|
60
57
|
logger.info('Step 2: Combining CSS...');
|
|
61
58
|
await buildAllCSS(root, outDir);
|
|
62
59
|
|
|
63
|
-
// Step 3: Assets
|
|
64
60
|
logger.info('Step 3: Copying static assets...');
|
|
65
61
|
await copyAllStaticAssets(root, outDir);
|
|
66
62
|
|
|
67
|
-
// Step 4: JavaScript Bundling
|
|
68
63
|
logger.info('Step 4: Bundling JavaScript...');
|
|
69
64
|
const buildEntry = join(buildDir, 'main.js');
|
|
70
65
|
|
|
71
|
-
// ✅ CRITICAL FIX: Check if main.js exists before bundling
|
|
72
66
|
if (!existsSync(buildEntry)) {
|
|
73
67
|
logger.error('❌ main.js not found in build directory!');
|
|
74
|
-
|
|
75
|
-
throw new Error('Build entry point missing. Compilation may have failed.');
|
|
68
|
+
throw new Error('Build entry point missing');
|
|
76
69
|
}
|
|
77
70
|
|
|
78
|
-
const result = await bundleJavaScript(buildEntry, outDir, envVars);
|
|
71
|
+
const result = await bundleJavaScript(buildEntry, outDir, envVars, buildDir);
|
|
79
72
|
|
|
80
|
-
// Step 5: HTML Generation
|
|
81
73
|
logger.info('Step 5: Generating HTML with Server Islands...');
|
|
82
74
|
await generateProductionHTML(root, outDir, result, routes, serverIslands, config);
|
|
83
75
|
|
|
84
|
-
// Step 6: Sitemap
|
|
85
76
|
logger.info('Step 6: Generating sitemap.xml...');
|
|
86
77
|
await generateSitemap(routes, config, outDir);
|
|
87
78
|
|
|
88
|
-
// Step 7: Robots.txt
|
|
89
79
|
logger.info('Step 7: Generating robots.txt...');
|
|
90
80
|
await generateRobots(config, outDir, routes);
|
|
91
81
|
|
|
92
|
-
// Cleanup
|
|
93
82
|
if (existsSync(buildDir)) rmSync(buildDir, { recursive: true });
|
|
94
83
|
|
|
95
|
-
// Summary
|
|
96
84
|
const duration = Date.now() - startTime;
|
|
97
85
|
showBuildSummary(routes, serverIslands, clientRoutes, duration);
|
|
98
86
|
|
|
@@ -104,9 +92,14 @@ export async function buildProduction(options = {}) {
|
|
|
104
92
|
}
|
|
105
93
|
}
|
|
106
94
|
|
|
107
|
-
async function bundleJavaScript(buildEntry, outDir, envVars) {
|
|
95
|
+
async function bundleJavaScript(buildEntry, outDir, envVars, buildDir) {
|
|
108
96
|
try {
|
|
109
|
-
//
|
|
97
|
+
// Change to build directory where bunfig.toml is
|
|
98
|
+
const originalCwd = process.cwd();
|
|
99
|
+
process.chdir(buildDir);
|
|
100
|
+
|
|
101
|
+
logger.info('🔧 Bundling with production JSX...');
|
|
102
|
+
|
|
110
103
|
const result = await Bun.build({
|
|
111
104
|
entrypoints: [buildEntry],
|
|
112
105
|
outdir: join(outDir, 'assets'),
|
|
@@ -119,8 +112,7 @@ async function bundleJavaScript(buildEntry, outDir, envVars) {
|
|
|
119
112
|
chunk: 'chunks/[name]-[hash].js',
|
|
120
113
|
asset: '[name]-[hash].[ext]'
|
|
121
114
|
},
|
|
122
|
-
|
|
123
|
-
external: ['react', 'react-dom', 'react-dom/client', 'react/jsx-runtime'],
|
|
115
|
+
external: ['react', 'react-dom', 'react-dom/client'],
|
|
124
116
|
define: {
|
|
125
117
|
'process.env.NODE_ENV': '"production"',
|
|
126
118
|
...Object.fromEntries(
|
|
@@ -132,10 +124,11 @@ async function bundleJavaScript(buildEntry, outDir, envVars) {
|
|
|
132
124
|
}
|
|
133
125
|
});
|
|
134
126
|
|
|
127
|
+
process.chdir(originalCwd);
|
|
128
|
+
|
|
135
129
|
if (!result.success) {
|
|
136
130
|
logger.error('❌ JavaScript build failed!');
|
|
137
131
|
|
|
138
|
-
// ✅ IMPROVED: Better error reporting
|
|
139
132
|
if (result.logs && result.logs.length > 0) {
|
|
140
133
|
logger.error('\n📋 Build errors:');
|
|
141
134
|
result.logs.forEach((log, i) => {
|
|
@@ -147,10 +140,9 @@ async function bundleJavaScript(buildEntry, outDir, envVars) {
|
|
|
147
140
|
});
|
|
148
141
|
}
|
|
149
142
|
|
|
150
|
-
throw new Error('JavaScript bundling failed
|
|
143
|
+
throw new Error('JavaScript bundling failed');
|
|
151
144
|
}
|
|
152
145
|
|
|
153
|
-
// ✅ IMPROVED: Log successful bundle info
|
|
154
146
|
logger.success('✅ JavaScript bundled successfully');
|
|
155
147
|
logger.info(` Entry points: ${result.outputs.filter(o => o.kind === 'entry-point').length}`);
|
|
156
148
|
logger.info(` Chunks: ${result.outputs.filter(o => o.kind === 'chunk').length}`);
|
|
@@ -162,7 +154,6 @@ async function bundleJavaScript(buildEntry, outDir, envVars) {
|
|
|
162
154
|
|
|
163
155
|
} catch (error) {
|
|
164
156
|
logger.error('❌ Bundling error: ' + error.message);
|
|
165
|
-
if (error.stack) logger.error(error.stack);
|
|
166
157
|
throw error;
|
|
167
158
|
}
|
|
168
159
|
}
|
|
@@ -181,4 +172,4 @@ function showBuildSummary(routes, serverIslands, clientRoutes, duration) {
|
|
|
181
172
|
}
|
|
182
173
|
|
|
183
174
|
logger.bigLog('READY TO DEPLOY 🚀', { color: 'green' });
|
|
184
|
-
}
|
|
175
|
+
}
|
package/src/client/compiler.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// bertui/src/client/compiler.js - FIXED
|
|
1
|
+
// bertui/src/client/compiler.js - FIXED JSX FOR DEV
|
|
2
2
|
import { existsSync, mkdirSync, readdirSync, statSync } from 'fs';
|
|
3
3
|
import { join, extname, relative, dirname } from 'path';
|
|
4
4
|
import logger from '../logger/logger.js';
|
|
@@ -295,23 +295,21 @@ async function compileFile(srcPath, outDir, filename, relativePath, root, envVar
|
|
|
295
295
|
const outPath = join(outDir, filename.replace(/\.(jsx|tsx|ts)$/, '.js'));
|
|
296
296
|
code = fixRouterImports(code, outPath, root);
|
|
297
297
|
|
|
298
|
+
// ✅ FIXED: Use automatic JSX runtime for dev too
|
|
298
299
|
const transpiler = new Bun.Transpiler({
|
|
299
300
|
loader,
|
|
301
|
+
jsxImportSource: 'react',
|
|
300
302
|
tsconfig: {
|
|
301
303
|
compilerOptions: {
|
|
302
|
-
jsx: 'react',
|
|
303
|
-
|
|
304
|
-
jsxFragmentFactory: 'React.Fragment'
|
|
304
|
+
jsx: loader === 'ts' ? 'preserve' : 'react-jsx',
|
|
305
|
+
jsxImportSource: 'react'
|
|
305
306
|
}
|
|
306
307
|
}
|
|
307
308
|
});
|
|
308
309
|
let compiled = await transpiler.transform(code);
|
|
309
310
|
|
|
310
|
-
|
|
311
|
-
compiled = `import React from 'react';\n${compiled}`;
|
|
312
|
-
}
|
|
311
|
+
// ✅ REMOVED: Don't manually add React for automatic runtime
|
|
313
312
|
|
|
314
|
-
// ✅ CRITICAL FIX: Don't touch node_modules imports
|
|
315
313
|
compiled = fixRelativeImports(compiled);
|
|
316
314
|
|
|
317
315
|
await Bun.write(outPath, compiled);
|
|
@@ -359,11 +357,7 @@ function fixRouterImports(code, outPath, root) {
|
|
|
359
357
|
}
|
|
360
358
|
|
|
361
359
|
function fixRelativeImports(code) {
|
|
362
|
-
// ✅ CRITICAL FIX: Only fix relative imports, NOT bare specifiers
|
|
363
|
-
// Regex explanation:
|
|
364
|
-
// - Match: from './file' or from '../file'
|
|
365
|
-
// - DON'T match: from 'bertui-icons' or from 'react'
|
|
366
|
-
|
|
360
|
+
// ✅ CRITICAL FIX: Only fix relative imports, NOT bare specifiers
|
|
367
361
|
const importRegex = /from\s+['"](\.\.?\/[^'"]+?)(?<!\.js|\.jsx|\.ts|\.tsx|\.json)['"]/g;
|
|
368
362
|
|
|
369
363
|
code = code.replace(importRegex, (match, path) => {
|
package/types/index.d.ts
CHANGED
|
@@ -1,19 +1,80 @@
|
|
|
1
1
|
// bertui/types/index.d.ts
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
3
|
+
// Import React types
|
|
4
|
+
import React from 'react';
|
|
6
5
|
|
|
7
6
|
declare global {
|
|
7
|
+
// Global React namespace
|
|
8
|
+
namespace React {
|
|
9
|
+
type ReactNode = import('react').ReactNode;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// JSX namespace
|
|
8
13
|
namespace JSX {
|
|
9
|
-
type Element =
|
|
14
|
+
type Element = React.ReactElement;
|
|
15
|
+
interface ElementClass extends React.Component<any> {
|
|
16
|
+
render(): React.ReactNode;
|
|
17
|
+
}
|
|
18
|
+
interface ElementAttributesProperty {
|
|
19
|
+
props: {};
|
|
20
|
+
}
|
|
21
|
+
interface ElementChildrenAttribute {
|
|
22
|
+
children: {};
|
|
23
|
+
}
|
|
24
|
+
|
|
10
25
|
interface IntrinsicElements {
|
|
26
|
+
// HTML elements
|
|
27
|
+
a: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>;
|
|
28
|
+
div: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
|
|
29
|
+
span: React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>;
|
|
30
|
+
h1: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
|
|
31
|
+
h2: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
|
|
32
|
+
h3: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
|
|
33
|
+
h4: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
|
|
34
|
+
h5: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
|
|
35
|
+
h6: React.DetailedHTMLProps<React.HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>;
|
|
36
|
+
p: React.DetailedHTMLProps<React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement>;
|
|
37
|
+
img: React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>;
|
|
38
|
+
button: React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>;
|
|
39
|
+
input: React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
|
40
|
+
textarea: React.DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>;
|
|
41
|
+
form: React.DetailedHTMLProps<React.FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>;
|
|
42
|
+
label: React.DetailedHTMLProps<React.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>;
|
|
43
|
+
select: React.DetailedHTMLProps<React.SelectHTMLAttributes<HTMLSelectElement>, HTMLSelectElement>;
|
|
44
|
+
option: React.DetailedHTMLProps<React.OptionHTMLAttributes<HTMLOptionElement>, HTMLOptionElement>;
|
|
45
|
+
ul: React.DetailedHTMLProps<React.HTMLAttributes<HTMLUListElement>, HTMLUListElement>;
|
|
46
|
+
ol: React.DetailedHTMLProps<React.HTMLAttributes<HTMLOListElement>, HTMLOListElement>;
|
|
47
|
+
li: React.DetailedHTMLProps<React.HTMLAttributes<HTMLLIElement>, HTMLLIElement>;
|
|
48
|
+
table: React.DetailedHTMLProps<React.TableHTMLAttributes<HTMLTableElement>, HTMLTableElement>;
|
|
49
|
+
tr: React.DetailedHTMLProps<React.HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>;
|
|
50
|
+
td: React.DetailedHTMLProps<React.TdHTMLAttributes<HTMLTableDataCellElement>, HTMLTableDataCellElement>;
|
|
51
|
+
th: React.DetailedHTMLProps<React.ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>;
|
|
52
|
+
header: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
53
|
+
footer: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
54
|
+
nav: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
55
|
+
main: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
56
|
+
section: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
57
|
+
article: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
58
|
+
aside: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
59
|
+
|
|
60
|
+
// SVG elements
|
|
61
|
+
svg: React.SVGProps<SVGSVGElement>;
|
|
62
|
+
path: React.SVGProps<SVGPathElement>;
|
|
63
|
+
circle: React.SVGProps<SVGCircleElement>;
|
|
64
|
+
rect: React.SVGProps<SVGRectElement>;
|
|
65
|
+
|
|
66
|
+
// Allow any other element with generic props
|
|
11
67
|
[elemName: string]: any;
|
|
12
68
|
}
|
|
13
69
|
}
|
|
70
|
+
|
|
71
|
+
// Global React variable for JSX transform
|
|
72
|
+
const React: typeof import('react');
|
|
14
73
|
}
|
|
74
|
+
|
|
15
75
|
declare module 'bertui' {
|
|
16
76
|
import { BertuiConfig } from 'bertui/config';
|
|
77
|
+
import React from 'react';
|
|
17
78
|
|
|
18
79
|
/**
|
|
19
80
|
* Logger utility
|
package/types/react.d.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
// bertui/types/react.d.ts
|
|
2
2
|
import React from 'react';
|
|
3
3
|
|
|
4
|
+
// Export everything from React
|
|
5
|
+
export = React;
|
|
6
|
+
export as namespace React;
|
|
7
|
+
|
|
4
8
|
declare global {
|
|
9
|
+
// Re-export React types for global access
|
|
5
10
|
namespace JSX {
|
|
6
11
|
interface IntrinsicElements {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
HTMLElement
|
|
10
|
-
>;
|
|
12
|
+
// All HTML elements with proper typing
|
|
13
|
+
[key: string]: any;
|
|
11
14
|
}
|
|
12
15
|
}
|
|
13
16
|
}
|