@minmaps-dev/mm-web-sdk 1.0.0-rc.1 → 1.0.0-rc.3

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 CHANGED
@@ -1,167 +1,239 @@
1
- # MinuteMaps SDK
1
+ # MinuteMaps Web SDK
2
2
 
3
- A comprehensive indoor mapping SDK built with MapLibre GL JS, providing venue management, theming, wayfinding, and interactive features.
3
+ `@minmaps-dev/mm-web-sdk` is the official MinuteMaps SDK for the web. It renders indoor venues — floors, POIs, amenities, destinations, and wayfinding routes — on top of [MapLibre GL JS](https://maplibre.org/), with data sourced from JACS.
4
4
 
5
- ## 🚀 Features
5
+ ## Features
6
6
 
7
- - **Venue Management** - Load and manage indoor venues with multiple floors
8
- - **Theme System** - Multiple visual themes with easy switching
9
- - **Wayfinding** - Indoor navigation and routing
10
- - **Interactive Layers** - Amenities, destinations, and moving elements
11
- - **Accessibility** - High-contrast themes and accessibility features
12
- - **Custom Controls** - Floor selector, navigation controls, and more
7
+ - **Venue + floors** load a venue by `customerId` / `venueId`, switch active floor, and let the SDK manage layer visibility.
8
+ - **POIs, amenities, destinations** query the venue, filter by floor, and run keyword searches.
9
+ - **Wayfinding** — compute kiosk-to-destination or waypoint-to-waypoint routes and render them on the map.
10
+ - **View modes** toggle 3D, flat (top-down), and 2D-units modes at runtime.
11
+ - **Camera control** `setView` / `resetView` / `getCameraPosition`, plus a live `cameraChange` event for compass UIs.
12
+ - **React entrypoint** — drop-in `<MinuteMapsView />` for React 18/19 apps.
13
+ - **JACS proxy or direct mode** — keep credentials server-side with the proxy mode, or call JACS directly from trusted environments.
13
14
 
14
- ## 📦 Installation
15
+ ## Installation
15
16
 
16
17
  ```bash
17
- npm install minutemaps-sdk
18
+ npm install @minmaps-dev/mm-web-sdk maplibre-gl @turf/turf
18
19
  ```
19
20
 
20
- ## 🎯 Quick Start
21
+ `maplibre-gl` (v4) and `@turf/turf` (v7) are peer dependencies. `react` / `react-dom` (v18 or v19) are optional peers, only required if you use the `/react` entrypoint.
21
22
 
22
- ```javascript
23
- import MinuteMapsSDK from 'minutemaps-sdk';
23
+ Don't forget to import the MapLibre stylesheet once in your app:
24
24
 
25
- // Initialize the SDK
26
- const sdk = new MinuteMapsSDK();
25
+ ```ts
26
+ import 'maplibre-gl/dist/maplibre-gl.css'
27
+ ```
27
28
 
28
- // Initialize with a venue
29
- await sdk.init({
30
- container: 'map-container',
31
- venueId: 'your-venue-id',
32
- styleUrl: 'https://example.com/style.json',
33
- onReady: () => {
34
- console.log('SDK ready!');
35
- }
36
- });
29
+ ## Quick start (vanilla)
30
+
31
+ ```ts
32
+ import { MinuteMaps } from '@minmaps-dev/mm-web-sdk'
33
+ import 'maplibre-gl/dist/maplibre-gl.css'
34
+
35
+ const sdk = new MinuteMaps({
36
+ container: 'map', // element or element id
37
+ jmap: {
38
+ host: '', // unused in proxy mode
39
+ customerId: 123,
40
+ venueId: 456,
41
+ },
42
+ jacs: {
43
+ mode: 'proxy', // recommended for browser apps
44
+ proxyBaseUrl: '/api/jacs',
45
+ },
46
+ options: {
47
+ customSprite: '/sprites/sprite', // your icon sprite (no extension)
48
+ minIndoorZoom: 16,
49
+ debug: true,
50
+ styleMode: 'sdkTemplate',
51
+ },
52
+ })
53
+
54
+ sdk.on('ready', ({ venue }) => {
55
+ console.log('venue ready', venue?.name)
56
+ })
57
+
58
+ await sdk.init()
59
+ ```
37
60
 
38
- // Switch themes
39
- sdk.switchTheme('modern-glassmorph');
61
+ ## Quick start (React)
62
+
63
+ ```tsx
64
+ import { MinuteMapsView } from '@minmaps-dev/mm-web-sdk/react'
65
+ import 'maplibre-gl/dist/maplibre-gl.css'
66
+
67
+ export function Map() {
68
+ return (
69
+ <MinuteMapsView
70
+ className="h-screen w-screen"
71
+ config={{
72
+ container: '', // ignored — the component owns the element
73
+ jmap: { host: '', customerId: 123, venueId: 456 },
74
+ jacs: { mode: 'proxy', proxyBaseUrl: '/api/jacs' },
75
+ options: { styleMode: 'sdkTemplate' },
76
+ }}
77
+ />
78
+ )
79
+ }
40
80
  ```
41
81
 
42
- ## 🎨 Available Themes
82
+ For a more involved integration that wires events, floors, search, and wayfinding into React state, see the [`mm-web-sdk-example`](../mm-web-sdk-example) Next.js app — particularly [`hooks/useMap.ts`](../mm-web-sdk-example/hooks/useMap.ts).
43
83
 
44
- - **Modern Glassmorph** - Clean, modern design with glass effects
45
- - **Soft Pastel** - Gentle, accessible color palette
46
- - **Accessibility** - High-contrast theme for accessibility
84
+ ## Configuration
85
+
86
+ ```ts
87
+ type SDKConfig = {
88
+ container: HTMLElement | string
89
+ jmap: {
90
+ host: string
91
+ customerId: number
92
+ venueId: number
93
+ locale?: string
94
+ auth?: { clientId: string; clientSecret: string }
95
+ }
96
+ jacs: {
97
+ mode: 'proxy' | 'direct'
98
+ host?: string // 'direct' only
99
+ auth?: { clientId: string; username: string; password: string } // 'direct' only
100
+ proxyBaseUrl?: string // default '/api/jacs'
101
+ }
102
+ options?: SDKOptions
103
+ }
104
+
105
+ type SDKOptions = {
106
+ debug?: boolean
107
+ initialFloor?: string | number
108
+ customSprite?: string // sprite URL prefix (no extension)
109
+ minIndoorZoom?: number
110
+ boundsPadding?: number // default 50
111
+ styleMode?: 'venueStyleUrl' | 'sdkTemplate'
112
+ templateOverrideMode?: 'colorsOnly' | 'colorsAndConstants' | 'all'
113
+ }
114
+ ```
47
115
 
48
- ## 🏗️ Architecture
116
+ ### JACS proxy mode (recommended)
49
117
 
50
- The SDK is organized into several key modules:
118
+ Browser apps should use `mode: 'proxy'` and forward requests through your own server so JACS credentials never reach the client. The example app ships a Next.js route handler at [`app/api/jacs/[...path]/route.ts`](../mm-web-sdk-example/app/api/jacs/%5B...path%5D/route.ts) that:
51
119
 
52
- ### Core
53
- - `ThemeManager` - Theme switching and management
54
- - `VenueManager` - Venue and building data management
55
- - `JMapCoreWrapper` - JMap functionality integration
120
+ 1. Reads `JACS_HOST`, `JACS_CLIENT_ID`, `JACS_USERNAME`, `JACS_PASSWORD` from server env.
121
+ 2. Exchanges the password grant for a bearer token (cached until expiry).
122
+ 3. Forwards `GET /api/jacs/<path>` to `${JACS_HOST}/JACS/api/<path>` with the token attached.
56
123
 
57
- ### Layers
58
- - `LayerBuilder` - Map layer creation and management
59
- - `AmenityLayer` - Amenity visualization
60
- - `DestinationLayer` - Destination markers
61
- - `PathLayer` - Route visualization
62
- - `MoverLayer` - Moving elements (elevators, escalators)
124
+ Copy that handler into your own backend (or adapt it to your framework) and point `jacs.proxyBaseUrl` at it.
63
125
 
64
- ### Features
65
- - `Wayfinding` - Navigation and routing
66
- - `FeatureHighlighter` - Interactive feature highlighting
67
- - `MarkerManager` - Custom marker management
68
- - `AccessibilityFeatures` - Accessibility enhancements
126
+ ### JACS direct mode
69
127
 
70
- ### Controls
71
- - `FloorSelector` - Floor switching
72
- - `NavigationControl` - Map navigation
73
- - `RecenterControl` - Map recentering
74
- - `MapInspector` - Debugging tools
128
+ For trusted environments (server-rendered pages, Electron kiosks, internal tools) you can call JACS directly:
75
129
 
76
- ### Utils
77
- - `ColorTokens` - Color system
78
- - `PatternGenerator` - Visual patterns
79
- - `IconSelector` - Icon mapping
80
- - `TurfHelpers` - Geospatial utilities
81
- - `GeoJSONFormatter` - Data formatting
130
+ ```ts
131
+ jacs: {
132
+ mode: 'direct',
133
+ host: 'https://jacs.example.com',
134
+ auth: { clientId, username, password },
135
+ }
136
+ ```
82
137
 
83
- ## 🎮 Demo Application
138
+ ## API
84
139
 
85
- ### Next.js Demo
140
+ ### Class `MinuteMaps`
86
141
 
87
- A modern Next.js application showcasing the MinuteMaps SDK with a clean UI and best-practice integration:
142
+ ```ts
143
+ new MinuteMaps(config: SDKConfig)
144
+ sdk.init(): Promise<void>
145
+ sdk.destroy(): void
146
+ sdk.isReady(): boolean
147
+ sdk.getMap(): maplibregl.Map | null
148
+ ```
88
149
 
89
- ```bash
90
- # Navigate to the Next.js demo
91
- cd demo-next
150
+ `createMinuteMapsSDK(config)` is a factory shorthand for `new MinuteMaps(config)`.
92
151
 
93
- # Install dependencies
94
- npm install
152
+ ### Floors
95
153
 
96
- # Start the development server
97
- npm run dev
154
+ ```ts
155
+ sdk.getFloors(): Floor[]
156
+ sdk.getCurrentFloor(): Floor | null
157
+ sdk.getDefaultFloor(): Floor | null
158
+ sdk.setCurrentFloor(floor: Floor): Promise<void>
98
159
  ```
99
160
 
100
- **Features:**
101
- - 🎨 **Theme Management** - Switch between available themes
102
- - 🏢 **Floor Selection** - Navigate between building floors
103
- - 📋 **Layer Controls** - Toggle map layers on/off
104
- - 🎯 **Feature Controls** - Control SDK features and markers
105
- - 🚶 **Wayfinding** - Indoor navigation between destinations
106
- - 📊 **SDK Status** - Real-time status and information
107
- - ⚡ **Quick Actions** - Recenter map and reset view
161
+ ### POIs, destinations, search
108
162
 
109
- ### Development Workflow
163
+ ```ts
164
+ sdk.getAllPOIs(floor?: Floor): POI[]
165
+ sdk.getDestinations(floor?: Floor): Destination[]
166
+ sdk.searchPOIs(query: string, floor?: Floor): POI[]
167
+ sdk.getYouAreHerePOI(floor?: Floor): POI | null
168
+ sdk.getYouAreHereCoordinates(floor?: Floor): [number, number] | null
169
+ ```
110
170
 
111
- For development with live SDK updates:
171
+ ### Amenities (`sdk.amenities`)
112
172
 
113
- ```bash
114
- # From the root directory
115
- npm run demo:react
173
+ ```ts
174
+ sdk.amenities.getAll(): AmenityWithFloor[]
175
+ sdk.amenities.getByFloorId(floorId): AmenityWithFloor[]
176
+ sdk.amenities.getAllKiosks(): AmenityWithFloor[]
177
+ sdk.amenities.getKioskForFloor(floorId): AmenityWithFloor | null
116
178
  ```
117
179
 
118
- This command:
119
- 1. Watches for SDK source changes and rebuilds automatically
120
- 2. Starts the React development server
121
- 3. Provides hot reloading for both SDK and React app
180
+ ### Wayfinding
122
181
 
123
- ## 📚 Documentation
182
+ ```ts
183
+ sdk.navigateFromKioskToDestination(destination): Promise<...>
184
+ sdk.wayfindBetweenWaypoints(from, to, opts?: {
185
+ centerMode?: 'none' | 'destination' | 'route'
186
+ zoom?: number
187
+ }): Promise<...>
188
+ sdk.clearRoute(): void
189
+ ```
124
190
 
125
- Generate comprehensive API documentation with a modern, beautiful interface:
191
+ ### Camera + view modes
126
192
 
127
- ```bash
128
- # Install dependencies
129
- npm install
193
+ ```ts
194
+ sdk.setView({ center?, zoom?, pitch?, bearing?, animate?, duration? })
195
+ sdk.resetView({ animate?, duration? })
196
+ sdk.getCameraPosition(): CameraState | null
130
197
 
131
- # Generate documentation
132
- npm run docs
198
+ sdk.set3dEnabled(enabled) / toggle3d() / getIs3dEnabled()
199
+ sdk.setUnits2dEnabled(enabled) / toggleUnits2d() / getIsUnits2dEnabled()
200
+ sdk.setFlatMode(enabled) / toggleFlatMode() / getIsFlatMode()
201
+ ```
133
202
 
134
- # Generate and preview locally (opens in browser)
135
- npm run docs:preview
203
+ ### MapLibre passthroughs
136
204
 
137
- # Watch for changes
138
- npm run docs:watch
205
+ ```ts
206
+ sdk.addControl(control, position?) // forwards to the underlying MapLibre map
207
+ sdk.getMap() // escape hatch: the raw maplibregl.Map
139
208
  ```
140
209
 
141
- ## 🛠️ Development
210
+ ### Events
142
211
 
143
- ### Building the SDK
212
+ Subscribe with `sdk.on(event, cb)` / unsubscribe with `sdk.off(event, cb)`.
144
213
 
145
- ```bash
146
- # Build the SDK
147
- npm run build
214
+ | Event | Payload | When |
215
+ | --------------- | ----------------------------- | ---------------------------------------------------------- |
216
+ | `ready` | `{ venue }` | Map loaded and the initial floor is rendered. |
217
+ | `floorsLoaded` | `{}` | All floor geojson is available. |
218
+ | `floorChanged` | `{ floor }` | After `setCurrentFloor` resolves. |
219
+ | `cameraChange` | `{ camera: CameraState }` | On every map `move` (drives compass/heading UI). |
220
+ | `error` | `{ error }` | Init or runtime error. |
148
221
 
149
- # Watch for changes and rebuild
150
- npm run build:watch
151
- ```
222
+ ## Sprites
152
223
 
153
- ### Project Structure
224
+ Pass `options.customSprite` as a sprite URL prefix without the extension (MapLibre will append `.json` and `.png` / `@2x`). The example app serves its sprite from [`public/sprites/`](../mm-web-sdk-example/public/sprites/).
154
225
 
226
+ ## Development
227
+
228
+ ```bash
229
+ npm install
230
+ npm run dev:sdk # rollup --watch
231
+ npm run build # clean + production build
232
+ npm run typecheck # tsc --noEmit
155
233
  ```
156
- minutemaps-sdk/
157
- ├── src-sdk/ # SDK source code
158
- ├── dist/ # Built SDK files
159
- ├── demo-next/ # Next.js demo application
160
- ├── docs/ # Generated documentation
161
- ├── docs-assets/ # Documentation assets
162
- └── package.json # Project configuration
163
- ```
164
234
 
165
- ## 📄 License
235
+ The build emits ESM, CJS, and types under `dist/` for both the root entry and the `/react` entry.
236
+
237
+ ## License
166
238
 
167
- This project is licensed under the MIT License - see the LICENSE file for details.
239
+ MIT see [LICENSE](./LICENSE).