@oidoid/void 0.1.7 → 0.1.8
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/dist/public/index.js +1 -1
- package/dist/public/index.js.map +1 -1
- package/dist/public/{void-v0.1.7+20260106.c6b562a.html → void-v0.1.8+20260106.f2ce523.html} +2 -2
- package/dist/src/demo/ents/clock.test.d.ts +2 -0
- package/dist/src/demo/ents/clock.test.d.ts.map +1 -0
- package/dist/src/demo/ents/clock.test.js +24 -0
- package/dist/src/demo/ents/clock.test.js.map +1 -0
- package/dist/src/demo/tsconfig.json +3 -3
- package/dist/src/ents/cursor.test.d.ts +2 -0
- package/dist/src/ents/cursor.test.d.ts.map +1 -0
- package/dist/src/ents/cursor.test.js +92 -0
- package/dist/src/ents/cursor.test.js.map +1 -0
- package/dist/src/ents/ent-query.test.d.ts +11 -0
- package/dist/src/ents/ent-query.test.d.ts.map +1 -0
- package/dist/src/ents/ent-query.test.js +63 -0
- package/dist/src/ents/ent-query.test.js.map +1 -0
- package/dist/src/graphics/atlas-parser.test.d.ts +2 -0
- package/dist/src/graphics/atlas-parser.test.d.ts.map +1 -0
- package/dist/src/graphics/atlas-parser.test.js +100 -0
- package/dist/src/graphics/atlas-parser.test.js.map +1 -0
- package/dist/src/graphics/cam.test.d.ts +2 -0
- package/dist/src/graphics/cam.test.d.ts.map +1 -0
- package/dist/src/graphics/cam.test.js +456 -0
- package/dist/src/graphics/cam.test.js.map +1 -0
- package/dist/src/graphics/layer.test.d.ts +2 -0
- package/dist/src/graphics/layer.test.d.ts.map +1 -0
- package/dist/src/graphics/layer.test.js +23 -0
- package/dist/src/graphics/layer.test.js.map +1 -0
- package/dist/src/graphics/renderer.test.d.ts +2 -0
- package/dist/src/graphics/renderer.test.d.ts.map +1 -0
- package/dist/src/graphics/renderer.test.js +92 -0
- package/dist/src/graphics/renderer.test.js.map +1 -0
- package/dist/src/graphics/sprite.test.d.ts +2 -0
- package/dist/src/graphics/sprite.test.d.ts.map +1 -0
- package/dist/src/graphics/sprite.test.js +582 -0
- package/dist/src/graphics/sprite.test.js.map +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +0 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/input/context-menu.test.d.ts +2 -0
- package/dist/src/input/context-menu.test.d.ts.map +1 -0
- package/dist/src/input/context-menu.test.js +111 -0
- package/dist/src/input/context-menu.test.js.map +1 -0
- package/dist/src/input/gamepad.test.d.ts +2 -0
- package/dist/src/input/gamepad.test.d.ts.map +1 -0
- package/dist/src/input/gamepad.test.js +172 -0
- package/dist/src/input/gamepad.test.js.map +1 -0
- package/dist/src/input/input.test.d.ts +2 -0
- package/dist/src/input/input.test.d.ts.map +1 -0
- package/dist/src/input/input.test.js +1146 -0
- package/dist/src/input/input.test.js.map +1 -0
- package/dist/src/input/keyboard.test.d.ts +2 -0
- package/dist/src/input/keyboard.test.d.ts.map +1 -0
- package/dist/src/input/keyboard.test.js +159 -0
- package/dist/src/input/keyboard.test.js.map +1 -0
- package/dist/src/input/pointer.test.d.ts +2 -0
- package/dist/src/input/pointer.test.d.ts.map +1 -0
- package/dist/src/input/pointer.test.js +339 -0
- package/dist/src/input/pointer.test.js.map +1 -0
- package/dist/src/input/wheel.test.d.ts +2 -0
- package/dist/src/input/wheel.test.d.ts.map +1 -0
- package/dist/src/input/wheel.test.js +92 -0
- package/dist/src/input/wheel.test.js.map +1 -0
- package/dist/src/level/level-parser.test.d.ts +20 -0
- package/dist/src/level/level-parser.test.d.ts.map +1 -0
- package/dist/src/level/level-parser.test.js +340 -0
- package/dist/src/level/level-parser.test.js.map +1 -0
- package/dist/src/looper.test.d.ts +2 -0
- package/dist/src/looper.test.d.ts.map +1 -0
- package/dist/src/looper.test.js +128 -0
- package/dist/src/looper.test.js.map +1 -0
- package/dist/src/mem/pool.test.d.ts +2 -0
- package/dist/src/mem/pool.test.d.ts.map +1 -0
- package/dist/src/mem/pool.test.js +120 -0
- package/dist/src/mem/pool.test.js.map +1 -0
- package/dist/src/random/random.test.d.ts +2 -0
- package/dist/src/random/random.test.d.ts.map +1 -0
- package/dist/src/random/random.test.js +36 -0
- package/dist/src/random/random.test.js.map +1 -0
- package/dist/src/storage/local-storage.test.d.ts +2 -0
- package/dist/src/storage/local-storage.test.d.ts.map +1 -0
- package/dist/src/storage/local-storage.test.js +105 -0
- package/dist/src/storage/local-storage.test.js.map +1 -0
- package/dist/src/test/assert.d.ts +5 -0
- package/dist/src/test/assert.d.ts.map +1 -0
- package/dist/src/test/assert.js +6 -0
- package/dist/src/test/assert.js.map +1 -0
- package/dist/src/test/device-pixel-ratio-mock.d.ts +6 -0
- package/dist/src/test/device-pixel-ratio-mock.d.ts.map +1 -0
- package/dist/src/test/device-pixel-ratio-mock.js +10 -0
- package/dist/src/test/device-pixel-ratio-mock.js.map +1 -0
- package/dist/src/test/index.d.ts +5 -0
- package/dist/src/test/index.d.ts.map +1 -0
- package/dist/src/test/index.js +5 -0
- package/dist/src/test/index.js.map +1 -0
- package/dist/src/test/navigator-gamepads-mock.d.ts +7 -0
- package/dist/src/test/navigator-gamepads-mock.d.ts.map +1 -0
- package/dist/src/test/navigator-gamepads-mock.js +14 -0
- package/dist/src/test/navigator-gamepads-mock.js.map +1 -0
- package/dist/src/test/secure-context-mock.d.ts +6 -0
- package/dist/src/test/secure-context-mock.d.ts.map +1 -0
- package/dist/src/test/secure-context-mock.js +10 -0
- package/dist/src/test/secure-context-mock.js.map +1 -0
- package/dist/src/test/test-element.d.ts +2 -0
- package/dist/src/test/test-element.d.ts.map +1 -0
- package/dist/src/test/test-element.js +8 -0
- package/dist/src/test/test-element.js.map +1 -0
- package/dist/src/test/test-event.d.ts +17 -0
- package/dist/src/test/test-event.d.ts.map +1 -0
- package/dist/src/test/test-event.js +26 -0
- package/dist/src/test/test-event.js.map +1 -0
- package/dist/src/test/tsconfig.json +30 -0
- package/dist/src/text/text-layout.test.d.ts +2 -0
- package/dist/src/text/text-layout.test.d.ts.map +1 -0
- package/dist/src/text/text-layout.test.js +717 -0
- package/dist/src/text/text-layout.test.js.map +1 -0
- package/dist/src/tsconfig.json +3 -3
- package/dist/src/types/geo.test.d.ts +2 -0
- package/dist/src/types/geo.test.d.ts.map +1 -0
- package/dist/src/types/geo.test.js +657 -0
- package/dist/src/types/geo.test.js.map +1 -0
- package/dist/src/types/time.test.d.ts +2 -0
- package/dist/src/types/time.test.d.ts.map +1 -0
- package/dist/src/types/time.test.js +27 -0
- package/dist/src/types/time.test.js.map +1 -0
- package/dist/src/utils/async-util.test.d.ts +2 -0
- package/dist/src/utils/async-util.test.d.ts.map +1 -0
- package/dist/src/utils/async-util.test.js +55 -0
- package/dist/src/utils/async-util.test.js.map +1 -0
- package/dist/src/utils/color-util.test.d.ts +2 -0
- package/dist/src/utils/color-util.test.d.ts.map +1 -0
- package/dist/src/utils/color-util.test.js +20 -0
- package/dist/src/utils/color-util.test.js.map +1 -0
- package/dist/src/utils/debug.test.d.ts +2 -0
- package/dist/src/utils/debug.test.d.ts.map +1 -0
- package/dist/src/utils/debug.test.js +61 -0
- package/dist/src/utils/debug.test.js.map +1 -0
- package/dist/src/utils/delay-interval.test.d.ts +2 -0
- package/dist/src/utils/delay-interval.test.d.ts.map +1 -0
- package/dist/src/utils/delay-interval.test.js +91 -0
- package/dist/src/utils/delay-interval.test.js.map +1 -0
- package/dist/src/utils/math.test.d.ts +2 -0
- package/dist/src/utils/math.test.d.ts.map +1 -0
- package/dist/src/utils/math.test.js +10 -0
- package/dist/src/utils/math.test.js.map +1 -0
- package/dist/src/utils/str-util.test.d.ts +2 -0
- package/dist/src/utils/str-util.test.d.ts.map +1 -0
- package/dist/src/utils/str-util.test.js +13 -0
- package/dist/src/utils/str-util.test.js.map +1 -0
- package/dist/tools/atlas-pack/atlas-json-parser.test.d.ts +2 -0
- package/dist/tools/atlas-pack/atlas-json-parser.test.d.ts.map +1 -0
- package/dist/tools/atlas-pack/atlas-json-parser.test.js +2109 -0
- package/dist/tools/atlas-pack/atlas-json-parser.test.js.map +1 -0
- package/dist/tools/atlas-pack/atlas.test.aseprite.json +4499 -0
- package/dist/tools/bundle/bundle.js +1 -1
- package/dist/tools/types/config-file.test.d.ts +2 -0
- package/dist/tools/types/config-file.test.d.ts.map +1 -0
- package/dist/tools/types/config-file.test.js +68 -0
- package/dist/tools/types/config-file.test.js.map +1 -0
- package/dist/tools/types/config.test.d.ts +2 -0
- package/dist/tools/types/config.test.d.ts.map +1 -0
- package/dist/tools/types/config.test.js +125 -0
- package/dist/tools/types/config.test.js.map +1 -0
- package/dist/tools/utils/argv.test.d.ts +9 -0
- package/dist/tools/utils/argv.test.d.ts.map +1 -0
- package/dist/tools/utils/argv.test.js +42 -0
- package/dist/tools/utils/argv.test.js.map +1 -0
- package/package.json +7 -3
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
2
|
+
if (value !== null && value !== void 0) {
|
|
3
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
4
|
+
var dispose, inner;
|
|
5
|
+
if (async) {
|
|
6
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
7
|
+
dispose = value[Symbol.asyncDispose];
|
|
8
|
+
}
|
|
9
|
+
if (dispose === void 0) {
|
|
10
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
11
|
+
dispose = value[Symbol.dispose];
|
|
12
|
+
if (async) inner = dispose;
|
|
13
|
+
}
|
|
14
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
15
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
16
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
17
|
+
}
|
|
18
|
+
else if (async) {
|
|
19
|
+
env.stack.push({ async: true });
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
24
|
+
return function (env) {
|
|
25
|
+
function fail(e) {
|
|
26
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
27
|
+
env.hasError = true;
|
|
28
|
+
}
|
|
29
|
+
var r, s = 0;
|
|
30
|
+
function next() {
|
|
31
|
+
while (r = env.stack.pop()) {
|
|
32
|
+
try {
|
|
33
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
34
|
+
if (r.dispose) {
|
|
35
|
+
var result = r.dispose.call(r.value);
|
|
36
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
37
|
+
}
|
|
38
|
+
else s |= 1;
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
fail(e);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
45
|
+
if (env.hasError) throw env.error;
|
|
46
|
+
}
|
|
47
|
+
return next();
|
|
48
|
+
};
|
|
49
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
50
|
+
var e = new Error(message);
|
|
51
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
|
+
});
|
|
53
|
+
import { test } from 'node:test';
|
|
54
|
+
import { assert } from "../test/assert.js";
|
|
55
|
+
import { MenuTestEvent } from "../test/test-event.js";
|
|
56
|
+
import { ContextMenu } from "./context-menu.js";
|
|
57
|
+
test('ContextMenu', async (ctx) => {
|
|
58
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
59
|
+
try {
|
|
60
|
+
const target = new EventTarget();
|
|
61
|
+
const menu = __addDisposableResource(env_1, new ContextMenu(target).register('add'), false);
|
|
62
|
+
await ctx.test('disabled', () => {
|
|
63
|
+
let blocked = 0;
|
|
64
|
+
target.dispatchEvent(MenuTestEvent('contextmenu', { preventDefault: () => blocked++ }));
|
|
65
|
+
assert(blocked, 1);
|
|
66
|
+
target.dispatchEvent(MenuTestEvent('touchstart', { preventDefault: () => blocked++ }));
|
|
67
|
+
assert(blocked, 2);
|
|
68
|
+
});
|
|
69
|
+
await ctx.test('enabled', () => {
|
|
70
|
+
menu.enable = true;
|
|
71
|
+
let blocked = 0;
|
|
72
|
+
target.dispatchEvent(MenuTestEvent('contextmenu', { preventDefault: () => blocked++ }));
|
|
73
|
+
assert(blocked, 0);
|
|
74
|
+
target.dispatchEvent(MenuTestEvent('touchstart', { preventDefault: () => blocked++ }));
|
|
75
|
+
assert(blocked, 0);
|
|
76
|
+
});
|
|
77
|
+
await ctx.test('modified events are skipped', () => {
|
|
78
|
+
menu.enable = true;
|
|
79
|
+
let blocked = 0;
|
|
80
|
+
target.dispatchEvent(MenuTestEvent('contextmenu', {
|
|
81
|
+
altKey: true,
|
|
82
|
+
preventDefault: () => blocked++
|
|
83
|
+
}));
|
|
84
|
+
assert(blocked, 0);
|
|
85
|
+
target.dispatchEvent(MenuTestEvent('contextmenu', {
|
|
86
|
+
metaKey: true,
|
|
87
|
+
preventDefault: () => blocked++
|
|
88
|
+
}));
|
|
89
|
+
assert(blocked, 0);
|
|
90
|
+
target.dispatchEvent(MenuTestEvent('contextmenu', {
|
|
91
|
+
ctrlKey: true,
|
|
92
|
+
preventDefault: () => blocked++
|
|
93
|
+
}));
|
|
94
|
+
assert(blocked, 0);
|
|
95
|
+
});
|
|
96
|
+
await ctx.test('untrusted events are skipped', () => {
|
|
97
|
+
menu.enable = true;
|
|
98
|
+
let blocked = 0;
|
|
99
|
+
target.dispatchEvent(Object.assign(new Event('contextmenu'), { preventDefault: () => blocked++ }));
|
|
100
|
+
assert(blocked, 0);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
catch (e_1) {
|
|
104
|
+
env_1.error = e_1;
|
|
105
|
+
env_1.hasError = true;
|
|
106
|
+
}
|
|
107
|
+
finally {
|
|
108
|
+
__disposeResources(env_1);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
//# sourceMappingURL=context-menu.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-menu.test.js","sourceRoot":"","sources":["../../../src/input/context-menu.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,EAAC,MAAM,EAAC,MAAM,mBAAmB,CAAA;AACxC,OAAO,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAA;AACnD,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAA;AAE7C,IAAI,CAAC,aAAa,EAAE,KAAK,EAAC,GAAG,EAAC,EAAE;;;QAC9B,MAAM,MAAM,GAAG,IAAI,WAAW,EAAE,CAAA;QAChC,MAAM,IAAI,kCAAG,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAA,CAAA;QAEpD,MAAM,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,EAAE;YAC9B,IAAI,OAAO,GAAG,CAAC,CAAA;YACf,MAAM,CAAC,aAAa,CAClB,aAAa,CAAC,aAAa,EAAE,EAAC,cAAc,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,EAAC,CAAC,CAChE,CAAA;YACD,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;YAClB,MAAM,CAAC,aAAa,CAClB,aAAa,CAAC,YAAY,EAAE,EAAC,cAAc,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,EAAC,CAAC,CAC/D,CAAA;YACD,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;QACpB,CAAC,CAAC,CAAA;QAEF,MAAM,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE;YAC7B,IAAI,CAAC,MAAM,G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E,GAAG,EAAE;YAClD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;YAClB,IAAI,OAAO,GAAG,CAAC,CAAA;YACf,MAAM,CAAC,aAAa,CAClB,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,aAAa,CAAC,EAAE,EAAC,cAAc,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,EAAC,CAAC,CAC3E,CAAA;YACD,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAA;QACpB,CAAC,CAAC,CAAA;;;;;;;;;CACH,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gamepad.test.d.ts","sourceRoot":"","sources":["../../../src/input/gamepad.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
2
|
+
if (value !== null && value !== void 0) {
|
|
3
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
4
|
+
var dispose, inner;
|
|
5
|
+
if (async) {
|
|
6
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
7
|
+
dispose = value[Symbol.asyncDispose];
|
|
8
|
+
}
|
|
9
|
+
if (dispose === void 0) {
|
|
10
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
11
|
+
dispose = value[Symbol.dispose];
|
|
12
|
+
if (async) inner = dispose;
|
|
13
|
+
}
|
|
14
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
15
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
16
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
17
|
+
}
|
|
18
|
+
else if (async) {
|
|
19
|
+
env.stack.push({ async: true });
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
24
|
+
return function (env) {
|
|
25
|
+
function fail(e) {
|
|
26
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
27
|
+
env.hasError = true;
|
|
28
|
+
}
|
|
29
|
+
var r, s = 0;
|
|
30
|
+
function next() {
|
|
31
|
+
while (r = env.stack.pop()) {
|
|
32
|
+
try {
|
|
33
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
34
|
+
if (r.dispose) {
|
|
35
|
+
var result = r.dispose.call(r.value);
|
|
36
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
37
|
+
}
|
|
38
|
+
else s |= 1;
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
fail(e);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
45
|
+
if (env.hasError) throw env.error;
|
|
46
|
+
}
|
|
47
|
+
return next();
|
|
48
|
+
};
|
|
49
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
50
|
+
var e = new Error(message);
|
|
51
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
|
+
});
|
|
53
|
+
import { test } from 'node:test';
|
|
54
|
+
import { assert } from "../test/assert.js";
|
|
55
|
+
import { NavigatorGamepadsMock } from "../test/navigator-gamepads-mock.js";
|
|
56
|
+
import { SecureContextMock } from "../test/secure-context-mock.js";
|
|
57
|
+
import { Gamepad } from "./gamepad.js";
|
|
58
|
+
test('Gamepad', async (ctx) => {
|
|
59
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
60
|
+
try {
|
|
61
|
+
const secureContext = __addDisposableResource(env_1, new SecureContextMock(), false);
|
|
62
|
+
secureContext.secure = true;
|
|
63
|
+
const navigator = __addDisposableResource(env_1, new NavigatorGamepadsMock(), false);
|
|
64
|
+
const target = new EventTarget();
|
|
65
|
+
const gamepad = __addDisposableResource(env_1, new Gamepad(target).register('add'), false);
|
|
66
|
+
gamepad.bitByButton[0] = 1;
|
|
67
|
+
await ctx.test('init', () => {
|
|
68
|
+
navigator.gamepads = [null];
|
|
69
|
+
assert(gamepad.bits, 0);
|
|
70
|
+
});
|
|
71
|
+
await ctx.test('no pads', () => {
|
|
72
|
+
navigator.gamepads = [];
|
|
73
|
+
gamepad.update();
|
|
74
|
+
assert(gamepad.bits, 0);
|
|
75
|
+
assert(gamepad.connected, false);
|
|
76
|
+
});
|
|
77
|
+
await ctx.test('one pad', () => {
|
|
78
|
+
navigator.gamepads = [
|
|
79
|
+
{ axes: [], buttons: [{ pressed: true }] }
|
|
80
|
+
];
|
|
81
|
+
assert(gamepad.connected, true);
|
|
82
|
+
gamepad.update();
|
|
83
|
+
assert(gamepad.bits, 1);
|
|
84
|
+
});
|
|
85
|
+
await ctx.test('update clears previous bits', () => {
|
|
86
|
+
// first update sets a bit.
|
|
87
|
+
navigator.gamepads = [
|
|
88
|
+
{ axes: [], buttons: [{ pressed: true }] }
|
|
89
|
+
];
|
|
90
|
+
gamepad.update();
|
|
91
|
+
assert(gamepad.bits, 1);
|
|
92
|
+
// second update with no buttons clears the bit.
|
|
93
|
+
navigator.gamepads = [
|
|
94
|
+
{ axes: [], buttons: [{ pressed: false }] }
|
|
95
|
+
];
|
|
96
|
+
gamepad.update();
|
|
97
|
+
assert(gamepad.bits, 0);
|
|
98
|
+
});
|
|
99
|
+
await ctx.test('axes thresholds', () => {
|
|
100
|
+
// map axis 0 to separate bits for negative and positive thresholds.
|
|
101
|
+
gamepad.bitByAxis[0] = [2, 4];
|
|
102
|
+
// zero yields no bit.
|
|
103
|
+
navigator.gamepads = [
|
|
104
|
+
{ axes: [0], buttons: [] }
|
|
105
|
+
];
|
|
106
|
+
gamepad.reset();
|
|
107
|
+
gamepad.update();
|
|
108
|
+
assert(gamepad.bits, 0);
|
|
109
|
+
// below positive threshold yields no bit.
|
|
110
|
+
navigator.gamepads = [
|
|
111
|
+
{ axes: [0.49], buttons: [] }
|
|
112
|
+
];
|
|
113
|
+
gamepad.reset();
|
|
114
|
+
gamepad.update();
|
|
115
|
+
assert(gamepad.bits, 0);
|
|
116
|
+
// a positive threshold yields "more" bit.
|
|
117
|
+
navigator.gamepads = [
|
|
118
|
+
{ axes: [0.5], buttons: [] }
|
|
119
|
+
];
|
|
120
|
+
gamepad.reset();
|
|
121
|
+
gamepad.update();
|
|
122
|
+
assert(gamepad.bits, 4);
|
|
123
|
+
// a negative threshold yields "less" bit.
|
|
124
|
+
navigator.gamepads = [
|
|
125
|
+
{ axes: [-0.5], buttons: [] }
|
|
126
|
+
];
|
|
127
|
+
gamepad.reset();
|
|
128
|
+
gamepad.update();
|
|
129
|
+
assert(gamepad.bits, 2);
|
|
130
|
+
// below negative threshold magnitude yields no bit.
|
|
131
|
+
navigator.gamepads = [
|
|
132
|
+
{ axes: [-0.49], buttons: [] }
|
|
133
|
+
];
|
|
134
|
+
gamepad.reset();
|
|
135
|
+
gamepad.update();
|
|
136
|
+
assert(gamepad.bits, 0);
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
catch (e_1) {
|
|
140
|
+
env_1.error = e_1;
|
|
141
|
+
env_1.hasError = true;
|
|
142
|
+
}
|
|
143
|
+
finally {
|
|
144
|
+
__disposeResources(env_1);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
test('insecure context ignores pads', () => {
|
|
148
|
+
const env_2 = { stack: [], error: void 0, hasError: false };
|
|
149
|
+
try {
|
|
150
|
+
const secureContext = __addDisposableResource(env_2, new SecureContextMock(), false);
|
|
151
|
+
secureContext.secure = false;
|
|
152
|
+
const navigator = __addDisposableResource(env_2, new NavigatorGamepadsMock(), false);
|
|
153
|
+
const target = new EventTarget();
|
|
154
|
+
const gamepad = __addDisposableResource(env_2, new Gamepad(target).register('add'), false);
|
|
155
|
+
gamepad.bitByButton[0] = 1;
|
|
156
|
+
navigator.gamepads = [
|
|
157
|
+
{ axes: [1], buttons: [{ pressed: true }] }
|
|
158
|
+
];
|
|
159
|
+
gamepad.reset();
|
|
160
|
+
gamepad.update();
|
|
161
|
+
assert(gamepad.bits, 0);
|
|
162
|
+
assert(gamepad.connected, false);
|
|
163
|
+
}
|
|
164
|
+
catch (e_2) {
|
|
165
|
+
env_2.error = e_2;
|
|
166
|
+
env_2.hasError = true;
|
|
167
|
+
}
|
|
168
|
+
finally {
|
|
169
|
+
__disposeResources(env_2);
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
//# sourceMappingURL=gamepad.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gamepad.test.js","sourceRoot":"","sources":["../../../src/input/gamepad.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,EAAC,MAAM,EAAC,MAAM,mBAAmB,CAAA;AACxC,OAAO,EAAC,qBAAqB,EAAC,MAAM,oCAAoC,CAAA;AACxE,OAAO,EAAC,iBAAiB,EAAC,MAAM,gCAAgC,CAAA;AAChE,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAA;AAEpC,IAAI,CAAC,SAAS,EAAE,KAAK,EAAC,GAAG,EAAC,EAAE;;;QAC1B,MAAM,aAAa,kCAAG,IAAI,iBAAiB,EAAE,QAAA,CAAA;QAC7C,aAAa,CAAC,MAAM,GAAG,IAAI,CAAA;QAC3B,MAAM,SAAS,kCAAG,IAAI,qBAAqB,EAAE,QAAA,CAAA;QAC7C,MAAM,MAAM,GAAG,IAAI,WAAW,EAAE,CAAA;QAChC,MAAM,OAAO,kCAAG,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAA,CAAA;QACnD,OAAO,CAAC,WAAW,CAAC,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