ooxml-core 0.10.0 → 0.12.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 +10 -6
- package/dist/automation/docx.d.ts +13 -0
- package/dist/automation/docx.d.ts.map +1 -0
- package/dist/automation/index.cjs +36953 -0
- package/dist/automation/index.d.ts +6 -0
- package/dist/automation/index.d.ts.map +1 -0
- package/dist/automation/index.mjs +36939 -0
- package/dist/automation/node.cjs +103 -0
- package/dist/automation/node.d.ts +16 -0
- package/dist/automation/node.d.ts.map +1 -0
- package/dist/automation/node.mjs +101 -0
- package/dist/automation/visio.d.ts +30 -0
- package/dist/automation/visio.d.ts.map +1 -0
- package/dist/automation/xlsx.d.ts +25 -0
- package/dist/automation/xlsx.d.ts.map +1 -0
- package/dist/pptx/automation/index.cjs +149047 -0
- package/dist/pptx/automation/index.d.ts +1474 -0
- package/dist/pptx/automation/index.d.ts.map +1 -0
- package/dist/pptx/automation/index.mjs +148926 -0
- package/dist/pptx/chunks/{index-BWUBPGgv.d.ts → index-BWRd8p4y.d.ts} +2 -2
- package/dist/pptx/chunks/{index-BWUBPGgv.d.ts.map → index-BWRd8p4y.d.ts.map} +1 -1
- package/dist/pptx/chunks/index-LoCVDu8Z.d.ts +9644 -0
- package/dist/pptx/chunks/index-LoCVDu8Z.d.ts.map +1 -0
- package/dist/pptx/chunks/{text-operations-IlJiffp7.d.ts → text-operations-2tKzrY5o.d.ts} +7381 -7381
- package/dist/pptx/chunks/text-operations-2tKzrY5o.d.ts.map +1 -0
- package/dist/pptx/cli/index.d.ts +1 -1
- package/dist/pptx/converter/index.d.ts +1 -1
- package/dist/pptx/index.d.ts +4 -9644
- package/dist/visio/edit-geometry-admission.d.ts +6 -3
- package/dist/visio/edit-geometry-admission.d.ts.map +1 -1
- package/dist/visio/edit-geometry.d.ts +2 -1
- package/dist/visio/edit-geometry.d.ts.map +1 -1
- package/dist/visio/edit-master-index.d.ts +1 -1
- package/dist/visio/edit-master-index.d.ts.map +1 -1
- package/dist/visio/edit-master-move.d.ts +20 -0
- package/dist/visio/edit-master-move.d.ts.map +1 -0
- package/dist/visio/edit-master-scope.d.ts +2 -1
- package/dist/visio/edit-master-scope.d.ts.map +1 -1
- package/dist/visio/edit-recalculate-index.d.ts +2 -0
- package/dist/visio/edit-recalculate-index.d.ts.map +1 -1
- package/dist/visio/edit-scope.d.ts +2 -1
- package/dist/visio/edit-scope.d.ts.map +1 -1
- package/dist/visio/edit.d.ts.map +1 -1
- package/dist/visio/index.cjs +250 -36
- package/dist/visio/index.mjs +250 -36
- package/dist/xlsx/formula/area-index.d.ts +3 -3
- package/dist/xlsx/formula/area-index.d.ts.map +1 -1
- package/dist/xlsx/formula/engine-core.d.ts +4 -1
- package/dist/xlsx/formula/engine-core.d.ts.map +1 -1
- package/dist/xlsx/formula/engine-host.d.ts +2 -0
- package/dist/xlsx/formula/engine-host.d.ts.map +1 -1
- package/dist/xlsx/formula/engine-order.d.ts +11 -0
- package/dist/xlsx/formula/engine-order.d.ts.map +1 -0
- package/dist/xlsx/formula/spill.d.ts.map +1 -1
- package/dist/xlsx/formula/store.d.ts.map +1 -1
- package/dist/xlsx/index.cjs +102 -64
- package/dist/xlsx/index.mjs +102 -64
- package/package.json +21 -3
- package/dist/pptx/chunks/text-operations-IlJiffp7.d.ts.map +0 -1
- package/dist/pptx/index.d.ts.map +0 -1
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var promises = require('fs/promises');
|
|
4
|
+
var path = require('path');
|
|
5
|
+
var crypto = require('crypto');
|
|
6
|
+
|
|
7
|
+
// src/automation/node.ts
|
|
8
|
+
function createFileOperations(rootDir = process.cwd()) {
|
|
9
|
+
const pending = /* @__PURE__ */ new Map();
|
|
10
|
+
const maxBytes = 64 * 1024 * 1024;
|
|
11
|
+
async function pathFor(file, extensions) {
|
|
12
|
+
const root = await promises.realpath(path.resolve(rootDir));
|
|
13
|
+
const path$1 = path.resolve(root, file);
|
|
14
|
+
const parent = await promises.realpath(path.dirname(path$1));
|
|
15
|
+
let actual = path.resolve(parent, path.basename(path$1));
|
|
16
|
+
const inside = (target) => {
|
|
17
|
+
const rel = path.relative(root, target);
|
|
18
|
+
if (rel === ".." || rel.startsWith("../") || rel.startsWith("..\\") || path.isAbsolute(rel))
|
|
19
|
+
throw new Error("Path is outside the configured root");
|
|
20
|
+
};
|
|
21
|
+
inside(actual);
|
|
22
|
+
try {
|
|
23
|
+
actual = await promises.realpath(actual);
|
|
24
|
+
inside(actual);
|
|
25
|
+
} catch (error) {
|
|
26
|
+
if (error.code !== "ENOENT") throw error;
|
|
27
|
+
}
|
|
28
|
+
if (!extensions.includes(path.extname(actual).toLowerCase()))
|
|
29
|
+
throw new Error("Unsupported file extension");
|
|
30
|
+
return actual;
|
|
31
|
+
}
|
|
32
|
+
async function read(path) {
|
|
33
|
+
const handle = await promises.open(path, "r");
|
|
34
|
+
try {
|
|
35
|
+
if ((await handle.stat()).size > maxBytes) throw new Error("File exceeds 64 MiB");
|
|
36
|
+
const bytes = await handle.readFile();
|
|
37
|
+
if (bytes.length > maxBytes) throw new Error("File exceeds 64 MiB");
|
|
38
|
+
return new Uint8Array(bytes);
|
|
39
|
+
} finally {
|
|
40
|
+
await handle.close();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async function write(path, bytes, replace) {
|
|
44
|
+
if (bytes.length > maxBytes) throw new Error("Output exceeds 64 MiB");
|
|
45
|
+
const temp = `${path}.${crypto.randomUUID()}.tmp`;
|
|
46
|
+
const handle = await promises.open(temp, "wx", 384);
|
|
47
|
+
try {
|
|
48
|
+
await handle.writeFile(bytes);
|
|
49
|
+
await handle.sync();
|
|
50
|
+
} catch (error) {
|
|
51
|
+
await handle.close();
|
|
52
|
+
await promises.unlink(temp).catch(() => {
|
|
53
|
+
});
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
await handle.close();
|
|
57
|
+
try {
|
|
58
|
+
if (replace) await promises.rename(temp, path);
|
|
59
|
+
else await promises.link(temp, path);
|
|
60
|
+
} finally {
|
|
61
|
+
await promises.unlink(temp).catch(() => {
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
async function serial(path, action) {
|
|
66
|
+
if (process.platform === "win32") path = path.toLowerCase();
|
|
67
|
+
const before = pending.get(path) ?? Promise.resolve();
|
|
68
|
+
const current = before.catch(() => {
|
|
69
|
+
}).then(action);
|
|
70
|
+
pending.set(path, current);
|
|
71
|
+
try {
|
|
72
|
+
return await current;
|
|
73
|
+
} finally {
|
|
74
|
+
if (pending.get(path) === current) pending.delete(path);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
async inspect(file, extensions, inspect) {
|
|
79
|
+
const path = await pathFor(file, extensions);
|
|
80
|
+
return serial(path, async () => inspect(await read(path)));
|
|
81
|
+
},
|
|
82
|
+
async create(file, extensions, create) {
|
|
83
|
+
const path = await pathFor(file, extensions);
|
|
84
|
+
return serial(path, async () => {
|
|
85
|
+
await write(path, await create(), false);
|
|
86
|
+
return { filePath: path, saved: true };
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
async edit(file, extensions, edit, outputPath) {
|
|
90
|
+
const path$1 = await pathFor(file, extensions);
|
|
91
|
+
const output = outputPath ? await pathFor(outputPath, extensions) : path$1;
|
|
92
|
+
if (path.extname(output).toLowerCase() !== path.extname(path$1).toLowerCase())
|
|
93
|
+
throw new Error("Save-as must keep the source file extension");
|
|
94
|
+
return serial(path$1, async () => {
|
|
95
|
+
const { bytes, ...result } = await edit(await read(path$1));
|
|
96
|
+
await write(output, bytes, output === path$1);
|
|
97
|
+
return { ...result, filePath: output, saved: true };
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
exports.createFileOperations = createFileOperations;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface ByteEditResult {
|
|
2
|
+
bytes: Uint8Array;
|
|
3
|
+
}
|
|
4
|
+
/** Local filesystem boundary used by the repository-owned MCP adapters. */
|
|
5
|
+
export declare function createFileOperations(rootDir?: string): {
|
|
6
|
+
inspect<T>(file: string, extensions: readonly string[], inspect: (bytes: Uint8Array) => Promise<T>): Promise<T>;
|
|
7
|
+
create(file: string, extensions: readonly string[], create: () => Promise<Uint8Array>): Promise<{
|
|
8
|
+
filePath: string;
|
|
9
|
+
saved: boolean;
|
|
10
|
+
}>;
|
|
11
|
+
edit<T extends ByteEditResult>(file: string, extensions: readonly string[], edit: (bytes: Uint8Array) => Promise<T>, outputPath?: string): Promise<Omit<T, "bytes"> & {
|
|
12
|
+
filePath: string;
|
|
13
|
+
saved: boolean;
|
|
14
|
+
}>;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/automation/node.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,cAAc;IAC9B,KAAK,EAAE,UAAU,CAAC;CAClB;AAED,2EAA2E;AAC3E,wBAAgB,oBAAoB,CAAC,OAAO,SAAgB;YAmE5C,CAAC,QACR,MAAM,cACA,SAAS,MAAM,EAAE,WACpB,CAAC,KAAK,EAAE,UAAU,KAAK,OAAO,CAAC,CAAC,CAAC;iBAKxB,MAAM,cAAc,SAAS,MAAM,EAAE,UAAU,MAAM,OAAO,CAAC,UAAU,CAAC;;;;SAOhF,CAAC,SAAS,cAAc,QAC5B,MAAM,cACA,SAAS,MAAM,EAAE,QACvB,CAAC,KAAK,EAAE,UAAU,KAAK,OAAO,CAAC,CAAC,CAAC,eAC1B,MAAM;;;;EAarB"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { realpath, open, unlink, rename, link } from 'fs/promises';
|
|
2
|
+
import { extname, resolve, dirname, basename, relative, isAbsolute } from 'path';
|
|
3
|
+
import { randomUUID } from 'crypto';
|
|
4
|
+
|
|
5
|
+
// src/automation/node.ts
|
|
6
|
+
function createFileOperations(rootDir = process.cwd()) {
|
|
7
|
+
const pending = /* @__PURE__ */ new Map();
|
|
8
|
+
const maxBytes = 64 * 1024 * 1024;
|
|
9
|
+
async function pathFor(file, extensions) {
|
|
10
|
+
const root = await realpath(resolve(rootDir));
|
|
11
|
+
const path = resolve(root, file);
|
|
12
|
+
const parent = await realpath(dirname(path));
|
|
13
|
+
let actual = resolve(parent, basename(path));
|
|
14
|
+
const inside = (target) => {
|
|
15
|
+
const rel = relative(root, target);
|
|
16
|
+
if (rel === ".." || rel.startsWith("../") || rel.startsWith("..\\") || isAbsolute(rel))
|
|
17
|
+
throw new Error("Path is outside the configured root");
|
|
18
|
+
};
|
|
19
|
+
inside(actual);
|
|
20
|
+
try {
|
|
21
|
+
actual = await realpath(actual);
|
|
22
|
+
inside(actual);
|
|
23
|
+
} catch (error) {
|
|
24
|
+
if (error.code !== "ENOENT") throw error;
|
|
25
|
+
}
|
|
26
|
+
if (!extensions.includes(extname(actual).toLowerCase()))
|
|
27
|
+
throw new Error("Unsupported file extension");
|
|
28
|
+
return actual;
|
|
29
|
+
}
|
|
30
|
+
async function read(path) {
|
|
31
|
+
const handle = await open(path, "r");
|
|
32
|
+
try {
|
|
33
|
+
if ((await handle.stat()).size > maxBytes) throw new Error("File exceeds 64 MiB");
|
|
34
|
+
const bytes = await handle.readFile();
|
|
35
|
+
if (bytes.length > maxBytes) throw new Error("File exceeds 64 MiB");
|
|
36
|
+
return new Uint8Array(bytes);
|
|
37
|
+
} finally {
|
|
38
|
+
await handle.close();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async function write(path, bytes, replace) {
|
|
42
|
+
if (bytes.length > maxBytes) throw new Error("Output exceeds 64 MiB");
|
|
43
|
+
const temp = `${path}.${randomUUID()}.tmp`;
|
|
44
|
+
const handle = await open(temp, "wx", 384);
|
|
45
|
+
try {
|
|
46
|
+
await handle.writeFile(bytes);
|
|
47
|
+
await handle.sync();
|
|
48
|
+
} catch (error) {
|
|
49
|
+
await handle.close();
|
|
50
|
+
await unlink(temp).catch(() => {
|
|
51
|
+
});
|
|
52
|
+
throw error;
|
|
53
|
+
}
|
|
54
|
+
await handle.close();
|
|
55
|
+
try {
|
|
56
|
+
if (replace) await rename(temp, path);
|
|
57
|
+
else await link(temp, path);
|
|
58
|
+
} finally {
|
|
59
|
+
await unlink(temp).catch(() => {
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
async function serial(path, action) {
|
|
64
|
+
if (process.platform === "win32") path = path.toLowerCase();
|
|
65
|
+
const before = pending.get(path) ?? Promise.resolve();
|
|
66
|
+
const current = before.catch(() => {
|
|
67
|
+
}).then(action);
|
|
68
|
+
pending.set(path, current);
|
|
69
|
+
try {
|
|
70
|
+
return await current;
|
|
71
|
+
} finally {
|
|
72
|
+
if (pending.get(path) === current) pending.delete(path);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
async inspect(file, extensions, inspect) {
|
|
77
|
+
const path = await pathFor(file, extensions);
|
|
78
|
+
return serial(path, async () => inspect(await read(path)));
|
|
79
|
+
},
|
|
80
|
+
async create(file, extensions, create) {
|
|
81
|
+
const path = await pathFor(file, extensions);
|
|
82
|
+
return serial(path, async () => {
|
|
83
|
+
await write(path, await create(), false);
|
|
84
|
+
return { filePath: path, saved: true };
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
async edit(file, extensions, edit, outputPath) {
|
|
88
|
+
const path = await pathFor(file, extensions);
|
|
89
|
+
const output = outputPath ? await pathFor(outputPath, extensions) : path;
|
|
90
|
+
if (extname(output).toLowerCase() !== extname(path).toLowerCase())
|
|
91
|
+
throw new Error("Save-as must keep the source file extension");
|
|
92
|
+
return serial(path, async () => {
|
|
93
|
+
const { bytes, ...result } = await edit(await read(path));
|
|
94
|
+
await write(output, bytes, output === path);
|
|
95
|
+
return { ...result, filePath: output, saved: true };
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export { createFileOperations };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { VisioShape } from '../visio/model.js';
|
|
2
|
+
/** JSON-safe scene inspection without embedding binary images in tool responses. */
|
|
3
|
+
export interface VisioShapeSummary {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
kind: VisioShape['kind'];
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
transform: VisioShape['transform'];
|
|
10
|
+
text: string;
|
|
11
|
+
hidden: boolean;
|
|
12
|
+
shapeData: VisioShape['shapeData'];
|
|
13
|
+
hyperlinks: VisioShape['hyperlinks'];
|
|
14
|
+
children: VisioShapeSummary[];
|
|
15
|
+
}
|
|
16
|
+
export declare function inspectVisio(bytes: Uint8Array): Promise<{
|
|
17
|
+
pages: {
|
|
18
|
+
id: string;
|
|
19
|
+
name: string;
|
|
20
|
+
width: number;
|
|
21
|
+
height: number;
|
|
22
|
+
isBackground: boolean;
|
|
23
|
+
backgroundPageId: string | undefined;
|
|
24
|
+
shapes: VisioShapeSummary[];
|
|
25
|
+
connectors: import("../visio/model.js").VisioConnection[];
|
|
26
|
+
layers: import("../visio/model.js").VisioLayer[] | undefined;
|
|
27
|
+
}[];
|
|
28
|
+
diagnostics: import("../visio/model.js").VisioDiagnostic[];
|
|
29
|
+
}>;
|
|
30
|
+
//# sourceMappingURL=visio.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visio.d.ts","sourceRoot":"","sources":["../../src/automation/visio.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,oFAAoF;AACpF,MAAM,WAAW,iBAAiB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;IACnC,UAAU,EAAE,UAAU,CAAC,YAAY,CAAC,CAAC;IACrC,QAAQ,EAAE,iBAAiB,EAAE,CAAC;CAC9B;AAkBD,wBAAsB,YAAY,CAAC,KAAK,EAAE,UAAU;;;;;;;;;;;;;GAgBnD"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare function inspectXlsx(bytes: Uint8Array): Promise<{
|
|
2
|
+
sheets: {
|
|
3
|
+
index: number;
|
|
4
|
+
name: string;
|
|
5
|
+
}[];
|
|
6
|
+
properties: import("../xlsx/model.js").WorkbookProperties;
|
|
7
|
+
warnings: string[];
|
|
8
|
+
}>;
|
|
9
|
+
export declare function createXlsx(names: readonly string[]): Promise<Uint8Array>;
|
|
10
|
+
export declare function readXlsxRange(bytes: Uint8Array, sheetIndex: number, reference: string): Promise<{
|
|
11
|
+
cells: {
|
|
12
|
+
address: string;
|
|
13
|
+
value: string | number | boolean | import("../xlsx/model.js").CellError | null;
|
|
14
|
+
formula: string | undefined;
|
|
15
|
+
}[];
|
|
16
|
+
warnings: string[];
|
|
17
|
+
}>;
|
|
18
|
+
export declare function setXlsxCells(bytes: Uint8Array, sheetIndex: number, cells: readonly {
|
|
19
|
+
address: string;
|
|
20
|
+
input: string;
|
|
21
|
+
}[]): Promise<{
|
|
22
|
+
bytes: Uint8Array<ArrayBufferLike>;
|
|
23
|
+
warnings: string[];
|
|
24
|
+
}>;
|
|
25
|
+
//# sourceMappingURL=xlsx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xlsx.d.ts","sourceRoot":"","sources":["../../src/automation/xlsx.ts"],"names":[],"mappings":"AAOA,wBAAsB,WAAW,CAAC,KAAK,EAAE,UAAU;;;;;;;GAOlD;AAED,wBAAsB,UAAU,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAW9E;AAED,wBAAsB,aAAa,CAAC,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;;;;;;;GAoB3F;AAED,wBAAsB,YAAY,CACjC,KAAK,EAAE,UAAU,EACjB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,SAAS;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE;;;GAgBpD"}
|