titanpl 2.0.1 → 2.0.3

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 (43) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/packages/cli/README.md +17 -17
  4. package/packages/cli/index.js +160 -160
  5. package/packages/cli/package.json +5 -5
  6. package/packages/cli/src/commands/build.js +5 -5
  7. package/packages/cli/src/commands/dev.js +12 -12
  8. package/packages/cli/src/commands/init.js +196 -174
  9. package/packages/cli/src/commands/migrate.js +124 -124
  10. package/packages/cli/src/commands/start.js +4 -4
  11. package/packages/cli/src/commands/update.js +90 -90
  12. package/packages/cli/src/engine.js +169 -152
  13. package/packages/engine-darwin-arm64/README.md +13 -13
  14. package/packages/engine-darwin-arm64/package.json +1 -1
  15. package/packages/engine-linux-x64/README.md +11 -11
  16. package/packages/engine-linux-x64/package.json +1 -1
  17. package/packages/engine-win32-x64/README.md +11 -11
  18. package/packages/engine-win32-x64/package.json +1 -1
  19. package/packages/native/README.md +11 -11
  20. package/packages/native/index.d.ts +41 -41
  21. package/packages/native/index.js +39 -39
  22. package/packages/native/package.json +1 -1
  23. package/packages/packet/README.md +11 -11
  24. package/packages/packet/index.js +83 -83
  25. package/packages/packet/js/titan/builder.js +50 -50
  26. package/packages/packet/js/titan/bundle.js +164 -164
  27. package/packages/packet/js/titan/dev.js +53 -19
  28. package/packages/packet/js/titan/error-box.js +277 -277
  29. package/packages/packet/package.json +1 -1
  30. package/packages/packet/ts/titan/bundle.js +227 -227
  31. package/packages/packet/ts/titan/dev.js +53 -20
  32. package/packages/packet/ts/titan/error-box.js +277 -277
  33. package/packages/route/README.md +24 -24
  34. package/packages/route/index.d.ts +16 -16
  35. package/packages/route/index.js +52 -52
  36. package/packages/route/package.json +1 -1
  37. package/templates/common/_gitignore +1 -1
  38. package/templates/extension/package.json +2 -2
  39. package/templates/js/package.json +5 -5
  40. package/templates/rust-js/package.json +4 -4
  41. package/templates/rust-ts/package.json +4 -4
  42. package/templates/ts/package.json +5 -5
  43. package/titanpl-sdk/package.json +1 -1
