@tileflow/dev 0.1.0-alpha.36 → 0.1.0-alpha.38

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.
@@ -1,4 +1,4 @@
1
- // src/devtools/observer.ts
1
+ // src/inspector/observer.ts
2
2
  function resourceAddress(input, base = "http://localhost") {
3
3
  try {
4
4
  const url = new URL(input.replace(/^(?:tileflow-pmtiles|pmtiles):\/\//u, ""), base);
@@ -12,9 +12,9 @@ var localTileflowBrowserJavaScript;
12
12
  var localThreeCoreJavaScript;
13
13
  var localThreeModuleJavaScript;
14
14
  function getTileflowPreviewRuntimeResponse(path) {
15
- if (path === "/__runtime/devtools-observer.js") {
15
+ if (path === "/__runtime/inspector-observer.js") {
16
16
  return textAssetResponse(
17
- readFileSync(new URL("../dist/devtools-observer.js", import.meta.url), "utf8"),
17
+ readFileSync(new URL("../dist/inspector-observer.js", import.meta.url), "utf8"),
18
18
  "text/javascript; charset=utf-8"
19
19
  );
20
20
  }
package/dist/preview.js CHANGED
@@ -205,29 +205,7 @@ function renderTileflowPreviewHtml(preview, basePath, initialStatus, isSemanticP
205
205
  <style>
206
206
  ${viewportCss}
207
207
  body { font-family: ui-sans-serif, system-ui, sans-serif; }
208
- #map {
209
- background-color: var(--tileflow-space, #2F5070);
210
- background-image:
211
- radial-gradient(circle at 18% 24%, rgba(225, 240, 250, 0.34) 0 1px, transparent 1.4px),
212
- radial-gradient(circle at 72% 62%, rgba(225, 240, 250, 0.22) 0 1px, transparent 1.3px),
213
- radial-gradient(circle at 42% 78%, rgba(225, 240, 250, 0.18) 0 0.8px, transparent 1.2px);
214
- background-position: 0 0, 37px 71px, 113px 29px;
215
- background-size: 173px 149px, 257px 211px, 337px 283px;
216
- }
217
- #map.tileflow-globe {
218
- position: relative;
219
- background-image:
220
- radial-gradient(circle at 18% 24%, rgba(225, 240, 250, 0.34) 0 1px, transparent 1.4px),
221
- radial-gradient(circle at 72% 62%, rgba(225, 240, 250, 0.22) 0 1px, transparent 1.3px),
222
- radial-gradient(circle at 42% 78%, rgba(225, 240, 250, 0.18) 0 0.8px, transparent 1.2px);
223
- }
224
- #map.tileflow-globe .maplibregl-canvas {
225
- filter: var(--tileflow-globe-rim, none);
226
- }
227
- #map.tileflow-globe > .maplibregl-canvas-container {
228
- position: relative;
229
- z-index: 1;
230
- }
208
+ #map { position: relative; }
231
209
  .badge {
232
210
  display: none;
233
211
  position: fixed;
@@ -256,7 +234,7 @@ function renderTileflowPreviewHtml(preview, basePath, initialStatus, isSemanticP
256
234
  padding: 12px;
257
235
  white-space: pre-wrap;
258
236
  }
259
- html[data-devtools-embedded=true] .status { display:none !important; }
237
+ html[data-inspector-embedded=true] .status { display:none !important; }
260
238
  .maplibregl-ctrl-group .tileflow-3d-toggle,
261
239
  .maplibregl-ctrl-group .tileflow-tree-toggle,
262
240
  .maplibregl-ctrl-group .tileflow-theme-toggle {
@@ -292,21 +270,22 @@ function renderTileflowPreviewHtml(preview, basePath, initialStatus, isSemanticP
292
270
  <script type="importmap">{"imports":{"three":"${basePath}/__runtime/three.module.js"}}</script>
293
271
  <script type="module">
294
272
  import * as maplibregl from "${basePath}/__runtime/maplibre-gl.mjs";
295
- import {createPreviewObserver} from "${basePath}/__runtime/devtools-observer.js";
273
+ import {createPreviewObserver} from "${basePath}/__runtime/inspector-observer.js";
296
274
  import {loadTileflowStyleFonts} from "${basePath}/__runtime/tileflow-browser.js";
275
+ import {attachTileflowLabelPlacement} from "${basePath}/__runtime/tileflow-browser.js";
297
276
  import {registerTileflowContourProtocol} from "${basePath}/__runtime/tileflow-browser.js";
298
277
  import {registerTileflowPmtilesProtocol} from "${basePath}/__runtime/tileflow-browser.js";
299
278
  import {attachTileflowNauticalLights, attachTileflowNotices} from "${basePath}/__runtime/tileflow-browser.js";
300
- import {attachTileflowSky, attachTileflowSkyHaze, tileflowMaxPitch} from "${basePath}/__runtime/tileflow-browser.js";
279
+ import {attachTileflowAtmosphere, tileflowMaxPitch} from "${basePath}/__runtime/tileflow-browser.js";
301
280
  import {tileflowCanvasContextAttributes} from "${basePath}/__runtime/tileflow-browser.js";
302
281
  import {createTileflowMap3D} from "${basePath}/__runtime/tileflow-browser.js";
303
282
  import {readTileflowSunPreset, resolveTileflowSun, tileflowDefaultSunPreset} from "${basePath}/__runtime/tileflow-browser.js";
304
283
 
305
284
  maplibregl.setWorkerUrl("${basePath}/__runtime/maplibre-gl-worker.mjs");
306
285
 
307
- const devtoolsObserver = window.parent !== window ? createPreviewObserver() : undefined;
308
- globalThis.__tileflowDevtoolsObserver = devtoolsObserver;
309
- if (window.parent !== window) document.documentElement.dataset.devtoolsEmbedded = "true";
286
+ const inspectorObserver = window.parent !== window ? createPreviewObserver() : undefined;
287
+ globalThis.__tileflowInspectorObserver = inspectorObserver;
288
+ if (window.parent !== window) document.documentElement.dataset.inspectorEmbedded = "true";
310
289
 
311
290
  const initialStatus = ${JSON.stringify(initialStatus)};
312
291
  const readBoundedTileflowResponse = ${readBoundedTileflowResponse.toString()};
@@ -867,49 +846,6 @@ function renderTileflowPreviewHtml(preview, basePath, initialStatus, isSemanticP
867
846
  history.replaceState(history.state, "", url.href);
868
847
  }
869
848
 
870
- function updateGlobeBackdrop(map) {
871
- // getProjection reads the style's projection without serializing the style.
872
- const projection = map.getProjection
873
- ? map.getProjection()?.type
874
- : map.getStyle?.()?.projection?.type;
875
- const container = map.getContainer?.();
876
- if (!container || !projection) return;
877
- if (projection !== "globe") {
878
- container.classList.remove("tileflow-globe");
879
- return;
880
- }
881
-
882
- container.classList.add("tileflow-globe");
883
- applyAtmosphereBackdrop(map, container);
884
- }
885
-
886
- // Uses the map's declared atmosphere for the preview's space and rim, so a themed globe shows
887
- // its own colours; maps without one keep the default backdrop.
888
- function applyAtmosphereBackdrop(map, container) {
889
- const atmosphere = styleReads(map).metadata()?.["tileflow:atmosphere"];
890
- const rgba = (hex, alpha) => {
891
- const match = /^#([0-9a-f]{6})$/i.exec(String(hex ?? ""));
892
- if (!match) return undefined;
893
- const value = Number.parseInt(match[1], 16);
894
- return "rgba(" + (value >> 16) + ", " + ((value >> 8) & 255) + ", " + (value & 255) + ", " + alpha + ")";
895
- };
896
- // Use the rendered canvas alpha, as the shared browser atmosphere does.
897
- // A zoom-only circle cannot track the globe's latitude, viewport or pitch.
898
- const opacity = Math.max(0, Math.min(1, (6 - map.getZoom()) / 3));
899
- const core = rgba(atmosphere?.horizonColor ?? "#F8FCFF", opacity * 0.65);
900
- const glow = rgba(atmosphere?.horizonColor ?? "#B0DCF6", opacity * 0.4);
901
- const properties = {
902
- "--tileflow-space": rgba(atmosphere?.spaceColor, 1),
903
- "--tileflow-globe-rim": opacity > 0
904
- ? "drop-shadow(0 0 2px " + core + ") drop-shadow(0 0 12px " + glow + ")"
905
- : "none",
906
- };
907
- for (const [name, value] of Object.entries(properties)) {
908
- if (value) container.style.setProperty(name, value);
909
- else container.style.removeProperty(name);
910
- }
911
- }
912
-
913
849
  function createBuildingWireframeLayer(map, styleLayer) {
914
850
  const maximumBuildings = 10000;
915
851
  const maximumSegments = 300000;
@@ -1688,7 +1624,7 @@ function renderTileflowPreviewHtml(preview, basePath, initialStatus, isSemanticP
1688
1624
  const groups = previewLayerGroups(layer);
1689
1625
  const hideLayer = groups.some((group) => !visibleLayerGroups.has(group));
1690
1626
  // Group controls only own the properties they mask. Ordinary style events must
1691
- // preserve temporary DevTools edits, including visibility and label text.
1627
+ // preserve temporary Inspector edits, including visibility and label text.
1692
1628
  if (hideLayer && !defaultLayerVisibility.has(layer.id)) {
1693
1629
  defaultLayerVisibility.set(layer.id, map.getLayoutProperty(layer.id, "visibility") || "visible");
1694
1630
  }
@@ -1741,7 +1677,7 @@ function renderTileflowPreviewHtml(preview, basePath, initialStatus, isSemanticP
1741
1677
  registerTileflowPmtilesProtocol({addProtocol: maplibregl.addProtocol});
1742
1678
  const map = new maplibregl.Map({
1743
1679
  canvasContextAttributes: tileflowCanvasContextAttributes({antialias: mapAntialias}),
1744
- collectResourceTiming: mapBenchmarkEnabled || Boolean(devtoolsObserver),
1680
+ collectResourceTiming: mapBenchmarkEnabled || Boolean(inspectorObserver),
1745
1681
  container: "map",
1746
1682
  maxPitch: tileflowMaxPitch,
1747
1683
  style: styleUrl,
@@ -1751,9 +1687,9 @@ function renderTileflowPreviewHtml(preview, basePath, initialStatus, isSemanticP
1751
1687
  globalThis.__tileflowPreviewMap = map;
1752
1688
  attachTileflowNotices(map);
1753
1689
  attachTileflowNauticalLights(map);
1754
- attachTileflowSky(map);
1755
- attachTileflowSkyHaze(map);
1756
- devtoolsObserver?.attach(map);
1690
+ attachTileflowAtmosphere(map);
1691
+ attachTileflowLabelPlacement(map);
1692
+ inspectorObserver?.attach(map);
1757
1693
  installMapBenchmark(map);
1758
1694
  if (window.parent === window) map.addControl(new maplibregl.NavigationControl(), "top-right");
1759
1695
  let threeDimensionalControl;
@@ -1763,14 +1699,14 @@ function renderTileflowPreviewHtml(preview, basePath, initialStatus, isSemanticP
1763
1699
  treeControl = new TreeControl();
1764
1700
  map.addControl(threeDimensionalControl, "top-right");
1765
1701
  map.addControl(treeControl, "top-right");
1766
- // Embedded Map DevTools owns the common Controls sidebar. Keep the controls mounted
1702
+ // Embedded Inspector owns the common Controls sidebar. Keep the controls mounted
1767
1703
  // for their renderer lifecycle and message bridge, but remove duplicate buttons.
1768
1704
  if (window.parent !== window) {
1769
1705
  threeDimensionalControl.container.hidden = true;
1770
1706
  treeControl.container.hidden = true;
1771
1707
  }
1772
1708
  }
1773
- // Map DevTools has a shared theme selector in its Controls panel; keep the map-level
1709
+ // Inspector has a shared theme selector in its Controls panel; keep the map-level
1774
1710
  // cycling button for standalone previews only.
1775
1711
  if (previewThemes.length > 1 && window.parent === window) map.addControl(new ThemeControl(), "top-right");
1776
1712
  let ensuringThreeDimensionalLayers;
@@ -1814,11 +1750,8 @@ function renderTileflowPreviewHtml(preview, basePath, initialStatus, isSemanticP
1814
1750
  mountCoreScene(map);
1815
1751
  treeControl?.update();
1816
1752
  writeCameraToUrl(map);
1817
- updateGlobeBackdrop(map);
1818
1753
  ensureThreeDimensionalLayers();
1819
1754
  });
1820
- map.on("move", () => updateGlobeBackdrop(map));
1821
- map.on("style.load", () => updateGlobeBackdrop(map));
1822
1755
  map.on("moveend", () => writeCameraToUrl(map));
1823
1756
  ${previewSceneClient}
1824
1757
  addEventListener("message", (event) => {
@@ -1895,7 +1828,7 @@ function renderTileflowPreviewHtml(preview, basePath, initialStatus, isSemanticP
1895
1828
  // six HTTP/1 connections and leave even local module/font requests waiting indefinitely.
1896
1829
  let unsubscribePreviewStatus;
1897
1830
  try {
1898
- if (window.parent !== window) unsubscribePreviewStatus = window.parent.__tileflowDevtoolsHost?.subscribePreviewStatus?.(window, applyStatus);
1831
+ if (window.parent !== window) unsubscribePreviewStatus = window.parent.__tileflowInspectorHost?.subscribePreviewStatus?.(window, applyStatus);
1899
1832
  } catch { /* Other embedders keep the standalone stream. */ }
1900
1833
  if (unsubscribePreviewStatus) {
1901
1834
  addEventListener("beforeunload", unsubscribePreviewStatus);
package/dist/server.d.ts CHANGED
@@ -37,7 +37,7 @@ type TileflowComparisonOptions = {
37
37
  };
38
38
  };
39
39
  /**
40
- * Compose one or two existing Tileflow dev handlers behind the same-origin Map DevTools.
40
+ * Compose one or two existing Tileflow dev handlers behind the same-origin Inspector.
41
41
  *
42
42
  * The side handlers retain ownership of styles, sprites, fonts, generations, live
43
43
  * events, and last-known-good behavior. This router owns only the shell document and