JSFiddle - React, Tailwind, and code Playground
HTML
<script>
f=a=>{for(s='',y=a[0].length;y--;)for(s=`
`+s,x=a.length;x--;)a[x][y]=='*'?s='*'+s:(k=>{for(t=0,j=3;j--;)for(i=3;i--;)t+=(a[x+i-1]||1)[y+j-1]=='*';s=t+s})`*`;return s}
</script>
<textarea id = "input" cols = "100" rows = "15" placeholder = "Input"></textarea><br/>
<textarea id = "result" cols = "100" rows = "15"></textarea><br/>
<input id = "compute" type = "button" value = "Compute">
JavaScript
const ge = a => document.getElementById(a);
const input = ge('input');
const result = ge('result');
const compute = ge('compute');
compute.addEventListener('click', a => a.button === 0 && (result.value = f((a => {
var g = Array(w = (a = a.split('\n'))[0].length).fill().map(() => Array(h = a.length)), w, h, x, y;
for(y = 0; y < h; y++) for(x = 0; x < w; x++) g[x][y] = a[y][x];
return g;
})(input.value))))