Skip to content

The VS Code of video editing, built for agents.

TypeScript

Enhance runtime package with new motion system and text animation utilities

konstantin-pauluse76ed7d60917
diff --git a/package-lock.json b/package-lock.json
index 81cc57c1..e3aac64d 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -11,7 +11,10 @@
"workspaces": [
"apps/*",
"packages/*"
- ]
+ ],
+ "devDependencies": {
+ "patch-package": "^8.0.1"
+ }
},
"apps/cli": {
"name": "@diffusionstudio/cli",
@@ -4608,6 +4611,13 @@
"dev": true,
"license": "Apache-2.0"
},
+ "node_modules/@yarnpkg/lockfile": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz",
+ "integrity": "sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ==",
+ "dev": true,
+ "license": "BSD-2-Clause"
+ },
"node_modules/abbrev": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
@@ -5277,6 +5287,56 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
+ "node_modules/call-bind": {
+ "version": "1.0.9",
+ "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.9.tgz",
+ "integrity": "sha512-a/hy+pNsFUTR+Iz8TCJvXudKVLAnz/DyeSUo10I5yvFDQJBFU2s9uqQpoSrJlroHUKoKqzg+epxyP9lqFdzfBQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "call-bind-apply-helpers": "^1.0.2",
+ "es-define-property": "^1.0.1",
+ "get-intrinsic": "^1.3.0",
+ "set-function-length": "^1.2.2"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/call-bind-apply-helpers": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
+ "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "es-errors": "^1.3.0",
+ "function-bind": "^1.1.2"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
+ "node_modules/call-bound": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz",
+ "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "call-bind-apply-helpers": "^1.0.2",
+ "get-intrinsic": "^1.3.0"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
"node_modules/callsites": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz",
@@ -5351,6 +5411,22 @@
"node": ">=6.0"
}
},
+ "node_modules/ci-info": {
+ "version": "3.9.0",
+ "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.9.0.tgz",
+ "integrity": "sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==",
+ "dev": true,
+ "funding": [
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/sibiraj-s"
+ }
+ ],
+ "license": "MIT",
+ "engines": {
+ "node": ">=8"
+ }
+ },
"node_modules/clean-stack": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz",
@@ -5844,7 +5920,6 @@
"integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==",
"dev": true,
"license": "MIT",
- "optional": true,
"dependencies": {
"es-define-property": "^1.0.0",
"es-errors": "^1.3.0",
@@ -6004,6 +6079,21 @@
"tn1150": "^0.1.0"
}
},
+ "node_modules/dunder-proto": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
+ "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "call-bind-apply-helpers": "^1.0.1",
+ "es-errors": "^1.3.0",
+ "gopd": "^1.2.0"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
"node_modules/eastasianwidth": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz",
@@ -6201,7 +6291,6 @@
"integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
"dev": true,
"license": "MIT",
- "optional": true,
"engines": {
"node": ">= 0.4"
}
@@ -6223,6 +6312,19 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/es-object-atoms": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz",
+ "integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "es-errors": "^1.3.0"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
"node_modules/es6-error": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/es6-error/-/es6-error-4.1.1.tgz",
@@ -6866,6 +6968,16 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
+ "node_modules/find-yarn-workspace-root": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/find-yarn-workspace-root/-/find-yarn-workspace-root-2.0.0.tgz",
+ "integrity": "sha512-1IMnbjt4KzsQfnhnzNd8wUEgXZ44IzZaZmnLYx7D5FZlaHt2gW20Cri8Q+E/t5tIj4+epTBub+2Zxu/vNILzqQ==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "dependencies": {
+ "micromatch": "^4.0.2"
+ }
+ },
"node_modules/flat-cache": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-4.0.1.tgz",
@@ -7054,6 +7166,31 @@
"node": "6.* || 8.* || >= 10.*"
}
},
+ "node_modules/get-intrinsic": {
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
+ "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "call-bind-apply-helpers": "^1.0.2",
+ "es-define-property": "^1.0.1",
+ "es-errors": "^1.3.0",
+ "es-object-atoms": "^1.1.1",
+ "function-bind": "^1.1.2",
+ "get-proto": "^1.0.1",
+ "gopd": "^1.2.0",
+ "has-symbols": "^1.1.0",
+ "hasown": "^2.0.2",
+ "math-intrinsics": "^1.1.0"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
"node_modules/get-package-info": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/get-package-info/-/get-package-info-1.0.0.tgz",
@@ -7087,6 +7224,20 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/get-proto": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",
+ "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "dunder-proto": "^1.0.1",
+ "es-object-atoms": "^1.0.0"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
"node_modules/get-stream": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz",
@@ -7216,7 +7367,6 @@
"integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
"dev": true,
"license": "MIT",
- "optional": true,
"engines": {
"node": ">= 0.4"
},
@@ -7273,7 +7423,6 @@
"integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==",
"dev": true,
"license": "MIT",
- "optional": true,
"dependencies": {
"es-define-property": "^1.0.0"
},
@@ -7281,6 +7430,19 @@
"url": "https://github.com/sponsors/ljharb"
}
},
+ "node_modules/has-symbols": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
+ "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
"node_modules/hasown": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz",
@@ -7587,6 +7749,22 @@
"url": "https://github.com/sponsors/ljharb"
}
},
+ "node_modules/is-docker": {
+ "version": "2.2.1",
+ "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz",
+ "integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==",
+ "dev": true,
+ "license": "MIT",
+ "bin": {
+ "is-docker": "cli.js"
+ },
+ "engines": {
+ "node": ">=8"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/is-extglob": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
@@ -7736,6 +7914,26 @@
"url": "https://github.com/sponsors/mesqueeb"
}
},
+ "node_modules/is-wsl": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz",
+ "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "is-docker": "^2.0.0"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
+ "node_modules/isarray": {
+ "version": "2.0.5",
+ "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz",
+ "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/isbinaryfile": {
"version": "4.0.10",
"resolved": "https://registry.npmjs.org/isbinaryfile/-/isbinaryfile-4.0.10.tgz",
@@ -7852,6 +8050,26 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/json-stable-stringify": {
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.3.0.tgz",
+ "integrity": "sha512-qtYiSSFlwot9XHtF9bD9c7rwKjr+RecWT//ZnPvSmEjpV5mmPOCN4j8UjY5hbjNkOwZ/jQv3J6R1/pL7RwgMsg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "call-bind": "^1.0.8",
+ "call-bound": "^1.0.4",
+ "isarray": "^2.0.5",
+ "jsonify": "^0.0.1",
+ "object-keys": "^1.1.1"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
"node_modules/json-stable-stringify-without-jsonify": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz",
@@ -7892,6 +8110,16 @@
"graceful-fs": "^4.1.6"
}
},
+ "node_modules/jsonify": {
+ "version": "0.0.1",
+ "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.1.tgz",
+ "integrity": "sha512-2/Ki0GcmuqSrgFyelQq9M05y7PS0mEwuIzrf3f1fPqkVDVRvZrPZtVSMHxdgo8Aq0sxAOb/cr2aqqA3LeWHVPg==",
+ "dev": true,
+ "license": "Public Domain",
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
"node_modules/jsonpointer": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-5.0.1.tgz",
@@ -7930,6 +8158,16 @@
"json-buffer": "3.0.1"
}
},
+ "node_modules/klaw-sync": {
+ "version": "6.0.0",
+ "resolved": "https://registry.npmjs.org/klaw-sync/-/klaw-sync-6.0.0.tgz",
+ "integrity": "sha512-nIeuVSzdCCs6TDPTqI8w1Yre34sSq7AkZ4B3sfOBbI2CgVSB4Du4aLQijFU2+lhAFCwt9+42Hel6lQNIv6AntQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "graceful-fs": "^4.1.11"
+ }
+ },
"node_modules/known-css-properties": {
"version": "0.30.0",
"resolved": "https://registry.npmjs.org/known-css-properties/-/known-css-properties-0.30.0.tgz",
@@ -8595,6 +8833,16 @@
"node": ">=10"
}
},
+ "node_modules/math-intrinsics": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
+ "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
"node_modules/mdn-data": {
"version": "2.0.30",
"resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.30.tgz",
@@ -9163,7 +9411,6 @@
"integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==",
"dev": true,
"license": "MIT",
- "optional": true,
"engines": {
"node": ">= 0.4"
}
@@ -9194,6 +9441,23 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
+ "node_modules/open": {
+ "version": "7.4.2",
+ "resolved": "https://registry.npmjs.org/open/-/open-7.4.2.tgz",
+ "integrity": "sha512-MVHddDVweXZF3awtlAS+6pgKLlm/JgxZ90+/NBurBoQctVOOB/zDdVjcyPzQ+0laDGbsWgrRkflI65sQeOgT9Q==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "is-docker": "^2.0.0",
+ "is-wsl": "^2.1.1"
+ },
+ "engines": {
+ "node": ">=8"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sindresorhus"
+ }
+ },
"node_modules/optionator": {
"version": "0.9.4",
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz",
@@ -9447,6 +9711,46 @@
"url": "https://github.com/inikulin/parse5?sponsor=1"
}
},
+ "node_modules/patch-package": {
+ "version": "8.0.1",
+ "resolved": "https://registry.npmjs.org/patch-package/-/patch-package-8.0.1.tgz",
+ "integrity": "sha512-VsKRIA8f5uqHQ7NGhwIna6Bx6D9s/1iXlA1hthBVBEbkq+t4kXD0HHt+rJhf/Z+Ci0F/HCB2hvn0qLdLG+Qxlw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@yarnpkg/lockfile": "^1.1.0",
+ "chalk": "^4.1.2",
+ "ci-info": "^3.7.0",
+ "cross-spawn": "^7.0.3",
+ "find-yarn-workspace-root": "^2.0.0",
+ "fs-extra": "^10.0.0",
+ "json-stable-stringify": "^1.0.2",
+ "klaw-sync": "^6.0.0",
+ "minimist": "^1.2.6",
+ "open": "^7.4.2",
+ "semver": "^7.5.3",
+ "slash": "^2.0.0",
+ "tmp": "^0.2.4",
+ "yaml": "^2.2.2"
+ },
+ "bin": {
+ "patch-package": "index.js"
+ },
+ "engines": {
+ "node": ">=14",
+ "npm": ">5"
+ }
+ },
+ "node_modules/patch-package/node_modules/tmp": {
+ "version": "0.2.7",
+ "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.7.tgz",
+ "integrity": "sha512-e0votIpp4Uo2AJYSzVHV6xCcawuiez3DzqDAbrTc3YxBkplN6e+dM13ZeIcZnDg/QpSuU2zfZ3rzwY8ukEnaXw==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=14.14"
+ }
+ },
"node_modules/path-exists": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
@@ -10318,6 +10622,24 @@
"seroval": "^1.0"
}
},
+ "node_modules/set-function-length": {
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz",
+ "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "define-data-property": "^1.1.4",
+ "es-errors": "^1.3.0",
+ "function-bind": "^1.1.2",
+ "get-intrinsic": "^1.2.4",
+ "gopd": "^1.0.1",
+ "has-property-descriptors": "^1.0.2"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ }
+ },
"node_modules/shebang-command": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
@@ -10354,6 +10676,16 @@
"url": "https://github.com/sponsors/isaacs"
}
},
+ "node_modules/slash": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz",
+ "integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=6"
+ }
+ },
"node_modules/slice-ansi": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-5.0.0.tgz",
@@ -11844,6 +12176,22 @@
"dev": true,
"license": "ISC"
},
+ "node_modules/yaml": {
+ "version": "2.9.0",
+ "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.9.0.tgz",
+ "integrity": "sha512-2AvhNX3mb8zd6Zy7INTtSpl1F15HW6Wnqj0srWlkKLcpYl/gMIMJiyuGq2KeI2YFxUPjdlB+3Lc10seMLtL4cA==",
+ "dev": true,
+ "license": "ISC",
+ "bin": {
+ "yaml": "bin.mjs"
+ },
+ "engines": {
+ "node": ">= 14.6"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/eemeli"
+ }
+ },
"node_modules/yargs": {
"version": "17.7.3",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.3.tgz",
@@ -11981,6 +12329,7 @@
"version": "0.1.0",
"license": "MPL-2.0",
"dependencies": {
+ "animejs": "^4.4.1",
"koota": "^0.6.6",
"mediabunny": "^1.32.2"
},
diff --git a/package.json b/package.json
index 2af0069d..cbfa26b7 100644
--- a/package.json
+++ b/package.json
@@ -4,7 +4,10 @@
"private": true,
"license": "MPL-2.0",
"type": "module",
- "workspaces": ["apps/*", "packages/*"],
+ "workspaces": [
+ "apps/*",
+ "packages/*"
+ ],
"scripts": {
"dev": "npm run dev:web",
"dev:web": "npm run dev --workspace=@diffusionstudio/web",
@@ -14,7 +17,11 @@
"build:desktop": "npm run build --workspace=@diffusionstudio/desktop",
"make": "npm run make --workspace=@diffusionstudio/desktop",
"release": "node scripts/release.mjs",
+ "postinstall": "patch-package",
"lint": "npm run lint --workspaces --if-present",
"check": "npm run check --workspaces --if-present && tsc -p examples --noEmit"
+ },
+ "devDependencies": {
+ "patch-package": "^8.0.1"
}
}
diff --git a/packages/runtime/package.json b/packages/runtime/package.json
index 8fb13a31..446a096a 100644
--- a/packages/runtime/package.json
+++ b/packages/runtime/package.json
@@ -21,6 +21,7 @@
"video"
],
"dependencies": {
+ "animejs": "^4.4.1",
"koota": "^0.6.6",
"mediabunny": "^1.32.2"
},
diff --git a/packages/runtime/src/index.ts b/packages/runtime/src/index.ts
index e0b18e7a..25fa8317 100644
--- a/packages/runtime/src/index.ts
+++ b/packages/runtime/src/index.ts
@@ -2,6 +2,7 @@ export * from './constants';
export * from './traits';
export * from './world/create-world';
export * from './world/serialize';
+export * from './world/store';
export * from './queries';
export * from './systems';
export * from './math';
diff --git a/packages/runtime/src/queries/hierarchy.ts b/packages/runtime/src/queries/hierarchy.ts
index 661972fa..6eaaa330 100644
--- a/packages/runtime/src/queries/hierarchy.ts
+++ b/packages/runtime/src/queries/hierarchy.ts
@@ -4,16 +4,34 @@
import { Not } from 'koota';
-import { ChildOf, Deleted, Computed, Name, Playback, PlaybackRate } from '../traits';
-import { isScene } from './predicates';
+import { ChildOf, Deleted, Computed, Name, Playback, PlaybackRate, DocumentRoot } from '../traits';
+import { isDocument, isScene } from './predicates';
import type { Entity, World, QueryParameter } from 'koota';
+/** The world's document root (see DocumentRoot). */
+export function getDocument(world: World): Entity {
+ const document = world.queryFirst(DocumentRoot);
+ if (document === undefined) throw new Error('World has no document root');
+ return document;
+}
+
export function getParentEntity(entity: Entity | null | undefined): Entity | null {
if (!entity) return null;
return entity.targetFor(ChildOf) ?? null;
}
+/**
+ * Parent node, or null when the parent is the document root (or missing).
+ * Use this wherever "top-level" matters; getParentEntity returns the raw
+ * parent including the document.
+ */
+export function getParentNode(entity: Entity | null | undefined): Entity | null {
+ const parent = getParentEntity(entity);
+ if (parent === null || isDocument(parent)) return null;
+ return parent;
+}
+
/**
* Nearest ancestor of `entity` (excluding `entity` itself) that is a scene, or null.
*/
@@ -62,9 +80,9 @@ export function getNodeLocalFrame(node: Entity): number {
let current: Entity | null = node;
while (current) {
- const parent = getParentEntity(current);
+ const parent = getParentNode(current);
- // must be a root playback entity
+ // must be a top-level playback entity
if (current.has(Playback) && parent === null) {
const currentTime = current.get(Computed)?.localTime ?? 0;
return Math.round((currentTime - delay) * playbackRate);
diff --git a/packages/runtime/src/queries/predicates.ts b/packages/runtime/src/queries/predicates.ts
index 227a93a7..c1ef94b4 100644
--- a/packages/runtime/src/queries/predicates.ts
+++ b/packages/runtime/src/queries/predicates.ts
@@ -4,12 +4,16 @@
import {
Scene, Group, Sequential, Audio, AdjustmentLayer, Caption, Geometry, IsMask,
- Paint, Cache,
+ Paint, Cache, DocumentRoot,
} from '../traits';
import { GeometryType, PaintType } from '../constants';
import type { Entity } from 'koota';
+export function isDocument(entity: Entity): boolean {
+ return entity.has(DocumentRoot);
+}
+
export function isScene(entity: Entity): boolean {
return entity.has(Scene);
}
diff --git a/packages/runtime/src/systems/index.ts b/packages/runtime/src/systems/index.ts
index 420eaf42..dffd197c 100644
--- a/packages/runtime/src/systems/index.ts
+++ b/packages/runtime/src/systems/index.ts
@@ -1,2 +1,3 @@
// Deterministic systems. Browser-only systems (input, keyboard, camera, hud, dom) stay in apps/web.
export * from './transform';
+export * from './motion';
diff --git a/packages/runtime/src/systems/motion.ts b/packages/runtime/src/systems/motion.ts
index 0d2cb817..0eff544d 100644
--- a/packages/runtime/src/systems/motion.ts
+++ b/packages/runtime/src/systems/motion.ts
@@ -1 +1,507 @@
-// Motion system: keyframe interpolation and animation (was systems/motion.ts).
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+import { Not, Or } from 'koota';
+import { cubicBezier, steps, spring } from 'animejs';
+
+import { store } from '../world/store';
+import {
+ Geometry, Group, AdjustmentLayer, Deleted, Hidden, Culled,
+ Computed, Cache, Animation, KeyframeTrack, Keyframe, Trim, Chars,
+ UniformScale, Position, Offset, Rotation, Scale, Skew, Size, Appearance,
+ Color, Blur, Volume, Effect, StrokeStyle, CornerRadius, MixedCornerRadius,
+ ColorStop,
+} from '../traits';
+import { AnimationType, AnimationPhase } from '../constants';
+import { revealChars, revealWords, scrambleChars } from '../utils/text-motion';
+
+import type { Entity, World } from 'koota';
+
+/**
+ * Reset an entity's Computed values back to its authored trait values.
+ * Motion (animations + keyframes) then layers on top each frame.
+ */
+export function resetAnimatedValues(world: World, entity: Entity | null) {
+ if (entity === null) return;
+
+ const computed = store(world, Computed);
+ const eid = entity.id();
+
+ computed.positionX[eid] = store(world, Position).x[eid] ?? 0;
+ computed.positionY[eid] = store(world, Position).y[eid] ?? 0;
+ computed.offsetX[eid] = store(world, Offset).x[eid] ?? 0;
+ computed.offsetY[eid] = store(world, Offset).y[eid] ?? 0;
+ computed.rotation[eid] = store(world, Rotation).value[eid] ?? 0;
+ computed.skewX[eid] = store(world, Skew).x[eid] ?? 0;
+ computed.skewY[eid] = store(world, Skew).y[eid] ?? 0;
+ computed.opacity[eid] = store(world, Appearance).opacity[eid] ?? 1;
+ computed.color[eid] = store(world, Color).value[eid] ?? 0;
+ computed.blur[eid] = store(world, Blur).value[eid] ?? 0;
+ computed.volume[eid] = store(world, Volume).value[eid] ?? 0;
+ computed.strokeWidth[eid] = store(world, StrokeStyle).width[eid] ?? 1;
+ computed.cornerRadius[eid] = store(world, CornerRadius).value[eid] ?? 0;
+ computed.cornerRadiusTopLeft[eid] = store(world, MixedCornerRadius).topLeft[eid] ?? 0;
+ computed.cornerRadiusTopRight[eid] = store(world, MixedCornerRadius).topRight[eid] ?? 0;
+ computed.cornerRadiusBottomRight[eid] = store(world, MixedCornerRadius).bottomRight[eid] ?? 0;
+ computed.cornerRadiusBottomLeft[eid] = store(world, MixedCornerRadius).bottomLeft[eid] ?? 0;
+ computed.stopOffset[eid] = store(world, ColorStop).offset[eid] ?? 0;
+ computed.stopColor[eid] = store(world, ColorStop).color[eid] ?? 0;
+ computed.stopOpacity[eid] = store(world, ColorStop).opacity[eid] ?? 1;
+ computed.chars[eid] = store(world, Chars).value[eid] ?? '';
+
+ if (entity.has(UniformScale)) {
+ computed.scaleX[eid] = store(world, UniformScale).value[eid] ?? 1;
+ computed.scaleY[eid] = store(world, UniformScale).value[eid] ?? 1;
+ } else {
+ computed.scaleX[eid] = store(world, Scale).x[eid] ?? 1;
+ computed.scaleY[eid] = store(world, Scale).y[eid] ?? 1;
+ }
+}
+
+/**
+ * Apply a preset animation to a node at the given normalized progress.
+ */
+function applyAnimation(world: World, entity: Entity, anim: Entity, progress: number) {
+ const computed = store(world, Computed);
+ const animation = store(world, Animation);
+ const chars = store(world, Chars);
+ const eid = entity.id();
+ const aid = anim.id();
+
+ switch (animation.type[aid]) {
+ case AnimationType.FADE: {
+ const phase = animation.phase[aid];
+ const func = cubicBezier(0.1, 0.7, 0.5, 1);
+ const eased = clamp01(func(progress));
+ computed.opacity[eid] = phase === AnimationPhase.OUT ? 1 - eased : eased;
+ break;
+ }
+ case AnimationType.GAIN: {
+ const phase = animation.phase[aid];
+ const func = cubicBezier(0.4, 0.095, 0.546, 0.875);
+ const eased = clamp01(func(progress));
+ computed.volume[eid] = phase === AnimationPhase.OUT ? 1 - eased : eased;
+ break;
+ }
+ case AnimationType.GROW: {
+ const phase = animation.phase[aid];
+ const func = cubicBezier(0.1, 0.7, 0.5, 1);
+ const eased = clamp01(func(progress));
+ const t = phase === AnimationPhase.OUT ? eased : 1 - eased;
+ const scale = 1 - 0.5 * t;
+ computed.scaleX[eid] = scale;
+ computed.scaleY[eid] = scale;
+ break;
+ }
+ case AnimationType.SHRINK: {
+ const phase = animation.phase[aid];
+ const func = cubicBezier(0.1, 0.7, 0.5, 1);
+ const eased = clamp01(func(progress));
+ const t = phase === AnimationPhase.OUT ? eased : 1 - eased;
+ const scale = 1 + 0.5 * t;
+ computed.scaleX[eid] = scale;
+ computed.scaleY[eid] = scale;
+ break;
+ }
+ case AnimationType.BLUR: {
+ const phase = animation.phase[aid];
+ const func = phase === AnimationPhase.OUT ? cubicBezier(0.4, 0, 1, 1) : cubicBezier(0.33, 0, 0.2, 1);
+ const eased = clamp01(func(progress));
+ computed.blur[eid] = phase === AnimationPhase.OUT ? lerp(0, 24, eased) : lerp(24, 0, eased);
+ break;
+ }
+ case AnimationType.SLIDE_LEFT:
+ case AnimationType.SLIDE_RIGHT:
+ case AnimationType.SLIDE_UP:
+ case AnimationType.SLIDE_DOWN: {
+ const phase = animation.phase[aid];
+ const type = animation.type[aid];
+ const func = cubicBezier(0.1, 0.7, 0.5, 1);
+ const eased = clamp01(func(progress));
+ const t = phase === AnimationPhase.OUT ? eased : 1 - eased;
+
+ const sign = phase === AnimationPhase.OUT ? -1 : 1;
+ if (type === AnimationType.SLIDE_LEFT) {
+ computed.offsetX[eid] = sign * 100 * t;
+ } else if (type === AnimationType.SLIDE_RIGHT) {
+ computed.offsetX[eid] = sign * -100 * t;
+ } else if (type === AnimationType.SLIDE_UP) {
+ computed.offsetY[eid] = sign * 100 * t;
+ } else if (type === AnimationType.SLIDE_DOWN) {
+ computed.offsetY[eid] = sign * -100 * t;
+ }
+ computed.opacity[eid] = 1 - t;
+ break;
+ }
+ case AnimationType.SPIN: {
+ const phase = animation.phase[aid];
+ const func = cubicBezier(0.44, 0.02, 0.252, 0.992);
+ const eased = clamp01(func(progress));
+ const t = phase === AnimationPhase.OUT ? eased : 1 - eased;
+ const scale = 1 - t;
+ computed.scaleX[eid] = scale;
+ computed.scaleY[eid] = scale;
+ computed.rotation[eid] = -45 * t;
+ break;
+ }
+ case AnimationType.TWIST: {
+ const phase = animation.phase[aid];
+ const func = cubicBezier(0.1, 0.7, 0.5, 1);
+ const eased = clamp01(func(progress));
+ const t = phase === AnimationPhase.OUT ? eased : 1 - eased;
+ const scale = 1 + t;
+ computed.scaleX[eid] = scale;
+ computed.scaleY[eid] = scale;
+ computed.rotation[eid] = -10 * t;
+ computed.offsetX[eid] = -30 * t;
+ computed.offsetY[eid] = -30 * t;
+ break;
+ }
+ case AnimationType.APPEAR_WORD: {
+ const phase = animation.phase[aid];
+ const t = phase === AnimationPhase.OUT ? progress : 1 - progress;
+ computed.chars[eid] = revealWords(chars.value[eid] ?? '', 1 - t);
+ break;
+ }
+ case AnimationType.APPEAR_CHAR: {
+ const phase = animation.phase[aid];
+ const t = phase === AnimationPhase.OUT ? progress : 1 - progress;
+ computed.chars[eid] = revealChars(chars.value[eid] ?? '', 1 - t);
+ break;
+ }
+ case AnimationType.SCRAMBLE: {
+ const phase = animation.phase[aid];
+ const t = phase === AnimationPhase.OUT ? progress : 1 - progress;
+ computed.chars[eid] = scrambleChars(chars.value[eid] ?? '', 1 - t);
+ break;
+ }
+ }
+}
+
+export function motionSystem(world: World): void {
+ const computed = store(world, Computed);
+ const cache = store(world, Cache);
+ const animation = store(world, Animation);
+ const keyframeTrack = store(world, KeyframeTrack);
+ const trimStore = store(world, Trim);
+ const worldProps = getPropertyPaths(world);
+
+ for (const entity of world.query(
+ Or(Geometry, Group, AdjustmentLayer),
+ Not(Deleted), Not(Hidden), Not(Culled),
+ )) {
+ const eid = entity.id();
+
+ if (computed.visibility[eid] === 0) continue;
+
+ const animations = cache.animations[eid] ?? [];
+ const keyframeTracks = cache.keyframeTracks[eid] ?? [];
+ if (animations.length === 0 && keyframeTracks.length === 0) continue;
+
+ resetAnimatedValues(world, entity);
+
+ let trimStart = 0;
+ let trimEnd = computed.duration[eid];
+
+ if (entity.has(Trim)) {
+ trimStart = trimStore.start[eid];
+ trimEnd = trimStore.end[eid] ?? trimEnd;
+ }
+
+ const localFrame = computed.localTime[eid];
+
+ // 1: Preset animations (FADE/GAIN/GROW/SHRINK/BLUR/SLIDE)
+ for (const anim of animations) {
+ const aid = anim.id();
+ const duration = animation.duration[aid] ?? 0;
+ if (duration <= 0) continue;
+
+ const delay = animation.delay[aid] ?? 0;
+ const isOut = animation.phase[aid] === AnimationPhase.OUT;
+ const windowStart = isOut
+ ? trimEnd - duration - delay
+ : trimStart + delay;
+ const windowEnd = windowStart + duration;
+ if (isOut ? localFrame < windowStart : localFrame >= windowEnd) continue;
+
+ const progress = clamp01((localFrame - windowStart) / duration);
+ applyAnimation(world, entity, anim, progress);
+ }
+
+ // 2: Keyframe tracks
+ for (const track of keyframeTracks) {
+ const tid = track.id();
+ const property = keyframeTrack.property[tid] as PropertyPath;
+ const target = keyframeTrack.target[tid];
+ const keyframes = cache.keyframes[tid] ?? [];
+ const result = sampleTrack(world, keyframes, localFrame, property);
+ if (result === null || target == null) continue;
+ worldProps[property].computed[target.id()] = result;
+ }
+
+ // Uniform scale is authored/animated as scaleX only; mirror it onto scaleY.
+ if (entity.has(UniformScale)) {
+ computed.scaleY[eid] = computed.scaleX[eid];
+ }
+ }
+}
+
+/**
+ * Keyframeable properties: dot-path string to the computed (per-frame
+ * resolved) and authored (document) store arrays.
+ */
+export function getPropertyPaths(world: World) {
+ const computed = store(world, Computed);
+ return {
+ 'position.x': {
+ computed: computed.positionX,
+ authored: store(world, Position).x,
+ },
+ 'position.y': {
+ computed: computed.positionY,
+ authored: store(world, Position).y,
+ },
+ 'offset.x': {
+ computed: computed.offsetX,
+ authored: store(world, Offset).x,
+ },
+ 'offset.y': {
+ computed: computed.offsetY,
+ authored: store(world, Offset).y,
+ },
+ 'rotation': {
+ computed: computed.rotation,
+ authored: store(world, Rotation).value,
+ },
+ 'scale.x': {
+ computed: computed.scaleX,
+ authored: store(world, Scale).x,
+ },
+ 'scale.y': {
+ computed: computed.scaleY,
+ authored: store(world, Scale).y,
+ },
+ 'scale': {
+ computed: computed.scaleX,
+ authored: store(world, UniformScale).value,
+ },
+ 'skew.x': {
+ computed: computed.skewX,
+ authored: store(world, Skew).x,
+ },
+ 'skew.y': {
+ computed: computed.skewY,
+ authored: store(world, Skew).y,
+ },
+ 'width': {
+ computed: computed.width,
+ authored: store(world, Size).width,
+ },
+ 'height': {
+ computed: computed.height,
+ authored: store(world, Size).height,
+ },
+ 'opacity': {
+ computed: computed.opacity,
+ authored: store(world, Appearance).opacity,
+ },
+ 'color': {
+ computed: computed.color,
+ authored: store(world, Color).value,
+ },
+ 'blur': {
+ computed: computed.blur,
+ authored: store(world, Blur).value,
+ },
+ 'volume': {
+ computed: computed.volume,
+ authored: store(world, Volume).value,
+ },
+ 'effect.value': {
+ computed: computed.value,
+ authored: store(world, Effect).value,
+ },
+ 'stroke.width': {
+ computed: computed.strokeWidth,
+ authored: store(world, StrokeStyle).width,
+ },
+ 'vertexRadius': {
+ computed: computed.cornerRadius,
+ authored: store(world, CornerRadius).value,
+ },
+ 'mixedVertexRadius.topLeft': {
+ computed: computed.cornerRadiusTopLeft,
+ authored: store(world, MixedCornerRadius).topLeft,
+ },
+ 'mixedVertexRadius.topRight': {
+ computed: computed.cornerRadiusTopRight,
+ authored: store(world, MixedCornerRadius).topRight,
+ },
+ 'mixedVertexRadius.bottomRight': {
+ computed: computed.cornerRadiusBottomRight,
+ authored: store(world, MixedCornerRadius).bottomRight,
+ },
+ 'mixedVertexRadius.bottomLeft': {
+ computed: computed.cornerRadiusBottomLeft,
+ authored: store(world, MixedCornerRadius).bottomLeft,
+ },
+ 'stop.offset': {
+ computed: computed.stopOffset,
+ authored: store(world, ColorStop).offset,
+ },
+ 'stop.color': {
+ computed: computed.stopColor,
+ authored: store(world, ColorStop).color,
+ },
+ 'stop.opacity': {
+ computed: computed.stopOpacity,
+ authored: store(world, ColorStop).opacity,
+ },
+ 'chars': {
+ computed: computed.chars,
+ authored: store(world, Chars).value,
+ },
+ };
+}
+
+export type PropertyPath = keyof ReturnType<typeof getPropertyPaths>;
+
+// ─── Easing ─────────────────────────────────────────────────
+
+type EasingFunction = (t: number) => number;
+
+const easingCache = new Map<string, EasingFunction>();
+
+/**
+ * Parse an easing descriptor string and return an easing function.
+ * Returns null for empty/undefined (= default linear interpolation).
+ * Supported formats:
+ * "steps(9)" or "steps(9,true)" → animejs steps(n, fromStart?)
+ * "cubicBezier(0.25,0.1,0.25,1)" → animejs cubicBezier(x1,y1,x2,y2)
+ * "spring(0.5,500)" → animejs spring({ bounce, duration })
+ */
+function resolveEasing(descriptor: string | undefined): EasingFunction | null {
+ if (!descriptor || descriptor === '') return null;
+
+ const cached = easingCache.get(descriptor);
+ if (cached) return cached;
+
+ let fn: EasingFunction | null = null;
+
+ const stepsMatch = descriptor.match(/^steps\((\d+)(?:,(true|false))?\)$/);
+ if (stepsMatch) {
+ const n = Number.parseInt(stepsMatch[1]!, 10);
+ const fromStart = stepsMatch[2] === 'true';
+ fn = steps(n, fromStart);
+ }
+
+ const bezierMatch = descriptor.match(/^cubicBezier\((-?[\d.]+),(-?[\d.]+),(-?[\d.]+),(-?[\d.]+)\)$/);
+ if (bezierMatch) {
+ const [, x1, y1, x2, y2] = bezierMatch;
+ fn = cubicBezier(Number(x1), Number(y1), Number(x2), Number(y2));
+ }
+
+ const springMatch = descriptor.match(/^spring\(([\d.-]+),([\d.-]+)\)$/);
+ if (springMatch) {
+ const [, bounce, duration] = springMatch;
+ const s = spring({
+ bounce: Number(bounce),
+ duration: Number(duration),
+ });
+ fn = (t: number) => s.ease(t);
+ }
+
+ if (fn) {
+ easingCache.set(descriptor, fn);
+ return fn;
+ }
+
+ return null;
+}
+
+/**
+ * Sample a presorted aggregated keyframe track at a local frame.
+ * Returns null only if the track has no keyframes.
+ */
+function sampleTrack(
+ world: World,
+ keyframes: Entity[],
+ frame: number,
+ property: PropertyPath,
+): number | null {
+ const keyframe = store(world, Keyframe);
+ if (keyframes.length === 0) return null;
+
+ if (keyframes.length === 1) {
+ return keyframe.value[keyframes[0]!.id()]!;
+ }
+
+ const firstValue = keyframe.value[keyframes[0]!.id()]!;
+ const lastValue = keyframe.value[keyframes[keyframes.length - 1]!.id()]!;
+
+ const firstFrame = keyframe.time[keyframes[0]!.id()]!;
+ const lastFrame = keyframe.time[keyframes[keyframes.length - 1]!.id()]!;
+
+ if (frame <= firstFrame) {
+ return firstValue;
+ }
+
+ if (frame >= lastFrame) {
+ return lastValue;
+ }
+
+ for (let i = 0; i < keyframes.length - 1; i++) {
+ const start = keyframe.time[keyframes[i]!.id()]!;
+ const end = keyframe.time[keyframes[i + 1]!.id()]!;
+ if (frame < start || frame > end) continue;
+
+ const span = end - start;
+ if (span <= 0) continue;
+
+ let progress = Math.max(0, Math.min(1, (frame - start) / span));
+
+ const easingFn = resolveEasing(keyframe.easing[keyframes[i]!.id()]);
+ if (easingFn) {
+ progress = easingFn(progress);
+ }
+
+ const startValue = keyframe.value[keyframes[i]!.id()]!;
+ const endValue = keyframe.value[keyframes[i + 1]!.id()]!;
+
+ if (property === 'color' || property === 'stop.color') {
+ return lerpColor(startValue, endValue, progress);
+ }
+
+ // Linear interpolation
+ return startValue + (endValue - startValue) * progress;
+ }
+
+ return lastValue;
+}
+
+/**
+ * Channel-wise linear interpolation between two packed 0xRRGGBB colors.
+ * Linear interpolation on the packed integer bleeds bits between channels
+ * and produces wrong intermediate hues.
+ */
+function lerpColor(from: number, to: number, progress: number): number {
+ const r0 = (from >> 16) & 0xFF;
+ const g0 = (from >> 8) & 0xFF;
+ const b0 = from & 0xFF;
+ const r1 = (to >> 16) & 0xFF;
+ const g1 = (to >> 8) & 0xFF;
+ const b1 = to & 0xFF;
+ const r = Math.round(r0 + (r1 - r0) * progress);
+ const g = Math.round(g0 + (g1 - g0) * progress);
+ const b = Math.round(b0 + (b1 - b0) * progress);
+ return (r << 16) | (g << 8) | b;
+}
+
+function clamp01(value: number): number {
+ return Math.max(0, Math.min(1, value));
+}
+
+function lerp(from: number, to: number, progress: number): number {
+ return from + (to - from) * progress;
+}
diff --git a/packages/runtime/src/systems/transform.ts b/packages/runtime/src/systems/transform.ts
index fab35297..2469d6bd 100644
--- a/packages/runtime/src/systems/transform.ts
+++ b/packages/runtime/src/systems/transform.ts
@@ -2,14 +2,15 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-import { Not, Or, getStore } from 'koota';
+import { Not, Or } from 'koota';
+import { store } from '../world/store';
import {
ChildOf, Geometry, Group, Deleted, Hidden, Sequential, AdjustmentLayer,
Culled, Flip, Anchor, Computed, Cache, LocalTransform, WorldTransform,
WorldBounds, Camera, RenderSurface,
} from '../traits';
-import { getParentEntity } from '../queries/hierarchy';
+import { getDocument, getParentNode } from '../queries/hierarchy';
import {
multiply2D,
@@ -25,18 +26,18 @@ import {
import type { Entity, World } from 'koota';
// This system writes derived per-frame data (LocalTransform, WorldTransform,
-// WorldBounds, Computed group bounds) straight into trait stores via getStore:
-// no snapshots, no change events, matching the bitecs SoA hot path.
+// WorldBounds, Computed group bounds) straight into trait stores: no
+// snapshots, no change events, matching the bitecs SoA hot path.
/**
* Compute the local 2D affine matrix from Offset, Rotation, Scale,
* Anchor, Skew and Size. Stores the result in LocalTransform.
*/
export function computeLocalMatrix(world: World, entity: Entity): void {
- const flip = getStore(world, Flip);
- const anchor = getStore(world, Anchor);
- const computed = getStore(world, Computed);
- const local = getStore(world, LocalTransform);
+ const flip = store(world, Flip);
+ const anchor = store(world, Anchor);
+ const computed = store(world, Computed);
+ const local = store(world, LocalTransform);
const eid = entity.id();
const positionX = computed.positionX[eid] + computed.offsetX[eid];
@@ -69,8 +70,8 @@ export function computeLocalMatrix(world: World, entity: Entity): void {
* For top-level entities (no entity parent), the camera × DPR matrix is used.
*/
export function computeWorldTransform(world: World, entity: Entity, parentEntity: Entity | null): void {
- const worldStore = getStore(world, WorldTransform);
- const localStore = getStore(world, LocalTransform);
+ const worldStore = store(world, WorldTransform);
+ const localStore = store(world, LocalTransform);
const eid = entity.id();
if (localStore.a[eid] === undefined) {
@@ -120,9 +121,9 @@ export function computeWorldTransform(world: World, entity: Entity, parentEntity
* Compute world-space AABB from world transform and size.
*/
export function computeWorldBounds(world: World, entity: Entity): void {
- const boundsStore = getStore(world, WorldBounds);
- const worldStore = getStore(world, WorldTransform);
- const computed = getStore(world, Computed);
+ const boundsStore = store(world, WorldBounds);
+ const worldStore = store(world, WorldTransform);
+ const computed = store(world, Computed);
const eid = entity.id();
const worldMat: Mat2D = {
@@ -152,7 +153,7 @@ function cullEntity(world: World, entity: Entity, parentEntity: Entity | null):
// Without a render surface (headless world) nothing is culled.
const canvas = world.get(RenderSurface)?.canvas;
if (canvas) {
- const boundsStore = getStore(world, WorldBounds);
+ const boundsStore = store(world, WorldBounds);
const eid = entity.id();
intersect = aabbsIntersect({
minX: boundsStore.minX[eid],
@@ -189,12 +190,12 @@ function cullEntity(world: World, entity: Entity, parentEntity: Entity | null):
* resolution here.
*/
export function computeGroupBounds(world: World, entity: Entity): void {
- const computed = getStore(world, Computed);
- const localStore = getStore(world, LocalTransform);
+ const computed = store(world, Computed);
+ const localStore = store(world, LocalTransform);
const eid = entity.id();
if (entity.has(Sequential)) {
- const parent = getParentEntity(entity);
+ const parent = getParentNode(entity);
if (parent !== null) {
const pid = parent.id();
computed.width[eid] = computed.width[pid];
@@ -241,18 +242,18 @@ export function computeGroupBounds(world: World, entity: Entity): void {
}
function adjustLayers(world: World, adjust: Entity): void {
- const computed = getStore(world, Computed);
- const localStore = getStore(world, LocalTransform);
+ const computed = store(world, Computed);
+ const localStore = store(world, LocalTransform);
const aid = adjust.id();
if (computed.visibility[aid] === 0 || adjust.has(Hidden)) return;
// get next non sequential parent
let slot = adjust;
- let parent = getParentEntity(slot);
+ let parent = getParentNode(slot);
while (parent !== null && parent.has(Sequential)) {
slot = parent;
- parent = getParentEntity(slot);
+ parent = getParentNode(slot);
}
if (parent === null) return;
@@ -316,12 +317,8 @@ export function transformSystem(world: World): void {
}
};
- // koota cannot express "has no ChildOf target" as an indexed query
- // (bitecs allowed Not(ChildOf('*'))), so roots are filtered per candidate.
- for (const entity of world.query(Or(Geometry, Group), Not(Deleted))) {
- if (entity.targetFor(ChildOf) === undefined) {
- walk(entity, null);
- }
+ for (const entity of world.query(Or(Geometry, Group), ChildOf(getDocument(world)), Not(Deleted))) {
+ walk(entity, null);
}
for (const adjust of world.query(AdjustmentLayer, Not(Deleted))) {
diff --git a/packages/runtime/src/traits/world.ts b/packages/runtime/src/traits/world.ts
index d8d20265..e77e1761 100644
--- a/packages/runtime/src/traits/world.ts
+++ b/packages/runtime/src/traits/world.ts
@@ -15,6 +15,12 @@ import type { FontSource } from '../fonts/types';
export const Project = trait({ id: '' });
+// Tag on the single document root entity every runtime world owns. All
+// rendered entities are its descendants (ChildOf), so "top-level" means
+// "direct child of the document", never "has no parent". Destroying it
+// cascades through the whole document tree.
+export const DocumentRoot = trait();
+
export type RuntimeMode = 'realtime' | 'offline-video' | 'offline-audio';
export const Mode = trait({ value: 'realtime' as RuntimeMode });
diff --git a/packages/runtime/src/utils/index.ts b/packages/runtime/src/utils/index.ts
index 47779cc2..4bae7df2 100644
--- a/packages/runtime/src/utils/index.ts
+++ b/packages/runtime/src/utils/index.ts
@@ -2,3 +2,4 @@
export * from './text';
export * from './live-mounts';
export * from './sort';
+export * from './text-motion';
diff --git a/packages/runtime/src/utils/text-motion.ts b/packages/runtime/src/utils/text-motion.ts
new file mode 100644
index 00000000..0d35f566
--- /dev/null
+++ b/packages/runtime/src/utils/text-motion.ts
@@ -0,0 +1,246 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+// Text animation helpers used by the motion system.
+// All functions take the target text and a normalized ratio (0..1), returning
+// the partial display string for that progress.
+
+export function revealWords(chars: string, ratio: number): string {
+ if (ratio >= 1) return chars;
+ if (ratio <= 0) return '';
+ const words = chars.split(/(\s+)/);
+ const wordTokens = words.filter((_, i) => i % 2 === 0);
+ const visibleCount = Math.floor(ratio * wordTokens.length);
+ if (visibleCount <= 0) return '';
+ let out = '';
+ let shown = 0;
+ for (let i = 0; i < words.length; i++) {
+ if (i % 2 === 0) {
+ if (shown >= visibleCount) break;
+ out += words[i];
+ shown++;
+ } else {
+ if (shown >= visibleCount) break;
+ out += words[i];
+ }
+ }
+ return out;
+}
+
+export function revealChars(chars: string, ratio: number): string {
+ if (ratio >= 1) return chars;
+ if (ratio <= 0) return '';
+ const visibleCount = Math.floor(ratio * chars.length);
+ return chars.slice(0, visibleCount);
+}
+
+// ─── Scramble Text ──────────────────────────────────────────
+// Adapted from anime.js scrambleText (src/text/scramble.js).
+// The motion system has no DOM target, prevTween, or wall-clock duration —
+// progress is the normalized ratio (0 = blank, 1 = settled). Real-time
+// concepts (revealRate/interval/settleDuration) collapse onto SCRAMBLE_SETTLE_RATIO
+// (per-char active window) and SCRAMBLE_SETTLE_RATE (refreshes across the animation).
+// Structural arrays are cached per text; scramble character lookups are stateless,
+// keyed by (seed, position, step) so timeline scrubbing stays deterministic.
+
+const SCRAMBLE_CHARSETS: Record<string, string> = {
+ lowercase: 'a-z',
+ uppercase: 'A-Z',
+ numbers: '0-9',
+ symbols: '!%#_|*+=',
+ braille: '⠀-⣿',
+ blocks: '▀-▟',
+ shades: '░-▓',
+};
+
+const SCRAMBLE_DEFAULT_CHARS = 'a-zA-Z0-9!%#_';
+const SCRAMBLE_SETTLE_RATIO = 0.3;
+const SCRAMBLE_SETTLE_RATE = 30;
+const SCRAMBLE_FROM: 'left' | 'right' | 'center' | 'random' | number = 'left';
+const SCRAMBLE_REVERSED = false;
+const SCRAMBLE_PERTURBATION = 0;
+const SCRAMBLE_CURSOR = '';
+const SCRAMBLE_CACHE_LIMIT = 64;
+
+type ScrambleState = {
+ animLength: number;
+ endLength: number;
+ characters: string;
+ cursorChars: string;
+ cursorLen: number;
+ cursorZone: number;
+ settleSpacing: number;
+ stepRatio: number;
+ charStarts: Float32Array;
+ charEnds: Float32Array;
+ seed: number;
+};
+
+const scrambleStateCache = new Map<string, ScrambleState>();
+
+function expandCharRanges(str: string): string {
+ let result = '';
+ for (let i = 0, l = str.length; i < l; i++) {
+ if (i + 2 < l && str[i + 1] === '-' && str.charCodeAt(i) < str.charCodeAt(i + 2)) {
+ const start = str.charCodeAt(i);
+ const end = str.charCodeAt(i + 2);
+ for (let c = start; c <= end; c++) result += String.fromCharCode(c);
+ i += 2;
+ } else {
+ result += str[i];
+ }
+ }
+ return result;
+}
+
+function hashTextToSeed(text: string): number {
+ let h = 2166136261;
+ for (let i = 0; i < text.length; i++) {
+ h ^= text.charCodeAt(i);
+ h = Math.imul(h, 16777619);
+ }
+ return h >>> 0;
+}
+
+function createSeededRandom(seed: number): (min: number, max: number) => number {
+ let state = (seed >>> 0) || 1;
+ return (min, max) => {
+ state = (state + 0x6d2b79f5) | 0;
+ let t = Math.imul(state ^ (state >>> 15), 1 | state);
+ t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
+ const r = ((t ^ (t >>> 14)) >>> 0) / 4294967296;
+ return Math.floor(r * (max - min + 1)) + min;
+ };
+}
+
+function pickScrambleChar(seed: number, position: number, step: number, charset: string): string {
+ let h = (seed ^ Math.imul(position + 1, 0x9e3779b1) ^ Math.imul(step + 1, 0x85ebca6b)) >>> 0;
+ h = Math.imul(h ^ (h >>> 16), 0x85ebca6b);
+ h = Math.imul(h ^ (h >>> 13), 0xc2b2ae35);
+ h ^= h >>> 16;
+ return charset[(h >>> 0) % charset.length];
+}
+
+function buildScrambleState(text: string): ScrambleState {
+ const characters = expandCharRanges(SCRAMBLE_CHARSETS[SCRAMBLE_DEFAULT_CHARS] ?? SCRAMBLE_DEFAULT_CHARS);
+ const cursorChars = SCRAMBLE_CURSOR;
+ const cursorLen = cursorChars.length;
+
+ const seed = hashTextToSeed(text);
+ const rng = createSeededRandom(seed);
+
+ const animLength = text.length;
+ const endLength = text.length;
+
+ const settleRatio = SCRAMBLE_SETTLE_RATIO;
+ const settleSpacing = animLength > 0 ? (1 - settleRatio) / animLength : 0;
+ const cursorZone = cursorLen * settleSpacing;
+ const stepRatio = 1 / SCRAMBLE_SETTLE_RATE;
+
+ const charOrder = new Int32Array(animLength);
+ if (SCRAMBLE_FROM === 'random') {
+ for (let i = 0; i < animLength; i++) charOrder[i] = i;
+ for (let i = animLength - 1; i > 0; i--) {
+ const j = rng(0, i);
+ const tmp = charOrder[i];
+ charOrder[i] = charOrder[j];
+ charOrder[j] = tmp;
+ }
+ } else {
+ const ref = SCRAMBLE_FROM === 'right' ? animLength - 1
+ : SCRAMBLE_FROM === 'center' ? (animLength - 1) / 2
+ : typeof SCRAMBLE_FROM === 'number' ? SCRAMBLE_FROM
+ : 0;
+ const indices = new Array<number>(animLength);
+ for (let i = 0; i < animLength; i++) indices[i] = i;
+ indices.sort((a, b) => Math.abs(a - ref) - Math.abs(b - ref));
+ for (let i = 0; i < animLength; i++) charOrder[indices[i]] = i;
+ }
+ if (SCRAMBLE_REVERSED) {
+ const last = animLength - 1;
+ for (let i = 0; i < animLength; i++) charOrder[i] = last - charOrder[i];
+ }
+
+ const charStarts = new Float32Array(animLength);
+ const charEnds = new Float32Array(animLength);
+ const scale = SCRAMBLE_PERTURBATION > 0 ? SCRAMBLE_PERTURBATION * settleRatio : 0;
+ for (let c = 0; c < animLength; c++) {
+ const so = scale > 0 ? ((rng(0, 2000) - 1000) / 1000) * scale : 0;
+ const eo = scale > 0 ? ((rng(0, 2000) - 1000) / 1000) * scale : 0;
+ charStarts[c] = charOrder[c] * settleSpacing + so;
+ charEnds[c] = Math.ceil((charStarts[c] + settleRatio + eo) / stepRatio) * stepRatio;
+ }
+
+ return {
+ animLength,
+ endLength,
+ characters,
+ cursorChars,
+ cursorLen,
+ cursorZone,
+ settleSpacing,
+ stepRatio,
+ charStarts,
+ charEnds,
+ seed,
+ };
+}
+
+function getScrambleState(text: string): ScrambleState {
+ let state = scrambleStateCache.get(text);
+ if (!state) {
+ if (scrambleStateCache.size >= SCRAMBLE_CACHE_LIMIT) {
+ const firstKey = scrambleStateCache.keys().next().value;
+ if (firstKey !== undefined) scrambleStateCache.delete(firstKey);
+ }
+ state = buildScrambleState(text);
+ scrambleStateCache.set(text, state);
+ }
+ return state;
+}
+
+export function scrambleChars(chars: string, ratio: number): string {
+ if (chars.length === 0) return '';
+ if (ratio >= 1) return chars;
+
+ const {
+ animLength, endLength, characters, charStarts, charEnds,
+ cursorChars, cursorLen, cursorZone, settleSpacing, stepRatio, seed,
+ } = getScrambleState(chars);
+ const hasCursor = cursorLen > 0;
+ const step = (ratio / stepRatio) | 0;
+
+ let out = '';
+ for (let c = 0; c < animLength; c++) {
+ const charStart = charStarts[c];
+ const charEnd = charEnds[c];
+
+ // Settled: target glyph
+ if (ratio >= charEnd) {
+ if (c < endLength) out += chars[c];
+ continue;
+ }
+
+ const isSpace = c < endLength && chars[c] === ' ';
+ if (isSpace) {
+ out += ' ';
+ continue;
+ }
+
+ // Pre-transition: override scramble char (length stays constant — equivalent to
+ // anime.js override=true with startLength == animLength)
+ if (ratio < charStart) {
+ out += pickScrambleChar(seed, c, step, characters);
+ continue;
+ }
+
+ // Active zone: cursor sub-zone, then scramble
+ if (hasCursor && ratio - charStart < cursorZone) {
+ out += cursorChars[cursorLen - 1 - (((ratio - charStart) / settleSpacing) | 0)];
+ } else {
+ out += pickScrambleChar(seed, c, step, characters);
+ }
+ }
+ return out;
+}
diff --git a/packages/runtime/src/world/create-world.ts b/packages/runtime/src/world/create-world.ts
index 342bc516..ceecbd4a 100644
--- a/packages/runtime/src/world/create-world.ts
+++ b/packages/runtime/src/world/create-world.ts
@@ -5,6 +5,7 @@
import { createWorld } from 'koota';
import {
+ DocumentRoot,
Project,
Mode,
ActiveScene,
@@ -18,9 +19,6 @@ import {
Mounts,
FramePromises,
} from '../traits/world';
-import {
- Anchor, Cache, Computed, Flip, LocalTransform, WorldBounds, WorldTransform,
-} from '../traits';
/**
* World with the headless runtime singletons attached. The host injects its
@@ -44,11 +42,8 @@ export function createRuntimeWorld(projectId: string) {
FramePromises,
);
- // koota registers a trait's store on first add/query; getStore alone
- // throws. Prime the stores the per-frame systems write through getStore
- // (bitecs-style, without the trait necessarily being on the entity) so
- // they run safely on a fresh world.
- world.spawn(Anchor, Cache, Computed, Flip, LocalTransform, WorldBounds, WorldTransform).destroy();
+ // The document root all rendered entities hang off (see DocumentRoot).
+ world.spawn(DocumentRoot);
return world;
}
diff --git a/packages/runtime/src/world/serialize.ts b/packages/runtime/src/world/serialize.ts
index 92262ae3..51e77c0f 100644
--- a/packages/runtime/src/world/serialize.ts
+++ b/packages/runtime/src/world/serialize.ts
@@ -14,8 +14,9 @@ import {
Chars, TextStyle,
Delay, PlaybackRate, Trim, Playback, Sequential, Transition, ClipHeight, Expanded,
Volume, Muted,
- KeyframeTrack, Keyframe, Animation,
+ KeyframeTrack, Keyframe, Animation, DocumentRoot,
} from '../traits';
+import { getDocument } from '../queries/hierarchy';
import type { Entity, World } from 'koota';
@@ -229,7 +230,7 @@ export function serializeEntity(entity: Entity): EntityRecord {
record.Expanded = {};
}
const parent = entity.targetFor(ChildOf);
- if (parent !== undefined) {
+ if (parent !== undefined && !parent.has(DocumentRoot)) {
record.ChildOf = parent;
}
if (entity.has(IsMask)) {
@@ -639,6 +640,8 @@ export function cloneFromRecords(world: World, records: EntityRecord[]) {
eidMap.set(record.eid, world.spawn());
}
+ const document = getDocument(world);
+
for (const record of records) {
const entity = eidMap.get(record.eid)!;
const copy = { ...record };
@@ -646,6 +649,9 @@ export function cloneFromRecords(world: World, records: EntityRecord[]) {
try {
if (copy.ChildOf !== undefined) {
copy.ChildOf = eidMap.get(copy.ChildOf) ?? copy.ChildOf;
+ } else {
+ // Parentless record = top-level entity; hang it off the document.
+ copy.ChildOf = document;
}
deserializeEntity(entity, copy);
diff --git a/packages/runtime/src/world/store.ts b/packages/runtime/src/world/store.ts
new file mode 100644
index 00000000..7fb4a792
--- /dev/null
+++ b/packages/runtime/src/world/store.ts
@@ -0,0 +1,28 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+import { getStore } from 'koota';
+
+import type { ExtractStore, Trait, World } from 'koota';
+
+const registered = new WeakMap<World, WeakSet<Trait>>();
+
+/**
+ * Direct SoA store access for hot paths (bitecs-style array indexing by
+ * entity.id(), no snapshots, no change events). koota registers a trait's
+ * store lazily on first add/query and bare getStore throws before that, so
+ * this wrapper registers the trait once per world.
+ */
+export function store<T extends Trait>(world: World, trait: T): ExtractStore<T> {
+ let traits = registered.get(world);
+ if (!traits) {
+ traits = new WeakSet();
+ registered.set(world, traits);
+ }
+ if (!traits.has(trait)) {
+ world.query(trait);
+ traits.add(trait);
+ }
+ return getStore(world, trait);
+}
diff --git a/patches/koota+0.6.6.patch b/patches/koota+0.6.6.patch
new file mode 100644
index 00000000..542029db
--- /dev/null
+++ b/patches/koota+0.6.6.patch
@@ -0,0 +1,150 @@
+diff --git a/node_modules/koota/dist/chunk-ZWIGMIL4.js b/node_modules/koota/dist/chunk-ZWIGMIL4.js
+index feb90a8..16e3081 100644
+--- a/node_modules/koota/dist/chunk-ZWIGMIL4.js
++++ b/node_modules/koota/dist/chunk-ZWIGMIL4.js
+@@ -176,6 +176,8 @@ function checkQuery(world, query, entity) {
+ const ctx = world[$internal];
+ const eid = entity & ENTITY_ID_MASK;
+ if (query.traitInstances.all.length === 0) return false;
++ let staticHasOr = false;
++ let staticOrMatched = false;
+ for (let i = 0; i < generations.length; i++) {
+ const generationId = generations[i];
+ const bitmask = staticBitmasks[i];
+@@ -187,8 +189,12 @@ function checkQuery(world, query, entity) {
+ if (!forbidden && !required && !or) return false;
+ if (forbidden && (entityMask & forbidden) !== 0) return false;
+ if (required && (entityMask & required) !== required) return false;
+- if (or !== 0 && (entityMask & or) === 0) return false;
++ if (or !== 0) {
++ staticHasOr = true;
++ if ((entityMask & or) !== 0) staticOrMatched = true;
++ }
+ }
++ if (staticHasOr && !staticOrMatched) return false;
+ return true;
+ }
+
+@@ -222,6 +228,8 @@ function checkQueryTracking(world, query, entity, eventType, eventGenerationId,
+ const generationsLen = generations.length;
+ const trackingGroupsLen = trackingGroups.length;
+ if (traitInstancesAll.length === 0) return false;
++ let staticHasOr = false;
++ let staticOrMatched = false;
+ for (let i = 0; i < generationsLen; i++) {
+ const generationId = generations[i];
+ const bitmask = staticBitmasks[i];
+@@ -233,8 +241,12 @@ function checkQueryTracking(world, query, entity, eventType, eventGenerationId,
+ const entityMask = genMasks ? genMasks[eid] | 0 : 0;
+ if (forbidden && (entityMask & forbidden) !== 0) return false;
+ if (required && (entityMask & required) !== required) return false;
+- if (or !== 0 && (entityMask & or) === 0) return false;
++ if (or !== 0) {
++ staticHasOr = true;
++ if ((entityMask & or) !== 0) staticOrMatched = true;
++ }
+ }
++ if (staticHasOr && !staticOrMatched) return false;
+ let hasOrGroup = false;
+ let anyOrMatched = false;
+ for (let i = 0; i < trackingGroupsLen; i++) {
+diff --git a/node_modules/koota/dist/index.cjs b/node_modules/koota/dist/index.cjs
+index efa87da..7f3fedd 100644
+--- a/node_modules/koota/dist/index.cjs
++++ b/node_modules/koota/dist/index.cjs
+@@ -222,6 +222,8 @@ function checkQuery(world, query, entity) {
+ const ctx = world[$internal];
+ const eid = entity & ENTITY_ID_MASK;
+ if (query.traitInstances.all.length === 0) return false;
++ let staticHasOr = false;
++ let staticOrMatched = false;
+ for (let i = 0; i < generations.length; i++) {
+ const generationId = generations[i];
+ const bitmask = staticBitmasks[i];
+@@ -233,8 +235,12 @@ function checkQuery(world, query, entity) {
+ if (!forbidden && !required && !or) return false;
+ if (forbidden && (entityMask & forbidden) !== 0) return false;
+ if (required && (entityMask & required) !== required) return false;
+- if (or !== 0 && (entityMask & or) === 0) return false;
++ if (or !== 0) {
++ staticHasOr = true;
++ if ((entityMask & or) !== 0) staticOrMatched = true;
++ }
+ }
++ if (staticHasOr && !staticOrMatched) return false;
+ return true;
+ }
+
+@@ -654,6 +660,8 @@ function checkQueryTracking(world, query, entity, eventType, eventGenerationId,
+ const generationsLen = generations.length;
+ const trackingGroupsLen = trackingGroups.length;
+ if (traitInstancesAll.length === 0) return false;
++ let staticHasOr = false;
++ let staticOrMatched = false;
+ for (let i = 0; i < generationsLen; i++) {
+ const generationId = generations[i];
+ const bitmask = staticBitmasks[i];
+@@ -665,8 +673,12 @@ function checkQueryTracking(world, query, entity, eventType, eventGenerationId,
+ const entityMask = genMasks ? genMasks[eid] | 0 : 0;
+ if (forbidden && (entityMask & forbidden) !== 0) return false;
+ if (required && (entityMask & required) !== required) return false;
+- if (or !== 0 && (entityMask & or) === 0) return false;
++ if (or !== 0) {
++ staticHasOr = true;
++ if ((entityMask & or) !== 0) staticOrMatched = true;
++ }
+ }
++ if (staticHasOr && !staticOrMatched) return false;
+ let hasOrGroup = false;
+ let anyOrMatched = false;
+ for (let i = 0; i < trackingGroupsLen; i++) {
+diff --git a/node_modules/koota/dist/react.cjs b/node_modules/koota/dist/react.cjs
+index 3117293..6b99f96 100644
+--- a/node_modules/koota/dist/react.cjs
++++ b/node_modules/koota/dist/react.cjs
+@@ -118,6 +118,8 @@ function checkQuery(world, query, entity) {
+ const ctx = world[$internal];
+ const eid = entity & ENTITY_ID_MASK;
+ if (query.traitInstances.all.length === 0) return false;
++ let staticHasOr = false;
++ let staticOrMatched = false;
+ for (let i = 0; i < generations.length; i++) {
+ const generationId = generations[i];
+ const bitmask = staticBitmasks[i];
+@@ -129,8 +131,12 @@ function checkQuery(world, query, entity) {
+ if (!forbidden && !required && !or) return false;
+ if (forbidden && (entityMask & forbidden) !== 0) return false;
+ if (required && (entityMask & required) !== required) return false;
+- if (or !== 0 && (entityMask & or) === 0) return false;
++ if (or !== 0) {
++ staticHasOr = true;
++ if ((entityMask & or) !== 0) staticOrMatched = true;
++ }
+ }
++ if (staticHasOr && !staticOrMatched) return false;
+ return true;
+ }
+
+@@ -493,6 +499,8 @@ function checkQueryTracking(world, query, entity, eventType, eventGenerationId,
+ const generationsLen = generations.length;
+ const trackingGroupsLen = trackingGroups.length;
+ if (traitInstancesAll.length === 0) return false;
++ let staticHasOr = false;
++ let staticOrMatched = false;
+ for (let i = 0; i < generationsLen; i++) {
+ const generationId = generations[i];
+ const bitmask = staticBitmasks[i];
+@@ -504,8 +512,12 @@ function checkQueryTracking(world, query, entity, eventType, eventGenerationId,
+ const entityMask = genMasks ? genMasks[eid] | 0 : 0;
+ if (forbidden && (entityMask & forbidden) !== 0) return false;
+ if (required && (entityMask & required) !== required) return false;
+- if (or !== 0 && (entityMask & or) === 0) return false;
++ if (or !== 0) {
++ staticHasOr = true;
++ if ((entityMask & or) !== 0) staticOrMatched = true;
++ }
+ }
++ if (staticHasOr && !staticOrMatched) return false;
+ let hasOrGroup = false;
+ let anyOrMatched = false;
+ for (let i = 0; i < trackingGroupsLen; i++) {