@ktjs/core 0.24.1 → 0.24.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
@@ -38,9 +38,10 @@ declare class KTComputed<T> {
38
38
  * @param computeFn
39
39
  * @param reactives refs and computeds that this computed depends on
40
40
  */
41
- declare function computed<T = JSX.Element>(computeFn: () => T, reactives: Array<KTReactive<unknown>>): KTComputed<T>;
41
+ declare function computed<T = JSX.Element>(computeFn: () => T, reactives: Array<KTReactive<any>>): KTComputed<T>;
42
42
 
43
43
  type KTReactive<T> = KTRef<T> | KTComputed<T>;
44
+ declare const toReactive: <T>(value: T | KTReactive<T>, onChange?: ReactiveChangeHandler<T>) => KTReactive<T>;
44
45
 
45
46
  declare const enum KTReactiveType {
46
47
  REF = 1,
@@ -227,7 +228,7 @@ type KTComponent = (
227
228
  * ## About
228
229
  * @package @ktjs/core
229
230
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
230
- * @version 0.24.1 (Last Update: 2026.02.05 12:51:38.436)
231
+ * @version 0.24.3 (Last Update: 2026.02.05 13:45:10.968)
231
232
  * @license MIT
232
233
  * @link https://github.com/baendlorel/kt.js
233
234
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -1406,5 +1407,5 @@ interface KTForProps<T> {
1406
1407
  */
1407
1408
  declare function KTFor<T>(props: KTForProps<T>): KTForElement;
1408
1409
 
1409
- export { $modelOrRef, Fragment, KTAsync, KTComputed, KTFor, KTReactiveType, KTRef, computed, h as createElement, createRedrawable, deref, h, isComputed, isKT, isRef, jsx, jsxDEV, jsxs, ref, surfaceRef, toRef };
1410
+ export { $modelOrRef, Fragment, KTAsync, KTComputed, KTFor, KTReactiveType, KTRef, computed, h as createElement, createRedrawable, deref, h, isComputed, isKT, isRef, jsx, jsxDEV, jsxs, ref, surfaceRef, toReactive, toRef };
1410
1411
  export type { EventHandler, HTMLTag, InputElementTag, KTAttribute, KTForElement, KTForProps, KTPrefixedEventAttribute, KTRawAttr, KTRawContent, KTRawContents, KTReactive, KTSurfaceRef, MathMLTag, ReactiveChangeHandler, SVGTag };
@@ -470,6 +470,18 @@ var __ktjs_core__ = (function (exports) {
470
470
  return new KTComputed(computeFn, reactives);
471
471
  }
472
472
 
473
+ const toReactive = (value, onChange) => {
474
+ if (isKT(value)) {
475
+ if (onChange) {
476
+ value.addOnChange(onChange);
477
+ }
478
+ return value;
479
+ }
480
+ else {
481
+ return ref(value, onChange);
482
+ }
483
+ };
484
+
473
485
  function applyKModel(element, valueRef) {
474
486
  if (!isKT(valueRef)) {
475
487
  console.warn('[kt.js warn] k-model value must be a KTRef.');
@@ -508,7 +520,7 @@ var __ktjs_core__ = (function (exports) {
508
520
  * ## About
509
521
  * @package @ktjs/core
510
522
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
511
- * @version 0.24.1 (Last Update: 2026.02.05 12:51:38.436)
523
+ * @version 0.24.3 (Last Update: 2026.02.05 13:45:10.968)
512
524
  * @license MIT
513
525
  * @link https://github.com/baendlorel/kt.js
514
526
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -898,6 +910,7 @@ var __ktjs_core__ = (function (exports) {
898
910
  exports.jsxs = jsxs;
899
911
  exports.ref = ref;
900
912
  exports.surfaceRef = surfaceRef;
913
+ exports.toReactive = toReactive;
901
914
  exports.toRef = toRef;
902
915
 
903
916
  return exports;
@@ -470,6 +470,18 @@ var __ktjs_core__ = (function (exports) {
470
470
  return new KTComputed(computeFn, reactives);
471
471
  }
472
472
 
473
+ var toReactive = function (value, onChange) {
474
+ if (isKT(value)) {
475
+ if (onChange) {
476
+ value.addOnChange(onChange);
477
+ }
478
+ return value;
479
+ }
480
+ else {
481
+ return ref(value, onChange);
482
+ }
483
+ };
484
+
473
485
  function applyKModel(element, valueRef) {
474
486
  if (!isKT(valueRef)) {
475
487
  console.warn('[kt.js warn] k-model value must be a KTRef.');
@@ -508,7 +520,7 @@ var __ktjs_core__ = (function (exports) {
508
520
  * ## About
509
521
  * @package @ktjs/core
510
522
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
511
- * @version 0.24.1 (Last Update: 2026.02.05 12:51:38.436)
523
+ * @version 0.24.3 (Last Update: 2026.02.05 13:45:10.968)
512
524
  * @license MIT
513
525
  * @link https://github.com/baendlorel/kt.js
514
526
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -905,6 +917,7 @@ var __ktjs_core__ = (function (exports) {
905
917
  exports.jsxs = jsxs;
906
918
  exports.ref = ref;
907
919
  exports.surfaceRef = surfaceRef;
920
+ exports.toReactive = toReactive;
908
921
  exports.toRef = toRef;
909
922
 
910
923
  return exports;
package/dist/index.mjs CHANGED
@@ -467,6 +467,18 @@ function computed(computeFn, reactives) {
467
467
  return new KTComputed(computeFn, reactives);
468
468
  }
469
469
 
470
+ const toReactive = (value, onChange) => {
471
+ if (isKT(value)) {
472
+ if (onChange) {
473
+ value.addOnChange(onChange);
474
+ }
475
+ return value;
476
+ }
477
+ else {
478
+ return ref(value, onChange);
479
+ }
480
+ };
481
+
470
482
  function applyKModel(element, valueRef) {
471
483
  if (!isKT(valueRef)) {
472
484
  console.warn('[kt.js warn] k-model value must be a KTRef.');
@@ -505,7 +517,7 @@ let creator = htmlCreator;
505
517
  * ## About
506
518
  * @package @ktjs/core
507
519
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
508
- * @version 0.24.1 (Last Update: 2026.02.05 12:51:38.436)
520
+ * @version 0.24.3 (Last Update: 2026.02.05 13:45:10.968)
509
521
  * @license MIT
510
522
  * @link https://github.com/baendlorel/kt.js
511
523
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -876,4 +888,4 @@ function getSequence(arr) {
876
888
  return result;
877
889
  }
878
890
 
879
- export { $modelOrRef, Fragment, KTAsync, KTComputed, KTFor, KTRef, computed, h as createElement, createRedrawable, deref, h, isComputed, isKT, isRef, jsx, jsxDEV, jsxs, ref, surfaceRef, toRef };
891
+ export { $modelOrRef, Fragment, KTAsync, KTComputed, KTFor, KTRef, computed, h as createElement, createRedrawable, deref, h, isComputed, isKT, isRef, jsx, jsxDEV, jsxs, ref, surfaceRef, toReactive, toRef };
@@ -141,7 +141,7 @@ type KTAttribute = KTBaseAttribute & KTPrefixedEventAttribute;
141
141
  * ## About
142
142
  * @package @ktjs/core
143
143
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
144
- * @version 0.24.1 (Last Update: 2026.02.05 12:51:38.436)
144
+ * @version 0.24.3 (Last Update: 2026.02.05 13:45:10.968)
145
145
  * @license MIT
146
146
  * @link https://github.com/baendlorel/kt.js
147
147
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -360,7 +360,7 @@ let creator = htmlCreator;
360
360
  * ## About
361
361
  * @package @ktjs/core
362
362
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
363
- * @version 0.24.1 (Last Update: 2026.02.05 12:51:38.436)
363
+ * @version 0.24.3 (Last Update: 2026.02.05 13:45:10.968)
364
364
  * @license MIT
365
365
  * @link https://github.com/baendlorel/kt.js
366
366
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -141,7 +141,7 @@ type KTAttribute = KTBaseAttribute & KTPrefixedEventAttribute;
141
141
  * ## About
142
142
  * @package @ktjs/core
143
143
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
144
- * @version 0.24.1 (Last Update: 2026.02.05 12:51:38.436)
144
+ * @version 0.24.3 (Last Update: 2026.02.05 13:45:10.968)
145
145
  * @license MIT
146
146
  * @link https://github.com/baendlorel/kt.js
147
147
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -360,7 +360,7 @@ let creator = htmlCreator;
360
360
  * ## About
361
361
  * @package @ktjs/core
362
362
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
363
- * @version 0.24.1 (Last Update: 2026.02.05 12:51:38.436)
363
+ * @version 0.24.3 (Last Update: 2026.02.05 13:45:10.968)
364
364
  * @license MIT
365
365
  * @link https://github.com/baendlorel/kt.js
366
366
  * @link https://baendlorel.github.io/ Welcome to my site!
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ktjs/core",
3
- "version": "0.24.1",
3
+ "version": "0.24.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",