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/web.js CHANGED
@@ -549,91 +549,125 @@ var $;
549
549
  "use strict";
550
550
  var $;
551
551
  (function ($) {
552
- const cache = new WeakMap();
553
- $.$mol_conform_stack = [];
554
- function $mol_conform(target, source) {
555
- if (Object.is(target, source))
556
- return source;
557
- if (!target || typeof target !== 'object')
558
- return target;
559
- if (!source || typeof source !== 'object')
560
- return target;
561
- if (target instanceof Error)
562
- return target;
563
- if (source instanceof Error)
564
- return target;
565
- if (target['constructor'] !== source['constructor'])
566
- return target;
567
- if (cache.get(target))
568
- return target;
569
- cache.set(target, true);
570
- const conform = $.$mol_conform_handlers.get(target['constructor']);
571
- if (!conform)
572
- return target;
573
- if ($.$mol_conform_stack.indexOf(target) !== -1)
574
- return target;
575
- $.$mol_conform_stack.push(target);
552
+ let cache = new WeakMap();
553
+ function $mol_compare_deep(left, right) {
554
+ if (Object.is(left, right))
555
+ return true;
556
+ if (left === null)
557
+ return false;
558
+ if (right === null)
559
+ return false;
560
+ if (typeof left !== 'object')
561
+ return false;
562
+ if (typeof right !== 'object')
563
+ return false;
564
+ const left_proto = Reflect.getPrototypeOf(left);
565
+ const right_proto = Reflect.getPrototypeOf(right);
566
+ if (left_proto !== right_proto)
567
+ return false;
568
+ if (left instanceof Boolean)
569
+ return Object.is(left.valueOf(), right['valueOf']());
570
+ if (left instanceof Number)
571
+ return Object.is(left.valueOf(), right['valueOf']());
572
+ if (left instanceof String)
573
+ return Object.is(left.valueOf(), right['valueOf']());
574
+ if (left instanceof Date)
575
+ return Object.is(left.valueOf(), right['valueOf']());
576
+ if (left instanceof RegExp)
577
+ return left.source === right['source'] && left.flags === right['flags'];
578
+ let left_cache = cache.get(left);
579
+ if (left_cache) {
580
+ const right_cache = left_cache.get(right);
581
+ if (typeof right_cache === 'boolean')
582
+ return right_cache;
583
+ }
584
+ else {
585
+ left_cache = new WeakMap([[right, true]]);
586
+ cache.set(left, left_cache);
587
+ }
588
+ let result;
576
589
  try {
577
- return conform(target, source);
590
+ if (left_proto && !Reflect.getPrototypeOf(left_proto))
591
+ result = compare_pojo(left, right);
592
+ else if (Array.isArray(left))
593
+ result = compare_array(left, right);
594
+ else if (left instanceof Set)
595
+ result = compare_set(left, right);
596
+ else if (left instanceof Map)
597
+ result = compare_map(left, right);
598
+ else if (ArrayBuffer.isView(left))
599
+ result = compare_buffer(left, right);
600
+ else if (Symbol.toPrimitive in left)
601
+ result = compare_primitive(left, right);
602
+ else
603
+ result = false;
578
604
  }
579
605
  finally {
580
- $.$mol_conform_stack.pop();
606
+ left_cache.set(right, result);
581
607
  }
608
+ return result;
582
609
  }
583
- $.$mol_conform = $mol_conform;
584
- $.$mol_conform_handlers = new WeakMap();
585
- function $mol_conform_handler(cl, handler) {
586
- $.$mol_conform_handlers.set(cl, handler);
587
- }
588
- $.$mol_conform_handler = $mol_conform_handler;
589
- function $mol_conform_array(target, source) {
590
- if (source.length !== target.length)
591
- return target;
592
- for (let i = 0; i < target.length; ++i) {
593
- if (!Object.is(source[i], target[i]))
594
- return target;
595
- }
596
- return source;
610
+ $.$mol_compare_deep = $mol_compare_deep;
611
+ function compare_array(left, right) {
612
+ const len = left.length;
613
+ if (len !== right.length)
614
+ return false;
615
+ for (let i = 0; i < len; ++i) {
616
+ if (!$mol_compare_deep(left[i], right[i]))
617
+ return false;
618
+ }
619
+ return true;
597
620
  }
598
- $.$mol_conform_array = $mol_conform_array;
599
- $mol_conform_handler(Array, $mol_conform_array);
600
- $mol_conform_handler(Uint8Array, $mol_conform_array);
601
- $mol_conform_handler(Uint16Array, $mol_conform_array);
602
- $mol_conform_handler(Uint32Array, $mol_conform_array);
603
- $mol_conform_handler(({})['constructor'], (target, source) => {
604
- let count = 0;
605
- let equal = true;
606
- for (let key in target) {
607
- const conformed = $mol_conform(target[key], source[key]);
608
- if (conformed !== target[key]) {
609
- try {
610
- target[key] = conformed;
611
- }
612
- catch (error) { }
613
- if (!Object.is(conformed, target[key]))
614
- equal = false;
615
- }
616
- if (!Object.is(conformed, source[key]))
617
- equal = false;
618
- ++count;
621
+ function compare_buffer(left, right) {
622
+ const len = left.byteLength;
623
+ if (len !== right.byteLength)
624
+ return false;
625
+ for (let i = 0; i < len; ++i) {
626
+ if (left[i] !== right[i])
627
+ return false;
619
628
  }
620
- for (let key in source)
621
- if (--count < 0)
629
+ return true;
630
+ }
631
+ function compare_iterator(left, right, compare) {
632
+ while (true) {
633
+ const left_next = left.next();
634
+ const right_next = right.next();
635
+ if (left_next.done !== right_next.done)
636
+ return false;
637
+ if (left_next.done)
622
638
  break;
623
- return (equal && count === 0) ? source : target;
624
- });
625
- $mol_conform_handler(Date, (target, source) => {
626
- if (target.getTime() === source.getTime())
627
- return source;
628
- return target;
629
- });
630
- $mol_conform_handler(RegExp, (target, source) => {
631
- if (target.toString() === source.toString())
632
- return source;
633
- return target;
634
- });
639
+ if (!compare(left_next.value, right_next.value))
640
+ return false;
641
+ }
642
+ return true;
643
+ }
644
+ function compare_set(left, right) {
645
+ if (left.size !== right.size)
646
+ return false;
647
+ return compare_iterator(left.values(), right.values(), $mol_compare_deep);
648
+ }
649
+ function compare_map(left, right) {
650
+ if (left.size !== right.size)
651
+ return false;
652
+ return compare_iterator(left.keys(), right.keys(), Object.is)
653
+ && compare_iterator(left.values(), right.values(), $mol_compare_deep);
654
+ }
655
+ function compare_pojo(left, right) {
656
+ const left_keys = Object.getOwnPropertyNames(left);
657
+ const right_keys = Object.getOwnPropertyNames(right);
658
+ if (left_keys.length !== right_keys.length)
659
+ return false;
660
+ for (let key of left_keys) {
661
+ if (!$mol_compare_deep(left[key], Reflect.get(right, key)))
662
+ return false;
663
+ }
664
+ return true;
665
+ }
666
+ function compare_primitive(left, right) {
667
+ return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
668
+ }
635
669
  })($ || ($ = {}));
636
- //conform.js.map
670
+ //deep.js.map
637
671
  ;
638
672
  "use strict";
639
673
  var $;
@@ -960,8 +994,7 @@ var $;
960
994
  }
961
995
  }
962
996
  push(value) {
963
- value = this.$.$mol_conform(value, this.value);
964
- if (this.error !== null || !Object.is(this.value, value)) {
997
+ if (this.error !== null || !$.$mol_compare_deep(this.value, value)) {
965
998
  if ($mol_fiber.logs)
966
999
  this.$.$mol_log3_done({
967
1000
  place: this,
@@ -2995,11 +3028,21 @@ var $;
2995
3028
  return val;
2996
3029
  return null;
2997
3030
  }
3031
+ draw_start(event) {
3032
+ if (event !== undefined)
3033
+ return event;
3034
+ return null;
3035
+ }
2998
3036
  draw(event) {
2999
3037
  if (event !== undefined)
3000
3038
  return event;
3001
3039
  return null;
3002
3040
  }
3041
+ draw_end(event) {
3042
+ if (event !== undefined)
3043
+ return event;
3044
+ return null;
3045
+ }
3003
3046
  style() {
3004
3047
  return {
3005
3048
  ...super.style(),
@@ -3013,7 +3056,7 @@ var $;
3013
3056
  pointerdown: (event) => this.event_start(event),
3014
3057
  pointermove: (event) => this.event_move(event),
3015
3058
  pointerup: (event) => this.event_end(event),
3016
- pointerleave: (event) => this.event_end(event),
3059
+ pointerleave: (event) => this.event_leave(event),
3017
3060
  wheel: (event) => this.event_wheel(event)
3018
3061
  };
3019
3062
  }
@@ -3032,6 +3075,11 @@ var $;
3032
3075
  return event;
3033
3076
  return null;
3034
3077
  }
3078
+ event_leave(event) {
3079
+ if (event !== undefined)
3080
+ return event;
3081
+ return null;
3082
+ }
3035
3083
  event_wheel(event) {
3036
3084
  if (event !== undefined)
3037
3085
  return event;
@@ -3101,9 +3149,15 @@ var $;
3101
3149
  __decorate([
3102
3150
  $.$mol_mem
3103
3151
  ], $mol_touch.prototype, "swipe_to_top", null);
3152
+ __decorate([
3153
+ $.$mol_mem
3154
+ ], $mol_touch.prototype, "draw_start", null);
3104
3155
  __decorate([
3105
3156
  $.$mol_mem
3106
3157
  ], $mol_touch.prototype, "draw", null);
3158
+ __decorate([
3159
+ $.$mol_mem
3160
+ ], $mol_touch.prototype, "draw_end", null);
3107
3161
  __decorate([
3108
3162
  $.$mol_mem
3109
3163
  ], $mol_touch.prototype, "event_start", null);
@@ -3113,6 +3167,9 @@ var $;
3113
3167
  __decorate([
3114
3168
  $.$mol_mem
3115
3169
  ], $mol_touch.prototype, "event_end", null);
3170
+ __decorate([
3171
+ $.$mol_mem
3172
+ ], $mol_touch.prototype, "event_leave", null);
3116
3173
  __decorate([
3117
3174
  $.$mol_mem
3118
3175
  ], $mol_touch.prototype, "event_wheel", null);
@@ -3159,10 +3216,14 @@ var $;
3159
3216
  event_eat(event) {
3160
3217
  if (event instanceof PointerEvent) {
3161
3218
  const events = this.pointer_events().filter(e => e.pointerId !== event.pointerId);
3162
- if (event.type !== 'pointerleave')
3219
+ if (event.type !== 'pointerup' && event.type !== 'pointerleave')
3163
3220
  events.push(event);
3164
3221
  this.pointer_events(events);
3165
- if (this.allow_zoom() && events.filter(e => e.pointerType === 'touch').length === 2) {
3222
+ const touch_count = events.filter(e => e.pointerType === 'touch').length;
3223
+ if (this.allow_zoom() && touch_count === 2) {
3224
+ return this.action_type('zoom');
3225
+ }
3226
+ if (this.action_type() === 'zoom' && touch_count === 1) {
3166
3227
  return this.action_type('zoom');
3167
3228
  }
3168
3229
  let button;
@@ -3195,10 +3256,12 @@ var $;
3195
3256
  const action_type = this.event_eat(event);
3196
3257
  if (!action_type)
3197
3258
  return;
3198
- if (action_type === 'draw')
3199
- return;
3200
3259
  const coords = this.pointer_coords();
3201
3260
  this.start_pos(coords.center());
3261
+ if (action_type === 'draw') {
3262
+ this.draw_start(event);
3263
+ return;
3264
+ }
3202
3265
  this.start_distance(coords.distance());
3203
3266
  this.start_zoom(this.zoom());
3204
3267
  }
@@ -3210,14 +3273,17 @@ var $;
3210
3273
  return;
3211
3274
  const start_pan = this.start_pan();
3212
3275
  const action_type = this.event_eat(event);
3276
+ const start_pos = this.start_pos();
3213
3277
  let pos = this.pointer_center();
3214
3278
  if (!action_type)
3215
3279
  return;
3216
3280
  if (action_type === 'draw') {
3217
- this.draw(event);
3281
+ const distance = new $.$mol_vector(start_pos, pos).distance();
3282
+ if (distance >= 4) {
3283
+ this.draw(event);
3284
+ }
3218
3285
  return;
3219
3286
  }
3220
- const start_pos = this.start_pos();
3221
3287
  if (!start_pos)
3222
3288
  return;
3223
3289
  if (action_type === 'pan') {
@@ -3266,12 +3332,15 @@ var $;
3266
3332
  }
3267
3333
  }
3268
3334
  event_end(event) {
3335
+ const action = this.action_type();
3336
+ if (action === 'draw') {
3337
+ this.draw_end(event);
3338
+ }
3339
+ this.event_leave(event);
3340
+ }
3341
+ event_leave(event) {
3269
3342
  this.event_eat(event);
3270
3343
  this.dom_node().releasePointerCapture(event.pointerId);
3271
- if (!this.start_pos()) {
3272
- this.draw(event);
3273
- return;
3274
- }
3275
3344
  this.start_pos(null);
3276
3345
  }
3277
3346
  swipe_left(event) {
@@ -3514,11 +3583,21 @@ var $;
3514
3583
  allow_zoom() {
3515
3584
  return true;
3516
3585
  }
3586
+ draw_start(event) {
3587
+ if (event !== undefined)
3588
+ return event;
3589
+ return null;
3590
+ }
3517
3591
  draw(event) {
3518
3592
  if (event !== undefined)
3519
3593
  return event;
3520
3594
  return null;
3521
3595
  }
3596
+ draw_end(event) {
3597
+ if (event !== undefined)
3598
+ return event;
3599
+ return null;
3600
+ }
3522
3601
  cursor_position() {
3523
3602
  return this.Touch().pointer_center();
3524
3603
  }
@@ -3535,7 +3614,9 @@ var $;
3535
3614
  obj.allow_draw = () => this.allow_draw();
3536
3615
  obj.allow_pan = () => this.allow_pan();
3537
3616
  obj.allow_zoom = () => this.allow_zoom();
3617
+ obj.draw_start = (event) => this.draw_start(event);
3538
3618
  obj.draw = (event) => this.draw(event);
3619
+ obj.draw_end = (event) => this.draw_end(event);
3539
3620
  return obj;
3540
3621
  }
3541
3622
  }
@@ -3617,9 +3698,15 @@ var $;
3617
3698
  __decorate([
3618
3699
  $.$mol_mem
3619
3700
  ], $mol_plot_pane.prototype, "zoom", null);
3701
+ __decorate([
3702
+ $.$mol_mem
3703
+ ], $mol_plot_pane.prototype, "draw_start", null);
3620
3704
  __decorate([
3621
3705
  $.$mol_mem
3622
3706
  ], $mol_plot_pane.prototype, "draw", null);
3707
+ __decorate([
3708
+ $.$mol_mem
3709
+ ], $mol_plot_pane.prototype, "draw_end", null);
3623
3710
  __decorate([
3624
3711
  $.$mol_mem
3625
3712
  ], $mol_plot_pane.prototype, "Touch", null);