@thyn/core 0.0.256 → 0.0.258

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/element.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export declare function mount(app: any, parent: any): void;
2
2
  export declare function collectEffect(effectFn: any): void;
3
- export declare function createReactiveTextNode(v: any): Text;
3
+ export declare function createReactiveTextNode(v: any): any;
4
4
  export declare function component(name: any, props?: any): any;
5
5
  export declare function fixedComponent(name: any, props?: any): any;
6
6
  export declare function setAttribute(el: any, key: any, val: any): any;
package/dist/element.js CHANGED
@@ -8,9 +8,12 @@ export function collectEffect(effectFn) {
8
8
  collectingHead = effectFn;
9
9
  }
10
10
  export function createReactiveTextNode(v) {
11
- const n = document.createTextNode(v());
11
+ let n;
12
12
  staticEffect(() => {
13
- n.nodeValue = v();
13
+ if (n)
14
+ n.nodeValue = v();
15
+ else
16
+ n = document.createTextNode(v());
14
17
  });
15
18
  return n;
16
19
  }
@@ -50,19 +53,7 @@ export function fixedComponent(name, props) {
50
53
  const prevHead = collectingHead;
51
54
  collectingHead = null;
52
55
  const e = name(props);
53
- let existing = e.$fx;
54
- if (existing) {
55
- if (collectingHead) {
56
- let next;
57
- while ((next = existing.next)) {
58
- existing = next;
59
- }
60
- existing.next = collectingHead;
61
- }
62
- }
63
- else {
64
- e.$fx = collectingHead;
65
- }
56
+ e.$fx = collectingHead;
66
57
  collectingHead = prevHead;
67
58
  return e;
68
59
  }
@@ -77,7 +68,7 @@ export function setProperty(el, key, val) {
77
68
  return el;
78
69
  }
