tileflow 0.1.0-alpha.5 → 0.1.0-alpha.6

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.
@@ -0,0 +1,268 @@
1
+ # Local visual feedback
2
+
3
+ Start with the [tileflow guide](https://github.com/tileflow/tileflow-sdk/blob/main/packages/cli/README.md) for installation and a complete first example.
4
+
5
+ Explore with capture itself. The first run may install Playwright's exact pinned Chromium headless
6
+ shell into its versioned per-user cache:
7
+
8
+ ```sh
9
+ npx tileflow capture \
10
+ --map madrid \
11
+ --theme dark \
12
+ --center=-3.69201,40.40871 \
13
+ --zoom=16.15 \
14
+ --width=1200 \
15
+ --height=1200 \
16
+ --json
17
+ ```
18
+
19
+ The successful entry includes a normalized `definition` with its concrete `theme`, `camera`,
20
+ `viewport`, and default map `target`. Copy it under a chosen `scenes.<name>` key; the CLI never rewrites
21
+ executable TypeScript config. Then commit the bounded scene so agents and CI render the same map,
22
+ camera, and viewport:
23
+
24
+ ```ts
25
+ import {defineMap} from '@tileflow/core';
26
+ import {streets} from '@tileflow/maps';
27
+
28
+ export default defineMap({
29
+ id: 'madrid',
30
+ name: 'Madrid',
31
+ version: 1,
32
+ extends: streets,
33
+ scenes: {
34
+ 'madrid-desktop': {
35
+ theme: 'dark',
36
+ camera: {type: 'center', center: [-3.7038, 40.4168], zoom: 12},
37
+ viewport: {width: 1280, height: 800, dpr: 1},
38
+ },
39
+ 'madrid-product': {
40
+ theme: 'dark',
41
+ camera: {type: 'center', center: [-3.7038, 40.4168], zoom: 12},
42
+ viewport: {width: 390, height: 844, dpr: 2},
43
+ target: {
44
+ kind: 'application',
45
+ path: '/maps/madrid',
46
+ captureId: 'product-map',
47
+ },
48
+ },
49
+ },
50
+ });
51
+ ```
52
+
53
+ `scenes` is tooling metadata owned by this map. It is not inherited and does not enter the
54
+ cartographic compiler; tooling supplies the exported map ID when it normalizes a scene internally.
55
+ Every scene stores a concrete theme; omission and browser-only `system` are invalid.
56
+
57
+ ### Live comparison workbench
58
+
59
+ Use the ordinary preview server with a right-hand selection to compare two maps or themes while
60
+ authoring:
61
+
62
+ ```sh
63
+ # Two maps or themes from one config.
64
+ npx tileflow preview \
65
+ --map harad --theme light \
66
+ --against-map ferraris --against-theme light
67
+
68
+ # Or compare against another config.
69
+ npx tileflow preview \
70
+ --config ./candidate.config.ts --map candidate \
71
+ --against-config ./reference.config.ts --against-map reference
72
+ ```
73
+
74
+ Any `--against-*` option opens the comparison workbench. Both previews remain same-origin and share
75
+ one synchronized camera. The toolbar switches between side-by-side, split, opacity overlay, and
76
+ blink modes; the selected mode, camera, split, opacity, and active interaction side survive in the
77
+ URL. Each config has its own watched, last-known-good session, so an invalid edit shows bounded
78
+ diagnostics without discarding the last valid map and recovers automatically after a fix.
79
+
80
+ Enable **Inspect** and click a rendered feature to see its bounded feature data, paint/layout values,
81
+ zoom-curve samples, and compiler contribution sidecar. The sprite gallery shows the compiled atlas,
82
+ not source directories. **Copy scene** produces a concrete-theme scene for the current camera and
83
+ viewport; **Copy command** produces the corresponding capture command. The inspector sidecar exists
84
+ only in memory in this local workbench and is not emitted by `tileflow build`.
85
+
86
+ ### Reproducible two-style review
87
+
88
+ For shareable evidence with exact pixels, use headless capture instead of the live preview:
89
+
90
+ ```sh
91
+ npx tileflow visual compare \
92
+ --config ./candidate.config.ts --map candidate --theme light \
93
+ --against-config ./reference.config.ts --against-map reference --against-theme light \
94
+ --center=-3.7038,40.4168 --zooms=12,14,16 \
95
+ --width=1200 --height=800 --dpr=1 --region=0,0,1200,760 \
96
+ --diff --open --json
97
+ ```
98
+
99
+ `--against-config` is explicit and may name the same config. Both sides use one camera, viewport,
100
+ DPR, ordered zoom matrix, pinned browser session, and concrete theme. At most 16 zooms and 64 MiB
101
+ of aggregate embedded PNG data are accepted; an earlier preflight also caps the matrix at
102
+ 67,108,864 aggregate physical pixels. The default transaction writes
103
+ `.tileflow/comparisons/compare.html`, a machine-readable sibling JSON document, and PNG/receipt-v4
104
+ pairs below `compare.assets`; `--diff` adds a highlighted diff when identities are comparable. The
105
+ HTML embeds every image, uses a restrictive CSP, performs no network request, and offers the same
106
+ side-by-side, wipe, overlay, and blink review modes.
107
+
108
+ `--region=x,y,width,height` selects one shared physical-pixel rectangle for compact appearance
109
+ profiles. Review JSON uses the explicit signed direction `rightMinusLeft`; the region does not crop
110
+ captures, changed-pixel metrics, or diffs.
111
+
112
+ Stdout and the sibling JSON use the same schema-version-1 `visual.compare` document: concrete
113
+ left/right selections, shared camera and viewport, zoom-sorted rows with Review v1 documents and
114
+ relative artifact paths, report/document paths, and sorted warnings. This document and the watch
115
+ NDJSON described below are versioned compatibility boundaries.
116
+
117
+ The asset directory also contains a bounded schema-version-1
118
+ `.tileflow-visual-compare.json` inventory. It assigns ownership only to the listed sibling assets
119
+ and records each exact SHA-256. A later successful transaction removes stale generated rows or
120
+ diffs only when that valid prior inventory names them, preserves unrelated files, and refuses a
121
+ managed asset that has been modified, replaced by a symlink/non-file, or grown beyond its bound.
122
+ `--force` does not weaken those ownership checks. The inventory is capped at 64 KiB and the complete
123
+ report, JSON, inventory, PNGs, receipts, stale cleanup, and optional diffs commit or roll back as one
124
+ file transaction.
125
+
126
+ Different pixels are ordinary review evidence and exit 0. A frame, dimension, runtime, or exact
127
+ data mismatch exits 1 and suppresses pixel metrics because the images are not comparable.
128
+ `--allow-data-mismatch` keeps a data-mismatch report inspectable with exit 0, but does not invent
129
+ pixel metrics. `--watch` observes both configs, cancels stale renders, preserves the last complete
130
+ report through invalid edits, and emits deterministic NDJSON with `--json`. An explicit report path
131
+ requires `--force` in watch mode; the managed default path is safely replaceable.
132
+
133
+ Watch events are `watching`, `building`, `invalid`, `recovered`, `generation-complete`, `failed`,
134
+ and `stopped`, with monotonic comparison generations and source-side generations where applicable.
135
+ Without `--allow-data-mismatch`, an incompatible generation emits `failed`, does not replace the
136
+ last complete report, and remains an unresolved failure; an allowed data mismatch emits
137
+ `generation-complete` but still has no pixel metrics. An orderly stop exits 0 only after at least
138
+ one complete generation and no unresolved invalid or failed state; otherwise it exits 1.
139
+
140
+ Render one checkpoint, or recapture after every edit:
141
+
142
+ ```sh
143
+ npx tileflow capture madrid-desktop --json
144
+ npx tileflow capture --all --json
145
+ npx tileflow capture madrid-desktop --watch --json
146
+ ```
147
+
148
+ Use the first command when you want a single image and the last command while refining a map. Watch
149
+ mode stays open, follows changes to the config, its local imports, and its effective icons and fonts,
150
+ and writes a new PNG after each valid edit. Keeping the browser ready makes repeated renders faster.
151
+ If an edit is invalid, the last good image remains in place and capture resumes automatically after
152
+ the fix. Stop watch mode with `Ctrl+C`. It accepts named committed scenes or `--all`, not exploratory
153
+ camera options.
154
+
155
+ Standalone scenes need no app server, account, API key, MCP service, system Chrome, or visible
156
+ window. The first command—or the first capture—may provision Playwright's pinned Chromium headless
157
+ shell in its versioned per-user cache. `--no-browser-install` makes a prepared/offline environment
158
+ strict. Tileflow never falls back to a system browser or packages the browser in npm.
159
+
160
+ For prepared or offline CI, install ahead of time with
161
+ `npx tileflow setup capture --json`. Use `setup capture --no-browser-install` or
162
+ `capture --no-browser-install` as an enforcement check that the exact shell is already cached.
163
+
164
+ For an application scene, its route and component props must render the committed camera. Tileflow
165
+ uses the camera in scene identity but does not mutate arbitrary application map state.
166
+
167
+ One-shot success JSON is one deterministic schema-version-1 document plus one newline. It contains
168
+ sorted scene/map/theme/target entries, relative output and receipt paths, image hash/dimensions/DPR,
169
+ renderer identity, remote-dependency state, and warnings; it contains no image bytes, credential,
170
+ origin, absolute path, user, or timestamp. Managed output is an atomic pair under
171
+ `.tileflow/captures/<scene>.png` and `<scene>.receipt.json`. `tileflow init` ignores managed captures
172
+ and `.tileflow/diffs` when creating a new `.gitignore`. Explicit output replacement requires
173
+ `--force`; symlinks and path escapes fail closed.
174
+
175
+ Each written receipt uses capture schema v4 and records the concrete theme. A Tileflow World
176
+ capture resolves its TileJSON once for
177
+ the whole capture session and records the exact `world-v1` release plus descriptor, archive, data
178
+ contract, and product-contract hashes. All selected scenes and retries therefore use one immutable
179
+ World release even if `current` moves while the command is running.
180
+
181
+ One-shot `--json` failures leave stdout empty and write exactly one deterministic failure document
182
+ to stderr with `code`, `phase`, bounded diagnostics, and optional origin-only resource metadata.
183
+
184
+ Watch JSON is NDJSON with monotonic `building`, `invalid`, `recovered`, `captured`, `failed`, and
185
+ `stopped` generation events. It watches config, transitive local imports, and effective icon/font
186
+ files, preserves the last good capture through invalid edits, cancels stale work, and reuses one
187
+ headless Browser. An orderly stop exits 0 only after a successful capture with no unresolved
188
+ terminal failure.
189
+
190
+ ### Capture through the real application
191
+
192
+ Application scenes use the app's existing Vite, Next.js, Webpack, or custom loopback server. Start
193
+ only that normal server; Tileflow does not run a package script, scan ports, or start
194
+ `tileflow preview`:
195
+
196
+ ```sh
197
+ npm run dev
198
+ TILEFLOW_APP_ORIGIN=http://127.0.0.1:3000 \
199
+ npx tileflow capture madrid-product --json
200
+ ```
201
+
202
+ The React, Vue, and Svelte wrappers expose `data-tileflow-map`, the resolved concrete
203
+ `data-tileflow-theme`, optional `data-tileflow-capture-id`, and
204
+ `data-tileflow-state="loading|idle|error"`. The headless client selects exactly one target, verifies
205
+ the theme, and waits for idle. Use `--url` for one explicit full loopback URL, `--selector` to
206
+ override target selection, and `--frame map|viewport` to override framing. Origins and URLs must be
207
+ credential-free loopback HTTP(S) without fragments. Each navigation uses a fresh context without a
208
+ reused profile, cookies, local storage, or service workers.
209
+
210
+ ### Match a reference and protect the result
211
+
212
+ While refining a style, compare the current scene with any reference screenshot:
213
+
214
+ ```sh
215
+ npx tileflow visual analyze madrid-desktop \
216
+ --reference ./design-reference.png --region=0,0,1200,760 --json
217
+ ```
218
+
219
+ `visual analyze` renders exactly one committed scene and writes the current image and a JSON report
220
+ under `.tileflow/analysis` by default. The report includes both images' dimensions and dominant
221
+ colors. When their physical dimensions match, it also includes exact and perceptual pixel metrics,
222
+ mean channel difference, a high-contrast `.diff.png`, and signed
223
+ `appearance.actualMinusReference` luminance, OKLab, edge-density, and local-contrast evidence. The
224
+ optional region affects only those appearance metrics. The reference PNG is never modified or
225
+ treated as a baseline.
226
+
227
+ Once the map is approved, save it as the expected baseline and use that image to catch later
228
+ regressions:
229
+
230
+ ```sh
231
+ # Save the reviewed current render as the expected baseline.
232
+ npx tileflow visual update madrid-desktop \
233
+ --baseline-dir test/visual-baselines --json
234
+
235
+ # Compare a fresh render without changing the baseline.
236
+ npx tileflow visual diff madrid-desktop \
237
+ --baseline-dir test/visual-baselines --json
238
+
239
+ # Or apply the operation to every committed scene.
240
+ npx tileflow visual diff --all \
241
+ --baseline-dir test/visual-baselines --json
242
+
243
+ # In CI, return exit 2 when the pixels have changed.
244
+ npx tileflow visual diff madrid-desktop \
245
+ --baseline-dir test/visual-baselines --fail-on changed --json
246
+ ```
247
+
248
+ `visual diff` and `visual update` require either one or more positional scene names or `--all`;
249
+ those forms are mutually exclusive. `visual analyze` always accepts exactly one scene.
250
+
251
+ The baseline directory holds the reviewed expected PNG and its receipt. The files generated by a
252
+ comparison are working evidence: the current `.actual.png`, a transparent high-contrast
253
+ `.diff.png` when comparable, and a `.visual.json` report under `.tileflow/diffs` by default.
254
+ `visual diff` may replace those working files on each run, but it never changes the baseline. This
255
+ separation prevents a check from silently accepting the change it was meant to reveal.
256
+
257
+ Before comparing, `visual diff` validates the baseline PNG and receipt, including their hashes,
258
+ dimensions, runtime, and scene identity, without executing or fetching baseline metadata.
259
+ Statuses are `unchanged`, `changed`, `missing-baseline`, `scene-mismatch`, and `runtime-mismatch`.
260
+ Same-size images report exact RGBA changed pixels and an informational fixed-threshold perceptual
261
+ metric; exact inequality determines changed.
262
+
263
+ Changed pixels exit 0 by default so a person or agent can inspect the working files.
264
+ `--fail-on changed` exits 2 for CI; missing or incompatible baselines and operational failures exit 1.
265
+
266
+ Run `visual update` again only after reviewing and accepting the new render. It is the only
267
+ command that creates or changes baseline pairs, and it never stages, commits, or pushes. Remote
268
+ tiles, glyphs, and sprites are reported because their pixels can change independently of the style.
@@ -0,0 +1,69 @@
1
+ # Read-only icon comparison
2
+
3
+ Start with the [tileflow guide](https://github.com/tileflow/tileflow-sdk/blob/main/packages/cli/README.md) for installation and a complete first example.
4
+
5
+ Compare the exported map with its active hosted revision before deciding whether to deploy:
6
+
7
+ ```sh
8
+ npx tileflow icons diff --map-id map_AbCdEfGhIjKlMnOp --against production
9
+ npx tileflow icons diff --map-id map_AbCdEfGhIjKlMnOp --against production --json
10
+ npx tileflow icons diff --map-id map_AbCdEfGhIjKlMnOp --against production --report ./icon-diff.html
11
+ ```
12
+
13
+ The command compiles only the exported map, performs authenticated read-only control-plane
14
+ requests, and never uploads a package, creates a deployment, or writes the frontend manifest.
15
+ Plain and JSON modes create no files. A requested HTML report adds reads of the baseline's four
16
+ public sprite files and
17
+ embeds verified old/new images in one self-contained file. The report groups exact-cell icon
18
+ previews under `Added`, `Modified`, and `Removed`. Added and removed cards show only the affected
19
+ icon; modified cards compare `Before` with `Next`. A script-free 1x/2x selector defaults to 2x,
20
+ switches the embedded density, and renders 1x at half the 2x preview size inside a stable frame so
21
+ the selected state is immediately visible. Package hashes, generated sizes, and icon counts stay in
22
+ collapsed `Details`. A map badge is shown only for a map-scoped report. It exposes no atlas
23
+ implementation UI and contains no API key, remote runtime dependency, original icon source, or
24
+ local source path. Use `--force` to replace different existing report bytes and `--open` only
25
+ together with `--report`.
26
+
27
+ Visual modification means that normalized rendered RGBA pixels changed at 1x or 2x. Fully
28
+ transparent RGB is ignored. The manifest also hashes the four encoded artifacts, so an artifact can
29
+ change while its per-icon pixel list remains unchanged. The report and digest analysis operate on
30
+ generated sprite data; SVG, raster source files, and absolute paths stay on the local machine.
31
+
32
+ `--json` writes exactly one deterministic schema-version-1 document plus a trailing newline. Its
33
+ stable top-level fields, in order, are:
34
+
35
+ ```json
36
+ {
37
+ "schemaVersion": 1,
38
+ "environment": "production",
39
+ "baseline": {"deploymentId": "dep_...", "package": null, "version": 7},
40
+ "proposed": {"package": null},
41
+ "icons": {"added": [], "removed": [], "modified": [], "unchangedCount": 0},
42
+ "generatedBytes": {"before": 0, "after": 0, "delta": 0},
43
+ "artifacts": {"report": null},
44
+ "hasChanges": false
45
+ }
46
+ ```
47
+
48
+ Package summaries, when present, contain `contentHash`, `iconCount`, `label`, and `totalBytes`.
49
+ A missing hosted baseline is an initial comparison against an empty package. The command compares
50
+ only delivered icon pixels, canonical package manifests, and generated bytes; config-directory
51
+ provenance and style-reference analysis belong to `icons list` and final style validation.
52
+
53
+ Normal differences exit 0. Config, compilation, credential, network, response, and report errors
54
+ exit 1.
55
+
56
+ This workflow does not provide OIDC, automatic secret installation, an official
57
+ GitHub Action, an atomic multi-map deploy set, or a Tileflow-hosted remote
58
+ builder.
59
+
60
+ Docs: https://tileflow.dev/docs/deploy
61
+
62
+ ### Team credentials and explicit Map targets
63
+
64
+ A unified Team credential can combine data and Map operations. Use `TILEFLOW_API_KEY` and an
65
+ explicit `--map-id` for deployment, status and hosted icon comparisons. The CLI sends that target
66
+ with style, icon and font requests and verifies the credential covers it. The Hosted API must
67
+ support unified credentials. All Maps includes future Maps; selected Maps is an explicit list.
68
+ A legacy Map key keeps its original binding. Personal CLI login remains separate from machine
69
+ credentials. Credential administration and Team management use the Hosted API or dashboard.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tileflow",
3
- "version": "0.1.0-alpha.5",
3
+ "version": "0.1.0-alpha.6",
4
4
  "license": "Apache-2.0",
5
5
  "description": "CLI-only tools for Tileflow config, capture, visual testing, and deploy.",
6
6
  "type": "module",
@@ -25,6 +25,7 @@
25
25
  },
26
26
  "files": [
27
27
  "dist",
28
+ "docs",
28
29
  "LICENSE"
29
30
  ],
30
31
  "bin": {
@@ -35,12 +36,12 @@
35
36
  },
36
37
  "dependencies": {
37
38
  "@hono/node-server": "2.0.10",
38
- "@tileflow/capture": ">=0.1.0-alpha.22 <0.1.0-beta.0",
39
- "@tileflow/coordinates": ">=0.1.0-alpha.0 <0.1.0-beta.0",
40
- "@tileflow/coordinates-runtime": ">=0.1.0-alpha.2 <0.1.0-beta.0",
41
- "@tileflow/core": ">=0.1.0-alpha.24 <0.1.0-beta.0",
42
- "@tileflow/dev": ">=0.1.0-alpha.23 <0.1.0-beta.0",
43
- "@tileflow/maps": ">=0.1.0-alpha.3 <0.1.0-beta.0",
39
+ "@tileflow/capture": ">=0.1.0-alpha.23 <0.1.0-beta.0",
40
+ "@tileflow/coordinates": ">=0.1.0-alpha.1 <0.1.0-beta.0",
41
+ "@tileflow/coordinates-runtime": ">=0.1.0-alpha.3 <0.1.0-beta.0",
42
+ "@tileflow/core": ">=0.1.0-alpha.25 <0.1.0-beta.0",
43
+ "@tileflow/dev": ">=0.1.0-alpha.24 <0.1.0-beta.0",
44
+ "@tileflow/maps": ">=0.1.0-alpha.4 <0.1.0-beta.0",
44
45
  "commander": "^15.0.0",
45
46
  "hono": "4.13.5",
46
47
  "picocolors": "^1.1.1",