frontend-hamroun 1.2.8 → 1.2.9

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.8",
3
+ "version": "1.2.9",
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",
@@ -491,3 +491,245 @@ fs.chmodSync(path.join(binDir, 'cli.cjs'), '755');
491
491
  console.log('✅ Created CJS wrapper: bin/cli.cjs');
492
492
 
493
493
  console.log('✅ CLI build process completed');
494
+
495
+ // Create a minimal basic template (update existing code)
496
+ function createBasicTemplate(templateDir) {
497
+ console.log(`📝 Creating minimal basic template at ${templateDir}`);
498
+
499
+ // Create package.json
500
+ const packageJson = {
501
+ "name": "frontend-hamroun-app",
502
+ "private": true,
503
+ "version": "0.1.0",
504
+ "type": "module",
505
+ "scripts": {
506
+ "dev": "vite",
507
+ "build": "tsc && vite build",
508
+ "preview": "vite preview"
509
+ },
510
+ "dependencies": {
511
+ "frontend-hamroun": "latest"
512
+ },
513
+ "devDependencies": {
514
+ "@types/node": "^20.10.0",
515
+ "typescript": "^5.3.2",
516
+ "vite": "^5.0.0",
517
+ "vite-plugin-node-polyfills": "^0.21.0"
518
+ }
519
+ };
520
+
521
+ fs.writeFileSync(
522
+ path.join(templateDir, 'package.json'),
523
+ JSON.stringify(packageJson, null, 2)
524
+ );
525
+
526
+ // Create index.html
527
+ fs.writeFileSync(
528
+ path.join(templateDir, 'index.html'),
529
+ `<!DOCTYPE html>
530
+ <html lang="en">
531
+ <head>
532
+ <meta charset="UTF-8">
533
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
534
+ <title>Frontend Hamroun App</title>
535
+ </head>
536
+ <body>
537
+ <div id="app"></div>
538
+ <script type="module" src="/src/main.ts"></script>
539
+ </body>
540
+ </html>`
541
+ );
542
+
543
+ // Create src directory
544
+ const srcDir = path.join(templateDir, 'src');
545
+ fs.mkdirSync(srcDir, { recursive: true });
546
+
547
+ // Create main.ts
548
+ fs.writeFileSync(
549
+ path.join(srcDir, 'main.ts'),
550
+ `import { render } from 'frontend-hamroun';
551
+ import { App } from './App';
552
+
553
+ document.addEventListener('DOMContentLoaded', () => {
554
+ const rootElement = document.getElementById('app');
555
+ if (rootElement) {
556
+ render(App({}), rootElement);
557
+ console.log('App rendered successfully');
558
+ }
559
+ });`
560
+ );
561
+
562
+ // Create App.ts (not App.tsx)
563
+ fs.writeFileSync(
564
+ path.join(srcDir, 'App.ts'),
565
+ `import { useState, useRef } from 'frontend-hamroun';
566
+
567
+ export function App(props) {
568
+ const [count, setCount] = useState(0);
569
+ const renderCount = useRef(0);
570
+
571
+ renderCount.current++;
572
+
573
+ return {
574
+ type: 'div',
575
+ props: {
576
+ style: {
577
+ fontFamily: 'Arial, sans-serif',
578
+ maxWidth: '600px',
579
+ margin: '0 auto',
580
+ padding: '2rem'
581
+ },
582
+ children: [
583
+ {
584
+ type: 'h1',
585
+ props: {
586
+ style: { textAlign: 'center' },
587
+ children: 'Frontend Hamroun App'
588
+ }
589
+ },
590
+ {
591
+ type: 'p',
592
+ props: {
593
+ style: { textAlign: 'center' },
594
+ children: \`Render count: \${renderCount.current}\`
595
+ }
596
+ },
597
+ {
598
+ type: 'div',
599
+ props: {
600
+ style: {
601
+ display: 'flex',
602
+ flexDirection: 'column',
603
+ alignItems: 'center',
604
+ padding: '1rem',
605
+ border: '1px solid #ccc',
606
+ borderRadius: '8px'
607
+ },
608
+ children: [
609
+ {
610
+ type: 'h2',
611
+ props: {
612
+ children: 'Counter Example'
613
+ }
614
+ },
615
+ {
616
+ type: 'p',
617
+ props: {
618
+ children: \`Count: \${count}\`
619
+ }
620
+ },
621
+ {
622
+ type: 'div',
623
+ props: {
624
+ style: {
625
+ display: 'flex',
626
+ gap: '8px'
627
+ },
628
+ children: [
629
+ {
630
+ type: 'button',
631
+ props: {
632
+ onClick: () => setCount(count - 1),
633
+ style: {
634
+ padding: '8px 16px',
635
+ backgroundColor: '#ff4d4d',
636
+ color: 'white',
637
+ border: 'none',
638
+ borderRadius: '4px',
639
+ cursor: 'pointer'
640
+ },
641
+ children: 'Decrement'
642
+ }
643
+ },
644
+ {
645
+ type: 'button',
646
+ props: {
647
+ onClick: () => setCount(count + 1),
648
+ style: {
649
+ padding: '8px 16px',
650
+ backgroundColor: '#4d79ff',
651
+ color: 'white',
652
+ border: 'none',
653
+ borderRadius: '4px',
654
+ cursor: 'pointer'
655
+ },
656
+ children: 'Increment'
657
+ }
658
+ }
659
+ ]
660
+ }
661
+ }
662
+ ]
663
+ }
664
+ }
665
+ ]
666
+ }
667
+ };
668
+ }`
669
+ );
670
+
671
+ // Create vite.config.ts
672
+ fs.writeFileSync(
673
+ path.join(templateDir, 'vite.config.ts'),
674
+ `import { defineConfig } from 'vite';
675
+ import { nodePolyfills } from 'vite-plugin-node-polyfills';
676
+
677
+ export default defineConfig({
678
+ build: {
679
+ outDir: 'dist',
680
+ emptyOutDir: true
681
+ },
682
+ server: {
683
+ port: 3000,
684
+ open: true
685
+ },
686
+ plugins: [
687
+ nodePolyfills({
688
+ protocolImports: true,
689
+ }),
690
+ ]
691
+ });`
692
+ );
693
+
694
+ // Create tsconfig.json
695
+ fs.writeFileSync(
696
+ path.join(templateDir, 'tsconfig.json'),
697
+ `{
698
+ "compilerOptions": {
699
+ "target": "ES2020",
700
+ "useDefineForClassFields": true,
701
+ "module": "ESNext",
702
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
703
+ "skipLibCheck": true,
704
+ "moduleResolution": "bundler",
705
+ "allowImportingTsExtensions": true,
706
+ "resolveJsonModule": true,
707
+ "isolatedModules": true,
708
+ "noEmit": true,
709
+ "strict": true,
710
+ "noUnusedLocals": true,
711
+ "noUnusedParameters": true,
712
+ "noFallthroughCasesInSwitch": true
713
+ },
714
+ "include": ["src"],
715
+ "references": [{ "path": "./tsconfig.node.json" }]
716
+ }`
717
+ );
718
+
719
+ // Create tsconfig.node.json
720
+ fs.writeFileSync(
721
+ path.join(templateDir, 'tsconfig.node.json'),
722
+ `{
723
+ "compilerOptions": {
724
+ "composite": true,
725
+ "skipLibCheck": true,
726
+ "module": "ESNext",
727
+ "moduleResolution": "bundler",
728
+ "allowSyntheticDefaultImports": true
729
+ },
730
+ "include": ["vite.config.ts"]
731
+ }`
732
+ );
733
+
734
+ console.log(`✅ Created minimal basic template at ${templateDir}`);
735
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "compilerOptions": {
3
+ "composite": true,
4
+ "skipLibCheck": true,
5
+ "module": "ESNext",
6
+ "moduleResolution": "bundler",
7
+ "allowSyntheticDefaultImports": true
8
+ },
9
+ "include": ["vite.config.ts"]
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "compilerOptions": {
3
+ "composite": true,
4
+ "skipLibCheck": true,
5
+ "module": "ESNext",
6
+ "moduleResolution": "bundler",
7
+ "allowSyntheticDefaultImports": true
8
+ },
9
+ "include": ["vite.config.ts"]
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "compilerOptions": {
3
+ "composite": true,
4
+ "skipLibCheck": true,
5
+ "module": "ESNext",
6
+ "moduleResolution": "bundler",
7
+ "allowSyntheticDefaultImports": true
8
+ },
9
+ "include": ["vite.config.ts"]
10
+ }