kt.js 0.12.0 → 0.13.1
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/README.md +5 -3
- package/dist/jsx-runtime.mjs +55 -35
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/kt.js) [](https://github.com/baendlorel/kt.js/blob/main/LICENSE)
|
|
6
6
|
|
|
7
|
-
[CHANGLOG✨](CHANGELOG.md)
|
|
7
|
+
[CHANGLOG✨](../../CHANGELOG.md)
|
|
8
|
+
|
|
9
|
+
**Current Version:** 0.13.x
|
|
8
10
|
|
|
9
11
|
> Note: This framework is still under development. APIs, type declarations, and other parts **may change frequently**. If you use it, please watch for updates in the near future. Feel free to mail me if you have any questions!
|
|
10
12
|
|
|
@@ -50,8 +52,8 @@ KT.js follows one rule: **full control of DOM and avoid unnecessary repainting**
|
|
|
50
52
|
- **JSX/TSX Support**: Full JSX syntax support with TypeScript integration
|
|
51
53
|
- Zero virtual DOM - JSX compiles directly to `h()` function calls
|
|
52
54
|
- Full HTML element type inference (`<button>` returns `HTMLButtonElement`)
|
|
53
|
-
- Support for
|
|
54
|
-
-
|
|
55
|
+
- Support for `on:click` event handler syntax
|
|
56
|
+
- **NEW**: `redraw()` method for controlled component updates
|
|
55
57
|
- **Async Components**: Built-in support for Promise-based components
|
|
56
58
|
- `KTAsync` component for handling async operations
|
|
57
59
|
- Automatic placeholder management during loading
|
package/dist/jsx-runtime.mjs
CHANGED
|
@@ -2,16 +2,6 @@ const $throw = (message) => {
|
|
|
2
2
|
throw new Error('kt.js: ' + message);
|
|
3
3
|
};
|
|
4
4
|
|
|
5
|
-
const $isArray = Array.isArray;
|
|
6
|
-
const $keys = Object.keys;
|
|
7
|
-
const $defines = Object.defineProperties;
|
|
8
|
-
const $mark = (func, tag) => $defines(func, { __ktjs_h__: { value: tag, configurable: true } });
|
|
9
|
-
const emptyPromiseHandler = () => ({});
|
|
10
|
-
if (typeof Promise === 'undefined') {
|
|
11
|
-
window.Promise = { resolve: emptyPromiseHandler, reject: emptyPromiseHandler };
|
|
12
|
-
}
|
|
13
|
-
const $isThenable = (o) => typeof o === 'object' && o !== null && 'then' in o && typeof o.then === 'function';
|
|
14
|
-
|
|
15
5
|
/**
|
|
16
6
|
* & Remove `bind` because it is shockingly slower than wrapper
|
|
17
7
|
* & `window.document` is safe because it is not configurable and its setter is undefined
|
|
@@ -50,6 +40,14 @@ const $append = // for ie 9/10/11
|
|
|
50
40
|
}
|
|
51
41
|
};
|
|
52
42
|
|
|
43
|
+
const $isArray = Array.isArray;
|
|
44
|
+
const $keys = Object.keys;
|
|
45
|
+
const emptyPromiseHandler = () => ({});
|
|
46
|
+
if (typeof Promise === 'undefined') {
|
|
47
|
+
window.Promise = { resolve: emptyPromiseHandler, reject: emptyPromiseHandler };
|
|
48
|
+
}
|
|
49
|
+
const $isThenable = (o) => typeof o === 'object' && o !== null && typeof o.then === 'function';
|
|
50
|
+
|
|
53
51
|
function booleanHandler(element, key, value) {
|
|
54
52
|
if (key in element) {
|
|
55
53
|
element[key] = !!value;
|
|
@@ -205,7 +203,7 @@ function applyContent(element, content) {
|
|
|
205
203
|
* ## About
|
|
206
204
|
* @package @ktjs/core
|
|
207
205
|
* @author Kasukabe Tsumugi <futami16237@gmail.com>
|
|
208
|
-
* @version 0.
|
|
206
|
+
* @version 0.13.0 (Last Update: 2026.01.15 16:05:51.084)
|
|
209
207
|
* @license MIT
|
|
210
208
|
* @link https://github.com/baendlorel/kt.js
|
|
211
209
|
* @link https://baendlorel.github.io/ Welcome to my site!
|
|
@@ -223,45 +221,67 @@ const h = ((tag, attr = '', content = '') => {
|
|
|
223
221
|
applyContent(element, content);
|
|
224
222
|
return element;
|
|
225
223
|
});
|
|
226
|
-
$mark(h, 'h');
|
|
227
224
|
|
|
228
225
|
/**
|
|
229
226
|
* @param tag html tag or function component
|
|
230
227
|
* @param props properties/attributes
|
|
231
|
-
* @param _metadata metadata is ignored
|
|
232
228
|
*/
|
|
233
|
-
function jsx(tag, props
|
|
229
|
+
function jsx(tag, props = {}) {
|
|
230
|
+
const ref = props.ref?.isKT ? props.ref : null;
|
|
231
|
+
if (ref) {
|
|
232
|
+
delete props.ref;
|
|
233
|
+
}
|
|
234
234
|
// Handle function components
|
|
235
235
|
if (typeof tag === 'function') {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
236
|
+
let el = tag(props);
|
|
237
|
+
if (!el.redraw) {
|
|
238
|
+
el.redraw = (newProps) => {
|
|
239
|
+
props = newProps ? { ...props, ...newProps } : props;
|
|
240
|
+
// $ same as below
|
|
241
|
+
const old = el;
|
|
242
|
+
el = tag(props);
|
|
243
|
+
el.redraw = old.redraw; // inherit redraw
|
|
244
|
+
if (ref) {
|
|
245
|
+
ref.value = el;
|
|
246
|
+
}
|
|
247
|
+
old.replaceWith(el);
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
if (ref) {
|
|
251
|
+
ref.value = el;
|
|
252
|
+
}
|
|
253
|
+
return el;
|
|
251
254
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
+
else {
|
|
256
|
+
// & deal children here
|
|
257
|
+
let children = props.children;
|
|
258
|
+
delete props.children;
|
|
259
|
+
let el = h(tag, props, children);
|
|
260
|
+
if (ref) {
|
|
261
|
+
ref.value = el;
|
|
262
|
+
}
|
|
263
|
+
el.redraw = (newProps, newChildren) => {
|
|
264
|
+
props = newProps ? { ...props, ...newProps } : props;
|
|
265
|
+
children = (newChildren ?? children);
|
|
266
|
+
// $ same as above
|
|
267
|
+
const old = el;
|
|
268
|
+
el = h(tag, props, children);
|
|
269
|
+
el.redraw = old.redraw; // inherit redraw
|
|
270
|
+
if (ref) {
|
|
271
|
+
ref.value = el;
|
|
272
|
+
}
|
|
273
|
+
old.replaceWith(el);
|
|
274
|
+
};
|
|
275
|
+
return el;
|
|
255
276
|
}
|
|
256
|
-
return el;
|
|
257
277
|
}
|
|
258
278
|
/**
|
|
259
279
|
* Fragment support - returns an array of children
|
|
260
280
|
* Note: kt.js doesn't have a real Fragment concept,
|
|
261
281
|
*/
|
|
262
282
|
function Fragment(props) {
|
|
263
|
-
|
|
264
|
-
// const { children } = props
|
|
283
|
+
throw new Error("kt.js doesn't have a Fragment concept");
|
|
284
|
+
// const { children } = props ?? {};
|
|
265
285
|
// if (!children) {
|
|
266
286
|
// return ;
|
|
267
287
|
// }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kt.js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.1",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Kasukabe Tsumugi",
|
|
6
6
|
"email": "futami16237@gmail.com"
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
],
|
|
42
42
|
"license": "MIT",
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@ktjs/core": "0.
|
|
44
|
+
"@ktjs/core": "0.13.0",
|
|
45
45
|
"@ktjs/shortcuts": "0.7.3"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|