@cesarandreslopez/occ 0.1.1 → 0.2.0
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 +58 -28
- package/dist/bin/occ.d.ts +2 -0
- package/{bin → dist/bin}/occ.js +1 -0
- package/dist/bin/occ.js.map +1 -0
- package/dist/src/cli.d.ts +1 -0
- package/dist/src/cli.js +184 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/markdown/convert.d.ts +2 -0
- package/dist/src/markdown/convert.js +117 -0
- package/dist/src/markdown/convert.js.map +1 -0
- package/dist/src/output/json.d.ts +4 -0
- package/dist/src/output/json.js +42 -0
- package/dist/src/output/json.js.map +1 -0
- package/dist/src/output/tabular.d.ts +12 -0
- package/dist/src/output/tabular.js +238 -0
- package/dist/src/output/tabular.js.map +1 -0
- package/dist/src/output/tree.d.ts +11 -0
- package/dist/src/output/tree.js +79 -0
- package/dist/src/output/tree.js.map +1 -0
- package/dist/src/parsers/docx.d.ts +2 -0
- package/dist/src/parsers/docx.js +14 -0
- package/dist/src/parsers/docx.js.map +1 -0
- package/dist/src/parsers/index.d.ts +4 -0
- package/dist/src/parsers/index.js +65 -0
- package/dist/src/parsers/index.js.map +1 -0
- package/dist/src/parsers/odf.d.ts +2 -0
- package/dist/src/parsers/odf.js +54 -0
- package/dist/src/parsers/odf.js.map +1 -0
- package/dist/src/parsers/pdf.d.ts +2 -0
- package/dist/src/parsers/pdf.js +43 -0
- package/dist/src/parsers/pdf.js.map +1 -0
- package/dist/src/parsers/pptx.d.ts +2 -0
- package/dist/src/parsers/pptx.js +19 -0
- package/dist/src/parsers/pptx.js.map +1 -0
- package/dist/src/parsers/xlsx.d.ts +2 -0
- package/dist/src/parsers/xlsx.js +21 -0
- package/dist/src/parsers/xlsx.js.map +1 -0
- package/dist/src/progress.d.ts +10 -0
- package/dist/src/progress.js +38 -0
- package/dist/src/progress.js.map +1 -0
- package/dist/src/scc.d.ts +28 -0
- package/dist/src/scc.js +83 -0
- package/dist/src/scc.js.map +1 -0
- package/dist/src/stats.d.ts +30 -0
- package/dist/src/stats.js +88 -0
- package/dist/src/stats.js.map +1 -0
- package/dist/src/structure/extract.d.ts +7 -0
- package/dist/src/structure/extract.js +176 -0
- package/dist/src/structure/extract.js.map +1 -0
- package/dist/src/structure/index.d.ts +3 -0
- package/dist/src/structure/index.js +3 -0
- package/dist/src/structure/index.js.map +1 -0
- package/dist/src/structure/types.d.ts +29 -0
- package/dist/src/structure/types.js +72 -0
- package/dist/src/structure/types.js.map +1 -0
- package/dist/src/types.d.ts +20 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/utils.d.ts +9 -0
- package/dist/src/utils.js +37 -0
- package/dist/src/utils.js.map +1 -0
- package/dist/src/walker.d.ts +13 -0
- package/dist/src/walker.js +59 -0
- package/dist/src/walker.js.map +1 -0
- package/package.json +13 -6
- package/scripts/postinstall.js +28 -1
- package/src/cli.js +0 -126
- package/src/output/json.js +0 -37
- package/src/output/tabular.js +0 -197
- package/src/parsers/docx.js +0 -23
- package/src/parsers/index.js +0 -72
- package/src/parsers/odf.js +0 -85
- package/src/parsers/pdf.js +0 -56
- package/src/parsers/pptx.js +0 -32
- package/src/parsers/xlsx.js +0 -31
- package/src/progress.js +0 -45
- package/src/scc.js +0 -94
- package/src/stats.js +0 -143
- package/src/utils.js +0 -35
- package/src/walker.js +0 -86
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface ProgressBar {
|
|
2
|
+
update(increment: number, detail?: string): void;
|
|
3
|
+
done(): void;
|
|
4
|
+
}
|
|
5
|
+
export interface ProgressOptions {
|
|
6
|
+
total: number;
|
|
7
|
+
label?: string;
|
|
8
|
+
enabled?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function createProgress({ total, label, enabled }: ProgressOptions): ProgressBar;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { basename } from 'node:path';
|
|
2
|
+
const BAR_WIDTH = 20;
|
|
3
|
+
function noop() { }
|
|
4
|
+
const noopProgress = { update: noop, done: noop };
|
|
5
|
+
export function createProgress({ total, label = 'Parsing', enabled = true }) {
|
|
6
|
+
if (!enabled || !process.stderr.isTTY || total === 0)
|
|
7
|
+
return noopProgress;
|
|
8
|
+
let completed = 0;
|
|
9
|
+
const startTime = Date.now();
|
|
10
|
+
const cols = process.stderr.columns || 80;
|
|
11
|
+
function render(detail) {
|
|
12
|
+
const pct = Math.round((completed / total) * 100);
|
|
13
|
+
const filled = Math.round((completed / total) * BAR_WIDTH);
|
|
14
|
+
const bar = '\u2588'.repeat(filled) + '\u2591'.repeat(BAR_WIDTH - filled);
|
|
15
|
+
let remaining = '';
|
|
16
|
+
if (completed > 0) {
|
|
17
|
+
const elapsed = (Date.now() - startTime) / 1000;
|
|
18
|
+
const eta = Math.round((elapsed / completed) * (total - completed));
|
|
19
|
+
remaining = ` ~${eta}s remaining`;
|
|
20
|
+
}
|
|
21
|
+
const name = detail ? ' ' + basename(detail) : '';
|
|
22
|
+
let line = `${label} [${bar}] ${completed}/${total} (${pct}%)${name}${remaining}`;
|
|
23
|
+
if (line.length > cols)
|
|
24
|
+
line = line.slice(0, cols);
|
|
25
|
+
line = line.padEnd(cols);
|
|
26
|
+
process.stderr.write('\r' + line);
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
update(increment, detail) {
|
|
30
|
+
completed += increment;
|
|
31
|
+
render(detail);
|
|
32
|
+
},
|
|
33
|
+
done() {
|
|
34
|
+
process.stderr.write('\r' + ' '.repeat(cols) + '\r');
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.js","sourceRoot":"","sources":["../../src/progress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,MAAM,SAAS,GAAG,EAAE,CAAC;AAar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AAC,CAAC,CAAC,GAAG,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAClD,IAAI,IAAI,GAAG,GAAG,KAAK,KAAK,GAAG,KAAK,SAAS,IAAI,KAAK,KAAK,GAAG,KAAK,IAAI,GAAG,SAAS,EAAE,CAAC;QAElF,IAAI,IAAI,CAAC,MAAM,GAAG,IAAI;YAAE,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;QACnD,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAEzB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;IACpC,CAAC;IAED,OAAO;QACL,MAAM,CAAC,SAAiB,EAAE,MAAe;YACvC,SAAS,IAAI,SAAS,CAAC;YACvB,MAAM,CAAC,MAAM,CAAC,CAAC;QACjB,CAAC;QACD,IAAI;YACF,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;QACvD,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface SccLanguage {
|
|
2
|
+
Name: string;
|
|
3
|
+
Count: number;
|
|
4
|
+
Lines: number;
|
|
5
|
+
Blank: number;
|
|
6
|
+
Comment: number;
|
|
7
|
+
Code: number;
|
|
8
|
+
Files?: SccFile[];
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
}
|
|
11
|
+
export interface SccFile {
|
|
12
|
+
Filename?: string;
|
|
13
|
+
Location?: string;
|
|
14
|
+
Lines: number;
|
|
15
|
+
Blank: number;
|
|
16
|
+
Comment: number;
|
|
17
|
+
Code: number;
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
}
|
|
20
|
+
export interface RunSccOptions {
|
|
21
|
+
byFile?: boolean;
|
|
22
|
+
excludeDir?: string[];
|
|
23
|
+
sort?: string;
|
|
24
|
+
ci?: boolean;
|
|
25
|
+
noGitignore?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export declare function checkScc(): Promise<string>;
|
|
28
|
+
export declare function runScc(sccBinary: string | null, directories: string[], options?: RunSccOptions): Promise<SccLanguage[]>;
|
package/dist/src/scc.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
2
|
+
import { promisify } from 'node:util';
|
|
3
|
+
import { existsSync } from 'node:fs';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { OFFICE_EXTENSIONS } from './utils.js';
|
|
7
|
+
const execFileAsync = promisify(execFile);
|
|
8
|
+
function getVendoredSccPath() {
|
|
9
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
const binary = process.platform === 'win32' ? 'scc.exe' : 'scc';
|
|
11
|
+
// Works from both src/ (dev) and dist/src/ (built)
|
|
12
|
+
const candidate1 = path.join(__dirname, '..', 'vendor', binary);
|
|
13
|
+
const candidate2 = path.join(__dirname, '..', '..', 'vendor', binary);
|
|
14
|
+
if (existsSync(candidate1))
|
|
15
|
+
return candidate1;
|
|
16
|
+
return candidate2;
|
|
17
|
+
}
|
|
18
|
+
async function findScc() {
|
|
19
|
+
// Prefer vendored binary
|
|
20
|
+
const vendored = getVendoredSccPath();
|
|
21
|
+
if (existsSync(vendored))
|
|
22
|
+
return vendored;
|
|
23
|
+
// Fall back to PATH
|
|
24
|
+
try {
|
|
25
|
+
const cmd = process.platform === 'win32' ? 'where' : 'which';
|
|
26
|
+
const { stdout } = await execFileAsync(cmd, ['scc']);
|
|
27
|
+
return stdout.trim().split('\n')[0];
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export async function checkScc() {
|
|
34
|
+
const binary = await findScc();
|
|
35
|
+
if (!binary) {
|
|
36
|
+
throw new Error('scc is required but not found.\n' +
|
|
37
|
+
'Run "npm install" to auto-download it, or install manually from https://github.com/boyter/scc');
|
|
38
|
+
}
|
|
39
|
+
return binary;
|
|
40
|
+
}
|
|
41
|
+
export async function runScc(sccBinary, directories, options = {}) {
|
|
42
|
+
const { byFile = false, excludeDir = [], sort, ci = false, noGitignore = false, } = options;
|
|
43
|
+
if (!sccBinary)
|
|
44
|
+
return [];
|
|
45
|
+
const args = ['--format', 'json'];
|
|
46
|
+
// Exclude office extensions
|
|
47
|
+
args.push('--exclude-ext', OFFICE_EXTENSIONS.join(','));
|
|
48
|
+
if (byFile)
|
|
49
|
+
args.push('--by-file');
|
|
50
|
+
if (ci)
|
|
51
|
+
args.push('--ci');
|
|
52
|
+
if (noGitignore)
|
|
53
|
+
args.push('--no-gitignore');
|
|
54
|
+
for (const dir of excludeDir) {
|
|
55
|
+
args.push('--exclude-dir', dir);
|
|
56
|
+
}
|
|
57
|
+
if (sort) {
|
|
58
|
+
const sortMap = { files: 'files', name: 'name', size: 'lines', words: 'lines' };
|
|
59
|
+
args.push('-s', sortMap[sort] || 'files');
|
|
60
|
+
}
|
|
61
|
+
// Add target directories
|
|
62
|
+
const dirs = directories.length > 0 ? directories : ['.'];
|
|
63
|
+
args.push(...dirs);
|
|
64
|
+
try {
|
|
65
|
+
const { stdout } = await execFileAsync(sccBinary, args, {
|
|
66
|
+
maxBuffer: 50 * 1024 * 1024,
|
|
67
|
+
timeout: 60000,
|
|
68
|
+
});
|
|
69
|
+
if (!stdout.trim())
|
|
70
|
+
return [];
|
|
71
|
+
return JSON.parse(stdout);
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
const error = err;
|
|
75
|
+
if (error.code === 'ENOENT') {
|
|
76
|
+
throw new Error('scc binary not found.');
|
|
77
|
+
}
|
|
78
|
+
// scc exited non-zero or produced no output
|
|
79
|
+
process.stderr.write(`Warning: scc returned an error: ${error.message}\n`);
|
|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AAC;QAC3E,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ParseResult } from './types.js';
|
|
2
|
+
export interface StatsRow {
|
|
3
|
+
fileType: string;
|
|
4
|
+
fileName?: string;
|
|
5
|
+
filePath?: string;
|
|
6
|
+
files: number;
|
|
7
|
+
size: number;
|
|
8
|
+
words: number;
|
|
9
|
+
pages: number;
|
|
10
|
+
paragraphs: number;
|
|
11
|
+
sheets: number;
|
|
12
|
+
rows: number;
|
|
13
|
+
cells: number;
|
|
14
|
+
slides: number;
|
|
15
|
+
[key: string]: string | number | boolean | undefined;
|
|
16
|
+
}
|
|
17
|
+
export interface ColumnVisibility {
|
|
18
|
+
[key: string]: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface AggregateResult {
|
|
21
|
+
rows: StatsRow[];
|
|
22
|
+
totals: StatsRow;
|
|
23
|
+
columns: ColumnVisibility;
|
|
24
|
+
mode: string;
|
|
25
|
+
}
|
|
26
|
+
export interface AggregateOptions {
|
|
27
|
+
byFile?: boolean;
|
|
28
|
+
sort?: string;
|
|
29
|
+
}
|
|
30
|
+
export declare function aggregate(results: ParseResult[], options?: AggregateOptions): AggregateResult;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { METRIC_FIELDS, hasKey } from './utils.js';
|
|
3
|
+
const SUM_FIELDS = ['files', ...METRIC_FIELDS, 'size'];
|
|
4
|
+
export function aggregate(results, options = {}) {
|
|
5
|
+
const { byFile = false, sort = 'files' } = options;
|
|
6
|
+
if (byFile) {
|
|
7
|
+
return aggregateByFile(results, sort);
|
|
8
|
+
}
|
|
9
|
+
return aggregateByType(results, sort);
|
|
10
|
+
}
|
|
11
|
+
function aggregateByType(results, sort) {
|
|
12
|
+
const groups = {};
|
|
13
|
+
for (const r of results) {
|
|
14
|
+
const key = r.success ? r.fileType : 'Unreadable';
|
|
15
|
+
if (!groups[key]) {
|
|
16
|
+
const g = { fileType: key, files: 0, size: 0, words: 0, pages: 0, paragraphs: 0, sheets: 0, rows: 0, cells: 0, slides: 0 };
|
|
17
|
+
for (const f of METRIC_FIELDS) {
|
|
18
|
+
g[hasKey(f)] = false;
|
|
19
|
+
}
|
|
20
|
+
groups[key] = g;
|
|
21
|
+
}
|
|
22
|
+
const g = groups[key];
|
|
23
|
+
g.files++;
|
|
24
|
+
g.size += r.size || 0;
|
|
25
|
+
if (r.success && r.metrics) {
|
|
26
|
+
const m = r.metrics;
|
|
27
|
+
for (const f of METRIC_FIELDS) {
|
|
28
|
+
if (m[f] != null) {
|
|
29
|
+
g[f] += m[f];
|
|
30
|
+
g[hasKey(f)] = true;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return finalize(Object.values(groups), sort, 'grouped');
|
|
36
|
+
}
|
|
37
|
+
function aggregateByFile(results, sort) {
|
|
38
|
+
const rows = results.map(r => {
|
|
39
|
+
const row = {
|
|
40
|
+
fileType: r.success ? r.fileType : 'Unreadable',
|
|
41
|
+
fileName: path.basename(r.filePath),
|
|
42
|
+
filePath: r.filePath,
|
|
43
|
+
files: 1,
|
|
44
|
+
size: r.size || 0,
|
|
45
|
+
words: 0, pages: 0, paragraphs: 0, sheets: 0, rows: 0, cells: 0, slides: 0,
|
|
46
|
+
};
|
|
47
|
+
for (const f of METRIC_FIELDS) {
|
|
48
|
+
row[f] = r.metrics?.[f] || 0;
|
|
49
|
+
row[hasKey(f)] = r.metrics?.[f] != null;
|
|
50
|
+
}
|
|
51
|
+
return row;
|
|
52
|
+
});
|
|
53
|
+
return finalize(rows, sort, 'by-file');
|
|
54
|
+
}
|
|
55
|
+
function finalize(rows, sort, mode) {
|
|
56
|
+
sortRows(rows, sort);
|
|
57
|
+
const totals = computeTotals(rows);
|
|
58
|
+
const columns = detectColumns(rows);
|
|
59
|
+
return { rows, totals, columns, mode };
|
|
60
|
+
}
|
|
61
|
+
function sortRows(rows, sort) {
|
|
62
|
+
const sortFns = {
|
|
63
|
+
files: (a, b) => b.files - a.files,
|
|
64
|
+
name: (a, b) => (a.fileType || a.fileName || '').localeCompare(b.fileType || b.fileName || ''),
|
|
65
|
+
words: (a, b) => b.words - a.words,
|
|
66
|
+
size: (a, b) => b.size - a.size,
|
|
67
|
+
};
|
|
68
|
+
const fn = sortFns[sort] || sortFns.files;
|
|
69
|
+
rows.sort(fn);
|
|
70
|
+
}
|
|
71
|
+
function computeTotals(rows) {
|
|
72
|
+
const totals = { fileType: 'Total', files: 0, size: 0, words: 0, pages: 0, paragraphs: 0, sheets: 0, rows: 0, cells: 0, slides: 0 };
|
|
73
|
+
for (const f of SUM_FIELDS)
|
|
74
|
+
totals[f] = 0;
|
|
75
|
+
for (const r of rows) {
|
|
76
|
+
for (const f of SUM_FIELDS)
|
|
77
|
+
totals[f] += r[f];
|
|
78
|
+
}
|
|
79
|
+
return totals;
|
|
80
|
+
}
|
|
81
|
+
function detectColumns(rows) {
|
|
82
|
+
const columns = {};
|
|
83
|
+
for (const f of METRIC_FIELDS) {
|
|
84
|
+
columns[hasKey(f)] = rows.some(r => !!r[hasKey(f)]);
|
|
85
|
+
}
|
|
86
|
+
return columns;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=stats.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stats.js","sourceRoot":"","sources":["../../src/stats.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAoCnD,MAAM,UAAU,GAAG,CAAC,OAAO,EAAE,GAAG,aAAa,EAAE,MAAM,CAAU,CAAC;AAEhE,MAAM,UAAU,SAAS,CAAC,OAAsB,EAAE,UAA4B,EAAE;IAC9E,MAAM,EAAE,MAAM,GAAG,KAAK,EAAE,IAAI,GAAG,OAAO,EAAE,GAAG,OAAO,CAAC;IAEnD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AAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;IAC9I,KAAK,MAAM,CAAC,IAAI,UAAU;QAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAC1C,KAAK,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;QACrB,KAAK,MAAM,CAAC,IAAI,UAAU;YAAG,MAAM,CAAC,CAAC,CAAY,IAAK,CAAC,CAAC,CAAC,CAAY,CAAC;IACxE,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,aAAa,CAAC,IAAgB;IACrC,MAAM,OAAO,GAAqB,EAAE,CAAC;IACrC,KAAK,MAAM,CAAC,IAAI,aAAa,EAAE,CAAC;QAC9B,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACtD,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { StructureNode, DocumentStructure } from './types.js';
|
|
2
|
+
/** Main extraction pipeline: markdown content → DocumentStructure */
|
|
3
|
+
export declare function extractFromMarkdown(content: string): DocumentStructure;
|
|
4
|
+
/** Find which section a character range falls into */
|
|
5
|
+
export declare function findChunkSection(structure: DocumentStructure, start: number, end: number): StructureNode | null;
|
|
6
|
+
/** Get the content of a section from the original markdown */
|
|
7
|
+
export declare function getSectionContent(content: string, node: StructureNode, includeChildren?: boolean): string;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/** Step 1: Extract headers from markdown content */
|
|
2
|
+
function extractHeaders(content) {
|
|
3
|
+
const lines = content.split('\n');
|
|
4
|
+
const headers = [];
|
|
5
|
+
let charPosition = 0;
|
|
6
|
+
let inCodeBlock = false;
|
|
7
|
+
for (let i = 0; i < lines.length; i++) {
|
|
8
|
+
const line = lines[i];
|
|
9
|
+
if (line.trimStart().startsWith('```')) {
|
|
10
|
+
inCodeBlock = !inCodeBlock;
|
|
11
|
+
}
|
|
12
|
+
if (!inCodeBlock) {
|
|
13
|
+
const match = line.match(/^(#{1,6})\s+(.+)$/);
|
|
14
|
+
if (match) {
|
|
15
|
+
headers.push({
|
|
16
|
+
title: match[2].trim(),
|
|
17
|
+
level: match[1].length,
|
|
18
|
+
lineNum: i + 1,
|
|
19
|
+
startChar: charPosition,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
charPosition += line.length + 1; // +1 for newline
|
|
24
|
+
}
|
|
25
|
+
return headers;
|
|
26
|
+
}
|
|
27
|
+
/** Step 2: Compute end positions — each section ends where the next begins */
|
|
28
|
+
function computeEndPositions(headers, contentLength) {
|
|
29
|
+
return headers.map((h, i) => ({
|
|
30
|
+
...h,
|
|
31
|
+
endChar: i < headers.length - 1 ? headers[i + 1].startChar : contentLength,
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
/** Step 3: Build tree using a stack-based approach */
|
|
35
|
+
function buildTree(headers) {
|
|
36
|
+
const rootNodes = [];
|
|
37
|
+
const stack = [];
|
|
38
|
+
let nodeCounter = 0;
|
|
39
|
+
for (const h of headers) {
|
|
40
|
+
nodeCounter++;
|
|
41
|
+
const node = {
|
|
42
|
+
nodeId: String(nodeCounter).padStart(4, '0'),
|
|
43
|
+
title: h.title,
|
|
44
|
+
level: h.level,
|
|
45
|
+
startChar: h.startChar,
|
|
46
|
+
endChar: h.endChar,
|
|
47
|
+
startLine: h.lineNum,
|
|
48
|
+
children: [],
|
|
49
|
+
};
|
|
50
|
+
// Pop stack until we find a parent (lower level)
|
|
51
|
+
while (stack.length > 0 && stack[stack.length - 1].level >= h.level) {
|
|
52
|
+
stack.pop();
|
|
53
|
+
}
|
|
54
|
+
if (stack.length === 0) {
|
|
55
|
+
rootNodes.push(node);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
const parent = stack[stack.length - 1].node;
|
|
59
|
+
node.parentNodeId = parent.nodeId;
|
|
60
|
+
parent.children.push(node);
|
|
61
|
+
}
|
|
62
|
+
stack.push({ node, level: h.level });
|
|
63
|
+
}
|
|
64
|
+
return rootNodes;
|
|
65
|
+
}
|
|
66
|
+
/** Step 4: Assign dotted structure codes recursively */
|
|
67
|
+
function assignStructureCodes(nodes, prefix = '') {
|
|
68
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
69
|
+
const code = prefix ? `${prefix}.${i + 1}` : String(i + 1);
|
|
70
|
+
nodes[i].structureCode = code;
|
|
71
|
+
assignStructureCodes(nodes[i].children, code);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/** Step 5: Extract page mappings from [Page N] markers in content */
|
|
75
|
+
function extractPageMappings(content) {
|
|
76
|
+
const regex = /^\[Page\s+(\d+)\]/gm;
|
|
77
|
+
const mappings = [];
|
|
78
|
+
let match;
|
|
79
|
+
while ((match = regex.exec(content)) !== null) {
|
|
80
|
+
const pageNumber = parseInt(match[1], 10);
|
|
81
|
+
mappings.push({
|
|
82
|
+
pageNumber,
|
|
83
|
+
startChar: match.index,
|
|
84
|
+
endChar: content.length, // will be adjusted below
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
// Adjust end positions
|
|
88
|
+
for (let i = 0; i < mappings.length - 1; i++) {
|
|
89
|
+
mappings[i].endChar = mappings[i + 1].startChar;
|
|
90
|
+
}
|
|
91
|
+
return mappings;
|
|
92
|
+
}
|
|
93
|
+
/** Step 6: Map nodes to pages based on char positions */
|
|
94
|
+
function mapNodesToPages(nodes, mappings) {
|
|
95
|
+
if (mappings.length === 0)
|
|
96
|
+
return;
|
|
97
|
+
function findPage(charPos) {
|
|
98
|
+
for (const m of mappings) {
|
|
99
|
+
if (charPos >= m.startChar && charPos < m.endChar) {
|
|
100
|
+
return m.pageNumber;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
function mapRecursive(nodeList) {
|
|
106
|
+
for (const node of nodeList) {
|
|
107
|
+
node.startPage = findPage(node.startChar);
|
|
108
|
+
node.endPage = findPage(Math.max(node.endChar - 1, node.startChar));
|
|
109
|
+
mapRecursive(node.children);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
mapRecursive(nodes);
|
|
113
|
+
}
|
|
114
|
+
/** Compute max depth of the tree */
|
|
115
|
+
function computeMaxDepth(nodes) {
|
|
116
|
+
if (nodes.length === 0)
|
|
117
|
+
return 0;
|
|
118
|
+
let max = 0;
|
|
119
|
+
for (const node of nodes) {
|
|
120
|
+
const childDepth = computeMaxDepth(node.children);
|
|
121
|
+
max = Math.max(max, 1 + childDepth);
|
|
122
|
+
}
|
|
123
|
+
return max;
|
|
124
|
+
}
|
|
125
|
+
/** Count total nodes in tree */
|
|
126
|
+
function countNodes(nodes) {
|
|
127
|
+
let count = 0;
|
|
128
|
+
for (const node of nodes) {
|
|
129
|
+
count += 1 + countNodes(node.children);
|
|
130
|
+
}
|
|
131
|
+
return count;
|
|
132
|
+
}
|
|
133
|
+
/** Main extraction pipeline: markdown content → DocumentStructure */
|
|
134
|
+
export function extractFromMarkdown(content) {
|
|
135
|
+
const rawHeaders = extractHeaders(content);
|
|
136
|
+
if (rawHeaders.length === 0) {
|
|
137
|
+
return { rootNodes: [], pageMappings: [], totalNodes: 0, maxDepth: 0 };
|
|
138
|
+
}
|
|
139
|
+
const withEnds = computeEndPositions(rawHeaders, content.length);
|
|
140
|
+
const rootNodes = buildTree(withEnds);
|
|
141
|
+
assignStructureCodes(rootNodes);
|
|
142
|
+
const pageMappings = extractPageMappings(content);
|
|
143
|
+
mapNodesToPages(rootNodes, pageMappings);
|
|
144
|
+
return {
|
|
145
|
+
rootNodes,
|
|
146
|
+
pageMappings,
|
|
147
|
+
totalNodes: countNodes(rootNodes),
|
|
148
|
+
maxDepth: computeMaxDepth(rootNodes),
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
/** Find which section a character range falls into */
|
|
152
|
+
export function findChunkSection(structure, start, end) {
|
|
153
|
+
let best = null;
|
|
154
|
+
function search(nodes) {
|
|
155
|
+
for (const node of nodes) {
|
|
156
|
+
if (start >= node.startChar && start < node.endChar) {
|
|
157
|
+
best = node;
|
|
158
|
+
search(node.children);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
search(structure.rootNodes);
|
|
163
|
+
return best;
|
|
164
|
+
}
|
|
165
|
+
/** Get the content of a section from the original markdown */
|
|
166
|
+
export function getSectionContent(content, node, includeChildren = true) {
|
|
167
|
+
if (includeChildren) {
|
|
168
|
+
return content.slice(node.startChar, node.endChar);
|
|
169
|
+
}
|
|
170
|
+
// Exclude children: get content from section start to first child start
|
|
171
|
+
if (node.children.length === 0) {
|
|
172
|
+
return content.slice(node.startChar, node.endChar);
|
|
173
|
+
}
|
|
174
|
+
return content.slice(node.startChar, node.children[0].startChar);
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=extract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract.js","sourceRoot":"","sources":["../../../src/structure/extract.ts"],"names":[],"mappings":"AASA,oDAAoD;AACpD,SAAS,cAAc,CAAC,OAAe;IACrC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAClC,MAAM,OAAO,GAAgB,EAAE,CAAC;IAChC,IAAI,YAAY,GAAG,CAAC,CAAC;IACrB,IAAI,WAAW,GAAG,KAAK,CAAC;IAExB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,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CAAC;IAC5B,OAAO,IAAI,CAAC;AACd,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,iBAAiB,CAAC,OAAe,EAAE,IAAmB,EAAE,eAAe,GAAG,IAAI;IAC5F,IAAI,eAAe,EAAE,CAAC;QACpB,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACrD,CAAC;IAED,wEAAwE;IACxE,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACrD,CAAC;IACD,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/structure/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAExF,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export interface PageMapping {
|
|
2
|
+
pageNumber: number;
|
|
3
|
+
startChar: number;
|
|
4
|
+
endChar: number;
|
|
5
|
+
}
|
|
6
|
+
export interface StructureNode {
|
|
7
|
+
nodeId: string;
|
|
8
|
+
title: string;
|
|
9
|
+
level: number;
|
|
10
|
+
startChar: number;
|
|
11
|
+
endChar: number;
|
|
12
|
+
startLine: number;
|
|
13
|
+
startPage?: number;
|
|
14
|
+
endPage?: number;
|
|
15
|
+
parentNodeId?: string;
|
|
16
|
+
structureCode?: string;
|
|
17
|
+
children: StructureNode[];
|
|
18
|
+
}
|
|
19
|
+
export interface DocumentStructure {
|
|
20
|
+
rootNodes: StructureNode[];
|
|
21
|
+
pageMappings: PageMapping[];
|
|
22
|
+
totalNodes: number;
|
|
23
|
+
maxDepth: number;
|
|
24
|
+
}
|
|
25
|
+
export declare function flatten(nodes: StructureNode[]): StructureNode[];
|
|
26
|
+
export declare function getNodeById(nodes: StructureNode[], nodeId: string): StructureNode | undefined;
|
|
27
|
+
export declare function getNodeByPath(nodes: StructureNode[], structureCode: string): StructureNode | undefined;
|
|
28
|
+
export declare function toDict(structure: DocumentStructure): Record<string, unknown>;
|
|
29
|
+
export declare function fromDict(data: Record<string, unknown>): DocumentStructure;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export function flatten(nodes) {
|
|
2
|
+
const result = [];
|
|
3
|
+
function walk(list) {
|
|
4
|
+
for (const node of list) {
|
|
5
|
+
result.push(node);
|
|
6
|
+
walk(node.children);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
walk(nodes);
|
|
10
|
+
return result;
|
|
11
|
+
}
|
|
12
|
+
export function getNodeById(nodes, nodeId) {
|
|
13
|
+
for (const node of flatten(nodes)) {
|
|
14
|
+
if (node.nodeId === nodeId)
|
|
15
|
+
return node;
|
|
16
|
+
}
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
export function getNodeByPath(nodes, structureCode) {
|
|
20
|
+
for (const node of flatten(nodes)) {
|
|
21
|
+
if (node.structureCode === structureCode)
|
|
22
|
+
return node;
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
export function toDict(structure) {
|
|
27
|
+
function nodeToDict(node) {
|
|
28
|
+
return {
|
|
29
|
+
nodeId: node.nodeId,
|
|
30
|
+
title: node.title,
|
|
31
|
+
level: node.level,
|
|
32
|
+
startChar: node.startChar,
|
|
33
|
+
endChar: node.endChar,
|
|
34
|
+
startLine: node.startLine,
|
|
35
|
+
startPage: node.startPage,
|
|
36
|
+
endPage: node.endPage,
|
|
37
|
+
parentNodeId: node.parentNodeId,
|
|
38
|
+
structureCode: node.structureCode,
|
|
39
|
+
children: node.children.map(nodeToDict),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
rootNodes: structure.rootNodes.map(nodeToDict),
|
|
44
|
+
pageMappings: structure.pageMappings,
|
|
45
|
+
totalNodes: structure.totalNodes,
|
|
46
|
+
maxDepth: structure.maxDepth,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export function fromDict(data) {
|
|
50
|
+
function nodeFromDict(d) {
|
|
51
|
+
return {
|
|
52
|
+
nodeId: d.nodeId,
|
|
53
|
+
title: d.title,
|
|
54
|
+
level: d.level,
|
|
55
|
+
startChar: d.startChar,
|
|
56
|
+
endChar: d.endChar,
|
|
57
|
+
startLine: d.startLine,
|
|
58
|
+
startPage: d.startPage,
|
|
59
|
+
endPage: d.endPage,
|
|
60
|
+
parentNodeId: d.parentNodeId,
|
|
61
|
+
structureCode: d.structureCode,
|
|
62
|
+
children: d.children.map(nodeFromDict),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
rootNodes: data.rootNodes.map(nodeFromDict),
|
|
67
|
+
pageMappings: data.pageMappings,
|
|
68
|
+
totalNodes: data.totalNodes,
|
|
69
|
+
maxDepth: data.maxDepth,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/structure/types.ts"],"names":[],"mappings":"AA2BA,MAAM,UAAU,OAAO,CAAC,KAAsB;IAC5C,MAAM,MAAM,GAAoB,EAAE,CAAC;IACnC,SAAS,IAAI,CAAC,IAAqB;QACjC,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;YACxB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC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AS,CAAC,YAAY;QACpC,UAAU,EAAE,SAAS,CAAC,UAAU;QAChC,QAAQ,EAAE,SAAS,CAAC,QAAQ;KAC7B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,IAA6B;IACpD,SAAS,YAAY,CAAC,CAA0B;QAC9C,OAAO;YACL,MAAM,EAAE,CAAC,CAAC,MAAgB;YAC1B,KAAK,EAAE,CAAC,CAAC,KAAe;YACxB,KAAK,EAAE,CAAC,CAAC,KAAe;YACxB,SAAS,EAAE,CAAC,CAAC,SAAmB;YAChC,OAAO,EAAE,CAAC,CAAC,OAAiB;YAC5B,SAAS,EAAE,CAAC,CAAC,SAAmB;YAChC,SAAS,EAAE,CAAC,CAAC,SAA+B;YAC5C,OAAO,EAAE,CAAC,CAAC,OAA6B;YACxC,YAAY,EAAE,CAAC,CAAC,YAAkC;YAClD,aAAa,EAAE,CAAC,CAAC,aAAmC;YACpD,QAAQ,EAAG,CAAC,CAAC,QAAsC,CAAC,GAAG,CAAC,YAAY,CAAC;SACtE,CAAC;IACJ,CAAC;IACD,OAAO;QACL,SAAS,EAAG,IAAI,CAAC,SAAuC,CAAC,GAAG,CAAC,YAAY,CAAC;QAC1E,YAAY,EAAE,IAAI,CAAC,YAA6B;QAChD,UAAU,EAAE,IAAI,CAAC,UAAoB;QACrC,QAAQ,EAAE,IAAI,CAAC,QAAkB;KAClC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface FileEntry {
|
|
2
|
+
path: string;
|
|
3
|
+
size: number;
|
|
4
|
+
}
|
|
5
|
+
export interface SkippedEntry {
|
|
6
|
+
path: string;
|
|
7
|
+
reason: string;
|
|
8
|
+
size: number;
|
|
9
|
+
}
|
|
10
|
+
export interface ParserOutput {
|
|
11
|
+
fileType: string;
|
|
12
|
+
metrics: Record<string, number>;
|
|
13
|
+
}
|
|
14
|
+
export interface ParseResult {
|
|
15
|
+
filePath: string;
|
|
16
|
+
size: number;
|
|
17
|
+
success: boolean;
|
|
18
|
+
fileType: string;
|
|
19
|
+
metrics: Record<string, number> | null;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|