@tileflow/svelte 0.1.0-alpha.22 → 0.1.0-alpha.23
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 +21 -4
- package/package.json +4 -4
- package/src/TileflowMap.svelte +3 -1
- package/src/index.d.ts +4 -0
- package/src/index.js +1 -0
- package/src/maplibre.js +36 -4
package/README.md
CHANGED
|
@@ -22,6 +22,23 @@ Install `maplibre-gl` alongside the package and import its CSS once in your app.
|
|
|
22
22
|
/>
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
+
## MapLibre 6 worker
|
|
26
|
+
|
|
27
|
+
With MapLibre GL JS 6, configure the application-owned worker once before mounting an interactive
|
|
28
|
+
map. The worker URL must come from the same `maplibre-gl` package installed by the application.
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
// main.ts
|
|
32
|
+
import workerUrl from 'maplibre-gl/dist/maplibre-gl-worker.mjs?worker&url';
|
|
33
|
+
import {configureTileflowMapLibre} from '@tileflow/svelte';
|
|
34
|
+
|
|
35
|
+
configureTileflowMapLibre({workerUrl});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
This is the Vite setup. Run it before `mount(...)`; `mode="image"` remains MapLibre-free. MapLibre
|
|
39
|
+
GL JS 6.4.1-6.x is supported. Use the `@tileflow/next` or `@tileflow/webpack` README for their
|
|
40
|
+
worker-delivery recipes.
|
|
41
|
+
|
|
25
42
|
`mapOptions` accepts native MapLibre options except `container` and `style`, which
|
|
26
43
|
Tileflow resolves from `source`. Direct
|
|
27
44
|
Tileflow props such as `center`, `zoom`, and `interactive` take priority when
|
|
@@ -186,9 +203,9 @@ present. Application capture selects exactly one ready target.
|
|
|
186
203
|
|
|
187
204
|
## Compatibility
|
|
188
205
|
|
|
189
|
-
The supported peer window is Svelte 5.x and MapLibre GL JS
|
|
190
|
-
Svelte 5.0.0 with the
|
|
191
|
-
the public declarations, and compile real Svelte consumers. Future Svelte majors
|
|
192
|
-
peer range until that matrix passes.
|
|
206
|
+
The supported peer window is Svelte 5.x and MapLibre GL JS 6.4.1-6.x. Compatibility smoke tests
|
|
207
|
+
install Svelte 5.0.0 with the exact lower bound and selected current release from packed Tileflow
|
|
208
|
+
tarballs, typecheck the public declarations, and compile real Svelte consumers. Future Svelte majors
|
|
209
|
+
stay outside the peer range until that matrix passes.
|
|
193
210
|
|
|
194
211
|
Docs: https://tileflow.dev/docs
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tileflow/svelte",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.23",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Svelte component for rendering Tileflow maps with MapLibre.",
|
|
6
6
|
"type": "module",
|
|
@@ -45,14 +45,14 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@tileflow/core": ">=0.1.0-alpha.24 <0.1.0-beta.0",
|
|
48
|
-
"@tileflow/interactions": ">=0.1.0-alpha.
|
|
48
|
+
"@tileflow/interactions": ">=0.1.0-alpha.3 <0.1.0-beta.0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"maplibre-gl": ">=
|
|
51
|
+
"maplibre-gl": ">=6.4.1 <7",
|
|
52
52
|
"svelte": ">=5 <6"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"maplibre-gl": "
|
|
55
|
+
"maplibre-gl": "6.9.0",
|
|
56
56
|
"svelte": "^5.43.17",
|
|
57
57
|
"svelte-check": "^4.3.4"
|
|
58
58
|
},
|
package/src/TileflowMap.svelte
CHANGED
|
@@ -1202,9 +1202,11 @@
|
|
|
1202
1202
|
}
|
|
1203
1203
|
|
|
1204
1204
|
function createTileflowMapLibrePoiMap(map: MapLibreMap): TileflowMapLibrePoiMap {
|
|
1205
|
+
const poiMap = map as unknown as TileflowMapLibrePoiMap;
|
|
1206
|
+
|
|
1205
1207
|
return {
|
|
1206
1208
|
getStyle: () => map.getStyle(),
|
|
1207
|
-
on: (event, listener) =>
|
|
1209
|
+
on: (event, listener) => poiMap.on(event, listener),
|
|
1208
1210
|
queryRenderedFeatures(point, options) {
|
|
1209
1211
|
return map
|
|
1210
1212
|
.queryRenderedFeatures(point as PointLike, {layers: [...options.layers]})
|
package/src/index.d.ts
CHANGED
|
@@ -19,6 +19,10 @@ import type {
|
|
|
19
19
|
export type TileflowMapMode = 'interactive' | 'image';
|
|
20
20
|
export type TileflowMapOptions = Omit<MapLibreMapOptions, 'container' | 'style'>;
|
|
21
21
|
export type TileflowMapSource = TileflowRuntimeSource;
|
|
22
|
+
export type TileflowMapLibreConfiguration = Readonly<{workerUrl: string}>;
|
|
23
|
+
|
|
24
|
+
/** Configure the application-owned worker before mounting an interactive Tileflow map. */
|
|
25
|
+
export function configureTileflowMapLibre(configuration: TileflowMapLibreConfiguration): void;
|
|
22
26
|
|
|
23
27
|
export type TileflowMapAnnotationSnippet<
|
|
24
28
|
TAnnotation extends TileflowAnnotation = TileflowAnnotation,
|
package/src/index.js
CHANGED
package/src/maplibre.js
CHANGED
|
@@ -1,14 +1,39 @@
|
|
|
1
1
|
/** @typedef {typeof import('maplibre-gl')} TileflowMapLibre */
|
|
2
|
+
/** @typedef {{workerUrl: string}} TileflowMapLibreConfiguration */
|
|
2
3
|
|
|
3
4
|
/** @type {Promise<TileflowMapLibre> | undefined} */
|
|
4
5
|
let mapLibrePromise;
|
|
6
|
+
/** @type {TileflowMapLibre | undefined} */
|
|
7
|
+
let mapLibre;
|
|
8
|
+
/** @type {string | undefined} */
|
|
9
|
+
let workerUrl;
|
|
10
|
+
|
|
11
|
+
/** @param {TileflowMapLibreConfiguration} configuration */
|
|
12
|
+
export function configureTileflowMapLibre(configuration) {
|
|
13
|
+
const nextWorkerUrl = configuration.workerUrl;
|
|
14
|
+
|
|
15
|
+
if (typeof nextWorkerUrl !== 'string' || nextWorkerUrl.trim().length === 0) {
|
|
16
|
+
throw new TypeError('Tileflow MapLibre workerUrl must be a non-empty string.');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (workerUrl !== undefined && workerUrl !== nextWorkerUrl) {
|
|
20
|
+
throw new Error('Tileflow MapLibre workerUrl is already configured.');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
workerUrl = nextWorkerUrl;
|
|
24
|
+
mapLibre?.setWorkerUrl(nextWorkerUrl);
|
|
25
|
+
}
|
|
5
26
|
|
|
6
27
|
/** Load the interactive renderer only after a browser map requests it. */
|
|
7
28
|
export function loadTileflowMapLibre() {
|
|
8
|
-
mapLibrePromise ??= import('maplibre-gl')
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
29
|
+
mapLibrePromise ??= import('maplibre-gl')
|
|
30
|
+
.then(resolveMapLibreModule)
|
|
31
|
+
.then(configureTileflowMapLibreModule)
|
|
32
|
+
.catch((error) => {
|
|
33
|
+
mapLibrePromise = undefined;
|
|
34
|
+
throw error;
|
|
35
|
+
});
|
|
36
|
+
|
|
12
37
|
return mapLibrePromise;
|
|
13
38
|
}
|
|
14
39
|
|
|
@@ -16,3 +41,10 @@ export function loadTileflowMapLibre() {
|
|
|
16
41
|
function resolveMapLibreModule(module) {
|
|
17
42
|
return /** @type {TileflowMapLibre & {default?: TileflowMapLibre}} */ (module).default ?? module;
|
|
18
43
|
}
|
|
44
|
+
|
|
45
|
+
/** @param {TileflowMapLibre} maplibregl */
|
|
46
|
+
function configureTileflowMapLibreModule(maplibregl) {
|
|
47
|
+
if (workerUrl !== undefined) maplibregl.setWorkerUrl(workerUrl);
|
|
48
|
+
mapLibre = maplibregl;
|
|
49
|
+
return maplibregl;
|
|
50
|
+
}
|