@metoceanapi/wxtiles-leaflet 1.0.6 → 1.0.10

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/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@metoceanapi/wxtiles-leaflet",
3
- "version": "1.0.6",
3
+ "version": "1.0.10",
4
4
  "description": "WxTile JS lib to render wxtiles datalayers",
5
- "main": "dist/es/bundle.js",
6
- "types": "dist/es/index.d.ts",
5
+ "main": "dist/es/wxtiles.js",
6
+ "types": "dist/es/wxtiles.d.ts",
7
7
  "scripts": {
8
8
  "build": "rm -rf dist/ && node build.js && tsc",
9
9
  "start": "node watch-public.js",
10
- "preversion": "npm run build && git add CHANGELOG.md"
10
+ "preversion": "npm run build",
11
+ "version": "changelogkeeper && git add CHANGELOG.md"
11
12
  },
12
13
  "repository": {
13
14
  "type": "git",
@@ -21,9 +22,13 @@
21
22
  "homepage": "https://github.com/metoceanapi/wxtiles-leaflet#readme",
22
23
  "devDependencies": {
23
24
  "@types/leaflet": "^1.7.5",
24
- "esbuild": "^0.11.23",
25
+ "changelogkeeper": "^1.2.0",
26
+ "esbuild": "^0.12.28",
27
+ "esbuild-plugin-external-global": "^1.0.1",
25
28
  "express": "^4.17.1",
26
- "leaflet": "^1.7.1",
27
29
  "typescript": "^4.4.3"
30
+ },
31
+ "peerDependencies": {
32
+ "leaflet": "^1.7.1"
28
33
  }
29
34
  }
