odf.js 1.12.0 → 1.13.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 (178) hide show
  1. package/README.md +39 -0
  2. package/dist/codec.cjs +28 -0
  3. package/dist/codec.d.cts +72 -0
  4. package/dist/codec.d.ts +72 -0
  5. package/dist/codec.js +24 -0
  6. package/dist/image/sniff.cjs +28 -0
  7. package/dist/image/sniff.d.cts +5 -0
  8. package/dist/image/sniff.d.ts +5 -0
  9. package/dist/image/sniff.js +27 -0
  10. package/dist/index.cjs +156 -3242
  11. package/dist/index.d.cts +42 -679
  12. package/dist/index.d.ts +42 -679
  13. package/dist/index.js +42 -3129
  14. package/dist/manifest.cjs +252 -0
  15. package/dist/manifest.d.cts +41 -0
  16. package/dist/manifest.d.ts +41 -0
  17. package/dist/manifest.js +242 -0
  18. package/dist/media-type.cjs +27 -0
  19. package/dist/media-type.d.cts +20 -0
  20. package/dist/media-type.d.ts +20 -0
  21. package/dist/media-type.js +25 -0
  22. package/dist/mimetype.cjs +19 -0
  23. package/dist/mimetype.d.cts +7 -0
  24. package/dist/mimetype.d.ts +7 -0
  25. package/dist/mimetype.js +16 -0
  26. package/dist/model/node.cjs +67 -0
  27. package/dist/model/node.d.cts +2 -0
  28. package/dist/model/node.d.ts +2 -0
  29. package/dist/model/node.js +58 -0
  30. package/dist/model/package.cjs +19 -0
  31. package/dist/model/package.d.cts +114 -0
  32. package/dist/model/package.d.ts +114 -0
  33. package/dist/model/package.js +15 -0
  34. package/dist/node-CkBWRjNR.d.cts +83 -0
  35. package/dist/node-CkBWRjNR.d.ts +83 -0
  36. package/dist/ns.cjs +37 -0
  37. package/dist/ns.d.cts +32 -0
  38. package/dist/ns.d.ts +32 -0
  39. package/dist/ns.js +35 -0
  40. package/dist/package-io/read.cjs +35 -0
  41. package/dist/package-io/read.d.cts +5 -0
  42. package/dist/package-io/read.d.ts +5 -0
  43. package/dist/package-io/read.js +34 -0
  44. package/dist/package-io/write.cjs +36 -0
  45. package/dist/package-io/write.d.cts +7 -0
  46. package/dist/package-io/write.d.ts +7 -0
  47. package/dist/package-io/write.js +33 -0
  48. package/dist/styles/properties.cjs +286 -0
  49. package/dist/styles/properties.d.cts +45 -0
  50. package/dist/styles/properties.d.ts +45 -0
  51. package/dist/styles/properties.js +277 -0
  52. package/dist/styles/registry.cjs +212 -0
  53. package/dist/styles/registry.d.cts +37 -0
  54. package/dist/styles/registry.d.ts +37 -0
  55. package/dist/styles/registry.js +209 -0
  56. package/dist/styles/serialize.cjs +23 -0
  57. package/dist/styles/serialize.d.cts +7 -0
  58. package/dist/styles/serialize.d.ts +7 -0
  59. package/dist/styles/serialize.js +21 -0
  60. package/dist/styles/span.cjs +114 -0
  61. package/dist/styles/span.d.cts +5 -0
  62. package/dist/styles/span.d.ts +5 -0
  63. package/dist/styles/span.js +113 -0
  64. package/dist/typed/draw/shapes.cjs +314 -0
  65. package/dist/typed/draw/shapes.d.cts +14 -0
  66. package/dist/typed/draw/shapes.d.ts +14 -0
  67. package/dist/typed/draw/shapes.js +311 -0
  68. package/dist/typed/formula/read.cjs +48 -0
  69. package/dist/typed/formula/read.d.cts +12 -0
  70. package/dist/typed/formula/read.d.ts +12 -0
  71. package/dist/typed/formula/read.js +47 -0
  72. package/dist/typed/odb/read.cjs +112 -0
  73. package/dist/typed/odb/read.d.cts +17 -0
  74. package/dist/typed/odb/read.d.ts +17 -0
  75. package/dist/typed/odb/read.js +111 -0
  76. package/dist/typed/odg/read.cjs +30 -0
  77. package/dist/typed/odg/read.d.cts +10 -0
  78. package/dist/typed/odg/read.d.ts +10 -0
  79. package/dist/typed/odg/read.js +29 -0
  80. package/dist/typed/odm/read.cjs +37 -0
  81. package/dist/typed/odm/read.d.cts +15 -0
  82. package/dist/typed/odm/read.d.ts +15 -0
  83. package/dist/typed/odm/read.js +36 -0
  84. package/dist/typed/odp/read.cjs +39 -0
  85. package/dist/typed/odp/read.d.cts +10 -0
  86. package/dist/typed/odp/read.d.ts +10 -0
  87. package/dist/typed/odp/read.js +38 -0
  88. package/dist/typed/ods/read.cjs +318 -0
  89. package/dist/typed/ods/read.d.cts +10 -0
  90. package/dist/typed/ods/read.d.ts +10 -0
  91. package/dist/typed/ods/read.js +317 -0
  92. package/dist/typed/odt/read.cjs +112 -0
  93. package/dist/typed/odt/read.d.cts +10 -0
  94. package/dist/typed/odt/read.d.ts +10 -0
  95. package/dist/typed/odt/read.js +111 -0
  96. package/dist/typed/shared/a1.cjs +68 -0
  97. package/dist/typed/shared/a1.d.cts +18 -0
  98. package/dist/typed/shared/a1.d.ts +18 -0
  99. package/dist/typed/shared/a1.js +63 -0
  100. package/dist/typed/shared/cascade.cjs +102 -0
  101. package/dist/typed/shared/cascade.d.cts +22 -0
  102. package/dist/typed/shared/cascade.d.ts +22 -0
  103. package/dist/typed/shared/cascade.js +99 -0
  104. package/dist/typed/shared/color.cjs +14 -0
  105. package/dist/typed/shared/color.d.cts +6 -0
  106. package/dist/typed/shared/color.d.ts +6 -0
  107. package/dist/typed/shared/color.js +12 -0
  108. package/dist/typed/shared/geometry.cjs +79 -0
  109. package/dist/typed/shared/geometry.d.cts +12 -0
  110. package/dist/typed/shared/geometry.d.ts +12 -0
  111. package/dist/typed/shared/geometry.js +75 -0
  112. package/dist/typed/shared/masterpage.cjs +39 -0
  113. package/dist/typed/shared/masterpage.d.cts +8 -0
  114. package/dist/typed/shared/masterpage.d.ts +8 -0
  115. package/dist/typed/shared/masterpage.js +37 -0
  116. package/dist/typed/shared/metadata.cjs +42 -0
  117. package/dist/typed/shared/metadata.d.cts +7 -0
  118. package/dist/typed/shared/metadata.d.ts +7 -0
  119. package/dist/typed/shared/metadata.js +40 -0
  120. package/dist/typed/shared/paragraph.cjs +57 -0
  121. package/dist/typed/shared/paragraph.d.cts +7 -0
  122. package/dist/typed/shared/paragraph.d.ts +7 -0
  123. package/dist/typed/shared/paragraph.js +56 -0
  124. package/dist/typed/shared/path.cjs +261 -0
  125. package/dist/typed/shared/path.d.cts +34 -0
  126. package/dist/typed/shared/path.d.ts +34 -0
  127. package/dist/typed/shared/path.js +255 -0
  128. package/dist/typed/shared/style.cjs +8 -0
  129. package/dist/typed/shared/style.d.cts +2 -0
  130. package/dist/typed/shared/style.d.ts +2 -0
  131. package/dist/typed/shared/style.js +2 -0
  132. package/dist/typed/shared/table.cjs +84 -0
  133. package/dist/typed/shared/table.d.cts +7 -0
  134. package/dist/typed/shared/table.d.ts +7 -0
  135. package/dist/typed/shared/table.js +83 -0
  136. package/dist/typed/shared/text.cjs +43 -0
  137. package/dist/typed/shared/text.d.cts +8 -0
  138. package/dist/typed/shared/text.d.ts +8 -0
  139. package/dist/typed/shared/text.js +39 -0
  140. package/dist/typed/shared/transform.cjs +112 -0
  141. package/dist/typed/shared/transform.d.cts +26 -0
  142. package/dist/typed/shared/transform.d.ts +26 -0
  143. package/dist/typed/shared/transform.js +107 -0
  144. package/dist/typed/shared/units.cjs +35 -0
  145. package/dist/typed/shared/units.d.cts +2 -0
  146. package/dist/typed/shared/units.d.ts +2 -0
  147. package/dist/typed/shared/units.js +33 -0
  148. package/dist/units-7pCiECuP.d.cts +6 -0
  149. package/dist/units-7pCiECuP.d.ts +6 -0
  150. package/dist/util/base64.cjs +48 -0
  151. package/dist/util/base64.d.cts +5 -0
  152. package/dist/util/base64.d.ts +5 -0
  153. package/dist/util/base64.js +46 -0
  154. package/dist/xml/build.cjs +46 -0
  155. package/dist/xml/build.d.cts +5 -0
  156. package/dist/xml/build.d.ts +5 -0
  157. package/dist/xml/build.js +46 -0
  158. package/dist/xml/entities.cjs +19 -0
  159. package/dist/xml/entities.d.cts +5 -0
  160. package/dist/xml/entities.d.ts +5 -0
  161. package/dist/xml/entities.js +17 -0
  162. package/dist/xml/fragment.cjs +22 -0
  163. package/dist/xml/fragment.d.cts +6 -0
  164. package/dist/xml/fragment.d.ts +6 -0
  165. package/dist/xml/fragment.js +20 -0
  166. package/dist/xml/parse.cjs +88 -0
  167. package/dist/xml/parse.d.cts +5 -0
  168. package/dist/xml/parse.d.ts +5 -0
  169. package/dist/xml/parse.js +88 -0
  170. package/dist/xml/query.cjs +33 -0
  171. package/dist/xml/query.d.cts +9 -0
  172. package/dist/xml/query.d.ts +9 -0
  173. package/dist/xml/query.js +28 -0
  174. package/dist/zip.cjs +15 -0
  175. package/dist/zip.d.cts +9 -0
  176. package/dist/zip.d.ts +9 -0
  177. package/dist/zip.js +13 -0
  178. package/package.json +9 -1
