Fix violation of unmined license (distribution)
This commit is contained in:
@@ -1,36 +1,41 @@
|
||||
<script lang="ts">
|
||||
import Navbar from "../../Navbar.svelte";
|
||||
import { unmined } from "../../stores";
|
||||
|
||||
import {
|
||||
Unmined,
|
||||
ol_proxy,
|
||||
type UnminedOptions,
|
||||
type UnminedRegions,
|
||||
} from "./unmined";
|
||||
|
||||
export let id = "map";
|
||||
|
||||
let unmined = new Unmined();
|
||||
|
||||
type Metadata = {
|
||||
properties: UnminedOptions;
|
||||
regions: UnminedRegions;
|
||||
};
|
||||
|
||||
async function get_metadata() {
|
||||
async function get_unmined() {
|
||||
if ($unmined === null) {
|
||||
let resp = await fetch("map/unmined.js");
|
||||
let code = await resp.text();
|
||||
$unmined = Function("ol", code).call({}, ol_proxy);
|
||||
}
|
||||
|
||||
let resp = await fetch("map/metadata.js");
|
||||
let code = await resp.text();
|
||||
let meta = Function(code).call({}); // TODO possibly vulnerable to prototype pollution
|
||||
let meta: Metadata = Function(code).call({}); // TODO possibly vulnerable to prototype pollution
|
||||
return meta;
|
||||
}
|
||||
|
||||
function setupMap(node: HTMLDivElement, metadata: Metadata) {
|
||||
unmined.map(node.id, metadata.properties, metadata.regions);
|
||||
$unmined.map(node.id, metadata.properties, metadata.regions);
|
||||
|
||||
return {
|
||||
destroy() {
|
||||
if (unmined.openlayersMap) {
|
||||
unmined.openlayersMap.setTarget(null);
|
||||
unmined.openlayersMap = null;
|
||||
if ($unmined.openlayersMap) {
|
||||
$unmined.openlayersMap.setTarget(null);
|
||||
$unmined.openlayersMap = null;
|
||||
}
|
||||
},
|
||||
};
|
||||
@@ -39,7 +44,7 @@
|
||||
|
||||
<div class="map-outer">
|
||||
<Navbar />
|
||||
{#await get_metadata() then metadata}
|
||||
{#await get_unmined() then metadata}
|
||||
<div class="map-target" {id} use:setupMap={metadata} />
|
||||
{:catch err}
|
||||
<div class="container">
|
||||
|
||||
Reference in New Issue
Block a user