create-aziz-app 2.0.5 → 2.0.6

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": "create-aziz-app",
3
- "version": "2.0.5",
3
+ "version": "2.0.6",
4
4
  "description": "A React-like framework with state management, routing, and API routes - Create apps with auto-import, live reload, and Next.js-like features",
5
5
  "keywords": [
6
6
  "react",
@@ -150,6 +150,13 @@ function renderShell() {
150
150
  footer.appendChild(Footer());
151
151
  }
152
152
 
153
+ // Re-render shell when route changes (for navbar active state)
154
+ function updateShell() {
155
+ const navbar = document.getElementById("navbar");
156
+ navbar.innerHTML = "";
157
+ navbar.appendChild(Navbar());
158
+ }
159
+
153
160
  // 404 page — shown when no route matches
154
161
  function NotFoundPage() {
155
162
  return (
@@ -170,8 +177,11 @@ function startApp() {
170
177
  renderShell();
171
178
  renderPage();
172
179
 
173
- // Re-render the page whenever the hash changes (back/forward navigation)
174
- window.addEventListener("hashchange", renderPage);
180
+ // Re-render the page and navbar whenever the hash changes (back/forward navigation)
181
+ window.addEventListener("hashchange", () => {
182
+ updateShell(); // Update navbar active state
183
+ renderPage();
184
+ });
175
185
  }
176
186
 
177
187
  // Export to global scope
@@ -1,6 +1,5 @@
1
1
  /** @jsx h */
2
2
 
3
- // Register this page at route "home" → "#/"
4
3
  registerPage("home", HomePage);
5
4
 
6
5
  function HomePage() {
@@ -25,14 +24,16 @@ function HomePage() {
25
24
  <h2>File-based Routing</h2>
26
25
  <p>
27
26
  Each file in <strong>pages/</strong> is a route — just like Next.js.
28
- Add a new file, register it in app.js, and it's a new page.
27
+ Add a new file, run the build script, and it's a new page.
29
28
  </p>
30
- <button class="btn btn-primary" onClick={() => navigate("test")}>
31
- Go to Test Page →
32
- </button>
33
- <button class="btn btn-primary" onClick={() => navigate("about")}>
34
- Go to About →
35
- </button>
29
+ <div style={{ display: 'flex', gap: '12px' }}>
30
+ <button class="btn btn-primary" onClick={() => navigate("test")}>
31
+ Go to Test Page →
32
+ </button>
33
+ <button class="btn btn-primary" onClick={() => navigate("about")}>
34
+ Go to About →
35
+ </button>
36
+ </div>
36
37
  </div>
37
38
  </div>
38
39
  );
@@ -1,6 +1,5 @@
1
1
  /** @jsx h */
2
2
 
3
- // Register this page at route "test" → "#/test"
4
3
  registerPage("test", TestPage);
5
4
 
6
5
  function TestPage() {
@@ -19,7 +18,7 @@ function TestPage() {
19
18
 
20
19
  <div class="card">
21
20
  <h2>Counter Example</h2>
22
- <p>This demonstrates the new state management system.</p>
21
+ <p>This demonstrates the state management system.</p>
23
22
 
24
23
  <div class="count-display">{count}</div>
25
24
  <div class="counter-actions">
@@ -37,15 +36,6 @@ function TestPage() {
37
36
  <p>Try the form with state management.</p>
38
37
 
39
38
  <form onSubmit={handleSubmit}>
40
- <div>
41
- <label>Email:</label>
42
- <input
43
- type="email"
44
- value={email}
45
- onInput={(e) => setEmail(e.target.value)}
46
- placeholder="Enter your email"
47
- />
48
- </div>
49
39
  <div>
50
40
  <label>Name:</label>
51
41
  <input
@@ -56,6 +46,15 @@ function TestPage() {
56
46
  />
57
47
  </div>
58
48
 
49
+ <div>
50
+ <label>Email:</label>
51
+ <input
52
+ type="email"
53
+ value={email}
54
+ onInput={(e) => setEmail(e.target.value)}
55
+ placeholder="Enter your email"
56
+ />
57
+ </div>
59
58
 
60
59
  <button type="submit" class="btn btn-primary">
61
60
  Submit Form
@@ -35,18 +35,59 @@ function notifyClients() {
35
35
  // Live reload script to inject
36
36
  const liveReloadScript = `
37
37
  <script>
38
- // Live reload client
38
+ // Hot Module Replacement (HMR) - Smart reload
39
39
  const evtSource = new EventSource('/live-reload');
40
+ let isReloading = false;
41
+
40
42
  evtSource.onmessage = (event) => {
41
- if (event.data === 'reload') {
42
- console.log('🔄 Changes detected, reloading...');
43
- location.reload();
43
+ if (event.data === 'reload' && !isReloading) {
44
+ isReloading = true;
45
+ console.log('🔄 Changes detected, hot reloading...');
46
+
47
+ // Save current state
48
+ const currentPath = window.location.hash;
49
+ const scrollPos = window.scrollY;
50
+
51
+ // Reload only changed scripts
52
+ const scripts = document.querySelectorAll('script[type="text/babel"]');
53
+ let reloadCount = 0;
54
+
55
+ scripts.forEach((script, index) => {
56
+ if (script.src && !script.src.includes('babel.min.js')) {
57
+ const newScript = document.createElement('script');
58
+ newScript.type = 'text/babel';
59
+ newScript.src = script.src + '?t=' + Date.now();
60
+
61
+ newScript.onload = () => {
62
+ reloadCount++;
63
+ if (reloadCount === scripts.length - 1) {
64
+ // All scripts reloaded, re-render
65
+ setTimeout(() => {
66
+ if (typeof renderShell === 'function') renderShell();
67
+ if (typeof renderPage === 'function') renderPage();
68
+ window.scrollTo(0, scrollPos);
69
+ console.log('✅ Hot reload complete');
70
+ isReloading = false;
71
+ }, 100);
72
+ }
73
+ };
74
+
75
+ script.parentNode.replaceChild(newScript, script);
76
+ }
77
+ });
78
+
79
+ // Fallback: if no scripts to reload, just refresh
80
+ if (scripts.length <= 1) {
81
+ location.reload();
82
+ }
44
83
  }
45
84
  };
85
+
46
86
  evtSource.onerror = () => {
47
87
  console.log('⚠️ Live reload disconnected');
48
88
  };
49
- console.log('✅ Live reload connected');
89
+
90
+ console.log('✅ Hot reload connected');
50
91
  </script>
51
92
  `;
52
93