79
70
  export function setReactiveAttribute(el, key, val) {
80
- let ran;
71
+ let ran = false;
81
72
  return addEffect(el, staticEffect(() => {
82
73
  const v = val();
83
74
  if (ran) {
@@ -93,7 +84,7 @@ export function setReactiveAttribute(el, key, val) {
93
84
  }));
94
85
  }
95
86
  export function setReactiveProperty(el, key, val) {
96
- let ran = true;
87
+ let ran = false;
97
88
  return addEffect(el, staticEffect(() => {
98
89
  const v = val();
99
90
  if (ran) {
@@ -442,13 +433,13 @@ export function isolatedTerminalList(props) {
442
433
  }
443
434
  const childNodeList = parent.childNodes;
444
435
  if (!newLength) {
445
- let node = startBookend.nextSibling;
446
- while (node !== endBookend) {
436
+ let node = startBookend;
437
+ while (node = node.nextSibling) {
447
438
  shallowTeardown(node);
448
- node = node.nextSibling;
449
439
  }
450
440
  parent.textContent = "";
451
- parent.append(startBookend, endBookend);
441
+ parent.appendChild(startBookend);
442
+ parent.appendChild(endBookend);
452
443
  prevItems = nextItems;
453
444
  nextItems = null;
454
445
  return;
@@ -503,10 +494,9 @@ export function isolatedTerminalList(props) {
503
494
  }
504
495
  }
505
496
  if (allRemove) {
506
- let node = startBookend.nextSibling;
507
- while (node !== endBookend) {
497
+ let node = startBookend;
498
+ while (node = node.nextSibling) {
508
499
  shallowTeardown(node);
509
- node = node.nextSibling;
510
500
  }
511
501
  parent.textContent = "";
512
502
  parent.appendChild(startBookend);
package/dist/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  export { addChildren, addEffect, component, createReactiveTextNode, fixedComponent, isolatedTerminalList, list, markAsReactive, mount, setAttribute, setProperty, setReactiveAttribute, setReactiveProperty, show, terminalList } from "./element.js";
2
- export { addEvent } from "./events.js";
3
2
  export { $effect, $signal, staticEffect } from "./signals.js";
package/dist/index.js CHANGED
@@ -1,3 +1,2 @@
1
1
  export { addChildren, addEffect, component, createReactiveTextNode, fixedComponent, isolatedTerminalList, list, markAsReactive, mount, setAttribute, setProperty, setReactiveAttribute, setReactiveProperty, show, terminalList } from "./element.js";
2
- export { addEvent } from "./events.js";
3
2
  export { $effect, $signal, staticEffect } from "./signals.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thyn/core",
3
- "version": "0.0.256",
3
+ "version": "0.0.258",
4
4
  "scripts": {
5
5
  "build": "tsc",
6
6
  "pub": "tsc && npm version patch -f && npm -f publish --access=public",
package/src/element.ts CHANGED
@@ -11,9 +11,10 @@ export function collectEffect(effectFn) {
11
11
  }
12
12
 
13
13
  export function createReactiveTextNode(v) {
14
- const n = document.createTextNode(v());
14
+ let n;
15
15
  staticEffect(() => {
16
- n.nodeValue = v();
16
+ if (n) n.nodeValue = v();
17
+ else n = document.createTextNode(v());
17
18
  });
18
19
  return n;
19
20
  }
@@ -56,18 +57,7 @@ export function fixedComponent(name, props?: any) {
56
57
  const prevHead = collectingHead;
57
58
  collectingHead = null;
58
59
  const e = name(props);
59
- let existing = e.$fx;
60
- if (existing) {
61
- if (collectingHead) {
62
- let next;
63
- while ((next = existing.next)) {
64
- existing = next;
65
- }
66
- existing.next = collectingHead;
67
- }
68
- } else {
69
- e.$fx = collectingHead;
70
- }
60
+ e.$fx = collectingHead;
71
61
  collectingHead = prevHead;
72
62
  return e;
73
63
  }
@@ -81,7 +71,7 @@ export function setProperty(el, key, val) {
81
71
  return el;
82
72
  }
83
73
  export function setReactiveAttribute(el, key, val) {
84
- let ran;
74
+ let ran = false;
85
75
  return addEffect(
86
76
  el,
87
77
  staticEffect(() => {
@@ -97,7 +87,7 @@ export function setReactiveAttribute(el, key, val) {
97
87
  );
98
88
  }
99
89
  export function setReactiveProperty(el, key, val) {
100
- let ran = true;
90
+ let ran = false;
101
91
  return addEffect(
102
92
  el,
103
93
  staticEffect(() => {
@@ -470,13 +460,13 @@ export function isolatedTerminalList(props) {
470
460
  }
471
461
  const childNodeList = parent.childNodes as NodeListOf<ChildNode>;
472
462
  if (!newLength) {
473
- let node = startBookend.nextSibling;
474
- while (node !== endBookend) {
463
+ let node = startBookend;
464
+ while (node = node.nextSibling) {
475
465
  shallowTeardown(node);
476
- node = node.nextSibling;
477
466
  }
478
467
  parent.textContent = "";
479
- parent.append(startBookend, endBookend);
468
+ parent.appendChild(startBookend);
469
+ parent.appendChild(endBookend);
480
470
  prevItems = nextItems;
481
471
  nextItems = null;
482
472
  return;
@@ -540,10 +530,9 @@ export function isolatedTerminalList(props) {
540
530
  }
541
531
  }
542
532
  if (allRemove) {
543
- let node = startBookend.nextSibling;
544
- while (node !== endBookend) {
533
+ let node = startBookend;
534
+ while (node = node.nextSibling) {
545
535
  shallowTeardown(node);
546
- node = node.nextSibling;
547
536
  }
548
537
  parent.textContent = "";
549
538
  parent.appendChild(startBookend);
package/src/index.ts CHANGED
@@ -15,5 +15,5 @@ export {
15
15
  show,
16
16
  terminalList
17
17
  } from "./element.js";
18
- export { addEvent } from "./events.js";
19
18
  export { $effect, $signal, staticEffect } from "./signals.js";
19
+
@@ -1 +1 @@
1
- {"fileNames":["./node_modules/typescript/lib/lib.es5.d.ts","./node_modules/typescript/lib/lib.es2015.d.ts","./node_modules/typescript/lib/lib.es2016.d.ts","./node_modules/typescript/lib/lib.es2017.d.ts","./node_modules/typescript/lib/lib.es2018.d.ts","./node_modules/typescript/lib/lib.es2019.d.ts","./node_modules/typescript/lib/lib.es2020.d.ts","./node_modules/typescript/lib/lib.dom.d.ts","./node_modules/typescript/lib/lib.dom.iterable.d.ts","./node_modules/typescript/lib/lib.dom.asynciterable.d.ts","./node_modules/typescript/lib/lib.webworker.importscripts.d.ts","./node_modules/typescript/lib/lib.scripthost.d.ts","./node_modules/typescript/lib/lib.es2015.core.d.ts","./node_modules/typescript/lib/lib.es2015.collection.d.ts","./node_modules/typescript/lib/lib.es2015.generator.d.ts","./node_modules/typescript/lib/lib.es2015.iterable.d.ts","./node_modules/typescript/lib/lib.es2015.promise.d.ts","./node_modules/typescript/lib/lib.es2015.proxy.d.ts","./node_modules/typescript/lib/lib.es2015.reflect.d.ts","./node_modules/typescript/lib/lib.es2015.symbol.d.ts","./node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","./node_modules/typescript/lib/lib.es2016.array.include.d.ts","./node_modules/typescript/lib/lib.es2016.intl.d.ts","./node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","./node_modules/typescript/lib/lib.es2017.date.d.ts","./node_modules/typescript/lib/lib.es2017.object.d.ts","./node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","./node_modules/typescript/lib/lib.es2017.string.d.ts","./node_modules/typescript/lib/lib.es2017.intl.d.ts","./node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","./node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","./node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","./node_modules/typescript/lib/lib.es2018.intl.d.ts","./node_modules/typescript/lib/lib.es2018.promise.d.ts","./node_modules/typescript/lib/lib.es2018.regexp.d.ts","./node_modules/typescript/lib/lib.es2019.array.d.ts","./node_modules/typescript/lib/lib.es2019.object.d.ts","./node_modules/typescript/lib/lib.es2019.string.d.ts","./node_modules/typescript/lib/lib.es2019.symbol.d.ts","./node_modules/typescript/lib/lib.es2019.intl.d.ts","./node_modules/typescript/lib/lib.es2020.bigint.d.ts","./node_modules/typescript/lib/lib.es2020.date.d.ts","./node_modules/typescript/lib/lib.es2020.promise.d.ts","./node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","./node_modules/typescript/lib/lib.es2020.string.d.ts","./node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","./node_modules/typescript/lib/lib.es2020.intl.d.ts","./node_modules/typescript/lib/lib.es2020.number.d.ts","./node_modules/typescript/lib/lib.decorators.d.ts","./node_modules/typescript/lib/lib.decorators.legacy.d.ts","./node_modules/typescript/lib/lib.es2020.full.d.ts","./src/signals.ts","./src/element.ts","./src/events.ts","./src/index.ts","./src/router.ts","./node_modules/@types/deep-eql/index.d.ts","./node_modules/assertion-error/index.d.ts","./node_modules/@types/chai/index.d.ts","./node_modules/@types/estree/index.d.ts"],"fileIdsList":[[57,58],[52],[52,53,54],[52,53],[53]],"fileInfos":[{"version":"c430d44666289dae81f30fa7b2edebf186ecc91a2d4c71266ea6ae76388792e1","affectsGlobalScope":true,"impliedFormat":1},{"version":"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","impliedFormat":1},{"version":"3facaf05f0c5fc569c5649dd359892c98a85557e3e0c847964caeb67076f4d75","impliedFormat":1},{"version":"e44bb8bbac7f10ecc786703fe0a6a4b952189f908707980ba8f3c8975a760962","impliedFormat":1},{"version":"5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","impliedFormat":1},{"version":"68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","impliedFormat":1},{"version":"5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","impliedFormat":1},{"version":"080941d9f9ff9307f7e27a83bcd888b7c8270716c39af943532438932ec1d0b9","affectsGlobalScope":true,"impliedFormat":1},{"version":"2e80ee7a49e8ac312cc11b77f1475804bee36b3b2bc896bead8b6e1266befb43","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7a3c8b952931daebdfc7a2897c53c0a1c73624593fa070e46bd537e64dcd20a","affectsGlobalScope":true,"impliedFormat":1},{"version":"80e18897e5884b6723488d4f5652167e7bb5024f946743134ecc4aa4ee731f89","affectsGlobalScope":true,"impliedFormat":1},{"version":"cd034f499c6cdca722b60c04b5b1b78e058487a7085a8e0d6fb50809947ee573","affectsGlobalScope":true,"impliedFormat":1},{"version":"c57796738e7f83dbc4b8e65132f11a377649c00dd3eee333f672b8f0a6bea671","affectsGlobalScope":true,"impliedFormat":1},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true,"impliedFormat":1},{"version":"515d0b7b9bea2e31ea4ec968e9edd2c39d3eebf4a2d5cbd04e88639819ae3b71","affectsGlobalScope":true,"impliedFormat":1},{"version":"0559b1f683ac7505ae451f9a96ce4c3c92bdc71411651ca6ddb0e88baaaad6a3","affectsGlobalScope":true,"impliedFormat":1},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true,"impliedFormat":1},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true,"impliedFormat":1},{"version":"fb0f136d372979348d59b3f5020b4cdb81b5504192b1cacff5d1fbba29378aa1","affectsGlobalScope":true,"impliedFormat":1},{"version":"d15bea3d62cbbdb9797079416b8ac375ae99162a7fba5de2c6c505446486ac0a","affectsGlobalScope":true,"impliedFormat":1},{"version":"68d18b664c9d32a7336a70235958b8997ebc1c3b8505f4f1ae2b7e7753b87618","affectsGlobalScope":true,"impliedFormat":1},{"version":"eb3d66c8327153d8fa7dd03f9c58d351107fe824c79e9b56b462935176cdf12a","affectsGlobalScope":true,"impliedFormat":1},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true,"impliedFormat":1},{"version":"69ab18c3b76cd9b1be3d188eaf8bba06112ebbe2f47f6c322b5105a6fbc45a2e","affectsGlobalScope":true,"impliedFormat":1},{"version":"a680117f487a4d2f30ea46f1b4b7f58bef1480456e18ba53ee85c2746eeca012","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true,"impliedFormat":1},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true,"impliedFormat":1},{"version":"954296b30da6d508a104a3a0b5d96b76495c709785c1d11610908e63481ee667","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac9538681b19688c8eae65811b329d3744af679e0bdfa5d842d0e32524c73e1c","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a969edff4bd52585473d24995c5ef223f6652d6ef46193309b3921d65dd4376","affectsGlobalScope":true,"impliedFormat":1},{"version":"9e9fbd7030c440b33d021da145d3232984c8bb7916f277e8ffd3dc2e3eae2bdb","affectsGlobalScope":true,"impliedFormat":1},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true,"impliedFormat":1},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true,"impliedFormat":1},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true,"impliedFormat":1},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true,"impliedFormat":1},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true,"impliedFormat":1},{"version":"74f7fa2d027d5b33eb0471c8e82a6c87216223181ec31247c357a3e8e2fddc5b","affectsGlobalScope":true,"impliedFormat":1},{"version":"d6d7ae4d1f1f3772e2a3cde568ed08991a8ae34a080ff1151af28b7f798e22ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true,"impliedFormat":1},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true,"impliedFormat":1},{"version":"52ada8e0b6e0482b728070b7639ee42e83a9b1c22d205992756fe020fd9f4a47","affectsGlobalScope":true,"impliedFormat":1},{"version":"3bdefe1bfd4d6dee0e26f928f93ccc128f1b64d5d501ff4a8cf3c6371200e5e6","affectsGlobalScope":true,"impliedFormat":1},{"version":"59fb2c069260b4ba00b5643b907ef5d5341b167e7d1dbf58dfd895658bda2867","affectsGlobalScope":true,"impliedFormat":1},{"version":"639e512c0dfc3fad96a84caad71b8834d66329a1f28dc95e3946c9b58176c73a","affectsGlobalScope":true,"impliedFormat":1},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true,"impliedFormat":1},{"version":"8e7f8264d0fb4c5339605a15daadb037bf238c10b654bb3eee14208f860a32ea","affectsGlobalScope":true,"impliedFormat":1},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true,"impliedFormat":1},{"version":"1305d1e76ca44e30fb8b2b8075fa522b83f60c0bcf5d4326a9d2cf79b53724f8","impliedFormat":1},{"version":"c45a0d7dd2ff10ebdf27f52c49ee05ced56340415c47a74af35a94c03dd0a09e","signature":"6f62706ec7610ba34467f5a0c3a393d6557bc78b9cc5592492fd0beca1a0315f"},{"version":"263db8e57bde1b63fd080d385ca44c7be4918a1951c19b48f963f16a16a8b695","signature":"1012c49b8c773599250ad516ce94f9c0a5fc4b64931e6244c52520335a543143"},{"version":"2c0edc9fba857d7a0e3f8173c3c1e1047e0e79e100f4e900e9d805eb01f411b4","signature":"f86b34792435dde287dfe695eab3462379d00d5769ecf62e4bbd551228a7b4b1"},{"version":"f0402dd5a9b5f441432684b96e5b2e84d653b6a89696f3cc67454421ce7813d4","signature":"aad19965bd7078bf21bff4539cfbea6df553926491472abf86a8833dd53d13c3"},{"version":"a155e9ebe821846c43103394346639a6a19a7f844be4892bbe4352aa20ee6707","signature":"58b2b60f8aae88fb4b926c3f9700b21a56e0b0f4016e56ab9fa879550cbdb294"},{"version":"427fe2004642504828c1476d0af4270e6ad4db6de78c0b5da3e4c5ca95052a99","impliedFormat":1},{"version":"2eeffcee5c1661ddca53353929558037b8cf305ffb86a803512982f99bcab50d","impliedFormat":99},{"version":"9afb4cb864d297e4092a79ee2871b5d3143ea14153f62ef0bb04ede25f432030","affectsGlobalScope":true,"impliedFormat":99},{"version":"151ff381ef9ff8da2da9b9663ebf657eac35c4c9a19183420c05728f31a6761d","impliedFormat":1}],"root":[[52,56]],"options":{"allowJs":true,"checkJs":false,"composite":true,"esModuleInterop":true,"module":99,"outDir":"./dist","rootDir":"./src","skipLibCheck":true,"target":7},"referencedMap":[[59,1],[53,2],[55,3],[56,4],[52,5]],"latestChangedDtsFile":"./dist/index.d.ts","version":"5.9.3"}
1
+ {"fileNames":["./node_modules/typescript/lib/lib.es5.d.ts","./node_modules/typescript/lib/lib.es2015.d.ts","./node_modules/typescript/lib/lib.es2016.d.ts","./node_modules/typescript/lib/lib.es2017.d.ts","./node_modules/typescript/lib/lib.es2018.d.ts","./node_modules/typescript/lib/lib.es2019.d.ts","./node_modules/typescript/lib/lib.es2020.d.ts","./node_modules/typescript/lib/lib.dom.d.ts","./node_modules/typescript/lib/lib.dom.iterable.d.ts","./node_modules/typescript/lib/lib.dom.asynciterable.d.ts","./node_modules/typescript/lib/lib.webworker.importscripts.d.ts","./node_modules/typescript/lib/lib.scripthost.d.ts","./node_modules/typescript/lib/lib.es2015.core.d.ts","./node_modules/typescript/lib/lib.es2015.collection.d.ts","./node_modules/typescript/lib/lib.es2015.generator.d.ts","./node_modules/typescript/lib/lib.es2015.iterable.d.ts","./node_modules/typescript/lib/lib.es2015.promise.d.ts","./node_modules/typescript/lib/lib.es2015.proxy.d.ts","./node_modules/typescript/lib/lib.es2015.reflect.d.ts","./node_modules/typescript/lib/lib.es2015.symbol.d.ts","./node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","./node_modules/typescript/lib/lib.es2016.array.include.d.ts","./node_modules/typescript/lib/lib.es2016.intl.d.ts","./node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","./node_modules/typescript/lib/lib.es2017.date.d.ts","./node_modules/typescript/lib/lib.es2017.object.d.ts","./node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","./node_modules/typescript/lib/lib.es2017.string.d.ts","./node_modules/typescript/lib/lib.es2017.intl.d.ts","./node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","./node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","./node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","./node_modules/typescript/lib/lib.es2018.intl.d.ts","./node_modules/typescript/lib/lib.es2018.promise.d.ts","./node_modules/typescript/lib/lib.es2018.regexp.d.ts","./node_modules/typescript/lib/lib.es2019.array.d.ts","./node_modules/typescript/lib/lib.es2019.object.d.ts","./node_modules/typescript/lib/lib.es2019.string.d.ts","./node_modules/typescript/lib/lib.es2019.symbol.d.ts","./node_modules/typescript/lib/lib.es2019.intl.d.ts","./node_modules/typescript/lib/lib.es2020.bigint.d.ts","./node_modules/typescript/lib/lib.es2020.date.d.ts","./node_modules/typescript/lib/lib.es2020.promise.d.ts","./node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","./node_modules/typescript/lib/lib.es2020.string.d.ts","./node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","./node_modules/typescript/lib/lib.es2020.intl.d.ts","./node_modules/typescript/lib/lib.es2020.number.d.ts","./node_modules/typescript/lib/lib.decorators.d.ts","./node_modules/typescript/lib/lib.decorators.legacy.d.ts","./node_modules/typescript/lib/lib.es2020.full.d.ts","./src/signals.ts","./src/element.ts","./src/index.ts","./src/router.ts","./node_modules/@types/deep-eql/index.d.ts","./node_modules/assertion-error/index.d.ts","./node_modules/@types/chai/index.d.ts","./node_modules/@types/estree/index.d.ts"],"fileIdsList":[[56,57],[52],[52,53],[53]],"fileInfos":[{"version":"c430d44666289dae81f30fa7b2edebf186ecc91a2d4c71266ea6ae76388792e1","affectsGlobalScope":true,"impliedFormat":1},{"version":"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","impliedFormat":1},{"version":"3facaf05f0c5fc569c5649dd359892c98a85557e3e0c847964caeb67076f4d75","impliedFormat":1},{"version":"e44bb8bbac7f10ecc786703fe0a6a4b952189f908707980ba8f3c8975a760962","impliedFormat":1},{"version":"5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","impliedFormat":1},{"version":"68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","impliedFormat":1},{"version":"5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","impliedFormat":1},{"version":"080941d9f9ff9307f7e27a83bcd888b7c8270716c39af943532438932ec1d0b9","affectsGlobalScope":true,"impliedFormat":1},{"version":"2e80ee7a49e8ac312cc11b77f1475804bee36b3b2bc896bead8b6e1266befb43","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7a3c8b952931daebdfc7a2897c53c0a1c73624593fa070e46bd537e64dcd20a","affectsGlobalScope":true,"impliedFormat":1},{"version":"80e18897e5884b6723488d4f5652167e7bb5024f946743134ecc4aa4ee731f89","affectsGlobalScope":true,"impliedFormat":1},{"version":"cd034f499c6cdca722b60c04b5b1b78e058487a7085a8e0d6fb50809947ee573","affectsGlobalScope":true,"impliedFormat":1},{"version":"c57796738e7f83dbc4b8e65132f11a377649c00dd3eee333f672b8f0a6bea671","affectsGlobalScope":true,"impliedFormat":1},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true,"impliedFormat":1},{"version":"515d0b7b9bea2e31ea4ec968e9edd2c39d3eebf4a2d5cbd04e88639819ae3b71","affectsGlobalScope":true,"impliedFormat":1},{"version":"0559b1f683ac7505ae451f9a96ce4c3c92bdc71411651ca6ddb0e88baaaad6a3","affectsGlobalScope":true,"impliedFormat":1},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true,"impliedFormat":1},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true,"impliedFormat":1},{"version":"fb0f136d372979348d59b3f5020b4cdb81b5504192b1cacff5d1fbba29378aa1","affectsGlobalScope":true,"impliedFormat":1},{"version":"d15bea3d62cbbdb9797079416b8ac375ae99162a7fba5de2c6c505446486ac0a","affectsGlobalScope":true,"impliedFormat":1},{"version":"68d18b664c9d32a7336a70235958b8997ebc1c3b8505f4f1ae2b7e7753b87618","affectsGlobalScope":true,"impliedFormat":1},{"version":"eb3d66c8327153d8fa7dd03f9c58d351107fe824c79e9b56b462935176cdf12a","affectsGlobalScope":true,"impliedFormat":1},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true,"impliedFormat":1},{"version":"69ab18c3b76cd9b1be3d188eaf8bba06112ebbe2f47f6c322b5105a6fbc45a2e","affectsGlobalScope":true,"impliedFormat":1},{"version":"a680117f487a4d2f30ea46f1b4b7f58bef1480456e18ba53ee85c2746eeca012","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true,"impliedFormat":1},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true,"impliedFormat":1},{"version":"954296b30da6d508a104a3a0b5d96b76495c709785c1d11610908e63481ee667","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac9538681b19688c8eae65811b329d3744af679e0bdfa5d842d0e32524c73e1c","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a969edff4bd52585473d24995c5ef223f6652d6ef46193309b3921d65dd4376","affectsGlobalScope":true,"impliedFormat":1},{"version":"9e9fbd7030c440b33d021da145d3232984c8bb7916f277e8ffd3dc2e3eae2bdb","affectsGlobalScope":true,"impliedFormat":1},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true,"impliedFormat":1},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true,"impliedFormat":1},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true,"impliedFormat":1},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true,"impliedFormat":1},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true,"impliedFormat":1},{"version":"74f7fa2d027d5b33eb0471c8e82a6c87216223181ec31247c357a3e8e2fddc5b","affectsGlobalScope":true,"impliedFormat":1},{"version":"d6d7ae4d1f1f3772e2a3cde568ed08991a8ae34a080ff1151af28b7f798e22ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true,"impliedFormat":1},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true,"impliedFormat":1},{"version":"52ada8e0b6e0482b728070b7639ee42e83a9b1c22d205992756fe020fd9f4a47","affectsGlobalScope":true,"impliedFormat":1},{"version":"3bdefe1bfd4d6dee0e26f928f93ccc128f1b64d5d501ff4a8cf3c6371200e5e6","affectsGlobalScope":true,"impliedFormat":1},{"version":"59fb2c069260b4ba00b5643b907ef5d5341b167e7d1dbf58dfd895658bda2867","affectsGlobalScope":true,"impliedFormat":1},{"version":"639e512c0dfc3fad96a84caad71b8834d66329a1f28dc95e3946c9b58176c73a","affectsGlobalScope":true,"impliedFormat":1},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true,"impliedFormat":1},{"version":"8e7f8264d0fb4c5339605a15daadb037bf238c10b654bb3eee14208f860a32ea","affectsGlobalScope":true,"impliedFormat":1},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true,"impliedFormat":1},{"version":"1305d1e76ca44e30fb8b2b8075fa522b83f60c0bcf5d4326a9d2cf79b53724f8","impliedFormat":1},{"version":"c45a0d7dd2ff10ebdf27f52c49ee05ced56340415c47a74af35a94c03dd0a09e","signature":"6f62706ec7610ba34467f5a0c3a393d6557bc78b9cc5592492fd0beca1a0315f"},{"version":"ea2816684ad892b056facb0b021ac7eb438b34f0582987d5e47afc408d578be4","signature":"f3ddd3670c33381859688f604378a0028cafa5b52cc936da9a225933eb464387"},{"version":"17c210e47841877c5c6e6d64cf41277596f65faa6cf3ec35c482c3c2231bb21b","signature":"12fd8be483df752ac04ae85347f9c397954ac2390e0de50612bf8b9899d7767d"},{"version":"a155e9ebe821846c43103394346639a6a19a7f844be4892bbe4352aa20ee6707","signature":"58b2b60f8aae88fb4b926c3f9700b21a56e0b0f4016e56ab9fa879550cbdb294"},{"version":"427fe2004642504828c1476d0af4270e6ad4db6de78c0b5da3e4c5ca95052a99","impliedFormat":1},{"version":"2eeffcee5c1661ddca53353929558037b8cf305ffb86a803512982f99bcab50d","impliedFormat":99},{"version":"9afb4cb864d297e4092a79ee2871b5d3143ea14153f62ef0bb04ede25f432030","affectsGlobalScope":true,"impliedFormat":99},{"version":"151ff381ef9ff8da2da9b9663ebf657eac35c4c9a19183420c05728f31a6761d","impliedFormat":1}],"root":[[52,55]],"options":{"allowJs":true,"checkJs":false,"composite":true,"esModuleInterop":true,"module":99,"outDir":"./dist","rootDir":"./src","skipLibCheck":true,"target":7},"referencedMap":[[58,1],[53,2],[54,3],[55,3],[52,4]],"latestChangedDtsFile":"./dist/index.d.ts","version":"5.9.3"}
package/src/events.ts DELETED
@@ -1,58 +0,0 @@
1
- const delegatedEvents = new Set<string>();
2
-
3
- const eventMap: Record<string, string> = {
4
- focus: 'focusin',
5
- blur: 'focusout',
6
- };
7
-
8
- // Events that bubble and are safe to delegate
9
- const bubbly = new Set([
10
- 'click', 'dblclick', 'contextmenu',
11
- 'keydown', 'keypress', 'keyup',
12
- 'mousedown', 'mousemove', 'mouseup', 'mouseout', 'mouseover',
13
- 'touchstart', 'touchend', 'touchmove', 'touchcancel',
14
- 'change', 'input', 'submit', 'reset',
15
- 'focusin', 'focusout',
16
- 'drag', 'dragend', 'dragenter', 'dragleave', 'dragover', 'dragstart', 'drop',
17
- 'animationstart', 'animationend', 'animationiteration',
18
- 'transitionend'
19
- ]);
20
-
21
- export function addEvent(el: any, name: string, handler: Function) {
22
- let eventName = name.startsWith('on') ? name.slice(2).toLowerCase() : name.toLowerCase();
23
-
24
- // Map events if needed (e.g. focus -> focusin)
25
- if (eventName in eventMap) {
26
- eventName = eventMap[eventName];
27
- }
28
-
29
- // If it's a known bubbling event, delegate it
30
- if (bubbly.has(eventName)) {
31
- if (!delegatedEvents.has(eventName)) {
32
- delegatedEvents.add(eventName);
33
- document.addEventListener(eventName, handleEvent);
34
- }
35
- if (!el.$$events) el.$$events = {};
36
- el.$$events[eventName] = handler;
37
- } else {
38
- // Fallback for non-bubbling events (scroll, load, mouseenter, etc.)
39
- // We attach directly.
40
- el.addEventListener(eventName, handler);
41
- }
42
- }
43
-
44
- function handleEvent(e: Event) {
45
- let node = e.target as Node;
46
- const eventName = e.type;
47
-
48
- while (node) {
49
- const handler = (node as any).$$events?.[eventName];
50
- if (handler) {
51
- // Use .call to set 'this' to the element, mimicking currentTarget
52
- handler.call(node, e);
53
- if (e.cancelBubble) return;
54
- }
55
- if (node === document) break;
56
- node = node.parentNode;
57
- }
58
- }
@@ -1,91 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach } from 'vitest';
2
- import { addEvent } from '../src/events';
3
-
4
- describe('Event Delegation', () => {
5
- let root: HTMLElement;
6
-
7
- beforeEach(() => {
8
- document.body.innerHTML = '';
9
- root = document.createElement('div');
10
- document.body.appendChild(root);
11
- });
12
-
13
- it('delegates click events', () => {
14
- const handler = vi.fn();
15
- const btn = document.createElement('button');
16
- root.appendChild(btn);
17
-
18
- addEvent(btn, 'click', handler);
19
-
20
- btn.click();
21
- expect(handler).toHaveBeenCalledTimes(1);
22
- });
23
-
24
- it('sets correct currentTarget in handler', () => {
25
- const handler = vi.fn(function(e) {
26
- expect(this).toBe(btn);
27
- // Note: we can't easily mock e.currentTarget being read-only on native events
28
- // but checking `this` is a good proxy for what frameworks provide
29
- });
30
- const btn = document.createElement('button');
31
- root.appendChild(btn);
32
-
33
- addEvent(btn, 'click', handler);
34
-
35
- btn.click();
36
- expect(handler).toHaveBeenCalledTimes(1);
37
- });
38
-
39
- it('delegates focus events via focusin', () => {
40
- const handler = vi.fn();
41
- const input = document.createElement('input');
42
- root.appendChild(input);
43
-
44
- addEvent(input, 'focus', handler);
45
-
46
- // Focus doesn't bubble, but we expect our delegation to handle it (likely via focusin)
47
- // Dispatching 'focus' directly on element won't bubble to document.
48
- // So we rely on the framework listening to 'focusin' on document.
49
- // Or, if we use capture, it catches 'focus'.
50
- // Let's see what happens if we dispatch focus.
51
- input.focus();
52
- // input.focus() triggers a 'focus' event.
53
-
54
- // If the implementation uses focusin on document, we need to check if jsdom fires focusin on focus.
55
- // JSDOM does support focusin/focusout.
56
-
57
- expect(handler).toHaveBeenCalledTimes(1);
58
- });
59
-
60
- it('handles non-bubbling events like scroll by direct attachment', () => {
61
- const handler = vi.fn();
62
- const div = document.createElement('div');
63
- div.style.height = '100px';
64
- div.style.overflow = 'scroll';
65
- div.innerHTML = '<div style="height: 200px"></div>';
66
- root.appendChild(div);
67
-
68
- addEvent(div, 'scroll', handler);
69
-
70
- div.dispatchEvent(new Event('scroll'));
71
- expect(handler).toHaveBeenCalledTimes(1);
72
- });
73
-
74
- it('stops propagation correctly', () => {
75
- const parentHandler = vi.fn();
76
- const childHandler = vi.fn((e) => e.stopPropagation());
77
-
78
- const parent = document.createElement('div');
79
- const child = document.createElement('button');
80
- parent.appendChild(child);
81
- root.appendChild(parent);
82
-
83
- addEvent(parent, 'click', parentHandler);
84
- addEvent(child, 'click', childHandler);
85
-
86
- child.click();
87
-
88
- expect(childHandler).toHaveBeenCalledTimes(1);
89
- expect(parentHandler).not.toHaveBeenCalled();
90
- });
91
- });