@thyn/core 0.0.344 → 0.0.347

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 (105) hide show
  1. package/.github/workflows/static.yml +48 -0
  2. package/.github/workflows/test.yml +39 -0
  3. package/LICENSE +21 -0
  4. package/README.md +50 -0
  5. package/dist/{element.js → core/element.js} +14 -36
  6. package/dist/core/index.d.ts +1 -0
  7. package/dist/core/index.js +1 -0
  8. package/dist/{router.d.ts → core/router.d.ts} +1 -1
  9. package/dist/{router.js → core/router.js} +22 -5
  10. package/dist/index.d.ts +5 -2
  11. package/dist/index.js +5 -2
  12. package/dist/plugin/html-parser.d.ts +31 -0
  13. package/dist/plugin/html-parser.js +275 -0
  14. package/dist/plugin/index.d.ts +24 -0
  15. package/dist/plugin/index.js +1009 -0
  16. package/dist/plugin/utils.d.ts +12 -0
  17. package/dist/plugin/utils.js +194 -0
  18. package/docs/CNAME +1 -0
  19. package/docs/index.html +18 -0
  20. package/docs/package-lock.json +980 -0
  21. package/docs/package.json +15 -0
  22. package/docs/public/thyn.png +0 -0
  23. package/docs/public/thyn.svg +1 -0
  24. package/docs/src/App.thyn +10 -0
  25. package/docs/src/components/Button.thyn +3 -0
  26. package/docs/src/docs/GettingStarted.thyn +8 -0
  27. package/docs/src/main.css +17 -0
  28. package/docs/src/main.js +5 -0
  29. package/docs/src/pages/Home.thyn +147 -0
  30. package/docs/vite.config.js +7 -0
  31. package/package.json +18 -10
  32. package/src/{element.ts → core/element.ts} +14 -34
  33. package/src/core/index.ts +1 -0
  34. package/src/{router.ts → core/router.ts} +22 -6
  35. package/src/{signals.ts → core/signals.ts} +1 -1
  36. package/src/index.ts +5 -15
  37. package/src/plugin/html-parser.ts +332 -0
  38. package/src/plugin/index.ts +1127 -0
  39. package/src/plugin/utils.ts +213 -0
  40. package/tests/Bind.test.ts +14 -0
  41. package/tests/Bind.thyn +7 -0
  42. package/tests/ConsecInterps.test.ts +9 -0
  43. package/tests/ConsecInterps.thyn +9 -0
  44. package/tests/Counter.test.ts +12 -0
  45. package/tests/Counter.thyn +7 -0
  46. package/tests/DoubleQuotes.test.ts +9 -0
  47. package/tests/DoubleQuotes.thyn +3 -0
  48. package/tests/Escape.test.ts +9 -0
  49. package/tests/Escape.thyn +3 -0
  50. package/tests/EscapeDollar.test.ts +9 -0
  51. package/tests/EscapeDollar.thyn +5 -0
  52. package/tests/EventPipes.test.ts +13 -0
  53. package/tests/EventPipes.thyn +11 -0
  54. package/tests/List.test.ts +21 -0
  55. package/tests/List.thyn +15 -0
  56. package/tests/ListV2.test.ts +20 -0
  57. package/tests/ListV2.thyn +16 -0
  58. package/tests/MixElemAndText.test.ts +9 -0
  59. package/tests/MixElemAndText.thyn +12 -0
  60. package/tests/Show.test.ts +13 -0
  61. package/tests/Show.thyn +8 -0
  62. package/tests/Template.test.ts +9 -0
  63. package/tests/Template.thyn +8 -0
  64. package/tests/list/comprehensive.test.ts +659 -0
  65. package/tests/list/operations/ChildrenAppend.thyn +11 -0
  66. package/tests/list/operations/ChildrenFilter.thyn +11 -0
  67. package/tests/list/operations/ChildrenInsert.thyn +11 -0
  68. package/tests/list/operations/ChildrenNoneToSome.thyn +11 -0
  69. package/tests/list/operations/ChildrenPrepend.thyn +11 -0
  70. package/tests/list/operations/ChildrenRemove.thyn +11 -0
  71. package/tests/list/operations/ChildrenReplaceAll.thyn +11 -0
  72. package/tests/list/operations/ChildrenSomeToNone.thyn +11 -0
  73. package/tests/list/operations/ChildrenSort.thyn +11 -0
  74. package/tests/list/operations/IsolatedAppend.thyn +10 -0
  75. package/tests/list/operations/IsolatedFilter.thyn +16 -0
  76. package/tests/list/operations/IsolatedInsert.thyn +10 -0
  77. package/tests/list/operations/IsolatedMove.thyn +16 -0
  78. package/tests/list/operations/IsolatedNoneToSome.thyn +16 -0
  79. package/tests/list/operations/IsolatedPrepend.thyn +10 -0
  80. package/tests/list/operations/IsolatedRemove.thyn +17 -0
  81. package/tests/list/operations/IsolatedReplaceAll.thyn +10 -0
  82. package/tests/list/operations/IsolatedSomeToNone.thyn +10 -0
  83. package/tests/list/operations/IsolatedSort.thyn +16 -0
  84. package/tests/list/operations/TerminalAppend.thyn +12 -0
  85. package/tests/list/operations/TerminalFilter.thyn +12 -0
  86. package/tests/list/operations/TerminalInsert.thyn +12 -0
  87. package/tests/list/operations/TerminalNoneToSome.thyn +12 -0
  88. package/tests/list/operations/TerminalPrepend.thyn +12 -0
  89. package/tests/list/operations/TerminalRemove.thyn +12 -0
  90. package/tests/list/operations/TerminalReplaceAll.thyn +12 -0
  91. package/tests/list/operations/TerminalSomeToNone.thyn +12 -0
  92. package/tests/list/operations/TerminalSort.thyn +12 -0
  93. package/tests/tsconfig.json +14 -0
  94. package/tsconfig.json +11 -6
  95. package/types/thyn.d.ts +4 -0
  96. package/vitest.config.ts +7 -2
  97. package/tests/fx.test.ts +0 -31
  98. package/tests/lists.test.ts +0 -184
  99. package/tests/router.test.ts +0 -69
  100. package/tests/show.test.ts +0 -66
  101. package/tests/utils.ts +0 -3
  102. package/tsconfig.tsbuildinfo +0 -1
  103. /package/dist/{element.d.ts → core/element.d.ts} +0 -0
  104. /package/dist/{signals.d.ts → core/signals.d.ts} +0 -0
  105. /package/dist/{signals.js → core/signals.js} +0 -0
