Skip to content

Commit 88a2649

Browse files
committed
upgrade deps
- fix mapbox styles not being included - fix marker element removal timing issue
1 parent 62ea7c6 commit 88a2649

19 files changed

+2870
-3127
lines changed

.editorconfig

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
root = true
66

7-
87
[*]
98
end_of_line = lf
109
charset = utf-8

.eslintrc.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1+
'use strict';
2+
13
module.exports = {
24
root: true,
35
parser: 'babel-eslint',
46
parserOptions: {
57
ecmaVersion: 2018,
6-
sourceType: 'module'
8+
sourceType: 'module',
9+
ecmaFeatures: {
10+
legacyDecorators: true
11+
}
712
},
813
plugins: [
914
'ember'

.travis.yml

+14-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
language: node_js
33
node_js:
4-
- "8"
4+
- "10"
55

66
services:
77
- xvfb
@@ -25,32 +25,34 @@ branches:
2525
- /^v\d+\.\d+\.\d+/
2626

2727
jobs:
28-
fail_fast: true
28+
fast_finish: true
2929

3030
include:
3131
# runs linting and tests with current locked deps
3232

3333
- stage: "Tests"
3434
name: "Tests"
35-
install:
36-
- yarn install --non-interactive
3735
script:
38-
- yarn lint:hbs
39-
- yarn lint:js
40-
- yarn test
36+
- yarn lint
37+
- yarn test:ember
4138

42-
- name: "Floating Dependencies"
39+
- stage: "Additional Tests"
40+
name: "Floating Dependencies"
41+
install:
42+
- yarn install --no-lockfile --non-interactive
4343
script:
44-
- yarn test
44+
- yarn test:ember
4545

46-
- stage: "Additional Tests"
47-
env: EMBER_TRY_SCENARIO=ember-lts-3.4
4846
- env: EMBER_TRY_SCENARIO=ember-lts-3.8
47+
- env: EMBER_TRY_SCENARIO=ember-lts-3.12
48+
- env: EMBER_TRY_SCENARIO=ember-lts-3.16
4949
- env: EMBER_TRY_SCENARIO=ember-release
5050
- env: EMBER_TRY_SCENARIO=ember-beta
51+
- env: EMBER_TRY_SCENARIO=ember-canary
52+
- env: EMBER_TRY_SCENARIO=ember-classic
5153

5254
install:
53-
- yarn install --no-lockfile --non-interactive
55+
- yarn install --non-interactive
5456

5557
script:
5658
- node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO

LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2019
3+
Copyright (c) 2020
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
66

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ module.exports = function(environment) {
3030
```
3131
3232
## Compatibility
33-
* Ember.js v3.4 or above
33+
* Ember.js v3.8 or above
3434
* Ember CLI v2.13 or above
35-
* Node.js v8 or above
35+
* Node.js v10 or above
3636
3737
## API Documentation
3838
See the detailed [API Documentation](API.md).

addon/components/mapbox-gl-marker.js

+16-31
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { assert } from '@ember/debug';
22
import { assign } from '@ember/polyfills';
33
import { getOwner } from '@ember/application';
4-
import { getProperties, get, set } from '@ember/object';
5-
import { run } from '@ember/runloop';
4+
import { getProperties, get } from '@ember/object';
65
import Component from '@ember/component';
76
import layout from '../templates/components/mapbox-gl-marker';
87

@@ -13,6 +12,7 @@ import layout from '../templates/components/mapbox-gl-marker';
1312
*/
1413
export default Component.extend({
1514
layout,
15+
tagName: '',
1616

1717
MapboxGl: null,
1818
map: null,
@@ -22,47 +22,32 @@ export default Component.extend({
2222
init() {
2323
this._super(...arguments);
2424

25-
this.marker = null;
26-
},
25+
this.domContent = document.createElement('div');
26+
const { lngLat, initOptions } = getProperties(this, 'lngLat', 'initOptions');
2727

28-
didInsertElement() {
29-
this._super(...arguments);
28+
assert('mapbox-gl-marker requires lngLat, maybe you passed latLng?', lngLat);
29+
30+
const options = assign({},
31+
get(getOwner(this).resolveRegistration('config:environment'), 'mapbox-gl.marker'),
32+
initOptions);
3033

31-
run.scheduleOnce('afterRender', this, this._setup);
34+
this.marker = new this.MapboxGl.Marker(this.domContent, options)
35+
.setLngLat(lngLat)
36+
.addTo(this.map);
3237
},
3338

3439
didUpdateAttrs() {
3540
this._super(...arguments);
3641

37-
if (this.marker !== null) {
38-
const lngLat = get(this, 'lngLat');
39-
assert('mapbox-gl-marker requires lngLat, maybe you passed latLng?', lngLat);
42+
const lngLat = get(this, 'lngLat');
43+
assert('mapbox-gl-marker requires lngLat, maybe you passed latLng?', lngLat);
4044

41-
this.marker.setLngLat(lngLat);
42-
}
45+
this.marker.setLngLat(lngLat);
4346
},
4447

4548
willDestroy() {
4649
this._super(...arguments);
4750

48-
if (this.marker !== null) {
49-
this.marker.remove();
50-
}
51-
},
52-
53-
_setup() {
54-
const { lngLat, initOptions } = getProperties(this, 'lngLat', 'initOptions');
55-
56-
assert('mapbox-gl-marker requires lngLat, maybe you passed latLng?', lngLat);
57-
58-
const options = assign({},
59-
get(getOwner(this).resolveRegistration('config:environment'), 'mapbox-gl.marker'),
60-
initOptions);
61-
62-
const marker = new this.MapboxGl.Marker(this.element, options)
63-
.setLngLat(lngLat)
64-
.addTo(this.map);
65-
66-
set(this, 'marker', marker);
51+
this.marker.remove();
6752
}
6853
});
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
{{#if marker}}
1+
{{#in-element this.domContent}}
22
{{yield
33
(hash
44
popup=(component 'mapbox-gl-popup' marker=this.marker MapboxGl=this.MapboxGl)
55
)
66
}}
7-
{{/if}}
7+
{{/in-element}}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
{{#in-element domContent}}
1+
{{#in-element this.domContent}}
22
{{yield (hash on=(component 'mapbox-gl-on' eventSource=this.popup))}}
33
{{/in-element}}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{yield
22
(hash
3-
layer=(component 'mapbox-gl-layer' map=map _sourceId=sourceId)
3+
layer=(component 'mapbox-gl-layer' map=this.map _sourceId=this.sourceId)
44
)
55
}}

config/ember-try.js

+35-4
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,26 @@ module.exports = async function() {
88

99
scenarios: [
1010
{
11-
name: 'ember-lts-3.4',
11+
name: 'ember-lts-3.8',
1212
npm: {
1313
devDependencies: {
14-
'ember-source': '~3.4.0'
14+
'ember-source': '~3.8.0'
1515
}
1616
}
1717
},
1818
{
19-
name: 'ember-lts-3.8',
19+
name: 'ember-lts-3.12',
2020
npm: {
2121
devDependencies: {
22-
'ember-source': '~3.8.0'
22+
'ember-source': '~3.12.0'
23+
}
24+
}
25+
},
26+
{
27+
name: 'ember-lts-3.16',
28+
npm: {
29+
devDependencies: {
30+
'ember-source': '~3.16.0'
2331
}
2432
}
2533
},
@@ -39,6 +47,14 @@ module.exports = async function() {
3947
}
4048
}
4149
},
50+
{
51+
name: 'ember-canary',
52+
npm: {
53+
devDependencies: {
54+
'ember-source': await getChannelURL('canary')
55+
}
56+
}
57+
},
4258
// The default `.travis.yml` runs this scenario via `npm test`,
4359
// not via `ember try`. It's still included here so that running
4460
// `ember try:each` manually or from a customized CI config will run it
@@ -48,6 +64,21 @@ module.exports = async function() {
4864
npm: {
4965
devDependencies: {}
5066
}
67+
},
68+
{
69+
name: 'ember-classic',
70+
env: {
71+
EMBER_OPTIONAL_FEATURES: JSON.stringify({
72+
'application-template-wrapper': true,
73+
'default-async-observers': false,
74+
'template-only-glimmer-components': false
75+
})
76+
},
77+
npm: {
78+
ember: {
79+
edition: 'classic'
80+
}
81+
}
5182
}
5283
]
5384
};

index.js

+7-19
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,15 @@ module.exports = {
1616
}
1717
},
1818

19-
treeForStyles(tree) {
20-
const Funnel = require('broccoli-funnel');
21-
22-
const mapboxDirName = require('path').dirname(require.resolve('mapbox-gl'));
23-
const mapboxGlTree = new Funnel(mapboxDirName, {
24-
files: [ 'mapbox-gl.css' ],
25-
destDir: 'app/styles'
26-
});
27-
28-
if (tree) {
29-
const MergeTrees = require('broccoli-merge-trees');
30-
31-
return new MergeTrees([ tree, mapboxGlTree ]);
32-
}
33-
34-
return mapboxGlTree;
35-
},
36-
3719
included(app) {
3820
this._super.included.apply(this, arguments);
3921

40-
app.import('app/styles/mapbox-gl.css');
22+
const path = require('path');
23+
const mapboxDirName = path.dirname(require.resolve('mapbox-gl'));
24+
25+
app.import(path.join(
26+
mapboxDirName.slice(mapboxDirName.lastIndexOf('node_modules')),
27+
'mapbox-gl.css'
28+
));
4129
}
4230
};

0 commit comments

Comments
 (0)