uniform js module naming

refactor-site-js
Thibault Duplessis 2020-09-03 14:45:24 +02:00
parent 29a013afbb
commit 899b10c46b
31 changed files with 48 additions and 52 deletions

View File

@ -52,7 +52,7 @@ trait AssetHelper { self: I18nHelper with SecurityHelper =>
)
def jsModule(name: String, defer: Boolean = false): Frag =
jsAt(s"compiled/lichess.$name${minifiedAssets ?? ".min"}.js", defer = defer)
jsAt(s"compiled/$name${minifiedAssets ?? ".min"}.js", defer = defer)
lazy val jQueryTag = raw {
s"""<script src="${staticUrl("javascripts/vendor/jquery.min.js")}"></script>"""

View File

@ -24,13 +24,13 @@ object freeJs {
"palantir",
"puzzle",
"round",
"serviceWorker",
"service-worker",
"simul",
"site",
"speech",
"tournamentCalendar",
"tournament.calendar",
"tournament",
"tournamentSchedule",
"tournament.schedule",
"swiss"
)
@ -52,7 +52,7 @@ object freeJs {
),
tbody(
uiModules map { module =>
val file = s"lichess.$module.min.js"
val file = s"$module.min.js"
tr(
td(a(href := assetUrl(s"compiled/$file"))(file)),
td(agpl),

View File

@ -13,7 +13,7 @@ object calendar {
views.html.base.layout(
title = "Tournament calendar",
moreJs = frag(
jsModule("tournamentCalendar"),
jsModule("tournament.calendar"),
embedJsUnsafe(
s"""LichessTournamentCalendar.app(document.getElementById('tournament-calendar'), ${safeJsonValue(
Json.obj(

View File

@ -24,7 +24,7 @@ object home {
wrapClass = "full-screen-force",
moreJs = frag(
infiniteScrollTag,
jsModule("tournamentSchedule"),
jsModule("tournament.schedule"),
embedJsUnsafe(
s"""var app=LichessTournamentSchedule.app(document.querySelector('.tour-chart'), ${safeJsonValue(
Json.obj(

View File

@ -4,10 +4,10 @@ export default rollupProject({
main: {
name: 'LichessAnalyse',
input: 'src/main.ts',
output: 'lichess.analyse',
output: 'analyse',
},
nvui: {
input: 'src/plugins/nvui.ts',
output: 'lichess.analyse.nvui',
output: 'analyse.nvui',
},
});

View File

@ -4,6 +4,6 @@ export default rollupProject({
main: {
name: 'LichessChallenge',
input: 'src/main.ts',
output: 'lichess.challenge',
output: 'challenge',
},
});

View File

@ -4,6 +4,6 @@ export default rollupProject({
main: {
name: 'LichessChat',
input: 'src/main.ts',
output: 'lichess.chat',
output: 'chat',
},
});

View File

@ -4,6 +4,6 @@ export default rollupProject({
main: {
name: 'LichessCli',
input: 'src/main.ts',
output: 'lichess.cli',
output: 'cli',
},
});

View File

@ -4,6 +4,6 @@ export default rollupProject({
main: {
name: 'LichessDasher',
input: 'src/main.ts',
output: 'lichess.dasher',
output: 'dasher',
},
});

View File

@ -4,6 +4,6 @@ export default rollupProject({
main: {
name: 'LichessEditor',
input: 'src/main.ts',
output: 'lichess.editor',
output: 'editor',
},
});

View File

@ -4,7 +4,7 @@ export default rollupProject({
main: {
name: 'LichessInsight',
input: 'src/main.js',
output: 'lichess.insight',
output: 'insight',
js: true,
},
});

View File

@ -4,7 +4,7 @@ export default rollupProject({
main: {
name: 'LichessLearn',
input: 'src/main.js',
output: 'lichess.learn',
output: 'learn',
js: true,
},
});

View File

@ -4,6 +4,6 @@ export default rollupProject({
main: {
name: 'LichessLobby',
input: 'src/main.ts',
output: 'lichess.lobby',
output: 'lobby',
},
});

View File

@ -4,6 +4,6 @@ export default rollupProject({
main: {
name: 'LichessMsg',
input: 'src/main.ts',
output: 'lichess.msg',
output: 'msg',
},
});

View File

@ -4,6 +4,6 @@ export default rollupProject({
main: {
name: 'LichessNotify',
input: 'src/main.ts',
output: 'lichess.notify',
output: 'notify',
},
});

View File

@ -4,6 +4,6 @@ export default rollupProject({
main: {
name: 'Palantir',
input: 'src/main.ts',
output: 'lichess.palantir',
output: 'palantir',
},
});

View File

@ -4,6 +4,6 @@ export default rollupProject({
main: {
name: 'LichessPuzzle',
input: 'src/main.ts',
output: 'lichess.puzzle',
output: 'puzzle',
},
});

View File

@ -4,16 +4,16 @@ export default rollupProject({
main: {
name: 'LichessRound',
input: 'src/main.ts',
output: 'lichess.round',
output: 'round',
},
keyboardMove: {
name: 'KeyboardMove',
input: 'src/plugins/keyboardMove.ts',
output: 'lichess.round.keyboardMove',
output: 'round.keyboard-move',
},
nvui: {
name: 'NVUI',
input: 'src/plugins/nvui.ts',
output: 'lichess.round.nvui',
output: 'round.nvui',
},
});

View File

@ -114,10 +114,10 @@ export function render(ctrl: KeyboardMove) {
spellcheck: false,
autocomplete: false
},
hook: onInsert(el => {
window.lichess.loadScript(window.lichess.jsModule('round.keyboardMove')).then(() => {
hook: onInsert(input => {
window.lichess.loadScript(window.lichess.jsModule('round.keyboard-move')).then(() => {
ctrl.registerHandler(window.lichess.keyboardMove({
input: el,
input,
ctrl
}));
});

View File

@ -3,6 +3,6 @@ import { rollupProject } from '@build/rollupProject';
export default rollupProject({
main: {
input: 'src/main.ts',
output: 'lichess.serviceWorker',
output: 'service-worker',
},
});

View File

@ -4,6 +4,6 @@ export default rollupProject({
main: {
name: 'LichessSimul',
input: 'src/main.ts',
output: 'lichess.simul',
output: 'simul',
},
});

View File

@ -21,7 +21,7 @@
"tablesort": "^5.1"
},
"scripts": {
"deps": "cat ../../public/javascripts/vendor/jquery.min.js ./dep/powertip.min.js ./dep/howler.min.js ./dep/mousetrap.min.js > ../../public/compiled/lichess.deps.js",
"deps": "cat ../../public/javascripts/vendor/jquery.min.js ./dep/powertip.min.js ./dep/howler.min.js ./dep/mousetrap.min.js > ../../public/compiled/deps.js",
"dev": "yarn run deps && rollup --config",
"prod": "yarn run deps && rollup --config --config-prod"
}

View File

@ -7,7 +7,7 @@ import replace from '@rollup/plugin-replace';
export default rollupProject({
main: {
input: 'src/site.ts',
output: 'lichess.site',
output: 'site',
plugins: [
copy({
targets: [
@ -78,38 +78,38 @@ export default rollupProject({
},
tvEmbed: {
input: 'src/tv-embed.ts',
output: 'lichess.tv.embed',
output: 'tv.embed',
},
puzzleEmbed: {
input: 'src/puzzle-embed.ts',
output: 'lichess.puzzle.embed',
output: 'puzzle.embed',
},
analyseEmbed: {
input: 'src/analyse-embed.ts',
output: 'lichess.analyse.embed',
output: 'analyse.embed',
},
user: {
input: 'src/user.ts',
output: 'lichess.user',
output: 'user',
},
modUser: {
input: 'src/mod-user.ts',
output: 'lichess.mod.user',
output: 'mod.user',
},
clas: {
input: 'src/clas.ts',
output: 'lichess.clas',
output: 'clas',
},
coordinate: {
input: 'src/coordinate.ts',
output: 'lichess.coordinate',
output: 'coordinate',
},
captcha: {
input: 'src/captcha.ts',
output: 'lichess.captcha',
output: 'captcha',
},
expandText: {
input: 'src/expand-text.ts',
output: 'lichess.expand-text',
output: 'expand-text',
},
});

View File

@ -22,7 +22,7 @@ export const loadCssPath = (key: string) =>
loadCss(`css/${key}.${$('body').data('theme')}.${$('body').data('dev') ? 'dev' : 'min'}.css`);
export const jsModule = (name: string) =>
`compiled/lichess.${name}${$('body').data('dev') ? '' : '.min'}.js`;
`compiled/${name}${$('body').data('dev') ? '' : '.min'}.js`;
export const loadScript = (url: string, opts: AssetUrlOpts = {}) =>
$.ajax({

View File

@ -3,7 +3,7 @@ import {storage} from "./storage";
export default function() {
if ('serviceWorker' in navigator && 'Notification' in window && 'PushManager' in window) {
const workerUrl = new URL(assetUrl(jsModule('serviceWorker'), {
const workerUrl = new URL(assetUrl(jsModule('service-worker'), {
sameDomain: true
}), self.location.href);
workerUrl.searchParams.set('asset-url', document.body.getAttribute('data-asset-url')!);

View File

@ -4,6 +4,6 @@ export default rollupProject({
main: {
name: 'LichessSpeech',
input: 'src/main.ts',
output: 'lichess.speech',
output: 'speech',
},
});

View File

@ -4,6 +4,6 @@ export default rollupProject({
main: {
name: 'LichessSwiss',
input: 'src/main.ts',
output: 'lichess.swiss',
output: 'swiss',
},
});

View File

@ -4,6 +4,6 @@ export default rollupProject({
main: {
name: 'LichessTournament',
input: 'src/main.ts',
output: 'lichess.tournament',
output: 'tournament',
},
});

View File

@ -1,9 +1,10 @@
import { rollupProject } from '@build/rollupProject';
export default rollupProject({
main: {
name: 'LichessTournamentCalendar',
input: 'src/main.ts',
output: 'lichess.tournamentCalendar',
output: 'tournament.calendar',
},
});

View File

@ -4,6 +4,6 @@ export default rollupProject({
main: {
name: 'LichessTournamentSchedule',
input: 'src/main.ts',
output: 'lichess.tournamentSchedule',
output: 'tournament.schedule',
},
});

View File

@ -4414,11 +4414,6 @@ types-serviceworker@^0.0.1:
resolved "https://registry.yarnpkg.com/types-serviceworker/-/types-serviceworker-0.0.1.tgz#3d356e176d3b987d2164b34e609c591e67d31f1c"
integrity sha512-EKO/SZ3AsHEZsqv+bsdlTCz5k955riOksnYGlG6JhVwNTVsPWj/TScTbiNVZ5+mmX8TcEXF0C8aSxUw0jTDpIw==
typescript@^3:
version "3.9.7"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.7.tgz#98d600a5ebdc38f40cb277522f12dc800e9e25fa"
integrity sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==
typescript@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.2.tgz#7ea7c88777c723c681e33bf7988be5d008d05ac2"