-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Anand Thakker
committed
Feb 17, 2018
1 parent
a616ea4
commit 802043a
Showing
30 changed files
with
216 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import assert from 'assert'; | ||
import MagicString from 'magic-string'; | ||
|
||
export default function workerPrelude () { | ||
return { | ||
name: 'mapbox-gl-worker-prelude', | ||
transformBundle: (source, {format}) => { | ||
assert(format === 'umd'); | ||
|
||
const preludeString = 'function (global, factory) {\n'; | ||
|
||
const s = new MagicString(source); | ||
s.appendRight(source.indexOf(preludeString) + preludeString.length, ` | ||
/* begin worker prelude */ | ||
const isWebWorker = (function () { try { return self instanceof WorkerGlobalScope; } catch(e) { return false; } })(); | ||
if (!isWebWorker) { | ||
const _factory = factory; | ||
factory = function () { | ||
const bundleString = \`const mbgl = (\${_factory})(); | ||
mbgl._createWorker(self);\`; | ||
const mbgl = _factory(); | ||
mbgl.workerUrl = window.URL.createObjectURL( | ||
new Blob([bundleString], { type: 'text/javascript' }) | ||
); | ||
return mbgl; | ||
} | ||
} | ||
/* end worker prelude */ | ||
`); | ||
|
||
return { | ||
code: s.toString(), | ||
map: s.generateMap() | ||
}; | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
|
||
export default require('./v8.json'); | ||
import spec from './v8.json'; | ||
export default spec; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
|
||
export default require('../validate_style.min'); | ||
import validateStyle from '../validate_style.min'; | ||
export default validateStyle; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// @flow | ||
|
||
import circle from './style_layer/circle_style_layer'; | ||
import heatmap from './style_layer/heatmap_style_layer'; | ||
import hillshade from './style_layer/hillshade_style_layer'; | ||
import fill from './style_layer/fill_style_layer'; | ||
import fillExtrusion from './style_layer/fill_extrusion_style_layer'; | ||
import line from './style_layer/line_style_layer'; | ||
import symbol from './style_layer/symbol_style_layer'; | ||
import background from './style_layer/background_style_layer'; | ||
import raster from './style_layer/raster_style_layer'; | ||
|
||
const subclasses = { | ||
circle, | ||
heatmap, | ||
hillshade, | ||
fill, | ||
'fill-extrusion': fillExtrusion, | ||
line, | ||
symbol, | ||
background, | ||
raster | ||
}; | ||
|
||
export default function createStyleLayer(layer: LayerSpecification) { | ||
return new subclasses[layer.type](layer); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.