なんかもうめっちゃ変えた

This commit is contained in:
syuilo 2017-11-13 18:05:35 +09:00
parent f8dddc81e2
commit bc9a8283c6
77 changed files with 170 additions and 165 deletions

View File

@ -52,6 +52,9 @@
"@types/ms": "0.7.30", "@types/ms": "0.7.30",
"@types/multer": "1.3.5", "@types/multer": "1.3.5",
"@types/node": "8.0.49", "@types/node": "8.0.49",
"@types/page": "1.5.32",
"@types/proxy-addr": "2.0.0",
"@types/seedrandom": "2.4.27",
"@types/ratelimiter": "2.1.28", "@types/ratelimiter": "2.1.28",
"@types/redis": "2.8.1", "@types/redis": "2.8.1",
"@types/request": "2.0.7", "@types/request": "2.0.7",
@ -92,8 +95,8 @@
"webpack": "3.8.1" "webpack": "3.8.1"
}, },
"dependencies": { "dependencies": {
"@prezzemolo/zip": "0.0.3",
"@prezzemolo/rap": "0.1.2", "@prezzemolo/rap": "0.1.2",
"@prezzemolo/zip": "0.0.3",
"accesses": "2.5.0", "accesses": "2.5.0",
"animejs": "2.2.0", "animejs": "2.2.0",
"autwh": "0.0.1", "autwh": "0.0.1",
@ -131,6 +134,7 @@
"page": "1.7.1", "page": "1.7.1",
"pictograph": "2.0.4", "pictograph": "2.0.4",
"prominence": "0.2.0", "prominence": "0.2.0",
"proxy-addr": "^2.0.2",
"pug": "2.0.0-rc.4", "pug": "2.0.0-rc.4",
"ratelimiter": "3.0.3", "ratelimiter": "3.0.3",
"recaptcha-promise": "0.1.3", "recaptcha-promise": "0.1.3",
@ -141,6 +145,7 @@
"riot": "3.7.4", "riot": "3.7.4",
"rndstr": "1.0.0", "rndstr": "1.0.0",
"s-age": "1.1.0", "s-age": "1.1.0",
"seedrandom": "^2.4.3",
"serve-favicon": "2.4.5", "serve-favicon": "2.4.5",
"sortablejs": "1.7.0", "sortablejs": "1.7.0",
"summaly": "2.0.3", "summaly": "2.0.3",

View File

@ -1,5 +1,5 @@
import * as riot from 'riot'; import * as riot from 'riot';
const route = require('page'); import * as route from 'page';
let page = null; let page = null;
export default me => { export default me => {
@ -22,7 +22,7 @@ export default me => {
} }
// EXEC // EXEC
route(); (route as any)();
}; };
function mount(content) { function mount(content) {

View File

@ -343,7 +343,7 @@
}; };
this.changeFile = () => { this.changeFile = () => {
this.refs.file.files.forEach(this.upload); Array.from(this.refs.file.files).forEach(this.upload);
}; };
this.selectFile = () => { this.selectFile = () => {
@ -367,7 +367,7 @@
}; };
this.onpaste = e => { this.onpaste = e => {
e.clipboardData.items.forEach(item => { Array.from(e.clipboardData.items).forEach(item => {
if (item.kind == 'file') { if (item.kind == 'file') {
this.upload(item.getAsFile()); this.upload(item.getAsFile());
} }

View File

@ -2,7 +2,7 @@ import * as riot from 'riot';
import api from '../scripts/api'; import api from '../scripts/api';
export default me => { export default me => {
riot.mixin('api', { (riot as any).mixin('api', {
api: api.bind(null, me ? me.token : null) api: api.bind(null, me ? me.token : null)
}); });
}; };

View File

@ -1,7 +1,7 @@
import * as riot from 'riot'; import * as riot from 'riot';
export default me => { export default me => {
riot.mixin('i', { (riot as any).mixin('i', {
init: function() { init: function() {
this.I = me; this.I = me;
this.SIGNIN = me != null; this.SIGNIN = me != null;

View File

@ -1,13 +0,0 @@
import * as riot from 'riot';
import activateMe from './i';
import activateApi from './api';
export default (me, stream, serverStreamManager) => {
activateMe(me);
activateApi(me);
riot.mixin('stream', { stream });
riot.mixin('server-stream', { serverStream: serverStreamManager });
};

View File

@ -0,0 +1,14 @@
import * as riot from 'riot';
import activateMe from './i';
import activateApi from './api';
import ServerStreamManager from '../scripts/server-stream-manager';
export default (me, stream) => {
activateMe(me);
activateApi(me);
(riot as any).mixin('stream', { stream });
(riot as any).mixin('server-stream', { serverStream: new ServerStreamManager() });
};

View File

@ -14,7 +14,7 @@ let pending = 0;
* @param {any} [data={}] Data * @param {any} [data={}] Data
* @return {Promise<any>} Response * @return {Promise<any>} Response
*/ */
export default (i, endpoint, data = {}) => { export default (i, endpoint, data = {}): Promise<any> => {
if (++pending === 1) { if (++pending === 1) {
spinner = document.createElement('div'); spinner = document.createElement('div');
spinner.setAttribute('id', 'wait'); spinner.setAttribute('id', 'wait');
@ -22,7 +22,7 @@ export default (i, endpoint, data = {}) => {
} }
// Append the credential // Append the credential
if (i != null) data.i = typeof i === 'object' ? i.token : i; if (i != null) (data as any).i = typeof i === 'object' ? i.token : i;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
// Send request // Send request

View File

@ -1,6 +1,6 @@
export default (bytes, digits = 0) => { export default (bytes, digits = 0) => {
var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']; const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
if (bytes == 0) return '0Byte'; if (bytes == 0) return '0Byte';
var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024))); const i = Math.floor(Math.log(bytes) / Math.log(1024));
return (bytes / Math.pow(1024, i)).toFixed(digits).replace(/\.0+$/, '') + sizes[i]; return (bytes / Math.pow(1024, i)).toFixed(digits).replace(/\.0+$/, '') + sizes[i];
}; };

View File

@ -1,5 +1,7 @@
import CONFIG from './config'; import CONFIG from './config';
declare var VERSION: string;
export default function() { export default function() {
fetch(CONFIG.apiUrl + '/meta', { fetch(CONFIG.apiUrl + '/meta', {
method: 'POST' method: 'POST'
@ -11,4 +13,4 @@ export default function() {
} }
}); });
}); });
}; }

View File

@ -1,5 +1,5 @@
export default () => [ export default () => [
'(=^・・^=)', '(=^・・^=)',
'v(‘ω’)v', 'v(‘ω’)v',
'🐡( '-' 🐡 )フグパンチ!!!!' '🐡( \'-\' 🐡 )フグパンチ!!!!'
][Math.floor(Math.random() * 3)]; ][Math.floor(Math.random() * 3)];

View File

@ -17,9 +17,9 @@ class Connection extends Stream {
this.send({ type: 'alive' }); this.send({ type: 'alive' });
}, 1000 * 60); }, 1000 * 60);
this.on('i_updated', me.update); (this as any).on('i_updated', me.update);
this.on('my_token_regenerated', () => { (this as any).on('my_token_regenerated', () => {
alert('%i18n:common.my-token-regenerated%'); alert('%i18n:common.my-token-regenerated%');
signout(); signout();
}); });

View File

@ -12,7 +12,7 @@ class Connection extends Stream {
otherparty otherparty
}); });
this.on('_connected_', () => { (this as any).on('_connected_', () => {
this.send({ this.send({
i: me.token i: me.token
}); });

View File

@ -1,14 +1,7 @@
import StreamManager from './stream-manager';
import Connection from './server-stream'; import Connection from './server-stream';
import * as uuid from 'uuid';
export default class ServerStreamManager {
private connection = null;
/**
*
*/
private users = [];
export default class ServerStreamManager extends StreamManager<Connection> {
public getConnection() { public getConnection() {
if (this.connection == null) { if (this.connection == null) {
this.connection = new Connection(); this.connection = new Connection();
@ -16,24 +9,4 @@ export default class ServerStreamManager {
return this.connection; return this.connection;
} }
public use() {
// ユーザーID生成
const userId = uuid();
this.users.push(userId);
return userId;
}
public dispose(userId) {
this.users = this.users.filter(id => id != userId);
// 誰もコネクションの利用者がいなくなったら
if (this.users.length == 0) {
// コネクションを切断する
this.connection.close();
this.connection = null;
}
}
} }

View File

@ -0,0 +1,33 @@
import * as uuid from 'uuid';
import Connection from './stream';
export default abstract class StreamManager<T extends Connection> {
protected connection: T = null;
/**
*
*/
private users = [];
public abstract getConnection(): T;
public use() {
// ユーザーID生成
const userId = uuid();
this.users.push(userId);
return userId;
}
public dispose(userId) {
this.users = this.users.filter(id => id != userId);
// 誰もコネクションの利用者がいなくなったら
if (this.users.length == 0) {
// コネクションを切断する
this.connection.close();
this.connection = null;
}
}
}

View File

@ -8,7 +8,11 @@ import CONFIG from './config';
* Misskey stream connection * Misskey stream connection
*/ */
class Connection { class Connection {
constructor(endpoint, params) { private state: string;
private buffer: any[];
private socket: ReconnectingWebsocket;
constructor(endpoint, params?) {
// BIND ----------------------------------- // BIND -----------------------------------
this.onOpen = this.onOpen.bind(this); this.onOpen = this.onOpen.bind(this);
this.onClose = this.onClose.bind(this); this.onClose = this.onClose.bind(this);
@ -37,11 +41,10 @@ class Connection {
/** /**
* Callback of when open connection * Callback of when open connection
* @private
*/ */
onOpen() { private onOpen() {
this.state = 'connected'; this.state = 'connected';
this.trigger('_connected_'); (this as any).trigger('_connected_');
// バッファーを処理 // バッファーを処理
const _buffer = [].concat(this.buffer); // Shallow copy const _buffer = [].concat(this.buffer); // Shallow copy
@ -53,21 +56,19 @@ class Connection {
/** /**
* Callback of when close connection * Callback of when close connection
* @private
*/ */
onClose() { private onClose() {
this.state = 'reconnecting'; this.state = 'reconnecting';
this.trigger('_closed_'); (this as any).trigger('_closed_');
} }
/** /**
* Callback of when received a message from connection * Callback of when received a message from connection
* @private
*/ */
onMessage(message) { private onMessage(message) {
try { try {
const msg = JSON.parse(message.data); const msg = JSON.parse(message.data);
if (msg.type) this.trigger(msg.type, msg.body); if (msg.type) (this as any).trigger(msg.type, msg.body);
} catch (e) { } catch (e) {
// noop // noop
} }
@ -75,23 +76,21 @@ class Connection {
/** /**
* Send a message to connection * Send a message to connection
* @public
*/ */
send(message) { public send(message) {
// まだ接続が確立されていなかったらバッファリングして次に接続した時に送信する // まだ接続が確立されていなかったらバッファリングして次に接続した時に送信する
if (this.state != 'connected') { if (this.state != 'connected') {
this.buffer.push(message); this.buffer.push(message);
return; return;
}; }
this.socket.send(JSON.stringify(message)); this.socket.send(JSON.stringify(message));
} }
/** /**
* Close this connection * Close this connection
* @public
*/ */
close() { public close() {
this.socket.removeEventListener('open', this.onOpen); this.socket.removeEventListener('open', this.onOpen);
this.socket.removeEventListener('message', this.onMessage); this.socket.removeEventListener('message', this.onMessage);
} }

View File

@ -1,5 +1,5 @@
import * as riot from 'riot'; import * as riot from 'riot';
const pictograph = require('pictograph'); import * as pictograph from 'pictograph';
import CONFIG from './config'; import CONFIG from './config';
const escape = text => const escape = text =>
@ -12,7 +12,7 @@ export default (tokens, shouldBreak) => {
shouldBreak = true; shouldBreak = true;
} }
const me = riot.mixin('i').me; const me = (riot as any).mixin('i').me;
let text = tokens.map(token => { let text = tokens.map(token => {
switch (token.type) { switch (token.type) {

View File

@ -219,7 +219,7 @@
this.refs.text.innerHTML = compile(tokens); this.refs.text.innerHTML = compile(tokens);
this.refs.text.children.forEach(e => { Array.from(this.refs.text.children).forEach(e => {
if (e.tagName == 'MK-URL') riot.mount(e); if (e.tagName == 'MK-URL') riot.mount(e);
}); });

View File

@ -52,7 +52,7 @@ function attach(el) {
clearTimeout(showTimer); clearTimeout(showTimer);
hideTimer = setTimeout(close, 500); hideTimer = setTimeout(close, 500);
}); });
tag = riot.mount(document.body.appendChild(preview), { tag = (riot as any).mount(document.body.appendChild(preview), {
user: user user: user
})[0]; })[0];
}; };

View File

@ -3,7 +3,7 @@ import * as riot from 'riot';
// ミックスインにオプションを渡せないのアレ // ミックスインにオプションを渡せないのアレ
// SEE: https://github.com/riot/riot/issues/2434 // SEE: https://github.com/riot/riot/issues/2434
riot.mixin('widget', { (riot as any).mixin('widget', {
init: function() { init: function() {
this.mixin('i'); this.mixin('i');
this.mixin('api'); this.mixin('api');

View File

@ -3,7 +3,7 @@
*/ */
import * as riot from 'riot'; import * as riot from 'riot';
const route = require('page'); import * as route from 'page';
let page = null; let page = null;
export default me => { export default me => {
@ -83,12 +83,12 @@ export default me => {
mount(document.createElement('mk-not-found')); mount(document.createElement('mk-not-found'));
} }
riot.mixin('page', { (riot as any).mixin('page', {
page: route page: route
}); });
// EXEC // EXEC
route(); (route as any)();
}; };
function mount(content) { function mount(content) {

View File

@ -11,7 +11,7 @@ import * as riot from 'riot';
import init from '../init'; import init from '../init';
import route from './router'; import route from './router';
import fuckAdBlock from './scripts/fuck-ad-block'; import fuckAdBlock from './scripts/fuck-ad-block';
import getPostSummary from '../../../common/get-post-summary.ts'; import getPostSummary from '../../../common/get-post-summary';
/** /**
* init * init
@ -27,11 +27,11 @@ init(async (me, stream) => {
*/ */
if ('Notification' in window) { if ('Notification' in window) {
// 許可を得ていなかったらリクエスト // 許可を得ていなかったらリクエスト
if (Notification.permission == 'default') { if ((Notification as any).permission == 'default') {
await Notification.requestPermission(); await Notification.requestPermission();
} }
if (Notification.permission == 'granted') { if ((Notification as any).permission == 'granted') {
registerNotifications(stream); registerNotifications(stream);
} }
} }
@ -82,7 +82,7 @@ function registerNotifications(stream) {
}); });
n.onclick = () => { n.onclick = () => {
n.close(); n.close();
riot.mount(document.body.appendChild(document.createElement('mk-messaging-room-window')), { (riot as any).mount(document.body.appendChild(document.createElement('mk-messaging-room-window')), {
user: message.user user: message.user
}); });
}; };

View File

@ -1,10 +1,12 @@
const getCaretCoordinates = require('textarea-caret'); import getCaretCoordinates = require('textarea-caret');
import * as riot from 'riot'; import * as riot from 'riot';
/** /**
* *
*/ */
class Autocomplete { class Autocomplete {
private suggestion: any;
private textarea: any;
/** /**
* *
@ -23,22 +25,22 @@ class Autocomplete {
/** /**
* *
*/ */
attach() { public attach() {
this.textarea.addEventListener('input', this.onInput); this.textarea.addEventListener('input', this.onInput);
} }
/** /**
* *
*/ */
detach() { public detach() {
this.textarea.removeEventListener('input', this.onInput); this.textarea.removeEventListener('input', this.onInput);
this.close(); this.close();
} }
/** /**
* [Private] *
*/ */
onInput() { private onInput() {
this.close(); this.close();
const caret = this.textarea.selectionStart; const caret = this.textarea.selectionStart;
@ -56,9 +58,9 @@ class Autocomplete {
} }
/** /**
* [Private] *
*/ */
open(type, q) { private open(type, q) {
// 既に開いているサジェストは閉じる // 既に開いているサジェストは閉じる
this.close(); this.close();
@ -81,7 +83,7 @@ class Autocomplete {
const el = document.body.appendChild(tag); const el = document.body.appendChild(tag);
// マウント // マウント
this.suggestion = riot.mount(el, { this.suggestion = (riot as any).mount(el, {
textarea: this.textarea, textarea: this.textarea,
complete: this.complete, complete: this.complete,
close: this.close, close: this.close,
@ -91,9 +93,9 @@ class Autocomplete {
} }
/** /**
* [Private] *
*/ */
close() { private close() {
if (this.suggestion == null) return; if (this.suggestion == null) return;
this.suggestion.unmount(); this.suggestion.unmount();
@ -103,9 +105,9 @@ class Autocomplete {
} }
/** /**
* [Private] *
*/ */
complete(user) { private complete(user) {
this.close(); this.close();
const value = user.username; const value = user.username;

View File

@ -1,9 +1,9 @@
import * as riot from 'riot'; import * as riot from 'riot';
export default (title, text, buttons, canThrough, onThrough) => { export default (title, text, buttons, canThrough?, onThrough?) => {
const dialog = document.body.appendChild(document.createElement('mk-dialog')); const dialog = document.body.appendChild(document.createElement('mk-dialog'));
const controller = riot.observable(); const controller = riot.observable();
riot.mount(dialog, { (riot as any).mount(dialog, {
controller: controller, controller: controller,
title: title, title: title,
text: text, text: text,

View File

@ -1,6 +1,8 @@
require('fuckadblock'); require('fuckadblock');
import dialog from './dialog'; import dialog from './dialog';
declare var fuckAdBlock: any;
export default () => { export default () => {
if (fuckAdBlock === undefined) { if (fuckAdBlock === undefined) {
adBlockDetected(); adBlockDetected();

View File

@ -2,7 +2,7 @@ import * as riot from 'riot';
export default (title, placeholder, defaultValue, onOk, onCancel) => { export default (title, placeholder, defaultValue, onOk, onCancel) => {
const dialog = document.body.appendChild(document.createElement('mk-input-dialog')); const dialog = document.body.appendChild(document.createElement('mk-input-dialog'));
return riot.mount(dialog, { return (riot as any).mount(dialog, {
title: title, title: title,
placeholder: placeholder, placeholder: placeholder,
'default': defaultValue, 'default': defaultValue,

View File

@ -2,7 +2,7 @@ import * as riot from 'riot';
export default message => { export default message => {
const notification = document.body.appendChild(document.createElement('mk-ui-notification')); const notification = document.body.appendChild(document.createElement('mk-ui-notification'));
riot.mount(notification, { (riot as any).mount(notification, {
message: message message: message
}); });
}; };

View File

@ -2,7 +2,7 @@ import * as riot from 'riot';
export default (title, onOk, onCancel) => { export default (title, onOk, onCancel) => {
const dialog = document.body.appendChild(document.createElement('mk-input-dialog')); const dialog = document.body.appendChild(document.createElement('mk-input-dialog'));
return riot.mount(dialog, { return (riot as any).mount(dialog, {
title: title, title: title,
type: 'password', type: 'password',
onOk: onOk, onOk: onOk,

View File

@ -5,7 +5,7 @@ import api from '../../common/scripts/api';
export default (I, cb, file = null) => { export default (I, cb, file = null) => {
const fileSelected = file => { const fileSelected = file => {
const cropper = riot.mount(document.body.appendChild(document.createElement('mk-crop-window')), { const cropper = (riot as any).mount(document.body.appendChild(document.createElement('mk-crop-window')), {
file: file, file: file,
title: 'アバターとして表示する部分を選択', title: 'アバターとして表示する部分を選択',
aspectRatio: 1 / 1 aspectRatio: 1 / 1
@ -37,7 +37,7 @@ export default (I, cb, file = null) => {
}; };
const upload = (data, folder) => { const upload = (data, folder) => {
const progress = riot.mount(document.body.appendChild(document.createElement('mk-progress-dialog')), { const progress = (riot as any).mount(document.body.appendChild(document.createElement('mk-progress-dialog')), {
title: '新しいアバターをアップロードしています' title: '新しいアバターをアップロードしています'
})[0]; })[0];
@ -46,7 +46,7 @@ export default (I, cb, file = null) => {
const xhr = new XMLHttpRequest(); const xhr = new XMLHttpRequest();
xhr.open('POST', CONFIG.apiUrl + '/drive/files/create', true); xhr.open('POST', CONFIG.apiUrl + '/drive/files/create', true);
xhr.onload = e => { xhr.onload = e => {
const file = JSON.parse(e.target.response); const file = JSON.parse((e.target as any).response);
progress.close(); progress.close();
set(file); set(file);
}; };
@ -75,7 +75,7 @@ export default (I, cb, file = null) => {
if (file) { if (file) {
fileSelected(file); fileSelected(file);
} else { } else {
const browser = riot.mount(document.body.appendChild(document.createElement('mk-select-file-from-drive-window')), { const browser = (riot as any).mount(document.body.appendChild(document.createElement('mk-select-file-from-drive-window')), {
multiple: false, multiple: false,
title: '<i class="fa fa-picture-o"></i>アバターにする画像を選択' title: '<i class="fa fa-picture-o"></i>アバターにする画像を選択'
})[0]; })[0];

View File

@ -5,7 +5,7 @@ import api from '../../common/scripts/api';
export default (I, cb, file = null) => { export default (I, cb, file = null) => {
const fileSelected = file => { const fileSelected = file => {
const cropper = riot.mount(document.body.appendChild(document.createElement('mk-crop-window')), { const cropper = (riot as any).mount(document.body.appendChild(document.createElement('mk-crop-window')), {
file: file, file: file,
title: 'バナーとして表示する部分を選択', title: 'バナーとして表示する部分を選択',
aspectRatio: 16 / 9 aspectRatio: 16 / 9
@ -37,7 +37,7 @@ export default (I, cb, file = null) => {
}; };
const upload = (data, folder) => { const upload = (data, folder) => {
const progress = riot.mount(document.body.appendChild(document.createElement('mk-progress-dialog')), { const progress = (riot as any).mount(document.body.appendChild(document.createElement('mk-progress-dialog')), {
title: '新しいバナーをアップロードしています' title: '新しいバナーをアップロードしています'
})[0]; })[0];
@ -46,7 +46,7 @@ export default (I, cb, file = null) => {
const xhr = new XMLHttpRequest(); const xhr = new XMLHttpRequest();
xhr.open('POST', CONFIG.apiUrl + '/drive/files/create', true); xhr.open('POST', CONFIG.apiUrl + '/drive/files/create', true);
xhr.onload = e => { xhr.onload = e => {
const file = JSON.parse(e.target.response); const file = JSON.parse((e.target as any).response);
progress.close(); progress.close();
set(file); set(file);
}; };
@ -75,7 +75,7 @@ export default (I, cb, file = null) => {
if (file) { if (file) {
fileSelected(file); fileSelected(file);
} else { } else {
const browser = riot.mount(document.body.appendChild(document.createElement('mk-select-file-from-drive-window')), { const browser = (riot as any).mount(document.body.appendChild(document.createElement('mk-select-file-from-drive-window')), {
multiple: false, multiple: false,
title: '<i class="fa fa-picture-o"></i>バナーにする画像を選択' title: '<i class="fa fa-picture-o"></i>バナーにする画像を選択'
})[0]; })[0];

View File

@ -177,7 +177,7 @@
}; };
this.applySelect = () => { this.applySelect = () => {
this.refs.users.children.forEach(el => { Array.from(this.refs.users.children).forEach(el => {
el.removeAttribute('data-selected'); el.removeAttribute('data-selected');
}); });

View File

@ -408,7 +408,7 @@
// ドロップされてきたものがファイルだったら // ドロップされてきたものがファイルだったら
if (e.dataTransfer.files.length > 0) { if (e.dataTransfer.files.length > 0) {
e.dataTransfer.files.forEach(file => { Array.from(e.dataTransfer.files).forEach(file => {
this.upload(file, this.folder); this.upload(file, this.folder);
}); });
return false; return false;
@ -510,7 +510,7 @@
}; };
this.changeFileInput = () => { this.changeFileInput = () => {
this.refs.fileInput.files.forEach(file => { Array.from(this.refs.fileInput.files).forEach(file => {
this.upload(file, this.folder); this.upload(file, this.folder);
}); });
}; };

View File

@ -109,7 +109,7 @@
// ファイルだったら // ファイルだったら
if (e.dataTransfer.files.length > 0) { if (e.dataTransfer.files.length > 0) {
e.dataTransfer.files.forEach(file => { Array.from(e.dataTransfer.files).forEach(file => {
this.browser.upload(file, this.folder); this.browser.upload(file, this.folder);
}); });
return false; return false;

View File

@ -55,7 +55,7 @@
// ファイルだったら // ファイルだったら
if (e.dataTransfer.files.length > 0) { if (e.dataTransfer.files.length > 0) {
e.dataTransfer.files.forEach(file => { Array.from(e.dataTransfer.files).forEach(file => {
this.browser.upload(file, this.folder); this.browser.upload(file, this.folder);
}); });
return false; return false;

View File

@ -129,7 +129,7 @@
this.refs.text.innerHTML = compile(tokens); this.refs.text.innerHTML = compile(tokens);
this.refs.text.children.forEach(e => { Array.from(this.refs.text.children).forEach(e => {
if (e.tagName == 'MK-URL') riot.mount(e); if (e.tagName == 'MK-URL') riot.mount(e);
}); });
} }

View File

@ -273,7 +273,7 @@
this.refs.text.innerHTML = compile(tokens); this.refs.text.innerHTML = compile(tokens);
this.refs.text.children.forEach(e => { Array.from(this.refs.text.children).forEach(e => {
if (e.tagName == 'MK-URL') riot.mount(e); if (e.tagName == 'MK-URL') riot.mount(e);
}); });

View File

@ -405,7 +405,7 @@
// ファイルだったら // ファイルだったら
if (e.dataTransfer.files.length > 0) { if (e.dataTransfer.files.length > 0) {
e.dataTransfer.files.forEach(this.upload); Array.from(e.dataTransfer.files).forEach(this.upload);
} }
}; };
@ -414,7 +414,7 @@
}; };
this.onpaste = e => { this.onpaste = e => {
e.clipboardData.items.forEach(item => { Array.from(e.clipboardData.items).forEach(item => {
if (item.kind == 'file') { if (item.kind == 'file') {
this.upload(item.getAsFile()); this.upload(item.getAsFile());
} }
@ -435,7 +435,7 @@
}; };
this.changeFile = () => { this.changeFile = () => {
this.refs.file.files.forEach(this.upload); Array.from(this.refs.file.files).forEach(this.upload);
}; };
this.upload = file => { this.upload = file => {

View File

@ -45,7 +45,7 @@
const tokens = this.post.ast; const tokens = this.post.ast;
this.refs.text.innerHTML = compile(tokens, false); this.refs.text.innerHTML = compile(tokens, false);
this.refs.text.children.forEach(e => { Array.from(this.refs.text.children).forEach(e => {
if (e.tagName == 'MK-URL') riot.mount(e); if (e.tagName == 'MK-URL') riot.mount(e);
}); });
} }

View File

@ -498,7 +498,7 @@
this.refs.text.innerHTML = this.refs.text.innerHTML.replace('<p class="dummy"></p>', compile(tokens)); this.refs.text.innerHTML = this.refs.text.innerHTML.replace('<p class="dummy"></p>', compile(tokens));
this.refs.text.children.forEach(e => { Array.from(this.refs.text.children).forEach(e => {
if (e.tagName == 'MK-URL') riot.mount(e); if (e.tagName == 'MK-URL') riot.mount(e);
}); });

View File

@ -1,5 +1,5 @@
import * as riot from 'riot'; import * as riot from 'riot';
const route = require('page'); import * as route from 'page';
let page = null; let page = null;
export default me => { export default me => {
@ -32,7 +32,7 @@ export default me => {
} }
// EXEC // EXEC
route(); (route as any)();
}; };
function mount(content) { function mount(content) {

View File

@ -2,14 +2,13 @@
* App initializer * App initializer
*/ */
'use strict'; declare var VERSION: string;
declare var LANG: string;
import * as riot from 'riot'; import * as riot from 'riot';
import api from './common/scripts/api';
import signout from './common/scripts/signout'; import signout from './common/scripts/signout';
import checkForUpdate from './common/scripts/check-for-update'; import checkForUpdate from './common/scripts/check-for-update';
import Connection from './common/scripts/home-stream'; import Connection from './common/scripts/home-stream';
import ServerStreamManager from './common/scripts/server-stream-manager.ts';
import Progress from './common/scripts/loading'; import Progress from './common/scripts/loading';
import mixin from './common/mixins'; import mixin from './common/mixins';
import CONFIG from './common/scripts/config'; import CONFIG from './common/scripts/config';
@ -37,21 +36,7 @@ console.info(`Misskey v${VERSION} (葵 aoi)`);
document.domain = CONFIG.host; document.domain = CONFIG.host;
// Set global configuration // Set global configuration
riot.mixin({ CONFIG }); (riot as any).mixin({ CONFIG });
// ↓ NodeList、HTMLCollection、FileList、DataTransferItemListで forEach を使えるようにする
if (NodeList.prototype.forEach === undefined) {
NodeList.prototype.forEach = Array.prototype.forEach;
}
if (HTMLCollection.prototype.forEach === undefined) {
HTMLCollection.prototype.forEach = Array.prototype.forEach;
}
if (FileList.prototype.forEach === undefined) {
FileList.prototype.forEach = Array.prototype.forEach;
}
if (window.DataTransferItemList && DataTransferItemList.prototype.forEach === undefined) {
DataTransferItemList.prototype.forEach = Array.prototype.forEach;
}
// iOSでプライベートモードだとlocalStorageが使えないので既存のメソッドを上書きする // iOSでプライベートモードだとlocalStorageが使えないので既存のメソッドを上書きする
try { try {
@ -72,7 +57,7 @@ setTimeout(checkForUpdate, 3000);
// ユーザーをフェッチしてコールバックする // ユーザーをフェッチしてコールバックする
export default callback => { export default callback => {
// Get cached account data // Get cached account data
let cachedMe = JSON.parse(localStorage.getItem('me')); const cachedMe = JSON.parse(localStorage.getItem('me'));
if (cachedMe) { if (cachedMe) {
fetched(cachedMe); fetched(cachedMe);
@ -112,11 +97,8 @@ export default callback => {
// Init home stream connection // Init home stream connection
const stream = me ? new Connection(me) : null; const stream = me ? new Connection(me) : null;
// Init server stream connection manager
const serverStreamManager = new ServerStreamManager();
// ミックスイン初期化 // ミックスイン初期化
mixin(me, stream, serverStreamManager); mixin(me, stream);
// ローディング画面クリア // ローディング画面クリア
const ini = document.getElementById('ini'); const ini = document.getElementById('ini');

View File

@ -3,7 +3,7 @@
*/ */
import * as riot from 'riot'; import * as riot from 'riot';
const route = require('page'); import * as route from 'page';
let page = null; let page = null;
export default me => { export default me => {
@ -131,12 +131,12 @@ export default me => {
mount(document.createElement('mk-not-found')); mount(document.createElement('mk-not-found'));
} }
riot.mixin('page', { (riot as any).mixin('page', {
page: route page: route
}); });
// EXEC // EXEC
route(); (route as any)();
}; };
function mount(content) { function mount(content) {

View File

@ -561,7 +561,7 @@
}; };
this.changeLocalFile = () => { this.changeLocalFile = () => {
this.refs.file.files.forEach(f => this.refs.uploader.upload(f, this.folder)); Array.from(this.refs.file.files).forEach(f => this.refs.uploader.upload(f, this.folder));
}; };
</script> </script>
</mk-drive> </mk-drive>

View File

@ -285,7 +285,7 @@
this.refs.text.innerHTML = compile(tokens); this.refs.text.innerHTML = compile(tokens);
this.refs.text.children.forEach(e => { Array.from(this.refs.text.children).forEach(e => {
if (e.tagName == 'MK-URL') riot.mount(e); if (e.tagName == 'MK-URL') riot.mount(e);
}); });

View File

@ -207,7 +207,7 @@
}; };
this.onpaste = e => { this.onpaste = e => {
e.clipboardData.items.forEach(item => { Array.from(e.clipboardData.items).forEach(item => {
if (item.kind == 'file') { if (item.kind == 'file') {
this.upload(item.getAsFile()); this.upload(item.getAsFile());
} }
@ -228,7 +228,7 @@
}; };
this.changeFile = () => { this.changeFile = () => {
this.refs.file.files.forEach(this.upload); Array.from(this.refs.file.files).forEach(this.upload);
}; };
this.upload = file => { this.upload = file => {

View File

@ -37,7 +37,7 @@
const tokens = this.post.ast; const tokens = this.post.ast;
this.refs.text.innerHTML = compile(tokens, false); this.refs.text.innerHTML = compile(tokens, false);
this.refs.text.children.forEach(e => { Array.from(this.refs.text.children).forEach(e => {
if (e.tagName == 'MK-URL') riot.mount(e); if (e.tagName == 'MK-URL') riot.mount(e);
}); });
} }

View File

@ -538,7 +538,7 @@
this.refs.text.innerHTML = this.refs.text.innerHTML.replace('<p class="dummy"></p>', compile(tokens)); this.refs.text.innerHTML = this.refs.text.innerHTML.replace('<p class="dummy"></p>', compile(tokens));
this.refs.text.children.forEach(e => { Array.from(this.refs.text.children).forEach(e => {
if (e.tagName == 'MK-URL') riot.mount(e); if (e.tagName == 'MK-URL') riot.mount(e);
}); });

View File

@ -13,6 +13,7 @@
"object-literal-sort-keys": false, "object-literal-sort-keys": false,
"curly": false, "curly": false,
"no-console": [false], "no-console": [false],
"no-empty":false,
"ordered-imports": [false], "ordered-imports": [false],
"arrow-parens": false, "arrow-parens": false,
"object-literal-shorthand": false, "object-literal-shorthand": false,

View File

@ -14,13 +14,13 @@ module.exports = langs.map(([lang, locale]) => {
// Entries // Entries
const entry = { const entry = {
desktop: './src/web/app/desktop/script.js', desktop: './src/web/app/desktop/script.ts',
mobile: './src/web/app/mobile/script.js', mobile: './src/web/app/mobile/script.ts',
ch: './src/web/app/ch/script.js', ch: './src/web/app/ch/script.ts',
stats: './src/web/app/stats/script.js', stats: './src/web/app/stats/script.ts',
status: './src/web/app/status/script.js', status: './src/web/app/status/script.ts',
dev: './src/web/app/dev/script.js', dev: './src/web/app/dev/script.ts',
auth: './src/web/app/auth/script.js' auth: './src/web/app/auth/script.ts'
}; };
const output = { const output = {
@ -33,6 +33,11 @@ module.exports = langs.map(([lang, locale]) => {
entry, entry,
module: module_(lang, locale), module: module_(lang, locale),
plugins: plugins(version, lang), plugins: plugins(version, lang),
output output,
resolve: {
extensions: [
'.js', '.ts'
]
}
}; };
}); });