valyrian.js 7.2.11 → 7.2.12

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.
Files changed (64) hide show
  1. package/dist/dataset/index.d.ts +2 -2
  2. package/dist/dataset/index.d.ts.map +1 -1
  3. package/dist/dataset/index.js +21 -21
  4. package/dist/dataset/index.js.map +2 -2
  5. package/dist/dataset/index.mjs +22 -22
  6. package/dist/dataset/index.mjs.map +2 -2
  7. package/dist/hooks/index.d.ts.map +1 -1
  8. package/dist/hooks/index.js +17 -32
  9. package/dist/hooks/index.js.map +3 -3
  10. package/dist/hooks/index.mjs +17 -32
  11. package/dist/hooks/index.mjs.map +3 -3
  12. package/dist/index.d.ts +49 -53
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +378 -326
  15. package/dist/index.js.map +3 -3
  16. package/dist/index.min.js +1 -1
  17. package/dist/index.min.js.map +1 -1
  18. package/dist/index.mjs +378 -326
  19. package/dist/index.mjs.map +3 -3
  20. package/dist/node/index.js +101 -78
  21. package/dist/node/index.js.map +2 -2
  22. package/dist/node/index.mjs +101 -78
  23. package/dist/node/index.mjs.map +2 -2
  24. package/dist/node/utils/tree-adapter.d.ts +5 -0
  25. package/dist/node/utils/tree-adapter.d.ts.map +1 -1
  26. package/dist/proxy-signal/index.js +10 -10
  27. package/dist/proxy-signal/index.js.map +2 -2
  28. package/dist/proxy-signal/index.mjs +10 -10
  29. package/dist/proxy-signal/index.mjs.map +2 -2
  30. package/dist/request/index.js +16 -16
  31. package/dist/request/index.js.map +2 -2
  32. package/dist/request/index.mjs +16 -16
  33. package/dist/request/index.mjs.map +2 -2
  34. package/dist/router/index.d.ts.map +1 -1
  35. package/dist/router/index.js +21 -20
  36. package/dist/router/index.js.map +2 -2
  37. package/dist/router/index.mjs +21 -20
  38. package/dist/router/index.mjs.map +2 -2
  39. package/dist/signal/index.d.ts +7 -18
  40. package/dist/signal/index.d.ts.map +1 -1
  41. package/dist/signal/index.js +29 -48
  42. package/dist/signal/index.js.map +3 -3
  43. package/dist/signal/index.mjs +31 -50
  44. package/dist/signal/index.mjs.map +3 -3
  45. package/dist/store/index.js +2 -2
  46. package/dist/store/index.js.map +2 -2
  47. package/dist/store/index.mjs +2 -2
  48. package/dist/store/index.mjs.map +2 -2
  49. package/lib/dataset/index.ts +25 -25
  50. package/lib/hooks/index.ts +25 -54
  51. package/lib/index.ts +465 -715
  52. package/lib/node/index.ts +2 -2
  53. package/lib/node/utils/icons.ts +5 -5
  54. package/lib/node/utils/inline.ts +17 -17
  55. package/lib/node/utils/sw.ts +3 -3
  56. package/lib/node/utils/tree-adapter.ts +81 -52
  57. package/lib/proxy-signal/index.ts +10 -10
  58. package/lib/request/index.ts +16 -16
  59. package/lib/router/index.ts +21 -20
  60. package/lib/signal/index.ts +56 -131
  61. package/lib/store/index.ts +2 -2
  62. package/package.json +10 -3
  63. package/lib/index.d.ts +0 -0
  64. package/lib/interfaces.ts.bak +0 -141
package/lib/node/index.ts CHANGED
@@ -11,8 +11,8 @@ global.FormData = FormData as any;
11
11
  global.document = document as any;
12
12
 
13
13
  function render(...args: any[]) {
14
- let Component = () => args;
15
- let result = mount("div", Component);
14
+ const Component = () => args;
15
+ const result = mount("div", Component);
16
16
  unmount();
17
17
  return result;
18
18
  }
