@ktjs/jsx 0.6.10 → 0.6.13

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.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("@ktjs/core");function t(t,n,...r){const o="string"==typeof n?{class:n}:n;if(null==o)return e.h(t);const s=o.children;delete o.children;const c=e.h(t,o,s);return"ref"in o&&"object"==typeof o.ref&&null!==o.ref&&(o.ref.value=c,delete o.ref),c}const n=t,r=t;Object.defineProperty(exports,"createElement",{enumerable:!0,get:function(){return e.h}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return e.h}}),exports.Fragment=function(e){window.__ktjs__.throws("kt.js doesn't have a Fragment concept")},exports.jsx=t,exports.jsxDEV=n,exports.jsxs=r,exports.ref=function(){return{value:null}};
1
+ "use strict";var e=require("@ktjs/core");function t(t,n,...r){const o="string"==typeof n?{class:n}:n;if(null==o)return e.h(t);const s=o.children;delete o.children;const c="ref"in o&&"object"==typeof o.ref&&null!==o.ref,u=c?o.ref:null;c&&delete o.ref;const l=e.h(t,o,s);return c&&(u.value=l),l}const n=t,r=t;Object.defineProperty(exports,"createElement",{enumerable:!0,get:function(){return e.h}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return e.h}}),exports.Fragment=function(e){window.__ktjs__.throws("kt.js doesn't have a Fragment concept")},exports.jsx=t,exports.jsxDEV=n,exports.jsxs=r,exports.ref=function(){return{value:null}};
package/dist/index.d.ts CHANGED
@@ -68,7 +68,7 @@ declare global {
68
68
  * ## About
69
69
  * @package @ktjs/jsx
70
70
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
71
- * @version 0.6.10 (Last Update: 2025.12.24 17:40:28.127)
71
+ * @version 0.6.13 (Last Update: 2025.12.24 21:38:35.869)
72
72
  * @license MIT
73
73
  * @link https://github.com/baendlorel/kt.js
74
74
  * @link https://baendlorel.github.io/ Welcome to my site!
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{h as t}from"@ktjs/core";export{h as createElement,h}from"@ktjs/core";function e(e,n,...o){const r="string"==typeof n?{class:n}:n;if(null==r)return t(e);const c=r.children;delete r.children;const s=t(e,r,c);return"ref"in r&&"object"==typeof r.ref&&null!==r.ref&&(r.ref.value=s,delete r.ref),s}function n(t){window.__ktjs__.throws("kt.js doesn't have a Fragment concept")}const o=e,r=e;function c(){return{value:null}}export{n as Fragment,e as jsx,o as jsxDEV,r as jsxs,c as ref};
1
+ import{h as t}from"@ktjs/core";export{h as createElement,h}from"@ktjs/core";function e(e,n,...o){const r="string"==typeof n?{class:n}:n;if(null==r)return t(e);const c=r.children;delete r.children;const l="ref"in r&&"object"==typeof r.ref&&null!==r.ref,s=l?r.ref:null;l&&delete r.ref;const u=t(e,r,c);return l&&(s.value=u),u}function n(t){window.__ktjs__.throws("kt.js doesn't have a Fragment concept")}const o=e,r=e;function c(){return{value:null}}export{n as Fragment,e as jsx,o as jsxDEV,r as jsxs,c as ref};
@@ -8,17 +8,23 @@ var core = require('@ktjs/core');
8
8
  * @param _metadata metadata is ignored
9
9
  */
10
10
  function jsx(tag, props, ..._metadata) {
11
+ console.log('JSX runtime called:', tag, props, _metadata);
11
12
  const propObj = typeof props === 'string' ? { class: props } : props;
12
13
  if (propObj === undefined || propObj === null) {
13
14
  return core.h(tag);
14
15
  }
15
16
  const children = propObj.children;
16
17
  delete propObj.children;
17
- const el = core.h(tag, propObj, children);
18
- if ('ref' in propObj && typeof propObj.ref === 'object' && propObj.ref !== null) {
19
- propObj.ref.value = el;
18
+ // deal with ref attribute
19
+ const hasRef = 'ref' in propObj && typeof propObj.ref === 'object' && propObj.ref !== null;
20
+ const ref = hasRef ? propObj.ref : null;
21
+ if (hasRef) {
20
22
  delete propObj.ref;
21
23
  }
24
+ const el = core.h(tag, propObj, children);
25
+ if (hasRef) {
26
+ ref.value = el;
27
+ }
22
28
  return el;
23
29
  }
24
30
  /**
@@ -7,17 +7,23 @@ export { h as createElement, h } from '@ktjs/core';
7
7
  * @param _metadata metadata is ignored
8
8
  */
9
9
  function jsx(tag, props, ..._metadata) {
10
+ console.log('JSX runtime called:', tag, props, _metadata);
10
11
  const propObj = typeof props === 'string' ? { class: props } : props;
11
12
  if (propObj === undefined || propObj === null) {
12
13
  return h(tag);
13
14
  }
14
15
  const children = propObj.children;
15
16
  delete propObj.children;
16
- const el = h(tag, propObj, children);
17
- if ('ref' in propObj && typeof propObj.ref === 'object' && propObj.ref !== null) {
18
- propObj.ref.value = el;
17
+ // deal with ref attribute
18
+ const hasRef = 'ref' in propObj && typeof propObj.ref === 'object' && propObj.ref !== null;
19
+ const ref = hasRef ? propObj.ref : null;
20
+ if (hasRef) {
19
21
  delete propObj.ref;
20
22
  }
23
+ const el = h(tag, propObj, children);
24
+ if (hasRef) {
25
+ ref.value = el;
26
+ }
21
27
  return el;
22
28
  }
23
29
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ktjs/jsx",
3
- "version": "0.6.10",
3
+ "version": "0.6.13",
4
4
  "description": "JSX/TSX support for KT.js - Build UIs with JSX syntax while keeping direct DOM control",
5
5
  "author": {
6
6
  "name": "Kasukabe Tsumugi",
@@ -51,10 +51,10 @@
51
51
  "directory": "packages/jsx"
52
52
  },
53
53
  "peerDependencies": {
54
- "@ktjs/core": "0.6.6"
54
+ "@ktjs/core": "0.6.12"
55
55
  },
56
56
  "devDependencies": {
57
- "@ktjs/core": "0.6.6"
57
+ "@ktjs/core": "0.6.12"
58
58
  },
59
59
  "scripts": {
60
60
  "build": "rollup -c rollup.config.mjs",