@ktjs/core 0.8.3 → 0.9.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/dist/index.d.ts CHANGED
@@ -24,13 +24,12 @@ type HTMLTag = keyof HTMLElementTagNameMap & otherstring;
24
24
 
25
25
  interface KTRef<T> {
26
26
  value: T;
27
- update: () => T;
28
- isRef: true;
27
+ isKT: true;
29
28
  }
30
29
  declare function ref<T>(value?: T): KTRef<T>;
31
30
 
32
- type Ctt = KTRef<any> | HTMLElement | string | number | undefined;
33
- type KTRawContent = Ctt[] | Ctt;
31
+ type KTAvailableContent = KTRef<any> | HTMLElement | string | number | undefined;
32
+ type KTRawContent = KTAvailableContent[] | KTAvailableContent;
34
33
  type KTRawAttr = KTAttribute | string;
35
34
  type KTRawContents = (HTMLElement | string | undefined)[];
36
35
 
@@ -100,6 +99,10 @@ type KTPrefixedEventHandlers = {
100
99
  type KTAttribute = KTBaseAttribute & KTPrefixedEventHandlers;
101
100
 
102
101
  type HTML<T extends HTMLTag & otherstring> = T extends HTMLTag ? HTMLElementTagNameMap[T] : HTMLElement;
102
+ type H = (<T extends HTMLTag>(tag: T, attr?: KTRawAttr, content?: KTRawContent) => HTML<T>) & {
103
+ kDepth: number;
104
+ kUpdater: (() => void)[];
105
+ };
103
106
  /**
104
107
  * Create an enhanced HTMLElement.
105
108
  * - Only supports HTMLElements, **NOT** SVGElements or other Elements.
@@ -110,21 +113,21 @@ type HTML<T extends HTMLTag & otherstring> = T extends HTMLTag ? HTMLElementTagN
110
113
  * ## About
111
114
  * @package @ktjs/core
112
115
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
113
- * @version 0.8.3 (Last Update: 2025.12.25 11:27:17.924)
116
+ * @version 0.9.0 (Last Update: 2025.12.29 11:09:49.983)
114
117
  * @license MIT
115
118
  * @link https://github.com/baendlorel/kt.js
116
119
  * @link https://baendlorel.github.io/ Welcome to my site!
117
120
  * @description Core functionality for kt.js - DOM manipulation utilities with JSX/TSX support
118
121
  * @copyright Copyright (c) 2025 Kasukabe Tsumugi. All rights reserved.
119
122
  */
120
- declare const h: <T extends HTMLTag>(tag: T, attr?: KTRawAttr, content?: KTRawContent) => HTML<T>;
123
+ declare const h: H;
121
124
 
122
125
  /**
123
- * @param tag html tag
126
+ * @param tag html tag or function component
124
127
  * @param props properties/attributes
125
128
  * @param _metadata metadata is ignored
126
129
  */
127
- declare function jsx<T extends HTMLTag>(tag: T, props: KTRawAttr, ..._metadata: any[]): HTMLElementTagNameMap[T];
130
+ declare function jsx<T extends HTMLTag>(tag: T | Function, props: KTRawAttr, ..._metadata: any[]): HTMLElementTagNameMap[T] | HTMLElement;
128
131
  /**
129
132
  * Fragment support - returns an array of children
130
133
  * Note: kt.js doesn't have a real Fragment concept,
@@ -175,25 +175,22 @@ var __ktjs_core__ = (function (exports) {
175
175
  }
176
176
  }
177
177
 
178
+ function apd(element, content) {
179
+ if (content && content.isKT) {
180
+ $append.call(element, content.value);
181
+ }
182
+ else {
183
+ $append.call(element, content);
184
+ }
185
+ }
178
186
  function applyContent(element, content) {
179
187
  if ($isArray(content)) {
180
188
  for (let i = 0; i < content.length; i++) {
181
- let c = content[i];
182
- if (c && c.isRef) {
183
- $append.call(element, c.value);
184
- }
185
- else {
186
- $append.call(element, c);
187
- }
189
+ apd(element, content[i]);
188
190
  }
189
191
  }
190
192
  else {
191
- if (content && content.isRef) {
192
- $append.call(element, content.value);
193
- }
194
- else {
195
- $append.call(element, content);
196
- }
193
+ apd(element, content);
197
194
  }
198
195
  }
199
196
 
@@ -207,14 +204,14 @@ var __ktjs_core__ = (function (exports) {
207
204
  * ## About
208
205
  * @package @ktjs/core
209
206
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
210
- * @version 0.8.3 (Last Update: 2025.12.25 11:27:17.924)
207
+ * @version 0.9.0 (Last Update: 2025.12.29 11:09:49.983)
211
208
  * @license MIT
212
209
  * @link https://github.com/baendlorel/kt.js
213
210
  * @link https://baendlorel.github.io/ Welcome to my site!
214
211
  * @description Core functionality for kt.js - DOM manipulation utilities with JSX/TSX support
215
212
  * @copyright Copyright (c) 2025 Kasukabe Tsumugi. All rights reserved.
216
213
  */
217
- const h = (tag, attr = '', content = '') => {
214
+ const h = ((tag, attr = '', content = '') => {
218
215
  if (typeof tag !== 'string') {
219
216
  $throw('__func__ tagName must be a string.');
220
217
  }
@@ -224,15 +221,22 @@ var __ktjs_core__ = (function (exports) {
224
221
  applyAttr(element, attr);
225
222
  applyContent(element, content);
226
223
  return element;
227
- };
224
+ });
228
225
  $mark(h, 'h');
229
226
 
230
227
  /**
231
- * @param tag html tag
228
+ * @param tag html tag or function component
232
229
  * @param props properties/attributes
233
230
  * @param _metadata metadata is ignored
234
231
  */
235
232
  function jsx(tag, props, ..._metadata) {
233
+ // Handle function components
234
+ if (typeof tag === 'function') {
235
+ const propObj = typeof props === 'string' ? { class: props } : props || {};
236
+ const children = propObj.children;
237
+ return tag({ ...propObj, children });
238
+ }
239
+ // Handle regular HTML tags
236
240
  const propObj = typeof props === 'string' ? { class: props } : props;
237
241
  if (propObj === undefined || propObj === null) {
238
242
  return h(tag);
@@ -247,12 +251,6 @@ var __ktjs_core__ = (function (exports) {
247
251
  const el = h(tag, propObj, children);
248
252
  if (ref) {
249
253
  ref.value = el;
250
- ref.update = () => {
251
- const old = ref.value;
252
- ref.value = h(tag, propObj, children);
253
- old.replaceWith(ref.value);
254
- return ref.value;
255
- };
256
254
  }
257
255
  return el;
258
256
  }
@@ -300,9 +298,8 @@ var __ktjs_core__ = (function (exports) {
300
298
  */
301
299
  const jsxs = jsx;
302
300
 
303
- const noop = () => ({});
304
301
  function ref(value) {
305
- return { value: value, update: noop, isRef: true };
302
+ return { value: value, isKT: true };
306
303
  }
307
304
 
308
305
  exports.Fragment = Fragment;
@@ -186,25 +186,22 @@ var __ktjs_core__ = (function (exports) {
186
186
  }
187
187
  }
188
188
 
189
+ function apd(element, content) {
190
+ if (content && content.isKT) {
191
+ $append.call(element, content.value);
192
+ }
193
+ else {
194
+ $append.call(element, content);
195
+ }
196
+ }
189
197
  function applyContent(element, content) {
190
198
  if ($isArray(content)) {
191
199
  for (var i = 0; i < content.length; i++) {
192
- var c = content[i];
193
- if (c && c.isRef) {
194
- $append.call(element, c.value);
195
- }
196
- else {
197
- $append.call(element, c);
198
- }
200
+ apd(element, content[i]);
199
201
  }
200
202
  }
201
203
  else {
202
- if (content && content.isRef) {
203
- $append.call(element, content.value);
204
- }
205
- else {
206
- $append.call(element, content);
207
- }
204
+ apd(element, content);
208
205
  }
209
206
  }
210
207
 
@@ -218,14 +215,14 @@ var __ktjs_core__ = (function (exports) {
218
215
  * ## About
219
216
  * @package @ktjs/core
220
217
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
221
- * @version 0.8.3 (Last Update: 2025.12.25 11:27:17.924)
218
+ * @version 0.9.0 (Last Update: 2025.12.29 11:09:49.983)
222
219
  * @license MIT
223
220
  * @link https://github.com/baendlorel/kt.js
224
221
  * @link https://baendlorel.github.io/ Welcome to my site!
225
222
  * @description Core functionality for kt.js - DOM manipulation utilities with JSX/TSX support
226
223
  * @copyright Copyright (c) 2025 Kasukabe Tsumugi. All rights reserved.
227
224
  */
228
- var h = function (tag, attr, content) {
225
+ var h = (function (tag, attr, content) {
229
226
  if (attr === void 0) { attr = ''; }
230
227
  if (content === void 0) { content = ''; }
231
228
  if (typeof tag !== 'string') {
@@ -237,7 +234,7 @@ var __ktjs_core__ = (function (exports) {
237
234
  applyAttr(element, attr);
238
235
  applyContent(element, content);
239
236
  return element;
240
- };
237
+ });
241
238
  $mark(h, 'h');
242
239
 
243
240
  /******************************************************************************
@@ -257,6 +254,17 @@ var __ktjs_core__ = (function (exports) {
257
254
  /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
258
255
 
259
256
 
257
+ var __assign = function() {
258
+ __assign = Object.assign || function __assign(t) {
259
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
260
+ s = arguments[i];
261
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
262
+ }
263
+ return t;
264
+ };
265
+ return __assign.apply(this, arguments);
266
+ };
267
+
260
268
  function __spreadArray(to, from, pack) {
261
269
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
262
270
  if (ar || !(i in from)) {
@@ -273,12 +281,19 @@ var __ktjs_core__ = (function (exports) {
273
281
  };
274
282
 
275
283
  /**
276
- * @param tag html tag
284
+ * @param tag html tag or function component
277
285
  * @param props properties/attributes
278
286
  * @param _metadata metadata is ignored
279
287
  */
280
288
  function jsx(tag, props) {
281
289
  var _a;
290
+ // Handle function components
291
+ if (typeof tag === 'function') {
292
+ var propObj_1 = typeof props === 'string' ? { class: props } : props || {};
293
+ var children_1 = propObj_1.children;
294
+ return tag(__assign(__assign({}, propObj_1), { children: children_1 }));
295
+ }
296
+ // Handle regular HTML tags
282
297
  var propObj = typeof props === 'string' ? { class: props } : props;
283
298
  if (propObj === undefined || propObj === null) {
284
299
  return h(tag);
@@ -293,12 +308,6 @@ var __ktjs_core__ = (function (exports) {
293
308
  var el = h(tag, propObj, children);
294
309
  if (ref) {
295
310
  ref.value = el;
296
- ref.update = function () {
297
- var old = ref.value;
298
- ref.value = h(tag, propObj, children);
299
- old.replaceWith(ref.value);
300
- return ref.value;
301
- };
302
311
  }
303
312
  return el;
304
313
  }
@@ -351,9 +360,8 @@ var __ktjs_core__ = (function (exports) {
351
360
  */
352
361
  var jsxs = jsx;
353
362
 
354
- var noop = function () { return ({}); };
355
363
  function ref(value) {
356
- return { value: value, update: noop, isRef: true };
364
+ return { value: value, isKT: true };
357
365
  }
358
366
 
359
367
  exports.Fragment = Fragment;
package/dist/index.mjs CHANGED
@@ -172,25 +172,22 @@ function applyAttr(element, attr) {
172
172
  }
173
173
  }
174
174
 
175
+ function apd(element, content) {
176
+ if (content && content.isKT) {
177
+ $append.call(element, content.value);
178
+ }
179
+ else {
180
+ $append.call(element, content);
181
+ }
182
+ }
175
183
  function applyContent(element, content) {
176
184
  if ($isArray(content)) {
177
185
  for (let i = 0; i < content.length; i++) {
178
- let c = content[i];
179
- if (c && c.isRef) {
180
- $append.call(element, c.value);
181
- }
182
- else {
183
- $append.call(element, c);
184
- }
186
+ apd(element, content[i]);
185
187
  }
186
188
  }
187
189
  else {
188
- if (content && content.isRef) {
189
- $append.call(element, content.value);
190
- }
191
- else {
192
- $append.call(element, content);
193
- }
190
+ apd(element, content);
194
191
  }
195
192
  }
196
193
 
@@ -204,14 +201,14 @@ function applyContent(element, content) {
204
201
  * ## About
205
202
  * @package @ktjs/core
206
203
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
207
- * @version 0.8.3 (Last Update: 2025.12.25 11:27:17.924)
204
+ * @version 0.9.0 (Last Update: 2025.12.29 11:09:49.983)
208
205
  * @license MIT
209
206
  * @link https://github.com/baendlorel/kt.js
210
207
  * @link https://baendlorel.github.io/ Welcome to my site!
211
208
  * @description Core functionality for kt.js - DOM manipulation utilities with JSX/TSX support
212
209
  * @copyright Copyright (c) 2025 Kasukabe Tsumugi. All rights reserved.
213
210
  */
214
- const h = (tag, attr = '', content = '') => {
211
+ const h = ((tag, attr = '', content = '') => {
215
212
  if (typeof tag !== 'string') {
216
213
  $throw('__func__ tagName must be a string.');
217
214
  }
@@ -221,15 +218,22 @@ const h = (tag, attr = '', content = '') => {
221
218
  applyAttr(element, attr);
222
219
  applyContent(element, content);
223
220
  return element;
224
- };
221
+ });
225
222
  $mark(h, 'h');
226
223
 
227
224
  /**
228
- * @param tag html tag
225
+ * @param tag html tag or function component
229
226
  * @param props properties/attributes
230
227
  * @param _metadata metadata is ignored
231
228
  */
232
229
  function jsx(tag, props, ..._metadata) {
230
+ // Handle function components
231
+ if (typeof tag === 'function') {
232
+ const propObj = typeof props === 'string' ? { class: props } : props || {};
233
+ const children = propObj.children;
234
+ return tag({ ...propObj, children });
235
+ }
236
+ // Handle regular HTML tags
233
237
  const propObj = typeof props === 'string' ? { class: props } : props;
234
238
  if (propObj === undefined || propObj === null) {
235
239
  return h(tag);
@@ -244,12 +248,6 @@ function jsx(tag, props, ..._metadata) {
244
248
  const el = h(tag, propObj, children);
245
249
  if (ref) {
246
250
  ref.value = el;
247
- ref.update = () => {
248
- const old = ref.value;
249
- ref.value = h(tag, propObj, children);
250
- old.replaceWith(ref.value);
251
- return ref.value;
252
- };
253
251
  }
254
252
  return el;
255
253
  }
@@ -297,9 +295,8 @@ const jsxDEV = (...args) => {
297
295
  */
298
296
  const jsxs = jsx;
299
297
 
300
- const noop = () => ({});
301
298
  function ref(value) {
302
- return { value: value, update: noop, isRef: true };
299
+ return { value: value, isKT: true };
303
300
  }
304
301
 
305
302
  export { Fragment, h as createElement, h, jsx, jsxDEV, jsxs, ktnull, ref };
@@ -7,13 +7,12 @@ type HTMLTag = keyof HTMLElementTagNameMap & otherstring;
7
7
 
8
8
  interface KTRef<T> {
9
9
  value: T;
10
- update: () => T;
11
- isRef: true;
10
+ isKT: true;
12
11
  }
13
12
  declare function ref<T>(value?: T): KTRef<T>;
14
13
 
15
- type Ctt = KTRef<any> | HTMLElement | string | number | undefined;
16
- type KTRawContent = Ctt[] | Ctt;
14
+ type KTAvailableContent = KTRef<any> | HTMLElement | string | number | undefined;
15
+ type KTRawContent = KTAvailableContent[] | KTAvailableContent;
17
16
  type KTRawAttr = KTAttribute | string;
18
17
 
19
18
  /**
@@ -77,6 +76,10 @@ type KTPrefixedEventHandlers = {
77
76
  type KTAttribute = KTBaseAttribute & KTPrefixedEventHandlers;
78
77
 
79
78
  type HTML<T extends HTMLTag & otherstring> = T extends HTMLTag ? HTMLElementTagNameMap[T] : HTMLElement;
79
+ type H = (<T extends HTMLTag>(tag: T, attr?: KTRawAttr, content?: KTRawContent) => HTML<T>) & {
80
+ kDepth: number;
81
+ kUpdater: (() => void)[];
82
+ };
80
83
  /**
81
84
  * Create an enhanced HTMLElement.
82
85
  * - Only supports HTMLElements, **NOT** SVGElements or other Elements.
@@ -87,14 +90,14 @@ type HTML<T extends HTMLTag & otherstring> = T extends HTMLTag ? HTMLElementTagN
87
90
  * ## About
88
91
  * @package @ktjs/core
89
92
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
90
- * @version 0.8.3 (Last Update: 2025.12.25 11:27:17.924)
93
+ * @version 0.9.0 (Last Update: 2025.12.29 11:09:49.983)
91
94
  * @license MIT
92
95
  * @link https://github.com/baendlorel/kt.js
93
96
  * @link https://baendlorel.github.io/ Welcome to my site!
94
97
  * @description Core functionality for kt.js - DOM manipulation utilities with JSX/TSX support
95
98
  * @copyright Copyright (c) 2025 Kasukabe Tsumugi. All rights reserved.
96
99
  */
97
- declare const h: <T extends HTMLTag>(tag: T, attr?: KTRawAttr, content?: KTRawContent) => HTML<T>;
100
+ declare const h: H;
98
101
 
99
102
  /**
100
103
  * This is a `falsy` value used to indicate "no node" in `h` function.
@@ -103,11 +106,11 @@ declare const h: <T extends HTMLTag>(tag: T, attr?: KTRawAttr, content?: KTRawCo
103
106
  declare const ktnull: any;
104
107
 
105
108
  /**
106
- * @param tag html tag
109
+ * @param tag html tag or function component
107
110
  * @param props properties/attributes
108
111
  * @param _metadata metadata is ignored
109
112
  */
110
- declare function jsx<T extends HTMLTag>(tag: T, props: KTRawAttr, ..._metadata: any[]): HTMLElementTagNameMap[T];
113
+ declare function jsx<T extends HTMLTag>(tag: T | Function, props: KTRawAttr, ..._metadata: any[]): HTMLElementTagNameMap[T] | HTMLElement;
111
114
  /**
112
115
  * Fragment support - returns an array of children
113
116
  * Note: kt.js doesn't have a real Fragment concept,
@@ -126,5 +129,23 @@ declare const jsxDEV: typeof jsx;
126
129
  */
127
130
  declare const jsxs: typeof jsx;
128
131
 
132
+ declare global {
133
+ namespace JSX {
134
+ type Element = HTMLElementTagNameMap[keyof HTMLElementTagNameMap];
135
+
136
+ interface IntrinsicElements {
137
+ [tag: string]: KTAttribute & { children?: KTRawContent };
138
+ }
139
+
140
+ interface IntrinsicAttributes {
141
+ key?: string | number;
142
+ }
143
+
144
+ interface ElementChildrenAttribute {
145
+ children: {};
146
+ }
147
+ }
148
+ }
149
+
129
150
  export { Fragment, h as createElement, jsx, jsxDEV, jsxs, ref };
130
151
  export type { KTRef };
@@ -155,25 +155,22 @@ function applyAttr(element, attr) {
155
155
  }
156
156
  }
157
157
 
158
+ function apd(element, content) {
159
+ if (content && content.isKT) {
160
+ $append.call(element, content.value);
161
+ }
162
+ else {
163
+ $append.call(element, content);
164
+ }
165
+ }
158
166
  function applyContent(element, content) {
159
167
  if ($isArray(content)) {
160
168
  for (let i = 0; i < content.length; i++) {
161
- let c = content[i];
162
- if (c && c.isRef) {
163
- $append.call(element, c.value);
164
- }
165
- else {
166
- $append.call(element, c);
167
- }
169
+ apd(element, content[i]);
168
170
  }
169
171
  }
170
172
  else {
171
- if (content && content.isRef) {
172
- $append.call(element, content.value);
173
- }
174
- else {
175
- $append.call(element, content);
176
- }
173
+ apd(element, content);
177
174
  }
178
175
  }
179
176
 
@@ -187,14 +184,14 @@ function applyContent(element, content) {
187
184
  * ## About
188
185
  * @package @ktjs/core
189
186
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
190
- * @version 0.8.3 (Last Update: 2025.12.25 11:27:17.924)
187
+ * @version 0.9.0 (Last Update: 2025.12.29 11:09:49.983)
191
188
  * @license MIT
192
189
  * @link https://github.com/baendlorel/kt.js
193
190
  * @link https://baendlorel.github.io/ Welcome to my site!
194
191
  * @description Core functionality for kt.js - DOM manipulation utilities with JSX/TSX support
195
192
  * @copyright Copyright (c) 2025 Kasukabe Tsumugi. All rights reserved.
196
193
  */
197
- const h = (tag, attr = '', content = '') => {
194
+ const h = ((tag, attr = '', content = '') => {
198
195
  if (typeof tag !== 'string') {
199
196
  $throw('__func__ tagName must be a string.');
200
197
  }
@@ -204,15 +201,22 @@ const h = (tag, attr = '', content = '') => {
204
201
  applyAttr(element, attr);
205
202
  applyContent(element, content);
206
203
  return element;
207
- };
204
+ });
208
205
  $mark(h, 'h');
209
206
 
210
207
  /**
211
- * @param tag html tag
208
+ * @param tag html tag or function component
212
209
  * @param props properties/attributes
213
210
  * @param _metadata metadata is ignored
214
211
  */
215
212
  function jsx(tag, props, ..._metadata) {
213
+ // Handle function components
214
+ if (typeof tag === 'function') {
215
+ const propObj = typeof props === 'string' ? { class: props } : props || {};
216
+ const children = propObj.children;
217
+ return tag({ ...propObj, children });
218
+ }
219
+ // Handle regular HTML tags
216
220
  const propObj = typeof props === 'string' ? { class: props } : props;
217
221
  if (propObj === undefined || propObj === null) {
218
222
  return h(tag);
@@ -227,12 +231,6 @@ function jsx(tag, props, ..._metadata) {
227
231
  const el = h(tag, propObj, children);
228
232
  if (ref) {
229
233
  ref.value = el;
230
- ref.update = () => {
231
- const old = ref.value;
232
- ref.value = h(tag, propObj, children);
233
- old.replaceWith(ref.value);
234
- return ref.value;
235
- };
236
234
  }
237
235
  return el;
238
236
  }
@@ -280,9 +278,8 @@ const jsxDEV = (...args) => {
280
278
  */
281
279
  const jsxs = jsx;
282
280
 
283
- const noop = () => ({});
284
281
  function ref(value) {
285
- return { value: value, update: noop, isRef: true };
282
+ return { value: value, isKT: true };
286
283
  }
287
284
 
288
285
  export { Fragment, h as createElement, jsx, jsxDEV, jsxs, ref };
@@ -7,12 +7,11 @@ type HTMLTag = keyof HTMLElementTagNameMap & otherstring;
7
7
 
8
8
  interface KTRef<T> {
9
9
  value: T;
10
- update: () => T;
11
- isRef: true;
10
+ isKT: true;
12
11
  }
13
12
 
14
- type Ctt = KTRef<any> | HTMLElement | string | number | undefined;
15
- type KTRawContent = Ctt[] | Ctt;
13
+ type KTAvailableContent = KTRef<any> | HTMLElement | string | number | undefined;
14
+ type KTRawContent = KTAvailableContent[] | KTAvailableContent;
16
15
  type KTRawAttr = KTAttribute | string;
17
16
 
18
17
  /**
@@ -76,6 +75,10 @@ type KTPrefixedEventHandlers = {
76
75
  type KTAttribute = KTBaseAttribute & KTPrefixedEventHandlers;
77
76
 
78
77
  type HTML<T extends HTMLTag & otherstring> = T extends HTMLTag ? HTMLElementTagNameMap[T] : HTMLElement;
78
+ type H = (<T extends HTMLTag>(tag: T, attr?: KTRawAttr, content?: KTRawContent) => HTML<T>) & {
79
+ kDepth: number;
80
+ kUpdater: (() => void)[];
81
+ };
79
82
  /**
80
83
  * Create an enhanced HTMLElement.
81
84
  * - Only supports HTMLElements, **NOT** SVGElements or other Elements.
@@ -86,14 +89,14 @@ type HTML<T extends HTMLTag & otherstring> = T extends HTMLTag ? HTMLElementTagN
86
89
  * ## About
87
90
  * @package @ktjs/core
88
91
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
89
- * @version 0.8.3 (Last Update: 2025.12.25 11:27:17.924)
92
+ * @version 0.9.0 (Last Update: 2025.12.29 11:09:49.983)
90
93
  * @license MIT
91
94
  * @link https://github.com/baendlorel/kt.js
92
95
  * @link https://baendlorel.github.io/ Welcome to my site!
93
96
  * @description Core functionality for kt.js - DOM manipulation utilities with JSX/TSX support
94
97
  * @copyright Copyright (c) 2025 Kasukabe Tsumugi. All rights reserved.
95
98
  */
96
- declare const h: <T extends HTMLTag>(tag: T, attr?: KTRawAttr, content?: KTRawContent) => HTML<T>;
99
+ declare const h: H;
97
100
 
98
101
  /**
99
102
  * This is a `falsy` value used to indicate "no node" in `h` function.
@@ -102,11 +105,11 @@ declare const h: <T extends HTMLTag>(tag: T, attr?: KTRawAttr, content?: KTRawCo
102
105
  declare const ktnull: any;
103
106
 
104
107
  /**
105
- * @param tag html tag
108
+ * @param tag html tag or function component
106
109
  * @param props properties/attributes
107
110
  * @param _metadata metadata is ignored
108
111
  */
109
- declare function jsx<T extends HTMLTag>(tag: T, props: KTRawAttr, ..._metadata: any[]): HTMLElementTagNameMap[T];
112
+ declare function jsx<T extends HTMLTag>(tag: T | Function, props: KTRawAttr, ..._metadata: any[]): HTMLElementTagNameMap[T] | HTMLElement;
110
113
  /**
111
114
  * Fragment support - returns an array of children
112
115
  * Note: kt.js doesn't have a real Fragment concept,
@@ -155,25 +155,22 @@ function applyAttr(element, attr) {
155
155
  }
156
156
  }
157
157
 
158
+ function apd(element, content) {
159
+ if (content && content.isKT) {
160
+ $append.call(element, content.value);
161
+ }
162
+ else {
163
+ $append.call(element, content);
164
+ }
165
+ }
158
166
  function applyContent(element, content) {
159
167
  if ($isArray(content)) {
160
168
  for (let i = 0; i < content.length; i++) {
161
- let c = content[i];
162
- if (c && c.isRef) {
163
- $append.call(element, c.value);
164
- }
165
- else {
166
- $append.call(element, c);
167
- }
169
+ apd(element, content[i]);
168
170
  }
169
171
  }
170
172
  else {
171
- if (content && content.isRef) {
172
- $append.call(element, content.value);
173
- }
174
- else {
175
- $append.call(element, content);
176
- }
173
+ apd(element, content);
177
174
  }
178
175
  }
179
176
 
@@ -187,14 +184,14 @@ function applyContent(element, content) {
187
184
  * ## About
188
185
  * @package @ktjs/core
189
186
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
190
- * @version 0.8.3 (Last Update: 2025.12.25 11:27:17.924)
187
+ * @version 0.9.0 (Last Update: 2025.12.29 11:09:49.983)
191
188
  * @license MIT
192
189
  * @link https://github.com/baendlorel/kt.js
193
190
  * @link https://baendlorel.github.io/ Welcome to my site!
194
191
  * @description Core functionality for kt.js - DOM manipulation utilities with JSX/TSX support
195
192
  * @copyright Copyright (c) 2025 Kasukabe Tsumugi. All rights reserved.
196
193
  */
197
- const h = (tag, attr = '', content = '') => {
194
+ const h = ((tag, attr = '', content = '') => {
198
195
  if (typeof tag !== 'string') {
199
196
  $throw('__func__ tagName must be a string.');
200
197
  }
@@ -204,15 +201,22 @@ const h = (tag, attr = '', content = '') => {
204
201
  applyAttr(element, attr);
205
202
  applyContent(element, content);
206
203
  return element;
207
- };
204
+ });
208
205
  $mark(h, 'h');
209
206
 
210
207
  /**
211
- * @param tag html tag
208
+ * @param tag html tag or function component
212
209
  * @param props properties/attributes
213
210
  * @param _metadata metadata is ignored
214
211
  */
215
212
  function jsx(tag, props, ..._metadata) {
213
+ // Handle function components
214
+ if (typeof tag === 'function') {
215
+ const propObj = typeof props === 'string' ? { class: props } : props || {};
216
+ const children = propObj.children;
217
+ return tag({ ...propObj, children });
218
+ }
219
+ // Handle regular HTML tags
216
220
  const propObj = typeof props === 'string' ? { class: props } : props;
217
221
  if (propObj === undefined || propObj === null) {
218
222
  return h(tag);
@@ -227,12 +231,6 @@ function jsx(tag, props, ..._metadata) {
227
231
  const el = h(tag, propObj, children);
228
232
  if (ref) {
229
233
  ref.value = el;
230
- ref.update = () => {
231
- const old = ref.value;
232
- ref.value = h(tag, propObj, children);
233
- old.replaceWith(ref.value);
234
- return ref.value;
235
- };
236
234
  }
237
235
  return el;
238
236
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ktjs/core",
3
- "version": "0.8.3",
3
+ "version": "0.9.0",
4
4
  "description": "Core functionality for kt.js - DOM manipulation utilities with JSX/TSX support",
5
5
  "type": "module",
6
6
  "module": "./dist/index.mjs",