titanpl 6.0.0 → 7.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.
- package/package.json +2 -6
- package/packages/cli/index.js +25 -11
- package/packages/cli/package.json +4 -4
- 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/{titanpl-sdk → packages/core-source}/LICENSE +1 -1
- package/packages/core-source/README.md +128 -0
- package/packages/core-source/V8_SERIALIZATION.md +125 -0
- package/packages/core-source/configure.js +50 -0
- package/packages/core-source/globals.d.ts +2238 -0
- package/packages/core-source/index.d.ts +515 -0
- package/packages/core-source/index.js +639 -0
- package/packages/core-source/jsconfig.json +12 -0
- package/packages/core-source/mkctx.config.json +7 -0
- package/packages/core-source/native/Cargo.lock +1559 -0
- package/packages/core-source/native/Cargo.toml +30 -0
- package/packages/core-source/native/src/crypto_impl.rs +139 -0
- package/packages/core-source/native/src/lib.rs +702 -0
- package/packages/core-source/native/src/storage_impl.rs +73 -0
- package/packages/core-source/native/src/v8_impl.rs +93 -0
- package/packages/core-source/package-lock.json +1464 -0
- package/packages/core-source/package.json +53 -0
- package/packages/core-source/tests/buffer.test.js +78 -0
- package/packages/core-source/tests/cookies.test.js +117 -0
- package/packages/core-source/tests/crypto.test.js +142 -0
- package/packages/core-source/tests/fs.test.js +176 -0
- package/packages/core-source/tests/ls.test.js +149 -0
- package/packages/core-source/tests/net.test.js +84 -0
- package/packages/core-source/tests/os.test.js +81 -0
- package/packages/core-source/tests/path.test.js +102 -0
- package/packages/core-source/tests/response.test.js +146 -0
- package/packages/core-source/tests/session.test.js +110 -0
- package/packages/core-source/tests/setup.js +325 -0
- package/packages/core-source/tests/time.test.js +57 -0
- package/packages/core-source/tests/url.test.js +82 -0
- package/packages/core-source/titan-ext.d.ts +2 -0
- package/packages/core-source/titan.json +9 -0
- package/packages/core-source/vitest.config.js +8 -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 +25 -4
- package/packages/native/index.js +7 -0
- package/packages/native/package.json +2 -2
- package/packages/native/t.native.d.ts +167 -2
- package/packages/packet/index.js +103 -94
- package/packages/packet/package.json +1 -1
- 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/_tanfig.json +19 -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 +5 -5
- package/templates/rust-ts/package.json +5 -5
- package/templates/ts/package.json +8 -8
- package/packages/packet/node_modules/typescript/LICENSE.txt +0 -55
- package/packages/packet/node_modules/typescript/README.md +0 -50
- package/packages/packet/node_modules/typescript/SECURITY.md +0 -41
- package/packages/packet/node_modules/typescript/ThirdPartyNoticeText.txt +0 -193
- package/packages/packet/node_modules/typescript/bin/tsc +0 -2
- package/packages/packet/node_modules/typescript/bin/tsserver +0 -2
- package/packages/packet/node_modules/typescript/lib/_tsc.js +0 -133818
- package/packages/packet/node_modules/typescript/lib/_tsserver.js +0 -659
- package/packages/packet/node_modules/typescript/lib/_typingsInstaller.js +0 -222
- package/packages/packet/node_modules/typescript/lib/cs/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/de/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/es/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/fr/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/it/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/ja/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/ko/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/lib.d.ts +0 -22
- package/packages/packet/node_modules/typescript/lib/lib.decorators.d.ts +0 -384
- package/packages/packet/node_modules/typescript/lib/lib.decorators.legacy.d.ts +0 -22
- package/packages/packet/node_modules/typescript/lib/lib.dom.asynciterable.d.ts +0 -41
- package/packages/packet/node_modules/typescript/lib/lib.dom.d.ts +0 -39429
- package/packages/packet/node_modules/typescript/lib/lib.dom.iterable.d.ts +0 -571
- package/packages/packet/node_modules/typescript/lib/lib.es2015.collection.d.ts +0 -147
- package/packages/packet/node_modules/typescript/lib/lib.es2015.core.d.ts +0 -597
- package/packages/packet/node_modules/typescript/lib/lib.es2015.d.ts +0 -28
- package/packages/packet/node_modules/typescript/lib/lib.es2015.generator.d.ts +0 -77
- package/packages/packet/node_modules/typescript/lib/lib.es2015.iterable.d.ts +0 -605
- package/packages/packet/node_modules/typescript/lib/lib.es2015.promise.d.ts +0 -81
- package/packages/packet/node_modules/typescript/lib/lib.es2015.proxy.d.ts +0 -128
- package/packages/packet/node_modules/typescript/lib/lib.es2015.reflect.d.ts +0 -144
- package/packages/packet/node_modules/typescript/lib/lib.es2015.symbol.d.ts +0 -46
- package/packages/packet/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts +0 -326
- package/packages/packet/node_modules/typescript/lib/lib.es2016.array.include.d.ts +0 -116
- package/packages/packet/node_modules/typescript/lib/lib.es2016.d.ts +0 -21
- package/packages/packet/node_modules/typescript/lib/lib.es2016.full.d.ts +0 -23
- package/packages/packet/node_modules/typescript/lib/lib.es2016.intl.d.ts +0 -31
- package/packages/packet/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts +0 -21
- package/packages/packet/node_modules/typescript/lib/lib.es2017.d.ts +0 -26
- package/packages/packet/node_modules/typescript/lib/lib.es2017.date.d.ts +0 -31
- package/packages/packet/node_modules/typescript/lib/lib.es2017.full.d.ts +0 -23
- package/packages/packet/node_modules/typescript/lib/lib.es2017.intl.d.ts +0 -44
- package/packages/packet/node_modules/typescript/lib/lib.es2017.object.d.ts +0 -49
- package/packages/packet/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts +0 -135
- package/packages/packet/node_modules/typescript/lib/lib.es2017.string.d.ts +0 -45
- package/packages/packet/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts +0 -53
- package/packages/packet/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts +0 -77
- package/packages/packet/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts +0 -53
- package/packages/packet/node_modules/typescript/lib/lib.es2018.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2018.full.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2018.intl.d.ts +0 -83
- package/packages/packet/node_modules/typescript/lib/lib.es2018.promise.d.ts +0 -30
- package/packages/packet/node_modules/typescript/lib/lib.es2018.regexp.d.ts +0 -37
- package/packages/packet/node_modules/typescript/lib/lib.es2019.array.d.ts +0 -79
- package/packages/packet/node_modules/typescript/lib/lib.es2019.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2019.full.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2019.intl.d.ts +0 -23
- package/packages/packet/node_modules/typescript/lib/lib.es2019.object.d.ts +0 -33
- package/packages/packet/node_modules/typescript/lib/lib.es2019.string.d.ts +0 -37
- package/packages/packet/node_modules/typescript/lib/lib.es2019.symbol.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2020.bigint.d.ts +0 -765
- package/packages/packet/node_modules/typescript/lib/lib.es2020.d.ts +0 -27
- package/packages/packet/node_modules/typescript/lib/lib.es2020.date.d.ts +0 -42
- package/packages/packet/node_modules/typescript/lib/lib.es2020.full.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2020.intl.d.ts +0 -474
- package/packages/packet/node_modules/typescript/lib/lib.es2020.number.d.ts +0 -28
- package/packages/packet/node_modules/typescript/lib/lib.es2020.promise.d.ts +0 -47
- package/packages/packet/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts +0 -99
- package/packages/packet/node_modules/typescript/lib/lib.es2020.string.d.ts +0 -44
- package/packages/packet/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts +0 -41
- package/packages/packet/node_modules/typescript/lib/lib.es2021.d.ts +0 -23
- package/packages/packet/node_modules/typescript/lib/lib.es2021.full.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2021.intl.d.ts +0 -166
- package/packages/packet/node_modules/typescript/lib/lib.es2021.promise.d.ts +0 -48
- package/packages/packet/node_modules/typescript/lib/lib.es2021.string.d.ts +0 -33
- package/packages/packet/node_modules/typescript/lib/lib.es2021.weakref.d.ts +0 -78
- package/packages/packet/node_modules/typescript/lib/lib.es2022.array.d.ts +0 -121
- package/packages/packet/node_modules/typescript/lib/lib.es2022.d.ts +0 -25
- package/packages/packet/node_modules/typescript/lib/lib.es2022.error.d.ts +0 -75
- package/packages/packet/node_modules/typescript/lib/lib.es2022.full.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2022.intl.d.ts +0 -145
- package/packages/packet/node_modules/typescript/lib/lib.es2022.object.d.ts +0 -26
- package/packages/packet/node_modules/typescript/lib/lib.es2022.regexp.d.ts +0 -39
- package/packages/packet/node_modules/typescript/lib/lib.es2022.string.d.ts +0 -25
- package/packages/packet/node_modules/typescript/lib/lib.es2023.array.d.ts +0 -924
- package/packages/packet/node_modules/typescript/lib/lib.es2023.collection.d.ts +0 -21
- package/packages/packet/node_modules/typescript/lib/lib.es2023.d.ts +0 -22
- package/packages/packet/node_modules/typescript/lib/lib.es2023.full.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2023.intl.d.ts +0 -56
- package/packages/packet/node_modules/typescript/lib/lib.es2024.arraybuffer.d.ts +0 -65
- package/packages/packet/node_modules/typescript/lib/lib.es2024.collection.d.ts +0 -29
- package/packages/packet/node_modules/typescript/lib/lib.es2024.d.ts +0 -26
- package/packages/packet/node_modules/typescript/lib/lib.es2024.full.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.es2024.object.d.ts +0 -29
- package/packages/packet/node_modules/typescript/lib/lib.es2024.promise.d.ts +0 -35
- package/packages/packet/node_modules/typescript/lib/lib.es2024.regexp.d.ts +0 -25
- package/packages/packet/node_modules/typescript/lib/lib.es2024.sharedmemory.d.ts +0 -68
- package/packages/packet/node_modules/typescript/lib/lib.es2024.string.d.ts +0 -29
- package/packages/packet/node_modules/typescript/lib/lib.es5.d.ts +0 -4601
- package/packages/packet/node_modules/typescript/lib/lib.es6.d.ts +0 -23
- package/packages/packet/node_modules/typescript/lib/lib.esnext.array.d.ts +0 -35
- package/packages/packet/node_modules/typescript/lib/lib.esnext.collection.d.ts +0 -96
- package/packages/packet/node_modules/typescript/lib/lib.esnext.d.ts +0 -29
- package/packages/packet/node_modules/typescript/lib/lib.esnext.decorators.d.ts +0 -28
- package/packages/packet/node_modules/typescript/lib/lib.esnext.disposable.d.ts +0 -193
- package/packages/packet/node_modules/typescript/lib/lib.esnext.error.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.esnext.float16.d.ts +0 -445
- package/packages/packet/node_modules/typescript/lib/lib.esnext.full.d.ts +0 -24
- package/packages/packet/node_modules/typescript/lib/lib.esnext.intl.d.ts +0 -21
- package/packages/packet/node_modules/typescript/lib/lib.esnext.iterator.d.ts +0 -148
- package/packages/packet/node_modules/typescript/lib/lib.esnext.promise.d.ts +0 -34
- package/packages/packet/node_modules/typescript/lib/lib.esnext.sharedmemory.d.ts +0 -25
- package/packages/packet/node_modules/typescript/lib/lib.scripthost.d.ts +0 -322
- package/packages/packet/node_modules/typescript/lib/lib.webworker.asynciterable.d.ts +0 -41
- package/packages/packet/node_modules/typescript/lib/lib.webworker.d.ts +0 -13150
- package/packages/packet/node_modules/typescript/lib/lib.webworker.importscripts.d.ts +0 -23
- package/packages/packet/node_modules/typescript/lib/lib.webworker.iterable.d.ts +0 -340
- package/packages/packet/node_modules/typescript/lib/pl/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/pt-br/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/ru/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/tr/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/tsc.js +0 -8
- package/packages/packet/node_modules/typescript/lib/tsserver.js +0 -8
- package/packages/packet/node_modules/typescript/lib/tsserverlibrary.d.ts +0 -17
- package/packages/packet/node_modules/typescript/lib/tsserverlibrary.js +0 -21
- package/packages/packet/node_modules/typescript/lib/typesMap.json +0 -497
- package/packages/packet/node_modules/typescript/lib/typescript.d.ts +0 -11437
- package/packages/packet/node_modules/typescript/lib/typescript.js +0 -200276
- package/packages/packet/node_modules/typescript/lib/typingsInstaller.js +0 -8
- package/packages/packet/node_modules/typescript/lib/watchGuard.js +0 -53
- package/packages/packet/node_modules/typescript/lib/zh-cn/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/lib/zh-tw/diagnosticMessages.generated.json +0 -2122
- package/packages/packet/node_modules/typescript/package.json +0 -120
- 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 -1060
- 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,175 +0,0 @@
|
|
|
1
|
-
//! Action Management and Dynamic Routing
|
|
2
|
-
//!
|
|
3
|
-
//! Handles resolution of action directories, scanning for available actions,
|
|
4
|
-
//! and matching dynamic routes (e.g. `/users/:id`).
|
|
5
|
-
|
|
6
|
-
use std::collections::HashMap;
|
|
7
|
-
use std::env;
|
|
8
|
-
use std::path::{Path, PathBuf};
|
|
9
|
-
use serde::Deserialize;
|
|
10
|
-
use serde_json::Value;
|
|
11
|
-
|
|
12
|
-
/// Route configuration (loaded from routes.json)
|
|
13
|
-
#[derive(Debug, Deserialize, Clone)]
|
|
14
|
-
pub struct RouteVal {
|
|
15
|
-
pub r#type: String,
|
|
16
|
-
#[serde(alias = "target")]
|
|
17
|
-
pub value: Value,
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
#[derive(Debug, Deserialize, Clone)]
|
|
21
|
-
pub struct DynamicRoute {
|
|
22
|
-
pub method: String,
|
|
23
|
-
pub pattern: String,
|
|
24
|
-
pub action: String,
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/// Resolve the directory path where actions are stored.
|
|
28
|
-
pub fn resolve_actions_dir() -> PathBuf {
|
|
29
|
-
// Respect explicit override first
|
|
30
|
-
if let Ok(override_dir) = env::var("TITAN_ACTIONS_DIR") {
|
|
31
|
-
return PathBuf::from(override_dir);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Production container layout
|
|
35
|
-
if Path::new("/app/actions").exists() {
|
|
36
|
-
return PathBuf::from("/app/actions");
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Try to walk up from the executing binary to discover `<...>/server/src/actions`
|
|
40
|
-
if let Ok(exe) = std::env::current_exe() {
|
|
41
|
-
if let Some(parent) = exe.parent() {
|
|
42
|
-
if let Some(target_dir) = parent.parent() {
|
|
43
|
-
if let Some(server_dir) = target_dir.parent() {
|
|
44
|
-
let candidate = server_dir.join("src").join("actions");
|
|
45
|
-
if candidate.exists() {
|
|
46
|
-
return candidate;
|
|
47
|
-
}
|
|
48
|
-
let candidate2 = server_dir.join("actions");
|
|
49
|
-
if candidate2.exists() {
|
|
50
|
-
return candidate2;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Fall back to local ./src/actions
|
|
58
|
-
PathBuf::from("./src/actions")
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/// Try to find the directory that contains compiled action bundles.
|
|
62
|
-
pub fn find_actions_dir(project_root: &PathBuf) -> Option<PathBuf> {
|
|
63
|
-
let candidates = [
|
|
64
|
-
project_root.join("server").join("src").join("actions"),
|
|
65
|
-
project_root.join("server").join("actions"),
|
|
66
|
-
project_root.join("app").join("actions"),
|
|
67
|
-
project_root.join("actions"),
|
|
68
|
-
|
|
69
|
-
project_root.join("..").join("server").join("actions"),
|
|
70
|
-
PathBuf::from("/app").join("actions"),
|
|
71
|
-
PathBuf::from("actions"),
|
|
72
|
-
];
|
|
73
|
-
|
|
74
|
-
for p in &candidates {
|
|
75
|
-
if p.exists() && p.is_dir() {
|
|
76
|
-
return Some(p.clone());
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
None
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/// Match a dynamic route against the current request path.
|
|
84
|
-
pub fn match_dynamic_route(
|
|
85
|
-
method: &str,
|
|
86
|
-
path: &str,
|
|
87
|
-
routes: &[DynamicRoute],
|
|
88
|
-
) -> Option<(String, HashMap<String, String>)> {
|
|
89
|
-
let path_segments: Vec<&str> =
|
|
90
|
-
path.trim_matches('/').split('/').collect();
|
|
91
|
-
|
|
92
|
-
for route in routes {
|
|
93
|
-
if route.method != method {
|
|
94
|
-
continue;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
let pattern_segments: Vec<&str> =
|
|
98
|
-
route.pattern.trim_matches('/').split('/').collect();
|
|
99
|
-
|
|
100
|
-
if pattern_segments.len() != path_segments.len() {
|
|
101
|
-
continue;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
let mut params = HashMap::new();
|
|
105
|
-
let mut matched = true;
|
|
106
|
-
|
|
107
|
-
for (pat, val) in pattern_segments.iter().zip(path_segments.iter()) {
|
|
108
|
-
if pat.starts_with(':') {
|
|
109
|
-
let inner = &pat[1..];
|
|
110
|
-
|
|
111
|
-
let (name, ty) = inner
|
|
112
|
-
.split_once('<')
|
|
113
|
-
.map(|(n, t)| (n, t.trim_end_matches('>')))
|
|
114
|
-
.unwrap_or((inner, "string"));
|
|
115
|
-
|
|
116
|
-
let valid = match ty {
|
|
117
|
-
"number" => val.parse::<i64>().is_ok(),
|
|
118
|
-
"string" => true,
|
|
119
|
-
_ => false,
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
if !valid {
|
|
123
|
-
matched = false;
|
|
124
|
-
break;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
params.insert(name.to_string(), (*val).to_string());
|
|
128
|
-
} else if pat != val {
|
|
129
|
-
matched = false;
|
|
130
|
-
break;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if matched {
|
|
135
|
-
return Some((route.action.clone(), params));
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
None
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/// Scan the resolved actions directory and return a map of action names to file paths.
|
|
143
|
-
pub fn scan_actions(root: &PathBuf) -> HashMap<String, PathBuf> {
|
|
144
|
-
let mut map = HashMap::new();
|
|
145
|
-
|
|
146
|
-
// Locate actions dir - Priority: project root relative paths
|
|
147
|
-
let dir = match find_actions_dir(root) {
|
|
148
|
-
Some(d) => d,
|
|
149
|
-
None => {
|
|
150
|
-
let ad = resolve_actions_dir();
|
|
151
|
-
if ad.exists() { ad } else { return map; }
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
// Scanning actions
|
|
156
|
-
if let Ok(entries) = std::fs::read_dir(dir) {
|
|
157
|
-
for entry in entries.flatten() {
|
|
158
|
-
let path = entry.path();
|
|
159
|
-
if !path.is_file() { continue; }
|
|
160
|
-
|
|
161
|
-
let ext = path.extension().and_then(|s| s.to_str()).unwrap_or("");
|
|
162
|
-
if ext != "js" && ext != "jsbundle" {
|
|
163
|
-
continue;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
let file_stem = path.file_stem().and_then(|s| s.to_str()).unwrap_or("");
|
|
167
|
-
if file_stem.is_empty() { continue; }
|
|
168
|
-
|
|
169
|
-
// Found action
|
|
170
|
-
map.insert(file_stem.to_string(), path);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
map
|
|
175
|
-
}
|