Fix violation of unmined license (distribution)

This commit is contained in:
2022-09-12 00:48:54 +02:00
parent c63eeb83a0
commit 16f60f6075
7 changed files with 94 additions and 253 deletions

View File

@@ -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">