reamkit 1.32.1 → 1.33.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.
- package/README.md +5 -4
- package/dist/esm/core/bidi/algorithm.js +2 -2
- package/dist/esm/core/bidi/char-types.js +1 -1
- package/dist/esm/core/bidi/index.js +3 -3
- package/dist/esm/core/bytes.js +1 -1
- package/dist/esm/core/converter/facade.js +3 -2
- package/dist/esm/core/converter/ream.js +12 -5
- package/dist/esm/core/crypto/asn1.js +2 -2
- package/dist/esm/core/crypto/cms.js +5 -3
- package/dist/esm/core/crypto/index.js +2 -1
- package/dist/esm/core/crypto/offcrypto.js +8 -7
- package/dist/esm/core/crypto/primitives.js +16 -16
- package/dist/esm/core/document-model/index.d.ts +1 -1
- package/dist/esm/core/document-model/types.d.ts +174 -2
- package/dist/esm/core/drawingml/chart-geometry.d.ts +24 -6
- package/dist/esm/core/drawingml/chart-geometry.js +905 -208
- package/dist/esm/core/drawingml/chart-parser.d.ts +5 -1
- package/dist/esm/core/drawingml/chart-parser.js +275 -19
- package/dist/esm/core/drawingml/chart-text.d.ts +41 -0
- package/dist/esm/core/drawingml/chart-text.js +93 -0
- package/dist/esm/core/drawingml/colors.js +5 -5
- package/dist/esm/core/drawingml/diagram/layout-engine.js +1 -4
- package/dist/esm/core/drawingml/diagram/run.js +2 -1
- package/dist/esm/core/drawingml/preset-geometry.js +4 -6
- package/dist/esm/core/drawingml/shape-render.js +1 -1
- package/dist/esm/core/drawingml/text-warp.js +4 -16
- package/dist/esm/core/drawingml/theme-parser.js +14 -8
- package/dist/esm/core/font/arabic-joining.js +2 -2
- package/dist/esm/core/font/binary-reader.js +2 -0
- package/dist/esm/core/font/font-registry.js +1 -0
- package/dist/esm/core/font/ligatures.js +1 -1
- package/dist/esm/core/font/opentype-layout.js +11 -5
- package/dist/esm/core/font/ttf-build.js +6 -10
- package/dist/esm/core/font/ttf-parser.js +2 -1
- package/dist/esm/core/font/ttf-subset.js +8 -8
- package/dist/esm/core/fonts/families.js +1 -1
- package/dist/esm/core/fonts/remote-fonts.js +4 -4
- package/dist/esm/core/hyphenation/index.js +1 -1
- package/dist/esm/core/images.js +8 -8
- package/dist/esm/core/ir/loss.js +1 -0
- package/dist/esm/core/line-breaker/cjk.js +1 -1
- package/dist/esm/core/line-breaker/index.js +4 -3
- package/dist/esm/core/links.js +1 -1
- package/dist/esm/core/lzw.js +1 -1
- package/dist/esm/core/metafile/blit.js +1 -1
- package/dist/esm/core/metafile/emf.js +5 -7
- package/dist/esm/core/metafile/picture.js +1 -1
- package/dist/esm/core/metafile/symbol-fonts.js +7 -7
- package/dist/esm/core/metafile/wmf.js +5 -7
- package/dist/esm/core/number-format.js +4 -6
- package/dist/esm/core/numbering/index.js +3 -2
- package/dist/esm/core/ole/cfb.js +4 -4
- package/dist/esm/core/ole/escher-blip.js +1 -1
- package/dist/esm/core/opc/index.js +5 -4
- package/dist/esm/core/opc/package.js +3 -1
- package/dist/esm/core/opc/xml-entities.js +1 -1
- package/dist/esm/core/outline.js +1 -1
- package/dist/esm/core/png-encode.js +3 -3
- package/dist/esm/core/po-helpers.js +1 -1
- package/dist/esm/core/spreadsheet-model/types.d.ts +6 -0
- package/dist/esm/core/style-cascade/index.js +4 -3
- package/dist/esm/core/tiff.js +3 -1
- package/dist/esm/excel/activex-parser.js +1 -1
- package/dist/esm/excel/conditional-format.js +7 -7
- package/dist/esm/excel/formula/functions.js +8 -4
- package/dist/esm/excel/formula/index.js +3 -3
- package/dist/esm/excel/formula/lexer.js +2 -2
- package/dist/esm/excel/formula/parser.js +4 -3
- package/dist/esm/excel/formula/value.js +1 -1
- package/dist/esm/excel/index.js +7 -6
- package/dist/esm/excel/print-model.js +4 -4
- package/dist/esm/excel/printer-settings.js +6 -7
- package/dist/esm/excel/rich-value.js +1 -1
- package/dist/esm/excel/sheet-shape-parser.js +4 -2
- package/dist/esm/excel/sheet-to-flow.js +13 -11
- package/dist/esm/excel/styles-parser.js +5 -3
- package/dist/esm/excel/tint.js +5 -5
- package/dist/esm/excel/vml-drawing.js +2 -2
- package/dist/esm/excel/worksheet-parser.js +5 -5
- package/dist/esm/excel/xls/biff-chart.js +1 -3
- package/dist/esm/excel/xls/biff-reader.js +10 -11
- package/dist/esm/excel/xls/xls-reader.js +1 -1
- package/dist/esm/excel/xlsx-reader.js +17 -4
- package/dist/esm/excel/xlsx-to-pdf.js +1 -1
- package/dist/esm/excel/xlsx-writer.js +2 -2
- package/dist/esm/html/html-writer.js +18 -10
- package/dist/esm/layout/line-paint.js +1 -1
- package/dist/esm/layout/math-layout.js +5 -8
- package/dist/esm/layout/styled-layout.js +103 -31
- package/dist/esm/layout/turned-section.js +2 -2
- package/dist/esm/markdown/markdown-writer.js +1 -1
- package/dist/esm/pdf/encryption.js +9 -9
- package/dist/esm/pdf/icc-profile.js +2 -2
- package/dist/esm/pdf/index.js +3 -2
- package/dist/esm/pdf/objects.js +7 -0
- package/dist/esm/pdf/serialize.js +1 -1
- package/dist/esm/pdf/struct-tree.js +3 -1
- package/dist/esm/pdf/styled-page-emitter.js +23 -15
- package/dist/esm/pdf/styled-page-renderer.js +9 -5
- package/dist/esm/pdf-reader/annot-draw.js +3 -3
- package/dist/esm/pdf-reader/ccitt.js +2 -1
- package/dist/esm/pdf-reader/cff-outline.js +1 -4
- package/dist/esm/pdf-reader/content.js +13 -15
- package/dist/esm/pdf-reader/decrypt.js +5 -4
- package/dist/esm/pdf-reader/document.js +6 -2
- package/dist/esm/pdf-reader/encodings.js +1 -1
- package/dist/esm/pdf-reader/flow-build.js +4 -6
- package/dist/esm/pdf-reader/font.js +3 -3
- package/dist/esm/pdf-reader/function.js +8 -7
- package/dist/esm/pdf-reader/icc.js +1 -1
- package/dist/esm/pdf-reader/images.js +1 -1
- package/dist/esm/pdf-reader/jbig2.js +36 -38
- package/dist/esm/pdf-reader/jpeg.js +14 -13
- package/dist/esm/pdf-reader/layout.js +12 -9
- package/dist/esm/pdf-reader/lexer.js +2 -1
- package/dist/esm/pdf-reader/math-rows.js +2 -2
- package/dist/esm/pdf-reader/optional-content.js +1 -1
- package/dist/esm/pdf-reader/page-numbers.js +1 -1
- package/dist/esm/pdf-reader/pattern-tint.js +1 -2
- package/dist/esm/pdf-reader/reader.js +2 -2
- package/dist/esm/pdf-reader/struct-tree.js +1 -1
- package/dist/esm/pdf-reader/tagged.js +3 -2
- package/dist/esm/pdf-reader/text.js +2 -2
- package/dist/esm/pdf-reader/type1-outline.js +1 -3
- package/dist/esm/pptx/embedded-fonts.js +3 -5
- package/dist/esm/pptx/placeholder-cascade.js +1 -1
- package/dist/esm/pptx/ppt/ppt-reader.js +5 -4
- package/dist/esm/pptx/ppt/ppt-text.js +9 -10
- package/dist/esm/pptx/pptx-reader.js +6 -5
- package/dist/esm/pptx/preset-table-styles.js +1 -1
- package/dist/esm/pptx/slide-parser.js +6 -4
- package/dist/esm/pptx/sp-helpers.js +1 -1
- package/dist/esm/pptx/table-style.js +2 -1
- package/dist/esm/svg/svg-writer.js +1 -1
- package/dist/esm/word/doc/doc-reader.js +2 -2
- package/dist/esm/word/doc/doc-text.js +20 -22
- package/dist/esm/word/document-parser.js +26 -21
- package/dist/esm/word/docx-reader.js +2 -2
- package/dist/esm/word/docx-to-pdf.js +3 -3
- package/dist/esm/word/docx-writer.js +10 -6
- package/dist/esm/word/drawing-parser.js +18 -18
- package/dist/esm/word/font-table.js +1 -1
- package/dist/esm/word/index.js +6 -5
- package/dist/esm/word/numbering-parser.js +4 -3
- package/dist/esm/word/omml-parser.js +1 -1
- package/dist/esm/word/paragraph-properties.js +11 -10
- package/dist/esm/word/run-properties.js +4 -4
- package/dist/esm/word/settings-parser.js +2 -1
- package/dist/esm/word/shading.js +1 -1
- package/dist/esm/word/styles-parser.js +5 -4
- package/dist/esm/word/table-parser.js +4 -4
- package/dist/esm/word/theme-fonts.js +1 -1
- package/package.json +8 -2
|
@@ -56,9 +56,7 @@ function parseBiffChart(records, cells, sharedStrings) {
|
|
|
56
56
|
}
|
|
57
57
|
break;
|
|
58
58
|
}
|
|
59
|
-
case REC_SERIESTEXT:
|
|
60
|
-
if (current) current.nameText = parseSeriesText(rec.data);
|
|
61
|
-
break;
|
|
59
|
+
case REC_SERIESTEXT: if (current) current.nameText = parseSeriesText(rec.data);
|
|
62
60
|
}
|
|
63
61
|
if (accs.length === 0) return void 0;
|
|
64
62
|
const byKey = /* @__PURE__ */ new Map();
|
|
@@ -541,9 +541,7 @@ function parsePrintModel(records) {
|
|
|
541
541
|
case REC.HPAGEBREAK:
|
|
542
542
|
rowBreaks = parseBreaks(d);
|
|
543
543
|
break;
|
|
544
|
-
case REC.VPAGEBREAK:
|
|
545
|
-
colBreaks = parseBreaks(d);
|
|
546
|
-
break;
|
|
544
|
+
case REC.VPAGEBREAK: colBreaks = parseBreaks(d);
|
|
547
545
|
}
|
|
548
546
|
}
|
|
549
547
|
const pageSetup = {
|
|
@@ -586,7 +584,7 @@ function parseBreaks(d) {
|
|
|
586
584
|
for (let k = 0; k < count && 2 + k * 6 + 2 <= d.length; k++) out.push(readU16(d, 2 + k * 6));
|
|
587
585
|
return out;
|
|
588
586
|
}
|
|
589
|
-
var BUILTIN_NAMES = new Map([[6, "_xlnm.Print_Area"], [7, "_xlnm.Print_Titles"]]);
|
|
587
|
+
var BUILTIN_NAMES = /* @__PURE__ */ new Map([[6, "_xlnm.Print_Area"], [7, "_xlnm.Print_Titles"]]);
|
|
590
588
|
function buildDefinedNames(lblRecords, boundSheets) {
|
|
591
589
|
const wsIndex = [];
|
|
592
590
|
let ws = 0;
|
|
@@ -722,7 +720,7 @@ var DV_OPERATORS = [
|
|
|
722
720
|
"greaterThanOrEqual",
|
|
723
721
|
"lessThanOrEqual"
|
|
724
722
|
];
|
|
725
|
-
var DV_OPERATOR_TYPES = new Set([
|
|
723
|
+
var DV_OPERATOR_TYPES = /* @__PURE__ */ new Set([
|
|
726
724
|
"whole",
|
|
727
725
|
"decimal",
|
|
728
726
|
"date",
|
|
@@ -1080,7 +1078,7 @@ function readIconSet(c, priority) {
|
|
|
1080
1078
|
};
|
|
1081
1079
|
}
|
|
1082
1080
|
function parseCf12Rule(d, color) {
|
|
1083
|
-
if (d.length <
|
|
1081
|
+
if (d.length < 28) return void 0;
|
|
1084
1082
|
const c = {
|
|
1085
1083
|
d,
|
|
1086
1084
|
p: FTR_HEADER
|
|
@@ -1109,12 +1107,12 @@ function parseConditionalFormats12(records, color) {
|
|
|
1109
1107
|
for (let i = 0; i < records.length; i++) {
|
|
1110
1108
|
if (records[i].type !== REC.CONDFMT12) continue;
|
|
1111
1109
|
const head = records[i].data;
|
|
1112
|
-
if (head.length <
|
|
1110
|
+
if (head.length < 26) continue;
|
|
1113
1111
|
const numcf = readU16(head, FTR_HEADER);
|
|
1114
|
-
const cref = readU16(head,
|
|
1112
|
+
const cref = readU16(head, 24);
|
|
1115
1113
|
const ranges = [];
|
|
1116
|
-
for (let k = 0; k < cref &&
|
|
1117
|
-
const o =
|
|
1114
|
+
for (let k = 0; k < cref && 26 + k * 8 + 8 <= head.length; k++) {
|
|
1115
|
+
const o = 26 + k * 8;
|
|
1118
1116
|
ranges.push({
|
|
1119
1117
|
startRow: readU16(head, o),
|
|
1120
1118
|
endRow: readU16(head, o + 2),
|
|
@@ -1414,6 +1412,7 @@ function readSst(blocks) {
|
|
|
1414
1412
|
* each crossing re-reads the `fHighByte` flag.
|
|
1415
1413
|
*/
|
|
1416
1414
|
var SstReader = class {
|
|
1415
|
+
blocks;
|
|
1417
1416
|
bi = 0;
|
|
1418
1417
|
off = 0;
|
|
1419
1418
|
/** @param blocks The SST record's data followed by each CONTINUE record's data. */
|
|
@@ -1502,4 +1501,4 @@ function readF64(d, off) {
|
|
|
1502
1501
|
return new DataView(d.buffer, d.byteOffset + off, 8).getFloat64(0, true);
|
|
1503
1502
|
}
|
|
1504
1503
|
//#endregion
|
|
1505
|
-
export { readXlsToSheetDoc };
|
|
1504
|
+
export { decodeRk, readSst, readXlsToSheetDoc };
|
|
@@ -25,7 +25,7 @@ var XLS_LOSSES = [{
|
|
|
25
25
|
var xlsReader = {
|
|
26
26
|
id: "xls",
|
|
27
27
|
produces: "sheet",
|
|
28
|
-
supports: new Set([FEATURES.text, FEATURES.tables]),
|
|
28
|
+
supports: /* @__PURE__ */ new Set([FEATURES.text, FEATURES.tables]),
|
|
29
29
|
sniff: looksLikeXls,
|
|
30
30
|
read: (bytes) => ({
|
|
31
31
|
doc: readXlsToSheetDoc(bytes),
|
|
@@ -3,9 +3,9 @@ import { FEATURES } from "../core/ir/features.js";
|
|
|
3
3
|
import { detectImageFormat } from "../core/images.js";
|
|
4
4
|
import { INDEXED_COLORS } from "../core/indexed-colors.js";
|
|
5
5
|
import { bytesInclude, packageHasPart } from "../core/bytes.js";
|
|
6
|
+
import { parseTheme, parseThemeEffectStyles, parseThemeFillStyles, parseThemeFonts, parseThemeLineWidths } from "../core/drawingml/theme-parser.js";
|
|
6
7
|
import { OFFICE_2023_THEME_PALETTE, makeColorResolver } from "../core/drawingml/colors.js";
|
|
7
8
|
import { parseChart, pointsPerSeries, withChartColorStyle } from "../core/drawingml/chart-parser.js";
|
|
8
|
-
import { parseTheme, parseThemeEffectStyles, parseThemeFillStyles, parseThemeLineWidths } from "../core/drawingml/theme-parser.js";
|
|
9
9
|
import { isOoxmlRel } from "../core/opc/relationship-types.js";
|
|
10
10
|
import { OpcPackage } from "../core/opc/package.js";
|
|
11
11
|
import { parseCoreProperties } from "../core/opc/core-properties.js";
|
|
@@ -109,6 +109,12 @@ function readXlsxToSheetDoc(xlsx) {
|
|
|
109
109
|
const themeLineWidths = buildThemeLineWidths(pkg, workbookRels);
|
|
110
110
|
const themeFillStyles = buildThemeFillStyles(pkg, workbookRels);
|
|
111
111
|
const themeEffectStyles = buildThemeEffectStyles(pkg, workbookRels);
|
|
112
|
+
const themeFonts = buildThemeFonts(pkg, workbookRels);
|
|
113
|
+
const normalFont = styles.fonts[0];
|
|
114
|
+
const chartText = themeFonts ? {
|
|
115
|
+
themeFonts,
|
|
116
|
+
...themeFonts.minor.latin ? { family: themeFonts.minor.latin } : {}
|
|
117
|
+
} : { family: normalFont?.name?.trim().toLowerCase() === "calibri" && normalFont.scheme === void 0 ? "Calibri" : "Aptos Narrow" };
|
|
112
118
|
const sheetsOut = [];
|
|
113
119
|
let embeddedObjects = 0;
|
|
114
120
|
let metafilePictures = 0;
|
|
@@ -142,7 +148,7 @@ function readXlsxToSheetDoc(xlsx) {
|
|
|
142
148
|
for (const ref of chartRefs) {
|
|
143
149
|
if (!chartData.has(ref.chartPartPath)) {
|
|
144
150
|
const chartXml = pkg.getPart(ref.chartPartPath);
|
|
145
|
-
const parsed = chartXml ? parseChart(chartXml, resolveColor) : null;
|
|
151
|
+
const parsed = chartXml ? parseChart(chartXml, resolveColor, void 0, chartText) : null;
|
|
146
152
|
if (!parsed) continue;
|
|
147
153
|
chartData.set(ref.chartPartPath, withChartColorStyle(parsed, pkg, ref.chartPartPath, resolveColor));
|
|
148
154
|
}
|
|
@@ -721,6 +727,13 @@ function buildThemePalette(pkg, workbookRels) {
|
|
|
721
727
|
}
|
|
722
728
|
return palette;
|
|
723
729
|
}
|
|
730
|
+
function buildThemeFonts(pkg, workbookRels) {
|
|
731
|
+
for (const rel of workbookRels) {
|
|
732
|
+
if (!isOoxmlRel(rel.type, "theme")) continue;
|
|
733
|
+
const resolved = pkg.resolveRelatedPart(WORKBOOK_PART, rel);
|
|
734
|
+
if (resolved) return parseThemeFonts(resolved.data);
|
|
735
|
+
}
|
|
736
|
+
}
|
|
724
737
|
function buildThemeLineWidths(pkg, workbookRels) {
|
|
725
738
|
for (const rel of workbookRels) {
|
|
726
739
|
if (!isOoxmlRel(rel.type, "theme")) continue;
|
|
@@ -874,7 +887,7 @@ function lighten(hex, amount) {
|
|
|
874
887
|
var xlsxReader = {
|
|
875
888
|
id: "xlsx",
|
|
876
889
|
produces: "sheet",
|
|
877
|
-
supports: new Set([FEATURES.text, FEATURES.tables]),
|
|
890
|
+
supports: /* @__PURE__ */ new Set([FEATURES.text, FEATURES.tables]),
|
|
878
891
|
sniff: (bytes) => bytes[0] === 80 && bytes[1] === 75 && packageHasPart(bytes, "xl/workbook.xml"),
|
|
879
892
|
read: (bytes) => ({
|
|
880
893
|
doc: readXlsxToSheetDoc(bytes),
|
|
@@ -893,4 +906,4 @@ function infoFromCore(core) {
|
|
|
893
906
|
};
|
|
894
907
|
}
|
|
895
908
|
//#endregion
|
|
896
|
-
export { readXlsx, xlsxReader };
|
|
909
|
+
export { readXlsx, readXlsxToSheetDoc, xlsxReader };
|
|
@@ -129,7 +129,7 @@ function writeXlsx(sheet) {
|
|
|
129
129
|
losses
|
|
130
130
|
};
|
|
131
131
|
}
|
|
132
|
-
|
|
132
|
+
FEATURES.text, FEATURES.tables;
|
|
133
133
|
function rel(id, type, target) {
|
|
134
134
|
return {
|
|
135
135
|
id,
|
|
@@ -206,7 +206,7 @@ function worksheetXml(grid, tableRelIds = [], drawingRelId) {
|
|
|
206
206
|
}
|
|
207
207
|
row.push(cell);
|
|
208
208
|
}
|
|
209
|
-
const rowsXml = [
|
|
209
|
+
const rowsXml = [.../* @__PURE__ */ new Set([...cellsByRow.keys(), ...heightByRow.keys()])].sort((a, b) => a - b).map((r) => {
|
|
210
210
|
const cells = (cellsByRow.get(r) ?? []).slice().sort((a, b) => a.column - b.column);
|
|
211
211
|
const h = heightByRow.get(r);
|
|
212
212
|
const heightAttrs = h ? ` ht="${h.heightPt}"${h.customHeight ? " customHeight=\"1\"" : ""}` : "";
|
|
@@ -75,7 +75,7 @@ function writeHtml(flow) {
|
|
|
75
75
|
var htmlWriter = {
|
|
76
76
|
id: "html",
|
|
77
77
|
consumes: "flow",
|
|
78
|
-
supports: new Set([
|
|
78
|
+
supports: /* @__PURE__ */ new Set([
|
|
79
79
|
FEATURES.text,
|
|
80
80
|
FEATURES.tables,
|
|
81
81
|
FEATURES.tablesNested,
|
|
@@ -320,6 +320,10 @@ function emitChartBlock(out, block, ctx) {
|
|
|
320
320
|
}
|
|
321
321
|
const svg = [figure, svgOpen(w, h, label)];
|
|
322
322
|
svg.push(`<g transform="matrix(1 0 0 -1 0 ${fmt(h)})">`);
|
|
323
|
+
if (scene.background) svg.push(rectSvg(scene.background));
|
|
324
|
+
if (scene.plotBackground) svg.push(rectSvg(scene.plotBackground));
|
|
325
|
+
for (const w of scene.walls ?? []) svg.push(polygonSvg(w));
|
|
326
|
+
for (const g of scene.gridlines ?? []) svg.push(polylineSvg(g));
|
|
323
327
|
for (const pg of scene.polygons ?? []) svg.push(polygonSvg(pg));
|
|
324
328
|
for (const r of scene.rects) svg.push(rectSvg(r));
|
|
325
329
|
for (const pl of scene.polylines) svg.push(polylineSvg(pl));
|
|
@@ -345,7 +349,8 @@ function polylineSvg(p) {
|
|
|
345
349
|
}
|
|
346
350
|
function polygonSvg(p) {
|
|
347
351
|
const stroke = p.strokeHex ? ` stroke="#${p.strokeHex}" stroke-width="${fmt(p.widthPt ?? 1)}"` : "";
|
|
348
|
-
|
|
352
|
+
const fill = p.fillHex ? `#${p.fillHex}` : "none";
|
|
353
|
+
return `<polygon points="${pointsAttr(p.points)}" fill="${fill}"${stroke}/>`;
|
|
349
354
|
}
|
|
350
355
|
function wedgeSvg(w) {
|
|
351
356
|
const start = arcPoint(w.cx, w.cy, w.r, w.r, w.startRad);
|
|
@@ -355,7 +360,10 @@ function wedgeSvg(w) {
|
|
|
355
360
|
}
|
|
356
361
|
function labelSvg(l, sceneH, anchor) {
|
|
357
362
|
const rot = l.rotationDeg ? ` transform="rotate(${fmt(-l.rotationDeg)} ${fmt(l.x)} ${fmt(sceneH - l.y)})"` : "";
|
|
358
|
-
|
|
363
|
+
const family = l.family ? escapeAttr(fontStack(l.family)) : "sans-serif";
|
|
364
|
+
const weight = l.bold ? " font-weight=\"bold\"" : "";
|
|
365
|
+
const slant = l.italic ? " font-style=\"italic\"" : "";
|
|
366
|
+
return `<text x="${fmt(l.x)}" y="${fmt(sceneH - l.y)}"${rot} font-size="${fmt(l.sizePt)}" font-family="${family}"${weight}${slant} fill="#${l.colorHex}" text-anchor="${anchor}">${escapeText(l.text)}</text>`;
|
|
359
367
|
}
|
|
360
368
|
/** `RRGGBB` as the `r,g,b` triple a CSS `rgba()` takes. */
|
|
361
369
|
function hexToRgbCss(hex) {
|
|
@@ -430,8 +438,10 @@ function paragraphCss(r) {
|
|
|
430
438
|
if (indentLeft !== 0) css.push(`margin-left:${fmt(indentLeft)}pt`);
|
|
431
439
|
if (indentRight !== 0) css.push(`margin-right:${fmt(indentRight)}pt`);
|
|
432
440
|
if (r.indentFirstLine !== 0) css.push(`text-indent:${fmt(r.indentFirstLine)}pt`);
|
|
433
|
-
if (r.spacingLine > 0)
|
|
434
|
-
|
|
441
|
+
if (r.spacingLine > 0) {
|
|
442
|
+
if (r.spacingLineRule === "auto") css.push(`line-height:${fmt(r.spacingLine / 12)}`);
|
|
443
|
+
else css.push(`line-height:${fmt(r.spacingLine)}pt`);
|
|
444
|
+
}
|
|
435
445
|
if (r.pageBreakBefore) css.push("break-before:page");
|
|
436
446
|
return css.join(";");
|
|
437
447
|
}
|
|
@@ -776,9 +786,7 @@ function cellIconSvg(icon) {
|
|
|
776
786
|
case "pie":
|
|
777
787
|
body = pieIconSvg(icon.fill, fill, `#${ICON_EMPTY_HEX}`);
|
|
778
788
|
break;
|
|
779
|
-
case "circle":
|
|
780
|
-
body = `<circle cx="5" cy="5" r="4" fill="${fill}"/>`;
|
|
781
|
-
break;
|
|
789
|
+
case "circle": body = `<circle cx="5" cy="5" r="4" fill="${fill}"/>`;
|
|
782
790
|
}
|
|
783
791
|
return `<svg width="10" height="10" viewBox="0 0 10 10" style="float:left;margin:2px 3px 0 0">${body}</svg>`;
|
|
784
792
|
}
|
|
@@ -786,7 +794,7 @@ var round2 = (n) => (Math.round(n * 100) / 100).toString();
|
|
|
786
794
|
function barsIconSvg(fill, color, empty) {
|
|
787
795
|
const n = Math.max(1, fill?.levels ?? 4);
|
|
788
796
|
const filled = fill?.filled ?? 0;
|
|
789
|
-
const gap =
|
|
797
|
+
const gap = 1.2;
|
|
790
798
|
const bw = (10 - gap * (n - 1)) / n;
|
|
791
799
|
let out = "";
|
|
792
800
|
for (let i = 0; i < n; i++) {
|
|
@@ -809,7 +817,7 @@ function pieIconSvg(fill, color, empty) {
|
|
|
809
817
|
const ex = cx + r * Math.cos(ang);
|
|
810
818
|
const ey = cy + r * Math.sin(ang);
|
|
811
819
|
const large = frac > .5 ? 1 : 0;
|
|
812
|
-
out += `<path d="M${cx} ${cy} L${cx} ${round2(
|
|
820
|
+
out += `<path d="M${cx} ${cy} L${cx} ${round2(.5999999999999996)} A${r} ${r} 0 ${large} 1 ${round2(ex)} ${round2(ey)} Z" fill="${color}"/>`;
|
|
813
821
|
}
|
|
814
822
|
return out;
|
|
815
823
|
}
|
|
@@ -8,7 +8,7 @@ var FAUX_ITALIC_SHEAR = .2126;
|
|
|
8
8
|
* §18.18.3 — the dash pattern of a rule that is not solid, in points: dashes
|
|
9
9
|
* and gaps alternating, from a dash.
|
|
10
10
|
*/
|
|
11
|
-
var BORDER_DASHES = new Map([
|
|
11
|
+
var BORDER_DASHES = /* @__PURE__ */ new Map([
|
|
12
12
|
["dashed", [8, 2.5]],
|
|
13
13
|
["dashSmallGap", [3, 1]],
|
|
14
14
|
["dotted", [.5, 1]],
|
|
@@ -58,7 +58,7 @@ var emptyBox = () => ({
|
|
|
58
58
|
descent: 0,
|
|
59
59
|
items: []
|
|
60
60
|
});
|
|
61
|
-
var MATH_BINARY = new Set([
|
|
61
|
+
var MATH_BINARY = /* @__PURE__ */ new Set([
|
|
62
62
|
"+",
|
|
63
63
|
"−",
|
|
64
64
|
"-",
|
|
@@ -72,7 +72,7 @@ var MATH_BINARY = new Set([
|
|
|
72
72
|
"⊗",
|
|
73
73
|
"∘"
|
|
74
74
|
]);
|
|
75
|
-
var MATH_RELATION = new Set([
|
|
75
|
+
var MATH_RELATION = /* @__PURE__ */ new Set([
|
|
76
76
|
"=",
|
|
77
77
|
"≠",
|
|
78
78
|
"<",
|
|
@@ -281,7 +281,7 @@ function layoutRadical(node, ctx, measure) {
|
|
|
281
281
|
};
|
|
282
282
|
}
|
|
283
283
|
var NARY_AXIS = .28;
|
|
284
|
-
var SUM_LIKE = new Set([
|
|
284
|
+
var SUM_LIKE = /* @__PURE__ */ new Set([
|
|
285
285
|
"∑",
|
|
286
286
|
"∏",
|
|
287
287
|
"∐",
|
|
@@ -1143,14 +1143,11 @@ function mathGlyphSegments(node) {
|
|
|
1143
1143
|
break;
|
|
1144
1144
|
case "accent":
|
|
1145
1145
|
case "bar":
|
|
1146
|
-
case "groupChr":
|
|
1147
|
-
visit(n.base);
|
|
1148
|
-
break;
|
|
1149
|
-
default: break;
|
|
1146
|
+
case "groupChr": visit(n.base);
|
|
1150
1147
|
}
|
|
1151
1148
|
};
|
|
1152
1149
|
visit(node);
|
|
1153
1150
|
return out;
|
|
1154
1151
|
}
|
|
1155
1152
|
//#endregion
|
|
1156
|
-
export { layoutMath, mathGlyphSegments, variantStyle };
|
|
1153
|
+
export { layoutMath, mathGlyphSegments, shiftItems, variantStyle };
|
|
@@ -98,7 +98,7 @@ var WORD_LINE_METRICS = (() => {
|
|
|
98
98
|
0,
|
|
99
99
|
432
|
|
100
100
|
];
|
|
101
|
-
return new Map([
|
|
101
|
+
return /* @__PURE__ */ new Map([
|
|
102
102
|
["calibri", [
|
|
103
103
|
1950,
|
|
104
104
|
0,
|
|
@@ -670,7 +670,7 @@ function layoutStyledDocument(body, options) {
|
|
|
670
670
|
const commentNums = noteAssigned.comments;
|
|
671
671
|
const threadDepth = (id) => {
|
|
672
672
|
let depth = 0;
|
|
673
|
-
const seen = new Set([id]);
|
|
673
|
+
const seen = /* @__PURE__ */ new Set([id]);
|
|
674
674
|
let cur = options.comments?.get(id)?.parentId;
|
|
675
675
|
while (cur !== void 0 && commentNums.has(cur) && !seen.has(cur)) {
|
|
676
676
|
depth++;
|
|
@@ -926,6 +926,7 @@ function balancedColumnHeight(bandHeightPt, colCount, roomPt) {
|
|
|
926
926
|
* between takes its share of both sides. Elsewhere the two add up.
|
|
927
927
|
*/
|
|
928
928
|
var SpacingStack = class {
|
|
929
|
+
collapse;
|
|
929
930
|
/** The space after the last block, which a paragraph right below may share. */
|
|
930
931
|
shared = 0;
|
|
931
932
|
constructor(collapse) {
|
|
@@ -1822,7 +1823,7 @@ function metafileDrawing(pic, widthPt, heightPt, options, fontResources, colorCh
|
|
|
1822
1823
|
seq++;
|
|
1823
1824
|
continue;
|
|
1824
1825
|
}
|
|
1825
|
-
const line = makeChartLabelLine(prim.text, font, sizePt, textHex ?? prim.colorHex);
|
|
1826
|
+
const line = makeChartLabelLine(prim.text, { font }, sizePt, textHex ?? prim.colorHex);
|
|
1826
1827
|
const shift = prim.alignH === "center" ? -line.contentWidthPt / 2 : prim.alignH === "right" ? -line.contentWidthPt : 0;
|
|
1827
1828
|
const baselineY = mapY(prim.y) - (prim.alignBaseline ? 0 : sizePt * .8);
|
|
1828
1829
|
texts.push({
|
|
@@ -1854,8 +1855,8 @@ function layoutChartBlock(block, options, fontResources, contentWidth, maxHeight
|
|
|
1854
1855
|
}
|
|
1855
1856
|
const chart = options.charts?.get(block.chartRelId);
|
|
1856
1857
|
const { variant } = options.registry.resolveByStyle(false, false);
|
|
1857
|
-
const
|
|
1858
|
-
const layout = chart &&
|
|
1858
|
+
const faceFor = chart ? chartFaceResolver(options, fontResources, fontResources.get(variant)) : void 0;
|
|
1859
|
+
const layout = chart && faceFor ? buildChartLayout(chart, widthPt, heightPt, faceFor) : {
|
|
1859
1860
|
shapes: [],
|
|
1860
1861
|
texts: []
|
|
1861
1862
|
};
|
|
@@ -1882,8 +1883,54 @@ function layoutChartBlock(block, options, fontResources, contentWidth, maxHeight
|
|
|
1882
1883
|
...block.float ? { float: block.float } : {}
|
|
1883
1884
|
};
|
|
1884
1885
|
}
|
|
1885
|
-
|
|
1886
|
-
|
|
1886
|
+
/**
|
|
1887
|
+
* Where a chart's text finds its face: the family and weight the chart sets it
|
|
1888
|
+
* in, resolved as a run's are (runFontKeyAndParsed), and the document's base
|
|
1889
|
+
* face for text that names none — which is all of a chart's text unless its
|
|
1890
|
+
* reader resolved the chart's own (Chart.text).
|
|
1891
|
+
*/
|
|
1892
|
+
function chartFaceResolver(options, fontResources, base) {
|
|
1893
|
+
const fallback = base ?? fontResources.values().next().value;
|
|
1894
|
+
if (!fallback) return void 0;
|
|
1895
|
+
return (font) => {
|
|
1896
|
+
if (!font || font.family === void 0 && !font.bold && !font.italic) return { font: fallback };
|
|
1897
|
+
const { fontKey, synthetic } = runFontKeyAndParsed(options, font.family, font.bold === true, font.italic === true);
|
|
1898
|
+
const resource = fontResources.get(fontKey);
|
|
1899
|
+
return resource ? {
|
|
1900
|
+
font: resource,
|
|
1901
|
+
...synthetic ? { synthetic } : {}
|
|
1902
|
+
} : { font: fallback };
|
|
1903
|
+
};
|
|
1904
|
+
}
|
|
1905
|
+
/**
|
|
1906
|
+
* The faces a chart's text is drawn in, one per distinct family and weight;
|
|
1907
|
+
* `undefined` stands for the document's base face, which text naming none is
|
|
1908
|
+
* drawn in.
|
|
1909
|
+
*/
|
|
1910
|
+
function chartFonts(chart) {
|
|
1911
|
+
if (!chart.text) return [void 0];
|
|
1912
|
+
const seen = /* @__PURE__ */ new Map();
|
|
1913
|
+
let base = false;
|
|
1914
|
+
for (const style of Object.values(chart.text)) {
|
|
1915
|
+
if (!style) continue;
|
|
1916
|
+
if (style.family === void 0 && !style.bold && !style.italic) {
|
|
1917
|
+
base = true;
|
|
1918
|
+
continue;
|
|
1919
|
+
}
|
|
1920
|
+
const font = {
|
|
1921
|
+
...style.family !== void 0 ? { family: style.family } : {},
|
|
1922
|
+
...style.bold ? { bold: true } : {},
|
|
1923
|
+
...style.italic ? { italic: true } : {}
|
|
1924
|
+
};
|
|
1925
|
+
seen.set(`${font.family ?? ""}|${font.bold === true}|${font.italic === true}`, font);
|
|
1926
|
+
}
|
|
1927
|
+
return base ? [void 0, ...seen.values()] : [...seen.values()];
|
|
1928
|
+
}
|
|
1929
|
+
function buildChartLayout(chart, widthPt, heightPt, faceFor) {
|
|
1930
|
+
const measure = (text, sizePt, font) => {
|
|
1931
|
+
const face = faceFor(font);
|
|
1932
|
+
return face.font.measure.textWidthPt(text, sizePt) * (face.synthetic?.widthScale ?? 1);
|
|
1933
|
+
};
|
|
1887
1934
|
const scene = buildChartScene(chart, widthPt, heightPt, measure);
|
|
1888
1935
|
if (!scene) return {
|
|
1889
1936
|
shapes: [{
|
|
@@ -1898,6 +1945,7 @@ function buildChartLayout(chart, widthPt, heightPt, font) {
|
|
|
1898
1945
|
const shapes = [];
|
|
1899
1946
|
if (scene.background) shapes.push(rectPrim(scene.background));
|
|
1900
1947
|
if (scene.plotBackground) shapes.push(rectPrim(scene.plotBackground));
|
|
1948
|
+
for (const w of scene.walls ?? []) shapes.push(polygonPrim(w));
|
|
1901
1949
|
for (const g of scene.gridlines ?? []) shapes.push(polylinePrim(g));
|
|
1902
1950
|
for (const pg of scene.polygons ?? []) shapes.push(polygonPrim(pg));
|
|
1903
1951
|
for (const r of scene.rects) shapes.push(rectPrim(r));
|
|
@@ -1905,7 +1953,7 @@ function buildChartLayout(chart, widthPt, heightPt, font) {
|
|
|
1905
1953
|
for (const w of scene.wedges) shapes.push(wedgePrim(w));
|
|
1906
1954
|
return {
|
|
1907
1955
|
shapes,
|
|
1908
|
-
texts: scene.labels.map((l) => labelPrim(l,
|
|
1956
|
+
texts: scene.labels.map((l) => labelPrim(l, faceFor(l)))
|
|
1909
1957
|
};
|
|
1910
1958
|
}
|
|
1911
1959
|
function rectAtPath(x, y, w, h) {
|
|
@@ -2061,7 +2109,7 @@ function polygonPrim(p) {
|
|
|
2061
2109
|
b.close();
|
|
2062
2110
|
return {
|
|
2063
2111
|
paths: [b.build()],
|
|
2064
|
-
fillColorHex: p.fillHex,
|
|
2112
|
+
...p.fillHex ? { fillColorHex: p.fillHex } : {},
|
|
2065
2113
|
...p.strokeHex ? { stroke: {
|
|
2066
2114
|
colorHex: p.strokeHex,
|
|
2067
2115
|
widthPt: p.widthPt ?? 1
|
|
@@ -2079,8 +2127,8 @@ function wedgePrim(w) {
|
|
|
2079
2127
|
} } : {}
|
|
2080
2128
|
};
|
|
2081
2129
|
}
|
|
2082
|
-
function labelPrim(l,
|
|
2083
|
-
const line = makeChartLabelLine(l.text,
|
|
2130
|
+
function labelPrim(l, face) {
|
|
2131
|
+
const line = makeChartLabelLine(l.text, face, l.sizePt, l.colorHex);
|
|
2084
2132
|
const w = line.contentWidthPt;
|
|
2085
2133
|
const shift = l.align === "center" ? -w / 2 : l.align === "right" ? -w : 0;
|
|
2086
2134
|
if (l.rotationDeg) return {
|
|
@@ -2095,8 +2143,9 @@ function labelPrim(l, font) {
|
|
|
2095
2143
|
y: l.y
|
|
2096
2144
|
};
|
|
2097
2145
|
}
|
|
2098
|
-
function makeChartLabelLine(text,
|
|
2099
|
-
const
|
|
2146
|
+
function makeChartLabelLine(text, face, sizePt, colorHex) {
|
|
2147
|
+
const { font, synthetic } = face;
|
|
2148
|
+
const widthPt = font.measure.textWidthPt(text, sizePt) * (synthetic?.widthScale ?? 1);
|
|
2100
2149
|
return {
|
|
2101
2150
|
tokens: [{
|
|
2102
2151
|
kind: "text",
|
|
@@ -2110,7 +2159,8 @@ function makeChartLabelLine(text, font, sizePt, colorHex) {
|
|
|
2110
2159
|
font,
|
|
2111
2160
|
fontSizePt: sizePt,
|
|
2112
2161
|
widthPt,
|
|
2113
|
-
bidiLevel: 0
|
|
2162
|
+
bidiLevel: 0,
|
|
2163
|
+
...synthetic ? { synthetic } : {}
|
|
2114
2164
|
}],
|
|
2115
2165
|
contentWidthPt: widthPt,
|
|
2116
2166
|
maxFontSizePt: sizePt,
|
|
@@ -2862,7 +2912,8 @@ function runFontKeyAndParsed(options, ascii, bold, italic) {
|
|
|
2862
2912
|
function fallbackFaceKey(options, cp, bold, italic) {
|
|
2863
2913
|
const byFamily = options.registriesByFamily;
|
|
2864
2914
|
if (!byFamily || byFamily.size === 0) return void 0;
|
|
2865
|
-
const
|
|
2915
|
+
const hanFace = byFamily.has("jp") ? "jp" : byFamily.has("kr") ? "kr" : "sc";
|
|
2916
|
+
const script = scriptForCodepoint(cp, hanFace);
|
|
2866
2917
|
const order = script ? [script] : [];
|
|
2867
2918
|
for (const key of byFamily.keys()) if (key !== script) order.push(key);
|
|
2868
2919
|
for (const key of order) {
|
|
@@ -3156,17 +3207,26 @@ function collectFontResources(body, headersFooters, options, imageResources) {
|
|
|
3156
3207
|
else {
|
|
3157
3208
|
const chart = options.charts?.get(el.chart.chartRelId);
|
|
3158
3209
|
if (chart) {
|
|
3159
|
-
const
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3210
|
+
const buckets = chartFonts(chart).map((font) => {
|
|
3211
|
+
const face = font === void 0 ? (() => {
|
|
3212
|
+
const reg = options.registry.resolveByStyle(false, false);
|
|
3213
|
+
return {
|
|
3214
|
+
fontKey: reg.variant,
|
|
3215
|
+
parsed: reg.parsed
|
|
3216
|
+
};
|
|
3217
|
+
})() : runFontKeyAndParsed(options, font.family, font.bold === true, font.italic === true);
|
|
3218
|
+
let bucket = used.get(face.fontKey);
|
|
3219
|
+
if (!bucket) {
|
|
3220
|
+
bucket = {
|
|
3221
|
+
parsed: face.parsed,
|
|
3222
|
+
gids: /* @__PURE__ */ new Set()
|
|
3223
|
+
};
|
|
3224
|
+
used.set(face.fontKey, bucket);
|
|
3225
|
+
}
|
|
3226
|
+
return bucket;
|
|
3227
|
+
});
|
|
3168
3228
|
const add = (s) => {
|
|
3169
|
-
for (const ch of s) bucket.gids.add(
|
|
3229
|
+
for (const bucket of buckets) for (const ch of s) bucket.gids.add(bucket.parsed.glyphForCodepoint(ch.codePointAt(0)));
|
|
3170
3230
|
};
|
|
3171
3231
|
if (chart.title) add(chart.title);
|
|
3172
3232
|
for (const c of chart.categories) add(c);
|
|
@@ -3766,7 +3826,7 @@ function paragraphMaxWidth(p, contentWidth, firstLine) {
|
|
|
3766
3826
|
const firstLineExtra = firstLine ? p.indentFirstLine : 0;
|
|
3767
3827
|
return Math.max(1, contentWidth - indentLeft - indentRight - firstLineExtra);
|
|
3768
3828
|
}
|
|
3769
|
-
var HYPHENS = new Set([
|
|
3829
|
+
var HYPHENS = /* @__PURE__ */ new Set([
|
|
3770
3830
|
45,
|
|
3771
3831
|
8208,
|
|
3772
3832
|
8211,
|
|
@@ -3960,7 +4020,7 @@ function paragraphItemStream(tokens, hyphenator, maxLineWidthPt) {
|
|
|
3960
4020
|
}
|
|
3961
4021
|
/** Word's own default when a document names none (§17.15.1.25): half an inch. */
|
|
3962
4022
|
var DEFAULT_TAB_STOP_PT = 36;
|
|
3963
|
-
var TAB_LEADER_CHARS = new Map([
|
|
4023
|
+
var TAB_LEADER_CHARS = /* @__PURE__ */ new Map([
|
|
3964
4024
|
["dot", "."],
|
|
3965
4025
|
["hyphen", "-"],
|
|
3966
4026
|
["underscore", "_"],
|
|
@@ -5116,6 +5176,11 @@ function listItemParagraphNode(builder, stack, list, wantLbl) {
|
|
|
5116
5176
|
* bodies move unchanged.
|
|
5117
5177
|
*/
|
|
5118
5178
|
var PageAssembler = class PageAssembler {
|
|
5179
|
+
sectionCtxs;
|
|
5180
|
+
builder;
|
|
5181
|
+
notes;
|
|
5182
|
+
bookmarkPositions;
|
|
5183
|
+
backgroundImage;
|
|
5119
5184
|
/**
|
|
5120
5185
|
* @param sectionCtxs The per-section render contexts, in order; assembly
|
|
5121
5186
|
* starts on the first section's first page.
|
|
@@ -5892,6 +5957,9 @@ var PageAssembler = class PageAssembler {
|
|
|
5892
5957
|
* every page that repeats them — which is what Excel prints.
|
|
5893
5958
|
*/
|
|
5894
5959
|
var SheetView = class {
|
|
5960
|
+
overlay;
|
|
5961
|
+
tableX;
|
|
5962
|
+
builder;
|
|
5895
5963
|
runs = [];
|
|
5896
5964
|
figures = /* @__PURE__ */ new Map();
|
|
5897
5965
|
/**
|
|
@@ -6518,13 +6586,15 @@ function emitRowChunk(out, row, marginLeft, cursorY, pageHeight, colCount, cellS
|
|
|
6518
6586
|
if (cell.icon && cell.mergeRole !== "middle" && cell.mergeRole !== "end") {
|
|
6519
6587
|
const iconSize = Math.min(CF_ICON_SIZE_PT, Math.max(0, row.heightPt - 1));
|
|
6520
6588
|
if (iconSize > 0) {
|
|
6589
|
+
const iconX = cellX + (CF_ICON_GUTTER_PT - iconSize) / 2;
|
|
6590
|
+
const iconBottomYUp = rowBottom + (row.heightPt - iconSize) / 2;
|
|
6521
6591
|
const iconTransform = flipTransform([
|
|
6522
6592
|
1,
|
|
6523
6593
|
0,
|
|
6524
6594
|
0,
|
|
6525
6595
|
1,
|
|
6526
|
-
|
|
6527
|
-
|
|
6596
|
+
iconX,
|
|
6597
|
+
iconBottomYUp
|
|
6528
6598
|
], pageHeight);
|
|
6529
6599
|
for (const prim of buildCellIconShape(cell.icon, iconSize)) out.push({
|
|
6530
6600
|
type: "shape",
|
|
@@ -6540,13 +6610,15 @@ function emitRowChunk(out, row, marginLeft, cursorY, pageHeight, colCount, cellS
|
|
|
6540
6610
|
if (cell.dropdown && cell.mergeRole !== "middle" && cell.mergeRole !== "end") {
|
|
6541
6611
|
const btn = Math.min(DROPDOWN_BUTTON_PT, Math.max(0, row.heightPt - 2));
|
|
6542
6612
|
if (btn > 1) {
|
|
6613
|
+
const btnX = cellX + cell.widthPt - btn - 1.5;
|
|
6614
|
+
const btnBottomYUp = rowBottom + (row.heightPt - btn) / 2;
|
|
6543
6615
|
const btnTransform = flipTransform([
|
|
6544
6616
|
1,
|
|
6545
6617
|
0,
|
|
6546
6618
|
0,
|
|
6547
6619
|
1,
|
|
6548
|
-
|
|
6549
|
-
|
|
6620
|
+
btnX,
|
|
6621
|
+
btnBottomYUp
|
|
6550
6622
|
], pageHeight);
|
|
6551
6623
|
for (const prim of buildDropdownPrims(btn)) out.push({
|
|
6552
6624
|
type: "shape",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { pt } from "../core/ir/units.js";
|
|
2
2
|
//#region src/layout/turned-section.ts
|
|
3
3
|
/** A quarter turn in the 1/60000° a DrawingML rotation is stated in (§20.1.7.6). */
|
|
4
|
-
var QUARTER_60K =
|
|
4
|
+
var QUARTER_60K = 54e5;
|
|
5
5
|
/**
|
|
6
6
|
* One item of a turned section's body, carried from the frame the text reads
|
|
7
7
|
* in onto the sheet: a point `(x, y)` of the frame (top-left origin, y down)
|
|
@@ -161,7 +161,7 @@ function floatIntoFrame(el, sheet) {
|
|
|
161
161
|
}
|
|
162
162
|
/** A clockwise turn with a quarter taken off, kept in the one full turn. */
|
|
163
163
|
function backedOff(rotation60k) {
|
|
164
|
-
const full =
|
|
164
|
+
const full = 216e5;
|
|
165
165
|
return (((rotation60k ?? 0) - QUARTER_60K) % full + full) % full;
|
|
166
166
|
}
|
|
167
167
|
/**
|
|
@@ -82,20 +82,20 @@ async function hardHash(password, salt, userData) {
|
|
|
82
82
|
async function preparePdfEncryption(options) {
|
|
83
83
|
const user = passwordBytes(options.userPassword ?? "");
|
|
84
84
|
const owner = passwordBytes(options.ownerPassword ?? options.userPassword ?? "");
|
|
85
|
-
const fileKey = new Uint8Array(32);
|
|
85
|
+
const fileKey = /* @__PURE__ */ new Uint8Array(32);
|
|
86
86
|
globalThis.crypto.getRandomValues(fileKey);
|
|
87
|
-
const salts = new Uint8Array(36);
|
|
87
|
+
const salts = /* @__PURE__ */ new Uint8Array(36);
|
|
88
88
|
globalThis.crypto.getRandomValues(salts);
|
|
89
89
|
const uvs = salts.slice(0, 8);
|
|
90
90
|
const uks = salts.slice(8, 16);
|
|
91
91
|
const ovs = salts.slice(16, 24);
|
|
92
92
|
const oks = salts.slice(24, 32);
|
|
93
|
-
const U = concat(await hardHash(user, uvs, new Uint8Array(0)), uvs, uks);
|
|
94
|
-
const UE = await aesCbcNoPad(await hardHash(user, uks, new Uint8Array(0)), new Uint8Array(16), fileKey);
|
|
93
|
+
const U = concat(await hardHash(user, uvs, /* @__PURE__ */ new Uint8Array(0)), uvs, uks);
|
|
94
|
+
const UE = await aesCbcNoPad(await hardHash(user, uks, /* @__PURE__ */ new Uint8Array(0)), /* @__PURE__ */ new Uint8Array(16), fileKey);
|
|
95
95
|
const O = concat(await hardHash(owner, ovs, U), ovs, oks);
|
|
96
|
-
const OE = await aesCbcNoPad(await hardHash(owner, oks, U), new Uint8Array(16), fileKey);
|
|
96
|
+
const OE = await aesCbcNoPad(await hardHash(owner, oks, U), /* @__PURE__ */ new Uint8Array(16), fileKey);
|
|
97
97
|
const p = permissionBits(options.permissions);
|
|
98
|
-
const permsPlain = new Uint8Array(16);
|
|
98
|
+
const permsPlain = /* @__PURE__ */ new Uint8Array(16);
|
|
99
99
|
new DataView(permsPlain.buffer).setInt32(0, p, true);
|
|
100
100
|
permsPlain.set([
|
|
101
101
|
255,
|
|
@@ -110,7 +110,7 @@ async function preparePdfEncryption(options) {
|
|
|
110
110
|
98
|
|
111
111
|
], 8);
|
|
112
112
|
permsPlain.set(salts.slice(32, 36), 12);
|
|
113
|
-
const perms = await aesCbcNoPad(fileKey, new Uint8Array(16), permsPlain);
|
|
113
|
+
const perms = await aesCbcNoPad(fileKey, /* @__PURE__ */ new Uint8Array(16), permsPlain);
|
|
114
114
|
return {
|
|
115
115
|
fileKey,
|
|
116
116
|
encryptDict: dict({
|
|
@@ -136,7 +136,7 @@ async function preparePdfEncryption(options) {
|
|
|
136
136
|
};
|
|
137
137
|
}
|
|
138
138
|
async function encryptBytes(fileKey, data) {
|
|
139
|
-
const iv = new Uint8Array(16);
|
|
139
|
+
const iv = /* @__PURE__ */ new Uint8Array(16);
|
|
140
140
|
globalThis.crypto.getRandomValues(iv);
|
|
141
141
|
const k = await subtle.importKey("raw", fileKey, "AES-CBC", false, ["encrypt"]);
|
|
142
142
|
return concat(iv, new Uint8Array(await subtle.encrypt({
|
|
@@ -177,4 +177,4 @@ async function encryptObjectGraph(value, fileKey) {
|
|
|
177
177
|
return value;
|
|
178
178
|
}
|
|
179
179
|
//#endregion
|
|
180
|
-
export { encryptObjectGraph, preparePdfEncryption };
|
|
180
|
+
export { encryptObjectGraph, hardHash, permissionBits, preparePdfEncryption };
|