@twinfinity/printing 6.0.1-ci.28952-beta → 6.0.2-beta

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 (82) hide show
  1. package/README.md +3 -3
  2. package/dist/BuildInfo.js +3 -3
  3. package/dist/BuildInfo.js.map +1 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/layout/analyzeTemplate.js.map +1 -1
  6. package/dist/layout/clipUtils.js.map +1 -1
  7. package/dist/layout/colorConstants.js.map +1 -1
  8. package/dist/layout/elementKinds.js.map +1 -1
  9. package/dist/layout/exportDrawing.js.map +1 -1
  10. package/dist/layout/filters.js.map +1 -1
  11. package/dist/layout/geometryConstants.js.map +1 -1
  12. package/dist/layout/index.js.map +1 -1
  13. package/dist/layout/itemBuilders.js.map +1 -1
  14. package/dist/layout/labelsRender.js.map +1 -1
  15. package/dist/layout/legendConstants.js.map +1 -1
  16. package/dist/layout/legendRender.js.map +1 -1
  17. package/dist/layout/legendRows.js.map +1 -1
  18. package/dist/layout/legendUtils.js.map +1 -1
  19. package/dist/layout/metadata.js.map +1 -1
  20. package/dist/layout/model.js.map +1 -1
  21. package/dist/layout/options.js.map +1 -1
  22. package/dist/layout/presets.js.map +1 -1
  23. package/dist/layout/qrRender.js.map +1 -1
  24. package/dist/layout/renderDrawing.js.map +1 -1
  25. package/dist/layout/renderUtils.js.map +1 -1
  26. package/dist/layout/sectionValidation.js.map +1 -1
  27. package/dist/layout/templateVariables.js.map +1 -1
  28. package/dist/layout/typeGuards.js.map +1 -1
  29. package/dist/layout/types.js.map +1 -1
  30. package/dist/layout/utils.js.map +1 -1
  31. package/dist/layout/validation.js.map +1 -1
  32. package/dist/layout/validationHelpers.js.map +1 -1
  33. package/dist/layout/validationUtils.js.map +1 -1
  34. package/dist/layout/viewportPrep.js.map +1 -1
  35. package/dist/layout/viewportRender.js.map +1 -1
  36. package/dist/layout/viewportUtils.js.map +1 -1
  37. package/dist/layout/warnings.js.map +1 -1
  38. package/dist/printToPdf.js.map +1 -1
  39. package/dist/printToSvg.js.map +1 -1
  40. package/dist/sections.js.map +1 -1
  41. package/dist/types.js.map +1 -1
  42. package/package.json +2 -2
  43. package/src/BuildInfo.ts +41 -41
  44. package/src/index.ts +10 -10
  45. package/src/layout/analyzeTemplate.ts +218 -218
  46. package/src/layout/clipUtils.ts +193 -193
  47. package/src/layout/colorConstants.ts +16 -16
  48. package/src/layout/elementKinds.ts +35 -35
  49. package/src/layout/exportDrawing.ts +206 -206
  50. package/src/layout/filters.ts +80 -80
  51. package/src/layout/geometryConstants.ts +11 -11
  52. package/src/layout/index.ts +671 -671
  53. package/src/layout/itemBuilders.ts +159 -159
  54. package/src/layout/labelsRender.ts +170 -170
  55. package/src/layout/legendConstants.ts +11 -11
  56. package/src/layout/legendRender.ts +543 -543
  57. package/src/layout/legendRows.ts +62 -62
  58. package/src/layout/legendUtils.ts +144 -144
  59. package/src/layout/metadata.ts +210 -210
  60. package/src/layout/model.ts +372 -372
  61. package/src/layout/options.ts +17 -17
  62. package/src/layout/presets.ts +51 -51
  63. package/src/layout/qrRender.ts +126 -126
  64. package/src/layout/qrcode.d.ts +2 -2
  65. package/src/layout/renderDrawing.ts +710 -710
  66. package/src/layout/renderUtils.ts +138 -138
  67. package/src/layout/sectionValidation.ts +2 -2
  68. package/src/layout/templateVariables.ts +317 -317
  69. package/src/layout/typeGuards.ts +9 -9
  70. package/src/layout/types.ts +835 -835
  71. package/src/layout/utils.ts +85 -85
  72. package/src/layout/validation.ts +392 -392
  73. package/src/layout/validationHelpers.ts +59 -59
  74. package/src/layout/validationUtils.ts +6 -6
  75. package/src/layout/viewportPrep.ts +351 -351
  76. package/src/layout/viewportRender.ts +442 -442
  77. package/src/layout/viewportUtils.ts +50 -50
  78. package/src/layout/warnings.ts +3 -3
  79. package/src/printToPdf.ts +108 -108
  80. package/src/printToSvg.ts +188 -188
  81. package/src/sections.ts +1019 -1019
  82. package/src/types.ts +49 -49
