| 1 |
document.addEventListener('DOMContentLoaded', async function() { |
| 2 |
const wasmCheckbox = document.getElementById('wasm'); |
| 3 |
const extraWasmLabel = document.getElementById('extraWasmLabel'); |
| 4 |
wasmCheckbox.disabled = true; |
| 5 |
|
| 6 |
try { |
| 7 |
const features = { |
| 8 |
tailCall: await wasmFeatureDetect.tailCall(), |
| 9 |
gc: await wasmFeatureDetect.gc(), |
| 10 |
exceptions: await wasmFeatureDetect.exceptions() |
| 11 |
}; |
| 12 |
|
| 13 |
const unsupportedFeatures = Object.entries(features) |
| 14 |
.filter(([feature, supported]) => !supported) |
| 15 |
.map(([feature]) => feature); |
| 16 |
|
| 17 |
if (unsupportedFeatures.length === 0) { |
| 18 |
wasmCheckbox.disabled = false; |
| 19 |
} else { |
| 20 |
wasmCheckbox.checked = false; |
| 21 |
|
| 22 |
let featureText = unsupportedFeatures.join(', '); |
| 23 |
let firefoxText = unsupportedFeatures.map(feature => { |
| 24 |
if (feature === 'tailCall') return 'javascript.options.wasm_tail_calls'; |
| 25 |
if (feature === 'gc') return 'javascript.options.wasm_gc'; |
| 26 |
if (feature === 'exceptions') return 'javascript.options.wasm_exceptions'; |
| 27 |
return feature; |
| 28 |
}).join(', '); |
| 29 |
|
| 30 |
if (navigator.userAgent.includes('Firefox')) { |
| 31 |
extraWasmLabel.innerHTML = `(enable <code>${firefoxText}</code> in <code>about:config</code>)`; |
| 32 |
} else { |
| 33 |
extraWasmLabel.innerHTML = `(missing wasm support for: ${featureText})`; |
| 34 |
} |
| 35 |
} |
| 36 |
} catch (error) { |
| 37 |
console.error('Error checking wasm feature support:', error); |
| 38 |
} |
| 39 |
}); |