pptx-glimpse 0.2.1 → 0.2.2
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 +179 -89
- package/dist/index.js +179 -89
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3813,6 +3813,65 @@ function renderPlaceholder(mimeType, w, h, transformAttr) {
|
|
|
3813
3813
|
].join("");
|
|
3814
3814
|
}
|
|
3815
3815
|
|
|
3816
|
+
// src/warning-logger.ts
|
|
3817
|
+
var PREFIX = "[pptx-glimpse]";
|
|
3818
|
+
var currentLevel = "off";
|
|
3819
|
+
var entries = [];
|
|
3820
|
+
var featureCounts = /* @__PURE__ */ new Map();
|
|
3821
|
+
function initWarningLogger(level) {
|
|
3822
|
+
currentLevel = level;
|
|
3823
|
+
entries = [];
|
|
3824
|
+
featureCounts.clear();
|
|
3825
|
+
}
|
|
3826
|
+
function warn(feature, message, context) {
|
|
3827
|
+
if (currentLevel === "off") return;
|
|
3828
|
+
entries.push({ feature, message, ...context !== void 0 && { context } });
|
|
3829
|
+
const existing = featureCounts.get(feature);
|
|
3830
|
+
if (existing) {
|
|
3831
|
+
existing.count++;
|
|
3832
|
+
} else {
|
|
3833
|
+
featureCounts.set(feature, { message, count: 1 });
|
|
3834
|
+
}
|
|
3835
|
+
if (currentLevel === "debug") {
|
|
3836
|
+
const ctx = context ? ` (${context})` : "";
|
|
3837
|
+
console.warn(`${PREFIX} SKIP: ${feature} - ${message}${ctx}`);
|
|
3838
|
+
}
|
|
3839
|
+
}
|
|
3840
|
+
function debug(feature, message, context) {
|
|
3841
|
+
if (currentLevel !== "debug") return;
|
|
3842
|
+
entries.push({ feature, message, ...context !== void 0 && { context } });
|
|
3843
|
+
const existing = featureCounts.get(feature);
|
|
3844
|
+
if (existing) {
|
|
3845
|
+
existing.count++;
|
|
3846
|
+
} else {
|
|
3847
|
+
featureCounts.set(feature, { message, count: 1 });
|
|
3848
|
+
}
|
|
3849
|
+
const ctx = context ? ` (${context})` : "";
|
|
3850
|
+
console.warn(`${PREFIX} DEBUG: ${feature} - ${message}${ctx}`);
|
|
3851
|
+
}
|
|
3852
|
+
function getWarningSummary() {
|
|
3853
|
+
const features = [];
|
|
3854
|
+
for (const [feature, { message, count }] of featureCounts) {
|
|
3855
|
+
features.push({ feature, message, count });
|
|
3856
|
+
}
|
|
3857
|
+
return { totalCount: entries.length, features };
|
|
3858
|
+
}
|
|
3859
|
+
function flushWarnings() {
|
|
3860
|
+
const summary = getWarningSummary();
|
|
3861
|
+
if (currentLevel !== "off" && summary.features.length > 0) {
|
|
3862
|
+
console.warn(`${PREFIX} Summary: ${summary.features.length} unsupported feature(s) detected`);
|
|
3863
|
+
for (const { feature, count } of summary.features) {
|
|
3864
|
+
console.warn(` - ${feature}: ${count} occurrence(s)`);
|
|
3865
|
+
}
|
|
3866
|
+
}
|
|
3867
|
+
entries = [];
|
|
3868
|
+
featureCounts.clear();
|
|
3869
|
+
return summary;
|
|
3870
|
+
}
|
|
3871
|
+
function getWarningEntries() {
|
|
3872
|
+
return entries;
|
|
3873
|
+
}
|
|
3874
|
+
|
|
3816
3875
|
// src/renderer/chart-renderer.ts
|
|
3817
3876
|
var DEFAULT_SERIES_COLORS = [
|
|
3818
3877
|
{ hex: "#4472C4", alpha: 1 },
|
|
@@ -3894,11 +3953,20 @@ function renderChartTitle(title, chartWidth) {
|
|
|
3894
3953
|
function renderBarChart(chart, x, y, w, h) {
|
|
3895
3954
|
const parts = [];
|
|
3896
3955
|
const { series, categories } = chart;
|
|
3897
|
-
if (series.length === 0)
|
|
3956
|
+
if (series.length === 0) {
|
|
3957
|
+
debug("chart.bar", "series is empty");
|
|
3958
|
+
return "";
|
|
3959
|
+
}
|
|
3898
3960
|
const maxVal = getMaxValue(series);
|
|
3899
|
-
if (maxVal === 0)
|
|
3961
|
+
if (maxVal === 0) {
|
|
3962
|
+
debug("chart.bar", "max value is 0");
|
|
3963
|
+
return "";
|
|
3964
|
+
}
|
|
3900
3965
|
const catCount = categories.length || Math.max(...series.map((s) => s.values.length));
|
|
3901
|
-
if (catCount === 0)
|
|
3966
|
+
if (catCount === 0) {
|
|
3967
|
+
debug("chart.bar", "category count is 0");
|
|
3968
|
+
return "";
|
|
3969
|
+
}
|
|
3902
3970
|
const isHorizontal = chart.barDirection === "bar";
|
|
3903
3971
|
parts.push(
|
|
3904
3972
|
`<line x1="${round3(x)}" y1="${round3(y + h)}" x2="${round3(x + w)}" y2="${round3(y + h)}" stroke="#D9D9D9" stroke-width="1"/>`
|
|
@@ -3958,11 +4026,20 @@ function renderBarChart(chart, x, y, w, h) {
|
|
|
3958
4026
|
function renderLineChart(chart, x, y, w, h) {
|
|
3959
4027
|
const parts = [];
|
|
3960
4028
|
const { series, categories } = chart;
|
|
3961
|
-
if (series.length === 0)
|
|
4029
|
+
if (series.length === 0) {
|
|
4030
|
+
debug("chart.line", "series is empty");
|
|
4031
|
+
return "";
|
|
4032
|
+
}
|
|
3962
4033
|
const maxVal = getMaxValue(series);
|
|
3963
|
-
if (maxVal === 0)
|
|
4034
|
+
if (maxVal === 0) {
|
|
4035
|
+
debug("chart.line", "max value is 0");
|
|
4036
|
+
return "";
|
|
4037
|
+
}
|
|
3964
4038
|
const catCount = categories.length || Math.max(...series.map((s) => s.values.length));
|
|
3965
|
-
if (catCount === 0)
|
|
4039
|
+
if (catCount === 0) {
|
|
4040
|
+
debug("chart.line", "category count is 0");
|
|
4041
|
+
return "";
|
|
4042
|
+
}
|
|
3966
4043
|
parts.push(
|
|
3967
4044
|
`<line x1="${round3(x)}" y1="${round3(y + h)}" x2="${round3(x + w)}" y2="${round3(y + h)}" stroke="#D9D9D9" stroke-width="1"/>`
|
|
3968
4045
|
);
|
|
@@ -3998,11 +4075,20 @@ function renderLineChart(chart, x, y, w, h) {
|
|
|
3998
4075
|
function renderAreaChart(chart, x, y, w, h) {
|
|
3999
4076
|
const parts = [];
|
|
4000
4077
|
const { series, categories } = chart;
|
|
4001
|
-
if (series.length === 0)
|
|
4078
|
+
if (series.length === 0) {
|
|
4079
|
+
debug("chart.area", "series is empty");
|
|
4080
|
+
return "";
|
|
4081
|
+
}
|
|
4002
4082
|
const maxVal = getMaxValue(series);
|
|
4003
|
-
if (maxVal === 0)
|
|
4083
|
+
if (maxVal === 0) {
|
|
4084
|
+
debug("chart.area", "max value is 0");
|
|
4085
|
+
return "";
|
|
4086
|
+
}
|
|
4004
4087
|
const catCount = categories.length || Math.max(...series.map((s) => s.values.length));
|
|
4005
|
-
if (catCount === 0)
|
|
4088
|
+
if (catCount === 0) {
|
|
4089
|
+
debug("chart.area", "category count is 0");
|
|
4090
|
+
return "";
|
|
4091
|
+
}
|
|
4006
4092
|
parts.push(
|
|
4007
4093
|
`<line x1="${round3(x)}" y1="${round3(y + h)}" x2="${round3(x + w)}" y2="${round3(y + h)}" stroke="#D9D9D9" stroke-width="1"/>`
|
|
4008
4094
|
);
|
|
@@ -4039,9 +4125,15 @@ function renderAreaChart(chart, x, y, w, h) {
|
|
|
4039
4125
|
function renderPieChart(chart, x, y, w, h) {
|
|
4040
4126
|
const parts = [];
|
|
4041
4127
|
const series = chart.series[0];
|
|
4042
|
-
if (!series || series.values.length === 0)
|
|
4128
|
+
if (!series || series.values.length === 0) {
|
|
4129
|
+
debug("chart.pie", "series is empty or has no values");
|
|
4130
|
+
return "";
|
|
4131
|
+
}
|
|
4043
4132
|
const total = series.values.reduce((sum, v) => sum + v, 0);
|
|
4044
|
-
if (total === 0)
|
|
4133
|
+
if (total === 0) {
|
|
4134
|
+
debug("chart.pie", "total value is 0");
|
|
4135
|
+
return "";
|
|
4136
|
+
}
|
|
4045
4137
|
const cx = x + w / 2;
|
|
4046
4138
|
const cy = y + h / 2;
|
|
4047
4139
|
const r = Math.min(w, h) / 2 * 0.85;
|
|
@@ -4071,9 +4163,15 @@ function renderPieChart(chart, x, y, w, h) {
|
|
|
4071
4163
|
function renderDoughnutChart(chart, x, y, w, h) {
|
|
4072
4164
|
const parts = [];
|
|
4073
4165
|
const series = chart.series[0];
|
|
4074
|
-
if (!series || series.values.length === 0)
|
|
4166
|
+
if (!series || series.values.length === 0) {
|
|
4167
|
+
debug("chart.doughnut", "series is empty or has no values");
|
|
4168
|
+
return "";
|
|
4169
|
+
}
|
|
4075
4170
|
const total = series.values.reduce((sum, v) => sum + v, 0);
|
|
4076
|
-
if (total === 0)
|
|
4171
|
+
if (total === 0) {
|
|
4172
|
+
debug("chart.doughnut", "total value is 0");
|
|
4173
|
+
return "";
|
|
4174
|
+
}
|
|
4077
4175
|
const cx = x + w / 2;
|
|
4078
4176
|
const cy = y + h / 2;
|
|
4079
4177
|
const outerR = Math.min(w, h) / 2 * 0.85;
|
|
@@ -4112,7 +4210,10 @@ function renderDoughnutChart(chart, x, y, w, h) {
|
|
|
4112
4210
|
function renderScatterChart(chart, x, y, w, h) {
|
|
4113
4211
|
const parts = [];
|
|
4114
4212
|
const { series } = chart;
|
|
4115
|
-
if (series.length === 0)
|
|
4213
|
+
if (series.length === 0) {
|
|
4214
|
+
debug("chart.scatter", "series is empty");
|
|
4215
|
+
return "";
|
|
4216
|
+
}
|
|
4116
4217
|
let maxX = 0;
|
|
4117
4218
|
let maxY = 0;
|
|
4118
4219
|
for (const s of series) {
|
|
@@ -4144,7 +4245,10 @@ function renderScatterChart(chart, x, y, w, h) {
|
|
|
4144
4245
|
function renderBubbleChart(chart, x, y, w, h) {
|
|
4145
4246
|
const parts = [];
|
|
4146
4247
|
const { series } = chart;
|
|
4147
|
-
if (series.length === 0)
|
|
4248
|
+
if (series.length === 0) {
|
|
4249
|
+
debug("chart.bubble", "series is empty");
|
|
4250
|
+
return "";
|
|
4251
|
+
}
|
|
4148
4252
|
let maxX = 0;
|
|
4149
4253
|
let maxY = 0;
|
|
4150
4254
|
let maxBubble = 0;
|
|
@@ -4186,11 +4290,20 @@ function renderBubbleChart(chart, x, y, w, h) {
|
|
|
4186
4290
|
function renderRadarChart(chart, x, y, w, h) {
|
|
4187
4291
|
const parts = [];
|
|
4188
4292
|
const { series, categories } = chart;
|
|
4189
|
-
if (series.length === 0)
|
|
4293
|
+
if (series.length === 0) {
|
|
4294
|
+
debug("chart.radar", "series is empty");
|
|
4295
|
+
return "";
|
|
4296
|
+
}
|
|
4190
4297
|
const maxVal = getMaxValue(series);
|
|
4191
|
-
if (maxVal === 0)
|
|
4298
|
+
if (maxVal === 0) {
|
|
4299
|
+
debug("chart.radar", "max value is 0");
|
|
4300
|
+
return "";
|
|
4301
|
+
}
|
|
4192
4302
|
const catCount = categories.length || Math.max(...series.map((s) => s.values.length));
|
|
4193
|
-
if (catCount === 0)
|
|
4303
|
+
if (catCount === 0) {
|
|
4304
|
+
debug("chart.radar", "category count is 0");
|
|
4305
|
+
return "";
|
|
4306
|
+
}
|
|
4194
4307
|
const cx = x + w / 2;
|
|
4195
4308
|
const cy = y + h / 2;
|
|
4196
4309
|
const radius = Math.min(w, h) / 2 * 0.85;
|
|
@@ -4254,12 +4367,18 @@ function renderRadarChart(chart, x, y, w, h) {
|
|
|
4254
4367
|
function renderStockChart(chart, x, y, w, h) {
|
|
4255
4368
|
const parts = [];
|
|
4256
4369
|
const { series, categories } = chart;
|
|
4257
|
-
if (series.length < 3)
|
|
4370
|
+
if (series.length < 3) {
|
|
4371
|
+
debug("chart.stock", `insufficient series count: ${series.length} (need at least 3)`);
|
|
4372
|
+
return "";
|
|
4373
|
+
}
|
|
4258
4374
|
const highSeries = series[0];
|
|
4259
4375
|
const lowSeries = series[1];
|
|
4260
4376
|
const closeSeries = series[2];
|
|
4261
4377
|
const catCount = categories.length || highSeries.values.length;
|
|
4262
|
-
if (catCount === 0)
|
|
4378
|
+
if (catCount === 0) {
|
|
4379
|
+
debug("chart.stock", "category count is 0");
|
|
4380
|
+
return "";
|
|
4381
|
+
}
|
|
4263
4382
|
let maxVal = 0;
|
|
4264
4383
|
let minVal = Infinity;
|
|
4265
4384
|
for (const s of [highSeries, lowSeries, closeSeries]) {
|
|
@@ -4268,7 +4387,10 @@ function renderStockChart(chart, x, y, w, h) {
|
|
|
4268
4387
|
minVal = Math.min(minVal, v);
|
|
4269
4388
|
}
|
|
4270
4389
|
}
|
|
4271
|
-
if (maxVal === minVal)
|
|
4390
|
+
if (maxVal === minVal) {
|
|
4391
|
+
debug("chart.stock", "max equals min value");
|
|
4392
|
+
return "";
|
|
4393
|
+
}
|
|
4272
4394
|
parts.push(
|
|
4273
4395
|
`<line x1="${round3(x)}" y1="${round3(y + h)}" x2="${round3(x + w)}" y2="${round3(y + h)}" stroke="#D9D9D9" stroke-width="1"/>`
|
|
4274
4396
|
);
|
|
@@ -4304,10 +4426,16 @@ function renderStockChart(chart, x, y, w, h) {
|
|
|
4304
4426
|
function renderSurfaceChart(chart, x, y, w, h) {
|
|
4305
4427
|
const parts = [];
|
|
4306
4428
|
const { series, categories } = chart;
|
|
4307
|
-
if (series.length === 0)
|
|
4429
|
+
if (series.length === 0) {
|
|
4430
|
+
debug("chart.surface", "series is empty");
|
|
4431
|
+
return "";
|
|
4432
|
+
}
|
|
4308
4433
|
const rows = series.length;
|
|
4309
4434
|
const cols = categories.length || Math.max(...series.map((s) => s.values.length));
|
|
4310
|
-
if (cols === 0)
|
|
4435
|
+
if (cols === 0) {
|
|
4436
|
+
debug("chart.surface", "column count is 0");
|
|
4437
|
+
return "";
|
|
4438
|
+
}
|
|
4311
4439
|
let minVal = Infinity;
|
|
4312
4440
|
let maxVal = -Infinity;
|
|
4313
4441
|
for (const s of series) {
|
|
@@ -4380,9 +4508,15 @@ function heatmapColor(t) {
|
|
|
4380
4508
|
function renderOfPieChart(chart, x, y, w, h) {
|
|
4381
4509
|
const parts = [];
|
|
4382
4510
|
const series = chart.series[0];
|
|
4383
|
-
if (!series || series.values.length === 0)
|
|
4511
|
+
if (!series || series.values.length === 0) {
|
|
4512
|
+
debug("chart.ofPie", "series is empty or has no values");
|
|
4513
|
+
return "";
|
|
4514
|
+
}
|
|
4384
4515
|
const total = series.values.reduce((sum, v) => sum + v, 0);
|
|
4385
|
-
if (total === 0)
|
|
4516
|
+
if (total === 0) {
|
|
4517
|
+
debug("chart.ofPie", "total value is 0");
|
|
4518
|
+
return "";
|
|
4519
|
+
}
|
|
4386
4520
|
const splitPos = chart.splitPos ?? 2;
|
|
4387
4521
|
const secondPieSize = chart.secondPieSize ?? 75;
|
|
4388
4522
|
const isBarOfPie = chart.ofPieType === "bar";
|
|
@@ -4747,65 +4881,6 @@ async function svgToPng(svgString, options) {
|
|
|
4747
4881
|
return { png: result.data, width: result.info.width, height: result.info.height };
|
|
4748
4882
|
}
|
|
4749
4883
|
|
|
4750
|
-
// src/warning-logger.ts
|
|
4751
|
-
var PREFIX = "[pptx-glimpse]";
|
|
4752
|
-
var currentLevel = "off";
|
|
4753
|
-
var entries = [];
|
|
4754
|
-
var featureCounts = /* @__PURE__ */ new Map();
|
|
4755
|
-
function initWarningLogger(level) {
|
|
4756
|
-
currentLevel = level;
|
|
4757
|
-
entries = [];
|
|
4758
|
-
featureCounts.clear();
|
|
4759
|
-
}
|
|
4760
|
-
function warn(feature, message, context) {
|
|
4761
|
-
if (currentLevel === "off") return;
|
|
4762
|
-
entries.push({ feature, message, ...context !== void 0 && { context } });
|
|
4763
|
-
const existing = featureCounts.get(feature);
|
|
4764
|
-
if (existing) {
|
|
4765
|
-
existing.count++;
|
|
4766
|
-
} else {
|
|
4767
|
-
featureCounts.set(feature, { message, count: 1 });
|
|
4768
|
-
}
|
|
4769
|
-
if (currentLevel === "debug") {
|
|
4770
|
-
const ctx = context ? ` (${context})` : "";
|
|
4771
|
-
console.warn(`${PREFIX} SKIP: ${feature} - ${message}${ctx}`);
|
|
4772
|
-
}
|
|
4773
|
-
}
|
|
4774
|
-
function debug(feature, message, context) {
|
|
4775
|
-
if (currentLevel !== "debug") return;
|
|
4776
|
-
entries.push({ feature, message, ...context !== void 0 && { context } });
|
|
4777
|
-
const existing = featureCounts.get(feature);
|
|
4778
|
-
if (existing) {
|
|
4779
|
-
existing.count++;
|
|
4780
|
-
} else {
|
|
4781
|
-
featureCounts.set(feature, { message, count: 1 });
|
|
4782
|
-
}
|
|
4783
|
-
const ctx = context ? ` (${context})` : "";
|
|
4784
|
-
console.warn(`${PREFIX} DEBUG: ${feature} - ${message}${ctx}`);
|
|
4785
|
-
}
|
|
4786
|
-
function getWarningSummary() {
|
|
4787
|
-
const features = [];
|
|
4788
|
-
for (const [feature, { message, count }] of featureCounts) {
|
|
4789
|
-
features.push({ feature, message, count });
|
|
4790
|
-
}
|
|
4791
|
-
return { totalCount: entries.length, features };
|
|
4792
|
-
}
|
|
4793
|
-
function flushWarnings() {
|
|
4794
|
-
const summary = getWarningSummary();
|
|
4795
|
-
if (currentLevel !== "off" && summary.features.length > 0) {
|
|
4796
|
-
console.warn(`${PREFIX} Summary: ${summary.features.length} unsupported feature(s) detected`);
|
|
4797
|
-
for (const { feature, count } of summary.features) {
|
|
4798
|
-
console.warn(` - ${feature}: ${count} occurrence(s)`);
|
|
4799
|
-
}
|
|
4800
|
-
}
|
|
4801
|
-
entries = [];
|
|
4802
|
-
featureCounts.clear();
|
|
4803
|
-
return summary;
|
|
4804
|
-
}
|
|
4805
|
-
function getWarningEntries() {
|
|
4806
|
-
return entries;
|
|
4807
|
-
}
|
|
4808
|
-
|
|
4809
4884
|
// src/parser/pptx-reader.ts
|
|
4810
4885
|
var import_fflate = require("fflate");
|
|
4811
4886
|
function readPptx(input) {
|
|
@@ -6183,10 +6258,16 @@ function parseCustomGeometry(custGeom) {
|
|
|
6183
6258
|
for (const path of paths) {
|
|
6184
6259
|
const w = Number(path["@_w"] ?? 0);
|
|
6185
6260
|
const h = Number(path["@_h"] ?? 0);
|
|
6186
|
-
if (w === 0 && h === 0)
|
|
6261
|
+
if (w === 0 && h === 0) {
|
|
6262
|
+
debug("custGeom.path", "path skipped: width and height are both 0");
|
|
6263
|
+
continue;
|
|
6264
|
+
}
|
|
6187
6265
|
const vars = evaluateGuides(avGd, gdGd, w, h);
|
|
6188
6266
|
const commands = buildPathCommands(path, vars);
|
|
6189
|
-
if (!commands)
|
|
6267
|
+
if (!commands) {
|
|
6268
|
+
debug("custGeom.path", "path skipped: failed to build path commands");
|
|
6269
|
+
continue;
|
|
6270
|
+
}
|
|
6190
6271
|
result.push({ width: w, height: h, commands });
|
|
6191
6272
|
}
|
|
6192
6273
|
return result.length > 0 ? result : null;
|
|
@@ -6759,7 +6840,10 @@ function parseImage(pic, rels, slidePath, archive, colorResolver) {
|
|
|
6759
6840
|
if (!rel) return null;
|
|
6760
6841
|
const mediaPath = resolveRelationshipTarget(slidePath, rel.target);
|
|
6761
6842
|
const mediaData = archive.media.get(mediaPath);
|
|
6762
|
-
if (!mediaData)
|
|
6843
|
+
if (!mediaData) {
|
|
6844
|
+
debug("picture.media", `media file not found: ${mediaPath}`);
|
|
6845
|
+
return null;
|
|
6846
|
+
}
|
|
6763
6847
|
const ext = mediaPath.split(".").pop()?.toLowerCase() ?? "png";
|
|
6764
6848
|
const mimeMap = {
|
|
6765
6849
|
png: "image/png",
|
|
@@ -6958,9 +7042,15 @@ function parseSmartArt(graphicData, transform, rels, slidePath, archive, colorRe
|
|
|
6958
7042
|
}
|
|
6959
7043
|
}
|
|
6960
7044
|
}
|
|
6961
|
-
if (!drawingPath)
|
|
7045
|
+
if (!drawingPath) {
|
|
7046
|
+
debug("smartArt.drawing", "diagramDrawing relationship not found");
|
|
7047
|
+
return null;
|
|
7048
|
+
}
|
|
6962
7049
|
const drawingXml = archive.files.get(drawingPath);
|
|
6963
|
-
if (!drawingXml)
|
|
7050
|
+
if (!drawingXml) {
|
|
7051
|
+
debug("smartArt.drawing", `drawing XML not found in archive: ${drawingPath}`);
|
|
7052
|
+
return null;
|
|
7053
|
+
}
|
|
6964
7054
|
const parsed = parseXml(drawingXml);
|
|
6965
7055
|
const drawing = parsed.drawing;
|
|
6966
7056
|
const spTree = drawing?.spTree;
|
package/dist/index.js
CHANGED
|
@@ -3770,6 +3770,65 @@ function renderPlaceholder(mimeType, w, h, transformAttr) {
|
|
|
3770
3770
|
].join("");
|
|
3771
3771
|
}
|
|
3772
3772
|
|
|
3773
|
+
// src/warning-logger.ts
|
|
3774
|
+
var PREFIX = "[pptx-glimpse]";
|
|
3775
|
+
var currentLevel = "off";
|
|
3776
|
+
var entries = [];
|
|
3777
|
+
var featureCounts = /* @__PURE__ */ new Map();
|
|
3778
|
+
function initWarningLogger(level) {
|
|
3779
|
+
currentLevel = level;
|
|
3780
|
+
entries = [];
|
|
3781
|
+
featureCounts.clear();
|
|
3782
|
+
}
|
|
3783
|
+
function warn(feature, message, context) {
|
|
3784
|
+
if (currentLevel === "off") return;
|
|
3785
|
+
entries.push({ feature, message, ...context !== void 0 && { context } });
|
|
3786
|
+
const existing = featureCounts.get(feature);
|
|
3787
|
+
if (existing) {
|
|
3788
|
+
existing.count++;
|
|
3789
|
+
} else {
|
|
3790
|
+
featureCounts.set(feature, { message, count: 1 });
|
|
3791
|
+
}
|
|
3792
|
+
if (currentLevel === "debug") {
|
|
3793
|
+
const ctx = context ? ` (${context})` : "";
|
|
3794
|
+
console.warn(`${PREFIX} SKIP: ${feature} - ${message}${ctx}`);
|
|
3795
|
+
}
|
|
3796
|
+
}
|
|
3797
|
+
function debug(feature, message, context) {
|
|
3798
|
+
if (currentLevel !== "debug") return;
|
|
3799
|
+
entries.push({ feature, message, ...context !== void 0 && { context } });
|
|
3800
|
+
const existing = featureCounts.get(feature);
|
|
3801
|
+
if (existing) {
|
|
3802
|
+
existing.count++;
|
|
3803
|
+
} else {
|
|
3804
|
+
featureCounts.set(feature, { message, count: 1 });
|
|
3805
|
+
}
|
|
3806
|
+
const ctx = context ? ` (${context})` : "";
|
|
3807
|
+
console.warn(`${PREFIX} DEBUG: ${feature} - ${message}${ctx}`);
|
|
3808
|
+
}
|
|
3809
|
+
function getWarningSummary() {
|
|
3810
|
+
const features = [];
|
|
3811
|
+
for (const [feature, { message, count }] of featureCounts) {
|
|
3812
|
+
features.push({ feature, message, count });
|
|
3813
|
+
}
|
|
3814
|
+
return { totalCount: entries.length, features };
|
|
3815
|
+
}
|
|
3816
|
+
function flushWarnings() {
|
|
3817
|
+
const summary = getWarningSummary();
|
|
3818
|
+
if (currentLevel !== "off" && summary.features.length > 0) {
|
|
3819
|
+
console.warn(`${PREFIX} Summary: ${summary.features.length} unsupported feature(s) detected`);
|
|
3820
|
+
for (const { feature, count } of summary.features) {
|
|
3821
|
+
console.warn(` - ${feature}: ${count} occurrence(s)`);
|
|
3822
|
+
}
|
|
3823
|
+
}
|
|
3824
|
+
entries = [];
|
|
3825
|
+
featureCounts.clear();
|
|
3826
|
+
return summary;
|
|
3827
|
+
}
|
|
3828
|
+
function getWarningEntries() {
|
|
3829
|
+
return entries;
|
|
3830
|
+
}
|
|
3831
|
+
|
|
3773
3832
|
// src/renderer/chart-renderer.ts
|
|
3774
3833
|
var DEFAULT_SERIES_COLORS = [
|
|
3775
3834
|
{ hex: "#4472C4", alpha: 1 },
|
|
@@ -3851,11 +3910,20 @@ function renderChartTitle(title, chartWidth) {
|
|
|
3851
3910
|
function renderBarChart(chart, x, y, w, h) {
|
|
3852
3911
|
const parts = [];
|
|
3853
3912
|
const { series, categories } = chart;
|
|
3854
|
-
if (series.length === 0)
|
|
3913
|
+
if (series.length === 0) {
|
|
3914
|
+
debug("chart.bar", "series is empty");
|
|
3915
|
+
return "";
|
|
3916
|
+
}
|
|
3855
3917
|
const maxVal = getMaxValue(series);
|
|
3856
|
-
if (maxVal === 0)
|
|
3918
|
+
if (maxVal === 0) {
|
|
3919
|
+
debug("chart.bar", "max value is 0");
|
|
3920
|
+
return "";
|
|
3921
|
+
}
|
|
3857
3922
|
const catCount = categories.length || Math.max(...series.map((s) => s.values.length));
|
|
3858
|
-
if (catCount === 0)
|
|
3923
|
+
if (catCount === 0) {
|
|
3924
|
+
debug("chart.bar", "category count is 0");
|
|
3925
|
+
return "";
|
|
3926
|
+
}
|
|
3859
3927
|
const isHorizontal = chart.barDirection === "bar";
|
|
3860
3928
|
parts.push(
|
|
3861
3929
|
`<line x1="${round3(x)}" y1="${round3(y + h)}" x2="${round3(x + w)}" y2="${round3(y + h)}" stroke="#D9D9D9" stroke-width="1"/>`
|
|
@@ -3915,11 +3983,20 @@ function renderBarChart(chart, x, y, w, h) {
|
|
|
3915
3983
|
function renderLineChart(chart, x, y, w, h) {
|
|
3916
3984
|
const parts = [];
|
|
3917
3985
|
const { series, categories } = chart;
|
|
3918
|
-
if (series.length === 0)
|
|
3986
|
+
if (series.length === 0) {
|
|
3987
|
+
debug("chart.line", "series is empty");
|
|
3988
|
+
return "";
|
|
3989
|
+
}
|
|
3919
3990
|
const maxVal = getMaxValue(series);
|
|
3920
|
-
if (maxVal === 0)
|
|
3991
|
+
if (maxVal === 0) {
|
|
3992
|
+
debug("chart.line", "max value is 0");
|
|
3993
|
+
return "";
|
|
3994
|
+
}
|
|
3921
3995
|
const catCount = categories.length || Math.max(...series.map((s) => s.values.length));
|
|
3922
|
-
if (catCount === 0)
|
|
3996
|
+
if (catCount === 0) {
|
|
3997
|
+
debug("chart.line", "category count is 0");
|
|
3998
|
+
return "";
|
|
3999
|
+
}
|
|
3923
4000
|
parts.push(
|
|
3924
4001
|
`<line x1="${round3(x)}" y1="${round3(y + h)}" x2="${round3(x + w)}" y2="${round3(y + h)}" stroke="#D9D9D9" stroke-width="1"/>`
|
|
3925
4002
|
);
|
|
@@ -3955,11 +4032,20 @@ function renderLineChart(chart, x, y, w, h) {
|
|
|
3955
4032
|
function renderAreaChart(chart, x, y, w, h) {
|
|
3956
4033
|
const parts = [];
|
|
3957
4034
|
const { series, categories } = chart;
|
|
3958
|
-
if (series.length === 0)
|
|
4035
|
+
if (series.length === 0) {
|
|
4036
|
+
debug("chart.area", "series is empty");
|
|
4037
|
+
return "";
|
|
4038
|
+
}
|
|
3959
4039
|
const maxVal = getMaxValue(series);
|
|
3960
|
-
if (maxVal === 0)
|
|
4040
|
+
if (maxVal === 0) {
|
|
4041
|
+
debug("chart.area", "max value is 0");
|
|
4042
|
+
return "";
|
|
4043
|
+
}
|
|
3961
4044
|
const catCount = categories.length || Math.max(...series.map((s) => s.values.length));
|
|
3962
|
-
if (catCount === 0)
|
|
4045
|
+
if (catCount === 0) {
|
|
4046
|
+
debug("chart.area", "category count is 0");
|
|
4047
|
+
return "";
|
|
4048
|
+
}
|
|
3963
4049
|
parts.push(
|
|
3964
4050
|
`<line x1="${round3(x)}" y1="${round3(y + h)}" x2="${round3(x + w)}" y2="${round3(y + h)}" stroke="#D9D9D9" stroke-width="1"/>`
|
|
3965
4051
|
);
|
|
@@ -3996,9 +4082,15 @@ function renderAreaChart(chart, x, y, w, h) {
|
|
|
3996
4082
|
function renderPieChart(chart, x, y, w, h) {
|
|
3997
4083
|
const parts = [];
|
|
3998
4084
|
const series = chart.series[0];
|
|
3999
|
-
if (!series || series.values.length === 0)
|
|
4085
|
+
if (!series || series.values.length === 0) {
|
|
4086
|
+
debug("chart.pie", "series is empty or has no values");
|
|
4087
|
+
return "";
|
|
4088
|
+
}
|
|
4000
4089
|
const total = series.values.reduce((sum, v) => sum + v, 0);
|
|
4001
|
-
if (total === 0)
|
|
4090
|
+
if (total === 0) {
|
|
4091
|
+
debug("chart.pie", "total value is 0");
|
|
4092
|
+
return "";
|
|
4093
|
+
}
|
|
4002
4094
|
const cx = x + w / 2;
|
|
4003
4095
|
const cy = y + h / 2;
|
|
4004
4096
|
const r = Math.min(w, h) / 2 * 0.85;
|
|
@@ -4028,9 +4120,15 @@ function renderPieChart(chart, x, y, w, h) {
|
|
|
4028
4120
|
function renderDoughnutChart(chart, x, y, w, h) {
|
|
4029
4121
|
const parts = [];
|
|
4030
4122
|
const series = chart.series[0];
|
|
4031
|
-
if (!series || series.values.length === 0)
|
|
4123
|
+
if (!series || series.values.length === 0) {
|
|
4124
|
+
debug("chart.doughnut", "series is empty or has no values");
|
|
4125
|
+
return "";
|
|
4126
|
+
}
|
|
4032
4127
|
const total = series.values.reduce((sum, v) => sum + v, 0);
|
|
4033
|
-
if (total === 0)
|
|
4128
|
+
if (total === 0) {
|
|
4129
|
+
debug("chart.doughnut", "total value is 0");
|
|
4130
|
+
return "";
|
|
4131
|
+
}
|
|
4034
4132
|
const cx = x + w / 2;
|
|
4035
4133
|
const cy = y + h / 2;
|
|
4036
4134
|
const outerR = Math.min(w, h) / 2 * 0.85;
|
|
@@ -4069,7 +4167,10 @@ function renderDoughnutChart(chart, x, y, w, h) {
|
|
|
4069
4167
|
function renderScatterChart(chart, x, y, w, h) {
|
|
4070
4168
|
const parts = [];
|
|
4071
4169
|
const { series } = chart;
|
|
4072
|
-
if (series.length === 0)
|
|
4170
|
+
if (series.length === 0) {
|
|
4171
|
+
debug("chart.scatter", "series is empty");
|
|
4172
|
+
return "";
|
|
4173
|
+
}
|
|
4073
4174
|
let maxX = 0;
|
|
4074
4175
|
let maxY = 0;
|
|
4075
4176
|
for (const s of series) {
|
|
@@ -4101,7 +4202,10 @@ function renderScatterChart(chart, x, y, w, h) {
|
|
|
4101
4202
|
function renderBubbleChart(chart, x, y, w, h) {
|
|
4102
4203
|
const parts = [];
|
|
4103
4204
|
const { series } = chart;
|
|
4104
|
-
if (series.length === 0)
|
|
4205
|
+
if (series.length === 0) {
|
|
4206
|
+
debug("chart.bubble", "series is empty");
|
|
4207
|
+
return "";
|
|
4208
|
+
}
|
|
4105
4209
|
let maxX = 0;
|
|
4106
4210
|
let maxY = 0;
|
|
4107
4211
|
let maxBubble = 0;
|
|
@@ -4143,11 +4247,20 @@ function renderBubbleChart(chart, x, y, w, h) {
|
|
|
4143
4247
|
function renderRadarChart(chart, x, y, w, h) {
|
|
4144
4248
|
const parts = [];
|
|
4145
4249
|
const { series, categories } = chart;
|
|
4146
|
-
if (series.length === 0)
|
|
4250
|
+
if (series.length === 0) {
|
|
4251
|
+
debug("chart.radar", "series is empty");
|
|
4252
|
+
return "";
|
|
4253
|
+
}
|
|
4147
4254
|
const maxVal = getMaxValue(series);
|
|
4148
|
-
if (maxVal === 0)
|
|
4255
|
+
if (maxVal === 0) {
|
|
4256
|
+
debug("chart.radar", "max value is 0");
|
|
4257
|
+
return "";
|
|
4258
|
+
}
|
|
4149
4259
|
const catCount = categories.length || Math.max(...series.map((s) => s.values.length));
|
|
4150
|
-
if (catCount === 0)
|
|
4260
|
+
if (catCount === 0) {
|
|
4261
|
+
debug("chart.radar", "category count is 0");
|
|
4262
|
+
return "";
|
|
4263
|
+
}
|
|
4151
4264
|
const cx = x + w / 2;
|
|
4152
4265
|
const cy = y + h / 2;
|
|
4153
4266
|
const radius = Math.min(w, h) / 2 * 0.85;
|
|
@@ -4211,12 +4324,18 @@ function renderRadarChart(chart, x, y, w, h) {
|
|
|
4211
4324
|
function renderStockChart(chart, x, y, w, h) {
|
|
4212
4325
|
const parts = [];
|
|
4213
4326
|
const { series, categories } = chart;
|
|
4214
|
-
if (series.length < 3)
|
|
4327
|
+
if (series.length < 3) {
|
|
4328
|
+
debug("chart.stock", `insufficient series count: ${series.length} (need at least 3)`);
|
|
4329
|
+
return "";
|
|
4330
|
+
}
|
|
4215
4331
|
const highSeries = series[0];
|
|
4216
4332
|
const lowSeries = series[1];
|
|
4217
4333
|
const closeSeries = series[2];
|
|
4218
4334
|
const catCount = categories.length || highSeries.values.length;
|
|
4219
|
-
if (catCount === 0)
|
|
4335
|
+
if (catCount === 0) {
|
|
4336
|
+
debug("chart.stock", "category count is 0");
|
|
4337
|
+
return "";
|
|
4338
|
+
}
|
|
4220
4339
|
let maxVal = 0;
|
|
4221
4340
|
let minVal = Infinity;
|
|
4222
4341
|
for (const s of [highSeries, lowSeries, closeSeries]) {
|
|
@@ -4225,7 +4344,10 @@ function renderStockChart(chart, x, y, w, h) {
|
|
|
4225
4344
|
minVal = Math.min(minVal, v);
|
|
4226
4345
|
}
|
|
4227
4346
|
}
|
|
4228
|
-
if (maxVal === minVal)
|
|
4347
|
+
if (maxVal === minVal) {
|
|
4348
|
+
debug("chart.stock", "max equals min value");
|
|
4349
|
+
return "";
|
|
4350
|
+
}
|
|
4229
4351
|
parts.push(
|
|
4230
4352
|
`<line x1="${round3(x)}" y1="${round3(y + h)}" x2="${round3(x + w)}" y2="${round3(y + h)}" stroke="#D9D9D9" stroke-width="1"/>`
|
|
4231
4353
|
);
|
|
@@ -4261,10 +4383,16 @@ function renderStockChart(chart, x, y, w, h) {
|
|
|
4261
4383
|
function renderSurfaceChart(chart, x, y, w, h) {
|
|
4262
4384
|
const parts = [];
|
|
4263
4385
|
const { series, categories } = chart;
|
|
4264
|
-
if (series.length === 0)
|
|
4386
|
+
if (series.length === 0) {
|
|
4387
|
+
debug("chart.surface", "series is empty");
|
|
4388
|
+
return "";
|
|
4389
|
+
}
|
|
4265
4390
|
const rows = series.length;
|
|
4266
4391
|
const cols = categories.length || Math.max(...series.map((s) => s.values.length));
|
|
4267
|
-
if (cols === 0)
|
|
4392
|
+
if (cols === 0) {
|
|
4393
|
+
debug("chart.surface", "column count is 0");
|
|
4394
|
+
return "";
|
|
4395
|
+
}
|
|
4268
4396
|
let minVal = Infinity;
|
|
4269
4397
|
let maxVal = -Infinity;
|
|
4270
4398
|
for (const s of series) {
|
|
@@ -4337,9 +4465,15 @@ function heatmapColor(t) {
|
|
|
4337
4465
|
function renderOfPieChart(chart, x, y, w, h) {
|
|
4338
4466
|
const parts = [];
|
|
4339
4467
|
const series = chart.series[0];
|
|
4340
|
-
if (!series || series.values.length === 0)
|
|
4468
|
+
if (!series || series.values.length === 0) {
|
|
4469
|
+
debug("chart.ofPie", "series is empty or has no values");
|
|
4470
|
+
return "";
|
|
4471
|
+
}
|
|
4341
4472
|
const total = series.values.reduce((sum, v) => sum + v, 0);
|
|
4342
|
-
if (total === 0)
|
|
4473
|
+
if (total === 0) {
|
|
4474
|
+
debug("chart.ofPie", "total value is 0");
|
|
4475
|
+
return "";
|
|
4476
|
+
}
|
|
4343
4477
|
const splitPos = chart.splitPos ?? 2;
|
|
4344
4478
|
const secondPieSize = chart.secondPieSize ?? 75;
|
|
4345
4479
|
const isBarOfPie = chart.ofPieType === "bar";
|
|
@@ -4704,65 +4838,6 @@ async function svgToPng(svgString, options) {
|
|
|
4704
4838
|
return { png: result.data, width: result.info.width, height: result.info.height };
|
|
4705
4839
|
}
|
|
4706
4840
|
|
|
4707
|
-
// src/warning-logger.ts
|
|
4708
|
-
var PREFIX = "[pptx-glimpse]";
|
|
4709
|
-
var currentLevel = "off";
|
|
4710
|
-
var entries = [];
|
|
4711
|
-
var featureCounts = /* @__PURE__ */ new Map();
|
|
4712
|
-
function initWarningLogger(level) {
|
|
4713
|
-
currentLevel = level;
|
|
4714
|
-
entries = [];
|
|
4715
|
-
featureCounts.clear();
|
|
4716
|
-
}
|
|
4717
|
-
function warn(feature, message, context) {
|
|
4718
|
-
if (currentLevel === "off") return;
|
|
4719
|
-
entries.push({ feature, message, ...context !== void 0 && { context } });
|
|
4720
|
-
const existing = featureCounts.get(feature);
|
|
4721
|
-
if (existing) {
|
|
4722
|
-
existing.count++;
|
|
4723
|
-
} else {
|
|
4724
|
-
featureCounts.set(feature, { message, count: 1 });
|
|
4725
|
-
}
|
|
4726
|
-
if (currentLevel === "debug") {
|
|
4727
|
-
const ctx = context ? ` (${context})` : "";
|
|
4728
|
-
console.warn(`${PREFIX} SKIP: ${feature} - ${message}${ctx}`);
|
|
4729
|
-
}
|
|
4730
|
-
}
|
|
4731
|
-
function debug(feature, message, context) {
|
|
4732
|
-
if (currentLevel !== "debug") return;
|
|
4733
|
-
entries.push({ feature, message, ...context !== void 0 && { context } });
|
|
4734
|
-
const existing = featureCounts.get(feature);
|
|
4735
|
-
if (existing) {
|
|
4736
|
-
existing.count++;
|
|
4737
|
-
} else {
|
|
4738
|
-
featureCounts.set(feature, { message, count: 1 });
|
|
4739
|
-
}
|
|
4740
|
-
const ctx = context ? ` (${context})` : "";
|
|
4741
|
-
console.warn(`${PREFIX} DEBUG: ${feature} - ${message}${ctx}`);
|
|
4742
|
-
}
|
|
4743
|
-
function getWarningSummary() {
|
|
4744
|
-
const features = [];
|
|
4745
|
-
for (const [feature, { message, count }] of featureCounts) {
|
|
4746
|
-
features.push({ feature, message, count });
|
|
4747
|
-
}
|
|
4748
|
-
return { totalCount: entries.length, features };
|
|
4749
|
-
}
|
|
4750
|
-
function flushWarnings() {
|
|
4751
|
-
const summary = getWarningSummary();
|
|
4752
|
-
if (currentLevel !== "off" && summary.features.length > 0) {
|
|
4753
|
-
console.warn(`${PREFIX} Summary: ${summary.features.length} unsupported feature(s) detected`);
|
|
4754
|
-
for (const { feature, count } of summary.features) {
|
|
4755
|
-
console.warn(` - ${feature}: ${count} occurrence(s)`);
|
|
4756
|
-
}
|
|
4757
|
-
}
|
|
4758
|
-
entries = [];
|
|
4759
|
-
featureCounts.clear();
|
|
4760
|
-
return summary;
|
|
4761
|
-
}
|
|
4762
|
-
function getWarningEntries() {
|
|
4763
|
-
return entries;
|
|
4764
|
-
}
|
|
4765
|
-
|
|
4766
4841
|
// src/parser/pptx-reader.ts
|
|
4767
4842
|
import { unzipSync, strFromU8 } from "fflate";
|
|
4768
4843
|
function readPptx(input) {
|
|
@@ -6140,10 +6215,16 @@ function parseCustomGeometry(custGeom) {
|
|
|
6140
6215
|
for (const path of paths) {
|
|
6141
6216
|
const w = Number(path["@_w"] ?? 0);
|
|
6142
6217
|
const h = Number(path["@_h"] ?? 0);
|
|
6143
|
-
if (w === 0 && h === 0)
|
|
6218
|
+
if (w === 0 && h === 0) {
|
|
6219
|
+
debug("custGeom.path", "path skipped: width and height are both 0");
|
|
6220
|
+
continue;
|
|
6221
|
+
}
|
|
6144
6222
|
const vars = evaluateGuides(avGd, gdGd, w, h);
|
|
6145
6223
|
const commands = buildPathCommands(path, vars);
|
|
6146
|
-
if (!commands)
|
|
6224
|
+
if (!commands) {
|
|
6225
|
+
debug("custGeom.path", "path skipped: failed to build path commands");
|
|
6226
|
+
continue;
|
|
6227
|
+
}
|
|
6147
6228
|
result.push({ width: w, height: h, commands });
|
|
6148
6229
|
}
|
|
6149
6230
|
return result.length > 0 ? result : null;
|
|
@@ -6716,7 +6797,10 @@ function parseImage(pic, rels, slidePath, archive, colorResolver) {
|
|
|
6716
6797
|
if (!rel) return null;
|
|
6717
6798
|
const mediaPath = resolveRelationshipTarget(slidePath, rel.target);
|
|
6718
6799
|
const mediaData = archive.media.get(mediaPath);
|
|
6719
|
-
if (!mediaData)
|
|
6800
|
+
if (!mediaData) {
|
|
6801
|
+
debug("picture.media", `media file not found: ${mediaPath}`);
|
|
6802
|
+
return null;
|
|
6803
|
+
}
|
|
6720
6804
|
const ext = mediaPath.split(".").pop()?.toLowerCase() ?? "png";
|
|
6721
6805
|
const mimeMap = {
|
|
6722
6806
|
png: "image/png",
|
|
@@ -6915,9 +6999,15 @@ function parseSmartArt(graphicData, transform, rels, slidePath, archive, colorRe
|
|
|
6915
6999
|
}
|
|
6916
7000
|
}
|
|
6917
7001
|
}
|
|
6918
|
-
if (!drawingPath)
|
|
7002
|
+
if (!drawingPath) {
|
|
7003
|
+
debug("smartArt.drawing", "diagramDrawing relationship not found");
|
|
7004
|
+
return null;
|
|
7005
|
+
}
|
|
6919
7006
|
const drawingXml = archive.files.get(drawingPath);
|
|
6920
|
-
if (!drawingXml)
|
|
7007
|
+
if (!drawingXml) {
|
|
7008
|
+
debug("smartArt.drawing", `drawing XML not found in archive: ${drawingPath}`);
|
|
7009
|
+
return null;
|
|
7010
|
+
}
|
|
6921
7011
|
const parsed = parseXml(drawingXml);
|
|
6922
7012
|
const drawing = parsed.drawing;
|
|
6923
7013
|
const spTree = drawing?.spTree;
|