@taloswork/ose-shared 0.1.12 → 0.1.14

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.
Files changed (71) hide show
  1. package/package.json +3 -3
  2. package/skills/document/SKILL.md +33 -45
  3. package/skills/document/bin/deck-build.cjs +10482 -272
  4. package/skills/document/bin/deck-chart.cjs +21 -12
  5. package/skills/document/bin/deck-plan.cjs +11654 -42
  6. package/skills/document/bin/deck-qa.cjs +107 -23
  7. package/skills/document/bin/deck-scenario.cjs +20 -3
  8. package/skills/document/bin/deck-styles.cjs +1604 -0
  9. package/skills/document/bin/doc-convert.cjs +200 -260
  10. package/skills/document/bin/doc-fill.cjs +140 -19
  11. package/skills/document/bin/doc-gen.cjs +1909 -282
  12. package/skills/document/bin/doc-scan.cjs +6 -1
  13. package/skills/document/bin/doc-text.cjs +6 -1
  14. package/skills/document/bin/doc-validate.cjs +139 -54
  15. package/skills/document/bin/docx-defaults.cjs +9907 -0
  16. package/skills/document/bin/html2pptx.cjs +35960 -31973
  17. package/skills/document/bin/pdf-form.cjs +14 -1
  18. package/skills/document/bin/pdf-images.cjs +6 -1
  19. package/skills/document/bin/pdf-ops.cjs +14 -1
  20. package/skills/document/bin/pdf-render.cjs +6 -1
  21. package/skills/document/bin/pdf-tables.cjs +6 -1
  22. package/skills/document/bin/pptx-notes.cjs +10038 -0
  23. package/skills/document/bin/pptx-tokenize.cjs +19 -4
  24. package/skills/document/bin/template-skin.cjs +10915 -0
  25. package/skills/document/bin-reference.md +15 -10
  26. package/skills/document/catalog.json +33 -32
  27. package/skills/document/content-pipeline.md +79 -44
  28. package/skills/document/deck-design.md +55 -32
  29. package/skills/document/generated-visuals.md +99 -0
  30. package/skills/document/layouts/MAINTAINERS.md +33 -0
  31. package/skills/document/layouts/README.md +20 -20
  32. package/skills/document/layouts/big-stat.tpl +1 -1
  33. package/skills/document/layouts/capacity.json +1 -1
  34. package/skills/document/layouts/cards-3.tpl +1 -1
  35. package/skills/document/layouts/chart-full.tpl +1 -1
  36. package/skills/document/layouts/chart-kpi.tpl +1 -1
  37. package/skills/document/layouts/comparison.tpl +1 -1
  38. package/skills/document/layouts/data-table.tpl +1 -1
  39. package/skills/document/layouts/funnel.tpl +1 -1
  40. package/skills/document/layouts/gantt.tpl +1 -1
  41. package/skills/document/layouts/hub-flow.tpl +4 -0
  42. package/skills/document/layouts/icon-row.tpl +1 -1
  43. package/skills/document/layouts/image-grid.tpl +1 -1
  44. package/skills/document/layouts/matrix-2x2.tpl +1 -1
  45. package/skills/document/layouts/mock-qa.tpl +4 -0
  46. package/skills/document/layouts/profiles.json +2 -2
  47. package/skills/document/layouts/pyramid.tpl +1 -1
  48. package/skills/document/layouts/radar.tpl +1 -1
  49. package/skills/document/layouts/ring-progress.tpl +1 -1
  50. package/skills/document/layouts/slots.json +1 -1
  51. package/skills/document/layouts/steps-vertical.tpl +1 -1
  52. package/skills/document/layouts/steps.tpl +1 -1
  53. package/skills/document/layouts/three-kpi.tpl +1 -1
  54. package/skills/document/layouts/timeline.tpl +1 -1
  55. package/skills/document/layouts/toc-panel.tpl +1 -1
  56. package/skills/document/layouts/two-kpi.tpl +2 -2
  57. package/skills/document/layouts/versus.tpl +1 -1
  58. package/skills/document/packs/README.md +1 -1
  59. package/skills/document/pdf.md +13 -0
  60. package/skills/document/rewrite.md +23 -8
  61. package/skills/document/scenarios.json +19 -2
  62. package/skills/document/scenarios.schema.json +1 -0
  63. package/skills/document/styles/_backdrops/rimlight.html +3 -2
  64. package/skills/document/styles/_contract-defaults.css +6 -1
  65. package/skills/document/styles/_samples/_groups/biz-premium.webp +0 -0
  66. package/skills/document/styles/_samples/mckinsey.webp +0 -0
  67. package/skills/document/styles/mckinsey/backdrop.html +7 -5
  68. package/skills/grill-me/SKILL.md +6 -0
  69. package/skills/grill-me/agents/openai.yaml +5 -0
  70. package/skills/grilling/SKILL.md +28 -0
  71. 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, attr2;
