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 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
@@ -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
- └── tkeron.d.ts # TypeScript definitions
41
+ ├── tkeron.d.ts # TypeScript definitions
42
+ └── tsconfig.json # TypeScript configuration
42
43
  ```
43
44
 
44
45
  ### Initialize in Current Directory
@@ -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
@@ -0,0 +1,13 @@
1
+ // Augment global scope for .pre.ts files
2
+ declare module "*.pre.ts" {
3
+ global {
4
+ const document: Document;
5
+ }
6
+ }
7
+
8
+ // Augment global scope for .com.ts files
9
+ declare module "*.com.ts" {
10
+ global {
11
+ const com: HTMLElement;
12
+ }
13
+ }
@@ -1,10 +1,10 @@
1
1
  // Client-side TypeScript - runs in the browser
2
- let count = 0;
2
+ let clickCount = 0;
3
3
 
4
- const button = document.getElementById('increment') as HTMLButtonElement;
5
- const countDisplay = document.getElementById('count') as HTMLSpanElement;
4
+ const button = document.getElementById("increment") as HTMLButtonElement;
5
+ const countDisplay = document.getElementById("count") as HTMLSpanElement;
6
6
 
7
- button.addEventListener('click', () => {
8
- count++;
9
- countDisplay.textContent = count.toString();
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('count') || '3';
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 <= parseInt(count); 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
  `;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tkeron",
3
- "version": "4.1.0",
3
+ "version": "4.2.0",
4
4
  "description": "CLI tool for backend-driven frontend development with TypeScript.",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",