@titanpl/core 2.0.7 → 2.0.9

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 CHANGED
@@ -2,48 +2,49 @@ import { readFileSync, existsSync, writeFileSync } from 'fs';
2
2
  import { resolve, dirname } from 'path';
3
3
  import { fileURLToPath } from 'url';
4
4
  import { platform as _platform } from 'os';
5
+ import { spawnSync } from 'child_process';
5
6
 
6
7
  const __filename = fileURLToPath(import.meta.url);
7
8
  const __dirname = dirname(__filename);
8
- const platform = _platform(); // 'win32', 'linux', 'darwin'
9
+ const platform = _platform();
9
10
  const titanConfigPath = resolve(__dirname, 'titan.json');
10
11
 
11
12
  console.log(`Configuring titan.json for platform: ${platform}`);
12
13
 
13
- try {
14
- const content = readFileSync(titanConfigPath, 'utf8');
15
- const titanConfig = JSON.parse(content);
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
+ }
16
23
 
17
- let libPath = "";
18
- if (platform === 'win32') {
19
- libPath = "native/target/release/titan_core.dll";
20
- } else if (platform === 'darwin') {
21
- libPath = "native/target/release/libtitan_core.dylib";
22
- } else {
23
- // Assume linux/unix defaults for anything else
24
- libPath = "native/target/release/libtitan_core.so";
25
- }
24
+ const nativeDir = resolve(__dirname, "native");
25
+ const expectedBinary = resolve(nativeDir, "target/release", libFile);
26
26
 
27
- const fullPath = resolve(__dirname, libPath);
28
- if (!existsSync(fullPath)) {
29
- console.warn(`Warning: Native binary not found at ${fullPath}. Valid binaries for this platform must be built or provided.`);
30
- }
27
+ // 2. Build if binary missing
28
+ if (!existsSync(expectedBinary)) {
29
+ console.log(`Native binary missing.`);
30
+ }
31
31
 
32
- // Check if configuration actually needs changing to avoid unnecessary writes
33
- if (titanConfig.native && titanConfig.native.path === libPath) {
34
- console.log(`titan.json is already configured for ${platform}.`);
35
- process.exit(0);
36
- }
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}`;
37
38
 
38
39
  if (!titanConfig.native) {
39
40
  titanConfig.native = {};
40
41
  }
41
42
 
42
- titanConfig.native.path = libPath;
43
+ titanConfig.native.path = relativeLibPath;
43
44
 
44
45
  writeFileSync(titanConfigPath, JSON.stringify(titanConfig, null, 2));
45
- console.log(`Successfully updated titan.json native path to: ${libPath}`);
46
+ console.log(`Updated titan.json to use native binary: ${relativeLibPath}`);
46
47
  } catch (error) {
47
- console.error("Error configuring titan.json:", error);
48
+ console.error("Error updating titan.json:", error);
48
49
  process.exit(1);
49
50
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@titanpl/core",
3
- "version": "2.0.7",
3
+ "version": "2.0.9",
4
4
  "description": "The official Core Standard Library for Titan Planet - provides fs, path, crypto, os, net, proc, time, and url modules",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/titan.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "version": "2.0.7",
5
5
  "main": "index.js",
6
6
  "native": {
7
- "path": "native/target/release/titan_core.dll",
7
+ "path": "native/target/release/libtitan_core.so",
8
8
  "functions": {
9
9
  "fs_read_file": {
10
10
  "symbol": "fs_read_file",