diff --git a/CHANGELOG.md b/CHANGELOG.md index 7dbd7797e..0a166aa44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,18 @@ ChangeLog (Release Notes) ========================= 主に notable な changes を書いていきます +3230 (2017/11/28) +----------------- +* :v: + +3219 (2017/11/28) +----------------- +* なんか + +3212 (2017/11/27) +----------------- +* なんか + 3201 (2017/11/23) ----------------- * Twitterログインを実装 (#939) diff --git a/package.json b/package.json index 7d302279e..3031f896b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "misskey", "author": "syuilo ", - "version": "0.0.3201", + "version": "0.0.3230", "license": "MIT", "description": "A miniblog-based SNS", "bugs": "https://github.com/syuilo/misskey/issues", @@ -26,14 +26,14 @@ "@prezzemolo/zip": "0.0.3", "@types/bcryptjs": "2.4.1", "@types/body-parser": "1.16.8", - "@types/chai": "4.0.5", + "@types/chai": "4.0.6", "@types/chai-http": "3.0.3", "@types/compression": "0.0.35", "@types/cookie": "0.3.1", "@types/cors": "2.8.3", "@types/debug": "0.0.30", "@types/deep-equal": "1.0.1", - "@types/elasticsearch": "5.0.17", + "@types/elasticsearch": "5.0.18", "@types/event-stream": "3.3.33", "@types/eventemitter3": "2.0.2", "@types/express": "4.0.39", @@ -48,9 +48,9 @@ "@types/inquirer": "0.0.35", "@types/is-root": "1.0.0", "@types/is-url": "1.2.28", - "@types/js-yaml": "3.10.0", + "@types/js-yaml": "3.10.1", "@types/mocha": "2.2.44", - "@types/mongodb": "2.2.15", + "@types/mongodb": "2.2.16", "@types/monk": "1.0.6", "@types/morgan": "1.7.35", "@types/ms": "0.7.30", @@ -60,7 +60,7 @@ "@types/proxy-addr": "2.0.0", "@types/ratelimiter": "2.1.28", "@types/redis": "2.8.1", - "@types/request": "2.0.7", + "@types/request": "2.0.8", "@types/rimraf": "2.0.2", "@types/riot": "3.6.1", "@types/seedrandom": "2.4.27", @@ -69,7 +69,7 @@ "@types/uuid": "3.4.3", "@types/webpack": "3.8.1", "@types/webpack-stream": "3.2.8", - "@types/websocket": "0.0.34", + "@types/websocket": "0.0.35", "accesses": "2.5.0", "animejs": "2.2.0", "autwh": "0.0.1", @@ -92,7 +92,7 @@ "elasticsearch": "14.0.0", "escape-regexp": "0.0.1", "event-stream": "3.3.4", - "eventemitter3": "2.0.3", + "eventemitter3": "3.0.0", "express": "4.16.2", "file-type": "7.3.0", "fuckadblock": "3.2.1", @@ -113,7 +113,7 @@ "is-root": "1.0.0", "is-url": "1.2.2", "js-yaml": "3.10.0", - "mecab-async": "0.1.0", + "mecab-async": "0.1.2", "mocha": "4.0.1", "moji": "0.5.1", "mongodb": "2.2.33", @@ -153,8 +153,8 @@ "tmp": "0.0.33", "ts-node": "3.3.0", "tslint": "5.8.0", - "typescript": "2.6.1", - "uglify-es": "3.1.10", + "typescript": "2.6.2", + "uglify-es": "3.2.0", "uglifyjs-webpack-plugin": "1.1.1", "uuid": "3.1.0", "vhost": "3.0.2", diff --git a/src/api/endpoints/meta.ts b/src/api/endpoints/meta.ts index e27ca39e7..1370ead3c 100644 --- a/src/api/endpoints/meta.ts +++ b/src/api/endpoints/meta.ts @@ -45,7 +45,7 @@ module.exports = (params) => new Promise(async (res, rej) => { res({ maintainer: config.maintainer, version: version, - secure: config.https.enable, + secure: config.https != null, machine: os.hostname(), os: os.platform(), node: process.version, diff --git a/src/web/app/boot.js b/src/web/app/boot.js index 4a8ea030a..0a3154ad8 100644 --- a/src/web/app/boot.js +++ b/src/web/app/boot.js @@ -69,4 +69,38 @@ script.setAttribute('async', 'true'); script.setAttribute('defer', 'true'); head.appendChild(script); + + // 1秒経ってもスクリプトがロードされない場合はバージョンが古くて + // 404になっているせいかもしれないので、バージョンを確認して古ければ更新する + // + // 読み込まれたスクリプトからこのタイマーを解除できるように、 + // グローバルにタイマーIDを代入しておく + window.mkBootTimer = window.setTimeout(async () => { + // Fetch meta + const res = await fetch(API + '/meta', { + method: 'POST', + cache: 'no-cache' + }); + + // Parse + const meta = await res.json(); + + // Compare versions + if (meta.version != VERSION) { + alert( + 'Misskeyの新しいバージョンがあります。ページを再度読み込みします。' + + '\n\n' + + 'New version of Misskey available. The page will be reloaded.'); + + // Clear cache (serive worker) + try { + navigator.serviceWorker.controller.postMessage('clear'); + } catch (e) { + console.error(e); + } + + // Force reload + location.reload(true); + } + }, 1000); } diff --git a/src/web/app/common/scripts/api.ts b/src/web/app/common/scripts/api.ts index e62447b0a..2008e6f5a 100644 --- a/src/web/app/common/scripts/api.ts +++ b/src/web/app/common/scripts/api.ts @@ -29,7 +29,8 @@ export default (i, endpoint, data = {}): Promise<{ [x: string]: any }> => { fetch(endpoint.indexOf('://') > -1 ? endpoint : `${_API_URL_}/${endpoint}`, { method: 'POST', body: JSON.stringify(data), - credentials: endpoint === 'signin' ? 'include' : 'omit' + credentials: endpoint === 'signin' ? 'include' : 'omit', + cache: 'no-cache' }).then(res => { if (--pending === 0) spinner.parentNode.removeChild(spinner); if (res.status === 200) { diff --git a/src/web/app/common/scripts/check-for-update.ts b/src/web/app/common/scripts/check-for-update.ts index c447a517f..154092451 100644 --- a/src/web/app/common/scripts/check-for-update.ts +++ b/src/web/app/common/scripts/check-for-update.ts @@ -7,6 +7,14 @@ export default async function(mios: MiOS) { if (meta.version != _VERSION_) { localStorage.setItem('should-refresh', 'true'); + + // Clear cache (serive worker) + try { + navigator.serviceWorker.controller.postMessage('clear'); + } catch (e) { + console.error(e); + } + alert('%i18n:common.update-available%'.replace('{newer}', meta.version).replace('{current}', _VERSION_)); } } diff --git a/src/web/app/desktop/tags/home-widgets/rss-reader.tag b/src/web/app/desktop/tags/home-widgets/rss-reader.tag index fe04ee0e2..12c1bee91 100644 --- a/src/web/app/desktop/tags/home-widgets/rss-reader.tag +++ b/src/web/app/desktop/tags/home-widgets/rss-reader.tag @@ -86,7 +86,9 @@ }); this.fetch = () => { - fetch(`https://api.rss2json.com/v1/api.json?rss_url=${this.url}`).then(res => { + fetch(`https://api.rss2json.com/v1/api.json?rss_url=${this.url}`, { + cache: 'no-cache' + }).then(res => { res.json().then(feed => { this.update({ initializing: false, diff --git a/src/web/app/init.ts b/src/web/app/init.ts index 79be1d368..154b1ba0f 100644 --- a/src/web/app/init.ts +++ b/src/web/app/init.ts @@ -19,6 +19,10 @@ require('./common/tags'); console.info(`Misskey v${_VERSION_} (葵 aoi)`); +// BootTimer解除 +window.clearTimeout((window as any).mkBootTimer); +delete (window as any).mkBootTimer; + if (_HOST_ != 'localhost') { document.domain = _HOST_; } diff --git a/src/web/app/sw.js b/src/web/app/sw.js index a7c84d022..669703b16 100644 --- a/src/web/app/sw.js +++ b/src/web/app/sw.js @@ -4,9 +4,41 @@ import composeNotification from './common/scripts/compose-notification'; +// キャッシュするリソース +const cachee = [ + '/' +]; + // インストールされたとき -self.addEventListener('install', () => { +self.addEventListener('install', ev => { console.info('installed'); + + ev.waitUntil(Promise.all([ + self.skipWaiting(), // Force activate + caches.open(_VERSION_).then(cache => cache.addAll(cachee)) // Cache + ])); +}); + +// アクティベートされたとき +self.addEventListener('activate', ev => { + // Clean up old caches + ev.waitUntil( + caches.keys().then(keys => Promise.all( + keys + .filter(key => key != _VERSION_) + .map(key => caches.delete(key)) + )) + ); +}); + +// リクエストが発生したとき +self.addEventListener('fetch', ev => { + ev.respondWith( + // キャッシュがあるか確認してあればそれを返す + caches.match(ev.request).then(response => + response || fetch(ev.request) + ) + ); }); // プッシュ通知を受け取ったとき @@ -31,3 +63,9 @@ self.addEventListener('push', ev => { }); })); }); + +self.addEventListener('message', ev => { + if (ev.data == 'clear') { + caches.keys().then(keys => keys.forEach(key => caches.delete(key))); + } +}); diff --git a/src/web/assets/404.js b/src/web/assets/404.js new file mode 100644 index 000000000..46fd004f1 --- /dev/null +++ b/src/web/assets/404.js @@ -0,0 +1,15 @@ +const yn = window.confirm( + 'サーバー上に存在しないスクリプトがリクエストされました。お使いのMisskeyのバージョンが古いことが原因の可能性があります。Misskeyを更新しますか?'); + +if (yn) { + // Clear cache (serive worker) + try { + navigator.serviceWorker.controller.postMessage('clear'); + } catch (e) { + console.error(e); + } + + location.reload(true); +} else { + alert('問題が解決しない場合はサーバー管理者までお問い合せください。'); +} diff --git a/src/web/assets/recover.html b/src/web/assets/recover.html new file mode 100644 index 000000000..019f57b2e --- /dev/null +++ b/src/web/assets/recover.html @@ -0,0 +1,34 @@ + + + + + + Misskeyのリカバリ + + + diff --git a/src/web/server.ts b/src/web/server.ts index d8a471329..1d3687f89 100644 --- a/src/web/server.ts +++ b/src/web/server.ts @@ -39,6 +39,12 @@ app.get('/apple-touch-icon.png', (req, res) => res.sendFile(`${__dirname}/assets app.use('/assets', express.static(`${__dirname}/assets`, { maxAge: ms('7 days') })); +app.use('/assets/*.js', (req, res) => res.sendFile(`${__dirname}/assets/404.js`)); +app.use('/assets', (req, res) => { + res.sendStatus(404); +}); + +app.use('/recover', (req, res) => res.sendFile(`${__dirname}/assets/recover.html`)); /** * ServiceWroker diff --git a/webpack/plugins/index.ts b/webpack/plugins/index.ts index 3d1416d1e..9850db485 100644 --- a/webpack/plugins/index.ts +++ b/webpack/plugins/index.ts @@ -2,7 +2,7 @@ const StringReplacePlugin = require('string-replace-webpack-plugin'); import consts from './consts'; import hoist from './hoist'; -//import minify from './minify'; +import minify from './minify'; import banner from './banner'; const env = process.env.NODE_ENV; @@ -16,7 +16,7 @@ export default (version, lang) => { ]; if (isProduction) { - //plugins.push(minify()); + plugins.push(minify()); } plugins.push(banner(version));