@tileflow/core 0.1.0-alpha.24 → 0.1.0-alpha.25

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.
@@ -0,0 +1,31 @@
1
+ /** URL resolution for native clients, without a renderer or an ambient application origin. */
2
+ declare const tileflowNativeUrlLimits: Readonly<{
3
+ maximumLength: 2048;
4
+ }>;
5
+ type TileflowNativeNetworkOptions = {
6
+ /** An exact HTTP development origin; never inferred from the device or environment. */
7
+ developmentOrigin?: string;
8
+ };
9
+ type TileflowNativeResourceUrlOptions = TileflowNativeNetworkOptions & {
10
+ /** The absolute URL of the document declaring this resource, after any approved redirects. */
11
+ documentUrl: string;
12
+ /** Preserve supported placeholders in the path or query, without expanding them. */
13
+ template?: 'tile' | 'glyphs';
14
+ };
15
+ type TileflowNativeUrlErrorCode = 'NATIVE_URL_INVALID' | 'NATIVE_URL_ABSOLUTE_REQUIRED' | 'NATIVE_URL_HTTPS_REQUIRED' | 'NATIVE_URL_DEVELOPMENT_ORIGIN_INVALID' | 'NATIVE_URL_TEMPLATE_INVALID';
16
+ type TileflowNativeUrlField = 'manifestUrl' | 'documentUrl' | 'resourceUrl' | 'developmentOrigin';
17
+ /** Safe to report without exposing URL credentials, query parameters or filesystem paths. */
18
+ declare class TileflowNativeUrlError extends TypeError {
19
+ readonly code: TileflowNativeUrlErrorCode;
20
+ readonly field: TileflowNativeUrlField;
21
+ constructor(code: TileflowNativeUrlErrorCode, field: TileflowNativeUrlField);
22
+ }
23
+ /** Resolve a native manifest URL. There is intentionally no browser-relative default. */
24
+ declare function resolveTileflowNativeManifestUrl(value: unknown, options?: TileflowNativeNetworkOptions): string;
25
+ /**
26
+ * Resolve a resource against its owning manifest, style or TileJSON document.
27
+ * This checks URL policy only: it neither fetches resources nor authorizes requests.
28
+ */
29
+ declare function resolveTileflowNativeResourceUrl(value: unknown, options: TileflowNativeResourceUrlOptions): string;
30
+
31
+ export { type TileflowNativeNetworkOptions, type TileflowNativeResourceUrlOptions, TileflowNativeUrlError, type TileflowNativeUrlErrorCode, type TileflowNativeUrlField, resolveTileflowNativeManifestUrl, resolveTileflowNativeResourceUrl, tileflowNativeUrlLimits };
package/dist/native.js ADDED
@@ -0,0 +1,143 @@
1
+ // src/native.ts
2
+ var tileflowNativeUrlLimits = Object.freeze({ maximumLength: 2048 });
3
+ var errorMessages = {
4
+ NATIVE_URL_INVALID: "Expected a bounded HTTP(S) URL without credentials, fragments or backslashes.",
5
+ NATIVE_URL_ABSOLUTE_REQUIRED: "An explicit absolute HTTP(S) document URL is required.",
6
+ NATIVE_URL_HTTPS_REQUIRED: "HTTP is allowed only at the explicitly configured development origin.",
7
+ NATIVE_URL_DEVELOPMENT_ORIGIN_INVALID: "Expected one HTTP origin without a path, credentials, query or fragment.",
8
+ NATIVE_URL_TEMPLATE_INVALID: "Expected supported URL placeholders in the resource path or query only."
9
+ };
10
+ var TileflowNativeUrlError = class extends TypeError {
11
+ code;
12
+ field;
13
+ constructor(code, field) {
14
+ super(errorMessages[code]);
15
+ this.name = "TileflowNativeUrlError";
16
+ this.code = code;
17
+ this.field = field;
18
+ }
19
+ };
20
+ var tilePlaceholders = /* @__PURE__ */ new Set(["z", "x", "y", "ratio", "quadkey", "bbox-epsg-3857", "prefix"]);
21
+ var glyphPlaceholders = /* @__PURE__ */ new Set(["fontstack", "range"]);
22
+ var absoluteHttpPattern = /^https?:\/\/[^/?#]+/iu;
23
+ var schemePattern = /^[a-z][a-z\d+.-]*:/iu;
24
+ function resolveTileflowNativeManifestUrl(value, options = {}) {
25
+ assertOptionsObject(options, "developmentOrigin");
26
+ const developmentOrigin = resolveDevelopmentOrigin(options.developmentOrigin);
27
+ return resolveDocumentUrl(value, "manifestUrl", developmentOrigin).href;
28
+ }
29
+ function resolveTileflowNativeResourceUrl(value, options) {
30
+ assertOptionsObject(options, "documentUrl");
31
+ const developmentOrigin = resolveDevelopmentOrigin(options.developmentOrigin);
32
+ const document = resolveDocumentUrl(options.documentUrl, "documentUrl", developmentOrigin);
33
+ assertUrlText(value, "resourceUrl");
34
+ if (options.template !== void 0 && options.template !== "tile" && options.template !== "glyphs") {
35
+ throw new TileflowNativeUrlError("NATIVE_URL_TEMPLATE_INVALID", "resourceUrl");
36
+ }
37
+ assertReferenceSyntax(value, "resourceUrl", false);
38
+ const authority = absoluteHttpPattern.exec(value)?.[0];
39
+ if (authority && /[{}]/u.test(authority)) {
40
+ throw new TileflowNativeUrlError("NATIVE_URL_TEMPLATE_INVALID", "resourceUrl");
41
+ }
42
+ let prefix = "__tileflow_native_template_";
43
+ while (value.includes(prefix) || document.href.includes(prefix)) prefix += "_";
44
+ const placeholders = [];
45
+ const allowed = options.template === "tile" ? tilePlaceholders : glyphPlaceholders;
46
+ const protectedValue = value.replace(/\{([^{}]*)\}/gu, (placeholder, name) => {
47
+ if (!options.template || !allowed.has(name)) {
48
+ throw new TileflowNativeUrlError("NATIVE_URL_TEMPLATE_INVALID", "resourceUrl");
49
+ }
50
+ placeholders.push(placeholder);
51
+ return `${prefix}${placeholders.length - 1}__`;
52
+ });
53
+ if (/[{}]/u.test(protectedValue)) {
54
+ throw new TileflowNativeUrlError("NATIVE_URL_TEMPLATE_INVALID", "resourceUrl");
55
+ }
56
+ const resolved = parseUrl(protectedValue, "resourceUrl", document.href);
57
+ assertTransport(resolved, "resourceUrl", developmentOrigin);
58
+ const resourcePath = resolved.href.slice(resolved.origin.length);
59
+ const suffix = resourcePath.replace(
60
+ new RegExp(`${prefix}(\\d+)__`, "gu"),
61
+ (match, index) => placeholders[Number(index)] ?? match
62
+ );
63
+ const result = resolved.origin + suffix;
64
+ assertUrlText(result, "resourceUrl");
65
+ return result;
66
+ }
67
+ function assertOptionsObject(value, field) {
68
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
69
+ throw new TileflowNativeUrlError(
70
+ field === "documentUrl" ? "NATIVE_URL_INVALID" : "NATIVE_URL_DEVELOPMENT_ORIGIN_INVALID",
71
+ field
72
+ );
73
+ }
74
+ }
75
+ function resolveDevelopmentOrigin(value) {
76
+ if (value === void 0) return void 0;
77
+ try {
78
+ assertUrlText(value, "developmentOrigin");
79
+ const match = /^(http:\/\/[^/?#]+)\/?$/iu.exec(value);
80
+ if (!match || /[{}@*]/u.test(value)) throw new Error();
81
+ const url = parseUrl(value, "developmentOrigin");
82
+ if (url.protocol !== "http:" || url.pathname !== "/" || url.search || url.hash || url.hostname.includes("*")) {
83
+ throw new Error();
84
+ }
85
+ return url.origin;
86
+ } catch {
87
+ throw new TileflowNativeUrlError("NATIVE_URL_DEVELOPMENT_ORIGIN_INVALID", "developmentOrigin");
88
+ }
89
+ }
90
+ function resolveDocumentUrl(value, field, developmentOrigin) {
91
+ assertUrlText(value, field);
92
+ assertReferenceSyntax(value, field, true);
93
+ if (/[{}]/u.test(value)) throw new TileflowNativeUrlError("NATIVE_URL_TEMPLATE_INVALID", field);
94
+ const url = parseUrl(value, field);
95
+ assertTransport(url, field, developmentOrigin);
96
+ assertUrlText(url.href, field);
97
+ return url;
98
+ }
99
+ function assertUrlText(value, field) {
100
+ if (typeof value !== "string" || value.length === 0 || value.length > tileflowNativeUrlLimits.maximumLength || value !== value.trim() || /[\p{Cc}\\#]/u.test(value) || /%(?![\da-f]{2})/iu.test(value)) {
101
+ throw new TileflowNativeUrlError("NATIVE_URL_INVALID", field);
102
+ }
103
+ }
104
+ function assertReferenceSyntax(value, field, absolute) {
105
+ if (value.startsWith("//")) {
106
+ throw new TileflowNativeUrlError(
107
+ absolute ? "NATIVE_URL_ABSOLUTE_REQUIRED" : "NATIVE_URL_INVALID",
108
+ field
109
+ );
110
+ }
111
+ const authority = absoluteHttpPattern.exec(value)?.[0];
112
+ if (schemePattern.test(value) && !authority) {
113
+ throw new TileflowNativeUrlError("NATIVE_URL_INVALID", field);
114
+ }
115
+ if (absolute && !authority) {
116
+ throw new TileflowNativeUrlError("NATIVE_URL_ABSOLUTE_REQUIRED", field);
117
+ }
118
+ if (authority?.includes("@")) throw new TileflowNativeUrlError("NATIVE_URL_INVALID", field);
119
+ }
120
+ function parseUrl(value, field, base) {
121
+ let url;
122
+ try {
123
+ url = base === void 0 ? new URL(value) : new URL(value, base);
124
+ if (!url.hostname || url.username || url.password || url.hash) throw new Error();
125
+ } catch {
126
+ throw new TileflowNativeUrlError("NATIVE_URL_INVALID", field);
127
+ }
128
+ if (/[{}]/u.test(url.hostname)) {
129
+ throw new TileflowNativeUrlError("NATIVE_URL_TEMPLATE_INVALID", field);
130
+ }
131
+ return url;
132
+ }
133
+ function assertTransport(url, field, developmentOrigin) {
134
+ if (url.protocol === "https:") return;
135
+ if (url.protocol === "http:" && url.origin === developmentOrigin) return;
136
+ throw new TileflowNativeUrlError("NATIVE_URL_HTTPS_REQUIRED", field);
137
+ }
138
+ export {
139
+ TileflowNativeUrlError,
140
+ resolveTileflowNativeManifestUrl,
141
+ resolveTileflowNativeResourceUrl,
142
+ tileflowNativeUrlLimits
143
+ };
@@ -0,0 +1,198 @@
1
+ # Authoring model
2
+
3
+ Start with the [@tileflow/core guide](https://github.com/tileflow/tileflow-sdk/blob/main/packages/core/README.md) for installation and a complete first example.
4
+
5
+ Tileflow exposes one authoring concept and one constructor: `defineMap()`. A complete map omits
6
+ `extends`; an inherited map sets `extends` to another imported map object. All ten first-party
7
+ maps are independent standalone maps. They use the sole semantic compiler while defining
8
+ their complete designs and asset providers directly; no official map imports or extends another
9
+ official map. Applications can extend any of those maps through the same public API. Streets
10
+ itself owns coordinated light and dark themes.
11
+ There is no public compiler selector or alternate compiler. The authoring contract has no recipe or
12
+ cartographic compatibility alias.
13
+
14
+ ### Machine-readable language surface
15
+
16
+ `tileflowAuthoringManifest` is the deterministic, deeply frozen description of the public semantic
17
+ language. Its schema version is `tileflowAuthoringManifestSchemaVersion`. The manifest's `domains`
18
+ array is generated from the compiler's closed registry and records exact compile order, module and
19
+ service dependencies, and provided services. `operations` lists only integrated public operations:
20
+ defining/extending a map, directly replacing, refining, disabling, or resetting a keyed domain,
21
+ and adding owner-local render passes or target refinements. Direct declaration is the sole
22
+ replacement syntax; there is no redundant `set()` helper.
23
+
24
+ Agents and other tools can discover this contract without importing executable configuration:
25
+ `tileflow language manifest --json` emits the manifest and `tileflow language schema --json` emits
26
+ the packaged generated authoring/resolved JSON Schema. Both commands are deterministic, read-only,
27
+ and network-free. The manifest links every domain to its authoring, options, patch, and resolved
28
+ schema definitions, and enumerates the closed expression and render-selector vocabulary with its
29
+ finite limits.
30
+
31
+ The manifest also describes the exact structured compiler contract. A successful
32
+ `createStyleResult()` has `{ok: true, diagnostics, report, style}`; a failure has
33
+ `{ok: false, diagnostics, report}` and forbids `style`. Report schema version 1 requires
34
+ `domains`, `map`, `planner`, `schemaVersion`, and sorted semantic `targets`; `theme`, source
35
+ `requirements`, and physical `provenance` are optional. Pass `{inspection: true}` only when the
36
+ read-only physical-output provenance sidecar is needed. Its IDs and indexes are diagnostic
37
+ observations, never stable or addressable authoring targets.
38
+
39
+ `diffTileflowMaps(before, after)` resolves both inputs before comparing them and returns semantic
40
+ diff schema version 1:
41
+
42
+ ```ts
43
+ {
44
+ schemaVersion: 1,
45
+ from: {id, version},
46
+ to: {id, version},
47
+ summary: {add, remove, change, total},
48
+ changes: [
49
+ {kind: 'add', path: '/projection', after: 'globe'},
50
+ {kind: 'remove', path: '/modules/water', before: {/* ... */}},
51
+ {kind: 'change', path: '/view/zoom', before: 12, after: 13},
52
+ ],
53
+ }
54
+ ```
55
+
56
+ Paths are RFC 6901 JSON Pointers. Object keys compare recursively in code-unit order; arrays compare
57
+ atomically because map inheritance replaces arrays. Leaf identity (`id`, `name`, `version`) and
58
+ delivery metadata identify the endpoints but are not cartographic changes.
59
+
60
+ Custom build tooling can opt into a separate, read-only diagnostic sidecar from the explicit build
61
+ entrypoint:
62
+
63
+ ```ts
64
+ import {createStyleWithInspection} from '@tileflow/core/build';
65
+
66
+ const {style, inspection} = createStyleWithInspection(map);
67
+ ```
68
+
69
+ `inspection.layers` stays aligned with the final Style layer order and records the semantic
70
+ `owner`, `slot`, `target`, and ordered render passes/refinements represented by each layer, including
71
+ layers merged by the physical planner. `createStyleFromCatalogWithInspection` and
72
+ `createStylesFromCatalogWithInspection` provide the corresponding catalog-oriented forms. The
73
+ ordinary Style bytes are identical to compilation without inspection; private compiler metadata is
74
+ stripped before finalization, and the sidecar never enters a Style, runtime manifest, or production
75
+ artifact unless a caller deliberately stores it.
76
+
77
+ Resolution happens before validation, asset preparation, compilation, capture, build, or deploy.
78
+ Only `view` deep-merges (its nested arrays and expressions still replace). The `themes` collection
79
+ replaces atomically when declared and clears an inherited `systemThemes` mapping; omission inherits
80
+ the collection. `defaultTheme` may independently choose one inherited concrete theme, while an
81
+ explicit `systemThemes` replaces the complete light/dark mapping. Every resolved selector must name
82
+ a theme in the final collection.
83
+ `modules` merges by domain name: an omitted domain remains inherited, while declaring `roads(...)`
84
+ or another domain replaces that inherited module request and every compiler-owned contribution
85
+ attached to it as a unit. `data`, `projection`, `terrain`, `marine`, `icons`, and the text provider
86
+ are atomic; identity and tooling metadata are leaf-owned. `disable()` removes the domain and
87
+ its complete inherited render stack. The resolved result is a standalone map with no runtime dependency on
88
+ TypeScript imports.
89
+
90
+ `icons` is an intentional exception to implicit array composition: omission inherits the exact
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
93
+ exclusive text providers; declaring either atomically replaces an inherited provider of either
94
+ kind. Unknown keys and former compatibility shapes are rejected.
95
+
96
+ Most authors should extend an existing official or application map. A complete standalone map uses
97
+ the same `defineMap()` call without `extends`:
98
+
99
+ ```ts
100
+ import {defineMap} from '@tileflow/core';
101
+ import {streetsIcons, streetsThemes} from '@tileflow/maps';
102
+
103
+ const companyBase = defineMap({
104
+ id: 'company-base',
105
+ name: 'Company base',
106
+ version: 1,
107
+ glyphs: {
108
+ kind: 'url',
109
+ url: 'https://api.tileflow.dev/fonts/{fontstack}/{range}.pbf',
110
+ fontStacks: ['Noto Sans Regular', 'Noto Sans Bold'],
111
+ },
112
+ icons: [streetsIcons],
113
+ themes: {light: streetsThemes.light, dark: streetsThemes.dark},
114
+ defaultTheme: 'light',
115
+ systemThemes: {light: 'light', dark: 'dark'},
116
+ });
117
+
118
+ export default defineMap({
119
+ id: 'company-navigation',
120
+ version: 1,
121
+ extends: companyBase,
122
+ projection: 'globe',
123
+ });
124
+ ```
125
+
126
+ The standalone map above is complete as written. A map always owns its complete text provider; Core does not
127
+ obtain fonts or sprites from World and never invents a fallback URL. The URL-backed first-party
128
+ `streets`, `ferraris`, `harad`, `soundings`, `verdant`, and `sanFrancisto` maps declare their glyph
129
+ providers directly, while `baedeker`, `siegfried`, `cyberpunk`, and `matrix` declare packaged fonts, so ordinary imports and derived
130
+ maps compile without out-of-band release metadata.
131
+
132
+ ```mermaid
133
+ flowchart LR
134
+ A["tileflow.config.ts exports one map"] --> B["Resolve imported map lineage"]
135
+ B --> C["Complete semantic design + closed domain registry"]
136
+ C --> D["Domain IR + assembly + render stacks"]
137
+ D --> E["Physical planner"]
138
+ E --> F["Single MapLibre lowering"]
139
+ F --> G["Validated Style JSON + compilation report"]
140
+ ```
141
+
142
+ Modules are keyed by domain, so object order never controls rendering and a domain can appear only
143
+ once. A map extending Streets inherits its complete module set. Use `disable()` to remove a domain
144
+ deliberately. The public domains are `land`, `water`, `nautical`, `roads`, `buildings`, `boundaries`,
145
+ `labels`, `poi`, `aeroways`, `transit`, `vegetation`, `addresses`, and `landforms`.
146
+ The closed domain registry is exhaustive over that domain set and owns defaults, dependency order,
147
+ services, and compiler orchestration. Contract tests keep its keys and type tags in lockstep with
148
+ the strict resolved schema, generated authoring/options/patch/resolved schema aliases, and public
149
+ exports. Disabling `roads` also removes dependent road names, shields, and junction references;
150
+ independent place, water, aerodrome, and POI labels remain under the labels module.
151
+
152
+ Every styling module supports semantic shortcuts and exact semantic targets. Visual style values
153
+ accept typed token refs, documented `fixed(value, {reason})` values, closed data expressions through
154
+ `expr.*` plus `field(...)`, and zoom functions through `zoom.step(...)`, `zoom.linear(...)`, or
155
+ `zoom.exponential(...)`. Refs and fixed leaves also work inside typed expressions and zoom stops.
156
+ Structural controls such as presets, visibility, and zoom gates remain ordinary literals. Exact
157
+ controls address stable concepts such as `roads.classes.primary.surface.fill`, not renderer layer
158
+ IDs.
159
+
160
+ The `land` module exposes stable land-use targets for `cemetery`, `civic`, `commercial`,
161
+ `education`, `government`, `industrial`, `medical`, `military`, `parking`, `railway`,
162
+ `recreation`, and `residential`. Its land-cover taxonomy distinguishes physical cover from authored
163
+ urban green: `farmland`, `flowerbed`, `grass`, `ice`, `meadow`, `protected`,
164
+ `recreationGround`, `rock`, `sand`, `scrub`, `urbanPark`, `villageGreen`, `wetland`, and
165
+ `wood`. The plain `grass` branch excludes every typed grass subclass, so one source feature cannot
166
+ receive two opaque green fills. Parking areas are polygons from the configured land-use source;
167
+ parking access aisles remain road features under `roads.serviceTypes.parkingAisle`. The
168
+ `commercial` target recognizes ordinary `commercial` and `retail` values plus Tileflow's derived
169
+ `business_area` ground class. Its `globalLandcover` fill styles the optional low-zoom global
170
+ land-cover extension without a raw layer patch. The `water.bathymetry` fill does the same for the
171
+ typed Tileflow World V1 depth bands. An explicit `water({bathymetryContours: {}})` traces the
172
+ submerged edges between those discrete polygon bands; it is an approximate visual contour, not a
173
+ surveyed isoline. `water({bathymetryLabels: {}})` separately opts into numeric metre values derived
174
+ from each polygon's absolute minimum band depth. Existing maps gain neither detail by default, and
175
+ sources without bathymetry bindings omit both requested layers. These labels describe coarse band
176
+ floors, not measured survey soundings, and must not be presented as hydrographic sounding data.
177
+
178
+ `addresses` renders the standard OpenMapTiles `housenumber` points at detailed zooms and exposes a
179
+ single semantic `labels` style. `landforms` renders the standard `mountain_peak` classes (`peak`,
180
+ `volcano`, `saddle`, `ridge`, `cliff`, and `arete`) with rank-aware collision priority and optional
181
+ metric elevation. Both source-layer and field names remain remappable through `openMapTiles(...)`;
182
+ landform names share the language selected by `labels({language: ...})`.
183
+
184
+ `aeroways.runwayRef` owns high-zoom runway designators from the remappable OpenMapTiles `ref`
185
+ field. Aerodrome names stay under `labels.styles.aerodrome`; `labels.aerodromeCodes` controls whether
186
+ they append no code, IATA only, or IATA with an ICAO fallback (`'none' | 'iata' | 'all'`).
187
+
188
+ The `vegetation` module binds individual-tree points from the optional OpenMapTiles `tree`
189
+ extension. Its default `mode: '3d'` emits a portable circle fallback plus metadata for runtimes
190
+ that can upgrade the points to instanced 3D trees. `mode: 'flat'` keeps the MapLibre circles, and
191
+ `flat` exposes the complete `CircleStyle` fallback. `threeDimensional` controls bark color,
192
+ broadleaf and conifer palettes, and independent height and crown scales. The legacy `minZoom`
193
+ shortcut remains available; `flat.minZoom` takes precedence when both are present. The binding
194
+ includes height, crown diameter, genus, leaf type, and species fields so compatible runtimes can
195
+ preserve source measurements and botanical form without hard-coding raw property names. The
196
+ pitched-scene stack follows physical height: pedestrian and transport surfaces, transport markings
197
+ and road names, buildings, then vegetation. Place, water, aerodrome, and POI annotations remain
198
+ last so geographic names stay readable without making street paint or text float over 3D geometry.
@@ -0,0 +1,36 @@
1
+ # Capture scenes
2
+
3
+ Start with the [@tileflow/core guide](https://github.com/tileflow/tileflow-sdk/blob/main/packages/core/README.md) for installation and a complete first example.
4
+
5
+ Commit named `scenes` on the singular exported map. A scene implicitly targets that map, so it does
6
+ not repeat a `map` selector. Scene metadata does not inherit and is removed before cartographic
7
+ compilation; it affects visual evidence, not style or manifest identity.
8
+
9
+ ```ts
10
+ import {defineMap} from '@tileflow/core';
11
+ import {streets} from '@tileflow/maps';
12
+
13
+ export default defineMap({
14
+ id: 'madrid',
15
+ name: 'Madrid',
16
+ version: 1,
17
+ extends: streets,
18
+ scenes: {
19
+ 'madrid-desktop': {
20
+ theme: 'dark',
21
+ camera: {type: 'center', center: [-3.7038, 40.4168], zoom: 12},
22
+ viewport: {width: 1280, height: 800, dpr: 1},
23
+ },
24
+ },
25
+ });
26
+ ```
27
+
28
+ Use `tileflow preview --scene madrid-desktop` (`tileflow dev` remains an alias) for live review and
29
+ `tileflow capture madrid-desktop` for exact pixels and a schema-version-4 receipt containing the
30
+ concrete theme plus Streets, data, style, renderer, and image identities. World capture resolves the selected TileJSON
31
+ once and records the exact `world-v1` release plus descriptor/archive/data-contract hashes;
32
+ external fixtures may identify their explicit revision.
33
+
34
+ Every exact World V1 release ID is already canonical at the producer boundary: 12–128 characters
35
+ matching `^world-v1-[a-z0-9][a-z0-9._-]*[a-z0-9]$`. Core validates the literal value and never trims,
36
+ lowercases, or upgrades it to another World generation.
@@ -0,0 +1,263 @@
1
+ # Compiled-style performance
2
+
3
+ Start with the [@tileflow/core guide](https://github.com/tileflow/tileflow-sdk/blob/main/packages/core/README.md) for installation and a complete first example.
4
+
5
+ The semantic compiler resolves semantic modules and their owned contributions first, then compacts equivalent
6
+ physical MapLibre layers. At high-detail zooms, road classes become a small set of data-driven
7
+ cohorts; equivalent road labels and tunnel hatches share compatible buckets; and land-cover,
8
+ land-use, and waterway classes share compatible buckets. Compaction selects
9
+ cohorts from compiler-owned semantic targets, not by parsing physical IDs; its temporary
10
+ owner/slot/target provenance is stripped from the public Style JSON.
11
+
12
+ After physical planning, Core embeds a bounded private `tileflow:interaction-manifest` lookup for the
13
+ final POI representations. `@tileflow/interactions/maplibre` validates and consumes that metadata
14
+ so applications can bind to `domain: 'poi'` without depending on physical layer IDs. The lookup is
15
+ paired atomically with the exact style it describes; it is not a public style-authoring API.
16
+
17
+ Use the exported structural sweep to enforce budgets without loading tiles or a browser:
18
+
19
+ ```ts
20
+ import {analyzeTileflowStylePerformance, createStyle} from '@tileflow/core';
21
+ import map from './tileflow.config';
22
+
23
+ const report = analyzeTileflowStylePerformance(createStyle(map));
24
+ console.log(report.zooms[16]);
25
+ ```
26
+
27
+ The report covers z0–z22 by default and includes active layers, conservative bucket estimates,
28
+ symbols, and active layers per source-layer. It is intended for regression gates; browser traces
29
+ remain the source of truth for decode, upload, placement, and frame time.
30
+
31
+ A `SymbolStyle` root zoom range governs its text/icon layer and is inherited by its marker layer.
32
+ Because a marker is materialized as a separate circle layer, an explicit marker range may refine
33
+ that inherited default. Text and icon ranges must agree because MapLibre renders them together.
34
+
35
+ The road module distinguishes the path family semantically:
36
+
37
+ ```ts
38
+ roads({
39
+ extras: {paths: true},
40
+ crossings: {image: token.image('roads.crosswalk')},
41
+ sidewalks: {
42
+ surface: {color: token.color('roads.city.casing'), minZoom: 17},
43
+ pattern: {
44
+ pattern: token.image('roads.sidewalkPattern'),
45
+ minZoom: 17,
46
+ opacity: fixed(0.6, {reason: 'Sidewalk texture strength is invariant'}),
47
+ },
48
+ },
49
+ roundabouts: {
50
+ casing: {strokeColor: token.color('roads.default.casing')},
51
+ fill: {strokeColor: token.color('roads.default')},
52
+ },
53
+ areas: {
54
+ pedestrian: {
55
+ fill: {color: token.color('surface.land')},
56
+ outline: {
57
+ color: token.color('roads.default.casing'),
58
+ width: fixed(1, {reason: 'Pedestrian-area outline weight is invariant'}),
59
+ },
60
+ },
61
+ },
62
+ classes: {
63
+ primary: {
64
+ tunnel: {
65
+ casing: {
66
+ color: token.color('roads.city.tunnelCasing'),
67
+ width: fixed(10, {reason: 'Primary-tunnel hierarchy is invariant'}),
68
+ },
69
+ fill: {
70
+ color: token.color('roads.city.tunnel'),
71
+ width: fixed(8, {reason: 'Primary-tunnel hierarchy is invariant'}),
72
+ },
73
+ hatch: {
74
+ color: token.color('roads.city.tunnelCasing'),
75
+ opacity: fixed(0.25, {reason: 'Tunnel hatch strength is invariant'}),
76
+ spacing: fixed(10, {reason: 'Tunnel hatch rhythm is invariant'}),
77
+ },
78
+ },
79
+ },
80
+ pedestrian: {
81
+ surface: {
82
+ fill: {
83
+ color: token.color('roads.path.transition'),
84
+ width: fixed(6, {reason: 'Pedestrian-road hierarchy is invariant'}),
85
+ },
86
+ },
87
+ },
88
+ footway: {
89
+ surface: {
90
+ fill: {
91
+ color: token.color('roads.path'),
92
+ width: fixed(1.2, {reason: 'Path hierarchy is invariant'}),
93
+ },
94
+ },
95
+ },
96
+ cycleway: {
97
+ surface: {
98
+ fill: {
99
+ color: token.color('roads.cycleway'),
100
+ width: fixed(1.5, {reason: 'Cycleway hierarchy is invariant'}),
101
+ },
102
+ },
103
+ },
104
+ steps: {
105
+ surface: {
106
+ fill: {
107
+ color: token.color('roads.path.casing'),
108
+ width: fixed(1.4, {reason: 'Step hierarchy is invariant'}),
109
+ },
110
+ },
111
+ },
112
+ pathway: {
113
+ surface: {
114
+ fill: {
115
+ color: token.color('roads.path'),
116
+ width: fixed(1.2, {reason: 'Path hierarchy is invariant'}),
117
+ },
118
+ },
119
+ },
120
+ },
121
+ modifiers: {
122
+ expressway: {widthScale: 1.06},
123
+ ramp: {widthScale: 0.7},
124
+ unpaved: {surface: {fill: {color: token.color('roads.path')}}},
125
+ construction: {
126
+ surface: {
127
+ fill: {opacity: fixed(0.7, {reason: 'Construction emphasis is invariant'})},
128
+ },
129
+ },
130
+ indoor: {
131
+ surface: {fill: {opacity: fixed(0.4, {reason: 'Indoor-road emphasis is invariant'})}},
132
+ },
133
+ },
134
+ restrictions: {
135
+ access: {
136
+ surface: {fill: {opacity: fixed(0.55, {reason: 'Restricted-road emphasis is invariant'})}},
137
+ },
138
+ toll: {
139
+ surface: {
140
+ casing: {color: fixed('#C5B7D8', {reason: 'Toll ink is regulatory and invariant'})},
141
+ },
142
+ },
143
+ },
144
+ serviceTypes: {
145
+ driveway: {widthScale: 0.75},
146
+ parkingAisle: {widthScale: 0.6},
147
+ },
148
+ });
149
+ ```
150
+
151
+ These targets are non-overlapping translations of the OpenMapTiles road class and subclass. The
152
+ same names are available under `labels().roadClasses` and `labels().styles.roads`. Surface, tunnel,
153
+ and bridge phases can be controlled independently for each target; each structure has
154
+ `shadow`/`casing`/`fill` and an optional `hatch`. Glyph hatch marks inherit the resolved fill width
155
+ when `size` is omitted and never participate in label collision. Setting `hatch.pattern` instead
156
+ emits a repeated sprite texture clipped to the resolved fill width. No raw source filter or generated
157
+ layer ID is needed. `hatch.patternWidths` can list intrinsic sprite heights named
158
+ `${pattern}-${width}`; the compiler selects the nearest height from the resolved road width so the
159
+ texture's marks remain approximately constant in screen pixels across classes, ramps, and zooms.
160
+
161
+ `classes.pedestrian` styles line-like pedestrian ways. Polygon pedestrian plazas are a distinct
162
+ geometry and use `areas.pedestrian`, including optional fill opacity, outline color, or sprite
163
+ pattern. This prevents plazas from degrading into a thin polygon outline.
164
+
165
+ Road treatments refine a class without creating another class or exposing source fields.
166
+ `construction`, `expressway`, `indoor`, `official`, `ramp`, and `unpaved` live under `modifiers`;
167
+ general, bicycle, foot, horse, and toll restrictions live under `restrictions`; `alley`,
168
+ `crossover`, `driveway`, `parkingAisle`, and `yard` live under `serviceTypes`; and exact
169
+ mountain-bike difficulty values live under `mountainBike`. Treatments reuse
170
+ surface/tunnel/bridge and casing/fill/shadow paint controls, plus a relative `widthScale`. The
171
+ compiler emits feature-driven paint expressions inside the existing stable class layers rather
172
+ than multiplying every possible combination.
173
+
174
+ Road names, shields, and motorway junctions remain label concerns:
175
+
176
+ ```ts
177
+ labels({
178
+ roads: 'all',
179
+ shields: 'major',
180
+ junctions: true,
181
+ styles: {
182
+ shields: {
183
+ default: {
184
+ icon: {
185
+ image: token.image('roads.shield.rectangleNeutral'),
186
+ optional: false,
187
+ pitchAlignment: 'viewport',
188
+ rotationAlignment: 'viewport',
189
+ textFit: 'width',
190
+ textFitPadding: [0, 4, 0, 4],
191
+ },
192
+ text: {
193
+ color: token.color('labels.shieldDark'),
194
+ font: token.font('places'),
195
+ optional: false,
196
+ pitchAlignment: 'viewport',
197
+ rotationAlignment: 'viewport',
198
+ },
199
+ },
200
+ overview: {minZoom: 6, maxZoom: 11, placement: 'point'},
201
+ detail: {minZoom: 11, placement: 'line', spacing: 400},
202
+ kinds: {
203
+ 'rectangle-neutral': {image: token.image('roads.shield.rectangleNeutral')},
204
+ 'rectangle-blue': {image: token.image('roads.shield.rectangleBlue')},
205
+ },
206
+ textColors: {
207
+ dark: {color: token.color('labels.shieldDark')},
208
+ light: {color: token.color('labels.shieldLight')},
209
+ },
210
+ },
211
+ junctions: {
212
+ text: {
213
+ color: token.color('labels.strong'),
214
+ haloColor: token.color('labels.halo'),
215
+ haloWidth: fixed(2, {reason: 'Junction halo weight is invariant'}),
216
+ },
217
+ },
218
+ },
219
+ });
220
+ ```
221
+
222
+ `icon.textFit` and `icon.textFitPadding` let a symbol background grow with its text. Setting both
223
+ icon and text `optional: false` keeps a route shield atomic during collision placement: neither an
224
+ empty badge nor a detached reference can render alone. `overview` renders producer-selected points
225
+ at low zoom and `detail` switches to line placement at street zooms; exclusive `maxZoom: 11` and
226
+ inclusive `minZoom: 11` make that handoff atomic. Keeping both icon and text aligned to `viewport`
227
+ makes the badge horizontal regardless of road bearing.
228
+
229
+ `kinds` and `textColors` are closed presentation tables. The vector producer supplies semantic
230
+ `shield_kind`, `shield_text_color`, `shield_text`, and `shield_rank` values; Core only matches them
231
+ against the authored tables and falls back to `default`. Country, route-prefix, and network-shape
232
+ rules therefore stay in the data authority instead of leaking into a map theme or multiplying
233
+ runtime layers.
234
+
235
+ Tileflow World owns POI classification, editorial zoom eligibility, and cross-source ranking. Its
236
+ canonical `poi` layer exposes `category`, `type`, `icon`, `min_zoom`, `filter_rank`, and `size_rank`;
237
+ Core validates that complete contract and never reconstructs those decisions from OpenMapTiles
238
+ `class`, `subclass`, or `rank`. `filter_rank` is an
239
+ integer from 0 through 5, with lower values reserved for the strongest candidates. The numeric
240
+ `density` option is an inclusive threshold from 1 through 5 and defaults to 3. `size_rank` is an
241
+ integer from 0 through 16 used to order eligible candidates before MapLibre performs final
242
+ collision placement.
243
+
244
+ The closed category vocabulary is `arts-entertainment`, `education`, `food-drink`, `landmark`,
245
+ `lodging`, `medical`, `park-nature`, `public-services`, `religion`, `retail`, `sport-leisure`,
246
+ `transport`, and `visitor-amenity`. Producer `type` and `icon` values use stable snake_case names.
247
+ When an `icon` sprite exists it is used directly; an unknown or absent icon safely falls back to the
248
+ category's themed image role. `labels` and `icons` are booleans. Category styles control only
249
+ presentation and may hide or delay candidates, never promote them above the producer's selection.
250
+ `placement.coupleIconAndLabel` keeps a POI's icon and label atomic during collision placement.
251
+
252
+ ```ts
253
+ poi({
254
+ categories: ['food-drink', 'landmark', 'transport'],
255
+ density: 3,
256
+ icons: true,
257
+ labels: true,
258
+ });
259
+ ```
260
+
261
+ The same contract drives regular POI layers, custom HUD treatments, semantic interactions, and
262
+ feature inspection. There is intentionally no compatibility path for the former class mapping,
263
+ rank ceilings, or named density/detail presets.