Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 38 additions & 27 deletions html/shell.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,35 @@
e.preventDefault();
}, false);

var setStatus = (text) => {
if (!setStatus.last) setStatus.last = { time: Date.now(), text: '' };
if (text === setStatus.last.text) return;
var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
var now = Date.now();
// if this is a progress update, skip it if too soon
if (m && now - setStatus.last.time < 30) return;
setStatus.last.time = now;
setStatus.last.text = text;
if (m) {
text = m[1];
progressElement.value = parseInt(m[2])*100;
progressElement.max = parseInt(m[4])*100;
progressElement.hidden = false;
spinnerElement.hidden = false;
} else {
progressElement.value = null;
progressElement.max = null;
progressElement.hidden = true;
if (!text) spinnerElement.style.display = 'none';
}
statusElement.innerHTML = text;
};

#if MODULARIZE && !EXPORT_ES6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this is the first time we use the preprocessor in these files - there is maybe some risk users were using the file directly? I thought we even had tests that just use the HTML, but maybe I'm wrong?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They already have {{{ SCRIPT }}} here in all of these files, so they already all need processing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, good point.

var moduleArgs = {
#else
var Module = {
#endif
print(...args) {
console.log(...args);
// These replacements are necessary if you render to raw HTML
Expand All @@ -60,45 +88,28 @@
}
},
canvas: canvasElement,
setStatus(text) {
if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' };
if (text === Module.setStatus.last.text) return;
var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
var now = Date.now();
// if this is a progress update, skip it if too soon
if (m && now - Module.setStatus.last.time < 30) return;
Module.setStatus.last.time = now;
Module.setStatus.last.text = text;
if (m) {
text = m[1];
progressElement.value = parseInt(m[2])*100;
progressElement.max = parseInt(m[4])*100;
progressElement.hidden = false;
spinnerElement.hidden = false;
} else {
progressElement.value = null;
progressElement.max = null;
progressElement.hidden = true;
if (!text) spinnerElement.style.display = 'none';
}
statusElement.innerHTML = text;
},
setStatus: setStatus,
totalDependencies: 0,
monitorRunDependencies(left) {
this.totalDependencies = Math.max(this.totalDependencies, left);
Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
}
};
Module.setStatus('Downloading...');
setStatus('Downloading...');
window.onerror = (event) => {
// TODO: do not warn on ok events like simulating an infinite loop or exitStatus
Module.setStatus('Exception thrown, see JavaScript console');
setStatus('Exception thrown, see JavaScript console');
spinnerElement.style.display = 'none';
Module.setStatus = (text) => {
setStatus = (text) => {
if (text) console.error('[post-exception status] ' + text);
};
};
</script>
{{{ SCRIPT }}}
#if MODULARIZE && !EXPORT_ES6
<script type='text/javascript'>
{{{ EXPORT_NAME }}}(moduleArgs);
</script>
#endif
</body>
</html>
63 changes: 37 additions & 26 deletions html/shell_minimal.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,34 @@
e.preventDefault();
}, false);

function setStatus(text) {
if (!setStatus.last) setStatus.last = { time: Date.now(), text: '' };
if (text === setStatus.last.text) return;
var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
var now = Date.now();
if (m && now - setStatus.last.time < 30) return; // if this is a progress update, skip it if too soon
setStatus.last.time = now;
setStatus.last.text = text;
if (m) {
text = m[1];
progressElement.value = parseInt(m[2])*100;
progressElement.max = parseInt(m[4])*100;
progressElement.hidden = false;
spinnerElement.hidden = false;
} else {
progressElement.value = null;
progressElement.max = null;
progressElement.hidden = true;
if (!text) spinnerElement.hidden = true;
}
statusElement.innerHTML = text;
}

