@leapfrog/interactive-canvas 1.0.8 → 1.1.0
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/index.d.ts
CHANGED
|
@@ -4,6 +4,30 @@ import { oc } from 'ts-optchain';
|
|
|
4
4
|
import { BehaviorSubject, Subject } from 'rxjs';
|
|
5
5
|
import { fabric } from 'fabric';
|
|
6
6
|
|
|
7
|
+
var PIXELS_PER_MM = 3.937;
|
|
8
|
+
var MillimeterDimensions = /** @class */ (function () {
|
|
9
|
+
function MillimeterDimensions(width, height) {
|
|
10
|
+
this.widthUnit = "mm";
|
|
11
|
+
this.heightUnit = "mm";
|
|
12
|
+
this.width = width;
|
|
13
|
+
this.widthMm = Math.max(0, width);
|
|
14
|
+
this.widthPx = round(this.widthMm * PIXELS_PER_MM);
|
|
15
|
+
this.height = height;
|
|
16
|
+
this.heightMm = Math.max(0, height);
|
|
17
|
+
this.heightPx = round(this.heightMm * PIXELS_PER_MM);
|
|
18
|
+
}
|
|
19
|
+
MillimeterDimensions.prototype.withSize = function (width, height) {
|
|
20
|
+
return new MillimeterDimensions(width, height);
|
|
21
|
+
};
|
|
22
|
+
MillimeterDimensions.prototype.widthPxToMm = function (px) {
|
|
23
|
+
return px / PIXELS_PER_MM;
|
|
24
|
+
};
|
|
25
|
+
MillimeterDimensions.prototype.heightPxToMm = function (px) {
|
|
26
|
+
return px / PIXELS_PER_MM;
|
|
27
|
+
};
|
|
28
|
+
return MillimeterDimensions;
|
|
29
|
+
}());
|
|
30
|
+
|
|
7
31
|
var PixelCanvasDimensions = /** @class */ (function () {
|
|
8
32
|
function PixelCanvasDimensions(width, height) {
|
|
9
33
|
this.widthUnit = "px";
|
|
@@ -27,7 +51,7 @@ var PixelCanvasDimensions = /** @class */ (function () {
|
|
|
27
51
|
|
|
28
52
|
var COLUMN_WIDTH_MM = 41;
|
|
29
53
|
var GUTTER_WIDTH_MM = 3;
|
|
30
|
-
var PIXELS_PER_MM = 3.937;
|
|
54
|
+
var PIXELS_PER_MM$1 = 3.937;
|
|
31
55
|
var Print6ColCanvasDimensions = /** @class */ (function () {
|
|
32
56
|
function Print6ColCanvasDimensions(width, height) {
|
|
33
57
|
this.widthUnit = "column(s)";
|
|
@@ -37,26 +61,26 @@ var Print6ColCanvasDimensions = /** @class */ (function () {
|
|
|
37
61
|
this.gutterTotalMm = this.gutterCount * GUTTER_WIDTH_MM;
|
|
38
62
|
this.columnsTotalMm = width * COLUMN_WIDTH_MM;
|
|
39
63
|
this.widthMm = Math.max(0, this.columnsTotalMm + this.gutterTotalMm);
|
|
40
|
-
this.widthPx = round(this.widthMm * PIXELS_PER_MM);
|
|
64
|
+
this.widthPx = round(this.widthMm * PIXELS_PER_MM$1);
|
|
41
65
|
this.height = height;
|
|
42
66
|
this.heightMm = Math.max(0, height * 10);
|
|
43
|
-
this.heightPx = round(this.heightMm * PIXELS_PER_MM);
|
|
67
|
+
this.heightPx = round(this.heightMm * PIXELS_PER_MM$1);
|
|
44
68
|
}
|
|
45
69
|
Print6ColCanvasDimensions.prototype.withSize = function (width, height) {
|
|
46
70
|
return new Print6ColCanvasDimensions(width, height);
|
|
47
71
|
};
|
|
48
72
|
Print6ColCanvasDimensions.prototype.widthPxToMm = function (px) {
|
|
49
|
-
return px / PIXELS_PER_MM;
|
|
73
|
+
return px / PIXELS_PER_MM$1;
|
|
50
74
|
};
|
|
51
75
|
Print6ColCanvasDimensions.prototype.heightPxToMm = function (px) {
|
|
52
|
-
return px / PIXELS_PER_MM;
|
|
76
|
+
return px / PIXELS_PER_MM$1;
|
|
53
77
|
};
|
|
54
78
|
return Print6ColCanvasDimensions;
|
|
55
79
|
}());
|
|
56
80
|
|
|
57
81
|
var COLUMN_WIDTH_MM$1 = 30.8772;
|
|
58
82
|
var GUTTER_WIDTH_MM$1 = 2.1053;
|
|
59
|
-
var PIXELS_PER_MM$
|
|
83
|
+
var PIXELS_PER_MM$2 = 3.937;
|
|
60
84
|
var Print8ColCanvasDimensions = /** @class */ (function () {
|
|
61
85
|
function Print8ColCanvasDimensions(width, height) {
|
|
62
86
|
this.widthUnit = "column(s)";
|
|
@@ -66,19 +90,19 @@ var Print8ColCanvasDimensions = /** @class */ (function () {
|
|
|
66
90
|
this.gutterTotalMm = this.gutterCount * GUTTER_WIDTH_MM$1;
|
|
67
91
|
this.columnsTotalMm = width * COLUMN_WIDTH_MM$1;
|
|
68
92
|
this.widthMm = Math.max(0, this.columnsTotalMm + this.gutterTotalMm);
|
|
69
|
-
this.widthPx = round(this.widthMm * PIXELS_PER_MM$
|
|
93
|
+
this.widthPx = round(this.widthMm * PIXELS_PER_MM$2);
|
|
70
94
|
this.height = height;
|
|
71
95
|
this.heightMm = Math.max(0, height * 10);
|
|
72
|
-
this.heightPx = round(this.heightMm * PIXELS_PER_MM$
|
|
96
|
+
this.heightPx = round(this.heightMm * PIXELS_PER_MM$2);
|
|
73
97
|
}
|
|
74
98
|
Print8ColCanvasDimensions.prototype.withSize = function (width, height) {
|
|
75
99
|
return new Print8ColCanvasDimensions(width, height);
|
|
76
100
|
};
|
|
77
101
|
Print8ColCanvasDimensions.prototype.widthPxToMm = function (px) {
|
|
78
|
-
return px / PIXELS_PER_MM$
|
|
102
|
+
return px / PIXELS_PER_MM$2;
|
|
79
103
|
};
|
|
80
104
|
Print8ColCanvasDimensions.prototype.heightPxToMm = function (px) {
|
|
81
|
-
return px / PIXELS_PER_MM$
|
|
105
|
+
return px / PIXELS_PER_MM$2;
|
|
82
106
|
};
|
|
83
107
|
return Print8ColCanvasDimensions;
|
|
84
108
|
}());
|
|
@@ -296,6 +320,8 @@ var ResizeCanvasLayoutFunction = /** @class */ (function () {
|
|
|
296
320
|
ResizeCanvasLayoutFunction.prototype.execute = function (canvas) {
|
|
297
321
|
if (canvas.getLayoutManager().isEnforcedPositioning)
|
|
298
322
|
return;
|
|
323
|
+
if (oc(canvas.getDimensionsRestrictions()).fixed(false))
|
|
324
|
+
return;
|
|
299
325
|
var currentDimensions = canvas.getDimensions();
|
|
300
326
|
var baseDimensions = canvas.getBaseDimensions();
|
|
301
327
|
var textHeightIncreasePx = _(canvas.getObjectsByTypeInternal(ObjectType.TEXT))
|
|
@@ -457,6 +483,8 @@ var StackObjectsLayoutFunction = /** @class */ (function () {
|
|
|
457
483
|
});
|
|
458
484
|
};
|
|
459
485
|
StackObjectsLayoutFunction.prototype.adjustCanvasSize = function (canvas, requiredHeight) {
|
|
486
|
+
if (oc(canvas.getDimensionsRestrictions()).fixed(false))
|
|
487
|
+
return;
|
|
460
488
|
var dimensions = canvas.getDimensions();
|
|
461
489
|
var targetDimensions = canvas.getDimensions().withSize(dimensions.width, MIN_MAGNITUDE);
|
|
462
490
|
while (targetDimensions.heightPx < requiredHeight) {
|
|
@@ -3222,4 +3250,4 @@ var InteractiveCanvas = /** @class */ (function (_super) {
|
|
|
3222
3250
|
return InteractiveCanvas;
|
|
3223
3251
|
}(AbstractInteractiveCanvas));
|
|
3224
3252
|
|
|
3225
|
-
export { AbstractCanvasObject, AbstractInteractiveCanvas, AbstractLayoutManager, AdvancedLayoutManager, Border, CanvasObjectData, Cutoff, DefaultCanvasProfile, Font, FontLibrary, HeadlessInteractiveCanvas, HorizontalRule, Image, ImageType, InteractiveCanvas, LayoutManager, ObjectType, PixelCanvasDimensions, Print6ColCanvasDimensions, Print8ColCanvasDimensions, Rectangle, SelectionData, StandardLayoutManager, Text, UNKNOWN_FONT, UnknownFont, VerticalRule, isMutableBackgroundColor, isMutableColor, isMutableImage, isMutablePosition, isMutableText, isMutableTextStyle };
|
|
3253
|
+
export { AbstractCanvasObject, AbstractInteractiveCanvas, AbstractLayoutManager, AdvancedLayoutManager, Border, CanvasObjectData, Cutoff, DefaultCanvasProfile, Font, FontLibrary, HeadlessInteractiveCanvas, HorizontalRule, Image, ImageType, InteractiveCanvas, LayoutManager, MillimeterDimensions, ObjectType, PixelCanvasDimensions, Print6ColCanvasDimensions, Print8ColCanvasDimensions, Rectangle, SelectionData, StandardLayoutManager, Text, UNKNOWN_FONT, UnknownFont, VerticalRule, isMutableBackgroundColor, isMutableColor, isMutableImage, isMutablePosition, isMutableText, isMutableTextStyle };
|
|
@@ -7,6 +7,30 @@ var tsOptchain = require('ts-optchain');
|
|
|
7
7
|
var rxjs = require('rxjs');
|
|
8
8
|
var fabric = require('fabric');
|
|
9
9
|
|
|
10
|
+
var PIXELS_PER_MM = 3.937;
|
|
11
|
+
var MillimeterDimensions = /** @class */ (function () {
|
|
12
|
+
function MillimeterDimensions(width, height) {
|
|
13
|
+
this.widthUnit = "mm";
|
|
14
|
+
this.heightUnit = "mm";
|
|
15
|
+
this.width = width;
|
|
16
|
+
this.widthMm = Math.max(0, width);
|
|
17
|
+
this.widthPx = _.round(this.widthMm * PIXELS_PER_MM);
|
|
18
|
+
this.height = height;
|
|
19
|
+
this.heightMm = Math.max(0, height);
|
|
20
|
+
this.heightPx = _.round(this.heightMm * PIXELS_PER_MM);
|
|
21
|
+
}
|
|
22
|
+
MillimeterDimensions.prototype.withSize = function (width, height) {
|
|
23
|
+
return new MillimeterDimensions(width, height);
|
|
24
|
+
};
|
|
25
|
+
MillimeterDimensions.prototype.widthPxToMm = function (px) {
|
|
26
|
+
return px / PIXELS_PER_MM;
|
|
27
|
+
};
|
|
28
|
+
MillimeterDimensions.prototype.heightPxToMm = function (px) {
|
|
29
|
+
return px / PIXELS_PER_MM;
|
|
30
|
+
};
|
|
31
|
+
return MillimeterDimensions;
|
|
32
|
+
}());
|
|
33
|
+
|
|
10
34
|
var PixelCanvasDimensions = /** @class */ (function () {
|
|
11
35
|
function PixelCanvasDimensions(width, height) {
|
|
12
36
|
this.widthUnit = "px";
|
|
@@ -30,7 +54,7 @@ var PixelCanvasDimensions = /** @class */ (function () {
|
|
|
30
54
|
|
|
31
55
|
var COLUMN_WIDTH_MM = 41;
|
|
32
56
|
var GUTTER_WIDTH_MM = 3;
|
|
33
|
-
var PIXELS_PER_MM = 3.937;
|
|
57
|
+
var PIXELS_PER_MM$1 = 3.937;
|
|
34
58
|
var Print6ColCanvasDimensions = /** @class */ (function () {
|
|
35
59
|
function Print6ColCanvasDimensions(width, height) {
|
|
36
60
|
this.widthUnit = "column(s)";
|
|
@@ -40,26 +64,26 @@ var Print6ColCanvasDimensions = /** @class */ (function () {
|
|
|
40
64
|
this.gutterTotalMm = this.gutterCount * GUTTER_WIDTH_MM;
|
|
41
65
|
this.columnsTotalMm = width * COLUMN_WIDTH_MM;
|
|
42
66
|
this.widthMm = Math.max(0, this.columnsTotalMm + this.gutterTotalMm);
|
|
43
|
-
this.widthPx = _.round(this.widthMm * PIXELS_PER_MM);
|
|
67
|
+
this.widthPx = _.round(this.widthMm * PIXELS_PER_MM$1);
|
|
44
68
|
this.height = height;
|
|
45
69
|
this.heightMm = Math.max(0, height * 10);
|
|
46
|
-
this.heightPx = _.round(this.heightMm * PIXELS_PER_MM);
|
|
70
|
+
this.heightPx = _.round(this.heightMm * PIXELS_PER_MM$1);
|
|
47
71
|
}
|
|
48
72
|
Print6ColCanvasDimensions.prototype.withSize = function (width, height) {
|
|
49
73
|
return new Print6ColCanvasDimensions(width, height);
|
|
50
74
|
};
|
|
51
75
|
Print6ColCanvasDimensions.prototype.widthPxToMm = function (px) {
|
|
52
|
-
return px / PIXELS_PER_MM;
|
|
76
|
+
return px / PIXELS_PER_MM$1;
|
|
53
77
|
};
|
|
54
78
|
Print6ColCanvasDimensions.prototype.heightPxToMm = function (px) {
|
|
55
|
-
return px / PIXELS_PER_MM;
|
|
79
|
+
return px / PIXELS_PER_MM$1;
|
|
56
80
|
};
|
|
57
81
|
return Print6ColCanvasDimensions;
|
|
58
82
|
}());
|
|
59
83
|
|
|
60
84
|
var COLUMN_WIDTH_MM$1 = 30.8772;
|
|
61
85
|
var GUTTER_WIDTH_MM$1 = 2.1053;
|
|
62
|
-
var PIXELS_PER_MM$
|
|
86
|
+
var PIXELS_PER_MM$2 = 3.937;
|
|
63
87
|
var Print8ColCanvasDimensions = /** @class */ (function () {
|
|
64
88
|
function Print8ColCanvasDimensions(width, height) {
|
|
65
89
|
this.widthUnit = "column(s)";
|
|
@@ -69,19 +93,19 @@ var Print8ColCanvasDimensions = /** @class */ (function () {
|
|
|
69
93
|
this.gutterTotalMm = this.gutterCount * GUTTER_WIDTH_MM$1;
|
|
70
94
|
this.columnsTotalMm = width * COLUMN_WIDTH_MM$1;
|
|
71
95
|
this.widthMm = Math.max(0, this.columnsTotalMm + this.gutterTotalMm);
|
|
72
|
-
this.widthPx = _.round(this.widthMm * PIXELS_PER_MM$
|
|
96
|
+
this.widthPx = _.round(this.widthMm * PIXELS_PER_MM$2);
|
|
73
97
|
this.height = height;
|
|
74
98
|
this.heightMm = Math.max(0, height * 10);
|
|
75
|
-
this.heightPx = _.round(this.heightMm * PIXELS_PER_MM$
|
|
99
|
+
this.heightPx = _.round(this.heightMm * PIXELS_PER_MM$2);
|
|
76
100
|
}
|
|
77
101
|
Print8ColCanvasDimensions.prototype.withSize = function (width, height) {
|
|
78
102
|
return new Print8ColCanvasDimensions(width, height);
|
|
79
103
|
};
|
|
80
104
|
Print8ColCanvasDimensions.prototype.widthPxToMm = function (px) {
|
|
81
|
-
return px / PIXELS_PER_MM$
|
|
105
|
+
return px / PIXELS_PER_MM$2;
|
|
82
106
|
};
|
|
83
107
|
Print8ColCanvasDimensions.prototype.heightPxToMm = function (px) {
|
|
84
|
-
return px / PIXELS_PER_MM$
|
|
108
|
+
return px / PIXELS_PER_MM$2;
|
|
85
109
|
};
|
|
86
110
|
return Print8ColCanvasDimensions;
|
|
87
111
|
}());
|
|
@@ -299,6 +323,8 @@ var ResizeCanvasLayoutFunction = /** @class */ (function () {
|
|
|
299
323
|
ResizeCanvasLayoutFunction.prototype.execute = function (canvas) {
|
|
300
324
|
if (canvas.getLayoutManager().isEnforcedPositioning)
|
|
301
325
|
return;
|
|
326
|
+
if (tsOptchain.oc(canvas.getDimensionsRestrictions()).fixed(false))
|
|
327
|
+
return;
|
|
302
328
|
var currentDimensions = canvas.getDimensions();
|
|
303
329
|
var baseDimensions = canvas.getBaseDimensions();
|
|
304
330
|
var textHeightIncreasePx = _(canvas.getObjectsByTypeInternal(exports.ObjectType.TEXT))
|
|
@@ -459,6 +485,8 @@ var StackObjectsLayoutFunction = /** @class */ (function () {
|
|
|
459
485
|
});
|
|
460
486
|
};
|
|
461
487
|
StackObjectsLayoutFunction.prototype.adjustCanvasSize = function (canvas, requiredHeight) {
|
|
488
|
+
if (tsOptchain.oc(canvas.getDimensionsRestrictions()).fixed(false))
|
|
489
|
+
return;
|
|
462
490
|
var dimensions = canvas.getDimensions();
|
|
463
491
|
var targetDimensions = canvas.getDimensions().withSize(dimensions.width, MIN_MAGNITUDE);
|
|
464
492
|
while (targetDimensions.heightPx < requiredHeight) {
|
|
@@ -3236,6 +3264,7 @@ exports.HeadlessInteractiveCanvas = HeadlessInteractiveCanvas;
|
|
|
3236
3264
|
exports.HorizontalRule = HorizontalRule;
|
|
3237
3265
|
exports.Image = Image;
|
|
3238
3266
|
exports.InteractiveCanvas = InteractiveCanvas;
|
|
3267
|
+
exports.MillimeterDimensions = MillimeterDimensions;
|
|
3239
3268
|
exports.PixelCanvasDimensions = PixelCanvasDimensions;
|
|
3240
3269
|
exports.Print6ColCanvasDimensions = Print6ColCanvasDimensions;
|
|
3241
3270
|
exports.Print8ColCanvasDimensions = Print8ColCanvasDimensions;
|