@mapbox/mapbox-gl-style-spec
Advanced tools
Comparing version 9.0.0 to 9.0.1
@@ -0,1 +1,5 @@ | ||
## 9.0.1 | ||
* Remove `fast-stable-stringify` dependency (#5152) | ||
## 9.0.0 | ||
@@ -2,0 +6,0 @@ |
@@ -1,2 +0,1 @@ | ||
'use strict'; | ||
@@ -6,2 +5,3 @@ module.exports = function (style) { | ||
const sourceIDs = []; | ||
const compositedSourceLayers = []; | ||
@@ -39,2 +39,10 @@ for (const id in style.sources) { | ||
layer.source = compositeID; | ||
if ('source-layer' in layer) { | ||
if (compositedSourceLayers.indexOf(layer['source-layer']) >= 0) { | ||
throw new Error('Conflicting source layer names'); | ||
} else { | ||
compositedSourceLayers.push(layer['source-layer']); | ||
} | ||
} | ||
} | ||
@@ -41,0 +49,0 @@ }); |
@@ -1,2 +0,1 @@ | ||
'use strict'; | ||
@@ -3,0 +2,0 @@ const extend = require('./util/extend'); |
@@ -1,2 +0,1 @@ | ||
'use strict'; | ||
@@ -3,0 +2,0 @@ const refProperties = require('./util/ref_properties'); |
@@ -1,2 +0,1 @@ | ||
'use strict'; | ||
@@ -3,0 +2,0 @@ const isEqual = require('lodash.isequal'); |
@@ -1,2 +0,1 @@ | ||
'use strict'; | ||
@@ -3,0 +2,0 @@ function ParsingError(error) { |
@@ -1,10 +0,6 @@ | ||
'use strict'; | ||
const format = require('util').format; | ||
function ValidationError(key, value /*, message, ...*/) { | ||
this.message = ( | ||
(key ? `${key}: ` : '') + | ||
format.apply(format, Array.prototype.slice.call(arguments, 2)) | ||
); | ||
function ValidationError(key, value, ...args) { | ||
this.message = (key ? `${key}: ` : '') + format.apply(format, args); | ||
@@ -11,0 +7,0 @@ if (value !== null && value !== undefined && value.__line__) { |
@@ -1,3 +0,1 @@ | ||
'use strict'; | ||
module.exports = createFilter; | ||
@@ -43,5 +41,6 @@ | ||
function compilePropertyReference(property) { | ||
return property === '$type' ? 'f.type' : | ||
property === '$id' ? 'f.id' : | ||
`p[${JSON.stringify(property)}]`; | ||
const ref = | ||
property === '$type' ? 'f.type' : | ||
property === '$id' ? 'f.id' : `p[${JSON.stringify(property)}]`; | ||
return ref; | ||
} | ||
@@ -48,0 +47,0 @@ |
@@ -1,2 +0,1 @@ | ||
'use strict'; | ||
@@ -3,0 +2,0 @@ const reference = require('./reference/latest.js'); |
@@ -1,2 +0,1 @@ | ||
'use strict'; | ||
@@ -3,0 +2,0 @@ // Constants |
@@ -1,2 +0,1 @@ | ||
'use strict'; | ||
@@ -7,2 +6,3 @@ const colorSpaces = require('./color_spaces'); | ||
const getType = require('../util/get_type'); | ||
const interpolate = require('../util/interpolate'); | ||
@@ -111,2 +111,3 @@ function identityFunction(x) { | ||
property: parameters.property, | ||
default: parameters.default, | ||
stops: [] | ||
@@ -189,11 +190,24 @@ }; | ||
const index = findStopLessThanOrEqualTo(parameters.stops, input); | ||
const t = interpolationFactor( | ||
input, base, | ||
parameters.stops[index][0], | ||
parameters.stops[index + 1][0]); | ||
return interpolate( | ||
input, | ||
base, | ||
parameters.stops[index][0], | ||
parameters.stops[index + 1][0], | ||
parameters.stops[index][1], | ||
parameters.stops[index + 1][1] | ||
); | ||
const outputLower = parameters.stops[index][1]; | ||
const outputUpper = parameters.stops[index + 1][1]; | ||
const interp = interpolate[propertySpec.type] || identityFunction; | ||
if (typeof outputLower === 'function') { | ||
return function(...args) { | ||
const evaluatedLower = outputLower.apply(undefined, args); | ||
const evaluatedUpper = outputUpper.apply(undefined, args); | ||
// Special case for fill-outline-color, which has no spec default. | ||
if (evaluatedLower === undefined || evaluatedUpper === undefined) { | ||
return undefined; | ||
} | ||
return interp(evaluatedLower, evaluatedUpper, t); | ||
}; | ||
} | ||
return interp(outputLower, outputUpper, t); | ||
} | ||
@@ -204,3 +218,3 @@ | ||
input = parseColor(input); | ||
} else if (getType(input) !== propertySpec.type) { | ||
} else if (getType(input) !== propertySpec.type && (propertySpec.type !== 'enum' || !propertySpec.values[input])) { | ||
input = undefined; | ||
@@ -239,33 +253,2 @@ } | ||
function interpolate(input, base, inputLower, inputUpper, outputLower, outputUpper) { | ||
if (typeof outputLower === 'function') { | ||
return function() { | ||
const evaluatedLower = outputLower.apply(undefined, arguments); | ||
const evaluatedUpper = outputUpper.apply(undefined, arguments); | ||
// Special case for fill-outline-color, which has no spec default. | ||
if (evaluatedLower === undefined || evaluatedUpper === undefined) { | ||
return undefined; | ||
} | ||
return interpolate(input, base, inputLower, inputUpper, evaluatedLower, evaluatedUpper); | ||
}; | ||
} else if (outputLower.length) { | ||
return interpolateArray(input, base, inputLower, inputUpper, outputLower, outputUpper); | ||
} else { | ||
return interpolateNumber(input, base, inputLower, inputUpper, outputLower, outputUpper); | ||
} | ||
} | ||
function interpolateNumber(input, base, inputLower, inputUpper, outputLower, outputUpper) { | ||
const ratio = interpolationFactor(input, base, inputLower, inputUpper); | ||
return outputLower + ratio * (outputUpper - outputLower); | ||
} | ||
function interpolateArray(input, base, inputLower, inputUpper, outputLower, outputUpper) { | ||
const output = []; | ||
for (let i = 0; i < outputLower.length; i++) { | ||
output[i] = interpolateNumber(input, base, inputLower, inputUpper, outputLower[i], outputUpper[i]); | ||
} | ||
return output; | ||
} | ||
function isFunctionDefinition(value) { | ||
@@ -317,3 +300,5 @@ return typeof value === 'object' && (value.stops || value.type === 'identity'); | ||
if (base === 1) { | ||
if (difference === 0) { | ||
return 0; | ||
} else if (base === 1) { | ||
return progress / difference; | ||
@@ -320,0 +305,0 @@ } else { |
@@ -1,12 +0,34 @@ | ||
'use strict'; | ||
const refProperties = require('./util/ref_properties'), | ||
stringify = require('fast-stable-stringify'); | ||
const refProperties = require('./util/ref_properties'); | ||
function key(layer) { | ||
return stringify(refProperties.map((k) => { | ||
return layer[k]; | ||
})); | ||
function stringify(obj) { | ||
const type = typeof obj; | ||
if (type === 'number' || type === 'string' || obj === undefined || obj === null) | ||
return JSON.stringify(obj); | ||
if (Array.isArray(obj)) { | ||
let str = '['; | ||
for (const val of obj) { | ||
str += `${stringify(val)},`; | ||
} | ||
return `${str}]`; | ||
} | ||
const keys = Object.keys(obj).sort(); | ||
let str = '{'; | ||
for (let i = 0; i < keys.length; i++) { | ||
str += `${JSON.stringify(keys[i])}:${stringify(obj[keys[i]])},`; | ||
} | ||
return `${str}}`; | ||
} | ||
function getKey(layer) { | ||
let key = ''; | ||
for (const k of refProperties) { | ||
key += `/${stringify(layer[k])}`; | ||
} | ||
return key; | ||
} | ||
module.exports = groupByLayout; | ||
@@ -32,3 +54,3 @@ | ||
for (let i = 0; i < layers.length; i++) { | ||
const k = key(layers[i]); | ||
const k = getKey(layers[i]); | ||
let group = groups[k]; | ||
@@ -35,0 +57,0 @@ if (!group) { |
@@ -1,2 +0,1 @@ | ||
'use strict'; | ||
@@ -3,0 +2,0 @@ exports.v6 = require('./reference/v6.json'); |
@@ -1,2 +0,1 @@ | ||
'use strict'; | ||
@@ -3,0 +2,0 @@ /** |
@@ -1,2 +0,1 @@ | ||
'use strict'; | ||
@@ -3,0 +2,0 @@ const ref = require('../reference/v7.json'); |
@@ -1,2 +0,1 @@ | ||
'use strict'; | ||
@@ -3,0 +2,0 @@ const Reference = require('../reference/v8.json'); |
@@ -1,2 +0,1 @@ | ||
'use strict'; | ||
@@ -3,0 +2,0 @@ const deref = require('../deref'); |
{ | ||
"name": "@mapbox/mapbox-gl-style-spec", | ||
"description": "a specification for mapbox gl styles", | ||
"version": "9.0.0", | ||
"version": "9.0.1", | ||
"author": "Mapbox", | ||
@@ -25,3 +25,2 @@ "keywords": [ | ||
"csscolorparser": "~1.0.2", | ||
"fast-stable-stringify": "^0.1.1", | ||
"jsonlint-lines-primitives": "~1.6.0", | ||
@@ -28,0 +27,0 @@ "lodash.isequal": "^3.0.4", |
@@ -1,3 +0,2 @@ | ||
'use strict'; | ||
module.exports = require('./v8.json'); |
@@ -1,6 +0,4 @@ | ||
'use strict'; | ||
module.exports = function (output) { | ||
for (let i = 1; i < arguments.length; i++) { | ||
const input = arguments[i]; | ||
module.exports = function (output, ...inputs) { | ||
for (const input of inputs) { | ||
for (const k in input) { | ||
@@ -7,0 +5,0 @@ output[k] = input[k]; |
@@ -1,2 +0,1 @@ | ||
'use strict'; | ||
@@ -3,0 +2,0 @@ module.exports = function getType(val) { |
@@ -1,2 +0,1 @@ | ||
'use strict'; | ||
@@ -3,0 +2,0 @@ const parseColorString = require('csscolorparser').parseCSSColor; |
@@ -1,3 +0,2 @@ | ||
'use strict'; | ||
module.exports = ['type', 'source', 'source-layer', 'minzoom', 'maxzoom', 'filter', 'layout']; |
@@ -1,2 +0,1 @@ | ||
'use strict'; | ||
@@ -3,0 +2,0 @@ // Turn jsonlint-lines-primitives objects into primitive objects |
@@ -1,2 +0,1 @@ | ||
'use strict'; | ||
@@ -3,0 +2,0 @@ const validateStyleMin = require('./validate_style.min'); |
@@ -1,2 +0,1 @@ | ||
'use strict'; | ||
@@ -3,0 +2,0 @@ const validateConstants = require('./validate/validate_constants'); |
@@ -1,2 +0,1 @@ | ||
'use strict'; | ||
@@ -3,0 +2,0 @@ /* |
@@ -1,2 +0,1 @@ | ||
'use strict'; | ||
@@ -3,0 +2,0 @@ const getType = require('../util/get_type'); |
@@ -1,2 +0,1 @@ | ||
'use strict'; | ||
@@ -3,0 +2,0 @@ const getType = require('../util/get_type'); |
@@ -1,2 +0,1 @@ | ||
'use strict'; | ||
@@ -3,0 +2,0 @@ const ValidationError = require('../error/validation_error'); |
@@ -1,2 +0,1 @@ | ||
'use strict'; | ||
@@ -3,0 +2,0 @@ const ValidationError = require('../error/validation_error'); |
@@ -1,2 +0,1 @@ | ||
'use strict'; | ||
@@ -3,0 +2,0 @@ const ValidationError = require('../error/validation_error'); |
@@ -1,2 +0,1 @@ | ||
'use strict'; | ||
@@ -3,0 +2,0 @@ const ValidationError = require('../error/validation_error'); |
@@ -1,2 +0,1 @@ | ||
'use strict'; | ||
@@ -172,3 +171,3 @@ const ValidationError = require('../error/validation_error'); | ||
if (type === 'number' && previousStopDomainValue !== undefined && value < previousStopDomainValue) { | ||
if (functionType !== 'categorical' && type === 'number' && previousStopDomainValue !== undefined && value < previousStopDomainValue) { | ||
return [new ValidationError(options.key, options.value, 'stop domain values must appear in ascending order')]; | ||
@@ -175,0 +174,0 @@ } else { |
@@ -1,2 +0,1 @@ | ||
'use strict'; | ||
@@ -3,0 +2,0 @@ const ValidationError = require('../error/validation_error'); |
@@ -1,2 +0,1 @@ | ||
'use strict'; | ||
@@ -3,0 +2,0 @@ const ValidationError = require('../error/validation_error'); |
@@ -1,2 +0,1 @@ | ||
'use strict'; | ||
@@ -3,0 +2,0 @@ const validateProperty = require('./validate_property'); |
@@ -1,2 +0,1 @@ | ||
'use strict'; | ||
@@ -3,0 +2,0 @@ const ValidationError = require('../error/validation_error'); |
@@ -1,2 +0,1 @@ | ||
'use strict'; | ||
@@ -3,0 +2,0 @@ const getType = require('../util/get_type'); |
@@ -1,2 +0,1 @@ | ||
'use strict'; | ||
@@ -3,0 +2,0 @@ const ValidationError = require('../error/validation_error'); |
@@ -1,2 +0,1 @@ | ||
'use strict'; | ||
@@ -3,0 +2,0 @@ const validateProperty = require('./validate_property'); |
@@ -1,2 +0,1 @@ | ||
'use strict'; | ||
@@ -35,5 +34,8 @@ const validate = require('./validate'); | ||
if (getType(value) === 'string' && valueSpec['property-function'] && !valueSpec.tokens && (tokenMatch = /^{([^}]+)}$/.exec(value))) { | ||
return [new ValidationError(key, value, '"%s" does not support interpolation syntax\n' + | ||
'Use an identity property function instead: `{ "type": "identity", "property": %s` }`.', | ||
propertyKey, JSON.stringify(tokenMatch[1]))]; | ||
return [new ValidationError( | ||
key, value, | ||
'"%s" does not support interpolation syntax\n' + | ||
'Use an identity property function instead: `{ "type": "identity", "property": %s` }`.', | ||
propertyKey, JSON.stringify(tokenMatch[1]) | ||
)]; | ||
} | ||
@@ -40,0 +42,0 @@ |
@@ -1,2 +0,1 @@ | ||
'use strict'; | ||
@@ -3,0 +2,0 @@ const ValidationError = require('../error/validation_error'); |
@@ -1,2 +0,1 @@ | ||
'use strict'; | ||
@@ -3,0 +2,0 @@ const getType = require('../util/get_type'); |
@@ -1,2 +0,1 @@ | ||
'use strict'; | ||
@@ -3,0 +2,0 @@ const ValidationError = require('../error/validation_error'); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
258747
6
8059
0
- Removedfast-stable-stringify@^0.1.1
- Removedfast-stable-stringify@0.1.1(transitive)