@tsonic/nodejs 0.4.6 → 10.0.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsonic/nodejs",
3
- "version": "0.4.6",
3
+ "version": "10.0.1",
4
4
  "description": "TypeScript type definitions for Node.js CLR library",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -9,7 +9,8 @@
9
9
  "types",
10
10
  "tsonic",
11
11
  "dotnet",
12
- "clr"
12
+ "clr",
13
+ "net10"
13
14
  ],
14
15
  "author": "Tsonic Team",
15
16
  "license": "MIT",
@@ -18,7 +19,7 @@
18
19
  "url": "https://github.com/tsoniclang/nodejs.git"
19
20
  },
20
21
  "peerDependencies": {
21
- "@tsonic/dotnet": "^0.8.3",
22
- "@tsonic/core": "^0.6.0"
22
+ "@tsonic/dotnet": "^10.0.1",
23
+ "@tsonic/core": "^10.0.1"
23
24
  }
24
25
  }
@@ -1,106 +0,0 @@
1
- #!/bin/bash
2
- # Generate TypeScript declarations for Node.js CLR library
3
- #
4
- # This script regenerates all TypeScript type declarations from the nodejs.dll
5
- # assembly using tsbindgen.
6
- #
7
- # Prerequisites:
8
- # - .NET 10 SDK installed
9
- # - tsbindgen repository cloned at ../tsbindgen (sibling directory)
10
- # - nodejs-clr repository cloned at ../nodejs-clr (sibling directory)
11
- #
12
- # Usage:
13
- # ./__build/scripts/generate.sh
14
-
15
- set -e
16
-
17
- SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
18
- PROJECT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)"
19
- TSBINDGEN_DIR="$PROJECT_DIR/../tsbindgen"
20
- NODEJS_CLR_DIR="$PROJECT_DIR/../nodejs-clr"
21
- DOTNET_LIB="$PROJECT_DIR/../dotnet"
22
-
23
- # .NET runtime path (needed for BCL type resolution)
24
- DOTNET_VERSION="${DOTNET_VERSION:-10.0.0}"
25
- DOTNET_HOME="${DOTNET_HOME:-$HOME/.dotnet}"
26
- DOTNET_RUNTIME_PATH="$DOTNET_HOME/shared/Microsoft.NETCore.App/$DOTNET_VERSION"
27
-
28
- # nodejs.dll path
29
- NODEJS_DLL="$NODEJS_CLR_DIR/artifacts/bin/nodejs/Release/net10.0/nodejs.dll"
30
-
31
- echo "================================================================"
32
- echo "Generating Node.js CLR TypeScript Declarations"
33
- echo "================================================================"
34
- echo ""
35
- echo "Configuration:"
36
- echo " nodejs.dll: $NODEJS_DLL"
37
- echo " .NET Runtime: $DOTNET_RUNTIME_PATH"
38
- echo " BCL Library: $DOTNET_LIB (external reference)"
39
- echo " tsbindgen: $TSBINDGEN_DIR"
40
- echo " Output: $PROJECT_DIR"
41
- echo " Naming: JS (camelCase)"
42
- echo ""
43
-
44
- # Verify prerequisites
45
- if [ ! -f "$NODEJS_DLL" ]; then
46
- echo "ERROR: nodejs.dll not found at $NODEJS_DLL"
47
- echo "Build it first: cd ../nodejs-clr && dotnet build -c Release"
48
- exit 1
49
- fi
50
-
51
- if [ ! -d "$DOTNET_RUNTIME_PATH" ]; then
52
- echo "ERROR: .NET runtime not found at $DOTNET_RUNTIME_PATH"
53
- echo "Set DOTNET_HOME or DOTNET_VERSION environment variables"
54
- exit 1
55
- fi
56
-
57
- if [ ! -d "$TSBINDGEN_DIR" ]; then
58
- echo "ERROR: tsbindgen not found at $TSBINDGEN_DIR"
59
- echo "Clone it: git clone https://github.com/tsoniclang/tsbindgen ../tsbindgen"
60
- exit 1
61
- fi
62
-
63
- if [ ! -d "$DOTNET_LIB" ]; then
64
- echo "ERROR: @tsonic/dotnet not found at $DOTNET_LIB"
65
- echo "Clone it: git clone https://github.com/tsoniclang/dotnet ../dotnet"
66
- exit 1
67
- fi
68
-
69
- # Clean output directory (keep config files)
70
- echo "[1/3] Cleaning output directory..."
71
- cd "$PROJECT_DIR"
72
-
73
- # Remove all namespace directories (but keep config files, __build, node_modules, .git)
74
- find . -maxdepth 1 -type d \
75
- ! -name '.' \
76
- ! -name '.git' \
77
- ! -name '.tests' \
78
- ! -name 'node_modules' \
79
- ! -name '__build' \
80
- -exec rm -rf {} \; 2>/dev/null || true
81
-
82
- # Remove generated files at root
83
- rm -f *.d.ts *.js 2>/dev/null || true
84
-
85
- echo " Done"
86
-
87
- # Build tsbindgen
88
- echo "[2/3] Building tsbindgen..."
89
- cd "$TSBINDGEN_DIR"
90
- dotnet build src/tsbindgen/tsbindgen.csproj -c Release --verbosity quiet
91
- echo " Done"
92
-
93
- # Generate types with JavaScript-style naming
94
- # Uses --lib to reference BCL types from @tsonic/dotnet instead of regenerating them
95
- # Uses --namespace-map to emit as index.d.ts/index.js for cleaner imports
96
- echo "[3/3] Generating TypeScript declarations..."
97
- dotnet run --project src/tsbindgen/tsbindgen.csproj --no-build -c Release -- \
98
- generate -a "$NODEJS_DLL" -d "$DOTNET_RUNTIME_PATH" -o "$PROJECT_DIR" \
99
- --lib "$DOTNET_LIB" \
100
- --naming js \
101
- --namespace-map "nodejs=index"
102
-
103
- echo ""
104
- echo "================================================================"
105
- echo "Generation Complete"
106
- echo "================================================================"
@@ -1,90 +0,0 @@
1
- #!/bin/bash
2
- # verify-library-mode.sh
3
- # Regression tests for library mode external import resolution
4
- # These tests detect the failure modes that occur when --lib doesn't work correctly
5
-
6
- set -e
7
-
8
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
9
- NODEJS_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)"
10
-
11
- echo "================================================================"
12
- echo "Library Mode Verification Tests"
13
- echo "================================================================"
14
- echo ""
15
- echo "Package directory: $NODEJS_DIR"
16
- echo ""
17
-
18
- FAILED=0
19
-
20
- # Test 1: No relative imports into BCL namespaces
21
- # If --lib fails, imports would look like "../../System/internal/index.js"
22
- echo "[Test 1] No relative imports to BCL namespaces..."
23
- if grep -r '"\.\./.*System' "$NODEJS_DIR"/*.d.ts "$NODEJS_DIR"/nodejs/*.d.ts "$NODEJS_DIR"/nodejs.Http/*.d.ts 2>/dev/null; then
24
- echo " FAIL: Found relative imports to System namespace"
25
- FAILED=1
26
- else
27
- echo " PASS: No relative BCL imports found"
28
- fi
29
-
30
- # Test 2: No 'unknown' type leakage for BCL types
31
- # If type resolution fails, BCL types become 'unknown'
32
- echo ""
33
- echo "[Test 2] No 'unknown' type leakage..."
34
- # Check for patterns like ": unknown" or "(arg: unknown)" that indicate unresolved types
35
- # Exclude legitimate uses (generic constraints, intentional unknown)
36
- UNKNOWN_COUNT=$(grep -rE ': unknown[^a-zA-Z]|: unknown$|\(.*: unknown' "$NODEJS_DIR"/nodejs/internal/index.d.ts "$NODEJS_DIR"/nodejs.Http/internal/index.d.ts 2>/dev/null | wc -l)
37
- if [ "$UNKNOWN_COUNT" -gt 0 ]; then
38
- echo " FAIL: Found $UNKNOWN_COUNT instances of 'unknown' type (potential unresolved BCL types)"
39
- grep -rE ': unknown[^a-zA-Z]|: unknown$|\(.*: unknown' "$NODEJS_DIR"/nodejs/internal/index.d.ts "$NODEJS_DIR"/nodejs.Http/internal/index.d.ts 2>/dev/null | head -5
40
- FAILED=1
41
- else
42
- echo " PASS: No 'unknown' type leakage found"
43
- fi
44
-
45
- # Test 3: No BCL namespace directories in output
46
- # If --lib fails, BCL namespaces get generated as separate directories
47
- echo ""
48
- echo "[Test 3] No BCL namespace directories..."
49
- BCL_DIRS=$(ls -d "$NODEJS_DIR"/System* "$NODEJS_DIR"/Microsoft* 2>/dev/null | wc -l)
50
- if [ "$BCL_DIRS" -gt 0 ]; then
51
- echo " FAIL: Found $BCL_DIRS BCL namespace directories (should be 0)"
52
- ls -d "$NODEJS_DIR"/System* "$NODEJS_DIR"/Microsoft* 2>/dev/null | head -5
53
- FAILED=1
54
- else
55
- echo " PASS: No BCL namespace directories found"
56
- fi
57
-
58
- # Test 4: Imports use package specifier format
59
- # Correct imports should be "@tsonic/dotnet/System.js" not relative paths
60
- echo ""
61
- echo "[Test 4] Imports use @tsonic/dotnet package specifier..."
62
- PACKAGE_IMPORTS=$(grep -c '@tsonic/dotnet/' "$NODEJS_DIR"/nodejs/internal/index.d.ts 2>/dev/null || echo "0")
63
- if [ "$PACKAGE_IMPORTS" -eq 0 ]; then
64
- echo " FAIL: No @tsonic/dotnet imports found (library mode not working)"
65
- FAILED=1
66
- else
67
- echo " PASS: Found $PACKAGE_IMPORTS @tsonic/dotnet imports"
68
- fi
69
-
70
- # Test 5: TypeScript compilation succeeds
71
- echo ""
72
- echo "[Test 5] TypeScript compilation..."
73
- cd "$NODEJS_DIR"
74
- if npx tsc --noEmit 2>&1; then
75
- echo " PASS: TypeScript compilation succeeded"
76
- else
77
- echo " FAIL: TypeScript compilation failed"
78
- FAILED=1
79
- fi
80
-
81
- # Summary
82
- echo ""
83
- echo "================================================================"
84
- if [ "$FAILED" -eq 0 ]; then
85
- echo "All tests PASSED"
86
- exit 0
87
- else
88
- echo "Some tests FAILED"
89
- exit 1
90
- fi