@@ -1,85 +1,85 @@
1
- import type { SectionPath } from '@twinfinity/geometry';
2
- import { RGB_MAX } from './colorConstants';
3
-
4
- export const uniquePositiveDenoms = (input?: readonly number[]): number[] => {
5
- const values = Array.isArray(input) && input.length ? input : [];
6
- const seen = new Set<number>();
7
- const filtered: number[] = [];
8
- values.forEach((d) => {
9
- if (typeof d === 'number' && Number.isFinite(d) && d > 0 && !seen.has(d)) {
10
- seen.add(d);
11
- filtered.push(d);
12
- }
13
- });
14
- return filtered.sort((a, b) => a - b);
15
- };
16
-
17
- export const computeLabelFontSize = (templateFontSize: number, sectionScale: number): number => {
18
- const base = typeof templateFontSize === 'number' && Number.isFinite(templateFontSize) ? templateFontSize : 5;
19
- if (!Number.isFinite(sectionScale) || sectionScale <= 0) return base;
20
- return base / sectionScale;
21
- };
22
-
23
- export const colorFromString = (value: string): [number, number, number, number] => {
24
- let hash = 0;
25
- for (let i = 0; i < value.length; i++) {
26
- hash = (hash << 5) - hash + value.charCodeAt(i);
27
- hash |= 0;
28
- }
29
- const hue = Math.abs(hash) % 360;
30
- const sat = 60;
31
- const light = 65;
32
- const c = (1 - Math.abs((2 * light) / 100 - 1)) * (sat / 100);
33
- const x = c * (1 - Math.abs(((hue / 60) % 2) - 1));
34
- const m = light / 100 - c / 2;
35
- let r = 0;
36
- let g = 0;
37
- let b = 0;
38
- if (hue < 60) {
39
- r = c;
40
- g = x;
41
- } else if (hue < 120) {
42
- r = x;
43
- g = c;
44
- } else if (hue < 180) {
45
- g = c;
46
- b = x;
47
- } else if (hue < 240) {
48
- g = x;
49
- b = c;
50
- } else if (hue < 300) {
51
- r = x;
52
- b = c;
53
- } else {
54
- r = c;
55
- b = x;
56
- }
57
- return [Math.round((r + m) * RGB_MAX), Math.round((g + m) * RGB_MAX), Math.round((b + m) * RGB_MAX), RGB_MAX];
58
- };
59
-
60
- export const applyLineStyleToPaths = (
61
- paths: SectionPath[],
62
- style: { stroke?: string; strokeWidth?: number }
63
- ): SectionPath[] => {
64
- if (!Array.isArray(paths) || !paths.length) {
65
- return paths ?? [];
66
- }
67
- const stroke = typeof style.stroke === 'string' && style.stroke.trim().length ? style.stroke.trim() : undefined;
68
- const strokeWidth = typeof style.strokeWidth === 'number' ? style.strokeWidth : undefined;
69
- if (!stroke && strokeWidth === undefined) {
70
- return paths;
71
- }
72
- return paths.map((path) => {
73
- if (!path || !path.stroke || path.stroke === 'none') {
74
- return path;
75
- }
76
- const next: SectionPath = { ...path };
77
- if (stroke) {
78
- next.stroke = stroke;
79
- }
80
- if (strokeWidth !== undefined) {
81
- next.strokeWidth = strokeWidth;
82
- }
83
- return next;
84
- });
85
- };
1
+ import type { SectionPath } from '@twinfinity/geometry';
2
+ import { RGB_MAX } from './colorConstants';
3
+
4
+ export const uniquePositiveDenoms = (input?: readonly number[]): number[] => {
5
+ const values = Array.isArray(input) && input.length ? input : [];
6
+ const seen = new Set<number>();
7
+ const filtered: number[] = [];
8
+ values.forEach((d) => {
9
+ if (typeof d === 'number' && Number.isFinite(d) && d > 0 && !seen.has(d)) {
10
+ seen.add(d);
11
+ filtered.push(d);
12
+ }
13
+ });
14
+ return filtered.sort((a, b) => a - b);
15
+ };
16
+
17
+ export const computeLabelFontSize = (templateFontSize: number, sectionScale: number): number => {
18
+ const base = typeof templateFontSize === 'number' && Number.isFinite(templateFontSize) ? templateFontSize : 5;
19
+ if (!Number.isFinite(sectionScale) || sectionScale <= 0) return base;
20
+ return base / sectionScale;
21
+ };
22
+
23
+ export const colorFromString = (value: string): [number, number, number, number] => {
24
+ let hash = 0;
25
+ for (let i = 0; i < value.length; i++) {
26
+ hash = (hash << 5) - hash + value.charCodeAt(i);
27
+ hash |= 0;
28
+ }
29
+ const hue = Math.abs(hash) % 360;
30
+ const sat = 60;
31
+ const light = 65;
32
+ const c = (1 - Math.abs((2 * light) / 100 - 1)) * (sat / 100);
33
+ const x = c * (1 - Math.abs(((hue / 60) % 2) - 1));
34
+ const m = light / 100 - c / 2;
35
+ let r = 0;
36
+ let g = 0;
37
+ let b = 0;
38
+ if (hue < 60) {
39
+ r = c;
40
+ g = x;
41
+ } else if (hue < 120) {
42
+ r = x;
43
+ g = c;
44
+ } else if (hue < 180) {
45
+ g = c;
46
+ b = x;
47
+ } else if (hue < 240) {
48
+ g = x;
49
+ b = c;
50
+ } else if (hue < 300) {
51
+ r = x;
52
+ b = c;
53
+ } else {
54
+ r = c;
55
+ b = x;
56
+ }
57
+ return [Math.round((r + m) * RGB_MAX), Math.round((g + m) * RGB_MAX), Math.round((b + m) * RGB_MAX), RGB_MAX];
58
+ };
59
+
60
+ export const applyLineStyleToPaths = (
61
+ paths: SectionPath[],
62
+ style: { stroke?: string; strokeWidth?: number }
63
+ ): SectionPath[] => {
64
+ if (!Array.isArray(paths) || !paths.length) {
65
+ return paths ?? [];
66
+ }
67
+ const stroke = typeof style.stroke === 'string' && style.stroke.trim().length ? style.stroke.trim() : undefined;
68
+ const strokeWidth = typeof style.strokeWidth === 'number' ? style.strokeWidth : undefined;
69
+ if (!stroke && strokeWidth === undefined) {
70
+ return paths;
71
+ }
72
+ return paths.map((path) => {
73
+ if (!path || !path.stroke || path.stroke === 'none') {
74
+ return path;
75
+ }
76
+ const next: SectionPath = { ...path };
77
+ if (stroke) {
78
+ next.stroke = stroke;
79
+ }
80
+ if (strokeWidth !== undefined) {
81
+ next.strokeWidth = strokeWidth;
82
+ }
83
+ return next;
84
+ });
85
+ };