@tileflow/dev 0.1.0-alpha.31 → 0.1.0-alpha.33

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.
@@ -8,7 +8,7 @@ import {
8
8
  import {
9
9
  getTileflowIconWatchPaths,
10
10
  prepareTileflowCatalogIcons
11
- } from "./chunk-IR22ZTQW.js";
11
+ } from "./chunk-QYU4OW5A.js";
12
12
  import {
13
13
  TileflowStyleValidationError,
14
14
  normalizeTileflowStyleValidationIssues,
@@ -666,7 +666,7 @@ function rebindNativeLayerReferences(input, lowered, changes) {
666
666
  if (originalMetadata?.["tileflow:interaction-manifest"] !== void 0) {
667
667
  if (!metadata) throw new Error();
668
668
  const manifest = object(originalMetadata["tileflow:interaction-manifest"]);
669
- if (manifest.version !== 2) throw new Error();
669
+ if (manifest.version !== 3) throw new Error();
670
670
  const domains = object(manifest.domains);
671
671
  let rebound = manifest;
672
672
  if (domains.poi !== void 0) {
@@ -2124,6 +2124,12 @@ async function prepareTileflowHostedNativeDeployment(input) {
2124
2124
  }
2125
2125
 
2126
2126
  // src/artifacts.ts
2127
+ import {
2128
+ tileflowLandmarkRegionOf,
2129
+ tileflowLandmarkRegionZoom,
2130
+ tileflowLandmarkTileOf,
2131
+ tileflowLandmarkTileZoom
2132
+ } from "@tileflow/core";
2127
2133
  var tileflowArtifactPlanSchemaVersion = 1;
2128
2134
  var tileflowArtifactInventoryFileName = ".tileflow-artifacts.json";
2129
2135
  var TileflowHostedManifestOverwriteError = class extends Error {
@@ -2301,6 +2307,7 @@ async function createTileflowArtifactPlan(prepared, options = {}) {
2301
2307
  )
2302
2308
  };
2303
2309
  const partial = {
2310
+ mapAssets: prepared.mapAssets,
2304
2311
  assets,
2305
2312
  buildManifest,
2306
2313
  ...renderer === "native" ? {
@@ -2455,7 +2462,12 @@ function createGenerationArtifactFiles(artifacts, generation, nativeUrls) {
2455
2462
  } : style;
2456
2463
  const replaceFontSources = artifacts.nativeBuild ? replaceTileflowNativeFontSources : replaceTileflowStyleFontSources;
2457
2464
  const generationStyle = replaceFontSources(
2458
- generationStyleWithSprite,
2465
+ withGenerationBuildingModels(
2466
+ generationStyleWithSprite,
2467
+ mapName,
2468
+ generation,
2469
+ artifacts.assets
2470
+ ),
2459
2471
  (source) => retargetLocalFontAssetUrl(source, artifacts.assets, generation)
2460
2472
  );
2461
2473
  if (artifacts.nativeBuild)
@@ -2506,7 +2518,8 @@ function retargetLocalFontAssetUrl(source, assets, generation) {
2506
2518
  function getMapBuildAssets(mapName, assets, fontAssets) {
2507
2519
  const selected = /* @__PURE__ */ new Map();
2508
2520
  for (const asset of assets) {
2509
- if (asset.fileName.startsWith(`icons/${mapName}/`)) selected.set(asset.fileName, asset);
2521
+ if (asset.fileName.startsWith(`icons/${mapName}/`) || asset.fileName.startsWith(`models/${mapName}/`))
2522
+ selected.set(asset.fileName, asset);
2510
2523
  }
2511
2524
  for (const asset of fontAssets) {
2512
2525
  selected.set(asset.fileName, asset);
@@ -2589,6 +2602,27 @@ async function findNearestLockfile(cwd) {
2589
2602
  directory = parent;
2590
2603
  }
2591
2604
  }
2605
+ function withGenerationBuildingModels(style, mapName, generation, assets) {
2606
+ const metadata = style.metadata;
2607
+ const buildings = metadata?.["tileflow:buildings"];
2608
+ if (!buildings || !Array.isArray(buildings.models)) return style;
2609
+ const models = buildings.models.map((entry) => {
2610
+ const url = entry.url;
2611
+ if (typeof url !== "string" || isRelativePublicUrl(url)) return entry;
2612
+ const file = url.slice(url.lastIndexOf("/") + 1);
2613
+ const logical = `models/${mapName}/${file}`;
2614
+ if (!url.endsWith(`/${logical}`) || !assets.some((asset) => asset.fileName === logical))
2615
+ return entry;
2616
+ return {
2617
+ ...entry,
2618
+ url: insertGenerationInPublicUrl(url, logical, generation)
2619
+ };
2620
+ });
2621
+ return {
2622
+ ...style,
2623
+ metadata: { ...metadata, "tileflow:buildings": { ...buildings, models } }
2624
+ };
2625
+ }
2592
2626
  function insertGenerationInPublicUrl(url, logicalPath, generation) {
2593
2627
  const marker = `/${logicalPath}`;
2594
2628
  const index = url.lastIndexOf(marker);
@@ -2939,7 +2973,10 @@ function assertTileflowArtifactFileName(fileName) {
2939
2973
  const logicalName = fileName.replace(/^generations\/[a-f0-9]{64}\//, "");
2940
2974
  const styleMatch = /^styles\/([^/]+)\/([^/]+)\.json$/u.exec(logicalName);
2941
2975
  const iconMatch = /^icons\/([^/]+)\/sprite(?:@2x)?\.(?:json|png)$/u.exec(logicalName);
2942
- if (fileName === "manifest.json" || fileName === tileflowMapBuildManifestFileName || fileName === tileflowNativeBuildRecordFileName || styleMatch && tileflowMapIdSchema.safeParse(styleMatch[1]).success && tileflowThemeNameSchema.safeParse(styleMatch[2]).success || iconMatch && tileflowMapIdSchema.safeParse(iconMatch[1]).success || /^tilesets\/[A-Za-z0-9][A-Za-z0-9._-]{0,127}\.pmtiles$/u.test(logicalName) || /^fonts\/[a-z0-9]+(?:-[a-z0-9]+)*-[a-f0-9]{64}\.(?:otf|ttf|woff2)$/.test(logicalName) || /^fonts\/licenses\/license-[a-f0-9]{64}\.txt$/.test(logicalName)) {
2976
+ const modelMatch = /^models\/([^/]+)\/[a-z0-9]+(?:-[a-z0-9]+)*-[a-f0-9]{16}\.glb$/u.exec(
2977
+ logicalName
2978
+ );
2979
+ if (fileName === "manifest.json" || fileName === tileflowMapBuildManifestFileName || fileName === tileflowNativeBuildRecordFileName || styleMatch && tileflowMapIdSchema.safeParse(styleMatch[1]).success && tileflowThemeNameSchema.safeParse(styleMatch[2]).success || iconMatch && tileflowMapIdSchema.safeParse(iconMatch[1]).success || modelMatch && tileflowMapIdSchema.safeParse(modelMatch[1]).success || /^tilesets\/[A-Za-z0-9][A-Za-z0-9._-]{0,127}\.pmtiles$/u.test(logicalName) || /^fonts\/[a-z0-9]+(?:-[a-z0-9]+)*-[a-f0-9]{64}\.(?:otf|ttf|woff2)$/.test(logicalName) || /^fonts\/licenses\/license-[a-f0-9]{64}\.txt$/.test(logicalName)) {
2943
2980
  return;
2944
2981
  }
2945
2982
  throw new Error(`Unexpected Tileflow managed artifact file name: ${fileName}`);
@@ -3058,5 +3095,9 @@ export {
3058
3095
  disposeTileflowBuildArtifacts,
3059
3096
  writeTileflowArtifactPlan,
3060
3097
  assertNoLocalTilesetsForProduction,
3061
- assertTileflowSelfHostedManifestTarget
3098
+ assertTileflowSelfHostedManifestTarget,
3099
+ tileflowLandmarkRegionOf,
3100
+ tileflowLandmarkRegionZoom,
3101
+ tileflowLandmarkTileOf,
3102
+ tileflowLandmarkTileZoom
3062
3103
  };