Skip to content

Commit 3420bd3

Browse files
committed
Merge branch 'release-2.0.1' into release
2 parents a2f09c4 + 50db04e commit 3420bd3

File tree

3 files changed

+31
-29
lines changed

3 files changed

+31
-29
lines changed

client/utils/previewEntry.js

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -149,30 +149,32 @@ window.onunhandledrejection = async function onUnhandledRejection(event) {
149149

150150
// Monkeypatch p5._friendlyError
151151
const { _report } = window.p5;
152-
window.p5._report = function resolvedReport(message, method, color) {
153-
const urls = Object.keys(window.objectUrls);
154-
const paths = Object.keys(window.objectPaths);
155-
let newMessage = message;
156-
urls.forEach((url) => {
157-
newMessage = newMessage.replaceAll(url, window.objectUrls[url]);
158-
if (newMessage.match('index.html')) {
159-
const onLineRegex = /on line (?<lineNo>.\d) in/gm;
160-
const lineNoRegex = /index\.html:(?<lineNo>.\d):/gm;
161-
const match = onLineRegex.exec(newMessage);
162-
const line = match.groups.lineNo;
163-
const resolvedLine = parseInt(line, 10) - htmlOffset;
164-
newMessage = newMessage.replace(
165-
onLineRegex,
166-
`on line ${resolvedLine} in`
167-
);
168-
newMessage = newMessage.replace(
169-
lineNoRegex,
170-
`index.html:${resolvedLine}:`
171-
);
172-
}
173-
});
174-
paths.forEach((path) => {
175-
newMessage = newMessage.replaceAll(path, window.objectPaths[path]);
176-
});
177-
_report.apply(window.p5, [newMessage, method, color]);
178-
};
152+
if (_report) {
153+
window.p5._report = function resolvedReport(message, method, color) {
154+
const urls = Object.keys(window.objectUrls);
155+
const paths = Object.keys(window.objectPaths);
156+
let newMessage = message;
157+
urls.forEach((url) => {
158+
newMessage = newMessage.replaceAll(url, window.objectUrls[url]);
159+
if (newMessage.match('index.html')) {
160+
const onLineRegex = /on line (?<lineNo>.\d) in/gm;
161+
const lineNoRegex = /index\.html:(?<lineNo>.\d):/gm;
162+
const match = onLineRegex.exec(newMessage);
163+
const line = match.groups.lineNo;
164+
const resolvedLine = parseInt(line, 10) - htmlOffset;
165+
newMessage = newMessage.replace(
166+
onLineRegex,
167+
`on line ${resolvedLine} in`
168+
);
169+
newMessage = newMessage.replace(
170+
lineNoRegex,
171+
`index.html:${resolvedLine}:`
172+
);
173+
}
174+
});
175+
paths.forEach((path) => {
176+
newMessage = newMessage.replaceAll(path, window.objectPaths[path]);
177+
});
178+
_report.apply(window.p5, [newMessage, method, color]);
179+
};
180+
}

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "p5.js-web-editor",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"description": "The web editor for p5.js.",
55
"scripts": {
66
"clean": "rimraf dist",

0 commit comments

Comments
 (0)