odf.js 6.3.0 → 6.4.1

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 (140) hide show
  1. package/README.md +172 -18
  2. package/dist/{codec-BnzBd5_I.d.cts → codec-CFdlbFLJ.d.cts} +16 -10
  3. package/dist/{codec-Dg_HWuH1.d.ts → codec-DTAgph2r.d.ts} +16 -10
  4. package/dist/codec.d.cts +1 -1
  5. package/dist/codec.d.ts +1 -1
  6. package/dist/{embedded-BONPxvS3.js → embedded-BnavfkP-.js} +3 -3
  7. package/dist/{embedded-wrtHCJ68.cjs → embedded-Bxyss_ck.cjs} +14 -2
  8. package/dist/image/sniff.cjs +26 -0
  9. package/dist/image/sniff.d.cts +1 -1
  10. package/dist/image/sniff.d.ts +1 -1
  11. package/dist/image/sniff.js +26 -0
  12. package/dist/index.cjs +34 -1
  13. package/dist/index.d.cts +20 -14
  14. package/dist/index.d.ts +20 -14
  15. package/dist/index.js +12 -6
  16. package/dist/{list-vhXd0Jf6.d.ts → list-7FO0SDqZ.d.ts} +14 -1
  17. package/dist/{list-Bttwr1mk.d.cts → list-BorrTJBY.d.cts} +14 -1
  18. package/dist/manifest.cjs +2 -0
  19. package/dist/manifest.js +2 -0
  20. package/dist/{ns-C14w-Zhf.d.cts → ns-DrleaIZQ.d.cts} +3 -1
  21. package/dist/{ns-CTyKJZeF.d.ts → ns-E0TfX9tZ.d.ts} +3 -1
  22. package/dist/ooo1/ns.cjs +9 -0
  23. package/dist/ooo1/ns.d.cts +2 -2
  24. package/dist/ooo1/ns.d.ts +2 -2
  25. package/dist/ooo1/ns.js +8 -1
  26. package/dist/ooo1/properties.cjs +30 -0
  27. package/dist/ooo1/properties.d.cts +6 -2
  28. package/dist/ooo1/properties.d.ts +6 -2
  29. package/dist/ooo1/properties.js +30 -1
  30. package/dist/ooo1/read.cjs +1 -1
  31. package/dist/ooo1/read.d.cts +1 -1
  32. package/dist/ooo1/read.d.ts +1 -1
  33. package/dist/ooo1/read.js +1 -1
  34. package/dist/ooo1/transform.cjs +290 -0
  35. package/dist/ooo1/transform.d.cts +2 -2
  36. package/dist/ooo1/transform.d.ts +2 -2
  37. package/dist/ooo1/transform.js +293 -4
  38. package/dist/ooo1/write.cjs +40 -0
  39. package/dist/ooo1/write.d.cts +2 -0
  40. package/dist/ooo1/write.d.ts +2 -0
  41. package/dist/ooo1/write.js +32 -0
  42. package/dist/package-io/scaffold.cjs +2 -1
  43. package/dist/package-io/scaffold.js +2 -1
  44. package/dist/{paragraph-BdwsQisB.d.cts → paragraph-Bf6Iq5wC.d.cts} +1 -1
  45. package/dist/{paragraph-BoVy1LrN.d.ts → paragraph-DtC86tft.d.ts} +1 -1
  46. package/dist/{path-CK0dIPgx.d.cts → path-8HQS-J7y.d.cts} +3 -1
  47. package/dist/{path-CK0dIPgx.d.ts → path-8HQS-J7y.d.ts} +3 -1
  48. package/dist/{read-Bo1GBjSE.d.ts → read-A3CJkqVM.d.ts} +3 -1
  49. package/dist/{read-RFqq4ckj.d.cts → read-BgnLFuSi.d.cts} +1 -1
  50. package/dist/{read-3yy5EFV_.d.ts → read-CqaZ01kU.d.ts} +1 -1
  51. package/dist/{read-tpfiT_n4.d.cts → read-fphkvCpR.d.cts} +3 -1
  52. package/dist/{shapes-DUzrrf7b.d.ts → shapes-B6Ms7ibr.d.ts} +1 -1
  53. package/dist/{shapes-BQhXAk0D.d.cts → shapes-CbBc9t0y.d.cts} +1 -1
  54. package/dist/{sniff-DGOBHA0O.d.cts → sniff-eR8lObzF.d.cts} +1 -1
  55. package/dist/{sniff-DGOBHA0O.d.ts → sniff-eR8lObzF.d.ts} +1 -1
  56. package/dist/{table-ByhqRnSG.d.cts → table-CECMtPxZ.d.cts} +6 -2
  57. package/dist/{table-DElqGcT0.d.ts → table-XuniPr2I.d.ts} +6 -2
  58. package/dist/{transform-SDysw9wx.d.cts → transform-DFCPKX7e.d.cts} +2 -1
  59. package/dist/{transform-DRr76JEu.d.ts → transform-DPliWQuD.d.ts} +2 -1
  60. package/dist/typed/draw/embedded.cjs +1 -1
  61. package/dist/typed/draw/embedded.js +1 -1
  62. package/dist/typed/draw/shapes.cjs +7 -2
  63. package/dist/typed/draw/shapes.d.cts +1 -1
  64. package/dist/typed/draw/shapes.d.ts +1 -1
  65. package/dist/typed/draw/shapes.js +7 -2
  66. package/dist/typed/draw/write-shapes.cjs +211 -0
  67. package/dist/typed/draw/write-shapes.d.cts +2 -0
  68. package/dist/typed/draw/write-shapes.d.ts +2 -0
  69. package/dist/typed/draw/write-shapes.js +204 -0
  70. package/dist/typed/draw/write-vectors.cjs +132 -0
  71. package/dist/typed/draw/write-vectors.d.cts +2 -0
  72. package/dist/typed/draw/write-vectors.d.ts +2 -0
  73. package/dist/typed/draw/write-vectors.js +129 -0
  74. package/dist/typed/odb/form.cjs +1 -1
  75. package/dist/typed/odb/form.js +1 -1
  76. package/dist/typed/odg/write.cjs +80 -0
  77. package/dist/typed/odg/write.d.cts +2 -0
  78. package/dist/typed/odg/write.d.ts +2 -0
  79. package/dist/typed/odg/write.js +77 -0
  80. package/dist/typed/odp/write.cjs +108 -0
  81. package/dist/typed/odp/write.d.cts +2 -0
  82. package/dist/typed/odp/write.d.ts +2 -0
  83. package/dist/typed/odp/write.js +105 -0
  84. package/dist/typed/ods/read.cjs +3 -1
  85. package/dist/typed/ods/read.d.cts +2 -2
  86. package/dist/typed/ods/read.d.ts +2 -2
  87. package/dist/typed/ods/read.js +2 -2
  88. package/dist/typed/ods/write.cjs +579 -0
  89. package/dist/typed/ods/write.d.cts +2 -0
  90. package/dist/typed/ods/write.d.ts +2 -0
  91. package/dist/typed/ods/write.js +576 -0
  92. package/dist/typed/odt/read.cjs +1 -1
  93. package/dist/typed/odt/read.js +1 -1
  94. package/dist/typed/odt/write.cjs +11 -141
  95. package/dist/typed/odt/write.d.cts +1 -1
  96. package/dist/typed/odt/write.d.ts +1 -1
  97. package/dist/typed/odt/write.js +10 -140
  98. package/dist/typed/shared/canonicalise.cjs +126 -0
  99. package/dist/typed/shared/canonicalise.d.cts +10 -0
  100. package/dist/typed/shared/canonicalise.d.ts +10 -0
  101. package/dist/typed/shared/canonicalise.js +120 -0
  102. package/dist/typed/shared/image.cjs +12 -0
  103. package/dist/typed/shared/image.d.cts +5 -0
  104. package/dist/typed/shared/image.d.ts +5 -0
  105. package/dist/typed/shared/image.js +11 -0
  106. package/dist/typed/shared/list.cjs +32 -0
  107. package/dist/typed/shared/list.d.cts +2 -2
  108. package/dist/typed/shared/list.d.ts +2 -2
  109. package/dist/typed/shared/list.js +28 -1
  110. package/dist/typed/shared/paragraph.d.cts +1 -1
  111. package/dist/typed/shared/paragraph.d.ts +1 -1
  112. package/dist/typed/shared/path.cjs +19 -0
  113. package/dist/typed/shared/path.d.cts +2 -2
  114. package/dist/typed/shared/path.d.ts +2 -2
  115. package/dist/typed/shared/path.js +18 -1
  116. package/dist/typed/shared/table.cjs +3 -0
  117. package/dist/typed/shared/table.d.cts +2 -2
  118. package/dist/typed/shared/table.d.ts +2 -2
  119. package/dist/typed/shared/table.js +1 -1
  120. package/dist/typed/shared/units.cjs +16 -1
  121. package/dist/typed/shared/units.d.cts +2 -2
  122. package/dist/typed/shared/units.d.ts +2 -2
  123. package/dist/typed/shared/units.js +16 -2
  124. package/dist/{units-BQSNkTQZ.d.cts → units-DdyaQolR.d.cts} +2 -1
  125. package/dist/{units-BQSNkTQZ.d.ts → units-DdyaQolR.d.ts} +2 -1
  126. package/dist/write-4kMi-asu.d.ts +14 -0
  127. package/dist/write-BZXpT8F6.d.cts +17 -0
  128. package/dist/write-BhG3t3fJ.d.cts +14 -0
  129. package/dist/write-BuLQmwLD.d.cts +14 -0
  130. package/dist/write-C2c4xBXs.d.cts +14 -0
  131. package/dist/{write-7Uu_wlkL.d.cts → write-CPATqG4v.d.cts} +1 -0
  132. package/dist/write-CfTE2jY8.d.ts +14 -0
  133. package/dist/write-DttX1rTC.d.ts +14 -0
  134. package/dist/{write-DGcI9W7Z.d.ts → write-JERychL3.d.ts} +1 -0
  135. package/dist/write-SKnCTU4C.d.ts +17 -0
  136. package/dist/write-shapes-Co7BrmMZ.d.ts +36 -0
  137. package/dist/write-shapes-D4piGKf4.d.cts +36 -0
  138. package/dist/write-vectors-B-RVHAKI.d.cts +11 -0
  139. package/dist/write-vectors-CYjZoVBW.d.ts +11 -0
  140. package/package.json +2 -2
