@titanpl/core 2.0.4 → 2.0.6

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 ADDED
@@ -0,0 +1,45 @@
1
+ import { readFileSync, existsSync, writeFileSync } from 'fs';
2
+ import { resolve } from 'path';
3
+ import { platform as _platform } from 'os';
4
+ const platform = _platform(); // 'win32', 'linux', 'darwin'
5
+ const titanConfigPath = resolve(__dirname, 'titan.json');
6
+
7
+ console.log(`Configuring titan.json for platform: ${platform}`);
8
+
9
+ try {
10
+ const content = readFileSync(titanConfigPath, 'utf8');
11
+ const titanConfig = JSON.parse(content);
12
+
13
+ let libPath = "";
14
+ if (platform === 'win32') {
15
+ libPath = "native/target/release/titan_core.dll";
16
+ } else if (platform === 'darwin') {
17
+ libPath = "native/target/release/libtitan_core.dylib";
18
+ } else {
19
+ // Assume linux/unix defaults for anything else
20
+ libPath = "native/target/release/libtitan_core.so";
21
+ }
22
+
23
+ const fullPath = resolve(__dirname, libPath);
24
+ if (!existsSync(fullPath)) {
25
+ console.warn(`Warning: Native binary not found at ${fullPath}. Valid binaries for this platform must be built or provided.`);
26
+ }
27
+
28
+ // Check if configuration actually needs changing to avoid unnecessary writes
29
+ if (titanConfig.native && titanConfig.native.path === libPath) {
30
+ console.log(`titan.json is already configured for ${platform}.`);
31
+ process.exit(0);
32
+ }
33
+
34
+ if (!titanConfig.native) {
35
+ titanConfig.native = {};
36
+ }
37
+
38
+ titanConfig.native.path = libPath;
39
+
40
+ writeFileSync(titanConfigPath, JSON.stringify(titanConfig, null, 2));
41
+ console.log(`Successfully updated titan.json native path to: ${libPath}`);
42
+ } catch (error) {
43
+ console.error("Error configuring titan.json:", error);
44
+ process.exit(1);
45
+ }
package/index.js CHANGED
@@ -485,7 +485,15 @@ const os = {
485
485
  const info = JSON.parse(native_os_info());
486
486
  return info.freeMemory;
487
487
  },
488
- tmpdir: () => '/tmp'
488
+ tmpdir: () => {
489
+ if (!native_os_info) return '/tmp';
490
+ try {
491
+ const info = JSON.parse(native_os_info());
492
+ return info.tempDir || '/tmp';
493
+ } catch (e) {
494
+ return '/tmp';
495
+ }
496
+ }
489
497
  };
490
498
 
491
499
  // --- Net ---
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "@titanpl/core",
3
- "version": "2.0.4",
3
+ "version": "2.0.6",
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
+ "type": "module",
6
7
  "types": "index.d.ts",
7
8
  "scripts": {
8
- "build:native": "cd native && cargo build --release",
9
+ "configure": "node configure.js",
10
+ "postinstall": "node configure.js",
11
+ "build:native": "cd native && cargo build --release && cd .. && npm run configure",
9
12
  "test": "titan run ext"
10
13
  },
11
14
  "keywords": [
@@ -25,6 +28,7 @@
25
28
  "license": "ISC",
26
29
  "files": [
27
30
  "index.js",
31
+ "configure.js",
28
32
  "titan.json",
29
33
  "globals.d.ts",
30
34
  "index.d.ts",
@@ -34,7 +38,8 @@
34
38
  "README.md"
35
39
  ],
36
40
  "engines": {
37
- "node": ">=18.0.0"
41
+ "node": ">=18.0.0",
42
+ "@ezetgalaxy/titan": ">=26.10.2"
38
43
  },
39
44
  "devDependencies": {
40
45
  "esbuild": "^0.27.2"
package/titan.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@titanpl/core",
3
3
  "description": "The official Core Standard Library for Titan Planet",
4
- "version": "2.0.2",
4
+ "version": "2.0.3",
5
5
  "main": "index.js",
6
6
  "native": {
7
7
  "path": "native/target/release/titan_core.dll",