@russss/maplibregl-layer-switcher 1.1.0 → 1.2.0

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/.prettierrc ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "singleQuote": true,
3
+ "printWidth": 120
4
+ }
package/lib/index.d.ts ADDED
@@ -0,0 +1,31 @@
1
+ import { List } from 'redom';
2
+ import './layerswitcher.css';
3
+ import URLHash from './urlhash';
4
+ declare class LayerSwitcher implements maplibregl.IControl {
5
+ _layers: Record<string, string>;
6
+ _identifiers: Record<string, string>;
7
+ _default_visible: Array<string>;
8
+ _container: HTMLElement;
9
+ _visible: Array<string>;
10
+ _layerList: List;
11
+ _map: maplibregl.Map | undefined;
12
+ urlhash: URLHash | undefined;
13
+ constructor(layers: Record<string, string>, default_visible?: Array<string>);
14
+ _initLayerIdentifiers(): Record<string, string>;
15
+ _getLayerIdentifiers(): string[];
16
+ _updateVisibility(): void;
17
+ /**
18
+ * Modify a MapLibre GL style object before creating the map to set initial visibility states.
19
+ * This prevents flash-of-invisible-layers.
20
+ *
21
+ * @param style the MapLibre GL style object to modify
22
+ */
23
+ setInitialVisibility(style: maplibregl.StyleSpecification): void;
24
+ getURLString(): string;
25
+ setURLString(string: string): void;
26
+ onAdd(map: maplibregl.Map): HTMLDivElement;
27
+ onRemove(): void;
28
+ _updateList(): void;
29
+ }
30
+ export default LayerSwitcher;
31
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,IAAI,EAAgC,MAAM,OAAO,CAAC;AAGjE,OAAO,qBAAqB,CAAC;AAC7B,OAAO,OAAO,MAAM,WAAW,CAAC;AAGhC,cAAM,aAAc,YAAW,UAAU,CAAC,QAAQ;IAChD,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,gBAAgB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAChC,UAAU,EAAE,WAAW,CAAC;IACxB,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACxB,UAAU,EAAE,IAAI,CAAC;IACjB,IAAI,EAAE,UAAU,CAAC,GAAG,GAAG,SAAS,CAAC;IACjC,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC;gBAEjB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,eAAe,GAAE,KAAK,CAAC,MAAM,CAAM;IAW/E,qBAAqB;IAgBrB,oBAAoB;IASpB,iBAAiB;IAwBjB;;;;;OAKG;IACH,oBAAoB,CAAC,KAAK,EAAE,UAAU,CAAC,kBAAkB;IAezD,YAAY;IAOZ,YAAY,CAAC,MAAM,EAAE,MAAM;IAqB3B,KAAK,CAAC,GAAG,EAAE,UAAU,CAAC,GAAG;IA6BzB,QAAQ;IAKR,WAAW;CAWZ;AA0CD,eAAe,aAAa,CAAC"}
package/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { el } from 'redom';
1
+ import { list, el, mount } from 'redom';
2
2
  import invert from 'lodash.invert';
3
3
  import isEqual from 'lodash.isequal';
4
4
  import './layerswitcher.css';
@@ -7,15 +7,16 @@ class LayerSwitcher {
7
7
  this._layers = layers;
8
8
  this._identifiers = this._initLayerIdentifiers();
9
9
  this._default_visible = default_visible;
10
- this._container = el('div', { class: 'maplibregl-ctrl layer-switcher-list' });
11
- this._container.appendChild(el('h3', 'Layers'));
10
+ this._layerList = list('ul', LayerSwitcherItem, 'name');
11
+ this._container = el('div', [el('h3', 'Layers'), this._layerList], { class: 'layer-switcher-list' });
12
+ mount(document.body, this._container);
12
13
  this._visible = [...default_visible];
13
14
  }
