@ktjs/core 0.8.1 → 0.8.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
@@ -22,14 +22,14 @@ type otherstring = string & {};
22
22
  */
23
23
  type HTMLTag = keyof HTMLElementTagNameMap & otherstring;
24
24
 
25
- declare class Ref<T> {
25
+ interface KTRef<T> {
26
26
  value: T;
27
27
  update: () => T;
28
- constructor(value: T);
28
+ isRef: true;
29
29
  }
30
- declare function ref<T>(value: T): Ref<T>;
30
+ declare function ref<T>(value?: T): KTRef<T>;
31
31
 
32
- type Ctt = Ref<any> | HTMLElement | string | number | undefined;
32
+ type Ctt = KTRef<any> | HTMLElement | string | number | undefined;
33
33
  type KTRawContent = Ctt[] | Ctt;
34
34
  type KTRawAttr = KTAttribute | string;
35
35
  type KTRawContents = (HTMLElement | string | undefined)[];
@@ -110,7 +110,7 @@ type HTML<T extends HTMLTag & otherstring> = T extends HTMLTag ? HTMLElementTagN
110
110
  * ## About
111
111
  * @package @ktjs/core
112
112
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
113
- * @version 0.8.1 (Last Update: 2025.12.25 11:07:30.486)
113
+ * @version 0.8.3 (Last Update: 2025.12.25 11:27:17.924)
114
114
  * @license MIT
115
115
  * @link https://github.com/baendlorel/kt.js
116
116
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -161,5 +161,5 @@ declare global {
161
161
  }
162
162
  }
163
163
 
164
- export { Fragment, Ref, h as createElement, h, jsx, jsxDEV, jsxs, ktnull, ref };
165
- export type { EventHandler, HTMLTag, KTAttribute, KTRawAttr, KTRawContent, KTRawContents, KTRuntime };
164
+ export { Fragment, h as createElement, h, jsx, jsxDEV, jsxs, ktnull, ref };
165
+ export type { EventHandler, HTMLTag, KTAttribute, KTRawAttr, KTRawContent, KTRawContents, KTRef, KTRuntime };
@@ -175,24 +175,11 @@ var __ktjs_core__ = (function (exports) {
175
175
  }
176
176
  }
177
177
 
