Skip to content

Commit

Permalink
Prettier 3.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
simon04 committed Aug 20, 2023
1 parent 28b859b commit 2ddcd4a
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 38 deletions.
6 changes: 3 additions & 3 deletions OSMXML.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class OSMXML extends XMLFeature {
},
PARSERS,
node,
[options]
[options],
);
// parse nodes in ways
for (let j = 0; j < state.ways.length; j++) {
Expand Down Expand Up @@ -143,7 +143,7 @@ function readNode(node, objectStack) {
},
NODE_PARSERS,
node,
objectStack
objectStack,
);
if (!isEmpty(values.tags)) {
const geometry = new Point(coordinates);
Expand Down Expand Up @@ -172,7 +172,7 @@ function readWay(node, objectStack) {
},
WAY_PARSERS,
node,
objectStack
objectStack,
);
const state = /** @type {Object} */ (objectStack[objectStack.length - 1]);
state.ways.push(values);
Expand Down
6 changes: 3 additions & 3 deletions OverpassVectorLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export default class OverpassVectorLayer extends VectorLayer<
const map = this.getMapInternal();
const features = await Promise.all(
splitQuerySubpart(query).map(({ query, subpart }) =>
this.executeQuery0(query, subpart)
)
this.executeQuery0(query, subpart),
),
);
const vectorSource = new VectorSource({
features: features.reduce((a, b) => [...a, ...b]),
Expand All @@ -39,7 +39,7 @@ export default class OverpassVectorLayer extends VectorLayer<
console.info("Parsed MapCSS", rules);
const vectorSource = this.getSource();
vectorSource?.forEachFeature((feature) =>
feature.setStyle(evaluateStyle(rules, feature))
feature.setStyle(evaluateStyle(rules, feature)),
);
return rules;
}
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
8 changes: 4 additions & 4 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ mapcssTextarea.value ||= store.mapcss;

queryTextarea.addEventListener(
"keydown",
(e) => (e.ctrlKey || e.metaKey) && e.key === "Enter" && executeQueryClick()
(e) => (e.ctrlKey || e.metaKey) && e.key === "Enter" && executeQueryClick(),
);
mapcssTextarea.addEventListener(
"keydown",
(e) => (e.ctrlKey || e.metaKey) && e.key === "Enter" && executeStyleClick()
(e) => (e.ctrlKey || e.metaKey) && e.key === "Enter" && executeStyleClick(),
);

const executeQueryButton = document.getElementById(
"executeQuery"
"executeQuery",
) as HTMLButtonElement;
executeQueryButton.addEventListener("click", executeQueryClick);
async function executeQueryClick() {
Expand All @@ -82,7 +82,7 @@ async function executeQueryClick() {
}

const executeStyleButton = document.getElementById(
"executeStyle"
"executeStyle",
) as HTMLButtonElement;
executeStyleButton.addEventListener("click", executeStyleClick);
async function executeStyleClick() {
Expand Down
40 changes: 20 additions & 20 deletions mapcss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type EvaluatedDeclarations = Partial<

export function evaluateStyle(
rules: Rule[],
feature: Feature | Geometry
feature: Feature | Geometry,
): Style | undefined {
const declarations: EvaluatedDeclarations = evaluateRules(rules, feature);

Expand All @@ -31,15 +31,15 @@ export function evaluateStyle(
? new Fill({
color: evaluateColor(
declarations["fill-color"] as string,
declarations["fill-opacity"] as number
declarations["fill-opacity"] as number,
),
})
: undefined;
const stroke = declarations.width
? new Stroke({
color: evaluateColor(
declarations.color as string,
declarations.opacity as number
declarations.opacity as number,
),
width: declarations.width as number,
lineDash: declarations.dashes as number[],
Expand All @@ -58,14 +58,14 @@ export function evaluateStyle(
fill: new Fill({
color: evaluateColor(
declarations["text-color"] as string,
declarations["text-opacity"] as number
declarations["text-opacity"] as number,
),
}),
stroke: declarations["text-halo-radius"]
? new Stroke({
color: evaluateColor(
declarations["text-halo-color"] as string,
declarations["text-halo-opacity"] as number
declarations["text-halo-opacity"] as number,
),
width: declarations["text-halo-radius"] as number,
})
Expand Down Expand Up @@ -105,20 +105,20 @@ const canvas = new Feature();

export function evaluateCanvas(
rules: Rule[],
layer: TileLayer<OSM>
layer: TileLayer<OSM>,
): EvaluatedDeclarations {
const declarations = evaluateRules(rules, canvas);
layer.setOpacity(
typeof declarations.opacity === "number" ? declarations.opacity : 1.0
typeof declarations.opacity === "number" ? declarations.opacity : 1.0,
);
layer.setBackground(
typeof declarations["fill-color"] === "string"
? declarations["fill-color"]
: undefined
: undefined,
);
document.body.style.setProperty(
"--ol-layer-osm-filter",
declarations["fill-filter"]
declarations["fill-filter"],
);
typeof declarations["fill-image"] === "string" &&
layer.getSource()?.setUrl(declarations["fill-image"]);
Expand All @@ -127,7 +127,7 @@ export function evaluateCanvas(

export function evaluateRules(
rules: Rule[],
feature: Feature | Geometry
feature: Feature | Geometry,
): EvaluatedDeclarations {
const declarations: EvaluatedDeclarations = {};
rules.forEach((rule) => evaluateRule(rule, feature, declarations));
Expand All @@ -137,14 +137,14 @@ export function evaluateRules(
function evaluateRule(
rule: Rule,
feature: Feature | Geometry,
declarations: EvaluatedDeclarations
declarations: EvaluatedDeclarations,
) {
const matches = rule.selectors.some((selector) =>
matchesSelector(selector, feature)
matchesSelector(selector, feature),
);
if (!matches) return;
rule.declaration.forEach((declaration) =>
Object.assign(declarations, evaluateDeclaration(declaration, feature))
Object.assign(declarations, evaluateDeclaration(declaration, feature)),
);
}

Expand Down Expand Up @@ -186,7 +186,7 @@ function matchesBase(base: Base, feature: Feature | Geometry) {

function matchesCondition(
condition: Condition,
feature: Feature | Geometry
feature: Feature | Geometry,
): boolean {
switch (condition.type) {
case "KeyCondition":
Expand All @@ -200,16 +200,16 @@ function matchesCondition(
}
function matchesKeyCondition(
{ key, not }: KeyCondition,
feature: Feature | Geometry
feature: Feature | Geometry,
): boolean {
const bool = Object.keys(feature.getProperties()).some((k) =>
matchesStringOrRegExp(key, k)
matchesStringOrRegExp(key, k),
);
return not ? !bool : bool;
}
function matchesKeyValueCondition(
{ key, value, op }: KeyValueCondition,
feature: Feature | Geometry
feature: Feature | Geometry,
): boolean {
let bool: boolean;
const osmValue: string =
Expand All @@ -228,7 +228,7 @@ function matchesKeyValueCondition(
}
function matchesClassCondition(
{ cls, not }: ClassCondition,
feature: Feature | Geometry
feature: Feature | Geometry,
) {
const bool = feature.get(`MapCSS-class-${cls}`);
return not ? !bool : bool;
Expand All @@ -239,7 +239,7 @@ function matchesStringOrRegExp(key: string | RegExp, str: string): boolean {

function evaluateDeclaration(
declaration: Declaration,
feature: Feature | Geometry
feature: Feature | Geometry,
) {
if (declaration.type === "SetInstruction") {
feature.set(`MapCSS-class-${declaration.cls}`, true);
Expand All @@ -254,7 +254,7 @@ function evaluateDeclaration(
}
function evaluateExpression(
expression: Expression,
feature: Feature | Geometry
feature: Feature | Geometry,
): string | number | number[] | undefined {
if (
typeof expression === "string" ||
Expand Down
4 changes: 2 additions & 2 deletions overpass.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export function splitQuerySubpart(
query: string
query: string,
): { query: string; subpart: string | undefined; start: number }[] {
const regexp = /\/\/\/\s*@subpart (?<subpart>[^\n]+)/dg;
if (!query.match(regexp)) {
Expand All @@ -14,7 +14,7 @@ export function splitQuerySubpart(
subpart: match.groups?.subpart,
start,
};
}
},
);
if (subparts[0]?.start > 0) {
const first = query.slice(0, subparts[0]?.start).trim();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@types/geojson": "^7946.0.10",
"bun-types": "^0.5.8",
"peggy": "^3.0.2",
"prettier": "^2.8.8",
"prettier": "^3.0.2",
"vite": "^4.4.9"
},
"dependencies": {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,10 @@ postcss@^8.4.27:
picocolors "^1.0.0"
source-map-js "^1.0.2"

prettier@^2.8.8:
version "2.8.8"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da"
integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==
prettier@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.0.2.tgz#78fcecd6d870551aa5547437cdae39d4701dca5b"
integrity sha512-o2YR9qtniXvwEZlOKbveKfDQVyqxbEIWn48Z8m3ZJjBjcCmUy3xZGIv+7AkaeuaTr6yPXJjwv07ZWlsWbEy1rQ==

protocol-buffers-schema@^3.3.1:
version "3.6.0"
Expand Down

0 comments on commit 2ddcd4a

Please sign in to comment.