@jsenv/core 39.7.1 → 39.7.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.
package/dist/js/autoreload.js
CHANGED
|
@@ -140,20 +140,18 @@ This could be due to syntax errors or importing non-existent modules (see errors
|
|
|
140
140
|
dispatchBeforePrune();
|
|
141
141
|
delete urlHotMetas[urlToFetch];
|
|
142
142
|
if (urlHotMeta.disposeCallback) {
|
|
143
|
-
console.
|
|
143
|
+
console.log(
|
|
144
144
|
`[jsenv] cleanup ${boundary} (no longer referenced by ${acceptedBy})`,
|
|
145
145
|
);
|
|
146
|
-
console.log(`call dispose callback`);
|
|
147
146
|
await urlHotMeta.disposeCallback();
|
|
148
|
-
console.groupEnd();
|
|
149
147
|
}
|
|
150
148
|
}
|
|
151
149
|
continue;
|
|
152
150
|
}
|
|
153
151
|
if (acceptedBy === boundary) {
|
|
154
|
-
console.
|
|
152
|
+
console.log(`[jsenv] hot reloading ${boundary} (${cause})`);
|
|
155
153
|
} else {
|
|
156
|
-
console.
|
|
154
|
+
console.log(
|
|
157
155
|
`[jsenv] hot reloading ${acceptedBy} usage in ${boundary} (${cause})`,
|
|
158
156
|
);
|
|
159
157
|
}
|
|
@@ -163,10 +161,8 @@ This could be due to syntax errors or importing non-existent modules (see errors
|
|
|
163
161
|
continue;
|
|
164
162
|
}
|
|
165
163
|
if (urlHotMeta.disposeCallback) {
|
|
166
|
-
console.log(`call dispose callback`);
|
|
167
164
|
await urlHotMeta.disposeCallback();
|
|
168
165
|
}
|
|
169
|
-
console.log(`importing js module`);
|
|
170
166
|
reloader.currentExecution = {
|
|
171
167
|
type: "dynamic_import",
|
|
172
168
|
url: urlToFetch,
|
|
@@ -175,8 +171,6 @@ This could be due to syntax errors or importing non-existent modules (see errors
|
|
|
175
171
|
if (urlHotMeta.acceptCallback) {
|
|
176
172
|
await urlHotMeta.acceptCallback(namespace);
|
|
177
173
|
}
|
|
178
|
-
console.log(`js module import done`);
|
|
179
|
-
console.groupEnd();
|
|
180
174
|
continue;
|
|
181
175
|
}
|
|
182
176
|
if (type === "html") {
|
|
@@ -210,7 +204,6 @@ This could be due to syntax errors or importing non-existent modules (see errors
|
|
|
210
204
|
domNodesUsingUrl.reload(hot);
|
|
211
205
|
});
|
|
212
206
|
}
|
|
213
|
-
console.groupEnd();
|
|
214
207
|
continue;
|
|
215
208
|
}
|
|
216
209
|
console.warn(`unknown update type: "${type}"`);
|
package/dist/jsenv_core.js
CHANGED
|
@@ -3906,6 +3906,24 @@ const ensureEmptyDirectory = async (source) => {
|
|
|
3906
3906
|
);
|
|
3907
3907
|
};
|
|
3908
3908
|
|
|
3909
|
+
const callOnceIdlePerFile = (callback, idleMs) => {
|
|
3910
|
+
const timeoutIdMap = new Map();
|
|
3911
|
+
return (fileEvent) => {
|
|
3912
|
+
const { relativeUrl } = fileEvent;
|
|
3913
|
+
let timeoutId = timeoutIdMap.get(relativeUrl);
|
|
3914
|
+
if (timeoutId) {
|
|
3915
|
+
clearTimeout(timeoutId);
|
|
3916
|
+
}
|
|
3917
|
+
timeoutId = setTimeout(() => {
|
|
3918
|
+
callback(fileEvent);
|
|
3919
|
+
}, idleMs);
|
|
3920
|
+
if (timeoutId.unref) {
|
|
3921
|
+
timeoutId.unref();
|
|
3922
|
+
}
|
|
3923
|
+
timeoutIdMap.set(relativeUrl, timeoutId);
|
|
3924
|
+
};
|
|
3925
|
+
};
|
|
3926
|
+
|
|
3909
3927
|
const isWindows = process.platform === "win32";
|
|
3910
3928
|
|
|
3911
3929
|
const createWatcher = (sourcePath, options) => {
|
|
@@ -4001,6 +4019,7 @@ const registerDirectoryLifecycle = (
|
|
|
4001
4019
|
// For this reason"cooldownBetweenFileEvents" should be reserved to scenarios
|
|
4002
4020
|
// like unit tests
|
|
4003
4021
|
cooldownBetweenFileEvents = 0,
|
|
4022
|
+
idleMs = 50,
|
|
4004
4023
|
},
|
|
4005
4024
|
) => {
|
|
4006
4025
|
const sourceUrl = assertAndNormalizeDirectoryUrl(source);
|
|
@@ -4017,6 +4036,11 @@ const registerDirectoryLifecycle = (
|
|
|
4017
4036
|
`removed must be a function or undefined, got ${removed}`,
|
|
4018
4037
|
);
|
|
4019
4038
|
}
|
|
4039
|
+
if (idleMs) {
|
|
4040
|
+
if (updated) {
|
|
4041
|
+
updated = callOnceIdlePerFile(updated, idleMs);
|
|
4042
|
+
}
|
|
4043
|
+
}
|
|
4020
4044
|
if (cooldownBetweenFileEvents) {
|
|
4021
4045
|
if (added) {
|
|
4022
4046
|
added = guardTooFastSecondCallPerFile(added, cooldownBetweenFileEvents);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/core",
|
|
3
|
-
"version": "39.7.
|
|
3
|
+
"version": "39.7.3",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"@financial-times/polyfill-useragent-normaliser": "1.10.2",
|
|
71
71
|
"@jsenv/abort": "4.3.0",
|
|
72
72
|
"@jsenv/ast": "6.4.0",
|
|
73
|
-
"@jsenv/filesystem": "4.
|
|
73
|
+
"@jsenv/filesystem": "4.11.0",
|
|
74
74
|
"@jsenv/humanize": "1.2.8",
|
|
75
75
|
"@jsenv/importmap": "1.2.1",
|
|
76
76
|
"@jsenv/integrity": "0.0.2",
|
|
@@ -153,20 +153,21 @@ This could be due to syntax errors or importing non-existent modules (see errors
|
|
|
153
153
|
dispatchBeforePrune();
|
|
154
154
|
delete urlHotMetas[urlToFetch];
|
|
155
155
|
if (urlHotMeta.disposeCallback) {
|
|
156
|
-
console.
|
|
156
|
+
console.log(
|
|
157
157
|
`[jsenv] cleanup ${boundary} (no longer referenced by ${acceptedBy})`,
|
|
158
158
|
);
|
|
159
|
-
|
|
159
|
+
if (debug) {
|
|
160
|
+
console.log(`call dispose callback`);
|
|
161
|
+
}
|
|
160
162
|
await urlHotMeta.disposeCallback();
|
|
161
|
-
console.groupEnd();
|
|
162
163
|
}
|
|
163
164
|
}
|
|
164
165
|
continue;
|
|
165
166
|
}
|
|
166
167
|
if (acceptedBy === boundary) {
|
|
167
|
-
console.
|
|
168
|
+
console.log(`[jsenv] hot reloading ${boundary} (${cause})`);
|
|
168
169
|
} else {
|
|
169
|
-
console.
|
|
170
|
+
console.log(
|
|
170
171
|
`[jsenv] hot reloading ${acceptedBy} usage in ${boundary} (${cause})`,
|
|
171
172
|
);
|
|
172
173
|
}
|
|
@@ -176,10 +177,14 @@ This could be due to syntax errors or importing non-existent modules (see errors
|
|
|
176
177
|
continue;
|
|
177
178
|
}
|
|
178
179
|
if (urlHotMeta.disposeCallback) {
|
|
179
|
-
|
|
180
|
+
if (debug) {
|
|
181
|
+
console.log(`call dispose callback`);
|
|
182
|
+
}
|
|
180
183
|
await urlHotMeta.disposeCallback();
|
|
181
184
|
}
|
|
182
|
-
|
|
185
|
+
if (debug) {
|
|
186
|
+
console.log(`importing js module`);
|
|
187
|
+
}
|
|
183
188
|
reloader.currentExecution = {
|
|
184
189
|
type: "dynamic_import",
|
|
185
190
|
url: urlToFetch,
|
|
@@ -188,8 +193,9 @@ This could be due to syntax errors or importing non-existent modules (see errors
|
|
|
188
193
|
if (urlHotMeta.acceptCallback) {
|
|
189
194
|
await urlHotMeta.acceptCallback(namespace);
|
|
190
195
|
}
|
|
191
|
-
|
|
192
|
-
|
|
196
|
+
if (debug) {
|
|
197
|
+
console.log(`js module import done`);
|
|
198
|
+
}
|
|
193
199
|
continue;
|
|
194
200
|
}
|
|
195
201
|
if (type === "html") {
|
|
@@ -223,7 +229,6 @@ This could be due to syntax errors or importing non-existent modules (see errors
|
|
|
223
229
|
domNodesUsingUrl.reload(hot);
|
|
224
230
|
});
|
|
225
231
|
}
|
|
226
|
-
console.groupEnd();
|
|
227
232
|
continue;
|
|
228
233
|
}
|
|
229
234
|
console.warn(`unknown update type: "${type}"`);
|