ooxml-core 0.8.0 → 0.9.0

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
@@ -188,6 +188,363 @@ function linearToSrgb255(linear) {
188
188
  return 255 * (c <= 31308e-7 ? c * 12.92 : 1.055 * c ** (1 / 2.4) - 0.055);
189
189
  }
190
190
 
191
+ // src/chart/index.ts
192
+ var chart_exports = {};
193
+ __export(chart_exports, {
194
+ computeBoxStats: () => computeBoxStats,
195
+ computeLinearRegression: () => computeLinearRegression,
196
+ computeRSquared: () => computeRSquared,
197
+ computeStackedSeriesPlots: () => computeStackedSeriesPlots,
198
+ fitPolynomial: () => fitPolynomial,
199
+ groupRowsByCategory: () => groupRowsByCategory,
200
+ resolveBlankDisplay: () => resolveBlankDisplay,
201
+ visibleRuns: () => visibleRuns
202
+ });
203
+
204
+ // src/chart/regression.ts
205
+ function computeLinearRegression(xVals, yVals) {
206
+ const n = xVals.length;
207
+ if (n < 2) {
208
+ return { slope: 0, intercept: 0, rSquared: 0 };
209
+ }
210
+ let sumX = 0;
211
+ let sumY = 0;
212
+ let sumXY = 0;
213
+ let sumXX = 0;
214
+ for (let i = 0; i < n; i++) {
215
+ sumX += xVals[i];
216
+ sumY += yVals[i];
217
+ sumXY += xVals[i] * yVals[i];
218
+ sumXX += xVals[i] * xVals[i];
219
+ }
220
+ const denom = n * sumXX - sumX * sumX;
221
+ if (Math.abs(denom) < 1e-12) {
222
+ return { slope: 0, intercept: sumY / n, rSquared: 0 };
223
+ }
224
+ const slope = (n * sumXY - sumX * sumY) / denom;
225
+ const intercept = (sumY - slope * sumX) / n;
226
+ const ssRes = yVals.reduce((s, y, i) => s + (y - (slope * xVals[i] + intercept)) ** 2, 0);
227
+ const meanY = sumY / n;
228
+ const ssTot = yVals.reduce((s, y) => s + (y - meanY) ** 2, 0);
229
+ const rSquared = ssTot > 0 ? 1 - ssRes / ssTot : 0;
230
+ return { slope, intercept, rSquared };
231
+ }
232
+ function fitPolynomial(xVals, yVals, order) {
233
+ const n = xVals.length;
234
+ const m = order + 1;
235
+ const matrix = Array.from({ length: m }, () => Array(m + 1).fill(0));
236
+ for (let i = 0; i < m; i++) {
237
+ for (let j = 0; j < m; j++) {
238
+ let sum2 = 0;
239
+ for (let k = 0; k < n; k++) {
240
+ sum2 += xVals[k] ** (i + j);
241
+ }
242
+ matrix[i][j] = sum2;
243
+ }
244
+ let sum = 0;
245
+ for (let k = 0; k < n; k++) {
246
+ sum += yVals[k] * xVals[k] ** i;
247
+ }
248
+ matrix[i][m] = sum;
249
+ }
250
+ for (let i = 0; i < m; i++) {
251
+ let maxRow = i;
252
+ for (let k = i + 1; k < m; k++) {
253
+ if (Math.abs(matrix[k][i]) > Math.abs(matrix[maxRow][i])) {
254
+ maxRow = k;
255
+ }
256
+ }
257
+ [matrix[i], matrix[maxRow]] = [matrix[maxRow], matrix[i]];
258
+ const pivot = matrix[i][i];
259
+ if (Math.abs(pivot) < 1e-12) {
260
+ continue;
261
+ }
262
+ for (let j = i; j <= m; j++) {
263
+ matrix[i][j] = matrix[i][j] / pivot;
264
+ }
265
+ for (let k = 0; k < m; k++) {
266
+ if (k === i) {
267
+ continue;
268
+ }
269
+ const factor = matrix[k][i];
270
+ for (let j = i; j <= m; j++) {
271
+ matrix[k][j] = matrix[k][j] - factor * matrix[i][j];
272
+ }
273
+ }
274
+ }
275
+ return matrix.map((row) => row[m]);
276
+ }
277
+ function computeRSquared(xVals, yVals, evalFn) {
278
+ const n = xVals.length;
279
+ if (n === 0) {
280
+ return 0;
281
+ }
282
+ const meanY = yVals.reduce((s, y) => s + y, 0) / n;
283
+ let ssRes = 0;
284
+ let ssTot = 0;
285
+ for (let i = 0; i < n; i++) {
286
+ ssRes += (yVals[i] - evalFn(xVals[i])) ** 2;
287
+ ssTot += (yVals[i] - meanY) ** 2;
288
+ }
289
+ return ssTot > 0 ? 1 - ssRes / ssTot : 0;
290
+ }
291
+
292
+ // src/chart/box-stats.ts
293
+ function groupRowsByCategory(rawCategories) {
294
+ const uniqueCategories = [];
295
+ const rowIndexesByCategory = /* @__PURE__ */ new Map();
296
+ rawCategories.forEach((rawLabel, rowIndex) => {
297
+ const label = rawLabel ?? "";
298
+ let rows = rowIndexesByCategory.get(label);
299
+ if (!rows) {
300
+ rows = [];
301
+ rowIndexesByCategory.set(label, rows);
302
+ uniqueCategories.push(label);
303
+ }
304
+ rows.push(rowIndex);
305
+ });
306
+ return { uniqueCategories, rowIndexesByCategory };
307
+ }
308
+ function percentile(sorted, p, method) {
309
+ const rank = method === "inclusive" ? (sorted.length - 1) * p : (sorted.length + 1) * p - 1;
310
+ const clamped = Math.max(0, Math.min(rank, sorted.length - 1));
311
+ const lower = Math.floor(clamped);
312
+ const upper = Math.ceil(clamped);
313
+ const fraction = clamped - lower;
314
+ return sorted[lower] + (sorted[upper] - sorted[lower]) * fraction;
315
+ }
316
+ function computeBoxStats(values, method) {
317
+ if (values.length < 2) {
318
+ return void 0;
319
+ }
320
+ const sorted = [...values].sort((a, b) => a - b);
321
+ if (!method) {
322
+ return {
323
+ min: sorted[0],
324
+ q1: sorted[Math.floor(sorted.length * 0.25)],
325
+ median: sorted[Math.floor(sorted.length * 0.5)],
326
+ q3: sorted[Math.floor(sorted.length * 0.75)],
327
+ max: sorted[sorted.length - 1]
328
+ };
329
+ }
330
+ return {
331
+ min: sorted[0],
332
+ q1: percentile(sorted, 0.25, method),
333
+ median: percentile(sorted, 0.5, method),
334
+ q3: percentile(sorted, 0.75, method),
335
+ max: sorted[sorted.length - 1]
336
+ };
337
+ }
338
+
339
+ // src/chart/blank-display.ts
340
+ function interpolate(values, blank) {
341
+ const out = [...values];
342
+ for (let i = 0; i < out.length; i++) {
343
+ if (!blank[i]) {
344
+ continue;
345
+ }
346
+ let prev = i - 1;
347
+ while (prev >= 0 && blank[prev]) {
348
+ prev--;
349
+ }
350
+ let next = i + 1;
351
+ while (next < out.length && blank[next]) {
352
+ next++;
353
+ }
354
+ const hasPrev = prev >= 0;
355
+ const hasNext = next < out.length;
356
+ if (hasPrev && hasNext) {
357
+ const t = (i - prev) / (next - prev);
358
+ out[i] = values[prev] + (values[next] - values[prev]) * t;
359
+ } else if (hasPrev) {
360
+ out[i] = values[prev];
361
+ } else if (hasNext) {
362
+ out[i] = values[next];
363
+ }
364
+ }
365
+ return out;
366
+ }
367
+ function resolveBlankDisplay(values, blanks, mode) {
368
+ const visible = values.map(() => true);
369
+ if (!blanks || !blanks.some(Boolean) || mode === void 0 || mode === "zero") {
370
+ return { values: [...values], visible };
371
+ }
372
+ if (mode === "span") {
373
+ return { values: interpolate(values, blanks), visible };
374
+ }
375
+ return {
376
+ values: [...values],
377
+ visible: values.map((_v, i) => !blanks[i])
378
+ };
379
+ }
380
+ function visibleRuns(visible) {
381
+ const runs = [];
382
+ let current = [];
383
+ for (let i = 0; i < visible.length; i++) {
384
+ if (visible[i]) {
385
+ current.push(i);
386
+ } else if (current.length > 0) {
387
+ runs.push(current);
388
+ current = [];
389
+ }
390
+ }
391
+ if (current.length > 0) {
392
+ runs.push(current);
393
+ }
394
+ return runs;
395
+ }
396
+
397
+ // src/chart/stacked-series.ts
398
+ function categoryAbsTotals(seriesValues, catCount) {
399
+ return Array.from(
400
+ { length: catCount },
401
+ (_, ci) => seriesValues.reduce((sum, values) => sum + Math.abs(values[ci] ?? 0), 0)
402
+ );
403
+ }
404
+ function computeStackedSeriesPlots(seriesValues, catCount, percent) {
405
+ const totals = percent ? categoryAbsTotals(seriesValues, catCount) : void 0, posRunning = new Array(catCount).fill(0), negRunning = new Array(catCount).fill(0);
406
+ return seriesValues.map((values) => {
407
+ const cumulative = [], base = [], own = [];
408
+ for (let ci = 0; ci < catCount; ci++) {
409
+ const raw = values[ci] ?? 0, total = totals?.[ci] ?? 0, val2 = percent ? total > 0 ? raw / total * 100 : 0 : raw, isNeg = val2 < 0, from = isNeg ? negRunning[ci] : posRunning[ci], to = from + val2;
410
+ base.push(from);
411
+ cumulative.push(to);
412
+ own.push(val2);
413
+ if (isNeg) {
414
+ negRunning[ci] = to;
415
+ } else {
416
+ posRunning[ci] = to;
417
+ }
418
+ }
419
+ return { cumulative, base, own };
420
+ });
421
+ }
422
+
423
+ // src/text/index.ts
424
+ var text_exports = {};
425
+ __export(text_exports, {
426
+ detectFontScript: () => detectFontScript,
427
+ hasDistinctScriptFonts: () => hasDistinctScriptFonts,
428
+ resolveFontForScript: () => resolveFontForScript,
429
+ segmentByScript: () => segmentByScript
430
+ });
431
+
432
+ // src/text/unicode-script-detection.ts
433
+ function detectFontScript(codePoint) {
434
+ if (codePoint >= 11904 && codePoint <= 40959 || // CJK radicals, unified ideographs
435
+ codePoint >= 44032 && codePoint <= 55215 || // Hangul syllables
436
+ codePoint >= 63744 && codePoint <= 64255 || // CJK compatibility ideographs
437
+ codePoint >= 65072 && codePoint <= 65103 || // CJK compatibility forms
438
+ codePoint >= 131072 && codePoint <= 195103 || // CJK extension B-F
439
+ codePoint >= 12288 && codePoint <= 12351 || // CJK symbols & punctuation
440
+ codePoint >= 12352 && codePoint <= 12447 || // Hiragana
441
+ codePoint >= 12448 && codePoint <= 12543 || // Katakana
442
+ codePoint >= 12784 && codePoint <= 12799 || // Katakana extensions
443
+ codePoint >= 65280 && codePoint <= 65519) {
444
+ return "eastAsia";
445
+ }
446
+ if (codePoint >= 1424 && codePoint <= 1535 || // Hebrew
447
+ codePoint >= 1536 && codePoint <= 1791 || // Arabic
448
+ codePoint >= 1792 && codePoint <= 1871 || // Syriac
449
+ codePoint >= 1872 && codePoint <= 1919 || // Arabic Supplement
450
+ codePoint >= 1920 && codePoint <= 1983 || // Thaana
451
+ codePoint >= 1984 && codePoint <= 2047 || // NKo
452
+ codePoint >= 2048 && codePoint <= 2111 || // Samaritan
453
+ codePoint >= 2304 && codePoint <= 2431 || // Devanagari
454
+ codePoint >= 2432 && codePoint <= 2559 || // Bengali
455
+ codePoint >= 2560 && codePoint <= 2687 || // Gurmukhi
456
+ codePoint >= 2688 && codePoint <= 2815 || // Gujarati
457
+ codePoint >= 2816 && codePoint <= 2943 || // Oriya
458
+ codePoint >= 2944 && codePoint <= 3071 || // Tamil
459
+ codePoint >= 3072 && codePoint <= 3199 || // Telugu
460
+ codePoint >= 3200 && codePoint <= 3327 || // Kannada
461
+ codePoint >= 3328 && codePoint <= 3455 || // Malayalam
462
+ codePoint >= 3456 && codePoint <= 3583 || // Sinhala
463
+ codePoint >= 3584 && codePoint <= 3711 || // Thai
464
+ codePoint >= 3712 && codePoint <= 3839 || // Lao
465
+ codePoint >= 3840 && codePoint <= 4095 || // Tibetan
466
+ codePoint >= 4096 && codePoint <= 4255 || // Myanmar
467
+ codePoint >= 4256 && codePoint <= 4351 || // Georgian
468
+ codePoint >= 6016 && codePoint <= 6143 || // Khmer
469
+ codePoint >= 64336 && codePoint <= 65023 || // Arabic Presentation Forms-A
470
+ codePoint >= 65136 && codePoint <= 65279) {
471
+ return "complexScript";
472
+ }
473
+ if (codePoint >= 8592 && codePoint <= 8703 || // Arrows
474
+ codePoint >= 8704 && codePoint <= 8959 || // Mathematical operators
475
+ codePoint >= 8960 && codePoint <= 9215 || // Misc technical
476
+ codePoint >= 9472 && codePoint <= 9599 || // Box drawing
477
+ codePoint >= 9600 && codePoint <= 9631 || // Block elements
478
+ codePoint >= 9632 && codePoint <= 9727 || // Geometric shapes
479
+ codePoint >= 9728 && codePoint <= 9983 || // Misc symbols
480
+ codePoint >= 9984 && codePoint <= 10175 || // Dingbats
481
+ codePoint >= 57344 && codePoint <= 63743 || // Private Use Area
482
+ codePoint >= 126976 && codePoint <= 129535) {
483
+ return "symbol";
484
+ }
485
+ return "latin";
486
+ }
487
+ function segmentByScript(text) {
488
+ if (!text) {
489
+ return [];
490
+ }
491
+ const runs = [];
492
+ let currentScript = null;
493
+ let currentStart = 0;
494
+ let currentText = "";
495
+ for (let i = 0; i < text.length; i++) {
496
+ const codePoint = text.codePointAt(i);
497
+ if (codePoint === void 0) {
498
+ continue;
499
+ }
500
+ const charLength = codePoint > 65535 ? 2 : 1;
501
+ const char = text.substring(i, i + charLength);
502
+ const isNeutral = codePoint <= 127 && !/[a-zA-Z0-9]/u.test(char);
503
+ const script = isNeutral ? currentScript ?? "latin" : detectFontScript(codePoint);
504
+ if (script !== currentScript && currentScript !== null) {
505
+ runs.push({
506
+ text: currentText,
507
+ script: currentScript,
508
+ startIndex: currentStart
509
+ });
510
+ currentStart = i;
511
+ currentText = "";
512
+ }
513
+ currentScript = script;
514
+ currentText += char;
515
+ if (charLength === 2) {
516
+ i++;
517
+ }
518
+ }
519
+ if (currentText && currentScript) {
520
+ runs.push({
521
+ text: currentText,
522
+ script: currentScript,
523
+ startIndex: currentStart
524
+ });
525
+ }
526
+ return runs;
527
+ }
528
+ function resolveFontForScript(script, fonts) {
529
+ switch (script) {
530
+ case "latin":
531
+ return fonts.latin;
532
+ case "eastAsia":
533
+ return fonts.eastAsia || fonts.latin;
534
+ case "complexScript":
535
+ return fonts.complexScript || fonts.latin;
536
+ case "symbol":
537
+ return fonts.symbol || fonts.latin;
538
+ }
539
+ }
540
+ function hasDistinctScriptFonts(fonts) {
541
+ const base = fonts.latin;
542
+ if (!base) {
543
+ return false;
544
+ }
545
+ return Boolean(fonts.eastAsia) && fonts.eastAsia !== base || Boolean(fonts.complexScript) && fonts.complexScript !== base || Boolean(fonts.symbol) && fonts.symbol !== base;
546
+ }
547
+
191
548
  // src/diagram/index.ts
