@taloswork/ose-shared 0.1.12 → 0.1.13
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 +33 -45
- package/skills/document/bin/deck-build.cjs +10482 -272
- package/skills/document/bin/deck-chart.cjs +21 -12
- package/skills/document/bin/deck-plan.cjs +11654 -42
- package/skills/document/bin/deck-qa.cjs +95 -21
- package/skills/document/bin/deck-scenario.cjs +20 -3
- package/skills/document/bin/deck-styles.cjs +1604 -0
- package/skills/document/bin/doc-convert.cjs +182 -257
- package/skills/document/bin/doc-fill.cjs +140 -19
- package/skills/document/bin/doc-gen.cjs +1903 -281
- package/skills/document/bin/doc-validate.cjs +127 -52
- package/skills/document/bin/docx-defaults.cjs +9907 -0
- package/skills/document/bin/html2pptx.cjs +35949 -31972
- package/skills/document/bin/pdf-form.cjs +8 -0
- package/skills/document/bin/pdf-ops.cjs +8 -0
- package/skills/document/bin/pptx-notes.cjs +10038 -0
- package/skills/document/bin/pptx-tokenize.cjs +19 -4
- package/skills/document/bin/template-skin.cjs +10910 -0
- package/skills/document/bin-reference.md +15 -10
- package/skills/document/catalog.json +33 -32
- package/skills/document/content-pipeline.md +79 -44
- package/skills/document/deck-design.md +55 -32
- package/skills/document/generated-visuals.md +99 -0
- package/skills/document/layouts/MAINTAINERS.md +33 -0
- package/skills/document/layouts/README.md +20 -20
- package/skills/document/layouts/big-stat.tpl +1 -1
- package/skills/document/layouts/capacity.json +1 -1
- package/skills/document/layouts/cards-3.tpl +1 -1
- package/skills/document/layouts/chart-full.tpl +1 -1
- package/skills/document/layouts/chart-kpi.tpl +1 -1
- package/skills/document/layouts/comparison.tpl +1 -1
- package/skills/document/layouts/data-table.tpl +1 -1
- package/skills/document/layouts/funnel.tpl +1 -1
- package/skills/document/layouts/gantt.tpl +1 -1
- package/skills/document/layouts/hub-flow.tpl +4 -0
- package/skills/document/layouts/icon-row.tpl +1 -1
- package/skills/document/layouts/image-grid.tpl +1 -1
- package/skills/document/layouts/matrix-2x2.tpl +1 -1
- package/skills/document/layouts/mock-qa.tpl +4 -0
- package/skills/document/layouts/profiles.json +2 -2
- package/skills/document/layouts/pyramid.tpl +1 -1
- package/skills/document/layouts/radar.tpl +1 -1
- package/skills/document/layouts/ring-progress.tpl +1 -1
- package/skills/document/layouts/slots.json +1 -1
- package/skills/document/layouts/steps-vertical.tpl +1 -1
- package/skills/document/layouts/steps.tpl +1 -1
- package/skills/document/layouts/three-kpi.tpl +1 -1
- package/skills/document/layouts/timeline.tpl +1 -1
- package/skills/document/layouts/toc-panel.tpl +1 -1
- package/skills/document/layouts/two-kpi.tpl +2 -2
- package/skills/document/layouts/versus.tpl +1 -1
- package/skills/document/packs/README.md +1 -1
- package/skills/document/pdf.md +13 -0
- package/skills/document/rewrite.md +23 -8
- package/skills/document/scenarios.json +19 -2
- package/skills/document/scenarios.schema.json +1 -0
- package/skills/document/styles/_backdrops/rimlight.html +3 -2
- package/skills/document/styles/_contract-defaults.css +6 -1
- package/skills/document/styles/_samples/_groups/biz-premium.webp +0 -0
- package/skills/document/styles/_samples/mckinsey.webp +0 -0
- package/skills/document/styles/mckinsey/backdrop.html +7 -5
- package/skills/grill-me/SKILL.md +6 -0
- package/skills/grill-me/agents/openai.yaml +5 -0
- package/skills/grilling/SKILL.md +28 -0
- package/skills/grilling/agents/openai.yaml +3 -0
|
@@ -3019,11 +3019,11 @@ var require_utils = __commonJS({
|
|
|
3019
3019
|
ctor2.prototype = new Obj();
|
|
3020
3020
|
};
|
|
3021
3021
|
exports2.extend = function() {
|
|
3022
|
-
var result2 = {}, i,
|
|
3022
|
+
var result2 = {}, i, attr;
|
|
3023
3023
|
for (i = 0; i < arguments.length; i++) {
|
|
3024
|
-
for (
|
|
3025
|
-
if (Object.prototype.hasOwnProperty.call(arguments[i],
|
|
3026
|
-
result2[
|
|
3024
|
+
for (attr in arguments[i]) {
|
|
3025
|
+
if (Object.prototype.hasOwnProperty.call(arguments[i], attr) && typeof result2[attr] === "undefined") {
|
|
3026
|
+
result2[attr] = arguments[i][attr];
|
|
3027
3027
|
}
|
|
3028
3028
|
}
|
|
3029
3029
|
}
|
|
@@ -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 JSZip4() {
|
|
9794
|
+
if (!(this instanceof JSZip4)) {
|
|
9795
|
+
return new JSZip4();
|
|
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 JSZip4();
|
|
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
|
+
JSZip4.prototype = require_object();
|
|
9814
|
+
JSZip4.prototype.loadAsync = require_load();
|
|
9815
|
+
JSZip4.support = require_support();
|
|
9816
|
+
JSZip4.defaults = require_defaults();
|
|
9817
|
+
JSZip4.version = "3.10.1";
|
|
9818
|
+
JSZip4.loadAsync = function(content, options) {
|
|
9819
|
+
return new JSZip4().loadAsync(content, options);
|
|
9820
9820
|
};
|
|
9821
|
-
|
|
9822
|
-
module2.exports =
|
|
9821
|
+
JSZip4.external = require_external();
|
|
9822
|
+
module2.exports = JSZip4;
|
|
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 JSZip4 = 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 JSZip4.loadAsync(arrayBuffer).then(function(zipFile) {
|
|
18410
18410
|
function exists(name) {
|
|
18411
18411
|
return zipFile.file(name) !== null;
|
|
18412
18412
|
}
|
|
@@ -18861,8 +18861,8 @@ var require_dom = __commonJS({
|
|
|
18861
18861
|
}
|
|
18862
18862
|
}
|
|
18863
18863
|
}
|
|
18864
|
-
function _removeNamedNode(el, list,
|
|
18865
|
-
var i = _findNodeIndex(list,
|
|
18864
|
+
function _removeNamedNode(el, list, attr) {
|
|
18865
|
+
var i = _findNodeIndex(list, attr);
|
|
18866
18866
|
if (i >= 0) {
|
|
18867
18867
|
var lastIndex = list.length - 1;
|
|
18868
18868
|
while (i < lastIndex) {
|
|
@@ -18872,12 +18872,12 @@ var require_dom = __commonJS({
|
|
|
18872
18872
|
if (el) {
|
|
18873
18873
|
var doc = el.ownerDocument;
|
|
18874
18874
|
if (doc) {
|
|
18875
|
-
_onRemoveAttribute(doc, el,
|
|
18876
|
-
|
|
18875
|
+
_onRemoveAttribute(doc, el, attr);
|
|
18876
|
+
attr.ownerElement = null;
|
|
18877
18877
|
}
|
|
18878
18878
|
}
|
|
18879
18879
|
} else {
|
|
18880
|
-
throw new DOMException(NOT_FOUND_ERR, new Error(el.tagName + "@" +
|
|
18880
|
+
throw new DOMException(NOT_FOUND_ERR, new Error(el.tagName + "@" + attr));
|
|
18881
18881
|
}
|
|
18882
18882
|
}
|
|
18883
18883
|
NamedNodeMap.prototype = {
|
|
@@ -18886,43 +18886,43 @@ var require_dom = __commonJS({
|
|
|
18886
18886
|
getNamedItem: function(key) {
|
|
18887
18887
|
var i = this.length;
|
|
18888
18888
|
while (i--) {
|
|
18889
|
-
var
|
|
18890
|
-
if (
|
|
18891
|
-
return
|
|
18889
|
+
var attr = this[i];
|
|
18890
|
+
if (attr.nodeName == key) {
|
|
18891
|
+
return attr;
|
|
18892
18892
|
}
|
|
18893
18893
|
}
|
|
18894
18894
|
},
|
|
18895
|
-
setNamedItem: function(
|
|
18896
|
-
var el =
|
|
18895
|
+
setNamedItem: function(attr) {
|
|
18896
|
+
var el = attr.ownerElement;
|
|
18897
18897
|
if (el && el != this._ownerElement) {
|
|
18898
18898
|
throw new DOMException(INUSE_ATTRIBUTE_ERR);
|
|
18899
18899
|
}
|
|
18900
|
-
var oldAttr = this.getNamedItem(
|
|
18901
|
-
_addNamedNode(this._ownerElement, this,
|
|
18900
|
+
var oldAttr = this.getNamedItem(attr.nodeName);
|
|
18901
|
+
_addNamedNode(this._ownerElement, this, attr, oldAttr);
|
|
18902
18902
|
return oldAttr;
|
|
18903
18903
|
},
|
|
18904
18904
|
/* returns Node */
|
|
18905
|
-
setNamedItemNS: function(
|
|
18906
|
-
var el =
|
|
18905
|
+
setNamedItemNS: function(attr) {
|
|
18906
|
+
var el = attr.ownerElement, oldAttr;
|
|
18907
18907
|
if (el && el != this._ownerElement) {
|
|
18908
18908
|
throw new DOMException(INUSE_ATTRIBUTE_ERR);
|
|
18909
18909
|
}
|
|
18910
|
-
oldAttr = this.getNamedItemNS(
|
|
18911
|
-
_addNamedNode(this._ownerElement, this,
|
|
18910
|
+
oldAttr = this.getNamedItemNS(attr.namespaceURI, attr.localName);
|
|
18911
|
+
_addNamedNode(this._ownerElement, this, attr, oldAttr);
|
|
18912
18912
|
return oldAttr;
|
|
18913
18913
|
},
|
|
18914
18914
|
/* returns Node */
|
|
18915
18915
|
removeNamedItem: function(key) {
|
|
18916
|
-
var
|
|
18917
|
-
_removeNamedNode(this._ownerElement, this,
|
|
18918
|
-
return
|
|
18916
|
+
var attr = this.getNamedItem(key);
|
|
18917
|
+
_removeNamedNode(this._ownerElement, this, attr);
|
|
18918
|
+
return attr;
|
|
18919
18919
|
},
|
|
18920
18920
|
// raises: NOT_FOUND_ERR,NO_MODIFICATION_ALLOWED_ERR
|
|
18921
18921
|
//for level2
|
|
18922
18922
|
removeNamedItemNS: function(namespaceURI, localName) {
|
|
18923
|
-
var
|
|
18924
|
-
_removeNamedNode(this._ownerElement, this,
|
|
18925
|
-
return
|
|
18923
|
+
var attr = this.getNamedItemNS(namespaceURI, localName);
|
|
18924
|
+
_removeNamedNode(this._ownerElement, this, attr);
|
|
18925
|
+
return attr;
|
|
18926
18926
|
},
|
|
18927
18927
|
getNamedItemNS: function(namespaceURI, localName) {
|
|
18928
18928
|
var i = this.length;
|
|
@@ -19424,9 +19424,9 @@ var require_dom = __commonJS({
|
|
|
19424
19424
|
node.ownerDocument = newOwnerDocument;
|
|
19425
19425
|
if (node.nodeType === ELEMENT_NODE && node.attributes) {
|
|
19426
19426
|
for (var i = 0; i < node.attributes.length; i++) {
|
|
19427
|
-
var
|
|
19428
|
-
if (
|
|
19429
|
-
|
|
19427
|
+
var attr = node.attributes.item(i);
|
|
19428
|
+
if (attr) {
|
|
19429
|
+
attr.ownerDocument = newOwnerDocument;
|
|
19430
19430
|
}
|
|
19431
19431
|
}
|
|
19432
19432
|
}
|
|
@@ -19695,20 +19695,20 @@ var require_dom = __commonJS({
|
|
|
19695
19695
|
return this.getAttributeNode(name) != null;
|
|
19696
19696
|
},
|
|
19697
19697
|
getAttribute: function(name) {
|
|
19698
|
-
var
|
|
19699
|
-
return
|
|
19698
|
+
var attr = this.getAttributeNode(name);
|
|
19699
|
+
return attr && attr.value || "";
|
|
19700
19700
|
},
|
|
19701
19701
|
getAttributeNode: function(name) {
|
|
19702
19702
|
return this.attributes.getNamedItem(name);
|
|
19703
19703
|
},
|
|
19704
19704
|
setAttribute: function(name, value) {
|
|
19705
|
-
var
|
|
19706
|
-
|
|
19707
|
-
this.setAttributeNode(
|
|
19705
|
+
var attr = this.ownerDocument.createAttribute(name);
|
|
19706
|
+
attr.value = attr.nodeValue = "" + value;
|
|
19707
|
+
this.setAttributeNode(attr);
|
|
19708
19708
|
},
|
|
19709
19709
|
removeAttribute: function(name) {
|
|
19710
|
-
var
|
|
19711
|
-
|
|
19710
|
+
var attr = this.getAttributeNode(name);
|
|
19711
|
+
attr && this.removeAttributeNode(attr);
|
|
19712
19712
|
},
|
|
19713
19713
|
//four real opeartion method
|
|
19714
19714
|
appendChild: function(newChild) {
|
|
@@ -19736,13 +19736,13 @@ var require_dom = __commonJS({
|
|
|
19736
19736
|
return this.getAttributeNodeNS(namespaceURI, localName) != null;
|
|
19737
19737
|
},
|
|
19738
19738
|
getAttributeNS: function(namespaceURI, localName) {
|
|
19739
|
-
var
|
|
19740
|
-
return
|
|
19739
|
+
var attr = this.getAttributeNodeNS(namespaceURI, localName);
|
|
19740
|
+
return attr && attr.value || "";
|
|
19741
19741
|
},
|
|
19742
19742
|
setAttributeNS: function(namespaceURI, qualifiedName, value) {
|
|
19743
|
-
var
|
|
19744
|
-
|
|
19745
|
-
this.setAttributeNode(
|
|
19743
|
+
var attr = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName);
|
|
19744
|
+
attr.value = attr.nodeValue = "" + value;
|
|
19745
|
+
this.setAttributeNode(attr);
|
|
19746
19746
|
},
|
|
19747
19747
|
getAttributeNodeNS: function(namespaceURI, localName) {
|
|
19748
19748
|
return this.attributes.getNamedItemNS(namespaceURI, localName);
|
|
@@ -19968,22 +19968,22 @@ var require_dom = __commonJS({
|
|
|
19968
19968
|
buf.push("<", prefixedNodeName);
|
|
19969
19969
|
var childNs = ns.slice();
|
|
19970
19970
|
for (var i = 0; i < len; i++) {
|
|
19971
|
-
var
|
|
19972
|
-
if (
|
|
19973
|
-
childNs.push({ prefix:
|
|
19974
|
-
} else if (
|
|
19975
|
-
childNs.push({ prefix: "", namespace:
|
|
19971
|
+
var attr = attrs.item(i);
|
|
19972
|
+
if (attr.prefix == "xmlns") {
|
|
19973
|
+
childNs.push({ prefix: attr.localName, namespace: attr.value });
|
|
19974
|
+
} else if (attr.nodeName == "xmlns") {
|
|
19975
|
+
childNs.push({ prefix: "", namespace: attr.value });
|
|
19976
19976
|
}
|
|
19977
19977
|
}
|
|
19978
19978
|
for (var i = 0; i < len; i++) {
|
|
19979
|
-
var
|
|
19980
|
-
if (needNamespaceDefine(
|
|
19981
|
-
var attrPrefix =
|
|
19982
|
-
var uri =
|
|
19979
|
+
var attr = attrs.item(i);
|
|
19980
|
+
if (needNamespaceDefine(attr, html, childNs)) {
|
|
19981
|
+
var attrPrefix = attr.prefix || "";
|
|
19982
|
+
var uri = attr.namespaceURI;
|
|
19983
19983
|
addSerializedAttribute(buf, attrPrefix ? "xmlns:" + attrPrefix : "xmlns", uri);
|
|
19984
19984
|
childNs.push({ prefix: attrPrefix, namespace: uri });
|
|
19985
19985
|
}
|
|
19986
|
-
var filteredAttr = nodeFilter ? nodeFilter(
|
|
19986
|
+
var filteredAttr = nodeFilter ? nodeFilter(attr) : attr;
|
|
19987
19987
|
if (filteredAttr) {
|
|
19988
19988
|
if (typeof filteredAttr === "string") {
|
|
19989
19989
|
buf.push(filteredAttr);
|
|
@@ -23050,10 +23050,10 @@ var require_dom_parser = __commonJS({
|
|
|
23050
23050
|
var namespaceURI = attrs.getURI(i);
|
|
23051
23051
|
var value = attrs.getValue(i);
|
|
23052
23052
|
var qName = attrs.getQName(i);
|
|
23053
|
-
var
|
|
23054
|
-
this.locator && position(attrs.getLocator(i),
|
|
23055
|
-
|
|
23056
|
-
el.setAttributeNode(
|
|
23053
|
+
var attr = doc.createAttributeNS(namespaceURI, qName);
|
|
23054
|
+
this.locator && position(attrs.getLocator(i), attr);
|
|
23055
|
+
attr.value = attr.nodeValue = value;
|
|
23056
|
+
el.setAttributeNode(attr);
|
|
23057
23057
|
}
|
|
23058
23058
|
},
|
|
23059
23059
|
endElement: function(namespaceURI, localName, qName) {
|
|
@@ -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 JSZip4 = 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 JSZip4();
|
|
37932
37932
|
this.stream = new StreamBuf();
|
|
37933
37933
|
}
|
|
37934
37934
|
append(data, options) {
|
|
@@ -39794,9 +39794,9 @@ var require_saxes = __commonJS({
|
|
|
39794
39794
|
pushAttribNS(name, value) {
|
|
39795
39795
|
var _a;
|
|
39796
39796
|
const { prefix, local } = this.qname(name);
|
|
39797
|
-
const
|
|
39798
|
-
this.attribList.push(
|
|
39799
|
-
(_a = this.attributeHandler) === null || _a === void 0 ? void 0 : _a.call(this,
|
|
39797
|
+
const attr = { name, prefix, local, value };
|
|
39798
|
+
this.attribList.push(attr);
|
|
39799
|
+
(_a = this.attributeHandler) === null || _a === void 0 ? void 0 : _a.call(this, attr);
|
|
39800
39800
|
if (prefix === "xmlns") {
|
|
39801
39801
|
const trimmed = value.trim();
|
|
39802
39802
|
if (this.currentXMLVersion === "1.0" && trimmed === "") {
|
|
@@ -39812,9 +39812,9 @@ var require_saxes = __commonJS({
|
|
|
39812
39812
|
}
|
|
39813
39813
|
pushAttribPlain(name, value) {
|
|
39814
39814
|
var _a;
|
|
39815
|
-
const
|
|
39816
|
-
this.attribList.push(
|
|
39817
|
-
(_a = this.attributeHandler) === null || _a === void 0 ? void 0 : _a.call(this,
|
|
39815
|
+
const attr = { name, value };
|
|
39816
|
+
this.attribList.push(attr);
|
|
39817
|
+
(_a = this.attributeHandler) === null || _a === void 0 ? void 0 : _a.call(this, attr);
|
|
39818
39818
|
}
|
|
39819
39819
|
/**
|
|
39820
39820
|
* End parsing. This performs final well-formedness checks and resets the
|
|
@@ -39914,8 +39914,8 @@ var require_saxes = __commonJS({
|
|
|
39914
39914
|
}
|
|
39915
39915
|
const { attributes } = tag;
|
|
39916
39916
|
const seen = /* @__PURE__ */ new Set();
|
|
39917
|
-
for (const
|
|
39918
|
-
const { name, prefix, local } =
|
|
39917
|
+
for (const attr of attribList) {
|
|
39918
|
+
const { name, prefix, local } = attr;
|
|
39919
39919
|
let uri;
|
|
39920
39920
|
let eqname;
|
|
39921
39921
|
if (prefix === "") {
|
|
@@ -39933,8 +39933,8 @@ var require_saxes = __commonJS({
|
|
|
39933
39933
|
this.fail(`duplicate attribute: ${eqname}.`);
|
|
39934
39934
|
}
|
|
39935
39935
|
seen.add(eqname);
|
|
39936
|
-
|
|
39937
|
-
attributes[name] =
|
|
39936
|
+
attr.uri = uri;
|
|
39937
|
+
attributes[name] = attr;
|
|
39938
39938
|
}
|
|
39939
39939
|
this.attribList = [];
|
|
39940
39940
|
}
|
|
@@ -40158,8 +40158,8 @@ var require_base_xform = __commonJS({
|
|
|
40158
40158
|
static toStringAttribute(value, dflt, always = false) {
|
|
40159
40159
|
return _BaseXform.toAttribute(value, dflt, always);
|
|
40160
40160
|
}
|
|
40161
|
-
static toStringValue(
|
|
40162
|
-
return
|
|
40161
|
+
static toStringValue(attr, dflt) {
|
|
40162
|
+
return attr === void 0 ? dflt : attr;
|
|
40163
40163
|
}
|
|
40164
40164
|
static toBoolAttribute(value, dflt, always = false) {
|
|
40165
40165
|
if (value === void 0) {
|
|
@@ -40171,20 +40171,20 @@ var require_base_xform = __commonJS({
|
|
|
40171
40171
|
}
|
|
40172
40172
|
return void 0;
|
|
40173
40173
|
}
|
|
40174
|
-
static toBoolValue(
|
|
40175
|
-
return
|
|
40174
|
+
static toBoolValue(attr, dflt) {
|
|
40175
|
+
return attr === void 0 ? dflt : attr === "1";
|
|
40176
40176
|
}
|
|
40177
40177
|
static toIntAttribute(value, dflt, always = false) {
|
|
40178
40178
|
return _BaseXform.toAttribute(value, dflt, always);
|
|
40179
40179
|
}
|
|
40180
|
-
static toIntValue(
|
|
40181
|
-
return
|
|
40180
|
+
static toIntValue(attr, dflt) {
|
|
40181
|
+
return attr === void 0 ? dflt : parseInt(attr, 10);
|
|
40182
40182
|
}
|
|
40183
40183
|
static toFloatAttribute(value, dflt, always = false) {
|
|
40184
40184
|
return _BaseXform.toAttribute(value, dflt, always);
|
|
40185
40185
|
}
|
|
40186
|
-
static toFloatValue(
|
|
40187
|
-
return
|
|
40186
|
+
static toFloatValue(attr, dflt) {
|
|
40187
|
+
return attr === void 0 ? dflt : parseFloat(attr);
|
|
40188
40188
|
}
|
|
40189
40189
|
};
|
|
40190
40190
|
module2.exports = BaseXform;
|
|
@@ -40538,9 +40538,9 @@ var require_underline_xform = __commonJS({
|
|
|
40538
40538
|
if (model === true) {
|
|
40539
40539
|
xmlStream.leafNode("u");
|
|
40540
40540
|
} else {
|
|
40541
|
-
const
|
|
40542
|
-
if (
|
|
40543
|
-
xmlStream.leafNode("u",
|
|
40541
|
+
const attr = _UnderlineXform.Attributes[model];
|
|
40542
|
+
if (attr) {
|
|
40543
|
+
xmlStream.leafNode("u", attr);
|
|
40544
40544
|
}
|
|
40545
40545
|
}
|
|
40546
40546
|
}
|
|
@@ -44717,7 +44717,7 @@ var require_page_setup_properties_xform = __commonJS({
|
|
|
44717
44717
|
var require_outline_properties_xform = __commonJS({
|
|
44718
44718
|
"node_modules/exceljs/lib/xlsx/xform/sheet/outline-properties-xform.js"(exports2, module2) {
|
|
44719
44719
|
var BaseXform = require_base_xform();
|
|
44720
|
-
var isDefined = (
|
|
44720
|
+
var isDefined = (attr) => typeof attr !== "undefined";
|
|
44721
44721
|
var OutlinePropertiesXform = class extends BaseXform {
|
|
44722
44722
|
get tag() {
|
|
44723
44723
|
return "outlinePr";
|
|
@@ -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 JSZip4 = 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 JSZip4.loadAsync(buffer);
|
|
49851
49851
|
for (const entry of Object.values(zip.files)) {
|
|
49852
49852
|
if (!entry.dir) {
|
|
49853
49853
|
let entryName = entry.name;
|
|
@@ -65527,8 +65527,8 @@ var require_zip_archive_entry = __commonJS({
|
|
|
65527
65527
|
}
|
|
65528
65528
|
this.crc = crc;
|
|
65529
65529
|
};
|
|
65530
|
-
ZipArchiveEntry.prototype.setExternalAttributes = function(
|
|
65531
|
-
this.exattr =
|
|
65530
|
+
ZipArchiveEntry.prototype.setExternalAttributes = function(attr) {
|
|
65531
|
+
this.exattr = attr >>> 0;
|
|
65532
65532
|
};
|
|
65533
65533
|
ZipArchiveEntry.prototype.setExtra = function(extra) {
|
|
65534
65534
|
this.extra = extra;
|
|
@@ -65539,8 +65539,8 @@ var require_zip_archive_entry = __commonJS({
|
|
|
65539
65539
|
}
|
|
65540
65540
|
this.gpb = gpb;
|
|
65541
65541
|
};
|
|
65542
|
-
ZipArchiveEntry.prototype.setInternalAttributes = function(
|
|
65543
|
-
this.inattr =
|
|
65542
|
+
ZipArchiveEntry.prototype.setInternalAttributes = function(attr) {
|
|
65543
|
+
this.inattr = attr;
|
|
65544
65544
|
};
|
|
65545
65545
|
ZipArchiveEntry.prototype.setMethod = function(method) {
|
|
65546
65546
|
if (method < 0) {
|
|
@@ -89026,65 +89026,12 @@ var import_node_path3 = require("node:path");
|
|
|
89026
89026
|
var import_promises3 = require("node:fs/promises");
|
|
89027
89027
|
|
|
89028
89028
|
// packages/core/dist/document/doc-convert.js
|
|
89029
|
-
var
|
|
89029
|
+
var import_jszip3 = __toESM(require_lib3(), 1);
|
|
89030
89030
|
var import_mammoth2 = __toESM(require_lib6(), 1);
|
|
89031
89031
|
|
|
89032
89032
|
// packages/core/dist/document/office-converter.js
|
|
89033
89033
|
var import_jszip = __toESM(require_lib3(), 1);
|
|
89034
89034
|
var import_mammoth = __toESM(require_lib6(), 1);
|
|
89035
|
-
|
|
89036
|
-
// packages/core/dist/document/ooxml-util.js
|
|
89037
|
-
function unescXml(s) {
|
|
89038
|
-
return s.replace(/&(amp|lt|gt|quot|apos|#x?[0-9a-fA-F]+);/g, (whole, code) => {
|
|
89039
|
-
switch (code) {
|
|
89040
|
-
case "amp":
|
|
89041
|
-
return "&";
|
|
89042
|
-
case "lt":
|
|
89043
|
-
return "<";
|
|
89044
|
-
case "gt":
|
|
89045
|
-
return ">";
|
|
89046
|
-
case "quot":
|
|
89047
|
-
return '"';
|
|
89048
|
-
case "apos":
|
|
89049
|
-
return "'";
|
|
89050
|
-
default: {
|
|
89051
|
-
const n = code.startsWith("#x") || code.startsWith("#X") ? parseInt(code.slice(2), 16) : parseInt(code.slice(1), 10);
|
|
89052
|
-
return Number.isInteger(n) && n >= 0 && n <= 1114111 ? String.fromCodePoint(n) : whole;
|
|
89053
|
-
}
|
|
89054
|
-
}
|
|
89055
|
-
});
|
|
89056
|
-
}
|
|
89057
|
-
|
|
89058
|
-
// packages/core/dist/document/pptx-parts.js
|
|
89059
|
-
var SLIDE_PART = /^ppt\/slides\/(slide\d+\.xml)$/;
|
|
89060
|
-
function relsPathFor(path) {
|
|
89061
|
-
return path.replace(SLIDE_PART, "ppt/slides/_rels/$1.rels");
|
|
89062
|
-
}
|
|
89063
|
-
function attr(el, name) {
|
|
89064
|
-
return new RegExp(`\\b${name}="([^"]*)"`).exec(el)?.[1];
|
|
89065
|
-
}
|
|
89066
|
-
async function slidePartsInOrder(zip) {
|
|
89067
|
-
const byNumber = Object.keys(zip.files).filter((p) => SLIDE_PART.test(p)).sort((a, b) => Number(/(\d+)\.xml$/.exec(a)[1]) - Number(/(\d+)\.xml$/.exec(b)[1]));
|
|
89068
|
-
const toParts = (paths) => paths.map((path, i) => ({ position: i + 1, path, relsPath: relsPathFor(path) }));
|
|
89069
|
-
const pres = await zip.file("ppt/presentation.xml")?.async("string");
|
|
89070
|
-
const rels = await zip.file("ppt/_rels/presentation.xml.rels")?.async("string");
|
|
89071
|
-
if (!pres || !rels)
|
|
89072
|
-
return toParts(byNumber);
|
|
89073
|
-
const targetById = /* @__PURE__ */ new Map();
|
|
89074
|
-
for (const [el] of rels.matchAll(/<Relationship\b[^>]*>/g)) {
|
|
89075
|
-
const id = attr(el, "Id");
|
|
89076
|
-
const target = attr(el, "Target");
|
|
89077
|
-
if (!id || !target)
|
|
89078
|
-
continue;
|
|
89079
|
-
targetById.set(id, target.startsWith("/") ? target.slice(1) : `ppt/${target.replace(/^\.\//, "")}`);
|
|
89080
|
-
}
|
|
89081
|
-
const list = /<p:sldIdLst\b[^>]*>([\s\S]*?)<\/p:sldIdLst>/.exec(pres)?.[1] ?? "";
|
|
89082
|
-
const ordered = [...list.matchAll(/<p:sldId\b[^>]*>/g)].map(([el]) => targetById.get(attr(el, "r:id") ?? "")).filter((p) => p !== void 0 && SLIDE_PART.test(p) && zip.file(p) !== null);
|
|
89083
|
-
const complete = ordered.length === byNumber.length && new Set(ordered).size === ordered.length;
|
|
89084
|
-
return toParts(complete ? ordered : byNumber);
|
|
89085
|
-
}
|
|
89086
|
-
|
|
89087
|
-
// packages/core/dist/document/office-converter.js
|
|
89088
89035
|
function isZipMagic(buffer) {
|
|
89089
89036
|
const b = new Uint8Array(buffer, 0, 4);
|
|
89090
89037
|
return b[0] === 80 && b[1] === 75 && b[2] === 3 && b[3] === 4;
|
|
@@ -89104,51 +89051,6 @@ async function detectZipFormat(zip) {
|
|
|
89104
89051
|
return "iwork";
|
|
89105
89052
|
return "unknown";
|
|
89106
89053
|
}
|
|
89107
|
-
function mimeFromPath(path) {
|
|
89108
|
-
const ext = path.split(".").pop()?.toLowerCase() ?? "";
|
|
89109
|
-
const map2 = {
|
|
89110
|
-
png: "image/png",
|
|
89111
|
-
jpg: "image/jpeg",
|
|
89112
|
-
jpeg: "image/jpeg",
|
|
89113
|
-
gif: "image/gif",
|
|
89114
|
-
webp: "image/webp",
|
|
89115
|
-
svg: "image/svg+xml",
|
|
89116
|
-
bmp: "image/bmp",
|
|
89117
|
-
tiff: "image/tiff",
|
|
89118
|
-
tif: "image/tiff",
|
|
89119
|
-
emf: "image/x-emf",
|
|
89120
|
-
wmf: "image/x-wmf"
|
|
89121
|
-
};
|
|
89122
|
-
return map2[ext] ?? "image/png";
|
|
89123
|
-
}
|
|
89124
|
-
function resolveRelTarget(relsFilePath, target) {
|
|
89125
|
-
const base = relsFilePath.replace(/_rels\/[^/]+$/, "");
|
|
89126
|
-
const parts = (base + target).split("/");
|
|
89127
|
-
const resolved = [];
|
|
89128
|
-
for (const part of parts) {
|
|
89129
|
-
if (part === "..")
|
|
89130
|
-
resolved.pop();
|
|
89131
|
-
else if (part !== ".")
|
|
89132
|
-
resolved.push(part);
|
|
89133
|
-
}
|
|
89134
|
-
return resolved.join("/");
|
|
89135
|
-
}
|
|
89136
|
-
function extractSlideText(xml) {
|
|
89137
|
-
const paragraphs = [];
|
|
89138
|
-
for (const pMatch of xml.matchAll(/<a:p[\s>][^]*?<\/a:p>/g)) {
|
|
89139
|
-
const texts = [];
|
|
89140
|
-
for (const tMatch of pMatch[0].matchAll(/<a:t\b[^>]*>([^<]*)<\/a:t>/g)) {
|
|
89141
|
-
texts.push(unescXml(tMatch[1]));
|
|
89142
|
-
}
|
|
89143
|
-
const para = texts.join("").trim();
|
|
89144
|
-
if (para)
|
|
89145
|
-
paragraphs.push(para);
|
|
89146
|
-
}
|
|
89147
|
-
return paragraphs.join("\n");
|
|
89148
|
-
}
|
|
89149
|
-
function imageRefsFromRels(relsXml) {
|
|
89150
|
-
return [...relsXml.matchAll(/Type="[^"]*\/image"\s+Target="([^"]+)"/g)].map((m) => m[1]);
|
|
89151
|
-
}
|
|
89152
89054
|
|
|
89153
89055
|
// node_modules/docx/dist/index.mjs
|
|
89154
89056
|
var __create2 = Object.create;
|
|
@@ -96468,14 +96370,14 @@ var require_js2xml = /* @__PURE__ */ __commonJSMin(((exports2, module2) => {
|
|
|
96468
96370
|
function writeAttributes(attributes, options, depth) {
|
|
96469
96371
|
if (options.ignoreAttributes) return "";
|
|
96470
96372
|
if ("attributesFn" in options) attributes = options.attributesFn(attributes, currentElementName, currentElement);
|
|
96471
|
-
var key,
|
|
96373
|
+
var key, attr, attrName, quote, result2 = [];
|
|
96472
96374
|
for (key in attributes) if (attributes.hasOwnProperty(key) && attributes[key] !== null && attributes[key] !== void 0) {
|
|
96473
96375
|
quote = options.noQuotesForNativeAttributes && typeof attributes[key] !== "string" ? "" : '"';
|
|
96474
|
-
|
|
96475
|
-
|
|
96476
|
-
attrName = "attributeNameFn" in options ? options.attributeNameFn(key,
|
|
96376
|
+
attr = "" + attributes[key];
|
|
96377
|
+
attr = attr.replace(/"/g, """);
|
|
96378
|
+
attrName = "attributeNameFn" in options ? options.attributeNameFn(key, attr, currentElementName, currentElement) : key;
|
|
96477
96379
|
result2.push(options.spaces && options.indentAttributes ? writeIndentation(options, depth + 1, false) : " ");
|
|
96478
|
-
result2.push(attrName + "=" + quote + ("attributeValueFn" in options ? options.attributeValueFn(
|
|
96380
|
+
result2.push(attrName + "=" + quote + ("attributeValueFn" in options ? options.attributeValueFn(attr, key, currentElementName, currentElement) : attr) + quote);
|
|
96479
96381
|
}
|
|
96480
96382
|
if (attributes && Object.keys(attributes).length && options.spaces && options.indentAttributes) result2.push(writeIndentation(options, depth, false));
|
|
96481
96383
|
return result2.join("");
|
|
@@ -101619,12 +101521,12 @@ var require_xml2 = /* @__PURE__ */ __commonJSMin(((exports2, module2) => {
|
|
|
101619
101521
|
}
|
|
101620
101522
|
}
|
|
101621
101523
|
function addXmlDeclaration(declaration) {
|
|
101622
|
-
var
|
|
101524
|
+
var attr = {
|
|
101623
101525
|
version: "1.0",
|
|
101624
101526
|
encoding: declaration.encoding || "UTF-8"
|
|
101625
101527
|
};
|
|
101626
|
-
if (declaration.standalone)
|
|
101627
|
-
add({ "?xml": { _attr:
|
|
101528
|
+
if (declaration.standalone) attr.standalone = declaration.standalone;
|
|
101529
|
+
add({ "?xml": { _attr: attr } });
|
|
101628
101530
|
output = output.replace("/>", "?>");
|
|
101629
101531
|
}
|
|
101630
101532
|
delay(function() {
|
|
@@ -102845,6 +102747,11 @@ var findPatchKeys = (text) => {
|
|
|
102845
102747
|
|
|
102846
102748
|
// packages/core/dist/document/doc-gen.js
|
|
102847
102749
|
var import_exceljs = __toESM(require_excel(), 1);
|
|
102750
|
+
|
|
102751
|
+
// packages/core/dist/document/docx-defaults.js
|
|
102752
|
+
var import_jszip2 = __toESM(require_lib3(), 1);
|
|
102753
|
+
|
|
102754
|
+
// packages/core/dist/document/doc-gen.js
|
|
102848
102755
|
var HEADINGS = [HeadingLevel.HEADING_1, HeadingLevel.HEADING_2, HeadingLevel.HEADING_3, HeadingLevel.HEADING_4];
|
|
102849
102756
|
|
|
102850
102757
|
// packages/core/dist/document/html-escape.js
|
|
@@ -102872,9 +102779,6 @@ table { border-collapse: collapse; width: 100%; margin: 8pt 0; font-size: 10.5pt
|
|
|
102872
102779
|
th, td { border: 1px solid #b9b9b9; padding: 4pt 8pt; text-align: left; vertical-align: top; }
|
|
102873
102780
|
th { background: #f2f2f2; font-weight: 700; }
|
|
102874
102781
|
img { max-width: 100%; }
|
|
102875
|
-
.slide { page-break-after: always; }
|
|
102876
|
-
.slide:last-child { page-break-after: auto; }
|
|
102877
|
-
.slide-no { color: #999; font-size: 8pt; margin: 0 0 6pt; }
|
|
102878
102782
|
`.trim();
|
|
102879
102783
|
function htmlShell(bodyHtml, title) {
|
|
102880
102784
|
const head = `<meta charset="utf-8">` + (title ? `<title>${escapeHtml(title)}</title>` : "") + `<style>${PRINT_STYLE}</style>`;
|
|
@@ -102898,32 +102802,6 @@ async function convertDocxToHtml(buffer, filename) {
|
|
|
102898
102802
|
warnings: (result2.messages ?? []).map((m) => `${m.type ?? "warning"}: ${m.message ?? ""}`)
|
|
102899
102803
|
};
|
|
102900
102804
|
}
|
|
102901
|
-
async function convertPptxToHtml(buffer, filename) {
|
|
102902
|
-
const zip = await import_jszip2.default.loadAsync(buffer);
|
|
102903
|
-
const slides = await slidePartsInOrder(zip);
|
|
102904
|
-
const sections = [];
|
|
102905
|
-
for (const { position, path, relsPath } of slides) {
|
|
102906
|
-
const xml = await zip.file(path).async("string");
|
|
102907
|
-
const paragraphs = extractSlideText(xml).split("\n").filter(Boolean);
|
|
102908
|
-
const imgs = [];
|
|
102909
|
-
const relsFile = zip.file(relsPath);
|
|
102910
|
-
if (relsFile) {
|
|
102911
|
-
for (const ref of imageRefsFromRels(await relsFile.async("string"))) {
|
|
102912
|
-
const mediaPath = resolveRelTarget(relsPath, ref);
|
|
102913
|
-
const media = zip.file(mediaPath);
|
|
102914
|
-
if (!media)
|
|
102915
|
-
continue;
|
|
102916
|
-
imgs.push(`<img src="data:${mimeFromPath(mediaPath)};base64,${await media.async("base64")}" alt="">`);
|
|
102917
|
-
}
|
|
102918
|
-
}
|
|
102919
|
-
sections.push(`<section class="slide"><div class="slide-no">${position} / ${slides.length}</div>` + paragraphs.map((p) => `<p>${escapeHtml(p)}</p>`).join("") + imgs.join("") + `</section>`);
|
|
102920
|
-
}
|
|
102921
|
-
return {
|
|
102922
|
-
kind: "pptx",
|
|
102923
|
-
html: htmlShell(sections.join("\n"), titleFromFilename(filename)),
|
|
102924
|
-
warnings: ["pptx conversion is one page per slide (text + images); in-slide layout is not reproduced"]
|
|
102925
|
-
};
|
|
102926
|
-
}
|
|
102927
102805
|
async function convertOfficeToPrintable(buffer, filename) {
|
|
102928
102806
|
if (buffer.byteLength < 4)
|
|
102929
102807
|
return { error: `\u65E0\u6CD5\u8BC6\u522B ${filename} \u7684\u6587\u4EF6\u683C\u5F0F\uFF08\u6587\u4EF6\u8FC7\u5C0F\uFF09` };
|
|
@@ -102931,10 +102809,10 @@ async function convertOfficeToPrintable(buffer, filename) {
|
|
|
102931
102809
|
return { error: `\u4E0D\u652F\u6301\u65E7\u7248 .doc/.ppt\uFF0C\u8BF7\u5148\u5728\u5BF9\u5E94\u5E94\u7528\u4E2D\u53E6\u5B58\u4E3A .docx/.pptx \u518D\u8F6C\u6362` };
|
|
102932
102810
|
}
|
|
102933
102811
|
if (!isZipMagic(buffer))
|
|
102934
|
-
return { error:
|
|
102812
|
+
return { error: `Unsupported format for ${filename}: HTML reconstruction supports .docx only` };
|
|
102935
102813
|
let zip;
|
|
102936
102814
|
try {
|
|
102937
|
-
zip = await
|
|
102815
|
+
zip = await import_jszip3.default.loadAsync(buffer);
|
|
102938
102816
|
} catch {
|
|
102939
102817
|
return { error: `\u65E0\u6CD5\u89E3\u6790 ${filename}\uFF1AZIP \u7ED3\u6784\u635F\u574F` };
|
|
102940
102818
|
}
|
|
@@ -102943,14 +102821,14 @@ async function convertOfficeToPrintable(buffer, filename) {
|
|
|
102943
102821
|
if (format === "docx")
|
|
102944
102822
|
return await convertDocxToHtml(buffer, filename);
|
|
102945
102823
|
if (format === "pptx")
|
|
102946
|
-
return
|
|
102824
|
+
return { error: "PPTX to PDF requires Office; HTML reconstruction cannot preserve the source fonts and layout" };
|
|
102947
102825
|
} catch (e) {
|
|
102948
102826
|
return { error: `\u8F6C\u6362 ${filename} \u5931\u8D25\uFF1A${String(e)}` };
|
|
102949
102827
|
}
|
|
102950
102828
|
if (format === "xlsx") {
|
|
102951
102829
|
return { error: `.xlsx \u65E0 HTML \u515C\u5E95\uFF1Axlsx\u2192PDF \u9700 LibreOffice\uFF08\u672C\u673A\u6216 sidecar\uFF09\uFF0C\u6570\u636E\u67E5\u8BE2\u7528 xlsx-query\u3001\u4EA7\u51FA\u62A5\u544A\u7528 doc-gen` };
|
|
102952
102830
|
}
|
|
102953
|
-
return { error:
|
|
102831
|
+
return { error: `Unsupported format for ${filename}: HTML reconstruction supports .docx only` };
|
|
102954
102832
|
}
|
|
102955
102833
|
|
|
102956
102834
|
// packages/core/dist/document/soffice.js
|
|
@@ -103207,10 +103085,46 @@ async function convertViaOfficeService(bytes, filename, url, options = {}) {
|
|
|
103207
103085
|
}
|
|
103208
103086
|
|
|
103209
103087
|
// apps/admin/data/skills.lib/document/bin-src/lib/headless-chromium.mjs
|
|
103210
|
-
var import_node_fs2 = require("node:fs");
|
|
103211
103088
|
var import_promises2 = require("node:fs/promises");
|
|
103212
103089
|
var import_node_module = require("node:module");
|
|
103213
103090
|
var import_node_path2 = require("node:path");
|
|
103091
|
+
|
|
103092
|
+
// packages/core/dist/document/pdf-print.js
|
|
103093
|
+
var CJK_TEXT_RE = /[\u2E80-\u30FF\u3200-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF\uFE30-\uFE4F\uFF00-\uFFEF]/;
|
|
103094
|
+
var PREPARE_FONTS = String.raw`async (fallbackFamily) => {
|
|
103095
|
+
const cjk = new RegExp(${JSON.stringify(CJK_TEXT_RE.source)});
|
|
103096
|
+
const normalize = (family) => family.trim().replace(/^['"]|['"]$/g, '').toLowerCase();
|
|
103097
|
+
const check = async () => {
|
|
103098
|
+
await document.fonts.ready;
|
|
103099
|
+
const failed = [...document.fonts].filter(face => face.status === 'error');
|
|
103100
|
+
if (failed.length) throw new Error('PDF font failed to load: ' + failed.map(face => face.family).join(', '));
|
|
103101
|
+
};
|
|
103102
|
+
await check();
|
|
103103
|
+
if (fallbackFamily && cjk.test(document.body.innerText)) {
|
|
103104
|
+
const faces = [...document.fonts];
|
|
103105
|
+
if (!faces.some(face => normalize(face.family) === normalize(fallbackFamily))) {
|
|
103106
|
+
throw new Error('PDF CJK fallback font is unavailable: ' + fallbackFamily);
|
|
103107
|
+
}
|
|
103108
|
+
const embedded = new Set(faces.filter(face => face.status === 'loaded' && normalize(face.family) !== normalize(fallbackFamily)).map(face => normalize(face.family)));
|
|
103109
|
+
const updates = [...document.body.querySelectorAll('*'), document.body]
|
|
103110
|
+
.filter(element => element.style && !['SCRIPT', 'STYLE', 'TEMPLATE', 'NOSCRIPT'].includes(element.tagName))
|
|
103111
|
+
.map(element => {
|
|
103112
|
+
const families = getComputedStyle(element).fontFamily.match(/(?:[^,"']+|"[^"]*"|'[^']*')+/g) || [];
|
|
103113
|
+
const authored = families.filter(family => normalize(family) !== normalize(fallbackFamily));
|
|
103114
|
+
return [element, [...authored.filter(family => embedded.has(normalize(family))), fallbackFamily,
|
|
103115
|
+
...authored.filter(family => !embedded.has(normalize(family)))].join(', ')];
|
|
103116
|
+
});
|
|
103117
|
+
for (const [element, family] of updates) element.style.setProperty('font-family', family, 'important');
|
|
103118
|
+
// Force layout before fonts.ready: newly selected fallback faces load lazily.
|
|
103119
|
+
document.body.getBoundingClientRect();
|
|
103120
|
+
await check();
|
|
103121
|
+
}
|
|
103122
|
+
}`;
|
|
103123
|
+
function pdfFontPreparationScript(fallbackFamily) {
|
|
103124
|
+
return `(${PREPARE_FONTS})(${JSON.stringify(fallbackFamily ?? null)})`;
|
|
103125
|
+
}
|
|
103126
|
+
|
|
103127
|
+
// apps/admin/data/skills.lib/document/bin-src/lib/headless-chromium.mjs
|
|
103214
103128
|
var NO_BROWSER_ADVICE = "Do not install packages or download a browser to work around this. Tell the user the file could not be produced here.";
|
|
103215
103129
|
function headlessBrowserDisabled() {
|
|
103216
103130
|
const v = (process.env.TALOS_HEADLESS_BROWSER ?? "").trim().toLowerCase();
|
|
@@ -103248,22 +103162,32 @@ async function launchHeadlessChromium() {
|
|
|
103248
103162
|
return null;
|
|
103249
103163
|
}
|
|
103250
103164
|
}
|
|
103251
|
-
var CJK_RE = /[\u2E80-\u2FFF\u3000-\u303F\u3040-\u30FF\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF\uFF00-\uFFEF]/;
|
|
103252
103165
|
var _fontManifest;
|
|
103253
103166
|
async function fontManifest() {
|
|
103254
103167
|
if (_fontManifest !== void 0) return _fontManifest;
|
|
103255
103168
|
const dir = process.env.TALOS_CJK_FONT_DIR || (0, import_node_path2.join)((0, import_node_path2.dirname)(process.argv[1]), "..", "assets", "fonts");
|
|
103256
103169
|
const file = (0, import_node_path2.join)(dir, "fonts.json");
|
|
103170
|
+
let manifest;
|
|
103257
103171
|
try {
|
|
103258
|
-
|
|
103259
|
-
} catch {
|
|
103260
|
-
|
|
103172
|
+
manifest = JSON.parse(await (0, import_promises2.readFile)(file, "utf8"));
|
|
103173
|
+
} catch (error) {
|
|
103174
|
+
throw new Error(`Cannot load PDF font manifest ${file}: ${error.message}`);
|
|
103261
103175
|
}
|
|
103176
|
+
if (!manifest || !Array.isArray(manifest.cjk) || !Array.isArray(manifest.latin) || typeof manifest.cjkUnicodeRange !== "string" || [...manifest.cjk, ...manifest.latin].some((entry) => !entry || typeof entry.file !== "string" || !Array.isArray(entry.families) || !entry.families.every((family) => typeof family === "string"))) {
|
|
103177
|
+
throw new Error(`Invalid PDF font manifest: ${file}`);
|
|
103178
|
+
}
|
|
103179
|
+
_fontManifest = { ...manifest, dir };
|
|
103262
103180
|
return _fontManifest;
|
|
103263
103181
|
}
|
|
103264
103182
|
var _faceB64 = /* @__PURE__ */ new Map();
|
|
103265
103183
|
async function faceBase64(path) {
|
|
103266
|
-
if (!_faceB64.has(path))
|
|
103184
|
+
if (!_faceB64.has(path)) {
|
|
103185
|
+
const bytes = await (0, import_promises2.readFile)(path).catch((error) => {
|
|
103186
|
+
throw new Error(`Cannot load PDF font ${path}: ${error.message}`);
|
|
103187
|
+
});
|
|
103188
|
+
if (!bytes.length) throw new Error(`Empty PDF font: ${path}`);
|
|
103189
|
+
_faceB64.set(path, bytes.toString("base64"));
|
|
103190
|
+
}
|
|
103267
103191
|
return _faceB64.get(path);
|
|
103268
103192
|
}
|
|
103269
103193
|
async function faceCss(entries, range2, doc) {
|
|
@@ -103273,9 +103197,7 @@ async function faceCss(entries, range2, doc) {
|
|
|
103273
103197
|
const families = doc ? (entry.families ?? []).filter((f) => doc.includes(f)) : entry.families ?? [];
|
|
103274
103198
|
if (!families.length) continue;
|
|
103275
103199
|
const path = (0, import_node_path2.join)(dir, entry.file);
|
|
103276
|
-
if (!(0, import_node_fs2.existsSync)(path)) continue;
|
|
103277
103200
|
const b64 = await faceBase64(path);
|
|
103278
|
-
if (!b64) continue;
|
|
103279
103201
|
for (const family of families) {
|
|
103280
103202
|
rules.push(
|
|
103281
103203
|
`@font-face{font-family:'${family}';src:local('${family}'),url(data:font/woff2;base64,${b64}) format('woff2');${entry.weight ? `font-weight:${entry.weight};` : ""}${range2 ? `unicode-range:${range2};` : ""}font-display:swap}`
|
|
@@ -103304,17 +103226,16 @@ function injectStyle(html, css) {
|
|
|
103304
103226
|
const tag = `<style>${css}</style>`;
|
|
103305
103227
|
return html.includes("</head>") ? html.replace("</head>", `${tag}</head>`) : tag + html;
|
|
103306
103228
|
}
|
|
103307
|
-
async function renderPdfHeadless(html
|
|
103229
|
+
async function renderPdfHeadless(html) {
|
|
103308
103230
|
const browser2 = await launchHeadlessChromium();
|
|
103309
103231
|
if (!browser2) return null;
|
|
103310
103232
|
try {
|
|
103311
103233
|
const page = await browser2.newPage();
|
|
103312
|
-
const faces = (
|
|
103234
|
+
const faces = (CJK_TEXT_RE.test(html) ? await cjkFontFaceCss(html) : "") + await latinFontFaceCss(html);
|
|
103235
|
+
await page.emulateMedia({ media: "print" });
|
|
103313
103236
|
await page.setContent(faces ? injectStyle(html, faces) : html, { waitUntil: "load" });
|
|
103314
|
-
await page.evaluate(
|
|
103315
|
-
});
|
|
103316
|
-
const hf = print.headerTemplate || print.footerTemplate ? { displayHeaderFooter: true, headerTemplate: print.headerTemplate || "<span></span>", footerTemplate: print.footerTemplate || "<span></span>" } : {};
|
|
103317
|
-
return new Uint8Array(await page.pdf({ printBackground: true, preferCSSPageSize: true, ...hf }));
|
|
103237
|
+
await page.evaluate(pdfFontPreparationScript());
|
|
103238
|
+
return new Uint8Array(await page.pdf({ printBackground: true, preferCSSPageSize: true }));
|
|
103318
103239
|
} finally {
|
|
103319
103240
|
await browser2.close().catch(() => {
|
|
103320
103241
|
});
|
|
@@ -103435,9 +103356,13 @@ async function main() {
|
|
|
103435
103356
|
return;
|
|
103436
103357
|
}
|
|
103437
103358
|
if (svc?.failed) failures.push(svc.failed);
|
|
103438
|
-
if (requireOffice) {
|
|
103439
|
-
|
|
103440
|
-
|
|
103359
|
+
if (requireOffice || /\.pptx$/i.test(input)) {
|
|
103360
|
+
const requirement = requireOffice ? "--require-office" : "PPTX to PDF requires Office";
|
|
103361
|
+
if (failures.length) {
|
|
103362
|
+
const policy = requireOffice ? "--require-office does not fall back" : "PPTX to PDF requires Office and cannot fall back";
|
|
103363
|
+
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);
|
|
103364
|
+
}
|
|
103365
|
+
die(`${requirement}: no LibreOffice engine here (no local soffice, TALOS_OFFICE_URL unset) \u2014 only a Chromium reconstruction is available, which is not an Office render`, 69);
|
|
103441
103366
|
}
|
|
103442
103367
|
for (const f of failures) process.stderr.write(`doc-convert: ${f}; falling back to HTML render
|
|
103443
103368
|
`);
|