diff --git a/data/wrappers b/data/wrappers index 3a73771e5..ec5334f5a 100644 --- a/data/wrappers +++ b/data/wrappers @@ -11,6 +11,3 @@ phet-io-wrappers/record phet-io-wrappers/playback phet-io-wrappers/screenshot phet-io-wrappers/state -phet-io-wrapper-arithmetic -phet-io-wrapper-classroom-activity -phet-io-wrapper-lab-book diff --git a/js/grunt/buildRunnable.js b/js/grunt/buildRunnable.js index 11455500f..f67539396 100644 --- a/js/grunt/buildRunnable.js +++ b/js/grunt/buildRunnable.js @@ -303,7 +303,7 @@ module.exports = async function( repo, minifyOptions, instrument, allHTML, brand } if ( brand === 'phet-io' ) { - await copySupplementalPhetioFiles( repo, version, englishTitle ); + await copySupplementalPhetioFiles( repo, version, englishTitle, packageObject ); } // Thumbnails and twitter card diff --git a/js/grunt/getPhetLibs.js b/js/grunt/getPhetLibs.js index a4652d38c..74e6504ba 100644 --- a/js/grunt/getPhetLibs.js +++ b/js/grunt/getPhetLibs.js @@ -68,6 +68,11 @@ module.exports = function getPhetLibs( repo, brand ) { phetLibs = phetLibs.concat( packageObject.phet[ brand ].phetLibs ); } + // wrappers are also marked as phetLibs, so we can get their shas without listing them twice + if ( brand === 'phet-io' && packageObject.phet[ brand ] ) { + phetLibs = phetLibs.concat( packageObject.phet[ brand ].wrappers || [] ); + } + // sort and remove duplicates return _.uniq( phetLibs.sort() ); } diff --git a/js/grunt/phet-io/copySupplementalPhetioFiles.js b/js/grunt/phet-io/copySupplementalPhetioFiles.js index f05767c42..bd5999dcb 100644 --- a/js/grunt/phet-io/copySupplementalPhetioFiles.js +++ b/js/grunt/phet-io/copySupplementalPhetioFiles.js @@ -72,7 +72,7 @@ const JSDOC_FILES = [ ]; const JSDOC_README_FILE = '../phet-io/doc/wrapper/phet-io-documentation_README.md'; -module.exports = async function( repo, version, simulationDisplayName ) { +module.exports = async function( repo, version, simulationDisplayName, packageObject ) { const buildDir = `../${repo}/build/phet-io/`; const wrappersLocation = `${buildDir}${WRAPPERS_FOLDER}`; @@ -226,8 +226,21 @@ module.exports = async function( repo, version, simulationDisplayName ) { const fullBlacklist = wrappersBlacklist.concat( libFileNames ); // wrapping function for copying the wrappers to the build dir - const copyWrapper = function( src, dest ) { - copyDirectory( src, dest, filterWrapper, { + const copyWrapper = function( src, dest, wrapper, wrapperName ) { + + const wrapperFilterWithNameFilter = function( abspath, contents ) { + const result = filterWrapper( abspath, contents ); + + // Support loading relative-path resources, like + //{ url: '../phet-io-wrapper-hookes-law-energy/sounds/precipitate-chimes-v1-shorter.mp3' } + // --> + //{ url: 'wrappers/hookes-law-energy/sounds/precipitate-chimes-v1-shorter.mp3' } + if ( wrapper && wrapperName && result ) { + return ChipperStringUtils.replaceAll( result, `../${wrapper}/`, `wrappers/${wrapperName}/` ); + } + return result; + }; + copyDirectory( src, dest, wrapperFilterWithNameFilter, { blacklist: fullBlacklist, minifyJS: true, minifyOptions: { @@ -238,6 +251,15 @@ module.exports = async function( repo, version, simulationDisplayName ) { // Make sure to copy the phet-io-wrappers common wrapper code too. wrappers.push( WRAPPER_COMMON_FOLDER ); + + // Add sim-specific wrappers + const simSpecificWrappers = packageObject.phet && + packageObject.phet[ 'phet-io' ] && + packageObject.phet[ 'phet-io' ].wrappers ? + packageObject.phet[ 'phet-io' ].wrappers : []; + + simSpecificWrappers.forEach( simSpecificWrapper => wrappers.push( simSpecificWrapper ) ); + wrappers.forEach( function( wrapper ) { const wrapperParts = wrapper.split( '/' ); @@ -246,11 +268,11 @@ module.exports = async function( repo, version, simulationDisplayName ) { const wrapperName = wrapperParts.length > 1 ? wrapperParts[ wrapperParts.length - 1 ] : wrapperParts[ 0 ].replace( DEDICATED_REPO_WRAPPER_PREFIX, '' ); // Copy the wrapper into the build dir /wrappers/, exclude the blacklist - copyWrapper( `../${wrapper}`, `${wrappersLocation}${wrapperName}` ); + copyWrapper( `../${wrapper}`, `${wrappersLocation}${wrapperName}`, wrapper, wrapperName ); } ); // Copy the wrapper index into the top level of the build dir, exclude the blacklist - copyWrapper( '../phet-io-wrappers/index', `${buildDir}` ); + copyWrapper( '../phet-io-wrappers/index', `${buildDir}`, null, null ); // Create the lib file that is minified and publicly available under the /lib folder of the build handleLib( buildDir, filterWrapper ); diff --git a/package.json b/package.json index b4ff39b13..e800922c6 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "babel-core": "^6.26.3", "babel-preset-env": "~1.6.1", "eslint": "~5.14.1", + "eslint-plugin-react": "^7.14.3", "grunt": "~1.0.0", "istanbul": "~0.4.5", "jimp": "^0.2.0",