dsh-unlag 1.9.105 → 1.9.107
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/index.js +14 -4
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from 'node:async_hooks'
|
|
2
2
|
import { createHash } from 'node:crypto'
|
|
3
|
-
import { appendFileSync, existsSync, mkdirSync, readFileSync, readdirSync, statSync, watch, writeFileSync } from 'node:fs'
|
|
3
|
+
import { appendFileSync, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, statSync, watch, writeFileSync } from 'node:fs'
|
|
4
4
|
import { homedir } from 'node:os'
|
|
5
5
|
import { join, resolve } from 'node:path'
|
|
6
6
|
import { Script } from 'node:vm'
|
|
@@ -238,8 +238,8 @@ function settingsOf(config) {
|
|
|
238
238
|
export function oneLine(value, limit = 2000) {
|
|
239
239
|
// A line break is not the only thing that forges a log line: an escape sequence can move the
|
|
240
240
|
// cursor and paint over earlier lines when a person reads the file, and a bare control byte can
|
|
241
|
-
// make a terminal misbehave. Page-supplied text reaches this function, so every control
|
|
242
|
-
//
|
|
241
|
+
// make a terminal misbehave. Page-supplied text reaches this function, so every control byte
|
|
242
|
+
// becomes a space, not only the line breaks.
|
|
243
243
|
const text = String(value ?? '')
|
|
244
244
|
.replace(/[\r\n\u2028\u2029]+/gu, ' ')
|
|
245
245
|
.replace(/[\u0000-\u001f\u007f-\u009f]+/gu, ' ')
|
|
@@ -271,9 +271,19 @@ function log(line) {
|
|
|
271
271
|
* A file that only grows eventually costs the app its own memory budget, and a burst of lines
|
|
272
272
|
* can land between two periodic checks: the size is read before every write and the whole
|
|
273
273
|
* line has to fit, so the file never passes the cap even for one event.
|
|
274
|
+
*
|
|
275
|
+
* A full file is moved aside rather than emptied: the lines it holds are the evidence for
|
|
276
|
+
* whatever just happened, and the event that fills the log is very often the one worth reading.
|
|
277
|
+
* One previous generation is kept, so a hostile page can cost at most one past million bytes.
|
|
274
278
|
*/
|
|
275
279
|
try {
|
|
276
|
-
if (statSync(target).size + Buffer.byteLength(text) > LOG_MAX_BYTES)
|
|
280
|
+
if (statSync(target).size + Buffer.byteLength(text) > LOG_MAX_BYTES) {
|
|
281
|
+
try {
|
|
282
|
+
renameSync(target, `${target}.1`)
|
|
283
|
+
} catch {
|
|
284
|
+
writeFileSync(target, '')
|
|
285
|
+
}
|
|
286
|
+
}
|
|
277
287
|
} catch {
|
|
278
288
|
/* a missing or unreadable log is created by the append below */
|
|
279
289
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-unlag",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.107",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A press applies plugin edits right away and brings a laggy interface back; automatic reloading stays off unless you turn it on, so the press is the only trigger, and nothing restarts.",
|
|
6
6
|
"license": "MIT",
|