@gmickel/gno 1.45.1 → 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.
Files changed (236) hide show
  1. package/README.md +1 -1
  2. package/THIRD_PARTY_NOTICES.md +46 -0
  3. package/assets/skill/SKILL.md +7 -6
  4. package/assets/skill/cli-reference.md +14 -6
  5. package/assets/skill/mcp-reference.md +4 -1
  6. package/assets/spa-production.json.gz +0 -0
  7. package/browser-extension/artifacts/gno-browser-clipper-v2.0.0.zip +0 -0
  8. package/browser-extension/artifacts/gno-browser-clipper-v2.0.0.zip.sha256 +1 -0
  9. package/browser-extension/dist/chunk-4tc9v0ja.js +74 -0
  10. package/browser-extension/dist/manifest.json +1 -1
  11. package/browser-extension/dist/preview.html +1 -1
  12. package/browser-extension/dist/service-worker.js +32 -33
  13. package/bunfig.toml +2 -0
  14. package/package.json +40 -26
  15. package/spec/cli.md +30 -11
  16. package/spec/db/schema.sql +146 -1
  17. package/spec/mcp.md +26 -0
  18. package/src/app/context-runtime-types.ts +3 -0
  19. package/src/app/context-runtime.ts +2 -0
  20. package/src/cli/commands/ask.ts +6 -1
  21. package/src/cli/commands/daemon.ts +21 -8
  22. package/src/cli/commands/embed.ts +77 -41
  23. package/src/cli/commands/mcp/install.ts +20 -0
  24. package/src/cli/commands/mcp/paths.ts +25 -0
  25. package/src/cli/commands/mcp/status.ts +6 -0
  26. package/src/cli/detach.ts +3 -2
  27. package/src/cli/program.ts +6 -0
  28. package/src/config/types.ts +3 -3
  29. package/src/converters/adapters/markitdownTs/adapter.ts +1 -2
  30. package/src/converters/adapters/officeparser/adapter.ts +1 -2
  31. package/src/converters/versions.ts +6 -8
  32. package/src/core/context-evidence.ts +8 -4
  33. package/src/core/job-manager.ts +95 -13
  34. package/src/core/network-boundary-inventory.ts +10 -0
  35. package/src/core/shutdown-budget.ts +45 -0
  36. package/src/embed/backlog.ts +107 -4
  37. package/src/embed/batch.ts +42 -2
  38. package/src/embed/fingerprint.ts +16 -0
  39. package/src/embed/retry.ts +113 -5
  40. package/src/embed/variant-backlog.ts +105 -0
  41. package/src/embed/variant-plan.ts +62 -0
  42. package/src/embed/variant-retry.ts +113 -0
  43. package/src/ingestion/graph-reconciliation.ts +327 -0
  44. package/src/ingestion/sync.ts +9 -272
  45. package/src/llm/http-inference.ts +6 -0
  46. package/src/llm/httpEmbedding.ts +37 -6
  47. package/src/llm/httpGeneration.ts +18 -3
  48. package/src/llm/httpRerank.ts +23 -5
  49. package/src/llm/inference-cancellation.ts +168 -0
  50. package/src/llm/inference-scope.ts +202 -0
  51. package/src/llm/lazy-ports.ts +115 -0
  52. package/src/llm/native-worker/client.ts +541 -0
  53. package/src/llm/native-worker/dispatcher.ts +228 -0
  54. package/src/llm/native-worker/embedding-identity.ts +33 -0
  55. package/src/llm/native-worker/entry.ts +173 -0
  56. package/src/llm/native-worker/errors.ts +32 -0
  57. package/src/llm/native-worker/evaluation.ts +16 -0
  58. package/src/llm/native-worker/owned-exit.ts +108 -0
  59. package/src/llm/native-worker/owner.ts +141 -0
  60. package/src/llm/native-worker/ports.ts +317 -0
  61. package/src/llm/native-worker/protocol.ts +442 -0
  62. package/src/llm/native-worker/runtime-config.ts +92 -0
  63. package/src/llm/nodeLlamaCpp/adapter.ts +77 -20
  64. package/src/llm/nodeLlamaCpp/embedding.ts +130 -46
  65. package/src/llm/nodeLlamaCpp/generation.ts +34 -5
  66. package/src/llm/nodeLlamaCpp/lifecycle-options.ts +99 -0
  67. package/src/llm/nodeLlamaCpp/lifecycle.ts +209 -204
  68. package/src/llm/nodeLlamaCpp/rerank-capacity.ts +111 -0
  69. package/src/llm/nodeLlamaCpp/rerank.ts +118 -27
  70. package/src/llm/nodeLlamaCpp/simulator-handle.ts +73 -0
  71. package/src/llm/nodeLlamaCpp/simulator-install.ts +124 -0
  72. package/src/llm/nodeLlamaCpp/simulator-session.ts +240 -0
  73. package/src/llm/nodeLlamaCpp/simulator-types.ts +80 -0
  74. package/src/llm/types.ts +35 -5
  75. package/src/mcp/context.ts +27 -0
  76. package/src/mcp/http-transport.ts +12 -10
  77. package/src/mcp/server.ts +3 -0
  78. package/src/mcp/tool-profile.ts +30 -8
  79. package/src/mcp/tools/context.ts +8 -11
  80. package/src/mcp/tools/embed.ts +1 -1
  81. package/src/mcp/tools/index-cmd.ts +1 -1
  82. package/src/mcp/tools/index.ts +10 -8
  83. package/src/mcp/tools/query.ts +14 -30
  84. package/src/mcp/tools/vsearch.ts +1 -1
  85. package/src/pipeline/answer.ts +23 -3
  86. package/src/pipeline/claim-verifier.ts +6 -0
  87. package/src/pipeline/expansion.ts +43 -40
  88. package/src/pipeline/explain.ts +6 -2
  89. package/src/pipeline/filters.ts +63 -0
  90. package/src/pipeline/fusion.ts +29 -9
  91. package/src/pipeline/graph-retrieval.ts +29 -9
  92. package/src/pipeline/hybrid.ts +198 -55
  93. package/src/pipeline/hydration.ts +161 -0
  94. package/src/pipeline/owner-fusion.ts +87 -0
  95. package/src/pipeline/rerank.ts +35 -11
  96. package/src/pipeline/search.ts +13 -2
  97. package/src/pipeline/types.ts +5 -3
  98. package/src/pipeline/vsearch.ts +87 -7
  99. package/src/sdk/client.ts +47 -3
  100. package/src/sdk/embed.ts +63 -39
  101. package/src/serve/background-runtime.ts +1 -1
  102. package/src/serve/context.ts +41 -56
  103. package/src/serve/embed-scheduler.ts +58 -35
  104. package/src/serve/public/components/IndexingProgress.tsx +46 -60
  105. package/src/serve/public/globals.built.css +1 -1
  106. package/src/serve/public/lib/shiki-language-ids.ts +14 -0
  107. package/src/serve/resident-admission.ts +36 -36
  108. package/src/serve/resident-background-work.ts +20 -2
  109. package/src/serve/resident-request.ts +11 -5
  110. package/src/serve/resident-runtime.ts +97 -61
  111. package/src/serve/resident-shutdown.ts +153 -0
  112. package/src/serve/routes/api.ts +3 -1
  113. package/src/serve/server.ts +47 -26
  114. package/src/store/migrations/028-vector-variants.ts +54 -0
  115. package/src/store/migrations/029-graph-reference-state.ts +77 -0
  116. package/src/store/migrations/index.ts +4 -0
  117. package/src/store/sqlite/adapter.ts +251 -183
  118. package/src/store/sqlite/eligibility.ts +174 -0
  119. package/src/store/sqlite/graph-edge-application.ts +66 -0
  120. package/src/store/sqlite/graph-reference-state.ts +194 -0
  121. package/src/store/sqlite/legacy-vector-ownership.ts +79 -0
  122. package/src/store/types.ts +80 -12
  123. package/src/store/vector/eligibility.ts +36 -0
  124. package/src/store/vector/freshness.ts +33 -6
  125. package/src/store/vector/lazy.ts +81 -0
  126. package/src/store/vector/sqlite-vec.ts +106 -54
  127. package/src/store/vector/stats.ts +14 -3
  128. package/src/store/vector/types.ts +35 -2
  129. package/src/store/vector/variant-search.ts +192 -0
  130. package/src/store/vector/variants.ts +451 -0
  131. package/vendor/converters/markitdown-ts/LICENSE +21 -0
  132. package/vendor/converters/markitdown-ts/dist/index.cjs +1180 -0
  133. package/vendor/converters/markitdown-ts/dist/index.d.cts +46 -0
  134. package/vendor/converters/markitdown-ts/dist/index.d.mts +46 -0
  135. package/vendor/converters/markitdown-ts/dist/index.d.ts +46 -0
  136. package/vendor/converters/markitdown-ts/dist/index.mjs +1152 -0
  137. package/vendor/converters/markitdown-ts/package.json +77 -0
  138. package/vendor/converters/officeparser/LICENSE +21 -0
  139. package/vendor/converters/officeparser/dist/OfficeConverter.d.ts +47 -0
  140. package/vendor/converters/officeparser/dist/OfficeConverter.js +76 -0
  141. package/vendor/converters/officeparser/dist/OfficeGenerator.d.ts +23 -0
  142. package/vendor/converters/officeparser/dist/OfficeGenerator.js +73 -0
  143. package/vendor/converters/officeparser/dist/OfficeParser.d.ts +106 -0
  144. package/vendor/converters/officeparser/dist/OfficeParser.js +332 -0
  145. package/vendor/converters/officeparser/dist/cli.d.ts +28 -0
  146. package/vendor/converters/officeparser/dist/cli.js +381 -0
  147. package/vendor/converters/officeparser/dist/defaults.d.ts +41 -0
  148. package/vendor/converters/officeparser/dist/defaults.js +218 -0
  149. package/vendor/converters/officeparser/dist/generators/BaseGenerator.d.ts +107 -0
  150. package/vendor/converters/officeparser/dist/generators/BaseGenerator.js +248 -0
  151. package/vendor/converters/officeparser/dist/generators/ChunkingGenerator.d.ts +82 -0
  152. package/vendor/converters/officeparser/dist/generators/ChunkingGenerator.js +797 -0
  153. package/vendor/converters/officeparser/dist/generators/CsvGenerator.d.ts +38 -0
  154. package/vendor/converters/officeparser/dist/generators/CsvGenerator.js +245 -0
  155. package/vendor/converters/officeparser/dist/generators/EpubGenerator.d.ts +43 -0
  156. package/vendor/converters/officeparser/dist/generators/EpubGenerator.js +315 -0
  157. package/vendor/converters/officeparser/dist/generators/HtmlGenerator.d.ts +59 -0
  158. package/vendor/converters/officeparser/dist/generators/HtmlGenerator.js +1942 -0
  159. package/vendor/converters/officeparser/dist/generators/MarkdownGenerator.d.ts +96 -0
  160. package/vendor/converters/officeparser/dist/generators/MarkdownGenerator.js +1175 -0
  161. package/vendor/converters/officeparser/dist/generators/PdfGenerator.d.ts +22 -0
  162. package/vendor/converters/officeparser/dist/generators/PdfGenerator.js +194 -0
  163. package/vendor/converters/officeparser/dist/generators/RtfGenerator.d.ts +29 -0
  164. package/vendor/converters/officeparser/dist/generators/RtfGenerator.js +316 -0
  165. package/vendor/converters/officeparser/dist/generators/TextGenerator.d.ts +13 -0
  166. package/vendor/converters/officeparser/dist/generators/TextGenerator.js +201 -0
  167. package/vendor/converters/officeparser/dist/index.d.ts +60 -0
  168. package/vendor/converters/officeparser/dist/index.js +72 -0
  169. package/vendor/converters/officeparser/dist/index.mjs +18 -0
  170. package/vendor/converters/officeparser/dist/officeparser.browser.d.ts +2621 -0
  171. package/vendor/converters/officeparser/dist/officeparser.browser.iife.js +1336 -0
  172. package/vendor/converters/officeparser/dist/officeparser.browser.mjs +1335 -0
  173. package/vendor/converters/officeparser/dist/officeparser.browser.slim.d.ts +2621 -0
  174. package/vendor/converters/officeparser/dist/officeparser.browser.slim.iife.js +1336 -0
  175. package/vendor/converters/officeparser/dist/officeparser.browser.slim.mjs +1335 -0
  176. package/vendor/converters/officeparser/dist/parsers/CsvParser.d.ts +9 -0
  177. package/vendor/converters/officeparser/dist/parsers/CsvParser.js +115 -0
  178. package/vendor/converters/officeparser/dist/parsers/EpubParser.d.ts +8 -0
  179. package/vendor/converters/officeparser/dist/parsers/EpubParser.js +217 -0
  180. package/vendor/converters/officeparser/dist/parsers/ExcelParser.d.ts +32 -0
  181. package/vendor/converters/officeparser/dist/parsers/ExcelParser.js +736 -0
  182. package/vendor/converters/officeparser/dist/parsers/HtmlParser.d.ts +2 -0
  183. package/vendor/converters/officeparser/dist/parsers/HtmlParser.js +1287 -0
  184. package/vendor/converters/officeparser/dist/parsers/MarkdownParser.d.ts +2 -0
  185. package/vendor/converters/officeparser/dist/parsers/MarkdownParser.js +1272 -0
  186. package/vendor/converters/officeparser/dist/parsers/OpenOfficeParser.d.ts +31 -0
  187. package/vendor/converters/officeparser/dist/parsers/OpenOfficeParser.js +1819 -0
  188. package/vendor/converters/officeparser/dist/parsers/PdfParser.d.ts +67 -0
  189. package/vendor/converters/officeparser/dist/parsers/PdfParser.js +848 -0
  190. package/vendor/converters/officeparser/dist/parsers/PowerPointParser.d.ts +32 -0
  191. package/vendor/converters/officeparser/dist/parsers/PowerPointParser.js +950 -0
  192. package/vendor/converters/officeparser/dist/parsers/RtfParser.d.ts +187 -0
  193. package/vendor/converters/officeparser/dist/parsers/RtfParser.js +1801 -0
  194. package/vendor/converters/officeparser/dist/parsers/WordParser.d.ts +79 -0
  195. package/vendor/converters/officeparser/dist/parsers/WordParser.js +1177 -0
  196. package/vendor/converters/officeparser/dist/sbom.cdx.json +1763 -0
  197. package/vendor/converters/officeparser/dist/types.d.ts +2507 -0
  198. package/vendor/converters/officeparser/dist/types.js +107 -0
  199. package/vendor/converters/officeparser/dist/utils/astUtils.d.ts +16 -0
  200. package/vendor/converters/officeparser/dist/utils/astUtils.js +33 -0
  201. package/vendor/converters/officeparser/dist/utils/chartUtils.d.ts +6 -0
  202. package/vendor/converters/officeparser/dist/utils/chartUtils.js +257 -0
  203. package/vendor/converters/officeparser/dist/utils/configUtils.d.ts +44 -0
  204. package/vendor/converters/officeparser/dist/utils/configUtils.js +315 -0
  205. package/vendor/converters/officeparser/dist/utils/dateUtils.d.ts +17 -0
  206. package/vendor/converters/officeparser/dist/utils/dateUtils.js +69 -0
  207. package/vendor/converters/officeparser/dist/utils/envUtils.d.ts +29 -0
  208. package/vendor/converters/officeparser/dist/utils/envUtils.js +152 -0
  209. package/vendor/converters/officeparser/dist/utils/errorUtils.d.ts +72 -0
  210. package/vendor/converters/officeparser/dist/utils/errorUtils.js +245 -0
  211. package/vendor/converters/officeparser/dist/utils/imageUtils.d.ts +66 -0
  212. package/vendor/converters/officeparser/dist/utils/imageUtils.js +133 -0
  213. package/vendor/converters/officeparser/dist/utils/mathUtils.d.ts +42 -0
  214. package/vendor/converters/officeparser/dist/utils/mathUtils.js +385 -0
  215. package/vendor/converters/officeparser/dist/utils/moduleLoader.d.ts +18 -0
  216. package/vendor/converters/officeparser/dist/utils/moduleLoader.js +106 -0
  217. package/vendor/converters/officeparser/dist/utils/ocrUtils.d.ts +42 -0
  218. package/vendor/converters/officeparser/dist/utils/ocrUtils.js +428 -0
  219. package/vendor/converters/officeparser/dist/utils/sanitize.d.ts +148 -0
  220. package/vendor/converters/officeparser/dist/utils/sanitize.js +344 -0
  221. package/vendor/converters/officeparser/dist/utils/sheetUtils.d.ts +7 -0
  222. package/vendor/converters/officeparser/dist/utils/sheetUtils.js +35 -0
  223. package/vendor/converters/officeparser/dist/utils/styleMapper.d.ts +36 -0
  224. package/vendor/converters/officeparser/dist/utils/styleMapper.js +224 -0
  225. package/vendor/converters/officeparser/dist/utils/xmlUtils.d.ts +163 -0
  226. package/vendor/converters/officeparser/dist/utils/xmlUtils.js +461 -0
  227. package/vendor/converters/officeparser/dist/utils/zipUtils.d.ts +134 -0
  228. package/vendor/converters/officeparser/dist/utils/zipUtils.js +337 -0
  229. package/vendor/converters/officeparser/package.json +147 -0
  230. package/vendor/converters/upstream-manifest.json +124 -0
  231. package/vendor/dependency-fixes/README.md +77 -0
  232. package/vendor/dependency-fixes/vendor-converters.py +83 -0
  233. package/browser-extension/artifacts/gno-browser-clipper-v1.45.1.zip +0 -0
  234. package/browser-extension/artifacts/gno-browser-clipper-v1.45.1.zip.sha256 +0 -1
  235. package/browser-extension/dist/chunk-627emwpj.js +0 -75
  236. /package/browser-extension/dist/{chunk-ydfx5d7p.css → chunk-z74y8n8c.css} +0 -0
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OfficeWarningType = exports.OfficeErrorType = void 0;
4
+ /**
5
+ * Standard error types for OfficeParser.
6
+ * Use these to identify the kind of error being reported.
7
+ */
8
+ var OfficeErrorType;
9
+ (function (OfficeErrorType) {
10
+ /** Unsupported file extension */
11
+ OfficeErrorType["EXTENSION_UNSUPPORTED"] = "EXTENSION_UNSUPPORTED";
12
+ /** Unsupported output generator format */
13
+ OfficeErrorType["FORMAT_UNSUPPORTED"] = "FORMAT_UNSUPPORTED";
14
+ /** File appears to be corrupted or malformed */
15
+ OfficeErrorType["FILE_CORRUPTED"] = "FILE_CORRUPTED";
16
+ /** File could not be found at the specified path */
17
+ OfficeErrorType["FILE_DOES_NOT_EXIST"] = "FILE_DOES_NOT_EXIST";
18
+ /** Specified location/directory is not reachable or is a directory */
19
+ OfficeErrorType["LOCATION_NOT_FOUND"] = "LOCATION_NOT_FOUND";
20
+ /** Arguments passed to the function are missing or invalid */
21
+ OfficeErrorType["IMPROPER_ARGUMENTS"] = "IMPROPER_ARGUMENTS";
22
+ /** Error occurred while reading or processing file buffers */
23
+ OfficeErrorType["IMPROPER_BUFFERS"] = "IMPROPER_BUFFERS";
24
+ /** Input type is not a supported type (string, Buffer, ArrayBuffer, Uint8Array) */
25
+ OfficeErrorType["INVALID_INPUT"] = "INVALID_INPUT";
26
+ /** PDF worker source is missing (required in browser) */
27
+ OfficeErrorType["PDF_WORKER_MISSING"] = "PDF_WORKER_MISSING";
28
+ /** Attempted to use Node.js-only features in a browser environment */
29
+ OfficeErrorType["FEATURE_NOT_SUPPORTED_IN_BROWSER"] = "FEATURE_NOT_SUPPORTED_IN_BROWSER";
30
+ /** Style mapping string is malformed */
31
+ OfficeErrorType["INVALID_STYLE_MAPPING"] = "INVALID_STYLE_MAPPING";
32
+ /** Selector in style mapping is invalid */
33
+ OfficeErrorType["INVALID_SELECTOR"] = "INVALID_SELECTOR";
34
+ /** Output mapping in style mapping is invalid */
35
+ OfficeErrorType["INVALID_OUTPUT_MAPPING"] = "INVALID_OUTPUT_MAPPING";
36
+ /** Semantic chunking strategy is selected but no embedding function is provided */
37
+ OfficeErrorType["MISSING_EMBEDDING_FUNCTION"] = "MISSING_EMBEDDING_FUNCTION";
38
+ /** The operation was aborted */
39
+ OfficeErrorType["OPERATION_ABORTED"] = "OPERATION_ABORTED";
40
+ /** ZIP entry count exceeds limit */
41
+ OfficeErrorType["ZIP_ENTRY_COUNT_LIMIT_EXCEEDED"] = "ZIP_ENTRY_COUNT_LIMIT_EXCEEDED";
42
+ /** ZIP entry missing a valid declared size */
43
+ OfficeErrorType["ZIP_ENTRY_INVALID_SIZE"] = "ZIP_ENTRY_INVALID_SIZE";
44
+ /** ZIP uncompressed size limit exceeded */
45
+ OfficeErrorType["ZIP_SIZE_LIMIT_EXCEEDED"] = "ZIP_SIZE_LIMIT_EXCEEDED";
46
+ /** ZIP data yielded no readable entries (corrupt, truncated, or not a ZIP archive) */
47
+ OfficeErrorType["ZIP_NO_ENTRIES_FOUND"] = "ZIP_NO_ENTRIES_FOUND";
48
+ /** ZIP data is truncated: the End of Central Directory record is absent */
49
+ OfficeErrorType["ZIP_TRUNCATED"] = "ZIP_TRUNCATED";
50
+ /** A readable ZIP archive is missing the part its document format requires */
51
+ OfficeErrorType["REQUIRED_PART_MISSING"] = "REQUIRED_PART_MISSING";
52
+ /** Document element/structure nesting exceeded the safe recursion depth */
53
+ OfficeErrorType["MAX_NESTING_DEPTH_EXCEEDED"] = "MAX_NESTING_DEPTH_EXCEEDED";
54
+ /** Embedding call timed out */
55
+ OfficeErrorType["EMBEDDING_TIMEOUT"] = "EMBEDDING_TIMEOUT";
56
+ })(OfficeErrorType || (exports.OfficeErrorType = OfficeErrorType = {}));
57
+ /**
58
+ * Standard warning types for OfficeParser.
59
+ * Use these for reporting non-fatal issues or performance tips.
60
+ */
61
+ var OfficeWarningType;
62
+ (function (OfficeWarningType) {
63
+ /** Performance advice (e.g., Rosetta translation on Mac) */
64
+ OfficeWarningType["PERFORMANCE_TIP"] = "PERFORMANCE_TIP";
65
+ /** OCR processing failed for an attachment */
66
+ OfficeWarningType["OCR_FAILED"] = "OCR_FAILED";
67
+ /** Extraction of structured chart data failed */
68
+ OfficeWarningType["CHART_DATA_EXTRACTION_FAILED"] = "CHART_DATA_EXTRACTION_FAILED";
69
+ /** Automatic worker path failed, falling back to CDN */
70
+ OfficeWarningType["PDF_WORKER_FALLBACK"] = "PDF_WORKER_FALLBACK";
71
+ /** General attachment extraction failure */
72
+ OfficeWarningType["ATTACHMENT_EXTRACTION_FAILED"] = "ATTACHMENT_EXTRACTION_FAILED";
73
+ /** Failed to load a specific page in a multi-page document */
74
+ OfficeWarningType["PAGE_LOAD_FAILED"] = "PAGE_LOAD_FAILED";
75
+ /** Failed to load a required dynamic dependency */
76
+ OfficeWarningType["DEPENDENCY_LOAD_FAILED"] = "DEPENDENCY_LOAD_FAILED";
77
+ /** Failed to extract images from a source */
78
+ OfficeWarningType["IMAGE_EXTRACTION_FAILED"] = "IMAGE_EXTRACTION_FAILED";
79
+ /** Failed to extract annotations from a document */
80
+ OfficeWarningType["ANNOTATION_EXTRACTION_FAILED"] = "ANNOTATION_EXTRACTION_FAILED";
81
+ /** Failed to process an extracted image bitmap */
82
+ OfficeWarningType["IMAGE_PROCESSING_FAILED"] = "IMAGE_PROCESSING_FAILED";
83
+ /** Warning about limitations of browser-based generation */
84
+ OfficeWarningType["BROWSER_GENERATION_LIMITATION"] = "BROWSER_GENERATION_LIMITATION";
85
+ /** Specified sheet range in Excel/ODS export was not found */
86
+ OfficeWarningType["SHEET_RANGE_NOT_FOUND"] = "SHEET_RANGE_NOT_FOUND";
87
+ /** Buffer content type does not match the provided or expected file extension */
88
+ OfficeWarningType["BUFFER_TYPE_MISMATCH"] = "BUFFER_TYPE_MISMATCH";
89
+ /** Failed to detect file type from buffer due to library error or incompatibility */
90
+ OfficeWarningType["FILE_TYPE_DETECTION_FAILED"] = "FILE_TYPE_DETECTION_FAILED";
91
+ /** No chunks were generated for the document given the current strategy */
92
+ OfficeWarningType["EMPTY_CHUNK_GENERATED"] = "EMPTY_CHUNK_GENERATED";
93
+ /** A node was skipped because it only contained whitespace */
94
+ OfficeWarningType["WHITESPACE_NODE_SKIPPED"] = "WHITESPACE_NODE_SKIPPED";
95
+ /** The HTML generator containerWidth option is invalid */
96
+ OfficeWarningType["INVALID_CONTAINER_WIDTH"] = "INVALID_CONTAINER_WIDTH";
97
+ /** A document's repeated-cell expansion hit the configured cell limit and was truncated */
98
+ OfficeWarningType["TABLE_CELL_LIMIT_EXCEEDED"] = "TABLE_CELL_LIMIT_EXCEEDED";
99
+ /** A metadata override could not be represented in the destination format's vocabulary */
100
+ OfficeWarningType["METADATA_NOT_REPRESENTABLE"] = "METADATA_NOT_REPRESENTABLE";
101
+ /** A styleMap output.tag was not an allowed element name and was ignored */
102
+ OfficeWarningType["INVALID_STYLE_MAP_TAG"] = "INVALID_STYLE_MAP_TAG";
103
+ /** A workbook archive contains no worksheet parts (chartsheet-only workbooks are legitimate) */
104
+ OfficeWarningType["NO_WORKSHEETS_FOUND"] = "NO_WORKSHEETS_FOUND";
105
+ /** A presentation archive contains no slides (a zero-slide presentation is legitimate) */
106
+ OfficeWarningType["NO_SLIDES_FOUND"] = "NO_SLIDES_FOUND";
107
+ })(OfficeWarningType || (exports.OfficeWarningType = OfficeWarningType = {}));
@@ -0,0 +1,16 @@
1
+ import { OfficeAttachment, OfficeAuxiliaryContent, OfficeContentNode, OfficeMetadata, OfficeParserAST, OfficeParserConfig, SupportedFileType } from '../types.js';
2
+ /**
3
+ * Creates a fully-featured OfficeParserAST object with conversion methods.
4
+ *
5
+ * This helper ensures that all ASTs returned by officeParser have the latest
6
+ * conversion methods (.to()) and maintain backward compatibility (.toText()).
7
+ *
8
+ * @param type - The detected file type
9
+ * @param metadata - Document metadata
10
+ * @param content - Parsed content nodes
11
+ * @param attachments - Extracted attachments
12
+ * @param config - Original parser configuration
13
+ * @param toTextSync - Synchronous text extraction logic (for backward compatibility)
14
+ * @returns An object conforming to OfficeParserAST
15
+ */
16
+ export declare function createAST(type: SupportedFileType, metadata: OfficeMetadata, content: OfficeContentNode[], attachments: OfficeAttachment[], config: OfficeParserConfig, auxiliary: OfficeAuxiliaryContent | undefined, toTextSync: () => string): OfficeParserAST;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createAST = createAST;
4
+ const OfficeGenerator_js_1 = require("../OfficeGenerator.js");
5
+ /**
6
+ * Creates a fully-featured OfficeParserAST object with conversion methods.
7
+ *
8
+ * This helper ensures that all ASTs returned by officeParser have the latest
9
+ * conversion methods (.to()) and maintain backward compatibility (.toText()).
10
+ *
11
+ * @param type - The detected file type
12
+ * @param metadata - Document metadata
13
+ * @param content - Parsed content nodes
14
+ * @param attachments - Extracted attachments
15
+ * @param config - Original parser configuration
16
+ * @param toTextSync - Synchronous text extraction logic (for backward compatibility)
17
+ * @returns An object conforming to OfficeParserAST
18
+ */
19
+ function createAST(type, metadata, content, attachments, config, auxiliary, toTextSync) {
20
+ return {
21
+ config,
22
+ type,
23
+ metadata,
24
+ content,
25
+ attachments,
26
+ auxiliary,
27
+ warnings: [],
28
+ toText: toTextSync,
29
+ async to(destination, genConfig) {
30
+ return OfficeGenerator_js_1.OfficeGenerator.generate(this, destination, genConfig);
31
+ }
32
+ };
33
+ }
@@ -0,0 +1,6 @@
1
+ import { ChartData } from "../types";
2
+ /**
3
+ * Universal chart data extractor that selects logic based on XML content.
4
+ * @param xmlBuffer Chart XML buffer
5
+ */
6
+ export declare const extractChartData: (xmlBuffer: Buffer) => ChartData;
@@ -0,0 +1,257 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractChartData = void 0;
4
+ const xmlUtils_1 = require("./xmlUtils");
5
+ /**
6
+ * Extracts a single text element located at:
7
+ * c:title -> c:tx -> c:rich -> a:p -> a:r -> a:t
8
+ * OR c:tx -> c:strRef -> c:strCache -> c:pt -> c:v
9
+ * @param el Chart element
10
+ * @param tagName The tag to search for (e.g., "c:title", "c:tx")
11
+ */
12
+ const extractOpenXmlRichText = (el, tagName) => {
13
+ const target = (el.localName === tagName || el.tagName === tagName) ? el : el.getElementsByTagName(tagName)[0];
14
+ if (!target)
15
+ return undefined;
16
+ // 1. Try c:rich or a:p (standard rich text)
17
+ const richNodes = target.getElementsByTagName("c:rich");
18
+ const pNodes = target.getElementsByTagName("a:p");
19
+ const textContainers = richNodes.length > 0 ? Array.from(richNodes) : Array.from(pNodes);
20
+ if (textContainers.length > 0) {
21
+ let acc = "";
22
+ for (const container of textContainers) {
23
+ const tNodes = container.getElementsByTagName("a:t");
24
+ for (let i = 0; i < tNodes.length; i++) {
25
+ acc += (tNodes[i].textContent || "") + " ";
26
+ }
27
+ }
28
+ if (acc.trim())
29
+ return acc.trim();
30
+ }
31
+ // 2. Try c:v (cached values/strings)
32
+ const vNode = target.getElementsByTagName("c:v")[0];
33
+ if (vNode && vNode.textContent) {
34
+ return vNode.textContent.trim() || undefined;
35
+ }
36
+ return undefined;
37
+ };
38
+ /**
39
+ * Extracts fully structured chart data from OpenXML (PPTX, XLSX) chart XML.
40
+ * @param xmlBuffer Chart XML buffer
41
+ */
42
+ const extractOpenXmlChartData = (xmlBuffer) => {
43
+ const xml = xmlBuffer.toString("utf8");
44
+ const dom = (0, xmlUtils_1.parseXmlString)(xml);
45
+ const root = dom.documentElement;
46
+ if (!root)
47
+ return { title: undefined, xAxisTitle: undefined, yAxisTitle: undefined, dataSets: [], labels: [], rawTexts: [] };
48
+ const title = extractOpenXmlRichText(root, "c:title");
49
+ // Axis titles
50
+ let xAxisTitle = undefined;
51
+ let yAxisTitle = undefined;
52
+ const catAxes = root.getElementsByTagName("c:catAx");
53
+ if (catAxes.length > 0)
54
+ xAxisTitle = extractOpenXmlRichText(catAxes[0], "c:title");
55
+ const valAxes = root.getElementsByTagName("c:valAx");
56
+ if (valAxes.length > 0)
57
+ yAxisTitle = extractOpenXmlRichText(valAxes[0], "c:title");
58
+ // Extract Series (dataSets)
59
+ const seriesNodes = root.getElementsByTagName("c:ser");
60
+ const dataSets = [];
61
+ const sharedLabels = [];
62
+ for (let i = 0; i < seriesNodes.length; i++) {
63
+ const ser = seriesNodes[i];
64
+ // DataSet Name (c:tx)
65
+ const name = extractOpenXmlRichText(ser, "c:tx");
66
+ // Values (c:val)
67
+ const values = [];
68
+ const valNode = ser.getElementsByTagName("c:val")[0] || ser.getElementsByTagName("c:yVal")[0];
69
+ if (valNode) {
70
+ const vNodes = valNode.getElementsByTagName("c:v");
71
+ for (let j = 0; j < vNodes.length; j++) {
72
+ const v = vNodes[j].textContent?.trim();
73
+ if (v)
74
+ values.push(v);
75
+ }
76
+ }
77
+ // Point Labels (data labels)
78
+ const pointLabels = [];
79
+ const dLbls = ser.getElementsByTagName("c:dLbl");
80
+ for (let j = 0; j < dLbls.length; j++) {
81
+ const lbl = extractOpenXmlRichText(dLbls[j], "c:tx");
82
+ if (lbl)
83
+ pointLabels.push(lbl);
84
+ }
85
+ // Categories (labels) - c:cat or c:xVal
86
+ const catNode = ser.getElementsByTagName("c:cat")[0] || ser.getElementsByTagName("c:xVal")[0];
87
+ if (catNode) {
88
+ const vNodes = catNode.getElementsByTagName("c:v");
89
+ const localLabels = [];
90
+ for (let j = 0; j < vNodes.length; j++) {
91
+ const v = vNodes[j].textContent?.trim();
92
+ if (v)
93
+ localLabels.push(v);
94
+ }
95
+ if (localLabels.length > 0 && sharedLabels.length === 0) {
96
+ sharedLabels.push(...localLabels);
97
+ }
98
+ }
99
+ dataSets.push({ name, values, pointLabels });
100
+ }
101
+ // Structured rawTexts: for each dataset: Name -> Labels -> Values
102
+ const rawTexts = [];
103
+ for (const ds of dataSets) {
104
+ if (ds.name)
105
+ rawTexts.push(ds.name);
106
+ rawTexts.push(...sharedLabels);
107
+ rawTexts.push(...ds.values);
108
+ }
109
+ return {
110
+ title,
111
+ xAxisTitle,
112
+ yAxisTitle,
113
+ dataSets,
114
+ labels: sharedLabels,
115
+ rawTexts
116
+ };
117
+ };
118
+ /**
119
+ * Extracts structured chart data from ODF (ODP, ODS) chart content.xml.
120
+ * @param xmlBuffer Chart XML buffer
121
+ */
122
+ const extractOdfChartData = (xmlBuffer) => {
123
+ const xml = xmlBuffer.toString("utf8");
124
+ const dom = (0, xmlUtils_1.parseXmlString)(xml);
125
+ const chart = (0, xmlUtils_1.getElementsByTagName)(dom, "chart:chart")[0] || dom.documentElement;
126
+ const titleNode = (0, xmlUtils_1.getElementsByTagName)(chart, "chart:title")[0];
127
+ const title = titleNode ? (0, xmlUtils_1.getElementsByTagName)(titleNode, "text:p")[0]?.textContent || undefined : undefined;
128
+ const table = (0, xmlUtils_1.getElementsByTagName)(chart, "table:table")[0];
129
+ const dataSets = [];
130
+ const labels = [];
131
+ const rawTexts = [];
132
+ if (table) {
133
+ // Chart with embedded data table (common in ODP presentations)
134
+ let rows = [];
135
+ const headerRowsNode = (0, xmlUtils_1.getDirectChildren)(table, "table:table-header-rows")[0];
136
+ if (headerRowsNode) {
137
+ rows.push(...(0, xmlUtils_1.getDirectChildren)(headerRowsNode, "table:table-row"));
138
+ }
139
+ rows.push(...(0, xmlUtils_1.getDirectChildren)(table, "table:table-row"));
140
+ if (rows.length > 0) {
141
+ // Header row for series names
142
+ const headerCells = (0, xmlUtils_1.getDirectChildren)(rows[0], "table:table-cell");
143
+ for (let j = 1; j < headerCells.length; j++) {
144
+ const colsRepeated = parseInt(headerCells[j].getAttribute("table:number-columns-repeated") || "1");
145
+ const name = (0, xmlUtils_1.getDirectChildren)(headerCells[j], "text:p")[0]?.textContent || undefined;
146
+ for (let k = 0; k < colsRepeated; k++) {
147
+ dataSets.push({ name, values: [], pointLabels: [] });
148
+ }
149
+ }
150
+ // Data rows
151
+ for (let i = 1; i < rows.length; i++) {
152
+ const dataCells = (0, xmlUtils_1.getDirectChildren)(rows[i], "table:table-cell");
153
+ if (dataCells.length > 0) {
154
+ const label = (0, xmlUtils_1.getDirectChildren)(dataCells[0], "text:p")[0]?.textContent || undefined;
155
+ if (label)
156
+ labels.push(label);
157
+ let dsIdx = 0;
158
+ for (let j = 1; j < dataCells.length; j++) {
159
+ const colsRepeated = parseInt(dataCells[j].getAttribute("table:number-columns-repeated") || "1");
160
+ const val = dataCells[j].getAttribute("office:value") || (0, xmlUtils_1.getDirectChildren)(dataCells[j], "text:p")[0]?.textContent || "";
161
+ for (let k = 0; k < colsRepeated; k++) {
162
+ if (dataSets[dsIdx]) {
163
+ dataSets[dsIdx].values.push(val);
164
+ }
165
+ dsIdx++;
166
+ }
167
+ }
168
+ }
169
+ }
170
+ }
171
+ }
172
+ else {
173
+ // Chart with cell references (common in ODS spreadsheets)
174
+ // Extract series info from chart:series elements
175
+ const seriesNodes = (0, xmlUtils_1.getElementsByTagName)(chart, "chart:series");
176
+ for (const series of seriesNodes) {
177
+ // Series label is in chart:label-cell-address attribute
178
+ const labelAddr = series.getAttribute("chart:label-cell-address");
179
+ const valuesAddr = series.getAttribute("chart:values-cell-range-address");
180
+ // Try to get series name from any text:p in a title
181
+ let name = undefined;
182
+ const seriesLabels = (0, xmlUtils_1.getElementsByTagName)(series, "text:p");
183
+ if (seriesLabels.length > 0) {
184
+ name = seriesLabels[0].textContent || undefined;
185
+ }
186
+ // If no embedded name, use cell address as identifier
187
+ if (!name && labelAddr) {
188
+ // Extract just the cell reference part, e.g., "Sheet1.$D$2" -> "D2"
189
+ const cellRef = labelAddr.split('.').pop()?.replace(/\$/g, '') || labelAddr;
190
+ name = `Series ${cellRef}`;
191
+ }
192
+ // Values cell range can give us some info
193
+ const dataSet = {
194
+ name,
195
+ values: [],
196
+ pointLabels: []
197
+ };
198
+ // Add values address as a hint in rawTexts
199
+ if (valuesAddr) {
200
+ dataSet.values.push(`[${valuesAddr}]`);
201
+ }
202
+ dataSets.push(dataSet);
203
+ }
204
+ // Extract category labels from chart:categories
205
+ const categories = (0, xmlUtils_1.getElementsByTagName)(chart, "chart:categories")[0];
206
+ if (categories) {
207
+ const catRange = categories.getAttribute("table:cell-range-address");
208
+ if (catRange) {
209
+ labels.push(`[${catRange}]`);
210
+ }
211
+ }
212
+ }
213
+ // Axis titles
214
+ const axes = (0, xmlUtils_1.getElementsByTagName)(dom, "chart:axis");
215
+ let xAxisTitle = undefined;
216
+ let yAxisTitle = undefined;
217
+ for (const axis of axes) {
218
+ const dimension = axis.getAttribute("chart:dimension");
219
+ const axisTitleNode = (0, xmlUtils_1.getElementsByTagName)(axis, "chart:title")[0];
220
+ const axisTitle = axisTitleNode ? (0, xmlUtils_1.getElementsByTagName)(axisTitleNode, "text:p")[0]?.textContent || undefined : undefined;
221
+ if (dimension === 'x')
222
+ xAxisTitle = axisTitle;
223
+ else if (dimension === 'y')
224
+ yAxisTitle = axisTitle;
225
+ }
226
+ // Structured rawTexts: title + series info
227
+ if (title)
228
+ rawTexts.push(title);
229
+ for (const ds of dataSets) {
230
+ if (ds.name)
231
+ rawTexts.push(ds.name);
232
+ rawTexts.push(...labels);
233
+ rawTexts.push(...ds.values);
234
+ }
235
+ return {
236
+ title,
237
+ xAxisTitle,
238
+ yAxisTitle,
239
+ dataSets,
240
+ labels,
241
+ rawTexts
242
+ };
243
+ };
244
+ /**
245
+ * Universal chart data extractor that selects logic based on XML content.
246
+ * @param xmlBuffer Chart XML buffer
247
+ */
248
+ const extractChartData = (xmlBuffer) => {
249
+ const head = xmlBuffer.toString("utf8", 0, 500);
250
+ if (head.includes("urn:oasis:names:tc:opendocument:xmlns:chart:1.0")) {
251
+ return extractOdfChartData(xmlBuffer);
252
+ }
253
+ else {
254
+ return extractOpenXmlChartData(xmlBuffer);
255
+ }
256
+ };
257
+ exports.extractChartData = extractChartData;
@@ -0,0 +1,44 @@
1
+ import { FullGeneratorConfig, FullOfficeParserConfig, GeneratorConfig, OfficeParserConfig } from '../types.js';
2
+ /**
3
+ * Checks if a configuration object is a FullGeneratorConfig.
4
+ */
5
+ export declare function isFullGeneratorConfig(config: any): config is FullGeneratorConfig;
6
+ /**
7
+ * Checks if a configuration object is a FullOfficeParserConfig.
8
+ */
9
+ export declare function isFullParserConfig(config: any): config is FullOfficeParserConfig;
10
+ /**
11
+ * Resolves a full parser configuration by merging defaults and user-provided overrides.
12
+ *
13
+ * The returned object always belongs solely to the caller of this function. That matters
14
+ * because a parse installs per-call state on the config it is handed, such as the collector
15
+ * that gathers warnings for one document's `ast.warnings`. Returning the caller's own object
16
+ * would attach that state to an object they may reuse, so a second parse would append its
17
+ * warnings to the first document's already-returned AST, and each parse would retain the
18
+ * previous one's state for as long as the config lived.
19
+ *
20
+ * Only the configuration containers are copied. Callbacks and `abortSignal` keep their
21
+ * identity, since a copy of an `AbortSignal` would no longer be tied to its controller.
22
+ *
23
+ * @param userConfig - Optional configuration provided by the user
24
+ * @returns A fully populated configuration object, owned by the caller
25
+ */
26
+ export declare function resolveParserConfig(userConfig?: OfficeParserConfig | FullOfficeParserConfig): FullOfficeParserConfig;
27
+ /**
28
+ * Resolves a full, destination-specific configuration by merging defaults,
29
+ * AST-level settings, and user-provided overrides.
30
+ *
31
+ * As with {@link resolveParserConfig}, the returned object belongs solely to the caller of this
32
+ * function, so that per-run normalization cannot edit a config the caller still holds.
33
+ *
34
+ * @param destination - The target format
35
+ * @param userConfig - Optional configuration provided by the user
36
+ * @param astConfig - Optional configuration from the source AST (for inheritance)
37
+ * @returns A fully populated configuration object, owned by the caller
38
+ */
39
+ export declare function resolveGeneratorConfig<D extends string>(destination: D, astConfig?: OfficeParserConfig, userConfig?: GeneratorConfig<D> | FullGeneratorConfig): FullGeneratorConfig;
40
+ /**
41
+ * Validates the containerWidth option for HTML generation.
42
+ * Can be 'auto', a positive number, or a positive CSS length/percentage string.
43
+ */
44
+ export declare function isValidContainerWidth(width: any): boolean;