@@ -0,0 +1,11 @@
1
+ <script>
2
+ // List with component children - Test: prepend
3
+ const items = $signal([3]);
4
+ </script>
5
+
6
+ <div onclick={() => items([1, 2, 3])}>
7
+ <p #for={item in items()} data-id={item}>
8
+ <span #if={item % 2 === 0}>even: {{ item }}</span>
9
+ <span #else>odd: {{ item }}</span>
10
+ </p>
11
+ </div>
@@ -0,0 +1,11 @@
1
+ <script>
2
+ // List with component children - Test: remove
3
+ const items = $signal([1, 2, 3, 4]);
4
+ </script>
5
+
6
+ <div onclick={() => items([1, 3])}>
7
+ <p #for={item in items()} data-id={item}>
8
+ <span #if={item % 2 === 0}>even: {{ item }}</span>
9
+ <span #else>odd: {{ item }}</span>
10
+ </p>
11
+ </div>
@@ -0,0 +1,11 @@
1
+ <script>
2
+ // List with component children - Test: replace all
3
+ const items = $signal([1, 2]);
4
+ </script>
5
+
6
+ <div onclick={() => items([5, 6, 7])}>
7
+ <p #for={item in items()} data-id={item}>
8
+ <span #if={item % 2 === 0}>even: {{ item }}</span>
9
+ <span #else>odd: {{ item }}</span>
10
+ </p>
11
+ </div>
@@ -0,0 +1,11 @@
1
+ <script>
2
+ // List with component children - Test: some → none
3
+ const items = $signal([1, 2, 3]);
4
+ </script>
5
+
6
+ <div onclick={() => items([])}>
7
+ <p #for={item in items()} data-id={item}>
8
+ <span #if={item % 2 === 0}>even: {{ item }}</span>
9
+ <span #else>odd: {{ item }}</span>
10
+ </p>
11
+ </div>
@@ -0,0 +1,11 @@
1
+ <script>
2
+ // List with component children - Test: sort
3
+ const items = $signal([4, 2, 3, 1]);
4
+ </script>
5
+
6
+ <div onclick={() => items([1, 2, 3, 4])}>
7
+ <p #for={item in items()} data-id={item}>
8
+ <span #if={item % 2 === 0}>even: {{ item }}</span>
9
+ <span #else>odd: {{ item }}</span>
10
+ </p>
11
+ </div>
@@ -0,0 +1,10 @@
1
+ <script>
2
+ // Test: append items
3
+ const items = $signal([1, 2]);
4
+ </script>
5
+
6
+ <div onclick={() => items([1, 2, 3, 4])}>
7
+ <span #for={item in items()} data-id={item}>
8
+ {{ item }}
9
+ </span>
10
+ </div>
@@ -0,0 +1,16 @@
1
+ <script>
2
+ // Test: filter items
3
+ const items = $signal([1, 2, 3, 4, 5, 6]);
4
+ let clickCount = 0;
5
+ </script>
6
+
7
+ <div onclick={() => {
8
+ clickCount++;
9
+ if (clickCount === 1) items([2, 4, 6]); // Even only
10
+ else if (clickCount === 2) items([1, 3, 5]); // Odd only
11
+ else items([10, 15, 20]); // Greater than 5
12
+ }}>
13
+ <span #for={item in items()} data-id={item}>
14
+ {{ item }}
15
+ </span>
16
+ </div>
@@ -0,0 +1,10 @@
1
+ <script>
2
+ // Test: insert items in middle
3
+ const items = $signal([1, 4]);
4
+ </script>
5
+
6
+ <div onclick={() => items([1, 2, 3, 4])}>
7
+ <span #for={item in items()} data-id={item}>
8
+ {{ item }}
9
+ </span>
10
+ </div>
@@ -0,0 +1,16 @@
1
+ <script>
2
+ // Test: move/reorder items
3
+ const items = $signal([1, 2, 3, 4]);
4
+ let clickCount = 0;
5
+ </script>
6
+
7
+ <div onclick={() => {
8
+ clickCount++;
9
+ if (clickCount === 1) items([4, 1, 2, 3]); // Move 4 to front
10
+ else if (clickCount === 2) items([1, 3, 2, 4]); // Swap 2 and 3
11
+ else items([4, 3, 2, 1]); // Reverse
12
+ }}>
13
+ <span #for={item in items()} data-id={item}>
14
+ {{ item }}
15
+ </span>
16
+ </div>
@@ -0,0 +1,16 @@
1
+ <script>
2
+ // Test: none → some (add items to empty list)
3
+ const items = $signal([]);
4
+ let clickCount = 0;
5
+ </script>
6
+
7
+ <div onclick={() => {
8
+ clickCount++;
9
+ if (clickCount === 1) items([1]);
10
+ else if (clickCount === 2) items([1, 2, 3]);
11
+ else items([]);
12
+ }}>
13
+ <span #for={item in items()} data-id={item}>
14
+ {{ item }}
15
+ </span>
16
+ </div>
@@ -0,0 +1,10 @@
1
+ <script>
2
+ // Test: prepend items
3
+ const items = $signal([3, 4]);
4
+ </script>
5
+
6
+ <div onclick={() => items([1, 2, 3, 4])}>
7
+ <span #for={item in items()} data-id={item}>
8
+ {{ item }}
9
+ </span>
10
+ </div>
@@ -0,0 +1,17 @@
1
+ <script>
2
+ // Test: remove items from various positions
3
+ const items = $signal([1, 2, 3, 4]);
4
+ let clickCount = 0;
5
+ </script>
6
+
7
+ <div onclick={() => {
8
+ clickCount++;
9
+ if (clickCount === 1) items([1, 2]); // Remove from end
10
+ else if (clickCount === 2) items([3, 4]); // Remove from beginning
11
+ else if (clickCount === 3) items([1, 4]); // Remove from middle
12
+ else items([]);
13
+ }}>
14
+ <span #for={item in items()} data-id={item}>
15
+ {{ item }}
16
+ </span>
17
+ </div>
@@ -0,0 +1,10 @@
1
+ <script>
2
+ // Test: replace all items
3
+ const items = $signal([1, 2, 3]);
4
+ </script>
5
+
6
+ <div onclick={() => items([4, 5, 6])}>
7
+ <span #for={item in items()} data-id={item}>
8
+ {{ item }}
9
+ </span>
10
+ </div>
@@ -0,0 +1,10 @@
1
+ <script>
2
+ // Test: some → none (clear all items)
3
+ const items = $signal([1, 2, 3]);
4
+ </script>
5
+
6
+ <div onclick={() => items([])}>
7
+ <span #for={item in items()} data-id={item}>
8
+ {{ item }}
9
+ </span>
10
+ </div>
@@ -0,0 +1,16 @@
1
+ <script>
2
+ // Test: sort items
3
+ const items = $signal([3, 1, 4, 5]);
4
+ let clickCount = 0;
5
+ </script>
6
+
7
+ <div onclick={() => {
8
+ clickCount++;
9
+ if (clickCount === 1) items([1, 3, 4, 5]); // Ascending
10
+ else if (clickCount === 2) items([5, 4, 3, 1]); // Descending
11
+ else items([5, 4, 3, 2, 1]); // Reverse
12
+ }}>
13
+ <span #for={item in items()} data-id={item}>
14
+ {{ item }}
15
+ </span>
16
+ </div>
@@ -0,0 +1,12 @@
1
+ <script>
2
+ // Terminal list with siblings - Test: append
3
+ const items = $signal([1, 2]);
4
+ </script>
5
+
6
+ <div onclick={() => items([1, 2, 3, 4])}>
7
+ <span class="before">start</span>
8
+ <span #for={item in items()} data-id={item}>
9
+ {{ item }}
10
+ </span>
11
+ <span class="after">end</span>
12
+ </div>
@@ -0,0 +1,12 @@
1
+ <script>
2
+ // Terminal list with siblings - Test: filter
3
+ const items = $signal([1, 2, 3, 4, 5, 6]);
4
+ </script>
5
+
6
+ <div onclick={() => items([2, 4, 6])}>
7
+ <span class="before">start</span>
8
+ <span #for={item in items()} data-id={item}>
9
+ {{ item }}
10
+ </span>
11
+ <span class="after">end</span>
12
+ </div>
@@ -0,0 +1,12 @@
1
+ <script>
2
+ // Terminal list with siblings - Test: insert
3
+ const items = $signal([1, 4]);
4
+ </script>
5
+
6
+ <div onclick={() => items([1, 2, 3, 4])}>
7
+ <span class="before">start</span>
8
+ <span #for={item in items()} data-id={item}>
9
+ {{ item }}
10
+ </span>
11
+ <span class="after">end</span>
12
+ </div>
@@ -0,0 +1,12 @@
1
+ <script>
2
+ // Terminal list with siblings - Test: none → some
3
+ const items = $signal([]);
4
+ </script>
5
+
6
+ <div>
7
+ <span class="before">start</span>
8
+ <span #for={item in items()} data-id={item} onclick={() => items([1, 2, 3])}>
9
+ {{ item }}
10
+ </span>
11
+ <span class="after">end</span>
12
+ </div>
@@ -0,0 +1,12 @@
1
+ <script>
2
+ // Terminal list with siblings - Test: prepend
3
+ const items = $signal([3, 4]);
4
+ </script>
5
+
6
+ <div onclick={() => items([1, 2, 3, 4])}>
7
+ <span class="before">start</span>
8
+ <span #for={item in items()} data-id={item}>
9
+ {{ item }}
10
+ </span>
11
+ <span class="after">end</span>
12
+ </div>
@@ -0,0 +1,12 @@
1
+ <script>
2
+ // Terminal list with siblings - Test: remove
3
+ const items = $signal([1, 2, 3, 4]);
4
+ </script>
5
+
6
+ <div onclick={() => items([1, 2])}>
7
+ <span class="before">start</span>
8
+ <span #for={item in items()} data-id={item}>
9
+ {{ item }}
10
+ </span>
11
+ <span class="after">end</span>
12
+ </div>
@@ -0,0 +1,12 @@
1
+ <script>
2
+ // Terminal list with siblings - Test: replace all
3
+ const items = $signal([1, 2]);
4
+ </script>
5
+
6
+ <div onclick={() => items([7, 8, 9])}>
7
+ <span class="before">start</span>
8
+ <span #for={item in items()} data-id={item}>
9
+ {{ item }}
10
+ </span>
11
+ <span class="after">end</span>
12
+ </div>
@@ -0,0 +1,12 @@
1
+ <script>
2
+ // Terminal list with siblings - Test: some → none
3
+ const items = $signal([1, 2, 3]);
4
+ </script>
5
+
6
+ <div onclick={() => items([])}>
7
+ <span class="before">start</span>
8
+ <span #for={item in items()} data-id={item}>
9
+ {{ item }}
10
+ </span>
11
+ <span class="after">end</span>
12
+ </div>
@@ -0,0 +1,12 @@
1
+ <script>
2
+ // Terminal list with siblings - Test: sort
3
+ const items = $signal([3, 1, 2]);
4
+ </script>
5
+
6
+ <div onclick={() => items([1, 2, 3])}>
7
+ <span class="before">start</span>
8
+ <span #for={item in items()} data-id={item}>
9
+ {{ item }}
10
+ </span>
11
+ <span class="after">end</span>
12
+ </div>
@@ -0,0 +1,14 @@
1
+ {
2
+ "extends": "../tsconfig.json",
3
+ "compilerOptions": {
4
+ "rootDir": ".",
5
+ "noEmit": true
6
+ },
7
+ "include": [
8
+ "./**/*",
9
+ "../types/**/*"
10
+ ],
11
+ "exclude": [
12
+ "node_modules"
13
+ ]
14
+ }
package/tsconfig.json CHANGED
@@ -1,8 +1,5 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "composite": true,
4
- "allowJs": true,
5
- "checkJs": false,
6
3
  "module": "ESNext",
