Skip to content

Commit 8b61812

Browse files
committed
[v8] migrate to monorepo
1 parent 7eeac4b commit 8b61812

File tree

107 files changed

+5058
-7809
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+5058
-7809
lines changed

Diff for: .eslintignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
dist/
22
node_modules/
3-
test/src/utils/mapbox-gl-mock/*.js
3+
test/
4+
modules/**/test/
45
**/vite.config.js
56
examples/vite.config.local.js

Diff for: .eslintrc.cjs

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const {getESLintConfig} = require('ocular-dev-tools/configuration');
1+
const {getESLintConfig} = require('@vis.gl/dev-tools/configuration');
22

33
module.exports = getESLintConfig({
44
react: '16.8.2',
@@ -25,12 +25,14 @@ module.exports = getESLintConfig({
2525
'@typescript-eslint/no-unsafe-member-access': 0,
2626
'@typescript-eslint/no-unsafe-assignment': 0,
2727
'import/named': 0,
28-
'@typescript-eslint/no-empty-function': ['warn', {allow: ['arrowFunctions']}],
29-
'@typescript-eslint/restrict-template-expressions': 0,
3028
'@typescript-eslint/explicit-module-boundary-types': 0,
3129
'@typescript-eslint/no-unsafe-return': 0,
3230
'@typescript-eslint/no-unsafe-call': 0,
33-
'@typescript-eslint/restrict-plus-operands': 0
31+
'@typescript-eslint/restrict-plus-operands': 0,
32+
'@typescript-eslint/no-explicit-any': 0,
33+
'@typescript-eslint/no-unsafe-argument': 0,
34+
'@typescript-eslint/no-shadow': 1,
35+
'@typescript-eslint/no-redundant-type-constituents': 1
3436
}
3537
}
3638
]

Diff for: .github/workflows/release.yml

+43-16
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,58 @@ on:
66
- v*
77

88
jobs:
9-
release-notes:
10-
runs-on: ubuntu-22.04
9+
check_branch:
10+
runs-on: ubuntu-latest
11+
outputs:
12+
should_build: ${{ steps.permitted.outputs.result }}
1113

12-
if: github.repository_owner == 'visgl'
14+
steps:
15+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
16+
17+
- name: Fetch remote branches
18+
run: |
19+
git fetch origin --depth=1
1320
21+
- name: Check if on permitted branch
22+
id: permitted
23+
run: |
24+
result=
25+
if git branch -a --contains $GITHUB_SHA | grep -q 'remotes/origin/master$'; then
26+
result=true
27+
elif git branch -a --contains $GITHUB_SHA | grep -q 'remotes/origin/.*-release$'; then
28+
result=true
29+
fi
30+
echo "result=${result}" >> "$GITHUB_OUTPUT"
31+
32+
release:
33+
runs-on: ubuntu-latest
34+
needs: check_branch
1435
permissions:
1536
contents: write
1637

38+
if: ${{ github.repository_owner == 'visgl' && needs.check_branch.outputs.should_build }}
39+
1740
env:
1841
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
NPM_ACCESS_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
1943

2044
steps:
2145
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
22-
23-
- name: Use Node.js
24-
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
46+
- uses: volta-cli/action@2d68418f32546fd191eb666e232b321d5726484d # v4.1.1
2547
with:
26-
node-version: '18.x'
48+
cache: 'yarn'
2749

28-
- name: Publish release
29-
run: |
30-
body=$(node scripts/github-release.js) &&
31-
curl \
32-
-X POST \
33-
-H "Accept: application/vnd.github.v3+json" \
34-
https://api.github.com/repos/visgl/react-map-gl/releases \
35-
-d "${body}" \
36-
-H "Authorization: token ${GITHUB_TOKEN}"
50+
- name: Install dependencies
51+
run: yarn
52+
53+
- name: Build packages
54+
run: npm run build
55+
56+
- name: Run tests from transpiled code
57+
run: npx ocular-test dist
58+
59+
- name: Login to NPM
60+
run: npm config set "//registry.npmjs.org/:_authToken=${NPM_ACCESS_TOKEN}"
61+
62+
- name: Publish to NPM
63+
run: npx ocular-publish from-git

Diff for: .github/workflows/test.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ jobs:
1313

1414
steps:
1515
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
16-
17-
- name: Use Node.js
18-
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
16+
- uses: volta-cli/action@2d68418f32546fd191eb666e232b321d5726484d # v4.1.1
1917
with:
20-
node-version: '18.x'
18+
cache: "yarn"
2119

2220
- name: Install dependencies
2321
run: |
@@ -27,6 +25,7 @@ jobs:
2725
env:
2826
VITE_MAPBOX_TOKEN: ${{ secrets.MAPBOX_ACCESS_TOKEN_CI }}
2927
run: |
28+
yarn lint
3029
yarn test ci
3130
3231
- name: Coveralls

Diff for: .gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ npm-debug.log
99
package-lock.json
1010
examples/**/yarn.lock
1111
test/**/yarn.lock
12-
*/**/package-lock.json
12+
**/package-lock.json
13+
**/tsconfig.tsbuildinfo
1314
yarn-error.log
1415
.DS_Store
1516
.reify-cache
17+
tsconfig.tsbuildinfo
1618

1719
.idea

Diff for: .ocularrc.js

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
1+
/** @typedef {import('@vis.gl/dev-tools').OcularConfig} OcularConfig */
12
import {resolve} from 'path';
23

4+
/** @type {OcularConfig} */
35
export default {
46
lint: {
5-
paths: ['src', 'test', 'examples']
7+
paths: ['modules', 'test', 'examples']
68
},
79

8-
typescript: {
9-
project: 'tsconfig.build.json'
10+
coverage: {
11+
test: 'browser'
1012
},
1113

1214
aliases: {
13-
'react-map-gl/test': resolve('./test'),
14-
'react-map-gl': resolve('./src')
15-
},
16-
nodeAliases: {
17-
'react-dom': resolve('./test/src/utils/react-dom-mock.js')
1815
},
1916

2017
browserTest: {
@@ -24,6 +21,10 @@ export default {
2421
entry: {
2522
test: 'test/node.js',
2623
'test-browser': 'test/browser.js',
27-
size: ['test/size/all.js', 'test/size/map.js']
24+
size: [
25+
'test/size/mapbox-legacy.js',
26+
'test/size/maplibre.js',
27+
'test/size/mapbox.js'
28+
]
2829
}
2930
};

Diff for: babel.config.cjs

-6
This file was deleted.

Diff for: examples/deckgl-overlay/src/app.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import {createRoot} from 'react-dom/client';
33
import {ArcLayer} from '@deck.gl/layers/typed';
44
import {DeckProps, PickingInfo} from '@deck.gl/core/typed';
55
import {MapboxOverlay} from '@deck.gl/mapbox/typed';
6-
import {useControl} from 'react-map-gl';
7-
8-
import Map, {NavigationControl} from 'react-map-gl';
6+
import Map, {useControl, NavigationControl} from 'react-map-gl';
97

108
const TOKEN = ''; // Set your mapbox token here
119

Diff for: examples/geocoder/src/control-panel.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
22

3-
function ControlPanel(props) {
3+
function ControlPanel() {
44
return (
55
<div className="control-panel">
66
<h3>Geocoder</h3>

Diff for: examples/terrain/src/control-panel.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
22

3-
function ControlPanel(props) {
3+
function ControlPanel() {
44
return (
55
<div className="control-panel">
66
<h3>3D Terrain</h3>

Diff for: lerna.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"version": "8.0.0-alpha.0",
3+
"npmClient": "yarn",
4+
"packages": [
5+
"modules/*"
6+
]
7+
}

Diff for: maplibre/package.json

-6
This file was deleted.

Diff for: modules/main/README.md

+1

Diff for: modules/main/package.json

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"name": "react-map-gl",
3+
"description": "React components for MapLibre GL JS and Mapbox GL JS",
4+
"version": "8.0.0-alpha.0",
5+
"keywords": [
6+
"mapbox",
7+
"maplibre",
8+
"mapbox-gl",
9+
"maplibre-gl",
10+
"react"
11+
],
12+
"repository": {
13+
"type": "git",
14+
"url": "https://github.com/visgl/react-map-gl.git"
15+
},
16+
"license": "MIT",
17+
"type": "module",
18+
"exports": {
19+
"./mapbox": {
20+
"types": "./dist/mapbox.d.ts",
21+
"require": "./dist/mapbox.cjs",
22+
"import": "./dist/mapbox.js"
23+
},
24+
"./maplibre": {
25+
"types": "./dist/maplibre.d.ts",
26+
"require": "./dist/maplibre.cjs",
27+
"import": "./dist/maplibre.js"
28+
},
29+
"./mapbox-legacy": {
30+
"types": "./dist/mapbox-legacy/index.d.ts",
31+
"require": "./dist/mapbox-legacy/index.cjs",
32+
"import": "./dist/mapbox-legacy/index.js"
33+
}
34+
},
35+
"files": [
36+
"src",
37+
"dist",
38+
"README.md"
39+
],
40+
"dependencies": {
41+
"@vis.gl/react-maplibre": "8.0.0-alpha.0",
42+
"@vis.gl/react-mapbox": "8.0.0-alpha.0"
43+
},
44+
"devDependencies": {
45+
"@types/mapbox-gl": "3.4.0",
46+
"mapbox-gl": "1.13.0"
47+
},
48+
"peerDependencies": {
49+
"mapbox-gl": ">=1.13.0",
50+
"maplibre-gl": ">=1.13.0",
51+
"react": ">=16.3.0",
52+
"react-dom": ">=16.3.0"
53+
},
54+
"peerDependenciesMeta": {
55+
"mapbox-gl": {
56+
"optional": true
57+
},
58+
"maplibre-gl": {
59+
"optional": true
60+
}
61+
}
62+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: src/components/source.ts renamed to modules/main/src/mapbox-legacy/components/source.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as React from 'react';
2-
import {useContext, useEffect, useMemo, useState, useRef} from 'react';
3-
import {cloneElement} from 'react';
2+
import {useContext, useEffect, useMemo, useState, useRef, cloneElement} from 'react';
43
import {MapContext} from './map';
54
import assert from '../utils/assert';
65
import {deepEqual} from '../utils/deep-equal';
@@ -13,7 +12,7 @@ import type {
1312
ImageSourceImplemtation,
1413
AnySourceImplementation
1514
} from '../types';
16-
import type {GeoJSONSourceRaw, ImageSourceRaw, VectorSourceRaw} from '../types/style-spec-maplibre';
15+
import type {GeoJSONSourceRaw, ImageSourceRaw, VectorSourceRaw} from '../types/style-spec-mapbox';
1716

1817
export type SourceProps<SourceT> = (SourceT | CustomSource) & {
1918
id?: string;
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: src/mapbox/create-ref.ts renamed to modules/main/src/mapbox-legacy/mapbox/create-ref.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const skipMethods = [
3434

3535
export type MapRef<MapT extends MapInstance> = {
3636
getMap(): MapT;
37-
} & Omit<MapT, typeof skipMethods[number]>;
37+
} & Omit<MapT, (typeof skipMethods)[number]>;
3838

3939
export default function createRef<
4040
StyleT extends MapStyle,
@@ -46,7 +46,7 @@ export default function createRef<
4646
}
4747

4848
const map = mapInstance.map as MapInstanceInternal<MapT>;
49-
const result: any = {
49+
const ref: any = {
5050
getMap: () => map,
5151

5252
// Overwrite getters to use our shadow transform
@@ -89,12 +89,12 @@ export default function createRef<
8989

9090
for (const key of getMethodNames(map)) {
9191
// @ts-expect-error
92-
if (!(key in result) && !skipMethods.includes(key)) {
93-
result[key] = map[key].bind(map);
92+
if (!(key in ref) && !skipMethods.includes(key)) {
93+
ref[key] = map[key].bind(map);
9494
}
9595
}
9696

97-
return result;
97+
return ref;
9898
}
9999

100100
function getMethodNames(obj: Object) {

Diff for: src/mapbox/mapbox.ts renamed to modules/main/src/mapbox-legacy/mapbox/mapbox.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ export default class Mapbox<
624624
}
625625
}
626626

627-
_onPointerEvent = (e: MapMouseEvent<MapT> | MapMouseEvent<MapT>) => {
627+
_onPointerEvent = (e: MapMouseEvent<MapT>) => {
628628
if (e.type === 'mousemove' || e.type === 'mouseout') {
629629
this._updateHover(e);
630630
}
@@ -727,12 +727,14 @@ function getAccessTokenFromEnv(): string {
727727

728728
// Note: This depends on bundler plugins (e.g. webpack) importing environment correctly
729729
try {
730+
// eslint-disable-next-line no-process-env
730731
accessToken = accessToken || process.env.MapboxAccessToken;
731732
} catch {
732733
// ignore
733734
}
734735

735736
try {
737+
// eslint-disable-next-line no-process-env
736738
accessToken = accessToken || process.env.REACT_APP_MAPBOX_ACCESS_TOKEN;
737739
} catch {
738740
// ignore
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: modules/main/src/mapbox.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from '@vis.gl/react-mapbox';

Diff for: modules/main/src/maplibre.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from '@vis.gl/react-maplibre';

0 commit comments

Comments
 (0)