svelte-log-view 6.4.0 → 7.0.0
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.
- package/package.json +2 -2
- package/src/LogView.svelte +42 -27
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-log-view",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": true
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@semantic-release/release-notes-generator": "^14.1.0",
|
|
47
47
|
"@sveltejs/vite-plugin-svelte": "^6.2.1",
|
|
48
48
|
"documentation": "^14.0.3",
|
|
49
|
-
"mf-styling": "^3.
|
|
49
|
+
"mf-styling": "^3.3.0",
|
|
50
50
|
"npm-pkgbuild": "^19.1.2",
|
|
51
51
|
"playwright": "^1.57.0",
|
|
52
52
|
"reader-line-iterator": "^1.2.3",
|
package/src/LogView.svelte
CHANGED
|
@@ -2,23 +2,26 @@
|
|
|
2
2
|
import { onDestroy } from "svelte";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* line 1 |
|
|
6
|
-
* line 2 | ->
|
|
7
|
-
* ----------
|
|
8
|
-
* | line 4 | |
|
|
9
|
-
* | line 5 | | ->
|
|
10
|
-
* | line 5 | |
|
|
11
|
-
* ----------
|
|
12
|
-
* line 6
|
|
5
|
+
* line 1 | \
|
|
6
|
+
* line 2 | -> offsetEntries. |
|
|
7
|
+
* ---------- |
|
|
8
|
+
* | line 4 | | |
|
|
9
|
+
* | line 5 | | -> visibleEntries. | -> maxBufferedEntries
|
|
10
|
+
* | line 5 | | |
|
|
11
|
+
* ---------- |
|
|
12
|
+
* line 6 /
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
let {
|
|
16
|
-
source
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
source /** data source */,
|
|
17
|
+
visibleEntries = $bindable(24) /** number of rows in the dom */,
|
|
18
|
+
offsetEntries = $bindable(
|
|
19
|
+
0
|
|
20
|
+
) /** number of rows from the top to the 1st. visible */,
|
|
19
21
|
follow = $bindable(true),
|
|
20
22
|
selected = $bindable(0),
|
|
21
|
-
|
|
23
|
+
numberOfEntriesToFetch = 10 /** number of rows to fetch if we reach outside of the buffered area */,
|
|
24
|
+
maxBufferedEntries = 1024,
|
|
22
25
|
row
|
|
23
26
|
} = $props();
|
|
24
27
|
|
|
@@ -43,11 +46,15 @@
|
|
|
43
46
|
for await (const entry of source.fetch(current)) {
|
|
44
47
|
entries.push(entry);
|
|
45
48
|
|
|
46
|
-
if (entries.
|
|
49
|
+
if (entries.lenght >= maxBufferedEntries) {
|
|
50
|
+
entries.shift();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (entries.length <= visibleEntries) {
|
|
47
54
|
visible = entries;
|
|
48
55
|
} else {
|
|
49
56
|
if (!follow) {
|
|
50
|
-
visible = entries.slice(
|
|
57
|
+
visible = entries.slice(offsetEntries, visibleEntries);
|
|
51
58
|
}
|
|
52
59
|
}
|
|
53
60
|
|
|
@@ -64,31 +71,39 @@
|
|
|
64
71
|
|
|
65
72
|
if (selected > entries.length - 1) {
|
|
66
73
|
selected = entries.length - 1;
|
|
67
|
-
|
|
74
|
+
offsetEntries = entries.length - visibleEntries;
|
|
68
75
|
}
|
|
69
76
|
|
|
70
77
|
if (selected < 0) {
|
|
71
78
|
const additionalEntries = [];
|
|
72
79
|
|
|
73
|
-
for await (const entry of source.fetch(
|
|
80
|
+
for await (const entry of source.fetch(
|
|
81
|
+
entries[0],
|
|
82
|
+
-numberOfEntriesToFetch,
|
|
83
|
+
numberOfEntriesToFetch
|
|
84
|
+
)) {
|
|
74
85
|
additionalEntries.push(entry);
|
|
75
86
|
}
|
|
76
87
|
|
|
77
88
|
entries.unshift(...additionalEntries);
|
|
78
89
|
|
|
90
|
+
if (entries.lenght >= maxBufferedEntries) {
|
|
91
|
+
entries.length = maxBufferedEntries;
|
|
92
|
+
}
|
|
93
|
+
|
|
79
94
|
selected += additionalEntries.length;
|
|
80
|
-
|
|
95
|
+
offsetEntries += additionalEntries.length;
|
|
81
96
|
}
|
|
82
97
|
|
|
83
|
-
if (selected <
|
|
84
|
-
|
|
98
|
+
if (selected < offsetEntries) {
|
|
99
|
+
offsetEntries = selected;
|
|
85
100
|
}
|
|
86
101
|
|
|
87
|
-
if (selected >=
|
|
88
|
-
|
|
102
|
+
if (selected >= offsetEntries + visibleEntries) {
|
|
103
|
+
offsetEntries = selected - visibleEntries + 1;
|
|
89
104
|
}
|
|
90
105
|
|
|
91
|
-
visible = entries.slice(
|
|
106
|
+
visible = entries.slice(offsetEntries, offsetEntries + visibleEntries);
|
|
92
107
|
}
|
|
93
108
|
|
|
94
109
|
function setFollow(flag) {
|
|
@@ -114,11 +129,11 @@
|
|
|
114
129
|
break;
|
|
115
130
|
case "PageUp":
|
|
116
131
|
setFollow(false);
|
|
117
|
-
setSelected(selected -
|
|
132
|
+
setSelected(selected - visibleEntries);
|
|
118
133
|
break;
|
|
119
134
|
case "PageDown":
|
|
120
135
|
setFollow(false);
|
|
121
|
-
setSelected(selected +
|
|
136
|
+
setSelected(selected + visibleEntries);
|
|
122
137
|
break;
|
|
123
138
|
case "End":
|
|
124
139
|
case "G":
|
|
@@ -139,14 +154,14 @@
|
|
|
139
154
|
function onclick(event) {
|
|
140
155
|
setFollow(false);
|
|
141
156
|
const totalHeight = content.getBoundingClientRect().height;
|
|
142
|
-
const rowHeight = totalHeight /
|
|
143
|
-
setSelected(
|
|
157
|
+
const rowHeight = totalHeight / visibleEntries;
|
|
158
|
+
setSelected(offsetEntries + Math.floor(event.clientY / rowHeight));
|
|
144
159
|
}
|
|
145
160
|
</script>
|
|
146
161
|
|
|
147
162
|
<svelte:window {onkeydown} />
|
|
148
163
|
<log-content {onclick} {onkeydown} bind:this={content} role="none">
|
|
149
164
|
{#each visible as entry, i (i)}
|
|
150
|
-
{@render row(entry, selected,
|
|
165
|
+
{@render row(entry, selected, offsetEntries + i, follow)}
|
|
151
166
|
{/each}
|
|
152
167
|
</log-content>
|