tangram-core 0.3.0__cp310-cp310-manylinux_2_28_aarch64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tangram_core/App.vue +441 -0
- tangram_core/CommandPalette.vue +200 -0
- tangram_core/HighlightText.vue +32 -0
- tangram_core/__Timeline.vue +300 -0
- tangram_core/__init__.py +5 -0
- tangram_core/__main__.py +331 -0
- tangram_core/_core.cpython-310-aarch64-linux-gnu.so +0 -0
- tangram_core/_core.pyi +38 -0
- tangram_core/api.ts +652 -0
- tangram_core/backend.py +458 -0
- tangram_core/components.ts +2 -0
- tangram_core/config.py +167 -0
- tangram_core/dist-frontend/aggregation-layers.js +521 -0
- tangram_core/dist-frontend/aggregation-layers.js.map +1 -0
- tangram_core/dist-frontend/assets/_commonjsHelpers-CqkleIqs.js +2 -0
- tangram_core/dist-frontend/assets/_commonjsHelpers-CqkleIqs.js.map +1 -0
- tangram_core/dist-frontend/assets/array-utils-flat-BBMak426.js +11 -0
- tangram_core/dist-frontend/assets/array-utils-flat-BBMak426.js.map +1 -0
- tangram_core/dist-frontend/assets/assert-cyW4mg7q.js +3 -0
- tangram_core/dist-frontend/assets/assert-cyW4mg7q.js.map +1 -0
- tangram_core/dist-frontend/assets/b612-latin-400-italic-DePNXA0a.woff +0 -0
- tangram_core/dist-frontend/assets/b612-latin-400-italic-a-4GLPtl.woff2 +0 -0
- tangram_core/dist-frontend/assets/b612-latin-400-normal-CC98FVm_.woff2 +0 -0
- tangram_core/dist-frontend/assets/b612-latin-400-normal-JbZ7xwUX.woff +0 -0
- tangram_core/dist-frontend/assets/b612-latin-700-normal-B_Snq1wd.woff +0 -0
- tangram_core/dist-frontend/assets/b612-latin-700-normal-BinQrnoB.woff2 +0 -0
- tangram_core/dist-frontend/assets/clip-extension-D-rbmFPj.js +26 -0
- tangram_core/dist-frontend/assets/clip-extension-D-rbmFPj.js.map +1 -0
- tangram_core/dist-frontend/assets/color-CUNNsFV-.js +17 -0
- tangram_core/dist-frontend/assets/color-CUNNsFV-.js.map +1 -0
- tangram_core/dist-frontend/assets/cube-geometry-v0HQ793i.js +2 -0
- tangram_core/dist-frontend/assets/cube-geometry-v0HQ793i.js.map +1 -0
- tangram_core/dist-frontend/assets/deep-equal-BTW2ZN6S.js +2 -0
- tangram_core/dist-frontend/assets/deep-equal-BTW2ZN6S.js.map +1 -0
- tangram_core/dist-frontend/assets/fly-to-interpolator-CIXGjOdo.js +2 -0
- tangram_core/dist-frontend/assets/fly-to-interpolator-CIXGjOdo.js.map +1 -0
- tangram_core/dist-frontend/assets/geojson-layer-DgMOQ4Qu.js +1010 -0
- tangram_core/dist-frontend/assets/geojson-layer-DgMOQ4Qu.js.map +1 -0
- tangram_core/dist-frontend/assets/globe-view-Day_n1iB.js +94 -0
- tangram_core/dist-frontend/assets/globe-view-Day_n1iB.js.map +1 -0
- tangram_core/dist-frontend/assets/globe-viewport-tqhQW7C4.js +2 -0
- tangram_core/dist-frontend/assets/globe-viewport-tqhQW7C4.js.map +1 -0
- tangram_core/dist-frontend/assets/image-loader-hHJsndO6.js +2 -0
- tangram_core/dist-frontend/assets/image-loader-hHJsndO6.js.map +1 -0
- tangram_core/dist-frontend/assets/inconsolata-latin-400-normal-DTZQ6lD6.woff2 +0 -0
- tangram_core/dist-frontend/assets/inconsolata-latin-400-normal-HYADljCo.woff +0 -0
- tangram_core/dist-frontend/assets/inconsolata-latin-700-normal-ByjKuJjN.woff2 +0 -0
- tangram_core/dist-frontend/assets/inconsolata-latin-700-normal-DzgUY3Rl.woff +0 -0
- tangram_core/dist-frontend/assets/inconsolata-latin-ext-400-normal-BaHVOdFB.woff2 +0 -0
- tangram_core/dist-frontend/assets/inconsolata-latin-ext-400-normal-yvPjCxxx.woff +0 -0
- tangram_core/dist-frontend/assets/inconsolata-latin-ext-700-normal-D0Kpgs_9.woff2 +0 -0
- tangram_core/dist-frontend/assets/inconsolata-latin-ext-700-normal-Dlt-daqV.woff +0 -0
- tangram_core/dist-frontend/assets/inconsolata-vietnamese-400-normal-ByiM2lek.woff +0 -0
- tangram_core/dist-frontend/assets/inconsolata-vietnamese-400-normal-DfC_iMic.woff2 +0 -0
- tangram_core/dist-frontend/assets/inconsolata-vietnamese-700-normal-DLCFFAUf.woff +0 -0
- tangram_core/dist-frontend/assets/inconsolata-vietnamese-700-normal-DuasYmn8.woff2 +0 -0
- tangram_core/dist-frontend/assets/index-CcogpxdD.js +824 -0
- tangram_core/dist-frontend/assets/index-CcogpxdD.js.map +1 -0
- tangram_core/dist-frontend/assets/index-SSLdizTv.css +1 -0
- tangram_core/dist-frontend/assets/layer-DPcO4AXQ.js +555 -0
- tangram_core/dist-frontend/assets/layer-DPcO4AXQ.js.map +1 -0
- tangram_core/dist-frontend/assets/layer-extension-CYwTXf73.js +2 -0
- tangram_core/dist-frontend/assets/layer-extension-CYwTXf73.js.map +1 -0
- tangram_core/dist-frontend/assets/mesh-layers-wiqredoy.js +1123 -0
- tangram_core/dist-frontend/assets/mesh-layers-wiqredoy.js.map +1 -0
- tangram_core/dist-frontend/assets/orthographic-viewport-B4nCj5tn.js +2 -0
- tangram_core/dist-frontend/assets/orthographic-viewport-B4nCj5tn.js.map +1 -0
- tangram_core/dist-frontend/assets/pick-layers-pass-C-3k0wbN.js +2 -0
- tangram_core/dist-frontend/assets/pick-layers-pass-C-3k0wbN.js.map +1 -0
- tangram_core/dist-frontend/assets/project-BTjD2Imj.js +760 -0
- tangram_core/dist-frontend/assets/project-BTjD2Imj.js.map +1 -0
- tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-400-italic-4qS3_zkX.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-400-italic-CDK-EZBY.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-400-normal-Bgns473E.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-400-normal-_T2aQlWs.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-500-normal-CvEVpWxD.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-500-normal-s4PklZE0.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-700-normal-9RN-Z7cI.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-700-normal-BGMkBBYx.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-ext-400-italic-C7erd-g8.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-ext-400-italic-DR5R5TWx.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-ext-400-normal-DGo1Ayjq.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-ext-400-normal-WtM1l1qc.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-ext-500-normal-C8FNIdXm.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-ext-500-normal-TLDmfi3Q.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-ext-700-normal-CTXjXnze.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-cyrillic-ext-700-normal-CWPRiRXS.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-greek-400-italic-CR6qj4Z4.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-greek-400-italic-DHRaIs10.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-greek-400-normal-D5vBSIyg.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-greek-400-normal-FabMgVmk.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-greek-500-normal-BIN62cw9.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-greek-500-normal-Hsn-wDIp.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-greek-700-normal-89Up2Xly.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-greek-700-normal-DWMOA2VK.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-latin-400-italic-D_BR-3LG.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-latin-400-italic-om57GXsO.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-latin-400-normal-BICmKrXV.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-latin-400-normal-D2e7XwB1.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-latin-500-normal-3p2daRJW.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-latin-500-normal-Dc9bsamC.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-latin-700-normal-BOl6B_hI.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-latin-700-normal-DRbp0YnP.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-latin-ext-400-italic-BXrkWnoY.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-latin-ext-400-italic-Bhem1d5z.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-latin-ext-400-normal-DT8nEsYA.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-latin-ext-400-normal-OHaX69iP.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-latin-ext-500-normal-CcSTXKtO.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-latin-ext-500-normal-JgPl2bDS.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-latin-ext-700-normal-B004qtqu.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-latin-ext-700-normal-O6H_RRvN.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-vietnamese-400-italic-BwUYFJ2t.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-vietnamese-400-italic-DV8QogUk.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-vietnamese-400-normal-0o1laQ-g.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-vietnamese-400-normal-CPsdS8_S.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-vietnamese-500-normal-G9shSJ2z.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-vietnamese-500-normal-TFWhjk13.woff2 +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-vietnamese-700-normal-BtNeb9D6.woff +0 -0
- tangram_core/dist-frontend/assets/roboto-condensed-vietnamese-700-normal-D35V1G0s.woff2 +0 -0
- tangram_core/dist-frontend/assets/shader-Cbdysp2j.js +843 -0
- tangram_core/dist-frontend/assets/shader-Cbdysp2j.js.map +1 -0
- tangram_core/dist-frontend/assets/solid-polygon-layer-DJFl_7Ca.js +392 -0
- tangram_core/dist-frontend/assets/solid-polygon-layer-DJFl_7Ca.js.map +1 -0
- tangram_core/dist-frontend/assets/tesselator-CENyUZ2p.js +2 -0
- tangram_core/dist-frontend/assets/tesselator-CENyUZ2p.js.map +1 -0
- tangram_core/dist-frontend/assets/webgl-developer-tools-utTNOsNf.js +7 -0
- tangram_core/dist-frontend/assets/webgl-developer-tools-utTNOsNf.js.map +1 -0
- tangram_core/dist-frontend/assets/webgl-device-BYRB-GQX.js +3 -0
- tangram_core/dist-frontend/assets/webgl-device-BYRB-GQX.js.map +1 -0
- tangram_core/dist-frontend/assets/widget-BjgEeHAL.js +2 -0
- tangram_core/dist-frontend/assets/widget-BjgEeHAL.js.map +1 -0
- tangram_core/dist-frontend/core.js +60 -0
- tangram_core/dist-frontend/core.js.map +1 -0
- tangram_core/dist-frontend/extensions.js +609 -0
- tangram_core/dist-frontend/extensions.js.map +1 -0
- tangram_core/dist-frontend/favicon.ico +0 -0
- tangram_core/dist-frontend/favicon.png +0 -0
- tangram_core/dist-frontend/geo-layers.js +115 -0
- tangram_core/dist-frontend/geo-layers.js.map +1 -0
- tangram_core/dist-frontend/index.html +39 -0
- tangram_core/dist-frontend/json.js +3 -0
- tangram_core/dist-frontend/json.js.map +1 -0
- tangram_core/dist-frontend/layers.js +268 -0
- tangram_core/dist-frontend/layers.js.map +1 -0
- tangram_core/dist-frontend/mapbox.js +2 -0
- tangram_core/dist-frontend/mapbox.js.map +1 -0
- tangram_core/dist-frontend/mesh-layers.js +2 -0
- tangram_core/dist-frontend/mesh-layers.js.map +1 -0
- tangram_core/dist-frontend/widgets.js +3 -0
- tangram_core/dist-frontend/widgets.js.map +1 -0
- tangram_core/main.ts +28 -0
- tangram_core/package.json +62 -0
- tangram_core/plugin.py +109 -0
- tangram_core/plugin.ts +47 -0
- tangram_core/redis.py +89 -0
- tangram_core/user.css +114 -0
- tangram_core/utils.ts +143 -0
- tangram_core/vite-plugin-tangram.mjs +155 -0
- tangram_core-0.3.0.dist-info/METADATA +101 -0
- tangram_core-0.3.0.dist-info/RECORD +162 -0
- tangram_core-0.3.0.dist-info/WHEEL +4 -0
- tangram_core-0.3.0.dist-info/entry_points.txt +2 -0
tangram_core/App.vue
ADDED
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-if="apiState === 'loading'" class="loading-container">
|
|
3
|
+
<div>initialising tangram…</div>
|
|
4
|
+
<div v-if="loadingMessage" class="loading-detail">{{ loadingMessage }}</div>
|
|
5
|
+
</div>
|
|
6
|
+
<div v-else-if="apiState === 'error'">
|
|
7
|
+
error: could not connect to the tangram backend.
|
|
8
|
+
</div>
|
|
9
|
+
<div v-else-if="apiState === 'ready' && tangramApi" class="main-container">
|
|
10
|
+
<div class="navbar" role="navigation">
|
|
11
|
+
<div class="navbar-brand">
|
|
12
|
+
<img src="/favicon.png" alt="tangram" class="navbar-logo" />
|
|
13
|
+
<span class="navbar-title">tangram</span>
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<div class="navbar-spacer"></div>
|
|
17
|
+
|
|
18
|
+
<component
|
|
19
|
+
:is="widget.id"
|
|
20
|
+
v-for="widget in tangramApi.ui.widgets.TopBar"
|
|
21
|
+
:key="widget.id"
|
|
22
|
+
/>
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
<div ref="mapContainer" class="map-container">
|
|
26
|
+
<CommandPalette />
|
|
27
|
+
<div v-if="visibleSidebarWidgets.length > 0" class="sidebar-container">
|
|
28
|
+
<div
|
|
29
|
+
v-for="widget in visibleSidebarWidgets"
|
|
30
|
+
:key="widget.id"
|
|
31
|
+
class="sidebar-section"
|
|
32
|
+
>
|
|
33
|
+
<div class="sidebar-header" @click="toggleSection(widget)">
|
|
34
|
+
<svg
|
|
35
|
+
class="caret"
|
|
36
|
+
:class="{ open: !widget.isCollapsed }"
|
|
37
|
+
viewBox="0 0 24 24"
|
|
38
|
+
width="16"
|
|
39
|
+
height="16"
|
|
40
|
+
>
|
|
41
|
+
<path d="M8 5v14l11-7z" fill="currentColor" />
|
|
42
|
+
</svg>
|
|
43
|
+
{{ widget.title || widget.id }}
|
|
44
|
+
</div>
|
|
45
|
+
<div v-show="!widget.isCollapsed" class="sidebar-body">
|
|
46
|
+
<component :is="widget.id" />
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
<component
|
|
51
|
+
:is="widget.id"
|
|
52
|
+
v-for="widget in tangramApi.ui.widgets.MapOverlay"
|
|
53
|
+
:key="widget.id"
|
|
54
|
+
/>
|
|
55
|
+
<div v-if="tangramApi && tangramApi.map.isReady" class="map-controls">
|
|
56
|
+
<button
|
|
57
|
+
v-if="
|
|
58
|
+
tangramApi.config.map.allow_bearing &&
|
|
59
|
+
Math.abs(tangramApi.map.bearing) > 0.1
|
|
60
|
+
"
|
|
61
|
+
class="map-btn"
|
|
62
|
+
title="Reset Bearing (North)"
|
|
63
|
+
@click="resetBearing"
|
|
64
|
+
>
|
|
65
|
+
<svg
|
|
66
|
+
viewBox="0 0 100 100"
|
|
67
|
+
class="compass-icon"
|
|
68
|
+
:style="{ transform: `rotate(${-tangramApi.map.bearing}deg)` }"
|
|
69
|
+
>
|
|
70
|
+
<path d="M50 15 L65 50 L50 50 Z" fill="#e74c3c" />
|
|
71
|
+
<path d="M50 15 L35 50 L50 50 Z" fill="#c0392b" />
|
|
72
|
+
<path d="M50 85 L65 50 L50 50 Z" fill="#ecf0f1" />
|
|
73
|
+
<path d="M50 85 L35 50 L50 50 Z" fill="#bdc3c7" />
|
|
74
|
+
</svg>
|
|
75
|
+
</button>
|
|
76
|
+
<button
|
|
77
|
+
v-if="tangramApi.config.map.allow_pitch && tangramApi.map.pitch > 0.1"
|
|
78
|
+
class="map-btn"
|
|
79
|
+
title="Reset Pitch (2D)"
|
|
80
|
+
@click="resetPitch"
|
|
81
|
+
>
|
|
82
|
+
2D
|
|
83
|
+
</button>
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
</template>
|
|
88
|
+
|
|
89
|
+
<script setup lang="ts">
|
|
90
|
+
import { onMounted, onUnmounted, getCurrentInstance, ref, watch, computed } from "vue";
|
|
91
|
+
import maplibregl from "maplibre-gl";
|
|
92
|
+
import { TangramApi, type WidgetEntry } from "./api";
|
|
93
|
+
import { loadPlugins } from "./plugin";
|
|
94
|
+
import { layers, namedFlavor } from "@protomaps/basemaps";
|
|
95
|
+
import * as pmtiles from "pmtiles";
|
|
96
|
+
import CommandPalette from "./CommandPalette.vue";
|
|
97
|
+
|
|
98
|
+
type ApiState = "loading" | "ready" | "error";
|
|
99
|
+
|
|
100
|
+
const app = getCurrentInstance()!.appContext.app;
|
|
101
|
+
const apiState = ref<ApiState>("loading");
|
|
102
|
+
const loadingMessage = ref<string>("");
|
|
103
|
+
const tangramApi = ref<TangramApi | null>(null);
|
|
104
|
+
const mapContainer = ref<HTMLElement | null>(null);
|
|
105
|
+
let mapInstance: maplibregl.Map | undefined = undefined;
|
|
106
|
+
|
|
107
|
+
const visibleSidebarWidgets = computed((): WidgetEntry[] => {
|
|
108
|
+
if (!tangramApi.value) return [];
|
|
109
|
+
const activeEntities = tangramApi.value.state.activeEntities;
|
|
110
|
+
|
|
111
|
+
const activeTypes = new Set<string>();
|
|
112
|
+
if (activeEntities) {
|
|
113
|
+
for (const entity of activeEntities.values()) {
|
|
114
|
+
activeTypes.add(entity.type);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return tangramApi.value.ui.widgets.SideBar.filter(widget => {
|
|
119
|
+
if (!widget.relevantFor) return true;
|
|
120
|
+
|
|
121
|
+
const widgetTypes = Array.isArray(widget.relevantFor)
|
|
122
|
+
? widget.relevantFor
|
|
123
|
+
: [widget.relevantFor];
|
|
124
|
+
return widgetTypes.some(t => activeTypes.has(t));
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
const toggleSection = (widget: WidgetEntry) => {
|
|
129
|
+
widget.isCollapsed = !widget.isCollapsed;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
watch(
|
|
133
|
+
() => tangramApi.value?.state.activeEntities.value,
|
|
134
|
+
newEntities => {
|
|
135
|
+
if (!tangramApi.value || !newEntities) return;
|
|
136
|
+
|
|
137
|
+
const activeTypes = new Set<string>();
|
|
138
|
+
for (const entity of newEntities.values()) {
|
|
139
|
+
activeTypes.add(entity.type);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
for (const widget of tangramApi.value.ui.widgets.SideBar) {
|
|
143
|
+
if (widget.relevantFor) {
|
|
144
|
+
const widgetTypes = Array.isArray(widget.relevantFor)
|
|
145
|
+
? widget.relevantFor
|
|
146
|
+
: [widget.relevantFor];
|
|
147
|
+
if (widgetTypes.some(t => activeTypes.has(t))) {
|
|
148
|
+
widget.isCollapsed = false;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
{ deep: true }
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
onMounted(async () => {
|
|
157
|
+
try {
|
|
158
|
+
const api = await TangramApi.create(app);
|
|
159
|
+
app.provide("tangramApi", api);
|
|
160
|
+
await loadPlugins(api, progress => {
|
|
161
|
+
if (progress.stage === "manifest") {
|
|
162
|
+
loadingMessage.value = "fetching plugin manifest";
|
|
163
|
+
} else if (progress.stage === "plugin" && progress.pluginName) {
|
|
164
|
+
loadingMessage.value = `loading plugin: ${progress.pluginName}`;
|
|
165
|
+
} else if (progress.stage === "done") {
|
|
166
|
+
loadingMessage.value = "starting user interface";
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
tangramApi.value = api;
|
|
170
|
+
apiState.value = "ready";
|
|
171
|
+
} catch (e) {
|
|
172
|
+
console.error("failed to initialise tangram api:", e);
|
|
173
|
+
apiState.value = "error";
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
watch(mapContainer, newEl => {
|
|
178
|
+
if (newEl && tangramApi.value && !mapInstance) {
|
|
179
|
+
const mapConfig = tangramApi.value.config.map;
|
|
180
|
+
|
|
181
|
+
const protocol = new pmtiles.Protocol();
|
|
182
|
+
maplibregl.addProtocol("pmtiles", protocol.tile);
|
|
183
|
+
|
|
184
|
+
if (typeof mapConfig.style === "object") {
|
|
185
|
+
// If the style is an object, we need to ensure it has the correct structure
|
|
186
|
+
// First we need to remove all None/null values from the style object
|
|
187
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
188
|
+
const removeNulls = (obj: any): any => {
|
|
189
|
+
if (Array.isArray(obj)) {
|
|
190
|
+
return obj.map(removeNulls);
|
|
191
|
+
}
|
|
192
|
+
if (typeof obj === "string") {
|
|
193
|
+
// This is a special case if we don't want to hardcode the root URL
|
|
194
|
+
// of the application in the style JSON, we can use #ROOT# as a placeholder
|
|
195
|
+
if (obj.includes("#ROOT#")) {
|
|
196
|
+
const rootUrl =
|
|
197
|
+
window.location.origin +
|
|
198
|
+
window.location.pathname.replace(/\/[^\/]*$/, "/");
|
|
199
|
+
return obj.replace(/#ROOT#/g, rootUrl);
|
|
200
|
+
}
|
|
201
|
+
return obj;
|
|
202
|
+
}
|
|
203
|
+
if (obj !== null && typeof obj === "object") {
|
|
204
|
+
return Object.entries(obj).reduce((acc, [key, value]) => {
|
|
205
|
+
if (value !== null && value !== undefined) {
|
|
206
|
+
acc[key] = removeNulls(value);
|
|
207
|
+
}
|
|
208
|
+
return acc;
|
|
209
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
210
|
+
}, {} as any);
|
|
211
|
+
}
|
|
212
|
+
return obj;
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
const styleObject = removeNulls(mapConfig.style);
|
|
216
|
+
|
|
217
|
+
if (!styleObject.layers) {
|
|
218
|
+
styleObject.layers = layers("protomaps", namedFlavor("light"), {
|
|
219
|
+
lang: mapConfig.lang
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
mapConfig.style = styleObject;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// @ts-expect-error TS2589: Type instantiation is excessively deep and possibly infinite
|
|
226
|
+
mapInstance = new maplibregl.Map({
|
|
227
|
+
container: newEl,
|
|
228
|
+
style: mapConfig.style,
|
|
229
|
+
center: [mapConfig.center_lon, mapConfig.center_lat],
|
|
230
|
+
zoom: mapConfig.zoom,
|
|
231
|
+
pitch: mapConfig.pitch,
|
|
232
|
+
bearing: mapConfig.bearing,
|
|
233
|
+
attributionControl: false,
|
|
234
|
+
minZoom: mapConfig.min_zoom,
|
|
235
|
+
maxZoom: mapConfig.max_zoom,
|
|
236
|
+
maxPitch: mapConfig.allow_pitch ? mapConfig.max_pitch : 0,
|
|
237
|
+
dragRotate: mapConfig.allow_bearing,
|
|
238
|
+
touchZoomRotate: mapConfig.allow_bearing,
|
|
239
|
+
pitchWithRotate: mapConfig.allow_pitch
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
tangramApi.value.map.initialize(mapInstance);
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
const resetBearing = () => {
|
|
247
|
+
tangramApi.value?.map.getMapInstance().easeTo({ bearing: 0 });
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
const resetPitch = () => {
|
|
251
|
+
tangramApi.value?.map.getMapInstance().easeTo({ pitch: 0 });
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
onUnmounted(() => {
|
|
255
|
+
tangramApi.value?.map.dispose();
|
|
256
|
+
if (mapInstance) {
|
|
257
|
+
mapInstance.remove();
|
|
258
|
+
mapInstance = undefined;
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
</script>
|
|
262
|
+
<style>
|
|
263
|
+
#app {
|
|
264
|
+
height: 100%;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
html {
|
|
268
|
+
width: 100%;
|
|
269
|
+
height: 100%;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
body {
|
|
273
|
+
font-family: "B612", sans-serif;
|
|
274
|
+
width: 100%;
|
|
275
|
+
height: 100%;
|
|
276
|
+
margin: 0;
|
|
277
|
+
padding: 0;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.main-container {
|
|
281
|
+
height: 100%;
|
|
282
|
+
width: 100%;
|
|
283
|
+
display: flex;
|
|
284
|
+
flex-direction: column;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
.navbar {
|
|
288
|
+
min-height: 50px;
|
|
289
|
+
background: white;
|
|
290
|
+
z-index: 500;
|
|
291
|
+
width: 100%;
|
|
292
|
+
box-sizing: border-box;
|
|
293
|
+
padding: 0.5rem 1rem;
|
|
294
|
+
display: flex;
|
|
295
|
+
flex-wrap: wrap;
|
|
296
|
+
align-items: center;
|
|
297
|
+
gap: 1.5rem;
|
|
298
|
+
border-bottom: 1px solid #e7e7e7;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
.navbar-brand {
|
|
302
|
+
display: flex;
|
|
303
|
+
align-items: center;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
.navbar-logo {
|
|
307
|
+
height: 24px;
|
|
308
|
+
margin-right: 5px;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
.navbar-title {
|
|
312
|
+
padding-top: 0.3125rem;
|
|
313
|
+
padding-bottom: 0.3125rem;
|
|
314
|
+
font-size: 1.25rem;
|
|
315
|
+
margin-bottom: 0;
|
|
316
|
+
color: black;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
.navbar-spacer {
|
|
320
|
+
margin-left: auto;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/* sidebar */
|
|
324
|
+
.sidebar-container {
|
|
325
|
+
font-family: "B612", sans-serif;
|
|
326
|
+
position: absolute;
|
|
327
|
+
top: 10px;
|
|
328
|
+
left: 10px;
|
|
329
|
+
width: 21rem;
|
|
330
|
+
max-height: calc(100% - 20px);
|
|
331
|
+
z-index: 1000;
|
|
332
|
+
display: flex;
|
|
333
|
+
flex-direction: column;
|
|
334
|
+
gap: 8px;
|
|
335
|
+
pointer-events: none;
|
|
336
|
+
scrollbar-width: thin;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
.sidebar-section {
|
|
340
|
+
background-color: rgba(255, 255, 255, 0.95);
|
|
341
|
+
color: #333;
|
|
342
|
+
border-radius: 10px;
|
|
343
|
+
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
|
|
344
|
+
overflow: hidden;
|
|
345
|
+
pointer-events: auto;
|
|
346
|
+
border: 1px solid rgba(0, 0, 0, 0.1);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
.sidebar-header {
|
|
350
|
+
padding: 4px;
|
|
351
|
+
background-color: #f8f9fa;
|
|
352
|
+
cursor: pointer;
|
|
353
|
+
user-select: none;
|
|
354
|
+
display: flex;
|
|
355
|
+
align-items: center;
|
|
356
|
+
font-size: 14px;
|
|
357
|
+
border-bottom: 1px solid rgba(0, 0, 0, 0.05);
|
|
358
|
+
color: #222;
|
|
359
|
+
transition: background-color 0.2s ease;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
.sidebar-header:hover {
|
|
363
|
+
background-color: #e9ecef;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
.sidebar-body {
|
|
367
|
+
padding: 0;
|
|
368
|
+
background-color: white;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
.caret {
|
|
372
|
+
display: inline-block;
|
|
373
|
+
margin-right: 8px;
|
|
374
|
+
transition: transform 0.15s ease;
|
|
375
|
+
color: #666;
|
|
376
|
+
width: 16px;
|
|
377
|
+
height: 16px;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
.caret.open {
|
|
381
|
+
transform: rotate(90deg);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/* map and controls */
|
|
385
|
+
.map-container {
|
|
386
|
+
flex: 1;
|
|
387
|
+
flex-grow: 1;
|
|
388
|
+
position: relative;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
.control-attribution {
|
|
392
|
+
display: none !important;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
.loading-container {
|
|
396
|
+
padding: 1.5rem;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
.loading-detail {
|
|
400
|
+
margin-top: 0.5rem;
|
|
401
|
+
color: #555;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
.map-controls {
|
|
405
|
+
position: absolute;
|
|
406
|
+
bottom: 30px;
|
|
407
|
+
right: 20px;
|
|
408
|
+
display: flex;
|
|
409
|
+
flex-direction: column;
|
|
410
|
+
gap: 8px;
|
|
411
|
+
z-index: 1000;
|
|
412
|
+
pointer-events: auto;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
.map-btn {
|
|
416
|
+
width: 32px;
|
|
417
|
+
height: 32px;
|
|
418
|
+
background: white;
|
|
419
|
+
border: 1px solid #ccc;
|
|
420
|
+
border-radius: 10px;
|
|
421
|
+
cursor: pointer;
|
|
422
|
+
display: flex;
|
|
423
|
+
align-items: center;
|
|
424
|
+
justify-content: center;
|
|
425
|
+
font-family: "B612", sans-serif;
|
|
426
|
+
font-weight: bold;
|
|
427
|
+
font-size: 12px;
|
|
428
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
|
|
429
|
+
padding: 2px;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
.map-btn:hover {
|
|
433
|
+
background-color: #f0f0f0;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
.compass-icon {
|
|
437
|
+
width: 100%;
|
|
438
|
+
height: 100%;
|
|
439
|
+
transition: transform 0.1s linear;
|
|
440
|
+
}
|
|
441
|
+
</style>
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="palette-widget" @click.stop>
|
|
3
|
+
<div class="search-box">
|
|
4
|
+
<input
|
|
5
|
+
ref="inputRef"
|
|
6
|
+
v-model="query"
|
|
7
|
+
type="text"
|
|
8
|
+
placeholder="Search (Ctrl+P)..."
|
|
9
|
+
class="search-input"
|
|
10
|
+
@keydown.down.prevent="moveSelection(1)"
|
|
11
|
+
@keydown.up.prevent="moveSelection(-1)"
|
|
12
|
+
@keydown.enter="selectCurrent"
|
|
13
|
+
@focus="isOpen = true"
|
|
14
|
+
/>
|
|
15
|
+
</div>
|
|
16
|
+
<ul v-if="isOpen && flatResults.length" class="results-list">
|
|
17
|
+
<li
|
|
18
|
+
v-for="(item, index) in flatResults"
|
|
19
|
+
:key="item.id"
|
|
20
|
+
class="result-item"
|
|
21
|
+
:class="{ selected: index === selectedIndex, 'is-child': item.depth > 0 }"
|
|
22
|
+
:style="{ paddingLeft: `${item.depth * 16 + 12}px` }"
|
|
23
|
+
@click="selectResult(item)"
|
|
24
|
+
@mouseenter="selectedIndex = index"
|
|
25
|
+
>
|
|
26
|
+
<component :is="item.component" v-bind="item.props" :query="query" />
|
|
27
|
+
</li>
|
|
28
|
+
</ul>
|
|
29
|
+
</div>
|
|
30
|
+
</template>
|
|
31
|
+
|
|
32
|
+
<script setup lang="ts">
|
|
33
|
+
import { ref, onMounted, onUnmounted, inject, watch, computed } from "vue";
|
|
34
|
+
import type { TangramApi, SearchResult } from "./api";
|
|
35
|
+
|
|
36
|
+
const tangramApi = inject<TangramApi>("tangramApi");
|
|
37
|
+
const query = ref("");
|
|
38
|
+
const results = ref<SearchResult[]>([]);
|
|
39
|
+
const selectedIndex = ref(0);
|
|
40
|
+
const isOpen = ref(false);
|
|
41
|
+
const inputRef = ref<HTMLInputElement | null>(null);
|
|
42
|
+
|
|
43
|
+
let abortController: AbortController | null = null;
|
|
44
|
+
let debounceTimeout: ReturnType<typeof setTimeout> | null = null;
|
|
45
|
+
|
|
46
|
+
interface FlatResult extends SearchResult {
|
|
47
|
+
depth: number;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const flatResults = computed(() => {
|
|
51
|
+
const flat: FlatResult[] = [];
|
|
52
|
+
const traverse = (nodes: SearchResult[], depth: number) => {
|
|
53
|
+
for (const node of nodes) {
|
|
54
|
+
flat.push({ ...node, depth });
|
|
55
|
+
if (node.children) {
|
|
56
|
+
traverse(node.children, depth + 1);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
traverse(results.value, 0);
|
|
61
|
+
return flat;
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const close = () => {
|
|
65
|
+
isOpen.value = false;
|
|
66
|
+
results.value = [];
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const moveSelection = (delta: number) => {
|
|
70
|
+
if (flatResults.value.length === 0) return;
|
|
71
|
+
selectedIndex.value =
|
|
72
|
+
(selectedIndex.value + delta + flatResults.value.length) % flatResults.value.length;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const selectResult = (result: SearchResult) => {
|
|
76
|
+
if (result.onSelect) {
|
|
77
|
+
result.onSelect();
|
|
78
|
+
close();
|
|
79
|
+
query.value = "";
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const selectCurrent = () => {
|
|
84
|
+
if (flatResults.value.length > 0) {
|
|
85
|
+
selectResult(flatResults.value[selectedIndex.value]);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const performSearch = () => {
|
|
90
|
+
if (!tangramApi) return;
|
|
91
|
+
if (abortController) abortController.abort();
|
|
92
|
+
abortController = new AbortController();
|
|
93
|
+
|
|
94
|
+
results.value = [];
|
|
95
|
+
|
|
96
|
+
if (!query.value.trim() || query.value.length < 2) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
isOpen.value = true;
|
|
101
|
+
tangramApi.search.search(query.value, abortController.signal, newResults => {
|
|
102
|
+
results.value = [...results.value, ...newResults].sort(
|
|
103
|
+
(a, b) => (b.score || 0) - (a.score || 0)
|
|
104
|
+
);
|
|
105
|
+
selectedIndex.value = 0;
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
watch(query, () => {
|
|
110
|
+
if (debounceTimeout) clearTimeout(debounceTimeout);
|
|
111
|
+
debounceTimeout = setTimeout(performSearch, 150);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
const onKeydown = (e: KeyboardEvent) => {
|
|
115
|
+
if (e.key === "p" && (e.ctrlKey || e.metaKey)) {
|
|
116
|
+
e.preventDefault();
|
|
117
|
+
inputRef.value?.focus();
|
|
118
|
+
}
|
|
119
|
+
if (e.key === "Escape") {
|
|
120
|
+
inputRef.value?.blur();
|
|
121
|
+
close();
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const onClickOutside = () => close();
|
|
126
|
+
|
|
127
|
+
onMounted(() => {
|
|
128
|
+
window.addEventListener("keydown", onKeydown);
|
|
129
|
+
window.addEventListener("click", onClickOutside);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
onUnmounted(() => {
|
|
133
|
+
window.removeEventListener("keydown", onKeydown);
|
|
134
|
+
window.removeEventListener("click", onClickOutside);
|
|
135
|
+
});
|
|
136
|
+
</script>
|
|
137
|
+
|
|
138
|
+
<style scoped>
|
|
139
|
+
.palette-widget {
|
|
140
|
+
position: absolute;
|
|
141
|
+
top: 10px;
|
|
142
|
+
right: 10px;
|
|
143
|
+
width: 400px;
|
|
144
|
+
z-index: 2000;
|
|
145
|
+
font-family: "B612", sans-serif;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.search-box {
|
|
149
|
+
background: white;
|
|
150
|
+
border-radius: 8px;
|
|
151
|
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
152
|
+
overflow: hidden;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.search-input {
|
|
156
|
+
width: 100%;
|
|
157
|
+
padding: 10px 12px;
|
|
158
|
+
border: 1px solid #ddd;
|
|
159
|
+
border-radius: 8px;
|
|
160
|
+
outline: none;
|
|
161
|
+
font-size: 14px;
|
|
162
|
+
box-sizing: border-box;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.search-input:focus {
|
|
166
|
+
border-color: #666;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.results-list {
|
|
170
|
+
margin: 4px 0 0 0;
|
|
171
|
+
padding: 0;
|
|
172
|
+
list-style: none;
|
|
173
|
+
background: white;
|
|
174
|
+
border-radius: 8px;
|
|
175
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
176
|
+
max-height: 400px;
|
|
177
|
+
overflow-y: auto;
|
|
178
|
+
border: 1px solid #eee;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.result-item {
|
|
182
|
+
padding: 6px 12px;
|
|
183
|
+
cursor: pointer;
|
|
184
|
+
border-bottom: 1px solid #f5f5f5;
|
|
185
|
+
transition: background-color 0.1s;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.result-item:last-child {
|
|
189
|
+
border-bottom: none;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.result-item.selected,
|
|
193
|
+
.result-item:hover {
|
|
194
|
+
background-color: #f8f9fa;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.is-child {
|
|
198
|
+
border-left: 2px solid #eee;
|
|
199
|
+
}
|
|
200
|
+
</style>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<span>
|
|
3
|
+
<span v-for="(p, i) in parts" :key="i" :class="{ highlight: p.m }">{{ p.t }}</span>
|
|
4
|
+
</span>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
import { computed } from "vue";
|
|
9
|
+
|
|
10
|
+
const props = defineProps<{
|
|
11
|
+
text: string;
|
|
12
|
+
query: string;
|
|
13
|
+
}>();
|
|
14
|
+
|
|
15
|
+
const parts = computed(() => {
|
|
16
|
+
if (!props.query || !props.text) return [{ t: props.text, m: false }];
|
|
17
|
+
const escapedQuery = props.query.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
18
|
+
const r = new RegExp(`(${escapedQuery})`, "gi");
|
|
19
|
+
return props.text
|
|
20
|
+
.split(r)
|
|
21
|
+
.map(t => ({ t, m: t.toLowerCase() === props.query.toLowerCase() }))
|
|
22
|
+
.filter(x => x.t);
|
|
23
|
+
});
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<style scoped>
|
|
27
|
+
.highlight {
|
|
28
|
+
font-weight: 800;
|
|
29
|
+
background: rgba(255, 255, 0, 0.2);
|
|
30
|
+
color: inherit;
|
|
31
|
+
}
|
|
32
|
+
</style>
|