package chat JS in lichess.round.min.js

pull/3375/head
Thibault Duplessis 2017-07-29 01:27:35 +02:00
parent 3f701b8f0e
commit d15ac6c11c
7 changed files with 34 additions and 21 deletions

View File

@ -49,6 +49,9 @@ trait AssetHelper { self: I18nHelper =>
s"""<script src="${staticUrl("javascripts/vendor/jquery.min.js")}"></script>"""
}
def roundTag(withChat: Boolean)(implicit ctx: Context) =
jsAt(s"compiled/lichess.round${(withChat && isProd) ?? (".chat")}${isProd ?? (".min")}.js", async = true)
val highchartsTag = cdnOrLocal(
cdn = "//code.highcharts.com/4.1.4/highcharts.js",
test = "window.Highcharts",

View File

@ -5,7 +5,7 @@
@title = @{ s"${trans.play.txt()} ${playerText(pov.opponent)} in $gameId" }
@moreJs = {
@jsAt(s"compiled/lichess.round${isProd??(".min")}.js", async = true)
@roundTag(withChat = chatOption.isDefined)
@embedJs {
window.customWS = true;
window.onload = function() {

View File

@ -3,7 +3,7 @@
@title = @{ s"${gameVsText(pov.game, withRatings = true)} in ${pov.gameId}" }
@moreJs = {
@jsAt(s"compiled/lichess.round${isProd??(".min")}.js", async = true)
@roundTag(withChat = true)
@embedJs {
window.customWS = true;
window.onload = function() {

View File

@ -3,7 +3,7 @@
@title = @{ s"${channel.name} TV: ${playerText(pov.player)} vs ${playerText(pov.opponent)}" }
@moreJs = {
@jsAt(s"compiled/lichess.round${isProd??(".min")}.js", async = true)
@roundTag(withChat = false)
@embedJs {
window.onload = function() {
LichessRound.boot({

View File

@ -13,15 +13,15 @@ function onError(error) {
gutil.log(gutil.colors.red(error.message));
}
function build(debug) {
return browserify('src/main.ts', {
standalone: 'LichessRound',
debug: debug
})
function build(debug, withChat) {
return browserify('src/' + (withChat ? 'withChat' : 'main') + '.ts', {
standalone: 'LichessRound',
debug: debug
})
.plugin(tsify);
}
const watchedBrowserify = watchify(build());
const watchedBrowserify = watchify(build(true, false));
function bundle() {
return watchedBrowserify
@ -32,22 +32,31 @@ function bundle() {
.pipe(gulp.dest(destination));
}
gulp.task('default', bundle);
watchedBrowserify.on('update', bundle);
watchedBrowserify.on('log', gutil.log);
gulp.task('dev', function() {
return build(true)
function dev(withChat) {
return () => build(true, withChat)
.bundle()
.pipe(source('lichess.round.js'))
.pipe(source('lichess.round' + (withChat ? '.chat' : '') + '.js'))
.pipe(gulp.dest(destination));
});
};
gulp.task('dev-alone', dev(false));
gulp.task('dev-chat', dev(true));
gulp.task('prod', function() {
return build(true)
function prod(withChat) {
return () => build(false, withChat)
.bundle()
.pipe(source('lichess.round.min.js'))
.pipe(source('lichess.round' + (withChat ? '.chat' : '') + '.min.js'))
.pipe(buffer())
.pipe(uglify())
.pipe(gulp.dest(destination));
});
}
gulp.task('prod-alone', prod(false));
gulp.task('prod-chat', prod(true));
gulp.task('prod', ['prod-alone', 'prod-chat']);
gulp.task('dev', ['dev-alone', 'dev-chat']);
gulp.task('default', bundle);

View File

@ -13,8 +13,6 @@ import MoveOn from './moveOn';
import { main as view } from './view/main';
import boot from './boot';
import * as chat from 'chat';
const patch = init([klass, attributes]);
export interface RoundApi {
@ -47,7 +45,6 @@ export function app(opts: RoundOpts): RoundApi {
};
export { boot };
window.LichessChat = chat;
// that's for the rest of lichess to access chessground
// without having to include it a second time

View File

@ -0,0 +1,4 @@
import * as chat from 'chat';
export { app, boot } from './main';
window.LichessChat = chat;