frontend-hamroun 1.2.10 → 1.2.12

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/bin/cli.mjs CHANGED
@@ -34,7 +34,7 @@ function printBanner() {
34
34
  ${colors.blue}${colors.bright}╔══════════════════════════════════════════════╗
35
35
  ║ ║
36
36
  ║ Frontend Hamroun v${packageJson.version.padEnd(25)}║
37
- ║ A lightweight frontend & backend framework
37
+ ║ A lightweight frontend & backend framework
38
38
  ║ ║
39
39
  ╚══════════════════════════════════════════════╝${colors.reset}
40
40
  `);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "frontend-hamroun",
3
- "version": "1.2.10",
3
+ "version": "1.2.12",
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",
@@ -50,7 +50,7 @@ function printBanner() {
50
50
  \${colors.blue}\${colors.bright}╔══════════════════════════════════════════════╗
51
51
  ║ ║
52
52
  ║ Frontend Hamroun v\${packageJson.version.padEnd(25)}║
53
- ║ A lightweight frontend & backend framework
53
+ ║ A lightweight frontend & backend framework
54
54
  ║ ║
55
55
  ╚══════════════════════════════════════════════╝\${colors.reset}
56
56
  \`);
@@ -732,4 +732,128 @@ export default defineConfig({
732
732
  );
733
733
 
734
734
  console.log(`✅ Created minimal basic template at ${templateDir}`);
735
+
736
+ // Create React compatibility layer
737
+ createReactCompatibilityLayer(templateDir);
735
738
  }
739
+
740
+ // Create React compatibility layer
741
+ function createReactCompatibilityLayer(templateDir) {
742
+ // Create React compatibility directory
743
+ const reactDir = path.join(templateDir, 'src/react');
744
+ if (!fs.existsSync(reactDir)) {
745
+ fs.mkdirSync(reactDir, { recursive: true });
746
+ }
747
+
748
+ // Create jsx-dev-runtime.ts
749
+ fs.writeFileSync(
750
+ path.join(reactDir, 'jsx-dev-runtime.ts'),
751
+ `import { jsx } from 'frontend-hamroun';
752
+
753
+ // Export jsx as jsxDEV for React compatibility
754
+ export const jsxDEV = jsx;
755
+ export const Fragment = Symbol('Fragment');
756
+ export const jsxs = jsx;
757
+
758
+ // Default export
759
+ export default {
760
+ jsxDEV,
761
+ Fragment,
762
+ jsxs
763
+ };`
764
+ );
765
+
766
+ // Create jsx-runtime.ts
767
+ fs.writeFileSync(
768
+ path.join(reactDir, 'jsx-runtime.ts'),
769
+ `import { jsx } from 'frontend-hamroun';
770
+
771
+ // Export jsx functions for React compatibility
772
+ export const jsxs = jsx;
773
+ export const Fragment = Symbol('Fragment');
774
+
775
+ // Default export
776
+ export default {
777
+ jsx,
778
+ jsxs,
779
+ Fragment
780
+ };`
781
+ );
782
+
783
+ // Create index.ts
784
+ fs.writeFileSync(
785
+ path.join(reactDir, 'index.ts'),
786
+ `import {
787
+ useState,
788
+ useEffect,
789
+ useRef,
790
+ useMemo,
791
+ useContext,
792
+ createContext,
793
+ jsx
794
+ } from 'frontend-hamroun';
795
+
796
+ // Provide React compatibility layer
797
+ const React = {
798
+ createElement: jsx,
799
+ Fragment: Symbol('Fragment'),
800
+ useState,
801
+ useEffect,
802
+ useRef,
803
+ useMemo,
804
+ useContext,
805
+ createContext
806
+ };
807
+
808
+ // Export hooks directly for named imports
809
+ export {
810
+ useState,
811
+ useEffect,
812
+ useRef,
813
+ useMemo,
814
+ useContext,
815
+ createContext,
816
+ jsx as createElement
817
+ };
818
+
819
+ // Default export
820
+ export default React;`
821
+ );
822
+
823
+ console.log(`✅ Created React compatibility layer in ${templateDir}`);
824
+ }
825
+
826
+ // Create React compatibility shims
827
+ function createTemplateShims(templateDir) {
828
+ // Create src directory if it doesn't exist
829
+ const srcDir = path.join(templateDir, 'src');
830
+ if (!fs.existsSync(srcDir)) {
831
+ fs.mkdirSync(srcDir, { recursive: true });
832
+ }
833
+
834
+ // Create shims.ts file for React JSX compatibility
835
+ fs.writeFileSync(
836
+ path.join(srcDir, 'shims.ts'),
837
+ `// This file provides compatibility shims for React JSX imports
838
+
839
+ import { jsx } from 'frontend-hamroun';
840
+
841
+ // Export the jsx function as jsxDEV for React compatibility
842
+ export const jsxDEV = jsx;
843
+
844
+ // Export a Fragment symbol
845
+ export const Fragment = Symbol('Fragment');
846
+
847
+ // Default export as React compatibility layer
848
+ export default {
849
+ createElement: jsx,
850
+ Fragment
851
+ };
852
+ `
853
+ );
854
+
855
+ console.log(`✅ Created React compatibility shims in ${templateDir}`);
856
+ }
857
+
858
+ // Call this function when creating templates
859
+ // ...existing code...
@@ -16,5 +16,9 @@
16
16
  "typescript": "^5.3.2",
17
17
  "vite": "^5.0.0",
18
18
  "vite-plugin-node-polyfills": "^0.21.0"
19
+ },
20
+ "overrides": {
21
+ "react": "npm:@empty-npm-package/react@1.0.0",
22
+ "react-dom": "npm:@empty-npm-package/react-dom@1.0.0"
19
23
  }
20
24
  }
@@ -0,0 +1,35 @@
1
+ import {
2
+ useState,
3
+ useEffect,
4
+ useRef,
5
+ useMemo,
6
+ useContext,
7
+ createContext,
8
+ jsx
9
+ } from 'frontend-hamroun';
10
+
11
+ // Provide React compatibility layer
12
+ const React = {
13
+ createElement: jsx,
14
+ Fragment: Symbol('Fragment'),
15
+ useState,
16
+ useEffect,
17
+ useRef,
18
+ useMemo,
19
+ useContext,
20
+ createContext
21
+ };
22
+
23
+ // Export hooks directly for named imports
24
+ export {
25
+ useState,
26
+ useEffect,
27
+ useRef,
28
+ useMemo,
29
+ useContext,
30
+ createContext,
31
+ jsx as createElement
32
+ };
33
+
34
+ // Default export
35
+ export default React;
@@ -0,0 +1,13 @@
1
+ import { jsx } from 'frontend-hamroun';
2
+
3
+ // Export jsx as jsxDEV for React compatibility
4
+ export const jsxDEV = jsx;
5
+ export const Fragment = Symbol('Fragment');
6
+ export const jsxs = jsx;
7
+
8
+ // Default export
9
+ export default {
10
+ jsxDEV,
11
+ Fragment,
12
+ jsxs
13
+ };
@@ -0,0 +1,12 @@
1
+ import { jsx } from 'frontend-hamroun';
2
+
3
+ // Export jsx functions for React compatibility
4
+ export const jsxs = jsx;
5
+ export const Fragment = Symbol('Fragment');
6
+
7
+ // Default export
8
+ export default {
9
+ jsx,
10
+ jsxs,
11
+ Fragment
12
+ };
@@ -0,0 +1,9 @@
1
+ // This file provides compatibility shims for React JSX imports
2
+
3
+ import { jsx } from 'frontend-hamroun';
4
+
5
+ // Export the jsx function as jsxDEV for React compatibility
6
+ export const jsxDEV = jsx;
7
+
8
+ // Export a Fragment symbol
9
+ export const Fragment = Symbol('Fragment');
@@ -1,5 +1,6 @@
1
1
  import { defineConfig } from 'vite';
2
2
  import { nodePolyfills } from 'vite-plugin-node-polyfills';
3
+ import path from 'path';
3
4
 
4
5
  export default defineConfig({
5
6
  build: {
@@ -34,7 +35,8 @@ export default defineConfig({
34
35
  define: {
35
36
  global: 'globalThis'
36
37
  }
37
- }
38
+ },
39
+ include: ['frontend-hamroun']
38
40
  },
39
41
  plugins: [
40
42
  nodePolyfills({
@@ -47,11 +49,11 @@ export default defineConfig({
47
49
  'bcrypt': 'frontend-hamroun',
48
50
  'jsonwebtoken': 'frontend-hamroun',
49
51
  'mongoose': 'frontend-hamroun',
50
- // Alias React imports to empty modules
51
- 'react': 'frontend-hamroun',
52
+ // Map React imports to our compatibility layer
53
+ 'react': path.resolve(__dirname, 'src/react/index.ts'),
52
54
  'react-dom': 'frontend-hamroun',
53
- 'react/jsx-runtime': 'frontend-hamroun',
54
- 'react/jsx-dev-runtime': 'frontend-hamroun'
55
+ 'react/jsx-runtime': path.resolve(__dirname, 'src/react/jsx-runtime.ts'),
56
+ 'react/jsx-dev-runtime': path.resolve(__dirname, 'src/react/jsx-dev-runtime.ts')
55
57
  }
56
58
  }
57
59
  });
@@ -0,0 +1,9 @@
1
+ // This file provides compatibility shims for React JSX imports
2
+
3
+ import { jsx } from 'frontend-hamroun';
4
+
5
+ // Export the jsx function as jsxDEV for React compatibility
6
+ export const jsxDEV = jsx;
7
+
8
+ // Export a Fragment symbol
9
+ export const Fragment = Symbol('Fragment');
@@ -1,5 +1,6 @@
1
1
  import { defineConfig } from 'vite';
2
2
  import { nodePolyfills } from 'vite-plugin-node-polyfills';
3
+ import path from 'path';
3
4
 
4
5
  export default defineConfig({
5
6
  esbuild: {
@@ -74,7 +75,11 @@ export default defineConfig({
74
75
  resolve: {
75
76
  alias: {
76
77
  '@mswjs/interceptors/presets/node': { find: /^@mswjs\/interceptors\/presets\/node/, replacement: '{}' },
77
- './util/nw-pre-gyp/index.html': { find: './util/nw-pre-gyp/index.html', replacement: '{}' }
78
+ './util/nw-pre-gyp/index.html': { find: './util/nw-pre-gyp/index.html', replacement: '{}' },
79
+ 'react/jsx-runtime': path.resolve(__dirname, 'src/shims.ts'),
80
+ 'react/jsx-dev-runtime': path.resolve(__dirname, 'src/shims.ts'),
81
+ 'react': path.resolve(__dirname, 'src/shims.ts'),
82
+ 'react-dom': 'frontend-hamroun'
78
83
  }
79
84
  }
80
85
  });