Skip to content

Commit

Permalink
Use named exports consistently internally (#904)
Browse files Browse the repository at this point in the history
  • Loading branch information
birkskyum authored Nov 16, 2024
1 parent 8cb30d3 commit 14ecbdf
Show file tree
Hide file tree
Showing 128 changed files with 662 additions and 720 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## main

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

### 🐞 Bug fixes
Expand Down
2 changes: 1 addition & 1 deletion bin/gl-style-format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import fs from 'fs';
import minimist from 'minimist';
import format from '../src/format';
import {format} from '../src/format';
const argv = minimist(process.argv.slice(2));

if (argv.help || argv.h || (!argv._.length && process.stdin.isTTY)) {
Expand Down
4 changes: 2 additions & 2 deletions bin/gl-style-migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import fs from 'fs';
import minimist from 'minimist';
import format from '../src/format';
import migrate from '../src/migrate';
import {format} from '../src/format';
import {migrate} from '../src/migrate';
const argv = minimist(process.argv.slice(2));

if (argv.help || argv.h || (!argv._.length && process.stdin.isTTY)) {
Expand Down
2 changes: 1 addition & 1 deletion bin/gl-style-validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import minimist from 'minimist';
import rw from 'rw';
import validate from '../src/validate_style';
import {validateStyle as validate} from '../src/validate_style';

const argv = minimist(process.argv.slice(2), {
boolean: 'json',
Expand Down
6 changes: 3 additions & 3 deletions build/bump-version-changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
* And adds on top a ## main with add stuff here.
*/

import * as fs from 'fs';
import {readFileSync, writeFileSync} from 'fs';

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

fs.writeFileSync(changelogPath, changelog, 'utf8');
writeFileSync(changelogPath, changelog, 'utf8');
11 changes: 5 additions & 6 deletions build/generate-style-spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as fs from 'fs';
import * as properties from '../src/util/properties';

import {writeFileSync} from 'fs';
import spec from '../src/reference/v8.json' with {type: 'json'};
import {supportsPropertyExpression, supportsZoomExpression} from '../src/util/properties';

function unionType(values) {
if (Array.isArray(values)) {
Expand Down Expand Up @@ -45,9 +44,9 @@ function propertyType(property) {
}
})();

if (properties.supportsPropertyExpression(property)) {
if (supportsPropertyExpression(property)) {
return `DataDrivenPropertyValueSpecification<${baseType}>`;
} else if (properties.supportsZoomExpression(property)) {
} else if (supportsZoomExpression(property)) {
return `PropertyValueSpecification<${baseType}>`;
} else if (property.expression) {
return 'ExpressionSpecification';
Expand Down Expand Up @@ -116,7 +115,7 @@ function layerType(key) {

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

fs.writeFileSync('src/types.g.ts',
writeFileSync('src/types.g.ts',
`// Generated code; do not edit. Edit build/generate-style-spec.ts instead.
/* eslint-disable */
Expand Down
4 changes: 2 additions & 2 deletions build/release-notes.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/env node

import * as fs from 'fs';
import {readFileSync} from 'fs';
import semver from 'semver';

const changelogPath = 'CHANGELOG.md';
const changelog = fs.readFileSync(changelogPath, 'utf8');
const changelog = readFileSync(changelogPath, 'utf8');

/*
Parse the raw changelog text and split it into individual releases.
Expand Down
10 changes: 5 additions & 5 deletions src/declass.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import declass from './declass';
import {declassStyle} from './declass';

describe('declass', () => {
test('declass a style, one class', () => {
Expand All @@ -16,7 +16,7 @@ describe('declass', () => {
}]
};

const declassed = declass(style, ['one']);
const declassed = declassStyle(style, ['one']);

expect(declassed).not.toBe(style);
expect(declassed.layers).not.toBe(style.layers);
Expand Down Expand Up @@ -47,7 +47,7 @@ describe('declass', () => {
}]
};

expect(declass(style, ['one'])).toEqual({
expect(declassStyle(style, ['one'])).toEqual({
layers: [{
id: 'a',
paint: {
Expand Down Expand Up @@ -78,7 +78,7 @@ describe('declass', () => {
}]
};

expect(declass(style, ['one', 'two'])).toEqual({
expect(declassStyle(style, ['one', 'two'])).toEqual({
layers: [{
id: 'a',
paint: {
Expand All @@ -104,7 +104,7 @@ describe('declass', () => {
}]
};

expect(declass(style, ['one'])).toEqual({
expect(declassStyle(style, ['one'])).toEqual({
layers: [{
id: 'a',
paint: {
Expand Down
12 changes: 5 additions & 7 deletions src/declass.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@

import extend from './util/extend';

export default declassStyle;
import {extendBy} from './util/extend';

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

Expand All @@ -36,7 +34,7 @@ function declassStyle(style, classes) {
}

function declassLayer(layer, klass) {
return extend({}, layer, {
paint: extend({}, layer.paint, layer[`paint.${klass}`])
return extendBy({}, layer, {
paint: extendBy({}, layer.paint, layer[`paint.${klass}`])
});
}
6 changes: 3 additions & 3 deletions src/deref.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import deref from './deref';
import {derefLayers} from './deref';

describe('deref', () => {
test('derefs a ref layer which follows its parent', () => {
expect(deref([
expect(derefLayers([
{
'id': 'parent',
'type': 'line'
Expand All @@ -24,7 +24,7 @@ describe('deref', () => {
});

test('derefs a ref layer which precedes its parent', () => {
expect(deref([
expect(derefLayers([
{
'id': 'child',
'ref': 'parent'
Expand Down
6 changes: 2 additions & 4 deletions src/deref.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import refProperties from './util/ref_properties';
import {refProperties} from './util/ref_properties';

function deref(layer, parent) {
const result = {};
Expand All @@ -19,8 +19,6 @@ function deref(layer, parent) {
return result;
}

export default derefLayers;

/**
* Given an array of layers, some of which may contain `ref` properties
* whose value is the `id` of another property, return a new array where
Expand All @@ -34,7 +32,7 @@ export default derefLayers;
* @param {Array<Layer>} layers
* @returns {Array<Layer>}
*/
function derefLayers(layers) {
export function derefLayers(layers) {
layers = layers.slice();

const map = Object.create(null);
Expand Down
Loading

0 comments on commit 14ecbdf

Please sign in to comment.