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