Skip to content

Commit ca41867

Browse files
add a formatter
1 parent 2e757d5 commit ca41867

File tree

159 files changed

+7813
-4980
lines changed

Some content is hidden

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

159 files changed

+7813
-4980
lines changed

.oxfmtrc.jsonc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"$schema": "./node_modules/oxfmt/configuration_schema.json",
3+
"tabWidth": 4,
4+
"singleQuote": true,
5+
"bracketSpacing": false
6+
}

bin/gl-style-migrate.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,3 @@ function help() {
1616
console.log('usage:');
1717
console.log(' gl-style-migrate style-v7.json > style-v8.json');
1818
}
19-

build/bump-version-changelog.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ const changelogPath = 'CHANGELOG.md';
1313
let changelog = readFileSync(changelogPath, 'utf8');
1414
changelog = changelog.replace('## main', `## ${process.argv[2]}`);
1515
changelog = changelog.replaceAll('- _...Add new stuff here..._\n', '');
16-
changelog = `## main
16+
changelog =
17+
`## main
1718
1819
### ✨ Features and improvements
1920
- _...Add new stuff here..._

build/generate-docs.ts

Lines changed: 83 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import v8 from '../src/reference/v8.json' with { type: 'json' };
1+
import v8 from '../src/reference/v8.json' with {type: 'json'};
22
import fs from 'fs';
33
import {formatJSON} from './util';
44

@@ -19,15 +19,15 @@ type JsonExpressionSyntax = {
1919
type: string;
2020
doc?: string;
2121
}[];
22-
}
22+
};
2323

2424
type JsonSdkSupport = {
2525
[info: string]: {
2626
js?: string;
2727
android?: string;
2828
ios?: string;
2929
};
30-
}
30+
};
3131

3232
type JsonObject = {
3333
required?: boolean;
@@ -37,12 +37,12 @@ type JsonObject = {
3737
doc: string;
3838
requires?: any[];
3939
example: string | object | number;
40-
expression?: { interpolated?: boolean; parameters?: string[]};
40+
expression?: {interpolated?: boolean; parameters?: string[]};
4141
transition?: boolean;
42-
values?: {[key: string]: { doc: string; 'sdk-support'?: JsonSdkSupport }} | number[];
42+
values?: {[key: string]: {doc: string; 'sdk-support'?: JsonSdkSupport}} | number[];
4343
minimum?: number;
4444
maximum?: number;
45-
}
45+
};
4646

4747
/**
4848
* Capitalizes the first letter of the word.
@@ -61,15 +61,17 @@ function capitalize(word: string) {
6161
* @returns true if the element should be a topic, false otherwise
6262
*/
6363
function topicElement(key: string, value: JsonObject): boolean {
64-
return value.type !== 'number' &&
64+
return (
65+
value.type !== 'number' &&
6566
value.type !== 'boolean' &&
6667
key !== 'center' &&
6768
value.type !== '*' &&
6869
value.type !== 'enum' &&
6970
key !== 'name' &&
7071
key !== 'sprite' &&
7172
key !== 'layers' &&
72-
key !== 'sources';
73+
key !== 'sources'
74+
);
7375
}
7476

