inkhash 0.0.0-stage → 0.0.1
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 +21 -0
- package/README.md +1 -3
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +334 -0
- package/dist/config-CvO48-dR.mjs +35 -0
- package/dist/index.d.mts +77 -0
- package/dist/index.mjs +1 -0
- package/package.json +66 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 naamukim
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
package/dist/cli.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { defineCommand, runMain } from "citty";
|
|
3
|
+
import { n as load } from "./config-CvO48-dR.mjs";
|
|
4
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
5
|
+
import { registerHooks } from "node:module";
|
|
6
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
7
|
+
import { transformSync } from "oxc-transform";
|
|
8
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
9
|
+
import { dirname, join, resolve } from "node:path";
|
|
10
|
+
import { selectAll, selectOne } from "css-select";
|
|
11
|
+
import postcss from "postcss";
|
|
12
|
+
import { createHash } from "node:crypto";
|
|
13
|
+
import { parseDocument } from "htmlparser2";
|
|
14
|
+
import { createElement } from "react";
|
|
15
|
+
import { renderToStaticMarkup } from "react-dom/server";
|
|
16
|
+
// package.json
|
|
17
|
+
var name = "inkhash";
|
|
18
|
+
var version = "0.0.1";
|
|
19
|
+
var description = "Visual regression keys from React views and browser profiles, without running a browser";
|
|
20
|
+
// src/hooks.ts
|
|
21
|
+
const graph = /* @__PURE__ */ new Map();
|
|
22
|
+
const source = /\.[mc]?[jt]sx?$/;
|
|
23
|
+
const asset = /\.(png|jpe?g|gif|webp|avif|svg|ico|bmp|woff2?|ttf|otf)$/;
|
|
24
|
+
const extensions = [
|
|
25
|
+
".tsx",
|
|
26
|
+
".ts",
|
|
27
|
+
".jsx",
|
|
28
|
+
".js",
|
|
29
|
+
"/index.tsx",
|
|
30
|
+
"/index.ts",
|
|
31
|
+
"/index.jsx",
|
|
32
|
+
"/index.js"
|
|
33
|
+
];
|
|
34
|
+
registerHooks({
|
|
35
|
+
resolve(specifier, context, next) {
|
|
36
|
+
let result;
|
|
37
|
+
try {
|
|
38
|
+
result = next(specifier, context);
|
|
39
|
+
} catch (error) {
|
|
40
|
+
if (!specifier.startsWith(".")) throw error;
|
|
41
|
+
const found = extensions.map((ext) => {
|
|
42
|
+
try {
|
|
43
|
+
return next(specifier + ext, context);
|
|
44
|
+
} catch {}
|
|
45
|
+
}).find(Boolean);
|
|
46
|
+
if (!found) throw error;
|
|
47
|
+
result = found;
|
|
48
|
+
}
|
|
49
|
+
if (context.parentURL) {
|
|
50
|
+
if (!graph.has(context.parentURL)) graph.set(context.parentURL, /* @__PURE__ */ new Set());
|
|
51
|
+
graph.get(context.parentURL).add(result.url);
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
54
|
+
},
|
|
55
|
+
load(url, context, next) {
|
|
56
|
+
if (url.endsWith(".css")) return {
|
|
57
|
+
format: "module",
|
|
58
|
+
source: "export default new Proxy({}, { get: (_, k) => k })",
|
|
59
|
+
shortCircuit: true
|
|
60
|
+
};
|
|
61
|
+
if (asset.test(url)) return {
|
|
62
|
+
format: "module",
|
|
63
|
+
source: `export default ${JSON.stringify(url)}`,
|
|
64
|
+
shortCircuit: true
|
|
65
|
+
};
|
|
66
|
+
if (url.startsWith("file:") && source.test(url) && !url.includes("/node_modules/")) {
|
|
67
|
+
const file = fileURLToPath(url);
|
|
68
|
+
const { code } = transformSync(file, readFileSync(file, "utf8"), { jsx: { runtime: "automatic" } });
|
|
69
|
+
return {
|
|
70
|
+
format: "module",
|
|
71
|
+
source: code,
|
|
72
|
+
shortCircuit: true
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
return next(url, context);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
function closure(url, seen = /* @__PURE__ */ new Set()) {
|
|
79
|
+
if (seen.has(url)) return seen;
|
|
80
|
+
seen.add(url);
|
|
81
|
+
for (const child of graph.get(url) ?? []) closure(child, seen);
|
|
82
|
+
return seen;
|
|
83
|
+
}
|
|
84
|
+
// src/css.ts
|
|
85
|
+
const dynamic = /::?(before|after|first-line|first-letter|marker|placeholder|selection|backdrop|file-selector-button|hover|focus|focus-visible|focus-within|active|visited|target|-webkit-[\w-]+|-moz-[\w-]+)(?![\w-])/g;
|
|
86
|
+
const nested = /* @__PURE__ */ new Set([
|
|
87
|
+
"media",
|
|
88
|
+
"supports",
|
|
89
|
+
"layer",
|
|
90
|
+
"container",
|
|
91
|
+
"scope"
|
|
92
|
+
]);
|
|
93
|
+
const vars = (value) => [...value.matchAll(/var\(\s*(--[\w-]+)/g)].map((m) => m[1]);
|
|
94
|
+
async function sheet(file) {
|
|
95
|
+
const root = postcss.parse(await readFile(file, "utf8"), { from: file });
|
|
96
|
+
for (const rule of root.nodes.filter((n) => n.type === "atrule" && n.name === "import")) {
|
|
97
|
+
const path = rule.params.match(/^(?:url\()?\s*['"]?([^'")\s]+)/)?.[1];
|
|
98
|
+
if (path && !/^[a-z]+:/i.test(path)) rule.replaceWith((await sheet(resolve(dirname(file), path))).nodes);
|
|
99
|
+
}
|
|
100
|
+
return root;
|
|
101
|
+
}
|
|
102
|
+
const matches = (doc, selector) => {
|
|
103
|
+
const stripped = selector.replace(dynamic, "").trim() || "*";
|
|
104
|
+
if (stripped !== selector.trim() && /:(not|is|where|has)\(/.test(selector)) return true;
|
|
105
|
+
try {
|
|
106
|
+
return !!selectOne(stripped, doc);
|
|
107
|
+
} catch {
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
const scope = (node) => node.parent?.type === "atrule" ? `${scope(node.parent)}@${node.parent.name} ${node.parent.params}` : "";
|
|
112
|
+
function select(doc, sheets, inline) {
|
|
113
|
+
const rules = [];
|
|
114
|
+
const atRules = [];
|
|
115
|
+
const visit = (nodes = []) => nodes.forEach((node) => {
|
|
116
|
+
if (node.type === "atrule" && nested.has(node.name)) visit(node.nodes);
|
|
117
|
+
else if (node.type === "atrule") atRules.push(node);
|
|
118
|
+
else if (node.type === "rule" && node.selectors.some((s) => matches(doc, s))) {
|
|
119
|
+
rules.push(node);
|
|
120
|
+
visit(node.nodes);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
sheets.forEach((root) => visit(root.nodes));
|
|
124
|
+
const plain = rules.flatMap((r) => r.nodes.filter((d) => d.type === "decl" && !d.prop.startsWith("--")));
|
|
125
|
+
const custom = rules.flatMap((r) => r.nodes.filter((d) => d.type === "decl" && d.prop.startsWith("--")));
|
|
126
|
+
const used = /* @__PURE__ */ new Set();
|
|
127
|
+
const queue = [...plain.map((d) => d.value), ...inline].flatMap(vars);
|
|
128
|
+
for (let name; name = queue.shift();) {
|
|
129
|
+
if (used.has(name)) continue;
|
|
130
|
+
used.add(name);
|
|
131
|
+
for (const d of custom) if (d.prop === name) queue.push(...vars(d.value));
|
|
132
|
+
}
|
|
133
|
+
const kept = /* @__PURE__ */ new Set([...plain, ...custom.filter((d) => used.has(d.prop))]);
|
|
134
|
+
const text = [...kept].map((d) => d.value).join("\n") + "\n" + inline.join("\n");
|
|
135
|
+
const named = (rule) => {
|
|
136
|
+
if (rule.name === "font-face") return [...rule.nodes ?? []].some((d) => d.type === "decl" && d.prop === "font-family" && text.includes(d.value.replace(/['"]/g, "")));
|
|
137
|
+
if (/keyframes$/.test(rule.name)) return text.includes(rule.params);
|
|
138
|
+
if (rule.name === "property") return used.has(rule.params);
|
|
139
|
+
return true;
|
|
140
|
+
};
|
|
141
|
+
const extra = atRules.filter(named);
|
|
142
|
+
return {
|
|
143
|
+
css: [...rules.map((r) => `${scope(r)}{${r.selector}{${r.nodes.filter((d) => kept.has(d)).map(String).join(";")}}}`), ...extra.map((r) => `${scope(r)}{${r}}`)],
|
|
144
|
+
urls: [...[...kept].map((d) => [d.value, d.source?.input.file]), ...extra.map((r) => [String(r), r.source?.input.file])].flatMap(([value, file]) => [...value.matchAll(/url\(\s*['"]?([^'")]+)/g)].map((m) => /^[a-z]+:/i.test(m[1]) ? m[1] : resolve(dirname(file ?? "."), m[1])))
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
// src/hash.ts
|
|
148
|
+
const hash = (v) => createHash("sha256").update(typeof v === "string" || v instanceof Uint8Array ? v : JSON.stringify(v)).digest("hex");
|
|
149
|
+
// src/lock.ts
|
|
150
|
+
const read = async (file, fallback) => existsSync(file) ? JSON.parse(await readFile(file, "utf8")) : fallback;
|
|
151
|
+
const write = async (file, value) => {
|
|
152
|
+
await mkdir(dirname(file), { recursive: true });
|
|
153
|
+
await writeFile(file, JSON.stringify(value, null, 2) + "\n");
|
|
154
|
+
};
|
|
155
|
+
function open(config) {
|
|
156
|
+
const last = join(config.dir, "last.json");
|
|
157
|
+
return {
|
|
158
|
+
read: () => read(config.lock, {}),
|
|
159
|
+
write: (locks) => write(config.lock, locks),
|
|
160
|
+
last: () => read(last, []),
|
|
161
|
+
save: (verdicts) => write(last, verdicts)
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
// src/renderer.ts
|
|
165
|
+
async function renderer(config, id) {
|
|
166
|
+
const file = join(config.dir, "renderers", `${id}.json`);
|
|
167
|
+
if (existsSync(file)) return JSON.parse(await readFile(file, "utf8"));
|
|
168
|
+
if (!config.registry) throw new Error(`renderer ${id}: not in ${file} and no registry configured`);
|
|
169
|
+
const response = await fetch(config.registry.replace("{id}", encodeURIComponent(id)));
|
|
170
|
+
if (!response.ok) throw new Error(`renderer ${id}: ${response.status}`);
|
|
171
|
+
const bundle = await response.json();
|
|
172
|
+
if (bundle.id !== id) throw new Error(`renderer ${id}: registry returned ${bundle.id}`);
|
|
173
|
+
await mkdir(join(config.dir, "renderers"), { recursive: true });
|
|
174
|
+
await writeFile(file, JSON.stringify(bundle, null, 2) + "\n");
|
|
175
|
+
return bundle;
|
|
176
|
+
}
|
|
177
|
+
// src/view.ts
|
|
178
|
+
const attributes = [
|
|
179
|
+
"src",
|
|
180
|
+
"srcset",
|
|
181
|
+
"poster",
|
|
182
|
+
"href",
|
|
183
|
+
"xlink:href"
|
|
184
|
+
];
|
|
185
|
+
async function bytes(url, config) {
|
|
186
|
+
if (url.startsWith("data:")) return url;
|
|
187
|
+
const file = url.startsWith("file:") ? fileURLToPath(url) : url.startsWith("/") && !existsSync(url) ? join(config.public, url) : /^[a-z]+:/i.test(url) ? null : resolve(url);
|
|
188
|
+
return file && existsSync(file) ? hash(await readFile(file)) : null;
|
|
189
|
+
}
|
|
190
|
+
async function render(view, config) {
|
|
191
|
+
const url = pathToFileURL(resolve(view.import)).href;
|
|
192
|
+
const mod = await import(url);
|
|
193
|
+
return {
|
|
194
|
+
markup: config.template.replace("{view}", renderToStaticMarkup(createElement(mod[view.export ?? "default"], view.props))),
|
|
195
|
+
css: [...config.css.map((f) => resolve(f)), ...[...closure(url)].filter((u) => u.endsWith(".css")).map((u) => fileURLToPath(u))]
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
async function page(view, config, sheet) {
|
|
199
|
+
const rendered = await render(view, config).catch(() => null);
|
|
200
|
+
if (!rendered) return null;
|
|
201
|
+
const { markup, css: files } = rendered;
|
|
202
|
+
const doc = parseDocument(markup);
|
|
203
|
+
const elements = selectAll("[src],[srcset],[poster],image[href],use[href],[style]", doc);
|
|
204
|
+
const inline = elements.flatMap((e) => e.attribs.style ?? []);
|
|
205
|
+
const { css, urls } = select(doc, await Promise.all(files.map(sheet)), inline);
|
|
206
|
+
const refs = [
|
|
207
|
+
...urls,
|
|
208
|
+
...inline.flatMap((s) => [...s.matchAll(/url\(\s*['"]?([^'")]+)/g)].map((m) => m[1])),
|
|
209
|
+
...elements.flatMap((e) => attributes.flatMap((a) => e.name === "a" ? [] : e.attribs[a]?.split(",").map((s) => s.trim().split(/\s+/)[0]) ?? []))
|
|
210
|
+
];
|
|
211
|
+
const assets = await Promise.all([...new Set(refs)].sort().map(async (ref) => [ref, await bytes(ref, config)]));
|
|
212
|
+
if (assets.some(([, b]) => b === null)) return null;
|
|
213
|
+
return {
|
|
214
|
+
markup: hash(markup),
|
|
215
|
+
css: hash(css),
|
|
216
|
+
assets: hash(assets)
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
// src/run.ts
|
|
220
|
+
async function run(config) {
|
|
221
|
+
const db = open(config);
|
|
222
|
+
const locks = await db.read();
|
|
223
|
+
const renderers = await Promise.all(config.renderers.map((id) => renderer(config, id)));
|
|
224
|
+
const context = hash([config.device, config.media]);
|
|
225
|
+
const sheets = /* @__PURE__ */ new Map();
|
|
226
|
+
const load = (file) => sheets.get(file) ?? sheets.set(file, sheet(file)).get(file);
|
|
227
|
+
const verdicts = [];
|
|
228
|
+
for (const view of config.views) {
|
|
229
|
+
const parts = await page(view, config, load);
|
|
230
|
+
const content = parts && hash(parts);
|
|
231
|
+
for (const bundle of renderers) {
|
|
232
|
+
const e = hash(bundle);
|
|
233
|
+
const key = {
|
|
234
|
+
renderer: e,
|
|
235
|
+
context,
|
|
236
|
+
page: content,
|
|
237
|
+
parts,
|
|
238
|
+
value: content && hash([
|
|
239
|
+
e,
|
|
240
|
+
context,
|
|
241
|
+
content
|
|
242
|
+
])
|
|
243
|
+
};
|
|
244
|
+
const base = locks[`${bundle.id}:${view.id}`]?.key;
|
|
245
|
+
const verdict = {
|
|
246
|
+
view: view.id,
|
|
247
|
+
renderer: bundle.id,
|
|
248
|
+
status: "capture",
|
|
249
|
+
key
|
|
250
|
+
};
|
|
251
|
+
if (!key.value) verdict.reason = "unkeyable";
|
|
252
|
+
else if (!base) verdict.reason = "new";
|
|
253
|
+
else if (base.value === key.value) verdict.status = "skip";
|
|
254
|
+
else if (base.renderer !== key.renderer) verdict.reason = "renderer";
|
|
255
|
+
else if (base.context !== key.context) verdict.reason = "context";
|
|
256
|
+
else {
|
|
257
|
+
verdict.reason = "page";
|
|
258
|
+
verdict.changed = Object.keys(parts).filter((k) => base.parts?.[k] !== parts[k]);
|
|
259
|
+
}
|
|
260
|
+
verdicts.push(verdict);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
await db.save(verdicts);
|
|
264
|
+
return verdicts;
|
|
265
|
+
}
|
|
266
|
+
async function accept(config, cause, view) {
|
|
267
|
+
const db = open(config);
|
|
268
|
+
const locks = await db.read();
|
|
269
|
+
const accepted = [];
|
|
270
|
+
for (const v of await db.last()) {
|
|
271
|
+
if (v.status === "skip" || view && v.view !== view) continue;
|
|
272
|
+
accepted.push(locks[`${v.renderer}:${v.view}`] = {
|
|
273
|
+
view: v.view,
|
|
274
|
+
renderer: v.renderer,
|
|
275
|
+
key: v.key,
|
|
276
|
+
acceptedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
277
|
+
cause
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
await db.write(locks);
|
|
281
|
+
return accepted;
|
|
282
|
+
}
|
|
283
|
+
async function explain(config, view) {
|
|
284
|
+
const db = open(config);
|
|
285
|
+
const [locks, last] = [await db.read(), await db.last()];
|
|
286
|
+
return last.filter((v) => v.view === view).map((v) => ({
|
|
287
|
+
verdict: v,
|
|
288
|
+
lock: locks[`${v.renderer}:${v.view}`]
|
|
289
|
+
}));
|
|
290
|
+
}
|
|
291
|
+
// src/cli.ts
|
|
292
|
+
const print = (v) => console.log(JSON.stringify(v, null, 2));
|
|
293
|
+
runMain(defineCommand({
|
|
294
|
+
meta: {
|
|
295
|
+
name,
|
|
296
|
+
version,
|
|
297
|
+
description
|
|
298
|
+
},
|
|
299
|
+
subCommands: {
|
|
300
|
+
run: defineCommand({
|
|
301
|
+
meta: { description: "Hash every view and list the ones that need a capture" },
|
|
302
|
+
async run() {
|
|
303
|
+
print(await run(await load()));
|
|
304
|
+
}
|
|
305
|
+
}),
|
|
306
|
+
accept: defineCommand({
|
|
307
|
+
meta: { description: "Record the last run in the lock file" },
|
|
308
|
+
args: {
|
|
309
|
+
view: {
|
|
310
|
+
type: "positional",
|
|
311
|
+
required: false
|
|
312
|
+
},
|
|
313
|
+
cause: {
|
|
314
|
+
type: "string",
|
|
315
|
+
required: true
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
async run({ args }) {
|
|
319
|
+
print(await accept(await load(), args.cause, args.view));
|
|
320
|
+
}
|
|
321
|
+
}),
|
|
322
|
+
explain: defineCommand({
|
|
323
|
+
meta: { description: "Show which key layer and page part changed" },
|
|
324
|
+
args: { view: {
|
|
325
|
+
type: "positional",
|
|
326
|
+
required: true
|
|
327
|
+
} },
|
|
328
|
+
async run({ args }) {
|
|
329
|
+
print(await explain(await load(), args.view));
|
|
330
|
+
}
|
|
331
|
+
})
|
|
332
|
+
}
|
|
333
|
+
}));
|
|
334
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { loadConfig } from "c12";
|
|
2
|
+
// src/config.ts
|
|
3
|
+
const defineConfig = (config) => config;
|
|
4
|
+
const defaults = {
|
|
5
|
+
renderers: [],
|
|
6
|
+
registry: "",
|
|
7
|
+
views: [],
|
|
8
|
+
css: [],
|
|
9
|
+
template: "<!doctype html><html><head></head><body><div id=\"root\">{view}</div></body></html>",
|
|
10
|
+
public: "public",
|
|
11
|
+
device: {
|
|
12
|
+
viewport: {
|
|
13
|
+
width: 1280,
|
|
14
|
+
height: 720
|
|
15
|
+
},
|
|
16
|
+
dpr: 1
|
|
17
|
+
},
|
|
18
|
+
media: {
|
|
19
|
+
colorScheme: "light",
|
|
20
|
+
reducedMotion: true,
|
|
21
|
+
locale: "en-US"
|
|
22
|
+
},
|
|
23
|
+
dir: ".inkhash",
|
|
24
|
+
lock: "inkhash.lock"
|
|
25
|
+
};
|
|
26
|
+
async function load(overrides = {}, cwd = process.cwd()) {
|
|
27
|
+
const { config } = await loadConfig({
|
|
28
|
+
name: "inkhash",
|
|
29
|
+
cwd,
|
|
30
|
+
defaults,
|
|
31
|
+
overrides
|
|
32
|
+
});
|
|
33
|
+
return config;
|
|
34
|
+
}
|
|
35
|
+
export { load as n, defineConfig as t };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
interface View {
|
|
2
|
+
id: string;
|
|
3
|
+
import: string;
|
|
4
|
+
export?: string;
|
|
5
|
+
props?: Record<string, unknown>;
|
|
6
|
+
}
|
|
7
|
+
interface Config {
|
|
8
|
+
renderers: string[];
|
|
9
|
+
registry: string;
|
|
10
|
+
views: View[];
|
|
11
|
+
css: string[];
|
|
12
|
+
template: string;
|
|
13
|
+
public: string;
|
|
14
|
+
device: {
|
|
15
|
+
viewport: {
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
};
|
|
19
|
+
dpr: number;
|
|
20
|
+
safeArea?: {
|
|
21
|
+
top: number;
|
|
22
|
+
bottom: number;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
media: {
|
|
26
|
+
colorScheme: 'light' | 'dark';
|
|
27
|
+
reducedMotion: boolean;
|
|
28
|
+
locale: string;
|
|
29
|
+
};
|
|
30
|
+
dir: string;
|
|
31
|
+
lock: string;
|
|
32
|
+
}
|
|
33
|
+
type UserConfig = Partial<Omit<Config, 'device' | 'media'>> & {
|
|
34
|
+
device?: Partial<Config['device']>;
|
|
35
|
+
media?: Partial<Config['media']>;
|
|
36
|
+
};
|
|
37
|
+
export declare const defineConfig: (config: UserConfig) => UserConfig;
|
|
38
|
+
interface Page {
|
|
39
|
+
markup: string;
|
|
40
|
+
css: string;
|
|
41
|
+
assets: string;
|
|
42
|
+
}
|
|
43
|
+
interface Key {
|
|
44
|
+
renderer: string;
|
|
45
|
+
context: string;
|
|
46
|
+
page: string | null;
|
|
47
|
+
parts: Page | null;
|
|
48
|
+
value: string | null;
|
|
49
|
+
}
|
|
50
|
+
interface Verdict {
|
|
51
|
+
view: string;
|
|
52
|
+
renderer: string;
|
|
53
|
+
status: 'skip' | 'capture';
|
|
54
|
+
reason?: 'new' | 'renderer' | 'context' | 'page' | 'unkeyable';
|
|
55
|
+
changed?: (keyof Page)[];
|
|
56
|
+
key: Key;
|
|
57
|
+
}
|
|
58
|
+
interface Lock {
|
|
59
|
+
view: string;
|
|
60
|
+
renderer: string;
|
|
61
|
+
key: Key;
|
|
62
|
+
acceptedAt: string;
|
|
63
|
+
cause: string;
|
|
64
|
+
}
|
|
65
|
+
interface Renderer {
|
|
66
|
+
id: string;
|
|
67
|
+
digest: string;
|
|
68
|
+
engine: 'chromium' | 'webkit';
|
|
69
|
+
arch: 'x86_64' | 'arm64';
|
|
70
|
+
raster: 'software';
|
|
71
|
+
fonts: string[];
|
|
72
|
+
webview?: {
|
|
73
|
+
textZoom: number;
|
|
74
|
+
algorithmicDarkening: boolean;
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
export type { Config, Key, Lock, Page, Renderer, UserConfig, Verdict, View };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as defineConfig } from "./config-CvO48-dR.mjs";
|
package/package.json
CHANGED
|
@@ -1,6 +1,69 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "inkhash",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Visual regression keys from React views and browser profiles, without running a browser",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/NaamuKim/inkhash.git"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/NaamuKim/inkhash#readme",
|
|
11
|
+
"bugs": "https://github.com/NaamuKim/inkhash/issues",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"keywords": [
|
|
14
|
+
"visual-regression",
|
|
15
|
+
"vrt",
|
|
16
|
+
"react",
|
|
17
|
+
"css",
|
|
18
|
+
"static-analysis"
|
|
19
|
+
],
|
|
20
|
+
"bin": {
|
|
21
|
+
"inkhash": "./dist/cli.mjs"
|
|
22
|
+
},
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/index.d.mts",
|
|
26
|
+
"default": "./dist/index.mjs"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist"
|
|
31
|
+
],
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=22.15"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"c12": "4.0.0-rc.4",
|
|
37
|
+
"citty": "^0.2.2",
|
|
38
|
+
"css-select": "^7.0.0",
|
|
39
|
+
"domhandler": "^6.0.1",
|
|
40
|
+
"htmlparser2": "^12.0.0",
|
|
41
|
+
"oxc-transform": "^0.161.0",
|
|
42
|
+
"postcss": "^8.5.34"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@changesets/cli": "^3.1.0",
|
|
46
|
+
"@types/node": "^26.6.11",
|
|
47
|
+
"@types/react": "^19.3.3",
|
|
48
|
+
"@types/react-dom": "^19.3.0",
|
|
49
|
+
"fs-fixture": "^2.16.2",
|
|
50
|
+
"odiff-bin": "^4.5.0",
|
|
51
|
+
"playwright-core": "^1.65.2",
|
|
52
|
+
"react": "^19.3.1",
|
|
53
|
+
"react-dom": "^19.3.1",
|
|
54
|
+
"tsdown": "^0.23.8",
|
|
55
|
+
"typescript": "^7.0.2"
|
|
56
|
+
},
|
|
57
|
+
"peerDependencies": {
|
|
58
|
+
"react": ">=18",
|
|
59
|
+
"react-dom": ">=18"
|
|
60
|
+
},
|
|
61
|
+
"scripts": {
|
|
62
|
+
"build": "tsdown",
|
|
63
|
+
"typecheck": "tsc --noEmit",
|
|
64
|
+
"test": "tsdown && node --test 'test/*.test.ts'",
|
|
65
|
+
"bench": "node bench/bench.ts",
|
|
66
|
+
"changeset": "changeset",
|
|
67
|
+
"release": "changeset publish"
|
|
68
|
+
}
|
|
6
69
|
}
|