hyperframes 0.4.41 → 0.4.43
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/cli.js +4663 -4392
- package/dist/commands/contrast-audit.browser.js +2 -0
- package/dist/hyperframe-runtime.js +19 -19
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +19 -19
- package/dist/skills/hyperframes/scripts/contrast-report.mjs +10 -0
- package/dist/studio/assets/{index-D4-n3yWG.js → index-Dzq4sUj7.js} +21 -21
- package/dist/studio/index.html +1 -1
- package/package.json +1 -1
|
@@ -156,7 +156,9 @@ async function annotateFrame(pngBuf, elements) {
|
|
|
156
156
|
|
|
157
157
|
const measured = [];
|
|
158
158
|
for (const el of elements) {
|
|
159
|
+
if (isBBoxOutsideFrame(el.bbox, width, height)) continue;
|
|
159
160
|
const bg = sampleRingMedian(raw, width, height, channels, el.bbox);
|
|
161
|
+
if (!bg) continue;
|
|
160
162
|
const fg = compositeOver(el.fg, bg); // flatten any alpha against measured bg
|
|
161
163
|
const ratio = wcagRatio(fg, bg);
|
|
162
164
|
const large = isLargeText(el.fontSize, el.fontWeight);
|
|
@@ -167,6 +169,8 @@ async function annotateFrame(pngBuf, elements) {
|
|
|
167
169
|
el.wcagAAA = large ? ratio >= 4.5 : ratio >= 7;
|
|
168
170
|
measured.push(el);
|
|
169
171
|
}
|
|
172
|
+
elements.length = 0;
|
|
173
|
+
elements.push(...measured);
|
|
170
174
|
|
|
171
175
|
// Draw boxes + ratio labels as an SVG overlay (sharp composite).
|
|
172
176
|
const svg = buildOverlaySVG(measured, width, height);
|
|
@@ -186,6 +190,7 @@ function sampleRingMedian(raw, width, height, channels, bbox) {
|
|
|
186
190
|
const y0 = Math.max(0, Math.floor(bbox.y) - 4);
|
|
187
191
|
const y1 = Math.min(height - 1, Math.ceil(bbox.y + bbox.h) + 4);
|
|
188
192
|
const pushPixel = (x, y) => {
|
|
193
|
+
if (x < 0 || x >= width || y < 0 || y >= height) return;
|
|
189
194
|
const i = (y * width + x) * channels;
|
|
190
195
|
r.push(raw[i]);
|
|
191
196
|
g.push(raw[i + 1]);
|
|
@@ -199,9 +204,14 @@ function sampleRingMedian(raw, width, height, channels, bbox) {
|
|
|
199
204
|
pushPixel(x0, y);
|
|
200
205
|
pushPixel(x1, y);
|
|
201
206
|
}
|
|
207
|
+
if (r.length === 0) return null;
|
|
202
208
|
return [median(r), median(g), median(b), 1];
|
|
203
209
|
}
|
|
204
210
|
|
|
211
|
+
function isBBoxOutsideFrame(bbox, width, height) {
|
|
212
|
+
return bbox.x + bbox.w <= 0 || bbox.y + bbox.h <= 0 || bbox.x >= width || bbox.y >= height;
|
|
213
|
+
}
|
|
214
|
+
|
|
205
215
|
function median(arr) {
|
|
206
216
|
const s = [...arr].sort((a, b) => a - b);
|
|
207
217
|
return s[Math.floor(s.length / 2)];
|