tkeron 4.1.0 → 4.2.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/changelog.md +26 -0
- package/docs/components-typescript.md +40 -0
- package/docs/getting-started.md +2 -1
- package/docs/pre-rendering.md +20 -0
- package/examples/init_sample/tkeron.d.ts +13 -0
- package/examples/init_sample/websrc/index.ts +6 -6
- package/examples/init_sample/websrc/user-badge.com.ts +4 -3
- package/package.json +1 -1
package/changelog.md
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
# v4.2.0
|
|
2
|
+
|
|
3
|
+
## Developer Experience
|
|
4
|
+
|
|
5
|
+
### New Features
|
|
6
|
+
|
|
7
|
+
- **Added**: TypeScript configuration to `init_sample` example
|
|
8
|
+
- `tsconfig.json` - Minimal TypeScript configuration for IDE support
|
|
9
|
+
- `tkeron.d.ts` - Type definitions for `.com.ts` and `.pre.ts` files
|
|
10
|
+
- Enables IntelliSense for `com` variable in `.com.ts` files
|
|
11
|
+
- Enables IntelliSense for `document` variable in `.pre.ts` files
|
|
12
|
+
- Improves developer experience in VS Code and other IDEs
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
- **Fixed**: Variable naming conflict in `init_sample/websrc/index.ts`
|
|
17
|
+
- Renamed `count` to `clickCount` to avoid TypeScript scope collision
|
|
18
|
+
- **Fixed**: TypeScript type error in `init_sample/websrc/user-badge.com.ts`
|
|
19
|
+
- Added explicit `parseInt` radix parameter for type safety
|
|
20
|
+
|
|
21
|
+
### Tests
|
|
22
|
+
|
|
23
|
+
- **Updated**: Test expectations to match renamed variables in `init_sample`
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
1
27
|
# v4.1.0
|
|
2
28
|
|
|
3
29
|
## Documentation & Developer Experience
|
|
@@ -86,6 +86,46 @@ Same as HTML components:
|
|
|
86
86
|
1. **Same directory** as the file using it
|
|
87
87
|
2. **Root directory** (`websrc/`)
|
|
88
88
|
|
|
89
|
+
### IDE Support & IntelliSense
|
|
90
|
+
|
|
91
|
+
For the best development experience, Tkeron projects include TypeScript configuration files:
|
|
92
|
+
|
|
93
|
+
**`tkeron.d.ts`** - Provides type definitions:
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
declare module "*.com.ts" {
|
|
97
|
+
global {
|
|
98
|
+
const com: HTMLElement;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
This tells your IDE that `com` is an `HTMLElement`, enabling:
|
|
104
|
+
|
|
105
|
+
- **IntelliSense** for `com.getAttribute()`, `com.innerHTML`, etc.
|
|
106
|
+
- **Type checking** for your component code
|
|
107
|
+
- **Auto-completion** for DOM methods and properties
|
|
108
|
+
|
|
109
|
+
**`tsconfig.json`** - TypeScript configuration:
|
|
110
|
+
|
|
111
|
+
```json
|
|
112
|
+
{
|
|
113
|
+
"compilerOptions": {
|
|
114
|
+
"target": "ESNext",
|
|
115
|
+
"module": "ESNext",
|
|
116
|
+
"lib": ["ESNext", "DOM"],
|
|
117
|
+
"moduleResolution": "bundler",
|
|
118
|
+
"strict": true,
|
|
119
|
+
"skipLibCheck": true
|
|
120
|
+
},
|
|
121
|
+
"include": ["websrc/**/*", "tkeron.d.ts"]
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Both files are automatically created when you run `tk init`. If you created your project manually, you can copy them from the [init_sample example](https://github.com/pablotk/tkeron/tree/master/examples/init_sample).
|
|
126
|
+
|
|
127
|
+
**Note:** These files are only for IDE support and don't affect the build process. Tkeron uses Bun's built-in TypeScript support for compilation.
|
|
128
|
+
|
|
89
129
|
## Basic Examples
|
|
90
130
|
|
|
91
131
|
### Attribute-Based Content
|
package/docs/getting-started.md
CHANGED
|
@@ -38,7 +38,8 @@ my-website/
|
|
|
38
38
|
│ ├── index.ts # TypeScript for index
|
|
39
39
|
│ ├── index.pre.ts # Pre-rendering script
|
|
40
40
|
│ └── *.com.html # Sample components
|
|
41
|
-
|
|
41
|
+
├── tkeron.d.ts # TypeScript definitions
|
|
42
|
+
└── tsconfig.json # TypeScript configuration
|
|
42
43
|
```
|
|
43
44
|
|
|
44
45
|
### Initialize in Current Directory
|
package/docs/pre-rendering.md
CHANGED
|
@@ -97,6 +97,26 @@ If the `.html` file doesn't exist, Tkeron creates a default one:
|
|
|
97
97
|
|
|
98
98
|
Then your `.pre.ts` file runs on this template.
|
|
99
99
|
|
|
100
|
+
### IDE Support & IntelliSense
|
|
101
|
+
|
|
102
|
+
The `tkeron.d.ts` file in your project provides type definitions for the `document` variable:
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
declare module "*.pre.ts" {
|
|
106
|
+
global {
|
|
107
|
+
const document: Document;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
This enables:
|
|
113
|
+
|
|
114
|
+
- **IntelliSense** for `document.querySelector()`, `document.getElementById()`, etc.
|
|
115
|
+
- **Type checking** for DOM manipulation
|
|
116
|
+
- **Auto-completion** for all Document methods and properties
|
|
117
|
+
|
|
118
|
+
The `tsconfig.json` ensures your IDE recognizes these types. Both files are automatically created by `tk init`.
|
|
119
|
+
|
|
100
120
|
## Basic Examples
|
|
101
121
|
|
|
102
122
|
### Set Page Title
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// Client-side TypeScript - runs in the browser
|
|
2
|
-
let
|
|
2
|
+
let clickCount = 0;
|
|
3
3
|
|
|
4
|
-
const button = document.getElementById(
|
|
5
|
-
const countDisplay = document.getElementById(
|
|
4
|
+
const button = document.getElementById("increment") as HTMLButtonElement;
|
|
5
|
+
const countDisplay = document.getElementById("count") as HTMLSpanElement;
|
|
6
6
|
|
|
7
|
-
button.addEventListener(
|
|
8
|
-
|
|
9
|
-
countDisplay.textContent =
|
|
7
|
+
button.addEventListener("click", () => {
|
|
8
|
+
clickCount++;
|
|
9
|
+
countDisplay.textContent = clickCount.toString();
|
|
10
10
|
});
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
// TypeScript component - runs at build time with logic
|
|
2
|
-
const count = com.getAttribute(
|
|
2
|
+
const count = com.getAttribute("count") || "3";
|
|
3
|
+
const numCount = parseInt(count, 10);
|
|
3
4
|
|
|
4
5
|
// Generate list dynamically
|
|
5
6
|
const items = [];
|
|
6
|
-
for (let i = 1; i <=
|
|
7
|
+
for (let i = 1; i <= numCount; i++) {
|
|
7
8
|
items.push(`<li>✓ Item ${i}</li>`);
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
com.innerHTML = `
|
|
11
12
|
<div style="background: #f0fdf4; border-left: 3px solid #22c55e; padding: 0.75rem; border-radius: 4px;">
|
|
12
13
|
<ul style="list-style: none; padding: 0; margin: 0; font-size: 0.9rem; color: #166534;">
|
|
13
|
-
${items.join(
|
|
14
|
+
${items.join("")}
|
|
14
15
|
</ul>
|
|
15
16
|
</div>
|
|
16
17
|
`;
|