frontend-hamroun 1.2.6 → 1.2.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/package.json +1 -1
- package/templates/basic/tsconfig.json +14 -4
- package/templates/basic-app/src/App.tsx +126 -100
- package/templates/basic-app/src/main.tsx +2 -10
- package/templates/basic-app/tsconfig.json +11 -4
- package/templates/basic-app/vite.config.ts +4 -15
- package/templates/full-stack/tsconfig.json +16 -15
- package/templates/full-stack/vite.config.ts +2 -1
package/package.json
CHANGED
@@ -1,13 +1,23 @@
|
|
1
1
|
{
|
2
2
|
"compilerOptions": {
|
3
3
|
"target": "ES2020",
|
4
|
+
"useDefineForClassFields": true,
|
4
5
|
"module": "ESNext",
|
5
6
|
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
6
|
-
"
|
7
|
+
"skipLibCheck": true,
|
7
8
|
"moduleResolution": "bundler",
|
8
|
-
"
|
9
|
+
"allowImportingTsExtensions": true,
|
10
|
+
"resolveJsonModule": true,
|
11
|
+
"isolatedModules": true,
|
12
|
+
"noEmit": true,
|
13
|
+
"jsx": "react-jsx",
|
14
|
+
"jsxFactory": "jsx",
|
15
|
+
"jsxFragmentFactory": "Fragment",
|
9
16
|
"strict": true,
|
10
|
-
"
|
17
|
+
"noUnusedLocals": true,
|
18
|
+
"noUnusedParameters": true,
|
19
|
+
"noFallthroughCasesInSwitch": true
|
11
20
|
},
|
12
|
-
"include": ["src"]
|
21
|
+
"include": ["src"],
|
22
|
+
"references": [{ "path": "./tsconfig.node.json" }]
|
13
23
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { useState, useEffect, useContext } from 'frontend-hamroun';
|
1
|
+
import { useState, useEffect, useContext, useRef } from 'frontend-hamroun';
|
2
2
|
import { Header } from './components/Header';
|
3
3
|
import { Counter } from './components/Counter';
|
4
4
|
import { ApiClient } from './api.js';
|
@@ -9,109 +9,135 @@ interface AppProps {
|
|
9
9
|
api: ApiClient;
|
10
10
|
}
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
const [isLoading, setIsLoading] = useState(true);
|
15
|
-
const [error, setError] = useState<string | null>(null);
|
12
|
+
// Use function declaration style instead of JSX component syntax
|
13
|
+
export function App(props: any) {
|
16
14
|
const [count, setCount] = useState(0);
|
17
|
-
const
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
)}
|
63
|
-
</div>
|
64
|
-
</div>
|
65
|
-
|
66
|
-
<div style={{ fontFamily: 'Arial, sans-serif', maxWidth: '600px', margin: '0 auto', padding: '2rem' }}>
|
67
|
-
<h1 style={{ color: '#333', textAlign: 'center' }}>Frontend Hamroun App</h1>
|
68
|
-
<p style={{ textAlign: 'center' }}>
|
69
|
-
Current theme: <strong>{theme}</strong>
|
70
|
-
</p>
|
71
|
-
<div style={{
|
72
|
-
display: 'flex',
|
73
|
-
flexDirection: 'column',
|
74
|
-
alignItems: 'center',
|
75
|
-
marginTop: '2rem',
|
76
|
-
padding: '1rem',
|
77
|
-
border: '1px solid #ccc',
|
78
|
-
borderRadius: '8px',
|
79
|
-
backgroundColor: theme === 'dark' ? '#333' : '#fff',
|
80
|
-
color: theme === 'dark' ? '#fff' : '#333'
|
81
|
-
}}>
|
82
|
-
<h2>Counter Example</h2>
|
83
|
-
<p>Count: {count}</p>
|
84
|
-
<div style={{ display: 'flex', gap: '8px' }}>
|
85
|
-
<button
|
86
|
-
onClick={() => setCount(count - 1)}
|
87
|
-
style={{
|
15
|
+
const [theme, setTheme] = useState('light');
|
16
|
+
const renderCount = useRef(0);
|
17
|
+
|
18
|
+
renderCount.current++;
|
19
|
+
|
20
|
+
// Return a standard object structure rather than JSX
|
21
|
+
return {
|
22
|
+
type: 'div',
|
23
|
+
props: {
|
24
|
+
style: {
|
25
|
+
fontFamily: 'Arial, sans-serif',
|
26
|
+
maxWidth: '600px',
|
27
|
+
margin: '0 auto',
|
28
|
+
padding: '2rem',
|
29
|
+
backgroundColor: theme === 'dark' ? '#222' : '#fff',
|
30
|
+
color: theme === 'dark' ? '#fff' : '#222'
|
31
|
+
},
|
32
|
+
children: [
|
33
|
+
{
|
34
|
+
type: 'h1',
|
35
|
+
props: {
|
36
|
+
style: { textAlign: 'center' },
|
37
|
+
children: 'Frontend Hamroun App'
|
38
|
+
}
|
39
|
+
},
|
40
|
+
{
|
41
|
+
type: 'p',
|
42
|
+
props: {
|
43
|
+
style: { textAlign: 'center' },
|
44
|
+
children: `This component has rendered ${renderCount.current} times`
|
45
|
+
}
|
46
|
+
},
|
47
|
+
{
|
48
|
+
type: 'div',
|
49
|
+
props: {
|
50
|
+
style: {
|
51
|
+
display: 'flex',
|
52
|
+
justifyContent: 'center',
|
53
|
+
marginBottom: '1rem'
|
54
|
+
},
|
55
|
+
children: {
|
56
|
+
type: 'button',
|
57
|
+
props: {
|
58
|
+
onClick: () => setTheme(theme === 'light' ? 'dark' : 'light'),
|
59
|
+
style: {
|
88
60
|
padding: '8px 16px',
|
89
|
-
|
61
|
+
backgroundColor: '#4b5563',
|
90
62
|
color: 'white',
|
91
63
|
border: 'none',
|
92
64
|
borderRadius: '4px',
|
93
65
|
cursor: 'pointer'
|
94
|
-
}
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
66
|
+
},
|
67
|
+
children: `Switch to ${theme === 'light' ? 'dark' : 'light'} mode`
|
68
|
+
}
|
69
|
+
}
|
70
|
+
}
|
71
|
+
},
|
72
|
+
{
|
73
|
+
type: 'div',
|
74
|
+
props: {
|
75
|
+
style: {
|
76
|
+
display: 'flex',
|
77
|
+
flexDirection: 'column',
|
78
|
+
alignItems: 'center',
|
79
|
+
padding: '1rem',
|
80
|
+
border: '1px solid #ccc',
|
81
|
+
borderRadius: '8px'
|
82
|
+
},
|
83
|
+
children: [
|
84
|
+
{
|
85
|
+
type: 'h2',
|
86
|
+
props: {
|
87
|
+
children: 'Counter Example'
|
88
|
+
}
|
89
|
+
},
|
90
|
+
{
|
91
|
+
type: 'p',
|
92
|
+
props: {
|
93
|
+
children: `Count: ${count}`
|
94
|
+
}
|
95
|
+
},
|
96
|
+
{
|
97
|
+
type: 'div',
|
98
|
+
props: {
|
99
|
+
style: {
|
100
|
+
display: 'flex',
|
101
|
+
gap: '8px'
|
102
|
+
},
|
103
|
+
children: [
|
104
|
+
{
|
105
|
+
type: 'button',
|
106
|
+
props: {
|
107
|
+
onClick: () => setCount(count - 1),
|
108
|
+
style: {
|
109
|
+
padding: '8px 16px',
|
110
|
+
backgroundColor: '#ff4d4d',
|
111
|
+
color: 'white',
|
112
|
+
border: 'none',
|
113
|
+
borderRadius: '4px',
|
114
|
+
cursor: 'pointer'
|
115
|
+
},
|
116
|
+
children: 'Decrement'
|
117
|
+
}
|
118
|
+
},
|
119
|
+
{
|
120
|
+
type: 'button',
|
121
|
+
props: {
|
122
|
+
onClick: () => setCount(count + 1),
|
123
|
+
style: {
|
124
|
+
padding: '8px 16px',
|
125
|
+
backgroundColor: '#4d79ff',
|
126
|
+
color: 'white',
|
127
|
+
border: 'none',
|
128
|
+
borderRadius: '4px',
|
129
|
+
cursor: 'pointer'
|
130
|
+
},
|
131
|
+
children: 'Increment'
|
132
|
+
}
|
133
|
+
}
|
134
|
+
]
|
135
|
+
}
|
136
|
+
}
|
137
|
+
]
|
138
|
+
}
|
139
|
+
}
|
140
|
+
]
|
141
|
+
}
|
142
|
+
};
|
117
143
|
}
|
@@ -141,21 +141,13 @@ function ContextConsumer() {
|
|
141
141
|
);
|
142
142
|
}
|
143
143
|
|
144
|
-
import { render
|
144
|
+
import { render } from 'frontend-hamroun';
|
145
145
|
import { App } from './App';
|
146
146
|
|
147
|
-
// Create an example context
|
148
|
-
export const AppContext = createContext({ theme: 'light' });
|
149
|
-
|
150
147
|
document.addEventListener('DOMContentLoaded', () => {
|
151
148
|
const rootElement = document.getElementById('app');
|
152
149
|
if (rootElement) {
|
153
|
-
render(
|
154
|
-
<AppContext.Provider value={{ theme: 'light' }}>
|
155
|
-
<App />
|
156
|
-
</AppContext.Provider>,
|
157
|
-
rootElement
|
158
|
-
);
|
150
|
+
render(App({}), rootElement);
|
159
151
|
console.log('App rendered successfully');
|
160
152
|
}
|
161
153
|
});
|
@@ -1,13 +1,20 @@
|
|
1
1
|
{
|
2
2
|
"compilerOptions": {
|
3
3
|
"target": "ES2020",
|
4
|
+
"useDefineForClassFields": true,
|
4
5
|
"module": "ESNext",
|
5
6
|
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
6
|
-
"
|
7
|
+
"skipLibCheck": true,
|
7
8
|
"moduleResolution": "bundler",
|
8
|
-
"
|
9
|
+
"allowImportingTsExtensions": true,
|
10
|
+
"resolveJsonModule": true,
|
11
|
+
"isolatedModules": true,
|
12
|
+
"noEmit": true,
|
9
13
|
"strict": true,
|
10
|
-
"
|
14
|
+
"noUnusedLocals": true,
|
15
|
+
"noUnusedParameters": true,
|
16
|
+
"noFallthroughCasesInSwitch": true
|
11
17
|
},
|
12
|
-
"include": ["src"]
|
18
|
+
"include": ["src"],
|
19
|
+
"references": [{ "path": "./tsconfig.node.json" }]
|
13
20
|
}
|
@@ -2,30 +2,19 @@ import { defineConfig } from 'vite';
|
|
2
2
|
import { nodePolyfills } from 'vite-plugin-node-polyfills';
|
3
3
|
|
4
4
|
export default defineConfig({
|
5
|
-
esbuild: {
|
6
|
-
jsxFactory: 'jsx',
|
7
|
-
jsxFragment: 'Fragment'
|
8
|
-
},
|
9
5
|
build: {
|
10
6
|
outDir: 'dist',
|
11
7
|
emptyOutDir: true,
|
12
8
|
rollupOptions: {
|
13
|
-
// Mark server dependencies as external
|
9
|
+
// Mark server-side dependencies as external
|
14
10
|
external: [
|
15
|
-
'mock-aws-s3',
|
16
|
-
'aws-sdk',
|
17
|
-
'nock',
|
18
|
-
'jest',
|
19
|
-
'jest-mock',
|
20
|
-
'@testing-library/react',
|
21
|
-
'@testing-library/jest-dom',
|
22
|
-
'bcrypt',
|
23
|
-
'jsonwebtoken',
|
24
|
-
'mongoose',
|
25
11
|
'express',
|
26
12
|
'compression',
|
27
13
|
'helmet',
|
28
14
|
'morgan',
|
15
|
+
'bcrypt',
|
16
|
+
'jsonwebtoken',
|
17
|
+
'mongoose',
|
29
18
|
/node:.*/
|
30
19
|
]
|
31
20
|
}
|
@@ -1,22 +1,23 @@
|
|
1
1
|
{
|
2
2
|
"compilerOptions": {
|
3
|
-
"target": "
|
3
|
+
"target": "ES2020",
|
4
|
+
"useDefineForClassFields": true,
|
4
5
|
"module": "ESNext",
|
5
|
-
"
|
6
|
-
"jsx": "react",
|
7
|
-
"jsxFactory": "createElement",
|
8
|
-
"jsxFragmentFactory": "Fragment",
|
9
|
-
"strict": true,
|
10
|
-
"esModuleInterop": true,
|
6
|
+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
11
7
|
"skipLibCheck": true,
|
12
|
-
"
|
13
|
-
"
|
14
|
-
"allowJs": true,
|
15
|
-
"noEmit": true,
|
16
|
-
"isolatedModules": true,
|
8
|
+
"moduleResolution": "bundler",
|
9
|
+
"allowImportingTsExtensions": true,
|
17
10
|
"resolveJsonModule": true,
|
18
|
-
"
|
11
|
+
"isolatedModules": true,
|
12
|
+
"noEmit": true,
|
13
|
+
"jsx": "react-jsx",
|
14
|
+
"jsxFactory": "jsx",
|
15
|
+
"jsxFragmentFactory": "Fragment",
|
16
|
+
"strict": true,
|
17
|
+
"noUnusedLocals": true,
|
18
|
+
"noUnusedParameters": true,
|
19
|
+
"noFallthroughCasesInSwitch": true
|
19
20
|
},
|
20
|
-
"include": ["src
|
21
|
-
"
|
21
|
+
"include": ["src"],
|
22
|
+
"references": [{ "path": "./tsconfig.node.json" }]
|
22
23
|
}
|
@@ -4,7 +4,8 @@ import { nodePolyfills } from 'vite-plugin-node-polyfills';
|
|
4
4
|
export default defineConfig({
|
5
5
|
esbuild: {
|
6
6
|
jsxFactory: 'jsx',
|
7
|
-
jsxFragment: 'Fragment'
|
7
|
+
jsxFragment: 'Fragment',
|
8
|
+
jsxInject: `import { jsx, Fragment } from 'frontend-hamroun'`
|
8
9
|
},
|
9
10
|
build: {
|
10
11
|
outDir: 'dist',
|