@@ -1,41 +1,41 @@
1
- export interface Request {
2
- method: string;
3
- path: string;
4
- headers: Record<string, string>;
5
- params: Record<string, any>;
6
- query: Record<string, any>;
7
- body: any;
8
- }
9
-
10
- export interface FileSystem {
11
- readFile(path: string, options?: any, callback?: (err: any, data: string) => void): string;
12
- writeFile(path: string, data: string): void;
13
- exists(path: string): boolean;
14
- readdir(path: string): string[];
15
- mkdir(path: string): void;
16
- stat(path: string): any;
17
- }
18
-
19
- export const fs: FileSystem;
20
- export function log(message: any): void;
21
- export function defineAction<T = any>(handler: (req: Request) => T | Promise<T>): (req: Request) => T | Promise<T>;
22
- export function fetch(url: string, options?: any): any;
23
- export function drift<T>(op: any): T;
24
-
25
- // Add more as needed based on native/index.js
26
- export const db: any;
27
- export const path: any;
28
- export const jwt: any;
29
- export const password: any;
30
- export const crypto: any;
31
- export const buffer: any;
32
- export const ls: any;
33
- export const session: any;
34
- export const cookies: any;
35
- export const os: any;
36
- export const net: any;
37
- export const proc: any;
38
- export const time: any;
39
- export const url: any;
40
- export const response: any;
41
- export const valid: any;
1
+ export interface Request {
2
+ method: string;
3
+ path: string;
4
+ headers: Record<string, string>;
5
+ params: Record<string, any>;
6
+ query: Record<string, any>;
7
+ body: any;
8
+ }
9
+
10
+ export interface FileSystem {
11
+ readFile(path: string, options?: any, callback?: (err: any, data: string) => void): string;
12
+ writeFile(path: string, data: string): void;
13
+ exists(path: string): boolean;
14
+ readdir(path: string): string[];
15
+ mkdir(path: string): void;
16
+ stat(path: string): any;
17
+ }
18
+
19
+ export const fs: FileSystem;
20
+ export function log(message: any): void;
21
+ export function defineAction<T = any>(handler: (req: Request) => T | Promise<T>): (req: Request) => T | Promise<T>;
22
+ export function fetch(url: string, options?: any): any;
23
+ export function drift<T>(op: any): T;
24
+
25
+ // Add more as needed based on native/index.js
26
+ export const db: any;
27
+ export const path: any;
28
+ export const jwt: any;
29
+ export const password: any;
30
+ export const crypto: any;
31
+ export const buffer: any;
32
+ export const ls: any;
33
+ export const session: any;
34
+ export const cookies: any;
35
+ export const os: any;
36
+ export const net: any;
37
+ export const proc: any;
38
+ export const time: any;
39
+ export const url: any;
40
+ export const response: any;
41
+ export const valid: any;
@@ -1,39 +1,39 @@
1
- // titan.js - Named exports for users who prefer imports over the global `t`
2
-
3
- export const fetch = t.fetch;
4
- export const log = t.log;
5
- export const read = t.read;
6
-
7
- // Authentication & Security
8
- export const jwt = t.jwt;
9
- export const password = t.password;
10
-
11
- // Database
12
- export const db = t.db;
13
-
14
- // File System & Path
15
- export const fs = t.fs;
16
- export const path = t.path;
17
-
18
- // Crypto & Buffer
19
- export const crypto = t.crypto;
20
- export const buffer = t.buffer;
21
-
22
- // Storage & Sessions
23
- export const ls = t.ls;
24
- export const localStorage = t.localStorage;
25
- export const session = t.session;
26
- export const cookies = t.cookies;
27
-
28
- // System
29
- export const os = t.os;
30
- export const net = t.net;
31
- export const proc = t.proc;
32
-
33
- // Utilities
34
- export const time = t.time;
35
- export const url = t.url;
36
- export const response = t.response;
37
- export const valid = t.valid;
38
-
39
- export const defineAction = (handler) => handler;
1
+ // titan.js - Named exports for users who prefer imports over the global `t`
2
+
3
+ export const fetch = t.fetch;
4
+ export const log = t.log;
5
+ export const read = t.read;
6
+
7
+ // Authentication & Security
8
+ export const jwt = t.jwt;
9
+ export const password = t.password;
10
+
11
+ // Database
12
+ export const db = t.db;
13
+
14
+ // File System & Path
15
+ export const fs = t.fs;
16
+ export const path = t.path;
17
+
18
+ // Crypto & Buffer
19
+ export const crypto = t.crypto;
20
+ export const buffer = t.buffer;
21
+
22
+ // Storage & Sessions
23
+ export const ls = t.ls;
24
+ export const localStorage = t.localStorage;
25
+ export const session = t.session;
26
+ export const cookies = t.cookies;
27
+
28
+ // System
29
+ export const os = t.os;
30
+ export const net = t.net;
31
+ export const proc = t.proc;
32
+
33
+ // Utilities
34
+ export const time = t.time;
35
+ export const url = t.url;
36
+ export const response = t.response;
37
+ export const valid = t.valid;
38
+
39
+ export const defineAction = (handler) => handler;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@titanpl/native",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "Titan native utilities package",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -1,11 +1,11 @@
1
- # @titanpl/packet
2
-
3
- The internal bundler and module packer for Titan Planet.
4
-
5
- ## What it works (What it does)
6
- This library parses all your app routes, components, middleware, and logic paths, then packages them into a static `build` output layer consisting of metadata files and JavaScript assets.
7
-
8
- ## How it works
9
- This package is triggered whenever you run `titan init` or `titan build` from the `@titanpl/cli`. It hooks into tools like `esbuild` to optimize your scripts efficiently. It strips unnecessary pieces out so that only explicit route actions make their way aggressively over to the Titan runtime engine.
10
-
11
- **Important Note:** Currently, Titan Planet and its entire package ecosystem are only for Windows. The Linux version is in development (dev only) for the new architecture and will be launched later.
1
+ # @titanpl/packet
2
+
3
+ The internal bundler and module packer for Titan Planet.
4
+
5
+ ## What it works (What it does)
6
+ This library parses all your app routes, components, middleware, and logic paths, then packages them into a static `build` output layer consisting of metadata files and JavaScript assets.
7
+
8
+ ## How it works
9
+ This package is triggered whenever you run `titan init` or `titan build` from the `@titanpl/cli`. It hooks into tools like `esbuild` to optimize your scripts efficiently. It strips unnecessary pieces out so that only explicit route actions make their way aggressively over to the Titan runtime engine.
10
+
11
+ **Important Note:** Currently, Titan Planet and its entire package ecosystem are only for Windows. The Linux version is in development (dev only) for the new architecture and will be launched later.
@@ -1,84 +1,84 @@
1
- import path from "path";
2
- import fs from "fs";
3
-
4
- /**
5
- * Get project type (js or ts)
6
- */
7
- function getProjectType(root) {
8
- try {
9
- const pkg = JSON.parse(fs.readFileSync(path.join(root, "package.json"), "utf8"));
10
- if (pkg.titan && pkg.titan.template && pkg.titan.template.includes("ts")) return "ts";
11
- } catch (e) { }
12
-
13
- if (fs.existsSync(path.join(root, "tsconfig.json"))) return "ts";
14
- return "js";
15
- }
16
-
17
- /**
18
- * Ensure dist directory exists
19
- */
20
- function ensureDist(root) {
21
- const dist = path.join(root, "dist");
22
- const actions = path.join(dist, "actions");
23
-
24
- if (!fs.existsSync(dist)) {
25
- fs.mkdirSync(dist, { recursive: true });
26
- }
27
-
28
- if (!fs.existsSync(actions)) {
29
- fs.mkdirSync(actions, { recursive: true });
30
- }
31
-
32
- return dist;
33
- }
34
-
35
- /**
36
- * Production build
37
- */
38
- export async function build(root = process.cwd()) {
39
- const type = getProjectType(root);
40
- const { bundle: bundleActions } = await import(`./${type}/titan/bundle.js`);
41
- const { buildMetadata } = await import(`./${type}/titan/builder.js`);
42
-
43
- const dist = ensureDist(root);
44
-
45
- await buildMetadata(root, dist);
46
- await bundleActions({
47
- root,
48
- outDir: dist,
49
- });
50
-
51
- return dist;
52
- }
53
-
54
- /**
55
- * Dev mode build
56
- */
57
- export async function dev(options = {}) {
58
- const root = typeof options === 'string' ? options : (options.root || process.cwd());
59
- const type = getProjectType(root);
60
- const { dev: devServer } = await import(`./${type}/titan/dev.js`);
61
-
62
- const dist = ensureDist(root);
63
-
64
- await devServer({
65
- root,
66
- outDir: dist,
67
- onRebuild: options.onRebuild
68
- });
69
-
70
- return dist;
71
- }
72
-
73
- /**
74
- * Direct export of current project tools
75
- */
76
- export async function getTools(root = process.cwd()) {
77
- const type = getProjectType(root);
78
- const bundleModule = await import(`./${type}/titan/bundle.js`);
79
- const builderModule = await import(`./${type}/titan/builder.js`);
80
- return {
81
- bundleActions: bundleModule.bundle,
82
- buildMetadata: builderModule.buildMetadata
83
- };
1
+ import path from "path";
2
+ import fs from "fs";
3
+
4
+ /**
5
+ * Get project type (js or ts)
6
+ */
7
+ function getProjectType(root) {
8
+ try {
9
+ const pkg = JSON.parse(fs.readFileSync(path.join(root, "package.json"), "utf8"));
10
+ if (pkg.titan && pkg.titan.template && pkg.titan.template.includes("ts")) return "ts";
11
+ } catch (e) { }
12
+
13
+ if (fs.existsSync(path.join(root, "tsconfig.json"))) return "ts";
14
+ return "js";
15
+ }
16
+
17
+ /**
18
+ * Ensure dist directory exists
19
+ */
20
+ function ensureDist(root) {
21
+ const dist = path.join(root, "dist");
22
+ const actions = path.join(dist, "actions");
23
+
24
+ if (!fs.existsSync(dist)) {
25
+ fs.mkdirSync(dist, { recursive: true });
26
+ }
27
+
28
+ if (!fs.existsSync(actions)) {
29
+ fs.mkdirSync(actions, { recursive: true });
30
+ }
31
+
32
+ return dist;
33
+ }
34
+
35
+ /**
36
+ * Production build
37
+ */
38
+ export async function build(root = process.cwd()) {
39
+ const type = getProjectType(root);
40
+ const { bundle: bundleActions } = await import(`./${type}/titan/bundle.js`);
41
+ const { buildMetadata } = await import(`./${type}/titan/builder.js`);
42
+
43
+ const dist = ensureDist(root);
44
+
45
+ await buildMetadata(root, dist);
46
+ await bundleActions({
47
+ root,
48
+ outDir: dist,
49
+ });
50
+
51
+ return dist;
52
+ }
53
+
54
+ /**
55
+ * Dev mode build
56
+ */
57
+ export async function dev(options = {}) {
58
+ const root = typeof options === 'string' ? options : (options.root || process.cwd());
59
+ const type = getProjectType(root);
60
+ const { dev: devServer } = await import(`./${type}/titan/dev.js`);
61
+
62
+ const dist = ensureDist(root);
63
+
64
+ await devServer({
65
+ root,
66
+ outDir: dist,
67
+ onRebuild: options.onRebuild
68
+ });
69
+
70
+ return dist;
71
+ }
72
+
73
+ /**
74
+ * Direct export of current project tools
75
+ */
76
+ export async function getTools(root = process.cwd()) {
77
+ const type = getProjectType(root);
78
+ const bundleModule = await import(`./${type}/titan/bundle.js`);
79
+ const builderModule = await import(`./${type}/titan/builder.js`);
80
+ return {
81
+ bundleActions: bundleModule.bundle,
82
+ buildMetadata: builderModule.buildMetadata
83
+ };
84
84
  }
@@ -1,50 +1,50 @@
1
- import fs from "fs";
2
- import path from "path";
3
- import { pathToFileURL } from "url";
4
-
5
- export async function buildMetadata(root, dist) {
6
- const appDir = path.join(root, "app");
7
- const appFile = "app.js";
8
- const appPath = path.join(appDir, appFile);
9
-
10
- if (!fs.existsSync(appPath)) {
11
- console.error(`\x1b[31m❌ app/${appFile} not found.\x1b[0m`);
12
- process.exit(1);
13
- }
14
-
15
- try {
16
- const appUrl = pathToFileURL(appPath).href;
17
- const cacheBuster = `?t=${Date.now()}`;
18
- await import(appUrl + cacheBuster);
19
-
20
- const config = globalThis.__TITAN_CONFIG__ || { port: 3000, threads: 4, stack_mb: 8 };
21
- const routes = globalThis.__TITAN_ROUTES_MAP__ || {};
22
- const dynamicRoutes = globalThis.__TITAN_DYNAMIC_ROUTES__ || {};
23
- const actionMap = globalThis.__TITAN_ACTION_MAP__ || {};
24
-
25
- const routesPath = path.join(dist, "routes.json");
26
- const actionMapPath = path.join(dist, "action_map.json");
27
-
28
- fs.writeFileSync(
29
- routesPath,
30
- JSON.stringify(
31
- {
32
- __config: config,
33
- routes,
34
- __dynamic_routes: Object.values(dynamicRoutes).flat()
35
- },
36
- null,
37
- 2
38
- )
39
- );
40
-
41
- fs.writeFileSync(
42
- actionMapPath,
43
- JSON.stringify(actionMap, null, 2)
44
- );
45
-
46
- } catch (err) {
47
- console.error("\x1b[31m❌ Failed to parse routes from app.js\x1b[0m", err);
48
- process.exit(1);
49
- }
50
- }
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { pathToFileURL } from "url";
4
+
5
+ export async function buildMetadata(root, dist) {
6
+ const appDir = path.join(root, "app");
7
+ const appFile = "app.js";
8
+ const appPath = path.join(appDir, appFile);
9
+
10
+ if (!fs.existsSync(appPath)) {
11
+ console.error(`\x1b[31m❌ app/${appFile} not found.\x1b[0m`);
12
+ process.exit(1);
13
+ }
14
+
15
+ try {
16
+ const appUrl = pathToFileURL(appPath).href;
17
+ const cacheBuster = `?t=${Date.now()}`;
18
+ await import(appUrl + cacheBuster);
19
+
20
+ const config = globalThis.__TITAN_CONFIG__ || { port: 3000, threads: 4, stack_mb: 8 };
21
+ const routes = globalThis.__TITAN_ROUTES_MAP__ || {};
22
+ const dynamicRoutes = globalThis.__TITAN_DYNAMIC_ROUTES__ || {};
23
+ const actionMap = globalThis.__TITAN_ACTION_MAP__ || {};
24
+
25
+ const routesPath = path.join(dist, "routes.json");
26
+ const actionMapPath = path.join(dist, "action_map.json");
27
+
28
+ fs.writeFileSync(
29
+ routesPath,
30
+ JSON.stringify(
31
+ {
32
+ __config: config,
33
+ routes,
34
+ __dynamic_routes: Object.values(dynamicRoutes).flat()
35
+ },
36
+ null,
37
+ 2
38
+ )
39
+ );
40
+
41
+ fs.writeFileSync(
42
+ actionMapPath,
43
+ JSON.stringify(actionMap, null, 2)
44
+ );
45
+
46
+ } catch (err) {
47
+ console.error("\x1b[31m❌ Failed to parse routes from app.js\x1b[0m", err);
48
+ process.exit(1);
49
+ }
50
+ }