@taloswork/ose-shared 0.1.14 → 0.1.16
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/package.json +3 -3
- package/skills/document/SKILL.md +2 -2
- package/skills/document/assets/fonts/fonts.json +1 -1
- package/skills/document/bin/deck-qa.cjs +2 -2
- package/skills/document/bin/doc-convert.cjs +627 -139
- package/skills/document/bin/html2pptx.cjs +27 -3
- package/skills/document/bin/ocr.cjs +7 -2
- package/skills/document/bin-reference.md +1 -1
- package/skills/expert-create/LICENSE.txt +7 -0
- package/skills/expert-create/SKILL.md +106 -0
- package/skills/expert-create/bin/expert-create.cjs +96 -0
- package/skills/expert-create/references/role-guide.md +24 -0
- package/skills/image-layout/SKILL.md +3 -3
|
@@ -315,7 +315,7 @@ var require_BufferList = __commonJS({
|
|
|
315
315
|
this.head = this.tail = null;
|
|
316
316
|
this.length = 0;
|
|
317
317
|
};
|
|
318
|
-
BufferList.prototype.join = function
|
|
318
|
+
BufferList.prototype.join = function join7(s) {
|
|
319
319
|
if (this.length === 0) return "";
|
|
320
320
|
var p = this.head;
|
|
321
321
|
var ret2 = "" + p.data;
|
|
@@ -9790,9 +9790,9 @@ var require_load = __commonJS({
|
|
|
9790
9790
|
var require_lib3 = __commonJS({
|
|
9791
9791
|
"node_modules/jszip/lib/index.js"(exports2, module2) {
|
|
9792
9792
|
"use strict";
|
|
9793
|
-
function
|
|
9794
|
-
if (!(this instanceof
|
|
9795
|
-
return new
|
|
9793
|
+
function JSZip5() {
|
|
9794
|
+
if (!(this instanceof JSZip5)) {
|
|
9795
|
+
return new JSZip5();
|
|
9796
9796
|
}
|
|
9797
9797
|
if (arguments.length) {
|
|
9798
9798
|
throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");
|
|
@@ -9801,7 +9801,7 @@ var require_lib3 = __commonJS({
|
|
|
9801
9801
|
this.comment = null;
|
|
9802
9802
|
this.root = "";
|
|
9803
9803
|
this.clone = function() {
|
|
9804
|
-
var newObj = new
|
|
9804
|
+
var newObj = new JSZip5();
|
|
9805
9805
|
for (var i in this) {
|
|
9806
9806
|
if (typeof this[i] !== "function") {
|
|
9807
9807
|
newObj[i] = this[i];
|
|
@@ -9810,16 +9810,16 @@ var require_lib3 = __commonJS({
|
|
|
9810
9810
|
return newObj;
|
|
9811
9811
|
};
|
|
9812
9812
|
}
|
|
9813
|
-
|
|
9814
|
-
|
|
9815
|
-
|
|
9816
|
-
|
|
9817
|
-
|
|
9818
|
-
|
|
9819
|
-
return new
|
|
9813
|
+
JSZip5.prototype = require_object();
|
|
9814
|
+
JSZip5.prototype.loadAsync = require_load();
|
|
9815
|
+
JSZip5.support = require_support();
|
|
9816
|
+
JSZip5.defaults = require_defaults();
|
|
9817
|
+
JSZip5.version = "3.10.1";
|
|
9818
|
+
JSZip5.loadAsync = function(content, options) {
|
|
9819
|
+
return new JSZip5().loadAsync(content, options);
|
|
9820
9820
|
};
|
|
9821
|
-
|
|
9822
|
-
module2.exports =
|
|
9821
|
+
JSZip5.external = require_external();
|
|
9822
|
+
module2.exports = JSZip5;
|
|
9823
9823
|
}
|
|
9824
9824
|
});
|
|
9825
9825
|
|
|
@@ -18401,12 +18401,12 @@ var require_base64_js = __commonJS({
|
|
|
18401
18401
|
var require_zipfile = __commonJS({
|
|
18402
18402
|
"node_modules/mammoth/lib/zipfile.js"(exports2) {
|
|
18403
18403
|
var base64js = require_base64_js();
|
|
18404
|
-
var
|
|
18404
|
+
var JSZip5 = require_lib3();
|
|
18405
18405
|
exports2.openArrayBuffer = openArrayBuffer;
|
|
18406
18406
|
exports2.splitPath = splitPath;
|
|
18407
18407
|
exports2.joinPath = joinPath;
|
|
18408
18408
|
function openArrayBuffer(arrayBuffer) {
|
|
18409
|
-
return
|
|
18409
|
+
return JSZip5.loadAsync(arrayBuffer).then(function(zipFile) {
|
|
18410
18410
|
function exists(name) {
|
|
18411
18411
|
return zipFile.file(name) !== null;
|
|
18412
18412
|
}
|
|
@@ -28105,16 +28105,16 @@ var require_path_is_absolute = __commonJS({
|
|
|
28105
28105
|
function posix2(path) {
|
|
28106
28106
|
return path.charAt(0) === "/";
|
|
28107
28107
|
}
|
|
28108
|
-
function
|
|
28108
|
+
function win323(path) {
|
|
28109
28109
|
var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/;
|
|
28110
28110
|
var result2 = splitDeviceRe.exec(path);
|
|
28111
28111
|
var device = result2[1] || "";
|
|
28112
28112
|
var isUnc = Boolean(device && device.charAt(1) !== ":");
|
|
28113
28113
|
return Boolean(result2[2] || isUnc);
|
|
28114
28114
|
}
|
|
28115
|
-
module2.exports = process.platform === "win32" ?
|
|
28115
|
+
module2.exports = process.platform === "win32" ? win323 : posix2;
|
|
28116
28116
|
module2.exports.posix = posix2;
|
|
28117
|
-
module2.exports.win32 =
|
|
28117
|
+
module2.exports.win32 = win323;
|
|
28118
28118
|
}
|
|
28119
28119
|
});
|
|
28120
28120
|
|
|
@@ -28142,7 +28142,7 @@ var require_files = __commonJS({
|
|
|
28142
28142
|
var base = options.relativeToFile ? dirname2(options.relativeToFile) : null;
|
|
28143
28143
|
function read(uri, encoding) {
|
|
28144
28144
|
return resolveUri(uri).then(function(path) {
|
|
28145
|
-
return
|
|
28145
|
+
return readFile7(path, encoding).caught(function(error) {
|
|
28146
28146
|
var message = "could not open external image: '" + uri + "' (document directory: '" + base + "')\n" + error.message;
|
|
28147
28147
|
return promises.reject(new Error(message));
|
|
28148
28148
|
});
|
|
@@ -28162,7 +28162,7 @@ var require_files = __commonJS({
|
|
|
28162
28162
|
read
|
|
28163
28163
|
};
|
|
28164
28164
|
}
|
|
28165
|
-
var
|
|
28165
|
+
var readFile7 = promises.promisify(fs.readFile.bind(fs));
|
|
28166
28166
|
function uriToPath(uriString, platform) {
|
|
28167
28167
|
if (!platform) {
|
|
28168
28168
|
platform = os.platform();
|
|
@@ -30879,10 +30879,10 @@ var require_unzip = __commonJS({
|
|
|
30879
30879
|
var promises = require_promises();
|
|
30880
30880
|
var zipfile = require_zipfile();
|
|
30881
30881
|
exports2.openZip = openZip;
|
|
30882
|
-
var
|
|
30882
|
+
var readFile7 = promises.promisify(fs.readFile);
|
|
30883
30883
|
function openZip(options) {
|
|
30884
30884
|
if (options.path) {
|
|
30885
|
-
return
|
|
30885
|
+
return readFile7(options.path).then(zipfile.openArrayBuffer);
|
|
30886
30886
|
} else if (options.buffer) {
|
|
30887
30887
|
return promises.resolve(zipfile.openArrayBuffer(options.buffer));
|
|
30888
30888
|
} else if (options.file) {
|
|
@@ -35136,7 +35136,7 @@ var require_buffer_list2 = __commonJS({
|
|
|
35136
35136
|
}
|
|
35137
35137
|
}, {
|
|
35138
35138
|
key: "join",
|
|
35139
|
-
value: function
|
|
35139
|
+
value: function join7(s) {
|
|
35140
35140
|
if (this.length === 0) return "";
|
|
35141
35141
|
var p = this.head;
|
|
35142
35142
|
var ret2 = "" + p.data;
|
|
@@ -37915,7 +37915,7 @@ var require_browser_buffer_encode = __commonJS({
|
|
|
37915
37915
|
var require_zip_stream = __commonJS({
|
|
37916
37916
|
"node_modules/exceljs/lib/utils/zip-stream.js"(exports2, module2) {
|
|
37917
37917
|
var events = require("events");
|
|
37918
|
-
var
|
|
37918
|
+
var JSZip5 = require_lib3();
|
|
37919
37919
|
var StreamBuf = require_stream_buf();
|
|
37920
37920
|
var { stringToBuffer } = require_browser_buffer_encode();
|
|
37921
37921
|
var ZipWriter = class extends events.EventEmitter {
|
|
@@ -37928,7 +37928,7 @@ var require_zip_stream = __commonJS({
|
|
|
37928
37928
|
},
|
|
37929
37929
|
options
|
|
37930
37930
|
);
|
|
37931
|
-
this.zip = new
|
|
37931
|
+
this.zip = new JSZip5();
|
|
37932
37932
|
this.stream = new StreamBuf();
|
|
37933
37933
|
}
|
|
37934
37934
|
append(data, options) {
|
|
@@ -49608,7 +49608,7 @@ var require_theme1 = __commonJS({
|
|
|
49608
49608
|
var require_xlsx = __commonJS({
|
|
49609
49609
|
"node_modules/exceljs/lib/xlsx/xlsx.js"(exports2, module2) {
|
|
49610
49610
|
var fs = require("fs");
|
|
49611
|
-
var
|
|
49611
|
+
var JSZip5 = require_lib3();
|
|
49612
49612
|
var { PassThrough } = require_readable2();
|
|
49613
49613
|
var ZipStream = require_zip_stream();
|
|
49614
49614
|
var StreamBuf = require_stream_buf();
|
|
@@ -49847,7 +49847,7 @@ var require_xlsx = __commonJS({
|
|
|
49847
49847
|
tables: {},
|
|
49848
49848
|
vmlDrawings: {}
|
|
49849
49849
|
};
|
|
49850
|
-
const zip = await
|
|
49850
|
+
const zip = await JSZip5.loadAsync(buffer);
|
|
49851
49851
|
for (const entry of Object.values(zip.files)) {
|
|
49852
49852
|
if (!entry.dir) {
|
|
49853
49853
|
let entryName = entry.name;
|
|
@@ -55546,7 +55546,7 @@ var require_readdir_glob = __commonJS({
|
|
|
55546
55546
|
});
|
|
55547
55547
|
});
|
|
55548
55548
|
}
|
|
55549
|
-
function
|
|
55549
|
+
function stat2(file, followSymlinks) {
|
|
55550
55550
|
return new Promise((resolve2, reject2) => {
|
|
55551
55551
|
const statFunc = followSymlinks ? fs.stat : fs.lstat;
|
|
55552
55552
|
statFunc(file, (err, stats) => {
|
|
@@ -55554,7 +55554,7 @@ var require_readdir_glob = __commonJS({
|
|
|
55554
55554
|
switch (err.code) {
|
|
55555
55555
|
case "ENOENT":
|
|
55556
55556
|
if (followSymlinks) {
|
|
55557
|
-
resolve2(
|
|
55557
|
+
resolve2(stat2(file, false));
|
|
55558
55558
|
} else {
|
|
55559
55559
|
resolve2(null);
|
|
55560
55560
|
}
|
|
@@ -55582,7 +55582,7 @@ var require_readdir_glob = __commonJS({
|
|
|
55582
55582
|
const absolute = path + "/" + relative;
|
|
55583
55583
|
let stats = null;
|
|
55584
55584
|
if (useStat || followSymlinks) {
|
|
55585
|
-
stats = await
|
|
55585
|
+
stats = await stat2(absolute, followSymlinks);
|
|
55586
55586
|
}
|
|
55587
55587
|
if (!stats && file.name !== void 0) {
|
|
55588
55588
|
stats = file;
|
|
@@ -57654,7 +57654,7 @@ var require_polyfills = __commonJS({
|
|
|
57654
57654
|
}
|
|
57655
57655
|
if (platform === "win32") {
|
|
57656
57656
|
fs.rename = typeof fs.rename !== "function" ? fs.rename : (function(fs$rename) {
|
|
57657
|
-
function
|
|
57657
|
+
function rename3(from, to, cb2) {
|
|
57658
57658
|
var start = Date.now();
|
|
57659
57659
|
var backoff = 0;
|
|
57660
57660
|
fs$rename(from, to, function CB(er) {
|
|
@@ -57674,8 +57674,8 @@ var require_polyfills = __commonJS({
|
|
|
57674
57674
|
if (cb2) cb2(er);
|
|
57675
57675
|
});
|
|
57676
57676
|
}
|
|
57677
|
-
if (Object.setPrototypeOf) Object.setPrototypeOf(
|
|
57678
|
-
return
|
|
57677
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(rename3, fs$rename);
|
|
57678
|
+
return rename3;
|
|
57679
57679
|
})(fs.rename);
|
|
57680
57680
|
}
|
|
57681
57681
|
fs.read = typeof fs.read !== "function" ? fs.read : (function(fs$read) {
|
|
@@ -58079,8 +58079,8 @@ var require_graceful_fs = __commonJS({
|
|
|
58079
58079
|
fs2.createReadStream = createReadStream;
|
|
58080
58080
|
fs2.createWriteStream = createWriteStream;
|
|
58081
58081
|
var fs$readFile = fs2.readFile;
|
|
58082
|
-
fs2.readFile =
|
|
58083
|
-
function
|
|
58082
|
+
fs2.readFile = readFile7;
|
|
58083
|
+
function readFile7(path, options, cb2) {
|
|
58084
58084
|
if (typeof options === "function")
|
|
58085
58085
|
cb2 = options, options = null;
|
|
58086
58086
|
return go$readFile(path, options, cb2);
|
|
@@ -58096,8 +58096,8 @@ var require_graceful_fs = __commonJS({
|
|
|
58096
58096
|
}
|
|
58097
58097
|
}
|
|
58098
58098
|
var fs$writeFile = fs2.writeFile;
|
|
58099
|
-
fs2.writeFile =
|
|
58100
|
-
function
|
|
58099
|
+
fs2.writeFile = writeFile6;
|
|
58100
|
+
function writeFile6(path, data, options, cb2) {
|
|
58101
58101
|
if (typeof options === "function")
|
|
58102
58102
|
cb2 = options, options = null;
|
|
58103
58103
|
return go$writeFile(path, data, options, cb2);
|
|
@@ -59636,15 +59636,15 @@ var require_old = __commonJS({
|
|
|
59636
59636
|
if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
|
|
59637
59637
|
resolvedLink = cache[base];
|
|
59638
59638
|
} else {
|
|
59639
|
-
var
|
|
59640
|
-
if (!
|
|
59639
|
+
var stat2 = fs.lstatSync(base);
|
|
59640
|
+
if (!stat2.isSymbolicLink()) {
|
|
59641
59641
|
knownHard[base] = true;
|
|
59642
59642
|
if (cache) cache[base] = base;
|
|
59643
59643
|
continue;
|
|
59644
59644
|
}
|
|
59645
59645
|
var linkTarget = null;
|
|
59646
59646
|
if (!isWindows) {
|
|
59647
|
-
var id =
|
|
59647
|
+
var id = stat2.dev.toString(32) + ":" + stat2.ino.toString(32);
|
|
59648
59648
|
if (seenLinks.hasOwnProperty(id)) {
|
|
59649
59649
|
linkTarget = seenLinks[id];
|
|
59650
59650
|
}
|
|
@@ -59713,15 +59713,15 @@ var require_old = __commonJS({
|
|
|
59713
59713
|
}
|
|
59714
59714
|
return fs.lstat(base, gotStat);
|
|
59715
59715
|
}
|
|
59716
|
-
function gotStat(err,
|
|
59716
|
+
function gotStat(err, stat2) {
|
|
59717
59717
|
if (err) return cb2(err);
|
|
59718
|
-
if (!
|
|
59718
|
+
if (!stat2.isSymbolicLink()) {
|
|
59719
59719
|
knownHard[base] = true;
|
|
59720
59720
|
if (cache) cache[base] = base;
|
|
59721
59721
|
return process.nextTick(LOOP);
|
|
59722
59722
|
}
|
|
59723
59723
|
if (!isWindows) {
|
|
59724
|
-
var id =
|
|
59724
|
+
var id = stat2.dev.toString(32) + ":" + stat2.ino.toString(32);
|
|
59725
59725
|
if (seenLinks.hasOwnProperty(id)) {
|
|
59726
59726
|
return gotTarget(null, seenLinks[id], base);
|
|
59727
59727
|
}
|
|
@@ -61076,7 +61076,7 @@ var require_sync = __commonJS({
|
|
|
61076
61076
|
return this._readdir(abs, false);
|
|
61077
61077
|
var entries;
|
|
61078
61078
|
var lstat;
|
|
61079
|
-
var
|
|
61079
|
+
var stat2;
|
|
61080
61080
|
try {
|
|
61081
61081
|
lstat = this.fs.lstatSync(abs);
|
|
61082
61082
|
} catch (er) {
|
|
@@ -61211,8 +61211,8 @@ var require_sync = __commonJS({
|
|
|
61211
61211
|
return false;
|
|
61212
61212
|
}
|
|
61213
61213
|
var exists;
|
|
61214
|
-
var
|
|
61215
|
-
if (!
|
|
61214
|
+
var stat2 = this.statCache[abs];
|
|
61215
|
+
if (!stat2) {
|
|
61216
61216
|
var lstat;
|
|
61217
61217
|
try {
|
|
61218
61218
|
lstat = this.fs.lstatSync(abs);
|
|
@@ -61224,18 +61224,18 @@ var require_sync = __commonJS({
|
|
|
61224
61224
|
}
|
|
61225
61225
|
if (lstat && lstat.isSymbolicLink()) {
|
|
61226
61226
|
try {
|
|
61227
|
-
|
|
61227
|
+
stat2 = this.fs.statSync(abs);
|
|
61228
61228
|
} catch (er) {
|
|
61229
|
-
|
|
61229
|
+
stat2 = lstat;
|
|
61230
61230
|
}
|
|
61231
61231
|
} else {
|
|
61232
|
-
|
|
61232
|
+
stat2 = lstat;
|
|
61233
61233
|
}
|
|
61234
61234
|
}
|
|
61235
|
-
this.statCache[abs] =
|
|
61235
|
+
this.statCache[abs] = stat2;
|
|
61236
61236
|
var c = true;
|
|
61237
|
-
if (
|
|
61238
|
-
c =
|
|
61237
|
+
if (stat2)
|
|
61238
|
+
c = stat2.isDirectory() ? "DIR" : "FILE";
|
|
61239
61239
|
this.cache[abs] = this.cache[abs] || c;
|
|
61240
61240
|
if (needDir && c === "FILE")
|
|
61241
61241
|
return false;
|
|
@@ -61877,16 +61877,16 @@ var require_glob = __commonJS({
|
|
|
61877
61877
|
return cb2();
|
|
61878
61878
|
}
|
|
61879
61879
|
var exists;
|
|
61880
|
-
var
|
|
61881
|
-
if (
|
|
61882
|
-
if (
|
|
61883
|
-
return cb2(null,
|
|
61880
|
+
var stat2 = this.statCache[abs];
|
|
61881
|
+
if (stat2 !== void 0) {
|
|
61882
|
+
if (stat2 === false)
|
|
61883
|
+
return cb2(null, stat2);
|
|
61884
61884
|
else {
|
|
61885
|
-
var type =
|
|
61885
|
+
var type = stat2.isDirectory() ? "DIR" : "FILE";
|
|
61886
61886
|
if (needDir && type === "FILE")
|
|
61887
61887
|
return cb2();
|
|
61888
61888
|
else
|
|
61889
|
-
return cb2(null, type,
|
|
61889
|
+
return cb2(null, type, stat2);
|
|
61890
61890
|
}
|
|
61891
61891
|
}
|
|
61892
61892
|
var self2 = this;
|
|
@@ -61895,33 +61895,33 @@ var require_glob = __commonJS({
|
|
|
61895
61895
|
self2.fs.lstat(abs, statcb);
|
|
61896
61896
|
function lstatcb_(er, lstat) {
|
|
61897
61897
|
if (lstat && lstat.isSymbolicLink()) {
|
|
61898
|
-
return self2.fs.stat(abs, function(er2,
|
|
61898
|
+
return self2.fs.stat(abs, function(er2, stat3) {
|
|
61899
61899
|
if (er2)
|
|
61900
61900
|
self2._stat2(f, abs, null, lstat, cb2);
|
|
61901
61901
|
else
|
|
61902
|
-
self2._stat2(f, abs, er2,
|
|
61902
|
+
self2._stat2(f, abs, er2, stat3, cb2);
|
|
61903
61903
|
});
|
|
61904
61904
|
} else {
|
|
61905
61905
|
self2._stat2(f, abs, er, lstat, cb2);
|
|
61906
61906
|
}
|
|
61907
61907
|
}
|
|
61908
61908
|
};
|
|
61909
|
-
Glob.prototype._stat2 = function(f, abs, er,
|
|
61909
|
+
Glob.prototype._stat2 = function(f, abs, er, stat2, cb2) {
|
|
61910
61910
|
if (er && (er.code === "ENOENT" || er.code === "ENOTDIR")) {
|
|
61911
61911
|
this.statCache[abs] = false;
|
|
61912
61912
|
return cb2();
|
|
61913
61913
|
}
|
|
61914
61914
|
var needDir = f.slice(-1) === "/";
|
|
61915
|
-
this.statCache[abs] =
|
|
61916
|
-
if (abs.slice(-1) === "/" &&
|
|
61917
|
-
return cb2(null, false,
|
|
61915
|
+
this.statCache[abs] = stat2;
|
|
61916
|
+
if (abs.slice(-1) === "/" && stat2 && !stat2.isDirectory())
|
|
61917
|
+
return cb2(null, false, stat2);
|
|
61918
61918
|
var c = true;
|
|
61919
|
-
if (
|
|
61920
|
-
c =
|
|
61919
|
+
if (stat2)
|
|
61920
|
+
c = stat2.isDirectory() ? "DIR" : "FILE";
|
|
61921
61921
|
this.cache[abs] = this.cache[abs] || c;
|
|
61922
61922
|
if (needDir && c === "FILE")
|
|
61923
61923
|
return cb2();
|
|
61924
|
-
return cb2(null, c,
|
|
61924
|
+
return cb2(null, c, stat2);
|
|
61925
61925
|
};
|
|
61926
61926
|
}
|
|
61927
61927
|
});
|
|
@@ -62361,7 +62361,7 @@ var require_buffer_list3 = __commonJS({
|
|
|
62361
62361
|
}
|
|
62362
62362
|
}, {
|
|
62363
62363
|
key: "join",
|
|
62364
|
-
value: function
|
|
62364
|
+
value: function join7(s) {
|
|
62365
62365
|
if (this.length === 0) return "";
|
|
62366
62366
|
var p = this.head;
|
|
62367
62367
|
var ret2 = "" + p.data;
|
|
@@ -64619,7 +64619,7 @@ var require_core = __commonJS({
|
|
|
64619
64619
|
var inherits2 = require("util").inherits;
|
|
64620
64620
|
var ArchiverError = require_error();
|
|
64621
64621
|
var Transform = require_readable3().Transform;
|
|
64622
|
-
var
|
|
64622
|
+
var win323 = process.platform === "win32";
|
|
64623
64623
|
var Archiver = function(format, options) {
|
|
64624
64624
|
if (!(this instanceof Archiver)) {
|
|
64625
64625
|
return new Archiver(format, options);
|
|
@@ -64792,18 +64792,18 @@ var require_core = __commonJS({
|
|
|
64792
64792
|
}
|
|
64793
64793
|
}
|
|
64794
64794
|
if (typeof data.mode === "number") {
|
|
64795
|
-
if (
|
|
64795
|
+
if (win323) {
|
|
64796
64796
|
data.mode &= 511;
|
|
64797
64797
|
} else {
|
|
64798
64798
|
data.mode &= 4095;
|
|
64799
64799
|
}
|
|
64800
64800
|
} else if (data.stats && data.mode === null) {
|
|
64801
|
-
if (
|
|
64801
|
+
if (win323) {
|
|
64802
64802
|
data.mode = data.stats.mode & 511;
|
|
64803
64803
|
} else {
|
|
64804
64804
|
data.mode = data.stats.mode & 4095;
|
|
64805
64805
|
}
|
|
64806
|
-
if (
|
|
64806
|
+
if (win323 && isDir) {
|
|
64807
64807
|
data.mode = 493;
|
|
64808
64808
|
}
|
|
64809
64809
|
} else if (data.mode === null) {
|
|
@@ -65727,7 +65727,7 @@ var require_buffer_list4 = __commonJS({
|
|
|
65727
65727
|
}
|
|
65728
65728
|
}, {
|
|
65729
65729
|
key: "join",
|
|
65730
|
-
value: function
|
|
65730
|
+
value: function join7(s) {
|
|
65731
65731
|
if (this.length === 0) return "";
|
|
65732
65732
|
var p = this.head;
|
|
65733
65733
|
var ret2 = "" + p.data;
|
|
@@ -68523,7 +68523,7 @@ var require_buffer_list5 = __commonJS({
|
|
|
68523
68523
|
}
|
|
68524
68524
|
}, {
|
|
68525
68525
|
key: "join",
|
|
68526
|
-
value: function
|
|
68526
|
+
value: function join7(s) {
|
|
68527
68527
|
if (this.length === 0) return "";
|
|
68528
68528
|
var p = this.head;
|
|
68529
68529
|
var ret2 = "" + p.data;
|
|
@@ -71393,7 +71393,7 @@ var require_buffer_list6 = __commonJS({
|
|
|
71393
71393
|
}
|
|
71394
71394
|
}, {
|
|
71395
71395
|
key: "join",
|
|
71396
|
-
value: function
|
|
71396
|
+
value: function join7(s) {
|
|
71397
71397
|
if (this.length === 0) return "";
|
|
71398
71398
|
var p = this.head;
|
|
71399
71399
|
var ret2 = "" + p.data;
|
|
@@ -74182,7 +74182,7 @@ var require_buffer_list7 = __commonJS({
|
|
|
74182
74182
|
}
|
|
74183
74183
|
}, {
|
|
74184
74184
|
key: "join",
|
|
74185
|
-
value: function
|
|
74185
|
+
value: function join7(s) {
|
|
74186
74186
|
if (this.length === 0) return "";
|
|
74187
74187
|
var p = this.head;
|
|
74188
74188
|
var ret2 = "" + p.data;
|
|
@@ -77172,7 +77172,7 @@ var require_buffer_list8 = __commonJS({
|
|
|
77172
77172
|
}
|
|
77173
77173
|
}, {
|
|
77174
77174
|
key: "join",
|
|
77175
|
-
value: function
|
|
77175
|
+
value: function join7(s) {
|
|
77176
77176
|
if (this.length === 0) return "";
|
|
77177
77177
|
var p = this.head;
|
|
77178
77178
|
var ret2 = "" + p.data;
|
|
@@ -82364,7 +82364,7 @@ var require_BufferList3 = __commonJS({
|
|
|
82364
82364
|
this.head = this.tail = null;
|
|
82365
82365
|
this.length = 0;
|
|
82366
82366
|
};
|
|
82367
|
-
BufferList.prototype.join = function
|
|
82367
|
+
BufferList.prototype.join = function join7(s) {
|
|
82368
82368
|
if (this.length === 0) return "";
|
|
82369
82369
|
var p = this.head;
|
|
82370
82370
|
var ret2 = "" + p.data;
|
|
@@ -84543,17 +84543,17 @@ var require_dir_reader = __commonJS({
|
|
|
84543
84543
|
assert(p !== self2._path);
|
|
84544
84544
|
assert(self2.entries[self2._index]);
|
|
84545
84545
|
self2._currentEntry = p;
|
|
84546
|
-
fs[self2.props.follow ? "stat" : "lstat"](p, function(er,
|
|
84546
|
+
fs[self2.props.follow ? "stat" : "lstat"](p, function(er, stat2) {
|
|
84547
84547
|
if (er) return self2.error(er);
|
|
84548
84548
|
var who = self2._proxy || self2;
|
|
84549
|
-
|
|
84550
|
-
|
|
84551
|
-
|
|
84552
|
-
var childProps = self2.getChildProps.call(who,
|
|
84549
|
+
stat2.path = p;
|
|
84550
|
+
stat2.basename = path.basename(p);
|
|
84551
|
+
stat2.dirname = path.dirname(p);
|
|
84552
|
+
var childProps = self2.getChildProps.call(who, stat2);
|
|
84553
84553
|
childProps.path = p;
|
|
84554
84554
|
childProps.basename = path.basename(p);
|
|
84555
84555
|
childProps.dirname = path.dirname(p);
|
|
84556
|
-
var entry = Reader(childProps,
|
|
84556
|
+
var entry = Reader(childProps, stat2);
|
|
84557
84557
|
self2._currentEntry = entry;
|
|
84558
84558
|
entry.on("pause", function(who2) {
|
|
84559
84559
|
if (!self2._paused && !entry._disowned) {
|
|
@@ -84826,8 +84826,8 @@ var require_proxy_reader = __commonJS({
|
|
|
84826
84826
|
ProxyReader.prototype._stat = function() {
|
|
84827
84827
|
var self2 = this;
|
|
84828
84828
|
var props = self2.props;
|
|
84829
|
-
var
|
|
84830
|
-
fs[
|
|
84829
|
+
var stat2 = props.follow ? "stat" : "lstat";
|
|
84830
|
+
fs[stat2](props.path, function(er, current) {
|
|
84831
84831
|
var type;
|
|
84832
84832
|
if (er || !current) {
|
|
84833
84833
|
type = "File";
|
|
@@ -84976,9 +84976,9 @@ var require_reader2 = __commonJS({
|
|
|
84976
84976
|
Reader.prototype._stat = function(currentStat) {
|
|
84977
84977
|
var self2 = this;
|
|
84978
84978
|
var props = self2.props;
|
|
84979
|
-
var
|
|
84979
|
+
var stat2 = props.follow ? "stat" : "lstat";
|
|
84980
84980
|
if (currentStat) process.nextTick(statCb.bind(null, null, currentStat));
|
|
84981
|
-
else fs[
|
|
84981
|
+
else fs[stat2](self2._path, statCb);
|
|
84982
84982
|
function statCb(er, props_) {
|
|
84983
84983
|
if (er) return self2.error(er);
|
|
84984
84984
|
Object.keys(props_).forEach(function(k2) {
|
|
@@ -85121,7 +85121,7 @@ var require_rimraf = __commonJS({
|
|
|
85121
85121
|
var n = 0;
|
|
85122
85122
|
if (options.disableGlob || !glob.hasMagic(p))
|
|
85123
85123
|
return afterGlob(null, [p]);
|
|
85124
|
-
options.lstat(p, function(er,
|
|
85124
|
+
options.lstat(p, function(er, stat2) {
|
|
85125
85125
|
if (!er)
|
|
85126
85126
|
return afterGlob(null, [p]);
|
|
85127
85127
|
glob(p, options.glob, afterGlob);
|
|
@@ -85394,8 +85394,8 @@ var require_mkdirp = __commonJS({
|
|
|
85394
85394
|
// there already. If so, then hooray! If not, then something
|
|
85395
85395
|
// is borked.
|
|
85396
85396
|
default:
|
|
85397
|
-
xfs.stat(p, function(er2,
|
|
85398
|
-
if (er2 || !
|
|
85397
|
+
xfs.stat(p, function(er2, stat2) {
|
|
85398
|
+
if (er2 || !stat2.isDirectory()) cb2(er, made);
|
|
85399
85399
|
else cb2(null, made);
|
|
85400
85400
|
});
|
|
85401
85401
|
break;
|
|
@@ -85426,13 +85426,13 @@ var require_mkdirp = __commonJS({
|
|
|
85426
85426
|
// there already. If so, then hooray! If not, then something
|
|
85427
85427
|
// is borked.
|
|
85428
85428
|
default:
|
|
85429
|
-
var
|
|
85429
|
+
var stat2;
|
|
85430
85430
|
try {
|
|
85431
|
-
|
|
85431
|
+
stat2 = xfs.statSync(p);
|
|
85432
85432
|
} catch (err1) {
|
|
85433
85433
|
throw err0;
|
|
85434
85434
|
}
|
|
85435
|
-
if (!
|
|
85435
|
+
if (!stat2.isDirectory()) throw err0;
|
|
85436
85436
|
break;
|
|
85437
85437
|
}
|
|
85438
85438
|
}
|
|
@@ -85503,7 +85503,7 @@ var require_dir_writer = __commonJS({
|
|
|
85503
85503
|
module2.exports = DirWriter;
|
|
85504
85504
|
var Writer = require_writer2();
|
|
85505
85505
|
var inherits2 = require_inherits();
|
|
85506
|
-
var
|
|
85506
|
+
var mkdir4 = require_mkdirp();
|
|
85507
85507
|
var path = require("path");
|
|
85508
85508
|
var collect = require_collect();
|
|
85509
85509
|
inherits2(DirWriter, Writer);
|
|
@@ -85519,7 +85519,7 @@ var require_dir_writer = __commonJS({
|
|
|
85519
85519
|
}
|
|
85520
85520
|
DirWriter.prototype._create = function() {
|
|
85521
85521
|
var self2 = this;
|
|
85522
|
-
|
|
85522
|
+
mkdir4(self2._path, Writer.dirmode, function(er) {
|
|
85523
85523
|
if (er) return self2.error(er);
|
|
85524
85524
|
self2.ready = true;
|
|
85525
85525
|
self2.emit("ready");
|
|
@@ -85792,8 +85792,8 @@ var require_proxy_writer = __commonJS({
|
|
|
85792
85792
|
ProxyWriter.prototype._stat = function() {
|
|
85793
85793
|
var self2 = this;
|
|
85794
85794
|
var props = self2.props;
|
|
85795
|
-
var
|
|
85796
|
-
fs[
|
|
85795
|
+
var stat2 = props.follow ? "stat" : "lstat";
|
|
85796
|
+
fs[stat2](props.path, function(er, current) {
|
|
85797
85797
|
var type;
|
|
85798
85798
|
if (er || !current) {
|
|
85799
85799
|
type = "File";
|
|
@@ -85864,7 +85864,7 @@ var require_writer2 = __commonJS({
|
|
|
85864
85864
|
var fs = require_graceful_fs();
|
|
85865
85865
|
var inherits2 = require_inherits();
|
|
85866
85866
|
var rimraf = require_rimraf();
|
|
85867
|
-
var
|
|
85867
|
+
var mkdir4 = require_mkdirp();
|
|
85868
85868
|
var path = require("path");
|
|
85869
85869
|
var umask = process.platform === "win32" ? 0 : process.umask();
|
|
85870
85870
|
var getType = require_get_type();
|
|
@@ -85943,10 +85943,10 @@ var require_writer2 = __commonJS({
|
|
|
85943
85943
|
Writer.prototype._stat = function(current) {
|
|
85944
85944
|
var self2 = this;
|
|
85945
85945
|
var props = self2.props;
|
|
85946
|
-
var
|
|
85946
|
+
var stat2 = props.follow ? "stat" : "lstat";
|
|
85947
85947
|
var who = self2._proxy || self2;
|
|
85948
85948
|
if (current) statCb(null, current);
|
|
85949
|
-
else fs[
|
|
85949
|
+
else fs[stat2](self2._path, statCb);
|
|
85950
85950
|
function statCb(er, current2) {
|
|
85951
85951
|
if (self2.filter && !self2.filter.call(who, who, current2)) {
|
|
85952
85952
|
self2._aborted = true;
|
|
@@ -85970,7 +85970,7 @@ var require_writer2 = __commonJS({
|
|
|
85970
85970
|
}
|
|
85971
85971
|
};
|
|
85972
85972
|
function create2(self2) {
|
|
85973
|
-
|
|
85973
|
+
mkdir4(path.dirname(self2._path), Writer.dirmode, function(er, made) {
|
|
85974
85974
|
if (er) return self2.error(er);
|
|
85975
85975
|
self2._madeDir = made;
|
|
85976
85976
|
return self2._create();
|
|
@@ -86027,8 +86027,8 @@ var require_writer2 = __commonJS({
|
|
|
86027
86027
|
self2._old.mtime = /* @__PURE__ */ new Date(0);
|
|
86028
86028
|
setProps(self2._old);
|
|
86029
86029
|
} else {
|
|
86030
|
-
var
|
|
86031
|
-
fs[
|
|
86030
|
+
var stat2 = self2.props.follow ? "stat" : "lstat";
|
|
86031
|
+
fs[stat2](self2._path, function(er, current) {
|
|
86032
86032
|
if (er) {
|
|
86033
86033
|
if (er.code === "ENOENT" && (self2.type === "Link" || self2.type === "SymbolicLink") && process.platform === "win32") {
|
|
86034
86034
|
self2.ready = true;
|
|
@@ -88191,8 +88191,8 @@ var require_tmp = __commonJS({
|
|
|
88191
88191
|
function _isENOENT(error) {
|
|
88192
88192
|
return _isExpectedError(error, -ENOENT, "ENOENT");
|
|
88193
88193
|
}
|
|
88194
|
-
function _isExpectedError(error,
|
|
88195
|
-
return IS_WIN32 ? error.code === code : error.code === code && error.errno ===
|
|
88194
|
+
function _isExpectedError(error, errno2, code) {
|
|
88195
|
+
return IS_WIN32 ? error.code === code : error.code === code && error.errno === errno2;
|
|
88196
88196
|
}
|
|
88197
88197
|
function setGracefulCleanup() {
|
|
88198
88198
|
_gracefulCleanup = true;
|
|
@@ -89021,9 +89021,9 @@ var require_excel = __commonJS({
|
|
|
89021
89021
|
});
|
|
89022
89022
|
|
|
89023
89023
|
// apps/admin/data/skills.lib/document/bin-src/doc-convert.mjs
|
|
89024
|
-
var
|
|
89025
|
-
var
|
|
89026
|
-
var
|
|
89024
|
+
var import_node_crypto2 = require("node:crypto");
|
|
89025
|
+
var import_node_path6 = require("node:path");
|
|
89026
|
+
var import_promises6 = require("node:fs/promises");
|
|
89027
89027
|
|
|
89028
89028
|
// packages/core/dist/document/doc-convert.js
|
|
89029
89029
|
var import_jszip3 = __toESM(require_lib3(), 1);
|
|
@@ -92628,7 +92628,7 @@ var require_buffer_list = /* @__PURE__ */ __commonJSMin(((exports2, module2) =>
|
|
|
92628
92628
|
},
|
|
92629
92629
|
{
|
|
92630
92630
|
key: "join",
|
|
92631
|
-
value: function
|
|
92631
|
+
value: function join7(s) {
|
|
92632
92632
|
if (this.length === 0) return "";
|
|
92633
92633
|
var p = this.head;
|
|
92634
92634
|
var ret2 = "" + p.data;
|
|
@@ -102986,10 +102986,10 @@ var MAC_FONTCONFIG_CONF = `<?xml version="1.0"?>
|
|
|
102986
102986
|
<alias binding="same"><family>Microsoft JhengHei</family><prefer><family>Heiti TC</family></prefer></alias>
|
|
102987
102987
|
</fontconfig>
|
|
102988
102988
|
`;
|
|
102989
|
-
var SANS = { group: "sans", mac: "Arial", cloud: "Liberation Sans" };
|
|
102990
|
-
var SERIF_TIMES = { group: "serif", mac: "Times New Roman", cloud: "Liberation Serif" };
|
|
102991
|
-
var SERIF_GEORGIA = { group: "serif", mac: "Georgia", cloud: "Liberation Serif" };
|
|
102992
|
-
var CONDENSED = { group: "display", mac: "Arial Narrow", cloud: "Liberation Sans Narrow" };
|
|
102989
|
+
var SANS = { group: "sans", mac: "Arial", cloud: "Liberation Sans", win: "Arial" };
|
|
102990
|
+
var SERIF_TIMES = { group: "serif", mac: "Times New Roman", cloud: "Liberation Serif", win: "Times New Roman" };
|
|
102991
|
+
var SERIF_GEORGIA = { group: "serif", mac: "Georgia", cloud: "Liberation Serif", win: "Georgia" };
|
|
102992
|
+
var CONDENSED = { group: "display", mac: "Arial Narrow", cloud: "Liberation Sans Narrow", win: "Arial Narrow" };
|
|
102993
102993
|
var WEB_FONT_SUBSTITUTES = {
|
|
102994
102994
|
// sans — the neutral grotesques
|
|
102995
102995
|
"Inter": SANS,
|
|
@@ -103016,10 +103016,19 @@ var WEB_FONT_SUBSTITUTES = {
|
|
|
103016
103016
|
// display
|
|
103017
103017
|
"Anton": CONDENSED,
|
|
103018
103018
|
"Big Shoulders Display": CONDENSED,
|
|
103019
|
-
"Syne": { group: "display", mac: "Arial", cloud: "Liberation Sans" },
|
|
103020
|
-
"Chakra Petch": { group: "display", mac: "Arial", cloud: "Liberation Sans" },
|
|
103021
|
-
"Gochi Hand": { group: "display", mac: "Noteworthy", cloud: "Liberation Sans" }
|
|
103019
|
+
"Syne": { group: "display", mac: "Arial", cloud: "Liberation Sans", win: "Arial" },
|
|
103020
|
+
"Chakra Petch": { group: "display", mac: "Arial", cloud: "Liberation Sans", win: "Arial" },
|
|
103021
|
+
"Gochi Hand": { group: "display", mac: "Noteworthy", cloud: "Liberation Sans", win: "Segoe Print" }
|
|
103022
103022
|
};
|
|
103023
|
+
function webFontSubstituteMap(column, families = Object.keys(WEB_FONT_SUBSTITUTES)) {
|
|
103024
|
+
const map2 = {};
|
|
103025
|
+
for (const family of families) {
|
|
103026
|
+
const substitute = WEB_FONT_SUBSTITUTES[family];
|
|
103027
|
+
if (substitute)
|
|
103028
|
+
map2[family] = substitute[column];
|
|
103029
|
+
}
|
|
103030
|
+
return map2;
|
|
103031
|
+
}
|
|
103023
103032
|
var WEB_GROTESQUE_FAMILIES = Object.keys(WEB_FONT_SUBSTITUTES).filter((f) => WEB_FONT_SUBSTITUTES[f].group === "sans");
|
|
103024
103033
|
var MAC_FONT_DIRS = ["/System/Library/Fonts", "/System/Library/Fonts/Supplemental", "/Library/Fonts"];
|
|
103025
103034
|
function missingWebFonts(fontFiles = macFontFiles()) {
|
|
@@ -103040,6 +103049,20 @@ function macFontFiles() {
|
|
|
103040
103049
|
}
|
|
103041
103050
|
return out;
|
|
103042
103051
|
}
|
|
103052
|
+
function windowsFontFiles(env2 = process.env) {
|
|
103053
|
+
const dirs = [
|
|
103054
|
+
(0, import_node_path.join)(env2.WINDIR ?? env2.SystemRoot ?? "C:\\Windows", "Fonts"),
|
|
103055
|
+
...env2.LOCALAPPDATA ? [(0, import_node_path.join)(env2.LOCALAPPDATA, "Microsoft", "Windows", "Fonts")] : []
|
|
103056
|
+
];
|
|
103057
|
+
const out = [];
|
|
103058
|
+
for (const d of dirs) {
|
|
103059
|
+
try {
|
|
103060
|
+
out.push(...(0, import_node_fs.readdirSync)(d));
|
|
103061
|
+
} catch {
|
|
103062
|
+
}
|
|
103063
|
+
}
|
|
103064
|
+
return out;
|
|
103065
|
+
}
|
|
103043
103066
|
var fontPair = (i, from, to) => `<node oor:name="_${i}" oor:op="replace"><prop oor:name="Always" oor:op="fuse"><value>true</value></prop><prop oor:name="OnScreenOnly" oor:op="fuse"><value>false</value></prop><prop oor:name="ReplaceFont" oor:op="fuse"><value>${from}</value></prop><prop oor:name="SubstituteFont" oor:op="fuse"><value>${to}</value></prop></node>`;
|
|
103044
103067
|
function macFontReplacementXcu(missing) {
|
|
103045
103068
|
if (!missing.length)
|
|
@@ -103073,6 +103096,428 @@ function runSoffice(bin, args, timeoutMs, env2) {
|
|
|
103073
103096
|
});
|
|
103074
103097
|
}
|
|
103075
103098
|
|
|
103099
|
+
// packages/core/dist/document/keynote.js
|
|
103100
|
+
var import_node_child_process2 = require("node:child_process");
|
|
103101
|
+
var import_node_fs2 = require("node:fs");
|
|
103102
|
+
var import_promises3 = require("node:fs/promises");
|
|
103103
|
+
var import_node_os2 = require("node:os");
|
|
103104
|
+
var import_node_path3 = require("node:path");
|
|
103105
|
+
|
|
103106
|
+
// packages/core/dist/document/office-app.js
|
|
103107
|
+
var import_node_crypto = require("node:crypto");
|
|
103108
|
+
var import_promises2 = require("node:fs/promises");
|
|
103109
|
+
var import_node_path2 = require("node:path");
|
|
103110
|
+
var import_jszip4 = __toESM(require_lib3(), 1);
|
|
103111
|
+
|
|
103112
|
+
// packages/core/dist/shared/async.js
|
|
103113
|
+
function sleep(ms, signal) {
|
|
103114
|
+
return new Promise((resolve) => {
|
|
103115
|
+
if (signal?.aborted)
|
|
103116
|
+
return resolve();
|
|
103117
|
+
const onAbort = () => {
|
|
103118
|
+
clearTimeout(timer);
|
|
103119
|
+
resolve();
|
|
103120
|
+
};
|
|
103121
|
+
const timer = setTimeout(() => {
|
|
103122
|
+
signal?.removeEventListener("abort", onAbort);
|
|
103123
|
+
resolve();
|
|
103124
|
+
}, ms);
|
|
103125
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
103126
|
+
});
|
|
103127
|
+
}
|
|
103128
|
+
|
|
103129
|
+
// packages/core/dist/document/office-app.js
|
|
103130
|
+
function replaceTypefaces(xml, map2) {
|
|
103131
|
+
return xml.replace(/typeface="([^"]*)"/g, (whole, family) => Object.hasOwn(map2, family) ? `typeface="${map2[family]}"` : whole);
|
|
103132
|
+
}
|
|
103133
|
+
async function rewriteDeckParts(bytes, fonts, transform = null) {
|
|
103134
|
+
const zip = await import_jszip4.default.loadAsync(bytes);
|
|
103135
|
+
const parts = Object.keys(zip.files).filter((name) => name.startsWith("ppt/") && name.endsWith(".xml"));
|
|
103136
|
+
let changed = false;
|
|
103137
|
+
for (const name of parts) {
|
|
103138
|
+
const original = await zip.file(name).async("string");
|
|
103139
|
+
const xml = replaceTypefaces(transform ? transform(original) : original, fonts);
|
|
103140
|
+
if (xml !== original) {
|
|
103141
|
+
zip.file(name, xml);
|
|
103142
|
+
changed = true;
|
|
103143
|
+
}
|
|
103144
|
+
}
|
|
103145
|
+
return changed ? zip.generateAsync({ type: "uint8array", compression: "DEFLATE" }) : bytes;
|
|
103146
|
+
}
|
|
103147
|
+
var OWNER_FILE = "owner.json";
|
|
103148
|
+
var EXPIRY_MARGIN_MS = 3e4;
|
|
103149
|
+
var UNOWNED_GRACE_MS = 3e4;
|
|
103150
|
+
var errno = (e) => e.code;
|
|
103151
|
+
async function readOwner(dir) {
|
|
103152
|
+
try {
|
|
103153
|
+
const parsed = JSON.parse(await (0, import_promises2.readFile)((0, import_node_path2.join)(dir, OWNER_FILE), "utf8"));
|
|
103154
|
+
return typeof parsed.nonce === "string" && typeof parsed.expiresAt === "number" ? parsed : null;
|
|
103155
|
+
} catch {
|
|
103156
|
+
return null;
|
|
103157
|
+
}
|
|
103158
|
+
}
|
|
103159
|
+
async function staleNonce(dir) {
|
|
103160
|
+
const owner = await readOwner(dir);
|
|
103161
|
+
if (owner)
|
|
103162
|
+
return Date.now() > owner.expiresAt ? owner.nonce : null;
|
|
103163
|
+
const age = await (0, import_promises2.stat)(dir).then((s) => Date.now() - s.mtimeMs, () => -1);
|
|
103164
|
+
return age > UNOWNED_GRACE_MS ? "" : null;
|
|
103165
|
+
}
|
|
103166
|
+
var REMOVAL_TOKEN_STALE_MS = 1e4;
|
|
103167
|
+
async function removeIf(lockPath, nonce) {
|
|
103168
|
+
const token = `${lockPath}.remove-${nonce || "unowned"}`;
|
|
103169
|
+
if (!await claimToken(token))
|
|
103170
|
+
return;
|
|
103171
|
+
try {
|
|
103172
|
+
const owner = await readOwner(lockPath);
|
|
103173
|
+
const present = await (0, import_promises2.stat)(lockPath).then(() => true, () => false);
|
|
103174
|
+
if (!present || (owner?.nonce ?? "") !== nonce)
|
|
103175
|
+
return;
|
|
103176
|
+
const trash = `${lockPath}.removed-${(0, import_node_crypto.randomBytes)(8).toString("hex")}`;
|
|
103177
|
+
await (0, import_promises2.rename)(lockPath, trash);
|
|
103178
|
+
await (0, import_promises2.rm)(trash, { recursive: true, force: true });
|
|
103179
|
+
} finally {
|
|
103180
|
+
await (0, import_promises2.rm)(token, { recursive: true, force: true });
|
|
103181
|
+
}
|
|
103182
|
+
}
|
|
103183
|
+
async function claimToken(token) {
|
|
103184
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
103185
|
+
try {
|
|
103186
|
+
await (0, import_promises2.mkdir)(token);
|
|
103187
|
+
return true;
|
|
103188
|
+
} catch (e) {
|
|
103189
|
+
if (errno(e) !== "EEXIST")
|
|
103190
|
+
throw e;
|
|
103191
|
+
const age = await (0, import_promises2.stat)(token).then((st) => Date.now() - st.mtimeMs, () => 0);
|
|
103192
|
+
if (age <= REMOVAL_TOKEN_STALE_MS)
|
|
103193
|
+
return false;
|
|
103194
|
+
await (0, import_promises2.rm)(token, { recursive: true, force: true });
|
|
103195
|
+
}
|
|
103196
|
+
}
|
|
103197
|
+
return false;
|
|
103198
|
+
}
|
|
103199
|
+
async function acquireOfficeAppLock(lockPath, app, budget) {
|
|
103200
|
+
const deadline = Date.now() + budget.waitMs;
|
|
103201
|
+
const nonce = (0, import_node_crypto.randomBytes)(16).toString("hex");
|
|
103202
|
+
for (; ; ) {
|
|
103203
|
+
if (await tryCreate(lockPath, nonce, budget.holdMs)) {
|
|
103204
|
+
return () => removeIf(lockPath, nonce);
|
|
103205
|
+
}
|
|
103206
|
+
const stale = await staleNonce(lockPath);
|
|
103207
|
+
if (stale !== null) {
|
|
103208
|
+
await removeIf(lockPath, stale);
|
|
103209
|
+
continue;
|
|
103210
|
+
}
|
|
103211
|
+
if (Date.now() > deadline)
|
|
103212
|
+
throw new Error(`another ${app} conversion is still running`);
|
|
103213
|
+
await sleep(250);
|
|
103214
|
+
}
|
|
103215
|
+
}
|
|
103216
|
+
async function tryCreate(lockPath, nonce, holdMs) {
|
|
103217
|
+
const staging = `${lockPath}.new-${nonce}`;
|
|
103218
|
+
const startedAt = Date.now();
|
|
103219
|
+
const owner = { nonce, startedAt, expiresAt: startedAt + holdMs + EXPIRY_MARGIN_MS };
|
|
103220
|
+
await (0, import_promises2.mkdir)(staging, { recursive: true });
|
|
103221
|
+
try {
|
|
103222
|
+
await (0, import_promises2.writeFile)((0, import_node_path2.join)(staging, OWNER_FILE), JSON.stringify(owner));
|
|
103223
|
+
await (0, import_promises2.rename)(staging, lockPath);
|
|
103224
|
+
return true;
|
|
103225
|
+
} catch (e) {
|
|
103226
|
+
await (0, import_promises2.rm)(staging, { recursive: true, force: true });
|
|
103227
|
+
const code = errno(e);
|
|
103228
|
+
if (code === "EEXIST" || code === "ENOTEMPTY")
|
|
103229
|
+
return false;
|
|
103230
|
+
if ((code === "EPERM" || code === "EACCES") && await (0, import_promises2.stat)(lockPath).then(() => true, () => false))
|
|
103231
|
+
return false;
|
|
103232
|
+
throw e;
|
|
103233
|
+
}
|
|
103234
|
+
}
|
|
103235
|
+
|
|
103236
|
+
// packages/core/dist/document/keynote.js
|
|
103237
|
+
var KEYNOTE_APP = "/Applications/Keynote.app";
|
|
103238
|
+
var KEYNOTE_BUNDLE_ID = "com.apple.iWork.Keynote";
|
|
103239
|
+
var KEYNOTE_DISABLE_VALUES = /* @__PURE__ */ new Set(["off", "none", "0", "false", "disabled"]);
|
|
103240
|
+
function resolveKeynote(deps = {}) {
|
|
103241
|
+
const env2 = deps.env ?? process.env;
|
|
103242
|
+
const platform = deps.platform ?? process.platform;
|
|
103243
|
+
const exists = deps.exists ?? import_node_fs2.existsSync;
|
|
103244
|
+
if (platform !== "darwin")
|
|
103245
|
+
return null;
|
|
103246
|
+
const override = env2.TALOS_KEYNOTE?.trim();
|
|
103247
|
+
if (override && KEYNOTE_DISABLE_VALUES.has(override.toLowerCase()))
|
|
103248
|
+
return null;
|
|
103249
|
+
if (override && exists(override))
|
|
103250
|
+
return override;
|
|
103251
|
+
return exists(KEYNOTE_APP) ? KEYNOTE_APP : null;
|
|
103252
|
+
}
|
|
103253
|
+
function isKeynoteInput(inputPath) {
|
|
103254
|
+
return (0, import_node_path3.extname)(inputPath).toLowerCase() === ".pptx";
|
|
103255
|
+
}
|
|
103256
|
+
var GRAD_FILL_RE = /<a:gradFill\b[^>]*>[\s\S]*?<\/a:gradFill>/g;
|
|
103257
|
+
var STOP_RE = /<a:gs pos="\d+">\s*<a:srgbClr val="([0-9A-Fa-f]{6})"\s*(?:\/>|>\s*(?:<a:alpha val="(\d+)"\s*\/>)?\s*<\/a:srgbClr>)\s*<\/a:gs>/g;
|
|
103258
|
+
function flattenTranslucentLinearGradients(xml) {
|
|
103259
|
+
let count = 0;
|
|
103260
|
+
const out = xml.replace(GRAD_FILL_RE, (grad) => {
|
|
103261
|
+
if (!grad.includes("<a:lin "))
|
|
103262
|
+
return grad;
|
|
103263
|
+
const stopCount = grad.match(/<a:gs\b/g)?.length ?? 0;
|
|
103264
|
+
const stops = [...grad.matchAll(STOP_RE)].map((m) => ({ rgb: m[1], alpha: m[2] === void 0 ? 1e5 : Number(m[2]) }));
|
|
103265
|
+
if (stopCount === 0 || stops.length !== stopCount || stops.every((s) => s.alpha >= 1e5))
|
|
103266
|
+
return grad;
|
|
103267
|
+
const mean = (pick) => Math.round(stops.reduce((sum, s) => sum + pick(s), 0) / stops.length);
|
|
103268
|
+
const channel = (offset) => mean((s) => parseInt(s.rgb.slice(offset, offset + 2), 16)).toString(16).padStart(2, "0");
|
|
103269
|
+
const rgb = `${channel(0)}${channel(2)}${channel(4)}`.toUpperCase();
|
|
103270
|
+
count++;
|
|
103271
|
+
return `<a:solidFill><a:srgbClr val="${rgb}"><a:alpha val="${mean((s) => s.alpha)}"/></a:srgbClr></a:solidFill>`;
|
|
103272
|
+
});
|
|
103273
|
+
return { xml: out, count };
|
|
103274
|
+
}
|
|
103275
|
+
async function prepareDeckForKeynote(bytes, missing = missingWebFonts()) {
|
|
103276
|
+
const fonts = webFontSubstituteMap("mac", missing);
|
|
103277
|
+
let flattenedGradients = 0;
|
|
103278
|
+
const out = await rewriteDeckParts(bytes, fonts, (xml) => {
|
|
103279
|
+
const flattened = flattenTranslucentLinearGradients(xml);
|
|
103280
|
+
flattenedGradients += flattened.count;
|
|
103281
|
+
return flattened.xml;
|
|
103282
|
+
});
|
|
103283
|
+
return { bytes: out, fonts, flattenedGradients };
|
|
103284
|
+
}
|
|
103285
|
+
var KEYNOTE_EXPORT_SCRIPT = `on run argv
|
|
103286
|
+
set inPath to item 1 of argv
|
|
103287
|
+
set outPath to item 2 of argv
|
|
103288
|
+
set waitSeconds to (item 3 of argv) as integer
|
|
103289
|
+
set wasRunning to application id "${KEYNOTE_BUNDLE_ID}" is running
|
|
103290
|
+
with timeout of waitSeconds seconds
|
|
103291
|
+
tell application id "${KEYNOTE_BUNDLE_ID}"
|
|
103292
|
+
set theDoc to open (POSIX file inPath as alias)
|
|
103293
|
+
try
|
|
103294
|
+
export theDoc to (POSIX file outPath) as PDF with properties {PDF image quality:Good}
|
|
103295
|
+
on error errMsg number errNum
|
|
103296
|
+
close theDoc saving no
|
|
103297
|
+
error errMsg number errNum
|
|
103298
|
+
end try
|
|
103299
|
+
close theDoc saving no
|
|
103300
|
+
if not wasRunning and (count of documents) is 0 then quit
|
|
103301
|
+
end tell
|
|
103302
|
+
end timeout
|
|
103303
|
+
end run
|
|
103304
|
+
`;
|
|
103305
|
+
var runOsascript = (args, timeoutMs) => new Promise((resolve, reject2) => {
|
|
103306
|
+
(0, import_node_child_process2.execFile)("/usr/bin/osascript", args, { timeout: timeoutMs, killSignal: "SIGKILL" }, (err, _stdout, stderr) => {
|
|
103307
|
+
if (!err)
|
|
103308
|
+
return resolve();
|
|
103309
|
+
const killed = err.killed;
|
|
103310
|
+
reject2(new Error(killed ? `Keynote did not finish within ${Math.round(timeoutMs / 1e3)}s` : String(stderr || err.message).trim()));
|
|
103311
|
+
});
|
|
103312
|
+
});
|
|
103313
|
+
function keynoteTimeoutMs(bytes) {
|
|
103314
|
+
return 6e4 + Math.ceil(bytes / 1048576) * 2e3;
|
|
103315
|
+
}
|
|
103316
|
+
var defaultIsRunning = async () => new Promise((resolve) => {
|
|
103317
|
+
(0, import_node_child_process2.execFile)("/usr/bin/pgrep", ["-x", "Keynote"], (err) => resolve(!err));
|
|
103318
|
+
});
|
|
103319
|
+
var defaultKill = async () => new Promise((resolve) => {
|
|
103320
|
+
(0, import_node_child_process2.execFile)("/usr/bin/pkill", ["-9", "-x", "Keynote"], () => resolve());
|
|
103321
|
+
});
|
|
103322
|
+
function explain(error) {
|
|
103323
|
+
if (/-1743\b/.test(error.message)) {
|
|
103324
|
+
return new Error("macOS did not allow controlling Keynote (Automation permission denied: System Settings \u2192 Privacy & Security \u2192 Automation)");
|
|
103325
|
+
}
|
|
103326
|
+
return error;
|
|
103327
|
+
}
|
|
103328
|
+
async function convertToPdfViaKeynote(inputPath, options = {}) {
|
|
103329
|
+
if (!isKeynoteInput(inputPath))
|
|
103330
|
+
throw new Error(`Keynote renders .pptx only, not ${(0, import_node_path3.extname)(inputPath) || inputPath}`);
|
|
103331
|
+
const run = options.run ?? runOsascript;
|
|
103332
|
+
const isRunning = options.isRunning ?? defaultIsRunning;
|
|
103333
|
+
const kill = options.kill ?? defaultKill;
|
|
103334
|
+
const source = await (0, import_promises3.readFile)(inputPath);
|
|
103335
|
+
const prep = await prepareDeckForKeynote(new Uint8Array(source), options.missingFonts);
|
|
103336
|
+
const timeoutMs = options.timeoutMs ?? keynoteTimeoutMs(source.byteLength);
|
|
103337
|
+
const work = await (0, import_promises3.mkdtemp)((0, import_node_path3.join)((0, import_node_os2.tmpdir)(), "talos-keynote-"));
|
|
103338
|
+
const budget = 2 * (timeoutMs + 5e3);
|
|
103339
|
+
const release = await acquireOfficeAppLock(options.lockPath ?? (0, import_node_path3.join)((0, import_node_os2.tmpdir)(), "talos-keynote.lock"), "Keynote", { holdMs: budget, waitMs: budget }).catch(async (e) => {
|
|
103340
|
+
await (0, import_promises3.rm)(work, { recursive: true, force: true });
|
|
103341
|
+
throw e;
|
|
103342
|
+
});
|
|
103343
|
+
try {
|
|
103344
|
+
const deck = (0, import_node_path3.join)(work, "deck.pptx");
|
|
103345
|
+
const pdf = (0, import_node_path3.join)(work, "deck.pdf");
|
|
103346
|
+
await (0, import_promises3.writeFile)(deck, prep.bytes);
|
|
103347
|
+
const args = ["-e", KEYNOTE_EXPORT_SCRIPT, deck, pdf, String(Math.ceil(timeoutMs / 1e3))];
|
|
103348
|
+
const wasRunning = await isRunning();
|
|
103349
|
+
try {
|
|
103350
|
+
await run(args, timeoutMs + 5e3);
|
|
103351
|
+
} catch (e) {
|
|
103352
|
+
const error = explain(e);
|
|
103353
|
+
const timedOut = /did not finish|-1712\b/.test(error.message);
|
|
103354
|
+
if (!timedOut || wasRunning)
|
|
103355
|
+
throw error;
|
|
103356
|
+
await kill();
|
|
103357
|
+
await run(args, timeoutMs + 5e3).catch((retry) => {
|
|
103358
|
+
throw explain(retry);
|
|
103359
|
+
});
|
|
103360
|
+
}
|
|
103361
|
+
const bytes = await (0, import_promises3.readFile)(pdf).catch(() => {
|
|
103362
|
+
throw new Error("Keynote produced no PDF");
|
|
103363
|
+
});
|
|
103364
|
+
if (bytes.subarray(0, 5).toString("latin1") !== "%PDF-")
|
|
103365
|
+
throw new Error("Keynote produced no PDF");
|
|
103366
|
+
return { bytes: new Uint8Array(bytes), fonts: prep.fonts, flattenedGradients: prep.flattenedGradients };
|
|
103367
|
+
} finally {
|
|
103368
|
+
await release().catch(() => {
|
|
103369
|
+
});
|
|
103370
|
+
await (0, import_promises3.rm)(work, { recursive: true, force: true }).catch(() => {
|
|
103371
|
+
});
|
|
103372
|
+
}
|
|
103373
|
+
}
|
|
103374
|
+
|
|
103375
|
+
// packages/core/dist/document/powerpoint.js
|
|
103376
|
+
var import_node_child_process3 = require("node:child_process");
|
|
103377
|
+
var import_node_fs3 = require("node:fs");
|
|
103378
|
+
var import_promises4 = require("node:fs/promises");
|
|
103379
|
+
var import_node_os3 = require("node:os");
|
|
103380
|
+
var import_node_path4 = require("node:path");
|
|
103381
|
+
var POWERPOINT_DISABLE_VALUES = /* @__PURE__ */ new Set(["off", "none", "0", "false", "disabled"]);
|
|
103382
|
+
var APP_PATHS_KEY = "HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\powerpnt.exe";
|
|
103383
|
+
function installCandidates(env2) {
|
|
103384
|
+
const roots = [env2.ProgramFiles ?? "C:\\Program Files", env2["ProgramFiles(x86)"] ?? "C:\\Program Files (x86)"];
|
|
103385
|
+
const out = [];
|
|
103386
|
+
for (const root2 of roots) {
|
|
103387
|
+
for (const version2 of ["Office16", "Office15"]) {
|
|
103388
|
+
out.push(import_node_path4.win32.join(root2, "Microsoft Office", "root", version2, "POWERPNT.EXE"));
|
|
103389
|
+
out.push(import_node_path4.win32.join(root2, "Microsoft Office", version2, "POWERPNT.EXE"));
|
|
103390
|
+
}
|
|
103391
|
+
}
|
|
103392
|
+
return out;
|
|
103393
|
+
}
|
|
103394
|
+
function parseRegisteredPath(regOutput) {
|
|
103395
|
+
const value = /REG_(?:EXPAND_)?SZ\s+(.+?)\s*$/m.exec(regOutput)?.[1]?.replace(/^"|"$/g, "");
|
|
103396
|
+
return value || null;
|
|
103397
|
+
}
|
|
103398
|
+
function system32(...path) {
|
|
103399
|
+
return import_node_path4.win32.join(process.env.SystemRoot ?? process.env.WINDIR ?? "C:\\Windows", "System32", ...path);
|
|
103400
|
+
}
|
|
103401
|
+
function defaultRegisteredPath() {
|
|
103402
|
+
try {
|
|
103403
|
+
const out = (0, import_node_child_process3.execFileSync)(system32("reg.exe"), ["query", APP_PATHS_KEY, "/ve"], { encoding: "utf8", timeout: 5e3, windowsHide: true });
|
|
103404
|
+
return parseRegisteredPath(out);
|
|
103405
|
+
} catch {
|
|
103406
|
+
return null;
|
|
103407
|
+
}
|
|
103408
|
+
}
|
|
103409
|
+
function resolvePowerPoint(deps = {}) {
|
|
103410
|
+
const env2 = deps.env ?? process.env;
|
|
103411
|
+
const platform = deps.platform ?? process.platform;
|
|
103412
|
+
const exists = deps.exists ?? import_node_fs3.existsSync;
|
|
103413
|
+
if (platform !== "win32")
|
|
103414
|
+
return null;
|
|
103415
|
+
const override = env2.TALOS_POWERPOINT?.trim();
|
|
103416
|
+
if (override && POWERPOINT_DISABLE_VALUES.has(override.toLowerCase()))
|
|
103417
|
+
return null;
|
|
103418
|
+
if (override && exists(override))
|
|
103419
|
+
return override;
|
|
103420
|
+
for (const candidate of installCandidates(env2))
|
|
103421
|
+
if (exists(candidate))
|
|
103422
|
+
return candidate;
|
|
103423
|
+
const registered = (deps.registeredPath ?? defaultRegisteredPath)();
|
|
103424
|
+
return registered && exists(registered) ? registered : null;
|
|
103425
|
+
}
|
|
103426
|
+
function isPowerPointInput(inputPath) {
|
|
103427
|
+
return (0, import_node_path4.extname)(inputPath).toLowerCase() === ".pptx";
|
|
103428
|
+
}
|
|
103429
|
+
async function prepareDeckForPowerPoint(bytes, missing = missingWebFonts(windowsFontFiles())) {
|
|
103430
|
+
const fonts = webFontSubstituteMap("win", missing);
|
|
103431
|
+
return { bytes: await rewriteDeckParts(bytes, fonts), fonts };
|
|
103432
|
+
}
|
|
103433
|
+
function psQuote(value) {
|
|
103434
|
+
return `'${value.replace(/['\u2018\u2019\u201A\u201B]/g, (q) => q + q)}'`;
|
|
103435
|
+
}
|
|
103436
|
+
function powerPointExportScript(inPath, outPath) {
|
|
103437
|
+
return `$ErrorActionPreference = 'Stop'
|
|
103438
|
+
try { [Console]::OutputEncoding = [Text.Encoding]::UTF8 } catch {}
|
|
103439
|
+
$wasRunning = [bool](Get-Process -Name POWERPNT -ErrorAction SilentlyContinue)
|
|
103440
|
+
$app = $null; $pres = $null; $failed = $false
|
|
103441
|
+
try {
|
|
103442
|
+
$app = New-Object -ComObject PowerPoint.Application
|
|
103443
|
+
$pres = $app.Presentations.Open(${psQuote(inPath)}, -1, 0, 0)
|
|
103444
|
+
$pres.SaveAs(${psQuote(outPath)}, 32)
|
|
103445
|
+
} catch {
|
|
103446
|
+
[Console]::Error.WriteLine($_.Exception.Message)
|
|
103447
|
+
$failed = $true
|
|
103448
|
+
} finally {
|
|
103449
|
+
if ($pres) { $pres.Close(); [void][Runtime.InteropServices.Marshal]::ReleaseComObject($pres) }
|
|
103450
|
+
if ($app) {
|
|
103451
|
+
if (-not $wasRunning -and $app.Presentations.Count -eq 0) { $app.Quit() }
|
|
103452
|
+
[void][Runtime.InteropServices.Marshal]::ReleaseComObject($app)
|
|
103453
|
+
}
|
|
103454
|
+
}
|
|
103455
|
+
if ($failed) { exit 1 }
|
|
103456
|
+
`;
|
|
103457
|
+
}
|
|
103458
|
+
function powerShellArgs(script) {
|
|
103459
|
+
return ["-NoProfile", "-NonInteractive", "-EncodedCommand", Buffer.from(script, "utf16le").toString("base64")];
|
|
103460
|
+
}
|
|
103461
|
+
var runPowerShell = (script, timeoutMs) => new Promise((resolve, reject2) => {
|
|
103462
|
+
(0, import_node_child_process3.execFile)(system32("WindowsPowerShell", "v1.0", "powershell.exe"), powerShellArgs(script), { timeout: timeoutMs, windowsHide: true }, (err, _stdout, stderr) => {
|
|
103463
|
+
if (!err)
|
|
103464
|
+
return resolve();
|
|
103465
|
+
const killed = err.killed;
|
|
103466
|
+
reject2(new Error(killed ? `PowerPoint did not finish within ${Math.round(timeoutMs / 1e3)}s` : String(stderr || err.message).trim()));
|
|
103467
|
+
});
|
|
103468
|
+
});
|
|
103469
|
+
var defaultIsRunning2 = async () => new Promise((resolve) => {
|
|
103470
|
+
(0, import_node_child_process3.execFile)(system32("tasklist.exe"), ["/FI", "IMAGENAME eq POWERPNT.EXE", "/NH"], { windowsHide: true }, (err, stdout) => resolve(!err && /POWERPNT\.EXE/i.test(stdout)));
|
|
103471
|
+
});
|
|
103472
|
+
var defaultKill2 = async () => new Promise((resolve) => {
|
|
103473
|
+
(0, import_node_child_process3.execFile)(system32("taskkill.exe"), ["/F", "/IM", "POWERPNT.EXE"], { windowsHide: true }, () => resolve());
|
|
103474
|
+
});
|
|
103475
|
+
function powerPointTimeoutMs(bytes) {
|
|
103476
|
+
return 9e4 + Math.ceil(bytes / 1048576) * 2e3;
|
|
103477
|
+
}
|
|
103478
|
+
async function convertToPdfViaPowerPoint(inputPath, options = {}) {
|
|
103479
|
+
if (!isPowerPointInput(inputPath))
|
|
103480
|
+
throw new Error(`PowerPoint renders .pptx only here, not ${(0, import_node_path4.extname)(inputPath) || inputPath}`);
|
|
103481
|
+
const run = options.run ?? runPowerShell;
|
|
103482
|
+
const isRunning = options.isRunning ?? defaultIsRunning2;
|
|
103483
|
+
const kill = options.kill ?? defaultKill2;
|
|
103484
|
+
const source = await (0, import_promises4.readFile)(inputPath);
|
|
103485
|
+
const prep = await prepareDeckForPowerPoint(new Uint8Array(source), options.missingFonts);
|
|
103486
|
+
const timeoutMs = options.timeoutMs ?? powerPointTimeoutMs(source.byteLength);
|
|
103487
|
+
const work = await (0, import_promises4.mkdtemp)((0, import_node_path4.join)((0, import_node_os3.tmpdir)(), "talos-powerpoint-"));
|
|
103488
|
+
const release = await acquireOfficeAppLock(options.lockPath ?? (0, import_node_path4.join)((0, import_node_os3.tmpdir)(), "talos-powerpoint.lock"), "PowerPoint", { holdMs: timeoutMs, waitMs: timeoutMs + 1e4 }).catch(async (e) => {
|
|
103489
|
+
await (0, import_promises4.rm)(work, { recursive: true, force: true });
|
|
103490
|
+
throw e;
|
|
103491
|
+
});
|
|
103492
|
+
try {
|
|
103493
|
+
const deck = (0, import_node_path4.join)(work, "deck.pptx");
|
|
103494
|
+
const pdf = (0, import_node_path4.join)(work, "deck.pdf");
|
|
103495
|
+
await (0, import_promises4.writeFile)(deck, prep.bytes);
|
|
103496
|
+
const wasRunning = await isRunning();
|
|
103497
|
+
try {
|
|
103498
|
+
await run(powerPointExportScript(deck, pdf), timeoutMs);
|
|
103499
|
+
} catch (e) {
|
|
103500
|
+
const error = e;
|
|
103501
|
+
if (/did not finish/.test(error.message) && !wasRunning) {
|
|
103502
|
+
await kill();
|
|
103503
|
+
throw new Error(`${error.message}; the PowerPoint it started was stopped (is a PowerPoint dialog waiting for an answer?)`);
|
|
103504
|
+
}
|
|
103505
|
+
throw error;
|
|
103506
|
+
}
|
|
103507
|
+
const bytes = await (0, import_promises4.readFile)(pdf).catch(() => {
|
|
103508
|
+
throw new Error("PowerPoint produced no PDF");
|
|
103509
|
+
});
|
|
103510
|
+
if (bytes.subarray(0, 5).toString("latin1") !== "%PDF-")
|
|
103511
|
+
throw new Error("PowerPoint produced no PDF");
|
|
103512
|
+
return { bytes: new Uint8Array(bytes), fonts: prep.fonts };
|
|
103513
|
+
} finally {
|
|
103514
|
+
await release().catch(() => {
|
|
103515
|
+
});
|
|
103516
|
+
await (0, import_promises4.rm)(work, { recursive: true, force: true }).catch(() => {
|
|
103517
|
+
});
|
|
103518
|
+
}
|
|
103519
|
+
}
|
|
103520
|
+
|
|
103076
103521
|
// packages/core/dist/document/office-service.js
|
|
103077
103522
|
async function convertViaOfficeService(bytes, filename, url, options = {}) {
|
|
103078
103523
|
const doFetch = options.fetchImpl ?? fetch;
|
|
@@ -103098,11 +103543,16 @@ async function convertViaOfficeService(bytes, filename, url, options = {}) {
|
|
|
103098
103543
|
clearTimeout(timer);
|
|
103099
103544
|
}
|
|
103100
103545
|
}
|
|
103546
|
+
async function prepareDeckForOfficeService(bytes, filename) {
|
|
103547
|
+
if (!/\.pptx$/i.test(filename))
|
|
103548
|
+
return bytes;
|
|
103549
|
+
return rewriteDeckParts(bytes, webFontSubstituteMap("cloud"));
|
|
103550
|
+
}
|
|
103101
103551
|
|
|
103102
103552
|
// apps/admin/data/skills.lib/document/bin-src/lib/headless-chromium.mjs
|
|
103103
|
-
var
|
|
103553
|
+
var import_promises5 = require("node:fs/promises");
|
|
103104
103554
|
var import_node_module = require("node:module");
|
|
103105
|
-
var
|
|
103555
|
+
var import_node_path5 = require("node:path");
|
|
103106
103556
|
|
|
103107
103557
|
// packages/core/dist/document/pdf-print.js
|
|
103108
103558
|
var CJK_TEXT_RE = /[\u2E80-\u30FF\u3200-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF\uFE30-\uFE4F\uFF00-\uFFEF]/;
|
|
@@ -103148,7 +103598,7 @@ function headlessBrowserDisabled() {
|
|
|
103148
103598
|
async function loadPlaywright() {
|
|
103149
103599
|
const deps = process.env.TALOS_SKILL_DEPS;
|
|
103150
103600
|
if (deps) {
|
|
103151
|
-
const req = (0, import_node_module.createRequire)((0,
|
|
103601
|
+
const req = (0, import_node_module.createRequire)((0, import_node_path5.join)(deps, "_resolve.js"));
|
|
103152
103602
|
for (const name of ["playwright", "playwright-core"]) {
|
|
103153
103603
|
try {
|
|
103154
103604
|
return req(name);
|
|
@@ -103180,11 +103630,11 @@ async function launchHeadlessChromium() {
|
|
|
103180
103630
|
var _fontManifest;
|
|
103181
103631
|
async function fontManifest() {
|
|
103182
103632
|
if (_fontManifest !== void 0) return _fontManifest;
|
|
103183
|
-
const dir = process.env.TALOS_CJK_FONT_DIR || (0,
|
|
103184
|
-
const file = (0,
|
|
103633
|
+
const dir = process.env.TALOS_CJK_FONT_DIR || (0, import_node_path5.join)((0, import_node_path5.dirname)(process.argv[1]), "..", "assets", "fonts");
|
|
103634
|
+
const file = (0, import_node_path5.join)(dir, "fonts.json");
|
|
103185
103635
|
let manifest;
|
|
103186
103636
|
try {
|
|
103187
|
-
manifest = JSON.parse(await (0,
|
|
103637
|
+
manifest = JSON.parse(await (0, import_promises5.readFile)(file, "utf8"));
|
|
103188
103638
|
} catch (error) {
|
|
103189
103639
|
throw new Error(`Cannot load PDF font manifest ${file}: ${error.message}`);
|
|
103190
103640
|
}
|
|
@@ -103197,7 +103647,7 @@ async function fontManifest() {
|
|
|
103197
103647
|
var _faceB64 = /* @__PURE__ */ new Map();
|
|
103198
103648
|
async function faceBase64(path) {
|
|
103199
103649
|
if (!_faceB64.has(path)) {
|
|
103200
|
-
const bytes = await (0,
|
|
103650
|
+
const bytes = await (0, import_promises5.readFile)(path).catch((error) => {
|
|
103201
103651
|
throw new Error(`Cannot load PDF font ${path}: ${error.message}`);
|
|
103202
103652
|
});
|
|
103203
103653
|
if (!bytes.length) throw new Error(`Empty PDF font: ${path}`);
|
|
@@ -103211,7 +103661,7 @@ async function faceCss(entries, range2, doc) {
|
|
|
103211
103661
|
for (const entry of entries ?? []) {
|
|
103212
103662
|
const families = doc ? (entry.families ?? []).filter((f) => doc.includes(f)) : entry.families ?? [];
|
|
103213
103663
|
if (!families.length) continue;
|
|
103214
|
-
const path = (0,
|
|
103664
|
+
const path = (0, import_node_path5.join)(dir, entry.file);
|
|
103215
103665
|
const b64 = await faceBase64(path);
|
|
103216
103666
|
for (const family of families) {
|
|
103217
103667
|
rules.push(
|
|
@@ -103289,23 +103739,23 @@ async function renderHtmlViaService(html) {
|
|
|
103289
103739
|
}
|
|
103290
103740
|
async function faithfulCachePath(cacheDir, input, raw) {
|
|
103291
103741
|
if (!cacheDir) return null;
|
|
103292
|
-
await (0,
|
|
103293
|
-
const key = (0,
|
|
103294
|
-
return (0,
|
|
103742
|
+
await (0, import_promises6.mkdir)(cacheDir, { recursive: true, mode: 448 });
|
|
103743
|
+
const key = (0, import_node_crypto2.createHash)("sha256").update("talos-doc-convert-pdf-v1\0").update((0, import_node_path6.extname)(input).toLowerCase()).update("\0").update(raw).digest("hex");
|
|
103744
|
+
return (0, import_node_path6.join)(cacheDir, `${key}.pdf`);
|
|
103295
103745
|
}
|
|
103296
103746
|
async function readCachedPdf(path) {
|
|
103297
103747
|
if (!path) return null;
|
|
103298
|
-
const bytes = await (0,
|
|
103748
|
+
const bytes = await (0, import_promises6.readFile)(path).catch(() => null);
|
|
103299
103749
|
return bytes && bytes.subarray(0, 5).toString("latin1") === "%PDF-" ? bytes : null;
|
|
103300
103750
|
}
|
|
103301
103751
|
async function writeCachedPdf(path, bytes) {
|
|
103302
103752
|
if (!path) return;
|
|
103303
103753
|
const tmp = `${path}.${process.pid}.tmp`;
|
|
103304
103754
|
try {
|
|
103305
|
-
await (0,
|
|
103306
|
-
await (0,
|
|
103755
|
+
await (0, import_promises6.writeFile)(tmp, bytes, { mode: 384 });
|
|
103756
|
+
await (0, import_promises6.rename)(tmp, path);
|
|
103307
103757
|
} finally {
|
|
103308
|
-
await (0,
|
|
103758
|
+
await (0, import_promises6.rm)(tmp, { force: true }).catch(() => {
|
|
103309
103759
|
});
|
|
103310
103760
|
}
|
|
103311
103761
|
}
|
|
@@ -103324,11 +103774,33 @@ async function renderViaSoffice(input, cachePath) {
|
|
|
103324
103774
|
return { failed: `LibreOffice failed (${e.message})` };
|
|
103325
103775
|
}
|
|
103326
103776
|
}
|
|
103777
|
+
async function renderViaKeynote(input) {
|
|
103778
|
+
if (!isKeynoteInput(input) || !resolveKeynote()) return null;
|
|
103779
|
+
try {
|
|
103780
|
+
const { bytes, flattenedGradients } = await convertToPdfViaKeynote(input);
|
|
103781
|
+
if (flattenedGradients) {
|
|
103782
|
+
process.stderr.write(`doc-convert: Keynote drops transparency from linear gradients; ${flattenedGradients} translucent gradient fill(s) were rendered as one flat translucent fill
|
|
103783
|
+
`);
|
|
103784
|
+
}
|
|
103785
|
+
return { bytes };
|
|
103786
|
+
} catch (e) {
|
|
103787
|
+
return { failed: `Keynote failed (${e.message})` };
|
|
103788
|
+
}
|
|
103789
|
+
}
|
|
103790
|
+
async function renderViaPowerPoint(input) {
|
|
103791
|
+
if (!isPowerPointInput(input) || !resolvePowerPoint()) return null;
|
|
103792
|
+
try {
|
|
103793
|
+
return { bytes: (await convertToPdfViaPowerPoint(input)).bytes };
|
|
103794
|
+
} catch (e) {
|
|
103795
|
+
return { failed: `PowerPoint failed (${e.message})` };
|
|
103796
|
+
}
|
|
103797
|
+
}
|
|
103327
103798
|
async function renderViaOfficeService(input, raw) {
|
|
103328
103799
|
const url = process.env.TALOS_OFFICE_URL;
|
|
103329
103800
|
if (!url) return null;
|
|
103330
103801
|
try {
|
|
103331
|
-
|
|
103802
|
+
const sent = await prepareDeckForOfficeService(new Uint8Array(raw), (0, import_node_path6.basename)(input));
|
|
103803
|
+
return { bytes: await convertViaOfficeService(sent, (0, import_node_path6.basename)(input), url, {
|
|
103332
103804
|
token: process.env.TALOS_OFFICE_TOKEN,
|
|
103333
103805
|
timeoutMs: 12e4
|
|
103334
103806
|
}) };
|
|
@@ -103348,7 +103820,7 @@ async function main() {
|
|
|
103348
103820
|
if (!/\.pdf$/i.test(out)) die("output must be a .pdf path", 64);
|
|
103349
103821
|
let raw;
|
|
103350
103822
|
try {
|
|
103351
|
-
raw = await (0,
|
|
103823
|
+
raw = await (0, import_promises6.readFile)(input);
|
|
103352
103824
|
} catch (e) {
|
|
103353
103825
|
die(`cannot read ${input}: ${e.message}`, 66);
|
|
103354
103826
|
}
|
|
@@ -103357,15 +103829,31 @@ async function main() {
|
|
|
103357
103829
|
const failures = [];
|
|
103358
103830
|
const loResult = await renderViaSoffice(input, cachePath);
|
|
103359
103831
|
if (loResult?.bytes) {
|
|
103360
|
-
await (0,
|
|
103832
|
+
await (0, import_promises6.writeFile)(out, Buffer.from(loResult.bytes));
|
|
103361
103833
|
process.stdout.write(`wrote ${out} [pdf (libreoffice${loResult.cached ? ", cache hit" : ""})]
|
|
103362
103834
|
`);
|
|
103363
103835
|
return;
|
|
103364
103836
|
}
|
|
103365
103837
|
if (loResult?.failed) failures.push(loResult.failed);
|
|
103838
|
+
const kn = await renderViaKeynote(input);
|
|
103839
|
+
if (kn?.bytes) {
|
|
103840
|
+
await (0, import_promises6.writeFile)(out, Buffer.from(kn.bytes));
|
|
103841
|
+
process.stdout.write(`wrote ${out} [pdf (keynote)]
|
|
103842
|
+
`);
|
|
103843
|
+
return;
|
|
103844
|
+
}
|
|
103845
|
+
if (kn?.failed) failures.push(kn.failed);
|
|
103846
|
+
const ppt = await renderViaPowerPoint(input);
|
|
103847
|
+
if (ppt?.bytes) {
|
|
103848
|
+
await (0, import_promises6.writeFile)(out, Buffer.from(ppt.bytes));
|
|
103849
|
+
process.stdout.write(`wrote ${out} [pdf (powerpoint)]
|
|
103850
|
+
`);
|
|
103851
|
+
return;
|
|
103852
|
+
}
|
|
103853
|
+
if (ppt?.failed) failures.push(ppt.failed);
|
|
103366
103854
|
const svc = await renderViaOfficeService(input, raw);
|
|
103367
103855
|
if (svc?.bytes) {
|
|
103368
|
-
await (0,
|
|
103856
|
+
await (0, import_promises6.writeFile)(out, Buffer.from(svc.bytes));
|
|
103369
103857
|
process.stdout.write(`wrote ${out} [pdf (libreoffice service)]
|
|
103370
103858
|
`);
|
|
103371
103859
|
return;
|
|
@@ -103377,7 +103865,7 @@ async function main() {
|
|
|
103377
103865
|
const policy = requireOffice ? "--require-office does not fall back" : "PPTX to PDF requires Office and cannot fall back";
|
|
103378
103866
|
die(`${failures.join("; ")} \u2014 ${policy} to a Chromium reconstruction (its layout is not Office's); retry, a timeout under load is the usual cause`, 75);
|
|
103379
103867
|
}
|
|
103380
|
-
die(`${requirement}: no
|
|
103868
|
+
die(`${requirement}: no Office engine here (no local soffice, no Keynote or PowerPoint for .pptx, TALOS_OFFICE_URL unset) \u2014 only a Chromium reconstruction is available, which is not an Office render`, 69);
|
|
103381
103869
|
}
|
|
103382
103870
|
for (const f of failures) process.stderr.write(`doc-convert: ${f}; falling back to HTML render
|
|
103383
103871
|
`);
|
|
@@ -103397,7 +103885,7 @@ async function main() {
|
|
|
103397
103885
|
}
|
|
103398
103886
|
engine = "pdf (headless chromium)";
|
|
103399
103887
|
}
|
|
103400
|
-
await (0,
|
|
103888
|
+
await (0, import_promises6.writeFile)(out, Buffer.from(bytes));
|
|
103401
103889
|
process.stdout.write(`wrote ${out} [${engine}]
|
|
103402
103890
|
`);
|
|
103403
103891
|
}
|