Skip to content

Commit

Permalink
Merge branch 'master' into a11ystring-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Aug 9, 2019
2 parents 6123081 + 97384e7 commit 9eeaa29
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 9 deletions.
3 changes: 0 additions & 3 deletions data/wrappers
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion js/grunt/buildRunnable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions js/grunt/getPhetLibs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() );
}
Expand Down
32 changes: 27 additions & 5 deletions js/grunt/phet-io/copySupplementalPhetioFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
Expand Down Expand Up @@ -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: {
Expand All @@ -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( '/' );
Expand All @@ -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 );
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 9eeaa29

Please sign in to comment.