@oliversalzburg/js-utils 0.0.5 → 0.0.7
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/{output → lib}/graphics/render-loop.d.ts +9 -0
- package/{output → lib}/graphics/render-loop.js +18 -1
- package/lib/graphics/render-loop.js.map +1 -0
- package/package.json +8 -10
- package/output/graphics/render-loop.js.map +0 -1
- package/output/vector.d.ts +0 -10
- package/output/vector.js +0 -19
- package/output/vector.js.map +0 -1
- /package/{output → lib}/array.d.ts +0 -0
- /package/{output → lib}/array.js +0 -0
- /package/{output → lib}/array.js.map +0 -0
- /package/{output → lib}/core.d.ts +0 -0
- /package/{output → lib}/core.js +0 -0
- /package/{output → lib}/core.js.map +0 -0
- /package/{output → lib}/error-serializer.d.ts +0 -0
- /package/{output → lib}/error-serializer.js +0 -0
- /package/{output → lib}/error-serializer.js.map +0 -0
- /package/{output → lib}/errors/AbstractError.d.ts +0 -0
- /package/{output → lib}/errors/AbstractError.js +0 -0
- /package/{output → lib}/errors/AbstractError.js.map +0 -0
- /package/{output → lib}/errors/InternalError.d.ts +0 -0
- /package/{output → lib}/errors/InternalError.js +0 -0
- /package/{output → lib}/errors/InternalError.js.map +0 -0
- /package/{output → lib}/errors/InvalidArgumentError.d.ts +0 -0
- /package/{output → lib}/errors/InvalidArgumentError.js +0 -0
- /package/{output → lib}/errors/InvalidArgumentError.js.map +0 -0
- /package/{output → lib}/errors/InvalidOperationError.d.ts +0 -0
- /package/{output → lib}/errors/InvalidOperationError.js +0 -0
- /package/{output → lib}/errors/InvalidOperationError.js.map +0 -0
- /package/{output → lib}/errors/NotImplementedError.d.ts +0 -0
- /package/{output → lib}/errors/NotImplementedError.js +0 -0
- /package/{output → lib}/errors/NotImplementedError.js.map +0 -0
- /package/{output → lib}/errors/PermissionViolationError.d.ts +0 -0
- /package/{output → lib}/errors/PermissionViolationError.js +0 -0
- /package/{output → lib}/errors/PermissionViolationError.js.map +0 -0
- /package/{output → lib}/errors/ResourceConflictError.d.ts +0 -0
- /package/{output → lib}/errors/ResourceConflictError.js +0 -0
- /package/{output → lib}/errors/ResourceConflictError.js.map +0 -0
- /package/{output → lib}/errors/UnknownError.d.ts +0 -0
- /package/{output → lib}/errors/UnknownError.js +0 -0
- /package/{output → lib}/errors/UnknownError.js.map +0 -0
- /package/{output → lib}/errors/index.d.ts +0 -0
- /package/{output → lib}/errors/index.js +0 -0
- /package/{output → lib}/errors/index.js.map +0 -0
- /package/{output → lib}/graphics/canvas.d.ts +0 -0
- /package/{output → lib}/graphics/canvas.js +0 -0
- /package/{output → lib}/graphics/canvas.js.map +0 -0
- /package/{output → lib}/graphics/core.d.ts +0 -0
- /package/{output → lib}/graphics/core.js +0 -0
- /package/{output → lib}/graphics/core.js.map +0 -0
- /package/{output → lib}/graphics/index.d.ts +0 -0
- /package/{output → lib}/graphics/index.js +0 -0
- /package/{output → lib}/graphics/index.js.map +0 -0
- /package/{output → lib}/index.d.ts +0 -0
- /package/{output → lib}/index.js +0 -0
- /package/{output → lib}/index.js.map +0 -0
- /package/{output → lib}/math/core.d.ts +0 -0
- /package/{output → lib}/math/core.js +0 -0
- /package/{output → lib}/math/core.js.map +0 -0
- /package/{output → lib}/math/index.d.ts +0 -0
- /package/{output → lib}/math/index.js +0 -0
- /package/{output → lib}/math/index.js.map +0 -0
- /package/{output → lib}/math/vector.d.ts +0 -0
- /package/{output → lib}/math/vector.js +0 -0
- /package/{output → lib}/math/vector.js.map +0 -0
- /package/{output → lib}/nil.d.ts +0 -0
- /package/{output → lib}/nil.js +0 -0
- /package/{output → lib}/nil.js.map +0 -0
- /package/{output → lib}/random.d.ts +0 -0
- /package/{output → lib}/random.js +0 -0
- /package/{output → lib}/random.js.map +0 -0
- /package/{output → lib}/sleep.d.ts +0 -0
- /package/{output → lib}/sleep.js +0 -0
- /package/{output → lib}/sleep.js.map +0 -0
- /package/{output → lib}/string-formatter.d.ts +0 -0
- /package/{output → lib}/string-formatter.js +0 -0
- /package/{output → lib}/string-formatter.js.map +0 -0
- /package/{output → lib}/string-formatter.test.d.ts +0 -0
- /package/{output → lib}/string-formatter.test.js +0 -0
- /package/{output → lib}/string-formatter.test.js.map +0 -0
|
@@ -10,6 +10,7 @@ export declare class RenderLoop {
|
|
|
10
10
|
readonly renderLoop: AnyFunction;
|
|
11
11
|
private previousTimestamp;
|
|
12
12
|
private readonly boundMain;
|
|
13
|
+
private frameRequestId;
|
|
13
14
|
/**
|
|
14
15
|
* Constructs a new {@link RenderLoop}.
|
|
15
16
|
* @param renderLoop The function to call when a new frame should be drawn.
|
|
@@ -17,4 +18,12 @@ export declare class RenderLoop {
|
|
|
17
18
|
* after a frame was rendered.
|
|
18
19
|
*/
|
|
19
20
|
constructor(renderLoop: AnyFunction, canvas?: Canvas);
|
|
21
|
+
/**
|
|
22
|
+
* Stop the render loop.
|
|
23
|
+
*/
|
|
24
|
+
block(): void;
|
|
25
|
+
/**
|
|
26
|
+
* Start the render loop.
|
|
27
|
+
*/
|
|
28
|
+
unblock(): void;
|
|
20
29
|
}
|
|
@@ -7,6 +7,7 @@ export class RenderLoop {
|
|
|
7
7
|
renderLoop;
|
|
8
8
|
previousTimestamp;
|
|
9
9
|
boundMain;
|
|
10
|
+
frameRequestId = null;
|
|
10
11
|
/**
|
|
11
12
|
* Constructs a new {@link RenderLoop}.
|
|
12
13
|
* @param renderLoop The function to call when a new frame should be drawn.
|
|
@@ -19,6 +20,22 @@ export class RenderLoop {
|
|
|
19
20
|
this.previousTimestamp = 0;
|
|
20
21
|
this.boundMain = this.#main.bind(this);
|
|
21
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Stop the render loop.
|
|
25
|
+
*/
|
|
26
|
+
block() {
|
|
27
|
+
if (this.frameRequestId === null) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
window.cancelAnimationFrame(this.frameRequestId);
|
|
31
|
+
this.frameRequestId = null;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Start the render loop.
|
|
35
|
+
*/
|
|
36
|
+
unblock() {
|
|
37
|
+
this.frameRequestId = window.requestAnimationFrame(this.boundMain);
|
|
38
|
+
}
|
|
22
39
|
/**
|
|
23
40
|
* Our main loop.
|
|
24
41
|
* @param timestamp The current timestamp.
|
|
@@ -26,7 +43,7 @@ export class RenderLoop {
|
|
|
26
43
|
#main(timestamp) {
|
|
27
44
|
const timeDelta = timestamp - this.previousTimestamp;
|
|
28
45
|
this.#drawFrame(timestamp, timeDelta);
|
|
29
|
-
|
|
46
|
+
this.unblock();
|
|
30
47
|
this.previousTimestamp = timestamp;
|
|
31
48
|
}
|
|
32
49
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render-loop.js","sourceRoot":"","sources":["../../source/graphics/render-loop.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,OAAO,UAAU;IACZ,MAAM,CAAqB;IAC3B,UAAU,CAAc;IACzB,iBAAiB,CAAS;IACjB,SAAS,CAA8B;IAChD,cAAc,GAAkB,IAAI,CAAC;IAE7C;;;;;OAKG;IACH,YAAY,UAAuB,EAAE,MAAe;QAClD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,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,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,qBAAqB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACrE,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,SAAiB;QACrB,MAAM,SAAS,GAAG,SAAS,GAAG,IAAI,CAAC,iBAAiB,CAAC;QACrD,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAEtC,IAAI,CAAC,OAAO,EAAE,CAAC;QAEf,IAAI,CAAC,iBAAiB,GAAG,SAAS,CAAC;IACrC,CAAC;IAED;;;;OAIG;IACH,UAAU,CAAC,SAAiB,EAAE,KAAa;QACzC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;QAE/C,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YAChB,OAAO;SACR;QAED,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QAErB,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC;QAC7C,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,GAAG,6BAA6B,CAAC;QAChE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,GAAG,CAAC,CAAC;QAClC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QAC3C,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;QAC1C,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;IAC3C,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
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.7",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Oliver Salzburg <oliver.salzburg@gmail.com>",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"exports": {
|
|
9
|
-
".":
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
"default": "./output/*.js"
|
|
14
|
-
}
|
|
9
|
+
".": "./lib/index.js",
|
|
10
|
+
"./lib": "./lib/index.js",
|
|
11
|
+
"./lib/*": "./lib/*.js",
|
|
12
|
+
"./lib/*.js": "./lib/*.js"
|
|
15
13
|
},
|
|
16
14
|
"scripts": {
|
|
17
15
|
"build": "yarn run build:tsc",
|
|
@@ -27,11 +25,11 @@
|
|
|
27
25
|
"npm:publish:minor": "npm version minor && npm publish",
|
|
28
26
|
"npm:publish:patch": "npm version patch && npm publish",
|
|
29
27
|
"prepack": "yarn run build",
|
|
30
|
-
"test": "node --enable-source-maps $(yarn bin mocha) ./
|
|
28
|
+
"test": "node --enable-source-maps $(yarn bin mocha) ./lib/*.test.js",
|
|
31
29
|
"test:coverage": "c8 --reporter html-spa --reporter text node --enable-source-maps $(yarn bin mocha)",
|
|
32
|
-
"test:inspect": "node $(yarn bin mocha) --inspect ./
|
|
30
|
+
"test:inspect": "node $(yarn bin mocha) --inspect ./lib/*.test.js"
|
|
33
31
|
},
|
|
34
|
-
"types": "./
|
|
32
|
+
"types": "./lib/index.d.ts",
|
|
35
33
|
"devDependencies": {
|
|
36
34
|
"@types/chai": "4.3.9",
|
|
37
35
|
"@types/chai-as-promised": "7.1.7",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"render-loop.js","sourceRoot":"","sources":["../../source/graphics/render-loop.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,OAAO,UAAU;IACZ,MAAM,CAAqB;IAC3B,UAAU,CAAc;IACzB,iBAAiB,CAAS;IACjB,SAAS,CAA8B;IAExD;;;;;OAKG;IACH,YAAY,UAAuB,EAAE,MAAe;QAClD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;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ts
DELETED
package/output/vector.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export class Vector2 {
|
|
2
|
-
x;
|
|
3
|
-
y;
|
|
4
|
-
constructor(x, y) {
|
|
5
|
-
this.x = x;
|
|
6
|
-
this.y = y;
|
|
7
|
-
}
|
|
8
|
-
dot2(x, y) {
|
|
9
|
-
return this.x * x + this.y * y;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
export class Vector3 extends Vector2 {
|
|
13
|
-
z;
|
|
14
|
-
constructor(x, y, z) {
|
|
15
|
-
super(x, y);
|
|
16
|
-
this.z = z;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=vector.js.map
|
package/output/vector.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vector.js","sourceRoot":"","sources":["../source/vector.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,OAAO;IAClB,CAAC,CAAS;IACV,CAAC,CAAS;IAEV,YAAY,CAAS,EAAE,CAAS;QAC9B,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;IACb,CAAC;IAED,IAAI,CAAC,CAAS,EAAE,CAAS;QACvB,OAAO,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC;CACF;AAED,MAAM,OAAO,OAAQ,SAAQ,OAAO;IAClC,CAAC,CAAS;IAEV,YAAY,CAAS,EAAE,CAAS,EAAE,CAAS;QACzC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACZ,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;IACb,CAAC;CACF"}
|
|
File without changes
|
/package/{output → lib}/array.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/{output → lib}/core.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/{output → lib}/index.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/{output → lib}/nil.d.ts
RENAMED
|
File without changes
|
/package/{output → lib}/nil.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/{output → lib}/sleep.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|