@tileflow/dev 0.1.0-alpha.41 → 0.1.0-alpha.42
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/dist/artifacts.js
CHANGED
|
@@ -70,6 +70,58 @@ import {
|
|
|
70
70
|
} from "@tileflow/core/native-profile";
|
|
71
71
|
import { prepareTileflowStyleFamilyForRendering } from "@tileflow/core/runtime";
|
|
72
72
|
|
|
73
|
+
// src/family-style-resources.ts
|
|
74
|
+
function rebaseTileflowFamilyStyle(style, mapName, themeName) {
|
|
75
|
+
const rebase = (value) => {
|
|
76
|
+
let start = 0;
|
|
77
|
+
let end = value.length;
|
|
78
|
+
while (start < end && value.charCodeAt(start) <= 32) start++;
|
|
79
|
+
while (end > start && value.charCodeAt(end - 1) <= 32) end--;
|
|
80
|
+
const reference = value.slice(start, end);
|
|
81
|
+
if (/^[\\/]/u.test(reference) || /^[a-z][a-z\d+.-]*:/iu.test(reference)) return value;
|
|
82
|
+
const target = !reference || /^[?#]/u.test(reference) ? `${themeName}.json${reference}` : reference;
|
|
83
|
+
return `../styles/${mapName}/${target}`;
|
|
84
|
+
};
|
|
85
|
+
const property = (value, key2) => {
|
|
86
|
+
if (record(value) && typeof value[key2] === "string") value[key2] = rebase(value[key2]);
|
|
87
|
+
};
|
|
88
|
+
const result = structuredClone(style);
|
|
89
|
+
property(result, "glyphs");
|
|
90
|
+
if (typeof result.sprite === "string") result.sprite = rebase(result.sprite);
|
|
91
|
+
else if (Array.isArray(result.sprite))
|
|
92
|
+
for (const sprite of result.sprite) property(sprite, "url");
|
|
93
|
+
const fontFaces = result["font-faces"];
|
|
94
|
+
if (record(fontFaces))
|
|
95
|
+
for (const [family, face] of Object.entries(fontFaces)) {
|
|
96
|
+
if (typeof face === "string") fontFaces[family] = rebase(face);
|
|
97
|
+
else property(face, "url");
|
|
98
|
+
}
|
|
99
|
+
for (const source of Object.values(result.sources)) {
|
|
100
|
+
property(source, "url");
|
|
101
|
+
if (source.type === "geojson") property(source, "data");
|
|
102
|
+
for (const key2 of ["tiles", "urls"]) {
|
|
103
|
+
const value = source[key2];
|
|
104
|
+
if (Array.isArray(value))
|
|
105
|
+
source[key2] = value.map(
|
|
106
|
+
(url) => typeof url === "string" ? rebase(url) : url
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const fonts = result.metadata?.["tileflow:fontFaces"];
|
|
111
|
+
if (Array.isArray(fonts)) for (const face of fonts) property(face, "source");
|
|
112
|
+
for (const key2 of ["tileflow:buildings", "tileflow:vegetation"]) {
|
|
113
|
+
const descriptor = result.metadata?.[key2];
|
|
114
|
+
if (!record(descriptor)) continue;
|
|
115
|
+
if (Array.isArray(descriptor.models))
|
|
116
|
+
for (const model of descriptor.models) property(model, "url");
|
|
117
|
+
property(descriptor.landmarks, "url");
|
|
118
|
+
}
|
|
119
|
+
return result;
|
|
120
|
+
}
|
|
121
|
+
function record(value) {
|
|
122
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
123
|
+
}
|
|
124
|
+
|
|
73
125
|
// src/image-source-assets.ts
|
|
74
126
|
import { createHash } from "crypto";
|
|
75
127
|
function prepareEmbeddedImageSources(input) {
|
|
@@ -2034,8 +2086,8 @@ function optionalDiagnosticPath(value) {
|
|
|
2034
2086
|
}
|
|
2035
2087
|
function isTileflowMapResolutionDiagnostic(value, path) {
|
|
2036
2088
|
if (!value || typeof value !== "object" || !path) return false;
|
|
2037
|
-
const
|
|
2038
|
-
return
|
|
2089
|
+
const record2 = value;
|
|
2090
|
+
return record2.name === "TileflowMapResolutionError" && typeof record2.code === "string" && typeof record2.mapId === "string" && path.startsWith("/modules/") && !/[\p{Cc}]/u.test(path) && !/~(?:[^01]|$)/u.test(path);
|
|
2039
2091
|
}
|
|
2040
2092
|
function removeSemanticResolutionPath(message, path) {
|
|
2041
2093
|
if (!path) return message;
|
|
@@ -2443,7 +2495,7 @@ function getStableTileflowArtifactFiles(artifacts) {
|
|
|
2443
2495
|
...!artifacts.nativeBuild ? Object.entries(artifacts.styles).map(([mapName, styles]) => ({
|
|
2444
2496
|
contentType: "application/json; charset=utf-8",
|
|
2445
2497
|
fileName: `families/${mapName}.json`,
|
|
2446
|
-
source: `${JSON.stringify(
|
|
2498
|
+
source: `${JSON.stringify(prepareArtifactStyleFamily(mapName, styles))}
|
|
2447
2499
|
`
|
|
2448
2500
|
})) : [],
|
|
2449
2501
|
...artifacts.assets,
|
|
@@ -2458,6 +2510,18 @@ function getStableTileflowArtifactFiles(artifacts) {
|
|
|
2458
2510
|
];
|
|
2459
2511
|
return validateArtifactFiles(files);
|
|
2460
2512
|
}
|
|
2513
|
+
function prepareArtifactStyleFamily(mapName, styles) {
|
|
2514
|
+
return prepareTileflowStyleFamilyForRendering(
|
|
2515
|
+
createTileflowStyleFamily(
|
|
2516
|
+
Object.fromEntries(
|
|
2517
|
+
Object.entries(styles).map(([theme, style]) => [
|
|
2518
|
+
theme,
|
|
2519
|
+
rebaseTileflowFamilyStyle(style, mapName, theme)
|
|
2520
|
+
])
|
|
2521
|
+
)
|
|
2522
|
+
)
|
|
2523
|
+
);
|
|
2524
|
+
}
|
|
2461
2525
|
function validateArtifactFiles(files) {
|
|
2462
2526
|
const seen = /* @__PURE__ */ new Set();
|
|
2463
2527
|
for (const file of files) {
|
|
@@ -2553,20 +2617,19 @@ function createGenerationArtifactFiles(artifacts, generation, nativeUrls) {
|
|
|
2553
2617
|
contentType: "application/json; charset=utf-8",
|
|
2554
2618
|
fileName: `${prefix}/families/${mapName}.json`,
|
|
2555
2619
|
source: `${JSON.stringify(
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
)
|
|
2620
|
+
prepareArtifactStyleFamily(
|
|
2621
|
+
mapName,
|
|
2622
|
+
Object.fromEntries(
|
|
2623
|
+
Object.keys(artifacts.styles[mapName]).map((theme) => [
|
|
2624
|
+
theme,
|
|
2625
|
+
JSON.parse(
|
|
2626
|
+
String(
|
|
2627
|
+
immutableStyles.find(
|
|
2628
|
+
(file) => file.fileName === `${prefix}/styles/${mapName}/${theme}.json`
|
|
2629
|
+
).source
|
|
2567
2630
|
)
|
|
2568
|
-
|
|
2569
|
-
)
|
|
2631
|
+
)
|
|
2632
|
+
])
|
|
2570
2633
|
)
|
|
2571
2634
|
)
|
|
2572
2635
|
)}
|
package/dist/server.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tileflow/dev",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.42",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Node development utilities for Tileflow configs and builds.",
|
|
6
6
|
"type": "module",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"dependencies": {
|
|
84
84
|
"@mapbox/vector-tile": "3.0.0",
|
|
85
85
|
"@maplibre/maplibre-gl-style-spec": "26.4.4",
|
|
86
|
-
"@tileflow/core": ">=0.1.0-alpha.
|
|
86
|
+
"@tileflow/core": ">=0.1.0-alpha.46 <0.1.0-beta.0",
|
|
87
87
|
"chokidar": "6.0.0",
|
|
88
88
|
"fontkit": "2.0.4",
|
|
89
89
|
"jiti": "^2.7.0",
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
},
|
|
103
103
|
"scripts": {
|
|
104
104
|
"build": "tsup src/artifacts.ts src/config.ts src/fonts.ts src/icons.ts src/inspect.ts src/preview.ts src/server.ts src/tilesets.ts src/validation.ts --format esm --dts --clean --platform node --external sharp && tsup --config tsup.inspector.config.ts",
|
|
105
|
-
"test": "tsx --test test/*.test.ts",
|
|
105
|
+
"test": "tsx --test --test-concurrency=2 test/*.test.ts",
|
|
106
106
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
107
107
|
"lint": "tsc -p tsconfig.json --noEmit",
|
|
108
108
|
"verify": "pnpm run typecheck && pnpm run test"
|