Skip to content

Commit

Permalink
fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
wangchou committed Jun 16, 2019
1 parent 88815fa commit 46b6625
Show file tree
Hide file tree
Showing 7 changed files with 179 additions and 171 deletions.
32 changes: 16 additions & 16 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import svelte from 'rollup-plugin-svelte';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import livereload from 'rollup-plugin-livereload';
import { terser } from 'rollup-plugin-terser';
import fs from 'fs';
import svelte from 'rollup-plugin-svelte'
import resolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'
import livereload from 'rollup-plugin-livereload'
import { terser } from 'rollup-plugin-terser'
import fs from 'fs'

const production = !process.env.ROLLUP_WATCH;
const production = !process.env.ROLLUP_WATCH

export default {
input: 'src/client/index.js',
output: {
sourcemap: true,
format: 'iife',
name: 'app',
file: 'public/bundle.js'
file: 'public/bundle.js',
},
plugins: [
svelte({
Expand All @@ -22,8 +22,8 @@ export default {
// we'll extract any component CSS out into
// a separate file — better for performance
css: css => {
css.write('public/bundle.css');
}
css.write('public/bundle.css')
},
}),

// If you have external dependencies installed from
Expand All @@ -40,16 +40,16 @@ export default {
watch: 'public',
https: {
key: fs.readFileSync('localhost.key'),
cert: fs.readFileSync('localhost.crt')
}
cert: fs.readFileSync('localhost.crt'),
},
}),

// If we're building for production (npm run build
// instead of npm run dev), minify
production && terser()
production && terser(),
],
watch: {
clearScreen: false,
include: 'src/client/**'
}
};
include: 'src/client/**',
},
}
36 changes: 18 additions & 18 deletions src/client/App.svelte
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
<script>
import Messenger from "./Messenger.svelte";
import Messenger from './Messenger.svelte'
</script>

<style>
h1 {
color: green;
margin: 0px auto;
text-align: center;
}
:global(body) {
margin: 4% 0;
background: #999;
}
h1 {
color: green;
margin: 0px auto;
text-align: center;
}
:global(body) {
margin: 4% 0;
background: #999;
}
</style>

<div>
<h1>
<ruby>
<rb>回音</rb>
<rt>echo</rt>
<rb>森林</rb>
<rt>mori</rt>
</ruby>
</h1>
<h1>
<ruby>
<rb>回音</rb>
<rt>echo</rt>
<rb>森林</rb>
<rt>mori</rt>
</ruby>
</h1>
</div>
<Messenger />
219 changes: 109 additions & 110 deletions src/client/Messenger.svelte
Original file line number Diff line number Diff line change
@@ -1,118 +1,117 @@
<script>
import { onMount, beforeUpdate, afterUpdate } from "svelte";
let div;
let autoscroll;
beforeUpdate(() => {
autoscroll =
div && div.offsetHeight + div.scrollTop > div.scrollHeight - 20;
});
afterUpdate(() => {
if (autoscroll) div.scrollTo(0, div.scrollHeight);
});
onMount(()=> {
let sentence = sentences[0]
say(sentence.text, sentence.speed, sentence.voice)
})
let PlaySpeed = {
normal: "normal",
slow: "slow",
verySlow: "verySlow"
};
let Voices = {
jaF1: "jaF1",
jaF2: "jaF2",
jaM1: "jaM1",
jaM2: "jaM2"
};
let sentences = [
{ text: "こんにちは、ともさん", speed: PlaySpeed.slow, voice: Voices.jaM1 },
{ text: "今日はいい天気ですね", speed: PlaySpeed.slow, voice: Voices.jaF1 },
{ text: "そうですね。", speed: PlaySpeed.slow, voice: Voices.jaM1 },
{ text: "じゃあ、またね。", speed: PlaySpeed.slow, voice: Voices.jaF1 }
];
let comments = [
{ author: "teacher", text: sentences[0].text },
{ author: "student", text: sentences[1].text },
{ author: "teacher", text: sentences[2].text },
{ author: "student", text: sentences[3].text }
];
function getMS() {
return new Date().getTime();
}
async function say(text, speed, voice) {
var startMS = getMS();
var response = await fetch(
`/tts?text=${text}&speed=${speed}&voice=${voice}`
).then(res => res.text());
const audio = new Audio("data:audio/wav;base64," + response);
let promise = new Promise(function(resolve, reject) {
audio.onended = () => {
resolve(getMS() - startMS);
};
});
audio.play();
return promise;
}
import { onMount, beforeUpdate, afterUpdate } from 'svelte'
let div
let autoscroll
beforeUpdate(() => {
autoscroll = div && div.offsetHeight + div.scrollTop > div.scrollHeight - 20
})
afterUpdate(() => {
if (autoscroll) div.scrollTo(0, div.scrollHeight)
})
onMount(() => {
let sentence = sentences[0]
say(sentence.text, sentence.speed, sentence.voice)
})
let PlaySpeed = {
normal: 'normal',
slow: 'slow',
verySlow: 'verySlow',
}
let Voices = {
jaF1: 'jaF1',
jaF2: 'jaF2',
jaM1: 'jaM1',
jaM2: 'jaM2',
}
let sentences = [
{ text: 'こんにちは、ともさん', speed: PlaySpeed.slow, voice: Voices.jaM1 },
{ text: '今日はいい天気ですね', speed: PlaySpeed.slow, voice: Voices.jaF1 },
{ text: 'そうですね。', speed: PlaySpeed.slow, voice: Voices.jaM1 },
{ text: 'じゃあ、またね。', speed: PlaySpeed.slow, voice: Voices.jaF1 },
]
let comments = [
{ author: 'teacher', text: sentences[0].text },
{ author: 'student', text: sentences[1].text },
{ author: 'teacher', text: sentences[2].text },
{ author: 'student', text: sentences[3].text },
]
function getMS() {
return new Date().getTime()
}
async function say(text, speed, voice) {
var startMS = getMS()
var response = await fetch(`/tts?text=${text}&speed=${speed}&voice=${voice}`).then(res =>
res.text(),
)
const audio = new Audio('data:audio/wav;base64,' + response)
let promise = new Promise(function(resolve, reject) {
audio.onended = () => {
resolve(getMS() - startMS)
}
})
audio.play()
return promise
}
</script>

