@tileflow/capture 0.1.0-alpha.17 → 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 { TileflowDataIdentity, 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,56 +24,6 @@ declare class TileflowCaptureBrowserManager {
38
24
  close(): Promise<void>;
39
25
  }
40
26
 
41
- declare const tileflowCaptureReceiptSchemaVersion: 2;
42
- declare const tileflowCaptureReceiptLimits: Readonly<{
43
- maximumBytes: number;
44
- }>;
45
- type TileflowCaptureReceipt = {
46
- schemaVersion: 2;
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
- data: TileflowDataIdentity;
70
- networkDependent: boolean;
71
- };
72
- type CreateTileflowCaptureReceiptInput = {
73
- dpr: 1 | 2;
74
- data: TileflowDataIdentity;
75
- height: number;
76
- map: string;
77
- networkDependent: boolean;
78
- pngSha256: string;
79
- renderer: TileflowCaptureRendererIdentity;
80
- scene: string;
81
- sceneSha256: string;
82
- styleSha256: string;
83
- target: 'map' | 'application';
84
- width: number;
85
- };
86
- declare function createTileflowCaptureReceipt(input: CreateTileflowCaptureReceiptInput): TileflowCaptureReceipt;
87
- declare function serializeTileflowCaptureReceipt(receipt: TileflowCaptureReceipt): string;
88
- declare function parseTileflowCaptureReceipt(source: string | Uint8Array): TileflowCaptureReceipt;
89
- declare function validateTileflowCaptureReceipt(value: unknown): TileflowCaptureReceipt;
90
-
91
27
  declare const tileflowCaptureResultSchemaVersion: 1;
92
28
  type TileflowCaptureOptions = {
93
29
  allowBrowserInstall?: boolean;
@@ -106,6 +42,7 @@ type CreateTileflowCaptureSessionOptions = Omit<TileflowCaptureOptions, 'scenes'
106
42
  type TileflowCapture = {
107
43
  scene: string;
108
44
  map: string;
45
+ theme: string;
109
46
  target: 'map' | 'application';
110
47
  png: Uint8Array;
111
48
  sha256: string;
@@ -116,7 +53,8 @@ type TileflowCapture = {
116
53
  dpr: 1 | 2;
117
54
  networkDependent: boolean;
118
55
  renderer: TileflowCaptureRendererIdentity;
119
- receipt: TileflowCaptureReceipt;
56
+ /** Newly captured evidence is always the concrete-theme receipt contract. */
57
+ receipt: TileflowCaptureReceiptV4;
120
58
  warnings: string[];
121
59
  };
122
60
  type TileflowCaptureResult = {
@@ -133,7 +71,7 @@ type TileflowCaptureSession = {
133
71
  declare function captureTileflowScenes(options: TileflowCaptureOptions): Promise<TileflowCaptureResult>;
134
72
  declare function createTileflowCaptureSession(options?: CreateTileflowCaptureSessionOptions): TileflowCaptureSession;
135
73
 
136
- 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';
137
75
  type TileflowCapturePhase = 'style-validation' | 'browser-start' | 'resource-load' | 'map-load' | 'map-idle' | 'screenshot';
138
76
  type TileflowCaptureDiagnostic = {
139
77
  message: string;
@@ -161,6 +99,35 @@ declare class TileflowCaptureError extends Error {
161
99
  }
162
100
  declare function captureErrorMessage(error: unknown, fallback: string): string;
163
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
+
164
131
  declare const tileflowSyntheticAssetOrigin = "https://tileflow.local.invalid";
165
132
 
166
133
  declare function resolveTileflowApplicationUrl(input: {
@@ -174,6 +141,8 @@ declare function resolveTileflowApplicationUrl(input: {
174
141
 
175
142
  declare const tileflowVisualComparisonSchemaVersion: 1;
176
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;
177
146
  declare const tileflowVisualArtifactLimits: Readonly<{
178
147
  maximumPngBytes: number;
179
148
  maximumPaletteColors: 16;
@@ -224,10 +193,58 @@ type TileflowVisualPaletteColor = {
224
193
  count: number;
225
194
  ratio: number;
226
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
+ };
227
243
  type TileflowVisualReferenceAnalysis = {
228
244
  schemaVersion: 1;
229
245
  scene: string;
230
246
  map: string;
247
+ theme: string;
231
248
  target: 'map' | 'application';
232
249
  dimensionsMatch: boolean;
233
250
  reference: {
@@ -247,6 +264,7 @@ type TileflowVisualReferenceAnalysis = {
247
264
  threshold: number;
248
265
  }) | null;
249
266
  meanAbsoluteChannelDifference: number | null;
267
+ appearance: TileflowVisualReferenceAppearance | null;
250
268
  diffPng?: Uint8Array;
251
269
  warnings: string[];
252
270
  };
@@ -259,10 +277,80 @@ declare function validateTileflowVisualReferencePng(png: Uint8Array): {
259
277
  width: number;
260
278
  height: number;
261
279
  };
262
- declare function analyzeTileflowCaptureReference(actualCapture: TileflowCapture, referencePng: Uint8Array): Promise<TileflowVisualReferenceAnalysis>;
280
+ declare function analyzeTileflowCaptureReference(actualCapture: TileflowCapture, referencePng: Uint8Array, options?: TileflowVisualReferenceAnalysisOptions): Promise<TileflowVisualReferenceAnalysis>;
263
281
  declare function createTileflowVisualReferenceAnalysisDocument(analysis: TileflowVisualReferenceAnalysis): TileflowVisualReferenceAnalysisDocument;
264
282
  declare function compareTileflowCaptureToBaseline(actualCapture: TileflowCapture, baseline?: TileflowVisualBaseline): Promise<TileflowVisualComparison>;
265
283
  declare function createTileflowVisualComparisonDocument(comparison: TileflowVisualComparison): TileflowVisualComparisonDocument;
266
284
  declare function serializeTileflowVisualComparison(comparison: TileflowVisualComparison | TileflowVisualComparisonDocument): string;
267
285
 
268
- 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 };