GeoXp Web is a library that unifies four essential packages — Core, Web Audio, Web Geolocation, and Web Storage — into a single, easy-to-use package.
It is designed to simplify the initialization and management of these tools for developers working in web environments.
# install using npm
npm install @geoxp/web
# or using yarn
yarn add @geoxp/web
GeoXp Core, Web-Audio, Web-Geolocation, and Web-Storage into one convenient library.core, audio, geolocation, storage). Refer to the respective package documentation for specific configuration options.core, audio, geolocation, and storage properties.GeoXp Web is intended for usage as a singleton instance. It has to be created once the application starts, based on a configuration object.
import GeoXpWeb from '@geoxp/web';
const config = {
core: { /* configuration for GeoXp Core */ },
audio: { /* configuration for Web Audio */ },
geolocation: { /* configuration for Web Geolocation */ },
storage: { /* configuration for Web Storage */ },
};
const geoXp = new GeoXpWeb(config);
As default behavior, when GeoXp Web instance is reloaded (eg: page refresh) exprience patterns memory of visited spots is cleared. This can be avoided enabling storage package.
To enable the storage package you can either pass storage: true to use default configuration or provide a custom config.
See Web Storage package docs for further config details.
// disabled storage
const noStorageConfig = {
core: { },
audio: { },
geolocation: { },
};
// enabled storage with default config
const defaultStorageConfig = {
core: { },
audio: { },
geolocation: { },
storage: true,
};
// enabled storage with custom config
const customStorageConfig = {
core: { },
audio: { },
geolocation: { },
storage: {
cookiePrefix: 'my-geoxp-experience',
deleteOnLastSpot: false, // clear storage when last spot is visited
deleteOnCompletion: true, // clear storage when all spots have been visited
expiration: 10, // expiration [minutes] - deafult 5
},
};
❗ Please note that when cookies expire they are deleted, but no change is made runtime to the current geoXp visited spots. To let the experience to restart, a reload or page refresh is needed.
GeoXpWeb, once created, works without any external intervention. To provide this high level of automation, it has to be accurately configured according to the desired application. The configuration respects each of the four packages specific configurations (see their docs for details).
// Refreshes all GeoXpWeb state with the given configuration
geoXp.reload(config);
Once initialized, you can directly interact with any of the included package instances APIs. For example:
// Disables specific pattern
geoXp.core.disablePattern(patternId: string);
// Immediately stops all audio currently playing
geoXp.audio.stopAll();
// Enables / disables geolocation updates
geoXp.geolocation.toggleUpdates();
GeoXp Web provides event management interfaces to handle specific events across the integrated packages. For example:
geoXp.on('active', (spot: GeoXpSpot) => { /* ... */ })
geoXp.on('playing', (sound: GeoXpWebAudioSound) => { /* ... */ })
geoXp.on('location', (location: GeoXpGeolocation) => { /* ... */ })
To contribute to this project, fork the repository, work on a development branch and open a MR. Remember to update the changelog (CHANGELOG.md)!
For repo admins To release a new version, follow these steps:
- verify and test changes
- verify changelog has been updated
- merge MR in
main- publish a new version
- create a new release in the release section