@@ -0,0 +1,48 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_xml_entities = require("../../xml/entities.cjs");
3
+ const require_xml_query = require("../../xml/query.cjs");
4
+ const require_typed_shared_metadata = require("../shared/metadata.cjs");
5
+ //#region src/typed/formula/read.ts
6
+ const CONTENT_PART = "content.xml";
7
+ const MATH_ROOT_TAGS = ["math", "math:math"];
8
+ const ANNOTATION_TAGS = ["annotation", "math:annotation"];
9
+ const STARMATH_ENCODING_PREFIX = "StarMath";
10
+ function findMathRoot(nodes) {
11
+ const root = require_xml_query.rootElement(nodes);
12
+ if (root === void 0) return;
13
+ if (MATH_ROOT_TAGS.includes(root.tag)) return root;
14
+ for (const tag of MATH_ROOT_TAGS) {
15
+ const [found] = require_xml_query.elementsWithTag(root.children, tag);
16
+ if (found !== void 0) return found;
17
+ }
18
+ }
19
+ function annotationText(element) {
20
+ let text = "";
21
+ for (const child of element.children) if (child.type === "text") text += require_xml_entities.decodeXmlText(child.value);
22
+ return text;
23
+ }
24
+ function findStarMathAnnotation(mathRoot) {
25
+ for (const tag of ANNOTATION_TAGS) for (const annotation of require_xml_query.elementsWithTag(mathRoot.children, tag)) {
26
+ if (!require_xml_query.attrValue(annotation, "encoding")?.startsWith(STARMATH_ENCODING_PREFIX)) continue;
27
+ const text = annotationText(annotation);
28
+ if (text.length > 0) return text;
29
+ }
30
+ }
31
+ function readOdfFormula(pkg) {
32
+ const contentPart = pkg.parts[CONTENT_PART];
33
+ if (contentPart?.kind !== "xml") throw new Error(`readOdfFormula: package has no ${CONTENT_PART} part`);
34
+ const mathRoot = findMathRoot(contentPart.nodes);
35
+ if (mathRoot === void 0) throw new Error(`readOdfFormula: ${CONTENT_PART} has no MathML root element`);
36
+ const metadata = require_typed_shared_metadata.readOdfMetadata(pkg);
37
+ const starMath = findStarMathAnnotation(mathRoot);
38
+ return starMath === void 0 ? {
39
+ mathml: mathRoot.children,
40
+ metadata
41
+ } : {
42
+ starMath,
43
+ mathml: mathRoot.children,
44
+ metadata
45
+ };
46
+ }
47
+ //#endregion
48
+ exports.readOdfFormula = readOdfFormula;
@@ -0,0 +1,12 @@
1
+ import { d as XmlNode } from "../../node-CkBWRjNR.cjs";
2
+ import { Package } from "../../model/package.cjs";
3
+ import { LayoutMetadata } from "document-schema.js";
4
+ //#region src/typed/formula/read.d.ts
5
+ interface OdfFormulaDocument {
6
+ starMath?: string;
7
+ mathml: XmlNode[];
8
+ metadata: LayoutMetadata;
9
+ }
10
+ declare function readOdfFormula(pkg: Package): OdfFormulaDocument;
11
+ //#endregion
12
+ export { OdfFormulaDocument, readOdfFormula };
@@ -0,0 +1,12 @@
1
+ import { d as XmlNode } from "../../node-CkBWRjNR.js";
2
+ import { Package } from "../../model/package.js";
3
+ import { LayoutMetadata } from "document-schema.js";
4
+ //#region src/typed/formula/read.d.ts
5
+ interface OdfFormulaDocument {
6
+ starMath?: string;
7
+ mathml: XmlNode[];
8
+ metadata: LayoutMetadata;
9
+ }
10
+ declare function readOdfFormula(pkg: Package): OdfFormulaDocument;
11
+ //#endregion
12
+ export { OdfFormulaDocument, readOdfFormula };
@@ -0,0 +1,47 @@
1
+ import { decodeXmlText } from "../../xml/entities.js";
2
+ import { attrValue, elementsWithTag, rootElement } from "../../xml/query.js";
3
+ import { readOdfMetadata } from "../shared/metadata.js";
4
+ //#region src/typed/formula/read.ts
5
+ const CONTENT_PART = "content.xml";
6
+ const MATH_ROOT_TAGS = ["math", "math:math"];
7
+ const ANNOTATION_TAGS = ["annotation", "math:annotation"];
8
+ const STARMATH_ENCODING_PREFIX = "StarMath";
9
+ function findMathRoot(nodes) {
10
+ const root = rootElement(nodes);
11
+ if (root === void 0) return;
12
+ if (MATH_ROOT_TAGS.includes(root.tag)) return root;
13
+ for (const tag of MATH_ROOT_TAGS) {
14
+ const [found] = elementsWithTag(root.children, tag);
15
+ if (found !== void 0) return found;
16
+ }
17
+ }
18
+ function annotationText(element) {
19
+ let text = "";
20
+ for (const child of element.children) if (child.type === "text") text += decodeXmlText(child.value);
21
+ return text;
22
+ }
23
+ function findStarMathAnnotation(mathRoot) {
24
+ for (const tag of ANNOTATION_TAGS) for (const annotation of elementsWithTag(mathRoot.children, tag)) {
25
+ if (!attrValue(annotation, "encoding")?.startsWith(STARMATH_ENCODING_PREFIX)) continue;
26
+ const text = annotationText(annotation);
27
+ if (text.length > 0) return text;
28
+ }
29
+ }
30
+ function readOdfFormula(pkg) {
31
+ const contentPart = pkg.parts[CONTENT_PART];
32
+ if (contentPart?.kind !== "xml") throw new Error(`readOdfFormula: package has no ${CONTENT_PART} part`);
33
+ const mathRoot = findMathRoot(contentPart.nodes);
34
+ if (mathRoot === void 0) throw new Error(`readOdfFormula: ${CONTENT_PART} has no MathML root element`);
35
+ const metadata = readOdfMetadata(pkg);
36
+ const starMath = findStarMathAnnotation(mathRoot);
37
+ return starMath === void 0 ? {
38
+ mathml: mathRoot.children,
39
+ metadata
40
+ } : {
41
+ starMath,
42
+ mathml: mathRoot.children,
43
+ metadata
44
+ };
45
+ }
46
+ //#endregion
47
+ export { readOdfFormula };
@@ -0,0 +1,112 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_manifest = require("../../manifest.cjs");
3
+ const require_xml_query = require("../../xml/query.cjs");
4
+ //#region src/typed/odb/read.ts
5
+ const CONTENT_PART = "content.xml";
6
+ const EMBEDDED_URL_PREFIX = "sdbc:embedded:";
7
+ const SUBDOCUMENT_CONTENT_SUFFIX = "/content.xml";
8
+ function isXmlMediaType(mediaType) {
9
+ return mediaType === "text/xml" || mediaType === "application/xml" || mediaType.endsWith("+xml");
10
+ }
11
+ function formatServerDatabaseUrl(serverDatabase) {
12
+ const dbType = require_xml_query.attrValue(serverDatabase, "db:type");
13
+ if (dbType === void 0) return;
14
+ const hostname = require_xml_query.attrValue(serverDatabase, "db:hostname");
15
+ const port = require_xml_query.attrValue(serverDatabase, "db:port");
16
+ const localSocketName = require_xml_query.attrValue(serverDatabase, "db:local-socket-name");
17
+ const databaseName = require_xml_query.attrValue(serverDatabase, "db:database-name");
18
+ const host = hostname === void 0 ? localSocketName : `${hostname}${port === void 0 ? "" : `:${port}`}`;
19
+ if (host === void 0) return databaseName === void 0 ? `${dbType}://` : `${dbType}:///${databaseName}`;
20
+ return databaseName === void 0 ? `${dbType}://${host}` : `${dbType}://${host}/${databaseName}`;
21
+ }
22
+ function readConnectionInfo(databaseElement) {
23
+ const dataSource = require_xml_query.findChildElement(databaseElement.children, "db:data-source");
24
+ const connectionData = dataSource === void 0 ? void 0 : require_xml_query.findChildElement(dataSource.children, "db:connection-data");
25
+ if (connectionData === void 0) return;
26
+ const resource = require_xml_query.findChildElement(connectionData.children, "db:connection-resource");
27
+ if (resource !== void 0) {
28
+ const url = require_xml_query.attrValue(resource, "xlink:href");
29
+ if (url === void 0) return;
30
+ return {
31
+ type: url.startsWith(EMBEDDED_URL_PREFIX) ? "embedded" : "external",
32
+ url
33
+ };
34
+ }
35
+ const description = require_xml_query.findChildElement(connectionData.children, "db:database-description");
36
+ if (description === void 0) return;
37
+ const fileBased = require_xml_query.findChildElement(description.children, "db:file-based-database");
38
+ if (fileBased !== void 0) {
39
+ const url = require_xml_query.attrValue(fileBased, "xlink:href");
40
+ return url === void 0 ? { type: "external" } : {
41
+ type: "external",
42
+ url
43
+ };
44
+ }
45
+ const serverDatabase = require_xml_query.findChildElement(description.children, "db:server-database");
46
+ if (serverDatabase !== void 0) {
47
+ const url = formatServerDatabaseUrl(serverDatabase);
48
+ return url === void 0 ? { type: "external" } : {
49
+ type: "external",
50
+ url
51
+ };
52
+ }
53
+ }
54
+ function collectQueryNames(container, names) {
55
+ for (const child of container.children) {
56
+ if (child.type !== "element") continue;
57
+ if (child.tag === "db:query") {
58
+ const name = require_xml_query.attrValue(child, "db:name");
59
+ if (name !== void 0) names.push(name);
60
+ } else if (child.tag === "db:query-collection") collectQueryNames(child, names);
61
+ }
62
+ }
63
+ function collectTableNames(databaseElement) {
64
+ const names = [];
65
+ const seen = /* @__PURE__ */ new Set();
66
+ const pushName = (name) => {
67
+ if (name !== void 0 && !seen.has(name)) {
68
+ seen.add(name);
69
+ names.push(name);
70
+ }
71
+ };
72
+ const representations = require_xml_query.findChildElement(databaseElement.children, "db:table-representations");
73
+ if (representations !== void 0) for (const representation of require_xml_query.childrenWithTag(representations, "db:table-representation")) pushName(require_xml_query.attrValue(representation, "db:name"));
74
+ const schemaDefinition = require_xml_query.findChildElement(databaseElement.children, "db:schema-definition");
75
+ const tableDefinitions = schemaDefinition === void 0 ? void 0 : require_xml_query.findChildElement(schemaDefinition.children, "db:table-definitions");
76
+ if (tableDefinitions !== void 0) for (const definition of require_xml_query.childrenWithTag(tableDefinitions, "db:table-definition")) pushName(require_xml_query.attrValue(definition, "db:name"));
77
+ return names;
78
+ }
79
+ function subdocumentNamesUnderPrefix(entries, prefix) {
80
+ const names = [];
81
+ for (const entry of entries) {
82
+ if (!entry.fullPath.startsWith(prefix) || !entry.fullPath.endsWith(SUBDOCUMENT_CONTENT_SUFFIX) || !isXmlMediaType(entry.mediaType)) continue;
83
+ const withoutSuffix = entry.fullPath.slice(0, entry.fullPath.length - 12);
84
+ const lastSlash = withoutSuffix.lastIndexOf("/");
85
+ const name = lastSlash === -1 ? withoutSuffix.slice(prefix.length) : withoutSuffix.slice(lastSlash + 1);
86
+ if (name.length > 0) names.push(name);
87
+ }
88
+ return names;
89
+ }
90
+ function readOdbInventory(pkg) {
91
+ const contentPart = pkg.parts[CONTENT_PART];
92
+ if (contentPart?.kind !== "xml") throw new Error(`readOdbInventory: package has no ${CONTENT_PART} part`);
93
+ const contentRoot = require_xml_query.rootElement(contentPart.nodes);
94
+ const body = contentRoot === void 0 ? void 0 : require_xml_query.findChildElement(contentRoot.children, "office:body");
95
+ const databaseElement = body === void 0 ? void 0 : require_xml_query.findChildElement(body.children, "office:database");
96
+ if (databaseElement === void 0) throw new Error(`readOdbInventory: ${CONTENT_PART} has no office:body/office:database element`);
97
+ const connection = readConnectionInfo(databaseElement);
98
+ const queries = [];
99
+ const queriesElement = require_xml_query.findChildElement(databaseElement.children, "db:queries");
100
+ if (queriesElement !== void 0) collectQueryNames(queriesElement, queries);
101
+ const tables = collectTableNames(databaseElement);
102
+ const manifest = require_manifest.readManifest(pkg);
103
+ return {
104
+ connection,
105
+ tables,
106
+ queries,
107
+ forms: subdocumentNamesUnderPrefix(manifest.entries, "forms/"),
108
+ reports: subdocumentNamesUnderPrefix(manifest.entries, "reports/")
109
+ };
110
+ }
111
+ //#endregion
112
+ exports.readOdbInventory = readOdbInventory;
@@ -0,0 +1,17 @@
1
+ import { Package } from "../../model/package.cjs";
2
+ //#region src/typed/odb/read.d.ts
3
+ interface OdbConnectionInfo {
4
+ type: 'embedded' | 'external';
5
+ driverClass?: string;
6
+ url?: string;
7
+ }
8
+ interface OdbInventory {
9
+ connection: OdbConnectionInfo | undefined;
10
+ tables: string[];
11
+ queries: string[];
12
+ forms: string[];
13
+ reports: string[];
14
+ }
15
+ declare function readOdbInventory(pkg: Package): OdbInventory;
16
+ //#endregion
17
+ export { OdbConnectionInfo, OdbInventory, readOdbInventory };
@@ -0,0 +1,17 @@
1
+ import { Package } from "../../model/package.js";
2
+ //#region src/typed/odb/read.d.ts
3
+ interface OdbConnectionInfo {
4
+ type: 'embedded' | 'external';
5
+ driverClass?: string;
6
+ url?: string;
7
+ }
8
+ interface OdbInventory {
9
+ connection: OdbConnectionInfo | undefined;
10
+ tables: string[];
11
+ queries: string[];
12
+ forms: string[];
13
+ reports: string[];
14
+ }
15
+ declare function readOdbInventory(pkg: Package): OdbInventory;
16
+ //#endregion
17
+ export { OdbConnectionInfo, OdbInventory, readOdbInventory };
@@ -0,0 +1,111 @@
1
+ import { readManifest } from "../../manifest.js";
2
+ import { attrValue, childrenWithTag, findChildElement, rootElement } from "../../xml/query.js";
3
+ //#region src/typed/odb/read.ts
4
+ const CONTENT_PART = "content.xml";
5
+ const EMBEDDED_URL_PREFIX = "sdbc:embedded:";
6
+ const SUBDOCUMENT_CONTENT_SUFFIX = "/content.xml";
7
+ function isXmlMediaType(mediaType) {
8
+ return mediaType === "text/xml" || mediaType === "application/xml" || mediaType.endsWith("+xml");
9
+ }
10
+ function formatServerDatabaseUrl(serverDatabase) {
11
+ const dbType = attrValue(serverDatabase, "db:type");
12
+ if (dbType === void 0) return;
13
+ const hostname = attrValue(serverDatabase, "db:hostname");
14
+ const port = attrValue(serverDatabase, "db:port");
15
+ const localSocketName = attrValue(serverDatabase, "db:local-socket-name");
16
+ const databaseName = attrValue(serverDatabase, "db:database-name");
17
+ const host = hostname === void 0 ? localSocketName : `${hostname}${port === void 0 ? "" : `:${port}`}`;
18
+ if (host === void 0) return databaseName === void 0 ? `${dbType}://` : `${dbType}:///${databaseName}`;
19
+ return databaseName === void 0 ? `${dbType}://${host}` : `${dbType}://${host}/${databaseName}`;
20
+ }
21
+ function readConnectionInfo(databaseElement) {
22
+ const dataSource = findChildElement(databaseElement.children, "db:data-source");
23
+ const connectionData = dataSource === void 0 ? void 0 : findChildElement(dataSource.children, "db:connection-data");
24
+ if (connectionData === void 0) return;
25
+ const resource = findChildElement(connectionData.children, "db:connection-resource");
26
+ if (resource !== void 0) {
27
+ const url = attrValue(resource, "xlink:href");
28
+ if (url === void 0) return;
29
+ return {
30
+ type: url.startsWith(EMBEDDED_URL_PREFIX) ? "embedded" : "external",
31
+ url
32
+ };
33
+ }
34
+ const description = findChildElement(connectionData.children, "db:database-description");
35
+ if (description === void 0) return;
36
+ const fileBased = findChildElement(description.children, "db:file-based-database");
37
+ if (fileBased !== void 0) {
38
+ const url = attrValue(fileBased, "xlink:href");
39
+ return url === void 0 ? { type: "external" } : {
40
+ type: "external",
41
+ url
42
+ };
43
+ }
44
+ const serverDatabase = findChildElement(description.children, "db:server-database");
45
+ if (serverDatabase !== void 0) {
46
+ const url = formatServerDatabaseUrl(serverDatabase);
47
+ return url === void 0 ? { type: "external" } : {
48
+ type: "external",
49
+ url
50
+ };
51
+ }
52
+ }
53
+ function collectQueryNames(container, names) {
54
+ for (const child of container.children) {
55
+ if (child.type !== "element") continue;
56
+ if (child.tag === "db:query") {
57
+ const name = attrValue(child, "db:name");
58
+ if (name !== void 0) names.push(name);
59
+ } else if (child.tag === "db:query-collection") collectQueryNames(child, names);
60
+ }
61
+ }
62
+ function collectTableNames(databaseElement) {
63
+ const names = [];
64
+ const seen = /* @__PURE__ */ new Set();
65
+ const pushName = (name) => {
66
+ if (name !== void 0 && !seen.has(name)) {
67
+ seen.add(name);
68
+ names.push(name);
69
+ }
70
+ };
71
+ const representations = findChildElement(databaseElement.children, "db:table-representations");
72
+ if (representations !== void 0) for (const representation of childrenWithTag(representations, "db:table-representation")) pushName(attrValue(representation, "db:name"));
73
+ const schemaDefinition = findChildElement(databaseElement.children, "db:schema-definition");
74
+ const tableDefinitions = schemaDefinition === void 0 ? void 0 : findChildElement(schemaDefinition.children, "db:table-definitions");
75
+ if (tableDefinitions !== void 0) for (const definition of childrenWithTag(tableDefinitions, "db:table-definition")) pushName(attrValue(definition, "db:name"));
76
+ return names;
77
+ }
78
+ function subdocumentNamesUnderPrefix(entries, prefix) {
79
+ const names = [];
80
+ for (const entry of entries) {
81
+ if (!entry.fullPath.startsWith(prefix) || !entry.fullPath.endsWith(SUBDOCUMENT_CONTENT_SUFFIX) || !isXmlMediaType(entry.mediaType)) continue;
82
+ const withoutSuffix = entry.fullPath.slice(0, entry.fullPath.length - 12);
83
+ const lastSlash = withoutSuffix.lastIndexOf("/");
84
+ const name = lastSlash === -1 ? withoutSuffix.slice(prefix.length) : withoutSuffix.slice(lastSlash + 1);
85
+ if (name.length > 0) names.push(name);
86
+ }
87
+ return names;
88
+ }
89
+ function readOdbInventory(pkg) {
90
+ const contentPart = pkg.parts[CONTENT_PART];
91
+ if (contentPart?.kind !== "xml") throw new Error(`readOdbInventory: package has no ${CONTENT_PART} part`);
92
+ const contentRoot = rootElement(contentPart.nodes);
93
+ const body = contentRoot === void 0 ? void 0 : findChildElement(contentRoot.children, "office:body");
94
+ const databaseElement = body === void 0 ? void 0 : findChildElement(body.children, "office:database");
95
+ if (databaseElement === void 0) throw new Error(`readOdbInventory: ${CONTENT_PART} has no office:body/office:database element`);
96
+ const connection = readConnectionInfo(databaseElement);
97
+ const queries = [];
98
+ const queriesElement = findChildElement(databaseElement.children, "db:queries");
99
+ if (queriesElement !== void 0) collectQueryNames(queriesElement, queries);
100
+ const tables = collectTableNames(databaseElement);
101
+ const manifest = readManifest(pkg);
102
+ return {
103
+ connection,
104
+ tables,
105
+ queries,
106
+ forms: subdocumentNamesUnderPrefix(manifest.entries, "forms/"),
107
+ reports: subdocumentNamesUnderPrefix(manifest.entries, "reports/")
108
+ };
109
+ }
110
+ //#endregion
111
+ export { readOdbInventory };
@@ -0,0 +1,30 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_xml_query = require("../../xml/query.cjs");
3
+ const require_typed_shared_metadata = require("../shared/metadata.cjs");
4
+ const require_typed_shared_masterpage = require("../shared/masterpage.cjs");
5
+ const require_typed_draw_shapes = require("../draw/shapes.cjs");
6
+ let document_schema_js = require("document-schema.js");
7
+ //#region src/typed/odg/read.ts
8
+ const CONTENT_PART = "content.xml";
9
+ function readPage(page, pkg) {
10
+ const size = require_typed_shared_masterpage.resolveDrawPageSize(page, pkg) ?? document_schema_js.PAGE_SIZE_A4;
11
+ const { shapes, vectors } = require_typed_draw_shapes.readDrawPageContent(page.children, pkg);
12
+ return {
13
+ size,
14
+ shapes,
15
+ vectors
16
+ };
17
+ }
18
+ function readOdg(pkg) {
19
+ const contentPart = pkg.parts[CONTENT_PART];
20
+ const root = contentPart?.kind === "xml" ? require_xml_query.rootElement(contentPart.nodes) : void 0;
21
+ const body = root === void 0 ? void 0 : require_xml_query.findChildElement(root.children, "office:body");
22
+ const drawing = body === void 0 ? void 0 : require_xml_query.findChildElement(body.children, "office:drawing");
23
+ const pages = drawing === void 0 ? [] : require_xml_query.childrenWithTag(drawing, "draw:page");
24
+ return {
25
+ metadata: require_typed_shared_metadata.readOdfMetadata(pkg),
26
+ pages: pages.map((page) => readPage(page, pkg))
27
+ };
28
+ }
29
+ //#endregion
30
+ exports.readOdg = readOdg;
@@ -0,0 +1,10 @@
1
+ import { Package } from "../../model/package.cjs";
2
+ import { ContentDrawPage, LayoutMetadata } from "document-schema.js";
3
+ //#region src/typed/odg/read.d.ts
4
+ interface OdgDocument {
5
+ metadata: LayoutMetadata;
6
+ pages: ContentDrawPage[];
7
+ }
8
+ declare function readOdg(pkg: Package): OdgDocument;
9
+ //#endregion
10
+ export { OdgDocument, readOdg };
@@ -0,0 +1,10 @@
1
+ import { Package } from "../../model/package.js";
2
+ import { ContentDrawPage, LayoutMetadata } from "document-schema.js";
3
+ //#region src/typed/odg/read.d.ts
4
+ interface OdgDocument {
5
+ metadata: LayoutMetadata;
6
+ pages: ContentDrawPage[];
7
+ }
8
+ declare function readOdg(pkg: Package): OdgDocument;
9
+ //#endregion
10
+ export { OdgDocument, readOdg };
@@ -0,0 +1,29 @@
1
+ import { childrenWithTag, findChildElement, rootElement } from "../../xml/query.js";
2
+ import { readOdfMetadata } from "../shared/metadata.js";
3
+ import { resolveDrawPageSize } from "../shared/masterpage.js";
4
+ import { readDrawPageContent } from "../draw/shapes.js";
5
+ import { PAGE_SIZE_A4 } from "document-schema.js";
6
+ //#region src/typed/odg/read.ts
7
+ const CONTENT_PART = "content.xml";
8
+ function readPage(page, pkg) {
9
+ const size = resolveDrawPageSize(page, pkg) ?? PAGE_SIZE_A4;
10
+ const { shapes, vectors } = readDrawPageContent(page.children, pkg);
11
+ return {
12
+ size,
13
+ shapes,
14
+ vectors
15
+ };
16
+ }
17
+ function readOdg(pkg) {
18
+ const contentPart = pkg.parts[CONTENT_PART];
19
+ const root = contentPart?.kind === "xml" ? rootElement(contentPart.nodes) : void 0;
20
+ const body = root === void 0 ? void 0 : findChildElement(root.children, "office:body");
21
+ const drawing = body === void 0 ? void 0 : findChildElement(body.children, "office:drawing");
22
+ const pages = drawing === void 0 ? [] : childrenWithTag(drawing, "draw:page");
23
+ return {
24
+ metadata: readOdfMetadata(pkg),
25
+ pages: pages.map((page) => readPage(page, pkg))
26
+ };
27
+ }
28
+ //#endregion
29
+ export { readOdg };
@@ -0,0 +1,37 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_xml_query = require("../../xml/query.cjs");
3
+ //#region src/typed/odm/read.ts
4
+ const CONTENT_PART = "content.xml";
5
+ function readSection(element) {
6
+ const sourceElement = require_xml_query.findChildElement(element.children, "text:section-source");
7
+ if (sourceElement === void 0) return;
8
+ const name = require_xml_query.attrValue(element, "text:name");
9
+ const href = require_xml_query.attrValue(sourceElement, "xlink:href");
10
+ if (name === void 0 || href === void 0) return;
11
+ const filterName = require_xml_query.attrValue(sourceElement, "text:filter-name");
12
+ return filterName === void 0 ? {
13
+ name,
14
+ href
15
+ } : {
16
+ name,
17
+ href,
18
+ filterName
19
+ };
20
+ }
21
+ function readOdm(pkg) {
22
+ const contentPart = pkg.parts[CONTENT_PART];
23
+ if (contentPart?.kind !== "xml") throw new Error(`readOdm: package has no ${CONTENT_PART} part`);
24
+ const contentRoot = require_xml_query.rootElement(contentPart.nodes);
25
+ const body = contentRoot === void 0 ? void 0 : require_xml_query.findChildElement(contentRoot.children, "office:body");
26
+ const textElement = body === void 0 ? void 0 : require_xml_query.findChildElement(body.children, "office:text");
27
+ if (textElement === void 0) throw new Error(`readOdm: ${CONTENT_PART} has no office:body/office:text element`);
28
+ const sections = [];
29
+ for (const node of textElement.children) {
30
+ if (node.type !== "element" || node.tag !== "text:section") continue;
31
+ const section = readSection(node);
32
+ if (section !== void 0) sections.push(section);
33
+ }
34
+ return { sections };
35
+ }
36
+ //#endregion
37
+ exports.readOdm = readOdm;
@@ -0,0 +1,15 @@
1
+ import { d as XmlNode } from "../../node-CkBWRjNR.cjs";
2
+ import { Package } from "../../model/package.cjs";
3
+ //#region src/typed/odm/read.d.ts
4
+ interface OdmSection {
5
+ name: string;
6
+ href: string;
7
+ filterName?: string;
8
+ inlineContent?: readonly XmlNode[];
9
+ }
10
+ interface OdmDocument {
11
+ sections: readonly OdmSection[];
12
+ }
13
+ declare function readOdm(pkg: Package): OdmDocument;
14
+ //#endregion
15
+ export { OdmDocument, OdmSection, readOdm };
@@ -0,0 +1,15 @@
1
+ import { d as XmlNode } from "../../node-CkBWRjNR.js";
2
+ import { Package } from "../../model/package.js";
3
+ //#region src/typed/odm/read.d.ts
4
+ interface OdmSection {
5
+ name: string;
6
+ href: string;
7
+ filterName?: string;
8
+ inlineContent?: readonly XmlNode[];
9
+ }
10
+ interface OdmDocument {
11
+ sections: readonly OdmSection[];
12
+ }
13
+ declare function readOdm(pkg: Package): OdmDocument;
14
+ //#endregion
15
+ export { OdmDocument, OdmSection, readOdm };
@@ -0,0 +1,36 @@
1
+ import { attrValue, findChildElement, rootElement } from "../../xml/query.js";
2
+ //#region src/typed/odm/read.ts
3
+ const CONTENT_PART = "content.xml";
4
+ function readSection(element) {
5
+ const sourceElement = findChildElement(element.children, "text:section-source");
6
+ if (sourceElement === void 0) return;
7
+ const name = attrValue(element, "text:name");
8
+ const href = attrValue(sourceElement, "xlink:href");
9
+ if (name === void 0 || href === void 0) return;
10
+ const filterName = attrValue(sourceElement, "text:filter-name");
11
+ return filterName === void 0 ? {
12
+ name,
13
+ href
14
+ } : {
15
+ name,
16
+ href,
17
+ filterName
18
+ };
19
+ }
20
+ function readOdm(pkg) {
21
+ const contentPart = pkg.parts[CONTENT_PART];
22
+ if (contentPart?.kind !== "xml") throw new Error(`readOdm: package has no ${CONTENT_PART} part`);
23
+ const contentRoot = rootElement(contentPart.nodes);
24
+ const body = contentRoot === void 0 ? void 0 : findChildElement(contentRoot.children, "office:body");
25
+ const textElement = body === void 0 ? void 0 : findChildElement(body.children, "office:text");
26
+ if (textElement === void 0) throw new Error(`readOdm: ${CONTENT_PART} has no office:body/office:text element`);
27
+ const sections = [];
28
+ for (const node of textElement.children) {
29
+ if (node.type !== "element" || node.tag !== "text:section") continue;
30
+ const section = readSection(node);
31
+ if (section !== void 0) sections.push(section);
32
+ }
33
+ return { sections };
34
+ }
35
+ //#endregion
36
+ export { readOdm };
@@ -0,0 +1,39 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_xml_query = require("../../xml/query.cjs");
3
+ const require_typed_shared_text = require("../shared/text.cjs");
4
+ const require_typed_shared_metadata = require("../shared/metadata.cjs");
5
+ const require_typed_shared_masterpage = require("../shared/masterpage.cjs");
6
+ const require_typed_draw_shapes = require("../draw/shapes.cjs");
7
+ let document_schema_js = require("document-schema.js");
8
+ //#region src/typed/odp/read.ts
9
+ const CONTENT_PART = "content.xml";
10
+ function readSlideSize(page, pkg) {
11
+ return require_typed_shared_masterpage.resolveDrawPageSize(page, pkg) ?? document_schema_js.SLIDE_SIZE_WIDESCREEN;
12
+ }
13
+ function readSlideNotes(page) {
14
+ const notes = require_xml_query.childrenWithTag(page, "presentation:notes")[0];
15
+ if (notes === void 0) return "";
16
+ return require_xml_query.elementsWithTag(notes.children, "text:p").map(require_typed_shared_text.decodeOdfText).join("\n");
17
+ }
18
+ function readSlide(page, pkg) {
19
+ const shapes = [];
20
+ require_typed_draw_shapes.walkDrawShapes(page.children, [], pkg, shapes);
21
+ return {
22
+ size: readSlideSize(page, pkg),
23
+ shapes,
24
+ notes: readSlideNotes(page)
25
+ };
26
+ }
27
+ function readOdp(pkg) {
28
+ const contentPart = pkg.parts[CONTENT_PART];
29
+ const root = contentPart?.kind === "xml" ? require_xml_query.rootElement(contentPart.nodes) : void 0;
30
+ const body = root === void 0 ? void 0 : require_xml_query.findChildElement(root.children, "office:body");
31
+ const presentation = body === void 0 ? void 0 : require_xml_query.findChildElement(body.children, "office:presentation");
32
+ const pages = presentation === void 0 ? [] : require_xml_query.childrenWithTag(presentation, "draw:page");
33
+ return {
34
+ metadata: require_typed_shared_metadata.readOdfMetadata(pkg),
35
+ slides: pages.map((page) => readSlide(page, pkg))
36
+ };
37
+ }
38
+ //#endregion
39
+ exports.readOdp = readOdp;
@@ -0,0 +1,10 @@
1
+ import { Package } from "../../model/package.cjs";
2
+ import { ContentSlide, LayoutMetadata } from "document-schema.js";
3
+ //#region src/typed/odp/read.d.ts
4
+ interface OdpDocument {
5
+ metadata: LayoutMetadata;
6
+ slides: ContentSlide[];
7
+ }
8
+ declare function readOdp(pkg: Package): OdpDocument;
9
+ //#endregion
10
+ export { OdpDocument, readOdp };
@@ -0,0 +1,10 @@
1
+ import { Package } from "../../model/package.js";
2
+ import { ContentSlide, LayoutMetadata } from "document-schema.js";
3
+ //#region src/typed/odp/read.d.ts
4
+ interface OdpDocument {
5
+ metadata: LayoutMetadata;
6
+ slides: ContentSlide[];
7
+ }
8
+ declare function readOdp(pkg: Package): OdpDocument;
9
+ //#endregion
10
+ export { OdpDocument, readOdp };