documents.js 1.102.2 → 2.1.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 (82) hide show
  1. package/README.md +42 -33
  2. package/dist/codecs/registry.cjs +7 -0
  3. package/dist/codecs/registry.js +7 -0
  4. package/dist/convert/capability.cjs +5 -0
  5. package/dist/convert/capability.js +5 -0
  6. package/dist/convert/codec.cjs +20 -0
  7. package/dist/convert/codec.d.cts +5 -1
  8. package/dist/convert/codec.d.ts +5 -1
  9. package/dist/convert/codec.js +19 -3
  10. package/dist/convert/composition.cjs +47 -11
  11. package/dist/convert/composition.d.cts +9 -5
  12. package/dist/convert/composition.d.ts +9 -5
  13. package/dist/convert/composition.js +47 -11
  14. package/dist/convert/convert.cjs +38 -3
  15. package/dist/convert/convert.d.cts +18 -1
  16. package/dist/convert/convert.d.ts +18 -1
  17. package/dist/convert/convert.js +31 -4
  18. package/dist/convert/from-package.cjs +179 -2
  19. package/dist/convert/from-package.d.cts +3 -2
  20. package/dist/convert/from-package.d.ts +3 -2
  21. package/dist/convert/from-package.js +179 -3
  22. package/dist/convert/local.cjs +2 -0
  23. package/dist/convert/local.js +2 -0
  24. package/dist/convert/port.cjs +1 -0
  25. package/dist/convert/port.d.cts +3 -0
  26. package/dist/convert/port.d.ts +3 -0
  27. package/dist/convert/port.js +1 -0
  28. package/dist/csv/read.cjs +85 -0
  29. package/dist/csv/read.d.cts +10 -0
  30. package/dist/csv/read.d.ts +10 -0
  31. package/dist/csv/read.js +84 -0
  32. package/dist/csv/records.cjs +85 -0
  33. package/dist/csv/records.d.cts +10 -0
  34. package/dist/csv/records.d.ts +10 -0
  35. package/dist/csv/records.js +80 -0
  36. package/dist/csv/text.cjs +22 -0
  37. package/dist/csv/text.d.cts +8 -0
  38. package/dist/csv/text.d.ts +8 -0
  39. package/dist/csv/text.js +19 -0
  40. package/dist/csv/write.cjs +75 -0
  41. package/dist/csv/write.d.cts +22 -0
  42. package/dist/csv/write.d.ts +22 -0
  43. package/dist/csv/write.js +71 -0
  44. package/dist/index.cjs +28 -1
  45. package/dist/index.d.cts +11 -7
  46. package/dist/index.d.ts +11 -7
  47. package/dist/index.js +10 -6
  48. package/dist/layout/drawing.cjs +71 -9
  49. package/dist/layout/drawing.d.cts +8 -3
  50. package/dist/layout/drawing.d.ts +8 -3
  51. package/dist/layout/drawing.js +71 -10
  52. package/dist/layout/engine.cjs +55 -43
  53. package/dist/layout/engine.d.cts +2 -1
  54. package/dist/layout/engine.d.ts +2 -1
  55. package/dist/layout/engine.js +57 -45
  56. package/dist/layout/reconstruct.cjs +260 -105
  57. package/dist/layout/reconstruct.js +260 -105
  58. package/dist/layout/shared.cjs +47 -2
  59. package/dist/layout/shared.d.cts +15 -4
  60. package/dist/layout/shared.d.ts +15 -4
  61. package/dist/layout/shared.js +44 -4
  62. package/dist/layout/sheets.cjs +18 -13
  63. package/dist/layout/sheets.d.cts +4 -2
  64. package/dist/layout/sheets.d.ts +4 -2
  65. package/dist/layout/sheets.js +20 -16
  66. package/dist/layout/slides.cjs +35 -31
  67. package/dist/layout/slides.d.cts +3 -2
  68. package/dist/layout/slides.d.ts +3 -2
  69. package/dist/layout/slides.js +37 -33
  70. package/dist/layout/text-layout.cjs +2 -1
  71. package/dist/layout/text-layout.d.cts +14 -3
  72. package/dist/layout/text-layout.d.ts +14 -3
  73. package/dist/layout/text-layout.js +2 -1
  74. package/dist/metadata/write.cjs +1 -0
  75. package/dist/metadata/write.js +1 -0
  76. package/dist/model/bytes.cjs +2 -0
  77. package/dist/model/bytes.d.cts +2 -1
  78. package/dist/model/bytes.d.ts +2 -1
  79. package/dist/model/bytes.js +2 -1
  80. package/dist/odb/csv.cjs +3 -6
  81. package/dist/odb/csv.js +3 -6
  82. package/package.json +5 -5
