customized-fabric 1.0.1 → 1.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "customized-fabric",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Customized fabric",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CLIPART_OBJECT_ATTRIBUTES = void 0;
4
- exports.CLIPART_OBJECT_ATTRIBUTES = {
5
- name: "Clipart",
6
- type: "CLIP_ART",
7
- stroke: {
8
- stroke: "#000000",
9
- strokeDashArray: [5, 5],
10
- strokeWidth: 2,
11
- },
12
- };
@@ -1,145 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Clipart = exports.toClipartObject = void 0;
4
- const fabric_1 = require("fabric");
5
- const constants_1 = require("./constants");
6
- const utils_1 = require("../utils");
7
- const objectId_1 = require("../objectId");
8
- const ClipartClass = fabric_1.fabric.util.createClass(fabric_1.fabric.Group, {
9
- initialize: function (options) {
10
- this.rectObject = new fabric_1.fabric.Rect({
11
- width: options?.width,
12
- height: options?.height,
13
- fill: undefined,
14
- originX: "center",
15
- originY: "center",
16
- objectCaching: false,
17
- ...constants_1.CLIPART_OBJECT_ATTRIBUTES.stroke,
18
- });
19
- const imageObject = new fabric_1.fabric.Image("");
20
- imageObject.set({
21
- width: options?.width,
22
- height: options?.height,
23
- });
24
- this.imageObject = imageObject;
25
- const group = new fabric_1.fabric.Group([this.rectObject, this.imageObject]);
26
- group.setControlsVisibility({
27
- mt: false,
28
- mr: false,
29
- mb: false,
30
- ml: false,
31
- });
32
- this.set(group);
33
- this.on("scaling", () => {
34
- let width = this.width * this.scaleX;
35
- let height = this.height * this.scaleY;
36
- const imageScaleX = width / this.imageObject.width;
37
- const imageScaleY = height / this.imageObject.height;
38
- this.imageObject.set({ scaleX: imageScaleX, scaleY: imageScaleY });
39
- this.fitImage(this.imageObject);
40
- this.canvas?.renderAll?.();
41
- });
42
- this.set({
43
- _id: new objectId_1.ObjectId().toString(),
44
- name: constants_1.CLIPART_OBJECT_ATTRIBUTES.name,
45
- type: constants_1.CLIPART_OBJECT_ATTRIBUTES.type,
46
- ...options,
47
- layerId: options?.personalizeId ?? options?.layerId,
48
- objectCaching: false,
49
- });
50
- if (options?.clipartUrl) {
51
- this.loadImageFromUrl(options.clipartUrl);
52
- }
53
- if (options?.clipartFile) {
54
- this.loadImageFromFile(options.clipartFile);
55
- }
56
- if (options?.hideStroke) {
57
- this.rectObject.set({ strokeWidth: 0 });
58
- }
59
- },
60
- loadImageFromUrl: async function (url) {
61
- fabric_1.fabric.Image.fromURL(url, (loadedImage) => {
62
- this.loadImage(loadedImage);
63
- }, {
64
- crossOrigin: "anonymous",
65
- });
66
- },
67
- loadImageFromFile: async function (imageFile) {
68
- const loadedImage = await (0, utils_1.loadImageFromFile)(imageFile);
69
- this.loadImage(loadedImage);
70
- },
71
- loadImage: function (image) {
72
- if (image.width && image.height) {
73
- image.set({
74
- originX: "center",
75
- originY: "center",
76
- });
77
- image.scaleToWidth(this.width);
78
- this.remove(this.imageObject);
79
- this.imageObject = image;
80
- this.add(this.imageObject);
81
- this.fitImage(this.imageObject);
82
- }
83
- else {
84
- this.remove(this.imageObject);
85
- const imageObject = new fabric_1.fabric.Image("");
86
- imageObject.set({
87
- width: this.width,
88
- height: this.height,
89
- });
90
- this.imageObject = imageObject;
91
- this.add(this.imageObject);
92
- this.fitImage(this.imageObject);
93
- }
94
- this.canvas?.renderAll();
95
- },
96
- getSettings: function (attribute) {
97
- return this.get(attribute);
98
- },
99
- setSizes: function (options) {
100
- const { width, height } = options;
101
- if (width) {
102
- const scaleX = width / (this?.imageObject?.width ?? this.width);
103
- this.imageObject.set({ scaleX, scaleY: scaleX });
104
- }
105
- if (height) {
106
- const scaleY = height / (this?.imageObject?.height ?? this.height);
107
- this.imageObject.set({ scaleX: scaleY, scaleY });
108
- }
109
- this.fitImage(this.imageObject);
110
- this.canvas?.renderAll?.();
111
- },
112
- fitImage: function (image) {
113
- const attributes = {
114
- scaleX: 1,
115
- scaleY: 1,
116
- width: (image.width ?? 0) * (image.scaleX ?? 1),
117
- height: (image.height ?? 0) * (image.scaleY ?? 1),
118
- };
119
- this.set(attributes);
120
- this.rectObject.set(attributes);
121
- },
122
- });
123
- const toClipartObject = (clipartObject) => {
124
- return {
125
- id: clipartObject._id,
126
- personalizeId: clipartObject.layerId,
127
- layerId: clipartObject.layerId,
128
- name: clipartObject.name,
129
- locked: clipartObject.locked,
130
- isAdditional: clipartObject?.isAdditional,
131
- clipartUrl: clipartObject?.clipartUrl,
132
- clipartFile: clipartObject?.clipartFile,
133
- clipartRootCategoryId: clipartObject?.clipartRootCategoryId,
134
- clipartCategoryId: clipartObject?.clipartCategoryId,
135
- clipartOptionId: clipartObject?.clipartOptionId,
136
- };
137
- };
138
- exports.toClipartObject = toClipartObject;
139
- class Clipart extends fabric_1.fabric.Group {
140
- constructor(options) {
141
- super();
142
- return new ClipartClass(options);
143
- }
144
- }
145
- exports.Clipart = Clipart;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IMAGE_PLACEHOLDER_OBJECT_ATTRIBUTES = void 0;
4
- exports.IMAGE_PLACEHOLDER_OBJECT_ATTRIBUTES = {
5
- name: "Image placeholder",
6
- type: "IMAGE_PLACEHOLDER",
7
- stroke: {
8
- stroke: "#000000",
9
- strokeDashArray: [5, 5],
10
- strokeWidth: 2,
11
- },
12
- };
@@ -1,140 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ImagePlaceholder = exports.toImagePlaceholderObject = void 0;
4
- const fabric_1 = require("fabric");
5
- const constants_1 = require("./constants");
6
- const utils_1 = require("../utils");
7
- const objectId_1 = require("../objectId");
8
- const ImagePlaceholderClass = fabric_1.fabric.util.createClass(fabric_1.fabric.Group, {
9
- initialize: function (options) {
10
- this.rectObject = new fabric_1.fabric.Rect({
11
- width: options?.width,
12
- height: options?.height,
13
- fill: undefined,
14
- originX: "center",
15
- originY: "center",
16
- objectCaching: false,
17
- ...constants_1.IMAGE_PLACEHOLDER_OBJECT_ATTRIBUTES.stroke,
18
- });
19
- this.imageObject = new fabric_1.fabric.Image("");
20
- const group = new fabric_1.fabric.Group([this.rectObject, this.imageObject]);
21
- this.set(group);
22
- this.on("scaling", () => {
23
- let width = this.width * this.scaleX;
24
- let height = this.height * this.scaleY;
25
- this.setSizes({ width, height });
26
- this.canvas?.renderAll();
27
- });
28
- this.set({
29
- _id: new objectId_1.ObjectId().toString(),
30
- name: constants_1.IMAGE_PLACEHOLDER_OBJECT_ATTRIBUTES.name,
31
- type: constants_1.IMAGE_PLACEHOLDER_OBJECT_ATTRIBUTES.type,
32
- ...options,
33
- layerId: options?.personalizeId ?? options?.layerId,
34
- objectCaching: false,
35
- });
36
- if (options?.imageFile) {
37
- this.loadImageFromFile(options?.imageFile);
38
- }
39
- if (options?.hideStroke) {
40
- this.rectObject.set({ strokeWidth: 0 });
41
- }
42
- },
43
- loadImageFromUrl: async function (url) {
44
- fabric_1.fabric.Image.fromURL(url, (loadedImage) => {
45
- this.loadImage(loadedImage);
46
- }, {
47
- crossOrigin: "anonymous",
48
- });
49
- },
50
- loadImageFromFile: async function (imageFile) {
51
- const loadedImage = await (0, utils_1.loadImageFromFile)(imageFile);
52
- this.loadImage(loadedImage);
53
- },
54
- loadImage: function (image) {
55
- if (image.width && image.height) {
56
- image.set({
57
- originX: "center",
58
- originY: "center",
59
- });
60
- this.remove(this.imageObject);
61
- this.imageObject = image;
62
- this.add(this.imageObject);
63
- this.fitImage(this.imageObject);
64
- }
65
- else {
66
- this.remove(this.imageObject);
67
- this.imageObject = new fabric_1.fabric.Image("");
68
- this.add(this.imageObject);
69
- this.fitImage(this.imageObject);
70
- }
71
- this.canvas?.renderAll();
72
- },
73
- setSizes: function (options) {
74
- const { width, height } = options;
75
- const attributes = {
76
- scaleX: 1,
77
- scaleY: 1,
78
- };
79
- if (width) {
80
- attributes.width = width;
81
- }
82
- if (height) {
83
- attributes.height = height;
84
- }
85
- this.set(attributes);
86
- this.rectObject.set(attributes);
87
- this.fitImage(this.imageObject);
88
- this.canvas?.renderAll?.();
89
- },
90
- fitImage: function (image) {
91
- const imageScaleX = this.width / (image?.width ?? 1);
92
- const imageScaleY = this.height / (image?.height ?? 1);
93
- imageScaleX > imageScaleY
94
- ? image.set({ scaleX: imageScaleY, scaleY: imageScaleY })
95
- : image.set({ scaleX: imageScaleX, scaleY: imageScaleX });
96
- },
97
- getSettings: function (attribute) {
98
- return this.get(attribute);
99
- },
100
- loadUploadedImage: function (imageFile) {
101
- (0, utils_1.loadImageFromFile)(imageFile).then((loadedImage) => {
102
- const clipPath = new fabric_1.fabric.Rect({
103
- width: this.width,
104
- height: this.height,
105
- top: this.top,
106
- left: this.left,
107
- absolutePositioned: true,
108
- });
109
- loadedImage.set({ top: this.top, left: this.left, clipPath: clipPath });
110
- this.fitImage(loadedImage);
111
- this.uploadedImage = loadedImage;
112
- const canvas = this?.canvas;
113
- canvas?.add(this.uploadedImage);
114
- canvas?.renderAll();
115
- });
116
- },
117
- removeUploadedImage: function () {
118
- const canvas = this?.canvas;
119
- canvas?.remove(this.uploadedImage);
120
- canvas?.renderAll();
121
- },
122
- });
123
- const toImagePlaceholderObject = (imagePlaceholderObject) => {
124
- return {
125
- id: imagePlaceholderObject._id,
126
- personalizeId: imagePlaceholderObject.layerId,
127
- layerId: imagePlaceholderObject.layerId,
128
- name: imagePlaceholderObject.name,
129
- locked: imagePlaceholderObject.locked,
130
- isAdditional: imagePlaceholderObject?.isAdditional,
131
- };
132
- };
133
- exports.toImagePlaceholderObject = toImagePlaceholderObject;
134
- class ImagePlaceholder extends fabric_1.fabric.Group {
135
- constructor(options) {
136
- super();
137
- return new ImagePlaceholderClass(options);
138
- }
139
- }
140
- exports.ImagePlaceholder = ImagePlaceholder;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PARENT_ATTRIBUTES = exports.TEXT_INPUT_OBJECT_ATTRIBUTES = void 0;
4
- exports.TEXT_INPUT_OBJECT_ATTRIBUTES = {
5
- name: "Text input",
6
- type: "TEXT_INPUT",
7
- stroke: {
8
- stroke: "#000000",
9
- strokeDashArray: [5, 5],
10
- strokeWidth: 2,
11
- },
12
- };
13
- exports.PARENT_ATTRIBUTES = ["top", "left", "width", "height", "angle"];
@@ -1,188 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TextInput = exports.toTextInputObject = void 0;
4
- const fabric_1 = require("fabric");
5
- const constants_1 = require("./constants");
6
- const utils_1 = require("../utils");
7
- const objectId_1 = require("../objectId");
8
- const TextInputClass = fabric_1.fabric.util.createClass(fabric_1.fabric.Group, {
9
- initialize: function (options) {
10
- const { text, ...rest } = options ?? {};
11
- this.rectObject = new fabric_1.fabric.Rect({
12
- width: options?.width,
13
- height: options?.height,
14
- fill: undefined,
15
- originX: "center",
16
- originY: "center",
17
- objectCaching: false,
18
- ...constants_1.TEXT_INPUT_OBJECT_ATTRIBUTES.stroke,
19
- });
20
- this.textObject = new fabric_1.fabric.IText("", {
21
- originX: "top",
22
- originY: "left",
23
- textAlign: "center",
24
- objectCaching: false,
25
- ...text,
26
- });
27
- const group = new fabric_1.fabric.Group([this.rectObject, this.textObject]);
28
- this.set(group);
29
- this.on("scaling", () => {
30
- let width = this.width * this.scaleX;
31
- let height = this.height * this.scaleY;
32
- const attributes = {
33
- scaleX: 1,
34
- scaleY: 1,
35
- width,
36
- height,
37
- };
38
- this.set(attributes);
39
- this.rectObject.set(attributes);
40
- this.autoChangeFontSize(0.1);
41
- this.textObject.set({
42
- width: width,
43
- });
44
- this.canvas?.renderAll?.();
45
- });
46
- this.set({
47
- _id: new objectId_1.ObjectId().toString(),
48
- name: constants_1.TEXT_INPUT_OBJECT_ATTRIBUTES.name,
49
- type: constants_1.TEXT_INPUT_OBJECT_ATTRIBUTES.type,
50
- ...rest,
51
- layerId: options?.personalizeId ?? options?.layerId,
52
- objectCaching: false,
53
- });
54
- this.autoChangeFontSize(0.1);
55
- this.textObject.set({
56
- width: this.width,
57
- });
58
- if (options?.fontUrl) {
59
- (0, utils_1.loadFontFromUrl)(text?.fontFamily ?? "", options?.fontUrl).then(() => {
60
- this.canvas?.renderAll?.();
61
- });
62
- }
63
- if (options?.hideStroke) {
64
- this.rectObject.set({ strokeWidth: 0 });
65
- }
66
- },
67
- autoChangeFontSize: function (changeSpeed) {
68
- if (this.width <= this.textObject.__lineWidths ||
69
- this.height <= this.textObject.height) {
70
- while (this.width <= this.textObject.__lineWidths ||
71
- this.height <= this.textObject.height) {
72
- this.textObject.set({
73
- fontSize: this.textObject.fontSize - changeSpeed,
74
- });
75
- }
76
- }
77
- else {
78
- while (this.textObject.maxFontSize > this.textObject.fontSize &&
79
- this.width > this.textObject.__lineWidths &&
80
- this.height > this.textObject.height) {
81
- this.textObject.set({
82
- fontSize: this.textObject.fontSize + changeSpeed,
83
- });
84
- }
85
- }
86
- },
87
- setText: function (text) {
88
- this.textObject.set({
89
- text,
90
- });
91
- this.autoChangeFontSize(0.1);
92
- this.textObject.set({
93
- width: this.width,
94
- });
95
- this.canvas?.renderAll?.();
96
- },
97
- setMaxFontSize: function (fontSize) {
98
- this.textObject.set({
99
- fontSize,
100
- });
101
- if (this.textObject.__lineWidths < this.width &&
102
- this.textObject.height < this.height) {
103
- }
104
- else {
105
- this.autoChangeFontSize(1);
106
- }
107
- this.textObject.set({
108
- width: this.width,
109
- });
110
- this.textObject.set({
111
- maxFontSize: fontSize,
112
- });
113
- this.canvas?.renderAll?.();
114
- },
115
- setFontFamily: async function (fontName, fontUrl) {
116
- if (!(0, utils_1.isFontLoaded)(fontName)) {
117
- await (0, utils_1.loadFontFromUrl)(fontName, fontUrl ?? "");
118
- }
119
- this.textObject.set({ fontFamily: fontName });
120
- this.autoChangeFontSize(0.1);
121
- this.textObject.set({
122
- width: this.width,
123
- });
124
- this.canvas?.renderAll?.();
125
- },
126
- setSizes: function (options) {
127
- const { width, height } = options;
128
- if (width && width > this.textObject.__lineWidths) {
129
- this.set({ width });
130
- this.textObject.set({ width });
131
- }
132
- if (height && height > this.textObject.height) {
133
- this.set({ height });
134
- }
135
- this.canvas?.renderAll?.();
136
- },
137
- setTextAttributes: function (options) {
138
- this.textObject.set(options);
139
- this.textObject.set({
140
- width: this.width,
141
- });
142
- this.canvas?.renderAll?.();
143
- },
144
- getTextAttribute: function (attribute) {
145
- return this.textObject.get(attribute);
146
- },
147
- getSettings: function (attribute) {
148
- if (constants_1.PARENT_ATTRIBUTES.includes(attribute)) {
149
- return this.get(attribute);
150
- }
151
- return this.textObject.get(attribute);
152
- },
153
- });
154
- const toTextInputObject = (textInputObject) => {
155
- const textObject = textInputObject.textObject;
156
- return {
157
- id: textInputObject?._id,
158
- personalizeId: textInputObject?.layerId,
159
- layerId: textInputObject?.layerId,
160
- name: textInputObject?.name,
161
- locked: textInputObject?.locked,
162
- fontId: textInputObject?.fontId,
163
- fontCategoryId: textInputObject?.fontCategoryId,
164
- fontUrl: textInputObject?.fontUrl,
165
- isAdditional: textInputObject?.isAdditional,
166
- text: {
167
- fontWeight: textObject?.fontWeight,
168
- fontSize: textObject?.fontSize,
169
- textAlign: textObject?.textAlign,
170
- text: textObject?.text,
171
- fill: textObject?.fill,
172
- width: textObject?.width,
173
- height: textObject?.height,
174
- fontFamily: textObject?.fontFamily,
175
- maxFontSize: textObject?.maxFontSize,
176
- stroke: textObject?.stroke,
177
- strokeWidth: textObject?.strokeWidth,
178
- },
179
- };
180
- };
181
- exports.toTextInputObject = toTextInputObject;
182
- class TextInput extends fabric_1.fabric.Group {
183
- constructor(options) {
184
- super();
185
- return new TextInputClass(options);
186
- }
187
- }
188
- exports.TextInput = TextInput;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
package/lib/constants.js DELETED
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OBJECT_TYPES = void 0;
4
- const constants_1 = require("./ClipartObject/constants");
5
- const constants_2 = require("./ImagePlaceholderObject/constants");
6
- const constants_3 = require("./TextInputObject/constants");
7
- exports.OBJECT_TYPES = {
8
- textInput: constants_3.TEXT_INPUT_OBJECT_ATTRIBUTES.type,
9
- clipart: constants_1.CLIPART_OBJECT_ATTRIBUTES.type,
10
- imagePlaceHolder: constants_2.IMAGE_PLACEHOLDER_OBJECT_ATTRIBUTES.type,
11
- activeSelection: "activeSelection",
12
- };
package/lib/interfaces.js DELETED
@@ -1,19 +0,0 @@
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("./TextInputObject/interfaces"), exports);
18
- __exportStar(require("./ClipartObject/interfaces"), exports);
19
- __exportStar(require("./ImagePlaceholderObject/interfaces"), exports);
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BSONValue = void 0;
4
- const constants_1 = require("./constants");
5
- /** @public */
6
- class BSONValue {
7
- /** @internal */
8
- get [Symbol.for("@@mdb.bson.version")]() {
9
- return constants_1.BSON_MAJOR_VERSION;
10
- }
11
- }
12
- exports.BSONValue = BSONValue;
@@ -1,107 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BSONType = exports.BSON_BINARY_SUBTYPE_USER_DEFINED = exports.BSON_BINARY_SUBTYPE_COLUMN = exports.BSON_BINARY_SUBTYPE_ENCRYPTED = exports.BSON_BINARY_SUBTYPE_MD5 = exports.BSON_BINARY_SUBTYPE_UUID_NEW = exports.BSON_BINARY_SUBTYPE_UUID = exports.BSON_BINARY_SUBTYPE_BYTE_ARRAY = exports.BSON_BINARY_SUBTYPE_FUNCTION = exports.BSON_BINARY_SUBTYPE_DEFAULT = exports.BSON_DATA_MAX_KEY = exports.BSON_DATA_MIN_KEY = exports.BSON_DATA_DECIMAL128 = exports.BSON_DATA_LONG = exports.BSON_DATA_TIMESTAMP = exports.BSON_DATA_INT = exports.BSON_DATA_CODE_W_SCOPE = exports.BSON_DATA_SYMBOL = exports.BSON_DATA_CODE = exports.BSON_DATA_DBPOINTER = exports.BSON_DATA_REGEXP = exports.BSON_DATA_NULL = exports.BSON_DATA_DATE = exports.BSON_DATA_BOOLEAN = exports.BSON_DATA_OID = exports.BSON_DATA_UNDEFINED = exports.BSON_DATA_BINARY = exports.BSON_DATA_ARRAY = exports.BSON_DATA_OBJECT = exports.BSON_DATA_STRING = exports.BSON_DATA_NUMBER = exports.JS_INT_MIN = exports.JS_INT_MAX = exports.BSON_INT64_MIN = exports.BSON_INT64_MAX = exports.BSON_INT32_MIN = exports.BSON_INT32_MAX = exports.BSON_MAJOR_VERSION = void 0;
4
- /** @internal */
5
- exports.BSON_MAJOR_VERSION = 5;
6
- /** @internal */
7
- exports.BSON_INT32_MAX = 0x7fffffff;
8
- /** @internal */
9
- exports.BSON_INT32_MIN = -0x80000000;
10
- /** @internal */
11
- exports.BSON_INT64_MAX = Math.pow(2, 63) - 1;
12
- /** @internal */
13
- exports.BSON_INT64_MIN = -Math.pow(2, 63);
14
- /**
15
- * Any integer up to 2^53 can be precisely represented by a double.
16
- * @internal
17
- */
18
- exports.JS_INT_MAX = Math.pow(2, 53);
19
- /**
20
- * Any integer down to -2^53 can be precisely represented by a double.
21
- * @internal
22
- */
23
- exports.JS_INT_MIN = -Math.pow(2, 53);
24
- /** Number BSON Type @internal */
25
- exports.BSON_DATA_NUMBER = 1;
26
- /** String BSON Type @internal */
27
- exports.BSON_DATA_STRING = 2;
28
- /** Object BSON Type @internal */
29
- exports.BSON_DATA_OBJECT = 3;
30
- /** Array BSON Type @internal */
31
- exports.BSON_DATA_ARRAY = 4;
32
- /** Binary BSON Type @internal */
33
- exports.BSON_DATA_BINARY = 5;
34
- /** Binary BSON Type @internal */
35
- exports.BSON_DATA_UNDEFINED = 6;
36
- /** ObjectId BSON Type @internal */
37
- exports.BSON_DATA_OID = 7;
38
- /** Boolean BSON Type @internal */
39
- exports.BSON_DATA_BOOLEAN = 8;
40
- /** Date BSON Type @internal */
41
- exports.BSON_DATA_DATE = 9;
42
- /** null BSON Type @internal */
43
- exports.BSON_DATA_NULL = 10;
44
- /** RegExp BSON Type @internal */
45
- exports.BSON_DATA_REGEXP = 11;
46
- /** Code BSON Type @internal */
47
- exports.BSON_DATA_DBPOINTER = 12;
48
- /** Code BSON Type @internal */
49
- exports.BSON_DATA_CODE = 13;
50
- /** Symbol BSON Type @internal */
51
- exports.BSON_DATA_SYMBOL = 14;
52
- /** Code with Scope BSON Type @internal */
53
- exports.BSON_DATA_CODE_W_SCOPE = 15;
54
- /** 32 bit Integer BSON Type @internal */
55
- exports.BSON_DATA_INT = 16;
56
- /** Timestamp BSON Type @internal */
57
- exports.BSON_DATA_TIMESTAMP = 17;
58
- /** Long BSON Type @internal */
59
- exports.BSON_DATA_LONG = 18;
60
- /** Decimal128 BSON Type @internal */
61
- exports.BSON_DATA_DECIMAL128 = 19;
62
- /** MinKey BSON Type @internal */
63
- exports.BSON_DATA_MIN_KEY = 0xff;
64
- /** MaxKey BSON Type @internal */
65
- exports.BSON_DATA_MAX_KEY = 0x7f;
66
- /** Binary Default Type @internal */
67
- exports.BSON_BINARY_SUBTYPE_DEFAULT = 0;
68
- /** Binary Function Type @internal */
69
- exports.BSON_BINARY_SUBTYPE_FUNCTION = 1;
70
- /** Binary Byte Array Type @internal */
71
- exports.BSON_BINARY_SUBTYPE_BYTE_ARRAY = 2;
72
- /** Binary Deprecated UUID Type @deprecated Please use BSON_BINARY_SUBTYPE_UUID_NEW @internal */
73
- exports.BSON_BINARY_SUBTYPE_UUID = 3;
74
- /** Binary UUID Type @internal */
75
- exports.BSON_BINARY_SUBTYPE_UUID_NEW = 4;
76
- /** Binary MD5 Type @internal */
77
- exports.BSON_BINARY_SUBTYPE_MD5 = 5;
78
- /** Encrypted BSON type @internal */
79
- exports.BSON_BINARY_SUBTYPE_ENCRYPTED = 6;
80
- /** Column BSON type @internal */
81
- exports.BSON_BINARY_SUBTYPE_COLUMN = 7;
82
- /** Binary User Defined Type @internal */
83
- exports.BSON_BINARY_SUBTYPE_USER_DEFINED = 128;
84
- /** @public */
85
- exports.BSONType = Object.freeze({
86
- double: 1,
87
- string: 2,
88
- object: 3,
89
- array: 4,
90
- binData: 5,
91
- undefined: 6,
92
- objectId: 7,
93
- bool: 8,
94
- date: 9,
95
- null: 10,
96
- regex: 11,
97
- dbPointer: 12,
98
- javascript: 13,
99
- symbol: 14,
100
- javascriptWithScope: 15,
101
- int: 16,
102
- timestamp: 17,
103
- long: 18,
104
- decimal: 19,
105
- minKey: -1,
106
- maxKey: 127,
107
- });