@tileflow/dev 0.1.0-alpha.3 → 0.1.0-alpha.30
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 +201 -0
- package/README.md +201 -5
- package/THIRD_PARTY_NOTICES.md +87 -0
- package/dist/artifacts.d.ts +265 -0
- package/dist/artifacts.js +81 -0
- package/dist/chunk-6MGFMKG3.js +284 -0
- package/dist/chunk-7C4F6GAX.js +170 -0
- package/dist/chunk-A2VTI43Y.js +1824 -0
- package/dist/chunk-D4OE4ITL.js +13 -0
- package/dist/chunk-KDFTE4Q5.js +156 -0
- package/dist/chunk-L56FLV4R.js +3061 -0
- package/dist/chunk-ONYQNLNA.js +1108 -0
- package/dist/chunk-UTRO4IBQ.js +671 -0
- package/dist/chunk-XHJBCVBB.js +241 -0
- package/dist/config.d.ts +33 -0
- package/dist/config.js +27 -0
- package/dist/fonts.d.ts +47 -0
- package/dist/fonts.js +16 -0
- package/dist/icons.d.ts +337 -0
- package/dist/icons.js +39 -0
- package/dist/inspect.d.ts +149 -0
- package/dist/inspect.js +805 -0
- package/dist/preview-assets-MVUJJ5XR.js +148 -0
- package/dist/preview.d.ts +71 -0
- package/dist/preview.js +4286 -0
- package/dist/server.d.ts +82 -0
- package/dist/server.js +2094 -0
- package/dist/tilesets.d.ts +89 -0
- package/dist/tilesets.js +6 -0
- package/dist/validation.d.ts +65 -0
- package/dist/validation.js +24 -0
- package/docs/artifact-lifecycle.md +152 -0
- package/docs/bounded-pmtiles-resource-inspection.md +21 -0
- package/docs/bounded-vector-feature-inspection.md +100 -0
- package/docs/local-comparison-workbench-and-compiler-inspection.md +249 -0
- package/docs/native-artifacts.md +285 -0
- package/docs/native-icons.md +129 -0
- package/docs/structured-config-inspection-and-diagnostics.md +39 -0
- package/package.json +77 -13
- package/dist/index.d.ts +0 -54
- package/dist/index.js +0 -314
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { MapLibreStyle, TileflowViewConfig, TileflowStyleOptions } from '@tileflow/core';
|
|
2
|
+
import { TileflowBuildCatalog, TileflowBuildStyles, TileflowMapBuildManifestV1, TileflowRendererDeploymentArtifact, TileflowStyleInspection, TileflowMapBuildProvenanceV1, TileflowPreparedMapAssets } from '@tileflow/core/build';
|
|
3
|
+
import { TileflowRuntimeManifest } from '@tileflow/core/manifest';
|
|
4
|
+
import { TileflowRenderer, TileflowNativeBuildRecord } from '@tileflow/core/native-profile';
|
|
5
|
+
import { TileflowBuildAsset, TileflowIconResolutionOptions, PreparedTileflowBuildCatalog, TileflowSourceCatalog, PreparedTileflowCatalog } from './icons.js';
|
|
6
|
+
export { defaultTileflowConfigPath } from './config.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Local glyph serving for line-fitted text backgrounds.
|
|
10
|
+
*
|
|
11
|
+
* A style whose text uses a derived `<stack> lines-v1-…` font stack needs a glyph provider that
|
|
12
|
+
* derives those ranges. Local previews and captures route such a map's glyph URL through
|
|
13
|
+
* `__glyphs/<map>/…`: ordinary stacks pass through from the map's declared provider unchanged, and
|
|
14
|
+
* derived stacks are computed from their source stack's range. Production output keeps the
|
|
15
|
+
* declared provider, which must serve derived stacks itself.
|
|
16
|
+
*/
|
|
17
|
+
declare const tileflowLineBackgroundGlyphRoute = "__glyphs";
|
|
18
|
+
/** Map name to the upstream glyph URL template its styles declared. Local only; never serialized. */
|
|
19
|
+
type TileflowLineBackgroundGlyphProviders = Readonly<Record<string, string>>;
|
|
20
|
+
type TileflowLineBackgroundGlyphResponderOptions = {
|
|
21
|
+
/** Project root; ranges are cached under `.tileflow/cache/glyphs/v1`. */
|
|
22
|
+
cwd: string;
|
|
23
|
+
fetch?: typeof globalThis.fetch;
|
|
24
|
+
};
|
|
25
|
+
type TileflowLineBackgroundGlyphResponder = (upstream: string, fontStack: string, range: string) => Promise<Response>;
|
|
26
|
+
/** Whether a compiled style draws text with a derived line-background stack. */
|
|
27
|
+
declare function usesTileflowLineBackgroundGlyphs(style: MapLibreStyle): boolean;
|
|
28
|
+
/** Parses `/__glyphs/<map>/<fontstack>/<range>.pbf` from a decoded route path. */
|
|
29
|
+
declare function parseTileflowLineBackgroundGlyphPath(path: string): {
|
|
30
|
+
fontStack: string;
|
|
31
|
+
mapName: string;
|
|
32
|
+
range: string;
|
|
33
|
+
} | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Serves one glyph range for a declared upstream template. Upstream ranges are cached on disk;
|
|
36
|
+
* derived ranges are recomputed from them and kept in a bounded in-memory cache.
|
|
37
|
+
*/
|
|
38
|
+
declare function createTileflowLineBackgroundGlyphResponder(options: TileflowLineBackgroundGlyphResponderOptions): TileflowLineBackgroundGlyphResponder;
|
|
39
|
+
|
|
40
|
+
type TileflowLocalTilesetFile = Readonly<{
|
|
41
|
+
byteLength: number;
|
|
42
|
+
etag: string;
|
|
43
|
+
fileName: string;
|
|
44
|
+
logicalId: string;
|
|
45
|
+
sourcePath: string;
|
|
46
|
+
}>;
|
|
47
|
+
declare function prepareTileflowLocalTilesets(project: TileflowBuildCatalog, styles: TileflowBuildStyles, options: {
|
|
48
|
+
assetBaseUrl: string;
|
|
49
|
+
baseDirectory: string;
|
|
50
|
+
cwd: string;
|
|
51
|
+
}): Promise<{
|
|
52
|
+
dispose(): Promise<void>;
|
|
53
|
+
files: TileflowLocalTilesetFile[];
|
|
54
|
+
styles: TileflowBuildStyles;
|
|
55
|
+
watchPaths: string[];
|
|
56
|
+
}>;
|
|
57
|
+
|
|
58
|
+
declare const tileflowArtifactSessionSchemaVersion: 1;
|
|
59
|
+
type TileflowArtifactDiagnostic = {
|
|
60
|
+
code?: string;
|
|
61
|
+
message: string;
|
|
62
|
+
path: string;
|
|
63
|
+
phase?: string;
|
|
64
|
+
renderer?: 'native';
|
|
65
|
+
profile?: 'native-v1';
|
|
66
|
+
severity?: 'error';
|
|
67
|
+
suggestion?: string;
|
|
68
|
+
};
|
|
69
|
+
type TileflowArtifactSessionState = {
|
|
70
|
+
status: 'building';
|
|
71
|
+
generation: number;
|
|
72
|
+
lastGoodGeneration?: number;
|
|
73
|
+
} | {
|
|
74
|
+
status: 'ready';
|
|
75
|
+
generation: number;
|
|
76
|
+
artifacts: TileflowBuildArtifacts;
|
|
77
|
+
lastGoodGeneration: number;
|
|
78
|
+
} | {
|
|
79
|
+
status: 'invalid';
|
|
80
|
+
generation: number;
|
|
81
|
+
diagnostics: TileflowArtifactDiagnostic[];
|
|
82
|
+
lastGoodGeneration?: number;
|
|
83
|
+
};
|
|
84
|
+
type TileflowArtifactSessionOptions = TileflowBuildArtifactsOptions & {
|
|
85
|
+
debounceMs?: number;
|
|
86
|
+
ignoredPaths?: string[];
|
|
87
|
+
watch?: boolean;
|
|
88
|
+
};
|
|
89
|
+
type TileflowArtifactAcquisition = Readonly<{
|
|
90
|
+
artifacts: TileflowBuildArtifacts;
|
|
91
|
+
generation: number;
|
|
92
|
+
release(): Promise<void>;
|
|
93
|
+
}>;
|
|
94
|
+
type TileflowArtifactSession = {
|
|
95
|
+
/** Pins the current generation for asynchronous work; the caller must release it. */
|
|
96
|
+
acquireArtifacts(generation?: number): TileflowArtifactAcquisition | undefined;
|
|
97
|
+
close(): Promise<void>;
|
|
98
|
+
/** Borrowed synchronous view. Use acquireArtifacts() before retaining it across an await. */
|
|
99
|
+
getLastGoodArtifacts(): TileflowBuildArtifacts | undefined;
|
|
100
|
+
/** Ready-state artifacts are a borrowed synchronous view. */
|
|
101
|
+
getState(): TileflowArtifactSessionState;
|
|
102
|
+
refresh(reason?: string): Promise<void>;
|
|
103
|
+
subscribe(listener: (state: TileflowArtifactSessionState) => void): () => void;
|
|
104
|
+
};
|
|
105
|
+
declare function createTileflowArtifactDiagnostics(error: unknown, cwd: string): TileflowArtifactDiagnostic[];
|
|
106
|
+
|
|
107
|
+
type Input = Readonly<{
|
|
108
|
+
mapId: string;
|
|
109
|
+
buildManifest: TileflowMapBuildManifestV1;
|
|
110
|
+
styles: Readonly<Record<string, MapLibreStyle>>;
|
|
111
|
+
teamSources: Readonly<Record<string, Readonly<{
|
|
112
|
+
tileset: string;
|
|
113
|
+
type: 'raster' | 'vector';
|
|
114
|
+
}>>>;
|
|
115
|
+
assets: readonly TileflowBuildAsset[];
|
|
116
|
+
view?: TileflowViewConfig;
|
|
117
|
+
}>;
|
|
118
|
+
/**
|
|
119
|
+
* Prepare both representations from the same already compiled, asset-bound web family.
|
|
120
|
+
* This has no network or publication port. Call it before any authenticated remote operation.
|
|
121
|
+
* Logical Hosted placeholders are validated syntactically without granting delivery authority.
|
|
122
|
+
*/
|
|
123
|
+
declare function prepareTileflowHostedNativeDeployment(input: Input): Promise<TileflowRendererDeploymentArtifact>;
|
|
124
|
+
|
|
125
|
+
/** Normalize a development route base. This is a URL pathname, never a filesystem path. */
|
|
126
|
+
declare function normalizeTileflowBasePath(value?: string): string;
|
|
127
|
+
/**
|
|
128
|
+
* Join a bundler public URL prefix to the Tileflow route without changing URL-reference kind.
|
|
129
|
+
* In particular, `./` and `../` remain path-relative rather than becoming root-relative.
|
|
130
|
+
*/
|
|
131
|
+
declare function joinTileflowPublicUrl(publicBase: string, basePath: string): string;
|
|
132
|
+
/**
|
|
133
|
+
* Resolve the public URL at which a manifest is exposed and the URLs embedded inside its artifacts.
|
|
134
|
+
* Path-relative deployments use owner-relative references because the manifest already lives below
|
|
135
|
+
* the public prefix.
|
|
136
|
+
*/
|
|
137
|
+
declare function resolveTileflowArtifactPublicUrls(publicBase: string, basePath: string): {
|
|
138
|
+
assetBaseUrl?: string;
|
|
139
|
+
publicBaseUrl: string;
|
|
140
|
+
styleBaseUrl: string;
|
|
141
|
+
};
|
|
142
|
+
/** Convert a validated route base to a bundler-relative asset prefix. */
|
|
143
|
+
declare function getTileflowAssetBasePath(basePath: string): string;
|
|
144
|
+
declare function getTileflowAssetFileName(basePath: string, fileName: string): string;
|
|
145
|
+
|
|
146
|
+
declare const tileflowArtifactPlanSchemaVersion: 1;
|
|
147
|
+
declare const tileflowArtifactInventoryFileName = ".tileflow-artifacts.json";
|
|
148
|
+
type TileflowManifestOptions = {
|
|
149
|
+
styleBaseUrl?: string;
|
|
150
|
+
};
|
|
151
|
+
type TileflowBuildArtifactsOptions = {
|
|
152
|
+
apiBaseUrl?: string;
|
|
153
|
+
assetBaseUrl?: string;
|
|
154
|
+
config?: string;
|
|
155
|
+
cwd?: string;
|
|
156
|
+
/**
|
|
157
|
+
* Native local preview only: the exact HTTP origin serving these artifacts, such as
|
|
158
|
+
* `http://127.0.0.1:3333`. Native checks accept HTTP resources at this origin only; every other
|
|
159
|
+
* origin still requires HTTPS. It is never inferred, and web or production output rejects it.
|
|
160
|
+
*/
|
|
161
|
+
developmentOrigin?: string;
|
|
162
|
+
/**
|
|
163
|
+
* Explicit shared Icon Set resolution settings for this build.
|
|
164
|
+
*
|
|
165
|
+
* Builds never resolve a catalog head. These options only choose the verified cache root,
|
|
166
|
+
* offline behavior, trusted delivery origins and the transport used to hydrate exact pins.
|
|
167
|
+
*/
|
|
168
|
+
icons?: TileflowIconResolutionOptions;
|
|
169
|
+
/** Artifact renderer. Omission is identical to web; native uses a separate output directory. */
|
|
170
|
+
renderer?: TileflowRenderer;
|
|
171
|
+
/** Build a memory-only compiler sidecar for local authoring tools. */
|
|
172
|
+
inspection?: boolean;
|
|
173
|
+
styleBaseUrl?: string;
|
|
174
|
+
/** Local tools may snapshot local PMTiles; production output must resolve them explicitly. */
|
|
175
|
+
target?: 'local' | 'production';
|
|
176
|
+
};
|
|
177
|
+
type TileflowBuildStyleInspections = Record<string, Record<string, TileflowStyleInspection>>;
|
|
178
|
+
/** Compatibility shape consumed by sessions and capture callers. */
|
|
179
|
+
type TileflowBuildArtifacts = {
|
|
180
|
+
assets: TileflowBuildAsset[];
|
|
181
|
+
buildManifest: TileflowMapBuildManifestV1;
|
|
182
|
+
/** Present only for native artifact preparation; never part of the runtime manifest. */
|
|
183
|
+
nativeBuild?: TileflowNativeBuildRecord;
|
|
184
|
+
/** Releases local immutable snapshot references owned by this artifact generation. */
|
|
185
|
+
dispose?: () => Promise<void>;
|
|
186
|
+
manifest: TileflowRuntimeManifest;
|
|
187
|
+
project: TileflowBuildCatalog;
|
|
188
|
+
/** Local-only archive ports. Paths never enter serialized build artifacts. */
|
|
189
|
+
localTilesets?: TileflowLocalTilesetFile[];
|
|
190
|
+
/** Local-only upstream glyph templates for maps whose text uses line-fitted backgrounds. */
|
|
191
|
+
lineBackgroundGlyphs?: TileflowLineBackgroundGlyphProviders;
|
|
192
|
+
/** Optional local-only provenance. It is never serialized as a build artifact. */
|
|
193
|
+
styleInspections?: TileflowBuildStyleInspections;
|
|
194
|
+
styles: TileflowBuildStyles;
|
|
195
|
+
watchPaths: string[];
|
|
196
|
+
};
|
|
197
|
+
type TileflowArtifactFile = TileflowBuildAsset;
|
|
198
|
+
type TileflowArtifactInputGraph = {
|
|
199
|
+
/** Exact executable config modules and data files observed during evaluation. */
|
|
200
|
+
files: string[];
|
|
201
|
+
/** Asset directories whose children can change without changing the config module. */
|
|
202
|
+
directories: string[];
|
|
203
|
+
};
|
|
204
|
+
/**
|
|
205
|
+
* Complete, deterministic output of compiling one prepared source generation.
|
|
206
|
+
* `sourceProject` is retained for diagnostics only; `project` is the portable runtime input.
|
|
207
|
+
*/
|
|
208
|
+
type TileflowArtifactPlan = TileflowBuildArtifacts & {
|
|
209
|
+
files: TileflowArtifactFile[];
|
|
210
|
+
inputs: TileflowArtifactInputGraph;
|
|
211
|
+
project: PreparedTileflowBuildCatalog;
|
|
212
|
+
schemaVersion: typeof tileflowArtifactPlanSchemaVersion;
|
|
213
|
+
sourceProject: TileflowSourceCatalog;
|
|
214
|
+
};
|
|
215
|
+
type CreateTileflowArtifactPlanOptions = Pick<TileflowBuildArtifactsOptions, 'apiBaseUrl' | 'assetBaseUrl' | 'developmentOrigin' | 'inspection' | 'renderer' | 'styleBaseUrl' | 'target'> & {
|
|
216
|
+
inputFiles?: readonly string[];
|
|
217
|
+
};
|
|
218
|
+
type WriteTileflowArtifactPlanOptions = {
|
|
219
|
+
cwd?: string;
|
|
220
|
+
outDir: string;
|
|
221
|
+
/** Explicit escape hatch for replacing a Hosted delivery manifest with self-hosted artifacts. */
|
|
222
|
+
overwriteHostedManifest?: boolean;
|
|
223
|
+
};
|
|
224
|
+
type WriteTileflowBuildArtifactsOptions = TileflowBuildArtifactsOptions & WriteTileflowArtifactPlanOptions;
|
|
225
|
+
declare class TileflowHostedManifestOverwriteError extends Error {
|
|
226
|
+
readonly code: "HOSTED_MANIFEST_OVERWRITE_REFUSED";
|
|
227
|
+
constructor(path: string);
|
|
228
|
+
}
|
|
229
|
+
declare class TileflowLocalTilesetProductionError extends Error {
|
|
230
|
+
readonly code: "TF_LOCAL_TILESET_PRODUCTION_UNRESOLVED";
|
|
231
|
+
constructor();
|
|
232
|
+
}
|
|
233
|
+
declare function createTileflowManifest(project: TileflowBuildCatalog, options?: TileflowManifestOptions): TileflowRuntimeManifest;
|
|
234
|
+
declare function createTileflowStyle(project: TileflowBuildCatalog, mapName: string, options?: TileflowStyleOptions): MapLibreStyle;
|
|
235
|
+
declare function createTileflowStyles(project: TileflowBuildCatalog, options?: Omit<TileflowStyleOptions, 'preparedAssets' | 'theme'> & {
|
|
236
|
+
mapAssets?: Readonly<Record<string, TileflowPreparedMapAssets>>;
|
|
237
|
+
}): TileflowBuildStyles;
|
|
238
|
+
/** Compiles only a prepared project, keeping local source resolution out of core compilation. */
|
|
239
|
+
declare function createTileflowArtifactPlan(prepared: PreparedTileflowCatalog, options?: CreateTileflowArtifactPlanOptions): Promise<TileflowArtifactPlan>;
|
|
240
|
+
declare function createTileflowBuildArtifacts(options?: TileflowBuildArtifactsOptions): Promise<TileflowArtifactPlan>;
|
|
241
|
+
declare function getTileflowArtifactFiles(artifacts: TileflowBuildArtifacts): TileflowArtifactFile[];
|
|
242
|
+
/** Resolve portable build provenance without making it part of any map authoring revision. */
|
|
243
|
+
declare function createTileflowBuildProvenance(cwd: string): Promise<TileflowMapBuildProvenanceV1>;
|
|
244
|
+
declare function createTileflowArtifactSession(options?: TileflowArtifactSessionOptions): Promise<TileflowArtifactSession>;
|
|
245
|
+
declare function getTileflowWatchPaths(options?: Pick<TileflowBuildArtifactsOptions, 'config' | 'cwd'>): Promise<string[]>;
|
|
246
|
+
declare function isTileflowArtifactInputPath(inputs: TileflowArtifactInputGraph, path: string): boolean;
|
|
247
|
+
/** Shared refresh gate for adapters that receive filesystem or framework lifecycle events. */
|
|
248
|
+
declare function refreshTileflowArtifactSession(session: TileflowArtifactSession, options: {
|
|
249
|
+
inputPath?: string;
|
|
250
|
+
reason: string;
|
|
251
|
+
}): Promise<boolean>;
|
|
252
|
+
declare function writeTileflowBuildArtifacts(options: WriteTileflowBuildArtifactsOptions): Promise<TileflowArtifactPlan>;
|
|
253
|
+
declare function disposeTileflowBuildArtifacts(artifacts: Pick<TileflowBuildArtifacts, 'dispose'>): Promise<void>;
|
|
254
|
+
/**
|
|
255
|
+
* Replaces one managed artifact generation and records its exact file inventory. Unmanaged files
|
|
256
|
+
* are never scanned or removed. A caught filesystem failure restores every previous managed file.
|
|
257
|
+
*/
|
|
258
|
+
declare function writeTileflowArtifactPlan(artifacts: TileflowArtifactPlan, options: WriteTileflowArtifactPlanOptions): Promise<void>;
|
|
259
|
+
declare function assertNoLocalTilesetsForProduction(artifacts: Pick<TileflowBuildArtifacts, 'localTilesets'>): void;
|
|
260
|
+
/** Prevents a framework build from silently replacing the frontend's Hosted delivery contract. */
|
|
261
|
+
declare function assertTileflowSelfHostedManifestTarget(manifestPath: string, options?: {
|
|
262
|
+
overwriteHostedManifest?: boolean;
|
|
263
|
+
}): Promise<void>;
|
|
264
|
+
|
|
265
|
+
export { type CreateTileflowArtifactPlanOptions, PreparedTileflowBuildCatalog, PreparedTileflowCatalog, type TileflowArtifactAcquisition, type TileflowArtifactDiagnostic, type TileflowArtifactFile, type TileflowArtifactInputGraph, type TileflowArtifactPlan, type TileflowArtifactSession, type TileflowArtifactSessionOptions, type TileflowArtifactSessionState, type TileflowBuildArtifacts, type TileflowBuildArtifactsOptions, TileflowBuildAsset, type TileflowBuildStyleInspections, TileflowHostedManifestOverwriteError, TileflowIconResolutionOptions, type TileflowLineBackgroundGlyphProviders, type TileflowLineBackgroundGlyphResponder, type TileflowLocalTilesetFile, TileflowLocalTilesetProductionError, type TileflowManifestOptions, TileflowSourceCatalog, type WriteTileflowArtifactPlanOptions, type WriteTileflowBuildArtifactsOptions, assertNoLocalTilesetsForProduction, assertTileflowSelfHostedManifestTarget, createTileflowArtifactDiagnostics, createTileflowArtifactPlan, createTileflowArtifactSession, createTileflowBuildArtifacts, createTileflowBuildProvenance, createTileflowLineBackgroundGlyphResponder, createTileflowManifest, createTileflowStyle, createTileflowStyles, disposeTileflowBuildArtifacts, getTileflowArtifactFiles, getTileflowAssetBasePath, getTileflowAssetFileName, getTileflowWatchPaths, isTileflowArtifactInputPath, joinTileflowPublicUrl, normalizeTileflowBasePath, parseTileflowLineBackgroundGlyphPath, prepareTileflowHostedNativeDeployment, prepareTileflowLocalTilesets, refreshTileflowArtifactSession, resolveTileflowArtifactPublicUrls, tileflowArtifactInventoryFileName, tileflowArtifactPlanSchemaVersion, tileflowArtifactSessionSchemaVersion, tileflowLineBackgroundGlyphRoute, usesTileflowLineBackgroundGlyphs, writeTileflowArtifactPlan, writeTileflowBuildArtifacts };
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TileflowHostedManifestOverwriteError,
|
|
3
|
+
TileflowLocalTilesetProductionError,
|
|
4
|
+
assertNoLocalTilesetsForProduction,
|
|
5
|
+
assertTileflowSelfHostedManifestTarget,
|
|
6
|
+
createTileflowArtifactDiagnostics,
|
|
7
|
+
createTileflowArtifactPlan,
|
|
8
|
+
createTileflowArtifactSession,
|
|
9
|
+
createTileflowBuildArtifacts,
|
|
10
|
+
createTileflowBuildProvenance,
|
|
11
|
+
createTileflowLineBackgroundGlyphResponder,
|
|
12
|
+
createTileflowManifest,
|
|
13
|
+
createTileflowStyle,
|
|
14
|
+
createTileflowStyles,
|
|
15
|
+
disposeTileflowBuildArtifacts,
|
|
16
|
+
getTileflowArtifactFiles,
|
|
17
|
+
getTileflowWatchPaths,
|
|
18
|
+
isTileflowArtifactInputPath,
|
|
19
|
+
parseTileflowLineBackgroundGlyphPath,
|
|
20
|
+
prepareTileflowHostedNativeDeployment,
|
|
21
|
+
prepareTileflowLocalTilesets,
|
|
22
|
+
refreshTileflowArtifactSession,
|
|
23
|
+
tileflowArtifactInventoryFileName,
|
|
24
|
+
tileflowArtifactPlanSchemaVersion,
|
|
25
|
+
tileflowArtifactSessionSchemaVersion,
|
|
26
|
+
tileflowLineBackgroundGlyphRoute,
|
|
27
|
+
usesTileflowLineBackgroundGlyphs,
|
|
28
|
+
writeTileflowArtifactPlan,
|
|
29
|
+
writeTileflowBuildArtifacts
|
|
30
|
+
} from "./chunk-L56FLV4R.js";
|
|
31
|
+
import {
|
|
32
|
+
getTileflowAssetBasePath,
|
|
33
|
+
getTileflowAssetFileName,
|
|
34
|
+
joinTileflowPublicUrl,
|
|
35
|
+
normalizeTileflowBasePath,
|
|
36
|
+
resolveTileflowArtifactPublicUrls
|
|
37
|
+
} from "./chunk-UTRO4IBQ.js";
|
|
38
|
+
import "./chunk-A2VTI43Y.js";
|
|
39
|
+
import "./chunk-7C4F6GAX.js";
|
|
40
|
+
import "./chunk-KDFTE4Q5.js";
|
|
41
|
+
import {
|
|
42
|
+
defaultTileflowConfigPath
|
|
43
|
+
} from "./chunk-6MGFMKG3.js";
|
|
44
|
+
import "./chunk-D4OE4ITL.js";
|
|
45
|
+
import "./chunk-ONYQNLNA.js";
|
|
46
|
+
export {
|
|
47
|
+
TileflowHostedManifestOverwriteError,
|
|
48
|
+
TileflowLocalTilesetProductionError,
|
|
49
|
+
assertNoLocalTilesetsForProduction,
|
|
50
|
+
assertTileflowSelfHostedManifestTarget,
|
|
51
|
+
createTileflowArtifactDiagnostics,
|
|
52
|
+
createTileflowArtifactPlan,
|
|
53
|
+
createTileflowArtifactSession,
|
|
54
|
+
createTileflowBuildArtifacts,
|
|
55
|
+
createTileflowBuildProvenance,
|
|
56
|
+
createTileflowLineBackgroundGlyphResponder,
|
|
57
|
+
createTileflowManifest,
|
|
58
|
+
createTileflowStyle,
|
|
59
|
+
createTileflowStyles,
|
|
60
|
+
defaultTileflowConfigPath,
|
|
61
|
+
disposeTileflowBuildArtifacts,
|
|
62
|
+
getTileflowArtifactFiles,
|
|
63
|
+
getTileflowAssetBasePath,
|
|
64
|
+
getTileflowAssetFileName,
|
|
65
|
+
getTileflowWatchPaths,
|
|
66
|
+
isTileflowArtifactInputPath,
|
|
67
|
+
joinTileflowPublicUrl,
|
|
68
|
+
normalizeTileflowBasePath,
|
|
69
|
+
parseTileflowLineBackgroundGlyphPath,
|
|
70
|
+
prepareTileflowHostedNativeDeployment,
|
|
71
|
+
prepareTileflowLocalTilesets,
|
|
72
|
+
refreshTileflowArtifactSession,
|
|
73
|
+
resolveTileflowArtifactPublicUrls,
|
|
74
|
+
tileflowArtifactInventoryFileName,
|
|
75
|
+
tileflowArtifactPlanSchemaVersion,
|
|
76
|
+
tileflowArtifactSessionSchemaVersion,
|
|
77
|
+
tileflowLineBackgroundGlyphRoute,
|
|
78
|
+
usesTileflowLineBackgroundGlyphs,
|
|
79
|
+
writeTileflowArtifactPlan,
|
|
80
|
+
writeTileflowBuildArtifacts
|
|
81
|
+
};
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isPathWithin
|
|
3
|
+
} from "./chunk-D4OE4ITL.js";
|
|
4
|
+
|
|
5
|
+
// src/config.ts
|
|
6
|
+
import { createJiti } from "jiti";
|
|
7
|
+
import { existsSync, realpathSync } from "fs";
|
|
8
|
+
import { createRequire } from "module";
|
|
9
|
+
import { dirname, resolve, sep } from "path";
|
|
10
|
+
import {
|
|
11
|
+
parseResolvedTileflowMap,
|
|
12
|
+
parseTileflowMap,
|
|
13
|
+
tileflowCaptureSceneNameSchema,
|
|
14
|
+
TileflowResolvedMapValidationError
|
|
15
|
+
} from "@tileflow/core";
|
|
16
|
+
import { collectTileflowMapBuildLineage } from "@tileflow/core/build";
|
|
17
|
+
var defaultTileflowApiUrl = "https://api.tileflow.dev";
|
|
18
|
+
var defaultTileflowConfigPath = "tileflow.config.ts";
|
|
19
|
+
var defaultTileflowManifestPath = "public/tileflow/manifest.json";
|
|
20
|
+
var TileflowValidationError = class extends Error {
|
|
21
|
+
code = "CONFIG_INVALID";
|
|
22
|
+
messages;
|
|
23
|
+
phase = "config-validation";
|
|
24
|
+
constructor(messages) {
|
|
25
|
+
super("Invalid Tileflow config");
|
|
26
|
+
this.name = "TileflowValidationError";
|
|
27
|
+
this.messages = messages;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
async function loadTileflowConfig(configPath = defaultTileflowConfigPath, options = {}) {
|
|
31
|
+
return (await loadTileflowConfigWithInputs(configPath, options)).project;
|
|
32
|
+
}
|
|
33
|
+
async function loadTileflowConfigWithInputs(configPath = defaultTileflowConfigPath, options = {}) {
|
|
34
|
+
const cwd = options.cwd ?? process.cwd();
|
|
35
|
+
const resolvedPath = resolve(cwd, configPath);
|
|
36
|
+
if (!existsSync(resolvedPath)) {
|
|
37
|
+
throw new Error(`Config not found: ${configPath}`);
|
|
38
|
+
}
|
|
39
|
+
if (options.fresh) {
|
|
40
|
+
clearTileflowLocalModuleCache(resolvedPath, cwd);
|
|
41
|
+
}
|
|
42
|
+
const jiti = createJiti(import.meta.url, {
|
|
43
|
+
fsCache: false,
|
|
44
|
+
moduleCache: true
|
|
45
|
+
});
|
|
46
|
+
const imported = await jiti.import(resolvedPath, { default: true });
|
|
47
|
+
const allowWorkspace = /\.workspace\.(?:[cm]?[jt]s)$/u.test(resolvedPath);
|
|
48
|
+
const project = asTileflowBuildCatalog(imported, { allowWorkspace });
|
|
49
|
+
return {
|
|
50
|
+
authoringMaps: getTileflowAuthoringMaps(imported, project, allowWorkspace),
|
|
51
|
+
configFile: resolvedPath,
|
|
52
|
+
inputFiles: collectTileflowConfigInputs(resolvedPath, cwd),
|
|
53
|
+
project
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
async function loadValidTileflowConfig(configPath = defaultTileflowConfigPath, options = {}) {
|
|
57
|
+
const project = await loadTileflowConfig(configPath, options);
|
|
58
|
+
assertValidTileflowConfig(project);
|
|
59
|
+
return project;
|
|
60
|
+
}
|
|
61
|
+
async function loadValidTileflowConfigWithInputs(configPath = defaultTileflowConfigPath, options = {}) {
|
|
62
|
+
const loaded = await loadTileflowConfigWithInputs(configPath, options);
|
|
63
|
+
assertValidTileflowConfig(loaded.project);
|
|
64
|
+
return loaded;
|
|
65
|
+
}
|
|
66
|
+
function assertValidTileflowConfig(project) {
|
|
67
|
+
const messages = [];
|
|
68
|
+
for (const [mapId, map] of Object.entries(project.maps)) {
|
|
69
|
+
try {
|
|
70
|
+
parseResolvedTileflowMap(map);
|
|
71
|
+
} catch (error) {
|
|
72
|
+
messages.push({
|
|
73
|
+
level: "error",
|
|
74
|
+
path: `maps.${mapId}`,
|
|
75
|
+
message: error instanceof Error ? error.message : String(error)
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
for (const [sceneId, scene] of Object.entries(project.scenes ?? {})) {
|
|
80
|
+
if (!Object.hasOwn(project.maps, scene.map)) {
|
|
81
|
+
messages.push({
|
|
82
|
+
level: "error",
|
|
83
|
+
path: `scenes.${sceneId}.map`,
|
|
84
|
+
message: `Unknown Tileflow map "${scene.map}".`
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (messages.length > 0) throw new TileflowValidationError(messages);
|
|
89
|
+
}
|
|
90
|
+
function asTileflowBuildCatalog(input, options = {}) {
|
|
91
|
+
if (isRecord(input) && isRecord(input.maps)) {
|
|
92
|
+
if (!options.allowWorkspace) {
|
|
93
|
+
throw tileflowConfigValidationError(
|
|
94
|
+
"maps",
|
|
95
|
+
new Error(
|
|
96
|
+
"tileflow.config.ts must export one map. Multi-map catalogs are internal workspaces and must use a *.workspace.ts file."
|
|
97
|
+
)
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
const unknownKey = Object.keys(input).find((key) => key !== "maps");
|
|
101
|
+
if (unknownKey) {
|
|
102
|
+
throw tileflowConfigValidationError(
|
|
103
|
+
unknownKey,
|
|
104
|
+
new Error(`Tileflow workspace has unrecognized key "${unknownKey}".`)
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
const entries = Object.entries(input.maps).map(([key, value]) => {
|
|
108
|
+
const map2 = value;
|
|
109
|
+
const resolved2 = parseTileflowCatalogMap(map2, `maps.${key}`);
|
|
110
|
+
if (key !== resolved2.id) {
|
|
111
|
+
throw tileflowConfigValidationError(
|
|
112
|
+
`maps.${key}`,
|
|
113
|
+
new Error(`Tileflow workspace map key "${key}" must match the map id "${resolved2.id}".`)
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
return [
|
|
117
|
+
key,
|
|
118
|
+
resolved2,
|
|
119
|
+
collectTileflowMapBuildLineage(map2),
|
|
120
|
+
normalizeSingularMapScenes(map2, resolved2.id)
|
|
121
|
+
];
|
|
122
|
+
});
|
|
123
|
+
if (entries.length === 0) {
|
|
124
|
+
throw tileflowConfigValidationError(
|
|
125
|
+
"maps",
|
|
126
|
+
new Error("Tileflow workspace must contain at least one map.")
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
const scenes2 = /* @__PURE__ */ new Map();
|
|
130
|
+
for (const [mapId, , , mapScenes] of entries) {
|
|
131
|
+
for (const [sceneId, scene] of Object.entries(mapScenes ?? {})) {
|
|
132
|
+
if (scenes2.has(sceneId)) {
|
|
133
|
+
throw tileflowConfigValidationError(
|
|
134
|
+
`maps.${mapId}.scenes.${sceneId}`,
|
|
135
|
+
new Error(`Tileflow workspace scene "${sceneId}" is already defined by another map.`)
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
scenes2.set(sceneId, scene);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
mapMetadata: Object.fromEntries(
|
|
143
|
+
entries.map(([id, map2, lineage]) => [id, { id, lineage, version: map2.version }])
|
|
144
|
+
),
|
|
145
|
+
maps: Object.fromEntries(entries.map(([id, map2]) => [id, map2])),
|
|
146
|
+
...scenes2.size > 0 ? { scenes: Object.fromEntries(scenes2) } : {}
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
const map = input;
|
|
150
|
+
const resolved = parseTileflowCatalogMap(map, "");
|
|
151
|
+
let scenes;
|
|
152
|
+
try {
|
|
153
|
+
scenes = normalizeSingularMapScenes(map, resolved.id);
|
|
154
|
+
} catch (error) {
|
|
155
|
+
throw tileflowConfigValidationError("scenes", error);
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
mapMetadata: {
|
|
159
|
+
[resolved.id]: {
|
|
160
|
+
id: resolved.id,
|
|
161
|
+
lineage: collectTileflowMapBuildLineage(map),
|
|
162
|
+
version: resolved.version
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
maps: { [resolved.id]: resolved },
|
|
166
|
+
...scenes ? { scenes } : {}
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
function parseTileflowCatalogMap(map, path) {
|
|
170
|
+
try {
|
|
171
|
+
return parseTileflowMap(map);
|
|
172
|
+
} catch (error) {
|
|
173
|
+
throw tileflowConfigValidationError(path, error);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
function getTileflowAuthoringMaps(input, project, allowWorkspace) {
|
|
177
|
+
if (allowWorkspace && isRecord(input) && isRecord(input.maps)) {
|
|
178
|
+
const maps = input.maps;
|
|
179
|
+
return Object.fromEntries(
|
|
180
|
+
Object.keys(project.maps).map((mapId2) => [mapId2, maps[mapId2]])
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
const [mapId] = Object.keys(project.maps);
|
|
184
|
+
return mapId ? { [mapId]: input } : {};
|
|
185
|
+
}
|
|
186
|
+
function tileflowConfigValidationError(path, error) {
|
|
187
|
+
if (error instanceof TileflowValidationError) return error;
|
|
188
|
+
if (error instanceof TileflowResolvedMapValidationError) {
|
|
189
|
+
return new TileflowValidationError(
|
|
190
|
+
error.messages.map((message) => ({
|
|
191
|
+
...message,
|
|
192
|
+
path: prefixValidationPath(path, message.path)
|
|
193
|
+
}))
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
return new TileflowValidationError([
|
|
197
|
+
{
|
|
198
|
+
level: "error",
|
|
199
|
+
path: path || "map",
|
|
200
|
+
message: error instanceof Error ? error.message : String(error)
|
|
201
|
+
}
|
|
202
|
+
]);
|
|
203
|
+
}
|
|
204
|
+
function prefixValidationPath(prefix, path) {
|
|
205
|
+
const child = path === "config" ? "" : path;
|
|
206
|
+
if (!prefix) return child || "map";
|
|
207
|
+
return child ? `${prefix}.${child}` : prefix;
|
|
208
|
+
}
|
|
209
|
+
function normalizeSingularMapScenes(map, mapId) {
|
|
210
|
+
if (!map.scenes) return void 0;
|
|
211
|
+
return Object.fromEntries(
|
|
212
|
+
Object.entries(map.scenes).map(([sceneId, scene]) => {
|
|
213
|
+
const normalizedSceneId = tileflowCaptureSceneNameSchema.parse(sceneId);
|
|
214
|
+
return [normalizedSceneId, { ...scene, map: mapId }];
|
|
215
|
+
})
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
function getTileflowMapNames(project) {
|
|
219
|
+
return Object.keys(project.maps);
|
|
220
|
+
}
|
|
221
|
+
function getFirstTileflowMapName(project) {
|
|
222
|
+
const [mapName] = getTileflowMapNames(project);
|
|
223
|
+
if (!mapName) {
|
|
224
|
+
throw new Error("Tileflow config must define at least one map.");
|
|
225
|
+
}
|
|
226
|
+
return mapName;
|
|
227
|
+
}
|
|
228
|
+
var localRequire = createRequire(import.meta.url);
|
|
229
|
+
function collectTileflowConfigInputs(configPath, cwd) {
|
|
230
|
+
const roots = [canonicalPath(cwd), canonicalPath(dirname(resolve(configPath)))];
|
|
231
|
+
const inputs = /* @__PURE__ */ new Set([canonicalPath(configPath)]);
|
|
232
|
+
const pending = [localRequire.cache[canonicalPath(configPath)]];
|
|
233
|
+
const visited = /* @__PURE__ */ new Set();
|
|
234
|
+
while (pending.length > 0) {
|
|
235
|
+
const module = pending.pop();
|
|
236
|
+
if (!module || visited.has(module.filename)) continue;
|
|
237
|
+
visited.add(module.filename);
|
|
238
|
+
const path = canonicalPath(module.filename);
|
|
239
|
+
if (!path.split(sep).includes("node_modules") && roots.some((root) => isPathWithin(root, path))) {
|
|
240
|
+
inputs.add(path);
|
|
241
|
+
}
|
|
242
|
+
pending.push(...module.children);
|
|
243
|
+
}
|
|
244
|
+
for (const cachePath of Object.keys(localRequire.cache)) {
|
|
245
|
+
const path = canonicalPath(cachePath);
|
|
246
|
+
if (!path.split(sep).includes("node_modules") && roots.some((root) => isPathWithin(root, path))) {
|
|
247
|
+
inputs.add(path);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return [...inputs].sort();
|
|
251
|
+
}
|
|
252
|
+
function clearTileflowLocalModuleCache(configPath, cwd) {
|
|
253
|
+
const roots = [canonicalPath(cwd), canonicalPath(dirname(resolve(configPath)))];
|
|
254
|
+
for (const cachePath of Object.keys(localRequire.cache)) {
|
|
255
|
+
if (cachePath.split(sep).includes("node_modules")) continue;
|
|
256
|
+
if (roots.some((root) => isPathWithin(root, canonicalPath(cachePath)))) {
|
|
257
|
+
delete localRequire.cache[cachePath];
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
function canonicalPath(path) {
|
|
262
|
+
try {
|
|
263
|
+
return realpathSync.native(resolve(path));
|
|
264
|
+
} catch {
|
|
265
|
+
return resolve(path);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
function isRecord(value) {
|
|
269
|
+
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export {
|
|
273
|
+
defaultTileflowApiUrl,
|
|
274
|
+
defaultTileflowConfigPath,
|
|
275
|
+
defaultTileflowManifestPath,
|
|
276
|
+
TileflowValidationError,
|
|
277
|
+
loadTileflowConfig,
|
|
278
|
+
loadTileflowConfigWithInputs,
|
|
279
|
+
loadValidTileflowConfig,
|
|
280
|
+
loadValidTileflowConfigWithInputs,
|
|
281
|
+
assertValidTileflowConfig,
|
|
282
|
+
getTileflowMapNames,
|
|
283
|
+
getFirstTileflowMapName
|
|
284
|
+
};
|