|
1 | 1 | // include: shell.js
|
2 | 2 | "use strict";
|
3 | 3 |
|
| 4 | +// include: minimum_runtime_check.js |
| 5 | +(function() { |
| 6 | + // "30.0.0" -> 300000 |
| 7 | + function humanReadableVersionToPacked(str) { |
| 8 | + str = str.split('-')[0]; // Remove any trailing part from e.g. "12.53.3-alpha" |
| 9 | + var vers = str.split('.').slice(0, 3); |
| 10 | + while(vers.length < 3) vers.push('00'); |
| 11 | + vers = vers.map((n, i, arr) => n.padStart(2, '0')); |
| 12 | + return vers.join(''); |
| 13 | + } |
| 14 | + // 300000 -> "30.0.0" |
| 15 | + var packedVersionToHumanReadable = n => [n / 10000 | 0, (n / 100 | 0) % 100, n % 100].join('.'); |
| 16 | + |
| 17 | + var TARGET_NOT_SUPPORTED = 2147483647; |
| 18 | + |
| 19 | + var currentNodeVersion = typeof process !== 'undefined' && process?.versions?.node ? humanReadableVersionToPacked(process.versions.node) : TARGET_NOT_SUPPORTED; |
| 20 | + if (currentNodeVersion < 160000) { |
| 21 | + throw new Error(`This emscripten-generated code requires node v${ packedVersionToHumanReadable(160000) } (detected v${packedVersionToHumanReadable(currentNodeVersion)})`); |
| 22 | + } |
| 23 | + |
| 24 | + var currentSafariVersion = typeof navigator !== 'undefined' && navigator?.userAgent?.includes("Safari/") && navigator.userAgent.match(/Version\/(\d+\.?\d*\.?\d*)/) ? humanReadableVersionToPacked(navigator.userAgent.match(/Version\/(\d+\.?\d*\.?\d*)/)[1]) : TARGET_NOT_SUPPORTED; |
| 25 | + if (currentSafariVersion < 150000) { |
| 26 | + throw new Error(`This emscripten-generated code requires Safari v${ packedVersionToHumanReadable(150000) } (detected v${currentSafariVersion})`); |
| 27 | + } |
| 28 | + |
| 29 | + var currentFirefoxVersion = typeof navigator !== 'undefined' && navigator?.userAgent?.match(/Firefox\/(\d+(?:\.\d+)?)/) ? parseFloat(navigator.userAgent.match(/Firefox\/(\d+(?:\.\d+)?)/)[1]) : TARGET_NOT_SUPPORTED; |
| 30 | + if (currentFirefoxVersion < 79) { |
| 31 | + throw new Error(`This emscripten-generated code requires Firefox v79 (detected v${currentFirefoxVersion})`); |
| 32 | + } |
| 33 | + |
| 34 | + var currentChromeVersion = typeof navigator !== 'undefined' && navigator?.userAgent?.match(/Chrome\/(\d+(?:\.\d+)?)/) ? parseFloat(navigator.userAgent.match(/Chrome\/(\d+(?:\.\d+)?)/)[1]) : TARGET_NOT_SUPPORTED; |
| 35 | + if (currentChromeVersion < 85) { |
| 36 | + throw new Error(`This emscripten-generated code requires Chrome v85 (detected v${currentChromeVersion})`); |
| 37 | + } |
| 38 | +})(); |
| 39 | + |
| 40 | +// end include: minimum_runtime_check.js |
4 | 41 | // The Module object: Our interface to the outside world. We import
|
5 | 42 | // and export values on it. There are various ways Module can be used:
|
6 | 43 | // 1. Not defined. We create it here
|
@@ -61,13 +98,6 @@ if (ENVIRONMENT_IS_NODE) {
|
61 | 98 | const isNode = typeof process == 'object' && process.versions?.node && process.type != 'renderer';
|
62 | 99 | if (!isNode) throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)');
|
63 | 100 |
|
64 |
| - var nodeVersion = process.versions.node; |
65 |
| - var numericVersion = nodeVersion.split('.').slice(0, 3); |
66 |
| - numericVersion = (numericVersion[0] * 10000) + (numericVersion[1] * 100) + (numericVersion[2].split('-')[0] * 1); |
67 |
| - if (numericVersion < 160000) { |
68 |
| - throw new Error('This emscripten-generated code requires node v16.0.0 (detected v' + nodeVersion + ')'); |
69 |
| - } |
70 |
| - |
71 | 101 | // These modules will usually be used on Node.js. Load them eagerly to avoid
|
72 | 102 | // the complexity of lazy-loading.
|
73 | 103 | var fs = require('fs');
|
@@ -110,9 +140,6 @@ readAsync = async (filename, binary = true) => {
|
110 | 140 | } else
|
111 | 141 | if (ENVIRONMENT_IS_SHELL) {
|
112 | 142 |
|
113 |
| - const isNode = typeof process == 'object' && process.versions?.node && process.type != 'renderer'; |
114 |
| - if (isNode || typeof window == 'object' || typeof WorkerGlobalScope != 'undefined') throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)'); |
115 |
| - |
116 | 143 | } else
|
117 | 144 |
|
118 | 145 | // Note that this includes Node.js workers when relevant (pthreads is enabled).
|
|
0 commit comments