@ktjs/core 0.15.1 → 0.15.3

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
@@ -3,7 +3,8 @@ type otherstring = string & {};
3
3
  /**
4
4
  * Normal HTML tags like `div`, `span`, `a`, etc.
5
5
  */
6
- type HTMLTag = keyof HTMLElementTagNameMap & otherstring;
6
+ type HTMLTag = keyof HTMLElementTagNameMap;
7
+ type SVGTag = keyof SVGElementTagNameMap;
7
8
 
8
9
  interface KTRef<T> {
9
10
  value: T;
@@ -138,11 +139,7 @@ type KTComponent = (
138
139
  any,
139
140
  ) => KTHTMLElement | Promise<KTHTMLElement> | any;
140
141
 
141
- type HTML<T extends HTMLTag & otherstring> = T extends HTMLTag ? HTMLElementTagNameMap[T] : HTMLElement;
142
- type H = (<T extends HTMLTag>(tag: T, attr?: KTRawAttr, content?: KTRawContent) => HTML<T>) & {
143
- kDepth: number;
144
- kUpdater: (() => void)[];
145
- };
142
+ type HTML<T extends (HTMLTag | SVGTag) & otherstring> = T extends SVGTag ? SVGElementTagNameMap[T] : T extends HTMLTag ? HTMLElementTagNameMap[T] : HTMLElement;
146
143
  /**
147
144
  * Create an enhanced HTMLElement.
148
145
  * - Only supports HTMLElements, **NOT** SVGElements or other Elements.
@@ -153,14 +150,14 @@ type H = (<T extends HTMLTag>(tag: T, attr?: KTRawAttr, content?: KTRawContent)
153
150
  * ## About
154
151
  * @package @ktjs/core
155
152
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
156
- * @version 0.15.1 (Last Update: 2026.01.25 13:09:33.161)
153
+ * @version 0.15.3 (Last Update: 2026.01.25 14:39:33.442)
157
154
  * @license MIT
158
155
  * @link https://github.com/baendlorel/kt.js
159
156
  * @link https://baendlorel.github.io/ Welcome to my site!
160
157
  * @description Core functionality for kt.js - DOM manipulation utilities with JSX/TSX support
161
158
  * @copyright Copyright (c) 2026 Kasukabe Tsumugi. All rights reserved.
162
159
  */
163
- declare const h: H;
160
+ declare const h: <T extends HTMLTag | SVGTag>(tag: T, attr?: KTRawAttr, content?: KTRawContent) => HTML<T>;
164
161
 
165
162
  type JSXTag = HTMLTag | ((props?: any) => HTMLElement) | ((props?: any) => Promise<HTMLElement>) | ((props?: any) => KTHTMLElement) | ((props?: any) => Promise<KTHTMLElement>);
166
163
  /**
@@ -194,6 +194,9 @@ var __ktjs_core__ = (function (exports) {
194
194
  }
195
195
  }
196
196
 
197
+ const defaultCreator = (tag) => document.createElement(tag);
198
+ const svgCreator = (tag) => document.createElementNS('http://www.w3.org/2000/svg', tag);
199
+ let creator = defaultCreator;
197
200
  /**
198
201
  * Create an enhanced HTMLElement.
199
202
  * - Only supports HTMLElements, **NOT** SVGElements or other Elements.
@@ -204,24 +207,29 @@ var __ktjs_core__ = (function (exports) {
204
207
  * ## About
205
208
  * @package @ktjs/core
206
209
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
207
- * @version 0.15.1 (Last Update: 2026.01.25 13:09:33.161)
210
+ * @version 0.15.3 (Last Update: 2026.01.25 14:39:33.442)
208
211
  * @license MIT
209
212
  * @link https://github.com/baendlorel/kt.js
210
213
  * @link https://baendlorel.github.io/ Welcome to my site!
211
214
  * @description Core functionality for kt.js - DOM manipulation utilities with JSX/TSX support
212
215
  * @copyright Copyright (c) 2026 Kasukabe Tsumugi. All rights reserved.
213
216
  */
214
- const h = ((tag, attr = '', content = '') => {
217
+ const h = (tag, attr, content) => {
215
218
  if (typeof tag !== 'string') {
216
219
  $throw('tagName must be a string.');
217
220
  }
221
+ let lastCreator = creator;
222
+ if (tag === 'svg') {
223
+ creator = svgCreator;
224
+ }
218
225
  // * start creating the element
219
- const element = document.createElement(tag);
226
+ const element = creator(tag);
220
227
  // * Handle content
221
228
  applyAttr(element, attr);
222
229
  applyContent(element, content);
230
+ creator = lastCreator; // restore previous creator
223
231
  return element;
224
- });
232
+ };
225
233
 
226
234
  /**
227
235
  * Reference to the created HTML element.
@@ -219,6 +219,9 @@ var __ktjs_core__ = (function (exports) {
219
219
  }
220
220
  }
221
221
 
222
+ var defaultCreator = function (tag) { return document.createElement(tag); };
223
+ var svgCreator = function (tag) { return document.createElementNS('http://www.w3.org/2000/svg', tag); };
224
+ var creator = defaultCreator;
222
225
  /**
223
226
  * Create an enhanced HTMLElement.
224
227
  * - Only supports HTMLElements, **NOT** SVGElements or other Elements.
@@ -229,26 +232,29 @@ var __ktjs_core__ = (function (exports) {
229
232
  * ## About
230
233
  * @package @ktjs/core
231
234
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
232
- * @version 0.15.1 (Last Update: 2026.01.25 13:09:33.161)
235
+ * @version 0.15.3 (Last Update: 2026.01.25 14:39:33.442)
233
236
  * @license MIT
234
237
  * @link https://github.com/baendlorel/kt.js
235
238
  * @link https://baendlorel.github.io/ Welcome to my site!
236
239
  * @description Core functionality for kt.js - DOM manipulation utilities with JSX/TSX support
237
240
  * @copyright Copyright (c) 2026 Kasukabe Tsumugi. All rights reserved.
238
241
  */
239
- var h = (function (tag, attr, content) {
240
- if (attr === void 0) { attr = ''; }
241
- if (content === void 0) { content = ''; }
242
+ var h = function (tag, attr, content) {
242
243
  if (typeof tag !== 'string') {
243
244
  $throw('tagName must be a string.');
244
245
  }
246
+ var lastCreator = creator;
247
+ if (tag === 'svg') {
248
+ creator = svgCreator;
249
+ }
245
250
  // * start creating the element
246
- var element = document.createElement(tag);
251
+ var element = creator(tag);
247
252
  // * Handle content
248
253
  applyAttr(element, attr);
249
254
  applyContent(element, content);
255
+ creator = lastCreator; // restore previous creator
250
256
  return element;
251
- });
257
+ };
252
258
 
253
259
  /******************************************************************************
254
260
  Copyright (c) Microsoft Corporation.
package/dist/index.mjs CHANGED
@@ -191,6 +191,9 @@ function applyContent(element, content) {
191
191
  }
192
192
  }
193
193
 
194
+ const defaultCreator = (tag) => document.createElement(tag);
195
+ const svgCreator = (tag) => document.createElementNS('http://www.w3.org/2000/svg', tag);
196
+ let creator = defaultCreator;
194
197
  /**
195
198
  * Create an enhanced HTMLElement.
196
199
  * - Only supports HTMLElements, **NOT** SVGElements or other Elements.
@@ -201,24 +204,29 @@ function applyContent(element, content) {
201
204
  * ## About
202
205
  * @package @ktjs/core
203
206
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
204
- * @version 0.15.1 (Last Update: 2026.01.25 13:09:33.161)
207
+ * @version 0.15.3 (Last Update: 2026.01.25 14:39:33.442)
205
208
  * @license MIT
206
209
  * @link https://github.com/baendlorel/kt.js
207
210
  * @link https://baendlorel.github.io/ Welcome to my site!
208
211
  * @description Core functionality for kt.js - DOM manipulation utilities with JSX/TSX support
209
212
  * @copyright Copyright (c) 2026 Kasukabe Tsumugi. All rights reserved.
210
213
  */
211
- const h = ((tag, attr = '', content = '') => {
214
+ const h = (tag, attr, content) => {
212
215
  if (typeof tag !== 'string') {
213
216
  $throw('tagName must be a string.');
214
217
  }
218
+ let lastCreator = creator;
219
+ if (tag === 'svg') {
220
+ creator = svgCreator;
221
+ }
215
222
  // * start creating the element
216
- const element = document.createElement(tag);
223
+ const element = creator(tag);
217
224
  // * Handle content
218
225
  applyAttr(element, attr);
219
226
  applyContent(element, content);
227
+ creator = lastCreator; // restore previous creator
220
228
  return element;
221
- });
229
+ };
222
230
 
223
231
  /**
224
232
  * Reference to the created HTML element.
@@ -3,7 +3,8 @@ type otherstring = string & {};
3
3
  /**
4
4
  * Normal HTML tags like `div`, `span`, `a`, etc.
5
5
  */
6
- type HTMLTag = keyof HTMLElementTagNameMap & otherstring;
6
+ type HTMLTag = keyof HTMLElementTagNameMap;
7
+ type SVGTag = keyof SVGElementTagNameMap;
7
8
 
8
9
  interface KTRef<T> {
9
10
  value: T;
@@ -124,11 +125,7 @@ type KTSpecialEventHandlers = {
124
125
 
125
126
  type KTAttribute = KTBaseAttribute & KTPrefixedEventHandlers & KTSpecialEventHandlers;
126
127
 
127
- type HTML<T extends HTMLTag & otherstring> = T extends HTMLTag ? HTMLElementTagNameMap[T] : HTMLElement;
128
- type H = (<T extends HTMLTag>(tag: T, attr?: KTRawAttr, content?: KTRawContent) => HTML<T>) & {
129
- kDepth: number;
130
- kUpdater: (() => void)[];
131
- };
128
+ type HTML<T extends (HTMLTag | SVGTag) & otherstring> = T extends SVGTag ? SVGElementTagNameMap[T] : T extends HTMLTag ? HTMLElementTagNameMap[T] : HTMLElement;
132
129
  /**
133
130
  * Create an enhanced HTMLElement.
134
131
  * - Only supports HTMLElements, **NOT** SVGElements or other Elements.
@@ -139,14 +136,14 @@ type H = (<T extends HTMLTag>(tag: T, attr?: KTRawAttr, content?: KTRawContent)
139
136
  * ## About
140
137
  * @package @ktjs/core
141
138
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
142
- * @version 0.15.1 (Last Update: 2026.01.25 13:09:33.161)
139
+ * @version 0.15.3 (Last Update: 2026.01.25 14:39:33.442)
143
140
  * @license MIT
144
141
  * @link https://github.com/baendlorel/kt.js
145
142
  * @link https://baendlorel.github.io/ Welcome to my site!
146
143
  * @description Core functionality for kt.js - DOM manipulation utilities with JSX/TSX support
147
144
  * @copyright Copyright (c) 2026 Kasukabe Tsumugi. All rights reserved.
148
145
  */
149
- declare const h: H;
146
+ declare const h: <T extends HTMLTag | SVGTag>(tag: T, attr?: KTRawAttr, content?: KTRawContent) => HTML<T>;
150
147
 
151
148
  type JSXTag = HTMLTag | ((props?: any) => HTMLElement) | ((props?: any) => Promise<HTMLElement>) | ((props?: any) => KTHTMLElement) | ((props?: any) => Promise<KTHTMLElement>);
152
149
  /**
@@ -191,6 +191,9 @@ function applyContent(element, content) {
191
191
  }
192
192
  }
193
193
 
194
+ const defaultCreator = (tag) => document.createElement(tag);
195
+ const svgCreator = (tag) => document.createElementNS('http://www.w3.org/2000/svg', tag);
196
+ let creator = defaultCreator;
194
197
  /**
195
198
  * Create an enhanced HTMLElement.
196
199
  * - Only supports HTMLElements, **NOT** SVGElements or other Elements.
@@ -201,24 +204,29 @@ function applyContent(element, content) {
201
204
  * ## About
202
205
  * @package @ktjs/core
203
206
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
204
- * @version 0.15.1 (Last Update: 2026.01.25 13:09:33.161)
207
+ * @version 0.15.3 (Last Update: 2026.01.25 14:39:33.442)
205
208
  * @license MIT
206
209
  * @link https://github.com/baendlorel/kt.js
207
210
  * @link https://baendlorel.github.io/ Welcome to my site!
208
211
  * @description Core functionality for kt.js - DOM manipulation utilities with JSX/TSX support
209
212
  * @copyright Copyright (c) 2026 Kasukabe Tsumugi. All rights reserved.
210
213
  */
211
- const h = ((tag, attr = '', content = '') => {
214
+ const h = (tag, attr, content) => {
212
215
  if (typeof tag !== 'string') {
213
216
  $throw('tagName must be a string.');
214
217
  }
218
+ let lastCreator = creator;
219
+ if (tag === 'svg') {
220
+ creator = svgCreator;
221
+ }
215
222
  // * start creating the element
216
- const element = document.createElement(tag);
223
+ const element = creator(tag);
217
224
  // * Handle content
218
225
  applyAttr(element, attr);
219
226
  applyContent(element, content);
227
+ creator = lastCreator; // restore previous creator
220
228
  return element;
221
- });
229
+ };
222
230
 
223
231
  /**
224
232
  * Reference to the created HTML element.
@@ -3,7 +3,8 @@ type otherstring = string & {};
3
3
  /**
4
4
  * Normal HTML tags like `div`, `span`, `a`, etc.
5
5
  */
6
- type HTMLTag = keyof HTMLElementTagNameMap & otherstring;
6
+ type HTMLTag = keyof HTMLElementTagNameMap;
7
+ type SVGTag = keyof SVGElementTagNameMap;
7
8
 
8
9
  interface KTRef<T> {
9
10
  value: T;
@@ -118,11 +119,7 @@ type KTSpecialEventHandlers = {
118
119
 
119
120
  type KTAttribute = KTBaseAttribute & KTPrefixedEventHandlers & KTSpecialEventHandlers;
120
121
 
121
- type HTML<T extends HTMLTag & otherstring> = T extends HTMLTag ? HTMLElementTagNameMap[T] : HTMLElement;
122
- type H = (<T extends HTMLTag>(tag: T, attr?: KTRawAttr, content?: KTRawContent) => HTML<T>) & {
123
- kDepth: number;
124
- kUpdater: (() => void)[];
125
- };
122
+ type HTML<T extends (HTMLTag | SVGTag) & otherstring> = T extends SVGTag ? SVGElementTagNameMap[T] : T extends HTMLTag ? HTMLElementTagNameMap[T] : HTMLElement;
126
123
  /**
127
124
  * Create an enhanced HTMLElement.
128
125
  * - Only supports HTMLElements, **NOT** SVGElements or other Elements.
@@ -133,14 +130,14 @@ type H = (<T extends HTMLTag>(tag: T, attr?: KTRawAttr, content?: KTRawContent)
133
130
  * ## About
134
131
  * @package @ktjs/core
135
132
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
136
- * @version 0.15.1 (Last Update: 2026.01.25 13:09:33.161)
133
+ * @version 0.15.3 (Last Update: 2026.01.25 14:39:33.442)
137
134
  * @license MIT
138
135
  * @link https://github.com/baendlorel/kt.js
139
136
  * @link https://baendlorel.github.io/ Welcome to my site!
140
137
  * @description Core functionality for kt.js - DOM manipulation utilities with JSX/TSX support
141
138
  * @copyright Copyright (c) 2026 Kasukabe Tsumugi. All rights reserved.
142
139
  */
143
- declare const h: H;
140
+ declare const h: <T extends HTMLTag | SVGTag>(tag: T, attr?: KTRawAttr, content?: KTRawContent) => HTML<T>;
144
141
 
145
142
  type JSXTag = HTMLTag | ((props?: any) => HTMLElement) | ((props?: any) => Promise<HTMLElement>) | ((props?: any) => KTHTMLElement) | ((props?: any) => Promise<KTHTMLElement>);
146
143
  /**
@@ -191,6 +191,9 @@ function applyContent(element, content) {
191
191
  }
192
192
  }
193
193
 
194
+ const defaultCreator = (tag) => document.createElement(tag);
195
+ const svgCreator = (tag) => document.createElementNS('http://www.w3.org/2000/svg', tag);
196
+ let creator = defaultCreator;
194
197
  /**
195
198
  * Create an enhanced HTMLElement.
196
199
  * - Only supports HTMLElements, **NOT** SVGElements or other Elements.
@@ -201,24 +204,29 @@ function applyContent(element, content) {
201
204
  * ## About
202
205
  * @package @ktjs/core
203
206
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
204
- * @version 0.15.1 (Last Update: 2026.01.25 13:09:33.161)
207
+ * @version 0.15.3 (Last Update: 2026.01.25 14:39:33.442)
205
208
  * @license MIT
206
209
  * @link https://github.com/baendlorel/kt.js
207
210
  * @link https://baendlorel.github.io/ Welcome to my site!
208
211
  * @description Core functionality for kt.js - DOM manipulation utilities with JSX/TSX support
209
212
  * @copyright Copyright (c) 2026 Kasukabe Tsumugi. All rights reserved.
210
213
  */
211
- const h = ((tag, attr = '', content = '') => {
214
+ const h = (tag, attr, content) => {
212
215
  if (typeof tag !== 'string') {
213
216
  $throw('tagName must be a string.');
214
217
  }
218
+ let lastCreator = creator;
219
+ if (tag === 'svg') {
220
+ creator = svgCreator;
221
+ }
215
222
  // * start creating the element
216
- const element = document.createElement(tag);
223
+ const element = creator(tag);
217
224
  // * Handle content
218
225
  applyAttr(element, attr);
219
226
  applyContent(element, content);
227
+ creator = lastCreator; // restore previous creator
220
228
  return element;
221
- });
229
+ };
222
230
 
223
231
  /**
224
232
  * Reference to the created HTML element.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ktjs/core",
3
- "version": "0.15.1",
3
+ "version": "0.15.3",
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",