@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 +33 -314
- package/REFERENCE.md +379 -0
- package/dist/browser.js +6796 -6795
- package/dist/build.d.ts +4 -4
- package/dist/build.js +175 -88
- package/dist/config-reference.json +245 -162
- package/dist/{icon-composition-CInvkr7s.d.ts → icon-composition-2nsUbE87.d.ts} +4 -50
- package/dist/index.d.ts +16 -6
- package/dist/index.js +281 -4
- package/dist/{manifest-types-CcD4OQkJ.d.ts → manifest-types-U7JPDNAo.d.ts} +128 -1
- package/dist/manifest.d.ts +2 -2
- package/dist/native.d.ts +99 -1
- package/dist/native.js +242 -4
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.js +281 -47
- package/package.json +2 -1
package/dist/native.d.ts
CHANGED
|
@@ -70,6 +70,104 @@ type MapLibreStyle = {
|
|
|
70
70
|
metadata?: Record<string, unknown>;
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
+
declare const tileflowOverlayPlacements: readonly ["above-water", "below-roads", "above-roads", "above-buildings", "below-labels", "above-labels"];
|
|
74
|
+
type TileflowOverlayPlacement = (typeof tileflowOverlayPlacements)[number];
|
|
75
|
+
/**
|
|
76
|
+
* A GeoJSON FeatureCollection, the shape MapLibre clustering and `setData` accept. Features are
|
|
77
|
+
* plain objects because typed GeoJSON interfaces, such as `Feature<Point>`, have no index signature.
|
|
78
|
+
*/
|
|
79
|
+
type TileflowGeoJsonFeatureCollection = Readonly<{
|
|
80
|
+
features: readonly object[];
|
|
81
|
+
type: 'FeatureCollection';
|
|
82
|
+
}>;
|
|
83
|
+
/** MapLibre aggregate: `[operator, mapExpression]`, summed into each cluster's properties. */
|
|
84
|
+
type TileflowClusterProperty = readonly [operator: unknown, map: unknown];
|
|
85
|
+
/** Clustering options named as in the Mapbox and MapLibre source specifications. */
|
|
86
|
+
type TileflowGeoJsonClusterOptions = Readonly<{
|
|
87
|
+
/** Group nearby points in the worker. Defaults to false. */
|
|
88
|
+
cluster?: boolean;
|
|
89
|
+
/** The last zoom that clusters; points are separate above it. MapLibre's default is 14. */
|
|
90
|
+
clusterMaxZoom?: number;
|
|
91
|
+
/** The fewest points that form a cluster. MapLibre's default is 2. */
|
|
92
|
+
clusterMinPoints?: number;
|
|
93
|
+
/** Aggregates kept on clusters, such as `{total: ['+', ['get', 'price']]}`. */
|
|
94
|
+
clusterProperties?: Readonly<Record<string, TileflowClusterProperty>>;
|
|
95
|
+
/** Cluster radius in CSS pixels. MapLibre's default is 50. */
|
|
96
|
+
clusterRadius?: number;
|
|
97
|
+
}>;
|
|
98
|
+
type TileflowGeoJsonSource = Readonly<TileflowGeoJsonClusterOptions & {
|
|
99
|
+
attribution?: string;
|
|
100
|
+
data: TileflowGeoJsonFeatureCollection | string;
|
|
101
|
+
kind: 'geojson';
|
|
102
|
+
}>;
|
|
103
|
+
type TileflowMapLibreOverlayLayer = Readonly<Record<string, unknown> & {
|
|
104
|
+
id: string;
|
|
105
|
+
source?: never;
|
|
106
|
+
type: string;
|
|
107
|
+
}>;
|
|
108
|
+
type TileflowMapLibreOverlay = Readonly<{
|
|
109
|
+
kind: 'maplibre-overlay';
|
|
110
|
+
layers: readonly TileflowMapLibreOverlayLayer[];
|
|
111
|
+
placement: TileflowOverlayPlacement;
|
|
112
|
+
source: string;
|
|
113
|
+
}>;
|
|
114
|
+
/**
|
|
115
|
+
* Declare a named GeoJSON source. Omit `data` for a source the application fills at runtime through
|
|
116
|
+
* a framework adapter's `dataSources`.
|
|
117
|
+
*/
|
|
118
|
+
declare function geojsonSource(options?: Readonly<TileflowGeoJsonClusterOptions & {
|
|
119
|
+
attribution?: string;
|
|
120
|
+
data?: TileflowGeoJsonFeatureCollection | string;
|
|
121
|
+
}>): TileflowGeoJsonSource;
|
|
122
|
+
/** Group one or more ordinary MapLibre layers around one named Tileflow source. */
|
|
123
|
+
declare function maplibreOverlay(options: {
|
|
124
|
+
layers: readonly TileflowMapLibreOverlayLayer[];
|
|
125
|
+
placement: TileflowOverlayPlacement;
|
|
126
|
+
source: string;
|
|
127
|
+
}): TileflowMapLibreOverlay;
|
|
128
|
+
/**
|
|
129
|
+
* Draw a clustering GeoJSON source: sized bubbles, their counts, and the separate points. Layers are
|
|
130
|
+
* named `<id>-clusters`, `<id>-cluster-count` and `<id>-points`. The count uses the map's label font
|
|
131
|
+
* unless `font` names another. Framework adapters zoom into a clicked cluster.
|
|
132
|
+
*/
|
|
133
|
+
declare function clusterOverlay(options: {
|
|
134
|
+
/** Bubble colours by point count: the first applies below `steps[0]`. */
|
|
135
|
+
colors?: readonly [string, string, string];
|
|
136
|
+
/** Zoom in when a cluster is clicked or tapped. Defaults to true. */
|
|
137
|
+
expandOnClick?: boolean;
|
|
138
|
+
/** An exact text-font stack, for maps whose labels use another font. */
|
|
139
|
+
font?: readonly string[];
|
|
140
|
+
id: string;
|
|
141
|
+
placement: TileflowOverlayPlacement;
|
|
142
|
+
/** Colour of the separate points. */
|
|
143
|
+
pointColor?: string;
|
|
144
|
+
/** Bubble radii in pixels, matching `colors`. */
|
|
145
|
+
radii?: readonly [number, number, number];
|
|
146
|
+
source: string;
|
|
147
|
+
/** The two point counts where bubbles change size and colour. */
|
|
148
|
+
steps?: readonly [number, number];
|
|
149
|
+
textColor?: string;
|
|
150
|
+
}): TileflowMapLibreOverlay;
|
|
151
|
+
/**
|
|
152
|
+
* Draw point density from a GeoJSON source or a hosted vector tileset. `weight` is a number or a
|
|
153
|
+
* MapLibre expression; values above 1 make a point count for more than one.
|
|
154
|
+
*/
|
|
155
|
+
declare function heatmapOverlay(options: {
|
|
156
|
+
/** `[density, color]` stops from 0 to 1. Start transparent so empty areas stay clear. */
|
|
157
|
+
colors?: readonly (readonly [density: number, color: string])[];
|
|
158
|
+
id: string;
|
|
159
|
+
intensity?: unknown;
|
|
160
|
+
/** Above this zoom the layer is not drawn, for handing over to points or clusters. */
|
|
161
|
+
maxZoom?: number;
|
|
162
|
+
opacity?: unknown;
|
|
163
|
+
placement: TileflowOverlayPlacement;
|
|
164
|
+
radius?: unknown;
|
|
165
|
+
source: string;
|
|
166
|
+
/** The source-layer of a vector tileset. GeoJSON sources have none. */
|
|
167
|
+
sourceLayer?: string;
|
|
168
|
+
weight?: unknown;
|
|
169
|
+
}): TileflowMapLibreOverlay;
|
|
170
|
+
|
|
73
171
|
/** Runtime-ready logical map with all relative theme resources already resolved. */
|
|
74
172
|
type TileflowRuntimeManifestMap = TileflowRuntimeManifestMapEntry & {
|
|
75
173
|
apiUrl?: string;
|
|
@@ -455,4 +553,4 @@ declare const tileflowMobileDiscoveryMaximumBytes = 4096;
|
|
|
455
553
|
/** Bind every advertised representation to the exact Hosted origin and Map being requested. */
|
|
456
554
|
declare function parseTileflowMobileDiscovery(value: unknown, discoveryUrl: string): TileflowMobileDiscovery;
|
|
457
555
|
|
|
458
|
-
export { type CreateBoundaryFeatureStateOptions, type TileflowBoundaryFamily, type TileflowBoundaryFeatureState, type TileflowBoundaryRow, type TileflowBoundaryValues, type TileflowFeatureStateMap, type TileflowMobileDiscovery, type TileflowNativeAbortSignal, type TileflowNativeInitialView, type TileflowNativeInitialViewOptions, type TileflowNativeManifestAcquire, type TileflowNativeManifestLoadOptions, type TileflowNativeManifestOperation, type TileflowNativeManifestReader, type TileflowNativeManifestResponse, type TileflowNativeManifestResult, type TileflowNativeNetworkOptions, type TileflowNativeResourceUrlOptions, type TileflowNativeSource, type TileflowNativeSourceController, TileflowNativeSourceError, type TileflowNativeSourceErrorCode, type TileflowNativeSourceErrorField, type TileflowNativeSourceOptions, type TileflowNativeSourceState, TileflowNativeUrlError, type TileflowNativeUrlErrorCode, type TileflowNativeUrlField, type TileflowThemeBlendClock, TileflowThemeBlendError, type TileflowThemeBlendImage, type TileflowThemeBlendOptions, type TileflowThemeBlendPaint, type TileflowThemeBlendPlan, type TileflowThemeBlendSelection, type TileflowThemeBlendSwitch, type TileflowTimeOfDay, type TileflowTimeOfDayVariants, createBoundaryFeatureState, createTileflowNativeSourceController, fillTileflowThemeBlendTemplate, loadTileflowNativeManifest, nearestTileflowBlendTheme, parseTileflowMobileDiscovery, planTileflowThemeBlend, resolveTileflowNativeInitialView, resolveTileflowNativeManifestUrl, resolveTileflowNativeResourceUrl, tileflowBoundaryFamilies, tileflowMobileDiscoveryMaximumBytes, tileflowNativeManifestLimits, tileflowNativeUrlLimits, tileflowThemeBlendLimits, validateTileflowThemeBlendSelection };
|
|
556
|
+
export { type CreateBoundaryFeatureStateOptions, type TileflowBoundaryFamily, type TileflowBoundaryFeatureState, type TileflowBoundaryRow, type TileflowBoundaryValues, type TileflowFeatureStateMap, type TileflowGeoJsonSource, type TileflowMapLibreOverlay, type TileflowMobileDiscovery, type TileflowNativeAbortSignal, type TileflowNativeInitialView, type TileflowNativeInitialViewOptions, type TileflowNativeManifestAcquire, type TileflowNativeManifestLoadOptions, type TileflowNativeManifestOperation, type TileflowNativeManifestReader, type TileflowNativeManifestResponse, type TileflowNativeManifestResult, type TileflowNativeNetworkOptions, type TileflowNativeResourceUrlOptions, type TileflowNativeSource, type TileflowNativeSourceController, TileflowNativeSourceError, type TileflowNativeSourceErrorCode, type TileflowNativeSourceErrorField, type TileflowNativeSourceOptions, type TileflowNativeSourceState, TileflowNativeUrlError, type TileflowNativeUrlErrorCode, type TileflowNativeUrlField, type TileflowOverlayPlacement, type TileflowThemeBlendClock, TileflowThemeBlendError, type TileflowThemeBlendImage, type TileflowThemeBlendOptions, type TileflowThemeBlendPaint, type TileflowThemeBlendPlan, type TileflowThemeBlendSelection, type TileflowThemeBlendSwitch, type TileflowTimeOfDay, type TileflowTimeOfDayVariants, clusterOverlay, createBoundaryFeatureState, createTileflowNativeSourceController, fillTileflowThemeBlendTemplate, geojsonSource, heatmapOverlay, loadTileflowNativeManifest, maplibreOverlay, nearestTileflowBlendTheme, parseTileflowMobileDiscovery, planTileflowThemeBlend, resolveTileflowNativeInitialView, resolveTileflowNativeManifestUrl, resolveTileflowNativeResourceUrl, tileflowBoundaryFamilies, tileflowMobileDiscoveryMaximumBytes, tileflowNativeManifestLimits, tileflowNativeUrlLimits, tileflowThemeBlendLimits, validateTileflowThemeBlendSelection };
|
package/dist/native.js
CHANGED
|
@@ -4326,6 +4326,18 @@ function planTileflowThemeBlend(styles, options = {}) {
|
|
|
4326
4326
|
function fillTileflowThemeBlendTemplate(template, position) {
|
|
4327
4327
|
return fillTemplate(template, position);
|
|
4328
4328
|
}
|
|
4329
|
+
function mixTileflowColours(from, to, t) {
|
|
4330
|
+
const a = oklab(from);
|
|
4331
|
+
const b = oklab(to);
|
|
4332
|
+
if (!a || !b) return void 0;
|
|
4333
|
+
const alpha = a[3] + (b[3] - a[3]) * t;
|
|
4334
|
+
if (alpha <= 0) return "rgba(0, 0, 0, 0)";
|
|
4335
|
+
const channels = a.slice(0, 3).map((value, channel) => {
|
|
4336
|
+
const from2 = value * a[3];
|
|
4337
|
+
return (from2 + (b[channel] * b[3] - from2) * t) / alpha;
|
|
4338
|
+
});
|
|
4339
|
+
return colourFromOklab([...channels, alpha]);
|
|
4340
|
+
}
|
|
4329
4341
|
function fillLayer(layer, position, dominant, layerSwitches) {
|
|
4330
4342
|
const filled = { ...layer };
|
|
4331
4343
|
for (const group of ["layout", "paint"]) {
|
|
@@ -4369,10 +4381,7 @@ function mixLeaf(values, position) {
|
|
|
4369
4381
|
if (t <= 0 || from === to) return from;
|
|
4370
4382
|
if (t >= 1) return to;
|
|
4371
4383
|
if (typeof from === "number" && typeof to === "number") return from + (to - from) * t;
|
|
4372
|
-
|
|
4373
|
-
const b = oklab(String(to));
|
|
4374
|
-
if (!a || !b) return t < 0.5 ? from : to;
|
|
4375
|
-
return colourFromOklab(a.map((value, channel) => value + (b[channel] - value) * t));
|
|
4384
|
+
return mixTileflowColours(String(from), String(to), t) ?? (t < 0.5 ? from : to);
|
|
4376
4385
|
}
|
|
4377
4386
|
function clampPosition(position, themes) {
|
|
4378
4387
|
if (!Number.isFinite(position)) return 0;
|
|
@@ -6061,6 +6070,231 @@ init_portable_identity_rules();
|
|
|
6061
6070
|
// src/runtime.ts
|
|
6062
6071
|
init_portable_identity_rules();
|
|
6063
6072
|
init_time_of_day();
|
|
6073
|
+
|
|
6074
|
+
// src/overlays.ts
|
|
6075
|
+
init_portable_identity_rules();
|
|
6076
|
+
var tileflowOverlayPlacements = [
|
|
6077
|
+
"above-water",
|
|
6078
|
+
"below-roads",
|
|
6079
|
+
"above-roads",
|
|
6080
|
+
"above-buildings",
|
|
6081
|
+
"below-labels",
|
|
6082
|
+
"above-labels"
|
|
6083
|
+
];
|
|
6084
|
+
var tileflowClusterMetadataKey = "tileflow:cluster";
|
|
6085
|
+
function geojsonSource(options = {}) {
|
|
6086
|
+
const data = options.data ?? { features: [], type: "FeatureCollection" };
|
|
6087
|
+
if (typeof data === "string") {
|
|
6088
|
+
if (!isHttpsUrl(data)) {
|
|
6089
|
+
throw new Error("Tileflow GeoJSON source URLs must be absolute https:// URLs.");
|
|
6090
|
+
}
|
|
6091
|
+
} else if (!isPlainRecord(data) || data.type !== "FeatureCollection" || !Array.isArray(data.features)) {
|
|
6092
|
+
throw new Error("Tileflow GeoJSON source data must be a FeatureCollection or an https:// URL.");
|
|
6093
|
+
}
|
|
6094
|
+
assertClusterOptions(options);
|
|
6095
|
+
const attribution = options.attribution?.trim();
|
|
6096
|
+
return Object.freeze({
|
|
6097
|
+
...attribution ? { attribution } : {},
|
|
6098
|
+
...pickClusterOptions(options),
|
|
6099
|
+
data: typeof data === "string" ? data : Object.freeze(cloneJson(data)),
|
|
6100
|
+
kind: "geojson"
|
|
6101
|
+
});
|
|
6102
|
+
}
|
|
6103
|
+
function maplibreOverlay(options) {
|
|
6104
|
+
if (!isTileflowPortableId(options.source)) {
|
|
6105
|
+
throw new Error(`Invalid Tileflow overlay source ID: ${options.source}.`);
|
|
6106
|
+
}
|
|
6107
|
+
if (!tileflowOverlayPlacements.includes(options.placement)) {
|
|
6108
|
+
throw new Error(`Invalid Tileflow overlay placement: ${String(options.placement)}.`);
|
|
6109
|
+
}
|
|
6110
|
+
if (!Array.isArray(options.layers) || options.layers.length < 1) {
|
|
6111
|
+
throw new Error("Tileflow MapLibre overlays require at least one layer.");
|
|
6112
|
+
}
|
|
6113
|
+
const layers = options.layers.map((layer, index) => {
|
|
6114
|
+
if (!isPlainRecord(layer)) {
|
|
6115
|
+
throw new Error(`Tileflow overlay layer ${index} must be a plain object.`);
|
|
6116
|
+
}
|
|
6117
|
+
if (!isTileflowPortableId(layer.id)) {
|
|
6118
|
+
throw new Error(`Invalid Tileflow overlay layer ID: ${String(layer.id)}.`);
|
|
6119
|
+
}
|
|
6120
|
+
if (layer.id === "tileflow" || layer.id.startsWith("tileflow-")) {
|
|
6121
|
+
throw new Error(`Tileflow overlay layer ID is reserved: ${layer.id}.`);
|
|
6122
|
+
}
|
|
6123
|
+
if (typeof layer.type !== "string" || !layer.type) {
|
|
6124
|
+
throw new Error(`Tileflow overlay layer ${layer.id} requires a MapLibre type.`);
|
|
6125
|
+
}
|
|
6126
|
+
if (Object.hasOwn(layer, "source")) {
|
|
6127
|
+
throw new Error(
|
|
6128
|
+
`Tileflow overlay layer ${layer.id} inherits its source from the overlay and must not declare source.`
|
|
6129
|
+
);
|
|
6130
|
+
}
|
|
6131
|
+
return Object.freeze(cloneJson(layer));
|
|
6132
|
+
});
|
|
6133
|
+
return Object.freeze({
|
|
6134
|
+
kind: "maplibre-overlay",
|
|
6135
|
+
layers: Object.freeze(layers),
|
|
6136
|
+
placement: options.placement,
|
|
6137
|
+
source: options.source
|
|
6138
|
+
});
|
|
6139
|
+
}
|
|
6140
|
+
function clusterOverlay(options) {
|
|
6141
|
+
const colors = options.colors ?? ["#2563eb", "#7c3aed", "#db2777"];
|
|
6142
|
+
const radii = options.radii ?? [16, 22, 30];
|
|
6143
|
+
const [low, high] = options.steps ?? [100, 750];
|
|
6144
|
+
if (!(low > 0 && high > low) || !radii.every((radius) => radius > 0)) {
|
|
6145
|
+
throw new Error("Tileflow cluster steps must increase and radii must be positive.");
|
|
6146
|
+
}
|
|
6147
|
+
const metadata = (role) => ({
|
|
6148
|
+
[tileflowClusterMetadataKey]: {
|
|
6149
|
+
expandOnClick: options.expandOnClick ?? true,
|
|
6150
|
+
role
|
|
6151
|
+
}
|
|
6152
|
+
});
|
|
6153
|
+
const step = (values) => [
|
|
6154
|
+
"step",
|
|
6155
|
+
["get", "point_count"],
|
|
6156
|
+
values[0],
|
|
6157
|
+
low,
|
|
6158
|
+
values[1],
|
|
6159
|
+
high,
|
|
6160
|
+
values[2]
|
|
6161
|
+
];
|
|
6162
|
+
return maplibreOverlay({
|
|
6163
|
+
layers: [
|
|
6164
|
+
{
|
|
6165
|
+
filter: ["has", "point_count"],
|
|
6166
|
+
id: `${options.id}-clusters`,
|
|
6167
|
+
metadata: metadata("cluster"),
|
|
6168
|
+
paint: {
|
|
6169
|
+
"circle-color": step(colors),
|
|
6170
|
+
"circle-radius": step(radii),
|
|
6171
|
+
"circle-stroke-color": "#ffffff",
|
|
6172
|
+
"circle-stroke-width": 2
|
|
6173
|
+
},
|
|
6174
|
+
type: "circle"
|
|
6175
|
+
},
|
|
6176
|
+
{
|
|
6177
|
+
filter: ["has", "point_count"],
|
|
6178
|
+
id: `${options.id}-cluster-count`,
|
|
6179
|
+
layout: {
|
|
6180
|
+
"text-allow-overlap": true,
|
|
6181
|
+
"text-field": ["get", "point_count_abbreviated"],
|
|
6182
|
+
...options.font ? { "text-font": [...options.font] } : {},
|
|
6183
|
+
"text-ignore-placement": true,
|
|
6184
|
+
"text-size": 13
|
|
6185
|
+
},
|
|
6186
|
+
metadata: metadata("count"),
|
|
6187
|
+
paint: { "text-color": options.textColor ?? "#ffffff" },
|
|
6188
|
+
type: "symbol"
|
|
6189
|
+
},
|
|
6190
|
+
{
|
|
6191
|
+
filter: ["!", ["has", "point_count"]],
|
|
6192
|
+
id: `${options.id}-points`,
|
|
6193
|
+
metadata: metadata("point"),
|
|
6194
|
+
paint: {
|
|
6195
|
+
"circle-color": options.pointColor ?? colors[0],
|
|
6196
|
+
"circle-radius": 6,
|
|
6197
|
+
"circle-stroke-color": "#ffffff",
|
|
6198
|
+
"circle-stroke-width": 1.5
|
|
6199
|
+
},
|
|
6200
|
+
type: "circle"
|
|
6201
|
+
}
|
|
6202
|
+
],
|
|
6203
|
+
placement: options.placement,
|
|
6204
|
+
source: options.source
|
|
6205
|
+
});
|
|
6206
|
+
}
|
|
6207
|
+
function heatmapOverlay(options) {
|
|
6208
|
+
const colors = options.colors ?? [
|
|
6209
|
+
[0, "rgba(33, 102, 172, 0)"],
|
|
6210
|
+
[0.2, "#67a9cf"],
|
|
6211
|
+
[0.4, "#d1e5f0"],
|
|
6212
|
+
[0.6, "#fddbc7"],
|
|
6213
|
+
[0.8, "#ef8a62"],
|
|
6214
|
+
[1, "#b2182b"]
|
|
6215
|
+
];
|
|
6216
|
+
if (colors.length < 2 || colors.some(([density], index) => {
|
|
6217
|
+
const previous = colors[index - 1]?.[0] ?? -1;
|
|
6218
|
+
return !(density >= 0 && density <= 1 && density > previous);
|
|
6219
|
+
})) {
|
|
6220
|
+
throw new Error("Tileflow heatmap colors need at least two increasing densities from 0 to 1.");
|
|
6221
|
+
}
|
|
6222
|
+
const paint = {
|
|
6223
|
+
"heatmap-color": ["interpolate", ["linear"], ["heatmap-density"], ...colors.flat()],
|
|
6224
|
+
"heatmap-intensity": options.intensity ?? 1,
|
|
6225
|
+
"heatmap-opacity": options.opacity ?? 0.8,
|
|
6226
|
+
"heatmap-radius": options.radius ?? 30,
|
|
6227
|
+
"heatmap-weight": options.weight ?? 1
|
|
6228
|
+
};
|
|
6229
|
+
return maplibreOverlay({
|
|
6230
|
+
layers: [
|
|
6231
|
+
{
|
|
6232
|
+
id: options.id,
|
|
6233
|
+
...options.maxZoom === void 0 ? {} : { maxzoom: options.maxZoom },
|
|
6234
|
+
paint,
|
|
6235
|
+
...options.sourceLayer === void 0 ? {} : { "source-layer": options.sourceLayer },
|
|
6236
|
+
type: "heatmap"
|
|
6237
|
+
}
|
|
6238
|
+
],
|
|
6239
|
+
placement: options.placement,
|
|
6240
|
+
source: options.source
|
|
6241
|
+
});
|
|
6242
|
+
}
|
|
6243
|
+
function pickClusterOptions(source) {
|
|
6244
|
+
return {
|
|
6245
|
+
...source.cluster === void 0 ? {} : { cluster: source.cluster },
|
|
6246
|
+
...source.clusterMaxZoom === void 0 ? {} : { clusterMaxZoom: source.clusterMaxZoom },
|
|
6247
|
+
...source.clusterMinPoints === void 0 ? {} : { clusterMinPoints: source.clusterMinPoints },
|
|
6248
|
+
...source.clusterProperties === void 0 ? {} : { clusterProperties: cloneJson(source.clusterProperties) },
|
|
6249
|
+
...source.clusterRadius === void 0 ? {} : { clusterRadius: source.clusterRadius }
|
|
6250
|
+
};
|
|
6251
|
+
}
|
|
6252
|
+
function assertClusterOptions(options) {
|
|
6253
|
+
const { cluster, clusterMaxZoom, clusterMinPoints, clusterProperties, clusterRadius } = options;
|
|
6254
|
+
if (cluster !== void 0 && typeof cluster !== "boolean") {
|
|
6255
|
+
throw new Error("Tileflow GeoJSON cluster must be a boolean.");
|
|
6256
|
+
}
|
|
6257
|
+
if (clusterRadius !== void 0 && !(Number.isFinite(clusterRadius) && clusterRadius > 0)) {
|
|
6258
|
+
throw new Error("Tileflow clusterRadius must be a positive number of pixels.");
|
|
6259
|
+
}
|
|
6260
|
+
if (clusterMaxZoom !== void 0 && !(Number.isFinite(clusterMaxZoom) && clusterMaxZoom >= 0 && clusterMaxZoom <= 24)) {
|
|
6261
|
+
throw new Error("Tileflow clusterMaxZoom must be a zoom from 0 to 24.");
|
|
6262
|
+
}
|
|
6263
|
+
if (clusterMinPoints !== void 0 && !(Number.isInteger(clusterMinPoints) && clusterMinPoints >= 2)) {
|
|
6264
|
+
throw new Error("Tileflow clusterMinPoints must be an integer of at least 2.");
|
|
6265
|
+
}
|
|
6266
|
+
if (!cluster && [clusterMaxZoom, clusterMinPoints, clusterProperties, clusterRadius].some(
|
|
6267
|
+
(value) => value !== void 0
|
|
6268
|
+
)) {
|
|
6269
|
+
throw new Error("Tileflow cluster options require cluster: true.");
|
|
6270
|
+
}
|
|
6271
|
+
for (const [name, value] of Object.entries(clusterProperties ?? {})) {
|
|
6272
|
+
if (!Array.isArray(value) || value.length !== 2) {
|
|
6273
|
+
throw new Error(`Tileflow clusterProperties.${name} must be [operator, mapExpression].`);
|
|
6274
|
+
}
|
|
6275
|
+
}
|
|
6276
|
+
}
|
|
6277
|
+
function isHttpsUrl(value) {
|
|
6278
|
+
try {
|
|
6279
|
+
return new URL(value).protocol === "https:";
|
|
6280
|
+
} catch {
|
|
6281
|
+
return false;
|
|
6282
|
+
}
|
|
6283
|
+
}
|
|
6284
|
+
function cloneJson(value) {
|
|
6285
|
+
if (Array.isArray(value)) return value.map(cloneJson);
|
|
6286
|
+
if (!isPlainRecord(value)) return value;
|
|
6287
|
+
return Object.fromEntries(
|
|
6288
|
+
Object.entries(value).map(([key, child]) => [key, cloneJson(child)])
|
|
6289
|
+
);
|
|
6290
|
+
}
|
|
6291
|
+
function isPlainRecord(value) {
|
|
6292
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
6293
|
+
const prototype = Object.getPrototypeOf(value);
|
|
6294
|
+
return prototype === Object.prototype || prototype === null;
|
|
6295
|
+
}
|
|
6296
|
+
|
|
6297
|
+
// src/runtime.ts
|
|
6064
6298
|
var defaultTileflowRuntimeView = Object.freeze({
|
|
6065
6299
|
bearing: 0,
|
|
6066
6300
|
center: [0, 20],
|
|
@@ -6530,10 +6764,14 @@ export {
|
|
|
6530
6764
|
TileflowNativeSourceError,
|
|
6531
6765
|
TileflowNativeUrlError,
|
|
6532
6766
|
TileflowThemeBlendError,
|
|
6767
|
+
clusterOverlay,
|
|
6533
6768
|
createBoundaryFeatureState,
|
|
6534
6769
|
createTileflowNativeSourceController,
|
|
6535
6770
|
fillTileflowThemeBlendTemplate,
|
|
6771
|
+
geojsonSource,
|
|
6772
|
+
heatmapOverlay,
|
|
6536
6773
|
loadTileflowNativeManifest,
|
|
6774
|
+
maplibreOverlay,
|
|
6537
6775
|
nearestTileflowBlendTheme,
|
|
6538
6776
|
parseTileflowMobileDiscovery,
|
|
6539
6777
|
planTileflowThemeBlend,
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { R as TileflowAnalytics, cy as TileflowAppearanceSelection, cz as TileflowColorOverrides, an as TileflowManifestFetchOptions, ao as TileflowManifestLoadOptions, aq as TileflowMapMode, ar as TileflowMapModeOptions, aG as TileflowResolvedRuntimeTheme, b2 as TileflowRuntimeCenterLike, a as TileflowRuntimeColorScheme, T as TileflowRuntimeManifest, b3 as TileflowRuntimeManifestMap, b as TileflowRuntimeManifestMapEntry, c as TileflowRuntimeManifestTheme, b4 as TileflowRuntimeSource, b5 as TileflowRuntimeSourceValidation, b6 as TileflowRuntimeStyle, b7 as TileflowRuntimeStyleOptions, d as TileflowRuntimeSystemThemes, b8 as TileflowRuntimeViewOptions, b9 as TileflowSessionController, ba as TileflowSessionGrantResponse, j as TileflowStyleFamily, be as TileflowStyleFontFace, bz as TileflowThemeBlendSelection, bG as TileflowThemeSelection, e as TileflowTimeOfDay, f as TileflowTimeOfDayVariants, cA as applyTileflowColorOverrides, bO as assertValidTileflowRuntimeSource, bP as clearTileflowManifestCache, bQ as clusterOverlay, bS as createTileflowSessionController, bT as createTileflowSessionId, bU as defaultTileflowManifestUrl, bV as defaultTileflowRuntimeView, l as expandTileflowFamilyTemplate, bX as geojsonSource, bY as getTileflowAnalyticsApiUrl, bZ as getTileflowStyleFontFaces, b_ as heatmapOverlay, c0 as inferTileflowAnalyticsFromStyleUrl, c2 as isTileflowTimeOfDay, c3 as loadTileflowManifest, cB as loadTileflowRuntimeAppearance, cC as loadTileflowStyleFamily, c4 as maplibreOverlay, n as materializeTileflowStyleFamily, c5 as mergeTileflowAnalytics, c6 as nearestTileflowBlendTheme, c7 as normalizeTileflowRuntimeCenter, c8 as normalizeTileflowStaticImageSize, cD as normalizeTileflowSurfaceId, c9 as normalizeTileflowUrl, p as parseTileflowStyleFamily, cE as prepareTileflowStyleFamilyForRendering, cb as resolveTileflowAnalyticsRequestUrl, cF as resolveTileflowAppearance, cG as resolveTileflowFamilyResourceUrls, cc as resolveTileflowManifestMap, cd as resolveTileflowMapMode, ce as resolveTileflowRuntimeStyle, cf as resolveTileflowRuntimeTheme, cg as resolveTileflowRuntimeThemeBlend, ch as resolveTileflowRuntimeView, ci as resolveTileflowStaticImageUrl, cH as resolveTileflowStyleResourceUrls, cj as shouldLoadTileflowManifest, ck as startTileflowSession, o as tileflowStyleFamilyLimits, cm as tileflowStyleFontFaceLimits, cn as tileflowStyleFontFacesMetadataKey, co as tileflowThemeBlendLimits, cq as tileflowTimesOfDay, cs as validateTileflowRuntimeSource, ct as validateTileflowThemeBlendSelection, cu as validateTileflowThemeSelection, w as withTileflowFamilyTemplate } from './manifest-types-U7JPDNAo.js';
|