@famibee/skynovel 1.64.22 → 2.0.0

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.
Files changed (186) hide show
  1. package/README.md +3 -3
  2. package/dist/Button.js +131 -163
  3. package/dist/Button.js.map +1 -1
  4. package/dist/CallStack.js +19 -22
  5. package/dist/CallStack.js.map +1 -1
  6. package/dist/CmnInterface.js +91 -0
  7. package/dist/CmnInterface.js.map +1 -0
  8. package/dist/CmnLib.js +94 -0
  9. package/dist/CmnLib.js.map +1 -0
  10. package/dist/Config.js +26 -0
  11. package/dist/Config.js.map +1 -0
  12. package/dist/ConfigBase.js +152 -0
  13. package/dist/ConfigBase.js.map +1 -0
  14. package/dist/DebugMng.js +89 -102
  15. package/dist/DebugMng.js.map +1 -1
  16. package/dist/EventListenerCtn.js +21 -0
  17. package/dist/EventListenerCtn.js.map +1 -0
  18. package/dist/EventMng.js +1435 -1577
  19. package/dist/EventMng.js.map +1 -1
  20. package/dist/Grammar.js +194 -0
  21. package/dist/Grammar.js.map +1 -0
  22. package/dist/GrpLayer.js +163 -195
  23. package/dist/GrpLayer.js.map +1 -1
  24. package/dist/Layer.js +260 -0
  25. package/dist/Layer.js.map +1 -0
  26. package/dist/LayerMng.js +810 -992
  27. package/dist/LayerMng.js.map +1 -1
  28. package/dist/Main.js +144 -393
  29. package/dist/Main.js.map +1 -1
  30. package/dist/PropParser.js +936 -834
  31. package/dist/PropParser.js.map +1 -1
  32. package/dist/Reading.js +918 -786
  33. package/dist/Reading.js.map +1 -1
  34. package/dist/RubySpliter.js +59 -89
  35. package/dist/RubySpliter.js.map +1 -1
  36. package/dist/ScriptIterator.js +805 -1035
  37. package/dist/ScriptIterator.js.map +1 -1
  38. package/dist/SndBuf.js +1097 -1326
  39. package/dist/SndBuf.js.map +1 -1
  40. package/dist/SoundMng.js +124 -135
  41. package/dist/SoundMng.js.map +1 -1
  42. package/dist/SpritesMng.js +220 -232
  43. package/dist/SpritesMng.js.map +1 -1
  44. package/dist/SysBase.js +1729 -0
  45. package/dist/SysBase.js.map +1 -0
  46. package/dist/TxtLayer.js +1212 -1398
  47. package/dist/TxtLayer.js.map +1 -1
  48. package/dist/Variable.js +398 -466
  49. package/dist/Variable.js.map +1 -1
  50. package/dist/chunk.js +18 -0
  51. package/dist/gamepad.js +723 -511
  52. package/dist/gamepad.js.map +1 -1
  53. package/dist/pixi.js +13422 -0
  54. package/dist/pixi.js.map +1 -0
  55. package/dist/platform.js +424 -369
  56. package/dist/platform.js.map +1 -1
  57. package/dist/sn/AnalyzeTagArg.d.ts +1 -1
  58. package/dist/sn/AnalyzeTagArg.d.ts.map +1 -1
  59. package/dist/sn/CmnInterface.d.ts +3 -1
  60. package/dist/sn/CmnInterface.d.ts.map +1 -1
  61. package/dist/sn/CmnLib.d.ts.map +1 -1
  62. package/dist/sn/CmnTween.d.ts +7 -7
  63. package/dist/sn/CmnTween.d.ts.map +1 -1
  64. package/dist/sn/EventMng.d.ts.map +1 -1
  65. package/dist/sn/FocusMng.d.ts.map +1 -1
  66. package/dist/sn/Grammar.d.ts +1 -1
  67. package/dist/sn/Grammar.d.ts.map +1 -1
  68. package/dist/sn/Log.d.ts.map +1 -1
  69. package/dist/sn/Main.d.ts.map +1 -1
  70. package/dist/sn/Pages.d.ts.map +1 -1
  71. package/dist/sn/PropParser.d.ts +2 -2
  72. package/dist/sn/PropParser.d.ts.map +1 -1
  73. package/dist/sn/Reading.d.ts +7 -0
  74. package/dist/sn/Reading.d.ts.map +1 -1
  75. package/dist/sn/RubySpliter.d.ts.map +1 -1
  76. package/dist/sn/ScriptIterator.d.ts.map +1 -1
  77. package/dist/sn/SndBuf.d.ts +27 -16
  78. package/dist/sn/SndBuf.d.ts.map +1 -1
  79. package/dist/sn/SoundMng.d.ts +4 -1
  80. package/dist/sn/SoundMng.d.ts.map +1 -1
  81. package/dist/sn/SysBase.d.ts.map +1 -1
  82. package/dist/sn/TxtStage.d.ts +4 -1
  83. package/dist/sn/TxtStage.d.ts.map +1 -1
  84. package/dist/test/ValTest.d.ts +1 -1
  85. package/dist/test/ValTest.d.ts.map +1 -1
  86. package/dist/web.js +653 -8
  87. package/dist/web.js.map +1 -1
  88. package/dist_app/Button.js +131 -163
  89. package/dist_app/Button.js.map +1 -1
  90. package/dist_app/CallStack.js +19 -22
  91. package/dist_app/CallStack.js.map +1 -1
  92. package/dist_app/CmnInterface.js +91 -0
  93. package/dist_app/CmnInterface.js.map +1 -0
  94. package/dist_app/CmnLib.js +94 -0
  95. package/dist_app/CmnLib.js.map +1 -0
  96. package/dist_app/Config.js +26 -0
  97. package/dist_app/Config.js.map +1 -0
  98. package/dist_app/ConfigBase.js +152 -0
  99. package/dist_app/ConfigBase.js.map +1 -0
  100. package/dist_app/DebugMng.js +92 -0
  101. package/dist_app/DebugMng.js.map +1 -0
  102. package/dist_app/EventListenerCtn.js +21 -0
  103. package/dist_app/EventListenerCtn.js.map +1 -0
  104. package/dist_app/EventMng.js +1435 -1577
  105. package/dist_app/EventMng.js.map +1 -1
  106. package/dist_app/Grammar.js +194 -0
  107. package/dist_app/Grammar.js.map +1 -0
  108. package/dist_app/GrpLayer.js +163 -195
  109. package/dist_app/GrpLayer.js.map +1 -1
  110. package/dist_app/Layer.js +260 -0
  111. package/dist_app/Layer.js.map +1 -0
  112. package/dist_app/LayerMng.js +810 -992
  113. package/dist_app/LayerMng.js.map +1 -1
  114. package/dist_app/Main.js +144 -392
  115. package/dist_app/Main.js.map +1 -1
  116. package/dist_app/PropParser.js +936 -834
  117. package/dist_app/PropParser.js.map +1 -1
  118. package/dist_app/Reading.js +918 -786
  119. package/dist_app/Reading.js.map +1 -1
  120. package/dist_app/RubySpliter.js +59 -89
  121. package/dist_app/RubySpliter.js.map +1 -1
  122. package/dist_app/ScriptIterator.js +805 -1034
  123. package/dist_app/ScriptIterator.js.map +1 -1
  124. package/dist_app/SndBuf.js +1097 -1326
  125. package/dist_app/SndBuf.js.map +1 -1
  126. package/dist_app/SoundMng.js +124 -135
  127. package/dist_app/SoundMng.js.map +1 -1
  128. package/dist_app/SpritesMng.js +220 -231
  129. package/dist_app/SpritesMng.js.map +1 -1
  130. package/dist_app/SysBase.js +1729 -0
  131. package/dist_app/SysBase.js.map +1 -0
  132. package/dist_app/TxtLayer.js +1212 -1397
  133. package/dist_app/TxtLayer.js.map +1 -1
  134. package/dist_app/Variable.js +398 -466
  135. package/dist_app/Variable.js.map +1 -1
  136. package/dist_app/app.js +211 -8
  137. package/dist_app/app.js.map +1 -1
  138. package/dist_app/appMain.js +20 -21
  139. package/dist_app/appMain.js.map +1 -1
  140. package/dist_app/chunk.js +18 -0
  141. package/dist_app/gamepad.js +723 -511
  142. package/dist_app/gamepad.js.map +1 -1
  143. package/dist_app/pixi.js +11181 -0
  144. package/dist_app/pixi.js.map +1 -0
  145. package/dist_app/platform.js +424 -369
  146. package/dist_app/platform.js.map +1 -1
  147. package/dist_app/preload.js +2 -2
  148. package/dist_app/preload.js.map +1 -1
  149. package/dist_app/sn/AnalyzeTagArg.d.ts +1 -1
  150. package/dist_app/sn/AnalyzeTagArg.d.ts.map +1 -1
  151. package/dist_app/sn/CmnInterface.d.ts +3 -1
  152. package/dist_app/sn/CmnInterface.d.ts.map +1 -1
  153. package/dist_app/sn/CmnLib.d.ts.map +1 -1
  154. package/dist_app/sn/CmnTween.d.ts +7 -7
  155. package/dist_app/sn/CmnTween.d.ts.map +1 -1
  156. package/dist_app/sn/EventMng.d.ts.map +1 -1
  157. package/dist_app/sn/FocusMng.d.ts.map +1 -1
  158. package/dist_app/sn/Grammar.d.ts +1 -1
  159. package/dist_app/sn/Grammar.d.ts.map +1 -1
  160. package/dist_app/sn/Log.d.ts.map +1 -1
  161. package/dist_app/sn/Main.d.ts.map +1 -1
  162. package/dist_app/sn/Pages.d.ts.map +1 -1
  163. package/dist_app/sn/PropParser.d.ts +2 -2
  164. package/dist_app/sn/PropParser.d.ts.map +1 -1
  165. package/dist_app/sn/Reading.d.ts +7 -0
  166. package/dist_app/sn/Reading.d.ts.map +1 -1
  167. package/dist_app/sn/RubySpliter.d.ts.map +1 -1
  168. package/dist_app/sn/ScriptIterator.d.ts.map +1 -1
  169. package/dist_app/sn/SndBuf.d.ts +27 -16
  170. package/dist_app/sn/SndBuf.d.ts.map +1 -1
  171. package/dist_app/sn/SoundMng.d.ts +4 -1
  172. package/dist_app/sn/SoundMng.d.ts.map +1 -1
  173. package/dist_app/sn/SysBase.d.ts.map +1 -1
  174. package/dist_app/sn/TxtStage.d.ts +4 -1
  175. package/dist_app/sn/TxtStage.d.ts.map +1 -1
  176. package/dist_app/test/ValTest.d.ts +1 -1
  177. package/dist_app/test/ValTest.d.ts.map +1 -1
  178. package/package.json +24 -14
  179. package/dist/CmnTween.js +0 -193
  180. package/dist/CmnTween.js.map +0 -1
  181. package/dist/web2.js +0 -21644
  182. package/dist/web2.js.map +0 -1
  183. package/dist_app/CmnTween.js +0 -193
  184. package/dist_app/CmnTween.js.map +0 -1
  185. package/dist_app/app2.js +0 -18547
  186. package/dist_app/app2.js.map +0 -1