@@ -33,7 +33,7 @@ interface IconsOptions {
33
33
  }
34
34
 
35
35
  export async function icons(source: string, configuration?: IconsOptions) {
36
- let options = {
36
+ const options = {
37
37
  ...icons.options,
38
38
  ...(configuration || {})
39
39
  };
@@ -49,20 +49,20 @@ export async function icons(source: string, configuration?: IconsOptions) {
49
49
  const { favicons } = await import("favicons");
50
50
 
51
51
  try {
52
- let response = await favicons(source, options);
52
+ const response = await favicons(source, options);
53
53
 
54
54
  if (options.iconsPath) {
55
- for (let i in response.images) {
55
+ for (const i in response.images) {
56
56
  fs.writeFileSync(options.iconsPath + response.images[i].name, response.images[i].contents);
57
57
  }
58
58
 
59
- for (let i in response.files) {
59
+ for (const i in response.files) {
60
60
  fs.writeFileSync(options.iconsPath + response.files[i].name, response.files[i].contents);
61
61
  }
62
62
  }
63
63
 
64
64
  if (options.linksViewPath) {
65
- let html = `
65
+ const html = `
66
66
  function Links(){
67
67
  return ${htmlToHyperscript(response.html.join(""))};
68
68
  }
@@ -12,13 +12,13 @@ export async function inline(
12
12
  options: Record<string, any> = {}
13
13
  ) {
14
14
  if (typeof file === "string") {
15
- let ext = file.split(".").pop();
15
+ const ext = file.split(".").pop();
16
16
  if (ext && /(js|cjs|jsx|mjs|ts|tsx)/.test(ext)) {
17
17
  if (/(ts|tsx)/.test(ext) && !options.noValidate) {
18
- let declarationDir = options.declarationDir;
19
- let emitDeclaration = !!declarationDir;
18
+ const declarationDir = options.declarationDir;
19
+ const emitDeclaration = !!declarationDir;
20
20
 
21
- let tscProgOptions = {
21
+ const tscProgOptions = {
22
22
  basePath: process.cwd(), // always required, used for relative paths
23
23
  configFilePath: "tsconfig.json", // config to inherit from (optional)
24
24
  files: [file],
@@ -53,7 +53,7 @@ export async function inline(
53
53
  tsc.build(tscProgOptions);
54
54
  }
55
55
 
56
- let esbuildOptions = {
56
+ const esbuildOptions = {
57
57
  entryPoints: [file],
58
58
  bundle: "bundle" in options ? options.bundle : true,
59
59
  sourcemap: "external",
@@ -72,14 +72,14 @@ export async function inline(
72
72
  ...(options.esbuild || {})
73
73
  };
74
74
 
75
- let result = await esbuild.build(esbuildOptions);
75
+ const result = await esbuild.build(esbuildOptions);
76
76
  if (result.outputFiles?.length !== 2) {
77
77
  throw new Error(result.errors.join("\n"));
78
78
  }
79
79
 
80
80
  if (options.compact) {
81
81
  const terser = await import("terser");
82
- let result2 = await terser.minify(result.outputFiles[1].text, {
82
+ const result2 = await terser.minify(result.outputFiles[1].text, {
83
83
  sourceMap: {
84
84
  content: result.outputFiles[0].text.toString()
85
85
  },
@@ -97,16 +97,16 @@ export async function inline(
97
97
  throw new Error("Unknown error");
98
98
  }
99
99
 
100
- let mapBase64 = Buffer.from(result2.map.toString()).toString("base64");
101
- let suffix = `//# sourceMappingURL=data:application/json;charset=utf-8;base64,${mapBase64}`;
100
+ const mapBase64 = Buffer.from(result2.map.toString()).toString("base64");
101
+ const suffix = `//# sourceMappingURL=data:application/json;charset=utf-8;base64,${mapBase64}`;
102
102
  return { raw: result2.code, map: suffix, file };
103
103
  } else {
104
- let mapBase64 = Buffer.from(result.outputFiles[0].text.toString()).toString("base64");
105
- let suffix = `//# sourceMappingURL=data:application/json;charset=utf-8;base64,${mapBase64}`;
104
+ const mapBase64 = Buffer.from(result.outputFiles[0].text.toString()).toString("base64");
105
+ const suffix = `//# sourceMappingURL=data:application/json;charset=utf-8;base64,${mapBase64}`;
106
106
  return { raw: result.outputFiles[1].text, map: suffix, file };
107
107
  }
108
108
  } else if (ext && /(css|scss|styl)/.test(ext)) {
109
- let result = await new CleanCSS({
109
+ const result = await new CleanCSS({
110
110
  sourceMap: true,
111
111
  level: {
112
112
  1: {
@@ -133,18 +133,18 @@ inline.uncss = async function (
133
133
  css: string,
134
134
  options: Record<string, any> = {}
135
135
  ) {
136
- let html = await Promise.all(renderedHtml);
136
+ const html = await Promise.all(renderedHtml);
137
137
 
138
- let contents = html.map((item) => {
138
+ const contents = html.map((item) => {
139
139
  return {
140
140
  raw: item,
141
141
  extension: "html"
142
142
  };
143
143
  });
144
144
 
145
- let purgecss = new PurgeCSS();
145
+ const purgecss = new PurgeCSS();
146
146
 
147
- let output = await purgecss.purge({
147
+ const output = await purgecss.purge({
148
148
  fontFace: true,
149
149
  keyframes: true,
150
150
  variables: true,
@@ -154,7 +154,7 @@ inline.uncss = async function (
154
154
  css: [{ raw: css }]
155
155
  });
156
156
 
157
- let cleanCss = await new CleanCSS({
157
+ const cleanCss = await new CleanCSS({
158
158
  sourceMap: false,
159
159
  level: {
160
160
  1: {
@@ -2,9 +2,9 @@ import fs from "fs";
2
2
  import path from "path";
3
3
 
4
4
  export function sw(file: string, options = {}) {
5
- let swfiletemplate = path.resolve(__dirname, "./node.sw.tpl");
6
- let swTpl = fs.readFileSync(swfiletemplate, "utf8");
7
- let opt = Object.assign(
5
+ const swfiletemplate = path.resolve(__dirname, "./node.sw.tpl");
6
+ const swTpl = fs.readFileSync(swfiletemplate, "utf8");
7
+ const opt = Object.assign(
8
8
  {
9
9
  version: "v1::",
10
10
  name: "Valyrian.js",
@@ -69,7 +69,7 @@ export class Node implements Node {
69
69
  node.parentNode && node.parentNode.removeChild(node as Node);
70
70
  node.parentNode = this;
71
71
  if (child) {
72
- let idx = this.childNodes.indexOf(child);
72
+ const idx = this.childNodes.indexOf(child);
73
73
  this.childNodes.splice(idx, 0, node);
74
74
  } else {
75
75
  this.childNodes.push(node);
@@ -87,19 +87,24 @@ export class Node implements Node {
87
87
  }
88
88
  removeChild<T extends Node>(child: T): T {
89
89
  if (child && child.parentNode === this) {
90
- let idx = (this.childNodes as unknown as Node[]).indexOf(child);
90
+ const idx = (this.childNodes as unknown as Node[]).indexOf(child);
91
91
  (this.childNodes as unknown as Node[]).splice(idx, 1);
92
92
  child.parentNode = null;
93
93
  }
94
94
  return child;
95
95
  }
96
+
97
+ remove(): Node {
98
+ return this.parentNode ? this.parentNode.removeChild(this) : this;
99
+ }
100
+
96
101
  cloneNode(deep?: boolean | undefined): Node {
97
102
  if (this.nodeType === 3) {
98
103
  return new Text(this.nodeValue);
99
104
  }
100
105
 
101
106
  if (this.nodeType === 1) {
102
- let node = new Element();
107
+ const node = new Element();
103
108
  node.nodeType = this.nodeType;
104
109
  this.nodeName = this.nodeName;
105
110
  if (this.attributes) {
@@ -115,14 +120,14 @@ export class Node implements Node {
115
120
  return node;
116
121
  }
117
122
 
118
- let node = new Node();
123
+ const node = new Node();
119
124
  node.nodeType = this.nodeType;
120
125
  node.nodeName = this.nodeName;
121
126
  return node;
122
127
  }
123
128
 
124
129
  setAttribute(name: string, value: any) {
125
- let attr = {
130
+ const attr = {
126
131
  nodeName: name,
127
132
  nodeValue: value
128
133
  };
@@ -266,8 +271,8 @@ export class Text extends Node {
266
271
 
267
272
  function updateElementStyles(element: Element, state: Record<string, any>) {
268
273
  let str = "";
269
- for (let key in state) {
270
- let value = state[key];
274
+ for (const key in state) {
275
+ const value = state[key];
271
276
  if (typeof value !== "undefined" && value !== null && String(value).length > 0) {
272
277
  str += `${key}: ${state[key]};`;
273
278
  }
@@ -324,11 +329,23 @@ export class Element extends Node {
324
329
  throw new Error("Cannot set style");
325
330
  }
326
331
 
332
+ get className(): string {
333
+ return this.getAttribute("class") || "";
334
+ }
335
+
336
+ set className(value: string | boolean) {
337
+ if (value == null || value === false) {
338
+ this.removeAttribute("class");
339
+ } else {
340
+ this.setAttribute("class", String(value));
341
+ }
342
+ }
343
+
327
344
  classList = {
328
345
  toggle: (item: any, force: any) => {
329
346
  if (item) {
330
- let classes = (this.getAttribute("class") || "").split(" ");
331
- let itemIndex = classes.indexOf(item);
347
+ const classes = (this.className || "").split(" ");
348
+ const itemIndex = classes.indexOf(item);
332
349
  if (force && itemIndex === -1) {
333
350
  classes.push(item);
334
351
  }
@@ -337,16 +354,28 @@ export class Element extends Node {
337
354
  classes.splice(itemIndex, 1);
338
355
  }
339
356
 
340
- let final = classes.join(" ").trim();
357
+ const final = classes.join(" ").trim();
341
358
  if (final.length) {
342
- this.setAttribute("class", classes.join(" ").trim());
359
+ this.className = classes.join(" ").trim();
343
360
  } else {
344
- this.removeAttribute("class");
361
+ this.className = false;
345
362
  }
346
363
  }
347
364
  }
348
365
  };
349
366
 
367
+ get id(): string {
368
+ return this.getAttribute("id") || "";
369
+ }
370
+
371
+ set id(value: string | boolean) {
372
+ if (value == null || value === false) {
373
+ this.removeAttribute("id");
374
+ } else {
375
+ this.setAttribute("id", String(value));
376
+ }
377
+ }
378
+
350
379
  set textContent(text) {
351
380
  this.nodeValue = String(text);
352
381
  this.childNodes = this.nodeValue ? [new Text(this.nodeValue)] : [];
@@ -374,7 +403,7 @@ export class Element extends Node {
374
403
 
375
404
  set innerHTML(html) {
376
405
  this.textContent = "";
377
- let result = htmlToDom(html);
406
+ const result = htmlToDom(html);
378
407
  if (result instanceof DocumentFragment) {
379
408
  for (let i = 0, l = result.childNodes.length; i < l; i++) {
380
409
  this.appendChild(result.childNodes[i]);
@@ -409,13 +438,13 @@ export class Document extends Element {
409
438
  }
410
439
 
411
440
  createElement(type: string) {
412
- let element = new Element();
441
+ const element = new Element();
413
442
  element.nodeName = type.toUpperCase();
414
443
  return element;
415
444
  }
416
445
 
417
446
  createElementNS(ns: string, type: string) {
418
- let element = this.createElement(type);
447
+ const element = this.createElement(type);
419
448
  element.baseURI = ns;
420
449
  return element;
421
450
  }
@@ -425,7 +454,7 @@ export class Document extends Element {
425
454
  }
426
455
  }
427
456
 
428
- let selfClosingTags = [
457
+ const selfClosingTags = [
429
458
  "area",
430
459
  "base",
431
460
  "br",
@@ -449,7 +478,7 @@ export function domToHtml(dom: Element): string {
449
478
  }
450
479
 
451
480
  if (dom.nodeType === 1) {
452
- let name = dom.nodeName.toLowerCase();
481
+ const name = dom.nodeName.toLowerCase();
453
482
  let str = "<" + name;
454
483
  for (let i = 0, l = dom.attributes.length; i < l; i++) {
455
484
  str += " " + dom.attributes[i].nodeName + '="' + dom.attributes[i].nodeValue + '"';
@@ -459,7 +488,7 @@ export function domToHtml(dom: Element): string {
459
488
  str += ">";
460
489
  if (dom.childNodes && dom.childNodes.length > 0) {
461
490
  for (let i = 0, l = dom.childNodes.length; i < l; i++) {
462
- let child = domToHtml(dom.childNodes[i] as Element);
491
+ const child = domToHtml(dom.childNodes[i] as Element);
463
492
  if (child) {
464
493
  str += child;
465
494
  }
@@ -492,9 +521,9 @@ export function domToHyperscript(childNodes: ChildNodes, depth = 1) {
492
521
  let str = `\n${spaces}v("${item.nodeName}", `;
493
522
 
494
523
  if (item.attributes) {
495
- let attrs: Record<string, any> = {};
524
+ const attrs: Record<string, any> = {};
496
525
  for (let i = 0, l = item.attributes.length; i < l; i++) {
497
- let attr = item.attributes[i];
526
+ const attr = item.attributes[i];
498
527
  attrs[attr.nodeName] = attr.nodeValue;
499
528
  }
500
529
  str += JSON.stringify(attrs);
@@ -534,21 +563,21 @@ interface ObjectIndexItemWithContent extends ObjectIndexItem {
534
563
  interface ObjectIndexList extends Array<ObjectIndexItem> {}
535
564
 
536
565
  function findTexts(item: ObjectIndexItemWithContent, html: string) {
537
- let newChildren: ObjectIndexItemWithContent[] = [];
566
+ const newChildren: ObjectIndexItemWithContent[] = [];
538
567
 
539
568
  // If the item has children
540
569
  if (item.children.length) {
541
570
  // Search for texts in the children.
542
571
  for (let i = 0; i < item.children.length; i++) {
543
- let child = item.children[i];
544
- let nextChild = item.children[i + 1];
572
+ const child = item.children[i];
573
+ const nextChild = item.children[i + 1];
545
574
 
546
575
  // If is the first child and the child startsAt is greater than the item contentStartsAt then
547
576
  // the content between the item contentStartsAt and the child startsAt is a text child of the item.
548
577
  if (i === 0 && child.startsAt > item.contentStartsAt) {
549
- let childContent = html.substring(item.contentStartsAt, child.startsAt);
578
+ const childContent = html.substring(item.contentStartsAt, child.startsAt);
550
579
 
551
- let childText: ObjectIndexItemWithContent = {
580
+ const childText: ObjectIndexItemWithContent = {
552
581
  tagName: "#text",
553
582
  startsAt: item.contentStartsAt,
554
583
  endsAt: item.contentStartsAt + childContent.length,
@@ -568,9 +597,9 @@ function findTexts(item: ObjectIndexItemWithContent, html: string) {
568
597
  // If there is a next child and the child endsAt is less than the next child startsAt then
569
598
  // the content between the child endsAt and the next child startsAt is a text child of the item.
570
599
  if (nextChild && child.endsAt < nextChild.startsAt) {
571
- let childContent = html.substring(child.endsAt, nextChild.startsAt);
600
+ const childContent = html.substring(child.endsAt, nextChild.startsAt);
572
601
 
573
- let childText: ObjectIndexItemWithContent = {
602
+ const childText: ObjectIndexItemWithContent = {
574
603
  tagName: "#text",
575
604
  startsAt: child.endsAt,
576
605
  endsAt: child.endsAt + childContent.length,
@@ -587,9 +616,9 @@ function findTexts(item: ObjectIndexItemWithContent, html: string) {
587
616
  // If there are no next child and the child endsAt is less than the item contentEndsAt then
588
617
  // the content between the child endsAt and the item contentEndsAt is a text child of the item.
589
618
  if (!nextChild && child.endsAt < item.contentEndsAt) {
590
- let childContent = html.substring(child.endsAt, item.contentEndsAt);
619
+ const childContent = html.substring(child.endsAt, item.contentEndsAt);
591
620
 
592
- let childText: ObjectIndexItemWithContent = {
621
+ const childText: ObjectIndexItemWithContent = {
593
622
  tagName: "#text",
594
623
  startsAt: child.endsAt,
595
624
  endsAt: child.endsAt + childContent.length,
@@ -611,10 +640,10 @@ function findTexts(item: ObjectIndexItemWithContent, html: string) {
611
640
  // If the item has no children then set the contents between the item contentStartsAt and the item contentEndsAt
612
641
  // as a text child of the item.
613
642
  if (!item.children.length) {
614
- let childContent = html.substring(item.contentStartsAt, item.contentEndsAt);
643
+ const childContent = html.substring(item.contentStartsAt, item.contentEndsAt);
615
644
 
616
645
  if (childContent.length) {
617
- let childText: ObjectIndexItemWithContent = {
646
+ const childText: ObjectIndexItemWithContent = {
618
647
  tagName: "#text",
619
648
  startsAt: item.contentStartsAt,
620
649
  endsAt: item.contentEndsAt,
@@ -642,12 +671,12 @@ function convertToDom<T extends Node>(item: ObjectIndexItemWithContent): T {
642
671
  ? document.createDocumentFragment()
643
672
  : document.createElement(item.tagName)) as unknown as T;
644
673
 
645
- for (let key in item.attributes) {
674
+ for (const key in item.attributes) {
646
675
  node.setAttribute(key, item.attributes[key]);
647
676
  }
648
677
 
649
678
  for (let i = 0; i < item.children.length; i++) {
650
- let child = convertToDom(item.children[i]);
679
+ const child = convertToDom(item.children[i]);
651
680
  node.appendChild(child);
652
681
  }
653
682
  }
@@ -658,23 +687,23 @@ function convertToDom<T extends Node>(item: ObjectIndexItemWithContent): T {
658
687
  // eslint-disable-next-line sonarjs/cognitive-complexity
659
688
  function getObjectIndexTree(html: string): DocumentFragment {
660
689
  let item;
661
- let regex = RegExp("<([^>|^!]+)>", "g");
662
- let items: ObjectIndexList = [];
690
+ const regex = RegExp("<([^>|^!]+)>", "g");
691
+ const items: ObjectIndexList = [];
663
692
 
664
693
  // Make the initial list of items.
665
694
  while ((item = regex.exec(html))) {
666
695
  // If is a closing tag
667
696
  if (item[0].startsWith("</")) {
668
- let lastOpenedItem = [...items].reverse().find((item) => item.endsAt === null);
697
+ const lastOpenedItem = [...items].reverse().find((item) => item.endsAt === null);
669
698
  if (lastOpenedItem) {
670
699
  lastOpenedItem.endsAt = item.index + item[0].length;
671
700
  lastOpenedItem.contentEndsAt = item.index;
672
701
 
673
702
  // Find the last opened item again, this will be the parent of the current item.
674
- let parent = [...items].reverse().find((item) => item.endsAt === null);
703
+ const parent = [...items].reverse().find((item) => item.endsAt === null);
675
704
  if (parent) {
676
705
  // Find the index of the current item in the items array.
677
- let index = items.indexOf(lastOpenedItem);
706
+ const index = items.indexOf(lastOpenedItem);
678
707
  // Remove the last opened item from the items array.
679
708
  items.splice(index, 1);
680
709
 
@@ -687,7 +716,7 @@ function getObjectIndexTree(html: string): DocumentFragment {
687
716
  }
688
717
 
689
718
  // If is an opening tag
690
- let element: ObjectIndexItem = {
719
+ const element: ObjectIndexItem = {
691
720
  tagName: item[1].split(" ")[0],
692
721
  startsAt: item.index,
693
722
  endsAt: null,
@@ -700,10 +729,10 @@ function getObjectIndexTree(html: string): DocumentFragment {
700
729
 
701
730
  // Find the attributes of the tag.
702
731
  let string = (item[1] || "").substring(element.tagName.length + 1).replace(/\/$/g, "");
703
- let attributesWithValues = string.match(/\S+="[^"]+"/g);
732
+ const attributesWithValues = string.match(/\S+="[^"]+"/g);
704
733
 
705
734
  if (attributesWithValues) {
706
- for (let attribute of attributesWithValues) {
735
+ for (const attribute of attributesWithValues) {
707
736
  const [name, ...value] = attribute.trim().split("=");
708
737
  string = string.replace(attribute, "");
709
738
  if (value) {
@@ -712,9 +741,9 @@ function getObjectIndexTree(html: string): DocumentFragment {
712
741
  }
713
742
  }
714
743
 
715
- let attributesWithBooleanValues = string.match(/\s\S+=[^"]+/g);
744
+ const attributesWithBooleanValues = string.match(/\s\S+=[^"]+/g);
716
745
  if (attributesWithBooleanValues) {
717
- for (let attribute of attributesWithBooleanValues) {
746
+ for (const attribute of attributesWithBooleanValues) {
718
747
  const [name, ...value] = attribute.trim().split("=");
719
748
  string = string.replace(attribute, "");
720
749
  if (value) {
@@ -723,9 +752,9 @@ function getObjectIndexTree(html: string): DocumentFragment {
723
752
  }
724
753
  }
725
754
 
726
- let attributesWithEmptyValues = string.match(/\s?\S+/g);
755
+ const attributesWithEmptyValues = string.match(/\s?\S+/g);
727
756
  if (attributesWithEmptyValues) {
728
- for (let attribute of attributesWithEmptyValues) {
757
+ for (const attribute of attributesWithEmptyValues) {
729
758
  const name = attribute.trim();
730
759
  element.attributes[name] = true;
731
760
  }
@@ -737,7 +766,7 @@ function getObjectIndexTree(html: string): DocumentFragment {
737
766
  element.contentStartsAt = element.contentEndsAt = element.endsAt;
738
767
 
739
768
  // Find the last opened item, this will be the parent of the current item.
740
- let parent = [...items].reverse().find((item) => item.endsAt === null);
769
+ const parent = [...items].reverse().find((item) => item.endsAt === null);
741
770
  if (parent) {
742
771
  // Add the last opened item as a child of the parent.
743
772
  parent.children.push(element);
@@ -748,7 +777,7 @@ function getObjectIndexTree(html: string): DocumentFragment {
748
777
  items.push(element);
749
778
  }
750
779
 
751
- let fragmentItem: ObjectIndexItemWithContent = {
780
+ const fragmentItem: ObjectIndexItemWithContent = {
752
781
  tagName: "#document-fragment",
753
782
  startsAt: 0,
754
783
  endsAt: html.length,
@@ -777,16 +806,16 @@ export function htmlToDom(html: string): Element | Text | DocumentFragment {
777
806
  // search for the first opening tag.
778
807
  const openingTag = html.match(/<[^>]+>/g);
779
808
 
780
- let document = new Document();
809
+ const document = new Document();
781
810
 
782
811
  // If the opening tag is not found, return a document fragment node with the html string as text content.
783
812
  if (!openingTag) {
784
- let documentFragment = document.createDocumentFragment();
813
+ const documentFragment = document.createDocumentFragment();
785
814
  documentFragment.appendChild(document.createTextNode(html));
786
815
  return documentFragment;
787
816
  }
788
817
 
789
- let fragment = getObjectIndexTree(html);
818
+ const fragment = getObjectIndexTree(html);
790
819
 
791
820
  if (fragment.childNodes.length > 1) {
792
821
  return fragment;
@@ -796,8 +825,8 @@ export function htmlToDom(html: string): Element | Text | DocumentFragment {
796
825
  }
797
826
 
798
827
  export function htmlToHyperscript(html: string) {
799
- let domTree = htmlToDom(html);
800
- let hyperscript = domToHyperscript(domTree instanceof DocumentFragment ? domTree.childNodes : [domTree]);
828
+ const domTree = htmlToDom(html);
829
+ const hyperscript = domToHyperscript(domTree instanceof DocumentFragment ? domTree.childNodes : [domTree]);
801
830
  return `[${hyperscript}\n]`;
802
831
  }
803
832
 
@@ -65,8 +65,8 @@ function makeUnsubscribe(
65
65
  function createSubscription(signal: ProxySignal, subscriptions: Subscriptions, handler: Subscription) {
66
66
  if (subscriptions.has(handler) === false) {
67
67
  // eslint-disable-next-line no-use-before-define
68
- let computed = ProxySignal(() => handler(signal.value));
69
- let cleanup = computed(); // Execute to register itself
68
+ const computed = ProxySignal(() => handler(signal.value));
69
+ const cleanup = computed(); // Execute to register itself
70
70
  makeUnsubscribe(subscriptions, computed, handler, cleanup);
71
71
  subscriptions.set(handler, computed);
72
72
  }
@@ -82,12 +82,12 @@ function delayedUpdate() {
82
82
 
83
83
  // eslint-disable-next-line sonarjs/cognitive-complexity
84
84
  export function ProxySignal(value: any): ProxySignal {
85
- let subscriptions = new Map();
86
- let getters: Getters = {};
85
+ const subscriptions = new Map();
86
+ const getters: Getters = {};
87
87
 
88
88
  let forceUpdate = false;
89
89
 
90
- let signal: ProxySignal = new Proxy(
90
+ const signal: ProxySignal = new Proxy(
91
91
  // eslint-disable-next-line no-unused-vars
92
92
  function (valOrPath?: any | Subscription, handler?: (valueAtPathPosition: any) => any) {
93
93
  // Works as a getter
@@ -102,7 +102,7 @@ export function ProxySignal(value: any): ProxySignal {
102
102
 
103
103
  // Works as a setter with a path
104
104
  if (typeof valOrPath === "string" && typeof handler !== "undefined") {
105
- let parsed = valOrPath.split(".");
105
+ const parsed = valOrPath.split(".");
106
106
  let result = signal.value;
107
107
  let next;
108
108
  while (parsed.length) {
@@ -128,13 +128,13 @@ export function ProxySignal(value: any): ProxySignal {
128
128
  {
129
129
  set(state, prop, val) {
130
130
  if (prop === "value" || prop === "unsubscribe" || prop === "cleanup") {
131
- let old = state[prop];
131
+ const old = state[prop];
132
132
  state[prop] = val;
133
133
  if (prop === "value" && (forceUpdate || val !== old)) {
134
134
  forceUpdate = false;
135
- for (let [handler, computed] of subscriptions) {
135
+ for (const [handler, computed] of subscriptions) {
136
136
  computed.cleanup();
137
- let cleanup = handler(val);
137
+ const cleanup = handler(val);
138
138
  makeUnsubscribe(subscriptions, computed, handler, cleanup);
139
139
  }
140
140
  delayedUpdate();
@@ -164,7 +164,7 @@ export function ProxySignal(value: any): ProxySignal {
164
164
  cleanup: {
165
165
  value() {
166
166
  // eslint-disable-next-line no-unused-vars
167
- for (let [handler, computed] of subscriptions) {
167
+ for (const [handler, computed] of subscriptions) {
168
168
  computed.unsubscribe();
169
169
  }
170
170
  },