@nativescript/canvas 2.0.0-rc.5 → 2.0.0-rc.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/Canvas/common.d.ts +7 -4
  2. package/Canvas/common.js +260 -194
  3. package/Canvas/common.js.map +1 -1
  4. package/Canvas/index.ios.js.map +1 -1
  5. package/TextDecoder/index.d.ts +1 -0
  6. package/TextDecoder/index.js +17 -0
  7. package/TextDecoder/index.js.map +1 -1
  8. package/WebGPU/GPUDevice.js +2 -2
  9. package/WebGPU/GPUDevice.js.map +1 -1
  10. package/angular/esm2022/index.mjs +4 -4
  11. package/angular/fesm2022/nativescript-canvas-angular.mjs +4 -4
  12. package/helpers.d.ts +3 -0
  13. package/helpers.js +9 -0
  14. package/helpers.js.map +1 -1
  15. package/package.json +1 -1
  16. package/platforms/android/canvas-release.aar +0 -0
  17. package/platforms/ios/CanvasNative.xcframework/Info.plist +5 -5
  18. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/CanvasNative +0 -0
  19. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Headers/canvas_native.h +10 -0
  20. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
  21. package/platforms/ios/CanvasNative.xcframework/ios-arm64/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios.abi.json +11881 -10901
  22. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  23. package/platforms/ios/CanvasNative.xcframework/ios-arm64/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +994 -994
  24. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/CanvasNative +0 -0
  25. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Headers/canvas_native.h +10 -0
  26. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
  27. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/Project/x86_64-apple-ios-simulator.swiftsourceinfo +0 -0
  28. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/arm64-apple-ios-simulator.abi.json +11881 -10901
  29. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/Modules/CanvasNative.swiftmodule/x86_64-apple-ios-simulator.abi.json +11881 -10901
  30. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/CanvasNative.framework/_CodeSignature/CodeResources +10 -10
  31. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/DWARF/CanvasNative +0 -0
  32. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/aarch64/CanvasNative.yml +993 -993
  33. package/platforms/ios/CanvasNative.xcframework/ios-arm64_x86_64-simulator/dSYMs/CanvasNative.framework.dSYM/Contents/Resources/Relocations/x86_64/CanvasNative.yml +1037 -1037
  34. package/platforms/ios/src/cpp/CanvasJSIModule.cpp +172 -2
  35. package/platforms/ios/src/cpp/CanvasJSIModule.h +6 -0
  36. package/platforms/ios/src/cpp/Helpers.h +44 -0
  37. package/platforms/ios/src/cpp/PromiseCallback.h +42 -20
  38. package/platforms/ios/src/cpp/TextDecoderImpl.cpp +142 -0
  39. package/platforms/ios/src/cpp/TextDecoderImpl.h +2 -0
  40. package/platforms/ios/src/cpp/webgpu/GPUQueueImpl.cpp +1 -0
package/Canvas/common.js CHANGED
@@ -34,12 +34,17 @@ export class Event {
34
34
  this.type = type;
35
35
  this.bubbles = options?.bubbles ?? false;
36
36
  this.cancelable = options?.cancelable ?? false;
37
- this.cancelable = options?.cancelable ?? false;
38
37
  this.composed = options?.composed ?? false;
39
38
  this.target = options?.target ?? null;
39
+ this._preventDefault = options?.preventDefault;
40
+ this._stopPropagation = options?.stopPropagation;
41
+ }
42
+ preventDefault() {
43
+ this._preventDefault?.();
44
+ }
45
+ stopPropagation() {
46
+ this._stopPropagation?.();
40
47
  }
41
- preventDefault() { }
42
- stopPropagation() { }
43
48
  }
