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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/******/ (() => { // webpackBootstrap
|
2 |
+
/******/ "use strict";
|
3 |
+
/******/ var __webpack_modules__ = ({
|
4 |
+
|
5 |
+
/***/ 7:
|
6 |
+
/***/ ((module) => {
|
7 |
+
|
8 |
+
|
9 |
+
var R = typeof Reflect === 'object' ? Reflect : null
|
10 |
+
var ReflectApply = R && typeof R.apply === 'function'
|
11 |
+
? R.apply
|
12 |
+
: function ReflectApply(target, receiver, args) {
|
13 |
+
return Function.prototype.apply.call(target, receiver, args);
|
14 |
+
}
|
15 |
+
|
16 |
+
var ReflectOwnKeys
|
17 |
+
if (R && typeof R.ownKeys === 'function') {
|
18 |
+
ReflectOwnKeys = R.ownKeys
|
19 |
+
} else if (Object.getOwnPropertySymbols) {
|
20 |
+
ReflectOwnKeys = function ReflectOwnKeys(target) {
|
21 |
+
return Object.getOwnPropertyNames(target)
|
22 |
+
.concat(Object.getOwnPropertySymbols(target));
|
23 |
+
};
|
24 |
+
} else {
|
25 |
+
ReflectOwnKeys = function ReflectOwnKeys(target) {
|
26 |
+
return Object.getOwnPropertyNames(target);
|
27 |
+
};
|
28 |
+
}
|
29 |
+
|
30 |
+
function ProcessEmitWarning(warning) {
|
31 |
+
if (console && console.warn) console.warn(warning);
|
32 |
+
}
|
33 |
+
|
34 |
+
var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {
|
35 |
+
return value !== value;
|
36 |
+
}
|
37 |
+
|
38 |
+
function EventEmitter() {
|
39 |
+
EventEmitter.init.call(this);
|
40 |
+
}
|
41 |
+
module.exports = EventEmitter;
|
42 |
+
module.exports.once = once;
|
43 |
+
|
44 |
+
// Backwards-compat with node 0.10.x
|
45 |
+
EventEmitter.EventEmitter = EventEmitter;
|
46 |
+
|
47 |
+
EventEmitter.prototype._events = undefined;
|
48 |
+
EventEmitter.prototype._eventsCount = 0;
|
49 |
+
EventEmitter.prototype._maxListeners = undefined;
|
50 |
+
|
51 |
+
// By default EventEmitters will print a warning if more than 10 listeners are
|
52 |
+
// added to it. This is a useful default which helps finding memory leaks.
|
53 |
+
var defaultMaxListeners = 10;
|
54 |
+
|
55 |
+
function checkListener(listener) {
|
56 |
+
if (typeof listener !== 'function') {
|
57 |
+
throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
|
62 |
+
enumerable: true,
|
63 |
+
get: function() {
|
64 |
+
return defaultMaxListeners;
|
65 |
+
},
|
66 |
+
set: function(arg) {
|
67 |
+
if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {
|
68 |
+
throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.');
|
69 |
+
}
|
70 |
+
defaultMaxListeners = arg;
|
71 |
+
}
|
72 |
+
});
|
73 |
+
|
74 |
+
EventEmitter.init = function() {
|
75 |
+
|
76 |
+
if (this._events === undefined ||
|
77 |
+
this._events === Object.getPrototypeOf(this)._events) {
|
78 |
+
this._events = Object.create(null);
|
79 |
+
this._eventsCount = 0;
|
80 |
+
}
|
81 |
+
|
82 |
+
this._maxListeners = this._maxListeners || undefined;
|
83 |
+
};
|
84 |
+
|
85 |
+
// Obviously not all Emitters should be limited to 10. This function allows
|
86 |
+
// that to be increased. Set to zero for unlimited.
|
87 |
+
EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
|
88 |
+
if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {
|
89 |
+
throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.');
|
90 |
+
}
|
91 |
+
this._maxListeners = n;
|
92 |
+
return this;
|
93 |
+
};
|
94 |
+
|
95 |
+
function _getMaxListeners(that) {
|
96 |
+
if (that._maxListeners === undefined)
|
97 |
+
return EventEmitter.defaultMaxListeners;
|
98 |
+
return that._maxListeners;
|
99 |
+
}
|
100 |
+
|
101 |
+
EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
|
102 |
+
return _getMaxListeners(this);
|
103 |
+
};
|
104 |
+
|
105 |
+
EventEmitter.prototype.emit = function emit(type) {
|
106 |
+
var args = [];
|
107 |
+
for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);
|
108 |
+
var doError = (type === 'error');
|
109 |
+
|
110 |
+
var events = this._events;
|
111 |
+
if (events !== undefined)
|
112 |
+
doError = (doError && events.error === undefined);
|
113 |
+
else if (!doError)
|
114 |
+
return false;
|
115 |
+
|
116 |
+
// If there is no 'error' event listener then throw.
|
117 |
+
if (doError) {
|
118 |
+
var er;
|
119 |
+
if (args.length > 0)
|
120 |
+
er = args[0];
|
121 |
+
if (er instanceof Error) {
|
122 |
+
// Note: The comments on the `throw` lines are intentional, they show
|
123 |
+
// up in Node's output if this results in an unhandled exception.
|
124 |
+
throw er; // Unhandled 'error' event
|
125 |
+
}
|
126 |
+
// At least give some kind of context to the user
|
127 |
+
var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));
|
128 |
+
err.context = er;
|
129 |
+
throw err; // Unhandled 'error' event
|
130 |
+
}
|
131 |
+
|
132 |
+
var handler = events[type];
|
133 |
+
|
134 |
+
if (handler === undefined)
|
135 |
+
return false;
|
136 |
+
|
137 |
+
if (typeof handler === 'function') {
|
138 |
+
ReflectApply(handler, this, args);
|
139 |
+
} else {
|
140 |
+
var len = handler.length;
|
141 |
+
var listeners = arrayClone(handler, len);
|
142 |
+
for (var i = 0; i < len; ++i)
|
143 |
+
ReflectApply(listeners[i], this, args);
|
144 |
+
}
|
145 |
+
|
146 |
+
return true;
|
147 |
+
};
|
148 |
+
|
149 |
+
function _addListener(target, type, listener, prepend) {
|
150 |
+
var m;
|
151 |
+
var events;
|
152 |
+
var existing;
|
153 |
+
|
154 |
+
checkListener(listener);
|
155 |
+
|
156 |
+
events = target._events;
|
157 |
+
if (events === undefined) {
|
158 |
+
events = target._events = Object.create(null);
|
159 |
+
target._eventsCount = 0;
|
160 |
+
} else {
|
161 |
+
// To avoid recursion in the case that type === "newListener"! Before
|
162 |
+
// adding it to the listeners, first emit "newListener".
|
163 |
+
if (events.newListener !== undefined) {
|
164 |
+
target.emit('newListener', type,
|
165 |
+
listener.listener ? listener.listener : listener);
|
166 |
+
|
167 |
+
// Re-assign `events` because a newListener handler could have caused the
|
168 |
+
// this._events to be assigned to a new object
|
169 |
+
events = target._events;
|
170 |
+
}
|
171 |
+
existing = events[type];
|
172 |
+
}
|
173 |
+
|
174 |
+
if (existing === undefined) {
|
175 |
+
// Optimize the case of one listener. Don't need the extra array object.
|
176 |
+
existing = events[type] = listener;
|
177 |
+
++target._eventsCount;
|
178 |
+
} else {
|
179 |
+
if (typeof existing === 'function') {
|
180 |
+
// Adding the second element, need to change to array.
|
181 |
+
existing = events[type] =
|
182 |
+
prepend ? [listener, existing] : [existing, listener];
|
183 |
+
// If we've already got an array, just append.
|
184 |
+
} else if (prepend) {
|
185 |
+
existing.unshift(listener);
|
186 |
+
} else {
|
187 |
+
existing.push(listener);
|
188 |
+
}
|
189 |
+
|
190 |
+
// Check for listener leak
|
191 |
+
m = _getMaxListeners(target);
|
192 |
+
if (m > 0 && existing.length > m && !existing.warned) {
|
193 |
+
existing.warned = true;
|
194 |
+
// No error code for this since it is a Warning
|
195 |
+
// eslint-disable-next-line no-restricted-syntax
|
196 |
+
var w = new Error('Possible EventEmitter memory leak detected. ' +
|
197 |
+
existing.length + ' ' + String(type) + ' listeners ' +
|
198 |
+
'added. Use emitter.setMaxListeners() to ' +
|
199 |
+
'increase limit');
|
200 |
+
w.name = 'MaxListenersExceededWarning';
|
201 |
+
w.emitter = target;
|
202 |
+
w.type = type;
|
203 |
+
w.count = existing.length;
|
204 |
+
ProcessEmitWarning(w);
|
205 |
+
}
|
206 |
+
}
|
207 |
+
|
208 |
+
return target;
|
209 |
+
}
|
210 |
+
|
211 |
+
EventEmitter.prototype.addListener = function addListener(type, listener) {
|
212 |
+
return _addListener(this, type, listener, false);
|
213 |
+
};
|
214 |
+
|
215 |
+
EventEmitter.prototype.on = EventEmitter.prototype.addListener;
|
216 |
+
|
217 |
+
EventEmitter.prototype.prependListener =
|
218 |
+
function prependListener(type, listener) {
|
219 |
+
return _addListener(this, type, listener, true);
|
220 |
+
};
|
221 |
+
|
222 |
+
function onceWrapper() {
|
223 |
+
if (!this.fired) {
|
224 |
+
this.target.removeListener(this.type, this.wrapFn);
|
225 |
+
this.fired = true;
|
226 |
+
if (arguments.length === 0)
|
227 |
+
return this.listener.call(this.target);
|
228 |
+
return this.listener.apply(this.target, arguments);
|
229 |
+
}
|
230 |
+
}
|
231 |
+
|
232 |
+
function _onceWrap(target, type, listener) {
|
233 |
+
var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
|
234 |
+
var wrapped = onceWrapper.bind(state);
|
235 |
+
wrapped.listener = listener;
|
236 |
+
state.wrapFn = wrapped;
|
237 |
+
return wrapped;
|
238 |
+
}
|
239 |
+
|
240 |
+
EventEmitter.prototype.once = function once(type, listener) {
|
241 |
+
checkListener(listener);
|
242 |
+
this.on(type, _onceWrap(this, type, listener));
|
243 |
+
return this;
|
244 |
+
};
|
245 |
+
|
246 |
+
EventEmitter.prototype.prependOnceListener =
|
247 |
+
function prependOnceListener(type, listener) {
|
248 |
+
checkListener(listener);
|
249 |
+
this.prependListener(type, _onceWrap(this, type, listener));
|
250 |
+
return this;
|
251 |
+
};
|
252 |
+
|
253 |
+
// Emits a 'removeListener' event if and only if the listener was removed.
|
254 |
+
EventEmitter.prototype.removeListener =
|
255 |
+
function removeListener(type, listener) {
|
256 |
+
var list, events, position, i, originalListener;
|
257 |
+
|
258 |
+
checkListener(listener);
|
259 |
+
|
260 |
+
events = this._events;
|
261 |
+
if (events === undefined)
|
262 |
+
return this;
|
263 |
+
|
264 |
+
list = events[type];
|
265 |
+
if (list === undefined)
|
266 |
+
return this;
|
267 |
+
|
268 |
+
if (list === listener || list.listener === listener) {
|
269 |
+
if (--this._eventsCount === 0)
|
270 |
+
this._events = Object.create(null);
|
271 |
+
else {
|
272 |
+
delete events[type];
|
273 |
+
if (events.removeListener)
|
274 |
+
this.emit('removeListener', type, list.listener || listener);
|
275 |
+
}
|
276 |
+
} else if (typeof list !== 'function') {
|
277 |
+
position = -1;
|
278 |
+
|
279 |
+
for (i = list.length - 1; i >= 0; i--) {
|
280 |
+
if (list[i] === listener || list[i].listener === listener) {
|
281 |
+
originalListener = list[i].listener;
|
282 |
+
position = i;
|
283 |
+
break;
|
284 |
+
}
|
285 |
+
}
|
286 |
+
|
287 |
+
if (position < 0)
|
288 |
+
return this;
|
289 |
+
|
290 |
+
if (position === 0)
|
291 |
+
list.shift();
|
292 |
+
else {
|
293 |
+
spliceOne(list, position);
|
294 |
+
}
|
295 |
+
|
296 |
+
if (list.length === 1)
|
297 |
+
events[type] = list[0];
|
298 |
+
|
299 |
+
if (events.removeListener !== undefined)
|
300 |
+
this.emit('removeListener', type, originalListener || listener);
|
301 |
+
}
|
302 |
+
|
303 |
+
return this;
|
304 |
+
};
|
305 |
+
|
306 |
+
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
|
307 |
+
|
308 |
+
EventEmitter.prototype.removeAllListeners =
|
309 |
+
function removeAllListeners(type) {
|
310 |
+
var listeners, events, i;
|
311 |
+
|
312 |
+
events = this._events;
|
313 |
+
if (events === undefined)
|
314 |
+
return this;
|
315 |
+
|
316 |
+
// not listening for removeListener, no need to emit
|
317 |
+
if (events.removeListener === undefined) {
|
318 |
+
if (arguments.length === 0) {
|
319 |
+
this._events = Object.create(null);
|
320 |
+
this._eventsCount = 0;
|
321 |
+
} else if (events[type] !== undefined) {
|
322 |
+
if (--this._eventsCount === 0)
|
323 |
+
this._events = Object.create(null);
|
324 |
+
else
|
325 |
+
delete events[type];
|
326 |
+
}
|
327 |
+
return this;
|
328 |
+
}
|
329 |
+
|
330 |
+
// emit removeListener for all listeners on all events
|
331 |
+
if (arguments.length === 0) {
|
332 |
+
var keys = Object.keys(events);
|
333 |
+
var key;
|
334 |
+
for (i = 0; i < keys.length; ++i) {
|
335 |
+
key = keys[i];
|
336 |
+
if (key === 'removeListener') continue;
|
337 |
+
this.removeAllListeners(key);
|
338 |
+
}
|
339 |
+
this.removeAllListeners('removeListener');
|
340 |
+
this._events = Object.create(null);
|
341 |
+
this._eventsCount = 0;
|
342 |
+
return this;
|
343 |
+
}
|
344 |
+
|
345 |
+
listeners = events[type];
|
346 |
+
|
347 |
+
if (typeof listeners === 'function') {
|
348 |
+
this.removeListener(type, listeners);
|
349 |
+
} else if (listeners !== undefined) {
|
350 |
+
// LIFO order
|
351 |
+
for (i = listeners.length - 1; i >= 0; i--) {
|
352 |
+
this.removeListener(type, listeners[i]);
|
353 |
+
}
|
354 |
+
}
|
355 |
+
|
356 |
+
return this;
|
357 |
+
};
|
358 |
+
|
359 |
+
function _listeners(target, type, unwrap) {
|
360 |
+
var events = target._events;
|
361 |
+
|
362 |
+
if (events === undefined)
|
363 |
+
return [];
|
364 |
+
|
365 |
+
var evlistener = events[type];
|
366 |
+
if (evlistener === undefined)
|
367 |
+
return [];
|
368 |
+
|
369 |
+
if (typeof evlistener === 'function')
|
370 |
+
return unwrap ? [evlistener.listener || evlistener] : [evlistener];
|
371 |
+
|
372 |
+
return unwrap ?
|
373 |
+
unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
|
374 |
+
}
|
375 |
+
|
376 |
+
EventEmitter.prototype.listeners = function listeners(type) {
|
377 |
+
return _listeners(this, type, true);
|
378 |
+
};
|
379 |
+
|
380 |
+
EventEmitter.prototype.rawListeners = function rawListeners(type) {
|
381 |
+
return _listeners(this, type, false);
|
382 |
+
};
|
383 |
+
|
384 |
+
EventEmitter.listenerCount = function(emitter, type) {
|
385 |
+
if (typeof emitter.listenerCount === 'function') {
|
386 |
+
return emitter.listenerCount(type);
|
387 |
+
} else {
|
388 |
+
return listenerCount.call(emitter, type);
|
389 |
+
}
|
390 |
+
};
|
391 |
+
|
392 |
+
EventEmitter.prototype.listenerCount = listenerCount;
|
393 |
+
function listenerCount(type) {
|
394 |
+
var events = this._events;
|
395 |
+
|
396 |
+
if (events !== undefined) {
|
397 |
+
var evlistener = events[type];
|
398 |
+
|
399 |
+
if (typeof evlistener === 'function') {
|
400 |
+
return 1;
|
401 |
+
} else if (evlistener !== undefined) {
|
402 |
+
return evlistener.length;
|
403 |
+
}
|
404 |
+
}
|
405 |
+
|
406 |
+
return 0;
|
407 |
+
}
|
408 |
+
|
409 |
+
EventEmitter.prototype.eventNames = function eventNames() {
|
410 |
+
return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];
|
411 |
+
};
|
412 |
+
|
413 |
+
function arrayClone(arr, n) {
|
414 |
+
var copy = new Array(n);
|
415 |
+
for (var i = 0; i < n; ++i)
|
416 |
+
copy[i] = arr[i];
|
417 |
+
return copy;
|
418 |
+
}
|
419 |
+
|
420 |
+
function spliceOne(list, index) {
|
421 |
+
for (; index + 1 < list.length; index++)
|
422 |
+
list[index] = list[index + 1];
|
423 |
+
list.pop();
|
424 |
+
}
|
425 |
+
|
426 |
+
function unwrapListeners(arr) {
|
427 |
+
var ret = new Array(arr.length);
|
428 |
+
for (var i = 0; i < ret.length; ++i) {
|
429 |
+
ret[i] = arr[i].listener || arr[i];
|
430 |
+
}
|
431 |
+
return ret;
|
432 |
+
}
|
433 |
+
|
434 |
+
function once(emitter, name) {
|
435 |
+
return new Promise(function (resolve, reject) {
|
436 |
+
function errorListener(err) {
|
437 |
+
emitter.removeListener(name, resolver);
|
438 |
+
reject(err);
|
439 |
+
}
|
440 |
+
|
441 |
+
function resolver() {
|
442 |
+
if (typeof emitter.removeListener === 'function') {
|
443 |
+
emitter.removeListener('error', errorListener);
|
444 |
+
}
|
445 |
+
resolve([].slice.call(arguments));
|
446 |
+
};
|
447 |
+
|
448 |
+
eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });
|
449 |
+
if (name !== 'error') {
|
450 |
+
addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });
|
451 |
+
}
|
452 |
+
});
|
453 |
+
}
|
454 |
+
|
455 |
+
function addErrorHandlerIfEventEmitter(emitter, handler, flags) {
|
456 |
+
if (typeof emitter.on === 'function') {
|
457 |
+
eventTargetAgnosticAddListener(emitter, 'error', handler, flags);
|
458 |
+
}
|
459 |
+
}
|
460 |
+
|
461 |
+
function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
|
462 |
+
if (typeof emitter.on === 'function') {
|
463 |
+
if (flags.once) {
|
464 |
+
emitter.once(name, listener);
|
465 |
+
} else {
|
466 |
+
emitter.on(name, listener);
|
467 |
+
}
|
468 |
+
} else if (typeof emitter.addEventListener === 'function') {
|
469 |
+
// EventTarget does not have `error` event semantics like Node
|
470 |
+
// EventEmitters, we do not listen for `error` events here.
|
471 |
+
emitter.addEventListener(name, function wrapListener(arg) {
|
472 |
+
// IE does not have builtin `{ once: true }` support so we
|
473 |
+
// have to do it manually.
|
474 |
+
if (flags.once) {
|
475 |
+
emitter.removeEventListener(name, wrapListener);
|
476 |
+
}
|
477 |
+
listener(arg);
|
478 |
+
});
|
479 |
+
} else {
|
480 |
+
throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof emitter);
|
481 |
+
}
|
482 |
+
}
|
483 |
+
|
484 |
+
/***/ }),
|
485 |
+
|
486 |
+
/***/ 58:
|
487 |
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
488 |
+
|
489 |
+
module.exports = __webpack_require__.p + "3fe9f0f9e254e41ba4b4.wasm";
|
490 |
+
|
491 |
+
/***/ })
|
492 |
+
|
493 |
+
/******/ });
|
494 |
+
/************************************************************************/
|
495 |
+
/******/ // The module cache
|
496 |
+
/******/ var __webpack_module_cache__ = {};
|
497 |
+
/******/
|
498 |
+
/******/ // The require function
|
499 |
+
/******/ function __webpack_require__(moduleId) {
|
500 |
+
/******/ // Check if module is in cache
|
501 |
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
502 |
+
/******/ if (cachedModule !== undefined) {
|
503 |
+
/******/ return cachedModule.exports;
|
504 |
+
/******/ }
|
505 |
+
/******/ // Create a new module (and put it into the cache)
|
506 |
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
507 |
+
/******/ // no module.id needed
|
508 |
+
/******/ // no module.loaded needed
|
509 |
+
/******/ exports: {}
|
510 |
+
/******/ };
|
511 |
+
/******/
|
512 |
+
/******/ // Execute the module function
|
513 |
+
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
514 |
+
/******/
|
515 |
+
/******/ // Return the exports of the module
|
516 |
+
/******/ return module.exports;
|
517 |
+
/******/ }
|
518 |
+
/******/
|
519 |
+
/******/ // expose the modules object (__webpack_modules__)
|
520 |
+
/******/ __webpack_require__.m = __webpack_modules__;
|
521 |
+
/******/
|
522 |
+
/************************************************************************/
|
523 |
+
/******/ /* webpack/runtime/global */
|
524 |
+
/******/ (() => {
|
525 |
+
/******/ __webpack_require__.g = (function() {
|
526 |
+
/******/ if (typeof globalThis === 'object') return globalThis;
|
527 |
+
/******/ try {
|
528 |
+
/******/ return this || new Function('return this')();
|
529 |
+
/******/ } catch (e) {
|
530 |
+
/******/ if (typeof window === 'object') return window;
|
531 |
+
/******/ }
|
532 |
+
/******/ })();
|
533 |
+
/******/ })();
|
534 |
+
/******/
|
535 |
+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
536 |
+
/******/ (() => {
|
537 |
+
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
538 |
+
/******/ })();
|
539 |
+
/******/
|
540 |
+
/******/ /* webpack/runtime/publicPath */
|
541 |
+
/******/ (() => {
|
542 |
+
/******/ var scriptUrl;
|
543 |
+
/******/ if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + "";
|
544 |
+
/******/ var document = __webpack_require__.g.document;
|
545 |
+
/******/ if (!scriptUrl && document) {
|
546 |
+
/******/ if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT')
|
547 |
+
/******/ scriptUrl = document.currentScript.src;
|
548 |
+
/******/ if (!scriptUrl) {
|
549 |
+
/******/ var scripts = document.getElementsByTagName("script");
|
550 |
+
/******/ if(scripts.length) {
|
551 |
+
/******/ var i = scripts.length - 1;
|
552 |
+
/******/ while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src;
|
553 |
+
/******/ }
|
554 |
+
/******/ }
|
555 |
+
/******/ }
|
556 |
+
/******/ // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration
|
557 |
+
/******/ // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.
|
558 |
+
/******/ if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
|
559 |
+
/******/ scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
|
560 |
+
/******/ __webpack_require__.p = scriptUrl;
|
561 |
+
/******/ })();
|
562 |
+
/******/
|
563 |
+
/******/ /* webpack/runtime/jsonp chunk loading */
|
564 |
+
/******/ (() => {
|
565 |
+
/******/ __webpack_require__.b = document.baseURI || self.location.href;
|
566 |
+
/******/
|
567 |
+
/******/ // object to store loaded and loading chunks
|
568 |
+
/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
|
569 |
+
/******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
|
570 |
+
/******/ var installedChunks = {
|
571 |
+
/******/ 792: 0
|
572 |
+
/******/ };
|
573 |
+
/******/
|
574 |
+
/******/ // no chunk on demand loading
|
575 |
+
/******/
|
576 |
+
/******/ // no prefetching
|
577 |
+
/******/
|
578 |
+
/******/ // no preloaded
|
579 |
+
/******/
|
580 |
+
/******/ // no HMR
|
581 |
+
/******/
|
582 |
+
/******/ // no HMR manifest
|
583 |
+
/******/
|
584 |
+
/******/ // no on chunks loaded
|
585 |
+
/******/
|
586 |
+
/******/ // no jsonp function
|
587 |
+
/******/ })();
|
588 |
+
/******/
|
589 |
+
/************************************************************************/
|
590 |
+
|
591 |
+
// EXTERNAL MODULE: ./node_modules/events/events.js
|
592 |
+
var events = __webpack_require__(7);
|
593 |
+
;// CONCATENATED MODULE: ./src/control.js
|
594 |
+
|
595 |
+
class Control extends events.EventEmitter {
|
596 |
+
constructor() {
|
597 |
+
super();
|
598 |
+
this.state = null;
|
599 |
+
this.player_index = null;
|
600 |
+
this._assets_url = null;
|
601 |
+
|
602 |
+
this.addListener("state", (data) => {
|
603 |
+
this.state = data;
|
604 |
+
});
|
605 |
+
// When we receive log slices, when executing a move
|
606 |
+
this.addListener("gamelog", (logData) => {
|
607 |
+
// Ignore the log data and tell the backend we want the new state
|
608 |
+
this.emit("fetchState");
|
609 |
+
});
|
610 |
+
this.addListener("state:updated", () => {
|
611 |
+
this.emit("fetchState");
|
612 |
+
});
|
613 |
+
this.addListener("player", (player) => {
|
614 |
+
this.player_index = player.index;
|
615 |
+
});
|
616 |
+
}
|
617 |
+
|
618 |
+
receive_state() {
|
619 |
+
const state = this.state;
|
620 |
+
this.state = null;
|
621 |
+
return state;
|
622 |
+
}
|
623 |
+
|
624 |
+
receive_player_index() {
|
625 |
+
const index = this.player_index;
|
626 |
+
this.player_index = null;
|
627 |
+
return index;
|
628 |
+
}
|
629 |
+
|
630 |
+
send_move(move) {
|
631 |
+
this.emit("move", move);
|
632 |
+
}
|
633 |
+
|
634 |
+
send_ready() {
|
635 |
+
console.log("Sending ready");
|
636 |
+
this.emit("ready");
|
637 |
+
}
|
638 |
+
|
639 |
+
get assets_url() {
|
640 |
+
return this._assets_url;
|
641 |
+
}
|
642 |
+
|
643 |
+
set assets_url(value) {
|
644 |
+
this._assets_url = value;
|
645 |
+
}
|
646 |
+
}
|
647 |
+
|
648 |
+
function get_control() {
|
649 |
+
return window.clash_control;
|
650 |
+
}
|
651 |
+
|
652 |
+
|
653 |
+
;// CONCATENATED MODULE: ../dist/snippets/client-cda1b8d006d10648/js/src/control.js
|
654 |
+
|
655 |
+
class control_Control extends events.EventEmitter {
|
656 |
+
constructor() {
|
657 |
+
super();
|
658 |
+
this.state = null;
|
659 |
+
this.player_index = null;
|
660 |
+
this._assets_url = null;
|
661 |
+
|
662 |
+
this.addListener("state", (data) => {
|
663 |
+
this.state = data;
|
664 |
+
});
|
665 |
+
// When we receive log slices, when executing a move
|
666 |
+
this.addListener("gamelog", (logData) => {
|
667 |
+
// Ignore the log data and tell the backend we want the new state
|
668 |
+
this.emit("fetchState");
|
669 |
+
});
|
670 |
+
this.addListener("state:updated", () => {
|
671 |
+
this.emit("fetchState");
|
672 |
+
});
|
673 |
+
this.addListener("player", (player) => {
|
674 |
+
this.player_index = player.index;
|
675 |
+
});
|
676 |
+
}
|
677 |
+
|
678 |
+
receive_state() {
|
679 |
+
const state = this.state;
|
680 |
+
this.state = null;
|
681 |
+
return state;
|
682 |
+
}
|
683 |
+
|
684 |
+
receive_player_index() {
|
685 |
+
const index = this.player_index;
|
686 |
+
this.player_index = null;
|
687 |
+
return index;
|
688 |
+
}
|
689 |
+
|
690 |
+
send_move(move) {
|
691 |
+
this.emit("move", move);
|
692 |
+
}
|
693 |
+
|
694 |
+
send_ready() {
|
695 |
+
console.log("Sending ready");
|
696 |
+
this.emit("ready");
|
697 |
+
}
|
698 |
+
|
699 |
+
get assets_url() {
|
700 |
+
return this._assets_url;
|
701 |
+
}
|
702 |
+
|
703 |
+
set assets_url(value) {
|
704 |
+
this._assets_url = value;
|
705 |
+
}
|
706 |
+
}
|
707 |
+
|
708 |
+
function control_get_control() {
|
709 |
+
return window.clash_control;
|
710 |
+
}
|
711 |
+
|
712 |
+
|
713 |
+
;// CONCATENATED MODULE: ../dist/remote_client.js
|
714 |
+
|
715 |
+
|
716 |
+
let wasm; const set_wasm = (w) => wasm = w;
|
717 |
+
|
718 |
+
const heap = new Array(128).fill(undefined);
|
719 |
+
|
720 |
+
heap.push(undefined, null, true, false);
|
721 |
+
|
722 |
+
function getObject(idx) { return heap[idx]; }
|
723 |
+
|
724 |
+
function isLikeNone(x) {
|
725 |
+
return x === undefined || x === null;
|
726 |
+
}
|
727 |
+
|
728 |
+
function _assertNum(n) {
|
729 |
+
if (typeof(n) !== 'number') throw new Error(`expected a number argument, found ${typeof(n)}`);
|
730 |
+
}
|
731 |
+
|
732 |
+
let cachedDataViewMemory0 = null;
|
733 |
+
|
734 |
+
function getDataViewMemory0() {
|
735 |
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
736 |
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
737 |
+
}
|
738 |
+
return cachedDataViewMemory0;
|
739 |
+
}
|
740 |
+
|
741 |
+
function _assertBoolean(n) {
|
742 |
+
if (typeof(n) !== 'boolean') {
|
743 |
+
throw new Error(`expected a boolean argument, found ${typeof(n)}`);
|
744 |
+
}
|
745 |
+
}
|
746 |
+
|
747 |
+
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
|
748 |
+
|
749 |
+
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
|
750 |
+
|
751 |
+
let cachedUint8ArrayMemory0 = null;
|
752 |
+
|
753 |
+
function getUint8ArrayMemory0() {
|
754 |
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
755 |
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
756 |
+
}
|
757 |
+
return cachedUint8ArrayMemory0;
|
758 |
+
}
|
759 |
+
|
760 |
+
function getStringFromWasm0(ptr, len) {
|
761 |
+
ptr = ptr >>> 0;
|
762 |
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
763 |
+
}
|
764 |
+
|
765 |
+
let heap_next = heap.length;
|
766 |
+
|
767 |
+
function addHeapObject(obj) {
|
768 |
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
769 |
+
const idx = heap_next;
|
770 |
+
heap_next = heap[idx];
|
771 |
+
|
772 |
+
if (typeof(heap_next) !== 'number') throw new Error('corrupt heap');
|
773 |
+
|
774 |
+
heap[idx] = obj;
|
775 |
+
return idx;
|
776 |
+
}
|
777 |
+
|
778 |
+
let WASM_VECTOR_LEN = 0;
|
779 |
+
|
780 |
+
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
|
781 |
+
|
782 |
+
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
783 |
+
? function (arg, view) {
|
784 |
+
return cachedTextEncoder.encodeInto(arg, view);
|
785 |
+
}
|
786 |
+
: function (arg, view) {
|
787 |
+
const buf = cachedTextEncoder.encode(arg);
|
788 |
+
view.set(buf);
|
789 |
+
return {
|
790 |
+
read: arg.length,
|
791 |
+
written: buf.length
|
792 |
+
};
|
793 |
+
});
|
794 |
+
|
795 |
+
function passStringToWasm0(arg, malloc, realloc) {
|
796 |
+
|
797 |
+
if (typeof(arg) !== 'string') throw new Error(`expected a string argument, found ${typeof(arg)}`);
|
798 |
+
|
799 |
+
if (realloc === undefined) {
|
800 |
+
const buf = cachedTextEncoder.encode(arg);
|
801 |
+
const ptr = malloc(buf.length, 1) >>> 0;
|
802 |
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
803 |
+
WASM_VECTOR_LEN = buf.length;
|
804 |
+
return ptr;
|
805 |
+
}
|
806 |
+
|
807 |
+
let len = arg.length;
|
808 |
+
let ptr = malloc(len, 1) >>> 0;
|
809 |
+
|
810 |
+
const mem = getUint8ArrayMemory0();
|
811 |
+
|
812 |
+
let offset = 0;
|
813 |
+
|
814 |
+
for (; offset < len; offset++) {
|
815 |
+
const code = arg.charCodeAt(offset);
|
816 |
+
if (code > 0x7F) break;
|
817 |
+
mem[ptr + offset] = code;
|
818 |
+
}
|
819 |
+
|
820 |
+
if (offset !== len) {
|
821 |
+
if (offset !== 0) {
|
822 |
+
arg = arg.slice(offset);
|
823 |
+
}
|
824 |
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
825 |
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
826 |
+
const ret = encodeString(arg, view);
|
827 |
+
if (ret.read !== arg.length) throw new Error('failed to pass whole string');
|
828 |
+
offset += ret.written;
|
829 |
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
830 |
+
}
|
831 |
+
|
832 |
+
WASM_VECTOR_LEN = offset;
|
833 |
+
return ptr;
|
834 |
+
}
|
835 |
+
|
836 |
+
function dropObject(idx) {
|
837 |
+
if (idx < 132) return;
|
838 |
+
heap[idx] = heap_next;
|
839 |
+
heap_next = idx;
|
840 |
+
}
|
841 |
+
|
842 |
+
function takeObject(idx) {
|
843 |
+
const ret = getObject(idx);
|
844 |
+
dropObject(idx);
|
845 |
+
return ret;
|
846 |
+
}
|
847 |
+
|
848 |
+
function debugString(val) {
|
849 |
+
// primitive types
|
850 |
+
const type = typeof val;
|
851 |
+
if (type == 'number' || type == 'boolean' || val == null) {
|
852 |
+
return `${val}`;
|
853 |
+
}
|
854 |
+
if (type == 'string') {
|
855 |
+
return `"${val}"`;
|
856 |
+
}
|
857 |
+
if (type == 'symbol') {
|
858 |
+
const description = val.description;
|
859 |
+
if (description == null) {
|
860 |
+
return 'Symbol';
|
861 |
+
} else {
|
862 |
+
return `Symbol(${description})`;
|
863 |
+
}
|
864 |
+
}
|
865 |
+
if (type == 'function') {
|
866 |
+
const name = val.name;
|
867 |
+
if (typeof name == 'string' && name.length > 0) {
|
868 |
+
return `Function(${name})`;
|
869 |
+
} else {
|
870 |
+
return 'Function';
|
871 |
+
}
|
872 |
+
}
|
873 |
+
// objects
|
874 |
+
if (Array.isArray(val)) {
|
875 |
+
const length = val.length;
|
876 |
+
let debug = '[';
|
877 |
+
if (length > 0) {
|
878 |
+
debug += debugString(val[0]);
|
879 |
+
}
|
880 |
+
for(let i = 1; i < length; i++) {
|
881 |
+
debug += ', ' + debugString(val[i]);
|
882 |
+
}
|
883 |
+
debug += ']';
|
884 |
+
return debug;
|
885 |
+
}
|
886 |
+
// Test for built-in
|
887 |
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
888 |
+
let className;
|
889 |
+
if (builtInMatches.length > 1) {
|
890 |
+
className = builtInMatches[1];
|
891 |
+
} else {
|
892 |
+
// Failed to match the standard '[object ClassName]'
|
893 |
+
return toString.call(val);
|
894 |
+
}
|
895 |
+
if (className == 'Object') {
|
896 |
+
// we're a user defined class or Object
|
897 |
+
// JSON.stringify avoids problems with cycles, and is generally much
|
898 |
+
// easier than looping through ownProperties of `val`.
|
899 |
+
try {
|
900 |
+
return 'Object(' + JSON.stringify(val) + ')';
|
901 |
+
} catch (_) {
|
902 |
+
return 'Object';
|
903 |
+
}
|
904 |
+
}
|
905 |
+
// errors
|
906 |
+
if (val instanceof Error) {
|
907 |
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
908 |
+
}
|
909 |
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
910 |
+
return className;
|
911 |
+
}
|
912 |
+
|
913 |
+
function _assertBigInt(n) {
|
914 |
+
if (typeof(n) !== 'bigint') throw new Error(`expected a bigint argument, found ${typeof(n)}`);
|
915 |
+
}
|
916 |
+
|
917 |
+
const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
|
918 |
+
? { register: () => {}, unregister: () => {} }
|
919 |
+
: new FinalizationRegistry(state => {
|
920 |
+
wasm.__wbindgen_export_2.get(state.dtor)(state.a, state.b)
|
921 |
+
});
|
922 |
+
|
923 |
+
function makeMutClosure(arg0, arg1, dtor, f) {
|
924 |
+
const state = { a: arg0, b: arg1, cnt: 1, dtor };
|
925 |
+
const real = (...args) => {
|
926 |
+
// First up with a closure we increment the internal reference
|
927 |
+
// count. This ensures that the Rust closure environment won't
|
928 |
+
// be deallocated while we're invoking it.
|
929 |
+
state.cnt++;
|
930 |
+
const a = state.a;
|
931 |
+
state.a = 0;
|
932 |
+
try {
|
933 |
+
return f(a, state.b, ...args);
|
934 |
+
} finally {
|
935 |
+
if (--state.cnt === 0) {
|
936 |
+
wasm.__wbindgen_export_2.get(state.dtor)(a, state.b);
|
937 |
+
CLOSURE_DTORS.unregister(state);
|
938 |
+
} else {
|
939 |
+
state.a = a;
|
940 |
+
}
|
941 |
+
}
|
942 |
+
};
|
943 |
+
real.original = state;
|
944 |
+
CLOSURE_DTORS.register(real, state, state);
|
945 |
+
return real;
|
946 |
+
}
|
947 |
+
|
948 |
+
function logError(f, args) {
|
949 |
+
try {
|
950 |
+
return f.apply(this, args);
|
951 |
+
} catch (e) {
|
952 |
+
let error = (function () {
|
953 |
+
try {
|
954 |
+
return e instanceof Error ? `${e.message}\n\nStack:\n${e.stack}` : e.toString();
|
955 |
+
} catch(_) {
|
956 |
+
return "<failed to stringify thrown value>";
|
957 |
+
}
|
958 |
+
}());
|
959 |
+
console.error("wasm-bindgen: imported JS function that was not marked as `catch` threw an error:", error);
|
960 |
+
throw e;
|
961 |
+
}
|
962 |
+
}
|
963 |
+
function __wbg_adapter_48(arg0, arg1, arg2) {
|
964 |
+
_assertNum(arg0);
|
965 |
+
_assertNum(arg1);
|
966 |
+
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h3fa2d535db38cca6(arg0, arg1, addHeapObject(arg2));
|
967 |
+
}
|
968 |
+
|
969 |
+
/**
|
970 |
+
* @param {any} players
|
971 |
+
* @param {any} _expansions
|
972 |
+
* @param {any} _options
|
973 |
+
* @param {any} seed
|
974 |
+
* @param {any} _creator
|
975 |
+
* @returns {Promise<any>}
|
976 |
+
*/
|
977 |
+
function init(players, _expansions, _options, seed, _creator) {
|
978 |
+
const ret = wasm.init(addHeapObject(players), addHeapObject(_expansions), addHeapObject(_options), addHeapObject(seed), addHeapObject(_creator));
|
979 |
+
return takeObject(ret);
|
980 |
+
}
|
981 |
+
|
982 |
+
/**
|
983 |
+
* @param {any} game
|
984 |
+
* @param {any} move_data
|
985 |
+
* @param {any} player
|
986 |
+
* @returns {any}
|
987 |
+
*/
|
988 |
+
function move(game, move_data, player) {
|
989 |
+
const ret = wasm.move(addHeapObject(game), addHeapObject(move_data), addHeapObject(player));
|
990 |
+
return takeObject(ret);
|
991 |
+
}
|
992 |
+
|
993 |
+
/**
|
994 |
+
* @param {any} game
|
995 |
+
* @returns {any}
|
996 |
+
*/
|
997 |
+
function ended(game) {
|
998 |
+
const ret = wasm.ended(addHeapObject(game));
|
999 |
+
return takeObject(ret);
|
1000 |
+
}
|
1001 |
+
|
1002 |
+
/**
|
1003 |
+
* @param {any} game
|
1004 |
+
* @returns {any}
|
1005 |
+
*/
|
1006 |
+
function scores(game) {
|
1007 |
+
const ret = wasm.scores(addHeapObject(game));
|
1008 |
+
return takeObject(ret);
|
1009 |
+
}
|
1010 |
+
|
1011 |
+
/**
|
1012 |
+
* @param {any} game
|
1013 |
+
* @param {any} player
|
1014 |
+
* @returns {Promise<any>}
|
1015 |
+
*/
|
1016 |
+
function dropPlayer(game, player) {
|
1017 |
+
const ret = wasm.dropPlayer(addHeapObject(game), addHeapObject(player));
|
1018 |
+
return takeObject(ret);
|
1019 |
+
}
|
1020 |
+
|
1021 |
+
/**
|
1022 |
+
* @param {any} game
|
1023 |
+
* @returns {any}
|
1024 |
+
*/
|
1025 |
+
function currentPlayer(game) {
|
1026 |
+
const ret = wasm.currentPlayer(addHeapObject(game));
|
1027 |
+
return takeObject(ret);
|
1028 |
+
}
|
1029 |
+
|
1030 |
+
/**
|
1031 |
+
* @param {any} game
|
1032 |
+
* @returns {any}
|
1033 |
+
*/
|
1034 |
+
function logLength(game) {
|
1035 |
+
const ret = wasm.logLength(addHeapObject(game));
|
1036 |
+
return takeObject(ret);
|
1037 |
+
}
|
1038 |
+
|
1039 |
+
/**
|
1040 |
+
* @param {any} game
|
1041 |
+
* @param {any} options
|
1042 |
+
* @returns {any}
|
1043 |
+
*/
|
1044 |
+
function logSlice(game, options) {
|
1045 |
+
const ret = wasm.logSlice(addHeapObject(game), addHeapObject(options));
|
1046 |
+
return takeObject(ret);
|
1047 |
+
}
|
1048 |
+
|
1049 |
+
/**
|
1050 |
+
* @param {any} game
|
1051 |
+
* @param {any} player_index
|
1052 |
+
* @param {any} meta_data
|
1053 |
+
* @returns {any}
|
1054 |
+
*/
|
1055 |
+
function setPlayerMetaData(game, player_index, meta_data) {
|
1056 |
+
const ret = wasm.setPlayerMetaData(addHeapObject(game), addHeapObject(player_index), addHeapObject(meta_data));
|
1057 |
+
return takeObject(ret);
|
1058 |
+
}
|
1059 |
+
|
1060 |
+
/**
|
1061 |
+
* @param {any} game
|
1062 |
+
* @returns {any}
|
1063 |
+
*/
|
1064 |
+
function rankings(game) {
|
1065 |
+
const ret = wasm.rankings(addHeapObject(game));
|
1066 |
+
return takeObject(ret);
|
1067 |
+
}
|
1068 |
+
|
1069 |
+
/**
|
1070 |
+
* @param {any} game
|
1071 |
+
* @returns {any}
|
1072 |
+
*/
|
1073 |
+
function roundNumber(game) {
|
1074 |
+
const ret = wasm.roundNumber(addHeapObject(game));
|
1075 |
+
return takeObject(ret);
|
1076 |
+
}
|
1077 |
+
|
1078 |
+
/**
|
1079 |
+
* @param {any} game
|
1080 |
+
* @returns {any}
|
1081 |
+
*/
|
1082 |
+
function factions(game) {
|
1083 |
+
const ret = wasm.factions(addHeapObject(game));
|
1084 |
+
return takeObject(ret);
|
1085 |
+
}
|
1086 |
+
|
1087 |
+
/**
|
1088 |
+
* @param {any} game
|
1089 |
+
* @param {any} player
|
1090 |
+
* @returns {any}
|
1091 |
+
*/
|
1092 |
+
function stripSecret(game, player) {
|
1093 |
+
const ret = wasm.stripSecret(addHeapObject(game), addHeapObject(player));
|
1094 |
+
return takeObject(ret);
|
1095 |
+
}
|
1096 |
+
|
1097 |
+
/**
|
1098 |
+
* @param {any} game
|
1099 |
+
* @returns {any}
|
1100 |
+
*/
|
1101 |
+
function messages(game) {
|
1102 |
+
const ret = wasm.messages(addHeapObject(game));
|
1103 |
+
return takeObject(ret);
|
1104 |
+
}
|
1105 |
+
|
1106 |
+
function handleError(f, args) {
|
1107 |
+
try {
|
1108 |
+
return f.apply(this, args);
|
1109 |
+
} catch (e) {
|
1110 |
+
wasm.__wbindgen_exn_store(addHeapObject(e));
|
1111 |
+
}
|
1112 |
+
}
|
1113 |
+
function __wbg_adapter_121(arg0, arg1, arg2, arg3) {
|
1114 |
+
_assertNum(arg0);
|
1115 |
+
_assertNum(arg1);
|
1116 |
+
wasm.wasm_bindgen__convert__closures__invoke2_mut__h57a40dbe11a3c21c(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
1117 |
+
}
|
1118 |
+
|
1119 |
+
const RemoteClientFinalization = (typeof FinalizationRegistry === 'undefined')
|
1120 |
+
? { register: () => {}, unregister: () => {} }
|
1121 |
+
: new FinalizationRegistry(ptr => wasm.__wbg_remoteclient_free(ptr >>> 0, 1));
|
1122 |
+
/**
|
1123 |
+
*/
|
1124 |
+
class RemoteClient {
|
1125 |
+
|
1126 |
+
constructor() {
|
1127 |
+
throw new Error('cannot invoke `new` directly');
|
1128 |
+
}
|
1129 |
+
|
1130 |
+
__destroy_into_raw() {
|
1131 |
+
const ptr = this.__wbg_ptr;
|
1132 |
+
this.__wbg_ptr = 0;
|
1133 |
+
RemoteClientFinalization.unregister(this);
|
1134 |
+
return ptr;
|
1135 |
+
}
|
1136 |
+
|
1137 |
+
free() {
|
1138 |
+
const ptr = this.__destroy_into_raw();
|
1139 |
+
wasm.__wbg_remoteclient_free(ptr, 0);
|
1140 |
+
}
|
1141 |
+
/**
|
1142 |
+
* @returns {Promise<void>}
|
1143 |
+
*/
|
1144 |
+
static start() {
|
1145 |
+
const ret = wasm.remoteclient_start();
|
1146 |
+
return takeObject(ret);
|
1147 |
+
}
|
1148 |
+
/**
|
1149 |
+
* @returns {Promise<void>}
|
1150 |
+
*/
|
1151 |
+
run() {
|
1152 |
+
if (this.__wbg_ptr == 0) throw new Error('Attempt to use a moved value');
|
1153 |
+
_assertNum(this.__wbg_ptr);
|
1154 |
+
const ret = wasm.remoteclient_run(this.__wbg_ptr);
|
1155 |
+
return takeObject(ret);
|
1156 |
+
}
|
1157 |
+
}
|
1158 |
+
|
1159 |
+
async function __wbg_load(module, imports) {
|
1160 |
+
if (typeof Response === 'function' && module instanceof Response) {
|
1161 |
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
1162 |
+
try {
|
1163 |
+
return await WebAssembly.instantiateStreaming(module, imports);
|
1164 |
+
|
1165 |
+
} catch (e) {
|
1166 |
+
if (module.headers.get('Content-Type') != 'application/wasm') {
|
1167 |
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
1168 |
+
|
1169 |
+
} else {
|
1170 |
+
throw e;
|
1171 |
+
}
|
1172 |
+
}
|
1173 |
+
}
|
1174 |
+
|
1175 |
+
const bytes = await module.arrayBuffer();
|
1176 |
+
return await WebAssembly.instantiate(bytes, imports);
|
1177 |
+
|
1178 |
+
} else {
|
1179 |
+
const instance = await WebAssembly.instantiate(module, imports);
|
1180 |
+
|
1181 |
+
if (instance instanceof WebAssembly.Instance) {
|
1182 |
+
return { instance, module };
|
1183 |
+
|
1184 |
+
} else {
|
1185 |
+
return instance;
|
1186 |
+
}
|
1187 |
+
}
|
1188 |
+
}
|
1189 |
+
|
1190 |
+
function __wbg_get_imports() {
|
1191 |
+
const imports = {};
|
1192 |
+
imports.wbg = {};
|
1193 |
+
imports.wbg.__wbg_log_4bdf1576e3317256 = function() { return logError(function (arg0, arg1) {
|
1194 |
+
console.log(getStringFromWasm0(arg0, arg1));
|
1195 |
+
}, arguments) };
|
1196 |
+
imports.wbg.__wbg_getcontrol_3264bfc667ef7fdf = function() { return logError(function () {
|
1197 |
+
const ret = control_get_control();
|
1198 |
+
return addHeapObject(ret);
|
1199 |
+
}, arguments) };
|
1200 |
+
imports.wbg.__wbg_receivestate_f4445fef81eefecf = function() { return logError(function (arg0) {
|
1201 |
+
const ret = getObject(arg0).receive_state();
|
1202 |
+
return addHeapObject(ret);
|
1203 |
+
}, arguments) };
|
1204 |
+
imports.wbg.__wbg_receiveplayerindex_ab65cd651c6192b6 = function() { return logError(function (arg0) {
|
1205 |
+
const ret = getObject(arg0).receive_player_index();
|
1206 |
+
return addHeapObject(ret);
|
1207 |
+
}, arguments) };
|
1208 |
+
imports.wbg.__wbg_sendmove_fed46023fcc631cd = function() { return logError(function (arg0, arg1) {
|
1209 |
+
getObject(arg0).send_move(takeObject(arg1));
|
1210 |
+
}, arguments) };
|
1211 |
+
imports.wbg.__wbg_sendready_b0dce48818afc6a8 = function() { return logError(function (arg0) {
|
1212 |
+
getObject(arg0).send_ready();
|
1213 |
+
}, arguments) };
|
1214 |
+
imports.wbg.__wbg_assetsurl_f9692a68a8f05e40 = function() { return logError(function (arg0, arg1) {
|
1215 |
+
const ret = getObject(arg1).assets_url;
|
1216 |
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
1217 |
+
const len1 = WASM_VECTOR_LEN;
|
1218 |
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
1219 |
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
1220 |
+
}, arguments) };
|
1221 |
+
imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
|
1222 |
+
const obj = getObject(arg1);
|
1223 |
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
1224 |
+
if (!isLikeNone(ret)) {
|
1225 |
+
_assertNum(ret);
|
1226 |
+
}
|
1227 |
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
1228 |
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
1229 |
+
};
|
1230 |
+
imports.wbg.__wbindgen_is_object = function(arg0) {
|
1231 |
+
const val = getObject(arg0);
|
1232 |
+
const ret = typeof(val) === 'object' && val !== null;
|
1233 |
+
_assertBoolean(ret);
|
1234 |
+
return ret;
|
1235 |
+
};
|
1236 |
+
imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
|
1237 |
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
1238 |
+
return addHeapObject(ret);
|
1239 |
+
};
|
1240 |
+
imports.wbg.__wbindgen_is_undefined = function(arg0) {
|
1241 |
+
const ret = getObject(arg0) === undefined;
|
1242 |
+
_assertBoolean(ret);
|
1243 |
+
return ret;
|
1244 |
+
};
|
1245 |
+
imports.wbg.__wbindgen_as_number = function(arg0) {
|
1246 |
+
const ret = +getObject(arg0);
|
1247 |
+
return ret;
|
1248 |
+
};
|
1249 |
+
imports.wbg.__wbindgen_in = function(arg0, arg1) {
|
1250 |
+
const ret = getObject(arg0) in getObject(arg1);
|
1251 |
+
_assertBoolean(ret);
|
1252 |
+
return ret;
|
1253 |
+
};
|
1254 |
+
imports.wbg.__wbindgen_boolean_get = function(arg0) {
|
1255 |
+
const v = getObject(arg0);
|
1256 |
+
const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2;
|
1257 |
+
_assertNum(ret);
|
1258 |
+
return ret;
|
1259 |
+
};
|
1260 |
+
imports.wbg.__wbindgen_number_new = function(arg0) {
|
1261 |
+
const ret = arg0;
|
1262 |
+
return addHeapObject(ret);
|
1263 |
+
};
|
1264 |
+
imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
|
1265 |
+
const obj = getObject(arg1);
|
1266 |
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
1267 |
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
1268 |
+
var len1 = WASM_VECTOR_LEN;
|
1269 |
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
1270 |
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
1271 |
+
};
|
1272 |
+
imports.wbg.__wbindgen_is_bigint = function(arg0) {
|
1273 |
+
const ret = typeof(getObject(arg0)) === 'bigint';
|
1274 |
+
_assertBoolean(ret);
|
1275 |
+
return ret;
|
1276 |
+
};
|
1277 |
+
imports.wbg.__wbindgen_is_string = function(arg0) {
|
1278 |
+
const ret = typeof(getObject(arg0)) === 'string';
|
1279 |
+
_assertBoolean(ret);
|
1280 |
+
return ret;
|
1281 |
+
};
|
1282 |
+
imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
|
1283 |
+
const ret = getObject(arg0);
|
1284 |
+
return addHeapObject(ret);
|
1285 |
+
};
|
1286 |
+
imports.wbg.__wbindgen_jsval_eq = function(arg0, arg1) {
|
1287 |
+
const ret = getObject(arg0) === getObject(arg1);
|
1288 |
+
_assertBoolean(ret);
|
1289 |
+
return ret;
|
1290 |
+
};
|
1291 |
+
imports.wbg.__wbindgen_bigint_from_u64 = function(arg0) {
|
1292 |
+
const ret = BigInt.asUintN(64, arg0);
|
1293 |
+
return addHeapObject(ret);
|
1294 |
+
};
|
1295 |
+
imports.wbg.__wbindgen_is_function = function(arg0) {
|
1296 |
+
const ret = typeof(getObject(arg0)) === 'function';
|
1297 |
+
_assertBoolean(ret);
|
1298 |
+
return ret;
|
1299 |
+
};
|
1300 |
+
imports.wbg.__wbindgen_cb_drop = function(arg0) {
|
1301 |
+
const obj = takeObject(arg0).original;
|
1302 |
+
if (obj.cnt-- == 1) {
|
1303 |
+
obj.a = 0;
|
1304 |
+
return true;
|
1305 |
+
}
|
1306 |
+
const ret = false;
|
1307 |
+
_assertBoolean(ret);
|
1308 |
+
return ret;
|
1309 |
+
};
|
1310 |
+
imports.wbg.__wbg_queueMicrotask_12a30234db4045d3 = function() { return logError(function (arg0) {
|
1311 |
+
queueMicrotask(getObject(arg0));
|
1312 |
+
}, arguments) };
|
1313 |
+
imports.wbg.__wbg_queueMicrotask_48421b3cc9052b68 = function() { return logError(function (arg0) {
|
1314 |
+
const ret = getObject(arg0).queueMicrotask;
|
1315 |
+
return addHeapObject(ret);
|
1316 |
+
}, arguments) };
|
1317 |
+
imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
|
1318 |
+
const ret = getStringFromWasm0(arg0, arg1);
|
1319 |
+
return addHeapObject(ret);
|
1320 |
+
};
|
1321 |
+
imports.wbg.__wbindgen_jsval_loose_eq = function(arg0, arg1) {
|
1322 |
+
const ret = getObject(arg0) == getObject(arg1);
|
1323 |
+
_assertBoolean(ret);
|
1324 |
+
return ret;
|
1325 |
+
};
|
1326 |
+
imports.wbg.__wbg_getwithrefkey_edc2c8960f0f1191 = function() { return logError(function (arg0, arg1) {
|
1327 |
+
const ret = getObject(arg0)[getObject(arg1)];
|
1328 |
+
return addHeapObject(ret);
|
1329 |
+
}, arguments) };
|
1330 |
+
imports.wbg.__wbg_set_f975102236d3c502 = function() { return logError(function (arg0, arg1, arg2) {
|
1331 |
+
getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
|
1332 |
+
}, arguments) };
|
1333 |
+
imports.wbg.__wbg_new_a220cf903aa02ca2 = function() { return logError(function () {
|
1334 |
+
const ret = new Array();
|
1335 |
+
return addHeapObject(ret);
|
1336 |
+
}, arguments) };
|
1337 |
+
imports.wbg.__wbg_get_3baa728f9d58d3f6 = function() { return logError(function (arg0, arg1) {
|
1338 |
+
const ret = getObject(arg0)[arg1 >>> 0];
|
1339 |
+
return addHeapObject(ret);
|
1340 |
+
}, arguments) };
|
1341 |
+
imports.wbg.__wbg_set_673dda6c73d19609 = function() { return logError(function (arg0, arg1, arg2) {
|
1342 |
+
getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
|
1343 |
+
}, arguments) };
|
1344 |
+
imports.wbg.__wbg_isArray_8364a5371e9737d8 = function() { return logError(function (arg0) {
|
1345 |
+
const ret = Array.isArray(getObject(arg0));
|
1346 |
+
_assertBoolean(ret);
|
1347 |
+
return ret;
|
1348 |
+
}, arguments) };
|
1349 |
+
imports.wbg.__wbg_length_ae22078168b726f5 = function() { return logError(function (arg0) {
|
1350 |
+
const ret = getObject(arg0).length;
|
1351 |
+
_assertNum(ret);
|
1352 |
+
return ret;
|
1353 |
+
}, arguments) };
|
1354 |
+
imports.wbg.__wbg_instanceof_ArrayBuffer_61dfc3198373c902 = function() { return logError(function (arg0) {
|
1355 |
+
let result;
|
1356 |
+
try {
|
1357 |
+
result = getObject(arg0) instanceof ArrayBuffer;
|
1358 |
+
} catch (_) {
|
1359 |
+
result = false;
|
1360 |
+
}
|
1361 |
+
const ret = result;
|
1362 |
+
_assertBoolean(ret);
|
1363 |
+
return ret;
|
1364 |
+
}, arguments) };
|
1365 |
+
imports.wbg.__wbg_newnoargs_76313bd6ff35d0f2 = function() { return logError(function (arg0, arg1) {
|
1366 |
+
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
1367 |
+
return addHeapObject(ret);
|
1368 |
+
}, arguments) };
|
1369 |
+
imports.wbg.__wbg_call_1084a111329e68ce = function() { return handleError(function (arg0, arg1) {
|
1370 |
+
const ret = getObject(arg0).call(getObject(arg1));
|
1371 |
+
return addHeapObject(ret);
|
1372 |
+
}, arguments) };
|
1373 |
+
imports.wbg.__wbg_call_89af060b4e1523f2 = function() { return handleError(function (arg0, arg1, arg2) {
|
1374 |
+
const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
|
1375 |
+
return addHeapObject(ret);
|
1376 |
+
}, arguments) };
|
1377 |
+
imports.wbg.__wbg_next_f9cb570345655b9a = function() { return handleError(function (arg0) {
|
1378 |
+
const ret = getObject(arg0).next();
|
1379 |
+
return addHeapObject(ret);
|
1380 |
+
}, arguments) };
|
1381 |
+
imports.wbg.__wbg_next_de3e9db4440638b2 = function() { return logError(function (arg0) {
|
1382 |
+
const ret = getObject(arg0).next;
|
1383 |
+
return addHeapObject(ret);
|
1384 |
+
}, arguments) };
|
1385 |
+
imports.wbg.__wbg_done_bfda7aa8f252b39f = function() { return logError(function (arg0) {
|
1386 |
+
const ret = getObject(arg0).done;
|
1387 |
+
_assertBoolean(ret);
|
1388 |
+
return ret;
|
1389 |
+
}, arguments) };
|
1390 |
+
imports.wbg.__wbg_value_6d39332ab4788d86 = function() { return logError(function (arg0) {
|
1391 |
+
const ret = getObject(arg0).value;
|
1392 |
+
return addHeapObject(ret);
|
1393 |
+
}, arguments) };
|
1394 |
+
imports.wbg.__wbg_isSafeInteger_7f1ed56200d90674 = function() { return logError(function (arg0) {
|
1395 |
+
const ret = Number.isSafeInteger(getObject(arg0));
|
1396 |
+
_assertBoolean(ret);
|
1397 |
+
return ret;
|
1398 |
+
}, arguments) };
|
1399 |
+
imports.wbg.__wbg_entries_7a0e06255456ebcd = function() { return logError(function (arg0) {
|
1400 |
+
const ret = Object.entries(getObject(arg0));
|
1401 |
+
return addHeapObject(ret);
|
1402 |
+
}, arguments) };
|
1403 |
+
imports.wbg.__wbg_new_525245e2b9901204 = function() { return logError(function () {
|
1404 |
+
const ret = new Object();
|
1405 |
+
return addHeapObject(ret);
|
1406 |
+
}, arguments) };
|
1407 |
+
imports.wbg.__wbg_iterator_888179a48810a9fe = function() { return logError(function () {
|
1408 |
+
const ret = Symbol.iterator;
|
1409 |
+
return addHeapObject(ret);
|
1410 |
+
}, arguments) };
|
1411 |
+
imports.wbg.__wbg_new_b85e72ed1bfd57f9 = function() { return logError(function (arg0, arg1) {
|
1412 |
+
try {
|
1413 |
+
var state0 = {a: arg0, b: arg1};
|
1414 |
+
var cb0 = (arg0, arg1) => {
|
1415 |
+
const a = state0.a;
|
1416 |
+
state0.a = 0;
|
1417 |
+
try {
|
1418 |
+
return __wbg_adapter_121(a, state0.b, arg0, arg1);
|
1419 |
+
} finally {
|
1420 |
+
state0.a = a;
|
1421 |
+
}
|
1422 |
+
};
|
1423 |
+
const ret = new Promise(cb0);
|
1424 |
+
return addHeapObject(ret);
|
1425 |
+
} finally {
|
1426 |
+
state0.a = state0.b = 0;
|
1427 |
+
}
|
1428 |
+
}, arguments) };
|
1429 |
+
imports.wbg.__wbg_resolve_570458cb99d56a43 = function() { return logError(function (arg0) {
|
1430 |
+
const ret = Promise.resolve(getObject(arg0));
|
1431 |
+
return addHeapObject(ret);
|
1432 |
+
}, arguments) };
|
1433 |
+
imports.wbg.__wbg_then_95e6edc0f89b73b1 = function() { return logError(function (arg0, arg1) {
|
1434 |
+
const ret = getObject(arg0).then(getObject(arg1));
|
1435 |
+
return addHeapObject(ret);
|
1436 |
+
}, arguments) };
|
1437 |
+
imports.wbg.__wbg_globalThis_86b222e13bdf32ed = function() { return handleError(function () {
|
1438 |
+
const ret = globalThis.globalThis;
|
1439 |
+
return addHeapObject(ret);
|
1440 |
+
}, arguments) };
|
1441 |
+
imports.wbg.__wbg_self_3093d5d1f7bcb682 = function() { return handleError(function () {
|
1442 |
+
const ret = self.self;
|
1443 |
+
return addHeapObject(ret);
|
1444 |
+
}, arguments) };
|
1445 |
+
imports.wbg.__wbg_window_3bcfc4d31bc012f8 = function() { return handleError(function () {
|
1446 |
+
const ret = window.window;
|
1447 |
+
return addHeapObject(ret);
|
1448 |
+
}, arguments) };
|
1449 |
+
imports.wbg.__wbg_global_e5a3fe56f8be9485 = function() { return handleError(function () {
|
1450 |
+
const ret = __webpack_require__.g.global;
|
1451 |
+
return addHeapObject(ret);
|
1452 |
+
}, arguments) };
|
1453 |
+
imports.wbg.__wbg_instanceof_Uint8Array_247a91427532499e = function() { return logError(function (arg0) {
|
1454 |
+
let result;
|
1455 |
+
try {
|
1456 |
+
result = getObject(arg0) instanceof Uint8Array;
|
1457 |
+
} catch (_) {
|
1458 |
+
result = false;
|
1459 |
+
}
|
1460 |
+
const ret = result;
|
1461 |
+
_assertBoolean(ret);
|
1462 |
+
return ret;
|
1463 |
+
}, arguments) };
|
1464 |
+
imports.wbg.__wbg_new_ea1883e1e5e86686 = function() { return logError(function (arg0) {
|
1465 |
+
const ret = new Uint8Array(getObject(arg0));
|
1466 |
+
return addHeapObject(ret);
|
1467 |
+
}, arguments) };
|
1468 |
+
imports.wbg.__wbg_length_8339fcf5d8ecd12e = function() { return logError(function (arg0) {
|
1469 |
+
const ret = getObject(arg0).length;
|
1470 |
+
_assertNum(ret);
|
1471 |
+
return ret;
|
1472 |
+
}, arguments) };
|
1473 |
+
imports.wbg.__wbg_set_d1e79e2388520f18 = function() { return logError(function (arg0, arg1, arg2) {
|
1474 |
+
getObject(arg0).set(getObject(arg1), arg2 >>> 0);
|
1475 |
+
}, arguments) };
|
1476 |
+
imports.wbg.__wbg_buffer_b7b08af79b0b0974 = function() { return logError(function (arg0) {
|
1477 |
+
const ret = getObject(arg0).buffer;
|
1478 |
+
return addHeapObject(ret);
|
1479 |
+
}, arguments) };
|
1480 |
+
imports.wbg.__wbg_get_224d16597dbbfd96 = function() { return handleError(function (arg0, arg1) {
|
1481 |
+
const ret = Reflect.get(getObject(arg0), getObject(arg1));
|
1482 |
+
return addHeapObject(ret);
|
1483 |
+
}, arguments) };
|
1484 |
+
imports.wbg.__wbg_error_f851667af71bcfc6 = function() { return logError(function (arg0, arg1) {
|
1485 |
+
let deferred0_0;
|
1486 |
+
let deferred0_1;
|
1487 |
+
try {
|
1488 |
+
deferred0_0 = arg0;
|
1489 |
+
deferred0_1 = arg1;
|
1490 |
+
console.error(getStringFromWasm0(arg0, arg1));
|
1491 |
+
} finally {
|
1492 |
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
1493 |
+
}
|
1494 |
+
}, arguments) };
|
1495 |
+
imports.wbg.__wbg_new_abda76e883ba8a5f = function() { return logError(function () {
|
1496 |
+
const ret = new Error();
|
1497 |
+
return addHeapObject(ret);
|
1498 |
+
}, arguments) };
|
1499 |
+
imports.wbg.__wbg_stack_658279fe44541cf6 = function() { return logError(function (arg0, arg1) {
|
1500 |
+
const ret = getObject(arg1).stack;
|
1501 |
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
1502 |
+
const len1 = WASM_VECTOR_LEN;
|
1503 |
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
1504 |
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
1505 |
+
}, arguments) };
|
1506 |
+
imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
|
1507 |
+
const ret = debugString(getObject(arg1));
|
1508 |
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
1509 |
+
const len1 = WASM_VECTOR_LEN;
|
1510 |
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
1511 |
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
1512 |
+
};
|
1513 |
+
imports.wbg.__wbindgen_bigint_get_as_i64 = function(arg0, arg1) {
|
1514 |
+
const v = getObject(arg1);
|
1515 |
+
const ret = typeof(v) === 'bigint' ? v : undefined;
|
1516 |
+
if (!isLikeNone(ret)) {
|
1517 |
+
_assertBigInt(ret);
|
1518 |
+
}
|
1519 |
+
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
1520 |
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
1521 |
+
};
|
1522 |
+
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
1523 |
+
takeObject(arg0);
|
1524 |
+
};
|
1525 |
+
imports.wbg.__wbindgen_throw = function(arg0, arg1) {
|
1526 |
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
1527 |
+
};
|
1528 |
+
imports.wbg.__wbindgen_memory = function() {
|
1529 |
+
const ret = wasm.memory;
|
1530 |
+
return addHeapObject(ret);
|
1531 |
+
};
|
1532 |
+
imports.wbg.__wbindgen_closure_wrapper14642 = function() { return logError(function (arg0, arg1, arg2) {
|
1533 |
+
const ret = makeMutClosure(arg0, arg1, 692, __wbg_adapter_48);
|
1534 |
+
return addHeapObject(ret);
|
1535 |
+
}, arguments) };
|
1536 |
+
return imports.wbg;
|
1537 |
+
|
1538 |
+
return imports;
|
1539 |
+
}
|
1540 |
+
|
1541 |
+
function __wbg_init_memory(imports, memory) {
|
1542 |
+
|
1543 |
+
}
|
1544 |
+
|
1545 |
+
function __wbg_finalize_init(instance, module) {
|
1546 |
+
wasm = instance.exports;
|
1547 |
+
__wbg_init.__wbindgen_wasm_module = module;
|
1548 |
+
cachedDataViewMemory0 = null;
|
1549 |
+
cachedUint8ArrayMemory0 = null;
|
1550 |
+
|
1551 |
+
wasm.__wbindgen_start();
|
1552 |
+
return wasm;
|
1553 |
+
}
|
1554 |
+
|
1555 |
+
function initSync(module) {
|
1556 |
+
if (wasm !== undefined) return wasm;
|
1557 |
+
|
1558 |
+
if (typeof module !== 'undefined' && Object.getPrototypeOf(module) === Object.prototype)
|
1559 |
+
({module} = module)
|
1560 |
+
else
|
1561 |
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
1562 |
+
|
1563 |
+
return __wbg_get_imports();
|
1564 |
+
|
1565 |
+
__wbg_init_memory(imports);
|
1566 |
+
|
1567 |
+
if (!(module instanceof WebAssembly.Module)) {
|
1568 |
+
module = new WebAssembly.Module(module);
|
1569 |
+
}
|
1570 |
+
|
1571 |
+
const instance = new WebAssembly.Instance(module, imports);
|
1572 |
+
|
1573 |
+
return __wbg_finalize_init(instance, module);
|
1574 |
+
}
|
1575 |
+
|
1576 |
+
async function __wbg_init(module_or_path) {
|
1577 |
+
if (wasm !== undefined) return wasm;
|
1578 |
+
|
1579 |
+
if (typeof module_or_path !== 'undefined' && Object.getPrototypeOf(module_or_path) === Object.prototype)
|
1580 |
+
({module_or_path} = module_or_path)
|
1581 |
+
else
|
1582 |
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
1583 |
+
|
1584 |
+
if (typeof module_or_path === 'undefined') {
|
1585 |
+
module_or_path = new URL(/* asset import */ __webpack_require__(58), __webpack_require__.b);
|
1586 |
+
}
|
1587 |
+
return __wbg_get_imports();
|
1588 |
+
|
1589 |
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
1590 |
+
module_or_path = fetch(module_or_path);
|
1591 |
+
}
|
1592 |
+
|
1593 |
+
__wbg_init_memory(imports);
|
1594 |
+
|
1595 |
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
1596 |
+
|
1597 |
+
return __wbg_finalize_init(instance, module);
|
1598 |
+
}
|
1599 |
+
|
1600 |
+
/* harmony default export */ const remote_client = (__wbg_init);
|
1601 |
+
|
1602 |
+
;// CONCATENATED MODULE: ./src/run.js
|
1603 |
+
|
1604 |
+
function dynamicallyLoadScript(url, onload) {
|
1605 |
+
const script = document.createElement("script");
|
1606 |
+
script.onload = onload;
|
1607 |
+
script.src = url;
|
1608 |
+
|
1609 |
+
document.head.appendChild(script);
|
1610 |
+
}
|
1611 |
+
|
1612 |
+
async function run({selector, control}) {
|
1613 |
+
const root = document.querySelector(selector);
|
1614 |
+
const canvas = document.createElement("canvas");
|
1615 |
+
canvas.setAttribute("id", "glcanvas");
|
1616 |
+
canvas.setAttribute("style", `
|
1617 |
+
margin: 0px;
|
1618 |
+
padding: 0px;
|
1619 |
+
width: 100%;
|
1620 |
+
height: 100%;
|
1621 |
+
overflow: hidden;
|
1622 |
+
position: absolute;
|
1623 |
+
z-index: 0;
|
1624 |
+
`);
|
1625 |
+
root.appendChild(canvas);
|
1626 |
+
|
1627 |
+
dynamicallyLoadScript("https://not-fl3.github.io/miniquad-samples/mq_js_bundle.js", async () => {
|
1628 |
+
let wbg = await remote_client();
|
1629 |
+
miniquad_add_plugin({
|
1630 |
+
register_plugin: (a) => (a.wbg = wbg),
|
1631 |
+
on_init: () => set_wasm(wasm_exports),
|
1632 |
+
version: "0.0.1",
|
1633 |
+
name: "wbg",
|
1634 |
+
});
|
1635 |
+
const src = document.head.getElementsByTagName("script")[0].src;
|
1636 |
+
control.assets_url = src.replace("client.js", "assets/");
|
1637 |
+
const url = src.replace("client.js", "client.wasm");
|
1638 |
+
console.log("Loading wasm from", url);
|
1639 |
+
await load(url);
|
1640 |
+
});
|
1641 |
+
}
|
1642 |
+
|
1643 |
+
;// CONCATENATED MODULE: ./src/index.js
|
1644 |
+
|
1645 |
+
|
1646 |
+
window.clash = {
|
1647 |
+
launch(selector) {
|
1648 |
+
const control = new Control();
|
1649 |
+
window.clash_control = control;
|
1650 |
+
|
1651 |
+
run({selector, control});
|
1652 |
+
|
1653 |
+
return control;
|
1654 |
+
},
|
1655 |
+
};
|
1656 |
+
|
1657 |
+
|
1658 |
+
/******/ })()
|
1659 |
+
;
|