178
- const noop = () => ({});
179
- class Ref {
180
- value;
181
- update;
182
- constructor(value) {
183
- this.value = value;
184
- this.update = noop;
185
- }
186
- }
187
- function ref(value) {
188
- return new Ref(value);
189
- }
190
-
191
178
  function applyContent(element, content) {
192
179
  if ($isArray(content)) {
193
180
  for (let i = 0; i < content.length; i++) {
194
181
  let c = content[i];
195
- if (c instanceof Ref) {
182
+ if (c && c.isRef) {
196
183
  $append.call(element, c.value);
197
184
  }
198
185
  else {
@@ -201,7 +188,7 @@ var __ktjs_core__ = (function (exports) {
201
188
  }
202
189
  }
203
190
  else {
204
- if (content instanceof Ref) {
191
+ if (content && content.isRef) {
205
192
  $append.call(element, content.value);
206
193
  }
207
194
  else {
@@ -220,7 +207,7 @@ var __ktjs_core__ = (function (exports) {
220
207
  * ## About
221
208
  * @package @ktjs/core
222
209
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
223
- * @version 0.8.1 (Last Update: 2025.12.25 11:07:30.486)
210
+ * @version 0.8.3 (Last Update: 2025.12.25 11:27:17.924)
224
211
  * @license MIT
225
212
  * @link https://github.com/baendlorel/kt.js
226
213
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -253,7 +240,7 @@ var __ktjs_core__ = (function (exports) {
253
240
  const children = propObj.children;
254
241
  delete propObj.children;
255
242
  // deal with ref attribute
256
- const ref = 'ref' in propObj && propObj.ref instanceof Ref ? propObj.ref : null;
243
+ const ref = propObj.ref?.isRef ? propObj.ref : null;
257
244
  if (ref) {
258
245
  delete propObj.ref;
259
246
  }
@@ -313,8 +300,12 @@ var __ktjs_core__ = (function (exports) {
313
300
  */
314
301
  const jsxs = jsx;
315
302
 
303
+ const noop = () => ({});
304
+ function ref(value) {
305
+ return { value: value, update: noop, isRef: true };
306
+ }
307
+
316
308
  exports.Fragment = Fragment;
317
- exports.Ref = Ref;
318
309
  exports.createElement = h;
319
310
  exports.h = h;
320
311
  exports.jsx = jsx;
@@ -186,23 +186,11 @@ var __ktjs_core__ = (function (exports) {
186
186
  }
187
187
  }
188
188
 
189
- var noop = function () { return ({}); };
190
- var Ref = /** @class */ (function () {
191
- function Ref(value) {
192
- this.value = value;
193
- this.update = noop;
194
- }
195
- return Ref;
196
- }());
197
- function ref(value) {
198
- return new Ref(value);
199
- }
200
-
201
189
  function applyContent(element, content) {
202
190
  if ($isArray(content)) {
203
191
  for (var i = 0; i < content.length; i++) {
204
192
  var c = content[i];
205
- if (c instanceof Ref) {
193
+ if (c && c.isRef) {
206
194
  $append.call(element, c.value);
207
195
  }
208
196
  else {
@@ -211,7 +199,7 @@ var __ktjs_core__ = (function (exports) {
211
199
  }
212
200
  }
213
201
  else {
214
- if (content instanceof Ref) {
202
+ if (content && content.isRef) {
215
203
  $append.call(element, content.value);
216
204
  }
217
205
  else {
@@ -230,7 +218,7 @@ var __ktjs_core__ = (function (exports) {
230
218
  * ## About
231
219
  * @package @ktjs/core
232
220
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
233
- * @version 0.8.1 (Last Update: 2025.12.25 11:07:30.486)
221
+ * @version 0.8.3 (Last Update: 2025.12.25 11:27:17.924)
234
222
  * @license MIT
235
223
  * @link https://github.com/baendlorel/kt.js
236
224
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -290,6 +278,7 @@ var __ktjs_core__ = (function (exports) {
290
278
  * @param _metadata metadata is ignored
291
279
  */
292
280
  function jsx(tag, props) {
281
+ var _a;
293
282
  var propObj = typeof props === 'string' ? { class: props } : props;
294
283
  if (propObj === undefined || propObj === null) {
295
284
  return h(tag);
@@ -297,7 +286,7 @@ var __ktjs_core__ = (function (exports) {
297
286
  var children = propObj.children;
298
287
  delete propObj.children;
299
288
  // deal with ref attribute
300
- var ref = 'ref' in propObj && propObj.ref instanceof Ref ? propObj.ref : null;
289
+ var ref = ((_a = propObj.ref) === null || _a === void 0 ? void 0 : _a.isRef) ? propObj.ref : null;
301
290
  if (ref) {
302
291
  delete propObj.ref;
303
292
  }
@@ -362,8 +351,12 @@ var __ktjs_core__ = (function (exports) {
362
351
  */
363
352
  var jsxs = jsx;
364
353
 
354
+ var noop = function () { return ({}); };
355
+ function ref(value) {
356
+ return { value: value, update: noop, isRef: true };
357
+ }
358
+
365
359
  exports.Fragment = Fragment;
366
- exports.Ref = Ref;
367
360
  exports.createElement = h;
368
361
  exports.h = h;
369
362
  exports.jsx = jsx;
package/dist/index.mjs CHANGED
@@ -172,24 +172,11 @@ function applyAttr(element, attr) {
172
172
  }
173
173
  }
174
174
 
175
- const noop = () => ({});
176
- class Ref {
177
- value;
178
- update;
179
- constructor(value) {
180
- this.value = value;
181
- this.update = noop;
182
- }
183
- }
184
- function ref(value) {
185
- return new Ref(value);
186
- }
187
-
188
175
  function applyContent(element, content) {
189
176
  if ($isArray(content)) {
190
177
  for (let i = 0; i < content.length; i++) {
191
178
  let c = content[i];
192
- if (c instanceof Ref) {
179
+ if (c && c.isRef) {
193
180
  $append.call(element, c.value);
194
181
  }
195
182
  else {
@@ -198,7 +185,7 @@ function applyContent(element, content) {
198
185
  }
199
186
  }
200
187
  else {
201
- if (content instanceof Ref) {
188
+ if (content && content.isRef) {
202
189
  $append.call(element, content.value);
203
190
  }
204
191
  else {
@@ -217,7 +204,7 @@ function applyContent(element, content) {
217
204
  * ## About
218
205
  * @package @ktjs/core
219
206
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
220
- * @version 0.8.1 (Last Update: 2025.12.25 11:07:30.486)
207
+ * @version 0.8.3 (Last Update: 2025.12.25 11:27:17.924)
221
208
  * @license MIT
222
209
  * @link https://github.com/baendlorel/kt.js
223
210
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -250,7 +237,7 @@ function jsx(tag, props, ..._metadata) {
250
237
  const children = propObj.children;
251
238
  delete propObj.children;
252
239
  // deal with ref attribute
253
- const ref = 'ref' in propObj && propObj.ref instanceof Ref ? propObj.ref : null;
240
+ const ref = propObj.ref?.isRef ? propObj.ref : null;
254
241
  if (ref) {
255
242
  delete propObj.ref;
256
243
  }
@@ -310,4 +297,9 @@ const jsxDEV = (...args) => {
310
297
  */
311
298
  const jsxs = jsx;
312
299
 
313
- export { Fragment, Ref, h as createElement, h, jsx, jsxDEV, jsxs, ktnull, ref };
300
+ const noop = () => ({});
301
+ function ref(value) {
302
+ return { value: value, update: noop, isRef: true };
303
+ }
304
+
305
+ export { Fragment, h as createElement, h, jsx, jsxDEV, jsxs, ktnull, ref };
@@ -5,14 +5,14 @@ type otherstring = string & {};
5
5
  */
6
6
  type HTMLTag = keyof HTMLElementTagNameMap & otherstring;
7
7
 
8
- declare class Ref<T> {
8
+ interface KTRef<T> {
9
9
  value: T;
10
10
  update: () => T;
11
- constructor(value: T);
11
+ isRef: true;
12
12
  }
13
- declare function ref<T>(value: T): Ref<T>;
13
+ declare function ref<T>(value?: T): KTRef<T>;
14
14
 
15
- type Ctt = Ref<any> | HTMLElement | string | number | undefined;
15
+ type Ctt = KTRef<any> | HTMLElement | string | number | undefined;
16
16
  type KTRawContent = Ctt[] | Ctt;
17
17
  type KTRawAttr = KTAttribute | string;
18
18
 
@@ -87,7 +87,7 @@ type HTML<T extends HTMLTag & otherstring> = T extends HTMLTag ? HTMLElementTagN
87
87
  * ## About
88
88
  * @package @ktjs/core
89
89
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
90
- * @version 0.8.1 (Last Update: 2025.12.25 11:07:30.486)
90
+ * @version 0.8.3 (Last Update: 2025.12.25 11:27:17.924)
91
91
  * @license MIT
92
92
  * @link https://github.com/baendlorel/kt.js
93
93
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -126,4 +126,5 @@ declare const jsxDEV: typeof jsx;
126
126
  */
127
127
  declare const jsxs: typeof jsx;
128
128
 
129
- export { Fragment, Ref, h as createElement, jsx, jsxDEV, jsxs, ref };
129
+ export { Fragment, h as createElement, jsx, jsxDEV, jsxs, ref };
130
+ export type { KTRef };
@@ -155,24 +155,11 @@ function applyAttr(element, attr) {
155
155
  }
156
156
  }
157
157
 
158
- const noop = () => ({});
159
- class Ref {
160
- value;
161
- update;
162
- constructor(value) {
163
- this.value = value;
164
- this.update = noop;
165
- }
166
- }
167
- function ref(value) {
168
- return new Ref(value);
169
- }
170
-
171
158
  function applyContent(element, content) {
172
159
  if ($isArray(content)) {
173
160
  for (let i = 0; i < content.length; i++) {
174
161
  let c = content[i];
175
- if (c instanceof Ref) {
162
+ if (c && c.isRef) {
176
163
  $append.call(element, c.value);
177
164
  }
178
165
  else {
@@ -181,7 +168,7 @@ function applyContent(element, content) {
181
168
  }
182
169
  }
183
170
  else {
184
- if (content instanceof Ref) {
171
+ if (content && content.isRef) {
185
172
  $append.call(element, content.value);
186
173
  }
187
174
  else {
@@ -200,7 +187,7 @@ function applyContent(element, content) {
200
187
  * ## About
201
188
  * @package @ktjs/core
202
189
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
203
- * @version 0.8.1 (Last Update: 2025.12.25 11:07:30.486)
190
+ * @version 0.8.3 (Last Update: 2025.12.25 11:27:17.924)
204
191
  * @license MIT
205
192
  * @link https://github.com/baendlorel/kt.js
206
193
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -233,7 +220,7 @@ function jsx(tag, props, ..._metadata) {
233
220
  const children = propObj.children;
234
221
  delete propObj.children;
235
222
  // deal with ref attribute
236
- const ref = 'ref' in propObj && propObj.ref instanceof Ref ? propObj.ref : null;
223
+ const ref = propObj.ref?.isRef ? propObj.ref : null;
237
224
  if (ref) {
238
225
  delete propObj.ref;
239
226
  }
@@ -293,4 +280,9 @@ const jsxDEV = (...args) => {
293
280
  */
294
281
  const jsxs = jsx;
295
282
 
296
- export { Fragment, Ref, h as createElement, jsx, jsxDEV, jsxs, ref };
283
+ const noop = () => ({});
284
+ function ref(value) {
285
+ return { value: value, update: noop, isRef: true };
286
+ }
287
+
288
+ export { Fragment, h as createElement, jsx, jsxDEV, jsxs, ref };
@@ -5,13 +5,13 @@ type otherstring = string & {};
5
5
  */
6
6
  type HTMLTag = keyof HTMLElementTagNameMap & otherstring;
7
7
 
8
- declare class Ref<T> {
8
+ interface KTRef<T> {
9
9
  value: T;
10
10
  update: () => T;
11
- constructor(value: T);
11
+ isRef: true;
12
12
  }
13
13
 
14
- type Ctt = Ref<any> | HTMLElement | string | number | undefined;
14
+ type Ctt = KTRef<any> | HTMLElement | string | number | undefined;
15
15
  type KTRawContent = Ctt[] | Ctt;
16
16
  type KTRawAttr = KTAttribute | string;
17
17
 
@@ -86,7 +86,7 @@ type HTML<T extends HTMLTag & otherstring> = T extends HTMLTag ? HTMLElementTagN
86
86
  * ## About
87
87
  * @package @ktjs/core
88
88
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
89
- * @version 0.8.1 (Last Update: 2025.12.25 11:07:30.486)
89
+ * @version 0.8.3 (Last Update: 2025.12.25 11:27:17.924)
90
90
  * @license MIT
91
91
  * @link https://github.com/baendlorel/kt.js
92
92
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -155,21 +155,11 @@ function applyAttr(element, attr) {
155
155
  }
156
156
  }
157
157
 
158
- const noop = () => ({});
159
- class Ref {
160
- value;
161
- update;
162
- constructor(value) {
163
- this.value = value;
164
- this.update = noop;
165
- }
166
- }
167
-
168
158
  function applyContent(element, content) {
169
159
  if ($isArray(content)) {
170
160
  for (let i = 0; i < content.length; i++) {
171
161
  let c = content[i];
172
- if (c instanceof Ref) {
162
+ if (c && c.isRef) {
173
163
  $append.call(element, c.value);
174
164
  }
175
165
  else {
@@ -178,7 +168,7 @@ function applyContent(element, content) {
178
168
  }
179
169
  }
180
170
  else {
181
- if (content instanceof Ref) {
171
+ if (content && content.isRef) {
182
172
  $append.call(element, content.value);
183
173
  }
184
174
  else {
@@ -197,7 +187,7 @@ function applyContent(element, content) {
197
187
  * ## About
198
188
  * @package @ktjs/core
199
189
  * @author Kasukabe Tsumugi <futami16237@gmail.com>
200
- * @version 0.8.1 (Last Update: 2025.12.25 11:07:30.486)
190
+ * @version 0.8.3 (Last Update: 2025.12.25 11:27:17.924)
201
191
  * @license MIT
202
192
  * @link https://github.com/baendlorel/kt.js
203
193
  * @link https://baendlorel.github.io/ Welcome to my site!
@@ -230,7 +220,7 @@ function jsx(tag, props, ..._metadata) {
230
220
  const children = propObj.children;
231
221
  delete propObj.children;
232
222
  // deal with ref attribute
233
- const ref = 'ref' in propObj && propObj.ref instanceof Ref ? propObj.ref : null;
223
+ const ref = propObj.ref?.isRef ? propObj.ref : null;
234
224
  if (ref) {
235
225
  delete propObj.ref;
236
226
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ktjs/core",
3
- "version": "0.8.1",
3
+ "version": "0.8.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",