@tileflow/dev 0.1.0-alpha.35 → 0.1.0-alpha.37

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,19 +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
- import {attachTileflowNotices} from "${basePath}/__runtime/tileflow-browser.js";
278
+ import {attachTileflowNauticalLights, attachTileflowNotices} from "${basePath}/__runtime/tileflow-browser.js";
279
+ import {attachTileflowAtmosphere, tileflowMaxPitch} from "${basePath}/__runtime/tileflow-browser.js";
280
+ import {tileflowCanvasContextAttributes} from "${basePath}/__runtime/tileflow-browser.js";
300
281
  import {createTileflowMap3D} from "${basePath}/__runtime/tileflow-browser.js";
301
282
  import {readTileflowSunPreset, resolveTileflowSun, tileflowDefaultSunPreset} from "${basePath}/__runtime/tileflow-browser.js";
302
283
 
303
284
  maplibregl.setWorkerUrl("${basePath}/__runtime/maplibre-gl-worker.mjs");
304
285
 
305
- const devtoolsObserver = window.parent !== window ? createPreviewObserver() : undefined;
306
- globalThis.__tileflowDevtoolsObserver = devtoolsObserver;
307
- 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";
308
289
 
309
290
  const initialStatus = ${JSON.stringify(initialStatus)};
310
291
  const readBoundedTileflowResponse = ${readBoundedTileflowResponse.toString()};
