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

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,227 @@
1
- # MinuteMaps SDK
1
+ <div align="center">
2
2
 
3
- A comprehensive indoor mapping SDK built with MapLibre GL JS, providing venue management, theming, wayfinding, and interactive features.
3
+ # MinuteMaps Web SDK
4
4
 
5
- ## 🚀 Features
5
+ **Render indoor venues — floors, POIs, amenities, destinations, and wayfinding routes — on top of [MapLibre GL JS](https://maplibre.org/).**
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
+ [![npm](https://img.shields.io/npm/v/@minmaps-dev/mm-web-sdk?label=npm)](https://www.npmjs.com/package/@minmaps-dev/mm-web-sdk)
8
+ [![license](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
9
+ [![types](https://img.shields.io/badge/types-included-blue)](./dist/index.d.ts)
13
10
 
14
- ## 📦 Installation
11
+ </div>
12
+
13
+ `@minmaps-dev/mm-web-sdk` is the official MinuteMaps SDK for the web. It loads venues from JACS, manages floors, POIs, amenities, destinations, and the camera, and gives you a small, well-typed surface for building modern kiosks and indoor mapping web apps.
15
14
 
16
15
  ```bash
17
- npm install minutemaps-sdk
16
+ npm install @minmaps-dev/mm-web-sdk maplibre-gl @turf/turf
18
17
  ```
19
18
 
20
- ## 🎯 Quick Start
19
+ ```ts
20
+ import { MinuteMaps } from '@minmaps-dev/mm-web-sdk'
21
+ import 'maplibre-gl/dist/maplibre-gl.css'
21
22
 
22
- ```javascript
23
- import MinuteMapsSDK from 'minutemaps-sdk';
23
+ const sdk = new MinuteMaps({
24
+ container: 'map',
25
+ jmap: { host: '', customerId: 123, venueId: 456 },
26
+ jacs: { mode: 'proxy', proxyBaseUrl: '/api/jacs' },
27
+ options: { styleMode: 'sdkTemplate' },
28
+ })
24
29
 
25
- // Initialize the SDK
26
- const sdk = new MinuteMapsSDK();
30
+ sdk.on('ready', ({ venue }) => console.log('venue ready', venue?.name))
31
+ await sdk.init()
32
+ ```
27
33
 
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
- });
34
+ ---
37
35
 
38
- // Switch themes
39
- sdk.switchTheme('modern-glassmorph');
40
- ```
36
+ ## Status
41
37
 
42
- ## 🎨 Available Themes
38
+ This SDK is on a pre-1.0 release candidate (`1.0.0-rc.3`). The following capabilities are wired but **dormant pending backend support** — they are not yet functional in the published build:
43
39
 
44
- - **Modern Glassmorph** - Clean, modern design with glass effects
45
- - **Soft Pastel** - Gentle, accessible color palette
46
- - **Accessibility** - High-contrast theme for accessibility
40
+ | Area | Status | Notes |
41
+ | --- | --- | --- |
42
+ | Floors, POIs, amenities, destinations | ✅ Shipped | Loads via JACS `building/full` + `venue/full`. |
43
+ | Camera + view modes (3D/2D/flat) | ✅ Shipped | Style toggles work against the bundled `alt3-hybrid-style.json`. |
44
+ | Venue-served stylesheets | 🚧 Roadmap | SDK currently uses its bundled style; `loadAndPatchVenueStyle()` is bypassed. |
45
+ | Polygon layers + 3D map templates | 🚧 Roadmap | `buildPolygonLayers` / `applyMapTemplate3d` imports are commented in `src/sdk.ts`. |
46
+ | Wayfinding | 🚧 Roadmap | Route renderer is fully built, but the runtime provider is a stub that throws *"Wayfinding is not yet implemented in the SDK"*. |
47
47
 
48
- ## 🏗️ Architecture
48
+ Track re-enable points by grepping `// TODO: Re-enable` in `src/sdk.ts` and `src/data/jacsDataProvider.ts`.
49
49
 
50
- The SDK is organized into several key modules:
50
+ ---
51
51
 
52
- ### Core
53
- - `ThemeManager` - Theme switching and management
54
- - `VenueManager` - Venue and building data management
55
- - `JMapCoreWrapper` - JMap functionality integration
52
+ ## What's in the box
56
53
 
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)
54
+ - **Venue + floors** — load a venue by `customerId` / `venueId`, switch active floor, let the SDK manage layer visibility.
55
+ - **POIs, amenities, destinations** query by floor, run keyword searches, find the kiosk's "You are here" location.
56
+ - **View modes** — toggle 3D extrusion, flat (top-down), and 2D-units modes at runtime.
57
+ - **Camera control** — `setView` / `resetView` / `getCameraPosition`, plus a live `cameraChange` event for compass UIs.
58
+ - **React entrypoint** — drop-in `<MinuteMapsView />` for React 18/19.
59
+ - **JACS proxy or direct mode** — keep credentials server-side (recommended) or call JACS directly from trusted environments.
63
60
 
64
- ### Features
65
- - `Wayfinding` - Navigation and routing
66
- - `FeatureHighlighter` - Interactive feature highlighting
67
- - `MarkerManager` - Custom marker management
68
- - `AccessibilityFeatures` - Accessibility enhancements
61
+ ---
69
62
 
70
- ### Controls
71
- - `FloorSelector` - Floor switching
72
- - `NavigationControl` - Map navigation
73
- - `RecenterControl` - Map recentering
74
- - `MapInspector` - Debugging tools
63
+ ## Documentation
75
64
 
76
- ### Utils
77
- - `ColorTokens` - Color system
78
- - `PatternGenerator` - Visual patterns
79
- - `IconSelector` - Icon mapping
80
- - `TurfHelpers` - Geospatial utilities
81
- - `GeoJSONFormatter` - Data formatting
65
+ The lean root README intentionally stops here. For depth, see:
82
66
 
83
- ## 🎮 Demo Application
67
+ - [`docs/ARCHITECTURE.md`](./docs/ARCHITECTURE.md) module map, init flow, JACS data path, style patching, dormant 3D notes.
68
+ - [`docs/API.md`](./docs/API.md) — full public API surface grouped by lifecycle, floors, POIs, amenities, wayfinding, camera, events.
69
+ - [`docs/KIOSK.md`](./docs/KIOSK.md) — kiosk integration patterns (You-Are-Here, kiosk-to-destination wayfinding once enabled, view-mode UX, sprite hosting, idle reset).
84
70
 
85
- ### Next.js Demo
71
+ External integrators will usually only need the [API](./docs/API.md) and [Kiosk](./docs/KIOSK.md) docs. Internal MTS engineers should also read [Architecture](./docs/ARCHITECTURE.md) before touching `src/sdk.ts` or the JACS provider.
86
72
 
87
- A modern Next.js application showcasing the MinuteMaps SDK with a clean UI and best-practice integration:
73
+ ---
88
74
 
89
- ```bash
90
- # Navigate to the Next.js demo
91
- cd demo-next
75
+ ## Quick start (vanilla)
92
76
 
93
- # Install dependencies
94
- npm install
77
+ ```ts
78
+ import { MinuteMaps } from '@minmaps-dev/mm-web-sdk'
79
+ import 'maplibre-gl/dist/maplibre-gl.css'
80
+
81
+ const sdk = new MinuteMaps({
82
+ container: 'map', // element or element id
83
+ jmap: {
84
+ host: '', // unused in proxy mode
85
+ customerId: 123,
86
+ venueId: 456,
87
+ },
88
+ jacs: {
89
+ mode: 'proxy', // recommended for browser apps
90
+ proxyBaseUrl: '/api/jacs',
91
+ },
92
+ options: {
93
+ customSprite: '/sprites/sprite', // your icon sprite (no extension)
94
+ minIndoorZoom: 16,
95
+ debug: true,
96
+ styleMode: 'sdkTemplate',
97
+ },
98
+ })
99
+
100
+ sdk.on('ready', ({ venue }) => console.log('venue ready', venue?.name))
101
+ sdk.on('floorChanged', ({ floor }) => console.log('now showing', floor?.name))
95
102
 
96
- # Start the development server
97
- npm run dev
103
+ await sdk.init()
98
104
  ```
99
105
 
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
106
+ ## Quick start (React)
107
+
108
+ ```tsx
109
+ import { MinuteMapsView } from '@minmaps-dev/mm-web-sdk/react'
110
+ import 'maplibre-gl/dist/maplibre-gl.css'
111
+
112
+ export function Map() {
113
+ return (
114
+ <MinuteMapsView
115
+ className="h-screen w-screen"
116
+ config={{
117
+ container: '', // ignored — the component owns the element
118
+ jmap: { host: '', customerId: 123, venueId: 456 },
119
+ jacs: { mode: 'proxy', proxyBaseUrl: '/api/jacs' },
120
+ options: { styleMode: 'sdkTemplate' },
121
+ }}
122
+ />
123
+ )
124
+ }
125
+ ```
108
126
 
109
- ### Development Workflow
127
+ The React entry is intentionally minimal: it owns its own `<div>`, calls `init()` on mount, and `destroy()` on unmount. Reach for the vanilla `MinuteMaps` class when you need imperative control (floor switching from a side panel, camera animations driven by Redux, etc.).
110
128
 
111
- For development with live SDK updates:
129
+ ---
112
130
 
113
- ```bash
114
- # From the root directory
115
- npm run demo:react
131
+ ## Configuration at a glance
132
+
133
+ ```ts
134
+ type SDKConfig = {
135
+ container: HTMLElement | string
136
+ jmap: {
137
+ host: string
138
+ customerId: number
139
+ venueId: number
140
+ locale?: string
141
+ auth?: { clientId: string; clientSecret: string }
142
+ }
143
+ jacs: {
144
+ mode: 'proxy' | 'direct'
145
+ host?: string // 'direct' only
146
+ auth?: { clientId: string; username: string; password: string } // 'direct' only
147
+ proxyBaseUrl?: string // default '/api/jacs'
148
+ }
149
+ options?: SDKOptions
150
+ }
116
151
  ```
117
152
 
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
153
+ Full option reference and an annotated `SDKOptions` shape live in [`docs/API.md`](./docs/API.md#configuration).
122
154
 
123
- ## 📚 Documentation
155
+ ### JACS proxy mode (recommended)
124
156
 
125
- Generate comprehensive API documentation with a modern, beautiful interface:
157
+ Browser apps should use `mode: 'proxy'` and forward requests through your own server so JACS credentials never reach the client. Your proxy should:
126
158
 
127
- ```bash
128
- # Install dependencies
129
- npm install
159
+ 1. Read `JACS_HOST`, `JACS_CLIENT_ID`, `JACS_USERNAME`, `JACS_PASSWORD` from server env.
160
+ 2. Exchange the password grant for a bearer token (cache until expiry).
161
+ 3. Forward `GET /api/jacs/<path>` to `${JACS_HOST}/JACS/api/<path>` with the token attached.
162
+
163
+ A reference Next.js route handler ships in the example app at `mm-web-sdk-example/app/api/jacs/[...path]/route.ts`. Copy it into your own backend or adapt it to your framework, then point `jacs.proxyBaseUrl` at it.
130
164
 
131
- # Generate documentation
132
- npm run docs
165
+ ### JACS direct mode
133
166
 
134
- # Generate and preview locally (opens in browser)
135
- npm run docs:preview
167
+ For trusted environments server-rendered pages, Electron kiosks, internal tools — call JACS directly:
136
168
 
137
- # Watch for changes
138
- npm run docs:watch
169
+ ```ts
170
+ jacs: {
171
+ mode: 'direct',
172
+ host: 'https://jacs.example.com',
173
+ auth: { clientId, username, password },
174
+ }
139
175
  ```
140
176
 
141
- ## 🛠️ Development
177
+ > Never ship `direct` mode to a public browser bundle. Your JACS credentials would be visible to anyone with devtools.
142
178
 
143
- ### Building the SDK
179
+ ---
144
180
 
145
- ```bash
146
- # Build the SDK
147
- npm run build
181
+ ## Sprites
148
182
 
149
- # Watch for changes and rebuild
150
- npm run build:watch
151
- ```
183
+ `options.customSprite` is a sprite URL **prefix without extension** — MapLibre appends `.json` and `.png` (and `@2x` variants) automatically. The example app serves its sprite from `mm-web-sdk-example/public/sprites/`.
152
184
 
153
- ### Project Structure
185
+ ---
154
186
 
187
+ ## Development
188
+
189
+ ```bash
190
+ npm install
191
+ npm run dev:sdk # rollup --watch (rebuilds dist/ on change)
192
+ npm run build # rimraf dist + production rollup build
193
+ npm run typecheck # tsc --noEmit
194
+ npm test # vitest run
195
+ npm run test:watch # vitest in watch mode
196
+ npm run test:coverage # vitest run --coverage (v8 provider)
155
197
  ```
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
198
 
165
- ## 📄 License
199
+ The build emits ESM, CJS, and types under `dist/` for both the root entry and the `/react` entry. Tests live in `tests/` and target the three highest-leverage modules: `JacsProvider`, `WayfindingManager`, and `ViewModeController`. Coverage thresholds are gated in `vitest.config.ts` (currently 60% lines/funcs/stmts, 50% branches).
200
+
201
+ ### Continuous integration
202
+
203
+ Two workflows in `.github/workflows/`:
204
+
205
+ - **`ci.yml`** — runs typecheck, vitest with coverage, and the production build on every push and pull request to `main` / `dev`. Coverage and `dist/` are uploaded as artifacts.
206
+ - **`publish.yml`** — runs on tags matching `v*` (or via manual dispatch). Verifies the tag matches `package.json` version, runs the full pipeline, and publishes to npm with provenance. Requires an `NPM_TOKEN` repo secret.
207
+
208
+ > **Internal note:** future Claude sessions get oriented from [`CLAUDE.md`](./CLAUDE.md). Repo-local subagents in [`.claude/agents/`](./.claude/agents/) cover API doc sync, release notes, and style/template edits.
209
+
210
+ ---
211
+
212
+ ## Browser + framework support
213
+
214
+ | Target | Version |
215
+ | --- | --- |
216
+ | Node (build/dev) | ≥ 18 |
217
+ | `maplibre-gl` | ^4 |
218
+ | `@turf/turf` | ^7 |
219
+ | `react` / `react-dom` | ^18 or ^19 (only required for `/react` entry) |
220
+
221
+ Modern evergreen browsers. Kiosk targets are typically pinned Chromium builds — if you need to support a specific minimum, open an issue.
222
+
223
+ ---
224
+
225
+ ## License
166
226
 
167
- This project is licensed under the MIT License - see the LICENSE file for details.
227
+ MIT see [LICENSE](./LICENSE).