titanpl 6.0.0 → 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/package.json +2 -6
- package/packages/cli/index.js +25 -11
- package/packages/cli/package.json +4 -4
- package/packages/cli/src/commands/build-ext.js +157 -0
- package/packages/cli/src/commands/build.js +12 -0
- package/packages/cli/src/commands/create.js +160 -0
- package/packages/cli/src/commands/init.js +5 -11
- package/packages/cli/src/commands/run-ext.js +104 -0
- package/{titanpl-sdk → packages/core-source}/LICENSE +1 -1
- package/packages/core-source/README.md +128 -0
- package/packages/core-source/V8_SERIALIZATION.md +125 -0
- package/packages/core-source/configure.js +50 -0
- package/packages/core-source/globals.d.ts +2238 -0
- package/packages/core-source/index.d.ts +515 -0
- package/packages/core-source/index.js +639 -0
- package/packages/core-source/jsconfig.json +12 -0
- package/packages/core-source/mkctx.config.json +7 -0
- package/packages/core-source/native/Cargo.lock +1559 -0
- package/packages/core-source/native/Cargo.toml +30 -0
- package/packages/core-source/native/src/crypto_impl.rs +139 -0
- package/packages/core-source/native/src/lib.rs +702 -0
- package/packages/core-source/native/src/storage_impl.rs +73 -0
- package/packages/core-source/native/src/v8_impl.rs +93 -0
- package/packages/core-source/package-lock.json +1464 -0
- package/packages/core-source/package.json +53 -0
- package/packages/core-source/tests/buffer.test.js +78 -0
- package/packages/core-source/tests/cookies.test.js +117 -0
- package/packages/core-source/tests/crypto.test.js +142 -0
- package/packages/core-source/tests/fs.test.js +176 -0
- package/packages/core-source/tests/ls.test.js +149 -0
- package/packages/core-source/tests/net.test.js +84 -0
- package/packages/core-source/tests/os.test.js +81 -0
- package/packages/core-source/tests/path.test.js +102 -0
- package/packages/core-source/tests/response.test.js +146 -0
- package/packages/core-source/tests/session.test.js +110 -0
- package/packages/core-source/tests/setup.js +325 -0
- package/packages/core-source/tests/time.test.js +57 -0
- package/packages/core-source/tests/url.test.js +82 -0
- package/packages/core-source/titan-ext.d.ts +2 -0
- package/packages/core-source/titan.json +9 -0
- package/packages/core-source/vitest.config.js +8 -0
- package/packages/engine-darwin-arm64/README.md +0 -2
- package/packages/engine-darwin-arm64/package.json +1 -1
- package/packages/engine-linux-x64/README.md +0 -2
- package/packages/engine-linux-x64/package.json +1 -1
- package/packages/engine-win32-x64/README.md +0 -1
- package/packages/engine-win32-x64/bin/titan-server.exe +0 -0
- package/packages/engine-win32-x64/package.json +1 -1
- package/packages/native/README.md +0 -1
- package/packages/native/index.d.ts +25 -4
- package/packages/native/index.js +7 -0
- package/packages/native/package.json +2 -2
- package/packages/native/t.native.d.ts +167 -2
- package/packages/packet/index.js +103 -94
- package/packages/packet/package.json +1 -1
- package/packages/route/package.json +1 -1
- package/packages/sdk/index.js +2 -0
- package/packages/sdk/package.json +18 -0
- package/packages/sdk/test/index.js +120 -0
- package/templates/common/_tanfig.json +19 -13
- package/templates/extension/index.d.ts +26 -22
- package/templates/extension/index.js +15 -15
- package/templates/extension/native/Cargo.toml +5 -3
- package/templates/extension/native/src/lib.rs +2 -3
- package/templates/extension/package.json +10 -20
- package/templates/extension/titan.json +5 -16
- package/templates/extension/utils/registerExtension.js +44 -0
- package/templates/js/package.json +8 -8
- package/templates/rust-js/package.json +5 -5
- package/templates/rust-ts/package.json +5 -5
- package/templates/ts/package.json +8 -8
- package/packages/packet/node_modules/typescript/LICENSE.txt +0 -55
- package/packages/packet/node_modules/typescript/README.md +0 -50
- package/packages/packet/node_modules/typescript/SECURITY.md +0 -41
- package/packages/packet/node_modules/typescript/ThirdPartyNoticeText.txt +0 -193
- package/packages/packet/node_modules/typescript/bin/tsc +0 -2
- package/packages/packet/node_modules/typescript/bin/tsserver +0 -2
- package/packages/packet/node_modules/typescript/lib/_tsc.js +0 -133818
- package/packages/packet/node_modules/typescript/lib/_tsserver.js +0 -659
- package/packages/packet/node_modules/typescript/lib/_typingsInstaller.js +0 -222
- package/packages/packet/node_modules/typescript/lib/cs/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/de/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/es/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/fr/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/it/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/ja/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/ko/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/lib.d.ts +0 -22
- package/packages/packet/node_modules/typescript/lib/lib.decorators.d.ts +0 -384
- package/packages/packet/node_modules/typescript/lib/lib.decorators.legacy.d.ts +0 -22
- package/packages/packet/node_modules/typescript/lib/lib.dom.asynciterable.d.ts +0 -41
- package/packages/packet/node_modules/typescript/lib/lib.dom.d.ts +0 -39429
- package/packages/packet/node_modules/typescript/lib/lib.dom.iterable.d.ts +0 -571
- package/packages/packet/node_modules/typescript/lib/lib.es2015.collection.d.ts +0 -147
- package/packages/packet/node_modules/typescript/lib/lib.es2015.core.d.ts +0 -597
- package/packages/packet/node_modules/typescript/lib/lib.es2015.d.ts +0 -28
- package/packages/packet/node_modules/typescript/lib/lib.es2015.generator.d.ts +0 -77
- package/packages/packet/node_modules/typescript/lib/lib.es2015.iterable.d.ts +0 -605
- package/packages/packet/node_modules/typescript/lib/lib.es2015.promise.d.ts +0 -81
- package/packages/packet/node_modules/typescript/lib/lib.es2015.proxy.d.ts +0 -128
- package/packages/packet/node_modules/typescript/lib/lib.es2015.reflect.d.ts +0 -144
- package/packages/packet/node_modules/typescript/lib/lib.es2015.symbol.d.ts +0 -46
- package/packages/packet/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts +0 -326
- package/packages/packet/node_modules/typescript/lib/lib.es2016.array.include.d.ts +0 -116
- package/packages/packet/node_modules/typescript/lib/lib.es2016.d.ts +0 -21
- package/packages/packet/node_modules/typescript/lib/lib.es2016.full.d.ts +0 -23
- package/packages/packet/node_modules/typescript/lib/lib.es2016.intl.d.ts +0 -31
- package/packages/packet/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts +0 -21
- package/packages/packet/node_modules/typescript/lib/lib.es2017.d.ts +0 -26
- package/packages/packet/node_modules/typescript/lib/lib.es2017.date.d.ts +0 -31
- package/packages/packet/node_modules/typescript/lib/lib.es2017.full.d.ts +0 -23
- package/packages/packet/node_modules/typescript/lib/lib.es2017.intl.d.ts +0 -44
- package/packages/packet/node_modules/typescript/lib/lib.es2017.object.d.ts +0 -49
- package/packages/packet/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts +0 -135
- package/packages/packet/node_modules/typescript/lib/lib.es2017.string.d.ts +0 -45
- package/packages/packet/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts +0 -53
- package/packages/packet/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts +0 -77
- package/packages/packet/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts +0 -53
- package/packages/packet/node_modules/typescript/lib/lib.es2018.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2018.full.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2018.intl.d.ts +0 -83
- package/packages/packet/node_modules/typescript/lib/lib.es2018.promise.d.ts +0 -30
- package/packages/packet/node_modules/typescript/lib/lib.es2018.regexp.d.ts +0 -37
- package/packages/packet/node_modules/typescript/lib/lib.es2019.array.d.ts +0 -79
- package/packages/packet/node_modules/typescript/lib/lib.es2019.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2019.full.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2019.intl.d.ts +0 -23
- package/packages/packet/node_modules/typescript/lib/lib.es2019.object.d.ts +0 -33
- package/packages/packet/node_modules/typescript/lib/lib.es2019.string.d.ts +0 -37
- package/packages/packet/node_modules/typescript/lib/lib.es2019.symbol.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2020.bigint.d.ts +0 -765
- package/packages/packet/node_modules/typescript/lib/lib.es2020.d.ts +0 -27
- package/packages/packet/node_modules/typescript/lib/lib.es2020.date.d.ts +0 -42
- package/packages/packet/node_modules/typescript/lib/lib.es2020.full.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2020.intl.d.ts +0 -474
- package/packages/packet/node_modules/typescript/lib/lib.es2020.number.d.ts +0 -28
- package/packages/packet/node_modules/typescript/lib/lib.es2020.promise.d.ts +0 -47
- package/packages/packet/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts +0 -99
- package/packages/packet/node_modules/typescript/lib/lib.es2020.string.d.ts +0 -44
- package/packages/packet/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts +0 -41
- package/packages/packet/node_modules/typescript/lib/lib.es2021.d.ts +0 -23
- package/packages/packet/node_modules/typescript/lib/lib.es2021.full.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2021.intl.d.ts +0 -166
- package/packages/packet/node_modules/typescript/lib/lib.es2021.promise.d.ts +0 -48
- package/packages/packet/node_modules/typescript/lib/lib.es2021.string.d.ts +0 -33
- package/packages/packet/node_modules/typescript/lib/lib.es2021.weakref.d.ts +0 -78
- package/packages/packet/node_modules/typescript/lib/lib.es2022.array.d.ts +0 -121
- package/packages/packet/node_modules/typescript/lib/lib.es2022.d.ts +0 -25
- package/packages/packet/node_modules/typescript/lib/lib.es2022.error.d.ts +0 -75
- package/packages/packet/node_modules/typescript/lib/lib.es2022.full.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2022.intl.d.ts +0 -145
- package/packages/packet/node_modules/typescript/lib/lib.es2022.object.d.ts +0 -26
- package/packages/packet/node_modules/typescript/lib/lib.es2022.regexp.d.ts +0 -39
- package/packages/packet/node_modules/typescript/lib/lib.es2022.string.d.ts +0 -25
- package/packages/packet/node_modules/typescript/lib/lib.es2023.array.d.ts +0 -924
- package/packages/packet/node_modules/typescript/lib/lib.es2023.collection.d.ts +0 -21
- package/packages/packet/node_modules/typescript/lib/lib.es2023.d.ts +0 -22
- package/packages/packet/node_modules/typescript/lib/lib.es2023.full.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2023.intl.d.ts +0 -56
- package/packages/packet/node_modules/typescript/lib/lib.es2024.arraybuffer.d.ts +0 -65
- package/packages/packet/node_modules/typescript/lib/lib.es2024.collection.d.ts +0 -29
- package/packages/packet/node_modules/typescript/lib/lib.es2024.d.ts +0 -26
- package/packages/packet/node_modules/typescript/lib/lib.es2024.full.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2024.object.d.ts +0 -29
- package/packages/packet/node_modules/typescript/lib/lib.es2024.promise.d.ts +0 -35
- package/packages/packet/node_modules/typescript/lib/lib.es2024.regexp.d.ts +0 -25
- package/packages/packet/node_modules/typescript/lib/lib.es2024.sharedmemory.d.ts +0 -68
- package/packages/packet/node_modules/typescript/lib/lib.es2024.string.d.ts +0 -29
- package/packages/packet/node_modules/typescript/lib/lib.es5.d.ts +0 -4601
- package/packages/packet/node_modules/typescript/lib/lib.es6.d.ts +0 -23
- package/packages/packet/node_modules/typescript/lib/lib.esnext.array.d.ts +0 -35
- package/packages/packet/node_modules/typescript/lib/lib.esnext.collection.d.ts +0 -96
- package/packages/packet/node_modules/typescript/lib/lib.esnext.d.ts +0 -29
- package/packages/packet/node_modules/typescript/lib/lib.esnext.decorators.d.ts +0 -28
- package/packages/packet/node_modules/typescript/lib/lib.esnext.disposable.d.ts +0 -193
- package/packages/packet/node_modules/typescript/lib/lib.esnext.error.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.esnext.float16.d.ts +0 -445
- package/packages/packet/node_modules/typescript/lib/lib.esnext.full.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.esnext.intl.d.ts +0 -21
- package/packages/packet/node_modules/typescript/lib/lib.esnext.iterator.d.ts +0 -148
- package/packages/packet/node_modules/typescript/lib/lib.esnext.promise.d.ts +0 -34
- package/packages/packet/node_modules/typescript/lib/lib.esnext.sharedmemory.d.ts +0 -25
- package/packages/packet/node_modules/typescript/lib/lib.scripthost.d.ts +0 -322
- package/packages/packet/node_modules/typescript/lib/lib.webworker.asynciterable.d.ts +0 -41
- package/packages/packet/node_modules/typescript/lib/lib.webworker.d.ts +0 -13150
- package/packages/packet/node_modules/typescript/lib/lib.webworker.importscripts.d.ts +0 -23
- package/packages/packet/node_modules/typescript/lib/lib.webworker.iterable.d.ts +0 -340
- package/packages/packet/node_modules/typescript/lib/pl/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/pt-br/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/ru/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/tr/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/tsc.js +0 -8
- package/packages/packet/node_modules/typescript/lib/tsserver.js +0 -8
- package/packages/packet/node_modules/typescript/lib/tsserverlibrary.d.ts +0 -17
- package/packages/packet/node_modules/typescript/lib/tsserverlibrary.js +0 -21
- package/packages/packet/node_modules/typescript/lib/typesMap.json +0 -497
- package/packages/packet/node_modules/typescript/lib/typescript.d.ts +0 -11437
- package/packages/packet/node_modules/typescript/lib/typescript.js +0 -200276
- package/packages/packet/node_modules/typescript/lib/typingsInstaller.js +0 -8
- package/packages/packet/node_modules/typescript/lib/watchGuard.js +0 -53
- package/packages/packet/node_modules/typescript/lib/zh-cn/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/zh-tw/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/package.json +0 -120
- package/titanpl-sdk/README.md +0 -111
- package/titanpl-sdk/assets/titanpl-sdk.png +0 -0
- package/titanpl-sdk/bin/run.js +0 -274
- package/titanpl-sdk/index.js +0 -5
- package/titanpl-sdk/package-lock.json +0 -28
- package/titanpl-sdk/package.json +0 -40
- package/titanpl-sdk/templates/app/actions/hello.js +0 -5
- package/titanpl-sdk/templates/app/app.js +0 -7
- package/titanpl-sdk/templates/jsconfig.json +0 -19
- package/titanpl-sdk/templates/server/Cargo.toml +0 -52
- package/titanpl-sdk/templates/server/src/action_management.rs +0 -175
- package/titanpl-sdk/templates/server/src/errors.rs +0 -12
- package/titanpl-sdk/templates/server/src/extensions/builtin.rs +0 -1060
- package/titanpl-sdk/templates/server/src/extensions/external.rs +0 -338
- package/titanpl-sdk/templates/server/src/extensions/mod.rs +0 -580
- package/titanpl-sdk/templates/server/src/extensions/titan_core.js +0 -249
- package/titanpl-sdk/templates/server/src/fast_path.rs +0 -719
- package/titanpl-sdk/templates/server/src/main.rs +0 -607
- package/titanpl-sdk/templates/server/src/runtime.rs +0 -284
- package/titanpl-sdk/templates/server/src/utils.rs +0 -33
- package/titanpl-sdk/templates/titan/bundle.js +0 -259
- package/titanpl-sdk/templates/titan/dev.js +0 -390
- package/titanpl-sdk/templates/titan/error-box.js +0 -277
- package/titanpl-sdk/templates/titan/titan.js +0 -129
|
@@ -0,0 +1,515 @@
|
|
|
1
|
+
// =============================================================================
|
|
2
|
+
// @titanpl/core — Module Type Definitions
|
|
3
|
+
// The official Core Standard Library for Titan Planet
|
|
4
|
+
// Version: 2.x
|
|
5
|
+
// Repository: https://github.com/ezet-galaxy/-titanpl-core
|
|
6
|
+
// =============================================================================
|
|
7
|
+
|
|
8
|
+
/// <reference path="./globals.d.ts" />
|
|
9
|
+
|
|
10
|
+
// =============================================================================
|
|
11
|
+
// ESM Named Exports
|
|
12
|
+
// Usage: import { fs, crypto, response } from '@titanpl/core';
|
|
13
|
+
// =============================================================================
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* # File System Module
|
|
17
|
+
*
|
|
18
|
+
* Native file operations backed by Rust. All methods are **synchronous**.
|
|
19
|
+
*
|
|
20
|
+
* **Methods:**
|
|
21
|
+
* - `readFile(path)` — Read file as UTF-8 string
|
|
22
|
+
* - `writeFile(path, content)` — Write string to file
|
|
23
|
+
* - `readdir(path)` — List directory contents
|
|
24
|
+
* - `mkdir(path)` — Create directory (recursive)
|
|
25
|
+
* - `exists(path)` — Check if path exists
|
|
26
|
+
* - `stat(path)` — Get file metadata
|
|
27
|
+
* - `remove(path)` — Delete file or directory
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```js
|
|
31
|
+
* import { fs } from '@titanpl/core';
|
|
32
|
+
*
|
|
33
|
+
* // Read and parse JSON
|
|
34
|
+
* const config = JSON.parse(fs.readFile("./config.json"));
|
|
35
|
+
*
|
|
36
|
+
* // Write data
|
|
37
|
+
* fs.writeFile("./output.json", JSON.stringify(data, null, 2));
|
|
38
|
+
*
|
|
39
|
+
* // Check existence
|
|
40
|
+
* if (fs.exists("./cache")) {
|
|
41
|
+
* const files = fs.readdir("./cache");
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @see https://github.com/ezet-galaxy/-titanpl-core#fs-file-system
|
|
46
|
+
*/
|
|
47
|
+
export declare const fs: TitanCore.FileSystem;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* # Path Module
|
|
51
|
+
*
|
|
52
|
+
* Cross-platform path manipulation utilities. All methods are **synchronous**.
|
|
53
|
+
*
|
|
54
|
+
* **Methods:**
|
|
55
|
+
* - `join(...parts)` — Join path segments
|
|
56
|
+
* - `resolve(...parts)` — Resolve to absolute path
|
|
57
|
+
* - `dirname(path)` — Get directory name
|
|
58
|
+
* - `basename(path)` — Get file name
|
|
59
|
+
* - `extname(path)` — Get file extension
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```js
|
|
63
|
+
* import { path } from '@titanpl/core';
|
|
64
|
+
*
|
|
65
|
+
* const configPath = path.join("app", "config", "settings.json");
|
|
66
|
+
* const absolute = path.resolve("./data", "users.db");
|
|
67
|
+
*
|
|
68
|
+
* path.dirname("/var/log/app.log"); // → "/var/log"
|
|
69
|
+
* path.basename("/var/log/app.log"); // → "app.log"
|
|
70
|
+
* path.extname("photo.png"); // → ".png"
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* @see https://github.com/ezet-galaxy/-titanpl-core#path-path-manipulation
|
|
74
|
+
*/
|
|
75
|
+
export declare const path: TitanCore.Path;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* # Cryptography Module
|
|
79
|
+
*
|
|
80
|
+
* Cryptographic utilities powered by native Rust. All methods are **synchronous**.
|
|
81
|
+
*
|
|
82
|
+
* **Methods:**
|
|
83
|
+
* - `hash(algo, data)` — Hash data (sha256, sha512, md5)
|
|
84
|
+
* - `randomBytes(size)` — Generate random bytes (hex)
|
|
85
|
+
* - `uuid()` — Generate UUID v4
|
|
86
|
+
* - `compare(a, b)` — Constant-time comparison
|
|
87
|
+
* - `base64.encode(str)` / `base64.decode(str)` — Base64 utilities
|
|
88
|
+
* - `encrypt(algo, key, plaintext)` — AES-256-GCM encrypt
|
|
89
|
+
* - `decrypt(algo, key, ciphertext)` — AES-256-GCM decrypt
|
|
90
|
+
* - `hashKeyed(algo, key, message)` — HMAC signing
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```js
|
|
94
|
+
* import { crypto } from '@titanpl/core';
|
|
95
|
+
*
|
|
96
|
+
* // Generate identifiers
|
|
97
|
+
* const id = crypto.uuid();
|
|
98
|
+
* const token = crypto.randomBytes(32);
|
|
99
|
+
*
|
|
100
|
+
* // Hash and verify
|
|
101
|
+
* const hash = crypto.hash("sha256", password + salt);
|
|
102
|
+
* const isValid = crypto.compare(storedHash, hash);
|
|
103
|
+
*
|
|
104
|
+
* // Base64 encoding
|
|
105
|
+
* const encoded = crypto.base64.encode("Hello World");
|
|
106
|
+
* const decoded = crypto.base64.decode(encoded);
|
|
107
|
+
*
|
|
108
|
+
* // HMAC for webhooks
|
|
109
|
+
* const signature = crypto.hashKeyed("hmac-sha256", secret, payload);
|
|
110
|
+
*
|
|
111
|
+
* // Encryption
|
|
112
|
+
* const encrypted = crypto.encrypt("aes-256-gcm", key, "secret");
|
|
113
|
+
* const decrypted = crypto.decrypt("aes-256-gcm", key, encrypted);
|
|
114
|
+
* ```
|
|
115
|
+
*
|
|
116
|
+
* @see https://github.com/ezet-galaxy/-titanpl-core#crypto-cryptography
|
|
117
|
+
*/
|
|
118
|
+
export declare const crypto: TitanCore.Crypto;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* # Operating System Module
|
|
122
|
+
*
|
|
123
|
+
* System information about the host machine. All methods are **synchronous**.
|
|
124
|
+
*
|
|
125
|
+
* **Methods:**
|
|
126
|
+
* - `platform()` — OS identifier ("linux", "darwin", "windows")
|
|
127
|
+
* - `cpus()` — Number of CPU cores
|
|
128
|
+
* - `totalMemory()` — Total RAM in bytes
|
|
129
|
+
* - `freeMemory()` — Available RAM in bytes
|
|
130
|
+
* - `tmpdir()` — Temporary directory path
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```js
|
|
134
|
+
* import { os } from '@titanpl/core';
|
|
135
|
+
*
|
|
136
|
+
* console.log({
|
|
137
|
+
* platform: os.platform(),
|
|
138
|
+
* cpus: os.cpus(),
|
|
139
|
+
* totalMemory: os.totalMemory() / (1024 ** 3) + " GB",
|
|
140
|
+
* freeMemory: os.freeMemory() / (1024 ** 3) + " GB",
|
|
141
|
+
* tmpdir: os.tmpdir()
|
|
142
|
+
* });
|
|
143
|
+
* ```
|
|
144
|
+
*
|
|
145
|
+
* @see https://github.com/ezet-galaxy/-titanpl-core#os-operating-system
|
|
146
|
+
*/
|
|
147
|
+
export declare const os: TitanCore.OS;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* # Network Module
|
|
151
|
+
*
|
|
152
|
+
* Network utilities for DNS and IP operations. All methods are **synchronous**.
|
|
153
|
+
*
|
|
154
|
+
* **Methods:**
|
|
155
|
+
* - `resolveDNS(hostname)` — Resolve hostname to IPs
|
|
156
|
+
* - `ip()` — Get local IP address
|
|
157
|
+
* - `ping(host)` — Check if host is reachable
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```js
|
|
161
|
+
* import { net } from '@titanpl/core';
|
|
162
|
+
*
|
|
163
|
+
* const ips = net.resolveDNS("github.com");
|
|
164
|
+
* const localIp = net.ip();
|
|
165
|
+
* const reachable = net.ping("8.8.8.8");
|
|
166
|
+
* ```
|
|
167
|
+
*
|
|
168
|
+
* @see https://github.com/ezet-galaxy/-titanpl-core#net-network
|
|
169
|
+
*/
|
|
170
|
+
export declare const net: TitanCore.Net;
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* # Process Module
|
|
174
|
+
*
|
|
175
|
+
* Runtime process information and subprocess management.
|
|
176
|
+
* All methods are **synchronous**.
|
|
177
|
+
*
|
|
178
|
+
* **Methods:**
|
|
179
|
+
* - `pid()` — Process ID
|
|
180
|
+
* - `uptime()` — Uptime in seconds
|
|
181
|
+
* - `memory()` — Memory usage stats
|
|
182
|
+
* - `run(cmd, args, cwd)` — Spawn subprocess
|
|
183
|
+
* - `kill(pid)` — Terminate process
|
|
184
|
+
* - `list()` — List running processes
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```js
|
|
188
|
+
* import { proc } from '@titanpl/core';
|
|
189
|
+
*
|
|
190
|
+
* console.log({
|
|
191
|
+
* pid: proc.pid(),
|
|
192
|
+
* uptime: proc.uptime() + " seconds",
|
|
193
|
+
* memory: proc.memory()
|
|
194
|
+
* });
|
|
195
|
+
*
|
|
196
|
+
* // Spawn subprocess
|
|
197
|
+
* const result = proc.run("node", ["script.js"], "./scripts");
|
|
198
|
+
* if (result.ok) {
|
|
199
|
+
* console.log("Spawned PID:", result.pid);
|
|
200
|
+
* }
|
|
201
|
+
* ```
|
|
202
|
+
*
|
|
203
|
+
* @see https://github.com/ezet-galaxy/-titanpl-core#proc-process
|
|
204
|
+
*/
|
|
205
|
+
export declare const proc: TitanCore.Process;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* # Time Module
|
|
209
|
+
*
|
|
210
|
+
* Time utilities including sleep, timestamps, and timing.
|
|
211
|
+
* All methods are **synchronous**.
|
|
212
|
+
*
|
|
213
|
+
* **Methods:**
|
|
214
|
+
* - `now()` — Current timestamp in milliseconds
|
|
215
|
+
* - `timestamp()` — ISO 8601 timestamp string
|
|
216
|
+
* - `sleep(ms)` — Blocking sleep
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* ```js
|
|
220
|
+
* import { time } from '@titanpl/core';
|
|
221
|
+
*
|
|
222
|
+
* // Measure execution time
|
|
223
|
+
* const start = time.now();
|
|
224
|
+
* performOperation();
|
|
225
|
+
* console.log(`Took ${time.now() - start}ms`);
|
|
226
|
+
*
|
|
227
|
+
* // Get ISO timestamp
|
|
228
|
+
* const ts = time.timestamp();
|
|
229
|
+
* // → "2026-01-15T12:30:45.123Z"
|
|
230
|
+
*
|
|
231
|
+
* // Rate limiting
|
|
232
|
+
* time.sleep(100); // Wait 100ms
|
|
233
|
+
* ```
|
|
234
|
+
*
|
|
235
|
+
* @see https://github.com/ezet-galaxy/-titanpl-core#time-time
|
|
236
|
+
*/
|
|
237
|
+
export declare const time: TitanCore.Time;
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* # URL Module
|
|
241
|
+
*
|
|
242
|
+
* URL parsing, formatting, and query string manipulation.
|
|
243
|
+
* All methods are **synchronous**.
|
|
244
|
+
*
|
|
245
|
+
* **Methods:**
|
|
246
|
+
* - `parse(url)` — Parse URL to components
|
|
247
|
+
* - `format(urlObj)` — Build URL from components
|
|
248
|
+
* - `SearchParams` — Query string class
|
|
249
|
+
*
|
|
250
|
+
* @example
|
|
251
|
+
* ```js
|
|
252
|
+
* import { url } from '@titanpl/core';
|
|
253
|
+
*
|
|
254
|
+
* // Parse URL
|
|
255
|
+
* const parsed = url.parse("https://api.example.com:8080/users?page=2");
|
|
256
|
+
* // → { protocol: "https:", hostname: "api.example.com", ... }
|
|
257
|
+
*
|
|
258
|
+
* // Build URL
|
|
259
|
+
* const built = url.format({
|
|
260
|
+
* protocol: "https:",
|
|
261
|
+
* hostname: "api.example.com",
|
|
262
|
+
* pathname: "/v2/users"
|
|
263
|
+
* });
|
|
264
|
+
*
|
|
265
|
+
* // Query strings
|
|
266
|
+
* const params = new url.SearchParams({ page: "1", limit: "20" });
|
|
267
|
+
* params.set("sort", "name");
|
|
268
|
+
* console.log(params.toString()); // → "page=1&limit=20&sort=name"
|
|
269
|
+
* ```
|
|
270
|
+
*
|
|
271
|
+
* @see https://github.com/ezet-galaxy/-titanpl-core#url-url
|
|
272
|
+
*/
|
|
273
|
+
export declare const url: TitanCore.URLModule;
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* # Buffer Module
|
|
277
|
+
*
|
|
278
|
+
* Binary data encoding and decoding utilities. All methods are **synchronous**.
|
|
279
|
+
*
|
|
280
|
+
* **Methods:**
|
|
281
|
+
* - `toBase64(data)` / `fromBase64(str)` — Base64 encoding
|
|
282
|
+
* - `toHex(data)` / `fromHex(str)` — Hex encoding
|
|
283
|
+
* - `toUtf8(bytes)` / `fromUtf8(str)` — UTF-8 encoding
|
|
284
|
+
*
|
|
285
|
+
* @example
|
|
286
|
+
* ```js
|
|
287
|
+
* import { buffer } from '@titanpl/core';
|
|
288
|
+
*
|
|
289
|
+
* // Base64
|
|
290
|
+
* const b64 = buffer.toBase64("Hello, World!");
|
|
291
|
+
* const decoded = buffer.toUtf8(buffer.fromBase64(b64));
|
|
292
|
+
*
|
|
293
|
+
* // Hex
|
|
294
|
+
* const hex = buffer.toHex("Hello");
|
|
295
|
+
* // → "48656c6c6f"
|
|
296
|
+
* ```
|
|
297
|
+
*
|
|
298
|
+
* @see https://github.com/ezet-galaxy/-titanpl-core#buffer-buffer-utilities
|
|
299
|
+
*/
|
|
300
|
+
export declare const buffer: TitanCore.BufferModule;
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* # Local Storage Module
|
|
304
|
+
*
|
|
305
|
+
* High-performance in-memory key-value store. All methods are **synchronous**.
|
|
306
|
+
*
|
|
307
|
+
* **Performance:** ~150,000+ ops/sec (native Rust RwLock<HashMap>)
|
|
308
|
+
*
|
|
309
|
+
* **Methods:**
|
|
310
|
+
* - `get(key)` / `set(key, value)` — String storage
|
|
311
|
+
* - `getObject(key)` / `setObject(key, value)` — Complex object storage
|
|
312
|
+
* - `remove(key)` / `clear()` — Deletion
|
|
313
|
+
* - `keys()` — List all keys
|
|
314
|
+
* - `serialize(value)` / `deserialize(bytes)` — V8 serialization
|
|
315
|
+
*
|
|
316
|
+
* @example
|
|
317
|
+
* ```js
|
|
318
|
+
* import { ls } from '@titanpl/core';
|
|
319
|
+
*
|
|
320
|
+
* // String storage
|
|
321
|
+
* ls.set("user:123", JSON.stringify({ name: "Alice" }));
|
|
322
|
+
* const user = JSON.parse(ls.get("user:123") || "{}");
|
|
323
|
+
*
|
|
324
|
+
* // Complex objects (preserves Map, Set, Date)
|
|
325
|
+
* const data = {
|
|
326
|
+
* users: new Map([["alice", { role: "admin" }]]),
|
|
327
|
+
* tags: new Set(["active"]),
|
|
328
|
+
* created: new Date()
|
|
329
|
+
* };
|
|
330
|
+
* ls.setObject("session", data);
|
|
331
|
+
* const restored = ls.getObject("session");
|
|
332
|
+
* // restored.users instanceof Map → true
|
|
333
|
+
*
|
|
334
|
+
* // Cleanup
|
|
335
|
+
* ls.remove("user:123");
|
|
336
|
+
* ls.clear();
|
|
337
|
+
* ```
|
|
338
|
+
*
|
|
339
|
+
* @see https://github.com/ezet-galaxy/-titanpl-core#ls--localstorage-persistent-storage
|
|
340
|
+
*/
|
|
341
|
+
export declare const ls: TitanCore.LocalStorage;
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* # Local Storage Module (Alias)
|
|
345
|
+
*
|
|
346
|
+
* Alias for `ls` — same high-performance key-value store.
|
|
347
|
+
*
|
|
348
|
+
* @see {@link ls}
|
|
349
|
+
* @see https://github.com/ezet-galaxy/-titanpl-core#ls--localstorage-persistent-storage
|
|
350
|
+
*/
|
|
351
|
+
export declare const localStorage: TitanCore.LocalStorage;
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* # Session Module
|
|
355
|
+
*
|
|
356
|
+
* Server-side session state management. All methods are **synchronous**.
|
|
357
|
+
*
|
|
358
|
+
* Uses composite keys (`{sessionId}:{key}`) for session isolation.
|
|
359
|
+
*
|
|
360
|
+
* **Methods:**
|
|
361
|
+
* - `get(sessionId, key)` — Get session value
|
|
362
|
+
* - `set(sessionId, key, value)` — Set session value
|
|
363
|
+
* - `delete(sessionId, key)` — Delete session key
|
|
364
|
+
* - `clear(sessionId)` — Clear entire session
|
|
365
|
+
*
|
|
366
|
+
* @example
|
|
367
|
+
* ```js
|
|
368
|
+
* import { session, crypto, cookies } from '@titanpl/core';
|
|
369
|
+
*
|
|
370
|
+
* export function handleRequest(req) {
|
|
371
|
+
* // Get or create session ID
|
|
372
|
+
* let sessionId = cookies.get(req, "sid");
|
|
373
|
+
* if (!sessionId) {
|
|
374
|
+
* sessionId = crypto.uuid();
|
|
375
|
+
* cookies.set(req, "sid", sessionId, { httpOnly: true });
|
|
376
|
+
* }
|
|
377
|
+
*
|
|
378
|
+
* // Store user data
|
|
379
|
+
* session.set(sessionId, "userId", "123");
|
|
380
|
+
* session.set(sessionId, "cart", JSON.stringify([1, 2, 3]));
|
|
381
|
+
*
|
|
382
|
+
* // Retrieve data
|
|
383
|
+
* const cart = JSON.parse(session.get(sessionId, "cart") || "[]");
|
|
384
|
+
*
|
|
385
|
+
* // Logout
|
|
386
|
+
* session.clear(sessionId);
|
|
387
|
+
* }
|
|
388
|
+
* ```
|
|
389
|
+
*
|
|
390
|
+
* @see https://github.com/ezet-galaxy/-titanpl-core#session-server-side-sessions
|
|
391
|
+
*/
|
|
392
|
+
export declare const session: TitanCore.Session;
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* # Cookies Module
|
|
396
|
+
*
|
|
397
|
+
* HTTP cookie parsing and setting utilities.
|
|
398
|
+
*
|
|
399
|
+
* **Methods:**
|
|
400
|
+
* - `get(req, name)` — Read cookie from request
|
|
401
|
+
* - `set(res, name, value, options)` — Set cookie on response
|
|
402
|
+
* - `delete(res, name)` — Delete cookie
|
|
403
|
+
*
|
|
404
|
+
* **Options:** `httpOnly`, `secure`, `sameSite`, `maxAge`, `path`
|
|
405
|
+
*
|
|
406
|
+
* @example
|
|
407
|
+
* ```js
|
|
408
|
+
* import { cookies, crypto } from '@titanpl/core';
|
|
409
|
+
*
|
|
410
|
+
* export function auth(req) {
|
|
411
|
+
* // Read cookie
|
|
412
|
+
* const token = cookies.get(req, "auth_token");
|
|
413
|
+
*
|
|
414
|
+
* if (!token) {
|
|
415
|
+
* // Set secure cookie
|
|
416
|
+
* cookies.set(req, "auth_token", crypto.uuid(), {
|
|
417
|
+
* httpOnly: true,
|
|
418
|
+
* secure: true,
|
|
419
|
+
* sameSite: "Strict",
|
|
420
|
+
* maxAge: 86400 * 7, // 7 days
|
|
421
|
+
* path: "/"
|
|
422
|
+
* });
|
|
423
|
+
* }
|
|
424
|
+
*
|
|
425
|
+
* // Delete cookie (logout)
|
|
426
|
+
* cookies.delete(req, "auth_token");
|
|
427
|
+
* }
|
|
428
|
+
* ```
|
|
429
|
+
*
|
|
430
|
+
* @see https://github.com/ezet-galaxy/-titanpl-core#cookies-http-cookies
|
|
431
|
+
*/
|
|
432
|
+
export declare const cookies: TitanCore.Cookies;
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* # Response Module
|
|
436
|
+
*
|
|
437
|
+
* HTTP response builder for controlled response formatting.
|
|
438
|
+
*
|
|
439
|
+
* **Methods:**
|
|
440
|
+
* - `response(options)` — Custom response
|
|
441
|
+
* - `response.json(data, options?)` — JSON response
|
|
442
|
+
* - `response.html(content, options?)` — HTML response
|
|
443
|
+
* - `response.text(content, options?)` — Plain text response
|
|
444
|
+
* - `response.redirect(url, status?)` — Redirect response
|
|
445
|
+
* - `response.empty(status?)` — Empty response (204)
|
|
446
|
+
*
|
|
447
|
+
* @example
|
|
448
|
+
* ```js
|
|
449
|
+
* import { response, fs } from '@titanpl/core';
|
|
450
|
+
*
|
|
451
|
+
* // JSON response
|
|
452
|
+
* export function getUsers(req) {
|
|
453
|
+
* return response.json({ users: [], total: 0 });
|
|
454
|
+
* }
|
|
455
|
+
*
|
|
456
|
+
* // Error response
|
|
457
|
+
* export function notFound(req) {
|
|
458
|
+
* return response.json({ error: "Not found" }, { status: 404 });
|
|
459
|
+
* }
|
|
460
|
+
*
|
|
461
|
+
* // HTML response
|
|
462
|
+
* export function home(req) {
|
|
463
|
+
* const html = fs.readFile("./views/index.html");
|
|
464
|
+
* return response.html(html);
|
|
465
|
+
* }
|
|
466
|
+
*
|
|
467
|
+
* // Redirect
|
|
468
|
+
* export function legacy(req) {
|
|
469
|
+
* return response.redirect("/api/v2/users", 301);
|
|
470
|
+
* }
|
|
471
|
+
*
|
|
472
|
+
* // Custom response with headers
|
|
473
|
+
* export function download(req) {
|
|
474
|
+
* return response({
|
|
475
|
+
* status: 200,
|
|
476
|
+
* headers: {
|
|
477
|
+
* "Content-Type": "text/csv",
|
|
478
|
+
* "Content-Disposition": "attachment; filename=\"data.csv\""
|
|
479
|
+
* },
|
|
480
|
+
* body: fs.readFile("./export.csv")
|
|
481
|
+
* });
|
|
482
|
+
* }
|
|
483
|
+
*
|
|
484
|
+
* // Empty response (after DELETE)
|
|
485
|
+
* export function deleteUser(req) {
|
|
486
|
+
* removeUser(req.params.id);
|
|
487
|
+
* return response.empty();
|
|
488
|
+
* }
|
|
489
|
+
* ```
|
|
490
|
+
*
|
|
491
|
+
* @see https://titan-docs-ez.vercel.app/docs/04-runtime-apis
|
|
492
|
+
*/
|
|
493
|
+
export declare const response: TitanCore.ResponseModule;
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* # Core Module
|
|
497
|
+
*
|
|
498
|
+
* Unified namespace providing access to all @titanpl/core APIs.
|
|
499
|
+
* Useful for destructuring multiple modules at once.
|
|
500
|
+
*
|
|
501
|
+
* @example
|
|
502
|
+
* ```js
|
|
503
|
+
* import { core } from '@titanpl/core';
|
|
504
|
+
*
|
|
505
|
+
* // Destructure what you need
|
|
506
|
+
* const { fs, crypto, os, response } = core;
|
|
507
|
+
*
|
|
508
|
+
* // Or access directly
|
|
509
|
+
* const config = JSON.parse(core.fs.readFile("./config.json"));
|
|
510
|
+
* const id = core.crypto.uuid();
|
|
511
|
+
* ```
|
|
512
|
+
*
|
|
513
|
+
* @see https://github.com/ezet-galaxy/-titanpl-core
|
|
514
|
+
*/
|
|
515
|
+
export declare const core: TitanCore.Core;
|