@woosh/meep-engine 2.110.15 → 2.111.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.
- package/build/meep.cjs +442 -370
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +442 -370
- package/editor/tools/v2/BlenderCameraOrientationGizmo.js +4 -2
- package/package.json +1 -1
- package/src/core/events/signal/Signal.d.ts.map +1 -1
- package/src/core/events/signal/Signal.js +289 -255
- package/src/core/events/signal/SignalHandler.d.ts +7 -2
- package/src/core/events/signal/SignalHandler.d.ts.map +1 -1
- package/src/core/events/signal/SignalHandler.js +12 -6
- package/src/core/events/signal/signal_handler_list_find.d.ts +8 -0
- package/src/core/events/signal/signal_handler_list_find.d.ts.map +1 -0
- package/src/core/events/signal/signal_handler_list_find.js +23 -0
- package/src/core/events/signal/signal_handler_list_last.d.ts +7 -0
- package/src/core/events/signal/signal_handler_list_last.d.ts.map +1 -0
- package/src/core/events/signal/signal_handler_list_last.js +14 -0
- package/src/core/events/signal/signal_handler_list_validate.d.ts +8 -0
- package/src/core/events/signal/signal_handler_list_validate.d.ts.map +1 -0
- package/src/core/events/signal/signal_handler_list_validate.js +29 -0
- package/src/engine/ecs/dynamic_actions/rules/DynamicRuleDescription.d.ts +2 -3
- package/src/engine/ecs/dynamic_actions/rules/DynamicRuleDescription.d.ts.map +1 -1
- package/src/engine/ecs/dynamic_actions/rules/DynamicRuleDescription.js +3 -3
- package/src/engine/graphics/ecs/camera/Camera.d.ts.map +1 -1
- package/src/engine/graphics/ecs/camera/Camera.js +2 -2
- package/src/engine/graphics/ecs/camera/CameraSystem.d.ts.map +1 -1
- package/src/engine/graphics/ecs/camera/CameraSystem.js +10 -2
- package/src/engine/graphics/ecs/camera/quaternion_invert_orientation.d.ts +7 -0
- package/src/engine/graphics/ecs/camera/quaternion_invert_orientation.d.ts.map +1 -0
- package/src/engine/graphics/ecs/camera/{InvertQuaternionOrientation.js → quaternion_invert_orientation.js} +6 -5
- package/src/engine/graphics/ecs/camera/InvertQuaternionOrientation.d.ts +0 -7
- package/src/engine/graphics/ecs/camera/InvertQuaternionOrientation.d.ts.map +0 -1
|
@@ -1,17 +1,8 @@
|
|
|
1
1
|
import { assert } from "../../assert.js";
|
|
2
|
-
import {
|
|
3
|
-
import { findSignalHandlerIndexByHandle } from "./findSignalHandlerIndexByHandle.js";
|
|
4
|
-
import { findSignalHandlerIndexByHandleAndContext } from "./findSignalHandlerIndexByHandleAndContext.js";
|
|
2
|
+
import { signal_handler_list_find } from "./signal_handler_list_find.js";
|
|
5
3
|
import { SignalFlags } from "./SignalFlags.js";
|
|
6
4
|
import { SignalHandler, SignalHandlerFlags } from "./SignalHandler.js";
|
|
7
5
|
|
|
8
|
-
/**
|
|
9
|
-
* Common dispatch stack
|
|
10
|
-
* @readonly
|
|
11
|
-
* @type {SignalHandler[]}
|
|
12
|
-
*/
|
|
13
|
-
const dispatch_stack = [];
|
|
14
|
-
let dispatch_stack_top = 0;
|
|
15
6
|
|
|
16
7
|
/**
|
|
17
8
|
* Signal is a type of event bus. You can subscribe to events using {@link add} method and dispatch using sendN method where N is the number of arguments you wish to pass
|
|
@@ -20,10 +11,11 @@ let dispatch_stack_top = 0;
|
|
|
20
11
|
*/
|
|
21
12
|
export class Signal {
|
|
22
13
|
/**
|
|
14
|
+
* Map is used to speed up lookup when removing handlers in case of large number of listeners.
|
|
23
15
|
* @private
|
|
24
|
-
* @type {SignalHandler
|
|
16
|
+
* @type {Map<function,SignalHandler>}
|
|
25
17
|
*/
|
|
26
|
-
handlers =
|
|
18
|
+
handlers = new Map();
|
|
27
19
|
|
|
28
20
|
/**
|
|
29
21
|
* Internal flag bitmask
|
|
@@ -100,9 +92,15 @@ export class Signal {
|
|
|
100
92
|
contains(handler, thisArg) {
|
|
101
93
|
const handlers = this.handlers;
|
|
102
94
|
|
|
103
|
-
const
|
|
95
|
+
const sh = handlers.get(handler);
|
|
96
|
+
|
|
97
|
+
if (sh === undefined) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
104
100
|
|
|
105
|
-
|
|
101
|
+
const existing = signal_handler_list_find(sh, handler, thisArg);
|
|
102
|
+
|
|
103
|
+
return existing !== null;
|
|
106
104
|
}
|
|
107
105
|
|
|
108
106
|
mute() {
|
|
@@ -118,7 +116,7 @@ export class Signal {
|
|
|
118
116
|
* @returns {boolean}
|
|
119
117
|
*/
|
|
120
118
|
hasHandlers() {
|
|
121
|
-
return this.handlers.
|
|
119
|
+
return this.handlers.size > 0;
|
|
122
120
|
}
|
|
123
121
|
|
|
124
122
|
/**
|
|
@@ -133,7 +131,7 @@ export class Signal {
|
|
|
133
131
|
|
|
134
132
|
handler.setFlag(SignalHandlerFlags.RemoveAfterExecution);
|
|
135
133
|
|
|
136
|
-
this
|
|
134
|
+
this.#add_handler(handler);
|
|
137
135
|
}
|
|
138
136
|
|
|
139
137
|
/**
|
|
@@ -144,15 +142,36 @@ export class Signal {
|
|
|
144
142
|
add(h, context) {
|
|
145
143
|
assert.isFunction(h, "handler");
|
|
146
144
|
|
|
147
|
-
// if (!ENV_PRODUCTION) {
|
|
148
|
-
// if (this.handlers.length + 1 === 100) {
|
|
149
|
-
// console.error(`Number of handlers has is 100 now, possible leak detected`);
|
|
150
|
-
// }
|
|
151
|
-
// }
|
|
152
|
-
|
|
153
145
|
const handler = new SignalHandler(h, context);
|
|
154
146
|
|
|
155
|
-
this
|
|
147
|
+
this.#add_handler(handler);
|
|
148
|
+
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
*
|
|
153
|
+
* @param {SignalHandler} handler
|
|
154
|
+
*/
|
|
155
|
+
#add_handler(handler) {
|
|
156
|
+
|
|
157
|
+
const f = handler.handle;
|
|
158
|
+
const first = this.handlers.get(f);
|
|
159
|
+
|
|
160
|
+
if (first === undefined) {
|
|
161
|
+
this.handlers.set(f, handler);
|
|
162
|
+
} else {
|
|
163
|
+
|
|
164
|
+
handler.next = first;
|
|
165
|
+
this.handlers.set(f,handler);
|
|
166
|
+
|
|
167
|
+
// const last = signal_handler_list_last(first);
|
|
168
|
+
|
|
169
|
+
// last.next = handler;
|
|
170
|
+
|
|
171
|
+
// assert.ok(signal_handler_list_validate(first, console.error), 'invalid configuration');
|
|
172
|
+
|
|
173
|
+
}
|
|
174
|
+
|
|
156
175
|
}
|
|
157
176
|
|
|
158
177
|
/**
|
|
@@ -164,11 +183,44 @@ export class Signal {
|
|
|
164
183
|
remove(h, thisArg) {
|
|
165
184
|
assert.isFunction(h, "handler");
|
|
166
185
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
return
|
|
186
|
+
const first = this.handlers.get(h);
|
|
187
|
+
|
|
188
|
+
if (first === undefined) {
|
|
189
|
+
return false;
|
|
171
190
|
}
|
|
191
|
+
|
|
192
|
+
if (first.handle === h && first.context === thisArg) {
|
|
193
|
+
if (first.next === null) {
|
|
194
|
+
this.handlers.delete(h);
|
|
195
|
+
} else {
|
|
196
|
+
this.handlers.set(h, first.next)
|
|
197
|
+
// assert.ok(signal_handler_list_validate(first.next, console.error), 'invalid configuration');
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
let previous = first;
|
|
204
|
+
let n = first.next;
|
|
205
|
+
|
|
206
|
+
while (n !== null) {
|
|
207
|
+
|
|
208
|
+
if (n.handle === h && n.context === thisArg) {
|
|
209
|
+
|
|
210
|
+
previous.next = n.next;
|
|
211
|
+
|
|
212
|
+
// assert.ok(signal_handler_list_validate(first, console.error), 'invalid configuration');
|
|
213
|
+
|
|
214
|
+
return true;
|
|
215
|
+
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
previous = n;
|
|
219
|
+
n = n.next;
|
|
220
|
+
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
return false;
|
|
172
224
|
}
|
|
173
225
|
|
|
174
226
|
/**
|
|
@@ -179,8 +231,58 @@ export class Signal {
|
|
|
179
231
|
* @deprecated
|
|
180
232
|
*/
|
|
181
233
|
removeAll() {
|
|
182
|
-
|
|
183
|
-
|
|
234
|
+
this.handlers.clear();
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
*
|
|
239
|
+
* @param {SignalHandler} handler
|
|
240
|
+
*/
|
|
241
|
+
#remove_handler_internal(handler) {
|
|
242
|
+
|
|
243
|
+
const first = this.handlers.get(handler.handle);
|
|
244
|
+
|
|
245
|
+
if (first === undefined) {
|
|
246
|
+
// nothing
|
|
247
|
+
return false;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// special case for first
|
|
251
|
+
if (first === handler) {
|
|
252
|
+
|
|
253
|
+
if (first.next === null) {
|
|
254
|
+
// was the only one
|
|
255
|
+
this.handlers.delete(handler.handle);
|
|
256
|
+
} else {
|
|
257
|
+
this.handlers.set(handler.handle, first.next);
|
|
258
|
+
// assert.ok(signal_handler_list_validate(first.next, console.error), 'invalid configuration');
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
return true;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
let previous = first;
|
|
265
|
+
let n = first.next;
|
|
266
|
+
|
|
267
|
+
while (n !== null) {
|
|
268
|
+
|
|
269
|
+
const next = n.next;
|
|
270
|
+
|
|
271
|
+
if (n === handler) {
|
|
272
|
+
previous.next = next;
|
|
273
|
+
|
|
274
|
+
// assert.ok(signal_handler_list_validate(first, console.error), 'invalid configuration');
|
|
275
|
+
|
|
276
|
+
return true;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
previous = n;
|
|
280
|
+
n = next;
|
|
281
|
+
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// not found
|
|
285
|
+
return false;
|
|
184
286
|
}
|
|
185
287
|
|
|
186
288
|
/**
|
|
@@ -193,10 +295,39 @@ export class Signal {
|
|
|
193
295
|
return;
|
|
194
296
|
}
|
|
195
297
|
|
|
196
|
-
|
|
298
|
+
const handlers = this.handlers;
|
|
299
|
+
|
|
300
|
+
for (const handle of handlers.values()) {
|
|
301
|
+
|
|
302
|
+
let _h = handle;
|
|
303
|
+
|
|
304
|
+
do {
|
|
305
|
+
|
|
306
|
+
const next = _h.next;
|
|
307
|
+
|
|
308
|
+
if (_h.getFlag(SignalHandlerFlags.RemoveAfterExecution)) {
|
|
309
|
+
//handler should be cut
|
|
310
|
+
this.#remove_handler_internal(_h);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
const _f = _h.handle;
|
|
314
|
+
|
|
315
|
+
try {
|
|
316
|
+
_f.apply(_h.context, args)
|
|
317
|
+
} catch (e) {
|
|
318
|
+
console.error("Failed to dispatch handler", _f, e);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
_h = next;
|
|
322
|
+
|
|
323
|
+
} while (_h !== null);
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
}
|
|
197
327
|
|
|
198
328
|
}
|
|
199
329
|
|
|
330
|
+
|
|
200
331
|
/**
|
|
201
332
|
* dispatch without a value.
|
|
202
333
|
* Allows JS engine to optimize for monomorphic call sites
|
|
@@ -209,42 +340,34 @@ export class Signal {
|
|
|
209
340
|
|
|
210
341
|
const handlers = this.handlers;
|
|
211
342
|
|
|
212
|
-
const
|
|
343
|
+
for (const handle of handlers.values()) {
|
|
213
344
|
|
|
214
|
-
|
|
215
|
-
const stack_frame_end = stack_pointer + length;
|
|
216
|
-
dispatch_stack_top = stack_frame_end;
|
|
345
|
+
let _h = handle;
|
|
217
346
|
|
|
218
|
-
|
|
347
|
+
do {
|
|
219
348
|
|
|
220
|
-
|
|
221
|
-
for (i = 0; i < length; i++) {
|
|
222
|
-
//copy to proxy
|
|
223
|
-
dispatch_stack[stack_pointer + i] = handlers[length - (i + 1)];
|
|
224
|
-
}
|
|
349
|
+
const next = _h.next;
|
|
225
350
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
351
|
+
if (_h.getFlag(SignalHandlerFlags.RemoveAfterExecution)) {
|
|
352
|
+
//handler should be cut
|
|
353
|
+
this.#remove_handler_internal(_h);
|
|
354
|
+
}
|
|
229
355
|
|
|
230
|
-
|
|
231
|
-
//handler should be cut
|
|
232
|
-
const p = handlers.indexOf(h);
|
|
233
|
-
handlers.splice(p, 1);
|
|
234
|
-
}
|
|
356
|
+
const _f = _h.handle;
|
|
235
357
|
|
|
236
|
-
|
|
358
|
+
try {
|
|
359
|
+
_f.call(_h.context)
|
|
360
|
+
} catch (e) {
|
|
361
|
+
console.error("Failed to dispatch handler", _f, e);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
_h = next;
|
|
365
|
+
|
|
366
|
+
} while (_h !== null);
|
|
237
367
|
|
|
238
|
-
try {
|
|
239
|
-
f.call(h.context)
|
|
240
|
-
} catch (e) {
|
|
241
|
-
console.error("Failed to dispatch handler", f, e);
|
|
242
|
-
}
|
|
243
368
|
|
|
244
369
|
}
|
|
245
370
|
|
|
246
|
-
//drop stack frame
|
|
247
|
-
dispatch_stack_top = stack_pointer;
|
|
248
371
|
}
|
|
249
372
|
|
|
250
373
|
/**
|
|
@@ -260,43 +383,34 @@ export class Signal {
|
|
|
260
383
|
|
|
261
384
|
const handlers = this.handlers;
|
|
262
385
|
|
|
263
|
-
const
|
|
386
|
+
for (const handle of handlers.values()) {
|
|
264
387
|
|
|
265
|
-
|
|
266
|
-
const stack_frame_end = stack_pointer + length;
|
|
267
|
-
dispatch_stack_top = stack_frame_end;
|
|
388
|
+
let _h = handle;
|
|
268
389
|
|
|
390
|
+
do {
|
|
269
391
|
|
|
270
|
-
|
|
392
|
+
const next = _h.next;
|
|
271
393
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
}
|
|
394
|
+
if (_h.getFlag(SignalHandlerFlags.RemoveAfterExecution)) {
|
|
395
|
+
//handler should be cut
|
|
396
|
+
this.#remove_handler_internal(_h);
|
|
397
|
+
}
|
|
277
398
|
|
|
278
|
-
|
|
279
|
-
for (i = stack_frame_end - 1; i >= stack_pointer; i--) {
|
|
280
|
-
h = dispatch_stack[i];
|
|
399
|
+
const _f = _h.handle;
|
|
281
400
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
401
|
+
try {
|
|
402
|
+
_f.call(_h.context, arg)
|
|
403
|
+
} catch (e) {
|
|
404
|
+
console.error("Failed to dispatch handler", _f, e);
|
|
405
|
+
}
|
|
287
406
|
|
|
288
|
-
|
|
407
|
+
_h = next;
|
|
408
|
+
|
|
409
|
+
} while (_h !== null);
|
|
289
410
|
|
|
290
|
-
try {
|
|
291
|
-
f.call(h.context, arg)
|
|
292
|
-
} catch (e) {
|
|
293
|
-
console.error("Failed to dispatch handler", f, e);
|
|
294
|
-
}
|
|
295
411
|
|
|
296
412
|
}
|
|
297
413
|
|
|
298
|
-
//drop stack frame
|
|
299
|
-
dispatch_stack_top = stack_pointer;
|
|
300
414
|
}
|
|
301
415
|
|
|
302
416
|
/**
|
|
@@ -312,42 +426,33 @@ export class Signal {
|
|
|
312
426
|
|
|
313
427
|
const handlers = this.handlers;
|
|
314
428
|
|
|
315
|
-
const
|
|
429
|
+
for (const handle of handlers.values()) {
|
|
316
430
|
|
|
317
|
-
|
|
318
|
-
const stack_frame_end = stack_pointer + length;
|
|
319
|
-
dispatch_stack_top = stack_frame_end;
|
|
431
|
+
let _h = handle;
|
|
320
432
|
|
|
321
|
-
|
|
433
|
+
do {
|
|
322
434
|
|
|
323
|
-
|
|
324
|
-
for (i = 0; i < length; i++) {
|
|
325
|
-
//copy to proxy
|
|
326
|
-
dispatch_stack[stack_pointer + i] = handlers[length - (i + 1)];
|
|
327
|
-
}
|
|
435
|
+
const next = _h.next;
|
|
328
436
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
437
|
+
if (_h.getFlag(SignalHandlerFlags.RemoveAfterExecution)) {
|
|
438
|
+
//handler should be cut
|
|
439
|
+
this.#remove_handler_internal(_h);
|
|
440
|
+
}
|
|
332
441
|
|
|
333
|
-
|
|
334
|
-
//handler should be cut
|
|
335
|
-
const p = handlers.indexOf(h);
|
|
336
|
-
handlers.splice(p, 1);
|
|
337
|
-
}
|
|
442
|
+
const _f = _h.handle;
|
|
338
443
|
|
|
339
|
-
|
|
444
|
+
try {
|
|
445
|
+
_f.call(_h.context, a, b)
|
|
446
|
+
} catch (e) {
|
|
447
|
+
console.error("Failed to dispatch handler", _f, e);
|
|
448
|
+
}
|
|
340
449
|
|
|
341
|
-
|
|
342
|
-
f.call(h.context, a, b)
|
|
343
|
-
} catch (e) {
|
|
344
|
-
console.error("Failed to dispatch handler", f, e);
|
|
345
|
-
}
|
|
450
|
+
_h = next;
|
|
346
451
|
|
|
347
|
-
|
|
452
|
+
} while (_h !== null);
|
|
348
453
|
|
|
349
|
-
|
|
350
|
-
|
|
454
|
+
|
|
455
|
+
}
|
|
351
456
|
}
|
|
352
457
|
|
|
353
458
|
/**
|
|
@@ -362,44 +467,36 @@ export class Signal {
|
|
|
362
467
|
return;
|
|
363
468
|
}
|
|
364
469
|
|
|
470
|
+
|
|
365
471
|
const handlers = this.handlers;
|
|
366
472
|
|
|
367
|
-
const
|
|
473
|
+
for (const handle of handlers.values()) {
|
|
368
474
|
|
|
369
|
-
|
|
370
|
-
const stack_frame_end = stack_pointer + length;
|
|
371
|
-
dispatch_stack_top = stack_frame_end;
|
|
475
|
+
let _h = handle;
|
|
372
476
|
|
|
373
|
-
|
|
477
|
+
do {
|
|
374
478
|
|
|
375
|
-
|
|
376
|
-
for (i = 0; i < length; i++) {
|
|
377
|
-
//copy to proxy
|
|
378
|
-
dispatch_stack[stack_pointer + i] = handlers[length - (i + 1)];
|
|
379
|
-
}
|
|
479
|
+
const next = _h.next;
|
|
380
480
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
481
|
+
if (_h.getFlag(SignalHandlerFlags.RemoveAfterExecution)) {
|
|
482
|
+
//handler should be cut
|
|
483
|
+
this.#remove_handler_internal(_h);
|
|
484
|
+
}
|
|
384
485
|
|
|
385
|
-
|
|
386
|
-
//handler should be cut
|
|
387
|
-
const p = handlers.indexOf(h);
|
|
388
|
-
handlers.splice(p, 1);
|
|
389
|
-
}
|
|
486
|
+
const _f = _h.handle;
|
|
390
487
|
|
|
391
|
-
|
|
488
|
+
try {
|
|
489
|
+
_f.call(_h.context, a, b, c)
|
|
490
|
+
} catch (e) {
|
|
491
|
+
console.error("Failed to dispatch handler", _f, e);
|
|
492
|
+
}
|
|
392
493
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
}
|
|
396
|
-
console.error("Failed to dispatch handler", f, e);
|
|
397
|
-
}
|
|
494
|
+
_h = next;
|
|
495
|
+
|
|
496
|
+
} while (_h !== null);
|
|
398
497
|
|
|
399
|
-
}
|
|
400
498
|
|
|
401
|
-
|
|
402
|
-
dispatch_stack_top = stack_pointer;
|
|
499
|
+
}
|
|
403
500
|
}
|
|
404
501
|
|
|
405
502
|
/**
|
|
@@ -415,44 +512,36 @@ export class Signal {
|
|
|
415
512
|
return;
|
|
416
513
|
}
|
|
417
514
|
|
|
515
|
+
|
|
418
516
|
const handlers = this.handlers;
|
|
419
517
|
|
|
420
|
-
const
|
|
518
|
+
for (const handle of handlers.values()) {
|
|
421
519
|
|
|
422
|
-
|
|
423
|
-
const stack_frame_end = stack_pointer + length;
|
|
424
|
-
dispatch_stack_top = stack_frame_end;
|
|
520
|
+
let _h = handle;
|
|
425
521
|
|
|
426
|
-
|
|
522
|
+
do {
|
|
427
523
|
|
|
428
|
-
|
|
429
|
-
for (i = 0; i < length; i++) {
|
|
430
|
-
//copy to proxy
|
|
431
|
-
dispatch_stack[stack_pointer + i] = handlers[length - (i + 1)];
|
|
432
|
-
}
|
|
524
|
+
const next = _h.next;
|
|
433
525
|
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
526
|
+
if (_h.getFlag(SignalHandlerFlags.RemoveAfterExecution)) {
|
|
527
|
+
//handler should be cut
|
|
528
|
+
this.#remove_handler_internal(_h);
|
|
529
|
+
}
|
|
437
530
|
|
|
438
|
-
|
|
439
|
-
//handler should be cut
|
|
440
|
-
const p = handlers.indexOf(h);
|
|
441
|
-
handlers.splice(p, 1);
|
|
442
|
-
}
|
|
531
|
+
const _f = _h.handle;
|
|
443
532
|
|
|
444
|
-
|
|
533
|
+
try {
|
|
534
|
+
_f.call(_h.context, a, b, c, d)
|
|
535
|
+
} catch (e) {
|
|
536
|
+
console.error("Failed to dispatch handler", _f, e);
|
|
537
|
+
}
|
|
445
538
|
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
}
|
|
449
|
-
console.error("Failed to dispatch handler", f, e);
|
|
450
|
-
}
|
|
539
|
+
_h = next;
|
|
540
|
+
|
|
541
|
+
} while (_h !== null);
|
|
451
542
|
|
|
452
|
-
}
|
|
453
543
|
|
|
454
|
-
|
|
455
|
-
dispatch_stack_top = stack_pointer;
|
|
544
|
+
}
|
|
456
545
|
}
|
|
457
546
|
|
|
458
547
|
/**
|
|
@@ -470,44 +559,36 @@ export class Signal {
|
|
|
470
559
|
return;
|
|
471
560
|
}
|
|
472
561
|
|
|
562
|
+
|
|
473
563
|
const handlers = this.handlers;
|
|
474
564
|
|
|
475
|
-
const
|
|
565
|
+
for (const handle of handlers.values()) {
|
|
476
566
|
|
|
477
|
-
|
|
478
|
-
const stack_frame_end = stack_pointer + length;
|
|
479
|
-
dispatch_stack_top = stack_frame_end;
|
|
567
|
+
let _h = handle;
|
|
480
568
|
|
|
481
|
-
|
|
569
|
+
do {
|
|
482
570
|
|
|
483
|
-
|
|
484
|
-
for (i = 0; i < length; i++) {
|
|
485
|
-
//copy to proxy
|
|
486
|
-
dispatch_stack[stack_pointer + i] = handlers[length - (i + 1)];
|
|
487
|
-
}
|
|
571
|
+
const next = _h.next;
|
|
488
572
|
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
573
|
+
if (_h.getFlag(SignalHandlerFlags.RemoveAfterExecution)) {
|
|
574
|
+
//handler should be cut
|
|
575
|
+
this.#remove_handler_internal(_h);
|
|
576
|
+
}
|
|
492
577
|
|
|
493
|
-
|
|
494
|
-
//handler should be cut
|
|
495
|
-
const p = handlers.indexOf(h);
|
|
496
|
-
handlers.splice(p, 1);
|
|
497
|
-
}
|
|
578
|
+
const _f = _h.handle;
|
|
498
579
|
|
|
499
|
-
|
|
580
|
+
try {
|
|
581
|
+
_f.call(_h.context, a, b, c, d, e, f)
|
|
582
|
+
} catch (e) {
|
|
583
|
+
console.error("Failed to dispatch handler", f, e);
|
|
584
|
+
}
|
|
500
585
|
|
|
501
|
-
|
|
502
|
-
handle.call(h.context, a, b, c, d, e, f)
|
|
503
|
-
} catch (e) {
|
|
504
|
-
console.error("Failed to dispatch handler", handle, e);
|
|
505
|
-
}
|
|
586
|
+
_h = next;
|
|
506
587
|
|
|
507
|
-
|
|
588
|
+
} while (_h !== null);
|
|
508
589
|
|
|
509
|
-
|
|
510
|
-
|
|
590
|
+
|
|
591
|
+
}
|
|
511
592
|
}
|
|
512
593
|
|
|
513
594
|
/**
|
|
@@ -529,42 +610,33 @@ export class Signal {
|
|
|
529
610
|
|
|
530
611
|
const handlers = this.handlers;
|
|
531
612
|
|
|
532
|
-
const
|
|
613
|
+
for (const handle of handlers.values()) {
|
|
533
614
|
|
|
534
|
-
|
|
535
|
-
const stack_frame_end = stack_pointer + length;
|
|
536
|
-
dispatch_stack_top = stack_frame_end;
|
|
615
|
+
let _h = handle;
|
|
537
616
|
|
|
538
|
-
|
|
617
|
+
do {
|
|
539
618
|
|
|
540
|
-
|
|
541
|
-
for (i = 0; i < length; i++) {
|
|
542
|
-
//copy to proxy
|
|
543
|
-
dispatch_stack[stack_pointer + i] = handlers[length - (i + 1)];
|
|
544
|
-
}
|
|
619
|
+
const next = _h.next;
|
|
545
620
|
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
621
|
+
if (_h.getFlag(SignalHandlerFlags.RemoveAfterExecution)) {
|
|
622
|
+
//handler should be cut
|
|
623
|
+
this.#remove_handler_internal(_h);
|
|
624
|
+
}
|
|
549
625
|
|
|
550
|
-
|
|
551
|
-
//handler should be cut
|
|
552
|
-
const p = handlers.indexOf(handler);
|
|
553
|
-
handlers.splice(p, 1);
|
|
554
|
-
}
|
|
626
|
+
const _f = _h.handle;
|
|
555
627
|
|
|
556
|
-
|
|
628
|
+
try {
|
|
629
|
+
_f.call(_h.context, a, b, c, d, e, f, g, h)
|
|
630
|
+
} catch (e) {
|
|
631
|
+
console.error("Failed to dispatch handler", f, e);
|
|
632
|
+
}
|
|
557
633
|
|
|
558
|
-
|
|
559
|
-
handle.call(handler.context, a, b, c, d, e, f, g, h)
|
|
560
|
-
} catch (e) {
|
|
561
|
-
console.error("Failed to dispatch handler", handle, e);
|
|
562
|
-
}
|
|
634
|
+
_h = next;
|
|
563
635
|
|
|
564
|
-
|
|
636
|
+
} while (_h !== null);
|
|
565
637
|
|
|
566
|
-
|
|
567
|
-
|
|
638
|
+
|
|
639
|
+
}
|
|
568
640
|
}
|
|
569
641
|
|
|
570
642
|
/**
|
|
@@ -593,42 +665,4 @@ export class Signal {
|
|
|
593
665
|
*/
|
|
594
666
|
Signal.prototype.isSignal = true;
|
|
595
667
|
|
|
596
|
-
/**
|
|
597
|
-
*
|
|
598
|
-
* @param {Signal} signal
|
|
599
|
-
* @param {function} h
|
|
600
|
-
* @returns {boolean}
|
|
601
|
-
*/
|
|
602
|
-
function removeHandlerByHandler(signal, h) {
|
|
603
|
-
const handlers = signal.handlers;
|
|
604
|
-
let i = findSignalHandlerIndexByHandle(handlers, h);
|
|
605
|
-
|
|
606
|
-
if (i >= 0) {
|
|
607
|
-
handlers.splice(i, 1);
|
|
608
|
-
return true;
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
return false;
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
/**
|
|
615
|
-
*
|
|
616
|
-
* @param {Signal} signal
|
|
617
|
-
* @param {function} h
|
|
618
|
-
* @param {*} ctx
|
|
619
|
-
* @returns {boolean}
|
|
620
|
-
*/
|
|
621
|
-
function removeHandlerByHandlerAndContext(signal, h, ctx) {
|
|
622
|
-
const handlers = signal.handlers;
|
|
623
|
-
const i = findSignalHandlerIndexByHandleAndContext(handlers, h, ctx);
|
|
624
|
-
|
|
625
|
-
if (i >= 0) {
|
|
626
|
-
handlers.splice(i, 1);
|
|
627
|
-
return true;
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
return false;
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
|
|
634
668
|
export default Signal;
|