@ktjs/core 0.8.3 → 0.8.5

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,8 +24,7 @@ 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
 
@@ -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,14 +113,14 @@ 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.8.5 (Last Update: 2025.12.29 10:16:21.619)
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
126
  * @param tag html tag
@@ -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.8.5 (Last Update: 2025.12.29 10:16:21.619)
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,7 +221,7 @@ 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
  /**
@@ -247,12 +244,6 @@ var __ktjs_core__ = (function (exports) {
247
244
  const el = h(tag, propObj, children);
248
245
  if (ref) {
249
246
  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
247
  }
257
248
  return el;
258
249
  }
@@ -300,9 +291,8 @@ var __ktjs_core__ = (function (exports) {
300
291
  */
301
292
  const jsxs = jsx;
302
293
 
303
- const noop = () => ({});
304
294
  function ref(value) {
305
- return { value: value, update: noop, isRef: true };
295
+ return { value: value, isKT: true };
306
296
  }
307
297
 
308
298
  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.8.5 (Last Update: 2025.12.29 10:16:21.619)
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
  /******************************************************************************
@@ -293,12 +290,6 @@ var __ktjs_core__ = (function (exports) {
293
290
  var el = h(tag, propObj, children);
294
291
  if (ref) {
295
292
  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
293
  }
303
294
  return el;
304
295
  }
@@ -351,9 +342,8 @@ var __ktjs_core__ = (function (exports) {
351
342
  */
352
343
  var jsxs = jsx;
353
344
 
354
- var noop = function () { return ({}); };
355
345
  function ref(value) {
356
- return { value: value, update: noop, isRef: true };
346
+ return { value: value, isKT: true };
357
347
  }
358
348
 
359
349
  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.8.5 (Last Update: 2025.12.29 10:16:21.619)
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,7 +218,7 @@ 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
  /**
@@ -244,12 +241,6 @@ function jsx(tag, props, ..._metadata) {
244
241
  const el = h(tag, propObj, children);
245
242
  if (ref) {
246
243
  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
244
  }
254
245
  return el;
255
246
  }
@@ -297,9 +288,8 @@ const jsxDEV = (...args) => {
297
288
  */
298
289
  const jsxs = jsx;
299
290
 
300
- const noop = () => ({});
301
291
  function ref(value) {
302
- return { value: value, update: noop, isRef: true };
292
+ return { value: value, isKT: true };
303
293
  }
304
294
 
305
295
  export { Fragment, h as createElement, h, jsx, jsxDEV, jsxs, ktnull, ref };
@@ -7,8 +7,7 @@ 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
 
@@ -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.8.5 (Last Update: 2025.12.29 10:16:21.619)
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.
@@ -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.8.5 (Last Update: 2025.12.29 10:16:21.619)
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,7 +201,7 @@ 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
  /**
@@ -227,12 +224,6 @@ function jsx(tag, props, ..._metadata) {
227
224
  const el = h(tag, propObj, children);
228
225
  if (ref) {
229
226
  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
227
  }
237
228
  return el;
238
229
  }
@@ -280,9 +271,8 @@ const jsxDEV = (...args) => {
280
271
  */
281
272
  const jsxs = jsx;
282
273
 
283
- const noop = () => ({});
284
274
  function ref(value) {
285
- return { value: value, update: noop, isRef: true };
275
+ return { value: value, isKT: true };
286
276
  }
287
277
 
288
278
  export { Fragment, h as createElement, jsx, jsxDEV, jsxs, ref };
@@ -7,8 +7,7 @@ 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
13
  type Ctt = KTRef<any> | HTMLElement | string | number | undefined;
@@ -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.8.5 (Last Update: 2025.12.29 10:16:21.619)
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.
@@ -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.8.5 (Last Update: 2025.12.29 10:16:21.619)
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,7 +201,7 @@ 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
  /**
@@ -227,12 +224,6 @@ function jsx(tag, props, ..._metadata) {
227
224
  const el = h(tag, propObj, children);
228
225
  if (ref) {
229
226
  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
227
  }
237
228
  return el;
238
229
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ktjs/core",
3
- "version": "0.8.3",
3
+ "version": "0.8.5",
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",