Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
18 changes: 16 additions & 2 deletions src/userlib/js/bootstrap/candid/candid.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ function renderMethod(name, idl_func, f) {
} else {
show_result = valuesToString(idl_func.retTypes, result);
}
left.innerText = show_result;
show_result = encodeStr(show_result);
left.innerHTML = show_result;
right.innerText = `(${duration}s)`;

const show_args = valuesToString(idl_func.argTypes, args);
Expand All @@ -86,6 +87,19 @@ function zipWith(xs, ys, f) {
return xs.map((x, i) => f(x, ys[i]));
}

function encodeStr(str) {
const escapeChars = {
' ' : ' ',
'<' : '&lt;',
'>' : '&gt;',
'\n' : '<br>',
};
const regex = new RegExp('[ <>\n]', 'g');
return str.replace(regex, m => {
return escapeChars[m];
});
}

function valuesToString(types, values) {
return '(' + zipWith(types, values, ((t, v) => t.valueToString(v))).join(', ') + ')';
}
Expand All @@ -97,7 +111,7 @@ function log(content) {
if (content instanceof Element) {
line.appendChild(content);
} else {
line.innerText = content;
line.innerHTML = content;
}
console.appendChild(line);
}
2 changes: 1 addition & 1 deletion src/userlib/js/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
// "outDir": "out", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
"rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
Copy link
Contributor

Choose a reason for hiding this comment

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

That's actually a bad idea if you don't have a list of files. This will force TypeScript to look into node_modules for example, which we don't want.

Add an include key instead.

// "composite": true, /* Enable project compilation */
"tsBuildInfoFile": "./build_info.json", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
Expand Down