@focusbc/bbs-lib
v0.0.5
Published
BBS map rendering library (deck.gl + @focusbc/map-rendering)
Readme
@focusbc/bbs-lib
TypeScript library wrapping deck.gl and @focusbc/map-rendering for BBS map rendering.
The library exposes a high-level MapOverlay API that receives the BBS map context returned by the integration API and renders the corresponding static and dynamic map layers.
Installation
The package is published to npm under the @focusbc scope.
# Using yarn
yarn add @focusbc/bbs-lib
# Using npm
npm install @focusbc/bbs-libBecause this package depends on @focusbc/map-rendering and deck.gl, consumers should use compatible deck.gl versions with the ones declared by the package.
Usage
<div id="map-overlay" style="position: relative; width: 100%; height: 100%;"></div>import { MapOverlay, type MapContext } from '@focusbc/bbs-lib'
const context: MapContext = {
// Context returned by the BBS/integration API
}
const overlay = MapOverlay.initialize(document.getElementById('map-overlay')!, context)
overlay.click().subscribe(({ shape, lat, lng }) => {
console.log('left click', { shape, lat, lng })
})
overlay.doubleClick().subscribe(({ shape, lat, lng }) => {
console.log('double click', { shape, lat, lng })
})
overlay.rightClick().subscribe(({ shape, lat, lng }) => {
console.log('right click', { shape, lat, lng })
})
// Later, when the event/site changes:
overlay.setContext(newContext)Development
Install dependencies and build the library from the bbs-lib/ directory:
yarn install
yarn buildFrom the repository root you can also run:
yarn bbs-lib buildThe build output is generated under dist/. Only dist/**/* and this README are included in the published npm package. The demo/ and sandbox/ folders are not published (see package.json "files" and .npmignore).
Sandbox (local manual testing)
A small static page under sandbox/ can be used to test MapOverlay against the integration API BBS endpoints. Unlike demo/, the sandbox bundles the local library source from this repo.
Copy
sandbox/config.example.tstosandbox/config.tsand set:INTEGRATION_API_BASE— for example,http://localhost:5016BBS_API_KEY— must matchSettings.BbsApiKeyin your local integration-api config
Start
integration-apilocally.Build and serve the sandbox:
cd bbs-lib
yarn install
yarn sandbox:build
npx --yes serve sandbox -p 5173For continuous rebuild on save:
yarn sandbox:watchOpen http://localhost:5173, select an event, then a site. The overlay calls MapOverlay.initialize on first site selection and setContext on subsequent changes.
Client demo
The client-facing reference implementation lives in demo/. It is a static site (index.html + main.js) with no build step. See demo/README.md.
From this directory:
yarn demo:serveOr from the repository root:
yarn bbs-demo:serveTo run the demo folder on its own, serve it statically — for example npx --yes serve . -p 5174 from demo/.
Releasing the library
The release process is handled by bbs-lib/scripts/release-lib.sh and can be started from inside bbs-lib/:
yarn release:libBy default, this performs a patch release, for example 1.0.0 → 1.0.1.
You can also choose the version bump explicitly:
yarn release:lib patch
yarn release:lib minor
yarn release:lib majorFrom the repository root, the equivalent command is:
yarn release:bbs-libRelease prerequisites
- You must have access to publish
@focusbc/bbs-libunder the@focusbcnpm scope. - You must have the Google Cloud CLI installed and authenticated.
- Your Google Cloud user must be able to decrypt/encrypt with the existing KMS key used by
auxiliary/scripts/decrypt_file.shandauxiliary/scripts/encrypt_file.sh. bbs-lib/.npmrc.encmust exist. This is the encrypted version of the npm credentials file and is the only credential file that should be committed.
What happens during release
When you run yarn release:lib, the script:
- Decrypts
bbs-lib/.npmrc.encinto a temporary localbbs-lib/.npmrc. - Bumps
package.jsonusingnpm version <patch|minor|major> --no-git-tag-version. - Builds the package with
npm run build. - Publishes the package to
https://registry.npmjs.org/withnpm publish --access public. - Uploads
dist/browser/bbs-lib.jsto Cloud Storage atgs://bbs-lib-bucket/bbs-lib(override withBBS_LIB_BUCKET_URIorBBS_LIB_BUCKET). - Re-encrypts the temporary
.npmrcback into.npmrc.enc. - Removes the plaintext
.npmrcfrom disk.
If the release fails after the version bump, review package.json before retrying because the version may already have been changed locally.
