mol_plot_all 1.2.143 → 1.2.147

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.test.js CHANGED
@@ -1938,16 +1938,50 @@ var $;
1938
1938
  "use strict";
1939
1939
  var $;
1940
1940
  (function ($) {
1941
+ function $mol_guid(length = 8, exists = () => false) {
1942
+ for (;;) {
1943
+ let id = Math.random().toString(36).substring(2, length + 2).toUpperCase();
1944
+ if (exists(id))
1945
+ continue;
1946
+ return id;
1947
+ }
1948
+ }
1949
+ $.$mol_guid = $mol_guid;
1950
+ })($ || ($ = {}));
1951
+ //guid.js.map
1952
+ ;
1953
+ "use strict";
1954
+ var $;
1955
+ (function ($) {
1956
+ const keys = new WeakMap();
1941
1957
  function $mol_key(value) {
1942
1958
  if (!value)
1943
1959
  return JSON.stringify(value);
1944
1960
  if (typeof value !== 'object' && typeof value !== 'function')
1945
1961
  return JSON.stringify(value);
1946
- if (Array.isArray(value))
1947
- return JSON.stringify(value);
1948
- if (Object.getPrototypeOf(Object.getPrototypeOf(value)) === null)
1949
- return JSON.stringify(value);
1950
- return value;
1962
+ return JSON.stringify(value, (field, value) => {
1963
+ if (!value)
1964
+ return value;
1965
+ if (typeof value !== 'object' && typeof value !== 'function')
1966
+ return value;
1967
+ if (Array.isArray(value))
1968
+ return value;
1969
+ const proto = Reflect.getPrototypeOf(value);
1970
+ if (!proto)
1971
+ return value;
1972
+ if (Reflect.getPrototypeOf(proto) === null)
1973
+ return value;
1974
+ if ('toJSON' in value)
1975
+ return value;
1976
+ if (value instanceof RegExp)
1977
+ return value.toString();
1978
+ let key = keys.get(value);
1979
+ if (key)
1980
+ return key;
1981
+ key = $.$mol_guid();
1982
+ keys.set(value, key);
1983
+ return key;
1984
+ });
1951
1985
  }
1952
1986
  $.$mol_key = $mol_key;
1953
1987
  })($ || ($ = {}));
@@ -3531,9 +3565,9 @@ var $;
3531
3565
  }
3532
3566
  if (event instanceof WheelEvent) {
3533
3567
  this.pointer_events([event]);
3534
- if (event.ctrlKey)
3535
- return this.action_type('zoom');
3536
- return this.action_type('pan');
3568
+ if (event.shiftKey)
3569
+ return this.action_type('pan');
3570
+ return this.action_type('zoom');
3537
3571
  }
3538
3572
  return this.action_type('');
3539
3573
  }
@@ -3678,7 +3712,7 @@ var $;
3678
3712
  }
3679
3713
  if (action_type === 'pan') {
3680
3714
  const pan_prev = this.pan();
3681
- const pan_next = new $.$mol_vector_2d(pan_prev.x - (event.shiftKey ? event.deltaY : event.deltaX), pan_prev.y - (event.shiftKey ? event.deltaX : event.deltaY));
3715
+ const pan_next = new $.$mol_vector_2d(pan_prev.x - event.deltaX, pan_prev.y - event.deltaY);
3682
3716
  this.pan(pan_next);
3683
3717
  }
3684
3718
  }
@@ -4712,7 +4746,7 @@ var $;
4712
4746
  $.$mol_mem_key
4713
4747
  ], $mol_plot_map_heat.prototype, "level_points", null);
4714
4748
  __decorate([
4715
- $.$mol_mem
4749
+ $.$mol_mem_key
4716
4750
  ], $mol_plot_map_heat.prototype, "level_opacity", null);
4717
4751
  __decorate([
4718
4752
  $.$mol_mem
@@ -6881,6 +6915,61 @@ var $;
6881
6915
  ;
6882
6916
  "use strict";
6883
6917
  var $;
6918
+ (function ($) {
6919
+ $.$mol_test({
6920
+ 'Primitives'() {
6921
+ $.$mol_assert_equal($.$mol_key(null), 'null');
6922
+ $.$mol_assert_equal($.$mol_key(false), 'false');
6923
+ $.$mol_assert_equal($.$mol_key(true), 'true');
6924
+ $.$mol_assert_equal($.$mol_key(0), '0');
6925
+ $.$mol_assert_equal($.$mol_key(''), '""');
6926
+ },
6927
+ 'Array & POJO'() {
6928
+ $.$mol_assert_equal($.$mol_key([null]), '[null]');
6929
+ $.$mol_assert_equal($.$mol_key({ foo: 0 }), '{"foo":0}');
6930
+ $.$mol_assert_equal($.$mol_key({ foo: [false] }), '{"foo":[false]}');
6931
+ },
6932
+ 'Function'() {
6933
+ const func = () => { };
6934
+ $.$mol_assert_equal($.$mol_key(func), $.$mol_key(func));
6935
+ $.$mol_assert_unique($.$mol_key(func), $.$mol_key(() => { }));
6936
+ },
6937
+ 'Objects'() {
6938
+ class User {
6939
+ }
6940
+ const jin = new User();
6941
+ $.$mol_assert_equal($.$mol_key(jin), $.$mol_key(jin));
6942
+ $.$mol_assert_unique($.$mol_key(jin), $.$mol_key(new User()));
6943
+ },
6944
+ 'Elements'() {
6945
+ const foo = $.$mol_jsx("div", null, "bar");
6946
+ $.$mol_assert_equal($.$mol_key(foo), $.$mol_key(foo));
6947
+ $.$mol_assert_unique($.$mol_key(foo), $.$mol_key($.$mol_jsx("div", null, "bar")));
6948
+ },
6949
+ 'Custom JSON representation'() {
6950
+ class User {
6951
+ name;
6952
+ age;
6953
+ constructor(name, age) {
6954
+ this.name = name;
6955
+ this.age = age;
6956
+ }
6957
+ toJSON() { return { name: this.name }; }
6958
+ }
6959
+ $.$mol_assert_equal($.$mol_key(new User('jin', 18)), '{"name":"jin"}');
6960
+ },
6961
+ 'Special native classes'() {
6962
+ $.$mol_assert_equal($.$mol_key(new Date('xyz')), 'null');
6963
+ $.$mol_assert_equal($.$mol_key(new Date('2001-01-02T03:04:05.678Z')), '"2001-01-02T03:04:05.678Z"');
6964
+ $.$mol_assert_equal($.$mol_key(/./), '"/./"');
6965
+ $.$mol_assert_equal($.$mol_key(/\./gimsu), '"/\\\\./gimsu"');
6966
+ },
6967
+ });
6968
+ })($ || ($ = {}));
6969
+ //key.test.js.map
6970
+ ;
6971
+ "use strict";
6972
+ var $;
6884
6973
  (function ($_1) {
6885
6974
  $_1.$mol_test({
6886
6975
  'keyed reactive properties'($) {