@@ -1,8 +1,10 @@
1
1
  import { bytesToBase64 } from "../util/base64.js";
2
2
  import { ODF_NAMESPACES } from "../ns.js";
3
- import { rootElement } from "../xml/query.js";
4
- import { OOO1_NAMESPACES, isOoo1Package, odfMediaTypeForOoo1MediaType } from "./ns.js";
5
- import { propertyTypesForContainer, splitStyleProperties } from "./properties.js";
3
+ import { readMimetype } from "../mimetype.js";
4
+ import { attrValue, findChildElement, rootElement } from "../xml/query.js";
5
+ import { resolveOdfListKind } from "../typed/shared/list.js";
6
+ import { OOO1_NAMESPACES, isOoo1NamespacePrefix, isOoo1Package, odfMediaTypeForOoo1MediaType, ooo1MediaTypeForOdfMediaType } from "./ns.js";
7
+ import { mergeStyleProperties, propertyTypesForContainer, splitStyleProperties } from "./properties.js";
6
8
  //#region src/ooo1/transform.ts
7
9
  const CANONICAL_PREFIX_BY_URI = new Map([...Object.entries(OOO1_NAMESPACES).map(([prefix, uri]) => [uri, prefix]), ...Object.entries(ODF_NAMESPACES).map(([prefix, uri]) => [uri, prefix])]);
