@titanpl/core 1.0.1 → 2.0.1
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/LICENSE +14 -14
- package/README.md +127 -127
- package/globals.d.ts +17 -17
- package/index.js +554 -249
- package/native/target/release/titan_core.dll +0 -0
- package/package.json +44 -41
- package/titan.json +209 -114
package/LICENSE
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
ISC License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025, Ezet Galaxy
|
|
4
|
-
|
|
5
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
-
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
-
copyright notice and this permission notice appear in all copies.
|
|
8
|
-
|
|
9
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
-
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
-
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
-
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
-
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
-
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025, Ezet Galaxy
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
15
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,127 +1,127 @@
|
|
|
1
|
-
# @titanpl/core
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
##
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
```javascript
|
|
58
|
-
t.
|
|
59
|
-
t.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
###
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
###
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
-
|
|
123
|
-
-
|
|
124
|
-
|
|
125
|
-
##
|
|
126
|
-
|
|
127
|
-
|
|
1
|
+
# @titanpl/core
|
|
2
|
+
The official Core Standard Library for Titan Planet - a high-performance JavaScript runtime extension.
|
|
3
|
+
|
|
4
|
+
## Overview
|
|
5
|
+
`@titanpl/core` provides essential standard library modules for Titan applications, bridging high-performance Rust native implementations with an easy-to-use JavaScript API.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
```bash
|
|
9
|
+
npm install @titanpl/core
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
The extension automatically attaches to the Titan runtime. You can access it via `t.core` or the `t` global object alias.
|
|
14
|
+
|
|
15
|
+
```javascript
|
|
16
|
+
// Access via t.core (Recommended)
|
|
17
|
+
const { fs, crypto, os } = t.core;
|
|
18
|
+
|
|
19
|
+
// Read a file
|
|
20
|
+
const content = fs.readFile("config.json");
|
|
21
|
+
|
|
22
|
+
// Generate UUID
|
|
23
|
+
const id = crypto.uuid();
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## API Reference
|
|
27
|
+
|
|
28
|
+
### `fs` (File System)
|
|
29
|
+
Perform synchronous file system operations.
|
|
30
|
+
- `fs.readFile(path: string): string` - Read file content as UTF-8 string.
|
|
31
|
+
- `fs.writeFile(path: string, content: string): void` - Write string content to file.
|
|
32
|
+
- `fs.exists(path: string): boolean` - Check if path exists.
|
|
33
|
+
- `fs.mkdir(path: string): void` - Create a directory (recursive).
|
|
34
|
+
- `fs.remove(path: string): void` - Remove file or directory.
|
|
35
|
+
- `fs.readdir(path: string): string[]` - List directory contents.
|
|
36
|
+
- `fs.stat(path: string): object` - Get file statistics (`{ type: "file"|"directory", size: number }`).
|
|
37
|
+
|
|
38
|
+
### `path` (Path Manipulation)
|
|
39
|
+
Utilities for handling file paths.
|
|
40
|
+
- `path.join(...parts: string[]): string` - Join path segments.
|
|
41
|
+
- `path.resolve(...parts: string[]): string` - Resolve path to absolute.
|
|
42
|
+
- `path.dirname(path: string): string` - Get directory name.
|
|
43
|
+
- `path.basename(path: string): string` - Get base file name.
|
|
44
|
+
- `path.extname(path: string): string` - Get file extension.
|
|
45
|
+
|
|
46
|
+
### `crypto` (Cryptography)
|
|
47
|
+
Cryptographic utilities using native Rust implementations.
|
|
48
|
+
- `crypto.hash(algo: string, data: string): string` - Hash data. Supported algos: `sha256`, `sha512`, `md5`.
|
|
49
|
+
- `crypto.randomBytes(size: number): string` - Generate random bytes as hex string.
|
|
50
|
+
- `crypto.uuid(): string` - Generate a UUID v4.
|
|
51
|
+
- `crypto.compare(hash: string, target: string): boolean` - Constant-time comparison.
|
|
52
|
+
- `crypto.encrypt(algorithm: string, key: string, plaintext: string): string` - AES-256-GCM Encrypt (Returns Base64).
|
|
53
|
+
- `crypto.decrypt(algorithm: string, key: string, ciphertext: string): string` - AES-256-GCM Decrypt.
|
|
54
|
+
- `crypto.hashKeyed(algo: string, key: string, message: string): string` - HMAC-SHA256/512.
|
|
55
|
+
|
|
56
|
+
**Example:**
|
|
57
|
+
```javascript
|
|
58
|
+
const hash = t.core.crypto.hash("sha256", "hii");
|
|
59
|
+
const valid = t.core.crypto.compare(
|
|
60
|
+
"a1a3b09875f9e9acade5623e1cca680009a6c9e0452489931cfa5b0041f4d290",
|
|
61
|
+
hash
|
|
62
|
+
);
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### `buffer` (Buffer Utilities)
|
|
66
|
+
Utilities for binary data manipulation.
|
|
67
|
+
- `buffer.fromBase64(str: string): Uint8Array` - Decode Base64 string.
|
|
68
|
+
- `buffer.toBase64(bytes: Uint8Array|string): string` - Encode to Base64.
|
|
69
|
+
- `buffer.fromHex(str: string): Uint8Array` - Decode Hex string.
|
|
70
|
+
- `buffer.toHex(bytes: Uint8Array|string): string` - Encode to Hex.
|
|
71
|
+
- `buffer.fromUtf8(str: string): Uint8Array` - Encode UTF-8 string to bytes.
|
|
72
|
+
- `buffer.toUtf8(bytes: Uint8Array): string` - Decode bytes to UTF-8 string.
|
|
73
|
+
|
|
74
|
+
### `ls` / `localStorage` (Persistent Storage)
|
|
75
|
+
Key-value storage persisted to disk (via Sled).
|
|
76
|
+
- `ls.get(key: string): string|null` - Get value.
|
|
77
|
+
- `ls.set(key: string, value: string): void` - Set value.
|
|
78
|
+
- `ls.remove(key: string): void` - Remove key.
|
|
79
|
+
- `ls.clear(): void` - Clear all storage.
|
|
80
|
+
- `ls.keys(): string[]` - List all keys.
|
|
81
|
+
|
|
82
|
+
### `session` (Server-side Sessions)
|
|
83
|
+
Session management backed by persistent storage.
|
|
84
|
+
- `session.get(sessionId: string, key: string): string|null` - Get session value.
|
|
85
|
+
- `session.set(sessionId: string, key: string, value: string): void` - Set session value.
|
|
86
|
+
- `session.delete(sessionId: string, key: string): void` - Delete session value.
|
|
87
|
+
- `session.clear(sessionId: string): void` - Clear entire session.
|
|
88
|
+
|
|
89
|
+
### `cookies` (HTTP Cookies)
|
|
90
|
+
Cookie parsing and serialization.
|
|
91
|
+
- `cookies.get(req: object, name: string): string|null` - Parse cookie from request headers.
|
|
92
|
+
- `cookies.set(res: object, name: string, value: string, options: object): void` - Set `Set-Cookie` header on response. Options: `{ httpOnly, secure, sameSite, path, maxAge }`.
|
|
93
|
+
- `cookies.delete(res: object, name: string): void` - Delete cookie (expire).
|
|
94
|
+
|
|
95
|
+
### `os` (Operating System)
|
|
96
|
+
Get system information.
|
|
97
|
+
- `os.platform(): string` - OS platform (e.g., `linux`, `windows`).
|
|
98
|
+
- `os.cpus(): number` - Number of CPU cores.
|
|
99
|
+
- `os.totalMemory(): number` - Total system memory in bytes.
|
|
100
|
+
- `os.freeMemory(): number` - Free system memory in bytes.
|
|
101
|
+
- `os.tmpdir(): string` - Temporary directory path.
|
|
102
|
+
|
|
103
|
+
### `net` (Network)
|
|
104
|
+
Network utilities.
|
|
105
|
+
- `net.resolveDNS(hostname: string): string[]` - Resolve hostname to IP addresses.
|
|
106
|
+
- `net.ip(): string` - Get local IP address.
|
|
107
|
+
|
|
108
|
+
### `proc` (Process)
|
|
109
|
+
Current process information.
|
|
110
|
+
- `proc.pid(): number` - Process ID.
|
|
111
|
+
- `proc.uptime(): number` - System uptime in seconds.
|
|
112
|
+
|
|
113
|
+
### `time` (Time)
|
|
114
|
+
Time utilities.
|
|
115
|
+
- `time.sleep(ms: number): void` - Sleep for specified milliseconds.
|
|
116
|
+
- `time.now(): number` - Current timestamp (ms).
|
|
117
|
+
- `time.timestamp(): string` - Current ISO timestamp.
|
|
118
|
+
|
|
119
|
+
### `url` (URL)
|
|
120
|
+
URL parsing and manipulation.
|
|
121
|
+
- `url.parse(urlString: string): URLObject` - Parse URL string.
|
|
122
|
+
- `url.format(urlObject: object): string` - Format URL object.
|
|
123
|
+
- `new url.SearchParams(query: string|object)` - Handle query strings.
|
|
124
|
+
|
|
125
|
+
## Native Bindings
|
|
126
|
+
This extension includes native Rust bindings for high-performance operations. The native library is automatically loaded by the Titan Runtime.
|
|
127
|
+
|
package/globals.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
declare var t: any;
|
|
2
|
-
declare var fs_read_file: any;
|
|
3
|
-
declare var fs_write_file: any;
|
|
4
|
-
declare var fs_readdir: any;
|
|
5
|
-
declare var fs_mkdir: any;
|
|
6
|
-
declare var fs_exists: any;
|
|
7
|
-
declare var fs_stat: any;
|
|
8
|
-
declare var fs_remove: any;
|
|
9
|
-
declare var path_cwd: any;
|
|
10
|
-
declare var crypto_hash: any;
|
|
11
|
-
declare var crypto_random_bytes: any;
|
|
12
|
-
declare var crypto_uuid: any;
|
|
13
|
-
declare var os_info: any;
|
|
14
|
-
declare var net_resolve: any;
|
|
15
|
-
declare var net_ip: any;
|
|
16
|
-
declare var proc_info: any;
|
|
17
|
-
declare var time_sleep: any;
|
|
1
|
+
declare var t: any;
|
|
2
|
+
declare var fs_read_file: any;
|
|
3
|
+
declare var fs_write_file: any;
|
|
4
|
+
declare var fs_readdir: any;
|
|
5
|
+
declare var fs_mkdir: any;
|
|
6
|
+
declare var fs_exists: any;
|
|
7
|
+
declare var fs_stat: any;
|
|
8
|
+
declare var fs_remove: any;
|
|
9
|
+
declare var path_cwd: any;
|
|
10
|
+
declare var crypto_hash: any;
|
|
11
|
+
declare var crypto_random_bytes: any;
|
|
12
|
+
declare var crypto_uuid: any;
|
|
13
|
+
declare var os_info: any;
|
|
14
|
+
declare var net_resolve: any;
|
|
15
|
+
declare var net_ip: any;
|
|
16
|
+
declare var proc_info: any;
|
|
17
|
+
declare var time_sleep: any;
|