@@ -2,8 +2,8 @@ import { flipY, rotatePointAboutCenter } from "../model/geometry.js";
2
2
  import { formulaOfBlock } from "../model/formula.js";
3
3
  import { layoutFormula } from "../mathml/layout.js";
4
4
  import { wrapRunsToWidth } from "./text-layout.js";
5
- import { alignmentOffsetPt, effectiveStyledRuns, estimateRowHeightPt, formulaSizePtForFrame, justifyLineGapsPt, lineNaturalHeightPt, registerImage, sumColumnWidthsPt } from "./shared.js";
6
- import { COLOR_BLACK, LAYOUT_FORMAT_VERSION } from "document-schema.js";
5
+ import { alignmentOffsetPt, effectiveStyledRuns, estimateRowHeightPt, formulaSizePtForFrame, justifyLineGapsPt, layoutDocumentOf, lineNaturalHeightPt, packagePagesOf, registerImage, stampFragmentFrame, stampFrame, sumColumnWidthsPt } from "./shared.js";
6
+ import { COLOR_BLACK } from "document-schema.js";
7
7
  //#region src/layout/slides.ts
8
8
  function shapePlacement(flippedFrame, rotationDeg) {
9
9
  if (rotationDeg === void 0 || rotationDeg === 0) return {
@@ -20,7 +20,7 @@ function shapePlacement(flippedFrame, rotationDeg) {
20
20
  layoutRotationDeg: ccwDeg
21
21
  };
22
22
  }
23
- function layoutParagraph(paragraph, contentLeftXDown, contentWidthPt, startYDown, slideHeightPt, placement, fontScale, spacingScale, measurer, out) {
23
+ function layoutParagraph(paragraph, contentLeftXDown, contentWidthPt, startYDown, slideHeightPt, pageIndex, placement, fontScale, spacingScale, measurer, out) {
24
24
  let cursorYDown = startYDown + (paragraph.spacingBeforePt ?? 0);
25
25
  const effectiveRuns = effectiveStyledRuns(paragraph.runs, fontScale);
26
26
  const fallbackRun = effectiveRuns[0];
@@ -52,6 +52,7 @@ function layoutParagraph(paragraph, contentLeftXDown, contentWidthPt, startYDown
52
52
  sourcePath: fragment.sourcePath
53
53
  };
54
54
  out.push(textItem);
55
+ stampFragmentFrame(paragraph.runs, fragment, pageIndex, textItem, measurer, line);
55
56
  if (fragment.hyperlink !== void 0) {
56
57
  const fragmentWidthPt = measurer.widthOfTextAtSize(fragment.text, fragment.font, fragment.sizePt);
57
58
  const linkBottomLeft = placement.place({
@@ -75,7 +76,7 @@ function layoutParagraph(paragraph, contentLeftXDown, contentWidthPt, startYDown
75
76
  cursorYDown += paragraph.spacingAfterPt ?? 0;
76
77
  return cursorYDown;
77
78
  }
78
- function layoutTable(table, contentLeftXDown, contentWidthPt, startYDown, slideHeightPt, placement, measurer, out) {
79
+ function layoutTable(table, contentLeftXDown, contentWidthPt, startYDown, slideHeightPt, pageIndex, placement, measurer, out) {
79
80
  let cursorYDown = startYDown;
80
81
  const gridWidthPt = table.columnWidthsPt.reduce((sum, w) => sum + w, 0);
81
82
  const scale = gridWidthPt > 0 ? contentWidthPt / gridWidthPt : 1;
@@ -86,25 +87,24 @@ function layoutTable(table, contentLeftXDown, contentWidthPt, startYDown, slideH
86
87
  for (const cell of row.cells) {
87
88
  const span = cell.colSpan ?? 1;
88
89
  const cellWidthPt = sumColumnWidthsPt(table.columnWidthsPt, colIndex, span) * scale;
89
- if (cell.background !== void 0 && placement.layoutRotationDeg === void 0) {
90
- const cellFrame = flipY({
91
- xPt: cellXDown,
92
- yPt: cursorYDown,
93
- widthPt: cellWidthPt,
94
- heightPt: rowHeightPt
95
- }, slideHeightPt);
96
- out.push({
97
- kind: "rect",
98
- xPt: cellFrame.xPt,
99
- yPt: cellFrame.yPt,
100
- widthPt: cellFrame.widthPt,
101
- heightPt: cellFrame.heightPt,
102
- fill: cell.background,
103
- sourcePath: table.sourcePath
104
- });
105
- }
90
+ const cellFrame = flipY({
91
+ xPt: cellXDown,
92
+ yPt: cursorYDown,
93
+ widthPt: cellWidthPt,
94
+ heightPt: rowHeightPt
95
+ }, slideHeightPt);
96
+ if (placement.layoutRotationDeg === void 0) stampFrame(cell, pageIndex, cellFrame);
97
+ if (cell.background !== void 0 && placement.layoutRotationDeg === void 0) out.push({
98
+ kind: "rect",
99
+ xPt: cellFrame.xPt,
100
+ yPt: cellFrame.yPt,
101
+ widthPt: cellFrame.widthPt,
102
+ heightPt: cellFrame.heightPt,
103
+ fill: cell.background,
104
+ sourcePath: table.sourcePath
105
+ });
106
106
  let cellCursorYDown = cursorYDown;
107
- for (const block of cell.blocks) if (block.kind === "paragraph") cellCursorYDown = layoutParagraph(block, cellXDown, cellWidthPt, cellCursorYDown, slideHeightPt, placement, 1, 1, measurer, out);
107
+ for (const block of cell.blocks) if (block.kind === "paragraph") cellCursorYDown = layoutParagraph(block, cellXDown, cellWidthPt, cellCursorYDown, slideHeightPt, pageIndex, placement, 1, 1, measurer, out);
108
108
  cellXDown += cellWidthPt;
109
109
  colIndex += span;
110
110
  }
@@ -128,16 +128,18 @@ function layoutShapeFormula(block, flippedFrame, formulaContext) {
128
128
  yPt: flippedFrame.yPt,
129
129
  box
130
130
  });
131
+ stampFrame(block, formulaContext.pageIndex, flippedFrame);
131
132
  }
132
- function convertShape(shape, slideHeightPt, measurer, images, out, formulaContext) {
133
+ function convertShape(shape, slideHeightPt, pageIndex, measurer, images, out, formulaContext) {
133
134
  const flippedFrame = flipY(shape.frame, slideHeightPt);
135
+ stampFrame(shape, pageIndex, flippedFrame);
134
136
  const placement = shapePlacement(flippedFrame, shape.rotationDeg);
135
137
  const contentLeftXDown = shape.frame.xPt + shape.insetLeftPt;
136
138
  const contentWidthPt = Math.max(0, shape.frame.widthPt - shape.insetLeftPt - shape.insetRightPt);
137
139
  const fontScale = shape.fontScale ?? 1;
138
140
  const spacingScale = 1 - (shape.lineSpacingReduction ?? 0);
139
141
  let cursorYDown = shape.frame.yPt + shape.insetTopPt;
140
- for (const block of shape.blocks) if (block.kind === "paragraph") cursorYDown = layoutParagraph(block, contentLeftXDown, contentWidthPt, cursorYDown, slideHeightPt, placement, fontScale, spacingScale, measurer, out);
142
+ for (const block of shape.blocks) if (block.kind === "paragraph") cursorYDown = layoutParagraph(block, contentLeftXDown, contentWidthPt, cursorYDown, slideHeightPt, pageIndex, placement, fontScale, spacingScale, measurer, out);
141
143
  else if (block.kind === "image") {
142
144
  const imageId = registerImage(block, images);
143
145
  const placed = placement.place({
@@ -155,7 +157,13 @@ function convertShape(shape, slideHeightPt, measurer, images, out, formulaContex
155
157
  sourcePath: block.sourcePath
156
158
  };
157
159
  out.push(imageItem);
158
- } else if (block.kind === "table") cursorYDown = layoutTable(block, contentLeftXDown, contentWidthPt, cursorYDown, slideHeightPt, placement, measurer, out);
160
+ stampFrame(block, pageIndex, {
161
+ xPt: placed.x,
162
+ yPt: placed.y,
163
+ widthPt: imageItem.widthPt,
164
+ heightPt: imageItem.heightPt
165
+ });
166
+ } else if (block.kind === "table") cursorYDown = layoutTable(block, contentLeftXDown, contentWidthPt, cursorYDown, slideHeightPt, pageIndex, placement, measurer, out);
159
167
  else if (block.kind === "embeddedObject" && block.objectKind === "formula" && formulaContext !== void 0) layoutShapeFormula(block, flippedFrame, formulaContext);
160
168
  }
161
169
  function convertSlide(slide, slideIndex, measurer, images, positioned, mathMetricsAt) {
@@ -165,7 +173,7 @@ function convertSlide(slide, slideIndex, measurer, images, positioned, mathMetri
165
173
  positioned,
166
174
  mathMetricsAt
167
175
  };
168
- for (const shape of slide.shapes) convertShape(shape, slide.size.heightPt, measurer, images, items, formulaContext);
176
+ for (const shape of slide.shapes) convertShape(shape, slide.size.heightPt, slideIndex, measurer, images, items, formulaContext);
169
177
  return {
170
178
  widthPt: slide.size.widthPt,
171
179
  heightPt: slide.size.heightPt,
@@ -178,13 +186,9 @@ function convertPresentationToLayout(doc, options) {
178
186
  const formulas = [];
179
187
  const pages = doc.slides.map((slide, slideIndex) => convertSlide(slide, slideIndex, options.measurer, images, formulas, options.mathMetricsAt));
180
188
  return {
181
- document: {
182
- formatVersion: LAYOUT_FORMAT_VERSION,
183
- metadata: doc.metadata,
184
- pages,
185
- images
186
- },
187
- formulas
189
+ document: layoutDocumentOf(doc.metadata, pages, images),
190
+ formulas,
191
+ pages: packagePagesOf(pages)
188
192
  };
189
193
  }
190
194
  //#endregion
@@ -38,7 +38,8 @@ function atomizeRuns(runs, measurer) {
38
38
  color: run.color,
39
39
  underline: run.underline,
40
40
  hyperlink: run.hyperlink,
41
- sourcePath: run.sourcePath
41
+ sourcePath: run.sourcePath,
42
+ runIndex: run.runIndex
42
43
  });
43
44
  wordWidth += measurer.widthOfTextAtSize(token, run.font, run.sizePt);
44
45
  }
@@ -1,5 +1,16 @@
1
- import { StyledRun, TextMeasurer, WrapOptions, WrappedLine } from "document-schema.js";
1
+ import { StyledFragment, StyledRun, TextMeasurer, WrapOptions, WrappedLine } from "document-schema.js";
2
2
  //#region src/layout/text-layout.d.ts
3
- declare function wrapRunsToWidth(runs: readonly StyledRun[], measurer: TextMeasurer, maxWidthPt: number, options?: WrapOptions): WrappedLine[];
3
+ interface SourcedRun extends StyledRun {
4
+ readonly runIndex?: number;
5
+ }
6
+ interface SourcedFragment extends StyledFragment {
7
+ readonly runIndex?: number;
8
+ }
9
+ interface SourcedWrappedLine extends Omit<WrappedLine, 'fragments'> {
10
+ readonly fragments: readonly (SourcedFragment & {
11
+ readonly xOffsetPt: number;
12
+ })[];
13
+ }
14
+ declare function wrapRunsToWidth(runs: readonly SourcedRun[], measurer: TextMeasurer, maxWidthPt: number, options?: WrapOptions): SourcedWrappedLine[];
4
15
  //#endregion
5
- export { wrapRunsToWidth };
16
+ export { SourcedFragment, SourcedRun, SourcedWrappedLine, wrapRunsToWidth };
@@ -1,5 +1,16 @@
1
- import { StyledRun, TextMeasurer, WrapOptions, WrappedLine } from "document-schema.js";
1
+ import { StyledFragment, StyledRun, TextMeasurer, WrapOptions, WrappedLine } from "document-schema.js";
2
2
  //#region src/layout/text-layout.d.ts
3
- declare function wrapRunsToWidth(runs: readonly StyledRun[], measurer: TextMeasurer, maxWidthPt: number, options?: WrapOptions): WrappedLine[];
3
+ interface SourcedRun extends StyledRun {
4
+ readonly runIndex?: number;
5
+ }
6
+ interface SourcedFragment extends StyledFragment {
7
+ readonly runIndex?: number;
8
+ }
9
+ interface SourcedWrappedLine extends Omit<WrappedLine, 'fragments'> {
10
+ readonly fragments: readonly (SourcedFragment & {
11
+ readonly xOffsetPt: number;
12
+ })[];
13
+ }
14
+ declare function wrapRunsToWidth(runs: readonly SourcedRun[], measurer: TextMeasurer, maxWidthPt: number, options?: WrapOptions): SourcedWrappedLine[];
4
15
  //#endregion
5
- export { wrapRunsToWidth };
16
+ export { SourcedFragment, SourcedRun, SourcedWrappedLine, wrapRunsToWidth };
@@ -37,7 +37,8 @@ function atomizeRuns(runs, measurer) {
37
37
  color: run.color,
38
38
  underline: run.underline,
39
39
  hyperlink: run.hyperlink,
40
- sourcePath: run.sourcePath
40
+ sourcePath: run.sourcePath,
41
+ runIndex: run.runIndex
41
42
  });
42
43
  wordWidth += measurer.widthOfTextAtSize(token, run.font, run.sizePt);
43
44
  }
@@ -38,6 +38,7 @@ function mergeMetadata(current, overrides) {
38
38
  function classifyWritePath(source, target) {
39
39
  if (source === "pdf" && target === "pdf") return { kind: "pdf" };
40
40
  if (target === "odf" || source === "odf") return { errorMessage: "'odf' (a standalone formula document) is not a supported setDocumentMetadata source or target -- it has no write path back out at all" };
41
+ if (target === "csv" || source === "csv") return { errorMessage: "'csv' is not a supported setDocumentMetadata source or target -- RFC 4180 text has no metadata container, so a rebuild would silently drop the override. Convert to or from csv first, then patch metadata on the package format." };
41
42
  if (!isRebuildFormat(source) || !isRebuildFormat(target)) return { errorMessage: `setDocumentMetadata only patches metadata in place; it does not convert format -- source ('${source}') and target ('${target}') must be the same format (or both 'pdf'). Convert first if you need a different target format.` };
42
43
  if (source !== target) return { errorMessage: `setDocumentMetadata only patches metadata in place; it does not convert format -- source ('${source}') and target ('${target}') must be the same format. Convert first if you need a different target format.` };
43
44
  return {
@@ -37,6 +37,7 @@ function mergeMetadata(current, overrides) {
37
37
  function classifyWritePath(source, target) {
38
38
  if (source === "pdf" && target === "pdf") return { kind: "pdf" };
39
39
  if (target === "odf" || source === "odf") return { errorMessage: "'odf' (a standalone formula document) is not a supported setDocumentMetadata source or target -- it has no write path back out at all" };
40
+ if (target === "csv" || source === "csv") return { errorMessage: "'csv' is not a supported setDocumentMetadata source or target -- RFC 4180 text has no metadata container, so a rebuild would silently drop the override. Convert to or from csv first, then patch metadata on the package format." };
40
41
  if (!isRebuildFormat(source) || !isRebuildFormat(target)) return { errorMessage: `setDocumentMetadata only patches metadata in place; it does not convert format -- source ('${source}') and target ('${target}') must be the same format (or both 'pdf'). Convert first if you need a different target format.` };
41
42
  if (source !== target) return { errorMessage: `setDocumentMetadata only patches metadata in place; it does not convert format -- source ('${source}') and target ('${target}') must be the same format. Convert first if you need a different target format.` };
42
43
  return {
@@ -89,7 +89,9 @@ function isWellFormedUtf8Text(bytes) {
89
89
  }
90
90
  }
91
91
  const MarkdownBytesSchema = zod.z.instanceof(Uint8Array).refine(isWellFormedUtf8Text, { message: "not well-formed UTF-8 text" });
92
+ const CsvBytesSchema = zod.z.instanceof(Uint8Array).refine(isWellFormedUtf8Text, { message: "not well-formed UTF-8 text" });
92
93
  //#endregion
94
+ exports.CsvBytesSchema = CsvBytesSchema;
93
95
  exports.DocxBytesSchema = DocxBytesSchema;
94
96
  exports.MarkdownBytesSchema = MarkdownBytesSchema;
95
97
  exports.OdgBytesSchema = OdgBytesSchema;
@@ -9,5 +9,6 @@ declare const OdsBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<Ar
9
9
  declare const OdpBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
10
10
  declare const OdgBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
11
11
  declare const MarkdownBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
12
+ declare const CsvBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
12
13
  //#endregion
13
- export { DocxBytesSchema, MarkdownBytesSchema, OdgBytesSchema, OdpBytesSchema, OdsBytesSchema, OdtBytesSchema, PdfBytesSchema, PptxBytesSchema, XlsxBytesSchema };
14
+ export { CsvBytesSchema, DocxBytesSchema, MarkdownBytesSchema, OdgBytesSchema, OdpBytesSchema, OdsBytesSchema, OdtBytesSchema, PdfBytesSchema, PptxBytesSchema, XlsxBytesSchema };
@@ -9,5 +9,6 @@ declare const OdsBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<Ar
9
9
  declare const OdpBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
10
10
  declare const OdgBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
11
11
  declare const MarkdownBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
12
+ declare const CsvBytesSchema: z.ZodCustom<Uint8Array<ArrayBuffer>, Uint8Array<ArrayBuffer>>;
12
13
  //#endregion
13
- export { DocxBytesSchema, MarkdownBytesSchema, OdgBytesSchema, OdpBytesSchema, OdsBytesSchema, OdtBytesSchema, PdfBytesSchema, PptxBytesSchema, XlsxBytesSchema };
14
+ export { CsvBytesSchema, DocxBytesSchema, MarkdownBytesSchema, OdgBytesSchema, OdpBytesSchema, OdsBytesSchema, OdtBytesSchema, PdfBytesSchema, PptxBytesSchema, XlsxBytesSchema };
@@ -88,5 +88,6 @@ function isWellFormedUtf8Text(bytes) {
88
88
  }
89
89
  }
90
90
  const MarkdownBytesSchema = z.instanceof(Uint8Array).refine(isWellFormedUtf8Text, { message: "not well-formed UTF-8 text" });
91
+ const CsvBytesSchema = z.instanceof(Uint8Array).refine(isWellFormedUtf8Text, { message: "not well-formed UTF-8 text" });
91
92
  //#endregion
92
- export { DocxBytesSchema, MarkdownBytesSchema, OdgBytesSchema, OdpBytesSchema, OdsBytesSchema, OdtBytesSchema, PdfBytesSchema, PptxBytesSchema, XlsxBytesSchema };
93
+ export { CsvBytesSchema, DocxBytesSchema, MarkdownBytesSchema, OdgBytesSchema, OdpBytesSchema, OdsBytesSchema, OdtBytesSchema, PdfBytesSchema, PptxBytesSchema, XlsxBytesSchema };
package/dist/odb/csv.cjs CHANGED
@@ -1,4 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_csv_records = require("../csv/records.cjs");
2
3
  const require_hsqldb_script = require("../hsqldb/script.cjs");
3
4
  //#region src/odb/csv.ts
4
5
  var OdbTableNotSpecifiedError = class extends Error {
@@ -19,10 +20,6 @@ var OdbTableNotFoundError = class extends Error {
19
20
  this.availableTables = availableTables;
20
21
  }
21
22
  };
22
- const CSV_QUOTE_NEEDED_RE = /[",\n\r]/;
23
- function csvField(value) {
24
- return CSV_QUOTE_NEEDED_RE.test(value) ? `"${value.replace(/"/g, "\"\"")}"` : value;
25
- }
26
23
  function selectTable(tables, tableName) {
27
24
  const availableNames = tables.map((table) => table.tableName);
28
25
  if (tableName !== void 0) {
@@ -38,8 +35,8 @@ function selectTable(tables, tableName) {
38
35
  }
39
36
  function buildOdbTableCsv(tables, tableName) {
40
37
  const table = selectTable(tables, tableName);
41
- const lines = [table.columns.map((column) => csvField(column.name)).join(",")];
42
- for (const row of table.rows) lines.push(row.map((cell) => csvField(require_hsqldb_script.displayTextFor(cell))).join(","));
38
+ const lines = [table.columns.map((column) => require_csv_records.quoteCsvField(column.name)).join(",")];
39
+ for (const row of table.rows) lines.push(row.map((cell) => require_csv_records.quoteCsvField(require_hsqldb_script.displayTextFor(cell))).join(","));
43
40
  return new TextEncoder().encode(`${lines.join("\r\n")}\r\n`);
44
41
  }
45
42
  //#endregion
package/dist/odb/csv.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { quoteCsvField } from "../csv/records.js";
1
2
  import { displayTextFor } from "../hsqldb/script.js";
2
3
  //#region src/odb/csv.ts
3
4
  var OdbTableNotSpecifiedError = class extends Error {
@@ -18,10 +19,6 @@ var OdbTableNotFoundError = class extends Error {
18
19
  this.availableTables = availableTables;
19
20
  }
20
21
  };
21
- const CSV_QUOTE_NEEDED_RE = /[",\n\r]/;
22
- function csvField(value) {
23
- return CSV_QUOTE_NEEDED_RE.test(value) ? `"${value.replace(/"/g, "\"\"")}"` : value;
24
- }
25
22
  function selectTable(tables, tableName) {
26
23
  const availableNames = tables.map((table) => table.tableName);
27
24
  if (tableName !== void 0) {
@@ -37,8 +34,8 @@ function selectTable(tables, tableName) {
37
34
  }
38
35
  function buildOdbTableCsv(tables, tableName) {
39
36
  const table = selectTable(tables, tableName);
40
- const lines = [table.columns.map((column) => csvField(column.name)).join(",")];
41
- for (const row of table.rows) lines.push(row.map((cell) => csvField(displayTextFor(cell))).join(","));
37
+ const lines = [table.columns.map((column) => quoteCsvField(column.name)).join(",")];
38
+ for (const row of table.rows) lines.push(row.map((cell) => quoteCsvField(displayTextFor(cell))).join(","));
42
39
  return new TextEncoder().encode(`${lines.join("\r\n")}\r\n`);
43
40
  }
44
41
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "documents.js",
3
- "version": "1.102.2",
3
+ "version": "2.1.0",
4
4
  "description": "Bidirectional docx/pptx <-> PDF conversion and a read+write editable OOXML document model, built on ooxml.js and Zod 4 codecs.",
5
5
  "type": "module",
6
6
  "repository": {
@@ -84,11 +84,11 @@
84
84
  "packageManager": "pnpm@11.6.0",
85
85
  "dependencies": {
86
86
  "byte-codec": "^1.1.9",
87
- "document-schema.js": "^2.7.17",
87
+ "document-schema.js": "^3.2.0",
88
88
  "fflate": "^0.8.3",
89
- "markdown-codec": "^1.4.2",
90
- "odf.js": "^2.7.23",
91
- "ooxml.js": "^2.11.31",
89
+ "markdown-codec": "^2.0.0",
90
+ "odf.js": "^3.0.1",
91
+ "ooxml.js": "^2.16.0",
92
92
  "pdf-codec": "^2.2.35",
93
93
  "zod": "^4.4.3"
94
94
  },