create-gardener 2.0.7 → 2.0.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
@@ -5,7 +5,7 @@
5
5
  "type": "git",
6
6
  "url": "https://github.com/ritishDas/gardener"
7
7
  },
8
- "version": "2.0.7",
8
+ "version": "2.0.9",
9
9
  "description": "A dom gardener converting dom elements into json and vice versa",
10
10
  "main": "index.js",
11
11
  "bin": {
@@ -28,10 +28,12 @@ async function findTemplate(fileName: string) {
28
28
  // file does not exist → continue
29
29
  }
30
30
 
31
- const lastUnderscore = fileName.lastIndexOf('_');
31
+ let lastUnderscore = fileName.lastIndexOf('_');
32
32
  if (lastUnderscore === -1) break;
33
33
 
34
- fileName = fileName.substring(0, lastUnderscore + 1);
34
+ if (lastUnderscore === 0) lastUnderscore += 1;
35
+
36
+ fileName = fileName.substring(0, lastUnderscore);
35
37
  console.log(fileName);
36
38
  }
37
39
 
@@ -61,7 +63,7 @@ export async function addPage(req: Request, res: Response) {
61
63
 
62
64
  await replaceLastOccurrence(viewPath, '<script', `<script src="/static/pages/pages.${name}.js" type='module'></script>`);
63
65
 
64
- const routeEntry = `router.route("${pagename}").get((req: Request, res: Response) => res.render("${name}"));\n`;
66
+ const routeEntry = `router.route("${pagename}").get((req: Request, res: Response) => res.render("${name}",{fileName:"${name}"}));\n`;
65
67
  await fsp.appendFile(routePath, routeEntry, "utf8");
66
68
 
67
69
  await fsp.mkdir(jsDir, { recursive: true });
@@ -13,7 +13,7 @@ export async function saveTemplate(req: Request, res: Response) {
13
13
  try {
14
14
  const { path: reqPath } = req.body; // ✅ renamed
15
15
 
16
- const name = reqPath.replaceAll("/", "_");
16
+ const name = reqPath;
17
17
 
18
18
  const sourceFile = path.join(frontendDir, 'views', `${name}.ejs`);
19
19
 
@@ -21,4 +21,4 @@ if (process.env.NODE_ENV !== 'production') {
21
21
 
22
22
 
23
23
 
24
- router.route('/').get((req: Request, res: Response) => res.render('_'));
24
+ router.route('/').get((req: Request, res: Response) => res.render('_', { fileName: '_' }));
@@ -78,7 +78,7 @@ const pagebtns = gardener({
78
78
  const result = await fetch('/savetemplate', {
79
79
  method: 'POST',
80
80
  headers: { "Content-Type": 'application/json' },
81
- body: JSON.stringify({ path: window.location.pathname })
81
+ body: JSON.stringify({ path: fetchElement('#fileName').innerText })
82
82
  });
83
83
 
84
84
  const data = await result.json(); // ✅ fix
@@ -13,7 +13,6 @@
13
13
  --color-green-300: oklch(87.1% 0.15 154.449);
14
14
  --color-green-400: oklch(79.2% 0.209 151.711);
15
15
  --color-green-500: oklch(72.3% 0.219 149.579);
16
- --color-green-600: oklch(62.7% 0.194 149.214);
17
16
  --color-green-700: oklch(52.7% 0.154 150.069);
18
17
  --color-green-800: oklch(44.8% 0.119 151.328);
19
18
  --color-green-900: oklch(39.3% 0.095 152.535);
@@ -273,9 +272,6 @@
273
272
  .bottom-4 {
274
273
  bottom: calc(var(--spacing) * 4);
275
274
  }
276
- .bottom-6 {
277
- bottom: calc(var(--spacing) * 6);
278
- }
279
275
  .bottom-20 {
280
276
  bottom: calc(var(--spacing) * 20);
281
277
  }
@@ -306,6 +302,24 @@
306
302
  .z-100 {
307
303
  z-index: 100;
308
304
  }
305
+ .container {
306
+ width: 100%;
307
+ @media (width >= 40rem) {
308
+ max-width: 40rem;
309
+ }
310
+ @media (width >= 48rem) {
311
+ max-width: 48rem;
312
+ }
313
+ @media (width >= 64rem) {
314
+ max-width: 64rem;
315
+ }
316
+ @media (width >= 80rem) {
317
+ max-width: 80rem;
318
+ }
319
+ @media (width >= 96rem) {
320
+ max-width: 96rem;
321
+ }
322
+ }
309
323
  .m-2 {
310
324
  margin: calc(var(--spacing) * 2);
311
325
  }
@@ -351,6 +365,9 @@
351
365
  .grid {
352
366
  display: grid;
353
367
  }
368
+ .hidden {
369
+ display: none;
370
+ }
354
371
  .inline {
355
372
  display: inline;
356
373
  }
@@ -369,9 +386,6 @@
369
386
  .h-15 {
370
387
  height: calc(var(--spacing) * 15);
371
388
  }
372
- .h-35 {
373
- height: calc(var(--spacing) * 35);
374
- }
375
389
  .h-96 {
376
390
  height: calc(var(--spacing) * 96);
377
391
  }
@@ -393,12 +407,6 @@
393
407
  .w-15 {
394
408
  width: calc(var(--spacing) * 15);
395
409
  }
396
- .w-35 {
397
- width: calc(var(--spacing) * 35);
398
- }
399
- .w-50 {
400
- width: calc(var(--spacing) * 50);
401
- }
402
410
  .w-96 {
403
411
  width: calc(var(--spacing) * 96);
404
412
  }
@@ -555,9 +563,6 @@
555
563
  .bg-gray-200 {
556
564
  background-color: var(--color-gray-200);
557
565
  }
558
- .bg-gray-400 {
559
- background-color: var(--color-gray-400);
560
- }
561
566
  .bg-gray-500 {
562
567
  background-color: var(--color-gray-500);
563
568
  }
@@ -570,9 +575,6 @@
570
575
  .bg-green-300 {
571
576
  background-color: var(--color-green-300);
572
577
  }
573
- .bg-green-500 {
574
- background-color: var(--color-green-500);
575
- }
576
578
  .bg-green-700 {
577
579
  background-color: var(--color-green-700);
578
580
  }
@@ -793,13 +795,6 @@
793
795
  }
794
796
  }
795
797
  }
796
- .hover\:bg-gray-800 {
797
- &:hover {
798
- @media (hover: hover) {
799
- background-color: var(--color-gray-800);
800
- }
801
- }
802
- }
803
798
  .hover\:bg-gray-900 {
804
799
  &:hover {
805
800
  @media (hover: hover) {
@@ -807,13 +802,6 @@
807
802
  }
808
803
  }
809
804
  }
810
- .hover\:bg-green-600 {
811
- &:hover {
812
- @media (hover: hover) {
813
- background-color: var(--color-green-600);
814
- }
815
- }
816
- }
817
805
  .hover\:bg-green-800 {
818
806
  &:hover {
819
807
  @media (hover: hover) {
@@ -10,6 +10,7 @@
10
10
  </head>
11
11
  <body class="bg-slate-50 text-slate-900 font-sans">
12
12
 
13
+ <div class='hidden' id='fileName'><%=fileName%></div>
13
14
  <div class='loader w-screen h-screen bg-white fixed z-2'> </div>
14
15
  <div class='notification'></div>
15
16
 
@@ -1,2 +0,0 @@
1
- import { gardener, fetchElement, replaceElement, appendElement } from "/static/gardener.js";
2
- import {log, parser, addEl, State} from "/static/gardenerDev.js"
@@ -1,2 +0,0 @@
1
- import { gardener, fetchElement, replaceElement, appendElement } from "/static/gardener.js";
2
- import {log, parser, addEl, State} from "/static/gardenerDev.js"
@@ -1,120 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <link rel="icon" type="image/svg+xml" href="/static/cache/favicon_50x50.webp" />
7
- <link href="/static/style.css" rel="stylesheet"/>
8
- <link href="/static/style2.css" rel="stylesheet"/>
9
- <title>Gardener: The Mini Web Framework</title>
10
- </head>
11
- <body class="bg-slate-50 text-slate-900 font-sans">
12
-
13
- <div class='loader w-screen h-screen bg-white fixed z-2'> </div>
14
- <div class='notification'></div>
15
-
16
- <div id='main'>
17
-
18
-
19
- <!-- hero -->
20
- <div class='hero flex-wrap w-full h-screen bg-green-200 flex justify-center items-center px-10'>
21
- <div class='w-200'>
22
- <a href="https://ritish.site">Home</a> > <a href="https://ritish.site/projects">Projects</a> > <a href="/">Gardener</a>
23
- <h1 class='text-6xl my-10 font-bold text-green-900'>Gardener</h1>
24
- <h2 class='text-2xl font-bold text-green-800 mb-4'>Develop With No Bloat</h2>
25
- <p class="text-lg mb-6 max-w-md">Gardener is a lightweight, DOM-first front-end library. No virtual DOM, no JSX, and no compilation step. Just the real DOM.</p>
26
- <div class='flex gap-2 m-2'>
27
- <a class="block bg-green-700 text-white px-8 py-3 rounded-lg font-bold hover:bg-green-800 transition" href='/get-started'>Get Started</a>
28
- <a class="block border border-green-700 text-black px-8 py-3 rounded-lg font-bold hover:text-white hover:bg-green-800 transition" href='/documentation/#introduction'>Documentation</a>
29
- </div>
30
- <div class='flex gap-2 m-2'>
31
- <a class="block border border-green-700 text-black px-8 py-3 rounded-lg font-bold hover:text-white hover:bg-green-800 transition" href='https://github.com/ritishDas/Gardener'>View On Github</a>
32
- <a class="block border border-green-700 text-black px-8 py-3 rounded-lg font-bold hover:text-white hover:bg-green-800 transition" href='https://www.npmjs.com/package/create-gardener'>View On npm</a>
33
- </div>
34
- </div>
35
- <img src="/static/cache/gardener_500x500.webp" alt="Gardener Logo" class="w-96 h-96 object-contain ml-10">
36
- </div>
37
-
38
- <!-- Copy command -->
39
- <div class="flex w-1/4 items-center mx-auto my-15 justify-between gap-4 bg-[#1e1e1e] border border-gray-700 rounded-lg px-4 py-3 font-mono shadow-sm group">
40
- <span class="text-sm md:text-base text-gray-300 select-all">
41
- <span class="text-emerald-400 mr-2">$</span><span class='initCommand'>pnpm create gardener app</span>
42
- </span>
43
-
44
- <button class="copybtn flex items-center justify-center p-2 text-gray-400 hover:text-white hover:bg-white/10 rounded transition-all duration-200 active:scale-95" title="Copy to clipboard">
45
- <span class="w-5 h-5" >
46
- <%- include('partials/icons/clipboard') %>
47
- </span>
48
- </button>
49
- </div>
50
- <!-- Philosophy -->
51
- <div class="max-w-5xl mx-auto py-20 px-6 grid md:grid-cols-2 gap-12">
52
- <div>
53
- <h3 class="text-3xl font-bold mb-4 text-green-900">✨ Philosophy</h3>
54
- <ul class="space-y-3 text-slate-700">
55
- <li><strong>DOM-First:</strong> Renders directly to the real DOM.</li>
56
- <li><strong>Deterministic:</strong> If you can inspect it, you can understand it.</li>
57
- <li><strong>Native:</strong> Works in the browser via ES modules.</li>
58
- <li><strong>Zero Build:</strong> No bundlers or magic required.</li>
59
- </ul>
60
- </div>
61
-
62
- <!-- Features -->
63
- <div>
64
- <h3 class="text-3xl font-bold mb-4 text-green-900">🚀 Features</h3>
65
- <div class="grid grid-cols-2 gap-4">
66
- <div class="p-4 bg-white shadow-sm border border-green-100 rounded">Declarative UI</div>
67
- <div class="p-4 bg-white shadow-sm border border-green-100 rounded">SVG Namespace Support</div>
68
- <div class="p-4 bg-white shadow-sm border border-green-100 rounded">Hot Reload</div>
69
- <div class="p-4 bg-white shadow-sm border border-green-100 rounded">Image Optimization</div>
70
- </div>
71
- </div>
72
- </div>
73
-
74
- <!-- Api Example -->
75
- <div class="bg-slate-900 py-20 text-white">
76
- <div class="max-w-5xl mx-auto px-6">
77
- <h3 class="text-3xl font-bold mb-8 text-center text-green-400">The Core API</h3>
78
- <div class="bg-slate-800 p-6 rounded-xl border border-slate-700 font-mono text-sm overflow-x-auto">
79
- <pre class="text-blue-300">
80
- gardener({
81
- t: <span class="text-green-300">'div'</span>,
82
- cn: [<span class="text-green-300">'p-6'</span>, <span class="text-green-300">'flex'</span>],
83
- attr: { id: <span class="text-green-300">'hero'</span> },
84
- txt: <span class="text-green-300">'Welcome to the Garden'</span>,
85
- events: {
86
- click: () => console.log(<span class="text-green-300">'Growth!'</span>)
87
- },
88
- children: [
89
- { t: <span class="text-green-300">'span'</span>, txt: <span class="text-green-300">'Pure DOM nodes.'</span> }
90
- ]
91
- })
92
- </pre>
93
- </div>
94
- </div>
95
- </div>
96
-
97
- <div class="max-w-5xl mx-auto py-20 px-6 text-center">
98
- <h3 class="text-3xl font-bold mb-4 text-green-900">🧠 Simple State</h3>
99
- <p class="mb-8 text-slate-600">No proxies. No diffing. Just clean, reactive callbacks.</p>
100
- <div class="inline-block text-left bg-white p-6 rounded shadow-lg border-t-4 border-green-500 font-mono text-sm">
101
- <p class="text-slate-500">// Initialize</p>
102
- <p>const count = new State(0);</p>
103
- <p class="text-slate-500 mt-2">// React</p>
104
- <p>count.registerCb(val => updateUI(val));</p>
105
- </div>
106
- </div>
107
-
108
- <!-- Footer -->
109
- <footer class="bg-green-900 text-green-100 py-12 text-center">
110
- <p class="text-xl italic">"Because sometimes you don't need a forest. Just a garden."</p>
111
- <div class="mt-6 text-sm opacity-70">
112
- MIT Licensed | Built on Express & EJS
113
- </div>
114
- </footer>
115
- </div>
116
-
117
- </body>
118
- <script type='module' src='/static/global.js'> </script>
119
-
120
- </html>