@twinfinity/printing 6.1.1-beta → 6.1.2-ci.30738-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.
- package/dist/BuildInfo.js +3 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/layout/analyzeTemplate.d.ts +4 -4
- package/dist/layout/analyzeTemplate.d.ts.map +1 -1
- package/dist/layout/analyzeTemplate.js +18 -16
- package/dist/layout/analyzeTemplate.js.map +1 -1
- package/dist/layout/classClosure.d.ts +41 -0
- package/dist/layout/classClosure.d.ts.map +1 -0
- package/dist/layout/classClosure.js +143 -0
- package/dist/layout/classClosure.js.map +1 -0
- package/dist/layout/clipUtils.d.ts +11 -0
- package/dist/layout/clipUtils.d.ts.map +1 -1
- package/dist/layout/clipUtils.js +67 -6
- package/dist/layout/clipUtils.js.map +1 -1
- package/dist/layout/filters.d.ts +14 -8
- package/dist/layout/filters.d.ts.map +1 -1
- package/dist/layout/filters.js +28 -3
- package/dist/layout/filters.js.map +1 -1
- package/dist/layout/index.d.ts +24 -57
- package/dist/layout/index.d.ts.map +1 -1
- package/dist/layout/index.js +20 -337
- package/dist/layout/index.js.map +1 -1
- package/dist/layout/itemBuilders.d.ts +11 -0
- package/dist/layout/itemBuilders.d.ts.map +1 -1
- package/dist/layout/itemBuilders.js +17 -3
- package/dist/layout/itemBuilders.js.map +1 -1
- package/dist/layout/labelsRender.d.ts.map +1 -1
- package/dist/layout/labelsRender.js +15 -27
- package/dist/layout/labelsRender.js.map +1 -1
- package/dist/layout/legendRender.d.ts +18 -6
- package/dist/layout/legendRender.d.ts.map +1 -1
- package/dist/layout/legendRender.js +49 -79
- package/dist/layout/legendRender.js.map +1 -1
- package/dist/layout/metadata.d.ts.map +1 -1
- package/dist/layout/metadata.js +26 -5
- package/dist/layout/metadata.js.map +1 -1
- package/dist/layout/model.d.ts +4 -3
- package/dist/layout/model.d.ts.map +1 -1
- package/dist/layout/model.js +17 -57
- package/dist/layout/model.js.map +1 -1
- package/dist/layout/options.d.ts +1 -2
- package/dist/layout/options.d.ts.map +1 -1
- package/dist/layout/options.js.map +1 -1
- package/dist/layout/preflight.d.ts +32 -0
- package/dist/layout/preflight.d.ts.map +1 -0
- package/dist/layout/preflight.js +69 -0
- package/dist/layout/preflight.js.map +1 -0
- package/dist/layout/qrRender.d.ts.map +1 -1
- package/dist/layout/qrRender.js +11 -10
- package/dist/layout/qrRender.js.map +1 -1
- package/dist/layout/renderDrawing.d.ts +28 -17
- package/dist/layout/renderDrawing.d.ts.map +1 -1
- package/dist/layout/renderDrawing.js +107 -88
- package/dist/layout/renderDrawing.js.map +1 -1
- package/dist/layout/renderLayout.d.ts +25 -0
- package/dist/layout/renderLayout.d.ts.map +1 -0
- package/dist/layout/renderLayout.js +315 -0
- package/dist/layout/renderLayout.js.map +1 -0
- package/dist/layout/renderTemplateSheet.d.ts +99 -0
- package/dist/layout/renderTemplateSheet.d.ts.map +1 -0
- package/dist/layout/renderTemplateSheet.js +296 -0
- package/dist/layout/renderTemplateSheet.js.map +1 -0
- package/dist/layout/renderUtils.d.ts +19 -0
- package/dist/layout/renderUtils.d.ts.map +1 -1
- package/dist/layout/renderUtils.js +47 -4
- package/dist/layout/renderUtils.js.map +1 -1
- package/dist/layout/sectionDefs.d.ts +65 -0
- package/dist/layout/sectionDefs.d.ts.map +1 -0
- package/dist/layout/sectionDefs.js +88 -0
- package/dist/layout/sectionDefs.js.map +1 -0
- package/dist/layout/slabModelView.d.ts +34 -0
- package/dist/layout/slabModelView.d.ts.map +1 -0
- package/dist/layout/slabModelView.js +175 -0
- package/dist/layout/slabModelView.js.map +1 -0
- package/dist/layout/templateVariables.d.ts +1 -1
- package/dist/layout/templateVariables.d.ts.map +1 -1
- package/dist/layout/templateVariables.js +21 -9
- package/dist/layout/templateVariables.js.map +1 -1
- package/dist/layout/types.d.ts +164 -83
- package/dist/layout/types.d.ts.map +1 -1
- package/dist/layout/types.js.map +1 -1
- package/dist/layout/validation.d.ts.map +1 -1
- package/dist/layout/validation.js +78 -33
- package/dist/layout/validation.js.map +1 -1
- package/dist/layout/viewportPrep.d.ts +8 -6
- package/dist/layout/viewportPrep.d.ts.map +1 -1
- package/dist/layout/viewportPrep.js +35 -23
- package/dist/layout/viewportPrep.js.map +1 -1
- package/dist/layout/viewportRender.d.ts +9 -7
- package/dist/layout/viewportRender.d.ts.map +1 -1
- package/dist/layout/viewportRender.js +93 -126
- package/dist/layout/viewportRender.js.map +1 -1
- package/dist/layout/viewportUtils.d.ts +20 -0
- package/dist/layout/viewportUtils.d.ts.map +1 -1
- package/dist/layout/viewportUtils.js +107 -4
- package/dist/layout/viewportUtils.js.map +1 -1
- package/dist/printToPdf.d.ts +7 -1
- package/dist/printToPdf.d.ts.map +1 -1
- package/dist/printToPdf.js +81 -14
- package/dist/printToPdf.js.map +1 -1
- package/dist/printToSvg.d.ts.map +1 -1
- package/dist/printToSvg.js +7 -3
- package/dist/printToSvg.js.map +1 -1
- package/dist/schemaUtils.d.ts +9 -0
- package/dist/schemaUtils.d.ts.map +1 -0
- package/dist/schemaUtils.js +14 -0
- package/dist/schemaUtils.js.map +1 -0
- package/dist/templates/default-template.json +30 -8
- package/dist/types.d.ts +2 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +10 -1
- package/dist/types.js.map +1 -1
- package/package.json +8 -3
- package/src/index.ts +4 -0
- package/src/layout/analyzeTemplate.ts +21 -19
- package/src/layout/classClosure.ts +142 -0
- package/src/layout/clipUtils.ts +65 -6
- package/src/layout/filters.ts +31 -3
- package/src/layout/index.ts +61 -571
- package/src/layout/itemBuilders.ts +20 -5
- package/src/layout/labelsRender.ts +23 -40
- package/src/layout/legendRender.ts +64 -84
- package/src/layout/metadata.ts +26 -5
- package/src/layout/model.ts +21 -66
- package/src/layout/options.ts +1 -2
- package/src/layout/preflight.ts +96 -0
- package/src/layout/qrRender.ts +11 -10
- package/src/layout/renderDrawing.ts +132 -110
- package/src/layout/renderLayout.ts +483 -0
- package/src/layout/renderTemplateSheet.ts +435 -0
- package/src/layout/renderUtils.ts +53 -4
- package/src/layout/sectionDefs.ts +131 -0
- package/src/layout/slabModelView.ts +196 -0
- package/src/layout/templateVariables.ts +25 -9
- package/src/layout/types.ts +160 -70
- package/src/layout/validation.ts +98 -32
- package/src/layout/viewportPrep.ts +47 -29
- package/src/layout/viewportRender.ts +114 -141
- package/src/layout/viewportUtils.ts +118 -5
- package/src/printToPdf.ts +84 -15
- package/src/printToSvg.ts +7 -3
- package/src/schemaUtils.ts +13 -0
- package/src/templates/default-template.json +30 -8
- package/src/types.ts +12 -2
- package/templates/default-a0-landscape.json +171 -66
- package/templates/default-a0-portrait.json +159 -60
- package/templates/default-a1-landscape.json +135 -48
- package/templates/default-a1-portrait.json +123 -42
- package/templates/default-a3-landscape.json +87 -24
- package/templates/default-a3-portrait.json +99 -30
- package/templates/default-a4-landscape.json +75 -18
- package/templates/default-a4-portrait.json +75 -18
- package/templates/llm-authoring-guide.md +247 -0
- package/templates/template-schema.json +295 -120
package/src/layout/index.ts
CHANGED
|
@@ -1,154 +1,11 @@
|
|
|
1
|
-
import type { SectionRenderState } from '@twinfinity/geometry';
|
|
2
1
|
import defaultTemplateJson from '../templates/default-template.json';
|
|
3
|
-
import {
|
|
4
|
-
pointInPolygon,
|
|
5
|
-
filterItemsInPolygons,
|
|
6
|
-
filterEntriesByClip,
|
|
7
|
-
offsetPolygons,
|
|
8
|
-
projectPolygonsToLocal
|
|
9
|
-
} from './clipUtils';
|
|
10
|
-
import { uniquePositiveDenoms } from './utils';
|
|
11
|
-
import { validateLayoutTemplate as validateLayoutTemplateExternal } from './validation';
|
|
12
|
-
import { renderViewportElement } from './viewportRender';
|
|
13
|
-
import { prepareViewports } from './viewportPrep';
|
|
14
|
-
import { renderLabels, ViewportRenderInfo } from './labelsRender';
|
|
15
|
-
import { renderQrElements } from './qrRender';
|
|
16
|
-
import { applyLegendFilter, buildLegendGroup } from './legendRender';
|
|
17
|
-
import { RenderLayoutOptions } from './options';
|
|
18
|
-
import { resolvePresets } from './presets';
|
|
19
|
-
import { pushWarning } from './warnings';
|
|
20
|
-
import { escapeAttr, escapeText, interpolate, getPathValue } from './renderUtils';
|
|
21
|
-
import { validateSectionState } from './sectionValidation';
|
|
22
|
-
import {
|
|
23
|
-
ELEMENT_KIND_VIEWPORT,
|
|
24
|
-
ELEMENT_KIND_TEXT,
|
|
25
|
-
ELEMENT_KIND_IMAGE,
|
|
26
|
-
ELEMENT_KIND_LINE,
|
|
27
|
-
ELEMENT_KIND_RECT,
|
|
28
|
-
ELEMENT_KIND_CIRCLE,
|
|
29
|
-
ELEMENT_KIND_POLYLINE,
|
|
30
|
-
ELEMENT_KIND_POLYGON,
|
|
31
|
-
ELEMENT_KIND_SCALE_BAR,
|
|
32
|
-
ELEMENT_KIND_QR,
|
|
33
|
-
ELEMENT_KIND_LABELS,
|
|
34
|
-
ELEMENT_KIND_LEGEND,
|
|
35
|
-
ELEMENT_KIND_GROUP
|
|
36
|
-
} from './elementKinds';
|
|
37
|
-
import {
|
|
38
|
-
AssetSpec,
|
|
39
|
-
LayoutElement,
|
|
40
|
-
ViewportElement,
|
|
41
|
-
TextElement,
|
|
42
|
-
ImageElement,
|
|
43
|
-
LineElement,
|
|
44
|
-
RectElement,
|
|
45
|
-
CircleElement,
|
|
46
|
-
PolylineElement,
|
|
47
|
-
PolygonElement,
|
|
48
|
-
ScaleBarElement,
|
|
49
|
-
QrElement,
|
|
50
|
-
LabelsElement,
|
|
51
|
-
LegendElement,
|
|
52
|
-
GroupElement,
|
|
53
|
-
LayoutTemplate,
|
|
54
|
-
ModelContext,
|
|
55
|
-
LayoutData,
|
|
56
|
-
ValidationIssue,
|
|
57
|
-
ComputedViewportScale
|
|
58
|
-
} from './types';
|
|
59
|
-
|
|
60
|
-
export type LayoutDataValidationResult =
|
|
61
|
-
| { ok: true }
|
|
62
|
-
| {
|
|
63
|
-
ok: false;
|
|
64
|
-
errors: string[];
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export type PreflightResult =
|
|
68
|
-
| { ok: true }
|
|
69
|
-
| {
|
|
70
|
-
ok: false;
|
|
71
|
-
templateErrors?: ValidationIssue[];
|
|
72
|
-
dataErrors?: string[];
|
|
73
|
-
sectionErrors?: string[];
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
import { isRecord, getProp } from './typeGuards';
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Validate template, layout data, and section state in a single call.
|
|
80
|
-
* Combines `validateLayoutTemplate`, `validateLayoutData`, and `validateSectionState`.
|
|
81
|
-
*/
|
|
82
|
-
export const preflight = (
|
|
83
|
-
template: LayoutTemplate,
|
|
84
|
-
data: unknown,
|
|
85
|
-
expectedViewportIds: string[],
|
|
86
|
-
sectionState?: SectionRenderState
|
|
87
|
-
): PreflightResult => {
|
|
88
|
-
const templateValidation = validateLayoutTemplate(template);
|
|
89
|
-
const dataValidation = validateLayoutData(data, expectedViewportIds);
|
|
90
|
-
const sectionValidation = sectionState ? validateSectionState(sectionState) : { ok: true as const };
|
|
91
|
-
|
|
92
|
-
const ok = templateValidation.ok && dataValidation.ok && sectionValidation.ok;
|
|
93
|
-
if (ok) return { ok: true };
|
|
94
|
-
|
|
95
|
-
return {
|
|
96
|
-
ok: false,
|
|
97
|
-
templateErrors: templateValidation.ok ? undefined : templateValidation.errors,
|
|
98
|
-
dataErrors: dataValidation.ok ? undefined : dataValidation.errors,
|
|
99
|
-
sectionErrors: sectionValidation.ok ? undefined : sectionValidation.errors
|
|
100
|
-
};
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Validate layout data before rendering to catch missing propertySets or items arrays.
|
|
105
|
-
*/
|
|
106
|
-
export const validateLayoutData = (data: unknown, expectedViewportIds: string[]): LayoutDataValidationResult => {
|
|
107
|
-
const errors: string[] = [];
|
|
108
|
-
if (!isRecord(data)) {
|
|
109
|
-
return { ok: false, errors: ['layout data must be an object'] };
|
|
110
|
-
}
|
|
111
|
-
expectedViewportIds.forEach((vpId) => {
|
|
112
|
-
const viewports = getProp(data, 'viewports');
|
|
113
|
-
const viewport = isRecord(viewports) ? getProp(viewports, vpId) : undefined;
|
|
114
|
-
const items = getProp(viewport, 'items');
|
|
115
|
-
if (!Array.isArray(items)) {
|
|
116
|
-
errors.push(`viewports.${vpId}.items is required and must be an array.`);
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
items.forEach((it: unknown, idx: number) => {
|
|
120
|
-
if (!isRecord(it)) {
|
|
121
|
-
errors.push(`viewports.${vpId}.items[${idx}] must be an object.`);
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
const sets = getProp(it, 'propertySets');
|
|
125
|
-
if (!isRecord(sets)) {
|
|
126
|
-
errors.push(`viewports.${vpId}.items[${idx}] is missing propertySets.<Set>.<Prop>.value.`);
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
Object.entries(sets).forEach(([setName, props]) => {
|
|
130
|
-
if (!isRecord(props)) {
|
|
131
|
-
errors.push(`viewports.${vpId}.items[${idx}].propertySets.${setName} must be an object.`);
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
Object.entries(props).forEach(([propName, payload]) => {
|
|
135
|
-
if (!isRecord(payload) || !('value' in payload)) {
|
|
136
|
-
errors.push(
|
|
137
|
-
`viewports.${vpId}.items[${idx}].propertySets.${setName}.${propName} must include a value (propertySets.<Set>.<Prop>.value).`
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
return errors.length ? { ok: false, errors } : { ok: true };
|
|
145
|
-
};
|
|
2
|
+
import type { LayoutTemplate } from './types';
|
|
146
3
|
|
|
147
4
|
export type {
|
|
148
5
|
PageSpec,
|
|
149
6
|
TextStyle,
|
|
150
7
|
StyleMap,
|
|
151
|
-
|
|
8
|
+
ResourceSpec,
|
|
152
9
|
LayoutElement,
|
|
153
10
|
BaseElement,
|
|
154
11
|
ViewportElement,
|
|
@@ -164,6 +21,7 @@ export type {
|
|
|
164
21
|
QrElement,
|
|
165
22
|
LabelsElement,
|
|
166
23
|
LegendElement,
|
|
24
|
+
LegendLineStyle,
|
|
167
25
|
GroupElement,
|
|
168
26
|
LayoutTemplate,
|
|
169
27
|
LegendAnchor,
|
|
@@ -183,10 +41,12 @@ export type {
|
|
|
183
41
|
SectionStateValidationResult,
|
|
184
42
|
LabelStyle,
|
|
185
43
|
WhereCondition,
|
|
44
|
+
VariableBinding,
|
|
186
45
|
ClipConfig,
|
|
187
46
|
HighlightConfig,
|
|
188
47
|
ViewportLineStyle,
|
|
189
48
|
ViewportLineStyles,
|
|
49
|
+
ViewportStairArrowOptions,
|
|
190
50
|
SectionResult,
|
|
191
51
|
FillRule,
|
|
192
52
|
RenderDrawingInput,
|
|
@@ -199,13 +59,48 @@ export type {
|
|
|
199
59
|
|
|
200
60
|
export type { RenderLayoutOptions } from './options';
|
|
201
61
|
|
|
202
|
-
|
|
62
|
+
/**
|
|
63
|
+
* High-level facade: renders a complete drawing from a template + section
|
|
64
|
+
* geometry or pre-built models. Start here.
|
|
65
|
+
*/
|
|
66
|
+
export {
|
|
67
|
+
renderDrawing,
|
|
68
|
+
resolveFillColor,
|
|
69
|
+
BUILTIN_LINE_DEFAULTS,
|
|
70
|
+
BUILTIN_HIDDEN_DEFAULTS,
|
|
71
|
+
BUILTIN_LABEL_DEFAULTS,
|
|
72
|
+
CATEGORY_BUILTIN_OVERRIDES
|
|
73
|
+
} from './renderDrawing';
|
|
74
|
+
export type { ResolvedLineStyles } from './renderDrawing';
|
|
75
|
+
|
|
76
|
+
/** Low-level template renderer (prefer {@link renderDrawing}). */
|
|
77
|
+
export { renderLayout, type RenderLayoutResult } from './renderLayout';
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Full orchestration: products + template → rendered sheet. Resolves each
|
|
81
|
+
* viewport's section definition, computes SlabSection/plane sections with a
|
|
82
|
+
* def-keyed cache, and renders. The one-call path for template consumers.
|
|
83
|
+
*/
|
|
84
|
+
export {
|
|
85
|
+
renderTemplateSheet,
|
|
86
|
+
SectionCache,
|
|
87
|
+
type RenderTemplateSheetInput,
|
|
88
|
+
type RenderedTemplateSheet,
|
|
89
|
+
type ComputedSection
|
|
90
|
+
} from './renderTemplateSheet';
|
|
91
|
+
|
|
92
|
+
/** Pre-render validation: template + layout data + section state in one call. */
|
|
93
|
+
export { preflight, validateLayoutData, type PreflightResult, type LayoutDataValidationResult } from './preflight';
|
|
94
|
+
/** Validate a layout template JSON structure. Returns `{ ok } | { ok: false, errors }`. */
|
|
95
|
+
export { validateLayoutTemplate } from './validation';
|
|
96
|
+
/** @deprecated Use {@link validateLayoutTemplate} — same function, historical alias. */
|
|
97
|
+
export { validateLayoutTemplate as validateLayoutTemplateExternal } from './validation';
|
|
203
98
|
|
|
204
|
-
export { pointInPolygon, filterItemsInPolygons, filterEntriesByClip, offsetPolygons, projectPolygonsToLocal };
|
|
205
99
|
/** Normalize IFC class names to lowercase for consistent matching. */
|
|
206
100
|
export { normalizeClass } from './filters';
|
|
207
101
|
/** Test whether an item matches a class + where filter (used by clip, highlight, labels, legend). */
|
|
208
|
-
export { matchesV2Filter } from './filters';
|
|
102
|
+
export { matchesFilter, matchesV2Filter } from './filters';
|
|
103
|
+
|
|
209
104
|
/** Metadata utilities: build lookup maps, resolve IFC class includes, and merge metadata sources. */
|
|
210
105
|
export {
|
|
211
106
|
buildMetadataMap,
|
|
@@ -216,34 +111,34 @@ export {
|
|
|
216
111
|
resolveAllowedClasses,
|
|
217
112
|
resolveMeta
|
|
218
113
|
} from './metadata';
|
|
219
|
-
|
|
220
|
-
export { validateLayoutTemplate as validateLayoutTemplateExternal } from './validation';
|
|
114
|
+
|
|
221
115
|
/** Layout utility functions: scale denominators, label sizing, color parsing, and line style application. */
|
|
222
116
|
export { uniquePositiveDenoms, computeLabelFontSize, colorFromString, applyLineStyleToPaths } from './utils';
|
|
117
|
+
|
|
118
|
+
/** SlabSection → SvgModelView adapter (per-product rawPaths for gid features) + productEntries builder. */
|
|
119
|
+
export { slabSectionToModelView, slabPerProductToEntries, type SlabPerProductEntry } from './slabModelView';
|
|
120
|
+
|
|
121
|
+
/** The template format's per-viewport section contract: one reader/writer for cutHeight/planeNormal/planePosition/depth. */
|
|
122
|
+
export {
|
|
123
|
+
resolveViewportSection,
|
|
124
|
+
writeViewportSection,
|
|
125
|
+
sectionDefKey,
|
|
126
|
+
isVariableBinding,
|
|
127
|
+
sectionUsesVariables,
|
|
128
|
+
DEFAULT_SECTION_DEPTH,
|
|
129
|
+
type ResolvedSectionDef,
|
|
130
|
+
type SectionDefaults
|
|
131
|
+
} from './sectionDefs';
|
|
132
|
+
|
|
223
133
|
/** Property resolution: traverse nested objects with dot-path strings like `"BIP.spacename"`. */
|
|
224
134
|
export { getPathValue, resolveProperty, resolvePath, matchesPropertyFilter } from './renderUtils';
|
|
225
135
|
|
|
226
|
-
const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
227
|
-
|
|
228
136
|
/** Build legend table rows from product items with property formatting. */
|
|
229
137
|
export { buildLegendRows, type LegendRow, type LegendRowOptions } from './legendRows';
|
|
138
|
+
|
|
230
139
|
/** Product normalization, viewport item builders, and section-state-to-SVG-model conversion. */
|
|
231
140
|
export type { ProductLike, BuildViewportItemsOptions } from './itemBuilders';
|
|
232
141
|
export { normalizeProductEntry, buildViewportItems, sectionStateToModelView } from './itemBuilders';
|
|
233
|
-
/**
|
|
234
|
-
* High-level facade: renders a complete drawing from a template + section geometry.
|
|
235
|
-
* Internalizes all data wiring (items, colors, labels, metadata) that `renderLayout` requires manually.
|
|
236
|
-
*/
|
|
237
|
-
export {
|
|
238
|
-
renderDrawing,
|
|
239
|
-
resolveFillColor,
|
|
240
|
-
BUILTIN_LINE_DEFAULTS,
|
|
241
|
-
BUILTIN_HIDDEN_DEFAULTS,
|
|
242
|
-
BUILTIN_LABEL_DEFAULTS,
|
|
243
|
-
CATEGORY_BUILTIN_OVERRIDES,
|
|
244
|
-
setRenderLayoutBinding
|
|
245
|
-
} from './renderDrawing';
|
|
246
|
-
export type { ResolvedLineStyles } from './renderDrawing';
|
|
247
142
|
|
|
248
143
|
export { EXAMPLE_BUILDING_CLASSES } from './presets';
|
|
249
144
|
|
|
@@ -262,410 +157,5 @@ export {
|
|
|
262
157
|
applyTemplateVariables
|
|
263
158
|
} from './templateVariables';
|
|
264
159
|
|
|
265
|
-
/** Result of {@link renderLayout}: the final SVG markup, per-viewport scale info, and any warnings. */
|
|
266
|
-
export interface RenderLayoutResult {
|
|
267
|
-
/** Complete SVG markup string ready for embedding or PDF conversion. */
|
|
268
|
-
svg: string;
|
|
269
|
-
/** Per-viewport computed scale information (denominator, mm-per-model-unit, fit status). */
|
|
270
|
-
viewportScales: Record<string, ComputedViewportScale>;
|
|
271
|
-
/** Non-fatal issues encountered during rendering (missing assets, unresolved styles, etc.). */
|
|
272
|
-
warnings: string[];
|
|
273
|
-
}
|
|
274
|
-
|
|
275
160
|
/** Built-in default layout template (A3 landscape with a single viewport). */
|
|
276
161
|
export const DEFAULT_LAYOUT_TEMPLATE = defaultTemplateJson as LayoutTemplate;
|
|
277
|
-
|
|
278
|
-
const dashArray = (dashed?: boolean): string => (dashed ? ' stroke-dasharray="4 2"' : '');
|
|
279
|
-
|
|
280
|
-
const formatNumber = (value: number): number => {
|
|
281
|
-
if (!Number.isFinite(value)) return 0;
|
|
282
|
-
return Number.parseFloat(value.toFixed(3));
|
|
283
|
-
};
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* Render a layout template to SVG.
|
|
287
|
-
*
|
|
288
|
-
* This is the low-level rendering function. For most use cases, prefer {@link renderDrawing}
|
|
289
|
-
* which handles all data wiring automatically.
|
|
290
|
-
*
|
|
291
|
-
* @param template - Validated layout template (page, elements, styles, presets).
|
|
292
|
-
* @param data - Layout data with viewport items, template variables, and legend rows.
|
|
293
|
-
* @param models - Per-viewport SVG model views (geometry + transforms).
|
|
294
|
-
* @param options - Optional rendering settings (remote assets, scale overrides, metadata).
|
|
295
|
-
* @returns SVG markup string, computed viewport scales, and any warnings.
|
|
296
|
-
*/
|
|
297
|
-
export async function renderLayout(
|
|
298
|
-
template: LayoutTemplate,
|
|
299
|
-
data: LayoutData,
|
|
300
|
-
models: ModelContext,
|
|
301
|
-
options?: RenderLayoutOptions
|
|
302
|
-
): Promise<RenderLayoutResult> {
|
|
303
|
-
const presets = resolvePresets(template?.presets);
|
|
304
|
-
|
|
305
|
-
const validation = validateLayoutTemplate(template, {
|
|
306
|
-
allowRemoteAssets: options?.allowRemoteAssets,
|
|
307
|
-
allowDataUrls: options?.allowDataUrls,
|
|
308
|
-
maxViewports: options?.maxViewports
|
|
309
|
-
});
|
|
310
|
-
if (!validation.ok) {
|
|
311
|
-
throw new Error(
|
|
312
|
-
`Template validation failed: ${validation.errors.map((e: ValidationIssue) => `${e.path}: ${e.message}`).join('; ')}`
|
|
313
|
-
);
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
const preferredScales = uniquePositiveDenoms(options?.scaleDenominators);
|
|
317
|
-
const page = template.page;
|
|
318
|
-
const warnings: string[] = [];
|
|
319
|
-
|
|
320
|
-
// Flatten all elements to collect viewports, qrs, labels, legends regardless of grouping
|
|
321
|
-
const allElements: LayoutElement[] = [];
|
|
322
|
-
const collectElements = (elements: LayoutElement[]): void => {
|
|
323
|
-
elements.forEach((el) => {
|
|
324
|
-
allElements.push(el);
|
|
325
|
-
if (el.kind === ELEMENT_KIND_GROUP) {
|
|
326
|
-
collectElements((el as GroupElement).children);
|
|
327
|
-
}
|
|
328
|
-
});
|
|
329
|
-
};
|
|
330
|
-
collectElements(template.elements);
|
|
331
|
-
|
|
332
|
-
const viewports = allElements.filter((el) => el.kind === ELEMENT_KIND_VIEWPORT) as ViewportElement[];
|
|
333
|
-
|
|
334
|
-
const dataValidation = validateLayoutData(
|
|
335
|
-
data,
|
|
336
|
-
viewports.map((v) => v.id)
|
|
337
|
-
);
|
|
338
|
-
if (!dataValidation.ok) {
|
|
339
|
-
throw new Error(`Layout data validation failed: ${dataValidation.errors.join('; ')}`);
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
const {
|
|
343
|
-
viewportScales,
|
|
344
|
-
viewportClipPolygonsLocal,
|
|
345
|
-
viewportClipPolygonsWorld,
|
|
346
|
-
viewportClipBounds,
|
|
347
|
-
viewportClipLabels,
|
|
348
|
-
viewportClipStyles,
|
|
349
|
-
// viewportClipWhere intentionally omitted — not needed for rendering
|
|
350
|
-
viewportHighlight,
|
|
351
|
-
filteredModelsByViewport
|
|
352
|
-
} = prepareViewports(viewports, models, data, preferredScales, presets, {
|
|
353
|
-
metadataById: options?.metadataById,
|
|
354
|
-
warnings
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
const viewportData: Record<
|
|
358
|
-
string,
|
|
359
|
-
{
|
|
360
|
-
scaleDenom: number;
|
|
361
|
-
scaleText: string;
|
|
362
|
-
mmPerModelUnit: number;
|
|
363
|
-
fits: boolean;
|
|
364
|
-
}
|
|
365
|
-
> = {};
|
|
366
|
-
|
|
367
|
-
Object.entries(viewportScales).forEach(([id, scale]) => {
|
|
368
|
-
viewportData[id] = {
|
|
369
|
-
scaleDenom: scale.denom,
|
|
370
|
-
scaleText: `1:${scale.denom}`,
|
|
371
|
-
mmPerModelUnit: scale.mmPerModelUnit,
|
|
372
|
-
fits: scale.fits
|
|
373
|
-
};
|
|
374
|
-
});
|
|
375
|
-
|
|
376
|
-
const dataWithViewport = { ...data, viewport: viewportData };
|
|
377
|
-
|
|
378
|
-
const sorted = [...template.elements].sort((a, b) => (a.zIndex ?? 0) - (b.zIndex ?? 0));
|
|
379
|
-
|
|
380
|
-
const parts: string[] = [];
|
|
381
|
-
parts.push(
|
|
382
|
-
`<svg xmlns="${SVG_NS}" width="${page.widthMm}mm" height="${page.heightMm}mm" viewBox="0 0 ${page.widthMm} ${page.heightMm}">`
|
|
383
|
-
);
|
|
384
|
-
|
|
385
|
-
if (page.backgroundColor) {
|
|
386
|
-
parts.push(
|
|
387
|
-
`<rect x="0" y="0" width="${page.widthMm}" height="${page.heightMm}" fill="${escapeAttr(page.backgroundColor)}"/>`
|
|
388
|
-
);
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
const assetMap = new Map<string, AssetSpec>();
|
|
392
|
-
(template.assets ?? []).forEach((asset) => assetMap.set(asset.id, asset));
|
|
393
|
-
|
|
394
|
-
const qrElements = allElements.filter((el) => el.kind === ELEMENT_KIND_QR) as QrElement[];
|
|
395
|
-
const labelElements = allElements.filter((el) => el.kind === ELEMENT_KIND_LABELS) as LabelsElement[];
|
|
396
|
-
const viewportRenderInfo: Record<string, ViewportRenderInfo> = {};
|
|
397
|
-
|
|
398
|
-
// Pre-process legends to collect color maps (needed before viewport rendering)
|
|
399
|
-
const legendColorMaps = new Map<string, Map<string, string>>(); // viewport ID -> color map
|
|
400
|
-
const legendElements = allElements.filter((el) => el.kind === ELEMENT_KIND_LEGEND) as LegendElement[];
|
|
401
|
-
legendElements.forEach((legend) => {
|
|
402
|
-
if (legend.assignColors?.enabled && legend.groupBy) {
|
|
403
|
-
const legendItems = getPathValue(data, `viewports.${legend.viewport}.items`);
|
|
404
|
-
const rawLegendItems = Array.isArray(legendItems) ? legendItems : [];
|
|
405
|
-
const legendDataFiltered = applyLegendFilter(
|
|
406
|
-
rawLegendItems,
|
|
407
|
-
legend,
|
|
408
|
-
viewports,
|
|
409
|
-
viewportClipPolygonsLocal,
|
|
410
|
-
viewportRenderInfo
|
|
411
|
-
);
|
|
412
|
-
if (legendDataFiltered && legendDataFiltered.length) {
|
|
413
|
-
const vpEl = viewports.find((v) => v.id === legend.viewport);
|
|
414
|
-
const fillOpacity = vpEl?.fills?.length ? (vpEl.fills[0].fillOpacity ?? 0.35) : undefined;
|
|
415
|
-
const result = buildLegendGroup(
|
|
416
|
-
legend,
|
|
417
|
-
template.styles,
|
|
418
|
-
page,
|
|
419
|
-
page.marginMm,
|
|
420
|
-
legendDataFiltered,
|
|
421
|
-
fillOpacity
|
|
422
|
-
);
|
|
423
|
-
if (result?.colorMap) {
|
|
424
|
-
legendColorMaps.set(legend.viewport, result.colorMap);
|
|
425
|
-
console.log(
|
|
426
|
-
`[LEGEND PRE-PROCESS] Stored color map for viewport "${legend.viewport}": ${result.colorMap.size} colors`
|
|
427
|
-
);
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
});
|
|
432
|
-
|
|
433
|
-
sorted.forEach((el) => {
|
|
434
|
-
if (el.kind === ELEMENT_KIND_RECT) {
|
|
435
|
-
const r = el as RectElement;
|
|
436
|
-
parts.push(
|
|
437
|
-
`<rect x="${r.xMm}" y="${r.yMm}" width="${r.widthMm}" height="${r.heightMm}"` +
|
|
438
|
-
(r.stroke ? ` stroke="${escapeAttr(r.stroke)}"` : '') +
|
|
439
|
-
(r.strokeWidthMm ? ` stroke-width="${r.strokeWidthMm}"` : '') +
|
|
440
|
-
(r.fill ? ` fill="${escapeAttr(r.fill)}"` : ' fill="none"') +
|
|
441
|
-
dashArray(r.dashed) +
|
|
442
|
-
` />`
|
|
443
|
-
);
|
|
444
|
-
} else if (el.kind === ELEMENT_KIND_LINE) {
|
|
445
|
-
const l = el as LineElement;
|
|
446
|
-
parts.push(
|
|
447
|
-
`<line x1="${l.x1Mm}" y1="${l.y1Mm}" x2="${l.x2Mm}" y2="${l.y2Mm}"` +
|
|
448
|
-
(l.stroke ? ` stroke="${escapeAttr(l.stroke)}"` : '') +
|
|
449
|
-
(l.strokeWidthMm ? ` stroke-width="${l.strokeWidthMm}"` : '') +
|
|
450
|
-
dashArray(l.dashed) +
|
|
451
|
-
` />`
|
|
452
|
-
);
|
|
453
|
-
} else if (el.kind === ELEMENT_KIND_CIRCLE) {
|
|
454
|
-
const c = el as CircleElement;
|
|
455
|
-
parts.push(
|
|
456
|
-
`<circle cx="${c.cxMm}" cy="${c.cyMm}" r="${c.rMm}"` +
|
|
457
|
-
(c.stroke ? ` stroke="${escapeAttr(c.stroke)}"` : '') +
|
|
458
|
-
(c.strokeWidthMm ? ` stroke-width="${c.strokeWidthMm}"` : '') +
|
|
459
|
-
(c.fill ? ` fill="${escapeAttr(c.fill)}"` : ' fill="none"') +
|
|
460
|
-
dashArray(c.dashed) +
|
|
461
|
-
` />`
|
|
462
|
-
);
|
|
463
|
-
} else if (el.kind === ELEMENT_KIND_POLYLINE) {
|
|
464
|
-
const pl = el as PolylineElement;
|
|
465
|
-
const pointsStr = pl.points.map((p) => `${formatNumber(p.xMm)},${formatNumber(p.yMm)}`).join(' ');
|
|
466
|
-
parts.push(
|
|
467
|
-
`<polyline points="${pointsStr}" stroke="${escapeAttr(pl.stroke)}" stroke-width="${pl.strokeWidthMm}" fill="none"${dashArray(pl.dashed)} />`
|
|
468
|
-
);
|
|
469
|
-
} else if (el.kind === ELEMENT_KIND_POLYGON) {
|
|
470
|
-
const pg = el as PolygonElement;
|
|
471
|
-
const pointsStr = pg.points.map((p) => `${formatNumber(p.xMm)},${formatNumber(p.yMm)}`).join(' ');
|
|
472
|
-
parts.push(
|
|
473
|
-
`<polygon points="${pointsStr}"` +
|
|
474
|
-
(pg.stroke ? ` stroke="${escapeAttr(pg.stroke)}"` : '') +
|
|
475
|
-
(pg.strokeWidthMm ? ` stroke-width="${pg.strokeWidthMm}"` : '') +
|
|
476
|
-
(pg.fill ? ` fill="${escapeAttr(pg.fill)}"` : ' fill="none"') +
|
|
477
|
-
dashArray(pg.dashed) +
|
|
478
|
-
` />`
|
|
479
|
-
);
|
|
480
|
-
} else if (el.kind === ELEMENT_KIND_TEXT) {
|
|
481
|
-
const tEl = el as TextElement;
|
|
482
|
-
const styleName = tEl.textStyle;
|
|
483
|
-
const style = styleName ? template.styles?.[styleName] : undefined;
|
|
484
|
-
if (!style) {
|
|
485
|
-
pushWarning(warnings, `Missing text style '${styleName ?? '(none)'}' for element '${tEl.id}'.`);
|
|
486
|
-
return;
|
|
487
|
-
}
|
|
488
|
-
const text = interpolate(tEl.text, dataWithViewport, warnings);
|
|
489
|
-
const anchor = tEl.align === 'center' ? 'middle' : tEl.align === 'right' ? 'end' : 'start';
|
|
490
|
-
parts.push(
|
|
491
|
-
`<text x="${tEl.xMm}" y="${tEl.yMm}" font-family="${escapeAttr(style.fontFamily)}" font-size="${style.fontSizeMm}"` +
|
|
492
|
-
(style.fontWeight ? ` font-weight="${escapeAttr(style.fontWeight)}"` : '') +
|
|
493
|
-
(style.color ? ` fill="${escapeAttr(style.color)}"` : '') +
|
|
494
|
-
(style.letterSpacingMm !== undefined ? ` letter-spacing="${style.letterSpacingMm}"` : '') +
|
|
495
|
-
(style.lineHeightMm !== undefined ? ` line-height="${style.lineHeightMm}"` : '') +
|
|
496
|
-
` text-anchor="${anchor}">${escapeText(text)}</text>`
|
|
497
|
-
);
|
|
498
|
-
} else if (el.kind === ELEMENT_KIND_IMAGE) {
|
|
499
|
-
const img = el as ImageElement;
|
|
500
|
-
const asset = assetMap.get(img.assetId);
|
|
501
|
-
if (!asset) {
|
|
502
|
-
pushWarning(warnings, `Missing asset '${img.assetId}' for image '${img.id}'.`);
|
|
503
|
-
return;
|
|
504
|
-
}
|
|
505
|
-
if (asset.src) {
|
|
506
|
-
parts.push(
|
|
507
|
-
`<image href="${escapeAttr(asset.src)}" x="${img.xMm}" y="${img.yMm}" width="${img.widthMm}" height="${img.heightMm}"` +
|
|
508
|
-
(img.fit === 'cover'
|
|
509
|
-
? ' preserveAspectRatio="xMidYMid slice"'
|
|
510
|
-
: img.fit === 'stretch'
|
|
511
|
-
? ' preserveAspectRatio="none"'
|
|
512
|
-
: ' preserveAspectRatio="xMidYMid meet"') +
|
|
513
|
-
` />`
|
|
514
|
-
);
|
|
515
|
-
} else if (asset.content) {
|
|
516
|
-
parts.push(
|
|
517
|
-
`<g transform="translate(${img.xMm} ${img.yMm}) scale(${img.widthMm} ${img.heightMm})">${asset.content}</g>`
|
|
518
|
-
);
|
|
519
|
-
}
|
|
520
|
-
} else if (el.kind === ELEMENT_KIND_SCALE_BAR) {
|
|
521
|
-
const sb = el as ScaleBarElement;
|
|
522
|
-
// Scale bar declares which viewport it binds to via `viewport`
|
|
523
|
-
const boundViewport = sb.viewport ?? viewports[0]?.id ?? null;
|
|
524
|
-
if (!boundViewport) {
|
|
525
|
-
pushWarning(warnings, `Scale bar '${sb.id}' is not bound to a viewport.`);
|
|
526
|
-
return;
|
|
527
|
-
}
|
|
528
|
-
const scaleInfo = viewportScales[boundViewport];
|
|
529
|
-
if (!scaleInfo) {
|
|
530
|
-
pushWarning(warnings, `Viewport '${boundViewport}' missing scale info for scale bar '${sb.id}'.`);
|
|
531
|
-
return;
|
|
532
|
-
}
|
|
533
|
-
const lengthMm = sb.maxLengthMm;
|
|
534
|
-
const segments = sb.segments ?? 10;
|
|
535
|
-
const segmentMm = lengthMm / segments;
|
|
536
|
-
const metersPerMm = 1 / scaleInfo.mmPerModelUnit;
|
|
537
|
-
const segmentMeters = segmentMm * metersPerMm;
|
|
538
|
-
const labelsEvery = Math.max(1, sb.labelEvery ?? 1);
|
|
539
|
-
const unitSuffix = sb.unit ? ` ${sb.unit}` : ' m';
|
|
540
|
-
const barParts: string[] = [];
|
|
541
|
-
const sbStroke = sb.stroke ?? '#000';
|
|
542
|
-
const sbStrokeWidth = sb.strokeWidthMm ?? 0.5;
|
|
543
|
-
|
|
544
|
-
for (let i = 0; i <= segments; i++) {
|
|
545
|
-
const x = sb.xMm + segmentMm * i;
|
|
546
|
-
const isLabel = i % labelsEvery === 0;
|
|
547
|
-
const height = isLabel ? 4 : 3;
|
|
548
|
-
barParts.push(
|
|
549
|
-
`<line x1="${x}" y1="${sb.yMm}" x2="${x}" y2="${sb.yMm - height}" stroke="${escapeAttr(
|
|
550
|
-
sbStroke
|
|
551
|
-
)}" stroke-width="${sbStrokeWidth}" />`
|
|
552
|
-
);
|
|
553
|
-
if (isLabel && sb.textStyle) {
|
|
554
|
-
const style = template.styles?.[sb.textStyle];
|
|
555
|
-
if (style) {
|
|
556
|
-
const labelValue = (segmentMeters * i).toFixed(2).replace(/\.?0+$/, '');
|
|
557
|
-
barParts.push(
|
|
558
|
-
`<text x="${x}" y="${sb.yMm + style.fontSizeMm + 1}" font-family="${escapeAttr(
|
|
559
|
-
style.fontFamily
|
|
560
|
-
)}" font-size="${style.fontSizeMm}" text-anchor="middle">${escapeText(labelValue + unitSuffix)}</text>`
|
|
561
|
-
);
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
barParts.push(
|
|
567
|
-
`<line x1="${sb.xMm}" y1="${sb.yMm}" x2="${sb.xMm + lengthMm}" y2="${sb.yMm}" stroke="${escapeAttr(
|
|
568
|
-
sbStroke
|
|
569
|
-
)}" stroke-width="${sbStrokeWidth}" />`
|
|
570
|
-
);
|
|
571
|
-
|
|
572
|
-
parts.push(barParts.join(''));
|
|
573
|
-
} else if (el.kind === ELEMENT_KIND_VIEWPORT) {
|
|
574
|
-
const vp = el as ViewportElement;
|
|
575
|
-
const model = filteredModelsByViewport[vp.id] ?? models[vp.id] ?? null;
|
|
576
|
-
if (!model) {
|
|
577
|
-
pushWarning(warnings, `Viewport '${vp.id}' missing model.`);
|
|
578
|
-
}
|
|
579
|
-
const vpParts = renderViewportElement(
|
|
580
|
-
vp,
|
|
581
|
-
model,
|
|
582
|
-
dataWithViewport,
|
|
583
|
-
preferredScales,
|
|
584
|
-
presets.scales,
|
|
585
|
-
assetMap,
|
|
586
|
-
viewportScales,
|
|
587
|
-
viewportClipPolygonsLocal,
|
|
588
|
-
viewportClipBounds,
|
|
589
|
-
viewportClipLabels,
|
|
590
|
-
viewportClipStyles,
|
|
591
|
-
viewportHighlight,
|
|
592
|
-
viewportRenderInfo,
|
|
593
|
-
warnings,
|
|
594
|
-
legendColorMaps
|
|
595
|
-
);
|
|
596
|
-
parts.push(...vpParts);
|
|
597
|
-
} else if (el.kind === ELEMENT_KIND_LEGEND) {
|
|
598
|
-
const legend = el as LegendElement;
|
|
599
|
-
const legendItems = getPathValue(data, `viewports.${legend.viewport}.items`);
|
|
600
|
-
const rawLegendItems = Array.isArray(legendItems) ? legendItems : [];
|
|
601
|
-
const legendDataFiltered = applyLegendFilter(
|
|
602
|
-
rawLegendItems,
|
|
603
|
-
legend,
|
|
604
|
-
viewports,
|
|
605
|
-
viewportClipPolygonsLocal,
|
|
606
|
-
viewportRenderInfo
|
|
607
|
-
);
|
|
608
|
-
if (!legendDataFiltered || !legendDataFiltered.length) {
|
|
609
|
-
if (!rawLegendItems.length) {
|
|
610
|
-
pushWarning(warnings, `Legend '${legend.id}' has no items from viewport '${legend.viewport}'.`);
|
|
611
|
-
} else {
|
|
612
|
-
pushWarning(
|
|
613
|
-
warnings,
|
|
614
|
-
`Legend '${legend.id}' filter matched 0 of ${rawLegendItems.length} items (class=${JSON.stringify(legend.class)}, where=${JSON.stringify(legend.where)}).`
|
|
615
|
-
);
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
const vpEl = viewports.find((v) => v.id === legend.viewport);
|
|
619
|
-
// Derive swatch opacity from viewport fill rules (first matching rule's opacity)
|
|
620
|
-
const fillOpacity = vpEl?.fills?.length ? (vpEl.fills[0].fillOpacity ?? 0.35) : undefined;
|
|
621
|
-
const legendResult = buildLegendGroup(
|
|
622
|
-
legend,
|
|
623
|
-
template.styles,
|
|
624
|
-
page,
|
|
625
|
-
page.marginMm,
|
|
626
|
-
legendDataFiltered || [],
|
|
627
|
-
fillOpacity
|
|
628
|
-
);
|
|
629
|
-
if (legendResult) {
|
|
630
|
-
parts.push(legendResult.svg);
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
});
|
|
634
|
-
|
|
635
|
-
if (labelElements.length) {
|
|
636
|
-
const labelParts = renderLabels(
|
|
637
|
-
labelElements,
|
|
638
|
-
data,
|
|
639
|
-
viewportRenderInfo,
|
|
640
|
-
viewportClipLabels,
|
|
641
|
-
viewportClipPolygonsLocal,
|
|
642
|
-
viewportClipPolygonsWorld,
|
|
643
|
-
template.styles ?? {},
|
|
644
|
-
dataWithViewport,
|
|
645
|
-
warnings
|
|
646
|
-
);
|
|
647
|
-
parts.push(...labelParts);
|
|
648
|
-
}
|
|
649
|
-
|
|
650
|
-
if (qrElements.length) {
|
|
651
|
-
const qrParts = await renderQrElements(
|
|
652
|
-
qrElements,
|
|
653
|
-
viewports,
|
|
654
|
-
viewportScales,
|
|
655
|
-
models,
|
|
656
|
-
{ qrContext: options?.qrContext },
|
|
657
|
-
dataWithViewport,
|
|
658
|
-
warnings
|
|
659
|
-
);
|
|
660
|
-
parts.push(...qrParts);
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
parts.push('</svg>');
|
|
664
|
-
|
|
665
|
-
return { svg: parts.join(''), viewportScales, warnings };
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
// Register renderLayout with renderDrawing to break the circular dependency.
|
|
669
|
-
// This runs at module evaluation time — safe because renderLayout is defined above.
|
|
670
|
-
import { setRenderLayoutBinding as _setBinding } from './renderDrawing';
|
|
671
|
-
_setBinding(renderLayout as any);
|