pptx-glimpse 0.4.0 → 0.4.1

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/dist/index.cjs CHANGED
@@ -1540,8 +1540,8 @@ var standardParser = new import_fast_xml_parser.XMLParser({
1540
1540
  attributeNamePrefix: "@_",
1541
1541
  removeNSPrefix: true,
1542
1542
  htmlEntities: true,
1543
- isArray: (_name, jpath) => {
1544
- const tag = jpath.split(".").pop() ?? "";
1543
+ isArray: (_name, jpath, _isLeafNode, _isAttribute) => {
1544
+ const tag = String(jpath).split(".").pop() ?? "";
1545
1545
  return ARRAY_TAGS.has(tag);
1546
1546
  }
1547
1547
  });
@@ -6276,7 +6276,8 @@ var presetGeometries = {
6276
6276
  rect: (w, h) => `<rect width="${w}" height="${h}"/>`,
6277
6277
  ellipse: (w, h) => `<ellipse cx="${w / 2}" cy="${h / 2}" rx="${w / 2}" ry="${h / 2}"/>`,
6278
6278
  roundRect: (w, h, adj) => {
6279
- const r = (adj["adj"] ?? 16667) / 1e5 * Math.min(w, h);
6279
+ const a = Math.min(5e4, Math.max(0, adj["adj"] ?? 16667));
6280
+ const r = a / 1e5 * Math.min(w, h);
6280
6281
  return `<rect width="${w}" height="${h}" rx="${r}" ry="${r}"/>`;
6281
6282
  },
6282
6283
  triangle: (w, h, adj) => {
@@ -6922,17 +6923,22 @@ var presetGeometries = {
6922
6923
  return `<path d="M ${r} 0 L ${w - d} 0 L ${w} ${d} L ${w} ${h} L 0 ${h} L 0 ${r} A ${r} ${r} 0 0 1 ${r} 0 Z"/>`;
6923
6924
  },
6924
6925
  round1Rect: (w, h, adj) => {
6925
- const r = (adj["adj"] ?? 16667) / 1e5 * Math.min(w, h);
6926
+ const a = Math.min(5e4, Math.max(0, adj["adj"] ?? 16667));
6927
+ const r = a / 1e5 * Math.min(w, h);
6926
6928
  return `<path d="M 0 0 L ${w - r} 0 A ${r} ${r} 0 0 1 ${w} ${r} L ${w} ${h} L 0 ${h} Z"/>`;
6927
6929
  },
6928
6930
  round2SameRect: (w, h, adj) => {
6929
- const r1 = (adj["adj1"] ?? 16667) / 1e5 * Math.min(w, h);
6930
- const r2 = (adj["adj2"] ?? 0) / 1e5 * Math.min(w, h);
6931
+ const a1 = Math.min(5e4, Math.max(0, adj["adj1"] ?? 16667));
6932
+ const a2 = Math.min(5e4, Math.max(0, adj["adj2"] ?? 0));
6933
+ const r1 = a1 / 1e5 * Math.min(w, h);
6934
+ const r2 = a2 / 1e5 * Math.min(w, h);
6931
6935
  return `<path d="M ${r1} 0 L ${w - r1} 0 A ${r1} ${r1} 0 0 1 ${w} ${r1} L ${w} ${h - r2} A ${r2} ${r2} 0 0 1 ${w - r2} ${h} L ${r2} ${h} A ${r2} ${r2} 0 0 1 0 ${h - r2} L 0 ${r1} A ${r1} ${r1} 0 0 1 ${r1} 0 Z"/>`;
6932
6936
  },
6933
6937
  round2DiagRect: (w, h, adj) => {
6934
- const r1 = (adj["adj1"] ?? 16667) / 1e5 * Math.min(w, h);
6935
- const r2 = (adj["adj2"] ?? 0) / 1e5 * Math.min(w, h);
6938
+ const a1 = Math.min(5e4, Math.max(0, adj["adj1"] ?? 16667));
6939
+ const a2 = Math.min(5e4, Math.max(0, adj["adj2"] ?? 0));
6940
+ const r1 = a1 / 1e5 * Math.min(w, h);
6941
+ const r2 = a2 / 1e5 * Math.min(w, h);
6936
6942
  return `<path d="M ${r1} 0 L ${w} 0 L ${w} ${h - r2} A ${r2} ${r2} 0 0 1 ${w - r2} ${h} L 0 ${h} L 0 ${r1} A ${r1} ${r1} 0 0 1 ${r1} 0 Z"/>`;
6937
6943
  },
6938
6944
  // Brackets and braces
package/dist/index.js CHANGED
@@ -1495,8 +1495,8 @@ var standardParser = new XMLParser({
1495
1495
  attributeNamePrefix: "@_",
1496
1496
  removeNSPrefix: true,
1497
1497
  htmlEntities: true,
1498
- isArray: (_name, jpath) => {
1499
- const tag = jpath.split(".").pop() ?? "";
1498
+ isArray: (_name, jpath, _isLeafNode, _isAttribute) => {
1499
+ const tag = String(jpath).split(".").pop() ?? "";
1500
1500
  return ARRAY_TAGS.has(tag);
1501
1501
  }
1502
1502
  });
@@ -6231,7 +6231,8 @@ var presetGeometries = {
6231
6231
  rect: (w, h) => `<rect width="${w}" height="${h}"/>`,
6232
6232
  ellipse: (w, h) => `<ellipse cx="${w / 2}" cy="${h / 2}" rx="${w / 2}" ry="${h / 2}"/>`,
6233
6233
  roundRect: (w, h, adj) => {
6234
- const r = (adj["adj"] ?? 16667) / 1e5 * Math.min(w, h);
6234
+ const a = Math.min(5e4, Math.max(0, adj["adj"] ?? 16667));
6235
+ const r = a / 1e5 * Math.min(w, h);
6235
6236
  return `<rect width="${w}" height="${h}" rx="${r}" ry="${r}"/>`;
6236
6237
  },
6237
6238
  triangle: (w, h, adj) => {
@@ -6877,17 +6878,22 @@ var presetGeometries = {
6877
6878
  return `<path d="M ${r} 0 L ${w - d} 0 L ${w} ${d} L ${w} ${h} L 0 ${h} L 0 ${r} A ${r} ${r} 0 0 1 ${r} 0 Z"/>`;
6878
6879
  },
6879
6880
  round1Rect: (w, h, adj) => {
6880
- const r = (adj["adj"] ?? 16667) / 1e5 * Math.min(w, h);
6881
+ const a = Math.min(5e4, Math.max(0, adj["adj"] ?? 16667));
6882
+ const r = a / 1e5 * Math.min(w, h);
6881
6883
  return `<path d="M 0 0 L ${w - r} 0 A ${r} ${r} 0 0 1 ${w} ${r} L ${w} ${h} L 0 ${h} Z"/>`;
6882
6884
  },
6883
6885
  round2SameRect: (w, h, adj) => {
6884
- const r1 = (adj["adj1"] ?? 16667) / 1e5 * Math.min(w, h);
6885
- const r2 = (adj["adj2"] ?? 0) / 1e5 * Math.min(w, h);
6886
+ const a1 = Math.min(5e4, Math.max(0, adj["adj1"] ?? 16667));
6887
+ const a2 = Math.min(5e4, Math.max(0, adj["adj2"] ?? 0));
6888
+ const r1 = a1 / 1e5 * Math.min(w, h);
6889
+ const r2 = a2 / 1e5 * Math.min(w, h);
6886
6890
  return `<path d="M ${r1} 0 L ${w - r1} 0 A ${r1} ${r1} 0 0 1 ${w} ${r1} L ${w} ${h - r2} A ${r2} ${r2} 0 0 1 ${w - r2} ${h} L ${r2} ${h} A ${r2} ${r2} 0 0 1 0 ${h - r2} L 0 ${r1} A ${r1} ${r1} 0 0 1 ${r1} 0 Z"/>`;
6887
6891
  },
6888
6892
  round2DiagRect: (w, h, adj) => {
6889
- const r1 = (adj["adj1"] ?? 16667) / 1e5 * Math.min(w, h);
6890
- const r2 = (adj["adj2"] ?? 0) / 1e5 * Math.min(w, h);
6893
+ const a1 = Math.min(5e4, Math.max(0, adj["adj1"] ?? 16667));
6894
+ const a2 = Math.min(5e4, Math.max(0, adj["adj2"] ?? 0));
6895
+ const r1 = a1 / 1e5 * Math.min(w, h);
6896
+ const r2 = a2 / 1e5 * Math.min(w, h);
6891
6897
  return `<path d="M ${r1} 0 L ${w} 0 L ${w} ${h - r2} A ${r2} ${r2} 0 0 1 ${w - r2} ${h} L 0 ${h} L 0 ${r1} A ${r1} ${r1} 0 0 1 ${r1} 0 Z"/>`;
6892
6898
  },
6893
6899
  // Brackets and braces
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pptx-glimpse",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "A lightweight JavaScript library for rendering PowerPoint (.pptx) files as SVG or PNG in Node.js. No LibreOffice required.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",