titanpl 4.0.2 → 7.0.0-beta

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 (70) hide show
  1. package/package.json +11 -5
  2. package/packages/cli/index.js +25 -11
  3. package/packages/cli/package.json +5 -5
  4. package/packages/cli/src/commands/build-ext.js +157 -0
  5. package/packages/cli/src/commands/build.js +12 -0
  6. package/packages/cli/src/commands/create.js +160 -0
  7. package/packages/cli/src/commands/init.js +5 -11
  8. package/packages/cli/src/commands/run-ext.js +104 -0
  9. package/packages/engine-darwin-arm64/README.md +0 -2
  10. package/packages/engine-darwin-arm64/package.json +1 -1
  11. package/packages/engine-linux-x64/README.md +0 -2
  12. package/packages/engine-linux-x64/package.json +1 -1
  13. package/packages/engine-win32-x64/README.md +0 -1
  14. package/packages/engine-win32-x64/bin/titan-server.exe +0 -0
  15. package/packages/engine-win32-x64/package.json +1 -1
  16. package/packages/native/README.md +0 -1
  17. package/packages/native/index.d.ts +10 -0
  18. package/packages/native/index.js +4 -0
  19. package/packages/native/package.json +1 -1
  20. package/packages/native/t.native.d.ts +175 -44
  21. package/packages/packet/README.md +0 -1
  22. package/packages/packet/index.js +19 -2
  23. package/packages/packet/package.json +1 -1
  24. package/packages/route/README.md +21 -0
  25. package/packages/route/index.d.ts +1 -0
  26. package/packages/route/index.js +22 -0
  27. package/packages/route/package.json +1 -1
  28. package/packages/sdk/index.js +2 -0
  29. package/packages/sdk/package.json +18 -0
  30. package/packages/sdk/test/index.js +120 -0
  31. package/templates/common/Dockerfile +9 -45
  32. package/templates/common/_tanfig.json +17 -13
  33. package/templates/extension/index.d.ts +26 -22
  34. package/templates/extension/index.js +15 -15
  35. package/templates/extension/native/Cargo.toml +5 -3
  36. package/templates/extension/native/src/lib.rs +2 -3
  37. package/templates/extension/package.json +10 -20
  38. package/templates/extension/titan.json +5 -16
  39. package/templates/extension/utils/registerExtension.js +44 -0
  40. package/templates/js/package.json +8 -8
  41. package/templates/rust-js/package.json +4 -4
  42. package/templates/rust-ts/package.json +4 -4
  43. package/templates/ts/package.json +8 -8
  44. package/templates/common/app/t.native.d.ts +0 -2043
  45. package/templates/common/app/t.native.js +0 -39
  46. package/titanpl-sdk/LICENSE +0 -15
  47. package/titanpl-sdk/README.md +0 -111
  48. package/titanpl-sdk/assets/titanpl-sdk.png +0 -0
  49. package/titanpl-sdk/bin/run.js +0 -274
  50. package/titanpl-sdk/index.js +0 -5
  51. package/titanpl-sdk/package-lock.json +0 -28
  52. package/titanpl-sdk/package.json +0 -40
  53. package/titanpl-sdk/templates/app/actions/hello.js +0 -5
  54. package/titanpl-sdk/templates/app/app.js +0 -7
  55. package/titanpl-sdk/templates/jsconfig.json +0 -19
  56. package/titanpl-sdk/templates/server/Cargo.toml +0 -52
  57. package/titanpl-sdk/templates/server/src/action_management.rs +0 -175
  58. package/titanpl-sdk/templates/server/src/errors.rs +0 -12
  59. package/titanpl-sdk/templates/server/src/extensions/builtin.rs +0 -1055
  60. package/titanpl-sdk/templates/server/src/extensions/external.rs +0 -338
  61. package/titanpl-sdk/templates/server/src/extensions/mod.rs +0 -580
  62. package/titanpl-sdk/templates/server/src/extensions/titan_core.js +0 -249
  63. package/titanpl-sdk/templates/server/src/fast_path.rs +0 -719
  64. package/titanpl-sdk/templates/server/src/main.rs +0 -607
  65. package/titanpl-sdk/templates/server/src/runtime.rs +0 -284
  66. package/titanpl-sdk/templates/server/src/utils.rs +0 -33
  67. package/titanpl-sdk/templates/titan/bundle.js +0 -259
  68. package/titanpl-sdk/templates/titan/dev.js +0 -390
  69. package/titanpl-sdk/templates/titan/error-box.js +0 -277
  70. package/titanpl-sdk/templates/titan/titan.js +0 -129
