@tileflow/capture 0.1.0-alpha.16 → 0.1.0-alpha.18

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/index.d.ts CHANGED
@@ -1,22 +1,8 @@
1
1
  import { Browser } from 'playwright';
2
- import { TileflowCaptureScene } from '@tileflow/core';
3
- import { TileflowBuildArtifacts } from '@tileflow/dev';
4
-
5
- type TileflowCaptureRendererIdentity = {
6
- tileflow: string;
7
- maplibre: string;
8
- playwright: string;
9
- chromiumRevision: string;
10
- chromiumVersion: string;
11
- };
12
- declare const tileflowCaptureRuntime: Readonly<{
13
- tileflow: string;
14
- maplibre: string;
15
- playwright: string;
16
- chromiumRevision: string;
17
- chromiumVersion: string;
18
- }>;
19
- declare function createTileflowCaptureRendererIdentity(browser?: Pick<Browser, 'version'>): TileflowCaptureRendererIdentity;
2
+ import { T as TileflowCaptureRendererIdentity, a as TileflowCaptureReceiptV4, b as TileflowCaptureDataInput, c as TileflowCaptureWorldIdentityV3, d as TileflowCaptureReceipt } from './receipt-Q7wQ68tG.js';
3
+ export { C as CreateTileflowCaptureReceiptInput, e as TileflowCaptureDataBindingsV2, f as TileflowCaptureDataCapabilitiesV2, g as TileflowCaptureDataIdentityV2, h as TileflowCaptureDataIdentityV3, i as TileflowCaptureDataSemanticsV2, j as TileflowCaptureDataSourceV2, k as TileflowCaptureReceiptV2, l as TileflowCaptureReceiptV3, m as TileflowCaptureVectorIdentityV3, n as TileflowCaptureVerificationV2, o as createTileflowCaptureReceipt, p as createTileflowCaptureRendererIdentity, q as parseTileflowCaptureReceipt, s as serializeTileflowCaptureReceipt, t as tileflowCaptureReceiptLimits, r as tileflowCaptureReceiptSchemaVersion, u as tileflowCaptureRuntime, v as validateTileflowCaptureReceipt } from './receipt-Q7wQ68tG.js';
4
+ import { TileflowCaptureScene, MapLibreStyle, NormalizedTileflowCaptureScene } from '@tileflow/core';
5
+ import { TileflowBuildArtifacts } from '@tileflow/dev/artifacts';
20
6
 
21
7
  type TileflowBrowserInstallProgress = 'installing' | 'installed';
