@firmer/mesh 0.0.10 → 0.0.11
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/codec/buffer.d.ts +98 -0
- package/dist/codec/codec.d.ts +6 -0
- package/dist/codec/index.d.ts +2 -0
- package/dist/codec/json.d.ts +0 -2
- package/dist/codec/text.d.ts +44 -0
- package/dist/mesh.js +10513 -11193
- package/dist/mesh.umd.cjs +6 -24
- package/dist/test/buffer.test.d.ts +1 -0
- package/dist/test/text.test.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
export type BufferEncoding = 'utf8' | 'utf-8' | 'base64' | 'hex';
|
|
2
|
+
/**
|
|
3
|
+
* Cross-platform Buffer implementation
|
|
4
|
+
* Compatible with Node.js Buffer API subset
|
|
5
|
+
* Works on browsers, Node.js, and mini-programs (WeChat, Alipay, etc.)
|
|
6
|
+
*/
|
|
7
|
+
export declare class Buffer extends Uint8Array {
|
|
8
|
+
/**
|
|
9
|
+
* Base64 character set
|
|
10
|
+
*/
|
|
11
|
+
private static readonly BASE64_CHARS;
|
|
12
|
+
private static readonly BASE64_LOOKUP;
|
|
13
|
+
/**
|
|
14
|
+
* Create a Buffer from various input types
|
|
15
|
+
* @param value string, Uint8Array, ArrayBuffer, or array of bytes
|
|
16
|
+
* @param encodingOrOffset encoding type for string, or offset for array-like
|
|
17
|
+
* @param length length parameter
|
|
18
|
+
* @returns Buffer instance
|
|
19
|
+
*/
|
|
20
|
+
static from(value: string, encoding?: BufferEncoding): Buffer;
|
|
21
|
+
static from(value: Uint8Array): Buffer;
|
|
22
|
+
static from(value: ArrayBuffer): Buffer;
|
|
23
|
+
static from(value: ArrayLike<number>): Buffer;
|
|
24
|
+
static from(value: Iterable<number>): Buffer;
|
|
25
|
+
/**
|
|
26
|
+
* Create a Buffer from a string with specified encoding
|
|
27
|
+
*/
|
|
28
|
+
private static fromString;
|
|
29
|
+
/**
|
|
30
|
+
* Encode string to UTF-8 bytes
|
|
31
|
+
*/
|
|
32
|
+
private static encodeUtf8;
|
|
33
|
+
/**
|
|
34
|
+
* Decode base64 string to bytes
|
|
35
|
+
*/
|
|
36
|
+
private static decodeBase64;
|
|
37
|
+
/**
|
|
38
|
+
* Decode hex string to bytes
|
|
39
|
+
*/
|
|
40
|
+
private static decodeHex;
|
|
41
|
+
/**
|
|
42
|
+
* Allocate a new Buffer of specified size
|
|
43
|
+
* @param size buffer size in bytes
|
|
44
|
+
* @param fill optional fill value
|
|
45
|
+
* @returns Buffer instance
|
|
46
|
+
*/
|
|
47
|
+
static alloc(size: number, fill?: number | string, encoding?: BufferEncoding): Buffer;
|
|
48
|
+
/**
|
|
49
|
+
* Allocate an uninitialized Buffer
|
|
50
|
+
* @param size buffer size in bytes
|
|
51
|
+
* @returns Buffer instance
|
|
52
|
+
*/
|
|
53
|
+
static allocUnsafe(size: number): Buffer;
|
|
54
|
+
/**
|
|
55
|
+
* Check if an object is a Buffer
|
|
56
|
+
*/
|
|
57
|
+
static isBuffer(obj: any): obj is Buffer;
|
|
58
|
+
/**
|
|
59
|
+
* Concatenate multiple buffers
|
|
60
|
+
*/
|
|
61
|
+
static concat(list: Uint8Array[], totalLength?: number): Buffer;
|
|
62
|
+
/**
|
|
63
|
+
* Compare two buffers
|
|
64
|
+
*/
|
|
65
|
+
static compare(a: Uint8Array, b: Uint8Array): number;
|
|
66
|
+
/**
|
|
67
|
+
* Instance method: Convert Buffer to string with specified encoding
|
|
68
|
+
* @param encoding encoding type (base64, hex, utf8, etc.)
|
|
69
|
+
* @param start start index
|
|
70
|
+
* @param end end index
|
|
71
|
+
* @returns encoded string
|
|
72
|
+
*/
|
|
73
|
+
toString(encoding?: BufferEncoding, start?: number, end?: number): string;
|
|
74
|
+
/**
|
|
75
|
+
* Decode UTF-8 bytes to string
|
|
76
|
+
*/
|
|
77
|
+
private static decodeUtf8;
|
|
78
|
+
/**
|
|
79
|
+
* Encode bytes to base64 string
|
|
80
|
+
*/
|
|
81
|
+
private static encodeBase64;
|
|
82
|
+
/**
|
|
83
|
+
* Encode bytes to hex string
|
|
84
|
+
*/
|
|
85
|
+
private static encodeHex;
|
|
86
|
+
/**
|
|
87
|
+
* Instance method: Compare with another buffer
|
|
88
|
+
*/
|
|
89
|
+
compare(target: Uint8Array): number;
|
|
90
|
+
/**
|
|
91
|
+
* Instance method: Check if buffer equals another buffer
|
|
92
|
+
*/
|
|
93
|
+
equals(other: Uint8Array): boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Instance method: Write string to buffer at specified offset
|
|
96
|
+
*/
|
|
97
|
+
write(str: string, offset?: number, length?: number, encoding?: BufferEncoding): number;
|
|
98
|
+
}
|
package/dist/codec/codec.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Type } from '../macro';
|
|
2
|
+
import { TextEncoder as TextEncoderX } from './text';
|
|
3
|
+
import { Buffer as BufferX } from './buffer';
|
|
2
4
|
export declare abstract class Codec {
|
|
3
5
|
static JSON: string;
|
|
4
6
|
static PROTOBUF: string;
|
|
@@ -41,3 +43,7 @@ export declare abstract class Codec {
|
|
|
41
43
|
*/
|
|
42
44
|
abstract stringify<T>(buffer: Uint8Array): string;
|
|
43
45
|
}
|
|
46
|
+
declare const textEncoder: TextEncoderX;
|
|
47
|
+
declare const textDecoder: TextDecoder;
|
|
48
|
+
declare const buffer: typeof BufferX | BufferConstructor;
|
|
49
|
+
export { textEncoder, textDecoder, buffer };
|
package/dist/codec/index.d.ts
CHANGED
package/dist/codec/json.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { Type } from '../macro';
|
|
2
2
|
import { Codec } from './codec';
|
|
3
3
|
export declare class JSONCodec extends Codec {
|
|
4
|
-
private readonly encoder;
|
|
5
|
-
private readonly decoder;
|
|
6
4
|
decode<T>(buffer: Uint8Array, type: Type<T>): T;
|
|
7
5
|
decorateAny(type: Type<any>, dict: any): any;
|
|
8
6
|
encode(value: any): Uint8Array;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-platform TextEncoder implementation
|
|
3
|
+
* Compatible with standard TextEncoder API
|
|
4
|
+
* Works on browsers, Node.js, and mini-programs (WeChat, Alipay, etc.)
|
|
5
|
+
*/
|
|
6
|
+
export declare class TextEncoder {
|
|
7
|
+
readonly encoding: string;
|
|
8
|
+
/**
|
|
9
|
+
* Encode string to Uint8Array using UTF-8 encoding
|
|
10
|
+
* @param input string to encode
|
|
11
|
+
* @returns UTF-8 encoded Uint8Array
|
|
12
|
+
*/
|
|
13
|
+
encode(input?: string): Uint8Array;
|
|
14
|
+
/**
|
|
15
|
+
* Encode string into provided Uint8Array
|
|
16
|
+
* @param source string to encode
|
|
17
|
+
* @param destination target Uint8Array
|
|
18
|
+
* @returns object with read and written counts
|
|
19
|
+
*/
|
|
20
|
+
encodeInto(source: string, destination: Uint8Array): {
|
|
21
|
+
read: number;
|
|
22
|
+
written: number;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Cross-platform TextDecoder implementation
|
|
27
|
+
* Compatible with standard TextDecoder API
|
|
28
|
+
* Works on browsers, Node.js, and mini-programs (WeChat, Alipay, etc.)
|
|
29
|
+
*/
|
|
30
|
+
export declare class TextDecoder {
|
|
31
|
+
readonly encoding: string;
|
|
32
|
+
readonly fatal: boolean;
|
|
33
|
+
readonly ignoreBOM: boolean;
|
|
34
|
+
constructor(encoding?: string, options?: {
|
|
35
|
+
fatal?: boolean;
|
|
36
|
+
ignoreBOM?: boolean;
|
|
37
|
+
});
|
|
38
|
+
/**
|
|
39
|
+
* Decode Uint8Array to string using UTF-8 decoding
|
|
40
|
+
* @param input Uint8Array to decode
|
|
41
|
+
* @returns decoded string
|
|
42
|
+
*/
|
|
43
|
+
decode(input?: Uint8Array | ArrayBuffer): string;
|
|
44
|
+
}
|