abstract-image 11.2.1 → 11.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/lib/dynamic-image/dynamic-image-xsd.d.ts +2 -0
- package/lib/dynamic-image/dynamic-image-xsd.d.ts.map +1 -0
- package/lib/dynamic-image/dynamic-image-xsd.js +188 -0
- package/lib/dynamic-image/dynamic-image-xsd.js.map +1 -0
- package/lib/dynamic-image/dynamic-image.d.ts +25 -0
- package/lib/dynamic-image/dynamic-image.d.ts.map +1 -0
- package/lib/dynamic-image/dynamic-image.js +189 -0
- package/lib/dynamic-image/dynamic-image.js.map +1 -0
- package/lib/dynamic-image/index.d.ts +2 -0
- package/lib/dynamic-image/index.d.ts.map +1 -0
- package/lib/dynamic-image/index.js +18 -0
- package/lib/dynamic-image/index.js.map +1 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/package.json +2 -2
- package/src/{abstract-image-xml/abstract-image-xsd.ts → dynamic-image/dynamic-image-xsd.ts} +1 -1
- package/src/{abstract-image-xml/abstract-image-xml.ts → dynamic-image/dynamic-image.ts} +20 -15
- package/src/dynamic-image/index.ts +1 -0
- package/src/index.ts +1 -1
- package/src/abstract-image-xml/index.ts +0 -1
- /package/src/{abstract-image-xml/abstract-image-xsd.xml → dynamic-image/dynamic-image-xsd.xml} +0 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const xsd = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"\n targetNamespace=\"urn:adml\"\n xmlns=\"urn:adml\"\n elementFormDefault=\"qualified\"\n attributeFormDefault=\"unqualified\">\n\n <!-- ========= Root ========= -->\n <xs:element name=\"abstractImage\" type=\"AbstractImage\"/>\n\n <xs:group name=\"Component\">\n <xs:choice>\n <xs:element name=\"image\" type=\"Image\"/>\n <xs:element name=\"ellipse\" type=\"Ellipse\"/>\n <xs:element name=\"line\" type=\"Line\"/>\n <xs:element name=\"polyline\" type=\"PolyLine\"/>\n <xs:element name=\"polygon\" type=\"Polygon\"/>\n <xs:element name=\"rectangle\" type=\"Rectangle\"/>\n <xs:element name=\"text\" type=\"Text\"/>\n <xs:element name=\"group\" type=\"Group\"/>\n </xs:choice>\n </xs:group>\n\n <xs:complexType name=\"AbstractImage\">\n <xs:sequence>\n <xs:element name=\"components\">\n <xs:complexType>\n <xs:sequence>\n <xs:group ref=\"Component\" minOccurs=\"0\" maxOccurs=\"unbounded\"/>\n </xs:sequence>\n </xs:complexType>\n </xs:element>\n </xs:sequence>\n <xs:attribute name=\"topLeft\" type=\"PointString\" use=\"required\"/>\n <xs:attribute name=\"size\" type=\"SizeString\" use=\"required\"/>\n <xs:attribute name=\"backgroundColor\" type=\"ColorString\" use=\"optional\"/>\n </xs:complexType>\n\n <xs:simpleType name=\"PointString\"><xs:restriction base=\"xs:string\"/></xs:simpleType>\n <xs:simpleType name=\"SizeString\"><xs:restriction base=\"xs:string\"/></xs:simpleType>\n <xs:simpleType name=\"ColorString\"><xs:restriction base=\"xs:string\"/></xs:simpleType>\n <xs:simpleType name=\"PointsString\"><xs:restriction base=\"xs:string\"/></xs:simpleType>\n <xs:simpleType name=\"DashArray\"><xs:restriction base=\"xs:string\"/></xs:simpleType>\n <xs:simpleType name=\"DashOffset\"><xs:restriction base=\"xs:string\"/></xs:simpleType>\n\n <!-- ========= Components ========= -->\n\n <!-- Group -->\n <xs:complexType name=\"Group\">\n <xs:sequence>\n <xs:element name=\"children\">\n <xs:complexType>\n <xs:sequence>\n <xs:group ref=\"Component\" minOccurs=\"0\" maxOccurs=\"unbounded\"/>\n </xs:sequence>\n </xs:complexType>\n </xs:element>\n </xs:sequence>\n <xs:attribute name=\"name\" type=\"xs:string\" use=\"optional\"/>\n </xs:complexType>\n\n <!-- Image -->\n <xs:complexType name=\"Image\">\n <xs:attribute name=\"url\" type=\"xs:anyURI\" use=\"required\"/>\n <xs:attribute name=\"topLeft\" type=\"PointString\" use=\"required\"/>\n <xs:attribute name=\"bottomRight\" type=\"PointString\" use=\"required\"/>\n <xs:attribute name=\"id\" type=\"xs:string\" use=\"optional\"/>\n </xs:complexType>\n\n <!-- Ellipse -->\n <xs:complexType name=\"Ellipse\">\n <xs:attribute name=\"topLeft\" type=\"PointString\" use=\"required\"/>\n <xs:attribute name=\"bottomRight\" type=\"PointString\" use=\"required\"/>\n <xs:attribute name=\"strokeColor\" type=\"ColorString\" use=\"optional\"/>\n <xs:attribute name=\"strokeThickness\" type=\"xs:double\" use=\"optional\"/>\n <xs:attribute name=\"strokeDashArray\" type=\"DashArray\" use=\"optional\"/> \n <xs:attribute name=\"strokeDashOffset\" type=\"DashOffset\" use=\"optional\"/>\n <xs:attribute name=\"fillColor\" type=\"ColorString\" use=\"optional\"/>\n <xs:attribute name=\"id\" type=\"xs:string\" use=\"optional\"/>\n </xs:complexType>\n\n <!-- Line -->\n <xs:complexType name=\"Line\">\n <xs:attribute name=\"start\" type=\"PointString\" use=\"required\"/>\n <xs:attribute name=\"end\" type=\"PointString\" use=\"required\"/>\n <xs:attribute name=\"strokeColor\" type=\"ColorString\" use=\"optional\"/>\n <xs:attribute name=\"strokeThickness\" type=\"xs:double\" use=\"optional\"/>\n <xs:attribute name=\"strokeDashArray\" type=\"DashArray\" use=\"optional\"/> \n <xs:attribute name=\"strokeDashOffset\" type=\"DashOffset\" use=\"optional\"/>\n <xs:attribute name=\"id\" type=\"xs:string\" use=\"optional\"/>\n </xs:complexType>\n\n <!-- PolyLine -->\n <xs:complexType name=\"PolyLine\">\n <xs:attribute name=\"points\" type=\"PointsString\" use=\"required\"/>\n <xs:attribute name=\"strokeColor\" type=\"ColorString\" use=\"optional\"/>\n <xs:attribute name=\"strokeThickness\" type=\"xs:double\" use=\"optional\"/>\n <xs:attribute name=\"strokeDashArray\" type=\"DashArray\" use=\"optional\"/> \n <xs:attribute name=\"strokeDashOffset\" type=\"DashOffset\" use=\"optional\"/>\n <xs:attribute name=\"id\" type=\"xs:string\" use=\"optional\"/>\n </xs:complexType>\n\n <!-- Polygon -->\n <xs:complexType name=\"Polygon\">\n <xs:attribute name=\"points\" type=\"PointsString\" use=\"required\"/>\n <xs:attribute name=\"strokeColor\" type=\"ColorString\" use=\"optional\"/>\n <xs:attribute name=\"strokeThickness\" type=\"xs:double\" use=\"optional\"/>\n <xs:attribute name=\"strokeDashArray\" type=\"DashArray\" use=\"optional\"/> \n <xs:attribute name=\"strokeDashOffset\" type=\"DashOffset\" use=\"optional\"/>\n <xs:attribute name=\"fillColor\" type=\"ColorString\" use=\"optional\"/>\n <xs:attribute name=\"id\" type=\"xs:string\" use=\"optional\"/>\n </xs:complexType>\n\n <!-- Rectangle -->\n <xs:complexType name=\"Rectangle\">\n <xs:attribute name=\"topLeft\" type=\"PointString\" use=\"required\"/>\n <xs:attribute name=\"bottomRight\" type=\"PointString\" use=\"required\"/>\n <xs:attribute name=\"strokeColor\" type=\"ColorString\" use=\"optional\"/>\n <xs:attribute name=\"strokeThickness\" type=\"xs:double\" use=\"optional\"/>\n <xs:attribute name=\"strokeDashArray\" type=\"DashArray\" use=\"optional\"/> \n <xs:attribute name=\"strokeDashOffset\" type=\"DashOffset\" use=\"optional\"/>\n <xs:attribute name=\"fillColor\" type=\"ColorString\" use=\"optional\"/>\n <xs:attribute name=\"id\" type=\"xs:string\" use=\"optional\"/>\n <xs:attribute name=\"radius\" type=\"PointString\" use=\"optional\"/>\n </xs:complexType>\n\n <!-- Text -->\n <xs:complexType name=\"Text\">\n <xs:attribute name=\"position\" type=\"PointString\" use=\"required\"/>\n <xs:attribute name=\"text\" type=\"xs:string\" use=\"required\"/>\n <xs:attribute name=\"fontFamily\" type=\"xs:string\" use=\"optional\"/>\n <xs:attribute name=\"fontSize\" type=\"xs:double\" use=\"optional\"/>\n <xs:attribute name=\"textColor\" type=\"ColorString\" use=\"optional\"/>\n\t<xs:attribute name=\"fontWeight\" use=\"optional\">\n\t\t<xs:simpleType>\n\t\t<xs:restriction base=\"xs:string\">\n\t\t\t<xs:enumeration value=\"light\"/>\n\t\t\t<xs:enumeration value=\"normal\"/>\n\t\t\t<xs:enumeration value=\"mediumBold\"/>\n\t\t\t<xs:enumeration value=\"bold\"/>\n\t\t\t<xs:enumeration value=\"extraBold\"/>\n\t\t</xs:restriction>\n\t\t</xs:simpleType>\n\t</xs:attribute>\n\t<xs:attribute name=\"clockwiseRotationDegrees\" type=\"xs:double\" use=\"optional\"/>\n\t<xs:attribute name=\"textAlignment\" use=\"optional\">\n\t\t<xs:simpleType>\n\t\t<xs:restriction base=\"xs:string\">\n\t\t\t<xs:enumeration value=\"left\"/>\n\t\t\t<xs:enumeration value=\"center\"/>\n\t\t\t<xs:enumeration value=\"right\"/>\n\t\t</xs:restriction>\n\t\t</xs:simpleType>\n\t</xs:attribute>\n\t<xs:attribute name=\"horizontalGrowthDirection\" use=\"optional\">\n\t\t<xs:simpleType>\n\t\t<xs:restriction base=\"xs:string\">\n\t\t\t<xs:enumeration value=\"up\"/>\n\t\t\t<xs:enumeration value=\"down\"/>\n\t\t\t<xs:enumeration value=\"uniform\"/>\n\t\t\t<xs:enumeration value=\"left\"/>\n\t\t\t<xs:enumeration value=\"right\"/>\n\t\t</xs:restriction>\n\t\t</xs:simpleType>\n\t</xs:attribute>\n\t<xs:attribute name=\"verticalGrowthDirection\" use=\"optional\">\n\t\t<xs:simpleType>\n\t\t<xs:restriction base=\"xs:string\">\n\t\t\t<xs:enumeration value=\"up\"/>\n\t\t\t<xs:enumeration value=\"down\"/>\n\t\t\t<xs:enumeration value=\"uniform\"/>\n\t\t\t<xs:enumeration value=\"left\"/>\n\t\t\t<xs:enumeration value=\"right\"/>\n\t\t</xs:restriction>\n\t\t</xs:simpleType>\n\t</xs:attribute>\n <xs:attribute name=\"strokeThickness\" type=\"xs:double\" use=\"optional\"/>\n <xs:attribute name=\"strokeColor\" type=\"ColorString\" use=\"optional\"/>\n <xs:attribute name=\"italic\" type=\"xs:boolean\" use=\"optional\"/>\n <xs:attribute name=\"id\" type=\"xs:string\" use=\"optional\"/>\n </xs:complexType>\n\n</xs:schema>\n";
|
|
2
|
+
//# sourceMappingURL=dynamic-image-xsd.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamic-image-xsd.d.ts","sourceRoot":"","sources":["../../src/dynamic-image/dynamic-image-xsd.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,GAAG,w2QAuLf,CAAC"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.xsd = void 0;
|
|
4
|
+
exports.xsd = `<?xml version="1.0" encoding="UTF-8"?>
|
|
5
|
+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
|
6
|
+
targetNamespace="urn:adml"
|
|
7
|
+
xmlns="urn:adml"
|
|
8
|
+
elementFormDefault="qualified"
|
|
9
|
+
attributeFormDefault="unqualified">
|
|
10
|
+
|
|
11
|
+
<!-- ========= Root ========= -->
|
|
12
|
+
<xs:element name="abstractImage" type="AbstractImage"/>
|
|
13
|
+
|
|
14
|
+
<xs:group name="Component">
|
|
15
|
+
<xs:choice>
|
|
16
|
+
<xs:element name="image" type="Image"/>
|
|
17
|
+
<xs:element name="ellipse" type="Ellipse"/>
|
|
18
|
+
<xs:element name="line" type="Line"/>
|
|
19
|
+
<xs:element name="polyline" type="PolyLine"/>
|
|
20
|
+
<xs:element name="polygon" type="Polygon"/>
|
|
21
|
+
<xs:element name="rectangle" type="Rectangle"/>
|
|
22
|
+
<xs:element name="text" type="Text"/>
|
|
23
|
+
<xs:element name="group" type="Group"/>
|
|
24
|
+
</xs:choice>
|
|
25
|
+
</xs:group>
|
|
26
|
+
|
|
27
|
+
<xs:complexType name="AbstractImage">
|
|
28
|
+
<xs:sequence>
|
|
29
|
+
<xs:element name="components">
|
|
30
|
+
<xs:complexType>
|
|
31
|
+
<xs:sequence>
|
|
32
|
+
<xs:group ref="Component" minOccurs="0" maxOccurs="unbounded"/>
|
|
33
|
+
</xs:sequence>
|
|
34
|
+
</xs:complexType>
|
|
35
|
+
</xs:element>
|
|
36
|
+
</xs:sequence>
|
|
37
|
+
<xs:attribute name="topLeft" type="PointString" use="required"/>
|
|
38
|
+
<xs:attribute name="size" type="SizeString" use="required"/>
|
|
39
|
+
<xs:attribute name="backgroundColor" type="ColorString" use="optional"/>
|
|
40
|
+
</xs:complexType>
|
|
41
|
+
|
|
42
|
+
<xs:simpleType name="PointString"><xs:restriction base="xs:string"/></xs:simpleType>
|
|
43
|
+
<xs:simpleType name="SizeString"><xs:restriction base="xs:string"/></xs:simpleType>
|
|
44
|
+
<xs:simpleType name="ColorString"><xs:restriction base="xs:string"/></xs:simpleType>
|
|
45
|
+
<xs:simpleType name="PointsString"><xs:restriction base="xs:string"/></xs:simpleType>
|
|
46
|
+
<xs:simpleType name="DashArray"><xs:restriction base="xs:string"/></xs:simpleType>
|
|
47
|
+
<xs:simpleType name="DashOffset"><xs:restriction base="xs:string"/></xs:simpleType>
|
|
48
|
+
|
|
49
|
+
<!-- ========= Components ========= -->
|
|
50
|
+
|
|
51
|
+
<!-- Group -->
|
|
52
|
+
<xs:complexType name="Group">
|
|
53
|
+
<xs:sequence>
|
|
54
|
+
<xs:element name="children">
|
|
55
|
+
<xs:complexType>
|
|
56
|
+
<xs:sequence>
|
|
57
|
+
<xs:group ref="Component" minOccurs="0" maxOccurs="unbounded"/>
|
|
58
|
+
</xs:sequence>
|
|
59
|
+
</xs:complexType>
|
|
60
|
+
</xs:element>
|
|
61
|
+
</xs:sequence>
|
|
62
|
+
<xs:attribute name="name" type="xs:string" use="optional"/>
|
|
63
|
+
</xs:complexType>
|
|
64
|
+
|
|
65
|
+
<!-- Image -->
|
|
66
|
+
<xs:complexType name="Image">
|
|
67
|
+
<xs:attribute name="url" type="xs:anyURI" use="required"/>
|
|
68
|
+
<xs:attribute name="topLeft" type="PointString" use="required"/>
|
|
69
|
+
<xs:attribute name="bottomRight" type="PointString" use="required"/>
|
|
70
|
+
<xs:attribute name="id" type="xs:string" use="optional"/>
|
|
71
|
+
</xs:complexType>
|
|
72
|
+
|
|
73
|
+
<!-- Ellipse -->
|
|
74
|
+
<xs:complexType name="Ellipse">
|
|
75
|
+
<xs:attribute name="topLeft" type="PointString" use="required"/>
|
|
76
|
+
<xs:attribute name="bottomRight" type="PointString" use="required"/>
|
|
77
|
+
<xs:attribute name="strokeColor" type="ColorString" use="optional"/>
|
|
78
|
+
<xs:attribute name="strokeThickness" type="xs:double" use="optional"/>
|
|
79
|
+
<xs:attribute name="strokeDashArray" type="DashArray" use="optional"/>
|
|
80
|
+
<xs:attribute name="strokeDashOffset" type="DashOffset" use="optional"/>
|
|
81
|
+
<xs:attribute name="fillColor" type="ColorString" use="optional"/>
|
|
82
|
+
<xs:attribute name="id" type="xs:string" use="optional"/>
|
|
83
|
+
</xs:complexType>
|
|
84
|
+
|
|
85
|
+
<!-- Line -->
|
|
86
|
+
<xs:complexType name="Line">
|
|
87
|
+
<xs:attribute name="start" type="PointString" use="required"/>
|
|
88
|
+
<xs:attribute name="end" type="PointString" use="required"/>
|
|
89
|
+
<xs:attribute name="strokeColor" type="ColorString" use="optional"/>
|
|
90
|
+
<xs:attribute name="strokeThickness" type="xs:double" use="optional"/>
|
|
91
|
+
<xs:attribute name="strokeDashArray" type="DashArray" use="optional"/>
|
|
92
|
+
<xs:attribute name="strokeDashOffset" type="DashOffset" use="optional"/>
|
|
93
|
+
<xs:attribute name="id" type="xs:string" use="optional"/>
|
|
94
|
+
</xs:complexType>
|
|
95
|
+
|
|
96
|
+
<!-- PolyLine -->
|
|
97
|
+
<xs:complexType name="PolyLine">
|
|
98
|
+
<xs:attribute name="points" type="PointsString" use="required"/>
|
|
99
|
+
<xs:attribute name="strokeColor" type="ColorString" use="optional"/>
|
|
100
|
+
<xs:attribute name="strokeThickness" type="xs:double" use="optional"/>
|
|
101
|
+
<xs:attribute name="strokeDashArray" type="DashArray" use="optional"/>
|
|
102
|
+
<xs:attribute name="strokeDashOffset" type="DashOffset" use="optional"/>
|
|
103
|
+
<xs:attribute name="id" type="xs:string" use="optional"/>
|
|
104
|
+
</xs:complexType>
|
|
105
|
+
|
|
106
|
+
<!-- Polygon -->
|
|
107
|
+
<xs:complexType name="Polygon">
|
|
108
|
+
<xs:attribute name="points" type="PointsString" use="required"/>
|
|
109
|
+
<xs:attribute name="strokeColor" type="ColorString" use="optional"/>
|
|
110
|
+
<xs:attribute name="strokeThickness" type="xs:double" use="optional"/>
|
|
111
|
+
<xs:attribute name="strokeDashArray" type="DashArray" use="optional"/>
|
|
112
|
+
<xs:attribute name="strokeDashOffset" type="DashOffset" use="optional"/>
|
|
113
|
+
<xs:attribute name="fillColor" type="ColorString" use="optional"/>
|
|
114
|
+
<xs:attribute name="id" type="xs:string" use="optional"/>
|
|
115
|
+
</xs:complexType>
|
|
116
|
+
|
|
117
|
+
<!-- Rectangle -->
|
|
118
|
+
<xs:complexType name="Rectangle">
|
|
119
|
+
<xs:attribute name="topLeft" type="PointString" use="required"/>
|
|
120
|
+
<xs:attribute name="bottomRight" type="PointString" use="required"/>
|
|
121
|
+
<xs:attribute name="strokeColor" type="ColorString" use="optional"/>
|
|
122
|
+
<xs:attribute name="strokeThickness" type="xs:double" use="optional"/>
|
|
123
|
+
<xs:attribute name="strokeDashArray" type="DashArray" use="optional"/>
|
|
124
|
+
<xs:attribute name="strokeDashOffset" type="DashOffset" use="optional"/>
|
|
125
|
+
<xs:attribute name="fillColor" type="ColorString" use="optional"/>
|
|
126
|
+
<xs:attribute name="id" type="xs:string" use="optional"/>
|
|
127
|
+
<xs:attribute name="radius" type="PointString" use="optional"/>
|
|
128
|
+
</xs:complexType>
|
|
129
|
+
|
|
130
|
+
<!-- Text -->
|
|
131
|
+
<xs:complexType name="Text">
|
|
132
|
+
<xs:attribute name="position" type="PointString" use="required"/>
|
|
133
|
+
<xs:attribute name="text" type="xs:string" use="required"/>
|
|
134
|
+
<xs:attribute name="fontFamily" type="xs:string" use="optional"/>
|
|
135
|
+
<xs:attribute name="fontSize" type="xs:double" use="optional"/>
|
|
136
|
+
<xs:attribute name="textColor" type="ColorString" use="optional"/>
|
|
137
|
+
<xs:attribute name="fontWeight" use="optional">
|
|
138
|
+
<xs:simpleType>
|
|
139
|
+
<xs:restriction base="xs:string">
|
|
140
|
+
<xs:enumeration value="light"/>
|
|
141
|
+
<xs:enumeration value="normal"/>
|
|
142
|
+
<xs:enumeration value="mediumBold"/>
|
|
143
|
+
<xs:enumeration value="bold"/>
|
|
144
|
+
<xs:enumeration value="extraBold"/>
|
|
145
|
+
</xs:restriction>
|
|
146
|
+
</xs:simpleType>
|
|
147
|
+
</xs:attribute>
|
|
148
|
+
<xs:attribute name="clockwiseRotationDegrees" type="xs:double" use="optional"/>
|
|
149
|
+
<xs:attribute name="textAlignment" use="optional">
|
|
150
|
+
<xs:simpleType>
|
|
151
|
+
<xs:restriction base="xs:string">
|
|
152
|
+
<xs:enumeration value="left"/>
|
|
153
|
+
<xs:enumeration value="center"/>
|
|
154
|
+
<xs:enumeration value="right"/>
|
|
155
|
+
</xs:restriction>
|
|
156
|
+
</xs:simpleType>
|
|
157
|
+
</xs:attribute>
|
|
158
|
+
<xs:attribute name="horizontalGrowthDirection" use="optional">
|
|
159
|
+
<xs:simpleType>
|
|
160
|
+
<xs:restriction base="xs:string">
|
|
161
|
+
<xs:enumeration value="up"/>
|
|
162
|
+
<xs:enumeration value="down"/>
|
|
163
|
+
<xs:enumeration value="uniform"/>
|
|
164
|
+
<xs:enumeration value="left"/>
|
|
165
|
+
<xs:enumeration value="right"/>
|
|
166
|
+
</xs:restriction>
|
|
167
|
+
</xs:simpleType>
|
|
168
|
+
</xs:attribute>
|
|
169
|
+
<xs:attribute name="verticalGrowthDirection" use="optional">
|
|
170
|
+
<xs:simpleType>
|
|
171
|
+
<xs:restriction base="xs:string">
|
|
172
|
+
<xs:enumeration value="up"/>
|
|
173
|
+
<xs:enumeration value="down"/>
|
|
174
|
+
<xs:enumeration value="uniform"/>
|
|
175
|
+
<xs:enumeration value="left"/>
|
|
176
|
+
<xs:enumeration value="right"/>
|
|
177
|
+
</xs:restriction>
|
|
178
|
+
</xs:simpleType>
|
|
179
|
+
</xs:attribute>
|
|
180
|
+
<xs:attribute name="strokeThickness" type="xs:double" use="optional"/>
|
|
181
|
+
<xs:attribute name="strokeColor" type="ColorString" use="optional"/>
|
|
182
|
+
<xs:attribute name="italic" type="xs:boolean" use="optional"/>
|
|
183
|
+
<xs:attribute name="id" type="xs:string" use="optional"/>
|
|
184
|
+
</xs:complexType>
|
|
185
|
+
|
|
186
|
+
</xs:schema>
|
|
187
|
+
`;
|
|
188
|
+
//# sourceMappingURL=dynamic-image-xsd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamic-image-xsd.js","sourceRoot":"","sources":["../../src/dynamic-image/dynamic-image-xsd.ts"],"names":[],"mappings":";;;AAAa,QAAA,GAAG,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuLlB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AbstractImage } from "../model/abstract-image.js";
|
|
2
|
+
import { XmlElement } from "handlebars-xml";
|
|
3
|
+
export type DynamicImageError = {
|
|
4
|
+
type: "HANDLEBARS_PARSE_ERROR";
|
|
5
|
+
message: string;
|
|
6
|
+
cause?: unknown;
|
|
7
|
+
} | {
|
|
8
|
+
type: "XML_PARSE_ERROR";
|
|
9
|
+
message: string;
|
|
10
|
+
cause?: unknown;
|
|
11
|
+
} | {
|
|
12
|
+
type: "UNKNOWN_ERROR";
|
|
13
|
+
message: string;
|
|
14
|
+
cause?: unknown;
|
|
15
|
+
};
|
|
16
|
+
export declare function dynamicImage(template: string, data: unknown): {
|
|
17
|
+
readonly type: "Ok";
|
|
18
|
+
readonly image: AbstractImage;
|
|
19
|
+
readonly imageUrls: ReadonlyArray<string>;
|
|
20
|
+
} | {
|
|
21
|
+
readonly type: "Err";
|
|
22
|
+
readonly error: DynamicImageError;
|
|
23
|
+
};
|
|
24
|
+
export declare const parsedXsd: readonly XmlElement[];
|
|
25
|
+
//# sourceMappingURL=dynamic-image.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamic-image.d.ts","sourceRoot":"","sources":["../../src/dynamic-image/dynamic-image.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAgC,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAmB1E,MAAM,MAAM,iBAAiB,GACzB;IAAE,IAAI,EAAE,wBAAwB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GACpE;IAAE,IAAI,EAAE,iBAAiB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAC7D;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAEhE,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,OAAO,GAEX;IAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CAAE,GACjG;IAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAA;CAAE,CA4B9D;AAwID,eAAO,MAAM,SAAS,uBAAgB,CAAC"}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parsedXsd = void 0;
|
|
4
|
+
exports.dynamicImage = dynamicImage;
|
|
5
|
+
const handlebars_xml_1 = require("handlebars-xml");
|
|
6
|
+
const color_js_1 = require("../model/color.js");
|
|
7
|
+
const dynamic_image_xsd_js_1 = require("./dynamic-image-xsd.js");
|
|
8
|
+
function dynamicImage(template, data) {
|
|
9
|
+
try {
|
|
10
|
+
const [parsedXml] = (0, handlebars_xml_1.parseHandlebarsXml)(template, data, {});
|
|
11
|
+
try {
|
|
12
|
+
const mutableImageUrls = Array();
|
|
13
|
+
const abstractImage = dynamicImageInternal(parsedXml, mutableImageUrls);
|
|
14
|
+
return { type: "Ok", image: abstractImage, imageUrls: mutableImageUrls };
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
return {
|
|
18
|
+
type: "Err",
|
|
19
|
+
error: {
|
|
20
|
+
type: "XML_PARSE_ERROR",
|
|
21
|
+
message: errorMessage(error),
|
|
22
|
+
cause: error,
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
return {
|
|
29
|
+
type: "Err",
|
|
30
|
+
error: {
|
|
31
|
+
type: "HANDLEBARS_PARSE_ERROR",
|
|
32
|
+
message: errorMessage(error),
|
|
33
|
+
cause: error,
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function errorMessage(error) {
|
|
39
|
+
return error instanceof Error ? error.message : String(error);
|
|
40
|
+
}
|
|
41
|
+
function dynamicImageInternal(el, mutableImageUrls) {
|
|
42
|
+
const children = Array();
|
|
43
|
+
const childElements = Array();
|
|
44
|
+
for (const child of el.children ?? []) {
|
|
45
|
+
if (child.tagName !== undefined) {
|
|
46
|
+
children.push(dynamicImageInternal(child, mutableImageUrls));
|
|
47
|
+
childElements.push(child);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
switch (el.tagName) {
|
|
51
|
+
case "AbstractImage":
|
|
52
|
+
const size = parsePoint(el.attributes.size);
|
|
53
|
+
return {
|
|
54
|
+
topLeft: parsePoint(el.attributes.topLeft),
|
|
55
|
+
size: { width: size.x, height: size.y },
|
|
56
|
+
backgroundColor: (0, color_js_1.fromString2)(el.attributes.backgroundColor ?? "", color_js_1.transparent),
|
|
57
|
+
components: children,
|
|
58
|
+
};
|
|
59
|
+
case "Group":
|
|
60
|
+
return {
|
|
61
|
+
type: "group",
|
|
62
|
+
name: el.attributes.name ?? "",
|
|
63
|
+
children: children,
|
|
64
|
+
};
|
|
65
|
+
case "Image":
|
|
66
|
+
if (typeof el.attributes.url === "string") {
|
|
67
|
+
mutableImageUrls.push(el.attributes.url);
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
type: "binaryimage",
|
|
71
|
+
topLeft: parsePoint(el.attributes.topLeft),
|
|
72
|
+
bottomRight: parsePoint(el.attributes.bottomRight),
|
|
73
|
+
data: { type: "url", url: el.attributes.url },
|
|
74
|
+
id: el.attributes.id,
|
|
75
|
+
format: "png",
|
|
76
|
+
};
|
|
77
|
+
case "Ellipse":
|
|
78
|
+
return {
|
|
79
|
+
type: "ellipse",
|
|
80
|
+
topLeft: parsePoint(el.attributes.topLeft),
|
|
81
|
+
bottomRight: parsePoint(el.attributes.bottomRight),
|
|
82
|
+
fillColor: (0, color_js_1.fromString2)(el.attributes.fillColor ?? "", color_js_1.white),
|
|
83
|
+
strokeColor: (0, color_js_1.fromString2)(el.attributes.strokeColor ?? "", color_js_1.black),
|
|
84
|
+
id: el.attributes.id,
|
|
85
|
+
strokeDashStyle: {
|
|
86
|
+
dashes: parseNumberArrayString(el.attributes.strokeDashArray),
|
|
87
|
+
offset: el.attributes.strokeDashOffset ? Number(el.attributes.strokeDashOffset) : 0,
|
|
88
|
+
},
|
|
89
|
+
strokeThickness: Number(el.attributes.strokeThickness ?? 1),
|
|
90
|
+
};
|
|
91
|
+
case "Line":
|
|
92
|
+
return {
|
|
93
|
+
type: "line",
|
|
94
|
+
start: parsePoint(el.attributes.start),
|
|
95
|
+
end: parsePoint(el.attributes.end),
|
|
96
|
+
strokeColor: (0, color_js_1.fromString2)(el.attributes.strokeColor ?? "", color_js_1.black),
|
|
97
|
+
id: el.attributes.id,
|
|
98
|
+
strokeDashStyle: {
|
|
99
|
+
dashes: parseNumberArrayString(el.attributes.strokeDashArray),
|
|
100
|
+
offset: el.attributes.strokeDashOffset ? Number(el.attributes.strokeDashOffset) : 0,
|
|
101
|
+
},
|
|
102
|
+
strokeThickness: Number(el.attributes.strokeThickness ?? 1),
|
|
103
|
+
};
|
|
104
|
+
case "PolyLine":
|
|
105
|
+
return {
|
|
106
|
+
type: "polyline",
|
|
107
|
+
points: parsePointsString(el.attributes.points),
|
|
108
|
+
strokeColor: (0, color_js_1.fromString2)(el.attributes.strokeColor ?? "", color_js_1.black),
|
|
109
|
+
id: el.attributes.id,
|
|
110
|
+
strokeDashStyle: {
|
|
111
|
+
dashes: parseNumberArrayString(el.attributes.strokeDashArray),
|
|
112
|
+
offset: el.attributes.strokeDashOffset ? Number(el.attributes.strokeDashOffset) : 0,
|
|
113
|
+
},
|
|
114
|
+
strokeThickness: Number(el.attributes.strokeThickness ?? 1),
|
|
115
|
+
};
|
|
116
|
+
case "Polygon":
|
|
117
|
+
return {
|
|
118
|
+
type: "polygon",
|
|
119
|
+
points: parsePointsString(el.attributes.points),
|
|
120
|
+
fillColor: (0, color_js_1.fromString2)(el.attributes.fillColor ?? "", color_js_1.white),
|
|
121
|
+
strokeColor: (0, color_js_1.fromString2)(el.attributes.strokeColor ?? "", color_js_1.black),
|
|
122
|
+
id: el.attributes.id,
|
|
123
|
+
strokeDashStyle: {
|
|
124
|
+
dashes: parseNumberArrayString(el.attributes.strokeDashArray),
|
|
125
|
+
offset: el.attributes.strokeDashOffset ? Number(el.attributes.strokeDashOffset) : 0,
|
|
126
|
+
},
|
|
127
|
+
strokeThickness: Number(el.attributes.strokeThickness ?? 1),
|
|
128
|
+
};
|
|
129
|
+
case "Rectangle":
|
|
130
|
+
return {
|
|
131
|
+
type: "rectangle",
|
|
132
|
+
topLeft: parsePoint(el.attributes.topLeft),
|
|
133
|
+
bottomRight: parsePoint(el.attributes.bottomRight),
|
|
134
|
+
fillColor: (0, color_js_1.fromString2)(el.attributes.fillColor ?? "", color_js_1.white),
|
|
135
|
+
radius: el.attributes.radius ? parsePoint(el.attributes.radius) : undefined,
|
|
136
|
+
strokeColor: (0, color_js_1.fromString2)(el.attributes.strokeColor ?? "", color_js_1.black),
|
|
137
|
+
id: el.attributes.id,
|
|
138
|
+
strokeDashStyle: {
|
|
139
|
+
dashes: parseNumberArrayString(el.attributes.strokeDashArray),
|
|
140
|
+
offset: el.attributes.strokeDashOffset ? Number(el.attributes.strokeDashOffset) : 0,
|
|
141
|
+
},
|
|
142
|
+
strokeThickness: Number(el.attributes.strokeThickness ?? 1),
|
|
143
|
+
};
|
|
144
|
+
case "Text":
|
|
145
|
+
return {
|
|
146
|
+
type: "text",
|
|
147
|
+
position: parsePoint(el.attributes.position),
|
|
148
|
+
clockwiseRotationDegrees: el.attributes.clockwiseRotationDegrees
|
|
149
|
+
? Number(el.attributes.clockwiseRotationDegrees)
|
|
150
|
+
: 0,
|
|
151
|
+
textColor: (0, color_js_1.fromString2)(el.attributes.textColor ?? "", color_js_1.black),
|
|
152
|
+
strokeColor: (0, color_js_1.fromString2)(el.attributes.strokeColor ?? "", color_js_1.transparent),
|
|
153
|
+
text: el.attributes.text?.toString() ?? "",
|
|
154
|
+
id: el.attributes.id,
|
|
155
|
+
fontFamily: el.attributes.fontFamily ?? "",
|
|
156
|
+
fontSize: el.attributes.fontSize ? Number(el.attributes.fontSize ?? 1) : 12,
|
|
157
|
+
strokeThickness: el.attributes.strokeThickness ? Number(el.attributes.strokeThickness) : 2,
|
|
158
|
+
textAlignment: el.attributes.textAlignment ?? "center",
|
|
159
|
+
verticalGrowthDirection: el.attributes.verticalGrowthDirection ?? "down",
|
|
160
|
+
fontWeight: el.attributes.fontWeight ?? "normal",
|
|
161
|
+
horizontalGrowthDirection: el.attributes.horizontalGrowthDirection ?? "right",
|
|
162
|
+
italic: Boolean(el.attributes.italic ?? false),
|
|
163
|
+
};
|
|
164
|
+
default:
|
|
165
|
+
throw new Error(`Could not find creator for element with name ${el.tagName}`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
exports.parsedXsd = (0, handlebars_xml_1.parseXsd)(dynamic_image_xsd_js_1.xsd);
|
|
169
|
+
function parsePoint(pointString) {
|
|
170
|
+
const [xString, yString] = (typeof pointString === "number" ? pointString.toString() : pointString)?.split(" ") ?? [
|
|
171
|
+
0, 0,
|
|
172
|
+
];
|
|
173
|
+
const [x, y] = [Number(xString ?? 0), Number(yString ?? 0)];
|
|
174
|
+
return { x: Number.isFinite(x) ? x : 0, y: Number.isFinite(y) ? y : 0 };
|
|
175
|
+
}
|
|
176
|
+
function parsePointsString(numberArrayString) {
|
|
177
|
+
return ((typeof numberArrayString === "number" ? numberArrayString.toString() : numberArrayString)
|
|
178
|
+
?.split(" ")
|
|
179
|
+
.map((tuple) => {
|
|
180
|
+
const [xString, yString] = tuple.split(",");
|
|
181
|
+
return { x: Number(xString ?? 0), y: Number(yString ?? 0) };
|
|
182
|
+
}) ?? []);
|
|
183
|
+
}
|
|
184
|
+
function parseNumberArrayString(numberArrayString) {
|
|
185
|
+
return ((typeof numberArrayString === "number" ? numberArrayString.toString() : numberArrayString)
|
|
186
|
+
?.split(",")
|
|
187
|
+
.map(Number) ?? []);
|
|
188
|
+
}
|
|
189
|
+
//# sourceMappingURL=dynamic-image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3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AE,CAAC,CAAC,CAAC,iBAAiB,CAAC;QACxF,EAAE,KAAK,CAAC,GAAG,CAAC;SACX,GAAG,CAAC,CAAC,KAAK,EAAS,EAAE;QACpB,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,CAAC,OAAO,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,OAAO,IAAI,CAAC,CAAC,EAAE,CAAC;IAC9D,CAAC,CAAC,IAAI,EAAE,CACX,CAAC;AACJ,CAAC;AAED,SAAS,sBAAsB,CAAC,iBAA8C;IAC5E,OAAO,CACL,CAAC,OAAO,iBAAiB,KAAK,QAAQ,CAAC,CAAC,CAAC,iBAAiB,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,iBAAiB,CAAC;QACxF,EAAE,KAAK,CAAC,GAAG,CAAC;SACX,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CACrB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dynamic-image/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./dynamic-image.js"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dynamic-image/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export * from "./exporters/png-export-image.js";
|
|
|
9
9
|
export * from "./exporters/dxf2d-export-image.js";
|
|
10
10
|
export * from "./exporters/react-svg-export-image.js";
|
|
11
11
|
export * from "./exporters/eps-export-image.js";
|
|
12
|
-
export * from "./
|
|
12
|
+
export * from "./dynamic-image/index.js";
|
|
13
13
|
export * from "./stringify-parse.js";
|
|
14
14
|
export * from "./replace-extract-urls.js";
|
|
15
15
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iCAAiC,CAAC;AAChD,cAAc,iCAAiC,CAAC;AAChD,cAAc,mCAAmC,CAAC;AAClD,cAAc,uCAAuC,CAAC;AACtD,cAAc,iCAAiC,CAAC;AAChD,cAAc
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iCAAiC,CAAC;AAChD,cAAc,iCAAiC,CAAC;AAChD,cAAc,mCAAmC,CAAC;AAClD,cAAc,uCAAuC,CAAC;AACtD,cAAc,iCAAiC,CAAC;AAChD,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -25,7 +25,7 @@ __exportStar(require("./exporters/png-export-image.js"), exports);
|
|
|
25
25
|
__exportStar(require("./exporters/dxf2d-export-image.js"), exports);
|
|
26
26
|
__exportStar(require("./exporters/react-svg-export-image.js"), exports);
|
|
27
27
|
__exportStar(require("./exporters/eps-export-image.js"), exports);
|
|
28
|
-
__exportStar(require("./
|
|
28
|
+
__exportStar(require("./dynamic-image/index.js"), exports);
|
|
29
29
|
__exportStar(require("./stringify-parse.js"), exports);
|
|
30
30
|
__exportStar(require("./replace-extract-urls.js"), exports);
|
|
31
31
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAA0C;AAC1C,mDAAiC;AACjC,uDAAqC;AACrC,mDAAiC;AACjC,kDAAgC;AAChC,wDAAsC;AACtC,kEAAgD;AAChD,kEAAgD;AAChD,oEAAkD;AAClD,wEAAsD;AACtD,kEAAgD;AAChD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAA0C;AAC1C,mDAAiC;AACjC,uDAAqC;AACrC,mDAAiC;AACjC,kDAAgC;AAChC,wDAAsC;AACtC,kEAAgD;AAChD,kEAAgD;AAChD,oEAAkD;AAClD,wEAAsD;AACtD,kEAAgD;AAChD,2DAAyC;AACzC,uDAAqC;AACrC,4DAA0C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "abstract-image",
|
|
3
|
-
"version": "11.2.
|
|
3
|
+
"version": "11.2.2",
|
|
4
4
|
"description": "Dynamically create images using code or JSX and render to any format",
|
|
5
5
|
"repository": "https://github.com/dividab/abstract-visuals/tree/master/packages/abstract-image",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"vite": "^6.0.1",
|
|
35
35
|
"vitest": "^2.1.6"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "b1b5389a0490ff09c8a3efd2f7658c901f8e99a1"
|
|
38
38
|
}
|
|
@@ -16,28 +16,26 @@ import {
|
|
|
16
16
|
TextAlignment,
|
|
17
17
|
} from "../model/component.js";
|
|
18
18
|
import { Point } from "../model/point.js";
|
|
19
|
-
import { xsd } from "./
|
|
19
|
+
import { xsd } from "./dynamic-image-xsd.js";
|
|
20
20
|
|
|
21
|
-
type
|
|
22
|
-
type Ok<TValue> = { readonly type: "Ok"; readonly value: TValue };
|
|
23
|
-
type Err<TError> = { readonly type: "Err"; readonly error: TError };
|
|
24
|
-
|
|
25
|
-
export type AbstractImageXmlError =
|
|
21
|
+
export type DynamicImageError =
|
|
26
22
|
| { type: "HANDLEBARS_PARSE_ERROR"; message: string; cause?: unknown }
|
|
27
23
|
| { type: "XML_PARSE_ERROR"; message: string; cause?: unknown }
|
|
28
24
|
| { type: "UNKNOWN_ERROR"; message: string; cause?: unknown };
|
|
29
25
|
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
26
|
+
export function dynamicImage(
|
|
27
|
+
template: string,
|
|
28
|
+
data: unknown
|
|
29
|
+
):
|
|
30
|
+
| { readonly type: "Ok"; readonly image: AbstractImage; readonly imageUrls: ReadonlyArray<string> }
|
|
31
|
+
| { readonly type: "Err"; readonly error: DynamicImageError } {
|
|
35
32
|
try {
|
|
36
33
|
const [parsedXml] = parseHandlebarsXml(template, data, {});
|
|
37
34
|
|
|
38
35
|
try {
|
|
39
|
-
const
|
|
40
|
-
|
|
36
|
+
const mutableImageUrls = Array<string>();
|
|
37
|
+
const abstractImage = dynamicImageInternal(parsedXml, mutableImageUrls) as AbstractImage;
|
|
38
|
+
return { type: "Ok", image: abstractImage, imageUrls: mutableImageUrls };
|
|
41
39
|
} catch (error) {
|
|
42
40
|
return {
|
|
43
41
|
type: "Err",
|
|
@@ -60,12 +58,16 @@ export function abstractImageXml(template: string, data: unknown): Result<Abstra
|
|
|
60
58
|
}
|
|
61
59
|
}
|
|
62
60
|
|
|
63
|
-
|
|
61
|
+
function errorMessage(error: unknown): string {
|
|
62
|
+
return error instanceof Error ? error.message : String(error);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function dynamicImageInternal(el: XmlElement, mutableImageUrls: Array<string>): unknown {
|
|
64
66
|
const children = Array<Component>();
|
|
65
67
|
const childElements = Array<XmlElement>();
|
|
66
68
|
for (const child of el.children ?? []) {
|
|
67
69
|
if (child.tagName !== undefined) {
|
|
68
|
-
children.push(
|
|
70
|
+
children.push(dynamicImageInternal(child, mutableImageUrls) as Component);
|
|
69
71
|
childElements.push(child);
|
|
70
72
|
}
|
|
71
73
|
}
|
|
@@ -86,6 +88,9 @@ export function abstractImageOfXml(el: XmlElement): unknown {
|
|
|
86
88
|
children: children,
|
|
87
89
|
} satisfies Group;
|
|
88
90
|
case "Image":
|
|
91
|
+
if (typeof el.attributes.url === "string") {
|
|
92
|
+
mutableImageUrls.push(el.attributes.url);
|
|
93
|
+
}
|
|
89
94
|
return {
|
|
90
95
|
type: "binaryimage",
|
|
91
96
|
topLeft: parsePoint(el.attributes.topLeft),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./dynamic-image.js";
|
package/src/index.ts
CHANGED
|
@@ -9,6 +9,6 @@ export * from "./exporters/png-export-image.js";
|
|
|
9
9
|
export * from "./exporters/dxf2d-export-image.js";
|
|
10
10
|
export * from "./exporters/react-svg-export-image.js";
|
|
11
11
|
export * from "./exporters/eps-export-image.js";
|
|
12
|
-
export * from "./
|
|
12
|
+
export * from "./dynamic-image/index.js";
|
|
13
13
|
export * from "./stringify-parse.js";
|
|
14
14
|
export * from "./replace-extract-urls.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./abstract-image-xml.js";
|
/package/src/{abstract-image-xml/abstract-image-xsd.xml → dynamic-image/dynamic-image-xsd.xml}
RENAMED
|
File without changes
|