Repository navigation
Expand file tree
/
Copy pathreport.go
More file actions
3159 lines (3025 loc) · 125 KB
/
Copy pathreport.go
File metadata and controls
3159 lines (3025 loc) · 125 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package main
import (
_ "embed"
"encoding/base64"
"fmt"
"regexp"
"strings"
"sync"
"time"
)
const appTitle = "webdiskstat"
var (
generatedTitlePattern = regexp.MustCompile(`<title>.*?</title>`)
generatedTimePattern = regexp.MustCompile(`<time class="generated" datetime="[^"]*">Generated .*?</time>`)
reportSizePattern = regexp.MustCompile(`HTML file: [^<]+`)
faviconLinkPattern = regexp.MustCompile(`<link rel="icon"[^>]*>`)
passwordPromptPattern = regexp.MustCompile(`const password = window\.prompt\([^;]+\);`)
latoFontFacePattern = regexp.MustCompile(`@font-face\{font-family:Lato;[^}]+\}(@font-face\{font-family:Lato;[^}]+\})?`)
robotoFontFacePattern = regexp.MustCompile(`@font-face\{font-family:"Roboto Mono";[^}]+\}(@font-face\{font-family:"Roboto Mono";[^}]+\})?`)
merriFontFacePattern = regexp.MustCompile(`@font-face\{font-family:Merriweather;[^}]+\}(@font-face\{font-family:Merriweather;[^}]+\})?`)
reportTemplateOnce sync.Once
preparedReportTemplate string
)
//go:embed assets/favicon.svg
var faviconSVG string
func renderReport(root *Node, password *string) (string, error) {
payload, err := reportDataPayload(root, password)
if err != nil {
return "", err
}
now := time.Now().Local()
generatedISO := now.Format(time.RFC3339)
generatedDisplay := now.Format("2006-01-02 15:04:05 MST")
report, err := replacePayload(optimizedReportTemplate(), payload)
if err != nil {
return "", err
}
report = replaceGeneratedMetadata(report, generatedISO, generatedDisplay)
report = replaceSecurityStatus(report, password != nil)
report = fillReportSize(report)
return report, nil
}
func optimizedReportTemplate() string {
reportTemplateOnce.Do(func() {
report := reportTemplate
report = replaceFavicon(report)
report = replaceEmbeddedFonts(report)
report = replaceReportDataLoader(report)
if !strings.Contains(report, "const SEARCH_INDEX_NODE_LIMIT = 500000;") &&
!strings.Contains(report, "const SEARCH_INDEX_FILE_LIMIT = 5000000;") {
report = replaceSearchIndexBuild(report)
}
report = replaceFolderIcon(report)
report = replaceMaterialFileIcons(report)
report = replaceBreadcrumbControls(report)
report = replaceColumnSettingsIcon(report)
report = replaceThemeSwitcher(report)
report = replaceDirectoryEntryFocus(report)
report = replacePasswordDialog(report)
report = replaceReportAccessibility(report)
report = replaceTreemapStyles(report)
report = replaceTreemapMimeColors(report)
report = replaceTreemapPalette(report)
report = replaceTreeColumnResizing(report)
report = replaceTreeColumnSeparators(report)
report = replaceTreeTableFontSize(report)
report = replaceBrowserMemoryUsage(report)
report = replaceLoadingProgress(report)
if !strings.Contains(report, " topFiles: [],") {
report = strings.Replace(
report,
" topFilesLimit: 10,\n treemapTileCap: DEFAULT_TREEMAP_TILE_CAP,",
" topFilesLimit: 10,\n topFiles: [],\n treemapTileCap: DEFAULT_TREEMAP_TILE_CAP,",
1,
)
}
if !strings.Contains(report, "function buildTopFilesIndex(root)") {
report = strings.Replace(
report,
`function collectFiles(node, files) {
if (node.type !== "dir") {
if (node.size > 0) files.push(node);
return;
}
(node.children || []).forEach(child => collectFiles(child, files));
}
`,
`function collectFiles(node, files) {
if (node.type !== "dir") {
if (node.size > 0) files.push(node);
return;
}
(node.children || []).forEach(child => collectFiles(child, files));
}
function buildTopFilesIndex(root) {
const files = [];
collectFiles(root, files);
files.sort((a, b) => b.size - a.size);
return files;
}
`,
1,
)
}
report = strings.Replace(
report,
` const files = [];
collectFiles(DATA, files);
files.sort((a, b) => b.size - a.size);
state.topFilesLimit = normalizeTopFilesLimit(state.topFilesLimit);`,
` const files = state.topFiles;
state.topFilesLimit = normalizeTopFilesLimit(state.topFilesLimit);`,
1,
)
if !strings.Contains(report, " state.topFiles = buildTopFilesIndex(DATA);") {
report = strings.Replace(
report,
` DATA = root;
walk(DATA, null);
state.current = DATA;`,
` DATA = root;
walk(DATA, null);
state.topFiles = buildTopFilesIndex(DATA);
state.current = DATA;`,
1,
)
}
preparedReportTemplate = replaceTopFilesIndex(report)
})
return preparedReportTemplate
}
func faviconDataURI() string {
return "data:image/svg+xml;base64," + base64.StdEncoding.EncodeToString([]byte(faviconSVG))
}
func replaceFavicon(report string) string {
link := `<link rel="icon" type="image/svg+xml" href="` + faviconDataURI() + `">`
if faviconLinkPattern.MatchString(report) {
return faviconLinkPattern.ReplaceAllString(report, link)
}
return strings.Replace(report, `</head>`, link+`</head>`, 1)
}
func replaceColumnSettingsIcon(report string) string {
const previous = `function makeColumnsIcon() {
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
svg.setAttribute("class", "icon");
svg.setAttribute("viewBox", "0 0 24 24");
[
"M4 5h16",
"M4 12h16",
"M4 19h16",
"M8 5v14",
"M16 5v14"
].forEach(d => {
const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
path.setAttribute("d", d);
svg.appendChild(path);
});
return svg;
}
`
const replacement = `function makeColumnsIcon() {
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
svg.setAttribute("class", "icon column-settings-icon");
svg.setAttribute("viewBox", "0 0 24 24");
const frame = document.createElementNS("http://www.w3.org/2000/svg", "rect");
frame.setAttribute("x", "2.5");
frame.setAttribute("y", "4");
frame.setAttribute("width", "19");
frame.setAttribute("height", "16");
frame.setAttribute("rx", "2");
svg.appendChild(frame);
[
"M8.5 4v16",
"M15 4v16",
"M4.5 9h2",
"M10.5 14h2.5",
"M17 10h2.5"
].forEach(d => {
const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
path.setAttribute("d", d);
svg.appendChild(path);
});
return svg;
}
`
return strings.Replace(report, previous, replacement, 1)
}
func replaceThemeSwitcher(report string) string {
if strings.Contains(report, `theme-switcher-v2`) {
return report
}
const previous = `<label class="theme-toggle" title="Toggle light theme"><input id="themeToggle" class="theme-input" type="checkbox" role="switch" aria-label="Light theme"><span class="theme-switch" aria-hidden="true"><svg class="theme-icon moon-icon" viewBox="0 0 24 24"><path d="M20 14.7A7.5 7.5 0 0 1 9.3 4a8 8 0 1 0 10.7 10.7Z"/></svg><svg class="theme-icon sun-icon" viewBox="0 0 24 24"><path d="M12 3v2"/><path d="M12 19v2"/><path d="m4.22 4.22 1.42 1.42"/><path d="m18.36 18.36 1.42 1.42"/><path d="M3 12h2"/><path d="M19 12h2"/><path d="m4.22 19.78 1.42-1.42"/><path d="m18.36 5.64 1.42-1.42"/><circle cx="12" cy="12" r="4"/></svg><span class="theme-knob"></span></span></label>`
const replacement = `<label class="theme-toggle" title="Switch to light theme"><input id="themeToggle" class="theme-input" type="checkbox" role="switch" aria-label="Switch to light theme"><span class="theme-switch theme-switcher-v2" aria-hidden="true"><svg class="theme-icon moon-icon" viewBox="0 0 24 24"><path d="M19.4 15.2A7.5 7.5 0 0 1 8.8 4.6a8 8 0 1 0 10.6 10.6Z"/><path class="moon-star" d="M17.5 5.5h.01M20 8.5h.01"/></svg><svg class="theme-icon sun-icon" viewBox="0 0 24 24"><circle cx="12" cy="12" r="4.25"/><path d="M12 2.75v2.1M12 19.15v2.1M5.46 5.46l1.49 1.49M17.05 17.05l1.49 1.49M2.75 12h2.1M19.15 12h2.1M5.46 18.54l1.49-1.49M17.05 6.95l1.49-1.49"/></svg></span></label>`
report = strings.Replace(report, previous, replacement, 1)
const css = `.theme-switch.theme-switcher-v2{width:36px;height:36px;display:grid;place-items:center;padding:0;overflow:hidden;border:1px solid #3b5268;border-radius:50%;background:linear-gradient(145deg,#223244 0%,#111820 78%);color:#8dd8ff;box-shadow:inset 0 1px 0 rgba(255,255,255,.08),0 2px 5px rgba(0,0,0,.22);transition:transform 160ms ease,border-color 160ms ease,background 180ms ease,box-shadow 180ms ease}.theme-switcher-v2::before{content:"";position:absolute;inset:4px;border-radius:50%;background:radial-gradient(circle,rgba(56,189,248,.2) 0%,rgba(56,189,248,0) 70%);transition:background 180ms ease,transform 180ms ease}.theme-switcher-v2 .theme-icon{position:absolute;width:18px;height:18px;z-index:1;opacity:1;stroke:currentColor;stroke-width:1.9;transform-origin:center;transition:opacity 170ms ease,transform 220ms cubic-bezier(.2,.8,.2,1),color 180ms ease}.theme-switcher-v2 .moon-icon{color:#9bddff;transform:rotate(0) scale(1)}.theme-switcher-v2 .moon-star{stroke-width:3.2;stroke-linecap:round}.theme-switcher-v2 .sun-icon{color:#f59e0b;opacity:0;transform:rotate(-55deg) scale(.5)}.theme-input:checked+.theme-switcher-v2{border-color:#d6b75d;background:linear-gradient(145deg,#fffdf4 0%,#f5e8b8 100%);box-shadow:inset 0 1px 0 rgba(255,255,255,.9),0 2px 5px rgba(71,51,12,.14)}.theme-input:checked+.theme-switcher-v2::before{background:radial-gradient(circle,rgba(251,191,36,.25) 0%,rgba(251,191,36,0) 72%);transform:scale(1.08)}.theme-input:checked+.theme-switcher-v2 .moon-icon{opacity:0;transform:rotate(45deg) scale(.5)}.theme-input:checked+.theme-switcher-v2 .sun-icon,html[data-theme="light"] .theme-input:checked+.theme-switcher-v2 .sun-icon{color:#d97706;opacity:1;transform:rotate(0) scale(1)}.theme-toggle:hover .theme-switcher-v2,html[data-theme="light"] .theme-toggle:hover .theme-switcher-v2{transform:translateY(-1px);border-color:var(--accent);background:linear-gradient(145deg,#fffdf4 0%,#f5e8b8 100%);box-shadow:inset 0 1px 0 rgba(255,255,255,.1),0 4px 9px rgba(0,0,0,.18)}html[data-theme="dark"] .theme-toggle:hover .theme-switcher-v2{background:linear-gradient(145deg,#293d52 0%,#151e28 78%)}.theme-input:focus-visible+.theme-switcher-v2{outline:2px solid var(--accent);outline-offset:2px}@media(prefers-reduced-motion:reduce){.theme-switcher-v2,.theme-switcher-v2::before,.theme-switcher-v2 .theme-icon{transition:none}}`
report = strings.Replace(report, `</style>`, css+`</style>`, 1)
report = strings.Replace(
report,
` el.themeToggle.checked = normalized === "light";
el.themeToggle.setAttribute("aria-checked", String(el.themeToggle.checked));`,
` el.themeToggle.checked = normalized === "light";
el.themeToggle.setAttribute("aria-checked", String(el.themeToggle.checked));
const nextTheme = normalized === "light" ? "dark" : "light";
const themeLabel = el.themeToggle.closest(".theme-toggle");
el.themeToggle.setAttribute("aria-label", "Switch to " + nextTheme + " theme");
if (themeLabel) themeLabel.title = "Switch to " + nextTheme + " theme";`,
1,
)
return report
}
func replaceDirectoryEntryFocus(report string) string {
if strings.Contains(report, `function focusFirstTreeRow()`) {
return report
}
report = strings.Replace(
report,
`function setCurrent(node, updateUrl = true) {
if (!node) return;
state.current = node;
state.selected = node;
if (updateUrl) syncUrlToCurrent(node);
renderSafely();
}`,
`function setCurrent(node, updateUrl = true, focusFirstRow = false) {
if (!node) return;
state.current = node;
state.selected = node;
if (updateUrl) syncUrlToCurrent(node);
renderSafely();
if (focusFirstRow) focusFirstTreeRow();
}`,
1,
)
const focusFunction = `function focusFirstTreeRow() {
const first = currentTreeChildren()[0];
if (!first) return;
state.selected = first;
el.tree.scrollTop = 0;
renderVisibleTreeRows(true);
renderDetails();
requestAnimationFrame(() => {
const row = el.tree.querySelector('.row[data-id="' + first.id + '"]');
if (!row) return;
row.tabIndex = 0;
row.classList.add("active");
row.focus({ preventScroll: true });
row.scrollIntoView({ block: "nearest" });
});
}
`
report = strings.Replace(report, `function setListSelectionByIndex(index) {`, focusFunction+`function setListSelectionByIndex(index) {`, 1)
report = strings.ReplaceAll(report, `if (child.type === "dir") setCurrent(child);`, `if (child.type === "dir") setCurrent(child, true, true);`)
report = strings.ReplaceAll(report, `if (node.type === "dir") setCurrent(node);`, `if (node.type === "dir") setCurrent(node, true, true);`)
report = strings.Replace(
report,
` if (parentNode) setCurrent(parentNode);`,
` if (parentNode) setCurrent(parentNode, true, true);`,
1,
)
report = strings.Replace(
report,
` setCurrent(state.selected);`,
` setCurrent(state.selected, true, true);`,
1,
)
return report
}
func replaceTopFilesIndex(report string) string {
const previous = `function buildTopFilesIndex(root) {
const files = [];
collectFiles(root, files);
files.sort((a, b) => b.size - a.size);
return files;
}
`
const replacement = `const TOP_FILE_INDEX_LIMIT = 50;
function buildTopFilesIndex(root) {
const heap = [];
const swap = (left, right) => ([heap[left], heap[right]] = [heap[right], heap[left]]);
const siftUp = index => {
while (index > 0) {
const parent = Math.floor((index - 1) / 2);
if (heap[parent].size <= heap[index].size) break;
swap(parent, index);
index = parent;
}
};
const siftDown = index => {
while (true) {
const left = index * 2 + 1;
const right = left + 1;
let smallest = index;
if (left < heap.length && heap[left].size < heap[smallest].size) smallest = left;
if (right < heap.length && heap[right].size < heap[smallest].size) smallest = right;
if (smallest === index) return;
swap(index, smallest);
index = smallest;
}
};
const add = node => {
if (!node || node.size <= 0) return;
if (heap.length < TOP_FILE_INDEX_LIMIT) {
heap.push(node);
siftUp(heap.length - 1);
} else if (node.size > heap[0].size) {
heap[0] = node;
siftDown(0);
}
};
const stack = root ? [root] : [];
while (stack.length) {
const node = stack.pop();
if (node.type !== "dir") {
add(node);
continue;
}
const children = node.children || [];
for (let index = 0; index < children.length; index++) stack.push(children[index]);
}
return heap.sort((a, b) => b.size - a.size);
}
`
return strings.Replace(report, previous, replacement, 1)
}
func replaceTreeTableFontSize(report string) string {
const tableFontCSS = `.tree-header{font-size:10px}.row{font-size:12px}.row-kind{font-size:9px}.row-count,.row-size,.row-modified,.row-pct{font-size:11px}`
if strings.Contains(report, tableFontCSS) {
return report
}
return strings.Replace(report, `</style>`, tableFontCSS+`</style>`, 1)
}
func replaceTreeColumnSeparators(report string) string {
const separatorCSS = `.tree-header-cell.with-separator{box-shadow:1px 0 0 color-mix(in srgb,var(--line) 68%,transparent)}.row>*:not(:last-child){box-shadow:1px 0 0 color-mix(in srgb,var(--line) 30%,transparent)}`
if !strings.Contains(report, separatorCSS) {
report = strings.Replace(report, `.tree-column-resizer{`, separatorCSS+`.tree-column-resizer{`, 1)
}
report = strings.Replace(
report,
` cell.dataset.column = column.key;
cell.append(content, makeTreeColumnResizer(column));`,
` cell.dataset.column = column.key;
if (column.hasSeparator) cell.classList.add("with-separator");
cell.append(content, makeTreeColumnResizer(column));`,
1,
)
report = strings.Replace(
report,
` const cells = visibleTreeColumns().map(column => {
if (column.key === "name") return makeTreeHeaderCell(column, nameHead);
if (column.sortKey) return makeTreeHeaderCell(column, makeHeaderButton(column.label, column.sortKey, column.numeric));
return makeTreeHeaderCell(column, makeHeaderLabel(column.label, column.numeric));
});`,
` const columns = visibleTreeColumns();
const cells = columns.map((column, index) => {
column.hasSeparator = index < columns.length - 1;
if (column.key === "name") return makeTreeHeaderCell(column, nameHead);
if (column.sortKey) return makeTreeHeaderCell(column, makeHeaderButton(column.label, column.sortKey, column.numeric));
return makeTreeHeaderCell(column, makeHeaderLabel(column.label, column.numeric));
});`,
1,
)
return report
}
func replaceTreeColumnResizing(report string) string {
if !strings.Contains(report, ".tree-column-resizer") {
report = strings.Replace(
report,
`</style>`,
`.tree-header-cell{min-width:0;position:relative;display:flex;align-items:center}.tree-header-cell.numeric{justify-content:flex-end}.tree-header-cell>.tree-sort,.tree-header-cell>.tree-label{flex:1 1 auto}.tree-column-resizer{position:absolute;top:0;right:-5px;z-index:8;width:10px;height:100%;border:0;background:transparent;padding:0;cursor:col-resize;touch-action:none}.tree-column-resizer::after{content:"";position:absolute;top:7px;bottom:7px;left:4px;width:2px;border-radius:999px;background:transparent}.tree-column-resizer:hover::after,.tree-column-resizer:focus-visible::after,.tree-column-resizer.dragging::after{background:var(--accent)}body.resizing-tree-column{cursor:col-resize;user-select:none}body.resizing-tree-column *{cursor:col-resize !important}</style>`,
1,
)
}
if !strings.Contains(report, `const TREE_COLUMN_WIDTH_STORAGE_KEY = "webdiskstat-tree-column-widths";`) {
report = strings.Replace(
report,
`const TREE_COLUMN_STORAGE_KEY = "webdiskstat-tree-columns";`,
`const TREE_COLUMN_STORAGE_KEY = "webdiskstat-tree-columns";
const TREE_COLUMN_WIDTH_STORAGE_KEY = "webdiskstat-tree-column-widths";`,
1,
)
}
if !strings.Contains(report, `columnWidths: {},`) {
report = strings.Replace(
report,
` searchActiveIndex: -1,
visibleColumns: { ...DEFAULT_TREE_COLUMNS }`,
` searchActiveIndex: -1,
visibleColumns: { ...DEFAULT_TREE_COLUMNS },
columnWidths: {}`,
1,
)
}
if !strings.Contains(report, "function readStoredTreeColumnWidths()") {
report = strings.Replace(
report,
`function storeTreeColumns() {
try {
localStorage.setItem(TREE_COLUMN_STORAGE_KEY, JSON.stringify(state.visibleColumns));
} catch (error) {
// Ignore storage failures in strict file contexts.
}
}
`,
`function storeTreeColumns() {
try {
localStorage.setItem(TREE_COLUMN_STORAGE_KEY, JSON.stringify(state.visibleColumns));
} catch (error) {
// Ignore storage failures in strict file contexts.
}
}
function readStoredTreeColumnWidths() {
const widths = {};
try {
const stored = JSON.parse(localStorage.getItem(TREE_COLUMN_WIDTH_STORAGE_KEY) || "{}");
TREE_COLUMNS.forEach(column => {
const width = Number(stored[column.key]);
if (Number.isFinite(width) && width >= column.minWidth) widths[column.key] = width;
});
} catch (error) {
// Column widths are optional; the report still works when storage is unavailable.
}
return widths;
}
function storeTreeColumnWidths() {
try {
localStorage.setItem(TREE_COLUMN_WIDTH_STORAGE_KEY, JSON.stringify(state.columnWidths));
} catch (error) {
// Ignore storage failures in strict file contexts.
}
}
function treeColumnWidth(column) {
const width = Number(state.columnWidths[column.key]);
return Number.isFinite(width) ? Math.max(column.minWidth, width) : 0;
}
`,
1,
)
}
report = strings.Replace(
report,
"function applyTreeColumnLayout() {\n"+
" const columns = visibleTreeColumns();\n"+
" const template = columns.map(column => column.grid).join(\" \");\n"+
" const minWidth = columns.reduce((total, column) => total + column.minWidth, 0) +\n"+
" Math.max(0, columns.length - 1) * 8 +\n"+
" 22;\n"+
" el.tree.style.setProperty(\"--tree-columns\", template);\n"+
" el.tree.style.setProperty(\"--tree-min-width\", `${Math.max(300, minWidth)}px`);\n"+
"}\n",
`function applyTreeColumnLayout() {
const columns = visibleTreeColumns();
const template = columns.map(column => {
const width = treeColumnWidth(column);
return width ? width + "px" : column.grid;
}).join(" ");
const minWidth = columns.reduce((total, column) => total + (treeColumnWidth(column) || column.minWidth), 0) +
Math.max(0, columns.length - 1) * 8 +
22;
el.tree.style.setProperty("--tree-columns", template);
el.tree.style.setProperty("--tree-min-width", Math.max(300, minWidth) + "px");
}
`,
1,
)
if !strings.Contains(report, "function setTreeColumnWidth(column, width)") {
report = strings.Replace(
report,
`function makeTreeColumnsButton(menu) {`,
`function setTreeColumnWidth(column, width) {
state.columnWidths[column.key] = Math.max(column.minWidth, Math.round(width));
applyTreeColumnLayout();
}
function commitTreeColumnWidth(column, width) {
setTreeColumnWidth(column, width);
storeTreeColumnWidths();
}
function beginTreeColumnResize(event, column, handle) {
event.preventDefault();
event.stopPropagation();
const startX = event.clientX;
const startWidth = treeColumnWidth(column) || Math.max(column.minWidth, handle.parentElement.getBoundingClientRect().width);
handle.classList.add("dragging");
document.body.classList.add("resizing-tree-column");
if (handle.setPointerCapture) handle.setPointerCapture(event.pointerId);
const onMove = moveEvent => {
const width = startWidth + moveEvent.clientX - startX;
setTreeColumnWidth(column, width);
};
const onEnd = endEvent => {
window.removeEventListener("pointermove", onMove);
window.removeEventListener("pointerup", onEnd);
window.removeEventListener("pointercancel", onEnd);
handle.classList.remove("dragging");
document.body.classList.remove("resizing-tree-column");
if (handle.releasePointerCapture) handle.releasePointerCapture(endEvent.pointerId);
storeTreeColumnWidths();
};
window.addEventListener("pointermove", onMove);
window.addEventListener("pointerup", onEnd);
window.addEventListener("pointercancel", onEnd);
}
function handleTreeColumnResizeKey(event, column) {
let delta = 0;
if (event.key === "ArrowLeft") delta = -12;
if (event.key === "ArrowRight") delta = 12;
if (!delta) return;
event.preventDefault();
event.stopPropagation();
commitTreeColumnWidth(column, (treeColumnWidth(column) || column.minWidth) + delta);
}
function makeTreeColumnResizer(column) {
const handle = document.createElement("button");
handle.type = "button";
handle.className = "tree-column-resizer";
handle.title = "Resize " + (column.menuLabel || column.label) + " column";
handle.setAttribute("aria-label", handle.title);
handle.addEventListener("pointerdown", event => beginTreeColumnResize(event, column, handle));
handle.addEventListener("keydown", event => handleTreeColumnResizeKey(event, column));
return handle;
}
function makeTreeHeaderCell(column, content) {
const cell = document.createElement("div");
cell.className = column.numeric ? "tree-header-cell numeric" : "tree-header-cell";
cell.dataset.column = column.key;
cell.append(content, makeTreeColumnResizer(column));
return cell;
}
function makeTreeColumnsButton(menu) {`,
1,
)
}
report = strings.Replace(
report,
` const cells = visibleTreeColumns().map(column => {
if (column.key === "name") return nameHead;
if (column.sortKey) return makeHeaderButton(column.label, column.sortKey, column.numeric);
return makeHeaderLabel(column.label, column.numeric);
});
header.append(...cells, columnsMenu);`,
` const cells = visibleTreeColumns().map(column => {
if (column.key === "name") return makeTreeHeaderCell(column, nameHead);
if (column.sortKey) return makeTreeHeaderCell(column, makeHeaderButton(column.label, column.sortKey, column.numeric));
return makeTreeHeaderCell(column, makeHeaderLabel(column.label, column.numeric));
});
header.append(...cells, columnsMenu);`,
1,
)
report = strings.Replace(
report,
` state.visibleColumns = readStoredTreeColumns();
applyTreeColumnLayout();`,
` state.visibleColumns = readStoredTreeColumns();
state.columnWidths = readStoredTreeColumnWidths();
applyTreeColumnLayout();`,
1,
)
return report
}
func replaceEmbeddedFonts(report string) string {
report = strings.ReplaceAll(
report,
`font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif`,
`font-family:"Noto Sans",ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif`,
)
report = strings.ReplaceAll(
report,
`font-family:Lato,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif`,
`font-family:"Noto Sans",ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif`,
)
report = strings.ReplaceAll(
report,
`font-family:"Roboto Mono",ui-monospace,SFMono-Regular,Menlo,Consolas,"Liberation Mono",monospace`,
`font-family:"Noto Sans",ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif`,
)
report = strings.ReplaceAll(
report,
`font-family:Merriweather,Georgia,"Times New Roman",serif`,
`font-family:"Noto Sans",ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif`,
)
report = latoFontFacePattern.ReplaceAllString(report, "")
report = robotoFontFacePattern.ReplaceAllString(report, "")
report = merriFontFacePattern.ReplaceAllString(report, "")
if strings.Contains(report, `@font-face{font-family:"Noto Sans";`) {
return report
}
return strings.Replace(report, "<style>", "<style>"+embeddedFontCSS(), 1)
}
func replaceTreemapMimeColors(report string) string {
const current = `function treemapColorFor(node) {
if (node.ext === "[other]") return TREEMAP_SMALLER_ENTRIES_COLOR;
if (node.type !== "dir") return colorFor(node);
const hash = hashString(pathForNode(node) || node.name || String(node.id));
const hue = 176 + (hash % 26);
const saturation = 52 + (Math.floor(hash / 29) % 18);
const lightness = 28 + (Math.floor(hash / 521) % 24);
return ` + "`hsl(${hue}, ${saturation}%, ${lightness}%)`" + `;
}
`
const replacement = `const TREEMAP_MIME_COLORS = new Map([
["image", "hsl(197, 76%, 43%)"],
["video", "hsl(270, 58%, 50%)"],
["audio", "hsl(316, 62%, 48%)"],
["text", "hsl(148, 52%, 38%)"],
["code", "hsl(168, 68%, 34%)"],
["pdf", "hsl(0, 68%, 50%)"],
["archive", "hsl(36, 80%, 46%)"],
["document", "hsl(218, 58%, 49%)"],
["data", "hsl(44, 78%, 45%)"],
["binary", "hsl(220, 11%, 46%)"],
["font", "hsl(186, 48%, 39%)"]
]);
const TREEMAP_MIME_EXACT_CATEGORIES = new Map([
["application/gzip", "archive"],
["application/javascript", "code"],
["application/json", "data"],
["application/msword", "document"],
["application/octet-stream", "binary"],
["application/pdf", "pdf"],
["application/rtf", "document"],
["application/vnd.ms-excel", "document"],
["application/vnd.ms-powerpoint", "document"],
["application/vnd.openxmlformats-officedocument.presentationml.presentation", "document"],
["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "document"],
["application/vnd.openxmlformats-officedocument.wordprocessingml.document", "document"],
["application/x-7z-compressed", "archive"],
["application/x-bzip2", "archive"],
["application/x-rar-compressed", "archive"],
["application/x-tar", "archive"],
["application/xml", "data"],
["application/zip", "archive"],
["text/css", "code"],
["text/html", "code"],
["text/javascript", "code"],
["text/markdown", "text"],
["text/xml", "data"]
]);
const TREEMAP_EXTENSION_CATEGORIES = new Map([
[".7z", "archive"], [".bz2", "archive"], [".gz", "archive"], [".rar", "archive"], [".tar", "archive"], [".tgz", "archive"], [".zip", "archive"],
[".csv", "data"], [".json", "data"], [".xml", "data"], [".yaml", "data"], [".yml", "data"],
[".css", "code"], [".html", "code"], [".js", "code"], [".jsx", "code"], [".ts", "code"], [".tsx", "code"], [".go", "code"], [".py", "code"], [".php", "code"], [".rb", "code"], [".rs", "code"], [".sh", "code"], [".sql", "code"],
[".doc", "document"], [".docx", "document"], [".ppt", "document"], [".pptx", "document"], [".rtf", "document"], [".xls", "document"], [".xlsx", "document"],
[".pdf", "pdf"],
[".bin", "binary"], [".dll", "binary"], [".exe", "binary"], [".o", "binary"], [".so", "binary"],
[".md", "text"], [".txt", "text"],
[".otf", "font"], [".ttf", "font"], [".woff", "font"], [".woff2", "font"]
]);
const treemapMimeWeightsCache = new WeakMap();
function normalizeMime(value) {
return String(value || "").split(";")[0].trim().toLowerCase();
}
function treemapMimeCategoryForFile(node) {
const mime = normalizeMime(node && node.mime);
if (mime) {
if (TREEMAP_MIME_EXACT_CATEGORIES.has(mime)) return TREEMAP_MIME_EXACT_CATEGORIES.get(mime);
const family = mime.split("/")[0];
if (TREEMAP_MIME_COLORS.has(family)) return family;
}
const ext = String(node && node.ext || "").toLowerCase();
if (TREEMAP_EXTENSION_CATEGORIES.has(ext)) return TREEMAP_EXTENSION_CATEGORIES.get(ext);
return "";
}
function treemapMimeWeightsForNode(node) {
if (!node) return new Map();
if (treemapMimeWeightsCache.has(node)) return treemapMimeWeightsCache.get(node);
const weights = new Map();
if (node.type !== "dir") {
const category = treemapMimeCategoryForFile(node);
if (category) weights.set(category, Math.max(1, Number(node.size) || 0));
} else {
(node.children || []).forEach(child => {
treemapMimeWeightsForNode(child).forEach((size, category) => {
weights.set(category, (weights.get(category) || 0) + size);
});
});
}
treemapMimeWeightsCache.set(node, weights);
return weights;
}
function dominantTreemapMimeCategory(node) {
let bestCategory = "";
let bestSize = -1;
treemapMimeWeightsForNode(node).forEach((size, category) => {
if (size > bestSize || (size === bestSize && category < bestCategory)) {
bestCategory = category;
bestSize = size;
}
});
return bestCategory;
}
function directoryTreemapColorFor(node) {
const hash = hashString(pathForNode(node) || node.name || String(node.id));
const hue = 176 + (hash % 26);
const saturation = 52 + (Math.floor(hash / 29) % 18);
const lightness = 28 + (Math.floor(hash / 521) % 24);
return ` + "`hsl(${hue}, ${saturation}%, ${lightness}%)`" + `;
}
function treemapColorFor(node) {
if (node.ext === "[other]") return TREEMAP_SMALLER_ENTRIES_COLOR;
const category = node.type === "dir" ? dominantTreemapMimeCategory(node) : treemapMimeCategoryForFile(node);
if (category && TREEMAP_MIME_COLORS.has(category)) return TREEMAP_MIME_COLORS.get(category);
return node.type === "dir" ? directoryTreemapColorFor(node) : colorFor(node);
}
`
if strings.Contains(report, current) {
return strings.Replace(report, current, replacement, 1)
}
if strings.Contains(report, "function treemapMimeCategoryForFile(node)") {
return report
}
return strings.Replace(
report,
`function treemapColorFor(node) {`,
replacement+`
function treemapColorForLegacy(node) {`,
1,
)
}
func replaceTreemapPalette(report string) string {
replacer := strings.NewReplacer(
`["image", "hsl(197, 76%, 43%)"]`, `["image", "#0EA5E9"]`,
`["video", "hsl(270, 58%, 50%)"]`, `["video", "#8B5CF6"]`,
`["audio", "hsl(316, 62%, 48%)"]`, `["audio", "#EC4899"]`,
`["text", "hsl(148, 52%, 38%)"]`, `["text", "#22C55E"]`,
`["code", "hsl(168, 68%, 34%)"]`, `["code", "#14B8A6"]`,
`["pdf", "hsl(0, 68%, 50%)"]`, `["pdf", "#EF4444"]`,
`["archive", "hsl(36, 80%, 46%)"]`, `["archive", "#F97316"]`,
`["document", "hsl(218, 58%, 49%)"]`, `["document", "#3B82F6"]`,
`["data", "hsl(44, 78%, 45%)"]`, `["data", "#EAB308"]`,
`["binary", "hsl(220, 11%, 46%)"]`, `["binary", "#64748B"]`,
`["font", "hsl(186, 48%, 39%)"]`, `["font", "#06B6D4"]`,
`["image", "#005F88"]`, `["image", "#0EA5E9"]`,
`["video", "#5B3F9B"]`, `["video", "#8B5CF6"]`,
`["audio", "#9B2C6B"]`, `["audio", "#EC4899"]`,
`["text", "#16734B"]`, `["text", "#22C55E"]`,
`["code", "#006B70"]`, `["code", "#14B8A6"]`,
`["pdf", "#B3261E"]`, `["pdf", "#EF4444"]`,
`["archive", "#8A5700"]`, `["archive", "#F97316"]`,
`["document", "#245DA6"]`, `["document", "#3B82F6"]`,
`["data", "#765600"]`, `["data", "#EAB308"]`,
`["binary", "#4B5563"]`, `["binary", "#64748B"]`,
`["font", "#176078"]`, `["font", "#06B6D4"]`,
`const TREEMAP_SMALLER_ENTRIES_COLOR = "#64748b";`, `const TREEMAP_SMALLER_ENTRIES_COLOR = "#475569";`,
`const TREEMAP_SMALLER_ENTRIES_COLOR = "#1E293B";`, `const TREEMAP_SMALLER_ENTRIES_COLOR = "#475569";`,
)
report = replacer.Replace(report)
const directoryPalette = `const TREEMAP_DIRECTORY_COLORS = [
"#2563EB", "#4F46E5", "#7C3AED", "#A21CAF",
"#DB2777", "#E11D48", "#EA580C", "#D97706",
"#65A30D", "#16A34A", "#0D9488", "#0891B2"
];`
report = strings.Replace(report, `const TREEMAP_DIRECTORY_COLOR = "#1E293B";`, directoryPalette, 1)
if !strings.Contains(report, `const TREEMAP_DIRECTORY_COLORS = [`) {
report = strings.Replace(
report,
`const TREEMAP_MIME_COLORS = new Map([`,
directoryPalette+`
const TREEMAP_MIME_COLORS = new Map([`,
1,
)
}
report = strings.Replace(
report,
`function treemapColorFor(node) {
if (node.ext === "[other]") return TREEMAP_SMALLER_ENTRIES_COLOR;
const category = node.type === "dir" ? dominantTreemapMimeCategory(node) : treemapMimeCategoryForFile(node);
if (category && TREEMAP_MIME_COLORS.has(category)) return TREEMAP_MIME_COLORS.get(category);
return node.type === "dir" ? directoryTreemapColorFor(node) : colorFor(node);
}`,
`function treemapColorFor(node) {
if (node.ext === "[other]") return TREEMAP_SMALLER_ENTRIES_COLOR;
if (node.type === "dir") return directoryTreemapColorFor(node);
const category = treemapMimeCategoryForFile(node);
if (category && TREEMAP_MIME_COLORS.has(category)) return TREEMAP_MIME_COLORS.get(category);
return colorFor(node);
}`,
1,
)
report = strings.ReplaceAll(report, `rgba(2,6,23,.64) 0%,rgba(2,6,23,.32) 72%`, `rgba(2,6,23,.56) 0%,rgba(2,6,23,.20) 72%`)
const labelCSS = `.tile-label{background:linear-gradient(90deg,rgba(2,6,23,.56) 0%,rgba(2,6,23,.20) 72%,transparent 100%);border-radius:3px;text-shadow:0 1px 2px rgba(0,0,0,.7)}`
if !strings.Contains(report, labelCSS) {
report = strings.Replace(report, `</style>`, labelCSS+`</style>`, 1)
}
return report
}
func replaceTreemapStyles(report string) string {
report = strings.ReplaceAll(
report,
`box-shadow:inset 0 0 0 2px rgba(255,255,255,0.58),inset 0 0 0 999px rgba(255,255,255,0.10)`,
`box-shadow:inset 0 0 0 1px rgba(255,255,255,0.40),inset 0 0 0 999px rgba(255,255,255,0.04)`,
)
report = strings.ReplaceAll(
report,
`box-shadow:inset 0 0 0 1px rgba(255,255,255,0.48),inset 0 0 0 999px rgba(255,255,255,0.08)`,
`box-shadow:inset 0 0 0 1px rgba(255,255,255,0.40),inset 0 0 0 999px rgba(255,255,255,0.04)`,
)
report = strings.ReplaceAll(
report,
`color-mix(in srgb,var(--tile-color,#0f766e) 82%,white 18%)`,
`color-mix(in srgb,var(--tile-color,#1E293B) 90%,white 10%)`,
)
report = strings.ReplaceAll(report, `var(--tile-color,#0f766e) 45%`, `var(--tile-color,#1E293B) 45%`)
report = strings.ReplaceAll(report, `var(--tile-color,#0f766e) 60%`, `var(--tile-color,#1E293B) 60%`)
report = strings.ReplaceAll(
report,
`.tile-children{position:absolute;overflow:hidden;border-radius:5px}`,
`.tile-children{position:absolute;overflow:hidden;border-radius:2px}`,
)
report = strings.ReplaceAll(
report,
`.tile.nested{border-width:1px}`,
`.tile.nested{border-width:.5px;border-radius:2px}`,
)
return report
}
func replaceMaterialFileIcons(report string) string {
const materialIconLookupFunction = `function materialIconLookupName(node) {
if (!node || node.type === "dir") return "";
const name = String(node.name || "").trim();
if (name) return name;
const path = String(node.path || "").trim();
if (path) {
const parts = path.split("/").filter(Boolean);
return parts.length ? parts[parts.length - 1] : path;
}
const ext = String(node.ext || "").trim();
return ext && ext !== "[no extension]" ? ` + "`file${ext.startsWith(\".\") ? ext : \".\" + ext}`" + ` : "file";
}
`
const oldMaterialIconLookupFunction = `function materialIconLookupName(node) {
if (!node || node.type === "dir") return "";
const mime = String(node.mime || "").split(";")[0].trim().toLowerCase();
if (MIME_ICON_FILENAMES.has(mime)) return MIME_ICON_FILENAMES.get(mime);
const family = mime.split("/")[0];
if (MIME_FAMILY_ICON_FILENAMES.has(family)) return MIME_FAMILY_ICON_FILENAMES.get(family);
return node.name || node.ext || "file";
}
`
if !strings.Contains(report, "const MaterialFileIcons = (() => {") {
wrapper := "<script>\nconst MaterialFileIcons = (() => {\nconst exports = {};\nconst module = { exports };\n" +
materialFileIconsBundle +
"\nreturn module.exports && Object.keys(module.exports).length ? module.exports : exports;\n})();\n</script>\n"
report = strings.Replace(report, "<script>\nconst REPORT_DATA_PAYLOAD = ", wrapper+"<script>\nconst REPORT_DATA_PAYLOAD = ", 1)
}
report = strings.Replace(
report,
`.swatch{width:10px;height:10px;border-radius:2px;flex:0 0 auto;background:var(--row-color,#2563eb);box-shadow:inset 0 0 0 1px rgba(0,0,0,0.16)}`,
`.swatch{width:18px;height:18px;flex:0 0 auto;display:inline-grid;place-items:center;overflow:hidden}.material-file-icon svg{width:100%;height:100%;display:block}`,
1,
)
report = strings.Replace(
report,
`.row.file .swatch{border-radius:50%}`,
`.row.file .swatch{border-radius:0;background:transparent;box-shadow:none}`,
1,
)
report = strings.Replace(
report,
`.top-file-row{display:grid;grid-template-columns:minmax(0,1fr) 120px;align-items:center;gap:12px;padding:10px 14px}`,
`.top-file-row{display:grid;grid-template-columns:20px minmax(0,1fr) 120px;align-items:center;gap:10px;padding:10px 14px}`,
1,
)
if !strings.Contains(report, "const MIME_ICON_FILENAMES = new Map(") {
report = strings.Replace(
report,
`function normalizeSearchText(value) {
return String(value || "").trim().toLowerCase();
}
`,
`const MIME_ICON_FILENAMES = new Map([
["application/gzip", "archive.gz"],
["application/javascript", "file.js"],
["application/json", "file.json"],
["application/msword", "file.doc"],
["application/octet-stream", "file.bin"],
["application/pdf", "file.pdf"],
["application/rtf", "file.rtf"],
["application/vnd.ms-excel", "file.xls"],
["application/vnd.ms-powerpoint", "file.ppt"],
["application/vnd.openxmlformats-officedocument.presentationml.presentation", "file.pptx"],
["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "file.xlsx"],
["application/vnd.openxmlformats-officedocument.wordprocessingml.document", "file.docx"],
["application/x-7z-compressed", "archive.7z"],
["application/x-bzip2", "archive.bz2"],
["application/x-rar-compressed", "archive.rar"],
["application/x-tar", "archive.tar"],
["application/xml", "file.xml"],
["application/zip", "archive.zip"],
["text/css", "file.css"],
["text/csv", "file.csv"],
["text/html", "file.html"],
["text/javascript", "file.js"],
["text/markdown", "file.md"],
["text/plain", "file.txt"],
["text/xml", "file.xml"]
]);
const MIME_FAMILY_ICON_FILENAMES = new Map([
["audio", "file.mp3"],
["image", "file.png"],
["text", "file.txt"],
["video", "file.mp4"]
]);
const materialIconCache = new Map();
function normalizeSearchText(value) {
return String(value || "").trim().toLowerCase();
}
`,
1,
)
}
if !strings.Contains(report, "function makeFileIcon(node)") {
report = strings.Replace(
report,
`function makeParentHeaderButton() {
const button = document.createElement("button");`,
materialIconLookupFunction+`
function materialIconSVG(node) {
const lookupName = materialIconLookupName(node);
if (!lookupName) return "";
if (materialIconCache.has(lookupName)) return materialIconCache.get(lookupName);
const icon = MaterialFileIcons && typeof MaterialFileIcons.getIcon === "function"
? MaterialFileIcons.getIcon(lookupName)
: null;
const svg = icon && icon.svg ? icon.svg : "";
materialIconCache.set(lookupName, svg);
return svg;
}
function makeFileIcon(node) {
const icon = document.createElement("span");
icon.className = "swatch";
if (!node || node.type === "dir") return icon;
icon.classList.add("material-file-icon");
icon.innerHTML = materialIconSVG(node);
return icon;
}
function makeParentHeaderButton() {
const button = document.createElement("button");`,
1,
)
}
report = strings.Replace(report, oldMaterialIconLookupFunction, materialIconLookupFunction, 1)
report = strings.Replace(
report,
` const swatch = document.createElement("span");
swatch.className = "swatch";`,
` const swatch = makeFileIcon(child);`,
1,
)
report = strings.Replace(
report,
` main.append(name, path);
row.append(main, size);`,
` main.append(name, path);
row.append(makeFileIcon(file), main, size);`,
1,
)
for strings.Contains(report, ` main.append(name, path);
main.append(name, path);`,