@tileflow/core 0.1.0-alpha.33 → 0.1.0-alpha.35

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.
package/dist/runtime.d.ts CHANGED
@@ -1 +1 @@
1
- export { z as TileflowAnalytics, $ as TileflowManifestFetchOptions, a0 as TileflowManifestLoadOptions, a1 as TileflowMapMode, a2 as TileflowMapModeOptions, ae as TileflowResolvedRuntimeTheme, aB as TileflowRuntimeCenterLike, a as TileflowRuntimeColorScheme, T as TileflowRuntimeManifest, aC as TileflowRuntimeManifestMap, b as TileflowRuntimeManifestMapEntry, c as TileflowRuntimeManifestTheme, aD as TileflowRuntimeSource, aE as TileflowRuntimeSourceValidation, aF as TileflowRuntimeStyle, aG as TileflowRuntimeStyleOptions, d as TileflowRuntimeSystemThemes, aH as TileflowRuntimeViewOptions, aI as TileflowSessionController, aJ as TileflowSessionGrantResponse, aM as TileflowStyleFontFace, b5 as TileflowThemeBlendSelection, bc as TileflowThemeSelection, bk as assertValidTileflowRuntimeSource, bl as clearTileflowManifestCache, bn as createTileflowSessionController, bo as createTileflowSessionId, bp as defaultTileflowManifestUrl, bq as defaultTileflowRuntimeView, bs as getTileflowAnalyticsApiUrl, bt as getTileflowStyleFontFaces, bu as inferTileflowAnalyticsFromStyleUrl, bv as loadTileflowManifest, bw as mergeTileflowAnalytics, bx as nearestTileflowBlendTheme, by as normalizeTileflowRuntimeCenter, bz as normalizeTileflowStaticImageSize, bX as normalizeTileflowSurfaceId, bA as normalizeTileflowUrl, bB as resolveTileflowAnalyticsRequestUrl, bC as resolveTileflowManifestMap, bD as resolveTileflowMapMode, bE as resolveTileflowRuntimeStyle, bF as resolveTileflowRuntimeTheme, bG as resolveTileflowRuntimeThemeBlend, bH as resolveTileflowRuntimeView, bI as resolveTileflowStaticImageUrl, bJ as shouldLoadTileflowManifest, bK as startTileflowSession, bM as tileflowStyleFontFaceLimits, bN as tileflowStyleFontFacesMetadataKey, bO as tileflowThemeBlendLimits, bR as validateTileflowRuntimeSource, bS as validateTileflowThemeBlendSelection, bT as validateTileflowThemeSelection } from './manifest-types-E7m23eXL.js';
1
+ export { C as TileflowAnalytics, a2 as TileflowManifestFetchOptions, a3 as TileflowManifestLoadOptions, a4 as TileflowMapMode, a5 as TileflowMapModeOptions, ai as TileflowResolvedRuntimeTheme, aG as TileflowRuntimeCenterLike, a as TileflowRuntimeColorScheme, T as TileflowRuntimeManifest, aH as TileflowRuntimeManifestMap, b as TileflowRuntimeManifestMapEntry, c as TileflowRuntimeManifestTheme, aI as TileflowRuntimeSource, aJ as TileflowRuntimeSourceValidation, aK as TileflowRuntimeStyle, aL as TileflowRuntimeStyleOptions, d as TileflowRuntimeSystemThemes, aM as TileflowRuntimeViewOptions, aN as TileflowSessionController, aO as TileflowSessionGrantResponse, aR as TileflowStyleFontFace, ba as TileflowThemeBlendSelection, bh as TileflowThemeSelection, e as TileflowTimeOfDay, f as TileflowTimeOfDayVariants, bp as assertValidTileflowRuntimeSource, bq as clearTileflowManifestCache, bs as createTileflowSessionController, bt as createTileflowSessionId, bu as defaultTileflowManifestUrl, bv as defaultTileflowRuntimeView, bx as getTileflowAnalyticsApiUrl, by as getTileflowStyleFontFaces, bz as inferTileflowAnalyticsFromStyleUrl, bA as isTileflowTimeOfDay, bB as loadTileflowManifest, bC as mergeTileflowAnalytics, bD as nearestTileflowBlendTheme, bE as normalizeTileflowRuntimeCenter, bF as normalizeTileflowStaticImageSize, c2 as normalizeTileflowSurfaceId, bG as normalizeTileflowUrl, bH as resolveTileflowAnalyticsRequestUrl, bI as resolveTileflowManifestMap, bJ as resolveTileflowMapMode, bK as resolveTileflowRuntimeStyle, bL as resolveTileflowRuntimeTheme, bM as resolveTileflowRuntimeThemeBlend, bN as resolveTileflowRuntimeView, bO as resolveTileflowStaticImageUrl, bP as shouldLoadTileflowManifest, bQ as startTileflowSession, bS as tileflowStyleFontFaceLimits, bT as tileflowStyleFontFacesMetadataKey, bU as tileflowThemeBlendLimits, bW as tileflowTimesOfDay, bY as validateTileflowRuntimeSource, bZ as validateTileflowThemeBlendSelection, b_ as validateTileflowThemeSelection } from './manifest-types-Bzxon3dx.js';
package/dist/runtime.js CHANGED
@@ -29,12 +29,70 @@ var init_portable_identity_rules = __esm({
29
29
  }
30
30
  });
