From 34f4f4cd380bdb8a06ad697154d7546d0f75bf96 Mon Sep 17 00:00:00 2001 From: Kilian Finger Date: Sun, 27 Oct 2024 11:36:06 +0100 Subject: [PATCH 01/13] chore: move doc generation to ts --- package.json | 11 +- scripts/download-style-spec.sh | 15 - scripts/generate-docs.js | 396 - scripts/generate-docs.ts | 339 + .../{DocJSONBuilder.js => DocJSONBuilder.ts} | 38 +- .../{JSDocNodeTree.js => JSDocNodeTree.ts} | 27 +- scripts/utils/MarkdownBuilder.js | 37 - scripts/utils/MarkdownBuilder.ts | 39 + scripts/utils/getNativeVersion.ts | 53 + ...emplate-globals.js => template-globals.ts} | 24 +- style-spec/v8.json | 6645 ----------------- tsconfig.json | 4 +- yarn.lock | 400 +- 13 files changed, 861 insertions(+), 7167 deletions(-) delete mode 100755 scripts/download-style-spec.sh delete mode 100644 scripts/generate-docs.js create mode 100644 scripts/generate-docs.ts rename scripts/utils/{DocJSONBuilder.js => DocJSONBuilder.ts} (95%) rename scripts/utils/{JSDocNodeTree.js => JSDocNodeTree.ts} (84%) delete mode 100644 scripts/utils/MarkdownBuilder.js create mode 100644 scripts/utils/MarkdownBuilder.ts create mode 100644 scripts/utils/getNativeVersion.ts rename scripts/utils/{template-globals.js => template-globals.ts} (97%) delete mode 100644 style-spec/v8.json diff --git a/package.json b/package.json index 4c777d9c1..a03b6ec41 100644 --- a/package.json +++ b/package.json @@ -21,9 +21,7 @@ "url": "https://github.com/maplibre/maplibre-react-native" }, "scripts": { - "generate": "yarn generate:fetch-style-spec && yarn generate:docs", - "generate:fetch-style-spec": "./scripts/download-style-spec.sh", - "generate:docs": "yarn node ./scripts/generate-docs", + "generate": "tsx scripts/generate-docs.ts", "test": "jest", "lint": "yarn lint:eslint && yarn lint:tsc", "lint:eslint": "eslint .", @@ -64,16 +62,18 @@ "@babel/plugin-proposal-class-properties": "7.18.6", "@babel/runtime": "7.17.2", "@expo/config-plugins": "^7.2.5", + "@maplibre/maplibre-gl-style-spec": "21.0.0", "@react-native/babel-preset": "^0.74.88", "@react-native/metro-config": "^0.74.88", "@sinonjs/fake-timers": "^11.2.2", "@testing-library/react-native": "^12.4.3", "@tsconfig/node14": "^14.1.0", + "@types/ejs": "^3.1.5", "@typescript-eslint/eslint-plugin": "^7.18.0", "@typescript-eslint/parser": "^7.18.0", "babel-jest": "^29.6.0", "documentation": "^14.0.0", - "ejs": "^3.1.3", + "ejs": "^3.1.10", "ejs-lint": "^2.0.0", "eslint": "^8.57.1", "eslint-config-universe": "13.0.0", @@ -86,9 +86,10 @@ "pinst": "^3.0.0", "prettier": "3.3.3", "react": "18.2.0", - "react-docgen": "rnmapbox/react-docgen#rnmapbox-dist", + "react-docgen": "^7.1.0", "react-native": "^0.74.6", "react-test-renderer": "18.2.0", + "tsx": "^4.19.2", "typescript": "^5.3.3" }, "resolutions": { diff --git a/scripts/download-style-spec.sh b/scripts/download-style-spec.sh deleted file mode 100755 index 1a280e727..000000000 --- a/scripts/download-style-spec.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -echo "Downloading MapLibre Style Spec" -cd style-spec/ - -FILENAME=v8.json - -if [ -e "./${FILENAME}" ]; then - echo "Removing old style spec ${FILENAME}" - rm "./${FILENAME}" -fi - -echo "Fetching new style spec ${FILENAME}" -curl -sS https://raw.githubusercontent.com/maplibre/maplibre-style-spec/main/src/reference/${FILENAME} -o ${FILENAME} -cd .. diff --git a/scripts/generate-docs.js b/scripts/generate-docs.js deleted file mode 100644 index 1b09ebf8d..000000000 --- a/scripts/generate-docs.js +++ /dev/null @@ -1,396 +0,0 @@ -require("./utils/template-globals"); - -const { execSync } = require("child_process"); -const ejs = require("ejs"); -const prettierrc = require("eslint-config-universe"); -const fs = require("fs"); -const path = require("path"); -const prettier = require("prettier"); - -const { camelCase } = require("./utils/template-globals"); -const styleSpecJSON = require("../style-spec/v8.json"); -const DocJSONBuilder = require("./utils/DocJSONBuilder"); -const MarkdownBuilder = require("./utils/MarkdownBuilder"); - -function readIosVersion() { - const podspecPath = path.join( - __dirname, - "..", - "maplibre-react-native.podspec", - ); - const lines = fs.readFileSync(podspecPath, "utf8").split("\n"); - const maplibreLineRegex = /^\s+version:\s*"(\d+\.\d+\.\d+)"$/; - const maplibreLine = lines.filter((i) => maplibreLineRegex.exec(i))[0]; - return `${maplibreLineRegex.exec(maplibreLine)[1]}.0`; -} - -function readAndroidVersion() { - const buildGradlePath = path.join( - __dirname, - "..", - "android", - "rctmln", - "build.gradle", - ); - const lines = fs.readFileSync(buildGradlePath, "utf8").split("\n"); - const maplibreLineRegex = - /^\s+implementation\s+"org.maplibre.gl:android-sdk:(\d+\.\d+\.\d+)"$/; - const maplibreLine = lines.filter((i) => maplibreLineRegex.exec(i))[0]; - return maplibreLineRegex.exec(maplibreLine)[1]; -} - -if (!styleSpecJSON) { - console.log( - 'Could not find style spec, try running "yarn generate:fetch-style-spec"', - ); - process.exit(1); -} - -const layers = []; -const androidVersion = readAndroidVersion(); -const iosVersion = readIosVersion(); - -const TMPL_PATH = path.join(__dirname, "templates"); - -const outputToExample = false; -const OUTPUT_EXAMPLE_PREFIX = [ - "..", - "example", - "node_modules", - "@maplibre", - "maplibre-react-native", -]; -const OUTPUT_PREFIX = outputToExample ? OUTPUT_EXAMPLE_PREFIX : [".."]; - -const IOS_OUTPUT_PATH = path.join(__dirname, ...OUTPUT_PREFIX, "ios", "RCTMLN"); -const ANDROID_OUTPUT_PATH = path.join( - __dirname, - ...OUTPUT_PREFIX, - "android", - "rctmln", - "src", - "main", - "java", - "com", - "maplibre", - "rctmln", - "components", - "styles", -); -const JS_OUTPUT_PATH = path.join( - __dirname, - ...OUTPUT_PREFIX, - "javascript", - "utils", -); - -getSupportedLayers(Object.keys(styleSpecJSON.layer.type.values)).forEach( - (layerName) => { - layers.push({ - name: layerName, - properties: getPropertiesForLayer(layerName), - }); - }, -); - -// add light as a layer -layers.push({ name: "light", properties: getPropertiesForLight() }); - -function getPropertiesForLight() { - const lightAttributes = styleSpecJSON.light; - - return getSupportedProperties(lightAttributes).map((attrName) => { - return Object.assign({}, buildProperties(lightAttributes, attrName), { - allowedFunctionTypes: [], - }); - }); -} - -function getPropertiesForLayer(layerName) { - const paintAttributes = styleSpecJSON[`paint_${layerName}`]; - const layoutAttributes = styleSpecJSON[`layout_${layerName}`]; - - const paintProps = getSupportedProperties(paintAttributes).map((attrName) => { - const prop = buildProperties(paintAttributes, attrName); - - // overrides - if (["line-width"].includes(attrName)) { - prop.allowedFunctionTypes = ["camera"]; - } - - return prop; - }); - - const layoutProps = getSupportedProperties(layoutAttributes).map( - (attrName) => { - const prop = buildProperties(layoutAttributes, attrName); - - // overrides - if ( - [ - "line-join", - "text-max-width", - "text-letter-spacing", - "text-anchor", - "text-justify", - "text-font", - ].includes(attrName) - ) { - prop.allowedFunctionTypes = ["camera"]; - } - // Overide type padding - if (prop.type === "padding") { - prop.type = "array"; - prop.value = "number"; - prop.length = 4; - } - return prop; - }, - ); - - return layoutProps.concat(paintProps); -} - -function getSupportedLayers(layerNames) { - const layerMap = styleSpecJSON.layer.type.values; - - const supportedLayers = []; - for (const layerName of layerNames) { - const layer = layerMap[layerName]; - const support = getAttributeSupport(layer["sdk-support"]); - - if (support.basic.android && support.basic.ios) { - supportedLayers.push(layerName); - } - } - - return supportedLayers; -} - -function getSupportedProperties(attributes) { - return Object.keys(attributes).filter((attrName) => - isAttrSupported(attributes[attrName]), - ); -} - -function buildProperties(attributes, attrName) { - return { - name: camelCase(attrName), - doc: { - default: attributes[attrName].default, - minimum: attributes[attrName].minimum, - maximum: attributes[attrName].maximum, - units: attributes[attrName].units, - description: formatDescription(attributes[attrName].doc), - requires: getRequires(attributes[attrName].requires), - disabledBy: getDisables(attributes[attrName].requires), - values: attributes[attrName].values, - }, - type: attributes[attrName].type, - value: attributes[attrName].value, - image: isImage(attrName), - translate: isTranslate(attrName), - transition: attributes[attrName].transition, - expression: attributes[attrName].expression, - expressionSupported: - Object.keys(attributes[attrName].expression || {}).length > 0, - support: getAttributeSupport(attributes[attrName]["sdk-support"]), - allowedFunctionTypes: getAllowedFunctionTypes(attributes[attrName]), - }; -} - -function formatDescription(description) { - const words = description.split(" "); - - for (let i = 0; i < words.length; i++) { - const word = words[i]; - - if (word.includes("-")) { - words[i] = camelCase(word); - } - } - - return words.join(" "); -} - -function getRequires(requiredItems) { - const items = []; - - if (!requiredItems) { - return items; - } - - for (const item of requiredItems) { - if (typeof item === "string") { - items.push(camelCase(item, "-")); - } - } - - return items; -} - -function getDisables(disabledItems) { - const items = []; - - if (!disabledItems) { - return items; - } - - for (const item of disabledItems) { - if (item["!"]) { - items.push(camelCase(item["!"], "-")); - } - } - - return items; -} - -function isImage(attrName) { - return ( - attrName.toLowerCase().indexOf("pattern") !== -1 || - attrName.toLowerCase().indexOf("image") !== -1 - ); -} - -function isTranslate(attrName) { - return attrName.toLowerCase().indexOf("translate") !== -1; -} - -function isAttrSupported(attr) { - const support = getAttributeSupport(attr["sdk-support"]); - if (attr.private) { - return false; - } - return support.basic.android && support.basic.ios; -} - -function getAttributeSupport(sdkSupport) { - const support = { - basic: { android: false, ios: false }, - data: { android: false, ios: false }, - }; - - const basicSupport = sdkSupport && sdkSupport["basic functionality"]; - if (basicSupport && basicSupport.android) { - support.basic.android = isVersionGTE(androidVersion, basicSupport.android); - } - if (basicSupport && basicSupport.ios) { - support.basic.ios = isVersionGTE(iosVersion, basicSupport.ios); - } - - const dataDrivenSupport = sdkSupport && sdkSupport["data-driven styling"]; - if (dataDrivenSupport && dataDrivenSupport.android) { - support.data.android = isVersionGTE( - androidVersion, - dataDrivenSupport.android, - ); - } - if (dataDrivenSupport && dataDrivenSupport.ios) { - support.data.ios = isVersionGTE(iosVersion, dataDrivenSupport.ios); - } - - if (support.data.ios !== true || support.data.android !== true) { - support.data.ios = false; - support.data.android = false; - } - - return support; -} - -function isVersionGTE(version, otherVersion) { - const v = +version - .split(".") - .map((i) => String(i).padStart(3, "0")) - .join(""); - const ov = +otherVersion - .split(".") - .map((i) => String(i).padStart(3, "0")) - .join(""); - return v >= ov; -} - -function getAllowedFunctionTypes(paintAttr) { - const allowedFunctionTypes = []; - - if (paintAttr["zoom-function"]) { - allowedFunctionTypes.push("camera"); - } - - if (paintAttr["property-function"]) { - allowedFunctionTypes.push("source"); - allowedFunctionTypes.push("composite"); - } - - return allowedFunctionTypes; -} - -async function generate() { - const templateMappings = [ - { - input: path.join(TMPL_PATH, "RCTMLNStyle.h.ejs"), - output: path.join(IOS_OUTPUT_PATH, "RCTMLNStyle.h"), - }, - { - input: path.join(TMPL_PATH, "MaplibreStyles.ts.ejs"), - output: path.join(JS_OUTPUT_PATH, "MaplibreStyles.d.ts"), - }, - { - input: path.join(TMPL_PATH, "RCTMLNStyle.m.ejs"), - output: path.join(IOS_OUTPUT_PATH, "RCTMLNStyle.m"), - }, - { - input: path.join(TMPL_PATH, "RCTMLNStyleFactory.java.ejs"), - output: path.join(ANDROID_OUTPUT_PATH, "RCTMLNStyleFactory.java"), - }, - { - input: path.join(TMPL_PATH, "styleMap.ts.ejs"), - output: path.join(JS_OUTPUT_PATH, "styleMap.ts"), - }, - ]; - const outputPaths = templateMappings.map((m) => m.output); - - // autogenerate code - await Promise.all( - templateMappings.map(async ({ input, output }) => { - const filename = output.split("/").pop(); - console.log(`Generating ${filename}`); - const tmpl = ejs.compile(fs.readFileSync(input, "utf8"), { - strict: true, - }); - let results = tmpl({ layers }); - if (filename.endsWith("ts")) { - results = await prettier.format(results, { - ...prettierrc, - filepath: filename, - }); - // Ensure all enums are exported - results = results.replace(/enum (\w+Enum) \{[^}]+\}\n/g, "export $&"); - // Replace Array with any[] - results = results.replace(/Array/g, "any[]"); - // Replace padding type with float array - results = results.replace(/padding: string;/g, "padding: number[];"); - } - fs.writeFileSync(output, results); - }), - ); - - // autogenerate docs - const docBuilder = new DocJSONBuilder(layers); - const markdownBuilder = new MarkdownBuilder(); - await docBuilder.generate(); - await markdownBuilder.generate(); - - // Check if any generated files changed - try { - execSync(`git diff --exit-code docs/ ${outputPaths.join(" ")}`); - } catch (_error) { - console.error( - "\n\nThere are unstaged changes in the generated code. " + - "Please add them to your commit.\n" + - 'If you would really like to exclude them, run "git commit -n" to skip.\n\n', - ); - process.exit(1); - } -} - -generate(); diff --git a/scripts/generate-docs.ts b/scripts/generate-docs.ts new file mode 100644 index 000000000..d1869bb30 --- /dev/null +++ b/scripts/generate-docs.ts @@ -0,0 +1,339 @@ +import maplibreGlStyleSpec from "@maplibre/maplibre-gl-style-spec/src/reference/latest"; +import ejs from "ejs"; +import { exec } from "node:child_process"; +import { promises as fs } from "node:fs"; +import path from "node:path"; +import prettier from "prettier"; + +import { DocJSONBuilder } from "./utils/DocJSONBuilder"; +import { MarkdownBuilder } from "./utils/MarkdownBuilder"; +import { + getAndroidVersion, + getIosVersion, + isVersionGTE, +} from "./utils/getNativeVersion"; +import { camelCase } from "./utils/template-globals"; + +const TMPL_PATH = path.join(__dirname, "templates"); + +const IOS_OUTPUT_PATH = path.join(__dirname, "..", "ios", "RCTMLN"); +const ANDROID_OUTPUT_PATH = path.join( + __dirname, + "..", + "android", + "rctmln", + "src", + "main", + "java", + "com", + "maplibre", + "rctmln", + "components", + "styles", +); + +const JS_OUTPUT_PATH = path.join(__dirname, "..", "javascript", "utils"); + +const TEMPLATE_MAPPINGS = [ + { + input: path.join(TMPL_PATH, "RCTMLNStyle.h.ejs"), + output: path.join(IOS_OUTPUT_PATH, "RCTMLNStyle.h"), + }, + { + input: path.join(TMPL_PATH, "MaplibreStyles.ts.ejs"), + output: path.join(JS_OUTPUT_PATH, "MaplibreStyles.d.ts"), + }, + { + input: path.join(TMPL_PATH, "RCTMLNStyle.m.ejs"), + output: path.join(IOS_OUTPUT_PATH, "RCTMLNStyle.m"), + }, + { + input: path.join(TMPL_PATH, "RCTMLNStyleFactory.java.ejs"), + output: path.join(ANDROID_OUTPUT_PATH, "RCTMLNStyleFactory.java"), + }, + { + input: path.join(TMPL_PATH, "styleMap.ts.ejs"), + output: path.join(JS_OUTPUT_PATH, "styleMap.ts"), + }, +]; + +async function generate() { + const androidVersion = await getAndroidVersion(); + const iosVersion = await getIosVersion(); + + function getPropertiesForLight() { + const lightAttributes = maplibreGlStyleSpec.light; + + return getSupportedProperties(lightAttributes).map((attrName) => { + return Object.assign({}, buildProperties(lightAttributes, attrName), { + allowedFunctionTypes: [], + }); + }); + } + + function getPropertiesForLayer(layerName: string) { + const paintAttributes = maplibreGlStyleSpec[`paint_${layerName}`]; + const layoutAttributes = maplibreGlStyleSpec[`layout_${layerName}`]; + + const paintProps = getSupportedProperties(paintAttributes).map( + (attrName) => { + const prop = buildProperties(paintAttributes, attrName); + + // overrides + if (["line-width"].includes(attrName)) { + prop.allowedFunctionTypes = ["camera"]; + } + + return prop; + }, + ); + + const layoutProps = getSupportedProperties(layoutAttributes).map( + (attrName) => { + const prop = buildProperties(layoutAttributes, attrName); + + // overrides + if ( + [ + "line-join", + "text-max-width", + "text-letter-spacing", + "text-anchor", + "text-justify", + "text-font", + ].includes(attrName) + ) { + prop.allowedFunctionTypes = ["camera"]; + } + + // TODO + // Overide type padding + if (prop.type === "padding") { + prop.type = "array"; + prop.value = "number"; + prop.length = 4; + } + + return prop; + }, + ); + + return layoutProps.concat(paintProps); + } + + function getSupportedLayers() { + return Object.entries(maplibreGlStyleSpec.layer.type.values) + .map(([layerName, layerProperties]) => { + if ( + layerProperties && + typeof layerProperties === "object" && + "sdk-support" in layerProperties + ) { + const support = getAttributeSupport(layerProperties["sdk-support"]); + + if (support.basic.android && support.basic.ios) { + return layerName; + } + } + + return undefined; + }) + .filter((layerName) => typeof layerName === "string"); + } + + function getSupportedProperties(attributes: any) { + return Object.keys(attributes).filter((attrName) => + isAttrSupported(attributes[attrName]), + ); + } + + function buildProperties(attributes: any, attrName: string) { + return { + name: camelCase(attrName), + doc: { + default: attributes[attrName].default, + minimum: attributes[attrName].minimum, + maximum: attributes[attrName].maximum, + units: attributes[attrName].units, + description: formatDescription(attributes[attrName].doc), + requires: getRequires(attributes[attrName].requires), + disabledBy: getDisables(attributes[attrName].requires), + values: attributes[attrName].values, + }, + type: attributes[attrName].type, + value: attributes[attrName].value, + length: undefined as undefined | number, + image: isImage(attrName), + translate: isTranslate(attrName), + transition: attributes[attrName].transition, + expression: attributes[attrName].expression, + expressionSupported: + Object.keys(attributes[attrName].expression || {}).length > 0, + support: getAttributeSupport(attributes[attrName]["sdk-support"]), + allowedFunctionTypes: getAllowedFunctionTypes(attributes[attrName]), + }; + } + + function formatDescription(description: string) { + const words = description.split(" "); + + for (let i = 0; i < words.length; i++) { + const word = words[i]; + + if (word.includes("-")) { + words[i] = camelCase(word); + } + } + + return words.join(" "); + } + + function getRequires(requiredItems: any) { + const items: any[] = []; + + if (!requiredItems) { + return items; + } + + for (const item of requiredItems) { + if (typeof item === "string") { + items.push(camelCase(item, "-")); + } + } + + return items; + } + + function getDisables(disabledItems: any[]) { + const items: any[] = []; + + if (!disabledItems) { + return items; + } + + for (const item of disabledItems) { + if (item["!"]) { + items.push(camelCase(item["!"], "-")); + } + } + + return items; + } + + function isImage(attrName: string) { + return ( + attrName.toLowerCase().indexOf("pattern") !== -1 || + attrName.toLowerCase().indexOf("image") !== -1 + ); + } + + function isTranslate(attrName: string) { + return attrName.toLowerCase().indexOf("translate") !== -1; + } + + function isAttrSupported(attr: any) { + const support = getAttributeSupport(attr["sdk-support"]); + if (attr.private) { + return false; + } + return support.basic.android && support.basic.ios; + } + + function getAttributeSupport(sdkSupport: any) { + const support = { + basic: { android: false, ios: false }, + data: { android: false, ios: false }, + }; + + const basicSupport = sdkSupport && sdkSupport["basic functionality"]; + support.basic.android = isVersionGTE(androidVersion, basicSupport?.android); + support.basic.ios = isVersionGTE(iosVersion, basicSupport?.ios); + + const dataDrivenSupport = sdkSupport && sdkSupport["data-driven styling"]; + support.data.android = isVersionGTE( + androidVersion, + dataDrivenSupport?.android, + ); + support.data.ios = isVersionGTE(iosVersion, dataDrivenSupport?.ios); + + if (!support.data.ios || !support.data.android) { + support.data.ios = false; + support.data.android = false; + } + + return support; + } + + function getAllowedFunctionTypes(paintAttr: any) { + const allowedFunctionTypes = []; + + if (paintAttr["zoom-function"]) { + allowedFunctionTypes.push("camera"); + } + + if (paintAttr["property-function"]) { + allowedFunctionTypes.push("source"); + allowedFunctionTypes.push("composite"); + } + + return allowedFunctionTypes; + } + + const layers = getSupportedLayers().map((layerName) => { + return { + name: layerName, + properties: getPropertiesForLayer(layerName), + }; + }); + + // add light as a layer + layers.push({ name: "light", properties: getPropertiesForLight() }); + + // autogenerate code + await Promise.all( + TEMPLATE_MAPPINGS.map(async ({ input, output }) => { + const filename = path.parse(output).base; + + console.log(`Generating ${filename}`); + const tmpl = ejs.compile(await fs.readFile(input, "utf8"), { + strict: true, + async: true, + }); + let results = await tmpl({ layers }); + if (filename.endsWith("ts")) { + results = await prettier.format(results, { + filepath: filename, + }); + // Ensure all enums are exported + results = results.replace(/enum (\w+Enum) \{[^}]+}\n/g, "export $&"); + // Replace Array with any[] + results = results.replace(/Array/g, "any[]"); + // Replace padding type with float array + results = results.replace(/padding: string;/g, "padding: number[];"); + } + await fs.writeFile(output, results); + }), + ); + + // autogenerate docs + const docBuilder = new DocJSONBuilder(layers); + const markdownBuilder = new MarkdownBuilder(); + await docBuilder.generate(); + await markdownBuilder.generate(); + + // Check if any generated files changed + try { + exec( + `git diff --exit-code docs/ ${TEMPLATE_MAPPINGS.map((m) => m.output).join(" ")}`, + ); + } catch (_error) { + console.error( + "\n\nThere are unstaged changes in the generated code. " + + "Please add them to your commit.\n" + + 'If you would really like to exclude them, run "git commit -n" to skip.\n\n', + ); + process.exit(1); + } +} + +generate(); diff --git a/scripts/utils/DocJSONBuilder.js b/scripts/utils/DocJSONBuilder.ts similarity index 95% rename from scripts/utils/DocJSONBuilder.js rename to scripts/utils/DocJSONBuilder.ts index ed703be67..d403b8991 100644 --- a/scripts/utils/DocJSONBuilder.js +++ b/scripts/utils/DocJSONBuilder.ts @@ -1,12 +1,12 @@ -const { exec } = require("child_process"); -const fs = require("fs"); -const dir = require("node-dir"); -const path = require("path"); -const docgen = require("react-docgen"); -const parseJsDoc = require("react-docgen/dist/utils/parseJsDoc").default; +import { exec } from "child_process"; +import dir from "node-dir"; +import fs from "node:fs"; +import path from "node:path"; +import * as docgen from "react-docgen"; +import { parseJsDoc } from "react-docgen/dist/utils"; -const JSDocNodeTree = require("./JSDocNodeTree"); -const { pascalCase } = require("./template-globals"); +import { JSDocNodeTree } from "./JSDocNodeTree"; +import { pascalCase } from "./template-globals"; const COMPONENT_PATH = path.join( __dirname, @@ -15,22 +15,24 @@ const COMPONENT_PATH = path.join( "javascript", "components", ); -const MODULES_PATH = path.join(__dirname, "..", "..", "javascript", "modules"); +const MODULES_PATH = path.join(__dirname, "..", "..", "javascript", "modules"); const OUTPUT_PATH = path.join(__dirname, "..", "..", "docs", "docs.json"); + const IGNORE_FILES = [ "AbstractLayer", "AbstractSource", "NativeBridgeComponent", ]; const IGNORE_PATTERN = /\.web\./; - const IGNORE_METHODS = ["setNativeProps"]; const fileExtensionsRegex = /.(js|tsx|(? { dir.readFiles( filePath, @@ -440,12 +444,10 @@ class DocJSONBuilder { const results = {}; - const tasks = [ + return Promise.all([ this.generateReactComponentsTask(results, COMPONENT_PATH), this.generateModulesTask(results, MODULES_PATH), - ]; - - return Promise.all(tasks).then(() => { + ]).then(() => { fs.writeFileSync( OUTPUT_PATH, JSON.stringify(this.sortObject(results), null, 2), @@ -454,5 +456,3 @@ class DocJSONBuilder { }); } } - -module.exports = DocJSONBuilder; diff --git a/scripts/utils/JSDocNodeTree.js b/scripts/utils/JSDocNodeTree.ts similarity index 84% rename from scripts/utils/JSDocNodeTree.js rename to scripts/utils/JSDocNodeTree.ts index 7b77df9b0..643bb0009 100644 --- a/scripts/utils/JSDocNodeTree.js +++ b/scripts/utils/JSDocNodeTree.ts @@ -1,13 +1,16 @@ -class JSDocNodeTree { - constructor(root) { +export class JSDocNodeTree { + _root: any; + + constructor(root: any) { this._root = root; } - getChildrenByTag(node, tag) { + getChildrenByTag(node: any, tag: any) { if (!node || !Array.isArray(node.children)) { return []; } - return node.children.filter((child) => child.type === tag); + + return node.children.filter((child: any) => child.type === tag); } getName() { @@ -59,7 +62,7 @@ class JSDocNodeTree { return methods; } - getMethodParams(field) { + getMethodParams(field: any) { if (!this._hasArray(field, "params")) { return []; } @@ -82,14 +85,14 @@ class JSDocNodeTree { return methodParams; } - getExamples(field) { + getExamples(field: any) { if (!this._hasArray(field, "examples")) { return []; } - return field.examples.map((example) => example.description); + return field.examples.map((example: any) => example.description); } - getReturnValue(field) { + getReturnValue(field: any) { if (!this._hasArray(field, "returns")) { return null; } @@ -103,7 +106,7 @@ class JSDocNodeTree { }; } - getType(typeNode) { + getType(typeNode: any) { if (!typeNode) { return ""; } @@ -119,16 +122,14 @@ class JSDocNodeTree { return this._hasArray(this._root.description, "children"); } - _hasArray(node, propName) { + _hasArray(node: any, propName: string) { if (!this._root) { return false; } return Array.isArray(node[propName]) && node[propName].length; } - _isPrivateMethod(field) { + _isPrivateMethod(field: any) { return field.name.charAt(0) === "_"; } } - -module.exports = JSDocNodeTree; diff --git a/scripts/utils/MarkdownBuilder.js b/scripts/utils/MarkdownBuilder.js deleted file mode 100644 index d91788411..000000000 --- a/scripts/utils/MarkdownBuilder.js +++ /dev/null @@ -1,37 +0,0 @@ -const ejs = require("ejs"); -const fs = require("fs"); -const path = require("path"); - -const TMPL_PATH = path.join(__dirname, "..", "templates"); -const TMPL_FILE = fs.readFileSync( - path.join(TMPL_PATH, "component.md.ejs"), - "utf8", -); - -class MarkdownBuilder { - generateComponentFile(docJSON, componentName) { - const tmpl = ejs.compile(TMPL_FILE, { strict: true }); - const fileContents = tmpl({ component: docJSON[componentName] }); - fs.writeFileSync( - path.join(__dirname, "..", "..", "docs", `${componentName}.md`), - fileContents, - ); - } - - generate() { - const docJSONFile = fs.readFileSync( - path.join(__dirname, "..", "..", "docs", "docs.json"), - "utf8", - ); - const docJSON = JSON.parse(docJSONFile); - const componentPaths = Object.keys(docJSON); - - for (const componentPath of componentPaths) { - this.generateComponentFile(docJSON, componentPath); - } - - console.log("Markdown is finished generating"); - } -} - -module.exports = MarkdownBuilder; diff --git a/scripts/utils/MarkdownBuilder.ts b/scripts/utils/MarkdownBuilder.ts new file mode 100644 index 000000000..a3cf22ccf --- /dev/null +++ b/scripts/utils/MarkdownBuilder.ts @@ -0,0 +1,39 @@ +import ejs from "ejs"; +import { promises as fs } from "node:fs"; +import path from "node:path"; + +const TMPL_PATH = path.join(__dirname, "..", "templates"); + +export class MarkdownBuilder { + async generateComponentFile(docJSON: any, componentName: string) { + const tmpl = ejs.compile( + await fs.readFile(path.join(TMPL_PATH, "component.md.ejs"), "utf8"), + { + async: true, + strict: true, + }, + ); + const fileContents = await tmpl({ component: docJSON[componentName] }); + await fs.writeFile( + path.join(__dirname, "..", "..", "docs", `${componentName}.md`), + fileContents, + ); + } + + async generate() { + const docJSONFile = await fs.readFile( + path.join(__dirname, "..", "..", "docs", "docs.json"), + "utf8", + ); + const docJSON = JSON.parse(docJSONFile); + const componentPaths = Object.keys(docJSON); + + await Promise.all( + componentPaths.map((componentPath) => + this.generateComponentFile(docJSON, componentPath), + ), + ); + + console.log("Markdown is finished generating"); + } +} diff --git a/scripts/utils/getNativeVersion.ts b/scripts/utils/getNativeVersion.ts new file mode 100644 index 000000000..8757c6e1d --- /dev/null +++ b/scripts/utils/getNativeVersion.ts @@ -0,0 +1,53 @@ +import { promises as fs } from "fs"; +import path from "node:path"; + +async function getNativeVersion(pathSegments: string[], regex: RegExp) { + const resolvedFilePath = path.join(__dirname, "..", "..", ...pathSegments); + const lines = (await fs.readFile(resolvedFilePath, "utf8")).split("\n"); + const line = lines.filter((i) => regex.exec(i))[0]; + const version = regex.exec(line)?.[1]; + + if (!version) { + throw new Error("Could not find native version from " + resolvedFilePath); + } + + return version; +} + +let cachedAndroidVersion: string; +let cachedIosVersion: string; + +export const getAndroidVersion = async () => { + if (!cachedAndroidVersion) { + cachedAndroidVersion = await getNativeVersion( + ["android", "rctmln", "build.gradle"], + /^\s+implementation\s+"org.maplibre.gl:android-sdk:(\d+\.\d+\.\d+)"$/, + ); + } + + return cachedAndroidVersion; +}; + +export const getIosVersion = async () => { + if (!cachedIosVersion) { + cachedIosVersion = await getNativeVersion( + ["maplibre-react-native.podspec"], + /^\s+version:\s*"(\d+\.\d+\.\d+)"$/, + ); + } + + return cachedIosVersion; +}; + +export function isVersionGTE( + version: string, + otherVersion: string | undefined, +) { + return ( + !!otherVersion?.match(/^(\d+\.\d+\.\d+)$/) && + version.localeCompare(otherVersion, undefined, { + numeric: true, + sensitivity: "base", + }) >= 0 + ); +} diff --git a/scripts/utils/template-globals.js b/scripts/utils/template-globals.ts similarity index 97% rename from scripts/utils/template-globals.js rename to scripts/utils/template-globals.ts index cff5c1259..851db6134 100644 --- a/scripts/utils/template-globals.js +++ b/scripts/utils/template-globals.ts @@ -52,7 +52,7 @@ global.getValue = function (value, defaultValue) { return value; }; -function camelCase(str, delimiter = "-") { +export function camelCase(str, delimiter = "-") { const parts = str.split(delimiter); return parts .map((part, index) => { @@ -65,7 +65,7 @@ function camelCase(str, delimiter = "-") { } global.camelCase = camelCase; -function pascalCase(str, delimiter = "-") { +export function pascalCase(str, delimiter = "-") { const parts = str.split(delimiter); return parts .map((part) => { @@ -408,14 +408,8 @@ function startAtSpace(spaceCount, str) { global.startAtSpace = startAtSpace; -function replaceNewLine(str) { - if (str === undefined) { - return undefined; - } - if (str === null) { - return null; - } - return str.replace(/\n/g, "
"); +export function replaceNewLine(str) { + return str?.replace(/\n/g, "
"); } global.replaceNewLine = replaceNewLine; @@ -449,17 +443,20 @@ function _propMarkdownTableRows(props, prefix = "") { } const defaultValue = prop.default || ""; const { description = "" } = prop; + let result = `| ${prefix}${ prop.name - } | \`${type}\` | \`${defaultValue}\` | \`${ + } | \`${type.replace(/^\\\| /, "").replace(/\n/g, " ")}\` | \`${defaultValue}\` | \`${ prop.required }\` | ${replaceNewLine(description)} |`; + if (type === "shape") { result = `${result}\n${_propMarkdownTableRows( prop.type.value, `  ${prefix}`, )}`; } + return result; }) .join("\n"); @@ -521,8 +518,3 @@ Object.keys(iosSpecOverrides).forEach((propName) => { iosSpecOverrides[propName], ); }); - -module.exports = { - camelCase, - pascalCase, -}; diff --git a/style-spec/v8.json b/style-spec/v8.json deleted file mode 100644 index 20986b9ea..000000000 --- a/style-spec/v8.json +++ /dev/null @@ -1,6645 +0,0 @@ -{ - "$version": 8, - "$root": { - "version": { - "required": true, - "type": "enum", - "values": [ - 8 - ], - "doc": "Style specification version number. Must be 8.", - "example": 8 - }, - "name": { - "type": "string", - "doc": "A human-readable name for the style.", - "example": "Bright" - }, - "metadata": { - "type": "*", - "doc": "Arbitrary properties useful to track with the stylesheet, but do not influence rendering. Properties should be prefixed to avoid collisions, like 'maplibre:'.", - "example": { - "styleeditor:slimmode": true, - "styleeditor:comment": "Style generated 1677776383", - "styleeditor:version": "3.14.159265", - "example:object": { "String": "one", "Number": 2, "Boolean": false } - } - }, - "center": { - "type": "array", - "value": "number", - "doc": "Default map center in longitude and latitude. The style center will be used only if the map has not been positioned by other means (e.g. map options or user interaction).", - "example": [ - -73.9749, - 40.7736 - ] - }, - "zoom": { - "type": "number", - "doc": "Default zoom level. The style zoom will be used only if the map has not been positioned by other means (e.g. map options or user interaction).", - "example": 12.5 - }, - "bearing": { - "type": "number", - "default": 0, - "period": 360, - "units": "degrees", - "doc": "Default bearing, in degrees. The bearing is the compass direction that is \"up\"; for example, a bearing of 90° orients the map so that east is up. This value will be used only if the map has not been positioned by other means (e.g. map options or user interaction).", - "example": 29 - }, - "pitch": { - "type": "number", - "default": 0, - "units": "degrees", - "doc": "Default pitch, in degrees. Zero is perpendicular to the surface, for a look straight down at the map, while a greater value like 60 looks ahead towards the horizon. The style pitch will be used only if the map has not been positioned by other means (e.g. map options or user interaction).", - "example": 50, - "sdk-support": { - "0-60 degrees": { - "js": "0.8.0", - "android": "1.0.0", - "ios": "1.0.0" - }, - "0-85 degrees": { - "js": "2.0.0", - "android": "https://github.com/maplibre/maplibre-native/issues/1909", - "ios": "https://github.com/maplibre/maplibre-native/issues/1909" - }, - "0-180 degrees": { - "js": "5.0.0", - "android": "https://github.com/maplibre/maplibre-native/issues/1909", - "ios": "https://github.com/maplibre/maplibre-native/issues/1909" - } - } - }, - "roll": { - "type": "number", - "default": 0, - "units": "degrees", - "doc": "Default roll, in degrees. The roll angle is measured counterclockwise about the camera boresight. The style roll will be used only if the map has not been positioned by other means (e.g. map options or user interaction).", - "example": 45, - "sdk-support": { - "basic functionality": { - "js": "5.0.0", - "android": "https://github.com/maplibre/maplibre-native/issues/2941", - "ios": "https://github.com/maplibre/maplibre-native/issues/2941" - } - } - }, - "light": { - "type": "light", - "doc": "The global light source.", - "example": { - "anchor": "viewport", - "color": "white", - "intensity": 0.4 - } - }, - "sky": { - "type": "sky", - "doc": "The map's sky configuration. **Note:** this definition is still experimental and is under development in maplibre-gl-js.", - "example": { - "sky-color": "#199EF3", - "sky-horizon-blend": 0.5, - "horizon-color": "#ffffff", - "horizon-fog-blend": 0.5, - "fog-color": "#0000ff", - "fog-ground-blend": 0.5, - "atmosphere-blend": ["interpolate", - ["linear"], - ["zoom"], - 0,1, - 10,1, - 12,0 - ] - } - }, - "projection": { - "type": "projection", - "doc": "The projection configuration. **Note:** this definition is still experimental and is under development in maplibre-gl-js.", - "example": { - "type": "globe" - } - }, - "terrain": { - "type": "terrain", - "doc": "The terrain configuration.", - "example": { - "source": "raster-dem-source", - "exaggeration": 0.5 - } - }, - "sources": { - "required": true, - "type": "sources", - "doc": "Sources state which data the map should display. Specify the type of source with the `type` property. Adding a source isn't enough to make data appear on the map because sources don't contain styling details like color or width. Layers refer to a source and give it a visual representation. This makes it possible to style the same source in different ways, like differentiating between types of roads in a highways layer.\n\nTiled sources (vector and raster) must specify their details according to the [TileJSON specification](https://github.com/mapbox/tilejson-spec).", - "example": { - "maplibre-demotiles": { - "type": "vector", - "url": "https://demotiles.maplibre.org/tiles/tiles.json" - }, - "maplibre-tilejson": { - "type": "vector", - "url": "http://api.example.com/tilejson.json" - }, - "maplibre-streets": { - "type": "vector", - "tiles": [ - "http://a.example.com/tiles/{z}/{x}/{y}.pbf", - "http://b.example.com/tiles/{z}/{x}/{y}.pbf" - ], - "maxzoom": 14 - }, - "wms-imagery": { - "type": "raster", - "tiles": [ - "http://a.example.com/wms?bbox={bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:3857&width=256&height=256&layers=example" - ], - "tileSize": 256 - } - } - }, - "sprite": { - "type": "sprite", - "doc": "An array of `{id: 'my-sprite', url: 'https://example.com/sprite'}` objects. Each object should represent a unique URL to load a sprite from and and a unique ID to use as a prefix when referencing images from that sprite (i.e. 'my-sprite:image'). All the URLs are internally extended to load both .json and .png files. If the `id` field is equal to 'default', the prefix is omitted (just 'image' instead of 'default:image'). All the IDs and URLs must be unique. For backwards compatibility, instead of an array, one can also provide a single string that represent a URL to load the sprite from. The images in this case won't be prefixed.", - "example": "https://demotiles.maplibre.org/styles/osm-bright-gl-style/sprite" - }, - "glyphs": { - "type": "string", - "doc": "A URL template for loading signed-distance-field glyph sets in PBF format. \n\nThe URL must include:\n\n - `{fontstack}` - When requesting glyphs, this token is replaced with a comma separated list of fonts from a font stack specified in the text-font property of a symbol layer. \n\n - `{range}` - When requesting glyphs, this token is replaced with a range of 256 Unicode code points. For example, to load glyphs for the Unicode Basic Latin and Basic Latin-1 Supplement blocks, the range would be 0-255. The actual ranges that are loaded are determined at runtime based on what text needs to be displayed.\n\nThis property is required if any layer uses the `text-field` layout property. The URL must be absolute, containing the [scheme, authority and path components](https://en.wikipedia.org/wiki/URL#Syntax).", - "example": "https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf" - }, - "transition": { - "type": "transition", - "doc": "A global transition definition to use as a default across properties, to be used for timing transitions between one value and the next when no property-specific transition is set. Collision-based symbol fading is controlled independently of the style's `transition` property.", - "example": { - "duration": 300, - "delay": 0 - } - }, - "layers": { - "required": true, - "type": "array", - "value": "layer", - "doc": "A style's `layers` property lists all the layers available in that style. The type of layer is specified by the `type` property, and must be one of `background`, `fill`, `line`, `symbol`, `raster`, `circle`, `fill-extrusion`, `heatmap`, `hillshade`.\n\nExcept for layers of the `background` type, each layer needs to refer to a source. Layers take the data that they get from a source, optionally filter features, and then define how those features are styled.", - "example": [ - { - "id": "coastline", - "source": "maplibre", - "source-layer": "countries", - "type": "line", - "paint": { - "line-color": "#198EC8" - } - } - ] - } - }, - "sources": { - "*": { - "type": "source", - "doc": "Specification of a data source. For vector and raster sources, either TileJSON or a URL to a TileJSON must be provided. For image and video sources, a URL must be provided. For GeoJSON sources, a URL or inline GeoJSON must be provided." - } - }, - "source": [ - "source_vector", - "source_raster", - "source_raster_dem", - "source_geojson", - "source_video", - "source_image" - ], - "source_vector": { - "type": { - "required": true, - "type": "enum", - "values": { - "vector": { - "doc": "A vector tile source." - } - }, - "doc": "The type of the source." - }, - "url": { - "type": "string", - "doc": "A URL to a TileJSON resource. Supported protocols are `http:` and `https:`." - }, - "tiles": { - "type": "array", - "value": "string", - "doc": "An array of one or more tile source URLs, as in the TileJSON spec." - }, - "bounds": { - "type": "array", - "value": "number", - "length": 4, - "default": [ - -180, - -85.051129, - 180, - 85.051129 - ], - "doc": "An array containing the longitude and latitude of the southwest and northeast corners of the source's bounding box in the following order: `[sw.lng, sw.lat, ne.lng, ne.lat]`. When this property is included in a source, no tiles outside of the given bounds are requested by MapLibre." - }, - "scheme": { - "type": "enum", - "values": { - "xyz": { - "doc": "Slippy map tilenames scheme." - }, - "tms": { - "doc": "OSGeo spec scheme." - } - }, - "default": "xyz", - "doc": "Influences the y direction of the tile coordinates. The global-mercator (aka Spherical Mercator) profile is assumed." - }, - "minzoom": { - "type": "number", - "default": 0, - "doc": "Minimum zoom level for which tiles are available, as in the TileJSON spec." - }, - "maxzoom": { - "type": "number", - "default": 22, - "doc": "Maximum zoom level for which tiles are available, as in the TileJSON spec. Data from tiles at the maxzoom are used when displaying the map at higher zoom levels." - }, - "attribution": { - "type": "string", - "doc": "Contains an attribution to be displayed when the map is shown to a user." - }, - "promoteId": { - "type": "promoteId", - "doc": "A property to use as a feature id (for feature state). Either a property name, or an object of the form `{: }`. If specified as a string for a vector tile source, the same property is used across all its source layers." - }, - "volatile": { - "type": "boolean", - "default": false, - "doc": "A setting to determine whether a source's tiles are cached locally.", - "sdk-support": { - "basic functionality": { - "android": "9.3.0", - "ios": "5.10.0", - "js": "wontfix" - } - } - }, - "*": { - "type": "*", - "doc": "Other keys to configure the data source." - } - }, - "source_raster": { - "type": { - "required": true, - "type": "enum", - "values": { - "raster": { - "doc": "A raster tile source." - } - }, - "doc": "The type of the source." - }, - "url": { - "type": "string", - "doc": "A URL to a TileJSON resource. Supported protocols are `http:` and `https:`." - }, - "tiles": { - "type": "array", - "value": "string", - "doc": "An array of one or more tile source URLs, as in the TileJSON spec." - }, - "bounds": { - "type": "array", - "value": "number", - "length": 4, - "default": [ - -180, - -85.051129, - 180, - 85.051129 - ], - "doc": "An array containing the longitude and latitude of the southwest and northeast corners of the source's bounding box in the following order: `[sw.lng, sw.lat, ne.lng, ne.lat]`. When this property is included in a source, no tiles outside of the given bounds are requested by MapLibre." - }, - "minzoom": { - "type": "number", - "default": 0, - "doc": "Minimum zoom level for which tiles are available, as in the TileJSON spec." - }, - "maxzoom": { - "type": "number", - "default": 22, - "doc": "Maximum zoom level for which tiles are available, as in the TileJSON spec. Data from tiles at the maxzoom are used when displaying the map at higher zoom levels." - }, - "tileSize": { - "type": "number", - "default": 512, - "units": "pixels", - "doc": "The minimum visual size to display tiles for this layer. Only configurable for raster layers." - }, - "scheme": { - "type": "enum", - "values": { - "xyz": { - "doc": "Slippy map tilenames scheme." - }, - "tms": { - "doc": "OSGeo spec scheme." - } - }, - "default": "xyz", - "doc": "Influences the y direction of the tile coordinates. The global-mercator (aka Spherical Mercator) profile is assumed." - }, - "attribution": { - "type": "string", - "doc": "Contains an attribution to be displayed when the map is shown to a user." - }, - "volatile": { - "type": "boolean", - "default": false, - "doc": "A setting to determine whether a source's tiles are cached locally.", - "sdk-support": { - "basic functionality": { - "android": "9.3.0", - "ios": "5.10.0", - "js": "wontfix" - } - } - }, - "*": { - "type": "*", - "doc": "Other keys to configure the data source." - } - }, - "source_raster_dem": { - "type": { - "required": true, - "type": "enum", - "values": { - "raster-dem": { - "doc": "A RGB-encoded raster DEM source" - } - }, - "doc": "The type of the source." - }, - "url": { - "type": "string", - "doc": "A URL to a TileJSON resource. Supported protocols are `http:` and `https:`." - }, - "tiles": { - "type": "array", - "value": "string", - "doc": "An array of one or more tile source URLs, as in the TileJSON spec." - }, - "bounds": { - "type": "array", - "value": "number", - "length": 4, - "default": [ - -180, - -85.051129, - 180, - 85.051129 - ], - "doc": "An array containing the longitude and latitude of the southwest and northeast corners of the source's bounding box in the following order: `[sw.lng, sw.lat, ne.lng, ne.lat]`. When this property is included in a source, no tiles outside of the given bounds are requested by MapLibre." - }, - "minzoom": { - "type": "number", - "default": 0, - "doc": "Minimum zoom level for which tiles are available, as in the TileJSON spec." - }, - "maxzoom": { - "type": "number", - "default": 22, - "doc": "Maximum zoom level for which tiles are available, as in the TileJSON spec. Data from tiles at the maxzoom are used when displaying the map at higher zoom levels." - }, - "tileSize": { - "type": "number", - "default": 512, - "units": "pixels", - "doc": "The minimum visual size to display tiles for this layer. Only configurable for raster layers." - }, - "attribution": { - "type": "string", - "doc": "Contains an attribution to be displayed when the map is shown to a user." - }, - "encoding": { - "type": "enum", - "values": { - "terrarium": { - "doc": "Terrarium format PNG tiles. See https://aws.amazon.com/es/public-datasets/terrain/ for more info." - }, - "mapbox": { - "doc": "Mapbox Terrain RGB tiles. See https://www.mapbox.com/help/access-elevation-data/#mapbox-terrain-rgb for more info." - }, - "custom": { - "doc": "Decodes tiles using the redFactor, blueFactor, greenFactor, baseShift parameters." - } - }, - "default": "mapbox", - "doc": "The encoding used by this source. Mapbox Terrain RGB is used by default.", - "sdk-support": { - "mapbox, terrarium": { - "js": "0.43.0", - "ios": "6.0.0", - "android": "6.0.0" - }, - "custom": { - "js": "3.4.0", - "ios": "https://github.com/maplibre/maplibre-native/issues/2783", - "android": "https://github.com/maplibre/maplibre-native/issues/2783" - } - } - }, - "redFactor": { - "type": "number", - "default": 1.0, - "doc": "Value that will be multiplied by the red channel value when decoding. Only used on custom encodings.", - "sdk-support": { - "basic functionality": { - "js": "3.4.0", - "ios": "https://github.com/maplibre/maplibre-native/issues/2783", - "android": "https://github.com/maplibre/maplibre-native/issues/2783" - } - } - }, - "blueFactor": { - "type": "number", - "default": 1.0, - "doc": "Value that will be multiplied by the blue channel value when decoding. Only used on custom encodings.", - "sdk-support": { - "basic functionality": { - "js": "3.4.0", - "ios": "https://github.com/maplibre/maplibre-native/issues/2783", - "android": "https://github.com/maplibre/maplibre-native/issues/2783" - } - } - }, - "greenFactor": { - "type": "number", - "default": 1.0, - "doc": "Value that will be multiplied by the green channel value when decoding. Only used on custom encodings.", - "sdk-support": { - "basic functionality": { - "js": "3.4.0", - "ios": "https://github.com/maplibre/maplibre-native/issues/2358", - "android": "https://github.com/maplibre/maplibre-native/issues/2783" - } - } - }, - "baseShift": { - "type": "number", - "default": 0.0, - "doc": "Value that will be added to the encoding mix when decoding. Only used on custom encodings.", - "sdk-support": { - "basic functionality": { - "js": "3.4.0", - "ios": "https://github.com/maplibre/maplibre-native/issues/2783", - "android": "https://github.com/maplibre/maplibre-native/issues/2783" - } - } - }, - "volatile": { - "type": "boolean", - "default": false, - "doc": "A setting to determine whether a source's tiles are cached locally.", - "sdk-support": { - "basic functionality": { - "android": "9.3.0", - "ios": "5.10.0", - "js": "wontfix" - } - } - }, - "*": { - "type": "*", - "doc": "Other keys to configure the data source." - } - }, - "source_geojson": { - "type": { - "required": true, - "type": "enum", - "values": { - "geojson": { - "doc": "A GeoJSON data source." - } - }, - "doc": "The data type of the GeoJSON source." - }, - "data": { - "required": true, - "type": "*", - "doc": "A URL to a GeoJSON file, or inline GeoJSON." - }, - "maxzoom": { - "type": "number", - "default": 18, - "doc": "Maximum zoom level at which to create vector tiles (higher means greater detail at high zoom levels)." - }, - "attribution": { - "type": "string", - "doc": "Contains an attribution to be displayed when the map is shown to a user." - }, - "buffer": { - "type": "number", - "default": 128, - "maximum": 512, - "minimum": 0, - "doc": "Size of the tile buffer on each side. A value of 0 produces no buffer. A value of 512 produces a buffer as wide as the tile itself. Larger values produce fewer rendering artifacts near tile edges and slower performance." - }, - "filter": { - "type": "*", - "doc": "An expression for filtering features prior to processing them for rendering." - }, - "tolerance": { - "type": "number", - "default": 0.375, - "doc": "Douglas-Peucker simplification tolerance (higher means simpler geometries and faster performance)." - }, - "cluster": { - "type": "boolean", - "default": false, - "doc": "If the data is a collection of point features, setting this to true clusters the points by radius into groups. Cluster groups become new `Point` features in the source with additional properties:\n\n * `cluster` Is `true` if the point is a cluster \n\n * `cluster_id` A unique id for the cluster to be used in conjunction with the [cluster inspection methods](https://maplibre.org/maplibre-gl-js/docs/API/classes/GeoJSONSource/#getclusterexpansionzoom)\n\n * `point_count` Number of original points grouped into this cluster\n\n * `point_count_abbreviated` An abbreviated point count" - }, - "clusterRadius": { - "type": "number", - "default": 50, - "minimum": 0, - "doc": "Radius of each cluster if clustering is enabled. A value of 512 indicates a radius equal to the width of a tile." - }, - "clusterMaxZoom": { - "type": "number", - "doc": "Max zoom on which to cluster points if clustering is enabled. Defaults to one zoom less than maxzoom (so that last zoom features are not clustered). Clusters are re-evaluated at integer zoom levels so setting clusterMaxZoom to 14 means the clusters will be displayed until z15." - }, - "clusterMinPoints": { - "type": "number", - "doc": "Minimum number of points necessary to form a cluster if clustering is enabled. Defaults to `2`." - }, - "clusterProperties": { - "type": "*", - "doc": "An object defining custom properties on the generated clusters if clustering is enabled, aggregating values from clustered points. Has the form `{\"property_name\": [operator, map_expression]}`. `operator` is any expression function that accepts at least 2 operands (e.g. `\"+\"` or `\"max\"`) — it accumulates the property value from clusters/points the cluster contains; `map_expression` produces the value of a single point.\n\nExample: `{\"sum\": [\"+\", [\"get\", \"scalerank\"]]}`.\n\nFor more advanced use cases, in place of `operator`, you can use a custom reduce expression that references a special `[\"accumulated\"]` value, e.g.:\n\n`{\"sum\": [[\"+\", [\"accumulated\"], [\"get\", \"sum\"]], [\"get\", \"scalerank\"]]}`" - }, - "lineMetrics": { - "type": "boolean", - "default": false, - "doc": "Whether to calculate line distance metrics. This is required for line layers that specify `line-gradient` values." - }, - "generateId": { - "type": "boolean", - "default": false, - "doc": "Whether to generate ids for the geojson features. When enabled, the `feature.id` property will be auto assigned based on its index in the `features` array, over-writing any previous values." - }, - "promoteId": { - "type": "promoteId", - "doc": "A property to use as a feature id (for feature state). Either a property name, or an object of the form `{: }`." - } - }, - "source_video": { - "type": { - "required": true, - "type": "enum", - "values": { - "video": { - "doc": "A video data source." - } - }, - "doc": "The data type of the video source." - }, - "urls": { - "required": true, - "type": "array", - "value": "string", - "doc": "URLs to video content in order of preferred format." - }, - "coordinates": { - "required": true, - "doc": "Corners of video specified in longitude, latitude pairs.", - "type": "array", - "length": 4, - "value": { - "type": "array", - "length": 2, - "value": "number", - "doc": "A single longitude, latitude pair." - } - } - }, - "source_image": { - "type": { - "required": true, - "type": "enum", - "values": { - "image": { - "doc": "An image data source." - } - }, - "doc": "The data type of the image source." - }, - "url": { - "required": true, - "type": "string", - "doc": "URL that points to an image." - }, - "coordinates": { - "required": true, - "doc": "Corners of image specified in longitude, latitude pairs.", - "type": "array", - "length": 4, - "value": { - "type": "array", - "length": 2, - "value": "number", - "doc": "A single longitude, latitude pair." - } - } - }, - "layer": { - "id": { - "type": "string", - "doc": "Unique layer name.", - "required": true - }, - "type": { - "type": "enum", - "values": { - "fill": { - "doc": "A filled polygon with an optional stroked border.", - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - } - }, - "line": { - "doc": "A stroked line.", - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - } - }, - "symbol": { - "doc": "An icon or a text label.", - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - } - }, - "circle": { - "doc": "A filled circle.", - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - } - }, - "heatmap": { - "doc": "A heatmap.", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "fill-extrusion": { - "doc": "An extruded (3D) polygon.", - "sdk-support": { - "basic functionality": { - "js": "0.27.0", - "android": "5.1.0", - "ios": "3.6.0" - } - } - }, - "raster": { - "doc": "Raster map textures such as satellite imagery.", - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - } - }, - "hillshade": { - "doc": "Client-side hillshading visualization based on DEM data. The implementation supports Mapbox Terrain RGB, Mapzen Terrarium tiles and custom encodings.", - "sdk-support": { - "basic functionality": { - "js": "0.43.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "background": { - "doc": "The background color or pattern of the map.", - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - } - } - }, - "doc": "Rendering type of this layer.", - "required": true - }, - "metadata": { - "type": "*", - "doc": "Arbitrary properties useful to track with the layer, but do not influence rendering. Properties should be prefixed to avoid collisions, like 'maplibre:'.", - "example": { - "source:comment": "Hydrology FCCODE 460 - Narrow wash" - } - }, - "source": { - "type": "string", - "doc": "Name of a source description to be used for this layer. Required for all layer types except `background`." - }, - "source-layer": { - "type": "string", - "doc": "Layer to use from a vector tile source. Required for vector tile sources; prohibited for all other source types, including GeoJSON sources." - }, - "minzoom": { - "type": "number", - "minimum": 0, - "maximum": 24, - "doc": "The minimum zoom level for the layer. At zoom levels less than the minzoom, the layer will be hidden." - }, - "maxzoom": { - "type": "number", - "minimum": 0, - "maximum": 24, - "doc": "The maximum zoom level for the layer. At zoom levels equal to or greater than the maxzoom, the layer will be hidden." - }, - "filter": { - "type": "filter", - "doc": "A expression specifying conditions on source features. Only features that match the filter are displayed. Zoom expressions in filters are only evaluated at integer zoom levels. The `feature-state` expression is not supported in filter expressions." - }, - "layout": { - "type": "layout", - "doc": "Layout properties for the layer." - }, - "paint": { - "type": "paint", - "doc": "Default paint properties for this layer." - } - }, - "layout": [ - "layout_fill", - "layout_line", - "layout_circle", - "layout_heatmap", - "layout_fill-extrusion", - "layout_symbol", - "layout_raster", - "layout_hillshade", - "layout_background" - ], - "layout_background": { - "visibility": { - "type": "enum", - "values": { - "visible": { - "doc": "The layer is shown." - }, - "none": { - "doc": "The layer is not shown." - } - }, - "default": "visible", - "doc": "Whether this layer is displayed.", - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "property-type": "constant" - } - }, - "layout_fill": { - "fill-sort-key": { - "type": "number", - "doc": "Sorts features in ascending order based on this value. Features with a higher sort key will appear above features with a lower sort key.", - "sdk-support": { - "basic functionality": { - "js": "1.2.0", - "android": "9.1.0", - "ios": "5.8.0" - }, - "data-driven styling": { - "js": "1.2.0", - "android": "9.1.0", - "ios": "5.8.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom", - "feature" - ] - }, - "property-type": "data-driven" - }, - "visibility": { - "type": "enum", - "values": { - "visible": { - "doc": "The layer is shown." - }, - "none": { - "doc": "The layer is not shown." - } - }, - "default": "visible", - "doc": "Whether this layer is displayed.", - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "property-type": "constant" - } - }, - "layout_circle": { - "circle-sort-key": { - "type": "number", - "doc": "Sorts features in ascending order based on this value. Features with a higher sort key will appear above features with a lower sort key.", - "sdk-support": { - "basic functionality": { - "js": "1.2.0", - "android": "9.2.0", - "ios": "5.9.0" - }, - "data-driven styling": { - "js": "1.2.0", - "android": "9.2.0", - "ios": "5.9.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom", - "feature" - ] - }, - "property-type": "data-driven" - }, - "visibility": { - "type": "enum", - "values": { - "visible": { - "doc": "The layer is shown." - }, - "none": { - "doc": "The layer is not shown." - } - }, - "default": "visible", - "doc": "Whether this layer is displayed.", - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "property-type": "constant" - } - }, - "layout_heatmap": { - "visibility": { - "type": "enum", - "values": { - "visible": { - "doc": "The layer is shown." - }, - "none": { - "doc": "The layer is not shown." - } - }, - "default": "visible", - "doc": "Whether this layer is displayed.", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - }, - "property-type": "constant" - } - }, - "layout_fill-extrusion": { - "visibility": { - "type": "enum", - "values": { - "visible": { - "doc": "The layer is shown." - }, - "none": { - "doc": "The layer is not shown." - } - }, - "default": "visible", - "doc": "Whether this layer is displayed.", - "sdk-support": { - "basic functionality": { - "js": "0.27.0", - "android": "5.1.0", - "ios": "3.6.0" - } - }, - "property-type": "constant" - } - }, - "layout_line": { - "line-cap": { - "type": "enum", - "values": { - "butt": { - "doc": "A cap with a squared-off end which is drawn to the exact endpoint of the line." - }, - "round": { - "doc": "A cap with a rounded end which is drawn beyond the endpoint of the line at a radius of one-half of the line's width and centered on the endpoint of the line." - }, - "square": { - "doc": "A cap with a squared-off end which is drawn beyond the endpoint of the line at a distance of one-half of the line's width." - } - }, - "default": "butt", - "doc": "The display of line endings.", - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "line-join": { - "type": "enum", - "values": { - "bevel": { - "doc": "A join with a squared-off end which is drawn beyond the endpoint of the line at a distance of one-half of the line's width." - }, - "round": { - "doc": "A join with a rounded end which is drawn beyond the endpoint of the line at a radius of one-half of the line's width and centered on the endpoint of the line." - }, - "miter": { - "doc": "A join with a sharp, angled corner which is drawn with the outer sides beyond the endpoint of the path until they meet." - } - }, - "default": "miter", - "doc": "The display of lines when joining.", - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "0.40.0", - "android": "5.2.0", - "ios": "3.7.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom", - "feature" - ] - }, - "property-type": "data-driven" - }, - "line-miter-limit": { - "type": "number", - "default": 2, - "doc": "Used to automatically convert miter joins to bevel joins for sharp angles.", - "requires": [ - { - "line-join": "miter" - } - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "line-round-limit": { - "type": "number", - "default": 1.05, - "doc": "Used to automatically convert round joins to miter joins for shallow angles.", - "requires": [ - { - "line-join": "round" - } - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "line-sort-key": { - "type": "number", - "doc": "Sorts features in ascending order based on this value. Features with a higher sort key will appear above features with a lower sort key.", - "sdk-support": { - "basic functionality": { - "js": "1.2.0", - "android": "9.1.0", - "ios": "5.8.0" - }, - "data-driven styling": { - "js": "1.2.0", - "android": "9.1.0", - "ios": "5.8.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom", - "feature" - ] - }, - "property-type": "data-driven" - }, - "visibility": { - "type": "enum", - "values": { - "visible": { - "doc": "The layer is shown." - }, - "none": { - "doc": "The layer is not shown." - } - }, - "default": "visible", - "doc": "Whether this layer is displayed.", - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "property-type": "constant" - } - }, - "layout_symbol": { - "symbol-placement": { - "type": "enum", - "values": { - "point": { - "doc": "The label is placed at the point where the geometry is located." - }, - "line": { - "doc": "The label is placed along the line of the geometry. Can only be used on `LineString` and `Polygon` geometries." - }, - "line-center": { - "doc": "The label is placed at the center of the line of the geometry. Can only be used on `LineString` and `Polygon` geometries. Note that a single feature in a vector tile may contain multiple line geometries." - } - }, - "default": "point", - "doc": "Label placement relative to its geometry.", - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "`line-center` value": { - "js": "0.47.0", - "android": "6.4.0", - "ios": "4.3.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "symbol-spacing": { - "type": "number", - "default": 250, - "minimum": 1, - "units": "pixels", - "doc": "Distance between two symbol anchors.", - "requires": [ - { - "symbol-placement": "line" - } - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "symbol-avoid-edges": { - "type": "boolean", - "default": false, - "doc": "If true, the symbols will not cross tile edges to avoid mutual collisions. Recommended in layers that don't have enough padding in the vector tile to prevent collisions, or if it is a point symbol layer placed after a line symbol layer. When using a client that supports global collision detection, like MapLibre GL JS version 0.42.0 or greater, enabling this property is not needed to prevent clipped labels at tile boundaries.", - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "symbol-sort-key": { - "type": "number", - "doc": "Sorts features in ascending order based on this value. Features with lower sort keys are drawn and placed first. When `icon-allow-overlap` or `text-allow-overlap` is `false`, features with a lower sort key will have priority during placement. When `icon-allow-overlap` or `text-allow-overlap` is set to `true`, features with a higher sort key will overlap over features with a lower sort key.", - "sdk-support": { - "basic functionality": { - "js": "0.53.0", - "android": "7.4.0", - "ios": "4.11.0" - }, - "data-driven styling": { - "js": "0.53.0", - "android": "7.4.0", - "ios": "4.11.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom", - "feature" - ] - }, - "property-type": "data-driven" - }, - "symbol-z-order": { - "type": "enum", - "values": { - "auto": { - "doc": "Sorts symbols by `symbol-sort-key` if set. Otherwise, sorts symbols by their y-position relative to the viewport if `icon-allow-overlap` or `text-allow-overlap` is set to `true` or `icon-ignore-placement` or `text-ignore-placement` is `false`." - }, - "viewport-y": { - "doc": "Sorts symbols by their y-position relative to the viewport if `icon-allow-overlap` or `text-allow-overlap` is set to `true` or `icon-ignore-placement` or `text-ignore-placement` is `false`." - }, - "source": { - "doc": "Sorts symbols by `symbol-sort-key` if set. Otherwise, no sorting is applied; symbols are rendered in the same order as the source data." - } - }, - "default": "auto", - "doc": "Determines whether overlapping symbols in the same layer are rendered in the order that they appear in the data source or by their y-position relative to the viewport. To control the order and prioritization of symbols otherwise, use `symbol-sort-key`.", - "sdk-support": { - "basic functionality": { - "js": "0.49.0", - "android": "6.6.0", - "ios": "4.5.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "icon-allow-overlap": { - "type": "boolean", - "default": false, - "doc": "If true, the icon will be visible even if it collides with other previously drawn symbols.", - "requires": [ - "icon-image", - { - "!": "icon-overlap" - } - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "icon-overlap": { - "type": "enum", - "values": { - "never": { - "doc": "The icon will be hidden if it collides with any other previously drawn symbol." - }, - "always": { - "doc": "The icon will be visible even if it collides with any other previously drawn symbol." - }, - "cooperative": { - "doc": "If the icon collides with another previously drawn symbol, the overlap mode for that symbol is checked. If the previous symbol was placed using `never` overlap mode, the new icon is hidden. If the previous symbol was placed using `always` or `cooperative` overlap mode, the new icon is visible." - } - }, - "doc": "Allows for control over whether to show an icon when it overlaps other symbols on the map. If `icon-overlap` is not set, `icon-allow-overlap` is used instead.", - "requires": [ - "icon-image" - ], - "sdk-support": { - "basic functionality": { - "js": "2.1.0", - "android": "https://github.com/maplibre/maplibre-native/issues/251", - "ios": "https://github.com/maplibre/maplibre-native/issues/251" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "icon-ignore-placement": { - "type": "boolean", - "default": false, - "doc": "If true, other symbols can be visible even if they collide with the icon.", - "requires": [ - "icon-image" - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "icon-optional": { - "type": "boolean", - "default": false, - "doc": "If true, text will display without their corresponding icons when the icon collides with other symbols and the text does not.", - "requires": [ - "icon-image", - "text-field" - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "icon-rotation-alignment": { - "type": "enum", - "values": { - "map": { - "doc": "When `symbol-placement` is set to `point`, aligns icons east-west. When `symbol-placement` is set to `line` or `line-center`, aligns icon x-axes with the line." - }, - "viewport": { - "doc": "Produces icons whose x-axes are aligned with the x-axis of the viewport, regardless of the value of `symbol-placement`." - }, - "auto": { - "doc": "When `symbol-placement` is set to `point`, this is equivalent to `viewport`. When `symbol-placement` is set to `line` or `line-center`, this is equivalent to `map`." - } - }, - "default": "auto", - "doc": "In combination with `symbol-placement`, determines the rotation behavior of icons.", - "requires": [ - "icon-image" - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "`auto` value": { - "js": "0.25.0", - "android": "4.2.0", - "ios": "3.4.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "icon-size": { - "type": "number", - "default": 1, - "minimum": 0, - "units": "factor of the original icon size", - "doc": "Scales the original size of the icon by the provided factor. The new pixel size of the image will be the original pixel size multiplied by `icon-size`. 1 is the original size; 3 triples the size of the image.", - "requires": [ - "icon-image" - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "0.35.0", - "android": "5.1.0", - "ios": "3.6.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature" - ] - }, - "property-type": "data-driven" - }, - "icon-text-fit": { - "type": "enum", - "values": { - "none": { - "doc": "The icon is displayed at its intrinsic aspect ratio." - }, - "width": { - "doc": "The icon is scaled in the x-dimension to fit the width of the text." - }, - "height": { - "doc": "The icon is scaled in the y-dimension to fit the height of the text." - }, - "both": { - "doc": "The icon is scaled in both x- and y-dimensions." - } - }, - "default": "none", - "doc": "Scales the icon to fit around the associated text.", - "requires": [ - "icon-image", - "text-field" - ], - "sdk-support": { - "basic functionality": { - "js": "0.21.0", - "android": "4.2.0", - "ios": "3.4.0" - }, - "stretchable icons": { - "js": "1.6.0", - "android": "9.2.0", - "ios": "5.8.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "icon-text-fit-padding": { - "type": "array", - "value": "number", - "length": 4, - "default": [ - 0, - 0, - 0, - 0 - ], - "units": "pixels", - "doc": "Size of the additional area added to dimensions determined by `icon-text-fit`, in clockwise order: top, right, bottom, left.", - "requires": [ - "icon-image", - "text-field", - { - "icon-text-fit": [ - "both", - "width", - "height" - ] - } - ], - "sdk-support": { - "basic functionality": { - "js": "0.21.0", - "android": "4.2.0", - "ios": "3.4.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "icon-image": { - "type": "resolvedImage", - "doc": "Name of image in sprite to use for drawing an image background.", - "tokens": true, - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "0.35.0", - "android": "5.1.0", - "ios": "3.6.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom", - "feature" - ] - }, - "property-type": "data-driven" - }, - "icon-rotate": { - "type": "number", - "default": 0, - "period": 360, - "units": "degrees", - "doc": "Rotates the icon clockwise.", - "requires": [ - "icon-image" - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "0.21.0", - "android": "5.0.0", - "ios": "3.5.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature" - ] - }, - "property-type": "data-driven" - }, - "icon-padding": { - "type": "padding", - "default": [2], - "units": "pixels", - "doc": "Size of additional area round the icon bounding box used for detecting symbol collisions.", - "requires": [ - "icon-image" - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "2.2.0", - "android": "https://github.com/maplibre/maplibre-native/issues/2754", - "ios": "https://github.com/maplibre/maplibre-native/issues/2754" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature" - ] - }, - "property-type": "data-driven" - }, - "icon-keep-upright": { - "type": "boolean", - "default": false, - "doc": "If true, the icon may be flipped to prevent it from being rendered upside-down.", - "requires": [ - "icon-image", - { - "icon-rotation-alignment": "map" - }, - { - "symbol-placement": [ - "line", - "line-center" - ] - } - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "icon-offset": { - "type": "array", - "value": "number", - "length": 2, - "default": [ - 0, - 0 - ], - "doc": "Offset distance of icon from its anchor. Positive values indicate right and down, while negative values indicate left and up. Each component is multiplied by the value of `icon-size` to obtain the final offset in pixels. When combined with `icon-rotate` the offset will be as if the rotated direction was up.", - "requires": [ - "icon-image" - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "0.29.0", - "android": "5.0.0", - "ios": "3.5.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature" - ] - }, - "property-type": "data-driven" - }, - "icon-anchor": { - "type": "enum", - "values": { - "center": { - "doc": "The center of the icon is placed closest to the anchor." - }, - "left": { - "doc": "The left side of the icon is placed closest to the anchor." - }, - "right": { - "doc": "The right side of the icon is placed closest to the anchor." - }, - "top": { - "doc": "The top of the icon is placed closest to the anchor." - }, - "bottom": { - "doc": "The bottom of the icon is placed closest to the anchor." - }, - "top-left": { - "doc": "The top left corner of the icon is placed closest to the anchor." - }, - "top-right": { - "doc": "The top right corner of the icon is placed closest to the anchor." - }, - "bottom-left": { - "doc": "The bottom left corner of the icon is placed closest to the anchor." - }, - "bottom-right": { - "doc": "The bottom right corner of the icon is placed closest to the anchor." - } - }, - "default": "center", - "doc": "Part of the icon placed closest to the anchor.", - "requires": [ - "icon-image" - ], - "sdk-support": { - "basic functionality": { - "js": "0.40.0", - "android": "5.2.0", - "ios": "3.7.0" - }, - "data-driven styling": { - "js": "0.40.0", - "android": "5.2.0", - "ios": "3.7.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom", - "feature" - ] - }, - "property-type": "data-driven" - }, - "icon-pitch-alignment": { - "type": "enum", - "values": { - "map": { - "doc": "The icon is aligned to the plane of the map." - }, - "viewport": { - "doc": "The icon is aligned to the plane of the viewport." - }, - "auto": { - "doc": "Automatically matches the value of `icon-rotation-alignment`." - } - }, - "default": "auto", - "doc": "Orientation of icon when map is pitched.", - "requires": [ - "icon-image" - ], - "sdk-support": { - "basic functionality": { - "js": "0.39.0", - "android": "5.2.0", - "ios": "3.7.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "text-pitch-alignment": { - "type": "enum", - "values": { - "map": { - "doc": "The text is aligned to the plane of the map." - }, - "viewport": { - "doc": "The text is aligned to the plane of the viewport." - }, - "auto": { - "doc": "Automatically matches the value of `text-rotation-alignment`." - } - }, - "default": "auto", - "doc": "Orientation of text when map is pitched.", - "requires": [ - "text-field" - ], - "sdk-support": { - "basic functionality": { - "js": "0.21.0", - "android": "4.2.0", - "ios": "3.4.0" - }, - "`auto` value": { - "js": "0.25.0", - "android": "4.2.0", - "ios": "3.4.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "text-rotation-alignment": { - "type": "enum", - "values": { - "map": { - "doc": "When `symbol-placement` is set to `point`, aligns text east-west. When `symbol-placement` is set to `line` or `line-center`, aligns text x-axes with the line." - }, - "viewport": { - "doc": "Produces glyphs whose x-axes are aligned with the x-axis of the viewport, regardless of the value of `symbol-placement`." - }, - "viewport-glyph": { - "doc": "When `symbol-placement` is set to `point`, aligns text to the x-axis of the viewport. When `symbol-placement` is set to `line` or `line-center`, aligns glyphs to the x-axis of the viewport and places them along the line." - }, - "auto": { - "doc": "When `symbol-placement` is set to `point`, this is equivalent to `viewport`. When `symbol-placement` is set to `line` or `line-center`, this is equivalent to `map`." - } - }, - "default": "auto", - "doc": "In combination with `symbol-placement`, determines the rotation behavior of the individual glyphs forming the text.", - "requires": [ - "text-field" - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "`auto` value": { - "js": "0.25.0", - "android": "4.2.0", - "ios": "3.4.0" - }, - "`viewport-glyph` value": { - "js": "2.1.8", - "android": "https://github.com/maplibre/maplibre-native/issues/250", - "ios": "https://github.com/maplibre/maplibre-native/issues/250" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "text-field": { - "type": "formatted", - "default": "", - "tokens": true, - "doc": "Value to use for a text label. If a plain `string` is provided, it will be treated as a `formatted` with default/inherited formatting options.", - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "0.33.0", - "android": "5.0.0", - "ios": "3.5.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom", - "feature" - ] - }, - "property-type": "data-driven" - }, - "text-font": { - "type": "array", - "value": "string", - "default": [ - "Open Sans Regular", - "Arial Unicode MS Regular" - ], - "doc": "Font stack to use for displaying text.", - "requires": [ - "text-field" - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "0.43.0", - "android": "6.0.0", - "ios": "4.0.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom", - "feature" - ] - }, - "property-type": "data-driven" - }, - "text-size": { - "type": "number", - "default": 16, - "minimum": 0, - "units": "pixels", - "doc": "Font size.", - "requires": [ - "text-field" - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "0.35.0", - "android": "5.1.0", - "ios": "3.6.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature" - ] - }, - "property-type": "data-driven" - }, - "text-max-width": { - "type": "number", - "default": 10, - "minimum": 0, - "units": "ems", - "doc": "The maximum line width for text wrapping.", - "requires": [ - "text-field" - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "0.40.0", - "android": "5.2.0", - "ios": "3.7.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature" - ] - }, - "property-type": "data-driven" - }, - "text-line-height": { - "type": "number", - "default": 1.2, - "units": "ems", - "doc": "Text leading value for multi-line text.", - "requires": [ - "text-field" - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "text-letter-spacing": { - "type": "number", - "default": 0, - "units": "ems", - "doc": "Text tracking amount.", - "requires": [ - "text-field" - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "0.40.0", - "android": "5.2.0", - "ios": "3.7.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature" - ] - }, - "property-type": "data-driven" - }, - "text-justify": { - "type": "enum", - "values": { - "auto": { - "doc": "The text is aligned towards the anchor position." - }, - "left": { - "doc": "The text is aligned to the left." - }, - "center": { - "doc": "The text is centered." - }, - "right": { - "doc": "The text is aligned to the right." - } - }, - "default": "center", - "doc": "Text justification options.", - "requires": [ - "text-field" - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "0.39.0", - "android": "5.2.0", - "ios": "3.7.0" - }, - "auto": { - "js": "0.54.0", - "android": "7.4.0", - "ios": "4.10.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom", - "feature" - ] - }, - "property-type": "data-driven" - }, - "text-radial-offset": { - "type": "number", - "units": "ems", - "default": 0, - "doc": "Radial offset of text, in the direction of the symbol's anchor. Useful in combination with `text-variable-anchor`, which defaults to using the two-dimensional `text-offset` if present.", - "sdk-support": { - "basic functionality": { - "js": "0.54.0", - "android": "7.4.0", - "ios": "4.10.0" - }, - "data-driven styling": { - "js": "0.54.0", - "android": "7.4.0", - "ios": "4.10.0" - } - }, - "requires": [ - "text-field" - ], - "property-type": "data-driven", - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature" - ] - } - }, - "text-variable-anchor": { - "type": "array", - "value": "enum", - "values": { - "center": { - "doc": "The center of the text is placed closest to the anchor." - }, - "left": { - "doc": "The left side of the text is placed closest to the anchor." - }, - "right": { - "doc": "The right side of the text is placed closest to the anchor." - }, - "top": { - "doc": "The top of the text is placed closest to the anchor." - }, - "bottom": { - "doc": "The bottom of the text is placed closest to the anchor." - }, - "top-left": { - "doc": "The top left corner of the text is placed closest to the anchor." - }, - "top-right": { - "doc": "The top right corner of the text is placed closest to the anchor." - }, - "bottom-left": { - "doc": "The bottom left corner of the text is placed closest to the anchor." - }, - "bottom-right": { - "doc": "The bottom right corner of the text is placed closest to the anchor." - } - }, - "requires": [ - "text-field", - { - "symbol-placement": [ - "point" - ] - } - ], - "doc": "To increase the chance of placing high-priority labels on the map, you can provide an array of `text-anchor` locations: the renderer will attempt to place the label at each location, in order, before moving onto the next label. Use `text-justify: auto` to choose justification based on anchor position. To apply an offset, use the `text-radial-offset` or the two-dimensional `text-offset`.", - "sdk-support": { - "basic functionality": { - "js": "0.54.0", - "android": "7.4.0", - "ios": "4.10.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "text-variable-anchor-offset": { - "type": "variableAnchorOffsetCollection", - "requires": [ - "text-field", - { - "symbol-placement": [ - "point" - ] - } - ], - "doc": "To increase the chance of placing high-priority labels on the map, you can provide an array of `text-anchor` locations, each paired with an offset value. The renderer will attempt to place the label at each location, in order, before moving on to the next location+offset. Use `text-justify: auto` to choose justification based on anchor position. \n\n The length of the array must be even, and must alternate between enum and point entries. i.e., each anchor location must be accompanied by a point, and that point defines the offset when the corresponding anchor location is used. Positive offset values indicate right and down, while negative values indicate left and up. Anchor locations may repeat, allowing the renderer to try multiple offsets to try and place a label using the same anchor. \n\n When present, this property takes precedence over `text-anchor`, `text-variable-anchor`, `text-offset`, and `text-radial-offset`. \n\n ```json \n\n { \"text-variable-anchor-offset\": [\"top\", [0, 4], \"left\", [3,0], \"bottom\", [1, 1]] } \n\n ``` \n\n When the renderer chooses the `top` anchor, `[0, 4]` will be used for `text-offset`; the text will be shifted down by 4 ems. \n\n When the renderer chooses the `left` anchor, `[3, 0]` will be used for `text-offset`; the text will be shifted right by 3 ems.", - "sdk-support": { - "basic functionality": { - "js": "3.3.0", - "ios": "https://github.com/maplibre/maplibre-native/issues/2358", - "android": "https://github.com/maplibre/maplibre-native/issues/2358" - }, - "data-driven styling": { - "js": "3.3.0", - "ios": "https://github.com/maplibre/maplibre-native/issues/2358", - "android": "https://github.com/maplibre/maplibre-native/issues/2358" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature" - ] - }, - "property-type": "data-driven" - }, - "text-anchor": { - "type": "enum", - "values": { - "center": { - "doc": "The center of the text is placed closest to the anchor." - }, - "left": { - "doc": "The left side of the text is placed closest to the anchor." - }, - "right": { - "doc": "The right side of the text is placed closest to the anchor." - }, - "top": { - "doc": "The top of the text is placed closest to the anchor." - }, - "bottom": { - "doc": "The bottom of the text is placed closest to the anchor." - }, - "top-left": { - "doc": "The top left corner of the text is placed closest to the anchor." - }, - "top-right": { - "doc": "The top right corner of the text is placed closest to the anchor." - }, - "bottom-left": { - "doc": "The bottom left corner of the text is placed closest to the anchor." - }, - "bottom-right": { - "doc": "The bottom right corner of the text is placed closest to the anchor." - } - }, - "default": "center", - "doc": "Part of the text placed closest to the anchor.", - "requires": [ - "text-field", - { - "!": "text-variable-anchor" - } - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "0.39.0", - "android": "5.2.0", - "ios": "3.7.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom", - "feature" - ] - }, - "property-type": "data-driven" - }, - "text-max-angle": { - "type": "number", - "default": 45, - "units": "degrees", - "doc": "Maximum angle change between adjacent characters.", - "requires": [ - "text-field", - { - "symbol-placement": [ - "line", - "line-center" - ] - } - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "text-writing-mode": { - "type": "array", - "value": "enum", - "values": { - "horizontal": { - "doc": "If a text's language supports horizontal writing mode, symbols with point placement would be laid out horizontally." - }, - "vertical": { - "doc": "If a text's language supports vertical writing mode, symbols with point placement would be laid out vertically." - } - }, - "doc": "The property allows control over a symbol's orientation. Note that the property values act as a hint, so that a symbol whose language doesn’t support the provided orientation will be laid out in its natural orientation. Example: English point symbol will be rendered horizontally even if array value contains single 'vertical' enum value. The order of elements in an array define priority order for the placement of an orientation variant.", - "requires": [ - "text-field", - { - "symbol-placement": [ - "point" - ] - } - ], - "sdk-support": { - "basic functionality": { - "js": "1.3.0", - "android": "8.3.0", - "ios": "5.3.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "text-rotate": { - "type": "number", - "default": 0, - "period": 360, - "units": "degrees", - "doc": "Rotates the text clockwise.", - "requires": [ - "text-field" - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "0.35.0", - "android": "5.1.0", - "ios": "3.6.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature" - ] - }, - "property-type": "data-driven" - }, - "text-padding": { - "type": "number", - "default": 2, - "minimum": 0, - "units": "pixels", - "doc": "Size of the additional area around the text bounding box used for detecting symbol collisions.", - "requires": [ - "text-field" - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "text-keep-upright": { - "type": "boolean", - "default": true, - "doc": "If true, the text may be flipped vertically to prevent it from being rendered upside-down.", - "requires": [ - "text-field", - { - "text-rotation-alignment": "map" - }, - { - "symbol-placement": [ - "line", - "line-center" - ] - } - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "text-transform": { - "type": "enum", - "values": { - "none": { - "doc": "The text is not altered." - }, - "uppercase": { - "doc": "Forces all letters to be displayed in uppercase." - }, - "lowercase": { - "doc": "Forces all letters to be displayed in lowercase." - } - }, - "default": "none", - "doc": "Specifies how to capitalize text, similar to the CSS `text-transform` property.", - "requires": [ - "text-field" - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "0.33.0", - "android": "5.0.0", - "ios": "3.5.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom", - "feature" - ] - }, - "property-type": "data-driven" - }, - "text-offset": { - "type": "array", - "doc": "Offset distance of text from its anchor. Positive values indicate right and down, while negative values indicate left and up. If used with text-variable-anchor, input values will be taken as absolute values. Offsets along the x- and y-axis will be applied automatically based on the anchor position.", - "value": "number", - "units": "ems", - "length": 2, - "default": [ - 0, - 0 - ], - "requires": [ - "text-field", - { - "!": "text-radial-offset" - } - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "0.35.0", - "android": "5.1.0", - "ios": "3.6.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature" - ] - }, - "property-type": "data-driven" - }, - "text-allow-overlap": { - "type": "boolean", - "default": false, - "doc": "If true, the text will be visible even if it collides with other previously drawn symbols.", - "requires": [ - "text-field", - { - "!": "text-overlap" - } - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "text-overlap": { - "type": "enum", - "values": { - "never": { - "doc": "The text will be hidden if it collides with any other previously drawn symbol." - }, - "always": { - "doc": "The text will be visible even if it collides with any other previously drawn symbol." - }, - "cooperative": { - "doc": "If the text collides with another previously drawn symbol, the overlap mode for that symbol is checked. If the previous symbol was placed using `never` overlap mode, the new text is hidden. If the previous symbol was placed using `always` or `cooperative` overlap mode, the new text is visible." - } - }, - "doc": "Allows for control over whether to show symbol text when it overlaps other symbols on the map. If `text-overlap` is not set, `text-allow-overlap` is used instead", - "requires": [ - "text-field" - ], - "sdk-support": { - "basic functionality": { - "js": "2.1.0", - "android": "https://github.com/maplibre/maplibre-native/issues/251", - "ios": "https://github.com/maplibre/maplibre-native/issues/251" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "text-ignore-placement": { - "type": "boolean", - "default": false, - "doc": "If true, other symbols can be visible even if they collide with the text.", - "requires": [ - "text-field" - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "text-optional": { - "type": "boolean", - "default": false, - "doc": "If true, icons will display without their corresponding text when the text collides with other symbols and the icon does not.", - "requires": [ - "text-field", - "icon-image" - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "visibility": { - "type": "enum", - "values": { - "visible": { - "doc": "The layer is shown." - }, - "none": { - "doc": "The layer is not shown." - } - }, - "default": "visible", - "doc": "Whether this layer is displayed.", - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "property-type": "constant" - } - }, - "layout_raster": { - "visibility": { - "type": "enum", - "values": { - "visible": { - "doc": "The layer is shown." - }, - "none": { - "doc": "The layer is not shown." - } - }, - "default": "visible", - "doc": "Whether this layer is displayed.", - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "property-type": "constant" - } - }, - "layout_hillshade": { - "visibility": { - "type": "enum", - "values": { - "visible": { - "doc": "The layer is shown." - }, - "none": { - "doc": "The layer is not shown." - } - }, - "default": "visible", - "doc": "Whether this layer is displayed.", - "sdk-support": { - "basic functionality": { - "js": "0.43.0", - "android": "6.0.0", - "ios": "4.0.0" - } - }, - "property-type": "constant" - } - }, - "filter": { - "type": "array", - "value": "*", - "doc": "A filter selects specific features from a layer." - }, - "filter_operator": { - "type": "enum", - "values": { - "==": { - "doc": "`[\"==\", key, value]` equality: `feature[key] = value`" - }, - "!=": { - "doc": "`[\"!=\", key, value]` inequality: `feature[key] ≠ value`" - }, - ">": { - "doc": "`[\">\", key, value]` greater than: `feature[key] > value`" - }, - ">=": { - "doc": "`[\">=\", key, value]` greater than or equal: `feature[key] ≥ value`" - }, - "<": { - "doc": "`[\"<\", key, value]` less than: `feature[key] < value`" - }, - "<=": { - "doc": "`[\"<=\", key, value]` less than or equal: `feature[key] ≤ value`" - }, - "in": { - "doc": "`[\"in\", key, v0, ..., vn]` set inclusion: `feature[key] ∈ {v0, ..., vn}`" - }, - "!in": { - "doc": "`[\"!in\", key, v0, ..., vn]` set exclusion: `feature[key] ∉ {v0, ..., vn}`" - }, - "all": { - "doc": "`[\"all\", f0, ..., fn]` logical `AND`: `f0 ∧ ... ∧ fn`" - }, - "any": { - "doc": "`[\"any\", f0, ..., fn]` logical `OR`: `f0 ∨ ... ∨ fn`" - }, - "none": { - "doc": "`[\"none\", f0, ..., fn]` logical `NOR`: `¬f0 ∧ ... ∧ ¬fn`" - }, - "has": { - "doc": "`[\"has\", key]` `feature[key]` exists" - }, - "!has": { - "doc": "`[\"!has\", key]` `feature[key]` does not exist" - } - }, - "doc": "The filter operator." - }, - "geometry_type": { - "type": "enum", - "values": { - "Point": { - "doc": "Filter to point geometries." - }, - "LineString": { - "doc": "Filter to line geometries." - }, - "Polygon": { - "doc": "Filter to polygon geometries." - } - }, - "doc": "The geometry type for the filter to select." - }, - "function": { - "expression": { - "type": "expression", - "doc": "An expression." - }, - "stops": { - "type": "array", - "doc": "An array of stops.", - "value": "function_stop" - }, - "base": { - "type": "number", - "default": 1, - "minimum": 0, - "doc": "The exponential base of the interpolation curve. It controls the rate at which the result increases. Higher values make the result increase more towards the high end of the range. With `1` the stops are interpolated linearly." - }, - "property": { - "type": "string", - "doc": "The name of a feature property to use as the function input.", - "default": "$zoom" - }, - "type": { - "type": "enum", - "values": { - "identity": { - "doc": "Return the input value as the output value." - }, - "exponential": { - "doc": "Generate an output by interpolating between stops just less than and just greater than the function input." - }, - "interval": { - "doc": "Return the output value of the stop just less than the function input." - }, - "categorical": { - "doc": "Return the output value of the stop equal to the function input." - } - }, - "doc": "The interpolation strategy to use in function evaluation.", - "default": "exponential" - }, - "colorSpace": { - "type": "enum", - "values": { - "rgb": { - "doc": "Use the RGB color space to interpolate color values" - }, - "lab": { - "doc": "Use the LAB color space to interpolate color values." - }, - "hcl": { - "doc": "Use the HCL color space to interpolate color values, interpolating the Hue, Chroma, and Luminance channels individually." - } - }, - "doc": "The color space in which colors interpolated. Interpolating colors in perceptual color spaces like LAB and HCL tend to produce color ramps that look more consistent and produce colors that can be differentiated more easily than those interpolated in RGB space.", - "default": "rgb" - }, - "default": { - "type": "*", - "required": false, - "doc": "A value to serve as a fallback function result when a value isn't otherwise available. It is used in the following circumstances:\n\n* In categorical functions, when the feature value does not match any of the stop domain values.\n\n* In property and zoom-and-property functions, when a feature does not contain a value for the specified property.\n\n* In identity functions, when the feature value is not valid for the style property (for example, if the function is being used for a `circle-color` property but the feature property value is not a string or not a valid color).\n\n* In interval or exponential property and zoom-and-property functions, when the feature value is not numeric.\n\nIf no default is provided, the style property's default is used in these circumstances." - } - }, - "function_stop": { - "type": "array", - "minimum": 0, - "maximum": 24, - "value": [ - "number", - "color" - ], - "length": 2, - "doc": "Zoom level and value pair." - }, - "expression": { - "type": "array", - "value": "*", - "minimum": 1, - "doc": "An expression defines a function that can be used for data-driven style properties or feature filters." - }, - "expression_name": { - "doc": "", - "type": "enum", - "values": { - "let": { - "doc": "Binds expressions to named variables, which can then be referenced in the result expression using `[\"var\", \"variable_name\"]`.\n\n - [Visualize population density](https://maplibre.org/maplibre-gl-js/docs/examples/visualize-population-density/)", - "example": { - "syntax": { - "method": ["string", "value", "expression"], - "result": "value" - }, - "value": ["let", "someNumber", 500, ["interpolate", ["linear"], ["var", "someNumber"], 274, "#edf8e9", 1551, "#006d2c"]] - }, - "group": "Variable binding", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "var": { - "doc": "References variable bound using `let`.\n\n - [Visualize population density](https://maplibre.org/maplibre-gl-js/docs/examples/visualize-population-density/)", - "example": { - "syntax": { - "method": ["string"], - "result": "value" - }, - "value": ["var", "density"] - }, - "group": "Variable binding", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "literal": { - "doc": "Provides a literal array or object value.\n\n - [Display and style rich text labels](https://maplibre.org/maplibre-gl-js/docs/examples/display-and-style-rich-text-labels/)", - "example": { - "syntax": { - "method": ["JSON object or array"], - "result": "array | object" - }, - "value": ["literal",["DIN Offc Pro Italic", "Arial Unicode MS Regular"]] - }, - "group": "Types", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "array": { - "doc": "Asserts that the input is an array (optionally with a specific item type and length). If, when the input expression is evaluated, it is not of the asserted type, then this assertion will cause the whole expression to be aborted.", - "example": { - "syntax": { - "method": ["value", "string?", "number?"], - "result": "array" - }, - "value": ["array", ["literal", ["a", "b", "c"]], "string", 3] - }, - "group": "Types", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "at": { - "doc": "Retrieves an item from an array.", - "example": { - "syntax": { - "method": ["number", "value"], - "result": "value" - }, - "value": ["at", 1, ["literal", ["a", "b", "c"]]] - }, - "group": "Lookup", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "in": { - "doc": "Determines whether an item exists in an array or a substring exists in a string.\n\n - [Measure distances](https://maplibre.org/maplibre-gl-js/docs/examples/measure/)", - "example": { - "syntax": { - "method": ["value", "value"], - "result": "boolean" - }, - "value": ["in", "$type", "Point"] - }, - "group": "Lookup", - "sdk-support": { - "basic functionality": { - "js": "1.6.0", - "android": "9.1.0", - "ios": "5.8.0" - } - } - }, - "index-of": { - "doc": "Returns the first position at which an item can be found in an array or a substring can be found in a string, or `-1` if the input cannot be found. Accepts an optional index from where to begin the search. In a string, a UTF-16 surrogate pair counts as a single position.", - "example": { - "syntax": { - "method": ["value", "value", "number?"], - "result": "number" - }, - "value": ["index-of", "foo", ["baz", "bar", "hello", "foo", "world"]] - }, - "group": "Lookup", - "sdk-support": { - "basic functionality": { - "js": "1.10.0", - "android": "10.3.0", - "ios": "6.0.0" - } - } - }, - "slice": { - "doc": "Returns an item from an array or a substring from a string from a specified start index, or between a start index and an end index if set. The return value is inclusive of the start index but not of the end index. In a string, a UTF-16 surrogate pair counts as a single position.", - "example": { - "syntax": { - "method": ["value", "number", "number?"], - "result": "value" - }, - "value": ["slice", ["get", "name"], 0, 3] - }, - "group": "Lookup", - "sdk-support": { - "basic functionality": { - "js": "1.10.0", - "android": "10.3.0", - "ios": "6.0.0" - } - } - }, - "case": { - "doc": "Selects the first output whose corresponding test condition evaluates to true, or the fallback value otherwise.\n\n - [Create a hover effect](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/)\n\n - [Display HTML clusters with custom properties](https://maplibre.org/maplibre-gl-js/docs/examples/cluster-html/)", - "example": { - "syntax": { - "method": ["value", "value", "...", "fallback: value"], - "result": "value" - }, - "value": ["case", ["boolean", ["feature-state", "hover"], false], 1, 0.5 ] - }, - "group": "Decision", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "match": { - "doc": "Selects the output whose label value matches the input value, or the fallback value if no match is found. The input can be any expression (e.g. `[\"get\", \"building_type\"]`). Each label must be either:\n\n - a single literal value; or\n\n - an array of literal values, whose values must be all strings or all numbers (e.g. `[100, 101]` or `[\"c\", \"b\"]`). The input matches if any of the values in the array matches, similar to the `\"in\"` operator.\n\nEach label must be unique. If the input type does not match the type of the labels, the result will be the fallback value.", - "example": { - "syntax": { - "method": ["value", "value", "...", "fallback: value"], - "result": "value" - }, - "value": ["match", ["get", "building_type"], "residential", "#f00", "commercial", "#0f0", "#000"] - }, - "group": "Decision", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "coalesce": { - "doc": "Evaluates each expression in turn until the first non-null value is obtained, and returns that value.\n\n - [Use a fallback image](https://maplibre.org/maplibre-gl-js/docs/examples/fallback-image/)", - "example": { - "syntax": { - "method": ["coalesce", "value", "fallback"], - "result": "value" - }, - "value": ["coalesce", ["image", ["concat", ["get", "icon"], "_15"]], ["image", "marker_15"] ] - }, - "group": "Decision", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "step": { - "doc": "Produces discrete, stepped results by evaluating a piecewise-constant function defined by pairs of input and output values (\"stops\"). The `input` may be any numeric expression (e.g., `[\"get\", \"population\"]`). Stop inputs must be numeric literals in strictly ascending order. Returns the output value of the stop just less than the input, or the first output if the input is less than the first stop.\n\n - [Create and style clusters](https://maplibre.org/maplibre-gl-js/docs/examples/cluster/)", - "example": { - "syntax": { - "method": ["step", "number", "number", "number", "..."], - "result": "number" - }, - "value": [ "step", ["get", "point_count"], 20, 100, 30, 750, 40] - }, - "group": "Ramps, scales, curves", - "sdk-support": { - "basic functionality": { - "js": "0.42.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "interpolate": { - "doc": "Produces continuous, smooth results by interpolating between pairs of input and output values (\"stops\"). The `input` may be any numeric expression (e.g., `[\"get\", \"population\"]`). Stop inputs must be numeric literals in strictly ascending order. The output type must be `number`, `array`, or `color`.\n\nInterpolation types:\n\n- `[\"linear\"]`, or an expression returning one of those types: Interpolates linearly between the pair of stops just less than and just greater than the input.\n\n- `[\"exponential\", base]`: Interpolates exponentially between the stops just less than and just greater than the input. `base` controls the rate at which the output increases: higher values make the output increase more towards the high end of the range. With values close to 1 the output increases linearly.\n\n- `[\"cubic-bezier\", x1, y1, x2, y2]`: Interpolates using the cubic bezier curve defined by the given control points.\n\n - [Animate map camera around a point](https://maplibre.org/maplibre-gl-js/docs/examples/animate-camera-around-point/)\n\n - [Change building color based on zoom level](https://maplibre.org/maplibre-gl-js/docs/examples/change-building-color-based-on-zoom-level/)\n\n - [Create a heatmap layer](https://maplibre.org/maplibre-gl-js/docs/examples/heatmap-layer/)\n\n - [Visualize population density](https://maplibre.org/maplibre-gl-js/docs/examples/visualize-population-density/)", - "example": { - "syntax": { - "method": ["[\"linear\"] | [\"exponential\", base] | [\"cubic-bezier\", x1, y1, x2, y2]", "number", "number", "number", "..."], - "result": "number | array | color" - }, - "value": ["interpolate", ["linear"], ["zoom"], 15, 0, 15.05, ["get", "height"]] - }, - "group": "Ramps, scales, curves", - "sdk-support": { - "basic functionality": { - "js": "0.42.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "interpolate-hcl": { - "doc": "Produces continuous, smooth results by interpolating between pairs of input and output values (\"stops\"). Works like `interpolate`, but the output type must be `color`, and the interpolation is performed in the Hue-Chroma-Luminance color space.", - "example": { - "syntax": { - "method": ["[\"linear\"] | [\"exponential\", base] | [\"cubic-bezier\", x1, y1, x2, y2]", "number", "number", "number", "..."], - "result": "color" - }, - "value": ["interpolate-hcl", ["linear"], ["zoom"], 15, "#f00", 15.05, "#00f"] - }, - "group": "Ramps, scales, curves", - "sdk-support": { - "basic functionality": { - "js": "0.49.0", - "ios": "https://github.com/maplibre/maplibre-native/issues/2784", - "android": "https://github.com/maplibre/maplibre-native/issues/2784" - } - } - }, - "interpolate-lab": { - "doc": "Produces continuous, smooth results by interpolating between pairs of input and output values (\"stops\"). Works like `interpolate`, but the output type must be `color`, and the interpolation is performed in the CIELAB color space.", - "example": { - "syntax": { - "method": ["[\"linear\"] | [\"exponential\", base] | [\"cubic-bezier\", x1, y1, x2, y2]", "number", "number", "number", "..."], - "result": "color" - }, - "value": ["interpolate-lab", ["linear"], ["zoom"], 15, "#f00", 15.05, "#00f"] - }, - "group": "Ramps, scales, curves", - "sdk-support": { - "basic functionality": { - "js": "0.49.0", - "ios": "https://github.com/maplibre/maplibre-native/issues/2784", - "android": "https://github.com/maplibre/maplibre-native/issues/2784" - } - } - }, - "ln2": { - "doc": "Returns mathematical constant ln(2).", - "example": { - "syntax": { - "method": [], - "result": "number" - }, - "value": ["ln2"] - }, - "group": "Math", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "pi": { - "doc": "Returns the mathematical constant pi.", - "example": { - "syntax": { - "method": [], - "result": "number" - }, - "value": ["pi"] - }, - "group": "Math", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "e": { - "doc": "Returns the mathematical constant e.", - "example": { - "syntax": { - "method": [], - "result": "number" - }, - "value": ["e"] - }, - "group": "Math", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "typeof": { - "doc": "Returns a string describing the type of the given value.", - "example": { - "syntax": { - "method": ["value"], - "result": "string" - }, - "value": ["typeof", ["get", "name"]] - }, - "group": "Types", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "string": { - "doc": "Asserts that the input value is a string. If multiple values are provided, each one is evaluated in order until a string is obtained. If none of the inputs are strings, the expression is an error.", - "example": { - "syntax": { - "method": ["value", "fallback: value", "fallback: value", "..."], - "result": "string" - }, - "value": ["string", ["get", "name"]] - }, - "group": "Types", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "number": { - "doc": "Asserts that the input value is a number. If multiple values are provided, each one is evaluated in order until a number is obtained. If none of the inputs are numbers, the expression is an error.", - "example": { - "syntax": { - "method": ["value", "fallback: value", "fallback: value", "..."], - "result": "number" - }, - "value": ["number", ["get", "population"]] - }, - "group": "Types", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "boolean": { - "doc": "Asserts that the input value is a boolean. If multiple values are provided, each one is evaluated in order until a boolean is obtained. If none of the inputs are booleans, the expression is an error.\n\n - [Create a hover effect](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/)", - "example": { - "syntax": { - "method": ["value", "fallback: value", "fallback: value", "..."], - "result": "boolean" - }, - "value": ["boolean", ["feature-state", "hover"], false] - }, - "group": "Types", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "object": { - "doc": "Asserts that the input value is an object. If multiple values are provided, each one is evaluated in order until an object is obtained. If none of the inputs are objects, the expression is an error.", - "example": { - "syntax": { - "method": ["value", "fallback: value", "fallback: value", "..."], - "result": "object" - }, - "value": ["object", ["get", "some-property"]] - }, - "group": "Types", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "collator": { - "doc": "Returns a `collator` for use in locale-dependent comparison operations. The `case-sensitive` and `diacritic-sensitive` options default to `false`. The `locale` argument specifies the IETF language tag of the locale to use. If none is provided, the default locale is used. If the requested locale is not available, the `collator` will use a system-defined fallback locale. Use `resolved-locale` to test the results of locale fallback behavior.", - "example": { - "syntax": { - "method": ["collator", "{ \"case-sensitive\": boolean, \"diacritic-sensitive\": boolean, \"locale\": string }"], - "result": "collator" - }, - "value": ["collator", {"case-sensitive": true, "diacritic-sensitive": true, "locale": "fr"}] - }, - "group": "Types", - "sdk-support": { - "basic functionality": { - "js": "0.45.0", - "android": "6.5.0", - "ios": "4.2.0" - } - } - }, - "format": { - "doc": "Returns a `formatted` string for displaying mixed-format text in the `text-field` property. The input may contain a string literal or expression, including an [`'image'`](#image) expression. Strings may be followed by a style override object that supports the following properties:\n\n- `\"text-font\"`: Overrides the font stack specified by the root layout property.\n\n- `\"text-color\"`: Overrides the color specified by the root paint property.\n\n- `\"font-scale\"`: Applies a scaling factor on `text-size` as specified by the root layout property.\n\n - [Change the case of labels](https://maplibre.org/maplibre-gl-js/docs/examples/change-case-of-labels/)\n\n - [Display and style rich text labels](https://maplibre.org/maplibre-gl-js/docs/examples/display-and-style-rich-text-labels/)", - "example": { - "syntax": { - "method": ["value", "{ \"text-font\": string, \"text-color\": color, \"font-scale\": number }", "..."], - "result": "formatted" - }, - "value": ["format", ["upcase", ["get", "FacilityName"]], {"font-scale": 0.8}, "\n\n", {}, ["downcase", ["get", "Comments"]], {"font-scale": 0.6}] - }, - "group": "Types", - "sdk-support": { - "basic functionality": { - "js": "0.48.0", - "android": "6.7.0", - "ios": "4.6.0" - }, - "text-font": { - "js": "0.48.0", - "android": "6.7.0", - "ios": "4.6.0" - }, - "font-scale": { - "js": "0.48.0", - "android": "6.7.0", - "ios": "4.6.0" - }, - "text-color": { - "js": "1.3.0", - "android": "7.3.0", - "ios": "4.10.0" - }, - "image": { - "js": "1.6.0", - "android": "8.6.0", - "ios": "5.7.0" - } - } - }, - "image": { - "doc": "Returns an `image` type for use in `icon-image`, `*-pattern` entries and as a section in the `format` expression. If set, the `image` argument will check that the requested image exists in the style and will return either the resolved image name or `null`, depending on whether or not the image is currently in the style. This validation process is synchronous and requires the image to have been added to the style before requesting it in the `image` argument.\n\n - [Use a fallback image](https://maplibre.org/maplibre-gl-js/docs/examples/fallback-image/)", - "example": { - "syntax": { - "method": ["value"], - "result": "image" - }, - "value": ["image", "marker_15"] - }, - "group": "Types", - "sdk-support": { - "basic functionality": { - "js": "1.4.0", - "android": "8.6.0", - "ios": "5.7.0" - } - } - }, - "number-format": { - "doc": "Converts the input number into a string representation using the providing formatting rules. If set, the `locale` argument specifies the locale to use, as a BCP 47 language tag. If set, the `currency` argument specifies an ISO 4217 code to use for currency-style formatting. If set, the `min-fraction-digits` and `max-fraction-digits` arguments specify the minimum and maximum number of fractional digits to include.\n\n - [Display HTML clusters with custom properties](https://maplibre.org/maplibre-gl-js/docs/examples/cluster-html/)", - "example": { - "syntax": { - "method": ["number", "{ \"locale\": string, \"currency\": string, \"min-fraction-digits\": number, \"max-fraction-digits\": number }"], - "result": "string" - }, - "value": ["number-format", ["get", "mag"], {"min-fraction-digits": 1, "max-fraction-digits": 1}] - }, - "group": "Types", - "sdk-support": { - "basic functionality": { - "js": "0.54.0", - "android": "8.4.0", - "ios": "supported" - } - } - }, - "to-string": { - "doc": "Converts the input value to a string. If the input is `null`, the result is `\"\"`. If the input is a boolean, the result is `\"true\"` or `\"false\"`. If the input is a number, it is converted to a string as specified by the [\"NumberToString\" algorithm](https://tc39.github.io/ecma262/#sec-tostring-applied-to-the-number-type) of the ECMAScript Language Specification. If the input is a color, it is converted to a string of the form `\"rgba(r,g,b,a)\"`, where `r`, `g`, and `b` are numerals ranging from 0 to 255, and `a` ranges from 0 to 1. Otherwise, the input is converted to a string in the format specified by the [`JSON.stringify`](https://tc39.github.io/ecma262/#sec-json.stringify) function of the ECMAScript Language Specification.\n\n - [Create a time slider](https://maplibre.org/maplibre-gl-js/docs/examples/timeline-animation/)", - "example": { - "syntax": { - "method": ["value"], - "result": "string" - }, - "value": ["to-string", ["get", "mag"]] - }, - "group": "Types", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "to-number": { - "doc": "Converts the input value to a number, if possible. If the input is `null` or `false`, the result is 0. If the input is `true`, the result is 1. If the input is a string, it is converted to a number as specified by the [\"ToNumber Applied to the String Type\" algorithm](https://tc39.github.io/ecma262/#sec-tonumber-applied-to-the-string-type) of the ECMAScript Language Specification. If multiple values are provided, each one is evaluated in order until the first successful conversion is obtained. If none of the inputs can be converted, the expression is an error.", - "example": { - "syntax": { - "method": ["value", "fallback: value", "fallback: value", "..."], - "result": "number" - }, - "value": ["to-number", "someProperty"] - }, - "group": "Types", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "to-boolean": { - "doc": "Converts the input value to a boolean. The result is `false` when then input is an empty string, 0, `false`, `null`, or `NaN`; otherwise it is `true`.", - "example": { - "syntax": { - "method": ["value"], - "result": "boolean" - }, - "value": ["to-boolean", "someProperty"] - }, - "group": "Types", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "to-rgba": { - "doc": "Returns a four-element array containing the input color's red, green, blue, and alpha components, in that order.", - "example": { - "syntax": { - "method": ["color"], - "result": "array" - }, - "value": ["to-rgba", "#ff0000"] - }, - "group": "Color", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "to-color": { - "doc": "Converts the input value to a color. If multiple values are provided, each one is evaluated in order until the first successful conversion is obtained. If none of the inputs can be converted, the expression is an error.\n\n - [Visualize population density](https://maplibre.org/maplibre-gl-js/docs/examples/visualize-population-density/)", - "example": { - "syntax": { - "method": ["value", "fallback: value", "fallback: value", "..."], - "result": "color" - }, - "value": ["to-color", "#edf8e9"] - }, - "group": "Types", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "rgb": { - "doc": "Creates a color value from red, green, and blue components, which must range between 0 and 255, and an alpha component of 1. If any component is out of range, the expression is an error.", - "example": { - "syntax": { - "method": ["number", "number", "number"], - "result": "color" - }, - "value": ["rgb", 255, 0, 0] - }, - "group": "Color", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "rgba": { - "doc": "Creates a color value from red, green, blue components, which must range between 0 and 255, and an alpha component which must range between 0 and 1. If any component is out of range, the expression is an error.", - "example": { - "syntax": { - "method": ["number", "number", "number", "number"], - "result": "color" - }, - "value": ["rgba", 255, 0, 0, 1] - }, - "group": "Color", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "get": { - "doc": "Retrieves a property value from the current feature's properties, or from another object if a second argument is provided. Returns null if the requested property is missing.\n\n - [Change the case of labels](https://maplibre.org/maplibre-gl-js/docs/examples/change-case-of-labels/)\n\n - [Display HTML clusters with custom properties](https://maplibre.org/maplibre-gl-js/docs/examples/cluster-html/)\n\n - [Extrude polygons for 3D indoor mapping](https://maplibre.org/maplibre-gl-js/docs/examples/3d-extrusion-floorplan/)", - "example": { - "syntax": { - "method": ["string"], - "result": "value" - }, - "value": ["get", "someProperty"] - }, - "group": "Lookup", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "has": { - "doc": "Tests for the presence of an property value in the current feature's properties, or from another object if a second argument is provided.\n\n - [Create and style clusters](https://maplibre.org/maplibre-gl-js/docs/examples/cluster/)", - "example": { - "syntax": { - "method": ["string"], - "result": "boolean" - }, - "value": ["has", "someProperty"] - }, - "group": "Lookup", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "length": { - "doc": "Gets the length of an array or string. In a string, a UTF-16 surrogate pair counts as a single position.", - "example": { - "syntax": { - "method": ["array"], - "result": "number" - }, - "value": ["length", ["get", "myArray"]] - }, - "group": "Lookup", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "properties": { - "doc": "Gets the feature properties object. Note that in some cases, it may be more efficient to use [\"get\", \"property_name\"] directly.", - "example": { - "syntax": { - "method": [], - "result": "value" - }, - "value": ["properties"] - }, - "group": "Feature data", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "feature-state": { - "doc": "Retrieves a property value from the current feature's state. Returns null if the requested property is not present on the feature's state. A feature's state is not part of the GeoJSON or vector tile data, and must be set programmatically on each feature. When `source.promoteId` is not provided, features are identified by their `id` attribute, which must be an integer or a string that can be cast to an integer. When `source.promoteId` is provided, features are identified by their `promoteId` property, which may be a number, string, or any primitive data type. Note that [\"feature-state\"] can only be used with paint properties that support data-driven styling.\n\n - [Create a hover effect](https://maplibre.org/maplibre-gl-js/docs/examples/hover-styles/)", - "example": { - "syntax": { - "method": ["string"], - "result": "value" - }, - "value": ["feature-state", "hover"] - }, - "group": "Feature data", - "sdk-support": { - "basic functionality": { - "js": "0.46.0", - "ios": "https://github.com/maplibre/maplibre-native/issues/1698", - "android": "https://github.com/maplibre/maplibre-native/issues/1698" - } - } - }, - "geometry-type": { - "doc": "Gets the feature's geometry type: `Point`, `MultiPoint`, `LineString`, `MultiLineString`, `Polygon`, `MultiPolygon`.", - "example": { - "syntax": { - "method": [], - "result": "string" - }, - "value": ["==", ["geometry-type"], "Polygon"] - }, - "group": "Feature data", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "id": { - "doc": "Gets the feature's id, if it has one.", - "example": { - "syntax": { - "method": [], - "result": "value" - }, - "value": ["id"] - }, - "group": "Feature data", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "zoom": { - "doc": "Gets the current zoom level. Note that in style layout and paint properties, [\"zoom\"] may only appear as the input to a top-level \"step\" or \"interpolate\" expression.", - "example": { - "syntax": { - "method": [], - "result": "number" - }, - "value": ["interpolate",["linear"],["zoom"],15,0,15.05,["get","height"]] - }, - "group": "Zoom", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "heatmap-density": { - "doc": "Gets the kernel density estimation of a pixel in a heatmap layer, which is a relative measure of how many data points are crowded around a particular pixel. Can only be used in the `heatmap-color` property.", - "example": { - "syntax": { - "method": [], - "result": "number" - }, - "value": ["heatmap-density"] - }, - "group": "Heatmap", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "line-progress": { - "doc": "Gets the progress along a gradient line. Can only be used in the `line-gradient` property.", - "example": { - "syntax": { - "method": ["number"], - "result": "number" - }, - "value": ["line-progress", 0.5] - }, - "group": "Feature data", - "sdk-support": { - "basic functionality": { - "js": "0.45.0", - "android": "6.5.0", - "ios": "4.6.0" - } - } - }, - "accumulated": { - "doc": "Gets the value of a cluster property accumulated so far. Can only be used in the `clusterProperties` option of a clustered GeoJSON source.", - "example": { - "syntax": { - "method": ["string"], - "result": "value" - }, - "value": ["accumulated", "sum"] - }, - "group": "Feature data", - "sdk-support": { - "basic functionality": { - "js": "0.53.0", - "ios": "supported", - "android": "supported" - } - } - }, - "+": { - "doc": "Returns the sum of the inputs.", - "example": { - "syntax": { - "method": ["number", "number", "..."], - "result": "number" - }, - "value": ["+", 2, 3] - }, - "group": "Math", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "*": { - "doc": "Returns the product of the inputs.", - "example": { - "syntax": { - "method": ["number", "number", "..."], - "result": "number" - }, - "value": ["*", 2, 3] - }, - "group": "Math", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "-": { - "doc": "For two inputs, returns the result of subtracting the second input from the first. For a single input, returns the result of subtracting it from 0.", - "example": { - "syntax": { - "method": ["number", "number?"], - "result": "number" - }, - "value": ["-", 10] - }, - "group": "Math", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "/": { - "doc": "Returns the result of floating point division of the first input by the second.\n\n - [Visualize population density](https://maplibre.org/maplibre-gl-js/docs/examples/visualize-population-density/)", - "example": { - "syntax": { - "method": ["number", "number"], - "result": "number" - }, - "value": ["/", ["get", "population"], ["get", "sq-km"]] - }, - "group": "Math", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "%": { - "doc": "Returns the remainder after integer division of the first input by the second.", - "example": { - "syntax": { - "method": ["number", "number"], - "result": "number" - }, - "value": ["%", 10, 3] - }, - "group": "Math", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "^": { - "doc": "Returns the result of raising the first input to the power specified by the second.", - "example": { - "syntax": { - "method": ["number", "number"], - "result": "number" - }, - "value": ["^", 2, 3] - }, - "group": "Math", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "sqrt": { - "doc": "Returns the square root of the input.", - "example": { - "syntax": { - "method": ["number"], - "result": "number" - }, - "value": ["sqrt", 9] - }, - "group": "Math", - "sdk-support": { - "basic functionality": { - "js": "0.42.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "log10": { - "doc": "Returns the base-ten logarithm of the input.", - "example": { - "syntax": { - "method": ["number"], - "result": "number" - }, - "value": ["log10", 8] - }, - "group": "Math", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "ln": { - "doc": "Returns the natural logarithm of the input.", - "example": { - "syntax": { - "method": ["number"], - "result": "number" - }, - "value": ["ln", 8] - }, - "group": "Math", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "log2": { - "doc": "Returns the base-two logarithm of the input.", - "example": { - "syntax": { - "method": ["number"], - "result": "number" - }, - "value": ["log2", 8] - }, - "group": "Math", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "sin": { - "doc": "Returns the sine of the input.", - "example": { - "syntax": { - "method": ["number"], - "result": "number" - }, - "value": ["sin", 1] - }, - "group": "Math", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "cos": { - "doc": "Returns the cosine of the input.", - "example": { - "syntax": { - "method": ["number"], - "result": "number" - }, - "value": ["cos", 1] - }, - "group": "Math", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "tan": { - "doc": "Returns the tangent of the input.", - "example": { - "syntax": { - "method": ["number"], - "result": "number" - }, - "value": ["tan", 1] - }, - "group": "Math", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "asin": { - "doc": "Returns the arcsine of the input.", - "example": { - "syntax": { - "method": ["number"], - "result": "number" - }, - "value": ["asin", 1] - }, - "group": "Math", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "acos": { - "doc": "Returns the arccosine of the input.", - "example": { - "syntax": { - "method": ["number"], - "result": "number" - }, - "value": ["acos", 1] - }, - "group": "Math", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "atan": { - "doc": "Returns the arctangent of the input.", - "example": { - "syntax": { - "method": ["number"], - "result": "number" - }, - "value": ["atan", 1] - }, - "group": "Math", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "min": { - "doc": "Returns the minimum value of the inputs.", - "example": { - "syntax": { - "method": ["number", "number", "..."], - "result": "number" - }, - "value": ["min", 1, 2] - }, - "group": "Math", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "max": { - "doc": "Returns the maximum value of the inputs.", - "example": { - "syntax": { - "method": ["number", "number", "..."], - "result": "number" - }, - "value": ["max", 1, 2] - }, - "group": "Math", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "round": { - "doc": "Rounds the input to the nearest integer. Halfway values are rounded away from zero. For example, `[\"round\", -1.5]` evaluates to -2.", - "example": { - "syntax": { - "method": ["number"], - "result": "number" - }, - "value": ["round", 1.5] - }, - "group": "Math", - "sdk-support": { - "basic functionality": { - "js": "0.45.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "abs": { - "doc": "Returns the absolute value of the input.", - "example": { - "syntax": { - "method": ["number"], - "result": "number" - }, - "value": ["abs", -1.5] - }, - "group": "Math", - "sdk-support": { - "basic functionality": { - "js": "0.45.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "ceil": { - "doc": "Returns the smallest integer that is greater than or equal to the input.", - "example": { - "syntax": { - "method": ["number"], - "result": "number" - }, - "value": ["ceil", 1.5] - }, - "group": "Math", - "sdk-support": { - "basic functionality": { - "js": "0.45.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "floor": { - "doc": "Returns the largest integer that is less than or equal to the input.", - "example": { - "syntax": { - "method": ["number"], - "result": "number" - }, - "value": ["floor", 1.5] - }, - "group": "Math", - "sdk-support": { - "basic functionality": { - "js": "0.45.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "distance": { - "doc": "Returns the shortest distance in meters between the evaluated feature and the input geometry. The input value can be a valid GeoJSON of type `Point`, `MultiPoint`, `LineString`, `MultiLineString`, `Polygon`, `MultiPolygon`, `Feature`, or `FeatureCollection`. Distance values returned may vary in precision due to loss in precision from encoding geometries, particularly below zoom level 13.", - "example": { - "syntax": { - "method": ["GeoJSON geometry"], - "result": "number" - }, - "value": ["distance", { "type": "Point", "coordinates": [0, 0]}] - }, - "group": "Math", - "sdk-support": { - "basic functionality": { - "js": "4.2.0", - "android": "9.2.0", - "ios": "5.9.0" - } - } - }, - "==": { - "doc": "Returns `true` if the input values are equal, `false` otherwise. The comparison is strictly typed: values of different runtime types are always considered unequal. Cases where the types are known to be different at parse time are considered invalid and will produce a parse error. Accepts an optional `collator` argument to control locale-dependent string comparisons.\n\n - [Add multiple geometries from one GeoJSON source](https://maplibre.org/maplibre-gl-js/docs/examples/multiple-geometries/)\n\n - [Create a time slider](https://maplibre.org/maplibre-gl-js/docs/examples/timeline-animation/)\n\n - [Display buildings in 3D](https://maplibre.org/maplibre-gl-js/docs/examples/3d-buildings/)\n\n - [Filter symbols by toggling a list](https://maplibre.org/maplibre-gl-js/docs/examples/filter-markers/)", - "example": { - "syntax": { - "method": ["value", "value", "collator?"], - "result": "boolean" - }, - "value": ["==", "$type", "Polygon"] - }, - "group": "Decision", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - }, - "collator": { - "js": "0.45.0", - "android": "6.5.0", - "ios": "4.2.0" - } - } - }, - "!=": { - "doc": "Returns `true` if the input values are not equal, `false` otherwise. The comparison is strictly typed: values of different runtime types are always considered unequal. Cases where the types are known to be different at parse time are considered invalid and will produce a parse error. Accepts an optional `collator` argument to control locale-dependent string comparisons.\n\n - [Display HTML clusters with custom properties](https://maplibre.org/maplibre-gl-js/docs/examples/cluster-html/)", - "example": { - "syntax": { - "method": ["value", "value", "collator?"], - "result": "boolean" - }, - "value": ["!=", "cluster", true] - }, - "group": "Decision", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - }, - "collator": { - "js": "0.45.0", - "android": "6.5.0", - "ios": "4.2.0" - } - } - }, - ">": { - "doc": "Returns `true` if the first input is strictly greater than the second, `false` otherwise. The arguments are required to be either both strings or both numbers; if during evaluation they are not, expression evaluation produces an error. Cases where this constraint is known not to hold at parse time are considered in valid and will produce a parse error. Accepts an optional `collator` argument to control locale-dependent string comparisons.", - "example": { - "syntax": { - "method": ["value", "value", "collator?"], - "result": "boolean" - }, - "value": [">", ["get", "mag"], 2] - }, - "group": "Decision", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - }, - "collator": { - "js": "0.45.0", - "android": "6.5.0", - "ios": "4.2.0" - } - } - }, - "<": { - "doc": "Returns `true` if the first input is strictly less than the second, `false` otherwise. The arguments are required to be either both strings or both numbers; if during evaluation they are not, expression evaluation produces an error. Cases where this constraint is known not to hold at parse time are considered in valid and will produce a parse error. Accepts an optional `collator` argument to control locale-dependent string comparisons.\n\n - [Display HTML clusters with custom properties](https://maplibre.org/maplibre-gl-js/docs/examples/cluster-html/)", - "example": { - "syntax": { - "method": ["value", "value", "collator?"], - "result": "boolean" - }, - "value": ["<", ["get", "mag"], 2] - }, - "group": "Decision", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - }, - "collator": { - "js": "0.45.0", - "android": "6.5.0", - "ios": "4.2.0" - } - } - }, - ">=": { - "doc": "Returns `true` if the first input is greater than or equal to the second, `false` otherwise. The arguments are required to be either both strings or both numbers; if during evaluation they are not, expression evaluation produces an error. Cases where this constraint is known not to hold at parse time are considered in valid and will produce a parse error. Accepts an optional `collator` argument to control locale-dependent string comparisons.\n\n - [Display HTML clusters with custom properties](https://maplibre.org/maplibre-gl-js/docs/examples/cluster-html/)", - "example": { - "syntax": { - "method": ["value", "value", "collator?"], - "result": "boolean" - }, - "value": [">=", ["get", "mag"], 6] - }, - "group": "Decision", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - }, - "collator": { - "js": "0.45.0", - "android": "6.5.0", - "ios": "4.2.0" - } - } - }, - "<=": { - "doc": "Returns `true` if the first input is less than or equal to the second, `false` otherwise. The arguments are required to be either both strings or both numbers; if during evaluation they are not, expression evaluation produces an error. Cases where this constraint is known not to hold at parse time are considered in valid and will produce a parse error. Accepts an optional `collator` argument to control locale-dependent string comparisons.", - "example": { - "syntax": { - "method": ["value", "value", "collator?"], - "result": "boolean" - }, - "value": ["<=", ["get", "mag"], 6] - }, - "group": "Decision", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - }, - "collator": { - "js": "0.45.0", - "android": "6.5.0", - "ios": "4.2.0" - } - } - }, - "all": { - "doc": "Returns `true` if all the inputs are `true`, `false` otherwise. The inputs are evaluated in order, and evaluation is short-circuiting: once an input expression evaluates to `false`, the result is `false` and no further input expressions are evaluated.\n\n - [Display HTML clusters with custom properties](https://maplibre.org/maplibre-gl-js/docs/examples/cluster-html/)", - "example": { - "syntax": { - "method": ["boolean", "boolean", "..."], - "result": "boolean" - }, - "value": ["all", [">=", ["get", "mag"], 4], ["<", ["get", "mag"], 5]] - }, - "group": "Decision", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "any": { - "doc": "Returns `true` if any of the inputs are `true`, `false` otherwise. The inputs are evaluated in order, and evaluation is short-circuiting: once an input expression evaluates to `true`, the result is `true` and no further input expressions are evaluated.", - "example": { - "syntax": { - "method": ["boolean", "boolean", "..."], - "result": "boolean" - }, - "value": ["any", [">=", ["get", "mag"], 4], ["<", ["get", "mag"], 5]] - }, - "group": "Decision", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "!": { - "doc": "Logical negation. Returns `true` if the input is `false`, and `false` if the input is `true`.\n\n - [Create and style clusters](https://maplibre.org/maplibre-gl-js/docs/examples/cluster/)", - "example": { - "syntax": { - "method": ["value", "value", "collator?"], - "result": "boolean" - }, - "value": ["!", ["has", "point_count"]] - }, - "group": "Decision", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "within": { - "doc": "Returns `true` if the evaluated feature is fully contained inside a boundary of the input geometry, `false` otherwise. The input value can be a valid GeoJSON of type `Polygon`, `MultiPolygon`, `Feature`, or `FeatureCollection`. Supported features for evaluation:\n\n- `Point`: Returns `false` if a point is on the boundary or falls outside the boundary.\n\n- `LineString`: Returns `false` if any part of a line falls outside the boundary, the line intersects the boundary, or a line's endpoint is on the boundary.", - "example": { - "syntax": { - "method": ["GeoJSON geometry"], - "result": "boolean" - }, - "value": ["within", {"type": "Polygon","coordinates": [[[0, 0], [0, 5], [5, 5], [5, 0], [0, 0]]]}] - }, - "group": "Decision", - "sdk-support": { - "basic functionality": { - "js": "1.9.0", - "android": "9.1.0", - "ios": "5.8.0" - } - } - }, - "is-supported-script": { - "doc": "Returns `true` if the input string is expected to render legibly. Returns `false` if the input string contains sections that cannot be rendered without potential loss of meaning (e.g. Indic scripts that require complex text shaping, or right-to-left scripts if the the `mapbox-gl-rtl-text` plugin is not in use in MapLibre GL JS).", - "example": { - "syntax": { - "method": ["string"], - "result": "boolean" - }, - "value": ["is-supported-script", "दिल्ली"] - }, - "group": "String", - "sdk-support": { - "basic functionality": { - "js": "0.45.0", - "android": "6.6.0", - "ios": "supported" - } - } - }, - "upcase": { - "doc": "Returns the input string converted to uppercase. Follows the Unicode Default Case Conversion algorithm and the locale-insensitive case mappings in the Unicode Character Database.\n\n - [Change the case of labels](https://maplibre.org/maplibre-gl-js/docs/examples/change-case-of-labels/)", - "example": { - "syntax": { - "method": ["string"], - "result": "string" - }, - "value": ["upcase", ["get", "name"]] - }, - "group": "String", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "downcase": { - "doc": "Returns the input string converted to lowercase. Follows the Unicode Default Case Conversion algorithm and the locale-insensitive case mappings in the Unicode Character Database.\n\n - [Change the case of labels](https://maplibre.org/maplibre-gl-js/docs/examples/change-case-of-labels/)", - "example": { - "syntax": { - "method": ["string"], - "result": "string" - }, - "value": ["downcase", ["get", "name"]] - }, - "group": "String", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "concat": { - "doc": "Returns a `string` consisting of the concatenation of the inputs. Each input is converted to a string as if by `to-string`.\n\n - [Add a generated icon to the map](https://maplibre.org/maplibre-gl-js/docs/examples/add-image-missing-generated/)\n\n - [Create a time slider](https://maplibre.org/maplibre-gl-js/docs/examples/timeline-animation/)\n\n - [Use a fallback image](https://maplibre.org/maplibre-gl-js/docs/examples/fallback-image/)\n\n - [Variable label placement](https://maplibre.org/maplibre-gl-js/docs/examples/variable-label-placement/)", - "example": { - "syntax": { - "method": ["string", "string", "..."], - "result": "string" - }, - "value": ["concat", "square-rgb-", ["get", "color"]] - }, - "group": "String", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - } - }, - "resolved-locale": { - "doc": "Returns the IETF language tag of the locale being used by the provided `collator`. This can be used to determine the default system locale, or to determine if a requested locale was successfully loaded.", - "example": { - "syntax": { - "method": ["collator"], - "result": "string" - }, - "value": ["resolved-locale", [ - "collator", - {"case-sensitive": true, "diacritic-sensitive": false, "locale": "de"} - ]] - }, - "group": "String", - "sdk-support": { - "basic functionality": { - "js": "0.45.0", - "android": "6.5.0", - "ios": "4.2.0" - } - } - } - } - }, - "light": { - "anchor": { - "type": "enum", - "default": "viewport", - "values": { - "map": { - "doc": "The position of the light source is aligned to the rotation of the map." - }, - "viewport": { - "doc": "The position of the light source is aligned to the rotation of the viewport." - } - }, - "property-type": "data-constant", - "transition": false, - "expression": { - "interpolated": false, - "parameters": [ - "zoom" - ] - }, - "doc": "Whether extruded geometries are lit relative to the map or viewport.", - "example": "map", - "sdk-support": { - "basic functionality": { - "js": "0.27.0", - "android": "5.1.0", - "ios": "3.6.0" - } - } - }, - "position": { - "type": "array", - "default": [ - 1.15, - 210, - 30 - ], - "length": 3, - "value": "number", - "property-type": "data-constant", - "transition": true, - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "doc": "Position of the light source relative to lit (extruded) geometries, in [r radial coordinate, a azimuthal angle, p polar angle] where r indicates the distance from the center of the base of an object to its light, a indicates the position of the light relative to 0° (0° when `light.anchor` is set to `viewport` corresponds to the top of the viewport, or 0° when `light.anchor` is set to `map` corresponds to due north, and degrees proceed clockwise), and p indicates the height of the light (from 0°, directly above, to 180°, directly below).", - "example": [ - 1.5, - 90, - 80 - ], - "sdk-support": { - "basic functionality": { - "js": "0.27.0", - "android": "5.1.0", - "ios": "3.6.0" - } - } - }, - "color": { - "type": "color", - "property-type": "data-constant", - "default": "#ffffff", - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "transition": true, - "doc": "Color tint for lighting extruded geometries.", - "sdk-support": { - "basic functionality": { - "js": "0.27.0", - "android": "5.1.0", - "ios": "3.6.0" - } - } - }, - "intensity": { - "type": "number", - "property-type": "data-constant", - "default": 0.5, - "minimum": 0, - "maximum": 1, - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "transition": true, - "doc": "Intensity of lighting (on a scale from 0 to 1). Higher numbers will present as more extreme contrast.", - "sdk-support": { - "basic functionality": { - "js": "0.27.0", - "android": "5.1.0", - "ios": "3.6.0" - } - } - } - }, - "sky": { - "sky-color": { - "type": "color", - "property-type": "data-constant", - "default": "#88C6FC", - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "transition": true, - "doc": "The base color for the sky." - }, - "horizon-color": { - "type": "color", - "property-type": "data-constant", - "default": "#ffffff", - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "transition": true, - "doc": "The base color at the horizon." - }, - "fog-color": { - "type": "color", - "property-type": "data-constant", - "default": "#ffffff", - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "transition": true, - "doc": "The base color for the fog. Requires 3D terrain." - }, - "fog-ground-blend": { - "type": "number", - "property-type": "data-constant", - "default": 0.5, - "minimum": 0, - "maximum": 1, - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "transition": true, - "doc": "How to blend the fog over the 3D terrain. Where 0 is the map center and 1 is the horizon." - }, - "horizon-fog-blend": { - "type": "number", - "property-type": "data-constant", - "default": 0.8, - "minimum": 0, - "maximum": 1, - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "transition": true, - "doc": "How to blend the fog color and the horizon color. Where 0 is using the horizon color only and 1 is using the fog color only." - }, - "sky-horizon-blend": { - "type": "number", - "property-type": "data-constant", - "default": 0.8, - "minimum": 0, - "maximum": 1, - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "transition": true, - "doc": "How to blend the the sky color and the horizon color. Where 1 is blending the color at the middle of the sky and 0 is not blending at all and using the sky color only." - }, - "atmosphere-blend": { - "type": "number", - "property-type": "data-constant", - "default": 0.8, - "minimum": 0, - "maximum": 1, - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "transition": true, - "doc": "How to blend the atmosphere. Where 1 is visible atmosphere and 0 is hidden. It is best to interpolate this expression when using globe projection." - } - }, - "terrain": { - "source": { - "type": "string", - "doc": "The source for the terrain data.", - "required": true, - "sdk-support": { - "basic functionality": { - "js": "2.2.0", - "ios": "https://github.com/maplibre/maplibre-native/issues/252", - "android": "https://github.com/maplibre/maplibre-native/issues/252" - } - } - }, - "exaggeration": { - "type": "number", - "minimum": 0, - "doc": "The exaggeration of the terrain - how high it will look.", - "default": 1.0, - "sdk-support": { - "basic functionality": { - "js": "2.2.0", - "ios": "https://github.com/maplibre/maplibre-native/issues/252", - "android": "https://github.com/maplibre/maplibre-native/issues/252" - } - } - } - }, - "projection": { - "type": { - "type": "enum", - "doc": "The projection type.", - "default": "mercator", - "values": { - "mercator": { - "doc": "The Mercator projection." - }, - "globe": { - "doc": "The globe projection." - } - } - } - }, - "paint": [ - "paint_fill", - "paint_line", - "paint_circle", - "paint_heatmap", - "paint_fill-extrusion", - "paint_symbol", - "paint_raster", - "paint_hillshade", - "paint_background" - ], - "paint_fill": { - "fill-antialias": { - "type": "boolean", - "default": true, - "doc": "Whether or not the fill should be antialiased.", - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "fill-opacity": { - "type": "number", - "default": 1, - "minimum": 0, - "maximum": 1, - "doc": "The opacity of the entire fill layer. In contrast to the `fill-color`, this value will also affect the 1px stroke around the fill, if the stroke is used.", - "transition": true, - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "0.21.0", - "android": "5.0.0", - "ios": "3.5.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature", - "feature-state" - ] - }, - "property-type": "data-driven" - }, - "fill-color": { - "type": "color", - "default": "#000000", - "doc": "The color of the filled part of this layer. This color can be specified as `rgba` with an alpha component and the color's opacity will not affect the opacity of the 1px stroke, if it is used.", - "transition": true, - "requires": [ - { - "!": "fill-pattern" - } - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "0.19.0", - "android": "5.0.0", - "ios": "3.5.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature", - "feature-state" - ] - }, - "property-type": "data-driven" - }, - "fill-outline-color": { - "type": "color", - "doc": "The outline color of the fill. Matches the value of `fill-color` if unspecified.", - "transition": true, - "requires": [ - { - "!": "fill-pattern" - }, - { - "fill-antialias": true - } - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "0.19.0", - "android": "5.0.0", - "ios": "3.5.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature", - "feature-state" - ] - }, - "property-type": "data-driven" - }, - "fill-translate": { - "type": "array", - "value": "number", - "length": 2, - "default": [ - 0, - 0 - ], - "transition": true, - "units": "pixels", - "doc": "The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively.", - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "fill-translate-anchor": { - "type": "enum", - "values": { - "map": { - "doc": "The fill is translated relative to the map." - }, - "viewport": { - "doc": "The fill is translated relative to the viewport." - } - }, - "doc": "Controls the frame of reference for `fill-translate`.", - "default": "map", - "requires": [ - "fill-translate" - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "fill-pattern": { - "type": "resolvedImage", - "transition": true, - "doc": "Name of image in sprite to use for drawing image fills. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512). Note that zoom-dependent expressions will be evaluated only at integer zoom levels.", - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "0.49.0", - "android": "6.5.0", - "ios": "4.4.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom", - "feature" - ] - }, - "property-type": "cross-faded-data-driven" - } - }, - "paint_fill-extrusion": { - "fill-extrusion-opacity": { - "type": "number", - "default": 1, - "minimum": 0, - "maximum": 1, - "doc": "The opacity of the entire fill extrusion layer. This is rendered on a per-layer, not per-feature, basis, and data-driven styling is not available.", - "transition": true, - "sdk-support": { - "basic functionality": { - "js": "0.27.0", - "android": "5.1.0", - "ios": "3.6.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "fill-extrusion-color": { - "type": "color", - "default": "#000000", - "doc": "The base color of the extruded fill. The extrusion's surfaces will be shaded differently based on this color in combination with the root `light` settings. If this color is specified as `rgba` with an alpha component, the alpha component will be ignored; use `fill-extrusion-opacity` to set layer opacity.", - "transition": true, - "requires": [ - { - "!": "fill-extrusion-pattern" - } - ], - "sdk-support": { - "basic functionality": { - "js": "0.27.0", - "android": "5.1.0", - "ios": "3.6.0" - }, - "data-driven styling": { - "js": "0.27.0", - "android": "5.1.0", - "ios": "3.6.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature", - "feature-state" - ] - }, - "property-type": "data-driven" - }, - "fill-extrusion-translate": { - "type": "array", - "value": "number", - "length": 2, - "default": [ - 0, - 0 - ], - "transition": true, - "units": "pixels", - "doc": "The geometry's offset. Values are [x, y] where negatives indicate left and up (on the flat plane), respectively.", - "sdk-support": { - "basic functionality": { - "js": "0.27.0", - "android": "5.1.0", - "ios": "3.6.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "fill-extrusion-translate-anchor": { - "type": "enum", - "values": { - "map": { - "doc": "The fill extrusion is translated relative to the map." - }, - "viewport": { - "doc": "The fill extrusion is translated relative to the viewport." - } - }, - "doc": "Controls the frame of reference for `fill-extrusion-translate`.", - "default": "map", - "requires": [ - "fill-extrusion-translate" - ], - "sdk-support": { - "basic functionality": { - "js": "0.27.0", - "android": "5.1.0", - "ios": "3.6.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "fill-extrusion-pattern": { - "type": "resolvedImage", - "transition": true, - "doc": "Name of image in sprite to use for drawing images on extruded fills. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512). Note that zoom-dependent expressions will be evaluated only at integer zoom levels.", - "sdk-support": { - "basic functionality": { - "js": "0.27.0", - "android": "5.1.0", - "ios": "3.6.0" - }, - "data-driven styling": { - "js": "0.49.0", - "android": "6.5.0", - "ios": "4.4.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom", - "feature" - ] - }, - "property-type": "cross-faded-data-driven" - }, - "fill-extrusion-height": { - "type": "number", - "default": 0, - "minimum": 0, - "units": "meters", - "doc": "The height with which to extrude this layer.", - "transition": true, - "sdk-support": { - "basic functionality": { - "js": "0.27.0", - "android": "5.1.0", - "ios": "3.6.0" - }, - "data-driven styling": { - "js": "0.27.0", - "android": "5.1.0", - "ios": "3.6.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature", - "feature-state" - ] - }, - "property-type": "data-driven" - }, - "fill-extrusion-base": { - "type": "number", - "default": 0, - "minimum": 0, - "units": "meters", - "doc": "The height with which to extrude the base of this layer. Must be less than or equal to `fill-extrusion-height`.", - "transition": true, - "requires": [ - "fill-extrusion-height" - ], - "sdk-support": { - "basic functionality": { - "js": "0.27.0", - "android": "5.1.0", - "ios": "3.6.0" - }, - "data-driven styling": { - "js": "0.27.0", - "android": "5.1.0", - "ios": "3.6.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature", - "feature-state" - ] - }, - "property-type": "data-driven" - }, - "fill-extrusion-vertical-gradient": { - "type": "boolean", - "default": true, - "doc": "Whether to apply a vertical gradient to the sides of a fill-extrusion layer. If true, sides will be shaded slightly darker farther down.", - "transition": false, - "sdk-support": { - "basic functionality": { - "js": "0.50.0", - "ios": "4.7.0", - "android": "7.0.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - } - }, - "paint_line": { - "line-opacity": { - "type": "number", - "doc": "The opacity at which the line will be drawn.", - "default": 1, - "minimum": 0, - "maximum": 1, - "transition": true, - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "0.29.0", - "android": "5.0.0", - "ios": "3.5.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature", - "feature-state" - ] - }, - "property-type": "data-driven" - }, - "line-color": { - "type": "color", - "doc": "The color with which the line will be drawn.", - "default": "#000000", - "transition": true, - "requires": [ - { - "!": "line-pattern" - } - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "0.23.0", - "android": "5.0.0", - "ios": "3.5.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature", - "feature-state" - ] - }, - "property-type": "data-driven" - }, - "line-translate": { - "type": "array", - "value": "number", - "length": 2, - "default": [ - 0, - 0 - ], - "transition": true, - "units": "pixels", - "doc": "The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively.", - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "line-translate-anchor": { - "type": "enum", - "values": { - "map": { - "doc": "The line is translated relative to the map." - }, - "viewport": { - "doc": "The line is translated relative to the viewport." - } - }, - "doc": "Controls the frame of reference for `line-translate`.", - "default": "map", - "requires": [ - "line-translate" - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "line-width": { - "type": "number", - "default": 1, - "minimum": 0, - "transition": true, - "units": "pixels", - "doc": "Stroke thickness.", - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "0.39.0", - "android": "5.2.0", - "ios": "3.7.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature", - "feature-state" - ] - }, - "property-type": "data-driven" - }, - "line-gap-width": { - "type": "number", - "default": 0, - "minimum": 0, - "doc": "Draws a line casing outside of a line's actual path. Value indicates the width of the inner gap.", - "transition": true, - "units": "pixels", - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "0.29.0", - "android": "5.0.0", - "ios": "3.5.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature", - "feature-state" - ] - }, - "property-type": "data-driven" - }, - "line-offset": { - "type": "number", - "default": 0, - "doc": "The line's offset. For linear features, a positive value offsets the line to the right, relative to the direction of the line, and a negative value to the left. For polygon features, a positive value results in an inset, and a negative value results in an outset.", - "transition": true, - "units": "pixels", - "sdk-support": { - "basic functionality": { - "js": "0.12.1", - "android": "3.0.0", - "ios": "3.1.0" - }, - "data-driven styling": { - "js": "0.29.0", - "android": "5.0.0", - "ios": "3.5.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature", - "feature-state" - ] - }, - "property-type": "data-driven" - }, - "line-blur": { - "type": "number", - "default": 0, - "minimum": 0, - "transition": true, - "units": "pixels", - "doc": "Blur applied to the line, in pixels.", - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "0.29.0", - "android": "5.0.0", - "ios": "3.5.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature", - "feature-state" - ] - }, - "property-type": "data-driven" - }, - "line-dasharray": { - "type": "array", - "value": "number", - "doc": "Specifies the lengths of the alternating dashes and gaps that form the dash pattern. The lengths are later scaled by the line width. To convert a dash length to pixels, multiply the length by the current line width. Note that GeoJSON sources with `lineMetrics: true` specified won't render dashed lines to the expected scale. Also note that zoom-dependent expressions will be evaluated only at integer zoom levels.", - "minimum": 0, - "transition": true, - "units": "line widths", - "requires": [ - { - "!": "line-pattern" - } - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "https://github.com/maplibre/maplibre-gl-js/issues/1235", - "ios": "https://github.com/maplibre/maplibre-native/issues/744", - "android": "https://github.com/maplibre/maplibre-native/issues/744" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom" - ] - }, - "property-type": "cross-faded" - }, - "line-pattern": { - "type": "resolvedImage", - "transition": true, - "doc": "Name of image in sprite to use for drawing image lines. For seamless patterns, image width must be a factor of two (2, 4, 8, ..., 512). Note that zoom-dependent expressions will be evaluated only at integer zoom levels.", - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "0.49.0", - "android": "6.5.0", - "ios": "4.4.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom", - "feature" - ] - }, - "property-type": "cross-faded-data-driven" - }, - "line-gradient": { - "type": "color", - "doc": "Defines a gradient with which to color a line feature. Can only be used with GeoJSON sources that specify `\"lineMetrics\": true`.", - "transition": false, - "requires": [ - { - "!": "line-dasharray" - }, - { - "!": "line-pattern" - }, - { - "source": "geojson", - "has": { - "lineMetrics": true - } - } - ], - "sdk-support": { - "basic functionality": { - "js": "0.45.0", - "android": "6.5.0", - "ios": "4.4.0" - }, - "data-driven styling": {} - }, - "expression": { - "interpolated": true, - "parameters": [ - "line-progress" - ] - }, - "property-type": "color-ramp" - } - }, - "paint_circle": { - "circle-radius": { - "type": "number", - "default": 5, - "minimum": 0, - "transition": true, - "units": "pixels", - "doc": "Circle radius.", - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "0.18.0", - "android": "5.0.0", - "ios": "3.5.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature", - "feature-state" - ] - }, - "property-type": "data-driven" - }, - "circle-color": { - "type": "color", - "default": "#000000", - "doc": "The fill color of the circle.", - "transition": true, - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "0.18.0", - "android": "5.0.0", - "ios": "3.5.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature", - "feature-state" - ] - }, - "property-type": "data-driven" - }, - "circle-blur": { - "type": "number", - "default": 0, - "doc": "Amount to blur the circle. 1 blurs the circle such that only the centerpoint is full opacity.", - "transition": true, - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "0.20.0", - "android": "5.0.0", - "ios": "3.5.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature", - "feature-state" - ] - }, - "property-type": "data-driven" - }, - "circle-opacity": { - "type": "number", - "doc": "The opacity at which the circle will be drawn.", - "default": 1, - "minimum": 0, - "maximum": 1, - "transition": true, - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "0.20.0", - "android": "5.0.0", - "ios": "3.5.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature", - "feature-state" - ] - }, - "property-type": "data-driven" - }, - "circle-translate": { - "type": "array", - "value": "number", - "length": 2, - "default": [ - 0, - 0 - ], - "transition": true, - "units": "pixels", - "doc": "The geometry's offset. Values are [x, y] where negatives indicate left and up, respectively.", - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "circle-translate-anchor": { - "type": "enum", - "values": { - "map": { - "doc": "The circle is translated relative to the map." - }, - "viewport": { - "doc": "The circle is translated relative to the viewport." - } - }, - "doc": "Controls the frame of reference for `circle-translate`.", - "default": "map", - "requires": [ - "circle-translate" - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "circle-pitch-scale": { - "type": "enum", - "values": { - "map": { - "doc": "Circles are scaled according to their apparent distance to the camera." - }, - "viewport": { - "doc": "Circles are not scaled." - } - }, - "default": "map", - "doc": "Controls the scaling behavior of the circle when the map is pitched.", - "sdk-support": { - "basic functionality": { - "js": "0.21.0", - "android": "4.2.0", - "ios": "3.4.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "circle-pitch-alignment": { - "type": "enum", - "values": { - "map": { - "doc": "The circle is aligned to the plane of the map." - }, - "viewport": { - "doc": "The circle is aligned to the plane of the viewport." - } - }, - "default": "viewport", - "doc": "Orientation of circle when map is pitched.", - "sdk-support": { - "basic functionality": { - "js": "0.39.0", - "android": "5.2.0", - "ios": "3.7.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "circle-stroke-width": { - "type": "number", - "default": 0, - "minimum": 0, - "transition": true, - "units": "pixels", - "doc": "The width of the circle's stroke. Strokes are placed outside of the `circle-radius`.", - "sdk-support": { - "basic functionality": { - "js": "0.29.0", - "android": "5.0.0", - "ios": "3.5.0" - }, - "data-driven styling": { - "js": "0.29.0", - "android": "5.0.0", - "ios": "3.5.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature", - "feature-state" - ] - }, - "property-type": "data-driven" - }, - "circle-stroke-color": { - "type": "color", - "default": "#000000", - "doc": "The stroke color of the circle.", - "transition": true, - "sdk-support": { - "basic functionality": { - "js": "0.29.0", - "android": "5.0.0", - "ios": "3.5.0" - }, - "data-driven styling": { - "js": "0.29.0", - "android": "5.0.0", - "ios": "3.5.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature", - "feature-state" - ] - }, - "property-type": "data-driven" - }, - "circle-stroke-opacity": { - "type": "number", - "doc": "The opacity of the circle's stroke.", - "default": 1, - "minimum": 0, - "maximum": 1, - "transition": true, - "sdk-support": { - "basic functionality": { - "js": "0.29.0", - "android": "5.0.0", - "ios": "3.5.0" - }, - "data-driven styling": { - "js": "0.29.0", - "android": "5.0.0", - "ios": "3.5.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature", - "feature-state" - ] - }, - "property-type": "data-driven" - } - }, - "paint_heatmap": { - "heatmap-radius": { - "type": "number", - "default": 30, - "minimum": 1, - "transition": true, - "units": "pixels", - "doc": "Radius of influence of one heatmap point in pixels. Increasing the value makes the heatmap smoother, but less detailed.", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - }, - "data-driven styling": { - "js": "0.43.0", - "android": "6.0.0", - "ios": "4.0.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature", - "feature-state" - ] - }, - "property-type": "data-driven" - }, - "heatmap-weight": { - "type": "number", - "default": 1, - "minimum": 0, - "transition": false, - "doc": "A measure of how much an individual point contributes to the heatmap. A value of 10 would be equivalent to having 10 points of weight 1 in the same spot. Especially useful when combined with clustering.", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - }, - "data-driven styling": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature", - "feature-state" - ] - }, - "property-type": "data-driven" - }, - "heatmap-intensity": { - "type": "number", - "default": 1, - "minimum": 0, - "transition": true, - "doc": "Similar to `heatmap-weight` but controls the intensity of the heatmap globally. Primarily used for adjusting the heatmap based on zoom level.", - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "heatmap-color": { - "type": "color", - "default": [ - "interpolate", - [ - "linear" - ], - [ - "heatmap-density" - ], - 0, - "rgba(0, 0, 255, 0)", - 0.1, - "royalblue", - 0.3, - "cyan", - 0.5, - "lime", - 0.7, - "yellow", - 1, - "red" - ], - "doc": "Defines the color of each pixel based on its density value in a heatmap. Should be an expression that uses `[\"heatmap-density\"]` as input.", - "transition": false, - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - }, - "data-driven styling": {} - }, - "expression": { - "interpolated": true, - "parameters": [ - "heatmap-density" - ] - }, - "property-type": "color-ramp" - }, - "heatmap-opacity": { - "type": "number", - "doc": "The global opacity at which the heatmap layer will be drawn.", - "default": 1, - "minimum": 0, - "maximum": 1, - "transition": true, - "sdk-support": { - "basic functionality": { - "js": "0.41.0", - "android": "6.0.0", - "ios": "4.0.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - } - }, - "paint_symbol": { - "icon-opacity": { - "doc": "The opacity at which the icon will be drawn.", - "type": "number", - "default": 1, - "minimum": 0, - "maximum": 1, - "transition": true, - "requires": [ - "icon-image" - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "0.33.0", - "android": "5.0.0", - "ios": "3.5.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature", - "feature-state" - ] - }, - "property-type": "data-driven" - }, - "icon-color": { - "type": "color", - "default": "#000000", - "transition": true, - "doc": "The color of the icon. This can only be used with SDF icons.", - "requires": [ - "icon-image" - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "0.33.0", - "android": "5.0.0", - "ios": "3.5.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature", - "feature-state" - ] - }, - "property-type": "data-driven" - }, - "icon-halo-color": { - "type": "color", - "default": "rgba(0, 0, 0, 0)", - "transition": true, - "doc": "The color of the icon's halo. Icon halos can only be used with SDF icons.", - "requires": [ - "icon-image" - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "0.33.0", - "android": "5.0.0", - "ios": "3.5.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature", - "feature-state" - ] - }, - "property-type": "data-driven" - }, - "icon-halo-width": { - "type": "number", - "default": 0, - "minimum": 0, - "transition": true, - "units": "pixels", - "doc": "Distance of halo to the icon outline. \n\nThe unit is in pixels only for SDF sprites that were created with a blur radius of 8, multiplied by the display density. I.e., the radius needs to be 16 for `@2x` sprites, etc.", - "requires": [ - "icon-image" - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "0.33.0", - "android": "5.0.0", - "ios": "3.5.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature", - "feature-state" - ] - }, - "property-type": "data-driven" - }, - "icon-halo-blur": { - "type": "number", - "default": 0, - "minimum": 0, - "transition": true, - "units": "pixels", - "doc": "Fade out the halo towards the outside.", - "requires": [ - "icon-image" - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "0.33.0", - "android": "5.0.0", - "ios": "3.5.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature", - "feature-state" - ] - }, - "property-type": "data-driven" - }, - "icon-translate": { - "type": "array", - "value": "number", - "length": 2, - "default": [ - 0, - 0 - ], - "transition": true, - "units": "pixels", - "doc": "Distance that the icon's anchor is moved from its original placement. Positive values indicate right and down, while negative values indicate left and up.", - "requires": [ - "icon-image" - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "icon-translate-anchor": { - "type": "enum", - "values": { - "map": { - "doc": "Icons are translated relative to the map." - }, - "viewport": { - "doc": "Icons are translated relative to the viewport." - } - }, - "doc": "Controls the frame of reference for `icon-translate`.", - "default": "map", - "requires": [ - "icon-image", - "icon-translate" - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "text-opacity": { - "type": "number", - "doc": "The opacity at which the text will be drawn.", - "default": 1, - "minimum": 0, - "maximum": 1, - "transition": true, - "requires": [ - "text-field" - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "0.33.0", - "android": "5.0.0", - "ios": "3.5.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature", - "feature-state" - ] - }, - "property-type": "data-driven" - }, - "text-color": { - "type": "color", - "doc": "The color with which the text will be drawn.", - "default": "#000000", - "transition": true, - "overridable": true, - "requires": [ - "text-field" - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "0.33.0", - "android": "5.0.0", - "ios": "3.5.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature", - "feature-state" - ] - }, - "property-type": "data-driven" - }, - "text-halo-color": { - "type": "color", - "default": "rgba(0, 0, 0, 0)", - "transition": true, - "doc": "The color of the text's halo, which helps it stand out from backgrounds.", - "requires": [ - "text-field" - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "0.33.0", - "android": "5.0.0", - "ios": "3.5.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature", - "feature-state" - ] - }, - "property-type": "data-driven" - }, - "text-halo-width": { - "type": "number", - "default": 0, - "minimum": 0, - "transition": true, - "units": "pixels", - "doc": "Distance of halo to the font outline. Max text halo width is 1/4 of the font-size.", - "requires": [ - "text-field" - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "0.33.0", - "android": "5.0.0", - "ios": "3.5.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature", - "feature-state" - ] - }, - "property-type": "data-driven" - }, - "text-halo-blur": { - "type": "number", - "default": 0, - "minimum": 0, - "transition": true, - "units": "pixels", - "doc": "The halo's fadeout distance towards the outside.", - "requires": [ - "text-field" - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": { - "js": "0.33.0", - "android": "5.0.0", - "ios": "3.5.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom", - "feature", - "feature-state" - ] - }, - "property-type": "data-driven" - }, - "text-translate": { - "type": "array", - "value": "number", - "length": 2, - "default": [ - 0, - 0 - ], - "transition": true, - "units": "pixels", - "doc": "Distance that the text's anchor is moved from its original placement. Positive values indicate right and down, while negative values indicate left and up.", - "requires": [ - "text-field" - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "text-translate-anchor": { - "type": "enum", - "values": { - "map": { - "doc": "The text is translated relative to the map." - }, - "viewport": { - "doc": "The text is translated relative to the viewport." - } - }, - "doc": "Controls the frame of reference for `text-translate`.", - "default": "map", - "requires": [ - "text-field", - "text-translate" - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - } - }, - "paint_raster": { - "raster-opacity": { - "type": "number", - "doc": "The opacity at which the image will be drawn.", - "default": 1, - "minimum": 0, - "maximum": 1, - "transition": true, - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "raster-hue-rotate": { - "type": "number", - "default": 0, - "period": 360, - "transition": true, - "units": "degrees", - "doc": "Rotates hues around the color wheel.", - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "raster-brightness-min": { - "type": "number", - "doc": "Increase or reduce the brightness of the image. The value is the minimum brightness.", - "default": 0, - "minimum": 0, - "maximum": 1, - "transition": true, - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "raster-brightness-max": { - "type": "number", - "doc": "Increase or reduce the brightness of the image. The value is the maximum brightness.", - "default": 1, - "minimum": 0, - "maximum": 1, - "transition": true, - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "raster-saturation": { - "type": "number", - "doc": "Increase or reduce the saturation of the image.", - "default": 0, - "minimum": -1, - "maximum": 1, - "transition": true, - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "raster-contrast": { - "type": "number", - "doc": "Increase or reduce the contrast of the image.", - "default": 0, - "minimum": -1, - "maximum": 1, - "transition": true, - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "raster-resampling": { - "type": "enum", - "doc": "The resampling/interpolation method to use for overscaling, also known as texture magnification filter", - "values": { - "linear": { - "doc": "(Bi)linear filtering interpolates pixel values using the weighted average of the four closest original source pixels creating a smooth but blurry look when overscaled" - }, - "nearest": { - "doc": "Nearest neighbor filtering interpolates pixel values using the nearest original source pixel creating a sharp but pixelated look when overscaled" - } - }, - "default": "linear", - "sdk-support": { - "basic functionality": { - "js": "0.47.0", - "android": "6.3.0", - "ios": "4.2.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "raster-fade-duration": { - "type": "number", - "default": 300, - "minimum": 0, - "transition": false, - "units": "milliseconds", - "doc": "Fade duration when a new tile is added, or when a video is started or its coordinates are updated.", - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - } - }, - "paint_hillshade": { - "hillshade-illumination-direction": { - "type": "number", - "default": 335, - "minimum": 0, - "maximum": 359, - "doc": "The direction of the light source used to generate the hillshading with 0 as the top of the viewport if `hillshade-illumination-anchor` is set to `viewport` and due north if `hillshade-illumination-anchor` is set to `map`.", - "transition": false, - "sdk-support": { - "basic functionality": { - "js": "0.43.0", - "android": "6.0.0", - "ios": "4.0.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "hillshade-illumination-anchor": { - "type": "enum", - "values": { - "map": { - "doc": "The hillshade illumination is relative to the north direction." - }, - "viewport": { - "doc": "The hillshade illumination is relative to the top of the viewport." - } - }, - "default": "viewport", - "doc": "Direction of light source when map is rotated.", - "sdk-support": { - "basic functionality": { - "js": "0.43.0", - "android": "6.0.0", - "ios": "4.0.0" - } - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "hillshade-exaggeration": { - "type": "number", - "doc": "Intensity of the hillshade", - "default": 0.5, - "minimum": 0, - "maximum": 1, - "transition": true, - "sdk-support": { - "basic functionality": { - "js": "0.43.0", - "android": "6.0.0", - "ios": "4.0.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "hillshade-shadow-color": { - "type": "color", - "default": "#000000", - "doc": "The shading color of areas that face away from the light source.", - "transition": true, - "sdk-support": { - "basic functionality": { - "js": "0.43.0", - "android": "6.0.0", - "ios": "4.0.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "hillshade-highlight-color": { - "type": "color", - "default": "#FFFFFF", - "doc": "The shading color of areas that faces towards the light source.", - "transition": true, - "sdk-support": { - "basic functionality": { - "js": "0.43.0", - "android": "6.0.0", - "ios": "4.0.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "hillshade-accent-color": { - "type": "color", - "default": "#000000", - "doc": "The shading color used to accentuate rugged terrain like sharp cliffs and gorges.", - "transition": true, - "sdk-support": { - "basic functionality": { - "js": "0.43.0", - "android": "6.0.0", - "ios": "4.0.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - } - }, - "paint_background": { - "background-color": { - "type": "color", - "default": "#000000", - "doc": "The color with which the background will be drawn.", - "transition": true, - "requires": [ - { - "!": "background-pattern" - } - ], - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - }, - "background-pattern": { - "type": "resolvedImage", - "transition": true, - "doc": "Name of image in sprite to use for drawing an image background. For seamless patterns, image width and height must be a factor of two (2, 4, 8, ..., 512). Note that zoom-dependent expressions will be evaluated only at integer zoom levels.", - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - }, - "data-driven styling": {} - }, - "expression": { - "interpolated": false, - "parameters": [ - "zoom" - ] - }, - "property-type": "cross-faded" - }, - "background-opacity": { - "type": "number", - "default": 1, - "minimum": 0, - "maximum": 1, - "doc": "The opacity at which the background will be drawn.", - "transition": true, - "sdk-support": { - "basic functionality": { - "js": "0.10.0", - "android": "2.0.1", - "ios": "2.0.0" - } - }, - "expression": { - "interpolated": true, - "parameters": [ - "zoom" - ] - }, - "property-type": "data-constant" - } - }, - "transition": { - "duration": { - "type": "number", - "default": 300, - "minimum": 0, - "units": "milliseconds", - "doc": "Time allotted for transitions to complete." - }, - "delay": { - "type": "number", - "default": 0, - "minimum": 0, - "units": "milliseconds", - "doc": "Length of time before a transition begins." - } - }, - "property-type": { - "data-driven": { - "type": "property-type", - "doc": "Property is interpolable and can be represented using a property expression." - }, - "cross-faded": { - "type": "property-type", - "doc": "Property is non-interpolable; rather, its values will be cross-faded to smoothly transition between integer zooms." - }, - "cross-faded-data-driven": { - "type": "property-type", - "doc": "Property is non-interpolable; rather, its values will be cross-faded to smoothly transition between integer zooms. It can be represented using a property expression." - }, - "color-ramp": { - "type": "property-type", - "doc": "Property should be specified using a color ramp from which the output color can be sampled based on a property calculation." - }, - "data-constant": { - "type": "property-type", - "doc": "Property is interpolable but cannot be represented using a property expression." - }, - "constant": { - "type": "property-type", - "doc": "Property is constant across all zoom levels and property values." - } - }, - "promoteId": { - "*": { - "type": "string", - "doc": "A name of a feature property to use as ID for feature state." - } - } -} diff --git a/tsconfig.json b/tsconfig.json index 71f06c61d..8e915b2c0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -17,7 +17,5 @@ "noUnusedLocals": true, "noImplicitReturns": true }, - "include": [ - "javascript/**/*", "index.ts" - ], + "include": ["javascript/**/*", "index.ts"] } diff --git a/yarn.lock b/yarn.lock index 8bf1fd51a..5b54bfef6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2193,6 +2193,174 @@ __metadata: languageName: node linkType: hard +"@esbuild/aix-ppc64@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/aix-ppc64@npm:0.23.1" + conditions: os=aix & cpu=ppc64 + languageName: node + linkType: hard + +"@esbuild/android-arm64@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/android-arm64@npm:0.23.1" + conditions: os=android & cpu=arm64 + languageName: node + linkType: hard + +"@esbuild/android-arm@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/android-arm@npm:0.23.1" + conditions: os=android & cpu=arm + languageName: node + linkType: hard + +"@esbuild/android-x64@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/android-x64@npm:0.23.1" + conditions: os=android & cpu=x64 + languageName: node + linkType: hard + +"@esbuild/darwin-arm64@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/darwin-arm64@npm:0.23.1" + conditions: os=darwin & cpu=arm64 + languageName: node + linkType: hard + +"@esbuild/darwin-x64@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/darwin-x64@npm:0.23.1" + conditions: os=darwin & cpu=x64 + languageName: node + linkType: hard + +"@esbuild/freebsd-arm64@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/freebsd-arm64@npm:0.23.1" + conditions: os=freebsd & cpu=arm64 + languageName: node + linkType: hard + +"@esbuild/freebsd-x64@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/freebsd-x64@npm:0.23.1" + conditions: os=freebsd & cpu=x64 + languageName: node + linkType: hard + +"@esbuild/linux-arm64@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/linux-arm64@npm:0.23.1" + conditions: os=linux & cpu=arm64 + languageName: node + linkType: hard + +"@esbuild/linux-arm@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/linux-arm@npm:0.23.1" + conditions: os=linux & cpu=arm + languageName: node + linkType: hard + +"@esbuild/linux-ia32@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/linux-ia32@npm:0.23.1" + conditions: os=linux & cpu=ia32 + languageName: node + linkType: hard + +"@esbuild/linux-loong64@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/linux-loong64@npm:0.23.1" + conditions: os=linux & cpu=loong64 + languageName: node + linkType: hard + +"@esbuild/linux-mips64el@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/linux-mips64el@npm:0.23.1" + conditions: os=linux & cpu=mips64el + languageName: node + linkType: hard + +"@esbuild/linux-ppc64@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/linux-ppc64@npm:0.23.1" + conditions: os=linux & cpu=ppc64 + languageName: node + linkType: hard + +"@esbuild/linux-riscv64@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/linux-riscv64@npm:0.23.1" + conditions: os=linux & cpu=riscv64 + languageName: node + linkType: hard + +"@esbuild/linux-s390x@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/linux-s390x@npm:0.23.1" + conditions: os=linux & cpu=s390x + languageName: node + linkType: hard + +"@esbuild/linux-x64@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/linux-x64@npm:0.23.1" + conditions: os=linux & cpu=x64 + languageName: node + linkType: hard + +"@esbuild/netbsd-x64@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/netbsd-x64@npm:0.23.1" + conditions: os=netbsd & cpu=x64 + languageName: node + linkType: hard + +"@esbuild/openbsd-arm64@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/openbsd-arm64@npm:0.23.1" + conditions: os=openbsd & cpu=arm64 + languageName: node + linkType: hard + +"@esbuild/openbsd-x64@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/openbsd-x64@npm:0.23.1" + conditions: os=openbsd & cpu=x64 + languageName: node + linkType: hard + +"@esbuild/sunos-x64@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/sunos-x64@npm:0.23.1" + conditions: os=sunos & cpu=x64 + languageName: node + linkType: hard + +"@esbuild/win32-arm64@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/win32-arm64@npm:0.23.1" + conditions: os=win32 & cpu=arm64 + languageName: node + linkType: hard + +"@esbuild/win32-ia32@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/win32-ia32@npm:0.23.1" + conditions: os=win32 & cpu=ia32 + languageName: node + linkType: hard + +"@esbuild/win32-x64@npm:0.23.1": + version: 0.23.1 + resolution: "@esbuild/win32-x64@npm:0.23.1" + conditions: os=win32 & cpu=x64 + languageName: node + linkType: hard + "@eslint-community/eslint-utils@npm:^4.2.0, @eslint-community/eslint-utils@npm:^4.4.0": version: 4.4.0 resolution: "@eslint-community/eslint-utils@npm:4.4.0" @@ -3132,6 +3300,13 @@ __metadata: languageName: node linkType: hard +"@mapbox/jsonlint-lines-primitives@npm:~2.0.2": + version: 2.0.2 + resolution: "@mapbox/jsonlint-lines-primitives@npm:2.0.2" + checksum: 10/6d8e64d34d912ebf29fead0d1917c8d8ad86e96f69b6100a9764af8cba391609474cdce7f7e4a2d579ccea58a142d1454257b795403179e9133a09af13101068 + languageName: node + linkType: hard + "@mapbox/sphericalmercator@npm:^1.2.0": version: 1.2.0 resolution: "@mapbox/sphericalmercator@npm:1.2.0" @@ -3144,6 +3319,13 @@ __metadata: languageName: node linkType: hard +"@mapbox/unitbezier@npm:^0.0.1": + version: 0.0.1 + resolution: "@mapbox/unitbezier@npm:0.0.1" + checksum: 10/bf104c85dbff37bf47d3217d9457a3abbf23714f78fefadea64e56bdc7c538491b626166809ef28db134f09baccd6ca3df6988a6422df90d8d0c9a23b0686043 + languageName: node + linkType: hard + "@maplibre-react-native/examples@workspace:*, @maplibre-react-native/examples@workspace:packages/examples": version: 0.0.0-use.local resolution: "@maplibre-react-native/examples@workspace:packages/examples" @@ -3197,6 +3379,25 @@ __metadata: languageName: unknown linkType: soft +"@maplibre/maplibre-gl-style-spec@npm:21.0.0": + version: 21.0.0 + resolution: "@maplibre/maplibre-gl-style-spec@npm:21.0.0" + dependencies: + "@mapbox/jsonlint-lines-primitives": "npm:~2.0.2" + "@mapbox/unitbezier": "npm:^0.0.1" + json-stringify-pretty-compact: "npm:^4.0.0" + minimist: "npm:^1.2.8" + quickselect: "npm:^2.0.0" + rw: "npm:^1.3.3" + tinyqueue: "npm:^3.0.0" + bin: + gl-style-format: dist/gl-style-format.mjs + gl-style-migrate: dist/gl-style-migrate.mjs + gl-style-validate: dist/gl-style-validate.mjs + checksum: 10/06d5d95ced163da8980f9f7f530e639fa625f0e0c50d2fde61038bc8d6c3e72f8145d3fb3f3db35babb3e15bc3b6f86a4cdfac97baa03d6861c59453ebc304bc + languageName: node + linkType: hard + "@maplibre/maplibre-react-native@workspace:*, @maplibre/maplibre-react-native@workspace:.": version: 0.0.0-use.local resolution: "@maplibre/maplibre-react-native@workspace:." @@ -3206,6 +3407,7 @@ __metadata: "@babel/plugin-proposal-class-properties": "npm:7.18.6" "@babel/runtime": "npm:7.17.2" "@expo/config-plugins": "npm:^7.2.5" + "@maplibre/maplibre-gl-style-spec": "npm:21.0.0" "@react-native/babel-preset": "npm:^0.74.88" "@react-native/metro-config": "npm:^0.74.88" "@sinonjs/fake-timers": "npm:^11.2.2" @@ -3216,6 +3418,7 @@ __metadata: "@turf/length": "npm:^7.1.0" "@turf/nearest-point-on-line": "npm:^7.1.0" "@types/debounce": "npm:^1.2.1" + "@types/ejs": "npm:^3.1.5" "@types/geojson": "npm:^7946.0.14" "@types/jest": "npm:^29.5.12" "@types/node": "npm:^18.11.18" @@ -3226,7 +3429,7 @@ __metadata: babel-jest: "npm:^29.6.0" debounce: "npm:^2.0.0" documentation: "npm:^14.0.0" - ejs: "npm:^3.1.3" + ejs: "npm:^3.1.10" ejs-lint: "npm:^2.0.0" eslint: "npm:^8.57.1" eslint-config-universe: "npm:13.0.0" @@ -3239,9 +3442,10 @@ __metadata: pinst: "npm:^3.0.0" prettier: "npm:3.3.3" react: "npm:18.2.0" - react-docgen: "rnmapbox/react-docgen#rnmapbox-dist" + react-docgen: "npm:^7.1.0" react-native: "npm:^0.74.6" react-test-renderer: "npm:18.2.0" + tsx: "npm:^4.19.2" typescript: "npm:^5.3.3" peerDependencies: "@expo/config-plugins": ">=7" @@ -4563,7 +4767,7 @@ __metadata: languageName: node linkType: hard -"@types/babel__core@npm:^7.1.14": +"@types/babel__core@npm:^7.1.14, @types/babel__core@npm:^7.18.0": version: 7.20.5 resolution: "@types/babel__core@npm:7.20.5" dependencies: @@ -4620,10 +4824,17 @@ __metadata: languageName: node linkType: hard -"@types/doctrine@npm:^0.0.5": - version: 0.0.5 - resolution: "@types/doctrine@npm:0.0.5" - checksum: 10/cfda418a9df86587815a0838a89dc88e44fa5c0af6f7242fa1e3e896fe3a69856ff3737301d5676eb7a612ed7a947ffd12d94cd3c3301178da573c9fbc17642f +"@types/doctrine@npm:^0.0.9": + version: 0.0.9 + resolution: "@types/doctrine@npm:0.0.9" + checksum: 10/64ef06e6eea2f4f9684d259fedbcb8bf21c954630b96ea2e04875ca42763552b0ba3b01b3dd27ec0f9ea6f8b3b0dba4965d31d5a925cd4c6225fd13a93ae9354 + languageName: node + linkType: hard + +"@types/ejs@npm:^3.1.5": + version: 3.1.5 + resolution: "@types/ejs@npm:3.1.5" + checksum: 10/918898fd279108087722c1713e2ddb0c152ab839397946d164db8a18b5bbd732af9746373882a9bcf4843d35c6b191a8f569a7a4e51e90726d24501b39f40367 languageName: node linkType: hard @@ -7560,7 +7771,7 @@ __metadata: languageName: node linkType: hard -"ejs@npm:^3.1.3": +"ejs@npm:^3.1.10": version: 3.1.10 resolution: "ejs@npm:3.1.10" dependencies: @@ -7856,6 +8067,89 @@ __metadata: languageName: node linkType: hard +"esbuild@npm:~0.23.0": + version: 0.23.1 + resolution: "esbuild@npm:0.23.1" + dependencies: + "@esbuild/aix-ppc64": "npm:0.23.1" + "@esbuild/android-arm": "npm:0.23.1" + "@esbuild/android-arm64": "npm:0.23.1" + "@esbuild/android-x64": "npm:0.23.1" + "@esbuild/darwin-arm64": "npm:0.23.1" + "@esbuild/darwin-x64": "npm:0.23.1" + "@esbuild/freebsd-arm64": "npm:0.23.1" + "@esbuild/freebsd-x64": "npm:0.23.1" + "@esbuild/linux-arm": "npm:0.23.1" + "@esbuild/linux-arm64": "npm:0.23.1" + "@esbuild/linux-ia32": "npm:0.23.1" + "@esbuild/linux-loong64": "npm:0.23.1" + "@esbuild/linux-mips64el": "npm:0.23.1" + "@esbuild/linux-ppc64": "npm:0.23.1" + "@esbuild/linux-riscv64": "npm:0.23.1" + "@esbuild/linux-s390x": "npm:0.23.1" + "@esbuild/linux-x64": "npm:0.23.1" + "@esbuild/netbsd-x64": "npm:0.23.1" + "@esbuild/openbsd-arm64": "npm:0.23.1" + "@esbuild/openbsd-x64": "npm:0.23.1" + "@esbuild/sunos-x64": "npm:0.23.1" + "@esbuild/win32-arm64": "npm:0.23.1" + "@esbuild/win32-ia32": "npm:0.23.1" + "@esbuild/win32-x64": "npm:0.23.1" + dependenciesMeta: + "@esbuild/aix-ppc64": + optional: true + "@esbuild/android-arm": + optional: true + "@esbuild/android-arm64": + optional: true + "@esbuild/android-x64": + optional: true + "@esbuild/darwin-arm64": + optional: true + "@esbuild/darwin-x64": + optional: true + "@esbuild/freebsd-arm64": + optional: true + "@esbuild/freebsd-x64": + optional: true + "@esbuild/linux-arm": + optional: true + "@esbuild/linux-arm64": + optional: true + "@esbuild/linux-ia32": + optional: true + "@esbuild/linux-loong64": + optional: true + "@esbuild/linux-mips64el": + optional: true + "@esbuild/linux-ppc64": + optional: true + "@esbuild/linux-riscv64": + optional: true + "@esbuild/linux-s390x": + optional: true + "@esbuild/linux-x64": + optional: true + "@esbuild/netbsd-x64": + optional: true + "@esbuild/openbsd-arm64": + optional: true + "@esbuild/openbsd-x64": + optional: true + "@esbuild/sunos-x64": + optional: true + "@esbuild/win32-arm64": + optional: true + "@esbuild/win32-ia32": + optional: true + "@esbuild/win32-x64": + optional: true + bin: + esbuild: bin/esbuild + checksum: 10/f55fbd0bfb0f86ce67a6d2c6f6780729d536c330999ecb9f5a38d578fb9fda820acbbc67d6d1d377eed8fed50fc38f14ff9cb014f86dafab94269a7fb2177018 + languageName: node + linkType: hard + "escalade@npm:^3.1.1, escalade@npm:^3.1.2, escalade@npm:^3.2.0": version: 3.2.0 resolution: "escalade@npm:3.2.0" @@ -9120,7 +9414,7 @@ __metadata: languageName: node linkType: hard -"fsevents@npm:^2.3.2, fsevents@npm:~2.3.2": +"fsevents@npm:^2.3.2, fsevents@npm:~2.3.2, fsevents@npm:~2.3.3": version: 2.3.3 resolution: "fsevents@npm:2.3.3" dependencies: @@ -9130,7 +9424,7 @@ __metadata: languageName: node linkType: hard -"fsevents@patch:fsevents@npm%3A^2.3.2#optional!builtin, fsevents@patch:fsevents@npm%3A~2.3.2#optional!builtin": +"fsevents@patch:fsevents@npm%3A^2.3.2#optional!builtin, fsevents@patch:fsevents@npm%3A~2.3.2#optional!builtin, fsevents@patch:fsevents@npm%3A~2.3.3#optional!builtin": version: 2.3.3 resolution: "fsevents@patch:fsevents@npm%3A2.3.3#optional!builtin::version=2.3.3&hash=df0bf1" dependencies: @@ -9254,6 +9548,15 @@ __metadata: languageName: node linkType: hard +"get-tsconfig@npm:^4.7.5": + version: 4.8.1 + resolution: "get-tsconfig@npm:4.8.1" + dependencies: + resolve-pkg-maps: "npm:^1.0.0" + checksum: 10/3fb5a8ad57b9633eaea085d81661e9e5c9f78b35d8f8689eaf8b8b45a2a3ebf3b3422266d4d7df765e308cc1e6231648d114803ab3d018332e29916f2c1de036 + languageName: node + linkType: hard + "getenv@npm:^1.0.0": version: 1.0.0 resolution: "getenv@npm:1.0.0" @@ -11455,6 +11758,13 @@ __metadata: languageName: node linkType: hard +"json-stringify-pretty-compact@npm:^4.0.0": + version: 4.0.0 + resolution: "json-stringify-pretty-compact@npm:4.0.0" + checksum: 10/a10d5c423e467872994a49c5c1b56b073f277ce02d899cf567fc625f3783b89406bee6408bfb3b4bdeeff509b6a562f5259227e26754a6186f721809ca895f0c + languageName: node + linkType: hard + "json5@npm:^1.0.2": version: 1.0.2 resolution: "json5@npm:1.0.2" @@ -12875,7 +13185,7 @@ __metadata: languageName: node linkType: hard -"min-indent@npm:^1.0.0": +"min-indent@npm:^1.0.0, min-indent@npm:^1.0.1": version: 1.0.1 resolution: "min-indent@npm:1.0.1" checksum: 10/bfc6dd03c5eaf623a4963ebd94d087f6f4bbbfd8c41329a7f09706b0cb66969c4ddd336abeb587bc44bc6f08e13bf90f0b374f9d71f9f01e04adc2cd6f083ef1 @@ -12918,7 +13228,7 @@ __metadata: languageName: node linkType: hard -"minimist@npm:^1.2.0, minimist@npm:^1.2.6": +"minimist@npm:^1.2.0, minimist@npm:^1.2.6, minimist@npm:^1.2.8": version: 1.2.8 resolution: "minimist@npm:1.2.8" checksum: 10/908491b6cc15a6c440ba5b22780a0ba89b9810e1aea684e253e43c4e3b8d56ec1dcdd7ea96dde119c29df59c936cde16062159eae4225c691e19c70b432b6e6f @@ -14263,6 +14573,13 @@ __metadata: languageName: node linkType: hard +"quickselect@npm:^2.0.0": + version: 2.0.0 + resolution: "quickselect@npm:2.0.0" + checksum: 10/ed2e78431050d223fb75da20ee98011aef1a03f7cb04e1a32ee893402e640be3cfb76d72e9dbe01edf3bb457ff6a62e5c2d85748424d1aa531f6ba50daef098c + languageName: node + linkType: hard + "range-parser@npm:~1.2.1": version: 1.2.1 resolution: "range-parser@npm:1.2.1" @@ -14304,20 +14621,21 @@ __metadata: languageName: node linkType: hard -"react-docgen@rnmapbox/react-docgen#rnmapbox-dist": - version: 6.0.0-alpha.3 - resolution: "react-docgen@https://github.com/rnmapbox/react-docgen.git#commit=4fd030846ff6b5b84ee39ff1ac07c537ba2e434f" +"react-docgen@npm:^7.1.0": + version: 7.1.0 + resolution: "react-docgen@npm:7.1.0" dependencies: "@babel/core": "npm:^7.18.9" "@babel/traverse": "npm:^7.18.9" "@babel/types": "npm:^7.18.9" + "@types/babel__core": "npm:^7.18.0" "@types/babel__traverse": "npm:^7.18.0" - "@types/doctrine": "npm:^0.0.5" + "@types/doctrine": "npm:^0.0.9" "@types/resolve": "npm:^1.20.2" doctrine: "npm:^3.0.0" resolve: "npm:^1.22.1" - strip-indent: "npm:^3.0.0" - checksum: 10/11c1a0e1a180fb5dd72eb8bb1b4f3cee721cc986dac52e0b5c81c8c7fa30b71d2f7bc3f61b1876c609f71afca520fd27ba7a88b2232a418eb9e23105d4f9856c + strip-indent: "npm:^4.0.0" + checksum: 10/ce1f6e4394375307ecf268ef0b3e41fd75a6b050e70053c6e64b72f108d7606a4b8de6c0f1dab2759bc80864db01be38a9245e2d71024d2ed3d3e0179bd02140 languageName: node linkType: hard @@ -14914,6 +15232,13 @@ __metadata: languageName: node linkType: hard +"resolve-pkg-maps@npm:^1.0.0": + version: 1.0.0 + resolution: "resolve-pkg-maps@npm:1.0.0" + checksum: 10/0763150adf303040c304009231314d1e84c6e5ebfa2d82b7d94e96a6e82bacd1dcc0b58ae257315f3c8adb89a91d8d0f12928241cba2df1680fbe6f60bf99b0e + languageName: node + linkType: hard + "resolve.exports@npm:^2.0.0, resolve.exports@npm:^2.0.2": version: 2.0.2 resolution: "resolve.exports@npm:2.0.2" @@ -15084,6 +15409,13 @@ __metadata: languageName: node linkType: hard +"rw@npm:^1.3.3": + version: 1.3.3 + resolution: "rw@npm:1.3.3" + checksum: 10/e90985d64777a00f4ab5f8c0bfea2fb5645c6bda5238840afa339c8a4f86f776e8ce83731155643a7425a0b27ce89077dab27b2f57519996ba4d2fe54cac1941 + languageName: node + linkType: hard + "sade@npm:^1.7.3": version: 1.8.1 resolution: "sade@npm:1.8.1" @@ -15993,6 +16325,15 @@ __metadata: languageName: node linkType: hard +"strip-indent@npm:^4.0.0": + version: 4.0.0 + resolution: "strip-indent@npm:4.0.0" + dependencies: + min-indent: "npm:^1.0.1" + checksum: 10/06cbcd93da721c46bc13caeb1c00af93a9b18146a1c95927672d2decab6a25ad83662772417cea9317a2507fb143253ecc23c4415b64f5828cef9b638a744598 + languageName: node + linkType: hard + "strip-json-comments@npm:^3.1.1": version: 3.1.1 resolution: "strip-json-comments@npm:3.1.1" @@ -16324,6 +16665,13 @@ __metadata: languageName: node linkType: hard +"tinyqueue@npm:^3.0.0": + version: 3.0.0 + resolution: "tinyqueue@npm:3.0.0" + checksum: 10/44195ae628e98f4de49acefac1fafa63a7f2b5d8a5c23ace6f49917109db3435db8ec9854f87c0d50f8a8c6a73f1526f3941921618a071e4ee1d246afacf69bb + languageName: node + linkType: hard + "tmp@npm:^0.0.33": version: 0.0.33 resolution: "tmp@npm:0.0.33" @@ -16509,6 +16857,22 @@ __metadata: languageName: node linkType: hard +"tsx@npm:^4.19.2": + version: 4.19.2 + resolution: "tsx@npm:4.19.2" + dependencies: + esbuild: "npm:~0.23.0" + fsevents: "npm:~2.3.3" + get-tsconfig: "npm:^4.7.5" + dependenciesMeta: + fsevents: + optional: true + bin: + tsx: dist/cli.mjs + checksum: 10/4c5610ed1fb2f80d766681f8ac7827e1e8118dfe354c18f74800691f3ef1e9ed676a29842ab818806bcf8613cdc97c6af84b5645e768ddb7f4b0527b9100deda + languageName: node + linkType: hard + "type-check@npm:^0.4.0, type-check@npm:~0.4.0": version: 0.4.0 resolution: "type-check@npm:0.4.0" From 8e3d163455bb6c413d7e451ad220b9db6bd5eddc Mon Sep 17 00:00:00 2001 From: Kilian Finger Date: Sun, 27 Oct 2024 19:54:06 +0100 Subject: [PATCH 02/13] refactor: move Annotation component --- javascript/Maplibre.ts | 2 +- javascript/components/{annotations => }/Annotation.tsx | 10 +++++----- javascript/components/UserLocation.tsx | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) rename javascript/components/{annotations => }/Annotation.tsx (92%) diff --git a/javascript/Maplibre.ts b/javascript/Maplibre.ts index e589a53cb..49ca7a5c2 100644 --- a/javascript/Maplibre.ts +++ b/javascript/Maplibre.ts @@ -13,7 +13,7 @@ export { default as MapView, type MapViewRef } from "./components/MapView"; export { default as Light } from "./components/Light"; export { default as PointAnnotation } from "./components/PointAnnotation"; export type { PointAnnotationRef } from "./components/PointAnnotation"; -export { default as Annotation } from "./components/annotations/Annotation"; +export { default as Annotation } from "./components/Annotation"; export { default as Callout } from "./components/Callout"; export { requestAndroidLocationPermissions } from "./requestAndroidLocationPermissions"; export { diff --git a/javascript/components/annotations/Annotation.tsx b/javascript/components/Annotation.tsx similarity index 92% rename from javascript/components/annotations/Annotation.tsx rename to javascript/components/Annotation.tsx index 68057e56a..c06e7b464 100644 --- a/javascript/components/annotations/Annotation.tsx +++ b/javascript/components/Annotation.tsx @@ -6,11 +6,11 @@ import React, { } from "react"; import { Animated as RNAnimated, Easing } from "react-native"; -import OnPressEvent from "../../types/OnPressEvent"; -import { SymbolLayerStyleProps } from "../../utils/MaplibreStyles"; -import { AnimatedShapeSource } from "../../utils/animated/Animated"; -import AnimatedMapPoint from "../../utils/animated/AnimatedPoint"; -import SymbolLayer from "../SymbolLayer"; +import SymbolLayer from "./SymbolLayer"; +import OnPressEvent from "../types/OnPressEvent"; +import { SymbolLayerStyleProps } from "../utils/MaplibreStyles"; +import { AnimatedShapeSource } from "../utils/animated/Animated"; +import AnimatedMapPoint from "../utils/animated/AnimatedPoint"; interface AnnotationProps { id: string; diff --git a/javascript/components/UserLocation.tsx b/javascript/components/UserLocation.tsx index 1651e7963..77fd9bb79 100644 --- a/javascript/components/UserLocation.tsx +++ b/javascript/components/UserLocation.tsx @@ -1,9 +1,9 @@ import React, { ReactElement, useEffect, useImperativeHandle } from "react"; +import Annotation from "./Annotation"; import CircleLayer from "./CircleLayer"; import HeadingIndicator from "./HeadingIndicator"; import NativeUserLocation from "./NativeUserLocation"; -import Annotation from "./annotations/Annotation"; import locationManager, { Location } from "../modules/location/locationManager"; import { CircleLayerStyleProps } from "../utils/MaplibreStyles"; From 9dea9b6dd3a1efa9d0f43a7ec822e132a065221d Mon Sep 17 00:00:00 2001 From: Kilian Finger Date: Sun, 27 Oct 2024 19:54:29 +0100 Subject: [PATCH 03/13] chore: replace node-dir --- package.json | 1 - scripts/utils/DocJSONBuilder.ts | 166 +++++++++++++++----------------- yarn.lock | 3 +- 3 files changed, 79 insertions(+), 91 deletions(-) diff --git a/package.json b/package.json index a03b6ec41..d7dfc418d 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,6 @@ "jest": "^29.7.0", "jest-cli": "^29.7.0", "lint-staged": "^15.2.2", - "node-dir": "0.1.17", "pinst": "^3.0.0", "prettier": "3.3.3", "react": "18.2.0", diff --git a/scripts/utils/DocJSONBuilder.ts b/scripts/utils/DocJSONBuilder.ts index d403b8991..e06f5e031 100644 --- a/scripts/utils/DocJSONBuilder.ts +++ b/scripts/utils/DocJSONBuilder.ts @@ -1,6 +1,5 @@ import { exec } from "child_process"; -import dir from "node-dir"; -import fs from "node:fs"; +import { promises as fs } from "node:fs"; import path from "node:path"; import * as docgen from "react-docgen"; import { parseJsDoc } from "react-docgen/dist/utils"; @@ -19,12 +18,6 @@ const COMPONENT_PATH = path.join( const MODULES_PATH = path.join(__dirname, "..", "..", "javascript", "modules"); const OUTPUT_PATH = path.join(__dirname, "..", "..", "docs", "docs.json"); -const IGNORE_FILES = [ - "AbstractLayer", - "AbstractSource", - "NativeBridgeComponent", -]; -const IGNORE_PATTERN = /\.web\./; const IGNORE_METHODS = ["setNativeProps"]; const fileExtensionsRegex = /.(js|tsx|(? { - dir.readFiles( - filePath, - this.options, - (err, content, fileNameWithExt, next) => { - if (err) { - return reject(err); - } + async generateReactComponentsTask(results: any, directoryPath: string) { + const filesNames = await fs.readdir(directoryPath); - let fileName = fileNameWithExt.replace(/\.(js|tsx|ts$)/, ""); - if ( - IGNORE_FILES.includes(fileName) || - fileName.match(IGNORE_PATTERN) - ) { - next(); - return; - } + const files = await Promise.all( + filesNames.map(async (base) => { + return { + base, + content: await fs.readFile(path.join(directoryPath, base), "utf-8"), + }; + }), + ); - const parsedComponents = docgen.parse(content, { - babelOptions: { - filename: fileNameWithExt, - }, - }); - const [parsed] = parsedComponents; - fileName = fileName.replace(fileExtensionsRegex, ""); - parsed.fileNameWithExt = fileNameWithExt; - results[fileName] = parsed; + files.forEach(({ base, content }) => { + const parsedComponents = docgen.parse(content, { + babelOptions: { + filename: base, + }, + }); - this.postprocess(results[fileName], fileName); + const [parsed] = parsedComponents; - return next(); - }, - () => resolve(), - ); + parsed.fileNameWithExt = base; + results[path.parse(base).name] = parsed; + + this.postprocess(results[path.parse(base).name], path.parse(base).name); }); } - generateModulesTask(results, filePath) { + async generateModulesTask(results, directoryPath) { return new Promise((resolve, reject) => { exec( `yarn run documentation build ${MODULES_PATH} -f json`, @@ -427,32 +422,27 @@ export class DocJSONBuilder { }); } - sortObject(not_sorted) { - return Object.keys(not_sorted) + sortObject(unsorted: Record) { + return Object.keys(unsorted) .sort() .reduce( (acc, key) => ({ ...acc, - [key]: not_sorted[key], + [key]: unsorted[key], }), {}, ); } async generate() { - this.generateModulesTask({}, MODULES_PATH); - const results = {}; - return Promise.all([ - this.generateReactComponentsTask(results, COMPONENT_PATH), - this.generateModulesTask(results, MODULES_PATH), - ]).then(() => { - fs.writeFileSync( - OUTPUT_PATH, - JSON.stringify(this.sortObject(results), null, 2), - ); - return true; - }); + await this.generateReactComponentsTask(results, COMPONENT_PATH); + await this.generateModulesTask(results, MODULES_PATH); + + await fs.writeFile( + OUTPUT_PATH, + JSON.stringify(this.sortObject(results), null, 2), + ); } } diff --git a/yarn.lock b/yarn.lock index 5b54bfef6..7c80aae5a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3438,7 +3438,6 @@ __metadata: jest: "npm:^29.7.0" jest-cli: "npm:^29.7.0" lint-staged: "npm:^15.2.2" - node-dir: "npm:0.1.17" pinst: "npm:^3.0.0" prettier: "npm:3.3.3" react: "npm:18.2.0" @@ -13482,7 +13481,7 @@ __metadata: languageName: node linkType: hard -"node-dir@npm:0.1.17, node-dir@npm:^0.1.17": +"node-dir@npm:^0.1.17": version: 0.1.17 resolution: "node-dir@npm:0.1.17" dependencies: From bac836e5c26e1a63407bfa165b789bd17935fc28 Mon Sep 17 00:00:00 2001 From: Kilian Finger Date: Tue, 5 Nov 2024 07:32:26 +0100 Subject: [PATCH 04/13] style: ignore unused catch error --- scripts/generate-docs.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/generate-docs.ts b/scripts/generate-docs.ts index d1869bb30..c86c0ca5c 100644 --- a/scripts/generate-docs.ts +++ b/scripts/generate-docs.ts @@ -326,6 +326,7 @@ async function generate() { exec( `git diff --exit-code docs/ ${TEMPLATE_MAPPINGS.map((m) => m.output).join(" ")}`, ); + // eslint-disable-next-line @typescript-eslint/no-unused-vars } catch (_error) { console.error( "\n\nThere are unstaged changes in the generated code. " + From 922fe9a793c5da6020d7e53c4bd175bf7257465e Mon Sep 17 00:00:00 2001 From: Kilian Finger Date: Tue, 5 Nov 2024 08:02:23 +0100 Subject: [PATCH 05/13] refactor: rename generate to codegen --- .github/pull_request_template.md | 2 +- .github/workflows/on-push.yml | 4 ++-- .husky/pre-commit | 2 +- CONTRIBUTING.md | 2 +- package.json | 2 +- scripts/{generate-docs.ts => codegen.ts} | 0 6 files changed, 6 insertions(+), 6 deletions(-) rename scripts/{generate-docs.ts => codegen.ts} (100%) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 87d456f94..0bb70ea77 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -20,7 +20,7 @@ Added `your feature` that allows ... - [ ] I have tested this on a device/simulator for each compatible OS - [ ] I formatted JS and TS files with running `yarn lint:eslint:fix` in the root folder - [ ] I have run tests via `yarn test` in the root folder -- [ ] I updated the documentation with running `yarn generate` in the root folder +- [ ] I updated the documentation with running `yarn codegen` in the root folder - [ ] I mentioned this change in `CHANGELOG.md` - [ ] I added/updated a sample (`/packages/examples`) diff --git a/.github/workflows/on-push.yml b/.github/workflows/on-push.yml index 24c010fe4..597d17318 100644 --- a/.github/workflows/on-push.yml +++ b/.github/workflows/on-push.yml @@ -33,8 +33,8 @@ jobs: - name: Run test with Jest run: yarn test - - name: Generate - run: yarn generate + - name: Codegen + run: yarn codegen - name: Pack (to ensure the plugin builds) run: yarn pack diff --git a/.husky/pre-commit b/.husky/pre-commit index f6698f7fc..8b533e0f3 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -2,4 +2,4 @@ . "$(dirname -- "$0")/_/husky.sh" yarn lint-staged -yarn generate \ No newline at end of file +yarn codegen \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9d7807e0b..ea5eedf00 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,7 +55,7 @@ can mitigate some of the pain with this. Documentation is generated from code blocks and comments. It will be auto-generated when you commit changes. If any changes are generated from your edits, the changed files will need to be added using `git add` before attempting the -commit again. To manually generate the changes, run `yarn generate`. +commit again. To manually generate the changes, run `yarn codegen`. Notice, that changing the documentation in the individual .md within `/docs` will not suffice. The correct way is the above described diff --git a/package.json b/package.json index d7dfc418d..c2324f72f 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "url": "https://github.com/maplibre/maplibre-react-native" }, "scripts": { - "generate": "tsx scripts/generate-docs.ts", + "codegen": "tsx scripts/codegen.ts", "test": "jest", "lint": "yarn lint:eslint && yarn lint:tsc", "lint:eslint": "eslint .", diff --git a/scripts/generate-docs.ts b/scripts/codegen.ts similarity index 100% rename from scripts/generate-docs.ts rename to scripts/codegen.ts From fceb5ef7a775a0da3e3a5c596952130b65a69d63 Mon Sep 17 00:00:00 2001 From: Kilian Finger Date: Tue, 5 Nov 2024 08:02:41 +0100 Subject: [PATCH 06/13] chore: remove unused @tsconfig/node14 --- package.json | 1 - yarn.lock | 8 -------- 2 files changed, 9 deletions(-) diff --git a/package.json b/package.json index c2324f72f..3ef1d457b 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,6 @@ "@react-native/metro-config": "^0.74.88", "@sinonjs/fake-timers": "^11.2.2", "@testing-library/react-native": "^12.4.3", - "@tsconfig/node14": "^14.1.0", "@types/ejs": "^3.1.5", "@typescript-eslint/eslint-plugin": "^7.18.0", "@typescript-eslint/parser": "^7.18.0", diff --git a/yarn.lock b/yarn.lock index 7c80aae5a..5947d050d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3412,7 +3412,6 @@ __metadata: "@react-native/metro-config": "npm:^0.74.88" "@sinonjs/fake-timers": "npm:^11.2.2" "@testing-library/react-native": "npm:^12.4.3" - "@tsconfig/node14": "npm:^14.1.0" "@turf/distance": "npm:^7.1.0" "@turf/helpers": "npm:^7.1.0" "@turf/length": "npm:^7.1.0" @@ -4617,13 +4616,6 @@ __metadata: languageName: node linkType: hard -"@tsconfig/node14@npm:^14.1.0": - version: 14.1.2 - resolution: "@tsconfig/node14@npm:14.1.2" - checksum: 10/f5934cebc6c8790b28a145d8abbafcb0bd23a405ebcb790bd9f524a2750757d5675b418583bddaed760894a18a0a59a8cbfec1979c90e388d7ad784a9519193f - languageName: node - linkType: hard - "@tsconfig/node18@npm:^18.2.2": version: 18.2.4 resolution: "@tsconfig/node18@npm:18.2.4" From f5555b3e26d55060781805bb74f8011c1cab6837 Mon Sep 17 00:00:00 2001 From: Kilian Finger Date: Tue, 5 Nov 2024 08:05:29 +0100 Subject: [PATCH 07/13] docs: add filePath to generated hint --- scripts/templates/component.md.ejs | 2 +- scripts/utils/DocJSONBuilder.ts | 46 ++++++++++++++++-------------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/scripts/templates/component.md.ejs b/scripts/templates/component.md.ejs index 80f3a54d1..0bd51808d 100644 --- a/scripts/templates/component.md.ejs +++ b/scripts/templates/component.md.ejs @@ -1,7 +1,7 @@ <% const component = locals.component; -%> - + ## /> ### <%- replaceNewLine(component.description) %> diff --git a/scripts/utils/DocJSONBuilder.ts b/scripts/utils/DocJSONBuilder.ts index e06f5e031..c5ce8b2f5 100644 --- a/scripts/utils/DocJSONBuilder.ts +++ b/scripts/utils/DocJSONBuilder.ts @@ -7,16 +7,15 @@ import { parseJsDoc } from "react-docgen/dist/utils"; import { JSDocNodeTree } from "./JSDocNodeTree"; import { pascalCase } from "./template-globals"; -const COMPONENT_PATH = path.join( - __dirname, - "..", - "..", +const WORKSPACE_ROOT = path.join(__dirname, "..", ".."); + +const COMPONENT_DIRECTORY = path.join( + WORKSPACE_ROOT, "javascript", "components", ); - -const MODULES_PATH = path.join(__dirname, "..", "..", "javascript", "modules"); -const OUTPUT_PATH = path.join(__dirname, "..", "..", "docs", "docs.json"); +const MODULES_DIRECTORY = path.join(WORKSPACE_ROOT, "javascript", "modules"); +const OUTPUT_PATH = path.join(WORKSPACE_ROOT, "docs", "docs.json"); const IGNORE_METHODS = ["setNativeProps"]; @@ -358,14 +357,17 @@ export class DocJSONBuilder { ); } - async generateReactComponentsTask(results: any, directoryPath: string) { - const filesNames = await fs.readdir(directoryPath); + async generateReactComponentsTask(results: Record) { + const filesNames = await fs.readdir(COMPONENT_DIRECTORY); const files = await Promise.all( filesNames.map(async (base) => { return { base, - content: await fs.readFile(path.join(directoryPath, base), "utf-8"), + content: await fs.readFile( + path.join(COMPONENT_DIRECTORY, base), + "utf-8", + ), }; }), ); @@ -379,17 +381,22 @@ export class DocJSONBuilder { const [parsed] = parsedComponents; - parsed.fileNameWithExt = base; - results[path.parse(base).name] = parsed; + results[path.parse(base).name] = { + ...parsed, + filePath: path.relative( + WORKSPACE_ROOT, + path.join(COMPONENT_DIRECTORY, base), + ), + }; this.postprocess(results[path.parse(base).name], path.parse(base).name); }); } - async generateModulesTask(results, directoryPath) { - return new Promise((resolve, reject) => { + async generateModulesTask(results: Record) { + return new Promise((resolve, reject) => { exec( - `yarn run documentation build ${MODULES_PATH} -f json`, + `yarn run documentation build ${MODULES_DIRECTORY} -f json`, (err, stdout, stderr) => { if (err || stderr) { reject(err || stderr); @@ -403,12 +410,9 @@ export class DocJSONBuilder { .charAt(0) .toLowerCase()}${module.name.substring(1)}`; - const pathParts = module.context.file.split("/"); - const fileNameWithExt = pathParts[pathParts.length - 1]; - results[name] = { name, - fileNameWithExt, + filePath: path.relative(WORKSPACE_ROOT, module.context.file), description: node.getText(), props: [], styles: [], @@ -437,8 +441,8 @@ export class DocJSONBuilder { async generate() { const results = {}; - await this.generateReactComponentsTask(results, COMPONENT_PATH); - await this.generateModulesTask(results, MODULES_PATH); + await this.generateReactComponentsTask(results); + await this.generateModulesTask(results); await fs.writeFile( OUTPUT_PATH, From 8126b7b05eced53e2099e8d8ac5934cb84f78740 Mon Sep 17 00:00:00 2001 From: Kilian Finger Date: Tue, 5 Nov 2024 08:50:18 +0100 Subject: [PATCH 08/13] docs: fix TypeScript problems --- scripts/utils/DocJSONBuilder.ts | 43 ++++++++++------- scripts/utils/template-globals.ts | 76 +++++++++++++++---------------- 2 files changed, 65 insertions(+), 54 deletions(-) diff --git a/scripts/utils/DocJSONBuilder.ts b/scripts/utils/DocJSONBuilder.ts index c5ce8b2f5..f2cc69ea0 100644 --- a/scripts/utils/DocJSONBuilder.ts +++ b/scripts/utils/DocJSONBuilder.ts @@ -60,7 +60,7 @@ export class DocJSONBuilder { component.name = name; // Main description - component.description = component.description.replace( + component.description = component.description?.replace( /(\n*)(@\w+) (\{.*})/g, "", ); @@ -133,11 +133,11 @@ export class DocJSONBuilder { return tsType.raw.replace(/\|/g, "\\|"); } else if (tsType.elements) { // Methods - return tsType.elements.map((e) => e.name).join(" \\| "); + return tsType.elements.map((element) => element.name).join(" \\| "); } - } else { - return tsType.name; } + + return tsType.name; } type TSTypeType = { @@ -158,6 +158,13 @@ export class DocJSONBuilder { interface TSVoidType extends TSTypeType { name: "void"; + type: never; + } + + interface TSUnionType extends TSTypeType { + name: "union"; + type: never; + elements: any[]; } interface TSFunctionType extends TSTypeType { @@ -172,7 +179,7 @@ export class DocJSONBuilder { signature: TSObjectSignature; } - type TSType = TSVoidType | TSFunctionType | TSObjectType; + type TSType = TSVoidType | TSUnionType | TSFunctionType | TSObjectType; function tsTypeIsFunction(tsType: TSType): tsType is TSFunctionType { return "type" in tsType && tsType.type === "function"; @@ -198,8 +205,8 @@ export class DocJSONBuilder { } } - function tsTypeDescType(tsType: TSType) { - if (!tsType?.name) { + function tsTypeDescType(tsType?: TSType) { + if (!tsType) { return null; } @@ -231,13 +238,17 @@ export class DocJSONBuilder { // Methods return tsType.elements.map((e) => e.name).join(" \\| "); } - } else { - return tsType.name; } + + return tsType.name; } - function mapProp(propMeta, propName, array) { - let result = {}; + function mapProp( + propMeta: any, + propName: string | undefined, + array: boolean, + ) { + let result: Record = {}; if (!array) { result = { name: propName || "FIX ME NO NAME", @@ -332,8 +343,8 @@ export class DocJSONBuilder { if (method.docblock) { const examples = method.docblock .split("@") - .filter((block) => block.startsWith("example")); - method.examples = examples.map((example) => + .filter((block: string) => block.startsWith("example")); + method.examples = examples.map((example: any) => example.substring("example".length), ); } @@ -341,11 +352,11 @@ export class DocJSONBuilder { privateMethods.push(...IGNORE_METHODS); component.methods = component.methods.filter( - (method) => !privateMethods.includes(method.name), + (method: any) => !privateMethods.includes(method.name), ); - component.methods.forEach((method) => { - method.params.forEach((param) => { + component.methods.forEach((method: any) => { + method.params.forEach((param: any) => { param.type = { name: tsTypeDesc(param.type) }; }); }); diff --git a/scripts/utils/template-globals.ts b/scripts/utils/template-globals.ts index 851db6134..47dc4cf8d 100644 --- a/scripts/utils/template-globals.ts +++ b/scripts/utils/template-globals.ts @@ -1,6 +1,6 @@ -const iosPropNameOverrides = {}; +const iosPropNameOverrides: Record = {}; -const iosSpecOverrides = { +const iosSpecOverrides: Record = { "icon-allow-overlap": "icon-allows-overlap", "icon-image": "icon-image-name", "icon-ignore-placement": "icon-ignores-placement", @@ -40,19 +40,19 @@ const iosSpecOverrides = { "text-writing-mode": "text-writing-modes", }; -function exists(value) { +function exists(value: T): value is NonNullable { return typeof value !== "undefined" && value !== null; } global.exists = exists; -global.getValue = function (value, defaultValue) { +global.getValue = function (value: any, defaultValue: any) { if (!exists(value) || value === "") { return defaultValue; } return value; }; -export function camelCase(str, delimiter = "-") { +export function camelCase(str: string, delimiter = "-") { const parts = str.split(delimiter); return parts .map((part, index) => { @@ -65,7 +65,7 @@ export function camelCase(str, delimiter = "-") { } global.camelCase = camelCase; -export function pascalCase(str, delimiter = "-") { +export function pascalCase(str: string, delimiter = "-") { const parts = str.split(delimiter); return parts .map((part) => { @@ -75,14 +75,14 @@ export function pascalCase(str, delimiter = "-") { } global.pascalCase = pascalCase; -global.setLayerMethodName = function (layer, platform) { +global.setLayerMethodName = function (layer: any, platform: "android" | "ios") { if (platform === "ios") { return `${camelCase(layer.name)}Layer`; } return `set${pascalCase(layer.name)}LayerStyle`; }; -global.getLayerType = function (layer, platform) { +global.getLayerType = function (layer: any, platform: "android" | "ios") { const isIOS = platform === "ios"; switch (layer.name) { @@ -113,18 +113,18 @@ global.getLayerType = function (layer, platform) { } }; -global.ifOrElseIf = function (index) { +global.ifOrElseIf = function (index: number) { if (index === 0) { return "if"; } return "} else if"; }; -global.iosStringArrayLiteral = function (arr) { - return `@[@${arr.map((item) => `"${item}"`).join(", @")}]`; +global.iosStringArrayLiteral = function (array: string[]) { + return `@[@${array.map((item) => `"${item}"`).join(", @")}]`; }; -function iosPropName(name) { +function iosPropName(name: string) { if (name.indexOf("visibility") !== -1) { return "visible"; } @@ -139,7 +139,7 @@ function iosPropName(name) { global.iosPropName = iosPropName; -global.iosMapLibrePropName = function (name) { +global.iosMapLibrePropName = function (name: string) { const result = iosPropName(name); if (result === "fillExtrusionVerticalGradient") { return "fillExtrusionHasVerticalGradient"; @@ -147,14 +147,14 @@ global.iosMapLibrePropName = function (name) { return undefined; }; -global.iosPropMethodName = function (layer, name) { +global.iosPropMethodName = function (layer: any, name: string) { if (name.indexOf("Visibility") !== -1) { return pascalCase(layer.name) + "StyleLayer" + name; } return name; }; -function androidInputType(type, value) { +function androidInputType(type: string, value?: string) { if (type === "array" && value) { return `${androidInputType(value)}[]`; } @@ -173,7 +173,7 @@ function androidInputType(type, value) { global.androidInputType = androidInputType; -function androidOutputType(type, value) { +function androidOutputType(type: string, value?: any): string { if (type === "array" && value) { return `${androidOutputType(value)}[]`; } @@ -192,7 +192,7 @@ function androidOutputType(type, value) { global.androidOutputType = androidOutputType; -global.androidGetConfigType = function (androidType, prop) { +global.androidGetConfigType = function (androidType: string, prop: any) { switch (androidType) { case "Integer": return "styleValue.getInt(VALUE_KEY)"; @@ -213,7 +213,7 @@ global.androidGetConfigType = function (androidType, prop) { } }; -global.jsStyleType = function (prop) { +global.jsStyleType = function (prop: any) { if (prop.type === "color") { return "StyleTypes.Color"; } @@ -237,7 +237,7 @@ global.jsStyleType = function (prop) { return "StyleTypes.Constant"; }; -global.jsDocPropRequires = function (prop) { +global.jsDocPropRequires = function (prop: any) { if (!prop.doc.requires) { return; } @@ -252,11 +252,11 @@ global.jsDocPropRequires = function (prop) { return desc; }; -global.getEnums = function (layers) { - const result = {}; +global.getEnums = function (layers: any[]) { + const result: Record = {}; layers.forEach((layer) => { - layer.properties.forEach((property) => { + layer.properties.forEach((property: any) => { if ( property.type === "enum" || (property.type === "array" && property.value === "enum") @@ -271,8 +271,8 @@ global.getEnums = function (layers) { return Object.values(result); }; -global.dtsInterfaceType = function (prop) { - const propTypes = []; +global.dtsInterfaceType = function (prop: any) { + const propTypes: string[] = []; if (prop.name.indexOf("Translate") !== -1 && prop.type !== "enum") { propTypes.push("Translation"); @@ -332,7 +332,7 @@ ${startAtSpace(2, "")}`; let params = ""; if (prop.expression && prop.expression.parameters) { params = `,[${prop.expression.parameters - .map((v) => `'${v}'`) + .map((v: string) => `'${v}'`) .join(",")}]`; } return `Value<${propTypes[0]}${params}>`; @@ -342,7 +342,7 @@ ${startAtSpace(2, "")}`; } }; -global.jsDocReactProp = function (prop) { +global.jsDocReactProp = function (prop: any) { const propTypes = []; if (prop.type === "color") { @@ -396,7 +396,7 @@ ${startAtSpace(2, "])")}`; } }; -function startAtSpace(spaceCount, str) { +function startAtSpace(spaceCount: number, str: string) { let value = ""; for (let i = 0; i < spaceCount; i++) { @@ -408,13 +408,13 @@ function startAtSpace(spaceCount, str) { global.startAtSpace = startAtSpace; -export function replaceNewLine(str) { +export function replaceNewLine(str: string) { return str?.replace(/\n/g, "
"); } global.replaceNewLine = replaceNewLine; -global.styleMarkdownTableRow = function (style) { +global.styleMarkdownTableRow = function (style: any) { return `| \`${style.name}\` | \`${style.type}\` | \`${ style.requires.join(", ") || "none" }\` | \`${style.disabledBy.join(", ") || "none"}\` | ${replaceNewLine( @@ -422,9 +422,9 @@ global.styleMarkdownTableRow = function (style) { )} |`; }; -global.methodMarkdownTableRow = function (method) { +global.methodMarkdownTableRow = function (method: any) { return method.params - .map((param) => { + .map((param: any) => { return `| \`${param.name}\` | \`${ (param.type && param.type.name) || "n/a" }\` | \`${param.optional ? "No" : "Yes"}\` | ${replaceNewLine( @@ -434,7 +434,7 @@ global.methodMarkdownTableRow = function (method) { .join("\n"); }; -function _propMarkdownTableRows(props, prefix = "") { +function _propMarkdownTableRows(props: any[], prefix = "") { return props .map((prop) => { let { type } = prop; @@ -462,13 +462,13 @@ function _propMarkdownTableRows(props, prefix = "") { .join("\n"); } -global.propMarkdownTableRows = function (component) { +global.propMarkdownTableRows = function (component: any) { return _propMarkdownTableRows(component.props, ""); }; -global.getMarkdownMethodSignature = function (method) { +global.getMarkdownMethodSignature = function (method: any) { const params = method.params - .map((param, i) => { + .map((param: any, i: number) => { const isOptional = param.optional; let name = ""; @@ -485,12 +485,12 @@ global.getMarkdownMethodSignature = function (method) { return `${method.name}(${params})`; }; -global.getMarkdownMethodExamples = function (method) { +global.getMarkdownMethodExamples = function (method: any) { if (method.examples == null) { return null; } return method.examples - .map((example) => { + .map((example: string) => { return ` \`\`\`javascript @@ -502,7 +502,7 @@ ${example.trim()} .join(""); }; -global.getStyleDefaultValue = function (style) { +global.getStyleDefaultValue = function (style: any) { if (style.type === "string" && style.default === "") { return "empty string"; } else if (style.type.includes("array")) { From abfa714e1103de4263e06c8be38d6f82579fa4ab Mon Sep 17 00:00:00 2001 From: Kilian Finger Date: Tue, 5 Nov 2024 08:50:26 +0100 Subject: [PATCH 09/13] docs: add do not modify header --- scripts/templates/component.md.ejs | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/templates/component.md.ejs b/scripts/templates/component.md.ejs index 0bd51808d..0464f0ed0 100644 --- a/scripts/templates/component.md.ejs +++ b/scripts/templates/component.md.ejs @@ -1,6 +1,7 @@ <% const component = locals.component; -%> + ## /> ### <%- replaceNewLine(component.description) %> From bde35b1a19d9ae5a9235c33712f5c3624d145b9a Mon Sep 17 00:00:00 2001 From: Kilian Finger Date: Tue, 5 Nov 2024 09:14:36 +0100 Subject: [PATCH 10/13] docs: pass TemplateHelpders as local --- scripts/codegen.ts | 5 +- scripts/templates/MaplibreStyles.ts.ejs | 15 +-- scripts/templates/RCTMLNStyle.h.ejs | 7 +- scripts/templates/RCTMLNStyle.m.ejs | 21 ++-- scripts/templates/RCTMLNStyleFactory.java.ejs | 23 ++--- scripts/templates/component.md.ejs | 23 ++--- scripts/templates/index.d.ts.ejs | 3 +- scripts/templates/styleMap.ts.ejs | 3 +- scripts/utils/DocJSONBuilder.ts | 2 +- scripts/utils/MarkdownBuilder.ts | 7 +- ...template-globals.ts => TemplateHelpers.ts} | 99 ++++++++----------- 11 files changed, 104 insertions(+), 104 deletions(-) rename scripts/utils/{template-globals.ts => TemplateHelpers.ts} (87%) diff --git a/scripts/codegen.ts b/scripts/codegen.ts index c86c0ca5c..427196304 100644 --- a/scripts/codegen.ts +++ b/scripts/codegen.ts @@ -7,12 +7,13 @@ import prettier from "prettier"; import { DocJSONBuilder } from "./utils/DocJSONBuilder"; import { MarkdownBuilder } from "./utils/MarkdownBuilder"; +import { camelCase } from "./utils/TemplateHelpers"; +import * as TemplateHelpers from "./utils/TemplateHelpers"; import { getAndroidVersion, getIosVersion, isVersionGTE, } from "./utils/getNativeVersion"; -import { camelCase } from "./utils/template-globals"; const TMPL_PATH = path.join(__dirname, "templates"); @@ -299,7 +300,7 @@ async function generate() { strict: true, async: true, }); - let results = await tmpl({ layers }); + let results = await tmpl({ layers, helpers: TemplateHelpers }); if (filename.endsWith("ts")) { results = await prettier.format(results, { filepath: filename, diff --git a/scripts/templates/MaplibreStyles.ts.ejs b/scripts/templates/MaplibreStyles.ts.ejs index a67958be1..5a3ab27d4 100644 --- a/scripts/templates/MaplibreStyles.ts.ejs +++ b/scripts/templates/MaplibreStyles.ts.ejs @@ -1,5 +1,6 @@ <% const layers = locals.layers; + const helpers = locals.helpers; -%> /* This file was generated from MapboxStyle.ts.ejs do not modify */ import { type ImageSourcePropType } from 'react-native'; @@ -58,20 +59,20 @@ export type Value = | T | Expression; -<%_ for (let enumInfo of getEnums(layers)) { _%> - enum <%- pascalCase(enumInfo.name) %>Enum { +<%_ for (let enumInfo of helpers.getEnums(layers)) { _%> + enum <%- helpers.pascalCase(enumInfo.name) %>Enum { <%_ for (let k of Object.keys(enumInfo.values)) { _%> /** <%- enumInfo.values[k].doc %> */ - <%- pascalCase(k) %> = '<%- k %>', + <%- helpers.pascalCase(k) %> = '<%- k %>', <%_ } _%> } - type <%- pascalCase(enumInfo.name) %>EnumValues = <%- Object.keys(enumInfo.values).map(k => `'${k}'`).join(' | ') %>; + type <%- helpers.pascalCase(enumInfo.name) %>EnumValues = <%- Object.keys(enumInfo.values).map(k => `'${k}'`).join(' | ') %>; <%_ } _%> type Enum = EnumType | EnumValues; <%_ for (let layer of layers) { _%> - export interface <%- pascalCase(layer.name) %>LayerStyleProps { + export interface <%- helpers.pascalCase(layer.name) %>LayerStyleProps { <%_ for (let prop of layer.properties) { _%> /** * <%- prop.doc.description %> @@ -84,7 +85,7 @@ type Enum = EnumType | EnumValues; * @disabledBy <%- prop.doc.disabledBy.join(', ') %> <%_ } _%> */ - <%= prop.name %>?: <%- dtsInterfaceType(prop) %> + <%= prop.name %>?: <%- helpers.dtsInterfaceType(prop) %> <%_ if (true && prop.transition) { %> /** * The transition affecting any changes to this layer’s <%= prop.name %> property. @@ -96,4 +97,4 @@ type Enum = EnumType | EnumValues; }; <%_ } _%> -export type AllLayerStyleProps = <%- layers.map(l => `${pascalCase(l.name)}LayerStyleProps`).join("|") -%>; \ No newline at end of file +export type AllLayerStyleProps = <%- layers.map(l => `${helpers.pascalCase(l.name)}LayerStyleProps`).join("|") -%>; \ No newline at end of file diff --git a/scripts/templates/RCTMLNStyle.h.ejs b/scripts/templates/RCTMLNStyle.h.ejs index 4a658de16..373730624 100644 --- a/scripts/templates/RCTMLNStyle.h.ejs +++ b/scripts/templates/RCTMLNStyle.h.ejs @@ -1,5 +1,6 @@ <% const layers = locals.layers; + const helpers = locals.helpers; -%> // DO NOT MODIFY // THIS FILE IS AUTOGENERATED @@ -18,14 +19,14 @@ - (id)initWithMLNStyle:(MLNStyle*)mlnStyle; <%_ for (const layer of layers) { _%> -- (void)<%- setLayerMethodName(layer, 'ios') -%>:(<%- getLayerType(layer, 'ios') -%> *)layer withReactStyle:(NSDictionary *)reactStyle isValid:(BOOL (^)(void)) isValid; +- (void)<%- helpers.setLayerMethodName(layer, 'ios') -%>:(<%- helpers.getLayerType(layer, 'ios') -%> *)layer withReactStyle:(NSDictionary *)reactStyle isValid:(BOOL (^)(void)) isValid; <%_ } _%> <%_ for (const layer of layers) { _%> <%_ for (const prop of layer.properties) { _%> -- (void)set<%- iosPropMethodName(layer, pascalCase(prop.name)) -%>:(<%- getLayerType(layer, 'ios') -%> *)layer withReactStyleValue:(RCTMLNStyleValue *)styleValue; +- (void)set<%- helpers.iosPropMethodName(layer, helpers.pascalCase(prop.name)) -%>:(<%- helpers.getLayerType(layer, 'ios') -%> *)layer withReactStyleValue:(RCTMLNStyleValue *)styleValue; <%_ if (prop.transition) { _%> -- (void)set<%- iosPropMethodName(layer, pascalCase(prop.name)) -%>Transition:(<%- getLayerType(layer, 'ios') -%> *)layer withReactStyleValue:(RCTMLNStyleValue *)styleValue; +- (void)set<%- helpers.iosPropMethodName(layer, helpers.pascalCase(prop.name)) -%>Transition:(<%- helpers.getLayerType(layer, 'ios') -%> *)layer withReactStyleValue:(RCTMLNStyleValue *)styleValue; <%_ } _%> <%_ } _%> <% } %> diff --git a/scripts/templates/RCTMLNStyle.m.ejs b/scripts/templates/RCTMLNStyle.m.ejs index 1732557a3..d21828f4e 100644 --- a/scripts/templates/RCTMLNStyle.m.ejs +++ b/scripts/templates/RCTMLNStyle.m.ejs @@ -1,5 +1,6 @@ <% const layers = locals.layers; + const helpers = locals.helpers; -%> // DO NOT MODIFY // THIS FILE IS AUTOGENERATED @@ -18,7 +19,7 @@ } <% for (const layer of layers) { %> -- (void)<%- setLayerMethodName(layer, 'ios') -%>:(<%- getLayerType(layer, 'ios') -%> *)layer withReactStyle:(NSDictionary *)reactStyle isValid:(BOOL (^)(void)) isValid +- (void)<%- helpers.setLayerMethodName(layer, 'ios') -%>:(<%- helpers.getLayerType(layer, 'ios') -%> *)layer withReactStyle:(NSDictionary *)reactStyle isValid:(BOOL (^)(void)) isValid { if (![self _hasReactStyle:reactStyle]) { // TODO throw exception @@ -34,10 +35,10 @@ RCTMLNStyleValue *styleValue = [RCTMLNStyleValue make:reactStyle[prop]]; <% for (let i = 0; i < layer.properties.length; i++) { -%> - <%- ifOrElseIf(i) -%> ([prop isEqualToString:@"<%= layer.properties[i].name %>"]) { + <%- helpers.ifOrElseIf(i) -%> ([prop isEqualToString:@"<%= layer.properties[i].name %>"]) { <%_ if (layer.properties[i].image) { _%> if (![styleValue shouldAddImage]) { - [self set<%- iosPropMethodName(layer, pascalCase(layer.properties[i].name)) -%>:layer withReactStyleValue:styleValue]; + [self set<%- helpers.iosPropMethodName(layer, helpers.pascalCase(layer.properties[i].name)) -%>:layer withReactStyleValue:styleValue]; } else { NSString *imageURI = [styleValue getImageURI]; @@ -46,18 +47,18 @@ dispatch_async(dispatch_get_main_queue(), ^{ if (isValid()) { [self->_style setImage:image forName:imageURI]; - [self set<%- iosPropMethodName(layer, pascalCase(layer.properties[i].name)) -%>:layer withReactStyleValue:styleValue]; + [self set<%- helpers.iosPropMethodName(layer, helpers.pascalCase(layer.properties[i].name)) -%>:layer withReactStyleValue:styleValue]; } }); } }]; } <%_ } else { _%> - [self set<%- iosPropMethodName(layer, pascalCase(layer.properties[i].name)) -%>:layer withReactStyleValue:styleValue]; + [self set<%- helpers.iosPropMethodName(layer, helpers.pascalCase(layer.properties[i].name)) -%>:layer withReactStyleValue:styleValue]; <%_ } _%> <%_ if (layer.properties[i].transition) { _%> } else if ([prop isEqualToString:@"<%= layer.properties[i].name %>Transition"]) { - [self set<%- iosPropMethodName(layer, pascalCase(layer.properties[i].name)) -%>Transition:layer withReactStyleValue:styleValue]; + [self set<%- helpers.iosPropMethodName(layer, helpers.pascalCase(layer.properties[i].name)) -%>Transition:layer withReactStyleValue:styleValue]; <%_ } _%> <% } -%> } else { @@ -69,21 +70,21 @@ <% for (const layer of layers) {%> <% for (const prop of layer.properties) {%> -- (void)set<%- iosPropMethodName(layer, pascalCase(prop.name)) -%>:(<%- getLayerType(layer, 'ios') -%> *)layer withReactStyleValue:(RCTMLNStyleValue *)styleValue +- (void)set<%- helpers.iosPropMethodName(layer, helpers.pascalCase(prop.name)) -%>:(<%- helpers.getLayerType(layer, 'ios') -%> *)layer withReactStyleValue:(RCTMLNStyleValue *)styleValue { <%_ if (layer.name === 'light' && prop.name === 'position') { _%> layer.position = [styleValue getSphericalPosition]; <%_ } else if (prop.name === 'visibility') { _%> layer.visible = [styleValue isVisible]; <%_ } else { _%> - layer.<%- iosPropName(prop.name) -%> = styleValue.mlnStyleValue; + layer.<%- helpers.iosPropName(prop.name) -%> = styleValue.mlnStyleValue; <%_ } _%> } <%_ if (prop.transition) { _%> -- (void)set<%- iosPropMethodName(layer, pascalCase(prop.name)) -%>Transition:(<%- getLayerType(layer, 'ios') -%> *)layer withReactStyleValue:(RCTMLNStyleValue *)styleValue +- (void)set<%- helpers.iosPropMethodName(layer, helpers.pascalCase(prop.name)) -%>Transition:(<%- helpers.getLayerType(layer, 'ios') -%> *)layer withReactStyleValue:(RCTMLNStyleValue *)styleValue { - layer.<%- iosPropName(prop.name) -%>Transition = [styleValue getTransition]; + layer.<%- helpers.iosPropName(prop.name) -%>Transition = [styleValue getTransition]; } <%_ } _%> <% } %> diff --git a/scripts/templates/RCTMLNStyleFactory.java.ejs b/scripts/templates/RCTMLNStyleFactory.java.ejs index cdfdd2f52..e0727aefe 100644 --- a/scripts/templates/RCTMLNStyleFactory.java.ejs +++ b/scripts/templates/RCTMLNStyleFactory.java.ejs @@ -1,5 +1,6 @@ <% const layers = locals.layers; + const helpers = locals.helpers; -%> // DO NOT MODIFY // THIS FILE IS AUTOGENERATED @@ -29,7 +30,7 @@ public class RCTMLNStyleFactory { public static final String SHOULD_ADD_IMAGE_KEY = "shouldAddImage"; <%_ for (const layer of layers) { _%> - public static void <%- setLayerMethodName(layer) -%>(final <%- getLayerType(layer, 'android') -%> layer, RCTMLNStyle style) { + public static void <%- helpers.setLayerMethodName(layer) -%>(final <%- helpers.getLayerType(layer, 'android') -%> layer, RCTMLNStyle style) { List styleKeys = style.getAllStyleKeys(); if (styleKeys.size() == 0) { @@ -46,16 +47,16 @@ public class RCTMLNStyleFactory { style.addImage(styleValue, new DownloadMapImageTask.OnAllImagesLoaded() { @Override public void onAllImagesLoaded() { - RCTMLNStyleFactory.set<%- pascalCase(prop.name) -%>(layer, styleValue); + RCTMLNStyleFactory.set<%- helpers.pascalCase(prop.name) -%>(layer, styleValue); } }); <%_ } else { _%> - RCTMLNStyleFactory.set<%- pascalCase(prop.name) -%>(layer, styleValue); + RCTMLNStyleFactory.set<%- helpers.pascalCase(prop.name) -%>(layer, styleValue); <%_ } _%> break; <%_ if (prop.transition) { _%> case "<%= prop.name %>Transition": - RCTMLNStyleFactory.set<%- pascalCase(prop.name) -%>Transition(layer, styleValue); + RCTMLNStyleFactory.set<%- helpers.pascalCase(prop.name) -%>Transition(layer, styleValue); break; <%_ } _%> <%_ } _%> @@ -66,12 +67,12 @@ public class RCTMLNStyleFactory { <%_ for (const layer of layers) { _%> <%_ for (const prop of layer.properties) { _%> - public static void set<%- pascalCase(prop.name) -%>(<%- getLayerType(layer, 'android') -%> layer, RCTMLNStyleValue styleValue) { + public static void set<%- helpers.pascalCase(prop.name) -%>(<%- helpers.getLayerType(layer, 'android') -%> layer, RCTMLNStyleValue styleValue) { <%_ if (layer.name === 'light' && prop.name === 'position') { _%> Float[] values = styleValue.getFloatArray(VALUE_KEY); - layer.set<%- pascalCase(prop.name) -%>(Position.fromPosition(values[0], values[1], values[2])); + layer.set<%- helpers.pascalCase(prop.name) -%>(Position.fromPosition(values[0], values[1], values[2])); <%_ } else if (layer.name === 'light') { _%> - layer.set<%- pascalCase(prop.name) -%>(<%- androidGetConfigType(androidInputType(prop.type, prop.value), prop) -%>); + layer.set<%- helpers.pascalCase(prop.name) -%>(<%- helpers.androidGetConfigType(helpers.androidInputType(prop.type, prop.value), prop) -%>); <%_ } else if (prop.name === 'visibility') { _%> layer.setProperties(PropertyFactory.visibility(styleValue.getString(VALUE_KEY))); <%_ } else if (prop.type === 'resolvedImage') { _%> @@ -82,22 +83,22 @@ public class RCTMLNStyleFactory { layer.setProperties(PropertyFactory.<%= prop.name %>(styleValue.getExpression())); } } else { - layer.setProperties(PropertyFactory.<%= prop.name %>(<%- androidGetConfigType(androidInputType(prop.type, prop.value), prop) -%>)); + layer.setProperties(PropertyFactory.<%= prop.name %>(<%- helpers.androidGetConfigType(helpers.androidInputType(prop.type, prop.value), prop) -%>)); } <%_ } else { _%> if (styleValue.isExpression()) { layer.setProperties(PropertyFactory.<%= prop.name %>(styleValue.getExpression())); } else { - layer.setProperties(PropertyFactory.<%= prop.name %>(<%- androidGetConfigType(androidInputType(prop.type, prop.value), prop) -%>)); + layer.setProperties(PropertyFactory.<%= prop.name %>(<%- helpers.androidGetConfigType(helpers.androidInputType(prop.type, prop.value), prop) -%>)); } <%_ } _%> } <%_ if (prop.transition) { %> - public static void set<%- pascalCase(prop.name) -%>Transition(<%- getLayerType(layer, 'android') -%> layer, RCTMLNStyleValue styleValue) { + public static void set<%- helpers.pascalCase(prop.name) -%>Transition(<%- helpers.getLayerType(layer, 'android') -%> layer, RCTMLNStyleValue styleValue) { TransitionOptions transition = styleValue.getTransition(); if (transition != null) { - layer.set<%- pascalCase(prop.name) -%>Transition(transition); + layer.set<%- helpers.pascalCase(prop.name) -%>Transition(transition); } } diff --git a/scripts/templates/component.md.ejs b/scripts/templates/component.md.ejs index 0464f0ed0..fb99f3c3b 100644 --- a/scripts/templates/component.md.ejs +++ b/scripts/templates/component.md.ejs @@ -1,31 +1,32 @@ <% const component = locals.component; + const helpers = locals.helpers; -%> ## /> -### <%- replaceNewLine(component.description) %> +### <%- helpers.replaceNewLine(component.description) %> <%_ if (component.props && component.props.length) { _%> ### props | Prop | Type | Default | Required | Description | | ---- | :--: | :-----: | :------: | :----------: | -<%- propMarkdownTableRows(component) %> +<%- helpers.propMarkdownTableRows(component) %> <%_ } _%> <%_ if (component.methods && component.methods.length) { _%> ### methods <%_ for (let method of component.methods) { _%> -#### <%- getMarkdownMethodSignature(method) %> +#### <%- helpers.getMarkdownMethodSignature(method) %> -<%- replaceNewLine(method.description) %> +<%- helpers.replaceNewLine(method.description) %> ##### arguments | Name | Type | Required | Description | | ---- | :--: | :------: | :----------: | -<%- methodMarkdownTableRow(method) %> +<%- helpers.methodMarkdownTableRow(method) %> -<%- getMarkdownMethodExamples(method) %> +<%- helpers.getMarkdownMethodExamples(method) %> <%_ } _%> <%_ } _%> @@ -50,9 +51,9 @@ ___ #### Type `<%- style.type %>` -<%_ if (exists(style.default)) { _%> +<%_ if (helpers.exists(style.default)) { _%> #### Default Value -`<%= getStyleDefaultValue(style) %>` +`<%= helpers.getStyleDefaultValue(style) %>` <%_ } _%> <%_ if (style.type === 'enum') { _%> @@ -62,18 +63,18 @@ ___ <%_ } _%> <%_ } _%> -<%_ if (exists(style.units)) { _%> +<%_ if (helpers.exists(style.units)) { _%> #### Units `<%- style.units %>` <%_ } _%> -<%_ if (exists(style.minimum)) { _%> +<%_ if (helpers.exists(style.minimum)) { _%> #### Minimum `<%- style.minimum %>` <%_ } _%> -<%_ if (exists(style.maximum)) { _%> +<%_ if (helpers.exists(style.maximum)) { _%> #### Maximum `<%- style.maximum %>` diff --git a/scripts/templates/index.d.ts.ejs b/scripts/templates/index.d.ts.ejs index ca80c6ec7..5a8c20429 100644 --- a/scripts/templates/index.d.ts.ejs +++ b/scripts/templates/index.d.ts.ejs @@ -1,5 +1,6 @@ <% const layers = locals.layers; + const helpers = locals.helpers; -%> // DO NOT MODIFY // THIS FILE IS AUTOGENERATED @@ -20,7 +21,7 @@ const styleMap = { <%_ for (let layer of layers) { _%> <%_ for (let prop of layer.properties) { _%> <%_ if (!['color', 'colorTransition', 'visibility'].includes(prop.name)) { _%> - <%= prop.name %>: <%- jsStyleType(prop) %>, + <%= prop.name %>: <%- helpers.jsStyleType(prop) %>, <%_ if (prop.transition) { _%> <%= prop.name %>Transition: StyleTypes.Transition, <%_ } _%> diff --git a/scripts/templates/styleMap.ts.ejs b/scripts/templates/styleMap.ts.ejs index db066d69c..321d42af3 100644 --- a/scripts/templates/styleMap.ts.ejs +++ b/scripts/templates/styleMap.ts.ejs @@ -1,5 +1,6 @@ <% const layers = locals.layers; + const helpers = locals.helpers; -%> /* eslint-disable */ // DO NOT MODIFY @@ -33,7 +34,7 @@ const styleMap = { <%_ for (let layer of layers) { _%> <%_ for (let prop of layer.properties) { _%> <%_ if (prop.name !== 'visibility') { _%> - <%= prop.name %>: <%- jsStyleType(prop) %>, + <%= prop.name %>: <%- helpers.jsStyleType(prop) %>, <%_ if (prop.transition) { _%> <%= prop.name %>Transition: StyleTypes.Transition, <%_ } _%> diff --git a/scripts/utils/DocJSONBuilder.ts b/scripts/utils/DocJSONBuilder.ts index f2cc69ea0..d9801c5d8 100644 --- a/scripts/utils/DocJSONBuilder.ts +++ b/scripts/utils/DocJSONBuilder.ts @@ -5,7 +5,7 @@ import * as docgen from "react-docgen"; import { parseJsDoc } from "react-docgen/dist/utils"; import { JSDocNodeTree } from "./JSDocNodeTree"; -import { pascalCase } from "./template-globals"; +import { pascalCase } from "./TemplateHelpers"; const WORKSPACE_ROOT = path.join(__dirname, "..", ".."); diff --git a/scripts/utils/MarkdownBuilder.ts b/scripts/utils/MarkdownBuilder.ts index a3cf22ccf..f0068ef14 100644 --- a/scripts/utils/MarkdownBuilder.ts +++ b/scripts/utils/MarkdownBuilder.ts @@ -2,6 +2,8 @@ import ejs from "ejs"; import { promises as fs } from "node:fs"; import path from "node:path"; +import * as TemplateHelpers from "./TemplateHelpers"; + const TMPL_PATH = path.join(__dirname, "..", "templates"); export class MarkdownBuilder { @@ -13,7 +15,10 @@ export class MarkdownBuilder { strict: true, }, ); - const fileContents = await tmpl({ component: docJSON[componentName] }); + const fileContents = await tmpl({ + component: docJSON[componentName], + helpers: TemplateHelpers, + }); await fs.writeFile( path.join(__dirname, "..", "..", "docs", `${componentName}.md`), fileContents, diff --git a/scripts/utils/template-globals.ts b/scripts/utils/TemplateHelpers.ts similarity index 87% rename from scripts/utils/template-globals.ts rename to scripts/utils/TemplateHelpers.ts index 47dc4cf8d..47f45a1f9 100644 --- a/scripts/utils/template-globals.ts +++ b/scripts/utils/TemplateHelpers.ts @@ -40,17 +40,16 @@ const iosSpecOverrides: Record = { "text-writing-mode": "text-writing-modes", }; -function exists(value: T): value is NonNullable { +export function exists(value: T): value is NonNullable { return typeof value !== "undefined" && value !== null; } -global.exists = exists; -global.getValue = function (value: any, defaultValue: any) { +export function getValue(value: any, defaultValue: any) { if (!exists(value) || value === "") { return defaultValue; } return value; -}; +} export function camelCase(str: string, delimiter = "-") { const parts = str.split(delimiter); @@ -63,7 +62,6 @@ export function camelCase(str: string, delimiter = "-") { }) .join(""); } -global.camelCase = camelCase; export function pascalCase(str: string, delimiter = "-") { const parts = str.split(delimiter); @@ -73,16 +71,15 @@ export function pascalCase(str: string, delimiter = "-") { }) .join(""); } -global.pascalCase = pascalCase; -global.setLayerMethodName = function (layer: any, platform: "android" | "ios") { +export function setLayerMethodName(layer: any, platform: "android" | "ios") { if (platform === "ios") { return `${camelCase(layer.name)}Layer`; } return `set${pascalCase(layer.name)}LayerStyle`; -}; +} -global.getLayerType = function (layer: any, platform: "android" | "ios") { +export function getLayerType(layer: any, platform: "android" | "ios") { const isIOS = platform === "ios"; switch (layer.name) { @@ -111,20 +108,20 @@ global.getLayerType = function (layer: any, platform: "android" | "ios") { `Is ${layer.name} a new layer? We should add support for it!`, ); } -}; +} -global.ifOrElseIf = function (index: number) { +export function ifOrElseIf(index: number) { if (index === 0) { return "if"; } return "} else if"; -}; +} -global.iosStringArrayLiteral = function (array: string[]) { +export function iosStringArrayLiteral(array: string[]) { return `@[@${array.map((item) => `"${item}"`).join(", @")}]`; -}; +} -function iosPropName(name: string) { +export function iosPropName(name: string) { if (name.indexOf("visibility") !== -1) { return "visible"; } @@ -137,24 +134,22 @@ function iosPropName(name: string) { return name; } -global.iosPropName = iosPropName; - -global.iosMapLibrePropName = function (name: string) { +export function iosMapLibrePropName(name: string) { const result = iosPropName(name); if (result === "fillExtrusionVerticalGradient") { return "fillExtrusionHasVerticalGradient"; } return undefined; -}; +} -global.iosPropMethodName = function (layer: any, name: string) { +export function iosPropMethodName(layer: any, name: string) { if (name.indexOf("Visibility") !== -1) { return pascalCase(layer.name) + "StyleLayer" + name; } return name; -}; +} -function androidInputType(type: string, value?: string) { +export function androidInputType(type: string, value?: string): string { if (type === "array" && value) { return `${androidInputType(value)}[]`; } @@ -171,9 +166,7 @@ function androidInputType(type: string, value?: string) { } } -global.androidInputType = androidInputType; - -function androidOutputType(type: string, value?: any): string { +export function androidOutputType(type: string, value?: any): string { if (type === "array" && value) { return `${androidOutputType(value)}[]`; } @@ -190,9 +183,7 @@ function androidOutputType(type: string, value?: any): string { } } -global.androidOutputType = androidOutputType; - -global.androidGetConfigType = function (androidType: string, prop: any) { +export function androidGetConfigType(androidType: string, prop: any) { switch (androidType) { case "Integer": return "styleValue.getInt(VALUE_KEY)"; @@ -211,9 +202,9 @@ global.androidGetConfigType = function (androidType: string, prop: any) { return "styleValue.getString(VALUE_KEY)"; } } -}; +} -global.jsStyleType = function (prop: any) { +export function jsStyleType(prop: any) { if (prop.type === "color") { return "StyleTypes.Color"; } @@ -235,9 +226,9 @@ global.jsStyleType = function (prop: any) { } return "StyleTypes.Constant"; -}; +} -global.jsDocPropRequires = function (prop: any) { +export function jsDocPropRequires(prop: any) { if (!prop.doc.requires) { return; } @@ -250,9 +241,9 @@ global.jsDocPropRequires = function (prop: any) { } return desc; -}; +} -global.getEnums = function (layers: any[]) { +export function getEnums(layers: any[]) { const result: Record = {}; layers.forEach((layer) => { @@ -269,9 +260,9 @@ global.getEnums = function (layers: any[]) { }); }); return Object.values(result); -}; +} -global.dtsInterfaceType = function (prop: any) { +export function dtsInterfaceType(prop: any) { const propTypes: string[] = []; if (prop.name.indexOf("Translate") !== -1 && prop.type !== "enum") { @@ -340,9 +331,9 @@ ${startAtSpace(2, "")}`; return propTypes[0]; } } -}; +} -global.jsDocReactProp = function (prop: any) { +export function jsDocReactProp(prop: any) { const propTypes = []; if (prop.type === "color") { @@ -394,9 +385,9 @@ ${startAtSpace(2, "])")}`; } else { return propTypes[0]; } -}; +} -function startAtSpace(spaceCount: number, str: string) { +export function startAtSpace(spaceCount: number, str: string) { let value = ""; for (let i = 0; i < spaceCount; i++) { @@ -406,23 +397,19 @@ function startAtSpace(spaceCount: number, str: string) { return `${value}${str}`; } -global.startAtSpace = startAtSpace; - export function replaceNewLine(str: string) { return str?.replace(/\n/g, "
"); } -global.replaceNewLine = replaceNewLine; - -global.styleMarkdownTableRow = function (style: any) { +export function styleMarkdownTableRow(style: any) { return `| \`${style.name}\` | \`${style.type}\` | \`${ style.requires.join(", ") || "none" }\` | \`${style.disabledBy.join(", ") || "none"}\` | ${replaceNewLine( style.description, )} |`; -}; +} -global.methodMarkdownTableRow = function (method: any) { +export function methodMarkdownTableRow(method: any) { return method.params .map((param: any) => { return `| \`${param.name}\` | \`${ @@ -432,7 +419,7 @@ global.methodMarkdownTableRow = function (method: any) { )} |`; }) .join("\n"); -}; +} function _propMarkdownTableRows(props: any[], prefix = "") { return props @@ -462,11 +449,11 @@ function _propMarkdownTableRows(props: any[], prefix = "") { .join("\n"); } -global.propMarkdownTableRows = function (component: any) { +export function propMarkdownTableRows(component: any) { return _propMarkdownTableRows(component.props, ""); -}; +} -global.getMarkdownMethodSignature = function (method: any) { +export function getMarkdownMethodSignature(method: any) { const params = method.params .map((param: any, i: number) => { const isOptional = param.optional; @@ -483,9 +470,9 @@ global.getMarkdownMethodSignature = function (method: any) { .join(""); return `${method.name}(${params})`; -}; +} -global.getMarkdownMethodExamples = function (method: any) { +export function getMarkdownMethodExamples(method: any) { if (method.examples == null) { return null; } @@ -500,9 +487,9 @@ ${example.trim()} `; }) .join(""); -}; +} -global.getStyleDefaultValue = function (style: any) { +export function getStyleDefaultValue(style: any) { if (style.type === "string" && style.default === "") { return "empty string"; } else if (style.type.includes("array")) { @@ -510,7 +497,7 @@ global.getStyleDefaultValue = function (style: any) { } else { return style.default; } -}; +} Object.keys(iosSpecOverrides).forEach((propName) => { const camelCasePropName = camelCase(propName); From 42e40bfed0c12aa12543a9f4a1364f3451c6c552 Mon Sep 17 00:00:00 2001 From: Kilian Finger Date: Tue, 5 Nov 2024 09:19:50 +0100 Subject: [PATCH 11/13] docs: codegen --- docs/Annotation.md | 13 +- docs/BackgroundLayer.md | 3 +- docs/Callout.md | 3 +- docs/Camera.md | 3 +- docs/CircleLayer.md | 3 +- docs/FillExtrusionLayer.md | 3 +- docs/FillLayer.md | 3 +- docs/HeadingIndicator.md | 3 +- docs/HeatmapLayer.md | 3 +- docs/ImageSource.md | 3 +- docs/Images.md | 3 +- docs/Light.md | 3 +- docs/LineLayer.md | 3 +- docs/MapView.md | 3 +- docs/MarkerView.md | 3 +- docs/NativeUserLocation.md | 3 +- docs/OfflineManager.md | 246 ------------------------------------- docs/PointAnnotation.md | 3 +- docs/RasterLayer.md | 3 +- docs/RasterSource.md | 3 +- docs/ShapeSource.md | 3 +- docs/Style.md | 3 +- docs/SymbolLayer.md | 3 +- docs/UserLocation.md | 3 +- docs/VectorSource.md | 3 +- docs/coordinates.md | 3 +- docs/docs.json | 81 +++++------- docs/location.md | 3 +- docs/offlineManager.md | 3 +- docs/snapshotManager.md | 3 +- 30 files changed, 84 insertions(+), 337 deletions(-) delete mode 100644 docs/OfflineManager.md diff --git a/docs/Annotation.md b/docs/Annotation.md index e64be37a6..e3821c9d7 100644 --- a/docs/Annotation.md +++ b/docs/Annotation.md @@ -1,4 +1,5 @@ - + + ## ### @@ -25,14 +26,4 @@ | `event` | `OnPressEvent` | `Yes` | undefined | -#### symbolStyle() - - - -##### arguments -| Name | Type | Required | Description | -| ---- | :--: | :------: | :----------: | - - - diff --git a/docs/BackgroundLayer.md b/docs/BackgroundLayer.md index dff55c35e..bc6777b73 100644 --- a/docs/BackgroundLayer.md +++ b/docs/BackgroundLayer.md @@ -1,4 +1,5 @@ - + + ## ### diff --git a/docs/Callout.md b/docs/Callout.md index 290463ece..97dd6686b 100644 --- a/docs/Callout.md +++ b/docs/Callout.md @@ -1,4 +1,5 @@ - + + ## ### Callout that displays information about a selected annotation near the annotation. diff --git a/docs/Camera.md b/docs/Camera.md index c3b708880..fd93d082e 100644 --- a/docs/Camera.md +++ b/docs/Camera.md @@ -1,4 +1,5 @@ - + + ## ### diff --git a/docs/CircleLayer.md b/docs/CircleLayer.md index 4372ca04e..9ca501ed7 100644 --- a/docs/CircleLayer.md +++ b/docs/CircleLayer.md @@ -1,4 +1,5 @@ - + + ## ### CircleLayer is a style layer that renders one or more filled circles on the map. diff --git a/docs/FillExtrusionLayer.md b/docs/FillExtrusionLayer.md index c0b469d87..d9d76ae50 100644 --- a/docs/FillExtrusionLayer.md +++ b/docs/FillExtrusionLayer.md @@ -1,4 +1,5 @@ - + + ## ### FillExtrusionLayer is a style layer that renders one or more 3D extruded polygons on the map. diff --git a/docs/FillLayer.md b/docs/FillLayer.md index 708e07266..c64ba6585 100644 --- a/docs/FillLayer.md +++ b/docs/FillLayer.md @@ -1,4 +1,5 @@ - + + ## ### FillLayer is a style layer that renders one or more filled (and optionally stroked) polygons on the map. diff --git a/docs/HeadingIndicator.md b/docs/HeadingIndicator.md index d3c03b732..6618fc37a 100644 --- a/docs/HeadingIndicator.md +++ b/docs/HeadingIndicator.md @@ -1,4 +1,5 @@ - + + ## ### diff --git a/docs/HeatmapLayer.md b/docs/HeatmapLayer.md index e3641d975..e43a2dd19 100644 --- a/docs/HeatmapLayer.md +++ b/docs/HeatmapLayer.md @@ -1,4 +1,5 @@ - + + ## ### HeatmapLayer is a style layer that renders one or more filled circles on the map. diff --git a/docs/ImageSource.md b/docs/ImageSource.md index cc0e80cbb..a7dce2b71 100644 --- a/docs/ImageSource.md +++ b/docs/ImageSource.md @@ -1,4 +1,5 @@ - + + ## ### ImageSource is a content source that is used for a georeferenced raster image to be shown on the map.
The georeferenced image scales and rotates as the user zooms and rotates the map diff --git a/docs/Images.md b/docs/Images.md index 57a1e8d91..2c55ee9ff 100644 --- a/docs/Images.md +++ b/docs/Images.md @@ -1,4 +1,5 @@ - + + ## ### Images defines the images used in Symbol etc layers diff --git a/docs/Light.md b/docs/Light.md index 315b458e0..89dfe192f 100644 --- a/docs/Light.md +++ b/docs/Light.md @@ -1,4 +1,5 @@ - + + ## ### Light represents the light source for extruded geometries diff --git a/docs/LineLayer.md b/docs/LineLayer.md index b9694ef73..ff46dbdbb 100644 --- a/docs/LineLayer.md +++ b/docs/LineLayer.md @@ -1,4 +1,5 @@ - + + ## ### LineLayer is a style layer that renders one or more stroked polylines on the map. diff --git a/docs/MapView.md b/docs/MapView.md index 46d531f19..e00d1c878 100644 --- a/docs/MapView.md +++ b/docs/MapView.md @@ -1,4 +1,5 @@ - + + ## ### MapView backed by MapLibre Native diff --git a/docs/MarkerView.md b/docs/MarkerView.md index 7ff9d2b4e..933387e44 100644 --- a/docs/MarkerView.md +++ b/docs/MarkerView.md @@ -1,4 +1,5 @@ - + + ## ### MarkerView allows you to place a interactive react native marker to the map.

If you have static view consider using PointAnnotation or SymbolLayer they'll offer much better performance
.
This is based on [MakerView plugin](https://docs.mapbox.com/android/plugins/overview/markerview/) on Android
and PointAnnotation on iOS. diff --git a/docs/NativeUserLocation.md b/docs/NativeUserLocation.md index 91970322f..4d3f6590a 100644 --- a/docs/NativeUserLocation.md +++ b/docs/NativeUserLocation.md @@ -1,4 +1,5 @@ - + + ## ### diff --git a/docs/OfflineManager.md b/docs/OfflineManager.md deleted file mode 100644 index 59e119f3a..000000000 --- a/docs/OfflineManager.md +++ /dev/null @@ -1,246 +0,0 @@ - -## -### OfflineManager implements a singleton (shared object) that manages offline packs.
All of this class’s instance methods are asynchronous, reflecting the fact that offline resources are stored in a database.
The shared object maintains a canonical collection of offline packs. - - -### methods -#### createPack(options[, progressListener][, errorListener]) - -Creates and registers an offline pack that downloads the resources needed to use the given region offline. - -##### arguments -| Name | Type | Required | Description | -| ---- | :--: | :------: | :----------: | -| `options` | `OfflineCreatePackOptions` | `Yes` | Create options for a offline pack that specifices zoom levels, style url, and the region to download. | -| `progressListener` | `Callback` | `No` | Callback that listens for status events while downloading the offline resource. | -| `errorListener` | `Callback` | `No` | Callback that listens for status events while downloading the offline resource. | - - - -```javascript -const progressListener = (offlineRegion, status) => console.log(offlineRegion, status); -const errorListener = (offlineRegion, err) => console.log(offlineRegion, err); - -await MapLibreGL.offlineManager.createPack({ - name: 'offlinePack', - styleURL: 'mapbox://...', - minZoom: 14, - maxZoom: 20, - bounds: [[neLng, neLat], [swLng, swLat]] -}, progressListener, errorListener) -``` - - -#### invalidatePack(name) - -Invalidates the specified offline pack. This method checks that the tiles in the specified offline pack match those from the server. Local tiles that do not match the latest version on the server are updated.This is more efficient than deleting the offline pack and downloading it again. If the data stored locally matches that on the server, new data will not be downloaded. - -##### arguments -| Name | Type | Required | Description | -| ---- | :--: | :------: | :----------: | -| `name` | `String` | `Yes` | Name of the offline pack. | - - - -```javascript -await MapLibreGL.offlineManager.invalidatePack('packName') -``` - - -#### deletePack(name) - -Unregisters the given offline pack and allows resources that are no longer required by any remaining packs to be potentially freed. - -##### arguments -| Name | Type | Required | Description | -| ---- | :--: | :------: | :----------: | -| `name` | `String` | `Yes` | Name of the offline pack. | - - - -```javascript -await MapLibreGL.offlineManager.deletePack('packName') -``` - - -#### invalidateAmbientCache() - -Forces a revalidation of the tiles in the ambient cache and downloads a fresh version of the tiles from the tile server.
This is the recommend method for clearing the cache.
This is the most efficient method because tiles in the ambient cache are re-downloaded to remove outdated data from a device.
It does not erase resources from the ambient cache or delete the database, which can be computationally expensive operations that may carry unintended side effects. - -##### arguments -| Name | Type | Required | Description | -| ---- | :--: | :------: | :----------: | - - - - -```javascript -await MapLibreGL.offlineManager.invalidateAmbientCache(); -``` - - -#### clearAmbientCache() - -Erases resources from the ambient cache.
This method clears the cache and decreases the amount of space that map resources take up on the device. - -##### arguments -| Name | Type | Required | Description | -| ---- | :--: | :------: | :----------: | - - - - -```javascript -await MapLibreGL.offlineManager.clearAmbientCache(); -``` - - -#### setMaximumAmbientCacheSize(size) - -Sets the maximum size of the ambient cache in bytes. Disables the ambient cache if set to 0.
This method may be computationally expensive because it will erase resources from the ambient cache if its size is decreased. - -##### arguments -| Name | Type | Required | Description | -| ---- | :--: | :------: | :----------: | -| `size` | `Number` | `Yes` | Size of ambient cache. | - - - -```javascript -await MapLibreGL.offlineManager.setMaximumAmbientCacheSize(5000000); -``` - - -#### resetDatabase() - -Deletes the existing database, which includes both the ambient cache and offline packs, then reinitializes it. - -##### arguments -| Name | Type | Required | Description | -| ---- | :--: | :------: | :----------: | - - - - -```javascript -await MapLibreGL.offlineManager.resetDatabase(); -``` - - -#### getPacks() - -Retrieves all the current offline packs that are stored in the database. - -##### arguments -| Name | Type | Required | Description | -| ---- | :--: | :------: | :----------: | - - - - -```javascript -const offlinePacks = await MapLibreGL.offlineManager.getPacks(); -``` - - -#### getPack(name) - -Retrieves an offline pack that is stored in the database by name. - -##### arguments -| Name | Type | Required | Description | -| ---- | :--: | :------: | :----------: | -| `name` | `String` | `Yes` | Name of the offline pack. | - - - -```javascript -const offlinePack = await MapLibreGL.offlineManager.getPack(); -``` - - -#### mergeOfflineRegions(path) - -Sideloads offline db - -##### arguments -| Name | Type | Required | Description | -| ---- | :--: | :------: | :----------: | -| `path` | `String` | `Yes` | Path to offline tile db on file system. | - - - -```javascript -await MapLibreGL.offlineManager.mergeOfflineRegions(path); -``` - - -#### setTileCountLimit(limit) - -Sets the maximum number of tiles that may be downloaded and stored on the current device.
Consult the Terms of Service for your map tile host before changing this value. - -##### arguments -| Name | Type | Required | Description | -| ---- | :--: | :------: | :----------: | -| `limit` | `Number` | `Yes` | Map tile limit count. | - - - -```javascript -MapLibreGL.offlineManager.setTileCountLimit(1000); -``` - - -#### setProgressEventThrottle(throttleValue) - -Sets the period at which download status events will be sent over the React Native bridge.
The default is 500ms. - -##### arguments -| Name | Type | Required | Description | -| ---- | :--: | :------: | :----------: | -| `throttleValue` | `Number` | `Yes` | event throttle value in ms. | - - - -```javascript -MapLibreGL.offlineManager.setProgressEventThrottle(500); -``` - - -#### subscribe(packName, progressListener, errorListener) - -Subscribe to download status/error events for the requested offline pack.
Note that createPack calls this internally if listeners are provided. - -##### arguments -| Name | Type | Required | Description | -| ---- | :--: | :------: | :----------: | -| `packName` | `String` | `Yes` | Name of the offline pack. | -| `progressListener` | `Callback` | `Yes` | Callback that listens for status events while downloading the offline resource. | -| `errorListener` | `Callback` | `Yes` | Callback that listens for status events while downloading the offline resource. | - - - -```javascript -const progressListener = (offlinePack, status) => console.log(offlinePack, status) -const errorListener = (offlinePack, err) => console.log(offlinePack, err) -MapLibreGL.offlineManager.subscribe('packName', progressListener, errorListener) -``` - - -#### unsubscribe(packName) - -Unsubscribes any listeners associated with the offline pack.
It's a good idea to call this on componentWillUnmount. - -##### arguments -| Name | Type | Required | Description | -| ---- | :--: | :------: | :----------: | -| `packName` | `String` | `Yes` | Name of the offline pack. | - - - -```javascript -MapLibreGL.offlineManager.unsubscribe('packName') -``` - - - diff --git a/docs/PointAnnotation.md b/docs/PointAnnotation.md index 6466124cf..7bfbcf541 100644 --- a/docs/PointAnnotation.md +++ b/docs/PointAnnotation.md @@ -1,4 +1,5 @@ - + + ## ### PointAnnotation represents a one-dimensional shape located at a single geographical coordinate.

Consider using ShapeSource and SymbolLayer instead, if you have many points and you have static images,
they'll offer much better performance

.
If you need interctive views please use MarkerView,
as with PointAnnotation on Android child views are rendered onto a bitmap for better performance. diff --git a/docs/RasterLayer.md b/docs/RasterLayer.md index e6c87fc4c..3511c30db 100644 --- a/docs/RasterLayer.md +++ b/docs/RasterLayer.md @@ -1,4 +1,5 @@ - + + ## ### diff --git a/docs/RasterSource.md b/docs/RasterSource.md index d5b1202c9..536a2ae94 100644 --- a/docs/RasterSource.md +++ b/docs/RasterSource.md @@ -1,4 +1,5 @@ - + + ## ### RasterSource is a map content source that supplies raster image tiles to be shown on the map.
The location of and metadata about the tiles are defined either by an option dictionary
or by an external file that conforms to the TileJSON specification. diff --git a/docs/ShapeSource.md b/docs/ShapeSource.md index 7a82db8fc..b3bf8e187 100644 --- a/docs/ShapeSource.md +++ b/docs/ShapeSource.md @@ -1,4 +1,5 @@ - + + ## ### ShapeSource is a map content source that supplies vector shapes to be shown on the map.
The shape may be a url or a GeoJSON object diff --git a/docs/Style.md b/docs/Style.md index e7ed37fe4..91f3f4b33 100644 --- a/docs/Style.md +++ b/docs/Style.md @@ -1,4 +1,5 @@ - + + ## ### Style is a component that automatically adds sources / layers to the map using MapLibre Style Spec.
Only [`sources`](https://maplibre.org/maplibre-gl-js-docs/style-spec/sources/) & [`layers`](https://maplibre.org/maplibre-gl-js-docs/style-spec/layers/) are supported.
Other fields such as `sprites`, `glyphs` etc. will be ignored. Not all layer / source attributes from the style spec are supported, in general the supported attributes will be mentioned under https://github.com/maplibre/maplibre-react-native/tree/main/docs.

TODO: Maintainer forking this project does not understand the above comment regarding what is supported. diff --git a/docs/SymbolLayer.md b/docs/SymbolLayer.md index fe12f9e9a..80f5f916d 100644 --- a/docs/SymbolLayer.md +++ b/docs/SymbolLayer.md @@ -1,4 +1,5 @@ - + + ## ### SymbolLayer is a style layer that renders icon and text labels at points or along lines on the map. diff --git a/docs/UserLocation.md b/docs/UserLocation.md index 15e508e92..55f6514f9 100644 --- a/docs/UserLocation.md +++ b/docs/UserLocation.md @@ -1,4 +1,5 @@ - + + ## ### diff --git a/docs/VectorSource.md b/docs/VectorSource.md index f6e2e5f84..913a168ca 100644 --- a/docs/VectorSource.md +++ b/docs/VectorSource.md @@ -1,4 +1,5 @@ - + + ## ### VectorSource is a map content source that supplies tiled vector data in Mapbox Vector Tile format to be shown on the map.
The location of and metadata about the tiles are defined either by an option dictionary or by an external file that conforms to the TileJSON specification. diff --git a/docs/coordinates.md b/docs/coordinates.md index 0db81f45e..fe288e725 100644 --- a/docs/coordinates.md +++ b/docs/coordinates.md @@ -1,4 +1,5 @@ - + + ## ### Coorinates sent by locationManager diff --git a/docs/docs.json b/docs/docs.json index 2e30592b1..e13c4f012 100644 --- a/docs/docs.json +++ b/docs/docs.json @@ -21,13 +21,6 @@ "name": "void" } } - }, - { - "name": "symbolStyle", - "docblock": null, - "modifiers": [], - "params": [], - "returns": null } ], "props": [ @@ -88,7 +81,7 @@ "description": "FIX ME NO DESCRIPTION" } ], - "fileNameWithExt": "Annotation.tsx", + "filePath": "javascript/components/Annotation.tsx", "name": "Annotation" }, "BackgroundLayer": { @@ -115,7 +108,7 @@ "BaseProps", "BaseLayerProps" ], - "fileNameWithExt": "BackgroundLayer.tsx", + "filePath": "javascript/components/BackgroundLayer.tsx", "name": "BackgroundLayer", "styles": [ { @@ -244,7 +237,7 @@ "composes": [ "Omit" ], - "fileNameWithExt": "Callout.tsx", + "filePath": "javascript/components/Callout.tsx", "name": "Callout" }, "Camera": { @@ -290,7 +283,6 @@ } ], "returns": { - "description": null, "type": { "name": "void" } @@ -323,7 +315,6 @@ } ], "returns": { - "description": null, "type": { "name": "void" } @@ -356,7 +347,6 @@ } ], "returns": { - "description": null, "type": { "name": "void" } @@ -389,7 +379,6 @@ } ], "returns": { - "description": null, "type": { "name": "void" } @@ -572,7 +561,7 @@ "composes": [ "Omit" ], - "fileNameWithExt": "Camera.tsx", + "filePath": "javascript/components/Camera.tsx", "name": "Camera" }, "CircleLayer": { @@ -599,7 +588,7 @@ "BaseProps", "BaseLayerProps" ], - "fileNameWithExt": "CircleLayer.tsx", + "filePath": "javascript/components/CircleLayer.tsx", "name": "CircleLayer", "styles": [ { @@ -902,7 +891,7 @@ "BaseProps", "BaseLayerProps" ], - "fileNameWithExt": "FillExtrusionLayer.tsx", + "filePath": "javascript/components/FillExtrusionLayer.tsx", "name": "FillExtrusionLayer", "styles": [ { @@ -1116,7 +1105,7 @@ "BaseProps", "BaseLayerProps" ], - "fileNameWithExt": "FillLayer.tsx", + "filePath": "javascript/components/FillLayer.tsx", "name": "FillLayer", "styles": [ { @@ -1315,7 +1304,7 @@ "composes": [ "BaseProps" ], - "fileNameWithExt": "HeadingIndicator.tsx", + "filePath": "javascript/components/HeadingIndicator.tsx", "name": "HeadingIndicator" }, "HeatmapLayer": { @@ -1342,7 +1331,7 @@ "BaseProps", "BaseLayerProps" ], - "fileNameWithExt": "HeatmapLayer.tsx", + "filePath": "javascript/components/HeatmapLayer.tsx", "name": "HeatmapLayer", "styles": [ { @@ -1518,7 +1507,7 @@ "composes": [ "BaseProps" ], - "fileNameWithExt": "ImageSource.tsx", + "filePath": "javascript/components/ImageSource.tsx", "name": "ImageSource" }, "Images": { @@ -1571,7 +1560,7 @@ "composes": [ "BaseProps" ], - "fileNameWithExt": "Images.tsx", + "filePath": "javascript/components/Images.tsx", "name": "Images" }, "Light": { @@ -1591,7 +1580,7 @@ "BaseProps", "BaseLayerProps" ], - "fileNameWithExt": "Light.tsx", + "filePath": "javascript/components/Light.tsx", "name": "Light", "styles": [ { @@ -1703,7 +1692,7 @@ "BaseProps", "BaseLayerProps" ], - "fileNameWithExt": "LineLayer.tsx", + "filePath": "javascript/components/LineLayer.tsx", "name": "LineLayer", "styles": [ { @@ -2088,7 +2077,6 @@ } ], "returns": { - "description": null, "type": { "name": "Promise", "elements": [ @@ -2121,7 +2109,6 @@ } ], "returns": { - "description": null, "type": { "name": "Promise", "elements": [ @@ -2145,7 +2132,6 @@ ], "params": [], "returns": { - "description": null, "type": { "name": "Promise", "elements": [ @@ -2202,7 +2188,6 @@ } ], "returns": { - "description": null, "type": { "name": "Promise", "elements": [ @@ -2251,7 +2236,6 @@ } ], "returns": { - "description": null, "type": { "name": "Promise", "elements": [ @@ -2297,7 +2281,6 @@ } ], "returns": { - "description": null, "type": { "name": "Promise", "elements": [ @@ -2319,7 +2302,6 @@ ], "params": [], "returns": { - "description": null, "type": { "name": "Promise", "elements": [ @@ -2590,7 +2572,7 @@ "composes": [ "BaseProps" ], - "fileNameWithExt": "MapView.tsx", + "filePath": "javascript/components/MapView.tsx", "name": "MapView" }, "MarkerView": { @@ -2655,7 +2637,7 @@ "composes": [ "ViewProps" ], - "fileNameWithExt": "MarkerView.tsx", + "filePath": "javascript/components/MarkerView.tsx", "name": "MarkerView" }, "NativeUserLocation": { @@ -2685,7 +2667,7 @@ "description": "Android only. Set max FPS at which location animators can output updates. Use this setting to limit animation rate of the location puck on higher zoom levels to decrease the stress on the device's CPU which can directly improve battery life, without sacrificing UX." } ], - "fileNameWithExt": "NativeUserLocation.tsx", + "filePath": "javascript/components/NativeUserLocation.tsx", "name": "NativeUserLocation" }, "PointAnnotation": { @@ -2789,7 +2771,7 @@ "description": "FIX ME NO DESCRIPTION" } ], - "fileNameWithExt": "PointAnnotation.tsx", + "filePath": "javascript/components/PointAnnotation.tsx", "name": "PointAnnotation" }, "RasterLayer": { @@ -2816,7 +2798,7 @@ "BaseProps", "BaseLayerProps" ], - "fileNameWithExt": "RasterLayer.tsx", + "filePath": "javascript/components/RasterLayer.tsx", "name": "RasterLayer", "styles": [ { @@ -3069,7 +3051,7 @@ "composes": [ "BaseProps" ], - "fileNameWithExt": "RasterSource.tsx", + "filePath": "javascript/components/RasterSource.tsx", "name": "RasterSource" }, "ShapeSource": { @@ -3093,7 +3075,6 @@ } ], "returns": { - "description": null, "type": { "name": "Promise", "elements": [ @@ -3126,7 +3107,6 @@ } ], "returns": { - "description": null, "type": { "name": "Promise", "elements": [ @@ -3175,7 +3155,6 @@ } ], "returns": { - "description": null, "type": { "name": "Promise", "elements": [ @@ -3208,7 +3187,6 @@ } ], "returns": { - "description": null, "type": { "name": "Promise", "elements": [ @@ -3381,7 +3359,7 @@ "composes": [ "BaseProps" ], - "fileNameWithExt": "ShapeSource.tsx", + "filePath": "javascript/components/ShapeSource.tsx", "name": "ShapeSource" }, "Style": { @@ -3397,7 +3375,7 @@ "description": "A JSON object conforming to the schema described in the MapLibre Style Specification, or a URL to such JSON." } ], - "fileNameWithExt": "Style.tsx", + "filePath": "javascript/components/Style.tsx", "name": "Style" }, "SymbolLayer": { @@ -3431,7 +3409,7 @@ "BaseProps", "BaseLayerProps" ], - "fileNameWithExt": "SymbolLayer.tsx", + "filePath": "javascript/components/SymbolLayer.tsx", "name": "SymbolLayer", "styles": [ { @@ -4797,7 +4775,6 @@ } ], "returns": { - "description": null, "type": { "name": "Promise", "elements": [ @@ -4817,7 +4794,6 @@ "modifiers": [], "params": [], "returns": { - "description": null, "type": { "name": "boolean" } @@ -4884,7 +4860,7 @@ "description": "Custom location icon of type mapbox-gl-native components\n\nNOTE: Forking maintainer does not understand the above comment." } ], - "fileNameWithExt": "UserLocation.tsx", + "filePath": "javascript/components/UserLocation.tsx", "name": "UserLocation" }, "VectorSource": { @@ -4916,7 +4892,6 @@ } ], "returns": { - "description": null, "type": { "name": "Promise", "elements": [ @@ -5048,12 +5023,12 @@ "composes": [ "BaseProps" ], - "fileNameWithExt": "VectorSource.tsx", + "filePath": "javascript/components/VectorSource.tsx", "name": "VectorSource" }, "coordinates": { "name": "coordinates", - "fileNameWithExt": "locationManager.ts", + "filePath": "javascript/modules/location/locationManager.ts", "description": "Coorinates sent by locationManager", "props": [], "styles": [], @@ -5061,7 +5036,7 @@ }, "location": { "name": "location", - "fileNameWithExt": "locationManager.ts", + "filePath": "javascript/modules/location/locationManager.ts", "description": "Location sent by locationManager", "props": [], "styles": [], @@ -5069,7 +5044,7 @@ }, "offlineManager": { "name": "offlineManager", - "fileNameWithExt": "offlineManager.ts", + "filePath": "javascript/modules/offline/offlineManager.ts", "description": "OfflineManager implements a singleton (shared object) that manages offline packs.\nAll of this class’s instance methods are asynchronous, reflecting the fact that offline resources are stored in a database.\nThe shared object maintains a canonical collection of offline packs.", "props": [], "styles": [], @@ -5396,7 +5371,7 @@ }, "snapshotManager": { "name": "snapshotManager", - "fileNameWithExt": "snapshotManager.ts", + "filePath": "javascript/modules/snapshot/snapshotManager.ts", "description": "The snapshotManager generates static raster images of the map.\nEach snapshot image depicts a portion of a map defined by an SnapshotOptions object you provide.\nThe snapshotter generates the snapshot asynchronous.", "props": [], "styles": [], diff --git a/docs/location.md b/docs/location.md index c9bc56452..795bc1a29 100644 --- a/docs/location.md +++ b/docs/location.md @@ -1,4 +1,5 @@ - + + ## ### Location sent by locationManager diff --git a/docs/offlineManager.md b/docs/offlineManager.md index 59e119f3a..d309d7c0c 100644 --- a/docs/offlineManager.md +++ b/docs/offlineManager.md @@ -1,4 +1,5 @@ - + + ## ### OfflineManager implements a singleton (shared object) that manages offline packs.
All of this class’s instance methods are asynchronous, reflecting the fact that offline resources are stored in a database.
The shared object maintains a canonical collection of offline packs. diff --git a/docs/snapshotManager.md b/docs/snapshotManager.md index ba89e39f9..86fcb4d74 100644 --- a/docs/snapshotManager.md +++ b/docs/snapshotManager.md @@ -1,4 +1,5 @@ - + + ## ### The snapshotManager generates static raster images of the map.
Each snapshot image depicts a portion of a map defined by an SnapshotOptions object you provide.
The snapshotter generates the snapshot asynchronous. From bc3aa7374b3c9e3b9b62b872b29d1aa64d87ba72 Mon Sep 17 00:00:00 2001 From: Kilian Finger Date: Tue, 5 Nov 2024 15:42:03 +0100 Subject: [PATCH 12/13] fix: update @maplibre/maplibre-gl-style-spec --- package.json | 2 +- yarn.lock | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 3ef1d457b..e23c1a79c 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "@babel/plugin-proposal-class-properties": "7.18.6", "@babel/runtime": "7.17.2", "@expo/config-plugins": "^7.2.5", - "@maplibre/maplibre-gl-style-spec": "21.0.0", + "@maplibre/maplibre-gl-style-spec": "21.1.0", "@react-native/babel-preset": "^0.74.88", "@react-native/metro-config": "^0.74.88", "@sinonjs/fake-timers": "^11.2.2", diff --git a/yarn.lock b/yarn.lock index 5947d050d..00e06eec5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3379,22 +3379,22 @@ __metadata: languageName: unknown linkType: soft -"@maplibre/maplibre-gl-style-spec@npm:21.0.0": - version: 21.0.0 - resolution: "@maplibre/maplibre-gl-style-spec@npm:21.0.0" +"@maplibre/maplibre-gl-style-spec@npm:21.1.0": + version: 21.1.0 + resolution: "@maplibre/maplibre-gl-style-spec@npm:21.1.0" dependencies: "@mapbox/jsonlint-lines-primitives": "npm:~2.0.2" "@mapbox/unitbezier": "npm:^0.0.1" json-stringify-pretty-compact: "npm:^4.0.0" minimist: "npm:^1.2.8" - quickselect: "npm:^2.0.0" + quickselect: "npm:^3.0.0" rw: "npm:^1.3.3" tinyqueue: "npm:^3.0.0" bin: gl-style-format: dist/gl-style-format.mjs gl-style-migrate: dist/gl-style-migrate.mjs gl-style-validate: dist/gl-style-validate.mjs - checksum: 10/06d5d95ced163da8980f9f7f530e639fa625f0e0c50d2fde61038bc8d6c3e72f8145d3fb3f3db35babb3e15bc3b6f86a4cdfac97baa03d6861c59453ebc304bc + checksum: 10/25ccfbe90022780f34cd57d2f0520a452e6bc04c52485098c54ebd46e219d727e76901746b18417139c5d5aef6c2f40ebecedc73ea7e2f2c59ae9edb7cbb7106 languageName: node linkType: hard @@ -3407,7 +3407,7 @@ __metadata: "@babel/plugin-proposal-class-properties": "npm:7.18.6" "@babel/runtime": "npm:7.17.2" "@expo/config-plugins": "npm:^7.2.5" - "@maplibre/maplibre-gl-style-spec": "npm:21.0.0" + "@maplibre/maplibre-gl-style-spec": "npm:21.1.0" "@react-native/babel-preset": "npm:^0.74.88" "@react-native/metro-config": "npm:^0.74.88" "@sinonjs/fake-timers": "npm:^11.2.2" @@ -14564,10 +14564,10 @@ __metadata: languageName: node linkType: hard -"quickselect@npm:^2.0.0": - version: 2.0.0 - resolution: "quickselect@npm:2.0.0" - checksum: 10/ed2e78431050d223fb75da20ee98011aef1a03f7cb04e1a32ee893402e640be3cfb76d72e9dbe01edf3bb457ff6a62e5c2d85748424d1aa531f6ba50daef098c +"quickselect@npm:^3.0.0": + version: 3.0.0 + resolution: "quickselect@npm:3.0.0" + checksum: 10/8f72bedb8bb14bce5c3767c55f567bc296fa3ca9d98ba385e3867e434463bc633feee1eddf3dfec17914b7e88feeb08c7b313cf47114a8ff11bf964f77f51cfc languageName: node linkType: hard From c6d4066d0a689510ab04df04859885de998cc32b Mon Sep 17 00:00:00 2001 From: Kilian Finger Date: Tue, 5 Nov 2024 15:47:43 +0100 Subject: [PATCH 13/13] fix: getMarkdownMethodSignature optional formatting --- docs/Camera.md | 8 ++++---- docs/MapView.md | 6 +++--- docs/VectorSource.md | 2 +- docs/offlineManager.md | 2 +- scripts/utils/TemplateHelpers.ts | 20 ++++++-------------- 5 files changed, 15 insertions(+), 23 deletions(-) diff --git a/docs/Camera.md b/docs/Camera.md index fd93d082e..180904753 100644 --- a/docs/Camera.md +++ b/docs/Camera.md @@ -28,7 +28,7 @@ | onUserTrackingModeChange | `func` | `none` | `false` | FIX ME NO DESCRIPTION
*signature:*`(event:MaplibreGLEvent) => void` | ### methods -#### fitBounds(northEastCoordinates, southWestCoordinates[, padding][, animationDuration]) +#### fitBounds(northEastCoordinates, southWestCoordinates, [padding], [animationDuration]) Map camera transitions to fit provided bounds @@ -50,7 +50,7 @@ this.camera.fitBounds([lng, lat], [lng, lat], [top, right, bottom, left], 1000) ``` -#### flyTo(coordinates[, animationDuration]) +#### flyTo(coordinates, [animationDuration]) Map camera will fly to new coordinate @@ -68,7 +68,7 @@ this.camera.flyTo([lng, lat], 12000) ``` -#### moveTo(coordinates[, animationDuration]) +#### moveTo(coordinates, [animationDuration]) Map camera will move to new coordinate at the same zoom level @@ -86,7 +86,7 @@ this.camera.moveTo([lng, lat]) // snaps camera to new location without any easin ``` -#### zoomTo(zoomLevel[, animationDuration]) +#### zoomTo(zoomLevel, [animationDuration]) Map camera will zoom to specified level diff --git a/docs/MapView.md b/docs/MapView.md index e00d1c878..5e8edb5bf 100644 --- a/docs/MapView.md +++ b/docs/MapView.md @@ -79,7 +79,7 @@ const visibleBounds = await this._map.getVisibleBounds(); ``` -#### queryRenderedFeaturesAtPoint(point[, filter][, layerIDs]) +#### queryRenderedFeaturesAtPoint(point, [filter], [layerIDs]) Returns an array of rendered map features that intersect with a given point. @@ -97,7 +97,7 @@ this._map.queryRenderedFeaturesAtPoint([30, 40], ['==', 'type', 'Point'], ['id1' ``` -#### queryRenderedFeaturesInRect(bbox[, filter][, layerIDs]) +#### queryRenderedFeaturesInRect(bbox, [filter], [layerIDs]) Returns an array of rendered map features that intersect with the given rectangle,
restricted to the given style layers and filtered by the given predicate. @@ -167,7 +167,7 @@ const center = await this._map.getCenter(); ``` -#### setSourceVisibility(visible, sourceId[, sourceLayerId]) +#### setSourceVisibility(visible, sourceId, [sourceLayerId]) Sets the visibility of all the layers referencing the specified `sourceLayerId` and/or `sourceId` diff --git a/docs/VectorSource.md b/docs/VectorSource.md index 913a168ca..c09ab9f5b 100644 --- a/docs/VectorSource.md +++ b/docs/VectorSource.md @@ -20,7 +20,7 @@ | children | `React.ReactElement \| React.ReactElement[]` | `none` | `false` | FIX ME NO DESCRIPTION | ### methods -#### features([layerIDs][, filter]) +#### features([layerIDs], [filter]) Returns all features that match the query parameters regardless of whether or not the feature is
currently rendered on the map. The domain of the query includes all currently-loaded vector tiles
and GeoJSON source tiles. This function does not check tiles outside of the visible viewport. diff --git a/docs/offlineManager.md b/docs/offlineManager.md index d309d7c0c..9a49761dd 100644 --- a/docs/offlineManager.md +++ b/docs/offlineManager.md @@ -5,7 +5,7 @@ ### methods -#### createPack(options[, progressListener][, errorListener]) +#### createPack(options, [progressListener], [errorListener]) Creates and registers an offline pack that downloads the resources needed to use the given region offline. diff --git a/scripts/utils/TemplateHelpers.ts b/scripts/utils/TemplateHelpers.ts index 47f45a1f9..1150b8144 100644 --- a/scripts/utils/TemplateHelpers.ts +++ b/scripts/utils/TemplateHelpers.ts @@ -453,21 +453,13 @@ export function propMarkdownTableRows(component: any) { return _propMarkdownTableRows(component.props, ""); } -export function getMarkdownMethodSignature(method: any) { +export function getMarkdownMethodSignature(method: { + name: string; + params: { name: string; optional: boolean }[]; +}) { const params = method.params - .map((param: any, i: number) => { - const isOptional = param.optional; - - let name = ""; - - if (i !== 0) { - name += ", "; - } - - name += param.name; - return isOptional ? `[${name}]` : name; - }) - .join(""); + .map((param) => (param.optional ? `[${param.name}]` : param.name)) + .join(", "); return `${method.name}(${params})`; }