Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
stepankuzmin authored Jun 28, 2024
2 parents 41ac581 + abbb41a commit b743cd9
Show file tree
Hide file tree
Showing 102 changed files with 12,820 additions and 8,757 deletions.
11 changes: 0 additions & 11 deletions .babelrc

This file was deleted.

4 changes: 2 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"mourner",
"plugin:import/recommended"
],
"parser": "@babel/eslint-parser",
"parser": "espree",
"parserOptions": {
"sourceType": "module",
"requireConfigFile": false
"ecmaVersion": 2020
},
"plugins": [
"import"
Expand Down
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @mapbox/gl-js
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 2
updates:
- package-ecosystem: npm
directory: /
open-pull-requests-limit: 999
schedule:
interval: weekly

- package-ecosystem: github-actions
open-pull-requests-limit: 999
directory: /
schedule:
interval: weekly
27 changes: 27 additions & 0 deletions .github/workflows/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Auto-merge patch dependency updates
on: pull_request

permissions: write-all

jobs:
dependabot:
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/[email protected]
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: Approve Dependabot PRs
if: steps.metadata.outputs.update-type == 'version-update:semver-patch'
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Enable auto-merge for Dependabot PRs
if: steps.metadata.outputs.update-type == 'version-update:semver-patch'
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
32 changes: 32 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: test

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'npm'

- uses: actions/cache@v4
with:
path: |
~/.npm
node_modules
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- run: npm ci
- run: npm test
21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

39 changes: 36 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,44 @@
## Changelog
# Changelog

# 1.2.2
## 1.4.3

* Fix for layer not found error in `featuresAt` function by @caldwellc in https://github.com/mapbox/mapbox-gl-draw/pull/1194
* Trigger `featureChanged` on feature props change by @wyozi in https://github.com/mapbox/mapbox-gl-draw/pull/1196
* Remove `preventDefault()` on `touchstart` and `touchmove` events by @Archetylator in https://github.com/mapbox/mapbox-gl-draw/pull/1195

## 1.4.2

* Fix key event handler checks for `mapboxgl-canvas` by @neodescis in https://github.com/mapbox/mapbox-gl-draw/pull/1165
* Fix draw updates not firing consistently by @gynekolog in https://github.com/mapbox/mapbox-gl-draw/pull/1160
* Fix boxZoom restoring after removal by @kibala145 in https://github.com/mapbox/mapbox-gl-draw/pull/1017

## 1.4.1

* Revert use of passive event listeners instead of `preventDefault` in https://github.com/mapbox/mapbox-gl-draw/pull/1158

## 1.4.0

* Reduce NPM package size and big dependency and dev environment cleanup by @mourner in https://github.com/mapbox/mapbox-gl-draw/pull/1119 https://github.com/mapbox/mapbox-gl-draw/pull/1053
* Add Bezier Curve mode by @Jeff-Numix in https://github.com/mapbox/mapbox-gl-draw/pull/1068
* Update control buttons styles by @chriswhong in https://github.com/mapbox/mapbox-gl-draw/pull/1125
* Use passive event listeners instead of `preventDefault` by @danielsippel in https://github.com/mapbox/mapbox-gl-draw/pull/1146
* Adding sorting rank value for MultiLineString by @zhangchn in https://github.com/mapbox/mapbox-gl-draw/pull/1142
* Expose constants and lib APIs to make it easier to write custom draw modes by @thaddmt in https://github.com/mapbox/mapbox-gl-draw/pull/1100

## 1.3.0

- ⚠️ Removed GeoJSON validation in `draw.add` — responsibility for valid input is now on the user. #1052
- Fixed NPM security warnings about dependencies. #1052
- Fixed midpoint calculation when terrain is enabled. #1039
- Reduced the size of the plugin's CSS code from 33KB to 5KB. #1038 (h/t @johanrd)
- Fixed `simple_select` mode handling on touch devices. #1008 (h/t @corinv)

## 1.2.2

### Bug Fixes:
- Fix midpoint calculation when using mapbox-gl-draw with 3d terrain

# 1.2.1
## 1.2.1

### Bug Fixes:
- Upgrade `peerDependencies` to allow `[email protected]+` to be used with gl-draw.
Expand Down
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# @mapbox/mapbox-gl-draw

[![Build Status](https://travis-ci.org/mapbox/mapbox-gl-draw.svg?branch=main)](https://travis-ci.org/mapbox/mapbox-gl-draw)
![Build Status](https://github.com/mapbox/mapbox-gl-draw/actions/workflows/main.yml/badge.svg)

Adds support for drawing and editing features on [mapbox-gl.js](https://www.mapbox.com/mapbox-gl-js/) maps. [See a live example here](https://www.mapbox.com/mapbox-gl-js/example/mapbox-gl-draw/)

**Requires [mapbox-gl-js](https://github.com/mapbox/mapbox-gl-js).**

**If you are developing with `mapbox-gl-draw`, see [API.md](https://github.com/mapbox/mapbox-gl-draw/blob/main/docs/API.md) for documentation.**

### Installing

```
Expand All @@ -28,7 +30,7 @@ import MapboxDraw from "@mapbox/mapbox-gl-draw";
**When using a CDN**

```html
<script src='https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-draw/v1.3.0/mapbox-gl-draw.js'></script>
<script src='https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-draw/v1.4.3/mapbox-gl-draw.js'></script>
```

#### CSS
Expand All @@ -40,7 +42,7 @@ import '@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw.css'

**When using CDN**
```html
<link rel='stylesheet' href='https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-draw/v1.3.0/mapbox-gl-draw.css' type='text/css' />
<link rel='stylesheet' href='https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-draw/v1.4.3/mapbox-gl-draw.css' type='text/css' />
```

### Typescript
Expand All @@ -58,7 +60,7 @@ mapboxgl.accessToken = 'YOUR_ACCESS_TOKEN';
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/streets-v11',
style: 'mapbox://styles/mapbox/streets-v12',
center: [40, -74.50],
zoom: 9
});
Expand Down Expand Up @@ -92,8 +94,8 @@ Install dependencies, build the source files and crank up a server via:

```
git clone [email protected]:mapbox/mapbox-gl-draw.git
yarn install
yarn start & open "http://localhost:9967/debug/?access_token=<token>"
npm ci
npm start & open "http://localhost:9967/debug/?access_token=<token>"
```

### Testing
Expand All @@ -118,8 +120,8 @@ To CDN:
```
# make sure you are authenticated for AWS
git checkout v{x.y.z}
yarn install
yarn run prepublish
npm ci
npm run prepublish
aws s3 cp --recursive --acl public-read dist s3://mapbox-gl-js/plugins/mapbox-gl-draw/v{x.y.z}
```

Expand Down
5 changes: 2 additions & 3 deletions bench/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ Benchmarks help us catch performance regressions and improve performance.
Start the benchmark server

```bash
MAPBOX_ACCESS_TOKEN={YOUR MAPBOX ACCESS TOKEN} npm start
MAPBOX_ACCESS_TOKEN={YOUR MAPBOX ACCESS TOKEN} npm run start-bench
```

Open a benchmark runner page

- **buffer benchmark** http://localhost:9966/bench/buffer
- **fps benchmark** http://localhost:9966/bench/fps
- http://localhost:9967/bench/

## Writing a Benchmark

Expand Down
6 changes: 3 additions & 3 deletions bench/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<meta charset='utf-8'>
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<link href='https://www.mapbox.com/base/latest/base.css' rel='stylesheet' />
<link rel='stylesheet' href='https://api.mapbox.com/mapbox-gl-js/v2.10.0/mapbox-gl.css'/>
<link href="https://api.mapbox.com/mapbox-assembly/v1.5.1/assembly.min.css" rel="stylesheet">
<link rel='stylesheet' href='https://api.mapbox.com/mapbox-gl-js/v3.4.0/mapbox-gl.css'/>
<link rel='stylesheet' href='/dist/mapbox-gl-draw.css'/>

<style>
Expand Down Expand Up @@ -47,7 +47,7 @@
<div id="map"></div>
<div id="tests"></div>
<div id="logs"></div>
<script src="https://api.mapbox.com/mapbox-gl-js/v2.10.0/mapbox-gl.js"></script>
<script src="https://api.mapbox.com/mapbox-gl-js/v3.4.0/mapbox-gl.js"></script>
<script src="/dist/mapbox-gl-draw-unminified.js"></script>
<script src="/dist/bench.js"></script>
</body>
Expand Down
2 changes: 1 addition & 1 deletion bench/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function createMap(options) {

const map = new mapboxgl.Map(Object.assign({
container: 'map',
style: 'mapbox://styles/mapbox/streets-v8'
style: 'mapbox://styles/mapbox/streets-v12'
}, options));

const draw = new MapboxDraw(options);
Expand Down
4 changes: 4 additions & 0 deletions bench/lib/evented.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@

export default class Evented {
on(type, listener) {
if (!listener) {
return new Promise(resolve => this.on(type, resolve));
}

this._listeners = this._listeners || {};
this._listeners[type] = this._listeners[type] || [];
this._listeners[type].push(listener);
Expand Down
7 changes: 2 additions & 5 deletions bench/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@

import replace from '@rollup/plugin-replace';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import buble from '@rollup/plugin-buble';
import replace from '@rollup/plugin-replace';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';

export default {
input: ['bench/index.js'],
Expand All @@ -21,7 +19,6 @@ export default {
'process.env.MAPBOX_ACCESS_TOKEN': JSON.stringify(process.env.MAPBOX_ACCESS_TOKEN),
preventAssignment: true
}),
buble({transforms: {dangerousForOf: true}, objectAssign: "Object.assign"}),
resolve({
browser: true,
preferBuiltins: false
Expand Down
18 changes: 10 additions & 8 deletions build/generate-access-token-script.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
/* eslint-disable */
'use strict';
const fs = require('fs');
const path = require('path');
import fs from 'fs';
import path from 'path';
import {fileURLToPath} from 'url';

const __dirname = fileURLToPath(new URL('.', import.meta.url));

const script = fs.readFileSync(path.join(__dirname, '../debug/access_token.js'), 'utf-8')
.replace('process.env.MapboxAccessToken',
JSON.stringify(process.env.MapboxAccessToken))
.replace('process.env.MAPBOX_ACCESS_TOKEN',
JSON.stringify(process.env.MAPBOX_ACCESS_TOKEN));
.replace('process.env.MapboxAccessToken',
JSON.stringify(process.env.MapboxAccessToken))
.replace('process.env.MAPBOX_ACCESS_TOKEN',
JSON.stringify(process.env.MAPBOX_ACCESS_TOKEN));

fs.writeFileSync(path.join(__dirname, '../debug/access_token_generated.js'), script);
14 changes: 0 additions & 14 deletions circle.yml

This file was deleted.

26 changes: 8 additions & 18 deletions debug/access_token.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
'use strict';
export function getAccessToken() {
const accessToken =
process.env.MapboxAccessToken ||
process.env.MAPBOX_ACCESS_TOKEN ||
(new URLSearchParams(location.search).get('access_token')) ||
localStorage.getItem('accessToken');

mapboxgl.accessToken = getAccessToken();

function getAccessToken() {
var accessToken = (
process.env.MapboxAccessToken ||
process.env.MAPBOX_ACCESS_TOKEN ||
getURLParameter('access_token') ||
localStorage.getItem('accessToken')
);
localStorage.setItem('accessToken', accessToken);
return accessToken;
}

function getURLParameter(name) {
var regexp = new RegExp('[?&]' + name + '=([^&#]*)', 'i');
var output = regexp.exec(window.location.href);
return output && output[1];
localStorage.setItem('accessToken', accessToken);
return accessToken;
}
Loading

0 comments on commit b743cd9

Please sign in to comment.