tkeron 4.0.0-beta.9 → 4.0.0
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/{readme.md → README.md} +36 -4
- package/bun.lock +23 -21
- package/changelog.md +274 -8
- package/docs/best-practices.md +127 -101
- package/docs/cli-reference.md +58 -38
- package/docs/components-html.md +30 -24
- package/docs/components-typescript.md +110 -79
- package/docs/getting-started.md +24 -18
- package/docs/mcp-server.md +19 -36
- package/docs/overview.md +16 -10
- package/docs/pre-rendering.md +163 -157
- package/docs/testing.md +331 -0
- package/examples/basic_build/src/index.ts +5 -5
- package/examples/with_assets/src/index.ts +5 -5
- package/examples/with_com_html_priority/src/admin/admin-panel.com.html +1 -1
- package/examples/with_com_html_priority/src/admin/dashboard.html +16 -16
- package/examples/with_com_html_priority/src/admin/nested-stat.com.html +1 -1
- package/examples/with_com_html_priority/src/admin/site-header.com.html +1 -1
- package/examples/with_com_html_priority/src/blog/comment-item.com.html +1 -1
- package/examples/with_com_html_priority/src/blog/comment-section.com.html +1 -1
- package/examples/with_com_html_priority/src/blog/post.html +22 -19
- package/examples/with_com_html_priority/src/index.html +15 -15
- package/examples/with_com_html_priority/src/info-box.com.html +1 -1
- package/examples/with_com_html_priority/src/site-header.com.html +1 -1
- package/examples/with_com_mixed_priority/src/dashboard/main.html +17 -17
- package/examples/with_com_mixed_priority/src/dashboard/stats-widget.com.ts +1 -1
- package/examples/with_com_mixed_priority/src/footer-info.com.html +3 -1
- package/examples/with_com_mixed_priority/src/index.html +16 -16
- package/examples/with_com_mixed_priority/src/page-header.com.html +8 -1
- package/examples/with_com_mixed_priority/src/settings/config.html +16 -16
- package/examples/with_com_mixed_priority/src/settings/priority-test.com.html +3 -1
- package/examples/with_com_mixed_priority/src/users/profiles/activity-feed.com.ts +7 -3
- package/examples/with_com_mixed_priority/src/users/profiles/page-header.com.html +8 -1
- package/examples/with_com_mixed_priority/src/users/profiles/profile-actions.com.html +45 -4
- package/examples/with_com_mixed_priority/src/users/profiles/user-profile.com.ts +1 -1
- package/examples/with_com_mixed_priority/src/users/profiles/view.html +17 -17
- package/examples/with_com_ts/src/index.html +15 -11
- package/examples/with_com_ts_priority/src/analytics/chart-widget.com.ts +7 -5
- package/examples/with_com_ts_priority/src/analytics/report.html +16 -16
- package/examples/with_com_ts_priority/src/analytics/user-stats.com.ts +1 -1
- package/examples/with_com_ts_priority/src/data-table.com.ts +7 -4
- package/examples/with_com_ts_priority/src/index.html +15 -15
- package/examples/with_com_ts_priority/src/sales/regional/data-table.com.ts +8 -5
- package/examples/with_com_ts_priority/src/sales/regional/overview.html +16 -16
- package/examples/with_com_ts_priority/src/sales/regional/sales-summary.com.ts +7 -4
- package/examples/with_com_ts_priority/src/user-stats.com.ts +1 -1
- package/examples/with_component_iteration/src/card-list.com.ts +40 -12
- package/examples/with_component_iteration/src/engagement-meter.com.ts +11 -6
- package/examples/with_component_iteration/src/index.html +108 -51
- package/examples/with_component_iteration/src/index.ts +1 -1
- package/examples/with_component_iteration/src/note-box.com.html +12 -2
- package/examples/with_component_iteration/src/status-badge.com.ts +14 -7
- package/examples/with_component_iteration/src/user-card.com.ts +10 -9
- package/examples/with_pre/src/contact.pre.ts +3 -3
- package/examples/with_pre/src/index.ts +5 -5
- package/examples/with_pre/src/section/index.pre.ts +2 -4
- package/index.ts +31 -40
- package/mcp-server.ts +168 -445
- package/package.json +19 -8
- package/src/banner.ts +5 -4
- package/src/build.ts +29 -29
- package/src/buildDir.ts +36 -18
- package/src/buildEntrypoints.ts +17 -6
- package/src/buildWrapper.ts +21 -0
- package/src/cleanupOrphanedTempDirs.ts +31 -0
- package/src/createTestLogger.ts +24 -0
- package/src/develop.ts +47 -46
- package/src/getBuildResult.ts +146 -0
- package/src/index.ts +7 -0
- package/src/init.ts +39 -42
- package/src/initWrapper.ts +39 -26
- package/src/logger.ts +4 -11
- package/src/loggerObj.ts +13 -0
- package/src/processCom.ts +136 -108
- package/src/processComTs.ts +173 -151
- package/src/processPre.ts +24 -27
- package/src/promptUser.ts +15 -0
- package/src/setupSigintHandler.ts +6 -0
- package/src/silentLogger.ts +8 -0
- package/tests/test-helpers.ts +30 -0
- package/funciones.md +0 -63
package/docs/cli-reference.md
CHANGED
|
@@ -33,6 +33,7 @@ tk
|
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
**Output:**
|
|
36
|
+
|
|
36
37
|
```
|
|
37
38
|
╔════════════════════════╗
|
|
38
39
|
║ TKERON ║
|
|
@@ -56,10 +57,10 @@ tk build [sourceDir] [targetDir]
|
|
|
56
57
|
|
|
57
58
|
**Arguments:**
|
|
58
59
|
|
|
59
|
-
| Argument
|
|
60
|
-
|
|
60
|
+
| Argument | Type | Default | Description |
|
|
61
|
+
| ----------- | ------ | -------- | ---------------------------------------------- |
|
|
61
62
|
| `sourceDir` | string | `websrc` | Source directory containing your project files |
|
|
62
|
-
| `targetDir` | string | `web`
|
|
63
|
+
| `targetDir` | string | `web` | Output directory for built files |
|
|
63
64
|
|
|
64
65
|
**Examples:**
|
|
65
66
|
|
|
@@ -89,11 +90,13 @@ tk build source output
|
|
|
89
90
|
8. Cleans up temporary directory
|
|
90
91
|
|
|
91
92
|
**Files Excluded from Output:**
|
|
93
|
+
|
|
92
94
|
- `*.com.html` - HTML components (inlined)
|
|
93
95
|
- `*.com.ts` - TypeScript components (inlined)
|
|
94
96
|
- `*.pre.ts` - Pre-rendering scripts (executed)
|
|
95
97
|
|
|
96
98
|
**Exit Codes:**
|
|
99
|
+
|
|
97
100
|
- `0` - Success
|
|
98
101
|
- `1` - Error (missing source directory, build failure, etc.)
|
|
99
102
|
|
|
@@ -122,12 +125,12 @@ tk develop [sourceDir] [outputDir] [port] [host]
|
|
|
122
125
|
|
|
123
126
|
**Arguments:**
|
|
124
127
|
|
|
125
|
-
| Argument
|
|
126
|
-
|
|
127
|
-
| `sourceDir` | string | `websrc`
|
|
128
|
-
| `outputDir` | string | `web`
|
|
129
|
-
| `port`
|
|
130
|
-
| `host`
|
|
128
|
+
| Argument | Type | Default | Description |
|
|
129
|
+
| ----------- | ------ | ----------- | --------------------------- |
|
|
130
|
+
| `sourceDir` | string | `websrc` | Source directory to watch |
|
|
131
|
+
| `outputDir` | string | `web` | Output directory for builds |
|
|
132
|
+
| `port` | number | `3000` | Port for development server |
|
|
133
|
+
| `host` | string | `localhost` | Host to bind server to |
|
|
131
134
|
|
|
132
135
|
**Examples:**
|
|
133
136
|
|
|
@@ -162,8 +165,24 @@ tk develop source output 8080 0.0.0.0
|
|
|
162
165
|
- **Hot Reload:** Page auto-refreshes on file changes
|
|
163
166
|
- **Development Mode:** Serves from output directory
|
|
164
167
|
- **Static File Serving:** Handles all file types
|
|
168
|
+
- **Clean URLs:** Access pages without `.html` extension (e.g., `/about` serves `about.html`)
|
|
169
|
+
- **Directory Index:** Trailing slash serves `index.html` (e.g., `/blog/` serves `blog/index.html`)
|
|
165
170
|
- **Error Handling:** Displays build errors in terminal
|
|
166
171
|
|
|
172
|
+
**Clean URLs:**
|
|
173
|
+
|
|
174
|
+
Access HTML pages without the `.html` extension:
|
|
175
|
+
|
|
176
|
+
| URL | Serves |
|
|
177
|
+
| ---------------------- | ----------------------------------- |
|
|
178
|
+
| `/about` | `about.html` |
|
|
179
|
+
| `/services` | `services.html` |
|
|
180
|
+
| `/docs/api/guide` | `docs/api/guide.html` |
|
|
181
|
+
| `/blog/` | `blog/index.html` |
|
|
182
|
+
| `/products?sort=price` | `products.html` (with query string) |
|
|
183
|
+
|
|
184
|
+
> Note: Paths containing a dot (e.g., `/file.json`) are treated as file requests and won't have `.html` appended.
|
|
185
|
+
|
|
167
186
|
**Hot Reload Endpoint:**
|
|
168
187
|
|
|
169
188
|
The server adds a `/dev-reload` endpoint that uses Server-Sent Events (SSE) to push reload notifications to the browser.
|
|
@@ -173,17 +192,17 @@ The server adds a `/dev-reload` endpoint that uses Server-Sent Events (SSE) to p
|
|
|
173
192
|
All HTML files automatically get this script before `</body>`:
|
|
174
193
|
|
|
175
194
|
```javascript
|
|
176
|
-
(function() {
|
|
195
|
+
(function () {
|
|
177
196
|
let es;
|
|
178
197
|
function connect() {
|
|
179
|
-
es = new EventSource(
|
|
180
|
-
es.onmessage = function(e) {
|
|
181
|
-
if (e.data ===
|
|
182
|
-
console.log(
|
|
198
|
+
es = new EventSource("/dev-reload");
|
|
199
|
+
es.onmessage = function (e) {
|
|
200
|
+
if (e.data === "reload") {
|
|
201
|
+
console.log("🔄 Reloading page...");
|
|
183
202
|
location.reload();
|
|
184
203
|
}
|
|
185
204
|
};
|
|
186
|
-
es.onerror = function() {
|
|
205
|
+
es.onerror = function () {
|
|
187
206
|
es.close();
|
|
188
207
|
setTimeout(connect, 1000);
|
|
189
208
|
};
|
|
@@ -227,14 +246,14 @@ tk init <projectName> [--force]
|
|
|
227
246
|
|
|
228
247
|
**Arguments:**
|
|
229
248
|
|
|
230
|
-
| Argument
|
|
231
|
-
|
|
232
|
-
| `projectName` | string | Yes
|
|
249
|
+
| Argument | Type | Required | Description |
|
|
250
|
+
| ------------- | ------ | -------- | ------------------------------------------------------- |
|
|
251
|
+
| `projectName` | string | Yes | Name of project directory, or `.` for current directory |
|
|
233
252
|
|
|
234
253
|
**Options:**
|
|
235
254
|
|
|
236
|
-
| Option
|
|
237
|
-
|
|
255
|
+
| Option | Description |
|
|
256
|
+
| --------- | ------------------------------------------ |
|
|
238
257
|
| `--force` | Overwrite existing files without prompting |
|
|
239
258
|
|
|
240
259
|
**Examples:**
|
|
@@ -326,11 +345,11 @@ Error: Template directory not found
|
|
|
326
345
|
|
|
327
346
|
Quick reference for command shortcuts:
|
|
328
347
|
|
|
329
|
-
| Full Command | Aliases
|
|
330
|
-
|
|
331
|
-
| `tk build`
|
|
332
|
-
| `tk develop` | `tk dev`, `tk d` | Start dev server
|
|
333
|
-
| `tk init`
|
|
348
|
+
| Full Command | Aliases | Description |
|
|
349
|
+
| ------------ | ---------------- | ------------------ |
|
|
350
|
+
| `tk build` | `tk b` | Build project |
|
|
351
|
+
| `tk develop` | `tk dev`, `tk d` | Start dev server |
|
|
352
|
+
| `tk init` | `tk i` | Initialize project |
|
|
334
353
|
|
|
335
354
|
**Examples:**
|
|
336
355
|
|
|
@@ -347,17 +366,17 @@ tk i my-site # Same as: tk init my-site
|
|
|
347
366
|
|
|
348
367
|
### Built-in Variables
|
|
349
368
|
|
|
350
|
-
| Variable
|
|
351
|
-
|
|
369
|
+
| Variable | Description | Set By |
|
|
370
|
+
| ---------------- | ---------------------- | ------ |
|
|
352
371
|
| `TKERON_VERSION` | Current Tkeron version | Tkeron |
|
|
353
|
-
| `NODE_ENV`
|
|
372
|
+
| `NODE_ENV` | Environment mode | User |
|
|
354
373
|
|
|
355
374
|
**Usage in Pre-rendering:**
|
|
356
375
|
|
|
357
376
|
```typescript
|
|
358
377
|
// index.pre.ts
|
|
359
|
-
console.log(
|
|
360
|
-
console.log(
|
|
378
|
+
console.log("Tkeron:", process.env.TKERON_VERSION);
|
|
379
|
+
console.log("Environment:", process.env.NODE_ENV);
|
|
361
380
|
```
|
|
362
381
|
|
|
363
382
|
**Setting Custom Variables:**
|
|
@@ -383,10 +402,10 @@ NODE_ENV=production API_URL=https://api.prod.com tk build
|
|
|
383
402
|
|
|
384
403
|
## Exit Codes
|
|
385
404
|
|
|
386
|
-
| Code | Meaning
|
|
387
|
-
|
|
388
|
-
| `0`
|
|
389
|
-
| `1`
|
|
405
|
+
| Code | Meaning |
|
|
406
|
+
| ---- | ----------------------------------------------------------------- |
|
|
407
|
+
| `0` | Success |
|
|
408
|
+
| `1` | Error (missing directory, build failure, invalid arguments, etc.) |
|
|
390
409
|
|
|
391
410
|
**Usage in Scripts:**
|
|
392
411
|
|
|
@@ -510,19 +529,19 @@ jobs:
|
|
|
510
529
|
runs-on: ubuntu-latest
|
|
511
530
|
steps:
|
|
512
531
|
- uses: actions/checkout@v3
|
|
513
|
-
|
|
532
|
+
|
|
514
533
|
- uses: oven-sh/setup-bun@v1
|
|
515
534
|
with:
|
|
516
535
|
bun-version: latest
|
|
517
|
-
|
|
536
|
+
|
|
518
537
|
- name: Install Tkeron
|
|
519
538
|
run: bun install -g tkeron
|
|
520
|
-
|
|
539
|
+
|
|
521
540
|
- name: Build
|
|
522
541
|
run: tk build
|
|
523
542
|
env:
|
|
524
543
|
NODE_ENV: production
|
|
525
|
-
|
|
544
|
+
|
|
526
545
|
- name: Deploy
|
|
527
546
|
run: |
|
|
528
547
|
# Your deployment commands
|
|
@@ -625,6 +644,7 @@ tk
|
|
|
625
644
|
### Command Documentation
|
|
626
645
|
|
|
627
646
|
This document! Also available at:
|
|
647
|
+
|
|
628
648
|
- [GitHub Repository](https://github.com/tkeron/tkeron)
|
|
629
649
|
- [Documentation Site](https://tkeron.dev/docs)
|
|
630
650
|
|
package/docs/components-html.md
CHANGED
|
@@ -25,18 +25,19 @@ Build, and the custom element is replaced with the component's content.
|
|
|
25
25
|
### 1. Component Naming
|
|
26
26
|
|
|
27
27
|
Component filenames must:
|
|
28
|
+
|
|
28
29
|
- End with `.com.html`
|
|
29
30
|
- Match the custom element name (without `.com.html`)
|
|
30
31
|
- Use lowercase with hyphens
|
|
31
32
|
|
|
32
33
|
**Examples:**
|
|
33
34
|
|
|
34
|
-
| Filename
|
|
35
|
-
|
|
36
|
-
| `user-card.com.html` | `<user-card>`
|
|
37
|
-
| `nav-menu.com.html`
|
|
38
|
-
| `header.com.html`
|
|
39
|
-
| `UserCard.com.html`
|
|
35
|
+
| Filename | Custom Element | Valid? |
|
|
36
|
+
| -------------------- | -------------- | ------------------------- |
|
|
37
|
+
| `user-card.com.html` | `<user-card>` | ✅ Yes |
|
|
38
|
+
| `nav-menu.com.html` | `<nav-menu>` | ✅ Yes |
|
|
39
|
+
| `header.com.html` | `<header>` | ❌ No (no hyphen) |
|
|
40
|
+
| `UserCard.com.html` | `<user-card>` | ✅ Yes (case-insensitive) |
|
|
40
41
|
|
|
41
42
|
### 2. Component Resolution
|
|
42
43
|
|
|
@@ -57,6 +58,7 @@ websrc/
|
|
|
57
58
|
```
|
|
58
59
|
|
|
59
60
|
In `blog/post.html`:
|
|
61
|
+
|
|
60
62
|
- `<comment>` → Finds `blog/comment.com.html` first
|
|
61
63
|
- `<header>` → Falls back to `websrc/header.com.html`
|
|
62
64
|
|
|
@@ -89,8 +91,7 @@ The `.com.html` file is NOT copied to output - only its content is inlined.
|
|
|
89
91
|
**Usage:**
|
|
90
92
|
|
|
91
93
|
```html
|
|
92
|
-
<card></card>
|
|
93
|
-
<card></card>
|
|
94
|
+
<card></card> <card></card>
|
|
94
95
|
```
|
|
95
96
|
|
|
96
97
|
**Output:**
|
|
@@ -131,12 +132,12 @@ The `.com.html` file is NOT copied to output - only its content is inlined.
|
|
|
131
132
|
```html
|
|
132
133
|
<!DOCTYPE html>
|
|
133
134
|
<html>
|
|
134
|
-
<body>
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
</body>
|
|
135
|
+
<body>
|
|
136
|
+
<site-header></site-header>
|
|
137
|
+
<main>
|
|
138
|
+
<!-- Page content -->
|
|
139
|
+
</main>
|
|
140
|
+
</body>
|
|
140
141
|
</html>
|
|
141
142
|
```
|
|
142
143
|
|
|
@@ -160,7 +161,7 @@ Components can use other components:
|
|
|
160
161
|
```html
|
|
161
162
|
<!-- user-avatar.com.html -->
|
|
162
163
|
<div class="avatar">
|
|
163
|
-
<img src="/avatars/default.jpg" alt="User"
|
|
164
|
+
<img src="/avatars/default.jpg" alt="User" />
|
|
164
165
|
</div>
|
|
165
166
|
```
|
|
166
167
|
|
|
@@ -185,7 +186,7 @@ Components can use other components:
|
|
|
185
186
|
```html
|
|
186
187
|
<div class="user-card">
|
|
187
188
|
<div class="avatar">
|
|
188
|
-
<img src="/avatars/default.jpg" alt="User"
|
|
189
|
+
<img src="/avatars/default.jpg" alt="User" />
|
|
189
190
|
</div>
|
|
190
191
|
<div class="user-info">
|
|
191
192
|
<h3>John Doe</h3>
|
|
@@ -239,7 +240,9 @@ Components can contain multiple root elements:
|
|
|
239
240
|
|
|
240
241
|
```html
|
|
241
242
|
<!-- alert-box.com.html -->
|
|
242
|
-
<div
|
|
243
|
+
<div
|
|
244
|
+
style="padding: 1rem; background: #fef2f2; border: 1px solid #ef4444; border-radius: 4px;"
|
|
245
|
+
>
|
|
243
246
|
<strong>Error:</strong> Something went wrong!
|
|
244
247
|
</div>
|
|
245
248
|
```
|
|
@@ -251,7 +254,7 @@ Components work with your existing CSS:
|
|
|
251
254
|
```html
|
|
252
255
|
<!-- product-card.com.html -->
|
|
253
256
|
<div class="product-card">
|
|
254
|
-
<img class="product-image" src="/products/placeholder.jpg" alt="Product"
|
|
257
|
+
<img class="product-image" src="/products/placeholder.jpg" alt="Product" />
|
|
255
258
|
<h3 class="product-title">Product Name</h3>
|
|
256
259
|
<p class="product-price">$99.99</p>
|
|
257
260
|
<button class="btn btn-primary">Add to Cart</button>
|
|
@@ -312,7 +315,8 @@ HTML components don't support:
|
|
|
312
315
|
```html
|
|
313
316
|
<!-- wrapper.com.html -->
|
|
314
317
|
<div class="wrapper">
|
|
315
|
-
<slot></slot>
|
|
318
|
+
<slot></slot>
|
|
319
|
+
<!-- Not supported -->
|
|
316
320
|
</div>
|
|
317
321
|
```
|
|
318
322
|
|
|
@@ -324,7 +328,8 @@ Components can't include themselves:
|
|
|
324
328
|
<!-- menu.com.html -->
|
|
325
329
|
<ul>
|
|
326
330
|
<li>Item 1</li>
|
|
327
|
-
<menu></menu>
|
|
331
|
+
<menu></menu>
|
|
332
|
+
<!-- ERROR: Circular dependency! -->
|
|
328
333
|
</ul>
|
|
329
334
|
```
|
|
330
335
|
|
|
@@ -339,6 +344,7 @@ Components can be nested up to **50 levels** deep. Deeper nesting will be ignore
|
|
|
339
344
|
### ✅ Use for Static UI Patterns
|
|
340
345
|
|
|
341
346
|
Perfect for:
|
|
347
|
+
|
|
342
348
|
- Headers and footers
|
|
343
349
|
- Navigation menus
|
|
344
350
|
- Card layouts
|
|
@@ -352,7 +358,7 @@ Perfect for:
|
|
|
352
358
|
<!-- Good: Small, focused component -->
|
|
353
359
|
<!-- icon-warning.com.html -->
|
|
354
360
|
<svg width="24" height="24" viewBox="0 0 24 24">
|
|
355
|
-
<path d="M12 2L1 21h22L12 2z"/>
|
|
361
|
+
<path d="M12 2L1 21h22L12 2z" />
|
|
356
362
|
<text x="12" y="17" text-anchor="middle">!</text>
|
|
357
363
|
</svg>
|
|
358
364
|
```
|
|
@@ -391,8 +397,8 @@ If your component needs attributes or logic, use [TypeScript Components](./compo
|
|
|
391
397
|
|
|
392
398
|
```typescript
|
|
393
399
|
// user-badge.com.ts
|
|
394
|
-
const name = com.getAttribute(
|
|
395
|
-
const role = com.getAttribute(
|
|
400
|
+
const name = com.getAttribute("name") || "Guest";
|
|
401
|
+
const role = com.getAttribute("role") || "User";
|
|
396
402
|
com.innerHTML = `<span class="badge">${name} - ${role}</span>`;
|
|
397
403
|
```
|
|
398
404
|
|
|
@@ -435,7 +441,7 @@ Build and check if "TEST COMPONENT LOADED" appears in output.
|
|
|
435
441
|
```html
|
|
436
442
|
<!-- blog-card.com.html -->
|
|
437
443
|
<article class="blog-card">
|
|
438
|
-
<img src="/blog/placeholder.jpg" alt="Blog post" class="blog-card-image"
|
|
444
|
+
<img src="/blog/placeholder.jpg" alt="Blog post" class="blog-card-image" />
|
|
439
445
|
<div class="blog-card-content">
|
|
440
446
|
<time class="blog-card-date">2025-01-15</time>
|
|
441
447
|
<h2 class="blog-card-title">Blog Post Title</h2>
|