html-bundle 6.1.6 → 6.1.7
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/dist/utils.mjs +10 -4
- package/package.json +5 -5
- package/src/utils.mts +10 -4
package/dist/utils.mjs
CHANGED
|
@@ -125,7 +125,9 @@ function getHMRCode(file, id, src) {
|
|
|
125
125
|
}, 1000);
|
|
126
126
|
});
|
|
127
127
|
window.eventsource${id}.addEventListener("message", ({ data }) => {
|
|
128
|
-
window.lastScroll
|
|
128
|
+
if (window.lastScroll == null) {
|
|
129
|
+
window.lastScroll = window.scrollY;
|
|
130
|
+
}
|
|
129
131
|
const dataObj = JSON.parse(data);
|
|
130
132
|
const file = "${file}";
|
|
131
133
|
|
|
@@ -141,10 +143,14 @@ function getHMRCode(file, id, src) {
|
|
|
141
143
|
|
|
142
144
|
if (dataObj.html.startsWith('<!DOCTYPE html>') || dataObj.html.startsWith('<html')) {
|
|
143
145
|
document.head.remove(); // Don't try to diff the head – just re-run the scripts
|
|
144
|
-
|
|
145
|
-
|
|
146
|
+
|
|
147
|
+
// Restore Scroll
|
|
148
|
+
window.addEventListener("afterRouting", () => {
|
|
146
149
|
window.scrollTo(0, window.lastScroll);
|
|
147
|
-
|
|
150
|
+
delete window.lastScroll;
|
|
151
|
+
}, { once: true })
|
|
152
|
+
|
|
153
|
+
render(newHTML, document.documentElement, false);
|
|
148
154
|
} else {
|
|
149
155
|
const hmrID = "${id}";
|
|
150
156
|
const hmrElems = Array.from(newHTML.childNodes);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "html-bundle",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.7",
|
|
4
4
|
"description": "A very simple bundler for HTML SFC",
|
|
5
5
|
"bin": "./dist/bundle.mjs",
|
|
6
6
|
"types": "./src/config.d.ts",
|
|
@@ -32,17 +32,17 @@
|
|
|
32
32
|
},
|
|
33
33
|
"bugs": "https://github.com/Krutsch/html-bundle/issues",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@fastify/static": "^8.0.
|
|
35
|
+
"@fastify/static": "^8.0.1",
|
|
36
36
|
"@web/parse5-utils": "^2.1.0",
|
|
37
37
|
"await-spawn": "^4.0.2",
|
|
38
|
-
"chokidar": "^4.0.
|
|
38
|
+
"chokidar": "^4.0.1",
|
|
39
39
|
"critters": "^0.0.24",
|
|
40
40
|
"cssnano": "^7.0.6",
|
|
41
|
-
"esbuild": "^0.
|
|
41
|
+
"esbuild": "^0.24.0",
|
|
42
42
|
"fastify": "^5.0.0",
|
|
43
43
|
"glob": "^11.0.0",
|
|
44
44
|
"html-minifier-terser": "^7.2.0",
|
|
45
|
-
"hydro-js": "^1.5.
|
|
45
|
+
"hydro-js": "^1.5.21",
|
|
46
46
|
"parse5": "^7.1.2",
|
|
47
47
|
"postcss": "^8.4.47",
|
|
48
48
|
"postcss-load-config": "^6.0.1"
|
package/src/utils.mts
CHANGED
|
@@ -168,7 +168,9 @@ function getHMRCode(file: string, id: string, src: string) {
|
|
|
168
168
|
}, 1000);
|
|
169
169
|
});
|
|
170
170
|
window.eventsource${id}.addEventListener("message", ({ data }) => {
|
|
171
|
-
window.lastScroll
|
|
171
|
+
if (window.lastScroll == null) {
|
|
172
|
+
window.lastScroll = window.scrollY;
|
|
173
|
+
}
|
|
172
174
|
const dataObj = JSON.parse(data);
|
|
173
175
|
const file = "${file}";
|
|
174
176
|
|
|
@@ -184,10 +186,14 @@ function getHMRCode(file: string, id: string, src: string) {
|
|
|
184
186
|
|
|
185
187
|
if (dataObj.html.startsWith('<!DOCTYPE html>') || dataObj.html.startsWith('<html')) {
|
|
186
188
|
document.head.remove(); // Don't try to diff the head – just re-run the scripts
|
|
187
|
-
|
|
188
|
-
|
|
189
|
+
|
|
190
|
+
// Restore Scroll
|
|
191
|
+
window.addEventListener("afterRouting", () => {
|
|
189
192
|
window.scrollTo(0, window.lastScroll);
|
|
190
|
-
|
|
193
|
+
delete window.lastScroll;
|
|
194
|
+
}, { once: true })
|
|
195
|
+
|
|
196
|
+
render(newHTML, document.documentElement, false);
|
|
191
197
|
} else {
|
|
192
198
|
const hmrID = "${id}";
|
|
193
199
|
const hmrElems = Array.from(newHTML.childNodes);
|