@@ -1,129 +0,0 @@
1
- /**
2
- * Titan.js
3
- * Main Titan runtime builder
4
- * RULE: This file does NOT handle esbuild errors - bundle.js handles those
5
- */
6
-
7
- import fs from "fs";
8
- import path from "path";
9
- import { bundle } from "./bundle.js";
10
-
11
- const cyan = (t) => `\x1b[36m${t}\x1b[0m`;
12
- const green = (t) => `\x1b[32m${t}\x1b[0m`;
13
-
14
- const routes = {};
15
- const dynamicRoutes = {};
16
- const actionMap = {};
17
-
18
- function addRoute(method, route) {
19
- const key = `${method.toUpperCase()}:${route}`;
20
-
21
- return {
22
- reply(value) {
23
- routes[key] = {
24
- type: typeof value === "object" ? "json" : "text",
25
- value
26
- };
27
- },
28
-
29
- action(name) {
30
- if (route.includes(":")) {
31
- if (!dynamicRoutes[method]) dynamicRoutes[method] = [];
32
- dynamicRoutes[method].push({
33
- method: method.toUpperCase(),
34
- pattern: route,
35
- action: name
36
- });
37
- } else {
38
- routes[key] = {
39
- type: "action",
40
- value: name
41
- };
42
- actionMap[key] = name;
43
- }
44
- }
45
- };
46
- }
47
-
48
- /**
49
- * Titan App Builder
50
- */
51
- const t = {
52
- /**
53
- * Define a GET route
54
- */
55
- get(route) {
56
- return addRoute("GET", route);
57
- },
58
-
59
- /**
60
- * Define a POST route
61
- */
62
- post(route) {
63
- return addRoute("POST", route);
64
- },
65
-
66
- log(module, msg) {
67
- console.log(`[\x1b[35m${module}\x1b[0m] ${msg}`);
68
- },
69
-
70
- /**
71
- * Start the Titan Server
72
- * RULE: Only calls bundle() - does NOT handle esbuild errors
73
- * RULE: If bundle throws __TITAN_BUNDLE_FAILED__, stop immediately without printing
74
- */
75
- async start(port = 3000, msg = "", threads, stack_mb = 8) {
76
- try {
77
- console.log(cyan("[Titan] Preparing runtime..."));
78
-
79
- // RULE: Just call bundle() - it handles its own errors
80
- await bundle();
81
-
82
- const base = path.join(process.cwd(), "server");
83
- if (!fs.existsSync(base)) {
84
- fs.mkdirSync(base, { recursive: true });
85
- }
86
-
87
- const routesPath = path.join(base, "routes.json");
88
- const actionMapPath = path.join(base, "action_map.json");
89
-
90
- fs.writeFileSync(
91
- routesPath,
92
- JSON.stringify(
93
- {
94
- __config: { port, threads, stack_mb },
95
- routes,
96
- __dynamic_routes: Object.values(dynamicRoutes).flat()
97
- },
98
- null,
99
- 2
100
- )
101
- );
102
-
103
- fs.writeFileSync(
104
- actionMapPath,
105
- JSON.stringify(actionMap, null, 2)
106
- );
107
-
108
- console.log(green("✔ Titan metadata written successfully"));
109
- if (msg) console.log(cyan(msg));
110
-
111
- } catch (e) {
112
- // RULE: If bundle threw __TITAN_BUNDLE_FAILED__, just re-throw it
113
- // The error box was already printed by bundle.js
114
- if (e.message === '__TITAN_BUNDLE_FAILED__') {
115
- throw e;
116
- }
117
-
118
- // Other unexpected errors (not from bundle)
119
- console.error(`\x1b[31m[Titan] Unexpected error: ${e.message}\x1b[0m`);
120
- throw e;
121
- }
122
- }
123
- };
124
-
125
- /**
126
- * Titan App Builder (Alias for t)
127
- */
128
- export const Titan = t;
129
- export default t;