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.
- package/package.json +11 -5
- package/packages/cli/index.js +25 -11
- package/packages/cli/package.json +5 -5
- package/packages/cli/src/commands/build-ext.js +157 -0
- package/packages/cli/src/commands/build.js +12 -0
- package/packages/cli/src/commands/create.js +160 -0
- package/packages/cli/src/commands/init.js +5 -11
- package/packages/cli/src/commands/run-ext.js +104 -0
- package/packages/engine-darwin-arm64/README.md +0 -2
- package/packages/engine-darwin-arm64/package.json +1 -1
- package/packages/engine-linux-x64/README.md +0 -2
- package/packages/engine-linux-x64/package.json +1 -1
- package/packages/engine-win32-x64/README.md +0 -1
- package/packages/engine-win32-x64/bin/titan-server.exe +0 -0
- package/packages/engine-win32-x64/package.json +1 -1
- package/packages/native/README.md +0 -1
- package/packages/native/index.d.ts +10 -0
- package/packages/native/index.js +4 -0
- package/packages/native/package.json +1 -1
- package/packages/native/t.native.d.ts +175 -44
- package/packages/packet/README.md +0 -1
- package/packages/packet/index.js +19 -2
- package/packages/packet/package.json +1 -1
- package/packages/route/README.md +21 -0
- package/packages/route/index.d.ts +1 -0
- package/packages/route/index.js +22 -0
- package/packages/route/package.json +1 -1
- package/packages/sdk/index.js +2 -0
- package/packages/sdk/package.json +18 -0
- package/packages/sdk/test/index.js +120 -0
- package/templates/common/Dockerfile +9 -45
- package/templates/common/_tanfig.json +17 -13
- package/templates/extension/index.d.ts +26 -22
- package/templates/extension/index.js +15 -15
- package/templates/extension/native/Cargo.toml +5 -3
- package/templates/extension/native/src/lib.rs +2 -3
- package/templates/extension/package.json +10 -20
- package/templates/extension/titan.json +5 -16
- package/templates/extension/utils/registerExtension.js +44 -0
- package/templates/js/package.json +8 -8
- package/templates/rust-js/package.json +4 -4
- package/templates/rust-ts/package.json +4 -4
- package/templates/ts/package.json +8 -8
- package/templates/common/app/t.native.d.ts +0 -2043
- package/templates/common/app/t.native.js +0 -39
- package/titanpl-sdk/LICENSE +0 -15
- package/titanpl-sdk/README.md +0 -111
- package/titanpl-sdk/assets/titanpl-sdk.png +0 -0
- package/titanpl-sdk/bin/run.js +0 -274
- package/titanpl-sdk/index.js +0 -5
- package/titanpl-sdk/package-lock.json +0 -28
- package/titanpl-sdk/package.json +0 -40
- package/titanpl-sdk/templates/app/actions/hello.js +0 -5
- package/titanpl-sdk/templates/app/app.js +0 -7
- package/titanpl-sdk/templates/jsconfig.json +0 -19
- package/titanpl-sdk/templates/server/Cargo.toml +0 -52
- package/titanpl-sdk/templates/server/src/action_management.rs +0 -175
- package/titanpl-sdk/templates/server/src/errors.rs +0 -12
- package/titanpl-sdk/templates/server/src/extensions/builtin.rs +0 -1055
- package/titanpl-sdk/templates/server/src/extensions/external.rs +0 -338
- package/titanpl-sdk/templates/server/src/extensions/mod.rs +0 -580
- package/titanpl-sdk/templates/server/src/extensions/titan_core.js +0 -249
- package/titanpl-sdk/templates/server/src/fast_path.rs +0 -719
- package/titanpl-sdk/templates/server/src/main.rs +0 -607
- package/titanpl-sdk/templates/server/src/runtime.rs +0 -284
- package/titanpl-sdk/templates/server/src/utils.rs +0 -33
- package/titanpl-sdk/templates/titan/bundle.js +0 -259
- package/titanpl-sdk/templates/titan/dev.js +0 -390
- package/titanpl-sdk/templates/titan/error-box.js +0 -277
- package/titanpl-sdk/templates/titan/titan.js +0 -129
|
@@ -1,39 +0,0 @@
|
|
|
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;
|
package/titanpl-sdk/LICENSE
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
ISC License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025, Ezet Galaxy
|
|
4
|
-
|
|
5
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
-
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
-
copyright notice and this permission notice appear in all copies.
|
|
8
|
-
|
|
9
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
-
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
-
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
-
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
-
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
-
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
-
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/titanpl-sdk/README.md
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
<div align="center">
|
|
3
|
-
<img src="./assets/titanpl-sdk.png" alt="Titan SDK Logo" width="120" />
|
|
4
|
-
<h1>Titan SDK</h1>
|
|
5
|
-
<p>
|
|
6
|
-
<b>The Developer Toolkit for Titan Planet. Type safety, IntelliSense, and Extension Testing.</b>
|
|
7
|
-
</p>
|
|
8
|
-
</div>
|
|
9
|
-
|
|
10
|
-
<div align="center">
|
|
11
|
-
|
|
12
|
-
[](https://www.npmjs.com/package/titanpl-sdk)
|
|
13
|
-
[](https://opensource.org/licenses/ISC)
|
|
14
|
-
|
|
15
|
-
</div>
|
|
16
|
-
|
|
17
|
-
---
|
|
18
|
-
|
|
19
|
-
## 🌌 Overview
|
|
20
|
-
|
|
21
|
-
**Titan SDK** is NOT the runtime engine itself. It is a **development-only toolkit** designed to bridge the gap between your local coding environment and the native Titan Planet binary.
|
|
22
|
-
|
|
23
|
-
It provides the necessary **Type Definitions** to make your IDE understand the global `t` object and a **Lite Test Harness** to verify your extensions before they ever touch a production binary.
|
|
24
|
-
|
|
25
|
-
> **Note:** The actual implementation of `t.log`, `t.fetch`, and other APIs are embedded directly into the [Titan Planet Binary](https://github.com/ezet-galaxy/titanpl). This SDK simply provides the "blueprints" (types) and a "sandbox" (test runner).
|
|
26
|
-
|
|
27
|
-
**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.
|
|
28
|
-
|
|
29
|
-
---
|
|
30
|
-
|
|
31
|
-
## ✨ Features
|
|
32
|
-
|
|
33
|
-
- **💎 Blueprint Types (IntelliSense)**: Provides the full TypeScript `index.d.ts` for the global `t` object so you get autocomplete in VS Code and other editors.
|
|
34
|
-
- **🛡️ Static Validation**: Catch parameter mismatches and typos in `t.log`, `t.fetch`, `t.db`, etc., during development.
|
|
35
|
-
- **🔌 Extension Test Harness**: A "lite" version of the Titan runtime that simulates the native environment to test extensions in isolation.
|
|
36
|
-
- **🚀 Zero Production Trace**: This is a `devDependencies` package. It never ships with your binary, keeping your production footprint at literal zero.
|
|
37
|
-
|
|
38
|
-
---
|
|
39
|
-
|
|
40
|
-
## 🚀 The Test Harness (Lite Runtime)
|
|
41
|
-
|
|
42
|
-
The SDK includes a specialized **Test Runner** (`titan-sdk`). This is a "lite" version of the Titan ecosystem that acts as a bridge for developers.
|
|
43
|
-
|
|
44
|
-
### How it works:
|
|
45
|
-
When you run the SDK in an extension folder, it:
|
|
46
|
-
1. **Scaffolds a Virtual Project**: Creates a temporary, minimal Titan environment in `.titan_test_run`.
|
|
47
|
-
2. **Native Compilation**: Automatically builds your native Rust code (`native/`) if it exists.
|
|
48
|
-
3. **Hot-Linking**: Junctions your local extension into the virtual project's `node_modules`.
|
|
49
|
-
4. **Verification**: Generates a test suite that attempts to call your extension's methods via the real `t` object inside the sandbox.
|
|
50
|
-
|
|
51
|
-
### Usage:
|
|
52
|
-
|
|
53
|
-
```bash
|
|
54
|
-
# Inside your extension directory
|
|
55
|
-
npx titan-sdk
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
---
|
|
59
|
-
|
|
60
|
-
## ⌨️ Enabling IntelliSense
|
|
61
|
-
|
|
62
|
-
Since the `t` object is injected globally by the Titan engine at runtime, your IDE won't recognize it by default. The SDK fixes this.
|
|
63
|
-
|
|
64
|
-
1. **Install the SDK**:
|
|
65
|
-
```bash
|
|
66
|
-
npm install --save-dev titan-sdk
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
2. **Configure Types**:
|
|
70
|
-
Create or update `jsconfig.json` (or `tsconfig.json`) in your project root:
|
|
71
|
-
```json
|
|
72
|
-
{
|
|
73
|
-
"compilerOptions": {
|
|
74
|
-
"types": ["titan-sdk"]
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
Now your editor will treat `t` as a first-class citizen:
|
|
80
|
-
```ts
|
|
81
|
-
export const myAction = defineAction((req) => {
|
|
82
|
-
t.log("Request received", req.path); // Autocomplete works!
|
|
83
|
-
return { status: "ok" };
|
|
84
|
-
});
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
---
|
|
88
|
-
|
|
89
|
-
## 🧱 What's Included? (Types Only)
|
|
90
|
-
|
|
91
|
-
The SDK provides types for the native APIs provided by the Titan Planet engine:
|
|
92
|
-
|
|
93
|
-
- **`t.log`**: Standardized logging that appears in the Titan binary console.
|
|
94
|
-
- **`t.fetch`**: Types for the high-performance Rust-native network stack.
|
|
95
|
-
- **`t.db`**: Interface for the native PostgreSQL driver.
|
|
96
|
-
- **`t.read`**: Definitions for optimized filesystem reads.
|
|
97
|
-
- **`t.jwt` / `t.password`**: Security helper types.
|
|
98
|
-
|
|
99
|
-
---
|
|
100
|
-
|
|
101
|
-
## 🌍 Community & Documentation
|
|
102
|
-
|
|
103
|
-
- **Core Framework**: [Titan Planet](https://github.com/ezet-galaxy/titanpl)
|
|
104
|
-
- **Official Docs**: [Titan Planet Docs](https://titan-docs-ez.vercel.app/docs)
|
|
105
|
-
- **Author**: [ezetgalaxy](https://github.com/ezet-galaxy)
|
|
106
|
-
|
|
107
|
-
---
|
|
108
|
-
|
|
109
|
-
<p align="center">
|
|
110
|
-
Built with ❤️ for the <a href="https://titan-docs-ez.vercel.app/">Titan Planet</a> ecosystem.
|
|
111
|
-
</p>
|
|
Binary file
|
package/titanpl-sdk/bin/run.js
DELETED
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import { execSync } from "child_process";
|
|
5
|
-
import { fileURLToPath } from "url";
|
|
6
|
-
|
|
7
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
-
const __dirname = path.dirname(__filename);
|
|
9
|
-
|
|
10
|
-
// Helper for colors
|
|
11
|
-
const cyan = (t) => `\x1b[36m${t}\x1b[0m`;
|
|
12
|
-
const green = (t) => `\x1b[32m${t}\x1b[0m`;
|
|
13
|
-
const red = (t) => `\x1b[31m${t}\x1b[0m`;
|
|
14
|
-
const yellow = (t) => `\x1b[33m${t}\x1b[0m`;
|
|
15
|
-
|
|
16
|
-
function copyDir(src, dest, excludes = []) {
|
|
17
|
-
// console.log(`DEBUG: copyDir ${src} -> ${dest}`);
|
|
18
|
-
if (!fs.existsSync(src)) {
|
|
19
|
-
console.log(red(`Source does not exist: ${src}`));
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
fs.mkdirSync(dest, { recursive: true });
|
|
24
|
-
|
|
25
|
-
const files = fs.readdirSync(src);
|
|
26
|
-
// console.log(`DEBUG: Found ${files.length} files in ${src}`);
|
|
27
|
-
|
|
28
|
-
for (const file of files) {
|
|
29
|
-
if (excludes.includes(file)) {
|
|
30
|
-
// console.log(`DEBUG: Skipping excluded ${file}`);
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const srcPath = path.join(src, file);
|
|
35
|
-
const destPath = path.join(dest, file);
|
|
36
|
-
|
|
37
|
-
if (fs.lstatSync(srcPath).isDirectory()) {
|
|
38
|
-
copyDir(srcPath, destPath, excludes);
|
|
39
|
-
} else {
|
|
40
|
-
// console.log(`DEBUG: Copying file ${file}`);
|
|
41
|
-
try {
|
|
42
|
-
fs.copyFileSync(srcPath, destPath);
|
|
43
|
-
} catch (err) {
|
|
44
|
-
console.log(red(`ERROR: Failed to copy ${file}: ${err.message}`));
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function run() {
|
|
51
|
-
console.log(cyan("TitanPl SDK: Test Runner"));
|
|
52
|
-
|
|
53
|
-
// 1. Validate we are in an extension directory
|
|
54
|
-
const cwd = process.cwd();
|
|
55
|
-
console.log(cyan(`Current Working Directory: ${cwd}`));
|
|
56
|
-
|
|
57
|
-
const manifestPath = path.join(cwd, "titan.json");
|
|
58
|
-
if (!fs.existsSync(manifestPath)) {
|
|
59
|
-
console.log(red("Error: titan.json not found. Run this command inside your extension folder."));
|
|
60
|
-
process.exit(1);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
|
|
64
|
-
const name = manifest.name;
|
|
65
|
-
console.log(green(`Extension: ${name}`));
|
|
66
|
-
|
|
67
|
-
// 2. Build Native Logic (if properly set up)
|
|
68
|
-
const nativeDir = path.join(cwd, "native");
|
|
69
|
-
if (fs.existsSync(nativeDir) && fs.existsSync(path.join(nativeDir, "Cargo.toml"))) {
|
|
70
|
-
console.log(cyan("Building native Rust module..."));
|
|
71
|
-
try {
|
|
72
|
-
execSync("cargo build --release", { cwd: nativeDir, stdio: "inherit" });
|
|
73
|
-
} catch (e) {
|
|
74
|
-
console.log(red("Failed to build native module."));
|
|
75
|
-
process.exit(1);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// 3. Setup Test Harness (Mini Titan Project)
|
|
80
|
-
// 3. Setup Test Harness (Mini Titan Project)
|
|
81
|
-
const runDir = path.join(cwd, ".titan_test_run");
|
|
82
|
-
const appDir = path.join(runDir, "app");
|
|
83
|
-
const actionsDir = path.join(appDir, "actions");
|
|
84
|
-
const nmDir = path.join(runDir, "node_modules");
|
|
85
|
-
|
|
86
|
-
const isFirstRun = !fs.existsSync(runDir);
|
|
87
|
-
|
|
88
|
-
if (isFirstRun) {
|
|
89
|
-
console.log(cyan("Initializing test environment..."));
|
|
90
|
-
fs.mkdirSync(runDir, { recursive: true });
|
|
91
|
-
|
|
92
|
-
// Create app structure
|
|
93
|
-
fs.mkdirSync(appDir);
|
|
94
|
-
|
|
95
|
-
// Create actions folder (required by Titan build)
|
|
96
|
-
fs.mkdirSync(actionsDir);
|
|
97
|
-
|
|
98
|
-
// Copy titan/ and server/ from templates
|
|
99
|
-
const templatesDir = path.join(__dirname, "..", "templates");
|
|
100
|
-
console.log(cyan(`Templates Source: ${templatesDir}`));
|
|
101
|
-
|
|
102
|
-
const titanSrc = path.join(templatesDir, "titan");
|
|
103
|
-
const titanDest = path.join(runDir, "titan");
|
|
104
|
-
|
|
105
|
-
if (fs.existsSync(titanSrc)) {
|
|
106
|
-
copyDir(titanSrc, titanDest);
|
|
107
|
-
if (!fs.existsSync(path.join(titanDest, "titan.js"))) {
|
|
108
|
-
throw new Error("Failed to copy titan.js template");
|
|
109
|
-
}
|
|
110
|
-
} else {
|
|
111
|
-
console.log(red(`Error: Titan templates not found at ${titanSrc}`));
|
|
112
|
-
process.exit(1);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const serverSrc = path.join(templatesDir, "server");
|
|
116
|
-
const serverDest = path.join(runDir, "server");
|
|
117
|
-
if (fs.existsSync(serverSrc)) {
|
|
118
|
-
copyDir(serverSrc, serverDest);
|
|
119
|
-
} else {
|
|
120
|
-
console.log(red(`Error: Server templates not found at ${serverSrc}`));
|
|
121
|
-
process.exit(1);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// Create package.json for the test harness
|
|
125
|
-
const pkgJson = {
|
|
126
|
-
"type": "module",
|
|
127
|
-
"dependencies": {
|
|
128
|
-
// We can add dependencies here if needed
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
fs.writeFileSync(path.join(runDir, "package.json"), JSON.stringify(pkgJson, null, 2));
|
|
132
|
-
|
|
133
|
-
// Create 'node_modules'
|
|
134
|
-
// const nmDir = path.join(runDir, "node_modules"); // Already defined
|
|
135
|
-
fs.mkdirSync(nmDir);
|
|
136
|
-
} else {
|
|
137
|
-
console.log(cyan("Using existing test environment..."));
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// const nmDir = path.join(runDir, "node_modules"); // Already defined
|
|
141
|
-
if (!fs.existsSync(nmDir)) fs.mkdirSync(nmDir, { recursive: true });
|
|
142
|
-
|
|
143
|
-
// COPY Extension to node_modules/NAME (Force Copy to avoid Symlink Loops)
|
|
144
|
-
const extDest = path.join(nmDir, name);
|
|
145
|
-
console.log(cyan(`Copying extension to ${extDest}...`));
|
|
146
|
-
|
|
147
|
-
// Always exclude the test run folder itself + standard ignores
|
|
148
|
-
const excludes = ['.titan_test_run', 'node_modules', '.git', 'target', 'dist'];
|
|
149
|
-
copyDir(cwd, extDest, excludes);
|
|
150
|
-
|
|
151
|
-
// Create default test files ONLY if they don't exist
|
|
152
|
-
// const actionsDir = path.join(runDir, "app", "actions"); // Already defined
|
|
153
|
-
const testActionPath = path.join(actionsDir, "test.js");
|
|
154
|
-
|
|
155
|
-
if (!fs.existsSync(testActionPath)) {
|
|
156
|
-
const testAction = `export const test = (req) => {
|
|
157
|
-
const ext = t["${name}"];
|
|
158
|
-
|
|
159
|
-
const results = {
|
|
160
|
-
extension: "${name}",
|
|
161
|
-
loaded: !!ext,
|
|
162
|
-
methods: ext ? Object.keys(ext) : [],
|
|
163
|
-
timestamp: new Date().toISOString()
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
if (ext && ext.hello) {
|
|
167
|
-
try {
|
|
168
|
-
results.hello_test = ext.hello("World");
|
|
169
|
-
} catch(e) {
|
|
170
|
-
results.hello_error = String(e);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if (ext && ext.calc) {
|
|
175
|
-
try {
|
|
176
|
-
results.calc_test = ext.calc(15, 25);
|
|
177
|
-
} catch(e) {
|
|
178
|
-
results.calc_error = String(e);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
return results;
|
|
183
|
-
};
|
|
184
|
-
`;
|
|
185
|
-
fs.writeFileSync(testActionPath, testAction);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
const appJsPath = path.join(runDir, "app", "app.js");
|
|
189
|
-
if (!fs.existsSync(appJsPath)) {
|
|
190
|
-
const testScript = `import t from "../titan/titan.js";
|
|
191
|
-
|
|
192
|
-
// 1. Expose 't' globally because extensions expect it (like in the real runtime)
|
|
193
|
-
globalThis.t = t;
|
|
194
|
-
|
|
195
|
-
// 2. Dynamic import ensures 't' is set BEFORE the extension loads
|
|
196
|
-
await import("${name}");
|
|
197
|
-
|
|
198
|
-
// Extension test harness for: ${name}
|
|
199
|
-
const ext = t["${name}"];
|
|
200
|
-
|
|
201
|
-
t.log("---------------------------------------------------");
|
|
202
|
-
t.log("Testing Extension: ${name}");
|
|
203
|
-
t.log("---------------------------------------------------");
|
|
204
|
-
|
|
205
|
-
if (!ext) {
|
|
206
|
-
console.log("ERROR: Extension '${name}' not found in global 't'.");
|
|
207
|
-
} else {
|
|
208
|
-
t.log("✓ Extension loaded successfully!");
|
|
209
|
-
t.log("✓ Available methods:", Object.keys(ext).join(", "));
|
|
210
|
-
|
|
211
|
-
// Try 'hello' if it exists
|
|
212
|
-
if (typeof ext.hello === 'function') {
|
|
213
|
-
console.log("\\nTesting ext.hello('Titan')...");
|
|
214
|
-
try {
|
|
215
|
-
const res = ext.hello("Titan");
|
|
216
|
-
t.log("✓ Result:", res);
|
|
217
|
-
} catch(e) {
|
|
218
|
-
t.log("✗ Error:", e.message);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
// Try 'calc' if it exists
|
|
223
|
-
if (typeof ext.calc === 'function') {
|
|
224
|
-
console.log("\\nTesting ext.calc(10, 20)...");
|
|
225
|
-
try {
|
|
226
|
-
const res = ext.calc(10, 20);
|
|
227
|
-
t.log("✓ Result:", res);
|
|
228
|
-
} catch(e) {
|
|
229
|
-
t.log("✗ Error:", e.message);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
t.log("---------------------------------------------------");
|
|
235
|
-
t.log("✓ Test complete!");
|
|
236
|
-
t.log("\\n📍 Routes:");
|
|
237
|
-
t.log(" GET http://localhost:3000/ → Test harness info");
|
|
238
|
-
t.log(" GET http://localhost:3000/test → Extension test results (JSON)");
|
|
239
|
-
t.log("---------------------------------------------------\\n");
|
|
240
|
-
|
|
241
|
-
// Create routes
|
|
242
|
-
t.get("/test").action("test");
|
|
243
|
-
t.get("/").reply("🚀 Extension Test Harness for ${name}\\n\\nVisit /test to see extension test results");
|
|
244
|
-
|
|
245
|
-
await t.start(3000, "Titan Extension Test Running!", 10, 16);
|
|
246
|
-
`;
|
|
247
|
-
fs.writeFileSync(appJsPath, testScript);
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
// Build the app (bundle actions)
|
|
251
|
-
console.log(cyan("Building test app..."));
|
|
252
|
-
try {
|
|
253
|
-
execSync("node app/app.js --build", {
|
|
254
|
-
cwd: runDir,
|
|
255
|
-
stdio: "inherit",
|
|
256
|
-
env: { ...process.env, NODE_OPTIONS: "--no-warnings" }
|
|
257
|
-
});
|
|
258
|
-
} catch (e) {
|
|
259
|
-
console.log(red("Failed to build test app. checking for runtime errors..."));
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
// 4. Run Titan Server using cargo run
|
|
263
|
-
console.log(green("\\x1b[1m\\n>>> STARTING EXTENSION TEST >>>\\n\\x1b[0m"));
|
|
264
|
-
|
|
265
|
-
const serverDir = path.join(runDir, "server");
|
|
266
|
-
|
|
267
|
-
try {
|
|
268
|
-
execSync("cargo run", { cwd: serverDir, stdio: "inherit" });
|
|
269
|
-
} catch (e) {
|
|
270
|
-
// console.log(red("Runtime exited."));
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
run();
|
package/titanpl-sdk/index.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "titanpl-sdk",
|
|
3
|
-
"version": "0.1.7",
|
|
4
|
-
"lockfileVersion": 3,
|
|
5
|
-
"requires": true,
|
|
6
|
-
"packages": {
|
|
7
|
-
"": {
|
|
8
|
-
"name": "titanpl-sdk",
|
|
9
|
-
"version": "0.1.7",
|
|
10
|
-
"license": "ISC",
|
|
11
|
-
"dependencies": {
|
|
12
|
-
"@titanpl/core": "^1.0.1"
|
|
13
|
-
},
|
|
14
|
-
"bin": {
|
|
15
|
-
"titanpl-sdk": "bin/run.js"
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
"node_modules/@titanpl/core": {
|
|
19
|
-
"version": "1.0.1",
|
|
20
|
-
"resolved": "https://registry.npmjs.org/@titanpl/core/-/core-1.0.1.tgz",
|
|
21
|
-
"integrity": "sha512-5zcDMNnf+oghKkQMiPBFuhLlRy2IASyWMAAMgfqa4AzoXxiw2BzzfN0B2EA76Dy9AhCeK2mY84Zm+FSE7ANVFg==",
|
|
22
|
-
"license": "ISC",
|
|
23
|
-
"engines": {
|
|
24
|
-
"node": ">=18.0.0"
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
package/titanpl-sdk/package.json
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "titanpl-sdk",
|
|
3
|
-
"version": "2.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
|
-
"main": "index.js",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"types": "index.d.ts",
|
|
8
|
-
"bin": {
|
|
9
|
-
"titanpl-sdk": "./bin/run.js"
|
|
10
|
-
},
|
|
11
|
-
"files": [
|
|
12
|
-
"bin/",
|
|
13
|
-
"templates/",
|
|
14
|
-
"titan",
|
|
15
|
-
"assets",
|
|
16
|
-
"index.js",
|
|
17
|
-
"index.d.ts",
|
|
18
|
-
"README.md"
|
|
19
|
-
],
|
|
20
|
-
"keywords": [
|
|
21
|
-
"titan",
|
|
22
|
-
"titan-planet",
|
|
23
|
-
"titanpl-sdk",
|
|
24
|
-
"ezetgalaxy",
|
|
25
|
-
"types",
|
|
26
|
-
"typescript",
|
|
27
|
-
"intellisense",
|
|
28
|
-
"sdk",
|
|
29
|
-
"backend-sdk",
|
|
30
|
-
"extension-development"
|
|
31
|
-
],
|
|
32
|
-
"license": "ISC",
|
|
33
|
-
"dependencies": {
|
|
34
|
-
"@titanpl/core": "latest",
|
|
35
|
-
"@titanpl/node": "latest"
|
|
36
|
-
},
|
|
37
|
-
"devDependencies": {
|
|
38
|
-
"@tgrv/microgravity": "latest"
|
|
39
|
-
}
|
|
40
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"module": "esnext",
|
|
4
|
-
"target": "esnext",
|
|
5
|
-
"checkJs": false,
|
|
6
|
-
"noImplicitAny": false,
|
|
7
|
-
"allowJs": true,
|
|
8
|
-
"moduleResolution": "node",
|
|
9
|
-
"baseUrl": ".",
|
|
10
|
-
"paths": {
|
|
11
|
-
"*": [
|
|
12
|
-
"./app/*"
|
|
13
|
-
]
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
"include": [
|
|
17
|
-
"app/**/*"
|
|
18
|
-
]
|
|
19
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
[package]
|
|
2
|
-
name = "titan-server"
|
|
3
|
-
version = "0.1.0"
|
|
4
|
-
edition = "2024"
|
|
5
|
-
|
|
6
|
-
[dependencies]
|
|
7
|
-
axum = "0.8.7"
|
|
8
|
-
dotenv = "0.15.0"
|
|
9
|
-
reqwest = { version = "0.12.24", features = ["json", "rustls-tls", "gzip", "brotli", "blocking"] }
|
|
10
|
-
serde = { version = "1.0.228", features = ["derive"] }
|
|
11
|
-
serde_json = "1.0.145"
|
|
12
|
-
thiserror = "2.0.17"
|
|
13
|
-
tokio = { version = "1.48.0", features = ["rt-multi-thread", "macros", "process", "fs"] }
|
|
14
|
-
tower-http = { version = "0.6.7", features = ["cors"] }
|
|
15
|
-
tracing = "0.1.43"
|
|
16
|
-
tracing-subscriber = "0.3.22"
|
|
17
|
-
anyhow = "1"
|
|
18
|
-
v8 = "0.106.0"
|
|
19
|
-
dotenvy = "0.15"
|
|
20
|
-
base64 = "0.21"
|
|
21
|
-
regex = "1.10"
|
|
22
|
-
bcrypt = "0.15"
|
|
23
|
-
jsonwebtoken = "9"
|
|
24
|
-
postgres = { version = "0.19", features = ["with-serde_json-1"] }
|
|
25
|
-
libloading = "0.8"
|
|
26
|
-
walkdir = "2"
|
|
27
|
-
crossbeam = "0.8.4"
|
|
28
|
-
dashmap = "6.1.0"
|
|
29
|
-
bytes = "1.11.0"
|
|
30
|
-
smallvec = "1.15.1"
|
|
31
|
-
num_cpus = "1.17.0"
|
|
32
|
-
deadpool-postgres = "0.12"
|
|
33
|
-
tokio-postgres = "0.7"
|
|
34
|
-
|
|
35
|
-
# Performance: Global Allocator
|
|
36
|
-
mimalloc = { version = "0.1", default-features = false }
|
|
37
|
-
|
|
38
|
-
# Static Analysis: OXC (Zero runtime cost, used at startup)
|
|
39
|
-
oxc = { version = "0.108", features = ["semantic"] }
|
|
40
|
-
|
|
41
|
-
# Release Profile
|
|
42
|
-
[profile.release]
|
|
43
|
-
opt-level = 3
|
|
44
|
-
lto = "fat"
|
|
45
|
-
codegen-units = 1
|
|
46
|
-
panic = "abort"
|
|
47
|
-
strip = true
|
|
48
|
-
|
|
49
|
-
# Dev Profile
|
|
50
|
-
[profile.dev]
|
|
51
|
-
opt-level = 0
|
|
52
|
-
debug = 1
|