7
4
  "target": "ES2020",
8
5
  "moduleResolution": "node",
@@ -10,9 +7,17 @@
10
7
  "skipLibCheck": true,
11
8
  "isolatedModules": true,
12
9
  "outDir": "dist",
13
- "rootDir": "src"
10
+ "rootDir": "src",
11
+ "declaration": true,
12
+ "strict": false
14
13
  },
15
14
  "include": [
16
- "src/**/*"
15
+ "src/**/*",
16
+ "types/**/*"
17
+ ],
18
+ "exclude": [
19
+ "node_modules",
20
+ "dist",
21
+ "tests"
17
22
  ]
18
- }
23
+ }
@@ -0,0 +1,4 @@
1
+ declare module "*.thyn" {
2
+ const component: () => HTMLElement;
3
+ export default component;
4
+ }
package/vitest.config.ts CHANGED
@@ -1,10 +1,15 @@
1
+ import { resolve } from "path";
1
2
  import { defineConfig } from "vitest/config";
3
+ import thyn from "./src/plugin/index.js";
2
4
 
3
5
  export default defineConfig({
6
+ plugins: [thyn()],
4
7
  test: {
5
- environment: 'jsdom',
6
- globals: true,
8
+ environment: 'happy-dom',
7
9
  include: ['tests/**/*.test.ts'],
8
10
  exclude: ['**/node_modules/**', 'dist/**'],
11
+ alias: {
12
+ '@thyn/core': resolve(__dirname, './src'),
13
+ },
9
14
  },
10
15
  });
