@xingwangzhe/force-rs 0.2.2 → 0.3.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/README.md +97 -41
- package/force-rs.darwin-arm64.node +0 -0
- package/force-rs.darwin-x64.node +0 -0
- package/force-rs.linux-arm64-gnu.node +0 -0
- package/force-rs.linux-x64-gnu.node +0 -0
- package/force-rs.linux-x64-musl.node +0 -0
- package/force-rs.win32-x64-msvc.node +0 -0
- package/index.d.ts +11 -0
- package/index.js +54 -54
- package/package.json +30 -28
package/README.md
CHANGED
|
@@ -6,16 +6,16 @@ Fast force-directed 3D graph layout powered by **Rust + a contiguous Barnes-Hut
|
|
|
6
6
|
|
|
7
7
|
### Why this exists
|
|
8
8
|
|
|
9
|
-
`d3-force-3d` is excellent for interactive visualizations, but at build time (SSG/SSR) with 47K+ nodes and 89K+ edges, the JS runtime becomes a bottleneck — hundreds of ticks at ~1s each is too slow. `force-rs` implements
|
|
9
|
+
`d3-force-3d` is excellent for interactive visualizations, but at build time (SSG/SSR) with 47K+ nodes and 89K+ edges, the JS runtime becomes a bottleneck — hundreds of ticks at ~1s each is too slow. `force-rs` implements d3-style repulsion, degree-biased springs and translational centering in Rust. Runtime depends on graph geometry, force options, hardware and thread count; measured consumer results are documented below.
|
|
10
10
|
|
|
11
|
-
### Force model
|
|
11
|
+
### Force model
|
|
12
12
|
|
|
13
|
-
| Force
|
|
14
|
-
|
|
15
|
-
| Many-body repulsion
|
|
16
|
-
| Link (spring)
|
|
17
|
-
| Center (translational) | Shift centroid toward origin (same as d3-force `forceCenter`)
|
|
18
|
-
| Distance softening
|
|
13
|
+
| Force | Implementation |
|
|
14
|
+
| ---------------------- | ---------------------------------------------------------------------- |
|
|
15
|
+
| Many-body repulsion | Barnes-Hut octree, O(n log n), with `√(4/k)` correction |
|
|
16
|
+
| Link (spring) | Degree-biased strength: `1/min(deg, deg)`, bias = other's degree ratio |
|
|
17
|
+
| Center (translational) | Shift centroid toward origin (same as d3-force `forceCenter`) |
|
|
18
|
+
| Distance softening | Smooth `√(d_min² × d²)` below 1.0 (same as d3-force) |
|
|
19
19
|
|
|
20
20
|
### Other features
|
|
21
21
|
|
|
@@ -36,15 +36,15 @@ npm install @xingwangzhe/force-rs
|
|
|
36
36
|
Execute one tick of force-directed simulation.
|
|
37
37
|
|
|
38
38
|
```ts
|
|
39
|
-
import { simTick } from
|
|
39
|
+
import { simTick } from "@xingwangzhe/force-rs";
|
|
40
40
|
|
|
41
41
|
const opts = {
|
|
42
|
-
repulsion: 3000,
|
|
43
|
-
linkDistance: 500,
|
|
44
|
-
centerStrength: 0.005
|
|
45
|
-
theta: 0.8,
|
|
46
|
-
velocityDecay: 0.
|
|
47
|
-
alphaDecay: 0.02,
|
|
42
|
+
repulsion: 3000, // many-body charge strength
|
|
43
|
+
linkDistance: 500, // natural spring length
|
|
44
|
+
centerStrength: 0.005, // translational center gravity
|
|
45
|
+
theta: 0.8, // Barnes-Hut approximation threshold
|
|
46
|
+
velocityDecay: 0.6, // velocity damping per tick
|
|
47
|
+
alphaDecay: 0.02, // cooling rate per tick
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
// state: n*6 + 1 floats [x0,y0,z0,vx0,vy0,vz0, ..., alpha]
|
|
@@ -55,7 +55,7 @@ const newState = simTick(state, links, n, opts);
|
|
|
55
55
|
For repeated ticks, preprocess links once and use typed arrays:
|
|
56
56
|
|
|
57
57
|
```ts
|
|
58
|
-
import { createSimulation } from
|
|
58
|
+
import { createSimulation } from "@xingwangzhe/force-rs";
|
|
59
59
|
|
|
60
60
|
const simulation = createSimulation(new Uint32Array(links), n);
|
|
61
61
|
const nextState = simulation.tick(new Float64Array(state), opts);
|
|
@@ -63,34 +63,63 @@ const nextState = simulation.tick(new Float64Array(state), opts);
|
|
|
63
63
|
|
|
64
64
|
**ForceOptions:**
|
|
65
65
|
|
|
66
|
-
| Field
|
|
67
|
-
|
|
68
|
-
| `repulsion` | number | Many-body charge strength
|
|
69
|
-
| `linkDistance` | number | Natural spring length
|
|
70
|
-
| `centerStrength` | number | Translational center gravity
|
|
71
|
-
| `theta` | number | Barnes-Hut approximation threshold
|
|
72
|
-
| `velocityDecay` | number | Velocity damping factor per tick
|
|
73
|
-
| `alphaDecay` | number | Alpha cooling rate per tick
|
|
74
|
-
| `algorithm` | string | `fast` (default), `
|
|
75
|
-
| `distanceMax` | number | Optional finite repulsion radius
|
|
76
|
-
| `algorithm` | string | `fast` (default) or `legacy` comparison path |
|
|
77
|
-
| `distanceMax` | number | Optional finite repulsion radius |
|
|
66
|
+
| Field | Type | Description |
|
|
67
|
+
| ---------------- | ------ | -------------------------------------------------------------------- |
|
|
68
|
+
| `repulsion` | number | Many-body charge strength |
|
|
69
|
+
| `linkDistance` | number | Natural spring length |
|
|
70
|
+
| `centerStrength` | number | Translational center gravity |
|
|
71
|
+
| `theta` | number | Barnes-Hut approximation threshold |
|
|
72
|
+
| `velocityDecay` | number | Velocity damping factor per tick |
|
|
73
|
+
| `alphaDecay` | number | Alpha cooling rate per tick |
|
|
74
|
+
| `algorithm` | string | `fast` (default), experimental `ordered` / `linear`, or `legacy` reference |
|
|
75
|
+
| `distanceMax` | number | Optional finite repulsion radius |
|
|
78
76
|
|
|
79
77
|
**Returns:** `Array<number>` for `simTick`, or `Float64Array` for the prepared typed-array API.
|
|
80
78
|
|
|
81
|
-
The default `fast` path
|
|
79
|
+
The default `fast` path reuses SoA state, precomputed CSR spring coefficients and a contiguous octree with stackless preorder traversal. It preserves the original insertion order and force contribution order. Experimental `ordered` evaluates independent nodes in Morton order and restores the public node order; `linear` changes tree insertion order. Use `legacy` to compare with the previous pointer-based tree. Parallel centroid reductions may produce ordinary floating-point roundoff differences.
|
|
80
|
+
|
|
81
|
+
### Bounded batched simulation
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
const result = simulation.run(new Float64Array(state), opts, 500, 0.001, 14 * 60 * 1000);
|
|
85
|
+
// result.state: Float64Array; result.ticks: number; result.stoppedByTime: boolean
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
`run` performs at most `maxTicks` ticks, checks `alpha < alphaMin` after every
|
|
89
|
+
completed tick, and optionally stops when `timeLimitMs` has elapsed. It returns
|
|
90
|
+
the exact completed tick count and reports a time cutoff separately from cooling
|
|
91
|
+
completion. A zero tick limit returns a copy of the input. Inputs are not mutated.
|
|
92
|
+
Two native result buffers are reused throughout the batch, so intermediate states
|
|
93
|
+
do not each become a JS external typed array. Use smaller batches for progress
|
|
94
|
+
reporting or cancellation between calls. A time cutoff is an incomplete layout;
|
|
95
|
+
the consumer decides whether it can be used or cached.
|
|
82
96
|
|
|
83
97
|
## Usage Example
|
|
84
98
|
|
|
85
99
|
```ts
|
|
86
|
-
import { simTick } from
|
|
100
|
+
import { simTick } from "@xingwangzhe/force-rs";
|
|
87
101
|
|
|
88
102
|
// 3 nodes: positions + velocities + alpha
|
|
89
103
|
const state = [
|
|
90
|
-
0,
|
|
91
|
-
|
|
92
|
-
0,
|
|
93
|
-
|
|
104
|
+
0,
|
|
105
|
+
0,
|
|
106
|
+
0,
|
|
107
|
+
0,
|
|
108
|
+
0,
|
|
109
|
+
0, // node 0
|
|
110
|
+
100,
|
|
111
|
+
0,
|
|
112
|
+
0,
|
|
113
|
+
0,
|
|
114
|
+
0,
|
|
115
|
+
0, // node 1
|
|
116
|
+
0,
|
|
117
|
+
100,
|
|
118
|
+
0,
|
|
119
|
+
0,
|
|
120
|
+
0,
|
|
121
|
+
0, // node 2
|
|
122
|
+
1.0, // alpha
|
|
94
123
|
];
|
|
95
124
|
const links = [0, 1, 0, 2]; // node 0 connected to 1 and 2
|
|
96
125
|
|
|
@@ -99,7 +128,7 @@ const opts = {
|
|
|
99
128
|
linkDistance: 500,
|
|
100
129
|
centerStrength: 0.005,
|
|
101
130
|
theta: 0.8,
|
|
102
|
-
velocityDecay: 0.
|
|
131
|
+
velocityDecay: 0.6,
|
|
103
132
|
alphaDecay: 0.02,
|
|
104
133
|
};
|
|
105
134
|
|
|
@@ -112,13 +141,40 @@ while (s[s.length - 1] > 0.001) {
|
|
|
112
141
|
|
|
113
142
|
## Real-world Performance
|
|
114
143
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
144
|
+
A 2026-10-18 cross-repository test used the real FriendLinks graph: **49,064 nodes,
|
|
145
|
+
107,527 edges, 342 cooling ticks**, identical options and initial state, portable
|
|
146
|
+
release builds, and 16 Rayon threads on an Intel Core i7-1260P.
|
|
147
|
+
|
|
148
|
+
| Implementation / call mode | Complete 342 ticks | Process peak RSS |
|
|
149
|
+
| --- | --- | --- |
|
|
150
|
+
| Published 0.2.3 | 42.99 s | Not recorded in the standalone control |
|
|
151
|
+
| 0.3 candidate, individual `tick` calls | 21.07 s | 840.8 MiB |
|
|
152
|
+
| 0.3 candidate, batches of 10, two independent runs | 23.02 / 21.61 s | 156.1 / 156.1 MiB |
|
|
153
|
+
| 0.3 candidate, one batch of 342 | 22.94 s | 76.9 MiB |
|
|
154
|
+
|
|
155
|
+
These are complete isolated native-run measurements, not universal throughput
|
|
156
|
+
guarantees. The arena and stackless traversal provide the CPU improvement;
|
|
157
|
+
batching reduces intermediate JS arrays and peak RSS. The batch-of-10 peak RSS
|
|
158
|
+
was 81.4% lower than individual calls in this runner, while CPU times do not show
|
|
159
|
+
a batching speedup. Small differences between call modes are sensitive to CPU
|
|
160
|
+
scheduling and temperature.
|
|
161
|
+
|
|
162
|
+
All coordinates remained finite, final alpha and graph geometry summary metrics
|
|
163
|
+
matched the published control. The graph, cooling count, theta and force law were
|
|
164
|
+
unchanged. Experimental Morton evaluation order had a modest exploratory gain
|
|
165
|
+
and remains opt-in. A coherent packet prototype was slower and removed. Local
|
|
166
|
+
PGO improved the balanced corpus geometric mean by only 1.1%, below the existing
|
|
167
|
+
3% selection threshold, so the unprofiled release was selected on this machine.
|
|
168
|
+
|
|
169
|
+
The tree remains specialized code in `src/lib.rs`, with no external numerical
|
|
170
|
+
tree crate. See [raw measurements and reproduction](reports/build-performance-2026-10-18/README.md),
|
|
171
|
+
[algorithm and crate research](scripts/ALGORITHM-RESEARCH.md), and the consumer
|
|
172
|
+
fixture runner `scripts/real-graph-benchmark.mjs`.
|
|
121
173
|
|
|
122
174
|
## License
|
|
123
175
|
|
|
124
176
|
MIT
|
|
177
|
+
|
|
178
|
+
## Runtime-focused release builds
|
|
179
|
+
|
|
180
|
+
Native CI artifacts use full LTO, one code-generation unit, and O3, while preserving the existing CPU instruction baseline. CI trains a profile-guided optimization (PGO) candidate using representative graph workloads and publishes it only when the runtime comparison passes; otherwise it publishes the unprofiled release. `bun run build:pgo` produces the optimized addon; `bun run benchmark:pgo` compares it with an unprofiled release. Install `llvm-tools-preview` with the same Rust toolchain first. Details and measurement limits: [scripts/PERFORMANCE.md](scripts/PERFORMANCE.md).
|
|
Binary file
|
package/force-rs.darwin-x64.node
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/index.d.ts
CHANGED
|
@@ -11,6 +11,11 @@ export declare const __napiBindingTarget: 'native' | 'wasm32-wasi' | 'wasm32-was
|
|
|
11
11
|
|
|
12
12
|
export declare class Simulation {
|
|
13
13
|
tick(state: Float64Array, opts: ForceOptions): Float64Array
|
|
14
|
+
/**
|
|
15
|
+
* Run a bounded batch without exposing intermediate arrays to the JS heap.
|
|
16
|
+
* Stops after the same completed tick that repeated `tick` calls would stop.
|
|
17
|
+
*/
|
|
18
|
+
run(state: Float64Array, opts: ForceOptions, maxTicks: number, alphaMin: number, timeLimitMs?: number | undefined | null): SimulationResult
|
|
14
19
|
}
|
|
15
20
|
|
|
16
21
|
export declare function createSimulation(links: Uint32Array, n: number): Simulation
|
|
@@ -27,3 +32,9 @@ export interface ForceOptions {
|
|
|
27
32
|
}
|
|
28
33
|
|
|
29
34
|
export declare function simTick(state: Array<number>, links: Array<number>, n: number, opts: ForceOptions): Array<number>
|
|
35
|
+
|
|
36
|
+
export interface SimulationResult {
|
|
37
|
+
state: Float64Array
|
|
38
|
+
ticks: number
|
|
39
|
+
stoppedByTime: boolean
|
|
40
|
+
}
|
package/index.js
CHANGED
|
@@ -89,8 +89,8 @@ function requireNative() {
|
|
|
89
89
|
try {
|
|
90
90
|
const binding = require('@xingwangzhe/force-rs-android-arm64')
|
|
91
91
|
const bindingPackageVersion = require('@xingwangzhe/force-rs-android-arm64/package.json').version
|
|
92
|
-
if (bindingPackageVersion !== '0.
|
|
93
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
92
|
+
if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
93
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
94
94
|
}
|
|
95
95
|
return binding
|
|
96
96
|
} catch (e) {
|
|
@@ -105,8 +105,8 @@ function requireNative() {
|
|
|
105
105
|
try {
|
|
106
106
|
const binding = require('@xingwangzhe/force-rs-android-arm-eabi')
|
|
107
107
|
const bindingPackageVersion = require('@xingwangzhe/force-rs-android-arm-eabi/package.json').version
|
|
108
|
-
if (bindingPackageVersion !== '0.
|
|
109
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
108
|
+
if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
109
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
110
110
|
}
|
|
111
111
|
return binding
|
|
112
112
|
} catch (e) {
|
|
@@ -126,8 +126,8 @@ function requireNative() {
|
|
|
126
126
|
try {
|
|
127
127
|
const binding = require('@xingwangzhe/force-rs-win32-x64-gnu')
|
|
128
128
|
const bindingPackageVersion = require('@xingwangzhe/force-rs-win32-x64-gnu/package.json').version
|
|
129
|
-
if (bindingPackageVersion !== '0.
|
|
130
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
129
|
+
if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
130
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
131
131
|
}
|
|
132
132
|
return binding
|
|
133
133
|
} catch (e) {
|
|
@@ -142,8 +142,8 @@ function requireNative() {
|
|
|
142
142
|
try {
|
|
143
143
|
const binding = require('@xingwangzhe/force-rs-win32-x64-msvc')
|
|
144
144
|
const bindingPackageVersion = require('@xingwangzhe/force-rs-win32-x64-msvc/package.json').version
|
|
145
|
-
if (bindingPackageVersion !== '0.
|
|
146
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
145
|
+
if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
146
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
147
147
|
}
|
|
148
148
|
return binding
|
|
149
149
|
} catch (e) {
|
|
@@ -159,8 +159,8 @@ function requireNative() {
|
|
|
159
159
|
try {
|
|
160
160
|
const binding = require('@xingwangzhe/force-rs-win32-ia32-msvc')
|
|
161
161
|
const bindingPackageVersion = require('@xingwangzhe/force-rs-win32-ia32-msvc/package.json').version
|
|
162
|
-
if (bindingPackageVersion !== '0.
|
|
163
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
162
|
+
if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
163
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
164
164
|
}
|
|
165
165
|
return binding
|
|
166
166
|
} catch (e) {
|
|
@@ -175,8 +175,8 @@ function requireNative() {
|
|
|
175
175
|
try {
|
|
176
176
|
const binding = require('@xingwangzhe/force-rs-win32-arm64-msvc')
|
|
177
177
|
const bindingPackageVersion = require('@xingwangzhe/force-rs-win32-arm64-msvc/package.json').version
|
|
178
|
-
if (bindingPackageVersion !== '0.
|
|
179
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
178
|
+
if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
179
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
180
180
|
}
|
|
181
181
|
return binding
|
|
182
182
|
} catch (e) {
|
|
@@ -194,8 +194,8 @@ function requireNative() {
|
|
|
194
194
|
try {
|
|
195
195
|
const binding = require('@xingwangzhe/force-rs-darwin-universal')
|
|
196
196
|
const bindingPackageVersion = require('@xingwangzhe/force-rs-darwin-universal/package.json').version
|
|
197
|
-
if (bindingPackageVersion !== '0.
|
|
198
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
197
|
+
if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
198
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
199
199
|
}
|
|
200
200
|
return binding
|
|
201
201
|
} catch (e) {
|
|
@@ -210,8 +210,8 @@ function requireNative() {
|
|
|
210
210
|
try {
|
|
211
211
|
const binding = require('@xingwangzhe/force-rs-darwin-x64')
|
|
212
212
|
const bindingPackageVersion = require('@xingwangzhe/force-rs-darwin-x64/package.json').version
|
|
213
|
-
if (bindingPackageVersion !== '0.
|
|
214
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
213
|
+
if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
214
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
215
215
|
}
|
|
216
216
|
return binding
|
|
217
217
|
} catch (e) {
|
|
@@ -226,8 +226,8 @@ function requireNative() {
|
|
|
226
226
|
try {
|
|
227
227
|
const binding = require('@xingwangzhe/force-rs-darwin-arm64')
|
|
228
228
|
const bindingPackageVersion = require('@xingwangzhe/force-rs-darwin-arm64/package.json').version
|
|
229
|
-
if (bindingPackageVersion !== '0.
|
|
230
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
229
|
+
if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
230
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
231
231
|
}
|
|
232
232
|
return binding
|
|
233
233
|
} catch (e) {
|
|
@@ -246,8 +246,8 @@ function requireNative() {
|
|
|
246
246
|
try {
|
|
247
247
|
const binding = require('@xingwangzhe/force-rs-freebsd-x64')
|
|
248
248
|
const bindingPackageVersion = require('@xingwangzhe/force-rs-freebsd-x64/package.json').version
|
|
249
|
-
if (bindingPackageVersion !== '0.
|
|
250
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
249
|
+
if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
250
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
251
251
|
}
|
|
252
252
|
return binding
|
|
253
253
|
} catch (e) {
|
|
@@ -262,8 +262,8 @@ function requireNative() {
|
|
|
262
262
|
try {
|
|
263
263
|
const binding = require('@xingwangzhe/force-rs-freebsd-arm64')
|
|
264
264
|
const bindingPackageVersion = require('@xingwangzhe/force-rs-freebsd-arm64/package.json').version
|
|
265
|
-
if (bindingPackageVersion !== '0.
|
|
266
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
265
|
+
if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
266
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
267
267
|
}
|
|
268
268
|
return binding
|
|
269
269
|
} catch (e) {
|
|
@@ -283,8 +283,8 @@ function requireNative() {
|
|
|
283
283
|
try {
|
|
284
284
|
const binding = require('@xingwangzhe/force-rs-linux-x64-musl')
|
|
285
285
|
const bindingPackageVersion = require('@xingwangzhe/force-rs-linux-x64-musl/package.json').version
|
|
286
|
-
if (bindingPackageVersion !== '0.
|
|
287
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
286
|
+
if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
287
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
288
288
|
}
|
|
289
289
|
return binding
|
|
290
290
|
} catch (e) {
|
|
@@ -299,8 +299,8 @@ function requireNative() {
|
|
|
299
299
|
try {
|
|
300
300
|
const binding = require('@xingwangzhe/force-rs-linux-x64-gnu')
|
|
301
301
|
const bindingPackageVersion = require('@xingwangzhe/force-rs-linux-x64-gnu/package.json').version
|
|
302
|
-
if (bindingPackageVersion !== '0.
|
|
303
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
302
|
+
if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
303
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
304
304
|
}
|
|
305
305
|
return binding
|
|
306
306
|
} catch (e) {
|
|
@@ -317,8 +317,8 @@ function requireNative() {
|
|
|
317
317
|
try {
|
|
318
318
|
const binding = require('@xingwangzhe/force-rs-linux-arm64-musl')
|
|
319
319
|
const bindingPackageVersion = require('@xingwangzhe/force-rs-linux-arm64-musl/package.json').version
|
|
320
|
-
if (bindingPackageVersion !== '0.
|
|
321
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
320
|
+
if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
321
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
322
322
|
}
|
|
323
323
|
return binding
|
|
324
324
|
} catch (e) {
|
|
@@ -333,8 +333,8 @@ function requireNative() {
|
|
|
333
333
|
try {
|
|
334
334
|
const binding = require('@xingwangzhe/force-rs-linux-arm64-gnu')
|
|
335
335
|
const bindingPackageVersion = require('@xingwangzhe/force-rs-linux-arm64-gnu/package.json').version
|
|
336
|
-
if (bindingPackageVersion !== '0.
|
|
337
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
336
|
+
if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
337
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
338
338
|
}
|
|
339
339
|
return binding
|
|
340
340
|
} catch (e) {
|
|
@@ -351,8 +351,8 @@ function requireNative() {
|
|
|
351
351
|
try {
|
|
352
352
|
const binding = require('@xingwangzhe/force-rs-linux-arm-musleabihf')
|
|
353
353
|
const bindingPackageVersion = require('@xingwangzhe/force-rs-linux-arm-musleabihf/package.json').version
|
|
354
|
-
if (bindingPackageVersion !== '0.
|
|
355
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
354
|
+
if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
355
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
356
356
|
}
|
|
357
357
|
return binding
|
|
358
358
|
} catch (e) {
|
|
@@ -367,8 +367,8 @@ function requireNative() {
|
|
|
367
367
|
try {
|
|
368
368
|
const binding = require('@xingwangzhe/force-rs-linux-arm-gnueabihf')
|
|
369
369
|
const bindingPackageVersion = require('@xingwangzhe/force-rs-linux-arm-gnueabihf/package.json').version
|
|
370
|
-
if (bindingPackageVersion !== '0.
|
|
371
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
370
|
+
if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
371
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
372
372
|
}
|
|
373
373
|
return binding
|
|
374
374
|
} catch (e) {
|
|
@@ -385,8 +385,8 @@ function requireNative() {
|
|
|
385
385
|
try {
|
|
386
386
|
const binding = require('@xingwangzhe/force-rs-linux-loong64-musl')
|
|
387
387
|
const bindingPackageVersion = require('@xingwangzhe/force-rs-linux-loong64-musl/package.json').version
|
|
388
|
-
if (bindingPackageVersion !== '0.
|
|
389
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
388
|
+
if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
389
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
390
390
|
}
|
|
391
391
|
return binding
|
|
392
392
|
} catch (e) {
|
|
@@ -401,8 +401,8 @@ function requireNative() {
|
|
|
401
401
|
try {
|
|
402
402
|
const binding = require('@xingwangzhe/force-rs-linux-loong64-gnu')
|
|
403
403
|
const bindingPackageVersion = require('@xingwangzhe/force-rs-linux-loong64-gnu/package.json').version
|
|
404
|
-
if (bindingPackageVersion !== '0.
|
|
405
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
404
|
+
if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
405
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
406
406
|
}
|
|
407
407
|
return binding
|
|
408
408
|
} catch (e) {
|
|
@@ -419,8 +419,8 @@ function requireNative() {
|
|
|
419
419
|
try {
|
|
420
420
|
const binding = require('@xingwangzhe/force-rs-linux-riscv64-musl')
|
|
421
421
|
const bindingPackageVersion = require('@xingwangzhe/force-rs-linux-riscv64-musl/package.json').version
|
|
422
|
-
if (bindingPackageVersion !== '0.
|
|
423
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
422
|
+
if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
423
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
424
424
|
}
|
|
425
425
|
return binding
|
|
426
426
|
} catch (e) {
|
|
@@ -435,8 +435,8 @@ function requireNative() {
|
|
|
435
435
|
try {
|
|
436
436
|
const binding = require('@xingwangzhe/force-rs-linux-riscv64-gnu')
|
|
437
437
|
const bindingPackageVersion = require('@xingwangzhe/force-rs-linux-riscv64-gnu/package.json').version
|
|
438
|
-
if (bindingPackageVersion !== '0.
|
|
439
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
438
|
+
if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
439
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
440
440
|
}
|
|
441
441
|
return binding
|
|
442
442
|
} catch (e) {
|
|
@@ -452,8 +452,8 @@ function requireNative() {
|
|
|
452
452
|
try {
|
|
453
453
|
const binding = require('@xingwangzhe/force-rs-linux-ppc64-gnu')
|
|
454
454
|
const bindingPackageVersion = require('@xingwangzhe/force-rs-linux-ppc64-gnu/package.json').version
|
|
455
|
-
if (bindingPackageVersion !== '0.
|
|
456
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
455
|
+
if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
456
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
457
457
|
}
|
|
458
458
|
return binding
|
|
459
459
|
} catch (e) {
|
|
@@ -468,8 +468,8 @@ function requireNative() {
|
|
|
468
468
|
try {
|
|
469
469
|
const binding = require('@xingwangzhe/force-rs-linux-s390x-gnu')
|
|
470
470
|
const bindingPackageVersion = require('@xingwangzhe/force-rs-linux-s390x-gnu/package.json').version
|
|
471
|
-
if (bindingPackageVersion !== '0.
|
|
472
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
471
|
+
if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
472
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
473
473
|
}
|
|
474
474
|
return binding
|
|
475
475
|
} catch (e) {
|
|
@@ -488,8 +488,8 @@ function requireNative() {
|
|
|
488
488
|
try {
|
|
489
489
|
const binding = require('@xingwangzhe/force-rs-openharmony-arm64')
|
|
490
490
|
const bindingPackageVersion = require('@xingwangzhe/force-rs-openharmony-arm64/package.json').version
|
|
491
|
-
if (bindingPackageVersion !== '0.
|
|
492
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
491
|
+
if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
492
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
493
493
|
}
|
|
494
494
|
return binding
|
|
495
495
|
} catch (e) {
|
|
@@ -504,8 +504,8 @@ function requireNative() {
|
|
|
504
504
|
try {
|
|
505
505
|
const binding = require('@xingwangzhe/force-rs-openharmony-x64')
|
|
506
506
|
const bindingPackageVersion = require('@xingwangzhe/force-rs-openharmony-x64/package.json').version
|
|
507
|
-
if (bindingPackageVersion !== '0.
|
|
508
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
507
|
+
if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
508
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
509
509
|
}
|
|
510
510
|
return binding
|
|
511
511
|
} catch (e) {
|
|
@@ -520,8 +520,8 @@ function requireNative() {
|
|
|
520
520
|
try {
|
|
521
521
|
const binding = require('@xingwangzhe/force-rs-openharmony-arm')
|
|
522
522
|
const bindingPackageVersion = require('@xingwangzhe/force-rs-openharmony-arm/package.json').version
|
|
523
|
-
if (bindingPackageVersion !== '0.
|
|
524
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
523
|
+
if (bindingPackageVersion !== '0.3.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
524
|
+
throw new Error(`Native binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
525
525
|
}
|
|
526
526
|
return binding
|
|
527
527
|
} catch (e) {
|
|
@@ -661,8 +661,8 @@ if (!nativeBinding || forceWasi) {
|
|
|
661
661
|
if (!candidateFailed) {
|
|
662
662
|
if (process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
663
663
|
const bindingPackageVersion = require('@xingwangzhe/force-rs-wasm32-wasi/package.json').version
|
|
664
|
-
if (bindingPackageVersion !== '0.
|
|
665
|
-
throw new Error(`WASI binding package version mismatch, expected 0.
|
|
664
|
+
if (bindingPackageVersion !== '0.3.0') {
|
|
665
|
+
throw new Error(`WASI binding package version mismatch, expected 0.3.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
666
666
|
}
|
|
667
667
|
}
|
|
668
668
|
wasiBinding = require('@xingwangzhe/force-rs-wasm32-wasi')
|
package/package.json
CHANGED
|
@@ -1,32 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xingwangzhe/force-rs",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Fast force-directed 3D graph layout powered by Rust
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"types": "index.d.ts",
|
|
7
|
-
"license": "MIT",
|
|
8
|
-
"author": "xingwangzhe",
|
|
9
|
-
"repository": {
|
|
10
|
-
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/xingwangzhe/force-rs.git"
|
|
12
|
-
},
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Fast force-directed 3D graph layout powered by Rust, a stackless Barnes-Hut octree, reusable CSR links and Rayon parallelism. Typed-array tick and bounded batched simulation APIs.",
|
|
13
5
|
"keywords": [
|
|
14
|
-
"
|
|
6
|
+
"3d",
|
|
15
7
|
"barnes-hut",
|
|
16
8
|
"d3-force",
|
|
17
9
|
"d3-force-3d",
|
|
18
|
-
"napi-rs",
|
|
19
|
-
"rust",
|
|
20
|
-
"graph-layout",
|
|
21
10
|
"force-directed",
|
|
22
|
-
"
|
|
23
|
-
"
|
|
11
|
+
"force-layout",
|
|
12
|
+
"graph-layout",
|
|
13
|
+
"napi-rs",
|
|
14
|
+
"octree",
|
|
15
|
+
"rust"
|
|
24
16
|
],
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"author": "xingwangzhe",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/xingwangzhe/force-rs.git"
|
|
22
|
+
},
|
|
25
23
|
"files": [
|
|
26
24
|
"index.d.ts",
|
|
27
25
|
"index.js",
|
|
28
26
|
"force-rs.*.node"
|
|
29
27
|
],
|
|
28
|
+
"main": "index.js",
|
|
29
|
+
"types": "index.d.ts",
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "napi build --platform --release",
|
|
32
|
+
"test": "node --test force.test.mjs",
|
|
33
|
+
"benchmark": "node benchmark.mjs",
|
|
34
|
+
"lint": "oxlint",
|
|
35
|
+
"artifacts": "napi artifacts",
|
|
36
|
+
"build:pgo": "node scripts/build-pgo.mjs",
|
|
37
|
+
"benchmark:pgo": "node scripts/build-pgo.mjs --compare"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@napi-rs/cli": "^3.10.8",
|
|
41
|
+
"oxlint": "^1.88.0",
|
|
42
|
+
"typescript": "~6.0.3"
|
|
43
|
+
},
|
|
30
44
|
"napi": {
|
|
31
45
|
"binaryName": "force-rs",
|
|
32
46
|
"targets": [
|
|
@@ -40,17 +54,5 @@
|
|
|
40
54
|
},
|
|
41
55
|
"engines": {
|
|
42
56
|
"node": ">= 18"
|
|
43
|
-
},
|
|
44
|
-
"scripts": {
|
|
45
|
-
"build": "napi build --platform --release",
|
|
46
|
-
"test": "node --test force.test.mjs",
|
|
47
|
-
"benchmark": "node benchmark.mjs",
|
|
48
|
-
"lint": "oxlint",
|
|
49
|
-
"artifacts": "napi artifacts"
|
|
50
|
-
},
|
|
51
|
-
"devDependencies": {
|
|
52
|
-
"@napi-rs/cli": "^3.10.5",
|
|
53
|
-
"oxlint": "^1.85.0",
|
|
54
|
-
"typescript": "^7.0.2"
|
|
55
57
|
}
|
|
56
58
|
}
|