#if MODULARIZE || !EXPORT_ES6
var moduleArgs = {
#else
var Module = {
#endif
print(...args) {
// These replacements are necessary if you render to raw HTML
//text = text.replace(/&/g, "&amp;");
Expand All @@ -99,43 +126,27 @@
}
},
canvas: canvasElement,
setStatus(text) {
if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' };
if (text === Module.setStatus.last.text) return;
var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
var now = Date.now();
if (m && now - Module.setStatus.last.time < 30) return; // if this is a progress update, skip it if too soon
Module.setStatus.last.time = now;
Module.setStatus.last.text = text;
if (m) {
text = m[1];
progressElement.value = parseInt(m[2])*100;
progressElement.max = parseInt(m[4])*100;
progressElement.hidden = false;
spinnerElement.hidden = false;
} else {
progressElement.value = null;
progressElement.max = null;
progressElement.hidden = true;
if (!text) spinnerElement.hidden = true;
}
statusElement.innerHTML = text;
},
setStatus: setStatus,
totalDependencies: 0,
monitorRunDependencies(left) {
this.totalDependencies = Math.max(this.totalDependencies, left);
Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
}
};
Module.setStatus('Downloading...');
setStatus('Downloading...');
window.onerror = () => {
Module.setStatus('Exception thrown, see JavaScript console');
setStatus('Exception thrown, see JavaScript console');
spinnerElement.style.display = 'none';
Module.setStatus = (text) => {
setStatus = (text) => {
if (text) console.error('[post-exception status] ' + text);
};
};
</script>
{{{ SCRIPT }}}
#if MODULARIZE && !EXPORT_ES6
<script type='text/javascript'>
{{{ EXPORT_NAME }}}(moduleArgs);
</script>
#endif
</body>
</html>
8 changes: 4 additions & 4 deletions html/shell_minimal_runtime.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
<script>

#if !MODULARIZE
var {{{ EXPORT_NAME }}} = {};
var {{{ EXPORT_NAME }}} = {};
#endif

#if WASM == 2
var supportsWasm = window.WebAssembly && location.search.indexOf('_rwasm=0') < 0;
#endif

// Depending on the build flags that one uses, different files need to be downloaded
// to load the compiled page. The right set of files will be expanded to be downloaded
// via the directive below.
// Depending on the build flags that one uses, different files need to be downloaded
// to load the compiled page. The right set of files will be expanded to be downloaded
// via the directive below.
{{{ DOWNLOAD_JS_AND_WASM_FILES }}}

#if SINGLE_FILE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.html": 519,
"a.html.gz": 357,
"a.html": 515,
"a.html.gz": 355,
"a.js": 4309,
"a.js.gz": 2217,
"a.wasm": 1329,
"a.wasm.gz": 895,
"total": 6157,
"total_gz": 3469
"total": 6153,
"total_gz": 3467
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.html": 552,
"a.html.gz": 373,
"a.html": 548,
"a.html.gz": 371,
"a.js": 7262,
"a.js.gz": 3324,
"a.wasm": 7387,
"a.wasm.gz": 3419,
"total": 15201,
"total_gz": 7116
"total": 15197,
"total_gz": 7114
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.html": 552,
"a.html.gz": 373,
"a.html": 548,
"a.html.gz": 371,
"a.js": 5353,
"a.js.gz": 2522,
"a.wasm": 6036,
"a.wasm.gz": 2854,
"total": 11941,
"total_gz": 5749
"total": 11937,
"total_gz": 5747
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.html": 519,
"a.html.gz": 357,
"a.html": 515,
"a.html.gz": 355,
"a.js": 855,
"a.js.gz": 543,
"a.wasm": 1841,
"a.wasm.gz": 1067,
"total": 3215,
"total_gz": 1967
"total": 3211,
"total_gz": 1965
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.html": 454,
"a.html.gz": 321,
"a.html": 450,
"a.html.gz": 318,
"a.js": 4437,
"a.js.gz": 2281,
"a.wasm": 8304,
"a.wasm.gz": 5647,
"total": 13195,
"total_gz": 8249
"total": 13191,
"total_gz": 8246
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"a.html": 346,
"a.html.gz": 255,
"a.html": 342,
"a.html.gz": 252,
"a.js": 18182,
"a.js.gz": 9814,
"total": 18528,
"total_gz": 10069
"total": 18524,
"total_gz": 10066
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.html": 454,
"a.html.gz": 321,
"a.html": 450,
"a.html.gz": 318,
"a.js": 3975,
"a.js.gz": 2123,
"a.wasm": 8304,
"a.wasm.gz": 5647,
"total": 12733,
"total_gz": 8091
"total": 12729,
"total_gz": 8088
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"a.html": 346,
"a.html.gz": 255,
"a.html": 342,
"a.html.gz": 252,
"a.js": 17708,
"a.js.gz": 9652,
"total": 18054,
"total_gz": 9907
"total": 18050,
"total_gz": 9904
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.html": 552,
"a.html.gz": 373,
"a.html": 548,
"a.html.gz": 371,
"a.js": 287,
"a.js.gz": 242,
"a.wasm": 95,
"a.wasm.gz": 101,
"total": 934,
"total_gz": 716
"total": 930,
"total_gz": 714
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"a.html": 323,
"a.html.gz": 246,
"a.html": 319,
"a.html.gz": 243,
"a.js": 965,
"a.js.gz": 588,
"total": 1288,
"total_gz": 834
"total": 1284,
"total_gz": 831
}
8 changes: 4 additions & 4 deletions test/codesize/test_minimal_runtime_code_size_math.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.html": 552,
"a.html.gz": 373,
"a.html": 548,
"a.html.gz": 371,
"a.js": 847,
"a.js.gz": 505,
"a.wasm": 2715,
"a.wasm.gz": 1674,
"total": 4114,
"total_gz": 2552
"total": 4110,
"total_gz": 2550
}
Loading