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

Promote StylePropertySpecification #5593

Merged
merged 1 commit into from
Nov 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions bench/benchmarks/expressions.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ const convertFunction = require('../../src/style-spec/function/convert');
const {isFunction, createFunction} = require('../../src/style-spec/function');
const {createExpression} = require('../../src/style-spec/expression');

import type {
StyleExpression,
StylePropertySpecification
} from '../../src/style-spec/expression';
import type {StylePropertySpecification} from '../../src/style-spec/style-spec';
import type {StyleExpression} from '../../src/style-spec/expression';

class ExpressionBenchmark extends Benchmark {
data: Array<{
Expand Down
36 changes: 1 addition & 35 deletions src/style-spec/expression/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const isConstant = require('./is_constant');
import type {Type} from './types';
import type {Value} from './values';
import type {Expression} from './expression';
import type {StylePropertySpecification} from '../style-spec';

export type Feature = {
+type: 1 | 2 | 3 | 'Unknown' | 'Point' | 'MultiPoint' | 'LineString' | 'MultiLineString' | 'Polygon' | 'MultiPolygon',
Expand Down Expand Up @@ -65,41 +66,6 @@ export type StyleFilterExpression = ZoomConstantExpression | {

export type StyleExpression = StyleDeclarationExpression | StyleFilterExpression;

export type StylePropertySpecification = {
type: 'number',
'function': boolean,
'property-function': boolean,
default?: number
} | {
type: 'string',
'function': boolean,
'property-function': boolean,
default?: string
} | {
type: 'boolean',
'function': boolean,
'property-function': boolean,
default?: boolean
} | {
type: 'enum',
'function': boolean,
'property-function': boolean,
values: {[string]: {}},
default?: string
} | {
type: 'array',
'function': boolean,
'property-function': boolean,
value: 'number' | 'string' | 'boolean',
length?: number,
default?: Array<Value>
} | {
type: 'color',
'function': boolean,
'property-function': boolean,
default?: string
};

function isExpression(expression: mixed) {
return Array.isArray(expression) && expression.length > 0 &&
typeof expression[0] === 'string' && expression[0] in definitions;
Expand Down
2 changes: 1 addition & 1 deletion src/style-spec/expression/values.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function validateRGBA(r: mixed, g: mixed, b: mixed, a?: mixed): ?string {
return null;
}

export type Value = null | string | boolean | number | Color | Array<Value> | { [string]: Value }
export type Value = null | string | boolean | number | Color | $ReadOnlyArray<Value> | { +[string]: Value }

function isValue(mixed: mixed): boolean {
if (mixed === null) {
Expand Down
43 changes: 43 additions & 0 deletions src/style-spec/style-spec.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,46 @@
// @flow

export type StylePropertySpecification = {
type: 'number',
'function': boolean,
'property-function': boolean,
default?: number
} | {
type: 'string',
'function': boolean,
'property-function': boolean,
default?: string
} | {
type: 'boolean',
'function': boolean,
'property-function': boolean,
default?: boolean
} | {
type: 'enum',
'function': boolean,
'property-function': boolean,
values: {[string]: {}},
default?: string
} | {
type: 'color',
'function': boolean,
'property-function': boolean,
default?: string
} | {
type: 'array',
value: 'number',
'function': boolean,
'property-function': boolean,
length?: number,
default?: Array<number>
} | {
type: 'array',
value: 'string',
'function': boolean,
'property-function': boolean,
length?: number,
default?: Array<string>
};

exports.v6 = require('./reference/v6.json');
exports.v7 = require('./reference/v7.json');
Expand Down