@@ -1,511 +1,723 @@
1
- function Q(F, z) {
2
- for (var D = 0; D < z.length; D++) {
3
- const B = z[D];
4
- if (typeof B != "string" && !Array.isArray(B)) {
5
- for (const x in B)
6
- if (x !== "default" && !(x in F)) {
7
- const q = Object.getOwnPropertyDescriptor(B, x);
8
- q && Object.defineProperty(F, x, q.get ? q : {
9
- enumerable: !0,
10
- get: () => B[x]
11
- });
12
- }
13
- }
14
- }
15
- return Object.freeze(Object.defineProperty(F, Symbol.toStringTag, { value: "Module" }));
16
- }
17
- var U = { exports: {} }, X = U.exports, W;
18
- function Y() {
19
- return W || (W = 1, function(F, z) {
20
- (function(D, B) {
21
- F.exports = B();
22
- })(X, () => (() => {
23
- var D = { 944: function(m) {
24
- var g;
25
- g = () => (() => {
26
- var S = { d: (u, c) => {
27
- for (var s in c) S.o(c, s) && !S.o(u, s) && Object.defineProperty(u, s, { enumerable: !0, get: c[s] });
28
- }, o: (u, c) => Object.prototype.hasOwnProperty.call(u, c) }, I = {};
29
- function w(u) {
30
- return w = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(c) {
31
- return typeof c;
32
- } : function(c) {
33
- return c && typeof Symbol == "function" && c.constructor === Symbol && c !== Symbol.prototype ? "symbol" : typeof c;
34
- }, w(u);
35
- }
36
- function A(u, c) {
37
- var s = typeof Symbol < "u" && u[Symbol.iterator] || u["@@iterator"];
38
- if (!s) {
39
- if (Array.isArray(u) || (s = O(u)) || c) {
40
- s && (u = s);
41
- var i = 0, f = function() {
42
- };
43
- return { s: f, n: function() {
44
- return i >= u.length ? { done: !0 } : { done: !1, value: u[i++] };
45
- }, e: function(p) {
46
- throw p;
47
- }, f };
48
- }
49
- throw new TypeError(`Invalid attempt to iterate non-iterable instance.
50
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
51
- }
52
- var d, v = !0, h = !1;
53
- return { s: function() {
54
- s = s.call(u);
55
- }, n: function() {
56
- var p = s.next();
57
- return v = p.done, p;
58
- }, e: function(p) {
59
- h = !0, d = p;
60
- }, f: function() {
61
- try {
62
- v || s.return == null || s.return();
63
- } finally {
64
- if (h) throw d;
65
- }
66
- } };
67
- }
68
- function y(u, c) {
69
- return function(s) {
70
- if (Array.isArray(s)) return s;
71
- }(u) || function(s, i) {
72
- var f = s == null ? null : typeof Symbol < "u" && s[Symbol.iterator] || s["@@iterator"];
73
- if (f != null) {
74
- var d, v, h, p, R = [], V = !0, L = !1;
75
- try {
76
- if (h = (f = f.call(s)).next, i !== 0) for (; !(V = (d = h.call(f)).done) && (R.push(d.value), R.length !== i); V = !0) ;
77
- } catch (H) {
78
- L = !0, v = H;
79
- } finally {
80
- try {
81
- if (!V && f.return != null && (p = f.return(), Object(p) !== p)) return;
82
- } finally {
83
- if (L) throw v;
84
- }
85
- }
86
- return R;
87
- }
88
- }(u, c) || O(u, c) || function() {
89
- throw new TypeError(`Invalid attempt to destructure non-iterable instance.
90
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
91
- }();
92
- }
93
- function O(u, c) {
94
- if (u) {
95
- if (typeof u == "string") return E(u, c);
96
- var s = Object.prototype.toString.call(u).slice(8, -1);
97
- return s === "Object" && u.constructor && (s = u.constructor.name), s === "Map" || s === "Set" ? Array.from(u) : s === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s) ? E(u, c) : void 0;
98
- }
99
- }
100
- function E(u, c) {
101
- (c == null || c > u.length) && (c = u.length);
102
- for (var s = 0, i = new Array(c); s < c; s++) i[s] = u[s];
103
- return i;
104
- }
105
- function j(u, c) {
106
- if (!(u instanceof c)) throw new TypeError("Cannot call a class as a function");
107
- }
108
- S.d(I, { default: () => Z });
109
- var Z = function() {
110
- function u() {
111
- var i = !(arguments.length > 0 && arguments[0] !== void 0) || arguments[0];
112
- j(this, u), this.strict = i, this.defaults = /* @__PURE__ */ new Map(), this.validators = /* @__PURE__ */ new Map(), this.types = /* @__PURE__ */ new Map(), this.optional = /* @__PURE__ */ new Set(), this.required = /* @__PURE__ */ new Set();
113
- }
114
- var c, s;
115
- return c = u, (s = [{ key: "allowExtra", value: function() {
116
- return this.strict = !1, this;
117
- } }, { key: "setDefaults", value: function(i) {
118
- var f = this;
119
- return Object.entries(i).forEach(function(d) {
120
- var v = y(d, 2), h = v[0], p = v[1];
121
- return f.defaults.set(h, p);
122
- }), this;
123
- } }, { key: "setValidators", value: function(i) {
124
- var f = this;
125
- return Object.entries(i).forEach(function(d) {
126
- var v = y(d, 2), h = v[0], p = v[1];
127
- return f.validators.set(h, p);
128
- }), this;
129
- } }, { key: "setTypes", value: function(i) {
130
- var f = this;
131
- return Object.entries(i).forEach(function(d) {
132
- var v = y(d, 2), h = v[0], p = v[1];
133
- return f.types.set(h, p);
134
- }), this;
135
- } }, { key: "setOptional", value: function(i) {
136
- var f = this;
137
- return i.forEach(function(d) {
138
- return f.optional.add(d);
139
- }), this;
140
- } }, { key: "setRequired", value: function(i) {
141
- var f = this;
142
- return i.forEach(function(d) {
143
- return f.required.add(d);
144
- }), this;
145
- } }, { key: "resolve", value: function(i) {
146
- return this.validate(Object.assign(this.getDefaults(), i));
147
- } }, { key: "getDefaults", value: function() {
148
- var i, f = {}, d = A(this.defaults);
149
- try {
150
- for (d.s(); !(i = d.n()).done; ) {
151
- var v = y(i.value, 2), h = v[0], p = v[1];
152
- f[h] = p;
153
- }
154
- } catch (R) {
155
- d.e(R);
156
- } finally {
157
- d.f();
158
- }
159
- return f;
160
- } }, { key: "validate", value: function(i) {
161
- for (var f in i) this.validators.has(f) && (i[f] = this.validators.get(f)(i[f]));
162
- for (var d in i) {
163
- if (!this.optionExists(d)) throw new Error('Unkown option "'.concat(d, '".'));
164
- this.checkType(d, i[d]);
165
- }
166
- var v, h = A(this.required.values());
167
- try {
168
- for (h.s(); !(v = h.n()).done; ) {
169
- var p = v.value;
170
- if (i[p] === void 0) throw new Error('Option "'.concat(p, '" is required.'));
171
- }
172
- } catch (R) {
173
- h.e(R);
174
- } finally {
175
- h.f();
176
- }
177
- return i;
178
- } }, { key: "checkType", value: function(i, f) {
179
- if (this.types.has(i)) {
180
- var d = this.types.get(i), v = w(f);
181
- if (v !== d) throw new Error('Wrong value for option "'.concat(i, '": expected type "').concat(d, '", got "').concat(v, '".'));
182
- }
183
- } }, { key: "optionExists", value: function(i) {
184
- return !this.strict || this.defaults.has(i) || this.validators.has(i) || this.optional.has(i) || this.required.has(i) || this.types.has(i);
185
- } }]) && function(i, f) {
186
- for (var d = 0; d < f.length; d++) {
187
- var v = f[d];
188
- v.enumerable = v.enumerable || !1, v.configurable = !0, "value" in v && (v.writable = !0), Object.defineProperty(i, (h = function(p, R) {
189
- if (w(p) !== "object" || p === null) return p;
190
- var V = p[Symbol.toPrimitive];
191
- if (V !== void 0) {
192
- var L = V.call(p, "string");
193
- if (w(L) !== "object") return L;
194
- throw new TypeError("@@toPrimitive must return a primitive value.");
195
- }
196
- return String(p);
197
- }(v.key), w(h) === "symbol" ? h : String(h)), v);
198
- }
199
- var h;
200
- }(c.prototype, s), Object.defineProperty(c, "prototype", { writable: !1 }), u;
201
- }();
202
- return I.default;
203
- })(), m.exports = g();
204
- }, 162: function(m) {
205
- m.exports = (() => {
206
- var g = { d: (w, A) => {
207
- for (var y in A) g.o(A, y) && !g.o(w, y) && Object.defineProperty(w, y, { enumerable: !0, get: A[y] });
208
- }, o: (w, A) => Object.prototype.hasOwnProperty.call(w, A) }, S = {};
209
- g.d(S, { default: () => I });
210
- var I = function() {
211
- function w() {
212
- (function(y, O) {
213
- if (!(y instanceof O)) throw new TypeError("Cannot call a class as a function");
214
- })(this, w), this._events = {}, this.on = this.addEventListener, this.off = this.removeEventListener;
215
- }
216
- var A;
217
- return (A = [{ key: "emit", value: function(y, O) {
218
- if (Object.prototype.hasOwnProperty.call(this._events, y)) for (var E = this._events[y], j = { type: y, detail: O }, Z = E.length, u = 0; u < Z; u++) this.handle(E[u], j);
219
- } }, { key: "handle", value: function(y, O) {
220
- y(O);
221
- } }, { key: "addEventListener", value: function(y, O) {
222
- Object.prototype.hasOwnProperty.call(this._events, y) || (this._events[y] = []), this._events[y].indexOf(O) < 0 && this._events[y].push(O);
223
- } }, { key: "removeEventListener", value: function(y, O) {
224
- if (Object.prototype.hasOwnProperty.call(this._events, y)) {
225
- var E = this._events[y], j = E.indexOf(O);
226
- j >= 0 && E.splice(j, 1), E.length === 0 && delete this._events[y];
227
- }
228
- } }]) && function(y, O) {
229
- for (var E = 0; E < O.length; E++) {
230
- var j = O[E];
231
- j.enumerable = j.enumerable || !1, j.configurable = !0, "value" in j && (j.writable = !0), Object.defineProperty(y, j.key, j);
232
- }
233
- }(w.prototype, A), w;
234
- }();
235
- return S.default;
236
- })();
237
- } }, B = {};
238
- function x(m) {
239
- var g = B[m];
240
- if (g !== void 0) return g.exports;
241
- var S = B[m] = { exports: {} };
242
- return D[m].call(S.exports, S, S.exports, x), S.exports;
243
- }
244
- x.n = (m) => {
245
- var g = m && m.__esModule ? () => m.default : () => m;
246
- return x.d(g, { a: g }), g;
247
- }, x.d = (m, g) => {
248
- for (var S in g) x.o(g, S) && !x.o(m, S) && Object.defineProperty(m, S, { enumerable: !0, get: g[S] });
249
- }, x.o = (m, g) => Object.prototype.hasOwnProperty.call(m, g), x.r = (m) => {
250
- typeof Symbol < "u" && Symbol.toStringTag && Object.defineProperty(m, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(m, "__esModule", { value: !0 });
251
- };
252
- var q = {};
253
- return (() => {
254
- x.r(q), x.d(q, { GamepadHandler: () => i, GamepadListener: () => K });
255
- var m = x(162), g = x.n(m), S = x(944), I = x.n(S);
256
- function w(a) {
257
- return w = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
258
- return typeof e;
259
- } : function(e) {
260
- return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
261
- }, w(a);
262
- }
263
- function A(a, e) {
264
- if (!(a instanceof e)) throw new TypeError("Cannot call a class as a function");
265
- }
266
- function y(a, e) {
267
- for (var o = 0; o < e.length; o++) {
268
- var l = e[o];
269
- l.enumerable = l.enumerable || !1, l.configurable = !0, "value" in l && (l.writable = !0), Object.defineProperty(a, Z(l.key), l);
270
- }
271
- }
272
- function O(a, e) {
273
- return O = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(o, l) {
274
- return o.__proto__ = l, o;
275
- }, O(a, e);
276
- }
277
- function E(a, e) {
278
- if (e && (w(e) === "object" || typeof e == "function")) return e;
279
- if (e !== void 0) throw new TypeError("Derived constructors may only return object or undefined");
280
- return function(o) {
281
- if (o === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
282
- return o;
283
- }(a);
284
- }
285
- function j(a) {
286
- return j = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(e) {
287
- return e.__proto__ || Object.getPrototypeOf(e);
288
- }, j(a);
289
- }
290
- function Z(a) {
291
- var e = function(o, l) {
292
- if (w(o) !== "object" || o === null) return o;
293
- var k = o[Symbol.toPrimitive];
294
- if (k !== void 0) {
295
- var _ = k.call(o, "string");
296
- if (w(_) !== "object") return _;
297
- throw new TypeError("@@toPrimitive must return a primitive value.");
298
- }
299
- return String(o);
300
- }(a);
301
- return w(e) === "symbol" ? e : String(e);
302
- }
303
- var u, c, s, i = function(a) {
304
- (function(n, r) {
305
- if (typeof r != "function" && r !== null) throw new TypeError("Super expression must either be null or a function");
306
- n.prototype = Object.create(r && r.prototype, { constructor: { value: n, writable: !0, configurable: !0 } }), Object.defineProperty(n, "prototype", { writable: !1 }), r && O(n, r);
307
- })(t, a);
308
- var e, o, l, k, _, C = (k = t, _ = function() {
309
- if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham) return !1;
310
- if (typeof Proxy == "function") return !0;
311
- try {
312
- return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
313
- })), !0;
314
- } catch {
315
- return !1;
316
- }
317
- }(), function() {
318
- var n, r = j(k);
319
- if (_) {
320
- var b = j(this).constructor;
321
- n = Reflect.construct(r, arguments, b);
322
- } else n = r.apply(this, arguments);
323
- return E(this, n);
324
- });
325
- function t(n, r) {
326
- var b, M = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
327
- return A(this, t), (b = C.call(this)).index = n, b.gamepad = r, b.options = b.constructor.resolveOptions(M), b.axes = new Array(r.axes.length).fill(null), b.buttons = new Array(r.buttons.length).fill(null), b.initAxes(), b.initButtons(), b;
328
- }
329
- return e = t, l = [{ key: "resolveOptions", value: function(n) {
330
- var r, b, M, T, P = n.axis, N = n.button;
331
- return { axis: this.optionResolver.resolve((r = (b = P ?? N) !== null && b !== void 0 ? b : n) !== null && r !== void 0 ? r : {}), button: this.optionResolver.resolve((M = (T = N ?? P) !== null && T !== void 0 ? T : n) !== null && M !== void 0 ? M : {}) };
332
- } }], (o = [{ key: "initAxes", value: function() {
333
- for (var n = this.axes.length, r = 0; r < n; r++) this.axes[r] = this.resolveAxisValue(r);
334
- } }, { key: "initButtons", value: function() {
335
- for (var n = this.buttons.length, r = 0; r < n; r++) this.buttons[r] = this.resolveButtonValue(r);
336
- } }, { key: "update", value: function(n) {
337
- this.gamepad = n, this.updateAxis(), this.updateButtons();
338
- } }, { key: "updateAxis", value: function() {
339
- for (var n = this.axes.length, r = 0; r < n; r++) this.setAxisValue(r, this.resolveAxisValue(r));
340
- } }, { key: "updateButtons", value: function() {
341
- for (var n = this.buttons.length, r = 0; r < n; r++) this.setButtonValue(r, this.resolveButtonValue(r));
342
- } }, { key: "setAxisValue", value: function(n, r) {
343
- this.axes[n] !== r && (this.axes[n] = r, this.emit("axis", { gamepad: this.gamepad, index: this.index, axis: n, value: r }));
344
- } }, { key: "setButtonValue", value: function(n, r) {
345
- this.buttons[n] !== r && (this.buttons[n] = r, this.emit("button", { gamepad: this.gamepad, index: this.index, button: n, pressed: this.gamepad.buttons[n].pressed, value: r }));
346
- } }, { key: "resolveAxisValue", value: function(n) {
347
- var r = this.options.axis, b = r.deadZone, M = r.analog, T = r.precision, P = this.gamepad.axes[n];
348
- return b && P < b && P > -b ? 0 : M ? T ? Math.round(P * T) / T : P : P > 0 ? 1 : P < 0 ? -1 : 0;
349
- } }, { key: "resolveButtonValue", value: function(n) {
350
- var r = this.options.button, b = r.deadZone, M = r.analog, T = r.precision, P = this.gamepad.buttons[n].value;
351
- return b > 0 && P < b && P > -b ? 0 : M ? T ? Math.round(P * T) / T : P : P === 0 ? 0 : 1;
352
- } }]) && y(e.prototype, o), l && y(e, l), Object.defineProperty(e, "prototype", { writable: !1 }), t;
353
- }(g());
354
- function f(a) {
355
- return f = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
356
- return typeof e;
357
- } : function(e) {
358
- return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
359
- }, f(a);
360
- }
361
- function d(a, e) {
362
- for (var o = 0; o < e.length; o++) {
363
- var l = e[o];
364
- l.enumerable = l.enumerable || !1, l.configurable = !0, "value" in l && (l.writable = !0), Object.defineProperty(a, v(l.key), l);
365
- }
366
- }
367
- function v(a) {
368
- var e = function(o, l) {
369
- if (f(o) !== "object" || o === null) return o;
370
- var k = o[Symbol.toPrimitive];
371
- if (k !== void 0) {
372
- var _ = k.call(o, "string");
373
- if (f(_) !== "object") return _;
374
- throw new TypeError("@@toPrimitive must return a primitive value.");
375
- }
376
- return String(o);
377
- }(a);
378
- return f(e) === "symbol" ? e : String(e);
379
- }
380
- u = i, c = "optionResolver", s = new (I())().setDefaults({ analog: !0, deadZone: 0, precision: 0 }).setTypes({ analog: "boolean", deadZone: "number", precision: "number" }).setValidators({ deadZone: function(a) {
381
- return Math.max(Math.min(a, 1), 0);
382
- }, precision: function(a) {
383
- return a > 0 ? Math.pow(10, a) : 0;
384
- } }), (c = Z(c)) in u ? Object.defineProperty(u, c, { value: s, enumerable: !0, configurable: !0, writable: !0 }) : u[c] = s;
385
- var h = function() {
386
- function a(l) {
387
- (function(k, _) {
388
- if (!(k instanceof _)) throw new TypeError("Cannot call a class as a function");
389
- })(this, a), this.callback = l, this.frame = null, this.update = this.update.bind(this);
390
- }
391
- var e, o;
392
- return e = a, (o = [{ key: "setCallback", value: function(l) {
393
- this.callback = l;
394
- } }, { key: "start", value: function() {
395
- this.frame || (this.frame = window.requestAnimationFrame(this.update));
396
- } }, { key: "stop", value: function() {
397
- this.frame && (window.cancelAnimationFrame(this.frame), this.frame = null);
398
- } }, { key: "update", value: function() {
399
- this.frame = window.requestAnimationFrame(this.update), this.callback();
400
- } }]) && d(e.prototype, o), Object.defineProperty(e, "prototype", { writable: !1 }), a;
401
- }();
402
- function p(a) {
403
- return p = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
404
- return typeof e;
405
- } : function(e) {
406
- return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
407
- }, p(a);
408
- }
409
- function R(a, e) {
410
- if (!(a instanceof e)) throw new TypeError("Cannot call a class as a function");
411
- }
412
- function V(a, e) {
413
- for (var o = 0; o < e.length; o++) {
414
- var l = e[o];
415
- l.enumerable = l.enumerable || !1, l.configurable = !0, "value" in l && (l.writable = !0), Object.defineProperty(a, L(l.key), l);
416
- }
417
- }
418
- function L(a) {
419
- var e = function(o, l) {
420
- if (p(o) !== "object" || o === null) return o;
421
- var k = o[Symbol.toPrimitive];
422
- if (k !== void 0) {
423
- var _ = k.call(o, "string");
424
- if (p(_) !== "object") return _;
425
- throw new TypeError("@@toPrimitive must return a primitive value.");
426
- }
427
- return String(o);
428
- }(a);
429
- return p(e) === "symbol" ? e : String(e);
430
- }
431
- function H(a, e) {
432
- return H = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(o, l) {
433
- return o.__proto__ = l, o;
434
- }, H(a, e);
435
- }
436
- function J(a, e) {
437
- if (e && (p(e) === "object" || typeof e == "function")) return e;
438
- if (e !== void 0) throw new TypeError("Derived constructors may only return object or undefined");
439
- return G(a);
440
- }
441
- function G(a) {
442
- if (a === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
443
- return a;
444
- }
445
- function $(a) {
446
- return $ = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(e) {
447
- return e.__proto__ || Object.getPrototypeOf(e);
448
- }, $(a);
449
- }
450
- var K = function(a) {
451
- (function(t, n) {
452
- if (typeof n != "function" && n !== null) throw new TypeError("Super expression must either be null or a function");
453
- t.prototype = Object.create(n && n.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), n && H(t, n);
454
- })(C, a);
455
- var e, o, l, k, _ = (l = C, k = function() {
456
- if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham) return !1;
457
- if (typeof Proxy == "function") return !0;
458
- try {
459
- return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
460
- })), !0;
461
- } catch {
462
- return !1;
463
- }
464
- }(), function() {
465
- var t, n = $(l);
466
- if (k) {
467
- var r = $(this).constructor;
468
- t = Reflect.construct(n, arguments, r);
469
- } else t = n.apply(this, arguments);
470
- return J(this, t);
471
- });
472
- function C() {
473
- var t, n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
474
- if (R(this, C), t = _.call(this), typeof navigator.getGamepads != "function") throw new Error("This browser does not support gamepad API.");
475
- return t.options = n, t.onAxis = t.onAxis.bind(G(t)), t.update = t.update.bind(G(t)), t.start = t.start.bind(G(t)), t.stop = t.stop.bind(G(t)), t.discover = t.discover.bind(G(t)), t.onButton = t.onButton.bind(G(t)), t.handlers = new Array(4).fill(null), t.loop = new h(t.update), window.addEventListener("error", t.stop), t;
476
- }
477
- return e = C, (o = [{ key: "start", value: function() {
478
- this.loop.start();
479
- } }, { key: "stop", value: function() {
480
- this.loop.stop();
481
- } }, { key: "update", value: function() {
482
- var t = navigator.getGamepads();
483
- this.discover(t[0], 0), this.discover(t[1], 1), this.discover(t[2], 2), this.discover(t[3], 3);
484
- } }, { key: "discover", value: function(t, n) {
485
- t ? (this.handlers[n] === null && this.registerHandler(n, t), this.handlers[n].update(t)) : this.handlers[n] && this.removeGamepad(n);
486
- } }, { key: "registerHandler", value: function(t, n) {
487
- var r = new i(t, n, this.options);
488
- this.handlers[t] = r, r.addEventListener("axis", this.onAxis), r.addEventListener("button", this.onButton), this.emit("gamepad:connected", { index: t, gamepad: n }), this.emit("gamepad:".concat(t, ":connected"), { index: t, gamepad: n });
489
- } }, { key: "removeGamepad", value: function(t) {
490
- var n = this.handlers[t];
491
- n.removeEventListener("axis", this.onAxis), n.removeEventListener("button", this.onButton), this.handlers[t] = null, this.emit("gamepad:disconnected", { index: t }), this.emit("gamepad:".concat(t, ":disconnected"), { index: t });
492
- } }, { key: "onAxis", value: function(t) {
493
- var n = t.detail.index;
494
- this.emit("gamepad:axis", t.detail), this.emit("gamepad:".concat(n, ":axis"), t.detail), this.emit("gamepad:".concat(n, ":axis:").concat(t.detail.axis), t.detail);
495
- } }, { key: "onButton", value: function(t) {
496
- var n = t.detail.index;
497
- this.emit("gamepad:button", t.detail), this.emit("gamepad:".concat(n, ":button"), t.detail), this.emit("gamepad:".concat(n, ":button:").concat(t.detail.button), t.detail);
498
- } }]) && V(e.prototype, o), Object.defineProperty(e, "prototype", { writable: !1 }), C;
499
- }(g());
500
- })(), q;
501
- })());
502
- }(U)), U.exports;
503
- }
504
- var ee = Y();
505
- const te = /* @__PURE__ */ Q({
506
- __proto__: null
507
- }, [ee]);
508
- export {
509
- te as g
510
- };
511
- //# sourceMappingURL=gamepad.js.map
1
+ import { t as __commonJSMin } from "./chunk.js";
2
+ var require_gamepad = /* @__PURE__ */ __commonJSMin(((e, t) => {
3
+ (function(n, r) {
4
+ typeof e == "object" && typeof t == "object" ? t.exports = r() : typeof define == "function" && define.amd ? define([], r) : typeof e == "object" ? e.gamepad = r() : n.gamepad = r();
5
+ })(e, (() => (() => {
6
+ var e = {
7
+ 944: function(e) {
8
+ e.exports = (() => (() => {
9
+ var e = {
10
+ d: (t, n) => {
11
+ for (var r in n) e.o(n, r) && !e.o(t, r) && Object.defineProperty(t, r, {
12
+ enumerable: !0,
13
+ get: n[r]
14
+ });
15
+ },
16
+ o: (e, t) => Object.prototype.hasOwnProperty.call(e, t)
17
+ }, t = {};
18
+ function n(e) {
19
+ return n = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
20
+ return typeof e;
21
+ } : function(e) {
22
+ return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
23
+ }, n(e);
24
+ }
25
+ function r(e, t) {
26
+ var n = typeof Symbol < "u" && e[Symbol.iterator] || e["@@iterator"];
27
+ if (!n) {
28
+ if (Array.isArray(e) || (n = a(e)) || t && e && typeof e.length == "number") {
29
+ n && (e = n);
30
+ var r = 0, i = function() {};
31
+ return {
32
+ s: i,
33
+ n: function() {
34
+ return r >= e.length ? { done: !0 } : {
35
+ done: !1,
36
+ value: e[r++]
37
+ };
38
+ },
39
+ e: function(e) {
40
+ throw e;
41
+ },
42
+ f: i
43
+ };
44
+ }
45
+ throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
46
+ }
47
+ var o, s = !0, c = !1;
48
+ return {
49
+ s: function() {
50
+ n = n.call(e);
51
+ },
52
+ n: function() {
53
+ var e = n.next();
54
+ return s = e.done, e;
55
+ },
56
+ e: function(e) {
57
+ c = !0, o = e;
58
+ },
59
+ f: function() {
60
+ try {
61
+ s || n.return == null || n.return();
62
+ } finally {
63
+ if (c) throw o;
64
+ }
65
+ }
66
+ };
67
+ }
68
+ function i(e, t) {
69
+ return function(e) {
70
+ if (Array.isArray(e)) return e;
71
+ }(e) || function(e, t) {
72
+ var n = e == null ? null : typeof Symbol < "u" && e[Symbol.iterator] || e["@@iterator"];
73
+ if (n != null) {
74
+ var r, i, a, o, s = [], c = !0, l = !1;
75
+ try {
76
+ if (a = (n = n.call(e)).next, t === 0) {
77
+ if (Object(n) !== n) return;
78
+ c = !1;
79
+ } else for (; !(c = (r = a.call(n)).done) && (s.push(r.value), s.length !== t); c = !0);
80
+ } catch (e) {
81
+ l = !0, i = e;
82
+ } finally {
83
+ try {
84
+ if (!c && n.return != null && (o = n.return(), Object(o) !== o)) return;
85
+ } finally {
86
+ if (l) throw i;
87
+ }
88
+ }
89
+ return s;
90
+ }
91
+ }(e, t) || a(e, t) || function() {
92
+ throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
93
+ }();
94
+ }
95
+ function a(e, t) {
96
+ if (e) {
97
+ if (typeof e == "string") return o(e, t);
98
+ var n = Object.prototype.toString.call(e).slice(8, -1);
99
+ return n === "Object" && e.constructor && (n = e.constructor.name), n === "Map" || n === "Set" ? Array.from(e) : n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? o(e, t) : void 0;
100
+ }
101
+ }
102
+ function o(e, t) {
103
+ (t == null || t > e.length) && (t = e.length);
104
+ for (var n = 0, r = Array(t); n < t; n++) r[n] = e[n];
105
+ return r;
106
+ }
107
+ function s(e, t) {
108
+ if (!(e instanceof t)) throw TypeError("Cannot call a class as a function");
109
+ }
110
+ e.d(t, { default: () => c });
111
+ var c = function() {
112
+ function e() {
113
+ var t = !(arguments.length > 0 && arguments[0] !== void 0) || arguments[0];
114
+ s(this, e), this.strict = t, this.defaults = /* @__PURE__ */ new Map(), this.validators = /* @__PURE__ */ new Map(), this.types = /* @__PURE__ */ new Map(), this.optional = /* @__PURE__ */ new Set(), this.required = /* @__PURE__ */ new Set();
115
+ }
116
+ var t, a;
117
+ return t = e, (a = [
118
+ {
119
+ key: "allowExtra",
120
+ value: function() {
121
+ return this.strict = !1, this;
122
+ }
123
+ },
124
+ {
125
+ key: "setDefaults",
126
+ value: function(e) {
127
+ var t = this;
128
+ return Object.entries(e).forEach((function(e) {
129
+ var n = i(e, 2), r = n[0], a = n[1];
130
+ return t.defaults.set(r, a);
131
+ })), this;
132
+ }
133
+ },
134
+ {
135
+ key: "setValidators",
136
+ value: function(e) {
137
+ var t = this;
138
+ return Object.entries(e).forEach((function(e) {
139
+ var n = i(e, 2), r = n[0], a = n[1];
140
+ return t.validators.set(r, a);
141
+ })), this;
142
+ }
143
+ },
144
+ {
145
+ key: "setTypes",
146
+ value: function(e) {
147
+ var t = this;
148
+ return Object.entries(e).forEach((function(e) {
149
+ var n = i(e, 2), r = n[0], a = n[1];
150
+ return t.types.set(r, a);
151
+ })), this;
152
+ }
153
+ },
154
+ {
155
+ key: "setOptional",
156
+ value: function(e) {
157
+ var t = this;
158
+ return e.forEach((function(e) {
159
+ return t.optional.add(e);
160
+ })), this;
161
+ }
162
+ },
163
+ {
164
+ key: "setRequired",
165
+ value: function(e) {
166
+ var t = this;
167
+ return e.forEach((function(e) {
168
+ return t.required.add(e);
169
+ })), this;
170
+ }
171
+ },
172
+ {
173
+ key: "resolve",
174
+ value: function(e) {
175
+ return this.validate(Object.assign(this.getDefaults(), e));
176
+ }
177
+ },
178
+ {
179
+ key: "getDefaults",
180
+ value: function() {
181
+ var e, t = {}, n = r(this.defaults);
182
+ try {
183
+ for (n.s(); !(e = n.n()).done;) {
184
+ var a = i(e.value, 2), o = a[0];
185
+ t[o] = a[1];
186
+ }
187
+ } catch (e) {
188
+ n.e(e);
189
+ } finally {
190
+ n.f();
191
+ }
192
+ return t;
193
+ }
194
+ },
195
+ {
196
+ key: "validate",
197
+ value: function(e) {
198
+ for (var t in e) this.validators.has(t) && (e[t] = this.validators.get(t)(e[t]));
199
+ for (var n in e) {
200
+ if (!this.optionExists(n)) throw Error(`Unkown option "${n}".`);
201
+ this.checkType(n, e[n]);
202
+ }
203
+ var i, a = r(this.required.values());
204
+ try {
205
+ for (a.s(); !(i = a.n()).done;) {
206
+ var o = i.value;
207
+ if (e[o] === void 0) throw Error(`Option "${o}" is required.`);
208
+ }
209
+ } catch (e) {
210
+ a.e(e);
211
+ } finally {
212
+ a.f();
213
+ }
214
+ return e;
215
+ }
216
+ },
217
+ {
218
+ key: "checkType",
219
+ value: function(e, t) {
220
+ if (this.types.has(e)) {
221
+ var r = this.types.get(e), i = n(t);
222
+ if (i !== r) throw Error(`Wrong value for option "${e}": expected type "${r}", got "${i}".`);
223
+ }
224
+ }
225
+ },
226
+ {
227
+ key: "optionExists",
228
+ value: function(e) {
229
+ return !this.strict || this.defaults.has(e) || this.validators.has(e) || this.optional.has(e) || this.required.has(e) || this.types.has(e);
230
+ }
231
+ }
232
+ ]) && function(e, t) {
233
+ for (var r = 0; r < t.length; r++) {
234
+ var i = t[r];
235
+ i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, (a = function(e, t) {
236
+ if (n(e) !== "object" || e === null) return e;
237
+ var r = e[Symbol.toPrimitive];
238
+ if (r !== void 0) {
239
+ var i = r.call(e, "string");
240
+ if (n(i) !== "object") return i;
241
+ throw TypeError("@@toPrimitive must return a primitive value.");
242
+ }
243
+ return String(e);
244
+ }(i.key), n(a) === "symbol" ? a : String(a)), i);
245
+ }
246
+ var a;
247
+ }(t.prototype, a), Object.defineProperty(t, "prototype", { writable: !1 }), e;
248
+ }();
249
+ return t.default;
250
+ })())();
251
+ },
252
+ 162: function(e) {
253
+ e.exports = (() => {
254
+ var e = {
255
+ d: (t, n) => {
256
+ for (var r in n) e.o(n, r) && !e.o(t, r) && Object.defineProperty(t, r, {
257
+ enumerable: !0,
258
+ get: n[r]
259
+ });
260
+ },
261
+ o: (e, t) => Object.prototype.hasOwnProperty.call(e, t)
262
+ }, t = {};
263
+ e.d(t, { default: () => n });
264
+ var n = function() {
265
+ function e() {
266
+ (function(e, t) {
267
+ if (!(e instanceof t)) throw TypeError("Cannot call a class as a function");
268
+ })(this, e), this._events = {}, this.on = this.addEventListener, this.off = this.removeEventListener;
269
+ }
270
+ var t;
271
+ return (t = [
272
+ {
273
+ key: "emit",
274
+ value: function(e, t) {
275
+ if (Object.prototype.hasOwnProperty.call(this._events, e)) for (var n = this._events[e], r = {
276
+ type: e,
277
+ detail: t
278
+ }, i = n.length, a = 0; a < i; a++) this.handle(n[a], r);
279
+ }
280
+ },
281
+ {
282
+ key: "handle",
283
+ value: function(e, t) {
284
+ e(t);
285
+ }
286
+ },
287
+ {
288
+ key: "addEventListener",
289
+ value: function(e, t) {
290
+ Object.prototype.hasOwnProperty.call(this._events, e) || (this._events[e] = []), this._events[e].indexOf(t) < 0 && this._events[e].push(t);
291
+ }
292
+ },
293
+ {
294
+ key: "removeEventListener",
295
+ value: function(e, t) {
296
+ if (Object.prototype.hasOwnProperty.call(this._events, e)) {
297
+ var n = this._events[e], r = n.indexOf(t);
298
+ r >= 0 && n.splice(r, 1), n.length === 0 && delete this._events[e];
299
+ }
300
+ }
301
+ }
302
+ ]) && function(e, t) {
303
+ for (var n = 0; n < t.length; n++) {
304
+ var r = t[n];
305
+ r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(e, r.key, r);
306
+ }
307
+ }(e.prototype, t), e;
308
+ }();
309
+ return t.default;
310
+ })();
311
+ }
312
+ }, t = {};
313
+ function n(r) {
314
+ var i = t[r];
315
+ if (i !== void 0) return i.exports;
316
+ var a = t[r] = { exports: {} };
317
+ return e[r].call(a.exports, a, a.exports, n), a.exports;
318
+ }
319
+ n.n = (e) => {
320
+ var t = e && e.__esModule ? () => e.default : () => e;
321
+ return n.d(t, { a: t }), t;
322
+ }, n.d = (e, t) => {
323
+ for (var r in t) n.o(t, r) && !n.o(e, r) && Object.defineProperty(e, r, {
324
+ enumerable: !0,
325
+ get: t[r]
326
+ });
327
+ }, n.o = (e, t) => Object.prototype.hasOwnProperty.call(e, t), n.r = (e) => {
328
+ typeof Symbol < "u" && Symbol.toStringTag && Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(e, "__esModule", { value: !0 });
329
+ };
330
+ var r = {};
331
+ return (() => {
332
+ n.r(r), n.d(r, {
333
+ GamepadHandler: () => g,
334
+ GamepadListener: () => k
335
+ });
336
+ var e = n(162), t = n.n(e), i = n(944), a = n.n(i);
337
+ function o(e) {
338
+ return o = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
339
+ return typeof e;
340
+ } : function(e) {
341
+ return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
342
+ }, o(e);
343
+ }
344
+ function s(e, t) {
345
+ if (!(e instanceof t)) throw TypeError("Cannot call a class as a function");
346
+ }
347
+ function c(e, t) {
348
+ for (var n = 0; n < t.length; n++) {
349
+ var r = t[n];
350
+ r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(e, f(r.key), r);
351
+ }
352
+ }
353
+ function l(e, t) {
354
+ return l = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(e, t) {
355
+ return e.__proto__ = t, e;
356
+ }, l(e, t);
357
+ }
358
+ function u(e, t) {
359
+ if (t && (o(t) === "object" || typeof t == "function")) return t;
360
+ if (t !== void 0) throw TypeError("Derived constructors may only return object or undefined");
361
+ return function(e) {
362
+ if (e === void 0) throw ReferenceError("this hasn't been initialised - super() hasn't been called");
363
+ return e;
364
+ }(e);
365
+ }
366
+ function d(e) {
367
+ return d = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(e) {
368
+ return e.__proto__ || Object.getPrototypeOf(e);
369
+ }, d(e);
370
+ }
371
+ function f(e) {
372
+ var t = function(e, t) {
373
+ if (o(e) !== "object" || e === null) return e;
374
+ var n = e[Symbol.toPrimitive];
375
+ if (n !== void 0) {
376
+ var r = n.call(e, "string");
377
+ if (o(r) !== "object") return r;
378
+ throw TypeError("@@toPrimitive must return a primitive value.");
379
+ }
380
+ return String(e);
381
+ }(e);
382
+ return o(t) === "symbol" ? t : String(t);
383
+ }
384
+ var p, m, h, g = function(e) {
385
+ (function(e, t) {
386
+ if (typeof t != "function" && t !== null) throw TypeError("Super expression must either be null or a function");
387
+ e.prototype = Object.create(t && t.prototype, { constructor: {
388
+ value: e,
389
+ writable: !0,
390
+ configurable: !0
391
+ } }), Object.defineProperty(e, "prototype", { writable: !1 }), t && l(e, t);
392
+ })(f, e);
393
+ var t, n, r, i, a, o = (i = f, a = function() {
394
+ if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham) return !1;
395
+ if (typeof Proxy == "function") return !0;
396
+ try {
397
+ return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], (function() {}))), !0;
398
+ } catch {
399
+ return !1;
400
+ }
401
+ }(), function() {
402
+ var e, t = d(i);
403
+ if (a) {
404
+ var n = d(this).constructor;
405
+ e = Reflect.construct(t, arguments, n);
406
+ } else e = t.apply(this, arguments);
407
+ return u(this, e);
408
+ });
409
+ function f(e, t) {
410
+ var n, r = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
411
+ return s(this, f), (n = o.call(this)).index = e, n.gamepad = t, n.options = n.constructor.resolveOptions(r), n.axes = Array(t.axes.length).fill(null), n.buttons = Array(t.buttons.length).fill(null), n.initAxes(), n.initButtons(), n;
412
+ }
413
+ return t = f, r = [{
414
+ key: "resolveOptions",
415
+ value: function(e) {
416
+ var t = e.axis, n = e.button;
417
+ return {
418
+ axis: this.optionResolver.resolve(t ?? n ?? e ?? {}),
419
+ button: this.optionResolver.resolve(n ?? t ?? e ?? {})
420
+ };
421
+ }
422
+ }], (n = [
423
+ {
424
+ key: "initAxes",
425
+ value: function() {
426
+ for (var e = this.axes.length, t = 0; t < e; t++) this.axes[t] = this.resolveAxisValue(t);
427
+ }
428
+ },
429
+ {
430
+ key: "initButtons",
431
+ value: function() {
432
+ for (var e = this.buttons.length, t = 0; t < e; t++) this.buttons[t] = this.resolveButtonValue(t);
433
+ }
434
+ },
435
+ {
436
+ key: "update",
437
+ value: function(e) {
438
+ this.gamepad = e, this.updateAxis(), this.updateButtons();
439
+ }
440
+ },
441
+ {
442
+ key: "updateAxis",
443
+ value: function() {
444
+ for (var e = this.axes.length, t = 0; t < e; t++) this.setAxisValue(t, this.resolveAxisValue(t));
445
+ }
446
+ },
447
+ {
448
+ key: "updateButtons",
449
+ value: function() {
450
+ for (var e = this.buttons.length, t = 0; t < e; t++) this.setButtonValue(t, this.resolveButtonValue(t));
451
+ }
452
+ },
453
+ {
454
+ key: "setAxisValue",
455
+ value: function(e, t) {
456
+ this.axes[e] !== t && (this.axes[e] = t, this.emit("axis", {
457
+ gamepad: this.gamepad,
458
+ index: this.index,
459
+ axis: e,
460
+ value: t
461
+ }));
462
+ }
463
+ },
464
+ {
465
+ key: "setButtonValue",
466
+ value: function(e, t) {
467
+ this.buttons[e] !== t && (this.buttons[e] = t, this.emit("button", {
468
+ gamepad: this.gamepad,
469
+ index: this.index,
470
+ button: e,
471
+ pressed: this.gamepad.buttons[e].pressed,
472
+ value: t
473
+ }));
474
+ }
475
+ },
476
+ {
477
+ key: "resolveAxisValue",
478
+ value: function(e) {
479
+ var t = this.options.axis, n = t.deadZone, r = t.analog, i = t.precision, a = this.gamepad.axes[e];
480
+ return n && a < n && a > -n ? 0 : r ? i ? Math.round(a * i) / i : a : a > 0 ? 1 : a < 0 ? -1 : 0;
481
+ }
482
+ },
483
+ {
484
+ key: "resolveButtonValue",
485
+ value: function(e) {
486
+ var t = this.options.button, n = t.deadZone, r = t.analog, i = t.precision, a = this.gamepad.buttons[e].value;
487
+ return n > 0 && a < n && a > -n ? 0 : r ? i ? Math.round(a * i) / i : a : a === 0 ? 0 : 1;
488
+ }
489
+ }
490
+ ]) && c(t.prototype, n), r && c(t, r), Object.defineProperty(t, "prototype", { writable: !1 }), f;
491
+ }(t());
492
+ function _(e) {
493
+ return _ = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
494
+ return typeof e;
495
+ } : function(e) {
496
+ return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
497
+ }, _(e);
498
+ }
499
+ function v(e, t) {
500
+ for (var n = 0; n < t.length; n++) {
501
+ var r = t[n];
502
+ r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(e, y(r.key), r);
503
+ }
504
+ }
505
+ function y(e) {
506
+ var t = function(e, t) {
507
+ if (_(e) !== "object" || e === null) return e;
508
+ var n = e[Symbol.toPrimitive];
509
+ if (n !== void 0) {
510
+ var r = n.call(e, "string");
511
+ if (_(r) !== "object") return r;
512
+ throw TypeError("@@toPrimitive must return a primitive value.");
513
+ }
514
+ return String(e);
515
+ }(e);
516
+ return _(t) === "symbol" ? t : String(t);
517
+ }
518
+ p = g, m = "optionResolver", h = new (a())().setDefaults({
519
+ analog: !0,
520
+ deadZone: 0,
521
+ precision: 0
522
+ }).setTypes({
523
+ analog: "boolean",
524
+ deadZone: "number",
525
+ precision: "number"
526
+ }).setValidators({
527
+ deadZone: function(e) {
528
+ return Math.max(Math.min(e, 1), 0);
529
+ },
530
+ precision: function(e) {
531
+ return e > 0 ? 10 ** e : 0;
532
+ }
533
+ }), (m = f(m)) in p ? Object.defineProperty(p, m, {
534
+ value: h,
535
+ enumerable: !0,
536
+ configurable: !0,
537
+ writable: !0
538
+ }) : p[m] = h;
539
+ var b = function() {
540
+ function e(t) {
541
+ (function(e, t) {
542
+ if (!(e instanceof t)) throw TypeError("Cannot call a class as a function");
543
+ })(this, e), this.callback = t, this.frame = null, this.update = this.update.bind(this);
544
+ }
545
+ var t, n;
546
+ return t = e, (n = [
547
+ {
548
+ key: "setCallback",
549
+ value: function(e) {
550
+ this.callback = e;
551
+ }
552
+ },
553
+ {
554
+ key: "start",
555
+ value: function() {
556
+ this.frame ||= window.requestAnimationFrame(this.update);
557
+ }
558
+ },
559
+ {
560
+ key: "stop",
561
+ value: function() {
562
+ this.frame &&= (window.cancelAnimationFrame(this.frame), null);
563
+ }
564
+ },
565
+ {
566
+ key: "update",
567
+ value: function() {
568
+ this.frame = window.requestAnimationFrame(this.update), this.callback();
569
+ }
570
+ }
571
+ ]) && v(t.prototype, n), Object.defineProperty(t, "prototype", { writable: !1 }), e;
572
+ }();
573
+ function x(e) {
574
+ return x = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
575
+ return typeof e;
576
+ } : function(e) {
577
+ return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
578
+ }, x(e);
579
+ }
580
+ function S(e, t) {
581
+ if (!(e instanceof t)) throw TypeError("Cannot call a class as a function");
582
+ }
583
+ function C(e, t) {
584
+ for (var n = 0; n < t.length; n++) {
585
+ var r = t[n];
586
+ r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(e, w(r.key), r);
587
+ }
588
+ }
589
+ function w(e) {
590
+ var t = function(e, t) {
591
+ if (x(e) !== "object" || e === null) return e;
592
+ var n = e[Symbol.toPrimitive];
593
+ if (n !== void 0) {
594
+ var r = n.call(e, "string");
595
+ if (x(r) !== "object") return r;
596
+ throw TypeError("@@toPrimitive must return a primitive value.");
597
+ }
598
+ return String(e);
599
+ }(e);
600
+ return x(t) === "symbol" ? t : String(t);
601
+ }
602
+ function T(e, t) {
603
+ return T = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(e, t) {
604
+ return e.__proto__ = t, e;
605
+ }, T(e, t);
606
+ }
607
+ function E(e, t) {
608
+ if (t && (x(t) === "object" || typeof t == "function")) return t;
609
+ if (t !== void 0) throw TypeError("Derived constructors may only return object or undefined");
610
+ return D(e);
611
+ }
612
+ function D(e) {
613
+ if (e === void 0) throw ReferenceError("this hasn't been initialised - super() hasn't been called");
614
+ return e;
615
+ }
616
+ function O(e) {
617
+ return O = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(e) {
618
+ return e.__proto__ || Object.getPrototypeOf(e);
619
+ }, O(e);
620
+ }
621
+ var k = function(e) {
622
+ (function(e, t) {
623
+ if (typeof t != "function" && t !== null) throw TypeError("Super expression must either be null or a function");
624
+ e.prototype = Object.create(t && t.prototype, { constructor: {
625
+ value: e,
626
+ writable: !0,
627
+ configurable: !0
628
+ } }), Object.defineProperty(e, "prototype", { writable: !1 }), t && T(e, t);
629
+ })(o, e);
630
+ var t, n, r, i, a = (r = o, i = function() {
631
+ if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham) return !1;
632
+ if (typeof Proxy == "function") return !0;
633
+ try {
634
+ return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], (function() {}))), !0;
635
+ } catch {
636
+ return !1;
637
+ }
638
+ }(), function() {
639
+ var e, t = O(r);
640
+ if (i) {
641
+ var n = O(this).constructor;
642
+ e = Reflect.construct(t, arguments, n);
643
+ } else e = t.apply(this, arguments);
644
+ return E(this, e);
645
+ });
646
+ function o() {
647
+ var e, t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
648
+ if (S(this, o), e = a.call(this), typeof navigator.getGamepads != "function") throw Error("This browser does not support gamepad API.");
649
+ return e.options = t, e.onAxis = e.onAxis.bind(D(e)), e.update = e.update.bind(D(e)), e.start = e.start.bind(D(e)), e.stop = e.stop.bind(D(e)), e.discover = e.discover.bind(D(e)), e.onButton = e.onButton.bind(D(e)), e.handlers = [
650
+ ,
651
+ ,
652
+ ,
653
+ ,
654
+ ].fill(null), e.loop = new b(e.update), window.addEventListener("error", e.stop), e;
655
+ }
656
+ return t = o, (n = [
657
+ {
658
+ key: "start",
659
+ value: function() {
660
+ this.loop.start();
661
+ }
662
+ },
663
+ {
664
+ key: "stop",
665
+ value: function() {
666
+ this.loop.stop();
667
+ }
668
+ },
669
+ {
670
+ key: "update",
671
+ value: function() {
672
+ var e = navigator.getGamepads();
673
+ this.discover(e[0], 0), this.discover(e[1], 1), this.discover(e[2], 2), this.discover(e[3], 3);
674
+ }
675
+ },
676
+ {
677
+ key: "discover",
678
+ value: function(e, t) {
679
+ e ? (this.handlers[t] === null && this.registerHandler(t, e), this.handlers[t].update(e)) : this.handlers[t] && this.removeGamepad(t);
680
+ }
681
+ },
682
+ {
683
+ key: "registerHandler",
684
+ value: function(e, t) {
685
+ var n = new g(e, t, this.options);
686
+ this.handlers[e] = n, n.addEventListener("axis", this.onAxis), n.addEventListener("button", this.onButton), this.emit("gamepad:connected", {
687
+ index: e,
688
+ gamepad: t
689
+ }), this.emit(`gamepad:${e}:connected`, {
690
+ index: e,
691
+ gamepad: t
692
+ });
693
+ }
694
+ },
695
+ {
696
+ key: "removeGamepad",
697
+ value: function(e) {
698
+ var t = this.handlers[e];
699
+ t.removeEventListener("axis", this.onAxis), t.removeEventListener("button", this.onButton), this.handlers[e] = null, this.emit("gamepad:disconnected", { index: e }), this.emit(`gamepad:${e}:disconnected`, { index: e });
700
+ }
701
+ },
702
+ {
703
+ key: "onAxis",
704
+ value: function(e) {
705
+ var t = e.detail.index;
706
+ this.emit("gamepad:axis", e.detail), this.emit(`gamepad:${t}:axis`, e.detail), this.emit(`gamepad:${t}:axis:${e.detail.axis}`, e.detail);
707
+ }
708
+ },
709
+ {
710
+ key: "onButton",
711
+ value: function(e) {
712
+ var t = e.detail.index;
713
+ this.emit("gamepad:button", e.detail), this.emit(`gamepad:${t}:button`, e.detail), this.emit(`gamepad:${t}:button:${e.detail.button}`, e.detail);
714
+ }
715
+ }
716
+ ]) && C(t.prototype, n), Object.defineProperty(t, "prototype", { writable: !1 }), o;
717
+ }(t());
718
+ })(), r;
719
+ })()));
720
+ }));
721
+ export default require_gamepad();
722
+
723
+ //# sourceMappingURL=gamepad.js.map