<style>
.chat {
display: flex;
flex-direction: column;
height: 400px;
max-width: 240px;
border: 1px solid #eee;
margin: 0px auto;
}
.scrollable {
flex: 1 1 auto;
margin: 0 0.5em;
overflow-y: auto;
}
article {
margin: 0.5em 0;
}
.student {
text-align: right;
}
span {
padding: 0.5em 1em;
display: inline-block;
}
.teacher span {
background-color: #eee;
border-radius: 1em 1em 1em 0;
}
.student span {
background-color: #0074d9;
color: white;
border-radius: 1em 1em 0 1em;
}
.chat {
display: flex;
flex-direction: column;
height: 400px;
max-width: 240px;
border: 1px solid #eee;
margin: 0px auto;
}
.scrollable {
flex: 1 1 auto;
margin: 0 0.5em;
overflow-y: auto;
}
article {
margin: 0.5em 0;
}
.student {
text-align: right;
}
span {
padding: 0.5em 1em;
display: inline-block;
}
.teacher span {
background-color: #eee;
border-radius: 1em 1em 1em 0;
}
.student span {
background-color: #0074d9;
color: white;
border-radius: 1em 1em 0 1em;
}
</style>

<div class="chat">
<div class="scrollable" bind:this={div}>
{#each comments as comment}
<article class={comment.author}>
<span>{comment.text}</span>
</article>
{/each}
</div>
<div class="scrollable" bind:this={div}>
{#each comments as comment}
<article class={comment.author}>
<span>{comment.text}</span>
</article>
{/each}
</div>
</div>
6 changes: 3 additions & 3 deletions src/client/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import App from './App.svelte';
import App from './App.svelte'

const app = new App({
target: document.body,
});
})

export default app;
export default app
6 changes: 3 additions & 3 deletions src/server/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ app.get('/tts', ttsAPI);

var port = 4000
https.createServer({
key: fs.readFileSync('localhost.key'),
cert: fs.readFileSync('localhost.crt')
key: fs.readFileSync('localhost.key'),
cert: fs.readFileSync('localhost.crt')
}, app).listen(port, function () {
console.log(`Express Server listening on port ${port}!`)
console.log(`Express Server listening on port ${port}!`)
});
Loading

0 comments on commit 46b6625

Please sign in to comment.