tkeron 4.0.0-beta.8 → 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 +292 -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 +137 -110
- package/src/processComTs.ts +174 -153
- 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
|
@@ -7,17 +7,17 @@ TypeScript components (`.com.ts` files) let you create dynamic, logic-driven com
|
|
|
7
7
|
Create a `.com.ts` file:
|
|
8
8
|
|
|
9
9
|
```typescript
|
|
10
|
-
// greeting.com.ts
|
|
11
|
-
const name = com.getAttribute(
|
|
10
|
+
// user-greeting.com.ts
|
|
11
|
+
const name = com.getAttribute("name") || "World";
|
|
12
12
|
com.innerHTML = `<h1>Hello, ${name}!</h1>`;
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
Use it with attributes:
|
|
16
16
|
|
|
17
17
|
```html
|
|
18
|
-
<greeting name="Alice"></greeting>
|
|
19
|
-
<greeting name="Bob"></greeting>
|
|
20
|
-
<greeting></greeting>
|
|
18
|
+
<user-greeting name="Alice"></user-greeting>
|
|
19
|
+
<user-greeting name="Bob"></user-greeting>
|
|
20
|
+
<user-greeting></user-greeting>
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
Build output:
|
|
@@ -36,9 +36,9 @@ Every `.com.ts` file has access to a special `com` variable:
|
|
|
36
36
|
|
|
37
37
|
```typescript
|
|
38
38
|
// The 'com' variable is the DOM element itself
|
|
39
|
-
com.getAttribute(
|
|
40
|
-
com.innerHTML =
|
|
41
|
-
com.tagName
|
|
39
|
+
com.getAttribute("attr-name"); // Read attributes
|
|
40
|
+
com.innerHTML = "..."; // Set content (this is what's kept)
|
|
41
|
+
com.tagName; // Get element name
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
**Important:** Only the `innerHTML` you set is included in the final output. Everything else is discarded.
|
|
@@ -58,6 +58,27 @@ Browser sees only:
|
|
|
58
58
|
<div class="card">John</div>
|
|
59
59
|
```
|
|
60
60
|
|
|
61
|
+
### Component Naming
|
|
62
|
+
|
|
63
|
+
Component filenames must:
|
|
64
|
+
|
|
65
|
+
- End with `.com.ts`
|
|
66
|
+
- Match the custom element name (without `.com.ts`)
|
|
67
|
+
- **Use lowercase with hyphens** (custom element requirement)
|
|
68
|
+
|
|
69
|
+
**Examples:**
|
|
70
|
+
|
|
71
|
+
| Filename | Custom Element | Valid? |
|
|
72
|
+
| --------------------- | --------------- | ------------------------- |
|
|
73
|
+
| `user-card.com.ts` | `<user-card>` | ✅ Yes |
|
|
74
|
+
| `nav-menu.com.ts` | `<nav-menu>` | ✅ Yes |
|
|
75
|
+
| `greeting.com.ts` | `<greeting>` | ❌ No (no hyphen) |
|
|
76
|
+
| `UserCard.com.ts` | `<user-card>` | ✅ Yes (case-insensitive) |
|
|
77
|
+
|
|
78
|
+
**Why hyphens are required:**
|
|
79
|
+
|
|
80
|
+
Custom elements in HTML must contain at least one hyphen to distinguish them from standard HTML elements. This is a web standard requirement. Tkeron validates this at build time and shows a clear error message if a component name doesn't follow this rule.
|
|
81
|
+
|
|
61
82
|
### Component Resolution
|
|
62
83
|
|
|
63
84
|
Same as HTML components:
|
|
@@ -71,8 +92,8 @@ Same as HTML components:
|
|
|
71
92
|
|
|
72
93
|
```typescript
|
|
73
94
|
// user-badge.com.ts
|
|
74
|
-
const name = com.getAttribute(
|
|
75
|
-
const role = com.getAttribute(
|
|
95
|
+
const name = com.getAttribute("name") || "Guest";
|
|
96
|
+
const role = com.getAttribute("role") || "User";
|
|
76
97
|
|
|
77
98
|
com.innerHTML = `
|
|
78
99
|
<div class="badge">
|
|
@@ -111,7 +132,7 @@ com.innerHTML = `
|
|
|
111
132
|
|
|
112
133
|
```typescript
|
|
113
134
|
// item-list.com.ts
|
|
114
|
-
const count = parseInt(com.getAttribute(
|
|
135
|
+
const count = parseInt(com.getAttribute("count") || "3");
|
|
115
136
|
const items = [];
|
|
116
137
|
|
|
117
138
|
for (let i = 1; i <= count; i++) {
|
|
@@ -120,7 +141,7 @@ for (let i = 1; i <= count; i++) {
|
|
|
120
141
|
|
|
121
142
|
com.innerHTML = `
|
|
122
143
|
<ul class="item-list">
|
|
123
|
-
${items.join(
|
|
144
|
+
${items.join("")}
|
|
124
145
|
</ul>
|
|
125
146
|
`;
|
|
126
147
|
```
|
|
@@ -147,14 +168,14 @@ com.innerHTML = `
|
|
|
147
168
|
|
|
148
169
|
```typescript
|
|
149
170
|
// alert-box.com.ts
|
|
150
|
-
const type = com.getAttribute(
|
|
151
|
-
const message = com.getAttribute(
|
|
171
|
+
const type = com.getAttribute("type") || "info";
|
|
172
|
+
const message = com.getAttribute("message") || "No message provided";
|
|
152
173
|
|
|
153
174
|
const colors = {
|
|
154
|
-
info:
|
|
155
|
-
success:
|
|
156
|
-
warning:
|
|
157
|
-
error:
|
|
175
|
+
info: "#3b82f6",
|
|
176
|
+
success: "#22c55e",
|
|
177
|
+
warning: "#f59e0b",
|
|
178
|
+
error: "#ef4444",
|
|
158
179
|
};
|
|
159
180
|
|
|
160
181
|
const color = colors[type as keyof typeof colors] || colors.info;
|
|
@@ -185,23 +206,23 @@ You can use all TypeScript features:
|
|
|
185
206
|
interface Stats {
|
|
186
207
|
label: string;
|
|
187
208
|
value: number;
|
|
188
|
-
trend:
|
|
209
|
+
trend: "up" | "down" | "neutral";
|
|
189
210
|
}
|
|
190
211
|
|
|
191
|
-
const label = com.getAttribute(
|
|
192
|
-
const value = parseInt(com.getAttribute(
|
|
193
|
-
const trend = com.getAttribute(
|
|
212
|
+
const label = com.getAttribute("label") || "Stat";
|
|
213
|
+
const value = parseInt(com.getAttribute("value") || "0");
|
|
214
|
+
const trend = (com.getAttribute("trend") as Stats["trend"]) || "neutral";
|
|
194
215
|
|
|
195
216
|
const trendIcon = {
|
|
196
|
-
up:
|
|
197
|
-
down:
|
|
198
|
-
neutral:
|
|
217
|
+
up: "↑",
|
|
218
|
+
down: "↓",
|
|
219
|
+
neutral: "→",
|
|
199
220
|
};
|
|
200
221
|
|
|
201
222
|
const trendColor = {
|
|
202
|
-
up:
|
|
203
|
-
down:
|
|
204
|
-
neutral:
|
|
223
|
+
up: "#22c55e",
|
|
224
|
+
down: "#ef4444",
|
|
225
|
+
neutral: "#6b7280",
|
|
205
226
|
};
|
|
206
227
|
|
|
207
228
|
com.innerHTML = `
|
|
@@ -221,10 +242,10 @@ You can import any TypeScript module or npm package:
|
|
|
221
242
|
|
|
222
243
|
```typescript
|
|
223
244
|
// product-card.com.ts
|
|
224
|
-
import { formatPrice } from
|
|
245
|
+
import { formatPrice } from "./utils";
|
|
225
246
|
|
|
226
|
-
const name = com.getAttribute(
|
|
227
|
-
const price = parseFloat(com.getAttribute(
|
|
247
|
+
const name = com.getAttribute("name") || "Product";
|
|
248
|
+
const price = parseFloat(com.getAttribute("price") || "0");
|
|
228
249
|
|
|
229
250
|
com.innerHTML = `
|
|
230
251
|
<div class="product-card">
|
|
@@ -237,9 +258,9 @@ com.innerHTML = `
|
|
|
237
258
|
```typescript
|
|
238
259
|
// utils.ts
|
|
239
260
|
export function formatPrice(price: number): string {
|
|
240
|
-
return new Intl.NumberFormat(
|
|
241
|
-
style:
|
|
242
|
-
currency:
|
|
261
|
+
return new Intl.NumberFormat("en-US", {
|
|
262
|
+
style: "currency",
|
|
263
|
+
currency: "USD",
|
|
243
264
|
}).format(price);
|
|
244
265
|
}
|
|
245
266
|
```
|
|
@@ -250,7 +271,7 @@ Fetch data at build time:
|
|
|
250
271
|
|
|
251
272
|
```typescript
|
|
252
273
|
// weather-widget.com.ts
|
|
253
|
-
const city = com.getAttribute(
|
|
274
|
+
const city = com.getAttribute("city") || "London";
|
|
254
275
|
|
|
255
276
|
interface WeatherData {
|
|
256
277
|
temperature: number;
|
|
@@ -279,9 +300,9 @@ com.innerHTML = `
|
|
|
279
300
|
|
|
280
301
|
```typescript
|
|
281
302
|
// markdown-content.com.ts
|
|
282
|
-
import { marked } from
|
|
303
|
+
import { marked } from "marked";
|
|
283
304
|
|
|
284
|
-
const content = com.getAttribute(
|
|
305
|
+
const content = com.getAttribute("content") || "# Hello";
|
|
285
306
|
const html = marked(content);
|
|
286
307
|
|
|
287
308
|
com.innerHTML = `
|
|
@@ -303,8 +324,8 @@ TypeScript components can use other components:
|
|
|
303
324
|
|
|
304
325
|
```typescript
|
|
305
326
|
// user-profile.com.ts
|
|
306
|
-
const username = com.getAttribute(
|
|
307
|
-
const bio = com.getAttribute(
|
|
327
|
+
const username = com.getAttribute("username") || "anonymous";
|
|
328
|
+
const bio = com.getAttribute("bio") || "No bio provided";
|
|
308
329
|
|
|
309
330
|
com.innerHTML = `
|
|
310
331
|
<div class="user-profile">
|
|
@@ -327,8 +348,8 @@ Event listeners are lost in the static output:
|
|
|
327
348
|
|
|
328
349
|
```typescript
|
|
329
350
|
// ❌ This won't work
|
|
330
|
-
com.addEventListener(
|
|
331
|
-
console.log(
|
|
351
|
+
com.addEventListener("click", () => {
|
|
352
|
+
console.log("clicked");
|
|
332
353
|
});
|
|
333
354
|
```
|
|
334
355
|
|
|
@@ -336,9 +357,9 @@ com.addEventListener('click', () => {
|
|
|
336
357
|
|
|
337
358
|
```typescript
|
|
338
359
|
// index.ts (runs in browser)
|
|
339
|
-
document.querySelectorAll(
|
|
340
|
-
button.addEventListener(
|
|
341
|
-
console.log(
|
|
360
|
+
document.querySelectorAll(".my-button").forEach((button) => {
|
|
361
|
+
button.addEventListener("click", () => {
|
|
362
|
+
console.log("clicked");
|
|
342
363
|
});
|
|
343
364
|
});
|
|
344
365
|
```
|
|
@@ -349,8 +370,8 @@ You can't access other parts of the document:
|
|
|
349
370
|
|
|
350
371
|
```typescript
|
|
351
372
|
// ❌ This won't work
|
|
352
|
-
const header = document.querySelector(
|
|
353
|
-
com.innerHTML = header?.textContent ||
|
|
373
|
+
const header = document.querySelector("header");
|
|
374
|
+
com.innerHTML = header?.textContent || "";
|
|
354
375
|
```
|
|
355
376
|
|
|
356
377
|
**Solution:** Use [pre-rendering](./pre-rendering.md) for document-wide transformations.
|
|
@@ -375,7 +396,7 @@ Build-time components can't access runtime data:
|
|
|
375
396
|
|
|
376
397
|
```typescript
|
|
377
398
|
// ❌ This won't work - no access to current user
|
|
378
|
-
const currentUser = localStorage.getItem(
|
|
399
|
+
const currentUser = localStorage.getItem("user");
|
|
379
400
|
com.innerHTML = `<p>Hello, ${currentUser}</p>`;
|
|
380
401
|
```
|
|
381
402
|
|
|
@@ -386,6 +407,7 @@ com.innerHTML = `<p>Hello, ${currentUser}</p>`;
|
|
|
386
407
|
### ✅ Use for Attribute-Driven Components
|
|
387
408
|
|
|
388
409
|
Perfect for:
|
|
410
|
+
|
|
389
411
|
- Components that vary based on attributes
|
|
390
412
|
- Generating repetitive HTML
|
|
391
413
|
- Build-time data transformation
|
|
@@ -395,11 +417,13 @@ Perfect for:
|
|
|
395
417
|
|
|
396
418
|
```typescript
|
|
397
419
|
// color-badge.com.ts
|
|
398
|
-
const validColors = [
|
|
399
|
-
const color = com.getAttribute(
|
|
420
|
+
const validColors = ["red", "blue", "green", "yellow"];
|
|
421
|
+
const color = com.getAttribute("color") || "blue";
|
|
400
422
|
|
|
401
423
|
if (!validColors.includes(color)) {
|
|
402
|
-
throw new Error(
|
|
424
|
+
throw new Error(
|
|
425
|
+
`Invalid color: ${color}. Use one of: ${validColors.join(", ")}`,
|
|
426
|
+
);
|
|
403
427
|
}
|
|
404
428
|
|
|
405
429
|
com.innerHTML = `<span class="badge badge-${color}">Badge</span>`;
|
|
@@ -415,14 +439,14 @@ Prevent XSS by escaping user-provided content:
|
|
|
415
439
|
// user-comment.com.ts
|
|
416
440
|
function escapeHtml(text: string): string {
|
|
417
441
|
return text
|
|
418
|
-
.replace(/&/g,
|
|
419
|
-
.replace(/</g,
|
|
420
|
-
.replace(/>/g,
|
|
421
|
-
.replace(/"/g,
|
|
422
|
-
.replace(/'/g,
|
|
442
|
+
.replace(/&/g, "&")
|
|
443
|
+
.replace(/</g, "<")
|
|
444
|
+
.replace(/>/g, ">")
|
|
445
|
+
.replace(/"/g, """)
|
|
446
|
+
.replace(/'/g, "'");
|
|
423
447
|
}
|
|
424
448
|
|
|
425
|
-
const comment = com.getAttribute(
|
|
449
|
+
const comment = com.getAttribute("comment") || "";
|
|
426
450
|
com.innerHTML = `<p>${escapeHtml(comment)}</p>`;
|
|
427
451
|
```
|
|
428
452
|
|
|
@@ -430,15 +454,15 @@ com.innerHTML = `<p>${escapeHtml(comment)}</p>`;
|
|
|
430
454
|
|
|
431
455
|
```typescript
|
|
432
456
|
// card.com.ts
|
|
433
|
-
type CardVariant =
|
|
457
|
+
type CardVariant = "default" | "outlined" | "elevated";
|
|
434
458
|
|
|
435
|
-
const variant = com.getAttribute(
|
|
436
|
-
const title = com.getAttribute(
|
|
459
|
+
const variant = (com.getAttribute("variant") as CardVariant) || "default";
|
|
460
|
+
const title = com.getAttribute("title") || "Card";
|
|
437
461
|
|
|
438
462
|
const variants = {
|
|
439
|
-
default:
|
|
440
|
-
outlined:
|
|
441
|
-
elevated:
|
|
463
|
+
default: "border: 1px solid #e5e7eb",
|
|
464
|
+
outlined: "border: 2px solid #3b82f6",
|
|
465
|
+
elevated: "box-shadow: 0 4px 6px rgba(0,0,0,0.1)",
|
|
442
466
|
};
|
|
443
467
|
|
|
444
468
|
com.innerHTML = `
|
|
@@ -452,9 +476,9 @@ com.innerHTML = `
|
|
|
452
476
|
|
|
453
477
|
```typescript
|
|
454
478
|
// data-table.com.ts
|
|
455
|
-
import { generateTableRows } from
|
|
479
|
+
import { generateTableRows } from "./table-utils";
|
|
456
480
|
|
|
457
|
-
const data = com.getAttribute(
|
|
481
|
+
const data = com.getAttribute("data") || "[]";
|
|
458
482
|
const rows = generateTableRows(JSON.parse(data));
|
|
459
483
|
|
|
460
484
|
com.innerHTML = `
|
|
@@ -482,8 +506,8 @@ If a component doesn't need attributes or logic, use [HTML components](./compone
|
|
|
482
506
|
|
|
483
507
|
```typescript
|
|
484
508
|
// debug-component.com.ts
|
|
485
|
-
const value = com.getAttribute(
|
|
486
|
-
console.log(
|
|
509
|
+
const value = com.getAttribute("value");
|
|
510
|
+
console.log("Building component with value:", value);
|
|
487
511
|
|
|
488
512
|
com.innerHTML = `<p>${value}</p>`;
|
|
489
513
|
```
|
|
@@ -514,13 +538,17 @@ cat web/index.html | grep "expected-content"
|
|
|
514
538
|
|
|
515
539
|
```typescript
|
|
516
540
|
// image-gallery.com.ts
|
|
517
|
-
const images = com.getAttribute(
|
|
541
|
+
const images = com.getAttribute("images")?.split(",") || [];
|
|
518
542
|
|
|
519
|
-
const imageElements = images
|
|
543
|
+
const imageElements = images
|
|
544
|
+
.map(
|
|
545
|
+
(img, idx) => `
|
|
520
546
|
<div class="gallery-item">
|
|
521
547
|
<img src="${img.trim()}" alt="Image ${idx + 1}" loading="lazy">
|
|
522
548
|
</div>
|
|
523
|
-
|
|
549
|
+
`,
|
|
550
|
+
)
|
|
551
|
+
.join("");
|
|
524
552
|
|
|
525
553
|
com.innerHTML = `
|
|
526
554
|
<div class="image-gallery">
|
|
@@ -539,8 +567,11 @@ com.innerHTML = `
|
|
|
539
567
|
|
|
540
568
|
```typescript
|
|
541
569
|
// progress-bar.com.ts
|
|
542
|
-
const progress = Math.min(
|
|
543
|
-
|
|
570
|
+
const progress = Math.min(
|
|
571
|
+
100,
|
|
572
|
+
Math.max(0, parseInt(com.getAttribute("progress") || "0")),
|
|
573
|
+
);
|
|
574
|
+
const label = com.getAttribute("label") || `${progress}%`;
|
|
544
575
|
|
|
545
576
|
com.innerHTML = `
|
|
546
577
|
<div class="progress-bar-container">
|
|
@@ -554,14 +585,14 @@ com.innerHTML = `
|
|
|
554
585
|
|
|
555
586
|
```typescript
|
|
556
587
|
// code-block.com.ts
|
|
557
|
-
import { codeToHtml } from
|
|
588
|
+
import { codeToHtml } from "shiki";
|
|
558
589
|
|
|
559
|
-
const code = com.getAttribute(
|
|
560
|
-
const lang = com.getAttribute(
|
|
590
|
+
const code = com.getAttribute("code") || "";
|
|
591
|
+
const lang = com.getAttribute("lang") || "typescript";
|
|
561
592
|
|
|
562
593
|
const html = await codeToHtml(code, {
|
|
563
594
|
lang,
|
|
564
|
-
theme:
|
|
595
|
+
theme: "github-dark",
|
|
565
596
|
});
|
|
566
597
|
|
|
567
598
|
com.innerHTML = `
|
|
@@ -587,8 +618,8 @@ bun add shiki
|
|
|
587
618
|
|
|
588
619
|
```typescript
|
|
589
620
|
// social-share.com.ts
|
|
590
|
-
const url = com.getAttribute(
|
|
591
|
-
const title = com.getAttribute(
|
|
621
|
+
const url = com.getAttribute("url") || "";
|
|
622
|
+
const title = com.getAttribute("title") || "";
|
|
592
623
|
|
|
593
624
|
const encodedUrl = encodeURIComponent(url);
|
|
594
625
|
const encodedTitle = encodeURIComponent(title);
|
|
@@ -620,7 +651,7 @@ Add types for better development experience:
|
|
|
620
651
|
/// <reference path="./tkeron.d.ts" />
|
|
621
652
|
|
|
622
653
|
// Now 'com' has full type information
|
|
623
|
-
const attr = com.getAttribute(
|
|
654
|
+
const attr = com.getAttribute("name"); // TypeScript knows about this
|
|
624
655
|
```
|
|
625
656
|
|
|
626
657
|
## Performance Considerations
|
|
@@ -631,7 +662,7 @@ Complex components increase build time:
|
|
|
631
662
|
|
|
632
663
|
```typescript
|
|
633
664
|
// ⚠️ Expensive at build time
|
|
634
|
-
const data = await fetch(
|
|
665
|
+
const data = await fetch("https://api.example.com/large-dataset");
|
|
635
666
|
```
|
|
636
667
|
|
|
637
668
|
For large datasets, consider caching or pre-processing.
|
package/docs/getting-started.md
CHANGED
|
@@ -3,16 +3,19 @@
|
|
|
3
3
|
## Installation
|
|
4
4
|
|
|
5
5
|
**Requires [Bun](https://bun.sh) runtime:**
|
|
6
|
+
|
|
6
7
|
```bash
|
|
7
8
|
curl -fsSL https://bun.sh/install | bash
|
|
8
9
|
```
|
|
9
10
|
|
|
10
11
|
**Install Tkeron:**
|
|
12
|
+
|
|
11
13
|
```bash
|
|
12
14
|
bun install -g tkeron
|
|
13
15
|
```
|
|
14
16
|
|
|
15
17
|
**Verify:**
|
|
18
|
+
|
|
16
19
|
```bash
|
|
17
20
|
tk
|
|
18
21
|
```
|
|
@@ -65,6 +68,7 @@ tk build websrc web
|
|
|
65
68
|
```
|
|
66
69
|
|
|
67
70
|
**Parameters:**
|
|
71
|
+
|
|
68
72
|
- First argument: source directory (default: `websrc`)
|
|
69
73
|
- Second argument: output directory (default: `web`)
|
|
70
74
|
|
|
@@ -96,6 +100,7 @@ tk dev
|
|
|
96
100
|
```
|
|
97
101
|
|
|
98
102
|
This will:
|
|
103
|
+
|
|
99
104
|
1. Build your project
|
|
100
105
|
2. Start a server at `http://localhost:3000`
|
|
101
106
|
3. Watch for file changes
|
|
@@ -108,6 +113,7 @@ tk dev websrc web 8080 0.0.0.0
|
|
|
108
113
|
```
|
|
109
114
|
|
|
110
115
|
**Parameters:**
|
|
116
|
+
|
|
111
117
|
- Source directory (default: `websrc`)
|
|
112
118
|
- Output directory (default: `web`)
|
|
113
119
|
- Port (default: `3000`)
|
|
@@ -143,15 +149,15 @@ Edit `websrc/index.html`:
|
|
|
143
149
|
```html
|
|
144
150
|
<!DOCTYPE html>
|
|
145
151
|
<html lang="en">
|
|
146
|
-
<head>
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
</head>
|
|
150
|
-
<body>
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
</body>
|
|
152
|
+
<head>
|
|
153
|
+
<meta charset="UTF-8" />
|
|
154
|
+
<title>My First Tkeron Site</title>
|
|
155
|
+
</head>
|
|
156
|
+
<body>
|
|
157
|
+
<h1>My Website</h1>
|
|
158
|
+
<greeting></greeting>
|
|
159
|
+
<greeting></greeting>
|
|
160
|
+
</body>
|
|
155
161
|
</html>
|
|
156
162
|
```
|
|
157
163
|
|
|
@@ -189,15 +195,15 @@ Open `web/index.html` in your browser. You'll see the greeting component inlined
|
|
|
189
195
|
|
|
190
196
|
### What Gets Processed?
|
|
191
197
|
|
|
192
|
-
| File Type
|
|
193
|
-
|
|
194
|
-
| `.html`
|
|
195
|
-
| `.ts` / `.js`
|
|
196
|
-
| `.com.html`
|
|
197
|
-
| `.com.ts`
|
|
198
|
-
| `.pre.ts`
|
|
199
|
-
| `.css`
|
|
200
|
-
| Images, fonts, etc. | Static assets
|
|
198
|
+
| File Type | Purpose | In Output? |
|
|
199
|
+
| ------------------- | --------------------- | ----------------- |
|
|
200
|
+
| `.html` | Regular HTML pages | ✅ Yes |
|
|
201
|
+
| `.ts` / `.js` | Scripts for pages | ✅ Yes (compiled) |
|
|
202
|
+
| `.com.html` | HTML components | ❌ No (inlined) |
|
|
203
|
+
| `.com.ts` | TypeScript components | ❌ No (inlined) |
|
|
204
|
+
| `.pre.ts` | Pre-rendering scripts | ❌ No (executed) |
|
|
205
|
+
| `.css` | Stylesheets | ✅ Yes |
|
|
206
|
+
| Images, fonts, etc. | Static assets | ✅ Yes |
|
|
201
207
|
|
|
202
208
|
## Common Commands
|
|
203
209
|
|
package/docs/mcp-server.md
CHANGED
|
@@ -15,6 +15,7 @@ bun install -g tkeron
|
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
This installs three commands:
|
|
18
|
+
|
|
18
19
|
- `tk` / `tkeron` - The main CLI tool
|
|
19
20
|
- `tkeron-mcp` - The MCP server
|
|
20
21
|
|
|
@@ -48,7 +49,8 @@ If the global command is not found, use Bun directly:
|
|
|
48
49
|
```
|
|
49
50
|
|
|
50
51
|
**Note:** This is the VS Code format. Other editors (Cursor, Windsurf, etc.) may use different configuration formats.
|
|
51
|
-
|
|
52
|
+
|
|
53
|
+
````
|
|
52
54
|
|
|
53
55
|
**Find the path:**
|
|
54
56
|
```bash
|
|
@@ -58,7 +60,7 @@ dirname $(which tk)
|
|
|
58
60
|
|
|
59
61
|
# The mcp-server.ts is in the same directory
|
|
60
62
|
ls $(dirname $(which tk))/mcp-server.ts
|
|
61
|
-
|
|
63
|
+
````
|
|
62
64
|
|
|
63
65
|
### Claude Desktop
|
|
64
66
|
|
|
@@ -88,15 +90,16 @@ The server communicates via stdio transport.
|
|
|
88
90
|
|
|
89
91
|
The MCP server exposes the following documentation resources:
|
|
90
92
|
|
|
91
|
-
| URI
|
|
92
|
-
|
|
93
|
-
| `tkeron://overview`
|
|
94
|
-
| `tkeron://getting-started`
|
|
95
|
-
| `tkeron://components-html`
|
|
96
|
-
| `tkeron://components-typescript` | Build dynamic components with .com.ts files
|
|
97
|
-
| `tkeron://pre-rendering`
|
|
98
|
-
| `tkeron://cli-reference`
|
|
99
|
-
| `tkeron://best-practices`
|
|
93
|
+
| URI | Description |
|
|
94
|
+
| -------------------------------- | ---------------------------------------------------- |
|
|
95
|
+
| `tkeron://overview` | What Tkeron is, what it does, and what it's not |
|
|
96
|
+
| `tkeron://getting-started` | Installation, first project, and basic workflow |
|
|
97
|
+
| `tkeron://components-html` | Create reusable HTML components with .com.html files |
|
|
98
|
+
| `tkeron://components-typescript` | Build dynamic components with .com.ts files |
|
|
99
|
+
| `tkeron://pre-rendering` | Transform HTML at build time with .pre.ts files |
|
|
100
|
+
| `tkeron://cli-reference` | Complete command-line interface documentation |
|
|
101
|
+
| `tkeron://best-practices` | Patterns, anti-patterns, and limitations |
|
|
102
|
+
| `tkeron://testing` | How to test tkeron projects with getBuildResult() |
|
|
100
103
|
|
|
101
104
|
## What AI Agents Can Do
|
|
102
105
|
|
|
@@ -109,25 +112,19 @@ With access to the MCP server, AI agents can:
|
|
|
109
112
|
- ✅ Provide accurate CLI commands and options
|
|
110
113
|
- ✅ Debug common issues with components and pre-rendering
|
|
111
114
|
- ✅ Recommend best practices and avoid anti-patterns
|
|
112
|
-
- ✅ **Initialize new Tkeron projects directly**
|
|
113
|
-
- ✅ **Build and develop Tkeron projects**
|
|
114
115
|
- ✅ **List and explore example projects**
|
|
115
116
|
- ✅ **Retrieve example code and structures**
|
|
117
|
+
- ✅ **Initialize, build, and develop projects via terminal** (`tk init`, `tk build`, `tk dev`)
|
|
116
118
|
|
|
117
119
|
## Available Tools
|
|
118
120
|
|
|
119
121
|
The MCP server provides the following tools for AI agents:
|
|
120
122
|
|
|
121
|
-
### Documentation Tool
|
|
122
|
-
|
|
123
|
-
- **`get_tkeron_docs`**: Retrieve specific documentation topics
|
|
124
|
-
- Parameters: `topic` (overview, getting-started, components-html, etc.)
|
|
125
|
-
- Returns the full markdown content of the requested documentation
|
|
126
|
-
|
|
127
123
|
### Example Management Tools
|
|
128
124
|
|
|
129
125
|
- **`list_examples`**: List all available Tkeron example projects
|
|
130
|
-
-
|
|
126
|
+
- No parameters required
|
|
127
|
+
- Returns example names, descriptions, and paths
|
|
131
128
|
- Helps users discover what's possible with Tkeron
|
|
132
129
|
|
|
133
130
|
- **`get_example`**: Get the complete source code of an example
|
|
@@ -135,22 +132,7 @@ The MCP server provides the following tools for AI agents:
|
|
|
135
132
|
- Returns file structure and all source code
|
|
136
133
|
- Useful for learning patterns and bootstrapping projects
|
|
137
134
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
- **`tkeron_init`**: Initialize a new Tkeron project
|
|
141
|
-
- Parameters: `projectPath` (absolute path), `force` (optional boolean)
|
|
142
|
-
- Creates the standard Tkeron structure (websrc/ with sample files)
|
|
143
|
-
- AI agents can create projects without user intervention
|
|
144
|
-
|
|
145
|
-
- **`tkeron_build`**: Build a Tkeron project
|
|
146
|
-
- Parameters: `sourceDir`, `targetDir` (optional)
|
|
147
|
-
- Processes all `.pre.ts`, `.com.html`, and `.com.ts` files
|
|
148
|
-
- Generates production-ready output
|
|
149
|
-
|
|
150
|
-
- **`tkeron_develop`**: Start the development server
|
|
151
|
-
- Parameters: `sourceDir`, `outputDir`, `port`, `host` (all optional)
|
|
152
|
-
- Launches hot-reload development server
|
|
153
|
-
- AI agents can test projects immediately after creation
|
|
135
|
+
> **Note:** The MCP server only provides documentation and examples. It does NOT modify files. The AI agent should use terminal commands (`tk init`, `tk build`, `tk dev`) to manage projects.
|
|
154
136
|
|
|
155
137
|
## Benefits
|
|
156
138
|
|
|
@@ -202,6 +184,7 @@ bun install
|
|
|
202
184
|
### MCP Client Not Connecting
|
|
203
185
|
|
|
204
186
|
Check your configuration file syntax:
|
|
187
|
+
|
|
205
188
|
- Valid JSON
|
|
206
189
|
- Correct command path
|
|
207
190
|
- Proper permissions on the executable
|