{"version":3,"file":"diff.mjs","names":[],"sources":["../src/diff.ts"],"sourcesContent":["import {\n FontFacesSpecification,\n GeoJSONSourceSpecification,\n LayerSpecification,\n LightSpecification,\n ProjectionSpecification,\n SkySpecification,\n SourceSpecification,\n SpriteSpecification,\n StyleSpecification,\n TerrainSpecification,\n TransitionSpecification,\n StateSpecification\n} from './types.g';\nimport {deepEqual} from './util/deep_equal';\n\n/**\n * Operations that can be performed by the diff.\n * Below are the operations and their arguments, the arguments should be aligned with the style methods in maplibre-gl-js.\n */\nexport type DiffOperationsMap = {\n setStyle: [StyleSpecification];\n addLayer: [LayerSpecification, string | null];\n removeLayer: [string];\n setPaintProperty: [string, string, unknown, string | null];\n setLayoutProperty: [string, string, unknown, string | null];\n setFilter: [string, unknown];\n addSource: [string, SourceSpecification];\n removeSource: [string];\n setGeoJSONSourceData: [string, unknown];\n setLayerZoomRange: [string, number, number];\n setLayerProperty: [string, string, unknown];\n setCenter: [number[]];\n setCenterAltitude: [number];\n setZoom: [number];\n setBearing: [number];\n setPitch: [number];\n setRoll: [number];\n setSprite: [SpriteSpecification];\n setGlyphs: [string];\n setFontFaces: [FontFacesSpecification];\n setTransition: [TransitionSpecification];\n setLight: [LightSpecification];\n setTerrain: [TerrainSpecification];\n setSky: [SkySpecification];\n setProjection: [ProjectionSpecification];\n setGlobalState: [StateSpecification];\n};\n\nexport type DiffOperations = keyof DiffOperationsMap;\n\nexport type DiffCommand = {\n command: T;\n args: DiffOperationsMap[T];\n};\n\n/**\n * The main reason for this method is to allow type check when adding a command to the array.\n * @param commands - The commands array to add to\n * @param command - The command to add\n */\nfunction addCommand(\n commands: DiffCommand[],\n command: DiffCommand\n) {\n commands.push(command);\n}\n\nfunction addSource(\n sourceId: string,\n after: {[key: string]: SourceSpecification},\n commands: DiffCommand[]\n) {\n addCommand(commands, {command: 'addSource', args: [sourceId, after[sourceId]]});\n}\n\nfunction removeSource(\n sourceId: string,\n commands: DiffCommand[],\n sourcesRemoved: {[key: string]: boolean}\n) {\n addCommand(commands, {command: 'removeSource', args: [sourceId]});\n sourcesRemoved[sourceId] = true;\n}\n\nfunction updateSource(\n sourceId: string,\n after: {[key: string]: SourceSpecification},\n commands: DiffCommand[],\n sourcesRemoved: {[key: string]: boolean}\n) {\n removeSource(sourceId, commands, sourcesRemoved);\n addSource(sourceId, after, commands);\n}\n\nfunction canUpdateGeoJSON(\n before: {[key: string]: SourceSpecification},\n after: {[key: string]: SourceSpecification},\n sourceId: string\n) {\n let prop;\n for (prop in before[sourceId]) {\n if (!Object.prototype.hasOwnProperty.call(before[sourceId], prop)) continue;\n if (prop !== 'data' && !deepEqual(before[sourceId][prop], after[sourceId][prop])) {\n return false;\n }\n }\n for (prop in after[sourceId]) {\n if (!Object.prototype.hasOwnProperty.call(after[sourceId], prop)) continue;\n if (prop !== 'data' && !deepEqual(before[sourceId][prop], after[sourceId][prop])) {\n return false;\n }\n }\n return true;\n}\n\nfunction diffSources(\n before: {[key: string]: SourceSpecification},\n after: {[key: string]: SourceSpecification},\n commands: DiffCommand[],\n sourcesRemoved: {[key: string]: boolean}\n) {\n before = before || ({} as {[key: string]: SourceSpecification});\n after = after || ({} as {[key: string]: SourceSpecification});\n\n let sourceId: string;\n\n // look for sources to remove\n for (sourceId in before) {\n if (!Object.prototype.hasOwnProperty.call(before, sourceId)) continue;\n if (!Object.prototype.hasOwnProperty.call(after, sourceId)) {\n removeSource(sourceId, commands, sourcesRemoved);\n }\n }\n\n // look for sources to add/update\n for (sourceId in after) {\n if (!Object.prototype.hasOwnProperty.call(after, sourceId)) continue;\n if (!Object.prototype.hasOwnProperty.call(before, sourceId)) {\n addSource(sourceId, after, commands);\n } else if (!deepEqual(before[sourceId], after[sourceId])) {\n if (\n before[sourceId].type === 'geojson' &&\n after[sourceId].type === 'geojson' &&\n canUpdateGeoJSON(before, after, sourceId)\n ) {\n addCommand(commands, {\n command: 'setGeoJSONSourceData',\n args: [sourceId, (after[sourceId] as GeoJSONSourceSpecification).data]\n });\n } else {\n // no update command, must remove then add\n updateSource(sourceId, after, commands, sourcesRemoved);\n }\n }\n }\n}\n\nfunction diffLayerPropertyChanges(\n before: LayerSpecification['layout'] | LayerSpecification['paint'],\n after: LayerSpecification['layout'] | LayerSpecification['paint'],\n commands: DiffCommand[],\n layerId: string,\n klass: string | null,\n command: 'setPaintProperty' | 'setLayoutProperty'\n) {\n before = before || ({} as LayerSpecification['layout'] | LayerSpecification['paint']);\n after = after || ({} as LayerSpecification['layout'] | LayerSpecification['paint']);\n\n for (const prop in before) {\n if (!Object.prototype.hasOwnProperty.call(before, prop)) continue;\n if (!deepEqual(before[prop], after[prop])) {\n commands.push({command, args: [layerId, prop, after[prop], klass]});\n }\n }\n for (const prop in after) {\n if (\n !Object.prototype.hasOwnProperty.call(after, prop) ||\n Object.prototype.hasOwnProperty.call(before, prop)\n )\n continue;\n if (!deepEqual(before[prop], after[prop])) {\n commands.push({command, args: [layerId, prop, after[prop], klass]});\n }\n }\n}\n\nfunction pluckId(layer: LayerSpecification) {\n return layer.id;\n}\nfunction indexById(group: {[key: string]: LayerSpecification}, layer: LayerSpecification) {\n group[layer.id] = layer;\n return group;\n}\n\nfunction diffLayers(\n before: LayerSpecification[],\n after: LayerSpecification[],\n commands: DiffCommand[]\n) {\n before = before || [];\n after = after || [];\n\n // order of layers by id\n const beforeOrder = before.map(pluckId);\n const afterOrder = after.map(pluckId);\n\n // index of layer by id\n const beforeIndex = before.reduce(indexById, {});\n const afterIndex = after.reduce(indexById, {});\n\n // track order of layers as if they have been mutated\n const tracker = beforeOrder.slice();\n\n // layers that have been added do not need to be diffed\n const clean = Object.create(null);\n\n let layerId: string;\n let beforeLayer: LayerSpecification & {source?: string; filter?: unknown};\n let afterLayer: LayerSpecification & {source?: string; filter?: unknown};\n let insertBeforeLayerId: string;\n let prop: string;\n\n // remove layers\n for (let i = 0, d = 0; i < beforeOrder.length; i++) {\n layerId = beforeOrder[i];\n if (!Object.prototype.hasOwnProperty.call(afterIndex, layerId)) {\n addCommand(commands, {command: 'removeLayer', args: [layerId]});\n tracker.splice(tracker.indexOf(layerId, d), 1);\n } else {\n // limit where in tracker we need to look for a match\n d++;\n }\n }\n\n // add/reorder layers\n for (let i = 0, d = 0; i < afterOrder.length; i++) {\n // work backwards as insert is before an existing layer\n layerId = afterOrder[afterOrder.length - 1 - i];\n\n if (tracker[tracker.length - 1 - i] === layerId) continue;\n\n if (Object.prototype.hasOwnProperty.call(beforeIndex, layerId)) {\n // remove the layer before we insert at the correct position\n addCommand(commands, {command: 'removeLayer', args: [layerId]});\n tracker.splice(tracker.lastIndexOf(layerId, tracker.length - d), 1);\n } else {\n // limit where in tracker we need to look for a match\n d++;\n }\n\n // add layer at correct position\n insertBeforeLayerId = tracker[tracker.length - i];\n addCommand(commands, {\n command: 'addLayer',\n args: [afterIndex[layerId], insertBeforeLayerId]\n });\n tracker.splice(tracker.length - i, 0, layerId);\n clean[layerId] = true;\n }\n\n // update layers\n for (let i = 0; i < afterOrder.length; i++) {\n layerId = afterOrder[i];\n beforeLayer = beforeIndex[layerId];\n afterLayer = afterIndex[layerId];\n\n // no need to update if previously added (new or moved)\n if (clean[layerId] || deepEqual(beforeLayer, afterLayer)) continue;\n\n // If source, source-layer, or type have changes, then remove the layer\n // and add it back 'from scratch'.\n if (\n !deepEqual(beforeLayer.source, afterLayer.source) ||\n !deepEqual(beforeLayer['source-layer'], afterLayer['source-layer']) ||\n !deepEqual(beforeLayer.type, afterLayer.type)\n ) {\n addCommand(commands, {command: 'removeLayer', args: [layerId]});\n // we add the layer back at the same position it was already in, so\n // there's no need to update the `tracker`\n insertBeforeLayerId = tracker[tracker.lastIndexOf(layerId) + 1];\n addCommand(commands, {command: 'addLayer', args: [afterLayer, insertBeforeLayerId]});\n continue;\n }\n\n // layout, paint, filter, minzoom, maxzoom\n diffLayerPropertyChanges(\n beforeLayer.layout,\n afterLayer.layout,\n commands,\n layerId,\n null,\n 'setLayoutProperty'\n );\n diffLayerPropertyChanges(\n beforeLayer.paint,\n afterLayer.paint,\n commands,\n layerId,\n null,\n 'setPaintProperty'\n );\n if (!deepEqual(beforeLayer.filter, afterLayer.filter)) {\n addCommand(commands, {command: 'setFilter', args: [layerId, afterLayer.filter]});\n }\n if (\n !deepEqual(beforeLayer.minzoom, afterLayer.minzoom) ||\n !deepEqual(beforeLayer.maxzoom, afterLayer.maxzoom)\n ) {\n addCommand(commands, {\n command: 'setLayerZoomRange',\n args: [layerId, afterLayer.minzoom, afterLayer.maxzoom]\n });\n }\n\n // handle all other layer props, including paint.*\n for (prop in beforeLayer) {\n if (!Object.prototype.hasOwnProperty.call(beforeLayer, prop)) continue;\n if (\n prop === 'layout' ||\n prop === 'paint' ||\n prop === 'filter' ||\n prop === 'metadata' ||\n prop === 'minzoom' ||\n prop === 'maxzoom'\n )\n continue;\n if (prop.indexOf('paint.') === 0) {\n diffLayerPropertyChanges(\n beforeLayer[prop],\n afterLayer[prop],\n commands,\n layerId,\n prop.slice(6),\n 'setPaintProperty'\n );\n } else if (!deepEqual(beforeLayer[prop], afterLayer[prop])) {\n addCommand(commands, {\n command: 'setLayerProperty',\n args: [layerId, prop, afterLayer[prop]]\n });\n }\n }\n for (prop in afterLayer) {\n if (\n !Object.prototype.hasOwnProperty.call(afterLayer, prop) ||\n Object.prototype.hasOwnProperty.call(beforeLayer, prop)\n )\n continue;\n if (\n prop === 'layout' ||\n prop === 'paint' ||\n prop === 'filter' ||\n prop === 'metadata' ||\n prop === 'minzoom' ||\n prop === 'maxzoom'\n )\n continue;\n if (prop.indexOf('paint.') === 0) {\n diffLayerPropertyChanges(\n beforeLayer[prop],\n afterLayer[prop],\n commands,\n layerId,\n prop.slice(6),\n 'setPaintProperty'\n );\n } else if (!deepEqual(beforeLayer[prop], afterLayer[prop])) {\n addCommand(commands, {\n command: 'setLayerProperty',\n args: [layerId, prop, afterLayer[prop]]\n });\n }\n }\n }\n}\n\n/**\n * Diff two stylesheet\n *\n * Creates semanticly aware diffs that can easily be applied at runtime.\n * Operations produced by the diff closely resemble the maplibre-gl-js API. Any\n * error creating the diff will fall back to the 'setStyle' operation.\n *\n * Example diff:\n * [\n * { command: 'setConstant', args: ['@water', '#0000FF'] },\n * { command: 'setPaintProperty', args: ['background', 'background-color', 'black'] }\n * ]\n *\n * @private\n * @param {*} [before] stylesheet to compare from\n * @param {*} after stylesheet to compare to\n * @returns Array list of changes\n */\nexport function diff(\n before: StyleSpecification,\n after: StyleSpecification\n): DiffCommand[] {\n if (!before) return [{command: 'setStyle', args: [after]}];\n\n let commands: DiffCommand[] = [];\n\n try {\n // Handle changes to top-level properties\n if (!deepEqual(before.version, after.version)) {\n return [{command: 'setStyle', args: [after]}];\n }\n if (!deepEqual(before.center, after.center)) {\n commands.push({command: 'setCenter', args: [after.center]});\n }\n if (!deepEqual(before.state, after.state)) {\n commands.push({command: 'setGlobalState', args: [after.state]});\n }\n if (!deepEqual(before.centerAltitude, after.centerAltitude)) {\n commands.push({command: 'setCenterAltitude', args: [after.centerAltitude]});\n }\n if (!deepEqual(before.zoom, after.zoom)) {\n commands.push({command: 'setZoom', args: [after.zoom]});\n }\n if (!deepEqual(before.bearing, after.bearing)) {\n commands.push({command: 'setBearing', args: [after.bearing]});\n }\n if (!deepEqual(before.pitch, after.pitch)) {\n commands.push({command: 'setPitch', args: [after.pitch]});\n }\n if (!deepEqual(before.roll, after.roll)) {\n commands.push({command: 'setRoll', args: [after.roll]});\n }\n if (!deepEqual(before.sprite, after.sprite)) {\n commands.push({command: 'setSprite', args: [after.sprite]});\n }\n if (!deepEqual(before.glyphs, after.glyphs)) {\n commands.push({command: 'setGlyphs', args: [after.glyphs]});\n }\n if (!deepEqual(before['font-faces'], after['font-faces'])) {\n commands.push({command: 'setFontFaces', args: [after['font-faces']]});\n }\n if (!deepEqual(before.transition, after.transition)) {\n commands.push({command: 'setTransition', args: [after.transition]});\n }\n if (!deepEqual(before.light, after.light)) {\n commands.push({command: 'setLight', args: [after.light]});\n }\n if (!deepEqual(before.terrain, after.terrain)) {\n commands.push({command: 'setTerrain', args: [after.terrain]});\n }\n if (!deepEqual(before.sky, after.sky)) {\n commands.push({command: 'setSky', args: [after.sky]});\n }\n if (!deepEqual(before.projection, after.projection)) {\n commands.push({command: 'setProjection', args: [after.projection]});\n }\n\n // Handle changes to `sources`\n // If a source is to be removed, we also--before the removeSource\n // command--need to remove all the style layers that depend on it.\n const sourcesRemoved = {};\n\n // First collect the {add,remove}Source commands\n const removeOrAddSourceCommands = [];\n diffSources(before.sources, after.sources, removeOrAddSourceCommands, sourcesRemoved);\n\n // Push a removeLayer command for each style layer that depends on a\n // source that's being removed.\n // Also, exclude any such layers them from the input to `diffLayers`\n // below, so that diffLayers produces the appropriate `addLayers`\n // command\n const beforeLayers = [];\n if (before.layers) {\n before.layers.forEach((layer) => {\n if ('source' in layer && sourcesRemoved[layer.source]) {\n commands.push({command: 'removeLayer', args: [layer.id]});\n } else {\n beforeLayers.push(layer);\n }\n });\n }\n commands = commands.concat(removeOrAddSourceCommands);\n\n // Handle changes to `layers`\n diffLayers(beforeLayers, after.layers, commands);\n } catch (e) {\n // fall back to setStyle\n console.warn('Unable to compute style diff:', e);\n commands = [{command: 'setStyle', args: [after]}];\n }\n\n return commands;\n}\n"],"mappings":";;;;;;;AA6DA,SAAS,WACL,UACA,SACF;CACE,SAAS,KAAK,OAAO;AACzB;AAEA,SAAS,UACL,UACA,OACA,UACF;CACE,WAAW,UAAU;EAAC,SAAS;EAAa,MAAM,CAAC,UAAU,MAAM,SAAS;CAAC,CAAC;AAClF;AAEA,SAAS,aACL,UACA,UACA,gBACF;CACE,WAAW,UAAU;EAAC,SAAS;EAAgB,MAAM,CAAC,QAAQ;CAAC,CAAC;CAChE,eAAe,YAAY;AAC/B;AAEA,SAAS,aACL,UACA,OACA,UACA,gBACF;CACE,aAAa,UAAU,UAAU,cAAc;CAC/C,UAAU,UAAU,OAAO,QAAQ;AACvC;AAEA,SAAS,iBACL,QACA,OACA,UACF;CACE,IAAI;CACJ,KAAK,QAAQ,OAAO,WAAW;EAC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