@stackwright/maplibre 1.0.0-alpha.2
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/LICENSE +21 -0
- package/README.md +231 -0
- package/dist/index.d.mts +105 -0
- package/dist/index.d.ts +105 -0
- package/dist/index.js +205 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +169 -0
- package/dist/index.mjs.map +1 -0
- package/dist/styles.css +50 -0
- package/package.json +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Per Aspera Sapientia LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
# @stackwright/maplibre
|
|
2
|
+
|
|
3
|
+
MapLibre GL adapter for Stackwright — **free tier, no API keys required**.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- ✅ 2D interactive maps with pan/zoom
|
|
8
|
+
- ✅ Markers with click-to-show popups
|
|
9
|
+
- ✅ Polyline routes (flight paths, shipping lanes)
|
|
10
|
+
- ✅ Polygon boundaries (territories, regions)
|
|
11
|
+
- ✅ GeoJSON support (complex geometries)
|
|
12
|
+
- ✅ Free MapLibre demo tiles (no vendor lock-in)
|
|
13
|
+
- ✅ SSR-safe for Next.js
|
|
14
|
+
- ✅ Responsive design (320px to 1440px)
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pnpm add @stackwright/maplibre
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
### 1. Register the Provider
|
|
25
|
+
|
|
26
|
+
In your Next.js `_app.tsx` (Pages Router) or `app/layout.tsx` (App Router):
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import { registerNextJSComponents } from '@stackwright/nextjs';
|
|
30
|
+
import { registerMapLibreProvider } from '@stackwright/maplibre';
|
|
31
|
+
import '@stackwright/maplibre/dist/styles.css'; // ⚠️ Required!
|
|
32
|
+
|
|
33
|
+
registerNextJSComponents();
|
|
34
|
+
registerMapLibreProvider(); // Register MapLibre as map adapter
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
⚠️ **Don't forget the CSS import!** MapLibre GL requires its stylesheets.
|
|
38
|
+
|
|
39
|
+
### 2. Use Maps in YAML
|
|
40
|
+
|
|
41
|
+
Create a page with map content:
|
|
42
|
+
|
|
43
|
+
```yaml
|
|
44
|
+
# pages/locations/content.yml
|
|
45
|
+
content:
|
|
46
|
+
content_items:
|
|
47
|
+
- type: map
|
|
48
|
+
label: "Our offices"
|
|
49
|
+
center: { lat: 37.7749, lng: -122.4194 }
|
|
50
|
+
zoom: 12
|
|
51
|
+
height: "500px"
|
|
52
|
+
markers:
|
|
53
|
+
- lat: 37.7749
|
|
54
|
+
lng: -122.4194
|
|
55
|
+
label: "San Francisco HQ"
|
|
56
|
+
popup: "123 Market St, SF CA 94103"
|
|
57
|
+
- lat: 37.8044
|
|
58
|
+
lng: -122.2712
|
|
59
|
+
label: "Oakland Office"
|
|
60
|
+
popup: "456 Broadway, Oakland CA 94607"
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### 3. View Your Map
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
pnpm dev
|
|
67
|
+
# Visit http://localhost:3000/locations
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Advanced Features
|
|
71
|
+
|
|
72
|
+
### Polyline Routes
|
|
73
|
+
|
|
74
|
+
Show flight paths, shipping lanes, or driving directions:
|
|
75
|
+
|
|
76
|
+
```yaml
|
|
77
|
+
- type: map
|
|
78
|
+
label: "Delivery route"
|
|
79
|
+
center: { lat: 37.7749, lng: -122.4194 }
|
|
80
|
+
zoom: 10
|
|
81
|
+
layers:
|
|
82
|
+
- type: polyline
|
|
83
|
+
data:
|
|
84
|
+
- [-122.4194, 37.7749] # SF
|
|
85
|
+
- [-122.2712, 37.8044] # Oakland
|
|
86
|
+
- [-122.0838, 37.4219] # Palo Alto
|
|
87
|
+
style:
|
|
88
|
+
color: "#FF5733"
|
|
89
|
+
width: 4
|
|
90
|
+
opacity: 0.8
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
⚠️ **Coordinate order:** MapLibre uses `[lng, lat]` for polyline data (GeoJSON standard).
|
|
94
|
+
|
|
95
|
+
### Polygon Regions
|
|
96
|
+
|
|
97
|
+
Highlight territories, service areas, or property boundaries:
|
|
98
|
+
|
|
99
|
+
```yaml
|
|
100
|
+
- type: map
|
|
101
|
+
label: "Service area"
|
|
102
|
+
center: { lat: 37.7749, lng: -122.4194 }
|
|
103
|
+
zoom: 11
|
|
104
|
+
layers:
|
|
105
|
+
- type: polygon
|
|
106
|
+
data: # Outer ring (clockwise)
|
|
107
|
+
- [-122.52, 37.82]
|
|
108
|
+
- [-122.35, 37.82]
|
|
109
|
+
- [-122.35, 37.70]
|
|
110
|
+
- [-122.52, 37.70]
|
|
111
|
+
- [-122.52, 37.82]
|
|
112
|
+
style:
|
|
113
|
+
fillColor: "#3388ff"
|
|
114
|
+
fillOpacity: 0.3
|
|
115
|
+
color: "#3388ff" # Border color
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### GeoJSON Layers
|
|
119
|
+
|
|
120
|
+
Import complex geometries from GeoJSON:
|
|
121
|
+
|
|
122
|
+
```yaml
|
|
123
|
+
- type: map
|
|
124
|
+
label: "Geographic data"
|
|
125
|
+
center: { lat: 37.7749, lng: -122.4194 }
|
|
126
|
+
zoom: 10
|
|
127
|
+
layers:
|
|
128
|
+
- type: geojson
|
|
129
|
+
data:
|
|
130
|
+
type: "FeatureCollection"
|
|
131
|
+
features:
|
|
132
|
+
- type: "Feature"
|
|
133
|
+
geometry:
|
|
134
|
+
type: "Point"
|
|
135
|
+
coordinates: [-122.4194, 37.7749]
|
|
136
|
+
properties:
|
|
137
|
+
title: "San Francisco"
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Tile Sources
|
|
141
|
+
|
|
142
|
+
By default, this package uses **MapLibre's free demo tiles** (no API key required). These tiles are:
|
|
143
|
+
|
|
144
|
+
- ✅ **Free forever** (MapLibre Foundation)
|
|
145
|
+
- ✅ **No usage limits** (community-hosted)
|
|
146
|
+
- ✅ **No vendor lock-in** (OSS stack)
|
|
147
|
+
|
|
148
|
+
### Custom Tile Sources
|
|
149
|
+
|
|
150
|
+
To use your own tiles (Maptiler, Mapbox, self-hosted, etc.), you'll need to modify the provider. We recommend:
|
|
151
|
+
|
|
152
|
+
1. **Maptiler Free Tier**: 100K map loads/month (sign up at [maptiler.com](https://www.maptiler.com/))
|
|
153
|
+
2. **Mapbox Free Tier**: 200K map loads/month (sign up at [mapbox.com](https://www.mapbox.com/))
|
|
154
|
+
3. **Self-hosted**: Use [TileServer GL](https://github.com/maptiler/tileserver-gl) + OpenStreetMap data
|
|
155
|
+
|
|
156
|
+
To use a custom style URL, fork this package or create a custom provider following the same adapter pattern.
|
|
157
|
+
|
|
158
|
+
## Adapter Pattern
|
|
159
|
+
|
|
160
|
+
This package follows Stackwright's **adapter pattern** (same as Next.js Image/Link). You can swap map providers with **zero changes** to your YAML content:
|
|
161
|
+
|
|
162
|
+
**Free tier (this package):**
|
|
163
|
+
```typescript
|
|
164
|
+
import { registerMapLibreProvider } from '@stackwright/maplibre';
|
|
165
|
+
registerMapLibreProvider();
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
**Pro tier (3D globe):**
|
|
169
|
+
```typescript
|
|
170
|
+
import { registerCesiumProvider } from '@stackwright-pro/cesium';
|
|
171
|
+
registerCesiumProvider(); // One line change!
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Your maps stay identical — the underlying rendering engine changes.
|
|
175
|
+
|
|
176
|
+
## Troubleshooting
|
|
177
|
+
|
|
178
|
+
### Map Not Showing
|
|
179
|
+
|
|
180
|
+
1. **Did you import the CSS?**
|
|
181
|
+
```typescript
|
|
182
|
+
import '@stackwright/maplibre/dist/styles.css';
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
2. **Did you register the provider?**
|
|
186
|
+
```typescript
|
|
187
|
+
registerMapLibreProvider();
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
3. **Is the height set?** Maps need explicit height:
|
|
191
|
+
```yaml
|
|
192
|
+
height: "500px"
|
|
193
|
+
# or
|
|
194
|
+
height: 500
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### Hydration Errors
|
|
198
|
+
|
|
199
|
+
If you see hydration mismatches, make sure you're using a recent version of React (^18 or ^19). This package is SSR-safe and includes client-side guards.
|
|
200
|
+
|
|
201
|
+
### Marker Icons
|
|
202
|
+
|
|
203
|
+
By default, markers use the 📍 emoji. To use custom icons, you'll need to extend the provider or use the icon registry (see `@stackwright/icons`).
|
|
204
|
+
|
|
205
|
+
## License
|
|
206
|
+
|
|
207
|
+
- **This package**: MIT
|
|
208
|
+
- **MapLibre GL**: BSD-3-Clause
|
|
209
|
+
- **react-map-gl**: MIT
|
|
210
|
+
|
|
211
|
+
No proprietary licenses, no vendor lock-in. Truly open source.
|
|
212
|
+
|
|
213
|
+
## Contributing
|
|
214
|
+
|
|
215
|
+
See [CONTRIBUTING.md](../../CONTRIBUTING.md) in the repository root.
|
|
216
|
+
|
|
217
|
+
## Support
|
|
218
|
+
|
|
219
|
+
- **Issues**: [GitHub Issues](https://github.com/Per-Aspera-LLC/stackwright/issues)
|
|
220
|
+
- **Discussions**: [GitHub Discussions](https://github.com/Per-Aspera-LLC/stackwright/discussions)
|
|
221
|
+
- **Pro support**: Email pro@stackwright.com
|
|
222
|
+
|
|
223
|
+
## Roadmap
|
|
224
|
+
|
|
225
|
+
- [ ] Custom marker icons (via icon registry)
|
|
226
|
+
- [ ] Clustering for large marker sets
|
|
227
|
+
- [ ] Heatmap layers
|
|
228
|
+
- [ ] 3D building extrusion
|
|
229
|
+
- [ ] Offline tile caching
|
|
230
|
+
|
|
231
|
+
Want to contribute? PRs welcome! 🎉
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MapProviderProps } from '@stackwright/core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* MapLibreProvider — Free tier map adapter using MapLibre GL.
|
|
6
|
+
*
|
|
7
|
+
* **Features:**
|
|
8
|
+
* - 2D interactive maps with pan/zoom
|
|
9
|
+
* - Markers with click-to-show popups
|
|
10
|
+
* - Polyline and polygon layers
|
|
11
|
+
* - GeoJSON support
|
|
12
|
+
* - Free MapLibre demo tiles (no API key required)
|
|
13
|
+
* - SSR-safe for Next.js
|
|
14
|
+
* - Responsive (320px to 1440px)
|
|
15
|
+
*
|
|
16
|
+
* **License:** BSD-3-Clause (MapLibre GL)
|
|
17
|
+
* **Vendor lock-in:** None (can swap to Mapbox, Maptiler, etc.)
|
|
18
|
+
*
|
|
19
|
+
* **Usage:**
|
|
20
|
+
*
|
|
21
|
+
* ```typescript
|
|
22
|
+
* import { registerMapLibreProvider } from '@stackwright/maplibre';
|
|
23
|
+
* import '@stackwright/maplibre/dist/styles.css';
|
|
24
|
+
*
|
|
25
|
+
* registerMapLibreProvider();
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @see https://maplibre.org/maplibre-gl-js/docs/
|
|
29
|
+
*/
|
|
30
|
+
declare const MapLibreProvider: React.FC<MapProviderProps>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @stackwright/maplibre — Free tier map adapter for Stackwright
|
|
34
|
+
*
|
|
35
|
+
* **License:** BSD-3-Clause (MapLibre GL) + MIT (this package)
|
|
36
|
+
* **Features:**
|
|
37
|
+
* - 2D interactive maps
|
|
38
|
+
* - No API keys required (uses MapLibre demo tiles)
|
|
39
|
+
* - Markers, polylines, polygons, GeoJSON
|
|
40
|
+
* - SSR-safe for Next.js
|
|
41
|
+
* - Responsive design
|
|
42
|
+
*
|
|
43
|
+
* **Installation:**
|
|
44
|
+
*
|
|
45
|
+
* ```bash
|
|
46
|
+
* pnpm add @stackwright/maplibre
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* **Usage in Next.js:**
|
|
50
|
+
*
|
|
51
|
+
* ```typescript
|
|
52
|
+
* // pages/_app.tsx
|
|
53
|
+
* import { registerMapLibreProvider } from '@stackwright/maplibre';
|
|
54
|
+
* import '@stackwright/maplibre/dist/styles.css';
|
|
55
|
+
* import { registerNextJSComponents } from '@stackwright/nextjs';
|
|
56
|
+
*
|
|
57
|
+
* registerNextJSComponents();
|
|
58
|
+
* registerMapLibreProvider();
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* **YAML Example:**
|
|
62
|
+
*
|
|
63
|
+
* ```yaml
|
|
64
|
+
* content:
|
|
65
|
+
* content_items:
|
|
66
|
+
* - type: map
|
|
67
|
+
* label: "Office locations"
|
|
68
|
+
* center: { lat: 37.7749, lng: -122.4194 }
|
|
69
|
+
* zoom: 12
|
|
70
|
+
* markers:
|
|
71
|
+
* - lat: 37.7749
|
|
72
|
+
* lng: -122.4194
|
|
73
|
+
* label: "San Francisco HQ"
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* @packageDocumentation
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Register MapLibreProvider as the active map adapter.
|
|
81
|
+
*
|
|
82
|
+
* Call this in `_app.tsx` (Pages Router) or `layout.tsx` (App Router)
|
|
83
|
+
* alongside `registerNextJSComponents()`:
|
|
84
|
+
*
|
|
85
|
+
* ```typescript
|
|
86
|
+
* import { registerMapLibreProvider } from '@stackwright/maplibre';
|
|
87
|
+
* import '@stackwright/maplibre/dist/styles.css';
|
|
88
|
+
*
|
|
89
|
+
* registerMapLibreProvider();
|
|
90
|
+
* ```
|
|
91
|
+
*
|
|
92
|
+
* **Swapping to pro 3D provider:**
|
|
93
|
+
*
|
|
94
|
+
* ```typescript
|
|
95
|
+
* // Switch from MapLibre (2D) to Cesium (3D globe)
|
|
96
|
+
* import { registerCesiumProvider } from '@stackwright-pro/cesium';
|
|
97
|
+
* registerCesiumProvider();
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* This is a one-line change — your YAML content, components, and pages
|
|
101
|
+
* stay identical. That's the power of the adapter pattern!
|
|
102
|
+
*/
|
|
103
|
+
declare function registerMapLibreProvider(): void;
|
|
104
|
+
|
|
105
|
+
export { MapLibreProvider, MapLibreProvider as default, registerMapLibreProvider };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MapProviderProps } from '@stackwright/core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* MapLibreProvider — Free tier map adapter using MapLibre GL.
|
|
6
|
+
*
|
|
7
|
+
* **Features:**
|
|
8
|
+
* - 2D interactive maps with pan/zoom
|
|
9
|
+
* - Markers with click-to-show popups
|
|
10
|
+
* - Polyline and polygon layers
|
|
11
|
+
* - GeoJSON support
|
|
12
|
+
* - Free MapLibre demo tiles (no API key required)
|
|
13
|
+
* - SSR-safe for Next.js
|
|
14
|
+
* - Responsive (320px to 1440px)
|
|
15
|
+
*
|
|
16
|
+
* **License:** BSD-3-Clause (MapLibre GL)
|
|
17
|
+
* **Vendor lock-in:** None (can swap to Mapbox, Maptiler, etc.)
|
|
18
|
+
*
|
|
19
|
+
* **Usage:**
|
|
20
|
+
*
|
|
21
|
+
* ```typescript
|
|
22
|
+
* import { registerMapLibreProvider } from '@stackwright/maplibre';
|
|
23
|
+
* import '@stackwright/maplibre/dist/styles.css';
|
|
24
|
+
*
|
|
25
|
+
* registerMapLibreProvider();
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @see https://maplibre.org/maplibre-gl-js/docs/
|
|
29
|
+
*/
|
|
30
|
+
declare const MapLibreProvider: React.FC<MapProviderProps>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @stackwright/maplibre — Free tier map adapter for Stackwright
|
|
34
|
+
*
|
|
35
|
+
* **License:** BSD-3-Clause (MapLibre GL) + MIT (this package)
|
|
36
|
+
* **Features:**
|
|
37
|
+
* - 2D interactive maps
|
|
38
|
+
* - No API keys required (uses MapLibre demo tiles)
|
|
39
|
+
* - Markers, polylines, polygons, GeoJSON
|
|
40
|
+
* - SSR-safe for Next.js
|
|
41
|
+
* - Responsive design
|
|
42
|
+
*
|
|
43
|
+
* **Installation:**
|
|
44
|
+
*
|
|
45
|
+
* ```bash
|
|
46
|
+
* pnpm add @stackwright/maplibre
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* **Usage in Next.js:**
|
|
50
|
+
*
|
|
51
|
+
* ```typescript
|
|
52
|
+
* // pages/_app.tsx
|
|
53
|
+
* import { registerMapLibreProvider } from '@stackwright/maplibre';
|
|
54
|
+
* import '@stackwright/maplibre/dist/styles.css';
|
|
55
|
+
* import { registerNextJSComponents } from '@stackwright/nextjs';
|
|
56
|
+
*
|
|
57
|
+
* registerNextJSComponents();
|
|
58
|
+
* registerMapLibreProvider();
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* **YAML Example:**
|
|
62
|
+
*
|
|
63
|
+
* ```yaml
|
|
64
|
+
* content:
|
|
65
|
+
* content_items:
|
|
66
|
+
* - type: map
|
|
67
|
+
* label: "Office locations"
|
|
68
|
+
* center: { lat: 37.7749, lng: -122.4194 }
|
|
69
|
+
* zoom: 12
|
|
70
|
+
* markers:
|
|
71
|
+
* - lat: 37.7749
|
|
72
|
+
* lng: -122.4194
|
|
73
|
+
* label: "San Francisco HQ"
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* @packageDocumentation
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Register MapLibreProvider as the active map adapter.
|
|
81
|
+
*
|
|
82
|
+
* Call this in `_app.tsx` (Pages Router) or `layout.tsx` (App Router)
|
|
83
|
+
* alongside `registerNextJSComponents()`:
|
|
84
|
+
*
|
|
85
|
+
* ```typescript
|
|
86
|
+
* import { registerMapLibreProvider } from '@stackwright/maplibre';
|
|
87
|
+
* import '@stackwright/maplibre/dist/styles.css';
|
|
88
|
+
*
|
|
89
|
+
* registerMapLibreProvider();
|
|
90
|
+
* ```
|
|
91
|
+
*
|
|
92
|
+
* **Swapping to pro 3D provider:**
|
|
93
|
+
*
|
|
94
|
+
* ```typescript
|
|
95
|
+
* // Switch from MapLibre (2D) to Cesium (3D globe)
|
|
96
|
+
* import { registerCesiumProvider } from '@stackwright-pro/cesium';
|
|
97
|
+
* registerCesiumProvider();
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* This is a one-line change — your YAML content, components, and pages
|
|
101
|
+
* stay identical. That's the power of the adapter pattern!
|
|
102
|
+
*/
|
|
103
|
+
declare function registerMapLibreProvider(): void;
|
|
104
|
+
|
|
105
|
+
export { MapLibreProvider, MapLibreProvider as default, registerMapLibreProvider };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
MapLibreProvider: () => MapLibreProvider,
|
|
34
|
+
default: () => index_default,
|
|
35
|
+
registerMapLibreProvider: () => registerMapLibreProvider
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(index_exports);
|
|
38
|
+
var import_core = require("@stackwright/core");
|
|
39
|
+
|
|
40
|
+
// src/MapLibreProvider.tsx
|
|
41
|
+
var import_react = require("react");
|
|
42
|
+
var import_maplibre = __toESM(require("react-map-gl/maplibre"));
|
|
43
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
44
|
+
var MapLibreProvider = ({
|
|
45
|
+
config,
|
|
46
|
+
height = "100%",
|
|
47
|
+
width = "100%",
|
|
48
|
+
className,
|
|
49
|
+
style
|
|
50
|
+
}) => {
|
|
51
|
+
const [popupInfo, setPopupInfo] = (0, import_react.useState)(null);
|
|
52
|
+
const [isClient, setIsClient] = (0, import_react.useState)(false);
|
|
53
|
+
(0, import_react.useEffect)(() => {
|
|
54
|
+
setIsClient(true);
|
|
55
|
+
}, []);
|
|
56
|
+
const onMarkerClick = (0, import_react.useCallback)((marker) => {
|
|
57
|
+
setPopupInfo(
|
|
58
|
+
(current) => current?.label === marker.label && current?.lat === marker.lat ? null : marker
|
|
59
|
+
);
|
|
60
|
+
}, []);
|
|
61
|
+
const onPopupClose = (0, import_react.useCallback)(() => {
|
|
62
|
+
setPopupInfo(null);
|
|
63
|
+
}, []);
|
|
64
|
+
if (!isClient) {
|
|
65
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
66
|
+
"div",
|
|
67
|
+
{
|
|
68
|
+
className,
|
|
69
|
+
style: {
|
|
70
|
+
...style,
|
|
71
|
+
width,
|
|
72
|
+
height,
|
|
73
|
+
background: "#f0f0f0",
|
|
74
|
+
display: "flex",
|
|
75
|
+
alignItems: "center",
|
|
76
|
+
justifyContent: "center",
|
|
77
|
+
borderRadius: "8px"
|
|
78
|
+
},
|
|
79
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { color: "#666", fontSize: "14px" }, children: "Loading map..." })
|
|
80
|
+
}
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
const mapStyle = "https://demotiles.maplibre.org/style.json";
|
|
84
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className, style: { ...style, width, height, position: "relative" }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
85
|
+
import_maplibre.default,
|
|
86
|
+
{
|
|
87
|
+
initialViewState: {
|
|
88
|
+
latitude: config.center.lat,
|
|
89
|
+
longitude: config.center.lng,
|
|
90
|
+
zoom: config.zoom
|
|
91
|
+
},
|
|
92
|
+
style: { width: "100%", height: "100%", borderRadius: "8px" },
|
|
93
|
+
mapStyle,
|
|
94
|
+
attributionControl: true,
|
|
95
|
+
children: [
|
|
96
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_maplibre.NavigationControl, { position: "top-right" }),
|
|
97
|
+
config.markers?.map((marker, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
98
|
+
import_maplibre.Marker,
|
|
99
|
+
{
|
|
100
|
+
latitude: marker.lat,
|
|
101
|
+
longitude: marker.lng,
|
|
102
|
+
anchor: "bottom",
|
|
103
|
+
onClick: () => onMarkerClick(marker),
|
|
104
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
105
|
+
"div",
|
|
106
|
+
{
|
|
107
|
+
style: {
|
|
108
|
+
cursor: "pointer",
|
|
109
|
+
fontSize: "24px",
|
|
110
|
+
transform: "translate(-50%, -100%)"
|
|
111
|
+
},
|
|
112
|
+
title: marker.label,
|
|
113
|
+
children: "\u{1F4CD}"
|
|
114
|
+
}
|
|
115
|
+
)
|
|
116
|
+
},
|
|
117
|
+
`${marker.label}-${index}`
|
|
118
|
+
)),
|
|
119
|
+
popupInfo && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
120
|
+
import_maplibre.Popup,
|
|
121
|
+
{
|
|
122
|
+
latitude: popupInfo.lat,
|
|
123
|
+
longitude: popupInfo.lng,
|
|
124
|
+
anchor: "top",
|
|
125
|
+
onClose: onPopupClose,
|
|
126
|
+
closeOnClick: false,
|
|
127
|
+
style: { maxWidth: "300px" },
|
|
128
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { padding: "4px 0" }, children: [
|
|
129
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { style: { display: "block", marginBottom: "4px" }, children: popupInfo.label }),
|
|
130
|
+
popupInfo.popup && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { fontSize: "14px", color: "#666" }, children: popupInfo.popup })
|
|
131
|
+
] })
|
|
132
|
+
}
|
|
133
|
+
),
|
|
134
|
+
config.layers?.map((layer, index) => {
|
|
135
|
+
if (layer.type === "polyline") {
|
|
136
|
+
const geojson = {
|
|
137
|
+
type: "Feature",
|
|
138
|
+
geometry: {
|
|
139
|
+
type: "LineString",
|
|
140
|
+
coordinates: layer.data
|
|
141
|
+
// [[lng, lat], [lng, lat], ...]
|
|
142
|
+
},
|
|
143
|
+
properties: {}
|
|
144
|
+
};
|
|
145
|
+
const layerStyle = {
|
|
146
|
+
id: `polyline-${index}`,
|
|
147
|
+
type: "line",
|
|
148
|
+
paint: {
|
|
149
|
+
"line-color": layer.style?.color || "#FF5733",
|
|
150
|
+
"line-width": layer.style?.width || 3,
|
|
151
|
+
"line-opacity": layer.style?.opacity || 1
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_maplibre.Source, { type: "geojson", data: geojson, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_maplibre.Layer, { ...layerStyle }) }, `polyline-${index}`);
|
|
155
|
+
}
|
|
156
|
+
if (layer.type === "polygon") {
|
|
157
|
+
const geojson = {
|
|
158
|
+
type: "Feature",
|
|
159
|
+
geometry: {
|
|
160
|
+
type: "Polygon",
|
|
161
|
+
coordinates: [layer.data]
|
|
162
|
+
// [[[lng, lat], [lng, lat], ...]]
|
|
163
|
+
},
|
|
164
|
+
properties: {}
|
|
165
|
+
};
|
|
166
|
+
const layerStyle = {
|
|
167
|
+
id: `polygon-${index}`,
|
|
168
|
+
type: "fill",
|
|
169
|
+
paint: {
|
|
170
|
+
"fill-color": layer.style?.fillColor || layer.style?.color || "#3388ff",
|
|
171
|
+
"fill-opacity": layer.style?.fillOpacity || 0.4,
|
|
172
|
+
"fill-outline-color": layer.style?.color || "#3388ff"
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_maplibre.Source, { type: "geojson", data: geojson, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_maplibre.Layer, { ...layerStyle }) }, `polygon-${index}`);
|
|
176
|
+
}
|
|
177
|
+
if (layer.type === "geojson") {
|
|
178
|
+
const layerStyle = {
|
|
179
|
+
id: `geojson-${index}`,
|
|
180
|
+
type: "fill",
|
|
181
|
+
paint: {
|
|
182
|
+
"fill-color": layer.style?.fillColor || layer.style?.color || "#3388ff",
|
|
183
|
+
"fill-opacity": layer.style?.fillOpacity || 0.4
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_maplibre.Source, { type: "geojson", data: layer.data, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_maplibre.Layer, { ...layerStyle }) }, `geojson-${index}`);
|
|
187
|
+
}
|
|
188
|
+
return null;
|
|
189
|
+
})
|
|
190
|
+
]
|
|
191
|
+
}
|
|
192
|
+
) });
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
// src/index.ts
|
|
196
|
+
function registerMapLibreProvider() {
|
|
197
|
+
(0, import_core.registerMapProvider)(MapLibreProvider);
|
|
198
|
+
}
|
|
199
|
+
var index_default = MapLibreProvider;
|
|
200
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
201
|
+
0 && (module.exports = {
|
|
202
|
+
MapLibreProvider,
|
|
203
|
+
registerMapLibreProvider
|
|
204
|
+
});
|
|
205
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/MapLibreProvider.tsx"],"sourcesContent":["/**\n * @stackwright/maplibre — Free tier map adapter for Stackwright\n *\n * **License:** BSD-3-Clause (MapLibre GL) + MIT (this package)\n * **Features:**\n * - 2D interactive maps\n * - No API keys required (uses MapLibre demo tiles)\n * - Markers, polylines, polygons, GeoJSON\n * - SSR-safe for Next.js\n * - Responsive design\n *\n * **Installation:**\n *\n * ```bash\n * pnpm add @stackwright/maplibre\n * ```\n *\n * **Usage in Next.js:**\n *\n * ```typescript\n * // pages/_app.tsx\n * import { registerMapLibreProvider } from '@stackwright/maplibre';\n * import '@stackwright/maplibre/dist/styles.css';\n * import { registerNextJSComponents } from '@stackwright/nextjs';\n *\n * registerNextJSComponents();\n * registerMapLibreProvider();\n * ```\n *\n * **YAML Example:**\n *\n * ```yaml\n * content:\n * content_items:\n * - type: map\n * label: \"Office locations\"\n * center: { lat: 37.7749, lng: -122.4194 }\n * zoom: 12\n * markers:\n * - lat: 37.7749\n * lng: -122.4194\n * label: \"San Francisco HQ\"\n * ```\n *\n * @packageDocumentation\n */\n\nimport { registerMapProvider } from '@stackwright/core';\nimport { MapLibreProvider } from './MapLibreProvider.js';\n\nexport { MapLibreProvider } from './MapLibreProvider.js';\n\n/**\n * Register MapLibreProvider as the active map adapter.\n *\n * Call this in `_app.tsx` (Pages Router) or `layout.tsx` (App Router)\n * alongside `registerNextJSComponents()`:\n *\n * ```typescript\n * import { registerMapLibreProvider } from '@stackwright/maplibre';\n * import '@stackwright/maplibre/dist/styles.css';\n *\n * registerMapLibreProvider();\n * ```\n *\n * **Swapping to pro 3D provider:**\n *\n * ```typescript\n * // Switch from MapLibre (2D) to Cesium (3D globe)\n * import { registerCesiumProvider } from '@stackwright-pro/cesium';\n * registerCesiumProvider();\n * ```\n *\n * This is a one-line change — your YAML content, components, and pages\n * stay identical. That's the power of the adapter pattern!\n */\nexport function registerMapLibreProvider(): void {\n registerMapProvider(MapLibreProvider);\n}\n\nexport default MapLibreProvider;\n","import React, { useState, useCallback, useEffect } from 'react';\nimport MapGL, { Marker, Popup, Source, Layer, NavigationControl } from 'react-map-gl/maplibre';\nimport type { MapProviderProps, MapMarker } from '@stackwright/core';\nimport type { LayerProps } from 'react-map-gl/maplibre';\n\n/**\n * MapLibreProvider — Free tier map adapter using MapLibre GL.\n *\n * **Features:**\n * - 2D interactive maps with pan/zoom\n * - Markers with click-to-show popups\n * - Polyline and polygon layers\n * - GeoJSON support\n * - Free MapLibre demo tiles (no API key required)\n * - SSR-safe for Next.js\n * - Responsive (320px to 1440px)\n *\n * **License:** BSD-3-Clause (MapLibre GL)\n * **Vendor lock-in:** None (can swap to Mapbox, Maptiler, etc.)\n *\n * **Usage:**\n *\n * ```typescript\n * import { registerMapLibreProvider } from '@stackwright/maplibre';\n * import '@stackwright/maplibre/dist/styles.css';\n *\n * registerMapLibreProvider();\n * ```\n *\n * @see https://maplibre.org/maplibre-gl-js/docs/\n */\nexport const MapLibreProvider: React.FC<MapProviderProps> = ({\n config,\n height = '100%',\n width = '100%',\n className,\n style,\n}) => {\n const [popupInfo, setPopupInfo] = useState<MapMarker | null>(null);\n const [isClient, setIsClient] = useState(false);\n\n // SSR safety: Only render map on client\n useEffect(() => {\n setIsClient(true);\n }, []);\n\n const onMarkerClick = useCallback((marker: MapMarker) => {\n // Toggle popup: close if already open on this marker, otherwise open\n setPopupInfo((current) =>\n current?.label === marker.label && current?.lat === marker.lat ? null : marker\n );\n }, []);\n\n const onPopupClose = useCallback(() => {\n setPopupInfo(null);\n }, []);\n\n // Don't render anything on server side\n if (!isClient) {\n return (\n <div\n className={className}\n style={{\n ...style,\n width,\n height,\n background: '#f0f0f0',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n borderRadius: '8px',\n }}\n >\n <span style={{ color: '#666', fontSize: '14px' }}>Loading map...</span>\n </div>\n );\n }\n\n // MapLibre demo tile server (free, no API key needed)\n const mapStyle = 'https://demotiles.maplibre.org/style.json';\n\n return (\n <div className={className} style={{ ...style, width, height, position: 'relative' }}>\n <MapGL\n initialViewState={{\n latitude: config.center.lat,\n longitude: config.center.lng,\n zoom: config.zoom,\n }}\n style={{ width: '100%', height: '100%', borderRadius: '8px' }}\n mapStyle={mapStyle}\n attributionControl={true}\n >\n {/* Navigation controls (zoom, rotate) */}\n <NavigationControl position=\"top-right\" />\n\n {/* Render markers */}\n {config.markers?.map((marker, index) => (\n <Marker\n key={`${marker.label}-${index}`}\n latitude={marker.lat}\n longitude={marker.lng}\n anchor=\"bottom\"\n onClick={() => onMarkerClick(marker)}\n >\n <div\n style={{\n cursor: 'pointer',\n fontSize: '24px',\n transform: 'translate(-50%, -100%)',\n }}\n title={marker.label}\n >\n 📍\n </div>\n </Marker>\n ))}\n\n {/* Popup for clicked marker */}\n {popupInfo && (\n <Popup\n latitude={popupInfo.lat}\n longitude={popupInfo.lng}\n anchor=\"top\"\n onClose={onPopupClose}\n closeOnClick={false}\n style={{ maxWidth: '300px' }}\n >\n <div style={{ padding: '4px 0' }}>\n <strong style={{ display: 'block', marginBottom: '4px' }}>{popupInfo.label}</strong>\n {popupInfo.popup && (\n <div style={{ fontSize: '14px', color: '#666' }}>{popupInfo.popup}</div>\n )}\n </div>\n </Popup>\n )}\n\n {/* Render layers (polylines, polygons, GeoJSON) */}\n {config.layers?.map((layer, index) => {\n if (layer.type === 'polyline') {\n // Polyline layer (routes, paths)\n const geojson = {\n type: 'Feature' as const,\n geometry: {\n type: 'LineString' as const,\n coordinates: layer.data as number[][], // [[lng, lat], [lng, lat], ...]\n },\n properties: {},\n };\n\n const layerStyle: LayerProps = {\n id: `polyline-${index}`,\n type: 'line',\n paint: {\n 'line-color': layer.style?.color || '#FF5733',\n 'line-width': layer.style?.width || 3,\n 'line-opacity': layer.style?.opacity || 1,\n },\n };\n\n return (\n <Source key={`polyline-${index}`} type=\"geojson\" data={geojson}>\n <Layer {...layerStyle} />\n </Source>\n );\n }\n\n if (layer.type === 'polygon') {\n // Polygon layer (boundaries, regions)\n const geojson = {\n type: 'Feature' as const,\n geometry: {\n type: 'Polygon' as const,\n coordinates: [layer.data] as number[][][], // [[[lng, lat], [lng, lat], ...]]\n },\n properties: {},\n };\n\n const layerStyle: LayerProps = {\n id: `polygon-${index}`,\n type: 'fill',\n paint: {\n 'fill-color': layer.style?.fillColor || layer.style?.color || '#3388ff',\n 'fill-opacity': layer.style?.fillOpacity || 0.4,\n 'fill-outline-color': layer.style?.color || '#3388ff',\n },\n };\n\n return (\n <Source key={`polygon-${index}`} type=\"geojson\" data={geojson}>\n <Layer {...layerStyle} />\n </Source>\n );\n }\n\n if (layer.type === 'geojson') {\n // GeoJSON layer (arbitrary geometries)\n const layerStyle: LayerProps = {\n id: `geojson-${index}`,\n type: 'fill',\n paint: {\n 'fill-color': layer.style?.fillColor || layer.style?.color || '#3388ff',\n 'fill-opacity': layer.style?.fillOpacity || 0.4,\n },\n };\n\n return (\n <Source key={`geojson-${index}`} type=\"geojson\" data={layer.data}>\n <Layer {...layerStyle} />\n </Source>\n );\n }\n\n return null;\n })}\n </MapGL>\n </div>\n );\n};\n\nexport default MapLibreProvider;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA+CA,kBAAoC;;;AC/CpC,mBAAwD;AACxD,sBAAuE;AAwE/D;AA1CD,IAAM,mBAA+C,CAAC;AAAA,EAC3D;AAAA,EACA,SAAS;AAAA,EACT,QAAQ;AAAA,EACR;AAAA,EACA;AACF,MAAM;AACJ,QAAM,CAAC,WAAW,YAAY,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
+
|
|
4
|
+
// src/MapLibreProvider.tsx
|
|
5
|
+
import { useState, useCallback, useEffect } from "react";
|
|
6
|
+
import MapGL, { Marker, Popup, Source, Layer, NavigationControl } from "react-map-gl/maplibre";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
var MapLibreProvider = ({
|
|
9
|
+
config,
|
|
10
|
+
height = "100%",
|
|
11
|
+
width = "100%",
|
|
12
|
+
className,
|
|
13
|
+
style
|
|
14
|
+
}) => {
|
|
15
|
+
const [popupInfo, setPopupInfo] = useState(null);
|
|
16
|
+
const [isClient, setIsClient] = useState(false);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
setIsClient(true);
|
|
19
|
+
}, []);
|
|
20
|
+
const onMarkerClick = useCallback((marker) => {
|
|
21
|
+
setPopupInfo(
|
|
22
|
+
(current) => current?.label === marker.label && current?.lat === marker.lat ? null : marker
|
|
23
|
+
);
|
|
24
|
+
}, []);
|
|
25
|
+
const onPopupClose = useCallback(() => {
|
|
26
|
+
setPopupInfo(null);
|
|
27
|
+
}, []);
|
|
28
|
+
if (!isClient) {
|
|
29
|
+
return /* @__PURE__ */ jsx(
|
|
30
|
+
"div",
|
|
31
|
+
{
|
|
32
|
+
className,
|
|
33
|
+
style: {
|
|
34
|
+
...style,
|
|
35
|
+
width,
|
|
36
|
+
height,
|
|
37
|
+
background: "#f0f0f0",
|
|
38
|
+
display: "flex",
|
|
39
|
+
alignItems: "center",
|
|
40
|
+
justifyContent: "center",
|
|
41
|
+
borderRadius: "8px"
|
|
42
|
+
},
|
|
43
|
+
children: /* @__PURE__ */ jsx("span", { style: { color: "#666", fontSize: "14px" }, children: "Loading map..." })
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
const mapStyle = "https://demotiles.maplibre.org/style.json";
|
|
48
|
+
return /* @__PURE__ */ jsx("div", { className, style: { ...style, width, height, position: "relative" }, children: /* @__PURE__ */ jsxs(
|
|
49
|
+
MapGL,
|
|
50
|
+
{
|
|
51
|
+
initialViewState: {
|
|
52
|
+
latitude: config.center.lat,
|
|
53
|
+
longitude: config.center.lng,
|
|
54
|
+
zoom: config.zoom
|
|
55
|
+
},
|
|
56
|
+
style: { width: "100%", height: "100%", borderRadius: "8px" },
|
|
57
|
+
mapStyle,
|
|
58
|
+
attributionControl: true,
|
|
59
|
+
children: [
|
|
60
|
+
/* @__PURE__ */ jsx(NavigationControl, { position: "top-right" }),
|
|
61
|
+
config.markers?.map((marker, index) => /* @__PURE__ */ jsx(
|
|
62
|
+
Marker,
|
|
63
|
+
{
|
|
64
|
+
latitude: marker.lat,
|
|
65
|
+
longitude: marker.lng,
|
|
66
|
+
anchor: "bottom",
|
|
67
|
+
onClick: () => onMarkerClick(marker),
|
|
68
|
+
children: /* @__PURE__ */ jsx(
|
|
69
|
+
"div",
|
|
70
|
+
{
|
|
71
|
+
style: {
|
|
72
|
+
cursor: "pointer",
|
|
73
|
+
fontSize: "24px",
|
|
74
|
+
transform: "translate(-50%, -100%)"
|
|
75
|
+
},
|
|
76
|
+
title: marker.label,
|
|
77
|
+
children: "\u{1F4CD}"
|
|
78
|
+
}
|
|
79
|
+
)
|
|
80
|
+
},
|
|
81
|
+
`${marker.label}-${index}`
|
|
82
|
+
)),
|
|
83
|
+
popupInfo && /* @__PURE__ */ jsx(
|
|
84
|
+
Popup,
|
|
85
|
+
{
|
|
86
|
+
latitude: popupInfo.lat,
|
|
87
|
+
longitude: popupInfo.lng,
|
|
88
|
+
anchor: "top",
|
|
89
|
+
onClose: onPopupClose,
|
|
90
|
+
closeOnClick: false,
|
|
91
|
+
style: { maxWidth: "300px" },
|
|
92
|
+
children: /* @__PURE__ */ jsxs("div", { style: { padding: "4px 0" }, children: [
|
|
93
|
+
/* @__PURE__ */ jsx("strong", { style: { display: "block", marginBottom: "4px" }, children: popupInfo.label }),
|
|
94
|
+
popupInfo.popup && /* @__PURE__ */ jsx("div", { style: { fontSize: "14px", color: "#666" }, children: popupInfo.popup })
|
|
95
|
+
] })
|
|
96
|
+
}
|
|
97
|
+
),
|
|
98
|
+
config.layers?.map((layer, index) => {
|
|
99
|
+
if (layer.type === "polyline") {
|
|
100
|
+
const geojson = {
|
|
101
|
+
type: "Feature",
|
|
102
|
+
geometry: {
|
|
103
|
+
type: "LineString",
|
|
104
|
+
coordinates: layer.data
|
|
105
|
+
// [[lng, lat], [lng, lat], ...]
|
|
106
|
+
},
|
|
107
|
+
properties: {}
|
|
108
|
+
};
|
|
109
|
+
const layerStyle = {
|
|
110
|
+
id: `polyline-${index}`,
|
|
111
|
+
type: "line",
|
|
112
|
+
paint: {
|
|
113
|
+
"line-color": layer.style?.color || "#FF5733",
|
|
114
|
+
"line-width": layer.style?.width || 3,
|
|
115
|
+
"line-opacity": layer.style?.opacity || 1
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
return /* @__PURE__ */ jsx(Source, { type: "geojson", data: geojson, children: /* @__PURE__ */ jsx(Layer, { ...layerStyle }) }, `polyline-${index}`);
|
|
119
|
+
}
|
|
120
|
+
if (layer.type === "polygon") {
|
|
121
|
+
const geojson = {
|
|
122
|
+
type: "Feature",
|
|
123
|
+
geometry: {
|
|
124
|
+
type: "Polygon",
|
|
125
|
+
coordinates: [layer.data]
|
|
126
|
+
// [[[lng, lat], [lng, lat], ...]]
|
|
127
|
+
},
|
|
128
|
+
properties: {}
|
|
129
|
+
};
|
|
130
|
+
const layerStyle = {
|
|
131
|
+
id: `polygon-${index}`,
|
|
132
|
+
type: "fill",
|
|
133
|
+
paint: {
|
|
134
|
+
"fill-color": layer.style?.fillColor || layer.style?.color || "#3388ff",
|
|
135
|
+
"fill-opacity": layer.style?.fillOpacity || 0.4,
|
|
136
|
+
"fill-outline-color": layer.style?.color || "#3388ff"
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
return /* @__PURE__ */ jsx(Source, { type: "geojson", data: geojson, children: /* @__PURE__ */ jsx(Layer, { ...layerStyle }) }, `polygon-${index}`);
|
|
140
|
+
}
|
|
141
|
+
if (layer.type === "geojson") {
|
|
142
|
+
const layerStyle = {
|
|
143
|
+
id: `geojson-${index}`,
|
|
144
|
+
type: "fill",
|
|
145
|
+
paint: {
|
|
146
|
+
"fill-color": layer.style?.fillColor || layer.style?.color || "#3388ff",
|
|
147
|
+
"fill-opacity": layer.style?.fillOpacity || 0.4
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
return /* @__PURE__ */ jsx(Source, { type: "geojson", data: layer.data, children: /* @__PURE__ */ jsx(Layer, { ...layerStyle }) }, `geojson-${index}`);
|
|
151
|
+
}
|
|
152
|
+
return null;
|
|
153
|
+
})
|
|
154
|
+
]
|
|
155
|
+
}
|
|
156
|
+
) });
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
// src/index.ts
|
|
160
|
+
function registerMapLibreProvider() {
|
|
161
|
+
registerMapProvider(MapLibreProvider);
|
|
162
|
+
}
|
|
163
|
+
var index_default = MapLibreProvider;
|
|
164
|
+
export {
|
|
165
|
+
MapLibreProvider,
|
|
166
|
+
index_default as default,
|
|
167
|
+
registerMapLibreProvider
|
|
168
|
+
};
|
|
169
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/MapLibreProvider.tsx"],"sourcesContent":["/**\n * @stackwright/maplibre — Free tier map adapter for Stackwright\n *\n * **License:** BSD-3-Clause (MapLibre GL) + MIT (this package)\n * **Features:**\n * - 2D interactive maps\n * - No API keys required (uses MapLibre demo tiles)\n * - Markers, polylines, polygons, GeoJSON\n * - SSR-safe for Next.js\n * - Responsive design\n *\n * **Installation:**\n *\n * ```bash\n * pnpm add @stackwright/maplibre\n * ```\n *\n * **Usage in Next.js:**\n *\n * ```typescript\n * // pages/_app.tsx\n * import { registerMapLibreProvider } from '@stackwright/maplibre';\n * import '@stackwright/maplibre/dist/styles.css';\n * import { registerNextJSComponents } from '@stackwright/nextjs';\n *\n * registerNextJSComponents();\n * registerMapLibreProvider();\n * ```\n *\n * **YAML Example:**\n *\n * ```yaml\n * content:\n * content_items:\n * - type: map\n * label: \"Office locations\"\n * center: { lat: 37.7749, lng: -122.4194 }\n * zoom: 12\n * markers:\n * - lat: 37.7749\n * lng: -122.4194\n * label: \"San Francisco HQ\"\n * ```\n *\n * @packageDocumentation\n */\n\nimport { registerMapProvider } from '@stackwright/core';\nimport { MapLibreProvider } from './MapLibreProvider.js';\n\nexport { MapLibreProvider } from './MapLibreProvider.js';\n\n/**\n * Register MapLibreProvider as the active map adapter.\n *\n * Call this in `_app.tsx` (Pages Router) or `layout.tsx` (App Router)\n * alongside `registerNextJSComponents()`:\n *\n * ```typescript\n * import { registerMapLibreProvider } from '@stackwright/maplibre';\n * import '@stackwright/maplibre/dist/styles.css';\n *\n * registerMapLibreProvider();\n * ```\n *\n * **Swapping to pro 3D provider:**\n *\n * ```typescript\n * // Switch from MapLibre (2D) to Cesium (3D globe)\n * import { registerCesiumProvider } from '@stackwright-pro/cesium';\n * registerCesiumProvider();\n * ```\n *\n * This is a one-line change — your YAML content, components, and pages\n * stay identical. That's the power of the adapter pattern!\n */\nexport function registerMapLibreProvider(): void {\n registerMapProvider(MapLibreProvider);\n}\n\nexport default MapLibreProvider;\n","import React, { useState, useCallback, useEffect } from 'react';\nimport MapGL, { Marker, Popup, Source, Layer, NavigationControl } from 'react-map-gl/maplibre';\nimport type { MapProviderProps, MapMarker } from '@stackwright/core';\nimport type { LayerProps } from 'react-map-gl/maplibre';\n\n/**\n * MapLibreProvider — Free tier map adapter using MapLibre GL.\n *\n * **Features:**\n * - 2D interactive maps with pan/zoom\n * - Markers with click-to-show popups\n * - Polyline and polygon layers\n * - GeoJSON support\n * - Free MapLibre demo tiles (no API key required)\n * - SSR-safe for Next.js\n * - Responsive (320px to 1440px)\n *\n * **License:** BSD-3-Clause (MapLibre GL)\n * **Vendor lock-in:** None (can swap to Mapbox, Maptiler, etc.)\n *\n * **Usage:**\n *\n * ```typescript\n * import { registerMapLibreProvider } from '@stackwright/maplibre';\n * import '@stackwright/maplibre/dist/styles.css';\n *\n * registerMapLibreProvider();\n * ```\n *\n * @see https://maplibre.org/maplibre-gl-js/docs/\n */\nexport const MapLibreProvider: React.FC<MapProviderProps> = ({\n config,\n height = '100%',\n width = '100%',\n className,\n style,\n}) => {\n const [popupInfo, setPopupInfo] = useState<MapMarker | null>(null);\n const [isClient, setIsClient] = useState(false);\n\n // SSR safety: Only render map on client\n useEffect(() => {\n setIsClient(true);\n }, []);\n\n const onMarkerClick = useCallback((marker: MapMarker) => {\n // Toggle popup: close if already open on this marker, otherwise open\n setPopupInfo((current) =>\n current?.label === marker.label && current?.lat === marker.lat ? null : marker\n );\n }, []);\n\n const onPopupClose = useCallback(() => {\n setPopupInfo(null);\n }, []);\n\n // Don't render anything on server side\n if (!isClient) {\n return (\n <div\n className={className}\n style={{\n ...style,\n width,\n height,\n background: '#f0f0f0',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n borderRadius: '8px',\n }}\n >\n <span style={{ color: '#666', fontSize: '14px' }}>Loading map...</span>\n </div>\n );\n }\n\n // MapLibre demo tile server (free, no API key needed)\n const mapStyle = 'https://demotiles.maplibre.org/style.json';\n\n return (\n <div className={className} style={{ ...style, width, height, position: 'relative' }}>\n <MapGL\n initialViewState={{\n latitude: config.center.lat,\n longitude: config.center.lng,\n zoom: config.zoom,\n }}\n style={{ width: '100%', height: '100%', borderRadius: '8px' }}\n mapStyle={mapStyle}\n attributionControl={true}\n >\n {/* Navigation controls (zoom, rotate) */}\n <NavigationControl position=\"top-right\" />\n\n {/* Render markers */}\n {config.markers?.map((marker, index) => (\n <Marker\n key={`${marker.label}-${index}`}\n latitude={marker.lat}\n longitude={marker.lng}\n anchor=\"bottom\"\n onClick={() => onMarkerClick(marker)}\n >\n <div\n style={{\n cursor: 'pointer',\n fontSize: '24px',\n transform: 'translate(-50%, -100%)',\n }}\n title={marker.label}\n >\n 📍\n </div>\n </Marker>\n ))}\n\n {/* Popup for clicked marker */}\n {popupInfo && (\n <Popup\n latitude={popupInfo.lat}\n longitude={popupInfo.lng}\n anchor=\"top\"\n onClose={onPopupClose}\n closeOnClick={false}\n style={{ maxWidth: '300px' }}\n >\n <div style={{ padding: '4px 0' }}>\n <strong style={{ display: 'block', marginBottom: '4px' }}>{popupInfo.label}</strong>\n {popupInfo.popup && (\n <div style={{ fontSize: '14px', color: '#666' }}>{popupInfo.popup}</div>\n )}\n </div>\n </Popup>\n )}\n\n {/* Render layers (polylines, polygons, GeoJSON) */}\n {config.layers?.map((layer, index) => {\n if (layer.type === 'polyline') {\n // Polyline layer (routes, paths)\n const geojson = {\n type: 'Feature' as const,\n geometry: {\n type: 'LineString' as const,\n coordinates: layer.data as number[][], // [[lng, lat], [lng, lat], ...]\n },\n properties: {},\n };\n\n const layerStyle: LayerProps = {\n id: `polyline-${index}`,\n type: 'line',\n paint: {\n 'line-color': layer.style?.color || '#FF5733',\n 'line-width': layer.style?.width || 3,\n 'line-opacity': layer.style?.opacity || 1,\n },\n };\n\n return (\n <Source key={`polyline-${index}`} type=\"geojson\" data={geojson}>\n <Layer {...layerStyle} />\n </Source>\n );\n }\n\n if (layer.type === 'polygon') {\n // Polygon layer (boundaries, regions)\n const geojson = {\n type: 'Feature' as const,\n geometry: {\n type: 'Polygon' as const,\n coordinates: [layer.data] as number[][][], // [[[lng, lat], [lng, lat], ...]]\n },\n properties: {},\n };\n\n const layerStyle: LayerProps = {\n id: `polygon-${index}`,\n type: 'fill',\n paint: {\n 'fill-color': layer.style?.fillColor || layer.style?.color || '#3388ff',\n 'fill-opacity': layer.style?.fillOpacity || 0.4,\n 'fill-outline-color': layer.style?.color || '#3388ff',\n },\n };\n\n return (\n <Source key={`polygon-${index}`} type=\"geojson\" data={geojson}>\n <Layer {...layerStyle} />\n </Source>\n );\n }\n\n if (layer.type === 'geojson') {\n // GeoJSON layer (arbitrary geometries)\n const layerStyle: LayerProps = {\n id: `geojson-${index}`,\n type: 'fill',\n paint: {\n 'fill-color': layer.style?.fillColor || layer.style?.color || '#3388ff',\n 'fill-opacity': layer.style?.fillOpacity || 0.4,\n },\n };\n\n return (\n <Source key={`geojson-${index}`} type=\"geojson\" data={layer.data}>\n <Layer {...layerStyle} />\n </Source>\n );\n }\n\n return null;\n })}\n </MapGL>\n </div>\n );\n};\n\nexport default MapLibreProvider;\n"],"mappings":";AA+CA,SAAS,2BAA2B;;;AC/CpC,SAAgB,UAAU,aAAa,iBAAiB;AACxD,OAAO,SAAS,QAAQ,OAAO,QAAQ,OAAO,yBAAyB;AAwE/D,cAuDI,YAvDJ;AA1CD,IAAM,mBAA+C,CAAC;AAAA,EAC3D;AAAA,EACA,SAAS;AAAA,EACT,QAAQ;AAAA,EACR;AAAA,EACA;AACF,MAAM;AACJ,QAAM,CAAC,WAAW,YAAY,IAAI,SAA2B,IAAI;AACjE,QAAM,CAAC,UAAU,WAAW,IAAI,SAAS,KAAK;AAG9C,YAAU,MAAM;AACd,gBAAY,IAAI;AAAA,EAClB,GAAG,CAAC,CAAC;AAEL,QAAM,gBAAgB,YAAY,CAAC,WAAsB;AAEvD;AAAA,MAAa,CAAC,YACZ,SAAS,UAAU,OAAO,SAAS,SAAS,QAAQ,OAAO,MAAM,OAAO;AAAA,IAC1E;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,QAAM,eAAe,YAAY,MAAM;AACrC,iBAAa,IAAI;AAAA,EACnB,GAAG,CAAC,CAAC;AAGL,MAAI,CAAC,UAAU;AACb,WACE;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA,OAAO;AAAA,UACL,GAAG;AAAA,UACH;AAAA,UACA;AAAA,UACA,YAAY;AAAA,UACZ,SAAS;AAAA,UACT,YAAY;AAAA,UACZ,gBAAgB;AAAA,UAChB,cAAc;AAAA,QAChB;AAAA,QAEA,8BAAC,UAAK,OAAO,EAAE,OAAO,QAAQ,UAAU,OAAO,GAAG,4BAAc;AAAA;AAAA,IAClE;AAAA,EAEJ;AAGA,QAAM,WA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,aAAa,MAAM,OAAO,SAAS;AAAA,gBAC9D,gBAAgB,MAAM,OAAO,eAAe;AAAA,cAC9C;AAAA,YACF;AAEA,mBACE,oBAAC,UAAgC,MAAK,WAAU,MAAM,MAAM,MAC1D,8BAAC,SAAO,GAAG,YAAY,KADZ,WAAW,KAAK,EAE7B;AAAA,UAEJ;AAEA,iBAAO;AAAA,QACT,CAAC;AAAA;AAAA;AAAA,EACH,GACF;AAEJ;;;AD9IO,SAAS,2BAAiC;AAC/C,sBAAoB,gBAAgB;AACtC;AAEA,IAAO,gBAAQ;","names":[]}
|
package/dist/styles.css
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MapLibre GL CSS
|
|
3
|
+
*
|
|
4
|
+
* This imports the required MapLibre GL styles and adds responsive overrides.
|
|
5
|
+
*
|
|
6
|
+
* Usage in Next.js _app.tsx:
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import '@stackwright/maplibre/dist/styles.css';
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
@import 'maplibre-gl/dist/maplibre-gl.css';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Responsive overrides for mobile devices
|
|
16
|
+
*/
|
|
17
|
+
.maplibregl-map {
|
|
18
|
+
font-family: inherit;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.maplibregl-ctrl-group {
|
|
22
|
+
box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Ensure popups are readable on small screens
|
|
27
|
+
*/
|
|
28
|
+
.maplibregl-popup-content {
|
|
29
|
+
min-width: 200px;
|
|
30
|
+
max-width: 90vw;
|
|
31
|
+
padding: 12px 16px;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@media (max-width: 768px) {
|
|
35
|
+
.maplibregl-popup-content {
|
|
36
|
+
font-size: 14px;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.maplibregl-ctrl-group button {
|
|
40
|
+
width: 32px;
|
|
41
|
+
height: 32px;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Improve marker visibility
|
|
47
|
+
*/
|
|
48
|
+
.maplibregl-marker {
|
|
49
|
+
cursor: pointer;
|
|
50
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stackwright/maplibre",
|
|
3
|
+
"version": "1.0.0-alpha.2",
|
|
4
|
+
"description": "MapLibre GL adapter for Stackwright maps (free tier, no API keys required)",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/Per-Aspera-LLC/stackwright"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"main": "./dist/index.js",
|
|
14
|
+
"module": "./dist/index.mjs",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.mjs",
|
|
20
|
+
"require": "./dist/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./dist/styles.css": "./dist/styles.css"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"maplibre-gl": "^4.7.1",
|
|
26
|
+
"react-map-gl": "^7.1.7"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@testing-library/jest-dom": "^6.6",
|
|
30
|
+
"@testing-library/react": "^16.3",
|
|
31
|
+
"@types/react": "^19.2.14",
|
|
32
|
+
"@types/react-dom": "^19.2.3",
|
|
33
|
+
"jsdom": "^28.1.0",
|
|
34
|
+
"react": "^19",
|
|
35
|
+
"react-dom": "^19",
|
|
36
|
+
"tsup": "^8",
|
|
37
|
+
"typescript": "^5",
|
|
38
|
+
"vitest": "^4",
|
|
39
|
+
"@stackwright/core": "0.7.0-alpha.6"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"react": "^18 || ^19",
|
|
43
|
+
"react-dom": "^18 || ^19",
|
|
44
|
+
"@stackwright/core": "0.7.0-alpha.6"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "tsup && cp src/styles.css dist/styles.css",
|
|
48
|
+
"dev": "tsup --watch",
|
|
49
|
+
"test": "vitest",
|
|
50
|
+
"test:run": "vitest run",
|
|
51
|
+
"test:coverage": "vitest run --coverage"
|
|
52
|
+
}
|
|
53
|
+
}
|