@self-review/core 1.28.1 → 1.28.4
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/index.cjs +84 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -142
- package/dist/index.d.ts +14 -142
- package/dist/index.js +81 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,144 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
interface DiffLine {
|
|
4
|
-
type: DiffLineType;
|
|
5
|
-
oldLineNumber: number | null;
|
|
6
|
-
newLineNumber: number | null;
|
|
7
|
-
content: string;
|
|
8
|
-
}
|
|
9
|
-
interface DiffHunk {
|
|
10
|
-
header: string;
|
|
11
|
-
oldStart: number;
|
|
12
|
-
oldLines: number;
|
|
13
|
-
newStart: number;
|
|
14
|
-
newLines: number;
|
|
15
|
-
lines: DiffLine[];
|
|
16
|
-
}
|
|
17
|
-
interface DiffFile {
|
|
18
|
-
oldPath: string;
|
|
19
|
-
newPath: string;
|
|
20
|
-
changeType: ChangeType;
|
|
21
|
-
isBinary: boolean;
|
|
22
|
-
hunks: DiffHunk[];
|
|
23
|
-
isUntracked?: boolean;
|
|
24
|
-
contentLoaded?: boolean;
|
|
25
|
-
}
|
|
26
|
-
type DiffSource = {
|
|
27
|
-
type: 'git';
|
|
28
|
-
gitDiffArgs: string;
|
|
29
|
-
repository: string;
|
|
30
|
-
} | {
|
|
31
|
-
type: 'directory';
|
|
32
|
-
sourcePath: string;
|
|
33
|
-
} | {
|
|
34
|
-
type: 'file';
|
|
35
|
-
sourcePath: string;
|
|
36
|
-
} | {
|
|
37
|
-
type: 'welcome';
|
|
38
|
-
} | {
|
|
39
|
-
type: 'loading';
|
|
40
|
-
};
|
|
41
|
-
interface Suggestion {
|
|
42
|
-
originalCode: string;
|
|
43
|
-
proposedCode: string;
|
|
44
|
-
}
|
|
45
|
-
interface Attachment {
|
|
46
|
-
id: string;
|
|
47
|
-
fileName: string;
|
|
48
|
-
mediaType: string;
|
|
49
|
-
data?: ArrayBuffer;
|
|
50
|
-
}
|
|
51
|
-
interface LineRange {
|
|
52
|
-
side: 'old' | 'new';
|
|
53
|
-
start: number;
|
|
54
|
-
end: number;
|
|
55
|
-
}
|
|
56
|
-
interface ReviewComment {
|
|
57
|
-
id: string;
|
|
58
|
-
filePath: string;
|
|
59
|
-
lineRange: LineRange | null;
|
|
60
|
-
body: string;
|
|
61
|
-
category: string;
|
|
62
|
-
suggestion: Suggestion | null;
|
|
63
|
-
orphaned?: boolean;
|
|
64
|
-
attachments?: Attachment[];
|
|
65
|
-
}
|
|
66
|
-
interface FileReviewState {
|
|
67
|
-
path: string;
|
|
68
|
-
changeType: ChangeType;
|
|
69
|
-
viewed: boolean;
|
|
70
|
-
comments: ReviewComment[];
|
|
71
|
-
}
|
|
72
|
-
interface ReviewState {
|
|
73
|
-
timestamp: string;
|
|
74
|
-
source: DiffSource;
|
|
75
|
-
files: FileReviewState[];
|
|
76
|
-
}
|
|
77
|
-
interface CategoryDef {
|
|
78
|
-
name: string;
|
|
79
|
-
description: string;
|
|
80
|
-
color: string;
|
|
81
|
-
}
|
|
82
|
-
interface AppConfig {
|
|
83
|
-
theme: 'light' | 'dark' | 'system';
|
|
84
|
-
diffView: 'split' | 'unified';
|
|
85
|
-
fontSize: number;
|
|
86
|
-
outputFormat: string;
|
|
87
|
-
outputFile: string;
|
|
88
|
-
ignore: string[];
|
|
89
|
-
categories: CategoryDef[];
|
|
90
|
-
defaultDiffArgs: string;
|
|
91
|
-
showUntracked: boolean;
|
|
92
|
-
wordWrap: boolean;
|
|
93
|
-
maxFiles: number;
|
|
94
|
-
maxTotalLines: number;
|
|
95
|
-
}
|
|
96
|
-
interface DiffLoadPayload {
|
|
97
|
-
files: DiffFile[];
|
|
98
|
-
source: DiffSource;
|
|
99
|
-
isLargePayload?: boolean;
|
|
100
|
-
}
|
|
101
|
-
interface ResumeLoadPayload {
|
|
102
|
-
comments: ReviewComment[];
|
|
103
|
-
}
|
|
104
|
-
interface OutputPathInfo {
|
|
105
|
-
resolvedOutputPath: string;
|
|
106
|
-
outputPathWritable: boolean;
|
|
107
|
-
}
|
|
108
|
-
interface ExpandContextRequest {
|
|
109
|
-
filePath: string;
|
|
110
|
-
contextLines: number;
|
|
111
|
-
}
|
|
112
|
-
interface ExpandContextResponse {
|
|
113
|
-
hunks: DiffHunk[];
|
|
114
|
-
totalLines: number;
|
|
115
|
-
}
|
|
116
|
-
interface FindInPageRequest {
|
|
117
|
-
text: string;
|
|
118
|
-
forward: boolean;
|
|
119
|
-
findNext: boolean;
|
|
120
|
-
}
|
|
121
|
-
interface FindInPageResult {
|
|
122
|
-
activeMatchOrdinal: number;
|
|
123
|
-
matches: number;
|
|
124
|
-
finalUpdate: boolean;
|
|
125
|
-
}
|
|
126
|
-
interface VersionUpdateInfo {
|
|
127
|
-
latestVersion: string;
|
|
128
|
-
releaseUrl: string;
|
|
129
|
-
}
|
|
130
|
-
type ImageLoadResult = {
|
|
131
|
-
dataUri: string;
|
|
132
|
-
} | {
|
|
133
|
-
error: string;
|
|
134
|
-
};
|
|
135
|
-
interface PayloadStats {
|
|
136
|
-
fileCount: number;
|
|
137
|
-
totalLines: number;
|
|
138
|
-
exceedsFiles: boolean;
|
|
139
|
-
exceedsLines: boolean;
|
|
140
|
-
exceedsAny: boolean;
|
|
141
|
-
}
|
|
1
|
+
import { DiffFile, ReviewState, ReviewComment, DiffSource, AppConfig, PayloadStats } from '@self-review/types';
|
|
2
|
+
export { AppConfig, Attachment, CategoryDef, ChangeType, DiffFile, DiffHunk, DiffLine, DiffLineType, DiffLoadPayload, DiffSource, ExpandContextRequest, ExpandContextResponse, FileReviewState, FindInPageRequest, FindInPageResult, ImageLoadResult, LineRange, OutputPathInfo, PayloadStats, ResumeLoadPayload, ReviewComment, ReviewState, Suggestion, VersionUpdateInfo } from '@self-review/types';
|
|
142
3
|
|
|
143
4
|
declare function parseDiff(rawDiff: string): DiffFile[];
|
|
144
5
|
|
|
@@ -243,4 +104,15 @@ declare function createIgnoreFilter(patterns: string[]): (path: string) => boole
|
|
|
243
104
|
*/
|
|
244
105
|
declare function checkWritability(filePath: string): boolean;
|
|
245
106
|
|
|
246
|
-
|
|
107
|
+
/**
|
|
108
|
+
* File-type detection utilities.
|
|
109
|
+
*
|
|
110
|
+
* NOTE: This file is intentionally duplicated in packages/react/src/utils/file-type-utils.ts.
|
|
111
|
+
* @self-review/core has Node-only dependencies, so @self-review/react cannot safely import
|
|
112
|
+
* from this package. Both copies must be kept in sync.
|
|
113
|
+
*/
|
|
114
|
+
declare function isPreviewableImage(filePath: string): boolean;
|
|
115
|
+
declare function isPreviewableSvg(filePath: string): boolean;
|
|
116
|
+
declare function getLanguageFromPath(filePath: string): string;
|
|
117
|
+
|
|
118
|
+
export { checkWritability, computePayloadStats, countTotalLines, createIgnoreFilter, generateSyntheticDiffs, generateUntrackedDiffs, getGitDiffStats, getLanguageFromPath, getRepoRoot, getRepoRootAsync, getUntrackedFilesAsync, isPreviewableImage, isPreviewableSvg, loadConfig, parseDiff, parseReviewXml, parseReviewXmlString, runGitDiff, runGitDiffAsync, scanDirectory, scanFile, serializeReview, validateGitAvailable };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,144 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
interface DiffLine {
|
|
4
|
-
type: DiffLineType;
|
|
5
|
-
oldLineNumber: number | null;
|
|
6
|
-
newLineNumber: number | null;
|
|
7
|
-
content: string;
|
|
8
|
-
}
|
|
9
|
-
interface DiffHunk {
|
|
10
|
-
header: string;
|
|
11
|
-
oldStart: number;
|
|
12
|
-
oldLines: number;
|
|
13
|
-
newStart: number;
|
|
14
|
-
newLines: number;
|
|
15
|
-
lines: DiffLine[];
|
|
16
|
-
}
|
|
17
|
-
interface DiffFile {
|
|
18
|
-
oldPath: string;
|
|
19
|
-
newPath: string;
|
|
20
|
-
changeType: ChangeType;
|
|
21
|
-
isBinary: boolean;
|
|
22
|
-
hunks: DiffHunk[];
|
|
23
|
-
isUntracked?: boolean;
|
|
24
|
-
contentLoaded?: boolean;
|
|
25
|
-
}
|
|
26
|
-
type DiffSource = {
|
|
27
|
-
type: 'git';
|
|
28
|
-
gitDiffArgs: string;
|
|
29
|
-
repository: string;
|
|
30
|
-
} | {
|
|
31
|
-
type: 'directory';
|
|
32
|
-
sourcePath: string;
|
|
33
|
-
} | {
|
|
34
|
-
type: 'file';
|
|
35
|
-
sourcePath: string;
|
|
36
|
-
} | {
|
|
37
|
-
type: 'welcome';
|
|
38
|
-
} | {
|
|
39
|
-
type: 'loading';
|
|
40
|
-
};
|
|
41
|
-
interface Suggestion {
|
|
42
|
-
originalCode: string;
|
|
43
|
-
proposedCode: string;
|
|
44
|
-
}
|
|
45
|
-
interface Attachment {
|
|
46
|
-
id: string;
|
|
47
|
-
fileName: string;
|
|
48
|
-
mediaType: string;
|
|
49
|
-
data?: ArrayBuffer;
|
|
50
|
-
}
|
|
51
|
-
interface LineRange {
|
|
52
|
-
side: 'old' | 'new';
|
|
53
|
-
start: number;
|
|
54
|
-
end: number;
|
|
55
|
-
}
|
|
56
|
-
interface ReviewComment {
|
|
57
|
-
id: string;
|
|
58
|
-
filePath: string;
|
|
59
|
-
lineRange: LineRange | null;
|
|
60
|
-
body: string;
|
|
61
|
-
category: string;
|
|
62
|
-
suggestion: Suggestion | null;
|
|
63
|
-
orphaned?: boolean;
|
|
64
|
-
attachments?: Attachment[];
|
|
65
|
-
}
|
|
66
|
-
interface FileReviewState {
|
|
67
|
-
path: string;
|
|
68
|
-
changeType: ChangeType;
|
|
69
|
-
viewed: boolean;
|
|
70
|
-
comments: ReviewComment[];
|
|
71
|
-
}
|
|
72
|
-
interface ReviewState {
|
|
73
|
-
timestamp: string;
|
|
74
|
-
source: DiffSource;
|
|
75
|
-
files: FileReviewState[];
|
|
76
|
-
}
|
|
77
|
-
interface CategoryDef {
|
|
78
|
-
name: string;
|
|
79
|
-
description: string;
|
|
80
|
-
color: string;
|
|
81
|
-
}
|
|
82
|
-
interface AppConfig {
|
|
83
|
-
theme: 'light' | 'dark' | 'system';
|
|
84
|
-
diffView: 'split' | 'unified';
|
|
85
|
-
fontSize: number;
|
|
86
|
-
outputFormat: string;
|
|
87
|
-
outputFile: string;
|
|
88
|
-
ignore: string[];
|
|
89
|
-
categories: CategoryDef[];
|
|
90
|
-
defaultDiffArgs: string;
|
|
91
|
-
showUntracked: boolean;
|
|
92
|
-
wordWrap: boolean;
|
|
93
|
-
maxFiles: number;
|
|
94
|
-
maxTotalLines: number;
|
|
95
|
-
}
|
|
96
|
-
interface DiffLoadPayload {
|
|
97
|
-
files: DiffFile[];
|
|
98
|
-
source: DiffSource;
|
|
99
|
-
isLargePayload?: boolean;
|
|
100
|
-
}
|
|
101
|
-
interface ResumeLoadPayload {
|
|
102
|
-
comments: ReviewComment[];
|
|
103
|
-
}
|
|
104
|
-
interface OutputPathInfo {
|
|
105
|
-
resolvedOutputPath: string;
|
|
106
|
-
outputPathWritable: boolean;
|
|
107
|
-
}
|
|
108
|
-
interface ExpandContextRequest {
|
|
109
|
-
filePath: string;
|
|
110
|
-
contextLines: number;
|
|
111
|
-
}
|
|
112
|
-
interface ExpandContextResponse {
|
|
113
|
-
hunks: DiffHunk[];
|
|
114
|
-
totalLines: number;
|
|
115
|
-
}
|
|
116
|
-
interface FindInPageRequest {
|
|
117
|
-
text: string;
|
|
118
|
-
forward: boolean;
|
|
119
|
-
findNext: boolean;
|
|
120
|
-
}
|
|
121
|
-
interface FindInPageResult {
|
|
122
|
-
activeMatchOrdinal: number;
|
|
123
|
-
matches: number;
|
|
124
|
-
finalUpdate: boolean;
|
|
125
|
-
}
|
|
126
|
-
interface VersionUpdateInfo {
|
|
127
|
-
latestVersion: string;
|
|
128
|
-
releaseUrl: string;
|
|
129
|
-
}
|
|
130
|
-
type ImageLoadResult = {
|
|
131
|
-
dataUri: string;
|
|
132
|
-
} | {
|
|
133
|
-
error: string;
|
|
134
|
-
};
|
|
135
|
-
interface PayloadStats {
|
|
136
|
-
fileCount: number;
|
|
137
|
-
totalLines: number;
|
|
138
|
-
exceedsFiles: boolean;
|
|
139
|
-
exceedsLines: boolean;
|
|
140
|
-
exceedsAny: boolean;
|
|
141
|
-
}
|
|
1
|
+
import { DiffFile, ReviewState, ReviewComment, DiffSource, AppConfig, PayloadStats } from '@self-review/types';
|
|
2
|
+
export { AppConfig, Attachment, CategoryDef, ChangeType, DiffFile, DiffHunk, DiffLine, DiffLineType, DiffLoadPayload, DiffSource, ExpandContextRequest, ExpandContextResponse, FileReviewState, FindInPageRequest, FindInPageResult, ImageLoadResult, LineRange, OutputPathInfo, PayloadStats, ResumeLoadPayload, ReviewComment, ReviewState, Suggestion, VersionUpdateInfo } from '@self-review/types';
|
|
142
3
|
|
|
143
4
|
declare function parseDiff(rawDiff: string): DiffFile[];
|
|
144
5
|
|
|
@@ -243,4 +104,15 @@ declare function createIgnoreFilter(patterns: string[]): (path: string) => boole
|
|
|
243
104
|
*/
|
|
244
105
|
declare function checkWritability(filePath: string): boolean;
|
|
245
106
|
|
|
246
|
-
|
|
107
|
+
/**
|
|
108
|
+
* File-type detection utilities.
|
|
109
|
+
*
|
|
110
|
+
* NOTE: This file is intentionally duplicated in packages/react/src/utils/file-type-utils.ts.
|
|
111
|
+
* @self-review/core has Node-only dependencies, so @self-review/react cannot safely import
|
|
112
|
+
* from this package. Both copies must be kept in sync.
|
|
113
|
+
*/
|
|
114
|
+
declare function isPreviewableImage(filePath: string): boolean;
|
|
115
|
+
declare function isPreviewableSvg(filePath: string): boolean;
|
|
116
|
+
declare function getLanguageFromPath(filePath: string): string;
|
|
117
|
+
|
|
118
|
+
export { checkWritability, computePayloadStats, countTotalLines, createIgnoreFilter, generateSyntheticDiffs, generateUntrackedDiffs, getGitDiffStats, getLanguageFromPath, getRepoRoot, getRepoRootAsync, getUntrackedFilesAsync, isPreviewableImage, isPreviewableSvg, loadConfig, parseDiff, parseReviewXml, parseReviewXmlString, runGitDiff, runGitDiffAsync, scanDirectory, scanFile, serializeReview, validateGitAvailable };
|
package/dist/index.js
CHANGED
|
@@ -1193,6 +1193,84 @@ function checkWritability(filePath) {
|
|
|
1193
1193
|
return false;
|
|
1194
1194
|
}
|
|
1195
1195
|
}
|
|
1196
|
+
|
|
1197
|
+
// src/file-type-utils.ts
|
|
1198
|
+
var RASTER_IMAGE_EXTENSIONS = /* @__PURE__ */ new Set([".jpg", ".jpeg", ".png", ".gif", ".webp", ".ico", ".bmp"]);
|
|
1199
|
+
function getExtension(filePath) {
|
|
1200
|
+
const lastDot = filePath.lastIndexOf(".");
|
|
1201
|
+
if (lastDot === -1 || lastDot === filePath.length - 1) return "";
|
|
1202
|
+
return filePath.slice(lastDot).toLowerCase();
|
|
1203
|
+
}
|
|
1204
|
+
function isPreviewableImage(filePath) {
|
|
1205
|
+
return RASTER_IMAGE_EXTENSIONS.has(getExtension(filePath));
|
|
1206
|
+
}
|
|
1207
|
+
function isPreviewableSvg(filePath) {
|
|
1208
|
+
return getExtension(filePath) === ".svg";
|
|
1209
|
+
}
|
|
1210
|
+
function getLanguageFromPath(filePath) {
|
|
1211
|
+
const ext = filePath.split(".").pop()?.toLowerCase() || "";
|
|
1212
|
+
const langMap = {
|
|
1213
|
+
ts: "typescript",
|
|
1214
|
+
tsx: "tsx",
|
|
1215
|
+
js: "javascript",
|
|
1216
|
+
jsx: "jsx",
|
|
1217
|
+
py: "python",
|
|
1218
|
+
css: "css",
|
|
1219
|
+
json: "json",
|
|
1220
|
+
md: "markdown",
|
|
1221
|
+
sh: "bash",
|
|
1222
|
+
bash: "bash",
|
|
1223
|
+
yml: "yaml",
|
|
1224
|
+
yaml: "yaml",
|
|
1225
|
+
java: "java",
|
|
1226
|
+
go: "go",
|
|
1227
|
+
rs: "rust",
|
|
1228
|
+
sql: "sql",
|
|
1229
|
+
html: "markup",
|
|
1230
|
+
xml: "markup",
|
|
1231
|
+
rb: "ruby",
|
|
1232
|
+
php: "php",
|
|
1233
|
+
twig: "twig",
|
|
1234
|
+
c: "c",
|
|
1235
|
+
cpp: "cpp",
|
|
1236
|
+
h: "c",
|
|
1237
|
+
hpp: "cpp",
|
|
1238
|
+
// Config and data formats
|
|
1239
|
+
ini: "ini",
|
|
1240
|
+
toml: "toml",
|
|
1241
|
+
csv: "csv",
|
|
1242
|
+
diff: "diff",
|
|
1243
|
+
patch: "diff",
|
|
1244
|
+
// Web and infrastructure
|
|
1245
|
+
scss: "scss",
|
|
1246
|
+
sass: "sass",
|
|
1247
|
+
graphql: "graphql",
|
|
1248
|
+
gql: "graphql",
|
|
1249
|
+
conf: "nginx",
|
|
1250
|
+
// Database
|
|
1251
|
+
mongodb: "mongodb",
|
|
1252
|
+
// Tooling
|
|
1253
|
+
makefile: "makefile",
|
|
1254
|
+
mk: "makefile",
|
|
1255
|
+
mak: "makefile",
|
|
1256
|
+
vim: "vim",
|
|
1257
|
+
vimrc: "vim"
|
|
1258
|
+
};
|
|
1259
|
+
const filename = filePath.split("/").pop()?.toLowerCase() || "";
|
|
1260
|
+
if (filename === "dockerfile" || filename.startsWith("dockerfile.")) {
|
|
1261
|
+
return "docker";
|
|
1262
|
+
}
|
|
1263
|
+
if (filename === "makefile" || filename.startsWith("makefile.")) {
|
|
1264
|
+
return "makefile";
|
|
1265
|
+
}
|
|
1266
|
+
if (filename.startsWith(".git")) {
|
|
1267
|
+
return "git";
|
|
1268
|
+
}
|
|
1269
|
+
if (filename === ".vimrc" || filename.startsWith(".vim")) {
|
|
1270
|
+
return "vim";
|
|
1271
|
+
}
|
|
1272
|
+
return langMap[ext] || "plaintext";
|
|
1273
|
+
}
|
|
1196
1274
|
export {
|
|
1197
1275
|
checkWritability,
|
|
1198
1276
|
computePayloadStats,
|
|
@@ -1201,9 +1279,12 @@ export {
|
|
|
1201
1279
|
generateSyntheticDiffs,
|
|
1202
1280
|
generateUntrackedDiffs,
|
|
1203
1281
|
getGitDiffStats,
|
|
1282
|
+
getLanguageFromPath,
|
|
1204
1283
|
getRepoRoot,
|
|
1205
1284
|
getRepoRootAsync,
|
|
1206
1285
|
getUntrackedFilesAsync,
|
|
1286
|
+
isPreviewableImage,
|
|
1287
|
+
isPreviewableSvg,
|
|
1207
1288
|
loadConfig,
|
|
1208
1289
|
parseDiff,
|
|
1209
1290
|
parseReviewXml,
|