@ai-gui/plugin-map 0.4.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/CHANGELOG.md +18 -0
- package/LICENSE +21 -0
- package/README.md +30 -0
- package/dist/index.cjs +877 -0
- package/dist/index.d.cts +181 -0
- package/dist/index.d.ts +181 -0
- package/dist/index.js +866 -0
- package/package.json +68 -0
- package/style.css +9 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { AIGuiPlugin } from "@ai-gui/core";
|
|
2
|
+
|
|
3
|
+
//#region src/types.d.ts
|
|
4
|
+
type MapVariant = "default" | "accent" | "muted" | "positive" | "warning" | "critical";
|
|
5
|
+
type Position = [longitude: number, latitude: number];
|
|
6
|
+
type MapScalar = string | number | boolean | null;
|
|
7
|
+
interface PointGeometry {
|
|
8
|
+
type: "Point";
|
|
9
|
+
coordinates: Position;
|
|
10
|
+
}
|
|
11
|
+
interface MultiPointGeometry {
|
|
12
|
+
type: "MultiPoint";
|
|
13
|
+
coordinates: Position[];
|
|
14
|
+
}
|
|
15
|
+
interface LineStringGeometry {
|
|
16
|
+
type: "LineString";
|
|
17
|
+
coordinates: Position[];
|
|
18
|
+
}
|
|
19
|
+
interface MultiLineStringGeometry {
|
|
20
|
+
type: "MultiLineString";
|
|
21
|
+
coordinates: Position[][];
|
|
22
|
+
}
|
|
23
|
+
interface PolygonGeometry {
|
|
24
|
+
type: "Polygon";
|
|
25
|
+
coordinates: Position[][];
|
|
26
|
+
}
|
|
27
|
+
interface MultiPolygonGeometry {
|
|
28
|
+
type: "MultiPolygon";
|
|
29
|
+
coordinates: Position[][][];
|
|
30
|
+
}
|
|
31
|
+
type MapGeometry = PointGeometry | MultiPointGeometry | LineStringGeometry | MultiLineStringGeometry | PolygonGeometry | MultiPolygonGeometry;
|
|
32
|
+
interface MapFeature {
|
|
33
|
+
type: "Feature";
|
|
34
|
+
id?: string | number;
|
|
35
|
+
properties?: Record<string, MapScalar>;
|
|
36
|
+
geometry: MapGeometry;
|
|
37
|
+
}
|
|
38
|
+
interface MapFeatureCollection {
|
|
39
|
+
type: "FeatureCollection";
|
|
40
|
+
features: MapFeature[];
|
|
41
|
+
}
|
|
42
|
+
interface MapGeoJSONLayer {
|
|
43
|
+
id: string;
|
|
44
|
+
type: "geojson";
|
|
45
|
+
data: MapFeatureCollection;
|
|
46
|
+
labelProperty?: string;
|
|
47
|
+
tooltipProperties?: string[];
|
|
48
|
+
variant?: MapVariant;
|
|
49
|
+
}
|
|
50
|
+
interface MapMarker {
|
|
51
|
+
id: string;
|
|
52
|
+
position: Position;
|
|
53
|
+
label: string;
|
|
54
|
+
description?: string;
|
|
55
|
+
variant?: MapVariant;
|
|
56
|
+
}
|
|
57
|
+
interface MapMarkersLayer {
|
|
58
|
+
id: string;
|
|
59
|
+
type: "markers";
|
|
60
|
+
items: MapMarker[];
|
|
61
|
+
}
|
|
62
|
+
interface MapRouteLayer {
|
|
63
|
+
id: string;
|
|
64
|
+
type: "route";
|
|
65
|
+
coordinates: Position[];
|
|
66
|
+
label?: string;
|
|
67
|
+
description?: string;
|
|
68
|
+
variant?: MapVariant;
|
|
69
|
+
}
|
|
70
|
+
type MapLayer = MapGeoJSONLayer | MapMarkersLayer | MapRouteLayer;
|
|
71
|
+
interface MapDocument {
|
|
72
|
+
version: 1;
|
|
73
|
+
ariaLabel?: string;
|
|
74
|
+
view?: {
|
|
75
|
+
center: Position;
|
|
76
|
+
zoom: number;
|
|
77
|
+
};
|
|
78
|
+
layers: MapLayer[];
|
|
79
|
+
}
|
|
80
|
+
interface MapLimits {
|
|
81
|
+
sourceBytes: number;
|
|
82
|
+
layers: number;
|
|
83
|
+
features: number;
|
|
84
|
+
markers: number;
|
|
85
|
+
coordinatePositions: number;
|
|
86
|
+
routePositions: number;
|
|
87
|
+
geometryDepth: number;
|
|
88
|
+
properties: number;
|
|
89
|
+
tooltipProperties: number;
|
|
90
|
+
string: number;
|
|
91
|
+
totalStrings: number;
|
|
92
|
+
id: number;
|
|
93
|
+
}
|
|
94
|
+
interface MapControlsOptions {
|
|
95
|
+
zoom?: boolean;
|
|
96
|
+
reset?: boolean;
|
|
97
|
+
fit?: boolean;
|
|
98
|
+
}
|
|
99
|
+
interface MapAttribution {
|
|
100
|
+
text: string;
|
|
101
|
+
url?: string;
|
|
102
|
+
}
|
|
103
|
+
interface MapBasemapOptions {
|
|
104
|
+
tileUrlTemplate: string;
|
|
105
|
+
attribution: MapAttribution;
|
|
106
|
+
minZoom?: number;
|
|
107
|
+
maxZoom?: number;
|
|
108
|
+
maxNativeZoom?: number;
|
|
109
|
+
tileSize?: number;
|
|
110
|
+
}
|
|
111
|
+
interface MapNetworkPolicy {
|
|
112
|
+
allowedTileOrigins: string[];
|
|
113
|
+
}
|
|
114
|
+
interface MapOptions {
|
|
115
|
+
height?: number;
|
|
116
|
+
minZoom?: number;
|
|
117
|
+
maxZoom?: number;
|
|
118
|
+
maxFitZoom?: number;
|
|
119
|
+
dragging?: boolean;
|
|
120
|
+
touchZoom?: boolean;
|
|
121
|
+
doubleClickZoom?: boolean;
|
|
122
|
+
scrollWheelZoom?: boolean;
|
|
123
|
+
keyboard?: boolean;
|
|
124
|
+
controls?: MapControlsOptions;
|
|
125
|
+
basemap?: false | MapBasemapOptions;
|
|
126
|
+
networkPolicy?: MapNetworkPolicy;
|
|
127
|
+
}
|
|
128
|
+
interface ResolvedMapOptions {
|
|
129
|
+
height: number;
|
|
130
|
+
minZoom: number;
|
|
131
|
+
maxZoom: number;
|
|
132
|
+
maxFitZoom: number;
|
|
133
|
+
dragging: boolean;
|
|
134
|
+
touchZoom: boolean;
|
|
135
|
+
doubleClickZoom: boolean;
|
|
136
|
+
scrollWheelZoom: boolean;
|
|
137
|
+
keyboard: boolean;
|
|
138
|
+
controls: Required<MapControlsOptions>;
|
|
139
|
+
basemap: false | MapBasemapOptions;
|
|
140
|
+
networkPolicy?: MapNetworkPolicy;
|
|
141
|
+
} //#endregion
|
|
142
|
+
//#region src/css.d.ts
|
|
143
|
+
declare const mapCss = "\n[data-aigui-map]{display:block;max-width:100%}\n[data-aigui-map-canvas]{position:relative;width:100%;height:var(--aigui-map-height,360px);min-height:240px;overflow:hidden;background:#e8edf1;outline:none}\n[data-aigui-map-canvas]:focus-visible{outline:3px solid #2563eb;outline-offset:2px}\n[data-aigui-map-controls]{position:absolute;z-index:800;top:10px;right:10px;display:flex;gap:8px;flex-wrap:wrap}\n[data-aigui-map-controls] button{min-width:44px;min-height:44px;border:1px solid #64748b;border-radius:6px;background:#fff;color:#111827;font:inherit;padding:8px 12px;cursor:pointer}\n[data-aigui-map-summary]{margin-top:12px}\n.leaflet-pane,.leaflet-tile,.leaflet-marker-icon,.leaflet-marker-shadow,.leaflet-tile-container,.leaflet-pane>svg,.leaflet-pane>canvas,.leaflet-zoom-box,.leaflet-image-layer,.leaflet-layer{position:absolute;left:0;top:0}\n.leaflet-container{overflow:hidden;-webkit-tap-highlight-color:transparent}.leaflet-container img,.leaflet-container svg{max-width:none!important;max-height:none!important}.leaflet-tile{visibility:hidden}.leaflet-tile-loaded{visibility:inherit}.leaflet-zoom-animated{transform-origin:0 0}.leaflet-zoom-hide{visibility:hidden}.leaflet-control-container{position:relative;z-index:800}.leaflet-control{position:relative;z-index:800;pointer-events:auto}.leaflet-top,.leaflet-bottom{position:absolute;z-index:1000;pointer-events:none}.leaflet-top{top:0}.leaflet-right{right:0}.leaflet-bottom{bottom:0}.leaflet-left{left:0}.leaflet-control-zoom a{display:block;width:44px;height:44px;line-height:44px;text-align:center;background:#fff;color:#111;text-decoration:none}.leaflet-tooltip{position:absolute;padding:6px;background:#fff;border:1px solid #64748b;border-radius:4px;color:#111;white-space:nowrap;pointer-events:none}\n@media (prefers-reduced-motion:reduce){[data-aigui-map] *{scroll-behavior:auto!important;transition:none!important;animation:none!important}}\n";
|
|
144
|
+
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region src/errors.d.ts
|
|
147
|
+
declare class MapDocumentError extends Error {
|
|
148
|
+
readonly issues: readonly string[];
|
|
149
|
+
constructor(issues: readonly string[]);
|
|
150
|
+
}
|
|
151
|
+
declare class MapLimitError extends MapDocumentError {
|
|
152
|
+
constructor(message: string);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
//#endregion
|
|
156
|
+
//#region src/limits.d.ts
|
|
157
|
+
declare const DEFAULT_MAP_LIMITS: Readonly<MapLimits>;
|
|
158
|
+
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region src/mount.d.ts
|
|
161
|
+
declare function mountMapDocument(host: HTMLElement, document: MapDocument, options: ResolvedMapOptions): () => void;
|
|
162
|
+
|
|
163
|
+
//#endregion
|
|
164
|
+
//#region src/options.d.ts
|
|
165
|
+
declare function resolveMapOptions(options?: MapOptions): ResolvedMapOptions;
|
|
166
|
+
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region src/prompt.d.ts
|
|
169
|
+
declare function mapPromptSpec(): string;
|
|
170
|
+
|
|
171
|
+
//#endregion
|
|
172
|
+
//#region src/validate.d.ts
|
|
173
|
+
declare function parseMapDocument(source: string): MapDocument;
|
|
174
|
+
declare function validateMapDocument(value: unknown): MapDocument;
|
|
175
|
+
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region src/index.d.ts
|
|
178
|
+
declare function map(options?: MapOptions): AIGuiPlugin;
|
|
179
|
+
|
|
180
|
+
//#endregion
|
|
181
|
+
export { DEFAULT_MAP_LIMITS, LineStringGeometry, MapAttribution, MapBasemapOptions, MapControlsOptions, MapDocument, MapDocumentError, MapFeature, MapFeatureCollection, MapGeoJSONLayer, MapGeometry, MapLayer, MapLimitError, MapLimits, MapMarker, MapMarkersLayer, MapNetworkPolicy, MapOptions, MapRouteLayer, MapScalar, MapVariant, MultiLineStringGeometry, MultiPointGeometry, MultiPolygonGeometry, PointGeometry, PolygonGeometry, Position, ResolvedMapOptions, map, mapCss, mapPromptSpec, mountMapDocument, parseMapDocument, resolveMapOptions, validateMapDocument };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { AIGuiPlugin } from "@ai-gui/core";
|
|
2
|
+
|
|
3
|
+
//#region src/types.d.ts
|
|
4
|
+
type MapVariant = "default" | "accent" | "muted" | "positive" | "warning" | "critical";
|
|
5
|
+
type Position = [longitude: number, latitude: number];
|
|
6
|
+
type MapScalar = string | number | boolean | null;
|
|
7
|
+
interface PointGeometry {
|
|
8
|
+
type: "Point";
|
|
9
|
+
coordinates: Position;
|
|
10
|
+
}
|
|
11
|
+
interface MultiPointGeometry {
|
|
12
|
+
type: "MultiPoint";
|
|
13
|
+
coordinates: Position[];
|
|
14
|
+
}
|
|
15
|
+
interface LineStringGeometry {
|
|
16
|
+
type: "LineString";
|
|
17
|
+
coordinates: Position[];
|
|
18
|
+
}
|
|
19
|
+
interface MultiLineStringGeometry {
|
|
20
|
+
type: "MultiLineString";
|
|
21
|
+
coordinates: Position[][];
|
|
22
|
+
}
|
|
23
|
+
interface PolygonGeometry {
|
|
24
|
+
type: "Polygon";
|
|
25
|
+
coordinates: Position[][];
|
|
26
|
+
}
|
|
27
|
+
interface MultiPolygonGeometry {
|
|
28
|
+
type: "MultiPolygon";
|
|
29
|
+
coordinates: Position[][][];
|
|
30
|
+
}
|
|
31
|
+
type MapGeometry = PointGeometry | MultiPointGeometry | LineStringGeometry | MultiLineStringGeometry | PolygonGeometry | MultiPolygonGeometry;
|
|
32
|
+
interface MapFeature {
|
|
33
|
+
type: "Feature";
|
|
34
|
+
id?: string | number;
|
|
35
|
+
properties?: Record<string, MapScalar>;
|
|
36
|
+
geometry: MapGeometry;
|
|
37
|
+
}
|
|
38
|
+
interface MapFeatureCollection {
|
|
39
|
+
type: "FeatureCollection";
|
|
40
|
+
features: MapFeature[];
|
|
41
|
+
}
|
|
42
|
+
interface MapGeoJSONLayer {
|
|
43
|
+
id: string;
|
|
44
|
+
type: "geojson";
|
|
45
|
+
data: MapFeatureCollection;
|
|
46
|
+
labelProperty?: string;
|
|
47
|
+
tooltipProperties?: string[];
|
|
48
|
+
variant?: MapVariant;
|
|
49
|
+
}
|
|
50
|
+
interface MapMarker {
|
|
51
|
+
id: string;
|
|
52
|
+
position: Position;
|
|
53
|
+
label: string;
|
|
54
|
+
description?: string;
|
|
55
|
+
variant?: MapVariant;
|
|
56
|
+
}
|
|
57
|
+
interface MapMarkersLayer {
|
|
58
|
+
id: string;
|
|
59
|
+
type: "markers";
|
|
60
|
+
items: MapMarker[];
|
|
61
|
+
}
|
|
62
|
+
interface MapRouteLayer {
|
|
63
|
+
id: string;
|
|
64
|
+
type: "route";
|
|
65
|
+
coordinates: Position[];
|
|
66
|
+
label?: string;
|
|
67
|
+
description?: string;
|
|
68
|
+
variant?: MapVariant;
|
|
69
|
+
}
|
|
70
|
+
type MapLayer = MapGeoJSONLayer | MapMarkersLayer | MapRouteLayer;
|
|
71
|
+
interface MapDocument {
|
|
72
|
+
version: 1;
|
|
73
|
+
ariaLabel?: string;
|
|
74
|
+
view?: {
|
|
75
|
+
center: Position;
|
|
76
|
+
zoom: number;
|
|
77
|
+
};
|
|
78
|
+
layers: MapLayer[];
|
|
79
|
+
}
|
|
80
|
+
interface MapLimits {
|
|
81
|
+
sourceBytes: number;
|
|
82
|
+
layers: number;
|
|
83
|
+
features: number;
|
|
84
|
+
markers: number;
|
|
85
|
+
coordinatePositions: number;
|
|
86
|
+
routePositions: number;
|
|
87
|
+
geometryDepth: number;
|
|
88
|
+
properties: number;
|
|
89
|
+
tooltipProperties: number;
|
|
90
|
+
string: number;
|
|
91
|
+
totalStrings: number;
|
|
92
|
+
id: number;
|
|
93
|
+
}
|
|
94
|
+
interface MapControlsOptions {
|
|
95
|
+
zoom?: boolean;
|
|
96
|
+
reset?: boolean;
|
|
97
|
+
fit?: boolean;
|
|
98
|
+
}
|
|
99
|
+
interface MapAttribution {
|
|
100
|
+
text: string;
|
|
101
|
+
url?: string;
|
|
102
|
+
}
|
|
103
|
+
interface MapBasemapOptions {
|
|
104
|
+
tileUrlTemplate: string;
|
|
105
|
+
attribution: MapAttribution;
|
|
106
|
+
minZoom?: number;
|
|
107
|
+
maxZoom?: number;
|
|
108
|
+
maxNativeZoom?: number;
|
|
109
|
+
tileSize?: number;
|
|
110
|
+
}
|
|
111
|
+
interface MapNetworkPolicy {
|
|
112
|
+
allowedTileOrigins: string[];
|
|
113
|
+
}
|
|
114
|
+
interface MapOptions {
|
|
115
|
+
height?: number;
|
|
116
|
+
minZoom?: number;
|
|
117
|
+
maxZoom?: number;
|
|
118
|
+
maxFitZoom?: number;
|
|
119
|
+
dragging?: boolean;
|
|
120
|
+
touchZoom?: boolean;
|
|
121
|
+
doubleClickZoom?: boolean;
|
|
122
|
+
scrollWheelZoom?: boolean;
|
|
123
|
+
keyboard?: boolean;
|
|
124
|
+
controls?: MapControlsOptions;
|
|
125
|
+
basemap?: false | MapBasemapOptions;
|
|
126
|
+
networkPolicy?: MapNetworkPolicy;
|
|
127
|
+
}
|
|
128
|
+
interface ResolvedMapOptions {
|
|
129
|
+
height: number;
|
|
130
|
+
minZoom: number;
|
|
131
|
+
maxZoom: number;
|
|
132
|
+
maxFitZoom: number;
|
|
133
|
+
dragging: boolean;
|
|
134
|
+
touchZoom: boolean;
|
|
135
|
+
doubleClickZoom: boolean;
|
|
136
|
+
scrollWheelZoom: boolean;
|
|
137
|
+
keyboard: boolean;
|
|
138
|
+
controls: Required<MapControlsOptions>;
|
|
139
|
+
basemap: false | MapBasemapOptions;
|
|
140
|
+
networkPolicy?: MapNetworkPolicy;
|
|
141
|
+
} //#endregion
|
|
142
|
+
//#region src/css.d.ts
|
|
143
|
+
declare const mapCss = "\n[data-aigui-map]{display:block;max-width:100%}\n[data-aigui-map-canvas]{position:relative;width:100%;height:var(--aigui-map-height,360px);min-height:240px;overflow:hidden;background:#e8edf1;outline:none}\n[data-aigui-map-canvas]:focus-visible{outline:3px solid #2563eb;outline-offset:2px}\n[data-aigui-map-controls]{position:absolute;z-index:800;top:10px;right:10px;display:flex;gap:8px;flex-wrap:wrap}\n[data-aigui-map-controls] button{min-width:44px;min-height:44px;border:1px solid #64748b;border-radius:6px;background:#fff;color:#111827;font:inherit;padding:8px 12px;cursor:pointer}\n[data-aigui-map-summary]{margin-top:12px}\n.leaflet-pane,.leaflet-tile,.leaflet-marker-icon,.leaflet-marker-shadow,.leaflet-tile-container,.leaflet-pane>svg,.leaflet-pane>canvas,.leaflet-zoom-box,.leaflet-image-layer,.leaflet-layer{position:absolute;left:0;top:0}\n.leaflet-container{overflow:hidden;-webkit-tap-highlight-color:transparent}.leaflet-container img,.leaflet-container svg{max-width:none!important;max-height:none!important}.leaflet-tile{visibility:hidden}.leaflet-tile-loaded{visibility:inherit}.leaflet-zoom-animated{transform-origin:0 0}.leaflet-zoom-hide{visibility:hidden}.leaflet-control-container{position:relative;z-index:800}.leaflet-control{position:relative;z-index:800;pointer-events:auto}.leaflet-top,.leaflet-bottom{position:absolute;z-index:1000;pointer-events:none}.leaflet-top{top:0}.leaflet-right{right:0}.leaflet-bottom{bottom:0}.leaflet-left{left:0}.leaflet-control-zoom a{display:block;width:44px;height:44px;line-height:44px;text-align:center;background:#fff;color:#111;text-decoration:none}.leaflet-tooltip{position:absolute;padding:6px;background:#fff;border:1px solid #64748b;border-radius:4px;color:#111;white-space:nowrap;pointer-events:none}\n@media (prefers-reduced-motion:reduce){[data-aigui-map] *{scroll-behavior:auto!important;transition:none!important;animation:none!important}}\n";
|
|
144
|
+
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region src/errors.d.ts
|
|
147
|
+
declare class MapDocumentError extends Error {
|
|
148
|
+
readonly issues: readonly string[];
|
|
149
|
+
constructor(issues: readonly string[]);
|
|
150
|
+
}
|
|
151
|
+
declare class MapLimitError extends MapDocumentError {
|
|
152
|
+
constructor(message: string);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
//#endregion
|
|
156
|
+
//#region src/limits.d.ts
|
|
157
|
+
declare const DEFAULT_MAP_LIMITS: Readonly<MapLimits>;
|
|
158
|
+
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region src/mount.d.ts
|
|
161
|
+
declare function mountMapDocument(host: HTMLElement, document: MapDocument, options: ResolvedMapOptions): () => void;
|
|
162
|
+
|
|
163
|
+
//#endregion
|
|
164
|
+
//#region src/options.d.ts
|
|
165
|
+
declare function resolveMapOptions(options?: MapOptions): ResolvedMapOptions;
|
|
166
|
+
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region src/prompt.d.ts
|
|
169
|
+
declare function mapPromptSpec(): string;
|
|
170
|
+
|
|
171
|
+
//#endregion
|
|
172
|
+
//#region src/validate.d.ts
|
|
173
|
+
declare function parseMapDocument(source: string): MapDocument;
|
|
174
|
+
declare function validateMapDocument(value: unknown): MapDocument;
|
|
175
|
+
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region src/index.d.ts
|
|
178
|
+
declare function map(options?: MapOptions): AIGuiPlugin;
|
|
179
|
+
|
|
180
|
+
//#endregion
|
|
181
|
+
export { DEFAULT_MAP_LIMITS, LineStringGeometry, MapAttribution, MapBasemapOptions, MapControlsOptions, MapDocument, MapDocumentError, MapFeature, MapFeatureCollection, MapGeoJSONLayer, MapGeometry, MapLayer, MapLimitError, MapLimits, MapMarker, MapMarkersLayer, MapNetworkPolicy, MapOptions, MapRouteLayer, MapScalar, MapVariant, MultiLineStringGeometry, MultiPointGeometry, MultiPolygonGeometry, PointGeometry, PolygonGeometry, Position, ResolvedMapOptions, map, mapCss, mapPromptSpec, mountMapDocument, parseMapDocument, resolveMapOptions, validateMapDocument };
|