@happy-nut/monacori 0.1.0 → 0.1.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/README.md +44 -132
- package/assets/icon.png +0 -0
- package/assets/screenshots/diff-review.png +0 -0
- package/assets/screenshots/terminal.png +0 -0
- package/dist/app-main.js +210 -10
- package/dist/assets.d.ts +6 -0
- package/dist/assets.js +51 -0
- package/dist/build.d.ts +13 -0
- package/dist/build.js +77 -0
- package/dist/cli.d.ts +5 -33
- package/dist/cli.js +7 -3529
- package/dist/commands.d.ts +1 -0
- package/dist/commands.js +678 -0
- package/dist/constants.d.ts +10 -0
- package/dist/constants.js +11 -0
- package/dist/diff.d.ts +12 -0
- package/dist/diff.js +396 -0
- package/dist/git.d.ts +4 -0
- package/dist/git.js +23 -0
- package/dist/highlight.d.ts +1 -0
- package/dist/highlight.js +85 -0
- package/dist/i18n.d.ts +1 -0
- package/dist/i18n.js +256 -0
- package/dist/preload.cjs +83 -0
- package/dist/preload.d.cts +1 -0
- package/dist/render.d.ts +33 -0
- package/dist/render.js +406 -0
- package/dist/server.d.ts +20 -0
- package/dist/server.js +175 -0
- package/dist/types.d.ts +99 -0
- package/dist/types.js +1 -0
- package/dist/util.d.ts +18 -0
- package/dist/util.js +144 -0
- package/dist/viewer.client.js +3935 -0
- package/dist/viewer.css +1094 -0
- package/package.json +9 -3
- package/scripts/patch-electron-name.mjs +65 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
export type FlowConfig = {
|
|
2
|
+
version: 1;
|
|
3
|
+
projectName: string;
|
|
4
|
+
verification: {
|
|
5
|
+
commands: string[];
|
|
6
|
+
};
|
|
7
|
+
diff: {
|
|
8
|
+
context: number;
|
|
9
|
+
includeUntracked: boolean;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export type GitSnapshot = {
|
|
13
|
+
branch: string;
|
|
14
|
+
status: string;
|
|
15
|
+
diffStat: string;
|
|
16
|
+
recentCommits: string;
|
|
17
|
+
};
|
|
18
|
+
export type DiffLine = {
|
|
19
|
+
kind: "context" | "add" | "delete";
|
|
20
|
+
oldLine?: number;
|
|
21
|
+
newLine?: number;
|
|
22
|
+
text: string;
|
|
23
|
+
};
|
|
24
|
+
export type DiffHunk = {
|
|
25
|
+
header: string;
|
|
26
|
+
title: string;
|
|
27
|
+
oldStart: number;
|
|
28
|
+
newStart: number;
|
|
29
|
+
lines: DiffLine[];
|
|
30
|
+
};
|
|
31
|
+
export type DiffFile = {
|
|
32
|
+
oldPath: string;
|
|
33
|
+
newPath: string;
|
|
34
|
+
displayPath: string;
|
|
35
|
+
status: string;
|
|
36
|
+
binary: boolean;
|
|
37
|
+
hunks: DiffHunk[];
|
|
38
|
+
vcs?: "new" | "edited" | "staged";
|
|
39
|
+
};
|
|
40
|
+
export type SourceFile = {
|
|
41
|
+
path: string;
|
|
42
|
+
name: string;
|
|
43
|
+
language: string;
|
|
44
|
+
content: string;
|
|
45
|
+
size: number;
|
|
46
|
+
changed: boolean;
|
|
47
|
+
embedded: boolean;
|
|
48
|
+
changedLines: number[];
|
|
49
|
+
signature: string;
|
|
50
|
+
skippedReason?: string;
|
|
51
|
+
image?: string;
|
|
52
|
+
vcs?: "new" | "edited" | "staged";
|
|
53
|
+
};
|
|
54
|
+
export type HttpSendRequest = {
|
|
55
|
+
method: string;
|
|
56
|
+
url: string;
|
|
57
|
+
headers: Record<string, string>;
|
|
58
|
+
body?: string;
|
|
59
|
+
};
|
|
60
|
+
export type HttpSendResult = {
|
|
61
|
+
ok: boolean;
|
|
62
|
+
status?: number;
|
|
63
|
+
statusText?: string;
|
|
64
|
+
headers?: Record<string, string>;
|
|
65
|
+
body?: string;
|
|
66
|
+
error?: string;
|
|
67
|
+
durationMs: number;
|
|
68
|
+
};
|
|
69
|
+
export type SourceTreeNode = {
|
|
70
|
+
name: string;
|
|
71
|
+
path: string;
|
|
72
|
+
children: Map<string, SourceTreeNode>;
|
|
73
|
+
file?: SourceFile;
|
|
74
|
+
};
|
|
75
|
+
export type DiffReviewResult = {
|
|
76
|
+
path: string;
|
|
77
|
+
url: string;
|
|
78
|
+
files: number;
|
|
79
|
+
hunks: number;
|
|
80
|
+
};
|
|
81
|
+
export type DiffReviewBuild = {
|
|
82
|
+
html: string;
|
|
83
|
+
files: number;
|
|
84
|
+
hunks: number;
|
|
85
|
+
signature: string;
|
|
86
|
+
generatedAt: string;
|
|
87
|
+
lazyBodies?: string[];
|
|
88
|
+
lazySourceData?: string;
|
|
89
|
+
};
|
|
90
|
+
export type VerificationRun = {
|
|
91
|
+
commands: string[];
|
|
92
|
+
failed: boolean;
|
|
93
|
+
skipped: boolean;
|
|
94
|
+
logPath?: string;
|
|
95
|
+
};
|
|
96
|
+
export type ReviewFileState = {
|
|
97
|
+
path: string;
|
|
98
|
+
signature: string;
|
|
99
|
+
};
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/util.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare function stripHtmlTags(value: string): string;
|
|
2
|
+
export declare function decodeEntities(value: string): string;
|
|
3
|
+
export declare function stripDiffPath(value: string): string;
|
|
4
|
+
export declare function languageForPath(path: string): string;
|
|
5
|
+
export declare function isLikelyBinary(path: string): boolean;
|
|
6
|
+
export declare function readOption(args: string[], name: string): string | undefined;
|
|
7
|
+
export declare function parsePositiveInteger(value: string, optionName: string): number;
|
|
8
|
+
export declare function readStdin(): string;
|
|
9
|
+
export declare function summarizeForState(content: string): string;
|
|
10
|
+
export declare function codeBlock(content: string): string;
|
|
11
|
+
export declare function timestampForFile(): string;
|
|
12
|
+
export declare function hashText(value: string): string;
|
|
13
|
+
export declare function sanitizeFilePart(value: string): string;
|
|
14
|
+
export declare function escapeHtml(value: string): string;
|
|
15
|
+
export declare function jsonForScript(value: unknown): string;
|
|
16
|
+
export declare function escapeAttr(value: string): string;
|
|
17
|
+
export declare function formatBytes(bytes: number): string;
|
|
18
|
+
export declare function listRecentFiles(dir: string, limit: number): string[];
|
package/dist/util.js
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
4
|
+
export function stripHtmlTags(value) {
|
|
5
|
+
return value.replace(/<[^>]*>/g, "");
|
|
6
|
+
}
|
|
7
|
+
export function decodeEntities(value) {
|
|
8
|
+
return value
|
|
9
|
+
.replace(/&#x([0-9a-fA-F]+);/g, (_match, hex) => String.fromCodePoint(parseInt(hex, 16)))
|
|
10
|
+
.replace(/&#(\d+);/g, (_match, dec) => String.fromCodePoint(parseInt(dec, 10)))
|
|
11
|
+
.replace(/</g, "<")
|
|
12
|
+
.replace(/>/g, ">")
|
|
13
|
+
.replace(/"/g, "\"")
|
|
14
|
+
.replace(/&/g, "&");
|
|
15
|
+
}
|
|
16
|
+
export function stripDiffPath(value) {
|
|
17
|
+
if (value === "/dev/null") {
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
return value.replace(/^[ab]\//, "");
|
|
21
|
+
}
|
|
22
|
+
export function languageForPath(path) {
|
|
23
|
+
const lower = path.toLowerCase();
|
|
24
|
+
if (lower.endsWith(".ts") || lower.endsWith(".tsx"))
|
|
25
|
+
return "typescript";
|
|
26
|
+
if (lower.endsWith(".js") || lower.endsWith(".jsx") || lower.endsWith(".mjs") || lower.endsWith(".cjs"))
|
|
27
|
+
return "javascript";
|
|
28
|
+
if (lower.endsWith(".json"))
|
|
29
|
+
return "json";
|
|
30
|
+
if (lower.endsWith(".css") || lower.endsWith(".scss") || lower.endsWith(".sass"))
|
|
31
|
+
return "css";
|
|
32
|
+
if (lower.endsWith(".html") || lower.endsWith(".htm") || lower.endsWith(".xml") || lower.endsWith(".svg"))
|
|
33
|
+
return "markup";
|
|
34
|
+
if (lower.endsWith(".md") || lower.endsWith(".mdx"))
|
|
35
|
+
return "markdown";
|
|
36
|
+
if (lower.endsWith(".py"))
|
|
37
|
+
return "python";
|
|
38
|
+
if (lower.endsWith(".rb"))
|
|
39
|
+
return "ruby";
|
|
40
|
+
if (lower.endsWith(".go"))
|
|
41
|
+
return "go";
|
|
42
|
+
if (lower.endsWith(".rs"))
|
|
43
|
+
return "rust";
|
|
44
|
+
if (lower.endsWith(".java") || lower.endsWith(".kt") || lower.endsWith(".kts"))
|
|
45
|
+
return "java";
|
|
46
|
+
if (lower.endsWith(".sh") || lower.endsWith(".bash") || lower.endsWith(".zsh"))
|
|
47
|
+
return "shell";
|
|
48
|
+
if (lower.endsWith(".yml") || lower.endsWith(".yaml"))
|
|
49
|
+
return "yaml";
|
|
50
|
+
if (lower.endsWith(".toml"))
|
|
51
|
+
return "toml";
|
|
52
|
+
if (lower.endsWith(".sql"))
|
|
53
|
+
return "sql";
|
|
54
|
+
if (lower.endsWith(".http") || lower.endsWith(".rest"))
|
|
55
|
+
return "http";
|
|
56
|
+
return "text";
|
|
57
|
+
}
|
|
58
|
+
export function isLikelyBinary(path) {
|
|
59
|
+
const sample = readFileSync(path).subarray(0, 8000);
|
|
60
|
+
return sample.includes(0);
|
|
61
|
+
}
|
|
62
|
+
export function readOption(args, name) {
|
|
63
|
+
const index = args.indexOf(name);
|
|
64
|
+
if (index < 0) {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
const value = args[index + 1];
|
|
68
|
+
if (!value || value.startsWith("--")) {
|
|
69
|
+
throw new Error(`Missing value for ${name}`);
|
|
70
|
+
}
|
|
71
|
+
return value;
|
|
72
|
+
}
|
|
73
|
+
export function parsePositiveInteger(value, optionName) {
|
|
74
|
+
const parsed = Number(value);
|
|
75
|
+
if (!Number.isInteger(parsed) || parsed < 0) {
|
|
76
|
+
throw new Error(`${optionName} must be a non-negative integer`);
|
|
77
|
+
}
|
|
78
|
+
return parsed;
|
|
79
|
+
}
|
|
80
|
+
export function readStdin() {
|
|
81
|
+
if (process.stdin.isTTY) {
|
|
82
|
+
return "";
|
|
83
|
+
}
|
|
84
|
+
return readFileSync(0, "utf8");
|
|
85
|
+
}
|
|
86
|
+
export function summarizeForState(content) {
|
|
87
|
+
const lines = content
|
|
88
|
+
.split(/\r?\n/)
|
|
89
|
+
.map((line) => line.trim())
|
|
90
|
+
.filter(Boolean)
|
|
91
|
+
.slice(0, 12);
|
|
92
|
+
return lines.map((line) => `- ${line.replace(/^-+\s*/, "")}`).join("\n");
|
|
93
|
+
}
|
|
94
|
+
export function codeBlock(content) {
|
|
95
|
+
return ["```", content, "```"].join("\n");
|
|
96
|
+
}
|
|
97
|
+
export function timestampForFile() {
|
|
98
|
+
return new Date().toISOString().replace(/[:.]/g, "-");
|
|
99
|
+
}
|
|
100
|
+
export function hashText(value) {
|
|
101
|
+
return createHash("sha1").update(value).digest("hex");
|
|
102
|
+
}
|
|
103
|
+
export function sanitizeFilePart(value) {
|
|
104
|
+
return value.toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-|-$/g, "");
|
|
105
|
+
}
|
|
106
|
+
export function escapeHtml(value) {
|
|
107
|
+
return value
|
|
108
|
+
.replace(/&/g, "&")
|
|
109
|
+
.replace(/</g, "<")
|
|
110
|
+
.replace(/>/g, ">")
|
|
111
|
+
.replace(/"/g, """)
|
|
112
|
+
.replace(/'/g, "'");
|
|
113
|
+
}
|
|
114
|
+
export function jsonForScript(value) {
|
|
115
|
+
return JSON.stringify(value)
|
|
116
|
+
.replace(/</g, "\\u003c")
|
|
117
|
+
.replace(/>/g, "\\u003e")
|
|
118
|
+
.replace(/&/g, "\\u0026")
|
|
119
|
+
.replace(/\u2028/g, "\\u2028")
|
|
120
|
+
.replace(/\u2029/g, "\\u2029");
|
|
121
|
+
}
|
|
122
|
+
export function escapeAttr(value) {
|
|
123
|
+
return escapeHtml(value);
|
|
124
|
+
}
|
|
125
|
+
export function formatBytes(bytes) {
|
|
126
|
+
if (bytes < 1024) {
|
|
127
|
+
return `${bytes} B`;
|
|
128
|
+
}
|
|
129
|
+
const kib = bytes / 1024;
|
|
130
|
+
if (kib < 1024) {
|
|
131
|
+
return `${kib.toFixed(1)} KiB`;
|
|
132
|
+
}
|
|
133
|
+
return `${(kib / 1024).toFixed(1)} MiB`;
|
|
134
|
+
}
|
|
135
|
+
export function listRecentFiles(dir, limit) {
|
|
136
|
+
if (!existsSync(dir)) {
|
|
137
|
+
return [];
|
|
138
|
+
}
|
|
139
|
+
return readdirSync(dir)
|
|
140
|
+
.map((name) => join(dir, name))
|
|
141
|
+
.filter((path) => statSync(path).isFile())
|
|
142
|
+
.sort((a, b) => statSync(b).mtimeMs - statSync(a).mtimeMs)
|
|
143
|
+
.slice(0, limit);
|
|
144
|
+
}
|