Skip to content

Commit 14ecbdf

Browse files
authored
Use named exports consistently internally (#904)
1 parent 8cb30d3 commit 14ecbdf

File tree

128 files changed

+662
-720
lines changed

Some content is hidden

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

128 files changed

+662
-720
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## main
22

33
### ✨ Features and improvements
4+
- Use named imports internally - no package entrypoints changed ([#904](https://github.com/maplibre/maplibre-style-spec/pull/904))
45
- _...Add new stuff here..._
56

67
### 🐞 Bug fixes

bin/gl-style-format.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import fs from 'fs';
44
import minimist from 'minimist';
5-
import format from '../src/format';
5+
import {format} from '../src/format';
66
const argv = minimist(process.argv.slice(2));
77

88
if (argv.help || argv.h || (!argv._.length && process.stdin.isTTY)) {

bin/gl-style-migrate.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import fs from 'fs';
44
import minimist from 'minimist';
5-
import format from '../src/format';
6-
import migrate from '../src/migrate';
5+
import {format} from '../src/format';
6+
import {migrate} from '../src/migrate';
77
const argv = minimist(process.argv.slice(2));
88

99
if (argv.help || argv.h || (!argv._.length && process.stdin.isTTY)) {

bin/gl-style-validate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import minimist from 'minimist';
44
import rw from 'rw';
5-
import validate from '../src/validate_style';
5+
import {validateStyle as validate} from '../src/validate_style';
66

77
const argv = minimist(process.argv.slice(2), {
88
boolean: 'json',

build/bump-version-changelog.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
* And adds on top a ## main with add stuff here.
88
*/
99

10-
import * as fs from 'fs';
10+
import {readFileSync, writeFileSync} from 'fs';
1111

1212
const changelogPath = 'CHANGELOG.md';
13-
let changelog = fs.readFileSync(changelogPath, 'utf8');
13+
let changelog = readFileSync(changelogPath, 'utf8');
1414
changelog = changelog.replace('## main', `## ${process.argv[2]}`);
1515
changelog = changelog.replaceAll('- _...Add new stuff here..._\n', '');
1616
changelog = `## main
@@ -23,4 +23,4 @@ changelog = `## main
2323
2424
` + changelog;
2525

26-
fs.writeFileSync(changelogPath, changelog, 'utf8');
26+
writeFileSync(changelogPath, changelog, 'utf8');

build/generate-style-spec.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import * as fs from 'fs';
2-
import * as properties from '../src/util/properties';
3-
1+
import {writeFileSync} from 'fs';
42
import spec from '../src/reference/v8.json' with {type: 'json'};
3+
import {supportsPropertyExpression, supportsZoomExpression} from '../src/util/properties';
54

65
function unionType(values) {
76
if (Array.isArray(values)) {
@@ -45,9 +44,9 @@ function propertyType(property) {
4544
}
4645
})();
4746

48-
if (properties.supportsPropertyExpression(property)) {
47+
if (supportsPropertyExpression(property)) {
4948
return `DataDrivenPropertyValueSpecification<${baseType}>`;
50-
} else if (properties.supportsZoomExpression(property)) {
49+
} else if (supportsZoomExpression(property)) {
5150
return `PropertyValueSpecification<${baseType}>`;
5251
} else if (property.expression) {
5352
return 'ExpressionSpecification';
@@ -116,7 +115,7 @@ function layerType(key) {
116115

117116
const layerTypes = Object.keys(spec.layer.type.values);
118117

119-
fs.writeFileSync('src/types.g.ts',
118+
writeFileSync('src/types.g.ts',
120119
`// Generated code; do not edit. Edit build/generate-style-spec.ts instead.
121120
/* eslint-disable */
122121

build/release-notes.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/usr/bin/env node
22

3-
import * as fs from 'fs';
3+
import {readFileSync} from 'fs';
44
import semver from 'semver';
55

66
const changelogPath = 'CHANGELOG.md';
7-
const changelog = fs.readFileSync(changelogPath, 'utf8');
7+
const changelog = readFileSync(changelogPath, 'utf8');
88

99
/*
1010
Parse the raw changelog text and split it into individual releases.

src/declass.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import declass from './declass';
1+
import {declassStyle} from './declass';
22

33
describe('declass', () => {
44
test('declass a style, one class', () => {
@@ -16,7 +16,7 @@ describe('declass', () => {
1616
}]
1717
};
1818

19-
const declassed = declass(style, ['one']);
19+
const declassed = declassStyle(style, ['one']);
2020

2121
expect(declassed).not.toBe(style);
2222
expect(declassed.layers).not.toBe(style.layers);
@@ -47,7 +47,7 @@ describe('declass', () => {
4747
}]
4848
};
4949

50-
expect(declass(style, ['one'])).toEqual({
50+
expect(declassStyle(style, ['one'])).toEqual({
5151
layers: [{
5252
id: 'a',
5353
paint: {
@@ -78,7 +78,7 @@ describe('declass', () => {
7878
}]
7979
};
8080

81-
expect(declass(style, ['one', 'two'])).toEqual({
81+
expect(declassStyle(style, ['one', 'two'])).toEqual({
8282
layers: [{
8383
id: 'a',
8484
paint: {
@@ -104,7 +104,7 @@ describe('declass', () => {
104104
}]
105105
};
106106

107-
expect(declass(style, ['one'])).toEqual({
107+
expect(declassStyle(style, ['one'])).toEqual({
108108
layers: [{
109109
id: 'a',
110110
paint: {

src/declass.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11

2-
import extend from './util/extend';
3-
4-
export default declassStyle;
2+
import {extendBy} from './util/extend';
53

64
/**
75
* Returns a new style with the given 'paint classes' merged into each layer's
@@ -18,8 +16,8 @@ export default declassStyle;
1816
* // nightStyle now has each layer's `paint.night` properties merged in to the
1917
* // main `paint` property.
2018
*/
21-
function declassStyle(style, classes) {
22-
return extend({}, style, {
19+
export function declassStyle(style, classes) {
20+
return extendBy({}, style, {
2321
layers: style.layers.map((layer) => {
2422
const result = classes.reduce(declassLayer, layer);
2523

@@ -36,7 +34,7 @@ function declassStyle(style, classes) {
3634
}
3735

3836
function declassLayer(layer, klass) {
39-
return extend({}, layer, {
40-
paint: extend({}, layer.paint, layer[`paint.${klass}`])
37+
return extendBy({}, layer, {
38+
paint: extendBy({}, layer.paint, layer[`paint.${klass}`])
4139
});
4240
}

src/deref.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import deref from './deref';
1+
import {derefLayers} from './deref';
22

33
describe('deref', () => {
44
test('derefs a ref layer which follows its parent', () => {
5-
expect(deref([
5+
expect(derefLayers([
66
{
77
'id': 'parent',
88
'type': 'line'
@@ -24,7 +24,7 @@ describe('deref', () => {
2424
});
2525

2626
test('derefs a ref layer which precedes its parent', () => {
27-
expect(deref([
27+
expect(derefLayers([
2828
{
2929
'id': 'child',
3030
'ref': 'parent'

0 commit comments

Comments
 (0)