customized-fabric 1.0.2 → 1.0.4
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/customizedFabric/ClipartObject/constants.d.ts +9 -0
- package/lib/customizedFabric/ClipartObject/index.d.ts +19 -0
- package/lib/customizedFabric/ClipartObject/interfaces.d.ts +30 -0
- package/lib/customizedFabric/ImagePlaceholderObject/constants.d.ts +9 -0
- package/lib/customizedFabric/ImagePlaceholderObject/index.d.ts +14 -0
- package/lib/customizedFabric/ImagePlaceholderObject/interfaces.d.ts +22 -0
- package/lib/customizedFabric/TextInputObject/constants.d.ts +11 -0
- package/lib/customizedFabric/TextInputObject/index.d.ts +30 -0
- package/lib/customizedFabric/TextInputObject/interfaces.d.ts +41 -0
- package/lib/customizedFabric/constants.d.ts +6 -0
- package/lib/customizedFabric/index.d.ts +8 -0
- package/lib/customizedFabric/interfaces.d.ts +3 -0
- package/lib/customizedFabric/utils.d.ts +11 -0
- package/lib/index.d.ts +1 -0
- package/lib/utils/objectId/bson_value.d.ts +9 -0
- package/lib/utils/objectId/constants.d.ts +106 -0
- package/lib/utils/objectId/error.d.ts +49 -0
- package/lib/utils/objectId/index.d.ts +95 -0
- package/lib/utils/objectId/parser/utils.d.ts +7 -0
- package/lib/utils/objectId/utils/byte_utils.d.ts +45 -0
- package/lib/utils/objectId/utils/node_byte_utils.d.ts +30 -0
- package/lib/utils/objectId/utils/web_byte_utils.d.ts +26 -0
- package/package.json +2 -1
@@ -0,0 +1,19 @@
|
|
1
|
+
import { fabric } from "fabric";
|
2
|
+
import { ObjectId } from "@/utils/objectId";
|
3
|
+
import { ClipartObject, IClipartOptions } from "./interfaces";
|
4
|
+
export declare const toClipartObject: (clipartObject: ClipartObject) => {
|
5
|
+
id: ObjectId;
|
6
|
+
personalizeId: number | undefined;
|
7
|
+
layerId: number | undefined;
|
8
|
+
name: string | undefined;
|
9
|
+
locked: boolean | undefined;
|
10
|
+
isAdditional: boolean | undefined;
|
11
|
+
clipartUrl: string | undefined;
|
12
|
+
clipartFile: File | undefined;
|
13
|
+
clipartRootCategoryId: string | undefined;
|
14
|
+
clipartCategoryId: string | undefined;
|
15
|
+
clipartOptionId: number | undefined;
|
16
|
+
};
|
17
|
+
export declare class Clipart extends fabric.Group {
|
18
|
+
constructor(options?: IClipartOptions);
|
19
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import { ObjectId } from "@/utils/objectId";
|
2
|
+
export interface ClipartObject extends fabric.Group {
|
3
|
+
_id: ObjectId;
|
4
|
+
layerId?: number;
|
5
|
+
locked?: boolean;
|
6
|
+
isAdditional?: boolean;
|
7
|
+
clipartFile?: File;
|
8
|
+
clipartRootCategoryId?: string;
|
9
|
+
clipartRootCategoryName?: string;
|
10
|
+
clipartCategoryId?: string;
|
11
|
+
clipartCategoryName?: string;
|
12
|
+
clipartOptionId?: number;
|
13
|
+
imageObject?: fabric.Image;
|
14
|
+
clipartUrl?: string;
|
15
|
+
loadImageFromFile: (imageFile: File) => void;
|
16
|
+
loadImageFromUrl: (imageUrl: string) => void;
|
17
|
+
getSettings: (attribute: string) => any;
|
18
|
+
setSizes: (options: {
|
19
|
+
width?: number;
|
20
|
+
height?: number;
|
21
|
+
}) => void;
|
22
|
+
}
|
23
|
+
export interface IClipartOptions extends fabric.IGroupOptions {
|
24
|
+
_id?: string;
|
25
|
+
personalizeId?: number;
|
26
|
+
layerId: number;
|
27
|
+
clipartUrl?: string;
|
28
|
+
clipartFile?: File;
|
29
|
+
hideStroke?: boolean;
|
30
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { fabric } from "fabric";
|
2
|
+
import { ObjectId } from "@/utils/objectId";
|
3
|
+
import { IImagePlaceholderOptions, ImagePlaceholderObject } from "./interfaces";
|
4
|
+
export declare const toImagePlaceholderObject: (imagePlaceholderObject: ImagePlaceholderObject) => {
|
5
|
+
id: ObjectId;
|
6
|
+
personalizeId: number;
|
7
|
+
layerId: number;
|
8
|
+
name: string | undefined;
|
9
|
+
locked: boolean;
|
10
|
+
isAdditional: boolean;
|
11
|
+
};
|
12
|
+
export declare class ImagePlaceholder extends fabric.Group {
|
13
|
+
constructor(options?: IImagePlaceholderOptions);
|
14
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import { ObjectId } from "@/utils/objectId";
|
2
|
+
export interface ImagePlaceholderObject extends fabric.Group {
|
3
|
+
_id: ObjectId;
|
4
|
+
layerId: number;
|
5
|
+
locked: boolean;
|
6
|
+
imageFile?: File;
|
7
|
+
isAdditional: boolean;
|
8
|
+
loadImageFromFile: (imageFile: File) => void;
|
9
|
+
loadImageFromUrl: (imageUrl: string) => void;
|
10
|
+
getSettings: (attribute: string) => any;
|
11
|
+
setSizes: (options: {
|
12
|
+
width?: number;
|
13
|
+
height?: number;
|
14
|
+
}) => void;
|
15
|
+
}
|
16
|
+
export interface IImagePlaceholderOptions extends fabric.IGroupOptions {
|
17
|
+
_id?: string;
|
18
|
+
personalizeId?: number;
|
19
|
+
layerId: number;
|
20
|
+
imageFile?: File;
|
21
|
+
hideStroke?: boolean;
|
22
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import { fabric } from "fabric";
|
2
|
+
import { ObjectId } from "@/utils/objectId";
|
3
|
+
import { ITextInputOptions, TextInputObject } from "./interfaces";
|
4
|
+
export declare const toTextInputObject: (textInputObject: TextInputObject) => {
|
5
|
+
id: ObjectId;
|
6
|
+
personalizeId: number;
|
7
|
+
layerId: number;
|
8
|
+
name: string | undefined;
|
9
|
+
locked: boolean;
|
10
|
+
fontId: number;
|
11
|
+
fontCategoryId: string;
|
12
|
+
fontUrl: string;
|
13
|
+
isAdditional: boolean;
|
14
|
+
text: {
|
15
|
+
fontWeight: string | number | undefined;
|
16
|
+
fontSize: number | undefined;
|
17
|
+
textAlign: string | undefined;
|
18
|
+
text: string | undefined;
|
19
|
+
fill: string | fabric.Gradient | fabric.Pattern | undefined;
|
20
|
+
width: number | undefined;
|
21
|
+
height: number | undefined;
|
22
|
+
fontFamily: string | undefined;
|
23
|
+
maxFontSize: any;
|
24
|
+
stroke: string | undefined;
|
25
|
+
strokeWidth: number | undefined;
|
26
|
+
};
|
27
|
+
};
|
28
|
+
export declare class TextInput extends fabric.Group {
|
29
|
+
constructor(options?: ITextInputOptions);
|
30
|
+
}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import { ObjectId } from "@/utils/objectId";
|
2
|
+
export interface TextInputObject extends fabric.Group {
|
3
|
+
_id: ObjectId;
|
4
|
+
layerId: number;
|
5
|
+
locked: boolean;
|
6
|
+
textObject: fabric.IText;
|
7
|
+
fontId: number;
|
8
|
+
fontCategoryId: string;
|
9
|
+
fontUrl: string;
|
10
|
+
isAdditional: boolean;
|
11
|
+
setText: (text: string) => void;
|
12
|
+
setMaxFontSize: (fontSize: string) => void;
|
13
|
+
setFontFamily: (fontName: string, fontUrl?: string) => void;
|
14
|
+
setTextAttributes: (options: fabric.ITextOptions) => void;
|
15
|
+
getTextAttribute: (attribute: string) => any;
|
16
|
+
getSettings: (attribute: string) => any;
|
17
|
+
setSizes: (options: {
|
18
|
+
width?: number;
|
19
|
+
height?: number;
|
20
|
+
}) => void;
|
21
|
+
}
|
22
|
+
export interface ITextInputOptions extends fabric.IGroupOptions {
|
23
|
+
_id?: ObjectId;
|
24
|
+
personalizeId?: string;
|
25
|
+
layerId: number;
|
26
|
+
text: {
|
27
|
+
fontSize?: number;
|
28
|
+
fill?: string;
|
29
|
+
width?: number;
|
30
|
+
height?: number;
|
31
|
+
textAlign?: string;
|
32
|
+
fontWeight?: string;
|
33
|
+
text: string;
|
34
|
+
fontFamily?: string;
|
35
|
+
maxFontSize: number;
|
36
|
+
stroke?: string;
|
37
|
+
strokeWidth?: number;
|
38
|
+
};
|
39
|
+
fontUrl?: string;
|
40
|
+
hideStroke?: boolean;
|
41
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { fabric } from "fabric";
|
2
|
+
import { Clipart, TextInput } from ".";
|
3
|
+
import { ImagePlaceholder } from "./ImagePlaceholderObject";
|
4
|
+
export declare const loadFontFromUrl: (name: string, url: string) => Promise<void>;
|
5
|
+
export declare const isFontLoaded: (name: string) => boolean;
|
6
|
+
export declare const loadImageFromFile: (image: File) => Promise<fabric.Image>;
|
7
|
+
export declare const lockObject: (object: fabric.Object | any, locked: boolean, selectable?: boolean) => void;
|
8
|
+
export declare const lockAllObjects: (canvas: fabric.Canvas, locked: boolean) => void;
|
9
|
+
export declare const getObject: (object: any, options?: {
|
10
|
+
isOriginal?: boolean;
|
11
|
+
}) => ImagePlaceholder | TextInput | Clipart | undefined;
|
package/lib/index.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export * from "./customizedFabric";
|
@@ -0,0 +1,106 @@
|
|
1
|
+
/** @internal */
|
2
|
+
export declare const BSON_MAJOR_VERSION: 5;
|
3
|
+
/** @internal */
|
4
|
+
export declare const BSON_INT32_MAX = 2147483647;
|
5
|
+
/** @internal */
|
6
|
+
export declare const BSON_INT32_MIN = -2147483648;
|
7
|
+
/** @internal */
|
8
|
+
export declare const BSON_INT64_MAX: number;
|
9
|
+
/** @internal */
|
10
|
+
export declare const BSON_INT64_MIN: number;
|
11
|
+
/**
|
12
|
+
* Any integer up to 2^53 can be precisely represented by a double.
|
13
|
+
* @internal
|
14
|
+
*/
|
15
|
+
export declare const JS_INT_MAX: number;
|
16
|
+
/**
|
17
|
+
* Any integer down to -2^53 can be precisely represented by a double.
|
18
|
+
* @internal
|
19
|
+
*/
|
20
|
+
export declare const JS_INT_MIN: number;
|
21
|
+
/** Number BSON Type @internal */
|
22
|
+
export declare const BSON_DATA_NUMBER = 1;
|
23
|
+
/** String BSON Type @internal */
|
24
|
+
export declare const BSON_DATA_STRING = 2;
|
25
|
+
/** Object BSON Type @internal */
|
26
|
+
export declare const BSON_DATA_OBJECT = 3;
|
27
|
+
/** Array BSON Type @internal */
|
28
|
+
export declare const BSON_DATA_ARRAY = 4;
|
29
|
+
/** Binary BSON Type @internal */
|
30
|
+
export declare const BSON_DATA_BINARY = 5;
|
31
|
+
/** Binary BSON Type @internal */
|
32
|
+
export declare const BSON_DATA_UNDEFINED = 6;
|
33
|
+
/** ObjectId BSON Type @internal */
|
34
|
+
export declare const BSON_DATA_OID = 7;
|
35
|
+
/** Boolean BSON Type @internal */
|
36
|
+
export declare const BSON_DATA_BOOLEAN = 8;
|
37
|
+
/** Date BSON Type @internal */
|
38
|
+
export declare const BSON_DATA_DATE = 9;
|
39
|
+
/** null BSON Type @internal */
|
40
|
+
export declare const BSON_DATA_NULL = 10;
|
41
|
+
/** RegExp BSON Type @internal */
|
42
|
+
export declare const BSON_DATA_REGEXP = 11;
|
43
|
+
/** Code BSON Type @internal */
|
44
|
+
export declare const BSON_DATA_DBPOINTER = 12;
|
45
|
+
/** Code BSON Type @internal */
|
46
|
+
export declare const BSON_DATA_CODE = 13;
|
47
|
+
/** Symbol BSON Type @internal */
|
48
|
+
export declare const BSON_DATA_SYMBOL = 14;
|
49
|
+
/** Code with Scope BSON Type @internal */
|
50
|
+
export declare const BSON_DATA_CODE_W_SCOPE = 15;
|
51
|
+
/** 32 bit Integer BSON Type @internal */
|
52
|
+
export declare const BSON_DATA_INT = 16;
|
53
|
+
/** Timestamp BSON Type @internal */
|
54
|
+
export declare const BSON_DATA_TIMESTAMP = 17;
|
55
|
+
/** Long BSON Type @internal */
|
56
|
+
export declare const BSON_DATA_LONG = 18;
|
57
|
+
/** Decimal128 BSON Type @internal */
|
58
|
+
export declare const BSON_DATA_DECIMAL128 = 19;
|
59
|
+
/** MinKey BSON Type @internal */
|
60
|
+
export declare const BSON_DATA_MIN_KEY = 255;
|
61
|
+
/** MaxKey BSON Type @internal */
|
62
|
+
export declare const BSON_DATA_MAX_KEY = 127;
|
63
|
+
/** Binary Default Type @internal */
|
64
|
+
export declare const BSON_BINARY_SUBTYPE_DEFAULT = 0;
|
65
|
+
/** Binary Function Type @internal */
|
66
|
+
export declare const BSON_BINARY_SUBTYPE_FUNCTION = 1;
|
67
|
+
/** Binary Byte Array Type @internal */
|
68
|
+
export declare const BSON_BINARY_SUBTYPE_BYTE_ARRAY = 2;
|
69
|
+
/** Binary Deprecated UUID Type @deprecated Please use BSON_BINARY_SUBTYPE_UUID_NEW @internal */
|
70
|
+
export declare const BSON_BINARY_SUBTYPE_UUID = 3;
|
71
|
+
/** Binary UUID Type @internal */
|
72
|
+
export declare const BSON_BINARY_SUBTYPE_UUID_NEW = 4;
|
73
|
+
/** Binary MD5 Type @internal */
|
74
|
+
export declare const BSON_BINARY_SUBTYPE_MD5 = 5;
|
75
|
+
/** Encrypted BSON type @internal */
|
76
|
+
export declare const BSON_BINARY_SUBTYPE_ENCRYPTED = 6;
|
77
|
+
/** Column BSON type @internal */
|
78
|
+
export declare const BSON_BINARY_SUBTYPE_COLUMN = 7;
|
79
|
+
/** Binary User Defined Type @internal */
|
80
|
+
export declare const BSON_BINARY_SUBTYPE_USER_DEFINED = 128;
|
81
|
+
/** @public */
|
82
|
+
export declare const BSONType: Readonly<{
|
83
|
+
readonly double: 1;
|
84
|
+
readonly string: 2;
|
85
|
+
readonly object: 3;
|
86
|
+
readonly array: 4;
|
87
|
+
readonly binData: 5;
|
88
|
+
readonly undefined: 6;
|
89
|
+
readonly objectId: 7;
|
90
|
+
readonly bool: 8;
|
91
|
+
readonly date: 9;
|
92
|
+
readonly null: 10;
|
93
|
+
readonly regex: 11;
|
94
|
+
readonly dbPointer: 12;
|
95
|
+
readonly javascript: 13;
|
96
|
+
readonly symbol: 14;
|
97
|
+
readonly javascriptWithScope: 15;
|
98
|
+
readonly int: 16;
|
99
|
+
readonly timestamp: 17;
|
100
|
+
readonly long: 18;
|
101
|
+
readonly decimal: 19;
|
102
|
+
readonly minKey: -1;
|
103
|
+
readonly maxKey: 127;
|
104
|
+
}>;
|
105
|
+
/** @public */
|
106
|
+
export type BSONType = (typeof BSONType)[keyof typeof BSONType];
|
@@ -0,0 +1,49 @@
|
|
1
|
+
/**
|
2
|
+
* @public
|
3
|
+
* @category Error
|
4
|
+
*
|
5
|
+
* `BSONError` objects are thrown when BSON ecounters an error.
|
6
|
+
*
|
7
|
+
* This is the parent class for all the other errors thrown by this library.
|
8
|
+
*/
|
9
|
+
export declare class BSONError extends Error {
|
10
|
+
/**
|
11
|
+
* @internal
|
12
|
+
* The underlying algorithm for isBSONError may change to improve how strict it is
|
13
|
+
* about determining if an input is a BSONError. But it must remain backwards compatible
|
14
|
+
* with previous minors & patches of the current major version.
|
15
|
+
*/
|
16
|
+
protected get bsonError(): true;
|
17
|
+
get name(): string;
|
18
|
+
constructor(message: string);
|
19
|
+
/**
|
20
|
+
* @public
|
21
|
+
*
|
22
|
+
* All errors thrown from the BSON library inherit from `BSONError`.
|
23
|
+
* This method can assist with determining if an error originates from the BSON library
|
24
|
+
* even if it does not pass an `instanceof` check against this class' constructor.
|
25
|
+
*
|
26
|
+
* @param value - any javascript value that needs type checking
|
27
|
+
*/
|
28
|
+
static isBSONError(value: unknown): value is BSONError;
|
29
|
+
}
|
30
|
+
/**
|
31
|
+
* @public
|
32
|
+
* @category Error
|
33
|
+
*/
|
34
|
+
export declare class BSONVersionError extends BSONError {
|
35
|
+
get name(): "BSONVersionError";
|
36
|
+
constructor();
|
37
|
+
}
|
38
|
+
/**
|
39
|
+
* @public
|
40
|
+
* @category Error
|
41
|
+
*
|
42
|
+
* An error generated when BSON functions encounter an unexpected input
|
43
|
+
* or reaches an unexpected/invalid internal state
|
44
|
+
*
|
45
|
+
*/
|
46
|
+
export declare class BSONRuntimeError extends BSONError {
|
47
|
+
get name(): "BSONRuntimeError";
|
48
|
+
constructor(message: string);
|
49
|
+
}
|
@@ -0,0 +1,95 @@
|
|
1
|
+
import { BSONValue } from "./bson_value";
|
2
|
+
/** @public */
|
3
|
+
export interface ObjectIdLike {
|
4
|
+
id: string | Uint8Array;
|
5
|
+
__id?: string;
|
6
|
+
toHexString(): string;
|
7
|
+
}
|
8
|
+
/** @public */
|
9
|
+
export interface ObjectIdExtended {
|
10
|
+
$oid: string;
|
11
|
+
}
|
12
|
+
declare const kId: unique symbol;
|
13
|
+
/**
|
14
|
+
* A class representation of the BSON ObjectId type.
|
15
|
+
* @public
|
16
|
+
* @category BSONType
|
17
|
+
*/
|
18
|
+
export declare class ObjectId extends BSONValue {
|
19
|
+
get _bsontype(): "ObjectId";
|
20
|
+
/** @internal */
|
21
|
+
private static index;
|
22
|
+
static cacheHexString: boolean;
|
23
|
+
/** ObjectId Bytes @internal */
|
24
|
+
private [kId];
|
25
|
+
/** ObjectId hexString cache @internal */
|
26
|
+
private __id?;
|
27
|
+
/**
|
28
|
+
* Create an ObjectId type
|
29
|
+
*
|
30
|
+
* @param inputId - Can be a 24 character hex string, 12 byte binary Buffer, or a number.
|
31
|
+
*/
|
32
|
+
constructor(inputId?: string | number | ObjectId | ObjectIdLike | Uint8Array);
|
33
|
+
/**
|
34
|
+
* The ObjectId bytes
|
35
|
+
* @readonly
|
36
|
+
*/
|
37
|
+
get id(): Uint8Array;
|
38
|
+
set id(value: Uint8Array);
|
39
|
+
/** Returns the ObjectId id as a 24 character hex string representation */
|
40
|
+
toHexString(): string;
|
41
|
+
/**
|
42
|
+
* Update the ObjectId index
|
43
|
+
* @internal
|
44
|
+
*/
|
45
|
+
private static getInc;
|
46
|
+
/**
|
47
|
+
* Generate a 12 byte id buffer used in ObjectId's
|
48
|
+
*
|
49
|
+
* @param time - pass in a second based timestamp.
|
50
|
+
*/
|
51
|
+
static generate(time?: number): Uint8Array;
|
52
|
+
/**
|
53
|
+
* Converts the id into a 24 character hex string for printing, unless encoding is provided.
|
54
|
+
* @param encoding - hex or base64
|
55
|
+
*/
|
56
|
+
toString(encoding?: "hex" | "base64"): string;
|
57
|
+
/** Converts to its JSON the 24 character hex string representation. */
|
58
|
+
toJSON(): string;
|
59
|
+
/**
|
60
|
+
* Compares the equality of this ObjectId with `otherID`.
|
61
|
+
*
|
62
|
+
* @param otherId - ObjectId instance to compare against.
|
63
|
+
*/
|
64
|
+
equals(otherId: string | ObjectId | ObjectIdLike): boolean;
|
65
|
+
/** Returns the generation date (accurate up to the second) that this ID was generated. */
|
66
|
+
getTimestamp(): Date;
|
67
|
+
/** @internal */
|
68
|
+
static createPk(): ObjectId;
|
69
|
+
/**
|
70
|
+
* Creates an ObjectId from a second based number, with the rest of the ObjectId zeroed out. Used for comparisons or sorting the ObjectId.
|
71
|
+
*
|
72
|
+
* @param time - an integer number representing a number of seconds.
|
73
|
+
*/
|
74
|
+
static createFromTime(time: number): ObjectId;
|
75
|
+
/**
|
76
|
+
* Creates an ObjectId from a hex string representation of an ObjectId.
|
77
|
+
*
|
78
|
+
* @param hexString - create a ObjectId from a passed in 24 character hexstring.
|
79
|
+
*/
|
80
|
+
static createFromHexString(hexString: string): ObjectId;
|
81
|
+
/** Creates an ObjectId instance from a base64 string */
|
82
|
+
static createFromBase64(base64: string): ObjectId;
|
83
|
+
/**
|
84
|
+
* Checks if a value is a valid bson ObjectId
|
85
|
+
*
|
86
|
+
* @param id - ObjectId instance to validate.
|
87
|
+
*/
|
88
|
+
static isValid(id: string | number | ObjectId | ObjectIdLike | Uint8Array): boolean;
|
89
|
+
/** @internal */
|
90
|
+
toExtendedJSON(): ObjectIdExtended;
|
91
|
+
/** @internal */
|
92
|
+
static fromExtendedJSON(doc: ObjectIdExtended): ObjectId;
|
93
|
+
inspect(): string;
|
94
|
+
}
|
95
|
+
export {};
|
@@ -0,0 +1,7 @@
|
|
1
|
+
export declare function isAnyArrayBuffer(value: unknown): value is ArrayBuffer;
|
2
|
+
export declare function isUint8Array(value: unknown): value is Uint8Array;
|
3
|
+
export declare function isBigInt64Array(value: unknown): value is BigInt64Array;
|
4
|
+
export declare function isBigUInt64Array(value: unknown): value is BigUint64Array;
|
5
|
+
export declare function isRegExp(d: unknown): d is RegExp;
|
6
|
+
export declare function isMap(d: unknown): d is Map<unknown, unknown>;
|
7
|
+
export declare function isDate(d: unknown): d is Date;
|
@@ -0,0 +1,45 @@
|
|
1
|
+
/** @internal */
|
2
|
+
export type ByteUtils = {
|
3
|
+
/** Transforms the input to an instance of Buffer if running on node, otherwise Uint8Array */
|
4
|
+
toLocalBufferType(buffer: Uint8Array | ArrayBufferView | ArrayBuffer): Uint8Array;
|
5
|
+
/** Create empty space of size */
|
6
|
+
allocate: (size: number) => Uint8Array;
|
7
|
+
/** Check if two Uint8Arrays are deep equal */
|
8
|
+
equals: (a: Uint8Array, b: Uint8Array) => boolean;
|
9
|
+
/** Check if two Uint8Arrays are deep equal */
|
10
|
+
fromNumberArray: (array: number[]) => Uint8Array;
|
11
|
+
/** Create a Uint8Array from a base64 string */
|
12
|
+
fromBase64: (base64: string) => Uint8Array;
|
13
|
+
/** Create a base64 string from bytes */
|
14
|
+
toBase64: (buffer: Uint8Array) => string;
|
15
|
+
/** **Legacy** binary strings are an outdated method of data transfer. Do not add public API support for interpreting this format */
|
16
|
+
fromISO88591: (codePoints: string) => Uint8Array;
|
17
|
+
/** **Legacy** binary strings are an outdated method of data transfer. Do not add public API support for interpreting this format */
|
18
|
+
toISO88591: (buffer: Uint8Array) => string;
|
19
|
+
/** Create a Uint8Array from a hex string */
|
20
|
+
fromHex: (hex: string) => Uint8Array;
|
21
|
+
/** Create a hex string from bytes */
|
22
|
+
toHex: (buffer: Uint8Array) => string;
|
23
|
+
/** Create a Uint8Array containing utf8 code units from a string */
|
24
|
+
fromUTF8: (text: string) => Uint8Array;
|
25
|
+
/** Create a string from utf8 code units */
|
26
|
+
toUTF8: (buffer: Uint8Array, start: number, end: number) => string;
|
27
|
+
/** Get the utf8 code unit count from a string if it were to be transformed to utf8 */
|
28
|
+
utf8ByteLength: (input: string) => number;
|
29
|
+
/** Encode UTF8 bytes generated from `source` string into `destination` at byteOffset. Returns the number of bytes encoded. */
|
30
|
+
encodeUTF8Into(destination: Uint8Array, source: string, byteOffset: number): number;
|
31
|
+
/** Generate a Uint8Array filled with random bytes with byteLength */
|
32
|
+
randomBytes(byteLength: number): Uint8Array;
|
33
|
+
};
|
34
|
+
/**
|
35
|
+
* This is the only ByteUtils that should be used across the rest of the BSON library.
|
36
|
+
*
|
37
|
+
* The type annotation is important here, it asserts that each of the platform specific
|
38
|
+
* utils implementations are compatible with the common one.
|
39
|
+
*
|
40
|
+
* @internal
|
41
|
+
*/
|
42
|
+
export declare const ByteUtils: ByteUtils;
|
43
|
+
export declare class BSONDataView extends DataView {
|
44
|
+
static fromUint8Array(input: Uint8Array): DataView;
|
45
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
type NodeJsEncoding = "base64" | "hex" | "utf8" | "binary";
|
2
|
+
type NodeJsBuffer = ArrayBufferView & Uint8Array & {
|
3
|
+
write(string: string, offset: number, length: undefined, encoding: "utf8"): number;
|
4
|
+
copy(target: Uint8Array, targetStart: number, sourceStart: number, sourceEnd: number): number;
|
5
|
+
toString: (this: Uint8Array, encoding: NodeJsEncoding, start?: number, end?: number) => string;
|
6
|
+
equals: (this: Uint8Array, other: Uint8Array) => boolean;
|
7
|
+
};
|
8
|
+
/** @internal */
|
9
|
+
export declare function nodejsMathRandomBytes(byteLength: number): NodeJsBuffer;
|
10
|
+
/** @internal */
|
11
|
+
export declare const nodeJsByteUtils: {
|
12
|
+
toLocalBufferType(potentialBuffer: Uint8Array | NodeJsBuffer | ArrayBuffer): NodeJsBuffer;
|
13
|
+
allocate(size: number): NodeJsBuffer;
|
14
|
+
equals(a: Uint8Array, b: Uint8Array): boolean;
|
15
|
+
fromNumberArray(array: number[]): NodeJsBuffer;
|
16
|
+
fromBase64(base64: string): NodeJsBuffer;
|
17
|
+
toBase64(buffer: Uint8Array): string;
|
18
|
+
/** **Legacy** binary strings are an outdated method of data transfer. Do not add public API support for interpreting this format */
|
19
|
+
fromISO88591(codePoints: string): NodeJsBuffer;
|
20
|
+
/** **Legacy** binary strings are an outdated method of data transfer. Do not add public API support for interpreting this format */
|
21
|
+
toISO88591(buffer: Uint8Array): string;
|
22
|
+
fromHex(hex: string): NodeJsBuffer;
|
23
|
+
toHex(buffer: Uint8Array): string;
|
24
|
+
fromUTF8(text: string): NodeJsBuffer;
|
25
|
+
toUTF8(buffer: Uint8Array, start: number, end: number): string;
|
26
|
+
utf8ByteLength(input: string): number;
|
27
|
+
encodeUTF8Into(buffer: Uint8Array, source: string, byteOffset: number): number;
|
28
|
+
randomBytes: (byteLength: number) => Uint8Array;
|
29
|
+
};
|
30
|
+
export {};
|
@@ -0,0 +1,26 @@
|
|
1
|
+
type ArrayBufferViewWithTag = ArrayBufferView & {
|
2
|
+
[Symbol.toStringTag]?: string;
|
3
|
+
};
|
4
|
+
/** @internal */
|
5
|
+
export declare function webMathRandomBytes(byteLength: number): Uint8Array;
|
6
|
+
/** @internal */
|
7
|
+
export declare const webByteUtils: {
|
8
|
+
toLocalBufferType(potentialUint8array: Uint8Array | ArrayBufferViewWithTag | ArrayBuffer): Uint8Array;
|
9
|
+
allocate(size: number): Uint8Array;
|
10
|
+
equals(a: Uint8Array, b: Uint8Array): boolean;
|
11
|
+
fromNumberArray(array: number[]): Uint8Array;
|
12
|
+
fromBase64(base64: string): Uint8Array;
|
13
|
+
toBase64(uint8array: Uint8Array): string;
|
14
|
+
/** **Legacy** binary strings are an outdated method of data transfer. Do not add public API support for interpreting this format */
|
15
|
+
fromISO88591(codePoints: string): Uint8Array;
|
16
|
+
/** **Legacy** binary strings are an outdated method of data transfer. Do not add public API support for interpreting this format */
|
17
|
+
toISO88591(uint8array: Uint8Array): string;
|
18
|
+
fromHex(hex: string): Uint8Array;
|
19
|
+
toHex(uint8array: Uint8Array): string;
|
20
|
+
fromUTF8(text: string): Uint8Array;
|
21
|
+
toUTF8(uint8array: Uint8Array, start: number, end: number): string;
|
22
|
+
utf8ByteLength(input: string): number;
|
23
|
+
encodeUTF8Into(buffer: Uint8Array, source: string, byteOffset: number): number;
|
24
|
+
randomBytes: (byteLength: number) => Uint8Array;
|
25
|
+
};
|
26
|
+
export {};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "customized-fabric",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.4",
|
4
4
|
"description": "Customized fabric",
|
5
5
|
"main": "lib/index.js",
|
6
6
|
"types": "lib/index.d.ts",
|
@@ -15,6 +15,7 @@
|
|
15
15
|
"author": "",
|
16
16
|
"license": "ISC",
|
17
17
|
"dependencies": {
|
18
|
+
"@types/node": "^18.15.11",
|
18
19
|
"fabric": "^5.3.0"
|
19
20
|
},
|
20
21
|
"devDependencies": {
|