@tileflow/core 0.1.0-alpha.21 → 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 +201 -72
- package/THIRD_PARTY_NOTICES.md +60 -2
- package/dist/browser.d.ts +82 -16
- package/dist/browser.js +1234 -267
- package/dist/build.d.ts +19 -56
- package/dist/build.js +10915 -8333
- package/dist/config-reference.json +31882 -0
- package/dist/index.d.ts +476 -13
- package/dist/index.js +12409 -8832
- package/dist/{types-DlUGI6LC.d.ts → manifest-B5GKVMFE.d.ts} +252 -20
- package/dist/manifest.d.ts +1 -2
- package/dist/manifest.js +18 -2
- package/dist/map-BHL_0Mkx.d.ts +1145 -0
- package/dist/runtime.d.ts +1 -2
- package/dist/runtime.js +60 -5
- package/package.json +5 -8
- package/dist/domains-CPSrdTik.d.ts +0 -4
- package/dist/recipe.d.ts +0 -66
- package/dist/recipe.js +0 -577
- package/dist/requirements-BV77ZVhR.d.ts +0 -491
- package/dist/runtime-C4MtSzkB.d.ts +0 -223
- package/dist/visual-semantics-DTC-8Hsb.d.ts +0 -479
package/dist/runtime.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
import './types-DlUGI6LC.js';
|
|
1
|
+
export { t as TileflowAnalytics, U as TileflowManifestFetchOptions, W as TileflowManifestLoadOptions, X as TileflowMapMode, Y as TileflowMapModeOptions, a8 as TileflowResolvedRuntimeTheme, av as TileflowRuntimeCenterLike, aw as TileflowRuntimeColorScheme, T as TileflowRuntimeManifest, ax as TileflowRuntimeManifestMap, ay as TileflowRuntimeManifestMapEntry, az as TileflowRuntimeManifestTheme, aA as TileflowRuntimeSource, aB as TileflowRuntimeSourceValidation, aC as TileflowRuntimeStyle, aD as TileflowRuntimeStyleOptions, aE as TileflowRuntimeSystemThemes, aF as TileflowRuntimeViewOptions, aG as TileflowSessionController, aH as TileflowSessionGrantResponse, aK as TileflowStyleFontFace, b7 as TileflowThemeSelection, bf as assertValidTileflowRuntimeSource, bg as clearTileflowManifestCache, bi as createTileflowSessionController, bj as createTileflowSessionId, bk as defaultTileflowManifestUrl, bl as defaultTileflowRuntimeView, bn as getTileflowAnalyticsApiUrl, bo as getTileflowStyleFontFaces, bp as inferTileflowAnalyticsFromStyleUrl, bq as loadTileflowManifest, br as mergeTileflowAnalytics, bs as normalizeTileflowRuntimeCenter, bt as normalizeTileflowStaticImageSize, bT as normalizeTileflowSurfaceId, bu as normalizeTileflowUrl, bw as resolveTileflowAnalyticsRequestUrl, bx as resolveTileflowManifestMap, by as resolveTileflowMapMode, bz as resolveTileflowRuntimeStyle, bA as resolveTileflowRuntimeTheme, bB as resolveTileflowRuntimeView, bC as resolveTileflowStaticImageUrl, bE as shouldLoadTileflowManifest, bF as startTileflowSession, bK as tileflowStyleFontFaceLimits, bL as tileflowStyleFontFacesMetadataKey, bO as validateTileflowRuntimeSource, bP as validateTileflowThemeSelection } from './manifest-B5GKVMFE.js';
|
|
3
2
|
import 'zod';
|
package/dist/runtime.js
CHANGED
|
@@ -49,6 +49,39 @@ var init_portable_identity = __esm({
|
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
+
// src/themes/visual-semantics.ts
|
|
53
|
+
var init_visual_semantics = __esm({
|
|
54
|
+
"src/themes/visual-semantics.ts"() {
|
|
55
|
+
"use strict";
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// src/themes/model.ts
|
|
60
|
+
var tileflowThemeLimits, themeTypographyStyleKeys, themeTypographyKeys;
|
|
61
|
+
var init_model = __esm({
|
|
62
|
+
"src/themes/model.ts"() {
|
|
63
|
+
"use strict";
|
|
64
|
+
tileflowThemeLimits = Object.freeze({ maxThemes: 64 });
|
|
65
|
+
themeTypographyStyleKeys = ["fallbacks", "font", "letterSpacing", "transform"];
|
|
66
|
+
themeTypographyKeys = [
|
|
67
|
+
...themeTypographyStyleKeys,
|
|
68
|
+
"places",
|
|
69
|
+
"poi",
|
|
70
|
+
"roads",
|
|
71
|
+
"water"
|
|
72
|
+
];
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// src/themes/index.ts
|
|
77
|
+
var init_themes = __esm({
|
|
78
|
+
"src/themes/index.ts"() {
|
|
79
|
+
"use strict";
|
|
80
|
+
init_model();
|
|
81
|
+
init_visual_semantics();
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
52
85
|
// src/manifest.ts
|
|
53
86
|
var manifest_exports = {};
|
|
54
87
|
__export(manifest_exports, {
|
|
@@ -145,6 +178,7 @@ var init_manifest = __esm({
|
|
|
145
178
|
"src/manifest.ts"() {
|
|
146
179
|
"use strict";
|
|
147
180
|
init_portable_identity();
|
|
181
|
+
init_themes();
|
|
148
182
|
tileflowRuntimeManifestVersion = 1;
|
|
149
183
|
tileflowRuntimeManifestLimits = Object.freeze({ maximumBytes: 1024 * 1024 });
|
|
150
184
|
safeTextSchema = z2.string().min(1).max(2048).refine((value) => value === value.trim(), "Expected text without surrounding whitespace").refine((value) => !/[\p{Cc}\\]/u.test(value), "Expected safe text");
|
|
@@ -189,8 +223,13 @@ var init_manifest = __esm({
|
|
|
189
223
|
if (names.length === 0) {
|
|
190
224
|
context.addIssue({ code: "custom", message: "Expected at least one theme", path: ["themes"] });
|
|
191
225
|
}
|
|
192
|
-
if (names.length >
|
|
193
|
-
context.addIssue({
|
|
226
|
+
if (names.length > tileflowThemeLimits.maxThemes) {
|
|
227
|
+
context.addIssue({
|
|
228
|
+
code: "too_big",
|
|
229
|
+
maximum: tileflowThemeLimits.maxThemes,
|
|
230
|
+
origin: "object",
|
|
231
|
+
path: ["themes"]
|
|
232
|
+
});
|
|
194
233
|
}
|
|
195
234
|
if (!Object.hasOwn(entry.themes, entry.defaultTheme)) {
|
|
196
235
|
context.addIssue({
|
|
@@ -269,6 +308,10 @@ var defaultTileflowRuntimeView = Object.freeze({
|
|
|
269
308
|
pitch: 0,
|
|
270
309
|
zoom: 2
|
|
271
310
|
});
|
|
311
|
+
var tileflowSurfaceIdPattern = /^[a-z0-9](?:[a-z0-9._-]{0,62}[a-z0-9])?$/u;
|
|
312
|
+
function normalizeTileflowSurfaceId(value) {
|
|
313
|
+
return typeof value === "string" && tileflowSurfaceIdPattern.test(value) ? value : "default";
|
|
314
|
+
}
|
|
272
315
|
var tileflowStyleFontFacesMetadataKey = "tileflow:fontFaces";
|
|
273
316
|
var tileflowStyleFontFaceLimits = Object.freeze({
|
|
274
317
|
maximumCount: 16,
|
|
@@ -551,7 +594,8 @@ async function requestSessionGrant(input) {
|
|
|
551
594
|
sdkVersion: input.analytics.sdkVersion,
|
|
552
595
|
sessionId: input.sessionId,
|
|
553
596
|
source: input.analytics.source ?? input.source,
|
|
554
|
-
styleId: input.analytics.styleId
|
|
597
|
+
styleId: input.analytics.styleId,
|
|
598
|
+
surfaceId: normalizeTileflowSurfaceId(input.analytics.surfaceId)
|
|
555
599
|
}),
|
|
556
600
|
credentials: "omit",
|
|
557
601
|
headers: { "Content-Type": "application/json" },
|
|
@@ -693,11 +737,19 @@ function isEligibleResource(value, mapId, apiOrigin, grantedOrigins) {
|
|
|
693
737
|
if (url.username || url.password) return false;
|
|
694
738
|
const originAllowed = url.origin === apiOrigin || grantedOrigins?.has(url.origin) || apiOrigin === "https://api.tileflow.dev" && url.origin === "https://cdn.tileflow.dev";
|
|
695
739
|
if (!originAllowed) return false;
|
|
696
|
-
return url.pathname
|
|
740
|
+
return isHostedStylePath(url.pathname, mapId) || url.pathname.startsWith("/tiles/") || url.pathname.startsWith("/v1/tiles/") || url.pathname.startsWith("/fonts/") || url.pathname.startsWith("/sprites/");
|
|
697
741
|
} catch {
|
|
698
742
|
return false;
|
|
699
743
|
}
|
|
700
744
|
}
|
|
745
|
+
function isHostedStylePath(pathname, mapId) {
|
|
746
|
+
const prefix = `/maps/${encodeURIComponent(mapId)}/`;
|
|
747
|
+
if (!pathname.startsWith(prefix)) return false;
|
|
748
|
+
const file = pathname.slice(prefix.length);
|
|
749
|
+
if (file === "style.json") return true;
|
|
750
|
+
if (!file.endsWith(".json")) return false;
|
|
751
|
+
return isTileflowThemeName(file.slice(0, -".json".length));
|
|
752
|
+
}
|
|
701
753
|
function originOf(value) {
|
|
702
754
|
if (typeof value !== "string") return null;
|
|
703
755
|
try {
|
|
@@ -739,6 +791,7 @@ function startTileflowSession(analytics, input) {
|
|
|
739
791
|
sessionId: input.sessionId,
|
|
740
792
|
source: analytics.source ?? input.source,
|
|
741
793
|
styleId: input.styleId,
|
|
794
|
+
surfaceId: normalizeTileflowSurfaceId(analytics.surfaceId),
|
|
742
795
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
743
796
|
});
|
|
744
797
|
const blob = new Blob([payload], { type: "application/json" });
|
|
@@ -778,7 +831,8 @@ function mergeTileflowAnalytics(userAnalytics, runtimeAnalytics) {
|
|
|
778
831
|
...userAnalytics,
|
|
779
832
|
apiUrl: userAnalytics?.apiUrl ?? runtimeAnalytics?.apiUrl,
|
|
780
833
|
mapId: userAnalytics?.mapId ?? runtimeAnalytics?.mapId,
|
|
781
|
-
styleId: userAnalytics?.styleId ?? runtimeAnalytics?.styleId
|
|
834
|
+
styleId: userAnalytics?.styleId ?? runtimeAnalytics?.styleId,
|
|
835
|
+
surfaceId: normalizeTileflowSurfaceId(userAnalytics?.surfaceId ?? runtimeAnalytics?.surfaceId)
|
|
782
836
|
};
|
|
783
837
|
}
|
|
784
838
|
function resolveTileflowMapMode(options) {
|
|
@@ -1100,6 +1154,7 @@ export {
|
|
|
1100
1154
|
mergeTileflowAnalytics,
|
|
1101
1155
|
normalizeTileflowRuntimeCenter,
|
|
1102
1156
|
normalizeTileflowStaticImageSize,
|
|
1157
|
+
normalizeTileflowSurfaceId,
|
|
1103
1158
|
normalizeTileflowUrl,
|
|
1104
1159
|
resolveTileflowAnalyticsRequestUrl,
|
|
1105
1160
|
resolveTileflowManifestMap,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tileflow/core",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.23",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Typed Tileflow config and MapLibre style compiler.",
|
|
6
6
|
"type": "module",
|
|
@@ -52,16 +52,12 @@
|
|
|
52
52
|
"import": "./dist/capture.js",
|
|
53
53
|
"default": "./dist/capture.js"
|
|
54
54
|
},
|
|
55
|
+
"./config-reference.json": "./dist/config-reference.json",
|
|
55
56
|
"./manifest": {
|
|
56
57
|
"types": "./dist/manifest.d.ts",
|
|
57
58
|
"import": "./dist/manifest.js",
|
|
58
59
|
"default": "./dist/manifest.js"
|
|
59
60
|
},
|
|
60
|
-
"./recipe": {
|
|
61
|
-
"types": "./dist/recipe.d.ts",
|
|
62
|
-
"import": "./dist/recipe.js",
|
|
63
|
-
"default": "./dist/recipe.js"
|
|
64
|
-
},
|
|
65
61
|
"./runtime": {
|
|
66
62
|
"types": "./dist/runtime.d.ts",
|
|
67
63
|
"import": "./dist/runtime.js",
|
|
@@ -77,10 +73,11 @@
|
|
|
77
73
|
"zod": "^4.4.3"
|
|
78
74
|
},
|
|
79
75
|
"devDependencies": {
|
|
80
|
-
"maplibre-contour": "0.1.0"
|
|
76
|
+
"maplibre-contour": "0.1.0",
|
|
77
|
+
"pmtiles": "4.4.0"
|
|
81
78
|
},
|
|
82
79
|
"scripts": {
|
|
83
|
-
"build": "tsup src/index.ts src/
|
|
80
|
+
"build": "tsup src/index.ts src/build.ts src/capture.ts src/manifest.ts src/runtime.ts --format esm --dts --clean --no-splitting && tsup src/browser.ts --format esm --dts --no-splitting --platform browser && cp ../../docs/modules-api-reference.json dist/config-reference.json",
|
|
84
81
|
"reference:check": "tsx scripts/generate-config-reference.ts --check",
|
|
85
82
|
"reference:generate": "tsx scripts/generate-config-reference.ts --write",
|
|
86
83
|
"verify": "pnpm run build && tsx --test test/*.test.ts",
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
declare const tileflowLayerDomains: readonly ["addresses", "land", "terrain", "landforms", "water", "nautical", "roads", "transit", "aeroways", "buildings", "vegetation", "boundaries", "labels", "poi"];
|
|
2
|
-
type TileflowLayerDomain = (typeof tileflowLayerDomains)[number];
|
|
3
|
-
|
|
4
|
-
export type { TileflowLayerDomain as T };
|
package/dist/recipe.d.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { T as TileflowStreetsModuleName, O as OpenMapTilesFieldBindings, a as OpenMapTilesLayerBindings } from './visual-semantics-DTC-8Hsb.js';
|
|
2
|
-
export { b as TileflowVisualValueCategory, c as classifyTileflowVisualProperty } from './visual-semantics-DTC-8Hsb.js';
|
|
3
|
-
import { T as TileflowLayerDomain } from './domains-CPSrdTik.js';
|
|
4
|
-
export { t as toMapLibreStyleValue } from './types-DlUGI6LC.js';
|
|
5
|
-
|
|
6
|
-
type TileflowSemanticFieldReference = {
|
|
7
|
-
readonly kind: 'tileflow-semantic-field';
|
|
8
|
-
readonly name: keyof OpenMapTilesFieldBindings;
|
|
9
|
-
};
|
|
10
|
-
type TileflowSemanticLayerReference = {
|
|
11
|
-
readonly kind: 'tileflow-semantic-layer';
|
|
12
|
-
readonly name: keyof OpenMapTilesLayerBindings;
|
|
13
|
-
};
|
|
14
|
-
type TileflowModuleLayerPlacement = {
|
|
15
|
-
after: string;
|
|
16
|
-
} | {
|
|
17
|
-
before: string;
|
|
18
|
-
};
|
|
19
|
-
type TileflowModuleEffect = {
|
|
20
|
-
kind: 'patch';
|
|
21
|
-
owner: TileflowStreetsModuleName;
|
|
22
|
-
patch: Record<string, unknown>;
|
|
23
|
-
requires?: readonly TileflowLayerDomain[];
|
|
24
|
-
target: string;
|
|
25
|
-
} | {
|
|
26
|
-
kind: 'add';
|
|
27
|
-
layer: Record<string, unknown> & {
|
|
28
|
-
id: string;
|
|
29
|
-
type: string;
|
|
30
|
-
};
|
|
31
|
-
owner: TileflowStreetsModuleName;
|
|
32
|
-
placement: TileflowModuleLayerPlacement;
|
|
33
|
-
requires?: readonly TileflowLayerDomain[];
|
|
34
|
-
target: string;
|
|
35
|
-
} | {
|
|
36
|
-
kind: 'remove';
|
|
37
|
-
owner: TileflowStreetsModuleName;
|
|
38
|
-
requires?: readonly TileflowLayerDomain[];
|
|
39
|
-
target: string;
|
|
40
|
-
};
|
|
41
|
-
/** Compiler-private authoring field reference. Official maps never capture physical data fields. */
|
|
42
|
-
declare function semanticField(name: keyof OpenMapTilesFieldBindings): TileflowSemanticFieldReference;
|
|
43
|
-
/** Compiler-private authoring layer reference. Official maps never capture physical source layers. */
|
|
44
|
-
declare function semanticLayer(name: keyof OpenMapTilesLayerBindings): TileflowSemanticLayerReference;
|
|
45
|
-
declare function patchModuleLayer(owner: TileflowStreetsModuleName, target: string, patch: Record<string, unknown>, options?: {
|
|
46
|
-
requires?: readonly TileflowLayerDomain[];
|
|
47
|
-
}): TileflowModuleEffect;
|
|
48
|
-
declare function addModuleLayer(owner: TileflowStreetsModuleName, target: string, layer: Record<string, unknown> & {
|
|
49
|
-
id: string;
|
|
50
|
-
type: string;
|
|
51
|
-
}, placement: TileflowModuleLayerPlacement, options?: {
|
|
52
|
-
requires?: readonly TileflowLayerDomain[];
|
|
53
|
-
}): TileflowModuleEffect;
|
|
54
|
-
declare function removeModuleLayer(owner: TileflowStreetsModuleName, target: string, options?: {
|
|
55
|
-
requires?: readonly TileflowLayerDomain[];
|
|
56
|
-
}): TileflowModuleEffect;
|
|
57
|
-
/**
|
|
58
|
-
* Attach compiler-private effects without adding a public string key to a map definition.
|
|
59
|
-
* The empty return type deliberately keeps the symbol out of public authoring inference.
|
|
60
|
-
*/
|
|
61
|
-
declare function internalModuleEffects(effects: readonly TileflowModuleEffect[]): {};
|
|
62
|
-
declare function getResolvedModuleEffects(input: object): readonly TileflowModuleEffect[];
|
|
63
|
-
|
|
64
|
-
declare function isMapLibreExpressionOperator(value: unknown): value is string;
|
|
65
|
-
|
|
66
|
-
export { type TileflowModuleEffect, type TileflowModuleLayerPlacement, addModuleLayer, internalModuleEffects as defineModuleEffects, getResolvedModuleEffects, isMapLibreExpressionOperator, patchModuleLayer, removeModuleLayer, semanticField, semanticLayer };
|