8
10
  function isOdfNamespacePrefix(prefix) {
@@ -150,7 +152,10 @@ const INCH_TOKEN = /(^|\s)(-?(?:\d+(?:\.\d+)?|\.\d+))inch(?=\s|$)/g;
150
152
  function carriesNoLength(attributeName) {
151
153
  return attributeName.endsWith("name") || attributeName === "xlink:href";
152
154
  }
155
+ const OOO1_GRAPHIC_STYLE_FAMILY = "graphics";
156
+ const ODF_GRAPHIC_STYLE_FAMILY = "graphic";
153
157
  function normaliseAttributeValue(name, value) {
158
+ if (name === "style:family") return value === OOO1_GRAPHIC_STYLE_FAMILY ? ODF_GRAPHIC_STYLE_FAMILY : value;
154
159
  if (carriesNoLength(name)) return value;
155
160
  return value.replace(INCH_TOKEN, "$1$2in");
156
161
  }
@@ -397,5 +402,289 @@ function transformOoo1Package(pkg) {
397
402
  };
398
403
  return { parts };
399
404
  }
405
+ const CLASS_BY_GENRE_ELEMENT = /* @__PURE__ */ new Map([
406
+ ["office:text", "text"],
407
+ ["office:spreadsheet", "spreadsheet"],
408
+ ["office:presentation", "presentation"],
409
+ ["office:drawing", "drawing"],
410
+ ["office:chart", "chart"]
411
+ ]);
412
+ const REVERSE_RENAMED_ELEMENTS = /* @__PURE__ */ new Map([
413
+ ["office:font-face-decls", "office:font-decls"],
414
+ ["office:scripts", "office:script"],
415
+ ["office:script", "office:script-data"],
416
+ ["office:event-listeners", "office:events"],
417
+ ["style:page-layout", "style:page-master"],
418
+ ["text:tab", "text:tab-stop"],
419
+ ["text:database-row-select", "text:database-select"],
420
+ ["text:index-entry-chapter", "text:index-entry-chapter-number"],
421
+ ["table:dependencies", "table:dependences"],
422
+ ["table:dependency", "table:dependence"]
423
+ ]);
424
+ function reverseNoteTag(tag, noteClass) {
425
+ const isEndnote = noteClass === "endnote";
426
+ if (tag === "text:note") return isEndnote ? "text:endnote" : "text:footnote";
427
+ if (tag === "text:note-ref") return isEndnote ? "text:endnote-ref" : "text:footnote-ref";
428
+ if (tag === "text:notes-configuration") return isEndnote ? "text:endnotes-configuration" : "text:footnotes-configuration";
429
+ }
430
+ function reverseNoteBodyOrCitation(tag, noteClass) {
431
+ const isEndnote = noteClass === "endnote";
432
+ if (tag === "text:note-body") return isEndnote ? "text:endnote-body" : "text:footnote-body";
433
+ if (tag === "text:note-citation") return isEndnote ? "text:endnote-citation" : "text:footnote-citation";
434
+ }
435
+ const PT_IN_TOKEN = /(^|\s)(-?(?:\d+(?:\.\d+)?|\.\d+))in(?=\s|$)/g;
436
+ function reverseAttributeValue(name, value) {
437
+ if (name === "style:family") return value === ODF_GRAPHIC_STYLE_FAMILY ? OOO1_GRAPHIC_STYLE_FAMILY : value;
438
+ if (name === "fo:keep-with-next") {
439
+ if (value === "always") return "true";
440
+ if (value === "auto") return "false";
441
+ return value;
442
+ }
443
+ if (carriesNoLength(name)) return value;
444
+ return value.replace(PT_IN_TOKEN, "$1$2inch");
445
+ }
446
+ function reverseRewriteHref(tag, name, value) {
447
+ if (name === "xlink:href" && PACKAGE_HREF_ELEMENTS.has(tag) && !value.startsWith("#") && !value.includes("://")) return `#${value}`;
448
+ return value;
449
+ }
450
+ function reverseRenamedAttributeName(tag, name) {
451
+ switch (name) {
452
+ case "style:page-layout-name": return "style:page-master-name";
453
+ case "style:leader-text": return "style:leader-char";
454
+ case "text:count-in-text-boxes": return "text:count-in-floating-frames";
455
+ case "form:control-implementation": return "form:service-name";
456
+ case "form:text-style-name": return "form:column-style-name";
457
+ case "office:value-type": return tag === "form:property" ? "form:property-type" : void 0;
458
+ default: return;
459
+ }
460
+ }
461
+ function reverseAttributeNameFor(tag, name) {
462
+ if (tag === "text:h" && name === "text:outline-level") return "text:level";
463
+ if (CELL_ELEMENTS.has(tag)) {
464
+ if (name === "table:content-validation-name") return "table:validation-name";
465
+ for (const local of VALUE_ATTRIBUTE_LOCAL_NAMES) if (name === `office:${local}`) return `table:${local}`;
466
+ }
467
+ if (TEXT_VALUE_ELEMENTS.has(tag)) {
468
+ for (const local of VALUE_ATTRIBUTE_LOCAL_NAMES) if (name === `office:${local}`) return `text:${local}`;
469
+ }
470
+ if (tag === "style:column") {
471
+ if (name === "fo:start-indent") return "fo:margin-left";
472
+ if (name === "fo:end-indent") return "fo:margin-right";
473
+ }
474
+ return reverseRenamedAttributeName(tag, name) ?? name;
475
+ }
476
+ function transformNamespaceDeclarationToOoo1(attribute) {
477
+ const canonical = CANONICAL_PREFIX_BY_URI.get(attribute.value);
478
+ if (canonical === void 0 || !isOoo1NamespacePrefix(canonical)) return attribute;
479
+ return {
480
+ name: attribute.name === "xmlns" ? "xmlns" : `xmlns:${canonical}`,
481
+ value: OOO1_NAMESPACES[canonical]
482
+ };
483
+ }
484
+ function reverseTransformAttributes(element, tag, prefixes) {
485
+ const out = [];
486
+ for (const attribute of element.attributes) {
487
+ if (attribute.name === "xmlns" || attribute.name.startsWith("xmlns:")) {
488
+ out.push(transformNamespaceDeclarationToOoo1(attribute));
489
+ continue;
490
+ }
491
+ const name = renameQName(attribute.name, prefixes);
492
+ const value = reverseRewriteHref(tag, name, reverseAttributeValue(name, attribute.value));
493
+ out.push({
494
+ name: reverseAttributeNameFor(tag, name),
495
+ value
496
+ });
497
+ }
498
+ return out;
499
+ }
500
+ function unwrapFrame(frameAttributes, frameChildren) {
501
+ let shape;
502
+ const otherChildren = [];
503
+ for (const child of frameChildren) {
504
+ if (shape === void 0 && child.type === "element" && FRAME_SHAPES.has(child.tag)) {
505
+ shape = child;
506
+ continue;
507
+ }
508
+ otherChildren.push(child);
509
+ }
510
+ if (shape === void 0) return;
511
+ return element(shape.tag, [...shape.attributes, ...frameAttributes], [...shape.children, ...otherChildren]);
512
+ }
513
+ function elementRawText(el) {
514
+ let text = "";
515
+ for (const child of el.children) if (child.type === "text") text += child.value;
516
+ return text;
517
+ }
518
+ function reverseMovedChildren(tag, children) {
519
+ const moved = MOVED_TO_CHILD_ELEMENT.get(tag);
520
+ if (moved === void 0) return;
521
+ const childTagToAttribute = new Map([...moved.entries()].map(([attributeName, childTag]) => [childTag, attributeName]));
522
+ const attributes = [];
523
+ const rest = [];
524
+ for (const child of children) {
525
+ const attributeName = child.type === "element" ? childTagToAttribute.get(child.tag) : void 0;
526
+ if (attributeName !== void 0 && child.type === "element") {
527
+ attributes.push({
528
+ name: attributeName,
529
+ value: elementRawText(child)
530
+ });
531
+ continue;
532
+ }
533
+ rest.push(child);
534
+ }
535
+ return {
536
+ attributes,
537
+ rest
538
+ };
539
+ }
540
+ function wrapMetaKeywords(nodes) {
541
+ const keywords = nodes.filter((node) => node.type === "element" && node.tag === "meta:keyword");
542
+ if (keywords.length === 0) return [...nodes];
543
+ const out = [];
544
+ let inserted = false;
545
+ for (const node of nodes) {
546
+ if (node.type === "element" && node.tag === "meta:keyword") {
547
+ if (!inserted) {
548
+ out.push({
549
+ type: "element",
550
+ tag: "meta:keywords",
551
+ attributes: [],
552
+ children: keywords
553
+ });
554
+ inserted = true;
555
+ }
556
+ continue;
557
+ }
558
+ out.push(node);
559
+ }
560
+ return out;
561
+ }
562
+ function finaliseReversedChildren(nodes) {
563
+ const { merged, rest } = mergeStyleProperties(nodes);
564
+ return wrapMetaKeywords(merged === void 0 ? rest : [merged, ...rest]);
565
+ }
566
+ function reverseTransformNodes(nodes, context) {
567
+ const out = [];
568
+ for (const node of nodes) {
569
+ if (node.type !== "element") {
570
+ out.push(node);
571
+ continue;
572
+ }
573
+ out.push(...reverseTransformElement(node, context));
574
+ }
575
+ return out;
576
+ }
577
+ function reverseListKind(source, context) {
578
+ return resolveOdfListKind(context.pkg, attrValue(source, "text:style-name")) ?? context.listKind;
579
+ }
580
+ function reverseTransformElement(source, context) {
581
+ const renamedTag = renameQName(source.tag, context.prefixes);
582
+ const attributes = reverseTransformAttributes(source, renamedTag, context.prefixes);
583
+ const genreChild = renamedTag === "office:body" ? source.children.find((child) => child.type === "element") : void 0;
584
+ const recurseInto = genreChild !== void 0 && CLASS_BY_GENRE_ELEMENT.has(genreChild.tag) ? genreChild.children : source.children;
585
+ let childContext = context;
586
+ if (renamedTag === "text:note") childContext = {
587
+ ...context,
588
+ noteClass: attrValue(source, "text:note-class") === "endnote" ? "endnote" : "footnote"
589
+ };
590
+ else if (renamedTag === "text:list") childContext = {
591
+ ...context,
592
+ listKind: reverseListKind(source, context)
593
+ };
594
+ const children = finaliseReversedChildren(reverseTransformNodes(recurseInto, childContext));
595
+ if (renamedTag === "office:body") return [element("office:body", attributes, children)];
596
+ if (renamedTag === "draw:frame") return [unwrapFrame(attributes, children) ?? element(renamedTag, attributes, children)];
597
+ if (renamedTag === "text:note" || renamedTag === "text:note-ref" || renamedTag === "text:notes-configuration") {
598
+ const noteClassRaw = attrValue(source, "text:note-class");
599
+ const withoutClass = attributes.filter((attribute) => attribute.name !== "text:note-class");
600
+ return [element(reverseNoteTag(renamedTag, noteClassRaw) ?? renamedTag, withoutClass, children)];
601
+ }
602
+ if (renamedTag === "text:note-body" || renamedTag === "text:note-citation") return [element(reverseNoteBodyOrCitation(renamedTag, context.noteClass) ?? renamedTag, attributes, children)];
603
+ if (renamedTag === "table:table" && attrValue(source, "table:is-sub-table") === "true") return [element("table:sub-table", attributes.filter((attribute) => attribute.name !== "table:is-sub-table"), children)];
604
+ if (renamedTag === "style:font-face") return [element("style:font-decl", attributes.map((attribute) => {
605
+ if (attribute.name === "svg:font-family") return {
606
+ name: "fo:font-family",
607
+ value: attribute.value
608
+ };
609
+ if (attribute.name === "style:font-adornments") return {
610
+ name: "style:font-style-name",
611
+ value: attribute.value
612
+ };
613
+ return attribute;
614
+ }), children)];
615
+ const movedBack = reverseMovedChildren(renamedTag, children);
616
+ if (movedBack !== void 0) return [element(renamedTag, [...attributes, ...movedBack.attributes], movedBack.rest)];
617
+ if (renamedTag === "text:list") {
618
+ const kind = reverseListKind(source, context);
619
+ return [element(kind === "ordered" ? "text:ordered-list" : kind === "bullet" ? "text:unordered-list" : renamedTag, attributes, children)];
620
+ }
621
+ const tag = REVERSE_RENAMED_ELEMENTS.get(renamedTag) ?? renamedTag;
622
+ return [element(tag, DOCUMENT_ROOT_ELEMENTS.has(tag) && context.documentClass !== void 0 ? [...attributes, {
623
+ name: "office:class",
624
+ value: context.documentClass
625
+ }] : attributes, children)];
626
+ }
627
+ const CONTENT_XML_PATH = "content.xml";
628
+ function documentClassOf(pkg) {
629
+ const content = pkg.parts[CONTENT_XML_PATH];
630
+ if (content?.kind !== "xml") return;
631
+ const root = rootElement(content.nodes);
632
+ const genre = (root === void 0 ? void 0 : findChildElement(root.children, "office:body"))?.children.find((child) => child.type === "element");
633
+ return genre === void 0 ? void 0 : CLASS_BY_GENRE_ELEMENT.get(genre.tag);
634
+ }
635
+ function reverseTransformXmlPart(nodes, context) {
636
+ const root = rootElement(nodes);
637
+ if (root === void 0) return [...nodes];
638
+ return reverseTransformNodes(nodes, {
639
+ prefixes: prefixRenames(root),
640
+ ...context
641
+ });
642
+ }
643
+ function rewriteManifestToOoo1(nodes, ooo1MediaType) {
644
+ return nodes.map((node) => {
645
+ if (node.type !== "element") return node;
646
+ return {
647
+ ...node,
648
+ children: node.children.map((entry) => {
649
+ if (entry.type !== "element" || entry.tag !== "manifest:file-entry") return entry;
650
+ if (entry.attributes.find((attribute) => attribute.name === "manifest:full-path")?.value !== "/") return entry;
651
+ return {
652
+ ...entry,
653
+ attributes: entry.attributes.map((attribute) => attribute.name === "manifest:media-type" ? {
654
+ name: attribute.name,
655
+ value: ooo1MediaType
656
+ } : attribute)
657
+ };
658
+ })
659
+ };
660
+ });
661
+ }
662
+ function transformToOoo1Package(pkg) {
663
+ const odfMediaType = readMimetype(pkg);
664
+ if (odfMediaType === void 0) return pkg;
665
+ const ooo1MediaType = ooo1MediaTypeForOdfMediaType(odfMediaType);
666
+ if (ooo1MediaType === void 0) return pkg;
667
+ const documentClass = documentClassOf(pkg);
668
+ const parts = {};
669
+ for (const [path, part] of Object.entries(pkg.parts)) {
670
+ if (path === MIMETYPE_PATH) continue;
671
+ if (part.kind !== "xml") {
672
+ parts[path] = part;
673
+ continue;
674
+ }
675
+ const nodes = reverseTransformXmlPart(part.nodes, {
676
+ pkg,
677
+ documentClass
678
+ });
679
+ parts[path] = path === MANIFEST_PATH ? {
680
+ kind: "xml",
681
+ nodes: rewriteManifestToOoo1(nodes, ooo1MediaType)
682
+ } : {
683
+ kind: "xml",
684
+ nodes
685
+ };
686
+ }
687
+ return { parts };
688
+ }
400
689
  //#endregion
