From b66691c76d291e9b7e4453a87fa77c6275e25477 Mon Sep 17 00:00:00 2001 From: Jonathan Olson Date: Tue, 19 Dec 2023 11:03:40 -0700 Subject: [PATCH] Include the license script in XHTML, see https://github.com/phetsims/chipper/issues/1413 (cherry picked from commit 4496294d711b1a97222fe2291edb01036c4fbddf) --- js/grunt/buildRunnable.js | 1 + js/grunt/packageXHTML.js | 5 ++++- templates/chipper-initialization.js | 3 --- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/js/grunt/buildRunnable.js b/js/grunt/buildRunnable.js index 32b9ab420..a3018404d 100644 --- a/js/grunt/buildRunnable.js +++ b/js/grunt/buildRunnable.js @@ -330,6 +330,7 @@ module.exports = async function( repo, minifyOptions, allHTML, brand, localesOpt stringMap: stringMap, htmlHeader: htmlHeader, initializationScript: xhtmlInitializationScript, + licenseScript: licenseScript, scripts: productionScripts } ); diff --git a/js/grunt/packageXHTML.js b/js/grunt/packageXHTML.js index 49aee8891..e460fce28 100644 --- a/js/grunt/packageXHTML.js +++ b/js/grunt/packageXHTML.js @@ -31,6 +31,7 @@ module.exports = function( xhtmlDir, config ) { brand, // {string} stringMap, // {Object}, map[ locale ][ stringKey ] => {string} initializationScript, // {string} - separate from the rest of the scripts since it needs to be able to run in IE. + licenseScript, // {string} scripts, // {Array.} htmlHeader // {string} } = config; @@ -41,6 +42,7 @@ module.exports = function( xhtmlDir, config ) { const localizedTitle = stringMap[ ChipperConstants.FALLBACK_LOCALE ][ getTitleStringKey( repo ) ]; + const licenseScriptFilename = `${repo}_license_${brand}.js`; const initializationScriptFilename = `${repo}_initialization_${brand}.js`; const script = scripts.join( '\n' ); @@ -49,10 +51,11 @@ module.exports = function( xhtmlDir, config ) { const xhtml = ChipperStringUtils.replacePlaceholders( grunt.file.read( '../chipper/templates/sim.xhtml' ), { PHET_SIM_TITLE: encoder.htmlEncode( localizedTitle ), PHET_HTML_HEADER: htmlHeader, - PHET_INITIALIZATION_SCRIPT: ``, + PHET_INITIALIZATION_SCRIPT: ``, PHET_SIM_SCRIPTS: `` } ); grunt.file.write( `${xhtmlDir}/${repo}_all${brand === 'phet' ? '' : `_${brand}`}.xhtml`, xhtml ); + grunt.file.write( `${xhtmlDir}/${licenseScriptFilename}`, licenseScript ); grunt.file.write( `${xhtmlDir}/${initializationScriptFilename}`, initializationScript ); grunt.file.write( `${xhtmlDir}/${scriptFilename}`, script ); }; diff --git a/templates/chipper-initialization.js b/templates/chipper-initialization.js index ce550a61f..ecfee0da0 100644 --- a/templates/chipper-initialization.js +++ b/templates/chipper-initialization.js @@ -1,6 +1,3 @@ -window.phet = window.phet|| {}; -window.phet.chipper = window.phet.chipper || {}; - window.phet.chipper.project = '{{PHET_PROJECT}}'; window.phet.chipper.version = '{{PHET_VERSION}}'; window.phet.chipper.buildTimestamp = '{{PHET_BUILD_TIMESTAMP}}';