├── .gitattributes
├── .gitignore
├── README.md
├── babel.config.js
├── dist
├── bundle.css
├── index.min.js
├── index.min.js.map
├── index.min.mjs
└── index.min.mjs.map
├── package-lock.json
├── package.json
├── public
├── favicon.png
├── global.css
└── index.html
├── rollup.config.js
└── src
├── App.svelte
├── components
├── Deckgl.svelte
└── components.module.js
└── main.js
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules/
2 | /public/build/
3 |
4 | .DS_Store
5 | /dist/
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Svelte DeckGL
2 |
3 | ## Deck.gl and Mapbox
4 | Head over to Deck.gl and Mapbox to see the official documentation to learn more.
5 |
6 | ### Using Mapbox
7 | ```
8 |
56 |
57 |
58 |
59 |
60 |
61 |
66 |
--------------------------------------------------------------------------------
/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | include: ['**/**/*.js', '**/**/*.mjs', '**/**/*.html', '**/**/*.svelte'],
3 | plugins: [
4 | '@babel/plugin-syntax-dynamic-import',
5 | [
6 | '@babel/plugin-transform-runtime',
7 | {
8 | useESModules: true,
9 | },
10 | ],
11 | ],
12 | presets: ['@babel/preset-env'],
13 | ignore: ['node_modules/**'],
14 | };
15 |
--------------------------------------------------------------------------------
/dist/bundle.css:
--------------------------------------------------------------------------------
1 | .deck-container.svelte-n32q4g{width:100%;height:100%;position:relative}.map-container.svelte-n32q4g{position:absolute;top:0;left:0;width:100%;height:100%;background:#e5e9ec;overflow:hidden}.deck-canvas.svelte-n32q4g{position:absolute;top:0;left:0;width:100%;height:100%}
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "svelte-deckgl",
3 | "description": "Use Deck.gl and Mapbox in svelte",
4 | "version": "1.0.0",
5 | "main": "dist/index.min.js",
6 | "module": "dist/index.min.mjs",
7 | "svelte": "src/components/components.module.js",
8 | "license": "MIT",
9 | "repository": "//https://github.com/arperyan/svelte-deckgl",
10 | "author": "Ryan Arpe",
11 | "files": [
12 | "src/components",
13 | "dist"
14 | ],
15 | "keywords": [
16 | "svelte",
17 | "deck.gl",
18 | "mapbox"
19 | ],
20 | "scripts": {
21 | "build": "rollup -c",
22 | "dev": "rollup -c -w",
23 | "start": "sirv public"
24 | },
25 | "devDependencies": {
26 | "@babel/core": "7.10.5",
27 | "@babel/plugin-syntax-dynamic-import": "7.8.3",
28 | "@babel/plugin-transform-runtime": "7.10.5",
29 | "@babel/preset-env": "7.10.4",
30 | "@rollup/plugin-commonjs": "^17.0.0",
31 | "@rollup/plugin-node-resolve": "^11.0.0",
32 | "rollup": "^2.3.4",
33 | "rollup-plugin-babel": "^4.4.0",
34 | "rollup-plugin-css-only": "^3.1.0",
35 | "rollup-plugin-livereload": "^2.0.0",
36 | "rollup-plugin-peer-deps-external": "^2.2.4",
37 | "rollup-plugin-replace": "2.2.0",
38 | "rollup-plugin-svelte": "^7.0.0",
39 | "rollup-plugin-terser": "^7.0.0",
40 | "@deck.gl/core": "^8.3.0",
41 | "svelte": "^3.0.0"
42 | },
43 | "dependencies": {
44 | "@deck.gl/aggregation-layers": "^8.3.0",
45 | "@deck.gl/core": "^8.3.0",
46 | "@deck.gl/layers": "^8.3.0",
47 | "mapbox-gl": "^1.12.0",
48 | "sirv-cli": "^1.0.0"
49 | },
50 | "peerDependencies": {
51 | "@deck.gl/core": "^8.3.0"
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/public/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arperyan/svelte-deckgl/d1af6c82aa103ba78d1714ebbce0e67c7cd34f29/public/favicon.png
--------------------------------------------------------------------------------
/public/global.css:
--------------------------------------------------------------------------------
1 | html, body {
2 | position: relative;
3 | width: 100%;
4 | height: 100%;
5 | }
6 |
7 | body {
8 | color: #333;
9 | margin: 0;
10 | padding: 8px;
11 | box-sizing: border-box;
12 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
13 | }
14 |
15 | a {
16 | color: rgb(0,100,200);
17 | text-decoration: none;
18 | }
19 |
20 | a:hover {
21 | text-decoration: underline;
22 | }
23 |
24 | a:visited {
25 | color: rgb(0,80,160);
26 | }
27 |
28 | label {
29 | display: block;
30 | }
31 |
32 | input, button, select, textarea {
33 | font-family: inherit;
34 | font-size: inherit;
35 | -webkit-padding: 0.4em 0;
36 | padding: 0.4em;
37 | margin: 0 0 0.5em 0;
38 | box-sizing: border-box;
39 | border: 1px solid #ccc;
40 | border-radius: 2px;
41 | }
42 |
43 | input:disabled {
44 | color: #ccc;
45 | }
46 |
47 | button {
48 | color: #333;
49 | background-color: #f4f4f4;
50 | outline: none;
51 | }
52 |
53 | button:disabled {
54 | color: #999;
55 | }
56 |
57 | button:not(:disabled):active {
58 | background-color: #ddd;
59 | }
60 |
61 | button:focus {
62 | border-color: #666;
63 | }
64 |
--------------------------------------------------------------------------------
/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Svelte app
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/rollup.config.js:
--------------------------------------------------------------------------------
1 | import svelte from 'rollup-plugin-svelte';
2 | import commonjs from '@rollup/plugin-commonjs';
3 | import resolve from '@rollup/plugin-node-resolve';
4 | import livereload from 'rollup-plugin-livereload';
5 | import replace from "rollup-plugin-replace"
6 | import babel from 'rollup-plugin-babel';
7 | import pkg from './package.json';
8 | import {
9 | terser
10 | } from 'rollup-plugin-terser';
11 | import css from 'rollup-plugin-css-only';
12 |
13 | const production = !process.env.ROLLUP_WATCH;
14 |
15 |
16 | export default {
17 | input: !production ? 'src/main.js' : 'src/components/components.module.js',
18 | output: !production ? {
19 | sourcemap: true,
20 | format: 'iife',
21 | name: 'app',
22 | file: 'public/build/bundle.js',
23 | globals: {
24 | '@deck.gl/core': 'core',
25 | '@deck.gl/layers': 'layers'
26 | }
27 | } : [{
28 | file: pkg.module,
29 | format: 'es',
30 | sourcemap: true,
31 | name: pkg.name,
32 | globals: {
33 | '@deck.gl/core': 'core',
34 | '@deck.gl/layers': 'layers'
35 | }
36 | },
37 | {
38 | file: pkg.main,
39 | format: 'umd',
40 | sourcemap: true,
41 | name: pkg.name,
42 | globals: {
43 | '@deck.gl/core': 'core',
44 | '@deck.gl/layers': 'layers'
45 |
46 | }
47 | }
48 |
49 | ],
50 | plugins: [
51 | svelte({
52 | compilerOptions: {
53 | // enable run-time checks when not in production
54 | dev: !production
55 | },
56 | css: (css) => {
57 | css.write('public/build/bundle.css');
58 | },
59 | }),
60 | css({
61 | output: 'bundle.css'
62 | }),
63 | babel({
64 | runtimeHelpers: true,
65 | }),
66 | // css({
67 | // output: 'bundle.css'
68 | // }),
69 | replace({
70 | 'process.env.NODE_ENV': JSON.stringify('production'),
71 | }),
72 |
73 | // we'll extract any component CSS out into
74 | // a separate file - better for performance
75 |
76 |
77 | // If you have external dependencies installed from
78 | // npm, you'll most likely need these plugins. In
79 | // some cases you'll need additional configuration -
80 | // consult the documentation for details:
81 | // https://github.com/rollup/plugins/tree/master/packages/commonjs
82 | resolve({
83 | browser: true,
84 | dedupe: ['svelte']
85 | }),
86 | commonjs({
87 | include: ['node_modules/**'],
88 | }),
89 |
90 | // In dev mode, call `npm run start` once
91 | // the bundle has been generated
92 | !production && serve(),
93 |
94 | // Watch the `public` directory and refresh the
95 | // browser on changes when not in production
96 | !production && livereload('public'),
97 |
98 | // If we're building for production (npm run build
99 | // instead of npm run dev), minify
100 | production && terser()
101 | ],
102 | // external: ["@deck.gl/core"],
103 | watch: {
104 | clearScreen: false
105 | }
106 | };
107 |
108 |
109 | function serve() {
110 | let server;
111 |
112 | function toExit() {
113 | if (server) server.kill(0);
114 | }
115 |
116 | return {
117 | writeBundle() {
118 | if (server) return;
119 | server = require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
120 | stdio: ['ignore', 'inherit', 'inherit'],
121 | shell: true
122 | });
123 |
124 | process.on('SIGTERM', toExit);
125 | process.on('exit', toExit);
126 | }
127 | };
128 | }
--------------------------------------------------------------------------------
/src/App.svelte:
--------------------------------------------------------------------------------
1 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
85 |
--------------------------------------------------------------------------------
/src/components/Deckgl.svelte:
--------------------------------------------------------------------------------
1 |
89 |
90 |
94 |
95 |
120 |
--------------------------------------------------------------------------------
/src/components/components.module.js:
--------------------------------------------------------------------------------
1 | export {
2 | default as SvelteDeckGL
3 | }
4 | from './Deckgl.svelte';
--------------------------------------------------------------------------------
/src/main.js:
--------------------------------------------------------------------------------
1 | import App from "./App.svelte";
2 |
3 | const app = new App({
4 | target: document.body,
5 | });
6 |
7 | export default app;
8 |
--------------------------------------------------------------------------------