@aurigma/design-atoms-model 6.5.30 → 6.5.33
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/ColorsNew/CmykColor.d.ts +17 -0
- package/ColorsNew/CmykColor.js +71 -0
- package/ColorsNew/CmykColor.js.map +1 -0
- package/ColorsNew/Color.d.ts +7 -0
- package/ColorsNew/Color.js +23 -0
- package/ColorsNew/Color.js.map +1 -0
- package/ColorsNew/GrayscaleColor.d.ts +11 -0
- package/ColorsNew/GrayscaleColor.js +50 -0
- package/ColorsNew/GrayscaleColor.js.map +1 -0
- package/ColorsNew/Ink.d.ts +18 -0
- package/ColorsNew/Ink.js +50 -0
- package/ColorsNew/Ink.js.map +1 -0
- package/ColorsNew/Palette.d.ts +4 -0
- package/ColorsNew/Palette.js +23 -0
- package/ColorsNew/Palette.js.map +1 -0
- package/ColorsNew/ProcessColor.d.ts +10 -0
- package/ColorsNew/ProcessColor.js +49 -0
- package/ColorsNew/ProcessColor.js.map +1 -0
- package/ColorsNew/RgbColor.d.ts +15 -0
- package/ColorsNew/RgbColor.js +64 -0
- package/ColorsNew/RgbColor.js.map +1 -0
- package/ColorsNew/SpotColor.d.ts +15 -0
- package/ColorsNew/SpotColor.js +68 -0
- package/ColorsNew/SpotColor.js.map +1 -0
- package/ColorsNew/Swatch.d.ts +8 -0
- package/ColorsNew/Swatch.js +40 -0
- package/ColorsNew/Swatch.js.map +1 -0
- package/ColorsNew/index.d.ts +9 -0
- package/ColorsNew/index.js +10 -0
- package/ColorsNew/index.js.map +1 -0
- package/Configuration.d.ts +0 -4
- package/Configuration.js +0 -8
- package/Configuration.js.map +1 -1
- package/Product/Convert/index.d.ts +1 -0
- package/Product/Convert/index.js +2 -0
- package/Product/Convert/index.js.map +1 -0
- package/Product/Decorators/index.d.ts +4 -0
- package/Product/Decorators/index.js +5 -0
- package/Product/Decorators/index.js.map +1 -0
- package/Product/Items/BarcodeData.d.ts +1 -0
- package/Product/Items/BarcodeData.js +2 -0
- package/Product/Items/BarcodeData.js.map +1 -1
- package/Product/Items/BarcodeItem.js +6 -0
- package/Product/Items/BarcodeItem.js.map +1 -1
- package/Product/Items/BarcodeSubType.d.ts +2 -1
- package/Product/Items/BarcodeSubType.js +1 -0
- package/Product/Items/BarcodeSubType.js.map +1 -1
- package/Product/ItemsData/index.d.ts +4 -1
- package/Product/ItemsData/index.js +4 -1
- package/Product/ItemsData/index.js.map +1 -1
- package/Product/Product.d.ts +4 -1
- package/Product/Product.js +5 -3
- package/Product/Product.js.map +1 -1
- package/Product/index.d.ts +7 -2
- package/Product/index.js +6 -2
- package/Product/index.js.map +1 -1
- package/Serialization/IProductSerializer.d.ts +3 -0
- package/Serialization/IProductSerializer.js +1 -0
- package/Serialization/IProductSerializer.js.map +1 -0
- package/Utils/Utils.d.ts +1 -2
- package/Utils/Utils.js +7 -6
- package/Utils/Utils.js.map +1 -1
- package/Utils/index.d.ts +4 -0
- package/Utils/index.js +5 -0
- package/Utils/index.js.map +1 -0
- package/Version.d.ts +1 -1
- package/Version.js +1 -1
- package/index.d.ts +8 -0
- package/index.js +10 -0
- package/index.js.map +1 -0
- package/package.json +1 -1
- package/Product/Serializer/AdditionalConverter.d.ts +0 -6
- package/Product/Serializer/AdditionalConverter.js +0 -10
- package/Product/Serializer/AdditionalConverter.js.map +0 -1
- package/Product/Serializer/JsonProductSerializer.d.ts +0 -12
- package/Product/Serializer/JsonProductSerializer.js +0 -77
- package/Product/Serializer/JsonProductSerializer.js.map +0 -1
- package/Product/Serializer/ProductParser.d.ts +0 -112
- package/Product/Serializer/ProductParser.js +0 -765
- package/Product/Serializer/ProductParser.js.map +0 -1
|
@@ -1,765 +0,0 @@
|
|
|
1
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
2
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
3
|
-
if (!m) return o;
|
|
4
|
-
var i = m.call(o), r, ar = [], e;
|
|
5
|
-
try {
|
|
6
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
7
|
-
}
|
|
8
|
-
catch (error) { e = { error: error }; }
|
|
9
|
-
finally {
|
|
10
|
-
try {
|
|
11
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
12
|
-
}
|
|
13
|
-
finally { if (e) throw e.error; }
|
|
14
|
-
}
|
|
15
|
-
return ar;
|
|
16
|
-
};
|
|
17
|
-
var __spread = (this && this.__spread) || function () {
|
|
18
|
-
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
|
|
19
|
-
return ar;
|
|
20
|
-
};
|
|
21
|
-
import { Product } from "../Product";
|
|
22
|
-
import { Surface } from "../Surface";
|
|
23
|
-
import { SurfaceMockup } from "../SurfaceMockup";
|
|
24
|
-
import * as _ from "underscore";
|
|
25
|
-
import { MockupContainer, Container, SurfaceContainer, SpotColorContainer, TextureContainer } from "../Container";
|
|
26
|
-
import { SizeF, RectangleF, PointF, Path, RotatedRectangleF } from "../../Math/index";
|
|
27
|
-
import { SafetyLine } from "../SafetyLine";
|
|
28
|
-
import { CropMark, CropMarkText } from "../CropMark";
|
|
29
|
-
import { PrintArea } from "../PrintArea";
|
|
30
|
-
import { ItemMask } from "../ItemMask";
|
|
31
|
-
import { RectangleItem, EllipseItem, ShapeItem, BaseTextItem, PlainTextItem, ImageItem, BoundedTextItem, CurvedTextItem, PathBoundedTextItem, BarcodeItem, PlaceholderItem, LineItem, DashedLineItem, AutoScaledTextItem, ThemeBinding, SmartItem, InStringPlaceholder, ImageMetaData, OverlayEffect, GroupItem, ArchedTextItem, EncodingOptions, LayoutItem } from "../Items";
|
|
32
|
-
import { NotImplementedException, Exception } from "../../Exception";
|
|
33
|
-
import { ColorFactory } from "../../Colors";
|
|
34
|
-
import { Transform } from "../../Math/Transform";
|
|
35
|
-
import { ManipulationPermissions, ContentPermissions, BarcodePermissions, TextPermissions, ImagePermissions, ItemPermissions, ItemToolbarPermissions, FrontendPermissions, ResizeGripsPermissions, ShapePermissions, PathBoundedTextPermissions, PlaceholderPermissions, VisualizationPermissions, LinePermissions } from "../Items";
|
|
36
|
-
import { ParagraphSettings } from "../Items/ParagraphSettings";
|
|
37
|
-
import { StrokeSettings } from "../Items/StrokeSettings";
|
|
38
|
-
import { ShadowSettings } from "../Items/ShadowSettings";
|
|
39
|
-
import { MODELVERSION } from "../../Version";
|
|
40
|
-
import { Collection } from "../../Collection";
|
|
41
|
-
import { WatermarkConfig, WatermarkTextConfig, WatermarkImageConfig, WatermarkVisibilityConfig } from "../../Configuration/WatermarkConfig";
|
|
42
|
-
import { Watermark } from "..";
|
|
43
|
-
import { GroupItemPermissions } from "../Items/GroupItemPermissions";
|
|
44
|
-
import { ClipartItem, ColorGroup } from "../Items/ClipartItem";
|
|
45
|
-
import { Margin } from "../../Math/Margin";
|
|
46
|
-
import { DefaultLayoutSettings, AutoLayoutSettings } from "../Items/LayoutItem";
|
|
47
|
-
import { ViolationSettings } from "../Items/ViolationSettings";
|
|
48
|
-
import { ShapeViolationSettings } from "../Items/ShapeViolationSettings";
|
|
49
|
-
import { ImageViolationSettings } from "../Items/ImageViolationSettings";
|
|
50
|
-
import { TextViolationSettings } from "../Items/TextViolationSettings";
|
|
51
|
-
var ProductParser = /** @class */ (function () {
|
|
52
|
-
function ProductParser(additionalConverters) {
|
|
53
|
-
var _this = this;
|
|
54
|
-
this.parseSurface = function (rawSurface) {
|
|
55
|
-
var surface = new Surface();
|
|
56
|
-
_this._parseModelComponent(rawSurface, surface, [
|
|
57
|
-
new PropertyConverter("mockup", _this.parseMockup.bind(_this)),
|
|
58
|
-
new PropertyConverter("printAreas", function (rawContainers) { return _this.parseCollection(rawContainers, _this.parsePrintArea, surface.printAreas); }, true),
|
|
59
|
-
new PropertyConverter("containers", function (rawContainers) { return _this.parseCollection(rawContainers, _this.parseSurfaceContainer, surface.containers); }, true),
|
|
60
|
-
new PropertyConverter("previewMockups", function (rawContainers) { return _this.parseCollection(rawContainers, _this.parseMockup.bind(_this), surface.previewMockups); }, true),
|
|
61
|
-
new PropertyConverter("watermark", _this.parseWatermark.bind(_this))
|
|
62
|
-
]);
|
|
63
|
-
return surface;
|
|
64
|
-
};
|
|
65
|
-
this.parseMockupContainer = function (rawContainer) {
|
|
66
|
-
var container = new MockupContainer();
|
|
67
|
-
_this.parseContainer(rawContainer, container);
|
|
68
|
-
return container;
|
|
69
|
-
};
|
|
70
|
-
//TODO next release
|
|
71
|
-
//parsePrintAreaContainer = (rawContainer: Object) => {
|
|
72
|
-
// var container = new PrintAreaContainer();
|
|
73
|
-
// this.parseContainer(rawContainer, container);
|
|
74
|
-
// return container;
|
|
75
|
-
//}
|
|
76
|
-
this.parseSurfaceContainer = function (rawContainer) {
|
|
77
|
-
var container;
|
|
78
|
-
var type = rawContainer["type"];
|
|
79
|
-
delete rawContainer["type"];
|
|
80
|
-
switch (type) {
|
|
81
|
-
case "SpotColorContainer":
|
|
82
|
-
container = new SpotColorContainer();
|
|
83
|
-
_this.parseContainer(rawContainer, container);
|
|
84
|
-
delete rawContainer["version"];
|
|
85
|
-
delete rawContainer["items"];
|
|
86
|
-
Object.assign(container, rawContainer);
|
|
87
|
-
break;
|
|
88
|
-
case "TextureContainer":
|
|
89
|
-
container = new TextureContainer();
|
|
90
|
-
_this.parseContainer(rawContainer, container);
|
|
91
|
-
container.previewTextureSource = _this.parseImageSource(rawContainer["previewTextureSource"]);
|
|
92
|
-
delete rawContainer["previewTextureSource"];
|
|
93
|
-
delete rawContainer["version"];
|
|
94
|
-
delete rawContainer["items"];
|
|
95
|
-
Object.assign(container, rawContainer);
|
|
96
|
-
break;
|
|
97
|
-
default:
|
|
98
|
-
container = new SurfaceContainer();
|
|
99
|
-
_this.parseContainer(rawContainer, container);
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
102
|
-
return container;
|
|
103
|
-
};
|
|
104
|
-
this.parseContainer = function (rawContainer, emptyContainer) {
|
|
105
|
-
if (emptyContainer === void 0) { emptyContainer = new Container(); }
|
|
106
|
-
_this._parseModelComponent(rawContainer, emptyContainer, [
|
|
107
|
-
new PropertyConverter("region", _this.parseRectangleF.bind(_this)),
|
|
108
|
-
new PropertyConverter("size", _this.parseSizeF.bind(_this)),
|
|
109
|
-
new PropertyConverter("items", function (rawItems) { return _this.parseCollection(rawItems, _this.parseItem, emptyContainer.items); }, true)
|
|
110
|
-
]);
|
|
111
|
-
return emptyContainer;
|
|
112
|
-
};
|
|
113
|
-
this.parseSafetyLine = function (rawSafetyLine) {
|
|
114
|
-
var safetyLine = new SafetyLine();
|
|
115
|
-
var converters = [
|
|
116
|
-
new PropertyConverter("color", _this.parseColor.bind(_this)),
|
|
117
|
-
new PropertyConverter("altColor", _this.parseColor.bind(_this)),
|
|
118
|
-
new PropertyConverter("margin", _this._parseMargin)
|
|
119
|
-
];
|
|
120
|
-
_this._parseObject(rawSafetyLine, safetyLine, converters);
|
|
121
|
-
return safetyLine;
|
|
122
|
-
};
|
|
123
|
-
this.parseCropMark = function (rawCropMark) {
|
|
124
|
-
var cropMark = new CropMark();
|
|
125
|
-
var converters = [
|
|
126
|
-
new PropertyConverter("color", _this.parseColor.bind(_this)),
|
|
127
|
-
new PropertyConverter("leftNotes", _this._setConvertedArray.bind(_this, _this.parseCropMarkText, function (obj) { cropMark.leftNotes = obj; }), true),
|
|
128
|
-
new PropertyConverter("rightNotes", _this._setConvertedArray.bind(_this, _this.parseCropMarkText, function (obj) { cropMark.rightNotes = obj; }), true),
|
|
129
|
-
new PropertyConverter("topNotes", _this._setConvertedArray.bind(_this, _this.parseCropMarkText, function (obj) { cropMark.topNotes = obj; }), true),
|
|
130
|
-
new PropertyConverter("bottomNotes", _this._setConvertedArray.bind(_this, _this.parseCropMarkText, function (obj) { cropMark.bottomNotes = obj; }), true),
|
|
131
|
-
];
|
|
132
|
-
_this._parseObject(rawCropMark, cropMark, converters);
|
|
133
|
-
return cropMark;
|
|
134
|
-
};
|
|
135
|
-
this.parseCropMarkText = function (rawCropMarkText) {
|
|
136
|
-
var cropMarkText = new CropMarkText();
|
|
137
|
-
_this._parseObject(rawCropMarkText, cropMarkText, []);
|
|
138
|
-
return cropMarkText;
|
|
139
|
-
};
|
|
140
|
-
this.parsePrintArea = function (rawPrintArea) {
|
|
141
|
-
var printArea = new PrintArea();
|
|
142
|
-
_this._parseModelComponent(rawPrintArea, printArea, [
|
|
143
|
-
new PropertyConverter("bounds", _this.parseRectangleF.bind(_this)),
|
|
144
|
-
new PropertyConverter("safetyLines", function (rawLines) { return _this.parseCollection(rawLines, _this.parseSafetyLine, printArea.safetyLines); }, true),
|
|
145
|
-
new PropertyConverter("cropMarks", function (rawMarks) { return new Collection(rawMarks.map(_this.parseCropMark)); }),
|
|
146
|
-
new PropertyConverter("slug", _this._parseMargin),
|
|
147
|
-
new PropertyConverter("bleed", _this._parseMargin),
|
|
148
|
-
]);
|
|
149
|
-
return printArea;
|
|
150
|
-
};
|
|
151
|
-
this._parseMargin = function (rawMargin) {
|
|
152
|
-
if (rawMargin == null)
|
|
153
|
-
return new Margin(0);
|
|
154
|
-
return new Margin({
|
|
155
|
-
left: rawMargin["left"], top: rawMargin["top"], right: rawMargin["right"], bottom: rawMargin["bottom"]
|
|
156
|
-
});
|
|
157
|
-
};
|
|
158
|
-
this.parseItem = function (rawItem) {
|
|
159
|
-
if (rawItem == null)
|
|
160
|
-
return null;
|
|
161
|
-
var type = rawItem["$type"];
|
|
162
|
-
delete rawItem["$type"];
|
|
163
|
-
var converters = [
|
|
164
|
-
new PropertyConverter("pathBoundedTextPermissions", _this.parsePathBoundedTextPermissions.bind(_this)),
|
|
165
|
-
new PropertyConverter("manipulationPermissions", _this.parseManipulationPermissions.bind(_this)),
|
|
166
|
-
new PropertyConverter("frontendPermissions", _this.parseFrontendPermissions.bind(_this)),
|
|
167
|
-
new PropertyConverter("visualizationPermissions", _this.parseVisualizationPermissions.bind(_this)),
|
|
168
|
-
new PropertyConverter("violationSettings", _this.parseViolationSettings),
|
|
169
|
-
new PropertyConverter("itemPermissions", _this.parseItemPermissions.bind(_this)),
|
|
170
|
-
new PropertyConverter("transform", _this.parseTransform.bind(_this)),
|
|
171
|
-
new PropertyConverter("color", _this.parseColor.bind(_this)),
|
|
172
|
-
new PropertyConverter("themeBinding", _this.parseThemeBinding.bind(_this)),
|
|
173
|
-
new PropertyConverter("mask", _this.parseMask.bind(_this))
|
|
174
|
-
];
|
|
175
|
-
var item = null;
|
|
176
|
-
var textConverters = converters.concat([
|
|
177
|
-
new PropertyConverter("textPermissions", _this.parseTextPermissions.bind(_this)),
|
|
178
|
-
new PropertyConverter("font", _this.parseFontSettings.bind(_this), true),
|
|
179
|
-
new PropertyConverter("stroke", _this.parseStrokeSettings.bind(_this)),
|
|
180
|
-
new PropertyConverter("shadow", _this.parseShadowSettings.bind(_this))
|
|
181
|
-
]);
|
|
182
|
-
if (type == null)
|
|
183
|
-
throw new Exception("Serialized data seems to be corrupted.");
|
|
184
|
-
switch (type) {
|
|
185
|
-
case SmartItem.type:
|
|
186
|
-
item = _this.parseSmartItem(rawItem);
|
|
187
|
-
break;
|
|
188
|
-
case RectangleItem.type:
|
|
189
|
-
item = _this.parseRectangleItem(rawItem, converters);
|
|
190
|
-
break;
|
|
191
|
-
case ShapeItem.type:
|
|
192
|
-
item = _this.parseShapeItem(rawItem, converters);
|
|
193
|
-
break;
|
|
194
|
-
case LineItem.type:
|
|
195
|
-
item = _this.parseLineItem(rawItem, converters);
|
|
196
|
-
break;
|
|
197
|
-
case DashedLineItem.type:
|
|
198
|
-
item = _this.parseDashedLineItem(rawItem, converters);
|
|
199
|
-
break;
|
|
200
|
-
case EllipseItem.type:
|
|
201
|
-
item = _this.parseEllipseItem(rawItem, converters);
|
|
202
|
-
break;
|
|
203
|
-
case ImageItem.type:
|
|
204
|
-
item = _this.parseImageItem(rawItem, converters);
|
|
205
|
-
break;
|
|
206
|
-
case BarcodeItem.type:
|
|
207
|
-
item = _this.parseBarcodeItem(rawItem, converters);
|
|
208
|
-
break;
|
|
209
|
-
case PlainTextItem.type:
|
|
210
|
-
item = _this.parsePlainTextItem(rawItem, textConverters);
|
|
211
|
-
break;
|
|
212
|
-
case BoundedTextItem.type:
|
|
213
|
-
item = _this.parseBoundedTextItem(rawItem, textConverters);
|
|
214
|
-
break;
|
|
215
|
-
case PathBoundedTextItem.type:
|
|
216
|
-
item = _this.parsePathBoundedTextItem(rawItem, textConverters);
|
|
217
|
-
break;
|
|
218
|
-
case CurvedTextItem.type:
|
|
219
|
-
item = _this.parseCurvedTextItem(rawItem, textConverters);
|
|
220
|
-
break;
|
|
221
|
-
case AutoScaledTextItem.type:
|
|
222
|
-
item = _this.parseAutoScaledTextItem(rawItem, textConverters);
|
|
223
|
-
break;
|
|
224
|
-
case ArchedTextItem.type:
|
|
225
|
-
item = _this.parseArchedTextItem(rawItem, textConverters);
|
|
226
|
-
break;
|
|
227
|
-
case PlaceholderItem.type:
|
|
228
|
-
item = _this.parsePlaceholderItem(rawItem, converters);
|
|
229
|
-
break;
|
|
230
|
-
case GroupItem.type:
|
|
231
|
-
item = _this.parseGroupItem(rawItem, converters);
|
|
232
|
-
break;
|
|
233
|
-
case ClipartItem.type:
|
|
234
|
-
item = _this.parseClipartItem(rawItem, converters);
|
|
235
|
-
break;
|
|
236
|
-
case LayoutItem.type:
|
|
237
|
-
item = _this.parseLayoutItem(rawItem, converters);
|
|
238
|
-
break;
|
|
239
|
-
default:
|
|
240
|
-
throw new NotImplementedException("Deserializing of item with type - " + type + " is not implemented");
|
|
241
|
-
}
|
|
242
|
-
return item;
|
|
243
|
-
};
|
|
244
|
-
this.parseEncodingOptions = function (raw) {
|
|
245
|
-
var result = new EncodingOptions();
|
|
246
|
-
_this._parseModelComponent(raw, result, []);
|
|
247
|
-
return result;
|
|
248
|
-
};
|
|
249
|
-
this.parseLineItem = function (rawLine, baseConverters) {
|
|
250
|
-
var line = new LineItem();
|
|
251
|
-
var converters = __spread(baseConverters, _this._getLineConverters());
|
|
252
|
-
_this._parseModelComponent(rawLine, line, converters);
|
|
253
|
-
return line;
|
|
254
|
-
};
|
|
255
|
-
this.parseRotatedRectangle = function (rawRectangle) {
|
|
256
|
-
return new RotatedRectangleF(rawRectangle["centerX"], rawRectangle["centerY"], rawRectangle["width"], rawRectangle["height"], rawRectangle["angle"]);
|
|
257
|
-
};
|
|
258
|
-
this.parseViolationSettings = function (rawPerms) {
|
|
259
|
-
delete rawPerms["version"];
|
|
260
|
-
switch (rawPerms["type"]) {
|
|
261
|
-
case ViolationSettings.type:
|
|
262
|
-
return Object.assign(new ViolationSettings(), rawPerms);
|
|
263
|
-
case ShapeViolationSettings.type:
|
|
264
|
-
return Object.assign(new ShapeViolationSettings(), rawPerms);
|
|
265
|
-
case ImageViolationSettings.type:
|
|
266
|
-
return Object.assign(new ImageViolationSettings(), rawPerms);
|
|
267
|
-
case TextViolationSettings.type:
|
|
268
|
-
return Object.assign(new TextViolationSettings(), rawPerms);
|
|
269
|
-
default:
|
|
270
|
-
throw new NotImplementedException("Deserializing of item with type - " + rawPerms["type"] + " is not implemented");
|
|
271
|
-
}
|
|
272
|
-
};
|
|
273
|
-
this.parsePlaceholderPermissions = function (rawPerms) {
|
|
274
|
-
return Object.assign(new PlaceholderPermissions(), rawPerms);
|
|
275
|
-
};
|
|
276
|
-
this.parseLayoutSettings = function (rawPerms) {
|
|
277
|
-
var layoutSettings;
|
|
278
|
-
switch (rawPerms["type"]) {
|
|
279
|
-
case AutoLayoutSettings.type:
|
|
280
|
-
layoutSettings = new AutoLayoutSettings();
|
|
281
|
-
break;
|
|
282
|
-
default:
|
|
283
|
-
layoutSettings = new DefaultLayoutSettings();
|
|
284
|
-
break;
|
|
285
|
-
}
|
|
286
|
-
return Object.assign(layoutSettings, rawPerms);
|
|
287
|
-
};
|
|
288
|
-
this.parseGroupItemPermissions = function (rawPerms) {
|
|
289
|
-
return Object.assign(new GroupItemPermissions(), rawPerms);
|
|
290
|
-
};
|
|
291
|
-
this.parseLinePermissions = function (rawPerms) {
|
|
292
|
-
return Object.assign(new LinePermissions(), rawPerms);
|
|
293
|
-
};
|
|
294
|
-
this.parseBarcodePermissions = function (rawPerms) {
|
|
295
|
-
return Object.assign(new BarcodePermissions(), rawPerms);
|
|
296
|
-
};
|
|
297
|
-
this._parseOverlayEffect = function (value) {
|
|
298
|
-
if (value != null)
|
|
299
|
-
return new OverlayEffect({
|
|
300
|
-
color: value["color"] != null ? _this.parseColor(value["color"]) : null,
|
|
301
|
-
opacity: value["opacity"] != null ? value["opacity"] : null,
|
|
302
|
-
blendMode: value["blendMode"] != null ? value["blendMode"] : null
|
|
303
|
-
});
|
|
304
|
-
};
|
|
305
|
-
this._parseImageItemValue = function (value) {
|
|
306
|
-
return new ImageItem.ImageItemValue(value["name"], new ImageItem.ImageMetaData(value["value"]), _this.parseRotatedRectangle(value["transformedRectangle"]));
|
|
307
|
-
};
|
|
308
|
-
this._parseTextItemValue = function (value) {
|
|
309
|
-
return new BaseTextItem.BaseTextValue(value["name"], value["text"]);
|
|
310
|
-
};
|
|
311
|
-
this._parseObject = function (rawObject, destObject, converters) {
|
|
312
|
-
for (var propertyName in rawObject)
|
|
313
|
-
if (rawObject.hasOwnProperty(propertyName)) {
|
|
314
|
-
var converter = converters.find(function (c) { return c.property === propertyName; });
|
|
315
|
-
var rawValue = rawObject[propertyName];
|
|
316
|
-
if (converter == null) {
|
|
317
|
-
if (_.isObject(rawValue)) {
|
|
318
|
-
var type = rawValue["$type"];
|
|
319
|
-
delete rawValue["$type"];
|
|
320
|
-
if (_.isString(type)) {
|
|
321
|
-
var typeConverter = _.find(_this._additionalConverters, function (converterBound) { return (converterBound.type === type); });
|
|
322
|
-
if (typeConverter != null) {
|
|
323
|
-
destObject[propertyName] = typeConverter.parseRawValue(rawValue);
|
|
324
|
-
continue;
|
|
325
|
-
}
|
|
326
|
-
else
|
|
327
|
-
console.warn("Unknown type " + type);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
destObject[propertyName] = rawValue;
|
|
331
|
-
continue;
|
|
332
|
-
}
|
|
333
|
-
if (converter.setByConverter) {
|
|
334
|
-
try {
|
|
335
|
-
converter.convert(rawValue, destObject);
|
|
336
|
-
}
|
|
337
|
-
catch (ex) {
|
|
338
|
-
console.error("Error while parsing property " + propertyName + " with converter ", converter, ex);
|
|
339
|
-
throw ex;
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
else {
|
|
343
|
-
if (propertyName === "manipulationPermissions" && destObject instanceof GroupItem) {
|
|
344
|
-
destObject["groupManipulationPermissions"] = converter.convert(rawValue);
|
|
345
|
-
continue;
|
|
346
|
-
}
|
|
347
|
-
destObject[propertyName] = converter.convert(rawValue);
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
};
|
|
351
|
-
/*
|
|
352
|
-
TODO: it crushes an insertion of psd when downloadPsdAsImage=false
|
|
353
|
-
const defaultConverters = [
|
|
354
|
-
new Model.AdditionalConverter(
|
|
355
|
-
"CustomersCanvas.Core.Model.PrintAreaContainer, CustomersCanvas.Core",
|
|
356
|
-
this.parsePrintAreaContainer.bind(this),
|
|
357
|
-
PrintAreaContainer),
|
|
358
|
-
new Model.AdditionalConverter(
|
|
359
|
-
"CustomersCanvas.Core.Model.PrintArea, CustomersCanvas.Core",
|
|
360
|
-
this.parsePrintArea.bind(this),
|
|
361
|
-
PrintArea)
|
|
362
|
-
];
|
|
363
|
-
this._additionalConverters = additionalConverters != null ? additionalConverters.concat(defaultConverters) : defaultConverters;
|
|
364
|
-
*/
|
|
365
|
-
this._additionalConverters = additionalConverters != null ? additionalConverters : [];
|
|
366
|
-
}
|
|
367
|
-
//#region public methods
|
|
368
|
-
ProductParser.prototype.parseProduct = function (rawProduct) {
|
|
369
|
-
var _this = this;
|
|
370
|
-
var product = new Product();
|
|
371
|
-
var productConverters = [
|
|
372
|
-
new PropertyConverter("surfaces", function (rawSurfaces) { return _this.parseCollection(rawSurfaces, _this.parseSurface, product.surfaces); }, true),
|
|
373
|
-
new PropertyConverter("watermarkConfig", this.parseWatermarkConfig.bind(this)),
|
|
374
|
-
new PropertyConverter("defaultSafetyLines", function (rawLines) { return _this.parseCollection(rawLines, _this.parseSafetyLine, product.defaultSafetyLines); }, true),
|
|
375
|
-
new PropertyConverter("defaultCropMarks", function (rawMarks) { return _this.parseCollection(rawMarks, _this.parseCropMark, product.defaultCropMarks); }, true),
|
|
376
|
-
new PropertyConverter("defaultDesignLocation", this.parsePointF.bind(this))
|
|
377
|
-
];
|
|
378
|
-
this._parseModelComponent(rawProduct, product, productConverters);
|
|
379
|
-
return product;
|
|
380
|
-
};
|
|
381
|
-
ProductParser.prototype.parseWatermarkConfig = function (rawConfig) {
|
|
382
|
-
var _this = this;
|
|
383
|
-
if (rawConfig == null)
|
|
384
|
-
return null;
|
|
385
|
-
var config = new WatermarkConfig();
|
|
386
|
-
var parseFontSettings = new PropertyConverter("fontSettings", (function (rawFontSettings) {
|
|
387
|
-
if (rawFontSettings == null)
|
|
388
|
-
return null;
|
|
389
|
-
var fontSettings = new BaseTextItem.FontSettings(null);
|
|
390
|
-
_this._parseObject(rawFontSettings, fontSettings, []);
|
|
391
|
-
return fontSettings;
|
|
392
|
-
}));
|
|
393
|
-
var parseWatermarkTextConfig = new PropertyConverter("text", (function (rawText) {
|
|
394
|
-
if (rawText == null)
|
|
395
|
-
return null;
|
|
396
|
-
var text = new WatermarkTextConfig();
|
|
397
|
-
_this._parseObject(rawText, text, [parseFontSettings]);
|
|
398
|
-
return text;
|
|
399
|
-
}));
|
|
400
|
-
var parseWatermarkImageConfig = new PropertyConverter("image", (function (rawImage) {
|
|
401
|
-
if (rawImage == null)
|
|
402
|
-
return null;
|
|
403
|
-
var image = new WatermarkImageConfig();
|
|
404
|
-
_this._parseObject(rawImage, image, []);
|
|
405
|
-
return image;
|
|
406
|
-
}));
|
|
407
|
-
var parseWatermarkVisibilityConfig = new PropertyConverter("visibility", (function (rawVisibility) {
|
|
408
|
-
if (rawVisibility == null)
|
|
409
|
-
return null;
|
|
410
|
-
var visibility = new WatermarkVisibilityConfig();
|
|
411
|
-
_this._parseObject(rawVisibility, visibility, []);
|
|
412
|
-
return visibility;
|
|
413
|
-
}));
|
|
414
|
-
this._parseObject(rawConfig, config, [parseWatermarkTextConfig, parseWatermarkImageConfig, parseWatermarkVisibilityConfig]);
|
|
415
|
-
return config;
|
|
416
|
-
};
|
|
417
|
-
ProductParser.prototype.parseWatermark = function (rawWatermark) {
|
|
418
|
-
if (rawWatermark == null)
|
|
419
|
-
return null;
|
|
420
|
-
var watermark = new Watermark();
|
|
421
|
-
this._parseObject(rawWatermark, watermark, []);
|
|
422
|
-
return watermark;
|
|
423
|
-
};
|
|
424
|
-
ProductParser.prototype.parseMockup = function (rawMockup) {
|
|
425
|
-
var _this = this;
|
|
426
|
-
var mockup = new SurfaceMockup();
|
|
427
|
-
this._parseModelComponent(rawMockup, mockup, [
|
|
428
|
-
new PropertyConverter("underContainers", function (rawContainers) { return _this.parseCollection(rawContainers, _this.parseMockupContainer, mockup.underContainers); }, true),
|
|
429
|
-
new PropertyConverter("overContainers", function (rawContainers) { return _this.parseCollection(rawContainers, _this.parseMockupContainer, mockup.overContainers); }, true)
|
|
430
|
-
]);
|
|
431
|
-
return mockup;
|
|
432
|
-
};
|
|
433
|
-
ProductParser.prototype.parseCollection = function (rawCollection, parseCollectionItem, targetCollection) {
|
|
434
|
-
/*if (rawCollection instanceof Collection)
|
|
435
|
-
targetCollection.setRange(rawCollection.select(i => parseCollectionItem(i)));
|
|
436
|
-
else*/
|
|
437
|
-
if (rawCollection != null)
|
|
438
|
-
targetCollection.setRange(rawCollection.map(function (rawColItem) { return parseCollectionItem(rawColItem); }));
|
|
439
|
-
};
|
|
440
|
-
ProductParser.prototype.parseRectangleF = function (rawRectangle) {
|
|
441
|
-
if (rawRectangle == null)
|
|
442
|
-
return null;
|
|
443
|
-
return new RectangleF(rawRectangle["left"], rawRectangle["top"], rawRectangle["width"], rawRectangle["height"]);
|
|
444
|
-
};
|
|
445
|
-
ProductParser.prototype.parsePointF = function (rawPoint) {
|
|
446
|
-
if (rawPoint == null)
|
|
447
|
-
return null;
|
|
448
|
-
var pointF = new PointF();
|
|
449
|
-
Object.assign(pointF, rawPoint);
|
|
450
|
-
return pointF;
|
|
451
|
-
};
|
|
452
|
-
ProductParser.prototype.parseSizeF = function (rawSize) {
|
|
453
|
-
if (rawSize == null)
|
|
454
|
-
return null;
|
|
455
|
-
//TODO: use server-side JsonConverter
|
|
456
|
-
if (_.isString(rawSize)) {
|
|
457
|
-
var values = rawSize.split(",");
|
|
458
|
-
return new SizeF(parseFloat(values[0].trim()), parseFloat(values[1].trim()));
|
|
459
|
-
}
|
|
460
|
-
else
|
|
461
|
-
return _.extend(new SizeF(), rawSize);
|
|
462
|
-
};
|
|
463
|
-
ProductParser.prototype.parsePath = function (rawPath) {
|
|
464
|
-
if (rawPath == null)
|
|
465
|
-
return null;
|
|
466
|
-
if (typeof rawPath === "string")
|
|
467
|
-
return new Path(rawPath);
|
|
468
|
-
return new Path(rawPath["path"]);
|
|
469
|
-
};
|
|
470
|
-
ProductParser.prototype.parsePaths = function (rawPaths) {
|
|
471
|
-
var _this = this;
|
|
472
|
-
if (rawPaths == null || !_.isArray(rawPaths))
|
|
473
|
-
return null;
|
|
474
|
-
var paths = [];
|
|
475
|
-
_.toArray(rawPaths).forEach(function (v) {
|
|
476
|
-
paths.push(_this.parsePath(v));
|
|
477
|
-
});
|
|
478
|
-
return paths;
|
|
479
|
-
};
|
|
480
|
-
ProductParser.prototype.parseSmartItem = function (rawSmartItem) {
|
|
481
|
-
var smartItem = new SmartItem();
|
|
482
|
-
this._parseModelComponent(rawSmartItem, smartItem, []);
|
|
483
|
-
return smartItem;
|
|
484
|
-
};
|
|
485
|
-
ProductParser.prototype.parsePlainTextItem = function (rawPlainText, baseConverters) {
|
|
486
|
-
var plainTextItem = new PlainTextItem();
|
|
487
|
-
var converters = baseConverters.concat(this._getShapeConverters(), this._getBaseTextItemConverters(plainTextItem), [new PropertyConverter("baselineLocation", this.parsePointF.bind(this))]);
|
|
488
|
-
this._parseModelComponent(rawPlainText, plainTextItem, converters);
|
|
489
|
-
return plainTextItem;
|
|
490
|
-
};
|
|
491
|
-
ProductParser.prototype.parseArchedTextItem = function (rawArchedText, baseConverters) {
|
|
492
|
-
var archedTextItem = new ArchedTextItem();
|
|
493
|
-
var converters = baseConverters.concat(this._getShapeConverters(), this._getBaseTextItemConverters(archedTextItem), [new PropertyConverter("center", this.parsePointF.bind(this))]);
|
|
494
|
-
this._parseModelComponent(rawArchedText, archedTextItem, converters);
|
|
495
|
-
return archedTextItem;
|
|
496
|
-
};
|
|
497
|
-
ProductParser.prototype.parseAutoScaledTextItem = function (rawAutoScaledText, baseConverters) {
|
|
498
|
-
var autoScaledTextItem = new AutoScaledTextItem();
|
|
499
|
-
var converters = baseConverters.concat(this._getShapeConverters(), this._getBaseTextItemConverters(autoScaledTextItem), [new PropertyConverter("textRectangle", this.parseRectangleF.bind(this))]);
|
|
500
|
-
this._parseModelComponent(rawAutoScaledText, autoScaledTextItem, converters);
|
|
501
|
-
return autoScaledTextItem;
|
|
502
|
-
};
|
|
503
|
-
ProductParser.prototype.parseBoundedTextItem = function (rawBoundedText, baseConverters) {
|
|
504
|
-
var boundedTextItem = new BoundedTextItem();
|
|
505
|
-
var converters = baseConverters.concat(this._getShapeConverters(), this._getBaseTextItemConverters(boundedTextItem), [
|
|
506
|
-
new PropertyConverter("paragraphSettings", this.parseParagraphSettings.bind(this)),
|
|
507
|
-
new PropertyConverter("textRectangle", this.parseRectangleF.bind(this)),
|
|
508
|
-
new PropertyConverter("wrappingPath", this.parsePath.bind(this))
|
|
509
|
-
]);
|
|
510
|
-
this._parseModelComponent(rawBoundedText, boundedTextItem, converters);
|
|
511
|
-
return boundedTextItem;
|
|
512
|
-
};
|
|
513
|
-
ProductParser.prototype.parsePathBoundedTextItem = function (rawBoundedText, baseConverters) {
|
|
514
|
-
var pathBoundedTextItem = new PathBoundedTextItem();
|
|
515
|
-
var converters = baseConverters.concat(this._getShapeConverters(), this._getBaseTextItemConverters(pathBoundedTextItem), [
|
|
516
|
-
new PropertyConverter("pathBoundedTextPermissions", this.parsePathBoundedTextPermissions.bind(this)),
|
|
517
|
-
new PropertyConverter("boundingPaths", this.parsePaths.bind(this)),
|
|
518
|
-
new PropertyConverter("paragraphSettings", this.parseParagraphSettings.bind(this)),
|
|
519
|
-
new PropertyConverter("wrappingPath", this.parsePath.bind(this))
|
|
520
|
-
]);
|
|
521
|
-
this._parseModelComponent(rawBoundedText, pathBoundedTextItem, converters);
|
|
522
|
-
return pathBoundedTextItem;
|
|
523
|
-
};
|
|
524
|
-
ProductParser.prototype.parseCurvedTextItem = function (rawCurvedText, baseConverters) {
|
|
525
|
-
var curvedTextItem = new CurvedTextItem();
|
|
526
|
-
var converters = baseConverters.concat(this._getShapeConverters(), this._getBaseTextItemConverters(curvedTextItem), [new PropertyConverter("textPath", this.parsePath.bind(this))]);
|
|
527
|
-
this._parseModelComponent(rawCurvedText, curvedTextItem, converters);
|
|
528
|
-
return curvedTextItem;
|
|
529
|
-
};
|
|
530
|
-
ProductParser.prototype._getBaseTextItemConverters = function (item) {
|
|
531
|
-
var _this = this;
|
|
532
|
-
return [
|
|
533
|
-
new PropertyConverter("values", this._setConvertedArray.bind(this, this._parseTextItemValue, function (obj) { item.values = obj; }), true),
|
|
534
|
-
new PropertyConverter("placeholders", function (rawPlaceholders) { return _this.parseCollection(rawPlaceholders, _this.parseInStringPlaceholder, item.placeholders); }, true),
|
|
535
|
-
new PropertyConverter("colorPalette", function (rawPalette) { return _this.parseCollection(rawPalette, _this.parseColor, item.colorPalette); }, true)
|
|
536
|
-
];
|
|
537
|
-
};
|
|
538
|
-
ProductParser.prototype.parseImageItem = function (rawImage, baseConverters) {
|
|
539
|
-
var image = new ImageItem();
|
|
540
|
-
var converters = baseConverters.concat(this._getShapeConverters(), this._getImageConverters(image));
|
|
541
|
-
this._parseModelComponent(rawImage, image, converters);
|
|
542
|
-
return image;
|
|
543
|
-
};
|
|
544
|
-
ProductParser.prototype.parseBarcodeItem = function (rawBarcode, baseConverters) {
|
|
545
|
-
var barcode = new BarcodeItem();
|
|
546
|
-
var converters = baseConverters.concat(this._getShapeConverters(), this._getImageConverters(barcode), [
|
|
547
|
-
new PropertyConverter("barcodePermissions", this.parseBarcodePermissions.bind(this)),
|
|
548
|
-
new PropertyConverter("color", this.parseColor.bind(this)),
|
|
549
|
-
new PropertyConverter("barcodeOptions", this.parseEncodingOptions)
|
|
550
|
-
]);
|
|
551
|
-
this._parseModelComponent(rawBarcode, barcode, converters);
|
|
552
|
-
return barcode;
|
|
553
|
-
};
|
|
554
|
-
ProductParser.prototype.parsePlaceholderItem = function (rawPlaceholder, baseConverters) {
|
|
555
|
-
var self = this;
|
|
556
|
-
var placeholder = new PlaceholderItem();
|
|
557
|
-
var converters = __spread(baseConverters, this._getShapeConverters(), [
|
|
558
|
-
new PropertyConverter("placeholderPermissions", this.parsePlaceholderPermissions),
|
|
559
|
-
new PropertyConverter("contentPermissions", this.parseContentPermissions.bind(this)),
|
|
560
|
-
new PropertyConverter("content", this.parseItem),
|
|
561
|
-
new PropertyConverter("topFrames", parseRawFrames),
|
|
562
|
-
new PropertyConverter("bottomFrames", parseRawFrames),
|
|
563
|
-
new PropertyConverter("stubStorageMeta", function (rawObject) { return new ImageMetaData(rawObject); }),
|
|
564
|
-
new PropertyConverter("contentFillColor", this.parseColor.bind(this)),
|
|
565
|
-
new PropertyConverter("contentOverlayEffect", this._parseOverlayEffect.bind(this))
|
|
566
|
-
]);
|
|
567
|
-
this._parseModelComponent(rawPlaceholder, placeholder, converters);
|
|
568
|
-
return placeholder;
|
|
569
|
-
function parseRawFrames(rawFrames) {
|
|
570
|
-
return rawFrames.map(self.parseItem);
|
|
571
|
-
}
|
|
572
|
-
};
|
|
573
|
-
ProductParser.prototype.parseGroupItem = function (rawGroupItem, baseConverters) {
|
|
574
|
-
var groupItem = new GroupItem();
|
|
575
|
-
var converters = __spread(baseConverters, this._getShapeConverters(), this._getGroupConverters(groupItem));
|
|
576
|
-
this._parseModelComponent(rawGroupItem, groupItem, converters);
|
|
577
|
-
return groupItem;
|
|
578
|
-
};
|
|
579
|
-
ProductParser.prototype.parseClipartItem = function (rawClipartItem, baseConverters) {
|
|
580
|
-
var clipartItem = new ClipartItem();
|
|
581
|
-
var converters = __spread(baseConverters, this._getShapeConverters(), this._getGroupConverters(clipartItem), [
|
|
582
|
-
new PropertyConverter("colorGroups", this._setConvertedArray.bind(this, this.parseColorGroup.bind(this), function (colorGroups) { return clipartItem.colorGroups = colorGroups; }), true),
|
|
583
|
-
]);
|
|
584
|
-
this._parseModelComponent(rawClipartItem, clipartItem, converters);
|
|
585
|
-
return clipartItem;
|
|
586
|
-
};
|
|
587
|
-
ProductParser.prototype.parseLayoutItem = function (rawLayoutItem, baseConverters) {
|
|
588
|
-
var layoutItem = new LayoutItem();
|
|
589
|
-
var converters = __spread(baseConverters, this._getShapeConverters(), this._getGroupConverters(layoutItem), [
|
|
590
|
-
new PropertyConverter("layoutSettings", this.parseLayoutSettings),
|
|
591
|
-
new PropertyConverter("sourceRectangle", this.parseRotatedRectangle)
|
|
592
|
-
]);
|
|
593
|
-
this._parseModelComponent(rawLayoutItem, layoutItem, converters);
|
|
594
|
-
return layoutItem;
|
|
595
|
-
};
|
|
596
|
-
ProductParser.prototype.parseContentPermissions = function (rawContentPermissions, baseConverters) {
|
|
597
|
-
var contentPermissions = new ContentPermissions();
|
|
598
|
-
contentPermissions.barcodePermissions = this.parseBarcodePermissions(rawContentPermissions["barcodePermissions"]);
|
|
599
|
-
contentPermissions.imagePermissions = this.parseImagePermissions(rawContentPermissions["imagePermissions"]);
|
|
600
|
-
return contentPermissions;
|
|
601
|
-
};
|
|
602
|
-
ProductParser.prototype.parseEllipseItem = function (rawEllipse, baseConverters) {
|
|
603
|
-
var ellipse = new EllipseItem();
|
|
604
|
-
var converters = baseConverters.concat(this._getShapeConverters());
|
|
605
|
-
this._parseModelComponent(rawEllipse, ellipse, converters);
|
|
606
|
-
return ellipse;
|
|
607
|
-
};
|
|
608
|
-
ProductParser.prototype.parseRectangleItem = function (rawRectangle, baseConverters) {
|
|
609
|
-
var rectangle = new RectangleItem();
|
|
610
|
-
var converters = baseConverters.concat(this._getShapeConverters());
|
|
611
|
-
this._parseModelComponent(rawRectangle, rectangle, converters);
|
|
612
|
-
return rectangle;
|
|
613
|
-
};
|
|
614
|
-
ProductParser.prototype.parseShapeItem = function (rawShape, baseConverters) {
|
|
615
|
-
var shape = new ShapeItem();
|
|
616
|
-
var converters = baseConverters.concat(this._getShapeConverters());
|
|
617
|
-
this._parseModelComponent(rawShape, shape, converters);
|
|
618
|
-
return shape;
|
|
619
|
-
};
|
|
620
|
-
ProductParser.prototype.parseDashedLineItem = function (rawLine, baseConverters) {
|
|
621
|
-
var line = new DashedLineItem();
|
|
622
|
-
var converters = __spread(baseConverters, this._getLineConverters(), this._getDashedLineConverters());
|
|
623
|
-
this._parseModelComponent(rawLine, line, converters);
|
|
624
|
-
return line;
|
|
625
|
-
};
|
|
626
|
-
ProductParser.prototype.parseThemeBinding = function (rawThemeBinding) {
|
|
627
|
-
return rawThemeBinding != null ? ThemeBinding.fromRaw(rawThemeBinding) : null;
|
|
628
|
-
};
|
|
629
|
-
ProductParser.prototype.parseMask = function (rawMask) {
|
|
630
|
-
if (rawMask == null)
|
|
631
|
-
return null;
|
|
632
|
-
var mask = new ItemMask();
|
|
633
|
-
if (rawMask.vectorMask != null)
|
|
634
|
-
mask.vectorMask = this.parsePath(rawMask.vectorMask);
|
|
635
|
-
return mask;
|
|
636
|
-
};
|
|
637
|
-
ProductParser.prototype.parseColor = function (rawColor) {
|
|
638
|
-
return rawColor != null ? ColorFactory.createColor(rawColor) : null;
|
|
639
|
-
};
|
|
640
|
-
ProductParser.prototype.parseTransform = function (rawTransform) {
|
|
641
|
-
return new Transform(rawTransform["scaleX"], rawTransform["scaleY"], rawTransform["translateX"], rawTransform["translateY"], rawTransform["angle"]);
|
|
642
|
-
};
|
|
643
|
-
ProductParser.prototype.parseFontSettings = function (rawSettings, destTextItem) {
|
|
644
|
-
var font = new BaseTextItem.FontSettings(null);
|
|
645
|
-
Object.assign(font, rawSettings);
|
|
646
|
-
destTextItem.font = font;
|
|
647
|
-
return destTextItem.font;
|
|
648
|
-
};
|
|
649
|
-
ProductParser.prototype.parseManipulationPermissions = function (rawPerms) {
|
|
650
|
-
var result = Object.assign(new ManipulationPermissions(), rawPerms);
|
|
651
|
-
result.resizeGrips = Object.assign(new ResizeGripsPermissions(false, false), rawPerms["resizeGrips"]);
|
|
652
|
-
return result;
|
|
653
|
-
};
|
|
654
|
-
ProductParser.prototype.parseFrontendPermissions = function (rawPerms) {
|
|
655
|
-
return Object.assign(new FrontendPermissions(), rawPerms);
|
|
656
|
-
};
|
|
657
|
-
ProductParser.prototype.parseVisualizationPermissions = function (rawPerms) {
|
|
658
|
-
return Object.assign(new VisualizationPermissions(), rawPerms);
|
|
659
|
-
};
|
|
660
|
-
ProductParser.prototype.parseColorGroup = function (rawPerms) {
|
|
661
|
-
return new ColorGroup(this.parseColor(rawPerms["color"]), rawPerms["targets"]);
|
|
662
|
-
};
|
|
663
|
-
ProductParser.prototype.parseItemPermissions = function (rawPerms) {
|
|
664
|
-
var result = Object.assign(new ItemPermissions(), rawPerms);
|
|
665
|
-
result.itemToolbarPermissions = Object.assign(new ItemToolbarPermissions(false), rawPerms["itemToolbarPermissions"]);
|
|
666
|
-
return result;
|
|
667
|
-
};
|
|
668
|
-
ProductParser.prototype.parseTextPermissions = function (rawPerms) {
|
|
669
|
-
return Object.assign(new TextPermissions(), rawPerms);
|
|
670
|
-
};
|
|
671
|
-
ProductParser.prototype.parsePathBoundedTextPermissions = function (rawPerms) {
|
|
672
|
-
return Object.assign(new PathBoundedTextPermissions(), rawPerms);
|
|
673
|
-
};
|
|
674
|
-
ProductParser.prototype.parseShapePermissions = function (rawPerms) {
|
|
675
|
-
return Object.assign(new ShapePermissions(), rawPerms);
|
|
676
|
-
};
|
|
677
|
-
ProductParser.prototype.parseImagePermissions = function (rawPerms) {
|
|
678
|
-
return Object.assign(new ImagePermissions(), rawPerms);
|
|
679
|
-
};
|
|
680
|
-
ProductParser.prototype.parseImageSource = function (rawImageSource) {
|
|
681
|
-
var origin = null;
|
|
682
|
-
if (rawImageSource["origin"] != null)
|
|
683
|
-
origin = new ImageItem.ImageSource.Origin(rawImageSource["origin"]);
|
|
684
|
-
if (rawImageSource["origin"] !== undefined)
|
|
685
|
-
delete rawImageSource["origin"];
|
|
686
|
-
return Object.assign(new ImageItem.ImageSource(rawImageSource["id"], rawImageSource["url"], 0, false, true, origin), rawImageSource);
|
|
687
|
-
};
|
|
688
|
-
ProductParser.prototype.parseParagraphSettings = function (rawSettings) {
|
|
689
|
-
return new ParagraphSettings(rawSettings);
|
|
690
|
-
};
|
|
691
|
-
ProductParser.prototype.parseStrokeSettings = function (rawSettings) {
|
|
692
|
-
return StrokeSettings._from_data(rawSettings);
|
|
693
|
-
};
|
|
694
|
-
ProductParser.prototype.parseShadowSettings = function (rawSettings) {
|
|
695
|
-
return ShadowSettings._from_data(rawSettings);
|
|
696
|
-
};
|
|
697
|
-
ProductParser.prototype.parseInStringPlaceholder = function (rawSettings) {
|
|
698
|
-
return new InStringPlaceholder(rawSettings["id"], rawSettings["name"], rawSettings["mask"], rawSettings["value"], rawSettings["values"]);
|
|
699
|
-
};
|
|
700
|
-
//#endregion
|
|
701
|
-
//#region private members
|
|
702
|
-
ProductParser.prototype._setConvertedArray = function (convertFunc, setFunc, rawArray) {
|
|
703
|
-
if (!_.isArray(rawArray))
|
|
704
|
-
return;
|
|
705
|
-
setFunc(_.map(rawArray, function (rawValue) { return convertFunc(rawValue); }));
|
|
706
|
-
};
|
|
707
|
-
ProductParser.prototype._getImageConverters = function (imageItem /*: ImageItem*/) {
|
|
708
|
-
return [
|
|
709
|
-
new PropertyConverter("source", this.parseImageSource.bind(this)),
|
|
710
|
-
new PropertyConverter("imagePermissions", this.parseImagePermissions.bind(this)),
|
|
711
|
-
new PropertyConverter("values", this._setConvertedArray.bind(this, this._parseImageItemValue, function (obj) { imageItem.values = obj; }), true),
|
|
712
|
-
new PropertyConverter("overlayEffect", this._parseOverlayEffect.bind(this))
|
|
713
|
-
];
|
|
714
|
-
};
|
|
715
|
-
ProductParser.prototype._getShapeConverters = function () {
|
|
716
|
-
return [
|
|
717
|
-
new PropertyConverter("fillColor", this.parseColor.bind(this)),
|
|
718
|
-
new PropertyConverter("borderColor", this.parseColor.bind(this)),
|
|
719
|
-
new PropertyConverter("altBorderColor", this.parseColor.bind(this)),
|
|
720
|
-
new PropertyConverter("sourceRectangle", this.parseRectangleF.bind(this)),
|
|
721
|
-
new PropertyConverter("sourcePath", this.parsePath.bind(this)),
|
|
722
|
-
new PropertyConverter("shapePermissions", this.parseShapePermissions.bind(this))
|
|
723
|
-
];
|
|
724
|
-
};
|
|
725
|
-
ProductParser.prototype._getGroupConverters = function (groupItem) {
|
|
726
|
-
return [
|
|
727
|
-
new PropertyConverter("items", this._setConvertedArray.bind(this, this.parseItem, function (items) { return groupItem.items.addRange(items); }), true),
|
|
728
|
-
new PropertyConverter("groupItemPermissions", this.parseGroupItemPermissions)
|
|
729
|
-
];
|
|
730
|
-
};
|
|
731
|
-
ProductParser.prototype._getLineConverters = function () {
|
|
732
|
-
return [
|
|
733
|
-
new PropertyConverter("color", this.parseColor.bind(this)),
|
|
734
|
-
new PropertyConverter("sourcePoint0", this.parsePointF.bind(this)),
|
|
735
|
-
new PropertyConverter("sourcePoint1", this.parsePointF.bind(this)),
|
|
736
|
-
new PropertyConverter("linePermissions", this.parseLinePermissions)
|
|
737
|
-
];
|
|
738
|
-
};
|
|
739
|
-
ProductParser.prototype._getDashedLineConverters = function () {
|
|
740
|
-
return [
|
|
741
|
-
new PropertyConverter("altColor", this.parseColor.bind(this))
|
|
742
|
-
];
|
|
743
|
-
};
|
|
744
|
-
ProductParser.prototype._parseModelComponent = function (rawComponent, destComponent, converters) {
|
|
745
|
-
if (rawComponent["version"] !== MODELVERSION)
|
|
746
|
-
throw new Exception("Version of serialized model component (" + rawComponent["version"] + ") does not match the editor's version (" + MODELVERSION + ").");
|
|
747
|
-
converters = converters.concat([
|
|
748
|
-
new PropertyConverter("tags", function (rawTags, destComponent) { destComponent["_tags"] = rawTags; }, true),
|
|
749
|
-
new PropertyConverter("version", function (rawVersion, destComponent) { }, true)
|
|
750
|
-
]);
|
|
751
|
-
this._parseObject(rawComponent, destComponent, converters);
|
|
752
|
-
};
|
|
753
|
-
return ProductParser;
|
|
754
|
-
}());
|
|
755
|
-
export { ProductParser };
|
|
756
|
-
var PropertyConverter = /** @class */ (function () {
|
|
757
|
-
function PropertyConverter(rawPropertyName, convertFunc, isSetByConvertFunc) {
|
|
758
|
-
this.property = rawPropertyName;
|
|
759
|
-
this.convert = convertFunc;
|
|
760
|
-
this.setByConverter = isSetByConvertFunc ? isSetByConvertFunc : false;
|
|
761
|
-
}
|
|
762
|
-
return PropertyConverter;
|
|
763
|
-
}());
|
|
764
|
-
export { PropertyConverter };
|
|
765
|
-
//# sourceMappingURL=ProductParser.js.map
|