@@ -0,0 +1,513 @@
1
+ import 'leaflet/dist/leaflet.css';
2
+ import L from 'leaflet'; // goes first always!
3
+
4
+ import {
5
+ WxTilesLogging,
6
+ WxTilesLibSetup,
7
+ CreateWxTilesWatermark,
8
+ CreateWxTilesLayer,
9
+ CreateWxDebugCoordsLayer,
10
+ WxGetColorStyles,
11
+ WxTilesLayer,
12
+ LoadQTree,
13
+ Meta,
14
+ Legend,
15
+ ColorStylesStrict,
16
+ } from '../src/wxtiles';
17
+ import '../src/wxtiles.css';
18
+
19
+ let map: L.Map;
20
+ let layerControl: L.Control.Layers;
21
+ let config: Config; // application config
22
+ let styles: ColorStylesStrict; // all available styles. Not every style is sutable for every layer.
23
+ let globalLayer: WxTilesLayer | undefined; // current layer
24
+
25
+ // json loader helper
26
+ async function fetchJson(url: string) {
27
+ return (await fetch(url)).json();
28
+ }
29
+
30
+ async function fillDataSets() {
31
+ let datasetsNames: string[];
32
+
33
+ try {
34
+ datasetsNames = await fetchJson(config.dataServer + '/datasets.json');
35
+ } catch (e) {
36
+ console.log(e);
37
+ return;
38
+ }
39
+
40
+ datasetsNames.sort();
41
+ for (const datasetName of datasetsNames) {
42
+ const opt = document.createElement('option');
43
+ opt.appendChild(document.createTextNode(datasetName));
44
+ opt.value = datasetName;
45
+ selectDataSetEl.appendChild(opt);
46
+ }
47
+
48
+ await fillVariables_selectDataSetEl_onchange();
49
+ }
50
+
51
+ async function fillVariables_selectDataSetEl_onchange() {
52
+ const oldVariable = selectVariableEl.value;
53
+ selectVariableEl.innerHTML = '';
54
+ let meta: Meta;
55
+ try {
56
+ const instances = await fetchJson(config.dataServer + '/' + selectDataSetEl.value + '/instances.json');
57
+ const instance = instances[instances.length - 1];
58
+ meta = await fetchJson(config.dataServer + '/' + selectDataSetEl.value + '/' + instance + '/meta.json');
59
+ } catch (e) {
60
+ console.log(e);
61
+ return;
62
+ }
63
+
64
+ meta.variables.sort();
65
+ for (const variable of meta.variables) {
66
+ if (variable.includes('northward')) {
67
+ continue;
68
+ }
69
+ const opt = document.createElement('option');
70
+ opt.appendChild(document.createTextNode(variable.replace('eastward', 'vector')));
71
+ opt.value = variable;
72
+ selectVariableEl.appendChild(opt);
73
+ }
74
+
75
+ if (meta.variables.includes(oldVariable)) {
76
+ selectVariableEl.value = oldVariable;
77
+ }
78
+
79
+ loadVariable_selectVariableEl_onchange();
80
+ }
81
+
82
+ async function loadVariable_selectVariableEl_onchange() {
83
+ stopPlay();
84
+
85
+ const variable = selectVariableEl.value;
86
+ const variables = [variable];
87
+ if (variable.includes('eastward')) {
88
+ variables.push(variable.replace('eastward', 'northward'));
89
+ }
90
+
91
+ const layerSettings = {
92
+ dataSource: {
93
+ serverURI: config.dataServer, // server to fetch data from
94
+ maskServerURI: config.dataServer.replace(/\/data\/?/i, '/mask/{z}/{x}/{y}'),
95
+ ext: config.ext, // png / webp (default) - wxtilesplitter output format
96
+ dataset: selectDataSetEl.value, // dataset of the dataset
97
+ variables, // variable(s) to be used for the layer rendering
98
+ name: selectDataSetEl.value + '/' + selectVariableEl.selectedOptions[0].label, // attribute of the dataSource to be used externally
99
+ styleName: variable, // The name of the style (from styles.json) to apply for the layer
100
+ },
101
+ // Lazy setup
102
+ // 'true': perform setup and data loading on 'addTo(map)'.
103
+ // 'false': start loading immediately, but loading is not finished when layer is created.
104
+ // the signal 'setupcomplete' is fired when loading is finished.
105
+ // useful when a big bunch of layers is used, so layers are not wasting memory and bandwidth.
106
+ // lazy: true,
107
+ options: {
108
+ opacity: 1,
109
+ },
110
+ };
111
+
112
+ // save in order to delete old layer
113
+ const oldLayer = globalLayer; // this is to store oldLayer in order a user change layers too fast.
114
+ globalLayer = CreateWxTilesLayer(layerSettings);
115
+ await globalLayer.getSetupCompletePromise(); // wait for meta info to be loaded. doesn't mean 'tiles are loaded' !!!
116
+ globalLayer.addTo(map);
117
+
118
+ layerControl.addOverlay(globalLayer, layerSettings.dataSource.name);
119
+ if (oldLayer)
120
+ globalLayer.once('load', () => {
121
+ oldLayer.removeFrom(map);
122
+ layerControl.removeLayer(oldLayer);
123
+ }); // delete old layer
124
+ globalLayer.setTime(selectTimeEl.value !== '' ? selectTimeEl.value : new Date()); // try to preserve 'time' from current time of selectTimeEl
125
+ fillTimes(globalLayer);
126
+ fillStyles(globalLayer);
127
+ }
128
+
129
+ function fillTimes(layer: WxTilesLayer) {
130
+ // once layer setup finished, times are available.
131
+ // let's fill up 'selectTimeEl'
132
+ selectTimeEl.innerHTML = '';
133
+ layer.getTimes().forEach((val) => {
134
+ const opt = document.createElement('option');
135
+ opt.appendChild(document.createTextNode(val));
136
+ opt.value = val;
137
+ selectTimeEl.appendChild(opt);
138
+ });
139
+
140
+ selectTimeEl.value = layer.getTime();
141
+ }
142
+
143
+ function startPlay() {
144
+ if (!globalLayer) return;
145
+ buttonPlayStopEl.textContent = 'stop';
146
+ globalLayer.setTimeAnimationMode(+inputCoarseLevelEl.value);
147
+ setTimeout(async function nextTimeStep() {
148
+ if (!globalLayer) return;
149
+ if (buttonPlayStopEl.textContent === 'stop') {
150
+ const start = Date.now();
151
+ await globalLayer.setTime(selectTimeEl.value);
152
+ selectTimeEl.selectedIndex++;
153
+ selectTimeEl.selectedIndex %= selectTimeEl.length;
154
+ const dt = +inputAnimDelayEl.value - (Date.now() - start);
155
+ setTimeout(nextTimeStep, dt < 0 ? 0 : dt);
156
+ oldE && updateInfoPanel(oldE);
157
+ }
158
+ });
159
+ }
160
+
161
+ function stopPlay() {
162
+ buttonPlayStopEl.textContent = 'play';
163
+ globalLayer?.unsetTimeAnimationMode();
164
+ }
165
+
166
+ function addOption(baseStyle: string, value = baseStyle) {
167
+ const opt = document.createElement('option');
168
+ opt.appendChild(document.createTextNode(baseStyle));
169
+ opt.value = value;
170
+ selectStyleEl.appendChild(opt);
171
+ }
172
+
173
+ function fillStyles(layer: WxTilesLayer) {
174
+ selectStyleEl.innerHTML = '';
175
+ if (config.varToStyleMap) {
176
+ for (const [regexp, styleName] of config.varToStyleMap) {
177
+ const regExp = new RegExp(regexp, 'i');
178
+ if (styleName in styles && regExp.test(layer.dataSource.variables[0])) {
179
+ addOption(styles[styleName].name, styleName);
180
+ }
181
+ }
182
+ }
183
+
184
+ addOption('base');
185
+ addOption('custom');
186
+ onStyleChange_selectStyleEl_onchange();
187
+ }
188
+
189
+ function JSONsort(o: any) {
190
+ if (Array.isArray(o)) {
191
+ return o.map(JSONsort);
192
+ } else if (typeof o === 'object' && o !== null) {
193
+ const keys = Object.keys(o)
194
+ // .map((a) => a.toUpperCase())
195
+ .sort((a, b) => {
196
+ const aa = a.toUpperCase();
197
+ const bb = b.toUpperCase();
198
+ return aa == bb ? 0 : aa > bb ? 1 : -1;
199
+ });
200
+ return keys.reduce((a, k) => {
201
+ a[k] = JSONsort(o[k]);
202
+ return a;
203
+ }, {});
204
+ }
205
+ return o;
206
+ }
207
+
208
+ function onStyleChange_selectStyleEl_onchange() {
209
+ if (!globalLayer) return;
210
+ if (selectStyleEl.value === 'custom') {
211
+ try {
212
+ styles.custom = JSON.parse(customStyleEl.value);
213
+ } catch {
214
+ console.log('Wrong custom style');
215
+ const ctx = legendCanvasEl.getContext('2d');
216
+ if (!ctx) return;
217
+ ctx.clearRect(0, 0, legendCanvasEl.width, legendCanvasEl.height);
218
+ ctx.beginPath();
219
+ ctx.font = legendCanvasEl.height / 2 + 'px sans-serif';
220
+ ctx.fillText('Wrong custom style', 10, legendCanvasEl.height / 2);
221
+ ctx.stroke();
222
+ return;
223
+ }
224
+ }
225
+ globalLayer.setStyle(selectStyleEl.value);
226
+ const curStyleName = globalLayer.getStyle();
227
+ const curStyle = styles[curStyleName];
228
+ customStyleEl.value = JSON.stringify(JSONsort(curStyle), null, ' ');
229
+ const legend = globalLayer.getLegendData(legendCanvasEl.width - 50);
230
+ if (!legend) return;
231
+ drawLegend({ legend, canvas: legendCanvasEl });
232
+ }
233
+
234
+ function drawLegend({ legend, canvas }: { legend: Legend; canvas: HTMLCanvasElement }) {
235
+ if (!globalLayer || !canvas || !legend) return;
236
+
237
+ const { width, height } = canvas;
238
+ const halfHeight = (16 + height) >> 2;
239
+
240
+ // draw legend
241
+ const ctx = canvas.getContext('2d')!;
242
+ const imData = ctx.createImageData(width, height);
243
+ const im = new Uint32Array(imData.data.buffer);
244
+ im.fill(-1);
245
+
246
+ const startX = 2;
247
+ const startY = 2;
248
+ const startXY = startX + width * startY;
249
+
250
+ const trSize = halfHeight >> 1;
251
+ // left triangle
252
+ if (legend.showBelowMin) {
253
+ const c = legend.colors[0];
254
+ if (c) {
255
+ for (let x = 0; x < trSize; ++x) {
256
+ for (let y = trSize; y < trSize + x; ++y) {
257
+ im[startXY + x + y * width] = c;
258
+ im[startXY + x + (trSize * 2 - y) * width] = c;
259
+ }
260
+ }
261
+ }
262
+ }
263
+
264
+ for (let x = 0; x < legend.size; ++x) {
265
+ for (let y = 0; y < halfHeight; ++y) {
266
+ if (legend.colors[0]) {
267
+ im[startX + x + trSize + (y + startY + 1) * width] = legend.colors[x];
268
+ }
269
+ }
270
+ }
271
+
272
+ // right triangle
273
+ if (legend.showAboveMax) {
274
+ const c = legend.colors[legend.colors.length - 1];
275
+ if (c) {
276
+ for (let x = 0; x <= trSize; ++x) {
277
+ for (let y = trSize; y < trSize + x; ++y) {
278
+ im[startXY + trSize * 2 + legend.size - x + y * width] = c;
279
+ im[startXY + trSize * 2 + legend.size - x + (trSize * 2 - y) * width] = c;
280
+ }
281
+ }
282
+ }
283
+ }
284
+
285
+ ctx.putImageData(imData, 0, 0);
286
+
287
+ // draw ticks
288
+ ctx.font = '8px sans-serif';
289
+ ctx.beginPath();
290
+ for (const tick of legend.ticks) {
291
+ ctx.strokeStyle = '#000';
292
+ ctx.moveTo(tick.pos + trSize + startX + 1, startY + 3);
293
+ ctx.lineTo(tick.pos + trSize + startX + 1, halfHeight);
294
+ ctx.fillText(tick.dataString, tick.pos + trSize + startX + 1, halfHeight + 11);
295
+ }
296
+ ctx.font = '12px sans-serif';
297
+ const txt = globalLayer.getStyleName() + ' (' + legend.units + ')';
298
+ ctx.fillText(txt, 13, height - 5);
299
+ ctx.stroke();
300
+
301
+ ctx.strokeStyle = '#888';
302
+ ctx.strokeRect(1, 1, width - 3, height - 2); //for white background
303
+ }
304
+
305
+ let oldE: L.LeafletMouseEvent | undefined;
306
+ function updateInfoPanel(e: L.LeafletMouseEvent) {
307
+ oldE = e; // save 'e'
308
+ let content = '' + `${e.latlng}<br>`;
309
+ map.eachLayer((layer) => {
310
+ if (layer instanceof WxTilesLayer) {
311
+ const tile = layer.getTile(e!.latlng);
312
+ const { min, max } = layer.getMinMax();
313
+
314
+ content += tile
315
+ ? `<div>
316
+ <div style="width:1em;height:1em;float:left;margin-right:2px;background:${tile.hexColor}"></div>
317
+ ${layer.dataSource.name}=${tile.inStyleUnits.toFixed(2)} ${tile.units} (${min.toFixed(2)}, ${max.toFixed(2)})
318
+ </div>`
319
+ : '';
320
+ }
321
+ });
322
+
323
+ infoPanelEl.innerHTML = content;
324
+ }
325
+
326
+ function popupInfo(e: L.LeafletMouseEvent) {
327
+ let content = '';
328
+ map.eachLayer((layer) => {
329
+ if (layer instanceof WxTilesLayer) {
330
+ const tile = layer.getTile(e.latlng);
331
+ const time = layer.getTime();
332
+ content += tile
333
+ ? `<div>
334
+ <div style="width:1em;height:1em;float:left;margin-right:2px;background:${tile.hexColor}"></div>
335
+ ${layer.dataSource.name}<br>
336
+ (in style Units = ${tile.inStyleUnits} ${tile.units})<br>
337
+ (in data Units = ${tile.data} ${layer.state.units})<br>
338
+ (time:${time})<br>
339
+ (instance:${layer.state.instance})<br>
340
+ (tilePoint:${tile.tilePoint.x},${tile.tilePoint.y})<br>
341
+ </div>`
342
+ : '';
343
+ // (tileCoords:${tile.tile.coords.x},${tile.tile.coords.y},zoom:${tile.tile.coords.z})<br>
344
+ }
345
+ });
346
+
347
+ L.popup()
348
+ .setLatLng(e.latlng)
349
+ .setContent(content + `${e.latlng}`)
350
+ .openOn(map);
351
+ }
352
+
353
+ function createControl(opt: L.ControlOptions & { htmlID: string }): L.Control {
354
+ return new (L.Control.extend({
355
+ onAdd() {
356
+ return document.getElementById(opt.htmlID);
357
+ },
358
+ }))(opt);
359
+ }
360
+
361
+ interface BaseLayerOptions {
362
+ name: string;
363
+ URL: string;
364
+ options?: L.TileLayerOptions;
365
+ add?: boolean;
366
+ }
367
+ interface Config {
368
+ dataServer: string;
369
+ ext: 'webp' | 'png';
370
+ map?: L.MapOptions;
371
+ baseLayers?: BaseLayerOptions[];
372
+ varToStyleMap?: [string, string][];
373
+ }
374
+
375
+ async function start() {
376
+ // read config
377
+ try {
378
+ config = await fetchJson('props/config.json'); // set the correct URI
379
+ } catch (e) {
380
+ console.log(e);
381
+ alert('No props/config.json');
382
+ return;
383
+ }
384
+
385
+ // Leaflet basic setup // set the main Leaflet's map object, compose and add base layers
386
+ map = L.map('map', config.map);
387
+
388
+ // Setup WxTiles lib
389
+ WxTilesLogging(true); // use wxtiles logging -> console.log
390
+ CreateWxTilesWatermark({ URI: 'res/wxtiles-logo.png', position: 'topright' }).addTo(map);
391
+ layerControl = L.control.layers(undefined, undefined, { position: 'topright', autoZIndex: false, collapsed: false }).addTo(map);
392
+ config.baseLayers?.map((baseLayer) => {
393
+ if (!baseLayer.add) return;
394
+ const layer = L.tileLayer(baseLayer.URL, baseLayer.options);
395
+ baseLayer.options?.zIndex === 0 ? layerControl.addBaseLayer(layer, baseLayer.name) : layerControl.addOverlay(layer, baseLayer.name);
396
+ });
397
+ layerControl.addOverlay(CreateWxDebugCoordsLayer(), 'tile boundaries');
398
+ layerControl.addBaseLayer(L.tileLayer('').addTo(map), 'base-empty');
399
+
400
+ createControl({ position: 'topleft', htmlID: 'legend' }).addTo(map);
401
+ createControl({ position: 'topleft', htmlID: 'layerPanel' }).addTo(map);
402
+ createControl({ position: 'topleft', htmlID: 'styleEditor' }).addTo(map);
403
+ createControl({ position: 'bottomleft', htmlID: 'infoPanel' }).addTo(map);
404
+
405
+ const wxlibCustomSettings: any = {};
406
+ try {
407
+ // these URIs are for the demo purpose. set the correct URI
408
+ wxlibCustomSettings.colorStyles = await fetchJson('props/styles.json'); // set the correct URI
409
+ } catch (e) {
410
+ console.log(e);
411
+ }
412
+
413
+ try {
414
+ wxlibCustomSettings.units = await fetchJson('props/uconv.json'); // set the correct URI
415
+ } catch (e) {
416
+ console.log(e);
417
+ }
418
+
419
+ try {
420
+ wxlibCustomSettings.colorSchemes = await fetchJson('props/colorschemes.json'); // set the correct URI
421
+ } catch (e) {
422
+ console.log(e);
423
+ }
424
+
425
+ // ESSENTIAL step to get lib ready.
426
+ WxTilesLibSetup(wxlibCustomSettings); // load fonts and styles, units, colorschemas - empty => defaults
427
+ await document.fonts.ready; // !!! IMPORTANT: make sure fonts (barbs, arrows, etc) are loaded
428
+ await LoadQTree(config.dataServer + 'seamask.qtree');
429
+
430
+ styles = WxGetColorStyles(); // all available styles. Not every style is sutable for this layer.
431
+
432
+ fillDataSets();
433
+
434
+ map.on('zoom', stopPlay); // stop time animation on zoom
435
+ map.on('mousemove', updateInfoPanel);
436
+ map.on('click', popupInfo);
437
+ }
438
+
439
+ const selectDataSetEl = document.getElementById('selectDataSet') as HTMLSelectElement;
440
+ selectDataSetEl.addEventListener('change', () => {
441
+ fillVariables_selectDataSetEl_onchange();
442
+ });
443
+
444
+ const selectVariableEl = document.getElementById('selectVariable') as HTMLSelectElement;
445
+ selectVariableEl.addEventListener('change', loadVariable_selectVariableEl_onchange);
446
+
447
+ const selectStyleEl = document.getElementById('selectStyle') as HTMLSelectElement;
448
+ selectStyleEl.addEventListener('change', onStyleChange_selectStyleEl_onchange);
449
+
450
+ const legendCanvasEl = document.getElementById('legend') as HTMLCanvasElement;
451
+
452
+ const customStyleEl = document.getElementById('customStyle') as HTMLTextAreaElement;
453
+ customStyleEl.addEventListener('change', () => {
454
+ selectStyleEl.value = 'custom';
455
+ onStyleChange_selectStyleEl_onchange();
456
+ });
457
+
458
+ const customStyleButtonEl = document.getElementById('customStyleButton')! as HTMLButtonElement;
459
+ customStyleButtonEl.addEventListener('click', () => {
460
+ if (customStyleEl.style.display != 'none') {
461
+ customStyleEl.style.display = 'none';
462
+ customStyleButtonEl.innerHTML = 'show Custom Style Editor';
463
+ } else {
464
+ customStyleEl.style.display = 'block';
465
+ customStyleButtonEl.innerHTML = 'update Custom Style & Hide';
466
+ selectStyleEl.value = 'custom';
467
+ }
468
+ });
469
+
470
+ const selectTimeEl = document.getElementById('selectTime') as HTMLSelectElement;
471
+ selectTimeEl.addEventListener('change', () => {
472
+ if (!globalLayer) return;
473
+ if (buttonPlayStopEl.textContent === 'stop') stopPlay();
474
+ globalLayer.setTime(selectTimeEl.value);
475
+ selectTimeEl.value = globalLayer.getTime();
476
+ });
477
+
478
+ const buttonHoldEl = document.getElementById('buttonHold') as HTMLButtonElement;
479
+ buttonHoldEl.addEventListener('click', () => {
480
+ L.popup()
481
+ .setLatLng(map.getCenter())
482
+ .setContent(
483
+ `
484
+ This layer was "held".
485
+ You can hold as many layers as you want, but you can't control them after holding.
486
+ New layers will appear OVER the held layers.
487
+ Use the "clear" button to clear the ALL VISIBLE layers.
488
+ `
489
+ )
490
+ .openOn(map);
491
+ stopPlay();
492
+ globalLayer = undefined;
493
+ });
494
+
495
+ const infoPanelEl = document.getElementById('infoPanel') as HTMLDivElement;
496
+ const inputAnimDelayEl = document.getElementById('animDelay') as HTMLInputElement;
497
+ const inputCoarseLevelEl = document.getElementById('coarseLevel') as HTMLInputElement;
498
+ const buttonPlayStopEl = document.getElementById('buttonPlayStop') as HTMLButtonElement;
499
+ buttonPlayStopEl.addEventListener('click', () => {
500
+ buttonPlayStopEl.textContent === 'play' ? startPlay() : stopPlay();
501
+ });
502
+ const clearEl = document.getElementById('buttonClear')!;
503
+ clearEl.addEventListener('click', () => {
504
+ map.eachLayer((l) => {
505
+ if ('getTile' in l) {
506
+ l.removeFrom(map);
507
+ layerControl.removeLayer(l);
508
+ }
509
+ });
510
+ loadVariable_selectVariableEl_onchange();
511
+ });
512
+
513
+ start();
package/.prettierrc.js DELETED
@@ -1,8 +0,0 @@
1
- module.exports = {
2
- trailingComma: 'es5',
3
- singleQuote: true,
4
- useTabs: true,
5
- arrowParens: 'always',
6
- printWidth: 160,
7
- jsxSingleQuote: true,
8
- };
@@ -1,22 +0,0 @@
1
- {
2
- // Use IntelliSense to learn about possible attributes.
3
- // Hover to view descriptions of existing attributes.
4
- // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
- "version": "0.2.0",
6
- "configurations": [
7
- {
8
- "type": "pwa-chrome",
9
- "request": "launch",
10
- "name": "Launch Chrome",
11
- "file": "${file}",
12
- "webRoot": "${workspaceFolder}/examples"
13
- },
14
- {
15
- "type": "pwa-chrome",
16
- "request": "launch",
17
- "name": "Launch",
18
- "url": "http://localhost:3001",
19
- "webRoot": "${workspaceFolder}/public"
20
- }
21
- ]
22
- }
@@ -1,6 +0,0 @@
1
- {
2
- "files.exclude": {
3
- "**/node_modules1": true,
4
- "**/dist1": true
5
- }
6
- }
package/build.js DELETED
@@ -1,32 +0,0 @@
1
- const esbuild = require('esbuild');
2
- // const sassPlugin = require('esbuild-plugin-sass');
3
-
4
- const sharedConfig = {
5
- entryPoints: ['src/index.ts'],
6
- bundle: true,
7
- loader: {
8
- '.ttf': 'base64',
9
- '.woff': 'base64',
10
- },
11
- target: 'es2015',
12
- minify: true,
13
- };
14
-
15
- // BUILD as ESModules
16
- esbuild
17
- .build({
18
- ...sharedConfig,
19
- format: 'esm',
20
- outfile: 'dist/es/bundle.js',
21
- })
22
- .catch((e) => console.error(e.message));
23
-
24
- // build for web
25
- esbuild
26
- .build({
27
- ...sharedConfig,
28
- format: 'iife',
29
- outfile: 'dist/web/wxtile.js',
30
- globalName: 'wxtilejs',
31
- })
32
- .catch((e) => console.error(e.message));