npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sitech-me/mobile-route-map

v0.1.6

Published

Framework-agnostic web component: live trip route map with status card (Mapbox GL). Works in React, Angular, Vue, or plain HTML.

Readme

@sitech-me/mobile-route-map

A single, framework-agnostic web component (<mobile-route-map>) that renders the live trip-tracking map + status card. Same UI, same CSS, same icons as the original Vue component — now usable from React, Angular, Vue, or plain HTML via one npm package, with one build output. Everything is bundled in: Mapbox GL, Moment, Socket.IO client, Lit — nothing extra for the consuming app to install.

1. Swap in your real assets, then build

src/assets/icons/garage.png            <- garage marker icon
src/assets/icons/watersourceicon.png   <- water-source marker icon
src/assets/icons/watersource.png       <- "completed" card icon
src/assets/icons/homeicon.png          <- drop-off marker icon
src/assets/icons/tanker.png            <- truck marker icon
src/assets/icons/tanker2.svg           <- truck illustration on the status card
src/locales/en.json, src/locales/ar.json <- full translation strings

Everything currently in those files is a placeholder (solid colored circles / a minimal SVG box) so the build runs end-to-end. Drop your real files in at the same paths and filenames, then:

npm install
npm run build

This produces dist/mobile-route-map.js (ESM) and dist/style.css.

2. Publish

npm login
npm publish --access public

(Rename @sitech-me/mobile-route-map in package.json to your actual npm scope/org first, and update the repository field to your GitHub URL.)

Push the source to your repo as usual — dist/ can either be committed or built by CI on release; either is fine, just make sure npm run build runs before npm publish (the prepublishOnly script already does this for you).

3. One required global CSS import

Mapbox GL needs its own base stylesheet (for controls, attribution, etc.) loaded once, globally — Vite extracts it to dist/style.css at build time. Import it once anywhere in your app's entry point:

import '@sitech-me/mobile-route-map/style.css'

Everything else (the modal, status card, markers) is scoped inside the component's Shadow DOM and needs no separate import.

4. Use it — plain HTML / Vue

<script type="module">
  import '@sitech-me/mobile-route-map'
</script>

<mobile-route-map id="map" mapbox-token="pk.xxx" lang="ar"></mobile-route-map>

<script type="module">
  const el = document.getElementById('map')
  el.tripData = { /* same shape as the old `data` prop */ }
  el.fetchRoute = (tripId) => fetch(`/api/trip-route/${tripId}?type=mobile`).then(r => r.json())
  el.fetchGarageEnums = () => fetch('/api/garage-enums').then(r => r.json())
  el.socket = mySocketIoClientInstance // optional, for live GPS updates
  el.addEventListener('close', () => console.log('closed'))
  el.show()
</script>

5. Use it — React

React apps can use the custom element directly (React 19+ passes props/attributes straight through to custom elements). If you want idiomatic props/callbacks instead of managing DOM refs and events by hand, copy examples/react/MobileRouteMap.jsx into your React project's source — it's plain JSX, compiled by your app's own build tool (Vite/webpack/CRA/etc.), so there's no separate package build step or version mismatch to worry about.

import { MobileRouteMap } from './MobileRouteMap' // the file you copied in
import { useRef, useState } from 'react'

function TripMap({ trip }) {
  const [open, setOpen] = useState(true)
  const mapRef = useRef(null)

  return (
    <MobileRouteMap
      ref={mapRef}
      open={open}
      tripData={trip}
      mapboxToken="pk.xxx"
      lang="ar"
      fetchRoute={(tripId) => fetch(`/api/trip-route/${tripId}?type=mobile`).then(r => r.json())}
      fetchGarageEnums={() => fetch('/api/garage-enums').then(r => r.json())}
      onClose={() => setOpen(false)}
      onBack={() => console.log('back pressed')}
    />
  )
}

6. Use it — Angular

Angular can talk to custom elements natively — no wrapper package needed, just allow unknown elements and set properties via a template ref.

// app.module.ts
import '@sitech-me/mobile-route-map'
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core'

@NgModule({
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  // ...
})
export class AppModule {}
<!-- trip-map.component.html -->
<mobile-route-map #map mapbox-token="pk.xxx" lang="ar"
                   (close)="onClose()"></mobile-route-map>
// trip-map.component.ts
import { AfterViewInit, ViewChild, ElementRef, Input } from '@angular/core'

export class TripMapComponent implements AfterViewInit {
  @ViewChild('map') mapRef!: ElementRef<any>
  @Input() trip: any

  ngAfterViewInit() {
    const el = this.mapRef.nativeElement
    el.tripData = this.trip
    el.fetchRoute = (tripId: string) =>
      fetch(`/api/trip-route/${tripId}?type=mobile`).then((r) => r.json())
    el.fetchGarageEnums = () => fetch('/api/garage-enums').then((r) => r.json())
    el.show()
  }
}

API reference

| Property / attribute | Type | Notes | |---|---|---| | mapbox-token | string attr | required | | .tripData | object property | same shape as the old Vue data prop | | lang | "ar" | "en" attr | default "ar" | | route-endpoint | string attr | default /api/trip-route, used if .fetchRoute isn't set | | garage-enums-endpoint | string attr | default /api/garage-enums, used if .fetchGarageEnums isn't set | | .fetchRoute(tripId) | function property | override the default fetch call | | .fetchGarageEnums() | function property | override the default fetch call | | .socket | property | an already-connected socket.io-client instance, for live GPS | | .show() | method | open the modal | | .close() | method | close the modal | | .applyTripStatusUpdate(update) | method | call when your app's own store/socket gets a trip-status push (replaces the old Vuex watcher) | | close / back / toggle-stats | events | CustomEvent, bubbling |

What changed vs. the original Vue component

  • BootstrapVue <b-modal> → a plain overlay div, driven by .show()/.close().
  • Vuex state.update_trip_status watcher → public applyTripStatusUpdate() method you call from wherever your app now receives that push.
  • The hard-coded TripRouteService / enums/GET_GARAGE_ENUMS store call → configurable fetchRoute / fetchGarageEnums (default to plain fetch against route-endpoint / garage-enums-endpoint, override with your real API client).
  • socket singleton import → an optional .socket property you pass in.
  • this.$t(...) → a small built-in en.json / ar.json dictionary — extend these with your full translation set.
  • Everything else — Mapbox logic, coordinate-normalization/GPS-snapping/Directions-API fallback, marker/status-card structure, all CSS — is a straight 1:1 port.

Known constraint

Mapbox GL renders its canvas into the Shadow DOM container; this works in all modern browsers but if you see any rendering quirks in a specific target browser, they're almost always solvable by adjusting the container sizing — flag it and it can be tuned per-project.