401
- export { transformOoo1Package };
690
+ export { transformOoo1Package, transformToOoo1Package };
@@ -0,0 +1,40 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_typed_odp_write = require("../typed/odp/write.cjs");
3
+ const require_typed_odt_write = require("../typed/odt/write.cjs");
4
+ const require_typed_odg_write = require("../typed/odg/write.cjs");
5
+ const require_typed_ods_write = require("../typed/ods/write.cjs");
6
+ const require_ooo1_transform = require("./transform.cjs");
7
+ //#region src/ooo1/write.ts
8
+ function writeSxw(document, options = {}) {
9
+ return require_ooo1_transform.transformToOoo1Package(require_typed_odt_write.writeOdt(document, options));
10
+ }
11
+ function writeSxwContent(document, options = {}) {
12
+ return require_ooo1_transform.transformToOoo1Package(require_typed_odt_write.writeOdtContent(document, options));
13
+ }
14
+ function writeSxc(document, options = {}) {
15
+ return require_ooo1_transform.transformToOoo1Package(require_typed_ods_write.writeOds(document, options));
16
+ }
17
+ function writeSxcContent(document, options = {}) {
18
+ return require_ooo1_transform.transformToOoo1Package(require_typed_ods_write.writeOdsContent(document, options));
19
+ }
20
+ function writeSxi(document, options = {}) {
21
+ return require_ooo1_transform.transformToOoo1Package(require_typed_odp_write.writeOdp(document, options));
22
+ }
23
+ function writeSxiContent(document, options = {}) {
24
+ return require_ooo1_transform.transformToOoo1Package(require_typed_odp_write.writeOdpContent(document, options));
25
+ }
26
+ function writeSxd(document, options = {}) {
27
+ return require_ooo1_transform.transformToOoo1Package(require_typed_odg_write.writeOdg(document, options));
28
+ }
29
+ function writeSxdContent(document, options = {}) {
30
+ return require_ooo1_transform.transformToOoo1Package(require_typed_odg_write.writeOdgContent(document, options));
31
+ }
32
+ //#endregion
33
+ exports.writeSxc = writeSxc;
34
+ exports.writeSxcContent = writeSxcContent;
35
+ exports.writeSxd = writeSxd;
36
+ exports.writeSxdContent = writeSxdContent;
37
+ exports.writeSxi = writeSxi;
38
+ exports.writeSxiContent = writeSxiContent;
39
+ exports.writeSxw = writeSxw;
40
+ exports.writeSxwContent = writeSxwContent;
@@ -0,0 +1,2 @@
1
+ import { a as writeSxi, c as writeSxwContent, i as writeSxdContent, n as writeSxcContent, o as writeSxiContent, r as writeSxd, s as writeSxw, t as writeSxc } from "../write-BZXpT8F6.cjs";
2
+ export { writeSxc, writeSxcContent, writeSxd, writeSxdContent, writeSxi, writeSxiContent, writeSxw, writeSxwContent };
@@ -0,0 +1,2 @@
1
+ import { a as writeSxi, c as writeSxwContent, i as writeSxdContent, n as writeSxcContent, o as writeSxiContent, r as writeSxd, s as writeSxw, t as writeSxc } from "../write-SKnCTU4C.js";
2
+ export { writeSxc, writeSxcContent, writeSxd, writeSxdContent, writeSxi, writeSxiContent, writeSxw, writeSxwContent };
@@ -0,0 +1,32 @@
1
+ import { writeOdp, writeOdpContent } from "../typed/odp/write.js";
2
+ import { writeOdt, writeOdtContent } from "../typed/odt/write.js";
3
+ import { writeOdg, writeOdgContent } from "../typed/odg/write.js";
4
+ import { writeOds, writeOdsContent } from "../typed/ods/write.js";
5
+ import { transformToOoo1Package } from "./transform.js";
6
+ //#region src/ooo1/write.ts
7
+ function writeSxw(document, options = {}) {
8
+ return transformToOoo1Package(writeOdt(document, options));
9
+ }
10
+ function writeSxwContent(document, options = {}) {
11
+ return transformToOoo1Package(writeOdtContent(document, options));
12
+ }
13
+ function writeSxc(document, options = {}) {
14
+ return transformToOoo1Package(writeOds(document, options));
15
+ }
16
+ function writeSxcContent(document, options = {}) {
17
+ return transformToOoo1Package(writeOdsContent(document, options));
18
+ }
19
+ function writeSxi(document, options = {}) {
20
+ return transformToOoo1Package(writeOdp(document, options));
21
+ }
22
+ function writeSxiContent(document, options = {}) {
23
+ return transformToOoo1Package(writeOdpContent(document, options));
24
+ }
25
+ function writeSxd(document, options = {}) {
26
+ return transformToOoo1Package(writeOdg(document, options));
27
+ }
28
+ function writeSxdContent(document, options = {}) {
29
+ return transformToOoo1Package(writeOdgContent(document, options));
30
+ }
31
+ //#endregion
32
+ export { writeSxc, writeSxcContent, writeSxd, writeSxdContent, writeSxi, writeSxiContent, writeSxw, writeSxwContent };
@@ -15,7 +15,8 @@ const ODF_DOCUMENT_PREFIXES = [
15
15
  "dc",
16
16
  "meta",
17
17
  "number",
18
- "svg"
18
+ "svg",
19
+ "presentation"
19
20
  ];
