Deploy implemented Videoreg interface and persistent theme cycle
This commit is contained in:
1 parent
6405a8d101
commit
a12eefa1de
98 files changed
+4094
-2319
No files matched your search
@@ -236,12 +236,23 @@ def active_source_files():
|
||||
continue
|
||||
candidates = [stem, *[Path(str(stem) + suffix) for suffix in (".ts", ".tsx", ".js", ".jsx", ".json", ".css")], stem / "index.ts", stem / "index.tsx"]
|
||||
pending.extend(p for p in candidates if p.is_file())
|
||||
# Framework icon conventions and first-party public code/branding have no
|
||||
# import edge, but still belong to the exact source identity.
|
||||
seen.update((ROOT / "web-front/public").glob("*.js"))
|
||||
seen.update(p for p in (ROOT / "web-front/public/brand").rglob("*") if p.is_file())
|
||||
seen.update(p for pattern in ("icon.*", "favicon.ico", "apple-icon.*") for p in (src / "app").glob(pattern) if p.is_file())
|
||||
# Hash the actual build/check inputs too; they are not browser destinations.
|
||||
seen.update(ROOT / name for name in ("package.json", "package-lock.json", "tsconfig.json", "web-front/next.config.ts", "scripts/design-system/check-fsd.mjs", "scripts/rebuild-v2/check-built.py", "scripts/rebuild-v2/decode-raster-sharp.mjs", "scripts/rebuild-v2/check-raster-sharp.mjs"))
|
||||
return sorted(seen)
|
||||
|
||||
|
||||
def source_occurrences(files):
|
||||
occurrences = []
|
||||
for path in files:
|
||||
if not (path.is_relative_to(ROOT / "web-front/src") or path.is_relative_to(ROOT / "web-front/public")):
|
||||
continue # Build/check tooling is hash-bound, not an active web reference.
|
||||
if path.suffix.lower() not in (".ts", ".tsx", ".js", ".jsx", ".css", ".json", ".svg"):
|
||||
continue # Binary sources are hash-bound; never decode them as text.
|
||||
text = path.read_text()
|
||||
relative = path.relative_to(ROOT).as_posix()
|
||||
if path.suffix == ".json":
|
||||
|
||||
@@ -16,6 +16,20 @@ try {
|
||||
assert.equal(report.results[0].width, 64);
|
||||
assert.equal(report.results[0].height, 32);
|
||||
assert.equal(report.results[1].valid, false, 'Truncated PNG must fail, not be skipped or treated as metadata-only pass');
|
||||
const frames = await Promise.all([16, 32, 48].map(size => sharp({ create: { width: size, height: size, channels: 4, background: '#17382f' } }).png().toBuffer()));
|
||||
const directory = Buffer.alloc(6 + frames.length * 16); directory.writeUInt16LE(1, 2); directory.writeUInt16LE(frames.length, 4);
|
||||
let offset = directory.length;
|
||||
frames.forEach((frame, i) => { const at = 6 + i * 16; directory[at] = [16,32,48][i]; directory[at+1] = [16,32,48][i]; directory.writeUInt16LE(1,at+4);directory.writeUInt16LE(32,at+6);directory.writeUInt32LE(frame.length,at+8);directory.writeUInt32LE(offset,at+12);offset += frame.length; });
|
||||
const ico = Buffer.concat([directory,...frames]);
|
||||
await writeFile(join(root,'all-frames.ico'),ico);
|
||||
await writeFile(join(root,'truncated-directory.ico'),ico.subarray(0,24));
|
||||
const bounds=Buffer.from(ico);bounds.writeUInt32LE(0xffffffff,18);await writeFile(join(root,'bad-bounds.ico'),bounds);
|
||||
const overlap=Buffer.from(ico);overlap.writeUInt32LE(directory.length,34);await writeFile(join(root,'overlap.ico'),overlap);
|
||||
const corrupt=Buffer.from(ico);corrupt[directory.length+frames[0].length]=0;await writeFile(join(root,'bad-middle-frame.ico'),corrupt);
|
||||
const icons=await decodeBatch({root,files:['all-frames.ico','truncated-directory.ico','bad-bounds.ico','overlap.ico','bad-middle-frame.ico']});
|
||||
assert.equal(icons.results[0].valid,true);assert.deepEqual(icons.results[0].frames.map(f=>[f.width,f.height]),[[16,16],[32,32],[48,48]]);
|
||||
assert.ok(icons.results.slice(1).every(f=>f.valid===false),'Every corrupt directory/member must fail the full ICO');
|
||||
process.stdout.write(JSON.stringify({test:'all-ICO-frames-and-corruption',status:'passed',results:icons.results})+'\n');
|
||||
process.stdout.write(JSON.stringify({ test: 'full-raster-decode-positive-and-corruption', status: 'passed', results: report.results }) + '\n');
|
||||
} finally {
|
||||
await rm(root, { recursive: true, force: true });
|
||||
|
||||
@@ -1,12 +1,32 @@
|
||||
/** Fully decode all raster pixels with npm-lockfile-pinned sharp; no network. */
|
||||
import sharp from 'sharp';
|
||||
import { realpath } from 'node:fs/promises';
|
||||
import { realpath, readFile } from 'node:fs/promises';
|
||||
import { resolve, sep } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
sharp.cache(false);
|
||||
sharp.concurrency(1);
|
||||
|
||||
/** Decode every PNG-backed ICO directory member, not just its largest frame. */
|
||||
export async function decodeIco(bytes) {
|
||||
if (bytes.length < 6 || bytes.length > 25 * 1024 * 1024 || bytes.readUInt16LE(0) !== 0 || bytes.readUInt16LE(2) !== 1) throw new Error('Invalid ICO header');
|
||||
const count = bytes.readUInt16LE(4), ranges = [], frames = [];
|
||||
if (count < 1 || count > 64 || bytes.length < 6 + count * 16) throw new Error('Invalid ICO directory');
|
||||
for (let i = 0; i < count; i++) {
|
||||
const at = 6 + i * 16, width = bytes[at] || 256, height = bytes[at + 1] || 256;
|
||||
const size = bytes.readUInt32LE(at + 8), offset = bytes.readUInt32LE(at + 12), end = offset + size;
|
||||
if (size < 8 || offset < 6 + count * 16 || end > bytes.length || ranges.some(([a, b]) => offset < b && end > a)) throw new Error('Invalid ICO member bounds/overlap');
|
||||
ranges.push([offset, end]);
|
||||
const png = bytes.subarray(offset, end);
|
||||
if (!png.subarray(0, 8).equals(Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]))) throw new Error('ICO member must be PNG-backed; unsupported DIB is not skipped');
|
||||
const image = sharp(png, { failOn: 'error', limitInputPixels: 65536 });
|
||||
const { info } = await image.raw().toBuffer({ resolveWithObject: true });
|
||||
if (info.width !== width || info.height !== height) throw new Error('ICO directory/pixels dimension mismatch');
|
||||
frames.push({ width, height, decodedBytes: info.size });
|
||||
}
|
||||
return { width: Math.max(...frames.map(f => f.width)), height: Math.max(...frames.map(f => f.height)), format: 'ico', pages: count, decodedBytes: frames.reduce((n, f) => n + f.decodedBytes, 0), frames };
|
||||
}
|
||||
|
||||
export async function decodeBatch({ root, files }) {
|
||||
if (sharp.versions.sharp !== '0.34.5') {
|
||||
throw new Error(`Expected lockfile sharp0.34.5, found ${sharp.versions.sharp}`);
|
||||
@@ -20,6 +40,11 @@ export async function decodeBatch({ root, files }) {
|
||||
try {
|
||||
const candidate = await realpath(resolve(boundary, file));
|
||||
if (!candidate.startsWith(boundary + sep)) throw new Error('Raster path outside public root');
|
||||
if (candidate.toLowerCase().endsWith('.ico')) {
|
||||
const decoded = await decodeIco(await readFile(candidate));
|
||||
results.push({ file, type: 'raster', valid: true, ...decoded, decoder: `sharp${sharp.versions.sharp}/all-ICO-PNG-frames` });
|
||||
continue;
|
||||
}
|
||||
const image = sharp(candidate, { failOn: 'error', animated: true, limitInputPixels: 64000000 });
|
||||
const metadata = await image.metadata();
|
||||
// metadata() alone is insufficient: force actual decode of every pixel.
|
||||
|
||||
Reference in new issue
Block a user