@emuanalytics/flow-rdf-core 4.1.7 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,164 @@
1
+ import { isPlainObject } from '../../utils/type-checks.mjs';
2
+ import { isExactString, attributeExpression, quoteString, formatNumber } from './literals.mjs';
3
+
4
+ function expandDataDriven(dataDriven, path, format) {
5
+ const issues = [];
6
+ const problem = (at, message) => issues.push({ path: at, message, severity: format.severity });
7
+ if (!isPlainObject(dataDriven) || Array.isArray(dataDriven)) {
8
+ problem(path, "A data-driven table must be an object.");
9
+ return { expression: void 0, issues };
10
+ }
11
+ const table = dataDriven;
12
+ if (!Array.isArray(table.values)) {
13
+ problem(`${path}.values`, "A data-driven table needs a `values` array.");
14
+ return { expression: void 0, issues };
15
+ }
16
+ const rows = [];
17
+ let keyType;
18
+ let mixed = false;
19
+ table.values.forEach((row, index) => {
20
+ const rowPath = `${path}.values[${index}]`;
21
+ if (!Array.isArray(row) || row.length < 2 || row.length > 3) {
22
+ problem(rowPath, "A row must be an array of a key, a value and optional options.");
23
+ return;
24
+ }
25
+ const [key, , options] = row;
26
+ if (!(typeof key === "string" || typeof key === "number" && Number.isFinite(key))) {
27
+ problem(rowPath, "A row key must be a string or a number.");
28
+ return;
29
+ }
30
+ if (options !== void 0 && (!isPlainObject(options) || Array.isArray(options))) {
31
+ problem(rowPath, "Row options must be an object.");
32
+ return;
33
+ }
34
+ const type = typeof key;
35
+ if (keyType === void 0) {
36
+ keyType = type;
37
+ } else if (keyType !== type) {
38
+ mixed = true;
39
+ }
40
+ rows.push(row);
41
+ });
42
+ if (mixed) {
43
+ problem(`${path}.values`, "All row keys must be of one type: strings or numbers.");
44
+ }
45
+ const mode = format.mode(table.mode, keyType, `${path}.mode`, issues);
46
+ if (mode !== "off" && !(typeof table.attribute === "string" && table.attribute.length > 0)) {
47
+ problem(`${path}.attribute`, "A data-driven table needs an `attribute`: the feature property to read.");
48
+ } else if (mode !== "off" && !isExactString(table.attribute, '"')) {
49
+ problem(`${path}.attribute`, "This feature property name cannot be written in a reactive expression.");
50
+ }
51
+ if ((mode === "step" || mode === "interpolate") && keyType === "string") {
52
+ problem(`${path}.values`, `Keys in ${mode} mode must be numbers.`);
53
+ }
54
+ if (mode === "interpolate") {
55
+ const keys = rows.map(([key]) => key);
56
+ if (new Set(keys).size !== keys.length) {
57
+ problem(`${path}.values`, "Keys in interpolate mode must be distinct.");
58
+ }
59
+ if (keys.some((key) => typeof key === "number" && key < 0)) {
60
+ problem(`${path}.values`, "Keys in interpolate mode cannot be negative.");
61
+ }
62
+ }
63
+ if (mode === "match") {
64
+ rows.forEach(([key, , options], index) => {
65
+ if (typeof key === "string" && options?.regexp) {
66
+ try {
67
+ new RegExp(key);
68
+ } catch {
69
+ problem(`${path}.values[${index}]`, `'${key}' is not a valid regular expression.`);
70
+ }
71
+ }
72
+ });
73
+ }
74
+ if (!("default" in table) || table.default === void 0) {
75
+ problem(`${path}.default`, "A data-driven table needs a `default` value.");
76
+ }
77
+ if (hasProblem(issues, format.severity)) {
78
+ return { expression: void 0, issues };
79
+ }
80
+ const defaultValue = format.value(table.default, `${path}.default`, issues);
81
+ const writtenValues = rows.map(([, value], index) => format.value(value, `${path}.values[${index}]`, issues));
82
+ if (defaultValue === void 0 || writtenValues.some((value) => value === void 0)) {
83
+ return { expression: void 0, issues };
84
+ }
85
+ const written = rows.map(([key, , options], index) => [
86
+ key,
87
+ writtenValues[index],
88
+ options
89
+ ]);
90
+ if (mode === "off" || written.length === 0) {
91
+ return { expression: defaultValue, issues };
92
+ }
93
+ const attribute = attributeExpression(table.attribute);
94
+ switch (mode) {
95
+ case "match":
96
+ return { expression: matchExpression(attribute, written, defaultValue, format), issues };
97
+ case "step":
98
+ return { expression: stepExpression(attribute, written, defaultValue, format), issues };
99
+ case "interpolate":
100
+ return { expression: interpolateExpression(attribute, written, defaultValue, format), issues };
101
+ }
102
+ }
103
+ function hasProblem(issues, severity) {
104
+ return issues.some((issue) => issue.severity === severity);
105
+ }
106
+ function matchExpression(attribute, rows, defaultValue, format) {
107
+ const cases = rows.map(([key, value, options]) => {
108
+ if (typeof key === "number") {
109
+ return `${attribute} == ${format.number(key)}, ${value}`;
110
+ }
111
+ const operator = options?.regexp ? options.caseSensitive ? "~" : "~*" : options?.caseSensitive ? "==" : "=*";
112
+ return `${attribute} ${operator} ${format.key(key)}, ${value}`;
113
+ });
114
+ return `case(${cases.join(", ")}, ${defaultValue})`;
115
+ }
116
+ function stepExpression(attribute, rows, defaultValue, format) {
117
+ const cases = [...rows].sort((a, b) => b[0] - a[0]).map(([key, value]) => `${attribute} >= ${format.number(key)}, ${value}`);
118
+ return `case(${attribute} == null, ${defaultValue}, ${cases.join(", ")}, ${defaultValue})`;
119
+ }
120
+ function interpolateExpression(attribute, rows, defaultValue, format) {
121
+ const stops = [...rows].sort((a, b) => a[0] - b[0]).map(([key, value]) => `${format.number(key)}, ${value}`);
122
+ return `typeof(${attribute}) == 'number' ? interpolate(linear(), ${attribute}, ${stops.join(", ")}) : ${defaultValue}`;
123
+ }
124
+ function writeLiteralV2(value, path, issues, severity) {
125
+ if (typeof value === "string") {
126
+ if (!isExactString(value)) {
127
+ issues.push({ path, message: "This string cannot be written in a reactive expression.", severity });
128
+ return void 0;
129
+ }
130
+ return quoteString(value);
131
+ }
132
+ if (typeof value === "number" && Number.isFinite(value)) {
133
+ return formatNumber(value);
134
+ }
135
+ if (typeof value === "boolean") {
136
+ return String(value);
137
+ }
138
+ issues.push({ path, message: "Expected a string, a number or a boolean.", severity });
139
+ return void 0;
140
+ }
141
+ const V2_MODES = ["match", "step", "interpolate", "off"];
142
+ const DATA_DRIVEN_FORMAT_V2 = {
143
+ severity: "warning",
144
+ mode(mode, _keyType, path, issues) {
145
+ if (V2_MODES.includes(mode)) {
146
+ return mode;
147
+ }
148
+ issues.push({ path, message: "The mode must be `match`, `step`, `interpolate` or `off`.", severity: "warning" });
149
+ return "off";
150
+ },
151
+ value: (value, path, issues) => writeLiteralV2(value, path, issues, "warning"),
152
+ key: (key) => quoteString(key),
153
+ number: formatNumber
154
+ };
155
+ function dataDrivenExpression(dataDriven) {
156
+ const { expression } = expandDataDriven(dataDriven, "dataDriven", DATA_DRIVEN_FORMAT_V2);
157
+ if (expression !== void 0) {
158
+ return expression;
159
+ }
160
+ const fallback = isPlainObject(dataDriven) ? writeLiteralV2(dataDriven.default, "dataDriven.default", [], "warning") : void 0;
161
+ return fallback ?? "null";
162
+ }
163
+
164
+ export { DATA_DRIVEN_FORMAT_V2, dataDrivenExpression, expandDataDriven, writeLiteralV2 };
@@ -0,0 +1,145 @@
1
+ import { validateFlowStyle } from './validate.mjs';
2
+ import { flowStyleVersion, flowStylePropertyExpression } from './values.mjs';
3
+
4
+ const VISIBILITY = ["visibility", "visibility"];
5
+ const CIRCLE_RULES = [
6
+ ["circle-color", "fillColor"],
7
+ ["circle-stroke-color", "strokeColor"],
8
+ ["circle-stroke-width", "strokeWidth"],
9
+ ["circle-radius", "radius"],
10
+ ["circle-opacity", "opacity"],
11
+ ["circle-stroke-opacity", "opacity"],
12
+ VISIBILITY
13
+ ];
14
+ const FILL_RULES = [["fill-color", "fillColor"], ["fill-opacity", "opacity"], VISIBILITY];
15
+ const STROKE_RULES = [
16
+ ["line-color", "strokeColor"],
17
+ ["line-width", "strokeWidth"],
18
+ ["line-opacity", "opacity"],
19
+ VISIBILITY
20
+ ];
21
+ const LINE_RULES = {
22
+ 1: [["line-color", "strokeColor"], ["line-width", "strokeWidth"], VISIBILITY],
23
+ 2: STROKE_RULES
24
+ };
25
+ const LABEL_RULES = [
26
+ ["text-field", "labelText"],
27
+ ["text-color", "labelColor"],
28
+ ["text-halo-color", "labelHaloColor"],
29
+ ["text-halo-blur", { constant: "1" }],
30
+ ["text-halo-width", { constant: "2" }],
31
+ ["text-size", "labelSize"],
32
+ ["text-opacity", "opacity"],
33
+ VISIBILITY
34
+ ];
35
+ const CIRCLE_LABEL_RULES = [
36
+ ["text-variable-anchor", { constant: "['top']" }],
37
+ ["text-radial-offset", { constant: "1.2" }]
38
+ ];
39
+ const GEOMETRIES = ["circle", "line", "fill"];
40
+ const STYLE_PATHS = ["", "type", "version"];
41
+ function expandFlowStyle(id, style, options = {}) {
42
+ try {
43
+ return expand(id, style, options);
44
+ } catch (e) {
45
+ return {
46
+ version: void 0,
47
+ geometry: void 0,
48
+ subLayers: [],
49
+ issues: [
50
+ { path: "", message: `The style could not be read: ${e?.message ?? String(e)}`, severity: "error" }
51
+ ]
52
+ };
53
+ }
54
+ }
55
+ function expand(id, style, options) {
56
+ const issues = validateFlowStyle(style);
57
+ const version = flowStyleVersion(style);
58
+ const none = (geometry2) => ({ version, geometry: geometry2, subLayers: [], issues });
59
+ if (version === void 0 || issues.some((issue) => issue.severity === "error" && STYLE_PATHS.includes(issue.path))) {
60
+ return none();
61
+ }
62
+ const object = style;
63
+ const geometry = version === 2 ? object.type : options.geometry;
64
+ if (!GEOMETRIES.includes(geometry)) {
65
+ issues.push({
66
+ path: "",
67
+ message: `A version 1 flow style is drawn as a circle, line or fill layer, not ${describeValue(geometry)}.`,
68
+ severity: "error"
69
+ });
70
+ return none();
71
+ }
72
+ const interactive = resolveInteractive(version, options.interactive, issues);
73
+ const expressions = /* @__PURE__ */ new Map();
74
+ const expression = (property) => {
75
+ if (!expressions.has(property)) {
76
+ const value = object[property];
77
+ expressions.set(
78
+ property,
79
+ isSet(version, property, value) ? flowStylePropertyExpression(version, property, value).expression : void 0
80
+ );
81
+ }
82
+ return expressions.get(property);
83
+ };
84
+ const program = (rules) => rules.map(([property, from]) => [property, typeof from === "string" ? expression(from) : from.constant]).filter(([, value]) => value !== void 0).map(([property, value]) => `${property}: ${value};`).join("\n");
85
+ const subLayers = [];
86
+ const add = (suffix, type, role, rules) => subLayers.push({
87
+ id: `${id}${suffix}`,
88
+ type,
89
+ style: program(rules),
90
+ interactive: role !== "label" && interactive,
91
+ role
92
+ });
93
+ switch (geometry) {
94
+ case "circle":
95
+ add("", "circle", "geometry", CIRCLE_RULES);
96
+ break;
97
+ case "fill":
98
+ add("", "fill", "geometry", FILL_RULES);
99
+ add("__stroke", "line", "stroke", STROKE_RULES);
100
+ break;
101
+ case "line":
102
+ add("", "line", "geometry", LINE_RULES[version]);
103
+ break;
104
+ }
105
+ if (hasLabel(version, object.labelText) && expression("labelText") !== void 0) {
106
+ const rules = LABEL_RULES.filter(
107
+ ([property]) => !["text-halo-blur", "text-halo-width"].includes(property) || expression("labelHaloColor")
108
+ );
109
+ add("__label", "symbol", "label", geometry === "circle" ? [...rules, ...CIRCLE_LABEL_RULES] : rules);
110
+ }
111
+ return { version, geometry, subLayers, issues };
112
+ }
113
+ function isSet(version, property, value) {
114
+ if (version === 2) {
115
+ return value !== void 0;
116
+ }
117
+ return property === "visibility" ? value !== void 0 && value !== null : !!value;
118
+ }
119
+ function hasLabel(version, labelText) {
120
+ if (typeof labelText === "string") {
121
+ return labelText.length > 0;
122
+ }
123
+ return version === 2 && labelText !== void 0;
124
+ }
125
+ function resolveInteractive(version, interactive, issues) {
126
+ if (typeof interactive === "boolean") {
127
+ return interactive;
128
+ }
129
+ if (interactive !== void 0 && version === 2) {
130
+ issues.push({
131
+ path: "",
132
+ message: `The layer's \`interactive\` option must be a boolean, not ${describeValue(interactive)}; the default (\`true\`) applies.`,
133
+ severity: "warning"
134
+ });
135
+ }
136
+ return true;
137
+ }
138
+ function describeValue(value) {
139
+ if (typeof value === "string") {
140
+ return `'${value}'`;
141
+ }
142
+ return value === void 0 ? "none" : JSON.stringify(value) ?? String(value);
143
+ }
144
+
145
+ export { expandFlowStyle };
@@ -0,0 +1,58 @@
1
+ import { ExpressionParser } from '../../expressions/expression-parser.mjs';
2
+
3
+ const parser = new ExpressionParser();
4
+ function quoteString(value, quote = "'") {
5
+ const other = quote === "'" ? '"' : "'";
6
+ if (!value.includes(quote)) {
7
+ return `${quote}${value}${quote}`;
8
+ }
9
+ if (!value.includes(other)) {
10
+ return `${other}${value}${other}`;
11
+ }
12
+ const args = [];
13
+ value.split("'").forEach((piece, index) => {
14
+ if (index > 0) {
15
+ args.push(`"'"`);
16
+ }
17
+ if (piece.length > 0) {
18
+ args.push(`'${piece}'`);
19
+ }
20
+ });
21
+ return `concat(${args.join(", ")})`;
22
+ }
23
+ function isExactString(value, quote = "'") {
24
+ const result = parser.parseExpression(`f(${quoteString(value, quote)}, 'z')`);
25
+ if (!result.status) {
26
+ return false;
27
+ }
28
+ const [, parsed, after] = result.value;
29
+ if (after !== "z") {
30
+ return false;
31
+ }
32
+ if (typeof parsed === "string") {
33
+ return parsed === value;
34
+ }
35
+ return Array.isArray(parsed) && parsed[0] === "concat" && parsed.slice(1).every((piece) => typeof piece === "string") && parsed.slice(1).join("") === value;
36
+ }
37
+ function attributeExpression(attribute) {
38
+ return `get(${quoteString(attribute, '"')})`;
39
+ }
40
+ function formatNumber(value) {
41
+ const text = String(value);
42
+ if (!/e/i.test(text)) {
43
+ return text;
44
+ }
45
+ return value.toLocaleString("en-US", { useGrouping: false, maximumFractionDigits: 20 });
46
+ }
47
+ function escapeLegacyString(value) {
48
+ return value.replace(/['\\]/g, "\\$&");
49
+ }
50
+ function expressionParseError(expression) {
51
+ const result = parser.parseExpression(expression);
52
+ if (result.status) {
53
+ return void 0;
54
+ }
55
+ return `expected ${result.expected.join(" ")} at offset ${result.index.offset}`;
56
+ }
57
+
58
+ export { attributeExpression, escapeLegacyString, expressionParseError, formatNumber, isExactString, quoteString };
@@ -0,0 +1,93 @@
1
+ import { isPlainObject } from '../../utils/type-checks.mjs';
2
+ import { cloneStoredValue, isStyleExpression, toStoredValueV2, isDataDrivenTable, isFlowStyleExpression } from './builder.mjs';
3
+ import { dataDrivenExpression } from './data-driven.mjs';
4
+ import { quoteString } from './literals.mjs';
5
+ import { flowStyleVersion, isFlowStylePropertyName, FLOW_STYLE_PROPERTIES, flowStylePropertyExpression } from './values.mjs';
6
+
7
+ function loadStoredFlowStyle(style) {
8
+ return { version: flowStyleVersion(style), style: cloneStoredValue(style) };
9
+ }
10
+ function saveStoredFlowStyle(stored) {
11
+ return cloneStoredValue(stored.style);
12
+ }
13
+ function setStoredFlowStyleProperty(stored, property, value) {
14
+ const version = stored.version ?? 2;
15
+ const style = isPlainObject(stored.style) && !Array.isArray(stored.style) ? cloneStoredValue(stored.style) : {};
16
+ const written = value === void 0 || value === null ? void 0 : toStoredValue(version, property, value);
17
+ if (written === void 0) {
18
+ delete style[property];
19
+ } else {
20
+ Object.defineProperty(style, property, { value: written, enumerable: true, writable: true, configurable: true });
21
+ }
22
+ return { version: stored.version, style: version === 1 ? withVersion1(style) : style };
23
+ }
24
+ function toStoredValue(version, property, value) {
25
+ if (!isFlowStylePropertyName(property)) {
26
+ return isStyleExpression(value) ? { type: "expression", value: value.toString() } : cloneStoredValue(value);
27
+ }
28
+ return version === 1 ? toStoredValueV1(property, value) : toStoredValueV2(value);
29
+ }
30
+ function withVersion1(style) {
31
+ if (style.version !== void 0) {
32
+ return style;
33
+ }
34
+ const keys = Object.keys(style);
35
+ const entries = keys.includes("type") ? [] : [["version", 1]];
36
+ for (const key of keys) {
37
+ entries.push([key, style[key]]);
38
+ if (key === "type") {
39
+ entries.push(["version", 1]);
40
+ }
41
+ }
42
+ const result = {};
43
+ for (const [key, entryValue] of entries) {
44
+ Object.defineProperty(result, key, { value: entryValue, enumerable: true, writable: true, configurable: true });
45
+ }
46
+ return result;
47
+ }
48
+ function toStoredValueV1(property, value) {
49
+ if (isStyleExpression(value)) {
50
+ return expressionV1(property, value.toString());
51
+ }
52
+ if (isDataDrivenTable(value)) {
53
+ return dataDrivenToV1(property, value);
54
+ }
55
+ if (isFlowStyleExpression(value)) {
56
+ const { dataDriven } = value;
57
+ if (isDataDrivenTable(dataDriven) && value.value === dataDrivenExpression(dataDriven)) {
58
+ return dataDrivenToV1(property, dataDriven);
59
+ }
60
+ return expressionV1(property, value.value);
61
+ }
62
+ if (typeof value === "string") {
63
+ if (FLOW_STYLE_PROPERTIES[property] === "size") {
64
+ return value;
65
+ }
66
+ const literal = quoteString(value);
67
+ if (`'${value}'` !== literal) {
68
+ return { type: "expression", value: literal };
69
+ }
70
+ return value.startsWith("@") ? { type: "literal", value } : value;
71
+ }
72
+ return cloneStoredValue(value);
73
+ }
74
+ function expressionV1(property, expression) {
75
+ if (property === "labelText" && typeof expression === "string" && expression.startsWith("@")) {
76
+ return expression;
77
+ }
78
+ return { type: "expression", value: expression };
79
+ }
80
+ function dataDrivenToV1(property, table) {
81
+ const expression = dataDrivenExpression(table);
82
+ const converted = {
83
+ type: "data-driven",
84
+ attribute: table.attribute,
85
+ default: cloneStoredValue(table.default),
86
+ ...table.mode === "off" || table.mode === "interpolate" ? { mode: table.mode } : {},
87
+ values: cloneStoredValue(table.values)
88
+ };
89
+ const v1 = flowStylePropertyExpression(1, property, converted).expression;
90
+ return v1 === expression ? converted : expressionV1(property, expression);
91
+ }
92
+
93
+ export { loadStoredFlowStyle, saveStoredFlowStyle, setStoredFlowStyleProperty };
@@ -0,0 +1,117 @@
1
+ import { isPlainObject } from '../../utils/type-checks.mjs';
2
+ import { flowStyleVersion, isFlowStylePropertyName, flowStylePropertyExpression } from './values.mjs';
3
+
4
+ const GEOMETRIES = ["circle", "line", "fill"];
5
+ const OTHER_MAPLIBRE_TYPES = [
6
+ "symbol",
7
+ "heatmap",
8
+ "fill-extrusion",
9
+ "raster",
10
+ "hillshade",
11
+ "background"
12
+ ];
13
+ const UNUSED_BY_GEOMETRY = {
14
+ circle: [],
15
+ line: ["fillColor", "radius"],
16
+ fill: ["radius"]
17
+ };
18
+ function validateFlowStyle(style) {
19
+ try {
20
+ return validate(style);
21
+ } catch (e) {
22
+ return [
23
+ { path: "", message: `The style could not be read: ${e?.message ?? String(e)}`, severity: "error" }
24
+ ];
25
+ }
26
+ }
27
+ function validate(style) {
28
+ const issues = [];
29
+ const error = (path, message) => {
30
+ issues.push({ path, message, severity: "error" });
31
+ return issues;
32
+ };
33
+ if (!isPlainObject(style) || Array.isArray(style)) {
34
+ return error("", `A flow style must be an object, not ${describe(style)}.`);
35
+ }
36
+ const object = style;
37
+ const keys = Object.keys(object);
38
+ if (keys.length === 0) {
39
+ return error("", "The style is empty: it needs a `type`.");
40
+ }
41
+ const version = flowStyleVersion(object);
42
+ if (version === void 0) {
43
+ return error("version", `Unknown version ${describe(object.version)}: expected 1 or 2.`);
44
+ }
45
+ const typeIssue = checkType(object.type, version, object.version !== void 0);
46
+ if (typeIssue) {
47
+ return error("type", typeIssue);
48
+ }
49
+ const geometry = version === 2 ? object.type : void 0;
50
+ for (const key of keys) {
51
+ if (key === "type" || key === "version") {
52
+ continue;
53
+ }
54
+ if (!isFlowStylePropertyName(key)) {
55
+ issues.push({ path: key, message: `Unknown property '${key}' is kept but not used.`, severity: "warning" });
56
+ continue;
57
+ }
58
+ issues.push(...flowStylePropertyExpression(version, key, object[key]).issues);
59
+ if (geometry && UNUSED_BY_GEOMETRY[geometry].includes(key)) {
60
+ issues.push({ path: key, message: `\`${key}\` is not used by ${geometry} styles.`, severity: "warning" });
61
+ }
62
+ if (version === 1 && key === "labelText" && object[key] !== void 0) {
63
+ if (typeof object[key] !== "string") {
64
+ issues.push({
65
+ path: key,
66
+ message: "Version 1 draws a label only when `labelText` is a plain string, such as `@name`.",
67
+ severity: "warning"
68
+ });
69
+ }
70
+ }
71
+ }
72
+ return issues;
73
+ }
74
+ function checkType(type, version, hasVersion) {
75
+ if (type === void 0) {
76
+ return "The style has no `type`.";
77
+ }
78
+ if (version === 1) {
79
+ if (type === "flow") {
80
+ return void 0;
81
+ }
82
+ if (typeof type === "string" && GEOMETRIES.includes(type)) {
83
+ return hasVersion ? "A version 1 style has `type: 'flow'`; its geometry is on the composite sub-layer." : `A version 2 style needs \`version: 2\`. A style with no version is read as version 1, whose \`type\` is 'flow'.`;
84
+ }
85
+ } else {
86
+ if (typeof type === "string" && GEOMETRIES.includes(type)) {
87
+ return void 0;
88
+ }
89
+ if (type === "flow") {
90
+ return "A version 2 style's `type` is its geometry: 'circle', 'line' or 'fill'.";
91
+ }
92
+ }
93
+ if (typeof type === "string" && OTHER_MAPLIBRE_TYPES.includes(type)) {
94
+ return `Unsupported geometry '${type}': flow styles support 'circle', 'line' and 'fill'.`;
95
+ }
96
+ return `Unknown type ${describe(type)}.`;
97
+ }
98
+ function describe(value) {
99
+ if (value === null) {
100
+ return "null";
101
+ }
102
+ if (Array.isArray(value)) {
103
+ return "an array";
104
+ }
105
+ if (typeof value === "string") {
106
+ return `'${value}'`;
107
+ }
108
+ if (typeof value === "object") {
109
+ return "an object";
110
+ }
111
+ if (typeof value === "function") {
112
+ return "a function";
113
+ }
114
+ return String(value);
115
+ }
116
+
117
+ export { validateFlowStyle };