Skip to content

Commit

Permalink
Merge branch 'main' into pluggable-render
Browse files Browse the repository at this point in the history
* main: (98 commits)
  [Jest] Migrate `geojson_worker_source.test.js` (maplibre#731)
  Fix events being fired after Map#remove has been called when the WebGL context is lost and restored (maplibre#726) (maplibre#727)
  Define return type of getSource as possibly undefined (maplibre#724)
  Fix attibution controll (maplibre#668)
  Fix start-debug to watch ts files (maplibre#704)
  [Jest] Migrate `touch_zoom_rotate.test.js` (maplibre#721)
  [Jest] Migrate `requestRenderFrame.test.js` (maplibre#722)
  [Jest] Migrate `scroll_zoom.test.js` (maplibre#712)
  [Jest] Migrate `marker.test.js` (maplibre#696)
  [Jest] Migrate `mouse_rotate.test.js` (maplibre#711)
  [Jest] Migrate `keyboard.test.js` (maplibre#707)
  [Jest] Migrate `map_event.test.js` (maplibre#710)
  [Jest] Migrate `drag_rotate.test.js` (maplibre#709)
  Handle spies and call counts (maplibre#708)
  [Jest] Migrate `drag_pan.test.js` (maplibre#702)
  Add type for styleimagemissing event (maplibre#703)
  Fix MapDataEvent#isSourceLoaded being true in GeoJSONSource "dataloading" event handlers (maplibre#694) (maplibre#695)
  [Jest] Migrate `dblclick_zoom.test.js` (maplibre#697)
  [Jest] Migrate `popup.test.js` (maplibre#687)
  Fixed typo (maplibre#698)
  ...
  • Loading branch information
davenquinn committed Dec 29, 2021
2 parents 87ac382 + aee0f05 commit 61fd24c
Show file tree
Hide file tree
Showing 178 changed files with 13,302 additions and 11,434 deletions.
18 changes: 16 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"plugins": [
"@typescript-eslint",
"import",
"jsdoc"
"jsdoc",
"jest"
],
"rules": {
"no-dupe-class-members": "off",
Expand Down Expand Up @@ -91,7 +92,20 @@
"jsdoc/require-param-description": "warn",
"jsdoc/require-param-name": "warn",
"jsdoc/require-returns": "warn",
"jsdoc/require-returns-description": "warn"
"jsdoc/require-returns-description": "warn",

// Jest https://www.npmjs.com/package/eslint-plugin-jest
"jest/no-commented-out-tests": "error",
"jest/no-disabled-tests": "warn",
"jest/no-focused-tests": "error",
"jest/prefer-to-contain": "warn",
"jest/prefer-to-have-length": "warn",
"jest/valid-expect": "error",
"jest/prefer-to-be": "warn",
"jest/no-alias-methods": "warn",
"jest/no-interpolation-in-snapshots": "warn",
"jest/no-large-snapshots": ["warn", { "maxSize": 50, "inlineMaxSize": 20 }],
"jest/no-deprecated-functions": "warn"
},
"settings": {
"jsdoc":{
Expand Down
21 changes: 16 additions & 5 deletions .github/ISSUE_TEMPLATE/Bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@ about: Report a bug
<!--
Hello! Thanks for contributing. For the fastest response and resolution, please:
- Make the issue title a succinct but specific description of the unexpected behavior. Bad: "Map rotation is broken". Good: "map.setBearing(...) throws a TypeError for negative values"
- Include a link to a minimal demonstration of the bug. We recommend using https://jsbin.com.
- Make the issue title a succinct but specific description of the unexpected behavior.
Bad: "Map rotation is broken".
Good: "map.setBearing(...) throws a TypeError for negative values"
- Include a link to a minimal demonstration of the bug – more below …
- Ensure you can reproduce the bug using the latest release.
- Check the console for relevant errors and warnings
- Only post to report a bug. For feature requests, please use https://github.com/maplibre/maplibre-gl-js/issues/new?template=Feature_request.md instead. Direct all other questions to https://stackoverflow.com/questions/tagged/maplibre-gl-js
-->
Expand All @@ -28,10 +34,15 @@ Hello! Thanks for contributing. For the fastest response and resolution, please
### Link to Demonstration

<!--
Providing a minimal, complete, verifiable demonstration *dramatically* improves maintainers' and other community members' ability to understand and address the problem you're reporting. (See https://stackoverflow.com/help/mcve for guidelines on creating an effective example.)
-->
Providing a minimal, complete, verifiable demonstration *dramatically* improves maintainers' and other community members' ability to understand and address the problem you're reporting.
We recommend using https://jsbin.com.
https://jsbin.com/
Consider using the non-minified version for this demo to create better error messages.
E.g. `<script src='https://unpkg.com/[email protected]/dist/maplibre-gl-dev.js'></script><link href='https://unpkg.com/[email protected]/dist/maplibre-gl.css' rel='stylesheet' />`
See https://stackoverflow.com/help/mcve for guidelines on creating an effective example.
-->

### Expected Behavior

Expand Down
13 changes: 7 additions & 6 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ jobs:
steps:
- uses: actions/stale@v4
with:
stale-issue-message: 'This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.'
stale-pr-message: 'This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.'
close-issue-message: 'This issue was closed because it has been stalled for 7 days with no activity.'
close-pr-message: 'This PR was closed because it has been stalled for 7 days with no activity.'
days-before-stale: 60
days-before-close: 7
stale-issue-message: 'This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 30 days.'
stale-pr-message: 'This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.'
close-issue-message: 'This issue was closed because it has been stalled for 30 days with no activity.'
close-pr-message: 'This PR was closed because it has been stalled for 30 days with no activity.'
days-before-pr-stale: 60
days-before-issue-stale: 180
days-before-close: 30
22 changes: 21 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,23 @@
- ** Breaking Change ** stopped supporting IE (internet explorer)
- ** Breaking Change ** removed all code related to `accessToken` and mapbox specific urls, including telemetry etc. Please do not use mapbox servers with this library.
- ** Breaking Change ** removed `baseApiUrl` as it was used only for mapbox related urls
- Added redraw function to map (#206)
- ** Breaking Change ** typescript typings have changed:
- `Style` => `StypeSpecification`
- `AnyLayer` => `LayerSpecification`
- `AnySourceData` => `SourceSpecification`
- `MapboxEvent` => `MapLibreEvent`
- `MapboxOptions` => `MapOptions`
- `MapBoxZoomEvent` => `MapLibreZoomEvent`
- `*SourceRaw` + `*SourceOptions` => `*SourceSpecification`
- `*Source` (source implementation definition) were removed
- `*Layer` => `*LayerSpecification`
- `*Paint` => `*LayerSpecification['paint']`
- `*Layout` => `*LayerSpecification['layout']`
- `MapboxGeoJSONFeature` => `GeoJSONFeature`
- Added `redraw` function to map (#206)
- Improve attribution controls accessibility. See [#359](https://github.com/maplibre/maplibre-gl-js/issues/359)
- Allow maxPitch value up to 85, use values greater than 60 at your own risk (#574)
- `getImage` uses createImageBitmap when supported (#650)
- *...Add new stuff here...*

### 🐞 Bug fixes
Expand All @@ -26,6 +42,10 @@
- Fix tile placeholder replacement to allow for placeholders to be in a URL more than once. (#348)
- Fix type check for non dom environment. (#334)
- Fix precision problem in patterns when overzoomed in OpenGL ES devices.
- Fix padding-top of the popup to improve readability of popup text (#354).
- Fix GeoJSONSource#loaded sometimes returning true while there are still pending loads (#669)
- Fix MapDataEvent#isSourceLoaded being true in GeoJSONSource "dataloading" event handlers (#694)
- Fix events being fired after Map#remove has been called when the WebGL context is lost and restored (#726)

## 1.15.2

Expand Down
41 changes: 32 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,75 @@
# MapLibre GL

**MapLibre GL** is a community led fork derived from [mapbox-gl-js](https://github.com/mapbox/mapbox-gl-js) prior to their switch to a non-OSS license.
**MapLibre GL** is a community-led fork derived from [mapbox-gl-js](https://github.com/mapbox/mapbox-gl-js) before their switch to a non-OSS license.

### Migrating from mapbox-gl

If you depend on mapbox-gl directly, simply replace `mapbox-gl` with `maplibre-gl` in `package.json`:

Use

```diff
"dependencies": {
- "mapbox-gl": "^1.13.0"
+ "maplibre-gl": ">=1.14.0"
+ "maplibre-gl": ">=1.15.2"
}
```

And replace ```mapboxgl``` with ```maplibregl``` in your JavaScript and optionally in your HTML/CSS code:
if it is important to you that the behaviour is similar to `mapbox-gl` version 1.x.

And replace `mapboxgl` with `maplibregl` in your JavaScript and optionally in your HTML/CSS code:

> MapLibre GL JS is distributed via [unpkg.com](https://unpkg.com). For more informations please see [MapLibre GL is on unpkg.com](./docs/README-unpkg.md#maplibre-gl-on-unpkgcom).
```diff
- <script src="https://api.mapbox.com/mapbox-gl-js/v1.13.0/mapbox-gl.js"></script>
- <link
- href="https://api.mapbox.com/mapbox-gl-js/v1.13.0/mapbox-gl.css"
- rel="stylesheet"
- />

<!-- Use maplibre-gl version 1.15.2 for backwards compatibility with mapbox-gl version 1.x. -->
+ <script src="https://unpkg.com/[email protected]/dist/maplibre-gl.js"></script>
+ <link
+ href="https://unpkg.com/[email protected]/dist/maplibre-gl.css"
+ rel="stylesheet"
+ />

- var map = new mapboxgl.Map({
+ var map = new maplibregl.Map({

- <button class="mapboxgl-ctrl">
+ <button class="maplibregl-ctrl">
```

Want an example? Have a look at the official [MapLibre GL JS Documentation](https://maplibre.org/maplibre-gl-js-docs/example/).
Want an example? Have a look at the official [MapLibre GL JS Documentation](https://maplibre.org/maplibre-gl-js-docs/example/).

Use MapLibre GL JS bindings for React (https://visgl.github.io/react-map-gl/docs/get-started/get-started#using-with-a-mapbox-gl-fork) and Angular (https://github.com/maplibre/ngx-maplibre-gl). Find more at [awesome-maplibre](https://github.com/maplibre/awesome-maplibre).

### Roadmap

This project's initial plans are outlined in the [Roadmap](https://github.com/maplibre/maplibre-gl-js/projects/2) project. The primary goal is consistency and backwards-compatability with previous releases and continued bug-fixes and maintenance going forward.
This project's initial plans are outlined in the [Roadmap](https://github.com/maplibre/maplibre-gl-js/projects/2) project. The primary goal is consistency and continued bug fixes and maintenance as we advance.

> **MapLibre GL** is developed following [Semantic Versioning (2.0.0)](http://semver.org/spec/v2.0.0.html).
### Getting Involved

Join the #maplibre slack channel at OSMUS: get an invite at https://osmus-slack.herokuapp.com/

### Community Leadership

The official status of the backing community and steering committee can be found in the [COMMUNITY.md](COMMUNITY.md) document.
You can find the official status of the backing community and steering committee in the [COMMUNITY.md](COMMUNITY.md) document.

### Avoid Fragmentation

If you depend on a free software alternative to `mapbox-gl-js`, please consider joining our effort! Anyone with a stake in a healthy community led fork is welcome to help us figure out our next steps. We welcome contributors and leaders! MapLibre GL already represents the combined efforts of a few early fork efforts, and we all benefit from "one project" rather than "our way". If you know of other forks, please reach out to them and direct them here.
If you depend on a free software alternative to `mapbox-gl-js`, please consider joining our effort! Anyone with a stake in a healthy community-led fork is welcome to help us figure out our next steps. We welcome contributors and leaders! MapLibre GL already represents the combined efforts of a few early fork efforts, and we all benefit from "one project" rather than "our way". If you know of other forks, please reach out to them and direct them here.

### Thank you Mapbox 🙏🏽

We'd like to acknowledge the amazing work Mapbox has contributed to open source. The open source community is sad to part ways with them, but we simultaneously feel grateful for everything they already contributed. `mapbox-gl-js` 1.x is an open source achievment which now lives on as `maplibre-gl`. We're proud to develop on the shoulders of giants, thank you Mapbox 🙇🏽‍♀️.
We'd like to acknowledge the amazing work Mapbox has contributed to open source. The open source community is sad to part ways with them, but we simultaneously feel grateful for everything they already contributed. `mapbox-gl-js` 1.x is an open source achievement which now lives on as `maplibre-gl`. We're proud to develop on the shoulders of giants, thank you Mapbox 🙇🏽‍♀️.

Please keep in mind: Unauthorized backports are the biggest threat to the MapLibre project. It is unacceptable to backport code from mapbox-gl-js, which is not covered by the former BSD-3 license. If you are unsure about this issue, [please ask](https://github.com/maplibre/maplibre-gl-js/discussions)!

## License

MapLibre GL is licensed under the [3-Clause BSD license](./LICENSE.txt).
**MapLibre GL** is licensed under the [3-Clause BSD license](./LICENSE.txt).
34 changes: 0 additions & 34 deletions build/copy-glsl-files.js

This file was deleted.

27 changes: 16 additions & 11 deletions build/generate-style-code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@ import * as fs from 'fs';

import spec from '../src/style-spec/reference/v8.json';

function camelizeWithLeadingLowercase(str) {
function camelCase(str: string): string {
return str.replace(/-(.)/g, function (_, x) {
return x.toUpperCase();
});
}

function pascalCase(str: string): string {
let almostCamelized = camelCase(str);
return almostCamelized[0].toUpperCase() + almostCamelized.slice(1);
}

function nativeType(property) {
switch (property.type) {
case 'boolean':
Expand Down Expand Up @@ -97,7 +102,7 @@ function runtimeType(property) {
}

function overrides(property) {
return `{ runtimeType: ${runtimeType(property)}, getOverride: (o) => o.${camelizeWithLeadingLowercase(property.name)}, hasOverride: (o) => !!o.${camelizeWithLeadingLowercase(property.name)} }`;
return `{ runtimeType: ${runtimeType(property)}, getOverride: (o) => o.${camelCase(property.name)}, hasOverride: (o) => !!o.${camelCase(property.name)} }`;
}

function propertyValue(property, type) {
Expand Down Expand Up @@ -146,7 +151,7 @@ const layers = Object.keys(spec.layer.type.values).map((type) => {

function emitlayerProperties(locals) {
const output = [];

const layerType = pascalCase(locals.type);
const {
layoutProperties,
paintProperties
Expand Down Expand Up @@ -188,7 +193,7 @@ import {StylePropertySpecification} from '../../style-spec/style-spec';

if (layoutProperties.length) {
output.push(
'export type LayoutProps = {');
`export type ${layerType}LayoutProps = {`);

for (const property of layoutProperties) {
output.push(
Expand All @@ -198,7 +203,7 @@ import {StylePropertySpecification} from '../../style-spec/style-spec';
output.push(
`};
export type LayoutPropsPossiblyEvaluated = {`);
export type ${layerType}LayoutPropsPossiblyEvaluated = {`);

for (const property of layoutProperties) {
output.push(
Expand All @@ -208,7 +213,7 @@ export type LayoutPropsPossiblyEvaluated = {`);
output.push(
`};
const layout: Properties<LayoutProps> = new Properties({`);
const layout: Properties<${layerType}LayoutProps> = new Properties({`);

for (const property of layoutProperties) {
output.push(
Expand All @@ -222,7 +227,7 @@ const layout: Properties<LayoutProps> = new Properties({`);
if (paintProperties.length) {
output.push(
`
export type PaintProps = {`);
export type ${layerType}PaintProps = {`);

for (const property of paintProperties) {
output.push(
Expand All @@ -232,7 +237,7 @@ export type PaintProps = {`);
output.push(
`};
export type PaintPropsPossiblyEvaluated = {`);
export type ${layerType}PaintPropsPossiblyEvaluated = {`);

for (const property of paintProperties) {
output.push(
Expand All @@ -243,12 +248,12 @@ export type PaintPropsPossiblyEvaluated = {`);
'};');
} else {
output.push(
'export type PaintProps = {};');
`export type ${layerType}PaintProps = {};`);
}

output.push(
`
const paint: Properties<PaintProps> = new Properties({`);
const paint: Properties<${layerType}PaintProps> = new Properties({`);

for (const property of paintProperties) {
output.push(
Expand All @@ -259,7 +264,7 @@ const paint: Properties<PaintProps> = new Properties({`);
`});
export default ({ paint${layoutProperties.length ? ', layout' : ''} } as {
paint: Properties<PaintProps>${layoutProperties.length ? ',\n layout: Properties<LayoutProps>' : ''}
paint: Properties<${layerType}PaintProps>${layoutProperties.length ? ',\n layout: Properties<' + layerType + 'LayoutProps>' : ''}
});`);

return output.join('\n');
Expand Down
8 changes: 4 additions & 4 deletions build/generate-style-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function propertyType(property) {
} else if (properties.supportsZoomExpression(property)) {
return `PropertyValueSpecification<${baseType}>`;
} else if (property.expression) {
return 'ExpressionSpecification';
return 'ExpressionSpecificationArray';
} else {
return baseType;
}
Expand Down Expand Up @@ -158,19 +158,19 @@ export type CompositeFunctionSpecification<T> =
| { type: 'interval', stops: Array<[{zoom: number, value: number}, T]>, property: string, default?: T }
| { type: 'categorical', stops: Array<[{zoom: number, value: string | number | boolean}, T]>, property: string, default?: T };
export type ExpressionSpecification = Array<unknown>;
export type ExpressionSpecificationArray = Array<unknown>;
export type PropertyValueSpecification<T> =
T
| CameraFunctionSpecification<T>
| ExpressionSpecification;
| ExpressionSpecificationArray;
export type DataDrivenPropertyValueSpecification<T> =
T
| CameraFunctionSpecification<T>
| SourceFunctionSpecification<T>
| CompositeFunctionSpecification<T>
| ExpressionSpecification;
| ExpressionSpecificationArray;
${objectDeclaration('StyleSpecification', spec.$root)}
Expand Down
12 changes: 12 additions & 0 deletions build/glsl_to_js.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export default function glsl_to_js(code, minify) {
if (minify) {
code = code.trim() // strip whitespace at the start/end
.replace(/\s*\/\/[^\n]*\n/g, '\n') // strip double-slash comments
.replace(/\n+/g, '\n') // collapse multi line breaks
.replace(/\n\s+/g, '\n') // strip identation
.replace(/\s?([+-\/*=,])\s?/g, '$1') // strip whitespace around operators
.replace(/([;\(\),\{\}])\n(?=[^#])/g, '$1'); // strip more line breaks

}
return `export default ${JSON.stringify(code)};`;
}
Loading

0 comments on commit 61fd24c

Please sign in to comment.