Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

@mapbox/mapbox-gl-style-spec

Package Overview
Dependencies
Maintainers
28
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mapbox/mapbox-gl-style-spec - npm Package Compare versions

Comparing version 14.0.0-beta.4 to 14.0.0-rc.1

90

diff.js

@@ -137,3 +137,3 @@ // @flow

/*
* { command: 'addImport', args: [importProperties] }
* { command: 'addImport', args: [import] }
*/

@@ -145,3 +145,13 @@ addImport: 'addImport',

*/
removeImport: 'removeImport'
removeImport: 'removeImport',
/*
* { command: 'setImportUrl', args: [importId, styleUrl] }
*/
setImportUrl: 'setImportUrl',
/*
* { command: 'setImportData', args: [importId, stylesheet] }
*/
setImportData: 'setImportData'
};

@@ -231,8 +241,8 @@

function pluckId(layer: LayerSpecification) {
return layer.id;
function pluckId<T: {id: string}>(item: T): string {
return item.id;
}
function indexById(group: {[string]: LayerSpecification}, layer: LayerSpecification) {
group[layer.id] = layer;
function indexById<T: {id: string}>(group: {[string]: T}, item: T): {[id: string]: T} {
group[item.id] = item;
return group;

@@ -351,10 +361,68 @@ }

function diffImports(before: Array<ImportSpecification> = [], after: Array<ImportSpecification> = [], commands: Array<Command>) {
// no diff for the imports, must remove then add
for (const beforeImport of before) {
commands.push({command: operations.removeImport, args: [beforeImport.id]});
export function diffImports(before: Array<ImportSpecification> = [], after: Array<ImportSpecification> = [], commands: Array<Command>) {
before = before || [];
after = after || [];
// order imports by id
const beforeOrder = before.map(pluckId);
const afterOrder = after.map(pluckId);
// index imports by id
const beforeIndex = before.reduce(indexById, {});
const afterIndex = after.reduce(indexById, {});
// track order of imports as if they have been mutated
const tracker = beforeOrder.slice();
let i, d, importId, insertBefore;
// remove imports
for (i = 0, d = 0; i < beforeOrder.length; i++) {
importId = beforeOrder[i];
if (!afterIndex.hasOwnProperty(importId)) {
commands.push({command: operations.removeImport, args: [importId]});
tracker.splice(tracker.indexOf(importId, d), 1);
} else {
// limit where in tracker we need to look for a match
d++;
}
}
// add/reorder imports
for (i = 0, d = 0; i < afterOrder.length; i++) {
// work backwards as insert is before an existing import
importId = afterOrder[afterOrder.length - 1 - i];
if (tracker[tracker.length - 1 - i] === importId) continue;
if (beforeIndex.hasOwnProperty(importId)) {
// remove the import before we insert at the correct position
commands.push({command: operations.removeImport, args: [importId]});
tracker.splice(tracker.lastIndexOf(importId, tracker.length - d), 1);
} else {
// limit where in tracker we need to look for a match
d++;
}
// add import at correct position
insertBefore = tracker[tracker.length - i];
commands.push({command: operations.addImport, args: [afterIndex[importId], insertBefore]});
tracker.splice(tracker.length - i, 0, importId);
}
// update imports
for (const afterImport of after) {
commands.push({command: operations.addImport, args: [afterImport]});
const beforeImport = beforeIndex[afterImport.id];
if (!beforeImport || isEqual(beforeImport, afterImport)) continue;
if (!isEqual(beforeImport.url, afterImport.url)) {
commands.push({command: operations.setImportUrl, args: [afterImport.id, afterImport.url]});
}
const beforeData = beforeImport && beforeImport.data;
const afterData = afterImport.data;
if (!isEqual(beforeData, afterData)) {
commands.push({command: operations.setImportData, args: [afterImport.id, afterData]});
}
}

@@ -361,0 +429,0 @@ }

@@ -19,1 +19,3 @@ // @flow

}
export class ValidationWarning extends ValidationError {}

@@ -13,2 +13,7 @@ // @flow strict

declare interface WebGLQuery {
prototype: WebGLQuery;
new(): WebGLQuery;
}
export type WebGL2RenderingContext = WebGLRenderingContext & {

@@ -21,2 +26,7 @@ createVertexArray: () => WebGLVertexArrayObject | null;

vertexAttribDivisor: (index: GLuint, divisor: GLuint) => void;
createQuery: () => WebGLQuery;
beginQuery: (target: GLenum, query: WebGLQuery) => void;
endQuery: (target: GLenum) => void;
deleteQuery: (query: WebGLQuery) => void;
getQueryParameter: (query: WebGLQuery, pname: GLenum) => GLuint;
};

2

package.json
{
"name": "@mapbox/mapbox-gl-style-spec",
"description": "a specification for mapbox gl styles",
"version": "14.0.0-beta.4",
"version": "14.0.0-rc.1",
"author": "Mapbox",

@@ -6,0 +6,0 @@ "keywords": [

@@ -121,2 +121,5 @@ // @flow

validateImports(imports);
if (imports.length !== (new Set(imports.map(i => i.id))).size) {
errors.push(new ValidationError(null, null, 'Duplicate ids of imports'));
}

@@ -123,0 +126,0 @@ return {errors, sourcesCount};

// @flow
import ValidationError from '../error/validation_error.js';
import {default as ValidationError, ValidationWarning} from '../error/validation_error.js';
import validate from './validate.js';

@@ -44,3 +44,3 @@ import getType from '../util/get_type.js';

} else {
errors = errors.concat([new ValidationError(key, fog[key], `unknown property "${key}"`)]);
errors = errors.concat([new ValidationWarning(key, fog[key], `unknown property "${key}"`)]);
}

@@ -47,0 +47,0 @@ }

// @flow
import ValidationError from '../error/validation_error.js';
import {default as ValidationError, ValidationWarning} from '../error/validation_error.js';
import getType from '../util/get_type.js';
import validate from './validate.js';
import {unbundle} from '../util/unbundle_jsonlint.js';
import type {ValidationOptions} from './validate.js';
export default function validateLights(options: ValidationOptions): Array<ValidationError> {
type Options = ValidationOptions & {
arrayIndex: number;
}
export default function validateLights(options: Options): Array<ValidationError> {
const light = options.value;

@@ -25,3 +30,5 @@ let errors = [];

const lightSpec = styleSpec['light-3d'];
const key = options.key;
const style = options.style;
const lights = options.style.lights;

@@ -35,2 +42,13 @@ for (const key of ['type', 'id']) {

if (light.type && lights) {
for (let i = 0; i < options.arrayIndex; i++) {
const lightType = unbundle(light.type);
const otherLight = lights[i];
if (unbundle(otherLight.type) === lightType) {
// $FlowFixMe[prop-missing] - id.__line__ is added dynamically during the readStyle step
errors.push(new ValidationError(key, light.id, `duplicate light type "${light.type}", previously defined at line ${otherLight.id.__line__}`));
}
}
}
const lightType = `properties_light_${light['type']}`;

@@ -80,3 +98,3 @@ if (!(lightType in styleSpec)) {

} else {
errors = errors.concat([new ValidationError(key, light[key], `unknown property "${key}"`)]);
errors = errors.concat([new ValidationWarning(key, light[key], `unknown property "${key}"`)]);
}

@@ -83,0 +101,0 @@ }

// @flow
import ValidationError from '../error/validation_error.js';
import {default as ValidationError, ValidationWarning} from '../error/validation_error.js';
import getType from '../util/get_type.js';

@@ -43,3 +43,3 @@ import validateSpec from './validate.js';

if (!validateElement) {
errors.push(new ValidationError(key, object[objectKey], `unknown property "${objectKey}"`));
errors.push(new ValidationWarning(key, object[objectKey], `unknown property "${objectKey}"`));
continue;

@@ -46,0 +46,0 @@ }

// @flow
import validate from './validate.js';
import ValidationError from '../error/validation_error.js';
import {default as ValidationError, ValidationWarning} from '../error/validation_error.js';
import getType from '../util/get_type.js';

@@ -44,3 +44,3 @@ import {isFunction} from '../function/index.js';

if (!valueSpec) {
return [new ValidationError(key, value, `unknown property "${propertyKey}"`)];
return [new ValidationWarning(key, value, `unknown property "${propertyKey}"`)];
}

@@ -71,4 +71,4 @@

const expressionObj = (expression.value: any).expression || (expression.value: any)._styleExpression.expression;
if (expressionObj && (!isGlobalPropertyConstant(expressionObj, ['zoom']) || !isGlobalPropertyConstant(expressionObj, ['measure-light']))) {
errors.push(new ValidationError(key, value, `${propertyKey} does not support zoom or measure-light expressions when the model layer source is vector tile or GeoJSON.`));
if (expressionObj && !isGlobalPropertyConstant(expressionObj, ['measure-light'])) {
errors.push(new ValidationError(key, value, `${propertyKey} does not support measure-light expressions when the model layer source is vector tile or GeoJSON.`));
}

@@ -75,0 +75,0 @@ }

// @flow
import ValidationError from '../error/validation_error.js';
import {default as ValidationError, ValidationWarning} from '../error/validation_error.js';
import validate from './validate.js';

@@ -46,3 +46,3 @@ import getType from '../util/get_type.js';

} else {
errors = errors.concat([new ValidationError(key, terrain[key], `unknown property "${key}"`)]);
errors = errors.concat([new ValidationWarning(key, terrain[key], `unknown property "${key}"`)]);
}

@@ -49,0 +49,0 @@ }

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc