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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "frontend-hamroun",
3
- "version": "1.2.6",
3
+ "version": "1.2.8",
4
4
  "description": "A lightweight frontend and backend framework for building modern web applications",
5
5
  "type": "module",
6
6
  "main": "dist/frontend-hamroun.umd.js",
@@ -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
- "jsx": "preserve",
7
+ "skipLibCheck": true,
7
8
  "moduleResolution": "bundler",
8
- "esModuleInterop": true,
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
- "skipLibCheck": true
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
- export function App({ api }: AppProps) {
13
- const [todos, setTodos] = useState([]);
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 { theme } = useContext(AppContext);
18
-
19
- useEffect(() => {
20
- // Fetch data when component mounts
21
- async function fetchData() {
22
- try {
23
- setIsLoading(true);
24
- const data = await api.getTodos();
25
- setTodos(data);
26
- setError(null);
27
- } catch (err) {
28
- setError('Failed to fetch todos');
29
- console.error(err);
30
- } finally {
31
- setIsLoading(false);
32
- }
33
- }
34
-
35
- fetchData();
36
- }, [api]);
37
-
38
- return (
39
- <div className="min-h-screen bg-gray-50">
40
- <Header title="My Front Package App" />
41
-
42
- <main className="container mx-auto px-4 py-8">
43
- <h1 className="text-3xl font-bold text-center mb-8">
44
- Welcome to your Front Package app!
45
- </h1>
46
-
47
- <div className="max-w-md mx-auto bg-white rounded-xl shadow-md overflow-hidden md:max-w-2xl mb-8">
48
- <div className="p-8">
49
- <Counter />
50
- </div>
51
- </div>
52
-
53
- <div className="max-w-md mx-auto bg-white rounded-xl shadow-md overflow-hidden md:max-w-2xl">
54
- <div className="p-8">
55
- <h2 className="text-xl font-bold mb-4">Todo List</h2>
56
- {isLoading ? (
57
- <div className="text-center py-4">Loading...</div>
58
- ) : error ? (
59
- <div className="text-red-500 py-4">{error}</div>
60
- ) : (
61
- <TodoList todos={todos} api={api} setTodos={setTodos} />
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
- background: '#ff4d4d',
61
+ backgroundColor: '#4b5563',
90
62
  color: 'white',
91
63
  border: 'none',
92
64
  borderRadius: '4px',
93
65
  cursor: 'pointer'
94
- }}
95
- >
96
- Decrement
97
- </button>
98
- <button
99
- onClick={() => setCount(count + 1)}
100
- style={{
101
- padding: '8px 16px',
102
- background: '#4d79ff',
103
- color: 'white',
104
- border: 'none',
105
- borderRadius: '4px',
106
- cursor: 'pointer'
107
- }}
108
- >
109
- Increment
110
- </button>
111
- </div>
112
- </div>
113
- </div>
114
- </main>
115
- </div>
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, createContext } from 'frontend-hamroun';
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
- "jsx": "preserve",
7
+ "skipLibCheck": true,
7
8
  "moduleResolution": "bundler",
8
- "esModuleInterop": true,
9
+ "allowImportingTsExtensions": true,
10
+ "resolveJsonModule": true,
11
+ "isolatedModules": true,
12
+ "noEmit": true,
9
13
  "strict": true,
10
- "skipLibCheck": true
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": "ES2018",
3
+ "target": "ES2020",
4
+ "useDefineForClassFields": true,
4
5
  "module": "ESNext",
5
- "moduleResolution": "node",
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
- "forceConsistentCasingInFileNames": true,
13
- "lib": ["dom", "dom.iterable", "esnext"],
14
- "allowJs": true,
15
- "noEmit": true,
16
- "isolatedModules": true,
8
+ "moduleResolution": "bundler",
9
+ "allowImportingTsExtensions": true,
17
10
  "resolveJsonModule": true,
18
- "outDir": "dist"
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/client/**/*"],
21
- "exclude": ["node_modules", "dist"]
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',