@@ -7,8 +7,8 @@ import PropTypes from 'prop-types';
77// JSON.stringify([...document.querySelectorAll('._132722c7')].map(n => n.innerText), null, 2)
88// TODO: use their API for this to grab these at build time?
99export const p5Versions = [
10+ '2.0.0' ,
1011 '1.11.3' ,
11- '2.0.0-beta.2' ,
1212 '1.11.2' ,
1313 '1.11.1' ,
1414 '1.11.0' ,
@@ -133,15 +133,17 @@ export const p5Versions = [
133133 '0.2.1'
134134] ;
135135
136- export const currentP5Version = p5Versions [ 0 ] ;
136+ export const currentP5Version = '1.11.3' ; // Don't update to 2.x until 2026
137137
138- export const p5SoundURL = `https://cdnjs.cloudflare.com/ajax/libs/p5.js/${ currentP5Version } /addons/p5.sound.min.js` ;
138+ export const p5SoundURLOld = `https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.11.3/addons/p5.sound.min.js` ;
139+ export const p5SoundURL =
140+ 'https://cdn.jsdelivr.net/npm/p5.sound@0.2.0/dist/p5.sound.min.js' ;
139141export const p5PreloadAddonURL =
140- 'https://cdn.jsdelivr.net/npm/p5.js-compatibility@0.0 .1/src/preload.js' ;
142+ 'https://cdn.jsdelivr.net/npm/p5.js-compatibility@0.1 .1/src/preload.js' ;
141143export const p5ShapesAddonURL =
142- 'https://cdn.jsdelivr.net/npm/p5.js-compatibility@0.0 .1/src/shapes.js' ;
144+ 'https://cdn.jsdelivr.net/npm/p5.js-compatibility@0.1 .1/src/shapes.js' ;
143145export const p5DataAddonURL =
144- 'https://cdn.jsdelivr.net/npm/p5.js-compatibility@0.0 .1/src/data.js' ;
146+ 'https://cdn.jsdelivr.net/npm/p5.js-compatibility@0.1 .1/src/data.js' ;
145147export const p5URL = `https://cdnjs.cloudflare.com/ajax/libs/p5.js/${ currentP5Version } /p5.js` ;
146148
147149const P5VersionContext = React . createContext ( { } ) ;
@@ -200,7 +202,7 @@ export function P5VersionProvider(props) {
200202 const file = minified ? 'p5.min.js' : 'p5.js' ;
201203 scriptNode . setAttribute (
202204 'src' ,
203- `https://cdnjs.cloudflare.com/ajax/libs/p5.js/ ${ newVersion } /${ file } `
205+ `https://cdn.jsdelivr.net/npm/p5@ ${ newVersion } /lib /${ file } `
204206 ) ;
205207 return serializeResult ( ) ;
206208 } ;
@@ -210,15 +212,19 @@ export function P5VersionProvider(props) {
210212 ] . find ( ( s ) =>
211213 [
212214 / ^ h t t p s ? : \/ \/ c d n j s .c l o u d f l a r e .c o m \/ a j a x \/ l i b s \/ p 5 .j s \/ ( .+ ) \/ a d d o n s \/ p 5 \. s o u n d (?: \. m i n ) ? \. j s $ / ,
213- / ^ h t t p s ? : \/ \/ c d n .j s d e l i v r .n e t \/ n p m \/ p 5 @ ( .+ ) \/ l i b \/ a d d o n s \/ p 5 \. s o u n d (?: \. m i n ) ? \. j s $ /
215+ / ^ h t t p s ? : \/ \/ c d n .j s d e l i v r .n e t \/ n p m \/ p 5 @ ( .+ ) \/ l i b \/ a d d o n s \/ p 5 \. s o u n d (?: \. m i n ) ? \. j s $ / ,
216+ / ^ h t t p s ? : \/ \/ c d n .j s d e l i v r .n e t \/ n p m \/ p 5 .s o u n d @ ( .+ ) \/ d i s t \/ p 5 \. s o u n d (?: \. m i n ) ? \. j s $ /
214217 ] . some ( ( regex ) => regex . exec ( s . getAttribute ( 'src' ) || '' ) )
215218 ) ;
216219 const setP5Sound = function ( enabled ) {
217220 if ( ! enabled && p5SoundNode ) {
218221 p5SoundNode . parentNode . removeChild ( p5SoundNode ) ;
219222 } else if ( enabled && ! p5SoundNode ) {
220223 const newNode = document . createElement ( 'script' ) ;
221- newNode . setAttribute ( 'src' , p5SoundURL ) ;
224+ newNode . setAttribute (
225+ 'src' ,
226+ version . startsWith ( '2' ) ? p5SoundURL : p5SoundURLOld
227+ ) ;
222228 scriptNode . parentNode . insertBefore ( newNode , scriptNode . nextSibling ) ;
223229 }
224230 return serializeResult ( ) ;
0 commit comments