@titanpl/core 2.0.8 → 2.1.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/configure.js +50 -67
- package/index.d.ts +929 -265
- package/index.js +88 -53
- package/native/target/release/libtitan_core.so +0 -0
- package/package.json +1 -1
- package/titan.json +1 -1
package/configure.js
CHANGED
|
@@ -1,67 +1,50 @@
|
|
|
1
|
-
import { readFileSync, existsSync, writeFileSync } from 'fs';
|
|
2
|
-
import { resolve, dirname } from 'path';
|
|
3
|
-
import { fileURLToPath } from 'url';
|
|
4
|
-
import { platform as _platform } from 'os';
|
|
5
|
-
import { spawnSync } from 'child_process';
|
|
6
|
-
|
|
7
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
-
const __dirname = dirname(__filename);
|
|
9
|
-
const platform = _platform();
|
|
10
|
-
const titanConfigPath = resolve(__dirname, 'titan.json');
|
|
11
|
-
|
|
12
|
-
console.log(`Configuring titan.json for platform: ${platform}`);
|
|
13
|
-
|
|
14
|
-
// 1. Platform-specific output file name
|
|
15
|
-
let libFile = "";
|
|
16
|
-
if (platform === "win32") {
|
|
17
|
-
libFile = "titan_core.dll";
|
|
18
|
-
} else if (platform === "darwin") {
|
|
19
|
-
libFile = "libtitan_core.dylib";
|
|
20
|
-
} else {
|
|
21
|
-
libFile = "libtitan_core.so";
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const nativeDir = resolve(__dirname, "native");
|
|
25
|
-
const expectedBinary = resolve(nativeDir, "target/release", libFile);
|
|
26
|
-
|
|
27
|
-
// 2. Build if binary missing
|
|
28
|
-
if (!existsSync(expectedBinary)) {
|
|
29
|
-
console.log(`Native binary missing
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
console.log(`
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const content = readFileSync(titanConfigPath, "utf8");
|
|
52
|
-
const titanConfig = JSON.parse(content);
|
|
53
|
-
|
|
54
|
-
const relativeLibPath = `native/target/release/${libFile}`;
|
|
55
|
-
|
|
56
|
-
if (!titanConfig.native) {
|
|
57
|
-
titanConfig.native = {};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
titanConfig.native.path = relativeLibPath;
|
|
61
|
-
|
|
62
|
-
writeFileSync(titanConfigPath, JSON.stringify(titanConfig, null, 2));
|
|
63
|
-
console.log(`Updated titan.json to use native binary: ${relativeLibPath}`);
|
|
64
|
-
} catch (error) {
|
|
65
|
-
console.error("Error updating titan.json:", error);
|
|
66
|
-
process.exit(1);
|
|
67
|
-
}
|
|
1
|
+
import { readFileSync, existsSync, writeFileSync } from 'fs';
|
|
2
|
+
import { resolve, dirname } from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import { platform as _platform } from 'os';
|
|
5
|
+
import { spawnSync } from 'child_process';
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = dirname(__filename);
|
|
9
|
+
const platform = _platform();
|
|
10
|
+
const titanConfigPath = resolve(__dirname, 'titan.json');
|
|
11
|
+
|
|
12
|
+
console.log(`Configuring titan.json for platform: ${platform}`);
|
|
13
|
+
|
|
14
|
+
// 1. Platform-specific output file name
|
|
15
|
+
let libFile = "";
|
|
16
|
+
if (platform === "win32") {
|
|
17
|
+
libFile = "titan_core.dll";
|
|
18
|
+
} else if (platform === "darwin") {
|
|
19
|
+
libFile = "libtitan_core.dylib";
|
|
20
|
+
} else {
|
|
21
|
+
libFile = "libtitan_core.so";
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const nativeDir = resolve(__dirname, "native");
|
|
25
|
+
const expectedBinary = resolve(nativeDir, "target/release", libFile);
|
|
26
|
+
|
|
27
|
+
// 2. Build if binary missing
|
|
28
|
+
if (!existsSync(expectedBinary)) {
|
|
29
|
+
console.log(`Native binary missing.`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// 3. Update titan.json
|
|
33
|
+
try {
|
|
34
|
+
const content = readFileSync(titanConfigPath, "utf8");
|
|
35
|
+
const titanConfig = JSON.parse(content);
|
|
36
|
+
|
|
37
|
+
const relativeLibPath = `native/target/release/${libFile}`;
|
|
38
|
+
|
|
39
|
+
if (!titanConfig.native) {
|
|
40
|
+
titanConfig.native = {};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
titanConfig.native.path = relativeLibPath;
|
|
44
|
+
|
|
45
|
+
writeFileSync(titanConfigPath, JSON.stringify(titanConfig, null, 2));
|
|
46
|
+
console.log(`Updated titan.json to use native binary: ${relativeLibPath}`);
|
|
47
|
+
} catch (error) {
|
|
48
|
+
console.error("Error updating titan.json:", error);
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|