diff --git a/package.json b/package.json index afdd17537..80b4bb556 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "lotus-chat", "version": "4.12.1-lotus", - "description": "Lotus Chat — Matrix client for Lotus Guild", + "description": "Lotus Chat \u2014 Matrix client for Lotus Guild", "main": "index.js", "type": "module", "engines": { @@ -18,7 +18,8 @@ "typecheck": "tsc --noEmit", "prepare": "husky install", "commit": "git-cz", - "semantic-release": "semantic-release" + "semantic-release": "semantic-release", + "postinstall": "node scripts/patch-folds.mjs" }, "lint-staged": { "*.{ts,tsx,js,jsx}": "eslint", diff --git a/scripts/patch-folds.mjs b/scripts/patch-folds.mjs new file mode 100644 index 000000000..19132afb1 --- /dev/null +++ b/scripts/patch-folds.mjs @@ -0,0 +1,26 @@ +import { readFileSync, writeFileSync } from 'fs'; +import { fileURLToPath } from 'url'; +import { join, dirname } from 'path'; + +const __dirname = dirname(fileURLToPath(import.meta.url)); +const foldsPath = join(__dirname, '../node_modules/folds/dist/index.js'); + +try { + let content = readFileSync(foldsPath, 'utf8'); + + // Defensive guard: if src is not a function, render null instead of crashing + const original = 'children: src(filled)'; + const patched = 'children: typeof src === "function" ? src(filled) : null'; + + if (content.includes(patched)) { + console.log('folds patch already applied.'); + } else if (content.includes(original)) { + content = content.replace(original, patched); + 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.'); + } +} catch (e) { + console.warn('Warning: Could not patch folds:', e.message); +}