@krate/runtime 0.5.0-rc.1 → 0.5.0-rc.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.
Files changed (153) hide show
  1. package/dist/actions.d.ts +7 -0
  2. package/dist/actions.js +23 -8
  3. package/dist/actions.test.js +8 -410
  4. package/dist/after.d.ts +28 -0
  5. package/dist/after.js +48 -0
  6. package/dist/after.test.js +58 -0
  7. package/dist/assets-static.d.ts +10 -1
  8. package/dist/assets-static.js +10 -2
  9. package/dist/base-path.d.ts +7 -0
  10. package/dist/base-path.js +20 -0
  11. package/dist/builtin-tags.d.ts +12 -0
  12. package/dist/builtin-tags.js +42 -0
  13. package/dist/builtin-tags.test.js +12 -0
  14. package/dist/cache-adapter.test.js +4 -203
  15. package/dist/cache-scope.d.ts +2 -0
  16. package/dist/cache.test.js +1 -197
  17. package/dist/cloudflare-workers.d.ts +2 -0
  18. package/dist/cloudflare-workers.js +27 -0
  19. package/dist/dev-overlay.d.ts +54 -3
  20. package/dist/dev-overlay.js +469 -76
  21. package/dist/dom.js +17 -2
  22. package/dist/events.test.js +2 -407
  23. package/dist/handler-html.test.js +1 -202
  24. package/dist/handler-routing.js +3 -0
  25. package/dist/handler-segments.d.ts +6 -0
  26. package/dist/handler-segments.js +16 -2
  27. package/dist/handler-segments.test.js +8 -200
  28. package/dist/head-tags.d.ts +9 -0
  29. package/dist/head-tags.js +85 -1
  30. package/dist/head-tags.test.js +18 -125
  31. package/dist/index.d.ts +1 -0
  32. package/dist/index.js +3 -0
  33. package/dist/inline-action-token.test.js +31 -0
  34. package/dist/jsx-svg-types.test.js +58 -0
  35. package/dist/jsx-types.d.ts +92 -1
  36. package/dist/krate-core.js +1 -1
  37. package/dist/krate-dev.js +384 -65
  38. package/dist/krate-f-actions.js +1 -1
  39. package/dist/krate-f-navigation.js +1 -1
  40. package/dist/krate-f-router-lite.js +1 -1
  41. package/dist/krate-f-router.js +1 -1
  42. package/dist/krate-features.json +2 -0
  43. package/dist/krate-hydrate-lite.js +5 -5
  44. package/dist/krate-hydrate.js +5 -5
  45. package/dist/krate-runtime.js +5 -5
  46. package/dist/link-base-path.test.js +28 -0
  47. package/dist/metadata.js +3 -0
  48. package/dist/node-server.test.js +1 -355
  49. package/dist/platform.d.ts +52 -0
  50. package/dist/platform.js +57 -0
  51. package/dist/platform.test.js +44 -0
  52. package/dist/router-lite.js +3 -9
  53. package/dist/router-nav.test.js +15 -444
  54. package/dist/router.js +51 -18
  55. package/dist/server-handler.d.ts +49 -0
  56. package/dist/server-handler.js +311 -21
  57. package/dist/server-handler.test.js +56 -344
  58. package/dist/server-renderer.test.js +0 -104
  59. package/dist/server.d.ts +15 -5
  60. package/dist/server.js +150 -22
  61. package/dist/server.test.js +52 -60
  62. package/dist/site-config.d.ts +13 -0
  63. package/dist/site-config.js +28 -0
  64. package/dist/site-config.test.js +30 -0
  65. package/dist/ssr-core-behavior.test.js +3 -515
  66. package/dist/testing.d.ts +59 -0
  67. package/dist/testing.js +88 -0
  68. package/dist/testing.test.js +73 -0
  69. package/package.json +9 -1
  70. package/dist/action-context.test.js +0 -72
  71. package/dist/class-component.test.js +0 -462
  72. package/dist/class-helpers.test.js +0 -169
  73. package/dist/context.test.js +0 -57
  74. package/dist/derived.test.js +0 -140
  75. package/dist/dev-overlay.test.js +0 -165
  76. package/dist/discrete.test.js +0 -100
  77. package/dist/dom.test.js +0 -39
  78. package/dist/effect-errors.test.d.ts +0 -1
  79. package/dist/effect-errors.test.js +0 -199
  80. package/dist/effects.test.d.ts +0 -1
  81. package/dist/effects.test.js +0 -485
  82. package/dist/handler-routing.test.d.ts +0 -1
  83. package/dist/handler-routing.test.js +0 -99
  84. package/dist/highlight-bind.test.d.ts +0 -1
  85. package/dist/highlight-bind.test.js +0 -124
  86. package/dist/highlight.test.d.ts +0 -1
  87. package/dist/highlight.test.js +0 -56
  88. package/dist/lanes.test.d.ts +0 -1
  89. package/dist/lanes.test.js +0 -59
  90. package/dist/list.test.d.ts +0 -1
  91. package/dist/list.test.js +0 -435
  92. package/dist/metadata.test.d.ts +0 -1
  93. package/dist/metadata.test.js +0 -167
  94. package/dist/navigation.test.d.ts +0 -1
  95. package/dist/navigation.test.js +0 -130
  96. package/dist/optimistic-lanes.test.d.ts +0 -1
  97. package/dist/optimistic-lanes.test.js +0 -45
  98. package/dist/patterns.test.d.ts +0 -1
  99. package/dist/patterns.test.js +0 -125
  100. package/dist/portal.test.d.ts +0 -1
  101. package/dist/portal.test.js +0 -99
  102. package/dist/react-effects.test.d.ts +0 -1
  103. package/dist/react-effects.test.js +0 -133
  104. package/dist/react-suspense.test.d.ts +0 -1
  105. package/dist/react-suspense.test.js +0 -194
  106. package/dist/react.test.d.ts +0 -1
  107. package/dist/react.test.js +0 -60
  108. package/dist/react19.test.d.ts +0 -1
  109. package/dist/react19.test.js +0 -176
  110. package/dist/reactivity-core.test.d.ts +0 -1
  111. package/dist/reactivity-core.test.js +0 -152
  112. package/dist/reconcile.test.d.ts +0 -1
  113. package/dist/reconcile.test.js +0 -110
  114. package/dist/refs.test.d.ts +0 -1
  115. package/dist/refs.test.js +0 -257
  116. package/dist/router-layout.test.d.ts +0 -1
  117. package/dist/router-layout.test.js +0 -249
  118. package/dist/router-slots.test.d.ts +0 -1
  119. package/dist/router-slots.test.js +0 -144
  120. package/dist/router-speculation.test.d.ts +0 -1
  121. package/dist/router-speculation.test.js +0 -25
  122. package/dist/router-styles.test.d.ts +0 -1
  123. package/dist/router-styles.test.js +0 -98
  124. package/dist/router.test.d.ts +0 -1
  125. package/dist/router.test.js +0 -36
  126. package/dist/server-async.test.d.ts +0 -1
  127. package/dist/server-async.test.js +0 -216
  128. package/dist/server-highlight.test.d.ts +0 -1
  129. package/dist/server-highlight.test.js +0 -32
  130. package/dist/signal-lanes.test.d.ts +0 -1
  131. package/dist/signal-lanes.test.js +0 -32
  132. package/dist/slots.test.d.ts +0 -1
  133. package/dist/slots.test.js +0 -187
  134. package/dist/snapshots.test.d.ts +0 -1
  135. package/dist/snapshots.test.js +0 -208
  136. package/dist/ssr-core.test.d.ts +0 -1
  137. package/dist/ssr-core.test.js +0 -324
  138. package/dist/static-memory.test.d.ts +0 -1
  139. package/dist/static-memory.test.js +0 -26
  140. package/dist/storage.test.d.ts +0 -1
  141. package/dist/storage.test.js +0 -46
  142. package/dist/suspense-actions.test.d.ts +0 -1
  143. package/dist/suspense-actions.test.js +0 -72
  144. package/dist/suspense.test.d.ts +0 -1
  145. package/dist/suspense.test.js +0 -556
  146. /package/dist/{action-context.test.d.ts → after.test.d.ts} +0 -0
  147. /package/dist/{class-component.test.d.ts → builtin-tags.test.d.ts} +0 -0
  148. /package/dist/{class-helpers.test.d.ts → inline-action-token.test.d.ts} +0 -0
  149. /package/dist/{context.test.d.ts → jsx-svg-types.test.d.ts} +0 -0
  150. /package/dist/{derived.test.d.ts → link-base-path.test.d.ts} +0 -0
  151. /package/dist/{dev-overlay.test.d.ts → platform.test.d.ts} +0 -0
  152. /package/dist/{discrete.test.d.ts → site-config.test.d.ts} +0 -0
  153. /package/dist/{dom.test.d.ts → testing.test.d.ts} +0 -0