14
15
  _initLayerIdentifiers() {
15
16
  let identifiers = {};
16
17
  Object.keys(this._layers)
17
18
  .sort()
18
- .forEach(layer_name => {
19
+ .forEach((layer_name) => {
19
20
  let size = 1;
20
21
  let ident = null;
21
22
  do {
@@ -29,7 +30,7 @@ class LayerSwitcher {
29
30
  _getLayerIdentifiers() {
30
31
  let identifiers = [];
31
32
  let id_map = invert(this._identifiers);
32
- this._visible.sort().forEach(layer_name => {
33
+ this._visible.sort().forEach((layer_name) => {
33
34
  identifiers.push(id_map[layer_name]);
34
35
  });
35
36
  return identifiers;
@@ -67,8 +68,7 @@ class LayerSwitcher {
67
68
  for (let layer of style['layers']) {
68
69
  for (let layer_name in this._layers) {
69
70
  let pref = this._layers[layer_name];
70
- if (layer['id'].startsWith(pref) &&
71
- !this._visible.includes(layer['id'])) {
71
+ if (layer['id'].startsWith(pref) && !this._visible.includes(layer['id'])) {
72
72
  if (!layer['layout']) {
73
73
  layer['layout'] = {};
74
74
  }
@@ -76,29 +76,35 @@ class LayerSwitcher {
76
76
  }
77
77
  }
78
78
  }
79
+ this._updateList();
79
80
  }
80
81
  getURLString() {
81
82
  if (!isEqual(this._visible.sort(), this._default_visible.sort())) {
82
83
  return this._getLayerIdentifiers().join(',');
83
84
  }
84
- return null;
85
+ return '';
85
86
  }
86
87
  setURLString(string) {
88
+ var _a;
87
89
  if (string) {
88
90
  const ids = string.split(',');
89
91
  if (ids.length == 0) {
90
92
  this._visible = [...this._default_visible];
91
93
  }
92
94
  else {
93
- this._visible = ids.map(id => this._identifiers[id]).filter(id => id);
95
+ this._visible = ids.map((id) => this._identifiers[id]).filter((id) => id);
94
96
  }
95
97
  }
96
98
  else {
97
99
  this._visible = [...this._default_visible];
98
100
  }
99
- if (this._map) {
101
+ // If the style hasn't been loaded yet, don't update visibility or this causes
102
+ // problems with the URLHash. Initial visibility is handled by the
103
+ // `setInitialVisibility` method.
104
+ if ((_a = this._map) === null || _a === void 0 ? void 0 : _a.isStyleLoaded()) {
100
105
  this._updateVisibility();
101
106
  }
107
+ this._updateList();
102
108
  }
103
109
  onAdd(map) {
104
110
  this._map = map;
@@ -110,43 +116,65 @@ class LayerSwitcher {
110
116
  this._updateVisibility();
111
117
  });
112
118
  }
113
- this._createList();
114
- const wrapper = el('div', {
115
- class: 'maplibregl-ctrl maplibregl-ctrl-group layer-switcher',
119
+ const button = el('button', {
120
+ class: 'layer-switcher-button',
121
+ 'aria-label': 'Layer Switcher',
116
122
  });
117
- wrapper.appendChild(this._container);
118
- wrapper.onmouseover = e => {
123
+ button.onmouseover = (e) => {
124
+ var button_position = button.getBoundingClientRect();
125
+ this._container.style.top = button_position.top + 'px';
126
+ this._container.style.right = document.documentElement.clientWidth - button_position.right + 'px';
119
127
  this._container.style.display = 'block';
120
128
  };
121
- wrapper.onmouseout = e => {
129
+ this._container.onmouseleave = (e) => {
122
130
  this._container.style.display = 'none';
123
131
  };
124
- return wrapper;
132
+ return el('div', button, {
133
+ class: 'maplibregl-ctrl maplibregl-ctrl-group layer-switcher',
134
+ });
125
135
  }
126
- _createList() {
127
- var list = el('ul');
128
- var i = 0;
129
- for (let name in this._layers) {
130
- let checkbox = el('input', {
131
- type: 'checkbox',
132
- id: 'layer' + i,
133
- checked: this._visible.includes(name),
134
- });
135
- let label = el('label', name, { for: 'layer' + i });
136
- checkbox.onchange = e => {
137
- if (e.target.checked) {
138
- this._visible.push(name);
139
- }
140
- else {
141
- this._visible = this._visible.filter(item => item !== name);
142
- }
143
- this._updateVisibility();
136
+ onRemove() {
137
+ var _a;
138
+ (_a = this._container.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(this._container);
139
+ this._map = undefined;
140
+ }
141
+ _updateList() {
142
+ this._layerList.update(Object.keys(this._layers).map((name) => {
143
+ return {
144
+ enabled: this._visible.includes(name),
145
+ name: name,
144
146
  };
145
- let li = el('li', [label, checkbox]);
146
- list.appendChild(li);
147
- i++;
147
+ }), this);
148
+ }
149
+ }
150
+ class LayerSwitcherItem {
151
+ constructor() {
152
+ this._checkbox = el('input', {
153
+ type: 'checkbox',
154
+ });
155
+ this._label = el('label');
156
+ this.el = el('li', [this._label, this._checkbox]);
157
+ this._checkbox.onchange = (e) => this.onChange(e);
158
+ }
159
+ onChange(e) {
160
+ if (!this.layerSwitcher)
161
+ return;
162
+ const name = this._label.innerText;
163
+ if (e.target.checked) {
164
+ this.layerSwitcher._visible.push(name);
165
+ }
166
+ else {
167
+ this.layerSwitcher._visible = this.layerSwitcher._visible.filter((item) => item !== name);
148
168
  }
149
- this._container.appendChild(list);
169
+ this.layerSwitcher._updateVisibility();
170
+ }
171
+ update(data, index, items, context) {
172
+ this.layerSwitcher = context;
173
+ let label_for = 'layerSwitch' + index;
174
+ this._checkbox.id = label_for;
175
+ this._label.setAttribute('for', label_for);
176
+ this._checkbox.checked = data.enabled;
177
+ this._label.innerText = data.name;
150
178
  }
151
179
  }
152
180
  export default LayerSwitcher;
@@ -12,10 +12,22 @@
12
12
  background: white;
13
13
  padding-left: 8px;
14
14
  padding-right: 8px;
15
- position: relative;
15
+ position: absolute;
16
16
  display: none;
17
17
  margin: 0 !important;
18
18
  font-size: 15px;
19
+ z-index: 1000;
20
+ border-radius: 4px;
21
+ }
22
+
23
+ @media screen and (max-width: 900px) {
24
+ .layer-switcher-list {
25
+ position: fixed;
26
+ top: 50px;
27
+ left: 10px;
28
+ right: 10px;
29
+ font-size: 20px;
30
+ }
19
31
  }
20
32
 
21
33
  .layer-switcher-list h3 {
@@ -44,4 +56,4 @@
44
56
 
45
57
  .layer-switcher-list label {
46
58
  float: left;
47
- }
59
+ }
@@ -1 +1 @@
1
- {"program":{"fileNames":["../node_modules/typescript/lib/lib.es5.d.ts","../node_modules/typescript/lib/lib.es2015.d.ts","../node_modules/typescript/lib/lib.es2016.d.ts","../node_modules/typescript/lib/lib.dom.d.ts","../node_modules/typescript/lib/lib.dom.iterable.d.ts","../node_modules/typescript/lib/lib.webworker.importscripts.d.ts","../node_modules/typescript/lib/lib.scripthost.d.ts","../node_modules/typescript/lib/lib.es2015.core.d.ts","../node_modules/typescript/lib/lib.es2015.collection.d.ts","../node_modules/typescript/lib/lib.es2015.generator.d.ts","../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../node_modules/typescript/lib/lib.es2015.promise.d.ts","../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../node_modules/typescript/lib/lib.decorators.d.ts","../node_modules/typescript/lib/lib.decorators.legacy.d.ts","../node_modules/typescript/lib/lib.es2016.full.d.ts","../node_modules/redom/index.d.ts","../node_modules/@types/lodash/common/common.d.ts","../node_modules/@types/lodash/common/array.d.ts","../node_modules/@types/lodash/common/collection.d.ts","../node_modules/@types/lodash/common/date.d.ts","../node_modules/@types/lodash/common/function.d.ts","../node_modules/@types/lodash/common/lang.d.ts","../node_modules/@types/lodash/common/math.d.ts","../node_modules/@types/lodash/common/number.d.ts","../node_modules/@types/lodash/common/object.d.ts","../node_modules/@types/lodash/common/seq.d.ts","../node_modules/@types/lodash/common/string.d.ts","../node_modules/@types/lodash/common/util.d.ts","../node_modules/@types/lodash/index.d.ts","../node_modules/@types/lodash.invert/index.d.ts","../node_modules/@types/lodash.isequal/index.d.ts","../node_modules/@types/mapbox__point-geometry/index.d.ts","../node_modules/@mapbox/tiny-sdf/index.d.ts","../node_modules/@types/pbf/index.d.ts","../node_modules/@types/geojson/index.d.ts","../node_modules/@types/mapbox__vector-tile/index.d.ts","../node_modules/@maplibre/maplibre-gl-style-spec/dist/index.d.ts","../node_modules/gl-matrix/index.d.ts","../node_modules/kdbush/index.d.ts","../node_modules/potpack/index.d.ts","../node_modules/maplibre-gl/dist/maplibre-gl.d.ts","../src/urlhash.ts","../src/index.ts"],"fileInfos":[{"version":"f59215c5f1d886b05395ee7aca73e0ac69ddfad2843aa88530e797879d511bad","affectsGlobalScope":true},"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","dc48272d7c333ccf58034c0026162576b7d50ea0e69c3b9292f803fc20720fd5",{"version":"3dda5344576193a4ae48b8d03f105c86f20b2f2aff0a1d1fd7935f5d68649654","affectsGlobalScope":true},{"version":"35299ae4a62086698444a5aaee27fc7aa377c68cbb90b441c9ace246ffd05c97","affectsGlobalScope":true},{"version":"c5c5565225fce2ede835725a92a28ece149f83542aa4866cfb10290bff7b8996","affectsGlobalScope":true},{"version":"7d2dbc2a0250400af0809b0ad5f84686e84c73526de931f84560e483eb16b03c","affectsGlobalScope":true},{"version":"9d9885c728913c1d16e0d2831b40341d6ad9a0ceecaabc55209b306ad9c736a5","affectsGlobalScope":true},{"version":"17bea081b9c0541f39dd1ae9bc8c78bdd561879a682e60e2f25f688c0ecab248","affectsGlobalScope":true},{"version":"4443e68b35f3332f753eacc66a04ac1d2053b8b035a0e0ac1d455392b5e243b3","affectsGlobalScope":true},{"version":"ab22100fdd0d24cfc2cc59d0a00fc8cf449830d9c4030dc54390a46bd562e929","affectsGlobalScope":true},{"version":"f7bd636ae3a4623c503359ada74510c4005df5b36de7f23e1db8a5c543fd176b","affectsGlobalScope":true},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true},{"version":"0c20f4d2358eb679e4ae8a4432bdd96c857a2960fd6800b21ec4008ec59d60ea","affectsGlobalScope":true},{"version":"36ae84ccc0633f7c0787bc6108386c8b773e95d3b052d9464a99cd9b8795fbec","affectsGlobalScope":true},{"version":"82d0d8e269b9eeac02c3bd1c9e884e85d483fcb2cd168bccd6bc54df663da031","affectsGlobalScope":true},{"version":"189c0703923150aa30673fa3de411346d727cc44a11c75d05d7cf9ef095daa22","affectsGlobalScope":true},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true},"11d072996eb4179a2697bb0cbaaa6372bd0ec2890d7ea25bc8b17454e2bce322","332f8e56efa13b367cb696e2036918d80887b13177c12acda6d49ee145c333ca","675e702f2032766a91eeadee64f51014c64688525da99dccd8178f0c599f13a8","458111fc89d11d2151277c822dfdc1a28fa5b6b2493cf942e37d4cd0a6ee5f22","19c816167e076e7c24f074389c6cf3ed87bdbb917d1ea439ca281f9d26db2439","187119ff4f9553676a884e296089e131e8cc01691c546273b1d0089c3533ce42","febf0b2de54781102b00f61653b21377390a048fbf5262718c91860d11ff34a6","98f9d826db9cd99d27a01a59ee5f22863df00ccf1aaf43e1d7db80ebf716f7c3","0aaef8cded245bf5036a7a40b65622dd6c4da71f7a35343112edbe112b348a1e","00baffbe8a2f2e4875367479489b5d43b5fc1429ecb4a4cc98cfc3009095f52a","dcd91d3b697cb650b95db5471189b99815af5db2a1cd28760f91e0b12ede8ed5","3c92b6dfd43cc1c2485d9eba5ff0b74a19bb8725b692773ef1d66dac48cda4bd","3cf0d343c2276842a5b617f22ba82af6322c7cfe8bb52238ffc0c491a3c21019","df996e25faa505f85aeb294d15ebe61b399cf1d1e49959cdfaf2cc0815c203f9",{"version":"f2eff8704452659641164876c1ef0df4174659ce7311b0665798ea3f556fa9ad","affectsGlobalScope":true},"b578be2890bf15a1a9b3b8177ff0975c99bae05f5422241452fe810eec3bff1c","6bb8d7433a29fbd33df8e9693f1788a273a9eb90b96c8f99c745678c7db623f1","e86cd9c6c99834f8591ed72f08e4ca31570296f081206d0168f58f032cec5b58","bc8b2489bf29fa17cf4e7d5a4447daa456d7caf61455f50aafc34f1f3b915727","2a856615ecd0af49997dfbb38cf94fd787d529062a2e96ce26b84432e61d785d","a3b6c93a9838b8c94c6998e85646d6f2d07c20ecfe1e235dba62158b29451391","ab438f22fa7748112b6b9744b992ab6049d2fa6f46f011c145ff9c90e533856a","e92ff9eccdb74e9bf34e9dcbd3525252b021ff7fd763e63c95d80c9e0eeb8406","6b729c3274f6d4738fe470109bcb08b09ef98a6b356c01da3ca8dc0996b4458b","4dbf094f9d643b74e516779a802d9c5debd2929fb875ccfbc608d61afba064e4","828ea2cf5792eba68ebd41d6dd17ac67d31622b7889965210f8fa50a6eb29eba","41d979b791363582ff485524e0db7d2312207a811d5f08e92566733ab90dde9f",{"version":"f33c46469c28f89f45e647fc0755cba1d4418ac3b8ac574d114a1b04c5103d3b","signature":"5ae269adda301545c45591e630c59df52e125cadc456f485e1d8b3c577fbbe9c"},{"version":"08aa3ed586993e892107dcc47902f90eb087d2616e1719c1dc608a6506d85ac5","signature":"d645d65f83ca9d4a8c9c1fa8566c6c3a2ecb5b965a09bb3157a1dbeb9c21ac14"}],"root":[47,48],"options":{"esModuleInterop":true,"module":5,"outDir":"./","strict":true,"target":3},"fileIdsList":[[37],[34],[22,24,25,26,27,28,29,30,31,32,33,34],[22,23,25,26,27,28,29,30,31,32,33,34],[23,24,25,26,27,28,29,30,31,32,33,34],[22,23,24,26,27,28,29,30,31,32,33,34],[22,23,24,25,27,28,29,30,31,32,33,34],[22,23,24,25,26,28,29,30,31,32,33,34],[22,23,24,25,26,27,29,30,31,32,33,34],[22,23,24,25,26,27,28,30,31,32,33,34],[22,23,24,25,26,27,28,29,31,32,33,34],[22,23,24,25,26,27,28,29,30,32,33,34],[22,23,24,25,26,27,28,29,30,31,33,34],[22,23,24,25,26,27,28,29,30,31,32,34],[22,23,24,25,26,27,28,29,30,31,32,33],[37,39,40],[37,38,41,42,43,44,45],[21,35,36,46,47],[46,48],[47],[48]],"referencedMap":[[42,1],[35,2],[36,2],[23,3],[24,4],[22,5],[25,6],[26,7],[27,8],[28,9],[29,10],[30,11],[31,12],[32,13],[33,14],[34,15],[41,16],[46,17],[48,18],[47,19]],"exportedModulesMap":[[42,1],[35,2],[36,2],[23,3],[24,4],[22,5],[25,6],[26,7],[27,8],[28,9],[29,10],[30,11],[31,12],[32,13],[33,14],[34,15],[41,16],[46,17],[48,20],[47,21]],"semanticDiagnosticsPerFile":[38,42,40,35,36,23,24,22,25,26,27,28,29,30,31,32,33,34,37,41,39,43,44,46,45,21,18,19,4,5,9,8,2,10,11,12,13,14,15,16,17,3,20,1,7,6,48,47]},"version":"5.1.6"}
1
+ {"program":{"fileNames":["../node_modules/typescript/lib/lib.es5.d.ts","../node_modules/typescript/lib/lib.es2015.d.ts","../node_modules/typescript/lib/lib.es2016.d.ts","../node_modules/typescript/lib/lib.es2017.d.ts","../node_modules/typescript/lib/lib.es2018.d.ts","../node_modules/typescript/lib/lib.es2019.d.ts","../node_modules/typescript/lib/lib.es2020.d.ts","../node_modules/typescript/lib/lib.dom.d.ts","../node_modules/typescript/lib/lib.dom.iterable.d.ts","../node_modules/typescript/lib/lib.webworker.importscripts.d.ts","../node_modules/typescript/lib/lib.scripthost.d.ts","../node_modules/typescript/lib/lib.es2015.core.d.ts","../node_modules/typescript/lib/lib.es2015.collection.d.ts","../node_modules/typescript/lib/lib.es2015.generator.d.ts","../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../node_modules/typescript/lib/lib.es2015.promise.d.ts","../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../node_modules/typescript/lib/lib.es2017.object.d.ts","../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../node_modules/typescript/lib/lib.es2017.string.d.ts","../node_modules/typescript/lib/lib.es2017.intl.d.ts","../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../node_modules/typescript/lib/lib.es2018.intl.d.ts","../node_modules/typescript/lib/lib.es2018.promise.d.ts","../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../node_modules/typescript/lib/lib.es2019.array.d.ts","../node_modules/typescript/lib/lib.es2019.object.d.ts","../node_modules/typescript/lib/lib.es2019.string.d.ts","../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../node_modules/typescript/lib/lib.es2019.intl.d.ts","../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../node_modules/typescript/lib/lib.es2020.date.d.ts","../node_modules/typescript/lib/lib.es2020.promise.d.ts","../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../node_modules/typescript/lib/lib.es2020.string.d.ts","../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../node_modules/typescript/lib/lib.es2020.intl.d.ts","../node_modules/typescript/lib/lib.es2020.number.d.ts","../node_modules/typescript/lib/lib.esnext.intl.d.ts","../node_modules/typescript/lib/lib.decorators.d.ts","../node_modules/typescript/lib/lib.decorators.legacy.d.ts","../node_modules/typescript/lib/lib.es2016.full.d.ts","../node_modules/redom/index.d.ts","../node_modules/@types/lodash/common/common.d.ts","../node_modules/@types/lodash/common/array.d.ts","../node_modules/@types/lodash/common/collection.d.ts","../node_modules/@types/lodash/common/date.d.ts","../node_modules/@types/lodash/common/function.d.ts","../node_modules/@types/lodash/common/lang.d.ts","../node_modules/@types/lodash/common/math.d.ts","../node_modules/@types/lodash/common/number.d.ts","../node_modules/@types/lodash/common/object.d.ts","../node_modules/@types/lodash/common/seq.d.ts","../node_modules/@types/lodash/common/string.d.ts","../node_modules/@types/lodash/common/util.d.ts","../node_modules/@types/lodash/index.d.ts","../node_modules/@types/lodash.invert/index.d.ts","../node_modules/@types/lodash.isequal/index.d.ts","../node_modules/@types/mapbox__point-geometry/index.d.ts","../node_modules/@mapbox/tiny-sdf/index.d.ts","../node_modules/@types/pbf/index.d.ts","../node_modules/@types/geojson/index.d.ts","../node_modules/@types/mapbox__vector-tile/index.d.ts","../node_modules/@maplibre/maplibre-gl-style-spec/dist/index.d.ts","../node_modules/gl-matrix/index.d.ts","../node_modules/kdbush/index.d.ts","../node_modules/potpack/index.d.ts","../node_modules/maplibre-gl/dist/maplibre-gl.d.ts","../src/urlhash.ts","../src/index.ts","../src/urlhash.test.ts","../node_modules/@babel/types/lib/index.d.ts","../node_modules/@types/babel__generator/index.d.ts","../node_modules/@babel/parser/typings/babel-parser.d.ts","../node_modules/@types/babel__template/index.d.ts","../node_modules/@types/babel__traverse/index.d.ts","../node_modules/@types/babel__core/index.d.ts","../node_modules/@types/node/assert.d.ts","../node_modules/@types/node/assert/strict.d.ts","../node_modules/@types/node/globals.d.ts","../node_modules/@types/node/async_hooks.d.ts","../node_modules/@types/node/buffer.d.ts","../node_modules/@types/node/child_process.d.ts","../node_modules/@types/node/cluster.d.ts","../node_modules/@types/node/console.d.ts","../node_modules/@types/node/constants.d.ts","../node_modules/@types/node/crypto.d.ts","../node_modules/@types/node/dgram.d.ts","../node_modules/@types/node/diagnostics_channel.d.ts","../node_modules/@types/node/dns.d.ts","../node_modules/@types/node/dns/promises.d.ts","../node_modules/@types/node/domain.d.ts","../node_modules/@types/node/dom-events.d.ts","../node_modules/@types/node/events.d.ts","../node_modules/@types/node/fs.d.ts","../node_modules/@types/node/fs/promises.d.ts","../node_modules/@types/node/http.d.ts","../node_modules/@types/node/http2.d.ts","../node_modules/@types/node/https.d.ts","../node_modules/@types/node/inspector.d.ts","../node_modules/@types/node/module.d.ts","../node_modules/@types/node/net.d.ts","../node_modules/@types/node/os.d.ts","../node_modules/@types/node/path.d.ts","../node_modules/@types/node/perf_hooks.d.ts","../node_modules/@types/node/process.d.ts","../node_modules/@types/node/punycode.d.ts","../node_modules/@types/node/querystring.d.ts","../node_modules/@types/node/readline.d.ts","../node_modules/@types/node/readline/promises.d.ts","../node_modules/@types/node/repl.d.ts","../node_modules/@types/node/stream.d.ts","../node_modules/@types/node/stream/promises.d.ts","../node_modules/@types/node/stream/consumers.d.ts","../node_modules/@types/node/stream/web.d.ts","../node_modules/@types/node/string_decoder.d.ts","../node_modules/@types/node/test.d.ts","../node_modules/@types/node/timers.d.ts","../node_modules/@types/node/timers/promises.d.ts","../node_modules/@types/node/tls.d.ts","../node_modules/@types/node/trace_events.d.ts","../node_modules/@types/node/tty.d.ts","../node_modules/@types/node/url.d.ts","../node_modules/@types/node/util.d.ts","../node_modules/@types/node/v8.d.ts","../node_modules/@types/node/vm.d.ts","../node_modules/@types/node/wasi.d.ts","../node_modules/@types/node/worker_threads.d.ts","../node_modules/@types/node/zlib.d.ts","../node_modules/@types/node/globals.global.d.ts","../node_modules/@types/node/index.d.ts","../node_modules/@types/graceful-fs/index.d.ts","../node_modules/@types/istanbul-lib-coverage/index.d.ts","../node_modules/@types/istanbul-lib-report/index.d.ts","../node_modules/@types/istanbul-reports/index.d.ts","../node_modules/@jest/expect-utils/build/index.d.ts","../node_modules/chalk/index.d.ts","../node_modules/@sinclair/typebox/typebox.d.ts","../node_modules/@jest/schemas/build/index.d.ts","../node_modules/pretty-format/build/index.d.ts","../node_modules/jest-diff/build/index.d.ts","../node_modules/jest-matcher-utils/build/index.d.ts","../node_modules/expect/build/index.d.ts","../node_modules/@types/jest/index.d.ts","../node_modules/parse5/dist/common/html.d.ts","../node_modules/parse5/dist/common/token.d.ts","../node_modules/parse5/dist/common/error-codes.d.ts","../node_modules/parse5/dist/tokenizer/preprocessor.d.ts","../node_modules/parse5/dist/tokenizer/index.d.ts","../node_modules/parse5/dist/tree-adapters/interface.d.ts","../node_modules/parse5/dist/parser/open-element-stack.d.ts","../node_modules/parse5/dist/parser/formatting-element-list.d.ts","../node_modules/parse5/dist/parser/index.d.ts","../node_modules/parse5/dist/tree-adapters/default.d.ts","../node_modules/parse5/dist/serializer/index.d.ts","../node_modules/parse5/dist/common/foreign-content.d.ts","../node_modules/parse5/dist/index.d.ts","../node_modules/@types/tough-cookie/index.d.ts","../node_modules/@types/jsdom/base.d.ts","../node_modules/@types/jsdom/index.d.ts","../node_modules/@types/prettier/index.d.ts","../node_modules/@types/stack-utils/index.d.ts","../node_modules/@types/yargs-parser/index.d.ts","../node_modules/@types/yargs/index.d.ts"],"fileInfos":[{"version":"f59215c5f1d886b05395ee7aca73e0ac69ddfad2843aa88530e797879d511bad","affectsGlobalScope":true},"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","dc48272d7c333ccf58034c0026162576b7d50ea0e69c3b9292f803fc20720fd5","27147504487dc1159369da4f4da8a26406364624fa9bc3db632f7d94a5bae2c3","5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4",{"version":"3dda5344576193a4ae48b8d03f105c86f20b2f2aff0a1d1fd7935f5d68649654","affectsGlobalScope":true},{"version":"35299ae4a62086698444a5aaee27fc7aa377c68cbb90b441c9ace246ffd05c97","affectsGlobalScope":true},{"version":"c5c5565225fce2ede835725a92a28ece149f83542aa4866cfb10290bff7b8996","affectsGlobalScope":true},{"version":"7d2dbc2a0250400af0809b0ad5f84686e84c73526de931f84560e483eb16b03c","affectsGlobalScope":true},{"version":"9d9885c728913c1d16e0d2831b40341d6ad9a0ceecaabc55209b306ad9c736a5","affectsGlobalScope":true},{"version":"17bea081b9c0541f39dd1ae9bc8c78bdd561879a682e60e2f25f688c0ecab248","affectsGlobalScope":true},{"version":"4443e68b35f3332f753eacc66a04ac1d2053b8b035a0e0ac1d455392b5e243b3","affectsGlobalScope":true},{"version":"ab22100fdd0d24cfc2cc59d0a00fc8cf449830d9c4030dc54390a46bd562e929","affectsGlobalScope":true},{"version":"f7bd636ae3a4623c503359ada74510c4005df5b36de7f23e1db8a5c543fd176b","affectsGlobalScope":true},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true},{"version":"0c20f4d2358eb679e4ae8a4432bdd96c857a2960fd6800b21ec4008ec59d60ea","affectsGlobalScope":true},{"version":"36ae84ccc0633f7c0787bc6108386c8b773e95d3b052d9464a99cd9b8795fbec","affectsGlobalScope":true},{"version":"82d0d8e269b9eeac02c3bd1c9e884e85d483fcb2cd168bccd6bc54df663da031","affectsGlobalScope":true},{"version":"b8deab98702588840be73d67f02412a2d45a417a3c097b2e96f7f3a42ac483d1","affectsGlobalScope":true},{"version":"4738f2420687fd85629c9efb470793bb753709c2379e5f85bc1815d875ceadcd","affectsGlobalScope":true},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true},{"version":"376d554d042fb409cb55b5cbaf0b2b4b7e669619493c5d18d5fa8bd67273f82a","affectsGlobalScope":true},{"version":"9fc46429fbe091ac5ad2608c657201eb68b6f1b8341bd6d670047d32ed0a88fa","affectsGlobalScope":true},{"version":"61c37c1de663cf4171e1192466e52c7a382afa58da01b1dc75058f032ddf0839","affectsGlobalScope":true},{"version":"c4138a3dd7cd6cf1f363ca0f905554e8d81b45844feea17786cdf1626cb8ea06","affectsGlobalScope":true},{"version":"6ff3e2452b055d8f0ec026511c6582b55d935675af67cdb67dd1dc671e8065df","affectsGlobalScope":true},{"version":"03de17b810f426a2f47396b0b99b53a82c1b60e9cba7a7edda47f9bb077882f4","affectsGlobalScope":true},{"version":"8184c6ddf48f0c98429326b428478ecc6143c27f79b79e85740f17e6feb090f1","affectsGlobalScope":true},{"version":"261c4d2cf86ac5a89ad3fb3fafed74cbb6f2f7c1d139b0540933df567d64a6ca","affectsGlobalScope":true},{"version":"6af1425e9973f4924fca986636ac19a0cf9909a7e0d9d3009c349e6244e957b6","affectsGlobalScope":true},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true},{"version":"15a630d6817718a2ddd7088c4f83e4673fde19fa992d2eae2cf51132a302a5d3","affectsGlobalScope":true},{"version":"f06948deb2a51aae25184561c9640fb66afeddb34531a9212d011792b1d19e0a","affectsGlobalScope":true},{"version":"01e0ee7e1f661acedb08b51f8a9b7d7f959e9cdb6441360f06522cc3aea1bf2e","affectsGlobalScope":true},{"version":"ac17a97f816d53d9dd79b0d235e1c0ed54a8cc6a0677e9a3d61efb480b2a3e4e","affectsGlobalScope":true},{"version":"bf14a426dbbf1022d11bd08d6b8e709a2e9d246f0c6c1032f3b2edb9a902adbe","affectsGlobalScope":true},{"version":"ec0104fee478075cb5171e5f4e3f23add8e02d845ae0165bfa3f1099241fa2aa","affectsGlobalScope":true},{"version":"2b72d528b2e2fe3c57889ca7baef5e13a56c957b946906d03767c642f386bbc3","affectsGlobalScope":true},{"version":"9cc66b0513ad41cb5f5372cca86ef83a0d37d1c1017580b7dace3ea5661836df","affectsGlobalScope":true},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true},{"version":"307c8b7ebbd7f23a92b73a4c6c0a697beca05b06b036c23a34553e5fe65e4fdc","affectsGlobalScope":true},{"version":"189c0703923150aa30673fa3de411346d727cc44a11c75d05d7cf9ef095daa22","affectsGlobalScope":true},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true},"11d072996eb4179a2697bb0cbaaa6372bd0ec2890d7ea25bc8b17454e2bce322","332f8e56efa13b367cb696e2036918d80887b13177c12acda6d49ee145c333ca","675e702f2032766a91eeadee64f51014c64688525da99dccd8178f0c599f13a8","458111fc89d11d2151277c822dfdc1a28fa5b6b2493cf942e37d4cd0a6ee5f22","19c816167e076e7c24f074389c6cf3ed87bdbb917d1ea439ca281f9d26db2439","187119ff4f9553676a884e296089e131e8cc01691c546273b1d0089c3533ce42","febf0b2de54781102b00f61653b21377390a048fbf5262718c91860d11ff34a6","98f9d826db9cd99d27a01a59ee5f22863df00ccf1aaf43e1d7db80ebf716f7c3","0aaef8cded245bf5036a7a40b65622dd6c4da71f7a35343112edbe112b348a1e","00baffbe8a2f2e4875367479489b5d43b5fc1429ecb4a4cc98cfc3009095f52a","dcd91d3b697cb650b95db5471189b99815af5db2a1cd28760f91e0b12ede8ed5","3c92b6dfd43cc1c2485d9eba5ff0b74a19bb8725b692773ef1d66dac48cda4bd","3cf0d343c2276842a5b617f22ba82af6322c7cfe8bb52238ffc0c491a3c21019","df996e25faa505f85aeb294d15ebe61b399cf1d1e49959cdfaf2cc0815c203f9",{"version":"f2eff8704452659641164876c1ef0df4174659ce7311b0665798ea3f556fa9ad","affectsGlobalScope":true},"b578be2890bf15a1a9b3b8177ff0975c99bae05f5422241452fe810eec3bff1c","6bb8d7433a29fbd33df8e9693f1788a273a9eb90b96c8f99c745678c7db623f1","e86cd9c6c99834f8591ed72f08e4ca31570296f081206d0168f58f032cec5b58","bc8b2489bf29fa17cf4e7d5a4447daa456d7caf61455f50aafc34f1f3b915727","2a856615ecd0af49997dfbb38cf94fd787d529062a2e96ce26b84432e61d785d","a3b6c93a9838b8c94c6998e85646d6f2d07c20ecfe1e235dba62158b29451391","ab438f22fa7748112b6b9744b992ab6049d2fa6f46f011c145ff9c90e533856a","e92ff9eccdb74e9bf34e9dcbd3525252b021ff7fd763e63c95d80c9e0eeb8406","6b729c3274f6d4738fe470109bcb08b09ef98a6b356c01da3ca8dc0996b4458b","4dbf094f9d643b74e516779a802d9c5debd2929fb875ccfbc608d61afba064e4","828ea2cf5792eba68ebd41d6dd17ac67d31622b7889965210f8fa50a6eb29eba","41d979b791363582ff485524e0db7d2312207a811d5f08e92566733ab90dde9f",{"version":"38fb200a6eedb5e68b673da82cb31d0e8137eb426e2bd5a694f412163a4c76ef","signature":"a881b9df48e5f910818dfab8ea1e2a74bfdbc51ad638f3fb980c8c86ba023583"},{"version":"0cc96e6f8f0d3a7474dc74af13121d6b91f825806366d92a311322b82261ced3","signature":"598868f3dd681bf8895043048b33e95d3149d53e00440e3d5762af2fdb1f3301"},{"version":"3234998ed4c3fc9a7e8dee958ac41398fb1ec1883c4b0e107a189102e7eddf3f","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"},"ac65f04c2df0218cb8e54f012745cbfcc3c0e67c1f6b1e557d88842bbb72e2db","cc957354aa3c94c9961ebf46282cfde1e81d107fc5785a61f62c67f1dd3ac2eb","a2e86df4db576d80704e25293cec6f20fc6101a11f4747440e2eef58fb3c860c","93de1c6dab503f053efe8d304cb522bb3a89feab8c98f307a674a4fae04773e9","6704f0b54df85640baaeebd86c9d4a1dbb661d5a4d57a75bc84162f562f6531d","9d255af1b09c6697089d3c9bf438292a298d8b7a95c68793c9aae80afc9e5ca7","587f13f1e8157bd8cec0adda0de4ef558bb8573daa9d518d1e2af38e87ecc91f","a69c09dbea52352f479d3e7ac949fde3d17b195abe90b045d619f747b38d6d1a",{"version":"bce910d9164785c9f0d4dcea4be359f5f92130c7c7833dea6138ab1db310a1f9","affectsGlobalScope":true},"7a435e0c814f58f23e9a0979045ec0ef5909aac95a70986e8bcce30c27dff228",{"version":"c81c51f43e343b6d89114b17341fb9d381c4ccbb25e0ee77532376052c801ba7","affectsGlobalScope":true},"db71be322f07f769200108aa19b79a75dd19a187c9dca2a30c4537b233aa2863","57135ce61976a8b1dadd01bb412406d1805b90db6e8ecb726d0d78e0b5f76050",{"version":"49479e21a040c0177d1b1bc05a124c0383df7a08a0726ad4d9457619642e875a","affectsGlobalScope":true},"82408ed3e959ddc60d3e9904481b5a8dc16469928257af22a3f7d1a3bc7fd8c4","f302f3a47d7758f67f2afc753b9375d6504dde05d2e6ecdb1df50abbb131fc89","3690133deae19c8127c5505fcb67b04bdc9eb053796008538a9b9abbb70d85aa","5b1c0a23f464f894e7c2b2b6c56df7b9afa60ed48c5345f8618d389a636b2108","be2b092f2765222757c6441b86c53a5ea8dfed47bbc43eab4c5fe37942c866b3","8e6b05abc98adba15e1ac78e137c64576c74002e301d682e66feb77a23907ab8","1ca735bb3d407b2af4fbee7665f3a0a83be52168c728cc209755060ba7ed67bd",{"version":"6b526a5ec4a401ca7c26cfe6a48e641d8f30af76673bad3b06a1b4504594a960","affectsGlobalScope":true},{"version":"b85c02e14ecb2a873dad5a1de72319b265160ba48f1b83661aeb3bba1366c1bc","affectsGlobalScope":true},"7a2ba0c9af860ac3e77b35ed01fd96d15986f17aa22fe40f188ae556fb1070df","fc3764040518a1008dd04bdc80964591b566b896283e00df85c95851c1f46237","55709608060f77965c270ac10ac646286589f1bd1cb174fff1778a2dd9a7ef31","790623a47c5eda62910098884ecb154dc0e5f3a23fc36c1bfb3b5b9ed44e2c2d","42b40e40f2a358cda332456214fad311e1806a6abf3cebaaac72496e07556642","354612fe1d49ecc9551ea3a27d94eef2887b64ef4a71f72ca444efe0f2f0ba80",{"version":"ac0c77cd7db52b3c278bdd1452ce754014835493d05b84535f46854fdc2063b2","affectsGlobalScope":true},"b9f36877501f2ce0e276e993c93cd2cf325e78d0409ec4612b1eb9d6a537e60b","5e2b91328a540a0933ab5c2203f4358918e6f0fe7505d22840a891a6117735f1","3abc3512fa04aa0230f59ea1019311fd8667bd935d28306311dccc8b17e79d5d",{"version":"14a50dafe3f45713f7f27cb6320dff07c6ac31678f07959c2134260061bf91ff","affectsGlobalScope":true},{"version":"19da7150ca062323b1db6311a6ef058c9b0a39cc64d836b5e9b75d301869653b","affectsGlobalScope":true},"1349077576abb41f0e9c78ec30762ff75b710208aff77f5fdcc6a8c8ce6289dd","e2ce82603102b5c0563f59fb40314cc1ff95a4d521a66ad14146e130ea80d89c","a3e0395220255a350aa9c6d56f882bfcb5b85c19fddf5419ec822cf22246a26d","c27b01e8ddff5cd280711af5e13aecd9a3228d1c256ea797dd64f8fdec5f7df5","898840e876dfd21843db9f2aa6ae38ba2eab550eb780ff62b894b9fbfebfae6b","0cab4d7d4edc40cd3af9eea7c3ed6d1016910c0954c49c4297e479bf3822a625","1b952304137851e45bc009785de89ada562d9376177c97e37702e39e60c2f1ff","785e5be57d4f20f290a20e7b0c6263f6c57fd6e51283050756cef07d6d651c68","44b8b584a338b190a59f4f6929d072431950c7bd92ec2694821c11bce180c8a5","164deb2409ac5f4da3cd139dbcee7f7d66753d90363a4d7e2db8d8874f272270",{"version":"ffc62d73b4fa10ca8c59f8802df88efefe447025730a24ee977b60adedc5bf37","affectsGlobalScope":true},{"version":"ab294c4b7279318ee2a8fdf681305457ecc05970c94108d304933f18823eeac1","affectsGlobalScope":true},"ad08154d9602429522cac965a715fde27d421d69b24756c5d291877dda75353e","5bc85813bfcb6907cc3a960fec8734a29d7884e0e372515147720c5991b8bc22","812b25f798033c202baedf386a1ccc41f9191b122f089bffd10fdccce99fba11","993325544790073f77e945bee046d53988c0bc3ac5695c9cf8098166feb82661",{"version":"75dd741ca6a6c8d2437a6ca8349b64b816421dbf9fe82dd026afaba965576962","affectsGlobalScope":true},{"version":"0e08c360c9b5961ecb0537b703e253842b3ded53151ee07024148219b61a8baf","affectsGlobalScope":true},"2ce2210032ccaff7710e2abf6a722e62c54960458e73e356b6a365c93ab6ca66","92db194ef7d208d5e4b6242a3434573fd142a621ff996d84cc9dbba3553277d0","16a3080e885ed52d4017c902227a8d0d8daf723d062bec9e45627c6fdcd6699b",{"version":"0bd9543cd8fc0959c76fb8f4f5a26626c2ed62ef4be98fd857bce268066db0a2","affectsGlobalScope":true},"1ca6858a0cbcd74d7db72d7b14c5360a928d1d16748a55ecfa6bfaff8b83071b",{"version":"ab9b9a36e5284fd8d3bf2f7d5fcbc60052f25f27e4d20954782099282c60d23e","affectsGlobalScope":true},"ebf3434b09c527078aa74139ff367fffa64fea32a01d6c06fb0a69b0ecadf43e","bf88ef4208a770ca39a844b182b3695df536326ea566893fdc5b8418702a331e","8b06ac3faeacb8484d84ddb44571d8f410697f98d7bfa86c0fda60373a9f5215","7eb06594824ada538b1d8b48c3925a83e7db792f47a081a62cf3e5c4e23cf0ee","f5638f7c2f12a9a1a57b5c41b3c1ea7db3876c003bab68e6a57afd6bcc169af0","6c1e688f95fcaf53b1e41c0fdadf2c1cfc96fa924eaf7f9fdb60f96deb0a4986","0d14fa22c41fdc7277e6f71473b20ebc07f40f00e38875142335d5b63cdfc9d2","c085e9aa62d1ae1375794c1fb927a445fa105fed891a7e24edbb1c3300f7384a","f315e1e65a1f80992f0509e84e4ae2df15ecd9ef73df975f7c98813b71e4c8da","5b9586e9b0b6322e5bfbd2c29bd3b8e21ab9d871f82346cb71020e3d84bae73e","3e70a7e67c2cb16f8cd49097360c0309fe9d1e3210ff9222e9dac1f8df9d4fb6","ab68d2a3e3e8767c3fba8f80de099a1cfc18c0de79e42cb02ae66e22dfe14a66","6d969939c4a63f70f2aa49e88da6f64b655c8e6799612807bef41ccff6ea0da9",{"version":"b2fdcc3836d425833af10e536ae5491c34e218bc71870f12a401720f874b6ce4","affectsGlobalScope":true},"3411c785dbe8fd42f7d644d1e05a7e72b624774a08a9356479754999419c3c5a","8fb8fdda477cd7382477ffda92c2bb7d9f7ef583b1aa531eb6b2dc2f0a206c10","66995b0c991b5c5d42eff1d950733f85482c7419f7296ab8952e03718169e379","33f3795a4617f98b1bb8dac36312119d02f31897ae75436a1e109ce042b48ee8","2850c9c5dc28d34ad5f354117d0419f325fc8932d2a62eadc4dc52c018cd569b","c753948f7e0febe7aa1a5b71a714001a127a68861309b2c4127775aa9b6d4f24","3e7a40e023e1d4a9eef1a6f08a3ded8edacb67ae5fce072014205d730f717ba5","a77be6fc44c876bc10c897107f84eaba10790913ebdcad40fcda7e47469b2160","382100b010774614310d994bbf16cc9cd291c14f0d417126c7a7cfad1dc1d3f8","91f5dbcdb25d145a56cffe957ec665256827892d779ef108eb2f3864faff523b","4fdf56315340bd1770eb52e1601c3a98e45b1d207202831357e99ce29c35b55c","927955a3de5857e0a1c575ced5a4245e74e6821d720ed213141347dd1870197f","be6fd74528b32986fbf0cd2cfa9192a5ed7f369060b32a7adcb0c8d055708e61","cc256fd958b33576ed32c7338c64adb0d08fc0c2c6525010202fab83f32745da","fd0589ca571ad090b531d8c095e26caa53d4825c64d3ff2b2b1ab95d72294175",{"version":"669843ecafb89ae1e944df06360e8966219e4c1c34c0d28aa2503272cdd444a7","affectsGlobalScope":true},"d88a5e779faf033be3d52142a04fbe1cb96009868e3bbdd296b2bc6c59e06c0e","b0d10e46cfe3f6c476b69af02eaa38e4ccc7430221ce3109ae84bb9fb8282298","70e9a18da08294f75bf23e46c7d69e67634c0765d355887b9b41f0d959e1426e","e9eb1b173aa166892f3eddab182e49cfe59aa2e14d33aedb6b49d175ed6a3750"],"root":[[75,77]],"options":{"declaration":true,"declarationMap":true,"esModuleInterop":true,"module":5,"outDir":"./","strict":true,"target":3},"fileIdsList":[[78,130],[130],[130,144],[65,130],[78,79,80,81,82,130],[78,80,130],[101,130,137],[130,139],[130,140],[130,146,149],[100,130,132,137,163,164,166],[130,165],[62,130],[50,52,53,54,55,56,57,58,59,60,61,62,130],[50,51,53,54,55,56,57,58,59,60,61,62,130],[51,52,53,54,55,56,57,58,59,60,61,62,130],[50,51,52,54,55,56,57,58,59,60,61,62,130],[50,51,52,53,55,56,57,58,59,60,61,62,130],[50,51,52,53,54,56,57,58,59,60,61,62,130],[50,51,52,53,54,55,57,58,59,60,61,62,130],[50,51,52,53,54,55,56,58,59,60,61,62,130],[50,51,52,53,54,55,56,57,59,60,61,62,130],[50,51,52,53,54,55,56,57,58,60,61,62,130],[50,51,52,53,54,55,56,57,58,59,61,62,130],[50,51,52,53,54,55,56,57,58,59,60,62,130],[50,51,52,53,54,55,56,57,58,59,60,61,130],[65,67,68,130],[84,130],[87,130],[88,93,121,130],[89,100,101,108,118,129,130],[89,90,100,108,130],[91,130],[92,93,101,109,130],[93,118,126,130],[94,96,100,108,130],[95,130],[96,97,130],[100,130],[98,100,130],[100,101,102,118,129,130],[100,101,102,115,118,121,130],[130,134],[96,100,103,108,118,129,130],[100,101,103,104,108,118,126,129,130],[103,105,118,126,129,130],[84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136],[100,106,130],[107,129,130],[96,100,108,118,130],[109,130],[110,130],[87,111,130],[112,128,130,134],[113,130],[114,130],[100,115,116,130],[115,117,130,132],[88,100,118,119,120,121,130],[88,118,120,130],[118,119,130],[121,130],[122,130],[118,130],[100,124,125,130],[124,125,130],[93,108,118,126,130],[127,130],[108,128,130],[88,103,114,129,130],[93,130],[118,130,131],[130,132],[130,133],[88,93,100,102,111,118,129,130,132,134],[118,130,135],[130,169],[87,130,137,142,148],[130,146],[130,143,147],[65,66,69,70,71,72,73,130],[130,152],[130,151,152],[130,151],[130,151,152,153,155,156,159,160,161,162],[130,152,156],[130,151,152,153,155,156,157,158],[130,151,156],[130,156,160],[130,152,153,154],[130,153],[130,151,152,156],[130,145],[49,63,64,74,75,130],[75,76,130],[74,76,130],[65],[62],[50,52,53,54,55,56,57,58,59,60,61,62],[50,51,53,54,55,56,57,58,59,60,61,62],[51,52,53,54,55,56,57,58,59,60,61,62],[50,51,52,54,55,56,57,58,59,60,61,62],[50,51,52,53,55,56,57,58,59,60,61,62],[50,51,52,53,54,56,57,58,59,60,61,62],[50,51,52,53,54,55,57,58,59,60,61,62],[50,51,52,53,54,55,56,58,59,60,61,62],[50,51,52,53,54,55,56,57,59,60,61,62],[50,51,52,53,54,55,56,57,58,60,61,62],[50,51,52,53,54,55,56,57,58,59,61,62],[50,51,52,53,54,55,56,57,58,59,60,62],[50,51,52,53,54,55,56,57,58,59,60,61],[65,67,68],[65,66,69,70,71,72,73],[49,75],[76]],"referencedMap":[[80,1],[78,2],[142,2],[145,3],[66,2],[70,4],[144,2],[83,5],[79,1],[81,6],[82,1],[68,2],[138,7],[139,2],[140,8],[141,9],[150,10],[165,11],[166,12],[63,13],[64,13],[51,14],[52,15],[50,16],[53,17],[54,18],[55,19],[56,20],[57,21],[58,22],[59,23],[60,24],[61,25],[62,26],[65,2],[69,27],[84,28],[85,28],[87,29],[88,30],[89,31],[90,32],[91,33],[92,34],[93,35],[94,36],[95,37],[96,38],[97,38],[99,39],[98,40],[100,39],[101,41],[102,42],[86,43],[136,2],[103,44],[104,45],[105,46],[137,47],[106,48],[107,49],[108,50],[109,51],[110,52],[111,53],[112,54],[113,55],[114,56],[115,57],[116,57],[117,58],[118,59],[120,60],[119,61],[121,62],[122,63],[123,64],[124,65],[125,66],[126,67],[127,68],[128,69],[129,70],[130,71],[131,72],[132,73],[133,74],[134,75],[135,76],[67,2],[167,2],[168,2],[164,2],[169,2],[170,77],[143,2],[149,78],[71,2],[147,79],[148,80],[72,2],[74,81],[153,82],[162,83],[151,2],[152,84],[163,85],[158,86],[159,87],[157,88],[161,89],[155,90],[154,91],[160,92],[156,83],[73,2],[146,93],[49,2],[46,2],[47,2],[8,2],[9,2],[13,2],[12,2],[2,2],[14,2],[15,2],[16,2],[17,2],[18,2],[19,2],[20,2],[21,2],[3,2],[48,2],[4,2],[25,2],[22,2],[23,2],[24,2],[26,2],[27,2],[28,2],[5,2],[29,2],[30,2],[31,2],[32,2],[6,2],[36,2],[33,2],[34,2],[35,2],[37,2],[7,2],[38,2],[43,2],[44,2],[39,2],[40,2],[41,2],[42,2],[1,2],[45,2],[11,2],[10,2],[76,94],[77,95],[75,96]],"exportedModulesMap":[[80,1],[78,2],[142,2],[145,3],[70,97],[144,2],[83,5],[79,1],[81,6],[82,1],[138,7],[139,2],[140,8],[141,9],[150,10],[165,11],[166,12],[63,98],[64,98],[51,99],[52,100],[50,101],[53,102],[54,103],[55,104],[56,105],[57,106],[58,107],[59,108],[60,109],[61,110],[62,111],[69,112],[84,28],[85,28],[87,29],[88,30],[89,31],[90,32],[91,33],[92,34],[93,35],[94,36],[95,37],[96,38],[97,38],[99,39],[98,40],[100,39],[101,41],[102,42],[86,43],[136,2],[103,44],[104,45],[105,46],[137,47],[106,48],[107,49],[108,50],[109,51],[110,52],[111,53],[112,54],[113,55],[114,56],[115,57],[116,57],[117,58],[118,59],[120,60],[119,61],[121,62],[122,63],[123,64],[124,65],[125,66],[126,67],[127,68],[128,69],[129,70],[130,71],[131,72],[132,73],[133,74],[134,75],[135,76],[167,2],[168,2],[164,2],[169,2],[170,77],[143,2],[149,78],[147,79],[148,80],[74,113],[153,82],[162,83],[151,2],[152,84],[163,85],[158,86],[159,87],[157,88],[161,89],[155,90],[154,91],[160,92],[156,83],[146,93],[4,2],[25,2],[22,2],[23,2],[24,2],[26,2],[27,2],[28,2],[5,2],[29,2],[30,2],[31,2],[32,2],[6,2],[36,2],[33,2],[34,2],[35,2],[37,2],[7,2],[38,2],[43,2],[44,2],[39,2],[40,2],[41,2],[42,2],[45,2],[76,114],[75,115]],"semanticDiagnosticsPerFile":[80,78,142,145,66,70,144,83,79,81,82,68,138,139,140,141,150,165,166,63,64,51,52,50,53,54,55,56,57,58,59,60,61,62,65,69,84,85,87,88,89,90,91,92,93,94,95,96,97,99,98,100,101,102,86,136,103,104,105,137,106,107,108,109,110,111,112,113,114,115,116,117,118,120,119,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,67,167,168,164,169,170,143,149,71,147,148,72,74,153,162,151,152,163,158,159,157,161,155,154,160,156,73,146,49,46,47,8,9,13,12,2,14,15,16,17,18,19,20,21,3,48,4,25,22,23,24,26,27,28,5,29,30,31,32,6,36,33,34,35,37,7,38,43,44,39,40,41,42,1,45,11,10,76,77,75]},"version":"5.1.6"}
@@ -0,0 +1,49 @@
1
+ import LayerSwitcher from './index';
2
+ export interface HashComponents {
3
+ zoom?: number;
4
+ center?: [number, number];
5
+ layers?: string;
6
+ additional: Record<string, string>;
7
+ }
8
+ export declare function decodeHash(hash: string): HashComponents;
9
+ export declare function encodeHash(components: HashComponents): string;
10
+ type ParameterCallbackFunction = (value: string | null) => void;
11
+ declare class URLHash {
12
+ layerSwitcher: LayerSwitcher;
13
+ _map: maplibregl.Map | undefined;
14
+ additional: Record<string, string>;
15
+ handlers: Record<string, ParameterCallbackFunction>;
16
+ constructor(layerSwitcher: LayerSwitcher);
17
+ enable(map: maplibregl.Map): void;
18
+ /**
19
+ * Register a handler for a URL hash parameter. The key will be included in
20
+ * the URL hash, so keep it as short as possible.
21
+ *
22
+ * @param key short key used to identify the parameter in the URL hash
23
+ * @param handler handler function that will be called when the parameter changes
24
+ */
25
+ registerHandler(key: string, handler: ParameterCallbackFunction): void;
26
+ /**
27
+ * Set a custom URL hash parameter. Use `registerHandler` to receive a notification
28
+ * when the parameter changes.
29
+ *
30
+ * @param key short key used to identify the parameter in the URL hash
31
+ * @param value the value of the parameter, or null to remove it.
32
+ */
33
+ setParameter(key: string, value: string | null): void;
34
+ _fireParameterChange(key: string, value: string | null): void;
35
+ _onHashChange(new_hash: string): void;
36
+ _updateHash(): void;
37
+ getHashString(): string;
38
+ /**
39
+ * Modify MapLibre GL map constructor options to include values from the URL hash.
40
+ *
41
+ * @param options the original options passed to the MapLibre GL `Map` constructor.
42
+ * You should include defaults for the `center` and `zoom` parameters.
43
+ * @returns an options object to be passed to the `Map` constructor, with the
44
+ * `center` and `zoom` parameters updated if necessary. Other options are untouched.
45
+ */
46
+ init(options: maplibregl.MapOptions): maplibregl.MapOptions;
47
+ }
48
+ export default URLHash;
49
+ //# sourceMappingURL=urlhash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"urlhash.d.ts","sourceRoot":"","sources":["../src/urlhash.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,SAAS,CAAC;AAGpC,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAsBvD;AAED,wBAAgB,UAAU,CAAC,UAAU,EAAE,cAAc,GAAG,MAAM,CA2B7D;AAED,KAAK,yBAAyB,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;AAEhE,cAAM,OAAO;IACX,aAAa,EAAE,aAAa,CAAC;IAC7B,IAAI,EAAE,UAAU,CAAC,GAAG,GAAG,SAAS,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAC;gBAExC,aAAa,EAAE,aAAa;IAMxC,MAAM,CAAC,GAAG,EAAE,UAAU,CAAC,GAAG;IAkB1B;;;;;;OAMG;IACH,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,yBAAyB;IAI/D;;;;;;OAMG;IACH,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAW9C,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAMtD,aAAa,CAAC,QAAQ,EAAE,MAAM;IA6B9B,WAAW;IASX,aAAa;IAkBb;;;;;;;OAOG;IACH,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,UAAU,GAAG,UAAU,CAAC,UAAU;CAS5D;AAED,eAAe,OAAO,CAAC"}
package/lib/urlhash.js CHANGED
@@ -1,55 +1,125 @@
1
+ export function decodeHash(hash) {
2
+ const loc = hash.replace('#', '').split('/');
3
+ let result = { additional: {} };
4
+ if (loc.length < 3) {
5
+ return result;
6
+ }
7
+ result.layers = '';
8
+ result.zoom = +loc[0];
9
+ result.center = [+loc[2], +loc[1]];
10
+ for (let i = 3; i < loc.length; i++) {
11
+ let component = loc[i];
12
+ let matches = component.match(/^(\w+)=(.*)$/);
13
+ if (matches) {
14
+ result.additional = result.additional || {};
15
+ result.additional[matches[1]] = matches[2];
16
+ }
17
+ else {
18
+ result.layers = component;
19
+ }
20
+ }
21
+ return result;
22
+ }
23
+ export function encodeHash(components) {
24
+ if (!components.zoom || !components.center) {
25
+ return '';
26
+ }
27
+ const zoom = Math.round(components.zoom * 100) / 100,
28
+ // derived from equation: 512px * 2^z / 360 / 10^d < 0.5px
29
+ precision = Math.ceil((zoom * Math.LN2 + Math.log(512 / 360 / 0.5)) / Math.LN10), m = Math.pow(10, precision), lng = Math.round(components.center[0] * m) / m, lat = Math.round(components.center[1] * m) / m;
30
+ // bearing = this._map.getBearing(),
31
+ // pitch = this._map.getPitch();
32
+ let hash = `#${zoom}/${lat}/${lng}`;
33
+ if (components.layers) {
34
+ hash += '/' + components.layers;
35
+ }
36
+ if (components.additional) {
37
+ for (let key in components.additional) {
38
+ hash += '/' + key + '=' + components.additional[key];
39
+ }
40
+ }
41
+ return hash;
42
+ }
1
43
  class URLHash {
2
44
  constructor(layerSwitcher) {
3
45
  this.layerSwitcher = layerSwitcher;
4
- this._onHashChange();
46
+ this.additional = {};
47
+ this.handlers = {};
5
48
  }
6
49
  enable(map) {
7
50
  this._map = map;
51
+ this._onHashChange(window.location.hash);
8
52
  map.on('moveend', () => {
9
53
  this._updateHash();
10
54
  });
11
55
  window.addEventListener('hashchange', () => {
12
- this._onHashChange();
56
+ this._onHashChange(window.location.hash);
13
57
  }, false);
14
58
  }
15
- _onHashChange() {
16
- const loc = window.location.hash.replace('#', '').split('/');
17
- if (loc.length >= 3) {
18
- let layerString = "";
19
- if (this._map) {
20
- this._map.jumpTo({
21
- center: [+loc[2], +loc[1]],
22
- zoom: +loc[0],
23
- });
59
+ /**
60
+ * Register a handler for a URL hash parameter. The key will be included in
61
+ * the URL hash, so keep it as short as possible.
62
+ *
63
+ * @param key short key used to identify the parameter in the URL hash
64
+ * @param handler handler function that will be called when the parameter changes
65
+ */
66
+ registerHandler(key, handler) {
67
+ this.handlers[key] = handler;
68
+ }
69
+ /**
70
+ * Set a custom URL hash parameter. Use `registerHandler` to receive a notification
71
+ * when the parameter changes.
72
+ *
73
+ * @param key short key used to identify the parameter in the URL hash
74
+ * @param value the value of the parameter, or null to remove it.
75
+ */
76
+ setParameter(key, value) {
77
+ if (this.additional[key] !== value) {
78
+ if (value === null) {
79
+ delete this.additional[key];
80
+ }
81
+ else {
82
+ this.additional[key] = value;
24
83
  }
25
- for (let i = 3; i < loc.length; i++) {
26
- let component = loc[i];
27
- let matches = component.match(/([a-z])=(.*)/);
28
- if (matches) {
29
- if (matches[1] == 'm') {
30
- //markerString = matches[2];
31
- }
32
- else {
33
- return false;
34
- }
35
- }
36
- else {
37
- layerString = component;
38
- }
84
+ this._updateHash();
85
+ }
86
+ }
87
+ _fireParameterChange(key, value) {
88
+ if (this.handlers[key]) {
89
+ this.handlers[key](value);
90
+ }
91
+ }
92
+ _onHashChange(new_hash) {
93
+ var _a;
94
+ const hash = decodeHash(new_hash);
95
+ // Check for changes in the additional parameters and fire callbacks.
96
+ // We need to do this first as calling jumpTo generates an _updateHash event
97
+ // which will lose our additional parameters.
98
+ let parameter_keys = [...Object.keys(hash.additional), ...Object.keys(this.additional)];
99
+ for (let key of parameter_keys) {
100
+ if (this.additional[key] && !hash.additional[key]) {
101
+ delete this.additional[key];
102
+ this._fireParameterChange(key, null);
39
103
  }
40
- if (this.layerSwitcher) {
41
- this.layerSwitcher.setURLString(layerString);
104
+ else if (hash.additional[key] && this.additional[key] !== hash.additional[key]) {
105
+ this.additional[key] = hash.additional[key];
106
+ this._fireParameterChange(key, hash.additional[key]);
42
107
  }
43
- return true;
44
108
  }
45
- if (this.layerSwitcher) {
46
- this.layerSwitcher.setURLString("");
109
+ if (((_a = this._map) === null || _a === void 0 ? void 0 : _a.isStyleLoaded()) && hash.center && hash.zoom) {
110
+ this._map.jumpTo({
111
+ center: hash.center,
112
+ zoom: hash.zoom,
113
+ });
114
+ }
115
+ if (this.layerSwitcher && hash.layers !== undefined) {
116
+ this.layerSwitcher.setURLString(hash.layers);
47
117
  }
48
- return false;
49
118
  }
50
119
  _updateHash() {
120
+ const newHash = this.getHashString();
51
121
  try {
52
- window.history.replaceState(window.history.state, '', this.getHashString());
122
+ window.history.replaceState(window.history.state, '', newHash);
53
123
  }
54
124
  catch (e) {
55
125
  console.log(e);
@@ -59,35 +129,33 @@ class URLHash {
59
129
  if (!this._map) {
60
130
  throw new Error('getHashString called before map initialised');
61
131
  }
62
- const center = this._map.getCenter(), zoom = Math.round(this._map.getZoom() * 100) / 100,
63
- // derived from equation: 512px * 2^z / 360 / 10^d < 0.5px
64
- precision = Math.ceil((zoom * Math.LN2 + Math.log(512 / 360 / 0.5)) / Math.LN10), m = Math.pow(10, precision), lng = Math.round(center.lng * m) / m, lat = Math.round(center.lat * m) / m, bearing = this._map.getBearing(), pitch = this._map.getPitch();
65
- let hash = `#${zoom}/${lat}/${lng}`;
66
- let layers = null;
132
+ const { lng, lat } = this._map.getCenter();
133
+ const components = {
134
+ center: [lng, lat],
135
+ zoom: this._map.getZoom(),
136
+ additional: this.additional,
137
+ };
67
138
  if (this.layerSwitcher) {
68
- layers = this.layerSwitcher.getURLString();
69
- }
70
- if (layers) {
71
- hash += '/' + layers;
139
+ components.layers = this.layerSwitcher.getURLString();
72
140
  }
73
- return hash;
141
+ return encodeHash(components);
74
142
  }
75
143
  /**
76
144
  * Modify MapLibre GL map constructor options to include values from the URL hash.
77
145
  *
78
146
  * @param options the original options passed to the MapLibre GL `Map` constructor.
79
- * You should include defaults for the center and zoom parameters.
80
- * @returns an options object to be passed to the `Map` constructor.
147
+ * You should include defaults for the `center` and `zoom` parameters.
148
+ * @returns an options object to be passed to the `Map` constructor, with the
149
+ * `center` and `zoom` parameters updated if necessary. Other options are untouched.
81
150
  */
82
151
  init(options) {
83
- options['hash'] = false;
152
+ options.hash = false;
84
153
  const loc = window.location.hash.replace('#', '').split('/');
85
154
  if (loc.length >= 3) {
86
- options['center'] = [+loc[2], +loc[1]];
87
- options['zoom'] = +loc[0];
155
+ options.center = [+loc[2], +loc[1]];
156
+ options.zoom = +loc[0];
88
157
  }
89
158
  return options;
90
159
  }
91
160
  }
92
- ;
93
161
  export default URLHash;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=urlhash.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"urlhash.test.d.ts","sourceRoot":"","sources":["../src/urlhash.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,38 @@
1
+ import LayerSwitcher from '.';
2
+ import URLHash, { decodeHash, encodeHash } from './urlhash';
3
+ test('decodeHash', () => {
4
+ expect(decodeHash('#10/51.505/-0.09')).toStrictEqual({
5
+ center: [-0.09, 51.505],
6
+ zoom: 10,
7
+ layers: '',
8
+ additional: {},
9
+ });
10
+ expect(decodeHash('#10/51.505/-0.09/A,B,C')).toStrictEqual({
11
+ center: [-0.09, 51.505],
12
+ zoom: 10,
13
+ layers: 'A,B,C',
14
+ additional: {},
15
+ });
16
+ });
17
+ test('Test hash encoding round trip', () => {
18
+ let components = { additional: {} };
19
+ expect(decodeHash(encodeHash(components))).toStrictEqual(components);
20
+ components.center = [-0.09, 51.505];
21
+ components.zoom = 10;
22
+ components.layers = '';
23
+ expect(decodeHash(encodeHash(components))).toStrictEqual(components);
24
+ components.layers = 'A,B,C';
25
+ expect(decodeHash(encodeHash(components))).toStrictEqual(components);
26
+ components.additional = { foo: 'bar', a: 'b' };
27
+ expect(decodeHash(encodeHash(components))).toStrictEqual(components);
28
+ });
29
+ test('test URLHash class', () => {
30
+ let layer_switcher = new LayerSwitcher({}, []);
31
+ let url_hash = new URLHash(layer_switcher);
32
+ let returned_value = null;
33
+ url_hash.registerHandler('a', (value) => {
34
+ returned_value = value;
35
+ });
36
+ url_hash._onHashChange('#10/51.505/-0.09/a=foo');
37
+ expect(returned_value).toBe('foo');
38
+ });
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@russss/maplibregl-layer-switcher",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Layer switcher for Maplibre GL JS based on layer prefixes",
5
5
  "exports": {
6
- ".": "lib/index.js",
7
- "./urlhash": "lib/urlhash.js"
6
+ ".": "src/index.ts",
7
+ "./urlhash": "src/urlhash.ts"
8
8
  },
9
9
  "scripts": {
10
- "build": "npx tsc && cp src/layerswitcher.css lib/"
10
+ "build": "npx tsc && cp src/layerswitcher.css lib/",
11
+ "test": "jest"
11
12
  },
12
13
  "author": "Russ Garrett",
13
14
  "license": "ISC",
@@ -17,9 +18,14 @@
17
18
  "redom": "^3.24.2"
18
19
  },
19
20
  "devDependencies": {
21
+ "@types/jest": "^29.5.3",
20
22
  "@types/lodash.invert": "^4.3.7",
21
23
  "@types/lodash.isequal": "^4.5.6",
24
+ "jest": "^29.6.1",
25
+ "jest-environment-jsdom": "^29.6.1",
22
26
  "maplibre-gl": "^3.1.0",
27
+ "prettier": "^3.0.0",
28
+ "ts-jest": "^29.1.1",
23
29
  "typescript": "^5.1.6"
24
30
  }
25
31
  }
@@ -1 +0,0 @@
1
- {"program":{"fileNames":[],"fileInfos":[],"root":[],"options":{"esModuleInterop":true,"module":1,"outDir":"./","strict":false,"target":3},"referencedMap":[],"exportedModulesMap":[]},"version":"5.1.6"}