31
31
 
32
+ // src/time-of-day.ts
33
+ function isTileflowTimeOfDay(value) {
34
+ return typeof value === "string" && tileflowTimesOfDay.includes(value);
35
+ }
36
+ function validateTileflowTimeOfDayVariants(variants, themes) {
37
+ const issues = [];
38
+ const owners = /* @__PURE__ */ new Map();
39
+ const families = Object.entries(variants);
40
+ for (const [family, moments] of families) {
41
+ if (!isTileflowThemeName(family) || !Object.hasOwn(themes, family)) {
42
+ issues.push({ path: [family], message: "Time-of-day family must name an existing theme" });
43
+ }
44
+ if (!Object.values(moments).includes(family)) {
45
+ issues.push({ path: [family], message: "A family must include its own theme in its presets" });
46
+ }
47
+ for (const [moment, name] of Object.entries(moments)) {
48
+ if (name === void 0) continue;
49
+ if (!isTileflowTimeOfDay(moment) || !isTileflowThemeName(name) || !Object.hasOwn(themes, name)) {
50
+ issues.push({
51
+ path: [family, moment],
52
+ message: "Expected a supported moment and an existing theme"
53
+ });
54
+ }
55
+ const owner = owners.get(name);
56
+ if (owner !== void 0 && owner !== family) {
57
+ issues.push({
58
+ path: [family, moment],
59
+ message: `Theme "${name}" already belongs to family "${owner}"`
60
+ });
61
+ }
62
+ owners.set(name, family);
63
+ }
64
+ }
65
+ return issues;
66
+ }
67
+ function resolveTileflowTimeOfDayTheme(variants, theme, timeOfDay) {
68
+ if (timeOfDay === void 0 || variants === void 0) return theme;
69
+ if (!isTileflowTimeOfDay(timeOfDay)) throw new TypeError("Expected day, dawn, dusk, or night");
70
+ const family = Object.hasOwn(variants, theme) ? variants[theme] : Object.values(variants).find((moments) => Object.values(moments).includes(theme));
71
+ if (!family) return theme;
72
+ const result = family[timeOfDay];
73
+ if (result === void 0) {
74
+ throw new Error(
75
+ `Theme "${theme}" does not offer timeOfDay="${timeOfDay}". Available: ${Object.keys(family).join(", ")}.`
76
+ );
77
+ }
78
+ return result;
79
+ }
80
+ var tileflowTimesOfDay;
81
+ var init_time_of_day = __esm({
82
+ "src/time-of-day.ts"() {
83
+ "use strict";
84
+ init_portable_identity_rules();
85
+ tileflowTimesOfDay = ["day", "dawn", "dusk", "night"];
86
+ }
87
+ });
88
+
32
89
  // src/manifest-types.ts