@@ -1,187 +0,0 @@
1
- import { describe, it, expect, beforeEach } from 'vitest';
2
- import { readFileSync } from 'node:fs';
3
- import { fileURLToPath } from 'node:url';
4
- import { dirname, resolve } from 'node:path';
5
- import { krateCondSwap, krateCondDetached, krateCondReset, krateSanitizeAttr, BLOCKED_URL } from './slots';
6
- import { createSignal, createEffect } from './signal';
7
- import { reconcileTrees } from './reconcile';
8
- const tick = () => new Promise((r) => setTimeout(r, 0));
9
- function startMarker(root, id) {
10
- const w = document.createTreeWalker(root, NodeFilter.SHOW_COMMENT);
11
- while (w.nextNode()) {
12
- if (w.currentNode.nodeValue === 'k:' + id)
13
- return w.currentNode;
14
- }
15
- throw new Error('marker not found: ' + id);
16
- }
17
- describe('krateCondSwap', () => {
18
- // happy-dom does not parse <tr> inside <template> per spec, so the
19
- // table-context case is covered by the Go emitter tests and the browser
20
- // conformance suite; the swap mechanics are identical for any element.
21
- it('swaps the active branch with the template branch', () => {
22
- document.body.innerHTML =
23
- '<ol><!--k:c1--><li>yes</li><!--/k:c1--></ol>' +
24
- '<template data-kc="c1" data-kb="a"><li>no</li></template>';
25
- const start = startMarker(document.body, 'c1');
26
- const tpl = document.querySelector('template[data-kc="c1"]');
27
- const tbody = document.querySelector('ol');
28
- const yesRow = tbody.querySelector('li');
29
- krateCondSwap(start, true, tpl);
30
- expect(tbody.textContent).toBe('yes');
31
- krateCondSwap(start, false, tpl);
32
- expect(tbody.querySelectorAll('li').length).toBe(1);
33
- expect(tbody.textContent).toBe('no');
34
- krateCondSwap(start, true, tpl);
35
- // The original (hydrated) node comes back, not a clone.
36
- expect(tbody.querySelector('li')).toBe(yesRow);
37
- });
38
- it('keeps bindings made on template content alive after the swap', async () => {
39
- document.body.innerHTML =
40
- '<ul><!--k:c2--><li>a</li><!--/k:c2--></ul><template data-kc="c2" data-kb="a"><li><button>b</button></li></template>';
41
- const tpl = document.querySelector('template');
42
- const btn = tpl.content.querySelector('button');
43
- let clicks = 0;
44
- btn.addEventListener('click', () => clicks++);
45
- const [on, setOn] = createSignal(true);
46
- const start = startMarker(document.body, 'c2');
47
- createEffect(() => krateCondSwap(start, !!on(), tpl));
48
- expect(document.querySelector('ul').textContent).toBe('a');
49
- setOn(false);
50
- await tick();
51
- const live = document.querySelector('ul button');
52
- expect(live).toBe(btn);
53
- live.click();
54
- expect(clicks).toBe(1);
55
- });
56
- it('starts from the consequent when the template holds it', () => {
57
- document.body.innerHTML = '<p><!--k:c3--><i>no</i><!--/k:c3--></p><template data-kc="c3" data-kb="c"><b>yes</b></template>';
58
- const start = startMarker(document.body, 'c3');
59
- const tpl = document.querySelector('template');
60
- krateCondSwap(start, false, tpl);
61
- expect(document.querySelector('p').innerHTML).toBe('<!--k:c3--><i>no</i><!--/k:c3-->');
62
- krateCondSwap(start, true, tpl);
63
- expect(document.querySelector('p').innerHTML).toBe('<!--k:c3--><b>yes</b><!--/k:c3-->');
64
- });
65
- it('treats a missing template as an empty branch', () => {
66
- document.body.innerHTML = '<div><!--k:c4--><b>x</b><!--/k:c4--></div>';
67
- const start = startMarker(document.body, 'c4');
68
- krateCondSwap(start, true, null);
69
- krateCondSwap(start, false, null);
70
- expect(document.querySelector('div').innerHTML).toBe('<!--k:c4--><!--/k:c4-->');
71
- krateCondSwap(start, true, null);
72
- expect(document.querySelector('div').textContent).toBe('x');
73
- });
74
- });
75
- describe('krateSanitizeAttr', () => {
76
- it('blocks javascript: URLs like React 19', () => {
77
- expect(krateSanitizeAttr('href', 'javascript:alert(1)')).toBe(BLOCKED_URL);
78
- expect(krateSanitizeAttr('src', ' \tJaVa\nScript:x')).toBe(BLOCKED_URL);
79
- expect(krateSanitizeAttr('xlink:href', 'javascript:x')).toBe(BLOCKED_URL);
80
- expect(krateSanitizeAttr('href', '/safe')).toBe('/safe');
81
- expect(krateSanitizeAttr('title', 'javascript:x')).toBe('javascript:x');
82
- });
83
- });
84
- describe('reconcile with conditional templates', () => {
85
- it('replaces a template whose content changed', () => {
86
- document.body.innerHTML = '<div id="root"><p>x</p><template data-kc="c1" data-kb="a"><b>old</b></template></div>';
87
- const root = document.getElementById('root');
88
- const next = document.createElement('div');
89
- next.id = 'root';
90
- next.innerHTML = '<p>x</p><template data-kc="c1" data-kb="a"><b>new</b></template>';
91
- reconcileTrees(root, next);
92
- const tpl = root.querySelector('template');
93
- expect(tpl.innerHTML).toBe('<b>new</b>');
94
- });
95
- });
96
- // The hydration bootstrap ships as a Go string constant appended to the
97
- // runtime chunk; run the real source against compiler-shaped markup.
98
- function loadBootstrap() {
99
- const here = dirname(fileURLToPath(import.meta.url));
100
- const src = readFileSync(resolve(here, '../../compiler/internal/renderer/newhydrate.go'), 'utf8');
101
- const start = src.indexOf('const HydrationBootstrapJS = `') + 'const HydrationBootstrapJS = `'.length;
102
- const end = src.indexOf('`\n', start);
103
- return src.slice(start, end);
104
- }
105
- describe('hydration bootstrap', () => {
106
- beforeEach(() => {
107
- const w = window;
108
- w.createEffect = createEffect;
109
- w.krateCondSwap = krateCondSwap;
110
- w.krateCondDetached = krateCondDetached;
111
- w.krateCondReset = krateCondReset;
112
- w.krateSanitizeAttr = krateSanitizeAttr;
113
- });
114
- it('binds handlers and text inside the inactive branch template, then toggles', async () => {
115
- document.body.innerHTML =
116
- '<div id="root"><ul><!--k:c--><li>on</li><!--/k:c--></ul>' +
117
- '<template data-kc="c" data-kb="a"><li><button data-k="k:btn">off</button><!--k:t-->0<!--/k:t--></li></template></div>';
118
- new Function(loadBootstrap())();
119
- const w = window;
120
- const [on, setOn] = createSignal(true);
121
- const [n, setN] = createSignal(0);
122
- let clicked = 0;
123
- w.kbindCond('c', () => on());
124
- w.kbindText('t', () => n());
125
- expect(w.findSlot('btn')).not.toBe(null);
126
- w.kbindEvent('btn', 'click', () => clicked++, false);
127
- expect(w.__krateErrs).toEqual([]);
128
- setN(5);
129
- setOn(false);
130
- await tick();
131
- const tbody = document.querySelector('ul');
132
- expect(tbody.textContent).toBe('off5');
133
- tbody.querySelector('button').click();
134
- expect(clicked).toBe(1);
135
- setOn(true);
136
- await tick();
137
- expect(tbody.textContent).toBe('on');
138
- setN(7);
139
- setOn(false);
140
- await tick();
141
- expect(tbody.textContent).toBe('off7');
142
- });
143
- it('renders bigint, and primitives inside arrays, as text in a content slot', async () => {
144
- document.body.innerHTML = '<div id="root"><p><!--k:v-->0<!--/k:v--></p></div>';
145
- new Function(loadBootstrap())();
146
- const w = window;
147
- const [val, setVal] = createSignal(5n / 2n);
148
- w.kbindContent('v', () => val());
149
- const p = document.querySelector('p');
150
- expect(w.__krateErrs).toEqual([]);
151
- await tick();
152
- expect(p.textContent).toBe('2');
153
- setVal(['a', 3, 7n, null, false]);
154
- await tick();
155
- expect(w.__krateErrs).toEqual([]);
156
- expect(p.textContent).toBe('a37');
157
- setVal(12345678901234567890n);
158
- await tick();
159
- expect(p.textContent).toBe('12345678901234567890');
160
- });
161
- it('finds nodes of a branch swapped out before its binding ran', async () => {
162
- document.body.innerHTML =
163
- '<div id="root"><p><!--k:c--><button data-k="k:b">ssr</button><!--/k:c--></p>' +
164
- '<template data-kc="c" data-kb="a"><i>client</i></template></div>';
165
- new Function(loadBootstrap())();
166
- const w = window;
167
- // The client state disagrees with the SSR state: the first run swaps.
168
- w.kbindCond('c', () => false);
169
- expect(document.querySelector('p').textContent).toBe('client');
170
- let clicks = 0;
171
- w.kbindEvent('b', 'click', () => clicks++, false);
172
- expect(w.findSlot('b')).not.toBe(null);
173
- w.findSlot('b').click();
174
- expect(clicks).toBe(1);
175
- });
176
- it('neutralizes javascript: URLs set by attribute bindings', async () => {
177
- document.body.innerHTML = '<div id="root"><a data-k="k:a">x</a></div>';
178
- new Function(loadBootstrap())();
179
- const [href, setHref] = createSignal('/ok');
180
- window.kbindAttr('a', 'href', () => href());
181
- const a = document.querySelector('a');
182
- expect(a.getAttribute('href')).toBe('/ok');
183
- setHref('javascript:alert(1)');
184
- await tick();
185
- expect(a.getAttribute('href')).toBe(BLOCKED_URL);
186
- });
187
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,208 +0,0 @@
1
- import { describe, it, expect, beforeEach } from 'vitest';
2
- import { createSignal, createReducer, createEffect, disposeAll, krateHookState, krateFlushSync } from './signal';
3
- import { createEffectDeps, krateOwner, krateMount, krateCondActivity, krateOnUnmount } from './effects';
4
- const tick = () => new Promise((r) => setTimeout(r, 0));
5
- async function settle() {
6
- for (let i = 0; i < 4; i++)
7
- await tick();
8
- }
9
- // Runs fn as if inside a native click listener (a discrete event).
10
- function inClick(fn) {
11
- const btn = document.createElement('button');
12
- document.body.appendChild(btn);
13
- // Browsers expose the event being dispatched as window.event; happy-dom
14
- // does not, so provide it the way a browser would.
15
- btn.addEventListener('click', (e) => {
16
- const w = window;
17
- const prev = w.event;
18
- w.event = e;
19
- try {
20
- fn();
21
- }
22
- finally {
23
- w.event = prev;
24
- }
25
- });
26
- btn.click();
27
- btn.remove();
28
- }
29
- describe('render snapshots for React state', () => {
30
- beforeEach(() => disposeAll());
31
- it('reads the committed value in handlers, so repeated setState(x + 1) adds one', async () => {
32
- const [count, setCount] = createSignal(0, krateHookState);
33
- inClick(() => {
34
- setCount(count() + 1);
35
- setCount(count() + 1);
36
- setCount(count() + 1);
37
- });
38
- await settle();
39
- expect(count()).toBe(1);
40
- });
41
- it('keeps functional updaters on the latest pending value', async () => {
42
- const [count, setCount] = createSignal(0, krateHookState);
43
- inClick(() => {
44
- setCount((c) => c + 1);
45
- setCount((c) => c + 1);
46
- expect(count()).toBe(0); // still the render's snapshot
47
- });
48
- await settle();
49
- expect(count()).toBe(2);
50
- });
51
- it('lets bindings (the render phase) see the latest value', async () => {
52
- const [count, setCount] = createSignal(0, krateHookState);
53
- const seen = [];
54
- createEffect(() => void seen.push(count()));
55
- inClick(() => setCount(5));
56
- await settle();
57
- expect(seen).toEqual([0, 5]);
58
- });
59
- it('runs cleanups with the values of the render their effect ran for', async () => {
60
- const [room, setRoom] = createSignal('general', krateHookState);
61
- const log = [];
62
- createEffectDeps(() => {
63
- log.push('connect ' + room());
64
- return () => log.push('disconnect ' + room());
65
- }, () => [room()]);
66
- await settle();
67
- inClick(() => setRoom('random'));
68
- await settle();
69
- inClick(() => setRoom('music'));
70
- await settle();
71
- expect(log).toEqual(['connect general', 'disconnect general', 'connect random', 'disconnect random', 'connect music']);
72
- });
73
- it('gives a second effect the committed value while the first sets state', async () => {
74
- const [text] = createSignal('hello', krateHookState);
75
- const [words, setWords] = createSignal(0, krateHookState);
76
- const log = [];
77
- createEffectDeps(() => {
78
- log.push('count ' + text());
79
- setWords(1);
80
- }, () => [text()]);
81
- createEffectDeps(() => void log.push('words ' + words()), () => [words()]);
82
- await settle();
83
- expect(log).toEqual(['count hello', 'words 0', 'words 1']);
84
- });
85
- it('does not change native signal semantics', () => {
86
- const [n, setN] = createSignal(0);
87
- setN(n() + 1);
88
- setN(n() + 1);
89
- expect(n()).toBe(2);
90
- });
91
- it('applies reducer options and the lazy initializer', async () => {
92
- const [s, dispatch] = createReducer((st, a) => st + a, 2, (x) => x * 10, krateHookState);
93
- expect(s()).toBe(20);
94
- inClick(() => {
95
- dispatch(1);
96
- expect(s()).toBe(20);
97
- });
98
- await settle();
99
- expect(s()).toBe(21);
100
- });
101
- });
102
- describe('update lanes', () => {
103
- beforeEach(() => disposeAll());
104
- it('flushes passive effects of a discrete update before the handler microtask', async () => {
105
- const [n, setN] = createSignal(0, krateHookState);
106
- const log = [];
107
- createEffectDeps(() => void log.push('passive ' + n()), () => [n()]);
108
- await settle();
109
- log.length = 0;
110
- inClick(() => {
111
- setN((v) => v + 1);
112
- queueMicrotask(() => log.push('microtask'));
113
- });
114
- await settle();
115
- expect(log).toEqual(['passive 1', 'microtask']);
116
- });
117
- it('commits a non-discrete update after the microtasks queued with it', async () => {
118
- const [n, setN] = createSignal(0, krateHookState);
119
- const log = [];
120
- createEffectDeps(() => void log.push('layout ' + n()), () => [n()], 'layout');
121
- await settle();
122
- log.length = 0;
123
- setTimeout(() => {
124
- setN(10);
125
- queueMicrotask(() => log.push('microtask'));
126
- }, 0);
127
- await settle();
128
- expect(log).toEqual(['microtask', 'layout 10']);
129
- });
130
- it('flushes synchronously on demand', () => {
131
- const [n, setN] = createSignal(0, krateHookState);
132
- const seen = [];
133
- createEffect(() => void seen.push(n()));
134
- setN(3);
135
- krateFlushSync();
136
- expect(seen).toEqual([0, 3]);
137
- expect(n()).toBe(3);
138
- });
139
- });
140
- describe('remountable conditional branches', () => {
141
- beforeEach(() => disposeAll());
142
- it('unmounts on hide and mounts a fresh instance on show', async () => {
143
- const log = [];
144
- const setters = [];
145
- const getters = [];
146
- const unmounted = [];
147
- krateOnUnmount((_owner, id) => unmounted.push(id));
148
- krateOwner('P', null);
149
- krateMount('C', 'P', [['5', 'c', 1]], null, () => {
150
- const [count, setCount] = createSignal(0, krateHookState);
151
- setters.push(setCount);
152
- getters.push(count);
153
- createEffectDeps(() => {
154
- log.push('mount ' + count());
155
- return () => log.push('unmount ' + count());
156
- }, () => []);
157
- });
158
- krateOwner(null);
159
- await settle();
160
- setters[0](2);
161
- await settle();
162
- expect(getters[0]()).toBe(2);
163
- krateCondActivity('5', 'a');
164
- await settle();
165
- krateCondActivity('5', 'c');
166
- await settle();
167
- expect(getters.length).toBe(2);
168
- expect(getters[1]()).toBe(0);
169
- expect(log).toEqual(['mount 0', 'unmount 0', 'mount 0']);
170
- expect(unmounted).toEqual(['C']);
171
- });
172
- it('defers a component in the initially hidden branch until it is shown', async () => {
173
- let runs = 0;
174
- krateOwner('P', null);
175
- krateCondActivity('9', 'c');
176
- krateMount('Alt', 'P', [['9', 'a', 0]], null, () => {
177
- runs++;
178
- });
179
- krateOwner(null);
180
- await settle();
181
- expect(runs).toBe(0);
182
- krateCondActivity('9', 'a');
183
- expect(runs).toBe(1);
184
- });
185
- it('remounts nested components under their fresh parent', async () => {
186
- const order = [];
187
- krateOwner('P', null);
188
- krateMount('C', 'P', [['5', 'c', 1]], null, () => void order.push('C'));
189
- krateMount('G', 'C', [['5', 'c', 1]], null, () => void order.push('G'));
190
- krateOwner(null);
191
- krateCondActivity('5', 'a');
192
- krateCondActivity('5', 'c');
193
- expect(order).toEqual(['C', 'G', 'C', 'G']);
194
- });
195
- it('disposes the bindings of an unmounted instance', async () => {
196
- const [n, setN] = createSignal(0);
197
- const seen = [];
198
- krateOwner('P', null);
199
- krateMount('C', 'P', [['5', 'c', 1]], null, () => {
200
- createEffect(() => void seen.push(n()));
201
- });
202
- krateOwner(null);
203
- krateCondActivity('5', 'a');
204
- setN(1);
205
- await settle();
206
- expect(seen).toEqual([0]);
207
- });
208
- });
@@ -1 +0,0 @@
1
- export {};