This repository has been archived by the owner on Jul 6, 2023. It is now read-only.
forked from protomaps/protomaps-leaflet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
With the install step requiring esbuild, running npm install in apps that imported this package but not esbuild failed. This removes the install step, removes the dist folder from gitignore and adds the build step as a pre-commit hook
- Loading branch information
Showing
44 changed files
with
15,958 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
node_modules | ||
dist | ||
src/**/*.js | ||
test/*.js | ||
.tool-versions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npx lint-staged | ||
npm run dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Feature } from "./tilecache"; | ||
export declare class StringAttr { | ||
str: string | ((z: number, f?: Feature) => string); | ||
per_feature: boolean; | ||
constructor(c: any, defaultValue?: string); | ||
get(z: number, f?: Feature): string; | ||
} | ||
export declare class NumberAttr { | ||
value: number | ((z: number, f?: Feature) => number); | ||
per_feature: boolean; | ||
constructor(c: any, defaultValue?: number); | ||
get(z: number, f?: Feature): number; | ||
} | ||
export declare class TextAttr { | ||
label_props: string[] | ((z: number, f?: Feature) => string[]); | ||
textTransform: string | ((z: number, f?: Feature) => string); | ||
constructor(options?: any); | ||
get(z: number, f: Feature): string; | ||
} | ||
export declare class FontAttr { | ||
family?: string | ((z: number, f: Feature) => string); | ||
size?: number | ((z: number, f: Feature) => number); | ||
weight?: number | ((z: number, f: Feature) => number); | ||
style?: number | ((z: number, f: Feature) => string); | ||
font?: string | ((z: number, f: Feature) => string); | ||
constructor(options: any); | ||
get(z: number, f: Feature): string; | ||
} | ||
export declare class ArrayAttr { | ||
value: string[] | number[] | ((z: number, f?: Feature) => string[] | number[]); | ||
per_feature: boolean; | ||
constructor(c: any, defaultValue?: number[]); | ||
get(z: number, f?: Feature): string[] | number[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
export class StringAttr { | ||
constructor(c, defaultValue = "") { | ||
this.str = c || defaultValue; | ||
this.per_feature = typeof this.str == "function" && this.str.length == 2; | ||
} | ||
get(z, f) { | ||
if (typeof this.str == "function") { | ||
return this.str(z, f); | ||
} | ||
else { | ||
return this.str; | ||
} | ||
} | ||
} | ||
export class NumberAttr { | ||
constructor(c, defaultValue = 1) { | ||
this.value = c || defaultValue; | ||
this.per_feature = | ||
typeof this.value == "function" && this.value.length == 2; | ||
} | ||
get(z, f) { | ||
if (typeof this.value == "function") { | ||
return this.value(z, f); | ||
} | ||
else { | ||
return this.value; | ||
} | ||
} | ||
} | ||
export class TextAttr { | ||
constructor(options = {}) { | ||
this.label_props = options.label_props || ["name"]; | ||
this.textTransform = options.textTransform; | ||
} | ||
get(z, f) { | ||
var retval; | ||
var label_props; | ||
if (typeof this.label_props == "function") { | ||
label_props = this.label_props(z, f); | ||
} | ||
else { | ||
label_props = this.label_props; | ||
} | ||
for (let property of label_props) { | ||
if (f.props.hasOwnProperty(property)) { | ||
retval = f.props[property]; | ||
break; | ||
} | ||
} | ||
let transform; | ||
if (typeof this.textTransform === "function") { | ||
transform = this.textTransform(z, f); | ||
} | ||
else { | ||
transform = this.textTransform; | ||
} | ||
if (retval && transform === "uppercase") | ||
retval = retval.toUpperCase(); | ||
else if (retval && transform === "lowercase") | ||
retval = retval.toLowerCase(); | ||
else if (retval && transform === "capitalize") { | ||
const wordsArray = retval.toLowerCase().split(" "); | ||
const capsArray = wordsArray.map((word) => { | ||
return word[0].toUpperCase() + word.slice(1); | ||
}); | ||
retval = capsArray.join(" "); | ||
} | ||
return retval; | ||
} | ||
} | ||
export class FontAttr { | ||
constructor(options) { | ||
if (options.font) { | ||
this.font = options.font; | ||
} | ||
else { | ||
this.family = options.fontFamily || "sans-serif"; | ||
this.size = options.fontSize || 12; | ||
this.weight = options.fontWeight; | ||
this.style = options.fontStyle; | ||
} | ||
} | ||
get(z, f) { | ||
if (this.font) { | ||
if (typeof this.font === "function") { | ||
return this.font(z, f); | ||
} | ||
else { | ||
return this.font; | ||
} | ||
} | ||
else { | ||
var style = ""; | ||
if (this.style) { | ||
if (typeof this.style === "function") { | ||
style = this.style(z, f) + " "; | ||
} | ||
else { | ||
style = this.style + " "; | ||
} | ||
} | ||
var weight = ""; | ||
if (this.weight) { | ||
if (typeof this.weight === "function") { | ||
weight = this.weight(z, f) + " "; | ||
} | ||
else { | ||
weight = this.weight + " "; | ||
} | ||
} | ||
var size; | ||
if (typeof this.size === "function") { | ||
size = this.size(z, f); | ||
} | ||
else { | ||
size = this.size; | ||
} | ||
var family; | ||
if (typeof this.family === "function") { | ||
family = this.family(z, f); | ||
} | ||
else { | ||
family = this.family; | ||
} | ||
return `${style}${weight}${size}px ${family}`; | ||
} | ||
} | ||
} | ||
export class ArrayAttr { | ||
constructor(c, defaultValue = []) { | ||
this.value = c || defaultValue; | ||
this.per_feature = | ||
typeof this.value == "function" && this.value.length == 2; | ||
} | ||
get(z, f) { | ||
if (typeof this.value == "function") { | ||
return this.value(z, f); | ||
} | ||
else { | ||
return this.value; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { PolygonSymbolizer, LineSymbolizer, LineLabelSymbolizer, CenteredTextSymbolizer, CircleSymbolizer } from "./../symbolizer"; | ||
import { Filter } from "../painter"; | ||
import { Feature } from "../tilecache"; | ||
export declare function filterFn(arr: any[]): Filter; | ||
export declare function numberFn(obj: any): (z: number, f: Feature) => number; | ||
export declare function numberOrFn(obj: any, defaultValue?: number): number | ((z: number, f: Feature) => number); | ||
export declare function widthFn(width_obj: any, gap_obj: any): (z: number, f: Feature) => number; | ||
interface FontSub { | ||
face: string; | ||
weight?: number; | ||
style?: string; | ||
} | ||
export declare function getFont(obj: any, fontsubmap: any): string | ((z: number, feature: Feature) => string); | ||
export declare function json_style(obj: any, fontsubmap: Map<string, FontSub>): { | ||
paint_rules: ({ | ||
dataLayer: any; | ||
filter: Filter | undefined; | ||
symbolizer: PolygonSymbolizer; | ||
} | { | ||
dataLayer: any; | ||
filter: Filter | undefined; | ||
symbolizer: LineSymbolizer; | ||
} | { | ||
dataLayer: any; | ||
filter: Filter | undefined; | ||
symbolizer: CircleSymbolizer; | ||
})[]; | ||
label_rules: ({ | ||
dataLayer: any; | ||
filter: Filter | undefined; | ||
symbolizer: LineLabelSymbolizer; | ||
} | { | ||
dataLayer: any; | ||
filter: Filter | undefined; | ||
symbolizer: CenteredTextSymbolizer; | ||
})[]; | ||
tasks: never[]; | ||
}; | ||
export {}; |
Oops, something went wrong.