@@ -338,6 +319,8 @@ function renderTileflowPreviewHtml(preview, basePath, initialStatus, isSemanticP
338
319
  requestedMapWorkerCount <= 3
339
320
  ? requestedMapWorkerCount
340
321
  : undefined;
322
+ // Benchmarks compare the multisampled canvas with a single-sampled one through this override.
323
+ const mapAntialias = readToggleFromUrl("mapAntialias", true);
341
324
  const mapBenchmarkLongitude = Number(previewSearchParameters.get("lng"));
342
325
  const mapBenchmarkLatitude = Number(previewSearchParameters.get("lat"));
343
326
  const mapBenchmarkCenter =
@@ -863,49 +846,6 @@ function renderTileflowPreviewHtml(preview, basePath, initialStatus, isSemanticP
863
846
  history.replaceState(history.state, "", url.href);
864
847
  }
865
848
 
866
- function updateGlobeBackdrop(map) {
867
- // getProjection reads the style's projection without serializing the style.
868
- const projection = map.getProjection
869
- ? map.getProjection()?.type
870
- : map.getStyle?.()?.projection?.type;
871
- const container = map.getContainer?.();
872
- if (!container || !projection) return;
873
- if (projection !== "globe") {
874
- container.classList.remove("tileflow-globe");
875
- return;
876
- }
877
-
878
- container.classList.add("tileflow-globe");
879
- applyAtmosphereBackdrop(map, container);
880
- }
881
-
882
- // Uses the map's declared atmosphere for the preview's space and rim, so a themed globe shows
883
- // its own colours; maps without one keep the default backdrop.
884
- function applyAtmosphereBackdrop(map, container) {
885
- const atmosphere = styleReads(map).metadata()?.["tileflow:atmosphere"];
886
- const rgba = (hex, alpha) => {
887
- const match = /^#([0-9a-f]{6})$/i.exec(String(hex ?? ""));
888
- if (!match) return undefined;
889
- const value = Number.parseInt(match[1], 16);
890
- return "rgba(" + (value >> 16) + ", " + ((value >> 8) & 255) + ", " + (value & 255) + ", " + alpha + ")";
891
- };
892
- // Use the rendered canvas alpha, as the shared browser atmosphere does.
893
- // A zoom-only circle cannot track the globe's latitude, viewport or pitch.
894
- const opacity = Math.max(0, Math.min(1, (6 - map.getZoom()) / 3));
895
- const core = rgba(atmosphere?.horizonColor ?? "#F8FCFF", opacity * 0.65);
896
- const glow = rgba(atmosphere?.horizonColor ?? "#B0DCF6", opacity * 0.4);
897
- const properties = {
898
- "--tileflow-space": rgba(atmosphere?.spaceColor, 1),
899
- "--tileflow-globe-rim": opacity > 0
900
- ? "drop-shadow(0 0 2px " + core + ") drop-shadow(0 0 12px " + glow + ")"
901
- : "none",
902
- };
903
- for (const [name, value] of Object.entries(properties)) {
904
- if (value) container.style.setProperty(name, value);
905
- else container.style.removeProperty(name);
906
- }
907
- }
908
-
909
849
  function createBuildingWireframeLayer(map, styleLayer) {
910
850
  const maximumBuildings = 10000;
911
851
  const maximumSegments = 300000;
@@ -1684,7 +1624,7 @@ function renderTileflowPreviewHtml(preview, basePath, initialStatus, isSemanticP
1684
1624
  const groups = previewLayerGroups(layer);
1685
1625
  const hideLayer = groups.some((group) => !visibleLayerGroups.has(group));
1686
1626
  // Group controls only own the properties they mask. Ordinary style events must
1687
- // preserve temporary DevTools edits, including visibility and label text.
1627
+ // preserve temporary Inspector edits, including visibility and label text.
1688
1628
  if (hideLayer && !defaultLayerVisibility.has(layer.id)) {
1689
1629
  defaultLayerVisibility.set(layer.id, map.getLayoutProperty(layer.id, "visibility") || "visible");
1690
1630
  }
@@ -1736,15 +1676,20 @@ function renderTileflowPreviewHtml(preview, basePath, initialStatus, isSemanticP
1736
1676
  registerTileflowContourProtocol({addProtocol: maplibregl.addProtocol});
1737
1677
  registerTileflowPmtilesProtocol({addProtocol: maplibregl.addProtocol});
1738
1678
  const map = new maplibregl.Map({
1739
- collectResourceTiming: mapBenchmarkEnabled || Boolean(devtoolsObserver),
1679
+ canvasContextAttributes: tileflowCanvasContextAttributes({antialias: mapAntialias}),
1680
+ collectResourceTiming: mapBenchmarkEnabled || Boolean(inspectorObserver),
1740
1681
  container: "map",
1682
+ maxPitch: tileflowMaxPitch,
1741
1683
  style: styleUrl,
1742
1684
  transformRequest: previewTransformRequest,
1743
1685
  ...resolveInitialMapOptions(previewMapOptions)
1744
1686
  });
1745
1687
  globalThis.__tileflowPreviewMap = map;
1746
1688
  attachTileflowNotices(map);
1747
- devtoolsObserver?.attach(map);
1689
+ attachTileflowNauticalLights(map);
1690
+ attachTileflowAtmosphere(map);
1691
+ attachTileflowLabelPlacement(map);
1692
+ inspectorObserver?.attach(map);
1748
1693
  installMapBenchmark(map);
1749
1694
  if (window.parent === window) map.addControl(new maplibregl.NavigationControl(), "top-right");
1750
1695
  let threeDimensionalControl;
@@ -1754,14 +1699,14 @@ function renderTileflowPreviewHtml(preview, basePath, initialStatus, isSemanticP
1754
1699
  treeControl = new TreeControl();
1755
1700
  map.addControl(threeDimensionalControl, "top-right");
1756
1701
  map.addControl(treeControl, "top-right");
1757
- // Embedded Map DevTools owns the common Controls sidebar. Keep the controls mounted
1702
+ // Embedded Inspector owns the common Controls sidebar. Keep the controls mounted
1758
1703
  // for their renderer lifecycle and message bridge, but remove duplicate buttons.
1759
1704
  if (window.parent !== window) {
1760
1705
  threeDimensionalControl.container.hidden = true;
1761
1706
  treeControl.container.hidden = true;
1762
1707
  }
1763
1708
  }
1764
- // 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
1765
1710
  // cycling button for standalone previews only.
1766
1711
  if (previewThemes.length > 1 && window.parent === window) map.addControl(new ThemeControl(), "top-right");
1767
1712
  let ensuringThreeDimensionalLayers;
@@ -1805,11 +1750,8 @@ function renderTileflowPreviewHtml(preview, basePath, initialStatus, isSemanticP
1805
1750
  mountCoreScene(map);
1806
1751
  treeControl?.update();
1807
1752
  writeCameraToUrl(map);
1808
- updateGlobeBackdrop(map);
1809
1753
  ensureThreeDimensionalLayers();
1810
1754
  });
1811
- map.on("move", () => updateGlobeBackdrop(map));
1812
- map.on("style.load", () => updateGlobeBackdrop(map));
1813
1755
  map.on("moveend", () => writeCameraToUrl(map));
1814
1756
  ${previewSceneClient}
1815
1757
  addEventListener("message", (event) => {
@@ -1886,7 +1828,7 @@ function renderTileflowPreviewHtml(preview, basePath, initialStatus, isSemanticP
1886
1828
  // six HTTP/1 connections and leave even local module/font requests waiting indefinitely.
1887
1829
  let unsubscribePreviewStatus;
1888
1830
  try {
1889
- if (window.parent !== window) unsubscribePreviewStatus = window.parent.__tileflowDevtoolsHost?.subscribePreviewStatus?.(window, applyStatus);
1831
+ if (window.parent !== window) unsubscribePreviewStatus = window.parent.__tileflowInspectorHost?.subscribePreviewStatus?.(window, applyStatus);
1890
1832
  } catch { /* Other embedders keep the standalone stream. */ }
1891
1833
  if (unsubscribePreviewStatus) {
1892
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