33
- var tileflowRuntimeManifestVersion, tileflowRuntimeManifestLimits;
90
+ var tileflowRuntimeManifestVersion, tileflowTimeOfDayManifestVersion, tileflowRuntimeManifestLimits;
34
91
  var init_manifest_types = __esm({
35
92
  "src/manifest-types.ts"() {
36
93
  "use strict";
37
94
  tileflowRuntimeManifestVersion = 1;
95
+ tileflowTimeOfDayManifestVersion = 2;
38
96
  tileflowRuntimeManifestLimits = Object.freeze({ maximumBytes: 1024 * 1024 });
39
97
  }
40
98
  });
@@ -103,6 +161,24 @@ var init_model = __esm({
103
161
  }
104
162
  });
105
163
 
164
+ // src/time-of-day-schema.ts
165
+ function createTileflowTimeOfDaySchema(operations, themeName) {
166
+ return operations.record(
167
+ themeName,
168
+ operations.object({
169
+ day: operations.optional(themeName),
170
+ dawn: operations.optional(themeName),
171
+ dusk: operations.optional(themeName),
172
+ night: operations.optional(themeName)
173
+ })
174
+ );
175
+ }
176
+ var init_time_of_day_schema = __esm({
177
+ "src/time-of-day-schema.ts"() {
178
+ "use strict";
179
+ }
180
+ });
181
+
106
182
  // src/manifest-schema.ts
107
183
  function createTileflowRuntimeManifestSchema(primitives, operations, identities = createPortableIdentitySchemas(operations)) {
108
184
  const { tileflowPortableIdSchema: tileflowPortableIdSchema2, tileflowThemeNameSchema: tileflowThemeNameSchema2 } = identities;
@@ -158,12 +234,24 @@ function createTileflowRuntimeManifestSchema(primitives, operations, identities
158
234
  })
159
235
  ),
160
236
  themes: operations.record(tileflowThemeNameSchema2, manifestThemeSchema),
237
+ timeOfDay: operations.optional(
238
+ createTileflowTimeOfDaySchema(operations, tileflowThemeNameSchema2)
239
+ ),
161
240
  usageMode: operations.optional(operations.literal("session")),
162
241
  view: operations.optional(viewSchema),
163
242
  worldGeneration: operations.optional(operations.literal("v1"))
164
243
  }),
