titanpl 4.0.2 → 6.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.
@@ -19,28 +19,10 @@ RUN npm install -g @titanpl/cli
19
19
 
20
20
  RUN npm install --include=optional
21
21
 
22
- # ------------------------------------------------
23
- # Extract Titan Extensions (packages with titan.json)
24
- # ------------------------------------------------
25
- RUN mkdir -p /app/.ext && \
26
- find node_modules -mindepth 2 -maxdepth 3 -type f -name "titan.json" | while read file; do \
27
- pkg_dir=$(dirname "$file"); \
28
- pkg_name=$(basename "$pkg_dir"); \
29
- echo "Extracting Titan extension: $pkg_name"; \
30
- cp -a "$pkg_dir" "/app/.ext/$pkg_name"; \
31
- rm -rf "/app/.ext/$pkg_name/node_modules"; \
32
- done
33
-
34
- # ------------------------------------------------
35
- # Copy ANY installed Titan Engine (Architecture agnostic)
36
- # ------------------------------------------------
37
- RUN mkdir -p /app/.ext/@titanpl && \
38
- cp -r node_modules/@titanpl/engine-linux-* /app/.ext/@titanpl/
39
-
40
22
  COPY . .
41
23
 
42
- # Run the Titan build step
43
- RUN npx titan build
24
+ # Run the Titan release build step (generates a 'build' folder)
25
+ RUN npx titan build --release
44
26
 
45
27
 
46
28
  # ================================================================
@@ -57,30 +39,13 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
57
39
  ca-certificates curl \
