@preventive/triage 1.0.0-alpha.87 → 1.0.0-alpha.88
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/common/default-scan-models.ts +1 -0
- package/common/line-diff.d.ts +2 -1
- package/common/line-diff.js +12 -5
- package/common/pretty-json.js +25 -0
- package/common/pretty-print.d.ts +1 -0
- package/common/pretty-print.js +5 -0
- package/out/activity.js +2 -2
- package/out/{chunk-Q2NFBTNH.js → chunk-4GHLPL2P.js} +1 -1
- package/out/chunk-5PWEAEA5.js +1 -0
- package/out/chunk-7KUZQB6S.js +267 -0
- package/out/{chunk-PSS7UX5T.js → chunk-A4HSJCXG.js} +1 -1
- package/out/{chunk-6CCSTJWB.js → chunk-ESXA7KID.js} +1 -1
- package/out/{chunk-WKXQOUNH.js → chunk-U6JONPTN.js} +1 -1
- package/out/chunk-VRFGZ6MV.js +1 -0
- package/out/client-managed.js +1 -1
- package/out/compare.js +13 -13
- package/out/dialogs.js +22 -22
- package/out/index.html +4 -4
- package/out/scan.js +1 -1
- package/out/view.js +15 -15
- package/package.json +2 -2
- package/server-managed/bundle-build-worker.js +13 -6
- package/server-managed/bundle-build.ts +7 -5
- package/server-managed/npm-delta-worker.js +56 -8
- package/server-managed/npm-delta.ts +1 -1
- package/server-managed/pretty-format.d.ts +3 -2
- package/server-managed/pretty-format.js +17 -3
- package/server-managed/pretty-print.ts +18 -16
- package/server-managed/stasis-dependencies.ts +14 -5
- package/server-managed/type-only-proof.js +22 -2
- package/out/chunk-5LY6QSPD.js +0 -265
- package/out/chunk-7PXMWWTQ.js +0 -1
- package/out/chunk-ZKJ7COEH.js +0 -1
- /package/out/{chunk-3YPZ7UBC.js → chunk-WBK5ZN4K.js} +0 -0
package/common/line-diff.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export function indentHiddenBlocks(before: string, after: string): ChangeBlock[]
|
|
|
9
9
|
export function markedCounts(blocks: readonly ChangeBlock[], marks: readonly ChangeBlock[] | null): { additions: number; deletions: number; renamed: number; marked: Set<number> }
|
|
10
10
|
export function diffSize(before: string, after: string, ignoreWhitespace?: boolean | 'leading'): { marks: number; lines: number }
|
|
11
11
|
export const isLargeDiff: (before: string, after: string) => boolean
|
|
12
|
-
export function typeFolds(before: string, after: string, runs: { runs: [number, number][]; otherRuns: [number, number][] }): { before: string; after: string; lineOf: { a: number[]; b: number[] }; lines: { a: number; b: number } } | null
|
|
12
|
+
export function typeFolds(before: string, after: string, runs: { runs: [number, number][]; otherRuns: [number, number][] }): { before: string; after: string; whole: { a: string; b: string }; lineOf: { a: number[]; b: number[] }; lines: { a: number; b: number } } | false | null
|
|
13
|
+
export function copiesRuns(a: { text: string; runs?: [number, number][] }, b: { text: string; runs?: [number, number][] }): { runs: [number, number][]; otherRuns: [number, number][] } | null
|
|
13
14
|
export function withSharedBlankLines(before: string, after: string, blankBefore: readonly number[], blankAfter: readonly number[]): { before: string; after: string }
|
|
14
15
|
export function blocksHold(before: string, after: string, blocks: unknown, ignoreWhitespace?: boolean | 'leading'): boolean
|
package/common/line-diff.js
CHANGED
|
@@ -90,9 +90,10 @@ export function withSharedBlankLines(before, after, blankBefore, blankAfter) {
|
|
|
90
90
|
// A file that changed in types alone but for what runs (type-only.js
|
|
91
91
|
// typeProof), its types set aside: `before` and `after` the texts of each
|
|
92
92
|
// side's lines that run (`runs`, `otherRuns`, `[from, to)` each), diffed in
|
|
93
|
-
// place of the files'; `lineOf` each of their lines' line in its file, and
|
|
94
|
-
// `lines` the file's count, for diffRows to show where the types stand.
|
|
95
|
-
// where
|
|
93
|
+
// place of the files' (`whole`); `lineOf` each of their lines' line in its file, and
|
|
94
|
+
// `lines` the file's count, for diffRows to show where the types stand. False
|
|
95
|
+
// where what runs reads alike on both sides, its types alone changed; else
|
|
96
|
+
// null where that would hide no change.
|
|
96
97
|
export function typeFolds(before, after, { runs, otherRuns }) {
|
|
97
98
|
const side = (text, ranges) => {
|
|
98
99
|
const lineOf = [], lines = textLines(text)
|
|
@@ -104,10 +105,16 @@ export function typeFolds(before, after, { runs, otherRuns }) {
|
|
|
104
105
|
types: lines.filter((_, i) => !shown.has(i)).join('\n') }
|
|
105
106
|
}
|
|
106
107
|
const a = side(before, runs), b = side(after, otherRuns)
|
|
107
|
-
if (a.
|
|
108
|
-
|
|
108
|
+
if (a.run === b.run) return false
|
|
109
|
+
if (a.types === b.types) return null
|
|
110
|
+
return { before: a.text, after: b.text, whole: { a: before, b: after }, lineOf: { a: a.lineOf, b: b.lineOf }, lines: { a: a.lines, b: b.lines } }
|
|
109
111
|
}
|
|
110
112
|
|
|
113
|
+
const NO_RUNS = Object.freeze([])
|
|
114
|
+
// Two printed copies' lines that run, as typeFolds takes them, where each kept
|
|
115
|
+
// them or has no text; else null.
|
|
116
|
+
export const copiesRuns = (a, b) => ([a, b].every(copy => copy.text === '' || copy.runs) ? { runs: a.runs ?? NO_RUNS, otherRuns: b.runs ?? NO_RUNS } : null)
|
|
117
|
+
|
|
111
118
|
// The lines `blocks` add and remove, but for those that are one of `marks`, counted apart (`renamed`, `marked`).
|
|
112
119
|
export function markedCounts(blocks, marks) {
|
|
113
120
|
const told = new Set((marks ?? []).map(({ a0, a1, b0, b1 }) => `${a0},${a1},${b0},${b1}`))
|
package/common/pretty-json.js
CHANGED
|
@@ -6,6 +6,31 @@ export const jsonPrinted = path => /\.json$/iu.test(path)
|
|
|
6
6
|
// The widths prettyJSON folds to in the pretty-print toggle's layouts.
|
|
7
7
|
export const JSON_LAYOUT_WIDTHS = { indented: 0, folded: 120 }
|
|
8
8
|
|
|
9
|
+
// A text's lines, a final newline ending the last rather than starting another.
|
|
10
|
+
const lineCount = text => (text === '' ? 0 : text.split('\n').length - (text.endsWith('\n') ? 1 : 0))
|
|
11
|
+
|
|
12
|
+
// Whether folding saves enough to offer: of `indented` lines, folded to
|
|
13
|
+
// `folded`, more than ten, and more than a tenth.
|
|
14
|
+
export const foldSaves = (indented, folded) => indented - folded > Math.max(10, indented / 10)
|
|
15
|
+
|
|
16
|
+
// Whether a JSON file's own copies may offer folding: not a package.json's,
|
|
17
|
+
// kept short and read often, which is folded only once the toggle is.
|
|
18
|
+
export const offersFold = path => !/(?:^|\/)package\.json$/u.test(path)
|
|
19
|
+
|
|
20
|
+
// Whether a file's copies, `[indented, folded]`, fold enough of its lines to
|
|
21
|
+
// offer folding (foldSaves).
|
|
22
|
+
export const copiesFold = ([indented, folded]) => foldSaves(lineCount(indented), lineCount(folded))
|
|
23
|
+
|
|
24
|
+
// Whether a comparison's JSON file offers folding: where its copies fold
|
|
25
|
+
// enough of either side's lines (copiesFold), and of those its diff changes,
|
|
26
|
+
// `changed(before, after)` counting them, or null where too many to count.
|
|
27
|
+
// `sides` its two sides' copies, `[indented, folded]`, '' both for a side it lacks.
|
|
28
|
+
export function comparisonFolds(sides, changed) {
|
|
29
|
+
if (!sides.some(copies => copies[0] !== '' && copiesFold(copies))) return false
|
|
30
|
+
const [indented, folded] = [0, 1].map(layout => changed(sides[0][layout], sides[1][layout]))
|
|
31
|
+
return indented !== null && folded !== null && foldSaves(indented, folded)
|
|
32
|
+
}
|
|
33
|
+
|
|
9
34
|
const isContainer = value => value !== null && typeof value === 'object'
|
|
10
35
|
|
|
11
36
|
// `value` on one line, `{ "a": [1, 2] }`, or null where that is longer than
|
package/common/pretty-print.d.ts
CHANGED
|
@@ -4,3 +4,4 @@ export const MAX_PRETTY_BYTES: number
|
|
|
4
4
|
export function prettyExtension(path: string): string | null
|
|
5
5
|
export function needsPrettyPrint(path: string, text: string, read?: () => { category: string }): boolean
|
|
6
6
|
export function layoutBlankList(blank: unknown): number[] | null
|
|
7
|
+
export function runRangeList(runs: unknown): [number, number][] | null
|
package/common/pretty-print.js
CHANGED
|
@@ -34,3 +34,8 @@ export function needsPrettyPrint(path, text, read = () => npmFileReadability(pat
|
|
|
34
34
|
// with its text (server-managed/pretty-print.ts, `{ text, blank }`): `blank`
|
|
35
35
|
// where it is lines' numbers in order, else null.
|
|
36
36
|
export const layoutBlankList = blank => (Array.isArray(blank) && blank.every((line, i) => Number.isSafeInteger(line) && line > (blank[i - 1] ?? -1)) ? blank : null)
|
|
37
|
+
|
|
38
|
+
// Lines `[from, to)` as the server tells them, in order, apart: a declaration
|
|
39
|
+
// file's copy's lines that run, or a proof's; else null.
|
|
40
|
+
export const runRangeList = runs => (Array.isArray(runs) && runs.every((range, i) => Array.isArray(range) && range.length === 2
|
|
41
|
+
&& range.every(Number.isSafeInteger) && range[0] >= (runs[i - 1]?.[1] ?? 0) && range[1] > range[0]) ? runs : null)
|