krackedmaps 0.1.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.
- package/README.md +149 -0
- package/bin/cli.js +117 -0
- package/bin/mcp.js +99 -0
- package/dist/data.d.ts +27 -0
- package/dist/data.esm.js +1 -0
- package/dist/index.d.ts +92 -0
- package/dist/krackedmaps-districts.geojson +105880 -0
- package/dist/krackedmaps.cjs +19 -0
- package/dist/krackedmaps.css +219 -0
- package/dist/krackedmaps.esm.js +19 -0
- package/dist/krackedmaps.geojson +8593 -0
- package/dist/krackedmaps.umd.js +19 -0
- package/package.json +55 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
export interface Point { x: number; y: number; }
|
|
2
|
+
|
|
3
|
+
export interface StateFeature {
|
|
4
|
+
slug: string;
|
|
5
|
+
name: string;
|
|
6
|
+
type: "state" | "ft";
|
|
7
|
+
d: string;
|
|
8
|
+
centroid: Point;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface DistrictFeature {
|
|
12
|
+
slug: string;
|
|
13
|
+
name: string;
|
|
14
|
+
state: string;
|
|
15
|
+
d: string;
|
|
16
|
+
centroid: Point;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface Projection {
|
|
20
|
+
minx: number; maxy: number; scale: number; pad: number; eastLng: number;
|
|
21
|
+
shift: number; offX: number; offY: number; viewW: number; viewH: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface StateMeta { capital?: string; pop?: number; }
|
|
25
|
+
|
|
26
|
+
export interface MalaysiaMapOptions {
|
|
27
|
+
/** render the built-in info panel (default true) */
|
|
28
|
+
panel?: boolean;
|
|
29
|
+
/** render the built-in hover tooltip (default true) */
|
|
30
|
+
tooltip?: boolean;
|
|
31
|
+
/** build the district drill-down layer (default true) */
|
|
32
|
+
showDistricts?: boolean;
|
|
33
|
+
/** attach pointer/click/keyboard handlers (default true) */
|
|
34
|
+
interactive?: boolean;
|
|
35
|
+
/** scoped Escape-to-step-out (default true) */
|
|
36
|
+
keyboard?: boolean;
|
|
37
|
+
/** start with state labels shown (default false) */
|
|
38
|
+
labels?: boolean;
|
|
39
|
+
/** slug to select after build */
|
|
40
|
+
initialState?: string | null;
|
|
41
|
+
/** preset name ("flat-dark" | "light" | "blueprint" | "batik") or a {cssVar: value} map */
|
|
42
|
+
theme?: string | Record<string, string> | null;
|
|
43
|
+
/** per-state metadata, merged over the built-in defaults */
|
|
44
|
+
meta?: Record<string, StateMeta> | null;
|
|
45
|
+
/** default choropleth colour ramp */
|
|
46
|
+
colors?: { from?: string; to?: string };
|
|
47
|
+
/** override the info-panel body; return an HTML string */
|
|
48
|
+
renderPanel?: (info: Record<string, unknown>) => string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export type EventName = "select" | "hover" | "drill";
|
|
52
|
+
|
|
53
|
+
export interface MalaysiaMapInstance {
|
|
54
|
+
select(slug: string): void;
|
|
55
|
+
deselect(): void;
|
|
56
|
+
focus(slug: string | null): void;
|
|
57
|
+
drillInto(slug: string | null): void;
|
|
58
|
+
selectDistrict(key: string): void;
|
|
59
|
+
addPin(pin: { lng: number; lat: number; label?: string; id?: string }): string;
|
|
60
|
+
removePin(id: string): void;
|
|
61
|
+
clearPins(): void;
|
|
62
|
+
setData(values: Record<string, number>, ramp?: { from?: string; to?: string }): void;
|
|
63
|
+
clearData(): void;
|
|
64
|
+
setTheme(theme: string | Record<string, string> | null): void;
|
|
65
|
+
toggleLabels(force?: boolean): void;
|
|
66
|
+
on(name: EventName, cb: (payload: any) => void): MalaysiaMapInstance;
|
|
67
|
+
off(name: EventName, cb: (payload: any) => void): MalaysiaMapInstance;
|
|
68
|
+
destroy(): void;
|
|
69
|
+
readonly STATES: StateFeature[];
|
|
70
|
+
readonly DISTRICTS: DistrictFeature[];
|
|
71
|
+
readonly META: Record<string, StateMeta>;
|
|
72
|
+
project(lng: number, lat: number): Point;
|
|
73
|
+
readonly distByState: Map<string, string[]>;
|
|
74
|
+
readonly root: HTMLElement;
|
|
75
|
+
readonly svg: SVGSVGElement;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function createMalaysiaMap(
|
|
79
|
+
container: HTMLElement | string,
|
|
80
|
+
options?: MalaysiaMapOptions
|
|
81
|
+
): MalaysiaMapInstance;
|
|
82
|
+
|
|
83
|
+
export const STATES: StateFeature[];
|
|
84
|
+
export const DISTRICTS: DistrictFeature[];
|
|
85
|
+
export const PROJECTION: Projection;
|
|
86
|
+
export function project(lng: number, lat: number): Point;
|
|
87
|
+
export const data: {
|
|
88
|
+
STATES: StateFeature[];
|
|
89
|
+
DISTRICTS: DistrictFeature[];
|
|
90
|
+
PROJECTION: Projection;
|
|
91
|
+
project(lng: number, lat: number): Point;
|
|
92
|
+
};
|