@gmickel/gno 1.46.0 → 2.0.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 +1 -1
- package/THIRD_PARTY_NOTICES.md +46 -0
- package/assets/skill/SKILL.md +7 -6
- package/assets/spa-production.json.gz +0 -0
- package/browser-extension/artifacts/gno-browser-clipper-v2.0.0.zip +0 -0
- package/browser-extension/artifacts/gno-browser-clipper-v2.0.0.zip.sha256 +1 -0
- package/browser-extension/dist/chunk-4tc9v0ja.js +74 -0
- package/browser-extension/dist/manifest.json +1 -1
- package/browser-extension/dist/preview.html +1 -1
- package/browser-extension/dist/service-worker.js +32 -33
- package/bunfig.toml +2 -0
- package/package.json +40 -26
- package/spec/cli.md +21 -4
- package/spec/db/schema.sql +146 -1
- package/spec/mcp.md +26 -0
- package/src/app/context-runtime-types.ts +3 -0
- package/src/app/context-runtime.ts +2 -0
- package/src/cli/commands/ask.ts +6 -1
- package/src/cli/commands/daemon.ts +21 -8
- package/src/cli/commands/embed.ts +77 -41
- package/src/cli/detach.ts +3 -2
- package/src/config/types.ts +3 -3
- package/src/converters/adapters/markitdownTs/adapter.ts +1 -2
- package/src/converters/adapters/officeparser/adapter.ts +1 -2
- package/src/converters/versions.ts +6 -8
- package/src/core/context-evidence.ts +8 -4
- package/src/core/job-manager.ts +95 -13
- package/src/core/network-boundary-inventory.ts +10 -0
- package/src/core/shutdown-budget.ts +45 -0
- package/src/embed/backlog.ts +107 -4
- package/src/embed/batch.ts +42 -2
- package/src/embed/fingerprint.ts +16 -0
- package/src/embed/retry.ts +113 -5
- package/src/embed/variant-backlog.ts +105 -0
- package/src/embed/variant-plan.ts +62 -0
- package/src/embed/variant-retry.ts +113 -0
- package/src/ingestion/graph-reconciliation.ts +327 -0
- package/src/ingestion/sync.ts +9 -272
- package/src/llm/http-inference.ts +6 -0
- package/src/llm/httpEmbedding.ts +37 -6
- package/src/llm/httpGeneration.ts +18 -3
- package/src/llm/httpRerank.ts +23 -5
- package/src/llm/inference-cancellation.ts +168 -0
- package/src/llm/inference-scope.ts +202 -0
- package/src/llm/lazy-ports.ts +115 -0
- package/src/llm/native-worker/client.ts +541 -0
- package/src/llm/native-worker/dispatcher.ts +228 -0
- package/src/llm/native-worker/embedding-identity.ts +33 -0
- package/src/llm/native-worker/entry.ts +173 -0
- package/src/llm/native-worker/errors.ts +32 -0
- package/src/llm/native-worker/evaluation.ts +16 -0
- package/src/llm/native-worker/owned-exit.ts +108 -0
- package/src/llm/native-worker/owner.ts +141 -0
- package/src/llm/native-worker/ports.ts +317 -0
- package/src/llm/native-worker/protocol.ts +442 -0
- package/src/llm/native-worker/runtime-config.ts +92 -0
- package/src/llm/nodeLlamaCpp/adapter.ts +77 -20
- package/src/llm/nodeLlamaCpp/embedding.ts +130 -46
- package/src/llm/nodeLlamaCpp/generation.ts +34 -5
- package/src/llm/nodeLlamaCpp/lifecycle-options.ts +99 -0
- package/src/llm/nodeLlamaCpp/lifecycle.ts +209 -204
- package/src/llm/nodeLlamaCpp/rerank-capacity.ts +111 -0
- package/src/llm/nodeLlamaCpp/rerank.ts +118 -27
- package/src/llm/nodeLlamaCpp/simulator-handle.ts +73 -0
- package/src/llm/nodeLlamaCpp/simulator-install.ts +124 -0
- package/src/llm/nodeLlamaCpp/simulator-session.ts +240 -0
- package/src/llm/nodeLlamaCpp/simulator-types.ts +80 -0
- package/src/llm/types.ts +35 -5
- package/src/mcp/context.ts +27 -0
- package/src/mcp/http-transport.ts +12 -10
- package/src/mcp/server.ts +3 -0
- package/src/mcp/tool-profile.ts +30 -8
- package/src/mcp/tools/context.ts +8 -11
- package/src/mcp/tools/embed.ts +1 -1
- package/src/mcp/tools/index-cmd.ts +1 -1
- package/src/mcp/tools/index.ts +10 -8
- package/src/mcp/tools/query.ts +14 -30
- package/src/mcp/tools/vsearch.ts +1 -1
- package/src/pipeline/answer.ts +23 -3
- package/src/pipeline/claim-verifier.ts +6 -0
- package/src/pipeline/expansion.ts +43 -40
- package/src/pipeline/explain.ts +6 -2
- package/src/pipeline/filters.ts +63 -0
- package/src/pipeline/fusion.ts +29 -9
- package/src/pipeline/graph-retrieval.ts +29 -9
- package/src/pipeline/hybrid.ts +198 -55
- package/src/pipeline/hydration.ts +161 -0
- package/src/pipeline/owner-fusion.ts +87 -0
- package/src/pipeline/rerank.ts +35 -11
- package/src/pipeline/search.ts +13 -2
- package/src/pipeline/types.ts +5 -3
- package/src/pipeline/vsearch.ts +87 -7
- package/src/sdk/client.ts +47 -3
- package/src/sdk/embed.ts +63 -39
- package/src/serve/background-runtime.ts +1 -1
- package/src/serve/context.ts +41 -56
- package/src/serve/embed-scheduler.ts +58 -35
- package/src/serve/public/components/IndexingProgress.tsx +46 -60
- package/src/serve/public/globals.built.css +1 -1
- package/src/serve/public/lib/shiki-language-ids.ts +14 -0
- package/src/serve/resident-admission.ts +36 -36
- package/src/serve/resident-background-work.ts +20 -2
- package/src/serve/resident-request.ts +11 -5
- package/src/serve/resident-runtime.ts +97 -61
- package/src/serve/resident-shutdown.ts +153 -0
- package/src/serve/routes/api.ts +3 -1
- package/src/serve/server.ts +47 -26
- package/src/store/migrations/028-vector-variants.ts +54 -0
- package/src/store/migrations/029-graph-reference-state.ts +77 -0
- package/src/store/migrations/index.ts +4 -0
- package/src/store/sqlite/adapter.ts +251 -183
- package/src/store/sqlite/eligibility.ts +174 -0
- package/src/store/sqlite/graph-edge-application.ts +66 -0
- package/src/store/sqlite/graph-reference-state.ts +194 -0
- package/src/store/sqlite/legacy-vector-ownership.ts +79 -0
- package/src/store/types.ts +80 -12
- package/src/store/vector/eligibility.ts +36 -0
- package/src/store/vector/freshness.ts +33 -6
- package/src/store/vector/lazy.ts +81 -0
- package/src/store/vector/sqlite-vec.ts +106 -54
- package/src/store/vector/stats.ts +14 -3
- package/src/store/vector/types.ts +35 -2
- package/src/store/vector/variant-search.ts +192 -0
- package/src/store/vector/variants.ts +451 -0
- package/vendor/converters/markitdown-ts/LICENSE +21 -0
- package/vendor/converters/markitdown-ts/dist/index.cjs +1180 -0
- package/vendor/converters/markitdown-ts/dist/index.d.cts +46 -0
- package/vendor/converters/markitdown-ts/dist/index.d.mts +46 -0
- package/vendor/converters/markitdown-ts/dist/index.d.ts +46 -0
- package/vendor/converters/markitdown-ts/dist/index.mjs +1152 -0
- package/vendor/converters/markitdown-ts/package.json +77 -0
- package/vendor/converters/officeparser/LICENSE +21 -0
- package/vendor/converters/officeparser/dist/OfficeConverter.d.ts +47 -0
- package/vendor/converters/officeparser/dist/OfficeConverter.js +76 -0
- package/vendor/converters/officeparser/dist/OfficeGenerator.d.ts +23 -0
- package/vendor/converters/officeparser/dist/OfficeGenerator.js +73 -0
- package/vendor/converters/officeparser/dist/OfficeParser.d.ts +106 -0
- package/vendor/converters/officeparser/dist/OfficeParser.js +332 -0
- package/vendor/converters/officeparser/dist/cli.d.ts +28 -0
- package/vendor/converters/officeparser/dist/cli.js +381 -0
- package/vendor/converters/officeparser/dist/defaults.d.ts +41 -0
- package/vendor/converters/officeparser/dist/defaults.js +218 -0
- package/vendor/converters/officeparser/dist/generators/BaseGenerator.d.ts +107 -0
- package/vendor/converters/officeparser/dist/generators/BaseGenerator.js +248 -0
- package/vendor/converters/officeparser/dist/generators/ChunkingGenerator.d.ts +82 -0
- package/vendor/converters/officeparser/dist/generators/ChunkingGenerator.js +797 -0
- package/vendor/converters/officeparser/dist/generators/CsvGenerator.d.ts +38 -0
- package/vendor/converters/officeparser/dist/generators/CsvGenerator.js +245 -0
- package/vendor/converters/officeparser/dist/generators/EpubGenerator.d.ts +43 -0
- package/vendor/converters/officeparser/dist/generators/EpubGenerator.js +315 -0
- package/vendor/converters/officeparser/dist/generators/HtmlGenerator.d.ts +59 -0
- package/vendor/converters/officeparser/dist/generators/HtmlGenerator.js +1942 -0
- package/vendor/converters/officeparser/dist/generators/MarkdownGenerator.d.ts +96 -0
- package/vendor/converters/officeparser/dist/generators/MarkdownGenerator.js +1175 -0
- package/vendor/converters/officeparser/dist/generators/PdfGenerator.d.ts +22 -0
- package/vendor/converters/officeparser/dist/generators/PdfGenerator.js +194 -0
- package/vendor/converters/officeparser/dist/generators/RtfGenerator.d.ts +29 -0
- package/vendor/converters/officeparser/dist/generators/RtfGenerator.js +316 -0
- package/vendor/converters/officeparser/dist/generators/TextGenerator.d.ts +13 -0
- package/vendor/converters/officeparser/dist/generators/TextGenerator.js +201 -0
- package/vendor/converters/officeparser/dist/index.d.ts +60 -0
- package/vendor/converters/officeparser/dist/index.js +72 -0
- package/vendor/converters/officeparser/dist/index.mjs +18 -0
- package/vendor/converters/officeparser/dist/officeparser.browser.d.ts +2621 -0
- package/vendor/converters/officeparser/dist/officeparser.browser.iife.js +1336 -0
- package/vendor/converters/officeparser/dist/officeparser.browser.mjs +1335 -0
- package/vendor/converters/officeparser/dist/officeparser.browser.slim.d.ts +2621 -0
- package/vendor/converters/officeparser/dist/officeparser.browser.slim.iife.js +1336 -0
- package/vendor/converters/officeparser/dist/officeparser.browser.slim.mjs +1335 -0
- package/vendor/converters/officeparser/dist/parsers/CsvParser.d.ts +9 -0
- package/vendor/converters/officeparser/dist/parsers/CsvParser.js +115 -0
- package/vendor/converters/officeparser/dist/parsers/EpubParser.d.ts +8 -0
- package/vendor/converters/officeparser/dist/parsers/EpubParser.js +217 -0
- package/vendor/converters/officeparser/dist/parsers/ExcelParser.d.ts +32 -0
- package/vendor/converters/officeparser/dist/parsers/ExcelParser.js +736 -0
- package/vendor/converters/officeparser/dist/parsers/HtmlParser.d.ts +2 -0
- package/vendor/converters/officeparser/dist/parsers/HtmlParser.js +1287 -0
- package/vendor/converters/officeparser/dist/parsers/MarkdownParser.d.ts +2 -0
- package/vendor/converters/officeparser/dist/parsers/MarkdownParser.js +1272 -0
- package/vendor/converters/officeparser/dist/parsers/OpenOfficeParser.d.ts +31 -0
- package/vendor/converters/officeparser/dist/parsers/OpenOfficeParser.js +1819 -0
- package/vendor/converters/officeparser/dist/parsers/PdfParser.d.ts +67 -0
- package/vendor/converters/officeparser/dist/parsers/PdfParser.js +848 -0
- package/vendor/converters/officeparser/dist/parsers/PowerPointParser.d.ts +32 -0
- package/vendor/converters/officeparser/dist/parsers/PowerPointParser.js +950 -0
- package/vendor/converters/officeparser/dist/parsers/RtfParser.d.ts +187 -0
- package/vendor/converters/officeparser/dist/parsers/RtfParser.js +1801 -0
- package/vendor/converters/officeparser/dist/parsers/WordParser.d.ts +79 -0
- package/vendor/converters/officeparser/dist/parsers/WordParser.js +1177 -0
- package/vendor/converters/officeparser/dist/sbom.cdx.json +1763 -0
- package/vendor/converters/officeparser/dist/types.d.ts +2507 -0
- package/vendor/converters/officeparser/dist/types.js +107 -0
- package/vendor/converters/officeparser/dist/utils/astUtils.d.ts +16 -0
- package/vendor/converters/officeparser/dist/utils/astUtils.js +33 -0
- package/vendor/converters/officeparser/dist/utils/chartUtils.d.ts +6 -0
- package/vendor/converters/officeparser/dist/utils/chartUtils.js +257 -0
- package/vendor/converters/officeparser/dist/utils/configUtils.d.ts +44 -0
- package/vendor/converters/officeparser/dist/utils/configUtils.js +315 -0
- package/vendor/converters/officeparser/dist/utils/dateUtils.d.ts +17 -0
- package/vendor/converters/officeparser/dist/utils/dateUtils.js +69 -0
- package/vendor/converters/officeparser/dist/utils/envUtils.d.ts +29 -0
- package/vendor/converters/officeparser/dist/utils/envUtils.js +152 -0
- package/vendor/converters/officeparser/dist/utils/errorUtils.d.ts +72 -0
- package/vendor/converters/officeparser/dist/utils/errorUtils.js +245 -0
- package/vendor/converters/officeparser/dist/utils/imageUtils.d.ts +66 -0
- package/vendor/converters/officeparser/dist/utils/imageUtils.js +133 -0
- package/vendor/converters/officeparser/dist/utils/mathUtils.d.ts +42 -0
- package/vendor/converters/officeparser/dist/utils/mathUtils.js +385 -0
- package/vendor/converters/officeparser/dist/utils/moduleLoader.d.ts +18 -0
- package/vendor/converters/officeparser/dist/utils/moduleLoader.js +106 -0
- package/vendor/converters/officeparser/dist/utils/ocrUtils.d.ts +42 -0
- package/vendor/converters/officeparser/dist/utils/ocrUtils.js +428 -0
- package/vendor/converters/officeparser/dist/utils/sanitize.d.ts +148 -0
- package/vendor/converters/officeparser/dist/utils/sanitize.js +344 -0
- package/vendor/converters/officeparser/dist/utils/sheetUtils.d.ts +7 -0
- package/vendor/converters/officeparser/dist/utils/sheetUtils.js +35 -0
- package/vendor/converters/officeparser/dist/utils/styleMapper.d.ts +36 -0
- package/vendor/converters/officeparser/dist/utils/styleMapper.js +224 -0
- package/vendor/converters/officeparser/dist/utils/xmlUtils.d.ts +163 -0
- package/vendor/converters/officeparser/dist/utils/xmlUtils.js +461 -0
- package/vendor/converters/officeparser/dist/utils/zipUtils.d.ts +134 -0
- package/vendor/converters/officeparser/dist/utils/zipUtils.js +337 -0
- package/vendor/converters/officeparser/package.json +147 -0
- package/vendor/converters/upstream-manifest.json +124 -0
- package/vendor/dependency-fixes/README.md +77 -0
- package/vendor/dependency-fixes/vendor-converters.py +83 -0
- package/browser-extension/artifacts/gno-browser-clipper-v1.46.0.zip +0 -0
- package/browser-extension/artifacts/gno-browser-clipper-v1.46.0.zip.sha256 +0 -1
- package/browser-extension/dist/chunk-627emwpj.js +0 -75
- /package/browser-extension/dist/{chunk-ydfx5d7p.css → chunk-z74y8n8c.css} +0 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RTF (Rich Text Format) Parser
|
|
3
|
+
*
|
|
4
|
+
* **RTF Format Overview:**
|
|
5
|
+
* RTF is a proprietary document format developed by Microsoft in 1987.
|
|
6
|
+
* Unlike OOXML formats (DOCX), RTF is a plain text format using control words and groups.
|
|
7
|
+
*
|
|
8
|
+
* **Basic RTF Structure:**
|
|
9
|
+
* ```rtf
|
|
10
|
+
* {\rtf1\ansi
|
|
11
|
+
* {\fonttbl{\f0 Arial;}{\f1 Times;}}
|
|
12
|
+
* {\colortbl;\red255\green0\blue0;\red0\green0\blue255;}
|
|
13
|
+
* \f0\fs24 This is \b bold\b0 and \i italic\i0 text.\par
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* **RTF Elements:**
|
|
18
|
+
* 1. **Control Words**: Backslash followed by letters and optional parameter (e.g., `\fs24`, `\b`, `\par`)
|
|
19
|
+
* 2. **Control Symbols**: Backslash followed by single special char (e.g., `\'xx` for hex char, `\{`, `\}`, `\\`)
|
|
20
|
+
* 3. **Groups**: Content enclosed in `{...}` - creates formatting scope
|
|
21
|
+
* 4. **Text**: Plain text characters
|
|
22
|
+
*
|
|
23
|
+
* **Key Control Words:**
|
|
24
|
+
* - `\rtf1` - RTF version 1
|
|
25
|
+
* - `\fs24` - Font size in half-points (24 = 12pt)
|
|
26
|
+
* - `\b`,`\i`,`\ul`,`\strike` - Bold, italic, underline, strikethrough
|
|
27
|
+
* - `\par` - Paragraph break
|
|
28
|
+
* - `\f0` - Switch to font 0 from font table
|
|
29
|
+
* - `\cf1` - Text color from color table
|
|
30
|
+
* - `\cb2` - Background color from color table
|
|
31
|
+
* - `\sub`,`\super` - Subscript, superscript
|
|
32
|
+
*
|
|
33
|
+
* **Parser Architecture:**
|
|
34
|
+
* This module uses a two-phase approach:
|
|
35
|
+
* 1. **Lexical Phase** (`SimpleRtfParser`): Tokenizes RTF into groups, control words, and text
|
|
36
|
+
* 2. **Semantic Phase** (`parseRtf`): Traverses the token tree to build the AST
|
|
37
|
+
*
|
|
38
|
+
* @module RtfParser
|
|
39
|
+
* @see https://www.biblioscape.com/rtf15_spec.htm RTF 1.5 Specification
|
|
40
|
+
* @see https://latex2rtf.sourceforge.net/RTF-Spec-1.2.pdf RTF 1.2 Specification
|
|
41
|
+
*/
|
|
42
|
+
import { FullOfficeParserConfig, OfficeParserAST } from '../types.js';
|
|
43
|
+
/**
|
|
44
|
+
* Represents an RTF group (content enclosed in braces).
|
|
45
|
+
* Groups create formatting scopes and can contain other groups, control words, or text.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* // RTF: {\b bold text}
|
|
49
|
+
* // Parsed as group containing control word 'b' and text 'bold text'
|
|
50
|
+
*/
|
|
51
|
+
export interface RtfGroup {
|
|
52
|
+
/** Node type identifier */
|
|
53
|
+
type: 'group';
|
|
54
|
+
/** Contents of this group (can be nested groups, control words, or text) */
|
|
55
|
+
content: (RtfGroup | RtfText | RtfControl)[];
|
|
56
|
+
/**
|
|
57
|
+
* The destination control word for this group (if any).
|
|
58
|
+
* Destinations specify what the group contains (e.g., 'fonttbl' for font table).
|
|
59
|
+
* Common destinations: 'fonttbl', 'colortbl', 'footer', 'header', 'pict', 'footnote'
|
|
60
|
+
* @example "fonttbl", "colortbl", "footnote"
|
|
61
|
+
*/
|
|
62
|
+
destination?: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Represents plain text content in RTF.
|
|
66
|
+
* Text nodes contain the actual displayable characters.
|
|
67
|
+
*/
|
|
68
|
+
export interface RtfText {
|
|
69
|
+
/** Node type identifier */
|
|
70
|
+
type: 'text';
|
|
71
|
+
/** The text content (may be a single character or multiple characters) */
|
|
72
|
+
value: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Represents an RTF control word or control symbol.
|
|
76
|
+
* Control words modify formatting, specify special characters, or provide document structure.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* // \fs24 - Control word "fs" with parameter 24
|
|
80
|
+
* { type: 'control', value: 'fs', param: 24 }
|
|
81
|
+
*
|
|
82
|
+
* // \b - Control word "b" with no parameter (defaults to "on")
|
|
83
|
+
* { type: 'control', value: 'b', param: undefined }
|
|
84
|
+
*
|
|
85
|
+
* // \u1234 - Unicode character U+1234
|
|
86
|
+
* { type: 'control', value: 'u', param: 1234 }
|
|
87
|
+
*/
|
|
88
|
+
export interface RtfControl {
|
|
89
|
+
/** Node type identifier */
|
|
90
|
+
type: 'control';
|
|
91
|
+
/**
|
|
92
|
+
* The control word name (without backslash).
|
|
93
|
+
* @example "fs" for font size, "b" for bold, "par" for paragraph
|
|
94
|
+
*/
|
|
95
|
+
value: string;
|
|
96
|
+
/**
|
|
97
|
+
* Optional numeric parameter.
|
|
98
|
+
* - For `\fs24`: param = 24 (12pt font)
|
|
99
|
+
* - For `\b`: param = undefined (defaults to "on")
|
|
100
|
+
* - For `\b0`: param = 0 (explicitly "off")
|
|
101
|
+
* - For `\u1234`: param = 1234 (Unicode code point)
|
|
102
|
+
*/
|
|
103
|
+
param?: number;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Union type representing any RTF parse tree node.
|
|
107
|
+
*/
|
|
108
|
+
export type RtfNode = RtfGroup | RtfText | RtfControl;
|
|
109
|
+
/**
|
|
110
|
+
* Low-level RTF tokenizer that parses RTF syntax into a tree structure.
|
|
111
|
+
*
|
|
112
|
+
* This class performs lexical analysis on RTF content, breaking it down into:
|
|
113
|
+
* - Groups (enclosed in braces)
|
|
114
|
+
* - Control words (e.g., `\fs24`, `\b`)
|
|
115
|
+
* - Control symbols (e.g., `\'xx`, `\{`)
|
|
116
|
+
* - Plain text
|
|
117
|
+
*
|
|
118
|
+
* The parser uses a byte-level approach and maintains a stack to track nested groups.
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```typescript
|
|
122
|
+
* const buffer = Buffer.from('{\\rtf1 Hello \\b world\\b0}');
|
|
123
|
+
* const parser = new SimpleRtfParser(buffer);
|
|
124
|
+
* const tree = parser.parse();
|
|
125
|
+
* // tree.content contains parsed RTF nodes
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
export declare class SimpleRtfParser {
|
|
129
|
+
/** Current position in the buffer */
|
|
130
|
+
private index;
|
|
131
|
+
/** The RTF content as a Buffer */
|
|
132
|
+
private buffer;
|
|
133
|
+
/** Current code page for character decoding (default is Windows-1252) */
|
|
134
|
+
private codePage;
|
|
135
|
+
/** Cached TextDecoders for different code pages */
|
|
136
|
+
private decoders;
|
|
137
|
+
/** Buffer for consecutive text bytes to handle multi-byte encodings and UTF-8 detection */
|
|
138
|
+
private pendingBytes;
|
|
139
|
+
/** Total length of the buffer */
|
|
140
|
+
private length;
|
|
141
|
+
/**
|
|
142
|
+
* Creates a new RTF parser.
|
|
143
|
+
* @param buffer - The RTF file content as a Buffer
|
|
144
|
+
*/
|
|
145
|
+
constructor(buffer: Buffer);
|
|
146
|
+
parse(): RtfGroup;
|
|
147
|
+
private parseControl;
|
|
148
|
+
private parseText;
|
|
149
|
+
/**
|
|
150
|
+
* Flushes the pending bytes buffer as a text node to the current group.
|
|
151
|
+
* @param group The group to append the text node to
|
|
152
|
+
*/
|
|
153
|
+
private flushPendingText;
|
|
154
|
+
/**
|
|
155
|
+
* Decodes a byte array using a "UTF-8 first" strategy.
|
|
156
|
+
* If the bytes form valid UTF-8 and contain non-ASCII characters, UTF-8 is preferred.
|
|
157
|
+
* Otherwise, falls back to the specified code page.
|
|
158
|
+
* @param bytes The bytes to decode
|
|
159
|
+
* @param codePage The RTF code page ID
|
|
160
|
+
* @returns The decoded string
|
|
161
|
+
*/
|
|
162
|
+
private decodeBytes;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Parses an RTF file and returns the AST.
|
|
166
|
+
*
|
|
167
|
+
* **RTF Format Limitations:**
|
|
168
|
+
* The following features are NOT supported due to RTF format constraints:
|
|
169
|
+
*
|
|
170
|
+
* 1. **Images/Attachments**: RTF `\pict` contains device-dependent metafile data
|
|
171
|
+
* (WMF/EMF/DIB). Extracting as portable images requires complex metafile parsing.
|
|
172
|
+
*
|
|
173
|
+
* 2. **StyleMap**: RTF uses inline formatting rather than named style definitions.
|
|
174
|
+
* There is no direct equivalent to DOCX's style.xml.
|
|
175
|
+
*
|
|
176
|
+
* **Note Support:**
|
|
177
|
+
* RTF supports both footnotes and endnotes using the `\footnote` group.
|
|
178
|
+
* The `\fet` control word distinguishes between them:
|
|
179
|
+
* - `\fet0` = footnotes only (default)
|
|
180
|
+
* - `\fet1` = endnotes only
|
|
181
|
+
* - `\fet2` = both footnotes and endnotes
|
|
182
|
+
*
|
|
183
|
+
* @param buffer The file buffer.
|
|
184
|
+
* @param config The parser configuration.
|
|
185
|
+
* @returns The parsed AST.
|
|
186
|
+
*/
|
|
187
|
+
export declare const parseRtf: (buffer: Buffer, config: FullOfficeParserConfig) => Promise<OfficeParserAST>;
|