feat: add local OneNote and ONEPKG reader

This commit is contained in:
2026-07-22 17:06:03 +02:00
commit f581cbdced
93 changed files with 14949 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.
export interface OneNoteParserLimits {
maxFileBytes: number;
maxTransactionFragments: number;
maxTransactionEntries: number;
maxListFragments: number;
maxListDepth: number;
maxFileNodes: number;
maxObjects: number;
maxPropertiesPerSet: number;
maxPropertyDepth: number;
maxStreamIds: number;
maxVectorBytes: number;
maxObjectReferences: number;
maxGraphDepth: number;
maxPages: number;
maxDiagnostics: number;
maxExtractedTextChars: number;
}
export const DEFAULT_ONENOTE_PARSER_LIMITS: Readonly<OneNoteParserLimits> = {
maxFileBytes: 512 * 1024 * 1024,
maxTransactionFragments: 16_384,
maxTransactionEntries: 1_000_000,
maxListFragments: 16_384,
maxListDepth: 64,
maxFileNodes: 1_000_000,
maxObjects: 500_000,
maxPropertiesPerSet: 16_384,
maxPropertyDepth: 64,
maxStreamIds: 1_000_000,
maxVectorBytes: 64 * 1024 * 1024,
maxObjectReferences: 1_000_000,
maxGraphDepth: 256,
maxPages: 100_000,
maxDiagnostics: 10_000,
maxExtractedTextChars: 2_000_000,
};
export function resolveParserLimits(
limits: Partial<OneNoteParserLimits> = {}
): OneNoteParserLimits {
const resolved = { ...DEFAULT_ONENOTE_PARSER_LIMITS, ...limits };
for (const [name, value] of Object.entries(resolved)) {
if (!Number.isSafeInteger(value) || value <= 0) {
throw new TypeError(`${name} must be a positive safe integer`);
}
}
return resolved;
}