192
549
  var diagram_exports = {};
193
550
  __export(diagram_exports, {
@@ -2214,6 +2571,7 @@ __export(geometry_exports, {
2214
2571
  evaluateFormula: () => evaluateFormula,
2215
2572
  evaluateGuides: () => evaluateGuides,
2216
2573
  findAllIntersections: () => findAllIntersections,
2574
+ flattenSvgPath: () => flattenSvgPath,
2217
2575
  fmtNum: () => fmtNum,
2218
2576
  fragmentShapes: () => fragmentShapes,
2219
2577
  gd: () => gd,
@@ -17161,6 +17519,197 @@ function subtractSvgPaths(path1, path2) {
17161
17519
  return subtractShapes(path1, path2);
17162
17520
  }
17163
17521
 
17522
+ // src/geometry/svg-path-curves.ts
17523
+ function sampleCubic(p0, p1, p2, p3, segments, out) {
17524
+ for (let i = 1; i <= segments; i++) {
17525
+ const t = i / segments;
17526
+ const mt = 1 - t;
17527
+ const x = mt * mt * mt * p0.x + 3 * mt * mt * t * p1.x + 3 * mt * t * t * p2.x + t * t * t * p3.x;
17528
+ const y = mt * mt * mt * p0.y + 3 * mt * mt * t * p1.y + 3 * mt * t * t * p2.y + t * t * t * p3.y;
17529
+ out.push({ x, y });
17530
+ }
17531
+ }
17532
+ function sampleQuadratic(p0, p1, p2, segments, out) {
17533
+ for (let i = 1; i <= segments; i++) {
17534
+ const t = i / segments;
17535
+ const mt = 1 - t;
17536
+ const x = mt * mt * p0.x + 2 * mt * t * p1.x + t * t * p2.x;
17537
+ const y = mt * mt * p0.y + 2 * mt * t * p1.y + t * t * p2.y;
17538
+ out.push({ x, y });
17539
+ }
17540
+ }
17541
+ function sampleArc(start, rxIn, ryIn, xAxisRotationDeg, largeArcFlag, sweepFlag, end, segments, out) {
17542
+ if (rxIn === 0 || ryIn === 0 || start.x === end.x && start.y === end.y) {
17543
+ out.push(end);
17544
+ return;
17545
+ }
17546
+ const phi = xAxisRotationDeg * Math.PI / 180;
17547
+ const cosPhi = Math.cos(phi);
17548
+ const sinPhi = Math.sin(phi);
17549
+ let rx = Math.abs(rxIn);
17550
+ let ry = Math.abs(ryIn);
17551
+ const dx2 = (start.x - end.x) / 2;
17552
+ const dy2 = (start.y - end.y) / 2;
17553
+ const x1p = cosPhi * dx2 + sinPhi * dy2;
17554
+ const y1p = -sinPhi * dx2 + cosPhi * dy2;
17555
+ const lambda = x1p * x1p / (rx * rx) + y1p * y1p / (ry * ry);
17556
+ if (lambda > 1) {
17557
+ const scale = Math.sqrt(lambda);
17558
+ rx *= scale;
17559
+ ry *= scale;
17560
+ }
17561
+ const sign = largeArcFlag !== sweepFlag ? 1 : -1;
17562
+ const num = rx * rx * ry * ry - rx * rx * y1p * y1p - ry * ry * x1p * x1p;
17563
+ const den = rx * rx * y1p * y1p + ry * ry * x1p * x1p;
17564
+ const coef = sign * Math.sqrt(Math.max(0, num / den));
17565
+ const cxp = coef * (rx * y1p) / ry;
17566
+ const cyp = coef * -(ry * x1p) / rx;
17567
+ const cx = cosPhi * cxp - sinPhi * cyp + (start.x + end.x) / 2;
17568
+ const cy = sinPhi * cxp + cosPhi * cyp + (start.y + end.y) / 2;
17569
+ const angle = (ux, uy, vx, vy) => {
17570
+ const sign2 = ux * vy - uy * vx < 0 ? -1 : 1;
17571
+ const dot = Math.max(
17572
+ -1,
17573
+ Math.min(1, (ux * vx + uy * vy) / (Math.hypot(ux, uy) * Math.hypot(vx, vy)))
17574
+ );
17575
+ return sign2 * Math.acos(dot);
17576
+ };
17577
+ const theta1 = angle(1, 0, (x1p - cxp) / rx, (y1p - cyp) / ry);
17578
+ let deltaTheta = angle((x1p - cxp) / rx, (y1p - cyp) / ry, (-x1p - cxp) / rx, (-y1p - cyp) / ry);
17579
+ if (!sweepFlag && deltaTheta > 0) {
17580
+ deltaTheta -= 2 * Math.PI;
17581
+ } else if (sweepFlag && deltaTheta < 0) {
17582
+ deltaTheta += 2 * Math.PI;
17583
+ }
17584
+ const steps = Math.max(2, Math.round(segments * (Math.abs(deltaTheta) / (Math.PI / 2))));
17585
+ for (let i = 1; i <= steps; i++) {
17586
+ const theta = theta1 + deltaTheta * i / steps;
17587
+ const x = cx + rx * Math.cos(theta) * cosPhi - ry * Math.sin(theta) * sinPhi;
17588
+ const y = cy + rx * Math.cos(theta) * sinPhi + ry * Math.sin(theta) * cosPhi;
17589
+ out.push({ x, y });
17590
+ }
17591
+ }
17592
+
17593
+ // src/geometry/svg-path-flatten.ts
17594
+ var COMMAND_RE = /[MLCQZAHVSmlcqzahvs][^MLCQZAHVSmlcqzahvs]*/gu;
17595
+ var NUMBER_RE = /-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/gu;
17596
+ function tokenize(d) {
17597
+ const tokens = [];
17598
+ const matches = d.match(COMMAND_RE);
17599
+ if (!matches) {
17600
+ return tokens;
17601
+ }
17602
+ for (const raw of matches) {
17603
+ const type = raw.charAt(0);
17604
+ const nums = raw.slice(1).match(NUMBER_RE);
17605
+ tokens.push({ type, values: nums ? nums.map((n) => Number.parseFloat(n)) : [] });
17606
+ }
17607
+ return tokens;
17608
+ }
17609
+ function flattenSvgPath(d, curveSegments = 16) {
17610
+ if (!Number.isFinite(curveSegments) || curveSegments < 1) curveSegments = 16;
17611
+ curveSegments = Math.min(4096, Math.floor(curveSegments));
17612
+ const tokens = tokenize(d);
17613
+ const loops = [];
17614
+ let current = [];
17615
+ let cursor = { x: 0, y: 0 };
17616
+ let subpathStart = { x: 0, y: 0 };
17617
+ let lastControl;
17618
+ let lastCommand = "";
17619
+ const closeLoop = () => {
17620
+ if (current.length > 0) {
17621
+ loops.push(current);
17622
+ }
17623
+ current = [];
17624
+ };
17625
+ for (const token of tokens) {
17626
+ const type = token.type;
17627
+ const upper = type.toUpperCase();
17628
+ const relative = type !== upper;
17629
+ const v = token.values;
17630
+ if (v.some((value) => !Number.isFinite(value)) || upper === "M" && v.length < 2) continue;
17631
+ if (upper === "M") {
17632
+ closeLoop();
17633
+ const x = relative ? cursor.x + at(v, 0) : at(v, 0);
17634
+ const y = relative ? cursor.y + at(v, 1) : at(v, 1);
17635
+ cursor = { x, y };
17636
+ subpathStart = cursor;
17637
+ current.push(cursor);
17638
+ for (let i = 2; i + 1 < v.length; i += 2) {
17639
+ const lx = relative ? cursor.x + at(v, i) : at(v, i);
17640
+ const ly = relative ? cursor.y + at(v, i + 1) : at(v, i + 1);
17641
+ cursor = { x: lx, y: ly };
17642
+ current.push(cursor);
17643
+ }
17644
+ } else if (upper === "L") {
17645
+ for (let i = 0; i + 1 < v.length; i += 2) {
17646
+ const x = relative ? cursor.x + at(v, i) : at(v, i);
17647
+ const y = relative ? cursor.y + at(v, i + 1) : at(v, i + 1);
17648
+ cursor = { x, y };
17649
+ current.push(cursor);
17650
+ }
17651
+ } else if (upper === "H") {
17652
+ for (const value of v) {
17653
+ const x = relative ? cursor.x + value : value;
17654
+ cursor = { x, y: cursor.y };
17655
+ current.push(cursor);
17656
+ }
17657
+ } else if (upper === "V") {
17658
+ for (const value of v) {
17659
+ const y = relative ? cursor.y + value : value;
17660
+ cursor = { x: cursor.x, y };
17661
+ current.push(cursor);
17662
+ }
17663
+ } else if (upper === "C") {
17664
+ for (let i = 0; i + 5 < v.length; i += 6) {
17665
+ const p1 = relative ? { x: cursor.x + at(v, i), y: cursor.y + at(v, i + 1) } : { x: at(v, i), y: at(v, i + 1) };
17666
+ const p2 = relative ? { x: cursor.x + at(v, i + 2), y: cursor.y + at(v, i + 3) } : { x: at(v, i + 2), y: at(v, i + 3) };
17667
+ const p3 = relative ? { x: cursor.x + at(v, i + 4), y: cursor.y + at(v, i + 5) } : { x: at(v, i + 4), y: at(v, i + 5) };
17668
+ sampleCubic(cursor, p1, p2, p3, curveSegments, current);
17669
+ cursor = p3;
17670
+ lastControl = p2;
17671
+ }
17672
+ } else if (upper === "S") {
17673
+ for (let i = 0; i + 3 < v.length; i += 4) {
17674
+ const p1 = lastCommand === "C" || lastCommand === "S" ? {
17675
+ x: 2 * cursor.x - (lastControl?.x ?? cursor.x),
17676
+ y: 2 * cursor.y - (lastControl?.y ?? cursor.y)
17677
+ } : cursor;
17678
+ const p2 = relative ? { x: cursor.x + at(v, i), y: cursor.y + at(v, i + 1) } : { x: at(v, i), y: at(v, i + 1) };
17679
+ const p3 = relative ? { x: cursor.x + at(v, i + 2), y: cursor.y + at(v, i + 3) } : { x: at(v, i + 2), y: at(v, i + 3) };
17680
+ sampleCubic(cursor, p1, p2, p3, curveSegments, current);
17681
+ cursor = p3;
17682
+ lastControl = p2;
17683
+ }
17684
+ } else if (upper === "Q") {
17685
+ for (let i = 0; i + 3 < v.length; i += 4) {
17686
+ const p1 = relative ? { x: cursor.x + at(v, i), y: cursor.y + at(v, i + 1) } : { x: at(v, i), y: at(v, i + 1) };
17687
+ const p2 = relative ? { x: cursor.x + at(v, i + 2), y: cursor.y + at(v, i + 3) } : { x: at(v, i + 2), y: at(v, i + 3) };
17688
+ sampleQuadratic(cursor, p1, p2, curveSegments, current);
17689
+ cursor = p2;
17690
+ lastControl = p1;
17691
+ }
17692
+ } else if (upper === "A") {
17693
+ for (let i = 0; i + 6 < v.length; i += 7) {
17694
+ const rx = at(v, i);
17695
+ const ry = at(v, i + 1);
17696
+ const rot = at(v, i + 2);
17697
+ const largeArc = at(v, i + 3) !== 0;
17698
+ const sweep = at(v, i + 4) !== 0;
17699
+ const end = relative ? { x: cursor.x + at(v, i + 5), y: cursor.y + at(v, i + 6) } : { x: at(v, i + 5), y: at(v, i + 6) };
17700
+ sampleArc(cursor, rx, ry, rot, largeArc, sweep, end, curveSegments, current);
17701
+ cursor = end;
17702
+ }
17703
+ } else if (upper === "Z") {
17704
+ cursor = subpathStart;
17705
+ current.push(cursor);
17706
+ }
17707
+ lastCommand = upper;
17708
+ }
17709
+ closeLoop();
17710
+ return loops;
17711
+ }
17712
+
17164
17713
  // src/units/index.ts
17165
17714
  var units_exports = {};
17166
17715
  __export(units_exports, {
@@ -17304,7 +17853,7 @@ __export(math_exports, {
17304
17853
  readRunText: () => readRunText,
17305
17854
  rowsToLatex: () => rowsToLatex,
17306
17855
  soleChild: () => soleChild,
17307
- tokenize: () => tokenize,
17856
+ tokenize: () => tokenize2,
17308
17857
  tryParseScripts: () => tryParseScripts,
17309
17858
  wrapDelimited: () => wrapDelimited
17310
17859
  });
@@ -17320,7 +17869,7 @@ function stripXmlOrderSuffix(tagName) {
17320
17869
  // src/math/latex-omml-siblings.ts
17321
17870
  var LETTER_RE = /[a-zA-Z]/u;
17322
17871
  var WHITESPACE_RE = /\s/u;
17323
- function tokenize(latex) {
17872
+ function tokenize2(latex) {
17324
17873
  const tokens = [];
17325
17874
  let i = 0;
17326
17875
  while (i < latex.length) {
@@ -18675,7 +19224,7 @@ function convertLatexToOmml(latex) {
18675
19224
  if (trimmed.length === 0) {
18676
19225
  return {};
18677
19226
  }
18678
- const tokens = tokenize(trimmed);
19227
+ const tokens = tokenize2(trimmed);
18679
19228
  const parser = new LatexParser(tokens);
18680
19229
  const nodes = parser.parseAll();
18681
19230
  if (nodes.length === 0) {
@@ -19268,11 +19817,13 @@ function parseOmml(xml) {
19268
19817
  return ommlFromElement(parseXml(xml, { label: "OMML" }).documentElement);
19269
19818
  }
19270
19819
 
19820
+ exports.chart = chart_exports;
19271
19821
  exports.color = color_exports;
19272
19822
  exports.diagram = diagram_exports;
19273
19823
  exports.digest = digest_exports;
19274
19824
  exports.geometry = geometry_exports;
19275
19825
  exports.math = math_exports;
19276
19826
  exports.opc = opc_exports;
19827
+ exports.text = text_exports;
19277
19828
  exports.units = units_exports;
19278
19829
  exports.xml = xml_exports;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export * as color from './color/index.js';
2
+ export * as chart from './chart/index.js';
3
+ export * as text from './text/index.js';
2
4
  export * as diagram from './diagram/index.js';
3
5
  export * as digest from './digest/index.js';
4
6
  export * as geometry from './geometry/index.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC"}