dsh-univer-office 0.2.8 → 0.2.9
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/artifacts/gateway.cjs +447 -1
- package/package.json +2 -2
package/artifacts/gateway.cjs
CHANGED
|
@@ -310802,6 +310802,452 @@ var require_dist4 = __commonJS({
|
|
|
310802
310802
|
}
|
|
310803
310803
|
});
|
|
310804
310804
|
|
|
310805
|
+
// node_modules/.pnpm/@univerjs-pro+exchange-node@1.0.0-insiders.20260821-c2f0ba5_react@18.3.1_rxjs@7.8.2/node_modules/@univerjs-pro/exchange-node/lib/cjs/index.cjs
|
|
310806
|
+
var require_cjs53 = __commonJS({
|
|
310807
|
+
"node_modules/.pnpm/@univerjs-pro+exchange-node@1.0.0-insiders.20260821-c2f0ba5_react@18.3.1_rxjs@7.8.2/node_modules/@univerjs-pro/exchange-node/lib/cjs/index.cjs"(exports2, module2) {
|
|
310808
|
+
"use strict";
|
|
310809
|
+
var __create2 = Object.create;
|
|
310810
|
+
var __defProp4 = Object.defineProperty;
|
|
310811
|
+
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
310812
|
+
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
310813
|
+
var __getProtoOf2 = Object.getPrototypeOf;
|
|
310814
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
310815
|
+
var __export2 = (target, all2) => {
|
|
310816
|
+
for (var name6 in all2)
|
|
310817
|
+
__defProp4(target, name6, { get: all2[name6], enumerable: true });
|
|
310818
|
+
};
|
|
310819
|
+
var __copyProps2 = (to3, from, except, desc) => {
|
|
310820
|
+
if (from && typeof from == "object" || typeof from == "function")
|
|
310821
|
+
for (let key of __getOwnPropNames2(from))
|
|
310822
|
+
!__hasOwnProp2.call(to3, key) && key !== except && __defProp4(to3, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
310823
|
+
return to3;
|
|
310824
|
+
};
|
|
310825
|
+
var __toESM2 = (mod3, isNodeMode, target) => (target = mod3 != null ? __create2(__getProtoOf2(mod3)) : {}, __copyProps2(
|
|
310826
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
310827
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
310828
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
310829
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
310830
|
+
isNodeMode || !mod3 || !mod3.__esModule ? __defProp4(target, "default", { value: mod3, enumerable: true }) : target,
|
|
310831
|
+
mod3
|
|
310832
|
+
));
|
|
310833
|
+
var __toCommonJS2 = (mod3) => __copyProps2(__defProp4({}, "__esModule", { value: true }), mod3);
|
|
310834
|
+
var index_exports = {};
|
|
310835
|
+
__export2(index_exports, {
|
|
310836
|
+
BaseAttachmentPolicy: () => BaseAttachmentPolicy,
|
|
310837
|
+
BaseExportMode: () => BaseExportMode2,
|
|
310838
|
+
BaseFormulaPolicy: () => BaseFormulaPolicy2,
|
|
310839
|
+
BaseHeaderPolicy: () => BaseHeaderPolicy,
|
|
310840
|
+
BaseImagePolicy: () => BaseImagePolicy,
|
|
310841
|
+
BaseImportMode: () => BaseImportMode2,
|
|
310842
|
+
BaseTypeInference: () => BaseTypeInference,
|
|
310843
|
+
CsvFormulaMode: () => CsvFormulaMode,
|
|
310844
|
+
CsvLineEnding: () => CsvLineEnding,
|
|
310845
|
+
CsvQuoteStyle: () => CsvQuoteStyle,
|
|
310846
|
+
CsvTypeInferenceMode: () => CsvTypeInferenceMode,
|
|
310847
|
+
CsvValueMode: () => CsvValueMode,
|
|
310848
|
+
DocxCompatibilityMode: () => DocxCompatibilityMode2,
|
|
310849
|
+
ExchangeError: () => ExchangeError2,
|
|
310850
|
+
ExchangeErrorCode: () => ExchangeErrorCode,
|
|
310851
|
+
ExchangeFormat: () => ExchangeFormat2,
|
|
310852
|
+
FormulaCalculationMode: () => FormulaCalculationMode2,
|
|
310853
|
+
exportSnapshotToBuffer: () => exportSnapshotToBuffer2,
|
|
310854
|
+
exportSnapshotToFile: () => exportSnapshotToFile,
|
|
310855
|
+
exportToBuffer: () => exportToBuffer,
|
|
310856
|
+
exportToFile: () => exportToFile,
|
|
310857
|
+
importBuffer: () => importBuffer2,
|
|
310858
|
+
importBufferToSnapshot: () => importBufferToSnapshot2,
|
|
310859
|
+
importFile: () => importFile,
|
|
310860
|
+
importFileToSnapshot: () => importFileToSnapshot
|
|
310861
|
+
});
|
|
310862
|
+
module2.exports = __toCommonJS2(index_exports);
|
|
310863
|
+
var import_collaboration = require_cjs32();
|
|
310864
|
+
var import_core13 = require_cjs5();
|
|
310865
|
+
var import_node_path8 = require("node:path");
|
|
310866
|
+
var import_promises2 = require("node:fs/promises");
|
|
310867
|
+
var import_node_module = require("node:module");
|
|
310868
|
+
var import_node_process2 = __toESM2(require("node:process"), 1);
|
|
310869
|
+
var ExchangeFormat2 = /* @__PURE__ */ ((ExchangeFormat22) => (ExchangeFormat22.XLS = "xls", ExchangeFormat22.XLSX = "xlsx", ExchangeFormat22.CSV = "csv", ExchangeFormat22.TSV = "tsv", ExchangeFormat22.DOC = "doc", ExchangeFormat22.DOCX = "docx", ExchangeFormat22.PPT = "ppt", ExchangeFormat22.PPTX = "pptx", ExchangeFormat22))(ExchangeFormat2 || {});
|
|
310870
|
+
var FormulaCalculationMode2 = /* @__PURE__ */ ((FormulaCalculationMode22) => (FormulaCalculationMode22.FORCED = "forced", FormulaCalculationMode22.WHEN_EMPTY = "when_empty", FormulaCalculationMode22.NO = "no", FormulaCalculationMode22))(FormulaCalculationMode2 || {});
|
|
310871
|
+
var CsvTypeInferenceMode = /* @__PURE__ */ ((CsvTypeInferenceMode2) => (CsvTypeInferenceMode2.OFF = "off", CsvTypeInferenceMode2.SAFE = "safe", CsvTypeInferenceMode2.AGGRESSIVE = "aggressive", CsvTypeInferenceMode2))(CsvTypeInferenceMode || {});
|
|
310872
|
+
var CsvQuoteStyle = /* @__PURE__ */ ((CsvQuoteStyle2) => (CsvQuoteStyle2.MINIMAL = "minimal", CsvQuoteStyle2.ALWAYS = "always", CsvQuoteStyle2))(CsvQuoteStyle || {});
|
|
310873
|
+
var CsvLineEnding = /* @__PURE__ */ ((CsvLineEnding2) => (CsvLineEnding2.LF = "lf", CsvLineEnding2.CRLF = "cr_lf", CsvLineEnding2))(CsvLineEnding || {});
|
|
310874
|
+
var CsvValueMode = /* @__PURE__ */ ((CsvValueMode2) => (CsvValueMode2.DISPLAY = "display", CsvValueMode2.RAW = "raw", CsvValueMode2))(CsvValueMode || {});
|
|
310875
|
+
var CsvFormulaMode = /* @__PURE__ */ ((CsvFormulaMode2) => (CsvFormulaMode2.CACHED = "cached", CsvFormulaMode2.EXPRESSION = "expression", CsvFormulaMode2))(CsvFormulaMode || {});
|
|
310876
|
+
var BaseImportMode2 = /* @__PURE__ */ ((BaseImportMode22) => (BaseImportMode22.TABLES = "tables", BaseImportMode22.SHEETS = "sheets", BaseImportMode22.HYBRID = "hybrid", BaseImportMode22.AUTO = "auto", BaseImportMode22))(BaseImportMode2 || {});
|
|
310877
|
+
var BaseTypeInference = /* @__PURE__ */ ((BaseTypeInference2) => (BaseTypeInference2.NONE = "none", BaseTypeInference2.SAFE = "safe", BaseTypeInference2.AGGRESSIVE = "aggressive", BaseTypeInference2))(BaseTypeInference || {});
|
|
310878
|
+
var BaseFormulaPolicy2 = /* @__PURE__ */ ((BaseFormulaPolicy22) => (BaseFormulaPolicy22.VALUES = "values", BaseFormulaPolicy22.TEXT = "text", BaseFormulaPolicy22.FAIL = "fail", BaseFormulaPolicy22.CONVERT_THEN_VALUES = "convertThenValues", BaseFormulaPolicy22))(BaseFormulaPolicy2 || {});
|
|
310879
|
+
var BaseImagePolicy = /* @__PURE__ */ ((BaseImagePolicy2) => (BaseImagePolicy2.SAFE = "safe", BaseImagePolicy2.CELL_ONLY = "cell-only", BaseImagePolicy2.MEDIA_TABLE = "media-table", BaseImagePolicy2.NONE = "none", BaseImagePolicy2))(BaseImagePolicy || {});
|
|
310880
|
+
var BaseHeaderPolicy = /* @__PURE__ */ ((BaseHeaderPolicy2) => (BaseHeaderPolicy2.FIRST_ROW = "firstRow", BaseHeaderPolicy2.NONE = "none", BaseHeaderPolicy2))(BaseHeaderPolicy || {});
|
|
310881
|
+
var BaseExportMode2 = /* @__PURE__ */ ((BaseExportMode22) => (BaseExportMode22.TABLES = "tables", BaseExportMode22.RANGES = "ranges", BaseExportMode22))(BaseExportMode2 || {});
|
|
310882
|
+
var BaseAttachmentPolicy = /* @__PURE__ */ ((BaseAttachmentPolicy2) => (BaseAttachmentPolicy2.HYBRID = "hybrid", BaseAttachmentPolicy2.MANIFEST = "manifest", BaseAttachmentPolicy2.LINKS = "links", BaseAttachmentPolicy2.NONE = "none", BaseAttachmentPolicy2))(BaseAttachmentPolicy || {});
|
|
310883
|
+
var DocxCompatibilityMode2 = /* @__PURE__ */ ((DocxCompatibilityMode22) => (DocxCompatibilityMode22.TRADITIONAL = "traditional", DocxCompatibilityMode22.MODERN = "modern", DocxCompatibilityMode22))(DocxCompatibilityMode2 || {});
|
|
310884
|
+
var ExchangeErrorCode = /* @__PURE__ */ ((ExchangeErrorCode2) => (ExchangeErrorCode2.INVALID_ARGUMENT = "INVALID_ARGUMENT", ExchangeErrorCode2.UNSUPPORTED_FORMAT = "UNSUPPORTED_FORMAT", ExchangeErrorCode2.INVALID_FILE = "INVALID_FILE", ExchangeErrorCode2.INCOMPLETE_SNAPSHOT = "INCOMPLETE_SNAPSHOT", ExchangeErrorCode2.IO_ERROR = "IO_ERROR", ExchangeErrorCode2.NATIVE_LOAD_FAILED = "NATIVE_LOAD_FAILED", ExchangeErrorCode2.CONVERSION_FAILED = "CONVERSION_FAILED", ExchangeErrorCode2))(ExchangeErrorCode || {});
|
|
310885
|
+
var ExchangeError2 = class extends Error {
|
|
310886
|
+
constructor(code, message2, options) {
|
|
310887
|
+
super(message2, options);
|
|
310888
|
+
this.code = code;
|
|
310889
|
+
}
|
|
310890
|
+
code;
|
|
310891
|
+
name = "ExchangeError";
|
|
310892
|
+
};
|
|
310893
|
+
var nativeBinding = null;
|
|
310894
|
+
var nativeBindingSource = null;
|
|
310895
|
+
var nodeRequire = (0, import_node_module.createRequire)(__filename);
|
|
310896
|
+
function errorMessage(error) {
|
|
310897
|
+
return error instanceof Error ? error.message : String(error);
|
|
310898
|
+
}
|
|
310899
|
+
async function loadNativeBinding() {
|
|
310900
|
+
if (nativeBinding)
|
|
310901
|
+
return nativeBinding;
|
|
310902
|
+
let errors = [];
|
|
310903
|
+
try {
|
|
310904
|
+
return nativeBinding = nodeRequire("@univerjs-pro/exchange-node-binding"), nativeBindingSource = "@univerjs-pro/exchange-node-binding", nativeBinding;
|
|
310905
|
+
} catch (error) {
|
|
310906
|
+
errors.push(`@univerjs-pro/exchange-node-binding: ${errorMessage(error)}`);
|
|
310907
|
+
}
|
|
310908
|
+
throw new ExchangeError2(
|
|
310909
|
+
"NATIVE_LOAD_FAILED",
|
|
310910
|
+
[
|
|
310911
|
+
"Failed to load native exchange binding.",
|
|
310912
|
+
`platform=${import_node_process2.default.platform}`,
|
|
310913
|
+
`arch=${import_node_process2.default.arch}`,
|
|
310914
|
+
"expected npm package=@univerjs-pro/exchange-node-binding",
|
|
310915
|
+
"attempted paths:",
|
|
310916
|
+
...errors.map((item) => `- ${item}`)
|
|
310917
|
+
].join(`
|
|
310918
|
+
`)
|
|
310919
|
+
);
|
|
310920
|
+
}
|
|
310921
|
+
var import_protocol6 = require_cjs();
|
|
310922
|
+
function createSnapshotCollector() {
|
|
310923
|
+
let sheetBlocks = /* @__PURE__ */ new Map();
|
|
310924
|
+
return {
|
|
310925
|
+
// The public Pro conversion functions accept the host-wide service
|
|
310926
|
+
// contract even though these conversion paths use its two write methods.
|
|
310927
|
+
service: {
|
|
310928
|
+
async saveSheetBlock(_context, { block }) {
|
|
310929
|
+
return block ? (sheetBlocks.set(block.id, block), {
|
|
310930
|
+
blockID: block.id,
|
|
310931
|
+
error: { code: import_protocol6.ErrorCode.OK, message: "" }
|
|
310932
|
+
}) : {
|
|
310933
|
+
blockID: "",
|
|
310934
|
+
error: { code: import_protocol6.ErrorCode.UNDEFINED, message: "block is required" }
|
|
310935
|
+
};
|
|
310936
|
+
},
|
|
310937
|
+
async saveSnapshot() {
|
|
310938
|
+
return { error: { code: import_protocol6.ErrorCode.OK, message: "" } };
|
|
310939
|
+
}
|
|
310940
|
+
},
|
|
310941
|
+
get sheetBlocks() {
|
|
310942
|
+
return [...sheetBlocks.values()];
|
|
310943
|
+
}
|
|
310944
|
+
};
|
|
310945
|
+
}
|
|
310946
|
+
var import_node_buffer = require("node:buffer");
|
|
310947
|
+
function bufferView(bytes) {
|
|
310948
|
+
return import_node_buffer.Buffer.isBuffer(bytes) ? bytes : import_node_buffer.Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
310949
|
+
}
|
|
310950
|
+
function takeMetadata(owner, kind, metadata, ownerId) {
|
|
310951
|
+
if (!owner)
|
|
310952
|
+
return owner;
|
|
310953
|
+
let { originalMeta, ...rest2 } = owner;
|
|
310954
|
+
if (originalMeta instanceof Uint8Array)
|
|
310955
|
+
metadata.push({ kind, ownerId, data: bufferView(originalMeta) });
|
|
310956
|
+
else if (originalMeta != null)
|
|
310957
|
+
throw new TypeError(`${kind} originalMeta must be a Uint8Array`);
|
|
310958
|
+
return rest2;
|
|
310959
|
+
}
|
|
310960
|
+
function toNativeSnapshot(value) {
|
|
310961
|
+
let metadata = [], source = value.snapshot, snapshot = { ...source }, sourceWorkbook = source.workbook;
|
|
310962
|
+
if (sourceWorkbook) {
|
|
310963
|
+
let workbook = takeMetadata(sourceWorkbook, "workbook", metadata), sourceSheets = sourceWorkbook.sheets;
|
|
310964
|
+
sourceSheets && (workbook.sheets = Object.fromEntries(
|
|
310965
|
+
Object.entries(sourceSheets).map(([sheetId, sheet]) => [
|
|
310966
|
+
sheetId,
|
|
310967
|
+
takeMetadata(sheet, "worksheet", metadata, sheetId)
|
|
310968
|
+
])
|
|
310969
|
+
)), snapshot.workbook = workbook;
|
|
310970
|
+
}
|
|
310971
|
+
for (let kind of ["doc", "slide"]) {
|
|
310972
|
+
let owner = source[kind];
|
|
310973
|
+
owner && (snapshot[kind] = takeMetadata(owner, kind, metadata));
|
|
310974
|
+
}
|
|
310975
|
+
return {
|
|
310976
|
+
snapshotJson: import_node_buffer.Buffer.from(JSON.stringify(snapshot)),
|
|
310977
|
+
metadata,
|
|
310978
|
+
sheetBlocks: value.sheetBlocks.map((block) => ({
|
|
310979
|
+
id: block.id,
|
|
310980
|
+
startRow: block.startRow,
|
|
310981
|
+
endRow: block.endRow,
|
|
310982
|
+
data: bufferView(block.data)
|
|
310983
|
+
}))
|
|
310984
|
+
};
|
|
310985
|
+
}
|
|
310986
|
+
function restoreMetadata(snapshot, metadata) {
|
|
310987
|
+
for (let entry of metadata) {
|
|
310988
|
+
let owner;
|
|
310989
|
+
if (entry.kind === "worksheet") {
|
|
310990
|
+
let sheets = snapshot.workbook?.sheets;
|
|
310991
|
+
owner = entry.ownerId ? sheets?.[entry.ownerId] : void 0;
|
|
310992
|
+
} else {
|
|
310993
|
+
if (entry.kind !== "workbook" && entry.kind !== "doc" && entry.kind !== "slide")
|
|
310994
|
+
throw new TypeError(`unsupported native snapshot metadata kind ${entry.kind}`);
|
|
310995
|
+
owner = snapshot[entry.kind];
|
|
310996
|
+
}
|
|
310997
|
+
if (!owner)
|
|
310998
|
+
throw new TypeError(`native snapshot metadata owner ${entry.kind}/${entry.ownerId ?? ""} is missing`);
|
|
310999
|
+
owner.originalMeta = entry.data;
|
|
311000
|
+
}
|
|
311001
|
+
}
|
|
311002
|
+
function fromNativeSnapshot(value) {
|
|
311003
|
+
let snapshot = JSON.parse(value.snapshotJson.toString("utf8"));
|
|
311004
|
+
return restoreMetadata(snapshot, value.metadata), {
|
|
311005
|
+
snapshot,
|
|
311006
|
+
sheetBlocks: value.sheetBlocks.map((block) => ({
|
|
311007
|
+
id: block.id,
|
|
311008
|
+
startRow: block.startRow,
|
|
311009
|
+
endRow: block.endRow,
|
|
311010
|
+
data: block.data
|
|
311011
|
+
}))
|
|
311012
|
+
};
|
|
311013
|
+
}
|
|
311014
|
+
var FORMAT_BY_EXTENSION = {
|
|
311015
|
+
".xls": "xls",
|
|
311016
|
+
".xlsx": "xlsx",
|
|
311017
|
+
".csv": "csv",
|
|
311018
|
+
".tsv": "tsv",
|
|
311019
|
+
".doc": "doc",
|
|
311020
|
+
".docx": "docx",
|
|
311021
|
+
".ppt": "ppt",
|
|
311022
|
+
".pptx": "pptx"
|
|
311023
|
+
/* PPTX */
|
|
311024
|
+
};
|
|
311025
|
+
function normalizeWorkbookSheetOrder(data2) {
|
|
311026
|
+
let existingOrder = Array.isArray(data2.sheetOrder) ? data2.sheetOrder.filter((sheetId) => typeof sheetId == "string") : [], ordered = new Set(existingOrder), missingSheetIds = Object.keys(data2.sheets).filter((sheetId) => !ordered.has(sheetId));
|
|
311027
|
+
return missingSheetIds.length === 0 ? data2 : { ...data2, sheetOrder: [...existingOrder, ...missingSheetIds] };
|
|
311028
|
+
}
|
|
311029
|
+
function exchangeError(error, fallback) {
|
|
311030
|
+
if (error instanceof ExchangeError2)
|
|
311031
|
+
return error;
|
|
311032
|
+
let message2 = error instanceof Error ? error.message : String(error), nativeCode = /^\[([A-Z_]+)]\s*/.exec(message2)?.[1];
|
|
311033
|
+
return nativeCode && Object.values(ExchangeErrorCode).includes(nativeCode) ? new ExchangeError2(nativeCode, message2.replace(/^\[[A-Z_]+]\s*/, ""), {
|
|
311034
|
+
cause: error
|
|
311035
|
+
}) : error instanceof TypeError ? new ExchangeError2("INVALID_ARGUMENT", message2, { cause: error }) : new ExchangeError2(fallback, message2, { cause: error });
|
|
311036
|
+
}
|
|
311037
|
+
function resolveFormat(fileName, format2) {
|
|
311038
|
+
if (format2)
|
|
311039
|
+
return format2;
|
|
311040
|
+
let inferred = FORMAT_BY_EXTENSION[(0, import_node_path8.extname)(fileName).toLowerCase()];
|
|
311041
|
+
if (!inferred)
|
|
311042
|
+
throw new ExchangeError2(
|
|
311043
|
+
"UNSUPPORTED_FORMAT",
|
|
311044
|
+
`Cannot infer an exchange format from fileName: ${fileName}`
|
|
311045
|
+
);
|
|
311046
|
+
return inferred;
|
|
311047
|
+
}
|
|
311048
|
+
function nativeUnitType(type3) {
|
|
311049
|
+
switch (type3) {
|
|
311050
|
+
case import_core13.UniverInstanceType.UNIVER_SHEET:
|
|
311051
|
+
return "sheet";
|
|
311052
|
+
case import_core13.UniverInstanceType.UNIVER_BASE:
|
|
311053
|
+
return "base";
|
|
311054
|
+
case import_core13.UniverInstanceType.UNIVER_DOC:
|
|
311055
|
+
return "doc";
|
|
311056
|
+
case import_core13.UniverInstanceType.UNIVER_SLIDE:
|
|
311057
|
+
return "slide";
|
|
311058
|
+
default:
|
|
311059
|
+
throw new ExchangeError2("INVALID_ARGUMENT", `Unsupported Univer unit type: ${type3}`);
|
|
311060
|
+
}
|
|
311061
|
+
}
|
|
311062
|
+
function nativeImportOptions(options, fileName) {
|
|
311063
|
+
return {
|
|
311064
|
+
format: resolveFormat(fileName, options.format),
|
|
311065
|
+
unitType: nativeUnitType(options.type),
|
|
311066
|
+
fileName,
|
|
311067
|
+
unitId: options.unitId,
|
|
311068
|
+
minSheetRowCount: "minSheetRowCount" in options ? options.minSheetRowCount : void 0,
|
|
311069
|
+
minSheetColumnCount: "minSheetColumnCount" in options ? options.minSheetColumnCount : void 0,
|
|
311070
|
+
compatibilityMode: "compatibilityMode" in options ? options.compatibilityMode : void 0,
|
|
311071
|
+
csv: "csv" in options ? options.csv : void 0,
|
|
311072
|
+
base: options.type === import_core13.UniverInstanceType.UNIVER_BASE ? {
|
|
311073
|
+
mode: options.mode,
|
|
311074
|
+
typeInference: options.typeInference,
|
|
311075
|
+
formulaPolicy: options.formulaPolicy,
|
|
311076
|
+
imagePolicy: options.imagePolicy,
|
|
311077
|
+
maxCells: options.maxCells,
|
|
311078
|
+
mapping: options.mapping
|
|
311079
|
+
} : void 0,
|
|
311080
|
+
formulaCalculation: "formulaCalculation" in options ? options.formulaCalculation : void 0
|
|
311081
|
+
};
|
|
311082
|
+
}
|
|
311083
|
+
function nativeExportOptions(options) {
|
|
311084
|
+
return {
|
|
311085
|
+
format: options.format,
|
|
311086
|
+
unitType: nativeUnitType(options.type),
|
|
311087
|
+
csv: "csv" in options ? options.csv : void 0,
|
|
311088
|
+
base: options.type === import_core13.UniverInstanceType.UNIVER_BASE && options.format === "xlsx" ? {
|
|
311089
|
+
mode: options.mode,
|
|
311090
|
+
formulaPolicy: options.formulaPolicy,
|
|
311091
|
+
attachmentPolicy: options.attachmentPolicy,
|
|
311092
|
+
mapping: options.mapping
|
|
311093
|
+
} : void 0,
|
|
311094
|
+
formulaCalculation: "formulaCalculation" in options ? options.formulaCalculation : void 0
|
|
311095
|
+
};
|
|
311096
|
+
}
|
|
311097
|
+
async function importSnapshot(input, options, fileName) {
|
|
311098
|
+
try {
|
|
311099
|
+
let result2 = await (await loadNativeBinding()).exchangeImportToSnapshot(
|
|
311100
|
+
input,
|
|
311101
|
+
JSON.stringify(nativeImportOptions(options, fileName))
|
|
311102
|
+
);
|
|
311103
|
+
return fromNativeSnapshot(result2);
|
|
311104
|
+
} catch (error) {
|
|
311105
|
+
throw exchangeError(
|
|
311106
|
+
error,
|
|
311107
|
+
"CONVERSION_FAILED"
|
|
311108
|
+
/* CONVERSION_FAILED */
|
|
311109
|
+
);
|
|
311110
|
+
}
|
|
311111
|
+
}
|
|
311112
|
+
async function snapshotToMemory(snapshot, type3) {
|
|
311113
|
+
try {
|
|
311114
|
+
switch (type3) {
|
|
311115
|
+
case import_core13.UniverInstanceType.UNIVER_SHEET:
|
|
311116
|
+
return await (0, import_collaboration.transformSnapshotToWorkbookData)(snapshot.snapshot, snapshot.sheetBlocks);
|
|
311117
|
+
case import_core13.UniverInstanceType.UNIVER_BASE:
|
|
311118
|
+
return await (0, import_collaboration.transformSnapshotToBaseData)(snapshot.snapshot, snapshot.sheetBlocks);
|
|
311119
|
+
case import_core13.UniverInstanceType.UNIVER_DOC:
|
|
311120
|
+
return (0, import_collaboration.transformSnapshotToDocumentData)(snapshot.snapshot);
|
|
311121
|
+
case import_core13.UniverInstanceType.UNIVER_SLIDE:
|
|
311122
|
+
return (0, import_collaboration.transformSnapshotToSlideData)(snapshot.snapshot);
|
|
311123
|
+
default:
|
|
311124
|
+
throw new TypeError(`Unsupported Univer unit type: ${type3}`);
|
|
311125
|
+
}
|
|
311126
|
+
} catch (error) {
|
|
311127
|
+
throw exchangeError(
|
|
311128
|
+
error,
|
|
311129
|
+
"CONVERSION_FAILED"
|
|
311130
|
+
/* CONVERSION_FAILED */
|
|
311131
|
+
);
|
|
311132
|
+
}
|
|
311133
|
+
}
|
|
311134
|
+
async function memoryToSnapshot(data2, options) {
|
|
311135
|
+
try {
|
|
311136
|
+
let unitId = data2.id;
|
|
311137
|
+
if (!unitId)
|
|
311138
|
+
throw new ExchangeError2("INVALID_ARGUMENT", "Export data must have a non-empty id");
|
|
311139
|
+
let rev = data2.rev ?? 0, collector = createSnapshotCollector();
|
|
311140
|
+
switch (options.type) {
|
|
311141
|
+
case import_core13.UniverInstanceType.UNIVER_SHEET: {
|
|
311142
|
+
let workbook = normalizeWorkbookSheetOrder(data2), { snapshot } = await (0, import_collaboration.transformWorkbookDataToSnapshot)(
|
|
311143
|
+
{ metadata: void 0 },
|
|
311144
|
+
workbook,
|
|
311145
|
+
unitId,
|
|
311146
|
+
rev,
|
|
311147
|
+
collector.service
|
|
311148
|
+
);
|
|
311149
|
+
return { snapshot, sheetBlocks: collector.sheetBlocks };
|
|
311150
|
+
}
|
|
311151
|
+
case import_core13.UniverInstanceType.UNIVER_BASE: {
|
|
311152
|
+
let { snapshot } = await (0, import_collaboration.transformBaseDataToSnapshot)(
|
|
311153
|
+
{ metadata: void 0 },
|
|
311154
|
+
data2,
|
|
311155
|
+
unitId,
|
|
311156
|
+
rev,
|
|
311157
|
+
collector.service
|
|
311158
|
+
);
|
|
311159
|
+
return { snapshot, sheetBlocks: collector.sheetBlocks };
|
|
311160
|
+
}
|
|
311161
|
+
case import_core13.UniverInstanceType.UNIVER_DOC: {
|
|
311162
|
+
let { snapshot } = await (0, import_collaboration.transformDocumentDataToSnapshot)(
|
|
311163
|
+
{ metadata: void 0 },
|
|
311164
|
+
data2,
|
|
311165
|
+
unitId,
|
|
311166
|
+
rev,
|
|
311167
|
+
collector.service
|
|
311168
|
+
);
|
|
311169
|
+
return { snapshot, sheetBlocks: [] };
|
|
311170
|
+
}
|
|
311171
|
+
case import_core13.UniverInstanceType.UNIVER_SLIDE: {
|
|
311172
|
+
let slide = data2, { snapshot } = await (0, import_collaboration.transformSlideDataToSnapshot)(
|
|
311173
|
+
slide.resources,
|
|
311174
|
+
slide,
|
|
311175
|
+
unitId,
|
|
311176
|
+
rev,
|
|
311177
|
+
collector.service
|
|
311178
|
+
);
|
|
311179
|
+
return { snapshot, sheetBlocks: [] };
|
|
311180
|
+
}
|
|
311181
|
+
default:
|
|
311182
|
+
throw new TypeError("Unsupported Univer unit type");
|
|
311183
|
+
}
|
|
311184
|
+
} catch (error) {
|
|
311185
|
+
throw exchangeError(
|
|
311186
|
+
error,
|
|
311187
|
+
"CONVERSION_FAILED"
|
|
311188
|
+
/* CONVERSION_FAILED */
|
|
311189
|
+
);
|
|
311190
|
+
}
|
|
311191
|
+
}
|
|
311192
|
+
async function importFile(path, options) {
|
|
311193
|
+
let snapshot = await importFileToSnapshot(path, options);
|
|
311194
|
+
return snapshotToMemory(snapshot, options.type);
|
|
311195
|
+
}
|
|
311196
|
+
async function importBuffer2(input, options) {
|
|
311197
|
+
let snapshot = await importSnapshot(input, options, options.fileName);
|
|
311198
|
+
return snapshotToMemory(snapshot, options.type);
|
|
311199
|
+
}
|
|
311200
|
+
async function importFileToSnapshot(path, options) {
|
|
311201
|
+
let fileName = options.fileName ?? (0, import_node_path8.basename)(path), input;
|
|
311202
|
+
try {
|
|
311203
|
+
input = await (0, import_promises2.readFile)(path);
|
|
311204
|
+
} catch (error) {
|
|
311205
|
+
throw exchangeError(
|
|
311206
|
+
error,
|
|
311207
|
+
"IO_ERROR"
|
|
311208
|
+
/* IO_ERROR */
|
|
311209
|
+
);
|
|
311210
|
+
}
|
|
311211
|
+
return importSnapshot(input, options, fileName);
|
|
311212
|
+
}
|
|
311213
|
+
async function importBufferToSnapshot2(input, options) {
|
|
311214
|
+
return importSnapshot(input, options, options.fileName);
|
|
311215
|
+
}
|
|
311216
|
+
async function exportToBuffer(data2, options) {
|
|
311217
|
+
return exportSnapshotToBuffer2(await memoryToSnapshot(data2, options), options);
|
|
311218
|
+
}
|
|
311219
|
+
async function exportToFile(data2, path, options) {
|
|
311220
|
+
await exportSnapshotToFile(await memoryToSnapshot(data2, options), path, options);
|
|
311221
|
+
}
|
|
311222
|
+
async function exportSnapshotToBuffer2(snapshot, options) {
|
|
311223
|
+
try {
|
|
311224
|
+
return await (await loadNativeBinding()).exchangeExportSnapshot(
|
|
311225
|
+
toNativeSnapshot(snapshot),
|
|
311226
|
+
JSON.stringify(nativeExportOptions(options))
|
|
311227
|
+
);
|
|
311228
|
+
} catch (error) {
|
|
311229
|
+
throw exchangeError(
|
|
311230
|
+
error,
|
|
311231
|
+
"CONVERSION_FAILED"
|
|
311232
|
+
/* CONVERSION_FAILED */
|
|
311233
|
+
);
|
|
311234
|
+
}
|
|
311235
|
+
}
|
|
311236
|
+
async function exportSnapshotToFile(snapshot, path, options) {
|
|
311237
|
+
let output = await exportSnapshotToBuffer2(snapshot, options);
|
|
311238
|
+
try {
|
|
311239
|
+
await (0, import_promises2.writeFile)(path, output);
|
|
311240
|
+
} catch (error) {
|
|
311241
|
+
throw exchangeError(
|
|
311242
|
+
error,
|
|
311243
|
+
"IO_ERROR"
|
|
311244
|
+
/* IO_ERROR */
|
|
311245
|
+
);
|
|
311246
|
+
}
|
|
311247
|
+
}
|
|
311248
|
+
}
|
|
311249
|
+
});
|
|
311250
|
+
|
|
310805
311251
|
// node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/constants.js
|
|
310806
311252
|
var require_constants = __commonJS({
|
|
310807
311253
|
"node_modules/.pnpm/ws@8.21.3/node_modules/ws/lib/constants.js"(exports2, module2) {
|
|
@@ -346747,7 +347193,7 @@ ResourceLoaderService = __decorate([__decorateParam(0, Inject(IResourceManagerSe
|
|
|
346747
347193
|
installShims();
|
|
346748
347194
|
|
|
346749
347195
|
// src/gateway-app/exchange/gateway-exchange-service.ts
|
|
346750
|
-
var import_exchange_node =
|
|
347196
|
+
var import_exchange_node = __toESM(require_cjs53(), 1);
|
|
346751
347197
|
var MAX_EXCHANGE_FILE_BYTES = 50 * 1024 * 1024;
|
|
346752
347198
|
var ARTIFACT_TTL_MS = 2 * 60 * 60 * 1e3;
|
|
346753
347199
|
var OK = { code: ErrorCode.OK, message: "" };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-univer-office",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"description": "DSH × Univer integration with a bundled collaboration Gateway and Viewer: inline previews, live floating Worktree windows, and session-end review actions in DeepSeek Harness.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -73,7 +73,6 @@
|
|
|
73
73
|
"@puppeteer/browsers": "^3.2.0",
|
|
74
74
|
"@univerjs-pro/cli-assets": "0.1.0",
|
|
75
75
|
"@univerjs-pro/engine-formula-rust-binding": "1.0.0-insiders.20260819-8209aa8",
|
|
76
|
-
"@univerjs-pro/exchange-node": "1.0.0-insiders.20260821-c2f0ba5",
|
|
77
76
|
"@univerjs-pro/exchange-node-binding": "0.1.0",
|
|
78
77
|
"libsql": "^0.5.29",
|
|
79
78
|
"puppeteer-core": "^25.7.0"
|
|
@@ -173,6 +172,7 @@
|
|
|
173
172
|
"@univerjs-pro/engine-formula": "1.0.0-insiders.20260821-c2f0ba5",
|
|
174
173
|
"@univerjs-pro/engine-shape": "1.0.0-insiders.20260821-c2f0ba5",
|
|
175
174
|
"@univerjs-pro/exchange-client": "1.0.0-insiders.20260821-c2f0ba5",
|
|
175
|
+
"@univerjs-pro/exchange-node": "1.0.0-insiders.20260821-c2f0ba5",
|
|
176
176
|
"@univerjs-pro/ink": "1.0.0-insiders.20260821-c2f0ba5",
|
|
177
177
|
"@univerjs-pro/ink-ui": "1.0.0-insiders.20260821-c2f0ba5",
|
|
178
178
|
"@univerjs-pro/license": "1.0.0-insiders.20260821-c2f0ba5",
|