Skip to content

Commit

Permalink
add sharedArrayBuffer option
Browse files Browse the repository at this point in the history
  • Loading branch information
greggman committed Apr 1, 2022
1 parent 4d1218f commit 47d34ff
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const defaultSettings = {
index: true,
scan: true,
unityHack: true,
sharedArrayBuffers: false,
extensions: ['html'],
recent: [],
};
Expand Down
4 changes: 4 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ <h2>A simple web server for local web development</h2>
<label for="unityHack">Support Unity</label>
<input type="checkbox" id="unityHack"/>
</div>
<div class="item checkbox">
<label for="sharedArrayBuffers">SharedArrayBuffer headers</label>
<input type="checkbox" id="sharedArrayBuffers"/>
</div>
<div class="item checkbox">
<label for="ssl">Use HTTPS</label>
<input type="checkbox" id="ssl"/>
Expand Down
13 changes: 8 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ ipcRenderer.on('stopped', () => {
startElem.textContent = "Start";
launchElem.disabled = true;
log("server stopped");
clearQRCodes();
});

ipcRenderer.send('getSettings');
Expand Down Expand Up @@ -283,12 +284,14 @@ function updateSettings() {
function addQRCode(s) {
const qr = QrCode.encodeText(s, Ecc.MEDIUM);
const scale = 4;
ctx.canvas.width = qr.size * scale;
ctx.canvas.height = qr.size * scale;
const padding = 3;
const size = qr.size + padding * 2;
ctx.canvas.width = size * scale;
ctx.canvas.height = size * scale;
ctx.scale(scale, scale);
for (let y = 0; y < qr.size; y++) {
for (let x = 0; x < qr.size; x++) {
ctx.fillStyle = qr.getModule(x, y) ? 'black' : 'white';
for (let y = 0; y < size; y++) {
for (let x = 0; x < size; x++) {
ctx.fillStyle = qr.getModule(x - padding, y - padding) ? 'black' : 'white';
ctx.fillRect(x, y, 1, 1);
}
}
Expand Down

0 comments on commit 47d34ff

Please sign in to comment.