Gospel x Internet takes the host's token the way the production maps do

profile-config tk, then the token ProfileLoader provides (a tokenUrl
token-service answer or the page's shared token), then window.MAP_TOKEN.
It read only the first and last, so a host using tokenUrl got no Mapbox
token on either of the board's maps.
This commit is contained in:
Doxa Maps 2026-09-27 05:23:01 +00:00
parent 91c3714348
commit 0c852d2572
13 changed files with 37 additions and 33 deletions

View file

@ -25,7 +25,7 @@ export function readerLang(profileConfig) {
/**
* @returns {Promise<{ map, provider } | { error: string, provider }>} resolves once the style has loaded
*/
export async function createBoardMap(el, profileConfig, { center = [60, 20], zoom = 1.4, whiteboard = false, boundaries = true, background = '#f3f3f1' } = {}) {
export async function createBoardMap(el, profileConfig, { center = [60, 20], zoom = 1.4, whiteboard = false, boundaries = true, background = '#f3f3f1', token = '' } = {}) {
const provider = resolveMapProvider(profileConfig)
try { await ensureEngineScript(provider) } catch (_) { /* reported below */ }
const gl = engineGlobal(provider)
@ -34,7 +34,9 @@ export async function createBoardMap(el, profileConfig, { center = [60, 20], zoo
const css = engineStylesheetUrl(provider)
if (css) await ensureEngineCSS(el, css)
const lang = readerLang(profileConfig)
const tk = profileConfig?.tk || (typeof window !== 'undefined' && window.MAP_TOKEN) || ''
// The host's token by the same ladder the production maps use: profile-config tk, then the token
// ProfileLoader provides (a tokenUrl token-service answer, or the page's shared token), then the page global.
const tk = profileConfig?.tk || token || (typeof window !== 'undefined' && window.MAP_TOKEN) || ''
const map = new gl.Map({
container: el,
style: resolveNamedStyle('paper', provider).style || 'mapbox://styles/mapbox/light-v11',

View file

@ -20,7 +20,7 @@
* HONESTY: a pin marks where a people is found within a country, not a town (the legend says so, and
* how many share a point); the band is the COUNTRY's figure; a state's NFHS-5 figure is the state's.
*/
import { ref, shallowRef, computed, watch, onMounted, onBeforeUnmount, markRaw } from 'vue'
import { ref, shallowRef, computed, watch, onMounted, onBeforeUnmount, markRaw, inject } from 'vue'
import { resolveAssetsBase } from '@map/utils/embedBase.js'
import { useShadowStyles } from '@map/composables/useShadowStyles.js'
import MapToolbar from '@map/components/map-controls/MapToolbar.vue'
@ -35,6 +35,7 @@ import { ACCESS_DETAILS, BANDS, DETAIL_FILL, DETAIL_RIM, BAND_COLOR, label } fro
const T = useGiT()
const board = useBoardState()
const { bus } = board
const injectedToken = inject('mapboxToken', null) // tokenUrl / shared page token, via ProfileLoader
const mapEl = ref(null)
const mapRef = shallowRef(null)
@ -275,7 +276,7 @@ onMounted(async () => {
}).catch(() => { adm1Table = null })
try {
if (!mapEl.value) return
const made = await createBoardMap(mapEl.value, board.profileConfig.value)
const made = await createBoardMap(mapEl.value, board.profileConfig.value, { token: injectedToken?.value || '' })
if (made.error) { err.value = T('messages.engineMissing', `The ${made.error} map engine did not load.`, { engine: made.error }); return }
const map = made.map
if (unmounted) { try { map.remove() } catch (_) {} return }

View file

@ -19,7 +19,7 @@
* the bus's one predicate); a hovered grid row points at its language's node (hover never moves the
* camera); a committed selection frames its languages once, and jumps under reduced motion.
*/
import { ref, shallowRef, computed, watch, onMounted, onBeforeUnmount, markRaw } from 'vue'
import { ref, shallowRef, computed, watch, onMounted, onBeforeUnmount, markRaw, inject } from 'vue'
import { useShadowStyles } from '@map/composables/useShadowStyles.js'
import { labelFont } from '@map/maps/label-font.js'
import MapToolbar from '@map/components/map-controls/MapToolbar.vue'
@ -33,6 +33,7 @@ import { treeScope, TREE_COLOR } from '../model.js'
const T = useGiT()
const board = useBoardState()
const { bus } = board
const injectedToken = inject('mapboxToken', null) // tokenUrl / shared page token, via ProfileLoader
const el = ref(null)
const mapRef = shallowRef(null)
@ -208,7 +209,7 @@ function frame(coords) {
async function build() {
const t = await board.loadTree()
if (unmounted || !el.value || mapRef.value) return
const made = await createBoardMap(el.value, board.profileConfig.value, { whiteboard: true, boundaries: false, center: [0, 0], zoom: 1 })
const made = await createBoardMap(el.value, board.profileConfig.value, { whiteboard: true, boundaries: false, center: [0, 0], zoom: 1, token: injectedToken?.value || '' })
if (made.error) { err.value = T('messages.engineMissing', `The ${made.error} map engine did not load.`, { engine: made.error }); return }
if (unmounted) { try { made.map.remove() } catch (_) {} return }
const map = made.map

View file

@ -578,7 +578,7 @@
"bundle": "gospel-internet",
"scriptUrl": "./gospel-internet/gospel-internet.js",
"output": "dx-maps/gospel-internet/gospel-internet.js",
"integrity": "sha384-NVgxHdVCb5aUY7aSYhuffQ3upM9FZCTOVLq80etKnDXCr8ZnVlhgmeu/FNwo/0ld",
"integrity": "sha384-7OLwBf2bK1Szc8ISMHusFv6dZkvimSiZdBtnCIsRCMZtVnMbBe1KaZ96OvXbu37e",
"elements": [
"gospel-internet-board"
],
@ -594,7 +594,7 @@
"scriptUrl": "./gospel-internet/gospel-internet.js",
"embed": {
"iframe": "<iframe src=\"./gospel-internet/board/index.html?utm_source=YOUR_SOURCE\" width=\"100%\" height=\"600\" style=\"border:none;border-radius:12px;\" allowfullscreen></iframe>",
"script": "<!-- Mapbox engine, fetched early. Keep it only with a real Mapbox token in \"tk\": without one (or with \"provider\":\"maplibre\") the map draws with MapLibre and this line must go -->\n<link rel=\"preload\" as=\"script\" href=\"https://api.mapbox.com/mapbox-gl-js/v3.24.0/mapbox-gl.js\" integrity=\"sha384-tO0clamXONKwbiz7O6xJpUeyJbTSPugC+xM9clvfFvKTH3i8SmCawHGdf5quMWmZ\" crossorigin=\"anonymous\">\n<script>window.MAP_APP_API_URL=\"https://pray.doxa.life\";</script>\n<script src=\"./gospel-internet/gospel-internet.js\" integrity=\"sha384-NVgxHdVCb5aUY7aSYhuffQ3upM9FZCTOVLq80etKnDXCr8ZnVlhgmeu/FNwo/0ld\" crossorigin=\"anonymous\"></script>\n<gospel-internet-board profile-config='{\"profile\":\"board\",\"tk\":\"YOUR_MAPBOX_TOKEN\",\"utmSource\":\"YOUR_SOURCE\",\"assetsBase\":\"YOUR_TREE_URL/assets\"}'></gospel-internet-board>"
"script": "<!-- Mapbox engine, fetched early. Keep it only with a real Mapbox token in \"tk\": without one (or with \"provider\":\"maplibre\") the map draws with MapLibre and this line must go -->\n<link rel=\"preload\" as=\"script\" href=\"https://api.mapbox.com/mapbox-gl-js/v3.24.0/mapbox-gl.js\" integrity=\"sha384-tO0clamXONKwbiz7O6xJpUeyJbTSPugC+xM9clvfFvKTH3i8SmCawHGdf5quMWmZ\" crossorigin=\"anonymous\">\n<script>window.MAP_APP_API_URL=\"https://pray.doxa.life\";</script>\n<script src=\"./gospel-internet/gospel-internet.js\" integrity=\"sha384-7OLwBf2bK1Szc8ISMHusFv6dZkvimSiZdBtnCIsRCMZtVnMbBe1KaZ96OvXbu37e\" crossorigin=\"anonymous\"></script>\n<gospel-internet-board profile-config='{\"profile\":\"board\",\"tk\":\"YOUR_MAPBOX_TOKEN\",\"utmSource\":\"YOUR_SOURCE\",\"assetsBase\":\"YOUR_TREE_URL/assets\"}'></gospel-internet-board>"
},
"instances": [
{

View file

@ -36,7 +36,7 @@
<script>window.MAP_APP_API_URL = "https://pray.doxa.life";</script>
<!-- Bundle IIFE — registers the <gospel-internet-board> custom element. -->
<script src="../../gospel-internet.js" integrity="sha384-NVgxHdVCb5aUY7aSYhuffQ3upM9FZCTOVLq80etKnDXCr8ZnVlhgmeu/FNwo/0ld" crossorigin="anonymous"></script>
<script src="../../gospel-internet.js" integrity="sha384-7OLwBf2bK1Szc8ISMHusFv6dZkvimSiZdBtnCIsRCMZtVnMbBe1KaZ96OvXbu37e" crossorigin="anonymous"></script>
<script>
// Mapbox token resolution — the A3 ladder, in precedence order:

View file

@ -36,7 +36,7 @@
<script>window.MAP_APP_API_URL = "https://pray.doxa.life";</script>
<!-- Bundle IIFE — registers the <gospel-internet-board> custom element. -->
<script src="../gospel-internet.js" integrity="sha384-NVgxHdVCb5aUY7aSYhuffQ3upM9FZCTOVLq80etKnDXCr8ZnVlhgmeu/FNwo/0ld" crossorigin="anonymous"></script>
<script src="../gospel-internet.js" integrity="sha384-7OLwBf2bK1Szc8ISMHusFv6dZkvimSiZdBtnCIsRCMZtVnMbBe1KaZ96OvXbu37e" crossorigin="anonymous"></script>
<script>
// Mapbox token resolution — the A3 ladder, in precedence order:

View file

@ -36,7 +36,7 @@
<script>window.MAP_APP_API_URL = "https://pray.doxa.life";</script>
<!-- Bundle IIFE — registers the <gospel-internet-board> custom element. -->
<script src="../../gospel-internet.js" integrity="sha384-NVgxHdVCb5aUY7aSYhuffQ3upM9FZCTOVLq80etKnDXCr8ZnVlhgmeu/FNwo/0ld" crossorigin="anonymous"></script>
<script src="../../gospel-internet.js" integrity="sha384-7OLwBf2bK1Szc8ISMHusFv6dZkvimSiZdBtnCIsRCMZtVnMbBe1KaZ96OvXbu37e" crossorigin="anonymous"></script>
<script>
// Mapbox token resolution — the A3 ladder, in precedence order:

View file

@ -36,7 +36,7 @@
<script>window.MAP_APP_API_URL = "https://pray.doxa.life";</script>
<!-- Bundle IIFE — registers the <gospel-internet-board> custom element. -->
<script src="../../gospel-internet.js" integrity="sha384-NVgxHdVCb5aUY7aSYhuffQ3upM9FZCTOVLq80etKnDXCr8ZnVlhgmeu/FNwo/0ld" crossorigin="anonymous"></script>
<script src="../../gospel-internet.js" integrity="sha384-7OLwBf2bK1Szc8ISMHusFv6dZkvimSiZdBtnCIsRCMZtVnMbBe1KaZ96OvXbu37e" crossorigin="anonymous"></script>
<script>
// Mapbox token resolution — the A3 ladder, in precedence order:

View file

@ -36,7 +36,7 @@
<script>window.MAP_APP_API_URL = "https://pray.doxa.life";</script>
<!-- Bundle IIFE — registers the <gospel-internet-board> custom element. -->
<script src="../../gospel-internet.js" integrity="sha384-NVgxHdVCb5aUY7aSYhuffQ3upM9FZCTOVLq80etKnDXCr8ZnVlhgmeu/FNwo/0ld" crossorigin="anonymous"></script>
<script src="../../gospel-internet.js" integrity="sha384-7OLwBf2bK1Szc8ISMHusFv6dZkvimSiZdBtnCIsRCMZtVnMbBe1KaZ96OvXbu37e" crossorigin="anonymous"></script>
<script>
// Mapbox token resolution — the A3 ladder, in precedence order:

View file

@ -36,7 +36,7 @@
<script>window.MAP_APP_API_URL = "https://pray.doxa.life";</script>
<!-- Bundle IIFE — registers the <gospel-internet-board> custom element. -->
<script src="../../gospel-internet.js" integrity="sha384-NVgxHdVCb5aUY7aSYhuffQ3upM9FZCTOVLq80etKnDXCr8ZnVlhgmeu/FNwo/0ld" crossorigin="anonymous"></script>
<script src="../../gospel-internet.js" integrity="sha384-7OLwBf2bK1Szc8ISMHusFv6dZkvimSiZdBtnCIsRCMZtVnMbBe1KaZ96OvXbu37e" crossorigin="anonymous"></script>
<script>
// Mapbox token resolution — the A3 ladder, in precedence order:

View file

@ -36,7 +36,7 @@
<script>window.MAP_APP_API_URL = "https://pray.doxa.life";</script>
<!-- Bundle IIFE — registers the <gospel-internet-board> custom element. -->
<script src="../../gospel-internet.js" integrity="sha384-NVgxHdVCb5aUY7aSYhuffQ3upM9FZCTOVLq80etKnDXCr8ZnVlhgmeu/FNwo/0ld" crossorigin="anonymous"></script>
<script src="../../gospel-internet.js" integrity="sha384-7OLwBf2bK1Szc8ISMHusFv6dZkvimSiZdBtnCIsRCMZtVnMbBe1KaZ96OvXbu37e" crossorigin="anonymous"></script>
<script>
// Mapbox token resolution — the A3 ladder, in precedence order:

File diff suppressed because one or more lines are too long

View file

@ -578,7 +578,7 @@
"bundle": "gospel-internet",
"scriptUrl": "./gospel-internet/gospel-internet.js",
"output": "dx-maps/gospel-internet/gospel-internet.js",
"integrity": "sha384-NVgxHdVCb5aUY7aSYhuffQ3upM9FZCTOVLq80etKnDXCr8ZnVlhgmeu/FNwo/0ld",
"integrity": "sha384-7OLwBf2bK1Szc8ISMHusFv6dZkvimSiZdBtnCIsRCMZtVnMbBe1KaZ96OvXbu37e",
"elements": [
"gospel-internet-board"
],
@ -594,7 +594,7 @@
"scriptUrl": "./gospel-internet/gospel-internet.js",
"embed": {
"iframe": "<iframe src=\"./gospel-internet/board/index.html?utm_source=YOUR_SOURCE\" width=\"100%\" height=\"600\" style=\"border:none;border-radius:12px;\" allowfullscreen></iframe>",
"script": "<!-- Mapbox engine, fetched early. Keep it only with a real Mapbox token in \"tk\": without one (or with \"provider\":\"maplibre\") the map draws with MapLibre and this line must go -->\n<link rel=\"preload\" as=\"script\" href=\"https://api.mapbox.com/mapbox-gl-js/v3.24.0/mapbox-gl.js\" integrity=\"sha384-tO0clamXONKwbiz7O6xJpUeyJbTSPugC+xM9clvfFvKTH3i8SmCawHGdf5quMWmZ\" crossorigin=\"anonymous\">\n<script>window.MAP_APP_API_URL=\"https://pray.doxa.life\";</script>\n<script src=\"./gospel-internet/gospel-internet.js\" integrity=\"sha384-NVgxHdVCb5aUY7aSYhuffQ3upM9FZCTOVLq80etKnDXCr8ZnVlhgmeu/FNwo/0ld\" crossorigin=\"anonymous\"></script>\n<gospel-internet-board profile-config='{\"profile\":\"board\",\"tk\":\"YOUR_MAPBOX_TOKEN\",\"utmSource\":\"YOUR_SOURCE\",\"assetsBase\":\"YOUR_TREE_URL/assets\"}'></gospel-internet-board>"
"script": "<!-- Mapbox engine, fetched early. Keep it only with a real Mapbox token in \"tk\": without one (or with \"provider\":\"maplibre\") the map draws with MapLibre and this line must go -->\n<link rel=\"preload\" as=\"script\" href=\"https://api.mapbox.com/mapbox-gl-js/v3.24.0/mapbox-gl.js\" integrity=\"sha384-tO0clamXONKwbiz7O6xJpUeyJbTSPugC+xM9clvfFvKTH3i8SmCawHGdf5quMWmZ\" crossorigin=\"anonymous\">\n<script>window.MAP_APP_API_URL=\"https://pray.doxa.life\";</script>\n<script src=\"./gospel-internet/gospel-internet.js\" integrity=\"sha384-7OLwBf2bK1Szc8ISMHusFv6dZkvimSiZdBtnCIsRCMZtVnMbBe1KaZ96OvXbu37e\" crossorigin=\"anonymous\"></script>\n<gospel-internet-board profile-config='{\"profile\":\"board\",\"tk\":\"YOUR_MAPBOX_TOKEN\",\"utmSource\":\"YOUR_SOURCE\",\"assetsBase\":\"YOUR_TREE_URL/assets\"}'></gospel-internet-board>"
},
"instances": [
{