22
8
  type TileflowBrowserLaunchOptions = {
@@ -38,58 +24,6 @@ declare class TileflowCaptureBrowserManager {
38
24
  close(): Promise<void>;
39
25
  }
40
26
 
41
- declare const tileflowCaptureReceiptSchemaVersion: 1;
42
- declare const tileflowCaptureReceiptLimits: Readonly<{
43
- maximumBytes: number;
44
- }>;
45
- type TileflowCaptureReceipt = {
46
- schemaVersion: 1;
47
- scene: {
48
- name: string;
49
- map: string;
50
- target: 'map' | 'application';
51
- sha256: string;
52
- };
53
- style: {
54
- sha256: string;
55
- };
56
- image: {
57
- sha256: string;
58
- cssWidth: number;
59
- cssHeight: number;
60
- physicalWidth: number;
61
- physicalHeight: number;
62
- dpr: 1 | 2;
63
- };
64
- renderer: TileflowCaptureRendererIdentity;
65
- platform: {
66
- os: string;
67
- architecture: string;
68
- };
69
- source: {
70
- tilesetVersion: string | null;
71
- };
72
- networkDependent: boolean;
73
- };
74
- type CreateTileflowCaptureReceiptInput = {
75
- dpr: 1 | 2;
76
- height: number;
77
- map: string;
78
- networkDependent: boolean;
79
- pngSha256: string;
80
- renderer: TileflowCaptureRendererIdentity;
81
- scene: string;
82
- sceneSha256: string;
83
- styleSha256: string;
84
- sourceVersion?: string;
85
- target: 'map' | 'application';
86
- width: number;
87
- };
88
- declare function createTileflowCaptureReceipt(input: CreateTileflowCaptureReceiptInput): TileflowCaptureReceipt;
89
- declare function serializeTileflowCaptureReceipt(receipt: TileflowCaptureReceipt): string;
90
- declare function parseTileflowCaptureReceipt(source: string | Uint8Array): TileflowCaptureReceipt;
91
- declare function validateTileflowCaptureReceipt(value: unknown): TileflowCaptureReceipt;
92
-
93
27
  declare const tileflowCaptureResultSchemaVersion: 1;
94
28
  type TileflowCaptureOptions = {
95
29
  allowBrowserInstall?: boolean;
@@ -108,6 +42,7 @@ type CreateTileflowCaptureSessionOptions = Omit<TileflowCaptureOptions, 'scenes'
108
42
  type TileflowCapture = {
109
43
  scene: string;
110
44
  map: string;
45
+ theme: string;
111
46
  target: 'map' | 'application';
112
47
  png: Uint8Array;
113
48
  sha256: string;
@@ -118,7 +53,8 @@ type TileflowCapture = {
118
53
  dpr: 1 | 2;
119
54
  networkDependent: boolean;
120
55
  renderer: TileflowCaptureRendererIdentity;
121
- receipt: TileflowCaptureReceipt;
56
+ /** Newly captured evidence is always the concrete-theme receipt contract. */
57
+ receipt: TileflowCaptureReceiptV4;
122
58
  warnings: string[];
123
59
  };
124
60
  type TileflowCaptureResult = {
@@ -135,7 +71,7 @@ type TileflowCaptureSession = {
135
71
  declare function captureTileflowScenes(options: TileflowCaptureOptions): Promise<TileflowCaptureResult>;
136
72
  declare function createTileflowCaptureSession(options?: CreateTileflowCaptureSessionOptions): TileflowCaptureSession;
137
73
 
138
- type TileflowCaptureErrorCode = 'ABORTED' | 'APPLICATION_ORIGIN_REQUIRED' | 'APPLICATION_ORIGIN_INVALID' | 'APPLICATION_NAVIGATION_FAILED' | 'APPLICATION_TARGET_NOT_FOUND' | 'APPLICATION_TARGET_AMBIGUOUS' | 'APPLICATION_ERROR' | 'BASELINE_INVALID' | 'BROWSER_INSTALL_FAILED' | 'BROWSER_MISSING' | 'BROWSER_START_FAILED' | 'CAPTURE_TIMEOUT' | 'INVALID_PNG' | 'MAP_LOAD_FAILED' | 'RENDER_FAILED' | 'RESOURCE_FAILED' | 'SCENE_NOT_FOUND' | 'SCREENSHOT_FAILED' | 'STYLE_INVALID' | 'SYNTHETIC_ASSET_NOT_FOUND';
74
+ type TileflowCaptureErrorCode = 'ABORTED' | 'APPLICATION_ORIGIN_REQUIRED' | 'APPLICATION_ORIGIN_INVALID' | 'APPLICATION_NAVIGATION_FAILED' | 'APPLICATION_TARGET_NOT_FOUND' | 'APPLICATION_TARGET_AMBIGUOUS' | 'APPLICATION_ERROR' | 'BASELINE_INVALID' | 'BROWSER_INSTALL_FAILED' | 'BROWSER_MISSING' | 'BROWSER_START_FAILED' | 'CAPTURE_TIMEOUT' | 'INVALID_PNG' | 'MAP_LOAD_FAILED' | 'RENDER_FAILED' | 'RESOURCE_FAILED' | 'SCENE_NOT_FOUND' | 'SCREENSHOT_FAILED' | 'STYLE_INVALID' | 'SYNTHETIC_ASSET_NOT_FOUND' | 'WORLD_RESOLUTION_FAILED';
139
75
  type TileflowCapturePhase = 'style-validation' | 'browser-start' | 'resource-load' | 'map-load' | 'map-idle' | 'screenshot';
140
76
  type TileflowCaptureDiagnostic = {
141
77
  message: string;
@@ -163,6 +99,35 @@ declare class TileflowCaptureError extends Error {
163
99
  }
164
100
  declare function captureErrorMessage(error: unknown, fallback: string): string;
165
101
 
102
+ declare const tileflowWorldCurrentTileJsonUrl: "https://api.tileflow.dev/tiles/world/tiles.json";
103
+ type FetchTileJson = (input: string, init: {
104
+ cache: 'no-store';
105
+ redirect: 'error';
106
+ signal?: AbortSignal;
107
+ }) => Promise<Pick<Response, 'ok' | 'status' | 'text'>>;
108
+ type TileflowCaptureResolvedWorldV1 = Readonly<{
109
+ identity: Omit<TileflowCaptureWorldIdentityV3, 'kind' | 'schema' | 'schemaVersion' | 'semantics' | 'sourceId'>;
110
+ tileJsonUrl: string;
111
+ tiles: readonly [string];
112
+ }>;
113
+ type PreparedTileflowCaptureStyle = Readonly<{
114
+ data: TileflowCaptureDataInput;
115
+ style: MapLibreStyle;
116
+ }>;
117
+ /**
118
+ * Own one exact World resolution for the complete lifetime of a capture session. A failed lookup
119
+ * is retained too: retrying the same session cannot silently move to a newer `current` release.
120
+ */
121
+ declare class TileflowCaptureWorldSession {
122
+ #private;
123
+ constructor(fetchTileJson?: FetchTileJson);
124
+ prepare(style: MapLibreStyle, signal?: AbortSignal): Promise<PreparedTileflowCaptureStyle>;
125
+ }
126
+ declare function resolveTileflowCaptureWorldTileJson(tileJsonUrl: string, options?: {
127
+ fetchTileJson?: FetchTileJson;
128
+ signal?: AbortSignal;
129
+ }): Promise<TileflowCaptureResolvedWorldV1>;
130
+
166
131
  declare const tileflowSyntheticAssetOrigin = "https://tileflow.local.invalid";
167
132
 
168
133
  declare function resolveTileflowApplicationUrl(input: {
@@ -176,6 +141,8 @@ declare function resolveTileflowApplicationUrl(input: {
176
141
 
177
142
  declare const tileflowVisualComparisonSchemaVersion: 1;
178
143
  declare const tileflowVisualPerceptualThreshold = 0.1;
144
+ /** Fixed linear-luminance difference used to classify adjacent pixel pairs as edges. */
145
+ declare const tileflowVisualEdgeThreshold = 0.05;
179
146
  declare const tileflowVisualArtifactLimits: Readonly<{
180
147
  maximumPngBytes: number;
181
148
  maximumPaletteColors: 16;
@@ -226,10 +193,58 @@ type TileflowVisualPaletteColor = {
226
193
  count: number;
227
194
  ratio: number;
228
195
  };
196
+ /** One bounded region in physical PNG pixels, relative to the top-left corner. */
197
+ type TileflowVisualRegion = {
198
+ x: number;
199
+ y: number;
200
+ width: number;
201
+ height: number;
202
+ };
203
+ type TileflowVisualAppearanceStatistics = {
204
+ mean: number;
205
+ percentiles: {
206
+ p10: number;
207
+ p50: number;
208
+ p90: number;
209
+ };
210
+ };
211
+ type TileflowVisualAppearanceProfile = {
212
+ /** WCAG relative luminance after compositing transparent pixels on white, in [0, 1]. */
213
+ linearLuminance: TileflowVisualAppearanceStatistics;
214
+ /** Perceptual OKLab L after compositing transparent pixels on white, in [0, 1]. */
215
+ oklabLightness: TileflowVisualAppearanceStatistics;
216
+ /** Perceptual OKLab chroma after compositing transparent pixels on white. */
217
+ oklabChroma: TileflowVisualAppearanceStatistics;
218
+ /** Ratio of horizontal/vertical neighbor pairs crossing tileflowVisualEdgeThreshold. */
219
+ edgeDensity: number;
220
+ /** Mean absolute linear-luminance difference across horizontal/vertical neighbor pairs. */
221
+ localContrast: number;
222
+ };
223
+ /** Signed, field-for-field subtraction between two reported appearance profiles. */
224
+ type TileflowVisualAppearanceDelta = TileflowVisualAppearanceProfile;
225
+ type TileflowVisualReferenceAppearance = {
226
+ region: TileflowVisualRegion;
227
+ reference: TileflowVisualAppearanceProfile;
228
+ actual: TileflowVisualAppearanceProfile;
229
+ /** Every value is actual minus reference; negative values mean the actual is lower. */
230
+ actualMinusReference: TileflowVisualAppearanceDelta;
231
+ };
232
+ type TileflowVisualReviewAppearance = {
233
+ region: TileflowVisualRegion;
234
+ left: TileflowVisualAppearanceProfile;
235
+ right: TileflowVisualAppearanceProfile;
236
+ /** Every value is right minus left; negative values mean the right side is lower. */
237
+ rightMinusLeft: TileflowVisualAppearanceDelta;
238
+ };
239
+ type TileflowVisualReferenceAnalysisOptions = {
240
+ /** Restrict appearance metrics to one bounded rectangle in physical PNG pixels. */
241
+ region?: TileflowVisualRegion;
242
+ };
229
243
  type TileflowVisualReferenceAnalysis = {
230
244
  schemaVersion: 1;
231
245
  scene: string;
232
246
  map: string;
247
+ theme: string;
233
248
  target: 'map' | 'application';
234
249
  dimensionsMatch: boolean;
235
250
  reference: {
@@ -249,6 +264,7 @@ type TileflowVisualReferenceAnalysis = {
249
264
  threshold: number;
250
265
  }) | null;
251
266
  meanAbsoluteChannelDifference: number | null;
267
+ appearance: TileflowVisualReferenceAppearance | null;
252
268
  diffPng?: Uint8Array;
253
269
  warnings: string[];
254
270
  };
@@ -261,10 +277,80 @@ declare function validateTileflowVisualReferencePng(png: Uint8Array): {
261
277
  width: number;
262
278
  height: number;
263
279
  };
264
- declare function analyzeTileflowCaptureReference(actualCapture: TileflowCapture, referencePng: Uint8Array): Promise<TileflowVisualReferenceAnalysis>;
280
+ declare function analyzeTileflowCaptureReference(actualCapture: TileflowCapture, referencePng: Uint8Array, options?: TileflowVisualReferenceAnalysisOptions): Promise<TileflowVisualReferenceAnalysis>;
265
281
  declare function createTileflowVisualReferenceAnalysisDocument(analysis: TileflowVisualReferenceAnalysis): TileflowVisualReferenceAnalysisDocument;
266
282
  declare function compareTileflowCaptureToBaseline(actualCapture: TileflowCapture, baseline?: TileflowVisualBaseline): Promise<TileflowVisualComparison>;
267
283
  declare function createTileflowVisualComparisonDocument(comparison: TileflowVisualComparison): TileflowVisualComparisonDocument;
268
284
  declare function serializeTileflowVisualComparison(comparison: TileflowVisualComparison | TileflowVisualComparisonDocument): string;
269
285
 
270
- export { type CreateTileflowCaptureSessionOptions, type TileflowBrowserInstallProgress, type TileflowBrowserLaunchOptions, type TileflowCapture, TileflowCaptureBrowserManager, type TileflowCaptureDiagnostic, TileflowCaptureError, type TileflowCaptureErrorCode, type TileflowCaptureErrorDetails, type TileflowCaptureOptions, type TileflowCapturePhase, type TileflowCaptureReceipt, type TileflowCaptureRendererIdentity, type TileflowCaptureResourceDiagnostic, type TileflowCaptureResourceKind, type TileflowCaptureResult, type TileflowCaptureSession, type TileflowVisualBaseline, type TileflowVisualComparison, type TileflowVisualComparisonDocument, type TileflowVisualComparisonStatus, type TileflowVisualImageIdentity, type TileflowVisualPaletteColor, type TileflowVisualPixelMetric, type TileflowVisualReferenceAnalysis, type TileflowVisualReferenceAnalysisDocument, type TileflowVisualRuntimeIdentity, type TileflowVisualSceneIdentity, analyzeTileflowCaptureReference, captureErrorMessage, captureTileflowScenes, compareTileflowCaptureToBaseline, createTileflowCaptureBrowserEnvironment, createTileflowCaptureReceipt, createTileflowCaptureRendererIdentity, createTileflowCaptureSession, createTileflowVisualComparisonDocument, createTileflowVisualReferenceAnalysisDocument, launchTileflowCaptureBrowser, parseTileflowCaptureReceipt, resolveTileflowApplicationUrl, serializeTileflowCaptureReceipt, serializeTileflowVisualComparison, setupTileflowCaptureBrowser, tileflowCaptureReceiptLimits, tileflowCaptureReceiptSchemaVersion, tileflowCaptureResultSchemaVersion, tileflowCaptureRuntime, tileflowSyntheticAssetOrigin, tileflowVisualArtifactLimits, tileflowVisualComparisonSchemaVersion, tileflowVisualPerceptualThreshold, validateTileflowCaptureReceipt, validateTileflowVisualReferencePng };
286
+ declare const tileflowVisualReviewSchemaVersion: 1;
287
+ type TileflowVisualReviewStatus = 'comparable' | 'frame-mismatch' | 'dimensions-mismatch' | 'runtime-mismatch' | 'data-mismatch';
288
+ type TileflowVisualReviewDefinition = NormalizedTileflowCaptureScene & {
289
+ theme: string;
290
+ };
291
+ type TileflowVisualReviewCapture = {
292
+ capture: TileflowCapture;
293
+ definition: TileflowVisualReviewDefinition;
294
+ };
295
+ type TileflowVisualReviewOptions = {
296
+ /** The contextual diff is evidence for review, never an approval or baseline decision. */
297
+ includeDiff?: boolean;
298
+ /** Restrict appearance metrics to one bounded rectangle in physical PNG pixels. */
299
+ region?: TileflowVisualRegion;
300
+ };
301
+ type TileflowVisualReviewFrameIdentity = {
302
+ camera: TileflowVisualReviewDefinition['camera'];
303
+ viewport: TileflowVisualReviewDefinition['viewport'];
304
+ target: {
305
+ kind: 'map';
306
+ } | {
307
+ kind: 'application';
308
+ frame: 'map' | 'viewport';
309
+ };
310
+ };
311
+ type TileflowVisualReviewSide = {
312
+ scene: TileflowCaptureReceiptV4['scene'];
313
+ style: TileflowCaptureReceiptV4['style'];
314
+ frame: TileflowVisualReviewFrameIdentity;
315
+ image: TileflowVisualImageIdentity;
316
+ runtime: Pick<TileflowCaptureReceiptV4, 'renderer' | 'platform'>;
317
+ data: TileflowCaptureReceiptV4['data'];
318
+ verification: TileflowCaptureReceiptV4['verification'];
319
+ palette: TileflowVisualPaletteColor[];
320
+ };
321
+ type TileflowVisualReviewComparison = {
322
+ schemaVersion: 1;
323
+ kind: 'style-review';
324
+ status: TileflowVisualReviewStatus;
325
+ left: TileflowVisualReviewSide;
326
+ right: TileflowVisualReviewSide;
327
+ frameMatch: boolean;
328
+ dimensionsMatch: boolean;
329
+ rendererMatch: boolean;
330
+ dataMatch: boolean;
331
+ exact: TileflowVisualPixelMetric | null;
332
+ perceptual: (TileflowVisualPixelMetric & {
333
+ threshold: number;
334
+ }) | null;
335
+ meanAbsoluteChannelDifference: number | null;
336
+ appearance: TileflowVisualReviewAppearance | null;
337
+ diffPng?: Uint8Array;
338
+ warnings: string[];
339
+ };
340
+ type TileflowVisualReviewDocument = Omit<TileflowVisualReviewComparison, 'diffPng'>;
341
+ declare class TileflowVisualReviewError extends Error {
342
+ readonly code: "VISUAL_REVIEW_INVALID";
343
+ constructor(message: string, options?: ErrorOptions);
344
+ }
345
+ /**
346
+ * Compare two deliberate Tileflow renders for human or agent review. Unlike baseline comparison,
347
+ * map, theme, scene, and style identities may differ. Pixel evidence is produced only after the
348
+ * two inputs prove that they share the same frame, dimensions, renderer, and exact data identity.
349
+ */
350
+ declare function compareTileflowCapturesForReview(leftInput: TileflowVisualReviewCapture, rightInput: TileflowVisualReviewCapture, options?: TileflowVisualReviewOptions): Promise<TileflowVisualReviewComparison>;
351
+ declare function createTileflowVisualReviewDocument(comparison: TileflowVisualReviewComparison): TileflowVisualReviewDocument;
352
+ declare const tileflowVisualReviewLimits: Readonly<{
353
+ maximumAggregatePngBytes: number;
354
+ }>;
355
+
356
+ export { type CreateTileflowCaptureSessionOptions, type PreparedTileflowCaptureStyle, type TileflowBrowserInstallProgress, type TileflowBrowserLaunchOptions, type TileflowCapture, TileflowCaptureBrowserManager, TileflowCaptureDataInput, type TileflowCaptureDiagnostic, TileflowCaptureError, type TileflowCaptureErrorCode, type TileflowCaptureErrorDetails, type TileflowCaptureOptions, type TileflowCapturePhase, TileflowCaptureReceipt, TileflowCaptureReceiptV4, TileflowCaptureRendererIdentity, type TileflowCaptureResolvedWorldV1, type TileflowCaptureResourceDiagnostic, type TileflowCaptureResourceKind, type TileflowCaptureResult, type TileflowCaptureSession, TileflowCaptureWorldIdentityV3, TileflowCaptureWorldSession, type TileflowVisualAppearanceDelta, type TileflowVisualAppearanceProfile, type TileflowVisualAppearanceStatistics, type TileflowVisualBaseline, type TileflowVisualComparison, type TileflowVisualComparisonDocument, type TileflowVisualComparisonStatus, type TileflowVisualImageIdentity, type TileflowVisualPaletteColor, type TileflowVisualPixelMetric, type TileflowVisualReferenceAnalysis, type TileflowVisualReferenceAnalysisDocument, type TileflowVisualReferenceAnalysisOptions, type TileflowVisualReferenceAppearance, type TileflowVisualRegion, type TileflowVisualReviewAppearance, type TileflowVisualReviewCapture, type TileflowVisualReviewComparison, type TileflowVisualReviewDefinition, type TileflowVisualReviewDocument, TileflowVisualReviewError, type TileflowVisualReviewFrameIdentity, type TileflowVisualReviewOptions, type TileflowVisualReviewSide, type TileflowVisualReviewStatus, type TileflowVisualRuntimeIdentity, type TileflowVisualSceneIdentity, analyzeTileflowCaptureReference, captureErrorMessage, captureTileflowScenes, compareTileflowCaptureToBaseline, compareTileflowCapturesForReview, createTileflowCaptureBrowserEnvironment, createTileflowCaptureSession, createTileflowVisualComparisonDocument, createTileflowVisualReferenceAnalysisDocument, createTileflowVisualReviewDocument, launchTileflowCaptureBrowser, resolveTileflowApplicationUrl, resolveTileflowCaptureWorldTileJson, serializeTileflowVisualComparison, setupTileflowCaptureBrowser, tileflowCaptureResultSchemaVersion, tileflowSyntheticAssetOrigin, tileflowVisualArtifactLimits, tileflowVisualComparisonSchemaVersion, tileflowVisualEdgeThreshold, tileflowVisualPerceptualThreshold, tileflowVisualReviewLimits, tileflowVisualReviewSchemaVersion, tileflowWorldCurrentTileJsonUrl, validateTileflowVisualReferencePng };