@tileflow/core 0.1.0-alpha.47 → 0.1.0-alpha.48

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/README.md CHANGED
@@ -1,22 +1,26 @@
1
1
  # @tileflow/core
2
2
 
3
- Define, validate, and compile Tileflow maps into MapLibre Style JSON. Core owns the map language;
4
- it does not start a server, prepare files on disk, render a browser map, or deploy a hosted map.
3
+ Define and customize maps in TypeScript, then compile them to MapLibre Style JSON. Start from an
4
+ official Tileflow map or create your own, with typed settings for themes, roads, buildings,
5
+ labels, and other map features.
5
6
 
6
- > Related packages and guides: [documentation index](https://raw.githubusercontent.com/tileflow/tileflow-sdk/main/llms.txt).
7
+ Use Core to author and validate the map, the Tileflow CLI to preview it, and a framework adapter
8
+ to display it in your application.
7
9
 
8
10
  ## Install
9
11
 
12
+ The SDK is in alpha. Use ES modules and Node.js 22.14+ (22.x) or 24+ for the CLI.
13
+
10
14
  ```sh
11
- npm install @tileflow/core@alpha @tileflow/maps@alpha
15
+ npm install --save-exact @tileflow/core@alpha @tileflow/maps@alpha
16
+ npm install --save-dev --save-exact tileflow@alpha
12
17
  ```
13
18
 
14
- Use ES modules. `@tileflow/maps` supplies the official map below. Load configs and prepare assets
15
- with the Node.js 22+ CLI or build integrations; browser adapters consume prepared assets.
19
+ `@tileflow/maps` supplies the official Streets map used below. Keep your package-manager lockfile.
16
20
 
17
- ## Define a map
21
+ ## Define your first map
18
22
 
19
- Create `tileflow.config.ts`. Every public config exports one map:
23
+ Create `tileflow.config.ts` in your project:
20
24
 
21
25
  <!-- docs:check -->
22
26
 
@@ -37,321 +41,36 @@ export default defineMap({
37
41
  });
38
42
  ```
39
43
 
40
- Coordinates use `[longitude, latitude]`. This map inherits Streets' themes and assets.
41
- A standalone map uses `defineMap()` without `extends`.
44
+ This keeps Streets' themes and assets, customizes its roads and labels, and opens over Madrid.
45
+ Coordinates are `[longitude, latitude]`. Each config exports one map.
42
46
 
43
- Validate and preview the file with the project-local CLI:
47
+ ## Preview it
44
48
 
45
49
  ```sh
46
- npm install --save-dev --save-exact tileflow@alpha
47
- npx tileflow validate --json
50
+ npx tileflow validate
48
51
  npx tileflow preview
49
52
  ```
50
53
 
51
- Loading a config executes its imports. Treat it as trusted code, not as sandboxed JSON.
52
-
53
- ## Understand inheritance
54
-
55
- Omitted fields inherit, but declaring a field does not imply a recursive merge:
56
-
57
- - `view` deep-merges; nested arrays replace.
58
- - `modules` merges by domain. Declaring `roads(...)` replaces that domain's inherited request and
59
- render contributions. Use `refine(...)` to patch it, `disable()` to remove it, and `reset()` for
60
- an explicit reset inside a supported patch.
61
- - `themes` replaces the complete collection and clears inherited `systemThemes` and `timeOfDay` mappings.
62
- `defaultTheme` can select an inherited concrete theme; `systemThemes` replaces its complete mapping.
63
- - `icons` replaces the ordered contributor list. Omission inherits it; `[]` disables it. Local and
64
- package directories can be combined with explicit locked `iconSet('@team/set')` descriptors.
65
- Spread the parent's list explicitly when composing contributors. Later contributors win for an
66
- exact icon ID.
67
- - `fonts` and `glyphs` are mutually exclusive text providers. Declaring either replaces the inherited
68
- provider. `atmosphere`, `data`, `projection`, `sky`, `terrain`, and `marine` are also atomic.
69
-
70
- Identity (`id`, `name`, `version`) and tooling `scenes` and `shots` belong to the leaf map and do not inherit.
71
- Module object order does not determine rendering order.
72
-
73
- ## Team Icon Sets foundations
74
-
75
- `iconSet('@team/set')` declares a contributor alongside local/package directories, without I/O.
76
- Maps accept at most 32 contributors; set references must be unique. Explicit array order and
77
- later-wins icon precedence apply to all contributors.
78
-
79
- `tileflow.icons.lock.json` pins immutable set revisions and artifacts. Its parser rejects duplicate
80
- keys, stale references, mixed Teams, invalid IDs, floating versions, unsafe URLs and manifest/hash
81
- mismatches. Serialization is canonical; hashes are internal integrity details.
82
-
83
- Shared identity follows published artwork, not source-only SVG edits yielding identical artifacts.
84
- Git retains original artwork history. Shared packages contain no original-source hash, format or
85
- filesystem path; local/package originals retain source identity. Shared winners use `rendered-icon`
86
- identity. Ordered, versioned composition receipts record consumed revisions, including shadowed
87
- sets and dependency changes preserving rendered pixels.
88
-
89
- Maps without shared sets retain v1 revision hashing. Shared sets require complete receipts and the
90
- domain-separated v2 contract, identified by `mapRevisionSchemaVersion: 2`; omission means v1.
91
- Metadata-free RGBA packages retain `tileflow-icon-package-v1`. SDF appearance or text-fitting
92
- metadata requires `tileflow-icon-package-v2` and v2 composition receipts, including defaults/layout.
93
-
94
- `@tileflow/dev` prepares declared contributors; the CLI manages catalogs and exact locks.
95
- Importing `iconSet` neither resolves revisions nor makes a Team catalog available to deployments.
96
-
97
- ## Style with themes and semantic modules
98
-
99
- `roads.pathGround` optionally gives surface paths different colors on mapped green ground and
100
- elsewhere. It accepts `greenColor`, `groundColor`, optional `widthScale`, and `opacity` (zero
101
- disables the treatment). The compiler keeps a complete ground-colored path, adds clipped green
102
- portions from the same HTTP(S) vector source, and places paths below vehicle casings. Grass,
103
- woods, wetlands, orchards, nurseries, and green recreation polygons supply context; polygon
104
- holes remain unpainted. Classification follows tile geometry, not imagery or inferred climate.
105
-
106
- Framework web adapters, CLI preview, capture, and the embedded mobile web runtime register the
107
- derived-source protocol automatically. Raw MapLibre integrations must call
108
- `registerTileflowPathGroundProtocol({addProtocol: maplibregl.addProtocol})` from
109
- `@tileflow/core/browser` before creating the map. The `native-v1` build keeps the complete
110
- ground-colored paths and disables the green overlay, since native renderers cannot run this
111
- browser protocol. Its build record explicitly reports `pathGround: 'ground-fallback'`.
112
-
113
- Themes are complete appearance documents, not loose color overrides. Every theme must supply the
114
- same token schema. Use `token.color(...)`, `token.number(...)`, `token.image(...)`, and typed font
115
- roles for theme-dependent values. Use `fixed(value, {reason})` for an intentionally invariant visual
116
- value. Structural controls, such as visibility and zoom gates, remain ordinary literals.
117
-
118
- Extend a theme without changing the inherited map structure:
119
-
120
- <!-- docs:check -->
121
-
122
- ```ts
123
- import {defineMap, defineTheme} from '@tileflow/core';
124
- import {streets, streetsThemes} from '@tileflow/maps';
125
-
126
- const dark = defineTheme(streetsThemes.dark, {
127
- id: 'madrid-dark',
128
- version: 1,
129
- colorScheme: 'dark',
130
- tokens: {color: {'surface.land': '#0d1320', 'surface.water': '#081e2e'}},
131
- });
132
-
133
- export default defineMap({
134
- id: 'madrid',
135
- version: 1,
136
- extends: streets,
137
- themes: {light: streetsThemes.light, dark},
138
- defaultTheme: 'light',
139
- systemThemes: {light: 'light', dark: 'dark'},
140
- });
141
- ```
142
-
143
- `system` is a runtime selection policy, not a stored theme. Builds, captures, static scenes, and
144
- receipts must use a concrete theme such as `light` or `dark`.
145
-
146
- Theme and `timeOfDay` changes animate over 450 ms, respecting reduced motion. Web manifests v3
147
- add `familyUrl`, a bounded `tileflow-style-family` v1 document sharing structure and parameters;
148
- flat `styleUrl` exports remain. `createTileflowStyleFamily` (`@tileflow/core/build`) factors styles;
149
- `parseTileflowStyleFamily` and `materializeTileflowStyleFamily` (`@tileflow/core/runtime`) validate
150
- and expand them. Controllers load each family once. Compatible appearances preserve sources,
151
- application layers and 3D palettes; structural variants swap styles. Feature-dependent branches
152
- prepare once; discrete values and RGBA icons switch at the dominant theme without relayout.
153
- Parameter columns are not semantic tokens.
154
-
155
- `controller.setColors({'surface.water': '#008800'})` overrides named tokens; `{}` restores authored
156
- colours. Fixed colours and application layers remain. Web builds retain token bindings; direct
157
- `createStyle` calls opt in with `runtimeColors: true`. `createTileflowAppearanceController().set()`
158
- selects author-owned `fixed`, `system` or local `clock` behaviour without UI or location requests.
159
- Profile performance on target devices.
160
-
161
- Theme controllers also provide module/label emphasis, eased numeric `expr.globalState` values,
162
- and fixed-size dynamic RGBA images with state refresh and restoration across theme changes.
163
- `getRouteInks()` supplies route colours; `createTileflowLineProgress` animates drawing routes.
164
- `createTileflowGroundLayers` places them under 3D buildings, optionally showing occluded stretches
165
- faintly. Themes declare `lighting.sun` and `lighting.ambient`; `getSun()` returns the displayed
166
- sun. `setSun()` accepts angles or a date and location. Transitions
167
- mix 3D directions (angular fallback for opposite vectors) and OKLab light colours.
168
-
169
- `createTileflowBuildings3D` enables worker-meshed buildings rising at zoom 15–15.3, scene sun,
170
- cast/contact shadows and 0.8 m rounded corners; effects are independently overridable. Its
171
- `tileflow-buildings-scene-3d` layer replaces `tileflow-buildings-native-extrusion` only after visible
172
- building tiles draw. Failure keeps the native fallback; 2D restores authored visibility.
173
- Street lights default off, including in Streets: enable `roads.streetLights.enabled` and mount
174
- `createTileflowStreetLights`. `createTileflowVegetation` follows the map's `3d`, `flat` or `auto` policy.
175
-
176
- POI icons and names place together; `placement.coupleIconAndLabel: false` separates them.
177
-
178
- The semantic domains are `land`, `water`, `nautical`, `roads`, `buildings`, `boundaries`, `labels`,
179
- `poi`, `aeroways`, `transit`, `vegetation`, `addresses`, and `landforms`. Style stable geographic
180
- targets rather than compiler-generated MapLibre layer IDs. Shared primitives cover fills, lines,
181
- text, icons, circles, and extrusions. `zoom.*` supplies zoom curves; `expr.*` and `field(...)` supply
182
- the closed data-expression language. `renderPass`, `refineRenderTarget`, and `withRenderStack` add
183
- owner-local rendering behavior without bypassing the compiler. A pass, or a target its module moves,
184
- is placed at a band edge such as `'above-relief'` or `'below-labels'`, or `{above}` / `{below}` one
185
- semantic target.
186
-
187
- ## Compile and inspect
188
-
189
- `validateTileflowMap(input)` returns `{valid, messages}`. `parseTileflowMap(map)` resolves and
190
- validates the authoring input and throws on failure. `createStyle(map, options)` returns a style or
191
- throws; `createStyleResult(map, options)` returns structured diagnostics and a compilation report.
192
- Only a successful result contains `style`.
193
-
194
- Compilation compacts redundant expressions and shares repeated predicates and values with
195
- MapLibre `let` bindings. Themes still produce standalone Style JSON, with the same layer order,
196
- appearance and assets. Inspect semantic targets rather than depending on the emitted expression
197
- shape; it may change when the compiler removes repetition.
198
-
199
- Maps with package/local icon or font directories need the CLI, a build plugin, or
200
- [`@tileflow/dev/artifacts`](https://github.com/tileflow/tileflow-sdk/blob/main/packages/dev/README.md)
201
- to prepare assets. Browser components consume the resulting manifest.
202
-
203
- Discover the language and inspect a prepared map:
204
-
205
- ```sh
206
- npx tileflow describe themes --json
207
- npx tileflow language manifest --json
208
- npx tileflow language schema --json
209
- npx tileflow inspect --json
210
- npx tileflow explain --theme dark --json
211
- npx tileflow semantic-diff --from-config before/tileflow.config.ts --to-config after/tileflow.config.ts --json
212
- ```
213
-
214
- The language manifest is also exported as `tileflowAuthoringManifest`, with
215
- `tileflowAuthoringManifestSchemaVersion`. The generated schema distinguishes authoring input from
216
- resolved compiler input. `diffTileflowMaps(before, after)` returns deterministic semantic changes
217
- at JSON Pointer paths. Physical inspection IDs and indexes are diagnostic observations, not stable
218
- application targets.
219
-
220
- ## Select a prepared map
221
-
222
- React, Vue and Svelte accept a required `source` object, `{map, manifestUrl?}`. `map` is the portable
223
- name in the manifest, not a Hosted `map_...` identifier. An omitted web `manifestUrl` means exactly
224
- `/tileflow/manifest.json`; custom paths and external hosts must be explicit. The native Core and
225
- React Native type contracts use `{map, manifestUrl}` with an explicit absolute URL. They do not
226
- infer an application origin, Metro host or manifest location.
227
-
228
- <!-- docs:check -->
229
-
230
- ```ts
231
- import type {TileflowNativeSource} from '@tileflow/core/native';
232
- import type {TileflowRuntimeSource} from '@tileflow/core/runtime';
233
-
234
- const webSource = {map: 'madrid'} satisfies TileflowRuntimeSource;
235
- const nativeSource = {
236
- map: 'madrid',
237
- manifestUrl: 'https://maps.example.com/tileflow/native/manifest.json',
238
- } satisfies TileflowNativeSource;
239
- ```
240
-
241
- These objects select existing prepared maps; they do not compile or render one. Every Tileflow
242
- framework Map is manifest-backed, without a renderer discriminator or direct-style mode. The
243
- obsolete source fields `kind` and `style` are rejected. Completely unmanaged maps use upstream
244
- MapLibre directly. Omitted themes use the manifest default, concrete themes select exact names,
245
- and `system` requires the manifest's explicit light/dark mapping and a supplied runtime color scheme.
246
- The pre-release React Native
247
- package uses this contract for its mounted Map; it is not yet published.
248
-
249
- ## Data, terrain, and browser resources
250
-
251
- Tileflow World is the hosted primary source, with an open (CC0)
252
- [schema](https://github.com/tileflow/tileflow-sdk/blob/main/packages/core/reference/tileflow-world-v1.json);
253
- detail layers load only when drawn. `vectorTiles()` takes that schema or OpenMapTiles
254
- (`openMapTiles()`). `hostedTileset()`, `boundaryAreas` and overlays add named sources.
255
-
256
- `bathymetry({vectorLayers: {...}})` declares contour/name layers. `marine: 'nautical'` adds
257
- navigation marks, flashing lights, and a "Not for navigation" notice.
258
-
259
- World attribution credits Tileflow and OpenStreetMap; other vector data keeps its owner's
260
- attribution.
261
-
262
- `projection` accepts `mercator` or `globe`. Terrain supports `none`, `hillshade`, `3d`, and an object
263
- form for explicit hillshade and contour configuration. Browser-derived contours require a DEM tile
264
- template, zoom limits, thresholds, and the Tileflow contour protocol. Framework adapters and local
265
- tooling prepare browser resources; direct MapLibre integrations must register required protocols
266
- before loading a style.
267
-
268
- ### Load a portable style in MapLibre
269
-
270
- Await `loadTileflowRuntimeStyle` before giving MapLibre a runtime style. React, Vue and Svelte do
271
- this automatically. The loader prepares flat styles or shared families, resolving sprites, glyphs,
272
- fonts, sources and model/landmark URLs against their declaring documents. HTTP TileJSON loads once
273
- per preparation; explicit source options win. Artifacts and input objects remain unchanged.
274
-
275
- <!-- docs:check -->
276
-
277
- ```ts
278
- import {loadTileflowRuntimeStyle, loadTileflowStyleFonts} from '@tileflow/core/browser';
279
- import type {TileflowRuntimeStyle} from '@tileflow/core/runtime';
280
-
281
- export async function prepareMapStyle(runtime: TileflowRuntimeStyle, signal?: AbortSignal) {
282
- const prepared = await loadTileflowRuntimeStyle(runtime, {signal});
283
- await loadTileflowStyleFonts(prepared.style, {fontFaces: prepared.fontFaces});
284
- return prepared.style; // Use as new maplibregl.Map({container, style}).
285
- }
286
- ```
287
-
288
- Resolve the runtime with `resolveTileflowRuntimeStyle`. For inline styles, `baseUrl` supplies the
289
- document URL (default: `document.baseURI`). Absolute URLs, signatures, template tokens and
290
- application data retain their meaning. Custom source protocols remain with MapLibre's handlers.
291
-
292
- `fetch`, `signal` and `transformRequest(url, 'Style' | 'Source')` control document requests, including
293
- families. Defaults use same-origin credentials and reject redirects. Invalid documents, failed
294
- requests and size limits (style/family: 16 MiB; TileJSON: 1 MiB) reject preparation.
295
-
296
- For theme changes, pass `initial: prepared` and `styleLoadOptions` to `createTileflowThemeController`.
297
- With flat styles, `initialStyle: prepared.style` can instead preserve the original `initial` and
298
- `getCurrent()` identity. Inline themes and `loadStyle` overrides must already be prepared. Disposal
299
- aborts pending loads; blends and rollback reuse prepared resources.
300
-
301
- With `projection: 'globe'`, `atmosphere: true` adds a halo and stars; an object configures colors, star count and size.
302
- `sky` follows the sun at street level. Frameworks and capture attach both; direct
303
- MapLibre consumers call `attachTileflowAtmosphere(map)` from `@tileflow/core/browser`.
304
-
305
- Applications that need the map's data themselves, such as streets to route over or the place
306
- under the camera, read chosen layers of a vector source for an area at a fixed zoom with
307
- `createTileflowTileReader` from `@tileflow/core/browser`, which also runs in a module worker.
308
-
309
- Browser 3D scenes resolve `camera.adaptivePerspective` from caller override, map default, then
310
- `false`; Streets enables it. Buildings occlude depth markers. `camera.pitchLimit: {maxZoom, maxPitch}`
311
- caps inclination through `maxZoom`, respecting stricter application caps. Closer views and disposal
312
- restore the application's maximum.
313
- 3D layers prioritize visible ground from viewport bottom toward the horizon. Buildings fade across
314
- the far boundary, followed by haze. Coverage follows resize and projection within each layer's
315
- `maxTiles` budget (default 25), prioritizing nearest ground.
316
- Model roles use `modelLighting` for colours/materials and `colorScale` (0–1, default 1) for darkening
317
- recoloured assets. Ordinary facades use soft daylight and a gradient through their lower 85%, leaving
318
- roofs and upper edges light. Map-shaded models retain a short base gradient; physical roles retain
319
- their lighting. Model corners belong to the asset; ordinary buildings use `edgeRadius`.
320
- `buildings.threeDimensional.entrance: false` shows buildings/models at full height and opacity at
321
- entrance zooms, without zoom/arrival growth or fading. Equal endpoints such as
322
- `entrance: {buildings: [14.25, 14.25], models: [14.25, 14.25]}` switch immediately at that zoom.
323
-
324
- Text requires exactly one provider. Soundings and Blueprint use URL glyphs; Streets packages DINish
325
- and Noto Sans; Baedeker, 1777 and Siegfried package Cormorant; Cívica packages its lettering. Hosted
326
- rejects packaged/local fonts: self-host or replace them with compatible public glyphs. Tile and font
327
- URLs do not grant redistribution rights.
328
-
329
- ## Reference
54
+ Open the local URL printed by the CLI. Change the starting `zoom`, save, and reload the preview
55
+ to see the result. Stop the server with Ctrl+C.
330
56
 
331
- Use the [generated language schema](https://github.com/tileflow/tileflow-sdk/blob/main/packages/core/reference/modules-api-reference.json),
332
- and [public exports](https://github.com/tileflow/tileflow-sdk/blob/main/packages/core/src/index.ts)
333
- for exact options. Prefer the installed CLI's generated contracts when using a published release;
334
- `main` can contain unreleased changes. Report defects in the
335
- [issue tracker](https://github.com/tileflow/tileflow-sdk/issues).
57
+ Local authoring and preview need no Tileflow account or API key. Remote map tiles and assets
58
+ still need a network connection.
336
59
 
337
- ## Native icon capabilities
60
+ ## Learn more
338
61
 
339
- Prepared icon metadata identifies SDF assets and their default fill and halo. Core rejects any
340
- symbol layer that can select both SDF and RGBA, including fallbacks and effective local overrides,
341
- with `TF_ICON_REPRESENTATION_MIXED`. It preserves layers, collisions and interaction IDs. Omitted
342
- SDF paint follows the resolved image selection; supplied map paint stays independent from asset
343
- defaults. See [Author recolorable and adaptable icons](https://github.com/tileflow/tileflow-sdk/blob/main/packages/dev/README.md).
62
+ - [Map configuration](https://tileflow.dev/docs/map-design/map-configuration): create a map or extend an existing design.
63
+ - [Themes and tokens](https://tileflow.dev/docs/map-design/themes-and-tokens): customize colors and switch appearances.
64
+ - [Semantic modules](https://tileflow.dev/docs/map-design/modules): style roads, water, buildings, and labels.
65
+ - [React](https://tileflow.dev/docs/integrations/react), [Vue](https://tileflow.dev/docs/integrations/vue), and [Svelte](https://tileflow.dev/docs/integrations/svelte): use your map in an application.
66
+ - [Core reference](https://github.com/tileflow/tileflow-sdk/blob/main/packages/core/REFERENCE.md): inheritance, compilation, assets, and browser/runtime contracts.
344
67
 
345
- Land may supply a georeferenced `globalLandcoverUnderlay` image with `url`, four
346
- `coordinates` (northwest, northeast, southeast, southwest), `attribution`, zoom bounds
347
- and themed `opacity`. It is drawn below global cover and omitted when land is disabled.
348
- Tree forms may use `sizeAnchor` and `crownAnchor` (metres) with `sizeCompression`
349
- from 0 to 1 to reduce size variation while preserving each tree’s proportions.
68
+ `REFERENCE.md` is also included in the installed package. Use that copy and its TypeScript
69
+ declarations for version-specific behavior; GitHub `main` can contain unreleased changes.
350
70
 
351
- ## Flat footprints under 3D buildings
71
+ ## Support and license
352
72
 
353
- `modules.buildings.threeDimensional.flatFootprints` defaults to `true`. Set it to `false`
354
- to suspend duplicate flat building fills, outlines and flat shadows in the shared 3D scene,
355
- after its building entrance zoom. Roads then remain visible beneath open landmark structures.
356
- Returning to 2D or disposing the scene restores their previous visibility; without WebGL2 the
357
- flat fallback remains. Streets selects this option; other maps keep their authored treatment.
73
+ [Report an issue](https://github.com/tileflow/tileflow-sdk/issues) or read the
74
+ [full documentation](https://tileflow.dev/docs). Licensed under
75
+ [Apache-2.0](https://github.com/tileflow/tileflow-sdk/blob/main/LICENSE); third-party assets retain
76
+ their own terms.