20
21
  const DEFAULT_ODF_VERSION = "1.3";
21
22
  function documentPartNodes(rootTag, version, containers) {
@@ -14,7 +14,8 @@ const ODF_DOCUMENT_PREFIXES = [
14
14
  "dc",
15
15
  "meta",
16
16
  "number",
17
- "svg"
17
+ "svg",
18
+ "presentation"
18
19
  ];
19
20
  const DEFAULT_ODF_VERSION = "1.3";
20
21
  function documentPartNodes(rootTag, version, containers) {
@@ -2,7 +2,7 @@ import { d as XmlNode, l as XmlElement } from "./node-B6JX5CRX.cjs";
2
2
  import { r as Package } from "./package-DMk9fuTI.cjs";
3
3
  import { n as StyleProperties } from "./properties-CiIoNu2h.cjs";
4
4
  import { a as StyleRegistry } from "./registry-PoQIRgbY.cjs";
5
- import { n as OdfListIdState } from "./list-Bttwr1mk.cjs";
5
+ import { i as OdfListIdState } from "./list-BorrTJBY.cjs";
6
6
  import { a as OdfDefinitionsSink, l as OdfResidueFormat, s as OdfMarkerHalf } from "./constructs-BzLZy5YP.cjs";
7
7
  import { ContentBlock, ContentParagraph, ContentRun, ProvenanceDescriptor } from "document-schema.js";
8
8
  //#region src/typed/shared/paragraph.d.ts
@@ -2,7 +2,7 @@ import { d as XmlNode, l as XmlElement } from "./node-B6JX5CRX.js";
2
2
  import { r as Package } from "./package-otZYrxiO.js";
3
3
  import { n as StyleProperties } from "./properties-CJyykyc_.js";
4
4
  import { a as StyleRegistry } from "./registry-C_16-N6i.js";
5
- import { n as OdfListIdState } from "./list-vhXd0Jf6.js";
5
+ import { i as OdfListIdState } from "./list-7FO0SDqZ.js";
6
6
  import { a as OdfDefinitionsSink, l as OdfResidueFormat, s as OdfMarkerHalf } from "./constructs-BntJjuvH.js";
7
7
  import { ContentBlock, ContentParagraph, ContentRun, ProvenanceDescriptor } from "document-schema.js";
8
8
  //#region src/typed/shared/paragraph.d.ts
@@ -30,5 +30,7 @@ declare function rawSubpathFromPoints(points: readonly OdfRawPoint[], closed: bo
30
30
  declare function parseOdfPathData(d: string): OdfRawSubpath[];
31
31
  declare function scaleOdfRawPoint(point: OdfRawPoint, viewBox: OdfViewBox, frame: Box): ContentPathPoint;
32
32
  declare function buildOdfSubpaths(rawSubpaths: readonly OdfRawSubpath[], viewBox: OdfViewBox, frame: Box): ContentSubpath[];
33
+ declare function formatOdfViewBox(frame: Box): string;
34
+ declare function formatOdfPathData(subpaths: readonly ContentSubpath[]): string;
33
35
  //#endregion
34
- export { buildOdfSubpaths as a, parseOdfViewBox as c, OdfViewBox as i, rawSubpathFromPoints as l, OdfRawSegment as n, parseOdfPathData as o, OdfRawSubpath as r, parseOdfPointsList as s, OdfRawPoint as t, scaleOdfRawPoint as u };
36
+ export { buildOdfSubpaths as a, parseOdfPathData as c, rawSubpathFromPoints as d, scaleOdfRawPoint as f, OdfViewBox as i, parseOdfPointsList as l, OdfRawSegment as n, formatOdfPathData as o, OdfRawSubpath as r, formatOdfViewBox as s, OdfRawPoint as t, parseOdfViewBox as u };
@@ -30,5 +30,7 @@ declare function rawSubpathFromPoints(points: readonly OdfRawPoint[], closed: bo
30
30
  declare function parseOdfPathData(d: string): OdfRawSubpath[];
31
31
  declare function scaleOdfRawPoint(point: OdfRawPoint, viewBox: OdfViewBox, frame: Box): ContentPathPoint;
32
32
  declare function buildOdfSubpaths(rawSubpaths: readonly OdfRawSubpath[], viewBox: OdfViewBox, frame: Box): ContentSubpath[];
33
+ declare function formatOdfViewBox(frame: Box): string;
34
+ declare function formatOdfPathData(subpaths: readonly ContentSubpath[]): string;
33
35
  //#endregion
34
- export { buildOdfSubpaths as a, parseOdfViewBox as c, OdfViewBox as i, rawSubpathFromPoints as l, OdfRawSegment as n, parseOdfPathData as o, OdfRawSubpath as r, parseOdfPointsList as s, OdfRawPoint as t, scaleOdfRawPoint as u };
36
+ export { buildOdfSubpaths as a, parseOdfPathData as c, rawSubpathFromPoints as d, scaleOdfRawPoint as f, OdfViewBox as i, parseOdfPointsList as l, OdfRawSegment as n, formatOdfPathData as o, OdfRawSubpath as r, formatOdfViewBox as s, OdfRawPoint as t, parseOdfViewBox as u };
@@ -7,7 +7,9 @@ interface OdsDocument {
7
7
  definitions?: DefinitionsTable;
8
8
  source?: Record<string, SourceResidue>;
9
9
  }
10
+ declare const DEFAULT_COLUMN_WIDTH_PT = 64;
11
+ declare const DEFAULT_ROW_HEIGHT_PT = 15;
10
12
  declare function readOdsContent(pkg: Package): OdsDocument;
11
13
  declare function readOds(pkg: Package): DocumentTree;
12
14
  //#endregion
13
- export { readOds as n, readOdsContent as r, OdsDocument as t };
15
+ export { readOdsContent as a, readOds as i, DEFAULT_ROW_HEIGHT_PT as n, OdsDocument as r, DEFAULT_COLUMN_WIDTH_PT as t };
@@ -2,7 +2,7 @@ import { r as Package } from "./package-DMk9fuTI.cjs";
2
2
  import { t as OdpDocument } from "./read-DHOQqjOZ.cjs";
3
3
  import { i as OdtReadOptions, t as OdtDocument } from "./read-Dy5p1OMb.cjs";
4
4
  import { t as OdgDocument } from "./read-DSyz0YLj.cjs";
5
- import { t as OdsDocument } from "./read-tpfiT_n4.cjs";
5
+ import { r as OdsDocument } from "./read-fphkvCpR.cjs";
6
6
  import { DocumentTree } from "document-schema.js";
7
7
  //#region src/ooo1/read.d.ts
8
8
  declare function readSxwContent(pkg: Package, options?: OdtReadOptions): OdtDocument;
@@ -2,7 +2,7 @@ import { r as Package } from "./package-otZYrxiO.js";
2
2
  import { t as OdpDocument } from "./read-DUOJ-1hX.js";
3
3
  import { i as OdtReadOptions, t as OdtDocument } from "./read-BcxAWBB5.js";
4
4
  import { t as OdgDocument } from "./read-D3wLfr-7.js";
5
- import { t as OdsDocument } from "./read-Bo1GBjSE.js";
5
+ import { r as OdsDocument } from "./read-A3CJkqVM.js";
6
6
  import { DocumentTree } from "document-schema.js";
7
7
  //#region src/ooo1/read.d.ts
8
8
  declare function readSxwContent(pkg: Package, options?: OdtReadOptions): OdtDocument;
@@ -7,7 +7,9 @@ interface OdsDocument {
7
7
  definitions?: DefinitionsTable;
8
8
  source?: Record<string, SourceResidue>;
9
9
  }
10
+ declare const DEFAULT_COLUMN_WIDTH_PT = 64;
11
+ declare const DEFAULT_ROW_HEIGHT_PT = 15;
10
12
  declare function readOdsContent(pkg: Package): OdsDocument;
11
13
  declare function readOds(pkg: Package): DocumentTree;
12
14
  //#endregion
13
- export { readOds as n, readOdsContent as r, OdsDocument as t };
15
+ export { readOdsContent as a, readOds as i, DEFAULT_ROW_HEIGHT_PT as n, OdsDocument as r, DEFAULT_COLUMN_WIDTH_PT as t };
@@ -1,6 +1,6 @@
1
1
  import { d as XmlNode, l as XmlElement } from "./node-B6JX5CRX.js";
2
2
  import { r as Package } from "./package-otZYrxiO.js";
3
- import { n as OdfListIdState } from "./list-vhXd0Jf6.js";
3
+ import { i as OdfListIdState } from "./list-7FO0SDqZ.js";
4
4
  import { r as OdfTransformFunction } from "./transform-BFNc16LQ.js";
5
5
  import { Box, ContentImageBlock, ContentShape, ContentVector } from "document-schema.js";
6
6
  //#region src/typed/draw/shapes.d.ts
@@ -1,6 +1,6 @@
1
1
  import { d as XmlNode, l as XmlElement } from "./node-B6JX5CRX.cjs";
2
2
  import { r as Package } from "./package-DMk9fuTI.cjs";
3
- import { n as OdfListIdState } from "./list-Bttwr1mk.cjs";
3
+ import { i as OdfListIdState } from "./list-BorrTJBY.cjs";
4
4
  import { r as OdfTransformFunction } from "./transform-M1gbHp4j.cjs";
5
5
  import { Box, ContentImageBlock, ContentShape, ContentVector } from "document-schema.js";
6
6
  //#region src/typed/draw/shapes.d.ts
@@ -1,5 +1,5 @@
1
1
  //#region src/image/sniff.d.ts
2
- type ImageFormat = "png" | "jpeg";
2
+ type ImageFormat = "png" | "jpeg" | "gif" | "svg";
3
3
  declare function sniffImageFormat(bytes: Uint8Array<ArrayBuffer>): ImageFormat | undefined;
4
4
  //#endregion
5
5
  export { sniffImageFormat as n, ImageFormat as t };
@@ -1,5 +1,5 @@
1
1
  //#region src/image/sniff.d.ts
2
- type ImageFormat = "png" | "jpeg";
2
+ type ImageFormat = "png" | "jpeg" | "gif" | "svg";
3
3
  declare function sniffImageFormat(bytes: Uint8Array<ArrayBuffer>): ImageFormat | undefined;
4
4
  //#endregion
5
5
  export { sniffImageFormat as n, ImageFormat as t };
@@ -1,8 +1,11 @@
1
1
  import { l as XmlElement } from "./node-B6JX5CRX.cjs";
2
2
  import { r as Package } from "./package-DMk9fuTI.cjs";
3
3
  import { a as StyleRegistry } from "./registry-PoQIRgbY.cjs";
4
- import { Alignment, Color, ContentCellBorders, ContentTable } from "document-schema.js";
4
+ import { Alignment, Color, ContentBorder, ContentCellBorders, ContentTable } from "document-schema.js";
5
5
  //#region src/typed/shared/table.d.ts
6
+ type BorderEdgeKey = "left" | "right" | "top" | "bottom";
7
+ declare const BORDER_EDGE_KEYS: readonly BorderEdgeKey[];
8
+ declare const BORDER_EDGE_ATTRS: Readonly<Record<BorderEdgeKey, string>>;
6
9
  interface CellStyleDecoration {
7
10
  background?: Color;
8
11
  borders?: ContentCellBorders;
@@ -10,7 +13,8 @@ interface CellStyleDecoration {
10
13
  verticalAlignment?: "top" | "middle" | "bottom";
11
14
  }
12
15
  declare function readCellStyleDecoration(elements: readonly XmlElement[]): CellStyleDecoration;
16
+ declare function formatBorderEdge(border: ContentBorder): string;
13
17
  declare function writeOdfTable(table: ContentTable, registry: StyleRegistry, tableName: string): XmlElement;
14
18
  declare function readOdfTable(tableElement: XmlElement, pkg: Package): ContentTable;
15
19
  //#endregion
16
- export { writeOdfTable as i, readCellStyleDecoration as n, readOdfTable as r, CellStyleDecoration as t };
20
+ export { formatBorderEdge as a, writeOdfTable as c, CellStyleDecoration as i, BORDER_EDGE_KEYS as n, readCellStyleDecoration as o, BorderEdgeKey as r, readOdfTable as s, BORDER_EDGE_ATTRS as t };
@@ -1,8 +1,11 @@
1
1
  import { l as XmlElement } from "./node-B6JX5CRX.js";
2
2
  import { r as Package } from "./package-otZYrxiO.js";
3
3
  import { a as StyleRegistry } from "./registry-C_16-N6i.js";
4
- import { Alignment, Color, ContentCellBorders, ContentTable } from "document-schema.js";
4
+ import { Alignment, Color, ContentBorder, ContentCellBorders, ContentTable } from "document-schema.js";
5
5
  //#region src/typed/shared/table.d.ts
6
+ type BorderEdgeKey = "left" | "right" | "top" | "bottom";
7
+ declare const BORDER_EDGE_KEYS: readonly BorderEdgeKey[];
8
+ declare const BORDER_EDGE_ATTRS: Readonly<Record<BorderEdgeKey, string>>;
6
9
  interface CellStyleDecoration {
7
10
  background?: Color;
8
11
  borders?: ContentCellBorders;
@@ -10,7 +13,8 @@ interface CellStyleDecoration {
10
13
  verticalAlignment?: "top" | "middle" | "bottom";
11
14
  }
12
15
  declare function readCellStyleDecoration(elements: readonly XmlElement[]): CellStyleDecoration;
16
+ declare function formatBorderEdge(border: ContentBorder): string;
13
17
  declare function writeOdfTable(table: ContentTable, registry: StyleRegistry, tableName: string): XmlElement;
14
18
  declare function readOdfTable(tableElement: XmlElement, pkg: Package): ContentTable;
15
19
  //#endregion
16
- export { writeOdfTable as i, readCellStyleDecoration as n, readOdfTable as r, CellStyleDecoration as t };
20
+ export { formatBorderEdge as a, writeOdfTable as c, CellStyleDecoration as i, BORDER_EDGE_KEYS as n, readCellStyleDecoration as o, BorderEdgeKey as r, readOdfTable as s, BORDER_EDGE_ATTRS as t };
@@ -1,5 +1,6 @@
1
1
  import { r as Package } from "./package-DMk9fuTI.cjs";
2
2
  //#region src/ooo1/transform.d.ts
3
3
  declare function transformOoo1Package(pkg: Package): Package;
4
+ declare function transformToOoo1Package(pkg: Package): Package;
4
5
  //#endregion
5
- export { transformOoo1Package as t };
6
+ export { transformToOoo1Package as n, transformOoo1Package as t };
@@ -1,5 +1,6 @@
1
1
  import { r as Package } from "./package-otZYrxiO.js";
2
2
  //#region src/ooo1/transform.d.ts
3
3
  declare function transformOoo1Package(pkg: Package): Package;
4
+ declare function transformToOoo1Package(pkg: Package): Package;
4
5
  //#endregion
5
- export { transformOoo1Package as t };
6
+ export { transformToOoo1Package as n, transformOoo1Package as t };
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_embedded = require("../../embedded-wrtHCJ68.cjs");
2
+ const require_embedded = require("../../embedded-Bxyss_ck.cjs");
3
3
  exports.readDrawObjectReference = require_embedded.readDrawObjectReference;
4
4
  exports.readEmbeddedObjectDocument = require_embedded.readEmbeddedObjectDocument;
5
5
  exports.readOdfChartContent = require_embedded.readOdfChartContent;
@@ -1,2 +1,2 @@
1
- import { n as readEmbeddedObjectDocument, r as readOdfChartContent, t as readDrawObjectReference } from "../../embedded-BONPxvS3.js";
1
+ import { n as readEmbeddedObjectDocument, r as readOdfChartContent, t as readDrawObjectReference } from "../../embedded-BnavfkP-.js";
2
2
  export { readDrawObjectReference, readEmbeddedObjectDocument, readOdfChartContent };