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,639 +0,0 @@
1
- const b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
2
-
3
- function local_btoa(input) {
4
- let str = String(input);
5
- let output = '';
6
-
7
- for (let i = 0; i < str.length; i += 3) {
8
- const char1 = str.charCodeAt(i);
9
- const char2 = str.charCodeAt(i + 1);
10
- const char3 = str.charCodeAt(i + 2);
11
-
12
- const enc1 = char1 >> 2;
13
- const enc2 = ((char1 & 3) << 4) | (char2 >> 4);
14
- let enc3 = ((char2 & 15) << 2) | (char3 >> 6);
15
- let enc4 = char3 & 63;
16
-
17
- if (isNaN(char2)) {
18
- enc3 = enc4 = 64;
19
- } else if (isNaN(char3)) {
20
- enc4 = 64;
21
- }
22
-
23
- output += b64chars.charAt(enc1) + b64chars.charAt(enc2);
24
- output += (enc3 === 64) ? '=' : b64chars.charAt(enc3);
25
- output += (enc4 === 64) ? '=' : b64chars.charAt(enc4);
26
- }
27
-
28
- return output;
29
- }
30
-
31
- function local_atob(input) {
32
- // Remove whitespace and padding '='
33
- let str = String(input).replace(/[\t\n\f\r =]/g, "");
34
- let output = '';
35
-
36
- for (let i = 0; i < str.length; i += 4) {
37
- const c1Str = str.charAt(i);
38
- const c2Str = str.charAt(i + 1);
39
- const c3Str = str.charAt(i + 2);
40
- const c4Str = str.charAt(i + 3);
41
-
42
- const e1 = b64chars.indexOf(c1Str);
43
- const e2 = c2Str ? b64chars.indexOf(c2Str) : -1;
44
- const e3 = c3Str ? b64chars.indexOf(c3Str) : -1;
45
- const e4 = c4Str ? b64chars.indexOf(c4Str) : -1;
46
-
47
- // e1 and e2 are required
48
- if (e1 < 0 || e2 < 0) continue;
49
-
50
- // Shift and mask to reconstruct bytes
51
- const c1 = (e1 << 2) | (e2 >> 4);
52
- output += String.fromCharCode(c1);
53
-
54
- if (e3 !== -1) {
55
- const c2 = ((e2 & 15) << 4) | (e3 >> 2);
56
- output += String.fromCharCode(c2);
57
- }
58
- if (e4 !== -1) {
59
- const c3 = ((e3 & 3) << 6) | e4;
60
- output += String.fromCharCode(c3);
61
- }
62
- }
63
-
64
- return output;
65
- }
66
-
67
- function local_utf8_encode(str) {
68
- let result = [];
69
- for (let i = 0; i < str.length; i++) {
70
- let c = str.charCodeAt(i);
71
- if (c < 0x80) { result.push(c); }
72
- else if (c < 0x800) {
73
- result.push(0xc0 | (c >> 6), 0x80 | (c & 0x3f));
74
- }
75
- else if (c < 0xd800 || c >= 0xe000) {
76
- result.push(0xe0 | (c >> 12), 0x80 | ((c >> 6) & 0x3f), 0x80 | (c & 0x3f));
77
- }
78
- else {
79
- i++;
80
- c = 0x10000 + (((c & 0x3ff) << 10) | (str.charCodeAt(i) & 0x3ff));
81
- result.push(0xf0 | (c >> 18), 0x80 | ((c >> 12) & 0x3f), 0x80 | ((c >> 6) & 0x3f), 0x80 | (c & 0x3f));
82
- }
83
- }
84
- return new Uint8Array(result);
85
- }
86
-
87
- function local_utf8_decode(bytes) {
88
- let str = "";
89
- let i = 0;
90
- while (i < bytes.length) {
91
- let c = bytes[i++];
92
- if (c > 127) {
93
- if (c > 191 && c < 224) {
94
- c = ((c & 31) << 6) | (bytes[i++] & 63);
95
- } else if (c > 223 && c < 240) {
96
- c = ((c & 15) << 12) | ((bytes[i++] & 63) << 6) | (bytes[i++] & 63);
97
- } else if (c > 239 && c < 248) {
98
- c = ((c & 7) << 18) | ((bytes[i++] & 63) << 12) | ((bytes[i++] & 63) << 6) | (bytes[i++] & 63);
99
- }
100
- }
101
- if (c <= 0xffff) str += String.fromCharCode(c);
102
- else if (c <= 0x10ffff) {
103
- c -= 0x10000;
104
- str += String.fromCharCode(c >> 10 | 0xd800) + String.fromCharCode(c & 0x3ff | 0xdc00);
105
- }
106
- }
107
- return str;
108
- }
109
-
110
-
111
- // Native bindings are loaded by the runtime into t["@titanpl/core"]
112
- const natives = t["@titanpl/core"] || {};
113
-
114
- // --- FS ---
115
- /** File System module */
116
- const fs = {
117
- /** Reads file content as string. Supports options: { encoding: 'utf8' } or encoding name string. */
118
- readFile: (path, options) => {
119
- const encoding = typeof options === 'string' ? options : (options && options.encoding);
120
- const res = natives.fs_read_file(path);
121
- if (res && typeof res === 'string' && res.startsWith("ERROR:")) throw new Error(res);
122
- return res;
123
- },
124
- /** Writes content to file */
125
- writeFile: (path, content) => {
126
- const res = natives.fs_write_file(path, content);
127
- if (res && typeof res === 'string' && res.startsWith("ERROR:")) throw new Error(res);
128
- },
129
- /** Reads directory contents */
130
- readdir: (path) => {
131
- const res = natives.fs_readdir(path);
132
- try {
133
- return typeof res === 'string' ? JSON.parse(res) : res;
134
- } catch (e) {
135
- return [];
136
- }
137
- },
138
- /** Creates direction recursively */
139
- mkdir: (path) => {
140
- const res = natives.fs_mkdir(path);
141
- if (res && typeof res === 'string' && res.startsWith("ERROR:")) throw new Error(res);
142
- },
143
- /** Checks if path exists */
144
- exists: (path) => {
145
- return natives.fs_exists(path);
146
- },
147
- /** Returns file stats */
148
- stat: (path) => {
149
- const res = natives.fs_stat(path);
150
- try {
151
- return typeof res === 'string' ? JSON.parse(res) : res;
152
- } catch (e) {
153
- return {};
154
- }
155
- },
156
- /** Removes file or directory */
157
- remove: (path) => {
158
- const res = natives.fs_remove(path);
159
- if (res && typeof res === 'string' && res.startsWith("ERROR:")) throw new Error(res);
160
- }
161
- };
162
-
163
- // --- Path ---
164
- /** Path manipulation module */
165
- const path = {
166
- join: (...args) => {
167
- return args
168
- .map((part, i) => {
169
- if (!part) return '';
170
- let p = part.replace(/\\/g, '/');
171
- if (i === 0) return p.trim().replace(/[\/]*$/g, '');
172
- return p.trim().replace(/(^[\/]*|[\/]*$)/g, '');
173
- })
174
- .filter(x => x.length)
175
- .join('/');
176
- },
177
- resolve: (...args) => {
178
- let resolved = '';
179
- for (let arg of args) {
180
- resolved = path.join(resolved, arg);
181
- }
182
- if (!resolved.startsWith('/')) {
183
- const isWindowsAbs = /^[a-zA-Z]:\\/.test(resolved) || resolved.startsWith('\\');
184
- if (!isWindowsAbs && natives.path_cwd) {
185
- const cwd = natives.path_cwd();
186
- if (cwd) {
187
- resolved = path.join(cwd, resolved);
188
- }
189
- }
190
- }
191
- return resolved;
192
- },
193
- extname: (p) => {
194
- const parts = p.split('.');
195
- return parts.length > 1 && !p.startsWith('.') ? '.' + parts.pop() : '';
196
- },
197
- dirname: (p) => {
198
- const parts = p.split('/');
199
- parts.pop();
200
- return parts.join('/') || '.';
201
- },
202
- basename: (p) => p.split('/').pop()
203
- };
204
-
205
- // --- Crypto ---
206
- /** Cryptography module */
207
- const crypto = {
208
- hash: (algo, data) => natives.crypto_hash ? natives.crypto_hash(algo, data) : "",
209
- randomBytes: (size) => natives.crypto_random_bytes ? natives.crypto_random_bytes(size) : "",
210
- uuid: () => natives.crypto_uuid ? natives.crypto_uuid() : "",
211
- base64: {
212
- encode: (str) => local_btoa(str),
213
- decode: (str) => local_atob(str),
214
- },
215
- // Extended API
216
- /** Encrypts data using AES-256-GCM. Returns Base64 string. */
217
- encrypt: (algorithm, key, plaintext) => {
218
- const res = natives.crypto_encrypt(algorithm, JSON.stringify({ key, plaintext }));
219
- if (res && typeof res === 'string' && res.startsWith("ERROR:")) throw new Error(res.substring(6));
220
- return res;
221
- },
222
- /** Decrypts data using AES-256-GCM. Returns plaintext string. */
223
- decrypt: (algorithm, key, ciphertext) => {
224
- const res = natives.crypto_decrypt(algorithm, JSON.stringify({ key, ciphertext }));
225
- if (res && typeof res === 'string' && res.startsWith("ERROR:")) throw new Error(res.substring(6));
226
- return res;
227
- },
228
- /** Computes HMAC-SHA256/512. Returns Hex string. */
229
- hashKeyed: (algorithm, key, message) => {
230
- const res = natives.crypto_hash_keyed(algorithm, JSON.stringify({ key, message }));
231
- if (res && typeof res === 'string' && res.startsWith("ERROR:")) throw new Error(res.substring(6));
232
- return res;
233
- },
234
- /** Constant-time string comparison */
235
- compare: (a, b) => {
236
- if (natives.crypto_compare) return natives.crypto_compare(a, b);
237
- // Fallback insecure
238
- if (a.length !== b.length) return false;
239
- let mismatch = 0;
240
- for (let i = 0; i < a.length; ++i) {
241
- mismatch |= (a.charCodeAt(i) ^ b.charCodeAt(i));
242
- }
243
- return mismatch === 0;
244
- }
245
- };
246
-
247
- // --- Buffer ---
248
- // Helper for hex
249
- function hexToBytes(hex) {
250
- const bytes = new Uint8Array(hex.length / 2);
251
- for (let i = 0; i < bytes.length; i++) {
252
- bytes[i] = parseInt(hex.substr(i * 2, 2), 16);
253
- }
254
- return bytes;
255
- }
256
- function bytesToHex(bytes) {
257
- return Array.from(bytes).map(b => b.toString(16).padStart(2, '0')).join('');
258
- }
259
-
260
- /** Buffer utility module */
261
- const buffer = {
262
- /** Creates Uint8Array from Base64 string */
263
- fromBase64: (str) => {
264
- const binary = local_atob(str);
265
- const bytes = new Uint8Array(binary.length);
266
- for (let i = 0; i < binary.length; i++) {
267
- bytes[i] = binary.charCodeAt(i);
268
- }
269
- return bytes;
270
- },
271
- /** encoded Uint8Array or String to Base64 string */
272
- toBase64: (bytes) => {
273
- let binary = '';
274
- if (typeof bytes === 'string') {
275
- return local_btoa(bytes);
276
- }
277
- // Uint8Array
278
- const len = bytes.byteLength;
279
- for (let i = 0; i < len; i++) {
280
- binary += String.fromCharCode(bytes[i]);
281
- }
282
- return local_btoa(binary);
283
- },
284
- /** Creates Uint8Array from Hex string */
285
- fromHex: (str) => hexToBytes(str),
286
- /** Encodes bytes to Hex string */
287
- toHex: (bytes) => {
288
- if (typeof bytes === 'string') {
289
- return bytesToHex(local_utf8_encode(bytes));
290
- }
291
- return bytesToHex(bytes);
292
- },
293
- /** Creates Uint8Array from UTF-8 string */
294
- fromUtf8: (str) => local_utf8_encode(str),
295
- /** Decodes bytes to UTF-8 string */
296
- toUtf8: (bytes) => local_utf8_decode(bytes)
297
- };
298
-
299
- // --- Local Storage ---
300
- /** High-performance in-memory Local Storage (backed by native RwLock<HashMap>) */
301
- const ls = {
302
- get: (key) => {
303
- return natives.ls_get(key);
304
- },
305
- set: (key, value) => {
306
- natives.ls_set(key, String(value));
307
- },
308
- remove: (key) => {
309
- natives.ls_remove(key);
310
- },
311
- clear: () => {
312
- natives.ls_clear();
313
- },
314
- keys: () => {
315
- const result = natives.ls_keys();
316
- try {
317
- return typeof result === 'string' ? JSON.parse(result) : result;
318
- } catch (e) {
319
- return [];
320
- }
321
- },
322
- /** Native V8 serialization - supports Map, Set, Date, Uint8Array, etc. */
323
- serialize: (value) => {
324
- return t.serialize ? t.serialize(value) : (natives.serialize ? natives.serialize(value) : null);
325
- },
326
- /** Native V8 deserialization - restores complex JS objects */
327
- deserialize: (bytes) => {
328
- return t.deserialize ? t.deserialize(bytes) : (natives.deserialize ? natives.deserialize(bytes) : null);
329
- },
330
- /** Store a complex JS object using native V8 serialization */
331
- setObject: (key, value) => {
332
- if (!natives.serialize) return;
333
- const bytes = natives.serialize(value);
334
- const base64 = buffer.toBase64(bytes);
335
- natives.ls_set(key, base64);
336
- },
337
- /** Retrieve and restore a complex JS object */
338
- getObject: (key) => {
339
- if (!natives.deserialize) return null;
340
- const base64 = natives.ls_get(key);
341
- if (!base64) return null;
342
- try {
343
- const bytes = buffer.fromBase64(base64);
344
- return natives.deserialize(bytes);
345
- } catch (e) {
346
- return null;
347
- }
348
- }
349
- };
350
-
351
- // --- Sessions ---
352
- /** High-performance in-memory Session Management (backed by native RwLock<HashMap>) */
353
- const session = {
354
- get: (sessionId, key) => {
355
- return natives.session_get(sessionId, key);
356
- },
357
- set: (sessionId, key, value) => {
358
- natives.session_set(sessionId, key, String(value));
359
- },
360
- delete: (sessionId, key) => {
361
- natives.session_delete(sessionId, key);
362
- },
363
- clear: (sessionId) => {
364
- natives.session_clear(sessionId);
365
- }
366
- };
367
-
368
-
369
- // --- Cookies ---
370
- /** HTTP Cookie Utilities */
371
- const cookies = {
372
- /** Parses cookie from request headers */
373
- get: (req, name) => {
374
- if (!req || !req.headers) return null;
375
- const cookieHeader = req.headers.cookie;
376
- if (!cookieHeader) return null;
377
- const cookies = cookieHeader.split(';');
378
- for (let c of cookies) {
379
- const [k, v] = c.trim().split('=');
380
- if (k === name) return decodeURIComponent(v);
381
- }
382
- return null;
383
- },
384
- /** Sets Set-Cookie header on response */
385
- set: (res, name, value, options = {}) => {
386
- if (!res || !res.setHeader) return;
387
- let cookie = `${name}=${encodeURIComponent(value)}`;
388
- if (options.maxAge) cookie += `; Max-Age=${options.maxAge}`;
389
- if (options.path) cookie += `; Path=${options.path}`;
390
- if (options.httpOnly) cookie += `; HttpOnly`;
391
- if (options.secure) cookie += `; Secure`;
392
- if (options.sameSite) cookie += `; SameSite=${options.sameSite}`;
393
-
394
- let prev = res.getHeader ? res.getHeader('Set-Cookie') : null;
395
- if (prev) {
396
- if (Array.isArray(prev)) {
397
- prev.push(cookie);
398
- res.setHeader('Set-Cookie', prev);
399
- } else {
400
- res.setHeader('Set-Cookie', [prev, cookie]);
401
- }
402
- } else {
403
- res.setHeader('Set-Cookie', cookie);
404
- }
405
- },
406
- /** Deletes cookie by setting maxAge=0 */
407
- delete: (res, name) => {
408
- cookies.set(res, name, "", { maxAge: 0, path: '/' });
409
- }
410
- };
411
-
412
-
413
-
414
- // --- Response ---
415
- /** Advanced HTTP Response Management */
416
- const response = (options) => {
417
- return {
418
- _isResponse: true,
419
- status: options.status || 200,
420
- headers: options.headers || {},
421
- body: options.body || ""
422
- };
423
- };
424
-
425
- response.text = (content, options = {}) => {
426
- return {
427
- _isResponse: true,
428
- status: options.status || 200,
429
- headers: { "Content-Type": "text/plain", ...(options.headers || {}) },
430
- body: content
431
- };
432
- };
433
-
434
- response.html = (content, options = {}) => {
435
- return {
436
- _isResponse: true,
437
- status: options.status || 200,
438
- headers: { "Content-Type": "text/html; charset=utf-8", ...(options.headers || {}) },
439
- body: content
440
- };
441
- };
442
-
443
- response.json = (content, options = {}) => {
444
- return {
445
- _isResponse: true,
446
- status: options.status || 200,
447
- headers: { "Content-Type": "application/json", ...(options.headers || {}) },
448
- body: JSON.stringify(content)
449
- };
450
- };
451
-
452
- response.redirect = (url, status = 302) => {
453
- return {
454
- _isResponse: true,
455
- status: status,
456
- headers: { "Location": url },
457
- body: ""
458
- };
459
- };
460
-
461
- response.empty = (status = 204) => {
462
- return {
463
- _isResponse: true,
464
- status: status,
465
- headers: {},
466
- body: ""
467
- };
468
- };
469
-
470
- // --- OS ---
471
- const os = {
472
- platform: () => {
473
- if (!natives.os_info) return "unknown";
474
- const result = natives.os_info();
475
- const info = typeof result === 'string' ? JSON.parse(result) : result;
476
- return info.platform;
477
- },
478
- cpus: () => {
479
- if (!natives.os_info) return 1;
480
- const result = natives.os_info();
481
- const info = typeof result === 'string' ? JSON.parse(result) : result;
482
- return info.cpus;
483
- },
484
- totalMemory: () => {
485
- if (!natives.os_info) return 0;
486
- const result = natives.os_info();
487
- const info = typeof result === 'string' ? JSON.parse(result) : result;
488
- return info.totalMemory;
489
- },
490
- freeMemory: () => {
491
- if (!natives.os_info) return 0;
492
- const result = natives.os_info();
493
- const info = typeof result === 'string' ? JSON.parse(result) : result;
494
- return info.freeMemory;
495
- },
496
- tmpdir: () => {
497
- if (!natives.os_info) return '/tmp';
498
- try {
499
- const result = natives.os_info();
500
- const info = typeof result === 'string' ? JSON.parse(result) : result;
501
- return info.tempDir || '/tmp';
502
- } catch (e) {
503
- return '/tmp';
504
- }
505
- }
506
- };
507
-
508
- // --- Net ---
509
- const net = {
510
- resolveDNS: (hostname) => {
511
- if (!natives.net_resolve) return [];
512
- const result = natives.net_resolve(hostname);
513
- return typeof result === 'string' ? JSON.parse(result) : result;
514
- },
515
- ip: () => natives.net_ip ? natives.net_ip() : "127.0.0.1",
516
- ping: (host) => true
517
- };
518
-
519
- // --- Proc ---
520
- const proc = {
521
- pid: () => {
522
- if (!natives.proc_info) return 0;
523
- const result = natives.proc_info();
524
- if (!result) return 0;
525
- const info = typeof result === 'string' ? JSON.parse(result) : result;
526
- return info.pid;
527
- },
528
- uptime: () => {
529
- if (!natives.proc_info) return 0;
530
- const result = natives.proc_info();
531
- if (!result) return 0;
532
- const info = typeof result === 'string' ? JSON.parse(result) : result;
533
- return info.uptime;
534
- },
535
- memory: () => ({})
536
- };
537
-
538
- // --- Time ---
539
- const time = {
540
- sleep: (ms) => {
541
- if (natives.time_sleep) natives.time_sleep(ms);
542
- },
543
- now: () => Date.now(),
544
- timestamp: () => new Date().toISOString()
545
- };
546
-
547
- // --- URL ---
548
- class TitanURLSearchParams {
549
- constructor(init = '') {
550
- this._params = {};
551
- if (typeof init === 'string') {
552
- const query = init.startsWith('?') ? init.slice(1) : init;
553
- query.split('&').forEach(pair => {
554
- const [key, value] = pair.split('=').map(decodeURIComponent);
555
- if (key) this._params[key] = value || '';
556
- });
557
- } else if (typeof init === 'object') {
558
- Object.assign(this._params, init);
559
- }
560
- }
561
- get(key) { return this._params[key] || null; }
562
- set(key, value) { this._params[key] = String(value); }
563
- has(key) { return key in this._params; }
564
- delete(key) { delete this._params[key]; }
565
- toString() {
566
- return Object.entries(this._params)
567
- .map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`)
568
- .join('&');
569
- }
570
- entries() { return Object.entries(this._params); }
571
- keys() { return Object.keys(this._params); }
572
- values() { return Object.values(this._params); }
573
- }
574
-
575
- const url = {
576
- parse: (str) => {
577
- if (typeof URL !== 'undefined') {
578
- return new URL(str);
579
- }
580
- const match = str.match(/^(https?:)\/\/([^/:]+)(?::(\d+))?(\/[^?#]*)?(\?[^#]*)?(#.*)?$/);
581
- if (!match) throw new Error('Invalid URL');
582
- return {
583
- protocol: match[1],
584
- hostname: match[2],
585
- port: match[3] || '',
586
- pathname: match[4] || '/',
587
- search: match[5] || '',
588
- hash: match[6] || ''
589
- };
590
- },
591
- format: (obj) => obj.toString ? obj.toString() : String(obj),
592
- SearchParams: TitanURLSearchParams
593
- };
594
-
595
- // Create the main core export object (following titan-valid pattern)
596
- const core = {
597
- fs,
598
- path,
599
- crypto,
600
- os,
601
- net,
602
- proc,
603
- time,
604
- url,
605
- buffer, // t.core.buffer
606
- ls,
607
- session,
608
- cookies,
609
- response
610
- };
611
-
612
- t.fs = fs;
613
- t.path = path;
614
- t.crypto = crypto;
615
- t.os = os;
616
- t.net = net;
617
- t.proc = proc;
618
- t.time = time;
619
- t.url = url;
620
-
621
- // New Global Modules
622
- t.buffer = buffer;
623
- t.ls = ls;
624
- t.localStorage = ls;
625
- t.session = session;
626
- t.cookies = cookies;
627
- t.response = response;
628
-
629
- // Attach core as unified namespace (main access point)
630
- t.core = core;
631
-
632
- // Register as extension under multiple names for compatibility
633
- t["titan-core"] = core;
634
- t["@titanpl/core"] = core;
635
-
636
- // Also register in t.exts
637
- if (!t.exts) t.exts = {};
638
- t.exts["titan-core"] = core;
639
- t.exts["@titanpl/core"] = core;
@@ -1,12 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "module": "CommonJS",
5
- "allowSyntheticDefaultImports": true,
6
- "checkJs": false
7
- },
8
- "exclude": [
9
- "node_modules",
10
- "native"
11
- ]
12
- }
@@ -1,7 +0,0 @@
1
- {
2
- "src": ".",
3
- "ignore": "mkctx.config.json, pnpm-lock.yaml, **/.titan/, mkctx/, node_modules/, .git/, dist/, build/, target/, .next/, out/, .cache, package-lock.json, *.log, temp/, tmp/, coverage/, .nyc_output, .env, .env.local, .env.development.local, .env.test.local, .env.production.local, npm-debug.log*, yarn-debug.log*, yarn-error.log*, .npm, .yarn-integrity, .parcel-cache, .vuepress/dist, .svelte-kit, **/*.rs.bk, .idea/, .vscode/, .DS_Store, Thumbs.db, *.swp, *.swo, .~lock.*, Cargo.lock, .cargo/registry/, .cargo/git/, .rustup/, *.pdb, *.dSYM/, *.so, *.dll, *.dylib, *.exe, *.lib, *.a, *.o, *.rlib, *.d, *.tmp, *.bak, *.orig, *.rej, *.pyc, *.pyo, *.class, *.jar, *.war, *.ear, *.zip, *.tar.gz, *.rar, *.7z, *.iso, *.img, *.dmg, *.pdf, *.doc, *.docx, *.xls, *.xlsx, *.ppt, *.pptx",
4
- "output": "./mkctx",
5
- "first_comment": "/* Project Context */",
6
- "last_comment": "/* End of Context */"
7
- }