165
244
  (entry, context) => {
166
245
  const names = Object.keys(entry.themes);
246
+ if (entry.timeOfDay) {
247
+ for (const issue of validateTileflowTimeOfDayVariants(entry.timeOfDay, entry.themes)) {
248
+ context.addIssue({
249
+ code: "custom",
250
+ message: issue.message,
251
+ path: ["timeOfDay", ...issue.path]
252
+ });
253
+ }
254
+ }
167
255
  if (names.length === 0) {
168
256
  context.addIssue({
169
257
  code: "custom",
@@ -217,10 +305,23 @@ function createTileflowRuntimeManifestSchema(primitives, operations, identities
217
305
  operations.object({
218
306
  apiUrl: operations.optional(apiOriginSchema),
219
307
  maps: operations.record(tileflowPortableIdSchema2, manifestMapSchema),
220
- version: operations.literal(tileflowRuntimeManifestVersion)
308
+ version: operations.union(
309
+ operations.literal(tileflowRuntimeManifestVersion),
310
+ operations.literal(2)
311
+ )
221
312
  }),
222
313
  (manifest, context) => {
223
314
  const mapCount = Object.keys(manifest.maps).length;
315
+ if (manifest.version === 1) {
316
+ for (const [name, map] of Object.entries(manifest.maps)) {
317
+ if (map.timeOfDay !== void 0)
318
+ context.addIssue({
319
+ code: "custom",
320
+ message: "timeOfDay requires manifest version 2",
321
+ path: ["maps", name, "timeOfDay"]
322
+ });
323
+ }
324
+ }
224
325
  if (mapCount === 0) {
225
326
  context.addIssue({ code: "custom", message: "Expected at least one map", path: ["maps"] });
226
327
  }
@@ -333,6 +434,8 @@ var init_manifest_schema = __esm({
333
434
  init_portable_identity_schema();
334
435
  init_runtime_view_schema();
335
436
  init_model();
437
+ init_time_of_day();
438
+ init_time_of_day_schema();
336
439
  }
337
440
  });
338
441
 
@@ -387,6 +490,7 @@ var init_manifest_schema_classic = __esm({
387
490
  return z2.enum(values);
388
491
  },
389
492
  literal: (value) => z2.literal(value),
493
+ union: (left, right) => z2.union([classic(left), classic(right)]),
390
494
  tuplePair(left, right) {
391
495
  return z2.tuple([classic(left), classic(right)]);
392
496
  },
@@ -422,7 +526,8 @@ __export(manifest_exports, {
422
526
  safeParseTileflowRuntimeManifest: () => safeParseTileflowRuntimeManifest,
423
527
  tileflowRuntimeManifestLimits: () => tileflowRuntimeManifestLimits,
424
528
  tileflowRuntimeManifestSchema: () => tileflowRuntimeManifestSchema,
425
- tileflowRuntimeManifestVersion: () => tileflowRuntimeManifestVersion
529
+ tileflowRuntimeManifestVersion: () => tileflowRuntimeManifestVersion,
530
+ tileflowTimeOfDayManifestVersion: () => tileflowTimeOfDayManifestVersion
426
531
  });
427
532
  function parseTileflowRuntimeManifest(input) {
428
533
  return tileflowRuntimeManifestSchema.parse(input);
@@ -451,6 +556,8 @@ var init_manifest = __esm({
451
556
 
452
557
  // src/runtime.ts
453
558
  init_portable_identity_rules();
559
+ init_time_of_day();
560
+ init_time_of_day();
454
561
  var defaultTileflowManifestUrl = "/tileflow/manifest.json";
455
562
  var defaultTileflowRuntimeView = Object.freeze({
456
563
  bearing: 0,
@@ -532,7 +639,8 @@ function resolveTileflowRuntimeStyle(options) {
532
639
  const theme = resolveTileflowRuntimeTheme(
533
640
  options.manifestMap,
534
641
  options.theme,
535
- options.colorScheme
642
+ options.colorScheme,
643
+ options.timeOfDay
536
644
  );
537
645
  return {
538
646
  analytics: {
@@ -549,7 +657,7 @@ function resolveTileflowRuntimeStyle(options) {
549
657
  }
550
658
  return null;
551
659
  }
552
- function resolveTileflowRuntimeTheme(map, selection, colorScheme) {
660
+ function resolveTileflowRuntimeTheme(map, selection, colorScheme, timeOfDay) {
553
661
  let name;
554
662
  if (selection === void 0) {
555
663
  name = map.defaultTheme;
@@ -571,6 +679,8 @@ function resolveTileflowRuntimeTheme(map, selection, colorScheme) {
571
679
  `Tileflow resolved invalid theme ${JSON.stringify(name)} for map "${map.name}"; expected a concrete portable theme name.`
572
680
  );
573
681
  }
682
+ if (Object.hasOwn(map.themes, name))
683
+ name = resolveTileflowTimeOfDayTheme(map.timeOfDay, name, timeOfDay);
574
684
  const theme = Object.hasOwn(map.themes, name) ? map.themes[name] : void 0;
575
685
  if (!theme) {
576
686
  const available = Object.keys(map.themes).sort().join(", ");
@@ -1106,6 +1216,7 @@ function resolveTileflowManifestMap(manifest, mapName) {
1106
1216
  defaultTheme: entry.defaultTheme,
1107
1217
  ...entry.environment ? { environment: entry.environment } : {},
1108
1218
  ...entry.systemThemes ? { systemThemes: { ...entry.systemThemes } } : {},
1219
+ ...entry.timeOfDay ? { timeOfDay: entry.timeOfDay } : {},
1109
1220
  themes: entry.themes,
1110
1221
  usageMode: entry.usageMode,
1111
1222
  view: entry.view,
@@ -1123,7 +1234,12 @@ function resolveTileflowStaticImageUrl(input) {
1123
1234
  const apiUrl = normalizeTileflowUrl(input.manifestMap.apiUrl ?? "https://api.tileflow.dev");
1124
1235
  const mapId = encodeURIComponent(input.manifestMap.mapId);
1125
1236
  const url = new URL(`/maps/${mapId}/static.png`, apiUrl);
1126
- const theme = resolveTileflowRuntimeTheme(input.manifestMap, input.theme, input.colorScheme);
1237
+ const theme = resolveTileflowRuntimeTheme(
1238
+ input.manifestMap,
1239
+ input.theme,
1240
+ input.colorScheme,
1241
+ input.timeOfDay
1242
+ );
1127
1243
  url.searchParams.set("center", input.center.join(","));
1128
1244
  url.searchParams.set("theme", theme.name);
1129
1245
  url.searchParams.set("zoom", String(input.zoom));
@@ -1291,6 +1407,7 @@ export {
1291
1407
  getTileflowAnalyticsApiUrl,
1292
1408
  getTileflowStyleFontFaces,
1293
1409
  inferTileflowAnalyticsFromStyleUrl,
1410
+ isTileflowTimeOfDay,
1294
1411
  loadTileflowManifest,
1295
1412
  mergeTileflowAnalytics,
1296
1413
  nearestTileflowBlendTheme,
@@ -1311,6 +1428,7 @@ export {
1311
1428
  tileflowStyleFontFaceLimits,
1312
1429
  tileflowStyleFontFacesMetadataKey,
1313
1430
  tileflowThemeBlendLimits,
1431
+ tileflowTimesOfDay,
1314
1432
  validateTileflowRuntimeSource,
1315
1433
  validateTileflowThemeBlendSelection,
1316
1434
  validateTileflowThemeSelection
@@ -74,6 +74,9 @@ state on the map.
74
74
  - **Requests.** `transformRequest` rewrites each request as a MapLibre map's option does. Pass the
75
75
  map's own so tile reads follow the same rules. The browser's HTTP cache applies as for any
76
76
  request.
77
+ - **Archives.** A source served from a Tileflow PMTiles archive (a `tileflow-pmtiles://` address)
78
+ is read through Core's PMTiles protocol, sharing the archives the page's map has opened. A
79
+ `fetch` of your own replaces both.
77
80
 
78
81
  The reader has no DOM dependency, so it also runs in a module worker: post the tile address and
79
82
  zooms to the worker and create the reader there. `decodeTileflowVectorTile(bytes, {layers})`
@@ -89,7 +89,8 @@ TypeScript imports.
89
89
 
90
90
  `icons` is an intentional exception to implicit array composition: omission inherits the exact
91
91
  parent array, any declaration replaces it atomically, and `[]` disables map icons. Compose with a
92
- spread when the child should keep a parent's directories. `fonts` and `glyphs` are mutually
92
+ spread when the child should keep a parent's directories. `models`, the directories of a map's own
93
+ 3D models, follows the same rule. `fonts` and `glyphs` are mutually
93
94
  exclusive text providers; declaring either atomically replaces an inherited provider of either
94
95
  kind. Unknown keys and former compatibility shapes are rejected.
95
96
 
@@ -214,6 +215,10 @@ surveyed isoline. `water({bathymetryLabels: {}})` separately opts into numeric m
214
215
  from each polygon's absolute minimum band depth. Existing maps gain neither detail by default, and
215
216
  sources without bathymetry bindings omit both requested layers. These labels describe coarse band
216
217
  floors, not measured survey soundings, and must not be presented as hydrographic sounding data.
218
+ An explicitly selected Bathymetry source can instead declare `vectorLayers.contours: true` to use
219
+ real contour lines and their `depth` values. Its optional named seafloor and water features have
220
+ separate `water.bathymetryLandforms` and `water.bathymetryWaterNames` styles, with the language
221
+ selected by `labels(...)`. See [the marine source contract](data-is-separate-from-design.md#declare-contour-and-name-layers).
217
222
 
218
223
  `addresses` renders the standard OpenMapTiles `housenumber` points at detailed zooms and exposes a
219
224
  single semantic `labels` style. `landforms` renders the standard `mountain_peak` classes (`peak`,