planck-deterministic/package.json
caelum0x 4c82aabc5d feat: deterministic cross-platform math kernel
Replaces every host-libm call in the physics source with a kernel built from
IEEE-754-exact operations only, so simulation results are bit-identical on
ARM64/JavaScriptCore and x86-64/V8.

ECMAScript permits Math.sin/cos/atan2 to be implementation-dependent
approximations, and Rot.setAngle and Sweep.getTransform call them for every
rotating body on every step. Without this, a replay recorded on mobile does
not reproduce on desktop, which breaks replay verification and leaderboards.

- add src/common/DeterministicMath.ts (fdlibm-derived polynomials and
  Cody-Waite range reduction, plus a seeded mulberry32 PRNG)
- rewire the nine hoisted aliases in Math, Matrix, Rot, Sweep and
  dynamics/Position; no host libm call remains in src/
- export DeterministicMath and seedRandom for consumers
- add determinism tests, incl. a free fall matching the analytic solution

All 14 upstream tests still pass (22 total).
2026-09-15 00:52:19 +03:00

113 lines
3.6 KiB
JSON

{
"name": "planck-deterministic",
"version": "1.5.0-det.1",
"description": "planck.js with a cross-platform deterministic math kernel \u2014 bit-identical simulation on ARM64/JavaScriptCore and x86-64/V8, so replays are portable between mobile and desktop builds.",
"homepage": "https://github.com/caelum0x/planck-deterministic",
"keywords": [
"box2d",
"html5",
"javascript",
"typescript",
"game",
"physics",
"engine",
"2d",
"mobile",
"deterministic",
"replay",
"rollback",
"lockstep",
"cross-platform"
],
"license": "MIT",
"repository": {
"type": "git",
"url": "git://github.com/caelum0x/planck-deterministic.git"
},
"author": "Ali Shakiba",
"contributors": [
"Erin Catto",
"Ali Shakiba",
"Oliver Zell"
],
"type": "commonjs",
"sideEffects": [
"./dist/planck-with-testbed.*"
],
"module": "dist/planck.mjs",
"main": "dist/planck.js",
"jsdelivr": "dist/planck.min.js",
"unpkg": "dist/planck.min.js",
"types": "index.d.ts",
"exports": {
".": {
"types": "./dist/planck.d.ts",
"import": "./dist/planck.mjs",
"default": "./dist/planck.js"
},
"./with-testbed": {
"types": "./dist/planck-with-testbed.d.ts",
"import": "./dist/planck-with-testbed.mjs",
"default": "./dist/planck-with-testbed.js"
},
"./dist/*": "./dist/*"
},
"engines": {
"node": ">=24.0"
},
"peerDependencies": {
"stage-js": "^1.0.0-alpha.12"
},
"devDependencies": {
"@changesets/cli": "^2.29.8",
"@eslint/js": "^9.39.2",
"@types/chai": "^5.2.3",
"@vitest/coverage-v8": "^4.0.18",
"ajv": "^8.17.1",
"eslint": "^9.39.2",
"eslint-config-prettier": "^10.1.8",
"prettier": "^3.8.1",
"rimraf": "^6.1.2",
"rollup-plugin-license": "^3.6.0",
"sinon": "^21.0.1",
"terser": "^5.46.0",
"tsd": "^0.33.0",
"tslib": "^2.8.1",
"typedoc": "^0.28.16",
"typedoc-plugin-markdown": "^4.10.0",
"typescript-eslint": "^8.54.0",
"vite": "^6.4.1",
"vite-plugin-dts-bundle-generator": "^2.1.2",
"vite-plugin-pages": "^0.33.3",
"vite-plugin-typescript": "^1.0.4",
"vite-plugin-typescript-transform": "^1.3.1",
"vitepress": "^2.0.0-alpha.16",
"vitest": "^4.0.18"
},
"scripts": {
"lint": "eslint './src/**/*.ts' './testbed/**/*.ts'",
"pretty": "prettier --write './src/**/*.ts' './testbed/**/*.ts'",
"lint:example": "eslint --fix './example/**/*.ts'",
"pretty:example": "prettier --write './example/**/*.ts'",
"test": "vitest run",
"test:coverage": "vitest run --coverage",
"test:types": "tsd --typings=./dist/planck.d.ts && tsd --typings=./dist/planck-with-testbed.d.ts",
"preflight": "npm run lint && npm run test:types && npm run test",
"testbed": "npm run dev",
"dev": "vite",
"build": "rimraf ./dist/* && vite build && BUILD_TESTBED=true vite build && npm run terser-core && npm run terser-testbed",
"terser-core": "terser ./dist/planck.js -o ./dist/planck.min.js --source-map",
"terser-testbed": "terser ./dist/planck-with-testbed.js -o ./dist/planck-with-testbed.min.js --source-map",
"watch": "vite build --watch",
"preview": "vite preview",
"benchmark": "git log -n 1 && vite-node ./benchmark/node",
"changeset": "changeset",
"bump": "changeset version",
"release": "changeset publish",
"typedoc": "typedoc --options typedoc.json && mv ./docs/pages/api/README.md ./docs/pages/api/index.md",
"docs:dev": "vitepress dev docs",
"docs:build": "vitepress build docs",
"docs:preview": "vitepress preview docs"
}
}