mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-23 22:13:34 +00:00
makeStaticLoader: Update fake standalone init module
* Don't add ext.visualEditor.base to it, and strip of ve-mw stuff ** .base doesn't contain ve-mw stuff any more, so no stripping needed ** Instead of appending .base, just load .base and create a separate fake module for Standalone init. * Don't manually register .sa files ** Instead use ext.visualEditor.standalone, it's right there. ** Add missing CSS file to .standalone. * Documented the purpose of 'Dependencies' and removed scripts from that fake module that don't fall under that rationale and instead add them as regular modules (rangy, unicodejs). * Removed weird 'jquery' dependency in 'ext.visualEditor.core' module. This is strongly recommended against, and might actually cause jQuery to be reloaded due to outstanding bugs in core with the state machine in the startup queue (jquery, mediawiki). * Unlist unused 'jquery.client' dependency in makeStaticLoader. As per the module definitions in VisualEditor.php, this is only used by the .mediawiki module. Grepped modules/ve/ and found 0 uses. * Update dependency order to roughly match the dependency tree as it is specified in ResourceLoader (e.g. rangy is for .core, not .base). * Keep fake modules out of ResourceLoader. Change-Id: I2a31543e5ad2fc39f5980fea855172108eda4428
This commit is contained in:
parent
1d9c82d7f5
commit
4c98f753a0
|
@ -261,6 +261,9 @@ $wgResourceModules += array(
|
|||
've/init/sa/ve.init.sa.Platform.js',
|
||||
've/init/sa/ve.init.sa.Target.js',
|
||||
),
|
||||
'styles' => array(
|
||||
've/init/sa/styles/ve.init.sa.css'
|
||||
),
|
||||
'dependencies' => array(
|
||||
'ext.visualEditor.base',
|
||||
),
|
||||
|
@ -532,7 +535,6 @@ $wgResourceModules += array(
|
|||
've-mw/ui/styles/ve.ui.MWDialog.css',
|
||||
),
|
||||
'dependencies' => array(
|
||||
'jquery',
|
||||
'rangy',
|
||||
'unicodejs.wordbreak',
|
||||
'ext.visualEditor.base',
|
||||
|
|
|
@ -27,8 +27,9 @@ $html = file_get_contents( $page );
|
|||
<!-- Generated by maintenance/makeStaticLoader.php -->
|
||||
<!-- oojs-ui -->
|
||||
<link rel=stylesheet href="../../modules/oojs-ui/oojs-ui.svg.css">
|
||||
<!-- ext.visualEditor.base#standalone-init -->
|
||||
<!-- ext.visualEditor.standalone -->
|
||||
<link rel=stylesheet href="../../modules/ve/init/sa/styles/ve.init.sa.css">
|
||||
<!-- Standalone init -->
|
||||
<script>
|
||||
if (
|
||||
document.createElementNS &&
|
||||
|
@ -80,30 +81,31 @@ $html = file_get_contents( $page );
|
|||
<div class="ve-demo-editor"></div>
|
||||
|
||||
<!-- Generated by maintenance/makeStaticLoader.php -->
|
||||
<!-- Dependencies -->
|
||||
<!-- jquery -->
|
||||
<script src="../../modules/jquery/jquery.js"></script>
|
||||
<script src="../../modules/jquery/jquery.client.js"></script>
|
||||
<!-- oojs -->
|
||||
<script src="../../modules/oojs/oojs.js"></script>
|
||||
<script src="../../modules/rangy/rangy-core-1.3.js"></script>
|
||||
<script src="../../modules/rangy/rangy-position-1.3.js"></script>
|
||||
<!-- oojs-ui -->
|
||||
<script src="../../modules/oojs-ui/oojs-ui.js"></script>
|
||||
<!-- unicodejs.wordbreak -->
|
||||
<script src="../../modules/unicodejs/unicodejs.js"></script>
|
||||
<script src="../../modules/unicodejs/unicodejs.textstring.js"></script>
|
||||
<script src="../../modules/unicodejs/unicodejs.graphemebreakproperties.js"></script>
|
||||
<script src="../../modules/unicodejs/unicodejs.graphemebreak.js"></script>
|
||||
<script src="../../modules/unicodejs/unicodejs.wordbreakproperties.js"></script>
|
||||
<script src="../../modules/unicodejs/unicodejs.wordbreak.js"></script>
|
||||
<!-- oojs-ui -->
|
||||
<script src="../../modules/oojs-ui/oojs-ui.js"></script>
|
||||
<!-- ext.visualEditor.base#standalone-init -->
|
||||
<!-- ext.visualEditor.base -->
|
||||
<script src="../../modules/ve/ve.js"></script>
|
||||
<script src="../../modules/ve/ve.track.js"></script>
|
||||
<script src="../../modules/ve/init/ve.init.js"></script>
|
||||
<script src="../../modules/ve/init/ve.init.Platform.js"></script>
|
||||
<script src="../../modules/ve/init/ve.init.Target.js"></script>
|
||||
<script src="../../modules/ve/ve.debug.js"></script>
|
||||
<!-- ext.visualEditor.standalone -->
|
||||
<script src="../../modules/ve/init/sa/ve.init.sa.js"></script>
|
||||
<script src="../../modules/ve/init/sa/ve.init.sa.Platform.js"></script>
|
||||
<script src="../../modules/ve/init/sa/ve.init.sa.Target.js"></script>
|
||||
<script src="../../modules/ve/ve.debug.js"></script>
|
||||
<!-- Standalone init -->
|
||||
<script>
|
||||
<?php
|
||||
require '../../modules/../VisualEditor.i18n.php';
|
||||
|
@ -111,6 +113,10 @@ $html = file_get_contents( $page );
|
|||
?>
|
||||
ve.init.platform.setModulesUrl( '../../modules' );
|
||||
</script>
|
||||
<!-- rangy -->
|
||||
<script src="../../modules/rangy/rangy-core-1.3.js"></script>
|
||||
<script src="../../modules/rangy/rangy-position-1.3.js"></script>
|
||||
<script src="../../modules/rangy/rangy-export.js"></script>
|
||||
<!-- ext.visualEditor.core -->
|
||||
<script src="../../modules/ve/ve.Range.js"></script>
|
||||
<script src="../../modules/ve/ve.Node.js"></script>
|
||||
|
|
|
@ -80,34 +80,68 @@ class MakeStaticLoader extends Maintenance {
|
|||
'../..'
|
||||
);
|
||||
|
||||
$wgResourceModules['Dependencies'] = array(
|
||||
'scripts' => array(
|
||||
'jquery/jquery.js',
|
||||
'jquery/jquery.client.js',
|
||||
'oojs/oojs.js',
|
||||
'rangy/rangy-core-1.3.js',
|
||||
'rangy/rangy-position-1.3.js',
|
||||
'unicodejs/unicodejs.js',
|
||||
'unicodejs/unicodejs.textstring.js',
|
||||
'unicodejs/unicodejs.graphemebreakproperties.js',
|
||||
'unicodejs/unicodejs.graphemebreak.js',
|
||||
'unicodejs/unicodejs.wordbreakproperties.js',
|
||||
'unicodejs/unicodejs.wordbreak.js',
|
||||
),
|
||||
);
|
||||
|
||||
// If we're running this script from STDIN,
|
||||
// hardcode the full path
|
||||
$i18nScript = $this->getOption( 'fixdir' ) ?
|
||||
dirname( __DIR__ ) . '/VisualEditor.i18n.php' :
|
||||
$vePath . '/../VisualEditor.i18n.php';
|
||||
|
||||
// Customized version to init standalone instead of mediawiki platform.
|
||||
$wgResourceModules['ext.visualEditor.base#standalone-init'] = array(
|
||||
'styles' => array(
|
||||
've/init/sa/styles/ve.init.sa.css',
|
||||
$self = isset( $_SERVER['PHP_SELF'] ) ? $_SERVER['PHP_SELF'] : ( lcfirst( __CLASS__ ) . '.php' );
|
||||
|
||||
$fakeModules = array(
|
||||
// These are dependencies that exist in MediaWiki core (such as jquery.js), but we
|
||||
// can't reference those modules as there is no reliable url to access them from
|
||||
// standalone. This must also include dependencies like oojs and jquery.uls which
|
||||
// are only registered by VisualEditor if they aren't registered by MediaWiki).
|
||||
'jquery' => array(
|
||||
'scripts' => array(
|
||||
'jquery/jquery.js',
|
||||
),
|
||||
),
|
||||
'headAdd' => '<script>
|
||||
'jquery.client' => array(
|
||||
'scripts' => array(
|
||||
'jquery/jquery.client.js',
|
||||
),
|
||||
),
|
||||
'oojs' => array(
|
||||
'scripts' => array(
|
||||
'oojs/oojs.js',
|
||||
),
|
||||
),
|
||||
'oojs-ui' => array(
|
||||
'scripts' => array(
|
||||
'oojs-ui/oojs-ui.js',
|
||||
),
|
||||
'styles' => array(
|
||||
'oojs-ui/oojs-ui.svg.css',
|
||||
),
|
||||
),
|
||||
'jquery.uls.grid' => array(
|
||||
'styles' => 'jquery.uls/css/jquery.uls.grid.css',
|
||||
),
|
||||
'jquery.uls.data' => array(
|
||||
'scripts' => array(
|
||||
'jquery.uls/src/jquery.uls.data.js',
|
||||
'jquery.uls/src/jquery.uls.data.utils.js',
|
||||
)
|
||||
),
|
||||
'jquery.uls.compact' => array(
|
||||
'styles' => 'jquery.uls/css/jquery.uls.compact.css',
|
||||
),
|
||||
'jquery.uls' => array(
|
||||
'scripts' => array(
|
||||
'jquery.uls/src/jquery.uls.core.js',
|
||||
'jquery.uls/src/jquery.uls.lcd.js',
|
||||
'jquery.uls/src/jquery.uls.languagefilter.js',
|
||||
'jquery.uls/src/jquery.uls.regionfilter.js',
|
||||
),
|
||||
'styles' => array(
|
||||
'jquery.uls/css/jquery.uls.css',
|
||||
'jquery.uls/css/jquery.uls.lcd.css',
|
||||
),
|
||||
),
|
||||
'Standalone init' => array(
|
||||
'headAdd' => '<script>
|
||||
if (
|
||||
document.createElementNS &&
|
||||
document.createElementNS( \'http://www.w3.org/2000/svg\', \'svg\' ).createSVGRect
|
||||
|
@ -123,32 +157,29 @@ class MakeStaticLoader extends Maintenance {
|
|||
);
|
||||
}
|
||||
</script>',
|
||||
'bodyAdd' => '<script>
|
||||
'bodyAdd' => '<script>
|
||||
<?php
|
||||
require ' . var_export( $i18nScript, true ) . ';
|
||||
echo \'ve.init.platform.addMessages( \' . json_encode( $messages[\'en\'] ) . " );\n";
|
||||
?>
|
||||
ve.init.platform.setModulesUrl( \'' . $vePath . '\' );
|
||||
</script>'
|
||||
) + $wgResourceModules['ext.visualEditor.base'];
|
||||
$baseScripts = &$wgResourceModules['ext.visualEditor.base#standalone-init']['scripts'];
|
||||
$baseScripts = array_filter( $baseScripts, function ( $script ) {
|
||||
return strpos( $script, 've/init/mw/ve.init.mw' ) === false;
|
||||
} );
|
||||
$baseScripts = array_merge( $baseScripts, array(
|
||||
've/init/sa/ve.init.sa.js',
|
||||
've/init/sa/ve.init.sa.Platform.js',
|
||||
've/init/sa/ve.init.sa.Target.js',
|
||||
) );
|
||||
|
||||
$self = isset( $_SERVER['PHP_SELF'] ) ? $_SERVER['PHP_SELF'] : ( lcfirst( __CLASS__ ) . '.php' );
|
||||
|
||||
$head = $body = '';
|
||||
),
|
||||
);
|
||||
|
||||
$modules = array(
|
||||
'Dependencies',
|
||||
// Dependencies for ext.visualEditor.base:
|
||||
'jquery',
|
||||
'oojs',
|
||||
'oojs-ui',
|
||||
'ext.visualEditor.base#standalone-init',
|
||||
'unicodejs.wordbreak',
|
||||
// Dependencies for ext.visualEditor.standalone:
|
||||
'ext.visualEditor.base',
|
||||
'ext.visualEditor.standalone',
|
||||
'Standalone init',
|
||||
// Dependencies for ext.visualEditor.core:
|
||||
'rangy',
|
||||
// Dependencies for ext.visualEditor.language
|
||||
'ext.visualEditor.core',
|
||||
'jquery.uls.grid',
|
||||
'jquery.uls.data',
|
||||
|
@ -157,15 +188,23 @@ class MakeStaticLoader extends Maintenance {
|
|||
'ext.visualEditor.language',
|
||||
);
|
||||
|
||||
$head = $body = '';
|
||||
|
||||
$resourceLoader = new ResourceLoader();
|
||||
|
||||
foreach ( $modules as $module ) {
|
||||
$moduleObj = $resourceLoader->getModule( $module );
|
||||
if ( !$moduleObj ) {
|
||||
echo "\nError: Module $module\n not found!\n";
|
||||
exit( 1 );
|
||||
if ( isset( $fakeModules[ $module ] ) ) {
|
||||
$registry = $fakeModules[ $module ];
|
||||
} else {
|
||||
$moduleObj = $resourceLoader->getModule( $module );
|
||||
if ( !$moduleObj ) {
|
||||
echo "\nError: Module $module\n not found!\n";
|
||||
exit( 1 );
|
||||
}
|
||||
$registry = isset( $wgResourceModules[$module] ) ?
|
||||
$wgResourceModules[$module] :
|
||||
$moduleObj->getDefinitionSummary( ResourceLoaderContext::newDummyContext() );
|
||||
}
|
||||
$registry = isset( $wgResourceModules[$module] ) ? $wgResourceModules[$module] :
|
||||
$moduleObj->getDefinitionSummary( ResourceLoaderContext::newDummyContext() );
|
||||
|
||||
$headAdd = $bodyAdd = '';
|
||||
|
||||
|
@ -180,6 +219,7 @@ class MakeStaticLoader extends Maintenance {
|
|||
) ) . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $registry['scripts'] ) ) {
|
||||
foreach ( (array)$registry['scripts'] as $path ) {
|
||||
if ( strpos( $path, 've-mw/' ) === 0 ) {
|
||||
|
@ -188,6 +228,7 @@ class MakeStaticLoader extends Maintenance {
|
|||
$bodyAdd .= $indent . Html::element( 'script', array( 'src' => "$vePath/$path" ) ) . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $registry['debugScripts'] ) ) {
|
||||
foreach ( (array)$registry['debugScripts'] as $path ) {
|
||||
if ( strpos( $path, 've-mw/' ) === 0 ) {
|
||||
|
@ -196,9 +237,11 @@ class MakeStaticLoader extends Maintenance {
|
|||
$bodyAdd .= $indent . Html::element( 'script', array( 'src' => "$vePath/$path" ) ) . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $registry['headAdd'] ) ) {
|
||||
$headAdd .= $indent . implode( "\n$indent", explode( "\n", $registry['headAdd'] ) ) . "\n";
|
||||
}
|
||||
|
||||
if ( isset( $registry['bodyAdd'] ) ) {
|
||||
$bodyAdd .= $indent . implode( "\n$indent", explode( "\n", $registry['bodyAdd'] ) ) . "\n";
|
||||
}
|
||||
|
@ -206,6 +249,7 @@ class MakeStaticLoader extends Maintenance {
|
|||
if ( $headAdd ) {
|
||||
$head .= "$indent<!-- $module -->\n$headAdd";
|
||||
}
|
||||
|
||||
if ( $bodyAdd ) {
|
||||
$body .= "$indent<!-- $module -->\n$bodyAdd";
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<script src="../../qunit/qunit.js"></script>
|
||||
|
||||
<!-- Generated by maintenance/makeStaticLoader.php -->
|
||||
<!-- ext.visualEditor.base#standalone-init -->
|
||||
<!-- Standalone init -->
|
||||
<script>
|
||||
if (
|
||||
document.createElementNS &&
|
||||
|
@ -33,30 +33,31 @@
|
|||
</head>
|
||||
<body>
|
||||
<!-- Generated by maintenance/makeStaticLoader.php -->
|
||||
<!-- Dependencies -->
|
||||
<!-- jquery -->
|
||||
<script src="../../jquery/jquery.js"></script>
|
||||
<script src="../../jquery/jquery.client.js"></script>
|
||||
<!-- oojs -->
|
||||
<script src="../../oojs/oojs.js"></script>
|
||||
<script src="../../rangy/rangy-core-1.3.js"></script>
|
||||
<script src="../../rangy/rangy-position-1.3.js"></script>
|
||||
<!-- oojs-ui -->
|
||||
<script src="../../oojs-ui/oojs-ui.js"></script>
|
||||
<!-- unicodejs.wordbreak -->
|
||||
<script src="../../unicodejs/unicodejs.js"></script>
|
||||
<script src="../../unicodejs/unicodejs.textstring.js"></script>
|
||||
<script src="../../unicodejs/unicodejs.graphemebreakproperties.js"></script>
|
||||
<script src="../../unicodejs/unicodejs.graphemebreak.js"></script>
|
||||
<script src="../../unicodejs/unicodejs.wordbreakproperties.js"></script>
|
||||
<script src="../../unicodejs/unicodejs.wordbreak.js"></script>
|
||||
<!-- oojs-ui -->
|
||||
<script src="../../oojs-ui/oojs-ui.js"></script>
|
||||
<!-- ext.visualEditor.base#standalone-init -->
|
||||
<!-- ext.visualEditor.base -->
|
||||
<script src="../../ve/ve.js"></script>
|
||||
<script src="../../ve/ve.track.js"></script>
|
||||
<script src="../../ve/init/ve.init.js"></script>
|
||||
<script src="../../ve/init/ve.init.Platform.js"></script>
|
||||
<script src="../../ve/init/ve.init.Target.js"></script>
|
||||
<script src="../../ve/ve.debug.js"></script>
|
||||
<!-- ext.visualEditor.standalone -->
|
||||
<script src="../../ve/init/sa/ve.init.sa.js"></script>
|
||||
<script src="../../ve/init/sa/ve.init.sa.Platform.js"></script>
|
||||
<script src="../../ve/init/sa/ve.init.sa.Target.js"></script>
|
||||
<script src="../../ve/ve.debug.js"></script>
|
||||
<!-- Standalone init -->
|
||||
<script>
|
||||
<?php
|
||||
require '../../../VisualEditor.i18n.php';
|
||||
|
@ -64,6 +65,10 @@
|
|||
?>
|
||||
ve.init.platform.setModulesUrl( '../..' );
|
||||
</script>
|
||||
<!-- rangy -->
|
||||
<script src="../../rangy/rangy-core-1.3.js"></script>
|
||||
<script src="../../rangy/rangy-position-1.3.js"></script>
|
||||
<script src="../../rangy/rangy-export.js"></script>
|
||||
<!-- ext.visualEditor.core -->
|
||||
<script src="../../ve/ve.Range.js"></script>
|
||||
<script src="../../ve/ve.Node.js"></script>
|
||||
|
|
Loading…
Reference in a new issue