3022
+ var result2 = {}, i, attr;
3023
3023
  for (i = 0; i < arguments.length; i++) {
3024
- for (attr2 in arguments[i]) {
3025
- if (Object.prototype.hasOwnProperty.call(arguments[i], attr2) && typeof result2[attr2] === "undefined") {
3026
- result2[attr2] = arguments[i][attr2];
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 JSZip3() {
9794
- if (!(this instanceof JSZip3)) {
9795
- return new JSZip3();
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 JSZip3();
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
- JSZip3.prototype = require_object();
9814
- JSZip3.prototype.loadAsync = require_load();
9815
- JSZip3.support = require_support();
9816
- JSZip3.defaults = require_defaults();
9817
- JSZip3.version = "3.10.1";
9818
- JSZip3.loadAsync = function(content, options) {
9819
- return new JSZip3().loadAsync(content, options);
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
- JSZip3.external = require_external();
9822
- module2.exports = JSZip3;
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 JSZip3 = require_lib3();
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 JSZip3.loadAsync(arrayBuffer).then(function(zipFile) {
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, attr2) {
18865
- var i = _findNodeIndex(list, attr2);
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, attr2);
18876
- attr2.ownerElement = null;
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 + "@" + attr2));
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 attr2 = this[i];
18890
- if (attr2.nodeName == key) {
18891
- return attr2;
18889
+ var attr = this[i];
18890
+ if (attr.nodeName == key) {
18891
+ return attr;
18892
18892
  }
18893
18893
  }
18894
18894
  },
18895
- setNamedItem: function(attr2) {
18896
- var el = attr2.ownerElement;
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(attr2.nodeName);
18901
- _addNamedNode(this._ownerElement, this, attr2, oldAttr);
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(attr2) {
18906
- var el = attr2.ownerElement, oldAttr;
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(attr2.namespaceURI, attr2.localName);
18911
- _addNamedNode(this._ownerElement, this, attr2, oldAttr);
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 attr2 = this.getNamedItem(key);
18917
- _removeNamedNode(this._ownerElement, this, attr2);
18918
- return attr2;
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 attr2 = this.getNamedItemNS(namespaceURI, localName);
18924
- _removeNamedNode(this._ownerElement, this, attr2);
18925
- return attr2;
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 attr2 = node.attributes.item(i);
19428
- if (attr2) {
19429
- attr2.ownerDocument = newOwnerDocument;
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 attr2 = this.getAttributeNode(name);
19699
- return attr2 && attr2.value || "";
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 attr2 = this.ownerDocument.createAttribute(name);
19706
- attr2.value = attr2.nodeValue = "" + value;
19707
- this.setAttributeNode(attr2);
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 attr2 = this.getAttributeNode(name);
19711
- attr2 && this.removeAttributeNode(attr2);
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 attr2 = this.getAttributeNodeNS(namespaceURI, localName);
19740
- return attr2 && attr2.value || "";
19739
+ var attr = this.getAttributeNodeNS(namespaceURI, localName);
19740
+ return attr && attr.value || "";
19741
19741
  },
19742
19742
  setAttributeNS: function(namespaceURI, qualifiedName, value) {
19743
- var attr2 = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName);
19744
- attr2.value = attr2.nodeValue = "" + value;
19745
- this.setAttributeNode(attr2);
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 attr2 = attrs.item(i);
19972
- if (attr2.prefix == "xmlns") {
19973
- childNs.push({ prefix: attr2.localName, namespace: attr2.value });
19974
- } else if (attr2.nodeName == "xmlns") {
19975
- childNs.push({ prefix: "", namespace: attr2.value });
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 attr2 = attrs.item(i);
19980
- if (needNamespaceDefine(attr2, html, childNs)) {
19981
- var attrPrefix = attr2.prefix || "";
19982
- var uri = attr2.namespaceURI;
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(attr2) : attr2;
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 attr2 = doc.createAttributeNS(namespaceURI, qName);
23054
- this.locator && position(attrs.getLocator(i), attr2);
23055
- attr2.value = attr2.nodeValue = value;
23056
- el.setAttributeNode(attr2);
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 JSZip3 = require_lib3();
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 JSZip3();
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 attr2 = { name, prefix, local, value };
39798
- this.attribList.push(attr2);
39799
- (_a = this.attributeHandler) === null || _a === void 0 ? void 0 : _a.call(this, attr2);
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 attr2 = { name, value };
39816
- this.attribList.push(attr2);
39817
- (_a = this.attributeHandler) === null || _a === void 0 ? void 0 : _a.call(this, attr2);
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 attr2 of attribList) {
39918
- const { name, prefix, local } = attr2;
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
- attr2.uri = uri;
39937
- attributes[name] = attr2;
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(attr2, dflt) {
40162
- return attr2 === void 0 ? dflt : attr2;
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(attr2, dflt) {
40175
- return attr2 === void 0 ? dflt : attr2 === "1";
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(attr2, dflt) {
40181
- return attr2 === void 0 ? dflt : parseInt(attr2, 10);
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(attr2, dflt) {
40187
- return attr2 === void 0 ? dflt : parseFloat(attr2);
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 attr2 = _UnderlineXform.Attributes[model];
40542
- if (attr2) {
40543
- xmlStream.leafNode("u", attr2);
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 = (attr2) => typeof attr2 !== "undefined";
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 JSZip3 = require_lib3();
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 JSZip3.loadAsync(buffer);
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(attr2) {
65531
- this.exattr = attr2 >>> 0;
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(attr2) {
65543
- this.inattr = attr2;
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 import_jszip2 = __toESM(require_lib3(), 1);
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, attr2, attrName, quote, result2 = [];
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
- attr2 = "" + attributes[key];
96475
- attr2 = attr2.replace(/"/g, "&quot;");
96476
- attrName = "attributeNameFn" in options ? options.attributeNameFn(key, attr2, currentElementName, currentElement) : key;
96376
+ attr = "" + attributes[key];
96377
+ attr = attr.replace(/"/g, "&quot;");
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(attr2, key, currentElementName, currentElement) : attr2) + quote);
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 attr2 = {
101524
+ var attr = {
101623
101525
  version: "1.0",
101624
101526
  encoding: declaration.encoding || "UTF-8"
101625
101527
  };
101626
- if (declaration.standalone) attr2.standalone = declaration.standalone;
101627
- add({ "?xml": { _attr: attr2 } });
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: `\u4E0D\u652F\u6301 ${filename} \u7684\u6587\u4EF6\u683C\u5F0F\uFF08doc-convert \u53EA\u652F\u6301 .docx/.pptx\uFF09` };
102812
+ return { error: `Unsupported format for ${filename}: HTML reconstruction supports .docx only` };
102935
102813
  let zip;
102936
102814
  try {
102937
- zip = await import_jszip2.default.loadAsync(buffer);
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 await convertPptxToHtml(buffer, filename);
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: `\u4E0D\u652F\u6301 ${filename} \u7684\u6587\u4EF6\u683C\u5F0F\uFF08doc-convert \u53EA\u652F\u6301 .docx/.pptx\uFF09` };
102831
+ return { error: `Unsupported format for ${filename}: HTML reconstruction supports .docx only` };
102954
102832
  }
102955
102833
 
102956
102834
  // packages/core/dist/document/soffice.js
@@ -103048,9 +102926,13 @@ async function convertToPdfViaSoffice(inputPath, options = {}) {
103048
102926
  const profileDir = await (0, import_promises.mkdtemp)((0, import_node_path.join)((0, import_node_os.tmpdir)(), "talos-lo-profile-"));
103049
102927
  const outDir = await (0, import_promises.mkdtemp)((0, import_node_path.join)((0, import_node_os.tmpdir)(), "talos-lo-out-"));
103050
102928
  try {
102929
+ let env2;
103051
102930
  if (isMacAppSoffice(soffice)) {
103052
102931
  await (0, import_promises.mkdir)((0, import_node_path.join)(profileDir, "user"), { recursive: true });
103053
102932
  await (0, import_promises.writeFile)((0, import_node_path.join)(profileDir, "user", "registrymodifications.xcu"), macFontReplacementXcu(missingWebFonts()));
102933
+ const fontsConf = (0, import_node_path.join)(profileDir, "fonts.conf");
102934
+ await (0, import_promises.writeFile)(fontsConf, MAC_FONTCONFIG_CONF);
102935
+ env2 = { ...process.env, FONTCONFIG_FILE: fontsConf };
103054
102936
  }
103055
102937
  await runSoffice(soffice, [
103056
102938
  "--headless",
@@ -103064,7 +102946,7 @@ async function convertToPdfViaSoffice(inputPath, options = {}) {
103064
102946
  "--outdir",
103065
102947
  outDir,
103066
102948
  inputPath
103067
- ], options.timeoutMs ?? sofficeTimeoutMs((0, import_node_fs.statSync)(inputPath).size));
102949
+ ], options.timeoutMs ?? sofficeTimeoutMs((0, import_node_fs.statSync)(inputPath).size), env2);
103068
102950
  const pdfs = (await (0, import_promises.readdir)(outDir)).filter((f) => f.toLowerCase().endsWith(".pdf"));
103069
102951
  const chosen = pickConvertedPdf(pdfs, inputPath);
103070
102952
  if (!chosen)
@@ -103093,6 +102975,17 @@ var MAC_CJK_FONT_REPLACEMENT_XCU = `<?xml version="1.0" encoding="UTF-8"?>
103093
102975
  <item oor:path="/org.openoffice.Office.Common/Font/Substitution/FontPairs"><node oor:name="_0" 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>Microsoft YaHei</value></prop><prop oor:name="SubstituteFont" oor:op="fuse"><value>\u51AC\u9752\u9ED1\u4F53\u7B80\u4F53\u4E2D\u6587</value></prop></node><node oor:name="_1" 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>Microsoft JhengHei</value></prop><prop oor:name="SubstituteFont" oor:op="fuse"><value>\u9ED1\u4F53-\u7E41</value></prop></node></item>
103094
102976
  </oor:items>
103095
102977
  `;
102978
+ var MAC_FONTCONFIG_CONF = `<?xml version="1.0"?>
102979
+ <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
102980
+ <fontconfig>
102981
+ <dir>/System/Library/Fonts</dir>
102982
+ <dir>/Library/Fonts</dir>
102983
+ <dir>~/Library/Fonts</dir>
102984
+ <cachedir prefix="xdg">fontconfig</cachedir>
102985
+ <alias binding="same"><family>Microsoft YaHei</family><prefer><family>Hiragino Sans GB</family></prefer></alias>
102986
+ <alias binding="same"><family>Microsoft JhengHei</family><prefer><family>Heiti TC</family></prefer></alias>
102987
+ </fontconfig>
102988
+ `;
103096
102989
  var SANS = { group: "sans", mac: "Arial", cloud: "Liberation Sans" };
103097
102990
  var SERIF_TIMES = { group: "serif", mac: "Times New Roman", cloud: "Liberation Serif" };
103098
102991
  var SERIF_GEORGIA = { group: "serif", mac: "Georgia", cloud: "Liberation Serif" };
@@ -103154,9 +103047,9 @@ function macFontReplacementXcu(missing) {
103154
103047
  const extra = missing.map((f, i) => fontPair(i + 2, f, WEB_FONT_SUBSTITUTES[f]?.mac ?? "Arial")).join("");
103155
103048
  return MAC_CJK_FONT_REPLACEMENT_XCU.replace("</node></item>", `</node>${extra}</item>`);
103156
103049
  }
103157
- function runSoffice(bin, args, timeoutMs) {
103050
+ function runSoffice(bin, args, timeoutMs, env2) {
103158
103051
  return new Promise((resolve, reject2) => {
103159
- const child = (0, import_node_child_process.spawn)(bin, args, { stdio: ["ignore", "pipe", "pipe"] });
103052
+ const child = (0, import_node_child_process.spawn)(bin, args, { stdio: ["ignore", "pipe", "pipe"], ...env2 ? { env: env2 } : {} });
103160
103053
  let stderr = "";
103161
103054
  const timer = setTimeout(() => {
103162
103055
  child.kill("SIGKILL");
@@ -103207,10 +103100,46 @@ async function convertViaOfficeService(bytes, filename, url, options = {}) {
103207
103100
  }
103208
103101
 
103209
103102
  // apps/admin/data/skills.lib/document/bin-src/lib/headless-chromium.mjs
103210
- var import_node_fs2 = require("node:fs");
103211
103103
  var import_promises2 = require("node:fs/promises");
103212
103104
  var import_node_module = require("node:module");
103213
103105
  var import_node_path2 = require("node:path");
103106
+
103107
+ // packages/core/dist/document/pdf-print.js
103108
+ var CJK_TEXT_RE = /[\u2E80-\u30FF\u3200-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF\uFE30-\uFE4F\uFF00-\uFFEF]/;
103109
+ var PREPARE_FONTS = String.raw`async (fallbackFamily) => {
103110
+ const cjk = new RegExp(${JSON.stringify(CJK_TEXT_RE.source)});
103111
+ const normalize = (family) => family.trim().replace(/^['"]|['"]$/g, '').toLowerCase();
103112
+ const check = async () => {
103113
+ await document.fonts.ready;
103114
+ const failed = [...document.fonts].filter(face => face.status === 'error');
103115
+ if (failed.length) throw new Error('PDF font failed to load: ' + failed.map(face => face.family).join(', '));
103116
+ };
103117
+ await check();
103118
+ if (fallbackFamily && cjk.test(document.body.innerText)) {
103119
+ const faces = [...document.fonts];
103120
+ if (!faces.some(face => normalize(face.family) === normalize(fallbackFamily))) {
103121
+ throw new Error('PDF CJK fallback font is unavailable: ' + fallbackFamily);
103122
+ }
103123
+ const embedded = new Set(faces.filter(face => face.status === 'loaded' && normalize(face.family) !== normalize(fallbackFamily)).map(face => normalize(face.family)));
103124
+ const updates = [...document.body.querySelectorAll('*'), document.body]
103125
+ .filter(element => element.style && !['SCRIPT', 'STYLE', 'TEMPLATE', 'NOSCRIPT'].includes(element.tagName))
103126
+ .map(element => {
103127
+ const families = getComputedStyle(element).fontFamily.match(/(?:[^,"']+|"[^"]*"|'[^']*')+/g) || [];
103128
+ const authored = families.filter(family => normalize(family) !== normalize(fallbackFamily));
103129
+ return [element, [...authored.filter(family => embedded.has(normalize(family))), fallbackFamily,
103130
+ ...authored.filter(family => !embedded.has(normalize(family)))].join(', ')];
103131
+ });
103132
+ for (const [element, family] of updates) element.style.setProperty('font-family', family, 'important');
103133
+ // Force layout before fonts.ready: newly selected fallback faces load lazily.
103134
+ document.body.getBoundingClientRect();
103135
+ await check();
103136
+ }
103137
+ }`;
103138
+ function pdfFontPreparationScript(fallbackFamily) {
103139
+ return `(${PREPARE_FONTS})(${JSON.stringify(fallbackFamily ?? null)})`;
103140
+ }
103141
+
103142
+ // apps/admin/data/skills.lib/document/bin-src/lib/headless-chromium.mjs
103214
103143
  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
103144
  function headlessBrowserDisabled() {
103216
103145
  const v = (process.env.TALOS_HEADLESS_BROWSER ?? "").trim().toLowerCase();
@@ -103248,22 +103177,32 @@ async function launchHeadlessChromium() {
103248
103177
  return null;
103249
103178
  }
103250
103179
  }
103251
- var CJK_RE = /[\u2E80-\u2FFF\u3000-\u303F\u3040-\u30FF\u3400-\u4DBF\u4E00-\u9FFF\uF900-\uFAFF\uFF00-\uFFEF]/;
103252
103180
  var _fontManifest;
103253
103181
  async function fontManifest() {
103254
103182
  if (_fontManifest !== void 0) return _fontManifest;
103255
103183
  const dir = process.env.TALOS_CJK_FONT_DIR || (0, import_node_path2.join)((0, import_node_path2.dirname)(process.argv[1]), "..", "assets", "fonts");
103256
103184
  const file = (0, import_node_path2.join)(dir, "fonts.json");
103185
+ let manifest;
103257
103186
  try {
103258
- _fontManifest = { dir, ...JSON.parse(await (0, import_promises2.readFile)(file, "utf8")) };
103259
- } catch {
103260
- _fontManifest = { dir, cjk: [], latin: [], cjkUnicodeRange: "" };
103187
+ manifest = JSON.parse(await (0, import_promises2.readFile)(file, "utf8"));
103188
+ } catch (error) {
103189
+ throw new Error(`Cannot load PDF font manifest ${file}: ${error.message}`);
103261
103190
  }
103191
+ 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"))) {
103192
+ throw new Error(`Invalid PDF font manifest: ${file}`);
103193
+ }
103194
+ _fontManifest = { ...manifest, dir };
103262
103195
  return _fontManifest;
103263
103196
  }
103264
103197
  var _faceB64 = /* @__PURE__ */ new Map();
103265
103198
  async function faceBase64(path) {
103266
- if (!_faceB64.has(path)) _faceB64.set(path, (await (0, import_promises2.readFile)(path).catch(() => null))?.toString("base64") ?? null);
103199
+ if (!_faceB64.has(path)) {
103200
+ const bytes = await (0, import_promises2.readFile)(path).catch((error) => {
103201
+ throw new Error(`Cannot load PDF font ${path}: ${error.message}`);
103202
+ });
103203
+ if (!bytes.length) throw new Error(`Empty PDF font: ${path}`);
103204
+ _faceB64.set(path, bytes.toString("base64"));
103205
+ }
103267
103206
  return _faceB64.get(path);
103268
103207
  }
103269
103208
  async function faceCss(entries, range2, doc) {
@@ -103273,9 +103212,7 @@ async function faceCss(entries, range2, doc) {
103273
103212
  const families = doc ? (entry.families ?? []).filter((f) => doc.includes(f)) : entry.families ?? [];
103274
103213
  if (!families.length) continue;
103275
103214
  const path = (0, import_node_path2.join)(dir, entry.file);
103276
- if (!(0, import_node_fs2.existsSync)(path)) continue;
103277
103215
  const b64 = await faceBase64(path);
103278
- if (!b64) continue;
103279
103216
  for (const family of families) {
103280
103217
  rules.push(
103281
103218
  `@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 +103241,16 @@ function injectStyle(html, css) {
103304
103241
  const tag = `<style>${css}</style>`;
103305
103242
  return html.includes("</head>") ? html.replace("</head>", `${tag}</head>`) : tag + html;
103306
103243
  }
103307
- async function renderPdfHeadless(html, print = {}) {
103244
+ async function renderPdfHeadless(html) {
103308
103245
  const browser2 = await launchHeadlessChromium();
103309
103246
  if (!browser2) return null;
103310
103247
  try {
103311
103248
  const page = await browser2.newPage();
103312
- const faces = (CJK_RE.test(html) ? await cjkFontFaceCss(html) : "") + await latinFontFaceCss(html);
103249
+ const faces = (CJK_TEXT_RE.test(html) ? await cjkFontFaceCss(html) : "") + await latinFontFaceCss(html);
103250
+ await page.emulateMedia({ media: "print" });
103313
103251
  await page.setContent(faces ? injectStyle(html, faces) : html, { waitUntil: "load" });
103314
- await page.evaluate("document.fonts && document.fonts.ready").catch(() => {
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 }));
103252
+ await page.evaluate(pdfFontPreparationScript());
103253
+ return new Uint8Array(await page.pdf({ printBackground: true, preferCSSPageSize: true }));
103318
103254
  } finally {
103319
103255
  await browser2.close().catch(() => {
103320
103256
  });
@@ -103435,9 +103371,13 @@ async function main() {
103435
103371
  return;
103436
103372
  }
103437
103373
  if (svc?.failed) failures.push(svc.failed);
103438
- if (requireOffice) {
103439
- if (failures.length) die(`${failures.join("; ")} \u2014 --require-office does not fall back to a Chromium reconstruction (its layout is not Office's); retry, a timeout under load is the usual cause`, 75);
103440
- die("--require-office: 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);
103374
+ if (requireOffice || /\.pptx$/i.test(input)) {
103375
+ const requirement = requireOffice ? "--require-office" : "PPTX to PDF requires Office";
103376
+ if (failures.length) {
103377
+ const policy = requireOffice ? "--require-office does not fall back" : "PPTX to PDF requires Office and cannot fall back";
103378
+ 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
+ }
103380
+ 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
103381
  }
103442
103382
  for (const f of failures) process.stderr.write(`doc-convert: ${f}; falling back to HTML render
103443
103383
  `);