titanpl 7.0.0 → 7.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.
Files changed (54) hide show
  1. package/package.json +1 -1
  2. package/packages/cli/package.json +4 -4
  3. package/packages/cli/src/commands/build-ext.js +17 -4
  4. package/packages/engine-darwin-arm64/package.json +1 -1
  5. package/packages/engine-linux-x64/package.json +1 -1
  6. package/packages/engine-win32-x64/bin/titan-server.exe +0 -0
  7. package/packages/engine-win32-x64/package.json +1 -1
  8. package/packages/native/index.d.ts +27 -0
  9. package/packages/native/index.js +1 -0
  10. package/packages/native/package.json +1 -1
  11. package/packages/native/t.native.d.ts +99 -3
  12. package/packages/packet/package.json +1 -1
  13. package/packages/route/package.json +1 -1
  14. package/packages/sdk/package.json +1 -1
  15. package/templates/extension/README_WASM.md +38 -0
  16. package/templates/extension/package.json +2 -2
  17. package/templates/js/package.json +7 -7
  18. package/templates/rust-js/package.json +4 -4
  19. package/templates/rust-ts/package.json +4 -4
  20. package/templates/ts/package.json +7 -7
  21. package/packages/core-source/LICENSE +0 -15
  22. package/packages/core-source/README.md +0 -128
  23. package/packages/core-source/V8_SERIALIZATION.md +0 -125
  24. package/packages/core-source/configure.js +0 -50
  25. package/packages/core-source/globals.d.ts +0 -2238
  26. package/packages/core-source/index.d.ts +0 -515
  27. package/packages/core-source/index.js +0 -639
  28. package/packages/core-source/jsconfig.json +0 -12
  29. package/packages/core-source/mkctx.config.json +0 -7
  30. package/packages/core-source/native/Cargo.lock +0 -1559
  31. package/packages/core-source/native/Cargo.toml +0 -30
  32. package/packages/core-source/native/src/crypto_impl.rs +0 -139
  33. package/packages/core-source/native/src/lib.rs +0 -702
  34. package/packages/core-source/native/src/storage_impl.rs +0 -73
  35. package/packages/core-source/native/src/v8_impl.rs +0 -93
  36. package/packages/core-source/package-lock.json +0 -1464
  37. package/packages/core-source/package.json +0 -53
  38. package/packages/core-source/tests/buffer.test.js +0 -78
  39. package/packages/core-source/tests/cookies.test.js +0 -117
  40. package/packages/core-source/tests/crypto.test.js +0 -142
  41. package/packages/core-source/tests/fs.test.js +0 -176
  42. package/packages/core-source/tests/ls.test.js +0 -149
  43. package/packages/core-source/tests/net.test.js +0 -84
  44. package/packages/core-source/tests/os.test.js +0 -81
  45. package/packages/core-source/tests/path.test.js +0 -102
  46. package/packages/core-source/tests/response.test.js +0 -146
  47. package/packages/core-source/tests/session.test.js +0 -110
  48. package/packages/core-source/tests/setup.js +0 -325
  49. package/packages/core-source/tests/time.test.js +0 -57
  50. package/packages/core-source/tests/url.test.js +0 -82
  51. package/packages/core-source/titan-ext.d.ts +0 -2
  52. package/packages/core-source/titan.json +0 -9
  53. package/packages/core-source/vitest.config.js +0 -8
  54. package/templates/extension/README.md +0 -69
@@ -1,515 +0,0 @@
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;