Skip to content

Commit e3f8359

Browse files
authored
Merge pull request #18 from mutablelogic/dev2
Dev2
2 parents 08a1f61 + 920ed30 commit e3f8359

File tree

81 files changed

+5625
-672
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+5625
-672
lines changed

.github/workflows/lint.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish Docs on Push to main
1+
name: Lint on Push to main
22
on:
33
push:
44
branches:

config/esbuild.config.mjs

+6-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import esbuild from 'esbuild';
22

33
const commonOptions = {
4-
entryPoints: ['example/index.js'],
54
outdir: 'dist',
65
format: 'esm',
76
bundle: true,
@@ -13,34 +12,29 @@ const commonOptions = {
1312
'.otf': 'file',
1413
'.html': 'copy',
1514
'.json': 'copy',
16-
}
15+
},
16+
logLevel: 'info',
17+
entryPoints: [],
1718
};
1819

1920
if (process.env.NODE_ENV === 'production') {
21+
commonOptions.entryPoints.push('src/index.js');
2022
await esbuild.build({
2123
...commonOptions,
24+
entryPoints: ['src/index.js'],
2225
minify: true,
2326
sourcemap: false,
24-
define: {
25-
'process.env.NODE_ENV': '"production"',
26-
},
2727
}).catch(() => process.exit(1));
2828
} else {
29-
commonOptions.entryPoints.push('example/index.html', 'example/data.json');
29+
commonOptions.entryPoints.push('example/index.html', 'example/index.js');
3030
let ctx = await esbuild.context({
3131
...commonOptions,
3232
minify: false,
3333
sourcemap: true,
34-
define: {
35-
'process.env.NODE_ENV': '"development"',
36-
},
3734
})
3835

3936
let { host, port } = await ctx.serve({
4037
servedir: commonOptions.outdir,
4138
});
42-
console.log(`Serving on http://${host}:${port}`);
43-
4439
await ctx.watch();
45-
console.log('watching');
4640
}

config/esbuild.geojson.mjs

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import esbuild from 'esbuild';
2+
3+
const commonOptions = {
4+
outdir: 'dist',
5+
format: 'esm',
6+
bundle: true,
7+
loader: {
8+
'.svg': 'file',
9+
'.woff': 'file',
10+
'.woff2': 'file',
11+
'.ttf': 'file',
12+
'.otf': 'file',
13+
'.html': 'copy',
14+
'.json': 'copy',
15+
},
16+
logLevel: 'info',
17+
entryPoints: [],
18+
};
19+
20+
if (process.env.NODE_ENV === 'production') {
21+
commonOptions.entryPoints.push('src/index.js');
22+
await esbuild.build({
23+
...commonOptions,
24+
entryPoints: ['src/index.js'],
25+
minify: true,
26+
sourcemap: false,
27+
}).catch(() => process.exit(1));
28+
} else {
29+
commonOptions.entryPoints.push('example/geojson/index.html', 'example/geojson/index.js', 'example/geojson/data.json');
30+
let ctx = await esbuild.context({
31+
...commonOptions,
32+
minify: false,
33+
sourcemap: true,
34+
})
35+
36+
let { host, port } = await ctx.serve({
37+
servedir: commonOptions.outdir,
38+
});
39+
await ctx.watch();
40+
}

config/eslint.config.mjs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { FlatCompat } from '@eslint/eslintrc';
22
import globals from 'globals';
3-
import {dirname } from 'path';
3+
import { dirname } from 'path';
44
import { fileURLToPath } from 'url';
55
import js from '@eslint/js';
66

@@ -18,6 +18,9 @@ export default [
1818
globals: globals.browser,
1919
ecmaVersion: 13,
2020
sourceType: 'module',
21+
parserOptions: {
22+
ecmaVersion: 13,
23+
},
2124
},
2225
},
2326
...compat.extends('airbnb-base'),

example/esbuild.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* Code to reload in the esbuild serve development environment */
22
window.addEventListener('load', () => {
33
// eslint-disable-next-line no-restricted-globals
4-
new EventSource('/esbuild').addEventListener('change', () => location.reload());
4+
//new EventSource('/esbuild').addEventListener('change', () => location.reload());
55
});
File renamed without changes.
+11
Loading

example/geojson/index.html

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>GeoJSON viewer</title>
8+
<script type="module" src="index.js" defer></script>
9+
<link href="index.css" rel="stylesheet">
10+
</head>
11+
12+
<body>
13+
<js-canvas>
14+
<js-nav vertical>
15+
<js-navitem disabled><js-image id="icon"></js-image></js-navitem>
16+
<js-navitem>Home</js-navitem>
17+
</js-nav>
18+
19+
<js-content>
20+
<!-- the map -->
21+
<js-map id="map"
22+
accessToken="pk.eyJ1IjoiZGp0aG9ycGUiLCJhIjoiY2x5ZnJhZjAzMDJsYTJqcjd6eWQ3cjRvcSJ9.LvoT_wihG5VQtv008P-MPw">
23+
<!-- add a source from the array (must currently be an array of GeoJSON features) -->
24+
<js-mapsource id="area" type="geojson" data="#array"></js-mapsource>
25+
26+
<!-- display the source on the map -->
27+
<js-maplayer id="points" source="#area" type="fill" paint='{ "fill-opacity": 0.2, "fill-color": "#aa0000" }'></js-maplayer>
28+
</js-map>
29+
</js-content>
30+
31+
</js-canvas>
32+
33+
<!-- contains the GeoJSON data -->
34+
<js-array id="array" provider="#provider"></js-array>
35+
36+
<!-- data source which updates when the event source /esbuild changes -->
37+
<js-provider id="provider" path="data.json" eventsource="/esbuild"></js-provider>
38+
39+
<!-- toast which persists on the screen for 1 second -->
40+
<js-toast id="toast" duration="1"></js-toast>
41+
</body>
42+
43+
</html>

example/geojson/index.js

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// This file defines all the styles and elements used for the web components
2+
import '../../src/index';
3+
import '../esbuild';
4+
import hala from './hala-white-132x132.svg';
5+
import { EventType } from '../../src/core/EventType';
6+
7+
window.addEventListener('load', () => {
8+
// Brand
9+
const icon = document.querySelector('#icon');
10+
if (icon) {
11+
icon.src = hala;
12+
}
13+
14+
// Set toast when error or done
15+
const provider = document.querySelector('#provider');
16+
const toast = document.querySelector('#toast');
17+
18+
provider.addEventListener(EventType.ERROR, (e) => {
19+
toast.visible = true;
20+
toast.duration = 10;
21+
toast.color = 'error';
22+
toast.innerHTML = `${e.detail}<js-close></js-close>`;
23+
});
24+
25+
provider.addEventListener(EventType.DONE, (e) => {
26+
toast.visible = true;
27+
toast.duration = 10;
28+
toast.color = 'info';
29+
toast.innerHTML = 'Data Reloaded&nbsp;&nbsp;<js-close></js-close>';
30+
});
31+
});

example/index.html

-80
This file was deleted.

example/index.js

-13
This file was deleted.

example/load.js

-6
This file was deleted.

0 commit comments

Comments
 (0)