mol_plot_all 1.2.130 → 1.2.134

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/node.js CHANGED
@@ -961,91 +961,125 @@ var $;
961
961
  "use strict";
962
962
  var $;
963
963
  (function ($) {
964
- const cache = new WeakMap();
965
- $.$mol_conform_stack = [];
966
- function $mol_conform(target, source) {
967
- if (Object.is(target, source))
968
- return source;
969
- if (!target || typeof target !== 'object')
970
- return target;
971
- if (!source || typeof source !== 'object')
972
- return target;
973
- if (target instanceof Error)
974
- return target;
975
- if (source instanceof Error)
976
- return target;
977
- if (target['constructor'] !== source['constructor'])
978
- return target;
979
- if (cache.get(target))
980
- return target;
981
- cache.set(target, true);
982
- const conform = $.$mol_conform_handlers.get(target['constructor']);
983
- if (!conform)
984
- return target;
985
- if ($.$mol_conform_stack.indexOf(target) !== -1)
986
- return target;
987
- $.$mol_conform_stack.push(target);
964
+ let cache = new WeakMap();
965
+ function $mol_compare_deep(left, right) {
966
+ if (Object.is(left, right))
967
+ return true;
968
+ if (left === null)
969
+ return false;
970
+ if (right === null)
971
+ return false;
972
+ if (typeof left !== 'object')
973
+ return false;
974
+ if (typeof right !== 'object')
975
+ return false;
976
+ const left_proto = Reflect.getPrototypeOf(left);
977
+ const right_proto = Reflect.getPrototypeOf(right);
978
+ if (left_proto !== right_proto)
979
+ return false;
980
+ if (left instanceof Boolean)
981
+ return Object.is(left.valueOf(), right['valueOf']());
982
+ if (left instanceof Number)
983
+ return Object.is(left.valueOf(), right['valueOf']());
984
+ if (left instanceof String)
985
+ return Object.is(left.valueOf(), right['valueOf']());
986
+ if (left instanceof Date)
987
+ return Object.is(left.valueOf(), right['valueOf']());
988
+ if (left instanceof RegExp)
989
+ return left.source === right['source'] && left.flags === right['flags'];
990
+ let left_cache = cache.get(left);
991
+ if (left_cache) {
992
+ const right_cache = left_cache.get(right);
993
+ if (typeof right_cache === 'boolean')
994
+ return right_cache;
995
+ }
996
+ else {
997
+ left_cache = new WeakMap([[right, true]]);
998
+ cache.set(left, left_cache);
999
+ }
1000
+ let result;
988
1001
  try {
989
- return conform(target, source);
1002
+ if (left_proto && !Reflect.getPrototypeOf(left_proto))
1003
+ result = compare_pojo(left, right);
1004
+ else if (Array.isArray(left))
1005
+ result = compare_array(left, right);
1006
+ else if (left instanceof Set)
1007
+ result = compare_set(left, right);
1008
+ else if (left instanceof Map)
1009
+ result = compare_map(left, right);
1010
+ else if (ArrayBuffer.isView(left))
1011
+ result = compare_buffer(left, right);
1012
+ else if (Symbol.toPrimitive in left)
1013
+ result = compare_primitive(left, right);
1014
+ else
1015
+ result = false;
990
1016
  }
991
1017
  finally {
992
- $.$mol_conform_stack.pop();
1018
+ left_cache.set(right, result);
993
1019
  }
1020
+ return result;
994
1021
  }
995
- $.$mol_conform = $mol_conform;
996
- $.$mol_conform_handlers = new WeakMap();
997
- function $mol_conform_handler(cl, handler) {
998
- $.$mol_conform_handlers.set(cl, handler);
999
- }
1000
- $.$mol_conform_handler = $mol_conform_handler;
1001
- function $mol_conform_array(target, source) {
1002
- if (source.length !== target.length)
1003
- return target;
1004
- for (let i = 0; i < target.length; ++i) {
1005
- if (!Object.is(source[i], target[i]))
1006
- return target;
1007
- }
1008
- return source;
1022
+ $.$mol_compare_deep = $mol_compare_deep;
1023
+ function compare_array(left, right) {
1024
+ const len = left.length;
1025
+ if (len !== right.length)
1026
+ return false;
1027
+ for (let i = 0; i < len; ++i) {
1028
+ if (!$mol_compare_deep(left[i], right[i]))
1029
+ return false;
1030
+ }
1031
+ return true;
1009
1032
  }
1010
- $.$mol_conform_array = $mol_conform_array;
1011
- $mol_conform_handler(Array, $mol_conform_array);
1012
- $mol_conform_handler(Uint8Array, $mol_conform_array);
1013
- $mol_conform_handler(Uint16Array, $mol_conform_array);
1014
- $mol_conform_handler(Uint32Array, $mol_conform_array);
1015
- $mol_conform_handler(({})['constructor'], (target, source) => {
1016
- let count = 0;
1017
- let equal = true;
1018
- for (let key in target) {
1019
- const conformed = $mol_conform(target[key], source[key]);
1020
- if (conformed !== target[key]) {
1021
- try {
1022
- target[key] = conformed;
1023
- }
1024
- catch (error) { }
1025
- if (!Object.is(conformed, target[key]))
1026
- equal = false;
1027
- }
1028
- if (!Object.is(conformed, source[key]))
1029
- equal = false;
1030
- ++count;
1033
+ function compare_buffer(left, right) {
1034
+ const len = left.byteLength;
1035
+ if (len !== right.byteLength)
1036
+ return false;
1037
+ for (let i = 0; i < len; ++i) {
1038
+ if (left[i] !== right[i])
1039
+ return false;
1031
1040
  }
1032
- for (let key in source)
1033
- if (--count < 0)
1041
+ return true;
1042
+ }
1043
+ function compare_iterator(left, right, compare) {
1044
+ while (true) {
1045
+ const left_next = left.next();
1046
+ const right_next = right.next();
1047
+ if (left_next.done !== right_next.done)
1048
+ return false;
1049
+ if (left_next.done)
1034
1050
  break;
1035
- return (equal && count === 0) ? source : target;
1036
- });
1037
- $mol_conform_handler(Date, (target, source) => {
1038
- if (target.getTime() === source.getTime())
1039
- return source;
1040
- return target;
1041
- });
1042
- $mol_conform_handler(RegExp, (target, source) => {
1043
- if (target.toString() === source.toString())
1044
- return source;
1045
- return target;
1046
- });
1051
+ if (!compare(left_next.value, right_next.value))
1052
+ return false;
1053
+ }
1054
+ return true;
1055
+ }
1056
+ function compare_set(left, right) {
1057
+ if (left.size !== right.size)
1058
+ return false;
1059
+ return compare_iterator(left.values(), right.values(), $mol_compare_deep);
1060
+ }
1061
+ function compare_map(left, right) {
1062
+ if (left.size !== right.size)
1063
+ return false;
1064
+ return compare_iterator(left.keys(), right.keys(), Object.is)
1065
+ && compare_iterator(left.values(), right.values(), $mol_compare_deep);
1066
+ }
1067
+ function compare_pojo(left, right) {
1068
+ const left_keys = Object.getOwnPropertyNames(left);
1069
+ const right_keys = Object.getOwnPropertyNames(right);
1070
+ if (left_keys.length !== right_keys.length)
1071
+ return false;
1072
+ for (let key of left_keys) {
1073
+ if (!$mol_compare_deep(left[key], Reflect.get(right, key)))
1074
+ return false;
1075
+ }
1076
+ return true;
1077
+ }
1078
+ function compare_primitive(left, right) {
1079
+ return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
1080
+ }
1047
1081
  })($ || ($ = {}));
1048
- //conform.js.map
1082
+ //deep.js.map
1049
1083
  ;
1050
1084
  "use strict";
1051
1085
  var $;
@@ -1372,8 +1406,7 @@ var $;
1372
1406
  }
1373
1407
  }
1374
1408
  push(value) {
1375
- value = this.$.$mol_conform(value, this.value);
1376
- if (this.error !== null || !Object.is(this.value, value)) {
1409
+ if (this.error !== null || !$.$mol_compare_deep(this.value, value)) {
1377
1410
  if ($mol_fiber.logs)
1378
1411
  this.$.$mol_log3_done({
1379
1412
  place: this,
@@ -3288,11 +3321,21 @@ var $;
3288
3321
  return val;
3289
3322
  return null;
3290
3323
  }
3324
+ draw_start(event) {
3325
+ if (event !== undefined)
3326
+ return event;
3327
+ return null;
3328
+ }
3291
3329
  draw(event) {
3292
3330
  if (event !== undefined)
3293
3331
  return event;
3294
3332
  return null;
3295
3333
  }
3334
+ draw_end(event) {
3335
+ if (event !== undefined)
3336
+ return event;
3337
+ return null;
3338
+ }
3296
3339
  style() {
3297
3340
  return {
3298
3341
  ...super.style(),
@@ -3306,7 +3349,7 @@ var $;
3306
3349
  pointerdown: (event) => this.event_start(event),
3307
3350
  pointermove: (event) => this.event_move(event),
3308
3351
  pointerup: (event) => this.event_end(event),
3309
- pointerleave: (event) => this.event_end(event),
3352
+ pointerleave: (event) => this.event_leave(event),
3310
3353
  wheel: (event) => this.event_wheel(event)
3311
3354
  };
3312
3355
  }
@@ -3325,6 +3368,11 @@ var $;
3325
3368
  return event;
3326
3369
  return null;
3327
3370
  }
3371
+ event_leave(event) {
3372
+ if (event !== undefined)
3373
+ return event;
3374
+ return null;
3375
+ }
3328
3376
  event_wheel(event) {
3329
3377
  if (event !== undefined)
3330
3378
  return event;
@@ -3394,9 +3442,15 @@ var $;
3394
3442
  __decorate([
3395
3443
  $.$mol_mem
3396
3444
  ], $mol_touch.prototype, "swipe_to_top", null);
3445
+ __decorate([
3446
+ $.$mol_mem
3447
+ ], $mol_touch.prototype, "draw_start", null);
3397
3448
  __decorate([
3398
3449
  $.$mol_mem
3399
3450
  ], $mol_touch.prototype, "draw", null);
3451
+ __decorate([
3452
+ $.$mol_mem
3453
+ ], $mol_touch.prototype, "draw_end", null);
3400
3454
  __decorate([
3401
3455
  $.$mol_mem
3402
3456
  ], $mol_touch.prototype, "event_start", null);
@@ -3406,6 +3460,9 @@ var $;
3406
3460
  __decorate([
3407
3461
  $.$mol_mem
3408
3462
  ], $mol_touch.prototype, "event_end", null);
3463
+ __decorate([
3464
+ $.$mol_mem
3465
+ ], $mol_touch.prototype, "event_leave", null);
3409
3466
  __decorate([
3410
3467
  $.$mol_mem
3411
3468
  ], $mol_touch.prototype, "event_wheel", null);
@@ -3452,10 +3509,14 @@ var $;
3452
3509
  event_eat(event) {
3453
3510
  if (event instanceof PointerEvent) {
3454
3511
  const events = this.pointer_events().filter(e => e.pointerId !== event.pointerId);
3455
- if (event.type !== 'pointerleave')
3512
+ if (event.type !== 'pointerup' && event.type !== 'pointerleave')
3456
3513
  events.push(event);
3457
3514
  this.pointer_events(events);
3458
- if (this.allow_zoom() && events.filter(e => e.pointerType === 'touch').length === 2) {
3515
+ const touch_count = events.filter(e => e.pointerType === 'touch').length;
3516
+ if (this.allow_zoom() && touch_count === 2) {
3517
+ return this.action_type('zoom');
3518
+ }
3519
+ if (this.action_type() === 'zoom' && touch_count === 1) {
3459
3520
  return this.action_type('zoom');
3460
3521
  }
3461
3522
  let button;
@@ -3488,10 +3549,12 @@ var $;
3488
3549
  const action_type = this.event_eat(event);
3489
3550
  if (!action_type)
3490
3551
  return;
3491
- if (action_type === 'draw')
3492
- return;
3493
3552
  const coords = this.pointer_coords();
3494
3553
  this.start_pos(coords.center());
3554
+ if (action_type === 'draw') {
3555
+ this.draw_start(event);
3556
+ return;
3557
+ }
3495
3558
  this.start_distance(coords.distance());
3496
3559
  this.start_zoom(this.zoom());
3497
3560
  }
@@ -3503,14 +3566,17 @@ var $;
3503
3566
  return;
3504
3567
  const start_pan = this.start_pan();
3505
3568
  const action_type = this.event_eat(event);
3569
+ const start_pos = this.start_pos();
3506
3570
  let pos = this.pointer_center();
3507
3571
  if (!action_type)
3508
3572
  return;
3509
3573
  if (action_type === 'draw') {
3510
- this.draw(event);
3574
+ const distance = new $.$mol_vector(start_pos, pos).distance();
3575
+ if (distance >= 4) {
3576
+ this.draw(event);
3577
+ }
3511
3578
  return;
3512
3579
  }
3513
- const start_pos = this.start_pos();
3514
3580
  if (!start_pos)
3515
3581
  return;
3516
3582
  if (action_type === 'pan') {
@@ -3559,12 +3625,15 @@ var $;
3559
3625
  }
3560
3626
  }
3561
3627
  event_end(event) {
3628
+ const action = this.action_type();
3629
+ if (action === 'draw') {
3630
+ this.draw_end(event);
3631
+ }
3632
+ this.event_leave(event);
3633
+ }
3634
+ event_leave(event) {
3562
3635
  this.event_eat(event);
3563
3636
  this.dom_node().releasePointerCapture(event.pointerId);
3564
- if (!this.start_pos()) {
3565
- this.draw(event);
3566
- return;
3567
- }
3568
3637
  this.start_pos(null);
3569
3638
  }
3570
3639
  swipe_left(event) {
@@ -3807,11 +3876,21 @@ var $;
3807
3876
  allow_zoom() {
3808
3877
  return true;
3809
3878
  }
3879
+ draw_start(event) {
3880
+ if (event !== undefined)
3881
+ return event;
3882
+ return null;
3883
+ }
3810
3884
  draw(event) {
3811
3885
  if (event !== undefined)
3812
3886
  return event;
3813
3887
  return null;
3814
3888
  }
3889
+ draw_end(event) {
3890
+ if (event !== undefined)
3891
+ return event;
3892
+ return null;
3893
+ }
3815
3894
  cursor_position() {
3816
3895
  return this.Touch().pointer_center();
3817
3896
  }
@@ -3828,7 +3907,9 @@ var $;
3828
3907
  obj.allow_draw = () => this.allow_draw();
3829
3908
  obj.allow_pan = () => this.allow_pan();
3830
3909
  obj.allow_zoom = () => this.allow_zoom();
3910
+ obj.draw_start = (event) => this.draw_start(event);
3831
3911
  obj.draw = (event) => this.draw(event);
3912
+ obj.draw_end = (event) => this.draw_end(event);
3832
3913
  return obj;
3833
3914
  }
3834
3915
  }
@@ -3910,9 +3991,15 @@ var $;
3910
3991
  __decorate([
3911
3992
  $.$mol_mem
3912
3993
  ], $mol_plot_pane.prototype, "zoom", null);
3994
+ __decorate([
3995
+ $.$mol_mem
3996
+ ], $mol_plot_pane.prototype, "draw_start", null);
3913
3997
  __decorate([
3914
3998
  $.$mol_mem
3915
3999
  ], $mol_plot_pane.prototype, "draw", null);
4000
+ __decorate([
4001
+ $.$mol_mem
4002
+ ], $mol_plot_pane.prototype, "draw_end", null);
3916
4003
  __decorate([
3917
4004
  $.$mol_mem
3918
4005
  ], $mol_plot_pane.prototype, "Touch", null);