element-web-synapse01pim.gr.jp

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

1492.js.map (15020B)


      1 {"version":3,"file":"bundles/12c8185ea2689492c07b/1492.js","mappings":"i6BAwBA,MAAMA,EAAkBA,EACpBC,KACAC,eACAC,UACAC,cACAC,SACAC,qBAYA,MAAMC,EAAS,UAAUN,IAGnBO,GAAUC,EAAAA,EAAAA,YAAWC,EAAAA,IACrBC,GAAcC,EAAAA,EAAAA,IAChBJ,EACAK,EAAAA,IAAYC,gBACXC,IAAiC,IAAAC,EAAA,OAA6C,QAA7CA,GAAKC,EAAAA,EAAAA,IAAwBF,UAAgB,IAAAC,OAAA,EAAxCA,EAA0D,gBAG/FE,EC1BYC,GAAGf,cAAaG,SAAQJ,cAC1C,MAAMiB,GAAMC,EAAAA,EAAAA,OACLH,EAAKI,IAAUC,EAAAA,EAAAA,YAyBtB,OAvBAC,EAAAA,EAAAA,WACI,KACI,IAAIN,EACJ,IACIA,GAAMO,EAAAA,EAAAA,GAAUL,IAAOhB,EAAaG,EAAQJ,GAC5CmB,EAAOJ,EACX,CAAE,MAAOQ,GACLC,QAAQD,MAAM,8BAA+BA,GACzCA,aAAiBE,QACjBzB,SAAAA,EAAUuB,GAElB,CACA,MAAO,KACCR,IACAA,EAAIW,SACJP,OAAOQ,MAKnB,CAACV,EAAKhB,EAAaG,EAAQJ,IAGxBe,GDDKC,CAAO,CAAEf,cAAaG,SAAQJ,aAE1CqB,EAAAA,EAAAA,WAAU,KACFb,GAAeO,GACfA,EAAIa,SAASpB,IAElB,CAACA,EAAaO,KAEjBM,EAAAA,EAAAA,WAAU,KACN,GAAIN,GAAOhB,EACP,IACI,MAAM8B,GAASC,EAAAA,EAAAA,IAAY/B,GAC3B,IAAK8B,EACD,MAAM,IAAIJ,MAAM,mBAEpBV,EAAIgB,UAAU,CAAEC,IAAKH,EAAOI,UAAWC,IAAKL,EAAOM,UACvD,CAAE,MAAOC,GACLC,EAAAA,GAAOd,MAAM,2BAA4Ba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,SAAS,8BAA+B,MAAM,IAAIpE,MAAMiE,EAAAA,EAAmBI,iBAC5F,MAAM1D,CACV","sources":["webpack://element-web/./src/components/views/location/Map.tsx","webpack://element-web/./src/utils/location/useMap.ts","webpack://element-web/./src/utils/location/map.ts"],"sourcesContent":["/*\nCopyright 2024 New Vector Ltd.\nCopyright 2022 The Matrix.org Foundation C.I.C.\n\nSPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial\nPlease see LICENSE files in the repository root for full details.\n*/\n\nimport React, { type ReactNode, useContext, useEffect, useState } from \"react\";\nimport classNames from \"classnames\";\nimport * as maplibregl from \"maplibre-gl\";\nimport { ClientEvent, type IClientWellKnown } from \"matrix-js-sdk/src/matrix\";\nimport { logger } from \"matrix-js-sdk/src/logger\";\n\nimport MatrixClientContext from \"../../../contexts/MatrixClientContext\";\nimport { useEventEmitterState } from \"../../../hooks/useEventEmitter\";\nimport { parseGeoUri, positionFailureMessage } from \"../../../utils/location\";\nimport { tileServerFromWellKnown } from \"../../../utils/WellKnownUtils\";\nimport { useMap } from \"../../../utils/location/useMap\";\nimport { type Bounds } from \"../../../utils/beacon/bounds\";\nimport Modal from \"../../../Modal\";\nimport ErrorDialog from \"../dialogs/ErrorDialog\";\nimport { _t } from \"../../../languageHandler\";\n\nconst useMapWithStyle = ({\n    id,\n    centerGeoUri,\n    onError,\n    interactive,\n    bounds,\n    allowGeolocate,\n}: {\n    id: string;\n    centerGeoUri?: string;\n    onError?(this: void, error: Error): void;\n    interactive?: boolean;\n    bounds?: Bounds;\n    allowGeolocate?: boolean;\n}): {\n    map: maplibregl.Map | undefined;\n    bodyId: string;\n} => {\n    const bodyId = `mx_Map_${id}`;\n\n    // style config\n    const context = useContext(MatrixClientContext);\n    const mapStyleUrl = useEventEmitterState(\n        context,\n        ClientEvent.ClientWellKnown,\n        (clientWellKnown: IClientWellKnown) => tileServerFromWellKnown(clientWellKnown)?.[\"map_style_url\"],\n    );\n\n    const map = useMap({ interactive, bodyId, onError });\n\n    useEffect(() => {\n        if (mapStyleUrl && map) {\n            map.setStyle(mapStyleUrl);\n        }\n    }, [mapStyleUrl, map]);\n\n    useEffect(() => {\n        if (map && centerGeoUri) {\n            try {\n                const coords = parseGeoUri(centerGeoUri);\n                if (!coords) {\n                    throw new Error(\"Invalid geo URI\");\n                }\n                map.setCenter({ lon: coords.longitude, lat: coords.latitude });\n            } catch (e) {\n                logger.error(\"Could not set map center\", e);\n            }\n        }\n    }, [map, centerGeoUri]);\n\n    useEffect(() => {\n        if (map && bounds) {\n            try {\n                const lngLatBounds = new maplibregl.LngLatBounds(\n                    [bounds.west, bounds.south],\n                    [bounds.east, bounds.north],\n                );\n                map.fitBounds(lngLatBounds, { padding: 100, maxZoom: 15 });\n            } catch (e) {\n                logger.error(\"Invalid map bounds\", e);\n            }\n        }\n    }, [map, bounds]);\n\n    const [geolocate, setGeolocate] = useState<maplibregl.GeolocateControl | null>(null);\n\n    useEffect(() => {\n        if (!map) {\n            return;\n        }\n        if (allowGeolocate && !geolocate) {\n            const geolocate = new maplibregl.GeolocateControl({\n                positionOptions: {\n                    enableHighAccuracy: true,\n                },\n                trackUserLocation: false,\n            });\n            setGeolocate(geolocate);\n            map.addControl(geolocate);\n        }\n        if (!allowGeolocate && geolocate) {\n            map.removeControl(geolocate);\n            setGeolocate(null);\n        }\n    }, [map, geolocate, allowGeolocate]);\n\n    useEffect(() => {\n        if (geolocate) {\n            geolocate.on(\"error\", onGeolocateError);\n            return () => {\n                geolocate.off(\"error\", onGeolocateError);\n            };\n        }\n    }, [geolocate]);\n\n    return {\n        map,\n        bodyId,\n    };\n};\n\nconst onGeolocateError = (e: GeolocationPositionError): void => {\n    logger.error(\"Could not fetch location\", e);\n    Modal.createDialog(ErrorDialog, {\n        title: _t(\"location_sharing|error_fetch_location\"),\n        description: positionFailureMessage(e.code) ?? \"\",\n    });\n};\n\nexport interface MapProps {\n    id: string;\n    interactive?: boolean;\n    /**\n     * set map center to geoUri coords\n     * Center will only be set to valid geoUri\n     * this prop is only simply diffed by useEffect, so to trigger *recentering* of the same geoUri\n     * append the uri with a var not used by the geoUri spec\n     * eg a timestamp: `geo:54,42;mxTs=123`\n     */\n    centerGeoUri?: string;\n    bounds?: Bounds;\n    className?: string;\n    allowGeolocate?: boolean;\n    onClick?: () => void;\n    onError?: (error: Error) => void;\n    children?: (renderProps: { map: maplibregl.Map }) => ReactNode;\n}\n\nconst MapComponent: React.FC<MapProps> = ({\n    bounds,\n    centerGeoUri,\n    children,\n    className,\n    allowGeolocate,\n    id,\n    interactive,\n    onError,\n    onClick,\n}) => {\n    const { map, bodyId } = useMapWithStyle({ centerGeoUri, onError, id, interactive, bounds, allowGeolocate });\n\n    const onMapClick = (event: React.MouseEvent<HTMLDivElement, MouseEvent>): void => {\n        // Eat click events when clicking the attribution button\n        const target = event.target as Element;\n        if (target.classList.contains(\"maplibregl-ctrl-attrib-button\")) {\n            return;\n        }\n\n        onClick?.();\n    };\n\n    return (\n        <div className={classNames(\"mx_Map\", className)} id={bodyId} onClick={onMapClick}>\n            {!!children && !!map && children({ map })}\n        </div>\n    );\n};\n\nexport default MapComponent;\n","/*\nCopyright 2024 New Vector Ltd.\nCopyright 2022 The Matrix.org Foundation C.I.C.\n\nSPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial\nPlease see LICENSE files in the repository root for full details.\n*/\n\nimport { useEffect, useState } from \"react\";\n\nimport type { Map as MapLibreMap } from \"maplibre-gl\";\nimport { createMap } from \"./map\";\nimport { useMatrixClientContext } from \"../../contexts/MatrixClientContext\";\n\ninterface UseMapProps {\n    bodyId: string;\n    onError?: (error: Error) => void;\n    interactive?: boolean;\n}\n\n/**\n * Create a map instance\n * Add listeners for errors\n * Make sure `onError` has a stable reference\n * As map is recreated on changes to it\n */\nexport const useMap = ({ interactive, bodyId, onError }: UseMapProps): MapLibreMap | undefined => {\n    const cli = useMatrixClientContext();\n    const [map, setMap] = useState<MapLibreMap>();\n\n    useEffect(\n        () => {\n            let map: MapLibreMap | undefined;\n            try {\n                map = createMap(cli, !!interactive, bodyId, onError);\n                setMap(map);\n            } catch (error) {\n                console.error(\"Error encountered in useMap\", error);\n                if (error instanceof Error) {\n                    onError?.(error);\n                }\n            }\n            return () => {\n                if (map) {\n                    map.remove();\n                    setMap(undefined);\n                }\n            };\n        },\n        // map is excluded as a dependency\n        [cli, interactive, bodyId, onError],\n    );\n\n    return map;\n};\n","/*\nCopyright 2024 New Vector Ltd.\nCopyright 2022 The Matrix.org Foundation C.I.C.\n\nSPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial\nPlease see LICENSE files in the repository root for full details.\n*/\n\nimport * as maplibregl from \"maplibre-gl\";\nimport { type MatrixClient } from \"matrix-js-sdk/src/matrix\";\nimport { logger } from \"matrix-js-sdk/src/logger\";\n\nimport { _t } from \"../../languageHandler\";\nimport { findMapStyleUrl } from \"./findMapStyleUrl\";\nimport { LocationShareError } from \"./LocationShareErrors\";\n\nexport const createMap = (\n    client: MatrixClient,\n    interactive: boolean,\n    bodyId: string,\n    onError?: (error: Error) => void,\n): maplibregl.Map => {\n    try {\n        const styleUrl = findMapStyleUrl(client);\n\n        const map = new maplibregl.Map({\n            container: bodyId,\n            style: styleUrl,\n            zoom: 15,\n            interactive,\n            attributionControl: false,\n            locale: {\n                \"AttributionControl.ToggleAttribution\": _t(\"location_sharing|toggle_attribution\"),\n                \"AttributionControl.MapFeedback\": _t(\"location_sharing|map_feedback\"),\n                \"FullscreenControl.Enter\": _t(\"action|enter_fullscreen\"),\n                \"FullscreenControl.Exit\": _t(\"action|exit_fullscreeen\"),\n                \"GeolocateControl.FindMyLocation\": _t(\"location_sharing|find_my_location\"),\n                \"GeolocateControl.LocationNotAvailable\": _t(\"location_sharing|location_not_available\"),\n                \"LogoControl.Title\": _t(\"location_sharing|mapbox_logo\"),\n                \"NavigationControl.ResetBearing\": _t(\"location_sharing|reset_bearing\"),\n                \"NavigationControl.ZoomIn\": _t(\"action|zoom_in\"),\n                \"NavigationControl.ZoomOut\": _t(\"action|zoom_out\"),\n            },\n        });\n        map.addControl(new maplibregl.AttributionControl(), \"top-right\");\n\n        map.on(\"error\", (e) => {\n            logger.error(\"Failed to load map: check map_style_url in config.json has a valid URL and API key\", e.error);\n            onError?.(new Error(LocationShareError.MapStyleUrlNotReachable));\n        });\n\n        return map;\n    } catch (e) {\n        logger.error(\"Failed to render map\", e);\n        const errorMessage = (e as Error)?.message;\n        if (errorMessage.includes(\"Failed to initialize WebGL\")) throw new Error(LocationShareError.WebGLNotEnabled);\n        throw e;\n    }\n};\n\nexport const createMarker = (coords: GeolocationCoordinates, element: HTMLElement): maplibregl.Marker => {\n    const marker = new maplibregl.Marker({\n        element,\n        anchor: \"bottom\",\n        offset: [0, -1],\n    }).setLngLat({ lon: coords.longitude, lat: coords.latitude });\n    return marker;\n};\n"],"names":["useMapWithStyle","id","centerGeoUri","onError","interactive","bounds","allowGeolocate","bodyId","context","useContext","MatrixClientContext","mapStyleUrl","useEventEmitterState","ClientEvent","ClientWellKnown","clientWellKnown","_tileServerFromWellKn","tileServerFromWellKnown","map","useMap","cli","useMatrixClientContext","setMap","useState","useEffect","createMap","error","console","Error","remove","undefined","setStyle","coords","parseGeoUri","setCenter","lon","longitude","lat","latitude","e","logger","lngLatBounds","maplibregl","west","south","east","north","fitBounds","padding","maxZoom","geolocate","setGeolocate","positionOptions","enableHighAccuracy","trackUserLocation","addControl","removeControl","on","onGeolocateError","off","_positionFailureMessa","Modal","createDialog","ErrorDialog","title","_t","description","positionFailureMessage","code","Map","MapComponent","children","className","onClick","React","classNames","event","target","classList","contains","createMarker","element","anchor","offset","setLngLat","client","styleUrl","findMapStyleUrl","container","style","zoom","attributionControl","locale","LocationShareError","MapStyleUrlNotReachable","message","includes","WebGLNotEnabled"],"sourceRoot":""}