diff --git a/build/lotus-denoise.js b/build/lotus-denoise.js index 9a997288b..b108765eb 100644 --- a/build/lotus-denoise.js +++ b/build/lotus-denoise.js @@ -30,6 +30,17 @@ return; } + // Derive the parent origin for postMessage targetOrigin from the parentUrl + // widget param (a full URL) so denoise-status messages aren't broadcast with + // '*'. Fall back to this frame's own origin if parentUrl is missing/malformed. + var targetOrigin; + try { + var parentUrl = params.get('parentUrl'); + targetOrigin = parentUrl ? new URL(parentUrl).origin : window.location.origin; + } catch (e) { + targetOrigin = window.location.origin; + } + var md = navigator.mediaDevices; if (!md || typeof md.getUserMedia !== 'function') return; if (typeof AudioWorkletNode === 'undefined' || typeof AudioContext === 'undefined') return; @@ -274,6 +285,9 @@ source.disconnect(); mlNode.disconnect(); } catch (e) {} + try { + if (gateNode) gateNode.disconnect(); + } catch (e) {} try { origTrack.stop(); } catch (e) {} @@ -301,7 +315,7 @@ nativeNS: USE_NATIVE_NS, gate: USE_GATE, }, - '*', + targetOrigin, ); } @@ -316,7 +330,10 @@ .catch(function (e) { var msg = e instanceof Error ? e.message : String(e); console.error('[lotus-denoise] Setup failed:', msg); - window.parent.postMessage({ type: 'lotus-denoise-status', active: false, error: msg }, '*'); + window.parent.postMessage( + { type: 'lotus-denoise-status', active: false, error: msg }, + targetOrigin, + ); return stream; }); } diff --git a/scripts/patch-folds.mjs b/scripts/patch-folds.mjs index d3427e8e6..59ad91b7e 100644 --- a/scripts/patch-folds.mjs +++ b/scripts/patch-folds.mjs @@ -19,8 +19,17 @@ try { writeFileSync(foldsPath, content, 'utf8'); console.log('Applied defensive Icon src guard to folds.'); } else { - console.warn('Warning: folds Icon patch target not found - may need updating.'); + // Genuine "patch could not be applied" case: the target string is gone + // (folds renamed/restructured it) AND it isn't already patched. Fail hard + // so the postinstall hook / CI breaks loudly instead of silently shipping + // an unpatched folds (which crashes at render with "src is not a function"). + console.error( + 'ERROR: folds Icon patch target not found - folds may have updated. ' + + 'Update the patch target string in scripts/patch-folds.mjs before building.', + ); + process.exit(1); } } catch (e) { - console.warn('Warning: Could not patch folds:', e.message); + console.error('ERROR: Could not patch folds:', e.message); + process.exit(1); } diff --git a/scripts/syncDecorations.mjs b/scripts/syncDecorations.mjs index f43e8ebde..f4969b6ad 100644 --- a/scripts/syncDecorations.mjs +++ b/scripts/syncDecorations.mjs @@ -21,10 +21,25 @@ const __dirname = dirname(fileURLToPath(import.meta.url)); const root = join(__dirname, '..'); const catalogPath = join(root, 'src', 'app', 'features', 'lotus', 'avatarDecorations.ts'); -const CDN = 'https://drive.lotusguild.org/public.php/dav/files/bHswJ9pNKp2t26N/cinny-decorations'; +// Single source of truth: the CDN base URL lives in avatarDecorations.ts as +// `export const DECORATION_CDN`. We extract it from there at runtime rather than +// re-declaring it here, so the build script and the app can never drift. This +// .mjs script can't cleanly import the browser-side .ts module (it's outside the +// Vite/TS app graph), so we parse the constant out of the file text instead. +// If you migrate the CDN, change it ONLY in avatarDecorations.ts. +const catalog = readFileSync(catalogPath, 'utf8'); + +const cdnMatch = catalog.match(/export const DECORATION_CDN\s*=\s*['"]([^'"]+)['"]/); +if (!cdnMatch) { + console.error( + 'Could not find `export const DECORATION_CDN` in avatarDecorations.ts — ' + + 'the constant may have been renamed. Update scripts/syncDecorations.mjs.', + ); + process.exit(1); +} +const CDN = cdnMatch[1]; // Extract all slugs from the catalog file -const catalog = readFileSync(catalogPath, 'utf8'); const slugMatches = [...catalog.matchAll(/slug: '([^']+)'/g)].map((m) => m[1]); if (slugMatches.length === 0) { diff --git a/src/app/features/lotus/avatarDecorations.ts b/src/app/features/lotus/avatarDecorations.ts index 59be0198c..2a624c1be 100644 --- a/src/app/features/lotus/avatarDecorations.ts +++ b/src/app/features/lotus/avatarDecorations.ts @@ -1,3 +1,8 @@ +// Single source of truth for the avatar-decoration CDN base URL. +// scripts/syncDecorations.mjs reads this exact `DECORATION_CDN` declaration out +// of this file at runtime (by regex) instead of re-declaring it, so the two can +// never drift. If you migrate the CDN, change it here ONLY — keep the +// `export const DECORATION_CDN = '...'` shape so the sync script can still parse it. export const DECORATION_CDN = 'https://drive.lotusguild.org/public.php/dav/files/bHswJ9pNKp2t26N/cinny-decorations';