Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Experimental] Use JSX for rendering in game debugger message #5983

Merged
merged 1 commit into from
Dec 1, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -123,48 +123,33 @@ namespace gdjs {
const errorIsInJs = isErrorComingFromJavaScriptCode(
this._uncaughtException
);
this._uncaughtExceptionElement = h(
'div',
{
style: styles.errorContainer,
},
h(
'button',
{
style: styles.closeButton,
onClick: () => this.setUncaughtException(null),
},
'×'
),
h(
'h2',
{
style: styles.errorTitle,
},
errorIsInJs
? 'An error happened in a JavaScript code event.'
: 'A crash or error happened in the game.'
),
h(
'p',
{
style: styles.errorMessage,
},
(errorIsInJs
? 'This error comes from a JavaScript code event. Verify your code to ensure no error is happening. You can use the Developer Tools (menu "View" > "Toggle Developer Tools"). Full error is: '
: "If you're using JavaScript, verify your code. Otherwise, this might be an issue with GDevelop - consider reporting a bug. Full error is: ") +
this._uncaughtException.message
),
h(
'pre',
{
style: styles.stacktrace,
},
this._uncaughtException.stack || '(No stracktrace).'
)
this._uncaughtExceptionElement = (
<div style={styles.errorContainer}>
<button
style={styles.closeButton}
onClick={() => this.setUncaughtException(null)}
>
×
</button>
<h2 style={styles.errorTitle}>
{errorIsInJs
? 'An error happened in a JavaScript code event.'
: 'A crash or error happened in the game.'}
</h2>
<p style={styles.errorMessage}>
{(errorIsInJs
? 'This error comes from a JavaScript code event. Verify your code to ensure no error is happening. You can use the Developer Tools (menu "View" > "Toggle Developer Tools"). Full error is: '
: "If you're using JavaScript, verify your code. Otherwise, this might be an issue with GDevelop - consider reporting a bug. Full error is: ") +
this._uncaughtException.message}
</p>
<pre style={styles.stacktrace}>
{this._uncaughtException.stack || '(No stracktrace).'}
</pre>
</div>
);

domElementContainer.appendChild(this._uncaughtExceptionElement);
if (this._uncaughtExceptionElement)
domElementContainer.appendChild(this._uncaughtExceptionElement);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion GDJS/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const fs = require('fs').promises;

/** @param {string} outPath */
const renameBuiltFile = (outPath) => {
return outPath.replace(/\.ts$/, '.js');
return outPath.replace(/\.tsx?$/, '.js');
};

const bundledOutPath =
Expand Down
4 changes: 2 additions & 2 deletions GDJS/scripts/lib/runtime-files-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ const extensionsRuntimePath = path.join(gdevelopRootPath, 'Extensions');
const gdjsRuntimePath = path.join(gdjsRootPath, 'Runtime');

// The extensions to be included in the bundled Runtime (will be built with esbuild or copied).
const allowedExtensions = ['.js', '.ts', '.html', '.json', '.xml', '.map', '.wasm'];
const allowedExtensions = ['.js', '.ts', '.tsx', '.html', '.json', '.xml', '.map', '.wasm'];

// These extensions will be built with esbuild (the other will be copied).
const transformIncludedExtensions = ['.js', '.ts'];
const transformIncludedExtensions = ['.js', '.ts', '.tsx'];

// Among the files matching the previous extensions, these extensions won't be built with esbuild
// (they will be copied).
Expand Down
6 changes: 5 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@
},
"baseUrl": "./",
"lib": ["DOM", "ES5", "ScriptHost", "ES2015.Iterable", "ES2015.Promise"],
"typeRoots": ["GDJS/node_modules/@types/"]
"typeRoots": ["GDJS/node_modules/@types/"],
// JSX syntax for lightweight rendering in the game engine:
"jsx": "react",
"jsxFactory": "h",
"jsxFragmentFactory": "Fragment"
},
"include": [
"GDJS/Runtime/**/*",
Expand Down