Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Named exports #904

Merged
merged 19 commits into from
Nov 16, 2024
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';
birkskyum marked this conversation as resolved.
Show resolved Hide resolved

const argv = minimist(process.argv.slice(2), {
boolean: 'json',
Expand Down
2 changes: 1 addition & 1 deletion src/declass.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import declass from './declass';
import {declassStyle as declass} from './declass';

describe('declass', () => {
test('declass a style, one class', () => {
Expand Down
6 changes: 2 additions & 4 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 as extend} from './util/extend';

/**
* Returns a new style with the given 'paint classes' merged into each layer's
Expand All @@ -18,7 +16,7 @@ export default declassStyle;
* // nightStyle now has each layer's `paint.night` properties merged in to the
* // main `paint` property.
*/
function declassStyle(style, classes) {
export function declassStyle(style, classes) {
return extend({}, style, {
layers: style.layers.map((layer) => {
const result = classes.reduce(declassLayer, layer);
Expand Down
2 changes: 1 addition & 1 deletion src/deref.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import deref from './deref';
import {derefLayers as deref} from './deref';

describe('deref', () => {
test('derefs a ref layer which follows its 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
2 changes: 1 addition & 1 deletion src/diff.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import diffStyles from './diff';
import {diffStyles} from './diff';
import {StyleSpecification} from './types.g';

describe('diff', () => {
Expand Down
6 changes: 2 additions & 4 deletions src/diff.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

import {GeoJSONSourceSpecification, LayerSpecification, LightSpecification, ProjectionSpecification, SkySpecification, SourceSpecification, SpriteSpecification, StyleSpecification, TerrainSpecification, TransitionSpecification} from './types.g';
import isEqual from './util/deep_equal';
import {deepEqual as isEqual} from './util/deep_equal';

/**
* Operations that can be performed by the diff.
Expand Down Expand Up @@ -267,7 +267,7 @@ function diffLayers(before: LayerSpecification[], after: LayerSpecification[], c
* @param {*} after stylesheet to compare to
* @returns Array list of changes
*/
function diffStyles(before: StyleSpecification, after: StyleSpecification): DiffCommand<DiffOperations>[] {
export function diffStyles(before: StyleSpecification, after: StyleSpecification): DiffCommand<DiffOperations>[] {
if (!before) return [{command: 'setStyle', args: [after]}];

let commands: DiffCommand<DiffOperations>[] = [];
Expand Down Expand Up @@ -354,5 +354,3 @@ function diffStyles(before: StyleSpecification, after: StyleSpecification): Diff

return commands;
}

export default diffStyles;
4 changes: 2 additions & 2 deletions src/empty.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import emptyStyle from './empty';
import validateStyleMin from './validate_style.min';
import {emptyStyle} from './empty';
import {validateStyleMin} from './validate_style.min';

describe('empty', () => {
test('it generates something', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/empty.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import latest from './reference/latest';
import {spec as latest} from './reference/latest';
import {StyleSpecification} from './types.g';

export default function emptyStyle(): StyleSpecification {
export function emptyStyle(): StyleSpecification {
const style = {};

const version = latest['$version'];
Expand Down
2 changes: 1 addition & 1 deletion src/error/parsing_error.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Note: Do not inherit from Error. It breaks when transpiling to ES5.

export default class ParsingError {
export class ParsingError {
message: string;
error: Error;
line: number;
Expand Down
2 changes: 1 addition & 1 deletion src/error/validation_error.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Note: Do not inherit from Error. It breaks when transpiling to ES5.

export default class ValidationError {
export class ValidationError {
message: string;
identifier: string;
line: number;
Expand Down
25 changes: 12 additions & 13 deletions src/expression/compound_expression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@ import {toString,
toString as typeToString,
} from './types';

import ParsingContext from './parsing_context';
import EvaluationContext from './evaluation_context';
import {ParsingContext} from './parsing_context';
import {EvaluationContext} from './evaluation_context';

import {expressions} from './definitions/index';
import CollatorExpression from './definitions/collator';
import Within from './definitions/within';
import Literal from './definitions/literal';
import Assertion from './definitions/assertion';
import Coercion from './definitions/coercion';
import Var from './definitions/var';
import Distance from './definitions/distance';
import {CollatorExpression} from './definitions/collator';
import {Within} from './definitions/within';
import {Literal} from './definitions/literal';
import {Assertion} from './definitions/assertion';
import {Coercion} from './definitions/coercion';
import {Var} from './definitions/var';
import {Distance} from './definitions/distance';

import type {Expression, ExpressionRegistry} from './expression';
import type {Value} from './values';
import type {Type} from './types';

import {typeOf, validateRGBA, toString as valueToString} from './values';
import RuntimeError from './runtime_error';
import Color from './types/color';
import {RuntimeError} from './runtime_error';
import {Color} from './types/color';

export type Varargs = {
type: Type;
Expand All @@ -42,7 +42,7 @@ type Definition = [Type, Signature, Evaluate] | {
overloads: Array<[Signature, Evaluate]>;
};

class CompoundExpression implements Expression {
export class CompoundExpression implements Expression {
name: string;
type: Type;
_evaluate: Evaluate;
Expand Down Expand Up @@ -752,4 +752,3 @@ function isGlobalPropertyConstant(e: Expression, properties: Array<string>) {
}

export {isFeatureConstant, isGlobalPropertyConstant, isStateConstant, isExpressionConstant};
export default CompoundExpression;
10 changes: 4 additions & 6 deletions src/expression/definitions/assertion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import {
toString,
array
} from '../types';
import RuntimeError from '../runtime_error';
import {RuntimeError} from '../runtime_error';
import {typeOf} from '../values';

import type {Expression} from '../expression';
import type ParsingContext from '../parsing_context';
import type EvaluationContext from '../evaluation_context';
import type {ParsingContext} from '../parsing_context';
import type {EvaluationContext} from '../evaluation_context';
import type {Type} from '../types';

const types = {
Expand All @@ -24,7 +24,7 @@ const types = {
object: ObjectType
};

class Assertion implements Expression {
export class Assertion implements Expression {
type: Type;
args: Array<Expression>;

Expand Down Expand Up @@ -104,5 +104,3 @@ class Assertion implements Expression {
return this.args.every(arg => arg.outputDefined());
}
}

export default Assertion;
9 changes: 4 additions & 5 deletions src/expression/definitions/at.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {array, ValueType, NumberType} from '../types';

import RuntimeError from '../runtime_error';
import {RuntimeError} from '../runtime_error';

import type {Expression} from '../expression';
import type ParsingContext from '../parsing_context';
import type EvaluationContext from '../evaluation_context';
import type {ParsingContext} from '../parsing_context';
import type {EvaluationContext} from '../evaluation_context';
import type {Type, ArrayType} from '../types';
import type {Value} from '../values';

class At implements Expression {
export class At implements Expression {
type: Type;
index: Expression;
input: Expression;
Expand Down Expand Up @@ -61,4 +61,3 @@ class At implements Expression {
}
}

export default At;
7 changes: 3 additions & 4 deletions src/expression/definitions/case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
import {BooleanType} from '../types';

import type {Expression} from '../expression';
import type ParsingContext from '../parsing_context';
import type EvaluationContext from '../evaluation_context';
import type {ParsingContext} from '../parsing_context';
import type {EvaluationContext} from '../evaluation_context';
import type {Type} from '../types';

type Branches = Array<[Expression, Expression]>;

class Case implements Expression {
export class Case implements Expression {
type: Type;

branches: Branches;
Expand Down Expand Up @@ -73,4 +73,3 @@ class Case implements Expression {
}
}

export default Case;
9 changes: 4 additions & 5 deletions src/expression/definitions/coalesce.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {checkSubtype, ValueType} from '../types';
import ResolvedImage from '../types/resolved_image';
import {ResolvedImage} from '../types/resolved_image';

import type {Expression} from '../expression';
import type ParsingContext from '../parsing_context';
import type EvaluationContext from '../evaluation_context';
import type {ParsingContext} from '../parsing_context';
import type {EvaluationContext} from '../evaluation_context';
import type {Type} from '../types';

class Coalesce implements Expression {
export class Coalesce implements Expression {
type: Type;
args: Array<Expression>;

Expand Down Expand Up @@ -80,4 +80,3 @@ class Coalesce implements Expression {
}
}

export default Coalesce;
19 changes: 9 additions & 10 deletions src/expression/definitions/coercion.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import {BooleanType, ColorType, NumberType, StringType, ValueType} from '../types';
import {toString as valueToString, validateRGBA} from '../values';
import RuntimeError from '../runtime_error';
import Formatted from '../types/formatted';
import ResolvedImage from '../types/resolved_image';
import Color from '../types/color';
import Padding from '../types/padding';
import VariableAnchorOffsetCollection from '../types/variable_anchor_offset_collection';
import {RuntimeError} from '../runtime_error';
import {Formatted} from '../types/formatted';
import {ResolvedImage} from '../types/resolved_image';
import {Color} from '../types/color';
import {Padding} from '../types/padding';
import {VariableAnchorOffsetCollection} from '../types/variable_anchor_offset_collection';

import type {Expression} from '../expression';
import type ParsingContext from '../parsing_context';
import type EvaluationContext from '../evaluation_context';
import type {ParsingContext} from '../parsing_context';
import type {EvaluationContext} from '../evaluation_context';
import type {Type} from '../types';

const types = {
Expand All @@ -26,7 +26,7 @@ const types = {
*
* @private
*/
class Coercion implements Expression {
export class Coercion implements Expression {
type: Type;
args: Array<Expression>;

Expand Down Expand Up @@ -140,4 +140,3 @@ class Coercion implements Expression {
}
}

export default Coercion;
8 changes: 4 additions & 4 deletions src/expression/definitions/collator.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {StringType, BooleanType, CollatorType} from '../types';
import Collator from '../types/collator';
import {Collator} from '../types/collator';

import type {Expression} from '../expression';
import type EvaluationContext from '../evaluation_context';
import type ParsingContext from '../parsing_context';
import type {EvaluationContext} from '../evaluation_context';
import type {ParsingContext} from '../parsing_context';
import type {Type} from '../types';

export default class CollatorExpression implements Expression {
export class CollatorExpression implements Expression {
type: Type;
caseSensitive: Expression;
diacriticSensitive: Expression;
Expand Down
8 changes: 4 additions & 4 deletions src/expression/definitions/comparison.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {toString, ValueType, BooleanType, CollatorType} from '../types';
import Assertion from './assertion';
import {Assertion} from './assertion';
import {typeOf} from '../values';
import RuntimeError from '../runtime_error';
import {RuntimeError} from '../runtime_error';

import type {Expression} from '../expression';
import type EvaluationContext from '../evaluation_context';
import type ParsingContext from '../parsing_context';
import type {EvaluationContext} from '../evaluation_context';
import type {ParsingContext} from '../parsing_context';
import type {Type} from '../types';

type ComparisonOperator = '==' | '!=' | '<' | '>' | '<=' | '>=';
Expand Down
10 changes: 4 additions & 6 deletions src/expression/definitions/distance.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import TinyQueue from 'tinyqueue';
import {Expression} from '../expression';
import ParsingContext from '../parsing_context';
import {ParsingContext} from '../parsing_context';
import {NumberType, Type} from '../types';
import {isValue} from '../values';
import EvaluationContext from '../evaluation_context';
import {EvaluationContext} from '../evaluation_context';
import {BBox, boxWithinBox, getLngLatFromTileCoord, pointWithinPolygon, segmentIntersectSegment, updateBBox} from '../../util/geometry_util';
import {classifyRings} from '../../util/classify_rings';
import CheapRuler from '../../util/cheap_ruler';
import {CheapRuler} from '../../util/cheap_ruler';

type SimpleGeometry = GeoJSON.Polygon | GeoJSON.LineString | GeoJSON.Point;

Expand Down Expand Up @@ -532,7 +532,7 @@ function toSimpleGeometry(geometry: Exclude<GeoJSON.Geometry, GeoJSON.GeometryCo
return [geometry];
}

class Distance implements Expression {
export class Distance implements Expression {
type: Type;
geojson: GeoJSON.GeoJSON;
geometries: SimpleGeometry[];
Expand Down Expand Up @@ -578,5 +578,3 @@ class Distance implements Expression {
return true;
}
}

export default Distance;
Loading