7577
/**
@@ -99,7 +101,7 @@ function supportCell(support?: string): string {
99101
// if the string is an issue link, generate a link to it
100102
// there is no support yet but there is a tracking issue
101103
const maplibreIssue = /https:\/\/github.com\/maplibre\/[^/]+\/issues\/(\d+)/;
102-
const match = support.match(maplibreIssue);
104+
const match = support.match(maplibreIssue);
103105
if (match) return `❌ ([#${match[1]}](${support}))`;
104106
return support;
105107
}
@@ -230,7 +232,12 @@ function formatRange(minimum?: number, maximum?: number) {
230232
* @param paintLayoutText - the text to be used for the paint/layout property
231233
* @returns the markdown string
232234
*/
233-
function convertPropertyToMarkdown(key: string, value: JsonObject, keyPrefix = '##', paintLayoutText = '') {
235+
function convertPropertyToMarkdown(
236+
key: string,
237+
value: JsonObject,
238+
keyPrefix = '##',
239+
paintLayoutText = '',
240+
) {
234241
let markdown = `${keyPrefix} ${key}\n*`;
235242
if (paintLayoutText) {
236243
markdown += `[${paintLayoutText}](#${paintLayoutText.toLowerCase()}) property. `;
@@ -267,8 +274,9 @@ function convertPropertyToMarkdown(key: string, value: JsonObject, keyPrefix = '
267274
}
268275
if (value.expression?.interpolated) {
269276
if (value.expression.parameters.includes('feature-state')) {
270-
markdown += 'Supports [feature-state](expressions.md#feature-state) and [interpolate](expressions.md#interpolate) expressions. ';
271-
} else {
277+
markdown +=
278+
'Supports [feature-state](expressions.md#feature-state) and [interpolate](expressions.md#interpolate) expressions. ';
279+
} else {
272280
markdown += 'Supports [interpolate](expressions.md#interpolate) expressions. ';
273281
}
274282
}
@@ -337,7 +345,7 @@ function createLayersContent() {
337345
content += convertPropertyToMarkdown(key, value as JsonObject, '###');
338346
}
339347

340-
for (const layoutKey of Object.keys(v8).filter(key => key.startsWith('layout_'))) {
348+
for (const layoutKey of Object.keys(v8).filter((key) => key.startsWith('layout_'))) {
341349
const layerName = layoutKey.replace('layout_', '');
342350
content += `## ${capitalize(layerName)}\n\n`;
343351
for (const [key, value] of Object.entries(v8[layoutKey])) {
@@ -360,143 +368,137 @@ function createSourcesContent() {
360368
doc: 'A vector tile source. Tiles must be in [Mapbox Vector Tile format](https://github.com/mapbox/vector-tile-spec). All geometric coordinates in vector tiles must be between \`-1 * extent\` and \`(extent * 2) - 1\` inclusive. All layers that use a vector source must specify a [`source-layer`](layers.md#source-layer) value. Note that features are only rendered within their originating tile, which may lead to visual artifacts when large values for width, radius, size or offset are specified. To mitigate rendering issues, either reduce the value of the property causing the artifact or, if you have control over the tile generation process, increase the buffer size to ensure that features are fully rendered within the tile.',
361369
example: {
362370
'maplibre-streets': {
363-
'type': 'vector',
364-
'tiles': [
365-
'http://a.example.com/tiles/{z}/{x}/{y}.pbf'
366-
],
367-
}
371+
type: 'vector',
372+
tiles: ['http://a.example.com/tiles/{z}/{x}/{y}.pbf'],
373+
},
368374
},
369375
'sdk-support': {
370376
'basic functionality': {
371377
js: '0.10.0',
372378
android: '2.0.1',
373-
ios: '2.0.0'
374-
}
375-
}
379+
ios: '2.0.0',
380+
},
381+
},
376382
},
377383
raster: {
378384
doc: 'A raster tile source.',
379385
example: {
380386
'maplibre-satellite': {
381-
'type': 'raster',
382-
'tiles': [
383-
'http://a.example.com/tiles/{z}/{x}/{y}.png'
384-
],
385-
'tileSize': 256
386-
}
387+
type: 'raster',
388+
tiles: ['http://a.example.com/tiles/{z}/{x}/{y}.png'],
389+
tileSize: 256,
390+
},
387391
},
388392
'sdk-support': {
389393
'basic functionality': {
390394
js: '0.10.0',
391395
android: '2.0.1',
392-
ios: '2.0.0'
393-
}
394-
}
396+
ios: '2.0.0',
397+
},
398+
},
395399
},
396400
'raster-dem': {
397401
doc: 'A raster DEM source. Only supports [Mapbox Terrain RGB](https://blog.mapbox.com/global-elevation-data-6689f1d0ba65) and Mapzen Terrarium tiles.',
398402
example: {
399403
'maplibre-terrain-rgb': {
400-
'type': 'raster-dem',
401-
'encoding': 'mapbox',
402-
'tiles': [
403-
'http://a.example.com/dem-tiles/{z}/{x}/{y}.png'
404-
],
405-
}
404+
type: 'raster-dem',
405+
encoding: 'mapbox',
406+
tiles: ['http://a.example.com/dem-tiles/{z}/{x}/{y}.png'],
407+
},
406408
},
407409
'sdk-support': {
408410
'basic functionality': {
409411
js: '0.43.0',
410412
android: '6.0.0',
411-
ios: '4.0.0'
412-
}
413-
}
413+
ios: '4.0.0',
414+
},
415+
},
414416
},
415417
geojson: {
416418
doc: 'A [GeoJSON](http://geojson.org/) source. Data must be provided via a \`"data"\` property, whose value can be a URL or inline GeoJSON. When using in a browser, the GeoJSON data must be on the same domain as the map or served with [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) headers.',
417419
example: {
418420
'geojson-marker': {
419-
'type': 'geojson',
420-
'data': {
421-
'type': 'Feature',
422-
'geometry': {
423-
'type': 'Point',
424-
'coordinates': [12.550343, 55.665957]
421+
type: 'geojson',
422+
data: {
423+
type: 'Feature',
424+
geometry: {
425+
type: 'Point',
426+
coordinates: [12.550343, 55.665957],
425427
},
426-
'properties': {
427-
'title': 'Somewhere',
428-
'marker-symbol': 'monument'
429-
}
430-
}
428+
properties: {
429+
title: 'Somewhere',
430+
'marker-symbol': 'monument',
431+
},
432+
},
431433
},
432434
'geojson-lines': {
433-
'type': 'geojson',
434-
'data': './lines.geojson'
435-
}
435+
type: 'geojson',
436+
data: './lines.geojson',
437+
},
436438
},
437439
'sdk-support': {
438440
'basic functionality': {
439441
js: '0.10.0',
440442
android: '2.0.1',
441-
ios: '2.0.0'
443+
ios: '2.0.0',
442444
},
443445
clustering: {
444446
js: '0.14.0',
445447
android: '4.2.0',
446-
ios: '3.4.0'
448+
ios: '3.4.0',
447449
},
448450
'line distance metrics': {
449451
js: '0.45.0',
450452
android: '6.5.0',
451-
ios: '4.4.0'
452-
}
453-
}
453+
ios: '4.4.0',
454+
},
455+
},
454456
},
455457
image: {
456458
doc: 'An image source. The `url` value contains the image location. The `coordinates` array contains `[longitude, latitude]` pairs for the image corners listed in clockwise order: top left, top right, bottom right, bottom left.',
457459
example: {
458-
'image': {
459-
'type': 'image',
460-
'url': 'https://maplibre.org/maplibre-gl-js/docs/assets/radar.gif',
461-
'coordinates': [
460+
image: {
461+
type: 'image',
462+
url: 'https://maplibre.org/maplibre-gl-js/docs/assets/radar.gif',
463+
coordinates: [
462464
[-80.425, 46.437],
463465
[-71.516, 46.437],
464466
[-71.516, 37.936],
465-
[-80.425, 37.936]
466-
]
467-
}
467+
[-80.425, 37.936],
468+
],
469+
},
468470
},
469471
'sdk-support': {
470472
'basic functionality': {
471473
js: '0.10.0',
472474
android: '5.2.0',
473-
ios: '3.7.0'
474-
}
475-
}
475+
ios: '3.7.0',
476+
},
477+
},
476478
},
477479
video: {
478-
doc: 'A video source. The `urls` value is an array. For each URL in the array, a video element [source](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/source) will be created. To support the video across browsers, supply URLs in multiple formats.\n\nThe `coordinates` array contains `[longitude, latitude]` pairs for the video corners listed in clockwise order: top left, top right, bottom right, bottom left.\n\nWhen rendered as a [raster layer](layers.md#raster), the layer\'s [`raster-fade-duration`](layers.md#raster-fade-duration) property will cause the video to fade in. This happens when playback is started, paused and resumed, or when the video\'s coordinates are updated. To avoid this behavior, set the layer\'s [`raster-fade-duration`](layers.md#raster-fade-duration) property to `0`.',
480+
doc: "A video source. The `urls` value is an array. For each URL in the array, a video element [source](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/source) will be created. To support the video across browsers, supply URLs in multiple formats.\n\nThe `coordinates` array contains `[longitude, latitude]` pairs for the video corners listed in clockwise order: top left, top right, bottom right, bottom left.\n\nWhen rendered as a [raster layer](layers.md#raster), the layer's [`raster-fade-duration`](layers.md#raster-fade-duration) property will cause the video to fade in. This happens when playback is started, paused and resumed, or when the video's coordinates are updated. To avoid this behavior, set the layer's [`raster-fade-duration`](layers.md#raster-fade-duration) property to `0`.",
479481
example: {
480-
'video': {
481-
'type': 'video',
482-
'urls': [
482+
video: {
483+
type: 'video',
484+
urls: [
483485
'https://static-assets.mapbox.com/mapbox-gl-js/drone.mp4',
484-
'https://static-assets.mapbox.com/mapbox-gl-js/drone.webm'
486+
'https://static-assets.mapbox.com/mapbox-gl-js/drone.webm',
485487
],
486-
'coordinates': [
488+
coordinates: [
487489
[-122.51596391201019, 37.56238816766053],
488490
[-122.51467645168304, 37.56410183312965],
489491
[-122.51309394836426, 37.563391708549425],
490-
[-122.51423120498657, 37.56161849366671]
491-
]
492-
}
492+
[-122.51423120498657, 37.56161849366671],
493+
],
494+
},
493495
},
494496
'sdk-support': {
495497
'basic functionality': {
496-
js: '0.10.0'
497-
}
498-
}
499-
}
498+
js: '0.10.0',
499+
},
500+
},
501+
},
500502
};
501503

502504
let content = '# Sources\n\n';

0 commit comments

Comments
 (0)