44
49
  export class UIEvent extends Event {
45
50
  constructor(type, options) {
@@ -85,8 +90,6 @@ export class PointerEvent extends MouseEvent {
85
90
  this.twist = options?.twist ?? 0;
86
91
  this.isPrimary = options?.isPrimary ?? false;
87
92
  }
88
- preventDefault() { }
89
- stopPropagation() { }
90
93
  }
91
94
  export class Touch {
92
95
  constructor(options) {
@@ -188,7 +191,7 @@ let CanvasBase = class CanvasBase extends View {
188
191
  this._touchCancelCallbacks = new Array();
189
192
  this._touches = [];
190
193
  this._touchesById = [];
191
- this._lastPointerEventById = [];
194
+ this._lastPointerEventById = new Map();
192
195
  this.__target = null;
193
196
  this._classList = new Set();
194
197
  this.style.width = { unit: '%', value: 1 };
@@ -327,19 +330,13 @@ let CanvasBase = class CanvasBase extends View {
327
330
  _moveCallback(pointers) {
328
331
  const hasPointerCallbacks = this._pointerMoveCallbacks.length > 0;
329
332
  const hasMouseCallbacks = this._mouseMoveCallbacks.length > 0;
330
- if (hasPointerCallbacks || hasMouseCallbacks) {
333
+ const hasTouchCallbacks = this._touchMoveCallbacks.length > 0;
334
+ if (hasPointerCallbacks || hasMouseCallbacks || hasTouchCallbacks) {
335
+ let preventDefault = false;
336
+ const changedTouches = hasTouchCallbacks ? TouchList.empty() : null;
331
337
  for (const pointer of pointers) {
332
338
  const pointerId = pointer.ptrId;
333
- const index = this._lastPointerEventById.findIndex((item) => {
334
- return item?.pointerId === pointerId;
335
- });
336
- let previousEvent;
337
- if (index > -1) {
338
- previousEvent = this._lastPointerEventById[index];
339
- }
340
- else {
341
- previousEvent = { pointerId, x: 0, y: 0 };
342
- }
339
+ const previousEvent = this._lastPointerEventById.get(pointerId) ?? { pointerId, x: 0, y: 0 };
343
340
  if (hasPointerCallbacks) {
344
341
  const event = new PointerEvent('pointermove', {
345
342
  pointerType: 'touch',
@@ -355,12 +352,47 @@ let CanvasBase = class CanvasBase extends View {
355
352
  isPrimary: pointer.isPrimary,
356
353
  button: -1,
357
354
  target: this.__target ?? this,
355
+ preventDefault: () => {
356
+ preventDefault = true;
357
+ },
358
358
  });
359
359
  for (const callback of this._pointerMoveCallbacks) {
360
360
  callback(event);
361
361
  }
362
362
  }
363
- if (hasMouseCallbacks) {
363
+ if (!preventDefault && hasTouchCallbacks) {
364
+ changedTouches.push(new Touch({
365
+ identifier: pointer.ptrId,
366
+ target: this.__target ?? this,
367
+ clientX: pointer.x,
368
+ clientY: pointer.y,
369
+ screenX: pointer.x,
370
+ screenY: pointer.y,
371
+ pageX: pointer.x,
372
+ pageY: pointer.y,
373
+ }));
374
+ }
375
+ this._lastPointerEventById.set(pointerId, { pointerId, x: pointer.x, y: pointer.y });
376
+ }
377
+ if ((changedTouches?.length ?? 0) > 0) {
378
+ const touches = TouchList.fromList(this._touches);
379
+ const event = new TouchEvent('touchmove', {
380
+ touches,
381
+ targetTouches: touches,
382
+ changedTouches,
383
+ target: this.__target ?? this,
384
+ preventDefault: () => {
385
+ preventDefault = true;
386
+ },
387
+ });
388
+ for (const callback of this._touchMoveCallbacks) {
389
+ callback(event);
390
+ }
391
+ }
392
+ if (!preventDefault && hasMouseCallbacks) {
393
+ for (const pointer of pointers) {
394
+ const pointerId = pointer.ptrId;
395
+ const previousEvent = this._lastPointerEventById.get(pointerId) ?? { pointerId, x: 0, y: 0 };
364
396
  const event = new MouseEvent('mousemove', {
365
397
  clientX: pointer.x,
366
398
  clientY: pointer.y,
@@ -372,48 +404,24 @@ let CanvasBase = class CanvasBase extends View {
372
404
  movementY: pointer.y - previousEvent.y,
373
405
  button: -1,
374
406
  target: this.__target ?? this,
407
+ preventDefault: () => {
408
+ preventDefault = true;
409
+ },
375
410
  });
376
- // todo emit mousemove when desktop is supported
377
- // for (const callback of this._mouseMoveCallbacks) {
378
- // callback(event);
379
- // }
380
- }
381
- if (index > -1) {
382
- this._lastPointerEventById[index] = { pointerId, x: pointer.x, y: pointer.y };
411
+ for (const callback of this._mouseMoveCallbacks) {
412
+ callback(event);
413
+ }
383
414
  }
384
415
  }
385
416
  }
386
- if (this._touchMoveCallbacks.length > 0) {
387
- const changedTouches = TouchList.empty();
388
- for (const pointer of pointers) {
389
- changedTouches.push(new Touch({
390
- identifier: pointer.ptrId,
391
- target: this.__target ?? this,
392
- clientX: pointer.x,
393
- clientY: pointer.y,
394
- screenX: pointer.x,
395
- screenY: pointer.y,
396
- pageX: pointer.x,
397
- pageY: pointer.y,
398
- }));
399
- }
400
- const touches = TouchList.fromList(this._touches);
401
- const event = new TouchEvent('touchmove', {
402
- touches,
403
- targetTouches: touches,
404
- changedTouches,
405
- target: this.__target ?? this,
406
- });
407
- for (const callback of this._touchMoveCallbacks) {
408
- callback(event);
409
- }
410
- }
411
417
  }
412
418
  _upCallback(ptrId, x, y, isPrimary = false) {
413
419
  const hasPointerCallbacks = this._pointerUpCallbacks.length > 0 || this._pointerOutCallbacks.length > 0 || this._pointerLeaveCallbacks.length > 0;
414
420
  const hasMouseCallbacks = this._mouseUpCallbacks.length > 0;
415
- if (hasPointerCallbacks || hasMouseCallbacks) {
416
- const pointerId = ptrId;
421
+ const hasTouchCallbacks = this._touchEndCallbacks.length > 0;
422
+ const pointerId = ptrId;
423
+ if (hasPointerCallbacks || hasMouseCallbacks || hasTouchCallbacks) {
424
+ let preventDefault = false;
417
425
  if (hasPointerCallbacks) {
418
426
  const up = new PointerEvent('pointerup', {
419
427
  pointerType: 'touch',
@@ -426,6 +434,9 @@ let CanvasBase = class CanvasBase extends View {
426
434
  pageX: x,
427
435
  pageY: y,
428
436
  target: this.__target ?? this,
437
+ preventDefault: () => {
438
+ preventDefault = true;
439
+ },
429
440
  });
430
441
  const out = new PointerEvent('pointerout', {
431
442
  pointerType: 'touch',
@@ -461,7 +472,34 @@ let CanvasBase = class CanvasBase extends View {
461
472
  callback(leave);
462
473
  }
463
474
  }
464
- if (hasMouseCallbacks) {
475
+ if (hasTouchCallbacks && !preventDefault) {
476
+ const touches = TouchList.fromList(this._touches);
477
+ const changedTouches = TouchList.fromList([
478
+ new Touch({
479
+ identifier: ptrId,
480
+ target: this.__target ?? this,
481
+ clientX: x,
482
+ clientY: y,
483
+ screenX: x,
484
+ screenY: y,
485
+ pageX: x,
486
+ pageY: y,
487
+ }),
488
+ ]);
489
+ const event = new TouchEvent('touchend', {
490
+ touches,
491
+ targetTouches: touches,
492
+ changedTouches,
493
+ target: this.__target ?? this,
494
+ preventDefault: () => {
495
+ preventDefault = true;
496
+ },
497
+ });
498
+ for (const callback of this._touchEndCallbacks) {
499
+ callback(event);
500
+ }
501
+ }
502
+ if (hasMouseCallbacks && !preventDefault) {
465
503
  const event = new MouseEvent('mouseup', {
466
504
  clientX: x,
467
505
  clientY: y,
@@ -470,17 +508,13 @@ let CanvasBase = class CanvasBase extends View {
470
508
  pageX: x,
471
509
  pageY: y,
472
510
  target: this.__target ?? this,
511
+ preventDefault: () => {
512
+ preventDefault = true;
513
+ },
473
514
  });
474
- // todo emit mouseup when desktop is supported
475
- // for (const callback of this._mouseUpCallbacks) {
476
- // callback(event);
477
- // }
478
- }
479
- const index = this._lastPointerEventById.findIndex((item) => {
480
- return item?.pointerId === pointerId;
481
- });
482
- if (index > -1) {
483
- this._lastPointerEventById.splice(index, 1);
515
+ for (const callback of this._mouseUpCallbacks) {
516
+ callback(event);
517
+ }
484
518
  }
485
519
  }
486
520
  const length = this._touches.length;
@@ -490,35 +524,14 @@ let CanvasBase = class CanvasBase extends View {
490
524
  break;
491
525
  }
492
526
  }
493
- if (this._touchEndCallbacks.length > 0) {
494
- const touches = TouchList.fromList(this._touches);
495
- const changedTouches = TouchList.fromList([
496
- new Touch({
497
- identifier: ptrId,
498
- target: this.__target ?? this,
499
- clientX: x,
500
- clientY: y,
501
- screenX: x,
502
- screenY: y,
503
- pageX: x,
504
- pageY: y,
505
- }),
506
- ]);
507
- const event = new TouchEvent('touchend', {
508
- touches,
509
- targetTouches: touches,
510
- changedTouches,
511
- target: this.__target ?? this,
512
- });
513
- for (const callback of this._touchEndCallbacks) {
514
- callback(event);
515
- }
516
- }
527
+ this._lastPointerEventById.delete(pointerId);
517
528
  }
518
529
  _downCallback(ptrId, x, y, isPrimary = false) {
519
530
  const hasPointerCallbacks = this._pointerDownCallbacks.length > 0;
520
531
  const hasMouseCallbacks = this._mouseDownCallbacks.length > 0;
521
- if (hasPointerCallbacks || hasMouseCallbacks) {
532
+ const hasTouchCallbacks = this._touchStartCallbacks.length > 0;
533
+ if (hasPointerCallbacks || hasMouseCallbacks || hasTouchCallbacks) {
534
+ let preventDefault = false;
522
535
  const pointerId = ptrId;
523
536
  if (hasPointerCallbacks) {
524
537
  const event = new PointerEvent('pointerdown', {
@@ -532,57 +545,67 @@ let CanvasBase = class CanvasBase extends View {
532
545
  pageX: x,
533
546
  pageY: y,
534
547
  target: this.__target ?? this,
548
+ preventDefault: () => {
549
+ preventDefault = true;
550
+ },
535
551
  });
536
552
  for (const callback of this._pointerDownCallbacks) {
537
553
  callback(event);
538
554
  }
539
555
  }
540
- if (hasMouseCallbacks) {
541
- const event = new MouseEvent('mousedown', {
556
+ if (hasTouchCallbacks && !preventDefault) {
557
+ const touch = new Touch({
558
+ identifier: ptrId,
559
+ target: this.__target ?? this,
542
560
  clientX: x,
543
561
  clientY: y,
544
562
  screenX: x,
545
563
  screenY: y,
546
564
  pageX: x,
547
565
  pageY: y,
566
+ });
567
+ this._touches.push(touch);
568
+ this._touchesById[ptrId] = touch;
569
+ const touches = TouchList.fromList(this._touches);
570
+ const touchEvent = new TouchEvent('touchstart', {
571
+ touches,
572
+ targetTouches: touches,
573
+ changedTouches: this._touches,
548
574
  target: this.__target ?? this,
575
+ preventDefault: () => {
576
+ preventDefault = true;
577
+ },
549
578
  });
550
- // todo emit mousedown when desktop is supported
551
- // for (const callback of this._mouseDownCallbacks) {
552
- // callback(event);
553
- // }
579
+ for (const callback of this._touchStartCallbacks) {
580
+ callback(touchEvent);
581
+ }
554
582
  }
555
- this._lastPointerEventById.push({ pointerId, x, y });
556
- }
557
- if (this._touchStartCallbacks.length > 0) {
558
- const touch = new Touch({
559
- identifier: ptrId,
560
- target: this.__target ?? this,
561
- clientX: x,
562
- clientY: y,
563
- screenX: x,
564
- screenY: y,
565
- pageX: x,
566
- pageY: y,
567
- });
568
- this._touches.push(touch);
569
- this._touchesById[ptrId] = touch;
570
- const touches = TouchList.fromList(this._touches);
571
- const touchEvent = new TouchEvent('touchstart', {
572
- touches,
573
- targetTouches: touches,
574
- changedTouches: this._touches,
575
- target: this.__target ?? this,
576
- });
577
- for (const callback of this._touchStartCallbacks) {
578
- callback(touchEvent);
583
+ if (hasMouseCallbacks && !preventDefault) {
584
+ const event = new MouseEvent('mousedown', {
585
+ clientX: x,
586
+ clientY: y,
587
+ screenX: x,
588
+ screenY: y,
589
+ pageX: x,
590
+ pageY: y,
591
+ target: this.__target ?? this,
592
+ preventDefault: () => {
593
+ preventDefault = true;
594
+ },
595
+ });
596
+ for (const callback of this._mouseDownCallbacks) {
597
+ callback(event);
598
+ }
579
599
  }
600
+ this._lastPointerEventById.set(pointerId, { pointerId, x, y });
580
601
  }
581
602
  }
582
603
  _cancelCallback(ptrId, x, y, isPrimary = false) {
583
604
  const hasPointerCallbacks = this._pointerCancelCallbacks.length > 0;
584
605
  const hasMouseCallbacks = this._mouseCancelCallbacks.length > 0;
585
- if (hasPointerCallbacks || hasMouseCallbacks) {
606
+ const hasTouchCallbacks = this._touchCancelCallbacks.length > 0;
607
+ if (hasPointerCallbacks || hasMouseCallbacks || hasTouchCallbacks) {
608
+ let preventDefault = false;
586
609
  const pointerId = ptrId;
587
610
  if (hasPointerCallbacks) {
588
611
  const event = new PointerEvent('pointercancel', {
@@ -596,51 +619,60 @@ let CanvasBase = class CanvasBase extends View {
596
619
  pageY: y,
597
620
  isPrimary,
598
621
  target: this.__target ?? this,
622
+ preventDefault: () => {
623
+ preventDefault = true;
624
+ },
599
625
  });
600
626
  for (const callback of this._pointerCancelCallbacks) {
601
627
  callback(event);
602
628
  }
603
629
  }
604
- if (hasMouseCallbacks) {
605
- const event = new MouseEvent('mouseout', {
630
+ if (hasTouchCallbacks && !preventDefault) {
631
+ const touch = new Touch({
632
+ identifier: ptrId,
633
+ target: this.__target ?? this,
606
634
  clientX: x,
607
635
  clientY: y,
608
636
  screenX: x,
609
637
  screenY: y,
610
638
  pageX: x,
611
639
  pageY: y,
640
+ });
641
+ const touchesList = [touch];
642
+ const touchesById = [];
643
+ touchesById[ptrId] = touch;
644
+ const touches = TouchList.fromList(touchesList);
645
+ const touchEvent = new TouchEvent('touchcancel', {
646
+ touches,
647
+ targetTouches: touches,
648
+ changedTouches: touchesList,
612
649
  target: this.__target ?? this,
650
+ preventDefault: () => {
651
+ preventDefault = true;
652
+ },
613
653
  });
614
- // todo emit mouseout when desktop is supported
615
- // for (const callback of this._mouseCancelCallbacks) {
616
- // callback(event);
617
- // }
654
+ for (const callback of this._touchCancelCallbacks) {
655
+ callback(touchEvent);
656
+ }
618
657
  }
619
- }
620
- if (this._touchCancelCallbacks.length > 0) {
621
- const touch = new Touch({
622
- identifier: ptrId,
623
- target: this.__target ?? this,
624
- clientX: x,
625
- clientY: y,
626
- screenX: x,
627
- screenY: y,
628
- pageX: x,
629
- pageY: y,
630
- });
631
- const touchesList = [touch];
632
- const touchesById = [];
633
- touchesById[ptrId] = touch;
634
- const touches = TouchList.fromList(touchesList);
635
- const touchEvent = new TouchEvent('touchcancel', {
636
- touches,
637
- targetTouches: touches,
638
- changedTouches: touchesList,
639
- target: this.__target ?? this,
640
- });
641
- for (const callback of this._touchCancelCallbacks) {
642
- callback(touchEvent);
658
+ if (hasMouseCallbacks && !preventDefault) {
659
+ const event = new MouseEvent('mouseout', {
660
+ clientX: x,
661
+ clientY: y,
662
+ screenX: x,
663
+ screenY: y,
664
+ pageX: x,
665
+ pageY: y,
666
+ target: this.__target ?? this,
667
+ preventDefault: () => {
668
+ preventDefault = true;
669
+ },
670
+ });
671
+ for (const callback of this._mouseCancelCallbacks) {
672
+ callback(event);
673
+ }
643
674
  }
675
+ this._lastPointerEventById.set(pointerId, { pointerId, x, y });
644
676
  }
645
677
  }
646
678
  _pinchCallback(data) {
@@ -648,19 +680,13 @@ let CanvasBase = class CanvasBase extends View {
648
680
  const hasPointerCallbacks = this._pointerMoveCallbacks.length > 0;
649
681
  const hasMouseCallbacks = this._mouseMoveCallbacks.length > 0;
650
682
  const hasMouseWheel = this._mouseWheelCallbacks.length > 0;
651
- if (hasPointerCallbacks || hasMouseCallbacks || hasMouseWheel) {
683
+ const hasTouchCallbacks = this._touchMoveCallbacks.length > 0;
684
+ if (hasPointerCallbacks || hasMouseCallbacks || hasMouseWheel || hasTouchCallbacks) {
685
+ const changedTouches = hasTouchCallbacks ? TouchList.empty() : null;
686
+ let preventDefault = false;
652
687
  for (const pointer of data.pointers) {
653
688
  const pointerId = pointer.ptrId;
654
- const index = this._lastPointerEventById.findIndex((item) => {
655
- return item?.pointerId === pointerId;
656
- });
657
- let previousEvent;
658
- if (index > -1) {
659
- previousEvent = this._lastPointerEventById[index];
660
- }
661
- else {
662
- previousEvent = { pointerId, x: 0, y: 0 };
663
- }
689
+ const previousEvent = this._lastPointerEventById.get(pointerId) ?? { pointerId, x: 0, y: 0 };
664
690
  if (hasPointerCallbacks) {
665
691
  const event = new PointerEvent('pointermove', {
666
692
  pointerType: 'touch',
@@ -675,12 +701,27 @@ let CanvasBase = class CanvasBase extends View {
675
701
  movementY: pointer.y - previousEvent.y,
676
702
  button: -1,
677
703
  target: this.__target ?? this,
704
+ preventDefault: () => {
705
+ preventDefault = true;
706
+ },
678
707
  });
679
708
  for (const callback of this._pointerMoveCallbacks) {
680
709
  callback(event);
681
710
  }
682
711
  }
683
- if (hasMouseCallbacks) {
712
+ if (hasTouchCallbacks && !preventDefault) {
713
+ changedTouches.push(new Touch({
714
+ identifier: pointer.ptrId,
715
+ target: this.__target ?? this,
716
+ clientX: pointer.x,
717
+ clientY: pointer.y,
718
+ screenX: pointer.x,
719
+ screenY: pointer.y,
720
+ pageX: pointer.x,
721
+ pageY: pointer.y,
722
+ }));
723
+ }
724
+ if (hasMouseCallbacks && !preventDefault) {
684
725
  const event = new MouseEvent('mousemove', {
685
726
  clientX: pointer.x,
686
727
  clientY: pointer.y,
@@ -693,10 +734,9 @@ let CanvasBase = class CanvasBase extends View {
693
734
  button: -1,
694
735
  target: this.__target ?? this,
695
736
  });
696
- // todo emit mousemove when desktop is supported
697
- // for (const callback of this._mouseMoveCallbacks) {
698
- // callback(event);
699
- // }
737
+ for (const callback of this._mouseMoveCallbacks) {
738
+ callback(event);
739
+ }
700
740
  }
701
741
  if (hasMouseWheel) {
702
742
  const event = new WheelEvent('wheel', {
@@ -706,39 +746,62 @@ let CanvasBase = class CanvasBase extends View {
706
746
  deltaMode: data.deltaMode,
707
747
  target: this.__target ?? this,
708
748
  });
709
- // todo emit wheel when desktop is supported
710
- // for (const callback of this._mouseWheelCallbacks) {
711
- // callback(event);
712
- // }
713
- }
714
- if (index > -1) {
715
- this._lastPointerEventById[index] = { pointerId, x: pointer.x, y: pointer.y };
749
+ for (const callback of this._mouseWheelCallbacks) {
750
+ callback(event);
751
+ }
716
752
  }
753
+ this._lastPointerEventById.set(pointerId, { pointerId, x: pointer.x, y: pointer.y });
717
754
  }
718
- }
719
- if (this._touchMoveCallbacks.length > 0) {
720
- const changedTouches = [];
721
- for (const pointer of data.pointers) {
722
- changedTouches.push(new Touch({
723
- identifier: pointer.ptrId,
755
+ if ((changedTouches?.length ?? 0) > 0) {
756
+ const touches = TouchList.fromList(this._touches);
757
+ const event = new TouchEvent('touchmove', {
758
+ touches,
759
+ targetTouches: touches,
760
+ changedTouches,
724
761
  target: this.__target ?? this,
725
- clientX: pointer.x,
726
- clientY: pointer.y,
727
- screenX: pointer.x,
728
- screenY: pointer.y,
729
- pageX: pointer.x,
730
- pageY: pointer.y,
731
- }));
762
+ preventDefault: () => {
763
+ preventDefault = true;
764
+ },
765
+ });
766
+ for (const callback of this._touchMoveCallbacks) {
767
+ callback(event);
768
+ }
769
+ }
770
+ if (!preventDefault && hasMouseCallbacks) {
771
+ for (const pointer of data.pointers) {
772
+ const pointerId = pointer.ptrId;
773
+ const previousEvent = this._lastPointerEventById.get(pointerId) ?? { pointerId, x: 0, y: 0 };
774
+ const event = new MouseEvent('mousemove', {
775
+ clientX: pointer.x,
776
+ clientY: pointer.y,
777
+ screenX: pointer.x,
778
+ screenY: pointer.y,
779
+ pageX: pointer.x,
780
+ pageY: pointer.y,
781
+ movementX: pointer.x - previousEvent.x,
782
+ movementY: pointer.y - previousEvent.y,
783
+ button: -1,
784
+ target: this.__target ?? this,
785
+ preventDefault: () => {
786
+ preventDefault = true;
787
+ },
788
+ });
789
+ for (const callback of this._mouseMoveCallbacks) {
790
+ callback(event);
791
+ }
792
+ }
732
793
  }
733
- const touches = TouchList.fromList(this._touches);
734
- const event = new TouchEvent('touchmove', {
735
- touches,
736
- targetTouches: touches,
737
- changedTouches,
738
- target: this.__target ?? this,
739
- });
740
- for (const callback of this._touchMoveCallbacks) {
741
- callback(event);
794
+ if (hasMouseWheel) {
795
+ const event = new WheelEvent('wheel', {
796
+ deltaX: data.deltaX,
797
+ deltaY: data.deltaY,
798
+ deltaZ: 0,
799
+ deltaMode: data.deltaMode,
800
+ target: this.__target ?? this,
801
+ });
802
+ for (const callback of this._mouseWheelCallbacks) {
803
+ callback(event);
804
+ }
742
805
  }
743
806
  }
744
807
  }
@@ -784,6 +847,9 @@ let CanvasBase = class CanvasBase extends View {
784
847
  }
785
848
  setPointerCapture(id) { }
786
849
  releasePointerCapture(id) { }
850
+ getRootNode() {
851
+ return this;
852
+ }
787
853
  };
788
854
  CanvasBase.readyEvent = 'ready';
789
855
  CanvasBase = __decorate([