package/tests/fx.test.ts DELETED
@@ -1,31 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { $effect, $signal } from "../src";
3
- import { wait } from "./utils";
4
-
5
- describe("runs effect", () => {
6
- it("if else", async () => {
7
- const on = $signal(true);
8
- const runRef = { val: 0 };
9
- const tdRef = { val: 0 };
10
- const root = (() => {
11
- const div = document.createElement("div");
12
- $effect(() => { div.textContent = on() ? "on" : "off" });
13
- $effect(() => {
14
- on();
15
- runRef.val++;
16
- return () => {
17
- tdRef.val++;
18
- };
19
- });
20
- return div;
21
- })();
22
- expect(root.textContent).toBe("on");
23
- expect(runRef.val).toBe(1);
24
- expect(tdRef.val).toBe(0);
25
- on(false);
26
- await wait();
27
- expect(root.textContent).toBe("off");
28
- expect(runRef.val).toBe(2);
29
- expect(tdRef.val).toBe(1);
30
- });
31
- });
@@ -1,184 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { $signal, isolatedTerminalList, list } from "../src";
3
- import { wait } from "./utils";
4
-
5
- function makeGenericList(signal: any) {
6
- return list({
7
- items: () => signal(),
8
- render: (item: number) => {
9
- const span = document.createElement("span");
10
- span.textContent = `${item}`;
11
- return span;
12
- },
13
- });
14
- }
15
-
16
- function makeIsolatedTerminalList(signal: any) {
17
- return isolatedTerminalList({
18
- items: () => signal(),
19
- render: (item: number) => {
20
- const span = document.createElement("span");
21
- span.textContent = `${item}`;
22
- return span;
23
- },
24
- });
25
- }
26
-
27
- const run = (makeList: any) => describe("list", () => {
28
- it("renders", async () => {
29
- const items = $signal([0, 1, 2]);
30
- const root = makeList(items);
31
- expect(root.textContent).toBe("012");
32
- });
33
-
34
- it("removes all", async () => {
35
- const items = $signal([0, 1]);
36
- const root = makeList(items);
37
- items([]);
38
- await wait();
39
- expect(root.textContent).toBe("");
40
- });
41
-
42
- if (makeList === makeGenericList) {
43
- it("removes all when offset 1", async () => {
44
- const items = $signal([0, 1, 2, 3]);
45
- const root = document.createElement("div");
46
- const a = document.createElement("span");
47
- a.textContent = "a";
48
- const b = document.createElement("span");
49
- b.textContent = "b";
50
- const div = makeList(items);
51
- root.append(a, div, b);
52
- expect(root.textContent).toBe("a0123b");
53
- items([]);
54
- await wait();
55
- expect(root.textContent).toBe("ab");
56
- });
57
-
58
- it("removes all when offset 2", async () => {
59
- const items = $signal([0, 1, 2, 3]);
60
- const root = document.createElement("div");
61
- const a = document.createElement("span");
62
- a.textContent = "a";
63
- const b = document.createElement("span");
64
- b.textContent = "b";
65
- const c = document.createElement("span");
66
- c.textContent = "c";
67
- const d = document.createElement("span");
68
- d.textContent = "d";
69
- const div = makeList(items);
70
- root.append(a, b, div, c, d);
71
- expect(root.textContent).toBe("ab0123cd");
72
- items([]);
73
- await wait();
74
- expect(root.textContent).toBe("abcd");
75
- });
76
- }
77
-
78
- it("stays the same", async () => {
79
- const items = $signal([0, 1]);
80
- const root = makeList(items);
81
- items([0, 1]);
82
- await wait();
83
- expect(root.textContent).toBe("01");
84
- });
85
-
86
- it("reverses 2", async () => {
87
- const items = $signal([0, 1]);
88
- const root = makeList(items);
89
- items([1, 0]);
90
- await wait();
91
- expect(root.textContent).toBe("10");
92
- });
93
-
94
- it("reverses 3", async () => {
95
- const items = $signal([0, 1, 2]);
96
- const root = makeList(items);
97
- items([2, 1, 0]);
98
- await wait();
99
- expect(root.textContent).toBe("210");
100
- });
101
-
102
- it("reverses 4", async () => {
103
- const items = $signal([0, 1, 2, 3]);
104
- const root = makeList(items);
105
- items([3, 2, 1, 0]);
106
- await wait();
107
- expect(root.textContent).toBe("3210");
108
- });
109
-
110
- it("removes from start", async () => {
111
- const items = $signal([0, 1, 2]);
112
- const root = makeList(items);
113
- items([1, 2]);
114
- await wait();
115
- expect(root.textContent).toBe("12");
116
- });
117
-
118
- it("removes from end", async () => {
119
- const items = $signal([0, 1, 2]);
120
- const root = makeList(items);
121
- items([0, 1]);
122
- await wait();
123
- expect(root.textContent).toBe("01");
124
- });
125
-
126
- it("removes from middle", async () => {
127
- const items = $signal([0, 1, 2]);
128
- const root = makeList(items);
129
- items([0, 2]);
130
- await wait();
131
- expect(root.textContent).toBe("02");
132
- });
133
-
134
- it("removes from everywhere", async () => {
135
- const items = $signal([0, 1, 2, 3, 4, 5, 6]);
136
- const root = makeList(items);
137
- items([1, 3, 5]);
138
- await wait();
139
- expect(root.textContent).toBe("135");
140
- });
141
-
142
- it("adds to start", async () => {
143
- const items = $signal([1, 2]);
144
- const root = makeList(items);
145
- items([0, 1, 2]);
146
- await wait();
147
- expect(root.textContent).toBe("012");
148
- });
149
-
150
- it("adds to end", async () => {
151
- const items = $signal([0, 1]);
152
- const root = makeList(items);
153
- items([0, 1, 2]);
154
- await wait();
155
- expect(root.textContent).toBe("012");
156
- });
157
-
158
- it("adds to middle", async () => {
159
- const items = $signal([0, 2]);
160
- const root = makeList(items);
161
- items([0, 1, 2]);
162
- await wait();
163
- expect(root.textContent).toBe("012");
164
- });
165
-
166
- it("replaces all", async () => {
167
- const items = $signal([0, 1]);
168
- const root = makeList(items);
169
- items([2, 3]);
170
- await wait();
171
- expect(root.textContent).toBe("23");
172
- });
173
-
174
- it("sorts", async () => {
175
- const items = $signal([6, 0, 2, 4, 7, 1, 3, 5]);
176
- const root = makeList(items);
177
- items([0, 1, 2, 3, 4, 5, 6, 7]);
178
- await wait();
179
- expect(root.textContent).toBe("01234567");
180
- });
181
- });
182
-
183
- run(makeGenericList);
184
- run(makeIsolatedTerminalList);