@opengeni/artifact-tool 0.2.2
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/LICENSE +190 -0
- package/README.md +104 -0
- package/dist/bounded-zip.d.ts +28 -0
- package/dist/chunk-4BSENMAE.js +39 -0
- package/dist/chunk-4BSENMAE.js.map +1 -0
- package/dist/chunk-4FRFNNBM.js +276 -0
- package/dist/chunk-4FRFNNBM.js.map +1 -0
- package/dist/chunk-5XIA6KHZ.js +49 -0
- package/dist/chunk-5XIA6KHZ.js.map +1 -0
- package/dist/chunk-66CT2ZRP.js +2229 -0
- package/dist/chunk-66CT2ZRP.js.map +1 -0
- package/dist/chunk-72SYDU4O.js +319 -0
- package/dist/chunk-72SYDU4O.js.map +1 -0
- package/dist/chunk-B2ZJRZDA.js +279 -0
- package/dist/chunk-B2ZJRZDA.js.map +1 -0
- package/dist/chunk-DCTLTNPW.js +2458 -0
- package/dist/chunk-DCTLTNPW.js.map +1 -0
- package/dist/chunk-FGZM4FQ6.js +473 -0
- package/dist/chunk-FGZM4FQ6.js.map +1 -0
- package/dist/chunk-HTJBLBDE.js +591 -0
- package/dist/chunk-HTJBLBDE.js.map +1 -0
- package/dist/chunk-IYFXZQ34.js +5306 -0
- package/dist/chunk-IYFXZQ34.js.map +1 -0
- package/dist/chunk-J6N7IR44.js +172 -0
- package/dist/chunk-J6N7IR44.js.map +1 -0
- package/dist/chunk-N2IHNWBS.js +1002 -0
- package/dist/chunk-N2IHNWBS.js.map +1 -0
- package/dist/chunk-NAG44K67.js +549 -0
- package/dist/chunk-NAG44K67.js.map +1 -0
- package/dist/chunk-O24KTEGP.js +33 -0
- package/dist/chunk-O24KTEGP.js.map +1 -0
- package/dist/chunk-PI2AZVGK.js +2074 -0
- package/dist/chunk-PI2AZVGK.js.map +1 -0
- package/dist/chunk-Q2FFHEY7.js +40 -0
- package/dist/chunk-Q2FFHEY7.js.map +1 -0
- package/dist/chunk-RBGQADXA.js +57 -0
- package/dist/chunk-RBGQADXA.js.map +1 -0
- package/dist/chunk-U5G2BKM2.js +613 -0
- package/dist/chunk-U5G2BKM2.js.map +1 -0
- package/dist/chunk-VOJHMSM3.js +39 -0
- package/dist/chunk-VOJHMSM3.js.map +1 -0
- package/dist/chunk-VUNV25KB.js +16 -0
- package/dist/chunk-VUNV25KB.js.map +1 -0
- package/dist/chunk-XIFUNVBO.js +101 -0
- package/dist/chunk-XIFUNVBO.js.map +1 -0
- package/dist/chunk-ZCJYRJGB.js +489 -0
- package/dist/chunk-ZCJYRJGB.js.map +1 -0
- package/dist/chunk-ZZXPEE4S.js +2260 -0
- package/dist/chunk-ZZXPEE4S.js.map +1 -0
- package/dist/document-docx-api.d.ts +49 -0
- package/dist/document-docx-codec.d.ts +9 -0
- package/dist/document-docx-codec.js +4765 -0
- package/dist/document-docx-codec.js.map +1 -0
- package/dist/document-docx-import.d.ts +261 -0
- package/dist/document-docx-packer.d.ts +18 -0
- package/dist/document-docx-state.d.ts +12 -0
- package/dist/document-render.d.ts +3 -0
- package/dist/document-render.js +492 -0
- package/dist/document-render.js.map +1 -0
- package/dist/document.d.ts +432 -0
- package/dist/document.js +37 -0
- package/dist/document.js.map +1 -0
- package/dist/errors.d.ts +23 -0
- package/dist/file-blob.d.ts +11 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +186 -0
- package/dist/index.js.map +1 -0
- package/dist/inspection.d.ts +12 -0
- package/dist/kernel.d.ts +101 -0
- package/dist/lib-GQLPACFK.js +9746 -0
- package/dist/lib-GQLPACFK.js.map +1 -0
- package/dist/materializer-cli-entry.d.ts +2 -0
- package/dist/materializer-cli-entry.js +29 -0
- package/dist/materializer-cli-entry.js.map +1 -0
- package/dist/materializer-cli.d.ts +24 -0
- package/dist/materializer-cli.js +24 -0
- package/dist/materializer-cli.js.map +1 -0
- package/dist/native-raster.d.ts +10 -0
- package/dist/native.d.ts +129 -0
- package/dist/native.js +31 -0
- package/dist/native.js.map +1 -0
- package/dist/office-import.d.ts +48 -0
- package/dist/office-import.js +154 -0
- package/dist/office-import.js.map +1 -0
- package/dist/presentation-pptx-api.d.ts +60 -0
- package/dist/presentation-pptx-import.d.ts +5 -0
- package/dist/presentation-pptx-state-digest-765CZZED.js +10 -0
- package/dist/presentation-pptx-state-digest-765CZZED.js.map +1 -0
- package/dist/presentation-pptx-state-digest.d.ts +3 -0
- package/dist/presentation-pptx-state.d.ts +4 -0
- package/dist/presentation-pptx-xml.d.ts +29 -0
- package/dist/presentation-pptx.d.ts +5 -0
- package/dist/presentation-pptx.js +2365 -0
- package/dist/presentation-pptx.js.map +1 -0
- package/dist/presentation-render.d.ts +29 -0
- package/dist/presentation-render.js +375 -0
- package/dist/presentation-render.js.map +1 -0
- package/dist/presentation.d.ts +565 -0
- package/dist/presentation.js +71 -0
- package/dist/presentation.js.map +1 -0
- package/dist/production-composite.d.ts +68 -0
- package/dist/production-document.d.ts +2 -0
- package/dist/production-document.js +176 -0
- package/dist/production-document.js.map +1 -0
- package/dist/production-native-codecs.d.ts +94 -0
- package/dist/production-presentation.d.ts +2 -0
- package/dist/production-presentation.js +176 -0
- package/dist/production-presentation.js.map +1 -0
- package/dist/production-sha256.d.ts +2 -0
- package/dist/production-spreadsheet-native.d.ts +12 -0
- package/dist/production-spreadsheet.d.ts +2 -0
- package/dist/production-spreadsheet.js +176 -0
- package/dist/production-spreadsheet.js.map +1 -0
- package/dist/production.d.ts +96 -0
- package/dist/raster-image.d.ts +34 -0
- package/dist/reference.d.ts +17 -0
- package/dist/reference.js +574 -0
- package/dist/reference.js.map +1 -0
- package/dist/runtime-cli-entry.d.ts +2 -0
- package/dist/runtime-cli-entry.js +21 -0
- package/dist/runtime-cli-entry.js.map +1 -0
- package/dist/runtime-cli.d.ts +76 -0
- package/dist/runtime-cli.js +26 -0
- package/dist/runtime-cli.js.map +1 -0
- package/dist/runtime-development.d.ts +73 -0
- package/dist/runtime-development.js +30 -0
- package/dist/runtime-development.js.map +1 -0
- package/dist/runtime-receipt.d.ts +19 -0
- package/dist/runtime.d.ts +355 -0
- package/dist/runtime.js +42 -0
- package/dist/runtime.js.map +1 -0
- package/dist/snapshot.d.ts +26 -0
- package/dist/snapshot.js +61 -0
- package/dist/snapshot.js.map +1 -0
- package/dist/spreadsheet-address.d.ts +18 -0
- package/dist/spreadsheet-file.d.ts +17 -0
- package/dist/spreadsheet-formula.d.ts +67 -0
- package/dist/spreadsheet-image.d.ts +17 -0
- package/dist/spreadsheet-render.d.ts +5 -0
- package/dist/spreadsheet-render.js +752 -0
- package/dist/spreadsheet-render.js.map +1 -0
- package/dist/spreadsheet-types.d.ts +155 -0
- package/dist/spreadsheet-xlsx-api.d.ts +88 -0
- package/dist/spreadsheet-xlsx-codec.d.ts +16 -0
- package/dist/spreadsheet-xlsx-codec.js +16 -0
- package/dist/spreadsheet-xlsx-codec.js.map +1 -0
- package/dist/spreadsheet-xlsx-state.d.ts +16 -0
- package/dist/spreadsheet.d.ts +724 -0
- package/dist/spreadsheet.js +67 -0
- package/dist/spreadsheet.js.map +1 -0
- package/package.json +129 -0
- package/src/bounded-zip.ts +450 -0
- package/src/document-docx-api.ts +64 -0
- package/src/document-docx-codec.ts +2253 -0
- package/src/document-docx-import.ts +3814 -0
- package/src/document-docx-packer.ts +72 -0
- package/src/document-docx-state.ts +59 -0
- package/src/document-render.ts +615 -0
- package/src/document.ts +2800 -0
- package/src/errors.ts +45 -0
- package/src/file-blob.ts +43 -0
- package/src/index.ts +4 -0
- package/src/inspection.ts +50 -0
- package/src/kernel.ts +525 -0
- package/src/materializer-cli-entry.ts +11 -0
- package/src/materializer-cli.ts +743 -0
- package/src/native-raster.ts +141 -0
- package/src/native.ts +390 -0
- package/src/office-import.ts +243 -0
- package/src/presentation-pptx-api.ts +107 -0
- package/src/presentation-pptx-import.ts +2065 -0
- package/src/presentation-pptx-state-digest.ts +46 -0
- package/src/presentation-pptx-state.ts +18 -0
- package/src/presentation-pptx-xml.ts +473 -0
- package/src/presentation-pptx.ts +447 -0
- package/src/presentation-render.ts +532 -0
- package/src/presentation.ts +2599 -0
- package/src/production-composite.ts +805 -0
- package/src/production-document.ts +2 -0
- package/src/production-native-codecs.ts +1141 -0
- package/src/production-presentation.ts +2 -0
- package/src/production-sha256.ts +150 -0
- package/src/production-spreadsheet-native.ts +686 -0
- package/src/production-spreadsheet.ts +2 -0
- package/src/production.ts +1022 -0
- package/src/raster-image.ts +586 -0
- package/src/reference.ts +17 -0
- package/src/runtime-cli-entry.ts +13 -0
- package/src/runtime-cli.ts +670 -0
- package/src/runtime-development.ts +689 -0
- package/src/runtime-receipt.ts +169 -0
- package/src/runtime.ts +1463 -0
- package/src/snapshot.ts +88 -0
- package/src/spreadsheet-address.ts +90 -0
- package/src/spreadsheet-file.ts +71 -0
- package/src/spreadsheet-formula.ts +1212 -0
- package/src/spreadsheet-image.ts +242 -0
- package/src/spreadsheet-render.ts +985 -0
- package/src/spreadsheet-types.ts +171 -0
- package/src/spreadsheet-xlsx-api.ts +123 -0
- package/src/spreadsheet-xlsx-codec.ts +3063 -0
- package/src/spreadsheet-xlsx-state.ts +191 -0
- package/src/spreadsheet.ts +5195 -0
package/src/snapshot.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import {
|
|
2
|
+
COMMITTED_TRANSACTION_PROTOCOL_VERSION,
|
|
3
|
+
EDITABLE_ARTIFACT_MODEL_SCHEMA_VERSION,
|
|
4
|
+
EDITABLE_ARTIFACT_SNAPSHOT_VERSION,
|
|
5
|
+
} from "@opengeni/contracts/editable-artifact-versions";
|
|
6
|
+
import type { Document } from "./document";
|
|
7
|
+
import {
|
|
8
|
+
NativeDocumentSession,
|
|
9
|
+
NativePresentationSession,
|
|
10
|
+
NativeSpreadsheetSession,
|
|
11
|
+
} from "./native";
|
|
12
|
+
import type { Presentation } from "./presentation";
|
|
13
|
+
import { requireCompositeState } from "./production-composite";
|
|
14
|
+
import type { Workbook } from "./spreadsheet";
|
|
15
|
+
|
|
16
|
+
type ArtifactSnapshotCommon = Readonly<{
|
|
17
|
+
schemaVersion: 1;
|
|
18
|
+
modality: "spreadsheet" | "document" | "presentation";
|
|
19
|
+
runtimeTarget: string;
|
|
20
|
+
kernelVersion: string;
|
|
21
|
+
modelSchemaVersion: 1;
|
|
22
|
+
snapshotVersion: 1;
|
|
23
|
+
stateHash: string;
|
|
24
|
+
snapshotBytes: Uint8Array;
|
|
25
|
+
}>;
|
|
26
|
+
|
|
27
|
+
/** Exact native-canonical state at one durable artifact boundary. */
|
|
28
|
+
export type ArtifactSnapshot =
|
|
29
|
+
| (ArtifactSnapshotCommon &
|
|
30
|
+
Readonly<{
|
|
31
|
+
modality: "spreadsheet";
|
|
32
|
+
coveredCausalFrontierBytes: Uint8Array;
|
|
33
|
+
operationProtocolVersion: 1;
|
|
34
|
+
crdtStateVersion: 1;
|
|
35
|
+
}>)
|
|
36
|
+
| (ArtifactSnapshotCommon &
|
|
37
|
+
Readonly<{
|
|
38
|
+
modality: "document" | "presentation";
|
|
39
|
+
nativeRevision: number;
|
|
40
|
+
}>);
|
|
41
|
+
|
|
42
|
+
/** Capture one immutable native snapshot from an open artifact object. */
|
|
43
|
+
export function createArtifactSnapshot(
|
|
44
|
+
artifact: Workbook | Document | Presentation,
|
|
45
|
+
): ArtifactSnapshot {
|
|
46
|
+
const state = requireCompositeState(artifact);
|
|
47
|
+
const native = state.native;
|
|
48
|
+
const common = {
|
|
49
|
+
schemaVersion: 1 as const,
|
|
50
|
+
modality: state.modality,
|
|
51
|
+
runtimeTarget: native.target,
|
|
52
|
+
kernelVersion: native.buildIdentity,
|
|
53
|
+
modelSchemaVersion: EDITABLE_ARTIFACT_MODEL_SCHEMA_VERSION,
|
|
54
|
+
snapshotVersion: EDITABLE_ARTIFACT_SNAPSHOT_VERSION,
|
|
55
|
+
stateHash: native.stateHash(),
|
|
56
|
+
snapshotBytes: Uint8Array.from(native.snapshot()),
|
|
57
|
+
};
|
|
58
|
+
if (state.modality === "spreadsheet") {
|
|
59
|
+
if (!(native instanceof NativeSpreadsheetSession)) {
|
|
60
|
+
throw new Error("Spreadsheet composite does not own a spreadsheet native session");
|
|
61
|
+
}
|
|
62
|
+
return Object.freeze({
|
|
63
|
+
...common,
|
|
64
|
+
modality: "spreadsheet" as const,
|
|
65
|
+
coveredCausalFrontierBytes: Uint8Array.from(native.frontier()),
|
|
66
|
+
operationProtocolVersion: COMMITTED_TRANSACTION_PROTOCOL_VERSION,
|
|
67
|
+
crdtStateVersion: EDITABLE_ARTIFACT_SNAPSHOT_VERSION,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
if (
|
|
71
|
+
!(native instanceof NativeDocumentSession) &&
|
|
72
|
+
!(native instanceof NativePresentationSession)
|
|
73
|
+
) {
|
|
74
|
+
throw new Error("Serialized composite does not own its expected native session");
|
|
75
|
+
}
|
|
76
|
+
return Object.freeze({
|
|
77
|
+
...common,
|
|
78
|
+
modality: state.modality,
|
|
79
|
+
nativeRevision: safeNativeRevision(native.revision()),
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function safeNativeRevision(value: bigint): number {
|
|
84
|
+
if (value < 0n || value > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
85
|
+
throw new RangeError("Artifact native revision exceeds the durable range");
|
|
86
|
+
}
|
|
87
|
+
return Number(value);
|
|
88
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
export const EXCEL_MAX_ROWS = 1_048_576;
|
|
2
|
+
export const EXCEL_MAX_COLUMNS = 16_384;
|
|
3
|
+
|
|
4
|
+
export type CellAddress = { row: number; col: number };
|
|
5
|
+
export type RangeAddress = CellAddress & { rowCount: number; colCount: number };
|
|
6
|
+
|
|
7
|
+
export function columnNameToIndex(name: string): number {
|
|
8
|
+
if (!/^[A-Za-z]+$/.test(name)) throw new Error(`Invalid column name: ${name}`);
|
|
9
|
+
let value = 0;
|
|
10
|
+
for (const character of name.toUpperCase()) {
|
|
11
|
+
value = value * 26 + character.charCodeAt(0) - 64;
|
|
12
|
+
}
|
|
13
|
+
const index = value - 1;
|
|
14
|
+
if (index < 0 || index >= EXCEL_MAX_COLUMNS) {
|
|
15
|
+
throw new Error(`Column is outside the XLSX range: ${name}`);
|
|
16
|
+
}
|
|
17
|
+
return index;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function columnIndexToName(index: number): string {
|
|
21
|
+
assertIntegerInRange(index, 0, EXCEL_MAX_COLUMNS - 1, "column index");
|
|
22
|
+
let value = index + 1;
|
|
23
|
+
let result = "";
|
|
24
|
+
while (value > 0) {
|
|
25
|
+
const remainder = (value - 1) % 26;
|
|
26
|
+
result = String.fromCharCode(65 + remainder) + result;
|
|
27
|
+
value = Math.floor((value - 1) / 26);
|
|
28
|
+
}
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function parseCellAddress(input: string): CellAddress {
|
|
33
|
+
const match = /^\$?([A-Za-z]+)\$?([1-9]\d*)$/.exec(input.trim());
|
|
34
|
+
if (!match) throw new Error(`Invalid A1 cell address: ${input}`);
|
|
35
|
+
const row = Number(match[2]) - 1;
|
|
36
|
+
if (row < 0 || row >= EXCEL_MAX_ROWS) {
|
|
37
|
+
throw new Error(`Row is outside the XLSX range: ${input}`);
|
|
38
|
+
}
|
|
39
|
+
return { row, col: columnNameToIndex(match[1]!) };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function parseRangeAddress(input: string): RangeAddress {
|
|
43
|
+
const parts = input.trim().split(":");
|
|
44
|
+
if (parts.length > 2 || !parts[0]) throw new Error(`Invalid A1 range: ${input}`);
|
|
45
|
+
const start = parseCellAddress(parts[0]);
|
|
46
|
+
const end = parseCellAddress(parts[1] ?? parts[0]);
|
|
47
|
+
if (end.row < start.row || end.col < start.col) {
|
|
48
|
+
throw new Error(`Range must run top-left to bottom-right: ${input}`);
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
row: start.row,
|
|
52
|
+
col: start.col,
|
|
53
|
+
rowCount: end.row - start.row + 1,
|
|
54
|
+
colCount: end.col - start.col + 1,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function formatCellAddress(address: CellAddress): string {
|
|
59
|
+
return `${columnIndexToName(address.col)}${address.row + 1}`;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function formatRangeAddress(address: RangeAddress): string {
|
|
63
|
+
const start = formatCellAddress(address);
|
|
64
|
+
if (address.rowCount === 1 && address.colCount === 1) return start;
|
|
65
|
+
return `${start}:${formatCellAddress({
|
|
66
|
+
row: address.row + address.rowCount - 1,
|
|
67
|
+
col: address.col + address.colCount - 1,
|
|
68
|
+
})}`;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function cellKey(row: number, col: number): number {
|
|
72
|
+
return row * EXCEL_MAX_COLUMNS + col;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function assertRange(address: RangeAddress): void {
|
|
76
|
+
assertIntegerInRange(address.row, 0, EXCEL_MAX_ROWS - 1, "start row");
|
|
77
|
+
assertIntegerInRange(address.col, 0, EXCEL_MAX_COLUMNS - 1, "start column");
|
|
78
|
+
assertIntegerInRange(address.rowCount, 1, EXCEL_MAX_ROWS, "row count");
|
|
79
|
+
assertIntegerInRange(address.colCount, 1, EXCEL_MAX_COLUMNS, "column count");
|
|
80
|
+
if (address.row + address.rowCount > EXCEL_MAX_ROWS) throw new Error("Range exceeds XLSX rows");
|
|
81
|
+
if (address.col + address.colCount > EXCEL_MAX_COLUMNS) {
|
|
82
|
+
throw new Error("Range exceeds XLSX columns");
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function assertIntegerInRange(value: number, min: number, max: number, label: string): void {
|
|
87
|
+
if (!Number.isInteger(value) || value < min || value > max) {
|
|
88
|
+
throw new Error(`${label} must be an integer between ${min} and ${max}`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { FileBlob } from "./file-blob";
|
|
2
|
+
import type { Workbook } from "./spreadsheet";
|
|
3
|
+
import {
|
|
4
|
+
SpreadsheetFidelityError,
|
|
5
|
+
SpreadsheetSecurityError,
|
|
6
|
+
type SpreadsheetFidelityIssue,
|
|
7
|
+
type SpreadsheetLossPreservationEnvelope,
|
|
8
|
+
type SpreadsheetXlsxExportOptions,
|
|
9
|
+
type SpreadsheetXlsxImportLimits,
|
|
10
|
+
type SpreadsheetXlsxImportOptions,
|
|
11
|
+
} from "./spreadsheet-xlsx-api";
|
|
12
|
+
import {
|
|
13
|
+
spreadsheetFidelityReport,
|
|
14
|
+
spreadsheetLossPreservationEnvelope,
|
|
15
|
+
} from "./spreadsheet-xlsx-state";
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
SpreadsheetFidelityError,
|
|
19
|
+
SpreadsheetSecurityError,
|
|
20
|
+
type SpreadsheetFidelityIssue,
|
|
21
|
+
type SpreadsheetLossPreservationEnvelope,
|
|
22
|
+
type SpreadsheetXlsxExportOptions,
|
|
23
|
+
type SpreadsheetXlsxImportLimits,
|
|
24
|
+
type SpreadsheetXlsxImportOptions,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/** Lazily loaded XLSX codec around the canonical Workbook model. */
|
|
28
|
+
// eslint-disable-next-line typescript/no-extraneous-class -- Skill-compatible static facade.
|
|
29
|
+
export class SpreadsheetFile {
|
|
30
|
+
static async importXlsx(
|
|
31
|
+
input: FileBlob | Blob | ArrayBuffer | Uint8Array,
|
|
32
|
+
options: SpreadsheetXlsxImportOptions = {},
|
|
33
|
+
): Promise<Workbook> {
|
|
34
|
+
const { SpreadsheetXlsxCodec } = await loadSpreadsheetXlsxCodec();
|
|
35
|
+
return SpreadsheetXlsxCodec.importXlsx(input, options);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
static async exportXlsx(
|
|
39
|
+
workbook: Workbook,
|
|
40
|
+
options: SpreadsheetXlsxExportOptions = {},
|
|
41
|
+
): Promise<FileBlob> {
|
|
42
|
+
const { SpreadsheetXlsxCodec } = await loadSpreadsheetXlsxCodec();
|
|
43
|
+
return SpreadsheetXlsxCodec.exportXlsx(workbook, options);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
static fidelityReport(workbook: Workbook): readonly SpreadsheetFidelityIssue[] {
|
|
47
|
+
return spreadsheetFidelityReport(workbook);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Returns a portable copy of the opaque original-package envelope.
|
|
52
|
+
* Persist it beside Workbook.toJSON(); the Workbook JSON intentionally does not contain Office bytes.
|
|
53
|
+
*/
|
|
54
|
+
static lossPreservationEnvelope(workbook: Workbook): SpreadsheetLossPreservationEnvelope | null {
|
|
55
|
+
return spreadsheetLossPreservationEnvelope(workbook);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Reattaches a separately persisted envelope to a restored canonical workbook snapshot. */
|
|
59
|
+
static async attachLossPreservationEnvelope(
|
|
60
|
+
workbook: Workbook,
|
|
61
|
+
envelope: SpreadsheetLossPreservationEnvelope,
|
|
62
|
+
options: Pick<SpreadsheetXlsxImportOptions, "limits"> = {},
|
|
63
|
+
): Promise<void> {
|
|
64
|
+
const { SpreadsheetXlsxCodec } = await loadSpreadsheetXlsxCodec();
|
|
65
|
+
return SpreadsheetXlsxCodec.attachLossPreservationEnvelope(workbook, envelope, options);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function loadSpreadsheetXlsxCodec() {
|
|
70
|
+
return import("@opengeni/artifact-tool/spreadsheet/xlsx");
|
|
71
|
+
}
|