@tileflow/dom 0.0.0-stage → 0.1.0-alpha.0

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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,111 @@
1
- # Temporary Holding Version
1
+ # @tileflow/dom
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Mount an interactive Tileflow map in any DOM element, without a framework. One function creates
4
+ the map, loads its manifest and style, keeps its theme, colours, camera, annotations and
5
+ interactions current, and takes everything down again. It draws nothing of its own around the map:
6
+ marker, popup and tooltip views, loading and error states belong to your page.
7
+
8
+ Use it for plain pages and web components. The React, Vue and Svelte packages are the easier way in
9
+ those frameworks.
10
+
11
+ > Related packages and guides: [documentation index](https://raw.githubusercontent.com/tileflow/tileflow-sdk/main/llms.txt).
12
+
13
+ ## Install
14
+
15
+ Supported peers are MapLibre GL JS `>=6.4.1 <7`. The local build workflow below requires
16
+ Node.js 22 or newer.
17
+
18
+ ```sh
19
+ npm install @tileflow/dom@alpha @tileflow/core@alpha @tileflow/maps@alpha "maplibre-gl@^6.4.1"
20
+ npm install --save-dev --save-exact tileflow@alpha
21
+ ```
22
+
23
+ Build a map into `public/tileflow` with `npx tileflow build --out public/tileflow`, as the
24
+ [React guide](https://github.com/tileflow/tileflow-sdk/blob/main/packages/react/README.md#prepare-a-map)
25
+ shows.
26
+
27
+ With Vite, the plugin from `@tileflow/vite` gives every map MapLibre's worker, in development and
28
+ in production builds, so the application configures nothing. `tileflow()` prepares maps and adds
29
+ the worker. When the CLI build or a hosted manifest provides the maps, add only the worker
30
+ (`npm install --save-dev @tileflow/vite@alpha`):
31
+
32
+ ```ts
33
+ import {defineConfig} from 'vite';
34
+ import {tileflowMapLibreWorker} from '@tileflow/vite';
35
+
36
+ export default defineConfig({plugins: [tileflowMapLibreWorker()]});
37
+ ```
38
+
39
+ The worker comes from the same installed MapLibre as the map's main module.
40
+
41
+ With another bundler, configure the worker once before the first map, with the URL at which the
42
+ page serves `maplibre-gl/dist/maplibre-gl-worker.mjs`. An explicit configuration wins over the
43
+ Vite plugin's:
44
+
45
+ ```ts
46
+ import {configureTileflowMapLibre} from '@tileflow/dom';
47
+
48
+ configureTileflowMapLibre({workerUrl: '/assets/maplibre-gl-worker.mjs'});
49
+ ```
50
+
51
+ ## Mount a map
52
+
53
+ The container needs a size; the map fills it and follows its resizes.
54
+
55
+ <!-- docs:check -->
56
+
57
+ ```ts
58
+ import 'maplibre-gl/dist/maplibre-gl.css';
59
+ import {createTileflowMap} from '@tileflow/dom';
60
+
61
+ const container = document.querySelector<HTMLElement>('#map')!;
62
+ const map = createTileflowMap(container, {
63
+ source: {map: 'madrid'},
64
+ theme: 'system',
65
+ annotations: [
66
+ {
67
+ ariaLabel: 'Prado Museum',
68
+ coordinate: [-3.6921, 40.4138],
69
+ id: 'prado',
70
+ kind: 'marker',
71
+ popup: {content: {kind: 'view', name: 'museum'}},
72
+ },
73
+ ],
74
+ views: {
75
+ popup(element, {close}) {
76
+ const button = document.createElement('button');
77
+ button.textContent = 'Close';
78
+ button.addEventListener('click', close);
79
+ element.append(button);
80
+ },
81
+ },
82
+ onError: ({code, error}) => console.warn(code, error),
83
+ });
84
+
85
+ await map.ready;
86
+ map.setTheme('dark');
87
+ map.setColors({water: 'var(--brand)'});
88
+ map.destroy();
89
+ ```
90
+
91
+ `createTileflowMap` returns at once. `ready` settles with the MapLibre map when it first loads.
92
+ Each setter applies one option; `update` applies several and does no work for values that did not
93
+ change, so an adapter can hand over all of its props on every render. The container carries
94
+ `data-tileflow-state` (`loading`, `idle` or `error`) for capture, and `getStatus` with
95
+ `onStatusChange` give the same readiness, the theme shown and interaction diagnostics to your own
96
+ loading or error view.
97
+
98
+ A view renderer fills the element it receives. It runs again on an emptied element when its context
99
+ changes, unless it returns `update`; `destroy` runs when the view leaves the map. A marker view
100
+ receives hover, focus and whether its popup is open in `state`.
101
+
102
+ `mode: "image"` shows a static image of the map instead, without loading MapLibre; `ready` then
103
+ settles with `null` once the image has loaded.
104
+
105
+ See [REFERENCE.md](REFERENCE.md) for every option and controller method.
106
+
107
+ ## Next steps
108
+
109
+ - [Show a popup on click](https://tileflow.dev/docs/examples/show-a-popup-on-click)
110
+ - [Themes and tokens](https://tileflow.dev/docs/map-design/themes-and-tokens)
111
+ - [Capture a map](https://github.com/tileflow/tileflow-sdk/blob/main/packages/capture/README.md)
package/REFERENCE.md ADDED
@@ -0,0 +1,80 @@
1
+ # @tileflow/dom reference
2
+
3
+ ## `createTileflowMap(container, options, createOptions?)`
4
+
5
+ Mounts a map in `container` and returns a controller at once. MapLibre loads lazily, after the
6
+ manifest and style are ready. Throws a `TypeError` for an invalid `source`, `theme`, `timeOfDay`,
7
+ `themeBlend` or `themeTransition`, and when both `views` and `renderTargets` are given.
8
+
9
+ ### Options
10
+
11
+ Every option except `source` is optional and can change after mount through `update` or a setter.
12
+
13
+ | Option | Meaning |
14
+ | ------------------------------------------------ | --------------------------------------------------------------------------------------------------------- |
15
+ | `source` | `{map, manifestUrl?}`: the map by name, from the default manifest or `manifestUrl`. |
16
+ | `theme`, `timeOfDay` | A concrete theme or `"system"`, which follows the page's colour scheme; an optional artistic preset. |
17
+ | `themeBlend` | `{themes, position, hold?}`: a continuous blend of two to eight themes instead of `theme`. |
18
+ | `themeTransition` | `{duration}` in milliseconds, used for theme, blend, colour and emphasis changes. |
19
+ | `colors`, `emphasis` | Colour token or knob overrides (CSS variables are read where the map sits); modules that recede. |
20
+ | `vegetation`, `viewMode` | 3D scene inputs; `viewMode` defaults to `"3d"`. |
21
+ | `center`, `zoom` | The view until `bounds` or `fitAnnotations` is given; a change moves the camera at once. |
22
+ | `bounds`, `fitBoundsOptions`, `fitAnnotations` | Bounds to show, how they are fitted, or a fit to all annotations. The first fit is immediate. |
23
+ | `interactive`, `navigationControl` | Whether the map takes input; zoom and compass buttons, none unless asked. |
24
+ | `mapOptions` | MapLibre options apart from `container` and `style`. A structurally different value recreates the map. |
25
+ | `analytics` | Analytics fields merged with the style's own. |
26
+ | `annotations`, `annotationClusters` | Portable annotations and optional clustering. |
27
+ | `dataSources`, `dataOverlays` | Application GeoJSON and the overlays drawn over it, keyed as in `defineMap`. |
28
+ | `interactions` | Semantic interaction bindings on map features. |
29
+ | `interactionState` or `defaultInteractionState` | The open popup, controlled or initial. Which of the two is used is fixed when the map is created. |
30
+ | `views` | `{marker?, popup?, tooltip?}` renderers that fill a plain element. |
31
+ | `renderTargets` | `{marker?, popup?, tooltip?, onChange}` for a framework that draws views itself; replaces `views`. |
32
+ | `onLoad`, `onError`, `onThemeChange` | The loaded MapLibre map; `{code, error}` failures (`console.error` without a handler); theme transitions. |
33
+ | `onInteractionEvent`, `onInteractionStateChange` | Pointer and popup events; requested popup state. |
34
+ | `onInteractionDiagnostic` | Each distinct interaction diagnostic, once. |
35
+ | `onStatusChange` | Every change to the status `getStatus` returns. |
36
+ | `mode`, `imageUrl`, `alt`, `imageLoading` | `"image"` shows a static image instead of a map: `imageUrl`, or one the map's style resolves. |
37
+ | `image` | In image mode, an `<img>` your page renders (or `null` until it does); otherwise the map adds its own. |
38
+
39
+ ### Image mode
40
+
41
+ With `mode: "image"` no MapLibre loads. The map shows `imageUrl`, or an image of the style at the
42
+ view and container size, and is `idle` once that image has loaded and decoded. Annotations,
43
+ interactions, interaction state, interaction callbacks and views are unavailable there and report
44
+ `UNSUPPORTED_MODE`. A framework that renders on the server passes its own `<img>` as `image` and
45
+ sets its `src` from `status.imageUrl`.
46
+
47
+ ### Create options
48
+
49
+ Read once: `captureId` (written as `data-tileflow-capture-id`), `sessionSource` (names the
50
+ integration in session analytics) and `statusElement` (the element that receives the capture
51
+ attributes; the container unless given, none when `null`).
52
+
53
+ ### Views
54
+
55
+ A renderer is `(element, context) => void | {update?, destroy?}`. It runs when the view appears,
56
+ and again on an emptied element when its context changes, unless it returned `update`. `destroy`
57
+ runs when the view leaves the map. A marker context has `state: {hovered, focused, selected}`;
58
+ popup and tooltip contexts belong to an annotation or to a map feature and carry `close`. A kind
59
+ with no renderer keeps the default view.
60
+
61
+ ## Controller
62
+
63
+ | Member | Meaning |
64
+ | -------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
65
+ | `ready` | Settles with the MapLibre map on its first load (`null` once an image shows); rejects when it cannot start or is destroyed first. |
66
+ | `update(options)` | Applies changed options; left-out keys keep their value, `undefined` clears one. |
67
+ | `setTheme`, `setThemeBlend`, `setColors`, `setEmphasis` | One option each. |
68
+ | `setView({center, zoom})`, `setBounds(bounds, options?)` | Camera options. |
69
+ | `setAnnotations`, `setInteractions`, `setViews` | Content options. |
70
+ | `setInteractionState(state)` | Opens or closes a popup; on a controlled map the same as passing `interactionState`. |
71
+ | `getStatus()` | `{readiness, theme, diagnostics, imageUrl}`: `loading`, `idle` or `error`, the theme shown, interaction diagnostics and, in image mode, the image. |
72
+ | `getMap()`, `getThemeController()` | The MapLibre map and theme controller, `null` until the map exists and after it is taken down. |
73
+ | `getInteractionState()`, `getRenderTargets()` | The open popup; the view elements the map handed out. |
74
+ | `destroy()` | Takes the map down, removes the capture attributes and stops every listener. Later calls do nothing. |
75
+
76
+ ## `getTileflowMapInitialStatus(options, controlledInteractionState?)`
77
+
78
+ The status a map with these options has before it mounts: its declarative diagnostics, `error` or
79
+ `loading`, the theme it names and, in image mode, `imageUrl`. It touches no DOM, so a framework can
80
+ render capture attributes on the server and before the controller exists.
@@ -0,0 +1,198 @@
1
+ import * as maplibre_gl from 'maplibre-gl';
2
+ import { Map, MapOptions } from 'maplibre-gl';
3
+ import { TileflowMapLibreOverlay, TileflowGeoJsonSource } from '@tileflow/core';
4
+ import { TileflowThemeController, TileflowBounds, TileflowFitBoundsOptions, TileflowColorOverrides, TileflowEmphasis, TileflowBrowserThemeBlendSelection, TileflowThemeTransitionOptions, TileflowViewMode, TileflowNavigationControlInput, TileflowMapError, TileflowThemeTransition } from '@tileflow/core/browser';
5
+ import { TileflowThemeSelection, TileflowRuntimeSource, TileflowTimeOfDay, TileflowAnalytics } from '@tileflow/core/runtime';
6
+ import { TileflowAnnotation, TileflowAnnotationViewContext, TileflowInteractionViewContext, TileflowInteractionState, TileflowInteractionDiagnostic, TileflowInteractionBinding, TileflowInteractionEvent } from '@tileflow/interactions';
7
+ import { TileflowMapLibreDomRenderTarget, TileflowMapLibreSemanticDomRenderTarget, TileflowAnnotationClusterOptions } from '@tileflow/interactions/maplibre';
8
+
9
+ /**
10
+ * What a view renderer may return: `update` receives the next context instead of the view being
11
+ * rendered again from an empty element, and `destroy` runs when the view leaves the map.
12
+ */
13
+ type TileflowMapViewInstance<TContext> = Readonly<{
14
+ destroy?: () => void;
15
+ update?: (context: TContext) => void;
16
+ }>;
17
+ /**
18
+ * Fills `element` with a view. It runs when the view appears and again, on an emptied element,
19
+ * whenever its context changes, unless it returned an `update`.
20
+ */
21
+ type TileflowMapViewRenderer<TContext> = (element: HTMLElement, context: TContext) => TileflowMapViewInstance<TContext> | void;
22
+ /** Views drawn into marker, popup and tooltip elements. Each kind left out keeps the default view. */
23
+ type TileflowMapViews<TAnnotation extends TileflowAnnotation = TileflowAnnotation> = Readonly<{
24
+ marker?: TileflowMapViewRenderer<TileflowAnnotationViewContext<TAnnotation>>;
25
+ popup?: TileflowMapViewRenderer<TileflowInteractionViewContext<TAnnotation>>;
26
+ tooltip?: TileflowMapViewRenderer<TileflowInteractionViewContext<TAnnotation>>;
27
+ }>;
28
+ type TileflowMapRenderTargetList<TAnnotation extends TileflowAnnotation> = Readonly<{
29
+ annotations: readonly TileflowMapLibreDomRenderTarget<TAnnotation>[];
30
+ semantic: readonly TileflowMapLibreSemanticDomRenderTarget[];
31
+ }>;
32
+
33
+ /** MapLibre options a map passes through, apart from the container and style it owns. */
34
+ type TileflowMapLibreOptions = Omit<MapOptions, 'container' | 'style'>;
35
+ type TileflowMapReadiness = 'error' | 'idle' | 'loading';
36
+ /**
37
+ * Where the map stands, for capture and for an application's own loading or error view. The map
38
+ * draws nothing for it: `diagnostics` are for the application to show.
39
+ */
40
+ type TileflowMapStatus = Readonly<{
41
+ /** Interaction problems: invalid annotations, interactions or state, and runtime failures. */
42
+ diagnostics: readonly TileflowInteractionDiagnostic[];
43
+ /** `idle` once the map, its theme and its views have settled; `error` when one cannot. */
44
+ readiness: TileflowMapReadiness;
45
+ /** The concrete theme shown, once it is known. */
46
+ theme: string | undefined;
47
+ /** In image mode, the image to show, once it is known. */
48
+ imageUrl: string | undefined;
49
+ }>;
50
+ /**
51
+ * For a framework that draws views itself, such as through portals: the map leaves the elements of
52
+ * the kinds marked `true` empty and hands every element to `onChange`.
53
+ */
54
+ type TileflowMapRenderTargetsOptions<TAnnotation extends TileflowAnnotation> = Readonly<{
55
+ marker?: boolean;
56
+ onChange: (targets: TileflowMapRenderTargetList<TAnnotation>) => void;
57
+ popup?: boolean;
58
+ tooltip?: boolean;
59
+ }>;
60
+ type TileflowMapInteractionStateOptions = Readonly<{
61
+ defaultInteractionState?: never;
62
+ interactionState?: TileflowInteractionState;
63
+ }> | Readonly<{
64
+ defaultInteractionState?: TileflowInteractionState;
65
+ interactionState?: never;
66
+ }>;
67
+ type TileflowMapControllerOptions<TAnnotation extends TileflowAnnotation = TileflowAnnotation> = TileflowMapInteractionStateOptions & {
68
+ /** The map to show, by name, from the manifest at `manifestUrl` or the default one. */
69
+ source: TileflowRuntimeSource;
70
+ /**
71
+ * `image` shows a static image of the map instead of MapLibre: `imageUrl`, or one the map's
72
+ * static renderer makes for the container's size, `center`, `zoom` and theme.
73
+ */
74
+ mode?: 'image' | 'interactive';
75
+ imageUrl?: string;
76
+ /** The image's alternative text; empty unless given. */
77
+ alt?: string;
78
+ /** How the browser loads the image; `eager` unless given. */
79
+ imageLoading?: 'eager' | 'lazy';
80
+ /**
81
+ * The `<img>` a framework renders itself (with `imageUrl` from the status), so the image can be
82
+ * rendered on the server. Without it, the map adds its own image to the container.
83
+ */
84
+ image?: HTMLImageElement | null;
85
+ theme?: TileflowThemeSelection;
86
+ /** Optional artistic preset; ignored by maps without this capability. */
87
+ timeOfDay?: TileflowTimeOfDay;
88
+ /** Shows a continuous blend of the map's themes instead of `theme`. */
89
+ themeBlend?: TileflowBrowserThemeBlendSelection;
90
+ /** Cross-fades theme, blend, colour and emphasis changes. */
91
+ themeTransition?: TileflowThemeTransitionOptions;
92
+ /** Colour token or knob overrides, which may use CSS variables read where the map sits. */
93
+ colors?: TileflowColorOverrides;
94
+ /** Makes chosen modules of the map recede so the application's content reads first. */
95
+ emphasis?: TileflowEmphasis;
96
+ vegetation?: boolean;
97
+ viewMode?: TileflowViewMode;
98
+ center?: [number, number];
99
+ zoom?: number;
100
+ /** Shows these bounds; `center` and `zoom` set the view only until bounds are given. */
101
+ bounds?: TileflowBounds;
102
+ /** Fits the map to all annotations, and again whenever their positions change. */
103
+ fitAnnotations?: boolean | TileflowFitBoundsOptions;
104
+ fitBoundsOptions?: TileflowFitBoundsOptions;
105
+ interactive?: boolean;
106
+ /** Zoom and compass buttons; none unless asked. */
107
+ navigationControl?: TileflowNavigationControlInput;
108
+ mapOptions?: TileflowMapLibreOptions;
109
+ analytics?: TileflowAnalytics;
110
+ /** Group `annotations` into accessible cluster buttons. Up to 1,000 annotations. */
111
+ annotationClusters?: TileflowAnnotationClusterOptions;
112
+ annotations?: readonly TAnnotation[];
113
+ dataOverlays?: Readonly<Record<string, TileflowMapLibreOverlay>>;
114
+ dataSources?: Readonly<Record<string, TileflowGeoJsonSource>>;
115
+ interactions?: readonly TileflowInteractionBinding[];
116
+ /** Views drawn into marker, popup and tooltip elements. */
117
+ views?: TileflowMapViews<TAnnotation>;
118
+ /** Hands view elements to a framework that draws them; replaces `views`. */
119
+ renderTargets?: TileflowMapRenderTargetsOptions<TAnnotation>;
120
+ onError?: (event: TileflowMapError) => void;
121
+ onLoad?: (map: Map) => void;
122
+ onThemeChange?: (transition: TileflowThemeTransition) => void;
123
+ onInteractionDiagnostic?: (diagnostic: TileflowInteractionDiagnostic) => void;
124
+ onInteractionEvent?: (event: TileflowInteractionEvent<TAnnotation>) => void;
125
+ onInteractionStateChange?: (state: TileflowInteractionState) => void;
126
+ onStatusChange?: (status: TileflowMapStatus) => void;
127
+ };
128
+ /** Options read once, when the map is created. */
129
+ type TileflowMapCreateOptions = Readonly<{
130
+ /** Names the map in deterministic capture, as `data-tileflow-capture-id`. */
131
+ captureId?: string;
132
+ /** Names the integration in session analytics; adapters pass their framework. */
133
+ sessionSource?: string;
134
+ /**
135
+ * Receives `data-tileflow-map`, `data-tileflow-theme`, `data-tileflow-state` and
136
+ * `data-tileflow-capture-id`; the container unless given, none when `null`.
137
+ */
138
+ statusElement?: HTMLElement | null;
139
+ }>;
140
+ type TileflowMapController<TAnnotation extends TileflowAnnotation = TileflowAnnotation> = Readonly<{
141
+ container: HTMLElement;
142
+ /**
143
+ * Settles with the MapLibre map when it first loads, or with `null` once an image-mode map has
144
+ * shown its image; rejects when it cannot start or when the controller is destroyed first.
145
+ */
146
+ ready: Promise<Map | null>;
147
+ /** Takes the map down, empties what it added to the container, and stops every listener. */
148
+ destroy(): void;
149
+ getInteractionState(): TileflowInteractionState;
150
+ /** The MapLibre map, or `null` before it is created and after it is taken down. */
151
+ getMap(): Map | null;
152
+ getRenderTargets(): TileflowMapRenderTargetList<TAnnotation>;
153
+ getStatus(): TileflowMapStatus;
154
+ /** Changes theme, colours and emphasis; `null` until the map exists or when it has no themes. */
155
+ getThemeController(): TileflowThemeController | null;
156
+ setAnnotations(annotations: readonly TAnnotation[] | undefined): void;
157
+ setBounds(bounds: TileflowBounds | undefined, options?: TileflowFitBoundsOptions): void;
158
+ setColors(colors: TileflowColorOverrides | undefined): void;
159
+ setEmphasis(emphasis: TileflowEmphasis | undefined): void;
160
+ setInteractions(interactions: readonly TileflowInteractionBinding[] | undefined): void;
161
+ /** Opens or closes a popup; on a controlled map it is the same as passing `interactionState`. */
162
+ setInteractionState(state: TileflowInteractionState): void;
163
+ setTheme(theme: TileflowThemeSelection | undefined): void;
164
+ setThemeBlend(themeBlend: TileflowBrowserThemeBlendSelection | undefined): void;
165
+ setView(view: Readonly<{
166
+ center?: [number, number];
167
+ zoom?: number;
168
+ }>): void;
169
+ setViews(views: TileflowMapViews<TAnnotation> | undefined): void;
170
+ /**
171
+ * Applies changed options. Keys left out keep their value; a key given as `undefined` clears it.
172
+ * Unchanged values do no work, so an adapter can pass all of its props on every render.
173
+ */
174
+ update(options: Partial<TileflowMapControllerOptions<TAnnotation>>): void;
175
+ }>;
176
+ /**
177
+ * Mounts a Tileflow map in `container` and returns its controller. The container should have a
178
+ * size; the map fills it and follows its resizes. Nothing is drawn around the map: loading,
179
+ * error and diagnostic views belong to the application, from `getStatus` and `onStatusChange`.
180
+ */
181
+ declare function createTileflowMap<TAnnotation extends TileflowAnnotation = TileflowAnnotation>(container: HTMLElement, initialOptions: TileflowMapControllerOptions<TAnnotation>, createOptions?: TileflowMapCreateOptions): TileflowMapController<TAnnotation>;
182
+ /**
183
+ * The status a map with these options has before it mounts: for server rendering and a framework's
184
+ * first render, so the page shows the same theme, diagnostics and image before and after mount.
185
+ * `controlledInteractionOwnership` is whether the map started with `interactionState`.
186
+ */
187
+ declare function getTileflowMapInitialStatus<TAnnotation extends TileflowAnnotation = TileflowAnnotation>(options: TileflowMapControllerOptions<TAnnotation>, controlledInteractionOwnership?: boolean): TileflowMapStatus;
188
+
189
+ type TileflowMapLibre = typeof maplibre_gl;
190
+ type TileflowMapLibreConfiguration = Readonly<{
191
+ workerUrl: string;
192
+ }>;
193
+ /** Configure the application-owned worker before mounting an interactive Tileflow map. */
194
+ declare function configureTileflowMapLibre(configuration: TileflowMapLibreConfiguration): void;
195
+ /** Load the interactive renderer only after a browser map requests it. */
196
+ declare function loadTileflowMapLibre(): Promise<TileflowMapLibre>;
197
+
198
+ export { type TileflowMapController, type TileflowMapControllerOptions, type TileflowMapCreateOptions, type TileflowMapLibre, type TileflowMapLibreConfiguration, type TileflowMapLibreOptions, type TileflowMapReadiness, type TileflowMapRenderTargetList, type TileflowMapRenderTargetsOptions, type TileflowMapStatus, type TileflowMapViewInstance, type TileflowMapViewRenderer, type TileflowMapViews, configureTileflowMapLibre, createTileflowMap, getTileflowMapInitialStatus, loadTileflowMapLibre };