becomap-v2 2.0.0-alpha.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/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2026 beCoMap
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
+ PERFORMANCE OF THIS SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,119 @@
1
+ # becomap-v2
2
+
3
+ High-performance indoor mapping and navigation SDK — a MapLibre GL basemap paired with a single unified Three.js layer that renders all 3D (floor plates, walls, extruded units, labels, routes).
4
+
5
+ > ⚠️ **ALPHA — `2.0.0-alpha.0`.** This is an early pre-release of the beCoMap v2 rewrite. The public API may change between alpha releases without a major version bump. Pin an exact version if you depend on it.
6
+ > The stable v1 SDK is published separately on npm as [`becomap`](https://www.npmjs.com/package/becomap) — this package does **not** replace it yet.
7
+
8
+ ## Requirements
9
+
10
+ - A browser with **WebGL2**: evergreen desktop and mobile browsers, plus Chromium-based kiosks.
11
+ - **Node.js >= 20** if you are building from source or bundling the ESM entry point.
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ npm install becomap-v2
17
+ ```
18
+
19
+ `maplibre-gl` and `three` are **peer dependencies** and are not bundled. Install them explicitly:
20
+
21
+ ```bash
22
+ npm install maplibre-gl@^4.4.1 three@^0.172.0
23
+ ```
24
+
25
+ ## Quick start (ESM / bundler)
26
+
27
+ The map needs a container element with an explicit height — it will not size itself:
28
+
29
+ ```html
30
+ <div id="map" style="width: 100%; height: 100vh"></div>
31
+ ```
32
+
33
+ ```ts
34
+ import 'maplibre-gl/dist/maplibre-gl.css';
35
+ import { createMap, RestVenueProvider } from 'becomap-v2';
36
+
37
+ const map = createMap(document.getElementById('map')!, {
38
+ center: [77.1062539422262, 28.642350800253993],
39
+ zoom: 16.6,
40
+ pitch: 45,
41
+ venue: {
42
+ provider: new RestVenueProvider({
43
+ baseUrl: 'https://your-backend.example.com',
44
+ siteId: 'your-site-id',
45
+ clientId: 'your-client-id',
46
+ clientSecret: 'your-client-secret',
47
+ }),
48
+ },
49
+ });
50
+
51
+ map.on('load', async () => {
52
+ // Fetches + parses the venue (REST metadata + protobuf binaries).
53
+ const stats = await map.venue.load(); // { buildings, floors, locations, shapes }
54
+ console.log(stats);
55
+
56
+ const building = map.venue.current()?.buildings[0];
57
+ const ground = building?.floors[0];
58
+ if (ground) map.floors.select(ground.id);
59
+ });
60
+
61
+ map.on('error', (e) => console.error(e.message, e.cause));
62
+ ```
63
+
64
+ ## Script tag (UMD)
65
+
66
+ The UMD bundle does **not** contain `maplibre-gl` or `three` — they are consumed as external globals, so both must be loaded **first** as `maplibregl` and `THREE`:
67
+
68
+ ```html
69
+ <link rel="stylesheet" href="https://unpkg.com/maplibre-gl@4.7.1/dist/maplibre-gl.css" />
70
+ <script src="https://unpkg.com/maplibre-gl@4.7.1/dist/maplibre-gl.js"></script>
71
+ <script src="https://unpkg.com/three@0.172.0/build/three.min.js"></script>
72
+ <script src="https://unpkg.com/becomap-v2@2.0.0-alpha.0/dist/becomap.umd.js"></script>
73
+
74
+ <div id="map" style="width: 100%; height: 100vh"></div>
75
+
76
+ <script>
77
+ // The bundle exposes the global `becomap`.
78
+ const map = becomap.createMap(document.getElementById('map'), {
79
+ center: [77.1062539422262, 28.642350800253993],
80
+ zoom: 16.6,
81
+ pitch: 45,
82
+ venue: {
83
+ provider: new becomap.RestVenueProvider({
84
+ baseUrl: 'https://your-backend.example.com',
85
+ siteId: 'your-site-id',
86
+ clientId: 'your-client-id',
87
+ clientSecret: 'your-client-secret',
88
+ }),
89
+ },
90
+ });
91
+
92
+ map.on('load', async () => {
93
+ await map.venue.load();
94
+ });
95
+ </script>
96
+ ```
97
+
98
+ ## API surface
99
+
100
+ Exported from the package root:
101
+
102
+ - `createMap(container, options)` — the only factory; returns a `BecoMap` instance. No default export, no module-level state.
103
+ - `RestVenueProvider` — loads a real venue from the beCoMap backend (REST metadata + protobuf binaries).
104
+ - `MockVenueProvider` — a synthetic venue for trying the SDK, tests, and local development **with no backend or credentials**.
105
+ - `Venue` / `buildVenue` — the parsed venue model and its builder, for custom data providers.
106
+ - Types: `BecoMap`, `BecoMapOptions`, `VenueProvider`, `VenueData`, `VenueStats`, `Building`, `Floor`, `VenueLocation`, `Shape`, `Category`, `GraphNode`, `GraphEdge`, `RouteStep`, `NavStepInfo`, `PolygonThemeName`, and the facade interfaces.
107
+
108
+ Reachable off the map instance:
109
+
110
+ - `map.venue` — load the venue, read the current `Venue`.
111
+ - `map.floors` — list floors, `select(floorId)`, read the active floor.
112
+ - `map.search` — query locations and categories.
113
+ - `map.routing` — compute and display routes, turn-by-turn steps.
114
+ - `map.camera` — programmatic camera control (center, zoom, pitch, bearing, fit).
115
+ - `map.on(event, handler)` / `map.off(event, handler)` — event API (`'load'`, `'error'`, and the rest of `BecoMapEvents`).
116
+
117
+ ## License
118
+
119
+ [ISC](./LICENSE)