@ezetgalaxy/titan 25.13.1 → 25.13.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.
- package/index.js +4 -3
- package/package.json +1 -1
- package/templates/server/src/main.rs +17 -12
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import path from "path";
|
|
4
4
|
import { execSync, spawn } from "child_process";
|
|
@@ -202,19 +202,20 @@ function buildProd() {
|
|
|
202
202
|
const outDir = path.join(root, "server", "actions");
|
|
203
203
|
fs.mkdirSync(outDir, { recursive: true });
|
|
204
204
|
|
|
205
|
-
const builtActions = path.join(
|
|
205
|
+
const builtActions = path.join(projectRoot, "server", "actions");
|
|
206
206
|
|
|
207
207
|
if (fs.existsSync(builtActions)) {
|
|
208
208
|
for (const file of fs.readdirSync(builtActions)) {
|
|
209
209
|
if (file.endsWith(".jsbundle")) {
|
|
210
210
|
fs.copyFileSync(
|
|
211
211
|
path.join(builtActions, file),
|
|
212
|
-
path.join(
|
|
212
|
+
path.join(actionsOut, file)
|
|
213
213
|
);
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
+
|
|
218
219
|
console.log(green("✔ Actions copied to server/actions"));
|
|
219
220
|
|
|
220
221
|
/* Rust release build */
|
package/package.json
CHANGED
|
@@ -40,9 +40,7 @@ struct AppState {
|
|
|
40
40
|
project_root: PathBuf,
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
/// This `t.fetch` runs the blocking HTTP call inside `tokio::task::block_in_place`
|
|
45
|
-
/// so it is safe to call while inside an async Tokio context.
|
|
43
|
+
|
|
46
44
|
fn inject_t_fetch(ctx: &mut Context) {
|
|
47
45
|
// Create native Rust function (Boa v0.20)
|
|
48
46
|
let t_fetch_native = NativeFunction::from_fn_ptr(|_this, args, ctx| {
|
|
@@ -186,19 +184,26 @@ async fn dynamic_handler_inner(
|
|
|
186
184
|
.into_response();
|
|
187
185
|
}
|
|
188
186
|
|
|
189
|
-
let action_path = state.project_root
|
|
190
|
-
.join("actions")
|
|
191
|
-
.join(format!("{}.jsbundle", action_name));
|
|
192
187
|
|
|
188
|
+
let dev_actions_dir = state.project_root.join("server").join("actions");
|
|
189
|
+
let prod_actions_dir = state.project_root.join("actions");
|
|
193
190
|
|
|
191
|
+
let actions_dir = if dev_actions_dir.exists() {
|
|
192
|
+
dev_actions_dir
|
|
193
|
+
} else {
|
|
194
|
+
prod_actions_dir
|
|
195
|
+
};
|
|
194
196
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
197
|
+
let action_path = actions_dir.join(format!("{}.jsbundle", action_name));
|
|
198
|
+
|
|
199
|
+
if !action_path.exists() {
|
|
200
|
+
return (
|
|
201
|
+
StatusCode::NOT_FOUND,
|
|
202
|
+
format!("Action bundle not found: {:?}", action_path),
|
|
203
|
+
)
|
|
200
204
|
.into_response();
|
|
201
|
-
|
|
205
|
+
}
|
|
206
|
+
|
|
202
207
|
|
|
203
208
|
let js_code = match fs::read_to_string(action_path) {
|
|
204
209
|
Ok(v) => v,
|