@titanpl/native 7.0.0-beta → 7.0.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/index.d.ts +16 -1
- package/index.js +6 -0
- package/package.json +2 -2
- package/t.native.d.ts +77 -0
package/index.d.ts
CHANGED
|
@@ -31,8 +31,13 @@ export interface ShareContext {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
// Add more as needed based on native/index.js
|
|
34
|
+
export interface WebSocketModule {
|
|
35
|
+
send(socketId: string, message: string): void;
|
|
36
|
+
broadcast(message: string): void;
|
|
37
|
+
}
|
|
38
|
+
|
|
34
39
|
export const db: any;
|
|
35
|
-
export const ws:
|
|
40
|
+
export const ws: WebSocketModule;
|
|
36
41
|
export const path: any;
|
|
37
42
|
export const jwt: any;
|
|
38
43
|
export const password: any;
|
|
@@ -49,3 +54,13 @@ export const time: any;
|
|
|
49
54
|
export const url: any;
|
|
50
55
|
export const response: any;
|
|
51
56
|
export const valid: any;
|
|
57
|
+
|
|
58
|
+
// Serialization
|
|
59
|
+
/** Binary-serializes a JavaScript value using V8's fast internal format. */
|
|
60
|
+
export function serialize(value: any): Uint8Array;
|
|
61
|
+
/** Binary-serializes a JavaScript value using V8's fast internal format. Alias for serialize. */
|
|
62
|
+
export function serialise(value: any): Uint8Array;
|
|
63
|
+
/** Deserializes a Uint8Array back into its original JavaScript value/object. */
|
|
64
|
+
export function deserialize(buffer: Uint8Array): any;
|
|
65
|
+
/** Deserializes a Uint8Array back into its original JavaScript value/object. Alias for deserialize. */
|
|
66
|
+
export function deserialise(buffer: Uint8Array): any;
|
package/index.js
CHANGED
|
@@ -40,4 +40,10 @@ export const url = t.url;
|
|
|
40
40
|
export const response = t.response;
|
|
41
41
|
export const valid = t.valid;
|
|
42
42
|
|
|
43
|
+
// Serialization
|
|
44
|
+
export const serialize = t.serialize;
|
|
45
|
+
export const serialise = t.serialise;
|
|
46
|
+
export const deserialize = t.deserialize;
|
|
47
|
+
export const deserialise = t.deserialise;
|
|
48
|
+
|
|
43
49
|
export const defineAction = (handler) => handler;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@titanpl/native",
|
|
3
|
-
"version": "7.0.0
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "Titan native utilities package",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@titanpl/core": "
|
|
23
|
+
"@titanpl/core": "7.0.0",
|
|
24
24
|
"@titanpl/node": "latest"
|
|
25
25
|
}
|
|
26
26
|
}
|
package/t.native.d.ts
CHANGED
|
@@ -233,6 +233,34 @@ export const password: typeof t.password;
|
|
|
233
233
|
*/
|
|
234
234
|
export const db: typeof t.db;
|
|
235
235
|
|
|
236
|
+
/**
|
|
237
|
+
* WebSocket communication utilities.
|
|
238
|
+
*
|
|
239
|
+
* Re-exported from the `t` global for module-style imports.
|
|
240
|
+
* @see {@link TitanRuntimeUtils.ws} for full documentation.
|
|
241
|
+
*/
|
|
242
|
+
export const ws: typeof t.ws;
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Binary serialization using V8's fast format.
|
|
246
|
+
*
|
|
247
|
+
* Re-exported from the `t` global for module-style imports.
|
|
248
|
+
* @see {@link TitanRuntimeUtils.serialize}
|
|
249
|
+
*/
|
|
250
|
+
export const serialize: typeof t.serialize;
|
|
251
|
+
/** Alias for serialize. @see {@link TitanRuntimeUtils.serialise} */
|
|
252
|
+
export const serialise: typeof t.serialise;
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Binary deserialization for V8 buffers.
|
|
256
|
+
*
|
|
257
|
+
* Re-exported from the `t` global for module-style imports.
|
|
258
|
+
* @see {@link TitanRuntimeUtils.deserialize}
|
|
259
|
+
*/
|
|
260
|
+
export const deserialize: typeof t.deserialize;
|
|
261
|
+
/** Alias for deserialize. @see {@link TitanRuntimeUtils.deserialise} */
|
|
262
|
+
export const deserialise: typeof t.deserialise;
|
|
263
|
+
|
|
236
264
|
/**
|
|
237
265
|
* Async file system operations (read, write, mkdir, stat, etc.).
|
|
238
266
|
*
|
|
@@ -647,6 +675,55 @@ declare global {
|
|
|
647
675
|
body?: string;
|
|
648
676
|
error?: string;
|
|
649
677
|
}>;
|
|
678
|
+
|
|
679
|
+
/**
|
|
680
|
+
* Fast binary serialization using V8's internal value format.
|
|
681
|
+
*
|
|
682
|
+
* Highly efficient for complex JavaScript objects including `Date`, `Map`,
|
|
683
|
+
* `Set`, and `TypedArrays`. The resulting `Uint8Array` is stable and
|
|
684
|
+
* can be safely stored in databases (e.g. `t.ls`) or transmitted.
|
|
685
|
+
*
|
|
686
|
+
* @param value - The JavaScript value/object to serialize.
|
|
687
|
+
* @returns A `Uint8Array` containing the binary-serialized representation.
|
|
688
|
+
*
|
|
689
|
+
* @example
|
|
690
|
+
* ```js
|
|
691
|
+
* const complex = { date: new Date(), map: new Map([["a", 1]]) };
|
|
692
|
+
* const bytes = t.serialize(complex);
|
|
693
|
+
* // Store bytes in database or pass to another action
|
|
694
|
+
* ```
|
|
695
|
+
*/
|
|
696
|
+
serialize(value: any): Uint8Array;
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* Binary serialization. Alias for `t.serialize`.
|
|
700
|
+
* @see {@link TitanRuntimeUtils.serialize}
|
|
701
|
+
*/
|
|
702
|
+
serialise(value: any): Uint8Array;
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
* Deserializes a binary buffer back into its original JavaScript value.
|
|
706
|
+
*
|
|
707
|
+
* Restores full object fidelity including native types like `Date` and `Buffer`.
|
|
708
|
+
* Performance is significantly faster than `JSON.parse` for large objects.
|
|
709
|
+
*
|
|
710
|
+
* @param buffer - A `Uint8Array` created by `t.serialize()`.
|
|
711
|
+
* @returns The restored JavaScript value or object.
|
|
712
|
+
* @throws If the buffer is invalid or contains corrupted V8 header data.
|
|
713
|
+
*
|
|
714
|
+
* @example
|
|
715
|
+
* ```js
|
|
716
|
+
* const restored = t.deserialize(bytes);
|
|
717
|
+
* console.log(restored.date instanceof Date); // true
|
|
718
|
+
* ```
|
|
719
|
+
*/
|
|
720
|
+
deserialize(buffer: Uint8Array): any;
|
|
721
|
+
|
|
722
|
+
/**
|
|
723
|
+
* Binary deserialization. Alias for `t.deserialize`.
|
|
724
|
+
* @see {@link TitanRuntimeUtils.deserialize}
|
|
725
|
+
*/
|
|
726
|
+
deserialise(buffer: Uint8Array): any;
|
|
650
727
|
|
|
651
728
|
/**
|
|
652
729
|
* WebSocket communication utilities.
|