58
40
  && rm -rf /var/lib/apt/lists/*
59
41
 
60
- # copy dist contents into /app/dist
61
- COPY --from=builder /app/dist/ ./dist/
62
-
63
- # titan extensions + engine
64
- COPY --from=builder /app/.ext ./.ext
65
-
66
- # runtime assets
67
- COPY --from=builder /app/package.json ./package.json
68
-
69
- # ---------------- OPTIONAL APP FOLDERS ----------------
70
- # Static assets
71
- # COPY --from=builder /app/app/static ./static
72
-
73
- # Public assets
74
- # COPY --from=builder /app/app/public ./public
75
-
76
- # DB
77
- # COPY --from=builder /app/app/db ./db
42
+ # Copy EVERYTHING from the generated build folder into Stage 2
43
+ # This includes dist/, .ext/, package.json, .env, and the titan-server binary
44
+ COPY --from=builder /app/build/ ./
78
45
 
79
46
  # CRITICAL SYSTEM SETUP:
80
- # 1. Mandatory .env file (Engine requires it for config parsing)
81
- # 2. Node modules symlink for extension JS dependency resolution
82
- RUN echo "TITAN_DEV=0" > .env && \
83
- ln -s /app/.ext /app/node_modules && \
47
+ # Ensure the worker threads can find the extensions through the symlink
48
+ RUN ln -s /app/.ext /app/node_modules && \
84
49
  chown -R titan:titan /app
85
50
 
86
51
  # Standard environment variables
@@ -95,6 +60,5 @@ EXPOSE 5100
95
60
  HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
96
61
  CMD curl -f http://localhost:5100/ || exit 1
97
62
 
98
- # DYNAMIC ENTRYPOINT: Finds the correct architecture binary and starts it
99
- # This allows the SAME image to work on x64 vs ARM64 servers.
100
- CMD ["/bin/sh", "-c", "exec $(find .ext/@titanpl/engine-linux-* -name titan-server -type f | head -n 1) run dist"]
63
+ # DYNAMIC ENTRYPOINT: Use the portable binary in the root of /app
64
+ CMD ["./titan-server", "start"]
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "{{name}}",
3
- "version": "2.0.4",
3
+ "version": "6.0.0",
4
4
  "description": "A Titan Planet extension",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -18,7 +18,7 @@
18
18
  "@titanpl/core": "latest",
19
19
  "chokidar": "^5.0.0",
20
20
  "esbuild": "^0.27.2",
21
- "titanpl-sdk": "2.0.4"
21
+ "titanpl-sdk": "6.0.0"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@tgrv/microgravity": "latest"
@@ -6,16 +6,16 @@
6
6
  "template": "js"
7
7
  },
8
8
  "dependencies": {
9
- "@titanpl/cli": "2.0.4",
10
- "@titanpl/route": "2.0.4",
11
- "@titanpl/native": "2.0.4",
9
+ "@titanpl/cli": "6.0.0",
10
+ "@titanpl/route": "6.0.0",
11
+ "@titanpl/native": "6.0.0",
12
12
  "@titanpl/core": "latest",
13
13
  "@titanpl/node": "latest",
14
- "@titanpl/packet": "2.0.4"
14
+ "@titanpl/packet": "6.0.0"
15
15
  },
16
16
  "optionalDependencies": {
17
- "@titanpl/engine-linux-x64": "2.0.5",
18
- "@titanpl/engine-win32-x64": "2.0.3"
17
+ "@titanpl/engine-linux-x64": "6.0.0",
18
+ "@titanpl/engine-win32-x64": "6.0.0"
19
19
  },
20
20
  "scripts": {
21
21
  "build": "titan build",
@@ -28,5 +28,5 @@
28
28
  "eslint": "^9.39.2",
29
29
  "eslint-plugin-titanpl": "latest"
30
30
  },
31
- "version": "2.0.4"
32
- }
31
+ "version": "6.0.0"
32
+ }
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "titanpl",
3
- "version": "2.0.4",
3
+ "version": "6.0.0",
4
4
  "description": "A Titan Planet server",
5
5
  "type": "module",
6
6
  "titan": {
7
7
  "template": "rust-js"
8
8
  },
9
9
  "dependencies": {
10
- "@titanpl/cli": "2.0.4",
11
- "@titanpl/route": "2.0.4",
12
- "@titanpl/native": "2.0.4",
10
+ "@titanpl/cli": "6.0.0",
11
+ "@titanpl/route": "6.0.0",
12
+ "@titanpl/native": "6.0.0",
13
13
  "@titanpl/core": "latest",
14
14
  "@titanpl/node": "latest"
15
15
  },
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "titanpl",
3
- "version": "2.0.4",
3
+ "version": "6.0.0",
4
4
  "description": "A Titan Planet server (Rust + TypeScript)",
5
5
  "type": "module",
6
6
  "titan": {
7
7
  "template": "rust-ts"
8
8
  },
9
9
  "dependencies": {
10
- "@titanpl/cli": "2.0.4",
11
- "@titanpl/route": "2.0.4",
12
- "@titanpl/native": "2.0.4",
10
+ "@titanpl/cli": "6.0.0",
11
+ "@titanpl/route": "6.0.0",
12
+ "@titanpl/native": "6.0.0",
13
13
  "@titanpl/core": "latest",
14
14
  "@titanpl/node": "latest",
15
15
  "typescript": "^5.0.0"
@@ -6,18 +6,18 @@
6
6
  "template": "ts"
7
7
  },
8
8
  "dependencies": {
9
- "@titanpl/cli": "2.0.4",
10
- "@titanpl/route": "2.0.4",
11
- "@titanpl/native": "2.0.4",
9
+ "@titanpl/cli": "6.0.0",
10
+ "@titanpl/route": "6.0.0",
11
+ "@titanpl/native": "6.0.0",
12
12
  "@titanpl/core": "latest",
13
13
  "@titanpl/node": "latest",
14
- "@titanpl/packet": "2.0.4",
14
+ "@titanpl/packet": "6.0.0",
15
15
  "typescript": "^5.0.0"
16
16
  },
17
17
  "optionalDependencies": {
18
18
  "@titanpl/engine-linux-arm64": "2.0.5",
19
- "@titanpl/engine-linux-x64": "2.0.5",
20
- "@titanpl/engine-win32-x64": "2.0.3"
19
+ "@titanpl/engine-linux-x64": "6.0.0",
20
+ "@titanpl/engine-win32-x64": "6.0.0"
21
21
  },
22
22
  "scripts": {
23
23
  "build": "titan build",
@@ -31,5 +31,5 @@
31
31
  "eslint-plugin-titanpl": "latest",
32
32
  "@typescript-eslint/parser": "^8.54.0"
33
33
  },
34
- "version": "2.0.4"
35
- }
34
+ "version": "6.0.0"
35
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "titanpl-sdk",
3
- "version": "2.0.4",
3
+ "version": "6.0.0",
4
4
  "description": "Development SDK for Titan Planet. Provides TypeScript type definitions for the global 't' runtime object and a 'lite' test-harness runtime for building and verifying extensions.",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -360,7 +360,9 @@ fn native_log(scope: &mut v8::HandleScope, args: v8::FunctionCallbackArguments,
360
360
 
361
361
  fn native_jwt_sign(scope: &mut v8::HandleScope, args: v8::FunctionCallbackArguments, mut retval: v8::ReturnValue) {
362
362
  let payload_val = args.get(0);
363
- let json_str = v8::json::stringify(scope, payload_val).unwrap().to_rust_string_lossy(scope);
363
+ let json_str = v8::json::stringify(scope, payload_val)
364
+ .map(|s| s.to_rust_string_lossy(scope))
365
+ .unwrap_or_else(|| "{}".to_string());
364
366
  let mut payload: serde_json::Map<String, Value> = serde_json::from_str(&json_str).unwrap_or_default();
365
367
  let secret = v8_to_string(scope, args.get(1));
366
368
 
@@ -475,7 +477,10 @@ fn native_db_connect(scope: &mut v8::HandleScope, args: v8::FunctionCallbackArgu
475
477
  let cfg: Config = match conn_string.parse() {
476
478
  Ok(c) => c,
477
479
  Err(e) => {
478
- throw(scope, &format!("t.db.connect(): Invalid connection string: {}", e));
480
+ let msg = format!("t.db.connect(): Invalid connection string: {}", e);
481
+ let message = v8::String::new(scope, &msg).unwrap_or_else(|| v8::String::new(scope, "Error").unwrap());
482
+ let exception = v8::Exception::error(scope, message);
483
+ scope.throw_exception(exception);
479
484
  return;
480
485
  }
481
486
  };
@@ -96,7 +96,7 @@ async fn handler(State(state): State<AppState>, req: Request<Body>) -> impl Into
96
96
  "Server-Timing",
97
97
  format!("reply;dur={:.2}", elapsed.as_secs_f64() * 1000.0)
98
98
  .parse()
99
- .unwrap(),
99
+ .unwrap_or_else(|_| axum::http::HeaderValue::from_static("")),
100
100
  );
101
101
 
102
102
  if log_enabled {
@@ -140,7 +140,7 @@ async fn handler(State(state): State<AppState>, req: Request<Body>) -> impl Into
140
140
  "Server-Timing",
141
141
  format!("fastpath;dur={:.2}", elapsed.as_secs_f64() * 1000.0)
142
142
  .parse()
143
- .unwrap(),
143
+ .unwrap_or_else(|_| axum::http::HeaderValue::from_static("")),
144
144
  );
145
145
 
146
146
  if log_enabled {
@@ -409,7 +409,7 @@ async fn handler(State(state): State<AppState>, req: Request<Body>) -> impl Into
409
409
  .join(", ");
410
410
  response
411
411
  .headers_mut()
412
- .insert("Server-Timing", server_timing.parse().unwrap());
412
+ .insert("Server-Timing", server_timing.parse().unwrap_or_else(|_| axum::http::HeaderValue::from_static("")));
413
413
  }
414
414
 
415
415
  // Logging