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,26 @@
1
+ import { l as XmlElement } from "../../node-CkBWRjNR.cjs";
2
+ import { Box } from "document-schema.js";
3
+ //#region src/typed/shared/transform.d.ts
4
+ type OdfTransformFunction = {
5
+ readonly kind: 'rotate';
6
+ readonly angleRad: number;
7
+ } | {
8
+ readonly kind: 'translate';
9
+ readonly xPt: number;
10
+ readonly yPt: number;
11
+ };
12
+ interface OdfPoint {
13
+ readonly xPt: number;
14
+ readonly yPt: number;
15
+ }
16
+ declare function parseOdfTransform(value: string): OdfTransformFunction[];
17
+ declare function applyOdfTransform(functions: readonly OdfTransformFunction[], point: OdfPoint): OdfPoint;
18
+ declare function netRotationDeg(functions: readonly OdfTransformFunction[]): number;
19
+ interface OdfShapeGeometry {
20
+ readonly frame: Box;
21
+ readonly rotationDeg: number | undefined;
22
+ }
23
+ declare function resolveOdfShapeGeometry(element: XmlElement): OdfShapeGeometry | undefined;
24
+ declare function composeOdfGroupTransform(groupFunctions: readonly OdfTransformFunction[], child: OdfShapeGeometry): OdfShapeGeometry;
25
+ //#endregion
26
+ export { OdfPoint, OdfShapeGeometry, OdfTransformFunction, applyOdfTransform, composeOdfGroupTransform, netRotationDeg, parseOdfTransform, resolveOdfShapeGeometry };
@@ -0,0 +1,26 @@
1
+ import { l as XmlElement } from "../../node-CkBWRjNR.js";
2
+ import { Box } from "document-schema.js";
3
+ //#region src/typed/shared/transform.d.ts
4
+ type OdfTransformFunction = {
5
+ readonly kind: 'rotate';
6
+ readonly angleRad: number;
7
+ } | {
8
+ readonly kind: 'translate';
9
+ readonly xPt: number;
10
+ readonly yPt: number;
11
+ };
12
+ interface OdfPoint {
13
+ readonly xPt: number;
14
+ readonly yPt: number;
15
+ }
16
+ declare function parseOdfTransform(value: string): OdfTransformFunction[];
17
+ declare function applyOdfTransform(functions: readonly OdfTransformFunction[], point: OdfPoint): OdfPoint;
18
+ declare function netRotationDeg(functions: readonly OdfTransformFunction[]): number;
19
+ interface OdfShapeGeometry {
20
+ readonly frame: Box;
21
+ readonly rotationDeg: number | undefined;
22
+ }
23
+ declare function resolveOdfShapeGeometry(element: XmlElement): OdfShapeGeometry | undefined;
24
+ declare function composeOdfGroupTransform(groupFunctions: readonly OdfTransformFunction[], child: OdfShapeGeometry): OdfShapeGeometry;
25
+ //#endregion
26
+ export { OdfPoint, OdfShapeGeometry, OdfTransformFunction, applyOdfTransform, composeOdfGroupTransform, netRotationDeg, parseOdfTransform, resolveOdfShapeGeometry };
@@ -0,0 +1,107 @@
1
+ import { parseOdfLength } from "./units.js";
2
+ import { attrValue } from "../../xml/query.js";
3
+ import { parseBox } from "./geometry.js";
4
+ //#region src/typed/shared/transform.ts
5
+ const FUNCTION_PATTERN = /([a-zA-Z]+)\s*\(\s*([^)]*?)\s*\)/g;
6
+ function parseOdfTransform(value) {
7
+ const functions = [];
8
+ for (const match of value.matchAll(FUNCTION_PATTERN)) {
9
+ const name = match[1];
10
+ const argsRaw = match[2];
11
+ if (name === void 0 || argsRaw === void 0) continue;
12
+ const args = argsRaw.split(/\s+/).filter((arg) => arg.length > 0);
13
+ if (name === "rotate") {
14
+ const angleArg = args[0];
15
+ if (angleArg === void 0) continue;
16
+ const angleRad = Number(angleArg);
17
+ if (!Number.isFinite(angleRad)) continue;
18
+ functions.push({
19
+ kind: "rotate",
20
+ angleRad
21
+ });
22
+ } else if (name === "translate") {
23
+ const xArg = args[0];
24
+ if (xArg === void 0) continue;
25
+ const yArg = args[1];
26
+ const xPt = parseOdfLength(xArg);
27
+ const yPt = yArg === void 0 ? 0 : parseOdfLength(yArg);
28
+ if (xPt === void 0 || yPt === void 0) continue;
29
+ functions.push({
30
+ kind: "translate",
31
+ xPt,
32
+ yPt
33
+ });
34
+ }
35
+ }
36
+ return functions;
37
+ }
38
+ function applyOdfTransform(functions, point) {
39
+ let current = point;
40
+ for (const fn of functions) if (fn.kind === "rotate") {
41
+ const cos = Math.cos(fn.angleRad);
42
+ const sin = Math.sin(fn.angleRad);
43
+ current = {
44
+ xPt: current.xPt * cos + current.yPt * sin,
45
+ yPt: current.yPt * cos - current.xPt * sin
46
+ };
47
+ } else current = {
48
+ xPt: current.xPt + fn.xPt,
49
+ yPt: current.yPt + fn.yPt
50
+ };
51
+ return current;
52
+ }
53
+ function netRotationDeg(functions) {
54
+ let totalRad = 0;
55
+ for (const fn of functions) if (fn.kind === "rotate") totalRad += fn.angleRad;
56
+ return -totalRad * 180 / Math.PI;
57
+ }
58
+ function resolveOdfShapeGeometry(element) {
59
+ const transformValue = attrValue(element, "draw:transform");
60
+ if (transformValue === void 0) {
61
+ const box = parseBox(element);
62
+ return box === void 0 ? void 0 : {
63
+ frame: box,
64
+ rotationDeg: void 0
65
+ };
66
+ }
67
+ const widthValue = attrValue(element, "svg:width");
68
+ const heightValue = attrValue(element, "svg:height");
69
+ if (widthValue === void 0 || heightValue === void 0) return;
70
+ const widthPt = parseOdfLength(widthValue);
71
+ const heightPt = parseOdfLength(heightValue);
72
+ if (widthPt === void 0 || heightPt === void 0) return;
73
+ const functions = parseOdfTransform(transformValue);
74
+ const center = applyOdfTransform(functions, {
75
+ xPt: widthPt / 2,
76
+ yPt: heightPt / 2
77
+ });
78
+ const rotationDeg = netRotationDeg(functions);
79
+ return {
80
+ frame: {
81
+ xPt: center.xPt - widthPt / 2,
82
+ yPt: center.yPt - heightPt / 2,
83
+ widthPt,
84
+ heightPt
85
+ },
86
+ rotationDeg: rotationDeg === 0 ? void 0 : rotationDeg
87
+ };
88
+ }
89
+ function composeOdfGroupTransform(groupFunctions, child) {
90
+ if (groupFunctions.length === 0) return child;
91
+ const newCenter = applyOdfTransform(groupFunctions, {
92
+ xPt: child.frame.xPt + child.frame.widthPt / 2,
93
+ yPt: child.frame.yPt + child.frame.heightPt / 2
94
+ });
95
+ const newRotationDeg = (child.rotationDeg ?? 0) + netRotationDeg(groupFunctions);
96
+ return {
97
+ frame: {
98
+ xPt: newCenter.xPt - child.frame.widthPt / 2,
99
+ yPt: newCenter.yPt - child.frame.heightPt / 2,
100
+ widthPt: child.frame.widthPt,
101
+ heightPt: child.frame.heightPt
102
+ },
103
+ rotationDeg: newRotationDeg === 0 ? void 0 : newRotationDeg
104
+ };
105
+ }
106
+ //#endregion
107
+ export { applyOdfTransform, composeOdfGroupTransform, netRotationDeg, parseOdfTransform, resolveOdfShapeGeometry };
@@ -0,0 +1,35 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/typed/shared/units.ts
3
+ const LENGTH_PATTERN = /^(-?(?:\d+(?:\.\d+)?|\.\d+))(cm|mm|in|pt|pc|px)$/;
4
+ const POINTS_PER_INCH = 72;
5
+ const POINTS_PER_PICA = 12;
6
+ const CM_PER_INCH = 2.54;
7
+ const MM_PER_INCH = 25.4;
8
+ const CSS_REFERENCE_PIXELS_PER_INCH = 96;
9
+ function unitToPtFactor(unit) {
10
+ switch (unit) {
11
+ case "pt": return 1;
12
+ case "in": return POINTS_PER_INCH;
13
+ case "cm": return POINTS_PER_INCH / CM_PER_INCH;
14
+ case "mm": return POINTS_PER_INCH / MM_PER_INCH;
15
+ case "pc": return POINTS_PER_PICA;
16
+ case "px": return POINTS_PER_INCH / CSS_REFERENCE_PIXELS_PER_INCH;
17
+ }
18
+ }
19
+ function isLengthUnit(value) {
20
+ return value === "cm" || value === "mm" || value === "in" || value === "pt" || value === "pc" || value === "px";
21
+ }
22
+ function parseOdfLength(value) {
23
+ const match = LENGTH_PATTERN.exec(value);
24
+ if (match === null) return;
25
+ const numeric = match[1];
26
+ const unit = match[2];
27
+ if (numeric === void 0 || unit === void 0 || !isLengthUnit(unit)) return;
28
+ return Number(numeric) * unitToPtFactor(unit);
29
+ }
30
+ function formatOdfLength(pt, unit = "pt") {
31
+ return `${pt / unitToPtFactor(unit)}${unit}`;
32
+ }
33
+ //#endregion
34
+ exports.formatOdfLength = formatOdfLength;
35
+ exports.parseOdfLength = parseOdfLength;
@@ -0,0 +1,2 @@
1
+ import { n as formatOdfLength, r as parseOdfLength, t as LengthUnit } from "../../units-7pCiECuP.cjs";
2
+ export { LengthUnit, formatOdfLength, parseOdfLength };
@@ -0,0 +1,2 @@
1
+ import { n as formatOdfLength, r as parseOdfLength, t as LengthUnit } from "../../units-7pCiECuP.js";
2
+ export { LengthUnit, formatOdfLength, parseOdfLength };
@@ -0,0 +1,33 @@
1
+ //#region src/typed/shared/units.ts
2
+ const LENGTH_PATTERN = /^(-?(?:\d+(?:\.\d+)?|\.\d+))(cm|mm|in|pt|pc|px)$/;
3
+ const POINTS_PER_INCH = 72;
4
+ const POINTS_PER_PICA = 12;
5
+ const CM_PER_INCH = 2.54;
6
+ const MM_PER_INCH = 25.4;
7
+ const CSS_REFERENCE_PIXELS_PER_INCH = 96;
8
+ function unitToPtFactor(unit) {
9
+ switch (unit) {
10
+ case "pt": return 1;
11
+ case "in": return POINTS_PER_INCH;
12
+ case "cm": return POINTS_PER_INCH / CM_PER_INCH;
13
+ case "mm": return POINTS_PER_INCH / MM_PER_INCH;
14
+ case "pc": return POINTS_PER_PICA;
15
+ case "px": return POINTS_PER_INCH / CSS_REFERENCE_PIXELS_PER_INCH;
16
+ }
17
+ }
18
+ function isLengthUnit(value) {
19
+ return value === "cm" || value === "mm" || value === "in" || value === "pt" || value === "pc" || value === "px";
20
+ }
21
+ function parseOdfLength(value) {
22
+ const match = LENGTH_PATTERN.exec(value);
23
+ if (match === null) return;
24
+ const numeric = match[1];
25
+ const unit = match[2];
26
+ if (numeric === void 0 || unit === void 0 || !isLengthUnit(unit)) return;
27
+ return Number(numeric) * unitToPtFactor(unit);
28
+ }
29
+ function formatOdfLength(pt, unit = "pt") {
30
+ return `${pt / unitToPtFactor(unit)}${unit}`;
31
+ }
32
+ //#endregion
33
+ export { formatOdfLength, parseOdfLength };
@@ -0,0 +1,6 @@
1
+ //#region src/typed/shared/units.d.ts
2
+ type LengthUnit = 'cm' | 'mm' | 'in' | 'pt' | 'pc' | 'px';
3
+ declare function parseOdfLength(value: string): number | undefined;
4
+ declare function formatOdfLength(pt: number, unit?: LengthUnit): string;
5
+ //#endregion
6
+ export { formatOdfLength as n, parseOdfLength as r, LengthUnit as t };
@@ -0,0 +1,6 @@
1
+ //#region src/typed/shared/units.d.ts
2
+ type LengthUnit = 'cm' | 'mm' | 'in' | 'pt' | 'pc' | 'px';
3
+ declare function parseOdfLength(value: string): number | undefined;
4
+ declare function formatOdfLength(pt: number, unit?: LengthUnit): string;
5
+ //#endregion
6
+ export { formatOdfLength as n, parseOdfLength as r, LengthUnit as t };
@@ -0,0 +1,48 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/util/base64.ts
3
+ const TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
4
+ const DECODE = (() => {
5
+ const map = (/* @__PURE__ */ new Uint8Array(256)).fill(255);
6
+ for (let i = 0; i < 64; i = i + 1) map[TABLE.charCodeAt(i)] = i;
7
+ return map;
8
+ })();
9
+ function bytesToBase64(bytes) {
10
+ let out = "";
11
+ const len = bytes.length;
12
+ for (let i = 0; i < len; i = i + 3) {
13
+ const b0 = bytes[i];
14
+ const b1 = i + 1 < len ? bytes[i + 1] : 0;
15
+ const b2 = i + 2 < len ? bytes[i + 2] : 0;
16
+ out += TABLE[b0 >> 2];
17
+ out += TABLE[(b0 & 3) << 4 | b1 >> 4];
18
+ out += i + 1 < len ? TABLE[(b1 & 15) << 2 | b2 >> 6] : "=";
19
+ out += i + 2 < len ? TABLE[b2 & 63] : "=";
20
+ }
21
+ return out;
22
+ }
23
+ function base64ToBytes(b64) {
24
+ const clean = b64.replace(/[^A-Za-z0-9+/=]/g, "");
25
+ const len = clean.length;
26
+ const out = new Uint8Array(len * 3 / 4 | 0);
27
+ let p = 0;
28
+ for (let i = 0; i < len; i = i + 4) {
29
+ const c0 = DECODE[clean.charCodeAt(i)];
30
+ const c1 = DECODE[clean.charCodeAt(i + 1)];
31
+ const c2 = clean.charCodeAt(i + 2);
32
+ const c3 = clean.charCodeAt(i + 3);
33
+ if (c0 === 255 || c1 === 255) throw new Error("invalid base64 input");
34
+ out[p++] = c0 << 2 | c1 >> 4;
35
+ if (c2 !== 61) {
36
+ const d2 = DECODE[c2];
37
+ out[p++] = (c1 & 15) << 4 | d2 >> 2;
38
+ if (c3 !== 61) {
39
+ const d3 = DECODE[c3];
40
+ out[p++] = (d2 & 3) << 6 | d3;
41
+ }
42
+ }
43
+ }
44
+ return out.subarray(0, p);
45
+ }
46
+ //#endregion
47
+ exports.base64ToBytes = base64ToBytes;
48
+ exports.bytesToBase64 = bytesToBase64;
@@ -0,0 +1,5 @@
1
+ //#region src/util/base64.d.ts
2
+ declare function bytesToBase64(bytes: Uint8Array<ArrayBuffer>): string;
3
+ declare function base64ToBytes(b64: string): Uint8Array<ArrayBuffer>;
4
+ //#endregion
5
+ export { base64ToBytes, bytesToBase64 };
@@ -0,0 +1,5 @@
1
+ //#region src/util/base64.d.ts
2
+ declare function bytesToBase64(bytes: Uint8Array<ArrayBuffer>): string;
3
+ declare function base64ToBytes(b64: string): Uint8Array<ArrayBuffer>;
4
+ //#endregion
5
+ export { base64ToBytes, bytesToBase64 };
@@ -0,0 +1,46 @@
1
+ //#region src/util/base64.ts
2
+ const TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
3
+ const DECODE = (() => {
4
+ const map = (/* @__PURE__ */ new Uint8Array(256)).fill(255);
5
+ for (let i = 0; i < 64; i = i + 1) map[TABLE.charCodeAt(i)] = i;
6
+ return map;
7
+ })();
8
+ function bytesToBase64(bytes) {
9
+ let out = "";
10
+ const len = bytes.length;
11
+ for (let i = 0; i < len; i = i + 3) {
12
+ const b0 = bytes[i];
13
+ const b1 = i + 1 < len ? bytes[i + 1] : 0;
14
+ const b2 = i + 2 < len ? bytes[i + 2] : 0;
15
+ out += TABLE[b0 >> 2];
16
+ out += TABLE[(b0 & 3) << 4 | b1 >> 4];
17
+ out += i + 1 < len ? TABLE[(b1 & 15) << 2 | b2 >> 6] : "=";
18
+ out += i + 2 < len ? TABLE[b2 & 63] : "=";
19
+ }
20
+ return out;
21
+ }
22
+ function base64ToBytes(b64) {
23
+ const clean = b64.replace(/[^A-Za-z0-9+/=]/g, "");
24
+ const len = clean.length;
25
+ const out = new Uint8Array(len * 3 / 4 | 0);
26
+ let p = 0;
27
+ for (let i = 0; i < len; i = i + 4) {
28
+ const c0 = DECODE[clean.charCodeAt(i)];
29
+ const c1 = DECODE[clean.charCodeAt(i + 1)];
30
+ const c2 = clean.charCodeAt(i + 2);
31
+ const c3 = clean.charCodeAt(i + 3);
32
+ if (c0 === 255 || c1 === 255) throw new Error("invalid base64 input");
33
+ out[p++] = c0 << 2 | c1 >> 4;
34
+ if (c2 !== 61) {
35
+ const d2 = DECODE[c2];
36
+ out[p++] = (c1 & 15) << 4 | d2 >> 2;
37
+ if (c3 !== 61) {
38
+ const d3 = DECODE[c3];
39
+ out[p++] = (d2 & 3) << 6 | d3;
40
+ }
41
+ }
42
+ }
43
+ return out.subarray(0, p);
44
+ }
45
+ //#endregion
46
+ export { base64ToBytes, bytesToBase64 };
@@ -0,0 +1,46 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/xml/build.ts
3
+ const BUILDER = new (require("fast-xml-parser")).XMLBuilder({
4
+ preserveOrder: true,
5
+ attributeNamePrefix: "@_",
6
+ ignoreAttributes: false,
7
+ textNodeName: "#text",
8
+ cdataPropName: "__cdata",
9
+ commentPropName: "__comment",
10
+ processEntities: false,
11
+ format: false,
12
+ suppressEmptyNode: false
13
+ });
14
+ function buildXml(nodes) {
15
+ const out = BUILDER.build(toOrdered(nodes));
16
+ if (typeof out !== "string") throw new Error("XMLBuilder did not return a string");
17
+ return out;
18
+ }
19
+ function toOrdered(nodes) {
20
+ return nodes.map(toOrderedNode);
21
+ }
22
+ function attrsObject(attributes) {
23
+ const obj = {};
24
+ for (const a of attributes) obj[`@_${a.name}`] = a.value;
25
+ return obj;
26
+ }
27
+ function toOrderedNode(node) {
28
+ switch (node.type) {
29
+ case "text": return { "#text": node.value };
30
+ case "comment": return { __comment: [{ "#text": node.value }] };
31
+ case "cdata": return { __cdata: [{ "#text": node.value }] };
32
+ case "pi": return { [`?${node.target}`]: [{ "#text": node.content }] };
33
+ case "declaration": return {
34
+ "?xml": [{ "#text": "" }],
35
+ ":@": attrsObject(node.attributes)
36
+ };
37
+ case "element": {
38
+ const obj = { [node.tag]: toOrdered(node.children) };
39
+ const attrs = attrsObject(node.attributes);
40
+ if (Object.keys(attrs).length > 0) obj[":@"] = attrs;
41
+ return obj;
42
+ }
43
+ }
44
+ }
45
+ //#endregion
46
+ exports.buildXml = buildXml;
@@ -0,0 +1,5 @@
1
+ import { d as XmlNode } from "../node-CkBWRjNR.cjs";
2
+ //#region src/xml/build.d.ts
3
+ declare function buildXml(nodes: XmlNode[]): string;
4
+ //#endregion
5
+ export { buildXml };
@@ -0,0 +1,5 @@
1
+ import { d as XmlNode } from "../node-CkBWRjNR.js";
2
+ //#region src/xml/build.d.ts
3
+ declare function buildXml(nodes: XmlNode[]): string;
4
+ //#endregion
5
+ export { buildXml };
@@ -0,0 +1,46 @@
1
+ import { XMLBuilder } from "fast-xml-parser";
2
+ //#region src/xml/build.ts
3
+ const BUILDER = new XMLBuilder({
4
+ preserveOrder: true,
5
+ attributeNamePrefix: "@_",
6
+ ignoreAttributes: false,
7
+ textNodeName: "#text",
8
+ cdataPropName: "__cdata",
9
+ commentPropName: "__comment",
10
+ processEntities: false,
11
+ format: false,
12
+ suppressEmptyNode: false
13
+ });
14
+ function buildXml(nodes) {
15
+ const out = BUILDER.build(toOrdered(nodes));
16
+ if (typeof out !== "string") throw new Error("XMLBuilder did not return a string");
17
+ return out;
18
+ }
19
+ function toOrdered(nodes) {
20
+ return nodes.map(toOrderedNode);
21
+ }
22
+ function attrsObject(attributes) {
23
+ const obj = {};
24
+ for (const a of attributes) obj[`@_${a.name}`] = a.value;
25
+ return obj;
26
+ }
27
+ function toOrderedNode(node) {
28
+ switch (node.type) {
29
+ case "text": return { "#text": node.value };
30
+ case "comment": return { __comment: [{ "#text": node.value }] };
31
+ case "cdata": return { __cdata: [{ "#text": node.value }] };
32
+ case "pi": return { [`?${node.target}`]: [{ "#text": node.content }] };
33
+ case "declaration": return {
34
+ "?xml": [{ "#text": "" }],
35
+ ":@": attrsObject(node.attributes)
36
+ };
37
+ case "element": {
38
+ const obj = { [node.tag]: toOrdered(node.children) };
39
+ const attrs = attrsObject(node.attributes);
40
+ if (Object.keys(attrs).length > 0) obj[":@"] = attrs;
41
+ return obj;
42
+ }
43
+ }
44
+ }
45
+ //#endregion
46
+ export { buildXml };
@@ -0,0 +1,19 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/xml/entities.ts
3
+ function encodeXmlText(value) {
4
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
5
+ }
6
+ const XML_ENTITY_PATTERN = /&(?:amp|lt|gt|quot|apos);/g;
7
+ const XML_ENTITY_DECODE = {
8
+ "&amp;": "&",
9
+ "&lt;": "<",
10
+ "&gt;": ">",
11
+ "&quot;": "\"",
12
+ "&apos;": "'"
13
+ };
14
+ function decodeXmlText(value) {
15
+ return value.replace(XML_ENTITY_PATTERN, (entity) => XML_ENTITY_DECODE[entity]);
16
+ }
17
+ //#endregion
18
+ exports.decodeXmlText = decodeXmlText;
19
+ exports.encodeXmlText = encodeXmlText;
@@ -0,0 +1,5 @@
1
+ //#region src/xml/entities.d.ts
2
+ declare function encodeXmlText(value: string): string;
3
+ declare function decodeXmlText(value: string): string;
4
+ //#endregion
5
+ export { decodeXmlText, encodeXmlText };
@@ -0,0 +1,5 @@
1
+ //#region src/xml/entities.d.ts
2
+ declare function encodeXmlText(value: string): string;
3
+ declare function decodeXmlText(value: string): string;
4
+ //#endregion
5
+ export { decodeXmlText, encodeXmlText };
@@ -0,0 +1,17 @@
1
+ //#region src/xml/entities.ts
2
+ function encodeXmlText(value) {
3
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
4
+ }
5
+ const XML_ENTITY_PATTERN = /&(?:amp|lt|gt|quot|apos);/g;
6
+ const XML_ENTITY_DECODE = {
7
+ "&amp;": "&",
8
+ "&lt;": "<",
9
+ "&gt;": ">",
10
+ "&quot;": "\"",
11
+ "&apos;": "'"
12
+ };
13
+ function decodeXmlText(value) {
14
+ return value.replace(XML_ENTITY_PATTERN, (entity) => XML_ENTITY_DECODE[entity]);
15
+ }
16
+ //#endregion
17
+ export { decodeXmlText, encodeXmlText };
@@ -0,0 +1,22 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/xml/fragment.ts
3
+ function el(tag, attrs = {}, children = []) {
4
+ return {
5
+ type: "element",
6
+ tag,
7
+ attributes: Object.entries(attrs).map(([name, value]) => ({
8
+ name,
9
+ value
10
+ })),
11
+ children
12
+ };
13
+ }
14
+ function txt(value) {
15
+ return {
16
+ type: "text",
17
+ value
18
+ };
19
+ }
20
+ //#endregion
21
+ exports.el = el;
22
+ exports.txt = txt;
@@ -0,0 +1,6 @@
1
+ import { d as XmlNode, h as XmlText, l as XmlElement } from "../node-CkBWRjNR.cjs";
2
+ //#region src/xml/fragment.d.ts
3
+ declare function el(tag: string, attrs?: Record<string, string>, children?: XmlNode[]): XmlElement;
4
+ declare function txt(value: string): XmlText;
5
+ //#endregion
6
+ export { el, txt };
@@ -0,0 +1,6 @@
1
+ import { d as XmlNode, h as XmlText, l as XmlElement } from "../node-CkBWRjNR.js";
2
+ //#region src/xml/fragment.d.ts
3
+ declare function el(tag: string, attrs?: Record<string, string>, children?: XmlNode[]): XmlElement;
4
+ declare function txt(value: string): XmlText;
5
+ //#endregion
6
+ export { el, txt };
@@ -0,0 +1,20 @@
1
+ //#region src/xml/fragment.ts
2
+ function el(tag, attrs = {}, children = []) {
3
+ return {
4
+ type: "element",
5
+ tag,
6
+ attributes: Object.entries(attrs).map(([name, value]) => ({
7
+ name,
8
+ value
9
+ })),
10
+ children
11
+ };
12
+ }
13
+ function txt(value) {
14
+ return {
15
+ type: "text",
16
+ value
17
+ };
18
+ }
19
+ //#endregion
20
+ export { el, txt };
@@ -0,0 +1,88 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/xml/parse.ts
3
+ const PARSER = new (require("fast-xml-parser")).XMLParser({
4
+ preserveOrder: true,
5
+ attributeNamePrefix: "@_",
6
+ ignoreAttributes: false,
7
+ textNodeName: "#text",
8
+ cdataPropName: "__cdata",
9
+ commentPropName: "__comment",
10
+ processEntities: false,
11
+ parseTagValue: false,
12
+ trimValues: false
13
+ });
14
+ function parseXml(xml) {
15
+ return parseNodes(PARSER.parse(xml));
16
+ }
17
+ function isRecord(value) {
18
+ return typeof value === "object" && value !== null && !Array.isArray(value);
19
+ }
20
+ function isUnknownArray(value) {
21
+ return Array.isArray(value);
22
+ }
23
+ function asString(value) {
24
+ if (typeof value !== "string") throw new Error(`expected string while parsing XML, got ${typeof value}`);
25
+ return value;
26
+ }
27
+ function parseNodes(raw) {
28
+ if (!isUnknownArray(raw)) throw new Error("fast-xml-parser output was not an ordered array");
29
+ return raw.map(parseNode);
30
+ }
31
+ function parseNode(raw) {
32
+ if (!isRecord(raw)) throw new Error("fast-xml-parser node was not an object");
33
+ let tagKey;
34
+ for (const key of Object.keys(raw)) if (key !== ":@") {
35
+ if (tagKey !== void 0) throw new Error("XML node had multiple tag keys");
36
+ tagKey = key;
37
+ }
38
+ if (tagKey === void 0) throw new Error("XML node had no tag key");
39
+ const attributes = parseAttributes(raw[":@"]);
40
+ if (tagKey === "#text") return {
41
+ type: "text",
42
+ value: asString(raw["#text"])
43
+ };
44
+ if (tagKey === "__comment") return {
45
+ type: "comment",
46
+ value: scalarText(raw.__comment)
47
+ };
48
+ if (tagKey === "__cdata") return {
49
+ type: "cdata",
50
+ value: scalarText(raw.__cdata)
51
+ };
52
+ if (tagKey === "?xml") return {
53
+ type: "declaration",
54
+ attributes
55
+ };
56
+ if (tagKey.startsWith("?")) return {
57
+ type: "pi",
58
+ target: tagKey.slice(1),
59
+ content: scalarText(raw[tagKey])
60
+ };
61
+ return {
62
+ type: "element",
63
+ tag: tagKey,
64
+ attributes,
65
+ children: parseNodes(raw[tagKey])
66
+ };
67
+ }
68
+ function parseAttributes(raw) {
69
+ if (raw === void 0) return [];
70
+ if (!isRecord(raw)) throw new Error("XML attributes were not an object");
71
+ const attrs = [];
72
+ for (const key of Object.keys(raw)) {
73
+ if (!key.startsWith("@_")) throw new Error(`unexpected attribute key without @_ prefix: ${key}`);
74
+ attrs.push({
75
+ name: key.slice(2),
76
+ value: asString(raw[key])
77
+ });
78
+ }
79
+ return attrs;
80
+ }
81
+ function scalarText(raw) {
82
+ if (!isUnknownArray(raw) || raw.length === 0) throw new Error("expected a scalar-text wrapper array");
83
+ const first = raw[0];
84
+ if (!isRecord(first)) throw new Error("scalar-text wrapper was not an object");
85
+ return asString(first["#text"]);
86
+ }
87
+ //#endregion
88
+ exports.parseXml = parseXml;