Skip to content

Commit 367767e

Browse files
committed
fix(repl): correctly update store, fix CSS
1 parent 314748a commit 367767e

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

packages/docs/src/repl/repl-output-symbols.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,17 @@ export const ReplOutputSymbols = component$(({ outputs }: ReplOutputSymbolsProps
4141
.map((o, i) => (
4242
<div class="file-item" data-symbol-item={i} key={o.path}>
4343
<div class="file-info">
44-
<span>{o.segment?.canonicalFilename}</span>
44+
<span>{o.segment!.canonicalFilename}</span>
45+
{o.segment!.paramNames && (
46+
<div>
47+
Params: <code>{o.segment!.paramNames.join(', ')}</code>
48+
</div>
49+
)}
50+
{o.segment!.captureNames && (
51+
<div>
52+
Captures: <code>{o.segment!.captureNames.join(', ')}</code>
53+
</div>
54+
)}
4555
</div>
4656
<div class="file-text">
4757
<CodeBlock

packages/docs/src/repl/repl-output-update.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { ReplResult, ReplStore } from './types';
22

33
// TODO fix useStore to recursively notify subscribers
4-
const deepUpdate = (prev: any, next: any) => {
4+
const deepUpdate = (prev: any, next: any, matcher?: (a: any, b: any) => boolean) => {
55
for (const key in next) {
66
if (prev[key] && typeof next[key] === 'object' && typeof prev[key] === 'object') {
77
deepUpdate(prev[key], next[key]);
@@ -13,13 +13,7 @@ const deepUpdate = (prev: any, next: any) => {
1313
}
1414
if (Array.isArray(prev)) {
1515
for (const item of prev) {
16-
// can't use Object as a matcher
17-
// because it will be a different object
18-
// so we need to use the path or code
19-
20-
if (
21-
next.some((nextItem: any) => (nextItem.path || nextItem.code) === (item.path || item.code))
22-
) {
16+
if (!next.some((nextItem: any) => (matcher ? matcher(nextItem, item) : nextItem === item))) {
2317
prev.splice(prev.indexOf(item), 1);
2418
}
2519
}
@@ -32,6 +26,8 @@ const deepUpdate = (prev: any, next: any) => {
3226
}
3327
};
3428

29+
const matchByPath = (a: any, b: any) => a.path === b.path;
30+
3531
export const updateReplOutput = async (store: ReplStore, result: ReplResult) => {
3632
deepUpdate(store.diagnostics, result.diagnostics);
3733

@@ -40,9 +36,9 @@ export const updateReplOutput = async (store: ReplStore, result: ReplResult) =>
4036
store.html = result.html;
4137
}
4238

43-
deepUpdate(store.transformedModules, result.transformedModules);
44-
deepUpdate(store.clientBundles, result.clientBundles);
45-
deepUpdate(store.ssrModules, result.ssrModules);
39+
deepUpdate(store.transformedModules, result.transformedModules, matchByPath);
40+
deepUpdate(store.clientBundles, result.clientBundles, matchByPath);
41+
deepUpdate(store.ssrModules, result.ssrModules, matchByPath);
4642
if (
4743
result.events.length !== store.events.length ||
4844
result.events.some((ev, i) => ev?.start !== store.events[i]?.start)

packages/docs/src/repl/repl.css

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@
230230
.output-modules .file-tree {
231231
padding: 0 15px 15px 15px;
232232
grid-area: repl-file-tree;
233-
overflow-y: auto;
233+
overflow: auto;
234234
}
235235

236236
.output-modules .file-tree-header {
@@ -242,8 +242,6 @@
242242
display: block;
243243
margin: 4px 0px 2px 9px;
244244
white-space: nowrap;
245-
text-overflow: ellipsis;
246-
overflow: hidden;
247245
}
248246

249247
.output-modules .file-tree-items a:hover,
@@ -270,8 +268,7 @@
270268
margin-bottom: 15px;
271269
background-color: rgb(33 104 170 / 15%);
272270
padding: 5px 10px;
273-
overflow: hidden;
274-
text-overflow: ellipsis;
271+
word-break: break-word;
275272
}
276273

277274
.output-modules .file-size {

0 commit comments

Comments
 (0)