From 1c634818326d81f9c52c88cf0efa4ec6e4c5f536 Mon Sep 17 00:00:00 2001 From: Doxa Maps Date: Sat, 26 Sep 2026 12:48:13 +0000 Subject: [PATCH] Six entries hand-rolled the RTL text plugin; the library already installs it Every one of these bundle entries carried its own copy of if (window.mapboxgl?.setRTLTextPlugin) { setRTLTextPlugin(url, null, true) } which is a strict SUBSET of what library/maps/rtl-text.js already does, so the copies could not be covering anything the library misses: - useMapInstance calls installRtlTextPlugin(gl) at line 450, before it builds a map at 537/567 -- registration still precedes construction, the one ordering Mapbox cares about. - the call is identical in effect: same v0.3.0 URL, same null callback, same lazy flag. - the block is mapboxgl-only. The library installs on MapLibre too, so every keyless embed was covered by the library and never by these blocks. - the single raw `new gl.Map` site (upg-100-list.vue:1894) installs for itself at 1835 and never depended on its entry. I first justified this as deleting DEAD code, on the theory that the engine is injected lazily so window.mapboxgl would not exist when an entry runs. That is wrong and the measurement says so: every leaf index.html loads mapbox-gl.js as a blocking script while ./index.js is a deferred module, so the guard did pass and the blocks were live. The reason to delete them is redundancy, which is the weaker and truer claim. A three-line pointer replaces each block so the next reader does not re-add a Mapbox-only copy. --- plugin-designs/country-posters/index.js | 15 +++------------ plugin-designs/doxa-research-map/index.js | 15 +++------------ plugin-designs/doxa-simple-map/index.js | 17 +++-------------- plugin-designs/my-upg-100-list/index.js | 17 +++-------------- plugin-designs/pplr-data-maps/index.js | 11 +++-------- plugin-designs/upg-neighbor/index.js | 11 +++-------- 6 files changed, 18 insertions(+), 68 deletions(-) diff --git a/plugin-designs/country-posters/index.js b/plugin-designs/country-posters/index.js index 63032263d..0c4b93504 100644 --- a/plugin-designs/country-posters/index.js +++ b/plugin-designs/country-posters/index.js @@ -42,18 +42,9 @@ const profileModules = import.meta.glob('./*.vue') // where _registry.js discovers them for every bundle, and src/colors/ holds no .js at all. The glob // matched nothing, so leaving it would be dead code that reads as a deliberate override. -// ─── Mapbox RTL text plugin — load ONCE before any map instance ────────────── -if (typeof window !== 'undefined' && window.mapboxgl?.setRTLTextPlugin) { - try { - window.mapboxgl.setRTLTextPlugin( - 'https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.3.0/mapbox-gl-rtl-text.js', - null, - true // lazy - ) - } catch (_) { - // Plugin already set in this session — ignore. - } -} +// RTL text plugin (Arabic/Hebrew/Persian shaping): installed by useMapInstance through +// library/maps/rtl-text.js, on BOTH engines, before every map is constructed. Do not re-add a +// hand-rolled mapboxgl-only block here -- it was a strict subset of that call. /** * Each instance gets its own Pinia + i18n so multiple embeds on one page never diff --git a/plugin-designs/doxa-research-map/index.js b/plugin-designs/doxa-research-map/index.js index c3c29bdaa..5f00a59ec 100644 --- a/plugin-designs/doxa-research-map/index.js +++ b/plugin-designs/doxa-research-map/index.js @@ -32,18 +32,9 @@ const profileModules = import.meta.glob('./*.vue') // where _registry.js discovers them for every bundle, and src/colors/ holds no .js at all. The glob // matched nothing, so leaving it would be dead code that reads as a deliberate override. -// ─── Mapbox RTL text plugin — load ONCE before any map instance ────────────── -if (typeof window !== 'undefined' && window.mapboxgl?.setRTLTextPlugin) { - try { - window.mapboxgl.setRTLTextPlugin( - 'https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.3.0/mapbox-gl-rtl-text.js', - null, - true // lazy - ) - } catch (_) { - // Already set in this session — ignore. - } -} +// RTL text plugin (Arabic/Hebrew/Persian shaping): installed by useMapInstance through +// library/maps/rtl-text.js, on BOTH engines, before every map is constructed. Do not re-add a +// hand-rolled mapboxgl-only block here -- it was a strict subset of that call. /** * Build a fresh defineCustomElement-wrapped class. Each instance gets its own diff --git a/plugin-designs/doxa-simple-map/index.js b/plugin-designs/doxa-simple-map/index.js index b1c223d18..b59c906aa 100644 --- a/plugin-designs/doxa-simple-map/index.js +++ b/plugin-designs/doxa-simple-map/index.js @@ -48,20 +48,9 @@ const profileModules = import.meta.glob('./*.vue') // No-op today: doxa-simple-map ships no local strategies (empty glob). registerStrategies(import.meta.glob('./src/colors/*.js', { eager: true })) -// ─── Mapbox RTL text plugin — load ONCE before any map instance ────────────── -// Required for proper rendering of Arabic text on the basemap. -// Lazy = plugin loads only when RTL text is first encountered. -if (typeof window !== 'undefined' && window.mapboxgl?.setRTLTextPlugin) { - try { - window.mapboxgl.setRTLTextPlugin( - 'https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.3.0/mapbox-gl-rtl-text.js', - null, - true // lazy - ) - } catch (_) { - // Plugin already set in this session — ignore. - } -} +// RTL text plugin (Arabic/Hebrew/Persian shaping): installed by useMapInstance through +// library/maps/rtl-text.js, on BOTH engines, before every map is constructed. Do not re-add a +// hand-rolled mapboxgl-only block here -- it was a strict subset of that call. /** * Build a fresh defineCustomElement-wrapped class. diff --git a/plugin-designs/my-upg-100-list/index.js b/plugin-designs/my-upg-100-list/index.js index ffd584a83..c9837a145 100644 --- a/plugin-designs/my-upg-100-list/index.js +++ b/plugin-designs/my-upg-100-list/index.js @@ -38,20 +38,9 @@ import { createAppI18n } from '@map/i18n/index.js' // app.provide('profileModules', ...) below. const profileModules = import.meta.glob('./*.vue') -// ─── Mapbox RTL text plugin — load ONCE before any map instance ────────────── -// Required for proper rendering of Arabic text on the basemap. -// Lazy = plugin loads only when RTL text is first encountered. -if (typeof window !== 'undefined' && window.mapboxgl?.setRTLTextPlugin) { - try { - window.mapboxgl.setRTLTextPlugin( - 'https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.3.0/mapbox-gl-rtl-text.js', - null, - true // lazy - ) - } catch (_) { - // Plugin already set in this session — ignore. - } -} +// RTL text plugin (Arabic/Hebrew/Persian shaping): installed by useMapInstance through +// library/maps/rtl-text.js, on BOTH engines, before every map is constructed. Do not re-add a +// hand-rolled mapboxgl-only block here -- it was a strict subset of that call. /** * Build the defineCustomElement-wrapped class for this bundle. diff --git a/plugin-designs/pplr-data-maps/index.js b/plugin-designs/pplr-data-maps/index.js index 5b522efd7..7440c834c 100644 --- a/plugin-designs/pplr-data-maps/index.js +++ b/plugin-designs/pplr-data-maps/index.js @@ -12,14 +12,9 @@ import { createAppI18n } from '@map/i18n/index.js' const profileModules = import.meta.glob('./*.vue') -if (typeof window !== 'undefined' && window.mapboxgl?.setRTLTextPlugin) { - try { - window.mapboxgl.setRTLTextPlugin( - 'https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.3.0/mapbox-gl-rtl-text.js', - null, true - ) - } catch (_) { /* already set this session */ } -} +// RTL text plugin (Arabic/Hebrew/Persian shaping): installed by useMapInstance through +// library/maps/rtl-text.js, on BOTH engines, before every map is constructed. Do not re-add a +// hand-rolled mapboxgl-only block here -- it was a strict subset of that call. const El = defineCustomElement(ProfileLoader, { configureApp(app) { diff --git a/plugin-designs/upg-neighbor/index.js b/plugin-designs/upg-neighbor/index.js index 675e45907..8d16a84f5 100644 --- a/plugin-designs/upg-neighbor/index.js +++ b/plugin-designs/upg-neighbor/index.js @@ -14,14 +14,9 @@ import { createAppI18n } from '@map/i18n/index.js' const profileModules = import.meta.glob('./*.vue') -if (typeof window !== 'undefined' && window.mapboxgl?.setRTLTextPlugin) { - try { - window.mapboxgl.setRTLTextPlugin( - 'https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.3.0/mapbox-gl-rtl-text.js', - null, true - ) - } catch (_) { /* already set this session */ } -} +// RTL text plugin (Arabic/Hebrew/Persian shaping): installed by useMapInstance through +// library/maps/rtl-text.js, on BOTH engines, before every map is constructed. Do not re-add a +// hand-rolled mapboxgl-only block here -- it was a strict subset of that call. const El = defineCustomElement(ProfileLoader, { configureApp(app) {