@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,138 +1,138 @@
1
- import { isRecord } from './typeGuards';
2
-
3
- export const escapeAttr = (value: unknown): string =>
4
- String(value).replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
5
-
6
- export const escapeText = (value: unknown): string =>
7
- String(value).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
8
-
9
- export const getPathValue = (source: unknown, path: string): unknown => {
10
- const parts = path
11
- .split('.')
12
- .map((p) => p.trim())
13
- .filter(Boolean);
14
- let current: unknown = source;
15
- for (const part of parts) {
16
- if (!isRecord(current)) {
17
- return undefined;
18
- }
19
- current = current[part];
20
- }
21
- return current;
22
- };
23
-
24
- export const interpolate = (template: string, data: any, warnings?: string[]): string =>
25
- template.replace(/\{\{\s*([^}]+?)\s*\}\}/g, (match, path) => {
26
- const value = getPathValue(data, path);
27
- if (value === undefined || value === null) {
28
- if (warnings) {
29
- warnings.push(`Unresolved template variable '${path}' in "${template}".`);
30
- }
31
- return '';
32
- }
33
- if (typeof value === 'object') {
34
- if (warnings) {
35
- warnings.push(
36
- `Template variable '${path}' resolved to an object instead of a string in "${template}".`
37
- );
38
- }
39
- return '';
40
- }
41
- return String(value);
42
- });
43
-
44
- export const interpolateWithSources = (template: string, sources: any[]): string =>
45
- template.replace(/\{\{\s*([^}]+?)\s*\}\}/g, (_match, path) => {
46
- for (const source of sources) {
47
- const value = getPathValue(source, path);
48
- if (value !== undefined && value !== null && typeof value !== 'object') {
49
- return String(value);
50
- }
51
- }
52
- return '';
53
- });
54
-
55
- // colorFromString moved to utils.ts to avoid duplication
56
- // Import from utils.ts if needed: import { colorFromString } from './utils';
57
-
58
- /**
59
- * Resolve a short property path from an item's propertySets.
60
- *
61
- * Template paths use the format: SetName.propertyName
62
- * Example: "SetName.propName" resolves to item.propertySets.SetName.propName.value
63
- *
64
- * @param item - An object with propertySets structure
65
- * @param shortPath - Short path like "SetName.propName"
66
- * @returns The property value, or undefined if not found
67
- */
68
- export const resolveProperty = (item: unknown, shortPath: string): unknown => {
69
- if (!shortPath || !isRecord(item)) return undefined;
70
-
71
- const propertySets = (item as Record<string, unknown>).propertySets;
72
- if (!isRecord(propertySets)) return undefined;
73
-
74
- const parts = shortPath.split('.');
75
- if (parts.length < 2) return undefined;
76
-
77
- const [setName, ...propParts] = parts;
78
- const propName = propParts.join('.');
79
-
80
- const propSet = propertySets[setName];
81
- if (!isRecord(propSet)) return undefined;
82
-
83
- // New T8 API: T8PropertySet has .properties sub-record
84
- const innerProps = propSet['properties'];
85
- const prop = (isRecord(innerProps) ? innerProps[propName] : undefined) ?? propSet[propName];
86
-
87
- // Handle both wrapped {value} and raw values
88
- if (isRecord(prop) && 'value' in prop) {
89
- return prop.value;
90
- }
91
- return prop;
92
- };
93
-
94
- /**
95
- * Resolve a property value using either short or full path.
96
- * Short path: "SetName.propName" → resolves via propertySets
97
- * Full path: "propertySets.SetName.propName.value" → resolves via direct traversal
98
- * Also handles top-level properties like "color".
99
- */
100
- export const resolvePath = (obj: unknown, path: string): unknown => {
101
- if (path.startsWith('propertySets.')) {
102
- return getPathValue(obj, path);
103
- }
104
- const direct = getPathValue(obj, path);
105
- if (direct !== undefined) return direct;
106
- return resolveProperty(obj, path);
107
- };
108
-
109
- /**
110
- * Check if an item matches a filter condition using short property paths.
111
- *
112
- * @param item - An object with propertySets structure
113
- * @param filter - Filter with path (short format), equals, or in conditions
114
- * @returns true if item matches the filter
115
- */
116
- export const matchesPropertyFilter = (
117
- item: unknown,
118
- filter: { path?: string; equals?: unknown; in?: unknown[] } | undefined
119
- ): boolean => {
120
- if (!filter || !filter.path) return true;
121
-
122
- const value = resolveProperty(item, filter.path);
123
- const normalizedValue = typeof value === 'string' ? value.toLowerCase().trim() : value;
124
-
125
- if (filter.equals !== undefined) {
126
- const normalizedEquals = typeof filter.equals === 'string' ? filter.equals.toLowerCase().trim() : filter.equals;
127
- return normalizedValue === normalizedEquals;
128
- }
129
-
130
- if (Array.isArray(filter.in)) {
131
- return filter.in.some((v) => {
132
- const normalizedV = typeof v === 'string' ? v.toLowerCase().trim() : v;
133
- return normalizedValue === normalizedV;
134
- });
135
- }
136
-
137
- return true;
138
- };
1
+ import { isRecord } from './typeGuards';
2
+
3
+ export const escapeAttr = (value: unknown): string =>
4
+ String(value).replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
5
+
6
+ export const escapeText = (value: unknown): string =>
7
+ String(value).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
8
+
9
+ export const getPathValue = (source: unknown, path: string): unknown => {
10
+ const parts = path
11
+ .split('.')
12
+ .map((p) => p.trim())
13
+ .filter(Boolean);
14
+ let current: unknown = source;
15
+ for (const part of parts) {
16
+ if (!isRecord(current)) {
17
+ return undefined;
18
+ }
19
+ current = current[part];
20
+ }
21
+ return current;
22
+ };
23
+
24
+ export const interpolate = (template: string, data: any, warnings?: string[]): string =>
25
+ template.replace(/\{\{\s*([^}]+?)\s*\}\}/g, (match, path) => {
26
+ const value = getPathValue(data, path);
27
+ if (value === undefined || value === null) {
28
+ if (warnings) {
29
+ warnings.push(`Unresolved template variable '${path}' in "${template}".`);
30
+ }
31
+ return '';
32
+ }
33
+ if (typeof value === 'object') {
34
+ if (warnings) {
35
+ warnings.push(
36
+ `Template variable '${path}' resolved to an object instead of a string in "${template}".`
37
+ );
38
+ }
39
+ return '';
40
+ }
41
+ return String(value);
42
+ });
43
+
44
+ export const interpolateWithSources = (template: string, sources: any[]): string =>
45
+ template.replace(/\{\{\s*([^}]+?)\s*\}\}/g, (_match, path) => {
46
+ for (const source of sources) {
47
+ const value = getPathValue(source, path);
48
+ if (value !== undefined && value !== null && typeof value !== 'object') {
49
+ return String(value);
50
+ }
51
+ }
52
+ return '';
53
+ });
54
+
55
+ // colorFromString moved to utils.ts to avoid duplication
56
+ // Import from utils.ts if needed: import { colorFromString } from './utils';
57
+
58
+ /**
59
+ * Resolve a short property path from an item's propertySets.
60
+ *
61
+ * Template paths use the format: SetName.propertyName
62
+ * Example: "SetName.propName" resolves to item.propertySets.SetName.propName.value
63
+ *
64
+ * @param item - An object with propertySets structure
65
+ * @param shortPath - Short path like "SetName.propName"
66
+ * @returns The property value, or undefined if not found
67
+ */
68
+ export const resolveProperty = (item: unknown, shortPath: string): unknown => {
69
+ if (!shortPath || !isRecord(item)) return undefined;
70
+
71
+ const propertySets = (item as Record<string, unknown>).propertySets;
72
+ if (!isRecord(propertySets)) return undefined;
73
+
74
+ const parts = shortPath.split('.');
75
+ if (parts.length < 2) return undefined;
76
+
77
+ const [setName, ...propParts] = parts;
78
+ const propName = propParts.join('.');
79
+
80
+ const propSet = propertySets[setName];
81
+ if (!isRecord(propSet)) return undefined;
82
+
83
+ // New T8 API: T8PropertySet has .properties sub-record
84
+ const innerProps = propSet['properties'];
85
+ const prop = (isRecord(innerProps) ? innerProps[propName] : undefined) ?? propSet[propName];
86
+
87
+ // Handle both wrapped {value} and raw values
88
+ if (isRecord(prop) && 'value' in prop) {
89
+ return prop.value;
90
+ }
91
+ return prop;
92
+ };
93
+
94
+ /**
95
+ * Resolve a property value using either short or full path.
96
+ * Short path: "SetName.propName" → resolves via propertySets
97
+ * Full path: "propertySets.SetName.propName.value" → resolves via direct traversal
98
+ * Also handles top-level properties like "color".
99
+ */
100
+ export const resolvePath = (obj: unknown, path: string): unknown => {
101
+ if (path.startsWith('propertySets.')) {
102
+ return getPathValue(obj, path);
103
+ }
104
+ const direct = getPathValue(obj, path);
105
+ if (direct !== undefined) return direct;
106
+ return resolveProperty(obj, path);
107
+ };
108
+
109
+ /**
110
+ * Check if an item matches a filter condition using short property paths.
111
+ *
112
+ * @param item - An object with propertySets structure
113
+ * @param filter - Filter with path (short format), equals, or in conditions
114
+ * @returns true if item matches the filter
115
+ */
116
+ export const matchesPropertyFilter = (
117
+ item: unknown,
118
+ filter: { path?: string; equals?: unknown; in?: unknown[] } | undefined
119
+ ): boolean => {
120
+ if (!filter || !filter.path) return true;
121
+
122
+ const value = resolveProperty(item, filter.path);
123
+ const normalizedValue = typeof value === 'string' ? value.toLowerCase().trim() : value;
124
+
125
+ if (filter.equals !== undefined) {
126
+ const normalizedEquals = typeof filter.equals === 'string' ? filter.equals.toLowerCase().trim() : filter.equals;
127
+ return normalizedValue === normalizedEquals;
128
+ }
129
+
130
+ if (Array.isArray(filter.in)) {
131
+ return filter.in.some((v) => {
132
+ const normalizedV = typeof v === 'string' ? v.toLowerCase().trim() : v;
133
+ return normalizedValue === normalizedV;
134
+ });
135
+ }
136
+
137
+ return true;
138
+ };
@@ -1,2 +1,2 @@
1
- export { validateSectionState } from '@twinfinity/geometry';
2
- export type { SectionStateValidationResult } from '@twinfinity/geometry';
1
+ export { validateSectionState } from '@twinfinity/geometry';
2
+ export type { SectionStateValidationResult } from '@twinfinity/geometry';