@oliversalzburg/js-utils 0.0.9 → 0.0.10
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 +4 -0
- package/lib/errors/AbstractError.js +5 -3
- package/lib/errors/AbstractError.js.map +1 -1
- package/lib/errors/InternalError.js +5 -3
- package/lib/errors/InternalError.js.map +1 -1
- package/lib/errors/InvalidArgumentError.js +5 -3
- package/lib/errors/InvalidArgumentError.js.map +1 -1
- package/lib/errors/InvalidOperationError.js +5 -3
- package/lib/errors/InvalidOperationError.js.map +1 -1
- package/lib/errors/NotImplementedError.js +5 -3
- package/lib/errors/NotImplementedError.js.map +1 -1
- package/lib/errors/PermissionViolationError.js +5 -3
- package/lib/errors/PermissionViolationError.js.map +1 -1
- package/lib/errors/ResourceConflictError.js +5 -3
- package/lib/errors/ResourceConflictError.js.map +1 -1
- package/lib/errors/UnknownError.js +5 -3
- package/lib/errors/UnknownError.js.map +1 -1
- package/lib/graphics/canvas.d.ts +29 -11
- package/lib/graphics/canvas.js +41 -17
- package/lib/graphics/canvas.js.map +1 -1
- package/lib/graphics/render-loop.d.ts +23 -4
- package/lib/graphics/render-loop.js +23 -12
- package/lib/graphics/render-loop.js.map +1 -1
- package/lib/math/vector2.d.ts +6 -1
- package/lib/math/vector2.js +8 -1
- package/lib/math/vector2.js.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -22,9 +22,11 @@ export class AbstractError extends Error {
|
|
|
22
22
|
this.code = code;
|
|
23
23
|
this.name = "AbstractError";
|
|
24
24
|
this.status = status;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
if (typeof Error.captureStackTrace !== "undefined") {
|
|
26
|
+
// Capture a new stacktrace, otherwise it will include our base-class constructor instead of the code
|
|
27
|
+
// location we're actually interested in.
|
|
28
|
+
Error.captureStackTrace(this, AbstractError);
|
|
29
|
+
}
|
|
28
30
|
}
|
|
29
31
|
/**
|
|
30
32
|
* Checks if an object is an instance of {@linkcode AbstractError}, or one of its subclasses.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractError.js","sourceRoot":"","sources":["../../source/errors/AbstractError.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC;;OAEG;IACH,MAAM,CAAS;IAEf;;OAEG;IACH,IAAI,CAAS;IAEb;;;;;OAKG;IACH,YAAY,IAAY,EAAE,OAAe,EAAE,MAAc;QACvD,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,qGAAqG;
|
|
1
|
+
{"version":3,"file":"AbstractError.js","sourceRoot":"","sources":["../../source/errors/AbstractError.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC;;OAEG;IACH,MAAM,CAAS;IAEf;;OAEG;IACH,IAAI,CAAS;IAEb;;;;;OAKG;IACH,YAAY,IAAY,EAAE,OAAe,EAAE,MAAc;QACvD,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,IAAI,OAAO,KAAK,CAAC,iBAAiB,KAAK,WAAW,EAAE;YAClD,qGAAqG;YACrG,yCAAyC;YACzC,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;SAC9C;IACH,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,eAAe,CAAC,KAAc,EAAE,kBAAkB,GAAG,IAAI;QAC9D,IAAI,KAAK,YAAY,aAAa,EAAE;YAClC,OAAO,IAAI,CAAC;SACb;QAED,gEAAgE;QAChE,sEAAsE;QACtE,cAAc;QACd,IAAI,kBAAkB,EAAE;YACtB,MAAM,WAAW,GAAG,KAAgC,CAAC;YACrD,IACE,MAAM,CAAC,KAAK,CAAC,KAAK,KAAK;gBACvB,MAAM,IAAI,WAAW;gBACrB,OAAO,WAAW,CAAC,IAAI,KAAK,QAAQ,EACpC;gBACA,MAAM,UAAU,GAAG,KAAyB,CAAC;gBAC7C,IAAI,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE;oBACrC,OAAO,IAAI,CAAC;iBACb;aACF;SACF;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
|
|
@@ -13,9 +13,11 @@ export class InternalError extends AbstractError {
|
|
|
13
13
|
constructor(message, status = 500) {
|
|
14
14
|
super("ERR_OS_INTERNAL", message, status);
|
|
15
15
|
this.name = "InternalError";
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
if (typeof Error.captureStackTrace !== "undefined") {
|
|
17
|
+
// Capture a new stacktrace, otherwise it will include our base-class
|
|
18
|
+
// constructor instead of the code location we're actually interested in.
|
|
19
|
+
Error.captureStackTrace(this, InternalError);
|
|
20
|
+
}
|
|
19
21
|
}
|
|
20
22
|
/**
|
|
21
23
|
* Converts an error into an {@linkcode InternalError}.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InternalError.js","sourceRoot":"","sources":["../../source/errors/InternalError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;;;GAIG;AACH,MAAM,OAAO,aAAc,SAAQ,aAAa;IAC9C;;;;OAIG;IACH,YAAY,OAAe,EAAE,MAAM,GAAG,GAAG;QACvC,KAAK,CAAC,iBAAiB,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAE1C,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAE5B,qEAAqE;
|
|
1
|
+
{"version":3,"file":"InternalError.js","sourceRoot":"","sources":["../../source/errors/InternalError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;;;GAIG;AACH,MAAM,OAAO,aAAc,SAAQ,aAAa;IAC9C;;;;OAIG;IACH,YAAY,OAAe,EAAE,MAAM,GAAG,GAAG;QACvC,KAAK,CAAC,iBAAiB,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAE1C,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAE5B,IAAI,OAAO,KAAK,CAAC,iBAAiB,KAAK,WAAW,EAAE;YAClD,qEAAqE;YACrE,yEAAyE;YACzE,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;SAC9C;IACH,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,SAAS,CAAC,KAAY;QAC3B,wEAAwE;QACxE,MAAM,aAAa,GAAG,IAAI,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACvD,kEAAkE;QAClE,mEAAmE;QACnE,0BAA0B;QAC1B,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,KAAK,EAAE,IAAI,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QACtE,0CAA0C;QAC1C,aAAa,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;QAElC,OAAO,aAAa,CAAC;IACvB,CAAC;CACF"}
|
|
@@ -13,9 +13,11 @@ export class InvalidArgumentError extends AbstractError {
|
|
|
13
13
|
constructor(message, status = 400) {
|
|
14
14
|
super("ERR_OS_INVALID_ARGUMENT", message, status);
|
|
15
15
|
this.name = "InvalidArgumentError";
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
if (typeof Error.captureStackTrace !== "undefined") {
|
|
17
|
+
// Capture a new stacktrace, otherwise it will include our base-class
|
|
18
|
+
// constructor instead of the code location we're actually interested in.
|
|
19
|
+
Error.captureStackTrace(this, InvalidArgumentError);
|
|
20
|
+
}
|
|
19
21
|
}
|
|
20
22
|
}
|
|
21
23
|
//# sourceMappingURL=InvalidArgumentError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InvalidArgumentError.js","sourceRoot":"","sources":["../../source/errors/InvalidArgumentError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;;;GAIG;AACH,MAAM,OAAO,oBAAqB,SAAQ,aAAa;IACrD;;;;OAIG;IACH,YAAY,OAAe,EAAE,MAAM,GAAG,GAAG;QACvC,KAAK,CAAC,yBAAyB,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAElD,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;QAEnC,qEAAqE;
|
|
1
|
+
{"version":3,"file":"InvalidArgumentError.js","sourceRoot":"","sources":["../../source/errors/InvalidArgumentError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;;;GAIG;AACH,MAAM,OAAO,oBAAqB,SAAQ,aAAa;IACrD;;;;OAIG;IACH,YAAY,OAAe,EAAE,MAAM,GAAG,GAAG;QACvC,KAAK,CAAC,yBAAyB,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAElD,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;QAEnC,IAAI,OAAO,KAAK,CAAC,iBAAiB,KAAK,WAAW,EAAE;YAClD,qEAAqE;YACrE,yEAAyE;YACzE,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC;SACrD;IACH,CAAC;CACF"}
|
|
@@ -13,9 +13,11 @@ export class InvalidOperationError extends AbstractError {
|
|
|
13
13
|
constructor(message, status = 400) {
|
|
14
14
|
super("ERR_OS_INVALID_OPERATION", message, status);
|
|
15
15
|
this.name = "InvalidOperationError";
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
if (typeof Error.captureStackTrace !== "undefined") {
|
|
17
|
+
// Capture a new stacktrace, otherwise it will include our base-class
|
|
18
|
+
// constructor instead of the code location we're actually interested in.
|
|
19
|
+
Error.captureStackTrace(this, InvalidOperationError);
|
|
20
|
+
}
|
|
19
21
|
}
|
|
20
22
|
}
|
|
21
23
|
//# sourceMappingURL=InvalidOperationError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InvalidOperationError.js","sourceRoot":"","sources":["../../source/errors/InvalidOperationError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;;;GAIG;AACH,MAAM,OAAO,qBAAsB,SAAQ,aAAa;IACtD;;;;OAIG;IACH,YAAY,OAAe,EAAE,MAAM,GAAG,GAAG;QACvC,KAAK,CAAC,0BAA0B,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAEnD,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;QAEpC,qEAAqE;
|
|
1
|
+
{"version":3,"file":"InvalidOperationError.js","sourceRoot":"","sources":["../../source/errors/InvalidOperationError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;;;GAIG;AACH,MAAM,OAAO,qBAAsB,SAAQ,aAAa;IACtD;;;;OAIG;IACH,YAAY,OAAe,EAAE,MAAM,GAAG,GAAG;QACvC,KAAK,CAAC,0BAA0B,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAEnD,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;QAEpC,IAAI,OAAO,KAAK,CAAC,iBAAiB,KAAK,WAAW,EAAE;YAClD,qEAAqE;YACrE,yEAAyE;YACzE,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,qBAAqB,CAAC,CAAC;SACtD;IACH,CAAC;CACF"}
|
|
@@ -12,9 +12,11 @@ export class NotImplementedError extends AbstractError {
|
|
|
12
12
|
constructor(message, status = 501) {
|
|
13
13
|
super("ERR_OS_NOT_IMPLEMENTED", message, status);
|
|
14
14
|
this.name = "NotImplementedError";
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
if (typeof Error.captureStackTrace !== "undefined") {
|
|
16
|
+
// Capture a new stacktrace, otherwise it will include our base-class
|
|
17
|
+
// constructor instead of the code location we're actually interested in.
|
|
18
|
+
Error.captureStackTrace(this, NotImplementedError);
|
|
19
|
+
}
|
|
18
20
|
}
|
|
19
21
|
}
|
|
20
22
|
//# sourceMappingURL=NotImplementedError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotImplementedError.js","sourceRoot":"","sources":["../../source/errors/NotImplementedError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;;GAGG;AACH,MAAM,OAAO,mBAAoB,SAAQ,aAAa;IACpD;;;;OAIG;IACH,YAAY,OAAe,EAAE,MAAM,GAAG,GAAG;QACvC,KAAK,CAAC,wBAAwB,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAEjD,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAElC,qEAAqE;
|
|
1
|
+
{"version":3,"file":"NotImplementedError.js","sourceRoot":"","sources":["../../source/errors/NotImplementedError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;;GAGG;AACH,MAAM,OAAO,mBAAoB,SAAQ,aAAa;IACpD;;;;OAIG;IACH,YAAY,OAAe,EAAE,MAAM,GAAG,GAAG;QACvC,KAAK,CAAC,wBAAwB,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAEjD,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAElC,IAAI,OAAO,KAAK,CAAC,iBAAiB,KAAK,WAAW,EAAE;YAClD,qEAAqE;YACrE,yEAAyE;YACzE,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC;SACpD;IACH,CAAC;CACF"}
|
|
@@ -13,9 +13,11 @@ export class PermissionViolationError extends AbstractError {
|
|
|
13
13
|
constructor(message, status = 403) {
|
|
14
14
|
super("ERR_OS_PERMISSION_VIOLATION", message, status);
|
|
15
15
|
this.name = "PermissionViolationError";
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
if (typeof Error.captureStackTrace !== "undefined") {
|
|
17
|
+
// Capture a new stacktrace, otherwise it will include our base-class
|
|
18
|
+
// constructor instead of the code location we're actually interested in.
|
|
19
|
+
Error.captureStackTrace(this, PermissionViolationError);
|
|
20
|
+
}
|
|
19
21
|
}
|
|
20
22
|
}
|
|
21
23
|
//# sourceMappingURL=PermissionViolationError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PermissionViolationError.js","sourceRoot":"","sources":["../../source/errors/PermissionViolationError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;;;GAIG;AACH,MAAM,OAAO,wBAAyB,SAAQ,aAAa;IACzD;;;;OAIG;IACH,YAAY,OAAe,EAAE,MAAM,GAAG,GAAG;QACvC,KAAK,CAAC,6BAA6B,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAEtD,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;QAEvC,qEAAqE;
|
|
1
|
+
{"version":3,"file":"PermissionViolationError.js","sourceRoot":"","sources":["../../source/errors/PermissionViolationError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;;;GAIG;AACH,MAAM,OAAO,wBAAyB,SAAQ,aAAa;IACzD;;;;OAIG;IACH,YAAY,OAAe,EAAE,MAAM,GAAG,GAAG;QACvC,KAAK,CAAC,6BAA6B,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAEtD,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;QAEvC,IAAI,OAAO,KAAK,CAAC,iBAAiB,KAAK,WAAW,EAAE;YAClD,qEAAqE;YACrE,yEAAyE;YACzE,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,wBAAwB,CAAC,CAAC;SACzD;IACH,CAAC;CACF"}
|
|
@@ -12,9 +12,11 @@ export class ResourceConflictError extends AbstractError {
|
|
|
12
12
|
constructor(message, status = 409) {
|
|
13
13
|
super("ERR_OS_RESOURCE_CONFLICT", message, status);
|
|
14
14
|
this.name = "ResourceConflictError";
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
if (typeof Error.captureStackTrace !== "undefined") {
|
|
16
|
+
// Capture a new stacktrace, otherwise it will include our base-class
|
|
17
|
+
// constructor instead of the code location we're actually interested in.
|
|
18
|
+
Error.captureStackTrace(this, ResourceConflictError);
|
|
19
|
+
}
|
|
18
20
|
}
|
|
19
21
|
}
|
|
20
22
|
//# sourceMappingURL=ResourceConflictError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResourceConflictError.js","sourceRoot":"","sources":["../../source/errors/ResourceConflictError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;;GAGG;AACH,MAAM,OAAO,qBAAsB,SAAQ,aAAa;IACtD;;;;OAIG;IACH,YAAY,OAAe,EAAE,MAAM,GAAG,GAAG;QACvC,KAAK,CAAC,0BAA0B,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAEnD,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;QAEpC,qEAAqE;
|
|
1
|
+
{"version":3,"file":"ResourceConflictError.js","sourceRoot":"","sources":["../../source/errors/ResourceConflictError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;;GAGG;AACH,MAAM,OAAO,qBAAsB,SAAQ,aAAa;IACtD;;;;OAIG;IACH,YAAY,OAAe,EAAE,MAAM,GAAG,GAAG;QACvC,KAAK,CAAC,0BAA0B,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAEnD,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;QAEpC,IAAI,OAAO,KAAK,CAAC,iBAAiB,KAAK,WAAW,EAAE;YAClD,qEAAqE;YACrE,yEAAyE;YACzE,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,qBAAqB,CAAC,CAAC;SACtD;IACH,CAAC;CACF"}
|
|
@@ -16,9 +16,11 @@ export class UnknownError extends AbstractError {
|
|
|
16
16
|
constructor(message, status = 500) {
|
|
17
17
|
super("ERR_OS_UNKNOWN", message, status);
|
|
18
18
|
this.name = "UnknownError";
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
if (typeof Error.captureStackTrace !== "undefined") {
|
|
20
|
+
// Capture a new stacktrace, otherwise it will include our base-class
|
|
21
|
+
// constructor instead of the code location we're actually interested in.
|
|
22
|
+
Error.captureStackTrace(this, UnknownError);
|
|
23
|
+
}
|
|
22
24
|
}
|
|
23
25
|
}
|
|
24
26
|
//# sourceMappingURL=UnknownError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnknownError.js","sourceRoot":"","sources":["../../source/errors/UnknownError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;;;;;;GAOG;AACH,MAAM,OAAO,YAAa,SAAQ,aAAa;IAC7C;;;;OAIG;IACH,YAAY,OAAe,EAAE,MAAM,GAAG,GAAG;QACvC,KAAK,CAAC,gBAAgB,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAEzC,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAE3B,qEAAqE;
|
|
1
|
+
{"version":3,"file":"UnknownError.js","sourceRoot":"","sources":["../../source/errors/UnknownError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;;;;;;GAOG;AACH,MAAM,OAAO,YAAa,SAAQ,aAAa;IAC7C;;;;OAIG;IACH,YAAY,OAAe,EAAE,MAAM,GAAG,GAAG;QACvC,KAAK,CAAC,gBAAgB,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAEzC,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAE3B,IAAI,OAAO,KAAK,CAAC,iBAAiB,KAAK,WAAW,EAAE;YAClD,qEAAqE;YACrE,yEAAyE;YACzE,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;SAC7C;IACH,CAAC;CACF"}
|
package/lib/graphics/canvas.d.ts
CHANGED
|
@@ -1,14 +1,26 @@
|
|
|
1
1
|
/// <reference types="@types/web" />
|
|
2
|
+
/**
|
|
3
|
+
* Construction options for a {@linkcode Canvas}.
|
|
4
|
+
* @group Graphics
|
|
5
|
+
*/
|
|
6
|
+
export interface CanvasOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Was this {@linkcode Canvas} created with the ability to copy the front buffer back into
|
|
9
|
+
* the back buffer?
|
|
10
|
+
*/
|
|
11
|
+
readonly supportReadBack: boolean;
|
|
12
|
+
}
|
|
2
13
|
/**
|
|
3
14
|
* A wrapper around {@linkcode !HTMLCanvasElement}
|
|
4
15
|
* to provide some convience for double-buffered drawing.
|
|
5
16
|
* @group Graphics
|
|
6
17
|
*/
|
|
7
18
|
export declare class Canvas {
|
|
19
|
+
#private;
|
|
8
20
|
/**
|
|
9
|
-
* The {@linkcode !HTMLCanvasElement} we're interacting with.
|
|
21
|
+
* The {@linkcode !HTMLCanvasElement} we're interacting with in the DOM.
|
|
10
22
|
*/
|
|
11
|
-
readonly
|
|
23
|
+
readonly canvasDom: HTMLCanvasElement;
|
|
12
24
|
/**
|
|
13
25
|
* The width of the canvas.
|
|
14
26
|
*/
|
|
@@ -18,9 +30,9 @@ export declare class Canvas {
|
|
|
18
30
|
*/
|
|
19
31
|
readonly height: number;
|
|
20
32
|
/**
|
|
21
|
-
* The {@linkcode !
|
|
33
|
+
* The {@linkcode !OffscreenCanvasRenderingContext2D} we're using to draw to the canvas.
|
|
22
34
|
*/
|
|
23
|
-
readonly context:
|
|
35
|
+
readonly context: OffscreenCanvasRenderingContext2D;
|
|
24
36
|
/**
|
|
25
37
|
* The {@linkcode !ImageData} object
|
|
26
38
|
* that represents our frontbuffer, which is the canvas itself.
|
|
@@ -31,24 +43,30 @@ export declare class Canvas {
|
|
|
31
43
|
*/
|
|
32
44
|
buffer: Uint8ClampedArray;
|
|
33
45
|
/**
|
|
34
|
-
*
|
|
35
|
-
* the back buffer?
|
|
46
|
+
* The configuration that was used for this canvas.
|
|
36
47
|
*/
|
|
37
|
-
readonly
|
|
48
|
+
readonly options: Readonly<Partial<CanvasOptions>>;
|
|
38
49
|
/**
|
|
39
50
|
* Constructs a new {@linkcode Canvas}.
|
|
40
51
|
* @param canvas The canvas to wrap.
|
|
41
52
|
* @param width The width of the canvas.
|
|
42
53
|
* @param height The height of the canvas.
|
|
43
|
-
* @param
|
|
44
|
-
* You will need this, if you plan to use regular canvas drawing on the front buffer, and
|
|
45
|
-
* read the results back into the back buffer.
|
|
54
|
+
* @param options The configuration for this canvas.
|
|
46
55
|
*/
|
|
47
|
-
constructor(canvas: HTMLCanvasElement, width: number, height: number,
|
|
56
|
+
constructor(canvas: HTMLCanvasElement, width: number, height: number, options?: Partial<CanvasOptions>);
|
|
48
57
|
/**
|
|
49
58
|
* Draws the back buffer onto the canvas.
|
|
50
59
|
*/
|
|
51
60
|
update(): void;
|
|
61
|
+
/**
|
|
62
|
+
* Draws the offscreen canvas into the DOM canvas.
|
|
63
|
+
*/
|
|
64
|
+
render(): void;
|
|
65
|
+
/**
|
|
66
|
+
* Draws a slightly transparent, black rectangle over the canvas,
|
|
67
|
+
* and then reads the result back into the buffer.
|
|
68
|
+
*/
|
|
69
|
+
fade(): void;
|
|
52
70
|
/**
|
|
53
71
|
* Reads the front buffer back into the back buffer.
|
|
54
72
|
*/
|
package/lib/graphics/canvas.js
CHANGED
|
@@ -8,9 +8,17 @@ import { blend, blendAdditive, blendSubtractive, fromRGBA, getA, getB, getG, get
|
|
|
8
8
|
*/
|
|
9
9
|
export class Canvas {
|
|
10
10
|
/**
|
|
11
|
-
* The {@linkcode !HTMLCanvasElement} we're interacting with.
|
|
11
|
+
* The {@linkcode !HTMLCanvasElement} we're interacting with in the DOM.
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
canvasDom;
|
|
14
|
+
/**
|
|
15
|
+
* The rendering context for the canvas located in the DOM.
|
|
16
|
+
*/
|
|
17
|
+
#canvasDomContext;
|
|
18
|
+
/**
|
|
19
|
+
* The offscreen canvas we use for rendering.
|
|
20
|
+
*/
|
|
21
|
+
#canvasOffscreen;
|
|
14
22
|
/**
|
|
15
23
|
* The width of the canvas.
|
|
16
24
|
*/
|
|
@@ -20,7 +28,7 @@ export class Canvas {
|
|
|
20
28
|
*/
|
|
21
29
|
height;
|
|
22
30
|
/**
|
|
23
|
-
* The {@linkcode !
|
|
31
|
+
* The {@linkcode !OffscreenCanvasRenderingContext2D} we're using to draw to the canvas.
|
|
24
32
|
*/
|
|
25
33
|
context;
|
|
26
34
|
/**
|
|
@@ -33,29 +41,28 @@ export class Canvas {
|
|
|
33
41
|
*/
|
|
34
42
|
buffer;
|
|
35
43
|
/**
|
|
36
|
-
*
|
|
37
|
-
* the back buffer?
|
|
44
|
+
* The configuration that was used for this canvas.
|
|
38
45
|
*/
|
|
39
|
-
|
|
46
|
+
options;
|
|
40
47
|
/**
|
|
41
48
|
* Constructs a new {@linkcode Canvas}.
|
|
42
49
|
* @param canvas The canvas to wrap.
|
|
43
50
|
* @param width The width of the canvas.
|
|
44
51
|
* @param height The height of the canvas.
|
|
45
|
-
* @param
|
|
46
|
-
* You will need this, if you plan to use regular canvas drawing on the front buffer, and
|
|
47
|
-
* read the results back into the back buffer.
|
|
52
|
+
* @param options The configuration for this canvas.
|
|
48
53
|
*/
|
|
49
|
-
constructor(canvas, width, height,
|
|
50
|
-
this.canvas = canvas;
|
|
54
|
+
constructor(canvas, width, height, options = {}) {
|
|
51
55
|
this.width = width;
|
|
52
56
|
this.height = height;
|
|
53
|
-
this.
|
|
57
|
+
this.options = options;
|
|
58
|
+
this.canvasDom = canvas;
|
|
59
|
+
this.#canvasDomContext = mustExist(this.canvasDom.getContext("bitmaprenderer"), "Unable to create rendering context for DOM canvas.");
|
|
60
|
+
this.#canvasOffscreen = new OffscreenCanvas(this.width, this.height);
|
|
61
|
+
this.context = mustExist(this.#canvasOffscreen.getContext("2d", {
|
|
54
62
|
alpha: false,
|
|
55
63
|
desynchronized: true,
|
|
56
|
-
willReadFrequently: supportReadBack,
|
|
57
|
-
}), "Unable to create rendering context.");
|
|
58
|
-
this.supportReadBack = supportReadBack;
|
|
64
|
+
willReadFrequently: this.options.supportReadBack,
|
|
65
|
+
}), "Unable to create rendering context for offscreen canvas.");
|
|
59
66
|
this.pixMap = this.context.createImageData(width, height);
|
|
60
67
|
this.buffer = this.pixMap.data;
|
|
61
68
|
this.context.font = "12px sans-serif";
|
|
@@ -66,12 +73,29 @@ export class Canvas {
|
|
|
66
73
|
update() {
|
|
67
74
|
this.context.putImageData(this.pixMap, 0, 0);
|
|
68
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Draws the offscreen canvas into the DOM canvas.
|
|
78
|
+
*/
|
|
79
|
+
render() {
|
|
80
|
+
const newFrame = this.#canvasOffscreen.transferToImageBitmap();
|
|
81
|
+
this.#canvasDomContext.transferFromImageBitmap(newFrame);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Draws a slightly transparent, black rectangle over the canvas,
|
|
85
|
+
* and then reads the result back into the buffer.
|
|
86
|
+
*/
|
|
87
|
+
fade() {
|
|
88
|
+
this.context.fillStyle = "rgba(0,0,0,0.1)";
|
|
89
|
+
this.context.rect(0, 0, this.width, this.height);
|
|
90
|
+
this.context.fill();
|
|
91
|
+
this.bufferReadBack();
|
|
92
|
+
}
|
|
69
93
|
/**
|
|
70
94
|
* Reads the front buffer back into the back buffer.
|
|
71
95
|
*/
|
|
72
96
|
bufferReadBack() {
|
|
73
|
-
if (!this.supportReadBack) {
|
|
74
|
-
throw new InvalidOperationError("To use `bufferReadBack()`, you must construct the `Canvas` with `supportReadBack` set to `true`.");
|
|
97
|
+
if (!this.options.supportReadBack) {
|
|
98
|
+
throw new InvalidOperationError("To use `bufferReadBack()`, you must construct the `Canvas` with `options.supportReadBack` set to `true`.");
|
|
75
99
|
}
|
|
76
100
|
this.pixMap = this.context.getImageData(0, 0, this.width, this.height);
|
|
77
101
|
this.buffer = this.pixMap.data;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canvas.js","sourceRoot":"","sources":["../../source/graphics/canvas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EACL,KAAK,EACL,aAAa,EACb,gBAAgB,EAChB,QAAQ,EACR,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,GACL,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"canvas.js","sourceRoot":"","sources":["../../source/graphics/canvas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EACL,KAAK,EACL,aAAa,EACb,gBAAgB,EAChB,QAAQ,EACR,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,GACL,MAAM,WAAW,CAAC;AAcnB;;;;GAIG;AACH,MAAM,OAAO,MAAM;IACjB;;OAEG;IACM,SAAS,CAAoB;IAEtC;;OAEG;IACH,iBAAiB,CAA8B;IAE/C;;OAEG;IACH,gBAAgB,CAAkB;IAElC;;OAEG;IACM,KAAK,CAAS;IAEvB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AAE;QAC3D,OAAO;KACR;IAED,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAClC,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAClC,MAAM,QAAQ,GAAG,CAAC,GAAG,OAAO,CAAC;IAC7B,MAAM,QAAQ,GAAG,CAAC,GAAG,OAAO,CAAC;IAE7B,MAAM,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,KAAK,CAAC;IAC3C,MAAM,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;IAC1C,MAAM,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,KAAK,CAAC;IAC1C,MAAM,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,CAAC;IAEzC,UAAU,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IAChD,UAAU,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IAChD,UAAU,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IAChD,UAAU,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAClD,CAAC,CAAC"}
|
|
@@ -4,6 +4,21 @@ import { Canvas } from "./canvas.js";
|
|
|
4
4
|
* @group Graphics
|
|
5
5
|
*/
|
|
6
6
|
export type RenderLoopCallback = (delta: number, timestamp: number) => unknown;
|
|
7
|
+
/**
|
|
8
|
+
* Configuration for a {@linkcode RenderLoop},
|
|
9
|
+
* @group Graphics
|
|
10
|
+
*/
|
|
11
|
+
export interface RenderLoopOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Should the current frames per second be rendered onto the canvas
|
|
14
|
+
* each frame?
|
|
15
|
+
*/
|
|
16
|
+
drawFps: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Should the buffer be cleared or faded to black before each frame?
|
|
19
|
+
*/
|
|
20
|
+
onRefresh: "clear" | "fade";
|
|
21
|
+
}
|
|
7
22
|
/**
|
|
8
23
|
* Conveniently provides a way to have a render loop called at
|
|
9
24
|
* a constant frame rate.
|
|
@@ -14,11 +29,15 @@ export declare class RenderLoop {
|
|
|
14
29
|
/**
|
|
15
30
|
* The {@linkcode Canvas} we're rendering to.
|
|
16
31
|
*/
|
|
17
|
-
readonly canvas: Canvas
|
|
32
|
+
readonly canvas: Canvas;
|
|
18
33
|
/**
|
|
19
34
|
* A function that we call when a new frame should be drawn.
|
|
20
35
|
*/
|
|
21
36
|
readonly renderLoop: RenderLoopCallback;
|
|
37
|
+
/**
|
|
38
|
+
* The configuration that was used for this render loop.
|
|
39
|
+
*/
|
|
40
|
+
readonly options: Readonly<Partial<RenderLoopOptions>>;
|
|
22
41
|
/**
|
|
23
42
|
* The timestamp we got for the previous frame.
|
|
24
43
|
*/
|
|
@@ -35,10 +54,10 @@ export declare class RenderLoop {
|
|
|
35
54
|
/**
|
|
36
55
|
* Constructs a new {@linkcode RenderLoop}.
|
|
37
56
|
* @param renderLoop The function to call when a new frame should be drawn.
|
|
38
|
-
* @param canvas
|
|
39
|
-
*
|
|
57
|
+
* @param canvas The {@linkcode Canvas} we're rendering to.
|
|
58
|
+
* @param options The configuration for thie {@linkcode RenderLoop}.
|
|
40
59
|
*/
|
|
41
|
-
constructor(renderLoop: RenderLoopCallback, canvas?:
|
|
60
|
+
constructor(renderLoop: RenderLoopCallback, canvas: Canvas, options?: Partial<RenderLoopOptions>);
|
|
42
61
|
/**
|
|
43
62
|
* Stop the render loop.
|
|
44
63
|
*/
|
|
@@ -12,6 +12,10 @@ export class RenderLoop {
|
|
|
12
12
|
* A function that we call when a new frame should be drawn.
|
|
13
13
|
*/
|
|
14
14
|
renderLoop;
|
|
15
|
+
/**
|
|
16
|
+
* The configuration that was used for this render loop.
|
|
17
|
+
*/
|
|
18
|
+
options;
|
|
15
19
|
/**
|
|
16
20
|
* The timestamp we got for the previous frame.
|
|
17
21
|
*/
|
|
@@ -28,11 +32,12 @@ export class RenderLoop {
|
|
|
28
32
|
/**
|
|
29
33
|
* Constructs a new {@linkcode RenderLoop}.
|
|
30
34
|
* @param renderLoop The function to call when a new frame should be drawn.
|
|
31
|
-
* @param canvas
|
|
32
|
-
*
|
|
35
|
+
* @param canvas The {@linkcode Canvas} we're rendering to.
|
|
36
|
+
* @param options The configuration for thie {@linkcode RenderLoop}.
|
|
33
37
|
*/
|
|
34
|
-
constructor(renderLoop, canvas) {
|
|
38
|
+
constructor(renderLoop, canvas, options = {}) {
|
|
35
39
|
this.canvas = canvas;
|
|
40
|
+
this.options = options;
|
|
36
41
|
this.renderLoop = renderLoop;
|
|
37
42
|
this.previousTimestamp = 0;
|
|
38
43
|
this.boundMain = this.#main.bind(this);
|
|
@@ -70,16 +75,22 @@ export class RenderLoop {
|
|
|
70
75
|
*/
|
|
71
76
|
#drawFrame(timestamp, delta) {
|
|
72
77
|
this.renderLoop(delta, timestamp);
|
|
73
|
-
if (!this.canvas) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
78
|
this.canvas.update();
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
this.
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
if (this.options.onRefresh === "fade") {
|
|
80
|
+
this.canvas.fade();
|
|
81
|
+
}
|
|
82
|
+
if (this.options.onRefresh === "clear") {
|
|
83
|
+
this.canvas.clearWith(0);
|
|
84
|
+
}
|
|
85
|
+
if (this.options.drawFps) {
|
|
86
|
+
const fps = `${Math.round(1000 / delta)}fps`;
|
|
87
|
+
this.canvas.context.strokeStyle = "rgba( 255, 255, 255, 0.85 )";
|
|
88
|
+
this.canvas.context.lineWidth = 5;
|
|
89
|
+
this.canvas.context.strokeText(fps, 4, 14);
|
|
90
|
+
this.canvas.context.fillStyle = "#000000";
|
|
91
|
+
this.canvas.context.fillText(fps, 4, 14);
|
|
92
|
+
}
|
|
93
|
+
this.canvas.render();
|
|
83
94
|
}
|
|
84
95
|
}
|
|
85
96
|
//# sourceMappingURL=render-loop.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-loop.js","sourceRoot":"","sources":["../../source/graphics/render-loop.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"render-loop.js","sourceRoot":"","sources":["../../source/graphics/render-loop.ts"],"names":[],"mappings":"AAyBA;;;;GAIG;AACH,MAAM,OAAO,UAAU;IACrB;;OAEG;IACM,MAAM,CAAS;IAExB;;OAEG;IACM,UAAU,CAAqB;IAExC;;OAEG;IACM,OAAO,CAAuC;IAEvD;;OAEG;IACK,iBAAiB,CAAS;IAElC;;;OAGG;IACc,SAAS,CAA8B;IAExD;;OAEG;IACK,cAAc,GAAkB,IAAI,CAAC;IAE7C;;;;;OAKG;IACH,YACE,UAA8B,EAC9B,MAAc,EACd,UAAsC,EAAE;QAExC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,iBAAiB,GAAG,CAAC,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,IAAI,CAAC,cAAc,KAAK,IAAI,EAAE;YAChC,OAAO;SACR;QAED,MAAM,CAAC,oBAAoB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACjD,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,OAAO;QACL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,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;SAC1C;QAED,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;IACvB,CAAC;CACF"}
|
package/lib/math/vector2.d.ts
CHANGED
|
@@ -110,7 +110,7 @@ export declare class Vector2 {
|
|
|
110
110
|
*/
|
|
111
111
|
divideScale(scale: number): this;
|
|
112
112
|
/**
|
|
113
|
-
* Inverts the vector.
|
|
113
|
+
* Inverts the sign of the vector.
|
|
114
114
|
* @returns This instance.
|
|
115
115
|
*/
|
|
116
116
|
invertAdd(): this;
|
|
@@ -168,6 +168,11 @@ export declare class Vector2 {
|
|
|
168
168
|
* @returns The dot product between the two vectors.
|
|
169
169
|
*/
|
|
170
170
|
dotXY(x: number, y: number): number;
|
|
171
|
+
/**
|
|
172
|
+
* Return the components of this vector as an array.
|
|
173
|
+
* @returns The components of this vector as an array.
|
|
174
|
+
*/
|
|
175
|
+
asArray(): [number, number];
|
|
171
176
|
}
|
|
172
177
|
/**
|
|
173
178
|
* Adds two vectors and returns a new vector with the result.
|
package/lib/math/vector2.js
CHANGED
|
@@ -157,7 +157,7 @@ export class Vector2 {
|
|
|
157
157
|
return this;
|
|
158
158
|
}
|
|
159
159
|
/**
|
|
160
|
-
* Inverts the vector.
|
|
160
|
+
* Inverts the sign of the vector.
|
|
161
161
|
* @returns This instance.
|
|
162
162
|
*/
|
|
163
163
|
invertAdd() {
|
|
@@ -265,6 +265,13 @@ export class Vector2 {
|
|
|
265
265
|
dotXY(x, y) {
|
|
266
266
|
return this.x * x + this.y * y;
|
|
267
267
|
}
|
|
268
|
+
/**
|
|
269
|
+
* Return the components of this vector as an array.
|
|
270
|
+
* @returns The components of this vector as an array.
|
|
271
|
+
*/
|
|
272
|
+
asArray() {
|
|
273
|
+
return [this.x, this.y];
|
|
274
|
+
}
|
|
268
275
|
}
|
|
269
276
|
/**
|
|
270
277
|
* Adds two vectors and returns a new vector with the result.
|
package/lib/math/vector2.js.map
CHANGED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GAMG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAU,EAAE,CAAU,EAAW,EAAE;IAC5D,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3C,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAU,EAAE,CAAU,EAAW,EAAE;IACjE,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3C,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAU,EAAE,CAAU,EAAW,EAAE;IACjE,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3C,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@oliversalzburg/js-utils",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.10",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Oliver Salzburg <oliver.salzburg@gmail.com>",
|
|
7
7
|
"type": "module",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"build": "yarn run build:tsc",
|
|
16
16
|
"build:esbuild": "node build.js",
|
|
17
17
|
"build:tsc": "tsc",
|
|
18
|
+
"build:tsc:watch": "tsc --watch",
|
|
18
19
|
"docs:typedoc": "typedoc",
|
|
19
20
|
"lint": "yarn run lint:eslint && yarn run lint:prettier && yarn run lint:tsc",
|
|
20
21
|
"lint:eslint": "eslint source ./*js",
|