Skip to content

Commit

Permalink
feat: minor improve types
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacek Pietal committed Mar 1, 2024
1 parent 67089c0 commit 8d588d0
Show file tree
Hide file tree
Showing 28 changed files with 72 additions and 75 deletions.
2 changes: 1 addition & 1 deletion dist/demo/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,7 @@ class System extends base_system_1.BaseSystem {
/**
* check all bodies collisions with callback
*/
checkAll(callback, response = this.response) {
checkAll(callback = utils_1.returnTrue, response = this.response) {
const checkOne = (body) => {
return this.checkOne(body, callback, response);
};
Expand Down
2 changes: 1 addition & 1 deletion dist/model.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Polygon } from "./bodies/polygon";
import { BaseSystem } from "./base-system";
export { Polygon as DecompPolygon, Point as DecompPoint } from "poly-decomp";
export { RBush, BBox, Response, SATVector, SATPolygon, SATCircle };
export type CheckCollisionCallback = (response: Response) => void | boolean;
export type CollisionCallback = (response: Response) => boolean | void;
/**
* types
*/
Expand Down
6 changes: 3 additions & 3 deletions dist/system.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// <reference types="sat" />
import { BaseSystem } from "./base-system";
import { Line } from "./bodies/line";
import { RaycastHit, Response, Vector, Body, CheckCollisionCallback } from "./model";
import { RaycastHit, Response, Vector, Body, CollisionCallback } from "./model";
/**
* collision system
*/
Expand All @@ -25,11 +25,11 @@ export declare class System<TBody extends Body = Body> extends BaseSystem<TBody>
/**
* check one body collisions with callback
*/
checkOne(body: TBody, callback?: CheckCollisionCallback, response?: Response): boolean;
checkOne(body: TBody, callback?: CollisionCallback, response?: Response): boolean;
/**
* check all bodies collisions with callback
*/
checkAll(callback: (response: Response) => void | boolean, response?: Response): boolean;
checkAll(callback?: CollisionCallback, response?: Response): boolean;
/**
* check do 2 objects collide
*/
Expand Down
2 changes: 1 addition & 1 deletion dist/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class System extends base_system_1.BaseSystem {
/**
* check all bodies collisions with callback
*/
checkAll(callback, response = this.response) {
checkAll(callback = utils_1.returnTrue, response = this.response) {
const checkOne = (body) => {
return this.checkOne(body, callback, response);
};
Expand Down
2 changes: 1 addition & 1 deletion docs/assets/navigation.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/assets/search.js

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions docs/classes/System.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/demo/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,7 @@ class System extends base_system_1.BaseSystem {
/**
* check all bodies collisions with callback
*/
checkAll(callback, response = this.response) {
checkAll(callback = utils_1.returnTrue, response = this.response) {
const checkOne = (body) => {
return this.checkOne(body, callback, response);
};
Expand Down
4 changes: 2 additions & 2 deletions docs/enums/BodyType.html

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions docs/interfaces/BodyOptions.html

Large diffs are not rendered by default.

42 changes: 21 additions & 21 deletions docs/interfaces/BodyProps.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/interfaces/ChildrenData.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/interfaces/Data.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/interfaces/GetAABBAsBox.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/interfaces/PotentialVector.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/interfaces/RaycastHit.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/interfaces/Vector.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/modules.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<a href="interfaces/RaycastHit.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>Raycast<wbr/>Hit</span></a>
<a href="interfaces/Vector.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-256"></use></svg><span>Vector</span></a>
</div></section><section class="tsd-index-section"><h3 class="tsd-index-heading">Type Aliases</h3><div class="tsd-index-list"><a href="types/Body.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-2097152"></use></svg><span>Body</span></a>
<a href="types/CheckCollisionCallback.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-2097152"></use></svg><span>Check<wbr/>Collision<wbr/>Callback</span></a>
<a href="types/CollisionCallback.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-2097152"></use></svg><span>Collision<wbr/>Callback</span></a>
<a href="types/DecompPoint.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-2097152"></use></svg><span>Decomp<wbr/>Point</span></a>
<a href="types/DecompPolygon.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-2097152"></use></svg><span>Decomp<wbr/>Polygon</span></a>
<a href="types/InTest.html" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="#icon-2097152"></use></svg><span>In<wbr/>Test</span></a>
Expand Down
2 changes: 1 addition & 1 deletion docs/types/Body.html

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion docs/types/CheckCollisionCallback.html

This file was deleted.

1 change: 1 addition & 0 deletions docs/types/CollisionCallback.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/types/InTest.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/types/Leaf.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/types/SATTest.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/types/TraverseFunction.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "detect-collisions",
"version": "9.3.3",
"version": "9.4.0",
"description": "detecting collisions between bodies: Points, Lines, Boxes, Polygons (Concave too), Ellipses and Circles. Also RayCasting. All bodies can have offset, rotation, scale, bounding box padding, can be static (non moving) or be trigger bodies (non colliding).",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
3 changes: 1 addition & 2 deletions src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ import { Ellipse } from "./bodies/ellipse";
import { Line } from "./bodies/line";
import { Point } from "./bodies/point";
import { Polygon } from "./bodies/polygon";
import { System } from "./system";
import { BaseSystem } from "./base-system";

export { Polygon as DecompPolygon, Point as DecompPoint } from "poly-decomp";
export { RBush, BBox, Response, SATVector, SATPolygon, SATCircle };

export type CheckCollisionCallback = (response: Response) => void | boolean;
export type CollisionCallback = (response: Response) => boolean | void;

/**
* types
Expand Down
8 changes: 3 additions & 5 deletions src/system.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { BaseSystem } from "./base-system";
import { Line } from "./bodies/line";
import {
Leaf,
RaycastHit,
Response,
SATVector,
SATTest,
Vector,
Body,
BodyType,
CheckCollisionCallback,
CollisionCallback,
} from "./model";
import {
distance,
Expand Down Expand Up @@ -74,7 +72,7 @@ export class System<TBody extends Body = Body> extends BaseSystem<TBody> {
*/
checkOne(
body: TBody,
callback: CheckCollisionCallback = returnTrue,
callback: CollisionCallback = returnTrue,
response = this.response,
): boolean {
// no need to check static body collision
Expand All @@ -99,7 +97,7 @@ export class System<TBody extends Body = Body> extends BaseSystem<TBody> {
* check all bodies collisions with callback
*/
checkAll(
callback: (response: Response) => void | boolean,
callback: CollisionCallback = returnTrue,
response = this.response,
): boolean {
const checkOne = (body: TBody) => {
Expand Down

0 comments on commit 8d588d0

Please sign in to comment.