Skip to content

Commit d61c2b5

Browse files
committed
Updated Reference for version 0.10.2
1 parent dc6ccfe commit d61c2b5

File tree

9 files changed

+4303
-4465
lines changed

9 files changed

+4303
-4465
lines changed

src/assets/js/p5.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/assets/js/p5.sound.min.js

Lines changed: 3 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/templates/pages/reference/assets/all.css

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

src/templates/pages/reference/assets/js/reference.js

Lines changed: 66 additions & 66 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/templates/pages/reference/assets/js/reference.js.map

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/templates/pages/reference/assets/js/render.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,19 @@ var renderCode = function(sel) {
177177
'touchStarted', 'touchMoved', 'touchEnded',
178178
'keyPressed', 'keyReleased', 'keyTyped'];
179179
var _found = [];
180+
// p.preload is an empty function created by the p5.sound library in
181+
// order to use the p5.js preload system to load AudioWorklet modules
182+
// before a sketch runs, even if that sketch doesn't have its own
183+
// preload function.
184+
// However, this causes an error in the eval code below because the
185+
// _found array will always contain "preload", even if the sketch in
186+
// question doesn't have a preload function. To get around this, we
187+
// delete p.preload before eval-ing the sketch and add it back
188+
// afterwards if the sketch doesn't contain its own preload function.
189+
// For more info, see: https://github.com/processing/p5.js-sound/blob/master/src/audioWorklet/index.js#L22
190+
if (p.preload) {
191+
delete p.preload;
192+
}
180193
with (p) {
181194
// Builds a function to detect declared functions via
182195
// them being hoisted past the return statement. Does
@@ -204,7 +217,7 @@ var renderCode = function(sel) {
204217
].join('\n'));
205218
}
206219
// If we haven't found any functions we'll assume it's
207-
// just a setup body.
220+
// just a setup body with an empty preload.
208221
if (!_found.length) {
209222
p.setup = function() {
210223
p.createCanvas(100, 100);
@@ -221,10 +234,12 @@ var renderCode = function(sel) {
221234
_found.forEach(function(name) {
222235
p[name] = eval(name);
223236
});
237+
// Ensure p.preload exists even if sketch doesn't have the function.
238+
p.preload = p.preload || function() {};
224239
p.setup = p.setup || function() {
225240
p.createCanvas(100, 100);
226241
p.background(200);
227-
}
242+
};
228243
}
229244
};
230245
}

src/templates/pages/reference/assets/js/vendor/ace-nc/ace.js

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

0 commit comments

Comments
 (0)